@agentplat/mesh-conformance 0.3.0-beta.1

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.
@@ -0,0 +1,103 @@
1
+ import { assertCondition, awaitConformanceOperation, bytesEqual, runConformanceCleanup, runBoundedCase, runnerContext, } from "./runner.js";
2
+ export async function runMeshTransportConformance(options) {
3
+ const context = runnerContext(options);
4
+ const bytes = options.signedEnvelopeBytes?.slice();
5
+ if (!(bytes instanceof Uint8Array) ||
6
+ bytes.byteLength < 1 ||
7
+ bytes.byteLength > 262_144) {
8
+ throw new RangeError("Mesh transport conformance bytes are invalid");
9
+ }
10
+ return Object.freeze([
11
+ await runBoundedCase({
12
+ caseId: "transport.retry.exact_bytes",
13
+ capability: "transport.exact_byte_retry",
14
+ context,
15
+ run: (signal) => withAdapter(options.factory, context, signal, "retry", async (adapter) => {
16
+ const first = await adapter.deliver(bytes.slice());
17
+ const second = await adapter.deliver(bytes.slice());
18
+ assertReceipt(first);
19
+ assertReceipt(second);
20
+ assertCondition(first.disposition === "retryable");
21
+ assertCondition(second.disposition === "accepted");
22
+ const observed = adapter.observations();
23
+ assertObservations(observed);
24
+ assertCondition(observed.attempts.length === 2);
25
+ assertCondition(bytesEqual(observed.attempts[0], bytes));
26
+ assertCondition(bytesEqual(observed.attempts[1], bytes));
27
+ assertCondition(bytesEqual(observed.attempts[0], observed.attempts[1]));
28
+ }),
29
+ }),
30
+ await runBoundedCase({
31
+ caseId: "transport.redirect.refused",
32
+ capability: "transport.exact_byte_retry",
33
+ context,
34
+ run: (signal) => withAdapter(options.factory, context, signal, "redirect", async (adapter) => {
35
+ const receipt = await adapter.deliver(bytes.slice());
36
+ assertReceipt(receipt);
37
+ const observed = adapter.observations();
38
+ assertObservations(observed);
39
+ assertCondition(observed.redirectFollowed === false);
40
+ assertCondition(observed.attempts.length === 1);
41
+ assertCondition(receipt.disposition !== "accepted");
42
+ }),
43
+ }),
44
+ await runBoundedCase({
45
+ caseId: "transport.receipt.coarse",
46
+ capability: "transport.coarse_receipts",
47
+ context,
48
+ run: (signal) => withAdapter(options.factory, context, signal, "receipt", async (adapter) => {
49
+ const receipt = await adapter.deliver(bytes.slice());
50
+ assertReceipt(receipt);
51
+ }),
52
+ }),
53
+ ]);
54
+ }
55
+ function assertReceipt(receipt) {
56
+ if (!receipt || typeof receipt !== "object") {
57
+ throw new TypeError("Mesh conformance receipt is invalid");
58
+ }
59
+ const keys = Object.keys(receipt).sort();
60
+ const allowed = new Set(["disposition", "messageId", "retryAfterMs"]);
61
+ assertCondition(keys.every((key) => allowed.has(key)));
62
+ assertCondition(receipt.disposition === "accepted" ||
63
+ receipt.disposition === "permanent_rejection" ||
64
+ receipt.disposition === "retryable");
65
+ assertCondition(receipt.messageId === undefined ||
66
+ /^[A-Za-z0-9_-]{21}[AQgw]$/u.test(receipt.messageId));
67
+ assertCondition(receipt.retryAfterMs === undefined ||
68
+ (receipt.disposition === "retryable" &&
69
+ Number.isSafeInteger(receipt.retryAfterMs) &&
70
+ receipt.retryAfterMs >= 1 &&
71
+ receipt.retryAfterMs <= 3_600_000));
72
+ assertCondition(new TextEncoder().encode(JSON.stringify(receipt)).byteLength <= 2_048);
73
+ assertCondition(!/(?:capabilit|credential|database|high.?water|key|peer.?card|secret|supported.?version)/iu.test(JSON.stringify(receipt)));
74
+ }
75
+ function assertObservations(observed) {
76
+ if (!observed ||
77
+ typeof observed !== "object" ||
78
+ Array.isArray(observed) ||
79
+ Object.keys(observed).sort().join(",") !== "attempts,redirectFollowed" ||
80
+ !Array.isArray(observed.attempts) ||
81
+ observed.attempts.length > 8 ||
82
+ observed.attempts.some((attempt) => !(attempt instanceof Uint8Array) || attempt.byteLength > 262_144) ||
83
+ typeof observed.redirectFollowed !== "boolean") {
84
+ throw new TypeError("Mesh transport conformance observations are invalid");
85
+ }
86
+ }
87
+ async function withAdapter(factory, context, signal, scenario, run) {
88
+ const adapter = await awaitConformanceOperation(factory(scenario, Object.freeze({ seed: context.seed, signal })), signal);
89
+ if (!adapter || typeof adapter !== "object") {
90
+ throw new TypeError("Mesh transport conformance factory is invalid");
91
+ }
92
+ let failed;
93
+ try {
94
+ await awaitConformanceOperation(run(adapter), signal);
95
+ }
96
+ catch (error) {
97
+ failed = error;
98
+ }
99
+ await runConformanceCleanup(adapter.cleanup?.bind(adapter), context.cleanupTimeoutMs, failed);
100
+ if (failed !== undefined)
101
+ throw failed;
102
+ }
103
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,aAAa,GAEd,MAAM,aAAa,CAAC;AA+BrB,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAwC;IAExC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,EAAE,KAAK,EAAE,CAAC;IACnD,IACE,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC;QAC9B,KAAK,CAAC,UAAU,GAAG,CAAC;QACpB,KAAK,CAAC,UAAU,GAAG,OAAO,EAC1B,CAAC;QACD,MAAM,IAAI,UAAU,CAAC,8CAA8C,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,MAAM,cAAc,CAAC;YACnB,MAAM,EAAE,6BAA6B;YACrC,UAAU,EAAE,4BAA4B;YACxC,OAAO;YACP,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CACd,WAAW,CACT,OAAO,CAAC,OAAO,EACf,OAAO,EACP,MAAM,EACN,OAAO,EACP,KAAK,EAAE,OAAO,EAAE,EAAE;gBAChB,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;gBACnD,MAAM,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,CAAC,qDAAqD,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,KAAK,UAAU,WAAW,CACxB,OAAwC,EACxC,OAAyC,EACzC,MAAmB,EACnB,QAA0C,EAC1C,GAAuE;IAEvE,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAC7C,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAChE,MAAM,CACP,CAAC;IACF,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,yBAAyB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,qBAAqB,CACzB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EAC9B,OAAO,CAAC,gBAAgB,EACxB,MAAM,CACP,CAAC;IACF,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,MAAM,CAAC;AACzC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@agentplat/mesh-conformance",
3
+ "version": "0.3.0-beta.1",
4
+ "description": "Provider-neutral compatibility runners for Agentplat Mesh adapters.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./protocol": {
16
+ "types": "./dist/protocol.d.ts",
17
+ "import": "./dist/protocol.js"
18
+ },
19
+ "./transport": {
20
+ "types": "./dist/transport.d.ts",
21
+ "import": "./dist/transport.js"
22
+ },
23
+ "./durability": {
24
+ "types": "./dist/durability.d.ts",
25
+ "import": "./dist/durability.js"
26
+ },
27
+ "./rooms": {
28
+ "types": "./dist/rooms.d.ts",
29
+ "import": "./dist/rooms.js"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ],
36
+ "dependencies": {
37
+ "@agentplat/mesh": "^0.3.0-beta.1",
38
+ "@agentplat/rooms-mesh": "^0.3.0-beta.1",
39
+ "@agentplat/mesh-protocol": "^0.3.0-beta.1"
40
+ },
41
+ "engines": {
42
+ "node": ">=20.19.3"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/Agentplat/agentplat.git",
50
+ "directory": "packages/mesh-conformance"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc -p tsconfig.json",
54
+ "type-check": "tsc -p tsconfig.json --noEmit",
55
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
56
+ }
57
+ }