feat(acp): introduce threads (#8344)
Signed-off-by: Bradley Axen <baxen@squareup.com>
This commit is contained in:
@@ -9,6 +9,7 @@ export interface ExtMethodProvider {
|
||||
|
||||
import type {
|
||||
AddExtensionRequest,
|
||||
ArchiveSessionRequest,
|
||||
CheckSecretRequest,
|
||||
CheckSecretResponse,
|
||||
DeleteSessionRequest,
|
||||
@@ -16,8 +17,6 @@ import type {
|
||||
ExportSessionResponse,
|
||||
GetExtensionsRequest,
|
||||
GetExtensionsResponse,
|
||||
GetSessionRequest,
|
||||
GetSessionResponse,
|
||||
GetToolsRequest,
|
||||
GetToolsResponse,
|
||||
ImportSessionRequest,
|
||||
@@ -31,6 +30,7 @@ import type {
|
||||
RemoveConfigRequest,
|
||||
RemoveExtensionRequest,
|
||||
RemoveSecretRequest,
|
||||
UnarchiveSessionRequest,
|
||||
UpdateProviderRequest,
|
||||
UpdateProviderResponse,
|
||||
UpdateWorkingDirRequest,
|
||||
@@ -41,7 +41,6 @@ import {
|
||||
zCheckSecretResponse,
|
||||
zExportSessionResponse,
|
||||
zGetExtensionsResponse,
|
||||
zGetSessionResponse,
|
||||
zGetToolsResponse,
|
||||
zImportSessionResponse,
|
||||
zListProvidersResponse,
|
||||
@@ -77,29 +76,10 @@ export class GooseExtClient {
|
||||
await this.conn.extMethod("_goose/working_dir/update", params);
|
||||
}
|
||||
|
||||
async sessionGet(params: GetSessionRequest): Promise<GetSessionResponse> {
|
||||
const raw = await this.conn.extMethod("session/get", params);
|
||||
return zGetSessionResponse.parse(raw) as GetSessionResponse;
|
||||
}
|
||||
|
||||
async sessionDelete(params: DeleteSessionRequest): Promise<void> {
|
||||
await this.conn.extMethod("session/delete", params);
|
||||
}
|
||||
|
||||
async GooseSessionExport(
|
||||
params: ExportSessionRequest,
|
||||
): Promise<ExportSessionResponse> {
|
||||
const raw = await this.conn.extMethod("_goose/session/export", params);
|
||||
return zExportSessionResponse.parse(raw) as ExportSessionResponse;
|
||||
}
|
||||
|
||||
async GooseSessionImport(
|
||||
params: ImportSessionRequest,
|
||||
): Promise<ImportSessionResponse> {
|
||||
const raw = await this.conn.extMethod("_goose/session/import", params);
|
||||
return zImportSessionResponse.parse(raw) as ImportSessionResponse;
|
||||
}
|
||||
|
||||
async GooseConfigExtensions(
|
||||
params: GetExtensionsRequest,
|
||||
): Promise<GetExtensionsResponse> {
|
||||
@@ -153,4 +133,26 @@ export class GooseExtClient {
|
||||
async GooseSecretRemove(params: RemoveSecretRequest): Promise<void> {
|
||||
await this.conn.extMethod("_goose/secret/remove", params);
|
||||
}
|
||||
|
||||
async GooseSessionExport(
|
||||
params: ExportSessionRequest,
|
||||
): Promise<ExportSessionResponse> {
|
||||
const raw = await this.conn.extMethod("_goose/session/export", params);
|
||||
return zExportSessionResponse.parse(raw) as ExportSessionResponse;
|
||||
}
|
||||
|
||||
async GooseSessionImport(
|
||||
params: ImportSessionRequest,
|
||||
): Promise<ImportSessionResponse> {
|
||||
const raw = await this.conn.extMethod("_goose/session/import", params);
|
||||
return zImportSessionResponse.parse(raw) as ImportSessionResponse;
|
||||
}
|
||||
|
||||
async GooseSessionArchive(params: ArchiveSessionRequest): Promise<void> {
|
||||
await this.conn.extMethod("_goose/session/archive", params);
|
||||
}
|
||||
|
||||
async GooseSessionUnarchive(params: UnarchiveSessionRequest): Promise<void> {
|
||||
await this.conn.extMethod("_goose/session/unarchive", params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export type { AddExtensionRequest, CheckSecretRequest, CheckSecretResponse, DeleteSessionRequest, EmptyResponse, ExportSessionRequest, ExportSessionResponse, ExtRequest, ExtResponse, GetExtensionsRequest, GetExtensionsResponse, GetSessionRequest, GetSessionResponse, GetToolsRequest, GetToolsResponse, ImportSessionRequest, ImportSessionResponse, ListProvidersRequest, ListProvidersResponse, ProviderListEntry, ReadConfigRequest, ReadConfigResponse, ReadResourceRequest, ReadResourceResponse, RemoveConfigRequest, RemoveExtensionRequest, RemoveSecretRequest, UpdateProviderRequest, UpdateProviderResponse, UpdateWorkingDirRequest, UpsertConfigRequest, UpsertSecretRequest } from './types.gen.js';
|
||||
export type { AddExtensionRequest, ArchiveSessionRequest, CheckSecretRequest, CheckSecretResponse, DeleteSessionRequest, EmptyResponse, ExportSessionRequest, ExportSessionResponse, ExtRequest, ExtResponse, GetExtensionsRequest, GetExtensionsResponse, GetToolsRequest, GetToolsResponse, ImportSessionRequest, ImportSessionResponse, ListProvidersRequest, ListProvidersResponse, ProviderListEntry, ReadConfigRequest, ReadConfigResponse, ReadResourceRequest, ReadResourceResponse, RemoveConfigRequest, RemoveExtensionRequest, RemoveSecretRequest, UnarchiveSessionRequest, UpdateProviderRequest, UpdateProviderResponse, UpdateWorkingDirRequest, UpsertConfigRequest, UpsertSecretRequest } from './types.gen.js';
|
||||
|
||||
export const GOOSE_EXT_METHODS = [
|
||||
{
|
||||
@@ -28,26 +28,11 @@ export const GOOSE_EXT_METHODS = [
|
||||
requestType: "UpdateWorkingDirRequest",
|
||||
responseType: "EmptyResponse",
|
||||
},
|
||||
{
|
||||
method: "session/get",
|
||||
requestType: "GetSessionRequest",
|
||||
responseType: "GetSessionResponse",
|
||||
},
|
||||
{
|
||||
method: "session/delete",
|
||||
requestType: "DeleteSessionRequest",
|
||||
responseType: "EmptyResponse",
|
||||
},
|
||||
{
|
||||
method: "_goose/session/export",
|
||||
requestType: "ExportSessionRequest",
|
||||
responseType: "ExportSessionResponse",
|
||||
},
|
||||
{
|
||||
method: "_goose/session/import",
|
||||
requestType: "ImportSessionRequest",
|
||||
responseType: "ImportSessionResponse",
|
||||
},
|
||||
{
|
||||
method: "_goose/config/extensions",
|
||||
requestType: "GetExtensionsRequest",
|
||||
@@ -93,6 +78,26 @@ export const GOOSE_EXT_METHODS = [
|
||||
requestType: "RemoveSecretRequest",
|
||||
responseType: "EmptyResponse",
|
||||
},
|
||||
{
|
||||
method: "_goose/session/export",
|
||||
requestType: "ExportSessionRequest",
|
||||
responseType: "ExportSessionResponse",
|
||||
},
|
||||
{
|
||||
method: "_goose/session/import",
|
||||
requestType: "ImportSessionRequest",
|
||||
responseType: "ImportSessionResponse",
|
||||
},
|
||||
{
|
||||
method: "_goose/session/archive",
|
||||
requestType: "ArchiveSessionRequest",
|
||||
responseType: "EmptyResponse",
|
||||
},
|
||||
{
|
||||
method: "_goose/session/unarchive",
|
||||
requestType: "UnarchiveSessionRequest",
|
||||
responseType: "EmptyResponse",
|
||||
},
|
||||
] as const;
|
||||
|
||||
export type GooseExtMethod = (typeof GOOSE_EXT_METHODS)[number];
|
||||
|
||||
@@ -71,24 +71,6 @@ export type UpdateWorkingDirRequest = {
|
||||
workingDir: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a session by ID.
|
||||
*/
|
||||
export type GetSessionRequest = {
|
||||
sessionId: string;
|
||||
includeMessages?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a session response.
|
||||
*/
|
||||
export type GetSessionResponse = {
|
||||
/**
|
||||
* The session object with id, name, working_dir, timestamps, tokens, etc.
|
||||
*/
|
||||
session?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a session.
|
||||
*/
|
||||
@@ -96,37 +78,6 @@ export type DeleteSessionRequest = {
|
||||
sessionId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Export a session as a JSON string.
|
||||
*/
|
||||
export type ExportSessionRequest = {
|
||||
sessionId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Export session response.
|
||||
*/
|
||||
export type ExportSessionResponse = {
|
||||
data: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Import a session from a JSON string.
|
||||
*/
|
||||
export type ImportSessionRequest = {
|
||||
data: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Import session response.
|
||||
*/
|
||||
export type ImportSessionResponse = {
|
||||
/**
|
||||
* The imported session object.
|
||||
*/
|
||||
session?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* List configured extensions and any warnings.
|
||||
*/
|
||||
@@ -245,17 +196,62 @@ export type RemoveSecretRequest = {
|
||||
key: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Export a session as a JSON string.
|
||||
*/
|
||||
export type ExportSessionRequest = {
|
||||
sessionId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Export session response — raw JSON of the goose session with `conversation`.
|
||||
*/
|
||||
export type ExportSessionResponse = {
|
||||
data: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Import a session from a JSON string.
|
||||
*/
|
||||
export type ImportSessionRequest = {
|
||||
data: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Import session response — metadata about the newly created session.
|
||||
*/
|
||||
export type ImportSessionResponse = {
|
||||
sessionId: string;
|
||||
title?: string | null;
|
||||
updatedAt?: string | null;
|
||||
messageCount: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Archive a session (soft delete).
|
||||
*/
|
||||
export type ArchiveSessionRequest = {
|
||||
sessionId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unarchive a previously archived session.
|
||||
*/
|
||||
export type UnarchiveSessionRequest = {
|
||||
sessionId: string;
|
||||
};
|
||||
|
||||
export type ExtRequest = {
|
||||
id: string;
|
||||
method: string;
|
||||
params?: AddExtensionRequest | RemoveExtensionRequest | GetToolsRequest | ReadResourceRequest | UpdateWorkingDirRequest | GetSessionRequest | DeleteSessionRequest | ExportSessionRequest | ImportSessionRequest | GetExtensionsRequest | UpdateProviderRequest | ListProvidersRequest | ReadConfigRequest | UpsertConfigRequest | RemoveConfigRequest | CheckSecretRequest | UpsertSecretRequest | RemoveSecretRequest | {
|
||||
params?: AddExtensionRequest | RemoveExtensionRequest | GetToolsRequest | ReadResourceRequest | UpdateWorkingDirRequest | DeleteSessionRequest | GetExtensionsRequest | UpdateProviderRequest | ListProvidersRequest | ReadConfigRequest | UpsertConfigRequest | RemoveConfigRequest | CheckSecretRequest | UpsertSecretRequest | RemoveSecretRequest | ExportSessionRequest | ImportSessionRequest | ArchiveSessionRequest | UnarchiveSessionRequest | {
|
||||
[key: string]: unknown;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type ExtResponse = {
|
||||
id: string;
|
||||
result?: EmptyResponse | GetToolsResponse | ReadResourceResponse | GetSessionResponse | ExportSessionResponse | ImportSessionResponse | GetExtensionsResponse | UpdateProviderResponse | ListProvidersResponse | ReadConfigResponse | CheckSecretResponse | unknown;
|
||||
result?: EmptyResponse | GetToolsResponse | ReadResourceResponse | GetExtensionsResponse | UpdateProviderResponse | ListProvidersResponse | ReadConfigResponse | CheckSecretResponse | ExportSessionResponse | ImportSessionResponse | unknown;
|
||||
} | {
|
||||
error: {
|
||||
code: number;
|
||||
|
||||
@@ -61,21 +61,6 @@ export const zUpdateWorkingDirRequest = z.object({
|
||||
workingDir: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Get a session by ID.
|
||||
*/
|
||||
export const zGetSessionRequest = z.object({
|
||||
sessionId: z.string(),
|
||||
includeMessages: z.boolean().optional().default(false)
|
||||
});
|
||||
|
||||
/**
|
||||
* Get a session response.
|
||||
*/
|
||||
export const zGetSessionResponse = z.object({
|
||||
session: z.unknown().optional().default(null)
|
||||
});
|
||||
|
||||
/**
|
||||
* Delete a session.
|
||||
*/
|
||||
@@ -83,34 +68,6 @@ export const zDeleteSessionRequest = z.object({
|
||||
sessionId: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Export a session as a JSON string.
|
||||
*/
|
||||
export const zExportSessionRequest = z.object({
|
||||
sessionId: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Export session response.
|
||||
*/
|
||||
export const zExportSessionResponse = z.object({
|
||||
data: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Import a session from a JSON string.
|
||||
*/
|
||||
export const zImportSessionRequest = z.object({
|
||||
data: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Import session response.
|
||||
*/
|
||||
export const zImportSessionResponse = z.object({
|
||||
session: z.unknown().optional().default(null)
|
||||
});
|
||||
|
||||
/**
|
||||
* List configured extensions and any warnings.
|
||||
*/
|
||||
@@ -226,6 +183,57 @@ export const zRemoveSecretRequest = z.object({
|
||||
key: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Export a session as a JSON string.
|
||||
*/
|
||||
export const zExportSessionRequest = z.object({
|
||||
sessionId: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Export session response — raw JSON of the goose session with `conversation`.
|
||||
*/
|
||||
export const zExportSessionResponse = z.object({
|
||||
data: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Import a session from a JSON string.
|
||||
*/
|
||||
export const zImportSessionRequest = z.object({
|
||||
data: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Import session response — metadata about the newly created session.
|
||||
*/
|
||||
export const zImportSessionResponse = z.object({
|
||||
sessionId: z.string(),
|
||||
title: z.union([
|
||||
z.string(),
|
||||
z.null()
|
||||
]).optional(),
|
||||
updatedAt: z.union([
|
||||
z.string(),
|
||||
z.null()
|
||||
]).optional(),
|
||||
messageCount: z.coerce.bigint().gte(BigInt(0)).max(BigInt('18446744073709551615'), { message: 'Invalid value: Expected uint64 to be <= 18446744073709551615' })
|
||||
});
|
||||
|
||||
/**
|
||||
* Archive a session (soft delete).
|
||||
*/
|
||||
export const zArchiveSessionRequest = z.object({
|
||||
sessionId: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Unarchive a previously archived session.
|
||||
*/
|
||||
export const zUnarchiveSessionRequest = z.object({
|
||||
sessionId: z.string()
|
||||
});
|
||||
|
||||
export const zExtRequest = z.object({
|
||||
id: z.string(),
|
||||
method: z.string(),
|
||||
@@ -236,10 +244,7 @@ export const zExtRequest = z.object({
|
||||
zGetToolsRequest,
|
||||
zReadResourceRequest,
|
||||
zUpdateWorkingDirRequest,
|
||||
zGetSessionRequest,
|
||||
zDeleteSessionRequest,
|
||||
zExportSessionRequest,
|
||||
zImportSessionRequest,
|
||||
zGetExtensionsRequest,
|
||||
zUpdateProviderRequest,
|
||||
zListProvidersRequest,
|
||||
@@ -248,7 +253,11 @@ export const zExtRequest = z.object({
|
||||
zRemoveConfigRequest,
|
||||
zCheckSecretRequest,
|
||||
zUpsertSecretRequest,
|
||||
zRemoveSecretRequest
|
||||
zRemoveSecretRequest,
|
||||
zExportSessionRequest,
|
||||
zImportSessionRequest,
|
||||
zArchiveSessionRequest,
|
||||
zUnarchiveSessionRequest
|
||||
]),
|
||||
z.union([
|
||||
z.record(z.unknown()),
|
||||
@@ -265,14 +274,13 @@ export const zExtResponse = z.union([
|
||||
zEmptyResponse,
|
||||
zGetToolsResponse,
|
||||
zReadResourceResponse,
|
||||
zGetSessionResponse,
|
||||
zExportSessionResponse,
|
||||
zImportSessionResponse,
|
||||
zGetExtensionsResponse,
|
||||
zUpdateProviderResponse,
|
||||
zListProvidersResponse,
|
||||
zReadConfigResponse,
|
||||
zCheckSecretResponse
|
||||
zCheckSecretResponse,
|
||||
zExportSessionResponse,
|
||||
zImportSessionResponse
|
||||
]),
|
||||
z.unknown()
|
||||
]).optional()
|
||||
|
||||
@@ -7748,6 +7748,10 @@
|
||||
"session_type": {
|
||||
"$ref": "#/components/schemas/SessionType"
|
||||
},
|
||||
"thread_id": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"total_tokens": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
|
||||
@@ -1232,6 +1232,7 @@ export type Session = {
|
||||
recipe?: Recipe | null;
|
||||
schedule_id?: string | null;
|
||||
session_type?: SessionType;
|
||||
thread_id?: string | null;
|
||||
total_tokens?: number | null;
|
||||
updated_at: string;
|
||||
user_recipe_values?: {
|
||||
|
||||
Reference in New Issue
Block a user