|
1 | | -import { z } from 'zod'; |
2 | | -import { JsonSchema7Type } from 'zod-to-json-schema'; |
3 | 1 | import { CoreMessage } from 'ai'; |
4 | 2 |
|
5 | | -import { Logger } from '../../utils/logger.js'; |
6 | | -import { TokenTracker } from '../tokens.js'; |
| 3 | +// Re-export all types from the original types.ts file |
| 4 | +export * from '../types.js'; |
7 | 5 |
|
8 | | -// Re-export existing types from the original types.ts |
9 | | -export type TokenLevel = 'debug' | 'verbose' | 'info' | 'warn' | 'error'; |
10 | | -export type pageFilter = 'simple' | 'none' | 'readability'; |
11 | | - |
12 | | -export type ToolContext = { |
13 | | - logger: Logger; |
14 | | - workingDirectory: string; |
15 | | - headless: boolean; |
16 | | - userSession: boolean; |
17 | | - pageFilter: pageFilter; |
18 | | - tokenTracker: TokenTracker; |
19 | | -}; |
20 | | - |
21 | | -export type Tool<TParams = Record<string, any>, TReturn = any> = { |
22 | | - name: string; |
23 | | - description: string; |
24 | | - parameters: z.ZodType<TParams>; |
25 | | - returns: z.ZodType<TReturn>; |
26 | | - logPrefix?: string; |
27 | | - |
28 | | - logParameters?: (params: TParams, context: ToolContext) => void; |
29 | | - logReturns?: (returns: TReturn, context: ToolContext) => void; |
30 | | - |
31 | | - execute: (params: TParams, context: ToolContext) => Promise<TReturn>; |
32 | | - |
33 | | - // Keep JsonSchema7Type for backward compatibility and Vercel AI SDK integration |
34 | | - parametersJsonSchema?: JsonSchema7Type; |
35 | | - returnsJsonSchema?: JsonSchema7Type; |
36 | | -}; |
37 | | - |
38 | | -export type ToolCall = { |
39 | | - id: string; |
40 | | - name: string; |
41 | | - input: any; |
42 | | -}; |
43 | | - |
44 | | -export type TextContent = { |
45 | | - type: 'text'; |
46 | | - text: string; |
47 | | -}; |
48 | | - |
49 | | -export type ToolUseContent = { |
50 | | - type: 'tool_use'; |
51 | | -} & ToolCall; |
52 | | - |
53 | | -export type AssistantMessage = { |
54 | | - role: 'assistant'; |
55 | | - content: (TextContent | ToolUseContent)[]; |
56 | | -}; |
57 | | - |
58 | | -export type ToolResultContent = { |
59 | | - type: 'tool_result'; |
60 | | - tool_use_id: string; |
61 | | - content: string; |
62 | | -}; |
63 | | - |
64 | | -export type UserMessage = { |
65 | | - role: 'user'; |
66 | | - content: (TextContent | ToolResultContent)[]; |
67 | | -}; |
68 | | - |
69 | | -export type Message = AssistantMessage | UserMessage; |
70 | | - |
71 | | -// New types specific to toolAgent |
| 6 | +// Only define new types specific to toolAgent here |
72 | 7 | export interface ToolAgentResult { |
73 | 8 | result: string; |
74 | 9 | interactions: number; |
|
0 commit comments