Open History to see the last commit
1import { describe, expect, it } from "@effect/vitest";
2import * as Schema from "effect/Schema";
3
4import * as V1 from "./_generated/schema-v1.gen.ts";
5import * as V2 from "./schema.ts";
6
7describe("pinned ACP wire schemas", () => {
8 it("validates known content variants without accepting malformed ones as future content", () => {
9 const accepts = Schema.is(V2.ContentBlock);
10 expect(accepts({ type: "text", text: "hello" })).toBe(true);
11 expect(accepts({ type: "text" })).toBe(false);
12 expect(accepts({ type: "image", data: "aGVsbG8=" })).toBe(false);
13 expect(accepts({ type: "future_content", payload: { value: 1 } })).toBe(true);
14 });
15
16 it("keeps v1 command inputs compatible with native agents", () => {
17 const command = { name: "plan", description: "Make a plan", input: { hint: "Task" } };
18 const isAvailableCommand = Schema.is(V1.AvailableCommand);
19
20 expect(isAvailableCommand(command)).toBe(true);
21 const isAvailableCommand2 = Schema.is(V2.AvailableCommand);
22
23 expect(isAvailableCommand2({ ...command, input: { type: "text", hint: "Task" } })).toBe(true);
24 });
25});