mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-19 16:03:35 +00:00
Change getAllTools() to return ToolInfo[] instead of string[]
Breaking change: pi.getAllTools() now returns Array<{ name, description }>
instead of string[]. Extensions needing just names can use .map(t => t.name).
Removes redundant getToolInfo() method added in original PR.
Fixes #647
This commit is contained in:
parent
34ecca352e
commit
1367a76ee8
12 changed files with 34 additions and 19 deletions
|
|
@ -459,10 +459,13 @@ export class AgentSession {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all configured tool names (built-in via --tools or default, plus custom tools).
|
||||
* Get all configured tools with name and description.
|
||||
*/
|
||||
getAllToolNames(): string[] {
|
||||
return Array.from(this._toolRegistry.keys());
|
||||
getAllTools(): Array<{ name: string; description: string }> {
|
||||
return Array.from(this._toolRegistry.values()).map((t) => ({
|
||||
name: t.name,
|
||||
description: t.description,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ export type {
|
|||
ToolCallEventResult,
|
||||
// Tools
|
||||
ToolDefinition,
|
||||
ToolInfo,
|
||||
ToolRenderResultOptions,
|
||||
ToolResultEvent,
|
||||
ToolResultEventResult,
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ function createExtensionAPI(
|
|||
return runtime.getActiveTools();
|
||||
},
|
||||
|
||||
getAllTools(): string[] {
|
||||
getAllTools() {
|
||||
return runtime.getAllTools();
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -743,8 +743,8 @@ export interface ExtensionAPI {
|
|||
/** Get the list of currently active tool names. */
|
||||
getActiveTools(): string[];
|
||||
|
||||
/** Get all configured tools (built-in + extension tools). */
|
||||
getAllTools(): string[];
|
||||
/** Get all configured tools with name and description. */
|
||||
getAllTools(): ToolInfo[];
|
||||
|
||||
/** Set the active tools by name. */
|
||||
setActiveTools(toolNames: string[]): void;
|
||||
|
|
@ -813,7 +813,10 @@ export type GetSessionNameHandler = () => string | undefined;
|
|||
|
||||
export type GetActiveToolsHandler = () => string[];
|
||||
|
||||
export type GetAllToolsHandler = () => string[];
|
||||
/** Tool info with name and description */
|
||||
export type ToolInfo = Pick<ToolDefinition, "name" | "description">;
|
||||
|
||||
export type GetAllToolsHandler = () => ToolInfo[];
|
||||
|
||||
export type SetActiveToolsHandler = (toolNames: string[]) => void;
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ export type {
|
|||
SessionTreeEvent,
|
||||
ToolCallEvent,
|
||||
ToolDefinition,
|
||||
ToolInfo,
|
||||
ToolRenderResultOptions,
|
||||
ToolResultEvent,
|
||||
TurnEndEvent,
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ export class InteractiveMode {
|
|||
return this.sessionManager.getSessionName();
|
||||
},
|
||||
getActiveTools: () => this.session.getActiveToolNames(),
|
||||
getAllTools: () => this.session.getAllToolNames(),
|
||||
getAllTools: () => this.session.getAllTools(),
|
||||
setActiveTools: (toolNames) => this.session.setActiveToolsByName(toolNames),
|
||||
setModel: async (model) => {
|
||||
const key = await this.session.modelRegistry.getApiKey(model);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export async function runPrintMode(session: AgentSession, options: PrintModeOpti
|
|||
return session.sessionManager.getSessionName();
|
||||
},
|
||||
getActiveTools: () => session.getActiveToolNames(),
|
||||
getAllTools: () => session.getAllToolNames(),
|
||||
getAllTools: () => session.getAllTools(),
|
||||
setActiveTools: (toolNames: string[]) => session.setActiveToolsByName(toolNames),
|
||||
setModel: async (model) => {
|
||||
const key = await session.modelRegistry.getApiKey(model);
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
return session.sessionManager.getSessionName();
|
||||
},
|
||||
getActiveTools: () => session.getActiveToolNames(),
|
||||
getAllTools: () => session.getAllToolNames(),
|
||||
getAllTools: () => session.getAllTools(),
|
||||
setActiveTools: (toolNames: string[]) => session.setActiveToolsByName(toolNames),
|
||||
setModel: async (model) => {
|
||||
const key = await session.modelRegistry.getApiKey(model);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue