@ggui-ai/protocol 0.2.0-alpha.4 → 0.3.0-rc.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.
- package/README.md +16 -16
- package/dist/envelope-adapters.d.ts +6 -5
- package/dist/envelope-adapters.d.ts.map +1 -1
- package/dist/envelope-adapters.js +3 -3
- package/dist/envelopes/builders.d.ts +6 -32
- package/dist/envelopes/builders.d.ts.map +1 -1
- package/dist/envelopes/builders.js +3 -25
- package/dist/errors/version-mismatch.d.ts +1 -1
- package/dist/errors/version-mismatch.js +1 -1
- package/dist/gadgets/resolve-app-gadgets.d.ts +10 -0
- package/dist/gadgets/resolve-app-gadgets.d.ts.map +1 -0
- package/dist/gadgets/resolve-app-gadgets.js +19 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts +6 -6
- package/dist/gadgets/resolve-contract-gadgets.js +5 -5
- package/dist/gadgets/stdlib-gadgets.d.ts +1 -1
- package/dist/gadgets/stdlib-gadgets.d.ts.map +1 -1
- package/dist/gadgets/stdlib-gadgets.js +43 -22
- package/dist/iframe-bridge.d.ts +4 -43
- package/dist/iframe-bridge.d.ts.map +1 -1
- package/dist/iframe-bridge.js +4 -141
- package/dist/index.d.ts +60 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -61
- package/dist/integrations/mcp-apps.d.ts +83 -38
- package/dist/integrations/mcp-apps.d.ts.map +1 -1
- package/dist/integrations/mcp-apps.js +98 -52
- package/dist/recommended-prompts.d.ts +1 -1
- package/dist/recommended-prompts.js +1 -1
- package/dist/registry/blueprint-key.d.ts +3 -0
- package/dist/registry/blueprint-key.d.ts.map +1 -1
- package/dist/registry/blueprint-key.js +9 -0
- package/dist/registry/blueprint-stamp.d.ts +12 -0
- package/dist/registry/blueprint-stamp.d.ts.map +1 -0
- package/dist/registry/blueprint-stamp.js +12 -0
- package/dist/registry/canonicalize-contract.d.ts +31 -2
- package/dist/registry/canonicalize-contract.d.ts.map +1 -1
- package/dist/registry/canonicalize-contract.js +125 -13
- package/dist/registry/portable-blueprint.d.ts +64 -0
- package/dist/registry/portable-blueprint.d.ts.map +1 -0
- package/dist/registry/portable-blueprint.js +103 -0
- package/dist/registry/summarize-contract.d.ts +7 -2
- package/dist/registry/summarize-contract.d.ts.map +1 -1
- package/dist/registry/summarize-contract.js +12 -3
- package/dist/registry/variant-key.d.ts +17 -0
- package/dist/registry/variant-key.d.ts.map +1 -0
- package/dist/registry/variant-key.js +22 -0
- package/dist/schema-learning/derive-contract.d.ts +2 -2
- package/dist/schema-learning/derive-contract.js +2 -2
- package/dist/schema-learning/merge.d.ts.map +1 -1
- package/dist/schema-learning/merge.js +3 -2
- package/dist/schemas/app-theme.d.ts +38 -0
- package/dist/schemas/app-theme.d.ts.map +1 -0
- package/dist/schemas/app-theme.js +43 -0
- package/dist/schemas/blueprint.d.ts +30 -11
- package/dist/schemas/blueprint.d.ts.map +1 -1
- package/dist/schemas/blueprint.js +62 -26
- package/dist/schemas/data-contract.d.ts +28 -30
- package/dist/schemas/data-contract.d.ts.map +1 -1
- package/dist/schemas/data-contract.js +26 -26
- package/dist/schemas/handshake-suggestion.d.ts +2 -4
- package/dist/schemas/handshake-suggestion.d.ts.map +1 -1
- package/dist/schemas/handshake-suggestion.js +5 -14
- package/dist/schemas/mcp.d.ts +240 -58
- package/dist/schemas/mcp.d.ts.map +1 -1
- package/dist/schemas/mcp.js +285 -93
- package/dist/schemas/ops-blueprint.d.ts +12 -12
- package/dist/schemas/ops-blueprint.d.ts.map +1 -1
- package/dist/schemas/ops-blueprint.js +14 -24
- package/dist/screen-blueprints/define.d.ts +2 -2
- package/dist/screen-blueprints/match.d.ts +12 -7
- package/dist/screen-blueprints/match.d.ts.map +1 -1
- package/dist/screen-blueprints/match.js +7 -5
- package/dist/screen-blueprints/types.d.ts +14 -18
- package/dist/screen-blueprints/types.d.ts.map +1 -1
- package/dist/transport/websocket.d.ts +5 -26
- package/dist/transport/websocket.d.ts.map +1 -1
- package/dist/types/app-config.d.ts +0 -1
- package/dist/types/app-config.d.ts.map +1 -1
- package/dist/types/auth.d.ts +1 -46
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/blueprint-source.d.ts +123 -0
- package/dist/types/blueprint-source.d.ts.map +1 -0
- package/dist/types/blueprint-source.js +126 -0
- package/dist/types/blueprint.d.ts +25 -18
- package/dist/types/blueprint.d.ts.map +1 -1
- package/dist/types/contract-inference.d.ts +2 -43
- package/dist/types/contract-inference.d.ts.map +1 -1
- package/dist/types/data-contract.d.ts +59 -344
- package/dist/types/data-contract.d.ts.map +1 -1
- package/dist/types/data-contract.js +5 -12
- package/dist/types/events.d.ts +31 -69
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/{render-event.d.ts → ggui-session-event.d.ts} +15 -15
- package/dist/types/ggui-session-event.d.ts.map +1 -0
- package/dist/types/{render-event.js → ggui-session-event.js} +5 -5
- package/dist/types/handshake-suggestion.d.ts +49 -35
- package/dist/types/handshake-suggestion.d.ts.map +1 -1
- package/dist/types/host-context.d.ts +8 -8
- package/dist/types/host-context.d.ts.map +1 -1
- package/dist/types/host-context.js +5 -5
- package/dist/types/invoke.d.ts +1 -13
- package/dist/types/invoke.d.ts.map +1 -1
- package/dist/types/{canvas-lifecycle.d.ts → lifecycle.d.ts} +35 -37
- package/dist/types/lifecycle.d.ts.map +1 -0
- package/dist/types/{canvas-lifecycle.js → lifecycle.js} +12 -14
- package/dist/types/live-channel.d.ts +48 -104
- package/dist/types/live-channel.d.ts.map +1 -1
- package/dist/types/llm.d.ts +13 -24
- package/dist/types/llm.d.ts.map +1 -1
- package/dist/types/llm.js +23 -53
- package/dist/types/mcp.d.ts +55 -176
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/types/mcp.js +2 -2
- package/dist/types/oauth-user-id.d.ts +12 -0
- package/dist/types/oauth-user-id.d.ts.map +1 -0
- package/dist/types/oauth-user-id.js +10 -0
- package/dist/types/portable-blueprint.d.ts +53 -0
- package/dist/types/portable-blueprint.d.ts.map +1 -0
- package/dist/types/portable-blueprint.js +8 -0
- package/dist/types/{session.d.ts → render.d.ts} +51 -53
- package/dist/types/render.d.ts.map +1 -0
- package/dist/types/thread.d.ts.map +1 -1
- package/dist/types/thread.js +3 -3
- package/dist/types/ui-generator.d.ts +5 -46
- package/dist/types/ui-generator.d.ts.map +1 -1
- package/dist/types/ui-generator.js +1 -53
- package/dist/validation/ajv-runtime.d.ts +3 -3
- package/dist/validation/ajv-runtime.d.ts.map +1 -1
- package/dist/validation/ajv-runtime.js +6 -5
- package/dist/validation/contract-validator.d.ts +23 -22
- package/dist/validation/contract-validator.d.ts.map +1 -1
- package/dist/validation/contract-validator.js +28 -26
- package/dist/validation/cross-references.d.ts +3 -3
- package/dist/validation/cross-references.js +3 -3
- package/dist/validation/hygiene-rules.d.ts +9 -9
- package/dist/validation/hygiene-rules.js +13 -13
- package/dist/validation/is-record.d.ts +17 -0
- package/dist/validation/is-record.d.ts.map +1 -0
- package/dist/validation/is-record.js +18 -0
- package/dist/validation/lint-contract.d.ts +1 -1
- package/dist/validation/lint-contract.js +3 -3
- package/dist/validation/name-invariants.d.ts +4 -4
- package/dist/validation/name-invariants.js +4 -4
- package/dist/validation/reserved-channels.d.ts +43 -46
- package/dist/validation/reserved-channels.d.ts.map +1 -1
- package/dist/validation/reserved-channels.js +14 -177
- package/dist/validation/resolve-stream-channel.d.ts +3 -9
- package/dist/validation/resolve-stream-channel.d.ts.map +1 -1
- package/dist/validation/resolve-stream-channel.js +3 -4
- package/dist/validation/sanitize-error.d.ts +10 -9
- package/dist/validation/sanitize-error.d.ts.map +1 -1
- package/dist/validation/sanitize-error.js +19 -18
- package/dist/validation/schema-compat-invariants.d.ts +1 -1
- package/dist/validation/schema-compat-invariants.js +3 -3
- package/dist/validation/schema-meta-validation.d.ts +4 -4
- package/dist/validation/schema-meta-validation.d.ts.map +1 -1
- package/dist/validation/schema-meta-validation.js +7 -9
- package/dist/validation/schema-subset.d.ts +9 -8
- package/dist/validation/schema-subset.d.ts.map +1 -1
- package/dist/validation/ui-security.d.ts +0 -17
- package/dist/validation/ui-security.d.ts.map +1 -1
- package/dist/validation/ui-security.js +17 -22
- package/dist/validation/zod-to-json-schema.d.ts +1 -1
- package/dist/validation/zod-to-json-schema.d.ts.map +1 -1
- package/dist/validation/zod-to-json-schema.js +4 -3
- package/dist/version.d.ts +783 -9
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +782 -8
- package/package.json +2 -2
- package/dist/bridge/invoke-agent.d.ts +0 -65
- package/dist/bridge/invoke-agent.d.ts.map +0 -1
- package/dist/bridge/invoke-agent.js +0 -113
- package/dist/stream/stream-parser.d.ts +0 -62
- package/dist/stream/stream-parser.d.ts.map +0 -1
- package/dist/stream/stream-parser.js +0 -199
- package/dist/types/canvas-lifecycle.d.ts.map +0 -1
- package/dist/types/credential.d.ts +0 -41
- package/dist/types/credential.d.ts.map +0 -1
- package/dist/types/credential.js +0 -32
- package/dist/types/data-bindings.d.ts +0 -322
- package/dist/types/data-bindings.d.ts.map +0 -1
- package/dist/types/data-bindings.js +0 -29
- package/dist/types/feedback.d.ts +0 -22
- package/dist/types/feedback.d.ts.map +0 -1
- package/dist/types/feedback.js +0 -7
- package/dist/types/mcp-proxy.d.ts +0 -67
- package/dist/types/mcp-proxy.d.ts.map +0 -1
- package/dist/types/mcp-proxy.js +0 -46
- package/dist/types/openrouter-models.d.ts +0 -23
- package/dist/types/openrouter-models.d.ts.map +0 -1
- package/dist/types/openrouter-models.js +0 -4843
- package/dist/types/region.d.ts +0 -26
- package/dist/types/region.d.ts.map +0 -1
- package/dist/types/region.js +0 -36
- package/dist/types/render-event.d.ts.map +0 -1
- package/dist/types/session.d.ts.map +0 -1
- /package/dist/types/{session.js → render.js} +0 -0
|
@@ -3,14 +3,15 @@ import type { KNOWN_PERMISSION_NAMES } from '../validation/hygiene-rules';
|
|
|
3
3
|
import type { PropsSpec, StreamSpec, ActionSpec, ContextSpec, ClientCapabilitiesSpec, GadgetDescriptor, JsonSchema, JsonObject } from './data-contract';
|
|
4
4
|
import type { EndUserIdentity } from './auth';
|
|
5
5
|
import type { HostContextProjection } from './host-context';
|
|
6
|
-
import type {
|
|
6
|
+
import type { AppTheme } from '../schemas/app-theme';
|
|
7
|
+
import type { McpAppsGguiSession } from '../integrations/mcp-apps';
|
|
7
8
|
/**
|
|
8
9
|
* Recognised system-card kinds the runtime renders via built-in
|
|
9
10
|
* components. The wire is open-ended (string), but new kinds without a
|
|
10
11
|
* matching renderer fall through to a generic "system message" card so
|
|
11
12
|
* an old runtime + new server still produce something visible.
|
|
12
13
|
*/
|
|
13
|
-
export type
|
|
14
|
+
export type SystemGguiSessionKind = 'no-credentials' | 'mcp-apps-probe' | (string & {});
|
|
14
15
|
/**
|
|
15
16
|
* Adapter permission status
|
|
16
17
|
*/
|
|
@@ -27,7 +28,7 @@ export type AdapterPermissions = {
|
|
|
27
28
|
readonly [K in (typeof KNOWN_PERMISSION_NAMES)[number]]?: PermissionStatus;
|
|
28
29
|
};
|
|
29
30
|
/**
|
|
30
|
-
* Lifecycle status of a {@link
|
|
31
|
+
* Lifecycle status of a {@link GguiSession}. GguiSessionStore implementations MAY
|
|
31
32
|
* populate this on `get`; absent ⇒ caller treats as `'active'`.
|
|
32
33
|
*
|
|
33
34
|
* Two states only:
|
|
@@ -35,29 +36,29 @@ export type AdapterPermissions = {
|
|
|
35
36
|
* - `'expired'` — TTL elapsed; no further writes accepted, reads return
|
|
36
37
|
* a historical snapshot.
|
|
37
38
|
*
|
|
38
|
-
* There is no explicit terminal state.
|
|
39
|
+
* There is no explicit terminal state. GguiSessions decay implicitly via TTL.
|
|
39
40
|
* The dropped `'completed'` state was a vestige of the deleted Session
|
|
40
41
|
* vessel — kept symmetrical with `ggui_new_session`, which was deleted
|
|
41
42
|
* in the earlier handshake collapse. The companion `ggui_close` tool
|
|
42
43
|
* that wrote it was removed in the same slice.
|
|
43
44
|
*/
|
|
44
|
-
export type
|
|
45
|
+
export type GguiSessionStatus = 'active' | 'expired';
|
|
45
46
|
/**
|
|
46
|
-
* Common base for every {@link
|
|
47
|
+
* Common base for every {@link GguiSession} variant. Carries identity,
|
|
47
48
|
* tenancy, lifecycle, and conversation-scoped context that every
|
|
48
49
|
* rendered thing has regardless of how its visible bits are
|
|
49
50
|
* produced (LLM-generated component, server-emitted system card,
|
|
50
51
|
* embedded MCP-App iframe).
|
|
51
52
|
*
|
|
52
53
|
* **Conversation-scoped context note** — fields that convey "this
|
|
53
|
-
*
|
|
54
|
-
* conversation" (hostContext continuity, sibling
|
|
55
|
-
* are NOT duplicated onto each
|
|
56
|
-
* {@link
|
|
54
|
+
* GguiSession belongs to a logical group of GguiSessions within a host
|
|
55
|
+
* conversation" (hostContext continuity, sibling-GguiSession discovery)
|
|
56
|
+
* are NOT duplicated onto each GguiSession. They look up via the optional
|
|
57
|
+
* {@link GguiSessionBase.hostSession} pair instead. See
|
|
57
58
|
* [[session-concept-deletion-2026-05-27]] for the framing.
|
|
58
59
|
*/
|
|
59
|
-
export interface
|
|
60
|
-
/**
|
|
60
|
+
export interface GguiSessionBase {
|
|
61
|
+
/** GguiSession identity. The value an iframe's bootstrap meta and every
|
|
61
62
|
* wire reference (props_update, consume, update) keys by. */
|
|
62
63
|
readonly id: string;
|
|
63
64
|
/** App identity (tenancy boundary, always per-render). */
|
|
@@ -74,13 +75,13 @@ export interface RenderBase {
|
|
|
74
75
|
* host's opaque grouping key for "this conversation" — typically
|
|
75
76
|
* the host's thread/chat id.
|
|
76
77
|
*
|
|
77
|
-
* Multiple
|
|
78
|
-
* `hostSessionId`. The `
|
|
79
|
-
* tool enumerates
|
|
80
|
-
* `hostSession` ⇒ the
|
|
78
|
+
* Multiple GguiSessions inside one host conversation share the same
|
|
79
|
+
* `hostSessionId`. The `ggui_list_sessions(hostName, hostSessionId)`
|
|
80
|
+
* tool enumerates GguiSessions belonging to a host conversation; absent
|
|
81
|
+
* `hostSession` ⇒ the GguiSession is one-shot (functional but
|
|
81
82
|
* non-rehydratable).
|
|
82
83
|
*
|
|
83
|
-
* Once captured, immutable for the
|
|
84
|
+
* Once captured, immutable for the GguiSession's lifetime.
|
|
84
85
|
*/
|
|
85
86
|
readonly hostSession?: {
|
|
86
87
|
readonly hostName: string;
|
|
@@ -88,7 +89,7 @@ export interface RenderBase {
|
|
|
88
89
|
};
|
|
89
90
|
/**
|
|
90
91
|
* Theme preset id for this render. Resolution chain:
|
|
91
|
-
* 1. `
|
|
92
|
+
* 1. `GguiSession.themeId` — agent-explicit per-render override
|
|
92
93
|
* 2. `App.defaultThemeId` — server-side per-app default
|
|
93
94
|
* 3. server fallback (process default)
|
|
94
95
|
* First non-undefined wins at bootstrap-meta projection.
|
|
@@ -111,13 +112,13 @@ export interface RenderBase {
|
|
|
111
112
|
/**
|
|
112
113
|
* Per-render Web Permissions API status map. Populated as the user
|
|
113
114
|
* grants / denies adapter requests (geolocation, camera, etc.) over
|
|
114
|
-
* the
|
|
115
|
+
* the GguiSession's lifetime.
|
|
115
116
|
*/
|
|
116
117
|
readonly adapterPermissions?: AdapterPermissions;
|
|
117
118
|
/** Resolved lifecycle status. Absent ⇒ caller treats as `'active'`. */
|
|
118
|
-
readonly status?:
|
|
119
|
-
/** Monotonic event ledger sequence (per-render — each
|
|
120
|
-
* own
|
|
119
|
+
readonly status?: GguiSessionStatus;
|
|
120
|
+
/** Monotonic event ledger sequence (per-render — each GguiSession has its
|
|
121
|
+
* own GguiSessionEvent ledger). */
|
|
121
122
|
readonly eventSequence: number;
|
|
122
123
|
/** Creation timestamp (epoch ms). */
|
|
123
124
|
readonly createdAt: number;
|
|
@@ -127,18 +128,18 @@ export interface RenderBase {
|
|
|
127
128
|
readonly expiresAt: number;
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
130
|
-
* `
|
|
131
|
+
* `GguiSession` — the canonical protocol shape for a single rendered UI.
|
|
131
132
|
*
|
|
132
|
-
* Three variants share {@link
|
|
133
|
+
* Three variants share {@link GguiSessionBase} (identity, tenancy,
|
|
133
134
|
* lifecycle); each variant adds its own visible-bits surface:
|
|
134
135
|
*
|
|
135
|
-
* - {@link
|
|
136
|
+
* - {@link ComponentGguiSession} — LLM-generated / native React component.
|
|
136
137
|
* Carries `componentCode`, `propsSpec`, `actionSpec`, `streamSpec`,
|
|
137
138
|
* `contextSpec`, `gadgetDescriptors`, etc.
|
|
138
|
-
* - {@link
|
|
139
|
+
* - {@link SystemGguiSession} — server-emitted system card. Carries an
|
|
139
140
|
* opaque `kind` + structured `props`; the runtime maps the kind to
|
|
140
141
|
* a built-in `.tsx` renderer.
|
|
141
|
-
* - {@link
|
|
142
|
+
* - {@link McpAppsGguiSession} — embedded third-party MCP-App iframe.
|
|
142
143
|
* Carries `resourceUri` + MCP server config. (Lives in
|
|
143
144
|
* `@ggui-ai/protocol/integrations/mcp-apps` to keep core typing
|
|
144
145
|
* MCP-Apps-opt-in.)
|
|
@@ -146,22 +147,22 @@ export interface RenderBase {
|
|
|
146
147
|
* Narrowing pattern:
|
|
147
148
|
* ```ts
|
|
148
149
|
* if (render.type === 'mcpApps') {
|
|
149
|
-
* //
|
|
150
|
+
* // McpAppsGguiSession — render via host-role adapter
|
|
150
151
|
* } else if (render.type === 'system') {
|
|
151
|
-
* //
|
|
152
|
+
* // SystemGguiSession — render via built-in card registry
|
|
152
153
|
* } else {
|
|
153
|
-
* //
|
|
154
|
+
* // ComponentGguiSession — render via DynamicComponent
|
|
154
155
|
* }
|
|
155
156
|
* ```
|
|
156
157
|
*/
|
|
157
|
-
export type
|
|
158
|
+
export type GguiSession<TProps = JsonObject> = ComponentGguiSession<TProps> | SystemGguiSession | McpAppsGguiSession;
|
|
158
159
|
/**
|
|
159
|
-
*
|
|
160
|
+
* GguiSession variant: LLM-generated / native React component.
|
|
160
161
|
*
|
|
161
162
|
* Discriminator: `type === 'component'` OR `type` absent (back-compat
|
|
162
163
|
* default — every producer that omits `type` is producing this variant).
|
|
163
164
|
*/
|
|
164
|
-
export interface
|
|
165
|
+
export interface ComponentGguiSession<TProps = JsonObject> extends GguiSessionBase {
|
|
165
166
|
/** Variant discriminator. Optional; absent ⇒ `'component'`. */
|
|
166
167
|
readonly type?: 'component';
|
|
167
168
|
/** Blueprint component code (pure UI). */
|
|
@@ -208,7 +209,7 @@ export interface ComponentRender<TProps = JsonObject> extends RenderBase {
|
|
|
208
209
|
* preserved verbatim from the agent's render payload — no enrichment
|
|
209
210
|
* overlay, no `version` (resolves from `App.gadgets`). Resolution
|
|
210
211
|
* metadata lives on the parallel
|
|
211
|
-
* {@link
|
|
212
|
+
* {@link ComponentGguiSession.gadgetDescriptors} sidecar.
|
|
212
213
|
*/
|
|
213
214
|
readonly clientCapabilities?: ClientCapabilitiesSpec;
|
|
214
215
|
/**
|
|
@@ -218,6 +219,18 @@ export interface ComponentRender<TProps = JsonObject> extends RenderBase {
|
|
|
218
219
|
* + CSP + bundle-loader derivation read from this array.
|
|
219
220
|
*/
|
|
220
221
|
readonly gadgetDescriptors?: readonly GadgetDescriptor[];
|
|
222
|
+
/**
|
|
223
|
+
* Theme sidecar — the resolved per-app theme overlay (mode +
|
|
224
|
+
* `--ggui-*` CSS-variable map) snapshotted from `App.theme` at
|
|
225
|
+
* render-commit time. Sibling to {@link ComponentGguiSession.gadgetDescriptors}:
|
|
226
|
+
* a render-time snapshot the slice-meta derivation reads without
|
|
227
|
+
* re-resolving against the App record. The bootstrap projection
|
|
228
|
+
* (`deriveRenderMeta`) surfaces it on the
|
|
229
|
+
* `_meta["ai.ggui/render"].theme` slice so the iframe applies the
|
|
230
|
+
* operator-curated overlay at boot. Absent ⇒ the renderer's default
|
|
231
|
+
* theme.
|
|
232
|
+
*/
|
|
233
|
+
readonly theme?: AppTheme;
|
|
221
234
|
/**
|
|
222
235
|
* Last-known snapshot of the contextSpec slot values, mirrored from
|
|
223
236
|
* the runtime's `ui/update-model-context` posts via
|
|
@@ -235,7 +248,7 @@ export interface ComponentRender<TProps = JsonObject> extends RenderBase {
|
|
|
235
248
|
readonly contextSnapshot?: JsonObject;
|
|
236
249
|
}
|
|
237
250
|
/**
|
|
238
|
-
*
|
|
251
|
+
* GguiSession variant: server-emitted system card.
|
|
239
252
|
*
|
|
240
253
|
* Used when the SERVER (not an LLM, not an MCP host) needs to render
|
|
241
254
|
* a UI card the operator can act on: "set up your LLM key", "rate
|
|
@@ -244,7 +257,7 @@ export interface ComponentRender<TProps = JsonObject> extends RenderBase {
|
|
|
244
257
|
* Wire shape is intentionally tiny — server emits identifier + data,
|
|
245
258
|
* not code. The runtime maps `kind` to a built-in `.tsx` component.
|
|
246
259
|
*/
|
|
247
|
-
export interface
|
|
260
|
+
export interface SystemGguiSession<TProps extends JsonObject = JsonObject> extends GguiSessionBase {
|
|
248
261
|
readonly type: 'system';
|
|
249
262
|
/**
|
|
250
263
|
* Identifier the runtime maps to a built-in renderer. Stable strings
|
|
@@ -252,7 +265,7 @@ export interface SystemRender<TProps extends JsonObject = JsonObject> extends Re
|
|
|
252
265
|
* never breaks an older runtime; it just falls through to a generic
|
|
253
266
|
* card carrying the props as raw JSON.
|
|
254
267
|
*/
|
|
255
|
-
readonly kind:
|
|
268
|
+
readonly kind: SystemGguiSessionKind;
|
|
256
269
|
/** Props forwarded to the built-in renderer. */
|
|
257
270
|
readonly props?: TProps;
|
|
258
271
|
/** Optional descriptive text the server can attach (telemetry, logs). */
|
|
@@ -275,19 +288,4 @@ export interface ConversationTurn<TToolArgs = JsonObject> {
|
|
|
275
288
|
}[];
|
|
276
289
|
timestamp: string;
|
|
277
290
|
}
|
|
278
|
-
|
|
279
|
-
* Progress update emitted by a producer during component production.
|
|
280
|
-
* Delivered via the `ggui:logs` bridge event.
|
|
281
|
-
*
|
|
282
|
-
* Post-Phase-B: collapsed from `{ sessionId, stackItemId }` to a single
|
|
283
|
-
* `renderId` (the two identifiers were the same value once each render
|
|
284
|
-
* was its own thing).
|
|
285
|
-
*/
|
|
286
|
-
export interface ProgressUpdate {
|
|
287
|
-
renderId: string;
|
|
288
|
-
step: 'queued' | 'negotiating' | 'matching' | 'generating' | 'compiling' | 'evaluating' | 'complete' | 'error';
|
|
289
|
-
label: string;
|
|
290
|
-
percent: number;
|
|
291
|
-
message?: string;
|
|
292
|
-
}
|
|
293
|
-
//# sourceMappingURL=session.d.ts.map
|
|
291
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/types/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA6BnE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAC7B,gBAAgB,GAChB,gBAAgB,GAEhB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,CAAC,IAAI,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB;CAC3E,CAAC;AAMF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SA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AAQ,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;CACvC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,CACvE,SAAQ,eAAe;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,gDAAgD;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB,CAAC,SAAS,GAAG,UAAU;IACtD,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/types/thread.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
1
|
+
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/types/thread.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE9D,iEAAiE;AACjE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1D,+BAA+B;AAC/B,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG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C,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAG9E"}
|
package/dist/types/thread.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* **Additions are additive forever** (consumer adapters dedupe on
|
|
26
26
|
* fields they know). Breaking changes require a protocol version bump.
|
|
27
27
|
*/
|
|
28
|
+
import { isRecord } from '../validation/is-record.js';
|
|
28
29
|
/**
|
|
29
30
|
* The 9-action state machine that mutates per-thread UI state. Identical
|
|
30
31
|
* vocabulary to `packages/chat-managed-amplify/src/createAdapter.ts#
|
|
@@ -50,8 +51,7 @@ export function isThreadStateAction(value) {
|
|
|
50
51
|
THREAD_STATE_ACTIONS.includes(value));
|
|
51
52
|
}
|
|
52
53
|
export function isThreadStreamEvent(value) {
|
|
53
|
-
if (
|
|
54
|
+
if (!isRecord(value))
|
|
54
55
|
return false;
|
|
55
|
-
|
|
56
|
-
return v['type'] === 'thread-message' && typeof v['message'] === 'object';
|
|
56
|
+
return value['type'] === 'thread-message' && typeof value['message'] === 'object';
|
|
57
57
|
}
|
|
@@ -1,51 +1,10 @@
|
|
|
1
1
|
import type { DataContract, JsonObject, JsonSchema, JsonValue } from './data-contract';
|
|
2
|
-
/**
|
|
3
|
-
* Design system version — used as part of the cache fingerprint.
|
|
4
|
-
* When tokens or primitives change, bump this to invalidate cached blueprints.
|
|
5
|
-
*
|
|
6
|
-
* Keep in sync with the `@ggui-ai/design` package.json version.
|
|
7
|
-
*/
|
|
8
|
-
export declare const DESIGN_SYSTEM_VERSION = "0.1.0";
|
|
9
|
-
/**
|
|
10
|
-
* Inputs for computing a style fingerprint.
|
|
11
|
-
* The fingerprint determines cache validity for generated blueprints.
|
|
12
|
-
*
|
|
13
|
-
* NOTE: themeId is NOT included — theme colors are injected at render time
|
|
14
|
-
* via cssOverrides, not baked into generated code.
|
|
15
|
-
*/
|
|
16
|
-
export interface StyleFingerprintInput {
|
|
17
|
-
/** App's styling/generation prompt (affects component structure/layout) */
|
|
18
|
-
stylingPrompt?: string;
|
|
19
|
-
/** Design system preset (affects available components/tokens) */
|
|
20
|
-
designSystemPreset?: string;
|
|
21
|
-
/** Design system version (covers tokens, primitives, motion, everything compiled) */
|
|
22
|
-
designSystemVersion: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Compute a style fingerprint for cache invalidation.
|
|
26
|
-
*
|
|
27
|
-
* Blueprints generated under the same fingerprint are interchangeable.
|
|
28
|
-
* A fingerprint change means cached blueprints may use outdated primitives,
|
|
29
|
-
* tokens, or structural patterns and should be regenerated.
|
|
30
|
-
*
|
|
31
|
-
* What invalidates the cache:
|
|
32
|
-
* - stylingPrompt changed ("make it playful" → different layout)
|
|
33
|
-
* - designSystemPreset changed (different component set available)
|
|
34
|
-
* - designSystemVersion bumped (new tokens, primitives, motion, etc.)
|
|
35
|
-
*
|
|
36
|
-
* What does NOT invalidate:
|
|
37
|
-
* - themeId changed (colors are applied at render time via cssOverrides)
|
|
38
|
-
*
|
|
39
|
-
* Uses FNV-1a (non-cryptographic) — this is for cache keys, not security.
|
|
40
|
-
* Works in all JS runtimes (browser, Node.js, React Native).
|
|
41
|
-
*/
|
|
42
|
-
export declare function computeStyleFingerprint(input: StyleFingerprintInput): string;
|
|
43
2
|
/**
|
|
44
3
|
* Request to generate a UI component.
|
|
45
4
|
* Generic `TContext` defaults to {@link JsonObject} for generator context hints.
|
|
46
5
|
*/
|
|
47
6
|
export interface UIGenerationRequest<TContext = JsonObject> {
|
|
48
|
-
|
|
7
|
+
sessionId: string;
|
|
49
8
|
prompt: string;
|
|
50
9
|
context?: TContext;
|
|
51
10
|
schema?: JsonSchema;
|
|
@@ -60,7 +19,7 @@ export interface UIGenerationRequest<TContext = JsonObject> {
|
|
|
60
19
|
* field.
|
|
61
20
|
*/
|
|
62
21
|
export interface UIGenerationResponse {
|
|
63
|
-
|
|
22
|
+
sessionId: string;
|
|
64
23
|
componentCode: string;
|
|
65
24
|
sourceCode?: string;
|
|
66
25
|
warnings?: string[];
|
|
@@ -70,8 +29,8 @@ export interface UIGenerationResponse {
|
|
|
70
29
|
* Populated by the generator when the component calls wire hooks
|
|
71
30
|
* (`useAction('name')`, `useStream('channel')`) — the generator
|
|
72
31
|
* extracts the call sites and emits a matching authoring-side
|
|
73
|
-
* envelope so downstream consumers (`ggui_render` →
|
|
74
|
-
* inspectors
|
|
32
|
+
* envelope so downstream consumers (`ggui_render` → GguiSession,
|
|
33
|
+
* console inspectors) have the contract available.
|
|
75
34
|
*
|
|
76
35
|
* - When the caller supplied `UiGenerateInput.contract` that
|
|
77
36
|
* envelope is passed through as-is (already authoritative).
|
|
@@ -80,7 +39,7 @@ export interface UIGenerationResponse {
|
|
|
80
39
|
* `actionSpec[name] = {label: name}` and
|
|
81
40
|
* `streamSpec[channel] = {schema: {type: 'object'}}`. Enough for
|
|
82
41
|
* the receiver to know the surface exists; callers who need
|
|
83
|
-
* richer metadata (labels, schemas,
|
|
42
|
+
* richer metadata (labels, schemas, nextStep hints) should
|
|
84
43
|
* author the contract themselves and pass it on input.
|
|
85
44
|
* - When no wire hooks are used, this field stays absent.
|
|
86
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-generator.d.ts","sourceRoot":"","sources":["../../src/types/ui-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB
|
|
1
|
+
{"version":3,"file":"ui-generator.d.ts","sourceRoot":"","sources":["../../src/types/ui-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,QAAQ,GAAG,UAAU;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;IACrE,OAAO,EAAE,MAAM,CAAC;IAChB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB"}
|
|
@@ -1,53 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Design system version — used as part of the cache fingerprint.
|
|
3
|
-
* When tokens or primitives change, bump this to invalidate cached blueprints.
|
|
4
|
-
*
|
|
5
|
-
* Keep in sync with the `@ggui-ai/design` package.json version.
|
|
6
|
-
*/
|
|
7
|
-
export const DESIGN_SYSTEM_VERSION = '0.1.0';
|
|
8
|
-
/**
|
|
9
|
-
* FNV-1a hash — a fast, non-cryptographic hash with good distribution.
|
|
10
|
-
* Used for cache key fingerprinting only, not for security purposes.
|
|
11
|
-
* Works in all JS runtimes (browser, Node.js, React Native).
|
|
12
|
-
*/
|
|
13
|
-
function fnv1aHash(str) {
|
|
14
|
-
let hash = 0x811c9dc5; // FNV offset basis (32-bit)
|
|
15
|
-
for (let i = 0; i < str.length; i++) {
|
|
16
|
-
hash ^= str.charCodeAt(i);
|
|
17
|
-
hash = Math.imul(hash, 0x01000193); // FNV prime (32-bit)
|
|
18
|
-
}
|
|
19
|
-
// Convert to unsigned 32-bit, then to base-36 for compact representation.
|
|
20
|
-
// Produce two 32-bit hashes (second seeded differently) for a longer fingerprint.
|
|
21
|
-
let hash2 = 0x1a2b3c4d;
|
|
22
|
-
for (let i = 0; i < str.length; i++) {
|
|
23
|
-
hash2 ^= str.charCodeAt(i);
|
|
24
|
-
hash2 = Math.imul(hash2, 0x01000193);
|
|
25
|
-
}
|
|
26
|
-
return (hash >>> 0).toString(36) + (hash2 >>> 0).toString(36);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Compute a style fingerprint for cache invalidation.
|
|
30
|
-
*
|
|
31
|
-
* Blueprints generated under the same fingerprint are interchangeable.
|
|
32
|
-
* A fingerprint change means cached blueprints may use outdated primitives,
|
|
33
|
-
* tokens, or structural patterns and should be regenerated.
|
|
34
|
-
*
|
|
35
|
-
* What invalidates the cache:
|
|
36
|
-
* - stylingPrompt changed ("make it playful" → different layout)
|
|
37
|
-
* - designSystemPreset changed (different component set available)
|
|
38
|
-
* - designSystemVersion bumped (new tokens, primitives, motion, etc.)
|
|
39
|
-
*
|
|
40
|
-
* What does NOT invalidate:
|
|
41
|
-
* - themeId changed (colors are applied at render time via cssOverrides)
|
|
42
|
-
*
|
|
43
|
-
* Uses FNV-1a (non-cryptographic) — this is for cache keys, not security.
|
|
44
|
-
* Works in all JS runtimes (browser, Node.js, React Native).
|
|
45
|
-
*/
|
|
46
|
-
export function computeStyleFingerprint(input) {
|
|
47
|
-
const raw = [
|
|
48
|
-
input.stylingPrompt || '',
|
|
49
|
-
input.designSystemPreset || 'default',
|
|
50
|
-
input.designSystemVersion,
|
|
51
|
-
].join('|');
|
|
52
|
-
return fnv1aHash(raw);
|
|
53
|
-
}
|
|
1
|
+
export {};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* between props vs action vs stream vs context.
|
|
16
16
|
* - Compile-time meta-validation: `strict: true` rejects malformed
|
|
17
17
|
* JSON Schemas at `compile()` — agents discover bugs at
|
|
18
|
-
* handshake/
|
|
18
|
+
* handshake/render, not at first data flow.
|
|
19
19
|
*
|
|
20
20
|
* Closed-shape (load-bearing):
|
|
21
21
|
* JSON Schema's default is `additionalProperties: true` (extras
|
|
@@ -66,7 +66,7 @@ export declare function injectClosedShape(schema: JsonSchema): JsonSchema;
|
|
|
66
66
|
* closed-shape injected at every object node. Throws if the schema
|
|
67
67
|
* is malformed under Ajv strict mode — this is layer B meta-
|
|
68
68
|
* validation as a free side effect. Dedicated meta-validation call
|
|
69
|
-
* sites (handshake /
|
|
69
|
+
* sites (handshake / render) wrap this in a structured error.
|
|
70
70
|
*
|
|
71
71
|
* Not cached. Compilation is fast and contracts are small; caching
|
|
72
72
|
* adds a memory cost without a measured win. Revisit if profiling
|
|
@@ -82,7 +82,7 @@ export declare function compileForValidation(schema: JsonSchema): ValidateFuncti
|
|
|
82
82
|
* Why this exists: the renderer iframe runs under a strict CSP with no
|
|
83
83
|
* `'unsafe-eval'`, so `ajv.compile()` (which builds the validator via
|
|
84
84
|
* `new Function`) throws `EvalError` there. Codegen has to happen
|
|
85
|
-
* where `eval` is legal — the server, at
|
|
85
|
+
* where `eval` is legal — the server, at render time, where the contract
|
|
86
86
|
* schema is already fixed. The iframe then loads this module source
|
|
87
87
|
* via a `blob:` dynamic import (governed by `script-src`, not
|
|
88
88
|
* `unsafe-eval`) and only ever *runs* the validator.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ajv-runtime.d.ts","sourceRoot":"","sources":["../../src/validation/ajv-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAGzD;;;;;GAKG;AACH,YAAY,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAI5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ajv-runtime.d.ts","sourceRoot":"","sources":["../../src/validation/ajv-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAGzD;;;;;GAKG;AACH,YAAY,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAI5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAoF9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAqChE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAGzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAIjE;AA4DD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,GAAG,SAAS,EACxC,IAAI,EAAE,OAAO,GACZ,iBAAiB,EAAE,CAGrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,iBAAiB,EAAE,EAC/B,MAAM,EAAE,MAAM,GACb,iBAAiB,EAAE,CAMrB"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* between props vs action vs stream vs context.
|
|
16
16
|
* - Compile-time meta-validation: `strict: true` rejects malformed
|
|
17
17
|
* JSON Schemas at `compile()` — agents discover bugs at
|
|
18
|
-
* handshake/
|
|
18
|
+
* handshake/render, not at first data flow.
|
|
19
19
|
*
|
|
20
20
|
* Closed-shape (load-bearing):
|
|
21
21
|
* JSON Schema's default is `additionalProperties: true` (extras
|
|
@@ -41,6 +41,7 @@ import addFormats from 'ajv-formats';
|
|
|
41
41
|
import standaloneCode from 'ajv/dist/standalone/index.js';
|
|
42
42
|
import equalImport from 'ajv/dist/runtime/equal.js';
|
|
43
43
|
import ucs2lengthImport from 'ajv/dist/runtime/ucs2length.js';
|
|
44
|
+
import { isRecord } from './is-record.js';
|
|
44
45
|
/**
|
|
45
46
|
* Resolve a runtime-helper module's exported function across the
|
|
46
47
|
* CJS↔ESM interop gap: a plain `module.exports = fn` CJS module
|
|
@@ -172,7 +173,7 @@ export function injectClosedShape(schema) {
|
|
|
172
173
|
* closed-shape injected at every object node. Throws if the schema
|
|
173
174
|
* is malformed under Ajv strict mode — this is layer B meta-
|
|
174
175
|
* validation as a free side effect. Dedicated meta-validation call
|
|
175
|
-
* sites (handshake /
|
|
176
|
+
* sites (handshake / render) wrap this in a structured error.
|
|
176
177
|
*
|
|
177
178
|
* Not cached. Compilation is fast and contracts are small; caching
|
|
178
179
|
* adds a memory cost without a measured win. Revisit if profiling
|
|
@@ -191,7 +192,7 @@ export function compileForValidation(schema) {
|
|
|
191
192
|
* Why this exists: the renderer iframe runs under a strict CSP with no
|
|
192
193
|
* `'unsafe-eval'`, so `ajv.compile()` (which builds the validator via
|
|
193
194
|
* `new Function`) throws `EvalError` there. Codegen has to happen
|
|
194
|
-
* where `eval` is legal — the server, at
|
|
195
|
+
* where `eval` is legal — the server, at render time, where the contract
|
|
195
196
|
* schema is already fixed. The iframe then loads this module source
|
|
196
197
|
* via a `blob:` dynamic import (governed by `script-src`, not
|
|
197
198
|
* `unsafe-eval`) and only ever *runs* the validator.
|
|
@@ -247,7 +248,7 @@ function inlineRuntimeHelpers(source) {
|
|
|
247
248
|
}
|
|
248
249
|
// Survivor check: a remaining `ajv/dist/runtime/*` import means Ajv
|
|
249
250
|
// emitted a helper we don't inline. Fail loud here (server-side,
|
|
250
|
-
// caught by tests /
|
|
251
|
+
// caught by tests / render) rather than shipping a module the iframe
|
|
251
252
|
// cannot load. Scoped to the `ajv/dist/runtime/` prefix — the only
|
|
252
253
|
// specifiers Ajv standalone emits — so an embedded contract-schema
|
|
253
254
|
// string can't false-trip it.
|
|
@@ -434,7 +435,7 @@ function resolveAtPath(root, instancePath) {
|
|
|
434
435
|
return undefined;
|
|
435
436
|
cur = cur[idx];
|
|
436
437
|
}
|
|
437
|
-
else if (
|
|
438
|
+
else if (isRecord(cur)) {
|
|
438
439
|
cur = cur[part];
|
|
439
440
|
}
|
|
440
441
|
else {
|
|
@@ -24,7 +24,7 @@ export interface ValidationResult {
|
|
|
24
24
|
* pre-injection wrapper.
|
|
25
25
|
*
|
|
26
26
|
* Shared by {@link validatePropsData} (server-side runtime check) and
|
|
27
|
-
* {@link compileContractValidators} (
|
|
27
|
+
* {@link compileContractValidators} (render-time standalone emission) so
|
|
28
28
|
* the precompiled in-iframe validator enforces byte-identical
|
|
29
29
|
* semantics to the runtime validator — one synthesis, no drift.
|
|
30
30
|
*/
|
|
@@ -42,7 +42,7 @@ export declare function buildPropsWrapperSchema(spec: PropsSpec): JsonSchema;
|
|
|
42
42
|
*
|
|
43
43
|
* Load-bearing for `ggui_update kind:'merge'` (RFC 7396): a patch
|
|
44
44
|
* adding a key absent from `propsSpec.properties` would silently
|
|
45
|
-
* land on the
|
|
45
|
+
* land on the render without this gate. Same rule applies to
|
|
46
46
|
* the `done`-vs-declared-`completed` class of bug inside array
|
|
47
47
|
* items — Ajv rejects with the exact path (`todos[0].done`).
|
|
48
48
|
*/
|
|
@@ -75,18 +75,18 @@ export declare function validatePropsData(props: Record<string, unknown>, spec:
|
|
|
75
75
|
* validator for `_ggui:preview`. Consulted FIRST so callers can
|
|
76
76
|
* override or extend built-ins.
|
|
77
77
|
* 2. `BUILTIN_RESERVED_VALIDATORS` — protocol-owned, always active.
|
|
78
|
-
* Ships the {@link
|
|
79
|
-
* `_ggui:
|
|
78
|
+
* Ships the {@link validateGguiLifecyclePayload} for
|
|
79
|
+
* `_ggui:lifecycle`.
|
|
80
80
|
* 3. Fall-through: if no validator is registered for the known
|
|
81
81
|
* reserved channel, return `{valid: true}`. Preserves backward
|
|
82
82
|
* compatibility for any future reserved channel the runtime
|
|
83
83
|
* adds before its validator is authored.
|
|
84
84
|
*
|
|
85
|
-
* Without this structure, a `_ggui:preview` emission into a
|
|
86
|
-
* whose active
|
|
85
|
+
* Without this structure, a `_ggui:preview` emission into a render
|
|
86
|
+
* whose active render carries ANY user streamSpec would
|
|
87
87
|
* synthesize a false "Unknown channel" violation, blocking the
|
|
88
88
|
* provisional preview runtime. Symmetric with the client-side
|
|
89
|
-
* handling in `
|
|
89
|
+
* handling in `GguiRender`.
|
|
90
90
|
*
|
|
91
91
|
* Crucially narrow by design — the known-reserved path is a CLOSED
|
|
92
92
|
* SET, not a prefix check. A typo inside the reserved namespace
|
|
@@ -118,7 +118,7 @@ export declare function validateStreamData(channelName: string, payload: unknown
|
|
|
118
118
|
*/
|
|
119
119
|
export declare function validateContextData(slotName: string, value: unknown, spec: ContextSpec, precompiledSlots?: ReadonlyMap<string, ValidateFunction>): ValidationResult;
|
|
120
120
|
/**
|
|
121
|
-
* Validate an inbound user-action payload against the
|
|
121
|
+
* Validate an inbound user-action payload against the render's ActionSpec.
|
|
122
122
|
*
|
|
123
123
|
* Symmetric with {@link validatePropsData} / {@link validateStreamData}, but for
|
|
124
124
|
* live-channel INBOUND user → core traffic. Enforces the action contract at the
|
|
@@ -140,24 +140,25 @@ export declare function validateContextData(slotName: string, value: unknown, sp
|
|
|
140
140
|
*/
|
|
141
141
|
export declare function validateActionData(value: unknown, spec: ActionSpec, precompiledActions?: ReadonlyMap<string, ValidateFunction>): ValidationResult;
|
|
142
142
|
/**
|
|
143
|
-
* Validate an inbound {@link ActionEnvelope} against the target
|
|
144
|
-
*
|
|
145
|
-
* inbound enforcement — the
|
|
146
|
-
*
|
|
147
|
-
*
|
|
143
|
+
* Validate an inbound {@link ActionEnvelope} against the target
|
|
144
|
+
* render's {@link ActionSpec}. Payload-contract layer of live-channel
|
|
145
|
+
* inbound enforcement — the ONLY gate on inbound actions today (the
|
|
146
|
+
* pre-Phase-B `subscription.events` allowlist gate was deleted with
|
|
147
|
+
* the session-stack collapse).
|
|
148
148
|
*
|
|
149
149
|
* Semantics:
|
|
150
150
|
* - `envelope.type !== 'data:submit'` → `{valid: true, violations: []}`.
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
151
|
+
* {@link EventType} has exactly one member, so a TYPED caller never
|
|
152
|
+
* hits this branch — it is a wire-trust guard: a rogue client's
|
|
153
|
+
* envelope claiming an unknown type string is ledger-only upstream
|
|
154
|
+
* and gets no payload enforcement on this layer.
|
|
155
|
+
* - `spec === undefined` → `{valid: true, violations: []}`. Renders
|
|
156
|
+
* without an actionSpec have no contract; legacy renders keep
|
|
156
157
|
* flowing.
|
|
157
158
|
* - Otherwise `envelope.payload` is validated against `spec` via
|
|
158
159
|
* {@link validateActionData}. Same rules, same output shape.
|
|
159
160
|
*
|
|
160
|
-
* This helper does NOT enforce allowlist,
|
|
161
|
+
* This helper does NOT enforce allowlist, render binding, or render
|
|
161
162
|
* routing — those are ingress-plumbing concerns. Pure payload-shape
|
|
162
163
|
* check; returns `ValidationResult` rather than throwing so callers
|
|
163
164
|
* can decide whether to surface as a wire error, log, etc.
|
|
@@ -171,7 +172,7 @@ export declare function validateActionEnvelope(envelope: ActionEnvelope, spec: A
|
|
|
171
172
|
*
|
|
172
173
|
* The renderer iframe runs under a strict CSP with no `'unsafe-eval'`,
|
|
173
174
|
* so it cannot call `ajv.compile()` (which builds validators via
|
|
174
|
-
* `new Function`). Compilation therefore happens server-side at
|
|
175
|
+
* `new Function`). Compilation therefore happens server-side at render
|
|
175
176
|
* time — where the contract schema is fixed and codegen is legal — and
|
|
176
177
|
* the iframe loads each emitted module via a `blob:` dynamic import.
|
|
177
178
|
*
|
|
@@ -216,7 +217,7 @@ export declare function compileContractValidators(specs: {
|
|
|
216
217
|
* + Node — the producer's iteration order is preserved, so a given
|
|
217
218
|
* contract always serializes to identical bytes. {@link computeContractBundle}
|
|
218
219
|
* leans on that determinism so the resulting hash is stable across
|
|
219
|
-
*
|
|
220
|
+
* renders of the same contract.
|
|
220
221
|
*
|
|
221
222
|
* @public
|
|
222
223
|
*/
|
|
@@ -224,7 +225,7 @@ export declare function bundleCompiledValidatorsAsModule(compiled: CompiledContr
|
|
|
224
225
|
/**
|
|
225
226
|
* Convenience over {@link compileContractValidators} +
|
|
226
227
|
* {@link bundleCompiledValidatorsAsModule} + sha256 — produces the
|
|
227
|
-
* `{contractHash, bundleSource, validators}` triple the emitter (
|
|
228
|
+
* `{contractHash, bundleSource, validators}` triple the emitter (render.ts
|
|
228
229
|
* / update.ts in #109 C4) writes to the content-addressable store and
|
|
229
230
|
* emits as `_meta["ai.ggui/contract"] = {contractHash, validatorsUrl}`.
|
|
230
231
|
*
|