mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
BREAKING CHANGE: ToolDefinition.execute parameter order changed from (id, params, onUpdate, ctx, signal) to (id, params, signal, onUpdate, ctx). This aligns with AgentTool.execute so wrapping built-in tools no longer requires parameter reordering. Update extensions by swapping signal and onUpdate parameters.
25 lines
627 B
TypeScript
25 lines
627 B
TypeScript
/**
|
|
* Hello Tool - Minimal custom tool example
|
|
*/
|
|
|
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
import { Type } from "@sinclair/typebox";
|
|
|
|
export default function (pi: ExtensionAPI) {
|
|
pi.registerTool({
|
|
name: "hello",
|
|
label: "Hello",
|
|
description: "A simple greeting tool",
|
|
parameters: Type.Object({
|
|
name: Type.String({ description: "Name to greet" }),
|
|
}),
|
|
|
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
const { name } = params as { name: string };
|
|
return {
|
|
content: [{ type: "text", text: `Hello, ${name}!` }],
|
|
details: { greeted: name },
|
|
};
|
|
},
|
|
});
|
|
}
|