19 lines
612 B
TypeScript
19 lines
612 B
TypeScript
|
|
import type { AgentTool, AgentToolResult } from '@earendil-works/pi-agent-core';
|
||
|
|
import type { ToolDefinition } from './tools/types';
|
||
|
|
|
||
|
|
export function createPiTools(tools: ToolDefinition[]): AgentTool[] {
|
||
|
|
return tools.map((t): AgentTool => ({
|
||
|
|
name: t.name,
|
||
|
|
description: t.description,
|
||
|
|
parameters: t.input_schema as any,
|
||
|
|
label: t.name,
|
||
|
|
execute: async (_toolCallId: string, params: any): Promise<AgentToolResult<any>> => {
|
||
|
|
const result = await t.execute(params);
|
||
|
|
return {
|
||
|
|
content: [{ type: 'text' as const, text: result }],
|
||
|
|
details: null,
|
||
|
|
};
|
||
|
|
},
|
||
|
|
}));
|
||
|
|
}
|