@copilotkit/shared 2.0.0-rc.4 → 2.0.0-rc.40
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 +4 -15
- 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/attachments/utils.cjs +16 -5
- package/dist/attachments/utils.cjs.map +1 -1
- package/dist/attachments/utils.d.cts +3 -1
- package/dist/attachments/utils.d.cts.map +1 -1
- package/dist/attachments/utils.d.mts +3 -1
- package/dist/attachments/utils.d.mts.map +1 -1
- package/dist/attachments/utils.mjs +16 -5
- package/dist/attachments/utils.mjs.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/catalog/catalog-export.cjs +329 -0
- package/dist/generative-ui/catalog/catalog-export.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.mjs +328 -0
- package/dist/generative-ui/catalog/catalog-export.mjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.cjs +315 -0
- package/dist/generative-ui/catalog/catalog.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.cts +407 -0
- package/dist/generative-ui/catalog/catalog.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.mts +407 -0
- package/dist/generative-ui/catalog/catalog.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog.mjs +312 -0
- package/dist/generative-ui/catalog/catalog.mjs.map +1 -0
- package/dist/generative-ui/catalog/errors.cjs +13 -0
- package/dist/generative-ui/catalog/errors.cjs.map +1 -0
- package/dist/generative-ui/catalog/errors.d.cts +46 -0
- package/dist/generative-ui/catalog/errors.d.cts.map +1 -0
- package/dist/generative-ui/catalog/errors.d.mts +46 -0
- package/dist/generative-ui/catalog/errors.d.mts.map +1 -0
- package/dist/generative-ui/catalog/errors.mjs +12 -0
- package/dist/generative-ui/catalog/errors.mjs.map +1 -0
- package/dist/generative-ui/catalog/index.d.mts +6 -0
- package/dist/generative-ui/catalog/json-schema.cjs +16 -0
- package/dist/generative-ui/catalog/json-schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.cts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.mts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.mjs +16 -0
- package/dist/generative-ui/catalog/json-schema.mjs.map +1 -0
- package/dist/generative-ui/catalog/refs.cjs +21 -0
- package/dist/generative-ui/catalog/refs.cjs.map +1 -0
- package/dist/generative-ui/catalog/refs.d.cts +55 -0
- package/dist/generative-ui/catalog/refs.d.cts.map +1 -0
- package/dist/generative-ui/catalog/refs.d.mts +55 -0
- package/dist/generative-ui/catalog/refs.d.mts.map +1 -0
- package/dist/generative-ui/catalog/refs.mjs +18 -0
- package/dist/generative-ui/catalog/refs.mjs.map +1 -0
- package/dist/generative-ui/catalog/schema.cjs +74 -0
- package/dist/generative-ui/catalog/schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/schema.d.cts +43 -0
- package/dist/generative-ui/catalog/schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/schema.d.mts +43 -0
- package/dist/generative-ui/catalog/schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/schema.mjs +68 -0
- package/dist/generative-ui/catalog/schema.mjs.map +1 -0
- 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/clone-value.cjs +364 -0
- package/dist/generative-ui/clone-value.cjs.map +1 -0
- package/dist/generative-ui/clone-value.d.cts +51 -0
- package/dist/generative-ui/clone-value.d.cts.map +1 -0
- package/dist/generative-ui/clone-value.d.mts +51 -0
- package/dist/generative-ui/clone-value.d.mts.map +1 -0
- package/dist/generative-ui/clone-value.mjs +363 -0
- package/dist/generative-ui/clone-value.mjs.map +1 -0
- 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/index.cjs +286 -0
- package/dist/generative-ui/index.d.cts +39 -0
- package/dist/generative-ui/index.d.mts +41 -0
- package/dist/generative-ui/index.mjs +40 -0
- package/dist/generative-ui/is-record.cjs +6 -1
- package/dist/generative-ui/is-record.cjs.map +1 -1
- package/dist/generative-ui/is-record.d.cts +8 -0
- package/dist/generative-ui/is-record.d.cts.map +1 -0
- package/dist/generative-ui/is-record.d.mts +8 -0
- package/dist/generative-ui/is-record.d.mts.map +1 -0
- package/dist/generative-ui/is-record.mjs +6 -2
- package/dist/generative-ui/is-record.mjs.map +1 -1
- 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 +243 -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 +240 -0
- package/dist/generative-ui/schema-render.mjs.map +1 -0
- package/dist/generative-ui/standard/chart-config.cjs +347 -0
- package/dist/generative-ui/standard/chart-config.cjs.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.cts +97 -0
- package/dist/generative-ui/standard/chart-config.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.mts +97 -0
- package/dist/generative-ui/standard/chart-config.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart-config.mjs +342 -0
- package/dist/generative-ui/standard/chart-config.mjs.map +1 -0
- package/dist/generative-ui/standard/chart.cjs +56 -0
- package/dist/generative-ui/standard/chart.cjs.map +1 -0
- package/dist/generative-ui/standard/chart.d.cts +62 -0
- package/dist/generative-ui/standard/chart.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart.d.mts +62 -0
- package/dist/generative-ui/standard/chart.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart.mjs +54 -0
- package/dist/generative-ui/standard/chart.mjs.map +1 -0
- package/dist/generative-ui/standard/checks.cjs +74 -0
- package/dist/generative-ui/standard/checks.cjs.map +1 -0
- package/dist/generative-ui/standard/checks.d.cts +56 -0
- package/dist/generative-ui/standard/checks.d.cts.map +1 -0
- package/dist/generative-ui/standard/checks.d.mts +56 -0
- package/dist/generative-ui/standard/checks.d.mts.map +1 -0
- package/dist/generative-ui/standard/checks.mjs +71 -0
- package/dist/generative-ui/standard/checks.mjs.map +1 -0
- package/dist/generative-ui/standard/components.cjs +23 -0
- package/dist/generative-ui/standard/components.cjs.map +1 -0
- package/dist/generative-ui/standard/components.d.cts +24 -0
- package/dist/generative-ui/standard/components.d.cts.map +1 -0
- package/dist/generative-ui/standard/components.d.mts +24 -0
- package/dist/generative-ui/standard/components.d.mts.map +1 -0
- package/dist/generative-ui/standard/components.mjs +22 -0
- package/dist/generative-ui/standard/components.mjs.map +1 -0
- package/dist/generative-ui/standard/composites.cjs +143 -0
- package/dist/generative-ui/standard/composites.cjs.map +1 -0
- package/dist/generative-ui/standard/composites.d.cts +233 -0
- package/dist/generative-ui/standard/composites.d.cts.map +1 -0
- package/dist/generative-ui/standard/composites.d.mts +233 -0
- package/dist/generative-ui/standard/composites.d.mts.map +1 -0
- package/dist/generative-ui/standard/composites.mjs +132 -0
- package/dist/generative-ui/standard/composites.mjs.map +1 -0
- package/dist/generative-ui/standard/data.cjs +176 -0
- package/dist/generative-ui/standard/data.cjs.map +1 -0
- package/dist/generative-ui/standard/data.d.cts +365 -0
- package/dist/generative-ui/standard/data.d.cts.map +1 -0
- package/dist/generative-ui/standard/data.d.mts +365 -0
- package/dist/generative-ui/standard/data.d.mts.map +1 -0
- package/dist/generative-ui/standard/data.mjs +167 -0
- package/dist/generative-ui/standard/data.mjs.map +1 -0
- package/dist/generative-ui/standard/declarations.cjs +40 -0
- package/dist/generative-ui/standard/declarations.cjs.map +1 -0
- package/dist/generative-ui/standard/declarations.d.cts +2570 -0
- package/dist/generative-ui/standard/declarations.d.cts.map +1 -0
- package/dist/generative-ui/standard/declarations.d.mts +2571 -0
- package/dist/generative-ui/standard/declarations.d.mts.map +1 -0
- package/dist/generative-ui/standard/declarations.mjs +39 -0
- package/dist/generative-ui/standard/declarations.mjs.map +1 -0
- package/dist/generative-ui/standard/feedback.cjs +97 -0
- package/dist/generative-ui/standard/feedback.cjs.map +1 -0
- package/dist/generative-ui/standard/feedback.d.cts +133 -0
- package/dist/generative-ui/standard/feedback.d.cts.map +1 -0
- package/dist/generative-ui/standard/feedback.d.mts +133 -0
- package/dist/generative-ui/standard/feedback.d.mts.map +1 -0
- package/dist/generative-ui/standard/feedback.mjs +90 -0
- package/dist/generative-ui/standard/feedback.mjs.map +1 -0
- package/dist/generative-ui/standard/index.d.mts +20 -0
- package/dist/generative-ui/standard/inputs.cjs +333 -0
- package/dist/generative-ui/standard/inputs.cjs.map +1 -0
- package/dist/generative-ui/standard/inputs.d.cts +1128 -0
- package/dist/generative-ui/standard/inputs.d.cts.map +1 -0
- package/dist/generative-ui/standard/inputs.d.mts +1128 -0
- package/dist/generative-ui/standard/inputs.d.mts.map +1 -0
- package/dist/generative-ui/standard/inputs.mjs +318 -0
- package/dist/generative-ui/standard/inputs.mjs.map +1 -0
- package/dist/generative-ui/standard/layout.cjs +289 -0
- package/dist/generative-ui/standard/layout.cjs.map +1 -0
- package/dist/generative-ui/standard/layout.d.cts +1974 -0
- package/dist/generative-ui/standard/layout.d.cts.map +1 -0
- package/dist/generative-ui/standard/layout.d.mts +1975 -0
- package/dist/generative-ui/standard/layout.d.mts.map +1 -0
- package/dist/generative-ui/standard/layout.mjs +269 -0
- package/dist/generative-ui/standard/layout.mjs.map +1 -0
- package/dist/generative-ui/standard/map-helpers.cjs +104 -0
- package/dist/generative-ui/standard/map-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.cts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.mts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.mjs +95 -0
- package/dist/generative-ui/standard/map-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/map.cjs +27 -0
- package/dist/generative-ui/standard/map.cjs.map +1 -0
- package/dist/generative-ui/standard/map.d.cts +31 -0
- package/dist/generative-ui/standard/map.d.cts.map +1 -0
- package/dist/generative-ui/standard/map.d.mts +31 -0
- package/dist/generative-ui/standard/map.d.mts.map +1 -0
- package/dist/generative-ui/standard/map.mjs +25 -0
- package/dist/generative-ui/standard/map.mjs.map +1 -0
- package/dist/generative-ui/standard/media.cjs +215 -0
- package/dist/generative-ui/standard/media.cjs.map +1 -0
- package/dist/generative-ui/standard/media.d.cts +396 -0
- package/dist/generative-ui/standard/media.d.cts.map +1 -0
- package/dist/generative-ui/standard/media.d.mts +396 -0
- package/dist/generative-ui/standard/media.d.mts.map +1 -0
- package/dist/generative-ui/standard/media.mjs +205 -0
- package/dist/generative-ui/standard/media.mjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.cjs +231 -0
- package/dist/generative-ui/standard/parameter-order.cjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.cts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.cts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.mts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.mts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.mjs +230 -0
- package/dist/generative-ui/standard/parameter-order.mjs.map +1 -0
- package/dist/generative-ui/standard/style-helpers.cjs +151 -0
- package/dist/generative-ui/standard/style-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.cts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.mts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.mjs +142 -0
- package/dist/generative-ui/standard/style-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/styles.cjs +62 -0
- package/dist/generative-ui/standard/styles.cjs.map +1 -0
- package/dist/generative-ui/standard/styles.d.cts +17 -0
- package/dist/generative-ui/standard/styles.d.cts.map +1 -0
- package/dist/generative-ui/standard/styles.d.mts +17 -0
- package/dist/generative-ui/standard/styles.d.mts.map +1 -0
- package/dist/generative-ui/standard/styles.mjs +60 -0
- package/dist/generative-ui/standard/styles.mjs.map +1 -0
- package/dist/generative-ui/standard/text.cjs +226 -0
- package/dist/generative-ui/standard/text.cjs.map +1 -0
- package/dist/generative-ui/standard/text.d.cts +522 -0
- package/dist/generative-ui/standard/text.d.cts.map +1 -0
- package/dist/generative-ui/standard/text.d.mts +522 -0
- package/dist/generative-ui/standard/text.d.mts.map +1 -0
- package/dist/generative-ui/standard/text.mjs +209 -0
- package/dist/generative-ui/standard/text.mjs.map +1 -0
- package/dist/generative-ui/standard/theme.cjs +115 -0
- package/dist/generative-ui/standard/theme.cjs.map +1 -0
- package/dist/generative-ui/standard/theme.d.cts +60 -0
- package/dist/generative-ui/standard/theme.d.cts.map +1 -0
- package/dist/generative-ui/standard/theme.d.mts +60 -0
- package/dist/generative-ui/standard/theme.d.mts.map +1 -0
- package/dist/generative-ui/standard/theme.mjs +112 -0
- package/dist/generative-ui/standard/theme.mjs.map +1 -0
- package/dist/generative-ui/standard/tokens.cjs +336 -0
- package/dist/generative-ui/standard/tokens.cjs.map +1 -0
- package/dist/generative-ui/standard/tokens.d.cts +76 -0
- package/dist/generative-ui/standard/tokens.d.cts.map +1 -0
- package/dist/generative-ui/standard/tokens.d.mts +76 -0
- package/dist/generative-ui/standard/tokens.d.mts.map +1 -0
- package/dist/generative-ui/standard/tokens.mjs +305 -0
- package/dist/generative-ui/standard/tokens.mjs.map +1 -0
- package/dist/generative-ui/standard/url.cjs +54 -0
- package/dist/generative-ui/standard/url.cjs.map +1 -0
- package/dist/generative-ui/standard/url.d.cts +32 -0
- package/dist/generative-ui/standard/url.d.cts.map +1 -0
- package/dist/generative-ui/standard/url.d.mts +32 -0
- package/dist/generative-ui/standard/url.d.mts.map +1 -0
- package/dist/generative-ui/standard/url.mjs +50 -0
- package/dist/generative-ui/standard/url.mjs.map +1 -0
- package/dist/generative-ui/thrown.cjs +69 -0
- package/dist/generative-ui/thrown.cjs.map +1 -0
- package/dist/generative-ui/thrown.d.cts +21 -0
- package/dist/generative-ui/thrown.d.cts.map +1 -0
- package/dist/generative-ui/thrown.d.mts +21 -0
- package/dist/generative-ui/thrown.d.mts.map +1 -0
- package/dist/generative-ui/thrown.mjs +67 -0
- package/dist/generative-ui/thrown.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 +17 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +17 -16
- 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 +1233 -456
- 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 +0 -5
- 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 +0 -5
- 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 +0 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -6
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -6
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -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/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 +19 -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 +323 -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/__tests__/utils.test.ts +22 -0
- package/src/attachments/types.ts +1 -3
- package/src/attachments/utils.ts +23 -5
- package/src/finalize-events.ts +16 -0
- package/src/generative-ui/__tests__/clone-value-differential.test.ts +480 -0
- package/src/generative-ui/__tests__/clone-value.test.ts +226 -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/base.ts +9 -0
- package/src/generative-ui/basic-functions.ts +1 -1
- package/src/generative-ui/catalog/catalog-export.ts +478 -0
- package/src/generative-ui/catalog/catalog.ts +1167 -0
- package/src/generative-ui/catalog/errors.ts +102 -0
- package/src/generative-ui/catalog/index.ts +6 -0
- package/src/generative-ui/catalog/json-schema.ts +14 -0
- package/src/generative-ui/catalog/refs.ts +87 -0
- package/src/generative-ui/catalog/schema.ts +107 -0
- package/src/generative-ui/child-refs.ts +5 -4
- package/src/generative-ui/clone-value.ts +511 -0
- package/src/generative-ui/compact-schema.ts +277 -0
- package/src/generative-ui/index.ts +14 -0
- package/src/generative-ui/is-record.ts +6 -1
- 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 +378 -0
- package/src/generative-ui/standard/__tests__/standard-helpers.test.ts +407 -0
- package/src/generative-ui/standard/__tests__/theme.test.ts +61 -0
- package/src/generative-ui/standard/__tests__/tokens.test.ts +139 -0
- package/src/generative-ui/standard/chart-config.ts +434 -0
- package/src/generative-ui/standard/chart.ts +79 -0
- package/src/generative-ui/standard/checks.ts +98 -0
- package/src/generative-ui/standard/components.ts +35 -0
- package/src/generative-ui/standard/composites.ts +158 -0
- package/src/generative-ui/standard/data.ts +213 -0
- package/src/generative-ui/standard/declarations.ts +57 -0
- package/src/generative-ui/standard/feedback.ts +105 -0
- package/src/generative-ui/standard/index.ts +55 -0
- package/src/generative-ui/standard/inputs.ts +423 -0
- package/src/generative-ui/standard/layout.ts +312 -0
- package/src/generative-ui/standard/map-helpers.ts +155 -0
- package/src/generative-ui/standard/map.ts +32 -0
- package/src/generative-ui/standard/media.ts +265 -0
- package/src/generative-ui/standard/parameter-order.ts +155 -0
- package/src/generative-ui/standard/style-helpers.ts +170 -0
- package/src/generative-ui/standard/styles.ts +79 -0
- package/src/generative-ui/standard/text.ts +210 -0
- package/src/generative-ui/standard/theme.ts +198 -0
- package/src/generative-ui/standard/tokens.ts +317 -0
- package/src/generative-ui/standard/url.ts +51 -0
- package/src/generative-ui/thrown.ts +90 -0
- package/src/generative-ui/types.ts +10 -7
- package/src/generative-ui/validate-operation.ts +2 -2
- package/src/index.ts +9 -17
- 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 +0 -5
- 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__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +0 -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/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
|
@@ -2,11 +2,11 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import { RenderUIArgsStream, extractRenderUIArgs } from "../render-ui-args";
|
|
3
3
|
|
|
4
4
|
const opA = {
|
|
5
|
-
version: "
|
|
5
|
+
version: "1.0",
|
|
6
6
|
createSurface: { surfaceId: "s" },
|
|
7
7
|
};
|
|
8
8
|
const opB = {
|
|
9
|
-
version: "
|
|
9
|
+
version: "1.0",
|
|
10
10
|
updateComponents: {
|
|
11
11
|
surfaceId: "s",
|
|
12
12
|
components: [
|
|
@@ -20,12 +20,12 @@ const opB = {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
const opC = {
|
|
23
|
-
version: "
|
|
23
|
+
version: "1.0",
|
|
24
24
|
updateDataModel: { surfaceId: "s", path: "/a", value: [1, { b: "]" }] },
|
|
25
25
|
};
|
|
26
26
|
/** One createSurface with the data model and the root inline. */
|
|
27
27
|
const inlineCreate = {
|
|
28
|
-
version: "
|
|
28
|
+
version: "1.0",
|
|
29
29
|
createSurface: {
|
|
30
30
|
surfaceId: "plan",
|
|
31
31
|
dataModel: { seats: 10, plans: [{ name: "Team" }] },
|
|
@@ -40,7 +40,7 @@ const inlineCreate = {
|
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
const functionCall = {
|
|
43
|
-
version: "
|
|
43
|
+
version: "1.0",
|
|
44
44
|
callRendererFunction: {
|
|
45
45
|
functionCallId: "f1",
|
|
46
46
|
callFunction: { "@call": "addToCart", args: { productId: "p{1}" } },
|
|
@@ -75,7 +75,7 @@ describe("extractRenderUIArgs", () => {
|
|
|
75
75
|
|
|
76
76
|
it("returns null for a balanced element that is not valid JSON", () => {
|
|
77
77
|
const text =
|
|
78
|
-
'{"target":"chat","operations":[{"version":"
|
|
78
|
+
'{"target":"chat","operations":[{"version":"1.0", bad},' +
|
|
79
79
|
JSON.stringify(opA) +
|
|
80
80
|
"]}";
|
|
81
81
|
expect(extractRenderUIArgs(text).operations).toEqual([null, opA]);
|
|
@@ -140,7 +140,7 @@ describe("RenderUIArgsStream", () => {
|
|
|
140
140
|
|
|
141
141
|
it("keeps the parser state across deltas that split strings, escapes and braces", () => {
|
|
142
142
|
const tricky = {
|
|
143
|
-
version: "
|
|
143
|
+
version: "1.0",
|
|
144
144
|
updateDataModel: { surfaceId: "s", path: "/q", value: 'a "}{" \\ ]' },
|
|
145
145
|
};
|
|
146
146
|
const text = JSON.stringify({
|
|
@@ -62,19 +62,19 @@ const functions = {
|
|
|
62
62
|
const knownSurfaces = new Set(["s1"]);
|
|
63
63
|
|
|
64
64
|
const update = (...components: unknown[]) => ({
|
|
65
|
-
version: "
|
|
65
|
+
version: "1.0",
|
|
66
66
|
updateComponents: { surfaceId: "s1", components },
|
|
67
67
|
});
|
|
68
68
|
const setData = (fields: { path?: string; value?: unknown }) => ({
|
|
69
|
-
version: "
|
|
69
|
+
version: "1.0",
|
|
70
70
|
updateDataModel: { surfaceId: "s1", ...fields },
|
|
71
71
|
});
|
|
72
72
|
const create = (fields: Record<string, unknown>) => ({
|
|
73
|
-
version: "
|
|
73
|
+
version: "1.0",
|
|
74
74
|
createSurface: { surfaceId: "s2", ...fields },
|
|
75
75
|
});
|
|
76
76
|
const callFunction = (fields: Record<string, unknown>) => ({
|
|
77
|
-
version: "
|
|
77
|
+
version: "1.0",
|
|
78
78
|
callRendererFunction: { functionCallId: "f1", ...fields },
|
|
79
79
|
});
|
|
80
80
|
/** A valid ProductCard with `props` added or replaced. */
|
|
@@ -90,23 +90,29 @@ const reasonOf = (
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
describe("validateOperation: version and kind", () => {
|
|
93
|
-
it("rejects
|
|
93
|
+
it("rejects the pre-release v1.0 spelling", () => {
|
|
94
|
+
expect(
|
|
95
|
+
reasonOf({ version: "v1.0", deleteSurface: { surfaceId: "s1" } }),
|
|
96
|
+
).toBe('unsupported version "v1.0"; use "1.0"');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("rejects a v0.9 operation with a reason that names 1.0", () => {
|
|
94
100
|
expect(
|
|
95
101
|
reasonOf({ version: "v0.9", deleteSurface: { surfaceId: "s1" } }),
|
|
96
|
-
).toBe('unsupported version "v0.9"; use "
|
|
102
|
+
).toBe('unsupported version "v0.9"; use "1.0"');
|
|
97
103
|
});
|
|
98
104
|
|
|
99
105
|
it("rejects an operation without a version", () => {
|
|
100
106
|
expect(reasonOf({ deleteSurface: { surfaceId: "s1" } })).toBe(
|
|
101
|
-
'operation needs "version":"
|
|
107
|
+
'operation needs "version":"1.0"',
|
|
102
108
|
);
|
|
103
109
|
});
|
|
104
110
|
|
|
105
111
|
it("rejects ops with zero or several kinds", () => {
|
|
106
|
-
expect(reasonOf({ version: "
|
|
112
|
+
expect(reasonOf({ version: "1.0" })).toMatch(/exactly one/);
|
|
107
113
|
expect(
|
|
108
114
|
reasonOf({
|
|
109
|
-
version: "
|
|
115
|
+
version: "1.0",
|
|
110
116
|
deleteSurface: { surfaceId: "s1" },
|
|
111
117
|
updateDataModel: { surfaceId: "s1", value: 1 },
|
|
112
118
|
}),
|
|
@@ -133,7 +139,7 @@ describe("validateOperation: createSurface", () => {
|
|
|
133
139
|
};
|
|
134
140
|
const check = (catalogId: string) =>
|
|
135
141
|
validateOperation(
|
|
136
|
-
{ version: "
|
|
142
|
+
{ version: "1.0", createSurface: { surfaceId: "s2", catalogId } },
|
|
137
143
|
options,
|
|
138
144
|
);
|
|
139
145
|
expect(check("copilotkit/standard@1")).toEqual({ ok: true });
|
|
@@ -146,13 +152,13 @@ describe("validateOperation: createSurface", () => {
|
|
|
146
152
|
|
|
147
153
|
it("rejects a createSurface without a surfaceId", () => {
|
|
148
154
|
expect(
|
|
149
|
-
reasonOf({ version: "
|
|
155
|
+
reasonOf({ version: "1.0", createSurface: { catalogId: "shop" } }),
|
|
150
156
|
).toBe("createSurface.surfaceId is required");
|
|
151
157
|
});
|
|
152
158
|
|
|
153
159
|
it("rejects an existing surface", () => {
|
|
154
160
|
expect(
|
|
155
|
-
reasonOf({ version: "
|
|
161
|
+
reasonOf({ version: "1.0", createSurface: { surfaceId: "s1" } }),
|
|
156
162
|
).toBe('surface "s1" already exists');
|
|
157
163
|
});
|
|
158
164
|
|
|
@@ -201,7 +207,7 @@ describe("validateOperation: surface updates", () => {
|
|
|
201
207
|
it("rejects updates to surfaces that do not exist", () => {
|
|
202
208
|
expect(
|
|
203
209
|
reasonOf({
|
|
204
|
-
version: "
|
|
210
|
+
version: "1.0",
|
|
205
211
|
updateComponents: {
|
|
206
212
|
surfaceId: "missing",
|
|
207
213
|
components: [{ id: "root", component: "ProductGrid" }],
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./validate-operation";
|
|
3
|
+
export * from "./render-ui-args";
|
|
4
|
+
export * from "./basic-functions";
|
|
5
|
+
export * from "./child-refs";
|
|
6
|
+
export * from "./prompt";
|
|
7
|
+
export { buildCompactGenerativeUISchema } from "./compact-schema";
|
|
8
|
+
export * from "./prompt-spec";
|
|
9
|
+
export * from "./schema-render";
|
|
@@ -189,7 +189,7 @@ export const COPILOTKIT_FUNCTIONS: Readonly<
|
|
|
189
189
|
> = rendererOnly({
|
|
190
190
|
calc: {
|
|
191
191
|
description:
|
|
192
|
-
"The value of an arithmetic expression over the other args, by name: + - * / % ( ), comparisons, && || !, cond ? a : b, min max round floor ceil abs, 'text' + name",
|
|
192
|
+
"The value of an arithmetic expression over the other args, by name: + - * / % ( ), x ^ y (power), comparisons, && || !, cond ? a : b, min max round floor ceil abs pow sqrt exp ln log10, the constants pi and e, 'text' + name",
|
|
193
193
|
parameters:
|
|
194
194
|
"{ expression: string; [name: string]: number | string | boolean }",
|
|
195
195
|
returnType: "any",
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A2UI_CHILD_LIST_REF,
|
|
3
|
+
A2UI_COMPONENT_ID_REF,
|
|
4
|
+
GENERATIVE_UI_FUNCTIONS,
|
|
5
|
+
childRefKind,
|
|
6
|
+
functionCallers,
|
|
7
|
+
} from "../base";
|
|
8
|
+
import type {
|
|
9
|
+
A2UIAllowedCallers,
|
|
10
|
+
A2UIFunctionPermissions,
|
|
11
|
+
GenerativeUIComponentManifest,
|
|
12
|
+
GenerativeUIJSONSchema,
|
|
13
|
+
} from "../base";
|
|
14
|
+
import type { GenerativeUI } from "./catalog";
|
|
15
|
+
import { toJsonSchema } from "./json-schema";
|
|
16
|
+
import { hasOwnKey, isRecord } from "../is-record";
|
|
17
|
+
|
|
18
|
+
const COMMON = "common_types.json#/$defs/";
|
|
19
|
+
const DATA_BINDING_REF = `${COMMON}DataBinding`;
|
|
20
|
+
const FUNCTION_CALL_REF = `${COMMON}FunctionCall`;
|
|
21
|
+
const ACTION_REF = `${COMMON}Action`;
|
|
22
|
+
const DYNAMIC_REFS: Record<string, string> = {
|
|
23
|
+
string: `${COMMON}DynamicString`,
|
|
24
|
+
number: `${COMMON}DynamicNumber`,
|
|
25
|
+
boolean: `${COMMON}DynamicBoolean`,
|
|
26
|
+
"string[]": `${COMMON}DynamicStringList`,
|
|
27
|
+
unknown: `${COMMON}DynamicValue`,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** What `exportA2UICatalog` adds at the top of the catalog. */
|
|
31
|
+
export interface ExportA2UICatalogOptions {
|
|
32
|
+
/** The title of the catalog. */
|
|
33
|
+
title?: string;
|
|
34
|
+
/** What the catalog is for. */
|
|
35
|
+
description?: string;
|
|
36
|
+
/** Markdown design guidelines for a model that writes this catalog. */
|
|
37
|
+
instructions?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The A2UI 1.0 catalog definition of a generative UI, as a JSON value that
|
|
42
|
+
* follows `catalog_definition.json`: one `components` entry per component,
|
|
43
|
+
* with `component` as a `const`, `functions` for the built-ins and the
|
|
44
|
+
* declared functions, and `$defs.anyComponent` / `$defs.anyFunction`. Other
|
|
45
|
+
* A2UI tools (a validator, another renderer, a prompt builder) read it.
|
|
46
|
+
*
|
|
47
|
+
* - A prop that `child()` or `childList()` marks is a `ComponentId` or a
|
|
48
|
+
* `ChildList` reference; so is a slot. An event prop is an `Action`.
|
|
49
|
+
* - Every other value, at any depth of a prop or of the args of a declared
|
|
50
|
+
* function, takes its literal schema, a `DataBinding` or a `FunctionCall`,
|
|
51
|
+
* because the renderer resolves dynamic values at any depth.
|
|
52
|
+
* - Every function states `returnType` and `allowedCallers`: the built-ins
|
|
53
|
+
* are `rendererOnly`, and so is a declared function without
|
|
54
|
+
* `allowedCallers`, as in A2UI 1.0.
|
|
55
|
+
*
|
|
56
|
+
* @param ui - The generative UI to describe.
|
|
57
|
+
* @param options - The title, description and instructions of the catalog.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const catalog = exportA2UICatalog(shopUI, { title: "Acme shop" });
|
|
62
|
+
* fs.writeFileSync("shop-catalog.json", JSON.stringify(catalog, null, 2));
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export function exportA2UICatalog(
|
|
66
|
+
ui: GenerativeUI,
|
|
67
|
+
options: ExportA2UICatalogOptions = {},
|
|
68
|
+
) {
|
|
69
|
+
const components = Object.fromEntries(
|
|
70
|
+
Object.entries(ui.manifestComponents).map(([name, manifest]) => [
|
|
71
|
+
name,
|
|
72
|
+
toDraft2020(
|
|
73
|
+
rebaseRefs(
|
|
74
|
+
componentDefinition(name, manifest),
|
|
75
|
+
`#/components/${pointerSegment(name)}`,
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
]),
|
|
79
|
+
);
|
|
80
|
+
const functions: Record<string, GenerativeUIJSONSchema> = {};
|
|
81
|
+
for (const [name, info] of Object.entries(GENERATIVE_UI_FUNCTIONS)) {
|
|
82
|
+
// A declared function of the same name is the app's.
|
|
83
|
+
if (ui.functions.has(name)) continue;
|
|
84
|
+
functions[name] = functionEntry(name, info, {
|
|
85
|
+
description: info.description,
|
|
86
|
+
returnType: info.returnType,
|
|
87
|
+
args: argsSchemaFromSignature(info.parameters),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
for (const [name, fn] of ui.functions) {
|
|
91
|
+
functions[name] = functionEntry(name, fn, {
|
|
92
|
+
description: fn.description,
|
|
93
|
+
returnType: fn.returnType ?? "any",
|
|
94
|
+
args: toDraft2020(
|
|
95
|
+
rebaseRefs(
|
|
96
|
+
dynamicArgs(toJsonSchema(fn.parameters)),
|
|
97
|
+
`#/functions/${pointerSegment(name)}/properties/args`,
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const { title, description, instructions } = options;
|
|
103
|
+
return {
|
|
104
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
105
|
+
protocolVersion: "1.0",
|
|
106
|
+
catalogId: ui.id,
|
|
107
|
+
...(title === undefined ? {} : { title }),
|
|
108
|
+
...(description === undefined ? {} : { description }),
|
|
109
|
+
...(instructions === undefined ? {} : { instructions }),
|
|
110
|
+
components,
|
|
111
|
+
functions,
|
|
112
|
+
$defs: {
|
|
113
|
+
anyComponent: {
|
|
114
|
+
...oneOfRefs("components", Object.keys(components)),
|
|
115
|
+
discriminator: { propertyName: "component" },
|
|
116
|
+
},
|
|
117
|
+
anyFunction: oneOfRefs("functions", Object.keys(functions)),
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* `oneOf` over the entries of a section. JSON Schema wants at least one
|
|
124
|
+
* variant, so an empty section (a UI with no components) matches nothing.
|
|
125
|
+
*/
|
|
126
|
+
function oneOfRefs(section: string, names: string[]) {
|
|
127
|
+
if (names.length === 0) return { not: {} };
|
|
128
|
+
return {
|
|
129
|
+
oneOf: names.map((name) => ({
|
|
130
|
+
$ref: `#/${section}/${pointerSegment(name)}`,
|
|
131
|
+
})),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** A name as a JSON Pointer segment in a URI fragment: `acme/Card` is `acme~1Card`. */
|
|
136
|
+
function pointerSegment(name: string) {
|
|
137
|
+
return encodeURIComponent(name.replace(/~/g, "~0").replace(/\//g, "~1"));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Keywords whose value is data, not a schema. */
|
|
141
|
+
const LITERAL_KEYWORDS = new Set(["default", "const", "enum", "examples"]);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A schema in the draft 2020-12 dialect that the catalog declares. The
|
|
145
|
+
* converter writes draft-07, where a tuple is `items: [...]` with
|
|
146
|
+
* `additionalItems`; 2020-12 spells that `prefixItems` and `items`.
|
|
147
|
+
*/
|
|
148
|
+
function toDraft2020(schema: GenerativeUIJSONSchema): GenerativeUIJSONSchema {
|
|
149
|
+
return mapSchema(schema, (node) => {
|
|
150
|
+
const { items, additionalItems, ...rest } = node;
|
|
151
|
+
if (!Array.isArray(items)) return node;
|
|
152
|
+
return {
|
|
153
|
+
...rest,
|
|
154
|
+
prefixItems: items,
|
|
155
|
+
...(additionalItems === undefined ? {} : { items: additionalItems }),
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** One `components` entry: the props as the model sets them, with the A2UI common types. */
|
|
161
|
+
function componentDefinition(
|
|
162
|
+
name: string,
|
|
163
|
+
manifest: GenerativeUIComponentManifest,
|
|
164
|
+
): GenerativeUIJSONSchema {
|
|
165
|
+
const { properties, required, description, $defs, definitions } =
|
|
166
|
+
manifest.props;
|
|
167
|
+
const props = Object.fromEntries(
|
|
168
|
+
Object.entries(isRecord(properties) ? properties : {}).map(
|
|
169
|
+
([key, schema]) => [key, dynamicProp(schema)],
|
|
170
|
+
),
|
|
171
|
+
);
|
|
172
|
+
const events = Object.fromEntries(
|
|
173
|
+
Object.entries(manifest.events ?? {}).map(([key, event]) => [
|
|
174
|
+
key,
|
|
175
|
+
{
|
|
176
|
+
$ref: ACTION_REF,
|
|
177
|
+
...(event.description ? { description: event.description } : {}),
|
|
178
|
+
},
|
|
179
|
+
]),
|
|
180
|
+
);
|
|
181
|
+
const slots = Object.fromEntries(
|
|
182
|
+
Object.entries(manifest.slots ?? {}).map(([key, kind]) => [
|
|
183
|
+
key,
|
|
184
|
+
{ $ref: kind === "single" ? A2UI_COMPONENT_ID_REF : A2UI_CHILD_LIST_REF },
|
|
185
|
+
]),
|
|
186
|
+
);
|
|
187
|
+
const fields = { ...props, ...events, ...slots };
|
|
188
|
+
const orderedFields =
|
|
189
|
+
manifest.parameterOrder === undefined
|
|
190
|
+
? fields
|
|
191
|
+
: Object.fromEntries(
|
|
192
|
+
[...new Set([...manifest.parameterOrder, ...Object.keys(fields)])]
|
|
193
|
+
.filter((key) => hasOwnKey(fields, key))
|
|
194
|
+
.map((key) => [key, fields[key]]),
|
|
195
|
+
);
|
|
196
|
+
const text = manifest.description ?? description;
|
|
197
|
+
return {
|
|
198
|
+
type: "object",
|
|
199
|
+
...(typeof text === "string" ? { description: text } : {}),
|
|
200
|
+
properties: { component: { const: name }, ...orderedFields },
|
|
201
|
+
required: [
|
|
202
|
+
"component",
|
|
203
|
+
...(Array.isArray(required) ? required.filter(isString) : []),
|
|
204
|
+
],
|
|
205
|
+
// The definitions of the props schema, when its converter made some:
|
|
206
|
+
// their values are dynamic like the props, and the references to them
|
|
207
|
+
// are rebased onto this entry.
|
|
208
|
+
...withDynamicChildren({
|
|
209
|
+
...(isRecord($defs) ? { $defs } : {}),
|
|
210
|
+
...(isRecord(definitions) ? { definitions } : {}),
|
|
211
|
+
}),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The schema with its local references (`#/...`) pointing into the place
|
|
217
|
+
* it is embedded at. A converter that writes `$defs` refers to them from
|
|
218
|
+
* the root of its own document; inside the catalog, that root is `base`.
|
|
219
|
+
*/
|
|
220
|
+
function rebaseRefs(
|
|
221
|
+
schema: GenerativeUIJSONSchema,
|
|
222
|
+
base: string,
|
|
223
|
+
): GenerativeUIJSONSchema {
|
|
224
|
+
return mapSchema(schema, (node) => {
|
|
225
|
+
const ref = node.$ref;
|
|
226
|
+
// "#" is the root of the embedded schema (a recursive one refers to it).
|
|
227
|
+
if (ref === "#") return { ...node, $ref: base };
|
|
228
|
+
if (typeof ref === "string" && ref.startsWith("#/")) {
|
|
229
|
+
return { ...node, $ref: `${base}${ref.slice(1)}` };
|
|
230
|
+
}
|
|
231
|
+
return node;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Keywords whose value is a map from a name to a schema. */
|
|
236
|
+
const SCHEMA_MAP_KEYWORDS = new Set([
|
|
237
|
+
"properties",
|
|
238
|
+
"patternProperties",
|
|
239
|
+
"$defs",
|
|
240
|
+
"definitions",
|
|
241
|
+
"dependentSchemas",
|
|
242
|
+
]);
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Walks a JSON Schema and rebuilds each schema node with `transform`, the
|
|
246
|
+
* children first. The names in `properties` and the definition maps are
|
|
247
|
+
* names, not keywords: a prop called `default` is a schema, while the
|
|
248
|
+
* `default` of a schema is data and stays as it is.
|
|
249
|
+
*/
|
|
250
|
+
function mapSchema(
|
|
251
|
+
schema: GenerativeUIJSONSchema,
|
|
252
|
+
transform: (node: Record<string, unknown>) => Record<string, unknown>,
|
|
253
|
+
): GenerativeUIJSONSchema {
|
|
254
|
+
const visitValue = (value: unknown): unknown => {
|
|
255
|
+
if (Array.isArray(value)) return value.map(visitValue);
|
|
256
|
+
return isRecord(value) ? visitNode(value) : value;
|
|
257
|
+
};
|
|
258
|
+
const visitNode = (
|
|
259
|
+
node: Record<string, unknown>,
|
|
260
|
+
): Record<string, unknown> => {
|
|
261
|
+
const result: Record<string, unknown> = {};
|
|
262
|
+
for (const [key, value] of Object.entries(node)) {
|
|
263
|
+
if (LITERAL_KEYWORDS.has(key)) result[key] = value;
|
|
264
|
+
else if (SCHEMA_MAP_KEYWORDS.has(key) && isRecord(value)) {
|
|
265
|
+
result[key] = Object.fromEntries(
|
|
266
|
+
Object.entries(value).map(([name, entry]) => [
|
|
267
|
+
name,
|
|
268
|
+
isRecord(entry) ? visitNode(entry) : entry,
|
|
269
|
+
]),
|
|
270
|
+
);
|
|
271
|
+
} else result[key] = visitValue(value);
|
|
272
|
+
}
|
|
273
|
+
return transform(result);
|
|
274
|
+
};
|
|
275
|
+
return visitNode(schema) as GenerativeUIJSONSchema;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const isString = (value: unknown): value is string => typeof value === "string";
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* A prop as the catalog states it. A component reference stays one. Any
|
|
282
|
+
* other value takes its literal schema, a data binding or a function call,
|
|
283
|
+
* and so does every value inside it: the properties of an object, the
|
|
284
|
+
* values of a record and the items of a list, because the renderer
|
|
285
|
+
* resolves dynamic values at any depth. The variants of a union are
|
|
286
|
+
* transformed in place.
|
|
287
|
+
*/
|
|
288
|
+
function dynamicProp(schema: unknown): GenerativeUIJSONSchema {
|
|
289
|
+
if (!isRecord(schema)) return { $ref: DYNAMIC_REFS.unknown };
|
|
290
|
+
if (childRefKind(schema)) return schema;
|
|
291
|
+
const { description, ...literal } = withDynamicChildren(schema);
|
|
292
|
+
return {
|
|
293
|
+
...(typeof description === "string" ? { description } : {}),
|
|
294
|
+
anyOf: [literal, { $ref: DATA_BINDING_REF }, { $ref: FUNCTION_CALL_REF }],
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** The schema with its nested values made dynamic, itself unchanged. */
|
|
299
|
+
function withDynamicChildren(
|
|
300
|
+
schema: Record<string, unknown>,
|
|
301
|
+
): Record<string, unknown> {
|
|
302
|
+
const result = { ...schema };
|
|
303
|
+
if (isRecord(schema.properties)) {
|
|
304
|
+
result.properties = Object.fromEntries(
|
|
305
|
+
Object.entries(schema.properties).map(([key, value]) => [
|
|
306
|
+
key,
|
|
307
|
+
dynamicProp(value),
|
|
308
|
+
]),
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
if (isRecord(schema.items)) result.items = dynamicProp(schema.items);
|
|
312
|
+
// A tuple, as the converter writes it; the catalog spells it prefixItems.
|
|
313
|
+
if (Array.isArray(schema.items)) {
|
|
314
|
+
result.items = schema.items.map((item) =>
|
|
315
|
+
isRecord(item) ? dynamicProp(item) : item,
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
if (isRecord(schema.additionalItems)) {
|
|
319
|
+
result.additionalItems = dynamicProp(schema.additionalItems);
|
|
320
|
+
}
|
|
321
|
+
// The definitions a converter wrote: referenced from value positions.
|
|
322
|
+
for (const key of ["$defs", "definitions"] as const) {
|
|
323
|
+
const defs = schema[key];
|
|
324
|
+
if (isRecord(defs)) {
|
|
325
|
+
result[key] = Object.fromEntries(
|
|
326
|
+
Object.entries(defs).map(([name, def]) => [
|
|
327
|
+
name,
|
|
328
|
+
isRecord(def) ? withDynamicChildren(def) : def,
|
|
329
|
+
]),
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (Array.isArray(schema.allOf)) {
|
|
334
|
+
result.allOf = schema.allOf.map((part) =>
|
|
335
|
+
isRecord(part) ? withDynamicChildren(part) : part,
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
// The values of a record, by any key or by key pattern.
|
|
339
|
+
if (isRecord(schema.additionalProperties)) {
|
|
340
|
+
result.additionalProperties = dynamicProp(schema.additionalProperties);
|
|
341
|
+
}
|
|
342
|
+
if (isRecord(schema.patternProperties)) {
|
|
343
|
+
result.patternProperties = Object.fromEntries(
|
|
344
|
+
Object.entries(schema.patternProperties).map(([pattern, value]) => [
|
|
345
|
+
pattern,
|
|
346
|
+
dynamicProp(value),
|
|
347
|
+
]),
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
for (const key of ["anyOf", "oneOf"] as const) {
|
|
351
|
+
const variants = schema[key];
|
|
352
|
+
if (Array.isArray(variants)) {
|
|
353
|
+
result[key] = variants.map((variant) =>
|
|
354
|
+
isRecord(variant) && !childRefKind(variant)
|
|
355
|
+
? withDynamicChildren(variant)
|
|
356
|
+
: variant,
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* The args of a declared function as the catalog states them: the object
|
|
365
|
+
* stays an object, each arg takes a value, a binding or a function call.
|
|
366
|
+
*/
|
|
367
|
+
function dynamicArgs(schema: GenerativeUIJSONSchema): GenerativeUIJSONSchema {
|
|
368
|
+
return withDynamicChildren(schema);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** One `functions` entry, in the A2UI `FunctionDefinition` shape. */
|
|
372
|
+
function functionEntry(
|
|
373
|
+
name: string,
|
|
374
|
+
permissions: A2UIFunctionPermissions,
|
|
375
|
+
parts: {
|
|
376
|
+
description: string | undefined;
|
|
377
|
+
returnType: string;
|
|
378
|
+
args: GenerativeUIJSONSchema;
|
|
379
|
+
},
|
|
380
|
+
): GenerativeUIJSONSchema {
|
|
381
|
+
const callers = functionCallers(permissions);
|
|
382
|
+
const allowedCallers: A2UIAllowedCallers =
|
|
383
|
+
callers.renderer && callers.agent
|
|
384
|
+
? "rendererOrAgent"
|
|
385
|
+
: callers.agent
|
|
386
|
+
? "agentOnly"
|
|
387
|
+
: "rendererOnly";
|
|
388
|
+
// The metaschema's activation rule has no `required`, so it also matches
|
|
389
|
+
// an entry without the key: the value is always written out.
|
|
390
|
+
// `args` is required only when an arg is.
|
|
391
|
+
const argsRequired = hasRequiredArgs(parts.args);
|
|
392
|
+
return {
|
|
393
|
+
type: "object",
|
|
394
|
+
...(parts.description ? { description: parts.description } : {}),
|
|
395
|
+
returnType: parts.returnType,
|
|
396
|
+
allowedCallers,
|
|
397
|
+
requiresUserActivation: permissions.requiresUserActivation === true,
|
|
398
|
+
properties: { "@call": { const: name }, args: parts.args },
|
|
399
|
+
required: argsRequired ? ["@call", "args"] : ["@call"],
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* True when an empty args object fails the schema: a key is required at
|
|
405
|
+
* its top, in an `allOf` part, or in every variant of an `anyOf` / `oneOf`.
|
|
406
|
+
*/
|
|
407
|
+
function hasRequiredArgs(schema: unknown): boolean {
|
|
408
|
+
if (!isRecord(schema)) return false;
|
|
409
|
+
if (Array.isArray(schema.required) && schema.required.length > 0) return true;
|
|
410
|
+
if (Array.isArray(schema.allOf) && schema.allOf.some(hasRequiredArgs)) {
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
for (const key of ["anyOf", "oneOf"] as const) {
|
|
414
|
+
const variants = schema[key];
|
|
415
|
+
if (Array.isArray(variants) && variants.length > 0) {
|
|
416
|
+
if (variants.every(hasRequiredArgs)) return true;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* The JSON Schema of the args of a built-in function, from its short
|
|
424
|
+
* TypeScript-like signature (`{ value: number; decimals?: number }`). Each
|
|
425
|
+
* arg takes a literal, a binding or a function call, so a type maps to the
|
|
426
|
+
* A2UI dynamic type; `[name: string]: T` becomes `additionalProperties`.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```ts
|
|
430
|
+
* argsSchemaFromSignature("{ value: string; min?: number }");
|
|
431
|
+
* // { type: "object", properties: { value: { $ref: ".../DynamicString" }, min: { $ref: ".../DynamicNumber" } }, required: ["value"], additionalProperties: false }
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
export function argsSchemaFromSignature(
|
|
435
|
+
signature: string,
|
|
436
|
+
): GenerativeUIJSONSchema {
|
|
437
|
+
const body = signature.trim().replace(/^\{/, "").replace(/\}$/, "");
|
|
438
|
+
const properties: Record<string, GenerativeUIJSONSchema> = {};
|
|
439
|
+
const required: string[] = [];
|
|
440
|
+
let additionalProperties: GenerativeUIJSONSchema | false = false;
|
|
441
|
+
for (const part of body.split(";")) {
|
|
442
|
+
const field = part.trim();
|
|
443
|
+
if (field === "") continue;
|
|
444
|
+
const index = field.match(/^\[\w+: string\]:\s*(.+)$/);
|
|
445
|
+
if (index) {
|
|
446
|
+
additionalProperties = typeSchema(index[1]!);
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
const named = field.match(/^(\w+)(\?)?:\s*(.+)$/);
|
|
450
|
+
if (!named) continue;
|
|
451
|
+
properties[named[1]!] = typeSchema(named[3]!);
|
|
452
|
+
if (!named[2]) required.push(named[1]!);
|
|
453
|
+
}
|
|
454
|
+
return {
|
|
455
|
+
type: "object",
|
|
456
|
+
properties,
|
|
457
|
+
...(required.length > 0 ? { required } : {}),
|
|
458
|
+
additionalProperties,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function typeSchema(type: string): GenerativeUIJSONSchema {
|
|
463
|
+
const trimmed = type.trim();
|
|
464
|
+
const alternatives = trimmed.split("|").map((part) => part.trim());
|
|
465
|
+
if (alternatives.length > 1) return { anyOf: alternatives.map(typeSchema) };
|
|
466
|
+
if (trimmed in DYNAMIC_REFS) return { $ref: DYNAMIC_REFS[trimmed] };
|
|
467
|
+
if (trimmed.endsWith("[]")) {
|
|
468
|
+
// The whole list can be bound or computed, like any other arg.
|
|
469
|
+
return {
|
|
470
|
+
anyOf: [
|
|
471
|
+
{ type: "array", items: typeSchema(trimmed.slice(0, -2)) },
|
|
472
|
+
{ $ref: DATA_BINDING_REF },
|
|
473
|
+
{ $ref: FUNCTION_CALL_REF },
|
|
474
|
+
],
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
return { $ref: DYNAMIC_REFS.unknown };
|
|
478
|
+
}
|