@acid-cat/cli 0.17.0 → 0.19.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.
- package/README.md +24 -24
- package/conformance/fixture.acidcat.json +4 -4
- package/dist/catalog.d.ts +2 -2
- package/dist/catalog.js +4 -4
- package/dist/conform/check.d.ts +13 -4
- package/dist/conform/check.js +46 -12
- package/dist/conform/cli.d.ts +1 -0
- package/dist/conform/cli.js +8 -8
- package/dist/conform/http.d.ts +1 -0
- package/dist/conform/http.js +6 -6
- package/dist/conform/index.d.ts +10 -4
- package/dist/conform/index.js +35 -13
- package/dist/conform/mcp-stdio.d.ts +1 -0
- package/dist/conform/mcp-stdio.js +7 -7
- package/dist/conform/mcp.d.ts +1 -0
- package/dist/conform/mcp.js +16 -14
- package/dist/conform/poll.js +1 -1
- package/dist/conform/properties.d.ts +1 -1
- package/dist/conform/properties.js +7 -11
- package/dist/conform/serve.js +4 -1
- package/dist/conform/server-card.js +1 -1
- package/dist/conform/webhook.js +1 -1
- package/dist/conform/webmcp.d.ts +1 -0
- package/dist/conform/webmcp.js +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/json/catalog.schema.json.js +5 -5
- package/dist/json/fixture.acidcat.json.js +4 -4
- package/dist/json/package.json.js +1 -1
- package/dist/main.js +10 -10
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ The AcidCat command line, published on npm as `@acid-cat/cli`. It gives the `aci
|
|
|
5
5
|
```sh
|
|
6
6
|
acid-cat check [--strict] [--output json] <catalog.json ...> # check catalogs
|
|
7
7
|
acid-cat format [--write] <catalog.json ...> # write catalogs in canonical form
|
|
8
|
-
acid-cat
|
|
8
|
+
acid-cat target <catalog.json> <target> # write the catalog of one target
|
|
9
9
|
acid-cat conform --mcp <url> [--mcp-handshake] --mcp-stdio "<command>" --http <url> --cli "<command>" --webmcp <url> [--deadline <ms>] [--max-bytes <n>] [--output json] # test an implementation
|
|
10
10
|
[--poll-buffer <n>] [--poll-lease-mcp <url> --poll-lease-ms <ms>] [--webhook-principal <name> --webhook-cert <file> --webhook-key <file>]
|
|
11
11
|
[--webhook-other-principal <name>] [--webhook-min-ttl-ms <ms>] [--webhook-max-ttl-ms <ms>] [--webhook-max-subscriptions <n>]
|
|
@@ -28,9 +28,9 @@ It needs Node.js 24 or later. `acid-cat conform --webmcp <url>` also needs [Play
|
|
|
28
28
|
`check` and `conform` take `--output human` (the default) or `--output json`. Human output is text for a person. JSON output is one JSON document on standard output, for a script or an agent, and nothing on standard error. The exit code is the same in both modes.
|
|
29
29
|
|
|
30
30
|
- `check`: `{ "conforms": boolean, "catalogs": [{ "file", "errors": [string], "warnings": [string] }] }`. `conforms` is `false` when the exit code is 1. A file that cannot be read, or that is not JSON, is a catalog with one error.
|
|
31
|
-
- `conform`: `{ "passed": number, "failed": number, "warnings": number, "checks": [{ "
|
|
31
|
+
- `conform`: `{ "passed": number, "failed": number, "warnings": number, "checks": [{ "surface", "name", "rule", "passed", "warning"?, "detail"? }] }`. A check with a warning has `"passed": true` and `"warning": true`, and counts in both `passed` and `warnings`.
|
|
32
32
|
|
|
33
|
-
You get the JSON document only when the options are correct. With incorrect options, the exit code is 1, and standard output can hold the help text. `conform` writes one line of text to standard error, and nothing to standard output, when it gets no
|
|
33
|
+
You get the JSON document only when the options are correct. With incorrect options, the exit code is 1, and standard output can hold the help text. `conform` writes one line of text to standard error, and nothing to standard output, when it gets no surface, only some of the `--webhook-*` options, or a certificate file that it cannot read.
|
|
34
34
|
|
|
35
35
|
## check
|
|
36
36
|
|
|
@@ -39,7 +39,7 @@ You get the JSON document only when the options are correct. With incorrect opti
|
|
|
39
39
|
- An **error** is a broken rule. Examples: an audience that names an unknown target, an event payload that is not an object, or an id that is both a capability and an event.
|
|
40
40
|
- A **warning** is a broken recommendation. Examples: a file that is not in [canonical form](../../spec/catalog.md#canonical-form), or a member with no `x-` prefix.
|
|
41
41
|
|
|
42
|
-
It also checks each alias in `options.cli` against the [alias rules](../../spec/
|
|
42
|
+
It also checks each alias in `options.cli` against the [alias rules](../../spec/surfaces/cli.md#aliases), and each `x-mcp-header` member in an input schema against the [header annotation rules](../../spec/surfaces/mcp.md#header-annotations) of MCP. An error about `x-mcp-header` names the capability or the event, and the location of the member as a JSON pointer into the bundled input schema.
|
|
43
43
|
|
|
44
44
|
The exit code is 1 with errors, and 0 otherwise. With `--strict`, warnings also give exit code 1.
|
|
45
45
|
|
|
@@ -47,28 +47,28 @@ The exit code is 1 with errors, and 0 otherwise. With `--strict`, warnings also
|
|
|
47
47
|
|
|
48
48
|
`format` writes a catalog in [canonical form](../../spec/catalog.md#canonical-form). Use it for catalogs that no catalog library wrote: Pkl output, generated files, or files you edit by hand. `--write` changes the files in place.
|
|
49
49
|
|
|
50
|
-
##
|
|
50
|
+
## target
|
|
51
51
|
|
|
52
|
-
`
|
|
52
|
+
`target` writes the [catalog of one target](../../spec/catalog.md#the-catalog-of-a-target): the capabilities, events and types that the target can use.
|
|
53
53
|
|
|
54
54
|
## conform
|
|
55
55
|
|
|
56
|
-
`conform` tests a running implementation of the [conformance fixture](conformance/fixture.pkl) through its
|
|
56
|
+
`conform` tests a running implementation of the [conformance fixture](conformance/fixture.pkl) through its surfaces. Each AcidCat core runs it in its tests.
|
|
57
57
|
|
|
58
58
|
### Options
|
|
59
59
|
|
|
60
|
-
Each flag has an equivalent option for `conform()` in code. Give one or more
|
|
60
|
+
Each flag has an equivalent option for `conform()` in code. Give one or more surfaces.
|
|
61
61
|
|
|
62
62
|
| Flag | In code | What it does |
|
|
63
63
|
| --- | --- | --- |
|
|
64
|
-
| `--mcp <url>` | `mcp` | Test the MCP
|
|
65
|
-
| `--mcp-handshake` | `mcpHandshake: true` | Also test the [`initialize` handshake of earlier revisions](../../spec/
|
|
66
|
-
| `--mcp-stdio "<command>"` | `mcpStdio` | Test the MCP
|
|
67
|
-
| `--http <url>` | `http` | Test the HTTP
|
|
68
|
-
| `--cli "<command>"` | `cli` | Test the CLI
|
|
69
|
-
| `--webmcp <url>` | `webmcp` | Test the WebMCP
|
|
64
|
+
| `--mcp <url>` | `mcp` | Test the MCP surface through HTTP |
|
|
65
|
+
| `--mcp-handshake` | `mcpHandshake: true` | Also test the [`initialize` handshake of earlier revisions](../../spec/surfaces/mcp.md#earlier-revisions-through-http) through HTTP |
|
|
66
|
+
| `--mcp-stdio "<command>"` | `mcpStdio` | Test the MCP surface through stdio. Each check starts the server as a process |
|
|
67
|
+
| `--http <url>` | `http` | Test the HTTP surface. The URL is the base URL, before `/capabilities` |
|
|
68
|
+
| `--cli "<command>"` | `cli` | Test the CLI surface |
|
|
69
|
+
| `--webmcp <url>` | `webmcp` | Test the WebMCP surface on a page that serves the `app` target. In code, `webmcp` can also be a function that installs the implementation on a host in the same process |
|
|
70
70
|
| `--deadline <ms>` | `deadline` | The deadline of each check. The default is 30 000 |
|
|
71
|
-
| `--max-bytes <n>` | `maximumBytes` | The body limit of the remote
|
|
71
|
+
| `--max-bytes <n>` | `maximumBytes` | The body limit of the remote surfaces, in bytes. The default is 1 048 576 |
|
|
72
72
|
| `--poll-buffer <n>` | `poll.bufferLimit` | The deployment's poll buffer size, from 1 to 97 |
|
|
73
73
|
| `--poll-lease-mcp <url>`, `--poll-lease-ms <ms>` | `pollLease: { mcp, leaseMs }` | An MCP server through HTTP with a poll lease time shorter than the deadline, and that lease time. Give both together |
|
|
74
74
|
| `--webhook-principal <name>`, `--webhook-cert <file>`, `--webhook-key <file>` | `webhook: { principal, cert, key }`, with the PEM text | Test webhook delivery. Give all three together |
|
|
@@ -85,13 +85,13 @@ Each flag has an equivalent option for `conform()` in code. Give one or more bin
|
|
|
85
85
|
- HTTP and CLI: Each outcome, each kind of call failure, availability and rejections. For the CLI: each kind of flag, usage lines, help, shared prefixes, aliases, interrupts with exit code 130, and `watch --cursor`.
|
|
86
86
|
- WebMCP: The checks act as the host: they open the page in Chromium through [Playwright](https://playwright.dev) with a test `modelContext`. Install it first: `pnpm add -D playwright`, then `pnpm exec playwright install chromium`.
|
|
87
87
|
- Events: Through HTTP, MCP and the CLI: the list of events, failures before the first occurrence, each occurrence against `schemas/occurrence.schema.json` and its payload schema, order, `truncated`, the cursor, each end, and cancellation. Through WebMCP, no event is a tool.
|
|
88
|
-
- [Poll delivery](../../spec/
|
|
89
|
-
- [Webhook delivery](../../spec/
|
|
90
|
-
- [Server Card](../../spec/
|
|
91
|
-
- [Hints](../../spec/
|
|
92
|
-
- [Heartbeat](../../spec/
|
|
93
|
-
- [Headers](../../spec/
|
|
94
|
-
- Properties: With fast-check, through MCP and HTTP: concurrent calls each get their own outcome, and a cancellation changes only its own call.
|
|
88
|
+
- [Poll delivery](../../spec/surfaces/mcp.md#poll): Through MCP, when `events/list` gives `poll`. Otherwise the check gives a warning and `events/poll` must answer `Unsupported`. `--poll-buffer` adds a cursor older than the buffer. The lease time of `--mcp` and `--mcp-stdio` must be longer than the deadline, because a check uses a lease for its whole time. `--poll-lease-mcp` with `--poll-lease-ms` adds the end of an unused lease. Serve it from a second MCP server with a lease time shorter than the deadline, for example 1000.
|
|
89
|
+
- [Webhook delivery](../../spec/surfaces/mcp.md#webhook): Through MCP over HTTP, with the three `--webhook-*` options. The checks run an HTTPS receiver on `127.0.0.1` with that certificate. Configure the deployment to trust the certificate, allow deliveries to private addresses, and give the principal `<name>` to a request with `Authorization: Bearer <name>`. The deadline must be longer than the deployment's first retry wait, and the maximum lifetime must be longer than the deadline. Give `--webhook-other-principal` with `--webhook-max-subscriptions`: the limit check then fills a principal that no other check uses. Without the webhook options, a server that does not list `webhook` must answer `Unsupported`.
|
|
90
|
+
- [Server Card](../../spec/surfaces/mcp.md#server-card): Through MCP over HTTP, when `<mcp>/server-card` gives 200. The card must pass the JSON Schema of the Server Card extension, have one remote with the URL of `--mcp`, the version of `server/discover` and the revisions that the server serves, the CORS and cache headers, 304 for its `ETag`, 204 for `OPTIONS`, public signing keys only, and egress ranges in CIDR text. With the webhook options and signing keys in the card, each webhook request must have one `v1a,` signature for each key, and each must verify. The JSON Schema is `conformance/server-card.schema.json`, from commit `28db12c` of [ext-server-card](https://github.com/modelcontextprotocol/ext-server-card), under the Apache License 2.0 in `conformance/server-card.LICENSE`.
|
|
91
|
+
- [Hints](../../spec/surfaces/mcp.md#tools): Each MCP tool's annotations match its capability's hints.
|
|
92
|
+
- [Heartbeat](../../spec/surfaces/mcp.md#push): Through MCP with each transport, each `notifications/events/active` grants a `heartbeatMs`. A suggestion is clamped between 1000 and 60 000, a heartbeat comes no sooner than the grant after the request and before the deadline ([why](../../spec/conformance.md#the-silence-before-a-heartbeat)), and a suggestion that is not valid gets `-32602`.
|
|
93
|
+
- [Headers](../../spec/surfaces/mcp.md#headers): Through MCP over HTTP, a missing or wrong `Mcp-Method`, `Mcp-Name` or `Mcp-Param-*` header on `tools/call` and `events/stream` gets 400 and `-32020`, and a value in the base64 form is decoded, with a leading U+FEFF kept. Every request of conform mirrors the annotated arguments of the fixture (`fixture.switch.set` and `fixture.ticks`) into their headers.
|
|
94
|
+
- Properties: With fast-check, through MCP and HTTP: concurrent calls each get their own outcome, and a cancellation changes only its own call. Each run of a property has the deadline.
|
|
95
95
|
|
|
96
96
|
Each poll check uses a new key, so leases from an earlier run do not change the result.
|
|
97
97
|
|
|
@@ -105,7 +105,7 @@ A failed check of a SHOULD rule gives a warning, marked `!`, and passes. The exi
|
|
|
105
105
|
|
|
106
106
|
### Use it in code
|
|
107
107
|
|
|
108
|
-
`conform()` and `serve()` come from `@acid-cat/cli
|
|
108
|
+
`conform()` and `serve()` come from `@acid-cat/cli`. Give `conform()` the signal of the test as `signal`, so that it stops when the test ends: each check that runs stops and kills the processes that it started, no other check and no other surface starts, and the promise rejects with the reason of the signal. This `serve()` is for tests only: it listens on `127.0.0.1`, on a free port, with plain HTTP. Like the servers of the cores, it closes no idle connection, so that a client of a test never sends a request on a connection while the server closes it. Its `close()` ends each idle connection at once, and ends each other connection when both its request and its response are complete, so it cuts no request that the server accepted. It resolves when every connection has ended, so a response that does not end, such as an open event stream, keeps it waiting. To serve an application, use its core's server: `serve` from `@acid-cat/core-ts/node`, `NodeServer` from `@acid-cat/core-effect`, or `remote::serve` from the crate `acid-cat-core`.
|
|
109
109
|
|
|
110
110
|
## Implementation
|
|
111
111
|
|
|
@@ -113,7 +113,7 @@ The command line is an [Effect](https://effect.website) program built on `effect
|
|
|
113
113
|
|
|
114
114
|
| File | Contents |
|
|
115
115
|
| --- | --- |
|
|
116
|
-
| `src/catalog.ts` | The catalog rules,
|
|
116
|
+
| `src/catalog.ts` | The catalog rules, the catalog of a target, and bundling |
|
|
117
117
|
| `src/main.ts` | The commands |
|
|
118
118
|
| `src/conform/` | The conformance checks, and `serve`, which serves web handlers on a local port for the tests |
|
|
119
119
|
| `conformance/` | The conformance fixture, in Pkl and in JSON |
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
"description": "One capability or event for each behavior that acid-cat conform tests.",
|
|
5
5
|
"targets": {
|
|
6
6
|
"api": {
|
|
7
|
-
"
|
|
7
|
+
"surfaces": [
|
|
8
8
|
"http"
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
11
|
"app": {
|
|
12
|
-
"
|
|
12
|
+
"surfaces": [
|
|
13
13
|
"typescript",
|
|
14
14
|
"webmcp"
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"cli": {
|
|
18
|
-
"
|
|
18
|
+
"surfaces": [
|
|
19
19
|
"cli"
|
|
20
20
|
],
|
|
21
21
|
"options": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
"mcp": {
|
|
93
|
-
"
|
|
93
|
+
"surfaces": [
|
|
94
94
|
"mcp"
|
|
95
95
|
]
|
|
96
96
|
}
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { bundle,
|
|
1
|
+
import { bundle, targetCatalog } from "@acid-cat/spec-ts";
|
|
2
2
|
import type { CatalogDocument as Catalog } from "@acid-cat/spec-ts";
|
|
3
|
-
export { bundle,
|
|
3
|
+
export { bundle, targetCatalog };
|
|
4
4
|
export type { Catalog };
|
|
5
5
|
/** The result of a check. An error breaks a rule. A warning breaks a recommendation. */
|
|
6
6
|
export interface Report {
|
package/dist/catalog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import catalog_schema_default from "./json/catalog.schema.json.js";
|
|
2
2
|
import { isObject, isRecordOf, isStringArray } from "./json.js";
|
|
3
3
|
import { canonicalText } from "@acid-cat/catalog";
|
|
4
|
-
import { REFERENCE, bundle, cliAliases, eventSchemasOf, mcpHeaderErrors, resolveType, schemasOf,
|
|
4
|
+
import { REFERENCE, bundle, cliAliases, eventSchemasOf, mcpHeaderErrors, resolveType, schemasOf, targetCatalog, visitObjects } from "@acid-cat/spec-ts";
|
|
5
5
|
import { Result, Schema, SchemaIssue, SchemaRepresentation } from "effect";
|
|
6
6
|
// src/catalog.ts
|
|
7
7
|
const KNOWN_MEMBERS = {
|
|
@@ -15,7 +15,7 @@ const KNOWN_MEMBERS = {
|
|
|
15
15
|
"events"
|
|
16
16
|
],
|
|
17
17
|
target: [
|
|
18
|
-
"
|
|
18
|
+
"surfaces",
|
|
19
19
|
"description",
|
|
20
20
|
"options"
|
|
21
21
|
],
|
|
@@ -41,7 +41,7 @@ const KNOWN_MEMBERS = {
|
|
|
41
41
|
const optional = (object, key, isMember) => !Object.hasOwn(object, key) || isMember(object[key]);
|
|
42
42
|
const isString = (value) => typeof value === "string";
|
|
43
43
|
const isBoolean = (value) => typeof value === "boolean";
|
|
44
|
-
const isTarget = (value) => isObject(value) && isStringArray(value.
|
|
44
|
+
const isTarget = (value) => isObject(value) && isStringArray(value.surfaces);
|
|
45
45
|
const isCapability = (value) => isObject(value) && typeof value.description === "string" && optional(value, "audience", isStringArray) && optional(value, "input", isObject) && optional(value, "output", isObject) && optional(value, "state", isObject) && optional(value, "failures", (failures) => isRecordOf(failures, isObject)) && optional(value, "readOnly", isBoolean) && optional(value, "destructive", isBoolean) && optional(value, "idempotent", isBoolean);
|
|
46
46
|
const isEvent = (value) => isObject(value) && typeof value.description === "string" && optional(value, "audience", isStringArray) && optional(value, "input", isObject) && optional(value, "payload", isObject);
|
|
47
47
|
const isCatalog = (value) => isObject(value) && typeof value.acidcat === "string" && optional(value, "title", isString) && optional(value, "description", isString) && isRecordOf(value.targets, isTarget) && optional(value, "$defs", (types) => isRecordOf(types, isObject)) && isRecordOf(value.capabilities, isCapability) && optional(value, "events", (events) => isRecordOf(events, isEvent));
|
|
@@ -146,4 +146,4 @@ function referenceErrors(schema, types) {
|
|
|
146
146
|
});
|
|
147
147
|
return errors;
|
|
148
148
|
}
|
|
149
|
-
export { bundle, check, isCatalog,
|
|
149
|
+
export { bundle, check, isCatalog, targetCatalog };
|
package/dist/conform/check.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CatalogDocument, Occurrence, Outcome } from "@acid-cat/spec-ts";
|
|
2
2
|
export interface Check {
|
|
3
|
-
readonly
|
|
3
|
+
readonly surface: string;
|
|
4
4
|
readonly name: string;
|
|
5
|
-
/** The part of the specification that the check tests, for example `spec/
|
|
5
|
+
/** The part of the specification that the check tests, for example `spec/surfaces/mcp.md#tools`. */
|
|
6
6
|
readonly rule: string;
|
|
7
7
|
readonly passed: boolean;
|
|
8
8
|
/** `true` when the check tests a recommendation (SHOULD) that the implementation does not follow. The check still passes. */
|
|
@@ -16,15 +16,24 @@ export declare const idsOf: (target: string) => string[];
|
|
|
16
16
|
export declare const eventIdsOf: (target: string) => string[];
|
|
17
17
|
export declare function expectOccurrence(value: unknown, id: string): Occurrence;
|
|
18
18
|
export declare const DEADLINE = 30000;
|
|
19
|
+
/** A signal that aborts when `signal` aborts, or when `stop`, the signal that stops conform, aborts. */
|
|
20
|
+
export declare const orStop: (signal: AbortSignal, stop: AbortSignal | undefined) => AbortSignal;
|
|
19
21
|
type Body = (signal: AbortSignal) => Promise<void> | void;
|
|
20
22
|
export type Define = (name: string, rule: string, body: Body) => void;
|
|
21
23
|
export declare class Checks {
|
|
22
24
|
#private;
|
|
23
25
|
readonly results: Check[];
|
|
24
|
-
readonly
|
|
26
|
+
readonly surface: string;
|
|
25
27
|
readonly deadline: number;
|
|
26
|
-
|
|
28
|
+
/** When it aborts, each check that runs stops as at its deadline, and no other check starts. */
|
|
29
|
+
readonly signal: AbortSignal | undefined;
|
|
30
|
+
constructor(surface: string, deadline: number, signal?: AbortSignal);
|
|
27
31
|
run(name: string, rule: string, body: Body): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Run a check of several runs, such as the runs of a property. Each run has the deadline, so the number of runs that
|
|
34
|
+
* fit in the check does not depend on the speed of the computer.
|
|
35
|
+
*/
|
|
36
|
+
runEach(name: string, rule: string, body: (each: (run: Body) => Promise<void>) => Promise<void>): Promise<void>;
|
|
28
37
|
concurrently(define: (check: Define) => void): Promise<void>;
|
|
29
38
|
should(name: string, rule: string, body: Body): Promise<void>;
|
|
30
39
|
}
|
package/dist/conform/check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fixture_acidcat_default from "../json/fixture.acidcat.json.js";
|
|
2
2
|
import { isObject } from "../json.js";
|
|
3
|
-
import { CALL_FAILURE_KINDS, isOccurrence,
|
|
3
|
+
import { CALL_FAILURE_KINDS, isOccurrence, targetCatalog } from "@acid-cat/spec-ts";
|
|
4
4
|
import { Schema, SchemaRepresentation } from "effect";
|
|
5
5
|
import { availableParallelism } from "node:os";
|
|
6
6
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
@@ -13,8 +13,8 @@ const isOutcome = (value) => {
|
|
|
13
13
|
if (value.ok === false) return "error" in value;
|
|
14
14
|
return !("ok" in value) && CALL_FAILURE_KINDS.some((kind) => kind === value.kind) && typeof value.message === "string";
|
|
15
15
|
};
|
|
16
|
-
const idsOf = (target) => Object.keys(
|
|
17
|
-
const eventIdsOf = (target) => Object.keys(
|
|
16
|
+
const idsOf = (target) => Object.keys(targetCatalog(fixture, target).capabilities).sort();
|
|
17
|
+
const eventIdsOf = (target) => Object.keys(targetCatalog(fixture, target).events ?? {}).sort();
|
|
18
18
|
const payloadChecks = /* @__PURE__ */ new Map();
|
|
19
19
|
function agreesWithPayload(id, data) {
|
|
20
20
|
let agrees = payloadChecks.get(id);
|
|
@@ -41,17 +41,43 @@ function expectOccurrence(value, id) {
|
|
|
41
41
|
return value;
|
|
42
42
|
}
|
|
43
43
|
const DEADLINE = 3e4;
|
|
44
|
+
/** A signal that aborts when `signal` aborts, or when `stop`, the signal that stops conform, aborts. */
|
|
45
|
+
const orStop = (signal, stop) => stop === void 0 ? signal : AbortSignal.any([signal, stop]);
|
|
44
46
|
var Checks = class {
|
|
45
47
|
results = [];
|
|
46
|
-
|
|
48
|
+
surface;
|
|
47
49
|
deadline;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
/** When it aborts, each check that runs stops as at its deadline, and no other check starts. */
|
|
51
|
+
signal;
|
|
52
|
+
constructor(surface, deadline, signal) {
|
|
53
|
+
this.surface = surface;
|
|
50
54
|
this.deadline = deadline;
|
|
55
|
+
this.signal = signal;
|
|
51
56
|
}
|
|
52
57
|
async run(name, rule, body) {
|
|
53
58
|
this.results.push(this.#result(name, rule, await this.#settle(body)));
|
|
54
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Run a check of several runs, such as the runs of a property. Each run has the deadline, so the number of runs that
|
|
62
|
+
* fit in the check does not depend on the speed of the computer.
|
|
63
|
+
*/
|
|
64
|
+
async runEach(name, rule, body) {
|
|
65
|
+
let late = false;
|
|
66
|
+
const each = async (run) => {
|
|
67
|
+
const failure = await this.#settle(run);
|
|
68
|
+
if (failure === void 0) return;
|
|
69
|
+
late ||= failure.startsWith("did not settle");
|
|
70
|
+
throw new Error(failure);
|
|
71
|
+
};
|
|
72
|
+
let failure;
|
|
73
|
+
try {
|
|
74
|
+
await body(each);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
77
|
+
failure = late && !message.startsWith("did not settle") ? `did not settle within ${this.deadline} ms: ${message}` : message;
|
|
78
|
+
}
|
|
79
|
+
this.results.push(this.#result(name, rule, failure));
|
|
80
|
+
}
|
|
55
81
|
async concurrently(define) {
|
|
56
82
|
const defined = [];
|
|
57
83
|
define((name, rule, body) => defined.push({
|
|
@@ -69,12 +95,12 @@ var Checks = class {
|
|
|
69
95
|
}
|
|
70
96
|
#result(name, rule, failure) {
|
|
71
97
|
return failure === void 0 ? {
|
|
72
|
-
|
|
98
|
+
surface: this.surface,
|
|
73
99
|
name,
|
|
74
100
|
rule,
|
|
75
101
|
passed: true
|
|
76
102
|
} : {
|
|
77
|
-
|
|
103
|
+
surface: this.surface,
|
|
78
104
|
name,
|
|
79
105
|
rule,
|
|
80
106
|
passed: false,
|
|
@@ -84,12 +110,12 @@ var Checks = class {
|
|
|
84
110
|
async should(name, rule, body) {
|
|
85
111
|
const failure = await this.#settle(body);
|
|
86
112
|
this.results.push(failure === void 0 ? {
|
|
87
|
-
|
|
113
|
+
surface: this.surface,
|
|
88
114
|
name,
|
|
89
115
|
rule,
|
|
90
116
|
passed: true
|
|
91
117
|
} : {
|
|
92
|
-
|
|
118
|
+
surface: this.surface,
|
|
93
119
|
name,
|
|
94
120
|
rule,
|
|
95
121
|
passed: true,
|
|
@@ -97,17 +123,25 @@ var Checks = class {
|
|
|
97
123
|
detail: failure
|
|
98
124
|
});
|
|
99
125
|
}
|
|
126
|
+
#stopped() {
|
|
127
|
+
return this.signal?.aborted === true;
|
|
128
|
+
}
|
|
100
129
|
async #settle(body) {
|
|
130
|
+
if (this.#stopped()) return "conform stopped before the check";
|
|
101
131
|
const controller = new AbortController();
|
|
102
|
-
const
|
|
132
|
+
const stop = () => controller.abort();
|
|
133
|
+
const timer = setTimeout(stop, this.deadline);
|
|
134
|
+
this.signal?.addEventListener("abort", stop, { once: true });
|
|
103
135
|
try {
|
|
104
136
|
await body(controller.signal);
|
|
105
137
|
return;
|
|
106
138
|
} catch (error) {
|
|
107
139
|
const message = error instanceof Error ? error.message : String(error);
|
|
140
|
+
if (this.#stopped()) return `conform stopped during the check: ${message}`;
|
|
108
141
|
return controller.signal.aborted ? `did not settle within ${this.deadline} ms: ${message}` : message;
|
|
109
142
|
} finally {
|
|
110
143
|
clearTimeout(timer);
|
|
144
|
+
this.signal?.removeEventListener("abort", stop);
|
|
111
145
|
controller.abort();
|
|
112
146
|
}
|
|
113
147
|
}
|
|
@@ -141,4 +175,4 @@ function expectEqual(actual, expected, what) {
|
|
|
141
175
|
}
|
|
142
176
|
const sorted = (values) => [...values].sort();
|
|
143
177
|
const FORBIDDEN_ORIGIN = "https://not-allowed.acid-cat.invalid";
|
|
144
|
-
export { Checks, DEADLINE, FORBIDDEN_ORIGIN, abortable, eventIdsOf, expect, expectEqual, expectOccurrence, fixture, idsOf, isOutcome, sorted, until };
|
|
178
|
+
export { Checks, DEADLINE, FORBIDDEN_ORIGIN, abortable, eventIdsOf, expect, expectEqual, expectOccurrence, fixture, idsOf, isOutcome, orStop, sorted, until };
|
package/dist/conform/cli.d.ts
CHANGED
package/dist/conform/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isArrayOf, isObject, memberOf, parseJson } from "../json.js";
|
|
2
|
-
import { Checks, abortable, eventIdsOf, expect, expectEqual, expectOccurrence, idsOf, sorted, until } from "./check.js";
|
|
2
|
+
import { Checks, abortable, eventIdsOf, expect, expectEqual, expectOccurrence, idsOf, orStop, sorted, until } from "./check.js";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -7,7 +7,7 @@ import { mkdtemp, rm } from "node:fs/promises";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { isDeepStrictEqual } from "node:util";
|
|
9
9
|
// src/conform/cli.ts
|
|
10
|
-
const RULE = "spec/
|
|
10
|
+
const RULE = "spec/surfaces/cli.md";
|
|
11
11
|
const USAGES = {
|
|
12
12
|
"fixture.crash": "fixture crash",
|
|
13
13
|
"fixture.echo": "fixture echo --text <string>",
|
|
@@ -100,9 +100,9 @@ function occurrencesIn(stdout, id) {
|
|
|
100
100
|
return stdout.split("\n").filter((line) => line !== "").map((line) => expectOccurrence(parseJson(line), id));
|
|
101
101
|
}
|
|
102
102
|
async function checkCli(command, options) {
|
|
103
|
-
const checks = new Checks("cli", options.deadline);
|
|
103
|
+
const checks = new Checks("cli", options.deadline, options.signal);
|
|
104
104
|
const run = (signal, ...args) => start(command, args, signal).run;
|
|
105
|
-
const listing = start(command, ["list"], AbortSignal.timeout(options.deadline)).run.then((result) => entriesOf(result.stdout));
|
|
105
|
+
const listing = start(command, ["list"], orStop(AbortSignal.timeout(options.deadline), options.signal)).run.then((result) => entriesOf(result.stdout));
|
|
106
106
|
listing.catch(() => void 0);
|
|
107
107
|
const listed = (signal) => abortable(listing, signal);
|
|
108
108
|
await checks.concurrently((check) => {
|
|
@@ -148,12 +148,12 @@ async function checkCli(command, options) {
|
|
|
148
148
|
2
|
|
149
149
|
],
|
|
150
150
|
[
|
|
151
|
-
"a capability outside the
|
|
151
|
+
"a capability outside the target has exit code 2",
|
|
152
152
|
["call", "fixture.hidden"],
|
|
153
153
|
2
|
|
154
154
|
],
|
|
155
155
|
[
|
|
156
|
-
"a capability outside the
|
|
156
|
+
"a capability outside the target with input that is not JSON has exit code 2",
|
|
157
157
|
[
|
|
158
158
|
"call",
|
|
159
159
|
"fixture.hidden",
|
|
@@ -317,7 +317,7 @@ async function checkCli(command, options) {
|
|
|
317
317
|
expectEqual(result.code, 0, "exit code");
|
|
318
318
|
expectEqual(parseJson(result.stdout), { text: "hello" }, "standard output");
|
|
319
319
|
});
|
|
320
|
-
check("list gives the
|
|
320
|
+
check("list gives the capabilities of the target, then its events", `${RULE}#commands`, async (signal) => {
|
|
321
321
|
const entries = await listed(signal);
|
|
322
322
|
const ids = (kind) => entries.filter((entry) => entry.kind === kind).map((entry) => entry.id);
|
|
323
323
|
expectEqual(sorted(ids("capability")), idsOf("cli"), "the ids of the items with kind: capability");
|
|
@@ -655,7 +655,7 @@ function checkWatch(check, command) {
|
|
|
655
655
|
3
|
|
656
656
|
],
|
|
657
657
|
[
|
|
658
|
-
"watch of an event outside the
|
|
658
|
+
"watch of an event outside the target has exit code 2",
|
|
659
659
|
["watch", "fixture.secret"],
|
|
660
660
|
2
|
|
661
661
|
],
|
package/dist/conform/http.d.ts
CHANGED
package/dist/conform/http.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
const RULE = "spec/
|
|
6
|
+
const RULE = "spec/surfaces/http.md";
|
|
7
7
|
const isEntry = (value) => isObject(value) && typeof value.id === "string";
|
|
8
8
|
async function entriesOf(response) {
|
|
9
9
|
const list = await readJson(response);
|
|
@@ -11,7 +11,7 @@ async function entriesOf(response) {
|
|
|
11
11
|
return list;
|
|
12
12
|
}
|
|
13
13
|
async function checkHttp(base, options) {
|
|
14
|
-
const checks = new Checks("http", options.deadline);
|
|
14
|
+
const checks = new Checks("http", options.deadline, options.signal);
|
|
15
15
|
const post = (signal, id, body, headers = {}) => fetch(`${base}/capabilities/${id}`, {
|
|
16
16
|
method: "POST",
|
|
17
17
|
headers: {
|
|
@@ -22,7 +22,7 @@ async function checkHttp(base, options) {
|
|
|
22
22
|
signal
|
|
23
23
|
});
|
|
24
24
|
const kindOf = async (response) => memberOf(await readJson(response), "kind");
|
|
25
|
-
await checks.run("GET /capabilities lists the
|
|
25
|
+
await checks.run("GET /capabilities lists the capabilities of the target with their availability", `${RULE}#requests`, async (signal) => {
|
|
26
26
|
const list = await entriesOf(await fetch(`${base}/capabilities`, { signal }));
|
|
27
27
|
expectEqual(sorted(list.map((entry) => entry.id)), idsOf("api"), "ids");
|
|
28
28
|
expect(list.every((entry) => typeof entry.available === "boolean"), "each entry must have available");
|
|
@@ -50,7 +50,7 @@ async function checkHttp(base, options) {
|
|
|
50
50
|
"invalid-input"
|
|
51
51
|
],
|
|
52
52
|
[
|
|
53
|
-
"a capability outside the
|
|
53
|
+
"a capability outside the target has the status 404",
|
|
54
54
|
"fixture.hidden",
|
|
55
55
|
{},
|
|
56
56
|
404,
|
|
@@ -171,14 +171,14 @@ async function checkEvents(checks, base) {
|
|
|
171
171
|
expect(typeof delivered === "number", `fixture.signal must give the number of subscriptions, got ${JSON.stringify(delivered)}`);
|
|
172
172
|
return delivered;
|
|
173
173
|
};
|
|
174
|
-
await checks.run("GET /events lists the events of the
|
|
174
|
+
await checks.run("GET /events lists the events of the target", `${RULE}#requests`, async (signal) => {
|
|
175
175
|
const list = await readJson(await fetch(`${base}/events`, { signal }));
|
|
176
176
|
if (!isArrayOf(list, isEntry)) throw new Error(`GET /events must give a list of objects with an id, got ${JSON.stringify(list)}`);
|
|
177
177
|
expectEqual(sorted(list.map((entry) => entry.id)), eventIdsOf("api"), "ids");
|
|
178
178
|
});
|
|
179
179
|
for (const [name, id, input, status, kind] of [
|
|
180
180
|
[
|
|
181
|
-
"a subscription to an event outside the
|
|
181
|
+
"a subscription to an event outside the target has the status 404",
|
|
182
182
|
"fixture.secret",
|
|
183
183
|
{},
|
|
184
184
|
404,
|
package/dist/conform/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ConformOptions {
|
|
|
15
15
|
readonly mcp?: string | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* Check the `initialize` handshake of revision 2025-11-25 through the MCP server too
|
|
18
|
-
* (spec/
|
|
18
|
+
* (spec/surfaces/mcp.md#earlier-revisions-through-http). The default is `false`.
|
|
19
19
|
*/
|
|
20
20
|
readonly mcpHandshake?: boolean | undefined;
|
|
21
21
|
/**
|
|
@@ -28,7 +28,7 @@ export interface ConformOptions {
|
|
|
28
28
|
/** The command that starts the command line, for example `["node", "fixture-cli.ts"]`. */
|
|
29
29
|
readonly cli?: readonly string[] | undefined;
|
|
30
30
|
/**
|
|
31
|
-
* The WebMCP
|
|
31
|
+
* The WebMCP surface: the URL of a page that serves the `app` target, or a function that installs the implementation
|
|
32
32
|
* on a host in the same process. A page runs in Chromium, through Playwright.
|
|
33
33
|
*/
|
|
34
34
|
readonly webmcp?: string | WebMcpInstall | undefined;
|
|
@@ -51,13 +51,19 @@ export interface ConformOptions {
|
|
|
51
51
|
* header `Authorization: Bearer <principal>`.
|
|
52
52
|
*/
|
|
53
53
|
readonly webhook?: WebhookSettings | undefined;
|
|
54
|
-
/** The body limit of the remote
|
|
54
|
+
/** The body limit of the remote surfaces, in bytes. The default is 1 MiB. */
|
|
55
55
|
readonly maximumBytes?: number | undefined;
|
|
56
56
|
/**
|
|
57
57
|
* The time, in milliseconds, that each check has to settle. A check that does not settle in this time fails. The
|
|
58
58
|
* default is `DEADLINE`, 30 seconds.
|
|
59
59
|
*/
|
|
60
60
|
readonly deadline?: number | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* When it aborts, conform stops: each check that runs stops as at its deadline and cleans up, no other check and no
|
|
63
|
+
* other surface starts, and the promise rejects with the reason of the signal. A test gives its own signal, so that
|
|
64
|
+
* conform ends with the test.
|
|
65
|
+
*/
|
|
66
|
+
readonly signal?: AbortSignal | undefined;
|
|
61
67
|
}
|
|
62
|
-
/** Run all checks for the
|
|
68
|
+
/** Run all checks for the surfaces that the options give. */
|
|
63
69
|
export declare function conform(options: ConformOptions): Promise<readonly Check[]>;
|
package/dist/conform/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Checks, DEADLINE, fixture } from "./check.js";
|
|
1
|
+
import { Checks, DEADLINE, fixture, orStop } from "./check.js";
|
|
2
2
|
import { checkCli } from "./cli.js";
|
|
3
3
|
import { checkHttp } from "./http.js";
|
|
4
4
|
import { checkMcp, httpChannel } from "./mcp.js";
|
|
@@ -8,50 +8,72 @@ import { browserDriver, checkWebMcp, processDriver } from "./webmcp.js";
|
|
|
8
8
|
import { checkPollLease } from "./poll.js";
|
|
9
9
|
import { serve } from "./serve.js";
|
|
10
10
|
// src/conform/index.ts
|
|
11
|
-
/** Run all checks for the
|
|
11
|
+
/** Run all checks for the surfaces that the options give. */
|
|
12
12
|
async function conform(options) {
|
|
13
13
|
const maximumBytes = options.maximumBytes ?? 1048576;
|
|
14
14
|
const deadline = options.deadline ?? 3e4;
|
|
15
15
|
const poll = options.poll ?? {};
|
|
16
|
+
const { signal } = options;
|
|
16
17
|
const results = [];
|
|
18
|
+
signal?.throwIfAborted();
|
|
17
19
|
if (options.mcp !== void 0) {
|
|
18
20
|
results.push(...(await checkMcp(options.mcp, {
|
|
19
21
|
maximumBytes,
|
|
20
22
|
deadline,
|
|
23
|
+
signal,
|
|
21
24
|
handshake: options.mcpHandshake === true,
|
|
22
25
|
poll,
|
|
23
26
|
webhook: options.webhook
|
|
24
27
|
})).results);
|
|
25
|
-
|
|
28
|
+
signal?.throwIfAborted();
|
|
29
|
+
const mcp = await mcpInvoke(options.mcp, orStop(AbortSignal.timeout(deadline), signal)).catch(() => void 0);
|
|
26
30
|
if (mcp !== void 0) {
|
|
27
|
-
results.push(...(await checkProperties("mcp", mcp.invoke, deadline)).results);
|
|
31
|
+
results.push(...(await checkProperties("mcp", mcp.invoke, deadline, signal)).results);
|
|
28
32
|
await mcp.close();
|
|
29
33
|
}
|
|
34
|
+
signal?.throwIfAborted();
|
|
30
35
|
}
|
|
31
36
|
if (options.pollLease !== void 0) {
|
|
32
|
-
const checks = new Checks("mcp", deadline);
|
|
37
|
+
const checks = new Checks("mcp", deadline, signal);
|
|
33
38
|
await checkPollLease(checks, httpChannel(options.pollLease.mcp), options.pollLease.leaseMs);
|
|
34
39
|
results.push(...checks.results);
|
|
40
|
+
signal?.throwIfAborted();
|
|
41
|
+
}
|
|
42
|
+
if (options.mcpStdio !== void 0) {
|
|
43
|
+
for (const checks of await checkMcpStdio(options.mcpStdio, {
|
|
44
|
+
deadline,
|
|
45
|
+
signal,
|
|
46
|
+
poll
|
|
47
|
+
})) results.push(...checks.results);
|
|
48
|
+
signal?.throwIfAborted();
|
|
35
49
|
}
|
|
36
|
-
if (options.mcpStdio !== void 0) for (const checks of await checkMcpStdio(options.mcpStdio, {
|
|
37
|
-
deadline,
|
|
38
|
-
poll
|
|
39
|
-
})) results.push(...checks.results);
|
|
40
50
|
if (options.http !== void 0) {
|
|
41
51
|
results.push(...(await checkHttp(options.http, {
|
|
42
52
|
maximumBytes,
|
|
43
|
-
deadline
|
|
53
|
+
deadline,
|
|
54
|
+
signal
|
|
55
|
+
})).results);
|
|
56
|
+
results.push(...(await checkProperties("http", httpInvoke(options.http), deadline, signal)).results);
|
|
57
|
+
signal?.throwIfAborted();
|
|
58
|
+
}
|
|
59
|
+
if (options.cli !== void 0) {
|
|
60
|
+
results.push(...(await checkCli(options.cli, {
|
|
61
|
+
deadline,
|
|
62
|
+
signal
|
|
44
63
|
})).results);
|
|
45
|
-
|
|
64
|
+
signal?.throwIfAborted();
|
|
46
65
|
}
|
|
47
|
-
if (options.cli !== void 0) results.push(...(await checkCli(options.cli, { deadline })).results);
|
|
48
66
|
if (options.webmcp !== void 0) {
|
|
49
67
|
const driver = typeof options.webmcp === "string" ? await browserDriver(options.webmcp) : await processDriver(options.webmcp);
|
|
50
68
|
try {
|
|
51
|
-
results.push(...(await checkWebMcp(driver, {
|
|
69
|
+
results.push(...(await checkWebMcp(driver, {
|
|
70
|
+
deadline,
|
|
71
|
+
signal
|
|
72
|
+
})).results);
|
|
52
73
|
} finally {
|
|
53
74
|
await driver.close();
|
|
54
75
|
}
|
|
76
|
+
signal?.throwIfAborted();
|
|
55
77
|
}
|
|
56
78
|
return results;
|
|
57
79
|
}
|
|
@@ -2,5 +2,6 @@ import { Checks } from "./check.js";
|
|
|
2
2
|
import type { PollSettings } from "./poll.js";
|
|
3
3
|
export declare function checkMcpStdio(command: readonly string[], options: {
|
|
4
4
|
readonly deadline: number;
|
|
5
|
+
readonly signal?: AbortSignal | undefined;
|
|
5
6
|
readonly poll: PollSettings;
|
|
6
7
|
}): Promise<readonly Checks[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject, memberOf } from "../json.js";
|
|
2
|
-
import { Checks, abortable, expect, expectEqual, until } from "./check.js";
|
|
2
|
+
import { Checks, abortable, expect, expectEqual, orStop, until } from "./check.js";
|
|
3
3
|
import { META, checkEvents, checkTools, subscriptionOf } from "./mcp.js";
|
|
4
4
|
import { checkProperties, clientInvoke } from "./properties.js";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
@@ -7,7 +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
|
-
const RULE = "spec/
|
|
10
|
+
const RULE = "spec/surfaces/mcp.md#stdio";
|
|
11
11
|
const ERAS = [{
|
|
12
12
|
revision: "2026-07-28",
|
|
13
13
|
connects: "an MCP client connects with revision 2026-07-28",
|
|
@@ -46,7 +46,7 @@ async function connect(command, options, changes, signal) {
|
|
|
46
46
|
async function checkMcpStdio(command, options) {
|
|
47
47
|
const all = [];
|
|
48
48
|
for (const era of ERAS) {
|
|
49
|
-
const checks = new Checks(`mcp-stdio ${era.revision}`, options.deadline);
|
|
49
|
+
const checks = new Checks(`mcp-stdio ${era.revision}`, options.deadline, options.signal);
|
|
50
50
|
all.push(checks);
|
|
51
51
|
const changes = { count: 0 };
|
|
52
52
|
let client;
|
|
@@ -59,7 +59,7 @@ async function checkMcpStdio(command, options) {
|
|
|
59
59
|
try {
|
|
60
60
|
await checkTools(checks, mcp);
|
|
61
61
|
await checkChanges(checks, mcp, changes);
|
|
62
|
-
all.push(await checkProperties(`mcp-stdio ${era.revision} properties`, clientInvoke(mcp), options.deadline));
|
|
62
|
+
all.push(await checkProperties(`mcp-stdio ${era.revision} properties`, clientInvoke(mcp), options.deadline, options.signal));
|
|
63
63
|
} finally {
|
|
64
64
|
await mcp.close();
|
|
65
65
|
}
|
|
@@ -69,9 +69,9 @@ async function checkMcpStdio(command, options) {
|
|
|
69
69
|
return all;
|
|
70
70
|
}
|
|
71
71
|
async function checkStdioEvents(command, options) {
|
|
72
|
-
const checks = new Checks("mcp-stdio events", options.deadline);
|
|
72
|
+
const checks = new Checks("mcp-stdio events", options.deadline, options.signal);
|
|
73
73
|
const controller = new AbortController();
|
|
74
|
-
const server = startRaw(command, controller.signal);
|
|
74
|
+
const server = startRaw(command, orStop(controller.signal, options.signal));
|
|
75
75
|
try {
|
|
76
76
|
await checkEvents(checks, stdioChannel(server), {
|
|
77
77
|
transport: "stdio",
|
|
@@ -222,7 +222,7 @@ async function handshake(server, revision = "2025-11-25") {
|
|
|
222
222
|
return response;
|
|
223
223
|
}
|
|
224
224
|
async function checkLines(command, options) {
|
|
225
|
-
const checks = new Checks("mcp-stdio", options.deadline);
|
|
225
|
+
const checks = new Checks("mcp-stdio", options.deadline, options.signal);
|
|
226
226
|
const withServer = (body) => async (signal) => {
|
|
227
227
|
const controller = new AbortController();
|
|
228
228
|
const server = startRaw(command, AbortSignal.any([controller.signal, signal]));
|
package/dist/conform/mcp.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare function mcpClient(url: string, signal?: AbortSignal, handshake?:
|
|
|
7
7
|
export interface McpCheckOptions {
|
|
8
8
|
readonly maximumBytes: number;
|
|
9
9
|
readonly deadline: number;
|
|
10
|
+
readonly signal?: AbortSignal | undefined;
|
|
10
11
|
readonly handshake: boolean;
|
|
11
12
|
readonly poll: PollSettings;
|
|
12
13
|
readonly webhook: WebhookSettings | undefined;
|
package/dist/conform/mcp.js
CHANGED
|
@@ -4,11 +4,13 @@ import { checkPoll } from "./poll.js";
|
|
|
4
4
|
import { sseReader } from "./sse.js";
|
|
5
5
|
import { checkServerCard, signingKeysOf } from "./server-card.js";
|
|
6
6
|
import { checkWebhook } from "./webhook.js";
|
|
7
|
-
import { MCP_EVENTS_EXTENSION, MCP_HEADER_MISMATCH, MCP_HEARTBEAT_MAX_MS, MCP_HEARTBEAT_MIN_MS, MCP_PROTOCOL_VERSION_KEY, MCP_SUBSCRIPTION_ID, bundle, encodeMcpHeaderValue, mcpParamHeaders,
|
|
7
|
+
import { MCP_EVENTS_EXTENSION, MCP_HEADER_MISMATCH, MCP_HEARTBEAT_MAX_MS, MCP_HEARTBEAT_MIN_MS, MCP_PROTOCOL_VERSION_KEY, MCP_SUBSCRIPTION_ID, bundle, encodeMcpHeaderValue, mcpParamHeaders, targetCatalog } from "@acid-cat/spec-ts";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
9
|
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
10
10
|
// src/conform/mcp.ts
|
|
11
|
-
const RULE = "spec/
|
|
11
|
+
const RULE = "spec/surfaces/mcp.md";
|
|
12
|
+
/** Runtimes measure the idle time of a stream with timers of 1 ms resolution, so a heartbeat can come 1 ms early. */
|
|
13
|
+
const TIMER_RESOLUTION_MS = 1;
|
|
12
14
|
async function mcpClient(url, signal, handshake = false) {
|
|
13
15
|
const client = new Client({
|
|
14
16
|
name: "acid-cat-conform",
|
|
@@ -22,7 +24,7 @@ const textOf = (result) => {
|
|
|
22
24
|
return parseJson(first?.type === "text" ? first.text : "null");
|
|
23
25
|
};
|
|
24
26
|
async function checkMcp(url, options) {
|
|
25
|
-
const checks = new Checks("mcp", options.deadline);
|
|
27
|
+
const checks = new Checks("mcp", options.deadline, options.signal);
|
|
26
28
|
let client;
|
|
27
29
|
await checks.run("an MCP client connects with revision 2026-07-28", `${RULE}#http`, async (signal) => {
|
|
28
30
|
client = await mcpClient(url, signal);
|
|
@@ -86,12 +88,12 @@ async function checkMcp(url, options) {
|
|
|
86
88
|
if (options.handshake) await checkHandshake(checks, url, options.deadline);
|
|
87
89
|
return checks;
|
|
88
90
|
}
|
|
89
|
-
const
|
|
91
|
+
const mcpCatalog = targetCatalog(fixture, "mcp");
|
|
90
92
|
function inputSchemaOf(method, name) {
|
|
91
93
|
if (typeof name !== "string") return void 0;
|
|
92
|
-
const entries = method === "tools/call" ?
|
|
94
|
+
const entries = method === "tools/call" ? mcpCatalog.capabilities : method.startsWith("events/") ? mcpCatalog.events ?? {} : {};
|
|
93
95
|
const input = Object.hasOwn(entries, name) ? entries[name]?.input : void 0;
|
|
94
|
-
return input === void 0 ? void 0 : bundle(input,
|
|
96
|
+
return input === void 0 ? void 0 : bundle(input, mcpCatalog.$defs ?? {});
|
|
95
97
|
}
|
|
96
98
|
function mcpRequestHeaders(method, params) {
|
|
97
99
|
return {
|
|
@@ -224,7 +226,7 @@ async function checkHeaders(checks, url) {
|
|
|
224
226
|
}
|
|
225
227
|
const ANCHOR = `${RULE}#earlier-revisions-through-http`;
|
|
226
228
|
async function checkHandshake(checks, url, deadline) {
|
|
227
|
-
const handshakeChecks = new Checks("mcp 2025-11-25", deadline);
|
|
229
|
+
const handshakeChecks = new Checks("mcp 2025-11-25", deadline, checks.signal);
|
|
228
230
|
let client;
|
|
229
231
|
await handshakeChecks.run("an MCP client connects with the initialize handshake of revision 2025-11-25", ANCHOR, async (signal) => {
|
|
230
232
|
client = await mcpClient(url, signal, true);
|
|
@@ -279,7 +281,7 @@ async function checkTools(checks, mcp) {
|
|
|
279
281
|
await checks.run("the instructions are the description of the catalog", `${RULE}#server`, () => {
|
|
280
282
|
expectEqual(mcp.getInstructions(), fixture.description, "instructions");
|
|
281
283
|
});
|
|
282
|
-
await checks.run("tools/list gives each available capability of the
|
|
284
|
+
await checks.run("tools/list gives each available capability of the target", `${RULE}#tools`, async (signal) => {
|
|
283
285
|
const { tools } = await mcp.listTools(void 0, { signal });
|
|
284
286
|
expectEqual(sorted(tools.map((tool) => tool.name)), idsOf("mcp"), "tools");
|
|
285
287
|
});
|
|
@@ -325,7 +327,7 @@ async function checkTools(checks, mcp) {
|
|
|
325
327
|
const result = await call(signal, "fixture.echo", { text: 1 });
|
|
326
328
|
expectEqual(memberOf(textOf(result), "kind"), "invalid-input", "kind");
|
|
327
329
|
});
|
|
328
|
-
await checks.run("a capability outside the
|
|
330
|
+
await checks.run("a capability outside the target is an unknown tool", `${RULE}#tools`, async (signal) => {
|
|
329
331
|
const error = await call(signal, "fixture.hidden", {}).then(() => void 0, (caught) => caught);
|
|
330
332
|
expect(memberOf(error, "code") === -32602, `expected the JSON-RPC error -32602, got ${JSON.stringify(error)}`);
|
|
331
333
|
});
|
|
@@ -485,7 +487,7 @@ async function checkEvents(checks, channel, options) {
|
|
|
485
487
|
expect(isObject(memberOf(extensions, MCP_EVENTS_EXTENSION)), `the capabilities must have the extension ${MCP_EVENTS_EXTENSION}, got ${JSON.stringify(result)}`);
|
|
486
488
|
});
|
|
487
489
|
let delivery = [];
|
|
488
|
-
await checks.run("events/list gives each event of the
|
|
490
|
+
await checks.run("events/list gives each event of the target, with the delivery modes of the server and its schemas", RULE_EVENTS, async (signal) => {
|
|
489
491
|
const result = await resultOf("events/list", {}, signal);
|
|
490
492
|
const entries = result.events;
|
|
491
493
|
if (!isArrayOf(entries, isObject)) throw new Error(`events/list must give a list of events, got ${JSON.stringify(result)}`);
|
|
@@ -509,7 +511,7 @@ async function checkEvents(checks, channel, options) {
|
|
|
509
511
|
});
|
|
510
512
|
for (const [name, params, code, kind] of [
|
|
511
513
|
[
|
|
512
|
-
"events/stream of an event outside the
|
|
514
|
+
"events/stream of an event outside the target is NotFound, with the kind event",
|
|
513
515
|
{
|
|
514
516
|
name: "fixture.secret",
|
|
515
517
|
arguments: {}
|
|
@@ -622,6 +624,7 @@ async function checkEvents(checks, channel, options) {
|
|
|
622
624
|
const name = `events/stream with heartbeatMs: ${suggested} grants heartbeatMs: ${granted} on notifications/events/active${granted === MCP_HEARTBEAT_MIN_MS ? ", then sends heartbeats at that interval" : ""}`;
|
|
623
625
|
await checks.run(name, `${RULE}#push`, async (signal) => {
|
|
624
626
|
const id = streamId();
|
|
627
|
+
const requested = performance.now();
|
|
625
628
|
const stream = await channel.stream(id, {
|
|
626
629
|
name: "fixture.watch",
|
|
627
630
|
arguments: { key: randomUUID() },
|
|
@@ -630,10 +633,9 @@ async function checkEvents(checks, channel, options) {
|
|
|
630
633
|
try {
|
|
631
634
|
await active(stream, id, granted);
|
|
632
635
|
if (granted !== MCP_HEARTBEAT_MIN_MS) return;
|
|
633
|
-
const started = Date.now();
|
|
634
636
|
expectEqual(paramsOf(await notification(stream, id, "notifications/events/heartbeat")), { cursor: null }, "the params of notifications/events/heartbeat");
|
|
635
|
-
const waited =
|
|
636
|
-
expect(waited >= granted
|
|
637
|
+
const waited = Math.round(performance.now() - requested);
|
|
638
|
+
expect(waited >= granted - TIMER_RESOLUTION_MS, `the heartbeat must come when the stream was idle for ${granted} ms, but it came ${waited} ms after the request`);
|
|
637
639
|
} finally {
|
|
638
640
|
await stream.cancel();
|
|
639
641
|
}
|
package/dist/conform/poll.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
const RULE = "spec/
|
|
6
|
+
const RULE = "spec/surfaces/mcp.md#poll";
|
|
7
7
|
const MAXIMUM_TICKS = 100;
|
|
8
8
|
const MAXIMUM_EVENTS = 100;
|
|
9
9
|
function pollRequests(channel) {
|
|
@@ -9,4 +9,4 @@ export declare function mcpInvoke(url: string, signal: AbortSignal): Promise<{
|
|
|
9
9
|
close(): Promise<void>;
|
|
10
10
|
}>;
|
|
11
11
|
export declare function clientInvoke(client: Client): Invoke;
|
|
12
|
-
export declare function checkProperties(
|
|
12
|
+
export declare function checkProperties(surface: string, invoke: Invoke, deadline: number, signal?: AbortSignal): Promise<Checks>;
|
|
@@ -124,28 +124,24 @@ const cancellations = fc.array(fc.boolean(), {
|
|
|
124
124
|
minLength: 2,
|
|
125
125
|
maxLength: 5
|
|
126
126
|
}).filter((flags) => flags.includes(true) && flags.includes(false));
|
|
127
|
-
async function checkProperties(
|
|
128
|
-
const checks = new Checks(`${
|
|
129
|
-
await checks.
|
|
127
|
+
async function checkProperties(surface, invoke, deadline, signal) {
|
|
128
|
+
const checks = new Checks(`${surface} properties`, deadline, signal);
|
|
129
|
+
await checks.runEach("concurrent calls each get exactly their own outcome", RULE, async (each) => {
|
|
130
130
|
await fc.assert(fc.asyncProperty(fc.array(operation, {
|
|
131
131
|
minLength: 1,
|
|
132
132
|
maxLength: 12
|
|
133
|
-
}), async (
|
|
134
|
-
fc.pre(!signal.aborted);
|
|
133
|
+
}), (operations) => each(async (signal) => {
|
|
135
134
|
(await Promise.all(operations.map(async (op) => ({
|
|
136
135
|
op,
|
|
137
136
|
outcome: await callFor(invoke, op, signal)
|
|
138
137
|
})))).forEach(({ op, outcome }) => expect(agrees(op, outcome), `${op.kind} gave ${JSON.stringify(outcome)}`));
|
|
139
|
-
}), {
|
|
138
|
+
})), {
|
|
140
139
|
numRuns: 25,
|
|
141
140
|
includeErrorInReport: true
|
|
142
141
|
});
|
|
143
142
|
});
|
|
144
|
-
await checks.
|
|
145
|
-
await fc.assert(fc.asyncProperty(cancellations, (flags) => {
|
|
146
|
-
fc.pre(!signal.aborted);
|
|
147
|
-
return cancelSome(invoke, flags, signal, deadline);
|
|
148
|
-
}), {
|
|
143
|
+
await checks.runEach("cancelling a call affects only that call", RULE, async (each) => {
|
|
144
|
+
await fc.assert(fc.asyncProperty(cancellations, (flags) => each((signal) => cancelSome(invoke, flags, signal, deadline))), {
|
|
149
145
|
numRuns: 5,
|
|
150
146
|
includeErrorInReport: true
|
|
151
147
|
});
|
package/dist/conform/serve.js
CHANGED
|
@@ -4,7 +4,10 @@ import { createServer } from "node:http";
|
|
|
4
4
|
function serve(handler) {
|
|
5
5
|
const routes = typeof handler === "function" ? { "/": handler } : handler;
|
|
6
6
|
const prefixes = Object.keys(routes).sort((a, b) => b.length - a.length);
|
|
7
|
-
const server = createServer((incoming, outgoing) => {
|
|
7
|
+
const server = createServer({ keepAliveTimeout: 0 }, (incoming, outgoing) => {
|
|
8
|
+
const closeIfIdle = () => server.listening || server.closeIdleConnections();
|
|
9
|
+
incoming.on("end", closeIfIdle);
|
|
10
|
+
outgoing.on("finish", closeIfIdle);
|
|
8
11
|
answer(incoming, outgoing, prefixes, routes);
|
|
9
12
|
});
|
|
10
13
|
return new Promise((resolve) => {
|
|
@@ -4,7 +4,7 @@ import { expect, expectEqual } from "./check.js";
|
|
|
4
4
|
import { MCP_EVENTS_EXTENSION, MCP_SERVER_CARD_CACHE_CONTROL, MCP_SERVER_CARD_MEDIA_TYPE, MCP_SERVER_CARD_PATH, isCidr } from "@acid-cat/spec-ts";
|
|
5
5
|
import { Result, Schema, SchemaIssue, SchemaRepresentation } from "effect";
|
|
6
6
|
// src/conform/server-card.ts
|
|
7
|
-
const RULE = "spec/
|
|
7
|
+
const RULE = "spec/surfaces/mcp.md#server-card";
|
|
8
8
|
const decodeCard = (() => {
|
|
9
9
|
const definitions = $defs;
|
|
10
10
|
const schema = SchemaRepresentation.fromJsonSchemaDocument({
|
package/dist/conform/webhook.js
CHANGED
|
@@ -5,7 +5,7 @@ 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
|
-
const RULE = "spec/
|
|
8
|
+
const RULE = "spec/surfaces/mcp.md#webhook";
|
|
9
9
|
const REFRESH_BEFORE_PRECISION_MS = 1;
|
|
10
10
|
const isVerification = (request) => memberOf(request.body, "type") === "verification";
|
|
11
11
|
async function startReceiver(settings) {
|
package/dist/conform/webmcp.d.ts
CHANGED
|
@@ -49,4 +49,5 @@ export declare function processDriver(install: WebMcpInstall): Promise<WebMcpDri
|
|
|
49
49
|
export declare function browserDriver(url: string): Promise<WebMcpDriver>;
|
|
50
50
|
export declare function checkWebMcp(driver: WebMcpDriver, options: {
|
|
51
51
|
readonly deadline: number;
|
|
52
|
+
readonly signal?: AbortSignal | undefined;
|
|
52
53
|
}): Promise<Checks>;
|
package/dist/conform/webmcp.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
|
-
const RULE = "spec/
|
|
5
|
+
const RULE = "spec/surfaces/webmcp.md";
|
|
6
6
|
const TARGET = "app";
|
|
7
7
|
/** The function uses no imports and no outer variables, because the browser driver sends its source text to the page. */
|
|
8
8
|
function createTestHost() {
|
|
@@ -155,18 +155,18 @@ async function heldKeys(driver, signal) {
|
|
|
155
155
|
return keys;
|
|
156
156
|
}
|
|
157
157
|
async function checkWebMcp(driver, options) {
|
|
158
|
-
const checks = new Checks("webmcp", options.deadline);
|
|
159
|
-
const
|
|
158
|
+
const checks = new Checks("webmcp", options.deadline, options.signal);
|
|
159
|
+
const capabilities = fixture.capabilities;
|
|
160
160
|
const expected = idsOf(TARGET);
|
|
161
|
-
await checks.run("each available capability of the
|
|
161
|
+
await checks.run("each available capability of the target is a tool", `${RULE}#tools`, async (signal) => {
|
|
162
162
|
await until(`the tools are ${expected.join(", ")}`, () => names(driver, signal), (tools) => JSON.stringify(tools) === JSON.stringify(expected), signal);
|
|
163
163
|
});
|
|
164
164
|
await checks.run("a tool has the description and the bundled input schema of its capability", `${RULE}#tools`, async (signal) => {
|
|
165
165
|
for (const tool of await driver.tools(signal)) {
|
|
166
|
-
expectEqual(tool.description,
|
|
166
|
+
expectEqual(tool.description, capabilities[tool.name]?.description, `description of ${tool.name}`);
|
|
167
167
|
const schema = tool.inputSchema;
|
|
168
168
|
expect(isObject(schema), `the input schema of ${tool.name} must be an object`);
|
|
169
|
-
expectSameInputShape(tool.name, schema,
|
|
169
|
+
expectSameInputShape(tool.name, schema, capabilities[tool.name]?.input ?? {});
|
|
170
170
|
expect(isBundled(schema), `the input schema of ${tool.name} must be bundled`);
|
|
171
171
|
}
|
|
172
172
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { bundle, check,
|
|
1
|
+
export { bundle, check, targetCatalog } from "./catalog.js";
|
|
2
2
|
export type { Catalog, Report } from "./catalog.js";
|
|
3
3
|
export { conform, fixture, serve } from "./conform/index.js";
|
|
4
4
|
export type { Check, ConformOptions, PollSettings, Routes, Served, WebHandler, WebhookSettings } from "./conform/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bundle, check,
|
|
1
|
+
import { bundle, check, targetCatalog } from "./catalog.js";
|
|
2
2
|
import { fixture } from "./conform/check.js";
|
|
3
3
|
import { serve } from "./conform/serve.js";
|
|
4
4
|
import { conform } from "./conform/index.js";
|
|
5
|
-
export { bundle, check, conform, fixture, serve,
|
|
5
|
+
export { bundle, check, conform, fixture, serve, targetCatalog };
|
|
@@ -52,7 +52,7 @@ var catalog_schema_default = {
|
|
|
52
52
|
"type": "string",
|
|
53
53
|
"pattern": "^[a-z][a-z0-9-]*(:[a-z][a-z0-9-]*)?$"
|
|
54
54
|
},
|
|
55
|
-
"
|
|
55
|
+
"surfaceName": {
|
|
56
56
|
"type": "string",
|
|
57
57
|
"pattern": "^[a-z][a-z0-9-]*(:[a-z][a-z0-9-]*)?$"
|
|
58
58
|
},
|
|
@@ -62,11 +62,11 @@ var catalog_schema_default = {
|
|
|
62
62
|
},
|
|
63
63
|
"target": {
|
|
64
64
|
"type": "object",
|
|
65
|
-
"required": ["
|
|
65
|
+
"required": ["surfaces"],
|
|
66
66
|
"properties": {
|
|
67
|
-
"
|
|
67
|
+
"surfaces": {
|
|
68
68
|
"type": "array",
|
|
69
|
-
"items": { "$ref": "#/$defs/
|
|
69
|
+
"items": { "$ref": "#/$defs/surfaceName" },
|
|
70
70
|
"minItems": 1,
|
|
71
71
|
"uniqueItems": true
|
|
72
72
|
},
|
|
@@ -78,7 +78,7 @@ var catalog_schema_default = {
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"cliOptions": {
|
|
81
|
-
"description": "The settings of the CLI
|
|
81
|
+
"description": "The settings of the CLI surface. See spec/surfaces/cli.md#aliases.",
|
|
82
82
|
"type": "object",
|
|
83
83
|
"properties": {
|
|
84
84
|
"aliases": {
|
|
@@ -4,10 +4,10 @@ var fixture_acidcat_default = {
|
|
|
4
4
|
title: "AcidCat conformance fixture",
|
|
5
5
|
description: "One capability or event for each behavior that acid-cat conform tests.",
|
|
6
6
|
targets: {
|
|
7
|
-
"api": { "
|
|
8
|
-
"app": { "
|
|
7
|
+
"api": { "surfaces": ["http"] },
|
|
8
|
+
"app": { "surfaces": ["typescript", "webmcp"] },
|
|
9
9
|
"cli": {
|
|
10
|
-
"
|
|
10
|
+
"surfaces": ["cli"],
|
|
11
11
|
"options": { "cli": {
|
|
12
12
|
"aliases": {
|
|
13
13
|
"--hello": {
|
|
@@ -49,7 +49,7 @@ var fixture_acidcat_default = {
|
|
|
49
49
|
"default": "quick"
|
|
50
50
|
} }
|
|
51
51
|
},
|
|
52
|
-
"mcp": { "
|
|
52
|
+
"mcp": { "surfaces": ["mcp"] }
|
|
53
53
|
},
|
|
54
54
|
$defs: { "Note": {
|
|
55
55
|
"properties": {
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { version } from "./json/package.json.js";
|
|
3
|
-
import { check, isCatalog,
|
|
3
|
+
import { check, isCatalog, targetCatalog } from "./catalog.js";
|
|
4
4
|
import { DEADLINE } from "./conform/check.js";
|
|
5
5
|
import { conform } from "./conform/index.js";
|
|
6
6
|
import { parseJson } from "./json.js";
|
|
@@ -82,7 +82,7 @@ const formatCommand = Command.make("format", {
|
|
|
82
82
|
else yield* Effect.sync(() => process.stdout.write(text));
|
|
83
83
|
}
|
|
84
84
|
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Write catalogs in canonical form."));
|
|
85
|
-
const
|
|
85
|
+
const targetCommand = Command.make("target", {
|
|
86
86
|
file: Argument.String("catalog").pipe(Argument.withDescription("A catalog file")),
|
|
87
87
|
target: Argument.String("target").pipe(Argument.withDescription("The name of a target in the catalog"))
|
|
88
88
|
}, Effect.fn(function* ({ file, target }) {
|
|
@@ -95,8 +95,8 @@ const viewCommand = Command.make("view", {
|
|
|
95
95
|
yield* Console.error(`${file}: error: there is no target ${target}`);
|
|
96
96
|
return yield* fail;
|
|
97
97
|
}
|
|
98
|
-
yield* Effect.sync(() => process.stdout.write(canonicalText(
|
|
99
|
-
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Print the
|
|
98
|
+
yield* Effect.sync(() => process.stdout.write(canonicalText(targetCatalog(catalog, target))));
|
|
99
|
+
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Print the catalog of one target."));
|
|
100
100
|
const url = (name, description) => Flag.String(name).pipe(Flag.withDescription(description), Flag.optional);
|
|
101
101
|
const conformCommand = Command.make("conform", {
|
|
102
102
|
mcp: url("mcp", "The URL of the MCP server"),
|
|
@@ -115,7 +115,7 @@ const conformCommand = Command.make("conform", {
|
|
|
115
115
|
webhookMaxTtlMs: Flag.Int("webhook-max-ttl-ms").pipe(Flag.withDescription("The maximum lifetime of a webhook subscription in the deployment. The default is 3600000"), Flag.optional),
|
|
116
116
|
webhookMinTtlMs: Flag.Int("webhook-min-ttl-ms").pipe(Flag.withDescription("The minimum lifetime of a webhook subscription in the deployment, shorter than the deadline. With it, conform tests that a subscription with no renewal ends"), Flag.optional),
|
|
117
117
|
webhookMaxSubscriptions: Flag.Int("webhook-max-subscriptions").pipe(Flag.withDescription("The maximum number of webhook subscriptions of one principal in the deployment. With it, conform tests the limit"), Flag.optional),
|
|
118
|
-
maximumBytes: Flag.Int("max-bytes").pipe(Flag.withDescription("The body limit of the remote
|
|
118
|
+
maximumBytes: Flag.Int("max-bytes").pipe(Flag.withDescription("The body limit of the remote surfaces"), Flag.withDefault(1048576)),
|
|
119
119
|
deadline: Flag.Int("deadline").pipe(Flag.withDescription("The time, in milliseconds, that each check has to settle. A check that does not settle in this time fails"), Flag.withDefault(DEADLINE)),
|
|
120
120
|
output
|
|
121
121
|
}, Effect.fn(function* (options) {
|
|
@@ -171,7 +171,7 @@ const conformCommand = Command.make("conform", {
|
|
|
171
171
|
deadline: options.deadline
|
|
172
172
|
}));
|
|
173
173
|
if (results.length === 0) {
|
|
174
|
-
yield* Console.error("Give at least one
|
|
174
|
+
yield* Console.error("Give at least one surface: --mcp, --mcp-stdio, --http, --cli or --webmcp.");
|
|
175
175
|
return yield* fail;
|
|
176
176
|
}
|
|
177
177
|
const failed = results.filter((result) => !result.passed).length;
|
|
@@ -186,14 +186,14 @@ const conformCommand = Command.make("conform", {
|
|
|
186
186
|
if (failed > 0) return yield* fail;
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
|
-
for (const result of results) yield* Console.log(`${result.warning === true ? "!" : result.passed ? "✓" : "✗"} ${result.
|
|
189
|
+
for (const result of results) yield* Console.log(`${result.warning === true ? "!" : result.passed ? "✓" : "✗"} ${result.surface}: ${result.name} (${result.rule})${result.detail ? `\n ${result.detail}` : ""}`);
|
|
190
190
|
yield* Console.log(`\n${results.length - failed} passed, ${failed} failed${warnings === 0 ? "" : `, ${warnings} with a warning`}.`);
|
|
191
191
|
if (failed > 0) return yield* fail;
|
|
192
|
-
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Test a running implementation of the conformance fixture through its
|
|
193
|
-
const acidCat = Command.make("acid-cat").pipe(Command.withDescription("Check
|
|
192
|
+
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Test a running implementation of the conformance fixture through its surfaces."));
|
|
193
|
+
const acidCat = Command.make("acid-cat").pipe(Command.withDescription("Check and format AcidCat catalogs, print the catalog of a target, and test implementations."), Command.withSubcommands([
|
|
194
194
|
checkCommand,
|
|
195
195
|
formatCommand,
|
|
196
|
-
|
|
196
|
+
targetCommand,
|
|
197
197
|
conformCommand
|
|
198
198
|
]));
|
|
199
199
|
const args = process.argv.slice(2);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acid-cat/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The AcidCat command line: check
|
|
3
|
+
"version": "0.19.0",
|
|
4
|
+
"description": "The AcidCat command line: check and format catalogs, print the catalog of a target, and test implementations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acidcat",
|
|
7
7
|
"cli",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@acid-cat/catalog": "0.
|
|
43
|
-
"@acid-cat/spec-ts": "0.
|
|
42
|
+
"@acid-cat/catalog": "0.19.0",
|
|
43
|
+
"@acid-cat/spec-ts": "0.19.0",
|
|
44
44
|
"@effect/platform-node": "^4.1.3",
|
|
45
45
|
"@effect/platform-node-shared": "^4.1.3",
|
|
46
46
|
"@modelcontextprotocol/client": "2.4.0",
|