@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 @@
1
+ {"version":3,"file":"data-contract.d.ts","sourceRoot":"","sources":["../../src/types/data-contract.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CACtC;AAED;;;;;;;;;GASG;AACH,MAAM,MAA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
4
+ // describing one screen of generated UI. Defines the wire surface the
5
+ // component compiles against AND the runtime surface the agent reads
6
+ // back via `ggui_consume`.
7
+ //
8
+ // Mental model — four typed specs + two catalogs:
9
+ //
10
+ // propsSpec : agent → client one-shot (initial render data)
11
+ // streamSpec : agent → client live (live-channel emits)
12
+ // actionSpec : client → agent gesture (discrete events;
13
+ // agent reacts on next turn via `ggui_consume`)
14
+ // contextSpec : client → agent state (observable last-write-wins)
15
+ // agentCapabilities : catalog of MCP tools the contract references
16
+ // (cross-ref target for `actionSpec[*].nextStep`
17
+ // and `streamSpec[*].source.tool`)
18
+ // clientCapabilities : catalog of browser-capability hooks the component
19
+ // imports (`useGeolocation`, `useClipboardWrite`, …)
20
+ //
21
+ // Placement rule for the two inbound specs (actionSpec vs contextSpec):
22
+ // "does this thing need the agent's next-turn reasoning?" Yes →
23
+ // actionSpec (actions drive turns). No → contextSpec (context observes
24
+ // state). There is no third category.
25
+ //
26
+ // Shape: `actionSpec` / `streamSpec` / `contextSpec` are flat
27
+ // `Record<name, Entry>` maps. `propsSpec` is a wrapper
28
+ // `{description?, properties: Record<name, Entry>}` — `properties` is
29
+ // the JSON Schema field name for a property bag, and the wrapper-level
30
+ // `description` documents the props contract as a whole.
31
+ //
32
+ // Every entry under `propsSpec.properties` / `actionSpec` / `streamSpec`
33
+ // / `contextSpec` is a WRAPPER that contains a JSON Schema in its
34
+ // `schema:` field; the JSON Schema does NOT sit flat at the entry level.
35
+ // (The #1 LLM authoring mistake. See {@link PropEntry} / {@link ActionEntry}.)
36
+ /** Locked default applied when {@link StreamChannelEntry.mode} is omitted. */
37
+ export const DEFAULT_STREAM_CHANNEL_MODE = 'append';
38
+ /** Locked default applied when {@link StreamChannelEntry.replay} is omitted. */
39
+ export const DEFAULT_STREAM_REPLAY_POLICY = 'none';
40
+ /** Locked default applied when {@link StreamChannelEntry.complete} is omitted. */
41
+ export const DEFAULT_STREAM_CHANNEL_COMPLETE = false;
42
+ /**
43
+ * Frozen singleton instance of {@link RefreshInput}. Pass this to
44
+ * refresh-tool invocations instead of a fresh `{}` literal so that:
45
+ *
46
+ * - Every call site emits exactly the same reference (cheap identity
47
+ * checks in mocks / spies / test harnesses).
48
+ * - `Object.freeze` catches accidental mutation that would otherwise
49
+ * surface as cross-invocation interference in long-running servers.
50
+ */
51
+ export const EMPTY_REFRESH_INPUT = Object.freeze({});
52
+ /** Locked default applied when {@link ContextEntry.debounceMs}
53
+ * is omitted. */
54
+ export const DEFAULT_CONTEXT_DEBOUNCE_MS = 300;
55
+ /**
56
+ * Derive a JSON-safe default value for a {@link ContextEntry}.
57
+ *
58
+ * Resolution order:
59
+ * 1. `entry.default` (if author provided)
60
+ * 2. Schema-typed fallback:
61
+ * - `string` → `''`
62
+ * - `number` / `integer` → `0`
63
+ * - `boolean` → `false`
64
+ * - `array` → `[]`
65
+ * - `object` → `{}`
66
+ * - `null` → `null`
67
+ * 3. `undefined` (caller validates / rejects)
68
+ *
69
+ * Push-time validators MUST reject contextSpec entries that resolve
70
+ * to `undefined` here (e.g., schema is `oneOf` with no clear primitive
71
+ * type — author MUST provide an explicit `default` for such schemas).
72
+ *
73
+ * Consumed by the boilerplate generator's useState emission and by
74
+ * the push-time validator's default-derivability rule.
75
+ *
76
+ * @public
77
+ */
78
+ export function deriveContextDefault(entry) {
79
+ if (entry.default !== undefined)
80
+ return entry.default;
81
+ const t = entry.schema?.type;
82
+ switch (t) {
83
+ case 'string': return '';
84
+ case 'number': return 0;
85
+ case 'integer': return 0;
86
+ case 'boolean': return false;
87
+ case 'array': return [];
88
+ case 'object': return {};
89
+ case 'null': return null;
90
+ default: return undefined;
91
+ }
92
+ }
93
+ /**
94
+ * Maximum byte size (UTF-8) of a single contextSpec slot's value
95
+ * accepted by `ggui_runtime_sync_context`. Values larger than this
96
+ * reject with `CONTEXT_TOO_LARGE`. contextSpec is observable state for
97
+ * the agent — content storage belongs on propsSpec / streamSpec / a
98
+ * tool call.
99
+ */
100
+ export const CONTEXT_SLOT_VALUE_MAX_BYTES = 16 * 1024;
101
+ /**
102
+ * Maximum byte size (UTF-8) of the full contextSpec snapshot (sum of
103
+ * all slot values) accepted by `ggui_runtime_sync_context`. Snapshots
104
+ * larger than this reject with `CONTEXT_TOO_LARGE`.
105
+ */
106
+ export const CONTEXT_SNAPSHOT_MAX_BYTES = 64 * 1024;
107
+ /**
108
+ * Maximum number of slots in a contextSpec snapshot. Snapshots with
109
+ * more slots reject with `CONTEXT_TOO_LARGE`.
110
+ */
111
+ export const CONTEXT_SNAPSHOT_MAX_SLOTS = 50;
@@ -0,0 +1,182 @@
1
+ import type { JsonValue } from './data-contract';
2
+ /**
3
+ * Event types that flow from user to agent
4
+ */
5
+ export type EventType = 'data:submit' | 'data:change' | 'lifecycle:session_start' | 'lifecycle:session_end' | 'lifecycle:stack_push' | 'lifecycle:stack_pop' | 'lifecycle:focus' | 'lifecycle:blur' | 'interaction:click' | 'interaction:hover' | 'interaction:scroll' | 'error:validation' | 'error:connection';
6
+ /**
7
+ * Payload shape for `data:submit` events emitted by `useAction()`.
8
+ *
9
+ * Actions ALWAYS drive turns — every action emits an event the agent
10
+ * reacts to on its next turn through `ggui_consume`. There is no
11
+ * synchronous server-side dispatch in agent-mediated deployments. The
12
+ * optional `tool` hint mirrors the active stack item's
13
+ * `actionSpec[action].nextStep` so consumers (the WS-direct
14
+ * `wiredActionRouter` for agent-less `ggui serve` deployments, and
15
+ * telemetry on agent-mediated deployments) see which tool the agent
16
+ * intends to call next without re-looking-up the contract.
17
+ *
18
+ * @typeParam TData - Type of the action payload (defaults to `unknown`).
19
+ */
20
+ export interface ActionEventValue<TData = unknown> {
21
+ /** Action ID from the contract (e.g., "submit", "archive"). */
22
+ action: string;
23
+ /** Action payload (e.g., form data). */
24
+ data: TData;
25
+ /**
26
+ * MCP tool name mirrored from the active stack item's
27
+ * `actionSpec[action].nextStep` (when the author declared one).
28
+ * Absent when the action has no `nextStep` — the agent decides the
29
+ * next tool freely from broader context.
30
+ *
31
+ * Consumer behavior:
32
+ * - Agent-mediated deployments: read by the agent on `ggui_consume`
33
+ * as a hint; agent decides whether to honor it.
34
+ * - WS-direct agent-less deployments (`ggui serve`): the
35
+ * `wiredActionRouter` fires this tool synchronously when present.
36
+ *
37
+ * **Disagreement policy:** if both the envelope's `tool` and the
38
+ * server's `actionSpec[action].nextStep` are present and disagree,
39
+ * the **client-populated value wins** (client is the source of truth
40
+ * for what the user actually saw).
41
+ */
42
+ tool?: string;
43
+ }
44
+ /**
45
+ * Inbound live-channel envelope — the body of a `type: 'action'`
46
+ * WebSocket message.
47
+ *
48
+ * Symmetric companion to the outbound {@link StreamEnvelope}. Flat,
49
+ * narrow, and limited to fields the server actually enforces or
50
+ * diagnostic fields real consumers populate today.
51
+ *
52
+ * Fields that are NOT on this envelope, and why:
53
+ * - `appId` — the server resolves it from the session; client-claimed
54
+ * values are ignored for enforcement.
55
+ * - `user` / `userId` / `deviceInfo` / `interfaceContext` — diagnostic
56
+ * session metadata captured at subscribe time, not per-delivery.
57
+ * - `componentId` / `contractHash` — diagnostic; no enforcement
58
+ * consumer.
59
+ * - `timestamp` — the server uses its own clock for ordering + log
60
+ * emission; client-supplied timestamps aren't authoritative.
61
+ * - `correlationId` — the doctrine names this for agent-push ↔ user
62
+ * action pairing; `stackItemId` covers the narrow case today.
63
+ *
64
+ * Required fields map to existing enforcement concerns; optional fields
65
+ * are doctrine-aligned forward-compat additions that cost nothing on the
66
+ * wire when omitted.
67
+ */
68
+ export interface ActionEnvelope<TPayload = JsonValue> {
69
+ /**
70
+ * Session identity. Server enforces subscriber-session binding —
71
+ * envelopes whose sessionId doesn't match the ws subscriber's bound
72
+ * session are rejected (SESSION_MISMATCH).
73
+ */
74
+ sessionId: string;
75
+ /**
76
+ * Action / event type. Gated by the active stack item's
77
+ * `subscription.events` allowlist (falling back to
78
+ * `DEFAULT_SUBSCRIPTION`).
79
+ */
80
+ type: EventType;
81
+ /**
82
+ * Payload for the action. For `type: 'data:submit'` this carries the
83
+ * {@link ActionEventValue} shape (`{action, data?, tool?}`) where
84
+ * `data` is validated against the stack item's
85
+ * `actionSpec[action].schema`. For non-data:submit types the payload
86
+ * is free-form — no schema enforcement.
87
+ */
88
+ payload?: TPayload;
89
+ /**
90
+ * Stack item the action originated from. Authoritative for contract
91
+ * lookup when present. Server falls back to
92
+ * `session.currentStackIndex` when absent — that fallback lets
93
+ * agents that have popped forward between emit and ingress still
94
+ * process legitimate in-flight actions.
95
+ */
96
+ stackIndex?: number;
97
+ /**
98
+ * Stable stack-item identifier. Forward-compat with the
99
+ * three-channel-topology doctrine's `correlationId` semantics — when
100
+ * `stackItemId` is present and matches a stack item's `id`, server MAY
101
+ * prefer stackItemId-based contract lookup over positional stackIndex.
102
+ */
103
+ stackItemId?: string;
104
+ /**
105
+ * Client-monotonic sequence number for at-least-once dedup. Declared
106
+ * shape; no server enforcement today (no inbound dedup infrastructure
107
+ * yet). Clients SHOULD populate when their transport can replay
108
+ * (e.g., reconnect-with-backfill); server SHOULD dedup by
109
+ * `(sessionId, clientSeq)` when dedup lands.
110
+ */
111
+ clientSeq?: number;
112
+ /**
113
+ * Protocol schema version stamped by the producer. Pre-launch:
114
+ * advisory — consumers MUST NOT reject on mismatch. A future
115
+ * launch-cutover change tightens policy to `UPGRADE_REQUIRED` when
116
+ * the received major diverges from the client's known major.
117
+ *
118
+ * See `PROTOCOL_SCHEMA_VERSION` for the current value.
119
+ */
120
+ schemaVersion?: string;
121
+ }
122
+ /**
123
+ * Event subscription configuration.
124
+ *
125
+ * @deprecated Pre-actionSpec event-filtering model. Today's flow:
126
+ * every action emits a `data:submit` event the agent receives via
127
+ * `ggui_consume`; non-`data:submit` event types are vestigial. Kept
128
+ * only for older WS clients that still send `subscribe` with these
129
+ * filters — new code MUST NOT consult this type.
130
+ */
131
+ export interface EventSubscription {
132
+ /** Global event types to subscribe to */
133
+ events: EventType[];
134
+ /** Per-component overrides for event filtering and streaming */
135
+ components?: Record<string, {
136
+ /** Whether to stream real-time change events for this component */
137
+ stream?: boolean;
138
+ /** Component-specific event types (overrides global list) */
139
+ events?: EventType[];
140
+ }>;
141
+ }
142
+ /**
143
+ * Default subscription when agent doesn't specify.
144
+ *
145
+ * @deprecated See {@link EventSubscription}.
146
+ */
147
+ export declare const DEFAULT_SUBSCRIPTION: EventSubscription;
148
+ /**
149
+ * Emitted when an MCP server requires OAuth credentials that the user
150
+ * has not yet granted. The frontend should display a consent prompt
151
+ * linking to {@link consentUrl}.
152
+ */
153
+ export interface McpAuthRequiredEvent {
154
+ type: 'system';
155
+ action: 'auth_required';
156
+ /** Identifier of the external service (e.g. `'github'`, `'slack'`) */
157
+ serviceId: string;
158
+ /** Human-readable service name shown in the consent UI */
159
+ displayName: string;
160
+ /** OAuth scopes being requested (optional — omitted when the service uses fixed scopes) */
161
+ scopes?: string[];
162
+ /** URL the user should visit to grant consent */
163
+ consentUrl: string;
164
+ /** Explanatory message for the user (e.g. "GitHub access is required to list repositories") */
165
+ message: string;
166
+ }
167
+ /**
168
+ * Emitted after the user completes (or denies) the OAuth consent flow.
169
+ * The frontend should dismiss the consent prompt and, if `status` is
170
+ * `'ready'`, retry the operation that triggered the auth request.
171
+ */
172
+ export interface McpCredentialReadyEvent {
173
+ type: 'system';
174
+ action: 'credential_ready';
175
+ /** Identifier of the external service that was authorized */
176
+ serviceId: string;
177
+ /** Whether the credential is now available or the user denied access */
178
+ status: 'ready' | 'denied';
179
+ }
180
+ /** Union of all system events emitted by the MCP credential proxy */
181
+ export type McpCredentialSystemEvent = McpAuthRequiredEvent | McpCredentialReadyEvent;
182
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,SAAS,GAEjB,aAAa,GACb,aAAa,GAEb,yBAAyB,GACzB,uBAAuB,GACvB,sBAAsB,G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ACf,MAAM,EAAE,eAAe,CAAC;IACxB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,2FAA2F;IAC3F,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,+FAA+F;IAC/F,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,kBAAkB,CAAC;IAC3B,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC5B;AAED,qEAAqE;AACrE,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,GAAG,uBAAuB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Default subscription when agent doesn't specify.
3
+ *
4
+ * @deprecated See {@link EventSubscription}.
5
+ */
6
+ export const DEFAULT_SUBSCRIPTION = {
7
+ events: ['data:submit', 'lifecycle:session_end'],
8
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * UI Feedback types -- end-user ratings for generated UIs.
3
+ *
4
+ * Users can rate each rendered page with love/dislike/other.
5
+ * Feedback is sent via WebSocket and stored server-side.
6
+ */
7
+ /**
8
+ * Feedback rating options for a generated UI page.
9
+ */
10
+ export type FeedbackRating = 'love' | 'dislike' | 'other';
11
+ /**
12
+ * Input payload for submitting UI feedback via WebSocket.
13
+ */
14
+ export interface UIFeedbackPayload {
15
+ /** Page (stack item) being rated */
16
+ stackItemId: string;
17
+ /** Session the page belongs to */
18
+ sessionId: string;
19
+ /** Rating type */
20
+ rating: FeedbackRating;
21
+ /** Free-text comment (required when rating is 'other', optional otherwise) */
22
+ comment?: string;
23
+ }
24
+ //# sourceMappingURL=feedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/types/feedback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB;IAClB,MAAM,EAAE,cAAc,CAAC;IACvB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * UI Feedback types -- end-user ratings for generated UIs.
3
+ *
4
+ * Users can rate each rendered page with love/dislike/other.
5
+ * Feedback is sent via WebSocket and stored server-side.
6
+ */
7
+ export {};
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Lifecycle states a {@link GadgetHook} reports through its
3
+ * `status` field. Implementations MUST transition through these in a
4
+ * predictable order; the UI generator's boilerplate may render
5
+ * status-conditioned UI (e.g., a "Tap to start" CTA on `'idle'`, a
6
+ * spinner on `'prompting'`, an error banner on `'denied' | 'error'`).
7
+ *
8
+ * - `'idle'` — hook mounted; no `start()` invoked yet.
9
+ * - `'prompting'` — browser permission UI surfaced; awaiting user.
10
+ * - `'active'` — gadget in flight (mic recording, location
11
+ * stream open, camera frame loop running, …). For
12
+ * one-shot gadgets (`navigator.share`), this
13
+ * status may not be observed.
14
+ * - `'completed'` — terminal success state. `value` populated.
15
+ * - `'denied'` — terminal failure: user (or platform policy)
16
+ * refused permission. `error.code === 'permission_denied'`.
17
+ * - `'error'` — terminal failure: any other error.
18
+ */
19
+ export type GadgetStatus = 'idle' | 'prompting' | 'active' | 'completed' | 'denied' | 'error';
20
+ /**
21
+ * Shape of {@link GadgetHook}'s `error` field when the hook is
22
+ * in a terminal-failure status (`'denied'` / `'error'`).
23
+ *
24
+ * `code` is a closed set today and MAY be extended with `(string &
25
+ * {})` in a future minor — consumers MUST handle unknown codes by
26
+ * falling through to a default branch instead of throwing.
27
+ *
28
+ * `message` is author-readable; safe to surface in UI. Hooks SHOULD
29
+ * NOT include raw stack traces here (those belong on hook-internal
30
+ * logging, not on the public error surface).
31
+ */
32
+ export interface GadgetError {
33
+ /**
34
+ * Canonical failure code. Implementations MUST set one of:
35
+ *
36
+ * - `'permission_denied'` — user refused the browser-permission
37
+ * prompt OR a platform policy (iframe sandbox, HTTP origin,
38
+ * enterprise lockdown) blocks the gadget.
39
+ * - `'not_supported'` — the host environment does not implement
40
+ * the underlying API (`!('mediaDevices' in navigator)`).
41
+ * - `'aborted'` — the call was cancelled (e.g., the user
42
+ * closed a `navigator.share` sheet, the hook was unmounted
43
+ * mid-flight).
44
+ * - `'timeout'` — the hook exceeded its configured
45
+ * deadline (e.g., geolocation watch never produced a fix).
46
+ * - `'unknown'` — fallback for failures the hook can't
47
+ * classify; `message` carries the platform string.
48
+ */
49
+ readonly code: 'permission_denied' | 'not_supported' | 'aborted' | 'timeout' | 'unknown';
50
+ /** Short, author-readable failure summary. Safe to surface in UI. */
51
+ readonly message: string;
52
+ }
53
+ /**
54
+ * The interface every browser-capability gadget hook in
55
+ * `@ggui-ai/gadgets` (and any third-party gadget hook
56
+ * registered on a `clientCapabilities` entry) MUST satisfy.
57
+ *
58
+ * Shape generic over:
59
+ *
60
+ * - `TOutput` — the value the gadget produces when active /
61
+ * completed (e.g., a `MediaRecorder`-backed `Blob` for
62
+ * `useMicrophone`, a `GeolocationPosition` for `useGeolocation`).
63
+ * - `TOptions` — the optional configuration passed to the hook (e.g.,
64
+ * `{ enableHighAccuracy: true }` for `useGeolocation`). Defaults to
65
+ * `void` for hooks that take no options.
66
+ *
67
+ * Return-shape contract:
68
+ *
69
+ * - `value` — `TOutput | undefined`. Undefined until the
70
+ * gadget transitions to `'active'` / `'completed'`.
71
+ * - `status` — current lifecycle state; see {@link GadgetStatus}.
72
+ * - `error` — present iff `status` is `'denied'` or `'error'`.
73
+ * - `start()` — invokes the gadget. MUST be idempotent if called
74
+ * while `status === 'active'`. Resolves with the produced value on
75
+ * success, `undefined` on failure (consumers read `error` for
76
+ * diagnostics).
77
+ * - `stop?` — optional cancel/teardown for continuous gadgets
78
+ * (mic stream, geolocation watch). Absent on one-shot gadgets.
79
+ *
80
+ * Why declarative-only on the contract surface:
81
+ *
82
+ * `DataContract.clientCapabilities.gadgets` is package-keyed —
83
+ * `Record<packageName, Record<exportName, { description?, usage? }>>`.
84
+ * Each export entry declares only WHICH export the UI uses (the
85
+ * export name is the inner map key; its grammar — `use`-prefixed
86
+ * hook vs PascalCase component — discriminates kind) and HOW the
87
+ * agent should describe it. It does NOT carry argument schemas,
88
+ * response schemas, or example payloads. Gadget values only become
89
+ * observable to the agent if the UI threads them into a
90
+ * `contextSpec` slot or an `actionSpec` payload —
91
+ * `clientCapabilities.gadgets` itself is an export-declaration
92
+ * catalog, not an RPC channel.
93
+ */
94
+ export interface GadgetHook<TOutput, TOptions = void> {
95
+ (options?: TOptions): {
96
+ /**
97
+ * Current gadget value. Undefined until the hook transitions to
98
+ * `'active'` / `'completed'`. For continuous gadgets (mic stream)
99
+ * this may update on every frame; for one-shot gadgets
100
+ * (`navigator.share`) it settles once on success.
101
+ */
102
+ readonly value: TOutput | undefined;
103
+ /** Lifecycle state; see {@link GadgetStatus}. */
104
+ readonly status: GadgetStatus;
105
+ /** Present iff `status` is `'denied'` or `'error'`. */
106
+ readonly error?: GadgetError;
107
+ /**
108
+ * Invoke the gadget. Idempotent while `status === 'active'`.
109
+ * Resolves to the produced value on success, `undefined` on
110
+ * failure. Consumers read `error` for diagnostics.
111
+ */
112
+ readonly start: () => Promise<TOutput | undefined>;
113
+ /**
114
+ * Optional teardown. Present only on continuous gadgets (mic
115
+ * stream, geolocation watch). Absent on one-shot gadgets
116
+ * (`navigator.share`).
117
+ */
118
+ readonly stop?: () => void;
119
+ };
120
+ }
121
+ //# sourceMappingURL=gadget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gadget.d.ts","sourceRoot":"","sources":["../../src/types/gadget.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,OAAO,CAAC;AAEZ;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACzF,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,WAAW,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAClD,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG;QACpB;;;;;WAKG;QACH,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;QACpC,iDAAiD;QACjD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;QAC9B,uDAAuD;QACvD,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;QAC7B;;;;WAIG;QACH,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;QACnD;;;;WAIG;QACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;KAC5B,CAAC;CACH"}
@@ -0,0 +1,24 @@
1
+ // packages/protocol/src/types/gadget.ts
2
+ //
3
+ // `GadgetHook` generic + the runtime status / error types that
4
+ // every browser-capability gadget hook in `@ggui-ai/gadgets`
5
+ // (and any third-party gadget hook) MUST satisfy.
6
+ //
7
+ // Capabilities differ from agent tools by direction and ownership:
8
+ //
9
+ // - **agentCapabilities** (in `@ggui-ai/protocol`'s
10
+ // `DataContract.agentCapabilities`) — RPC the contract REFERENCES.
11
+ // The agent's MCP toolbox is the source of truth at dispatch time.
12
+ // Catalog declaration is documentation.
13
+ //
14
+ // - **clientCapabilities** (in `DataContract.clientCapabilities`) —
15
+ // browser-capability gadget HOOKS the UI uses. The catalog says
16
+ // "this UI calls `useMicrophone()`"; the value flows from browser →
17
+ // UI → (optionally) into context/action payloads. The agent does
18
+ // NOT invoke these from its side — there is no RPC. The UI hook
19
+ // owns the lifecycle (prompting, status, value, error).
20
+ //
21
+ // The generic below pins what every gadget hook MUST return so the
22
+ // generated boilerplate, the LLM authoring contract, and the
23
+ // `@ggui-ai/gadgets` v1 package all agree on shape.
24
+ export {};