|
13 | 13 | * roots.test.ts), `requestState` carried across the multi-step tool's |
14 | 14 | * rounds on both eras, with retries after missing or bad input, and the |
15 | 15 | * SDK refusing an embedded request whose capability the request did not |
16 | | - * declare (-32021) or a tampered state (-32602). |
| 16 | + * declare (-32021) or a tampered or expired state (-32602). |
17 | 17 | * - Per-request log levels (`trigger-log-messages`) against the 2025-era |
18 | 18 | * session level. |
19 | 19 | * - Change notifications (`trigger-list-changed`, `trigger-resource-update`) |
@@ -336,6 +336,35 @@ describe("multi-round-trip requests on 2026-07-28", () => { |
336 | 336 | requestState: expect.any(String), |
337 | 337 | }); |
338 | 338 | }); |
| 339 | + |
| 340 | + it("refuses an untampered requestState with -32602 once its 600-second TTL has passed", async () => { |
| 341 | + // Freeze the clock before the state is minted, so only the test moves it. |
| 342 | + vi.useFakeTimers({ toFake: ["Date"] }); |
| 343 | + raw = await connectRaw({ elicitation: {} }); |
| 344 | + const mintedAt = Date.now(); |
| 345 | + const first = await raw.call("trigger-multi-step-elicitation"); |
| 346 | + const answerTheName = { |
| 347 | + name: "trigger-multi-step-elicitation", |
| 348 | + arguments: {}, |
| 349 | + requestState: (first as { requestState: string }).requestState, |
| 350 | + inputResponses: { |
| 351 | + name: { action: "accept", content: { name: "Ada" } }, |
| 352 | + }, |
| 353 | + }; |
| 354 | + |
| 355 | + // Inside the TTL the state is accepted, so the refusal below is the |
| 356 | + // expiry and nothing else about this continuation. |
| 357 | + vi.setSystemTime(mintedAt + 599_000); |
| 358 | + expect(await raw.result("tools/call", answerTheName)).toMatchObject({ |
| 359 | + resultType: "input_required", |
| 360 | + inputRequests: { color: { method: "elicitation/create" } }, |
| 361 | + }); |
| 362 | + |
| 363 | + // Past it, the same state is refused: only the clock has moved. |
| 364 | + vi.setSystemTime(mintedAt + 601_000); |
| 365 | + const response = await raw.request("tools/call", answerTheName); |
| 366 | + expect(response.error).toMatchObject({ code: -32602 }); |
| 367 | + }); |
339 | 368 | }); |
340 | 369 |
|
341 | 370 | describe("trigger-multi-step-elicitation", () => { |
|
0 commit comments