@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
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
MODEL_HOST_CLASSES,
|
|
5
|
-
type ModelHostClass,
|
|
6
|
-
} from "./model-host";
|
|
2
|
+
import { classifyModelHost, MODEL_HOST_CLASSES } from "./model-host";
|
|
3
|
+
import type { ModelHostClass } from "./model-host";
|
|
7
4
|
|
|
8
5
|
describe("classifyModelHost", () => {
|
|
9
6
|
describe("the case this exists for: an OpenAI-shaped client aimed elsewhere", () => {
|
|
@@ -5,11 +5,6 @@ import { processEnv } from "../utils/process-env";
|
|
|
5
5
|
* Users can opt out by setting:
|
|
6
6
|
* - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
|
|
7
7
|
* - DO_NOT_TRACK=true or DO_NOT_TRACK=1
|
|
8
|
-
*
|
|
9
|
-
* Lives in its own module so that the browser-facing root entry can
|
|
10
|
-
* re-export it without pulling in `telemetry-client.ts`, whose
|
|
11
|
-
* `@segment/analytics-node` import drags Node built-ins into browser
|
|
12
|
-
* bundler module graphs. See the note in `../index.ts`.
|
|
13
8
|
*/
|
|
14
9
|
export function isTelemetryDisabled(): boolean {
|
|
15
10
|
const env = processEnv();
|
package/src/types/message.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as agui from "@ag-ui/core";
|
|
1
|
+
import type * as agui from "@ag-ui/core";
|
|
2
2
|
|
|
3
3
|
// Re-export AG-UI multimodal input types.
|
|
4
4
|
// Note: AG-UI names the text variant TextInputContent; we export it as TextInputPart for consistency.
|
|
@@ -14,18 +14,6 @@ export type {
|
|
|
14
14
|
DocumentInputPart,
|
|
15
15
|
} from "@ag-ui/core";
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Use `InputContentSource` from `@ag-ui/core` (re-exported from `@copilotkit/shared`) instead.
|
|
19
|
-
* `ImageData` only described base64 image payloads. `InputContentSource` supports
|
|
20
|
-
* data and URL sources for images, audio, video, and documents.
|
|
21
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
22
|
-
* @since 1.56.0
|
|
23
|
-
*/
|
|
24
|
-
export interface ImageData {
|
|
25
|
-
format: string;
|
|
26
|
-
bytes: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
17
|
// Pass through types
|
|
30
18
|
export type Role = agui.Role;
|
|
31
19
|
export type SystemMessage = agui.SystemMessage;
|
|
@@ -44,12 +32,6 @@ export type AIMessage = agui.AssistantMessage & {
|
|
|
44
32
|
generativeUIPosition?: "before" | "after";
|
|
45
33
|
agentName?: string;
|
|
46
34
|
state?: any;
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated Use multimodal `content` array with `InputContent` parts instead.
|
|
49
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
50
|
-
* @since 1.56.0
|
|
51
|
-
*/
|
|
52
|
-
image?: ImageData;
|
|
53
35
|
runId?: string;
|
|
54
36
|
};
|
|
55
37
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
CopilotKitError,
|
|
4
|
+
CopilotKitErrorCode,
|
|
5
|
+
ConfigurationError,
|
|
6
|
+
ErrorVisibility,
|
|
7
|
+
Severity,
|
|
8
|
+
} from "../errors";
|
|
9
|
+
|
|
10
|
+
describe("CopilotKitError", () => {
|
|
11
|
+
it("is a plain Error that keeps the structured extensions", () => {
|
|
12
|
+
const error = new CopilotKitError({
|
|
13
|
+
message: "boom",
|
|
14
|
+
code: CopilotKitErrorCode.NOT_FOUND,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(error).toBeInstanceOf(Error);
|
|
18
|
+
expect(error.message).toBe("boom");
|
|
19
|
+
expect(error.name).toBe("CopilotError");
|
|
20
|
+
expect(error.extensions).toMatchObject({
|
|
21
|
+
name: "CopilotError",
|
|
22
|
+
code: CopilotKitErrorCode.NOT_FOUND,
|
|
23
|
+
statusCode: 404,
|
|
24
|
+
visibility: ErrorVisibility.BANNER,
|
|
25
|
+
severity: Severity.CRITICAL,
|
|
26
|
+
originalError: { message: "boom" },
|
|
27
|
+
});
|
|
28
|
+
expect(error.extensions.troubleshootingUrl).toContain(
|
|
29
|
+
"network-errors-api-not-found",
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("sets troubleshootingUrl to null when the code has none", () => {
|
|
34
|
+
const error = new CopilotKitError({ code: CopilotKitErrorCode.UNKNOWN });
|
|
35
|
+
expect(error.extensions.troubleshootingUrl).toBeNull();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("keeps subclasses instanceof both the subclass and CopilotKitError", () => {
|
|
39
|
+
const error = new ConfigurationError("bad config");
|
|
40
|
+
expect(error).toBeInstanceOf(ConfigurationError);
|
|
41
|
+
expect(error).toBeInstanceOf(CopilotKitError);
|
|
42
|
+
expect(error.extensions.code).toBe(CopilotKitErrorCode.CONFIGURATION_ERROR);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,486 +1,10 @@
|
|
|
1
|
-
import { describe, it, expect
|
|
2
|
-
import {
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import type { JSONSchema } from "../json-schema";
|
|
3
3
|
import {
|
|
4
|
-
convertJsonSchemaToZodSchema,
|
|
5
4
|
actionParametersToJsonSchema,
|
|
6
5
|
jsonSchemaToActionParameters,
|
|
7
|
-
JSONSchema,
|
|
8
6
|
} from "../json-schema";
|
|
9
|
-
import {
|
|
10
|
-
import { Parameter } from "../../types";
|
|
11
|
-
|
|
12
|
-
describe("convertJsonSchemaToZodSchema", () => {
|
|
13
|
-
it("should convert a simple JSON schema to a Zod schema", () => {
|
|
14
|
-
const jsonSchema = {
|
|
15
|
-
type: "object",
|
|
16
|
-
properties: {
|
|
17
|
-
name: { type: "string" },
|
|
18
|
-
age: { type: "number" },
|
|
19
|
-
},
|
|
20
|
-
required: ["name", "age"],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const expectedSchema = z.object({
|
|
24
|
-
name: z.string(),
|
|
25
|
-
age: z.number(),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
29
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
30
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
31
|
-
|
|
32
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should convert a JSON schema with nested objects to a Zod schema", () => {
|
|
36
|
-
const jsonSchema = {
|
|
37
|
-
type: "object",
|
|
38
|
-
properties: {
|
|
39
|
-
name: { type: "string" },
|
|
40
|
-
address: {
|
|
41
|
-
type: "object",
|
|
42
|
-
properties: {
|
|
43
|
-
street: { type: "string" },
|
|
44
|
-
city: { type: "string" },
|
|
45
|
-
},
|
|
46
|
-
required: ["street", "city"],
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
required: ["name", "address"],
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const expectedSchema = z.object({
|
|
53
|
-
name: z.string(),
|
|
54
|
-
address: z.object({
|
|
55
|
-
street: z.string(),
|
|
56
|
-
city: z.string(),
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
61
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
62
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
63
|
-
|
|
64
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("should convert a JSON schema with arrays to a Zod schema", () => {
|
|
68
|
-
const jsonSchema = {
|
|
69
|
-
type: "object",
|
|
70
|
-
properties: {
|
|
71
|
-
names: {
|
|
72
|
-
type: "array",
|
|
73
|
-
items: { type: "string" },
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
required: ["names"],
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const expectedSchema = z.object({
|
|
80
|
-
names: z.array(z.string()),
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
84
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
85
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
86
|
-
|
|
87
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("should convert a JSON schema with optional properties to a Zod schema", () => {
|
|
91
|
-
const jsonSchema = {
|
|
92
|
-
type: "object",
|
|
93
|
-
properties: {
|
|
94
|
-
name: { type: "string" },
|
|
95
|
-
age: { type: "number", required: false },
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const expectedSchema = z
|
|
100
|
-
.object({
|
|
101
|
-
name: z.string().optional(),
|
|
102
|
-
age: z.number().optional(),
|
|
103
|
-
})
|
|
104
|
-
.optional();
|
|
105
|
-
|
|
106
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, false);
|
|
107
|
-
|
|
108
|
-
console.log(convertJsonSchemaToZodSchema(jsonSchema, false));
|
|
109
|
-
|
|
110
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
111
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
112
|
-
|
|
113
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("should convert a JSON schema with different types to a Zod schema", () => {
|
|
117
|
-
const jsonSchema = {
|
|
118
|
-
type: "object",
|
|
119
|
-
properties: {
|
|
120
|
-
name: { type: "string" },
|
|
121
|
-
age: { type: "number" },
|
|
122
|
-
isAdmin: { type: "boolean" },
|
|
123
|
-
},
|
|
124
|
-
required: ["name", "age", "isAdmin"],
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const expectedSchema = z.object({
|
|
128
|
-
name: z.string(),
|
|
129
|
-
age: z.number(),
|
|
130
|
-
isAdmin: z.boolean(),
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
134
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
135
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
136
|
-
|
|
137
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("should handle edge case where JSON schema has no properties", () => {
|
|
141
|
-
const jsonSchema = {
|
|
142
|
-
type: "object",
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const expectedSchema = z.object({});
|
|
146
|
-
|
|
147
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
148
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
149
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
150
|
-
|
|
151
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("should preserve string enum constraints", () => {
|
|
155
|
-
const jsonSchema = {
|
|
156
|
-
type: "object",
|
|
157
|
-
properties: {
|
|
158
|
-
status: {
|
|
159
|
-
type: "string",
|
|
160
|
-
description: "The status",
|
|
161
|
-
enum: ["todo", "done"],
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
required: ["status"],
|
|
165
|
-
};
|
|
166
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
167
|
-
const statusSchema = (result as z.ZodObject<any>).shape.status;
|
|
168
|
-
expect(statusSchema._def.typeName).toBe("ZodEnum");
|
|
169
|
-
expect(statusSchema._def.values).toEqual(["todo", "done"]);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("should handle null-union type ['string', 'null'] as nullable", () => {
|
|
173
|
-
const jsonSchema = {
|
|
174
|
-
type: "object",
|
|
175
|
-
properties: {
|
|
176
|
-
nickname: {
|
|
177
|
-
type: ["string", "null"],
|
|
178
|
-
description: "Optional nickname",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
required: ["nickname"],
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
185
|
-
const shape = (result as z.ZodObject<any>).shape;
|
|
186
|
-
|
|
187
|
-
// The nickname field should accept both string and null
|
|
188
|
-
expect(shape.nickname.safeParse("hello").success).toBe(true);
|
|
189
|
-
expect(shape.nickname.safeParse(null).success).toBe(true);
|
|
190
|
-
expect(shape.nickname.safeParse(42).success).toBe(false);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it("should handle null-union type ['number', 'null'] as nullable number", () => {
|
|
194
|
-
const jsonSchema = {
|
|
195
|
-
type: "object",
|
|
196
|
-
properties: {
|
|
197
|
-
score: {
|
|
198
|
-
type: ["number", "null"],
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
required: ["score"],
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
205
|
-
const shape = (result as z.ZodObject<any>).shape;
|
|
206
|
-
|
|
207
|
-
expect(shape.score.safeParse(42).success).toBe(true);
|
|
208
|
-
expect(shape.score.safeParse(null).success).toBe(true);
|
|
209
|
-
expect(shape.score.safeParse("hello").success).toBe(false);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it("should handle edge case where JSON schema has no required properties", () => {
|
|
213
|
-
const jsonSchema = {
|
|
214
|
-
type: "object",
|
|
215
|
-
properties: {
|
|
216
|
-
name: { type: "string" },
|
|
217
|
-
age: { type: "number" },
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const expectedSchema = z
|
|
222
|
-
.object({
|
|
223
|
-
name: z.string().optional(),
|
|
224
|
-
age: z.number().optional(),
|
|
225
|
-
})
|
|
226
|
-
.optional();
|
|
227
|
-
|
|
228
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, false);
|
|
229
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
230
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
231
|
-
|
|
232
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it("should resolve non-circular $ref definitions correctly", () => {
|
|
236
|
-
const jsonSchema = {
|
|
237
|
-
type: "object",
|
|
238
|
-
properties: {
|
|
239
|
-
address: { $ref: "#/$defs/Address" },
|
|
240
|
-
},
|
|
241
|
-
required: ["address"],
|
|
242
|
-
$defs: {
|
|
243
|
-
Address: {
|
|
244
|
-
type: "object",
|
|
245
|
-
properties: {
|
|
246
|
-
street: { type: "string", description: "Street name" },
|
|
247
|
-
city: { type: "string", description: "City name" },
|
|
248
|
-
},
|
|
249
|
-
required: ["street", "city"],
|
|
250
|
-
description: "A postal address",
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
256
|
-
const resultJson = zodToJsonSchema(result);
|
|
257
|
-
|
|
258
|
-
const expectedSchema = z.object({
|
|
259
|
-
address: z
|
|
260
|
-
.object({
|
|
261
|
-
street: z.string().describe("Street name"),
|
|
262
|
-
city: z.string().describe("City name"),
|
|
263
|
-
})
|
|
264
|
-
.describe("A postal address"),
|
|
265
|
-
});
|
|
266
|
-
const expectedJson = zodToJsonSchema(expectedSchema);
|
|
267
|
-
|
|
268
|
-
expect(resultJson).toStrictEqual(expectedJson);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it("should handle circular $ref without crashing and return z.any()", () => {
|
|
272
|
-
// A schema where Node references itself — this would cause infinite
|
|
273
|
-
// recursion without cycle detection.
|
|
274
|
-
const jsonSchema = {
|
|
275
|
-
type: "object",
|
|
276
|
-
properties: {
|
|
277
|
-
root: { $ref: "#/$defs/Node" },
|
|
278
|
-
},
|
|
279
|
-
required: ["root"],
|
|
280
|
-
$defs: {
|
|
281
|
-
Node: {
|
|
282
|
-
type: "object",
|
|
283
|
-
properties: {
|
|
284
|
-
value: { type: "string", description: "Node value" },
|
|
285
|
-
child: { $ref: "#/$defs/Node" },
|
|
286
|
-
},
|
|
287
|
-
required: ["value"],
|
|
288
|
-
description: "A tree node",
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
294
|
-
|
|
295
|
-
// Must not throw or hang
|
|
296
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
297
|
-
expect(result).toBeDefined();
|
|
298
|
-
|
|
299
|
-
// The circular ref should have produced a console.warn
|
|
300
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
301
|
-
expect.stringContaining("Circular $ref detected"),
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
// The top-level shape should still have a "root" key that is an object
|
|
305
|
-
const shape = (result as z.ZodObject<any>).shape;
|
|
306
|
-
expect(shape.root).toBeDefined();
|
|
307
|
-
|
|
308
|
-
// Inside root, "value" should be a string and "child" should be z.any()
|
|
309
|
-
// (child is optional since it's not in required[], so unwrap ZodOptional)
|
|
310
|
-
const rootShape = (shape.root as z.ZodObject<any>).shape;
|
|
311
|
-
expect(rootShape.value._def.typeName).toBe("ZodString");
|
|
312
|
-
const childDef = rootShape.child._def;
|
|
313
|
-
if (childDef.typeName === "ZodOptional") {
|
|
314
|
-
expect(childDef.innerType._def.typeName).toBe("ZodAny");
|
|
315
|
-
} else {
|
|
316
|
-
expect(childDef.typeName).toBe("ZodAny");
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
warnSpy.mockRestore();
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it("should resolve the same $ref used by multiple sibling properties", () => {
|
|
323
|
-
// Two properties reference the same $def — the visited set must NOT
|
|
324
|
-
// mark the second usage as circular.
|
|
325
|
-
const jsonSchema = {
|
|
326
|
-
type: "object",
|
|
327
|
-
properties: {
|
|
328
|
-
billing: { $ref: "#/$defs/Address" },
|
|
329
|
-
shipping: { $ref: "#/$defs/Address" },
|
|
330
|
-
},
|
|
331
|
-
required: ["billing", "shipping"],
|
|
332
|
-
$defs: {
|
|
333
|
-
Address: {
|
|
334
|
-
type: "object",
|
|
335
|
-
properties: {
|
|
336
|
-
street: { type: "string", description: "Street" },
|
|
337
|
-
city: { type: "string", description: "City" },
|
|
338
|
-
},
|
|
339
|
-
required: ["street", "city"],
|
|
340
|
-
description: "An address",
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
346
|
-
|
|
347
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
348
|
-
const shape = (result as z.ZodObject<any>).shape;
|
|
349
|
-
|
|
350
|
-
// Both should be fully resolved objects, NOT z.any()
|
|
351
|
-
expect(shape.billing._def.typeName).toBe("ZodObject");
|
|
352
|
-
expect(shape.shipping._def.typeName).toBe("ZodObject");
|
|
353
|
-
|
|
354
|
-
// No circular-ref warning should have been emitted
|
|
355
|
-
expect(warnSpy).not.toHaveBeenCalled();
|
|
356
|
-
|
|
357
|
-
warnSpy.mockRestore();
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it("should resolve a shared $ref used in different branches of a $ref chain", () => {
|
|
361
|
-
// Wrapper -> Container (via $ref) which has two children both using $ref to Leaf.
|
|
362
|
-
// Without set cloning, the second Leaf ref in Container would be wrongly flagged
|
|
363
|
-
// as circular because the first Leaf resolution already added it to the set.
|
|
364
|
-
const jsonSchema = {
|
|
365
|
-
type: "object",
|
|
366
|
-
properties: {
|
|
367
|
-
wrapper: { $ref: "#/$defs/Container" },
|
|
368
|
-
},
|
|
369
|
-
required: ["wrapper"],
|
|
370
|
-
$defs: {
|
|
371
|
-
Container: {
|
|
372
|
-
type: "object",
|
|
373
|
-
properties: {
|
|
374
|
-
first: { $ref: "#/$defs/Leaf" },
|
|
375
|
-
second: { $ref: "#/$defs/Leaf" },
|
|
376
|
-
},
|
|
377
|
-
required: ["first", "second"],
|
|
378
|
-
description: "A container with two leaves",
|
|
379
|
-
},
|
|
380
|
-
Leaf: {
|
|
381
|
-
type: "object",
|
|
382
|
-
properties: {
|
|
383
|
-
label: { type: "string", description: "Leaf label" },
|
|
384
|
-
},
|
|
385
|
-
required: ["label"],
|
|
386
|
-
description: "A leaf node",
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
392
|
-
|
|
393
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
394
|
-
const wrapperShape = (
|
|
395
|
-
(result as z.ZodObject<any>).shape.wrapper as z.ZodObject<any>
|
|
396
|
-
).shape;
|
|
397
|
-
|
|
398
|
-
// Both first and second should be fully resolved Leaf objects
|
|
399
|
-
expect(wrapperShape.first._def.typeName).toBe("ZodObject");
|
|
400
|
-
expect(wrapperShape.second._def.typeName).toBe("ZodObject");
|
|
401
|
-
|
|
402
|
-
// No circular-ref warning should have been emitted
|
|
403
|
-
expect(warnSpy).not.toHaveBeenCalled();
|
|
404
|
-
|
|
405
|
-
warnSpy.mockRestore();
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
it("should handle anyOf with $ref variants", () => {
|
|
409
|
-
const jsonSchema = {
|
|
410
|
-
type: "object",
|
|
411
|
-
properties: {
|
|
412
|
-
pet: {
|
|
413
|
-
anyOf: [{ $ref: "#/$defs/Cat" }, { $ref: "#/$defs/Dog" }],
|
|
414
|
-
description: "A pet",
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
required: ["pet"],
|
|
418
|
-
$defs: {
|
|
419
|
-
Cat: {
|
|
420
|
-
type: "object",
|
|
421
|
-
properties: { meow: { type: "boolean" } },
|
|
422
|
-
required: ["meow"],
|
|
423
|
-
},
|
|
424
|
-
Dog: {
|
|
425
|
-
type: "object",
|
|
426
|
-
properties: { bark: { type: "boolean" } },
|
|
427
|
-
required: ["bark"],
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
433
|
-
expect(result).toBeDefined();
|
|
434
|
-
|
|
435
|
-
// Should produce a union inside the "pet" property
|
|
436
|
-
const petSchema = (result as z.ZodObject<any>).shape.pet;
|
|
437
|
-
expect(petSchema._def.typeName).toBe("ZodUnion");
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it("should handle integer type as z.number()", () => {
|
|
441
|
-
const jsonSchema = {
|
|
442
|
-
type: "object",
|
|
443
|
-
properties: {
|
|
444
|
-
count: { type: "integer", description: "A count" },
|
|
445
|
-
},
|
|
446
|
-
required: ["count"],
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
450
|
-
const shape = (result as z.ZodObject<any>).shape;
|
|
451
|
-
expect(shape.count._def.typeName).toBe("ZodNumber");
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it("should handle null type", () => {
|
|
455
|
-
const jsonSchema = {
|
|
456
|
-
type: "object",
|
|
457
|
-
properties: {
|
|
458
|
-
empty: { type: "null", description: "Always null" },
|
|
459
|
-
},
|
|
460
|
-
required: ["empty"],
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
464
|
-
const shape = (result as z.ZodObject<any>).shape;
|
|
465
|
-
expect(shape.empty._def.typeName).toBe("ZodNull");
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
it("should warn and return z.any() for unsupported schema types", () => {
|
|
469
|
-
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
470
|
-
|
|
471
|
-
const jsonSchema = { type: "custom_unsupported" };
|
|
472
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
473
|
-
|
|
474
|
-
expect(result._def.typeName).toBe("ZodAny");
|
|
475
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
476
|
-
expect.stringContaining(
|
|
477
|
-
'Unsupported JSON schema type "custom_unsupported"',
|
|
478
|
-
),
|
|
479
|
-
);
|
|
480
|
-
|
|
481
|
-
warnSpy.mockRestore();
|
|
482
|
-
});
|
|
483
|
-
});
|
|
7
|
+
import type { Parameter } from "../../types";
|
|
484
8
|
|
|
485
9
|
describe("jsonSchemaToActionParameters", () => {
|
|
486
10
|
it("should convert a simple JSONSchema to Parameter array", () => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { randomId, randomUUID } from "../random-id";
|
|
3
|
+
|
|
4
|
+
const UUID_V4 =
|
|
5
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6
|
+
|
|
7
|
+
describe("randomUUID", () => {
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
vi.unstubAllGlobals();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("returns crypto.randomUUID() when it exists", () => {
|
|
13
|
+
vi.stubGlobal("crypto", {
|
|
14
|
+
randomUUID: () => "11111111-2222-4333-8444-555555555555",
|
|
15
|
+
});
|
|
16
|
+
expect(randomUUID()).toBe("11111111-2222-4333-8444-555555555555");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("builds a v4 UUID from getRandomValues when randomUUID is missing", () => {
|
|
20
|
+
vi.stubGlobal("crypto", {
|
|
21
|
+
getRandomValues: (bytes: Uint8Array) => bytes.fill(0xff),
|
|
22
|
+
});
|
|
23
|
+
const id = randomUUID();
|
|
24
|
+
expect(id).toBe("ffffffff-ffff-4fff-bfff-ffffffffffff");
|
|
25
|
+
expect(id).toMatch(UUID_V4);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("throws a clear error when the runtime has no crypto", () => {
|
|
29
|
+
vi.stubGlobal("crypto", undefined);
|
|
30
|
+
expect(() => randomUUID()).toThrow(/getRandomValues/);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("prefixes randomId with ck-", () => {
|
|
34
|
+
expect(randomId()).toMatch(/^ck-/);
|
|
35
|
+
expect(randomId().slice(3)).toMatch(UUID_V4);
|
|
36
|
+
});
|
|
37
|
+
});
|