Files
oh-my-pi/packages/coding-agent/examples/extensions/hello.ts
T

34 lines
842 B
TypeScript

/**
* Hello Tool - Minimal custom tool example
*
* Demonstrates using ExtensionAPI's logger, typebox, and pi module access.
*/
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
export default function (pi: ExtensionAPI) {
// Access TypeBox via pi.typebox (no need to import separately)
const { Type } = pi.typebox;
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, _onUpdate, _ctx, _signal) {
const { name } = params as { name: string };
// Use logger for debugging
pi.logger.debug("Hello tool executed", { name });
return {
content: [{ type: "text", text: `Hello, ${name}!` }],
details: { greeted: name },
};
},
});
}