rust acp client for extension methods (#8227)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import type {
|
||||
DeleteSessionRequest,
|
||||
ExportSessionRequest,
|
||||
ExportSessionResponse,
|
||||
GetExtensionsRequest,
|
||||
GetExtensionsResponse,
|
||||
GetSessionRequest,
|
||||
GetSessionResponse,
|
||||
@@ -83,8 +84,10 @@ export class GooseExtClient {
|
||||
return zImportSessionResponse.parse(raw) as ImportSessionResponse;
|
||||
}
|
||||
|
||||
async GooseConfigExtensions(): Promise<GetExtensionsResponse> {
|
||||
const raw = await this.conn.extMethod("_goose/config/extensions", {});
|
||||
async GooseConfigExtensions(
|
||||
params: GetExtensionsRequest,
|
||||
): Promise<GetExtensionsResponse> {
|
||||
const raw = await this.conn.extMethod("_goose/config/extensions", params);
|
||||
return zGetExtensionsResponse.parse(raw) as GetExtensionsResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// 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, ReadResourceRequest, ReadResourceResponse, RemoveExtensionRequest, UpdateWorkingDirRequest } from './types.gen.js';
|
||||
export type { AddExtensionRequest, DeleteSessionRequest, EmptyResponse, ExportSessionRequest, ExportSessionResponse, ExtRequest, ExtResponse, GetExtensionsRequest, GetExtensionsResponse, GetSessionRequest, GetSessionResponse, GetToolsRequest, GetToolsResponse, ImportSessionRequest, ImportSessionResponse, ReadResourceRequest, ReadResourceResponse, RemoveExtensionRequest, UpdateWorkingDirRequest } from './types.gen.js';
|
||||
|
||||
export const GOOSE_EXT_METHODS = [
|
||||
{
|
||||
@@ -50,7 +50,7 @@ export const GOOSE_EXT_METHODS = [
|
||||
},
|
||||
{
|
||||
method: "_goose/config/extensions",
|
||||
requestType: null,
|
||||
requestType: "GetExtensionsRequest",
|
||||
responseType: "GetExtensionsResponse",
|
||||
},
|
||||
] as const;
|
||||
|
||||
@@ -9,7 +9,7 @@ export type AddExtensionRequest = {
|
||||
/**
|
||||
* Extension configuration (see ExtensionConfig variants: Stdio, StreamableHttp, Builtin, Platform).
|
||||
*/
|
||||
config: unknown;
|
||||
config?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -34,6 +34,9 @@ export type GetToolsRequest = {
|
||||
sessionId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tools response.
|
||||
*/
|
||||
export type GetToolsResponse = {
|
||||
/**
|
||||
* Array of tool info objects with `name`, `description`, `parameters`, and optional `permission`.
|
||||
@@ -50,11 +53,14 @@ export type ReadResourceRequest = {
|
||||
extensionName: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resource read response.
|
||||
*/
|
||||
export type ReadResourceResponse = {
|
||||
/**
|
||||
* The resource result from the extension (MCP ReadResourceResult).
|
||||
*/
|
||||
result: unknown;
|
||||
result?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -80,7 +86,7 @@ export type GetSessionResponse = {
|
||||
/**
|
||||
* The session object with id, name, working_dir, timestamps, tokens, etc.
|
||||
*/
|
||||
session: unknown;
|
||||
session?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -97,6 +103,9 @@ export type ExportSessionRequest = {
|
||||
sessionId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Export session response.
|
||||
*/
|
||||
export type ExportSessionResponse = {
|
||||
data: string;
|
||||
};
|
||||
@@ -108,11 +117,21 @@ export type ImportSessionRequest = {
|
||||
data: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Import session response.
|
||||
*/
|
||||
export type ImportSessionResponse = {
|
||||
/**
|
||||
* The imported session object.
|
||||
*/
|
||||
session: unknown;
|
||||
session?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* List configured extensions and any warnings.
|
||||
*/
|
||||
export type GetExtensionsRequest = {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -129,7 +148,7 @@ export type GetExtensionsResponse = {
|
||||
export type ExtRequest = {
|
||||
id: string;
|
||||
method: string;
|
||||
params?: AddExtensionRequest | RemoveExtensionRequest | GetToolsRequest | ReadResourceRequest | UpdateWorkingDirRequest | GetSessionRequest | DeleteSessionRequest | ExportSessionRequest | ImportSessionRequest | {
|
||||
params?: AddExtensionRequest | RemoveExtensionRequest | GetToolsRequest | ReadResourceRequest | UpdateWorkingDirRequest | GetSessionRequest | DeleteSessionRequest | ExportSessionRequest | ImportSessionRequest | GetExtensionsRequest | {
|
||||
[key: string]: unknown;
|
||||
} | null;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
||||
*/
|
||||
export const zAddExtensionRequest = z.object({
|
||||
sessionId: z.string(),
|
||||
config: z.unknown()
|
||||
config: z.unknown().optional().default(null)
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -30,6 +30,9 @@ export const zGetToolsRequest = z.object({
|
||||
sessionId: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Tools response.
|
||||
*/
|
||||
export const zGetToolsResponse = z.object({
|
||||
tools: z.array(z.unknown())
|
||||
});
|
||||
@@ -43,8 +46,11 @@ export const zReadResourceRequest = z.object({
|
||||
extensionName: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Resource read response.
|
||||
*/
|
||||
export const zReadResourceResponse = z.object({
|
||||
result: z.unknown()
|
||||
result: z.unknown().optional().default(null)
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -67,7 +73,7 @@ export const zGetSessionRequest = z.object({
|
||||
* Get a session response.
|
||||
*/
|
||||
export const zGetSessionResponse = z.object({
|
||||
session: z.unknown()
|
||||
session: z.unknown().optional().default(null)
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -84,6 +90,9 @@ export const zExportSessionRequest = z.object({
|
||||
sessionId: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Export session response.
|
||||
*/
|
||||
export const zExportSessionResponse = z.object({
|
||||
data: z.string()
|
||||
});
|
||||
@@ -95,10 +104,18 @@ export const zImportSessionRequest = z.object({
|
||||
data: z.string()
|
||||
});
|
||||
|
||||
/**
|
||||
* Import session response.
|
||||
*/
|
||||
export const zImportSessionResponse = z.object({
|
||||
session: z.unknown()
|
||||
session: z.unknown().optional().default(null)
|
||||
});
|
||||
|
||||
/**
|
||||
* List configured extensions and any warnings.
|
||||
*/
|
||||
export const zGetExtensionsRequest = z.record(z.unknown());
|
||||
|
||||
/**
|
||||
* List configured extensions and any warnings.
|
||||
*/
|
||||
@@ -120,7 +137,8 @@ export const zExtRequest = z.object({
|
||||
zGetSessionRequest,
|
||||
zDeleteSessionRequest,
|
||||
zExportSessionRequest,
|
||||
zImportSessionRequest
|
||||
zImportSessionRequest,
|
||||
zGetExtensionsRequest
|
||||
]),
|
||||
z.union([
|
||||
z.record(z.unknown()),
|
||||
|
||||
Reference in New Issue
Block a user