contract.test.ts 957 B

12345678910111213141516171819202122232425
  1. import { expect, it } from "vitest";
  2. import { replyToChannelToolEntry } from "../../src/tool/handlers/reply-to-channel.js";
  3. import {
  4. channelReplyPartsSchema,
  5. type ChannelReplyTool,
  6. } from "../../src/tool/channel-reply/contract.js";
  7. const entry: ChannelReplyTool = replyToChannelToolEntry;
  8. it("渠道回复仍按严格的逐项参数契约校验", () => {
  9. const parts = [{ type: "text", text: "请确认" }];
  10. expect(channelReplyPartsSchema.parse(parts)).toEqual(parts);
  11. expect(entry.runtimeInputSchema?.safeParse({ parts }).success).toBe(true);
  12. expect(entry.runtimeInputSchema?.safeParse({ parts, extra: true }).success).toBe(false);
  13. expect(channelReplyPartsSchema.safeParse([{ type: "mention" }]).success).toBe(false);
  14. });
  15. it("保留延迟曝光及网络写入的调度属性", () => {
  16. expect(entry.metadata).toMatchObject({
  17. shouldDefer: true,
  18. readOnly: false,
  19. concurrentSafe: false,
  20. sideEffectScope: "network",
  21. });
  22. });