agent-comms 9.0.3 → 9.0.5

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.
Files changed (134) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +4 -0
  4. package/dist/bridges/user/web/dist/bundle.js +1 -1
  5. package/dist/bridges/user/web/dist/mesh-worker.js +4 -4
  6. package/dist/bridges/user/web/dist/sw.js +1 -1
  7. package/dist/bridges/user/web/frontend/event-pump.d.ts +22 -0
  8. package/dist/bridges/user/web/frontend/event-pump.d.ts.map +1 -0
  9. package/dist/bridges/user/web/frontend/event-pump.js +73 -0
  10. package/dist/bridges/user/web/frontend/event-pump.js.map +1 -0
  11. package/dist/bridges/user/web/frontend/mesh-client.d.ts +2 -2
  12. package/dist/bridges/user/web/frontend/mesh-client.d.ts.map +1 -1
  13. package/dist/bridges/user/web/frontend/mesh-client.js +16 -24
  14. package/dist/bridges/user/web/frontend/mesh-client.js.map +1 -1
  15. package/dist/bridges/user/web/frontend/mesh-worker.d.ts +1 -1
  16. package/dist/bridges/user/web/frontend/mesh-worker.d.ts.map +1 -1
  17. package/dist/bridges/user/web/frontend/mesh-worker.js +31 -40
  18. package/dist/bridges/user/web/frontend/mesh-worker.js.map +1 -1
  19. package/dist/bridges/user/web/test/web-access.unit.test.d.ts +1 -1
  20. package/dist/bridges/user/web/test/web-access.unit.test.js +19 -375
  21. package/dist/bridges/user/web/test/web-access.unit.test.js.map +1 -1
  22. package/dist/core/bridge.d.ts +11 -0
  23. package/dist/core/bridge.d.ts.map +1 -1
  24. package/dist/core/bridge.js +17 -2
  25. package/dist/core/bridge.js.map +1 -1
  26. package/dist/core/index.d.ts +1 -1
  27. package/dist/core/index.d.ts.map +1 -1
  28. package/dist/core/index.js +1 -1
  29. package/dist/core/index.js.map +1 -1
  30. package/dist/core/test/build-action.unit.test.d.ts +2 -0
  31. package/dist/core/test/build-action.unit.test.d.ts.map +1 -0
  32. package/dist/core/test/build-action.unit.test.js +28 -0
  33. package/dist/core/test/build-action.unit.test.js.map +1 -0
  34. package/dist/test/ci-required-checks.unit.test.d.ts +2 -0
  35. package/dist/test/ci-required-checks.unit.test.d.ts.map +1 -0
  36. package/dist/test/ci-required-checks.unit.test.js +137 -0
  37. package/dist/test/ci-required-checks.unit.test.js.map +1 -0
  38. package/dist/test/claude-command.unit.test.js +2 -21
  39. package/dist/test/claude-command.unit.test.js.map +1 -1
  40. package/dist/test/conformance/corpus-files.d.ts +11 -0
  41. package/dist/test/conformance/corpus-files.d.ts.map +1 -0
  42. package/dist/test/conformance/corpus-files.js +71 -0
  43. package/dist/test/conformance/corpus-files.js.map +1 -0
  44. package/dist/test/conformance/corpus-types.d.ts +62 -0
  45. package/dist/test/conformance/corpus-types.d.ts.map +1 -0
  46. package/dist/test/conformance/corpus-types.js +8 -0
  47. package/dist/test/conformance/corpus-types.js.map +1 -0
  48. package/dist/test/conformance/corpus.d.ts +34 -0
  49. package/dist/test/conformance/corpus.d.ts.map +1 -0
  50. package/dist/test/conformance/corpus.js +134 -0
  51. package/dist/test/conformance/corpus.js.map +1 -0
  52. package/dist/test/conformance/read-json.d.ts +2 -0
  53. package/dist/test/conformance/read-json.d.ts.map +1 -0
  54. package/dist/test/conformance/read-json.js +7 -0
  55. package/dist/test/conformance/read-json.js.map +1 -0
  56. package/dist/test/conformance/text.d.ts +10 -0
  57. package/dist/test/conformance/text.d.ts.map +1 -0
  58. package/dist/test/conformance/text.js +64 -0
  59. package/dist/test/conformance/text.js.map +1 -0
  60. package/dist/test/conformance/validate.d.ts +14 -0
  61. package/dist/test/conformance/validate.d.ts.map +1 -0
  62. package/dist/test/conformance/validate.js +85 -0
  63. package/dist/test/conformance/validate.js.map +1 -0
  64. package/dist/test/conformance-functions.helper.d.ts +19 -0
  65. package/dist/test/conformance-functions.helper.d.ts.map +1 -0
  66. package/dist/test/conformance-functions.helper.js +583 -0
  67. package/dist/test/conformance-functions.helper.js.map +1 -0
  68. package/dist/test/conformance.unit.test.d.ts +2 -0
  69. package/dist/test/conformance.unit.test.d.ts.map +1 -0
  70. package/dist/test/conformance.unit.test.js +358 -0
  71. package/dist/test/conformance.unit.test.js.map +1 -0
  72. package/dist/test/error-reporting.unit.test.js +2 -90
  73. package/dist/test/error-reporting.unit.test.js.map +1 -1
  74. package/dist/test/version-report-actions.unit.test.d.ts +1 -1
  75. package/dist/test/version-report-actions.unit.test.js +2 -55
  76. package/dist/test/version-report-actions.unit.test.js.map +1 -1
  77. package/package.json +4 -2
  78. package/src/bridges/user/web/dist/bundle.js +1 -1
  79. package/src/bridges/user/web/dist/mesh-worker.js +4 -4
  80. package/src/bridges/user/web/dist/sw.js +1 -1
  81. package/src/core/bridge.ts +30 -1
  82. package/src/core/index.ts +1 -0
  83. package/dist/core/test/bridge.unit.test.d.ts +0 -5
  84. package/dist/core/test/bridge.unit.test.d.ts.map +0 -1
  85. package/dist/core/test/bridge.unit.test.js +0 -119
  86. package/dist/core/test/bridge.unit.test.js.map +0 -1
  87. package/dist/test/agent-table.unit.test.d.ts +0 -5
  88. package/dist/test/agent-table.unit.test.d.ts.map +0 -1
  89. package/dist/test/agent-table.unit.test.js +0 -53
  90. package/dist/test/agent-table.unit.test.js.map +0 -1
  91. package/dist/test/bind-retry.unit.test.d.ts +0 -2
  92. package/dist/test/bind-retry.unit.test.d.ts.map +0 -1
  93. package/dist/test/bind-retry.unit.test.js +0 -42
  94. package/dist/test/bind-retry.unit.test.js.map +0 -1
  95. package/dist/test/default-command.unit.test.d.ts +0 -2
  96. package/dist/test/default-command.unit.test.d.ts.map +0 -1
  97. package/dist/test/default-command.unit.test.js +0 -26
  98. package/dist/test/default-command.unit.test.js.map +0 -1
  99. package/dist/test/delegation-policy.unit.test.d.ts +0 -5
  100. package/dist/test/delegation-policy.unit.test.d.ts.map +0 -1
  101. package/dist/test/delegation-policy.unit.test.js +0 -52
  102. package/dist/test/delegation-policy.unit.test.js.map +0 -1
  103. package/dist/test/display-name.unit.test.d.ts +0 -5
  104. package/dist/test/display-name.unit.test.d.ts.map +0 -1
  105. package/dist/test/display-name.unit.test.js +0 -65
  106. package/dist/test/display-name.unit.test.js.map +0 -1
  107. package/dist/test/machine-list-groups.unit.test.d.ts +0 -5
  108. package/dist/test/machine-list-groups.unit.test.d.ts.map +0 -1
  109. package/dist/test/machine-list-groups.unit.test.js +0 -61
  110. package/dist/test/machine-list-groups.unit.test.js.map +0 -1
  111. package/dist/test/relay-selection.unit.test.d.ts +0 -5
  112. package/dist/test/relay-selection.unit.test.d.ts.map +0 -1
  113. package/dist/test/relay-selection.unit.test.js +0 -103
  114. package/dist/test/relay-selection.unit.test.js.map +0 -1
  115. package/dist/test/request-timeouts.unit.test.d.ts +0 -2
  116. package/dist/test/request-timeouts.unit.test.d.ts.map +0 -1
  117. package/dist/test/request-timeouts.unit.test.js +0 -28
  118. package/dist/test/request-timeouts.unit.test.js.map +0 -1
  119. package/dist/test/room-discovery.unit.test.d.ts +0 -2
  120. package/dist/test/room-discovery.unit.test.d.ts.map +0 -1
  121. package/dist/test/room-discovery.unit.test.js +0 -29
  122. package/dist/test/room-discovery.unit.test.js.map +0 -1
  123. package/dist/test/room-lookup.unit.test.d.ts +0 -2
  124. package/dist/test/room-lookup.unit.test.d.ts.map +0 -1
  125. package/dist/test/room-lookup.unit.test.js +0 -59
  126. package/dist/test/room-lookup.unit.test.js.map +0 -1
  127. package/dist/test/room-path.unit.test.d.ts +0 -2
  128. package/dist/test/room-path.unit.test.d.ts.map +0 -1
  129. package/dist/test/room-path.unit.test.js +0 -54
  130. package/dist/test/room-path.unit.test.js.map +0 -1
  131. package/dist/test/send-outcome.unit.test.d.ts +0 -2
  132. package/dist/test/send-outcome.unit.test.d.ts.map +0 -1
  133. package/dist/test/send-outcome.unit.test.js +0 -52
  134. package/dist/test/send-outcome.unit.test.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ import { readFileSync } from "node:fs";
2
+ /** Strict: a file that is not valid UTF-8 is an error, never read with replacement characters, and a leading byte order mark is kept and so refused by the parse, so every loader sees the same text (the Rust loader refuses both too). */
3
+ const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
4
+ export function readJson(path) {
5
+ return JSON.parse(decoder.decode(readFileSync(path)));
6
+ }
7
+ //# sourceMappingURL=read-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-json.js","sourceRoot":"","sources":["../../../src/test/conformance/read-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,4OAA4O;AAC5O,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAE3E,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Text } from "./corpus-types.js";
2
+ /** The string a corpus text denotes. */
3
+ export declare function textToString(text: Text): string;
4
+ /** The UTF-16 code units a corpus text denotes. */
5
+ export declare function textToCodeUnits(text: Text): readonly number[];
6
+ /** The name of a special number, as a corpus file writes it, or undefined for any other number. */
7
+ export declare function specialNumberName(value: number): string | undefined;
8
+ /** A value with every `{ "codeUnits": [...] }` replaced by the string it denotes and every `{ "$number": name }` by the number it names, at any depth. The schema has already refused an object that holds either key and anything else. */
9
+ export declare function decodeValue(value: unknown): unknown;
10
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/test/conformance/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAkB9C,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAI/C;AAED,mDAAmD;AACnD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,MAAM,EAAE,CAQ7D;AAUD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOnE;AAED,4OAA4O;AAC5O,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAwBnD"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The corpus carries every string as a sequence of UTF-16 code units, either as a JSON string or as `{ "codeUnits": [...] }` (`conformance/README.md`). A JavaScript string is already that sequence, so decoding is the identity for the first form and `String.fromCharCode` for the second.
3
+ */
4
+ function isRecord(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
+ }
7
+ function isCodeUnitsObject(value) {
8
+ const units = value.codeUnits;
9
+ return Array.isArray(units) && units.every((u) => typeof u === "number");
10
+ }
11
+ /** The string a corpus text denotes. */
12
+ export function textToString(text) {
13
+ return typeof text === "string"
14
+ ? text
15
+ : String.fromCharCode(...text.codeUnits);
16
+ }
17
+ /** The UTF-16 code units a corpus text denotes. */
18
+ export function textToCodeUnits(text) {
19
+ if (typeof text !== "string") {
20
+ return text.codeUnits;
21
+ }
22
+ return Array.from({ length: text.length }, (_, index) => text.charCodeAt(index));
23
+ }
24
+ /** The numbers a corpus file names with `{ "$number": name }`, a closed lookup: the canonical JSON form writes a negative zero as 0 and has no infinity or NaN. */
25
+ const NAMED_NUMBERS = {
26
+ "-0": -0,
27
+ Infinity: Number.POSITIVE_INFINITY,
28
+ "-Infinity": Number.NEGATIVE_INFINITY,
29
+ NaN: Number.NaN,
30
+ };
31
+ /** The name of a special number, as a corpus file writes it, or undefined for any other number. */
32
+ export function specialNumberName(value) {
33
+ if (Number.isNaN(value))
34
+ return "NaN";
35
+ if (Object.is(value, -0))
36
+ return "-0";
37
+ if (value === Number.POSITIVE_INFINITY)
38
+ return "Infinity";
39
+ if (value === Number.NEGATIVE_INFINITY)
40
+ return "-Infinity";
41
+ return undefined;
42
+ }
43
+ /** A value with every `{ "codeUnits": [...] }` replaced by the string it denotes and every `{ "$number": name }` by the number it names, at any depth. The schema has already refused an object that holds either key and anything else. */
44
+ export function decodeValue(value) {
45
+ if (Array.isArray(value)) {
46
+ return value.map((item) => decodeValue(item));
47
+ }
48
+ if (isRecord(value)) {
49
+ const named = value.$number;
50
+ if (typeof named === "string" && Object.keys(value).length === 1) {
51
+ const decoded = NAMED_NUMBERS[named];
52
+ if (decoded === undefined) {
53
+ throw new Error(`$number names ${named}, which no corpus file may`);
54
+ }
55
+ return decoded;
56
+ }
57
+ if (isCodeUnitsObject(value)) {
58
+ return String.fromCharCode(...value.codeUnits);
59
+ }
60
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, decodeValue(item)]));
61
+ }
62
+ return value;
63
+ }
64
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/test/conformance/text.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,iBAAiB,CACxB,KAA8B;IAE9B,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC;IAE9B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AAC3E,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,OAAO,OAAO,IAAI,KAAK,QAAQ;QAC7B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAM,CAAC,YAAY,CA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,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;QAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjE,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,4BAA4B,CAAC,CAAC;YACtE,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CACrE,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { CorpusFile, Manifest } from "./corpus-types.js";
2
+ /**
3
+ * Validates corpus files and the manifest against the schemas in `conformance/`, which is the whole definition of the format. The checks beside the schema are the rules JSON Schema cannot express and `conformance/README.md` lists: a case id is not repeated within a file, a manifest's `skip` lists are in ascending order, and no JSON string holds an unpaired surrogate (content that needs one is written as `{ "codeUnits": [...] }`). Nothing else is validated by hand.
4
+ */
5
+ export type Validation<T> = {
6
+ readonly ok: true;
7
+ readonly value: T;
8
+ } | {
9
+ readonly ok: false;
10
+ readonly problems: readonly string[];
11
+ };
12
+ export declare function validateCorpusFile(value: unknown): Validation<CorpusFile>;
13
+ export declare function validateManifest(value: unknown): Validation<Manifest>;
14
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/test/conformance/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;GAEG;AAEH,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAgFjE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,CAWzE;AAWD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAWrE"}
@@ -0,0 +1,85 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import Ajv2020Module from "ajv/dist/2020.js";
4
+ function readSchema(name) {
5
+ const parsed = JSON.parse(readFileSync(fileURLToPath(new URL(`../../../conformance/${name}`, import.meta.url)), "utf8"));
6
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
7
+ throw new Error(`${name} must hold a JSON object`);
8
+ }
9
+ return Object.fromEntries(Object.entries(parsed));
10
+ }
11
+ // Strict mode, so a schema keyword Ajv does not know is an error rather than ignored; unions of types are what the schema's open "any JSON value" definitions use.
12
+ // ajv ships CommonJS with a default export, which Node16 resolution types as the module and not the class.
13
+ const Ajv2020 = Ajv2020Module.default;
14
+ const ajv = new Ajv2020({
15
+ allErrors: true,
16
+ strict: true,
17
+ allowUnionTypes: true,
18
+ });
19
+ // The generic states what a document the schema accepted holds; it is the schema, not this code, that makes it true.
20
+ const checkCorpusFile = ajv.compile(readSchema("case.schema.json"));
21
+ const checkManifest = ajv.compile(readSchema("manifest.schema.json"));
22
+ function describeErrors(errors) {
23
+ if (errors === null || errors === undefined) {
24
+ return ["the schema rejected the document"];
25
+ }
26
+ return errors.map(({ instancePath, message }) => `${instancePath === "" ? "(root)" : instancePath} ${message ?? "is invalid"}`);
27
+ }
28
+ function isRecord(value) {
29
+ return typeof value === "object" && value !== null && !Array.isArray(value);
30
+ }
31
+ /** Where a JSON string, or an object key, holds an unpaired surrogate: such a document is read differently by different loaders. */
32
+ function malformedStrings(value, where) {
33
+ if (typeof value === "string") {
34
+ return value.isWellFormed() ? [] : [`${where} holds an unpaired surrogate`];
35
+ }
36
+ if (Array.isArray(value)) {
37
+ return value.flatMap((item, index) => malformedStrings(item, `${where}/${String(index)}`));
38
+ }
39
+ if (isRecord(value)) {
40
+ return Object.entries(value).flatMap(([key, item]) => [
41
+ ...malformedStrings(key, `${where}/(key)`),
42
+ ...malformedStrings(item, `${where}/${key}`),
43
+ ]);
44
+ }
45
+ return [];
46
+ }
47
+ function ruleProblems(file) {
48
+ const problems = [];
49
+ const ids = new Set();
50
+ for (const testCase of file.cases) {
51
+ if (ids.has(testCase.id)) {
52
+ problems.push(`case id ${testCase.id} is used twice in the file`);
53
+ }
54
+ ids.add(testCase.id);
55
+ }
56
+ return problems;
57
+ }
58
+ export function validateCorpusFile(value) {
59
+ const malformed = malformedStrings(value, "");
60
+ if (malformed.length > 0) {
61
+ return { ok: false, problems: malformed };
62
+ }
63
+ if (!checkCorpusFile(value)) {
64
+ return { ok: false, problems: describeErrors(checkCorpusFile.errors) };
65
+ }
66
+ const problems = ruleProblems(value);
67
+ return problems.length === 0 ? { ok: true, value } : { ok: false, problems };
68
+ }
69
+ /** Whether the ids are distinct and in ascending UTF-16 code unit order, which is the order every loader sorts in for the ASCII ids the schema allows. */
70
+ function isAscending(ids) {
71
+ return ids.every((id, index) => {
72
+ const before = ids[index - 1];
73
+ return before === undefined || before < id;
74
+ });
75
+ }
76
+ export function validateManifest(value) {
77
+ if (!checkManifest(value)) {
78
+ return { ok: false, problems: describeErrors(checkManifest.errors) };
79
+ }
80
+ const problems = Object.entries(value.files).flatMap(([name, entry]) => isAscending(entry.skip)
81
+ ? []
82
+ : [`${name}: "skip" must list distinct ids in ascending order`]);
83
+ return problems.length === 0 ? { ok: true, value } : { ok: false, problems };
84
+ }
85
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/test/conformance/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAW7C,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAChC,YAAY,CACV,aAAa,CAAC,IAAI,GAAG,CAAC,wBAAwB,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvE,MAAM,CACP,CACF,CAAC;IACF,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0BAA0B,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,mKAAmK;AACnK,2GAA2G;AAC3G,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;AACtC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC;IACtB,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,IAAI;IACZ,eAAe,EAAE,IAAI;CACtB,CAAC,CAAC;AAEH,qHAAqH;AACrH,MAAM,eAAe,GA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,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC/E,CAAC;AAED,0JAA0J;AAC1J,SAAS,WAAW,CAAC,GAAsB;IACzC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAE9B,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,GAAG,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;IACvE,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CACrE,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC;QACrB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,GAAG,IAAI,oDAAoD,CAAC,CAClE,CAAC;IAEF,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,19 @@
1
+ type CorpusFunction = (...args: readonly unknown[]) => unknown;
2
+ /** The outcome of validating an input: what the schema made of it, or every issue it found. */
3
+ export type ValidateResult = {
4
+ readonly ok: true;
5
+ readonly value: unknown;
6
+ } | {
7
+ readonly ok: false;
8
+ readonly issues: readonly {
9
+ readonly path: readonly (string | number)[];
10
+ readonly code: string;
11
+ readonly message: string;
12
+ }[];
13
+ };
14
+ export declare const FUNCTIONS: Readonly<Record<string, CorpusFunction>>;
15
+ export declare const SCHEMAS: Readonly<Record<string, (input: unknown) => ValidateResult>>;
16
+ /** Exposed for the CommsError code check the runner makes on a `throws` expectation. */
17
+ export declare function errorCode(error: unknown): string | undefined;
18
+ export {};
19
+ //# sourceMappingURL=conformance-functions.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance-functions.helper.d.ts","sourceRoot":"","sources":["../../src/test/conformance-functions.helper.ts"],"names":[],"mappings":"AAwGA,KAAK,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,OAAO,CAAC;AAE/D,+FAA+F;AAC/F,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,SAAS;QACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;QAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;CACL,CAAC;AAuZN,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAqS9D,CAAC;AAqBF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAC5B,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,cAAc,CAAC,CAgBnD,CAAC;AAEF,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE5D"}