feat(acp): add session/set_config and stabilize list, delete and close (#7984)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Adrian Cole
2026-03-22 18:33:26 -04:00
committed by GitHub
parent 6afaeb8432
commit 1426c8bfa0
32 changed files with 2539 additions and 1100 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ async function generateClient(meta: { methods: MethodMeta[] }) {
for (const m of meta.methods) {
const fnName = methodToCamelCase(m.method);
const fullMethod = `_goose/${m.method}`;
const fullMethod = m.method;
let paramType = "";
let paramArg = "";
+10 -21
View File
@@ -19,7 +19,6 @@ import type {
GetToolsResponse,
ImportSessionRequest,
ImportSessionResponse,
ListSessionsResponse,
ReadResourceRequest,
ReadResourceResponse,
RemoveExtensionRequest,
@@ -31,70 +30,60 @@ import {
zGetSessionResponse,
zGetToolsResponse,
zImportSessionResponse,
zListSessionsResponse,
zReadResourceResponse,
} from './zod.gen.js';
/**
* Typed client for Goose custom extension methods.
* Wraps an ExtMethodProvider (e.g. ClientSideConnection) with proper types and Zod validation.
*/
export class GooseExtClient {
constructor(private conn: ExtMethodProvider) {}
async extensionsAdd(params: AddExtensionRequest): Promise<void> {
async GooseExtensionsAdd(params: AddExtensionRequest): Promise<void> {
await this.conn.extMethod("_goose/extensions/add", params);
}
async extensionsRemove(params: RemoveExtensionRequest): Promise<void> {
async GooseExtensionsRemove(params: RemoveExtensionRequest): Promise<void> {
await this.conn.extMethod("_goose/extensions/remove", params);
}
async tools(params: GetToolsRequest): Promise<GetToolsResponse> {
async GooseTools(params: GetToolsRequest): Promise<GetToolsResponse> {
const raw = await this.conn.extMethod("_goose/tools", params);
return zGetToolsResponse.parse(raw) as GetToolsResponse;
}
async resourceRead(
async GooseResourceRead(
params: ReadResourceRequest,
): Promise<ReadResourceResponse> {
const raw = await this.conn.extMethod("_goose/resource/read", params);
return zReadResourceResponse.parse(raw) as ReadResourceResponse;
}
async workingDirUpdate(params: UpdateWorkingDirRequest): Promise<void> {
async GooseWorkingDirUpdate(params: UpdateWorkingDirRequest): Promise<void> {
await this.conn.extMethod("_goose/working_dir/update", params);
}
async sessionList(): Promise<ListSessionsResponse> {
const raw = await this.conn.extMethod("_goose/session/list", {});
return zListSessionsResponse.parse(raw) as ListSessionsResponse;
}
async sessionGet(params: GetSessionRequest): Promise<GetSessionResponse> {
const raw = await this.conn.extMethod("_goose/session/get", params);
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("_goose/session/delete", params);
await this.conn.extMethod("session/delete", params);
}
async sessionExport(
async GooseSessionExport(
params: ExportSessionRequest,
): Promise<ExportSessionResponse> {
const raw = await this.conn.extMethod("_goose/session/export", params);
return zExportSessionResponse.parse(raw) as ExportSessionResponse;
}
async sessionImport(
async GooseSessionImport(
params: ImportSessionRequest,
): Promise<ImportSessionResponse> {
const raw = await this.conn.extMethod("_goose/session/import", params);
return zImportSessionResponse.parse(raw) as ImportSessionResponse;
}
async configExtensions(): Promise<GetExtensionsResponse> {
async GooseConfigExtensions(): Promise<GetExtensionsResponse> {
const raw = await this.conn.extMethod("_goose/config/extensions", {});
return zGetExtensionsResponse.parse(raw) as GetExtensionsResponse;
}
+9 -14
View File
@@ -1,38 +1,33 @@
// This file is auto-generated by @hey-api/openapi-ts
export type { AddExtensionRequest, DeleteSessionRequest, EmptyResponse, ExportSessionRequest, ExportSessionResponse, ExtRequest, ExtResponse, GetExtensionsResponse, GetSessionRequest, GetSessionResponse, GetToolsRequest, GetToolsResponse, ImportSessionRequest, ImportSessionResponse, ListSessionsResponse, ReadResourceRequest, ReadResourceResponse, RemoveExtensionRequest, UpdateWorkingDirRequest } from './types.gen.js';
export type { AddExtensionRequest, DeleteSessionRequest, EmptyResponse, ExportSessionRequest, ExportSessionResponse, ExtRequest, ExtResponse, GetExtensionsResponse, GetSessionRequest, GetSessionResponse, GetToolsRequest, GetToolsResponse, ImportSessionRequest, ImportSessionResponse, ReadResourceRequest, ReadResourceResponse, RemoveExtensionRequest, UpdateWorkingDirRequest } from './types.gen.js';
export const GOOSE_EXT_METHODS = [
{
method: "extensions/add",
method: "_goose/extensions/add",
requestType: "AddExtensionRequest",
responseType: "EmptyResponse",
},
{
method: "extensions/remove",
method: "_goose/extensions/remove",
requestType: "RemoveExtensionRequest",
responseType: "EmptyResponse",
},
{
method: "tools",
method: "_goose/tools",
requestType: "GetToolsRequest",
responseType: "GetToolsResponse",
},
{
method: "resource/read",
method: "_goose/resource/read",
requestType: "ReadResourceRequest",
responseType: "ReadResourceResponse",
},
{
method: "working_dir/update",
method: "_goose/working_dir/update",
requestType: "UpdateWorkingDirRequest",
responseType: "EmptyResponse",
},
{
method: "session/list",
requestType: null,
responseType: "ListSessionsResponse",
},
{
method: "session/get",
requestType: "GetSessionRequest",
@@ -44,17 +39,17 @@ export const GOOSE_EXT_METHODS = [
responseType: "EmptyResponse",
},
{
method: "session/export",
method: "_goose/session/export",
requestType: "ExportSessionRequest",
responseType: "ExportSessionResponse",
},
{
method: "session/import",
method: "_goose/session/import",
requestType: "ImportSessionRequest",
responseType: "ImportSessionResponse",
},
{
method: "config/extensions",
method: "_goose/config/extensions",
requestType: null,
responseType: "GetExtensionsResponse",
},
+12 -30
View File
@@ -3,10 +3,9 @@
/**
* Add an extension to an active session.
* Method: `_agent/extensions/add`
*/
export type AddExtensionRequest = {
session_id: string;
sessionId: string;
/**
* Extension configuration (see ExtensionConfig variants: Stdio, StreamableHttp, Builtin, Platform).
*/
@@ -22,19 +21,17 @@ export type EmptyResponse = {
/**
* Remove an extension from an active session.
* Method: `_agent/extensions/remove`
*/
export type RemoveExtensionRequest = {
session_id: string;
sessionId: string;
name: string;
};
/**
* List all tools available in a session.
* Method: `_agent/tools`
*/
export type GetToolsRequest = {
session_id: string;
sessionId: string;
};
export type GetToolsResponse = {
@@ -46,12 +43,11 @@ export type GetToolsResponse = {
/**
* Read a resource from an extension.
* Method: `_agent/resource/read`
*/
export type ReadResourceRequest = {
session_id: string;
sessionId: string;
uri: string;
extension_name: string;
extensionName: string;
};
export type ReadResourceResponse = {
@@ -63,28 +59,18 @@ export type ReadResourceResponse = {
/**
* Update the working directory for a session.
* Method: `_agent/working_dir/update`
*/
export type UpdateWorkingDirRequest = {
session_id: string;
working_dir: string;
};
/**
* List all sessions.
* Method: `_session/list`
*/
export type ListSessionsResponse = {
sessions: Array<unknown>;
sessionId: string;
workingDir: string;
};
/**
* Get a session by ID.
* Method: `_session/get`
*/
export type GetSessionRequest = {
session_id: string;
include_messages?: boolean;
sessionId: string;
includeMessages?: boolean;
};
/**
@@ -99,18 +85,16 @@ export type GetSessionResponse = {
/**
* Delete a session.
* Method: `_session/delete`
*/
export type DeleteSessionRequest = {
session_id: string;
sessionId: string;
};
/**
* Export a session as a JSON string.
* Method: `_session/export`
*/
export type ExportSessionRequest = {
session_id: string;
sessionId: string;
};
export type ExportSessionResponse = {
@@ -119,7 +103,6 @@ export type ExportSessionResponse = {
/**
* Import a session from a JSON string.
* Method: `_session/import`
*/
export type ImportSessionRequest = {
data: string;
@@ -134,7 +117,6 @@ export type ImportSessionResponse = {
/**
* List configured extensions and any warnings.
* Method: `_config/extensions`
*/
export type GetExtensionsResponse = {
/**
@@ -154,7 +136,7 @@ export type ExtRequest = {
export type ExtResponse = {
id: string;
result?: EmptyResponse | GetToolsResponse | ReadResourceResponse | ListSessionsResponse | GetSessionResponse | ExportSessionResponse | ImportSessionResponse | GetExtensionsResponse | unknown;
result?: EmptyResponse | GetToolsResponse | ReadResourceResponse | GetSessionResponse | ExportSessionResponse | ImportSessionResponse | GetExtensionsResponse | unknown;
} | {
error: {
code: number;
+11 -30
View File
@@ -4,10 +4,9 @@ import { z } from 'zod';
/**
* Add an extension to an active session.
* Method: `_agent/extensions/add`
*/
export const zAddExtensionRequest = z.object({
session_id: z.string(),
sessionId: z.string(),
config: z.unknown()
});
@@ -18,19 +17,17 @@ export const zEmptyResponse = z.record(z.unknown());
/**
* Remove an extension from an active session.
* Method: `_agent/extensions/remove`
*/
export const zRemoveExtensionRequest = z.object({
session_id: z.string(),
sessionId: z.string(),
name: z.string()
});
/**
* List all tools available in a session.
* Method: `_agent/tools`
*/
export const zGetToolsRequest = z.object({
session_id: z.string()
sessionId: z.string()
});
export const zGetToolsResponse = z.object({
@@ -39,12 +36,11 @@ export const zGetToolsResponse = z.object({
/**
* Read a resource from an extension.
* Method: `_agent/resource/read`
*/
export const zReadResourceRequest = z.object({
session_id: z.string(),
sessionId: z.string(),
uri: z.string(),
extension_name: z.string()
extensionName: z.string()
});
export const zReadResourceResponse = z.object({
@@ -53,28 +49,18 @@ export const zReadResourceResponse = z.object({
/**
* Update the working directory for a session.
* Method: `_agent/working_dir/update`
*/
export const zUpdateWorkingDirRequest = z.object({
session_id: z.string(),
working_dir: z.string()
});
/**
* List all sessions.
* Method: `_session/list`
*/
export const zListSessionsResponse = z.object({
sessions: z.array(z.unknown())
sessionId: z.string(),
workingDir: z.string()
});
/**
* Get a session by ID.
* Method: `_session/get`
*/
export const zGetSessionRequest = z.object({
session_id: z.string(),
include_messages: z.boolean().optional().default(false)
sessionId: z.string(),
includeMessages: z.boolean().optional().default(false)
});
/**
@@ -86,18 +72,16 @@ export const zGetSessionResponse = z.object({
/**
* Delete a session.
* Method: `_session/delete`
*/
export const zDeleteSessionRequest = z.object({
session_id: z.string()
sessionId: z.string()
});
/**
* Export a session as a JSON string.
* Method: `_session/export`
*/
export const zExportSessionRequest = z.object({
session_id: z.string()
sessionId: z.string()
});
export const zExportSessionResponse = z.object({
@@ -106,7 +90,6 @@ export const zExportSessionResponse = z.object({
/**
* Import a session from a JSON string.
* Method: `_session/import`
*/
export const zImportSessionRequest = z.object({
data: z.string()
@@ -118,7 +101,6 @@ export const zImportSessionResponse = z.object({
/**
* List configured extensions and any warnings.
* Method: `_config/extensions`
*/
export const zGetExtensionsResponse = z.object({
extensions: z.array(z.unknown()),
@@ -155,7 +137,6 @@ export const zExtResponse = z.union([
zEmptyResponse,
zGetToolsResponse,
zReadResourceResponse,
zListSessionsResponse,
zGetSessionResponse,
zExportSessionResponse,
zImportSessionResponse,