Squashed 'third_party/pi/' content from commit d981de122
git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
26
packages/coding-agent/examples/extensions/hello.ts
Normal file
26
packages/coding-agent/examples/extensions/hello.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Hello Tool - Minimal custom tool example
|
||||
*/
|
||||
|
||||
import { Type } from "@earendil-works/pi-ai";
|
||||
import { defineTool, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
||||
|
||||
const helloTool = defineTool({
|
||||
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) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Hello, ${params.name}!` }],
|
||||
details: { greeted: params.name },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
pi.registerTool(helloTool);
|
||||
}
|
||||
Reference in New Issue
Block a user