@acid-cat/cli 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,13 +7,7 @@ import { MCP_EVENTS_EXTENSION, MCP_SUBSCRIPTION_ID } from "@acid-cat/spec-ts";
7
7
  import { randomUUID } from "node:crypto";
8
8
  import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
9
9
  // src/conform/mcp.ts
10
- /**
11
- * Conformance checks for the MCP binding through HTTP (spec/bindings/mcp.md). The protocol checks use the official MCP
12
- * client with revision 2026-07-28. With `handshake`, they run again with the `initialize` handshake of revision
13
- * 2025-11-25. The other checks send requests that a client never sends.
14
- */
15
10
  const RULE = "spec/bindings/mcp.md";
16
- /** A connected MCP client. With `handshake`, the client opens the session with `initialize`. */
17
11
  async function mcpClient(url, signal, handshake = false) {
18
12
  const client = new Client({
19
13
  name: "acid-cat-conform",
@@ -22,7 +16,6 @@ async function mcpClient(url, signal, handshake = false) {
22
16
  await client.connect(new StreamableHTTPClientTransport(new URL(url)), signal ? { signal } : void 0);
23
17
  return client;
24
18
  }
25
- /** The JSON value in the first text content of a tool result, or `null` when there is no text content. */
26
19
  const textOf = (result) => {
27
20
  const first = result.content[0];
28
21
  return parseJson(first?.type === "text" ? first.text : "null");
@@ -91,7 +84,6 @@ async function checkMcp(url, options) {
91
84
  return checks;
92
85
  }
93
86
  const ANCHOR = `${RULE}#earlier-revisions-through-http`;
94
- /** The checks of the `initialize` handshake of revision 2025-11-25 (spec/bindings/mcp.md#earlier-revisions-through-http). */
95
87
  async function checkHandshake(checks, url, deadline) {
96
88
  const handshakeChecks = new Checks("mcp 2025-11-25", deadline);
97
89
  let client;
@@ -140,10 +132,6 @@ async function checkHandshake(checks, url, deadline) {
140
132
  });
141
133
  checks.results.push(...handshakeChecks.results);
142
134
  }
143
- /**
144
- * The checks of the tools and their outcomes, through a connected client (spec/bindings/mcp.md#tools). Each transport
145
- * runs them.
146
- */
147
135
  async function checkTools(checks, mcp) {
148
136
  const call = (signal, name, args) => mcp.callTool({
149
137
  name,
@@ -204,14 +192,11 @@ async function checkTools(checks, mcp) {
204
192
  }
205
193
  });
206
194
  }
207
- /** The revision of the protocol that serves the events extension. */
208
195
  const EVENTS_REVISION = "2026-07-28";
209
- /** The `_meta` of each request of revision 2026-07-28: the revision, and the capabilities of the client, which has none. */
210
196
  const META = {
211
197
  "io.modelcontextprotocol/protocolVersion": EVENTS_REVISION,
212
198
  "io.modelcontextprotocol/clientCapabilities": {}
213
199
  };
214
- /** A channel to a server through HTTP. Each request has the `headers` too, for example the credentials of a principal. */
215
200
  function httpChannel(url, headers = {}) {
216
201
  const post = (id, method, params, signal) => fetch(url, {
217
202
  method: "POST",
@@ -234,7 +219,6 @@ function httpChannel(url, headers = {}) {
234
219
  }),
235
220
  signal
236
221
  });
237
- /** The messages of a response: one JSON message, or a stream of server-sent events with one message in each. */
238
222
  const messagesOf = (response, close) => {
239
223
  if (response.headers.get("Content-Type")?.startsWith("text/event-stream") !== true) {
240
224
  let read = false;
@@ -276,22 +260,18 @@ function httpChannel(url, headers = {}) {
276
260
  }
277
261
  };
278
262
  }
279
- /** The subscription id in the `_meta` of the params of a notification, or of a result. */
280
263
  const subscriptionOf = (message) => memberOf(memberOf(memberOf(message, "params") ?? memberOf(message, "result"), "_meta"), MCP_SUBSCRIPTION_ID);
281
- /** The params of a notification of a subscription, without `_meta`. */
282
264
  const paramsOf = (message) => {
283
265
  const params = memberOf(message, "params");
284
266
  expect(isObject(params), `expected a notification with params, got ${JSON.stringify(message)}`);
285
267
  const { _meta: _, ...rest } = params;
286
268
  return rest;
287
269
  };
288
- /** The order of the delivery modes in `events/list` (spec/bindings/mcp.md#events). */
289
270
  const DELIVERY_ORDER = [
290
271
  "push",
291
272
  "poll",
292
273
  "webhook"
293
274
  ];
294
- /** The requests that the checks of events send through a channel, and the capabilities of the fixture that they call. */
295
275
  function eventRequests(channel) {
296
276
  const resultOf = async (method, params, signal) => {
297
277
  const message = await channel.request(method, params, signal);
@@ -308,13 +288,11 @@ function eventRequests(channel) {
308
288
  name,
309
289
  arguments: args
310
290
  }, signal), "structuredContent");
311
- /** The keys of the subscriptions to `fixture.watch` that are active now. */
312
291
  const watching = async (signal) => {
313
292
  const keys = memberOf(await tool("fixture.watching", {}, signal), "keys");
314
293
  expect(isStringArray(keys), `fixture.watching must give a list of keys, got ${JSON.stringify(keys)}`);
315
294
  return keys;
316
295
  };
317
- /** Give a value to the subscriptions to `fixture.watch` that watch the key. The result is the number of these subscriptions. */
318
296
  const signalKey = async (key, value, signal) => memberOf(await tool("fixture.signal", {
319
297
  key,
320
298
  value
@@ -327,16 +305,10 @@ function eventRequests(channel) {
327
305
  signalKey
328
306
  };
329
307
  }
330
- /** The number of times that a key is in a list of keys. */
331
308
  const count = (keys, key) => keys.filter((each) => each === key).length;
332
- /**
333
- * The checks of the events extension (spec/bindings/mcp.md#events), through a channel. Each transport runs them. Through
334
- * stdio, `cancel` sends `notifications/cancelled`; through HTTP, it closes the request.
335
- */
336
309
  async function checkEvents(checks, channel, options) {
337
310
  const RULE_EVENTS = `${RULE}#events`;
338
311
  const { resultOf, errorOf, watching, signalKey } = eventRequests(channel);
339
- /** The next message of a stream, which must be a notification of the method for this subscription. */
340
312
  const notification = async (stream, id, method) => {
341
313
  const message = await stream.next();
342
314
  expect(message !== void 0 && message.method === method, `expected ${method}, got ${JSON.stringify(message)}`);
@@ -348,7 +320,6 @@ async function checkEvents(checks, channel, options) {
348
320
  const message = await notification(stream, id, "notifications/events/active");
349
321
  expectEqual(paramsOf(message), { truncated: false }, "the params of notifications/events/active");
350
322
  };
351
- /** The response of the stream, which must be the result `complete` for this subscription, then the end. */
352
323
  const complete = async (stream, id) => {
353
324
  const message = await stream.next();
354
325
  expect(message !== void 0 && message.id === id, `expected the result of events/stream, got ${JSON.stringify(message)}`);
@@ -362,7 +333,6 @@ async function checkEvents(checks, channel, options) {
362
333
  const extensions = memberOf(memberOf(result, "capabilities"), "extensions");
363
334
  expect(isObject(memberOf(extensions, MCP_EVENTS_EXTENSION)), `the capabilities must have the extension ${MCP_EVENTS_EXTENSION}, got ${JSON.stringify(result)}`);
364
335
  });
365
- /** The delivery modes that the server serves, from `events/list`. */
366
336
  let delivery = [];
367
337
  await checks.run("events/list gives each event of the view, with the delivery modes of the server and its schemas", RULE_EVENTS, async (signal) => {
368
338
  const result = await resultOf("events/list", {}, signal);
@@ -3,22 +3,11 @@ import { expect, expectEqual, expectOccurrence, until } from "./check.js";
3
3
  import { eventRequests } from "./mcp.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
  // src/conform/poll.ts
6
- /**
7
- * Conformance checks for poll delivery of the MCP events extension (spec/bindings/mcp.md#poll), through a channel. Each
8
- * transport runs them. The checks read the state of a lease only through `events/poll` and `fixture.watching`, and wait
9
- * for states that they can observe, not for times.
10
- *
11
- * A lease continues after the check that started it, until the lease time of the deployment ends. So each check uses a
12
- * new key in its input: the leases of one check, or of an earlier run of conform, never have the key of another check.
13
- */
14
6
  const RULE = "spec/bindings/mcp.md#poll";
15
- /** The largest count of `fixture.ticks`. */
16
7
  const MAXIMUM_TICKS = 100;
17
- /** The most occurrences that a check asks for in one poll. */
18
8
  const MAXIMUM_EVENTS = 100;
19
9
  async function checkPoll(checks, channel, settings) {
20
10
  const { errorOf, watching, signalKey } = eventRequests(channel);
21
- /** The form of a result of `events/poll` (spec/bindings/mcp.md#poll). */
22
11
  const polledOf = (message, name) => {
23
12
  const result = memberOf(message, "result");
24
13
  expect(isObject(result), `events/poll must give a result, got ${JSON.stringify(message)}`);
@@ -37,15 +26,12 @@ async function checkPoll(checks, channel, settings) {
37
26
  hasMore
38
27
  };
39
28
  };
40
- /** Poll once. The result must have the form of a result. */
41
29
  const poll = async (name, input, extra, signal) => polledOf(await channel.request("events/poll", {
42
30
  name,
43
31
  arguments: input,
44
32
  ...extra
45
33
  }, signal), name);
46
- /** Poll with the same params until `done` is true for the result. Each poll renews the lease. */
47
34
  const pollUntil = (what, name, input, extra, done, signal) => until(what, () => poll(name, input, extra, signal), done, signal);
48
- /** The JSON-RPC error of a poll. */
49
35
  const pollError = async (name, input, extra, signal) => errorOf(await channel.request("events/poll", {
50
36
  name,
51
37
  arguments: input,
@@ -64,14 +50,12 @@ async function checkPoll(checks, channel, settings) {
64
50
  expectEqual(polled.truncated, truncated, "truncated");
65
51
  expectEqual(polled.hasMore, false, "hasMore");
66
52
  };
67
- /** Start a lease of `fixture.watch` for the key, and wait until its subscription is active. The result is the cursor of the start. */
68
53
  const startWatch = async (key, signal) => {
69
54
  const started = await poll("fixture.watch", { key }, {}, signal);
70
55
  expectStart(started, false);
71
56
  await until("fixture.watching gives the key of the lease", () => watching(signal), hasKey(key), signal);
72
57
  return started.cursor;
73
58
  };
74
- /** Give values to the subscriptions of the key, one at a time. Each must reach one subscription. */
75
59
  const signalAll = async (key, values, signal) => {
76
60
  for (const value of values) expectEqual(await signalKey(key, value, signal), 1, "the subscriptions that fixture.signal reached");
77
61
  };
@@ -242,7 +226,6 @@ async function checkPoll(checks, channel, settings) {
242
226
  }
243
227
  });
244
228
  await checks.run("after a defect, the next poll is the error -32603 and ends the lease, and a later poll starts a new lease", RULE, async (signal) => {
245
- /** Start a lease of `fixture.broken`. A lease of an earlier run can still have the failure: its poll ends it first. */
246
229
  const start = async () => {
247
230
  const message = await channel.request("events/poll", {
248
231
  name: "fixture.broken",
@@ -252,7 +235,6 @@ async function checkPoll(checks, channel, settings) {
252
235
  expectStart(polled, false);
253
236
  return polled.cursor;
254
237
  };
255
- /** Poll until the error. A result before the error can only have the occurrence n = 1. */
256
238
  const failure = async (cursor) => {
257
239
  const message = await until("a poll gets the error", async () => {
258
240
  const each = await channel.request("events/poll", {
@@ -2,15 +2,12 @@ import type { Outcome } from "@acid-cat/spec-ts";
2
2
  import type { Client } from "@modelcontextprotocol/client";
3
3
  import type { JsonObject } from "../json.js";
4
4
  import { Checks } from "./check.js";
5
- /** A call through one binding. When the signal aborts, the client stops the call and rejects with the reason of the signal. */
6
5
  export type Invoke = (id: string, input: JsonObject, signal?: AbortSignal) => Promise<Outcome<unknown, unknown>>;
7
6
  export declare function httpInvoke(base: string): Invoke;
8
7
  export declare function mcpInvoke(url: string, signal: AbortSignal): Promise<{
9
8
  readonly invoke: Invoke;
10
9
  close(): Promise<void>;
11
10
  }>;
12
- /** Calls through a connected MCP client, with any transport. */
13
11
  export declare function clientInvoke(client: Client): Invoke;
14
- /** The keys of the calls that hold now, as fixture.held gives them through the binding. */
15
12
  export declare function heldKeys(invoke: Invoke, signal: AbortSignal): Promise<readonly string[]>;
16
13
  export declare function checkProperties(binding: string, invoke: Invoke, deadline: number): Promise<Checks>;
@@ -5,10 +5,6 @@ import { randomUUID } from "node:crypto";
5
5
  import { SdkError } from "@modelcontextprotocol/client";
6
6
  import fc from "fast-check";
7
7
  // src/conform/properties.ts
8
- /**
9
- * Property-based checks for the guarantees of spec/invocation.md#cancellation-and-concurrency, through each remote
10
- * binding. fast-check makes random sets of concurrent calls and cancellations.
11
- */
12
8
  const RULE = "spec/invocation.md#cancellation-and-concurrency";
13
9
  function httpInvoke(base) {
14
10
  return async (id, input, signal) => {
@@ -30,7 +26,6 @@ async function mcpInvoke(url, signal) {
30
26
  close: () => client.close()
31
27
  };
32
28
  }
33
- /** Calls through a connected MCP client, with any transport. */
34
29
  function clientInvoke(client) {
35
30
  return async (id, input, signal) => {
36
31
  try {
@@ -60,7 +55,6 @@ const operation = fc.oneof(fc.string({ maxLength: 40 }).map((text) => ({
60
55
  kind: "echo",
61
56
  text
62
57
  })), fc.constant({ kind: "refuse" }), fc.constant({ kind: "crash" }), fc.constant({ kind: "invalid" }));
63
- /** The outcome that an operation must have. */
64
58
  function agrees(operation, outcome) {
65
59
  switch (operation.kind) {
66
60
  case "echo": return "ok" in outcome && outcome.ok && JSON.stringify(outcome.value) === JSON.stringify({ text: operation.text });
@@ -79,12 +73,7 @@ const callFor = (invoke, operation, signal) => {
79
73
  };
80
74
  const settle = (call) => call.then((outcome) => ({ outcome }), (rejected) => ({ rejected }));
81
75
  const describe = (settled) => "outcome" in settled ? JSON.stringify(settled.outcome) : `the rejection ${String(settled.rejected)}`;
82
- /**
83
- * True if a call ended as a cancellation: with the call failure `cancelled`, or with the rejection that the client gives
84
- * when it aborts the call, which is the reason of its signal. Any other rejection is not a cancellation.
85
- */
86
76
  const isCancellation = (settled, reason) => "outcome" in settled ? "kind" in settled.outcome && settled.outcome.kind === "cancelled" : settled.rejected === reason;
87
- /** The keys of the calls that hold now, as fixture.held gives them through the binding. */
88
77
  async function heldKeys(invoke, signal) {
89
78
  const outcome = await invoke("fixture.held", {}, signal);
90
79
  expect("ok" in outcome && outcome.ok, `fixture.held gave ${JSON.stringify(outcome)}`);
@@ -92,12 +81,6 @@ async function heldKeys(invoke, signal) {
92
81
  expect(isStringArray(keys), `fixture.held gave ${JSON.stringify(outcome)}, with no list of keys`);
93
82
  return keys;
94
83
  }
95
- /**
96
- * Start one call to fixture.hold for each flag, and wait until each call holds. Then cancel each call whose flag is
97
- * true, and release the others. Each cancelled call must end as a cancellation and stop holding. Each other call must
98
- * hold until it is released, and then give its own key. At the end, the cleanup releases every key, with a signal that
99
- * aborts `deadline` milliseconds later.
100
- */
101
84
  async function cancelSome(invoke, flags, signal, deadline) {
102
85
  const calls = flags.map((cancelled) => {
103
86
  const key = randomUUID();
@@ -137,7 +120,6 @@ async function cancelSome(invoke, flags, signal, deadline) {
137
120
  await Promise.all(calls.map((call) => invoke("fixture.release", { key: call.key }, cleanup).catch(() => void 0)));
138
121
  }
139
122
  }
140
- /** Two calls or more, at least one of them cancelled and at least one not. */
141
123
  const cancellations = fc.array(fc.boolean(), {
142
124
  minLength: 2,
143
125
  maxLength: 5
@@ -1,9 +1,5 @@
1
1
  import { createServer } from "node:http";
2
2
  // src/conform/serve.ts
3
- /**
4
- * Serve a web request handler, `(request: Request) => Promise<Response>`, on a local port. Implementations use it
5
- * to run `acid-cat conform` against their bindings in a test.
6
- */
7
3
  /** Serve one handler for all paths, or handlers by path prefix, on `127.0.0.1` and a free port. */
8
4
  function serve(handler) {
9
5
  const routes = typeof handler === "function" ? { "/": handler } : handler;
@@ -65,12 +61,7 @@ async function answer(incoming, outgoing, prefixes, routes) {
65
61
  outgoing.end();
66
62
  }
67
63
  }
68
- /**
69
- * The body of an incoming request, as a web stream. The stream reads the request only when the handler reads the body,
70
- * and the request pauses after each chunk until the handler reads again. A request that the handler does not read stays
71
- * unread, so that Node.js discards it after the response. When the handler cancels the stream, the request discards the
72
- * rest of its body.
73
- */
64
+ /** A request that the handler does not read stays unread, so that Node.js discards it after the response. */
74
65
  function bodyOf(incoming) {
75
66
  let open = true;
76
67
  let reading = false;
@@ -1,14 +1,8 @@
1
- /** A reader of a stream of server-sent events, for the checks of the HTTP binding and of MCP through HTTP. */
2
- /** One message of a stream of server-sent events. A comment line is a message with the event `comment`. */
3
1
  export interface SseMessage {
4
2
  readonly event?: string;
5
3
  readonly id?: string;
6
4
  readonly data: string;
7
5
  }
8
- /**
9
- * Read the messages of a response one at a time. `next` skips comment lines, and resolves with `undefined` at the end of
10
- * the stream. When the signal of the request aborts, `next` rejects.
11
- */
12
6
  export declare function sseReader(response: Response): {
13
7
  next(): Promise<SseMessage | undefined>;
14
8
  cancel: () => Promise<void | undefined>;
@@ -1,8 +1,4 @@
1
1
  // src/conform/sse.ts
2
- /**
3
- * Read the messages of a response one at a time. `next` skips comment lines, and resolves with `undefined` at the end of
4
- * the stream. When the signal of the request aborts, `next` rejects.
5
- */
6
2
  function sseReader(response) {
7
3
  if (response.body === null) throw new Error("the response has no body");
8
4
  const reader = response.body.getReader();
@@ -24,8 +20,9 @@ function sseReader(response) {
24
20
  return {
25
21
  async next() {
26
22
  for (;;) {
27
- const message = await read();
28
- if (message?.event !== "comment") return message;
23
+ const frame = await read();
24
+ if (frame === void 0) return void 0;
25
+ if (frame.type === "message") return frame.message;
29
26
  }
30
27
  },
31
28
  cancel: () => reader.cancel().catch(() => void 0)
@@ -34,10 +31,7 @@ function sseReader(response) {
34
31
  function parse(raw) {
35
32
  const fields = { data: [] };
36
33
  const lines = raw.split(/\r?\n/);
37
- if (lines.every((line) => line.startsWith(":"))) return {
38
- event: "comment",
39
- data: ""
40
- };
34
+ if (lines.every((line) => line.startsWith(":"))) return { type: "comment" };
41
35
  for (const line of lines) {
42
36
  if (line.startsWith(":")) continue;
43
37
  const colon = line.indexOf(":");
@@ -48,9 +42,12 @@ function parse(raw) {
48
42
  else if (name === "data") fields.data.push(value);
49
43
  }
50
44
  return {
51
- ...fields.event === void 0 ? {} : { event: fields.event },
52
- ...fields.id === void 0 ? {} : { id: fields.id },
53
- data: fields.data.join("\n")
45
+ type: "message",
46
+ message: {
47
+ ...fields.event === void 0 ? {} : { event: fields.event },
48
+ ...fields.id === void 0 ? {} : { id: fields.id },
49
+ data: fields.data.join("\n")
50
+ }
54
51
  };
55
52
  }
56
53
  export { sseReader };
@@ -1,5 +1,4 @@
1
1
  import { Checks } from "./check.js";
2
- /** The settings of the checks of webhook delivery. */
3
2
  export interface WebhookSettings {
4
3
  /** The principal that the deployment gives to a request with the header `Authorization: Bearer <principal>`. */
5
4
  readonly principal: string;
@@ -24,5 +23,4 @@ export interface WebhookSettings {
24
23
  /** The maximum number of subscriptions of one principal in the deployment. With it, conform tests the limit. */
25
24
  readonly maxSubscriptions?: number | undefined;
26
25
  }
27
- /** The checks of webhook delivery through the MCP server at `url`. */
28
26
  export declare function checkWebhook(checks: Checks, url: string, settings: WebhookSettings): Promise<void>;
@@ -5,22 +5,9 @@ import { MCP_WEBHOOK_DEFAULTS, isOccurrence, webhookSignature, webhookSubscripti
5
5
  import { randomBytes, randomUUID } from "node:crypto";
6
6
  import { createServer } from "node:https";
7
7
  // src/conform/webhook.ts
8
- /**
9
- * Conformance checks for webhook delivery of the MCP events extension (spec/bindings/mcp.md#webhook), through HTTP.
10
- * conform runs an HTTPS receiver on 127.0.0.1 with the certificate that it gets. The deployment under test must trust
11
- * that certificate, allow deliveries to 127.0.0.1, and give the principal of `WebhookSettings` to each request with the
12
- * header `Authorization: Bearer <principal>`.
13
- *
14
- * Each check uses its own path on the receiver, so its URL is new: the server verifies it again, and the subscriptions
15
- * of one check, or of an earlier run of conform, never have the key of another check.
16
- */
17
8
  const RULE = "spec/bindings/mcp.md#webhook";
18
- /** True if the body of a request is the control message `verification`. */
9
+ const REFRESH_BEFORE_PRECISION_MS = 1;
19
10
  const isVerification = (request) => memberOf(request.body, "type") === "verification";
20
- /**
21
- * Start the receiver. By default, it answers a verification with its challenge, and each other request with 200. A
22
- * check can choose other answers for its path.
23
- */
24
11
  async function startReceiver(settings) {
25
12
  const received = /* @__PURE__ */ new Map();
26
13
  const answerers = /* @__PURE__ */ new Map();
@@ -60,7 +47,6 @@ async function startReceiver(settings) {
60
47
  const address = server.address();
61
48
  const port = typeof address === "object" && address !== null ? address.port : 0;
62
49
  return {
63
- /** A new URL on the receiver, for one check. */
64
50
  url: (answer) => {
65
51
  const path = `/hook/${randomUUID()}`;
66
52
  if (answer !== void 0) answerers.set(path, answer);
@@ -75,18 +61,12 @@ async function startReceiver(settings) {
75
61
  })
76
62
  };
77
63
  }
78
- /** A new Standard Webhooks secret. */
79
64
  const newSecret = () => `whsec_${randomBytes(32).toString("base64")}`;
80
- /** One header of a request, as text. */
81
65
  function header(request, name) {
82
66
  const value = request.headers[name];
83
67
  expect(typeof value === "string", `the request must have the header ${name}, got ${JSON.stringify(request.headers)}`);
84
68
  return value;
85
69
  }
86
- /**
87
- * Check the headers of a request of the server: the media type, the id, the timestamp, the subscription id, and a
88
- * signature with each secret. `type` is the type of a control message; with none, the request is an occurrence.
89
- */
90
70
  async function expectSigned(request, subscription, secrets, type) {
91
71
  expect(header(request, "content-type").startsWith("application/json"), `Content-Type must be application/json, got ${header(request, "content-type")}`);
92
72
  const id = header(request, "webhook-id");
@@ -103,12 +83,10 @@ async function expectSigned(request, subscription, secrets, type) {
103
83
  }
104
84
  return id;
105
85
  }
106
- /** The body of a delivery of an occurrence: the occurrence without `truncated`. */
107
86
  function expectDelivered(request, name) {
108
87
  expect(isObject(request.body) && !("truncated" in request.body), `the body must be an occurrence without truncated, got ${request.text}`);
109
88
  return expectOccurrence(request.body, name);
110
89
  }
111
- /** The checks of webhook delivery through the MCP server at `url`. */
112
90
  async function checkWebhook(checks, url, settings) {
113
91
  let receiver;
114
92
  try {
@@ -174,9 +152,7 @@ async function checkWithReceiver(checks, url, settings, receiver) {
174
152
  };
175
153
  };
176
154
  const unsubscribe = (name, input, hook, signal, client = main) => client.channel.request("events/unsubscribe", unsubscribeParams(name, input, hook), signal);
177
- /** End a subscription at the end of a check. It can be gone already. */
178
155
  const cleanup = (name, input, hook, client = main) => unsubscribe(name, input, hook, AbortSignal.timeout(checks.deadline), client).catch(() => void 0);
179
- /** The requests of a URL that are not verifications. */
180
156
  const deliveries = (hook) => hook.received().filter((each) => !isVerification(each));
181
157
  const atLeast = (hook, number, signal) => until(`the receiver gets ${number} deliveries`, async () => deliveries(hook), (list) => list.length >= number, signal);
182
158
  const watchedKey = (key) => (keys) => keys.includes(key);
@@ -407,7 +383,7 @@ async function checkWithReceiver(checks, url, settings, receiver) {
407
383
  const before = Date.now();
408
384
  const { refreshBefore } = await subscribe("fixture.watch", input, hook.url, newSecret(), signal, extra);
409
385
  const after = Date.now();
410
- expect(refreshBefore >= before + granted - 1 && refreshBefore <= after + granted + 1, `for ${what}, refreshBefore must be ${granted} ms after the request, got ${refreshBefore - before} ms after its start`);
386
+ expect(refreshBefore >= before + granted - REFRESH_BEFORE_PRECISION_MS && refreshBefore <= after + granted + REFRESH_BEFORE_PRECISION_MS, `for ${what}, refreshBefore must be ${granted} ms after the request, got ${refreshBefore - before} ms after its start`);
411
387
  } finally {
412
388
  await cleanup("fixture.watch", input, hook.url);
413
389
  }
@@ -1,17 +1,14 @@
1
1
  import { Checks } from "./check.js";
2
- /** A tool as the host records it. */
3
2
  export interface RecordedTool {
4
3
  readonly name: string;
5
4
  readonly description: string;
6
5
  readonly inputSchema: unknown;
7
6
  }
8
- /** A tool, as a page gives it to `registerTool`. */
9
7
  export interface HostTool extends RecordedTool {
10
8
  execute(input: unknown, options: {
11
9
  readonly signal: AbortSignal;
12
10
  }): Promise<unknown>;
13
11
  }
14
- /** What a call to a tool gives: the value that `execute` resolves with, or the error that it rejects with. */
15
12
  export type ToolCall = {
16
13
  readonly resolved: unknown;
17
14
  } | {
@@ -23,7 +20,6 @@ export type ToolCall = {
23
20
  } | {
24
21
  readonly missing: true;
25
22
  };
26
- /** The host that the checks give to the page. */
27
23
  export interface TestHost {
28
24
  readonly modelContext: {
29
25
  registerTool(tool: HostTool, options: {
@@ -31,23 +27,13 @@ export interface TestHost {
31
27
  }): void;
32
28
  };
33
29
  tools(): RecordedTool[];
34
- /** Call a tool. With an `id`, `cancel` can abort the signal of the call. */
35
30
  call(name: string, input: unknown, id?: string): Promise<ToolCall>;
36
- /** Abort the signal of the call that has this `id`, if it runs. */
37
31
  cancel(id: string): void;
38
32
  }
39
- /**
40
- * Make a test host. The function uses no imports and no outer variables, because the browser driver sends its
41
- * source text to the page.
42
- */
33
+ /** The function uses no imports and no outer variables, because the browser driver sends its source text to the page. */
43
34
  export declare function createTestHost(): TestHost;
44
- /** The view from the checks: the tools of the page, and calls to them. */
45
35
  export interface WebMcpDriver {
46
36
  tools(signal: AbortSignal): Promise<RecordedTool[]>;
47
- /**
48
- * Call a tool. When `cancel` aborts, the host aborts the signal of the call, and the driver waits for what the tool
49
- * gives. When `signal` aborts, the host aborts the signal of the call, and the driver stops waiting.
50
- */
51
37
  call(name: string, input: unknown, options?: {
52
38
  readonly signal?: AbortSignal;
53
39
  readonly cancel?: AbortSignal;
@@ -59,9 +45,7 @@ export interface WebMcpDriver {
59
45
  * implementation serves the `app` target of the fixture, with its switch on.
60
46
  */
61
47
  export type WebMcpInstall = (modelContext: TestHost["modelContext"]) => void | (() => void | Promise<void>) | Promise<void | (() => void | Promise<void>)>;
62
- /** A driver for an implementation in the same process. Values pass through JSON, as they do from a page. */
63
48
  export declare function processDriver(install: WebMcpInstall): Promise<WebMcpDriver>;
64
- /** A driver for a page in Chromium, through Playwright. The page loads with the test host as its `modelContext`. */
65
49
  export declare function browserDriver(url: string): Promise<WebMcpDriver>;
66
50
  export declare function checkWebMcp(driver: WebMcpDriver, options: {
67
51
  readonly deadline: number;
@@ -2,20 +2,9 @@ import { isArrayOf, isObject, isStringArray, memberOf, parseJson } from "../json
2
2
  import { Checks, abortable, expect, expectEqual, fixture, idsOf, sorted, until } from "./check.js";
3
3
  import { REFERENCE, visitObjects } from "@acid-cat/spec-ts";
4
4
  // src/conform/webmcp.ts
5
- /**
6
- * Conformance checks for the WebMCP binding (spec/bindings/webmcp.md).
7
- *
8
- * The checks act as the WebMCP host: they give the page a `modelContext`, record the tools that the binding registers,
9
- * and call them. The page can run in a browser, or the implementation can install itself on the host in the same
10
- * process.
11
- */
12
5
  const RULE = "spec/bindings/webmcp.md";
13
- /** The target of the fixture that has the WebMCP binding. */
14
6
  const TARGET = "app";
15
- /**
16
- * Make a test host. The function uses no imports and no outer variables, because the browser driver sends its
17
- * source text to the page.
18
- */
7
+ /** The function uses no imports and no outer variables, because the browser driver sends its source text to the page. */
19
8
  function createTestHost() {
20
9
  const registered = /* @__PURE__ */ new Map();
21
10
  const calls = /* @__PURE__ */ new Map();
@@ -57,7 +46,6 @@ function createTestHost() {
57
46
  }
58
47
  };
59
48
  }
60
- /** The tools that a host gives, after they pass through JSON. The check fails when the value is not a list of tools. */
61
49
  function toolsOf(value) {
62
50
  const isTool = (tool) => isObject(tool) && typeof tool.name === "string" && typeof tool.description === "string";
63
51
  if (!isArrayOf(value, isTool)) throw new Error(`the host must give a list of tools, got ${JSON.stringify(value)}`);
@@ -67,7 +55,6 @@ function toolsOf(value) {
67
55
  inputSchema: tool.inputSchema
68
56
  }));
69
57
  }
70
- /** A tool call that a host gives, after it passes through JSON. The check fails when the value is not a tool call. */
71
58
  function toolCallOf(value) {
72
59
  if (isObject(value)) {
73
60
  if (value.missing === true) return { missing: true };
@@ -99,7 +86,6 @@ function driverOf(host) {
99
86
  close: () => host.close()
100
87
  };
101
88
  }
102
- /** A driver for an implementation in the same process. Values pass through JSON, as they do from a page. */
103
89
  async function processDriver(install) {
104
90
  const host = createTestHost();
105
91
  const remove = await install(host.modelContext);
@@ -113,7 +99,6 @@ async function processDriver(install) {
113
99
  }
114
100
  });
115
101
  }
116
- /** A driver for a page in Chromium, through Playwright. The page loads with the test host as its `modelContext`. */
117
102
  async function browserDriver(url) {
118
103
  let playwright;
119
104
  try {
@@ -145,7 +130,6 @@ async function browserDriver(url) {
145
130
  close: () => browser.close()
146
131
  });
147
132
  }
148
- /** True if each `$ref` of a schema refers to a type in its own `$defs` (spec/catalog.md#bundling). */
149
133
  function isBundled(schema) {
150
134
  const types = isObject(schema.$defs) ? schema.$defs : {};
151
135
  let bundled = true;
@@ -156,8 +140,13 @@ function isBundled(schema) {
156
140
  });
157
141
  return bundled;
158
142
  }
143
+ const requiredOf = (schema) => isStringArray(schema.required) ? schema.required : [];
144
+ function expectSameInputShape(tool, schema, input) {
145
+ expectEqual(schema.type, "object", `type of the input schema of ${tool}`);
146
+ expectEqual(sorted(Object.keys(schema.properties ?? {})), sorted(Object.keys(input.properties ?? {})), `properties of ${tool}`);
147
+ expectEqual(sorted(requiredOf(schema)), sorted(requiredOf(input)), `required properties of ${tool}`);
148
+ }
159
149
  const names = async (driver, signal) => sorted((await driver.tools(signal)).map((tool) => tool.name));
160
- /** The keys of the calls that hold now, as fixture.held gives them through the host. */
161
150
  async function heldKeys(driver, signal) {
162
151
  const call = await driver.call("fixture.held", {}, { signal });
163
152
  expect("resolved" in call, `fixture.held gave ${JSON.stringify(call)}`);
@@ -182,11 +171,7 @@ async function checkWebMcp(driver, options) {
182
171
  expectEqual(tool.description, view[tool.name]?.description, `description of ${tool.name}`);
183
172
  const schema = tool.inputSchema;
184
173
  expect(isObject(schema), `the input schema of ${tool.name} must be an object`);
185
- const input = view[tool.name]?.input ?? {};
186
- const required = (object) => isStringArray(object.required) ? object.required : [];
187
- expectEqual(schema.type, "object", `type of the input schema of ${tool.name}`);
188
- expectEqual(sorted(Object.keys(schema.properties ?? {})), sorted(Object.keys(input.properties ?? {})), `properties of ${tool.name}`);
189
- expectEqual(sorted(required(schema)), sorted(required(input)), `required properties of ${tool.name}`);
174
+ expectSameInputShape(tool.name, schema, view[tool.name]?.input ?? {});
190
175
  expect(isBundled(schema), `the input schema of ${tool.name} must be bundled`);
191
176
  }
192
177
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /** The library of `@acid-cat/cli`: catalog checks, and the conformance tests. */
2
1
  export { bundle, check, viewOf } from "./catalog.js";
3
2
  export type { Catalog, Report } from "./catalog.js";
4
3
  export { conform, fixture, serve } from "./conform/index.js";
@@ -71,7 +71,35 @@ var catalog_schema_default = {
71
71
  "uniqueItems": true
72
72
  },
73
73
  "description": { "type": "string" },
74
- "options": { "type": "object" }
74
+ "options": {
75
+ "type": "object",
76
+ "properties": { "cli": { "$ref": "#/$defs/cliOptions" } }
77
+ }
78
+ }
79
+ },
80
+ "cliOptions": {
81
+ "description": "The settings of the CLI binding. See spec/bindings/cli.md#aliases.",
82
+ "type": "object",
83
+ "properties": {
84
+ "aliases": {
85
+ "type": "object",
86
+ "propertyNames": { "pattern": "^(--)?[a-z][a-z0-9]*(-[a-z0-9]+)*$" },
87
+ "additionalProperties": { "$ref": "#/$defs/cliAlias" }
88
+ },
89
+ "default": {
90
+ "description": "The name of the default alias: a command alias that runs when the command line gets no command.",
91
+ "type": "string",
92
+ "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"
93
+ }
94
+ }
95
+ },
96
+ "cliAlias": {
97
+ "description": "A short name for a capability or an event: its id in capability or event, and an optional fixed input. Other members start with x-; acid-cat check rejects other members, and an alias with both or neither of capability and event.",
98
+ "type": "object",
99
+ "properties": {
100
+ "capability": { "$ref": "#/$defs/id" },
101
+ "event": { "$ref": "#/$defs/id" },
102
+ "input": { "type": "object" }
75
103
  }
76
104
  },
77
105
  "schema": {