|
1 | 1 | import { describe, it, expect, vi } from 'vitest'; |
2 | 2 | import { register } from '../../src/tools/projects.js'; |
3 | | -import { callConfirmed, callPreview } from './_confirm-helpers.js'; |
| 3 | +import { callConfirmed, callPreview, ELICIT_CTX } from './_confirm-helpers.js'; |
4 | 4 | import type { TempoClient } from '../../src/client.js'; |
5 | 5 | import type { McpServer } from '@modelcontextprotocol/server'; |
6 | 6 |
|
@@ -317,6 +317,29 @@ describe.each(TIMESHEET_ACTION_TOOLS)('%s', (toolName, action) => { |
317 | 317 | expect(parsed.willSendQuery).toEqual({ from: '2024-01-01' }); |
318 | 318 | }); |
319 | 319 |
|
| 320 | + // opencode 2.0.x declares form elicitation but never renders the prompt, so |
| 321 | + // the call hangs; MCP_CONFIRM_ELICITATION=off puts it on the token flow. |
| 322 | + it('with MCP_CONFIRM_ELICITATION=off, a client that declares elicitation gets the token flow', async () => { |
| 323 | + vi.stubEnv('MCP_CONFIRM_ELICITATION', 'off'); |
| 324 | + try { |
| 325 | + const client = makeClient({ status: { key: 'APPROVED' } }); |
| 326 | + const { server, tools } = makeMockServer(); |
| 327 | + register(server, client); |
| 328 | + const cb = findTool(tools, toolName).cb as (a: Record<string, unknown>, c: unknown) => Promise<{ content: { text: string }[] }>; |
| 329 | + const args = { accountId: 'user123', from: '2024-01-01' }; |
| 330 | + const phase1 = JSON.parse((await cb(args, ELICIT_CTX)).content[0].text); |
| 331 | + expect(phase1.status).toBe('confirmation-required'); |
| 332 | + expect(client.request).not.toHaveBeenCalled(); |
| 333 | + await cb({ ...args, confirmToken: phase1.confirmToken }, ELICIT_CTX); |
| 334 | + expect(client.request).toHaveBeenCalledTimes(1); |
| 335 | + expect(client.request).toHaveBeenCalledWith( |
| 336 | + 'POST', `/4/timesheet-approvals/user/user123/${action}`, undefined, { from: '2024-01-01', to: undefined }, |
| 337 | + ); |
| 338 | + } finally { |
| 339 | + vi.unstubAllEnvs(); |
| 340 | + } |
| 341 | + }); |
| 342 | + |
320 | 343 | it('is marked as a mutating tool', () => { |
321 | 344 | const { server, tools } = makeMockServer(); |
322 | 345 | register(server, makeClient()); |
|
0 commit comments