mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 10:03:27 +00:00
fix(coding-agent): support dynamic tool registration and tool prompt snippets closes #1720
This commit is contained in:
parent
ca5510158d
commit
bc2fa8d6d0
12 changed files with 285 additions and 47 deletions
|
|
@ -119,6 +119,8 @@ export function createExtensionRuntime(): ExtensionRuntime {
|
|||
getActiveTools: notInitialized,
|
||||
getAllTools: notInitialized,
|
||||
setActiveTools: notInitialized,
|
||||
// registerTool() is valid during extension load; refresh is only needed post-bind.
|
||||
refreshTools: () => {},
|
||||
getCommands: notInitialized,
|
||||
setModel: () => Promise.reject(new Error("Extension runtime not initialized")),
|
||||
getThinkingLevel: notInitialized,
|
||||
|
|
@ -162,6 +164,7 @@ function createExtensionAPI(
|
|||
definition: tool,
|
||||
extensionPath: extension.path,
|
||||
});
|
||||
runtime.refreshTools();
|
||||
},
|
||||
|
||||
registerCommand(name: string, options: Omit<RegisteredCommand, "name">): void {
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ export class ExtensionRunner {
|
|||
this.runtime.getActiveTools = actions.getActiveTools;
|
||||
this.runtime.getAllTools = actions.getAllTools;
|
||||
this.runtime.setActiveTools = actions.setActiveTools;
|
||||
this.runtime.refreshTools = actions.refreshTools;
|
||||
this.runtime.getCommands = actions.getCommands;
|
||||
this.runtime.setModel = actions.setModel;
|
||||
this.runtime.getThinkingLevel = actions.getThinkingLevel;
|
||||
|
|
|
|||
|
|
@ -339,6 +339,8 @@ export interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = un
|
|||
label: string;
|
||||
/** Description for LLM */
|
||||
description: string;
|
||||
/** Optional one-line snippet for the Available tools section in the default system prompt. Falls back to description when omitted. */
|
||||
promptSnippet?: string;
|
||||
/** Parameter schema (TypeBox) */
|
||||
parameters: TParams;
|
||||
|
||||
|
|
@ -1251,6 +1253,8 @@ export type GetCommandsHandler = () => SlashCommandInfo[];
|
|||
|
||||
export type SetActiveToolsHandler = (toolNames: string[]) => void;
|
||||
|
||||
export type RefreshToolsHandler = () => void;
|
||||
|
||||
export type SetModelHandler = (model: Model<any>) => Promise<boolean>;
|
||||
|
||||
export type GetThinkingLevelHandler = () => ThinkingLevel;
|
||||
|
|
@ -1291,6 +1295,7 @@ export interface ExtensionActions {
|
|||
getActiveTools: GetActiveToolsHandler;
|
||||
getAllTools: GetAllToolsHandler;
|
||||
setActiveTools: SetActiveToolsHandler;
|
||||
refreshTools: RefreshToolsHandler;
|
||||
getCommands: GetCommandsHandler;
|
||||
setModel: SetModelHandler;
|
||||
getThinkingLevel: GetThinkingLevelHandler;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue