@ggui-ai/protocol-conformance 0.1.0-rc.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.
Files changed (107) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +89 -0
  3. package/dist/cli.d.ts +15 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +193 -0
  6. package/dist/conformance-host.d.ts +155 -0
  7. package/dist/conformance-host.d.ts.map +1 -0
  8. package/dist/conformance-host.js +45 -0
  9. package/dist/fixtures/bootstrap-protocol/bootstrap-bundle-fetch-failed.json +26 -0
  10. package/dist/fixtures/bootstrap-protocol/bootstrap-meta-missing.json +32 -0
  11. package/dist/fixtures/bootstrap-protocol/bootstrap-success.json +17 -0
  12. package/dist/fixtures/bootstrap-protocol/index.d.ts +5 -0
  13. package/dist/fixtures/bootstrap-protocol/index.d.ts.map +1 -0
  14. package/dist/fixtures/bootstrap-protocol/index.js +24 -0
  15. package/dist/fixtures/canvas-mode-wire-shapes/canvas-bootstrap-mutual-exclusion.json +25 -0
  16. package/dist/fixtures/canvas-mode-wire-shapes/canvas-lifecycle-channel-emits-handshake-started.json +30 -0
  17. package/dist/fixtures/canvas-mode-wire-shapes/canvas-navigated-updates-active-stack-item.json +30 -0
  18. package/dist/fixtures/canvas-mode-wire-shapes/host-context-observed-persists.json +22 -0
  19. package/dist/fixtures/canvas-mode-wire-shapes/index.d.ts +5 -0
  20. package/dist/fixtures/canvas-mode-wire-shapes/index.d.ts.map +1 -0
  21. package/dist/fixtures/canvas-mode-wire-shapes/index.js +47 -0
  22. package/dist/fixtures/index.d.ts +78 -0
  23. package/dist/fixtures/index.d.ts.map +1 -0
  24. package/dist/fixtures/index.js +87 -0
  25. package/dist/fixtures/observability-events/index.d.ts +5 -0
  26. package/dist/fixtures/observability-events/index.d.ts.map +1 -0
  27. package/dist/fixtures/observability-events/index.js +22 -0
  28. package/dist/fixtures/observability-events/observability-contract-error-emitted.json +29 -0
  29. package/dist/fixtures/observability-events/observability-wired-tool-invoked.json +28 -0
  30. package/dist/fixtures/refresh-semantics/index.d.ts +5 -0
  31. package/dist/fixtures/refresh-semantics/index.d.ts.map +1 -0
  32. package/dist/fixtures/refresh-semantics/index.js +19 -0
  33. package/dist/fixtures/refresh-semantics/stream-refresh-success.json +40 -0
  34. package/dist/fixtures/reserved-channel-authority/index.d.ts +4 -0
  35. package/dist/fixtures/reserved-channel-authority/index.d.ts.map +1 -0
  36. package/dist/fixtures/reserved-channel-authority/index.js +21 -0
  37. package/dist/fixtures/reserved-channel-authority/props-update-roundtrip.json +34 -0
  38. package/dist/fixtures/reserved-channel-authority/stream-schema-violation.json +45 -0
  39. package/dist/fixtures/schema-version-handshake/index.d.ts +4 -0
  40. package/dist/fixtures/schema-version-handshake/index.d.ts.map +1 -0
  41. package/dist/fixtures/schema-version-handshake/index.js +20 -0
  42. package/dist/fixtures/schema-version-handshake/version-match.json +16 -0
  43. package/dist/fixtures/schema-version-handshake/version-mismatch.json +26 -0
  44. package/dist/fixtures/wired-action-dispatch/index.d.ts +5 -0
  45. package/dist/fixtures/wired-action-dispatch/index.d.ts.map +1 -0
  46. package/dist/fixtures/wired-action-dispatch/index.js +29 -0
  47. package/dist/fixtures/wired-action-dispatch/wired-action-success.json +36 -0
  48. package/dist/fixtures/wired-action-dispatch/wired-action-tool-not-found.json +31 -0
  49. package/dist/fixtures/wired-action-dispatch/wired-action-tool-threw.json +32 -0
  50. package/dist/fixtures/wired-action-dispatch/wired-action-tool-timeout.json +32 -0
  51. package/dist/index.d.ts +28 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +40 -0
  54. package/dist/loader.d.ts +19 -0
  55. package/dist/loader.d.ts.map +1 -0
  56. package/dist/loader.js +46 -0
  57. package/dist/match-behavior.d.ts +121 -0
  58. package/dist/match-behavior.d.ts.map +1 -0
  59. package/dist/match-behavior.js +385 -0
  60. package/dist/registration-conformance/cases/gate-export-not-registered.json +19 -0
  61. package/dist/registration-conformance/cases/gate-no-gadgets-accept.json +13 -0
  62. package/dist/registration-conformance/cases/gate-package-mismatch.json +19 -0
  63. package/dist/registration-conformance/cases/gate-priority-not-registered-outranks-mismatch.json +20 -0
  64. package/dist/registration-conformance/cases/gate-registered-resolves-accept.json +25 -0
  65. package/dist/registration-conformance/cases/gate-stdlib-hook-accept.json +27 -0
  66. package/dist/registration-conformance/cases/gate-typo-classifies-as-not-registered.json +27 -0
  67. package/dist/registration-conformance/index.d.ts +114 -0
  68. package/dist/registration-conformance/index.d.ts.map +1 -0
  69. package/dist/registration-conformance/index.js +63 -0
  70. package/dist/reporter.d.ts +32 -0
  71. package/dist/reporter.d.ts.map +1 -0
  72. package/dist/reporter.js +151 -0
  73. package/dist/resolution-conformance/cases/resolve-bundle-host-computed.json +13 -0
  74. package/dist/resolution-conformance/cases/resolve-default-host.json +12 -0
  75. package/dist/resolution-conformance/cases/resolve-explicit-bundle-and-style-url.json +14 -0
  76. package/dist/resolution-conformance/cases/resolve-explicit-bundle-url.json +12 -0
  77. package/dist/resolution-conformance/cases/resolve-loopback-host-http-scheme.json +13 -0
  78. package/dist/resolution-conformance/cases/resolve-package-only-no-version.json +8 -0
  79. package/dist/resolution-conformance/cases/resolve-stdlib-no-urls.json +10 -0
  80. package/dist/resolution-conformance/index.d.ts +76 -0
  81. package/dist/resolution-conformance/index.d.ts.map +1 -0
  82. package/dist/resolution-conformance/index.js +81 -0
  83. package/dist/run-conformance.d.ts +58 -0
  84. package/dist/run-conformance.d.ts.map +1 -0
  85. package/dist/run-conformance.js +286 -0
  86. package/dist/schema-conformance/cases/wire-bad-export-name-reject.json +11 -0
  87. package/dist/schema-conformance/cases/wire-bad-package-name-reject.json +11 -0
  88. package/dist/schema-conformance/cases/wire-component-export-accept.json +10 -0
  89. package/dist/schema-conformance/cases/wire-empty-package-reject.json +11 -0
  90. package/dist/schema-conformance/cases/wire-minimal-accept.json +10 -0
  91. package/dist/schema-conformance/cases/wire-multi-package-accept.json +14 -0
  92. package/dist/schema-conformance/cases/wire-prose-accept.json +15 -0
  93. package/dist/schema-conformance/cases/wire-registry-metadata-reject.json +13 -0
  94. package/dist/schema-conformance/cases/wire-stale-libraries-reject.json +14 -0
  95. package/dist/schema-conformance/cases/wire-stdlib-accept.json +10 -0
  96. package/dist/schema-conformance/cases/wire-transport-field-reject.json +15 -0
  97. package/dist/schema-conformance/cases/wire-version-field-reject.json +13 -0
  98. package/dist/schema-conformance/index.d.ts +71 -0
  99. package/dist/schema-conformance/index.d.ts.map +1 -0
  100. package/dist/schema-conformance/index.js +103 -0
  101. package/dist/types.d.ts +434 -0
  102. package/dist/types.d.ts.map +1 -0
  103. package/dist/types.js +62 -0
  104. package/dist/ws-transport.d.ts +42 -0
  105. package/dist/ws-transport.d.ts.map +1 -0
  106. package/dist/ws-transport.js +135 -0
  107. package/package.json +83 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Loqu, Inc. (Guuey)
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @ggui-ai/protocol-conformance
2
+
3
+ Conformance test kit for the ggui protocol. Ships a JSON fixture catalog + a runner that drives each fixture against a live implementation over WebSocket and reports scorecard-style pass / fail / skip output.
4
+
5
+ This kit is the protocol's conformance surface: it lets a third-party MCP builder prove their implementation is protocol-conformant without reimplementing the test harness.
6
+
7
+ ## Transport
8
+
9
+ **v1.0 is WebSocket-only.** The canonical ggui transport is WS (see SPEC §12 Transport Bindings). `TransportConfig` is shaped as an extensibly-closed union so later transports (stdio MCP, HTTP long-poll) can be added post-v1.1 without breaking the public API.
10
+
11
+ ## Path-A vs Path-B matchability
12
+
13
+ The fixture catalog spans both wire-observable claims and surface-observable claims. The kit's runner (`runConformance()`) handles the **Path-A** subset — behaviors a runner can assert from WS frames alone, with no MCP-Apps-host adapter and no Playwright page.
14
+
15
+ Path-A-matchable kinds (`matchBehavior` returns `pass` / `fail`):
16
+
17
+ - `bootstrap-success` — subscribe → `ack` round-trip
18
+ - `version-mismatch` — `error` frame with `code: UPGRADE_REQUIRED`
19
+ - `contract-error` — `_ggui:contract-error` envelope on the reserved channel
20
+ - `stream-update` — `stream` frame on a named channel matching the declared value
21
+ - `no-op` — silence after input dispatch
22
+ - `observability-event` — `wired-tool-invoked` and `contract-error-emitted` arms (the WS evidence the protocol-and-contract bar mandates a conformant host mirror-emit on)
23
+
24
+ Path-B-only kinds (`matchBehavior` returns `unmatchable-on-ws` → runner records SKIP):
25
+
26
+ - `bootstrap-failure` — fault surface is the host's bootstrap-fetch + `ui/initialize` postMessage round-trip; `renderer-url-override` / `ui-initialize-response-override` setup directives are MCP-Apps-host concerns, not WS server concerns.
27
+ - `props-update` — assertion is on rendered DOM after `_ggui:props` is emitted; matchable on WS only as "frame was emitted", not as "DOM reflects it".
28
+ - Future `observability-event` arms beyond the two above (e.g. `schema-version-mismatch`, `subscribe-failed`).
29
+
30
+ A Path-B browser-host harness drives these fixtures via Playwright + `page.route()` fault injection + DOM assertion. A future packaged browser-host adapter will fold that capability into the kit so third-party adopters don't reimplement it.
31
+
32
+ The partition is intentional: Path-A FAILs are vendor-neutrality bugs the server owns; Path-B SKIPs are not fails — they are claims a different driver is responsible for.
33
+
34
+ ## Pure-function conformance catalogs
35
+
36
+ The behavioral fixture catalog above asserts what an implementation _does_ over the wire. Some protocol obligations aren't transport-observable at all — they are deterministic _validation functions_: given an input, accept or reject it. SPEC §7.7.2's gadget obligations are exactly this. Modeling them as WebSocket fixtures would mean faking wire frames the protocol never emits; instead the kit ships **pure-function catalogs** — accept/reject cases graded against a caller-supplied function, with no host, session, or transport.
37
+
38
+ Each catalog ships its cases as raw JSON so a non-TypeScript implementer can grade their own implementation, and each runner takes the implementation as a callback — the kit never hard-binds a concrete one. Three catalogs ship today:
39
+
40
+ - **`@ggui-ai/protocol-conformance/schema-conformance`** — which `DataContract.clientCapabilities` payloads a conformant parser MUST accept / reject (the gadget wire shape).
41
+ - **`@ggui-ai/protocol-conformance/registration-conformance`** — which `(contract, appGadgets)` pairs the push-time gadget registry gate MUST accept / reject, and with which precise reject code (`gadget_not_registered` / `gadget_package_mismatch`).
42
+ - **`@ggui-ai/protocol-conformance/resolution-conformance`** — which bundle + style URLs the server MUST compute for a gadget descriptor's transport fields (`bundleHost` precedence, default host, loopback `http` scheme).
43
+
44
+ ```ts
45
+ import { runSchemaConformance } from "@ggui-ai/protocol-conformance/schema-conformance";
46
+ import { runRegistrationConformance } from "@ggui-ai/protocol-conformance/registration-conformance";
47
+ import { runResolutionConformance } from "@ggui-ai/protocol-conformance/resolution-conformance";
48
+
49
+ const schema = runSchemaConformance((clientCapabilities) =>
50
+ myGadgetWireParser.isValid(clientCapabilities)
51
+ );
52
+ const gate = runRegistrationConformance((contract, appGadgets) =>
53
+ myGadgetGate(contract, appGadgets)
54
+ );
55
+ const urls = runResolutionConformance((entry) => myGadgetUrlResolver(entry));
56
+
57
+ if (schema.failed.length + gate.failed.length + urls.failed.length > 0) {
58
+ process.exit(1);
59
+ }
60
+ ```
61
+
62
+ The `schema-conformance` meta-test binds its catalog to the live `@ggui-ai/protocol` `clientCapabilitiesSpecSchema` — a drift-catch if the wire schema diverges from the §7.7.2 obligations the catalog freezes. The `registration-conformance` and `resolution-conformance` meta-tests verify catalog coherence against faithful in-test implementations (the kit stays vendor-neutral — it does not depend on a server implementation); grading the _shipping_ gate / resolver is an implementation-side test that drives the corresponding runner.
63
+
64
+ ## Public API (target)
65
+
66
+ ```ts
67
+ import { runConformance } from "@ggui-ai/protocol-conformance";
68
+
69
+ const result = await runConformance({
70
+ serverUrl: "ws://localhost:3000/ws",
71
+ auth: { kind: "bearer", token: process.env.TOKEN! },
72
+ });
73
+
74
+ if (result.failed.length > 0) {
75
+ process.exit(1);
76
+ }
77
+ ```
78
+
79
+ CLI equivalent:
80
+
81
+ ```
82
+ npx @ggui-ai/protocol-conformance --url ws://localhost:3000/ws --auth bearer:$TOKEN
83
+ ```
84
+
85
+ Full adoption guide + fixture-to-contract mapping table land with the fixture-extraction commit.
86
+
87
+ ## License
88
+
89
+ Apache 2.0 — see `../LICENSE`.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import type { AuthConfig } from './types.js';
3
+ interface ParsedArgs {
4
+ readonly url?: string;
5
+ readonly auth?: string;
6
+ readonly only?: readonly string[];
7
+ readonly timeoutMs?: number;
8
+ readonly verbose: boolean;
9
+ readonly help: boolean;
10
+ }
11
+ declare function parseArgs(argv: readonly string[]): ParsedArgs;
12
+ declare function parseAuth(spec: string): AuthConfig;
13
+ declare function main(argv: readonly string[]): Promise<number>;
14
+ export { main, parseArgs, parseAuth };
15
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA4BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C,UAAU,UAAU;IAClB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,iBAAS,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CA8CtD;AAED,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAY3C;AA+BD,iBAAe,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAoD5D;AA+BD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC"}
package/dist/cli.js ADDED
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `ggui-protocol-conformance` — CLI entry point.
4
+ *
5
+ * Usage:
6
+ *
7
+ * npx @ggui-ai/protocol-conformance \
8
+ * --url http://localhost:3000 \
9
+ * --auth bearer:TOKEN
10
+ *
11
+ * Exits with code 0 if every fixture passed OR skipped; exits 1 if
12
+ * ANY fixture failed. Skips are not failures — an implementation may
13
+ * legitimately not provide every `ConformanceHost` directive in
14
+ * v1.0. Operators who want skip-is-failure semantics can pair
15
+ * `--require-host` (future) with a host that implements every known
16
+ * directive.
17
+ *
18
+ * Honest scope of the bundled CLI: no `host` wiring. The CLI runs
19
+ * the runner with an absent host, meaning every fixture with non-empty
20
+ * `setup` skips cleanly with the "no host provided" reason. To get
21
+ * real pass/fail signal against an implementation, consumers call
22
+ * `runConformance({ host: myImpl })` programmatically. The CLI is the
23
+ * lowest-friction entry point for a smoke check, and for CI jobs where
24
+ * the server under test is exercised directly over the wire via a
25
+ * subprocess harness rather than a `ConformanceHost` injection.
26
+ */
27
+ import { createDefaultReporter, formatFailures, formatSkips } from './reporter.js';
28
+ import { runConformance } from './run-conformance.js';
29
+ function parseArgs(argv) {
30
+ let url;
31
+ let auth;
32
+ const only = [];
33
+ let timeoutMs;
34
+ let verbose = false;
35
+ let help = false;
36
+ for (let i = 0; i < argv.length; i += 1) {
37
+ const flag = argv[i];
38
+ const next = () => {
39
+ const value = argv[i + 1];
40
+ if (value === undefined || value.startsWith('--')) {
41
+ throw new Error(`missing value for '${flag}'`);
42
+ }
43
+ i += 1;
44
+ return value;
45
+ };
46
+ switch (flag) {
47
+ case '--url':
48
+ url = next();
49
+ break;
50
+ case '--auth':
51
+ auth = next();
52
+ break;
53
+ case '--only':
54
+ only.push(next());
55
+ break;
56
+ case '--timeout-ms':
57
+ timeoutMs = Number.parseInt(next(), 10);
58
+ if (Number.isNaN(timeoutMs))
59
+ throw new Error('--timeout-ms must be an integer');
60
+ break;
61
+ case '--verbose':
62
+ case '-v':
63
+ verbose = true;
64
+ break;
65
+ case '--help':
66
+ case '-h':
67
+ help = true;
68
+ break;
69
+ default:
70
+ throw new Error(`unknown flag '${flag}' — run with --help for usage`);
71
+ }
72
+ }
73
+ return { url, auth, only, timeoutMs, verbose, help };
74
+ }
75
+ function parseAuth(spec) {
76
+ const idx = spec.indexOf(':');
77
+ if (idx === -1) {
78
+ throw new Error(`--auth expects 'kind:value'; received '${spec}'`);
79
+ }
80
+ const kind = spec.slice(0, idx);
81
+ const value = spec.slice(idx + 1);
82
+ if (kind === 'bearer')
83
+ return { kind: 'bearer', token: value };
84
+ if (kind === 'session-cookie')
85
+ return { kind: 'session-cookie', cookie: value };
86
+ throw new Error(`--auth kind '${kind}' is not recognized; supported: 'bearer', 'session-cookie'`);
87
+ }
88
+ // =============================================================================
89
+ // Entry point
90
+ // =============================================================================
91
+ const USAGE = `
92
+ ggui-protocol-conformance — run the protocol conformance kit against a live server
93
+
94
+ Usage:
95
+ ggui-protocol-conformance --url <URL> --auth <kind:value> [options]
96
+
97
+ Required:
98
+ --url <URL> Base URL of the server (http://… or https://…).
99
+ The runner derives ws://…/ws from this.
100
+ --auth <kind:value> Auth carried on the WS upgrade.
101
+ bearer:TOKEN — Authorization header
102
+ session-cookie:COOKIE — Cookie header
103
+
104
+ Options:
105
+ --only <fixture-name> Run only this fixture. May be repeated.
106
+ --timeout-ms <N> Per-fixture observation window. Default 2000.
107
+ --verbose, -v Print failure details + skip reasons at the end.
108
+ --help, -h Show this help.
109
+
110
+ Exit codes:
111
+ 0 — all fixtures passed or skipped.
112
+ 1 — at least one fixture failed.
113
+ 2 — invocation error (bad args, cannot reach server, etc.).
114
+ `.trimStart();
115
+ async function main(argv) {
116
+ let parsed;
117
+ try {
118
+ parsed = parseArgs(argv);
119
+ }
120
+ catch (err) {
121
+ process.stderr.write(`error: ${String(err.message ?? err)}\n\n`);
122
+ process.stderr.write(USAGE);
123
+ return 2;
124
+ }
125
+ if (parsed.help) {
126
+ process.stdout.write(USAGE);
127
+ return 0;
128
+ }
129
+ if (parsed.url === undefined) {
130
+ process.stderr.write('error: --url is required\n\n');
131
+ process.stderr.write(USAGE);
132
+ return 2;
133
+ }
134
+ if (parsed.auth === undefined) {
135
+ process.stderr.write('error: --auth is required\n\n');
136
+ process.stderr.write(USAGE);
137
+ return 2;
138
+ }
139
+ let auth;
140
+ try {
141
+ auth = parseAuth(parsed.auth);
142
+ }
143
+ catch (err) {
144
+ process.stderr.write(`error: ${String(err.message ?? err)}\n\n`);
145
+ process.stderr.write(USAGE);
146
+ return 2;
147
+ }
148
+ const reporter = createDefaultReporter();
149
+ const result = await runConformance({
150
+ serverUrl: parsed.url,
151
+ auth,
152
+ only: parsed.only !== undefined && parsed.only.length > 0 ? parsed.only : undefined,
153
+ observationTimeoutMs: parsed.timeoutMs,
154
+ reporter,
155
+ });
156
+ if (parsed.verbose) {
157
+ const failures = formatFailures(result.failed);
158
+ if (failures.length > 0)
159
+ process.stdout.write(`${failures}\n`);
160
+ const skips = formatSkips(result.skipped);
161
+ if (skips.length > 0)
162
+ process.stdout.write(`${skips}\n`);
163
+ }
164
+ return result.failed.length > 0 ? 1 : 0;
165
+ }
166
+ // Immediately-invoked — this module IS the bin entry. Tests import
167
+ // `parseArgs` / `parseAuth` / `main` via named exports without
168
+ // triggering the run.
169
+ if (isEntryPoint()) {
170
+ main(process.argv.slice(2)).then((code) => process.exit(code), (err) => {
171
+ process.stderr.write(`fatal: ${String(err.message ?? err)}\n`);
172
+ process.exit(2);
173
+ });
174
+ }
175
+ function isEntryPoint() {
176
+ // Node ESM entry-point check. `import.meta.url` equals
177
+ // `pathToFileURL(process.argv[1])` when this module was invoked as
178
+ // the script. Guards against running `main()` when the module is
179
+ // imported (e.g., from meta-tests).
180
+ if (typeof import.meta.url !== 'string')
181
+ return false;
182
+ const scriptPath = process.argv[1];
183
+ if (typeof scriptPath !== 'string' || scriptPath.length === 0)
184
+ return false;
185
+ try {
186
+ const scriptUrl = new URL(`file://${scriptPath}`);
187
+ return import.meta.url === scriptUrl.href;
188
+ }
189
+ catch {
190
+ return false;
191
+ }
192
+ }
193
+ export { main, parseArgs, parseAuth };
@@ -0,0 +1,155 @@
1
+ /**
2
+ * `ConformanceHost` — the seam between the kit's authored fixtures
3
+ * and the implementation under test.
4
+ *
5
+ * Most fixtures declare `setup` / `teardown` directives (see
6
+ * {@link SetupStep} / {@link TeardownStep} in `./types`) that the host
7
+ * dispatches against its live server. v1.0 of the kit does NOT
8
+ * require implementations to ship a host — fixtures that need setup
9
+ * directives skip cleanly when `runConformance()` is called without
10
+ * a `host`.
11
+ *
12
+ * When a host IS provided, the runner calls `dispatchSetup()` for
13
+ * every step before driving the fixture's `inputEnvelope`, then
14
+ * `dispatchTeardown()` for every step after the assertion. Unknown
15
+ * `kind` values MUST throw so unimplemented directives surface as a
16
+ * test SKIP with a clear "host does not implement X" reason — never
17
+ * a silent pass.
18
+ *
19
+ * ## Extensibly-closed
20
+ *
21
+ * The concrete step vocabulary below mirrors `./types`' vocabulary
22
+ * but is re-exported here as a host-facing narrower form:
23
+ * - Every arm carries the full semantic payload (not the JSON-
24
+ * loader's `unknown`-fields view).
25
+ * - The tail `(Record<string, unknown> & { readonly kind: string & {} })`
26
+ * catches fixture-JSON directives the host hasn't wired — the host
27
+ * returns by throwing, the runner maps it to a skip.
28
+ *
29
+ * Third-party hosts MAY extend either union with additional arms by
30
+ * augmenting the declaration in their own module. v1.0 of the kit
31
+ * does not require exhaustive coverage — it requires *honest*
32
+ * coverage: either implement the directive OR throw, never silently
33
+ * succeed on an unknown kind.
34
+ *
35
+ * ## Relation to `./types`
36
+ *
37
+ * `./types` defines the JSON-authoring surface: every directive has
38
+ * optional-by-default fields so JSON authors don't have to think
39
+ * about shape. This module defines the *runtime* surface: once the
40
+ * loader has validated a directive, the host receives a narrowed
41
+ * form. The two are intentionally parallel but not identical — JSON
42
+ * loaders accept what the author wrote; hosts receive what the
43
+ * runner confirmed is shape-valid.
44
+ */
45
+ /**
46
+ * Setup directive the host dispatches BEFORE a fixture's input
47
+ * envelope drives the system under test.
48
+ *
49
+ * Extensibly-closed: a host that receives a `kind` it doesn't
50
+ * recognize MUST throw `Error('conformance-host: unknown setup kind: <kind>')`
51
+ * so the runner records the fixture as SKIPPED with that reason —
52
+ * never silently succeed.
53
+ */
54
+ export type SetupStep = CreateSessionSetup | RegisterToolSetup | RegisterActionSpecSetup | EmitEnvelopeSetup | RendererUrlOverrideSetup | UiInitializeResponseOverrideSetup | ServerVersionOverrideSetup | UnknownSetupStep;
55
+ export interface CreateSessionSetup {
56
+ readonly kind: 'create-session';
57
+ readonly sessionId: string;
58
+ readonly appId?: string;
59
+ }
60
+ /**
61
+ * Register a tool on the session by symbolic handler name. Known
62
+ * handlers the reference implementation supports:
63
+ * - `'echo'` — returns `{received: args}`.
64
+ * - `'throw'` — rejects with `Error('tool_threw_for_fixture')`.
65
+ * - `'timeout'` — never resolves; runner times out per policy.
66
+ * - `'malformed'`— returns `{wrong:'shape'}` to exercise
67
+ * `SCHEMA_VIOLATION`.
68
+ */
69
+ export interface RegisterToolSetup {
70
+ readonly kind: 'register-tool';
71
+ readonly name: string;
72
+ readonly handler: 'echo' | 'throw' | 'timeout' | 'malformed' | (string & {});
73
+ }
74
+ export interface RegisterActionSpecSetup {
75
+ readonly kind: 'register-actionspec';
76
+ readonly name: string;
77
+ readonly tool: string;
78
+ }
79
+ export interface EmitEnvelopeSetup {
80
+ readonly kind: 'emit-envelope';
81
+ readonly channel: string;
82
+ readonly payload: unknown;
83
+ }
84
+ export interface RendererUrlOverrideSetup {
85
+ readonly kind: 'renderer-url-override';
86
+ readonly url: string;
87
+ }
88
+ export interface UiInitializeResponseOverrideSetup {
89
+ readonly kind: 'ui-initialize-response-override';
90
+ readonly response: unknown;
91
+ }
92
+ export interface ServerVersionOverrideSetup {
93
+ readonly kind: 'server-version-override';
94
+ readonly version: string;
95
+ }
96
+ /**
97
+ * Future-compat catch. A host that reaches this arm MUST throw rather
98
+ * than return silently — the runner interprets the throw as a skip
99
+ * with the error message as the reason.
100
+ */
101
+ export type UnknownSetupStep = Record<string, unknown> & {
102
+ readonly kind: string & {};
103
+ };
104
+ export type TeardownStep = CloseSessionTeardown | UnregisterToolTeardown | UnknownTeardownStep;
105
+ export interface CloseSessionTeardown {
106
+ readonly kind: 'close-session';
107
+ readonly sessionId: string;
108
+ }
109
+ export interface UnregisterToolTeardown {
110
+ readonly kind: 'unregister-tool';
111
+ readonly name: string;
112
+ }
113
+ export type UnknownTeardownStep = Record<string, unknown> & {
114
+ readonly kind: string & {};
115
+ };
116
+ /**
117
+ * Adapter the implementation under test provides to the runner. An
118
+ * implementation MAY:
119
+ *
120
+ * - Implement every directive the kit authors (full coverage — the
121
+ * reference `@ggui-ai/mcp-server`-backed host target).
122
+ * - Implement a subset + throw on unknown kinds (partial coverage
123
+ * — the kit records unimplemented directives as SKIPPED rather
124
+ * than failed).
125
+ * - Not be provided at all (the runner drops every fixture with a
126
+ * non-empty `setup` or `teardown` as skip-with-reason).
127
+ *
128
+ * The runner invokes `dispatchSetup()` once per setup step, in order,
129
+ * before driving the fixture's `inputEnvelope`; invokes
130
+ * `dispatchTeardown()` once per teardown step, in order, after the
131
+ * assertion (pass or fail). Teardown runs unconditionally — the host
132
+ * is responsible for its own idempotency under partial setup.
133
+ *
134
+ * Throwing from either dispatcher is the signal for "I don't
135
+ * implement this directive" — the runner records the fixture as
136
+ * SKIPPED with the error's `message` as the skip reason. A host MUST
137
+ * NOT treat a fixture as passed after throwing from setup — the
138
+ * runner does not call the assertion if setup throws.
139
+ */
140
+ export interface ConformanceHost {
141
+ /**
142
+ * Dispatch one setup step. Throws `Error` to signal "directive not
143
+ * implemented" — the runner maps this to a skip with the error's
144
+ * message as the skip reason. Throws are NOT treated as failures.
145
+ */
146
+ dispatchSetup(step: SetupStep): Promise<void>;
147
+ /**
148
+ * Dispatch one teardown step. Same contract as `dispatchSetup`.
149
+ * Teardown errors do NOT flip a passed fixture to failed — they
150
+ * emit a warning-level event to the reporter so operators can see
151
+ * the cleanup gap without corrupting the pass/fail tally.
152
+ */
153
+ dispatchTeardown(step: TeardownStep): Promise<void>;
154
+ }
155
+ //# sourceMappingURL=conformance-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance-host.d.ts","sourceRoot":"","sources":["../src/conformance-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAMH;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,uBAAuB,GACvB,iBAAiB,GACjB,wBAAwB,GACxB,iCAAiC,GACjC,0BAA0B,GAC1B,gBAAgB,CAAC;AAErB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;CAC9E;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,IAAI,EAAE,iCAAiC,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC;CAC5B,CAAC;AAMF,MAAM,MAAM,YAAY,GACpB,oBAAoB,GACpB,sBAAsB,GACtB,mBAAmB,CAAC;AAExB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC;CAC5B,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD"}