@ggui-ai/iframe-runtime 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/call-tool-unwrap.d.ts +29 -0
  2. package/dist/call-tool-unwrap.js +56 -0
  3. package/dist/channels/props-update.d.ts +19 -0
  4. package/dist/channels/props-update.js +14 -1
  5. package/dist/compiled-validators.d.ts +16 -7
  6. package/dist/compiled-validators.js +41 -8
  7. package/dist/events-polling.d.ts +123 -1
  8. package/dist/events-polling.js +181 -53
  9. package/dist/iframe-runtime.js +65 -64
  10. package/dist/iframe-runtime.meta.json +1 -1
  11. package/dist/mcp-app-iframe-host.d.ts +1 -1
  12. package/dist/meta-parse.d.ts +13 -0
  13. package/dist/meta-parse.js +41 -0
  14. package/dist/observability.d.ts +1 -1
  15. package/dist/provisional-renderer.d.ts +1 -1
  16. package/dist/provisional-renderer.js +1 -1
  17. package/dist/react-renderer.d.ts +13 -1
  18. package/dist/react-renderer.js +87 -17
  19. package/dist/registry-subscribe.d.ts +42 -3
  20. package/dist/registry-subscribe.js +33 -10
  21. package/dist/render-item.d.ts +9 -0
  22. package/dist/render-item.js +7 -1
  23. package/dist/runtime-telemetry.d.ts +53 -0
  24. package/dist/runtime-telemetry.js +74 -0
  25. package/dist/runtime.d.ts +84 -0
  26. package/dist/runtime.js +522 -100
  27. package/dist/server.d.ts +19 -0
  28. package/dist/server.js +19 -0
  29. package/dist/shims/app-components.js +1 -0
  30. package/dist/shims/components.js +1 -0
  31. package/dist/shims/compositions.js +1 -0
  32. package/dist/shims/design.js +1 -0
  33. package/dist/shims/gadgets.js +1 -0
  34. package/dist/shims/interact.js +1 -0
  35. package/dist/shims/jsx-runtime.js +1 -0
  36. package/dist/shims/primitives.js +1 -0
  37. package/dist/shims/react-dom.js +1 -0
  38. package/dist/shims/react.js +1 -0
  39. package/dist/shims/templates.js +1 -0
  40. package/dist/shims/tokens.js +1 -0
  41. package/dist/shims/wire.js +1 -0
  42. package/dist/system-cards/ProtocolProbeCard.js +1 -1
  43. package/dist/system-cards/UiFeedbackCard.d.ts +1 -1
  44. package/dist/system-cards/UiFeedbackCard.js +1 -1
  45. package/dist/ui-feedback-chrome.js +7 -4
  46. package/dist/zod-jitless.d.ts +1 -0
  47. package/dist/zod-jitless.js +18 -0
  48. package/package.json +8 -7
package/dist/runtime.d.ts CHANGED
@@ -1,3 +1,30 @@
1
+ /**
2
+ * `@ggui-ai/iframe-runtime` iframe runtime entry.
3
+ *
4
+ * This is the file esbuild bundles into `dist/iframe-runtime.js`. The
5
+ * thin-shell HTML loads it via `<script type="module" src=".../iframe-runtime.js">`;
6
+ * on import the side-effects below take over: build a status DOM,
7
+ * postMessage `ui/initialize` to the parent, parse the bootstrap, open
8
+ * the WebSocket, run the version handshake, and mount the render
9
+ * placeholder.
10
+ *
11
+ * Boot sequence:
12
+ * - Boot from the `_meta["ai.ggui/render"]` slice received via
13
+ * `ui/initialize`.
14
+ * - Open the WebSocket, run the subscribe handshake.
15
+ * - Mount the render — either a structural placeholder or, when
16
+ * the renderer hooks are wired, a React mount of `componentCode`.
17
+ *
18
+ * The runtime advertises its build version via a post-`ui/initialize`
19
+ * notification (`ggui:renderer-ready`).
20
+ *
21
+ * Failure surfacing: every parse / handshake failure goes to two
22
+ * places — (1) the in-iframe status line (operator-visible) and
23
+ * (2) a parent-bound `postMessage({type:'ggui:bootstrap-failed', ...})`.
24
+ * The post-message envelope is consumed by the `<McpAppIframe>` host
25
+ * wrapper, which routes it to the host's `onError` callback.
26
+ */
27
+ import './zod-jitless.js';
1
28
  import type { DrainAckPayload, JsonValue, JsonObject, GguiSession } from '@ggui-ai/protocol';
2
29
  import type { WebSocketMessage } from '@ggui-ai/protocol/transport/websocket';
3
30
  import { type McpAppAiGguiRenderMeta, type McpAppBootstrapFailedMessage, type McpAppRendererReadyMessage } from '@ggui-ai/protocol/integrations/mcp-apps';
@@ -47,6 +74,29 @@ export type ConnectAppResult = {
47
74
  * without invoking the full boot pipeline.
48
75
  */
49
76
  export declare function setCurrentApp(app: App): void;
77
+ /**
78
+ * The host's announced color mode, read from the connected App's
79
+ * pre-merged hostContext (`ui/initialize` result, kept current by the
80
+ * App across `host-context-changed`). `undefined` when no App is
81
+ * connected, the host sent no `theme`, or it sent something outside
82
+ * the spec's `'light' | 'dark'` literals (dropped, never guessed —
83
+ * the same tolerant posture as `projectHostContext`).
84
+ *
85
+ * This is the INPUT leg of host-theme adaptation
86
+ * (rnd/gen-ui/beauty/experiments/002-host-theme-adaptation.md, ggui#551):
87
+ * `hostContext.theme` alone reaches only `data-theme` +
88
+ * `color-scheme` via `applyDocumentTheme` — nothing in the token
89
+ * pipeline keys off it, so a dark host painted the light ladder
90
+ * (host-fit 46.0 vs 87.7 with the dark ladder, probe `cc728a8eb`).
91
+ * `buildOpts` consumes this ONLY when the slice stamps no `themeMode`:
92
+ * every operator layer (live provider > per-render override > app
93
+ * default > server default) still wins by being stamped; the host
94
+ * fills the gap where no operator had an opinion.
95
+ *
96
+ * @internal — exported for unit tests (`setCurrentApp` injects the
97
+ * App); production caller is `buildOpts` inside `bootSequence`.
98
+ */
99
+ export declare function hostAnnouncedThemeMode(): 'light' | 'dark' | undefined;
50
100
  /**
51
101
  * @internal — exported for unit tests to reset module state between
52
102
  * scenarios.
@@ -193,6 +243,17 @@ export interface BootSequenceOptions {
193
243
  * arrives, and `hostContext` is captured from `app.getHostContext()`.
194
244
  */
195
245
  readonly preResolvedMeta?: McpAppAiGguiRenderMeta;
246
+ /**
247
+ * Autostart-layer pre-resolution of the read-plane door (ggui#537):
248
+ * a tool result that arrived before `bootSequence` ran carried the
249
+ * view's LOCATOR (`ui://ggui/render/…`) but no bootstrap material —
250
+ * the read-plane-only posture. The runtime cannot read the resource
251
+ * before the App is connected, so the locator is threaded here and
252
+ * resolved via {@link resolveMetaViaReadDoor} right after the
253
+ * handshake, ahead of the Tier 2 tool-result wait. Ignored when
254
+ * `preResolvedMeta` is set.
255
+ */
256
+ readonly preResolvedLocator?: string;
196
257
  /**
197
258
  * How long to wait for the spec-canonical `ui/notifications/tool-result`
198
259
  * notification (Tier 2 of the resolver chain) before failing with
@@ -409,6 +470,29 @@ export declare function extractMetaFromToolResult(params: unknown): McpAppAiGgui
409
470
  * runtime reads it once at autostart.
410
471
  */
411
472
  export declare function readPendingToolResults(): McpAppAiGguiRenderMeta | null;
473
+ /**
474
+ * Sibling of {@link readPendingToolResults} for the read-plane-only
475
+ * posture (ggui#537): the NEWEST buffered tool result that carries a
476
+ * `ui://ggui/render/…` locator but no bootstrap material. Consulted only
477
+ * when the buffer yielded no inline slice; the autostart threads it to
478
+ * `bootSequence` as `preResolvedLocator`, resolved after the handshake.
479
+ */
480
+ export declare function readPendingToolResultLocator(): string | null;
481
+ /**
482
+ * The read-plane door (ggui#537). A server running the read-plane-only
483
+ * posture publishes only the view's identity on the tool result — the
484
+ * `ui://ggui/render/…` locator — and no bootstrap material; the
485
+ * per-render resource that locator names is the self-contained shell,
486
+ * whose document inlines the very envelope this runtime boots from.
487
+ * Ask the HOST to read it (`app.readServerResource` → `resources/read`,
488
+ * proxied by the host's own MCP client — no fetch from this sandbox, so
489
+ * a host CSP without `connect-src` to the server is not in the way),
490
+ * recover the envelope with the protocol's writer/reader pair
491
+ * ({@link readGguiShellEnvelope}), and validate it exactly as an inline
492
+ * slice would be. `null` on any miss (host cannot proxy reads, resource
493
+ * gone, no envelope) — the caller's other tiers still decide.
494
+ */
495
+ export declare function resolveMetaViaReadDoor(app: App, locator: string): Promise<McpAppAiGguiRenderMeta | null>;
412
496
  /**
413
497
  * Render a submit-action's `data` payload as a short inline string
414
498
  * for embedding in a `ui/message` consent prompt. Goal: human-