@ggui-ai/protocol 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 (222) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +46 -0
  3. package/dist/bridge/invoke-agent.d.ts +65 -0
  4. package/dist/bridge/invoke-agent.d.ts.map +1 -0
  5. package/dist/bridge/invoke-agent.js +113 -0
  6. package/dist/envelope-adapters.d.ts +24 -0
  7. package/dist/envelope-adapters.d.ts.map +1 -0
  8. package/dist/envelope-adapters.js +14 -0
  9. package/dist/envelopes/builders.d.ts +145 -0
  10. package/dist/envelopes/builders.d.ts.map +1 -0
  11. package/dist/envelopes/builders.js +113 -0
  12. package/dist/errors/unknown-permission-name.d.ts +12 -0
  13. package/dist/errors/unknown-permission-name.d.ts.map +1 -0
  14. package/dist/errors/unknown-permission-name.js +29 -0
  15. package/dist/errors/version-mismatch.d.ts +55 -0
  16. package/dist/errors/version-mismatch.d.ts.map +1 -0
  17. package/dist/errors/version-mismatch.js +52 -0
  18. package/dist/gadgets/resolve-contract-gadgets.d.ts +93 -0
  19. package/dist/gadgets/resolve-contract-gadgets.d.ts.map +1 -0
  20. package/dist/gadgets/resolve-contract-gadgets.js +119 -0
  21. package/dist/gadgets/stdlib-gadgets.d.ts +43 -0
  22. package/dist/gadgets/stdlib-gadgets.d.ts.map +1 -0
  23. package/dist/gadgets/stdlib-gadgets.js +161 -0
  24. package/dist/iframe-bridge.d.ts +63 -0
  25. package/dist/iframe-bridge.d.ts.map +1 -0
  26. package/dist/iframe-bridge.js +166 -0
  27. package/dist/index.d.ts +62 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +79 -0
  30. package/dist/integrations/mcp-apps.d.ts +1218 -0
  31. package/dist/integrations/mcp-apps.d.ts.map +1 -0
  32. package/dist/integrations/mcp-apps.js +427 -0
  33. package/dist/navigation/index.d.ts +3 -0
  34. package/dist/navigation/index.d.ts.map +1 -0
  35. package/dist/navigation/index.js +1 -0
  36. package/dist/navigation/stack-navigation.d.ts +55 -0
  37. package/dist/navigation/stack-navigation.d.ts.map +1 -0
  38. package/dist/navigation/stack-navigation.js +80 -0
  39. package/dist/recommended-prompts.d.ts +56 -0
  40. package/dist/recommended-prompts.d.ts.map +1 -0
  41. package/dist/recommended-prompts.js +55 -0
  42. package/dist/registry/blueprint-key.d.ts +9 -0
  43. package/dist/registry/blueprint-key.d.ts.map +1 -0
  44. package/dist/registry/blueprint-key.js +28 -0
  45. package/dist/registry/canonicalize-contract.d.ts +35 -0
  46. package/dist/registry/canonicalize-contract.d.ts.map +1 -0
  47. package/dist/registry/canonicalize-contract.js +166 -0
  48. package/dist/registry/summarize-contract.d.ts +46 -0
  49. package/dist/registry/summarize-contract.d.ts.map +1 -0
  50. package/dist/registry/summarize-contract.js +63 -0
  51. package/dist/schema-learning/derive-contract.d.ts +67 -0
  52. package/dist/schema-learning/derive-contract.d.ts.map +1 -0
  53. package/dist/schema-learning/derive-contract.js +117 -0
  54. package/dist/schema-learning/merge.d.ts +32 -0
  55. package/dist/schema-learning/merge.d.ts.map +1 -0
  56. package/dist/schema-learning/merge.js +146 -0
  57. package/dist/schemas/blueprint.d.ts +32 -0
  58. package/dist/schemas/blueprint.d.ts.map +1 -0
  59. package/dist/schemas/blueprint.js +92 -0
  60. package/dist/schemas/data-contract.d.ts +750 -0
  61. package/dist/schemas/data-contract.d.ts.map +1 -0
  62. package/dist/schemas/data-contract.js +663 -0
  63. package/dist/schemas/gadget-name-grammar.d.ts +29 -0
  64. package/dist/schemas/gadget-name-grammar.d.ts.map +1 -0
  65. package/dist/schemas/gadget-name-grammar.js +28 -0
  66. package/dist/schemas/handshake-suggestion.d.ts +46 -0
  67. package/dist/schemas/handshake-suggestion.d.ts.map +1 -0
  68. package/dist/schemas/handshake-suggestion.js +107 -0
  69. package/dist/schemas/invoke.d.ts +337 -0
  70. package/dist/schemas/invoke.d.ts.map +1 -0
  71. package/dist/schemas/invoke.js +169 -0
  72. package/dist/schemas/mcp.d.ts +301 -0
  73. package/dist/schemas/mcp.d.ts.map +1 -0
  74. package/dist/schemas/mcp.js +373 -0
  75. package/dist/schemas/ops-blueprint.d.ts +176 -0
  76. package/dist/schemas/ops-blueprint.d.ts.map +1 -0
  77. package/dist/schemas/ops-blueprint.js +259 -0
  78. package/dist/schemas/sync-check.d.ts +11 -0
  79. package/dist/schemas/sync-check.d.ts.map +1 -0
  80. package/dist/schemas/sync-check.js +60 -0
  81. package/dist/screen-blueprints/define.d.ts +22 -0
  82. package/dist/screen-blueprints/define.d.ts.map +1 -0
  83. package/dist/screen-blueprints/define.js +3 -0
  84. package/dist/screen-blueprints/index.d.ts +4 -0
  85. package/dist/screen-blueprints/index.d.ts.map +1 -0
  86. package/dist/screen-blueprints/index.js +3 -0
  87. package/dist/screen-blueprints/match.d.ts +35 -0
  88. package/dist/screen-blueprints/match.d.ts.map +1 -0
  89. package/dist/screen-blueprints/match.js +51 -0
  90. package/dist/screen-blueprints/types.d.ts +164 -0
  91. package/dist/screen-blueprints/types.d.ts.map +1 -0
  92. package/dist/screen-blueprints/types.js +1 -0
  93. package/dist/stream/stream-parser.d.ts +62 -0
  94. package/dist/stream/stream-parser.d.ts.map +1 -0
  95. package/dist/stream/stream-parser.js +199 -0
  96. package/dist/transport/websocket.d.ts +178 -0
  97. package/dist/transport/websocket.d.ts.map +1 -0
  98. package/dist/transport/websocket.js +1 -0
  99. package/dist/types/app-config.d.ts +61 -0
  100. package/dist/types/app-config.d.ts.map +1 -0
  101. package/dist/types/app-config.js +1 -0
  102. package/dist/types/auth.d.ts +61 -0
  103. package/dist/types/auth.d.ts.map +1 -0
  104. package/dist/types/auth.js +1 -0
  105. package/dist/types/blueprint.d.ts +206 -0
  106. package/dist/types/blueprint.d.ts.map +1 -0
  107. package/dist/types/blueprint.js +1 -0
  108. package/dist/types/canvas-lifecycle.d.ts +105 -0
  109. package/dist/types/canvas-lifecycle.d.ts.map +1 -0
  110. package/dist/types/canvas-lifecycle.js +38 -0
  111. package/dist/types/capabilities.d.ts +40 -0
  112. package/dist/types/capabilities.d.ts.map +1 -0
  113. package/dist/types/capabilities.js +19 -0
  114. package/dist/types/contract-inference.d.ts +401 -0
  115. package/dist/types/contract-inference.d.ts.map +1 -0
  116. package/dist/types/contract-inference.js +44 -0
  117. package/dist/types/credential.d.ts +41 -0
  118. package/dist/types/credential.d.ts.map +1 -0
  119. package/dist/types/credential.js +32 -0
  120. package/dist/types/data-bindings.d.ts +322 -0
  121. package/dist/types/data-bindings.d.ts.map +1 -0
  122. package/dist/types/data-bindings.js +29 -0
  123. package/dist/types/data-contract.d.ts +1296 -0
  124. package/dist/types/data-contract.d.ts.map +1 -0
  125. package/dist/types/data-contract.js +111 -0
  126. package/dist/types/events.d.ts +182 -0
  127. package/dist/types/events.d.ts.map +1 -0
  128. package/dist/types/events.js +8 -0
  129. package/dist/types/feedback.d.ts +24 -0
  130. package/dist/types/feedback.d.ts.map +1 -0
  131. package/dist/types/feedback.js +7 -0
  132. package/dist/types/gadget.d.ts +121 -0
  133. package/dist/types/gadget.d.ts.map +1 -0
  134. package/dist/types/gadget.js +24 -0
  135. package/dist/types/handshake-suggestion.d.ts +264 -0
  136. package/dist/types/handshake-suggestion.d.ts.map +1 -0
  137. package/dist/types/handshake-suggestion.js +70 -0
  138. package/dist/types/host-context.d.ts +163 -0
  139. package/dist/types/host-context.d.ts.map +1 -0
  140. package/dist/types/host-context.js +142 -0
  141. package/dist/types/interface-context.d.ts +105 -0
  142. package/dist/types/interface-context.d.ts.map +1 -0
  143. package/dist/types/interface-context.js +115 -0
  144. package/dist/types/invoke.d.ts +28 -0
  145. package/dist/types/invoke.d.ts.map +1 -0
  146. package/dist/types/invoke.js +7 -0
  147. package/dist/types/live-channel.d.ts +613 -0
  148. package/dist/types/live-channel.d.ts.map +1 -0
  149. package/dist/types/live-channel.js +1 -0
  150. package/dist/types/llm.d.ts +61 -0
  151. package/dist/types/llm.d.ts.map +1 -0
  152. package/dist/types/llm.js +186 -0
  153. package/dist/types/mcp-proxy.d.ts +67 -0
  154. package/dist/types/mcp-proxy.d.ts.map +1 -0
  155. package/dist/types/mcp-proxy.js +46 -0
  156. package/dist/types/mcp.d.ts +637 -0
  157. package/dist/types/mcp.d.ts.map +1 -0
  158. package/dist/types/mcp.js +30 -0
  159. package/dist/types/openrouter-models.d.ts +22 -0
  160. package/dist/types/openrouter-models.d.ts.map +1 -0
  161. package/dist/types/openrouter-models.js +4843 -0
  162. package/dist/types/region.d.ts +26 -0
  163. package/dist/types/region.d.ts.map +1 -0
  164. package/dist/types/region.js +36 -0
  165. package/dist/types/session.d.ts +419 -0
  166. package/dist/types/session.d.ts.map +1 -0
  167. package/dist/types/session.js +1 -0
  168. package/dist/types/thread.d.ts +207 -0
  169. package/dist/types/thread.d.ts.map +1 -0
  170. package/dist/types/thread.js +57 -0
  171. package/dist/types/ui-generator.d.ts +100 -0
  172. package/dist/types/ui-generator.d.ts.map +1 -0
  173. package/dist/types/ui-generator.js +53 -0
  174. package/dist/validation/ajv-runtime.d.ts +140 -0
  175. package/dist/validation/ajv-runtime.d.ts.map +1 -0
  176. package/dist/validation/ajv-runtime.js +452 -0
  177. package/dist/validation/content-hash.d.ts +3 -0
  178. package/dist/validation/content-hash.d.ts.map +1 -0
  179. package/dist/validation/content-hash.js +21 -0
  180. package/dist/validation/contract-validator.d.ts +244 -0
  181. package/dist/validation/contract-validator.d.ts.map +1 -0
  182. package/dist/validation/contract-validator.js +711 -0
  183. package/dist/validation/cross-references.d.ts +105 -0
  184. package/dist/validation/cross-references.d.ts.map +1 -0
  185. package/dist/validation/cross-references.js +164 -0
  186. package/dist/validation/hygiene-rules.d.ts +250 -0
  187. package/dist/validation/hygiene-rules.d.ts.map +1 -0
  188. package/dist/validation/hygiene-rules.js +564 -0
  189. package/dist/validation/lint-contract.d.ts +130 -0
  190. package/dist/validation/lint-contract.d.ts.map +1 -0
  191. package/dist/validation/lint-contract.js +225 -0
  192. package/dist/validation/name-invariants.d.ts +117 -0
  193. package/dist/validation/name-invariants.d.ts.map +1 -0
  194. package/dist/validation/name-invariants.js +172 -0
  195. package/dist/validation/reserved-channels.d.ts +156 -0
  196. package/dist/validation/reserved-channels.d.ts.map +1 -0
  197. package/dist/validation/reserved-channels.js +356 -0
  198. package/dist/validation/resolve-stream-channel.d.ts +78 -0
  199. package/dist/validation/resolve-stream-channel.d.ts.map +1 -0
  200. package/dist/validation/resolve-stream-channel.js +64 -0
  201. package/dist/validation/sanitize-error.d.ts +46 -0
  202. package/dist/validation/sanitize-error.d.ts.map +1 -0
  203. package/dist/validation/sanitize-error.js +88 -0
  204. package/dist/validation/schema-compat-invariants.d.ts +140 -0
  205. package/dist/validation/schema-compat-invariants.d.ts.map +1 -0
  206. package/dist/validation/schema-compat-invariants.js +220 -0
  207. package/dist/validation/schema-meta-validation.d.ts +60 -0
  208. package/dist/validation/schema-meta-validation.d.ts.map +1 -0
  209. package/dist/validation/schema-meta-validation.js +131 -0
  210. package/dist/validation/schema-subset.d.ts +165 -0
  211. package/dist/validation/schema-subset.d.ts.map +1 -0
  212. package/dist/validation/schema-subset.js +295 -0
  213. package/dist/validation/ui-security.d.ts +54 -0
  214. package/dist/validation/ui-security.d.ts.map +1 -0
  215. package/dist/validation/ui-security.js +138 -0
  216. package/dist/validation/zod-to-json-schema.d.ts +63 -0
  217. package/dist/validation/zod-to-json-schema.d.ts.map +1 -0
  218. package/dist/validation/zod-to-json-schema.js +126 -0
  219. package/dist/version.d.ts +1458 -0
  220. package/dist/version.d.ts.map +1 -0
  221. package/dist/version.js +1459 -0
  222. package/package.json +113 -0
@@ -0,0 +1,206 @@
1
+ /**
2
+ * `Blueprint` — the variant-unit between a `DataContract` and the
3
+ * generated UI code that renders it.
4
+ *
5
+ * Multiple `Blueprint` records MAY share `(appId, contractHash)`; they
6
+ * differ on `generator` and/or {@link BlueprintVariance}. The selector
7
+ * picks one at runtime (an LLM-driven pick layered atop the
8
+ * deterministic fallback ladder; see
9
+ * {@link BlueprintSelector} in `@ggui-ai/mcp-server-core`).
10
+ *
11
+ * Locked decisions:
12
+ *
13
+ * - **Storage shape: S3 + DDB pointer.** Production adapters store
14
+ * code body in S3 at a content-hashed key and persist
15
+ * `codeS3Url + codeHash` on the metadata row. DDB's 400KB per-item
16
+ * limit precludes inline storage — typical generated code is
17
+ * 5-30KB but advanced-generator iterative-loop output routinely
18
+ * exceeds it. OSS in-memory adapter skips S3 (in-process
19
+ * `Map<codeHash, string>`).
20
+ * - **Tenancy.** Scoped per `(appId, contractHash)`. Different apps'
21
+ * contract may coincidentally hash the same; their blueprints
22
+ * must never cross-pollinate. The DDB primary key is
23
+ * `blueprintId`; the lookup GSI is `blueprintsByAppAndContract`.
24
+ * - **`contract` field.** The contract shape is content-keyed by
25
+ * `contractHash` (RFC 8785 / `blueprintKey`), so any two
26
+ * blueprints with the same `contractHash` agree on it
27
+ * byte-for-byte after canonicalization. The embedded `contract`
28
+ * copy is a read-time convenience for callers that have the
29
+ * blueprint row in hand and don't want a second lookup — NOT a
30
+ * source-of-truth divergence. Implementations MAY denormalize
31
+ * freely; consumers MUST treat `contractHash` as authoritative.
32
+ */
33
+ import type { DataContract, JsonObject } from './data-contract.js';
34
+ /**
35
+ * Per-axis weights for the {@link BlueprintSearch} multi-axis scoring
36
+ * algorithm. Each weight is a non-negative number; the final score is
37
+ * the weighted sum divided by the sum-of-weights so the output stays
38
+ * in `[0, 1]` regardless of how operators tune the dial.
39
+ *
40
+ * Wire shape: lives on
41
+ * {@link BlueprintSearchConfig.weights}, which lives on the per-app
42
+ * {@link AppBlueprintSearchConfig}. Default values:
43
+ * `{hash: 1.0, embed: 0.4, struct: 0.3, variance: 0.2, intent: 0.1}` —
44
+ * the embed + struct axes dominate by design (a structurally-similar
45
+ * contract is the strongest semantic match short of an exact hash).
46
+ */
47
+ export interface BlueprintSearchWeights {
48
+ /** Exact `contractHash` equality. Short-circuit weight — when a
49
+ * match exists on this axis, the search returns `score: 1.0`
50
+ * immediately without consulting the others. */
51
+ readonly hash: number;
52
+ /** Cosine similarity between query + candidate `contractEmbedding`. */
53
+ readonly embed: number;
54
+ /** Structural fingerprint Jaccard — actionNames, streamChannels,
55
+ * propsKeys, contextKeys overlap. */
56
+ readonly struct: number;
57
+ /** Variance-tag overlap — persona equality + aesthetic equality +
58
+ * context-key Jaccard, averaged. */
59
+ readonly variance: number;
60
+ /** Intent-keyword Jaccard against the blueprint's stored
61
+ * `seedPrompt + persona` tokens. */
62
+ readonly intent: number;
63
+ }
64
+ /**
65
+ * Per-app blueprint-search configuration. All fields optional — the
66
+ * server applies the global default when absent.
67
+ *
68
+ * Wire shape: lives on the per-app `App` record
69
+ * in `@ggui-ai/mcp-server-core` as `App.blueprintSearchConfig?`. The
70
+ * cloud DDB adapter carries it as an optional map column with
71
+ * default-on-read.
72
+ */
73
+ export interface AppBlueprintSearchConfig {
74
+ /** Per-axis weight overrides. Falls back to
75
+ * `DEFAULT_BLUEPRINT_SEARCH_WEIGHTS`. */
76
+ readonly weights?: Partial<BlueprintSearchWeights>;
77
+ /** Score gate for `origin: 'cache'` routing in the three-step
78
+ * handshake. Defaults to `0.85`. */
79
+ readonly threshold?: number;
80
+ /** Maximum results returned per call. Defaults to `5`. */
81
+ readonly topK?: number;
82
+ }
83
+ /**
84
+ * Per-blueprint variance tags. Free-form at v1 — a `PersonaRegistry`
85
+ * may follow if the tag set stabilizes around recurring patterns.
86
+ *
87
+ * The LLM-driven selector reads `persona` + `context` + `seedPrompt`
88
+ * to pick the best fit for the current request's `intent` + `hint`.
89
+ */
90
+ export interface BlueprintVariance {
91
+ /**
92
+ * Free-form persona tag (e.g. `'minimalist'`, `'data-dense'`,
93
+ * `'mobile-first'`). Operator-authored.
94
+ */
95
+ readonly persona?: string;
96
+ /**
97
+ * Free-form aesthetic tag (e.g. `'glassmorphic'`, `'brutalist'`,
98
+ * `'editorial'`). Distinct from persona — persona names the user
99
+ * mental model; aesthetic names the visual treatment. Cold-gen
100
+ * prompts surface this as a styling directive; the variant selector
101
+ * weights it alongside persona when ranking cached variants.
102
+ */
103
+ readonly aesthetic?: string;
104
+ /**
105
+ * Small structured signal carried alongside the persona. Typed as
106
+ * {@link JsonObject} so any JSON-safe shape rides through.
107
+ */
108
+ readonly context?: JsonObject;
109
+ /**
110
+ * The raw operator prompt that produced this variant. Round-trip
111
+ * input for the LLM selector + audit trail.
112
+ */
113
+ readonly seedPrompt?: string;
114
+ }
115
+ /**
116
+ * The variant-unit. See file-level docstring for the locked decisions
117
+ * this shape encodes.
118
+ */
119
+ export interface Blueprint {
120
+ /** Stable, unique blueprint id (e.g. `bp-<uuid>`). Primary key. */
121
+ readonly blueprintId: string;
122
+ /**
123
+ * Canonical RFC 8785 (JCS) hash of the contract shape — same
124
+ * function as `blueprintKey(contract)`. Groups variants under one
125
+ * key.
126
+ */
127
+ readonly contractHash: string;
128
+ /** Tenancy scope. Composite secondary key with `contractHash`. */
129
+ readonly appId: string;
130
+ /**
131
+ * S3 URL (`s3://<bucket>/<key>`) of the generated code body when
132
+ * cached. Absent → blueprint is pending generation; push branches
133
+ * on this to decide cache-hit vs gen-and-persist. OSS in-memory
134
+ * adapters MAY use a non-S3 sentinel (or just leave this absent
135
+ * and rely on `codeHash` to look up code body inline).
136
+ */
137
+ readonly codeS3Url?: string;
138
+ /**
139
+ * Content hash of the generated code body. Present iff
140
+ * {@link codeS3Url} is present (or the in-memory equivalent).
141
+ */
142
+ readonly codeHash?: string;
143
+ /**
144
+ * Slug of the {@link UiGenerator} that produced this variant
145
+ * (e.g. `'ui-gen-default-haiku-4-5'`). The server's `GeneratorRegistry`
146
+ * is the authority for which slugs exist on a given deployment.
147
+ */
148
+ readonly generator: string;
149
+ /**
150
+ * Optional 0-1 validator score from the advanced generator's
151
+ * iterative loop. Sub-threshold variants are stored but not selected
152
+ * by default; the operator UI can promote them.
153
+ */
154
+ readonly validatorScore?: number;
155
+ /**
156
+ * Variance tags driving the LLM selector. See
157
+ * {@link BlueprintVariance}.
158
+ */
159
+ readonly variance: BlueprintVariance;
160
+ /**
161
+ * Operator-pinned default flag. The deterministic fallback ladder
162
+ * picks this variant first when present; the LLM selector defers to
163
+ * it when ambiguous.
164
+ *
165
+ * Encoded as `true | undefined` (never `false`) — only one variant
166
+ * per `(appId, contractHash)` carries the flag, and the store
167
+ * enforces the invariant on `setOperatorDefault`. Absent ≡ not
168
+ * the default.
169
+ */
170
+ readonly isOperatorDefault?: true;
171
+ /** ISO-8601 timestamp the row was first inserted. */
172
+ readonly createdAt: string;
173
+ /**
174
+ * `'agent'` when the standard handshake → push flow minted the
175
+ * blueprint; `'operator'` when an explicit `ggui_ops_generate_blueprint`
176
+ * call created it.
177
+ */
178
+ readonly createdBy: 'agent' | 'operator';
179
+ /**
180
+ * Read-cache copy of the contract shape. See file-level docstring
181
+ * for why this is a denormalization, not a source-of-truth
182
+ * divergence. Consumers MUST treat {@link contractHash} as
183
+ * authoritative for identity comparison.
184
+ */
185
+ readonly contract: DataContract;
186
+ /**
187
+ * Embedding vector of the canonical-JSON-stringified contract,
188
+ * computed by {@link EmbeddingProvider} at
189
+ * {@link BlueprintStore.put} time when a provider is wired. Read
190
+ * by {@link BlueprintSearch} on the embed axis (cosine similarity
191
+ * vs. the search-time embedding of the query contract). Absent
192
+ * when the store was constructed without a provider; the search
193
+ * still works — the embed axis simply contributes zero and the
194
+ * other axes (hash, structural, variance, intent) carry the
195
+ * decision.
196
+ *
197
+ * Length MUST equal the provider's declared `dimensions`. SHOULD be
198
+ * L2-normalized so dot product == cosine.
199
+ * Implementations that swap providers across deployments are
200
+ * expected to re-embed; comparing vectors across provider ids is
201
+ * a category error (different basis), and the search layer
202
+ * defends by treating dimension mismatch as embed-axis zero.
203
+ */
204
+ readonly contractEmbedding?: readonly number[];
205
+ }
206
+ //# sourceMappingURL=blueprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blueprint.d.ts","sourceRoot":"","sources":["../../src/types/blueprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,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,CAAC,sBAAsB,CAAC,CAAC;IACnD;yCACqC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;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,kEAAkE;IAClE,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;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Canvas-mode lifecycle envelopes.
3
+ *
4
+ * Carried over the reserved `_ggui:lifecycle` channel via `data`
5
+ * WebSocket messages. The server emits at four lifecycle moments;
6
+ * canvas iframes consume (via the animator host) to drive their
7
+ * pill state machine:
8
+ *
9
+ * - `handshake_started` / `handshake_completed`: bracket each
10
+ * `ggui_handshake` call so the animator can render "negotiating"
11
+ * during the gap.
12
+ * - `push_started`: emitted at the gen gate of `ggui_push`, before
13
+ * the final `push` envelope lands. Drives the animator's
14
+ * `constructing` state. The eventual `push` envelope (existing
15
+ * wire type) signals completion → animator transitions to
16
+ * `content`.
17
+ * - `consume_polling`: signals that `ggui_consume` opened a long-
18
+ * poll. The animator's `listening` state. The complementary
19
+ * "close" signal is the existing `drain_ack` envelope (consume
20
+ * drained an action) — no separate "closed" lifecycle kind is
21
+ * needed.
22
+ *
23
+ * Discriminated on `kind`. Adding a kind is a protocol-version bump,
24
+ * not a silent extension — keeps the union closed so producers and
25
+ * consumers agree on the surface.
26
+ *
27
+ * Every variant extends `JsonObject` so producers can hand the
28
+ * payload directly to JsonValue-typed transport seams without an
29
+ * unsafe cast.
30
+ *
31
+ * Boundary discipline:
32
+ * - This module describes ENVELOPE SHAPES carried on a reserved
33
+ * channel. It does NOT describe the animator state machine that
34
+ * consumes them (lives in `@ggui-ai/iframe-runtime/canvas/animator`).
35
+ * - This module is `data` only — no functions, no reducers. Pure
36
+ * types so the protocol bundle stays tiny.
37
+ */
38
+ import type { JsonObject } from './data-contract';
39
+ /**
40
+ * Emitted when the server starts processing a `ggui_handshake` call.
41
+ * Animator transitions from current state into `handshake` (or its
42
+ * `content`-substate equivalent).
43
+ */
44
+ export interface HandshakeStartedPayload extends JsonObject {
45
+ readonly kind: 'handshake_started';
46
+ readonly handshakeId: string;
47
+ /** Agent's intent string — animator may surface this as a label. */
48
+ readonly intent: string;
49
+ }
50
+ /**
51
+ * Emitted when the server finishes a `ggui_handshake` call. Animator
52
+ * either drops back to `ready`/`content` (no gen expected) or
53
+ * pre-warms to `constructing` if `genExpected: true` so the
54
+ * transition from handshake → constructing doesn't flicker.
55
+ */
56
+ export interface HandshakeCompletedPayload extends JsonObject {
57
+ readonly kind: 'handshake_completed';
58
+ readonly handshakeId: string;
59
+ /** Negotiator outcome — informational; animator may surface. */
60
+ readonly outcome: 'accepted' | 'amended' | 'declined' | 'cached';
61
+ /**
62
+ * Whether a cold gen is about to follow this handshake. When true,
63
+ * the canvas may pre-warm the `constructing` state to suppress a
64
+ * `handshake → ready → constructing` flicker.
65
+ */
66
+ readonly genExpected: boolean;
67
+ }
68
+ /**
69
+ * Emitted when the server starts a `ggui_push` cold-gen (or
70
+ * blueprint-cache hit). The eventual `push` envelope on the existing
71
+ * wire signals completion.
72
+ */
73
+ export interface PushStartedPayload extends JsonObject {
74
+ readonly kind: 'push_started';
75
+ /** The stack-item id the eventual `push` envelope will carry. */
76
+ readonly stackItemId: string;
77
+ /** Echoed for the animator label ("Building: <intent>"). */
78
+ readonly intent: string;
79
+ }
80
+ /**
81
+ * Emitted when `ggui_consume` opens a long-poll (after the action
82
+ * pipe is found empty). Animator transitions to `listening`. The
83
+ * complementary "close" signal is the existing `drain_ack` envelope.
84
+ */
85
+ export interface ConsumePollingPayload extends JsonObject {
86
+ readonly kind: 'consume_polling';
87
+ /**
88
+ * Always `'open'` today — the closing transition is signaled
89
+ * by the existing `drain_ack` envelope (action consumed) and by the
90
+ * absence of further `consume_polling` for the same stack item.
91
+ * Reserved as a discriminator field rather than implicit so future
92
+ * `'closed'` / `'timeout'` variants can layer in without a wire
93
+ * shape change.
94
+ */
95
+ readonly state: 'open';
96
+ /** Stack item id whose action pipe is being polled. */
97
+ readonly stackItemId: string;
98
+ }
99
+ /**
100
+ * Closed discriminated union of every canvas-mode lifecycle payload.
101
+ * New kinds bump the protocol version; consumers narrow on `kind`
102
+ * with exhaustive switch.
103
+ */
104
+ export type CanvasLifecyclePayload = HandshakeStartedPayload | HandshakeCompletedPayload | PushStartedPayload | ConsumePollingPayload;
105
+ //# sourceMappingURL=canvas-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-lifecycle.d.ts","sourceRoot":"","sources":["../../src/types/canvas-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,UAAU;IACzD,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC3D,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IACjE;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAC9B,uBAAuB,GACvB,yBAAyB,GACzB,kBAAkB,GAClB,qBAAqB,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Canvas-mode lifecycle envelopes.
3
+ *
4
+ * Carried over the reserved `_ggui:lifecycle` channel via `data`
5
+ * WebSocket messages. The server emits at four lifecycle moments;
6
+ * canvas iframes consume (via the animator host) to drive their
7
+ * pill state machine:
8
+ *
9
+ * - `handshake_started` / `handshake_completed`: bracket each
10
+ * `ggui_handshake` call so the animator can render "negotiating"
11
+ * during the gap.
12
+ * - `push_started`: emitted at the gen gate of `ggui_push`, before
13
+ * the final `push` envelope lands. Drives the animator's
14
+ * `constructing` state. The eventual `push` envelope (existing
15
+ * wire type) signals completion → animator transitions to
16
+ * `content`.
17
+ * - `consume_polling`: signals that `ggui_consume` opened a long-
18
+ * poll. The animator's `listening` state. The complementary
19
+ * "close" signal is the existing `drain_ack` envelope (consume
20
+ * drained an action) — no separate "closed" lifecycle kind is
21
+ * needed.
22
+ *
23
+ * Discriminated on `kind`. Adding a kind is a protocol-version bump,
24
+ * not a silent extension — keeps the union closed so producers and
25
+ * consumers agree on the surface.
26
+ *
27
+ * Every variant extends `JsonObject` so producers can hand the
28
+ * payload directly to JsonValue-typed transport seams without an
29
+ * unsafe cast.
30
+ *
31
+ * Boundary discipline:
32
+ * - This module describes ENVELOPE SHAPES carried on a reserved
33
+ * channel. It does NOT describe the animator state machine that
34
+ * consumes them (lives in `@ggui-ai/iframe-runtime/canvas/animator`).
35
+ * - This module is `data` only — no functions, no reducers. Pure
36
+ * types so the protocol bundle stays tiny.
37
+ */
38
+ export {};
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Component capability permissions and quality metadata.
3
+ *
4
+ * Components run in a sandboxed context with all capabilities denied by default.
5
+ * Capabilities can be granted by the app developer (per-app) or by the end-user (per-session).
6
+ */
7
+ /**
8
+ * Software capabilities that can be granted to sandboxed components.
9
+ *
10
+ * Hardware access flows through gadget hooks (`clientCapabilities.gadgets`)
11
+ * — each gadget descriptor declares a `permission` that threads to the
12
+ * iframe's `Permissions-Policy` header. There is no separate
13
+ * `adapters[]` model.
14
+ */
15
+ export type ComponentCapability = 'network' | 'storage' | 'dom' | 'eval' | 'navigation' | 'device';
16
+ /**
17
+ * Capability permissions for a component.
18
+ * Default posture: all capabilities denied (granted: []).
19
+ */
20
+ export interface CapabilityPermissions {
21
+ /** Capabilities this component is allowed to use. Default: [] (all denied) */
22
+ granted: ComponentCapability[];
23
+ }
24
+ /**
25
+ * Quality evaluation metadata attached to produced components.
26
+ * Producers MAY attach quality scores. Renderers MAY display quality indicators.
27
+ */
28
+ export interface QualityMetadata {
29
+ evaluationRounds: number;
30
+ finalScore: number;
31
+ dimensions: {
32
+ completeness: number;
33
+ visualPolish: number;
34
+ interactivity: number;
35
+ accessibility: number;
36
+ codeQuality: number;
37
+ };
38
+ passed: boolean;
39
+ }
40
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/types/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,SAAS,GACT,KAAK,GACL,MAAM,GACN,YAAY,GACZ,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,8EAA8E;IAC9E,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC;AAMD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;CACjB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Component capability permissions and quality metadata.
3
+ *
4
+ * Components run in a sandboxed context with all capabilities denied by default.
5
+ * Capabilities can be granted by the app developer (per-app) or by the end-user (per-session).
6
+ */
7
+ export {};
8
+ // =============================================================================
9
+ // Hardware grant model
10
+ // =============================================================================
11
+ //
12
+ // Hardware-capability hooks (camera, microphone, geolocation, etc.) flow
13
+ // through the gadget catalog at `DataContract.clientCapabilities.gadgets`.
14
+ // Each gadget descriptor declares a `permission` field whose value is the
15
+ // Web Permissions API name (`KNOWN_PERMISSION_NAMES`); the server projects
16
+ // every declared permission onto the iframe's `Permissions-Policy` header.
17
+ //
18
+ // There is no `adapters[]` allow-list (voice / camera / location /
19
+ // bluetooth). Per-gadget permission threading IS the grant model.