* Create a mock toolset that returns a simple success result for any tool call.
( handler?: (toolCall: ToolCall) => Promise<ToolResult> | ToolResult, )
| 46 | * Create a mock toolset that returns a simple success result for any tool call. |
| 47 | */ |
| 48 | function createSimpleMockToolset( |
| 49 | handler?: (toolCall: ToolCall) => Promise<ToolResult> | ToolResult, |
| 50 | ): Toolset { |
| 51 | return { |
| 52 | tools: [ |
| 53 | { |
| 54 | name: 'plus', |
| 55 | description: 'Add two numbers', |
| 56 | parameters: { |
| 57 | type: 'object', |
| 58 | properties: { |
| 59 | a: { type: 'integer' }, |
| 60 | b: { type: 'integer' }, |
| 61 | }, |
| 62 | }, |
| 63 | }, |
| 64 | ], |
| 65 | handle: |
| 66 | handler ?? |
| 67 | ((toolCall: ToolCall): ToolResult => ({ |
| 68 | toolCallId: toolCall.id, |
| 69 | returnValue: toolOk({ output: 'mock-result' }), |
| 70 | })), |
| 71 | }; |
| 72 | } |
| 73 | describe('step()', () => { |
| 74 | it('returns a StepResult with message, toolCalls, and toolResults', async () => { |
| 75 | const plusToolCall: ToolCall = { |