@ggui-ai/protocol 0.1.0-rc.1 → 0.2.0-alpha.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.
- package/README.md +3 -3
- package/dist/bridge/invoke-agent.d.ts +8 -8
- package/dist/bridge/invoke-agent.d.ts.map +1 -1
- package/dist/bridge/invoke-agent.js +12 -12
- package/dist/envelopes/builders.d.ts +2 -4
- package/dist/envelopes/builders.d.ts.map +1 -1
- package/dist/envelopes/builders.js +2 -6
- package/dist/gadgets/stdlib-gadgets.d.ts +1 -1
- package/dist/gadgets/stdlib-gadgets.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/integrations/mcp-apps.d.ts +354 -711
- package/dist/integrations/mcp-apps.d.ts.map +1 -1
- package/dist/integrations/mcp-apps.js +266 -208
- package/dist/recommended-prompts.d.ts +1 -1
- package/dist/recommended-prompts.js +1 -1
- package/dist/schemas/data-contract.d.ts +4 -3
- package/dist/schemas/data-contract.d.ts.map +1 -1
- package/dist/schemas/data-contract.js +4 -3
- package/dist/schemas/invoke.d.ts +2 -2
- package/dist/schemas/invoke.js +2 -2
- package/dist/schemas/mcp.d.ts +60 -79
- package/dist/schemas/mcp.d.ts.map +1 -1
- package/dist/schemas/mcp.js +93 -116
- package/dist/schemas/sync-check.js +1 -1
- package/dist/stream/stream-parser.d.ts +4 -4
- package/dist/stream/stream-parser.d.ts.map +1 -1
- package/dist/stream/stream-parser.js +9 -9
- package/dist/transport/websocket.d.ts +14 -49
- package/dist/transport/websocket.d.ts.map +1 -1
- package/dist/types/app-config.d.ts +17 -32
- package/dist/types/app-config.d.ts.map +1 -1
- package/dist/types/canvas-lifecycle.d.ts +13 -13
- package/dist/types/canvas-lifecycle.d.ts.map +1 -1
- package/dist/types/canvas-lifecycle.js +3 -3
- package/dist/types/contract-inference.d.ts +4 -7
- package/dist/types/contract-inference.d.ts.map +1 -1
- package/dist/types/data-bindings.d.ts +1 -1
- package/dist/types/data-bindings.d.ts.map +1 -1
- package/dist/types/data-contract.d.ts +10 -10
- package/dist/types/data-contract.d.ts.map +1 -1
- package/dist/types/events.d.ts +14 -56
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/events.js +1 -8
- package/dist/types/feedback.d.ts +2 -4
- package/dist/types/feedback.d.ts.map +1 -1
- package/dist/types/handshake-suggestion.d.ts +1 -1
- package/dist/types/host-context.d.ts +5 -15
- package/dist/types/host-context.d.ts.map +1 -1
- package/dist/types/host-context.js +1 -1
- package/dist/types/live-channel.d.ts +128 -191
- package/dist/types/live-channel.d.ts.map +1 -1
- package/dist/types/llm-route.d.ts +233 -0
- package/dist/types/llm-route.d.ts.map +1 -0
- package/dist/types/llm-route.js +433 -0
- package/dist/types/llm.d.ts +35 -17
- package/dist/types/llm.d.ts.map +1 -1
- package/dist/types/llm.js +50 -39
- package/dist/types/mcp.d.ts +47 -137
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/types/mcp.js +2 -2
- package/dist/types/openrouter-models.d.ts +3 -2
- package/dist/types/openrouter-models.d.ts.map +1 -1
- package/dist/types/render-event.d.ts +119 -0
- package/dist/types/render-event.d.ts.map +1 -0
- package/dist/types/render-event.js +38 -0
- package/dist/types/session.d.ts +216 -342
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/ui-generator.d.ts +8 -9
- package/dist/types/ui-generator.d.ts.map +1 -1
- package/dist/validation/contract-validator.d.ts +60 -4
- package/dist/validation/contract-validator.d.ts.map +1 -1
- package/dist/validation/contract-validator.js +101 -5
- package/dist/validation/reserved-channels.d.ts +1 -1
- package/dist/validation/reserved-channels.js +5 -5
- package/dist/validation/sanitize-error.js +1 -1
- package/dist/validation/schema-compat-invariants.d.ts +2 -2
- package/dist/validation/schema-compat-invariants.js +2 -2
- package/dist/validation/schema-meta-validation.d.ts +1 -1
- package/dist/validation/schema-meta-validation.js +2 -2
- package/dist/validation/schema-subset.d.ts +1 -1
- package/dist/version.d.ts +253 -46
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +253 -46
- package/package.json +17 -16
- package/dist/navigation/index.d.ts +0 -3
- package/dist/navigation/index.d.ts.map +0 -1
- package/dist/navigation/index.js +0 -1
- package/dist/navigation/stack-navigation.d.ts +0 -55
- package/dist/navigation/stack-navigation.d.ts.map +0 -1
- package/dist/navigation/stack-navigation.js +0 -80
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.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;AAK5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA+B9D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB,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,EAA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OAaG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;CACvC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,CAClE,SAAQ,UAAU;IAClB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,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;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EACA,QAAQ,GACR,aAAa,GACb,UAAU,GACV,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,UAAU,GACV,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { EventSubscription } from './events';
|
|
2
1
|
import type { DataContract, JsonObject, JsonSchema, JsonValue } from './data-contract';
|
|
3
2
|
/**
|
|
4
3
|
* Design system version — used as part of the cache fingerprint.
|
|
@@ -46,22 +45,22 @@ export declare function computeStyleFingerprint(input: StyleFingerprintInput): s
|
|
|
46
45
|
* Generic `TContext` defaults to {@link JsonObject} for generator context hints.
|
|
47
46
|
*/
|
|
48
47
|
export interface UIGenerationRequest<TContext = JsonObject> {
|
|
49
|
-
|
|
48
|
+
renderId: string;
|
|
50
49
|
prompt: string;
|
|
51
50
|
context?: TContext;
|
|
52
51
|
schema?: JsonSchema;
|
|
53
|
-
subscription?: EventSubscription;
|
|
54
52
|
}
|
|
55
53
|
/**
|
|
56
54
|
* Internal response from UI generation. This is the GENERATOR-OUTPUT
|
|
57
55
|
* shape — `componentCode` is the freshly produced ESM string. Before
|
|
58
|
-
* the
|
|
56
|
+
* the render commits to the wire, the slice-meta derivation
|
|
59
57
|
* uploads the code body and projects `codeUrl` (a fetchable URL) onto
|
|
60
|
-
* `
|
|
61
|
-
* runtimes fetch the code from `codeUrl`; they never see this
|
|
58
|
+
* the `ai.ggui/render` slice instead of inlining the source.
|
|
59
|
+
* Iframe runtimes fetch the code from `codeUrl`; they never see this
|
|
60
|
+
* field.
|
|
62
61
|
*/
|
|
63
62
|
export interface UIGenerationResponse {
|
|
64
|
-
|
|
63
|
+
renderId: string;
|
|
65
64
|
componentCode: string;
|
|
66
65
|
sourceCode?: string;
|
|
67
66
|
warnings?: string[];
|
|
@@ -71,8 +70,8 @@ export interface UIGenerationResponse {
|
|
|
71
70
|
* Populated by the generator when the component calls wire hooks
|
|
72
71
|
* (`useAction('name')`, `useStream('channel')`) — the generator
|
|
73
72
|
* extracts the call sites and emits a matching authoring-side
|
|
74
|
-
* envelope so downstream consumers (`
|
|
75
|
-
* inspectors,
|
|
73
|
+
* envelope so downstream consumers (`ggui_render` → Render, console
|
|
74
|
+
* inspectors, render-channel router) have the contract available.
|
|
76
75
|
*
|
|
77
76
|
* - When the caller supplied `UiGenerateInput.contract` that
|
|
78
77
|
* envelope is passed through as-is (already authoritative).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-generator.d.ts","sourceRoot":"","sources":["../../src/types/ui-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
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;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAuBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAO5E;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,QAAQ,GAAG,UAAU;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,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"}
|
|
@@ -167,7 +167,7 @@ export declare function validateActionEnvelope(envelope: ActionEnvelope, spec: A
|
|
|
167
167
|
* Compile a contract's runtime-validated sub-schemas into standalone,
|
|
168
168
|
* eval-free ESM validator modules — the producer half of the
|
|
169
169
|
* precompiled-validator channel
|
|
170
|
-
* ({@link CompiledContractValidators} on `
|
|
170
|
+
* ({@link CompiledContractValidators} on `McpAppAiGguiMeta`).
|
|
171
171
|
*
|
|
172
172
|
* The renderer iframe runs under a strict CSP with no `'unsafe-eval'`,
|
|
173
173
|
* so it cannot call `ajv.compile()` (which builds validators via
|
|
@@ -189,7 +189,7 @@ export declare function validateActionEnvelope(envelope: ActionEnvelope, spec: A
|
|
|
189
189
|
* validates `value`.
|
|
190
190
|
*
|
|
191
191
|
* Returns `undefined` when the contract declares no runtime-validated
|
|
192
|
-
* schema at all — the
|
|
192
|
+
* schema at all — the slice-meta projection then omits the field.
|
|
193
193
|
*/
|
|
194
194
|
export declare function compileContractValidators(specs: {
|
|
195
195
|
readonly propsSpec?: PropsSpec;
|
|
@@ -197,6 +197,62 @@ export declare function compileContractValidators(specs: {
|
|
|
197
197
|
readonly streamSpec?: StreamSpec;
|
|
198
198
|
readonly contextSpec?: ContextSpec;
|
|
199
199
|
}): CompiledContractValidators | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* Wrap a {@link CompiledContractValidators} object as the source text of
|
|
202
|
+
* an ES module whose `default` export is the same object. This is the
|
|
203
|
+
* wire format served from the content-addressable contract route
|
|
204
|
+
* (`GET /contract/<hash>.js`) in #109's decomposition slice — one URL,
|
|
205
|
+
* one fetch, one dynamic-import per unique contract.
|
|
206
|
+
*
|
|
207
|
+
* Why a wrapping module rather than emitting the validator-modules
|
|
208
|
+
* raw: each inner validator-module is independently `export default ...`,
|
|
209
|
+
* so they can't share a single file without name collisions. The
|
|
210
|
+
* iframe-runtime's existing `loadCompiledValidators` already knows how
|
|
211
|
+
* to take a `CompiledContractValidators` and load each inner module via
|
|
212
|
+
* `blob:` import; this wrapper just hands it the same shape it expects,
|
|
213
|
+
* sourced from one HTTP round-trip instead of inline.
|
|
214
|
+
*
|
|
215
|
+
* `JSON.stringify` is deterministic on objects with string keys in V8
|
|
216
|
+
* + Node — the producer's iteration order is preserved, so a given
|
|
217
|
+
* contract always serializes to identical bytes. {@link computeContractBundle}
|
|
218
|
+
* leans on that determinism so the resulting hash is stable across
|
|
219
|
+
* pushes of the same contract.
|
|
220
|
+
*
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export declare function bundleCompiledValidatorsAsModule(compiled: CompiledContractValidators): string;
|
|
224
|
+
/**
|
|
225
|
+
* Convenience over {@link compileContractValidators} +
|
|
226
|
+
* {@link bundleCompiledValidatorsAsModule} + sha256 — produces the
|
|
227
|
+
* `{contractHash, bundleSource, validators}` triple the emitter (push.ts
|
|
228
|
+
* / update.ts in #109 C4) writes to the content-addressable store and
|
|
229
|
+
* emits as `_meta["ai.ggui/contract"] = {contractHash, validatorsUrl}`.
|
|
230
|
+
*
|
|
231
|
+
* `contractHash` is `sha256(canonicalJsonStringify(specs))` (hex). Hashing
|
|
232
|
+
* the INPUT specs — not the compiled output — guarantees a stable hash
|
|
233
|
+
* across server processes and Ajv version bumps: the same contract
|
|
234
|
+
* definition always lands at the same URL. Compiled output bytes may
|
|
235
|
+
* differ across calls (Ajv's standalone emitter uses incrementing
|
|
236
|
+
* counter names like `validate10`/`validate11`), but the CodeStore is
|
|
237
|
+
* idempotent (first write wins) and the URL response carries
|
|
238
|
+
* `Cache-Control: immutable`, so browsers + CDNs lock in the
|
|
239
|
+
* first-served bytes and never observe a counter-name reshuffle.
|
|
240
|
+
*
|
|
241
|
+
* Returns `undefined` when the contract declares no runtime-validated
|
|
242
|
+
* schema at all (matches {@link compileContractValidators}'s posture).
|
|
243
|
+
*
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
export declare function computeContractBundle(specs: {
|
|
247
|
+
readonly propsSpec?: PropsSpec;
|
|
248
|
+
readonly actionSpec?: ActionSpec;
|
|
249
|
+
readonly streamSpec?: StreamSpec;
|
|
250
|
+
readonly contextSpec?: ContextSpec;
|
|
251
|
+
}): Promise<{
|
|
252
|
+
readonly contractHash: string;
|
|
253
|
+
readonly bundleSource: string;
|
|
254
|
+
readonly validators: CompiledContractValidators;
|
|
255
|
+
} | undefined>;
|
|
200
256
|
/**
|
|
201
257
|
* Format violations into a human-readable error message for the target agent.
|
|
202
258
|
*/
|
|
@@ -226,10 +282,10 @@ export declare function formatViolations(violations: ContractViolation[]): strin
|
|
|
226
282
|
export declare function validateContractStructure(contract: DataContract): ValidationResult;
|
|
227
283
|
export declare class ContractViolationError extends Error {
|
|
228
284
|
readonly violations: ContractViolation[];
|
|
229
|
-
readonly tool: '
|
|
285
|
+
readonly tool: 'ggui_render' | 'ggui_update' | 'ggui_emit' | 'ggui_event';
|
|
230
286
|
readonly hint: string;
|
|
231
287
|
constructor(opts: {
|
|
232
|
-
tool: '
|
|
288
|
+
tool: 'ggui_render' | 'ggui_update' | 'ggui_emit' | 'ggui_event';
|
|
233
289
|
violations: ContractViolation[];
|
|
234
290
|
hint?: string;
|
|
235
291
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-validator.d.ts","sourceRoot":"","sources":["../../src/validation/contract-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEnI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAO3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,EAKL,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,KAAK,EA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,SAAS,CACZ,CAeA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAIxE;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,YAAY,GAAG,gBAAgB,CAiGlF;AAyPD,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,GAAG,WAAW,GAAG,YAAY,CAAC;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE;QAChB,IAAI,EAAE,aAAa,GAAG,aAAa,GAAG,WAAW,GAAG,YAAY,CAAC;QACjE,UAAU,EAAE,iBAAiB,EAAE,CAAC;QAChC,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IASD,8DAA8D;IAC9D,WAAW,IAAI;QACb,KAAK,EAAE,oBAAoB,CAAC;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,iBAAiB,EAAE,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;KACd;CAQF"}
|
|
@@ -294,7 +294,7 @@ export function validateActionEnvelope(envelope, spec, precompiledActions) {
|
|
|
294
294
|
* Compile a contract's runtime-validated sub-schemas into standalone,
|
|
295
295
|
* eval-free ESM validator modules — the producer half of the
|
|
296
296
|
* precompiled-validator channel
|
|
297
|
-
* ({@link CompiledContractValidators} on `
|
|
297
|
+
* ({@link CompiledContractValidators} on `McpAppAiGguiMeta`).
|
|
298
298
|
*
|
|
299
299
|
* The renderer iframe runs under a strict CSP with no `'unsafe-eval'`,
|
|
300
300
|
* so it cannot call `ajv.compile()` (which builds validators via
|
|
@@ -316,7 +316,7 @@ export function validateActionEnvelope(envelope, spec, precompiledActions) {
|
|
|
316
316
|
* validates `value`.
|
|
317
317
|
*
|
|
318
318
|
* Returns `undefined` when the contract declares no runtime-validated
|
|
319
|
-
* schema at all — the
|
|
319
|
+
* schema at all — the slice-meta projection then omits the field.
|
|
320
320
|
*/
|
|
321
321
|
export function compileContractValidators(specs) {
|
|
322
322
|
const compilePerEntry = (spec) => {
|
|
@@ -350,6 +350,102 @@ export function compileContractValidators(specs) {
|
|
|
350
350
|
out.context = context;
|
|
351
351
|
return Object.keys(out).length > 0 ? out : undefined;
|
|
352
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Wrap a {@link CompiledContractValidators} object as the source text of
|
|
355
|
+
* an ES module whose `default` export is the same object. This is the
|
|
356
|
+
* wire format served from the content-addressable contract route
|
|
357
|
+
* (`GET /contract/<hash>.js`) in #109's decomposition slice — one URL,
|
|
358
|
+
* one fetch, one dynamic-import per unique contract.
|
|
359
|
+
*
|
|
360
|
+
* Why a wrapping module rather than emitting the validator-modules
|
|
361
|
+
* raw: each inner validator-module is independently `export default ...`,
|
|
362
|
+
* so they can't share a single file without name collisions. The
|
|
363
|
+
* iframe-runtime's existing `loadCompiledValidators` already knows how
|
|
364
|
+
* to take a `CompiledContractValidators` and load each inner module via
|
|
365
|
+
* `blob:` import; this wrapper just hands it the same shape it expects,
|
|
366
|
+
* sourced from one HTTP round-trip instead of inline.
|
|
367
|
+
*
|
|
368
|
+
* `JSON.stringify` is deterministic on objects with string keys in V8
|
|
369
|
+
* + Node — the producer's iteration order is preserved, so a given
|
|
370
|
+
* contract always serializes to identical bytes. {@link computeContractBundle}
|
|
371
|
+
* leans on that determinism so the resulting hash is stable across
|
|
372
|
+
* pushes of the same contract.
|
|
373
|
+
*
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
export function bundleCompiledValidatorsAsModule(compiled) {
|
|
377
|
+
return `export default ${JSON.stringify(compiled)};\n`;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Recursive canonical-JSON serializer with object keys sorted
|
|
381
|
+
* lexicographically at every depth. Output is byte-stable across any
|
|
382
|
+
* two callers building the same logical contract via different key
|
|
383
|
+
* orders (e.g. `{a:1, b:2}` vs `{b:2, a:1}`) — so {@link computeContractBundle}'s
|
|
384
|
+
* hash is robust to spec-author hand-ordering.
|
|
385
|
+
*
|
|
386
|
+
* Arrays preserve element order (semantically meaningful in JSON
|
|
387
|
+
* Schema, e.g. `required: [a, b]` differs from `[b, a]` for some
|
|
388
|
+
* validators / error message ordering). Functions are not part of
|
|
389
|
+
* `DataContract` specs, so the type-`function` branch is unreachable
|
|
390
|
+
* in normal use and excluded.
|
|
391
|
+
*/
|
|
392
|
+
function canonicalJsonStringify(value) {
|
|
393
|
+
if (value === null)
|
|
394
|
+
return 'null';
|
|
395
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
396
|
+
return JSON.stringify(value);
|
|
397
|
+
if (typeof value === 'string')
|
|
398
|
+
return JSON.stringify(value);
|
|
399
|
+
if (Array.isArray(value)) {
|
|
400
|
+
return `[${value.map(canonicalJsonStringify).join(',')}]`;
|
|
401
|
+
}
|
|
402
|
+
if (typeof value === 'object') {
|
|
403
|
+
const keys = Object.keys(value).sort();
|
|
404
|
+
const parts = keys.map((k) => `${JSON.stringify(k)}:${canonicalJsonStringify(value[k])}`);
|
|
405
|
+
return `{${parts.join(',')}}`;
|
|
406
|
+
}
|
|
407
|
+
// undefined / function — not valid inside DataContract specs.
|
|
408
|
+
return 'null';
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Convenience over {@link compileContractValidators} +
|
|
412
|
+
* {@link bundleCompiledValidatorsAsModule} + sha256 — produces the
|
|
413
|
+
* `{contractHash, bundleSource, validators}` triple the emitter (push.ts
|
|
414
|
+
* / update.ts in #109 C4) writes to the content-addressable store and
|
|
415
|
+
* emits as `_meta["ai.ggui/contract"] = {contractHash, validatorsUrl}`.
|
|
416
|
+
*
|
|
417
|
+
* `contractHash` is `sha256(canonicalJsonStringify(specs))` (hex). Hashing
|
|
418
|
+
* the INPUT specs — not the compiled output — guarantees a stable hash
|
|
419
|
+
* across server processes and Ajv version bumps: the same contract
|
|
420
|
+
* definition always lands at the same URL. Compiled output bytes may
|
|
421
|
+
* differ across calls (Ajv's standalone emitter uses incrementing
|
|
422
|
+
* counter names like `validate10`/`validate11`), but the CodeStore is
|
|
423
|
+
* idempotent (first write wins) and the URL response carries
|
|
424
|
+
* `Cache-Control: immutable`, so browsers + CDNs lock in the
|
|
425
|
+
* first-served bytes and never observe a counter-name reshuffle.
|
|
426
|
+
*
|
|
427
|
+
* Returns `undefined` when the contract declares no runtime-validated
|
|
428
|
+
* schema at all (matches {@link compileContractValidators}'s posture).
|
|
429
|
+
*
|
|
430
|
+
* @public
|
|
431
|
+
*/
|
|
432
|
+
export async function computeContractBundle(specs) {
|
|
433
|
+
const validators = compileContractValidators(specs);
|
|
434
|
+
if (validators === undefined)
|
|
435
|
+
return undefined;
|
|
436
|
+
const bundleSource = bundleCompiledValidatorsAsModule(validators);
|
|
437
|
+
// Web Crypto's subtle.digest is universal (Node 19+, all modern
|
|
438
|
+
// browsers, Workers). The protocol package ships into iframe-runtime
|
|
439
|
+
// bundles too — `node:crypto` would force esbuild to mark a Node
|
|
440
|
+
// builtin unresolved at browser bundle time even though this
|
|
441
|
+
// function is server-only at call time.
|
|
442
|
+
const bytes = new TextEncoder().encode(canonicalJsonStringify(specs));
|
|
443
|
+
const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);
|
|
444
|
+
const contractHash = Array.from(new Uint8Array(digest))
|
|
445
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
446
|
+
.join('');
|
|
447
|
+
return { contractHash, bundleSource, validators };
|
|
448
|
+
}
|
|
353
449
|
/**
|
|
354
450
|
* Format violations into a human-readable error message for the target agent.
|
|
355
451
|
*/
|
|
@@ -679,13 +775,13 @@ function validateSchemaStructure(schema, path, violations) {
|
|
|
679
775
|
* Thrown by commit/update/stream handlers when agent data doesn't match
|
|
680
776
|
* the negotiated contract. The MCP handler catches this and returns a
|
|
681
777
|
* structured error response with violations + hint so the agent can
|
|
682
|
-
* self-correct (fix data or propose a new contract via
|
|
778
|
+
* self-correct (fix data or propose a new contract via ggui_render).
|
|
683
779
|
*/
|
|
684
780
|
function defaultHintFor(tool) {
|
|
685
781
|
if (tool === 'ggui_event') {
|
|
686
|
-
return 'The user-action payload did not match the
|
|
782
|
+
return 'The user-action payload did not match the render\'s actionSpec. Re-check the client-side action wiring, or have the agent render a new UI whose actionSpec covers this payload shape.';
|
|
687
783
|
}
|
|
688
|
-
return 'Fix your data to match the contract, or call
|
|
784
|
+
return 'Fix your data to match the contract, or call ggui_render to create a new UI for this data shape.';
|
|
689
785
|
}
|
|
690
786
|
export class ContractViolationError extends Error {
|
|
691
787
|
violations;
|
|
@@ -3,7 +3,7 @@ import type { ValidationResult } from './contract-validator';
|
|
|
3
3
|
export declare const RESERVED_CHANNEL_PREFIX = "_ggui:";
|
|
4
4
|
/**
|
|
5
5
|
* Reserved channel for provisional A2UI assembly streams emitted by
|
|
6
|
-
* the server during fresh-gen `
|
|
6
|
+
* the server during fresh-gen `ggui_render` flows. The agent never
|
|
7
7
|
* authors messages on this channel; the renderer subscribes implicitly
|
|
8
8
|
* and dispatches the A2UI payload through its preview surface.
|
|
9
9
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const RESERVED_CHANNEL_PREFIX = '_ggui:';
|
|
3
3
|
/**
|
|
4
4
|
* Reserved channel for provisional A2UI assembly streams emitted by
|
|
5
|
-
* the server during fresh-gen `
|
|
5
|
+
* the server during fresh-gen `ggui_render` flows. The agent never
|
|
6
6
|
* authors messages on this channel; the renderer subscribes implicitly
|
|
7
7
|
* and dispatches the A2UI payload through its preview surface.
|
|
8
8
|
*/
|
|
@@ -329,12 +329,12 @@ export function validateCanvasLifecyclePayload(payload) {
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
break;
|
|
332
|
-
case '
|
|
333
|
-
requireString('
|
|
332
|
+
case 'render_started':
|
|
333
|
+
requireString('renderId');
|
|
334
334
|
requireString('intent');
|
|
335
335
|
break;
|
|
336
336
|
case 'consume_polling':
|
|
337
|
-
requireString('
|
|
337
|
+
requireString('renderId');
|
|
338
338
|
if (p.state !== 'open') {
|
|
339
339
|
violations.push({
|
|
340
340
|
field: 'state',
|
|
@@ -348,7 +348,7 @@ export function validateCanvasLifecyclePayload(payload) {
|
|
|
348
348
|
violations.push({
|
|
349
349
|
field: 'kind',
|
|
350
350
|
message: `Unknown lifecycle kind '${p.kind}'. Closed union; new kinds bump protocol version.`,
|
|
351
|
-
expected: "'handshake_started' | 'handshake_completed' | '
|
|
351
|
+
expected: "'handshake_started' | 'handshake_completed' | 'render_started' | 'consume_polling'",
|
|
352
352
|
received: p.kind,
|
|
353
353
|
});
|
|
354
354
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// and env-var dumps. The envelope flows on the reserved
|
|
10
10
|
// `_ggui:contract-error` channel with `replay: 'all'`, so anything that
|
|
11
11
|
// lands in `causedBy` persists in the session ring buffer and is visible
|
|
12
|
-
// in operator tools (
|
|
12
|
+
// in operator tools (RenderInspector activity panels). If an operator
|
|
13
13
|
// shares a bug report with that data, the credential leaks externally.
|
|
14
14
|
//
|
|
15
15
|
// This module's default posture is "sanitize before emission": the
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* `streamSpec[*].schema` vs `agentCapabilities.tools[*].inputSchema` /
|
|
19
19
|
* `outputSchema`, all of which are author-declared JSON Schemas
|
|
20
20
|
* already on the contract. No tool registry, no zod conversion, no
|
|
21
|
-
* server state. The server-level F4 check (`
|
|
21
|
+
* server state. The server-level F4 check (`checkRenderSchemaCompat`
|
|
22
22
|
* in `@ggui-ai/mcp-server`) compares the same `actionSpec` /
|
|
23
23
|
* `streamSpec` schemas against the SERVER-REGISTERED tools' actual
|
|
24
24
|
* zod schemas; it covers the operator-side "did the deployed tool
|
|
@@ -132,7 +132,7 @@ export declare class SchemaCompatInvariantError extends Error {
|
|
|
132
132
|
*
|
|
133
133
|
* Slots alongside `assertCrossReferences` + `assertNameInvariants`
|
|
134
134
|
* at push time. Different scope from the server-level
|
|
135
|
-
* `SchemaCompatError` thrown by `
|
|
135
|
+
* `SchemaCompatError` thrown by `checkRenderSchemaCompat` in
|
|
136
136
|
* `@ggui-ai/mcp-server`: this check uses ONLY the contract's own
|
|
137
137
|
* catalog; the server-level check uses the runtime tool registry.
|
|
138
138
|
*/
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* `streamSpec[*].schema` vs `agentCapabilities.tools[*].inputSchema` /
|
|
19
19
|
* `outputSchema`, all of which are author-declared JSON Schemas
|
|
20
20
|
* already on the contract. No tool registry, no zod conversion, no
|
|
21
|
-
* server state. The server-level F4 check (`
|
|
21
|
+
* server state. The server-level F4 check (`checkRenderSchemaCompat`
|
|
22
22
|
* in `@ggui-ai/mcp-server`) compares the same `actionSpec` /
|
|
23
23
|
* `streamSpec` schemas against the SERVER-REGISTERED tools' actual
|
|
24
24
|
* zod schemas; it covers the operator-side "did the deployed tool
|
|
@@ -208,7 +208,7 @@ export class SchemaCompatInvariantError extends Error {
|
|
|
208
208
|
*
|
|
209
209
|
* Slots alongside `assertCrossReferences` + `assertNameInvariants`
|
|
210
210
|
* at push time. Different scope from the server-level
|
|
211
|
-
* `SchemaCompatError` thrown by `
|
|
211
|
+
* `SchemaCompatError` thrown by `checkRenderSchemaCompat` in
|
|
212
212
|
* `@ggui-ai/mcp-server`: this check uses ONLY the contract's own
|
|
213
213
|
* catalog; the server-level check uses the runtime tool registry.
|
|
214
214
|
*/
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* Designed to slot at:
|
|
24
24
|
* - `ggui_handshake` entry — validates `blueprintDraft.contract`
|
|
25
25
|
* before the negotiator runs.
|
|
26
|
-
* - `
|
|
26
|
+
* - `ggui_render` entry — validates the `effectiveContract` (either
|
|
27
27
|
* synth-amended or override) before any state mutation.
|
|
28
28
|
*
|
|
29
29
|
* Both call sites already run cross-reference and name-invariant
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* Designed to slot at:
|
|
24
24
|
* - `ggui_handshake` entry — validates `blueprintDraft.contract`
|
|
25
25
|
* before the negotiator runs.
|
|
26
|
-
* - `
|
|
26
|
+
* - `ggui_render` entry — validates the `effectiveContract` (either
|
|
27
27
|
* synth-amended or override) before any state mutation.
|
|
28
28
|
*
|
|
29
29
|
* Both call sites already run cross-reference and name-invariant
|
|
@@ -50,7 +50,7 @@ export class ContractSchemaMetaError extends Error {
|
|
|
50
50
|
'Fix the JSON Schema at the named field. Common causes: ' +
|
|
51
51
|
'missing `items` on an array schema, a properties entry that ' +
|
|
52
52
|
'is not itself a JSON Schema object, or an unknown keyword. ' +
|
|
53
|
-
'Re-call
|
|
53
|
+
'Re-call ggui_render (or ggui_handshake) once corrected.';
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
function tryCompile(field, schema, violations) {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* **Check points.**
|
|
14
14
|
*
|
|
15
|
-
* - Pre-commit of a `
|
|
15
|
+
* - Pre-commit of a `Render` with `actionSpec` / `streamSpec`
|
|
16
16
|
* entries that reference tools: each action's declared schema
|
|
17
17
|
* MUST be a subset of the tool's inputSchema (what the action
|
|
18
18
|
* payload is allowed to send ⊆ what the tool accepts). Each
|