2867e1f4e3
- Added canonical `pi.zod` schema API exports and removed TypeBox package exports/imports. - Migrated Tool schema typing from TypeBox to shared `TSchema`/Zod flow with legacy TypeBox compatibility. - Updated AI provider adapters and MCP/agent builders to convert tool params through `toolWireSchema()`. - Reworked schema validation from AJV to Zod-safe parsing with `fromTypeBox`, `toolWireSchema`, and meta schema checks.
32 lines
747 B
TypeScript
32 lines
747 B
TypeScript
/**
|
|
* Hello Tool - Minimal custom tool example
|
|
*
|
|
* Demonstrates using ExtensionAPI's logger, injected `pi.zod`, and pi module access.
|
|
*/
|
|
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
|
|
export default function (pi: ExtensionAPI) {
|
|
const { z } = pi.zod;
|
|
|
|
pi.registerTool({
|
|
name: "hello",
|
|
label: "Hello",
|
|
description: "A simple greeting tool",
|
|
parameters: z.object({
|
|
name: z.string().describe("Name to greet"),
|
|
}),
|
|
|
|
async execute(_toolCallId, params, _onUpdate, _ctx, _signal) {
|
|
const { name } = params;
|
|
|
|
// Use logger for debugging
|
|
pi.logger.debug("Hello tool executed", { name });
|
|
|
|
return {
|
|
content: [{ type: "text", text: `Hello, ${name}!` }],
|
|
details: { greeted: name },
|
|
};
|
|
},
|
|
});
|
|
}
|