|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { validateAgentParams } from "../index.js"; |
| 3 | + |
| 4 | +const minimalAgentParams = { |
| 5 | + message: "wake", |
| 6 | + idempotencyKey: "idem-1234", |
| 7 | +} as const; |
| 8 | + |
| 9 | +describe("AgentParamsSchema", () => { |
| 10 | + it("accepts minimal params", () => { |
| 11 | + expect(validateAgentParams(minimalAgentParams)).toBe(true); |
| 12 | + }); |
| 13 | + |
| 14 | + it("accepts a paperclip context object in the payload", () => { |
| 15 | + // Paperclip ≥ 2026.416.0 includes a `paperclip` field in wake payloads. |
| 16 | + // The gateway must not reject it as an unexpected property. |
| 17 | + expect( |
| 18 | + validateAgentParams({ |
| 19 | + ...minimalAgentParams, |
| 20 | + paperclip: { |
| 21 | + runId: "run-abc123", |
| 22 | + companyId: "13808fb1-a29b-4465-9796-b8b200845155", |
| 23 | + agentId: "agent-xyz", |
| 24 | + issueId: "issue-001", |
| 25 | + }, |
| 26 | + }), |
| 27 | + ).toBe(true); |
| 28 | + }); |
| 29 | + |
| 30 | + it("accepts a paperclip field with arbitrary shape", () => { |
| 31 | + expect( |
| 32 | + validateAgentParams({ |
| 33 | + ...minimalAgentParams, |
| 34 | + paperclip: { nested: { deep: true }, list: [1, 2, 3] }, |
| 35 | + }), |
| 36 | + ).toBe(true); |
| 37 | + }); |
| 38 | + |
| 39 | + it("rejects a payload missing idempotencyKey", () => { |
| 40 | + expect(validateAgentParams({ message: "wake" })).toBe(false); |
| 41 | + }); |
| 42 | + |
| 43 | + it("rejects a payload missing message", () => { |
| 44 | + expect(validateAgentParams({ idempotencyKey: "idem-1234" })).toBe(false); |
| 45 | + }); |
| 46 | + |
| 47 | + it("rejects unknown top-level properties other than paperclip", () => { |
| 48 | + expect(validateAgentParams({ ...minimalAgentParams, notAKnownField: "value" })).toBe(false); |
| 49 | + }); |
| 50 | +}); |
0 commit comments