@ggui-ai/protocol 0.14.0 → 0.16.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 (112) hide show
  1. package/dist/envelopes/render-refusal.d.ts +49 -0
  2. package/dist/envelopes/render-refusal.d.ts.map +1 -0
  3. package/dist/envelopes/render-refusal.js +12 -0
  4. package/dist/errors/domain-error.d.ts +70 -0
  5. package/dist/errors/domain-error.d.ts.map +1 -0
  6. package/dist/errors/domain-error.js +118 -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 +69 -63
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +8 -2
  13. package/dist/integrations/mcp-apps.d.ts +35 -9
  14. package/dist/integrations/mcp-apps.d.ts.map +1 -1
  15. package/dist/integrations/mcp-apps.js +13 -13
  16. package/dist/integrations/overlay-hash.d.ts +19 -0
  17. package/dist/integrations/overlay-hash.d.ts.map +1 -0
  18. package/dist/integrations/overlay-hash.js +29 -0
  19. package/dist/integrations/theme-binding.d.ts +14 -12
  20. package/dist/integrations/theme-binding.d.ts.map +1 -1
  21. package/dist/integrations/theme-binding.js +10 -6
  22. package/dist/registry/blueprint-key.d.ts.map +1 -1
  23. package/dist/registry/blueprint-key.js +4 -3
  24. package/dist/schemas/app-theme.d.ts +46 -10
  25. package/dist/schemas/app-theme.d.ts.map +1 -1
  26. package/dist/schemas/app-theme.js +108 -40
  27. package/dist/schemas/blueprint.d.ts +4 -3
  28. package/dist/schemas/blueprint.d.ts.map +1 -1
  29. package/dist/schemas/blueprint.js +15 -3
  30. package/dist/schemas/data-contract.d.ts +11 -31
  31. package/dist/schemas/data-contract.d.ts.map +1 -1
  32. package/dist/schemas/data-contract.js +5 -28
  33. package/dist/schemas/handshake-suggestion.d.ts.map +1 -1
  34. package/dist/schemas/handshake-suggestion.js +8 -1
  35. package/dist/schemas/interface-context.d.ts +44 -0
  36. package/dist/schemas/interface-context.d.ts.map +1 -0
  37. package/dist/schemas/interface-context.js +22 -0
  38. package/dist/schemas/invoke.d.ts +3 -3
  39. package/dist/schemas/invoke.js +1 -1
  40. package/dist/schemas/mcp.d.ts +246 -111
  41. package/dist/schemas/mcp.d.ts.map +1 -1
  42. package/dist/schemas/mcp.js +149 -42
  43. package/dist/schemas/ops-blueprint.d.ts +4 -4
  44. package/dist/schemas/ops-blueprint.d.ts.map +1 -1
  45. package/dist/schemas/ops-blueprint.js +13 -8
  46. package/dist/schemas/public-env-key.d.ts +26 -0
  47. package/dist/schemas/public-env-key.d.ts.map +1 -0
  48. package/dist/schemas/public-env-key.js +25 -0
  49. package/dist/schemas/render-input-envelope.d.ts +2 -2
  50. package/dist/schemas/render-input-envelope.js +1 -1
  51. package/dist/schemas/runtime-telemetry-limits.d.ts +11 -0
  52. package/dist/schemas/runtime-telemetry-limits.d.ts.map +1 -0
  53. package/dist/schemas/runtime-telemetry-limits.js +10 -0
  54. package/dist/transport/websocket.d.ts +5 -5
  55. package/dist/types/auth.d.ts +1 -1
  56. package/dist/types/blueprint-source.d.ts +27 -7
  57. package/dist/types/blueprint-source.d.ts.map +1 -1
  58. package/dist/types/blueprint-source.js +19 -3
  59. package/dist/types/blueprint.d.ts +2 -2
  60. package/dist/types/blueprint.d.ts.map +1 -1
  61. package/dist/types/contract-inference.d.ts +1 -1
  62. package/dist/types/data-contract.d.ts +3 -3
  63. package/dist/types/domain-error-codes.d.ts +167 -0
  64. package/dist/types/domain-error-codes.d.ts.map +1 -0
  65. package/dist/types/domain-error-codes.js +170 -0
  66. package/dist/types/events.d.ts +1 -1
  67. package/dist/types/ggui-session-event.d.ts +2 -2
  68. package/dist/types/handshake-suggestion.d.ts +2 -2
  69. package/dist/types/host-context.d.ts +3 -3
  70. package/dist/types/interface-context.d.ts +1 -1
  71. package/dist/types/invoke.d.ts +1 -1
  72. package/dist/types/lifecycle.d.ts +1 -1
  73. package/dist/types/live-channel.d.ts +3 -3
  74. package/dist/types/llm-route.d.ts +59 -2
  75. package/dist/types/llm-route.d.ts.map +1 -1
  76. package/dist/types/llm-route.js +62 -16
  77. package/dist/types/llm.d.ts +22 -2
  78. package/dist/types/llm.d.ts.map +1 -1
  79. package/dist/types/llm.js +29 -2
  80. package/dist/types/mcp.d.ts +49 -100
  81. package/dist/types/mcp.d.ts.map +1 -1
  82. package/dist/types/mcp.js +28 -9
  83. package/dist/types/refusal-codes.d.ts +54 -95
  84. package/dist/types/refusal-codes.d.ts.map +1 -1
  85. package/dist/types/refusal-codes.js +67 -105
  86. package/dist/types/render.d.ts +12 -11
  87. package/dist/types/render.d.ts.map +1 -1
  88. package/dist/types/ui-generator.d.ts +1 -1
  89. package/dist/validation/ajv-runtime.d.ts +2 -2
  90. package/dist/validation/contract-validator.d.ts +14 -8
  91. package/dist/validation/contract-validator.d.ts.map +1 -1
  92. package/dist/validation/contract-validator.js +12 -4
  93. package/dist/validation/cross-references.d.ts +2 -2
  94. package/dist/validation/hygiene-rules.d.ts +1 -1
  95. package/dist/validation/lint-contract.d.ts +2 -2
  96. package/dist/validation/lint-contract.d.ts.map +1 -1
  97. package/dist/validation/lint-contract.js +6 -4
  98. package/dist/validation/name-invariants.d.ts +2 -2
  99. package/dist/validation/reserved-channels.d.ts +1 -1
  100. package/dist/validation/schema-compat-invariants.d.ts +2 -2
  101. package/dist/validation/schema-meta-validation.d.ts +1 -1
  102. package/dist/validation/schema-subset.d.ts +3 -3
  103. package/dist/version.d.ts +485 -12
  104. package/dist/version.d.ts.map +1 -1
  105. package/dist/version.js +484 -11
  106. package/dist/wire.d.ts +45 -0
  107. package/dist/wire.d.ts.map +1 -0
  108. package/dist/wire.js +44 -0
  109. package/package.json +7 -1
  110. package/dist/envelope-adapters.d.ts +0 -25
  111. package/dist/envelope-adapters.d.ts.map +0 -1
  112. package/dist/envelope-adapters.js +0 -14
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * - `llm` — engine-generated. `generator` is the slug of the
13
13
  * {@link UiGenerator} that produced the component code; `model` is
14
- * the LLM model id the engine called. Both REQUIRED: every
14
+ * the route the engine called, as a `ModelRef`. Both REQUIRED: every
15
15
  * generation mint site has them in scope, and an engine-generated
16
16
  * artifact without them is not a real state.
17
17
  * - `user` — developer-registered / hand-authored. Covers
@@ -31,8 +31,21 @@
31
31
  * rows are dropped at the trust boundary, never coerced.
32
32
  */
33
33
  import { isRecord } from "../validation/is-record.js";
34
+ import { isModelRef } from "./llm-route.js";
34
35
  /** Closed list of `BlueprintSource` discriminants. */
35
36
  export const BLUEPRINT_SOURCE_KINDS = ["llm", "user", "curated"];
37
+ /**
38
+ * The de-modeled generator identity (ggui#924): `ui-gen-` + ONE tier token
39
+ * — `ui-gen-default`, `ui-gen-advanced`, or an operator-defined tier. No
40
+ * model segment: the model is its own field, so a model retirement never
41
+ * renames an identity or re-keys a stored record. The template admits any
42
+ * `ui-gen-*` at the type level; {@link isGeneratorId} is the grammar.
43
+ */
44
+ export const GENERATOR_ID_PATTERN = /^ui-gen-[a-z0-9]+$/;
45
+ /** Whether `value` is a generator identity: one tier token, no model segment. */
46
+ export function isGeneratorId(value) {
47
+ return GENERATOR_ID_PATTERN.test(value);
48
+ }
36
49
  /**
37
50
  * Validating narrower for trust boundaries (DB row → union, JSON
38
51
  * artifact → union). Returns a CANONICAL rebuild of the union value —
@@ -50,9 +63,12 @@ export function parseBlueprintSource(value) {
50
63
  case "llm": {
51
64
  const generator = v["generator"];
52
65
  const model = v["model"];
53
- if (typeof generator !== "string" || generator.length === 0)
66
+ // ggui#924: a modeled identity (`ui-gen-default-haiku-4-5`) or a
67
+ // non-route model (a bare `claude-…`, a dated API name) is not a
68
+ // provenance — null.
69
+ if (typeof generator !== "string" || !isGeneratorId(generator))
54
70
  return null;
55
- if (typeof model !== "string" || model.length === 0)
71
+ if (typeof model !== "string" || !isModelRef(model))
56
72
  return null;
57
73
  return { kind: "llm", generator, model };
58
74
  }
@@ -18,7 +18,7 @@
18
18
  * advanced-generator iterative-loop output routinely exceeds
19
19
  * them). The in-memory adapter skips the body store (in-process
20
20
  * `Map<codeHash, string>`).
21
- * - **Tenancy.** Scoped per `(appId, contractHash)`. Different apps'
21
+ * - **App scope.** Scoped per `(appId, contractHash)`. Different apps'
22
22
  * contract may coincidentally hash the same; their blueprints
23
23
  * must never cross-pollinate. Rows are keyed by `blueprintId`;
24
24
  * lookups go through an indexed `(appId, contractHash)` query.
@@ -127,7 +127,7 @@ export interface Blueprint {
127
127
  * key.
128
128
  */
129
129
  readonly contractHash: string;
130
- /** Tenancy scope. Composite secondary key with `contractHash`. */
130
+ /** App scope. Composite secondary key with `contractHash`. */
131
131
  readonly appId: string;
132
132
  /**
133
133
  * S3 URL (`s3://<bucket>/<key>`) of the generated code body when
@@ -1 +1 @@
1
- {"version":3,"file":"blueprint.d.ts","sourceRoot":"","sources":["../../src/types/blueprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,sBAAsB;IACrC;;qDAEiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;0CACsC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;yCACqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;yCACqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACvC;8CAC0C;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAA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IAC5B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,mEAAmE;IACnE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC;;;;;;;;;OASG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC;IAClC,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,UAAU,CAAC;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChD"}
@@ -1,4 +1,4 @@
1
- import type { DataContract, JsonObject, JsonSchemaTypeName, JsonValue } from './data-contract';
1
+ import type { DataContract, JsonObject, JsonSchemaTypeName, JsonValue } from './data-contract.js';
2
2
  /**
3
3
  * Extract the JSON Schema `required` array from a schema literal as a
4
4
  * string union. Resolves to `never` when `required` is absent, empty,
@@ -188,7 +188,7 @@ export interface StreamChannelEntry {
188
188
  * `CTR_SCHEMA_INCOMPAT` linter additionally checks that the feed
189
189
  * tool's declared return schema is a subset of this schema — see
190
190
  * the docstring on {@link ActionEntry.schema} for the schema-subset
191
- * algorithm and the `SCHEMA_MISMATCH_ERROR` failure surface.
191
+ * algorithm and the `schema_mismatch_error` failure surface.
192
192
  */
193
193
  schema: JsonSchema;
194
194
  /** Example payload (used for documentation and smoke testing). Typed as {@link JsonValue}. */
@@ -276,7 +276,7 @@ export interface ActionEntry {
276
276
  * advisory — the agent owns the actual tool call on its next turn
277
277
  * and is responsible for shaping the payload as the tool expects.
278
278
  * For tools registered on THIS server, the F4 schema-compat checker
279
- * surfaces a `SCHEMA_MISMATCH_ERROR` at render-time / blueprint-
279
+ * surfaces a `schema_mismatch_error` at render-time / blueprint-
280
280
  * registration-time so authors get fail-loud feedback.
281
281
  *
282
282
  * The canonical algorithm lives in
@@ -610,7 +610,7 @@ export interface GadgetDescriptor {
610
610
  package: string;
611
611
  /**
612
612
  * ggui-hosted bundle URL — the preferred distribution path. Same
613
- * origin as the iframe in single-tenant OSS deployments (served
613
+ * origin as the iframe in single-deployment installs (served
614
614
  * from `/_ggui/libs/<libId>/bundle.js`) and the ggui marketplace
615
615
  * CDN in cloud deployments. CSP `script-src` allowlists only the
616
616
  * ggui origin — no per-plugin third-party origins.
@@ -0,0 +1,167 @@
1
+ /**
2
+ * The Plane-2 registry — the ONLY list of domain-error slugs (ggui#880).
3
+ *
4
+ * SPEC §7.9 Plane 2: a recoverable, contract-level failure the caller can
5
+ * fix — a missing session or handshake, props that do not satisfy the
6
+ * contract, an undeclared channel. The MCP SDK ships a thrown handler error
7
+ * to the agent as `{content: [{type: 'text', text: error.message}],
8
+ * isError: true}` and nothing else, so the slug travels as the LEADING
9
+ * token of that text — `<code>: <detail>` — composed by the `DomainError`
10
+ * base in `../errors/domain-error` from a code in this registry. A reader
11
+ * branches on `text.startsWith(code + ': ')` for a registered code and on
12
+ * nothing else.
13
+ *
14
+ * Same posture as the refusal registry in `./refusal-codes`: `code === key`
15
+ * is forced at the definer, the code type is derived from the keys, and
16
+ * the two registries are disjoint (pinned) — one code names one plane.
17
+ */
18
+ /**
19
+ * How a caller recovers from a Plane-2 failure.
20
+ *
21
+ * - `retry-same-id` — fix the input and retry on the SAME handshakeId /
22
+ * sessionId; nothing was consumed.
23
+ * - `re-mint` — the id itself is gone (unknown, consumed, expired,
24
+ * another app's); mint a fresh one (`ggui_handshake`, then `ggui_render`).
25
+ * - `later` — a dependency the server fetches was unavailable; time
26
+ * restores it, the input was fine.
27
+ */
28
+ export declare const DOMAIN_ERROR_RECOVERIES: readonly ["retry-same-id", "re-mint", "later"];
29
+ /** One member of {@link DOMAIN_ERROR_RECOVERIES}. */
30
+ export type DomainErrorRecovery = (typeof DOMAIN_ERROR_RECOVERIES)[number];
31
+ /**
32
+ * A data-plane `tools/call` name a Plane-2 slug may be emitted on. The
33
+ * template admits any `ggui_*` name at the type level; the registry's own
34
+ * suite narrows every row's `tools` to the data-plane set (no `ggui_ops_*`,
35
+ * no `ggui_protocol_*`).
36
+ */
37
+ export type DataPlaneToolName = `ggui_${string}`;
38
+ /**
39
+ * The registry with its per-key literal types kept (ggui#889):
40
+ * `DOMAIN_ERROR_ROWS.session_not_found.code` is `'session_not_found'`,
41
+ * its `recovery` is `'re-mint'`. {@link DOMAIN_ERROR_REGISTRY} is the
42
+ * same object read through the normalized row type.
43
+ */
44
+ export declare const DOMAIN_ERROR_ROWS: {
45
+ readonly session_not_found: {
46
+ readonly code: "session_not_found";
47
+ readonly tools: readonly ["ggui_consume", "ggui_get_session", "ggui_get_render_source", "ggui_update", "ggui_amend", "ggui_emit", "ggui_runtime_pull"];
48
+ readonly recovery: "re-mint";
49
+ readonly emitter: "the session lookup on every session-scoped tool";
50
+ readonly description: "The sessionId names no session this caller can reach — never minted, expired, closed, or owned by another app (cross-app access surfaces uniformly). Re-handshake and re-render to mint a fresh one.";
51
+ };
52
+ readonly handshake_not_found: {
53
+ readonly code: "handshake_not_found";
54
+ readonly tools: readonly ["ggui_render"];
55
+ readonly recovery: "re-mint";
56
+ readonly emitter: "the handshake-record lookup at ggui_render";
57
+ readonly description: "The handshakeId is unknown, already consumed by a render, or expired. Call ggui_handshake again for a fresh id, then render with the new pair.";
58
+ };
59
+ readonly contract_violation: {
60
+ readonly code: "contract_violation";
61
+ readonly tools: readonly ["ggui_render", "ggui_update", "ggui_amend", "ggui_emit"];
62
+ readonly recovery: "retry-same-id";
63
+ readonly emitter: "the props / payload validator against the contract";
64
+ readonly description: "Props or a payload do not satisfy the contract's spec — a missing required prop included. Fix the values and retry with the same id; nothing was consumed.";
65
+ };
66
+ readonly schema_mismatch_error: {
67
+ readonly code: "schema_mismatch_error";
68
+ readonly tools: readonly ["ggui_render"];
69
+ readonly recovery: "retry-same-id";
70
+ readonly emitter: "the schema-compatibility check between the contract and the registered tool shapes";
71
+ readonly description: "An actionSpec or streamSpec schema is not a subset of the named tool's registered shape. Adjust the contract or the tool, then retry with the same handshakeId.";
72
+ };
73
+ readonly contract_validation_failed: {
74
+ readonly code: "contract_validation_failed";
75
+ readonly tools: readonly ["ggui_render"];
76
+ readonly recovery: "retry-same-id";
77
+ readonly emitter: "the contract lint gate (shape, retired fields, schema metadata, cross-references, schema compatibility)";
78
+ readonly description: "The contract failed the lint gate; the detail names the category and the finding. Fix the contract and retry with the same handshakeId.";
79
+ };
80
+ readonly override_contract_invalid: {
81
+ readonly code: "override_contract_invalid";
82
+ readonly tools: readonly ["ggui_render"];
83
+ readonly recovery: "retry-same-id";
84
+ readonly emitter: "the override gate at ggui_render";
85
+ readonly description: "override.contract failed validation — an override commits the caller to a conforming contract. Drop the override and render the suggestion, or fix the draft.";
86
+ };
87
+ readonly channel_not_declared: {
88
+ readonly code: "channel_not_declared";
89
+ readonly tools: readonly ["ggui_emit"];
90
+ readonly recovery: "retry-same-id";
91
+ readonly emitter: "ggui_emit's channel check against the contract's streamSpec";
92
+ readonly description: "The channel is not declared by the session's contract. Emit on a declared channel; the detail lists them.";
93
+ };
94
+ readonly invalid_complete: {
95
+ readonly code: "invalid_complete";
96
+ readonly tools: readonly ["ggui_emit"];
97
+ readonly recovery: "retry-same-id";
98
+ readonly emitter: "ggui_emit's completion check";
99
+ readonly description: "A completion was signalled for a channel that cannot complete in its current state. Emit on the channel first, or omit the completion.";
100
+ };
101
+ readonly gadget_not_registered: {
102
+ readonly code: "gadget_not_registered";
103
+ readonly tools: readonly ["ggui_render"];
104
+ readonly recovery: "retry-same-id";
105
+ readonly emitter: "the gadget gate at ggui_render";
106
+ readonly description: "A clientCapabilities.gadgets reference names an export the app's gadget registry does not carry. Drop the reference or fix the name; the detail suggests the nearest match.";
107
+ };
108
+ readonly gadget_package_mismatch: {
109
+ readonly code: "gadget_package_mismatch";
110
+ readonly tools: readonly ["ggui_render"];
111
+ readonly recovery: "retry-same-id";
112
+ readonly emitter: "the gadget gate at ggui_render";
113
+ readonly description: "A gadget export is registered, but only under a different package than the contract requested. Request the registered package; the detail names it.";
114
+ };
115
+ readonly gadget_public_env_missing: {
116
+ readonly code: "gadget_public_env_missing";
117
+ readonly tools: readonly ["ggui_render"];
118
+ readonly recovery: "retry-same-id";
119
+ readonly emitter: "the gadget gate at ggui_render";
120
+ readonly description: "A registered wrapper requires a public-env key the app has not set. Set the key on the app's public env, then retry.";
121
+ };
122
+ readonly duplicate_gadget_hook: {
123
+ readonly code: "duplicate_gadget_hook";
124
+ readonly tools: readonly ["ggui_render"];
125
+ readonly recovery: "retry-same-id";
126
+ readonly emitter: "the gadget gate at ggui_render";
127
+ readonly description: "Two gadget packages export the same name; the generated import would collide. Reference one of them.";
128
+ };
129
+ readonly gadget_types_fetch_failed: {
130
+ readonly code: "gadget_types_fetch_failed";
131
+ readonly tools: readonly ["ggui_render"];
132
+ readonly recovery: "later";
133
+ readonly emitter: "the gadget type fetch before cold generation";
134
+ readonly description: "Fetching a gadget package's types failed; the input was fine. Retry after a short delay.";
135
+ };
136
+ readonly gadget_catalog_integrity: {
137
+ readonly code: "gadget_catalog_integrity";
138
+ readonly tools: readonly ["ggui_render"];
139
+ readonly recovery: "retry-same-id";
140
+ readonly emitter: "the app's gadget catalog resolver at ggui_render";
141
+ readonly description: "The app's gadget catalog is inconsistent with its registrations. Repair the catalog, then retry with the same handshakeId.";
142
+ };
143
+ readonly blueprint_rejected: {
144
+ readonly code: "blueprint_rejected";
145
+ readonly tools: readonly ["ggui_render"];
146
+ readonly recovery: "retry-same-id";
147
+ readonly emitter: "the blueprint registry on registration";
148
+ readonly description: "The blueprint was rejected by the registry's error-level findings; the detail lists them. Fix the contract and retry with the same handshakeId.";
149
+ };
150
+ };
151
+ /** A domain-error code = a registry key. Derived; never a second list. */
152
+ export type DomainErrorCode = keyof typeof DOMAIN_ERROR_ROWS;
153
+ /** A registry row, as consumers read it. */
154
+ export interface DomainErrorRow {
155
+ readonly code: DomainErrorCode;
156
+ readonly tools: readonly DataPlaneToolName[];
157
+ readonly recovery: DomainErrorRecovery;
158
+ readonly emitter: string;
159
+ readonly description: string;
160
+ }
161
+ /** The registry consumers read. */
162
+ export declare const DOMAIN_ERROR_REGISTRY: Readonly<Record<DomainErrorCode, DomainErrorRow>>;
163
+ /** Whether `value` is a registered domain-error code. */
164
+ export declare function isDomainErrorCode(value: string): value is DomainErrorCode;
165
+ /** Every registered code, in registry order. */
166
+ export declare const DOMAIN_ERROR_CODES: readonly DomainErrorCode[];
167
+ //# sourceMappingURL=domain-error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-error-codes.d.ts","sourceRoot":"","sources":["../../src/types/domain-error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,gDAAiD,CAAC;AAEtF,qDAAqD;AACrD,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,MAAM,EAAE,CAAC;AAyBjD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsI5B,CAAC;AAEH,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAE7D,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,mCAAmC;AACnC,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,cAAc,CAAC,CACjE,CAAC;AAEpB,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,eAAe,CAEzE;AAED,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EACC,CAAC"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * The Plane-2 registry — the ONLY list of domain-error slugs (ggui#880).
3
+ *
4
+ * SPEC §7.9 Plane 2: a recoverable, contract-level failure the caller can
5
+ * fix — a missing session or handshake, props that do not satisfy the
6
+ * contract, an undeclared channel. The MCP SDK ships a thrown handler error
7
+ * to the agent as `{content: [{type: 'text', text: error.message}],
8
+ * isError: true}` and nothing else, so the slug travels as the LEADING
9
+ * token of that text — `<code>: <detail>` — composed by the `DomainError`
10
+ * base in `../errors/domain-error` from a code in this registry. A reader
11
+ * branches on `text.startsWith(code + ': ')` for a registered code and on
12
+ * nothing else.
13
+ *
14
+ * Same posture as the refusal registry in `./refusal-codes`: `code === key`
15
+ * is forced at the definer, the code type is derived from the keys, and
16
+ * the two registries are disjoint (pinned) — one code names one plane.
17
+ */
18
+ /**
19
+ * How a caller recovers from a Plane-2 failure.
20
+ *
21
+ * - `retry-same-id` — fix the input and retry on the SAME handshakeId /
22
+ * sessionId; nothing was consumed.
23
+ * - `re-mint` — the id itself is gone (unknown, consumed, expired,
24
+ * another app's); mint a fresh one (`ggui_handshake`, then `ggui_render`).
25
+ * - `later` — a dependency the server fetches was unavailable; time
26
+ * restores it, the input was fine.
27
+ */
28
+ export const DOMAIN_ERROR_RECOVERIES = ['retry-same-id', 're-mint', 'later'];
29
+ /**
30
+ * The registry is the ONLY list of domain-error codes: {@link DomainErrorCode}
31
+ * is derived from the keys below, and this definer forces every row's
32
+ * `code` to equal its key at the type level.
33
+ */
34
+ function defineDomainErrorRegistry(rows) {
35
+ return rows;
36
+ }
37
+ /**
38
+ * The registry with its per-key literal types kept (ggui#889):
39
+ * `DOMAIN_ERROR_ROWS.session_not_found.code` is `'session_not_found'`,
40
+ * its `recovery` is `'re-mint'`. {@link DOMAIN_ERROR_REGISTRY} is the
41
+ * same object read through the normalized row type.
42
+ */
43
+ export const DOMAIN_ERROR_ROWS = /* @__PURE__ */ defineDomainErrorRegistry({
44
+ // ── identity ──────────────────────────────────────────────────────
45
+ session_not_found: {
46
+ code: 'session_not_found',
47
+ tools: [
48
+ 'ggui_consume',
49
+ 'ggui_get_session',
50
+ 'ggui_get_render_source',
51
+ 'ggui_update',
52
+ 'ggui_amend',
53
+ 'ggui_emit',
54
+ 'ggui_runtime_pull',
55
+ ],
56
+ recovery: 're-mint',
57
+ emitter: 'the session lookup on every session-scoped tool',
58
+ description: 'The sessionId names no session this caller can reach — never minted, expired, closed, or owned by another app (cross-app access surfaces uniformly). Re-handshake and re-render to mint a fresh one.',
59
+ },
60
+ handshake_not_found: {
61
+ code: 'handshake_not_found',
62
+ tools: ['ggui_render'],
63
+ recovery: 're-mint',
64
+ emitter: 'the handshake-record lookup at ggui_render',
65
+ description: 'The handshakeId is unknown, already consumed by a render, or expired. Call ggui_handshake again for a fresh id, then render with the new pair.',
66
+ },
67
+ // ── the contract gate ─────────────────────────────────────────────
68
+ contract_violation: {
69
+ code: 'contract_violation',
70
+ tools: ['ggui_render', 'ggui_update', 'ggui_amend', 'ggui_emit'],
71
+ recovery: 'retry-same-id',
72
+ emitter: 'the props / payload validator against the contract',
73
+ description: "Props or a payload do not satisfy the contract's spec — a missing required prop included. Fix the values and retry with the same id; nothing was consumed.",
74
+ },
75
+ schema_mismatch_error: {
76
+ code: 'schema_mismatch_error',
77
+ tools: ['ggui_render'],
78
+ recovery: 'retry-same-id',
79
+ emitter: 'the schema-compatibility check between the contract and the registered tool shapes',
80
+ description: "An actionSpec or streamSpec schema is not a subset of the named tool's registered shape. Adjust the contract or the tool, then retry with the same handshakeId.",
81
+ },
82
+ contract_validation_failed: {
83
+ code: 'contract_validation_failed',
84
+ tools: ['ggui_render'],
85
+ recovery: 'retry-same-id',
86
+ emitter: 'the contract lint gate (shape, retired fields, schema metadata, cross-references, schema compatibility)',
87
+ description: 'The contract failed the lint gate; the detail names the category and the finding. Fix the contract and retry with the same handshakeId.',
88
+ },
89
+ override_contract_invalid: {
90
+ code: 'override_contract_invalid',
91
+ tools: ['ggui_render'],
92
+ recovery: 'retry-same-id',
93
+ emitter: 'the override gate at ggui_render',
94
+ description: 'override.contract failed validation — an override commits the caller to a conforming contract. Drop the override and render the suggestion, or fix the draft.',
95
+ },
96
+ // ── the live channel ──────────────────────────────────────────────
97
+ channel_not_declared: {
98
+ code: 'channel_not_declared',
99
+ tools: ['ggui_emit'],
100
+ recovery: 'retry-same-id',
101
+ emitter: "ggui_emit's channel check against the contract's streamSpec",
102
+ description: "The channel is not declared by the session's contract. Emit on a declared channel; the detail lists them.",
103
+ },
104
+ invalid_complete: {
105
+ code: 'invalid_complete',
106
+ tools: ['ggui_emit'],
107
+ recovery: 'retry-same-id',
108
+ emitter: "ggui_emit's completion check",
109
+ description: 'A completion was signalled for a channel that cannot complete in its current state. Emit on the channel first, or omit the completion.',
110
+ },
111
+ // ── the gadget gate ───────────────────────────────────────────────
112
+ gadget_not_registered: {
113
+ code: 'gadget_not_registered',
114
+ tools: ['ggui_render'],
115
+ recovery: 'retry-same-id',
116
+ emitter: 'the gadget gate at ggui_render',
117
+ description: "A clientCapabilities.gadgets reference names an export the app's gadget registry does not carry. Drop the reference or fix the name; the detail suggests the nearest match.",
118
+ },
119
+ gadget_package_mismatch: {
120
+ code: 'gadget_package_mismatch',
121
+ tools: ['ggui_render'],
122
+ recovery: 'retry-same-id',
123
+ emitter: 'the gadget gate at ggui_render',
124
+ description: 'A gadget export is registered, but only under a different package than the contract requested. Request the registered package; the detail names it.',
125
+ },
126
+ gadget_public_env_missing: {
127
+ code: 'gadget_public_env_missing',
128
+ tools: ['ggui_render'],
129
+ recovery: 'retry-same-id',
130
+ emitter: 'the gadget gate at ggui_render',
131
+ description: "A registered wrapper requires a public-env key the app has not set. Set the key on the app's public env, then retry.",
132
+ },
133
+ duplicate_gadget_hook: {
134
+ code: 'duplicate_gadget_hook',
135
+ tools: ['ggui_render'],
136
+ recovery: 'retry-same-id',
137
+ emitter: 'the gadget gate at ggui_render',
138
+ description: 'Two gadget packages export the same name; the generated import would collide. Reference one of them.',
139
+ },
140
+ gadget_types_fetch_failed: {
141
+ code: 'gadget_types_fetch_failed',
142
+ tools: ['ggui_render'],
143
+ recovery: 'later',
144
+ emitter: 'the gadget type fetch before cold generation',
145
+ description: "Fetching a gadget package's types failed; the input was fine. Retry after a short delay.",
146
+ },
147
+ gadget_catalog_integrity: {
148
+ code: 'gadget_catalog_integrity',
149
+ tools: ['ggui_render'],
150
+ recovery: 'retry-same-id',
151
+ emitter: "the app's gadget catalog resolver at ggui_render",
152
+ description: "The app's gadget catalog is inconsistent with its registrations. Repair the catalog, then retry with the same handshakeId.",
153
+ },
154
+ // ── the blueprint registry ────────────────────────────────────────
155
+ blueprint_rejected: {
156
+ code: 'blueprint_rejected',
157
+ tools: ['ggui_render'],
158
+ recovery: 'retry-same-id',
159
+ emitter: 'the blueprint registry on registration',
160
+ description: "The blueprint was rejected by the registry's error-level findings; the detail lists them. Fix the contract and retry with the same handshakeId.",
161
+ },
162
+ });
163
+ /** The registry consumers read. */
164
+ export const DOMAIN_ERROR_REGISTRY = DOMAIN_ERROR_ROWS;
165
+ /** Whether `value` is a registered domain-error code. */
166
+ export function isDomainErrorCode(value) {
167
+ return Object.hasOwn(DOMAIN_ERROR_ROWS, value);
168
+ }
169
+ /** Every registered code, in registry order. */
170
+ export const DOMAIN_ERROR_CODES = Object.keys(DOMAIN_ERROR_ROWS).filter(isDomainErrorCode);
@@ -1,4 +1,4 @@
1
- import type { JsonValue } from './data-contract';
1
+ import type { JsonValue } from './data-contract.js';
2
2
  /**
3
3
  * Event type that flows from user to agent.
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import type { z } from 'zod';
2
- import type { runtimePullEventsPageSchema } from '../schemas/mcp';
3
- import type { DeepReadonly } from './readonly';
2
+ import type { runtimePullEventsPageSchema } from '../schemas/mcp.js';
3
+ import type { DeepReadonly } from './readonly.js';
4
4
  /**
5
5
  * GguiSessionEvent ledger — wire-frame replay primitives (R7).
6
6
  *
@@ -89,12 +89,12 @@ export interface BlueprintDraft {
89
89
  readonly seedPrompt?: string;
90
90
  };
91
91
  /**
92
- * Generator slug hint (e.g. `'ui-gen-advanced-opus-4-7'`). The
92
+ * Generator identity hint (e.g. `'ui-gen-advanced'` — de-modeled, ggui#924). The
93
93
  * server resolves the effective generator as:
94
94
  *
95
95
  * 1. Operator app-pin (`App.pinnedGenerator`) — wins if set.
96
96
  * 2. This hint — if registered in the GeneratorRegistry.
97
- * 3. Registry default (`ui-gen-default-haiku-4-5`).
97
+ * 3. Registry default (`ui-gen-default`).
98
98
  *
99
99
  * Hint-only; unknown slugs fall through to the registry default.
100
100
  */
@@ -40,12 +40,12 @@
40
40
  * projection widenings can be detected; this module is the canonical
41
41
  * shape for the current schema major.
42
42
  */
43
- import type { JsonValue } from './data-contract';
43
+ import type { JsonValue } from './data-contract.js';
44
44
  export type { McpUiDisplayMode, McpUiHostContext, McpUiHostCapabilities, } from '@modelcontextprotocol/ext-apps';
45
45
  import type { McpUiDisplayMode } from '@modelcontextprotocol/ext-apps';
46
46
  import type { z } from 'zod';
47
- import type { hostContextProjectionSchema, mcpUiDisplayModeSchema } from '../schemas/mcp';
48
- import type { DeepReadonly } from './readonly';
47
+ import type { hostContextProjectionSchema, mcpUiDisplayModeSchema } from '../schemas/mcp.js';
48
+ import type { DeepReadonly } from './readonly.js';
49
49
  /**
50
50
  * The wire enum is assignable to ext-apps' `McpUiDisplayMode` — checked at
51
51
  * compile time, so a display mode the host SDK adds is a protocol change
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Allows Claude to generate UIs adapted to the user's device/viewport.
8
8
  */
9
- import type { JsonObject } from './data-contract';
9
+ import type { JsonObject } from './data-contract.js';
10
10
  export type PlatformType = 'web' | 'mobile' | 'desktop';
11
11
  export type DeviceType = 'phone' | 'tablet' | 'desktop';
12
12
  export type Orientation = 'portrait' | 'landscape';
@@ -5,7 +5,7 @@
5
5
  * of truth. Do not hand-author parallel types here.
6
6
  */
7
7
  import type { z } from 'zod';
8
- import type { textBlockSchema, toolUseBlockSchema, toolResultBlockSchema, contentBlockSchema, invokeEventSchema, invokeErrorCodeSchema, invokeTurnSchema } from '../schemas/invoke';
8
+ import type { textBlockSchema, toolUseBlockSchema, toolResultBlockSchema, contentBlockSchema, invokeEventSchema, invokeErrorCodeSchema, invokeTurnSchema } from '../schemas/invoke.js';
9
9
  export type TextBlock = z.infer<typeof textBlockSchema>;
10
10
  export type ToolUseBlock = z.infer<typeof toolUseBlockSchema>;
11
11
  export type ToolResultBlock = z.infer<typeof toolResultBlockSchema>;
@@ -33,7 +33,7 @@
33
33
  * - This module is `data` only — no functions, no reducers. Pure
34
34
  * types so the protocol bundle stays tiny.
35
35
  */
36
- import type { JsonObject } from './data-contract';
36
+ import type { JsonObject } from './data-contract.js';
37
37
  /**
38
38
  * Emitted when the server starts processing a `ggui_handshake` call.
39
39
  * Progress UIs transition from their current state into a
@@ -15,15 +15,15 @@
15
15
  * The corresponding inbound user-action envelope ({@link ActionEnvelope})
16
16
  * lives in `types/events.ts` alongside the event-type enum.
17
17
  */
18
- import type { GguiSession } from './render';
19
- import type { JsonObject, JsonValue, StreamChannelMode } from './data-contract';
18
+ import type { GguiSession } from './render.js';
19
+ import type { JsonObject, JsonValue, StreamChannelMode } from './data-contract.js';
20
20
  /**
21
21
  * Payload for subscribe message
22
22
  */
23
23
  export interface SubscribePayload {
24
24
  sessionId: string;
25
25
  /**
26
- * App (tenant) identity. OPTIONAL — absent ⇒ the server resolves the
26
+ * App identity — the `appId` the session belongs to. OPTIONAL — absent ⇒ the server resolves the
27
27
  * caller's identity-default app, the same resolution rule the MCP
28
28
  * route uses: a token binding (`wsToken` binds `(sessionId, appId)`)
29
29
  * wins, then the deployment's identity → appId mapping, then the