feat(tools): add getToolExplanation() method with XML examples for LLM tool calling
Each tool now provides comprehensive documentation including parameter schemas and concrete <tool_call> XML examples. This helps smaller LLMs understand the exact format required for tool invocation.
This commit is contained in:
@@ -164,6 +164,45 @@ export class DenoTool extends BaseToolWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public getToolExplanation(): string {
|
||||
return `## Tool: deno
|
||||
Execute TypeScript/JavaScript code in a sandboxed Deno environment with fine-grained permission control.
|
||||
|
||||
### Actions:
|
||||
|
||||
**execute** - Execute TypeScript/JavaScript code and return stdout/stderr
|
||||
Parameters:
|
||||
- code (required): TypeScript/JavaScript code to execute
|
||||
- permissions (optional): Array of Deno permissions to grant. Options: "all", "env", "net", "read", "write", "run", "sys", "ffi", "hrtime". Default: none (fully sandboxed)
|
||||
|
||||
Example - Simple execution:
|
||||
<tool_call>
|
||||
<tool>deno</tool>
|
||||
<action>execute</action>
|
||||
<params>{"code": "console.log('Hello from Deno!');"}</params>
|
||||
</tool_call>
|
||||
|
||||
Example - With network permission:
|
||||
<tool_call>
|
||||
<tool>deno</tool>
|
||||
<action>execute</action>
|
||||
<params>{"code": "const resp = await fetch('https://api.example.com/data');\\nconsole.log(await resp.text());", "permissions": ["net"]}</params>
|
||||
</tool_call>
|
||||
|
||||
**executeWithResult** - Execute code that outputs JSON on the last line of stdout
|
||||
Parameters:
|
||||
- code (required): Code that console.logs a JSON value on the final line
|
||||
- permissions (optional): Array of Deno permissions to grant
|
||||
|
||||
Example:
|
||||
<tool_call>
|
||||
<tool>deno</tool>
|
||||
<action>executeWithResult</action>
|
||||
<params>{"code": "const result = { sum: 1 + 2, product: 2 * 3 };\\nconsole.log(JSON.stringify(result));"}</params>
|
||||
</tool_call>
|
||||
`;
|
||||
}
|
||||
|
||||
public getCallSummary(action: string, params: Record<string, unknown>): string {
|
||||
const code = params.code as string;
|
||||
const permissions = (params.permissions as string[]) || [];
|
||||
|
||||
Reference in New Issue
Block a user