mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 21:03:19 +00:00
- CustomAgentTool renamed to CustomTool
- ToolAPI renamed to CustomToolAPI
- ToolContext renamed to CustomToolContext
- ToolSessionEvent renamed to CustomToolSessionEvent
- Added CustomToolContext parameter to execute() and onSession()
- CustomToolFactory now returns CustomTool<any, any> for type compatibility
- dispose() replaced with onSession({ reason: 'shutdown' })
- Added wrapCustomTool() to convert CustomTool to AgentTool
- Session exposes setToolUIContext() instead of leaking internals
- Fix ToolExecutionComponent to sync with toolOutputExpanded state
- Update all custom tool examples for new API
21 lines
545 B
TypeScript
21 lines
545 B
TypeScript
import type { CustomToolFactory } from "@mariozechner/pi-coding-agent";
|
|
import { Type } from "@sinclair/typebox";
|
|
|
|
const factory: CustomToolFactory = (_pi) => ({
|
|
name: "hello",
|
|
label: "Hello",
|
|
description: "A simple greeting tool",
|
|
parameters: Type.Object({
|
|
name: Type.String({ description: "Name to greet" }),
|
|
}),
|
|
|
|
async execute(_toolCallId, params) {
|
|
const { name } = params as { name: string };
|
|
return {
|
|
content: [{ type: "text", text: `Hello, ${name}!` }],
|
|
details: { greeted: name },
|
|
};
|
|
},
|
|
});
|
|
|
|
export default factory;
|