@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,15 +7,15 @@ import { tmpdir } from "node:os";
7
7
  import { join } from "node:path";
8
8
  import { isDeepStrictEqual } from "node:util";
9
9
  // src/conform/cli.ts
10
- /** Conformance checks for the CLI binding (spec/bindings/cli.md). Each check runs the command line as a process. */
11
10
  const RULE = "spec/bindings/cli.md";
12
- /** The `usage` of each capability in the view of the fixture, after the name of the program. */
13
11
  const USAGES = {
14
12
  "fixture.crash": "fixture crash",
15
13
  "fixture.echo": "fixture echo --text <string>",
16
14
  "fixture.flags": "fixture flags --mode <fast|slow> [--count <integer>] [--extra <json>] [--label <string>] [--ratio <number>] [--steps <integer>...] [--tags <string>...] [--verbose]",
17
15
  "fixture.held": "fixture held",
18
16
  "fixture.hold": "fixture hold --key <string> [--marker <string>]",
17
+ "fixture.note": "fixture note --text <string> [--loud]",
18
+ "fixture.raw": "call fixture.raw '<json>'",
19
19
  "fixture.refuse": "fixture refuse",
20
20
  "fixture.release": "fixture release --key <string>",
21
21
  "fixture.switch.set": "fixture switch set --on",
@@ -23,23 +23,34 @@ const USAGES = {
23
23
  "fixture.signal": "fixture signal --key <string> --value <string>",
24
24
  "fixture.watching": "fixture watching"
25
25
  };
26
- /** The `usage` of each event in the view of the fixture, after the name of the program. */
27
26
  const EVENT_USAGES = {
28
27
  "fixture.broken": "watch fixture.broken [--cursor <string>] [--max-age-ms <integer>]",
28
+ "fixture.echoes": "watch fixture.echoes '<json>' [--cursor <string>] [--max-age-ms <integer>]",
29
29
  "fixture.ticks": "watch fixture.ticks --count <integer> [--gap <integer>] [--key <string>] [--cursor <string>] [--max-age-ms <integer>]",
30
30
  "fixture.watch": "watch fixture.watch --key <string> [--marker <string>] [--cursor <string>] [--max-age-ms <integer>]"
31
31
  };
32
+ const ALIAS_USAGES = {
33
+ "fixture.echo": ["--hello", "say --text <string>"],
34
+ "fixture.flags": ["quick [--count <integer>] [--extra <json>] [--label <string>] [--ratio <number>] [--steps <integer>...] [--tags <string>...] [--verbose]"],
35
+ "fixture.held": ["held-keys"],
36
+ "fixture.note": ["fixed-note [--loud]"],
37
+ "fixture.raw": ["raw '<json>'"]
38
+ };
39
+ const EVENT_ALIAS_USAGES = {
40
+ "fixture.broken": ["broken-ticks [--cursor <string>] [--max-age-ms <integer>]"],
41
+ "fixture.echoes": ["echoes '<json>' [--cursor <string>] [--max-age-ms <integer>]"],
42
+ "fixture.ticks": ["ticks [--gap <integer>] [--key <string>] [--cursor <string>] [--max-age-ms <integer>]"]
43
+ };
44
+ const ALIASES = `${RULE}#aliases`;
32
45
  const isEntry = (value) => isObject(value) && typeof value.id === "string";
33
- /** The list that the `list` command writes to standard output. The check fails when it is not a list of entries. */
34
46
  function entriesOf(stdout) {
35
47
  const list = parseJson(stdout);
36
48
  if (!isArrayOf(list, isEntry)) throw new Error(`list must give a list of objects with an id, got ${JSON.stringify(list)}`);
37
49
  return list;
38
50
  }
39
51
  /**
40
- * Start the command line. When the signal aborts, the process is killed, and its run rejects. The rejection is observed
41
- * here too, so that a check that stops waiting first, for example at the deadline, records a failure and does not end
42
- * the process with an unhandled rejection.
52
+ * The rejection is observed here too, so that a check that stops waiting first, for example at the deadline, records a
53
+ * failure and does not end the process with an unhandled rejection.
43
54
  */
44
55
  function start(command, args, signal) {
45
56
  const [program, ...programArgs] = command;
@@ -72,6 +83,14 @@ function start(command, args, signal) {
72
83
  run
73
84
  };
74
85
  }
86
+ async function expectUsageError(result, code) {
87
+ const { code: actual, stdout } = await result;
88
+ expectEqual(actual, code, "exit code");
89
+ expectEqual(stdout, "", "standard output");
90
+ }
91
+ function occurrencesIn(stdout, id) {
92
+ return stdout.split("\n").filter((line) => line !== "").map((line) => expectOccurrence(parseJson(line), id));
93
+ }
75
94
  async function checkCli(command, options) {
76
95
  const checks = new Checks("cli", options.deadline);
77
96
  const run = (signal, ...args) => start(command, args, signal).run;
@@ -96,6 +115,11 @@ async function checkCli(command, options) {
96
115
  ["fixture", "nothing"],
97
116
  2
98
117
  ],
118
+ [
119
+ "a shared prefix alone has exit code 2",
120
+ ["fixture"],
121
+ 2
122
+ ],
99
123
  [
100
124
  "a capability outside the view has exit code 2",
101
125
  ["call", "fixture.hidden"],
@@ -106,6 +130,18 @@ async function checkCli(command, options) {
106
130
  ["fixture", "echo"],
107
131
  3
108
132
  ],
133
+ [
134
+ "an unknown flag has exit code 3",
135
+ [
136
+ "fixture",
137
+ "echo",
138
+ "--text",
139
+ "hello",
140
+ "--nope",
141
+ "x"
142
+ ],
143
+ 3
144
+ ],
109
145
  [
110
146
  "a flag that is not valid has exit code 3",
111
147
  [
@@ -154,7 +190,7 @@ async function checkCli(command, options) {
154
190
  3
155
191
  ]
156
192
  ]) await checks.run(name, `${RULE}#outcomes`, async (signal) => {
157
- expectEqual((await run(signal, ...args)).code, code, "exit code");
193
+ await expectUsageError(run(signal, ...args), code);
158
194
  });
159
195
  await checks.run("an interrupt cancels the call with exit code 130", `${RULE}#commands`, async (signal) => {
160
196
  const directory = await mkdtemp(join(tmpdir(), "acid-cat-conform-"));
@@ -255,30 +291,185 @@ async function checkCli(command, options) {
255
291
  expectEqual(rest.join(" "), kind === "event" ? EVENT_USAGES[id] : USAGES[id], `usage of ${id} after the name of the program`);
256
292
  }
257
293
  });
294
+ await checkAliases(checks, command);
258
295
  await checkWatch(checks, command);
259
296
  return checks;
260
297
  }
298
+ async function checkAliases(checks, command) {
299
+ const run = (signal, ...args) => start(command, args, signal).run;
300
+ const expectOutput = (result, expected) => {
301
+ expectEqual(result.code, 0, `exit code, with standard error ${JSON.stringify(result.stderr)}`);
302
+ const output = parseJson(result.stdout);
303
+ expect(isDeepStrictEqual(output, expected), `standard output: expected ${JSON.stringify(expected)}, got ${JSON.stringify(output)}`);
304
+ };
305
+ await checks.run("a command alias calls its capability with the flags", ALIASES, async (signal) => {
306
+ expectOutput(await run(signal, "say", "--text", "hi"), { text: "hi" });
307
+ });
308
+ await checks.run("a flag alias calls its capability with its fixed input", ALIASES, async (signal) => {
309
+ expectOutput(await run(signal, "--hello"), { text: "hello" });
310
+ });
311
+ await checks.run("the input of an alias is its fixed input with the properties of the flags", ALIASES, async (signal) => {
312
+ expectOutput(await run(signal, "quick", "--count", "2", "--steps", "1", "--steps", "2"), {
313
+ mode: "fast",
314
+ count: 2,
315
+ steps: [1, 2]
316
+ });
317
+ });
318
+ await checks.run("an alias of a capability whose input schema has no properties takes the input as JSON text", ALIASES, async (signal) => {
319
+ expectOutput(await run(signal, "raw", "{\"a\":[1]}"), { a: [1] });
320
+ expectOutput(await run(signal, "raw"), {});
321
+ });
322
+ await checks.run("the flags of an alias come from the type that the $ref of the input schema refers to, whatever other keys it has", ALIASES, async (signal) => {
323
+ expectOutput(await run(signal, "fixed-note"), { text: "fixed" });
324
+ expectOutput(await run(signal, "fixed-note", "--loud"), {
325
+ text: "fixed",
326
+ loud: true
327
+ });
328
+ });
329
+ await checks.run("an alias of a capability with no input takes no argument", ALIASES, async (signal) => {
330
+ const result = await run(signal, "held-keys");
331
+ expectEqual(result.code, 0, `exit code, with standard error ${JSON.stringify(result.stderr)}`);
332
+ expect(isArrayOf(memberOf(parseJson(result.stdout), "keys"), (key) => typeof key === "string"), `standard output must have the keys, got ${result.stdout}`);
333
+ });
334
+ const ticks = async (signal, ...args) => {
335
+ const result = await run(signal, "ticks", ...args);
336
+ expectEqual(result.code, 0, `exit code, with standard error ${JSON.stringify(result.stderr)}`);
337
+ return occurrencesIn(result.stdout, "fixture.ticks");
338
+ };
339
+ const tickData = async (signal, ...args) => (await ticks(signal, ...args)).map((occurrence) => occurrence.data);
340
+ await checks.run("an alias of an event subscribes with its fixed input and the cursor", ALIASES, async (signal) => {
341
+ expectEqual(await tickData(signal), [{ n: 1 }, { n: 2 }], "the data of the occurrences");
342
+ expectEqual(await tickData(signal, "--cursor", "1"), [{ n: 2 }], "the data of the occurrences after the cursor 1");
343
+ });
344
+ await checks.run("an alias of an event takes the flags of the input of its event", ALIASES, async (signal) => {
345
+ expectEqual((await ticks(signal, "--gap", "2")).map((occurrence) => [occurrence.data, occurrence.truncated ?? null]), [[{ n: 1 }, null], [{ n: 2 }, true]], "the data and truncated of the occurrences");
346
+ });
347
+ await checks.run("an alias of an event takes --max-age-ms", ALIASES, async (signal) => {
348
+ expectEqual(await tickData(signal, "--max-age-ms", "60000"), [{ n: 1 }, { n: 2 }], "the data of the occurrences");
349
+ });
350
+ await checks.run("an alias of an event takes a flag value that starts with - in the form --name=value", ALIASES, async (signal) => {
351
+ expectEqual(await tickData(signal, "--key=--cursor"), [{ n: 1 }, { n: 2 }], "the data of the occurrences with the key --cursor");
352
+ });
353
+ await checks.run("an alias of an event whose input schema has no properties takes the input as JSON text", ALIASES, async (signal) => {
354
+ const echoes = async (...args) => {
355
+ const result = await run(signal, "echoes", ...args);
356
+ expectEqual(result.code, 0, `exit code, with standard error ${JSON.stringify(result.stderr)}`);
357
+ return occurrencesIn(result.stdout, "fixture.echoes").map((occurrence) => occurrence.data);
358
+ };
359
+ expectEqual(await echoes("{\"a\":1}"), [{ a: 1 }], "the data of the occurrences");
360
+ expectEqual(await echoes(), [{}], "the data of the occurrences with no input");
361
+ });
362
+ await checks.run("an alias of an event writes internal to standard error with exit code 5 after a defect", ALIASES, async (signal) => {
363
+ const result = await run(signal, "broken-ticks");
364
+ expectEqual(result.code, 5, "exit code");
365
+ expectEqual(occurrencesIn(result.stdout, "fixture.broken").map((occurrence) => occurrence.data), [{ n: 1 }], "the data of the occurrences");
366
+ expect(/"kind":"internal"/.test(result.stderr), `standard error must contain the call failure internal, got ${JSON.stringify(result.stderr)}`);
367
+ });
368
+ await checks.run("the default alias runs with no arguments", ALIASES, async (signal) => {
369
+ expectOutput(await run(signal), { mode: "fast" });
370
+ });
371
+ await checks.run("the default alias takes the flags when the first argument is a flag", ALIASES, async (signal) => {
372
+ expectOutput(await run(signal, "--count", "2", "--verbose"), {
373
+ mode: "fast",
374
+ count: 2,
375
+ verbose: true
376
+ });
377
+ expectOutput(await run(signal, "--hello"), { text: "hello" });
378
+ });
379
+ await checks.run("--help writes the help when there is a default alias", ALIASES, async (signal) => {
380
+ const result = await run(signal, "--help");
381
+ expectEqual(result.code, 0, "exit code");
382
+ expect(result.stdout.length > 0, "standard output must have the help");
383
+ });
384
+ for (const [name, args, code] of [
385
+ [
386
+ "a flag of a property of the fixed input has exit code 3",
387
+ [
388
+ "quick",
389
+ "--mode",
390
+ "slow"
391
+ ],
392
+ 3
393
+ ],
394
+ [
395
+ "a flag of a property of the fixed input of an alias of an event has exit code 3",
396
+ [
397
+ "ticks",
398
+ "--count",
399
+ "3"
400
+ ],
401
+ 3
402
+ ],
403
+ [
404
+ "a flag that the default alias does not have has exit code 3",
405
+ ["--nothing"],
406
+ 3
407
+ ],
408
+ [
409
+ "a missing required flag of an alias has exit code 3",
410
+ ["say"],
411
+ 3
412
+ ],
413
+ [
414
+ "an alias with input that is not JSON has exit code 3",
415
+ ["raw", "{"],
416
+ 3
417
+ ],
418
+ [
419
+ "an alias of an event with input that is not JSON has exit code 3",
420
+ ["echoes", "{"],
421
+ 3
422
+ ],
423
+ [
424
+ "JSON text to an alias of a capability whose input schema refers to a type with properties has exit code 3",
425
+ ["fixed-note", "{\"text\":\"override\"}"],
426
+ 3
427
+ ],
428
+ [
429
+ "an argument to an alias of a capability with no input has exit code 3",
430
+ ["held-keys", "{}"],
431
+ 3
432
+ ]
433
+ ]) await checks.run(name, ALIASES, async (signal) => {
434
+ expectEqual((await run(signal, ...args)).code, code, "exit code");
435
+ });
436
+ await checks.run("list gives the usage of the aliases of each capability", ALIASES, async (signal) => {
437
+ const entries = entriesOf((await run(signal, "list")).stdout);
438
+ for (const { id, kind, aliases } of entries) {
439
+ const expected = kind === "capability" ? ALIAS_USAGES[id] : EVENT_ALIAS_USAGES[id];
440
+ if (expected === void 0) {
441
+ expect(aliases === void 0, `${id} has no alias, so its item must not have aliases, got ${JSON.stringify(aliases)}`);
442
+ continue;
443
+ }
444
+ expect(isArrayOf(aliases, (usage) => typeof usage === "string"), `the aliases of ${id} must be a list of strings, got ${JSON.stringify(aliases)}`);
445
+ const rest = aliases.map((usage) => usage.split(" ").slice(1).join(" "));
446
+ expectEqual(rest, expected, `the usage of the aliases of ${id} after the name of the program`);
447
+ }
448
+ });
449
+ }
261
450
  const EVENTS = `${RULE}#events`;
262
- /** The checks of `watch` (spec/bindings/cli.md#events). */
263
451
  async function checkWatch(checks, command) {
264
452
  const run = (signal, ...args) => start(command, args, signal).run;
265
- /** The lines of standard output, each one an occurrence of the event. */
266
- const occurrences = (stdout, id) => stdout.split("\n").filter((line) => line !== "").map((line) => expectOccurrence(parseJson(line), id));
267
453
  await checks.run("watch writes each occurrence as one line of JSON, and exits with 0 when the subscription is complete", EVENTS, async (signal) => {
268
454
  const result = await run(signal, "watch", "fixture.ticks", "--count", "2");
269
455
  expectEqual(result.code, 0, "exit code");
270
- expectEqual(occurrences(result.stdout, "fixture.ticks").map((occurrence) => occurrence.data), [{ n: 1 }, { n: 2 }], "the data of the occurrences");
456
+ expectEqual(occurrencesIn(result.stdout, "fixture.ticks").map((occurrence) => occurrence.data), [{ n: 1 }, { n: 2 }], "the data of the occurrences");
271
457
  expectEqual(result.stderr, "", "standard error");
272
458
  });
273
459
  await checks.run("watch with --cursor starts after the cursor", EVENTS, async (signal) => {
274
460
  const result = await run(signal, "watch", "fixture.ticks", "--count", "3", "--cursor", "1", "--max-age-ms", "60000");
275
461
  expectEqual(result.code, 0, "exit code");
276
- expectEqual(occurrences(result.stdout, "fixture.ticks").map((occurrence) => [occurrence.data, occurrence.cursor]), [[{ n: 2 }, "2"], [{ n: 3 }, "3"]], "the data and the cursor of the occurrences");
462
+ expectEqual(occurrencesIn(result.stdout, "fixture.ticks").map((occurrence) => [occurrence.data, occurrence.cursor]), [[{ n: 2 }, "2"], [{ n: 3 }, "3"]], "the data and the cursor of the occurrences");
463
+ });
464
+ await checks.run("watch takes a flag value that starts with - in the form --name=value", EVENTS, async (signal) => {
465
+ const result = await run(signal, "watch", "fixture.ticks", "--count", "1", "--key=--cursor");
466
+ expectEqual(result.code, 0, `exit code, with standard error ${JSON.stringify(result.stderr)}`);
467
+ expectEqual(occurrencesIn(result.stdout, "fixture.ticks").map((occurrence) => occurrence.data), [{ n: 1 }], "the data of the occurrences");
277
468
  });
278
469
  await checks.run("watch writes an occurrence after a gap with truncated: true", EVENTS, async (signal) => {
279
470
  const result = await run(signal, "watch", "fixture.ticks", "--count", "3", "--gap", "2");
280
471
  expectEqual(result.code, 0, "exit code");
281
- expectEqual(occurrences(result.stdout, "fixture.ticks").map((occurrence) => [occurrence.data, occurrence.truncated ?? null]), [
472
+ expectEqual(occurrencesIn(result.stdout, "fixture.ticks").map((occurrence) => [occurrence.data, occurrence.truncated ?? null]), [
282
473
  [{ n: 1 }, null],
283
474
  [{ n: 2 }, true],
284
475
  [{ n: 3 }, null]
@@ -287,10 +478,15 @@ async function checkWatch(checks, command) {
287
478
  await checks.run("watch writes internal to standard error with exit code 5 after a defect", EVENTS, async (signal) => {
288
479
  const result = await run(signal, "watch", "fixture.broken");
289
480
  expectEqual(result.code, 5, "exit code");
290
- expectEqual(occurrences(result.stdout, "fixture.broken").map((occurrence) => occurrence.data), [{ n: 1 }], "the data of the occurrences");
481
+ expectEqual(occurrencesIn(result.stdout, "fixture.broken").map((occurrence) => occurrence.data), [{ n: 1 }], "the data of the occurrences");
291
482
  expect(/"kind":"internal"/.test(result.stderr), `standard error must contain the call failure internal, got ${JSON.stringify(result.stderr)}`);
292
483
  });
293
484
  for (const [name, args, code] of [
485
+ [
486
+ "watch with no event id has exit code 3",
487
+ ["watch"],
488
+ 3
489
+ ],
294
490
  [
295
491
  "watch with invalid input has exit code 3",
296
492
  [
@@ -336,7 +532,7 @@ async function checkWatch(checks, command) {
336
532
  3
337
533
  ]
338
534
  ]) await checks.run(name, EVENTS, async (signal) => {
339
- expectEqual((await run(signal, ...args)).code, code, "exit code");
535
+ await expectUsageError(run(signal, ...args), code);
340
536
  });
341
537
  await checks.run("an interrupt cancels watch with exit code 130", EVENTS, async (signal) => {
342
538
  const directory = await mkdtemp(join(tmpdir(), "acid-cat-conform-"));
@@ -3,10 +3,8 @@ import { Checks, FORBIDDEN_ORIGIN, eventIdsOf, expect, expectEqual, expectOccurr
3
3
  import { sseReader } from "./sse.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
  // src/conform/http.ts
6
- /** Conformance checks for the HTTP binding (spec/bindings/http.md). */
7
6
  const RULE = "spec/bindings/http.md";
8
7
  const isEntry = (value) => isObject(value) && typeof value.id === "string";
9
- /** The list that `GET /capabilities` gives. The check fails when it is not a list of entries. */
10
8
  async function entriesOf(response) {
11
9
  const list = await readJson(response);
12
10
  if (!isArrayOf(list, isEntry)) throw new Error(`GET /capabilities must give a list of objects with an id, got ${JSON.stringify(list)}`);
@@ -109,7 +107,6 @@ async function checkHttp(base, options) {
109
107
  return checks;
110
108
  }
111
109
  const EVENTS = `${RULE}#events`;
112
- /** The checks of the events (spec/bindings/http.md#events). */
113
110
  async function checkEvents(checks, base) {
114
111
  const subscribe = (signal, id, input, headers = {}) => fetch(`${base}/events/${id}`, {
115
112
  method: "POST",
@@ -120,7 +117,6 @@ async function checkEvents(checks, base) {
120
117
  body: JSON.stringify(input),
121
118
  signal
122
119
  });
123
- /** Subscribe, and check that the stream starts. `signal` and `close` both close the stream. */
124
120
  const open = async (signal, id, input, headers = {}) => {
125
121
  const controller = new AbortController();
126
122
  const response = await subscribe(AbortSignal.any([signal, controller.signal]), id, input, headers);
@@ -136,7 +132,6 @@ async function checkEvents(checks, base) {
136
132
  close: () => controller.abort()
137
133
  };
138
134
  };
139
- /** The next message of a stream, which must be an occurrence of the event with the cursor as its SSE id. */
140
135
  const nextOccurrence = async (stream, id) => {
141
136
  const message = await stream.reader.next();
142
137
  expect(message?.event === "next", `expected event: next, got ${JSON.stringify(message)}`);
@@ -7,10 +7,6 @@ import { checkProperties, httpInvoke, mcpInvoke } from "./properties.js";
7
7
  import { browserDriver, checkWebMcp, processDriver } from "./webmcp.js";
8
8
  import { serve } from "./serve.js";
9
9
  // src/conform/index.ts
10
- /**
11
- * `acid-cat conform`: test a running implementation through its bindings (spec/conformance.md). The implementation
12
- * serves the conformance fixture (conformance/fixture.acidcat.json), with its switch on.
13
- */
14
10
  /** Run all checks for the bindings that the options give. */
15
11
  async function conform(options) {
16
12
  const maximumBytes = options.maximumBytes ?? 1048576;
@@ -7,14 +7,7 @@ import { randomUUID } from "node:crypto";
7
7
  import { Client } from "@modelcontextprotocol/client";
8
8
  import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
9
9
  // src/conform/mcp-stdio.ts
10
- /**
11
- * Conformance checks for the MCP binding through standard input and standard output (spec/bindings/mcp.md#stdio). Each
12
- * check starts the server as a process. The protocol checks use the official MCP client, once with revision 2026-07-28
13
- * and once with the `initialize` handshake of revision 2025-11-25. The other checks write lines that a client never
14
- * writes, or end standard input during a call.
15
- */
16
10
  const RULE = "spec/bindings/mcp.md#stdio";
17
- /** The two ways that a client opens the session: revision 2026-07-28, or the handshake of revision 2025-11-25. */
18
11
  const ERAS = [{
19
12
  revision: "2026-07-28",
20
13
  connects: "an MCP client connects with revision 2026-07-28",
@@ -24,11 +17,9 @@ const ERAS = [{
24
17
  connects: "an MCP client connects with the initialize handshake of revision 2025-11-25",
25
18
  options: {}
26
19
  }];
27
- /** The environment of the process: the environment of `conform`, without the variables that have no value. */
28
20
  function environment() {
29
21
  return Object.fromEntries(Object.entries(process.env).flatMap(([name, value]) => value === void 0 ? [] : [[name, value]]));
30
22
  }
31
- /** Start the server and connect an MCP client. `changes` counts each `notifications/tools/list_changed`. */
32
23
  async function connect(command, options, changes, signal) {
33
24
  const [program, ...args] = command;
34
25
  if (program === void 0) throw new Error("the command that starts the MCP server is empty");
@@ -78,10 +69,6 @@ async function checkMcpStdio(command, options) {
78
69
  all.push(await checkStdioEvents(command, options));
79
70
  return all;
80
71
  }
81
- /**
82
- * The checks of the events extension through one server process. The requests have revision 2026-07-28 in `_meta`, with
83
- * no handshake. `cancel` sends `notifications/cancelled` with the id of the `events/stream` request.
84
- */
85
72
  async function checkStdioEvents(command, options) {
86
73
  const checks = new Checks("mcp-stdio events", options.deadline);
87
74
  const controller = new AbortController();
@@ -97,7 +84,6 @@ async function checkStdioEvents(command, options) {
97
84
  }
98
85
  return checks;
99
86
  }
100
- /** A channel to a server process. Each wait stops when the signal of the check aborts. */
101
87
  function stdioChannel(server) {
102
88
  let next = 0;
103
89
  const send = (id, method, params) => server.write(JSON.stringify({
@@ -143,7 +129,6 @@ function stdioChannel(server) {
143
129
  }
144
130
  };
145
131
  }
146
- /** The server tells the client each change of the set of available tools. */
147
132
  async function checkChanges(checks, mcp, changes) {
148
133
  const set = (on, signal) => mcp.callTool({
149
134
  name: "fixture.switch.set",
@@ -165,7 +150,7 @@ async function checkChanges(checks, mcp, changes) {
165
150
  }
166
151
  });
167
152
  }
168
- /** `notifications/cancelled` cancels a call. The official client sends it when the signal of a call aborts. */
153
+ /** The official client sends `notifications/cancelled` when the signal of a call aborts. */
169
154
  async function checkCancellation(checks, mcp) {
170
155
  const invoke = clientInvoke(mcp);
171
156
  await checks.run("notifications/cancelled cancels the call", RULE, async (signal) => {
@@ -182,10 +167,6 @@ async function checkCancellation(checks, mcp) {
182
167
  }
183
168
  });
184
169
  }
185
- /**
186
- * A server process with its standard input and output, one JSON-RPC message on each line. `lines` holds each line of
187
- * standard output. When the signal aborts, the process is killed.
188
- */
189
170
  function startRaw(command, signal) {
190
171
  const [program, ...args] = command;
191
172
  if (program === void 0) throw new Error("the command that starts the MCP server is empty");
@@ -224,7 +205,6 @@ function startRaw(command, signal) {
224
205
  exited.catch(() => void 0);
225
206
  let next = 0;
226
207
  const write = (line) => child.stdin.write(`${line}\n`);
227
- /** Send a request and wait for its response. */
228
208
  const request = async (method, params = {}) => {
229
209
  const id = `conform-${next += 1}`;
230
210
  write(JSON.stringify({
@@ -244,7 +224,6 @@ function startRaw(command, signal) {
244
224
  exited
245
225
  };
246
226
  }
247
- /** The `initialize` handshake of revision 2025-11-25, through a raw process. */
248
227
  async function handshake(server, revision = "2025-11-25") {
249
228
  const response = await server.request("initialize", {
250
229
  protocolVersion: revision,
@@ -262,7 +241,6 @@ async function handshake(server, revision = "2025-11-25") {
262
241
  }
263
242
  async function checkLines(command, options) {
264
243
  const checks = new Checks("mcp-stdio", options.deadline);
265
- /** Run a body with a new server process, and kill the process at the end. */
266
244
  const withServer = (body) => async (signal) => {
267
245
  const controller = new AbortController();
268
246
  const server = startRaw(command, AbortSignal.any([controller.signal, signal]));
@@ -3,60 +3,37 @@ import type { JsonObject } from "../json.js";
3
3
  import { Checks } from "./check.js";
4
4
  import type { PollSettings } from "./poll.js";
5
5
  import type { WebhookSettings } from "./webhook.js";
6
- /** A connected MCP client. With `handshake`, the client opens the session with `initialize`. */
7
6
  export declare function mcpClient(url: string, signal?: AbortSignal, handshake?: boolean): Promise<Client>;
8
7
  export interface McpCheckOptions {
9
8
  readonly maximumBytes: number;
10
9
  readonly deadline: number;
11
10
  readonly handshake: boolean;
12
- /** The poll settings of the deployment, for the checks of the buffer and of the lease time. */
13
11
  readonly poll: PollSettings;
14
- /** The settings of the checks of webhook delivery. With none, conform does not test webhook delivery. */
15
12
  readonly webhook: WebhookSettings | undefined;
16
13
  }
17
14
  export declare function checkMcp(url: string, options: McpCheckOptions): Promise<Checks>;
18
- /**
19
- * The checks of the tools and their outcomes, through a connected client (spec/bindings/mcp.md#tools). Each transport
20
- * runs them.
21
- */
22
15
  export declare function checkTools(checks: Checks, mcp: Client): Promise<void>;
23
- /** The revision of the protocol that serves the events extension. */
24
16
  export declare const EVENTS_REVISION = "2026-07-28";
25
- /** The `_meta` of each request of revision 2026-07-28: the revision, and the capabilities of the client, which has none. */
26
17
  export declare const META: {
27
18
  "io.modelcontextprotocol/protocolVersion": string;
28
19
  "io.modelcontextprotocol/clientCapabilities": {};
29
20
  };
30
- /** A JSON-RPC message from the server. */
31
21
  export type Message = JsonObject;
32
- /**
33
- * The messages of one `events/stream` request: the notifications of the subscription and its response. `next` gives
34
- * the next message, or `undefined` at the end. `cancel` cancels the subscription, as the transport does.
35
- */
36
22
  export interface EventStream {
37
23
  next(): Promise<Message | undefined>;
38
24
  cancel(): Promise<void>;
39
25
  }
40
- /** A way to send requests of revision 2026-07-28 to a server: through HTTP, or through standard input and output. */
41
26
  export interface Channel {
42
27
  request(method: string, params: JsonObject, signal: AbortSignal): Promise<Message>;
43
- /** Start `events/stream` with this request id. */
44
28
  stream(id: string, params: JsonObject, signal: AbortSignal): Promise<EventStream>;
45
29
  }
46
- /** A channel to a server through HTTP. Each request has the `headers` too, for example the credentials of a principal. */
47
30
  export declare function httpChannel(url: string, headers?: Readonly<Record<string, string>>): Channel;
48
- /** The subscription id in the `_meta` of the params of a notification, or of a result. */
49
31
  export declare const subscriptionOf: (message: Message) => unknown;
50
- /** How a server serves the events extension, as `checkEvents` tests it. */
51
32
  export interface EventsOptions {
52
- /** The transport of the channel. Through stdio, the server never serves webhook delivery. */
53
33
  readonly transport: "http" | "stdio";
54
- /** The poll settings of the deployment. */
55
34
  readonly poll: PollSettings;
56
- /** `true` if conform tests webhook delivery through this server, so the server must serve it. */
57
35
  readonly webhook: boolean;
58
36
  }
59
- /** The requests that the checks of events send through a channel, and the capabilities of the fixture that they call. */
60
37
  export declare function eventRequests(channel: Channel): {
61
38
  resultOf: (method: string, params: JsonObject, signal: AbortSignal) => Promise<JsonObject>;
62
39
  errorOf: (message: Message | undefined) => JsonObject;
@@ -64,10 +41,5 @@ export declare function eventRequests(channel: Channel): {
64
41
  watching: (signal: AbortSignal) => Promise<readonly string[]>;
65
42
  signalKey: (key: string, value: string, signal: AbortSignal) => Promise<unknown>;
66
43
  };
67
- /** The number of times that a key is in a list of keys. */
68
44
  export declare const count: (keys: readonly string[], key: string) => number;
69
- /**
70
- * The checks of the events extension (spec/bindings/mcp.md#events), through a channel. Each transport runs them. Through
71
- * stdio, `cancel` sends `notifications/cancelled`; through HTTP, it closes the request.
72
- */
73
45
  export declare function checkEvents(checks: Checks, channel: Channel, options: EventsOptions): Promise<void>;