@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
|
@@ -1,32 +1,67 @@
|
|
|
1
1
|
import { Analytics } from "@segment/analytics-node";
|
|
2
|
-
import { AnalyticsEvents } from "./events";
|
|
2
|
+
import type { AnalyticsEvents } from "./events";
|
|
3
3
|
import { flattenObject } from "./utils";
|
|
4
4
|
import { v4 as uuidv4 } from "uuid";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
import {
|
|
6
|
+
firstNonBlankTelemetryId,
|
|
7
|
+
lambdaClient,
|
|
8
|
+
parseAndWarnTelemetryId,
|
|
9
|
+
} from "./lambda-client";
|
|
10
|
+
import {
|
|
11
|
+
computeSamplingMeta,
|
|
12
|
+
TELEMETRY_EMITTER_V1,
|
|
13
|
+
TELEMETRY_SURFACE_V1,
|
|
14
|
+
UNSAMPLED_RATE,
|
|
15
|
+
} from "./sampling";
|
|
16
|
+
import { isTelemetryDisabled } from "./telemetry-disabled";
|
|
17
|
+
|
|
18
|
+
export { isTelemetryDisabled };
|
|
19
|
+
|
|
20
|
+
/** Transport identity and sampling authority resolved for one runtime. */
|
|
21
|
+
export interface TelemetryIdentity {
|
|
22
|
+
telemetryId?: string;
|
|
23
|
+
licenseToken?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Capture-only telemetry client bound to one runtime identity. */
|
|
27
|
+
export interface TelemetryCapture {
|
|
28
|
+
capture<K extends keyof AnalyticsEvents>(
|
|
29
|
+
event: K,
|
|
30
|
+
properties: AnalyticsEvents[K],
|
|
31
|
+
): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface ResolvedTelemetryIdentity {
|
|
35
|
+
telemetryId: string | null;
|
|
36
|
+
licenseToken: string | null;
|
|
37
|
+
licenseTelemetryId: string | null;
|
|
20
38
|
}
|
|
21
39
|
|
|
22
40
|
export class TelemetryClient {
|
|
23
41
|
segment: Analytics | undefined;
|
|
24
42
|
globalProperties: Record<string, any> = {};
|
|
25
43
|
cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;
|
|
44
|
+
// EIP / Intelligence license token (Ed25519-signed JWT). The lambda
|
|
45
|
+
// client decodes its payload to extract telemetry_id. Customer API
|
|
46
|
+
// keys are NOT used here — they flow only into Segment.
|
|
47
|
+
private licenseToken: string | null = null;
|
|
48
|
+
// Standalone analytics identity. This stays separate from the effective
|
|
49
|
+
// identity so legacy callers continue sending only their license token to
|
|
50
|
+
// the Lambda transport.
|
|
51
|
+
private telemetryId: string | null = null;
|
|
52
|
+
// License-derived identity used only as sampling authority. A standalone
|
|
53
|
+
// telemetry id remains a transport claim and does not bypass the
|
|
54
|
+
// Segment gate.
|
|
55
|
+
private licenseTelemetryId: string | null = null;
|
|
26
56
|
packageName: string;
|
|
27
57
|
packageVersion: string;
|
|
28
58
|
private telemetryDisabled: boolean = false;
|
|
29
|
-
|
|
59
|
+
// Client-side sampling rate for anonymous events on the Segment wire
|
|
60
|
+
// only. The lambda sink is ours and takes every event; Segment is
|
|
61
|
+
// billed per event, so the anonymous population stays capped there.
|
|
62
|
+
// Identified events (those whose license token yielded a telemetry_id)
|
|
63
|
+
// bypass the gate on both wires.
|
|
64
|
+
private segmentSampleRate: number = 0.05;
|
|
30
65
|
private anonymousId = `anon_${uuidv4()}`;
|
|
31
66
|
|
|
32
67
|
constructor({
|
|
@@ -40,6 +75,8 @@ export class TelemetryClient {
|
|
|
40
75
|
packageVersion: string;
|
|
41
76
|
telemetryDisabled?: boolean;
|
|
42
77
|
telemetryBaseUrl?: string;
|
|
78
|
+
// Anonymous sampling rate for the Segment wire. Named without the
|
|
79
|
+
// prefix for backward compatibility; the lambda sink ignores it.
|
|
43
80
|
sampleRate?: number;
|
|
44
81
|
}) {
|
|
45
82
|
this.packageName = packageName;
|
|
@@ -53,7 +90,9 @@ export class TelemetryClient {
|
|
|
53
90
|
this.setSampleRate(sampleRate);
|
|
54
91
|
|
|
55
92
|
// eslint-disable-next-line
|
|
56
|
-
const writeKey =
|
|
93
|
+
const writeKey =
|
|
94
|
+
process.env.COPILOTKIT_SEGMENT_WRITE_KEY ||
|
|
95
|
+
"n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja";
|
|
57
96
|
|
|
58
97
|
this.segment = new Analytics({
|
|
59
98
|
writeKey,
|
|
@@ -65,19 +104,76 @@ export class TelemetryClient {
|
|
|
65
104
|
});
|
|
66
105
|
}
|
|
67
106
|
|
|
68
|
-
private
|
|
107
|
+
private shouldSendToSegment() {
|
|
69
108
|
const randomNumber = Math.random();
|
|
70
|
-
return randomNumber < this.
|
|
109
|
+
return randomNumber < this.segmentSampleRate;
|
|
71
110
|
}
|
|
72
111
|
|
|
73
|
-
async capture<K extends keyof AnalyticsEvents>(
|
|
74
|
-
|
|
112
|
+
async capture<K extends keyof AnalyticsEvents>(
|
|
113
|
+
event: K,
|
|
114
|
+
properties: AnalyticsEvents[K],
|
|
115
|
+
): Promise<void> {
|
|
116
|
+
return this.captureWithIdentity(event, properties, {
|
|
117
|
+
telemetryId: this.telemetryId,
|
|
118
|
+
licenseToken: this.licenseToken,
|
|
119
|
+
licenseTelemetryId: this.licenseTelemetryId,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private async captureWithIdentity<K extends keyof AnalyticsEvents>(
|
|
124
|
+
event: K,
|
|
125
|
+
properties: AnalyticsEvents[K],
|
|
126
|
+
identity: ResolvedTelemetryIdentity,
|
|
127
|
+
): Promise<void> {
|
|
128
|
+
// Re-read the environment: an opt-out set after import (for example a
|
|
129
|
+
// dotenv call below the imports) must still stop events.
|
|
130
|
+
if (this.telemetryDisabled || isTelemetryDisabled()) {
|
|
75
131
|
return;
|
|
76
132
|
}
|
|
77
133
|
|
|
134
|
+
// The two wires are gated separately. The lambda sink takes every
|
|
135
|
+
// event: it is CopilotKit-owned, so anonymous volume costs nothing
|
|
136
|
+
// per event there and a real count beats one extrapolated from 5% of
|
|
137
|
+
// the population. Segment is billed per event, so it keeps the gate —
|
|
138
|
+
// callers without license-derived sampling authority are dropped from
|
|
139
|
+
// that copy at segmentSampleRate. Legacy license tokens with a
|
|
140
|
+
// telemetry_id send on both wires: the volume is bounded by
|
|
141
|
+
// paying-customer count and full fidelity per identified customer is
|
|
142
|
+
// worth the marginal cost.
|
|
143
|
+
const sendToSegment =
|
|
144
|
+
Boolean(identity.licenseTelemetryId) || this.shouldSendToSegment();
|
|
145
|
+
|
|
146
|
+
// Sampling metadata is computed in ./sampling so this client and the
|
|
147
|
+
// v2 runtime client can't drift apart again — see the note there.
|
|
148
|
+
// One call per wire, because the two wires were gated differently and
|
|
149
|
+
// a shared block would overweight the lambda copy by 1/sampleRate.
|
|
150
|
+
const lambdaSamplingMeta = computeSamplingMeta({
|
|
151
|
+
telemetryId: identity.licenseTelemetryId,
|
|
152
|
+
sampleRate: UNSAMPLED_RATE,
|
|
153
|
+
});
|
|
154
|
+
const segmentSamplingMeta = computeSamplingMeta({
|
|
155
|
+
telemetryId: identity.licenseTelemetryId,
|
|
156
|
+
sampleRate: this.segmentSampleRate,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Everything below travels identically on both copies of this event.
|
|
160
|
+
// The event id is what makes the dual-write dedupable downstream:
|
|
161
|
+
// one capture() produces one id, stamped on the lambda copy and the
|
|
162
|
+
// Segment copy alike, so consumers no longer have to infer the
|
|
163
|
+
// duplication from $lib or from which fields happen to be present
|
|
164
|
+
// (OSS-1019).
|
|
165
|
+
const eventMeta = {
|
|
166
|
+
telemetry_emitter: TELEMETRY_EMITTER_V1,
|
|
167
|
+
telemetry_surface: TELEMETRY_SURFACE_V1,
|
|
168
|
+
telemetry_event_id: uuidv4(),
|
|
169
|
+
};
|
|
170
|
+
|
|
78
171
|
const flattenedProperties = flattenObject(properties);
|
|
79
|
-
const propertiesWithGlobal = {
|
|
172
|
+
const propertiesWithGlobal: Record<string, any> = {
|
|
80
173
|
...this.globalProperties,
|
|
174
|
+
...eventMeta,
|
|
175
|
+
...segmentSamplingMeta,
|
|
176
|
+
telemetry_transport: "segment",
|
|
81
177
|
...flattenedProperties,
|
|
82
178
|
};
|
|
83
179
|
const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal)
|
|
@@ -90,20 +186,36 @@ export class TelemetryClient {
|
|
|
90
186
|
{} as Record<string, any>,
|
|
91
187
|
);
|
|
92
188
|
|
|
93
|
-
|
|
94
|
-
anonymousId: this.anonymousId,
|
|
189
|
+
await lambdaClient.send({
|
|
95
190
|
event,
|
|
96
|
-
properties:
|
|
191
|
+
properties: flattenedProperties,
|
|
192
|
+
globalProperties: {
|
|
193
|
+
...this.globalProperties,
|
|
194
|
+
...eventMeta,
|
|
195
|
+
...lambdaSamplingMeta,
|
|
196
|
+
telemetry_transport: "lambda",
|
|
197
|
+
},
|
|
198
|
+
packageName: this.packageName,
|
|
199
|
+
packageVersion: this.packageVersion,
|
|
200
|
+
telemetryId: identity.telemetryId ?? undefined,
|
|
201
|
+
licenseToken: identity.licenseToken ?? undefined,
|
|
97
202
|
});
|
|
98
203
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
204
|
+
if (this.segment && sendToSegment) {
|
|
205
|
+
this.segment.track({
|
|
206
|
+
anonymousId: this.anonymousId,
|
|
207
|
+
event,
|
|
208
|
+
properties: { ...orderedPropertiesWithGlobal },
|
|
209
|
+
});
|
|
210
|
+
}
|
|
102
211
|
}
|
|
103
212
|
|
|
104
213
|
setGlobalProperties(properties: Record<string, any>) {
|
|
105
214
|
const flattenedProperties = flattenObject(properties);
|
|
106
|
-
this.globalProperties = {
|
|
215
|
+
this.globalProperties = {
|
|
216
|
+
...this.globalProperties,
|
|
217
|
+
...flattenedProperties,
|
|
218
|
+
};
|
|
107
219
|
}
|
|
108
220
|
|
|
109
221
|
setCloudConfiguration(properties: { publicApiKey: string; baseUrl: string }) {
|
|
@@ -117,6 +229,77 @@ export class TelemetryClient {
|
|
|
117
229
|
});
|
|
118
230
|
}
|
|
119
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Atomically configure standalone, legacy, or anonymous telemetry identity.
|
|
234
|
+
*
|
|
235
|
+
* A standalone id takes transport precedence over a supplied legacy license
|
|
236
|
+
* token, but only a license-derived id grants sampling authority. Neither
|
|
237
|
+
* value is added to event properties.
|
|
238
|
+
*
|
|
239
|
+
* @param identity - One standalone id, one legacy license token, or neither.
|
|
240
|
+
*/
|
|
241
|
+
setTelemetryIdentity(identity: {
|
|
242
|
+
telemetryId?: string;
|
|
243
|
+
licenseToken?: string;
|
|
244
|
+
}): void {
|
|
245
|
+
const resolvedIdentity = this.resolveTelemetryIdentity(identity);
|
|
246
|
+
this.telemetryId = resolvedIdentity.telemetryId;
|
|
247
|
+
this.licenseToken = resolvedIdentity.licenseToken;
|
|
248
|
+
this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Configure legacy license-derived telemetry identity.
|
|
253
|
+
*
|
|
254
|
+
* @param licenseToken - License token whose telemetry claim identifies sends.
|
|
255
|
+
*/
|
|
256
|
+
setLicenseToken(licenseToken: string) {
|
|
257
|
+
this.setTelemetryIdentity({ licenseToken });
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Create an immutable capture scope for one runtime.
|
|
262
|
+
*
|
|
263
|
+
* The scope shares this client's sinks, process-wide opt-out, global
|
|
264
|
+
* properties, and Segment sampling rate, but snapshots transport identity and
|
|
265
|
+
* license-derived sampling authority. Constructing another runtime cannot
|
|
266
|
+
* rewrite an existing scope.
|
|
267
|
+
*
|
|
268
|
+
* @param identity - The runtime's construction-time telemetry identity.
|
|
269
|
+
* @returns A capture-only client bound to that identity.
|
|
270
|
+
*/
|
|
271
|
+
createScope(identity: TelemetryIdentity): TelemetryCapture {
|
|
272
|
+
const resolvedIdentity = this.resolveTelemetryIdentity(identity);
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
capture: <K extends keyof AnalyticsEvents>(
|
|
276
|
+
event: K,
|
|
277
|
+
properties: AnalyticsEvents[K],
|
|
278
|
+
) => this.captureWithIdentity(event, properties, resolvedIdentity),
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private resolveTelemetryIdentity(
|
|
283
|
+
identity: TelemetryIdentity,
|
|
284
|
+
): ResolvedTelemetryIdentity {
|
|
285
|
+
const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);
|
|
286
|
+
if (telemetryId !== undefined) {
|
|
287
|
+
return {
|
|
288
|
+
telemetryId,
|
|
289
|
+
licenseToken: null,
|
|
290
|
+
licenseTelemetryId: null,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
telemetryId: null,
|
|
296
|
+
licenseToken: identity.licenseToken ?? null,
|
|
297
|
+
licenseTelemetryId: identity.licenseToken
|
|
298
|
+
? parseAndWarnTelemetryId(identity.licenseToken)
|
|
299
|
+
: null,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
120
303
|
private setSampleRate(sampleRate: number | undefined) {
|
|
121
304
|
let _sampleRate: number;
|
|
122
305
|
|
|
@@ -128,15 +311,18 @@ export class TelemetryClient {
|
|
|
128
311
|
_sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
|
|
129
312
|
}
|
|
130
313
|
|
|
131
|
-
|
|
314
|
+
// Number.isNaN guards against parseFloat("nonsense") slipping past the
|
|
315
|
+
// range check (all NaN comparisons are false), which would silently
|
|
316
|
+
// drop every anonymous Segment event with no signal.
|
|
317
|
+
if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) {
|
|
132
318
|
throw new Error("Sample rate must be between 0 and 1");
|
|
133
319
|
}
|
|
134
320
|
|
|
135
|
-
this.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
321
|
+
this.segmentSampleRate = _sampleRate;
|
|
322
|
+
// Per-event sampling metadata (sampleRate/sampleRateAdjustmentFactor/
|
|
323
|
+
// sampleWeight) is computed per capture() in ./sampling, once per
|
|
324
|
+
// wire. Only license-authorized events get effectiveSampleRate=1 on
|
|
325
|
+
// the Segment copy; standalone transport identity stays in the
|
|
326
|
+
// sampled population there. The lambda copy is always unsampled.
|
|
141
327
|
}
|
|
142
328
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if telemetry is disabled via environment variables.
|
|
3
|
+
* Users can opt out by setting:
|
|
4
|
+
* - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
|
|
5
|
+
* - DO_NOT_TRACK=true or DO_NOT_TRACK=1
|
|
6
|
+
*
|
|
7
|
+
* Lives in its own module so that the browser-facing root entry can
|
|
8
|
+
* re-export it without pulling in `telemetry-client.ts`, whose
|
|
9
|
+
* `@segment/analytics-node` import drags Node built-ins into browser
|
|
10
|
+
* bundler module graphs. See the note in `../index.ts`.
|
|
11
|
+
*/
|
|
12
|
+
export function isTelemetryDisabled(): boolean {
|
|
13
|
+
return (
|
|
14
|
+
(process.env as Record<string, string | undefined>)
|
|
15
|
+
.COPILOTKIT_TELEMETRY_DISABLED === "true" ||
|
|
16
|
+
(process.env as Record<string, string | undefined>)
|
|
17
|
+
.COPILOTKIT_TELEMETRY_DISABLED === "1" ||
|
|
18
|
+
(process.env as Record<string, string | undefined>).DO_NOT_TRACK ===
|
|
19
|
+
"true" ||
|
|
20
|
+
(process.env as Record<string, string | undefined>).DO_NOT_TRACK === "1"
|
|
21
|
+
);
|
|
22
|
+
}
|
package/src/telemetry/utils.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
|
|
3
1
|
export function flattenObject(
|
|
4
2
|
obj: Record<string, any>,
|
|
5
3
|
parentKey = "",
|
|
@@ -15,25 +13,3 @@ export function flattenObject(
|
|
|
15
13
|
}
|
|
16
14
|
return res;
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
export function printSecurityNotice(advisory: {
|
|
20
|
-
advisory: string | null;
|
|
21
|
-
message: string;
|
|
22
|
-
severity: "low" | "medium" | "high" | "none";
|
|
23
|
-
}) {
|
|
24
|
-
const severityColor =
|
|
25
|
-
{
|
|
26
|
-
low: chalk.blue,
|
|
27
|
-
medium: chalk.yellow,
|
|
28
|
-
high: chalk.red,
|
|
29
|
-
}[advisory.severity.toLowerCase()] || chalk.white;
|
|
30
|
-
|
|
31
|
-
console.log();
|
|
32
|
-
console.log(`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`);
|
|
33
|
-
console.log();
|
|
34
|
-
console.log(`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);
|
|
35
|
-
console.log();
|
|
36
|
-
console.log(`${chalk.bold(advisory.message)}`);
|
|
37
|
-
console.log();
|
|
38
|
-
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
|
|
39
|
-
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for transcription HTTP responses.
|
|
3
|
+
* Uses snake_case to align with existing CopilotKitCoreErrorCode pattern.
|
|
4
|
+
* These codes are returned by the runtime and parsed by the client.
|
|
5
|
+
*/
|
|
6
|
+
export enum TranscriptionErrorCode {
|
|
7
|
+
/** Transcription service not configured in runtime */
|
|
8
|
+
SERVICE_NOT_CONFIGURED = "service_not_configured",
|
|
9
|
+
/** Audio format not supported */
|
|
10
|
+
INVALID_AUDIO_FORMAT = "invalid_audio_format",
|
|
11
|
+
/** Audio file is too long */
|
|
12
|
+
AUDIO_TOO_LONG = "audio_too_long",
|
|
13
|
+
/** Audio file is empty or too short */
|
|
14
|
+
AUDIO_TOO_SHORT = "audio_too_short",
|
|
15
|
+
/** Rate limited by transcription provider */
|
|
16
|
+
RATE_LIMITED = "rate_limited",
|
|
17
|
+
/** Authentication failed with transcription provider */
|
|
18
|
+
AUTH_FAILED = "auth_failed",
|
|
19
|
+
/** Transcription provider returned an error */
|
|
20
|
+
PROVIDER_ERROR = "provider_error",
|
|
21
|
+
/** Network error during transcription */
|
|
22
|
+
NETWORK_ERROR = "network_error",
|
|
23
|
+
/** Invalid request format */
|
|
24
|
+
INVALID_REQUEST = "invalid_request",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Error response format returned by the transcription endpoint.
|
|
29
|
+
*/
|
|
30
|
+
export interface TranscriptionErrorResponse {
|
|
31
|
+
error: TranscriptionErrorCode;
|
|
32
|
+
message: string;
|
|
33
|
+
retryable?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Helper functions to create transcription error responses.
|
|
38
|
+
* Used by the runtime to return consistent error responses.
|
|
39
|
+
*/
|
|
40
|
+
export const TranscriptionErrors = {
|
|
41
|
+
serviceNotConfigured: (): TranscriptionErrorResponse => ({
|
|
42
|
+
error: TranscriptionErrorCode.SERVICE_NOT_CONFIGURED,
|
|
43
|
+
message: "Transcription service is not configured",
|
|
44
|
+
retryable: false,
|
|
45
|
+
}),
|
|
46
|
+
|
|
47
|
+
invalidAudioFormat: (
|
|
48
|
+
format: string,
|
|
49
|
+
supported: string[],
|
|
50
|
+
): TranscriptionErrorResponse => ({
|
|
51
|
+
error: TranscriptionErrorCode.INVALID_AUDIO_FORMAT,
|
|
52
|
+
message: `Unsupported audio format: ${format}. Supported: ${supported.join(", ")}`,
|
|
53
|
+
retryable: false,
|
|
54
|
+
}),
|
|
55
|
+
|
|
56
|
+
invalidRequest: (details: string): TranscriptionErrorResponse => ({
|
|
57
|
+
error: TranscriptionErrorCode.INVALID_REQUEST,
|
|
58
|
+
message: details,
|
|
59
|
+
retryable: false,
|
|
60
|
+
}),
|
|
61
|
+
|
|
62
|
+
rateLimited: (): TranscriptionErrorResponse => ({
|
|
63
|
+
error: TranscriptionErrorCode.RATE_LIMITED,
|
|
64
|
+
message: "Rate limited. Please try again later.",
|
|
65
|
+
retryable: true,
|
|
66
|
+
}),
|
|
67
|
+
|
|
68
|
+
authFailed: (): TranscriptionErrorResponse => ({
|
|
69
|
+
error: TranscriptionErrorCode.AUTH_FAILED,
|
|
70
|
+
message: "Authentication failed with transcription provider",
|
|
71
|
+
retryable: false,
|
|
72
|
+
}),
|
|
73
|
+
|
|
74
|
+
providerError: (message: string): TranscriptionErrorResponse => ({
|
|
75
|
+
error: TranscriptionErrorCode.PROVIDER_ERROR,
|
|
76
|
+
message,
|
|
77
|
+
retryable: true,
|
|
78
|
+
}),
|
|
79
|
+
|
|
80
|
+
networkError: (
|
|
81
|
+
message: string = "Network error during transcription",
|
|
82
|
+
): TranscriptionErrorResponse => ({
|
|
83
|
+
error: TranscriptionErrorCode.NETWORK_ERROR,
|
|
84
|
+
message,
|
|
85
|
+
retryable: true,
|
|
86
|
+
}),
|
|
87
|
+
|
|
88
|
+
audioTooLong: (): TranscriptionErrorResponse => ({
|
|
89
|
+
error: TranscriptionErrorCode.AUDIO_TOO_LONG,
|
|
90
|
+
message: "Audio file is too long",
|
|
91
|
+
retryable: false,
|
|
92
|
+
}),
|
|
93
|
+
|
|
94
|
+
audioTooShort: (): TranscriptionErrorResponse => ({
|
|
95
|
+
error: TranscriptionErrorCode.AUDIO_TOO_SHORT,
|
|
96
|
+
message: "Audio is too short to transcribe",
|
|
97
|
+
retryable: false,
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import type {
|
|
3
|
+
UserMessage,
|
|
4
|
+
InputContent,
|
|
5
|
+
TextInputPart,
|
|
6
|
+
ImageInputPart,
|
|
7
|
+
AudioInputPart,
|
|
8
|
+
VideoInputPart,
|
|
9
|
+
DocumentInputPart,
|
|
10
|
+
InputContentSource,
|
|
11
|
+
InputContentDataSource,
|
|
12
|
+
InputContentUrlSource,
|
|
13
|
+
} from "../message";
|
|
14
|
+
|
|
15
|
+
describe("shared message types", () => {
|
|
16
|
+
it("UserMessage content accepts string", () => {
|
|
17
|
+
const msg: UserMessage = { id: "1", role: "user", content: "hello" };
|
|
18
|
+
expect(msg.content).toBe("hello");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("UserMessage content accepts InputContent[]", () => {
|
|
22
|
+
const msg: UserMessage = {
|
|
23
|
+
id: "1",
|
|
24
|
+
role: "user",
|
|
25
|
+
content: [
|
|
26
|
+
{ type: "text", text: "hello" },
|
|
27
|
+
{
|
|
28
|
+
type: "image",
|
|
29
|
+
source: { type: "data", value: "base64...", mimeType: "image/png" },
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
expect(Array.isArray(msg.content)).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("InputContent union covers all modalities", () => {
|
|
37
|
+
const parts: InputContent[] = [
|
|
38
|
+
{ type: "text", text: "hi" },
|
|
39
|
+
{
|
|
40
|
+
type: "image",
|
|
41
|
+
source: { type: "url", value: "https://example.com/img.png" },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "audio",
|
|
45
|
+
source: { type: "data", value: "base64...", mimeType: "audio/mp3" },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "video",
|
|
49
|
+
source: { type: "data", value: "base64...", mimeType: "video/mp4" },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: "document",
|
|
53
|
+
source: {
|
|
54
|
+
type: "data",
|
|
55
|
+
value: "base64...",
|
|
56
|
+
mimeType: "application/pdf",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
expect(parts).toHaveLength(5);
|
|
61
|
+
});
|
|
62
|
+
});
|
package/src/types/action.ts
CHANGED
|
@@ -31,16 +31,18 @@ interface ObjectArrayParameter extends AbstractParameter {
|
|
|
31
31
|
attributes?: Parameter[];
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
type SpecialParameters =
|
|
34
|
+
type SpecialParameters =
|
|
35
|
+
| StringParameter
|
|
36
|
+
| ObjectParameter
|
|
37
|
+
| ObjectArrayParameter;
|
|
35
38
|
interface BaseParameter extends AbstractParameter {
|
|
36
39
|
type?: Exclude<AbstractParameter["type"], SpecialParameters["type"]>;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export type Parameter = BaseParameter | SpecialParameters;
|
|
40
43
|
|
|
41
|
-
type OptionalParameterType<P extends AbstractParameter> =
|
|
42
|
-
? undefined
|
|
43
|
-
: never;
|
|
44
|
+
type OptionalParameterType<P extends AbstractParameter> =
|
|
45
|
+
P["required"] extends false ? undefined : never;
|
|
44
46
|
|
|
45
47
|
type StringParameterType<P> = P extends StringParameter
|
|
46
48
|
? P extends { enum?: Array<infer E> }
|
|
@@ -61,7 +63,9 @@ type ObjectArrayParameterType<P> = P extends ObjectArrayParameter
|
|
|
61
63
|
: never;
|
|
62
64
|
|
|
63
65
|
type MappedTypeOrString<T> = T extends keyof TypeMap ? TypeMap[T] : string;
|
|
64
|
-
type BaseParameterType<P extends AbstractParameter> = P extends {
|
|
66
|
+
type BaseParameterType<P extends AbstractParameter> = P extends {
|
|
67
|
+
type: infer T;
|
|
68
|
+
}
|
|
65
69
|
? T extends BaseParameter["type"]
|
|
66
70
|
? MappedTypeOrString<T>
|
|
67
71
|
: never
|
package/src/types/error.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export interface CopilotErrorEvent {
|
|
2
|
-
type:
|
|
2
|
+
type:
|
|
3
|
+
| "error"
|
|
4
|
+
| "request"
|
|
5
|
+
| "response"
|
|
6
|
+
| "agent_state"
|
|
7
|
+
| "action"
|
|
8
|
+
| "message"
|
|
9
|
+
| "performance";
|
|
3
10
|
timestamp: number;
|
|
4
11
|
context: CopilotRequestContext;
|
|
5
12
|
error?: any; // Present when type is 'error'
|
|
@@ -67,4 +74,6 @@ export interface CopilotRequestContext {
|
|
|
67
74
|
metadata?: Record<string, any>;
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
export type CopilotErrorHandler = (
|
|
77
|
+
export type CopilotErrorHandler = (
|
|
78
|
+
errorEvent: CopilotErrorEvent,
|
|
79
|
+
) => void | Promise<void>;
|
package/src/types/message.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import agui from "@ag-ui/core";
|
|
1
|
+
import * as agui from "@ag-ui/core";
|
|
2
2
|
|
|
3
|
+
// Re-export AG-UI multimodal input types.
|
|
4
|
+
// Note: AG-UI names the text variant TextInputContent; we export it as TextInputPart for consistency.
|
|
5
|
+
export type {
|
|
6
|
+
InputContent,
|
|
7
|
+
InputContentSource,
|
|
8
|
+
InputContentDataSource,
|
|
9
|
+
InputContentUrlSource,
|
|
10
|
+
TextInputContent as TextInputPart,
|
|
11
|
+
ImageInputPart,
|
|
12
|
+
AudioInputPart,
|
|
13
|
+
VideoInputPart,
|
|
14
|
+
DocumentInputPart,
|
|
15
|
+
} from "@ag-ui/core";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `InputContentSource` from `@ag-ui/core` (re-exported from `@copilotkit/shared`) instead.
|
|
19
|
+
* `ImageData` only described base64 image payloads. `InputContentSource` supports
|
|
20
|
+
* data and URL sources for images, audio, video, and documents.
|
|
21
|
+
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
22
|
+
* @since 1.56.0
|
|
23
|
+
*/
|
|
3
24
|
export interface ImageData {
|
|
4
25
|
format: string;
|
|
5
26
|
bytes: string;
|
|
@@ -11,6 +32,7 @@ export type SystemMessage = agui.SystemMessage;
|
|
|
11
32
|
export type DeveloperMessage = agui.DeveloperMessage;
|
|
12
33
|
export type ToolCall = agui.ToolCall;
|
|
13
34
|
export type ActivityMessage = agui.ActivityMessage;
|
|
35
|
+
export type ReasoningMessage = agui.ReasoningMessage;
|
|
14
36
|
|
|
15
37
|
// Extended message types
|
|
16
38
|
export type ToolResult = agui.ToolMessage & {
|
|
@@ -19,14 +41,19 @@ export type ToolResult = agui.ToolMessage & {
|
|
|
19
41
|
|
|
20
42
|
export type AIMessage = agui.AssistantMessage & {
|
|
21
43
|
generativeUI?: (props?: any) => any;
|
|
44
|
+
generativeUIPosition?: "before" | "after";
|
|
22
45
|
agentName?: string;
|
|
23
46
|
state?: any;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use multimodal `content` array with `InputContent` parts instead.
|
|
49
|
+
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
50
|
+
* @since 1.56.0
|
|
51
|
+
*/
|
|
24
52
|
image?: ImageData;
|
|
53
|
+
runId?: string;
|
|
25
54
|
};
|
|
26
55
|
|
|
27
|
-
export type UserMessage = agui.UserMessage
|
|
28
|
-
image?: ImageData;
|
|
29
|
-
};
|
|
56
|
+
export type UserMessage = agui.UserMessage;
|
|
30
57
|
|
|
31
58
|
export type Message =
|
|
32
59
|
| AIMessage
|
|
@@ -34,4 +61,5 @@ export type Message =
|
|
|
34
61
|
| UserMessage
|
|
35
62
|
| SystemMessage
|
|
36
63
|
| DeveloperMessage
|
|
37
|
-
| ActivityMessage
|
|
64
|
+
| ActivityMessage
|
|
65
|
+
| ReasoningMessage;
|