| 34 | } |
| 35 | |
| 36 | function makeTool( |
| 37 | options: { |
| 38 | readonly mode?: PermissionMode; |
| 39 | readonly requestQuestion?: ( |
| 40 | request: QuestionRequest, |
| 41 | options: { readonly signal?: AbortSignal }, |
| 42 | ) => Promise<QuestionResult>; |
| 43 | } = {}, |
| 44 | ): { |
| 45 | readonly tool: AskUserQuestionTool; |
| 46 | readonly requestQuestion: ReturnType<typeof vi.fn>; |
| 47 | readonly telemetryTrack: ReturnType<typeof vi.fn>; |
| 48 | } { |
| 49 | const requestQuestion = vi.fn( |
| 50 | options.requestQuestion ?? |
| 51 | (async () => ({ |
| 52 | Postgres: true, |
| 53 | })), |
| 54 | ); |
| 55 | const telemetryTrack = vi.fn(); |
| 56 | const agent = { |
| 57 | permission: { mode: options.mode ?? 'manual' }, |
| 58 | rpc: { requestQuestion }, |
| 59 | telemetry: { track: telemetryTrack }, |
| 60 | } as unknown as Agent; |
| 61 | return { tool: new AskUserQuestionTool(agent), requestQuestion, telemetryTrack }; |
| 62 | } |
| 63 | |
| 64 | describe('AskUserQuestionTool', () => { |
| 65 | afterEach(() => { |