@copilotkit/shared 2.0.0-rc.2 → 2.0.0-rc.21
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 -14
- package/dist/a2ui-envelope.cjs +2 -2
- package/dist/a2ui-envelope.cjs.map +1 -1
- package/dist/a2ui-envelope.d.cts +1 -1
- package/dist/a2ui-envelope.d.cts.map +1 -1
- package/dist/a2ui-envelope.d.mts +1 -1
- package/dist/a2ui-envelope.d.mts.map +1 -1
- package/dist/a2ui-envelope.mjs +2 -2
- package/dist/a2ui-envelope.mjs.map +1 -1
- package/dist/a2ui-prompts.cjs +21 -62
- package/dist/a2ui-prompts.cjs.map +1 -1
- package/dist/a2ui-prompts.d.cts +8 -1
- package/dist/a2ui-prompts.d.cts.map +1 -1
- package/dist/a2ui-prompts.d.mts +8 -1
- package/dist/a2ui-prompts.d.mts.map +1 -1
- package/dist/a2ui-prompts.mjs +22 -62
- package/dist/a2ui-prompts.mjs.map +1 -1
- package/dist/attachments/types.d.cts +1 -3
- package/dist/attachments/types.d.cts.map +1 -1
- package/dist/attachments/types.d.mts +1 -3
- package/dist/attachments/types.d.mts.map +1 -1
- package/dist/finalize-events.cjs +16 -0
- package/dist/finalize-events.cjs.map +1 -1
- package/dist/finalize-events.d.cts.map +1 -1
- package/dist/finalize-events.d.mts.map +1 -1
- package/dist/finalize-events.mjs +16 -0
- package/dist/finalize-events.mjs.map +1 -1
- package/dist/generative-ui/basic-functions.cjs +1 -1
- package/dist/generative-ui/basic-functions.cjs.map +1 -1
- package/dist/generative-ui/basic-functions.mjs +1 -1
- package/dist/generative-ui/basic-functions.mjs.map +1 -1
- package/dist/generative-ui/child-refs.cjs +3 -3
- package/dist/generative-ui/child-refs.cjs.map +1 -1
- package/dist/generative-ui/child-refs.d.cts.map +1 -1
- package/dist/generative-ui/child-refs.d.mts.map +1 -1
- package/dist/generative-ui/child-refs.mjs +3 -3
- package/dist/generative-ui/child-refs.mjs.map +1 -1
- package/dist/generative-ui/compact-schema.cjs +187 -0
- package/dist/generative-ui/compact-schema.cjs.map +1 -0
- package/dist/generative-ui/compact-schema.d.cts +55 -0
- package/dist/generative-ui/compact-schema.d.cts.map +1 -0
- package/dist/generative-ui/compact-schema.d.mts +55 -0
- package/dist/generative-ui/compact-schema.d.mts.map +1 -0
- package/dist/generative-ui/compact-schema.mjs +185 -0
- package/dist/generative-ui/compact-schema.mjs.map +1 -0
- package/dist/generative-ui/prompt-spec.cjs +225 -0
- package/dist/generative-ui/prompt-spec.cjs.map +1 -0
- package/dist/generative-ui/prompt-spec.d.cts +94 -0
- package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
- package/dist/generative-ui/prompt-spec.d.mts +94 -0
- package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
- package/dist/generative-ui/prompt-spec.mjs +220 -0
- package/dist/generative-ui/prompt-spec.mjs.map +1 -0
- package/dist/generative-ui/prompt.cjs +10 -36
- package/dist/generative-ui/prompt.cjs.map +1 -1
- package/dist/generative-ui/prompt.d.cts +2 -1
- package/dist/generative-ui/prompt.d.cts.map +1 -1
- package/dist/generative-ui/prompt.d.mts +2 -1
- package/dist/generative-ui/prompt.d.mts.map +1 -1
- package/dist/generative-ui/prompt.mjs +12 -38
- package/dist/generative-ui/prompt.mjs.map +1 -1
- package/dist/generative-ui/render-ui-args.cjs +1 -0
- package/dist/generative-ui/render-ui-args.cjs.map +1 -1
- package/dist/generative-ui/render-ui-args.d.cts.map +1 -1
- package/dist/generative-ui/render-ui-args.d.mts.map +1 -1
- package/dist/generative-ui/render-ui-args.mjs +1 -0
- package/dist/generative-ui/render-ui-args.mjs.map +1 -1
- package/dist/generative-ui/schema-render.cjs +242 -0
- package/dist/generative-ui/schema-render.cjs.map +1 -0
- package/dist/generative-ui/schema-render.d.cts +44 -0
- package/dist/generative-ui/schema-render.d.cts.map +1 -0
- package/dist/generative-ui/schema-render.d.mts +44 -0
- package/dist/generative-ui/schema-render.d.mts.map +1 -0
- package/dist/generative-ui/schema-render.mjs +239 -0
- package/dist/generative-ui/schema-render.mjs.map +1 -0
- package/dist/generative-ui/types.cjs +2 -2
- package/dist/generative-ui/types.cjs.map +1 -1
- package/dist/generative-ui/types.d.cts +7 -7
- package/dist/generative-ui/types.d.cts.map +1 -1
- package/dist/generative-ui/types.d.mts +7 -7
- package/dist/generative-ui/types.d.mts.map +1 -1
- package/dist/generative-ui/types.mjs +2 -2
- package/dist/generative-ui/types.mjs.map +1 -1
- package/dist/generative-ui/validate-operation.cjs +2 -2
- package/dist/generative-ui/validate-operation.cjs.map +1 -1
- package/dist/generative-ui/validate-operation.mjs +2 -2
- package/dist/generative-ui/validate-operation.mjs.map +1 -1
- package/dist/index.cjs +18 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -10
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +11 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +10 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +864 -450
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/standard-schema.cjs +20 -7
- package/dist/standard-schema.cjs.map +1 -1
- package/dist/standard-schema.d.cts +15 -16
- package/dist/standard-schema.d.cts.map +1 -1
- package/dist/standard-schema.d.mts +15 -16
- package/dist/standard-schema.d.mts.map +1 -1
- package/dist/standard-schema.mjs +20 -8
- package/dist/standard-schema.mjs.map +1 -1
- package/dist/telemetry/lambda-client.cjs +1 -1
- package/dist/telemetry/lambda-client.cjs.map +1 -1
- package/dist/telemetry/lambda-client.d.cts.map +1 -1
- package/dist/telemetry/lambda-client.d.mts.map +1 -1
- package/dist/telemetry/lambda-client.mjs +1 -1
- package/dist/telemetry/lambda-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +3 -6
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.cts +0 -5
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.mts +0 -5
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
- package/dist/telemetry/telemetry-disabled.mjs +4 -6
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
- package/dist/types/message.d.cts +1 -18
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +1 -18
- package/dist/types/message.d.mts.map +1 -1
- package/dist/utils/errors.cjs +5 -42
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.d.cts +16 -34
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.mts +16 -34
- package/dist/utils/errors.d.mts.map +1 -1
- package/dist/utils/errors.mjs +6 -41
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +1 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +5 -6
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +5 -6
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +5 -6
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/inspector-visibility.cjs +25 -3
- package/dist/utils/inspector-visibility.cjs.map +1 -1
- package/dist/utils/inspector-visibility.d.cts +26 -3
- package/dist/utils/inspector-visibility.d.cts.map +1 -1
- package/dist/utils/inspector-visibility.d.mts +26 -3
- package/dist/utils/inspector-visibility.d.mts.map +1 -1
- package/dist/utils/inspector-visibility.mjs +25 -4
- package/dist/utils/inspector-visibility.mjs.map +1 -1
- package/dist/utils/json-schema.cjs +4 -79
- package/dist/utils/json-schema.cjs.map +1 -1
- package/dist/utils/json-schema.d.cts +1 -4
- package/dist/utils/json-schema.d.cts.map +1 -1
- package/dist/utils/json-schema.d.mts +1 -4
- package/dist/utils/json-schema.d.mts.map +1 -1
- package/dist/utils/json-schema.mjs +5 -78
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/process-env.cjs +14 -0
- package/dist/utils/process-env.cjs.map +1 -0
- package/dist/utils/process-env.d.cts +10 -0
- package/dist/utils/process-env.d.cts.map +1 -0
- package/dist/utils/process-env.d.mts +10 -0
- package/dist/utils/process-env.d.mts.map +1 -0
- package/dist/utils/process-env.mjs +13 -0
- package/dist/utils/process-env.mjs.map +1 -0
- package/dist/utils/random-id.cjs +13 -26
- package/dist/utils/random-id.cjs.map +1 -1
- package/dist/utils/random-id.d.cts +6 -3
- package/dist/utils/random-id.d.cts.map +1 -1
- package/dist/utils/random-id.d.mts +6 -3
- package/dist/utils/random-id.d.mts.map +1 -1
- package/dist/utils/random-id.mjs +14 -25
- package/dist/utils/random-id.mjs.map +1 -1
- package/package.json +8 -32
- package/scripts/verify-cjs-exports.cjs +1 -1
- package/src/__tests__/a2ui-envelope.test.ts +18 -13
- package/src/__tests__/a2ui-prompts.test.ts +47 -14
- package/src/__tests__/fixtures/prompt-goldens.json +354 -0
- package/src/__tests__/prompt-spec.test.ts +191 -0
- package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
- package/src/__tests__/schema-render.test.ts +245 -0
- package/src/__tests__/standard-schema.test.ts +61 -101
- package/src/a2ui-envelope.ts +7 -6
- package/src/a2ui-prompts.ts +47 -96
- package/src/attachments/types.ts +1 -3
- package/src/finalize-events.ts +16 -0
- package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
- package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
- package/src/generative-ui/basic-functions.ts +1 -1
- package/src/generative-ui/child-refs.ts +5 -4
- package/src/generative-ui/compact-schema.ts +277 -0
- package/src/generative-ui/index.ts +3 -0
- package/src/generative-ui/prompt-spec.ts +335 -0
- package/src/generative-ui/prompt.ts +25 -75
- package/src/generative-ui/render-ui-args.ts +3 -0
- package/src/generative-ui/schema-render.ts +377 -0
- package/src/generative-ui/types.ts +10 -7
- package/src/generative-ui/validate-operation.ts +2 -2
- package/src/index.ts +3 -16
- package/src/standard-schema.ts +24 -27
- package/src/telemetry/lambda-client.ts +8 -3
- package/src/telemetry/model-host.test.ts +2 -5
- package/src/telemetry/telemetry-disabled.ts +7 -12
- package/src/types/message.ts +1 -19
- package/src/utils/__tests__/errors.test.ts +44 -0
- package/src/utils/__tests__/json-schema.test.ts +3 -479
- package/src/utils/__tests__/process-env.test.ts +22 -0
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +1 -2
- package/src/utils/inspector-visibility.test.ts +26 -0
- package/src/utils/inspector-visibility.ts +35 -3
- package/src/utils/json-schema.ts +5 -152
- package/src/utils/process-env.ts +14 -0
- package/src/utils/random-id.ts +17 -37
- package/tsconfig.json +3 -1
- package/tsdown.config.ts +2 -19
- package/dist/event-transforms/index.cjs +0 -15
- package/dist/event-transforms/index.d.cts +0 -4
- package/dist/event-transforms/index.d.mts +0 -4
- package/dist/event-transforms/index.mjs +0 -5
- package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
- package/dist/event-transforms/recorded-events.cjs +0 -59
- package/dist/event-transforms/recorded-events.cjs.map +0 -1
- package/dist/event-transforms/recorded-events.d.cts +0 -23
- package/dist/event-transforms/recorded-events.d.cts.map +0 -1
- package/dist/event-transforms/recorded-events.d.mts +0 -23
- package/dist/event-transforms/recorded-events.d.mts.map +0 -1
- package/dist/event-transforms/recorded-events.mjs +0 -58
- package/dist/event-transforms/recorded-events.mjs.map +0 -1
- package/dist/telemetry/events.d.cts +0 -72
- package/dist/telemetry/events.d.cts.map +0 -1
- package/dist/telemetry/events.d.mts +0 -72
- package/dist/telemetry/events.d.mts.map +0 -1
- package/dist/telemetry/index.cjs +0 -18
- package/dist/telemetry/index.d.cts +0 -5
- package/dist/telemetry/index.d.mts +0 -5
- package/dist/telemetry/index.mjs +0 -6
- package/dist/telemetry/telemetry-client.cjs +0 -165
- package/dist/telemetry/telemetry-client.cjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.cts +0 -87
- package/dist/telemetry/telemetry-client.d.cts.map +0 -1
- package/dist/telemetry/telemetry-client.d.mts +0 -87
- package/dist/telemetry/telemetry-client.d.mts.map +0 -1
- package/dist/telemetry/telemetry-client.mjs +0 -164
- package/dist/telemetry/telemetry-client.mjs.map +0 -1
- package/dist/telemetry/utils.cjs +0 -14
- package/dist/telemetry/utils.cjs.map +0 -1
- package/dist/telemetry/utils.mjs +0 -13
- package/dist/telemetry/utils.mjs.map +0 -1
- package/dist/utils/conditions.cjs +0 -32
- package/dist/utils/conditions.cjs.map +0 -1
- package/dist/utils/conditions.d.cts +0 -31
- package/dist/utils/conditions.d.cts.map +0 -1
- package/dist/utils/conditions.d.mts +0 -31
- package/dist/utils/conditions.d.mts.map +0 -1
- package/dist/utils/conditions.mjs +0 -31
- package/dist/utils/conditions.mjs.map +0 -1
- package/dist/utils/console-styling.cjs +0 -91
- package/dist/utils/console-styling.cjs.map +0 -1
- package/dist/utils/console-styling.d.cts +0 -65
- package/dist/utils/console-styling.d.cts.map +0 -1
- package/dist/utils/console-styling.d.mts +0 -65
- package/dist/utils/console-styling.d.mts.map +0 -1
- package/dist/utils/console-styling.mjs +0 -85
- package/dist/utils/console-styling.mjs.map +0 -1
- package/src/__tests__/zod-regression.test.ts +0 -319
- package/src/event-transforms/index.ts +0 -5
- package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
- package/src/event-transforms/recorded-events.test.ts +0 -166
- package/src/event-transforms/recorded-events.ts +0 -74
- package/src/telemetry/events.ts +0 -68
- package/src/telemetry/index.ts +0 -9
- package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
- package/src/telemetry/telemetry-client.test.ts +0 -798
- package/src/telemetry/telemetry-client.ts +0 -328
- package/src/telemetry/utils.ts +0 -15
- package/src/utils/__tests__/conditions.test.ts +0 -161
- package/src/utils/conditions.ts +0 -116
- package/src/utils/console-styling.ts +0 -126
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-render.mjs","names":[],"sources":["../../src/generative-ui/schema-render.ts"],"sourcesContent":["import { functionCallers } from \"./basic-functions\";\nimport {\n buildCompactGenerativeUISchema,\n compactProps,\n compactType,\n} from \"./compact-schema\";\nimport type { GenerativeUISchemaSettings } from \"./prompt-spec\";\nimport { GENERATIVE_UI_AGENT_FUNCTION_CALLS } from \"./types\";\nimport type {\n GenerativeUIComponentManifest,\n GenerativeUIJSONSchema,\n GenerativeUIManifest,\n} from \"./types\";\n\ntype SchemaManifest = Pick<\n GenerativeUIManifest,\n \"catalogId\" | \"components\" | \"functions\" | \"targets\" | \"surfaces\"\n>;\n\n/** An own key (shared compiles to ES2017, which has no Object.hasOwn). */\nconst hasOwn = (target: object, key: string) =>\n Object.prototype.hasOwnProperty.call(target, key);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The props schema without the description of each prop. */\nfunction withoutPropDescriptions(\n schema: GenerativeUIJSONSchema,\n): GenerativeUIJSONSchema {\n if (!isRecord(schema.properties)) return schema;\n return {\n ...schema,\n properties: Object.fromEntries(\n Object.entries(schema.properties).map(([key, value]) => {\n if (!isRecord(value)) return [key, value];\n const { description: _description, ...rest } = value;\n return [key, rest];\n }),\n ),\n };\n}\n\n/** The short signature of a function: its built-in signature, or its schema made short. */\nfunction functionSignature(fn: GenerativeUIManifest[\"functions\"][string]) {\n const signature = fn.parameters.description;\n const hasSignature =\n typeof signature === \"string\" &&\n signature.startsWith(\"{\") &&\n Object.keys(fn.parameters).length === 2;\n return hasSignature ? signature : compactType(fn.parameters, 0);\n}\n\n/**\n * A function name with its parameters: `pick{ id: string }`, `clearCart{}`\n * for no arguments, `setVolume(number)` for a parameter that is not an object.\n */\nfunction nameWithParameters(name: string, parameters: string) {\n if (parameters.startsWith(\"{\")) return `${name}${parameters}`;\n if (parameters === \"object\") return `${name}{}`;\n return `${name}(${parameters})`;\n}\n\n/**\n * One component as a TypeScript-like signature line, with its events and\n * slots on the lines below:\n * `- Text(text?: string // The text): Shows text`.\n */\nfunction signatureLines(\n name: string,\n component: GenerativeUIComponentManifest,\n settings: GenerativeUISchemaSettings,\n) {\n const props = Object.entries(\n compactProps(component.props, settings.propDescriptions),\n ).map(([key, type]) => `${key}: ${type}`);\n const lines = [\n `- ${name}(${props.join(\", \")})${component.description ? `: ${oneLine(component.description)}` : \"\"}`,\n ];\n const events = Object.entries(component.events ?? {}).map(\n ([event, definition]) =>\n `${event}(${definition.description ? oneLine(definition.description) : compactType(definition.parameters, 0)})`,\n );\n if (events.length > 0) lines.push(` events: ${events.join(\", \")}`);\n const slots = Object.entries(component.slots ?? {}).map(\n ([slot, kind]) => `${slot} (${kind})`,\n );\n if (slots.length > 0) lines.push(` slots: ${slots.join(\", \")}`);\n return lines;\n}\n\n/** The whole schema as signature text: targets, functions, components, surfaces. */\nfunction signatureSchema(\n manifest: SchemaManifest,\n settings: GenerativeUISchemaSettings,\n) {\n const targets = manifest.targets.map((t) => {\n const limit = t.components ? `; only ${t.components.join(\", \")}` : \"\";\n return `- ${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : \"\"}`;\n });\n const functions = Object.entries(manifest.functions).map(([name, fn]) => {\n const callers = functionCallers(fn);\n const who =\n callers.agent && GENERATIVE_UI_AGENT_FUNCTION_CALLS\n ? callers.renderer\n ? \" (UI or agent)\"\n : \" (agent only)\"\n : \"\";\n return `- ${nameWithParameters(name, functionSignature(fn))}${who}${fn.description ? `: ${oneLine(fn.description)}` : \"\"}`;\n });\n const components = Object.entries(manifest.components).flatMap(\n ([name, component]) => signatureLines(name, component, settings),\n );\n const surfaces = Object.entries(manifest.surfaces).map(\n ([id, s]) =>\n `- ${id} (target ${s.target})${s.status ? ` status: ${s.status}` : \"\"}${s.dataModel ? ` user values: ${JSON.stringify(s.dataModel)}` : \"\"}${(s.rejected ?? []).map((r) => ` rejected: ${r}`).join(\"\")}`,\n );\n return [\n `Catalog: ${manifest.catalogId}`,\n `Targets:\\n${targets.join(\"\\n\") || \"- none\"}`,\n `Functions:\\n${functions.join(\"\\n\") || \"- none\"}`,\n `Components:\\n${components.join(\"\\n\") || \"- none\"}`,\n `Surfaces:\\n${surfaces.join(\"\\n\") || \"- none\"}`,\n ].join(\"\\n\\n\");\n}\n\n/** A description on one line, so its lines cannot read as new entries. */\nfunction oneLine(text: string) {\n return text.replace(/\\s*\\n\\s*/g, \" \");\n}\n\n/** Values that would read as a type or a number once their quotes are gone. */\nconst AMBIGUOUS_VALUE =\n /^(?:string|number|integer|boolean|true|false|null|object|array|unknown|any|-?\\d[\\d.]*)$/;\n\n/**\n * A compact type with bare enum values and tight unions:\n * `\"sm\" | \"md\" | \"lg\"` becomes `sm|md|lg`. A union keeps its quotes when it\n * also holds a type (`\"sm\" | number`) or a value that reads as a type or a\n * number (`\"number\" | \"currency\"`, `\"1\" | \"2\"`), and so do values that are\n * not plain words.\n */\nfunction bareType(type: string) {\n return type\n .replace(\n /\"[A-Za-z0-9_#%.-]+\"(?: \\| \"[A-Za-z0-9_#%.-]+\")*(?! \\|)/g,\n (union: string, offset: number, whole: string) => {\n if (whole.slice(offset - 2, offset) === \"| \") return union;\n const values = union.split(\" | \").map((v) => v.slice(1, -1));\n if (values.some((v) => AMBIGUOUS_VALUE.test(v))) return union;\n return values.join(\"|\");\n },\n )\n .replace(/ \\| /g, \"|\");\n}\n\n/** A compact prop (`type // description`) as `name: type - description`. */\nfunction propLine(key: string, value: string) {\n const name = key.endsWith(\"?\") ? key.slice(0, -1) : `${key}*`;\n const cut = value.indexOf(\" // \");\n const type = bareType(cut < 0 ? value : value.slice(0, cut));\n const text = cut < 0 ? \"\" : value.slice(cut + 4).trim();\n const description = text ? ` - ${oneLine(text)}` : \"\";\n return ` ${name}: ${type}${description}`;\n}\n\n/**\n * The whole schema as plain lines: a header line per component and one\n * indented line per prop: events are `action` props and slots `componentId`\n * or `childList` props. Props are optional unless marked `*`, enum values\n * are bare, and the common props are listed once. It carries the same names, types and descriptions as\n * `compact`, in fewer tokens.\n */\nfunction linesSchema(\n manifest: SchemaManifest,\n settings: GenerativeUISchemaSettings,\n) {\n const compact = buildCompactGenerativeUISchema(manifest, {\n propDescriptions: settings.propDescriptions,\n commonProps: settings.commonProps,\n });\n const targets = compact.targets\n .map((t) => {\n const limit = t.components ? `, only ${t.components.join(\", \")}` : \"\";\n return `${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : \"\"}`;\n })\n .join(\"; \");\n const functions = Object.entries(compact.functions).map(\n ([name, fn]) =>\n `${nameWithParameters(name, fn.parameters)}${\"callers\" in fn ? ` (${fn.callers})` : \"\"}${fn.description ? `: ${oneLine(fn.description)}` : \"\"}`,\n );\n const common = compact.commonProps\n ? Object.entries(compact.commonProps).map(([k, v]) => propLine(k, v))\n : [];\n const lineSets = Object.entries(compact.components).map(([name, c]) => ({\n name,\n c,\n own: [\n ...Object.entries(c.props).map(([k, v]) => propLine(k, v)),\n ...Object.entries(c.events ?? {}).map(\n ([e, d]) => ` ${e}: action - ${oneLine(d)}`,\n ),\n ],\n }));\n const components = lineSets.flatMap(({ name, c, own }) => {\n const lines = [\n `${name}${c.includesCommonProps ? \" +common\" : \"\"}${c.description ? `: ${oneLine(c.description)}` : \"\"}`,\n ...own,\n ];\n // Slots are props that take component ids.\n for (const [slot, kind] of Object.entries(c.slots ?? {})) {\n lines.push(\n ` ${slot}: ${kind === \"single\" ? \"componentId\" : \"childList\"}`,\n );\n }\n return lines;\n });\n const surfaces = Object.keys(compact.surfaces).length\n ? JSON.stringify(compact.surfaces)\n : \"none\";\n return [\n `Catalog ${compact.catalogId}. Targets: ${targets || \"none\"}`,\n 'Props are optional unless marked *. a|b|c is one of those strings, quoted when one reads as a type or a number. A component marked +common also takes every common prop. A prop of type action is an event prop: give it {\"event\":{...}} or {\"functionCall\":{...}}. A componentId prop takes one component id; a childList prop takes a list of ids or a template.',\n `Functions:\\n${functions.join(\"\\n\")}`,\n ...(common.length ? [`Common props:\\n${common.join(\"\\n\")}`] : []),\n `Components:\\n${components.join(\"\\n\")}`,\n `Surfaces: ${surfaces}`,\n ].join(\"\\n\\n\");\n}\n\n/**\n * The component schema of the markdown transport, as the text of its\n * context entry, in the notation of `settings`. `compact` is the schema that\n * ships (`buildCompactGenerativeUISchema`), `json-schema` the manifest parts\n * as JSON, `ts-signature` one line per component, `lines` one line per\n * prop with bare enums (the fewest tokens).\n *\n * @example\n * ```ts\n * const value = renderGenerativeUISchema(manifest, spec.schema.markdown);\n * ```\n */\nexport function renderGenerativeUISchema(\n manifest: SchemaManifest,\n settings: GenerativeUISchemaSettings,\n): string {\n switch (settings.notation) {\n case \"compact\":\n return JSON.stringify(\n buildCompactGenerativeUISchema(manifest, {\n propDescriptions: settings.propDescriptions,\n commonProps: settings.commonProps,\n }),\n );\n case \"json-schema\": {\n const components = Object.fromEntries(\n Object.entries(manifest.components).map(([name, c]) => [\n name,\n settings.propDescriptions\n ? c\n : { ...c, props: withoutPropDescriptions(c.props) },\n ]),\n );\n return JSON.stringify({\n catalogId: manifest.catalogId,\n targets: manifest.targets,\n functions: manifest.functions,\n components,\n surfaces: manifest.surfaces,\n });\n }\n case \"ts-signature\":\n return signatureSchema(manifest, settings);\n case \"lines\":\n return linesSchema(manifest, settings);\n }\n}\n\n/**\n * The component list of the tool guide, one entry per component, in the\n * notation of `settings`. `json-schema` is the list that ships.\n */\nexport function renderGenerativeUIComponentList(\n components: GenerativeUIManifest[\"components\"],\n settings: GenerativeUISchemaSettings,\n): string {\n return Object.entries(components)\n .map(([name, c]) => {\n if (\n settings.notation === \"ts-signature\" ||\n settings.notation === \"lines\"\n ) {\n return signatureLines(name, c, settings).join(\"\\n\");\n }\n const props =\n settings.notation === \"compact\"\n ? compactProps(c.props, settings.propDescriptions)\n : settings.propDescriptions\n ? c.props\n : withoutPropDescriptions(c.props);\n const lines = [\n `- **${name}**${c.description ? `: ${oneLine(c.description)}` : \"\"}`,\n ` props: ${JSON.stringify(props)}`,\n ];\n if (c.events) lines.push(` event props: ${JSON.stringify(c.events)}`);\n if (c.slots)\n lines.push(` slot props (component ids): ${JSON.stringify(c.slots)}`);\n return lines.join(\"\\n\");\n })\n .join(\"\\n\");\n}\n\n/**\n * The manifest with replaced descriptions: `\"Name\"` replaces the\n * description of a component, `\"Name.prop\"` the description of one of its\n * props. Keys that name no component or prop are left out of the result\n * and listed in `unknown`. The manifest is not changed.\n */\nexport function applyDescriptionOverrides<\n M extends Pick<GenerativeUIManifest, \"components\">,\n>(\n manifest: M,\n overrides: Record<string, string>,\n): { manifest: M; unknown: string[] } {\n const components = structuredClone(manifest.components);\n const unknown: string[] = [];\n for (const [key, description] of Object.entries(overrides)) {\n const [name, prop, ...rest] = key.split(\".\");\n // Own keys only: \"__proto__\" must never reach Object.prototype.\n const component =\n name !== undefined && hasOwn(components, name)\n ? components[name]\n : undefined;\n if (!component || rest.length > 0) {\n unknown.push(key);\n continue;\n }\n if (prop === undefined) {\n component.description = description;\n continue;\n }\n const properties = component.props.properties;\n const property =\n isRecord(properties) && hasOwn(properties, prop)\n ? properties[prop]\n : undefined;\n if (!isRecord(property)) {\n unknown.push(key);\n continue;\n }\n property.description = description;\n }\n return { manifest: { ...manifest, components }, unknown };\n}\n\n/**\n * The components and props of `manifest` whose names do not appear in\n * `rendered`. A schema notation that leaves one out would hide part of the\n * catalog from the model.\n */\nexport function schemaCoverage(\n manifest: Pick<GenerativeUIManifest, \"components\">,\n rendered: string,\n): { missing: string[] } {\n const missing: string[] = [];\n for (const [name, component] of Object.entries(manifest.components)) {\n if (!rendered.includes(name)) missing.push(name);\n const properties = isRecord(component.props.properties)\n ? component.props.properties\n : {};\n for (const prop of Object.keys(properties)) {\n if (!rendered.includes(prop)) missing.push(`${name}.${prop}`);\n }\n }\n return { missing };\n}\n"],"mappings":";;;;;;AAoBA,MAAM,UAAU,QAAgB,QAC9B,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;AAEnD,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;AAI7E,SAAS,wBACP,QACwB;AACxB,KAAI,CAAC,SAAS,OAAO,WAAW,CAAE,QAAO;AACzC,QAAO;EACL,GAAG;EACH,YAAY,OAAO,YACjB,OAAO,QAAQ,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,WAAW;AACtD,OAAI,CAAC,SAAS,MAAM,CAAE,QAAO,CAAC,KAAK,MAAM;GACzC,MAAM,EAAE,aAAa,cAAc,GAAG,SAAS;AAC/C,UAAO,CAAC,KAAK,KAAK;IAClB,CACH;EACF;;;AAIH,SAAS,kBAAkB,IAA+C;CACxE,MAAM,YAAY,GAAG,WAAW;AAKhC,QAHE,OAAO,cAAc,YACrB,UAAU,WAAW,IAAI,IACzB,OAAO,KAAK,GAAG,WAAW,CAAC,WAAW,IAClB,YAAY,YAAY,GAAG,YAAY,EAAE;;;;;;AAOjE,SAAS,mBAAmB,MAAc,YAAoB;AAC5D,KAAI,WAAW,WAAW,IAAI,CAAE,QAAO,GAAG,OAAO;AACjD,KAAI,eAAe,SAAU,QAAO,GAAG,KAAK;AAC5C,QAAO,GAAG,KAAK,GAAG,WAAW;;;;;;;AAQ/B,SAAS,eACP,MACA,WACA,UACA;CAIA,MAAM,QAAQ,CACZ,KAAK,KAAK,GAJE,OAAO,QACnB,aAAa,UAAU,OAAO,SAAS,iBAAiB,CACzD,CAAC,KAAK,CAAC,KAAK,UAAU,GAAG,IAAI,IAAI,OAAO,CAEpB,KAAK,KAAK,CAAC,GAAG,UAAU,cAAc,KAAK,QAAQ,UAAU,YAAY,KAAK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N,OAAK,MAAM,QAAQ,OAAO,KAAK,WAAW,CACxC,KAAI,CAAC,SAAS,SAAS,KAAK,CAAE,SAAQ,KAAK,GAAG,KAAK,GAAG,OAAO;;AAGjE,QAAO,EAAE,SAAS"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/generative-ui/types.ts
|
|
3
3
|
/** A2UI protocol version used on the wire. */
|
|
4
|
-
const A2UI_VERSION = "
|
|
4
|
+
const A2UI_VERSION = "1.0";
|
|
5
5
|
/** Activity type of a generated surface message. */
|
|
6
6
|
const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
|
|
7
7
|
/** Activity type of a function call that the agent asks the client to run. */
|
|
@@ -65,7 +65,7 @@ const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;
|
|
|
65
65
|
* @example
|
|
66
66
|
* ```ts
|
|
67
67
|
* toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
|
|
68
|
-
* // { version: "
|
|
68
|
+
* // { version: "1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
function toA2UIActionMessage(event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"v1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: \"v1.0\";\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: \"v1.0\";\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: \"v1.0\";\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | { version: \"v1.0\"; deleteSurface: { surfaceId: string } }\n | {\n version: \"v1.0\";\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"v1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AA8JF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AA+DlD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: typeof A2UI_VERSION;\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: typeof A2UI_VERSION;\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: typeof A2UI_VERSION;\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | {\n version: typeof A2UI_VERSION;\n deleteSurface: { surfaceId: string };\n }\n | {\n version: typeof A2UI_VERSION;\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AAiKF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AA+DlD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
|
@@ -2,7 +2,7 @@ import { A2UIFunctionPermissions, A2UIFunctionReturnType } from "./basic-functio
|
|
|
2
2
|
|
|
3
3
|
//#region src/generative-ui/types.d.ts
|
|
4
4
|
/** A2UI protocol version used on the wire. */
|
|
5
|
-
declare const A2UI_VERSION = "
|
|
5
|
+
declare const A2UI_VERSION = "1.0";
|
|
6
6
|
/** Activity type of a generated surface message. */
|
|
7
7
|
declare const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
|
|
8
8
|
/** Activity type of a function call that the agent asks the client to run. */
|
|
@@ -61,7 +61,7 @@ type A2UIFunctionCall = {
|
|
|
61
61
|
catalogId?: string;
|
|
62
62
|
};
|
|
63
63
|
type A2UIOperation = {
|
|
64
|
-
version:
|
|
64
|
+
version: typeof A2UI_VERSION;
|
|
65
65
|
createSurface: {
|
|
66
66
|
surfaceId: string; /** Left out by the model. The run's catalog id is filled in. */
|
|
67
67
|
catalogId?: string; /** Components to add at once, checked like `updateComponents`. */
|
|
@@ -73,13 +73,13 @@ type A2UIOperation = {
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
} | {
|
|
76
|
-
version:
|
|
76
|
+
version: typeof A2UI_VERSION;
|
|
77
77
|
updateComponents: {
|
|
78
78
|
surfaceId: string;
|
|
79
79
|
components: A2UIComponentNode[];
|
|
80
80
|
};
|
|
81
81
|
} | {
|
|
82
|
-
version:
|
|
82
|
+
version: typeof A2UI_VERSION;
|
|
83
83
|
/**
|
|
84
84
|
* Sets `value` at `path`. A `null` value deletes the key at `path`.
|
|
85
85
|
* With no `path`, or `"/"`, it sets the whole data model.
|
|
@@ -90,12 +90,12 @@ type A2UIOperation = {
|
|
|
90
90
|
value: unknown;
|
|
91
91
|
};
|
|
92
92
|
} | {
|
|
93
|
-
version:
|
|
93
|
+
version: typeof A2UI_VERSION;
|
|
94
94
|
deleteSurface: {
|
|
95
95
|
surfaceId: string;
|
|
96
96
|
};
|
|
97
97
|
} | {
|
|
98
|
-
version:
|
|
98
|
+
version: typeof A2UI_VERSION; /** Runs an app function in the browser, with no user interaction. */
|
|
99
99
|
callRendererFunction: {
|
|
100
100
|
functionCallId: string;
|
|
101
101
|
callFunction: A2UIFunctionCall;
|
|
@@ -261,7 +261,7 @@ interface A2UIActionMessage {
|
|
|
261
261
|
* @example
|
|
262
262
|
* ```ts
|
|
263
263
|
* toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
|
|
264
|
-
* // { version: "
|
|
264
|
+
* // { version: "1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
|
|
265
265
|
* ```
|
|
266
266
|
*/
|
|
267
267
|
declare function toA2UIActionMessage(event: GenerativeUIUserEvent): A2UIActionMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/generative-ui/types.ts"],"mappings":";;;;cACa,YAAA;;cAEA,2BAAA;;cAEA,yCAAA;;cAGA,yBAAA;AALb;AAAA,cAOa,yBAAA;;cAEA,qBAAA;;AAPb;;;;;AAGA;;cAaa,kCAAA;;cAEA,6CAAA;AAbb;AAAA,iBAiBgB,4BAAA,CAA6B,SAAA;;;;AAf7C;;;;;AASA;;;iBAqBgB,iCAAA,CAAkC,cAAA;AAAA,KAWtC,sBAAA,GAAyB,MAAA;AAAA,KAEzB,iBAAA;EACV,EAAA;EACA,SAAA;EAAA,CACC,IAAA;AAAA;;;;;AAhBH;;cAyBa,4BAAA,EAA8B,WAAA;;;AAd3C;;KAwBY,gBAAA;EACV,OAAA;EACA,IAAA,GAAO,MAAA;EACP,SAAA;AAAA;AAAA,KAGU,aAAA;EAEN,OAAA;
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/generative-ui/types.ts"],"mappings":";;;;cACa,YAAA;;cAEA,2BAAA;;cAEA,yCAAA;;cAGA,yBAAA;AALb;AAAA,cAOa,yBAAA;;cAEA,qBAAA;;AAPb;;;;;AAGA;;cAaa,kCAAA;;cAEA,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BAAA"}
|
|
@@ -2,7 +2,7 @@ import { A2UIFunctionPermissions, A2UIFunctionReturnType } from "./basic-functio
|
|
|
2
2
|
|
|
3
3
|
//#region src/generative-ui/types.d.ts
|
|
4
4
|
/** A2UI protocol version used on the wire. */
|
|
5
|
-
declare const A2UI_VERSION = "
|
|
5
|
+
declare const A2UI_VERSION = "1.0";
|
|
6
6
|
/** Activity type of a generated surface message. */
|
|
7
7
|
declare const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
|
|
8
8
|
/** Activity type of a function call that the agent asks the client to run. */
|
|
@@ -61,7 +61,7 @@ type A2UIFunctionCall = {
|
|
|
61
61
|
catalogId?: string;
|
|
62
62
|
};
|
|
63
63
|
type A2UIOperation = {
|
|
64
|
-
version:
|
|
64
|
+
version: typeof A2UI_VERSION;
|
|
65
65
|
createSurface: {
|
|
66
66
|
surfaceId: string; /** Left out by the model. The run's catalog id is filled in. */
|
|
67
67
|
catalogId?: string; /** Components to add at once, checked like `updateComponents`. */
|
|
@@ -73,13 +73,13 @@ type A2UIOperation = {
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
} | {
|
|
76
|
-
version:
|
|
76
|
+
version: typeof A2UI_VERSION;
|
|
77
77
|
updateComponents: {
|
|
78
78
|
surfaceId: string;
|
|
79
79
|
components: A2UIComponentNode[];
|
|
80
80
|
};
|
|
81
81
|
} | {
|
|
82
|
-
version:
|
|
82
|
+
version: typeof A2UI_VERSION;
|
|
83
83
|
/**
|
|
84
84
|
* Sets `value` at `path`. A `null` value deletes the key at `path`.
|
|
85
85
|
* With no `path`, or `"/"`, it sets the whole data model.
|
|
@@ -90,12 +90,12 @@ type A2UIOperation = {
|
|
|
90
90
|
value: unknown;
|
|
91
91
|
};
|
|
92
92
|
} | {
|
|
93
|
-
version:
|
|
93
|
+
version: typeof A2UI_VERSION;
|
|
94
94
|
deleteSurface: {
|
|
95
95
|
surfaceId: string;
|
|
96
96
|
};
|
|
97
97
|
} | {
|
|
98
|
-
version:
|
|
98
|
+
version: typeof A2UI_VERSION; /** Runs an app function in the browser, with no user interaction. */
|
|
99
99
|
callRendererFunction: {
|
|
100
100
|
functionCallId: string;
|
|
101
101
|
callFunction: A2UIFunctionCall;
|
|
@@ -261,7 +261,7 @@ interface A2UIActionMessage {
|
|
|
261
261
|
* @example
|
|
262
262
|
* ```ts
|
|
263
263
|
* toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
|
|
264
|
-
* // { version: "
|
|
264
|
+
* // { version: "1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
|
|
265
265
|
* ```
|
|
266
266
|
*/
|
|
267
267
|
declare function toA2UIActionMessage(event: GenerativeUIUserEvent): A2UIActionMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/generative-ui/types.ts"],"mappings":";;;;cACa,YAAA;;cAEA,2BAAA;;cAEA,yCAAA;;cAGA,yBAAA;AALb;AAAA,cAOa,yBAAA;;cAEA,qBAAA;;AAPb;;;;;AAGA;;cAaa,kCAAA;;cAEA,6CAAA;AAbb;AAAA,iBAiBgB,4BAAA,CAA6B,SAAA;;;;AAf7C;;;;;AASA;;;iBAqBgB,iCAAA,CAAkC,cAAA;AAAA,KAWtC,sBAAA,GAAyB,MAAA;AAAA,KAEzB,iBAAA;EACV,EAAA;EACA,SAAA;EAAA,CACC,IAAA;AAAA;;;;;AAhBH;;cAyBa,4BAAA,EAA8B,WAAA;;;AAd3C;;KAwBY,gBAAA;EACV,OAAA;EACA,IAAA,GAAO,MAAA;EACP,SAAA;AAAA;AAAA,KAGU,aAAA;EAEN,OAAA;
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/generative-ui/types.ts"],"mappings":";;;;cACa,YAAA;;cAEA,2BAAA;;cAEA,yCAAA;;cAGA,yBAAA;AALb;AAAA,cAOa,yBAAA;;cAEA,qB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AiFgB,mBAAA,CACd,KAAA,EAAO,qBAAA,GACN,iBAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/generative-ui/types.ts
|
|
2
2
|
/** A2UI protocol version used on the wire. */
|
|
3
|
-
const A2UI_VERSION = "
|
|
3
|
+
const A2UI_VERSION = "1.0";
|
|
4
4
|
/** Activity type of a generated surface message. */
|
|
5
5
|
const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
|
|
6
6
|
/** Activity type of a function call that the agent asks the client to run. */
|
|
@@ -64,7 +64,7 @@ const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;
|
|
|
64
64
|
* @example
|
|
65
65
|
* ```ts
|
|
66
66
|
* toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
|
|
67
|
-
* // { version: "
|
|
67
|
+
* // { version: "1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
function toA2UIActionMessage(event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"v1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: \"v1.0\";\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: \"v1.0\";\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: \"v1.0\";\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | { version: \"v1.0\"; deleteSurface: { surfaceId: string } }\n | {\n version: \"v1.0\";\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"v1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AA8JF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AA+DlD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: typeof A2UI_VERSION;\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: typeof A2UI_VERSION;\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: typeof A2UI_VERSION;\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | {\n version: typeof A2UI_VERSION;\n deleteSurface: { surfaceId: string };\n }\n | {\n version: typeof A2UI_VERSION;\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AAiKF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AA+DlD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
|
@@ -375,11 +375,11 @@ function childRefProblem(node, ref, ownId) {
|
|
|
375
375
|
const isDynamic = (value) => isPathBinding(value) || require_is_record.isRecord(value) && "@call" in value;
|
|
376
376
|
const visit = (value, steps) => {
|
|
377
377
|
if (isDynamic(value)) return void 0;
|
|
378
|
-
|
|
378
|
+
const [head, ...rest] = steps;
|
|
379
|
+
if (head === void 0) {
|
|
379
380
|
const reason = slotProblem(value, ref.kind, ownId);
|
|
380
381
|
return reason ? `${label}: ${reason}` : void 0;
|
|
381
382
|
}
|
|
382
|
-
const [head, ...rest] = steps;
|
|
383
383
|
if (head === "*") {
|
|
384
384
|
if (!Array.isArray(value)) return void 0;
|
|
385
385
|
for (const item of value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-operation.cjs","names":["isRecord","A2UI_VERSION","GENERATIVE_UI_AGENT_FUNCTION_CALLS","GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON","isCallBinding","GENERATIVE_UI_FUNCTIONS","functionCallers","isA2UIValueFunction","isA2UIBasicFunction","collectChildRefs"],"sources":["../../src/generative-ui/validate-operation.ts"],"sourcesContent":["import {\n GENERATIVE_UI_FUNCTIONS,\n functionCallers,\n isA2UIBasicFunction,\n isA2UIValueFunction,\n isCallBinding,\n} from \"./basic-functions\";\nimport type { A2UIFunctionPermissions } from \"./basic-functions\";\nimport { collectChildRefs } from \"./child-refs\";\nimport type { ChildRef } from \"./child-refs\";\nimport {\n A2UI_VERSION,\n GENERATIVE_UI_AGENT_FUNCTION_CALLS,\n GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON,\n} from \"./types\";\nimport type {\n GenerativeUIActionBinding,\n GenerativeUIJSONSchema,\n GenerativeUIManifest,\n} from \"./types\";\nimport { isRecord } from \"./is-record\";\n\nexport type OperationValidation = { ok: true } | { ok: false; reason: string };\n\nconst OPERATION_KINDS = [\n \"createSurface\",\n \"updateComponents\",\n \"updateDataModel\",\n \"deleteSurface\",\n \"callRendererFunction\",\n] as const;\nexport type OperationKind = (typeof OPERATION_KINDS)[number];\n\nexport interface ValidateOperationOptions {\n manifest: Pick<\n GenerativeUIManifest,\n \"catalogId\" | \"catalogIds\" | \"components\"\n >;\n /**\n * Surfaces that exist before this operation is applied. `updateComponents`,\n * `updateDataModel`, and `deleteSurface` need their surface in this set.\n */\n knownSurfaces: ReadonlySet<string>;\n /**\n * Surface ids that were created before, also the deleted ones. A surface id\n * is unique for the life of the page, so `createSurface` rejects them.\n */\n createdSurfaces?: ReadonlySet<string>;\n /**\n * UI-callable functions. When provided, `functionCall` bindings and\n * `callRendererFunction` must name one of them. The client omits it:\n * availability is checked when the function runs.\n */\n functions?: GenerativeUIManifest[\"functions\"];\n /**\n * The components that the target of the surface takes. When provided,\n * `updateComponents` and the inline components of `createSurface` can use\n * only these names. Left out, every catalog component is allowed.\n */\n allowedComponents?: AllowedComponents;\n}\n\n/** The component names that one target takes. */\nexport interface AllowedComponents {\n /** The target id, for the reason of a rejection. */\n target: string;\n names: ReadonlySet<string>;\n}\n\nconst OK: OperationValidation = { ok: true };\nconst fail = (reason: string): OperationValidation => ({ ok: false, reason });\n\n/** Models write the v0.9 binding from habit. The reason names the v1.0 form. */\nconst V09_PATH_REASON = 'bind data with {\"@path\": \"/x\"}, not {\"path\": \"/x\"}';\n\nfunction hasOwn(record: object, key: string) {\n return Object.prototype.hasOwnProperty.call(record, key);\n}\n\n/**\n * Reads an own property only. Model-controlled keys such as \"constructor\" or\n * \"toString\" must not resolve to Object.prototype members.\n */\nfunction ownValue<T>(record: Record<string, T> | undefined, key: string) {\n return record && hasOwn(record, key) ? record[key] : undefined;\n}\n\nexport function getOperationKind(op: unknown) {\n if (!isRecord(op)) return undefined;\n const kinds = OPERATION_KINDS.filter((kind) => kind in op);\n return kinds.length === 1 ? kinds[0] : undefined;\n}\n\n/** The `surfaceId` of a surface operation. `callRendererFunction` has none. */\nexport function getOperationSurfaceId(op: unknown) {\n if (!isRecord(op)) return undefined;\n const kind = getOperationKind(op);\n if (!kind) return undefined;\n const payload = op[kind];\n return isRecord(payload) && typeof payload.surfaceId === \"string\"\n ? payload.surfaceId\n : undefined;\n}\n\n/** `{ \"@path\": \"/x\" }`: a data-model binding. */\nexport function isPathBinding(value: unknown): value is { \"@path\": string } {\n return (\n isRecord(value) &&\n typeof value[\"@path\"] === \"string\" &&\n Object.keys(value).length === 1\n );\n}\n\n/** `{ \"path\": \"/x\" }`: the v0.9 binding, which v1.0 does not accept. */\nfunction isV09PathBinding(value: unknown) {\n return (\n isRecord(value) &&\n typeof value.path === \"string\" &&\n Object.keys(value).length === 1\n );\n}\n\n/**\n * `{ \"@call\": \"@index\" }` or `{ \"@call\": \"@index\", \"args\": { \"offset\": 1 } }`:\n * the 0-based position of the item in a template, plus `offset`.\n */\nexport function isIndexCall(\n value: unknown,\n): value is { \"@call\": \"@index\"; args?: { offset?: number } } {\n if (!isRecord(value) || value[\"@call\"] !== \"@index\") return false;\n const hasOnlyCallKeys = Object.keys(value).every(\n (key) => key === \"@call\" || key === \"args\",\n );\n if (!hasOnlyCallKeys) return false;\n const { args } = value;\n if (args === undefined) return true;\n return (\n isRecord(args) &&\n Object.keys(args).every((key) => key === \"offset\") &&\n (args.offset === undefined || Number.isFinite(args.offset))\n );\n}\n\nexport function isActionBinding(\n value: unknown,\n): value is GenerativeUIActionBinding {\n return (\n isRecord(value) &&\n Object.keys(value).length === 1 &&\n (isRecord(value.functionCall) || isRecord(value.event))\n );\n}\n\n/**\n * Checks one A2UI v1.0 operation against the catalog and the surfaces that\n * exist. The operation comes from the model, so nothing in it is trusted.\n *\n * @param op - The operation, as parsed from JSON.\n * @param options - The catalog, the known and created surfaces, the\n * functions that the UI can call, and the components that the target of\n * the surface takes.\n *\n * @example\n * ```ts\n * const result = validateOperation(op, { manifest, knownSurfaces });\n * if (!result.ok) rejected.push({ index, reason: result.reason });\n * ```\n */\nexport function validateOperation(\n op: unknown,\n options: ValidateOperationOptions,\n) {\n if (!isRecord(op)) return fail(\"operation must be a JSON object\");\n if (op.version !== A2UI_VERSION) return fail(versionProblem(op.version));\n const kind = getOperationKind(op);\n if (!kind) {\n return fail(\n `operation must contain exactly one of ${OPERATION_KINDS.join(\", \")}`,\n );\n }\n const payload = op[kind];\n if (kind === \"callRendererFunction\") {\n if (!GENERATIVE_UI_AGENT_FUNCTION_CALLS) {\n return fail(GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON);\n }\n return validateRendererFunctionCall(payload, options);\n }\n if (\n !isRecord(payload) ||\n typeof payload.surfaceId !== \"string\" ||\n !payload.surfaceId\n ) {\n return fail(`${kind}.surfaceId is required`);\n }\n const surfaceId = payload.surfaceId;\n if (kind === \"createSurface\") {\n return validateCreateSurface(payload, surfaceId, options);\n }\n if (!options.knownSurfaces.has(surfaceId)) {\n return fail(\n `surface \"${surfaceId}\" does not exist; send createSurface first`,\n );\n }\n switch (kind) {\n case \"deleteSurface\":\n return OK;\n case \"updateDataModel\":\n return validateDataModelUpdate(payload);\n case \"updateComponents\":\n return validateComponents(\n payload.components,\n \"updateComponents.components\",\n options,\n );\n }\n}\n\nfunction versionProblem(version: unknown) {\n return typeof version === \"string\"\n ? `unsupported version \"${version}\"; use \"${A2UI_VERSION}\"`\n : `operation needs \"version\":\"${A2UI_VERSION}\"`;\n}\n\n/** A `catalogId` can name the catalog of the run or one of its bases. */\nfunction catalogProblem(\n catalogId: unknown,\n manifest: ValidateOperationOptions[\"manifest\"],\n) {\n const ids = manifest.catalogIds ?? [manifest.catalogId];\n if (catalogId === undefined || ids.includes(catalogId as string)) {\n return undefined;\n }\n const names = ids.map((id) => `\"${id}\"`).join(\", \");\n const use = ids.length === 1 ? names : `one of: ${names}`;\n return `unknown catalog \"${String(catalogId)}\"; leave out catalogId or use ${use}`;\n}\n\nfunction validateCreateSurface(\n payload: Record<string, unknown>,\n surfaceId: string,\n options: ValidateOperationOptions,\n) {\n if (options.knownSurfaces.has(surfaceId)) {\n return fail(`surface \"${surfaceId}\" already exists`);\n }\n if (options.createdSurfaces?.has(surfaceId)) {\n return fail(\n `surface id \"${surfaceId}\" was used before; use a new surfaceId`,\n );\n }\n const catalogReason = catalogProblem(payload.catalogId, options.manifest);\n if (catalogReason) return fail(catalogReason);\n const { dataModel, components } = payload;\n if (dataModel !== undefined && !isRecord(dataModel)) {\n return fail(\"createSurface.dataModel must be a JSON object\");\n }\n if (components === undefined) return OK;\n return validateComponents(components, \"createSurface.components\", options);\n}\n\nfunction validateRendererFunctionCall(\n payload: unknown,\n options: ValidateOperationOptions,\n) {\n const hasCallId =\n isRecord(payload) &&\n typeof payload.functionCallId === \"string\" &&\n payload.functionCallId !== \"\";\n if (!hasCallId) {\n return fail(\n \"callRendererFunction.functionCallId must be a non-empty string\",\n );\n }\n const reason = functionCallProblem(\n payload.callFunction,\n \"callRendererFunction.callFunction\",\n options,\n );\n return reason ? fail(reason) : OK;\n}\n\nconst FORBIDDEN_SEGMENTS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nfunction decodeSegment(segment: string) {\n return segment.replace(/~([01])/g, (_, g) => (g === \"1\" ? \"/\" : \"~\"));\n}\n\nfunction validateDataModelUpdate(payload: Record<string, unknown>) {\n if (payload.value === undefined) {\n return fail(\n 'updateDataModel.value is required; use \"value\":null to delete',\n );\n }\n const path = payload.path ?? \"/\";\n if (typeof path !== \"string\" || !path.startsWith(\"/\")) {\n return fail(\"updateDataModel.path must be an absolute JSON pointer\");\n }\n if (path === \"/\") {\n // Paths such as \"/items\" point into the root, so the root must be an object.\n if (!isRecord(payload.value)) {\n return fail(\"a root updateDataModel value must be a JSON object\");\n }\n return OK;\n }\n const reason = pathProblem(path, \"updateDataModel.path\");\n return reason ? fail(reason) : OK;\n}\n\n/**\n * Checks the segments of an absolute JSON pointer (\"/a/b\") or of a path\n * relative to a template item (\"a/b\"). `label` names the field in the reason.\n */\nfunction pathProblem(path: string, label: string) {\n const relative = path.startsWith(\"/\") ? path.slice(1) : path;\n const segments = relative.split(\"/\");\n if (segments.some((segment) => segment === \"\")) {\n return `${label} must not contain empty segments`;\n }\n const decoded = segments.map(decodeSegment);\n const forbidden = decoded.find((segment) => FORBIDDEN_SEGMENTS.has(segment));\n if (forbidden !== undefined) {\n return `path segment \"${forbidden}\" is not allowed in ${label}`;\n }\n return undefined;\n}\n\nfunction validateComponents(\n components: unknown,\n label: string,\n options: ValidateOperationOptions,\n) {\n if (!Array.isArray(components) || components.length === 0) {\n return fail(`${label} must be a non-empty array`);\n }\n const ids = new Set<string>();\n for (const node of components) {\n if (!isRecord(node)) return fail(\"component must be a JSON object\");\n const { id } = node;\n if (typeof id !== \"string\" || !id) return fail(\"id is required\");\n const reason = nodeProblem(node, id, options);\n if (reason) return fail(`component \"${id}\": ${reason}`);\n if (ids.has(id)) {\n return fail(`component \"${id}\" appears twice in one update`);\n }\n ids.add(id);\n }\n return OK;\n}\n\nfunction nodeProblem(\n node: Record<string, unknown>,\n id: string,\n options: ValidateOperationOptions,\n) {\n if (typeof node.component !== \"string\") return \"component type is required\";\n const entry = ownValue(options.manifest.components, node.component);\n if (!entry) return `unknown component \"${node.component}\"`;\n const { allowedComponents } = options;\n if (allowedComponents && !allowedComponents.names.has(node.component)) {\n const names = [...allowedComponents.names].join(\", \") || \"none\";\n return `\"${node.component}\" is not allowed in target \"${allowedComponents.target}\"; use one of: ${names}`;\n }\n const { properties, required } = entry.props;\n const propNames = isRecord(properties) ? Object.keys(properties) : [];\n const props = Object.entries(node);\n for (const [key, value] of props) {\n if (key === \"id\" || key === \"component\") continue;\n if (key === \"catalogId\") {\n const reason = catalogProblem(value, options.manifest);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n if (key === \"metadata\") {\n const isMetadata =\n isRecord(value) &&\n (value.extensions === undefined || isRecord(value.extensions));\n if (!isMetadata) return 'metadata must be { \"extensions\": { ... } }';\n continue;\n }\n if (key === \"accessibility\") {\n const reason = accessibilityProblem(value);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n if (ownValue(entry.events, key)) {\n const reason = actionBindingProblem(value, options);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n const slot = ownValue(entry.slots, key);\n if (slot) {\n const reason = slotProblem(value, slot, id);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n if (!propNames.includes(key)) return `unknown prop \"${key}\"`;\n if (isV09PathBinding(value)) return `${key}: ${V09_PATH_REASON}`;\n const call = findForbiddenCall(value, { allowValueFunctions: true });\n if (call !== undefined) {\n return `${key}: ${call}; a data prop can call only ${VALUE_FUNCTION_LIST}`;\n }\n }\n for (const ref of childRefsOf(entry.props)) {\n const reason = childRefProblem(node, ref, id);\n if (reason) return reason;\n }\n const requiredNames = Array.isArray(required) ? required : [];\n for (const name of requiredNames) {\n if (typeof name === \"string\" && !(name in node)) {\n return `missing required prop \"${name}\"`;\n }\n }\n return undefined;\n}\n\nconst ACCESSIBILITY_KEYS = [\"label\", \"description\", \"live\", \"hidden\"];\nconst LIVE_VALUES = [\"off\", \"polite\", \"assertive\"];\n\n/**\n * Checks the `accessibility` of a component envelope: `label` and\n * `description` are strings or dynamic values, `live` is one of the ARIA\n * values, `hidden` is a boolean or a dynamic value.\n */\nfunction accessibilityProblem(value: unknown) {\n if (!isRecord(value)) {\n return 'must be { \"label\": \"...\", \"description\": \"...\", \"live\": \"polite\", \"hidden\": false }';\n }\n const isDynamic = (field: unknown) =>\n isPathBinding(field) || isCallBinding(field);\n for (const [key, field] of Object.entries(value)) {\n if (!ACCESSIBILITY_KEYS.includes(key)) return `unknown key \"${key}\"`;\n if (isV09PathBinding(field)) return `${key}: ${V09_PATH_REASON}`;\n if (isDynamic(field)) {\n const call = findForbiddenCall(field, { allowValueFunctions: true });\n if (call !== undefined) return `${key}: ${call}`;\n continue;\n }\n if (key === \"live\") {\n if (typeof field !== \"string\" || !LIVE_VALUES.includes(field)) {\n return `live must be one of ${LIVE_VALUES.join(\", \")}`;\n }\n } else if (key === \"hidden\") {\n if (typeof field !== \"boolean\") return \"hidden must be a boolean\";\n } else if (typeof field !== \"string\") {\n return `${key} must be a string`;\n }\n }\n return undefined;\n}\n\nfunction actionBindingProblem(\n value: unknown,\n options: ValidateOperationOptions,\n) {\n if (!isRecord(value)) return \"must be an action object\";\n const keys = Object.keys(value);\n const isOneAction =\n keys.length === 1 && (keys[0] === \"functionCall\" || keys[0] === \"event\");\n if (!isOneAction) {\n return 'must be { \"event\": ... } or { \"functionCall\": ... }';\n }\n if (keys[0] === \"functionCall\") {\n return functionCallProblem(value.functionCall, \"functionCall\", options);\n }\n return eventProblem(value.event);\n}\n\n/**\n * Checks `{ \"@call\": \"<function>\", \"args\": { ... } }`. `label` names the\n * field in the reason.\n */\nfunction functionCallProblem(\n call: unknown,\n label: string,\n options: ValidateOperationOptions,\n) {\n if (!isRecord(call)) {\n return `${label} must be { \"@call\": \"<function>\", \"args\": { ... } }`;\n }\n const name = call[\"@call\"];\n if (typeof name !== \"string\" || !name) {\n return typeof call.call === \"string\"\n ? `${label} names the function with \"@call\", not \"call\"`\n : `${label}[\"@call\"] must be a function name`;\n }\n const { args } = call;\n if (args !== undefined && !isRecord(args)) {\n return `${label}.args must be an object`;\n }\n const catalogReason = catalogProblem(call.catalogId, options.manifest);\n if (catalogReason) return `${label}: ${catalogReason}`;\n const argEntries = Object.entries(args ?? {});\n for (const [key, arg] of argEntries) {\n if (isV09PathBinding(arg))\n return `${label}.args.${key}: ${V09_PATH_REASON}`;\n }\n // A function the app declares under a built-in name is the app's; the\n // restrictions of the built-in do not apply to it.\n const appFunctions = options.functions;\n const declared =\n appFunctions !== undefined && hasOwn(appFunctions, name)\n ? appFunctions[name]\n : undefined;\n const builtIn =\n declared === undefined && hasOwn(GENERATIVE_UI_FUNCTIONS, name)\n ? GENERATIVE_UI_FUNCTIONS[name]\n : undefined;\n if (declared === undefined && builtIn === undefined) {\n return appFunctions === undefined\n ? undefined\n : `function \"${name}\" is not exposed to generative UI`;\n }\n // Without the list of app functions, a built-in name may be the app's own\n // function, so the dispatcher applies the restriction when the call runs.\n if (declared === undefined && appFunctions === undefined) return undefined;\n return callerProblem(\n name,\n declared ?? builtIn!,\n label.startsWith(\"callRendererFunction\") ? \"agent\" : \"renderer\",\n );\n}\n\n/**\n * Why `caller` may not call a function with these permissions, or\n * `undefined` when it may. The dispatcher gives the same reasons at run\n * time, for the calls that are not validated against a function list.\n */\nexport function callerProblem(\n name: string,\n fn: A2UIFunctionPermissions,\n caller: \"agent\" | \"renderer\",\n) {\n const callers = functionCallers(fn);\n if (caller === \"agent\" && !callers.agent) {\n return fn.requiresUserActivation\n ? `function \"${name}\" runs only from a user gesture; the agent cannot call it`\n : `function \"${name}\" runs only in the UI (allowedCallers \"rendererOnly\"); the agent cannot call it`;\n }\n if (caller === \"renderer\" && !callers.renderer) {\n return `function \"${name}\" runs only for the agent (allowedCallers \"agentOnly\"); the UI cannot call it`;\n }\n return undefined;\n}\n\nfunction eventProblem(event: unknown) {\n if (!isRecord(event) || typeof event.name !== \"string\" || !event.name) {\n return \"event.name is required\";\n }\n const { userMessage, context } = event;\n const isUserMessage =\n userMessage === undefined ||\n typeof userMessage === \"string\" ||\n isPathBinding(userMessage) ||\n (isRecord(userMessage) &&\n typeof userMessage[\"@call\"] === \"string\" &&\n findForbiddenCall(userMessage, { allowValueFunctions: true }) ===\n undefined);\n if (!isUserMessage) {\n return isV09PathBinding(userMessage)\n ? `event.userMessage: ${V09_PATH_REASON}`\n : 'event.userMessage must be a string, {\"@path\": \"/x\"} or a function value';\n }\n if (context === undefined) return undefined;\n if (!isRecord(context)) return \"event.context must be an object\";\n const entries = Object.entries(context);\n for (const [key, entry] of entries) {\n if (isV09PathBinding(entry)) {\n return `event.context.${key}: ${V09_PATH_REASON}`;\n }\n const call = findForbiddenCall(entry, { allowValueFunctions: true });\n if (call !== undefined) {\n return `event.context.${key}: ${call}; a context value can call only ${VALUE_FUNCTION_LIST}`;\n }\n }\n return undefined;\n}\n\nfunction slotProblem(\n value: unknown,\n kind: \"single\" | \"multiple\",\n ownId: string,\n) {\n const isTemplate = isRecord(value) && \"componentId\" in value;\n if (kind === \"single\" && isTemplate) {\n return 'a template { \"componentId\", \"path\" } is only allowed in a \"multiple\" slot';\n }\n if (kind === \"multiple\" && isTemplate) {\n return templateProblem(value, ownId);\n }\n if (kind === \"multiple\" && !Array.isArray(value)) {\n return 'must be an array of component ids or a template { \"componentId\", \"path\" }';\n }\n const ids = kind === \"multiple\" && Array.isArray(value) ? value : [value];\n for (const id of ids) {\n if (typeof id !== \"string\" || !id)\n return \"must reference component ids (strings)\";\n if (id === ownId) return \"a component cannot be its own child\";\n }\n return undefined;\n}\n\nfunction templateProblem(template: Record<string, unknown>, ownId: string) {\n const hasOnlyTemplateKeys = Object.keys(template).every(\n (key) => key === \"componentId\" || key === \"path\",\n );\n if (!hasOnlyTemplateKeys) {\n return 'a template takes only \"componentId\" and \"path\"';\n }\n const { componentId, path } = template;\n if (typeof componentId !== \"string\" || !componentId) {\n return \"template componentId must be a component id\";\n }\n if (componentId === ownId) return \"a component cannot be its own child\";\n if (typeof path !== \"string\" || !path) {\n return \"template path must be a JSON pointer or a relative path\";\n }\n return pathProblem(path, \"template path\");\n}\n\nconst VALUE_FUNCTION_LIST = `@index and the built-in functions (${Object.keys(\n GENERATIVE_UI_FUNCTIONS,\n)\n .filter(isA2UIValueFunction)\n .join(\", \")})`;\n\n/**\n * The reason for the first function call in `value` that a data value may\n * not make, at any depth, or `undefined`. A data value may call `@index`\n * and, with `allowValueFunctions`, the basic functions that need no user\n * gesture; the renderer resolves those. An app function, `openUrl`, or an\n * event binding is not a value.\n */\n// The annotation is needed: the function calls itself in its return.\nfunction findForbiddenCall(\n value: unknown,\n options: { allowValueFunctions: boolean },\n): string | undefined {\n if (Array.isArray(value)) {\n for (const item of value) {\n const reason = findForbiddenCall(item, options);\n if (reason !== undefined) return reason;\n }\n return undefined;\n }\n if (!isRecord(value)) return undefined;\n if (isIndexCall(value)) return undefined;\n if (value[\"@call\"] === \"@index\") return \"@index takes only an offset\";\n if (typeof value.call === \"string\") {\n return 'name the function with \"@call\", not \"call\"';\n }\n if (\"functionCall\" in value) {\n return \"an event binding is not a value\";\n }\n const name = value[\"@call\"];\n if (typeof name === \"string\") {\n if (!options.allowValueFunctions || !isA2UIValueFunction(name)) {\n return isA2UIBasicFunction(name)\n ? `\"${name}\" runs only from an event`\n : `\"${name}\" is not a basic function`;\n }\n const args = value.args;\n if (args !== undefined && !isRecord(args)) {\n return `the args of \"${name}\" must be an object`;\n }\n return args === undefined ? undefined : findForbiddenCall(args, options);\n }\n for (const item of Object.values(value)) {\n const reason = findForbiddenCall(item, options);\n if (reason !== undefined) return reason;\n }\n return undefined;\n}\n\nconst childRefCache = new WeakMap<GenerativeUIJSONSchema, ChildRef[]>();\n\n/** The component references of a props schema, computed once per schema. */\nfunction childRefsOf(props: GenerativeUIJSONSchema) {\n let refs = childRefCache.get(props);\n if (!refs) {\n refs = collectChildRefs(props);\n childRefCache.set(props, refs);\n }\n return refs;\n}\n\n/**\n * Checks the component ids at one reference of a node: a typed `child()`\n * or `childList()` prop, at any depth. A missing key is fine; the props\n * schema reports a required one.\n */\nfunction childRefProblem(\n node: Record<string, unknown>,\n ref: ChildRef,\n ownId: string,\n): string | undefined {\n const label = ref.path.filter((step) => step !== \"*\").join(\".\");\n const isDynamic = (value: unknown) =>\n isPathBinding(value) || (isRecord(value) && \"@call\" in value);\n const visit = (\n value: unknown,\n steps: readonly string[],\n ): string | undefined => {\n // A bound or computed value, at the reference or above it, is known\n // only at render.\n if (isDynamic(value)) return undefined;\n if (steps.length === 0) {\n const reason = slotProblem(value, ref.kind, ownId);\n return reason ? `${label}: ${reason}` : undefined;\n }\n const [head, ...rest] = steps;\n if (head === \"*\") {\n if (!Array.isArray(value)) return undefined;\n for (const item of value) {\n const reason = visit(item, rest);\n if (reason) return reason;\n }\n return undefined;\n }\n if (!isRecord(value) || !hasOwn(value, head)) return undefined;\n return visit(value[head], rest);\n };\n return visit(node, ref.path);\n}\n"],"mappings":";;;;;;AAwBA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACD;AAuCD,MAAM,KAA0B,EAAE,IAAI,MAAM;AAC5C,MAAM,QAAQ,YAAyC;CAAE,IAAI;CAAO;CAAQ;;AAG5E,MAAM,kBAAkB;AAEx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cAAc,IAAI,MAAM;AACnC,KAAI,CAAC,MAAM;AACT,SAAOS,oCAAiB,MAAM;AAC9B,gBAAc,IAAI,OAAO,KAAK;;AAEhC,QAAO;;;;;;;AAQT,SAAS,gBACP,MACA,KACA,OACoB;CACpB,MAAM,QAAQ,IAAI,KAAK,QAAQ,SAAS,SAAS,IAAI,CAAC,KAAK,IAAI;CAC/D,MAAM,aAAa,UACjB,cAAc,MAAM,IAAKT,2BAAS,MAAM,IAAI,WAAW;CACzD,MAAM,SACJ,OACA,UACuB;AAGvB,MAAI,UAAU,MAAM,CAAE,QAAO;AAC7B,MAAI,MAAM,WAAW,GAAG;GACtB,MAAM,SAAS,YAAY,OAAO,IAAI,MAAM,MAAM;AAClD,UAAO,SAAS,GAAG,MAAM,IAAI,WAAW;;EAE1C,MAAM,CAAC,MAAM,GAAG,QAAQ;AACxB,MAAI,SAAS,KAAK;AAChB,OAAI,CAAC,MAAM,QAAQ,MAAM,CAAE,QAAO;AAClC,QAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,SAAS,MAAM,MAAM,KAAK;AAChC,QAAI,OAAQ,QAAO;;AAErB;;AAEF,MAAI,CAACA,2BAAS,MAAM,IAAI,CAAC,OAAO,OAAO,KAAK,CAAE,QAAO;AACrD,SAAO,MAAM,MAAM,OAAO,KAAK;;AAEjC,QAAO,MAAM,MAAM,IAAI,KAAK"}
|
|
1
|
+
{"version":3,"file":"validate-operation.cjs","names":["isRecord","A2UI_VERSION","GENERATIVE_UI_AGENT_FUNCTION_CALLS","GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON","isCallBinding","GENERATIVE_UI_FUNCTIONS","functionCallers","isA2UIValueFunction","isA2UIBasicFunction","collectChildRefs"],"sources":["../../src/generative-ui/validate-operation.ts"],"sourcesContent":["import {\n GENERATIVE_UI_FUNCTIONS,\n functionCallers,\n isA2UIBasicFunction,\n isA2UIValueFunction,\n isCallBinding,\n} from \"./basic-functions\";\nimport type { A2UIFunctionPermissions } from \"./basic-functions\";\nimport { collectChildRefs } from \"./child-refs\";\nimport type { ChildRef } from \"./child-refs\";\nimport {\n A2UI_VERSION,\n GENERATIVE_UI_AGENT_FUNCTION_CALLS,\n GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON,\n} from \"./types\";\nimport type {\n GenerativeUIActionBinding,\n GenerativeUIJSONSchema,\n GenerativeUIManifest,\n} from \"./types\";\nimport { isRecord } from \"./is-record\";\n\nexport type OperationValidation = { ok: true } | { ok: false; reason: string };\n\nconst OPERATION_KINDS = [\n \"createSurface\",\n \"updateComponents\",\n \"updateDataModel\",\n \"deleteSurface\",\n \"callRendererFunction\",\n] as const;\nexport type OperationKind = (typeof OPERATION_KINDS)[number];\n\nexport interface ValidateOperationOptions {\n manifest: Pick<\n GenerativeUIManifest,\n \"catalogId\" | \"catalogIds\" | \"components\"\n >;\n /**\n * Surfaces that exist before this operation is applied. `updateComponents`,\n * `updateDataModel`, and `deleteSurface` need their surface in this set.\n */\n knownSurfaces: ReadonlySet<string>;\n /**\n * Surface ids that were created before, also the deleted ones. A surface id\n * is unique for the life of the page, so `createSurface` rejects them.\n */\n createdSurfaces?: ReadonlySet<string>;\n /**\n * UI-callable functions. When provided, `functionCall` bindings and\n * `callRendererFunction` must name one of them. The client omits it:\n * availability is checked when the function runs.\n */\n functions?: GenerativeUIManifest[\"functions\"];\n /**\n * The components that the target of the surface takes. When provided,\n * `updateComponents` and the inline components of `createSurface` can use\n * only these names. Left out, every catalog component is allowed.\n */\n allowedComponents?: AllowedComponents;\n}\n\n/** The component names that one target takes. */\nexport interface AllowedComponents {\n /** The target id, for the reason of a rejection. */\n target: string;\n names: ReadonlySet<string>;\n}\n\nconst OK: OperationValidation = { ok: true };\nconst fail = (reason: string): OperationValidation => ({ ok: false, reason });\n\n/** Models write the v0.9 binding from habit. The reason names the v1.0 form. */\nconst V09_PATH_REASON = 'bind data with {\"@path\": \"/x\"}, not {\"path\": \"/x\"}';\n\nfunction hasOwn(record: object, key: string) {\n return Object.prototype.hasOwnProperty.call(record, key);\n}\n\n/**\n * Reads an own property only. Model-controlled keys such as \"constructor\" or\n * \"toString\" must not resolve to Object.prototype members.\n */\nfunction ownValue<T>(record: Record<string, T> | undefined, key: string) {\n return record && hasOwn(record, key) ? record[key] : undefined;\n}\n\nexport function getOperationKind(op: unknown) {\n if (!isRecord(op)) return undefined;\n const kinds = OPERATION_KINDS.filter((kind) => kind in op);\n return kinds.length === 1 ? kinds[0] : undefined;\n}\n\n/** The `surfaceId` of a surface operation. `callRendererFunction` has none. */\nexport function getOperationSurfaceId(op: unknown) {\n if (!isRecord(op)) return undefined;\n const kind = getOperationKind(op);\n if (!kind) return undefined;\n const payload = op[kind];\n return isRecord(payload) && typeof payload.surfaceId === \"string\"\n ? payload.surfaceId\n : undefined;\n}\n\n/** `{ \"@path\": \"/x\" }`: a data-model binding. */\nexport function isPathBinding(value: unknown): value is { \"@path\": string } {\n return (\n isRecord(value) &&\n typeof value[\"@path\"] === \"string\" &&\n Object.keys(value).length === 1\n );\n}\n\n/** `{ \"path\": \"/x\" }`: the v0.9 binding, which v1.0 does not accept. */\nfunction isV09PathBinding(value: unknown) {\n return (\n isRecord(value) &&\n typeof value.path === \"string\" &&\n Object.keys(value).length === 1\n );\n}\n\n/**\n * `{ \"@call\": \"@index\" }` or `{ \"@call\": \"@index\", \"args\": { \"offset\": 1 } }`:\n * the 0-based position of the item in a template, plus `offset`.\n */\nexport function isIndexCall(\n value: unknown,\n): value is { \"@call\": \"@index\"; args?: { offset?: number } } {\n if (!isRecord(value) || value[\"@call\"] !== \"@index\") return false;\n const hasOnlyCallKeys = Object.keys(value).every(\n (key) => key === \"@call\" || key === \"args\",\n );\n if (!hasOnlyCallKeys) return false;\n const { args } = value;\n if (args === undefined) return true;\n return (\n isRecord(args) &&\n Object.keys(args).every((key) => key === \"offset\") &&\n (args.offset === undefined || Number.isFinite(args.offset))\n );\n}\n\nexport function isActionBinding(\n value: unknown,\n): value is GenerativeUIActionBinding {\n return (\n isRecord(value) &&\n Object.keys(value).length === 1 &&\n (isRecord(value.functionCall) || isRecord(value.event))\n );\n}\n\n/**\n * Checks one A2UI v1.0 operation against the catalog and the surfaces that\n * exist. The operation comes from the model, so nothing in it is trusted.\n *\n * @param op - The operation, as parsed from JSON.\n * @param options - The catalog, the known and created surfaces, the\n * functions that the UI can call, and the components that the target of\n * the surface takes.\n *\n * @example\n * ```ts\n * const result = validateOperation(op, { manifest, knownSurfaces });\n * if (!result.ok) rejected.push({ index, reason: result.reason });\n * ```\n */\nexport function validateOperation(\n op: unknown,\n options: ValidateOperationOptions,\n) {\n if (!isRecord(op)) return fail(\"operation must be a JSON object\");\n if (op.version !== A2UI_VERSION) return fail(versionProblem(op.version));\n const kind = getOperationKind(op);\n if (!kind) {\n return fail(\n `operation must contain exactly one of ${OPERATION_KINDS.join(\", \")}`,\n );\n }\n const payload = op[kind];\n if (kind === \"callRendererFunction\") {\n if (!GENERATIVE_UI_AGENT_FUNCTION_CALLS) {\n return fail(GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON);\n }\n return validateRendererFunctionCall(payload, options);\n }\n if (\n !isRecord(payload) ||\n typeof payload.surfaceId !== \"string\" ||\n !payload.surfaceId\n ) {\n return fail(`${kind}.surfaceId is required`);\n }\n const surfaceId = payload.surfaceId;\n if (kind === \"createSurface\") {\n return validateCreateSurface(payload, surfaceId, options);\n }\n if (!options.knownSurfaces.has(surfaceId)) {\n return fail(\n `surface \"${surfaceId}\" does not exist; send createSurface first`,\n );\n }\n switch (kind) {\n case \"deleteSurface\":\n return OK;\n case \"updateDataModel\":\n return validateDataModelUpdate(payload);\n case \"updateComponents\":\n return validateComponents(\n payload.components,\n \"updateComponents.components\",\n options,\n );\n }\n}\n\nfunction versionProblem(version: unknown) {\n return typeof version === \"string\"\n ? `unsupported version \"${version}\"; use \"${A2UI_VERSION}\"`\n : `operation needs \"version\":\"${A2UI_VERSION}\"`;\n}\n\n/** A `catalogId` can name the catalog of the run or one of its bases. */\nfunction catalogProblem(\n catalogId: unknown,\n manifest: ValidateOperationOptions[\"manifest\"],\n) {\n const ids = manifest.catalogIds ?? [manifest.catalogId];\n if (catalogId === undefined || ids.includes(catalogId as string)) {\n return undefined;\n }\n const names = ids.map((id) => `\"${id}\"`).join(\", \");\n const use = ids.length === 1 ? names : `one of: ${names}`;\n return `unknown catalog \"${String(catalogId)}\"; leave out catalogId or use ${use}`;\n}\n\nfunction validateCreateSurface(\n payload: Record<string, unknown>,\n surfaceId: string,\n options: ValidateOperationOptions,\n) {\n if (options.knownSurfaces.has(surfaceId)) {\n return fail(`surface \"${surfaceId}\" already exists`);\n }\n if (options.createdSurfaces?.has(surfaceId)) {\n return fail(\n `surface id \"${surfaceId}\" was used before; use a new surfaceId`,\n );\n }\n const catalogReason = catalogProblem(payload.catalogId, options.manifest);\n if (catalogReason) return fail(catalogReason);\n const { dataModel, components } = payload;\n if (dataModel !== undefined && !isRecord(dataModel)) {\n return fail(\"createSurface.dataModel must be a JSON object\");\n }\n if (components === undefined) return OK;\n return validateComponents(components, \"createSurface.components\", options);\n}\n\nfunction validateRendererFunctionCall(\n payload: unknown,\n options: ValidateOperationOptions,\n) {\n const hasCallId =\n isRecord(payload) &&\n typeof payload.functionCallId === \"string\" &&\n payload.functionCallId !== \"\";\n if (!hasCallId) {\n return fail(\n \"callRendererFunction.functionCallId must be a non-empty string\",\n );\n }\n const reason = functionCallProblem(\n payload.callFunction,\n \"callRendererFunction.callFunction\",\n options,\n );\n return reason ? fail(reason) : OK;\n}\n\nconst FORBIDDEN_SEGMENTS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nfunction decodeSegment(segment: string) {\n return segment.replace(/~([01])/g, (_, g) => (g === \"1\" ? \"/\" : \"~\"));\n}\n\nfunction validateDataModelUpdate(payload: Record<string, unknown>) {\n if (payload.value === undefined) {\n return fail(\n 'updateDataModel.value is required; use \"value\":null to delete',\n );\n }\n const path = payload.path ?? \"/\";\n if (typeof path !== \"string\" || !path.startsWith(\"/\")) {\n return fail(\"updateDataModel.path must be an absolute JSON pointer\");\n }\n if (path === \"/\") {\n // Paths such as \"/items\" point into the root, so the root must be an object.\n if (!isRecord(payload.value)) {\n return fail(\"a root updateDataModel value must be a JSON object\");\n }\n return OK;\n }\n const reason = pathProblem(path, \"updateDataModel.path\");\n return reason ? fail(reason) : OK;\n}\n\n/**\n * Checks the segments of an absolute JSON pointer (\"/a/b\") or of a path\n * relative to a template item (\"a/b\"). `label` names the field in the reason.\n */\nfunction pathProblem(path: string, label: string) {\n const relative = path.startsWith(\"/\") ? path.slice(1) : path;\n const segments = relative.split(\"/\");\n if (segments.some((segment) => segment === \"\")) {\n return `${label} must not contain empty segments`;\n }\n const decoded = segments.map(decodeSegment);\n const forbidden = decoded.find((segment) => FORBIDDEN_SEGMENTS.has(segment));\n if (forbidden !== undefined) {\n return `path segment \"${forbidden}\" is not allowed in ${label}`;\n }\n return undefined;\n}\n\nfunction validateComponents(\n components: unknown,\n label: string,\n options: ValidateOperationOptions,\n) {\n if (!Array.isArray(components) || components.length === 0) {\n return fail(`${label} must be a non-empty array`);\n }\n const ids = new Set<string>();\n for (const node of components) {\n if (!isRecord(node)) return fail(\"component must be a JSON object\");\n const { id } = node;\n if (typeof id !== \"string\" || !id) return fail(\"id is required\");\n const reason = nodeProblem(node, id, options);\n if (reason) return fail(`component \"${id}\": ${reason}`);\n if (ids.has(id)) {\n return fail(`component \"${id}\" appears twice in one update`);\n }\n ids.add(id);\n }\n return OK;\n}\n\nfunction nodeProblem(\n node: Record<string, unknown>,\n id: string,\n options: ValidateOperationOptions,\n) {\n if (typeof node.component !== \"string\") return \"component type is required\";\n const entry = ownValue(options.manifest.components, node.component);\n if (!entry) return `unknown component \"${node.component}\"`;\n const { allowedComponents } = options;\n if (allowedComponents && !allowedComponents.names.has(node.component)) {\n const names = [...allowedComponents.names].join(\", \") || \"none\";\n return `\"${node.component}\" is not allowed in target \"${allowedComponents.target}\"; use one of: ${names}`;\n }\n const { properties, required } = entry.props;\n const propNames = isRecord(properties) ? Object.keys(properties) : [];\n const props = Object.entries(node);\n for (const [key, value] of props) {\n if (key === \"id\" || key === \"component\") continue;\n if (key === \"catalogId\") {\n const reason = catalogProblem(value, options.manifest);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n if (key === \"metadata\") {\n const isMetadata =\n isRecord(value) &&\n (value.extensions === undefined || isRecord(value.extensions));\n if (!isMetadata) return 'metadata must be { \"extensions\": { ... } }';\n continue;\n }\n if (key === \"accessibility\") {\n const reason = accessibilityProblem(value);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n if (ownValue(entry.events, key)) {\n const reason = actionBindingProblem(value, options);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n const slot = ownValue(entry.slots, key);\n if (slot) {\n const reason = slotProblem(value, slot, id);\n if (reason) return `${key}: ${reason}`;\n continue;\n }\n if (!propNames.includes(key)) return `unknown prop \"${key}\"`;\n if (isV09PathBinding(value)) return `${key}: ${V09_PATH_REASON}`;\n const call = findForbiddenCall(value, { allowValueFunctions: true });\n if (call !== undefined) {\n return `${key}: ${call}; a data prop can call only ${VALUE_FUNCTION_LIST}`;\n }\n }\n for (const ref of childRefsOf(entry.props)) {\n const reason = childRefProblem(node, ref, id);\n if (reason) return reason;\n }\n const requiredNames = Array.isArray(required) ? required : [];\n for (const name of requiredNames) {\n if (typeof name === \"string\" && !(name in node)) {\n return `missing required prop \"${name}\"`;\n }\n }\n return undefined;\n}\n\nconst ACCESSIBILITY_KEYS = [\"label\", \"description\", \"live\", \"hidden\"];\nconst LIVE_VALUES = [\"off\", \"polite\", \"assertive\"];\n\n/**\n * Checks the `accessibility` of a component envelope: `label` and\n * `description` are strings or dynamic values, `live` is one of the ARIA\n * values, `hidden` is a boolean or a dynamic value.\n */\nfunction accessibilityProblem(value: unknown) {\n if (!isRecord(value)) {\n return 'must be { \"label\": \"...\", \"description\": \"...\", \"live\": \"polite\", \"hidden\": false }';\n }\n const isDynamic = (field: unknown) =>\n isPathBinding(field) || isCallBinding(field);\n for (const [key, field] of Object.entries(value)) {\n if (!ACCESSIBILITY_KEYS.includes(key)) return `unknown key \"${key}\"`;\n if (isV09PathBinding(field)) return `${key}: ${V09_PATH_REASON}`;\n if (isDynamic(field)) {\n const call = findForbiddenCall(field, { allowValueFunctions: true });\n if (call !== undefined) return `${key}: ${call}`;\n continue;\n }\n if (key === \"live\") {\n if (typeof field !== \"string\" || !LIVE_VALUES.includes(field)) {\n return `live must be one of ${LIVE_VALUES.join(\", \")}`;\n }\n } else if (key === \"hidden\") {\n if (typeof field !== \"boolean\") return \"hidden must be a boolean\";\n } else if (typeof field !== \"string\") {\n return `${key} must be a string`;\n }\n }\n return undefined;\n}\n\nfunction actionBindingProblem(\n value: unknown,\n options: ValidateOperationOptions,\n) {\n if (!isRecord(value)) return \"must be an action object\";\n const keys = Object.keys(value);\n const isOneAction =\n keys.length === 1 && (keys[0] === \"functionCall\" || keys[0] === \"event\");\n if (!isOneAction) {\n return 'must be { \"event\": ... } or { \"functionCall\": ... }';\n }\n if (keys[0] === \"functionCall\") {\n return functionCallProblem(value.functionCall, \"functionCall\", options);\n }\n return eventProblem(value.event);\n}\n\n/**\n * Checks `{ \"@call\": \"<function>\", \"args\": { ... } }`. `label` names the\n * field in the reason.\n */\nfunction functionCallProblem(\n call: unknown,\n label: string,\n options: ValidateOperationOptions,\n) {\n if (!isRecord(call)) {\n return `${label} must be { \"@call\": \"<function>\", \"args\": { ... } }`;\n }\n const name = call[\"@call\"];\n if (typeof name !== \"string\" || !name) {\n return typeof call.call === \"string\"\n ? `${label} names the function with \"@call\", not \"call\"`\n : `${label}[\"@call\"] must be a function name`;\n }\n const { args } = call;\n if (args !== undefined && !isRecord(args)) {\n return `${label}.args must be an object`;\n }\n const catalogReason = catalogProblem(call.catalogId, options.manifest);\n if (catalogReason) return `${label}: ${catalogReason}`;\n const argEntries = Object.entries(args ?? {});\n for (const [key, arg] of argEntries) {\n if (isV09PathBinding(arg))\n return `${label}.args.${key}: ${V09_PATH_REASON}`;\n }\n // A function the app declares under a built-in name is the app's; the\n // restrictions of the built-in do not apply to it.\n const appFunctions = options.functions;\n const declared =\n appFunctions !== undefined && hasOwn(appFunctions, name)\n ? appFunctions[name]\n : undefined;\n const builtIn =\n declared === undefined && hasOwn(GENERATIVE_UI_FUNCTIONS, name)\n ? GENERATIVE_UI_FUNCTIONS[name]\n : undefined;\n if (declared === undefined && builtIn === undefined) {\n return appFunctions === undefined\n ? undefined\n : `function \"${name}\" is not exposed to generative UI`;\n }\n // Without the list of app functions, a built-in name may be the app's own\n // function, so the dispatcher applies the restriction when the call runs.\n if (declared === undefined && appFunctions === undefined) return undefined;\n return callerProblem(\n name,\n declared ?? builtIn!,\n label.startsWith(\"callRendererFunction\") ? \"agent\" : \"renderer\",\n );\n}\n\n/**\n * Why `caller` may not call a function with these permissions, or\n * `undefined` when it may. The dispatcher gives the same reasons at run\n * time, for the calls that are not validated against a function list.\n */\nexport function callerProblem(\n name: string,\n fn: A2UIFunctionPermissions,\n caller: \"agent\" | \"renderer\",\n) {\n const callers = functionCallers(fn);\n if (caller === \"agent\" && !callers.agent) {\n return fn.requiresUserActivation\n ? `function \"${name}\" runs only from a user gesture; the agent cannot call it`\n : `function \"${name}\" runs only in the UI (allowedCallers \"rendererOnly\"); the agent cannot call it`;\n }\n if (caller === \"renderer\" && !callers.renderer) {\n return `function \"${name}\" runs only for the agent (allowedCallers \"agentOnly\"); the UI cannot call it`;\n }\n return undefined;\n}\n\nfunction eventProblem(event: unknown) {\n if (!isRecord(event) || typeof event.name !== \"string\" || !event.name) {\n return \"event.name is required\";\n }\n const { userMessage, context } = event;\n const isUserMessage =\n userMessage === undefined ||\n typeof userMessage === \"string\" ||\n isPathBinding(userMessage) ||\n (isRecord(userMessage) &&\n typeof userMessage[\"@call\"] === \"string\" &&\n findForbiddenCall(userMessage, { allowValueFunctions: true }) ===\n undefined);\n if (!isUserMessage) {\n return isV09PathBinding(userMessage)\n ? `event.userMessage: ${V09_PATH_REASON}`\n : 'event.userMessage must be a string, {\"@path\": \"/x\"} or a function value';\n }\n if (context === undefined) return undefined;\n if (!isRecord(context)) return \"event.context must be an object\";\n const entries = Object.entries(context);\n for (const [key, entry] of entries) {\n if (isV09PathBinding(entry)) {\n return `event.context.${key}: ${V09_PATH_REASON}`;\n }\n const call = findForbiddenCall(entry, { allowValueFunctions: true });\n if (call !== undefined) {\n return `event.context.${key}: ${call}; a context value can call only ${VALUE_FUNCTION_LIST}`;\n }\n }\n return undefined;\n}\n\nfunction slotProblem(\n value: unknown,\n kind: \"single\" | \"multiple\",\n ownId: string,\n) {\n const isTemplate = isRecord(value) && \"componentId\" in value;\n if (kind === \"single\" && isTemplate) {\n return 'a template { \"componentId\", \"path\" } is only allowed in a \"multiple\" slot';\n }\n if (kind === \"multiple\" && isTemplate) {\n return templateProblem(value, ownId);\n }\n if (kind === \"multiple\" && !Array.isArray(value)) {\n return 'must be an array of component ids or a template { \"componentId\", \"path\" }';\n }\n const ids = kind === \"multiple\" && Array.isArray(value) ? value : [value];\n for (const id of ids) {\n if (typeof id !== \"string\" || !id)\n return \"must reference component ids (strings)\";\n if (id === ownId) return \"a component cannot be its own child\";\n }\n return undefined;\n}\n\nfunction templateProblem(template: Record<string, unknown>, ownId: string) {\n const hasOnlyTemplateKeys = Object.keys(template).every(\n (key) => key === \"componentId\" || key === \"path\",\n );\n if (!hasOnlyTemplateKeys) {\n return 'a template takes only \"componentId\" and \"path\"';\n }\n const { componentId, path } = template;\n if (typeof componentId !== \"string\" || !componentId) {\n return \"template componentId must be a component id\";\n }\n if (componentId === ownId) return \"a component cannot be its own child\";\n if (typeof path !== \"string\" || !path) {\n return \"template path must be a JSON pointer or a relative path\";\n }\n return pathProblem(path, \"template path\");\n}\n\nconst VALUE_FUNCTION_LIST = `@index and the built-in functions (${Object.keys(\n GENERATIVE_UI_FUNCTIONS,\n)\n .filter(isA2UIValueFunction)\n .join(\", \")})`;\n\n/**\n * The reason for the first function call in `value` that a data value may\n * not make, at any depth, or `undefined`. A data value may call `@index`\n * and, with `allowValueFunctions`, the basic functions that need no user\n * gesture; the renderer resolves those. An app function, `openUrl`, or an\n * event binding is not a value.\n */\n// The annotation is needed: the function calls itself in its return.\nfunction findForbiddenCall(\n value: unknown,\n options: { allowValueFunctions: boolean },\n): string | undefined {\n if (Array.isArray(value)) {\n for (const item of value) {\n const reason = findForbiddenCall(item, options);\n if (reason !== undefined) return reason;\n }\n return undefined;\n }\n if (!isRecord(value)) return undefined;\n if (isIndexCall(value)) return undefined;\n if (value[\"@call\"] === \"@index\") return \"@index takes only an offset\";\n if (typeof value.call === \"string\") {\n return 'name the function with \"@call\", not \"call\"';\n }\n if (\"functionCall\" in value) {\n return \"an event binding is not a value\";\n }\n const name = value[\"@call\"];\n if (typeof name === \"string\") {\n if (!options.allowValueFunctions || !isA2UIValueFunction(name)) {\n return isA2UIBasicFunction(name)\n ? `\"${name}\" runs only from an event`\n : `\"${name}\" is not a basic function`;\n }\n const args = value.args;\n if (args !== undefined && !isRecord(args)) {\n return `the args of \"${name}\" must be an object`;\n }\n return args === undefined ? undefined : findForbiddenCall(args, options);\n }\n for (const item of Object.values(value)) {\n const reason = findForbiddenCall(item, options);\n if (reason !== undefined) return reason;\n }\n return undefined;\n}\n\nconst childRefCache = new WeakMap<GenerativeUIJSONSchema, ChildRef[]>();\n\n/** The component references of a props schema, computed once per schema. */\nfunction childRefsOf(props: GenerativeUIJSONSchema) {\n let refs = childRefCache.get(props);\n if (!refs) {\n refs = collectChildRefs(props);\n childRefCache.set(props, refs);\n }\n return refs;\n}\n\n/**\n * Checks the component ids at one reference of a node: a typed `child()`\n * or `childList()` prop, at any depth. A missing key is fine; the props\n * schema reports a required one.\n */\nfunction childRefProblem(\n node: Record<string, unknown>,\n ref: ChildRef,\n ownId: string,\n): string | undefined {\n const label = ref.path.filter((step) => step !== \"*\").join(\".\");\n const isDynamic = (value: unknown) =>\n isPathBinding(value) || (isRecord(value) && \"@call\" in value);\n const visit = (\n value: unknown,\n steps: readonly string[],\n ): string | undefined => {\n // A bound or computed value, at the reference or above it, is known\n // only at render.\n if (isDynamic(value)) return undefined;\n const [head, ...rest] = steps;\n if (head === undefined) {\n const reason = slotProblem(value, ref.kind, ownId);\n return reason ? `${label}: ${reason}` : undefined;\n }\n if (head === \"*\") {\n if (!Array.isArray(value)) return undefined;\n for (const item of value) {\n const reason = visit(item, rest);\n if (reason) return reason;\n }\n return undefined;\n }\n if (!isRecord(value) || !hasOwn(value, head)) return undefined;\n return visit(value[head], rest);\n };\n return visit(node, ref.path);\n}\n"],"mappings":";;;;;;AAwBA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACD;AAuCD,MAAM,KAA0B,EAAE,IAAI,MAAM;AAC5C,MAAM,QAAQ,YAAyC;CAAE,IAAI;CAAO;CAAQ;;AAG5E,MAAM,kBAAkB;AAExB,SAAS,OAAO,QAAgB,KAAa;AAC3C,QAAO,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;;;;;;AAO1D,SAAS,SAAY,QAAuC,KAAa;AACvE,QAAO,UAAU,OAAO,QAAQ,IAAI,GAAG,OAAO,OAAO;;AAGvD,SAAgB,iBAAiB,IAAa;AAC5C,KAAI,CAACA,2BAAS,GAAG,CAAE,QAAO;CAC1B,MAAM,QAAQ,gBAAgB,QAAQ,SAAS,QAAQ,GAAG;AAC1D,QAAO,MAAM,WAAW,IAAI,MAAM,KAAK;;;AAIzC,SAAgB,sBAAsB,IAAa;AACjD,KAAI,CAACA,2BAAS,GAAG,CAAE,QAAO;CAC1B,MAAM,OAAO,iBAAiB,GAAG;AACjC,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,UAAU,GAAG;AACnB,QAAOA,2BAAS,QAAQ,IAAI,OAAO,QAAQ,cAAc,WACrD,QAAQ,YACR;;;AAIN,SAAgB,cAAc,OAA8C;AAC1E,QACEA,2BAAS,MAAM,IACf,OAAO,MAAM,aAAa,YAC1B,OAAO,KAAK,MAAM,CAAC,WAAW;;;A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AEF,MAAI,CAACA,2BAAS,MAAM,IAAI,CAAC,OAAO,OAAO,KAAK,CAAE,QAAO;AACrD,SAAO,MAAM,MAAM,OAAO,KAAK;;AAEjC,QAAO,MAAM,MAAM,IAAI,KAAK"}
|
|
@@ -375,11 +375,11 @@ function childRefProblem(node, ref, ownId) {
|
|
|
375
375
|
const isDynamic = (value) => isPathBinding(value) || isRecord(value) && "@call" in value;
|
|
376
376
|
const visit = (value, steps) => {
|
|
377
377
|
if (isDynamic(value)) return void 0;
|
|
378
|
-
|
|
378
|
+
const [head, ...rest] = steps;
|
|
379
|
+
if (head === void 0) {
|
|
379
380
|
const reason = slotProblem(value, ref.kind, ownId);
|
|
380
381
|
return reason ? `${label}: ${reason}` : void 0;
|
|
381
382
|
}
|
|
382
|
-
const [head, ...rest] = steps;
|
|
383
383
|
if (head === "*") {
|
|
384
384
|
if (!Array.isArray(value)) return void 0;
|
|
385
385
|
for (const item of value) {
|