@copilotkit/shared 2.0.0-next.1 → 2.0.0-rc.0
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
package/src/index.ts
CHANGED
|
@@ -1,7 +1,196 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export * from "./utils";
|
|
3
3
|
export * from "./constants";
|
|
4
|
-
|
|
4
|
+
// Telemetry is split deliberately. `TelemetryClient` imports
|
|
5
|
+
// `@segment/analytics-node`, which imports `node-fetch`, which imports the
|
|
6
|
+
// Node built-ins `stream`, `http`, `https` and `zlib`. Browser bundlers
|
|
7
|
+
// resolve the whole module graph before they tree-shake, so re-exporting
|
|
8
|
+
// that module here made every browser build of a dependent package print
|
|
9
|
+
// "Module ... has been externalized for browser compatibility" warnings,
|
|
10
|
+
// even when the consumer never touched telemetry (#4151). Only the
|
|
11
|
+
// browser-safe telemetry surface is re-exported from this entry. Server
|
|
12
|
+
// code that needs the client imports it from `@copilotkit/shared/telemetry`.
|
|
13
|
+
// This mirrors the license-verifier note below.
|
|
14
|
+
export { isTelemetryDisabled } from "./telemetry/telemetry-disabled";
|
|
15
|
+
export * from "./telemetry/sampling";
|
|
16
|
+
// Pure string classification with no imports, so it carries no runtime edge
|
|
17
|
+
// into browser builds — same reasoning as `sampling` above.
|
|
18
|
+
export * from "./telemetry/model-host";
|
|
19
|
+
export {
|
|
20
|
+
firstNonBlankTelemetryId,
|
|
21
|
+
lambdaClient,
|
|
22
|
+
parseTelemetryIdFromLicense,
|
|
23
|
+
parseAndWarnTelemetryId,
|
|
24
|
+
} from "./telemetry/lambda-client";
|
|
25
|
+
export type { LambdaSendOptions } from "./telemetry/lambda-client";
|
|
26
|
+
// Types only: erased at build time, so they add no runtime edge to
|
|
27
|
+
// `telemetry-client.ts` and therefore none to @segment/analytics-node.
|
|
28
|
+
export type {
|
|
29
|
+
TelemetryCapture,
|
|
30
|
+
TelemetryIdentity,
|
|
31
|
+
} from "./telemetry/telemetry-client";
|
|
32
|
+
export * from "./debug";
|
|
33
|
+
export * from "./standard-schema";
|
|
34
|
+
export * from "./attachments";
|
|
35
|
+
|
|
36
|
+
export { logger } from "./logger";
|
|
37
|
+
export {
|
|
38
|
+
createRunEventFinalizer,
|
|
39
|
+
finalizeRunEvents,
|
|
40
|
+
type FinalizeRunOptions,
|
|
41
|
+
type RunEventFinalizer,
|
|
42
|
+
} from "./finalize-events";
|
|
43
|
+
export { stripIntelligenceRoutingFields } from "./intelligence-routing-fields";
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
TranscriptionErrorCode,
|
|
47
|
+
TranscriptionErrors,
|
|
48
|
+
type TranscriptionErrorResponse,
|
|
49
|
+
} from "./transcription-errors";
|
|
5
50
|
|
|
6
51
|
import * as packageJson from "../package.json";
|
|
7
52
|
export const COPILOTKIT_VERSION = packageJson.version;
|
|
53
|
+
|
|
54
|
+
// Re-export only types from license-verifier (types are erased at compile time,
|
|
55
|
+
// so they don't pull in the Node-only `crypto` dependency into client bundles).
|
|
56
|
+
// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions
|
|
57
|
+
// like createLicenseChecker and getLicenseWarningHeader directly from
|
|
58
|
+
// @copilotkit/license-verifier.
|
|
59
|
+
export type {
|
|
60
|
+
LicenseChecker,
|
|
61
|
+
LicenseStatus,
|
|
62
|
+
LicensePayload,
|
|
63
|
+
LicenseFeatures,
|
|
64
|
+
LicenseTier,
|
|
65
|
+
LicenseOwner,
|
|
66
|
+
} from "@copilotkit/license-verifier";
|
|
67
|
+
|
|
68
|
+
import type { LicensePayload } from "@copilotkit/license-verifier";
|
|
69
|
+
import type {
|
|
70
|
+
RuntimeEntitlementResponse,
|
|
71
|
+
RuntimeLicenseStatus,
|
|
72
|
+
} from "./utils/types";
|
|
73
|
+
|
|
74
|
+
// LicenseContextValue was dropped from license-verifier's public API in
|
|
75
|
+
// 0.3.0, so it is defined here. The context shape is owned by this package
|
|
76
|
+
// anyway via createLicenseContextValue below.
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* License context value exposed to child components.
|
|
80
|
+
* Frontend providers create their own context using this shape.
|
|
81
|
+
*/
|
|
82
|
+
export interface LicenseContextValue {
|
|
83
|
+
/** Effective license status after structured entitlement precedence. Null until known. */
|
|
84
|
+
status: RuntimeLicenseStatus | null;
|
|
85
|
+
/** The license payload if available. Always null on the client; the payload stays server-side. */
|
|
86
|
+
license: LicensePayload | null;
|
|
87
|
+
/** Whether a feature is licensed. Ready entitlements override legacy status behavior. */
|
|
88
|
+
checkFeature: (feature: string) => boolean;
|
|
89
|
+
/** Get a numeric feature limit. Zero means unlimited; null means not applicable. */
|
|
90
|
+
getLimit: (feature: string) => number | null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Read a record value without traversing its prototype chain. */
|
|
94
|
+
function getOwnRecordValue<Value>(
|
|
95
|
+
record: Readonly<Record<string, Value>>,
|
|
96
|
+
key: string,
|
|
97
|
+
): Value | undefined {
|
|
98
|
+
return Object.prototype.hasOwnProperty.call(record, key)
|
|
99
|
+
? record[key]
|
|
100
|
+
: undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Legacy UI surfaces that remain available for every active entitlement. */
|
|
104
|
+
function isLegacyUiFeature(feature: string): boolean {
|
|
105
|
+
return feature === "chat" || feature === "popup" || feature === "sidebar";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Client-safe license context factory, driven by the license authority the
|
|
110
|
+
* runtime reports via /info.
|
|
111
|
+
*
|
|
112
|
+
* A ready managed entitlement is authoritative in both directions. A ready
|
|
113
|
+
* active self-hosted entitlement is also authoritative, while an inactive
|
|
114
|
+
* self-hosted response preserves the legacy signed-license fallback. Active
|
|
115
|
+
* entitlements supply feature grants and limits; authoritative inactive
|
|
116
|
+
* entitlements deny every feature and limit. Older runtimes that report only a
|
|
117
|
+
* status retain the legacy behavior: features are enabled unless the status is
|
|
118
|
+
* "expired" or "invalid", and no limits are reported. This is inlined here to
|
|
119
|
+
* avoid importing the full license-verifier bundle (which depends on Node's
|
|
120
|
+
* `crypto`) into browser bundles.
|
|
121
|
+
*/
|
|
122
|
+
export function createLicenseContextValue(
|
|
123
|
+
status: RuntimeLicenseStatus | null | undefined,
|
|
124
|
+
runtimeEntitlements?: RuntimeEntitlementResponse,
|
|
125
|
+
): LicenseContextValue {
|
|
126
|
+
const readyEntitlement =
|
|
127
|
+
runtimeEntitlements?.status === "ready"
|
|
128
|
+
? runtimeEntitlements.entitlement
|
|
129
|
+
: null;
|
|
130
|
+
const hasUsableSelfHostedLegacyFallback =
|
|
131
|
+
readyEntitlement &&
|
|
132
|
+
!readyEntitlement.active &&
|
|
133
|
+
readyEntitlement.source === "selfHostedDeploymentLicense" &&
|
|
134
|
+
(status === "valid" || status === "expiring");
|
|
135
|
+
const featureAuthority =
|
|
136
|
+
readyEntitlement && !hasUsableSelfHostedLegacyFallback
|
|
137
|
+
? readyEntitlement
|
|
138
|
+
: null;
|
|
139
|
+
const activeEntitlement = featureAuthority?.active ? featureAuthority : null;
|
|
140
|
+
const resolvedStatus = activeEntitlement
|
|
141
|
+
? "valid"
|
|
142
|
+
: readyEntitlement?.source === "managedOrgSubscription" ||
|
|
143
|
+
readyEntitlement?.source === "awsMarketplaceDeploymentLicense"
|
|
144
|
+
? "none"
|
|
145
|
+
: featureAuthority
|
|
146
|
+
? (status ?? "none")
|
|
147
|
+
: (status ?? null);
|
|
148
|
+
const featuresEnabled =
|
|
149
|
+
resolvedStatus !== "expired" && resolvedStatus !== "invalid";
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
status: resolvedStatus,
|
|
153
|
+
license: null,
|
|
154
|
+
checkFeature: (feature) =>
|
|
155
|
+
featureAuthority
|
|
156
|
+
? activeEntitlement
|
|
157
|
+
? feature === "threads" &&
|
|
158
|
+
Object.prototype.hasOwnProperty.call(
|
|
159
|
+
activeEntitlement.limits,
|
|
160
|
+
"threads.max_count",
|
|
161
|
+
)
|
|
162
|
+
? true
|
|
163
|
+
: (getOwnRecordValue(activeEntitlement.features, feature) ??
|
|
164
|
+
isLegacyUiFeature(feature))
|
|
165
|
+
: false
|
|
166
|
+
: featuresEnabled,
|
|
167
|
+
getLimit: (feature) =>
|
|
168
|
+
activeEntitlement
|
|
169
|
+
? (getOwnRecordValue(activeEntitlement.limits, feature) ?? null)
|
|
170
|
+
: null,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export {
|
|
175
|
+
A2UI_DEFAULT_GENERATION_GUIDELINES,
|
|
176
|
+
A2UI_DEFAULT_DESIGN_GUIDELINES,
|
|
177
|
+
ALL_GENERATIVE_UI_GUIDE_FEATURES,
|
|
178
|
+
buildGenerativeUIMarkdownGuidelines,
|
|
179
|
+
generativeUIGuideFeatures,
|
|
180
|
+
GENERATIVE_UI_MARKDOWN_GUIDELINES,
|
|
181
|
+
GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION,
|
|
182
|
+
GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION,
|
|
183
|
+
} from "./a2ui-prompts";
|
|
184
|
+
export type { GenerativeUIGuideFeatures } from "./a2ui-prompts";
|
|
185
|
+
export {
|
|
186
|
+
COPILOTKIT_FORWARDED_PROPS_KEY,
|
|
187
|
+
COPILOTKIT_UI_ENVELOPE_FORMAT,
|
|
188
|
+
envelopeToManifest,
|
|
189
|
+
readCopilotKitUIEnvelope,
|
|
190
|
+
} from "./a2ui-envelope";
|
|
191
|
+
export type { CopilotKitUIEnvelope } from "./a2ui-envelope";
|
|
192
|
+
|
|
193
|
+
export type { DebugEventEnvelope } from "./debug-event-envelope";
|
|
194
|
+
|
|
195
|
+
export { GENERATE_SANDBOXED_UI_DESCRIPTION } from "./open-generative-ui-prompts";
|
|
196
|
+
export * from "./generative-ui";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BaseEvent } from "@ag-ui/client";
|
|
2
|
+
import { EventType } from "@ag-ui/client";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { stripIntelligenceRoutingFields } from "./intelligence-routing-fields";
|
|
5
|
+
|
|
6
|
+
const stamped = {
|
|
7
|
+
threadId: "t1",
|
|
8
|
+
runId: "r1",
|
|
9
|
+
thread_id: "t1",
|
|
10
|
+
run_id: "r1",
|
|
11
|
+
metadata: { cpki_event_id: "e1" },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe("stripIntelligenceRoutingFields", () => {
|
|
15
|
+
it("removes all routing fields from an event that does not declare them", () => {
|
|
16
|
+
const event = {
|
|
17
|
+
type: EventType.TEXT_MESSAGE_CONTENT,
|
|
18
|
+
messageId: "m1",
|
|
19
|
+
delta: "hi",
|
|
20
|
+
...stamped,
|
|
21
|
+
} as BaseEvent;
|
|
22
|
+
|
|
23
|
+
expect(stripIntelligenceRoutingFields(event)).toEqual({
|
|
24
|
+
type: EventType.TEXT_MESSAGE_CONTENT,
|
|
25
|
+
messageId: "m1",
|
|
26
|
+
delta: "hi",
|
|
27
|
+
metadata: { cpki_event_id: "e1" },
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("keeps threadId and runId on the run events that declare them", () => {
|
|
32
|
+
const event = { type: EventType.RUN_FINISHED, ...stamped } as BaseEvent;
|
|
33
|
+
|
|
34
|
+
expect(stripIntelligenceRoutingFields(event)).toEqual({
|
|
35
|
+
type: EventType.RUN_FINISHED,
|
|
36
|
+
threadId: "t1",
|
|
37
|
+
runId: "r1",
|
|
38
|
+
metadata: { cpki_event_id: "e1" },
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("returns an event without routing fields unchanged", () => {
|
|
43
|
+
const event = {
|
|
44
|
+
type: EventType.RUN_STARTED,
|
|
45
|
+
threadId: "t1",
|
|
46
|
+
runId: "r1",
|
|
47
|
+
} as BaseEvent;
|
|
48
|
+
|
|
49
|
+
expect(stripIntelligenceRoutingFields(event)).toBe(event);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BaseEvent } from "@ag-ui/client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The only AG-UI 1.0 events whose schema declares `threadId` and `runId`.
|
|
5
|
+
* Plain literals, not `EventType`: a value import of `@ag-ui/client` here put
|
|
6
|
+
* the client and its zod validators into the initial chunk of every app that
|
|
7
|
+
* imports `@copilotkit/shared`.
|
|
8
|
+
*/
|
|
9
|
+
const RUN_IDENTITY_EVENTS = new Set<string>(["RUN_STARTED", "RUN_FINISHED"]);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Removes the routing fields that the Intelligence runner stamps on every
|
|
13
|
+
* event it sends to the gateway (`thread_id`, `run_id`, and `threadId` /
|
|
14
|
+
* `runId` on events that do not declare them).
|
|
15
|
+
*
|
|
16
|
+
* The gateway relays these payloads unchanged. AG-UI 1.0 strips unknown
|
|
17
|
+
* fields before subscribers see them and warns once per field, per event,
|
|
18
|
+
* so a streamed answer would log hundreds of warnings. Call this where a
|
|
19
|
+
* gateway payload enters an AG-UI pipeline. The gateway still receives the
|
|
20
|
+
* fields, because the runner adds them after this point.
|
|
21
|
+
*/
|
|
22
|
+
export function stripIntelligenceRoutingFields<T extends BaseEvent>(
|
|
23
|
+
event: T,
|
|
24
|
+
): T {
|
|
25
|
+
const record = event as T & Record<string, unknown>;
|
|
26
|
+
const keepRunIdentity = RUN_IDENTITY_EVENTS.has(record.type);
|
|
27
|
+
if (
|
|
28
|
+
!("thread_id" in record) &&
|
|
29
|
+
!("run_id" in record) &&
|
|
30
|
+
(keepRunIdentity || (!("threadId" in record) && !("runId" in record)))
|
|
31
|
+
) {
|
|
32
|
+
return event;
|
|
33
|
+
}
|
|
34
|
+
const { thread_id: _t, run_id: _r, ...rest } = record;
|
|
35
|
+
if (!keepRunIdentity) {
|
|
36
|
+
delete rest.threadId;
|
|
37
|
+
delete rest.runId;
|
|
38
|
+
}
|
|
39
|
+
return rest as unknown as T;
|
|
40
|
+
}
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const logger = console;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Shared generation contract for all Open Generative UI renderers. */
|
|
2
|
+
export const GENERATE_SANDBOXED_UI_DESCRIPTION =
|
|
3
|
+
"Generate sandboxed UI. " +
|
|
4
|
+
"IMPORTANT: The generated code runs in a sandboxed iframe WITHOUT same-origin access. " +
|
|
5
|
+
"Do NOT use localStorage, sessionStorage, document.cookie, IndexedDB, or fetch/XMLHttpRequest to same-origin URLs. " +
|
|
6
|
+
"To communicate with the host application, use Websandbox.connection.remote.<functionName>(args) which returns a Promise.\n\n" +
|
|
7
|
+
"You CAN use external libraries from CDNs by including <script> or <link> tags in the HTML <head> (e.g., Chart.js, D3, Three.js, x-data-spreadsheet, etc.). " +
|
|
8
|
+
"CDN resources load normally inside the sandbox.\n\n" +
|
|
9
|
+
"PARAMETER ORDER IS CRITICAL — generate parameters in exactly this order:\n" +
|
|
10
|
+
"1. initialHeight + placeholderMessages (shown to user while generating)\n" +
|
|
11
|
+
"2. css (all styles FIRST — the user sees a placeholder until CSS is complete)\n" +
|
|
12
|
+
"3. html (streams in live — the user watches the UI build as HTML is generated)\n" +
|
|
13
|
+
"4. jsFunctions (reusable helper functions)\n" +
|
|
14
|
+
"5. jsExpressions (applied one-by-one — the user sees each expression take effect)" +
|
|
15
|
+
"\n\nINITIALIZATION CONTRACT: jsFunctions and jsExpressions run after the final HTML DOM is ready, in both live generation and saved-thread replay. " +
|
|
16
|
+
"Define reusable functions in jsFunctions, then initialize the UI directly in the first jsExpressions entry (for example, initializeCalculator()). " +
|
|
17
|
+
"Attach click/keyboard handlers and set initial display values there. Do NOT wait for DOMContentLoaded, window.onload, or the load event in jsFunctions or jsExpressions: these events may already have fired. " +
|
|
18
|
+
"Each expression is executed once per rendered sandbox; later expressions must not repeat initialization or reattach the same handlers. " +
|
|
19
|
+
"Keep initialization self-contained so a new sandbox can reconstruct the UI when a saved thread is opened. If a library loads asynchronously, initialize from its explicit load promise instead of waiting for document readiness.\n\n" +
|
|
20
|
+
"INTERACTION CONTRACT: Every visible interactive control needs a working handler, including controls created during initialization. If the handlers are supplied through jsFunctions/jsExpressions, initialize them in the first expression; if supplied by an inline HTML script, ensure it runs when the final sandbox mounts and replays. Every user action must update the visible UI to reflect its completed result, including success and error paths. Changing a JavaScript variable alone does not update the DOM. After changing state, call the rendering function or update the displayed element directly. When delegating clicks from a parent element, resolve the clicked control with closest('button') so clicks on nested labels and values work. For a calculator, pressing = must replace the visible expression with the computed answer; metric shortcuts must visibly insert their values. Trace each button handler through its final display update before emitting the tool call.";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
StandardSchemaV1,
|
|
3
|
+
StandardJSONSchemaV1,
|
|
4
|
+
} from "@standard-schema/spec";
|
|
5
|
+
|
|
6
|
+
export type { StandardSchemaV1, StandardJSONSchemaV1 };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Extract the Output type from a StandardSchemaV1 schema.
|
|
10
|
+
* Replaces `z.infer<S>` for generic schema inference.
|
|
11
|
+
*/
|
|
12
|
+
export type InferSchemaOutput<S> =
|
|
13
|
+
S extends StandardSchemaV1<any, infer O> ? O : never;
|
|
14
|
+
|
|
15
|
+
export interface SchemaToJsonSchemaOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Injected `zodToJsonSchema` function so that `shared` does not depend on
|
|
18
|
+
* `zod-to-json-schema`. Required when the schema is a Zod v3 schema that
|
|
19
|
+
* does not implement Standard JSON Schema V1.
|
|
20
|
+
*/
|
|
21
|
+
zodToJsonSchema?: (
|
|
22
|
+
schema: unknown,
|
|
23
|
+
options?: { $refStrategy?: string },
|
|
24
|
+
) => Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Check whether a schema implements the Standard JSON Schema V1 protocol.
|
|
29
|
+
*/
|
|
30
|
+
function hasStandardJsonSchema(
|
|
31
|
+
schema: StandardSchemaV1,
|
|
32
|
+
): schema is StandardSchemaV1 & StandardJSONSchemaV1 {
|
|
33
|
+
const props = schema["~standard"];
|
|
34
|
+
return (
|
|
35
|
+
props != null &&
|
|
36
|
+
typeof props === "object" &&
|
|
37
|
+
"jsonSchema" in props &&
|
|
38
|
+
props.jsonSchema != null &&
|
|
39
|
+
typeof props.jsonSchema === "object" &&
|
|
40
|
+
"input" in props.jsonSchema &&
|
|
41
|
+
typeof props.jsonSchema.input === "function"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Convert any StandardSchemaV1-compatible schema to a JSON Schema object.
|
|
47
|
+
*
|
|
48
|
+
* Strategy:
|
|
49
|
+
* 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
|
|
50
|
+
* call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
|
|
51
|
+
* 2. If the schema exposes a `toJSONSchema()` method (Zod v4), call it directly.
|
|
52
|
+
* 3. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the
|
|
53
|
+
* injected `zodToJsonSchema()` function.
|
|
54
|
+
* 4. Otherwise throw a descriptive error.
|
|
55
|
+
*/
|
|
56
|
+
export function schemaToJsonSchema(
|
|
57
|
+
schema: StandardSchemaV1,
|
|
58
|
+
options?: SchemaToJsonSchemaOptions,
|
|
59
|
+
): Record<string, unknown> {
|
|
60
|
+
// 1. Standard JSON Schema V1
|
|
61
|
+
if (hasStandardJsonSchema(schema)) {
|
|
62
|
+
return schema["~standard"].jsonSchema.input({ target: "draft-07" });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 2. Zod v4 native — exposes toJSONSchema() on the schema itself
|
|
66
|
+
if (typeof (schema as any).toJSONSchema === "function") {
|
|
67
|
+
return (schema as any).toJSONSchema() as Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 3. Zod v3 fallback
|
|
71
|
+
const vendor = schema["~standard"].vendor;
|
|
72
|
+
if (vendor === "zod" && options?.zodToJsonSchema) {
|
|
73
|
+
return options.zodToJsonSchema(schema, { $refStrategy: "none" });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1 ` +
|
|
78
|
+
`and no zodToJsonSchema fallback is available. ` +
|
|
79
|
+
`Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) ` +
|
|
80
|
+
`or pass a zodToJsonSchema function in options.`,
|
|
81
|
+
);
|
|
82
|
+
}
|
package/src/telemetry/events.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ModelHostClass } from "./model-host";
|
|
2
|
+
|
|
1
3
|
export type AnalyticsEvents = {
|
|
2
4
|
"oss.runtime.instance_created": RuntimeInstanceCreatedInfo;
|
|
3
5
|
"oss.runtime.copilot_request_created": {
|
|
@@ -7,13 +9,35 @@ export type AnalyticsEvents = {
|
|
|
7
9
|
"cloud.public_api_key"?: string;
|
|
8
10
|
"cloud.base_url"?: string;
|
|
9
11
|
};
|
|
10
|
-
"oss.runtime.server_action_executed": {};
|
|
11
|
-
"oss.runtime.remote_action_executed": RemoteActionExecutionInfo;
|
|
12
12
|
"oss.runtime.agent_execution_stream_started": { hashedLgcKey?: string };
|
|
13
13
|
"oss.runtime.agent_execution_stream_ended": AgentExecutionResponseInfo;
|
|
14
|
-
"oss.runtime.agent_execution_stream_errored": {
|
|
14
|
+
"oss.runtime.agent_execution_stream_errored": {
|
|
15
|
+
hashedLgcKey?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A managed Channel lost its gateway link. Carries only the cause we already
|
|
20
|
+
* compute for the log line — never the Channel name, which is a
|
|
21
|
+
* customer-chosen identifier, and never message content.
|
|
22
|
+
*/
|
|
23
|
+
"oss.runtime.channel_session_dropped": ChannelSessionDroppedInfo;
|
|
24
|
+
/** A managed Channel's gateway link came back, and how long it was gone. */
|
|
25
|
+
"oss.runtime.channel_session_recovered": { downForMs: number };
|
|
15
26
|
};
|
|
16
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Kept identical to the v2 runtime's catalog in
|
|
30
|
+
* `packages/runtime/src/runtime/telemetry/events.ts`. The v1 entrypoint
|
|
31
|
+
* hands its capture scope to the V2 runtime it builds, so that scope has to
|
|
32
|
+
* accept every event the V2 runtime can send, channel events included.
|
|
33
|
+
*/
|
|
34
|
+
export interface ChannelSessionDroppedInfo {
|
|
35
|
+
/** Diagnosis of the drop, e.g. `the gateway host answered HTTP 502`. */
|
|
36
|
+
reason?: string;
|
|
37
|
+
/** Transport/OS code when the transport named one, e.g. `ECONNRESET`. */
|
|
38
|
+
code?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
17
41
|
export interface RuntimeInstanceCreatedInfo {
|
|
18
42
|
actionsAmount: number;
|
|
19
43
|
endpointTypes: string[];
|
|
@@ -25,14 +49,17 @@ export interface RuntimeInstanceCreatedInfo {
|
|
|
25
49
|
"cloud.base_url"?: string;
|
|
26
50
|
}
|
|
27
51
|
|
|
28
|
-
export interface RemoteActionExecutionInfo {
|
|
29
|
-
agentExecution: boolean;
|
|
30
|
-
type: "self-hosted" | "langgraph-platform";
|
|
31
|
-
agentsAmount?: number | null;
|
|
32
|
-
hashedLgcKey?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
52
|
export interface AgentExecutionResponseInfo {
|
|
53
|
+
/**
|
|
54
|
+
* Which vendor the runtime actually sent the completion to, as a closed
|
|
55
|
+
* vocabulary — see `classifyModelHost`. Distinct from `provider` below,
|
|
56
|
+
* which the upstream reports as a model name and which cannot tell Azure,
|
|
57
|
+
* OpenRouter or a local server apart from OpenAI.
|
|
58
|
+
*
|
|
59
|
+
* `unknown` when the developer handed us an already-built model, because
|
|
60
|
+
* the endpoint is unrecoverable from one.
|
|
61
|
+
*/
|
|
62
|
+
llmHostClass?: ModelHostClass;
|
|
36
63
|
provider?: string;
|
|
37
64
|
model?: string;
|
|
38
65
|
langGraphHost?: string;
|
package/src/telemetry/index.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
1
|
export * from "./telemetry-client";
|
|
2
|
+
export * from "./sampling";
|
|
3
|
+
export {
|
|
4
|
+
firstNonBlankTelemetryId,
|
|
5
|
+
lambdaClient,
|
|
6
|
+
parseTelemetryIdFromLicense,
|
|
7
|
+
parseAndWarnTelemetryId,
|
|
8
|
+
} from "./lambda-client";
|
|
9
|
+
export type { LambdaSendOptions } from "./lambda-client";
|