@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
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type { AssistantMessage, Message } from "@ag-ui/core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stable per-row view keys for chat transcripts, across backends that re-key a
|
|
5
|
+
* message mid-stream. Shared by every frontend package, because the defect and
|
|
6
|
+
* the correlation signal are in the message stream, not in any one framework.
|
|
7
|
+
*
|
|
8
|
+
* ## The problem
|
|
9
|
+
*
|
|
10
|
+
* A message's canonical `id` is not stable within a turn. LangChain stamps a
|
|
11
|
+
* placeholder id on the first streamed chunk when the provider didn't supply
|
|
12
|
+
* one (`chat_models.py`: `if chunk.message.id is None: chunk.message.id =
|
|
13
|
+
* "lc_run-" + "-" + run_id`), then prefers any provider-assigned id it sees
|
|
14
|
+
* while merging chunks (`messages/ai.py`, "Ranks are defined by the order of
|
|
15
|
+
* preference"). The `MESSAGES_SNAPSHOT` therefore carries the provider's final
|
|
16
|
+
* id (e.g. `resp_…`) for a message the client already knows as `lc_run--…`.
|
|
17
|
+
*
|
|
18
|
+
* Every framework destroys and recreates a row whose key changes, so keying
|
|
19
|
+
* rows by `id` turned that swap into the visible HITL chat flash, where a
|
|
20
|
+
* rendered approval card appears to reset during a tool's
|
|
21
|
+
* `executing → complete` transition.
|
|
22
|
+
*
|
|
23
|
+
* This is provider-conditional: providers that stamp an id on every chunk (so
|
|
24
|
+
* `chunk.message.id is None` never holds) never trigger a rename.
|
|
25
|
+
*
|
|
26
|
+
* ## The approach
|
|
27
|
+
*
|
|
28
|
+
* Tool-call ids survive the rename, so they are used as *anchors*: the first
|
|
29
|
+
* message seen carrying a given tool call records the key it was assigned, and
|
|
30
|
+
* any later message carrying that same tool call reuses it. The store is an
|
|
31
|
+
* override table consulted before falling back to `message.id`. Resolving only
|
|
32
|
+
* reads it; each render that reaches the DOM then records what it rendered:
|
|
33
|
+
*
|
|
34
|
+
* ```text
|
|
35
|
+
* render 1 id=lc_run--1 no tools key = message.id = lc_run--1
|
|
36
|
+
* commit 1 store {}
|
|
37
|
+
* render 2 id=lc_run--1 tc call_A key = message.id = lc_run--1
|
|
38
|
+
* commit 2 store { tc:call_A -> lc_run--1 }
|
|
39
|
+
* render 3 id=resp_1 tc call_A key = store[tc:call_A]
|
|
40
|
+
* = lc_run--1 (row survives)
|
|
41
|
+
* commit 3 store unchanged
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Recording the anchor at commit 2 — while the id is still stable — is what
|
|
45
|
+
* makes render 3 resolvable. Note the fix does not depend on render 2
|
|
46
|
+
* existing: a message born already carrying a tool call anchors on the first
|
|
47
|
+
* render that commits it, under whatever id it holds then.
|
|
48
|
+
*
|
|
49
|
+
* ## Why an override table rather than keying rows by tool-call id
|
|
50
|
+
*
|
|
51
|
+
* Deriving the key from the tool call directly (`tc:<id>` whenever a tool call
|
|
52
|
+
* is present) needs no state, but changes the key the moment a tool call
|
|
53
|
+
* *appears* — so an assistant message that streams text and then calls a tool
|
|
54
|
+
* is torn down on that transition, for every provider, whether or not it
|
|
55
|
+
* renames. That trades a conditional flash for an unconditional one. Recording
|
|
56
|
+
* an override keeps the key the row already had.
|
|
57
|
+
*
|
|
58
|
+
* ## Cost
|
|
59
|
+
*
|
|
60
|
+
* The store holds only `tc:<toolCallId>` entries, so a conversation with no
|
|
61
|
+
* tool calls keeps an empty store and behaviour byte-identical to keying by
|
|
62
|
+
* `id`. Size is bounded to the tool calls of the currently-rendered messages
|
|
63
|
+
* (see `pruneRowKeyStore`), not the conversation length. Deleting the store
|
|
64
|
+
* reverts to plain `id` keying.
|
|
65
|
+
*
|
|
66
|
+
* ## Known gaps
|
|
67
|
+
*
|
|
68
|
+
* - A text-only assistant message has no anchor, so it still re-keys. No
|
|
69
|
+
* client-side correlation signal exists for it; the fix is stable ids
|
|
70
|
+
* upstream.
|
|
71
|
+
* - If the tool call's arrival and the id swap land in the same update, the
|
|
72
|
+
* intermediate state never renders, the anchor is never recorded, and the
|
|
73
|
+
* row is recreated as before. Correlating in the event-apply layer (i.e. in
|
|
74
|
+
* the AG-UI client, which observes every intermediate state) would be immune.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
const TOOL_ANCHOR_PREFIX = "tc:";
|
|
78
|
+
|
|
79
|
+
export interface RowKeyStore {
|
|
80
|
+
/**
|
|
81
|
+
* `tc:<toolCallId>` → the row key first assigned to a message carrying that
|
|
82
|
+
* tool call. Populated only for assistant messages that carry tool calls.
|
|
83
|
+
*/
|
|
84
|
+
overrides: Map<string, string>;
|
|
85
|
+
/**
|
|
86
|
+
* Anchors carried by more than one message in the last rendered list. Such
|
|
87
|
+
* an anchor identifies no single row, so it is never used to vend a key.
|
|
88
|
+
*/
|
|
89
|
+
ambiguous: Set<string>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function createRowKeyStore(): RowKeyStore {
|
|
93
|
+
return { overrides: new Map(), ambiguous: new Set() };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Anchors a message contributes. Only assistant tool calls qualify: LangChain's
|
|
98
|
+
* id preference applies when merging `AIMessageChunk`s, so user message ids are
|
|
99
|
+
* not renamed, and `role: "tool"` messages are not rendered as rows. Every tool
|
|
100
|
+
* call is used (not just the first) so the anchor survives tool-call reordering
|
|
101
|
+
* between snapshots.
|
|
102
|
+
*/
|
|
103
|
+
function toolAnchorsOf(message: Message | undefined): string[] {
|
|
104
|
+
if (message?.role !== "assistant") return [];
|
|
105
|
+
const toolCalls = (message as AssistantMessage).toolCalls;
|
|
106
|
+
if (!toolCalls?.length) return [];
|
|
107
|
+
|
|
108
|
+
const anchors: string[] = [];
|
|
109
|
+
for (const toolCall of toolCalls) {
|
|
110
|
+
if (toolCall?.id) anchors.push(`${TOOL_ANCHOR_PREFIX}${toolCall.id}`);
|
|
111
|
+
}
|
|
112
|
+
return anchors;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Resolves the row key for every message, returned by position.
|
|
117
|
+
*
|
|
118
|
+
* Pure: it reads `store` and never writes to it. Every framework here may
|
|
119
|
+
* evaluate a render pass whose result never reaches the DOM — an abandoned
|
|
120
|
+
* concurrent render in React, a discarded `computed` evaluation in Vue or
|
|
121
|
+
* Angular. An anchor recorded by such a pass would vend its key to the pass
|
|
122
|
+
* that does render, re-keying the row the user is looking at, which is the
|
|
123
|
+
* teardown this module exists to prevent. Anchors are recorded by
|
|
124
|
+
* `commitRowKeyStore`, from whichever phase each framework runs after the DOM
|
|
125
|
+
* is updated.
|
|
126
|
+
*
|
|
127
|
+
* Uniqueness is structural rather than assumed: a caller that does not
|
|
128
|
+
* deduplicate can pass two rows with the same id, and an override can vend a
|
|
129
|
+
* key equal to a later message's own id.
|
|
130
|
+
*/
|
|
131
|
+
export function resolveRowRenderKeys(
|
|
132
|
+
store: RowKeyStore,
|
|
133
|
+
messages: readonly (Message | undefined)[],
|
|
134
|
+
): string[] {
|
|
135
|
+
const keys: string[] = [];
|
|
136
|
+
const claimed = new Set<string>();
|
|
137
|
+
|
|
138
|
+
messages.forEach((message, index) => {
|
|
139
|
+
const anchors = toolAnchorsOf(message);
|
|
140
|
+
|
|
141
|
+
// Reuse the key recorded for any of this message's anchors. An override
|
|
142
|
+
// pointing at a key another row already claimed this pass is skipped: two
|
|
143
|
+
// messages can share a tool-call id (upstream bug, or replayed state), and
|
|
144
|
+
// the later one falls back to its own id instead.
|
|
145
|
+
let key: string | undefined;
|
|
146
|
+
for (const anchor of anchors) {
|
|
147
|
+
if (store.ambiguous.has(anchor)) continue;
|
|
148
|
+
const recorded = store.overrides.get(anchor);
|
|
149
|
+
if (recorded !== undefined && !claimed.has(recorded)) {
|
|
150
|
+
key = recorded;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// The index fallback covers a message with no usable id.
|
|
156
|
+
key ??= message?.id || `index-${index}`;
|
|
157
|
+
|
|
158
|
+
if (claimed.has(key)) {
|
|
159
|
+
let suffix = 2;
|
|
160
|
+
while (claimed.has(`${key}:${suffix}`)) suffix += 1;
|
|
161
|
+
key = `${key}:${suffix}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
keys.push(key);
|
|
165
|
+
claimed.add(key);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return keys;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* `message.id` → row key, for callers that render by message rather than by
|
|
173
|
+
* position. `messages` must be deduplicated: duplicate ids would overwrite
|
|
174
|
+
* each other in the returned map.
|
|
175
|
+
*/
|
|
176
|
+
export function resolveRowRenderKeysById(
|
|
177
|
+
store: RowKeyStore,
|
|
178
|
+
messages: readonly Message[],
|
|
179
|
+
): Map<string, string> {
|
|
180
|
+
const keys = resolveRowRenderKeys(store, messages);
|
|
181
|
+
const byId = new Map<string, string>();
|
|
182
|
+
messages.forEach((message, index) => {
|
|
183
|
+
const key = keys[index];
|
|
184
|
+
if (key !== undefined) byId.set(message.id, key);
|
|
185
|
+
});
|
|
186
|
+
return byId;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Records the anchors of a rendered list, then bounds the store to it. Call
|
|
191
|
+
* from the phase that runs after the DOM is updated, never while resolving —
|
|
192
|
+
* see `resolveRowRenderKeys`.
|
|
193
|
+
*
|
|
194
|
+
* Re-resolving here reproduces the keys the rows were rendered with, because
|
|
195
|
+
* the store cannot change between a render and its own post-render phase.
|
|
196
|
+
*
|
|
197
|
+
* An anchor carried by two rows in the same list is marked ambiguous rather
|
|
198
|
+
* than recorded. Recording it would give the first row's key to whichever row
|
|
199
|
+
* outlived the other, and with it that row's DOM and component state.
|
|
200
|
+
*/
|
|
201
|
+
export function commitRowKeyStore(
|
|
202
|
+
store: RowKeyStore,
|
|
203
|
+
messages: readonly (Message | undefined)[],
|
|
204
|
+
): void {
|
|
205
|
+
const keys = resolveRowRenderKeys(store, messages);
|
|
206
|
+
|
|
207
|
+
const anchorCounts = new Map<string, number>();
|
|
208
|
+
for (const message of messages) {
|
|
209
|
+
for (const anchor of toolAnchorsOf(message)) {
|
|
210
|
+
anchorCounts.set(anchor, (anchorCounts.get(anchor) ?? 0) + 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Ambiguity is a property of the rendered list, so it is recomputed rather
|
|
215
|
+
// than accumulated: an anchor left alone by the row that shadowed it becomes
|
|
216
|
+
// usable again.
|
|
217
|
+
store.ambiguous.clear();
|
|
218
|
+
for (const [anchor, count] of anchorCounts) {
|
|
219
|
+
if (count > 1) {
|
|
220
|
+
store.ambiguous.add(anchor);
|
|
221
|
+
store.overrides.delete(anchor);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// First claimant of an anchor owns it, so a re-keyed message resolves to the
|
|
226
|
+
// key the row already had rather than overwriting it.
|
|
227
|
+
messages.forEach((message, index) => {
|
|
228
|
+
const key = keys[index];
|
|
229
|
+
if (key === undefined) return;
|
|
230
|
+
for (const anchor of toolAnchorsOf(message)) {
|
|
231
|
+
if (store.ambiguous.has(anchor)) continue;
|
|
232
|
+
if (!store.overrides.has(anchor)) store.overrides.set(anchor, key);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
pruneRowKeyStore(store, messages);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Drops anchors no longer present in `messages`, bounding the store to the
|
|
241
|
+
* tool calls of the currently-rendered messages. Called by
|
|
242
|
+
* `commitRowKeyStore`; like it, this writes to the store and so belongs after
|
|
243
|
+
* the DOM is updated, never while resolving.
|
|
244
|
+
*
|
|
245
|
+
* Pruned entries are unreachable by construction: `resolveRowRenderKeys` only
|
|
246
|
+
* looks up anchors belonging to messages in the list it is given.
|
|
247
|
+
*/
|
|
248
|
+
export function pruneRowKeyStore(
|
|
249
|
+
store: RowKeyStore,
|
|
250
|
+
messages: readonly (Message | undefined)[],
|
|
251
|
+
): void {
|
|
252
|
+
const live = new Set<string>();
|
|
253
|
+
for (const message of messages) {
|
|
254
|
+
for (const anchor of toolAnchorsOf(message)) live.add(anchor);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
for (const anchor of store.overrides.keys()) {
|
|
258
|
+
if (!live.has(anchor)) store.overrides.delete(anchor);
|
|
259
|
+
}
|
|
260
|
+
for (const anchor of store.ambiguous) {
|
|
261
|
+
if (!live.has(anchor)) store.ambiguous.delete(anchor);
|
|
262
|
+
}
|
|
263
|
+
}
|
package/src/utils/types.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import type { AgentCapabilities } from "@ag-ui/core";
|
|
2
|
+
|
|
1
3
|
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* More specific utility for records with at least one key
|
|
5
7
|
*/
|
|
6
8
|
export type NonEmptyRecord<T> =
|
|
7
|
-
T extends Record<string, unknown>
|
|
9
|
+
T extends Record<string, unknown>
|
|
10
|
+
? keyof T extends never
|
|
11
|
+
? never
|
|
12
|
+
: T
|
|
13
|
+
: never;
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
16
|
* Type representing an agent's basic information
|
|
@@ -13,10 +19,131 @@ export interface AgentDescription {
|
|
|
13
19
|
name: string;
|
|
14
20
|
className: string;
|
|
15
21
|
description: string;
|
|
22
|
+
capabilities?: AgentCapabilities;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type RuntimeMode = "sse" | "intelligence";
|
|
26
|
+
|
|
27
|
+
export const RUNTIME_MODE_SSE = "sse" as const;
|
|
28
|
+
export const RUNTIME_MODE_INTELLIGENCE = "intelligence" as const;
|
|
29
|
+
|
|
30
|
+
export interface IntelligenceRuntimeInfo {
|
|
31
|
+
wsUrl: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ThreadEndpointRuntimeInfo {
|
|
35
|
+
list: boolean;
|
|
36
|
+
inspect: boolean;
|
|
37
|
+
mutations: boolean;
|
|
38
|
+
realtimeMetadata: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type RuntimeLicenseStatus =
|
|
42
|
+
| "valid"
|
|
43
|
+
| "none"
|
|
44
|
+
| "expired"
|
|
45
|
+
| "expiring"
|
|
46
|
+
| "invalid"
|
|
47
|
+
| "unknown";
|
|
48
|
+
|
|
49
|
+
/** Runtime entitlement authority resolved by a managed or self-hosted backend. */
|
|
50
|
+
interface RuntimeEntitlement {
|
|
51
|
+
/** Whether the resolved entitlement currently grants product access. */
|
|
52
|
+
active: boolean;
|
|
53
|
+
/** Deployment authority that produced this entitlement. */
|
|
54
|
+
source:
|
|
55
|
+
| "managedOrgSubscription"
|
|
56
|
+
| "selfHostedDeploymentLicense"
|
|
57
|
+
| "awsMarketplaceDeploymentLicense";
|
|
58
|
+
/** Boolean feature grants keyed by stable feature id. */
|
|
59
|
+
features: Record<string, boolean>;
|
|
60
|
+
/** Numeric limits keyed by stable feature id. */
|
|
61
|
+
limits: Record<string, number>;
|
|
62
|
+
/** Optional catalog plan code supplied by the entitlement authority. */
|
|
63
|
+
planCode?: string;
|
|
64
|
+
/** Optional lower-level source metadata supplied by the authority. */
|
|
65
|
+
entitlementSource?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Public diagnostic returned when Runtime entitlement resolution is not ready. */
|
|
69
|
+
interface RuntimeEntitlementError {
|
|
70
|
+
/** Stable backend or SDK error code. */
|
|
71
|
+
code: string;
|
|
72
|
+
/** Safe human-readable diagnostic. */
|
|
73
|
+
message: string;
|
|
74
|
+
/** Whether a later resolution attempt may succeed without reconfiguration. */
|
|
75
|
+
retryable: boolean;
|
|
76
|
+
/** Optional originating request correlation id. */
|
|
77
|
+
requestId?: string;
|
|
78
|
+
/** Optional originating trace correlation id. */
|
|
79
|
+
traceId?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Successfully resolved Runtime entitlement response. */
|
|
83
|
+
interface RuntimeEntitlementReadyResponse {
|
|
84
|
+
status: "ready";
|
|
85
|
+
entitlement: RuntimeEntitlement;
|
|
86
|
+
error?: never;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Structured non-ready Runtime entitlement response. */
|
|
90
|
+
interface RuntimeEntitlementErrorResponse {
|
|
91
|
+
status: "degraded" | "misconfigured" | "unavailable";
|
|
92
|
+
entitlement?: never;
|
|
93
|
+
error: RuntimeEntitlementError;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Final structured Runtime entitlement response exposed through `/info`. */
|
|
97
|
+
export type RuntimeEntitlementResponse =
|
|
98
|
+
| RuntimeEntitlementReadyResponse
|
|
99
|
+
| RuntimeEntitlementErrorResponse;
|
|
100
|
+
|
|
101
|
+
export interface A2UIRuntimeInfo {
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Agent ids the runtime applies A2UI to. When omitted, A2UI applies to
|
|
105
|
+
* every agent served by the runtime.
|
|
106
|
+
*/
|
|
107
|
+
agents?: string[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Intelligence resource support available through a single runtime route. */
|
|
111
|
+
export interface SingleRouteRuntimeInfo {
|
|
112
|
+
/** Whether the runtime accepts resource requests through the single route. */
|
|
113
|
+
resourceOperations: boolean;
|
|
114
|
+
/** Thread features available through the single-route resource bridge. */
|
|
115
|
+
threadEndpoints: ThreadEndpointRuntimeInfo;
|
|
16
116
|
}
|
|
17
117
|
|
|
18
118
|
export interface RuntimeInfo {
|
|
19
119
|
version: string;
|
|
20
120
|
agents: Record<string, AgentDescription>;
|
|
21
121
|
audioFileTranscriptionEnabled: boolean;
|
|
122
|
+
mode: RuntimeMode;
|
|
123
|
+
intelligence?: IntelligenceRuntimeInfo;
|
|
124
|
+
threadEndpoints?: ThreadEndpointRuntimeInfo;
|
|
125
|
+
/** Optional capabilities exposed by runtimes that use one HTTP route. */
|
|
126
|
+
singleRoute?: SingleRouteRuntimeInfo;
|
|
127
|
+
/** Whether this runtime exposes trusted inspector metadata. */
|
|
128
|
+
inspectorMetadata?: boolean;
|
|
129
|
+
/** Whether this runtime exposes the debug-authorized Learning snapshot. */
|
|
130
|
+
inspectorLearning?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* When true, the runtime exposes POST /agent/:agentId/suggest for stateless
|
|
133
|
+
* suggestion generation. Absent on older runtimes; clients fall back to a
|
|
134
|
+
* client-side agent run.
|
|
135
|
+
*/
|
|
136
|
+
suggestions?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated Use `a2ui` instead, which preserves per-agent scoping.
|
|
139
|
+
* Kept for backward compatibility with older clients.
|
|
140
|
+
*/
|
|
141
|
+
a2uiEnabled?: boolean;
|
|
142
|
+
a2ui?: A2UIRuntimeInfo;
|
|
143
|
+
openGenerativeUIEnabled?: boolean;
|
|
144
|
+
/** Structured Runtime-level entitlement authority, when advertised. */
|
|
145
|
+
runtimeEntitlements?: RuntimeEntitlementResponse;
|
|
146
|
+
/** Legacy compatibility diagnostic retained for older Core/Inspector clients. */
|
|
147
|
+
licenseStatus?: RuntimeLicenseStatus;
|
|
148
|
+
telemetryDisabled?: boolean;
|
|
22
149
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { describe, test, expect, vi } from "vitest";
|
|
2
|
+
import { partialJSONParse, safeParseToolArgs } from "./utils";
|
|
3
|
+
|
|
4
|
+
describe("partialJSONParse", () => {
|
|
5
|
+
test("should parse a valid object", () => {
|
|
6
|
+
expect(partialJSONParse('{"key": "value"}')).toEqual({ key: "value" });
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("should return {} for a JSON string value", () => {
|
|
10
|
+
expect(partialJSONParse('"hello"')).toEqual({});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("should return {} for a JSON number", () => {
|
|
14
|
+
expect(partialJSONParse("42")).toEqual({});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("should return {} for a JSON boolean", () => {
|
|
18
|
+
expect(partialJSONParse("true")).toEqual({});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("should return {} for a JSON null", () => {
|
|
22
|
+
expect(partialJSONParse("null")).toEqual({});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("should return {} for a JSON array", () => {
|
|
26
|
+
expect(partialJSONParse("[1, 2, 3]")).toEqual({});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("should return {} for unparseable input", () => {
|
|
30
|
+
expect(partialJSONParse("not-json")).toEqual({});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("should return {} for an empty string", () => {
|
|
34
|
+
expect(partialJSONParse("")).toEqual({});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("should withhold an unterminated trailing number", () => {
|
|
38
|
+
expect(partialJSONParse('{"value":72,"max":1')).toEqual({ value: 72 });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("should withhold a number that is still unterminated at end of input", () => {
|
|
42
|
+
expect(partialJSONParse('{"value":72,"max":100')).toEqual({ value: 72 });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("should reveal a number once terminated", () => {
|
|
46
|
+
expect(partialJSONParse('{"value":72,"max":100}')).toEqual({
|
|
47
|
+
value: 72,
|
|
48
|
+
max: 100,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("should withhold an unterminated trailing array number", () => {
|
|
53
|
+
expect(partialJSONParse('{"data":[10,20,3')).toEqual({ data: [10, 20] });
|
|
54
|
+
expect(partialJSONParse('{"data":[10,20,30]')).toEqual({
|
|
55
|
+
data: [10, 20, 30],
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("should withhold unterminated numbers at any depth", () => {
|
|
60
|
+
expect(partialJSONParse('{"nested":{"a":1,"b":2')).toEqual({
|
|
61
|
+
nested: { a: 1 },
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("should withhold unterminated negatives, decimals and exponents", () => {
|
|
66
|
+
for (const input of [
|
|
67
|
+
'{"x":-',
|
|
68
|
+
'{"x":-4',
|
|
69
|
+
'{"x":3.',
|
|
70
|
+
'{"x":3.1',
|
|
71
|
+
'{"x":1e',
|
|
72
|
+
'{"x":1e-',
|
|
73
|
+
]) {
|
|
74
|
+
expect(partialJSONParse(input)).toEqual({});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("should keep negative, decimal and exponent numbers once terminated", () => {
|
|
79
|
+
expect(partialJSONParse('{"x":-4,"y":2')).toEqual({ x: -4 });
|
|
80
|
+
expect(partialJSONParse('{"x":3.1,"y":2')).toEqual({ x: 3.1 });
|
|
81
|
+
expect(partialJSONParse('{"x":1e-3,"y":2')).toEqual({ x: 1e-3 });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("should withhold a number followed only by whitespace", () => {
|
|
85
|
+
expect(partialJSONParse('{"max":100\n')).toEqual({});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("should still allow partial strings, booleans and null", () => {
|
|
89
|
+
expect(partialJSONParse('{"name":"jo')).toEqual({ name: "jo" });
|
|
90
|
+
expect(partialJSONParse('{"value":72,"max":tru')).toEqual({
|
|
91
|
+
value: 72,
|
|
92
|
+
max: true,
|
|
93
|
+
});
|
|
94
|
+
expect(partialJSONParse('{"value":72,"max":nul')).toEqual({
|
|
95
|
+
value: 72,
|
|
96
|
+
max: null,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("should still parse complete numbers", () => {
|
|
101
|
+
expect(partialJSONParse('{"value":72,"max":100}')).toEqual({
|
|
102
|
+
value: 72,
|
|
103
|
+
max: 100,
|
|
104
|
+
});
|
|
105
|
+
expect(partialJSONParse('{"pi":3.14}')).toEqual({ pi: 3.14 });
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe("safeParseToolArgs", () => {
|
|
110
|
+
test("should parse a valid JSON object string", () => {
|
|
111
|
+
expect(safeParseToolArgs('{"key": "value"}')).toEqual({ key: "value" });
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("should return {} for a JSON string value", () => {
|
|
115
|
+
expect(safeParseToolArgs('"hello"')).toEqual({});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("should return {} for a JSON number", () => {
|
|
119
|
+
expect(safeParseToolArgs("42")).toEqual({});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("should return {} for a JSON array", () => {
|
|
123
|
+
expect(safeParseToolArgs("[1, 2, 3]")).toEqual({});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("should return {} for malformed JSON", () => {
|
|
127
|
+
expect(safeParseToolArgs("{broken")).toEqual({});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("should return {} for a JSON null", () => {
|
|
131
|
+
expect(safeParseToolArgs("null")).toEqual({});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("should return {} for a JSON boolean", () => {
|
|
135
|
+
expect(safeParseToolArgs("true")).toEqual({});
|
|
136
|
+
});
|
|
137
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
2
|
+
"extends": "../tsconfig/base.json",
|
|
3
3
|
"include": ["."],
|
|
4
4
|
"compilerOptions": {
|
|
5
|
+
"target": "es2017",
|
|
5
6
|
"lib": ["es2017", "dom"],
|
|
6
7
|
"resolveJsonModule": true
|
|
7
8
|
},
|
|
8
|
-
"exclude": [
|
|
9
|
+
"exclude": [
|
|
10
|
+
"dist",
|
|
11
|
+
"build",
|
|
12
|
+
"node_modules",
|
|
13
|
+
"**/*.test.ts",
|
|
14
|
+
"**/*.test.tsx",
|
|
15
|
+
"**/__tests__/*"
|
|
16
|
+
]
|
|
9
17
|
}
|
package/tsdown.config.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
export default defineConfig([
|
|
4
|
+
{
|
|
5
|
+
// Node-only telemetry and event transforms have separate entries.
|
|
6
|
+
// The browser-facing root must not re-export either (#4151).
|
|
7
|
+
entry: [
|
|
8
|
+
"src/index.ts",
|
|
9
|
+
"src/telemetry/index.ts",
|
|
10
|
+
"src/event-transforms/index.ts",
|
|
11
|
+
],
|
|
12
|
+
format: ["esm", "cjs"],
|
|
13
|
+
dts: true,
|
|
14
|
+
sourcemap: true,
|
|
15
|
+
target: "es2022",
|
|
16
|
+
outDir: "dist",
|
|
17
|
+
unbundle: true,
|
|
18
|
+
exports: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
entry: ["src/index.ts"],
|
|
22
|
+
format: ["umd"],
|
|
23
|
+
globalName: "CopilotKitShared",
|
|
24
|
+
sourcemap: true,
|
|
25
|
+
target: "es2018",
|
|
26
|
+
outDir: "dist",
|
|
27
|
+
external: [
|
|
28
|
+
"zod",
|
|
29
|
+
"graphql",
|
|
30
|
+
"uuid",
|
|
31
|
+
"@ag-ui/core",
|
|
32
|
+
"@ag-ui/client",
|
|
33
|
+
"partial-json",
|
|
34
|
+
],
|
|
35
|
+
outputOptions(options) {
|
|
36
|
+
options.entryFileNames = "[name].umd.js";
|
|
37
|
+
options.globals = {
|
|
38
|
+
zod: "Zod",
|
|
39
|
+
graphql: "GraphQL",
|
|
40
|
+
uuid: "UUID",
|
|
41
|
+
"@ag-ui/core": "AgUICore",
|
|
42
|
+
"@ag-ui/client": "AgUIClient",
|
|
43
|
+
"@segment/analytics-node": "SegmentAnalyticsNode",
|
|
44
|
+
"partial-json": "PartialJSON",
|
|
45
|
+
};
|
|
46
|
+
return options;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
]);
|