@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,613 @@
1
+ /**
2
+ * Live-channel contract payload types.
3
+ *
4
+ * The live channel is the live session plane between core-mcp and the
5
+ * user. The types in this file describe WHAT that plane talks about —
6
+ * the payload shapes for each exchange, independent of how they're
7
+ * framed on the wire.
8
+ *
9
+ * The transport envelope (discriminated union + discriminator enum +
10
+ * connection-status enum) lives behind the
11
+ * `@ggui-ai/protocol/transport/websocket` subpath so only transport
12
+ * implementors pay its type/build cost. Consumers that only need
13
+ * contract shapes stay on the root import.
14
+ *
15
+ * The corresponding inbound user-action envelope ({@link ActionEnvelope})
16
+ * lives in `types/events.ts` alongside the event-type enum.
17
+ */
18
+ import type { InterfaceContext } from './interface-context';
19
+ import type { SessionStackEntry } from './session';
20
+ import type { DataContract, JsonObject, JsonSchema, JsonValue, StreamChannelMode } from './data-contract';
21
+ /**
22
+ * Payload for subscribe message
23
+ */
24
+ export interface SubscribePayload {
25
+ sessionId: string;
26
+ appId: string;
27
+ /** Role of the subscriber: 'user' (Portal) or 'agent' (MCP bridge) */
28
+ role?: 'user' | 'agent';
29
+ /**
30
+ * Resume cursor for live-channel outbound stream replay. When present,
31
+ * the server replays buffered envelopes with `seq > fromSeq` per the
32
+ * active stack item's per-channel replay policy
33
+ * (`streamSpec[name].replay`) BEFORE transitioning to the
34
+ * live tail.
35
+ *
36
+ * Semantics:
37
+ * - Omitted → fresh subscribe. No replay; client only sees live
38
+ * tail from the current cursor onward.
39
+ * - `0` → replay everything the server still retains, subject to
40
+ * policy and bounded buffer retention (may flag
41
+ * `replayTruncated` on the ack).
42
+ * - `N` → replay envelopes with `seq > N`. Use `lastSeenSeq` from
43
+ * the last envelope the client observed.
44
+ *
45
+ * Honored only by implementations that expose
46
+ * `SessionStreamBuffer`-backed replay. Hosted cloud does NOT
47
+ * yet honor `fromSeq` — the field is silently ignored there. OSS
48
+ * `@ggui-ai/mcp-server` honors it fully.
49
+ */
50
+ fromSeq?: number;
51
+ /**
52
+ * Opaque single-use bootstrap credential for initial subscribe.
53
+ *
54
+ * General transport-bootstrap slot — the type system does NOT couple
55
+ * this field to any integration. Today the only consumer minting these
56
+ * is the MCP Apps outbound delivery path (`ui://ggui/session`), but
57
+ * any future bootstrap mechanism (signed-URL share, short-code
58
+ * auto-login, etc.) reuses the same field with the same semantics:
59
+ *
60
+ * - Opaque to the client — validated server-side against the
61
+ * subscribe's `sessionId` + `appId`.
62
+ * - Short TTL (seconds-to-minutes); stale tokens are rejected.
63
+ * - Single-use; consumed at first successful subscribe.
64
+ *
65
+ * On a successful bootstrap-auth subscribe, the server SHOULD issue
66
+ * a longer-lived reconnect credential via {@link AckPayload.sessionToken}.
67
+ *
68
+ * Mutually compatible with upstream bearer-auth (`Authorization`
69
+ * header / `?token=` query). When both are present, server behavior
70
+ * is implementation-defined; the canonical path is bearer-OR-bootstrap,
71
+ * not bearer-AND-bootstrap.
72
+ */
73
+ bootstrap?: string;
74
+ /**
75
+ * Protocol schema versions this client accepts on the wire. Opt-in
76
+ * — absent is legacy-pass-through (server treats the subscribe as
77
+ * version-agnostic).
78
+ *
79
+ * First-party clients populate this with `CLIENT_SUPPORTED_VERSIONS`
80
+ * (`@ggui-ai/protocol`), seeded with `PROTOCOL_SCHEMA_VERSION`. A
81
+ * server whose {@link PROTOCOL_SCHEMA_VERSION} is NOT a member of
82
+ * this list is a version mismatch — the server replies with an
83
+ * `UPGRADE_REQUIRED` error envelope (see {@link UPGRADE_REQUIRED}).
84
+ *
85
+ * Symmetric with {@link AckPayload.serverVersion}: the server's
86
+ * declaration is advisory on the receiver; this client declaration
87
+ * is advisory on the server. The policy split is intentional — it
88
+ * lets either side opt into stricter enforcement without breaking
89
+ * legacy peers.
90
+ *
91
+ * Launch posture: servers run `versionPolicy: 'reject'` by default —
92
+ * mismatch emits `UPGRADE_REQUIRED` AND closes the connection. Legacy
93
+ * opt-out via explicit `versionPolicy: 'advisory'` keeps the connection
94
+ * open after the error frame — used only for controlled migration
95
+ * windows.
96
+ */
97
+ supportedVersions?: string[];
98
+ }
99
+ /**
100
+ * Payload for ack message (subscribe response includes current stack)
101
+ */
102
+ export interface AckPayload {
103
+ sequence: number;
104
+ timestamp: number;
105
+ /** Current session stack (returned on subscribe) */
106
+ stack?: SessionStackEntry[];
107
+ /**
108
+ * Current outbound-stream cursor snapshot at the moment the ack is
109
+ * sent. Distinct from `sequence` (which counts INBOUND session
110
+ * events like `user.submitted`). Clients use `streamSeq` to:
111
+ * - know the point beyond which the live tail begins;
112
+ * - seed their `lastSeenSeq` if they didn't pass `fromSeq` on
113
+ * subscribe.
114
+ *
115
+ * Absent on implementations without a `SessionStreamBuffer`.
116
+ * 0 means the session has recorded no outbound envelopes yet.
117
+ */
118
+ streamSeq?: number;
119
+ /**
120
+ * Truthy when the server could NOT honor the client's `fromSeq`
121
+ * fully — some envelopes with `seq > fromSeq` have been evicted
122
+ * from the bounded buffer for a channel declaring
123
+ * `replay: 'all'`. The client has a history gap; UX layers
124
+ * typically surface this as a break-in-timeline indicator.
125
+ *
126
+ * Absent on fresh subscribes and on servers without replay
127
+ * infrastructure.
128
+ */
129
+ replayTruncated?: boolean;
130
+ /**
131
+ * Reconnect credential issued on successful bootstrap-auth subscribe.
132
+ *
133
+ * General transport-bootstrap slot — the type system does NOT couple
134
+ * this field to any integration (same positioning as
135
+ * {@link SubscribePayload.bootstrap}). Servers that accepted a
136
+ * bootstrap credential on `subscribe` SHOULD mint a longer-lived
137
+ * session-scoped token and return it here so the client can reconnect
138
+ * without re-minting from the original bootstrap source.
139
+ *
140
+ * Semantics:
141
+ * - Longer TTL than the bootstrap (minutes-to-hours).
142
+ * - Bound to the same `sessionId` + `appId`.
143
+ * - Passed on reconnect via the standard bearer path
144
+ * (`Authorization: Bearer <sessionToken>` or `?token=`), NOT in
145
+ * `SubscribePayload.bootstrap` (which is single-use).
146
+ *
147
+ * Absent when the subscribe was bearer-authed (no bootstrap-bound
148
+ * reconnect credential needed) and on servers that don't implement
149
+ * bootstrap auth.
150
+ */
151
+ sessionToken?: string;
152
+ /**
153
+ * Protocol schema version this server emits on. Advertised on every
154
+ * successful ack. First-party servers populate this with
155
+ * {@link PROTOCOL_SCHEMA_VERSION} from `@ggui-ai/protocol`.
156
+ *
157
+ * Client-side policy: on ack receipt, if `serverVersion` is present
158
+ * AND not in the client's `CLIENT_SUPPORTED_VERSIONS`, the client
159
+ * surfaces `UPGRADE_REQUIRED` (see {@link UPGRADE_REQUIRED}) via
160
+ * its error channel. Absent `serverVersion` is legacy-pass-through
161
+ * — the client treats the session as version-agnostic, preserving
162
+ * pre-handshake behavior for servers that haven't wired the field.
163
+ *
164
+ * Symmetric with {@link SubscribePayload.supportedVersions}.
165
+ */
166
+ serverVersion?: string;
167
+ }
168
+ /**
169
+ * Payload for push message (Server -> Client: agent push event with generated/cached UI).
170
+ * Carries a {@link SessionStackEntry} — either a generated component
171
+ * item (default) or an embedded MCP Apps iframe variant.
172
+ */
173
+ export interface PushPayload {
174
+ stackItem: SessionStackEntry;
175
+ matchType?: string;
176
+ }
177
+ /**
178
+ * Explicit outbound live-channel envelope — the body of a `type: 'data'`
179
+ * WebSocket message.
180
+ *
181
+ * Carries the CHANNEL identity explicitly plus the minimal per-delivery
182
+ * semantics receivers need to fold the payload correctly. Maps 1:1 to
183
+ * the three-channel-topology doctrine's `StreamEnvelope` shape.
184
+ *
185
+ * Validation is split intentionally — `validateStreamData(channel,
186
+ * payload, spec)` checks payload shape against the channel's
187
+ * `schema`. `mode` / `complete` / `seq` are NOT validated by the
188
+ * shape checker; senders declare them and receivers honor them.
189
+ *
190
+ * `replay` is NOT on the envelope — it's a per-channel policy
191
+ * declared on `spec.channels[channel].replay`. A per-delivery field
192
+ * would imply replay can vary message-to-message, which it can't.
193
+ *
194
+ * `timestamp` is NOT on the envelope in this slice. Replay
195
+ * correctness needs `seq` only; timestamp is a future optional
196
+ * addition driven by a concrete client-UX need.
197
+ */
198
+ export interface StreamEnvelope {
199
+ /** Session this delivery belongs to. */
200
+ sessionId: string;
201
+ /** Channel name (keys into `spec.channels`). */
202
+ channel: string;
203
+ /**
204
+ * State-folding mode for this delivery. Senders declare; receivers
205
+ * honor. Typically equals the channel's declared `mode` on the
206
+ * spec, but the envelope is the authoritative per-delivery signal.
207
+ */
208
+ mode: StreamChannelMode;
209
+ /**
210
+ * Payload — validated against `spec.channels[channel].schema`.
211
+ * Shape is channel-specific; consumers typecheck via contract
212
+ * inference when they use `defineContract` + `useStream`.
213
+ */
214
+ payload: JsonValue;
215
+ /**
216
+ * Terminal completion marker — truthy on the last delivery for a
217
+ * completable channel (one declared with `complete: true` on the
218
+ * spec). Consumers use this to transition subscribers into a
219
+ * "channel closed" state. Absent on non-terminal deliveries.
220
+ */
221
+ complete?: boolean;
222
+ /**
223
+ * Session-scoped monotonic outbound sequence. Server-assigned;
224
+ * clients MUST NOT populate it on producer-side inputs. Gap-free
225
+ * within a single session, starting at 1. Used by the client to:
226
+ * - track `lastSeenSeq` for reconnect (pass it back as
227
+ * `SubscribePayload.fromSeq`);
228
+ * - dedupe deliveries (at-least-once semantics).
229
+ *
230
+ * OPTIONAL because hosted cloud does not yet stamp `seq`;
231
+ * implementations backed by `SessionStreamBuffer`
232
+ * (OSS `@ggui-ai/mcp-server`) always populate it. When absent,
233
+ * clients treat deliveries as single-shot with no replay possible.
234
+ * This becomes required once the hosted runtime supports replay.
235
+ */
236
+ seq?: number;
237
+ /**
238
+ * Protocol schema version stamped by the producer. Pre-launch:
239
+ * advisory — consumers MUST NOT reject on mismatch. A future
240
+ * launch-cutover change tightens policy to `UPGRADE_REQUIRED` when
241
+ * the received major diverges from the client's known major.
242
+ *
243
+ * See `PROTOCOL_SCHEMA_VERSION` for the current value.
244
+ */
245
+ schemaVersion?: string;
246
+ }
247
+ /**
248
+ * Payload for stream message (Server → Client)
249
+ * Delivers streaming text chunks from the agent in real-time.
250
+ */
251
+ export interface StreamPayload {
252
+ sessionId: string;
253
+ /** Text chunk from agent. Empty string on final (done=true) message. */
254
+ chunk: string;
255
+ /** Whether this is the final chunk in the stream. */
256
+ done: boolean;
257
+ }
258
+ /**
259
+ * Payload for error message.
260
+ * The `details` field is {@link JsonValue} to carry any JSON-safe diagnostic data.
261
+ *
262
+ * `code` is typed as `string` (open) so first-party servers can mint
263
+ * new codes without a protocol version bump. Canonical codes shipped
264
+ * by first-party implementations are exported as named constants from
265
+ * `@ggui-ai/protocol::version` so consumers can pattern-match against
266
+ * a typed literal rather than string-sniffing:
267
+ *
268
+ * - `UPGRADE_REQUIRED` — version-handshake mismatch (see
269
+ * {@link SubscribePayload.supportedVersions} /
270
+ * {@link AckPayload.serverVersion}).
271
+ *
272
+ * Other codes emitted by first-party servers are free-form strings.
273
+ */
274
+ export interface ErrorPayload {
275
+ code: string;
276
+ message: string;
277
+ /** Additional diagnostic information. Typed as {@link JsonValue} (any JSON-safe value). */
278
+ details?: JsonValue;
279
+ }
280
+ /**
281
+ * Payload for `channel_subscribe` (Client → Server). Tells the server
282
+ * to begin polling the channel's `streamSpec[ch].source.tool` on the
283
+ * iframe's behalf and fan results out as `channel_payload` frames.
284
+ *
285
+ * Idempotent on reconnect: replaying the same `{sessionId, channelName,
286
+ * pollIntervalMs?, args?}` triple after a WS disconnect re-binds the
287
+ * existing subscription rather than minting a duplicate. The server is
288
+ * authoritative on `pollIntervalMs` — clients propose, server caps to
289
+ * its policy floor.
290
+ */
291
+ export interface ChannelSubscribePayload {
292
+ /** Active session id from the iframe's bootstrap. */
293
+ sessionId: string;
294
+ /** Active app id from the iframe's bootstrap. */
295
+ appId: string;
296
+ /** Stack item the channel belongs to (so the server can resolve `streamSpec[channelName]`). */
297
+ stackItemId: string;
298
+ /** Channel name as keyed in `streamSpec`. The source.tool comes from the contract. */
299
+ channelName: string;
300
+ /**
301
+ * Optional client-side poll cadence override (milliseconds). The
302
+ * server clamps to its configured floor (default 1000ms) and ceiling
303
+ * (default 60000ms). Absent ⇒ server default (typically 10000ms).
304
+ */
305
+ pollIntervalMs?: number;
306
+ /**
307
+ * Optional arguments object merged into the `source.tool` call. Layered
308
+ * over `streamSpec[ch].source.args`; client values win on key collision.
309
+ * Use for "subscribe to a specific city's weather" style scoping.
310
+ */
311
+ args?: JsonObject;
312
+ }
313
+ /**
314
+ * Payload for `channel_unsubscribe` (Client → Server). Idempotent: the
315
+ * server tolerates an unsubscribe for an unknown `{sessionId,
316
+ * channelName}` pair (treats as a no-op + ack). Closing the WebSocket
317
+ * implicitly unsubscribes all channels on that subscriber — this
318
+ * message is for fine-grained mid-session cancellation.
319
+ */
320
+ export interface ChannelUnsubscribePayload {
321
+ sessionId: string;
322
+ appId: string;
323
+ stackItemId: string;
324
+ channelName: string;
325
+ }
326
+ /**
327
+ * Payload for `channel_payload` (Server → Client). A single result of
328
+ * the server's poll against `streamSpec[channelName].source.tool`,
329
+ * matching the existing component-facing `StreamDelivery` shape.
330
+ *
331
+ * `mode: 'replace'` collapses the channel's history to this payload;
332
+ * `mode: 'append'` appends to the tail. The runtime forwards both to
333
+ * the component's `useChannel(name)` subscription with the same
334
+ * semantics as iframe-polled payloads.
335
+ */
336
+ export interface ChannelPayloadFrame {
337
+ sessionId: string;
338
+ appId: string;
339
+ stackItemId: string;
340
+ channelName: string;
341
+ /** Server-monotonic sequence for this channel — gap-detection on the client. */
342
+ seq: number;
343
+ /** Server clock at fan-out — useful for staleness checks on slow clients. */
344
+ ts: string;
345
+ /** `replace` (full snapshot) or `append` (delta). Mirrors `StreamDelivery.mode`. */
346
+ mode: StreamChannelMode;
347
+ /** Raw tool output validated against `streamSpec[ch].schema` server-side. */
348
+ payload: JsonValue;
349
+ /**
350
+ * Channel quiescence marker. When `true`, the server has decided the
351
+ * channel is finished (e.g., source tool returned a terminal status)
352
+ * and will not poll further. Client surfaces this as `isComplete`.
353
+ */
354
+ complete?: boolean;
355
+ }
356
+ /**
357
+ * Payload for `channel_error` (Server → Client). Either a subscribe
358
+ * rejection (channel name unknown, tool not in `streamWebSocketLocalTools`,
359
+ * token expired) OR a poll-time failure (source.tool threw / timed
360
+ * out). Clients distinguish via {@link code}.
361
+ *
362
+ * Defined error codes (extend in the SPEC's live-channel table as new
363
+ * cases land):
364
+ *
365
+ * - `CHANNEL_UNKNOWN` — channelName not present in streamSpec.
366
+ * - `CHANNEL_NOT_LOCAL` — `source.tool` not in `streamWebSocketLocalTools`; iframe must poll directly.
367
+ * - `STACK_ITEM_NOT_FOUND` — `stackItemId` not on the session.
368
+ * - `SUBSCRIBE_UNAUTHORIZED` — bootstrap token expired or session-mismatch.
369
+ * - `POLL_FAILED` — source.tool invocation threw. `details` carries the error.
370
+ */
371
+ export interface ChannelErrorPayload {
372
+ sessionId: string;
373
+ channelName: string;
374
+ code: 'CHANNEL_UNKNOWN' | 'CHANNEL_NOT_LOCAL' | 'STACK_ITEM_NOT_FOUND' | 'SUBSCRIBE_UNAUTHORIZED' | 'POLL_FAILED' | (string & {});
375
+ message: string;
376
+ details?: JsonValue;
377
+ }
378
+ /**
379
+ * Payload for pop message (Client → Server: remove top card from stack)
380
+ */
381
+ export interface PopPayload {
382
+ sessionId: string;
383
+ }
384
+ /**
385
+ * Payload for close message (Client → Server: close session)
386
+ */
387
+ export interface ClosePayload {
388
+ sessionId: string;
389
+ }
390
+ /**
391
+ * Payload for get_stack message (Client → Server: get stack info)
392
+ */
393
+ export interface GetStackPayload {
394
+ sessionId: string;
395
+ }
396
+ /**
397
+ * Generation strategy controls how ggui resolves UI generation requests.
398
+ *
399
+ * - `strict` — Only use predefined/cached blueprints. Fails if no match found.
400
+ * - `balanced` — Try blueprint matching first, fall back to LLM generation.
401
+ * - `creative` — Always generate fresh UI via LLM (no blueprint matching).
402
+ */
403
+ export type GenerationStrategy = 'strict' | 'balanced' | 'creative';
404
+ /**
405
+ * Payload for the legacy `generate` WS message — the pre-handshake-first
406
+ * direct-generation entry point. The canonical mint path is the
407
+ * `ggui_new_session` → `ggui_handshake` → `ggui_push` tool chain; this
408
+ * payload survives only because `@ggui-ai/ggui-react` /
409
+ * `@ggui-ai/ggui-react-native` SDKs still expose a `useGenerate()` hook
410
+ * that POSTs through the WS surface for one-shot UI generation.
411
+ *
412
+ * Several flat fields here (`adapters`, `actions`) are legacy shapes
413
+ * superseded by `DataContract.agentCapabilities` + `DataContract.actionSpec`;
414
+ * they remain on the type for SDK back-compat but new code MUST author
415
+ * via the handshake-first chain.
416
+ *
417
+ * Generic `TProps` defaults to {@link JsonObject} for the data payload.
418
+ * Generic `TContext` defaults to {@link JsonObject} for generator context hints.
419
+ *
420
+ * @deprecated Use `ggui_handshake` + `ggui_push` (the canonical mint
421
+ * path). This payload is retained only for the legacy `useGenerate()`
422
+ * SDK hook surface.
423
+ */
424
+ export interface GeneratePayload<TProps = JsonObject, TContext = JsonObject> {
425
+ sessionId: string;
426
+ prompt: string;
427
+ /** Human-readable description (for non-LLM producers) */
428
+ description?: string;
429
+ /** Context hints for the generator */
430
+ context?: TContext;
431
+ /** JSON Schema for form validation */
432
+ schema?: JsonSchema;
433
+ /**
434
+ * @deprecated Legacy flat shape. Declare via
435
+ * `DataContract.actionSpec` instead.
436
+ */
437
+ actions?: Array<{
438
+ id: string;
439
+ label: string;
440
+ description?: string;
441
+ icon?: string;
442
+ variant?: string;
443
+ confirm?: boolean | string;
444
+ disabled?: boolean;
445
+ }>;
446
+ /** Device/viewport context for responsive UI generation */
447
+ interfaceContext?: InterfaceContext;
448
+ /** Generation strategy (default: 'balanced') */
449
+ strategy?: GenerationStrategy;
450
+ /** Predefined blueprint name to use (for strict/balanced strategy) */
451
+ blueprintName?: string;
452
+ /** Props data to pass to the blueprint */
453
+ data?: TProps;
454
+ /** Data contract from negotiation (agreed props/actions shape) */
455
+ contract?: DataContract;
456
+ /** UX/presentation instructions for the generator */
457
+ instructions?: string;
458
+ /** Specific model override for generation */
459
+ model?: string;
460
+ /**
461
+ * Existing stack-item id for repair — reuses the broken component's
462
+ * slot instead of creating a new one.
463
+ */
464
+ stackItemId?: string;
465
+ }
466
+ /**
467
+ * Progress step during UI generation
468
+ */
469
+ export type ProgressStep = 'queued' | 'primitives' | 'writing' | 'compiling';
470
+ /**
471
+ * Payload for progress message (Server → Client)
472
+ */
473
+ export interface ProgressPayload {
474
+ sessionId: string;
475
+ stackItemId: string;
476
+ step: ProgressStep;
477
+ message: string;
478
+ }
479
+ /**
480
+ * Payload for agent thinking message (Server → Client).
481
+ * Sent immediately when a user message is received, before the agent processes it.
482
+ * Agent message payload — used for both thinking and final messages.
483
+ */
484
+ export type AgentMsgType = 'thinking' | 'chat';
485
+ export interface AgentMsgPayload {
486
+ /** Message type — 'thinking' for status updates, 'chat' for final responses */
487
+ type: AgentMsgType;
488
+ /** Message text from the agent */
489
+ message: string;
490
+ /** Session ID */
491
+ sessionId: string;
492
+ }
493
+ /**
494
+ * Payload for props_update message (Server → Client).
495
+ * Replaces props on an existing rendered component without re-generation.
496
+ */
497
+ export interface PropsUpdatePayload {
498
+ /** Stack-item id of the rendered component being updated. */
499
+ stackItemId: string;
500
+ /** New props — full replacement */
501
+ props: JsonObject;
502
+ }
503
+ /**
504
+ * Payload for url message (Server → Client)
505
+ * Note: shortCode is returned; client constructs full URL using renderUrl from amplify_outputs
506
+ */
507
+ export interface UrlPayload {
508
+ sessionId: string;
509
+ stackItemId: string;
510
+ shortCode: string;
511
+ }
512
+ /**
513
+ * System-level event actions sent from platform to client.
514
+ *
515
+ * - `auth_required` — Agent needs user to authorize an OAuth service.
516
+ * - `credential_ready` — User completed OAuth; credential is available.
517
+ */
518
+ export type SystemAction = 'auth_required' | 'credential_ready';
519
+ /**
520
+ * Payload for system message (Server → Client).
521
+ * Carries platform-level events such as OAuth consent requests.
522
+ */
523
+ export interface SystemPayload {
524
+ action: SystemAction;
525
+ serviceId: string;
526
+ /** Human-readable service name (e.g., "Google", "Slack") */
527
+ displayName?: string;
528
+ /** OAuth scopes the agent is requesting */
529
+ scopes?: string[];
530
+ /** URL the user should open to initiate the OAuth consent flow */
531
+ consentUrl?: string;
532
+ /** Human-readable message explaining why access is needed */
533
+ message?: string;
534
+ /** Status of the credential (used with credential_ready) */
535
+ status?: string;
536
+ /** App ID requesting access (used with auth_required for app-scoped grants) */
537
+ appId?: string;
538
+ /** Session ID for WebSocket context (used with auth_required) */
539
+ sessionId?: string;
540
+ }
541
+ /**
542
+ * Payload for internal:progress message (generator → handler)
543
+ */
544
+ export interface InternalProgressPayload {
545
+ sessionId: string;
546
+ stackItemId: string;
547
+ step: ProgressStep;
548
+ }
549
+ /**
550
+ * Extended AckPayload for legacy `generate` requests. The handshake-first
551
+ * mint path (`ggui_new_session` → `ggui_handshake` → `ggui_push`) does
552
+ * NOT use this ack — it returns its own structured-content envelope.
553
+ *
554
+ * Note: shortCode is returned; client constructs full URL using renderUrl
555
+ * from amplify_outputs.
556
+ *
557
+ * @deprecated Same lifecycle as {@link GeneratePayload}.
558
+ */
559
+ export interface GenerateAckPayload extends AckPayload {
560
+ shortCode: string;
561
+ stackItemId: string;
562
+ /**
563
+ * @deprecated No live producer or consumer. Retained on the type for
564
+ * one minor before structural removal.
565
+ */
566
+ sentViaWebsocket: boolean;
567
+ }
568
+ /**
569
+ * Payload for session message (Server → Client)
570
+ * Sent when an agent creates a session in response to a start invoke.
571
+ */
572
+ export interface SessionPayload {
573
+ sessionId: string;
574
+ }
575
+ /**
576
+ * Payload for `drain_ack` (Server → Client). Sent by `ggui_consume` after
577
+ * it pops an `ActionEnvelope` off a stack item's pending-events pipe, so
578
+ * the iframe-runtime knows the agent received the gesture and can
579
+ * dismiss the per-action toast.
580
+ *
581
+ * Wired entirely server-initiated — there is no `drain_subscribe` from
582
+ * the iframe; the runtime listens on its existing WS connection and
583
+ * filters frames by `eventId`.
584
+ *
585
+ * Named parties: **`ggui_consume` handler** produces (on successful pop);
586
+ * **iframe-runtime** consumes (toast dismissal). Frame loss is
587
+ * inconsequential — the pipe is the single source of truth for the
588
+ * action; drain_ack is the optional UI-resolution signal, the pipe-
589
+ * append + agent drain already happened.
590
+ *
591
+ * @public
592
+ */
593
+ export interface DrainAckPayload {
594
+ /** Active session id from the bootstrap that emitted the action. */
595
+ sessionId: string;
596
+ /** Active app id from the bootstrap that emitted the action. */
597
+ appId: string;
598
+ /** Stack item the drained event was queued on. */
599
+ stackItemId: string;
600
+ /**
601
+ * Server-assigned `ActionEnvelope.id` of the specific event that
602
+ * was drained. The iframe-runtime keys its toast resolution on this
603
+ * id to dismiss the matching toast.
604
+ */
605
+ eventId: string;
606
+ /**
607
+ * ISO 8601 UTC timestamp of when the pop landed (server clock). Used
608
+ * by the iframe for end-to-end latency telemetry (`drainedAt -
609
+ * submittedAt` becomes the submit→consume latency).
610
+ */
611
+ drainedAt: string;
612
+ }
613
+ //# sourceMappingURL=live-channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-channel.d.ts","sourceRoot":"","sources":["../../src/types/live-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,EACT,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;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H,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ /**
2
+ * LLM Provider and Model Types for BYOK (Bring Your Own Key)
3
+ *
4
+ * Model IDs use LiteLLM format: "provider/model-name"
5
+ * This allows direct passthrough to LiteLLM proxy without transformation.
6
+ *
7
+ * Pricing last verified: March 2026
8
+ * Sources:
9
+ * https://docs.anthropic.com/en/docs/about-claude/pricing
10
+ * https://developers.openai.com/api/docs/pricing/
11
+ * https://ai.google.dev/gemini-api/docs/pricing
12
+ */
13
+ export type LLMProvider = "anthropic" | "google" | "openai" | "openrouter";
14
+ export declare const PROVIDER_INFO: Record<LLMProvider, {
15
+ displayName: string;
16
+ keyPrefix: string;
17
+ }>;
18
+ export type ModelId = "anthropic/claude-haiku-4-5" | "anthropic/claude-sonnet-4-6" | "anthropic/claude-opus-4-6" | "gemini/gemini-3.1-flash-lite-preview" | "gemini/gemini-3-flash-preview" | "gemini/gemini-3.1-pro-preview" | "openai/gpt-5.3-codex" | "openai/gpt-5.4" | "openai/gpt-5.4-mini" | "openai/gpt-5.4-nano";
19
+ export type ModelTier = "fast" | "balanced" | "premium";
20
+ export interface ModelConfig {
21
+ id: ModelId;
22
+ provider: LLMProvider;
23
+ displayName: string;
24
+ tier: ModelTier;
25
+ costs: {
26
+ inputPer1M: number;
27
+ outputPer1M: number;
28
+ };
29
+ maxTokens: number;
30
+ supportsTools: boolean;
31
+ supportsCaching?: boolean;
32
+ supportsThinking?: boolean;
33
+ }
34
+ export declare const MODEL_REGISTRY: Record<ModelId, ModelConfig>;
35
+ /**
36
+ * Default model for generation
37
+ */
38
+ export declare const DEFAULT_MODEL: ModelId;
39
+ export declare function isValidModelId(id: string): id is ModelId;
40
+ /**
41
+ * Get provider name from a LiteLLM-format model ID.
42
+ * Returns 'anthropic' as default for unrecognized formats.
43
+ */
44
+ export declare function getProviderForModel(modelId: string): LLMProvider;
45
+ /**
46
+ * Validate LiteLLM format: "provider/model-name"
47
+ */
48
+ export declare function isValidLiteLLMFormat(modelId: string): boolean;
49
+ /**
50
+ * Get all model IDs for a given provider.
51
+ */
52
+ export declare function getModelsForProvider(provider: LLMProvider): ModelId[];
53
+ /**
54
+ * Get all model IDs for a given tier.
55
+ */
56
+ export declare function getModelsForTier(tier: ModelTier): ModelId[];
57
+ /**
58
+ * Select the default model for a given tier.
59
+ */
60
+ export declare function selectModelByTier(tier: ModelTier): ModelId;
61
+ //# sourceMappingURL=llm.d.ts.map