@ggui-ai/protocol 0.2.0-alpha.4 → 0.4.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 +71 -0
- package/dist/registry/portable-blueprint.d.ts.map +1 -0
- package/dist/registry/portable-blueprint.js +111 -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 +294 -59
- package/dist/schemas/mcp.d.ts.map +1 -1
- package/dist/schemas/mcp.js +350 -94
- 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-route.d.ts +4 -4
- package/dist/types/llm-route.d.ts.map +1 -1
- package/dist/types/llm-route.js +24 -2
- 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 +74 -177
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/types/mcp.js +11 -4
- 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 +61 -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 +24 -47
- 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 +818 -9
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +817 -8
- package/package.json +3 -3
- 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
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* 2. `actionSpec[*].schema` (optional per entry)
|
|
7
7
|
* 3. `streamSpec[*].schema`
|
|
8
8
|
* 4. `contextSpec[*].schema`
|
|
9
|
-
* 5. `agentCapabilities.tools[*].inputSchema` (
|
|
10
|
-
* 6. `agentCapabilities.tools[*].outputSchema` (optional per entry)
|
|
9
|
+
* 5. `agentCapabilities.tools[*].toolInfo.inputSchema` (required per entry)
|
|
10
|
+
* 6. `agentCapabilities.tools[*].toolInfo.outputSchema` (optional per entry)
|
|
11
11
|
*
|
|
12
12
|
* For each present schema, runs `compileForValidation()` from
|
|
13
13
|
* `ajv-runtime`. Ajv's `strict: true` mode throws on malformed JSON
|
|
@@ -40,7 +40,7 @@ export interface SchemaMetaViolation {
|
|
|
40
40
|
/**
|
|
41
41
|
* Typed error for contract schema meta-validation failures. Mirrors
|
|
42
42
|
* the shape of `CrossReferenceError` / `ContractViolationError` for
|
|
43
|
-
* symmetry —
|
|
43
|
+
* symmetry — render/handshake catch and surface a structured
|
|
44
44
|
* `contract_schema_invalid` error to the agent.
|
|
45
45
|
*/
|
|
46
46
|
export declare class ContractSchemaMetaError extends Error {
|
|
@@ -60,7 +60,7 @@ export declare class ContractSchemaMetaError extends Error {
|
|
|
60
60
|
* This is the inner-schema validity check folded into the unified
|
|
61
61
|
* `validateContract` gate (lint-contract.ts `phaseSchemaMeta`) — the
|
|
62
62
|
* one check the strict linter was previously missing relative to the
|
|
63
|
-
*
|
|
63
|
+
* render/handshake assert set.
|
|
64
64
|
*/
|
|
65
65
|
export declare function checkContractSchemasValid(contract: DataContract): SchemaMetaViolation[];
|
|
66
66
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-meta-validation.d.ts","sourceRoot":"","sources":["../../src/validation/schema-meta-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAG,yBAAyB,CAAU;IACnD,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,UAAU,EAAE,SAAS,mBAAmB,EAAE;CAWvD;AAmCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,GACrB,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"schema-meta-validation.d.ts","sourceRoot":"","sources":["../../src/validation/schema-meta-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAG,yBAAyB,CAAU;IACnD,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,UAAU,EAAE,SAAS,mBAAmB,EAAE;CAWvD;AAmCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,GACrB,mBAAmB,EAAE,CAmDvB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAKvE"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* 2. `actionSpec[*].schema` (optional per entry)
|
|
7
7
|
* 3. `streamSpec[*].schema`
|
|
8
8
|
* 4. `contextSpec[*].schema`
|
|
9
|
-
* 5. `agentCapabilities.tools[*].inputSchema` (
|
|
10
|
-
* 6. `agentCapabilities.tools[*].outputSchema` (optional per entry)
|
|
9
|
+
* 5. `agentCapabilities.tools[*].toolInfo.inputSchema` (required per entry)
|
|
10
|
+
* 6. `agentCapabilities.tools[*].toolInfo.outputSchema` (optional per entry)
|
|
11
11
|
*
|
|
12
12
|
* For each present schema, runs `compileForValidation()` from
|
|
13
13
|
* `ajv-runtime`. Ajv's `strict: true` mode throws on malformed JSON
|
|
@@ -34,7 +34,7 @@ import { compileForValidation } from './ajv-runtime.js';
|
|
|
34
34
|
/**
|
|
35
35
|
* Typed error for contract schema meta-validation failures. Mirrors
|
|
36
36
|
* the shape of `CrossReferenceError` / `ContractViolationError` for
|
|
37
|
-
* symmetry —
|
|
37
|
+
* symmetry — render/handshake catch and surface a structured
|
|
38
38
|
* `contract_schema_invalid` error to the agent.
|
|
39
39
|
*/
|
|
40
40
|
export class ContractSchemaMetaError extends Error {
|
|
@@ -91,7 +91,7 @@ function truncate(s, max) {
|
|
|
91
91
|
* This is the inner-schema validity check folded into the unified
|
|
92
92
|
* `validateContract` gate (lint-contract.ts `phaseSchemaMeta`) — the
|
|
93
93
|
* one check the strict linter was previously missing relative to the
|
|
94
|
-
*
|
|
94
|
+
* render/handshake assert set.
|
|
95
95
|
*/
|
|
96
96
|
export function checkContractSchemasValid(contract) {
|
|
97
97
|
const violations = [];
|
|
@@ -123,11 +123,9 @@ export function checkContractSchemasValid(contract) {
|
|
|
123
123
|
}
|
|
124
124
|
if (contract.agentCapabilities?.tools) {
|
|
125
125
|
for (const [name, entry] of Object.entries(contract.agentCapabilities.tools)) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (entry.outputSchema) {
|
|
130
|
-
tryCompile(`agentCapabilities.tools.${name}.outputSchema`, entry.outputSchema, violations);
|
|
126
|
+
tryCompile(`agentCapabilities.tools.${name}.inputSchema`, entry.toolInfo.inputSchema, violations);
|
|
127
|
+
if (entry.toolInfo.outputSchema) {
|
|
128
|
+
tryCompile(`agentCapabilities.tools.${name}.outputSchema`, entry.toolInfo.outputSchema, violations);
|
|
131
129
|
}
|
|
132
130
|
}
|
|
133
131
|
}
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
* schema accepts also pass the `superset` schema?".
|
|
4
4
|
*
|
|
5
5
|
* **Why this lives in the protocol package.** The schema-alignment
|
|
6
|
-
* contract is enforced at
|
|
7
|
-
* canonical failure is
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* contract is enforced at render-time + blueprint-registration; the
|
|
7
|
+
* canonical failure is the named `'SCHEMA_MISMATCH_ERROR'` rejection
|
|
8
|
+
* the push / registration call answers with — fail-loud at
|
|
9
|
+
* declaration time, before a malformed payload reaches the agentic
|
|
10
|
+
* loop. See the schema-compat docstrings
|
|
10
11
|
* on {@link ActionEntry.schema} and {@link StreamChannelEntry.schema}
|
|
11
12
|
* for the author-invariant the check enforces.
|
|
12
13
|
*
|
|
13
14
|
* **Check points.**
|
|
14
15
|
*
|
|
15
|
-
* - Pre-commit of a `
|
|
16
|
+
* - Pre-commit of a `GguiSession` with `actionSpec` / `streamSpec`
|
|
16
17
|
* entries that reference tools: each action's declared schema
|
|
17
18
|
* MUST be a subset of the tool's inputSchema (what the action
|
|
18
19
|
* payload is allowed to send ⊆ what the tool accepts). Each
|
|
@@ -71,13 +72,13 @@
|
|
|
71
72
|
* **Determinism contract.** No randomness, no IO, no thrown
|
|
72
73
|
* exceptions for normal violations. Every incompatibility is
|
|
73
74
|
* reported as a {@link SubsetViolation} with enough field-path
|
|
74
|
-
* context for the
|
|
75
|
+
* context for the `SCHEMA_MISMATCH_ERROR` rejection to name the
|
|
75
76
|
* mismatch cleanly. Thrown errors are reserved for programmer-
|
|
76
77
|
* bug conditions (a caller passes `null` where a JsonSchema is
|
|
77
78
|
* expected).
|
|
78
79
|
*
|
|
79
80
|
* @see ./schema-compat-invariants.ts — the protocol-level invariants
|
|
80
|
-
* that call this algorithm at
|
|
81
|
+
* that call this algorithm at render-time.
|
|
81
82
|
*/
|
|
82
83
|
import type { JsonSchema, JsonValue } from '../types/data-contract.js';
|
|
83
84
|
/**
|
|
@@ -132,7 +133,7 @@ export interface SubsetViolation {
|
|
|
132
133
|
* {@link SubsetViolation.superset}. */
|
|
133
134
|
readonly subset?: string;
|
|
134
135
|
/** Human-readable summary suitable for inclusion in a
|
|
135
|
-
* `SCHEMA_MISMATCH_ERROR`
|
|
136
|
+
* `SCHEMA_MISMATCH_ERROR` rejection. Producers MAY ignore this
|
|
136
137
|
* and render their own message from `path` + `reason` if they
|
|
137
138
|
* prefer a consistent localized format. */
|
|
138
139
|
readonly message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-subset.d.ts","sourceRoot":"","sources":["../../src/validation/schema-subset.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema-subset.d.ts","sourceRoot":"","sources":["../../src/validation/schema-subset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAC7B,eAAe;AACjB;sDACsD;GACpD,gBAAgB;AAClB;;;;mDAImD;GACjD,iBAAiB;AACnB;sEACsE;GACpE,kBAAkB;AACpB,mCAAmC;GACjC,gBAAgB;AAClB,sEAAsE;GACpE,8BAA8B;AAChC;;mDAEmD;GACjD,aAAa,CAAC;AAElB;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC;;sDAEkD;IAClD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;4CACwC;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;gDAG4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;CACjD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,UAAU,GACjB,kBAAkB,CAiBpB;AAoTD,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -25,8 +25,6 @@ export interface DangerousPattern {
|
|
|
25
25
|
* These are security-critical — changes here affect every validation consumer.
|
|
26
26
|
*/
|
|
27
27
|
export declare const DANGEROUS_PATTERNS: DangerousPattern[];
|
|
28
|
-
/** Import prefixes that indicate a fullstack UI (requires client bundle). */
|
|
29
|
-
export declare const FULLSTACK_IMPORT_PREFIXES: readonly ["@ggui-ai/wire", "@ggui-ai/react", "@app/components"];
|
|
30
28
|
/**
|
|
31
29
|
* Classify a component as sandboxed or fullstack based on its imports.
|
|
32
30
|
*
|
|
@@ -36,19 +34,4 @@ export declare const FULLSTACK_IMPORT_PREFIXES: readonly ["@ggui-ai/wire", "@ggu
|
|
|
36
34
|
* Works on both source (.tsx) and compiled (.js) code.
|
|
37
35
|
*/
|
|
38
36
|
export declare function classifyUi(code: string): UiClass;
|
|
39
|
-
export interface SecurityCheckResult {
|
|
40
|
-
/** True if no dangerous patterns found. */
|
|
41
|
-
safe: boolean;
|
|
42
|
-
/** List of violations found. */
|
|
43
|
-
violations: Array<{
|
|
44
|
-
name: string;
|
|
45
|
-
suggestion: string;
|
|
46
|
-
line?: number;
|
|
47
|
-
}>;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Check code for dangerous patterns.
|
|
51
|
-
* Works on both source and compiled code.
|
|
52
|
-
*/
|
|
53
|
-
export declare function checkSecurity(code: string): SecurityCheckResult;
|
|
54
37
|
//# sourceMappingURL=ui-security.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-security.d.ts","sourceRoot":"","sources":["../../src/validation/ui-security.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ui-security.d.ts","sourceRoot":"","sources":["../../src/validation/ui-security.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;AAMhD,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAiFhD,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUhD"}
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Shared UI security validation — single source of truth for dangerous
|
|
4
4
|
// patterns and UI classification. Used by:
|
|
5
|
-
// -
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// - @ggui-ai/ui-gen src/validation/component-detailed.ts
|
|
6
|
+
// (validateComponentDetailed — the generator/compiler validation
|
|
7
|
+
// pipeline, consumes DANGEROUS_PATTERNS)
|
|
8
|
+
// - @ggui-ai/ui-gen src/validation/ui-compiler.ts (standalone
|
|
9
|
+
// compileUi/validateUi — consumes classifyUi + UiClass)
|
|
10
|
+
// - @ggui-ai/project-config src/ui-manifest.ts (UiManifest schema —
|
|
11
|
+
// validates against the UiClass vocabulary owned here)
|
|
8
12
|
//
|
|
9
13
|
// This module is PUBLIC (@ggui-ai/protocol) — keep it dependency-free.
|
|
10
14
|
/**
|
|
@@ -94,8 +98,11 @@ export const DANGEROUS_PATTERNS = [
|
|
|
94
98
|
},
|
|
95
99
|
];
|
|
96
100
|
// ── UI Classification ───────────────────────────────────────────────
|
|
97
|
-
/**
|
|
98
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Import prefixes that indicate a fullstack UI (requires client bundle).
|
|
103
|
+
* Internal input of {@link classifyUi} — not part of the published API.
|
|
104
|
+
*/
|
|
105
|
+
const FULLSTACK_IMPORT_PREFIXES = [
|
|
99
106
|
'@ggui-ai/wire',
|
|
100
107
|
'@ggui-ai/react',
|
|
101
108
|
'@app/components',
|
|
@@ -119,20 +126,8 @@ export function classifyUi(code) {
|
|
|
119
126
|
}
|
|
120
127
|
return 'sandboxed';
|
|
121
128
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const violations = [];
|
|
128
|
-
for (const { pattern, name, suggestion } of DANGEROUS_PATTERNS) {
|
|
129
|
-
// Reset lastIndex for global regexes
|
|
130
|
-
const re = new RegExp(pattern.source, pattern.flags);
|
|
131
|
-
const match = re.exec(code);
|
|
132
|
-
if (match) {
|
|
133
|
-
const line = code.substring(0, match.index).split('\n').length;
|
|
134
|
-
violations.push({ name, suggestion, line });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return { safe: violations.length === 0, violations };
|
|
138
|
-
}
|
|
129
|
+
// ── Content Hash ────────────────────────────────────────────────────
|
|
130
|
+
//
|
|
131
|
+
// Moved to `./content-hash` because it depends on `node:crypto`. Server-
|
|
132
|
+
// only callers import it via `@ggui-ai/protocol/content-hash` — see that
|
|
133
|
+
// file's header for rationale.
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*
|
|
34
34
|
* **Intended call sites.**
|
|
35
35
|
*
|
|
36
|
-
* -
|
|
36
|
+
* - render-time + blueprint-registration schema-compat checks in
|
|
37
37
|
* `@ggui-ai/mcp-server`: a mount-registered tool handler exposes
|
|
38
38
|
* its `inputSchema` as a {@link ZodRawShape}; wrapping it in
|
|
39
39
|
* `z.object(shape)` and converting gives the JsonSchema that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-to-json-schema.d.ts","sourceRoot":"","sources":["../../src/validation/zod-to-json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAK,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"zod-to-json-schema.d.ts","sourceRoot":"","sources":["../../src/validation/zod-to-json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAK,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,CAQxE"}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*
|
|
34
34
|
* **Intended call sites.**
|
|
35
35
|
*
|
|
36
|
-
* -
|
|
36
|
+
* - render-time + blueprint-registration schema-compat checks in
|
|
37
37
|
* `@ggui-ai/mcp-server`: a mount-registered tool handler exposes
|
|
38
38
|
* its `inputSchema` as a {@link ZodRawShape}; wrapping it in
|
|
39
39
|
* `z.object(shape)` and converting gives the JsonSchema that
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
* @see ./schema-subset.ts
|
|
45
45
|
*/
|
|
46
46
|
import { z } from 'zod';
|
|
47
|
+
import { isRecord } from './is-record.js';
|
|
47
48
|
/**
|
|
48
49
|
* Convert a zod schema (or raw shape) to a {@link JsonSchema} suitable
|
|
49
50
|
* for the subset algorithm.
|
|
@@ -78,13 +79,13 @@ export function zodToJsonSchema(input) {
|
|
|
78
79
|
function normalize(value) {
|
|
79
80
|
if (Array.isArray(value))
|
|
80
81
|
return value.map(normalize);
|
|
81
|
-
if (value
|
|
82
|
+
if (!isRecord(value))
|
|
82
83
|
return value;
|
|
83
84
|
const out = {};
|
|
84
85
|
for (const [key, v] of Object.entries(value)) {
|
|
85
86
|
if (key === '$schema')
|
|
86
87
|
continue;
|
|
87
|
-
if (key === 'properties' && v
|
|
88
|
+
if (key === 'properties' && isRecord(v)) {
|
|
88
89
|
const props = {};
|
|
89
90
|
for (const [pkey, pval] of Object.entries(v)) {
|
|
90
91
|
props[pkey] = normalize(pval);
|