@ggui-ai/protocol 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +46 -0
- package/dist/bridge/invoke-agent.d.ts +65 -0
- package/dist/bridge/invoke-agent.d.ts.map +1 -0
- package/dist/bridge/invoke-agent.js +113 -0
- package/dist/envelope-adapters.d.ts +24 -0
- package/dist/envelope-adapters.d.ts.map +1 -0
- package/dist/envelope-adapters.js +14 -0
- package/dist/envelopes/builders.d.ts +145 -0
- package/dist/envelopes/builders.d.ts.map +1 -0
- package/dist/envelopes/builders.js +113 -0
- package/dist/errors/unknown-permission-name.d.ts +12 -0
- package/dist/errors/unknown-permission-name.d.ts.map +1 -0
- package/dist/errors/unknown-permission-name.js +29 -0
- package/dist/errors/version-mismatch.d.ts +55 -0
- package/dist/errors/version-mismatch.d.ts.map +1 -0
- package/dist/errors/version-mismatch.js +52 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts +93 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts.map +1 -0
- package/dist/gadgets/resolve-contract-gadgets.js +119 -0
- package/dist/gadgets/stdlib-gadgets.d.ts +43 -0
- package/dist/gadgets/stdlib-gadgets.d.ts.map +1 -0
- package/dist/gadgets/stdlib-gadgets.js +161 -0
- package/dist/iframe-bridge.d.ts +63 -0
- package/dist/iframe-bridge.d.ts.map +1 -0
- package/dist/iframe-bridge.js +166 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +79 -0
- package/dist/integrations/mcp-apps.d.ts +1218 -0
- package/dist/integrations/mcp-apps.d.ts.map +1 -0
- package/dist/integrations/mcp-apps.js +427 -0
- package/dist/navigation/index.d.ts +3 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stack-navigation.d.ts +55 -0
- package/dist/navigation/stack-navigation.d.ts.map +1 -0
- package/dist/navigation/stack-navigation.js +80 -0
- package/dist/recommended-prompts.d.ts +56 -0
- package/dist/recommended-prompts.d.ts.map +1 -0
- package/dist/recommended-prompts.js +55 -0
- package/dist/registry/blueprint-key.d.ts +9 -0
- package/dist/registry/blueprint-key.d.ts.map +1 -0
- package/dist/registry/blueprint-key.js +28 -0
- package/dist/registry/canonicalize-contract.d.ts +35 -0
- package/dist/registry/canonicalize-contract.d.ts.map +1 -0
- package/dist/registry/canonicalize-contract.js +166 -0
- package/dist/registry/summarize-contract.d.ts +46 -0
- package/dist/registry/summarize-contract.d.ts.map +1 -0
- package/dist/registry/summarize-contract.js +63 -0
- package/dist/schema-learning/derive-contract.d.ts +67 -0
- package/dist/schema-learning/derive-contract.d.ts.map +1 -0
- package/dist/schema-learning/derive-contract.js +117 -0
- package/dist/schema-learning/merge.d.ts +32 -0
- package/dist/schema-learning/merge.d.ts.map +1 -0
- package/dist/schema-learning/merge.js +146 -0
- package/dist/schemas/blueprint.d.ts +32 -0
- package/dist/schemas/blueprint.d.ts.map +1 -0
- package/dist/schemas/blueprint.js +92 -0
- package/dist/schemas/data-contract.d.ts +750 -0
- package/dist/schemas/data-contract.d.ts.map +1 -0
- package/dist/schemas/data-contract.js +663 -0
- package/dist/schemas/gadget-name-grammar.d.ts +29 -0
- package/dist/schemas/gadget-name-grammar.d.ts.map +1 -0
- package/dist/schemas/gadget-name-grammar.js +28 -0
- package/dist/schemas/handshake-suggestion.d.ts +46 -0
- package/dist/schemas/handshake-suggestion.d.ts.map +1 -0
- package/dist/schemas/handshake-suggestion.js +107 -0
- package/dist/schemas/invoke.d.ts +337 -0
- package/dist/schemas/invoke.d.ts.map +1 -0
- package/dist/schemas/invoke.js +169 -0
- package/dist/schemas/mcp.d.ts +301 -0
- package/dist/schemas/mcp.d.ts.map +1 -0
- package/dist/schemas/mcp.js +373 -0
- package/dist/schemas/ops-blueprint.d.ts +176 -0
- package/dist/schemas/ops-blueprint.d.ts.map +1 -0
- package/dist/schemas/ops-blueprint.js +259 -0
- package/dist/schemas/sync-check.d.ts +11 -0
- package/dist/schemas/sync-check.d.ts.map +1 -0
- package/dist/schemas/sync-check.js +60 -0
- package/dist/screen-blueprints/define.d.ts +22 -0
- package/dist/screen-blueprints/define.d.ts.map +1 -0
- package/dist/screen-blueprints/define.js +3 -0
- package/dist/screen-blueprints/index.d.ts +4 -0
- package/dist/screen-blueprints/index.d.ts.map +1 -0
- package/dist/screen-blueprints/index.js +3 -0
- package/dist/screen-blueprints/match.d.ts +35 -0
- package/dist/screen-blueprints/match.d.ts.map +1 -0
- package/dist/screen-blueprints/match.js +51 -0
- package/dist/screen-blueprints/types.d.ts +164 -0
- package/dist/screen-blueprints/types.d.ts.map +1 -0
- package/dist/screen-blueprints/types.js +1 -0
- package/dist/stream/stream-parser.d.ts +62 -0
- package/dist/stream/stream-parser.d.ts.map +1 -0
- package/dist/stream/stream-parser.js +199 -0
- package/dist/transport/websocket.d.ts +178 -0
- package/dist/transport/websocket.d.ts.map +1 -0
- package/dist/transport/websocket.js +1 -0
- package/dist/types/app-config.d.ts +61 -0
- package/dist/types/app-config.d.ts.map +1 -0
- package/dist/types/app-config.js +1 -0
- package/dist/types/auth.d.ts +61 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +1 -0
- package/dist/types/blueprint.d.ts +206 -0
- package/dist/types/blueprint.d.ts.map +1 -0
- package/dist/types/blueprint.js +1 -0
- package/dist/types/canvas-lifecycle.d.ts +105 -0
- package/dist/types/canvas-lifecycle.d.ts.map +1 -0
- package/dist/types/canvas-lifecycle.js +38 -0
- package/dist/types/capabilities.d.ts +40 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +19 -0
- package/dist/types/contract-inference.d.ts +401 -0
- package/dist/types/contract-inference.d.ts.map +1 -0
- package/dist/types/contract-inference.js +44 -0
- package/dist/types/credential.d.ts +41 -0
- package/dist/types/credential.d.ts.map +1 -0
- package/dist/types/credential.js +32 -0
- package/dist/types/data-bindings.d.ts +322 -0
- package/dist/types/data-bindings.d.ts.map +1 -0
- package/dist/types/data-bindings.js +29 -0
- package/dist/types/data-contract.d.ts +1296 -0
- package/dist/types/data-contract.d.ts.map +1 -0
- package/dist/types/data-contract.js +111 -0
- package/dist/types/events.d.ts +182 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +8 -0
- package/dist/types/feedback.d.ts +24 -0
- package/dist/types/feedback.d.ts.map +1 -0
- package/dist/types/feedback.js +7 -0
- package/dist/types/gadget.d.ts +121 -0
- package/dist/types/gadget.d.ts.map +1 -0
- package/dist/types/gadget.js +24 -0
- package/dist/types/handshake-suggestion.d.ts +264 -0
- package/dist/types/handshake-suggestion.d.ts.map +1 -0
- package/dist/types/handshake-suggestion.js +70 -0
- package/dist/types/host-context.d.ts +163 -0
- package/dist/types/host-context.d.ts.map +1 -0
- package/dist/types/host-context.js +142 -0
- package/dist/types/interface-context.d.ts +105 -0
- package/dist/types/interface-context.d.ts.map +1 -0
- package/dist/types/interface-context.js +115 -0
- package/dist/types/invoke.d.ts +28 -0
- package/dist/types/invoke.d.ts.map +1 -0
- package/dist/types/invoke.js +7 -0
- package/dist/types/live-channel.d.ts +613 -0
- package/dist/types/live-channel.d.ts.map +1 -0
- package/dist/types/live-channel.js +1 -0
- package/dist/types/llm.d.ts +61 -0
- package/dist/types/llm.d.ts.map +1 -0
- package/dist/types/llm.js +186 -0
- package/dist/types/mcp-proxy.d.ts +67 -0
- package/dist/types/mcp-proxy.d.ts.map +1 -0
- package/dist/types/mcp-proxy.js +46 -0
- package/dist/types/mcp.d.ts +637 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +30 -0
- package/dist/types/openrouter-models.d.ts +22 -0
- package/dist/types/openrouter-models.d.ts.map +1 -0
- package/dist/types/openrouter-models.js +4843 -0
- package/dist/types/region.d.ts +26 -0
- package/dist/types/region.d.ts.map +1 -0
- package/dist/types/region.js +36 -0
- package/dist/types/session.d.ts +419 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +1 -0
- package/dist/types/thread.d.ts +207 -0
- package/dist/types/thread.d.ts.map +1 -0
- package/dist/types/thread.js +57 -0
- package/dist/types/ui-generator.d.ts +100 -0
- package/dist/types/ui-generator.d.ts.map +1 -0
- package/dist/types/ui-generator.js +53 -0
- package/dist/validation/ajv-runtime.d.ts +140 -0
- package/dist/validation/ajv-runtime.d.ts.map +1 -0
- package/dist/validation/ajv-runtime.js +452 -0
- package/dist/validation/content-hash.d.ts +3 -0
- package/dist/validation/content-hash.d.ts.map +1 -0
- package/dist/validation/content-hash.js +21 -0
- package/dist/validation/contract-validator.d.ts +244 -0
- package/dist/validation/contract-validator.d.ts.map +1 -0
- package/dist/validation/contract-validator.js +711 -0
- package/dist/validation/cross-references.d.ts +105 -0
- package/dist/validation/cross-references.d.ts.map +1 -0
- package/dist/validation/cross-references.js +164 -0
- package/dist/validation/hygiene-rules.d.ts +250 -0
- package/dist/validation/hygiene-rules.d.ts.map +1 -0
- package/dist/validation/hygiene-rules.js +564 -0
- package/dist/validation/lint-contract.d.ts +130 -0
- package/dist/validation/lint-contract.d.ts.map +1 -0
- package/dist/validation/lint-contract.js +225 -0
- package/dist/validation/name-invariants.d.ts +117 -0
- package/dist/validation/name-invariants.d.ts.map +1 -0
- package/dist/validation/name-invariants.js +172 -0
- package/dist/validation/reserved-channels.d.ts +156 -0
- package/dist/validation/reserved-channels.d.ts.map +1 -0
- package/dist/validation/reserved-channels.js +356 -0
- package/dist/validation/resolve-stream-channel.d.ts +78 -0
- package/dist/validation/resolve-stream-channel.d.ts.map +1 -0
- package/dist/validation/resolve-stream-channel.js +64 -0
- package/dist/validation/sanitize-error.d.ts +46 -0
- package/dist/validation/sanitize-error.d.ts.map +1 -0
- package/dist/validation/sanitize-error.js +88 -0
- package/dist/validation/schema-compat-invariants.d.ts +140 -0
- package/dist/validation/schema-compat-invariants.d.ts.map +1 -0
- package/dist/validation/schema-compat-invariants.js +220 -0
- package/dist/validation/schema-meta-validation.d.ts +60 -0
- package/dist/validation/schema-meta-validation.d.ts.map +1 -0
- package/dist/validation/schema-meta-validation.js +131 -0
- package/dist/validation/schema-subset.d.ts +165 -0
- package/dist/validation/schema-subset.d.ts.map +1 -0
- package/dist/validation/schema-subset.js +295 -0
- package/dist/validation/ui-security.d.ts +54 -0
- package/dist/validation/ui-security.d.ts.map +1 -0
- package/dist/validation/ui-security.js +138 -0
- package/dist/validation/zod-to-json-schema.d.ts +63 -0
- package/dist/validation/zod-to-json-schema.d.ts.map +1 -0
- package/dist/validation/zod-to-json-schema.js +126 -0
- package/dist/version.d.ts +1458 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1459 -0
- package/package.json +113 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/** Infer a JSON Schema from a single JSON value. */
|
|
2
|
+
export function inferSchema(value) {
|
|
3
|
+
if (value === null)
|
|
4
|
+
return { type: "null" };
|
|
5
|
+
if (typeof value === "boolean")
|
|
6
|
+
return { type: "boolean" };
|
|
7
|
+
if (typeof value === "number") {
|
|
8
|
+
return { type: Number.isInteger(value) ? "integer" : "number" };
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === "string")
|
|
11
|
+
return { type: "string" };
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
if (value.length === 0)
|
|
14
|
+
return { type: "array" };
|
|
15
|
+
// Fold all elements into a single item schema.
|
|
16
|
+
let items = inferSchema(value[0]);
|
|
17
|
+
for (let i = 1; i < value.length; i++) {
|
|
18
|
+
items = mergeTwoSchemas(items, inferSchema(value[i]));
|
|
19
|
+
}
|
|
20
|
+
return { type: "array", items };
|
|
21
|
+
}
|
|
22
|
+
// Object
|
|
23
|
+
const obj = value;
|
|
24
|
+
const keys = Object.keys(obj);
|
|
25
|
+
const properties = {};
|
|
26
|
+
for (const k of keys) {
|
|
27
|
+
properties[k] = inferSchema(obj[k]);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties,
|
|
32
|
+
required: keys.slice().sort(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Merge a new observed sample into an existing schema. If `existing` is null,
|
|
37
|
+
* returns the schema inferred from `sample` alone.
|
|
38
|
+
*/
|
|
39
|
+
export function mergeSchema(existing, sample) {
|
|
40
|
+
const inferred = inferSchema(sample);
|
|
41
|
+
if (!existing)
|
|
42
|
+
return inferred;
|
|
43
|
+
return mergeTwoSchemas(existing, inferred);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Merge two schemas into one that accepts values satisfying either. Exported
|
|
47
|
+
* for the seeder path (combining two known schemas without sampling).
|
|
48
|
+
*/
|
|
49
|
+
export function mergeTwoSchemas(a, b) {
|
|
50
|
+
// null + X → X nullable
|
|
51
|
+
if (a.type === "null" && b.type !== "null")
|
|
52
|
+
return withNullable(b);
|
|
53
|
+
if (b.type === "null" && a.type !== "null")
|
|
54
|
+
return withNullable(a);
|
|
55
|
+
if (a.type === "null" && b.type === "null")
|
|
56
|
+
return { type: "null" };
|
|
57
|
+
// Same type — structural merge.
|
|
58
|
+
if (a.type === b.type) {
|
|
59
|
+
if (a.type === "object")
|
|
60
|
+
return mergeObjects(a, b);
|
|
61
|
+
if (a.type === "array")
|
|
62
|
+
return mergeArrays(a, b);
|
|
63
|
+
// Primitives — keep a's metadata as the canonical one; carry nullability forward.
|
|
64
|
+
const merged = { type: a.type };
|
|
65
|
+
if (a.nullable || b.nullable)
|
|
66
|
+
merged.nullable = true;
|
|
67
|
+
if (a.format && b.format && a.format === b.format)
|
|
68
|
+
merged.format = a.format;
|
|
69
|
+
return merged;
|
|
70
|
+
}
|
|
71
|
+
// integer + number → number (widen)
|
|
72
|
+
if ((a.type === "integer" && b.type === "number") || (a.type === "number" && b.type === "integer")) {
|
|
73
|
+
const merged = { type: "number" };
|
|
74
|
+
if (a.nullable || b.nullable)
|
|
75
|
+
merged.nullable = true;
|
|
76
|
+
return merged;
|
|
77
|
+
}
|
|
78
|
+
// Conflicting types — union via anyOf.
|
|
79
|
+
return { anyOf: dedupeAnyOf([...flattenAnyOf(a), ...flattenAnyOf(b)]) };
|
|
80
|
+
}
|
|
81
|
+
function mergeObjects(a, b) {
|
|
82
|
+
const aProps = a.properties ?? {};
|
|
83
|
+
const bProps = b.properties ?? {};
|
|
84
|
+
const allKeys = new Set([...Object.keys(aProps), ...Object.keys(bProps)]);
|
|
85
|
+
const merged = {};
|
|
86
|
+
for (const k of allKeys) {
|
|
87
|
+
const pa = aProps[k];
|
|
88
|
+
const pb = bProps[k];
|
|
89
|
+
if (pa && pb)
|
|
90
|
+
merged[k] = mergeTwoSchemas(pa, pb);
|
|
91
|
+
else
|
|
92
|
+
merged[k] = (pa ?? pb);
|
|
93
|
+
}
|
|
94
|
+
// Required = intersection. A field missing from either sample cannot be required.
|
|
95
|
+
const aReq = new Set(a.required ?? []);
|
|
96
|
+
const bReq = b.required ?? [];
|
|
97
|
+
const requiredSet = new Set();
|
|
98
|
+
for (const k of bReq)
|
|
99
|
+
if (aReq.has(k))
|
|
100
|
+
requiredSet.add(k);
|
|
101
|
+
const required = Array.from(requiredSet).sort();
|
|
102
|
+
const out = { type: "object", properties: merged };
|
|
103
|
+
if (required.length > 0)
|
|
104
|
+
out.required = required;
|
|
105
|
+
if (a.nullable || b.nullable)
|
|
106
|
+
out.nullable = true;
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
function mergeArrays(a, b) {
|
|
110
|
+
const items = a.items && b.items ? mergeTwoSchemas(a.items, b.items) : (a.items ?? b.items);
|
|
111
|
+
const out = { type: "array" };
|
|
112
|
+
if (items)
|
|
113
|
+
out.items = items;
|
|
114
|
+
if (a.nullable || b.nullable)
|
|
115
|
+
out.nullable = true;
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
function withNullable(s) {
|
|
119
|
+
if (s.nullable)
|
|
120
|
+
return s;
|
|
121
|
+
return { ...s, nullable: true };
|
|
122
|
+
}
|
|
123
|
+
function flattenAnyOf(s) {
|
|
124
|
+
if (s.anyOf && s.anyOf.length > 0)
|
|
125
|
+
return s.anyOf.slice();
|
|
126
|
+
return [s];
|
|
127
|
+
}
|
|
128
|
+
function dedupeAnyOf(list) {
|
|
129
|
+
const seen = new Map();
|
|
130
|
+
for (const s of list) {
|
|
131
|
+
const key = canonicalKey(s);
|
|
132
|
+
if (!seen.has(key))
|
|
133
|
+
seen.set(key, s);
|
|
134
|
+
}
|
|
135
|
+
return Array.from(seen.values());
|
|
136
|
+
}
|
|
137
|
+
/** Deterministic stable key — recursive, sorts object keys at every depth. */
|
|
138
|
+
function canonicalKey(v) {
|
|
139
|
+
if (v === null || typeof v !== "object")
|
|
140
|
+
return JSON.stringify(v);
|
|
141
|
+
if (Array.isArray(v))
|
|
142
|
+
return "[" + v.map(canonicalKey).join(",") + "]";
|
|
143
|
+
const obj = v;
|
|
144
|
+
const keys = Object.keys(obj).sort();
|
|
145
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canonicalKey(obj[k])).join(",") + "}";
|
|
146
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema mirror of {@link Blueprint}. Structural-mirror discipline
|
|
3
|
+
* matches `data-contract.ts`'s posture: the TS interface in
|
|
4
|
+
* `../types/blueprint.ts` is the declared source of truth; the schema
|
|
5
|
+
* here is `z.ZodType<Blueprint>` so any drift fails compile.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import type { AppBlueprintSearchConfig, Blueprint, BlueprintSearchWeights, BlueprintVariance } from '../types/blueprint';
|
|
9
|
+
/** Zod mirror of {@link BlueprintVariance}. */
|
|
10
|
+
export declare const blueprintVarianceSchema: z.ZodType<BlueprintVariance>;
|
|
11
|
+
/**
|
|
12
|
+
* Zod mirror of {@link Blueprint}. Required fields are listed first;
|
|
13
|
+
* `passthrough()` is intentionally NOT applied — blueprint rows are
|
|
14
|
+
* a closed shape (every field is enumerated here), and stray fields
|
|
15
|
+
* in persisted rows are a bug worth surfacing rather than tolerating.
|
|
16
|
+
*/
|
|
17
|
+
export declare const blueprintSchema: z.ZodType<Blueprint>;
|
|
18
|
+
/**
|
|
19
|
+
* Zod mirror of {@link BlueprintSearchWeights}. Every axis is a
|
|
20
|
+
* non-negative finite number. Per-axis defaults are applied at the
|
|
21
|
+
* impl layer (see `DEFAULT_BLUEPRINT_SEARCH_WEIGHTS` in
|
|
22
|
+
* `@ggui-ai/mcp-server-core`); this schema only validates the shape
|
|
23
|
+
* an operator passes through `App.blueprintSearchConfig.weights`
|
|
24
|
+
* when the operator provides EVERY axis.
|
|
25
|
+
*/
|
|
26
|
+
export declare const blueprintSearchWeightsSchema: z.ZodType<BlueprintSearchWeights>;
|
|
27
|
+
/**
|
|
28
|
+
* Zod mirror of {@link AppBlueprintSearchConfig}. All fields optional;
|
|
29
|
+
* server applies the global default for any axis the operator omits.
|
|
30
|
+
*/
|
|
31
|
+
export declare const appBlueprintSearchConfigSchema: z.ZodType<AppBlueprintSearchConfig>;
|
|
32
|
+
//# sourceMappingURL=blueprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blueprint.d.ts","sourceRoot":"","sources":["../../src/schemas/blueprint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,wBAAwB,EACxB,SAAS,EACT,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAG5B,+CAA+C;AAC/C,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAOtB,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAwBd,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,EAAE,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAQ3B,CAAC;AAmBjD;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAM7B,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema mirror of {@link Blueprint}. Structural-mirror discipline
|
|
3
|
+
* matches `data-contract.ts`'s posture: the TS interface in
|
|
4
|
+
* `../types/blueprint.ts` is the declared source of truth; the schema
|
|
5
|
+
* here is `z.ZodType<Blueprint>` so any drift fails compile.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { dataContractSchema, jsonValueSchema } from './data-contract.js';
|
|
9
|
+
/** Zod mirror of {@link BlueprintVariance}. */
|
|
10
|
+
export const blueprintVarianceSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
persona: z.string().optional(),
|
|
13
|
+
aesthetic: z.string().optional(),
|
|
14
|
+
context: z.record(z.string(), jsonValueSchema).optional(),
|
|
15
|
+
seedPrompt: z.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
/**
|
|
19
|
+
* Zod mirror of {@link Blueprint}. Required fields are listed first;
|
|
20
|
+
* `passthrough()` is intentionally NOT applied — blueprint rows are
|
|
21
|
+
* a closed shape (every field is enumerated here), and stray fields
|
|
22
|
+
* in persisted rows are a bug worth surfacing rather than tolerating.
|
|
23
|
+
*/
|
|
24
|
+
export const blueprintSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
blueprintId: z.string().min(1),
|
|
27
|
+
contractHash: z.string().min(1),
|
|
28
|
+
appId: z.string().min(1),
|
|
29
|
+
codeS3Url: z.string().optional(),
|
|
30
|
+
codeHash: z.string().optional(),
|
|
31
|
+
generator: z.string().min(1),
|
|
32
|
+
validatorScore: z.number().min(0).max(1).optional(),
|
|
33
|
+
variance: blueprintVarianceSchema,
|
|
34
|
+
// `true | undefined` — store-level invariant: at most one row per
|
|
35
|
+
// `(appId, contractHash)` carries the flag. `z.literal(true)` enforces
|
|
36
|
+
// the "never false" half of the type.
|
|
37
|
+
isOperatorDefault: z.literal(true).optional(),
|
|
38
|
+
createdAt: z.string().min(1),
|
|
39
|
+
createdBy: z.enum(['agent', 'operator']),
|
|
40
|
+
contract: dataContractSchema,
|
|
41
|
+
// Optional cached embedding vector. Written by BlueprintStore.put
|
|
42
|
+
// when an EmbeddingProvider is wired; read by BlueprintSearch on
|
|
43
|
+
// the embed axis. `readonly number[]` on the TS side; zod can't
|
|
44
|
+
// express readonly so a plain array survives the assignability
|
|
45
|
+
// check via the outer `as z.ZodType<Blueprint>` cast.
|
|
46
|
+
contractEmbedding: z.array(z.number()).optional(),
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
49
|
+
/**
|
|
50
|
+
* Zod mirror of {@link BlueprintSearchWeights}. Every axis is a
|
|
51
|
+
* non-negative finite number. Per-axis defaults are applied at the
|
|
52
|
+
* impl layer (see `DEFAULT_BLUEPRINT_SEARCH_WEIGHTS` in
|
|
53
|
+
* `@ggui-ai/mcp-server-core`); this schema only validates the shape
|
|
54
|
+
* an operator passes through `App.blueprintSearchConfig.weights`
|
|
55
|
+
* when the operator provides EVERY axis.
|
|
56
|
+
*/
|
|
57
|
+
export const blueprintSearchWeightsSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
hash: z.number().min(0),
|
|
60
|
+
embed: z.number().min(0),
|
|
61
|
+
struct: z.number().min(0),
|
|
62
|
+
variance: z.number().min(0),
|
|
63
|
+
intent: z.number().min(0),
|
|
64
|
+
})
|
|
65
|
+
.strict();
|
|
66
|
+
/**
|
|
67
|
+
* Zod mirror of the partial-weights shape on
|
|
68
|
+
* {@link AppBlueprintSearchConfig.weights}. Built directly rather
|
|
69
|
+
* than as `.partial()` on `blueprintSearchWeightsSchema` because
|
|
70
|
+
* that schema is typed `z.ZodType<...>` for cross-zod-version
|
|
71
|
+
* compatibility — `.partial()` only exists on `z.ZodObject`.
|
|
72
|
+
*/
|
|
73
|
+
const partialBlueprintSearchWeightsSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
hash: z.number().min(0).optional(),
|
|
76
|
+
embed: z.number().min(0).optional(),
|
|
77
|
+
struct: z.number().min(0).optional(),
|
|
78
|
+
variance: z.number().min(0).optional(),
|
|
79
|
+
intent: z.number().min(0).optional(),
|
|
80
|
+
})
|
|
81
|
+
.strict();
|
|
82
|
+
/**
|
|
83
|
+
* Zod mirror of {@link AppBlueprintSearchConfig}. All fields optional;
|
|
84
|
+
* server applies the global default for any axis the operator omits.
|
|
85
|
+
*/
|
|
86
|
+
export const appBlueprintSearchConfigSchema = z
|
|
87
|
+
.object({
|
|
88
|
+
weights: partialBlueprintSearchWeightsSchema.optional(),
|
|
89
|
+
threshold: z.number().min(0).max(1).optional(),
|
|
90
|
+
topK: z.number().int().min(1).optional(),
|
|
91
|
+
})
|
|
92
|
+
.strict();
|