@acid-cat/cli 0.14.0 → 0.15.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 +64 -32
- package/dist/conform/check.d.ts +6 -2
- package/dist/conform/check.js +22 -3
- package/dist/conform/cli.js +283 -253
- package/dist/conform/http.js +10 -21
- package/dist/conform/index.d.ts +9 -1
- package/dist/conform/index.js +8 -2
- package/dist/conform/mcp-stdio.js +1 -19
- package/dist/conform/mcp.js +10 -21
- package/dist/conform/poll.d.ts +3 -3
- package/dist/conform/poll.js +51 -26
- package/dist/conform/properties.d.ts +0 -1
- package/dist/conform/properties.js +1 -1
- package/dist/conform/webhook.d.ts +4 -1
- package/dist/conform/webhook.js +20 -8
- package/dist/conform/webmcp.js +0 -5
- package/dist/json/package.json.js +1 -1
- package/dist/main.js +11 -5
- package/package.json +3 -3
package/dist/conform/http.js
CHANGED
|
@@ -264,27 +264,7 @@ async function checkEvents(checks, base) {
|
|
|
264
264
|
stream.close();
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
|
-
await checks.run("
|
|
268
|
-
const key = randomUUID();
|
|
269
|
-
const pending = open(signal, "fixture.watch", { key });
|
|
270
|
-
pending.catch(() => void 0);
|
|
271
|
-
let stream;
|
|
272
|
-
try {
|
|
273
|
-
await until("fixture.watching gives the key", () => watching(signal), (keys) => keys.includes(key), signal);
|
|
274
|
-
stream = await pending;
|
|
275
|
-
expectEqual(await signalKey(signal, key, "first"), 1, "the subscriptions that fixture.signal reached");
|
|
276
|
-
expectEqual((await nextOccurrence(stream, "fixture.watch")).data, {
|
|
277
|
-
key,
|
|
278
|
-
value: "first"
|
|
279
|
-
}, "data");
|
|
280
|
-
stream.close();
|
|
281
|
-
await until("the key leaves fixture.watching", () => watching(signal), (keys) => !keys.includes(key), signal);
|
|
282
|
-
} finally {
|
|
283
|
-
stream?.close();
|
|
284
|
-
pending.then((opened) => opened.close(), () => void 0);
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
await checks.run("cancelling one subscription leaves the other subscriptions running", EVENTS, async (signal) => {
|
|
267
|
+
await checks.run("each subscription gets the things that happen, and closing one stream cancels only its subscription", EVENTS, async (signal) => {
|
|
288
268
|
const key = randomUUID();
|
|
289
269
|
const first = open(signal, "fixture.watch", { key });
|
|
290
270
|
const second = open(signal, "fixture.watch", { key });
|
|
@@ -293,6 +273,15 @@ async function checkEvents(checks, base) {
|
|
|
293
273
|
try {
|
|
294
274
|
await until("fixture.watching gives the key of both subscriptions", () => watching(signal), (keys) => count(keys, key) === 2, signal);
|
|
295
275
|
const [cancelled, kept] = [await first, await second];
|
|
276
|
+
expectEqual(await signalKey(signal, key, "both"), 2, "the subscriptions that fixture.signal reached");
|
|
277
|
+
expectEqual((await nextOccurrence(cancelled, "fixture.watch")).data, {
|
|
278
|
+
key,
|
|
279
|
+
value: "both"
|
|
280
|
+
}, "data of the first subscription");
|
|
281
|
+
expectEqual((await nextOccurrence(kept, "fixture.watch")).data, {
|
|
282
|
+
key,
|
|
283
|
+
value: "both"
|
|
284
|
+
}, "data of the second subscription");
|
|
296
285
|
cancelled.close();
|
|
297
286
|
await until("the cancelled subscription leaves fixture.watching", () => watching(signal), (keys) => count(keys, key) === 1, signal);
|
|
298
287
|
expectEqual(await signalKey(signal, key, "after"), 1, "the subscriptions that fixture.signal reached");
|
package/dist/conform/index.d.ts
CHANGED
|
@@ -34,9 +34,17 @@ export interface ConformOptions {
|
|
|
34
34
|
readonly webmcp?: string | WebMcpInstall | undefined;
|
|
35
35
|
/**
|
|
36
36
|
* The poll settings of the deployment, for MCP through HTTP and through stdio. With `bufferLimit`, conform tests a
|
|
37
|
-
* cursor older than the buffer.
|
|
37
|
+
* cursor older than the buffer. The lease time of the deployment must be longer than the deadline.
|
|
38
38
|
*/
|
|
39
39
|
readonly poll?: PollSettings | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* An MCP server through HTTP whose lease time is `leaseMs`, shorter than the deadline. conform tests there that a lease
|
|
42
|
+
* with no poll ends.
|
|
43
|
+
*/
|
|
44
|
+
readonly pollLease?: {
|
|
45
|
+
readonly mcp: string;
|
|
46
|
+
readonly leaseMs: number;
|
|
47
|
+
} | undefined;
|
|
40
48
|
/**
|
|
41
49
|
* Test webhook delivery through `mcp`. conform runs an HTTPS receiver on 127.0.0.1 with this certificate and key. The
|
|
42
50
|
* deployment trusts the certificate, allows deliveries to 127.0.0.1, and gives the principal to each request with the
|
package/dist/conform/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { DEADLINE, fixture } from "./check.js";
|
|
1
|
+
import { Checks, DEADLINE, fixture } from "./check.js";
|
|
2
2
|
import { checkCli } from "./cli.js";
|
|
3
3
|
import { checkHttp } from "./http.js";
|
|
4
|
-
import { checkMcp } from "./mcp.js";
|
|
4
|
+
import { checkMcp, httpChannel } from "./mcp.js";
|
|
5
5
|
import { checkMcpStdio } from "./mcp-stdio.js";
|
|
6
6
|
import { checkProperties, httpInvoke, mcpInvoke } from "./properties.js";
|
|
7
7
|
import { browserDriver, checkWebMcp, processDriver } from "./webmcp.js";
|
|
8
|
+
import { checkPollLease } from "./poll.js";
|
|
8
9
|
import { serve } from "./serve.js";
|
|
9
10
|
// src/conform/index.ts
|
|
10
11
|
/** Run all checks for the bindings that the options give. */
|
|
@@ -27,6 +28,11 @@ async function conform(options) {
|
|
|
27
28
|
await mcp.close();
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
if (options.pollLease !== void 0) {
|
|
32
|
+
const checks = new Checks("mcp", deadline);
|
|
33
|
+
await checkPollLease(checks, httpChannel(options.pollLease.mcp), options.pollLease.leaseMs);
|
|
34
|
+
results.push(...checks.results);
|
|
35
|
+
}
|
|
30
36
|
if (options.mcpStdio !== void 0) for (const checks of await checkMcpStdio(options.mcpStdio, {
|
|
31
37
|
deadline,
|
|
32
38
|
poll
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isObject, memberOf } from "../json.js";
|
|
2
2
|
import { Checks, abortable, expect, expectEqual, until } from "./check.js";
|
|
3
3
|
import { META, checkEvents, checkTools, subscriptionOf } from "./mcp.js";
|
|
4
|
-
import { checkProperties, clientInvoke
|
|
4
|
+
import { checkProperties, clientInvoke } from "./properties.js";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { Client } from "@modelcontextprotocol/client";
|
|
@@ -59,7 +59,6 @@ async function checkMcpStdio(command, options) {
|
|
|
59
59
|
try {
|
|
60
60
|
await checkTools(checks, mcp);
|
|
61
61
|
await checkChanges(checks, mcp, changes);
|
|
62
|
-
await checkCancellation(checks, mcp);
|
|
63
62
|
all.push(await checkProperties(`mcp-stdio ${era.revision} properties`, clientInvoke(mcp), options.deadline));
|
|
64
63
|
} finally {
|
|
65
64
|
await mcp.close();
|
|
@@ -150,23 +149,6 @@ async function checkChanges(checks, mcp, changes) {
|
|
|
150
149
|
}
|
|
151
150
|
});
|
|
152
151
|
}
|
|
153
|
-
/** The official client sends `notifications/cancelled` when the signal of a call aborts. */
|
|
154
|
-
async function checkCancellation(checks, mcp) {
|
|
155
|
-
const invoke = clientInvoke(mcp);
|
|
156
|
-
await checks.run("notifications/cancelled cancels the call", RULE, async (signal) => {
|
|
157
|
-
const key = randomUUID();
|
|
158
|
-
const controller = new AbortController();
|
|
159
|
-
const call = invoke("fixture.hold", { key }, AbortSignal.any([controller.signal, signal])).catch(() => void 0);
|
|
160
|
-
try {
|
|
161
|
-
await until("fixture.held gives the key of the call", () => heldKeys(invoke, signal), (held) => held.includes(key), signal);
|
|
162
|
-
controller.abort();
|
|
163
|
-
await call;
|
|
164
|
-
await until("the cancelled call stops holding", () => heldKeys(invoke, signal), (held) => !held.includes(key), signal);
|
|
165
|
-
} finally {
|
|
166
|
-
await invoke("fixture.release", { key }, AbortSignal.timeout(checks.deadline)).catch(() => void 0);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
152
|
function startRaw(command, signal) {
|
|
171
153
|
const [program, ...args] = command;
|
|
172
154
|
if (program === void 0) throw new Error("the command that starts the MCP server is empty");
|
package/dist/conform/mcp.js
CHANGED
|
@@ -391,6 +391,16 @@ async function checkEvents(checks, channel, options) {
|
|
|
391
391
|
},
|
|
392
392
|
-32602,
|
|
393
393
|
void 0
|
|
394
|
+
],
|
|
395
|
+
[
|
|
396
|
+
"events/stream with a maxAgeMs that is not valid is the error -32602",
|
|
397
|
+
{
|
|
398
|
+
name: "fixture.ticks",
|
|
399
|
+
arguments: { count: 1 },
|
|
400
|
+
maxAgeMs: -1
|
|
401
|
+
},
|
|
402
|
+
-32602,
|
|
403
|
+
void 0
|
|
394
404
|
]
|
|
395
405
|
]) await checks.run(name, RULE_EVENTS, async (signal) => {
|
|
396
406
|
const stream = await channel.stream(streamId(), params, signal);
|
|
@@ -481,27 +491,6 @@ async function checkEvents(checks, channel, options) {
|
|
|
481
491
|
await stream.cancel();
|
|
482
492
|
}
|
|
483
493
|
});
|
|
484
|
-
await checks.run("events/stream gets the things that happen, and cancelling it ends the subscription", RULE_EVENTS, async (signal) => {
|
|
485
|
-
const key = randomUUID();
|
|
486
|
-
const id = streamId();
|
|
487
|
-
const stream = await channel.stream(id, {
|
|
488
|
-
name: "fixture.watch",
|
|
489
|
-
arguments: { key }
|
|
490
|
-
}, signal);
|
|
491
|
-
try {
|
|
492
|
-
await active(stream, id);
|
|
493
|
-
await until("fixture.watching gives the key", () => watching(signal), (keys) => keys.includes(key), signal);
|
|
494
|
-
expectEqual(await signalKey(key, "first", signal), 1, "the subscriptions that fixture.signal reached");
|
|
495
|
-
expectEqual((await occurrence(stream, id, "fixture.watch")).data, {
|
|
496
|
-
key,
|
|
497
|
-
value: "first"
|
|
498
|
-
}, "data");
|
|
499
|
-
await stream.cancel();
|
|
500
|
-
await until("the key leaves fixture.watching", () => watching(signal), (keys) => !keys.includes(key), signal);
|
|
501
|
-
} finally {
|
|
502
|
-
await stream.cancel();
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
494
|
await checks.run("two subscriptions at the same time each get their own messages, and cancelling one leaves the other", RULE_EVENTS, async (signal) => {
|
|
506
495
|
const key = randomUUID();
|
|
507
496
|
const [firstId, secondId] = [streamId(), streamId()];
|
package/dist/conform/poll.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { Checks } from "./check.js";
|
|
|
2
2
|
import type { Channel } from "./mcp.js";
|
|
3
3
|
/**
|
|
4
4
|
* The poll settings of the deployment that conform tests. Each one is optional. With a setting, conform also tests the
|
|
5
|
-
* rule that depends on it.
|
|
5
|
+
* rule that depends on it. The lease time of the deployment must be longer than the deadline: a lease must last for a
|
|
6
|
+
* whole check.
|
|
6
7
|
*/
|
|
7
8
|
export interface PollSettings {
|
|
8
9
|
/** The number of occurrences that a lease keeps. With it, conform tests the occurrences of a cursor older than the buffer. It must be 97 or less. */
|
|
9
10
|
readonly bufferLimit?: number | undefined;
|
|
10
|
-
/** The lease time, in milliseconds. With it, conform tests that a lease with no poll ends. It must be shorter than the deadline. */
|
|
11
|
-
readonly leaseMs?: number | undefined;
|
|
12
11
|
}
|
|
13
12
|
export declare function checkPoll(checks: Checks, channel: Channel, settings: PollSettings): Promise<void>;
|
|
13
|
+
export declare function checkPollLease(checks: Checks, channel: Channel, leaseMs: number): Promise<void>;
|
package/dist/conform/poll.js
CHANGED
|
@@ -6,7 +6,7 @@ import { randomUUID } from "node:crypto";
|
|
|
6
6
|
const RULE = "spec/bindings/mcp.md#poll";
|
|
7
7
|
const MAXIMUM_TICKS = 100;
|
|
8
8
|
const MAXIMUM_EVENTS = 100;
|
|
9
|
-
|
|
9
|
+
function pollRequests(channel) {
|
|
10
10
|
const { errorOf, watching, signalKey } = eventRequests(channel);
|
|
11
11
|
const polledOf = (message, name) => {
|
|
12
12
|
const result = memberOf(message, "result");
|
|
@@ -59,21 +59,32 @@ async function checkPoll(checks, channel, settings) {
|
|
|
59
59
|
const signalAll = async (key, values, signal) => {
|
|
60
60
|
for (const value of values) expectEqual(await signalKey(key, value, signal), 1, "the subscriptions that fixture.signal reached");
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
return {
|
|
63
|
+
errorOf,
|
|
64
|
+
watching,
|
|
65
|
+
polledOf,
|
|
66
|
+
poll,
|
|
67
|
+
pollUntil,
|
|
68
|
+
pollError,
|
|
69
|
+
dataOf,
|
|
70
|
+
watched,
|
|
71
|
+
ticks,
|
|
72
|
+
hasKey,
|
|
73
|
+
lacksKey,
|
|
74
|
+
expectStart,
|
|
75
|
+
startWatch,
|
|
76
|
+
signalAll
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async function checkPoll(checks, channel, settings) {
|
|
80
|
+
const { errorOf, watching, polledOf, poll, pollUntil, pollError, dataOf, watched, ticks, hasKey, expectStart, startWatch, signalAll } = pollRequests(channel);
|
|
81
|
+
await checks.run("events/poll with no cursor and no lease starts a lease with no occurrences, whose subscription starts now; a cursor of the lease gives the occurrences after it, in order; and no cursor gives the newest position", RULE, async (signal) => {
|
|
71
82
|
const key = randomUUID();
|
|
72
83
|
const start = await startWatch(key, signal);
|
|
73
84
|
await signalAll(key, ["a", "b"], signal);
|
|
74
85
|
const both = await pollUntil("the lease has both occurrences", "fixture.watch", { key }, { cursor: start }, (each) => each.events.length >= 2, signal);
|
|
75
86
|
expectEqual(dataOf(both), watched(key, "a", "b"), "the data of the occurrences after the start");
|
|
76
|
-
expectEqual(both.truncated, false, "truncated");
|
|
87
|
+
expectEqual([both.truncated, both.hasMore], [false, false], "truncated and hasMore");
|
|
77
88
|
const newest = await poll("fixture.watch", { key }, {}, signal);
|
|
78
89
|
expectEqual([newest.events, newest.truncated], [[], false], "the occurrences and truncated of a poll with no cursor");
|
|
79
90
|
await signalAll(key, ["c"], signal);
|
|
@@ -252,19 +263,33 @@ async function checkPoll(checks, channel, settings) {
|
|
|
252
263
|
await failure(await start());
|
|
253
264
|
await failure(await start());
|
|
254
265
|
});
|
|
255
|
-
if (settings.leaseMs !== void 0) {
|
|
256
|
-
const leaseMs = settings.leaseMs;
|
|
257
|
-
await checks.run("a lease that gets no poll for the lease time ends, and cancels its subscription", RULE, async (signal) => {
|
|
258
|
-
const key = randomUUID();
|
|
259
|
-
const before = Date.now();
|
|
260
|
-
const cursor = await startWatch(key, signal);
|
|
261
|
-
await until("the lease ends, and the key leaves fixture.watching", () => watching(signal), lacksKey(key), signal);
|
|
262
|
-
const elapsed = Date.now() - before;
|
|
263
|
-
expect(elapsed >= leaseMs, `the lease ended ${elapsed} ms after the last poll, before the lease time of ${leaseMs} ms`);
|
|
264
|
-
const again = await poll("fixture.watch", { key }, { cursor }, signal);
|
|
265
|
-
expectStart(again, true);
|
|
266
|
-
await until("fixture.watching gives the key of the new lease", () => watching(signal), hasKey(key), signal);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
266
|
}
|
|
270
|
-
|
|
267
|
+
async function checkPollLease(checks, channel, leaseMs) {
|
|
268
|
+
const { watching, poll, lacksKey, hasKey, expectStart } = pollRequests(channel);
|
|
269
|
+
const keepUntilWatched = async (key, cursor, signal) => {
|
|
270
|
+
const lease = {
|
|
271
|
+
cursor,
|
|
272
|
+
renewedAt: Date.now()
|
|
273
|
+
};
|
|
274
|
+
await until("fixture.watching gives the key of the lease, while each poll renews the lease", async () => {
|
|
275
|
+
lease.renewedAt = Date.now();
|
|
276
|
+
lease.cursor = (await poll("fixture.watch", { key }, { cursor: lease.cursor }, signal)).cursor;
|
|
277
|
+
return watching(signal);
|
|
278
|
+
}, hasKey(key), signal);
|
|
279
|
+
return lease;
|
|
280
|
+
};
|
|
281
|
+
await checks.run("a lease that gets no poll for the lease time ends, and cancels its subscription", RULE, async (signal) => {
|
|
282
|
+
expect(Number.isSafeInteger(leaseMs) && leaseMs >= 1 && leaseMs < checks.deadline, `conform tests the end of a lease only when the lease time is shorter than the deadline of ${checks.deadline} ms, got ${leaseMs}`);
|
|
283
|
+
const key = randomUUID();
|
|
284
|
+
const started = await poll("fixture.watch", { key }, {}, signal);
|
|
285
|
+
expectStart(started, false);
|
|
286
|
+
const lease = await keepUntilWatched(key, started.cursor, signal);
|
|
287
|
+
await until("the lease ends, and the key leaves fixture.watching", () => watching(signal), lacksKey(key), signal);
|
|
288
|
+
const elapsed = Date.now() - lease.renewedAt;
|
|
289
|
+
expect(elapsed >= leaseMs, `the lease ended ${elapsed} ms after the last poll, before the lease time of ${leaseMs} ms`);
|
|
290
|
+
const again = await poll("fixture.watch", { key }, { cursor: lease.cursor }, signal);
|
|
291
|
+
expectStart(again, true);
|
|
292
|
+
await keepUntilWatched(key, again.cursor, signal);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
export { checkPoll, checkPollLease };
|
|
@@ -9,5 +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 heldKeys(invoke: Invoke, signal: AbortSignal): Promise<readonly string[]>;
|
|
13
12
|
export declare function checkProperties(binding: string, invoke: Invoke, deadline: number): Promise<Checks>;
|
|
@@ -12,7 +12,10 @@ export interface WebhookSettings {
|
|
|
12
12
|
* principal can still subscribe.
|
|
13
13
|
*/
|
|
14
14
|
readonly otherPrincipal?: string | undefined;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The maximum lifetime of a subscription in the deployment, in milliseconds. The default is the default of the
|
|
17
|
+
* specification, 3 600 000. It must be longer than the deadline: a subscription must last for a whole check.
|
|
18
|
+
*/
|
|
16
19
|
readonly maxTtlMs?: number | undefined;
|
|
17
20
|
/**
|
|
18
21
|
* The minimum lifetime of a subscription in the deployment, in milliseconds. The default is the default of the
|
package/dist/conform/webhook.js
CHANGED
|
@@ -133,12 +133,13 @@ async function checkWithReceiver(checks, url, settings, receiver) {
|
|
|
133
133
|
principal
|
|
134
134
|
};
|
|
135
135
|
const subscribe = async (name, input, hook, secret, signal, extra = {}, client = main) => {
|
|
136
|
+
const sent = Date.now();
|
|
136
137
|
const result = resultOf(await client.channel.request("events/subscribe", subscribeParams(name, input, hook, secret, extra), signal), "events/subscribe");
|
|
137
138
|
expectEqual(result.resultType, "complete", "resultType");
|
|
138
139
|
expectEqual(result.id, await webhookSubscriptionId(client.principal, hook, name, input), "the subscription id");
|
|
139
140
|
const refreshBefore = result.refreshBefore;
|
|
140
141
|
expect(typeof refreshBefore === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(refreshBefore), `refreshBefore must be an RFC 3339 date and time, got ${JSON.stringify(refreshBefore)}`);
|
|
141
|
-
expect(Date.parse(refreshBefore) >
|
|
142
|
+
expect(Date.parse(refreshBefore) > sent, `refreshBefore must be after the request, got ${refreshBefore}`);
|
|
142
143
|
expect(result.cursor === null || typeof result.cursor === "string", `cursor must be the watermark or null, got ${JSON.stringify(result.cursor)}`);
|
|
143
144
|
expectEqual(result.truncated, false, "truncated");
|
|
144
145
|
const status = result.deliveryStatus;
|
|
@@ -158,6 +159,12 @@ async function checkWithReceiver(checks, url, settings, receiver) {
|
|
|
158
159
|
const watchedKey = (key) => (keys) => keys.includes(key);
|
|
159
160
|
const minTtlMs = settings.minTtlMs ?? MCP_WEBHOOK_DEFAULTS.minTtlMs;
|
|
160
161
|
const maxTtlMs = settings.maxTtlMs ?? MCP_WEBHOOK_DEFAULTS.maxTtlMs;
|
|
162
|
+
if (maxTtlMs <= checks.deadline) {
|
|
163
|
+
await checks.run("the maximum lifetime of a subscription is longer than the deadline", RULE, () => {
|
|
164
|
+
throw new Error(`conform tests webhook delivery only when the maximum lifetime is longer than the deadline of ${checks.deadline} ms, got ${maxTtlMs}`);
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
161
168
|
await checks.run("events/subscribe and events/unsubscribe with no principal are Forbidden", RULE, async (signal) => {
|
|
162
169
|
const hook = receiver.url();
|
|
163
170
|
const input = { key: randomUUID() };
|
|
@@ -241,7 +248,7 @@ async function checkWithReceiver(checks, url, settings, receiver) {
|
|
|
241
248
|
const input = { key: randomUUID() };
|
|
242
249
|
const [first, second] = [newSecret(), newSecret()];
|
|
243
250
|
try {
|
|
244
|
-
const started = await subscribe("fixture.watch", input, hook.url, first, signal, { ttlMs:
|
|
251
|
+
const started = await subscribe("fixture.watch", input, hook.url, first, signal, { ttlMs: checks.deadline });
|
|
245
252
|
await until("fixture.watching gives the key", () => watching(signal), watchedKey(input.key), signal);
|
|
246
253
|
expectEqual(await signalKey(input.key, "a", signal), 1, "the subscriptions that fixture.signal reached");
|
|
247
254
|
const [a] = await atLeast(hook, 1, signal);
|
|
@@ -255,7 +262,7 @@ async function checkWithReceiver(checks, url, settings, receiver) {
|
|
|
255
262
|
expect(!("cursor" in occurrence), `with no cursor of the provider, the delivery has no cursor, got ${a.text}`);
|
|
256
263
|
const renewed = await subscribe("fixture.watch", input, hook.url, second, signal);
|
|
257
264
|
expectEqual(renewed.id, started.id, "the subscription id of the renewal");
|
|
258
|
-
expect(renewed.refreshBefore
|
|
265
|
+
expect(renewed.refreshBefore > started.refreshBefore, "a renewal with no ttlMs, which grants the maximum lifetime, must end after the first grant of a lifetime of the deadline");
|
|
259
266
|
expectEqual(count(await watching(signal), input.key), 1, "the subscriptions of the key after the renewal");
|
|
260
267
|
expectEqual(await signalKey(input.key, "b", signal), 1, "the subscriptions that fixture.signal reached after the renewal");
|
|
261
268
|
const [, b] = await atLeast(hook, 2, signal);
|
|
@@ -393,12 +400,17 @@ async function checkWithReceiver(checks, url, settings, receiver) {
|
|
|
393
400
|
const hook = receiver.url();
|
|
394
401
|
const input = { key: randomUUID() };
|
|
395
402
|
try {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
403
|
+
expect(minTtlMs < checks.deadline, `conform tests the end of a lifetime only when the minimum lifetime is shorter than the deadline of ${checks.deadline} ms, got ${minTtlMs}`);
|
|
404
|
+
const secret = newSecret();
|
|
405
|
+
let renewedAt = Date.now();
|
|
406
|
+
await until("fixture.watching gives the key, while each events/subscribe renews the subscription", async () => {
|
|
407
|
+
renewedAt = Date.now();
|
|
408
|
+
await subscribe("fixture.watch", input, hook.url, secret, signal, { ttlMs: minTtlMs });
|
|
409
|
+
return watching(signal);
|
|
410
|
+
}, watchedKey(input.key), signal);
|
|
399
411
|
await until("the lifetime ends, and the key leaves fixture.watching", () => watching(signal), (keys) => !keys.includes(input.key), signal);
|
|
400
|
-
const elapsed = Date.now() -
|
|
401
|
-
expect(elapsed >= minTtlMs, `the subscription ended ${elapsed} ms after the
|
|
412
|
+
const elapsed = Date.now() - renewedAt;
|
|
413
|
+
expect(elapsed >= minTtlMs, `the subscription ended ${elapsed} ms after the last events/subscribe, before its lifetime of ${minTtlMs} ms`);
|
|
402
414
|
expectEqual(await signalKey(input.key, "late", signal), 0, "the subscriptions that fixture.signal reached after the end");
|
|
403
415
|
expectEqual(deliveries(hook).length, 0, "the deliveries that the receiver got");
|
|
404
416
|
const ended = errorOf(await unsubscribe("fixture.watch", input, hook.url, signal));
|
package/dist/conform/webmcp.js
CHANGED
|
@@ -161,11 +161,6 @@ async function checkWebMcp(driver, options) {
|
|
|
161
161
|
await checks.run("each available capability of the view 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
|
-
await checks.run("an event is not a tool", `${RULE}#events`, async (signal) => {
|
|
165
|
-
const tools = await names(driver, signal);
|
|
166
|
-
const events = Object.keys(fixture.events ?? {}).filter((id) => tools.includes(id));
|
|
167
|
-
expectEqual(events, [], "the tools that have the id of an event");
|
|
168
|
-
});
|
|
169
164
|
await checks.run("a tool has the description and the bundled input schema of its capability", `${RULE}#tools`, async (signal) => {
|
|
170
165
|
for (const tool of await driver.tools(signal)) {
|
|
171
166
|
expectEqual(tool.description, view[tool.name]?.description, `description of ${tool.name}`);
|
package/dist/main.js
CHANGED
|
@@ -106,7 +106,8 @@ const conformCommand = Command.make("conform", {
|
|
|
106
106
|
cli: url("cli", "The command that starts the command line, for example \"node fixture-cli.ts\""),
|
|
107
107
|
webmcp: url("webmcp", "The URL of a web page that serves the app target. It runs in Chromium, through Playwright"),
|
|
108
108
|
pollBuffer: Flag.Int("poll-buffer").pipe(Flag.withDescription("The number of occurrences that a poll lease of the deployment keeps, from 1 to 97. With it, conform tests a cursor older than the buffer"), Flag.optional),
|
|
109
|
-
|
|
109
|
+
pollLeaseMcp: url("poll-lease-mcp", "The URL of an MCP server whose lease time is --poll-lease-ms. conform tests there that a lease with no poll ends"),
|
|
110
|
+
pollLeaseMs: Flag.Int("poll-lease-ms").pipe(Flag.withDescription("The lease time of the MCP server of --poll-lease-mcp, in milliseconds, shorter than the deadline"), Flag.optional),
|
|
110
111
|
webhookPrincipal: url("webhook-principal", "Test webhook delivery through --mcp. The deployment gives this principal to a request with the header Authorization: Bearer <principal>"),
|
|
111
112
|
webhookCert: url("webhook-cert", "The PEM file of the certificate of the HTTPS receiver of the webhook tests. It must be valid for 127.0.0.1, and the deployment must trust it"),
|
|
112
113
|
webhookKey: url("webhook-key", "The PEM file of the private key of --webhook-cert"),
|
|
@@ -130,6 +131,10 @@ const conformCommand = Command.make("conform", {
|
|
|
130
131
|
yield* Console.error("Give --webhook-principal, --webhook-cert and --webhook-key together.");
|
|
131
132
|
return yield* fail;
|
|
132
133
|
}
|
|
134
|
+
if (Option.isSome(options.pollLeaseMcp) !== Option.isSome(options.pollLeaseMs)) {
|
|
135
|
+
yield* Console.error("Give --poll-lease-mcp and --poll-lease-ms together.");
|
|
136
|
+
return yield* fail;
|
|
137
|
+
}
|
|
133
138
|
const settings = [
|
|
134
139
|
Option.isSome(options.webhookOtherPrincipal),
|
|
135
140
|
Option.isSome(options.webhookMaxTtlMs),
|
|
@@ -156,10 +161,11 @@ const conformCommand = Command.make("conform", {
|
|
|
156
161
|
http: value(options.http),
|
|
157
162
|
cli: words(options.cli),
|
|
158
163
|
webmcp: value(options.webmcp),
|
|
159
|
-
poll: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
poll: { bufferLimit: optionalInt(options.pollBuffer) },
|
|
165
|
+
pollLease: Option.isSome(options.pollLeaseMcp) && Option.isSome(options.pollLeaseMs) ? {
|
|
166
|
+
mcp: options.pollLeaseMcp.value,
|
|
167
|
+
leaseMs: options.pollLeaseMs.value
|
|
168
|
+
} : void 0,
|
|
163
169
|
webhook,
|
|
164
170
|
maximumBytes: options.maximumBytes,
|
|
165
171
|
deadline: options.deadline
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acid-cat/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "The AcidCat command line: check, format and view catalogs, and test implementations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acidcat",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@acid-cat/catalog": "0.
|
|
41
|
-
"@acid-cat/spec-ts": "0.
|
|
40
|
+
"@acid-cat/catalog": "0.15.0",
|
|
41
|
+
"@acid-cat/spec-ts": "0.15.0",
|
|
42
42
|
"@effect/platform-node": "^4.1.3",
|
|
43
43
|
"@effect/platform-node-shared": "^4.1.3",
|
|
44
44
|
"@modelcontextprotocol/client": "2.4.0",
|