@copilotkit/shared 2.0.0-next.1 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +93 -12
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/a2ui-envelope.cjs +154 -0
- package/dist/a2ui-envelope.cjs.map +1 -0
- package/dist/a2ui-envelope.d.cts +101 -0
- package/dist/a2ui-envelope.d.cts.map +1 -0
- package/dist/a2ui-envelope.d.mts +101 -0
- package/dist/a2ui-envelope.d.mts.map +1 -0
- package/dist/a2ui-envelope.mjs +151 -0
- package/dist/a2ui-envelope.mjs.map +1 -0
- package/dist/a2ui-prompts.cjs +259 -0
- package/dist/a2ui-prompts.cjs.map +1 -0
- package/dist/a2ui-prompts.d.cts +79 -0
- package/dist/a2ui-prompts.d.cts.map +1 -0
- package/dist/a2ui-prompts.d.mts +79 -0
- package/dist/a2ui-prompts.d.mts.map +1 -0
- package/dist/a2ui-prompts.mjs +251 -0
- package/dist/a2ui-prompts.mjs.map +1 -0
- package/dist/attachments/content.cjs +17 -0
- package/dist/attachments/content.cjs.map +1 -0
- package/dist/attachments/content.d.cts +9 -0
- package/dist/attachments/content.d.cts.map +1 -0
- package/dist/attachments/content.d.mts +9 -0
- package/dist/attachments/content.d.mts.map +1 -0
- package/dist/attachments/content.mjs +16 -0
- package/dist/attachments/content.mjs.map +1 -0
- package/dist/attachments/types.d.cts +64 -0
- package/dist/attachments/types.d.cts.map +1 -0
- package/dist/attachments/types.d.mts +64 -0
- package/dist/attachments/types.d.mts.map +1 -0
- package/dist/attachments/utils.cjs +137 -0
- package/dist/attachments/utils.cjs.map +1 -0
- package/dist/attachments/utils.d.cts +44 -0
- package/dist/attachments/utils.d.cts.map +1 -0
- package/dist/attachments/utils.d.mts +44 -0
- package/dist/attachments/utils.d.mts.map +1 -0
- package/dist/attachments/utils.mjs +129 -0
- package/dist/attachments/utils.mjs.map +1 -0
- package/dist/constants/index.cjs +25 -0
- package/dist/constants/index.cjs.map +1 -0
- package/dist/constants/index.d.cts +17 -0
- package/dist/constants/index.d.cts.map +1 -0
- package/dist/constants/index.d.mts +17 -0
- package/dist/constants/index.d.mts.map +1 -0
- package/dist/constants/index.mjs +17 -12
- package/dist/constants/index.mjs.map +1 -1
- package/dist/debug-event-envelope.d.cts +13 -0
- package/dist/debug-event-envelope.d.cts.map +1 -0
- package/dist/debug-event-envelope.d.mts +13 -0
- package/dist/debug-event-envelope.d.mts.map +1 -0
- package/dist/debug.cjs +38 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.d.cts +29 -0
- package/dist/debug.d.cts.map +1 -0
- package/dist/debug.d.mts +29 -0
- package/dist/debug.d.mts.map +1 -0
- package/dist/debug.mjs +37 -0
- package/dist/debug.mjs.map +1 -0
- package/dist/event-transforms/index.cjs +15 -0
- package/dist/event-transforms/index.d.cts +4 -0
- package/dist/event-transforms/index.d.mts +4 -0
- package/dist/event-transforms/index.mjs +5 -0
- package/dist/event-transforms/open-generative-ui-middleware.cjs +286 -0
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +60 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +60 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
- package/dist/event-transforms/open-generative-ui-middleware.mjs +283 -0
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
- package/dist/event-transforms/recorded-events.cjs +59 -0
- package/dist/event-transforms/recorded-events.cjs.map +1 -0
- package/dist/event-transforms/recorded-events.d.cts +23 -0
- package/dist/event-transforms/recorded-events.d.cts.map +1 -0
- package/dist/event-transforms/recorded-events.d.mts +23 -0
- package/dist/event-transforms/recorded-events.d.mts.map +1 -0
- package/dist/event-transforms/recorded-events.mjs +58 -0
- package/dist/event-transforms/recorded-events.mjs.map +1 -0
- package/dist/finalize-events.cjs +186 -0
- package/dist/finalize-events.cjs.map +1 -0
- package/dist/finalize-events.d.cts +40 -0
- package/dist/finalize-events.d.cts.map +1 -0
- package/dist/finalize-events.d.mts +40 -0
- package/dist/finalize-events.d.mts.map +1 -0
- package/dist/finalize-events.mjs +184 -0
- package/dist/finalize-events.mjs.map +1 -0
- package/dist/generative-ui/basic-functions.cjs +177 -0
- package/dist/generative-ui/basic-functions.cjs.map +1 -0
- package/dist/generative-ui/basic-functions.d.cts +108 -0
- package/dist/generative-ui/basic-functions.d.cts.map +1 -0
- package/dist/generative-ui/basic-functions.d.mts +108 -0
- package/dist/generative-ui/basic-functions.d.mts.map +1 -0
- package/dist/generative-ui/basic-functions.mjs +167 -0
- package/dist/generative-ui/basic-functions.mjs.map +1 -0
- package/dist/generative-ui/child-refs.cjs +161 -0
- package/dist/generative-ui/child-refs.cjs.map +1 -0
- package/dist/generative-ui/child-refs.d.cts +68 -0
- package/dist/generative-ui/child-refs.d.cts.map +1 -0
- package/dist/generative-ui/child-refs.d.mts +68 -0
- package/dist/generative-ui/child-refs.d.mts.map +1 -0
- package/dist/generative-ui/child-refs.mjs +152 -0
- package/dist/generative-ui/child-refs.mjs.map +1 -0
- package/dist/generative-ui/is-record.cjs +10 -0
- package/dist/generative-ui/is-record.cjs.map +1 -0
- package/dist/generative-ui/is-record.mjs +9 -0
- package/dist/generative-ui/is-record.mjs.map +1 -0
- package/dist/generative-ui/prompt.cjs +91 -0
- package/dist/generative-ui/prompt.cjs.map +1 -0
- package/dist/generative-ui/prompt.d.cts +13 -0
- package/dist/generative-ui/prompt.d.cts.map +1 -0
- package/dist/generative-ui/prompt.d.mts +13 -0
- package/dist/generative-ui/prompt.d.mts.map +1 -0
- package/dist/generative-ui/prompt.mjs +90 -0
- package/dist/generative-ui/prompt.mjs.map +1 -0
- package/dist/generative-ui/render-ui-args.cjs +160 -0
- package/dist/generative-ui/render-ui-args.cjs.map +1 -0
- package/dist/generative-ui/render-ui-args.d.cts +40 -0
- package/dist/generative-ui/render-ui-args.d.cts.map +1 -0
- package/dist/generative-ui/render-ui-args.d.mts +40 -0
- package/dist/generative-ui/render-ui-args.d.mts.map +1 -0
- package/dist/generative-ui/render-ui-args.mjs +159 -0
- package/dist/generative-ui/render-ui-args.mjs.map +1 -0
- package/dist/generative-ui/types.cjs +101 -0
- package/dist/generative-ui/types.cjs.map +1 -0
- package/dist/generative-ui/types.d.cts +270 -0
- package/dist/generative-ui/types.d.cts.map +1 -0
- package/dist/generative-ui/types.d.mts +270 -0
- package/dist/generative-ui/types.d.mts.map +1 -0
- package/dist/generative-ui/types.mjs +86 -0
- package/dist/generative-ui/types.mjs.map +1 -0
- package/dist/generative-ui/validate-operation.cjs +405 -0
- package/dist/generative-ui/validate-operation.cjs.map +1 -0
- package/dist/generative-ui/validate-operation.d.cts +86 -0
- package/dist/generative-ui/validate-operation.d.cts.map +1 -0
- package/dist/generative-ui/validate-operation.d.mts +86 -0
- package/dist/generative-ui/validate-operation.d.mts.map +1 -0
- package/dist/generative-ui/validate-operation.mjs +399 -0
- package/dist/generative-ui/validate-operation.mjs.map +1 -0
- package/dist/index.cjs +233 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +80 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +80 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +78 -123
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +3979 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/intelligence-routing-fields.cjs +35 -0
- package/dist/intelligence-routing-fields.cjs.map +1 -0
- package/dist/intelligence-routing-fields.d.cts +18 -0
- package/dist/intelligence-routing-fields.d.cts.map +1 -0
- package/dist/intelligence-routing-fields.d.mts +18 -0
- package/dist/intelligence-routing-fields.d.mts.map +1 -0
- package/dist/intelligence-routing-fields.mjs +34 -0
- package/dist/intelligence-routing-fields.mjs.map +1 -0
- package/dist/logger.cjs +7 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +5 -0
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +5 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/logger.mjs +6 -0
- package/dist/logger.mjs.map +1 -0
- package/dist/open-generative-ui-prompts.cjs +8 -0
- package/dist/open-generative-ui-prompts.cjs.map +1 -0
- package/dist/open-generative-ui-prompts.d.cts +6 -0
- package/dist/open-generative-ui-prompts.d.cts.map +1 -0
- package/dist/open-generative-ui-prompts.d.mts +6 -0
- package/dist/open-generative-ui-prompts.d.mts.map +1 -0
- package/dist/open-generative-ui-prompts.mjs +7 -0
- package/dist/open-generative-ui-prompts.mjs.map +1 -0
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/standard-schema.cjs +31 -0
- package/dist/standard-schema.cjs.map +1 -0
- package/dist/standard-schema.d.cts +33 -0
- package/dist/standard-schema.d.cts.map +1 -0
- package/dist/standard-schema.d.mts +33 -0
- package/dist/standard-schema.d.mts.map +1 -0
- package/dist/standard-schema.mjs +30 -0
- package/dist/standard-schema.mjs.map +1 -0
- package/dist/telemetry/events.d.cts +72 -0
- package/dist/telemetry/events.d.cts.map +1 -0
- package/dist/telemetry/events.d.mts +72 -0
- package/dist/telemetry/events.d.mts.map +1 -0
- package/dist/telemetry/index.cjs +18 -0
- package/dist/telemetry/index.d.cts +5 -0
- package/dist/telemetry/index.d.mts +5 -0
- package/dist/telemetry/index.mjs +6 -12
- package/dist/telemetry/lambda-client.cjs +91 -0
- package/dist/telemetry/lambda-client.cjs.map +1 -0
- package/dist/telemetry/lambda-client.d.cts +31 -0
- package/dist/telemetry/lambda-client.d.cts.map +1 -0
- package/dist/telemetry/lambda-client.d.mts +31 -0
- package/dist/telemetry/lambda-client.d.mts.map +1 -0
- package/dist/telemetry/lambda-client.mjs +87 -0
- package/dist/telemetry/lambda-client.mjs.map +1 -0
- package/dist/telemetry/model-host.cjs +104 -0
- package/dist/telemetry/model-host.cjs.map +1 -0
- package/dist/telemetry/model-host.d.cts +26 -0
- package/dist/telemetry/model-host.d.cts.map +1 -0
- package/dist/telemetry/model-host.d.mts +26 -0
- package/dist/telemetry/model-host.d.mts.map +1 -0
- package/dist/telemetry/model-host.mjs +102 -0
- package/dist/telemetry/model-host.mjs.map +1 -0
- package/dist/telemetry/sampling.cjs +50 -0
- package/dist/telemetry/sampling.cjs.map +1 -0
- package/dist/telemetry/sampling.d.cts +57 -0
- package/dist/telemetry/sampling.d.cts.map +1 -0
- package/dist/telemetry/sampling.d.mts +57 -0
- package/dist/telemetry/sampling.d.mts.map +1 -0
- package/dist/telemetry/sampling.mjs +44 -0
- package/dist/telemetry/sampling.mjs.map +1 -0
- package/dist/telemetry/telemetry-client.cjs +165 -0
- package/dist/telemetry/telemetry-client.cjs.map +1 -0
- package/dist/telemetry/telemetry-client.d.cts +87 -0
- package/dist/telemetry/telemetry-client.d.cts.map +1 -0
- package/dist/telemetry/telemetry-client.d.mts +87 -0
- package/dist/telemetry/telemetry-client.d.mts.map +1 -0
- package/dist/telemetry/telemetry-client.mjs +162 -9
- package/dist/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +20 -0
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -0
- package/dist/telemetry/telemetry-disabled.d.cts +16 -0
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -0
- package/dist/telemetry/telemetry-disabled.d.mts +16 -0
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -0
- package/dist/telemetry/telemetry-disabled.mjs +19 -0
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -0
- package/dist/telemetry/utils.cjs +14 -0
- package/dist/telemetry/utils.cjs.map +1 -0
- package/dist/telemetry/utils.mjs +12 -8
- package/dist/telemetry/utils.mjs.map +1 -1
- package/dist/transcription-errors.cjs +84 -0
- package/dist/transcription-errors.cjs.map +1 -0
- package/dist/transcription-errors.d.cts +52 -0
- package/dist/transcription-errors.d.cts.map +1 -0
- package/dist/transcription-errors.d.mts +52 -0
- package/dist/transcription-errors.d.mts.map +1 -0
- package/dist/transcription-errors.mjs +82 -0
- package/dist/transcription-errors.mjs.map +1 -0
- package/dist/types/{action.d.ts → action.d.cts} +32 -32
- package/dist/types/action.d.cts.map +1 -0
- package/dist/types/action.d.mts +59 -0
- package/dist/types/action.d.mts.map +1 -0
- package/dist/types/copilot-cloud-config.d.cts +15 -0
- package/dist/types/copilot-cloud-config.d.cts.map +1 -0
- package/dist/types/copilot-cloud-config.d.mts +15 -0
- package/dist/types/copilot-cloud-config.d.mts.map +1 -0
- package/dist/types/error.d.cts +57 -0
- package/dist/types/error.d.cts.map +1 -0
- package/dist/types/error.d.mts +57 -0
- package/dist/types/error.d.mts.map +1 -0
- package/dist/types/message.d.cts +42 -0
- package/dist/types/message.d.cts.map +1 -0
- package/dist/types/message.d.mts +42 -0
- package/dist/types/message.d.mts.map +1 -0
- package/dist/types/openai-assistant.d.cts +55 -0
- package/dist/types/openai-assistant.d.cts.map +1 -0
- package/dist/types/openai-assistant.d.mts +55 -0
- package/dist/types/openai-assistant.d.mts.map +1 -0
- package/dist/types/utility.d.cts +6 -0
- package/dist/types/utility.d.cts.map +1 -0
- package/dist/types/utility.d.mts +6 -0
- package/dist/types/utility.d.mts.map +1 -0
- package/dist/utils/clipboard.cjs +28 -0
- package/dist/utils/clipboard.cjs.map +1 -0
- package/dist/utils/clipboard.d.cts +14 -0
- package/dist/utils/clipboard.d.cts.map +1 -0
- package/dist/utils/clipboard.d.mts +14 -0
- package/dist/utils/clipboard.d.mts.map +1 -0
- package/dist/utils/clipboard.mjs +27 -0
- package/dist/utils/clipboard.mjs.map +1 -0
- package/dist/utils/conditions.cjs +32 -0
- package/dist/utils/conditions.cjs.map +1 -0
- package/dist/utils/{conditions.d.ts → conditions.d.cts} +16 -11
- package/dist/utils/conditions.d.cts.map +1 -0
- package/dist/utils/conditions.d.mts +31 -0
- package/dist/utils/conditions.d.mts.map +1 -0
- package/dist/utils/conditions.mjs +30 -6
- package/dist/utils/conditions.mjs.map +1 -1
- package/dist/utils/console-styling.cjs +91 -0
- package/dist/utils/console-styling.cjs.map +1 -0
- package/dist/utils/console-styling.d.cts +65 -0
- package/dist/utils/console-styling.d.cts.map +1 -0
- package/dist/utils/console-styling.d.mts +65 -0
- package/dist/utils/console-styling.d.mts.map +1 -0
- package/dist/utils/console-styling.mjs +83 -15
- package/dist/utils/console-styling.mjs.map +1 -1
- package/dist/utils/dashboard-url.cjs +19 -0
- package/dist/utils/dashboard-url.cjs.map +1 -0
- package/dist/utils/dashboard-url.mjs +18 -0
- package/dist/utils/dashboard-url.mjs.map +1 -0
- package/dist/utils/errors.cjs +439 -0
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/{errors.d.ts → errors.d.cts} +188 -156
- package/dist/utils/errors.d.cts.map +1 -0
- package/dist/utils/errors.d.mts +312 -0
- package/dist/utils/errors.d.mts.map +1 -0
- package/dist/utils/errors.mjs +416 -63
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +105 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +58 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +58 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +97 -107
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/inspector-learning.cjs +217 -0
- package/dist/utils/inspector-learning.cjs.map +1 -0
- package/dist/utils/inspector-learning.d.cts +104 -0
- package/dist/utils/inspector-learning.d.cts.map +1 -0
- package/dist/utils/inspector-learning.d.mts +104 -0
- package/dist/utils/inspector-learning.d.mts.map +1 -0
- package/dist/utils/inspector-learning.mjs +215 -0
- package/dist/utils/inspector-learning.mjs.map +1 -0
- package/dist/utils/inspector-metadata.cjs +146 -0
- package/dist/utils/inspector-metadata.cjs.map +1 -0
- package/dist/utils/inspector-metadata.d.cts +55 -0
- package/dist/utils/inspector-metadata.d.cts.map +1 -0
- package/dist/utils/inspector-metadata.d.mts +55 -0
- package/dist/utils/inspector-metadata.d.mts.map +1 -0
- package/dist/utils/inspector-metadata.mjs +146 -0
- package/dist/utils/inspector-metadata.mjs.map +1 -0
- package/dist/utils/inspector-visibility.cjs +13 -0
- package/dist/utils/inspector-visibility.cjs.map +1 -0
- package/dist/utils/inspector-visibility.d.cts +18 -0
- package/dist/utils/inspector-visibility.d.cts.map +1 -0
- package/dist/utils/inspector-visibility.d.mts +18 -0
- package/dist/utils/inspector-visibility.d.mts.map +1 -0
- package/dist/utils/inspector-visibility.mjs +12 -0
- package/dist/utils/inspector-visibility.mjs.map +1 -0
- package/dist/utils/json-schema.cjs +215 -0
- package/dist/utils/json-schema.cjs.map +1 -0
- package/dist/utils/{json-schema.d.ts → json-schema.d.cts} +20 -18
- package/dist/utils/json-schema.d.cts.map +1 -0
- package/dist/utils/json-schema.d.mts +36 -0
- package/dist/utils/json-schema.d.mts.map +1 -0
- package/dist/utils/json-schema.mjs +210 -12
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/random-id.cjs +38 -0
- package/dist/utils/random-id.cjs.map +1 -0
- package/dist/utils/{random-id.d.ts → random-id.d.cts} +3 -1
- package/dist/utils/random-id.d.cts.map +1 -0
- package/dist/utils/random-id.d.mts +8 -0
- package/dist/utils/random-id.d.mts.map +1 -0
- package/dist/utils/random-id.mjs +33 -12
- package/dist/utils/random-id.mjs.map +1 -1
- package/dist/utils/requests.cjs +58 -0
- package/dist/utils/requests.cjs.map +1 -0
- package/dist/utils/{requests.d.ts → requests.d.cts} +3 -1
- package/dist/utils/requests.d.cts.map +1 -0
- package/dist/utils/requests.d.mts +12 -0
- package/dist/utils/requests.d.mts.map +1 -0
- package/dist/utils/requests.mjs +56 -6
- package/dist/utils/requests.mjs.map +1 -1
- package/dist/utils/row-render-keys.cjs +206 -0
- package/dist/utils/row-render-keys.cjs.map +1 -0
- package/dist/utils/row-render-keys.d.cts +65 -0
- package/dist/utils/row-render-keys.d.cts.map +1 -0
- package/dist/utils/row-render-keys.d.mts +65 -0
- package/dist/utils/row-render-keys.d.mts.map +1 -0
- package/dist/utils/row-render-keys.mjs +201 -0
- package/dist/utils/row-render-keys.mjs.map +1 -0
- package/dist/utils/types.cjs +9 -0
- package/dist/utils/types.cjs.map +1 -0
- package/dist/utils/types.d.cts +122 -0
- package/dist/utils/types.d.cts.map +1 -0
- package/dist/utils/types.d.mts +122 -0
- package/dist/utils/types.d.mts.map +1 -0
- package/dist/utils/types.mjs +6 -1
- package/dist/utils/types.mjs.map +1 -1
- package/package.json +74 -40
- package/scripts/verify-cjs-exports.cjs +16 -0
- package/src/__tests__/a2ui-envelope.test.ts +434 -0
- package/src/__tests__/a2ui-prompts.test.ts +362 -0
- package/src/__tests__/debug.test.ts +116 -0
- package/src/__tests__/license-context.test.ts +253 -0
- package/src/__tests__/root-entry-browser-safety.test.ts +91 -0
- package/src/__tests__/standard-schema-types.test.ts +144 -0
- package/src/__tests__/standard-schema.test.ts +359 -0
- package/src/__tests__/zod-regression.test.ts +319 -0
- package/src/a2ui-envelope.ts +309 -0
- package/src/a2ui-prompts.ts +322 -0
- package/src/attachments/__tests__/utils.test.ts +214 -0
- package/src/attachments/content.test.ts +48 -0
- package/src/attachments/content.ts +16 -0
- package/src/attachments/index.ts +21 -0
- package/src/attachments/types.ts +77 -0
- package/src/attachments/utils.ts +169 -0
- package/src/constants/index.ts +14 -1
- package/src/debug-event-envelope.ts +9 -0
- package/src/debug.ts +55 -0
- package/src/event-transforms/index.ts +5 -0
- package/src/event-transforms/open-generative-ui-middleware.ts +392 -0
- package/src/event-transforms/recorded-events.test.ts +166 -0
- package/src/event-transforms/recorded-events.ts +74 -0
- package/src/finalize-events.test.ts +284 -0
- package/src/finalize-events.ts +260 -0
- package/src/generative-ui/__tests__/render-ui-args.test.ts +175 -0
- package/src/generative-ui/__tests__/validate-operation.test.ts +977 -0
- package/src/generative-ui/basic-functions.ts +282 -0
- package/src/generative-ui/child-refs.ts +210 -0
- package/src/generative-ui/index.ts +6 -0
- package/src/generative-ui/is-record.ts +4 -0
- package/src/generative-ui/prompt.ts +174 -0
- package/src/generative-ui/render-ui-args.ts +199 -0
- package/src/generative-ui/types.ts +314 -0
- package/src/generative-ui/validate-operation.ts +723 -0
- package/src/index.ts +190 -1
- package/src/intelligence-routing-fields.test.ts +51 -0
- package/src/intelligence-routing-fields.ts +40 -0
- package/src/logger.ts +1 -0
- package/src/open-generative-ui-prompts.ts +20 -0
- package/src/standard-schema.ts +82 -0
- package/src/telemetry/events.ts +37 -10
- package/src/telemetry/index.ts +8 -0
- package/src/telemetry/lambda-client.test.ts +446 -0
- package/src/telemetry/lambda-client.ts +194 -0
- package/src/telemetry/model-host.test.ts +145 -0
- package/src/telemetry/model-host.ts +156 -0
- package/src/telemetry/sampling.test.ts +65 -0
- package/src/telemetry/sampling.ts +103 -0
- package/src/telemetry/telemetry-blank-license-identity.test.ts +128 -0
- package/src/telemetry/telemetry-client.test.ts +798 -0
- package/src/telemetry/telemetry-client.ts +223 -37
- package/src/telemetry/telemetry-disabled.ts +22 -0
- package/src/telemetry/utils.ts +0 -24
- package/src/transcription-errors.ts +99 -0
- package/src/types/__tests__/message.test.ts +62 -0
- package/src/types/action.ts +9 -5
- package/src/types/error.ts +11 -2
- package/src/types/message.ts +33 -5
- package/src/types/openai-assistant.ts +6 -2
- package/src/utils/__tests__/clipboard.test.ts +87 -0
- package/src/utils/__tests__/conditions.test.ts +161 -0
- package/src/utils/__tests__/json-schema.test.ts +812 -0
- package/src/utils/__tests__/row-render-keys.test.ts +388 -0
- package/src/utils/clipboard.ts +23 -0
- package/src/utils/conditions.ts +27 -9
- package/src/utils/console-styling.ts +10 -8
- package/src/utils/dashboard-url.ts +17 -0
- package/src/utils/errors.ts +55 -22
- package/src/utils/index.ts +70 -1
- package/src/utils/inspector-learning.test.ts +423 -0
- package/src/utils/inspector-learning.ts +523 -0
- package/src/utils/inspector-metadata.test.ts +743 -0
- package/src/utils/inspector-metadata.ts +263 -0
- package/src/utils/inspector-visibility.test.ts +43 -0
- package/src/utils/inspector-visibility.ts +17 -0
- package/src/utils/json-schema.ts +156 -12
- package/src/utils/random-id.ts +5 -2
- package/src/utils/requests.ts +3 -1
- package/src/utils/row-render-keys.ts +263 -0
- package/src/utils/types.ts +128 -1
- package/src/utils.test.ts +137 -0
- package/tsconfig.json +10 -2
- package/tsdown.config.ts +49 -0
- package/vitest.config.mjs +11 -0
- package/CHANGELOG.md +0 -1817
- package/dist/chunk-2OJ5OJ2D.mjs +0 -1
- package/dist/chunk-2OJ5OJ2D.mjs.map +0 -1
- package/dist/chunk-64DYJ27R.mjs +0 -201
- package/dist/chunk-64DYJ27R.mjs.map +0 -1
- package/dist/chunk-6QGXWNS5.mjs +0 -34
- package/dist/chunk-6QGXWNS5.mjs.map +0 -1
- package/dist/chunk-6W2UEO2M.mjs +0 -94
- package/dist/chunk-6W2UEO2M.mjs.map +0 -1
- package/dist/chunk-7DJDTRNX.mjs +0 -426
- package/dist/chunk-7DJDTRNX.mjs.map +0 -1
- package/dist/chunk-A66772CV.mjs +0 -107
- package/dist/chunk-A66772CV.mjs.map +0 -1
- package/dist/chunk-BOKE4OKY.mjs +0 -41
- package/dist/chunk-BOKE4OKY.mjs.map +0 -1
- package/dist/chunk-FCCOSO5L.mjs +0 -1
- package/dist/chunk-FCCOSO5L.mjs.map +0 -1
- package/dist/chunk-GYZIHHE6.mjs +0 -13
- package/dist/chunk-GYZIHHE6.mjs.map +0 -1
- package/dist/chunk-IAFBVORQ.mjs +0 -1
- package/dist/chunk-IAFBVORQ.mjs.map +0 -1
- package/dist/chunk-JAAUCDUR.mjs +0 -38
- package/dist/chunk-JAAUCDUR.mjs.map +0 -1
- package/dist/chunk-MSUB6DGR.mjs +0 -1
- package/dist/chunk-MSUB6DGR.mjs.map +0 -1
- package/dist/chunk-N5EP5OD5.mjs +0 -1
- package/dist/chunk-N5EP5OD5.mjs.map +0 -1
- package/dist/chunk-NAFEBKSO.mjs +0 -1
- package/dist/chunk-NAFEBKSO.mjs.map +0 -1
- package/dist/chunk-P7STFMPO.mjs +0 -1
- package/dist/chunk-P7STFMPO.mjs.map +0 -1
- package/dist/chunk-PL5WNHFZ.mjs +0 -50
- package/dist/chunk-PL5WNHFZ.mjs.map +0 -1
- package/dist/chunk-UYARLQNA.mjs +0 -1
- package/dist/chunk-UYARLQNA.mjs.map +0 -1
- package/dist/chunk-XEMZTHQZ.mjs +0 -67
- package/dist/chunk-XEMZTHQZ.mjs.map +0 -1
- package/dist/chunk-XTHC46M2.mjs +0 -1
- package/dist/chunk-XTHC46M2.mjs.map +0 -1
- package/dist/constants/index.d.ts +0 -6
- package/dist/constants/index.js +0 -40
- package/dist/constants/index.js.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -1098
- package/dist/index.js.map +0 -1
- package/dist/telemetry/events.d.ts +0 -45
- package/dist/telemetry/events.js +0 -19
- package/dist/telemetry/events.js.map +0 -1
- package/dist/telemetry/events.mjs +0 -1
- package/dist/telemetry/events.mjs.map +0 -1
- package/dist/telemetry/index.d.ts +0 -3
- package/dist/telemetry/index.js +0 -188
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/index.mjs.map +0 -1
- package/dist/telemetry/scarf-client.d.ts +0 -7
- package/dist/telemetry/scarf-client.js +0 -59
- package/dist/telemetry/scarf-client.js.map +0 -1
- package/dist/telemetry/scarf-client.mjs +0 -7
- package/dist/telemetry/scarf-client.mjs.map +0 -1
- package/dist/telemetry/security-check.d.ts +0 -2
- package/dist/telemetry/security-check.js +0 -2
- package/dist/telemetry/security-check.js.map +0 -1
- package/dist/telemetry/security-check.mjs +0 -1
- package/dist/telemetry/security-check.mjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.ts +0 -40
- package/dist/telemetry/telemetry-client.js +0 -186
- package/dist/telemetry/telemetry-client.js.map +0 -1
- package/dist/telemetry/utils.d.ts +0 -8
- package/dist/telemetry/utils.js +0 -69
- package/dist/telemetry/utils.js.map +0 -1
- package/dist/types/action.js +0 -19
- package/dist/types/action.js.map +0 -1
- package/dist/types/action.mjs +0 -2
- package/dist/types/action.mjs.map +0 -1
- package/dist/types/copilot-cloud-config.d.ts +0 -13
- package/dist/types/copilot-cloud-config.js +0 -19
- package/dist/types/copilot-cloud-config.js.map +0 -1
- package/dist/types/copilot-cloud-config.mjs +0 -2
- package/dist/types/copilot-cloud-config.mjs.map +0 -1
- package/dist/types/error.d.ts +0 -55
- package/dist/types/error.js +0 -19
- package/dist/types/error.js.map +0 -1
- package/dist/types/error.mjs +0 -2
- package/dist/types/error.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -19
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -8
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/message.d.ts +0 -26
- package/dist/types/message.js +0 -19
- package/dist/types/message.js.map +0 -1
- package/dist/types/message.mjs +0 -2
- package/dist/types/message.mjs.map +0 -1
- package/dist/types/openai-assistant.d.ts +0 -53
- package/dist/types/openai-assistant.js +0 -19
- package/dist/types/openai-assistant.js.map +0 -1
- package/dist/types/openai-assistant.mjs +0 -2
- package/dist/types/openai-assistant.mjs.map +0 -1
- package/dist/types/utility.d.ts +0 -6
- package/dist/types/utility.js +0 -19
- package/dist/types/utility.js.map +0 -1
- package/dist/types/utility.mjs +0 -2
- package/dist/types/utility.mjs.map +0 -1
- package/dist/utils/conditions.js +0 -74
- package/dist/utils/conditions.js.map +0 -1
- package/dist/utils/console-styling.d.ts +0 -84
- package/dist/utils/console-styling.js +0 -123
- package/dist/utils/console-styling.js.map +0 -1
- package/dist/utils/errors.js +0 -443
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -32
- package/dist/utils/index.js +0 -927
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/json-schema.js +0 -228
- package/dist/utils/json-schema.js.map +0 -1
- package/dist/utils/random-id.js +0 -68
- package/dist/utils/random-id.js.map +0 -1
- package/dist/utils/requests.js +0 -91
- package/dist/utils/requests.js.map +0 -1
- package/dist/utils/types.d.ts +0 -20
- package/dist/utils/types.js +0 -19
- package/dist/utils/types.js.map +0 -1
- package/jest.config.js +0 -5
- package/src/telemetry/scarf-client.ts +0 -39
- package/src/telemetry/security-check.ts +0 -0
- package/src/utils/json-schema.test.ts +0 -383
- package/tsup.config.ts +0 -11
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/generative-ui/basic-functions.ts
|
|
3
|
+
/**
|
|
4
|
+
* The callers of an app function that names none: the renderer only, as
|
|
5
|
+
* in A2UI 1.0. The agent calls a function with `callRendererFunction` only
|
|
6
|
+
* when its declaration allows it (`"rendererOrAgent"` or `"agentOnly"`).
|
|
7
|
+
* The manifests and the exported catalog write the value out.
|
|
8
|
+
*/
|
|
9
|
+
const GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS = "rendererOnly";
|
|
10
|
+
/**
|
|
11
|
+
* Who may call a function, from its permissions. A function that needs a
|
|
12
|
+
* user gesture is for the renderer only, whatever `allowedCallers` says.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* functionCallers({}); // { renderer: true, agent: true }
|
|
17
|
+
* functionCallers({ allowedCallers: "rendererOnly" }); // { renderer: true, agent: false }
|
|
18
|
+
* functionCallers({ requiresUserActivation: true }); // { renderer: true, agent: false }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function functionCallers(fn) {
|
|
22
|
+
if (fn.requiresUserActivation) return {
|
|
23
|
+
renderer: true,
|
|
24
|
+
agent: false
|
|
25
|
+
};
|
|
26
|
+
const callers = fn.allowedCallers ?? GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS;
|
|
27
|
+
return {
|
|
28
|
+
renderer: callers !== "agentOnly",
|
|
29
|
+
agent: callers !== "rendererOnly"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Marks a table of built-in functions as callable by the renderer only. */
|
|
33
|
+
function rendererOnly(functions) {
|
|
34
|
+
return Object.fromEntries(Object.entries(functions).map(([name, info]) => [name, {
|
|
35
|
+
...info,
|
|
36
|
+
allowedCallers: "rendererOnly"
|
|
37
|
+
}]));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The basic functions by name. A `{"@call"}` in a prop, in an event
|
|
41
|
+
* binding, or in a `callRendererFunction` may name any of them without a
|
|
42
|
+
* declaration in `createGenerativeUI({ functions })`.
|
|
43
|
+
*/
|
|
44
|
+
const A2UI_BASIC_FUNCTIONS = rendererOnly({
|
|
45
|
+
required: {
|
|
46
|
+
description: "Valid when the value is not empty",
|
|
47
|
+
parameters: "{ value: unknown }",
|
|
48
|
+
returnType: "validationResult"
|
|
49
|
+
},
|
|
50
|
+
regex: {
|
|
51
|
+
description: "Valid when the value matches the pattern",
|
|
52
|
+
parameters: "{ value: string; pattern: string }",
|
|
53
|
+
returnType: "validationResult"
|
|
54
|
+
},
|
|
55
|
+
length: {
|
|
56
|
+
description: "Valid when the length of the value is within min and max",
|
|
57
|
+
parameters: "{ value: string; min?: number; max?: number }",
|
|
58
|
+
returnType: "validationResult"
|
|
59
|
+
},
|
|
60
|
+
numeric: {
|
|
61
|
+
description: "Valid when the value is a number within min and max",
|
|
62
|
+
parameters: "{ value: number; min?: number; max?: number }",
|
|
63
|
+
returnType: "validationResult"
|
|
64
|
+
},
|
|
65
|
+
email: {
|
|
66
|
+
description: "Valid when the value is an email address",
|
|
67
|
+
parameters: "{ value: string }",
|
|
68
|
+
returnType: "validationResult"
|
|
69
|
+
},
|
|
70
|
+
formatString: {
|
|
71
|
+
description: "Interpolates ${/path}, ${relative/path} and ${fn(arg: value)} in the value; \\${ is a literal",
|
|
72
|
+
parameters: "{ value: string }",
|
|
73
|
+
returnType: "string"
|
|
74
|
+
},
|
|
75
|
+
formatNumber: {
|
|
76
|
+
description: "The number in the locale of the user",
|
|
77
|
+
parameters: "{ value: number; decimals?: number; grouping?: boolean }",
|
|
78
|
+
returnType: "string"
|
|
79
|
+
},
|
|
80
|
+
formatCurrency: {
|
|
81
|
+
description: "The amount as money, with an ISO 4217 currency code",
|
|
82
|
+
parameters: "{ value: number; currency: string; decimals?: number; grouping?: boolean }",
|
|
83
|
+
returnType: "string"
|
|
84
|
+
},
|
|
85
|
+
formatDate: {
|
|
86
|
+
description: "A date or ISO string in a TR35 pattern, for example \"MMM d, yyyy\" or \"HH:mm\"",
|
|
87
|
+
parameters: "{ value: string | number; format: string }",
|
|
88
|
+
returnType: "string"
|
|
89
|
+
},
|
|
90
|
+
pluralize: {
|
|
91
|
+
description: "The string of the plural category of the value",
|
|
92
|
+
parameters: "{ value: number; zero?: string; one?: string; two?: string; few?: string; many?: string; other: string }",
|
|
93
|
+
returnType: "string"
|
|
94
|
+
},
|
|
95
|
+
openUrl: {
|
|
96
|
+
description: "Opens an http(s) URL in a new tab. Only from an event",
|
|
97
|
+
parameters: "{ url: string }",
|
|
98
|
+
returnType: "void",
|
|
99
|
+
requiresUserActivation: true
|
|
100
|
+
},
|
|
101
|
+
and: {
|
|
102
|
+
description: "True when every value is true",
|
|
103
|
+
parameters: "{ values: boolean[] }",
|
|
104
|
+
returnType: "boolean"
|
|
105
|
+
},
|
|
106
|
+
or: {
|
|
107
|
+
description: "True when any value is true",
|
|
108
|
+
parameters: "{ values: boolean[] }",
|
|
109
|
+
returnType: "boolean"
|
|
110
|
+
},
|
|
111
|
+
not: {
|
|
112
|
+
description: "The negated value",
|
|
113
|
+
parameters: "{ value: boolean }",
|
|
114
|
+
returnType: "boolean"
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* The value functions that CopilotKit adds to the basic catalog, because
|
|
119
|
+
* A2UI 1.0 has no arithmetic: `calc` evaluates an expression over named
|
|
120
|
+
* args, and `series` builds a computed list. A catalog may declare its own
|
|
121
|
+
* functions in A2UI, so these are regular catalog functions to the model;
|
|
122
|
+
* a renderer without them rejects the call instead of misrendering.
|
|
123
|
+
*/
|
|
124
|
+
const COPILOTKIT_FUNCTIONS = rendererOnly({
|
|
125
|
+
calc: {
|
|
126
|
+
description: "The value of an arithmetic expression over the other args, by name: + - * / % ( ), comparisons, && || !, cond ? a : b, min max round floor ceil abs, 'text' + name",
|
|
127
|
+
parameters: "{ expression: string; [name: string]: number | string | boolean }",
|
|
128
|
+
returnType: "any",
|
|
129
|
+
extension: true
|
|
130
|
+
},
|
|
131
|
+
series: {
|
|
132
|
+
description: "A list of count copies of item, for chart data and template lists. Put arithmetic in ${expression} strings in item, using the loop variable (default i, counting from start, default 1) and other named args. A whole-expression string retains the result type, so \"${i * monthlyCost}\" yields a number. Arguments, including nested calc or formatString calls in item, resolve before the series loop; those calls cannot use the loop variable. Example: {\"@call\":\"series\",\"args\":{\"count\":6,\"item\":{\"month\":\"${i}\",\"cost\":\"${i * monthlyCost}\"},\"monthlyCost\":{\"@path\":\"/monthlyCost\"}}}. Omit variable to use i.",
|
|
133
|
+
parameters: "{ count: number; item: unknown; variable?: string; start?: number; [name: string]: unknown }",
|
|
134
|
+
returnType: "array",
|
|
135
|
+
extension: true
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
/** Every function a `{"@call"}` may name without a declaration: basic and CopilotKit. */
|
|
139
|
+
const GENERATIVE_UI_FUNCTIONS = {
|
|
140
|
+
...A2UI_BASIC_FUNCTIONS,
|
|
141
|
+
...COPILOTKIT_FUNCTIONS
|
|
142
|
+
};
|
|
143
|
+
/** The name of the system function that gives the index of a template item. */
|
|
144
|
+
const A2UI_INDEX_FUNCTION = "@index";
|
|
145
|
+
/** True for a built-in function name: basic, CopilotKit, or `@index`. */
|
|
146
|
+
function isA2UIBasicFunction(name) {
|
|
147
|
+
return name === A2UI_INDEX_FUNCTION || Object.prototype.hasOwnProperty.call(GENERATIVE_UI_FUNCTIONS, name);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* True for a built-in function that a prop or a check may call: every one
|
|
151
|
+
* except the functions that need a user gesture.
|
|
152
|
+
*/
|
|
153
|
+
function isA2UIValueFunction(name) {
|
|
154
|
+
if (name === A2UI_INDEX_FUNCTION) return true;
|
|
155
|
+
const info = Object.prototype.hasOwnProperty.call(GENERATIVE_UI_FUNCTIONS, name) ? GENERATIVE_UI_FUNCTIONS[name] : void 0;
|
|
156
|
+
return info !== void 0 && !info.requiresUserActivation;
|
|
157
|
+
}
|
|
158
|
+
/** `{ "@call": "<name>", "args"?: {...} }`: a function call value. */
|
|
159
|
+
function isCallBinding(value) {
|
|
160
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value["@call"] === "string";
|
|
161
|
+
}
|
|
162
|
+
function isValidationResult(value) {
|
|
163
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value.valid === "boolean";
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
exports.A2UI_BASIC_FUNCTIONS = A2UI_BASIC_FUNCTIONS;
|
|
168
|
+
exports.A2UI_INDEX_FUNCTION = A2UI_INDEX_FUNCTION;
|
|
169
|
+
exports.COPILOTKIT_FUNCTIONS = COPILOTKIT_FUNCTIONS;
|
|
170
|
+
exports.GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS = GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS;
|
|
171
|
+
exports.GENERATIVE_UI_FUNCTIONS = GENERATIVE_UI_FUNCTIONS;
|
|
172
|
+
exports.functionCallers = functionCallers;
|
|
173
|
+
exports.isA2UIBasicFunction = isA2UIBasicFunction;
|
|
174
|
+
exports.isA2UIValueFunction = isA2UIValueFunction;
|
|
175
|
+
exports.isCallBinding = isCallBinding;
|
|
176
|
+
exports.isValidationResult = isValidationResult;
|
|
177
|
+
//# sourceMappingURL=basic-functions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-functions.cjs","names":[],"sources":["../../src/generative-ui/basic-functions.ts"],"sourcesContent":["/**\n * The functions of the A2UI 1.0 basic catalog, as the model and the\n * validator see them. The renderer implements them (react-core\n * `generative-ui/functions.ts`); this file holds only what both sides share:\n * the names, the short signatures for the schema the model reads, and who\n * may call each one.\n */\n\n/** What a function gives back, as A2UI 1.0 names it. */\nexport type A2UIFunctionReturnType =\n | \"string\"\n | \"number\"\n | \"boolean\"\n | \"array\"\n | \"object\"\n | \"validationResult\"\n | \"any\"\n | \"void\";\n\n/**\n * Who may call a function. The renderer calls it from an event binding or\n * as a prop value; the agent calls it with `callRendererFunction`.\n */\nexport type A2UIAllowedCallers =\n | \"rendererOnly\"\n | \"agentOnly\"\n | \"rendererOrAgent\";\n\n/**\n * The callers of an app function that names none: the renderer only, as\n * in A2UI 1.0. The agent calls a function with `callRendererFunction` only\n * when its declaration allows it (`\"rendererOrAgent\"` or `\"agentOnly\"`).\n * The manifests and the exported catalog write the value out.\n */\nexport const GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS: A2UIAllowedCallers =\n \"rendererOnly\";\n\n/** The A2UI 1.0 interface fields of a function: who calls it, and how. */\nexport interface A2UIFunctionPermissions {\n allowedCallers?: A2UIAllowedCallers;\n /**\n * True for a function that only runs from a user gesture (a click, a key\n * press). It is `rendererOnly`: the agent cannot call it, and a prop\n * cannot be bound to it.\n */\n requiresUserActivation?: boolean;\n}\n\n/**\n * Who may call a function, from its permissions. A function that needs a\n * user gesture is for the renderer only, whatever `allowedCallers` says.\n *\n * @example\n * ```ts\n * functionCallers({}); // { renderer: true, agent: true }\n * functionCallers({ allowedCallers: \"rendererOnly\" }); // { renderer: true, agent: false }\n * functionCallers({ requiresUserActivation: true }); // { renderer: true, agent: false }\n * ```\n */\nexport function functionCallers(fn: A2UIFunctionPermissions) {\n if (fn.requiresUserActivation) return { renderer: true, agent: false };\n const callers = fn.allowedCallers ?? GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS;\n return {\n renderer: callers !== \"agentOnly\",\n agent: callers !== \"rendererOnly\",\n };\n}\n\nexport interface A2UIBasicFunctionInfo extends A2UIFunctionPermissions {\n description: string;\n /** The args, as a short TypeScript-like type for the compact schema. */\n parameters: string;\n returnType: A2UIFunctionReturnType;\n /** Built-in functions are value functions of the renderer. */\n allowedCallers: \"rendererOnly\";\n requiresUserActivation?: true;\n /** True for a CopilotKit function that the A2UI basic catalog lacks. */\n extension?: true;\n}\n\n/** Marks a table of built-in functions as callable by the renderer only. */\nfunction rendererOnly<Name extends string>(\n functions: Record<Name, Omit<A2UIBasicFunctionInfo, \"allowedCallers\">>,\n): Readonly<Record<Name, A2UIBasicFunctionInfo>> {\n return Object.fromEntries(\n Object.entries<Omit<A2UIBasicFunctionInfo, \"allowedCallers\">>(\n functions,\n ).map(([name, info]) => [\n name,\n { ...info, allowedCallers: \"rendererOnly\" },\n ]),\n ) as Record<Name, A2UIBasicFunctionInfo>;\n}\n\n/**\n * The basic functions by name. A `{\"@call\"}` in a prop, in an event\n * binding, or in a `callRendererFunction` may name any of them without a\n * declaration in `createGenerativeUI({ functions })`.\n */\nexport const A2UI_BASIC_FUNCTIONS: Readonly<\n Record<string, A2UIBasicFunctionInfo>\n> = rendererOnly({\n required: {\n description: \"Valid when the value is not empty\",\n parameters: \"{ value: unknown }\",\n returnType: \"validationResult\",\n },\n regex: {\n description: \"Valid when the value matches the pattern\",\n parameters: \"{ value: string; pattern: string }\",\n returnType: \"validationResult\",\n },\n length: {\n description: \"Valid when the length of the value is within min and max\",\n parameters: \"{ value: string; min?: number; max?: number }\",\n returnType: \"validationResult\",\n },\n numeric: {\n description: \"Valid when the value is a number within min and max\",\n parameters: \"{ value: number; min?: number; max?: number }\",\n returnType: \"validationResult\",\n },\n email: {\n description: \"Valid when the value is an email address\",\n parameters: \"{ value: string }\",\n returnType: \"validationResult\",\n },\n formatString: {\n description:\n \"Interpolates ${/path}, ${relative/path} and ${fn(arg: value)} in the value; \\\\${ is a literal\",\n parameters: \"{ value: string }\",\n returnType: \"string\",\n },\n formatNumber: {\n description: \"The number in the locale of the user\",\n parameters: \"{ value: number; decimals?: number; grouping?: boolean }\",\n returnType: \"string\",\n },\n formatCurrency: {\n description: \"The amount as money, with an ISO 4217 currency code\",\n parameters:\n \"{ value: number; currency: string; decimals?: number; grouping?: boolean }\",\n returnType: \"string\",\n },\n formatDate: {\n description:\n 'A date or ISO string in a TR35 pattern, for example \"MMM d, yyyy\" or \"HH:mm\"',\n parameters: \"{ value: string | number; format: string }\",\n returnType: \"string\",\n },\n pluralize: {\n description: \"The string of the plural category of the value\",\n parameters:\n \"{ value: number; zero?: string; one?: string; two?: string; few?: string; many?: string; other: string }\",\n returnType: \"string\",\n },\n openUrl: {\n description: \"Opens an http(s) URL in a new tab. Only from an event\",\n parameters: \"{ url: string }\",\n returnType: \"void\",\n requiresUserActivation: true,\n },\n and: {\n description: \"True when every value is true\",\n parameters: \"{ values: boolean[] }\",\n returnType: \"boolean\",\n },\n or: {\n description: \"True when any value is true\",\n parameters: \"{ values: boolean[] }\",\n returnType: \"boolean\",\n },\n not: {\n description: \"The negated value\",\n parameters: \"{ value: boolean }\",\n returnType: \"boolean\",\n },\n});\n\n/**\n * The value functions that CopilotKit adds to the basic catalog, because\n * A2UI 1.0 has no arithmetic: `calc` evaluates an expression over named\n * args, and `series` builds a computed list. A catalog may declare its own\n * functions in A2UI, so these are regular catalog functions to the model;\n * a renderer without them rejects the call instead of misrendering.\n */\nexport const COPILOTKIT_FUNCTIONS: Readonly<\n Record<string, A2UIBasicFunctionInfo>\n> = rendererOnly({\n calc: {\n description:\n \"The value of an arithmetic expression over the other args, by name: + - * / % ( ), comparisons, && || !, cond ? a : b, min max round floor ceil abs, 'text' + name\",\n parameters:\n \"{ expression: string; [name: string]: number | string | boolean }\",\n returnType: \"any\",\n extension: true,\n },\n // WORKAROUND(a2ui-agent-sdk 0.9.0): examples omit `variable` and use default i\n // because the Express compiler mistakes a literal `variable` key for its AST.\n // Runtime support for custom variable names is unchanged.\n // https://github.com/a2ui-project/a2ui/issues/3410\n series: {\n description:\n 'A list of count copies of item, for chart data and template lists. Put arithmetic in ${expression} strings in item, using the loop variable (default i, counting from start, default 1) and other named args. A whole-expression string retains the result type, so \"${i * monthlyCost}\" yields a number. Arguments, including nested calc or formatString calls in item, resolve before the series loop; those calls cannot use the loop variable. Example: {\"@call\":\"series\",\"args\":{\"count\":6,\"item\":{\"month\":\"${i}\",\"cost\":\"${i * monthlyCost}\"},\"monthlyCost\":{\"@path\":\"/monthlyCost\"}}}. Omit variable to use i.',\n parameters:\n \"{ count: number; item: unknown; variable?: string; start?: number; [name: string]: unknown }\",\n returnType: \"array\",\n extension: true,\n },\n});\n\n/** Every function a `{\"@call\"}` may name without a declaration: basic and CopilotKit. */\nexport const GENERATIVE_UI_FUNCTIONS: Readonly<\n Record<string, A2UIBasicFunctionInfo>\n> = { ...A2UI_BASIC_FUNCTIONS, ...COPILOTKIT_FUNCTIONS };\n\n/** The name of the system function that gives the index of a template item. */\nexport const A2UI_INDEX_FUNCTION = \"@index\";\n\n/** True for a built-in function name: basic, CopilotKit, or `@index`. */\nexport function isA2UIBasicFunction(name: string) {\n return (\n name === A2UI_INDEX_FUNCTION ||\n Object.prototype.hasOwnProperty.call(GENERATIVE_UI_FUNCTIONS, name)\n );\n}\n\n/**\n * True for a built-in function that a prop or a check may call: every one\n * except the functions that need a user gesture.\n */\nexport function isA2UIValueFunction(name: string) {\n if (name === A2UI_INDEX_FUNCTION) return true;\n const info = Object.prototype.hasOwnProperty.call(\n GENERATIVE_UI_FUNCTIONS,\n name,\n )\n ? GENERATIVE_UI_FUNCTIONS[name]\n : undefined;\n return info !== undefined && !info.requiresUserActivation;\n}\n\n/** `{ \"@call\": \"<name>\", \"args\"?: {...} }`: a function call value. */\nexport function isCallBinding(\n value: unknown,\n): value is { \"@call\": string; args?: Record<string, unknown> } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n typeof (value as Record<string, unknown>)[\"@call\"] === \"string\"\n );\n}\n\n/** How bad a failed check is. `error` is the default; only an error blocks. */\nexport type A2UIValidationSeverity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A2UI's `ValidationResult`: what a check gives. A validator function gives\n * one; a check may also bind a boolean, which the renderer coerces to one.\n * `code` names the failure for programs; `severity` says how bad it is,\n * `\"error\"` when left out. Other keys are allowed, for app validators that\n * carry more (a suggested value, a field path).\n */\nexport interface A2UIValidationResult {\n valid: boolean;\n message?: string;\n code?: string;\n severity?: A2UIValidationSeverity;\n [extra: string]: unknown;\n}\n\nexport function isValidationResult(\n value: unknown,\n): value is A2UIValidationResult {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n typeof (value as Record<string, unknown>).valid === \"boolean\"\n );\n}\n"],"mappings":";;;;;;;;AAkCA,MAAa,wCACX;;;;;;;;;;;;AAwBF,SAAgB,gBAAgB,IAA6B;AAC3D,KAAI,GAAG,uBAAwB,QAAO;EAAE,UAAU;EAAM,OAAO;EAAO;CACtE,MAAM,UAAU,GAAG,kBAAkB;AACrC,QAAO;EACL,UAAU,YAAY;EACtB,OAAO,YAAY;EACpB;;;AAgBH,SAAS,aACP,WAC+C;AAC/C,QAAO,OAAO,YACZ,OAAO,QACL,UACD,CAAC,KAAK,CAAC,MAAM,UAAU,CACtB,MACA;EAAE,GAAG;EAAM,gBAAgB;EAAgB,CAC5C,CAAC,CACH;;;;;;;AAQH,MAAa,uBAET,aAAa;CACf,UAAU;EACR,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,OAAO;EACL,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,QAAQ;EACN,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,SAAS;EACP,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,OAAO;EACL,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,cAAc;EACZ,aACE;EACF,YAAY;EACZ,YAAY;EACb;CACD,cAAc;EACZ,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,gBAAgB;EACd,aAAa;EACb,YACE;EACF,YAAY;EACb;CACD,YAAY;EACV,aACE;EACF,YAAY;EACZ,YAAY;EACb;CACD,WAAW;EACT,aAAa;EACb,YACE;EACF,YAAY;EACb;CACD,SAAS;EACP,aAAa;EACb,YAAY;EACZ,YAAY;EACZ,wBAAwB;EACzB;CACD,KAAK;EACH,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,IAAI;EACF,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,KAAK;EACH,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACF,CAAC;;;;;;;;AASF,MAAa,uBAET,aAAa;CACf,MAAM;EACJ,aACE;EACF,YACE;EACF,YAAY;EACZ,WAAW;EACZ;CAKD,QAAQ;EACN,aACE;EACF,YACE;EACF,YAAY;EACZ,WAAW;EACZ;CACF,CAAC;;AAGF,MAAa,0BAET;CAAE,GAAG;CAAsB,GAAG;CAAsB;;AAGxD,MAAa,sBAAsB;;AAGnC,SAAgB,oBAAoB,MAAc;AAChD,QACE,SAAS,uBACT,OAAO,UAAU,eAAe,KAAK,yBAAyB,KAAK;;;;;;AAQvE,SAAgB,oBAAoB,MAAc;AAChD,KAAI,SAAS,oBAAqB,QAAO;CACzC,MAAM,OAAO,OAAO,UAAU,eAAe,KAC3C,yBACA,KACD,GACG,wBAAwB,QACxB;AACJ,QAAO,SAAS,UAAa,CAAC,KAAK;;;AAIrC,SAAgB,cACd,OAC8D;AAC9D,QACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,MAAM,IACrB,OAAQ,MAAkC,aAAa;;AAsB3D,SAAgB,mBACd,OAC+B;AAC/B,QACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,MAAM,IACrB,OAAQ,MAAkC,UAAU"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//#region src/generative-ui/basic-functions.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The functions of the A2UI 1.0 basic catalog, as the model and the
|
|
4
|
+
* validator see them. The renderer implements them (react-core
|
|
5
|
+
* `generative-ui/functions.ts`); this file holds only what both sides share:
|
|
6
|
+
* the names, the short signatures for the schema the model reads, and who
|
|
7
|
+
* may call each one.
|
|
8
|
+
*/
|
|
9
|
+
/** What a function gives back, as A2UI 1.0 names it. */
|
|
10
|
+
type A2UIFunctionReturnType = "string" | "number" | "boolean" | "array" | "object" | "validationResult" | "any" | "void";
|
|
11
|
+
/**
|
|
12
|
+
* Who may call a function. The renderer calls it from an event binding or
|
|
13
|
+
* as a prop value; the agent calls it with `callRendererFunction`.
|
|
14
|
+
*/
|
|
15
|
+
type A2UIAllowedCallers = "rendererOnly" | "agentOnly" | "rendererOrAgent";
|
|
16
|
+
/**
|
|
17
|
+
* The callers of an app function that names none: the renderer only, as
|
|
18
|
+
* in A2UI 1.0. The agent calls a function with `callRendererFunction` only
|
|
19
|
+
* when its declaration allows it (`"rendererOrAgent"` or `"agentOnly"`).
|
|
20
|
+
* The manifests and the exported catalog write the value out.
|
|
21
|
+
*/
|
|
22
|
+
declare const GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS: A2UIAllowedCallers;
|
|
23
|
+
/** The A2UI 1.0 interface fields of a function: who calls it, and how. */
|
|
24
|
+
interface A2UIFunctionPermissions {
|
|
25
|
+
allowedCallers?: A2UIAllowedCallers;
|
|
26
|
+
/**
|
|
27
|
+
* True for a function that only runs from a user gesture (a click, a key
|
|
28
|
+
* press). It is `rendererOnly`: the agent cannot call it, and a prop
|
|
29
|
+
* cannot be bound to it.
|
|
30
|
+
*/
|
|
31
|
+
requiresUserActivation?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Who may call a function, from its permissions. A function that needs a
|
|
35
|
+
* user gesture is for the renderer only, whatever `allowedCallers` says.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* functionCallers({}); // { renderer: true, agent: true }
|
|
40
|
+
* functionCallers({ allowedCallers: "rendererOnly" }); // { renderer: true, agent: false }
|
|
41
|
+
* functionCallers({ requiresUserActivation: true }); // { renderer: true, agent: false }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function functionCallers(fn: A2UIFunctionPermissions): {
|
|
45
|
+
renderer: boolean;
|
|
46
|
+
agent: boolean;
|
|
47
|
+
};
|
|
48
|
+
interface A2UIBasicFunctionInfo extends A2UIFunctionPermissions {
|
|
49
|
+
description: string;
|
|
50
|
+
/** The args, as a short TypeScript-like type for the compact schema. */
|
|
51
|
+
parameters: string;
|
|
52
|
+
returnType: A2UIFunctionReturnType;
|
|
53
|
+
/** Built-in functions are value functions of the renderer. */
|
|
54
|
+
allowedCallers: "rendererOnly";
|
|
55
|
+
requiresUserActivation?: true;
|
|
56
|
+
/** True for a CopilotKit function that the A2UI basic catalog lacks. */
|
|
57
|
+
extension?: true;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The basic functions by name. A `{"@call"}` in a prop, in an event
|
|
61
|
+
* binding, or in a `callRendererFunction` may name any of them without a
|
|
62
|
+
* declaration in `createGenerativeUI({ functions })`.
|
|
63
|
+
*/
|
|
64
|
+
declare const A2UI_BASIC_FUNCTIONS: Readonly<Record<string, A2UIBasicFunctionInfo>>;
|
|
65
|
+
/**
|
|
66
|
+
* The value functions that CopilotKit adds to the basic catalog, because
|
|
67
|
+
* A2UI 1.0 has no arithmetic: `calc` evaluates an expression over named
|
|
68
|
+
* args, and `series` builds a computed list. A catalog may declare its own
|
|
69
|
+
* functions in A2UI, so these are regular catalog functions to the model;
|
|
70
|
+
* a renderer without them rejects the call instead of misrendering.
|
|
71
|
+
*/
|
|
72
|
+
declare const COPILOTKIT_FUNCTIONS: Readonly<Record<string, A2UIBasicFunctionInfo>>;
|
|
73
|
+
/** Every function a `{"@call"}` may name without a declaration: basic and CopilotKit. */
|
|
74
|
+
declare const GENERATIVE_UI_FUNCTIONS: Readonly<Record<string, A2UIBasicFunctionInfo>>;
|
|
75
|
+
/** The name of the system function that gives the index of a template item. */
|
|
76
|
+
declare const A2UI_INDEX_FUNCTION = "@index";
|
|
77
|
+
/** True for a built-in function name: basic, CopilotKit, or `@index`. */
|
|
78
|
+
declare function isA2UIBasicFunction(name: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* True for a built-in function that a prop or a check may call: every one
|
|
81
|
+
* except the functions that need a user gesture.
|
|
82
|
+
*/
|
|
83
|
+
declare function isA2UIValueFunction(name: string): boolean;
|
|
84
|
+
/** `{ "@call": "<name>", "args"?: {...} }`: a function call value. */
|
|
85
|
+
declare function isCallBinding(value: unknown): value is {
|
|
86
|
+
"@call": string;
|
|
87
|
+
args?: Record<string, unknown>;
|
|
88
|
+
};
|
|
89
|
+
/** How bad a failed check is. `error` is the default; only an error blocks. */
|
|
90
|
+
type A2UIValidationSeverity = "error" | "warning" | "info";
|
|
91
|
+
/**
|
|
92
|
+
* A2UI's `ValidationResult`: what a check gives. A validator function gives
|
|
93
|
+
* one; a check may also bind a boolean, which the renderer coerces to one.
|
|
94
|
+
* `code` names the failure for programs; `severity` says how bad it is,
|
|
95
|
+
* `"error"` when left out. Other keys are allowed, for app validators that
|
|
96
|
+
* carry more (a suggested value, a field path).
|
|
97
|
+
*/
|
|
98
|
+
interface A2UIValidationResult {
|
|
99
|
+
valid: boolean;
|
|
100
|
+
message?: string;
|
|
101
|
+
code?: string;
|
|
102
|
+
severity?: A2UIValidationSeverity;
|
|
103
|
+
[extra: string]: unknown;
|
|
104
|
+
}
|
|
105
|
+
declare function isValidationResult(value: unknown): value is A2UIValidationResult;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { A2UIAllowedCallers, A2UIBasicFunctionInfo, A2UIFunctionPermissions, A2UIFunctionReturnType, A2UIValidationResult, A2UIValidationSeverity, A2UI_BASIC_FUNCTIONS, A2UI_INDEX_FUNCTION, COPILOTKIT_FUNCTIONS, GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS, GENERATIVE_UI_FUNCTIONS, functionCallers, isA2UIBasicFunction, isA2UIValueFunction, isCallBinding, isValidationResult };
|
|
108
|
+
//# sourceMappingURL=basic-functions.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-functions.d.cts","names":[],"sources":["../../src/generative-ui/basic-functions.ts"],"mappings":";;AASA;;;;;AAcA;;KAdY,sBAAA;;;AAyBZ;;KAXY,kBAAA;;;AAeZ;;;;cAJa,qCAAA,EAAuC,kBAAA;;UAInC,uBAAA;EACf,cAAA,GAAiB,kBAAA;EAMK;AAcxB;;;;EAdE,sBAAA;AAAA;;;;;AAuBF;;;;;;;iBATgB,eAAA,CAAgB,EAAA,EAAI,uBAAA;;;;UASnB,qBAAA,SAA8B,uBAAA;EAC7C,WAAA;EAQS;EANT,UAAA;EACA,UAAA,EAAY,sBAAA;;EAEZ,cAAA;EACA,sBAAA;EAwBiC;EAtBjC,SAAA;AAAA;;;;;;cAsBW,oBAAA,EAAsB,QAAA,CACjC,MAAA,SAAe,qBAAA;;;;;;;;cAsFJ,oBAAA,EAAsB,QAAA,CACjC,MAAA,SAAe,qBAAA;;cAyBJ,uBAAA,EAAyB,QAAA,CACpC,MAAA,SAAe,qBAAA;;cAIJ,mBAAA;AALb;AAAA,iBAQgB,mBAAA,CAAoB,IAAA;;;;;iBAWpB,mBAAA,CAAoB,IAAA;;iBAYpB,aAAA,CACd,KAAA,YACC,KAAA;EAAW,OAAA;EAAiB,IAAA,GAAO,MAAA;AAAA;;KAU1B,sBAAA;;;;;AAnCZ;;;UA4CiB,oBAAA;EACf,KAAA;EACA,OAAA;EACA,IAAA;EACA,QAAA,GAAW,sBAAA;EAAA,CACV,KAAA;AAAA;AAAA,iBAGa,kBAAA,CACd,KAAA,YACC,KAAA,IAAS,oBAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//#region src/generative-ui/basic-functions.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The functions of the A2UI 1.0 basic catalog, as the model and the
|
|
4
|
+
* validator see them. The renderer implements them (react-core
|
|
5
|
+
* `generative-ui/functions.ts`); this file holds only what both sides share:
|
|
6
|
+
* the names, the short signatures for the schema the model reads, and who
|
|
7
|
+
* may call each one.
|
|
8
|
+
*/
|
|
9
|
+
/** What a function gives back, as A2UI 1.0 names it. */
|
|
10
|
+
type A2UIFunctionReturnType = "string" | "number" | "boolean" | "array" | "object" | "validationResult" | "any" | "void";
|
|
11
|
+
/**
|
|
12
|
+
* Who may call a function. The renderer calls it from an event binding or
|
|
13
|
+
* as a prop value; the agent calls it with `callRendererFunction`.
|
|
14
|
+
*/
|
|
15
|
+
type A2UIAllowedCallers = "rendererOnly" | "agentOnly" | "rendererOrAgent";
|
|
16
|
+
/**
|
|
17
|
+
* The callers of an app function that names none: the renderer only, as
|
|
18
|
+
* in A2UI 1.0. The agent calls a function with `callRendererFunction` only
|
|
19
|
+
* when its declaration allows it (`"rendererOrAgent"` or `"agentOnly"`).
|
|
20
|
+
* The manifests and the exported catalog write the value out.
|
|
21
|
+
*/
|
|
22
|
+
declare const GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS: A2UIAllowedCallers;
|
|
23
|
+
/** The A2UI 1.0 interface fields of a function: who calls it, and how. */
|
|
24
|
+
interface A2UIFunctionPermissions {
|
|
25
|
+
allowedCallers?: A2UIAllowedCallers;
|
|
26
|
+
/**
|
|
27
|
+
* True for a function that only runs from a user gesture (a click, a key
|
|
28
|
+
* press). It is `rendererOnly`: the agent cannot call it, and a prop
|
|
29
|
+
* cannot be bound to it.
|
|
30
|
+
*/
|
|
31
|
+
requiresUserActivation?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Who may call a function, from its permissions. A function that needs a
|
|
35
|
+
* user gesture is for the renderer only, whatever `allowedCallers` says.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* functionCallers({}); // { renderer: true, agent: true }
|
|
40
|
+
* functionCallers({ allowedCallers: "rendererOnly" }); // { renderer: true, agent: false }
|
|
41
|
+
* functionCallers({ requiresUserActivation: true }); // { renderer: true, agent: false }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function functionCallers(fn: A2UIFunctionPermissions): {
|
|
45
|
+
renderer: boolean;
|
|
46
|
+
agent: boolean;
|
|
47
|
+
};
|
|
48
|
+
interface A2UIBasicFunctionInfo extends A2UIFunctionPermissions {
|
|
49
|
+
description: string;
|
|
50
|
+
/** The args, as a short TypeScript-like type for the compact schema. */
|
|
51
|
+
parameters: string;
|
|
52
|
+
returnType: A2UIFunctionReturnType;
|
|
53
|
+
/** Built-in functions are value functions of the renderer. */
|
|
54
|
+
allowedCallers: "rendererOnly";
|
|
55
|
+
requiresUserActivation?: true;
|
|
56
|
+
/** True for a CopilotKit function that the A2UI basic catalog lacks. */
|
|
57
|
+
extension?: true;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The basic functions by name. A `{"@call"}` in a prop, in an event
|
|
61
|
+
* binding, or in a `callRendererFunction` may name any of them without a
|
|
62
|
+
* declaration in `createGenerativeUI({ functions })`.
|
|
63
|
+
*/
|
|
64
|
+
declare const A2UI_BASIC_FUNCTIONS: Readonly<Record<string, A2UIBasicFunctionInfo>>;
|
|
65
|
+
/**
|
|
66
|
+
* The value functions that CopilotKit adds to the basic catalog, because
|
|
67
|
+
* A2UI 1.0 has no arithmetic: `calc` evaluates an expression over named
|
|
68
|
+
* args, and `series` builds a computed list. A catalog may declare its own
|
|
69
|
+
* functions in A2UI, so these are regular catalog functions to the model;
|
|
70
|
+
* a renderer without them rejects the call instead of misrendering.
|
|
71
|
+
*/
|
|
72
|
+
declare const COPILOTKIT_FUNCTIONS: Readonly<Record<string, A2UIBasicFunctionInfo>>;
|
|
73
|
+
/** Every function a `{"@call"}` may name without a declaration: basic and CopilotKit. */
|
|
74
|
+
declare const GENERATIVE_UI_FUNCTIONS: Readonly<Record<string, A2UIBasicFunctionInfo>>;
|
|
75
|
+
/** The name of the system function that gives the index of a template item. */
|
|
76
|
+
declare const A2UI_INDEX_FUNCTION = "@index";
|
|
77
|
+
/** True for a built-in function name: basic, CopilotKit, or `@index`. */
|
|
78
|
+
declare function isA2UIBasicFunction(name: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* True for a built-in function that a prop or a check may call: every one
|
|
81
|
+
* except the functions that need a user gesture.
|
|
82
|
+
*/
|
|
83
|
+
declare function isA2UIValueFunction(name: string): boolean;
|
|
84
|
+
/** `{ "@call": "<name>", "args"?: {...} }`: a function call value. */
|
|
85
|
+
declare function isCallBinding(value: unknown): value is {
|
|
86
|
+
"@call": string;
|
|
87
|
+
args?: Record<string, unknown>;
|
|
88
|
+
};
|
|
89
|
+
/** How bad a failed check is. `error` is the default; only an error blocks. */
|
|
90
|
+
type A2UIValidationSeverity = "error" | "warning" | "info";
|
|
91
|
+
/**
|
|
92
|
+
* A2UI's `ValidationResult`: what a check gives. A validator function gives
|
|
93
|
+
* one; a check may also bind a boolean, which the renderer coerces to one.
|
|
94
|
+
* `code` names the failure for programs; `severity` says how bad it is,
|
|
95
|
+
* `"error"` when left out. Other keys are allowed, for app validators that
|
|
96
|
+
* carry more (a suggested value, a field path).
|
|
97
|
+
*/
|
|
98
|
+
interface A2UIValidationResult {
|
|
99
|
+
valid: boolean;
|
|
100
|
+
message?: string;
|
|
101
|
+
code?: string;
|
|
102
|
+
severity?: A2UIValidationSeverity;
|
|
103
|
+
[extra: string]: unknown;
|
|
104
|
+
}
|
|
105
|
+
declare function isValidationResult(value: unknown): value is A2UIValidationResult;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { A2UIAllowedCallers, A2UIBasicFunctionInfo, A2UIFunctionPermissions, A2UIFunctionReturnType, A2UIValidationResult, A2UIValidationSeverity, A2UI_BASIC_FUNCTIONS, A2UI_INDEX_FUNCTION, COPILOTKIT_FUNCTIONS, GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS, GENERATIVE_UI_FUNCTIONS, functionCallers, isA2UIBasicFunction, isA2UIValueFunction, isCallBinding, isValidationResult };
|
|
108
|
+
//# sourceMappingURL=basic-functions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-functions.d.mts","names":[],"sources":["../../src/generative-ui/basic-functions.ts"],"mappings":";;AASA;;;;;AAcA;;KAdY,sBAAA;;;AAyBZ;;KAXY,kBAAA;;;AAeZ;;;;cAJa,qCAAA,EAAuC,kBAAA;;UAInC,uBAAA;EACf,cAAA,GAAiB,kBAAA;EAMK;AAcxB;;;;EAdE,sBAAA;AAAA;;;;;AAuBF;;;;;;;iBATgB,eAAA,CAAgB,EAAA,EAAI,uBAAA;;;;UASnB,qBAAA,SAA8B,uBAAA;EAC7C,WAAA;EAQS;EANT,UAAA;EACA,UAAA,EAAY,sBAAA;;EAEZ,cAAA;EACA,sBAAA;EAwBiC;EAtBjC,SAAA;AAAA;;;;;;cAsBW,oBAAA,EAAsB,QAAA,CACjC,MAAA,SAAe,qBAAA;;;;;;;;cAsFJ,oBAAA,EAAsB,QAAA,CACjC,MAAA,SAAe,qBAAA;;cAyBJ,uBAAA,EAAyB,QAAA,CACpC,MAAA,SAAe,qBAAA;;cAIJ,mBAAA;AALb;AAAA,iBAQgB,mBAAA,CAAoB,IAAA;;;;;iBAWpB,mBAAA,CAAoB,IAAA;;iBAYpB,aAAA,CACd,KAAA,YACC,KAAA;EAAW,OAAA;EAAiB,IAAA,GAAO,MAAA;AAAA;;KAU1B,sBAAA;;;;;AAnCZ;;;UA4CiB,oBAAA;EACf,KAAA;EACA,OAAA;EACA,IAAA;EACA,QAAA,GAAW,sBAAA;EAAA,CACV,KAAA;AAAA;AAAA,iBAGa,kBAAA,CACd,KAAA,YACC,KAAA,IAAS,oBAAA"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
//#region src/generative-ui/basic-functions.ts
|
|
2
|
+
/**
|
|
3
|
+
* The callers of an app function that names none: the renderer only, as
|
|
4
|
+
* in A2UI 1.0. The agent calls a function with `callRendererFunction` only
|
|
5
|
+
* when its declaration allows it (`"rendererOrAgent"` or `"agentOnly"`).
|
|
6
|
+
* The manifests and the exported catalog write the value out.
|
|
7
|
+
*/
|
|
8
|
+
const GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS = "rendererOnly";
|
|
9
|
+
/**
|
|
10
|
+
* Who may call a function, from its permissions. A function that needs a
|
|
11
|
+
* user gesture is for the renderer only, whatever `allowedCallers` says.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* functionCallers({}); // { renderer: true, agent: true }
|
|
16
|
+
* functionCallers({ allowedCallers: "rendererOnly" }); // { renderer: true, agent: false }
|
|
17
|
+
* functionCallers({ requiresUserActivation: true }); // { renderer: true, agent: false }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function functionCallers(fn) {
|
|
21
|
+
if (fn.requiresUserActivation) return {
|
|
22
|
+
renderer: true,
|
|
23
|
+
agent: false
|
|
24
|
+
};
|
|
25
|
+
const callers = fn.allowedCallers ?? GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS;
|
|
26
|
+
return {
|
|
27
|
+
renderer: callers !== "agentOnly",
|
|
28
|
+
agent: callers !== "rendererOnly"
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Marks a table of built-in functions as callable by the renderer only. */
|
|
32
|
+
function rendererOnly(functions) {
|
|
33
|
+
return Object.fromEntries(Object.entries(functions).map(([name, info]) => [name, {
|
|
34
|
+
...info,
|
|
35
|
+
allowedCallers: "rendererOnly"
|
|
36
|
+
}]));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The basic functions by name. A `{"@call"}` in a prop, in an event
|
|
40
|
+
* binding, or in a `callRendererFunction` may name any of them without a
|
|
41
|
+
* declaration in `createGenerativeUI({ functions })`.
|
|
42
|
+
*/
|
|
43
|
+
const A2UI_BASIC_FUNCTIONS = rendererOnly({
|
|
44
|
+
required: {
|
|
45
|
+
description: "Valid when the value is not empty",
|
|
46
|
+
parameters: "{ value: unknown }",
|
|
47
|
+
returnType: "validationResult"
|
|
48
|
+
},
|
|
49
|
+
regex: {
|
|
50
|
+
description: "Valid when the value matches the pattern",
|
|
51
|
+
parameters: "{ value: string; pattern: string }",
|
|
52
|
+
returnType: "validationResult"
|
|
53
|
+
},
|
|
54
|
+
length: {
|
|
55
|
+
description: "Valid when the length of the value is within min and max",
|
|
56
|
+
parameters: "{ value: string; min?: number; max?: number }",
|
|
57
|
+
returnType: "validationResult"
|
|
58
|
+
},
|
|
59
|
+
numeric: {
|
|
60
|
+
description: "Valid when the value is a number within min and max",
|
|
61
|
+
parameters: "{ value: number; min?: number; max?: number }",
|
|
62
|
+
returnType: "validationResult"
|
|
63
|
+
},
|
|
64
|
+
email: {
|
|
65
|
+
description: "Valid when the value is an email address",
|
|
66
|
+
parameters: "{ value: string }",
|
|
67
|
+
returnType: "validationResult"
|
|
68
|
+
},
|
|
69
|
+
formatString: {
|
|
70
|
+
description: "Interpolates ${/path}, ${relative/path} and ${fn(arg: value)} in the value; \\${ is a literal",
|
|
71
|
+
parameters: "{ value: string }",
|
|
72
|
+
returnType: "string"
|
|
73
|
+
},
|
|
74
|
+
formatNumber: {
|
|
75
|
+
description: "The number in the locale of the user",
|
|
76
|
+
parameters: "{ value: number; decimals?: number; grouping?: boolean }",
|
|
77
|
+
returnType: "string"
|
|
78
|
+
},
|
|
79
|
+
formatCurrency: {
|
|
80
|
+
description: "The amount as money, with an ISO 4217 currency code",
|
|
81
|
+
parameters: "{ value: number; currency: string; decimals?: number; grouping?: boolean }",
|
|
82
|
+
returnType: "string"
|
|
83
|
+
},
|
|
84
|
+
formatDate: {
|
|
85
|
+
description: "A date or ISO string in a TR35 pattern, for example \"MMM d, yyyy\" or \"HH:mm\"",
|
|
86
|
+
parameters: "{ value: string | number; format: string }",
|
|
87
|
+
returnType: "string"
|
|
88
|
+
},
|
|
89
|
+
pluralize: {
|
|
90
|
+
description: "The string of the plural category of the value",
|
|
91
|
+
parameters: "{ value: number; zero?: string; one?: string; two?: string; few?: string; many?: string; other: string }",
|
|
92
|
+
returnType: "string"
|
|
93
|
+
},
|
|
94
|
+
openUrl: {
|
|
95
|
+
description: "Opens an http(s) URL in a new tab. Only from an event",
|
|
96
|
+
parameters: "{ url: string }",
|
|
97
|
+
returnType: "void",
|
|
98
|
+
requiresUserActivation: true
|
|
99
|
+
},
|
|
100
|
+
and: {
|
|
101
|
+
description: "True when every value is true",
|
|
102
|
+
parameters: "{ values: boolean[] }",
|
|
103
|
+
returnType: "boolean"
|
|
104
|
+
},
|
|
105
|
+
or: {
|
|
106
|
+
description: "True when any value is true",
|
|
107
|
+
parameters: "{ values: boolean[] }",
|
|
108
|
+
returnType: "boolean"
|
|
109
|
+
},
|
|
110
|
+
not: {
|
|
111
|
+
description: "The negated value",
|
|
112
|
+
parameters: "{ value: boolean }",
|
|
113
|
+
returnType: "boolean"
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* The value functions that CopilotKit adds to the basic catalog, because
|
|
118
|
+
* A2UI 1.0 has no arithmetic: `calc` evaluates an expression over named
|
|
119
|
+
* args, and `series` builds a computed list. A catalog may declare its own
|
|
120
|
+
* functions in A2UI, so these are regular catalog functions to the model;
|
|
121
|
+
* a renderer without them rejects the call instead of misrendering.
|
|
122
|
+
*/
|
|
123
|
+
const COPILOTKIT_FUNCTIONS = rendererOnly({
|
|
124
|
+
calc: {
|
|
125
|
+
description: "The value of an arithmetic expression over the other args, by name: + - * / % ( ), comparisons, && || !, cond ? a : b, min max round floor ceil abs, 'text' + name",
|
|
126
|
+
parameters: "{ expression: string; [name: string]: number | string | boolean }",
|
|
127
|
+
returnType: "any",
|
|
128
|
+
extension: true
|
|
129
|
+
},
|
|
130
|
+
series: {
|
|
131
|
+
description: "A list of count copies of item, for chart data and template lists. Put arithmetic in ${expression} strings in item, using the loop variable (default i, counting from start, default 1) and other named args. A whole-expression string retains the result type, so \"${i * monthlyCost}\" yields a number. Arguments, including nested calc or formatString calls in item, resolve before the series loop; those calls cannot use the loop variable. Example: {\"@call\":\"series\",\"args\":{\"count\":6,\"item\":{\"month\":\"${i}\",\"cost\":\"${i * monthlyCost}\"},\"monthlyCost\":{\"@path\":\"/monthlyCost\"}}}. Omit variable to use i.",
|
|
132
|
+
parameters: "{ count: number; item: unknown; variable?: string; start?: number; [name: string]: unknown }",
|
|
133
|
+
returnType: "array",
|
|
134
|
+
extension: true
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
/** Every function a `{"@call"}` may name without a declaration: basic and CopilotKit. */
|
|
138
|
+
const GENERATIVE_UI_FUNCTIONS = {
|
|
139
|
+
...A2UI_BASIC_FUNCTIONS,
|
|
140
|
+
...COPILOTKIT_FUNCTIONS
|
|
141
|
+
};
|
|
142
|
+
/** The name of the system function that gives the index of a template item. */
|
|
143
|
+
const A2UI_INDEX_FUNCTION = "@index";
|
|
144
|
+
/** True for a built-in function name: basic, CopilotKit, or `@index`. */
|
|
145
|
+
function isA2UIBasicFunction(name) {
|
|
146
|
+
return name === A2UI_INDEX_FUNCTION || Object.prototype.hasOwnProperty.call(GENERATIVE_UI_FUNCTIONS, name);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* True for a built-in function that a prop or a check may call: every one
|
|
150
|
+
* except the functions that need a user gesture.
|
|
151
|
+
*/
|
|
152
|
+
function isA2UIValueFunction(name) {
|
|
153
|
+
if (name === A2UI_INDEX_FUNCTION) return true;
|
|
154
|
+
const info = Object.prototype.hasOwnProperty.call(GENERATIVE_UI_FUNCTIONS, name) ? GENERATIVE_UI_FUNCTIONS[name] : void 0;
|
|
155
|
+
return info !== void 0 && !info.requiresUserActivation;
|
|
156
|
+
}
|
|
157
|
+
/** `{ "@call": "<name>", "args"?: {...} }`: a function call value. */
|
|
158
|
+
function isCallBinding(value) {
|
|
159
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value["@call"] === "string";
|
|
160
|
+
}
|
|
161
|
+
function isValidationResult(value) {
|
|
162
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value.valid === "boolean";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
export { A2UI_BASIC_FUNCTIONS, A2UI_INDEX_FUNCTION, COPILOTKIT_FUNCTIONS, GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS, GENERATIVE_UI_FUNCTIONS, functionCallers, isA2UIBasicFunction, isA2UIValueFunction, isCallBinding, isValidationResult };
|
|
167
|
+
//# sourceMappingURL=basic-functions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-functions.mjs","names":[],"sources":["../../src/generative-ui/basic-functions.ts"],"sourcesContent":["/**\n * The functions of the A2UI 1.0 basic catalog, as the model and the\n * validator see them. The renderer implements them (react-core\n * `generative-ui/functions.ts`); this file holds only what both sides share:\n * the names, the short signatures for the schema the model reads, and who\n * may call each one.\n */\n\n/** What a function gives back, as A2UI 1.0 names it. */\nexport type A2UIFunctionReturnType =\n | \"string\"\n | \"number\"\n | \"boolean\"\n | \"array\"\n | \"object\"\n | \"validationResult\"\n | \"any\"\n | \"void\";\n\n/**\n * Who may call a function. The renderer calls it from an event binding or\n * as a prop value; the agent calls it with `callRendererFunction`.\n */\nexport type A2UIAllowedCallers =\n | \"rendererOnly\"\n | \"agentOnly\"\n | \"rendererOrAgent\";\n\n/**\n * The callers of an app function that names none: the renderer only, as\n * in A2UI 1.0. The agent calls a function with `callRendererFunction` only\n * when its declaration allows it (`\"rendererOrAgent\"` or `\"agentOnly\"`).\n * The manifests and the exported catalog write the value out.\n */\nexport const GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS: A2UIAllowedCallers =\n \"rendererOnly\";\n\n/** The A2UI 1.0 interface fields of a function: who calls it, and how. */\nexport interface A2UIFunctionPermissions {\n allowedCallers?: A2UIAllowedCallers;\n /**\n * True for a function that only runs from a user gesture (a click, a key\n * press). It is `rendererOnly`: the agent cannot call it, and a prop\n * cannot be bound to it.\n */\n requiresUserActivation?: boolean;\n}\n\n/**\n * Who may call a function, from its permissions. A function that needs a\n * user gesture is for the renderer only, whatever `allowedCallers` says.\n *\n * @example\n * ```ts\n * functionCallers({}); // { renderer: true, agent: true }\n * functionCallers({ allowedCallers: \"rendererOnly\" }); // { renderer: true, agent: false }\n * functionCallers({ requiresUserActivation: true }); // { renderer: true, agent: false }\n * ```\n */\nexport function functionCallers(fn: A2UIFunctionPermissions) {\n if (fn.requiresUserActivation) return { renderer: true, agent: false };\n const callers = fn.allowedCallers ?? GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS;\n return {\n renderer: callers !== \"agentOnly\",\n agent: callers !== \"rendererOnly\",\n };\n}\n\nexport interface A2UIBasicFunctionInfo extends A2UIFunctionPermissions {\n description: string;\n /** The args, as a short TypeScript-like type for the compact schema. */\n parameters: string;\n returnType: A2UIFunctionReturnType;\n /** Built-in functions are value functions of the renderer. */\n allowedCallers: \"rendererOnly\";\n requiresUserActivation?: true;\n /** True for a CopilotKit function that the A2UI basic catalog lacks. */\n extension?: true;\n}\n\n/** Marks a table of built-in functions as callable by the renderer only. */\nfunction rendererOnly<Name extends string>(\n functions: Record<Name, Omit<A2UIBasicFunctionInfo, \"allowedCallers\">>,\n): Readonly<Record<Name, A2UIBasicFunctionInfo>> {\n return Object.fromEntries(\n Object.entries<Omit<A2UIBasicFunctionInfo, \"allowedCallers\">>(\n functions,\n ).map(([name, info]) => [\n name,\n { ...info, allowedCallers: \"rendererOnly\" },\n ]),\n ) as Record<Name, A2UIBasicFunctionInfo>;\n}\n\n/**\n * The basic functions by name. A `{\"@call\"}` in a prop, in an event\n * binding, or in a `callRendererFunction` may name any of them without a\n * declaration in `createGenerativeUI({ functions })`.\n */\nexport const A2UI_BASIC_FUNCTIONS: Readonly<\n Record<string, A2UIBasicFunctionInfo>\n> = rendererOnly({\n required: {\n description: \"Valid when the value is not empty\",\n parameters: \"{ value: unknown }\",\n returnType: \"validationResult\",\n },\n regex: {\n description: \"Valid when the value matches the pattern\",\n parameters: \"{ value: string; pattern: string }\",\n returnType: \"validationResult\",\n },\n length: {\n description: \"Valid when the length of the value is within min and max\",\n parameters: \"{ value: string; min?: number; max?: number }\",\n returnType: \"validationResult\",\n },\n numeric: {\n description: \"Valid when the value is a number within min and max\",\n parameters: \"{ value: number; min?: number; max?: number }\",\n returnType: \"validationResult\",\n },\n email: {\n description: \"Valid when the value is an email address\",\n parameters: \"{ value: string }\",\n returnType: \"validationResult\",\n },\n formatString: {\n description:\n \"Interpolates ${/path}, ${relative/path} and ${fn(arg: value)} in the value; \\\\${ is a literal\",\n parameters: \"{ value: string }\",\n returnType: \"string\",\n },\n formatNumber: {\n description: \"The number in the locale of the user\",\n parameters: \"{ value: number; decimals?: number; grouping?: boolean }\",\n returnType: \"string\",\n },\n formatCurrency: {\n description: \"The amount as money, with an ISO 4217 currency code\",\n parameters:\n \"{ value: number; currency: string; decimals?: number; grouping?: boolean }\",\n returnType: \"string\",\n },\n formatDate: {\n description:\n 'A date or ISO string in a TR35 pattern, for example \"MMM d, yyyy\" or \"HH:mm\"',\n parameters: \"{ value: string | number; format: string }\",\n returnType: \"string\",\n },\n pluralize: {\n description: \"The string of the plural category of the value\",\n parameters:\n \"{ value: number; zero?: string; one?: string; two?: string; few?: string; many?: string; other: string }\",\n returnType: \"string\",\n },\n openUrl: {\n description: \"Opens an http(s) URL in a new tab. Only from an event\",\n parameters: \"{ url: string }\",\n returnType: \"void\",\n requiresUserActivation: true,\n },\n and: {\n description: \"True when every value is true\",\n parameters: \"{ values: boolean[] }\",\n returnType: \"boolean\",\n },\n or: {\n description: \"True when any value is true\",\n parameters: \"{ values: boolean[] }\",\n returnType: \"boolean\",\n },\n not: {\n description: \"The negated value\",\n parameters: \"{ value: boolean }\",\n returnType: \"boolean\",\n },\n});\n\n/**\n * The value functions that CopilotKit adds to the basic catalog, because\n * A2UI 1.0 has no arithmetic: `calc` evaluates an expression over named\n * args, and `series` builds a computed list. A catalog may declare its own\n * functions in A2UI, so these are regular catalog functions to the model;\n * a renderer without them rejects the call instead of misrendering.\n */\nexport const COPILOTKIT_FUNCTIONS: Readonly<\n Record<string, A2UIBasicFunctionInfo>\n> = rendererOnly({\n calc: {\n description:\n \"The value of an arithmetic expression over the other args, by name: + - * / % ( ), comparisons, && || !, cond ? a : b, min max round floor ceil abs, 'text' + name\",\n parameters:\n \"{ expression: string; [name: string]: number | string | boolean }\",\n returnType: \"any\",\n extension: true,\n },\n // WORKAROUND(a2ui-agent-sdk 0.9.0): examples omit `variable` and use default i\n // because the Express compiler mistakes a literal `variable` key for its AST.\n // Runtime support for custom variable names is unchanged.\n // https://github.com/a2ui-project/a2ui/issues/3410\n series: {\n description:\n 'A list of count copies of item, for chart data and template lists. Put arithmetic in ${expression} strings in item, using the loop variable (default i, counting from start, default 1) and other named args. A whole-expression string retains the result type, so \"${i * monthlyCost}\" yields a number. Arguments, including nested calc or formatString calls in item, resolve before the series loop; those calls cannot use the loop variable. Example: {\"@call\":\"series\",\"args\":{\"count\":6,\"item\":{\"month\":\"${i}\",\"cost\":\"${i * monthlyCost}\"},\"monthlyCost\":{\"@path\":\"/monthlyCost\"}}}. Omit variable to use i.',\n parameters:\n \"{ count: number; item: unknown; variable?: string; start?: number; [name: string]: unknown }\",\n returnType: \"array\",\n extension: true,\n },\n});\n\n/** Every function a `{\"@call\"}` may name without a declaration: basic and CopilotKit. */\nexport const GENERATIVE_UI_FUNCTIONS: Readonly<\n Record<string, A2UIBasicFunctionInfo>\n> = { ...A2UI_BASIC_FUNCTIONS, ...COPILOTKIT_FUNCTIONS };\n\n/** The name of the system function that gives the index of a template item. */\nexport const A2UI_INDEX_FUNCTION = \"@index\";\n\n/** True for a built-in function name: basic, CopilotKit, or `@index`. */\nexport function isA2UIBasicFunction(name: string) {\n return (\n name === A2UI_INDEX_FUNCTION ||\n Object.prototype.hasOwnProperty.call(GENERATIVE_UI_FUNCTIONS, name)\n );\n}\n\n/**\n * True for a built-in function that a prop or a check may call: every one\n * except the functions that need a user gesture.\n */\nexport function isA2UIValueFunction(name: string) {\n if (name === A2UI_INDEX_FUNCTION) return true;\n const info = Object.prototype.hasOwnProperty.call(\n GENERATIVE_UI_FUNCTIONS,\n name,\n )\n ? GENERATIVE_UI_FUNCTIONS[name]\n : undefined;\n return info !== undefined && !info.requiresUserActivation;\n}\n\n/** `{ \"@call\": \"<name>\", \"args\"?: {...} }`: a function call value. */\nexport function isCallBinding(\n value: unknown,\n): value is { \"@call\": string; args?: Record<string, unknown> } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n typeof (value as Record<string, unknown>)[\"@call\"] === \"string\"\n );\n}\n\n/** How bad a failed check is. `error` is the default; only an error blocks. */\nexport type A2UIValidationSeverity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A2UI's `ValidationResult`: what a check gives. A validator function gives\n * one; a check may also bind a boolean, which the renderer coerces to one.\n * `code` names the failure for programs; `severity` says how bad it is,\n * `\"error\"` when left out. Other keys are allowed, for app validators that\n * carry more (a suggested value, a field path).\n */\nexport interface A2UIValidationResult {\n valid: boolean;\n message?: string;\n code?: string;\n severity?: A2UIValidationSeverity;\n [extra: string]: unknown;\n}\n\nexport function isValidationResult(\n value: unknown,\n): value is A2UIValidationResult {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n typeof (value as Record<string, unknown>).valid === \"boolean\"\n );\n}\n"],"mappings":";;;;;;;AAkCA,MAAa,wCACX;;;;;;;;;;;;AAwBF,SAAgB,gBAAgB,IAA6B;AAC3D,KAAI,GAAG,uBAAwB,QAAO;EAAE,UAAU;EAAM,OAAO;EAAO;CACtE,MAAM,UAAU,GAAG,kBAAkB;AACrC,QAAO;EACL,UAAU,YAAY;EACtB,OAAO,YAAY;EACpB;;;AAgBH,SAAS,aACP,WAC+C;AAC/C,QAAO,OAAO,YACZ,OAAO,QACL,UACD,CAAC,KAAK,CAAC,MAAM,UAAU,CACtB,MACA;EAAE,GAAG;EAAM,gBAAgB;EAAgB,CAC5C,CAAC,CACH;;;;;;;AAQH,MAAa,uBAET,aAAa;CACf,UAAU;EACR,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,OAAO;EACL,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,QAAQ;EACN,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,SAAS;EACP,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,OAAO;EACL,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,cAAc;EACZ,aACE;EACF,YAAY;EACZ,YAAY;EACb;CACD,cAAc;EACZ,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,gBAAgB;EACd,aAAa;EACb,YACE;EACF,YAAY;EACb;CACD,YAAY;EACV,aACE;EACF,YAAY;EACZ,YAAY;EACb;CACD,WAAW;EACT,aAAa;EACb,YACE;EACF,YAAY;EACb;CACD,SAAS;EACP,aAAa;EACb,YAAY;EACZ,YAAY;EACZ,wBAAwB;EACzB;CACD,KAAK;EACH,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,IAAI;EACF,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACD,KAAK;EACH,aAAa;EACb,YAAY;EACZ,YAAY;EACb;CACF,CAAC;;;;;;;;AASF,MAAa,uBAET,aAAa;CACf,MAAM;EACJ,aACE;EACF,YACE;EACF,YAAY;EACZ,WAAW;EACZ;CAKD,QAAQ;EACN,aACE;EACF,YACE;EACF,YAAY;EACZ,WAAW;EACZ;CACF,CAAC;;AAGF,MAAa,0BAET;CAAE,GAAG;CAAsB,GAAG;CAAsB;;AAGxD,MAAa,sBAAsB;;AAGnC,SAAgB,oBAAoB,MAAc;AAChD,QACE,SAAS,uBACT,OAAO,UAAU,eAAe,KAAK,yBAAyB,KAAK;;;;;;AAQvE,SAAgB,oBAAoB,MAAc;AAChD,KAAI,SAAS,oBAAqB,QAAO;CACzC,MAAM,OAAO,OAAO,UAAU,eAAe,KAC3C,yBACA,KACD,GACG,wBAAwB,QACxB;AACJ,QAAO,SAAS,UAAa,CAAC,KAAK;;;AAIrC,SAAgB,cACd,OAC8D;AAC9D,QACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,MAAM,IACrB,OAAQ,MAAkC,aAAa;;AAsB3D,SAAgB,mBACd,OAC+B;AAC/B,QACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,MAAM,IACrB,OAAQ,MAAkC,UAAU"}
|