@ggui-ai/protocol 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.
Files changed (66) hide show
  1. package/dist/envelope-adapters.d.ts +1 -14
  2. package/dist/envelope-adapters.d.ts.map +1 -1
  3. package/dist/envelope-adapters.js +17 -1
  4. package/dist/envelopes/render-refusal.d.ts +49 -0
  5. package/dist/envelopes/render-refusal.d.ts.map +1 -0
  6. package/dist/envelopes/render-refusal.js +12 -0
  7. package/dist/gadgets/resolve-app-gadgets.d.ts +1 -1
  8. package/dist/gadgets/stdlib-gadgets.d.ts +2 -2
  9. package/dist/gadgets/stdlib-gadgets.js +1 -1
  10. package/dist/index.d.ts +67 -63
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -0
  13. package/dist/integrations/mcp-apps.d.ts +2 -2
  14. package/dist/schemas/blueprint.d.ts +2 -2
  15. package/dist/schemas/data-contract.d.ts +10 -30
  16. package/dist/schemas/data-contract.d.ts.map +1 -1
  17. package/dist/schemas/data-contract.js +4 -27
  18. package/dist/schemas/interface-context.d.ts +44 -0
  19. package/dist/schemas/interface-context.d.ts.map +1 -0
  20. package/dist/schemas/interface-context.js +22 -0
  21. package/dist/schemas/invoke.d.ts +3 -3
  22. package/dist/schemas/invoke.js +1 -1
  23. package/dist/schemas/mcp.d.ts +203 -94
  24. package/dist/schemas/mcp.d.ts.map +1 -1
  25. package/dist/schemas/mcp.js +110 -32
  26. package/dist/schemas/public-env-key.d.ts +26 -0
  27. package/dist/schemas/public-env-key.d.ts.map +1 -0
  28. package/dist/schemas/public-env-key.js +25 -0
  29. package/dist/schemas/render-input-envelope.d.ts +2 -2
  30. package/dist/schemas/runtime-telemetry-limits.d.ts +11 -0
  31. package/dist/schemas/runtime-telemetry-limits.d.ts.map +1 -0
  32. package/dist/schemas/runtime-telemetry-limits.js +10 -0
  33. package/dist/transport/websocket.d.ts +5 -5
  34. package/dist/types/auth.d.ts +1 -1
  35. package/dist/types/contract-inference.d.ts +1 -1
  36. package/dist/types/events.d.ts +1 -1
  37. package/dist/types/ggui-session-event.d.ts +2 -2
  38. package/dist/types/host-context.d.ts +3 -3
  39. package/dist/types/interface-context.d.ts +1 -1
  40. package/dist/types/invoke.d.ts +1 -1
  41. package/dist/types/lifecycle.d.ts +1 -1
  42. package/dist/types/live-channel.d.ts +2 -2
  43. package/dist/types/mcp.d.ts +20 -63
  44. package/dist/types/mcp.d.ts.map +1 -1
  45. package/dist/types/mcp.js +7 -0
  46. package/dist/types/refusal-codes.d.ts +23 -2
  47. package/dist/types/refusal-codes.d.ts.map +1 -1
  48. package/dist/types/refusal-codes.js +26 -9
  49. package/dist/types/render.d.ts +9 -8
  50. package/dist/types/render.d.ts.map +1 -1
  51. package/dist/types/ui-generator.d.ts +1 -1
  52. package/dist/validation/ajv-runtime.d.ts +2 -2
  53. package/dist/validation/contract-validator.d.ts +6 -6
  54. package/dist/validation/cross-references.d.ts +2 -2
  55. package/dist/validation/hygiene-rules.d.ts +1 -1
  56. package/dist/validation/name-invariants.d.ts +2 -2
  57. package/dist/validation/reserved-channels.d.ts +1 -1
  58. package/dist/validation/schema-compat-invariants.d.ts +2 -2
  59. package/dist/validation/schema-meta-validation.d.ts +1 -1
  60. package/dist/version.d.ts +132 -10
  61. package/dist/version.d.ts.map +1 -1
  62. package/dist/version.js +132 -10
  63. package/dist/wire.d.ts +45 -0
  64. package/dist/wire.d.ts.map +1 -0
  65. package/dist/wire.js +44 -0
  66. package/package.json +7 -1
package/dist/version.js CHANGED
@@ -6,6 +6,75 @@
6
6
  * schema change; the most recent change anchors {@link PROTOCOL_VERSION}.
7
7
  *
8
8
  * --------------------------------------------------------------------
9
+ * SPEC §7.1's refused arm is ONE primitive (2026-09-05, additive,
10
+ * pre-launch, ggui#803 leg 9). The tool result a render gate answers a
11
+ * pre-generation refusal with was built by hand in
12
+ * `@ggui-ai/mcp-server-handlers` (`buildRenderRefusalText` + an inline
13
+ * `{ outcome: 'refused', refusal }`), the conformance kit carried its
14
+ * own reference, and the reference server could not project it at all
15
+ * — so the reference server was not a reference for the refused
16
+ * envelope, and a third hand-built copy there would only have re-graded
17
+ * the kit's reference.
18
+ *
19
+ * rr1. **`projectRenderRefusal(refusal): RenderRefusalResult`** (new
20
+ * export, `envelopes/render-refusal.ts`) — `isError: true`,
21
+ * `content[0].text` = `<code>: <message> <fix>`, `structuredContent`
22
+ * = `{ outcome: 'refused', refusal }` typed as **`RefusedRenderOutput`**
23
+ * (`z.infer<typeof refusedOutputSchema>`, new export), no `_meta`.
24
+ * Pure and synchronous. The four facts have one source.
25
+ *
26
+ * rr2. **Consumers**: `mcp-server-handlers`' `ggui_render` builds the
27
+ * refused result here (its local builder, inline object and
28
+ * `RenderRefusedOutput` alias are deleted — no shim); the
29
+ * reference server supplies the kit's `refusalProjector` from the
30
+ * same primitive at the kit's stringly boundary (a code off
31
+ * `RENDER_GATE_REFUSAL_CODES` → `null`; anything else parsed by
32
+ * `renderRefusalSchema`), so its six `refusal-envelope/*` rows are
33
+ * GRADED, not skipped. The kit's own hand-built reference stays as
34
+ * the second source that catches the primitive drifting.
35
+ *
36
+ * Conformance-kit verdict: no new kit entry — the six `refusal-envelope`
37
+ * cases already grade exactly these four facts; what changed is that
38
+ * two implementations now answer them through one function, and the
39
+ * reference server's exact-set assertion moved the rows from SKIPPED to
40
+ * PASSING. Bytes on the wire: unchanged.
41
+ *
42
+ * Package version — classification MADE here: MINOR for
43
+ * `@ggui-ai/protocol` (two new exports, additive) and for
44
+ * `@ggui-ai/mcp-server-handlers` (same result, one source), pre-1.0 and
45
+ * pre-launch. PROTOCOL_VERSION unchanged — no WS envelope moved.
46
+ *
47
+ * --------------------------------------------------------------------
48
+ * Authorization refusals carry JSON-RPC `data` (2026-09-05, additive,
49
+ * pre-launch, ggui#825). `@ggui-ai/mcp-server`'s per-app `authorize`
50
+ * hook refuses by throwing, and the route answered every throw with a
51
+ * bare `403 {code: -32000, message: "Forbidden"}` — correct in effect,
52
+ * illegible to a client that needs to tell "this app is no longer served" from
53
+ * "your credential is wrong".
54
+ *
55
+ * ar1. **`ErrorMapperResult.data?: JsonValue`** — a deployment's
56
+ * `errorMapper` may attach JSON-RPC 2.0 error `data` (any JSON
57
+ * value) to a mapped result; serialized verbatim on `error.data`,
58
+ * omitted when absent. Applies to every mapped error, not only
59
+ * authorization refusals.
60
+ *
61
+ * ar2. **The per-app authorization refusal consults the mapper**,
62
+ * bounded to 401 / 403: a mapper answering any other status, or
63
+ * throwing, is ignored and logged (`per_app_authorize_mapper_out_
64
+ * of_bounds` / `error_mapper_failed` on the route logger) and the
65
+ * default-deny 403 stands byte-identical to a deployment with no
66
+ * mapper. The allow path never consults the mapper.
67
+ *
68
+ * Conformance-kit verdict: no kit entry required — an optional field on
69
+ * an operator-side hook result, no MCP tool name/shape touched; the
70
+ * shape of any `data.refusal` a deployment chooses to attach is that
71
+ * deployment's declaration, not this package's.
72
+ *
73
+ * Package version — classification MADE here: MINOR for
74
+ * `@ggui-ai/mcp-server` (new optional field on `ErrorMapperResult` +
75
+ * the authorization refusal path consults `errorMapper`), pre-1.0 and
76
+ * pre-launch. PROTOCOL_VERSION unchanged — no WS envelope moved.
77
+ * --------------------------------------------------------------------
9
78
  * Authored source rides blueprint reuse (2026-08-14, additive,
10
79
  * pre-launch). Cache-reuse renders (a repeated prompt semantic-matches
11
80
  * a cached blueprint) previously committed without authored
@@ -3121,15 +3190,6 @@
3121
3190
  * reference and against the shipping projector in
3122
3191
  * `@ggui-ai/mcp-server-handlers`) and `registry-completeness`
3123
3192
  * (the registry's structural pins, bound to the LIVE registry).
3124
- *
3125
- * FOLLOWER — moves in the SAME commit as this constant, pinned by a
3126
- * gate that fails loud when it lags: the `protocol` field of every
3127
- * shipped `samples/gguis/<name>/ggui.json` (the `@ggui-ai/project-config`
3128
- * samples test). That pin is a HOUSE rule — shipped samples declare the
3129
- * CURRENT stamp, because a new project starts from them. The CONTRACT
3130
- * for any `ggui.json#protocol` is membership in
3131
- * `CLIENT_SUPPORTED_VERSIONS`, enforced by the loader (`UPGRADE_REQUIRED`
3132
- * on a non-member); the two coincide only while the set is a singleton.
3133
3193
  * r7. **Tool output shapes are protocol-owned (ggui#817 part C):**
3134
3194
  * seven schemas — search / featured / validate / consume's
3135
3195
  * host-context projection / list_sessions' summary / runtime_pull's
@@ -3146,6 +3206,44 @@
3146
3206
  * grammar and nothing else, so `{}` still reaches the gate per r5); the
3147
3207
  * full envelope (`renderInputEnvelopeSchema`) parses after the gate.
3148
3208
  * Bare model ids are out.
3209
+ * r9. **Endpoint-level refusal (ggui#825):** registry surface
3210
+ * `mcp-endpoint` (v11) and the transport envelope — a per-app MCP
3211
+ * endpoint that refuses a request for a registry state answers HTTP
3212
+ * 403 with `{ code: -32000, message: 'Forbidden', data: { refusal } }`
3213
+ * (`transportRefusalErrorSchema`; `refusal` = the projection without
3214
+ * the render-only fields, `MCP_ENDPOINT_REFUSAL_CODES` derived — today
3215
+ * `app_deprovisioned`). Untyped authorization failures keep the bare
3216
+ * 403 by contract. Additive.
3217
+ * r10. **Consume / list_sessions / emit own their wire shapes (ggui#817
3218
+ * part C2):** `consumeEventEntrySchema` (the drained row, closed),
3219
+ * `gguiSessionStatusSchema` (`active` | `expired`), `gguiConsumeOutputSchema`,
3220
+ * `gguiListSessionsOutputSchema`, `gguiEmitOutputSchema`; the types
3221
+ * derive (`ConsumeEventEntry`, `GguiConsumeOutput`, `GguiEmitOutput`,
3222
+ * `GguiListSessionsOutput`, `GguiSessionStatus`). `tools/list` now
3223
+ * advertises the entry vocabulary and the status enum for
3224
+ * `ggui_consume`; `parsePendingEnvelope` parses a drained row instead
3225
+ * of casting it, so a malformed pipe entry refuses at the seam. The
3226
+ * wire bytes of a well-formed row are unchanged. Additive.
3227
+ * r11. **Endpoint refusal codes (ggui#836):** the per-app endpoint speaks
3228
+ * §7.9 Plane-1 rows — the typed deprovisioned arm is `-32003`
3229
+ * (`APP_NOT_FOUND`, `App not found`) with `data.refusal`; untyped
3230
+ * authorization failures are `-32001` (`UNAUTHORIZED`) with no
3231
+ * `data`; HTTP 403 on both. `-32000` (the SDK client's
3232
+ * `ConnectionClosed`) is never a code a first-party server chooses.
3233
+ * Supersedes r9's literals; pre-launch, no compatibility arm.
3234
+ * r12. **`GENERATION_OVERLOADED: -32014`** joins `PLATFORM_ERROR_CODES` —
3235
+ * the generation queue is saturated (HTTP 503 + `Retry-After`; the
3236
+ * server is the limit, unlike `-32013`). Additive; the four complete
3237
+ * mirrors carry it under `check-error-code-mirrors`.
3238
+ *
3239
+ * FOLLOWER — moves in the SAME commit as this constant, pinned by a
3240
+ * gate that fails loud when it lags: the `protocol` field of every
3241
+ * shipped `samples/gguis/<name>/ggui.json` (the `@ggui-ai/project-config`
3242
+ * samples test). That pin is a HOUSE rule — shipped samples declare the
3243
+ * CURRENT stamp, because a new project starts from them. The CONTRACT
3244
+ * for any `ggui.json#protocol` is membership in
3245
+ * `CLIENT_SUPPORTED_VERSIONS`, enforced by the loader (`UPGRADE_REQUIRED`
3246
+ * on a non-member); the two coincide only while the set is a singleton.
3149
3247
  */
3150
3248
  export const PROTOCOL_VERSION = "draft-2026-09-04";
3151
3249
  /**
@@ -3163,8 +3261,32 @@ export const PROTOCOL_VERSION = "draft-2026-09-04";
3163
3261
  * `package.json#version` (the same parity pattern as
3164
3262
  * `STDLIB_GADGETS_VERSION` and `agent-server`'s `CLIENT_INFO`), and the
3165
3263
  * `/release:cut` straggler list names it so the bump is mechanical.
3264
+ *
3265
+ * Wave classifications (protocol seat; the kit is the arbiter,
3266
+ * docs/protocol/VERSION-POLICY.md §1–2):
3267
+ *
3268
+ * - **0.15.0 — MINOR** (ruled 2026-09-05). Every `@ggui-ai/protocol`
3269
+ * landing since the 0.14.0 cut (`f3cf6c906`) is additive under
3270
+ * §1.2: the `@ggui-ai/protocol/wire` browser entry (ggui#819), the
3271
+ * `GENERATION_OVERLOADED: -32014` canonical code and SPEC §7.9's
3272
+ * Plane 0 (ggui#840), `ErrorMapperResult.data` (ggui#825), the
3273
+ * endpoint-level refusal — `403 {code: -32003, data.refusal}` for
3274
+ * `app_deprovisioned` (ggui#836), the `ggui_consume` /
3275
+ * `ggui_list_sessions` / `ggui_emit` output schemas (ggui#817 C2),
3276
+ * and the `.readonly()` removal from the gadget wire schema
3277
+ * (ggui#824). The one non-additive-looking line — the untyped
3278
+ * authorization refusal moving from `-32000` to `-32001
3279
+ * UNAUTHORIZED` (ggui#836) — is not a fixture regression: no
3280
+ * fixture on 0.14.0 pinned `-32000` (it was the SDK's default
3281
+ * courtesy code, never a first-party choice; ggui#840's Plane-0
3282
+ * ruling), and the transport-refusal catalog now states `-32001`.
3283
+ * §1.4 (`draft-`: semver describes intent) applies on top. A
3284
+ * 0.14.1 is legitimate ONLY as a founder-ruled hotfix branch off
3285
+ * `f3cf6c906` carrying ggui#846 alone (a declaration-emit fix —
3286
+ * PATCH under §1.3); it cannot be cut from main, whose delta since
3287
+ * 0.14.0 is minor-class.
3166
3288
  */
3167
- export const GGUI_WAVE_VERSION = "0.14.0";
3289
+ export const GGUI_WAVE_VERSION = "0.15.0";
3168
3290
  /**
3169
3291
  * Schema version stamped onto wire envelopes that opt into the
3170
3292
  * `schemaVersion` forward-compat field (see {@link ActionEnvelope},
package/dist/wire.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `@ggui-ai/protocol/wire` — the browser entry (ggui#819).
3
+ *
4
+ * What a renderer running inside an iframe validates and types against:
5
+ * the contract's shapes and their inference, the live-channel frames, the
6
+ * action envelope, the host-context projection, the reserved-channel
7
+ * guard, the interface-context snapshot, the invoke event, the permission
8
+ * grammar and the two limits the runtime shares with the server. Nothing
9
+ * a SERVER registers or validates — no tool input/output schema, no ops
10
+ * tool, no LLM route table, no contract zod schema — is reachable from
11
+ * here at runtime: a bundler cannot drop a module whose top level builds
12
+ * zod schemas, so the iframe pays for every module its entry reaches
13
+ * (`wire.test.ts` walks the graph and pins that). The root barrel keeps
14
+ * every name; this entry is the same names, fewer modules.
15
+ */
16
+ export * from './types/contract-inference.js';
17
+ export * from './types/data-contract.js';
18
+ export * from './types/live-channel.js';
19
+ export * from './types/render.js';
20
+ export * from './types/invoke.js';
21
+ export * from './types/events.js';
22
+ export * from './types/ggui-session-event.js';
23
+ export * from './types/host-context.js';
24
+ export * from './types/interface-context.js';
25
+ export * from './validation/contract-validator.js';
26
+ export * from './validation/reserved-channels.js';
27
+ export * from './validation/hygiene-rules.js';
28
+ export * from './errors/unknown-permission-name.js';
29
+ export * from './envelopes/builders.js';
30
+ export * from './schemas/invoke.js';
31
+ export * from './schemas/interface-context.js';
32
+ export * from './schemas/runtime-telemetry-limits.js';
33
+ export * from './schemas/public-env-key.js';
34
+ export * from './version.js';
35
+ export * from './schemas/data-contract.js';
36
+ export * from './types/gadget.js';
37
+ export * from './gadgets/stdlib-gadgets.js';
38
+ export * from './gadgets/resolve-contract-gadgets.js';
39
+ export * from './iframe-bridge.js';
40
+ export type { ValidateFunction } from './validation/ajv-runtime.js';
41
+ export type { AppTheme } from './schemas/app-theme.js';
42
+ export type { AppDisplayConfig } from './types/app-config.js';
43
+ export type { EndUserIdentity } from './types/auth.js';
44
+ export type { GguiRuntimePullInput, GguiConsumeOutput, ConsumeEventEntry, GguiEmitOutput, GguiSessionStatus, } from './types/mcp.js';
45
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAI1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AAGnD,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
package/dist/wire.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * `@ggui-ai/protocol/wire` — the browser entry (ggui#819).
3
+ *
4
+ * What a renderer running inside an iframe validates and types against:
5
+ * the contract's shapes and their inference, the live-channel frames, the
6
+ * action envelope, the host-context projection, the reserved-channel
7
+ * guard, the interface-context snapshot, the invoke event, the permission
8
+ * grammar and the two limits the runtime shares with the server. Nothing
9
+ * a SERVER registers or validates — no tool input/output schema, no ops
10
+ * tool, no LLM route table, no contract zod schema — is reachable from
11
+ * here at runtime: a bundler cannot drop a module whose top level builds
12
+ * zod schemas, so the iframe pays for every module its entry reaches
13
+ * (`wire.test.ts` walks the graph and pins that). The root barrel keeps
14
+ * every name; this entry is the same names, fewer modules.
15
+ */
16
+ export * from './types/contract-inference.js';
17
+ export * from './types/data-contract.js';
18
+ export * from './types/live-channel.js';
19
+ export * from './types/render.js';
20
+ export * from './types/invoke.js';
21
+ export * from './types/events.js';
22
+ export * from './types/ggui-session-event.js';
23
+ export * from './types/host-context.js';
24
+ export * from './types/interface-context.js';
25
+ export * from './validation/contract-validator.js';
26
+ export * from './validation/reserved-channels.js';
27
+ export * from './validation/hygiene-rules.js';
28
+ export * from './errors/unknown-permission-name.js';
29
+ export * from './envelopes/builders.js';
30
+ export * from './schemas/invoke.js';
31
+ export * from './schemas/interface-context.js';
32
+ export * from './schemas/runtime-telemetry-limits.js';
33
+ export * from './schemas/public-env-key.js';
34
+ export * from './version.js';
35
+ // The gadget family: the stdlib hooks bundled into the iframe validate a
36
+ // descriptor draft at runtime (`createGguiGadget`), so the contract-schema
37
+ // module comes along — it is what the browser validates there.
38
+ export * from './schemas/data-contract.js';
39
+ export * from './types/gadget.js';
40
+ export * from './gadgets/stdlib-gadgets.js';
41
+ export * from './gadgets/resolve-contract-gadgets.js';
42
+ // The iframe bridge vocabulary (`BRIDGE_EVENTS`) — what the RN WebView bridge
43
+ // and the web runtime agree on; browser data, not a tool schema.
44
+ export * from './iframe-bridge.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ggui-ai/protocol",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "sideEffects": [
5
5
  "./dist/schemas/sync-check.js",
6
6
  "./dist/validation/ajv-runtime.js"
@@ -78,6 +78,12 @@
78
78
  "require": "./dist/integrations/theme-binding.js",
79
79
  "default": "./dist/integrations/theme-binding.js"
80
80
  },
81
+ "./wire": {
82
+ "types": "./dist/wire.d.ts",
83
+ "import": "./dist/wire.js",
84
+ "require": "./dist/wire.js",
85
+ "default": "./dist/wire.js"
86
+ },
81
87
  "./version": {
82
88
  "types": "./dist/version.d.ts",
83
89
  "import": "./dist/version.js",