@copilotkit/shared 2.0.0-rc.1 → 2.0.0-rc.11
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-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/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/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/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/index.cjs +17 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -7
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +808 -438
- 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.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.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 +4 -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 +5 -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 +4 -5
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -5
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -5
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/json-schema.cjs +0 -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 +1 -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 +7 -31
- package/src/__tests__/a2ui-prompts.test.ts +42 -9
- 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-prompts.ts +47 -96
- package/src/generative-ui/basic-functions.ts +1 -1
- 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/schema-render.ts +374 -0
- package/src/index.ts +3 -16
- package/src/standard-schema.ts +24 -27
- package/src/telemetry/lambda-client.ts +3 -2
- 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 +27 -85
- package/src/utils/index.ts +1 -2
- package/src/utils/json-schema.ts +1 -152
- package/src/utils/process-env.ts +14 -0
- package/src/utils/random-id.ts +17 -37
- 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.cjs","names":["compactType","compactProps","functionCallers","GENERATIVE_UI_AGENT_FUNCTION_CALLS","buildCompactGenerativeUISchema"],"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 = hasOwn(components, name) ? components[name] : 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,YAAYA,mCAAY,GAAG,Y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AO,YAAY,KAAK,GAC5C,WAAW,QACX;AACN,MAAI,CAAC,SAAS,SAAS,EAAE;AACvB,WAAQ,KAAK,IAAI;AACjB;;AAEF,WAAS,cAAc;;AAEzB,QAAO;EAAE,UAAU;GAAE,GAAG;GAAU;GAAY;EAAE;EAAS;;;;;;;AAQ3D,SAAgB,eACd,UACA,UACuB;CACvB,MAAM,UAAoB,EAAE;AAC5B,MAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,SAAS,WAAW,EAAE;AACnE,MAAI,CAAC,SAAS,SAAS,KAAK,CAAE,SAAQ,KAAK,KAAK;EAChD,MAAM,aAAa,SAAS,UAAU,MAAM,WAAW,GACnD,UAAU,MAAM,aAChB,EAAE;AACN,OAAK,MAAM,QAAQ,OAAO,KAAK,WAAW,CACxC,KAAI,CAAC,SAAS,SAAS,KAAK,CAAE,SAAQ,KAAK,GAAG,KAAK,GAAG,OAAO;;AAGjE,QAAO,EAAE,SAAS"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GenerativeUIManifest } from "./types.cjs";
|
|
2
|
+
import { GenerativeUISchemaSettings } from "./prompt-spec.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/generative-ui/schema-render.d.ts
|
|
5
|
+
type SchemaManifest = Pick<GenerativeUIManifest, "catalogId" | "components" | "functions" | "targets" | "surfaces">;
|
|
6
|
+
/**
|
|
7
|
+
* The component schema of the markdown transport, as the text of its
|
|
8
|
+
* context entry, in the notation of `settings`. `compact` is the schema that
|
|
9
|
+
* ships (`buildCompactGenerativeUISchema`), `json-schema` the manifest parts
|
|
10
|
+
* as JSON, `ts-signature` one line per component, `lines` one line per
|
|
11
|
+
* prop with bare enums (the fewest tokens).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const value = renderGenerativeUISchema(manifest, spec.schema.markdown);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function renderGenerativeUISchema(manifest: SchemaManifest, settings: GenerativeUISchemaSettings): string;
|
|
19
|
+
/**
|
|
20
|
+
* The component list of the tool guide, one entry per component, in the
|
|
21
|
+
* notation of `settings`. `json-schema` is the list that ships.
|
|
22
|
+
*/
|
|
23
|
+
declare function renderGenerativeUIComponentList(components: GenerativeUIManifest["components"], settings: GenerativeUISchemaSettings): string;
|
|
24
|
+
/**
|
|
25
|
+
* The manifest with replaced descriptions: `"Name"` replaces the
|
|
26
|
+
* description of a component, `"Name.prop"` the description of one of its
|
|
27
|
+
* props. Keys that name no component or prop are left out of the result
|
|
28
|
+
* and listed in `unknown`. The manifest is not changed.
|
|
29
|
+
*/
|
|
30
|
+
declare function applyDescriptionOverrides<M extends Pick<GenerativeUIManifest, "components">>(manifest: M, overrides: Record<string, string>): {
|
|
31
|
+
manifest: M;
|
|
32
|
+
unknown: string[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The components and props of `manifest` whose names do not appear in
|
|
36
|
+
* `rendered`. A schema notation that leaves one out would hide part of the
|
|
37
|
+
* catalog from the model.
|
|
38
|
+
*/
|
|
39
|
+
declare function schemaCoverage(manifest: Pick<GenerativeUIManifest, "components">, rendered: string): {
|
|
40
|
+
missing: string[];
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { applyDescriptionOverrides, renderGenerativeUIComponentList, renderGenerativeUISchema, schemaCoverage };
|
|
44
|
+
//# sourceMappingURL=schema-render.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-render.d.cts","names":[],"sources":["../../src/generative-ui/schema-render.ts"],"mappings":";;;;KAcK,cAAA,GAAiB,IAAA,CACpB,oBAAA;;AAHe;;;;;AAuOjB;;;;;;iBAAgB,wBAAA,CACd,QAAA,EAAU,cAAA,EACV,QAAA,EAAU,0BAAA;;;;AAsCZ;iBAAgB,+BAAA,CACd,UAAA,EAAY,oBAAA,gBACZ,QAAA,EAAU,0BAAA;;;;;;;iBAkCI,yBAAA,WACJ,IAAA,CAAK,oBAAA,gBAAA,CAEf,QAAA,EAAU,CAAA,EACV,SAAA,EAAW,MAAA;EACR,QAAA,EAAU,CAAA;EAAG,OAAA;AAAA;;;;;;iBAkCF,cAAA,CACd,QAAA,EAAU,IAAA,CAAK,oBAAA,iBACf,QAAA;EACG,OAAA;AAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GenerativeUIManifest } from "./types.mjs";
|
|
2
|
+
import { GenerativeUISchemaSettings } from "./prompt-spec.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/generative-ui/schema-render.d.ts
|
|
5
|
+
type SchemaManifest = Pick<GenerativeUIManifest, "catalogId" | "components" | "functions" | "targets" | "surfaces">;
|
|
6
|
+
/**
|
|
7
|
+
* The component schema of the markdown transport, as the text of its
|
|
8
|
+
* context entry, in the notation of `settings`. `compact` is the schema that
|
|
9
|
+
* ships (`buildCompactGenerativeUISchema`), `json-schema` the manifest parts
|
|
10
|
+
* as JSON, `ts-signature` one line per component, `lines` one line per
|
|
11
|
+
* prop with bare enums (the fewest tokens).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const value = renderGenerativeUISchema(manifest, spec.schema.markdown);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function renderGenerativeUISchema(manifest: SchemaManifest, settings: GenerativeUISchemaSettings): string;
|
|
19
|
+
/**
|
|
20
|
+
* The component list of the tool guide, one entry per component, in the
|
|
21
|
+
* notation of `settings`. `json-schema` is the list that ships.
|
|
22
|
+
*/
|
|
23
|
+
declare function renderGenerativeUIComponentList(components: GenerativeUIManifest["components"], settings: GenerativeUISchemaSettings): string;
|
|
24
|
+
/**
|
|
25
|
+
* The manifest with replaced descriptions: `"Name"` replaces the
|
|
26
|
+
* description of a component, `"Name.prop"` the description of one of its
|
|
27
|
+
* props. Keys that name no component or prop are left out of the result
|
|
28
|
+
* and listed in `unknown`. The manifest is not changed.
|
|
29
|
+
*/
|
|
30
|
+
declare function applyDescriptionOverrides<M extends Pick<GenerativeUIManifest, "components">>(manifest: M, overrides: Record<string, string>): {
|
|
31
|
+
manifest: M;
|
|
32
|
+
unknown: string[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The components and props of `manifest` whose names do not appear in
|
|
36
|
+
* `rendered`. A schema notation that leaves one out would hide part of the
|
|
37
|
+
* catalog from the model.
|
|
38
|
+
*/
|
|
39
|
+
declare function schemaCoverage(manifest: Pick<GenerativeUIManifest, "components">, rendered: string): {
|
|
40
|
+
missing: string[];
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { applyDescriptionOverrides, renderGenerativeUIComponentList, renderGenerativeUISchema, schemaCoverage };
|
|
44
|
+
//# sourceMappingURL=schema-render.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-render.d.mts","names":[],"sources":["../../src/generative-ui/schema-render.ts"],"mappings":";;;;KAcK,cAAA,GAAiB,IAAA,CACpB,oBAAA;;AAHe;;;;;AAuOjB;;;;;;iBAAgB,wBAAA,CACd,QAAA,EAAU,cAAA,EACV,QAAA,EAAU,0BAAA;;;;AAsCZ;iBAAgB,+BAAA,CACd,UAAA,EAAY,oBAAA,gBACZ,QAAA,EAAU,0BAAA;;;;;;;iBAkCI,yBAAA,WACJ,IAAA,CAAK,oBAAA,gBAAA,CAEf,QAAA,EAAU,CAAA,EACV,SAAA,EAAW,MAAA;EACR,QAAA,EAAU,CAAA;EAAG,OAAA;AAAA;;;;;;iBAkCF,cAAA,CACd,QAAA,EAAU,IAAA,CAAK,oBAAA,iBACf,QAAA;EACG,OAAA;AAAA"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { functionCallers } from "./basic-functions.mjs";
|
|
2
|
+
import { GENERATIVE_UI_AGENT_FUNCTION_CALLS } from "./types.mjs";
|
|
3
|
+
import { buildCompactGenerativeUISchema, compactProps, compactType } from "./compact-schema.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/generative-ui/schema-render.ts
|
|
6
|
+
/** An own key (shared compiles to ES2017, which has no Object.hasOwn). */
|
|
7
|
+
const hasOwn = (target, key) => Object.prototype.hasOwnProperty.call(target, key);
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
/** The props schema without the description of each prop. */
|
|
12
|
+
function withoutPropDescriptions(schema) {
|
|
13
|
+
if (!isRecord(schema.properties)) return schema;
|
|
14
|
+
return {
|
|
15
|
+
...schema,
|
|
16
|
+
properties: Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => {
|
|
17
|
+
if (!isRecord(value)) return [key, value];
|
|
18
|
+
const { description: _description, ...rest } = value;
|
|
19
|
+
return [key, rest];
|
|
20
|
+
}))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** The short signature of a function: its built-in signature, or its schema made short. */
|
|
24
|
+
function functionSignature(fn) {
|
|
25
|
+
const signature = fn.parameters.description;
|
|
26
|
+
return typeof signature === "string" && signature.startsWith("{") && Object.keys(fn.parameters).length === 2 ? signature : compactType(fn.parameters, 0);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A function name with its parameters: `pick{ id: string }`, `clearCart{}`
|
|
30
|
+
* for no arguments, `setVolume(number)` for a parameter that is not an object.
|
|
31
|
+
*/
|
|
32
|
+
function nameWithParameters(name, parameters) {
|
|
33
|
+
if (parameters.startsWith("{")) return `${name}${parameters}`;
|
|
34
|
+
if (parameters === "object") return `${name}{}`;
|
|
35
|
+
return `${name}(${parameters})`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One component as a TypeScript-like signature line, with its events and
|
|
39
|
+
* slots on the lines below:
|
|
40
|
+
* `- Text(text?: string // The text): Shows text`.
|
|
41
|
+
*/
|
|
42
|
+
function signatureLines(name, component, settings) {
|
|
43
|
+
const lines = [`- ${name}(${Object.entries(compactProps(component.props, settings.propDescriptions)).map(([key, type]) => `${key}: ${type}`).join(", ")})${component.description ? `: ${oneLine(component.description)}` : ""}`];
|
|
44
|
+
const events = Object.entries(component.events ?? {}).map(([event, definition]) => `${event}(${definition.description ? oneLine(definition.description) : compactType(definition.parameters, 0)})`);
|
|
45
|
+
if (events.length > 0) lines.push(` events: ${events.join(", ")}`);
|
|
46
|
+
const slots = Object.entries(component.slots ?? {}).map(([slot, kind]) => `${slot} (${kind})`);
|
|
47
|
+
if (slots.length > 0) lines.push(` slots: ${slots.join(", ")}`);
|
|
48
|
+
return lines;
|
|
49
|
+
}
|
|
50
|
+
/** The whole schema as signature text: targets, functions, components, surfaces. */
|
|
51
|
+
function signatureSchema(manifest, settings) {
|
|
52
|
+
const targets = manifest.targets.map((t) => {
|
|
53
|
+
const limit = t.components ? `; only ${t.components.join(", ")}` : "";
|
|
54
|
+
return `- ${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : ""}`;
|
|
55
|
+
});
|
|
56
|
+
const functions = Object.entries(manifest.functions).map(([name, fn]) => {
|
|
57
|
+
const callers = functionCallers(fn);
|
|
58
|
+
const who = callers.agent && GENERATIVE_UI_AGENT_FUNCTION_CALLS ? callers.renderer ? " (UI or agent)" : " (agent only)" : "";
|
|
59
|
+
return `- ${nameWithParameters(name, functionSignature(fn))}${who}${fn.description ? `: ${oneLine(fn.description)}` : ""}`;
|
|
60
|
+
});
|
|
61
|
+
const components = Object.entries(manifest.components).flatMap(([name, component]) => signatureLines(name, component, settings));
|
|
62
|
+
const surfaces = Object.entries(manifest.surfaces).map(([id, s]) => `- ${id} (target ${s.target})${s.status ? ` status: ${s.status}` : ""}${s.dataModel ? ` user values: ${JSON.stringify(s.dataModel)}` : ""}${(s.rejected ?? []).map((r) => ` rejected: ${r}`).join("")}`);
|
|
63
|
+
return [
|
|
64
|
+
`Catalog: ${manifest.catalogId}`,
|
|
65
|
+
`Targets:\n${targets.join("\n") || "- none"}`,
|
|
66
|
+
`Functions:\n${functions.join("\n") || "- none"}`,
|
|
67
|
+
`Components:\n${components.join("\n") || "- none"}`,
|
|
68
|
+
`Surfaces:\n${surfaces.join("\n") || "- none"}`
|
|
69
|
+
].join("\n\n");
|
|
70
|
+
}
|
|
71
|
+
/** A description on one line, so its lines cannot read as new entries. */
|
|
72
|
+
function oneLine(text) {
|
|
73
|
+
return text.replace(/\s*\n\s*/g, " ");
|
|
74
|
+
}
|
|
75
|
+
/** Values that would read as a type or a number once their quotes are gone. */
|
|
76
|
+
const AMBIGUOUS_VALUE = /^(?:string|number|integer|boolean|true|false|null|object|array|unknown|any|-?\d[\d.]*)$/;
|
|
77
|
+
/**
|
|
78
|
+
* A compact type with bare enum values and tight unions:
|
|
79
|
+
* `"sm" | "md" | "lg"` becomes `sm|md|lg`. A union keeps its quotes when it
|
|
80
|
+
* also holds a type (`"sm" | number`) or a value that reads as a type or a
|
|
81
|
+
* number (`"number" | "currency"`, `"1" | "2"`), and so do values that are
|
|
82
|
+
* not plain words.
|
|
83
|
+
*/
|
|
84
|
+
function bareType(type) {
|
|
85
|
+
return type.replace(/"[A-Za-z0-9_#%.-]+"(?: \| "[A-Za-z0-9_#%.-]+")*(?! \|)/g, (union, offset, whole) => {
|
|
86
|
+
if (whole.slice(offset - 2, offset) === "| ") return union;
|
|
87
|
+
const values = union.split(" | ").map((v) => v.slice(1, -1));
|
|
88
|
+
if (values.some((v) => AMBIGUOUS_VALUE.test(v))) return union;
|
|
89
|
+
return values.join("|");
|
|
90
|
+
}).replace(/ \| /g, "|");
|
|
91
|
+
}
|
|
92
|
+
/** A compact prop (`type // description`) as `name: type - description`. */
|
|
93
|
+
function propLine(key, value) {
|
|
94
|
+
const name = key.endsWith("?") ? key.slice(0, -1) : `${key}*`;
|
|
95
|
+
const cut = value.indexOf(" // ");
|
|
96
|
+
const type = bareType(cut < 0 ? value : value.slice(0, cut));
|
|
97
|
+
const text = cut < 0 ? "" : value.slice(cut + 4).trim();
|
|
98
|
+
return ` ${name}: ${type}${text ? ` - ${oneLine(text)}` : ""}`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The whole schema as plain lines: a header line per component and one
|
|
102
|
+
* indented line per prop: events are `action` props and slots `componentId`
|
|
103
|
+
* or `childList` props. Props are optional unless marked `*`, enum values
|
|
104
|
+
* are bare, and the common props are listed once. It carries the same names, types and descriptions as
|
|
105
|
+
* `compact`, in fewer tokens.
|
|
106
|
+
*/
|
|
107
|
+
function linesSchema(manifest, settings) {
|
|
108
|
+
const compact = buildCompactGenerativeUISchema(manifest, {
|
|
109
|
+
propDescriptions: settings.propDescriptions,
|
|
110
|
+
commonProps: settings.commonProps
|
|
111
|
+
});
|
|
112
|
+
const targets = compact.targets.map((t) => {
|
|
113
|
+
const limit = t.components ? `, only ${t.components.join(", ")}` : "";
|
|
114
|
+
return `${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : ""}`;
|
|
115
|
+
}).join("; ");
|
|
116
|
+
const functions = Object.entries(compact.functions).map(([name, fn]) => `${nameWithParameters(name, fn.parameters)}${"callers" in fn ? ` (${fn.callers})` : ""}${fn.description ? `: ${oneLine(fn.description)}` : ""}`);
|
|
117
|
+
const common = compact.commonProps ? Object.entries(compact.commonProps).map(([k, v]) => propLine(k, v)) : [];
|
|
118
|
+
const components = Object.entries(compact.components).map(([name, c]) => ({
|
|
119
|
+
name,
|
|
120
|
+
c,
|
|
121
|
+
own: [...Object.entries(c.props).map(([k, v]) => propLine(k, v)), ...Object.entries(c.events ?? {}).map(([e, d]) => ` ${e}: action - ${oneLine(d)}`)]
|
|
122
|
+
})).flatMap(({ name, c, own }) => {
|
|
123
|
+
const lines = [`${name}${c.includesCommonProps ? " +common" : ""}${c.description ? `: ${oneLine(c.description)}` : ""}`, ...own];
|
|
124
|
+
for (const [slot, kind] of Object.entries(c.slots ?? {})) lines.push(` ${slot}: ${kind === "single" ? "componentId" : "childList"}`);
|
|
125
|
+
return lines;
|
|
126
|
+
});
|
|
127
|
+
const surfaces = Object.keys(compact.surfaces).length ? JSON.stringify(compact.surfaces) : "none";
|
|
128
|
+
return [
|
|
129
|
+
`Catalog ${compact.catalogId}. Targets: ${targets || "none"}`,
|
|
130
|
+
"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.",
|
|
131
|
+
`Functions:\n${functions.join("\n")}`,
|
|
132
|
+
...common.length ? [`Common props:\n${common.join("\n")}`] : [],
|
|
133
|
+
`Components:\n${components.join("\n")}`,
|
|
134
|
+
`Surfaces: ${surfaces}`
|
|
135
|
+
].join("\n\n");
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The component schema of the markdown transport, as the text of its
|
|
139
|
+
* context entry, in the notation of `settings`. `compact` is the schema that
|
|
140
|
+
* ships (`buildCompactGenerativeUISchema`), `json-schema` the manifest parts
|
|
141
|
+
* as JSON, `ts-signature` one line per component, `lines` one line per
|
|
142
|
+
* prop with bare enums (the fewest tokens).
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const value = renderGenerativeUISchema(manifest, spec.schema.markdown);
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
function renderGenerativeUISchema(manifest, settings) {
|
|
150
|
+
switch (settings.notation) {
|
|
151
|
+
case "compact": return JSON.stringify(buildCompactGenerativeUISchema(manifest, {
|
|
152
|
+
propDescriptions: settings.propDescriptions,
|
|
153
|
+
commonProps: settings.commonProps
|
|
154
|
+
}));
|
|
155
|
+
case "json-schema": {
|
|
156
|
+
const components = Object.fromEntries(Object.entries(manifest.components).map(([name, c]) => [name, settings.propDescriptions ? c : {
|
|
157
|
+
...c,
|
|
158
|
+
props: withoutPropDescriptions(c.props)
|
|
159
|
+
}]));
|
|
160
|
+
return JSON.stringify({
|
|
161
|
+
catalogId: manifest.catalogId,
|
|
162
|
+
targets: manifest.targets,
|
|
163
|
+
functions: manifest.functions,
|
|
164
|
+
components,
|
|
165
|
+
surfaces: manifest.surfaces
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
case "ts-signature": return signatureSchema(manifest, settings);
|
|
169
|
+
case "lines": return linesSchema(manifest, settings);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The component list of the tool guide, one entry per component, in the
|
|
174
|
+
* notation of `settings`. `json-schema` is the list that ships.
|
|
175
|
+
*/
|
|
176
|
+
function renderGenerativeUIComponentList(components, settings) {
|
|
177
|
+
return Object.entries(components).map(([name, c]) => {
|
|
178
|
+
if (settings.notation === "ts-signature" || settings.notation === "lines") return signatureLines(name, c, settings).join("\n");
|
|
179
|
+
const props = settings.notation === "compact" ? compactProps(c.props, settings.propDescriptions) : settings.propDescriptions ? c.props : withoutPropDescriptions(c.props);
|
|
180
|
+
const lines = [`- **${name}**${c.description ? `: ${oneLine(c.description)}` : ""}`, ` props: ${JSON.stringify(props)}`];
|
|
181
|
+
if (c.events) lines.push(` event props: ${JSON.stringify(c.events)}`);
|
|
182
|
+
if (c.slots) lines.push(` slot props (component ids): ${JSON.stringify(c.slots)}`);
|
|
183
|
+
return lines.join("\n");
|
|
184
|
+
}).join("\n");
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The manifest with replaced descriptions: `"Name"` replaces the
|
|
188
|
+
* description of a component, `"Name.prop"` the description of one of its
|
|
189
|
+
* props. Keys that name no component or prop are left out of the result
|
|
190
|
+
* and listed in `unknown`. The manifest is not changed.
|
|
191
|
+
*/
|
|
192
|
+
function applyDescriptionOverrides(manifest, overrides) {
|
|
193
|
+
const components = structuredClone(manifest.components);
|
|
194
|
+
const unknown = [];
|
|
195
|
+
for (const [key, description] of Object.entries(overrides)) {
|
|
196
|
+
const [name, prop, ...rest] = key.split(".");
|
|
197
|
+
const component = hasOwn(components, name) ? components[name] : void 0;
|
|
198
|
+
if (!component || rest.length > 0) {
|
|
199
|
+
unknown.push(key);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (prop === void 0) {
|
|
203
|
+
component.description = description;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const properties = component.props.properties;
|
|
207
|
+
const property = isRecord(properties) && hasOwn(properties, prop) ? properties[prop] : void 0;
|
|
208
|
+
if (!isRecord(property)) {
|
|
209
|
+
unknown.push(key);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
property.description = description;
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
manifest: {
|
|
216
|
+
...manifest,
|
|
217
|
+
components
|
|
218
|
+
},
|
|
219
|
+
unknown
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The components and props of `manifest` whose names do not appear in
|
|
224
|
+
* `rendered`. A schema notation that leaves one out would hide part of the
|
|
225
|
+
* catalog from the model.
|
|
226
|
+
*/
|
|
227
|
+
function schemaCoverage(manifest, rendered) {
|
|
228
|
+
const missing = [];
|
|
229
|
+
for (const [name, component] of Object.entries(manifest.components)) {
|
|
230
|
+
if (!rendered.includes(name)) missing.push(name);
|
|
231
|
+
const properties = isRecord(component.props.properties) ? component.props.properties : {};
|
|
232
|
+
for (const prop of Object.keys(properties)) if (!rendered.includes(prop)) missing.push(`${name}.${prop}`);
|
|
233
|
+
}
|
|
234
|
+
return { missing };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
//#endregion
|
|
238
|
+
export { applyDescriptionOverrides, renderGenerativeUIComponentList, renderGenerativeUISchema, schemaCoverage };
|
|
239
|
+
//# sourceMappingURL=schema-render.mjs.map
|
|
@@ -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 = hasOwn(components, name) ? components[name] : 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,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EAAE;AAC5B,MAAK,MAAM,CAAC,KAAK,gBAAgB,OAAO,QAAQ,UAAU,EAAE;EAC1D,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,IAAI,MAAM,IAAI;EAE5C,MAAM,YAAY,OAAO,YAAY,KAAK,GAAG,WAAW,QAAQ;AAChE,MAAI,CAAC,aAAa,KAAK,SAAS,GAAG;AACjC,WAAQ,KAAK,IAAI;AACjB;;AAEF,MAAI,SAAS,QAAW;AACtB,aAAU,cAAc;AACxB;;EAEF,MAAM,aAAa,UAAU,MAAM;EACnC,MAAM,WACJ,SAAS,WAAW,IAAI,OAAO,YAAY,KAAK,GAC5C,WAAW,QACX;AACN,MAAI,CAAC,SAAS,SAAS,EAAE;AACvB,WAAQ,KAAK,IAAI;AACjB;;AAEF,WAAS,cAAc;;AAEzB,QAAO;EAAE,UAAU;GAAE,GAAG;GAAU;GAAY;EAAE;EAAS;;;;;;;AAQ3D,SAAgB,eACd,UACA,UACuB;CACvB,MAAM,UAAoB,EAAE;AAC5B,MAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,SAAS,WAAW,EAAE;AACnE,MAAI,CAAC,SAAS,SAAS,KAAK,CAAE,SAAQ,KAAK,KAAK;EAChD,MAAM,aAAa,SAAS,UAAU,MAAM,WAAW,GACnD,UAAU,MAAM,aAChB,EAAE;AACN,OAAK,MAAM,QAAQ,OAAO,KAAK,WAAW,CACxC,KAAI,CAAC,SAAS,SAAS,KAAK,CAAE,SAAQ,KAAK,GAAG,KAAK,GAAG,OAAO;;AAGjE,QAAO,EAAE,SAAS"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_clipboard = require('./utils/clipboard.cjs');
|
|
3
|
-
const require_conditions = require('./utils/conditions.cjs');
|
|
4
|
-
const require_console_styling = require('./utils/console-styling.cjs');
|
|
5
3
|
const require_errors = require('./utils/errors.cjs');
|
|
6
4
|
const require_json_schema = require('./utils/json-schema.cjs');
|
|
7
5
|
const require_inspector_metadata = require('./utils/inspector-metadata.cjs');
|
|
@@ -9,6 +7,7 @@ const require_inspector_learning = require('./utils/inspector-learning.cjs');
|
|
|
9
7
|
const require_inspector_visibility = require('./utils/inspector-visibility.cjs');
|
|
10
8
|
const require_types = require('./utils/types.cjs');
|
|
11
9
|
const require_random_id = require('./utils/random-id.cjs');
|
|
10
|
+
const require_process_env = require('./utils/process-env.cjs');
|
|
12
11
|
const require_requests = require('./utils/requests.cjs');
|
|
13
12
|
const require_row_render_keys = require('./utils/row-render-keys.cjs');
|
|
14
13
|
const require_index = require('./utils/index.cjs');
|
|
@@ -29,11 +28,14 @@ const require_package = require('./package.cjs');
|
|
|
29
28
|
const require_basic_functions = require('./generative-ui/basic-functions.cjs');
|
|
30
29
|
const require_child_refs = require('./generative-ui/child-refs.cjs');
|
|
31
30
|
const require_types$1 = require('./generative-ui/types.cjs');
|
|
31
|
+
const require_prompt_spec = require('./generative-ui/prompt-spec.cjs');
|
|
32
32
|
const require_a2ui_prompts = require('./a2ui-prompts.cjs');
|
|
33
33
|
const require_a2ui_envelope = require('./a2ui-envelope.cjs');
|
|
34
34
|
const require_open_generative_ui_prompts = require('./open-generative-ui-prompts.cjs');
|
|
35
35
|
const require_validate_operation = require('./generative-ui/validate-operation.cjs');
|
|
36
36
|
const require_render_ui_args = require('./generative-ui/render-ui-args.cjs');
|
|
37
|
+
const require_compact_schema = require('./generative-ui/compact-schema.cjs');
|
|
38
|
+
const require_schema_render = require('./generative-ui/schema-render.cjs');
|
|
37
39
|
const require_prompt = require('./generative-ui/prompt.cjs');
|
|
38
40
|
|
|
39
41
|
//#region src/index.ts
|
|
@@ -99,8 +101,6 @@ exports.COPILOT_CLOUD_ERROR_NAMES = require_errors.COPILOT_CLOUD_ERROR_NAMES;
|
|
|
99
101
|
exports.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = require_index$1.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER;
|
|
100
102
|
exports.COPILOT_CLOUD_VERSION = require_index$1.COPILOT_CLOUD_VERSION;
|
|
101
103
|
exports.ConfigurationError = require_errors.ConfigurationError;
|
|
102
|
-
exports.ConsoleColors = require_console_styling.ConsoleColors;
|
|
103
|
-
exports.ConsoleStyles = require_console_styling.ConsoleStyles;
|
|
104
104
|
exports.CopilotKitAgentDiscoveryError = require_errors.CopilotKitAgentDiscoveryError;
|
|
105
105
|
exports.CopilotKitApiDiscoveryError = require_errors.CopilotKitApiDiscoveryError;
|
|
106
106
|
exports.CopilotKitError = require_errors.CopilotKitError;
|
|
@@ -108,7 +108,6 @@ exports.CopilotKitErrorCode = require_errors.CopilotKitErrorCode;
|
|
|
108
108
|
exports.CopilotKitLowLevelError = require_errors.CopilotKitLowLevelError;
|
|
109
109
|
exports.CopilotKitMisuseError = require_errors.CopilotKitMisuseError;
|
|
110
110
|
exports.CopilotKitRemoteEndpointDiscoveryError = require_errors.CopilotKitRemoteEndpointDiscoveryError;
|
|
111
|
-
exports.CopilotKitVersionMismatchError = require_errors.CopilotKitVersionMismatchError;
|
|
112
111
|
exports.DEFAULT_AGENT_ID = require_index$1.DEFAULT_AGENT_ID;
|
|
113
112
|
exports.ERROR_CONFIG = require_errors.ERROR_CONFIG;
|
|
114
113
|
exports.ERROR_NAMES = require_errors.ERROR_NAMES;
|
|
@@ -125,11 +124,14 @@ exports.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE = require_types$1.GENERATIVE_U
|
|
|
125
124
|
exports.GENERATIVE_UI_MARKDOWN_GUIDELINES = require_a2ui_prompts.GENERATIVE_UI_MARKDOWN_GUIDELINES;
|
|
126
125
|
exports.GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION = require_a2ui_prompts.GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION;
|
|
127
126
|
exports.GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION = require_a2ui_prompts.GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION;
|
|
127
|
+
exports.GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW = require_prompt_spec.GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW;
|
|
128
128
|
exports.GENERATIVE_UI_MAX_REJECTION_LENGTH = require_types$1.GENERATIVE_UI_MAX_REJECTION_LENGTH;
|
|
129
129
|
exports.GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = require_types$1.GENERATIVE_UI_MAX_SUMMARY_REJECTIONS;
|
|
130
130
|
exports.GENERATIVE_UI_MAX_TARGET_COMPONENTS = require_types$1.GENERATIVE_UI_MAX_TARGET_COMPONENTS;
|
|
131
131
|
exports.GENERATIVE_UI_RENDER_TOOL = require_types$1.GENERATIVE_UI_RENDER_TOOL;
|
|
132
132
|
exports.GENERATIVE_UI_ROOT_ID = require_types$1.GENERATIVE_UI_ROOT_ID;
|
|
133
|
+
exports.GENERATIVE_UI_WHEN_TO_SHOW = require_prompt_spec.GENERATIVE_UI_WHEN_TO_SHOW;
|
|
134
|
+
exports.GUIDE_COMPONENTS = require_prompt_spec.GUIDE_COMPONENTS;
|
|
133
135
|
exports.MODEL_HOST_CLASSES = require_model_host.MODEL_HOST_CLASSES;
|
|
134
136
|
exports.MissingPublicApiKeyError = require_errors.MissingPublicApiKeyError;
|
|
135
137
|
exports.RUNTIME_MODE_INTELLIGENCE = require_types.RUNTIME_MODE_INTELLIGENCE;
|
|
@@ -148,6 +150,8 @@ exports.UNSAMPLED_RATE = require_sampling.UNSAMPLED_RATE;
|
|
|
148
150
|
exports.UpgradeRequiredError = require_errors.UpgradeRequiredError;
|
|
149
151
|
exports.actionParametersToJsonSchema = require_json_schema.actionParametersToJsonSchema;
|
|
150
152
|
exports.applyChildRefMarks = require_child_refs.applyChildRefMarks;
|
|
153
|
+
exports.applyDescriptionOverrides = require_schema_render.applyDescriptionOverrides;
|
|
154
|
+
exports.buildCompactGenerativeUISchema = require_compact_schema.buildCompactGenerativeUISchema;
|
|
151
155
|
exports.buildGenerativeUIMarkdownGuidelines = require_a2ui_prompts.buildGenerativeUIMarkdownGuidelines;
|
|
152
156
|
exports.buildGenerativeUIPrompt = require_prompt.buildGenerativeUIPrompt;
|
|
153
157
|
exports.callerProblem = require_validate_operation.callerProblem;
|
|
@@ -157,17 +161,15 @@ exports.classifyModelHost = require_model_host.classifyModelHost;
|
|
|
157
161
|
exports.collectChildRefs = require_child_refs.collectChildRefs;
|
|
158
162
|
exports.commitRowKeyStore = require_row_render_keys.commitRowKeyStore;
|
|
159
163
|
exports.computeSamplingMeta = require_sampling.computeSamplingMeta;
|
|
160
|
-
exports.convertJsonSchemaToZodSchema = require_json_schema.convertJsonSchemaToZodSchema;
|
|
161
164
|
exports.copyToClipboard = require_clipboard.copyToClipboard;
|
|
162
165
|
exports.createAttachmentContent = require_content.createAttachmentContent;
|
|
163
166
|
exports.createLicenseContextValue = createLicenseContextValue;
|
|
164
167
|
exports.createRowKeyStore = require_row_render_keys.createRowKeyStore;
|
|
165
168
|
exports.createRunEventFinalizer = require_finalize_events.createRunEventFinalizer;
|
|
166
|
-
exports.
|
|
169
|
+
exports.defaultGenerativeUIPromptSpec = require_prompt_spec.defaultGenerativeUIPromptSpec;
|
|
167
170
|
exports.ensureStructuredError = require_errors.ensureStructuredError;
|
|
168
171
|
exports.envelopeToManifest = require_a2ui_envelope.envelopeToManifest;
|
|
169
172
|
exports.exceedsMaxSize = require_utils.exceedsMaxSize;
|
|
170
|
-
exports.executeConditions = require_conditions.executeConditions;
|
|
171
173
|
exports.extractRenderUIArgs = require_render_ui_args.extractRenderUIArgs;
|
|
172
174
|
exports.finalizeRunEvents = require_finalize_events.finalizeRunEvents;
|
|
173
175
|
exports.firstNonBlankTelemetryId = require_lambda_client.firstNonBlankTelemetryId;
|
|
@@ -176,14 +178,13 @@ exports.functionCallers = require_basic_functions.functionCallers;
|
|
|
176
178
|
exports.generateVideoThumbnail = require_utils.generateVideoThumbnail;
|
|
177
179
|
exports.generativeUIFunctionCallMessageId = require_types$1.generativeUIFunctionCallMessageId;
|
|
178
180
|
exports.generativeUIGuideFeatures = require_a2ui_prompts.generativeUIGuideFeatures;
|
|
181
|
+
exports.generativeUIPromptFeatures = require_prompt_spec.generativeUIPromptFeatures;
|
|
179
182
|
exports.generativeUISurfaceMessageId = require_types$1.generativeUISurfaceMessageId;
|
|
180
183
|
exports.getDocumentIcon = require_utils.getDocumentIcon;
|
|
181
184
|
exports.getModalityFromMimeType = require_utils.getModalityFromMimeType;
|
|
182
185
|
exports.getOperationKind = require_validate_operation.getOperationKind;
|
|
183
186
|
exports.getOperationSurfaceId = require_validate_operation.getOperationSurfaceId;
|
|
184
|
-
exports.getPossibleVersionMismatch = require_errors.getPossibleVersionMismatch;
|
|
185
187
|
exports.getSourceUrl = require_utils.getSourceUrl;
|
|
186
|
-
exports.getZodParameters = require_json_schema.getZodParameters;
|
|
187
188
|
exports.hasBoundChildRef = require_child_refs.hasBoundChildRef;
|
|
188
189
|
exports.isA2UIBasicFunction = require_basic_functions.isA2UIBasicFunction;
|
|
189
190
|
exports.isA2UIValueFunction = require_basic_functions.isA2UIValueFunction;
|
|
@@ -194,12 +195,9 @@ exports.isMacOS = require_index.isMacOS;
|
|
|
194
195
|
exports.isPathBinding = require_validate_operation.isPathBinding;
|
|
195
196
|
exports.isStructuredCopilotKitError = require_errors.isStructuredCopilotKitError;
|
|
196
197
|
exports.isTelemetryDisabled = require_telemetry_disabled.isTelemetryDisabled;
|
|
197
|
-
exports.isValidUUID = require_random_id.isValidUUID;
|
|
198
198
|
exports.isValidationResult = require_basic_functions.isValidationResult;
|
|
199
199
|
exports.jsonSchemaToActionParameters = require_json_schema.jsonSchemaToActionParameters;
|
|
200
200
|
exports.lambdaClient = require_lambda_client.lambdaClient;
|
|
201
|
-
exports.logCopilotKitPlatformMessage = require_console_styling.logCopilotKitPlatformMessage;
|
|
202
|
-
exports.logStyled = require_console_styling.logStyled;
|
|
203
201
|
exports.logger = require_logger.logger;
|
|
204
202
|
exports.mapAtChildRef = require_child_refs.mapAtChildRef;
|
|
205
203
|
exports.matchesAcceptFilter = require_utils.matchesAcceptFilter;
|
|
@@ -212,22 +210,26 @@ exports.parseJson = require_index.parseJson;
|
|
|
212
210
|
exports.parseTelemetryIdFromLicense = require_lambda_client.parseTelemetryIdFromLicense;
|
|
213
211
|
exports.partialJSONParse = require_index.partialJSONParse;
|
|
214
212
|
exports.phoenixExponentialBackoff = require_index.phoenixExponentialBackoff;
|
|
213
|
+
exports.processEnv = require_process_env.processEnv;
|
|
215
214
|
exports.pruneRowKeyStore = require_row_render_keys.pruneRowKeyStore;
|
|
216
|
-
exports.publicApiKeyRequired = require_console_styling.publicApiKeyRequired;
|
|
217
215
|
exports.randomId = require_random_id.randomId;
|
|
218
216
|
exports.randomUUID = require_random_id.randomUUID;
|
|
219
217
|
exports.readBody = require_requests.readBody;
|
|
220
218
|
exports.readCopilotKitUIEnvelope = require_a2ui_envelope.readCopilotKitUIEnvelope;
|
|
221
219
|
exports.readFileAsBase64 = require_utils.readFileAsBase64;
|
|
220
|
+
exports.renderGenerativeUIComponentList = require_schema_render.renderGenerativeUIComponentList;
|
|
221
|
+
exports.renderGenerativeUISchema = require_schema_render.renderGenerativeUISchema;
|
|
222
222
|
exports.resolveDebugConfig = require_debug.resolveDebugConfig;
|
|
223
223
|
exports.resolveRowRenderKeys = require_row_render_keys.resolveRowRenderKeys;
|
|
224
224
|
exports.resolveRowRenderKeysById = require_row_render_keys.resolveRowRenderKeysById;
|
|
225
225
|
exports.safeParseToolArgs = require_index.safeParseToolArgs;
|
|
226
|
+
exports.schemaCoverage = require_schema_render.schemaCoverage;
|
|
226
227
|
exports.schemaToJsonSchema = require_standard_schema.schemaToJsonSchema;
|
|
228
|
+
exports.selectPromptItems = require_prompt_spec.selectPromptItems;
|
|
227
229
|
exports.shouldEnableInspector = require_inspector_visibility.shouldEnableInspector;
|
|
228
230
|
exports.stripIntelligenceRoutingFields = require_intelligence_routing_fields.stripIntelligenceRoutingFields;
|
|
229
|
-
exports.styledConsole = require_console_styling.styledConsole;
|
|
230
231
|
exports.toA2UIActionMessage = require_types$1.toA2UIActionMessage;
|
|
231
232
|
exports.tryMap = require_index.tryMap;
|
|
232
233
|
exports.validateOperation = require_validate_operation.validateOperation;
|
|
234
|
+
exports.ɵanySchema = require_standard_schema.ɵanySchema;
|
|
233
235
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\n//
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\n// Only browser-safe telemetry helpers live here. The runtime owns its\n// telemetry client (`packages/runtime/src/runtime/telemetry`), so this package\n// imports no Node-only analytics SDK (#4151).\nexport { isTelemetryDisabled } from \"./telemetry/telemetry-disabled\";\nexport * from \"./telemetry/sampling\";\n// Pure string classification with no imports, so it carries no runtime edge\n// into browser builds — same reasoning as `sampling` above.\nexport * from \"./telemetry/model-host\";\nexport {\n firstNonBlankTelemetryId,\n lambdaClient,\n parseTelemetryIdFromLicense,\n parseAndWarnTelemetryId,\n} from \"./telemetry/lambda-client\";\nexport type { LambdaSendOptions } from \"./telemetry/lambda-client\";\nexport * from \"./debug\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport {\n createRunEventFinalizer,\n finalizeRunEvents,\n type FinalizeRunOptions,\n type RunEventFinalizer,\n} from \"./finalize-events\";\nexport { stripIntelligenceRoutingFields } from \"./intelligence-routing-fields\";\n\nexport {\n TranscriptionErrorCode,\n TranscriptionErrors,\n type TranscriptionErrorResponse,\n} from \"./transcription-errors\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n\n// Re-export only types from license-verifier (types are erased at compile time,\n// so they don't pull in the Node-only `crypto` dependency into client bundles).\n// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions\n// like createLicenseChecker and getLicenseWarningHeader directly from\n// @copilotkit/license-verifier.\nexport type {\n LicenseChecker,\n LicenseStatus,\n LicensePayload,\n LicenseFeatures,\n LicenseTier,\n LicenseOwner,\n} from \"@copilotkit/license-verifier\";\n\nimport type { LicensePayload } from \"@copilotkit/license-verifier\";\nimport type {\n RuntimeEntitlementResponse,\n RuntimeLicenseStatus,\n} from \"./utils/types\";\n\n// LicenseContextValue was dropped from license-verifier's public API in\n// 0.3.0, so it is defined here. The context shape is owned by this package\n// anyway via createLicenseContextValue below.\n\n/**\n * License context value exposed to child components.\n * Frontend providers create their own context using this shape.\n */\nexport interface LicenseContextValue {\n /** Effective license status after structured entitlement precedence. Null until known. */\n status: RuntimeLicenseStatus | null;\n /** The license payload if available. Always null on the client; the payload stays server-side. */\n license: LicensePayload | null;\n /** Whether a feature is licensed. Ready entitlements override legacy status behavior. */\n checkFeature: (feature: string) => boolean;\n /** Get a numeric feature limit. Zero means unlimited; null means not applicable. */\n getLimit: (feature: string) => number | null;\n}\n\n/** Read a record value without traversing its prototype chain. */\nfunction getOwnRecordValue<Value>(\n record: Readonly<Record<string, Value>>,\n key: string,\n): Value | undefined {\n return Object.prototype.hasOwnProperty.call(record, key)\n ? record[key]\n : undefined;\n}\n\n/** Legacy UI surfaces that remain available for every active entitlement. */\nfunction isLegacyUiFeature(feature: string): boolean {\n return feature === \"chat\" || feature === \"popup\" || feature === \"sidebar\";\n}\n\n/**\n * Client-safe license context factory, driven by the license authority the\n * runtime reports via /info.\n *\n * A ready managed entitlement is authoritative in both directions. A ready\n * active self-hosted entitlement is also authoritative, while an inactive\n * self-hosted response preserves the legacy signed-license fallback. Active\n * entitlements supply feature grants and limits; authoritative inactive\n * entitlements deny every feature and limit. Older runtimes that report only a\n * status retain the legacy behavior: features are enabled unless the status is\n * \"expired\" or \"invalid\", and no limits are reported. This is inlined here to\n * avoid importing the full license-verifier bundle (which depends on Node's\n * `crypto`) into browser bundles.\n */\nexport function createLicenseContextValue(\n status: RuntimeLicenseStatus | null | undefined,\n runtimeEntitlements?: RuntimeEntitlementResponse,\n): LicenseContextValue {\n const readyEntitlement =\n runtimeEntitlements?.status === \"ready\"\n ? runtimeEntitlements.entitlement\n : null;\n const hasUsableSelfHostedLegacyFallback =\n readyEntitlement &&\n !readyEntitlement.active &&\n readyEntitlement.source === \"selfHostedDeploymentLicense\" &&\n (status === \"valid\" || status === \"expiring\");\n const featureAuthority =\n readyEntitlement && !hasUsableSelfHostedLegacyFallback\n ? readyEntitlement\n : null;\n const activeEntitlement = featureAuthority?.active ? featureAuthority : null;\n const resolvedStatus = activeEntitlement\n ? \"valid\"\n : readyEntitlement?.source === \"managedOrgSubscription\" ||\n readyEntitlement?.source === \"awsMarketplaceDeploymentLicense\"\n ? \"none\"\n : featureAuthority\n ? (status ?? \"none\")\n : (status ?? null);\n const featuresEnabled =\n resolvedStatus !== \"expired\" && resolvedStatus !== \"invalid\";\n\n return {\n status: resolvedStatus,\n license: null,\n checkFeature: (feature) =>\n featureAuthority\n ? activeEntitlement\n ? feature === \"threads\" &&\n Object.prototype.hasOwnProperty.call(\n activeEntitlement.limits,\n \"threads.max_count\",\n )\n ? true\n : (getOwnRecordValue(activeEntitlement.features, feature) ??\n isLegacyUiFeature(feature))\n : false\n : featuresEnabled,\n getLimit: (feature) =>\n activeEntitlement\n ? (getOwnRecordValue(activeEntitlement.limits, feature) ?? null)\n : null,\n };\n}\n\nexport {\n A2UI_DEFAULT_GENERATION_GUIDELINES,\n A2UI_DEFAULT_DESIGN_GUIDELINES,\n ALL_GENERATIVE_UI_GUIDE_FEATURES,\n buildGenerativeUIMarkdownGuidelines,\n generativeUIGuideFeatures,\n GENERATIVE_UI_MARKDOWN_GUIDELINES,\n GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION,\n GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION,\n} from \"./a2ui-prompts\";\nexport type { GenerativeUIGuideFeatures } from \"./a2ui-prompts\";\nexport {\n COPILOTKIT_FORWARDED_PROPS_KEY,\n COPILOTKIT_UI_ENVELOPE_FORMAT,\n envelopeToManifest,\n readCopilotKitUIEnvelope,\n} from \"./a2ui-envelope\";\nexport type { CopilotKitUIEnvelope } from \"./a2ui-envelope\";\n\nexport type { DebugEventEnvelope } from \"./debug-event-envelope\";\n\nexport { GENERATE_SANDBOXED_UI_DESCRIPTION } from \"./open-generative-ui-prompts\";\nexport * from \"./generative-ui\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa;;AA0Cb,SAAS,kBACP,QACA,KACmB;AACnB,QAAO,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI,GACpD,OAAO,OACP;;;AAIN,SAAS,kBAAkB,SAA0B;AACnD,QAAO,YAAY,UAAU,YAAY,WAAW,YAAY;;;;;;;;;;;;;;;;AAiBlE,SAAgB,0BACd,QACA,qBACqB;CACrB,MAAM,mBACJ,qBAAqB,WAAW,UAC5B,oBAAoB,cACpB;CACN,MAAM,oCACJ,oBACA,CAAC,iBAAiB,UAClB,iBAAiB,WAAW,kCAC3B,WAAW,WAAW,WAAW;CACpC,MAAM,mBACJ,oBAAoB,CAAC,oCACjB,mBACA;CACN,MAAM,oBAAoB,kBAAkB,SAAS,mBAAmB;CACxE,MAAM,iBAAiB,oBACnB,UACA,kBAAkB,WAAW,4BAC3B,kBAAkB,WAAW,oCAC7B,SACA,mBACG,UAAU,SACV,UAAU;CACnB,MAAM,kBACJ,mBAAmB,aAAa,mBAAmB;AAErD,QAAO;EACL,QAAQ;EACR,SAAS;EACT,eAAe,YACb,mBACI,oBACE,YAAY,aACZ,OAAO,UAAU,eAAe,KAC9B,kBAAkB,QAClB,oBACD,GACC,OACC,kBAAkB,kBAAkB,UAAU,QAAQ,IACvD,kBAAkB,QAAQ,GAC5B,QACF;EACN,WAAW,YACT,oBACK,kBAAkB,kBAAkB,QAAQ,QAAQ,IAAI,OACzD;EACP"}
|