@copilotkit/runtime 2.0.0-rc.5 → 2.0.0-rc.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -4
- package/dist/agent/{url-download.cjs → ai-sdk/url-download.cjs} +19 -76
- package/dist/agent/ai-sdk/url-download.cjs.map +1 -0
- package/dist/agent/{url-download.d.cts → ai-sdk/url-download.d.cts} +11 -8
- package/dist/agent/ai-sdk/url-download.d.cts.map +1 -0
- package/dist/agent/{url-download.d.mts → ai-sdk/url-download.d.mts} +11 -8
- package/dist/agent/ai-sdk/url-download.d.mts.map +1 -0
- package/dist/agent/{url-download.mjs → ai-sdk/url-download.mjs} +20 -74
- package/dist/agent/ai-sdk/url-download.mjs.map +1 -0
- package/dist/agent/ai-sdk.cjs +425 -0
- package/dist/agent/ai-sdk.cjs.map +1 -0
- package/dist/agent/ai-sdk.d.cts +119 -0
- package/dist/agent/ai-sdk.d.cts.map +1 -0
- package/dist/agent/ai-sdk.d.mts +119 -0
- package/dist/agent/ai-sdk.d.mts.map +1 -0
- package/dist/agent/ai-sdk.mjs +419 -0
- package/dist/agent/ai-sdk.mjs.map +1 -0
- package/dist/agent/classic-tools.cjs +185 -0
- package/dist/agent/classic-tools.cjs.map +1 -0
- package/dist/agent/classic-tools.mjs +183 -0
- package/dist/agent/classic-tools.mjs.map +1 -0
- package/dist/agent/converters/aisdk.cjs +17 -4
- package/dist/agent/converters/aisdk.cjs.map +1 -1
- package/dist/agent/converters/aisdk.d.cts.map +1 -1
- package/dist/agent/converters/aisdk.d.mts.map +1 -1
- package/dist/agent/converters/aisdk.mjs +18 -2
- package/dist/agent/converters/aisdk.mjs.map +1 -1
- package/dist/agent/converters/tanstack.cjs +202 -30
- package/dist/agent/converters/tanstack.cjs.map +1 -1
- package/dist/agent/converters/tanstack.d.cts +90 -6
- package/dist/agent/converters/tanstack.d.cts.map +1 -1
- package/dist/agent/converters/tanstack.d.mts +90 -6
- package/dist/agent/converters/tanstack.d.mts.map +1 -1
- package/dist/agent/converters/tanstack.mjs +202 -29
- package/dist/agent/converters/tanstack.mjs.map +1 -1
- package/dist/agent/learned-skills.cjs +15 -17
- package/dist/agent/learned-skills.cjs.map +1 -1
- package/dist/agent/learned-skills.d.cts +9 -3
- package/dist/agent/learned-skills.d.cts.map +1 -1
- package/dist/agent/learned-skills.d.mts +9 -3
- package/dist/agent/learned-skills.d.mts.map +1 -1
- package/dist/agent/learned-skills.mjs +15 -16
- package/dist/agent/learned-skills.mjs.map +1 -1
- package/dist/agent/model.cjs +42 -0
- package/dist/agent/model.cjs.map +1 -0
- package/dist/agent/model.d.cts +19 -0
- package/dist/agent/model.d.cts.map +1 -0
- package/dist/agent/model.d.mts +19 -0
- package/dist/agent/model.d.mts.map +1 -0
- package/dist/agent/model.mjs +41 -0
- package/dist/agent/model.mjs.map +1 -0
- package/dist/agent/state-delta.cjs +0 -1
- package/dist/agent/state-delta.cjs.map +1 -1
- package/dist/agent.cjs +558 -0
- package/dist/agent.cjs.map +1 -0
- package/dist/agent.d.cts +455 -0
- package/dist/agent.d.cts.map +1 -0
- package/dist/agent.d.mts +455 -0
- package/dist/agent.d.mts.map +1 -0
- package/dist/agent.mjs +551 -0
- package/dist/agent.mjs.map +1 -0
- package/dist/index.cjs +27 -27
- package/dist/index.d.cts +15 -15
- package/dist/index.d.mts +15 -15
- package/dist/index.mjs +9 -8
- package/dist/internal/learned-skills.d.cts +1 -1
- package/dist/internal/learned-skills.d.mts +1 -1
- package/dist/node.cjs +3 -2
- package/dist/node.d.cts +3 -3
- package/dist/node.d.mts +3 -3
- package/dist/node.mjs +3 -3
- package/dist/runtime/core/channel-manager.cjs +10 -2
- package/dist/runtime/core/channel-manager.cjs.map +1 -1
- package/dist/runtime/core/channel-manager.d.cts +1 -1
- package/dist/runtime/core/channel-manager.d.mts +1 -1
- package/dist/runtime/core/channel-manager.mjs +10 -1
- package/dist/runtime/core/channel-manager.mjs.map +1 -1
- package/dist/runtime/core/debug-event-bus.cjs +4 -3
- package/dist/runtime/core/debug-event-bus.cjs.map +1 -1
- package/dist/runtime/core/debug-event-bus.d.cts +5 -1
- package/dist/runtime/core/debug-event-bus.d.cts.map +1 -1
- package/dist/runtime/core/debug-event-bus.d.mts +4 -0
- package/dist/runtime/core/debug-event-bus.d.mts.map +1 -1
- package/dist/runtime/core/debug-event-bus.mjs +5 -3
- package/dist/runtime/core/debug-event-bus.mjs.map +1 -1
- package/dist/runtime/core/fetch-cors.cjs.map +1 -1
- package/dist/runtime/core/fetch-cors.d.cts +2 -2
- package/dist/runtime/core/fetch-cors.d.cts.map +1 -1
- package/dist/runtime/core/fetch-cors.d.mts +2 -2
- package/dist/runtime/core/fetch-cors.d.mts.map +1 -1
- package/dist/runtime/core/fetch-cors.mjs.map +1 -1
- package/dist/runtime/core/fetch-handler.cjs +24 -13
- package/dist/runtime/core/fetch-handler.cjs.map +1 -1
- package/dist/runtime/core/fetch-handler.d.cts +35 -14
- package/dist/runtime/core/fetch-handler.d.cts.map +1 -1
- package/dist/runtime/core/fetch-handler.d.mts +35 -14
- package/dist/runtime/core/fetch-handler.d.mts.map +1 -1
- package/dist/runtime/core/fetch-handler.mjs +16 -5
- package/dist/runtime/core/fetch-handler.mjs.map +1 -1
- package/dist/runtime/core/hooks.cjs.map +1 -1
- package/dist/runtime/core/hooks.d.cts +5 -5
- package/dist/runtime/core/hooks.d.cts.map +1 -1
- package/dist/runtime/core/hooks.d.mts +5 -5
- package/dist/runtime/core/hooks.d.mts.map +1 -1
- package/dist/runtime/core/hooks.mjs.map +1 -1
- package/dist/runtime/core/learning.cjs.map +1 -1
- package/dist/runtime/core/learning.d.cts +9 -9
- package/dist/runtime/core/learning.d.cts.map +1 -1
- package/dist/runtime/core/learning.d.mts +8 -8
- package/dist/runtime/core/learning.d.mts.map +1 -1
- package/dist/runtime/core/learning.mjs.map +1 -1
- package/dist/runtime/core/logger.cjs +105 -14
- package/dist/runtime/core/logger.cjs.map +1 -1
- package/dist/runtime/core/logger.d.cts +26 -9
- package/dist/runtime/core/logger.d.cts.map +1 -1
- package/dist/runtime/core/logger.d.mts +26 -9
- package/dist/runtime/core/logger.d.mts.map +1 -1
- package/dist/runtime/core/logger.mjs +105 -12
- package/dist/runtime/core/logger.mjs.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.cjs +3 -4
- package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.mjs +2 -2
- package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -1
- package/dist/runtime/core/middleware.cjs +5 -5
- package/dist/runtime/core/middleware.cjs.map +1 -1
- package/dist/runtime/core/middleware.d.cts +3 -3
- package/dist/runtime/core/middleware.d.cts.map +1 -1
- package/dist/runtime/core/middleware.d.mts +3 -3
- package/dist/runtime/core/middleware.d.mts.map +1 -1
- package/dist/runtime/core/middleware.mjs +4 -3
- package/dist/runtime/core/middleware.mjs.map +1 -1
- package/dist/runtime/core/package-info.cjs +1 -1
- package/dist/runtime/core/package-info.mjs +1 -1
- package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -1
- package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -1
- package/dist/runtime/core/runtime.cjs +29 -46
- package/dist/runtime/core/runtime.cjs.map +1 -1
- package/dist/runtime/core/runtime.d.cts +157 -91
- package/dist/runtime/core/runtime.d.cts.map +1 -1
- package/dist/runtime/core/runtime.d.mts +157 -91
- package/dist/runtime/core/runtime.d.mts.map +1 -1
- package/dist/runtime/core/runtime.mjs +27 -42
- package/dist/runtime/core/runtime.mjs.map +1 -1
- package/dist/runtime/endpoints/auto-start-channels.cjs +3 -4
- package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -1
- package/dist/runtime/endpoints/auto-start-channels.mjs +2 -2
- package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.cjs +11 -7
- package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.d.cts +9 -5
- package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.d.mts +9 -5
- package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.mjs +10 -5
- package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -1
- package/dist/runtime/endpoints/node.cjs +14 -4
- package/dist/runtime/endpoints/node.cjs.map +1 -1
- package/dist/runtime/endpoints/node.d.cts +39 -16
- package/dist/runtime/endpoints/node.d.cts.map +1 -1
- package/dist/runtime/endpoints/node.d.mts +39 -16
- package/dist/runtime/endpoints/node.d.mts.map +1 -1
- package/dist/runtime/endpoints/node.mjs +16 -7
- package/dist/runtime/endpoints/node.mjs.map +1 -1
- package/dist/runtime/event-transforms/index.d.cts +4 -0
- package/dist/runtime/event-transforms/index.d.mts +4 -0
- package/dist/runtime/event-transforms/index.mjs +5 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs +277 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts +61 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts +61 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs +276 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.cjs +68 -0
- package/dist/runtime/event-transforms/recorded-events.cjs.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.d.cts +27 -0
- package/dist/runtime/event-transforms/recorded-events.d.cts.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.d.mts +27 -0
- package/dist/runtime/event-transforms/recorded-events.d.mts.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.mjs +68 -0
- package/dist/runtime/event-transforms/recorded-events.mjs.map +1 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.cjs +289 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.cjs.map +1 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.mjs +288 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.cjs +106 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.mjs +106 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs +422 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs +422 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs +84 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts +41 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts +41 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs +83 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.cjs +694 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.mjs +694 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.mjs.map +1 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.cjs +0 -1
- package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -1
- package/dist/runtime/generative-ui/index.d.cts +1 -0
- package/dist/runtime/generative-ui/index.d.mts +1 -0
- package/dist/runtime/generative-ui/surface-writer.cjs +4 -5
- package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -1
- package/dist/runtime/generative-ui/surface-writer.d.cts +1 -1
- package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -1
- package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -1
- package/dist/runtime/generative-ui/surface-writer.mjs +5 -5
- package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -1
- package/dist/runtime/handlers/get-runtime-info.cjs +24 -6
- package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -1
- package/dist/runtime/handlers/get-runtime-info.mjs +25 -7
- package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -1
- package/dist/runtime/handlers/handle-connect.cjs +3 -8
- package/dist/runtime/handlers/handle-connect.cjs.map +1 -1
- package/dist/runtime/handlers/handle-connect.mjs +3 -8
- package/dist/runtime/handlers/handle-connect.mjs.map +1 -1
- package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -1
- package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-learning.cjs +2 -3
- package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-metadata.cjs +2 -3
- package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -1
- package/dist/runtime/handlers/handle-run.cjs +11 -16
- package/dist/runtime/handlers/handle-run.cjs.map +1 -1
- package/dist/runtime/handlers/handle-run.mjs +8 -12
- package/dist/runtime/handlers/handle-run.mjs.map +1 -1
- package/dist/runtime/handlers/handle-stop.cjs +5 -5
- package/dist/runtime/handlers/handle-stop.cjs.map +1 -1
- package/dist/runtime/handlers/handle-stop.mjs +2 -1
- package/dist/runtime/handlers/handle-stop.mjs.map +1 -1
- package/dist/runtime/handlers/handle-suggest.cjs +6 -3
- package/dist/runtime/handlers/handle-suggest.cjs.map +1 -1
- package/dist/runtime/handlers/handle-suggest.mjs +6 -2
- package/dist/runtime/handlers/handle-suggest.mjs.map +1 -1
- package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -1
- package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -1
- package/dist/runtime/handlers/handle-transcribe.cjs +0 -1
- package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -1
- package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/annotate.cjs +8 -8
- package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/annotate.mjs +5 -4
- package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/connect.cjs +6 -2
- package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/connect.mjs +6 -2
- package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/memories.cjs +28 -23
- package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/memories.mjs +12 -6
- package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/run.cjs +38 -30
- package/dist/runtime/handlers/intelligence/run.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/run.mjs +37 -28
- package/dist/runtime/handlers/intelligence/run.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/thread-names.cjs +6 -5
- package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/thread-names.mjs +3 -1
- package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/threads.cjs +40 -31
- package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/threads.mjs +18 -8
- package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -1
- package/dist/runtime/handlers/shared/agent-utils.cjs +50 -46
- package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/runtime/handlers/shared/agent-utils.mjs +47 -42
- package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/runtime/handlers/shared/cloud-telemetry.cjs +0 -1
- package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -1
- package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -1
- package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -1
- package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +4 -3
- package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
- package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +4 -3
- package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
- package/dist/runtime/handlers/shared/sse-response.cjs +77 -78
- package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -1
- package/dist/runtime/handlers/shared/sse-response.mjs +77 -77
- package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.cjs +4 -3
- package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.mjs +4 -3
- package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -1
- package/dist/runtime/handlers/sse/connect.cjs +2 -0
- package/dist/runtime/handlers/sse/connect.cjs.map +1 -1
- package/dist/runtime/handlers/sse/connect.mjs +2 -0
- package/dist/runtime/handlers/sse/connect.mjs.map +1 -1
- package/dist/runtime/handlers/sse/run.cjs +5 -2
- package/dist/runtime/handlers/sse/run.cjs.map +1 -1
- package/dist/runtime/handlers/sse/run.mjs +5 -2
- package/dist/runtime/handlers/sse/run.mjs.map +1 -1
- package/dist/runtime/index.cjs +29 -0
- package/dist/runtime/index.cjs.map +1 -0
- package/dist/runtime/index.d.cts +61 -15
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +61 -15
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +27 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/analytics-context.cjs +84 -0
- package/dist/runtime/intelligence-platform/analytics-context.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/analytics-context.mjs +83 -0
- package/dist/runtime/intelligence-platform/analytics-context.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/client.cjs +30 -4
- package/dist/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/client.d.cts +25 -2
- package/dist/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/runtime/intelligence-platform/client.d.mts +25 -2
- package/dist/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/runtime/intelligence-platform/client.mjs +30 -3
- package/dist/runtime/intelligence-platform/client.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/learning-management.cjs +7 -8
- package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/learning-management.mjs +7 -7
- package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +104 -110
- package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +8 -2
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +8 -2
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +104 -109
- package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/config.cjs +0 -1
- package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +22 -19
- package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +22 -19
- package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/stop-run.cjs +50 -0
- package/dist/runtime/intelligence-platform/stop-run.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/stop-run.mjs +50 -0
- package/dist/runtime/intelligence-platform/stop-run.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +3 -3
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +2 -1
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/trajectories.cjs +2 -3
- package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/trajectories.mjs +2 -2
- package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -1
- package/dist/runtime/node.d.cts +2 -2
- package/dist/runtime/node.d.mts +2 -2
- package/dist/runtime/runner/agent-runner.cjs +0 -1
- package/dist/runtime/runner/agent-runner.cjs.map +1 -1
- package/dist/runtime/runner/agent-runner.d.cts +9 -0
- package/dist/runtime/runner/agent-runner.d.cts.map +1 -1
- package/dist/runtime/runner/agent-runner.d.mts +9 -0
- package/dist/runtime/runner/agent-runner.d.mts.map +1 -1
- package/dist/runtime/runner/agent-runner.mjs.map +1 -1
- package/dist/runtime/runner/in-memory.cjs +0 -1
- package/dist/runtime/runner/in-memory.cjs.map +1 -1
- package/dist/runtime/runner/index.d.cts +1 -1
- package/dist/runtime/runner/index.d.mts +1 -1
- package/dist/runtime/runner/index.mjs +1 -1
- package/dist/runtime/runner/intelligence.cjs +55 -9
- package/dist/runtime/runner/intelligence.cjs.map +1 -1
- package/dist/runtime/runner/intelligence.d.cts +12 -1
- package/dist/runtime/runner/intelligence.d.cts.map +1 -1
- package/dist/runtime/runner/intelligence.d.mts +12 -1
- package/dist/runtime/runner/intelligence.d.mts.map +1 -1
- package/dist/runtime/runner/intelligence.mjs +56 -10
- package/dist/runtime/runner/intelligence.mjs.map +1 -1
- package/dist/runtime/telemetry/disclosure.cjs +2 -3
- package/dist/runtime/telemetry/disclosure.cjs.map +1 -1
- package/dist/runtime/telemetry/disclosure.mjs +3 -3
- package/dist/runtime/telemetry/disclosure.mjs.map +1 -1
- package/dist/runtime/telemetry/events.d.cts +1 -1
- package/dist/runtime/telemetry/events.d.mts +1 -1
- package/dist/runtime/telemetry/instance-created.cjs +33 -12
- package/dist/runtime/telemetry/instance-created.cjs.map +1 -1
- package/dist/runtime/telemetry/instance-created.mjs +33 -12
- package/dist/runtime/telemetry/instance-created.mjs.map +1 -1
- package/dist/runtime/telemetry/telemetry-client.cjs +0 -5
- package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/runtime/telemetry/telemetry-client.mjs +0 -4
- package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/runtime/telemetry/telemetry-identity.cjs +0 -1
- package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -1
- package/package.json +54 -29
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/agent/converters/index.d.mts +0 -2
- package/dist/agent/index.cjs +0 -1328
- package/dist/agent/index.cjs.map +0 -1
- package/dist/agent/index.d.cts +0 -467
- package/dist/agent/index.d.cts.map +0 -1
- package/dist/agent/index.d.mts +0 -468
- package/dist/agent/index.d.mts.map +0 -1
- package/dist/agent/index.mjs +0 -1318
- package/dist/agent/index.mjs.map +0 -1
- package/dist/agent/mcp-tool-names.cjs +0 -82
- package/dist/agent/mcp-tool-names.cjs.map +0 -1
- package/dist/agent/mcp-tool-names.mjs +0 -80
- package/dist/agent/mcp-tool-names.mjs.map +0 -1
- package/dist/agent/url-download.cjs.map +0 -1
- package/dist/agent/url-download.d.cts.map +0 -1
- package/dist/agent/url-download.d.mts.map +0 -1
- package/dist/agent/url-download.mjs.map +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ToolDefinition } from "../agent.cjs";
|
|
2
|
+
import { CreateSafeUrlDownloadOptions, SafeUrlDownloadOptions, createSafeUrlDownload } from "./ai-sdk/url-download.cjs";
|
|
3
|
+
import { Message, RunAgentInput } from "@ag-ui/client";
|
|
4
|
+
import { AnyTool } from "@tanstack/ai";
|
|
5
|
+
import { ModelMessage, ToolSet } from "ai";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
|
|
8
|
+
//#region src/agent/ai-sdk/index.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Options for {@link convertMessagesToVercelAISDKMessages}.
|
|
11
|
+
*/
|
|
12
|
+
interface MessageConversionOptions {
|
|
13
|
+
/** Send AG-UI `system` messages to the model as system messages. */
|
|
14
|
+
forwardSystemMessages?: boolean;
|
|
15
|
+
/** Send AG-UI `developer` messages to the model as system messages. */
|
|
16
|
+
forwardDeveloperMessages?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts AG-UI messages to AI SDK `ModelMessage`s, for `streamText` calls in
|
|
20
|
+
* a `type: "aisdk"` factory.
|
|
21
|
+
*
|
|
22
|
+
* System and developer messages are dropped unless the matching option is on.
|
|
23
|
+
* Tool results keep their text and inline media.
|
|
24
|
+
*
|
|
25
|
+
* @param messages - The run's AG-UI messages, usually `ctx.input.messages`.
|
|
26
|
+
* @param options - Which system and developer messages to forward.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* streamText({ model, messages: convertMessagesToVercelAISDKMessages(ctx.input.messages) })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function convertMessagesToVercelAISDKMessages(messages: Message[], options?: MessageConversionOptions): ModelMessage[];
|
|
33
|
+
/**
|
|
34
|
+
* The JSON Schema subset that {@link convertJsonSchemaToZodSchema} reads.
|
|
35
|
+
*/
|
|
36
|
+
interface JsonSchema {
|
|
37
|
+
type?: "object" | "string" | "number" | "integer" | "boolean" | "array" | "null";
|
|
38
|
+
description?: string;
|
|
39
|
+
properties?: Record<string, JsonSchema>;
|
|
40
|
+
required?: string[];
|
|
41
|
+
items?: JsonSchema;
|
|
42
|
+
enum?: string[];
|
|
43
|
+
anyOf?: JsonSchema[];
|
|
44
|
+
oneOf?: JsonSchema[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts a JSON Schema to a Zod schema, for `type: "aisdk"` factories that
|
|
48
|
+
* need a Zod schema for an AG-UI tool.
|
|
49
|
+
*
|
|
50
|
+
* @param jsonSchema - The schema: objects, strings (with `enum`), numbers,
|
|
51
|
+
* integers, booleans, arrays, `null`, and `anyOf` / `oneOf` unions.
|
|
52
|
+
* @param required - When false, the result is `.optional()`.
|
|
53
|
+
* @throws Error for an array without `items` or a `type` it does not know.
|
|
54
|
+
*/
|
|
55
|
+
declare function convertJsonSchemaToZodSchema(jsonSchema: JsonSchema, required: boolean): z.ZodSchema;
|
|
56
|
+
/**
|
|
57
|
+
* Converts AG-UI tools (the run's frontend tools, `ctx.input.tools`) to an AI
|
|
58
|
+
* SDK `ToolSet`, for `streamText` calls in a `type: "aisdk"` factory.
|
|
59
|
+
*
|
|
60
|
+
* The tools have no `execute`, so the AI SDK leaves their calls to the
|
|
61
|
+
* client. Their JSON Schema goes to the model unchanged, and the arguments
|
|
62
|
+
* are validated against it.
|
|
63
|
+
*
|
|
64
|
+
* @param tools - AG-UI tools whose `parameters` are JSON Schema objects.
|
|
65
|
+
* @throws Error when a tool's `parameters` is not a JSON Schema object.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* streamText({ model, tools: convertToolsToVercelAITools(ctx.input.tools) })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function convertToolsToVercelAITools(tools: RunAgentInput["tools"]): ToolSet;
|
|
72
|
+
/**
|
|
73
|
+
* Converts TanStack AI tools to an AI SDK `ToolSet`, for `streamText` calls in
|
|
74
|
+
* a `type: "aisdk"` factory.
|
|
75
|
+
*
|
|
76
|
+
* - A tool with `execute` keeps it. The AI SDK runs it with the parsed input.
|
|
77
|
+
* - A tool without `execute` stays client-side: the AI SDK leaves its calls
|
|
78
|
+
* to the client.
|
|
79
|
+
* - `inputSchema` can be JSON Schema or a Standard Schema such as Zod.
|
|
80
|
+
*
|
|
81
|
+
* A typical use is the learned-skill tools of the run:
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { streamText } from "ai";
|
|
85
|
+
* import { toAISDKTools } from "@copilotkit/runtime/agent/ai-sdk";
|
|
86
|
+
*
|
|
87
|
+
* factory: (ctx) =>
|
|
88
|
+
* streamText({
|
|
89
|
+
* model,
|
|
90
|
+
* system: ctx.learnedSkills.catalog,
|
|
91
|
+
* messages,
|
|
92
|
+
* tools: toAISDKTools(ctx.learnedSkills.tools),
|
|
93
|
+
* }),
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @param tools - TanStack server or client tools, as plain objects or from
|
|
97
|
+
* `toolDefinition()`.
|
|
98
|
+
* @throws Error when a Standard Schema cannot describe itself as JSON Schema.
|
|
99
|
+
*/
|
|
100
|
+
declare function toAISDKTools(tools: readonly AnyTool[]): ToolSet;
|
|
101
|
+
/**
|
|
102
|
+
* Converts tools made with `defineTool()` to an AI SDK `ToolSet`, for
|
|
103
|
+
* `streamText` calls in a `type: "aisdk"` factory.
|
|
104
|
+
*
|
|
105
|
+
* Each tool offers its JSON Schema to the model. Its `execute` validates the
|
|
106
|
+
* arguments with the tool's parameters schema and runs your `execute` with the
|
|
107
|
+
* parsed output. A tool without `execute` (an interrupt tool) stays
|
|
108
|
+
* client-side.
|
|
109
|
+
*
|
|
110
|
+
* @param tools - Tools from `defineTool()`.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* streamText({ model, tools: convertToolDefinitionsToVercelAITools([weatherTool]) })
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function convertToolDefinitionsToVercelAITools(tools: readonly ToolDefinition[]): ToolSet;
|
|
117
|
+
//#endregion
|
|
118
|
+
export { type CreateSafeUrlDownloadOptions, MessageConversionOptions, type SafeUrlDownloadOptions, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createSafeUrlDownload, toAISDKTools };
|
|
119
|
+
//# sourceMappingURL=ai-sdk.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk.d.cts","names":[],"sources":["../../src/agent/ai-sdk/index.ts"],"mappings":";;;;;;;;;AA8NA;;UAAiB,wBAAA;EAEf;EAAA,qBAAA;EAmBc;EAjBd,wBAAA;AAAA;;;;;;;;;;;;;AAkGD;;iBAjFe,oCAAA,CACd,QAAA,EAAU,OAAA,IACV,OAAA,GAAS,wBAAA,GAA6B,YAAA;;;;UAoF9B,UAAA;EACR,IAAA;EAQA,WAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,QAAA;EACA,KAAA,GAAQ,UAAA;EACR,IAAA;EAIA,KAAA,GAAQ,UAAA;EACR,KAAA,GAAQ,UAAA;AAAA;;;;;;;;;;iBAYM,4BAAA,CACd,UAAA,EAAY,UAAA,EACZ,QAAA,YACC,CAAA,CAAE,SAAA;;;;;;;;;;;AA8GL;;;;;iBAAgB,2BAAA,CAA4B,KAAA,EAAO,aAAA,YAAsB,OAAA;;;;AAwFzE;;;;;;;;;AA+BA;;;;;;;;;;;;;;;;iBA/BgB,YAAA,CAAa,KAAA,WAAgB,OAAA,KAAS,OAAA;;;;;;;;;;;;;;;;iBA+BtC,qCAAA,CACd,KAAA,WAAgB,cAAA,KAAgB,OAAA"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ToolDefinition } from "../agent.mjs";
|
|
2
|
+
import { CreateSafeUrlDownloadOptions, SafeUrlDownloadOptions, createSafeUrlDownload } from "./ai-sdk/url-download.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { Message, RunAgentInput } from "@ag-ui/client";
|
|
5
|
+
import { ModelMessage, ToolSet } from "ai";
|
|
6
|
+
import { AnyTool } from "@tanstack/ai";
|
|
7
|
+
|
|
8
|
+
//#region src/agent/ai-sdk/index.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Options for {@link convertMessagesToVercelAISDKMessages}.
|
|
11
|
+
*/
|
|
12
|
+
interface MessageConversionOptions {
|
|
13
|
+
/** Send AG-UI `system` messages to the model as system messages. */
|
|
14
|
+
forwardSystemMessages?: boolean;
|
|
15
|
+
/** Send AG-UI `developer` messages to the model as system messages. */
|
|
16
|
+
forwardDeveloperMessages?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts AG-UI messages to AI SDK `ModelMessage`s, for `streamText` calls in
|
|
20
|
+
* a `type: "aisdk"` factory.
|
|
21
|
+
*
|
|
22
|
+
* System and developer messages are dropped unless the matching option is on.
|
|
23
|
+
* Tool results keep their text and inline media.
|
|
24
|
+
*
|
|
25
|
+
* @param messages - The run's AG-UI messages, usually `ctx.input.messages`.
|
|
26
|
+
* @param options - Which system and developer messages to forward.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* streamText({ model, messages: convertMessagesToVercelAISDKMessages(ctx.input.messages) })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function convertMessagesToVercelAISDKMessages(messages: Message[], options?: MessageConversionOptions): ModelMessage[];
|
|
33
|
+
/**
|
|
34
|
+
* The JSON Schema subset that {@link convertJsonSchemaToZodSchema} reads.
|
|
35
|
+
*/
|
|
36
|
+
interface JsonSchema {
|
|
37
|
+
type?: "object" | "string" | "number" | "integer" | "boolean" | "array" | "null";
|
|
38
|
+
description?: string;
|
|
39
|
+
properties?: Record<string, JsonSchema>;
|
|
40
|
+
required?: string[];
|
|
41
|
+
items?: JsonSchema;
|
|
42
|
+
enum?: string[];
|
|
43
|
+
anyOf?: JsonSchema[];
|
|
44
|
+
oneOf?: JsonSchema[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts a JSON Schema to a Zod schema, for `type: "aisdk"` factories that
|
|
48
|
+
* need a Zod schema for an AG-UI tool.
|
|
49
|
+
*
|
|
50
|
+
* @param jsonSchema - The schema: objects, strings (with `enum`), numbers,
|
|
51
|
+
* integers, booleans, arrays, `null`, and `anyOf` / `oneOf` unions.
|
|
52
|
+
* @param required - When false, the result is `.optional()`.
|
|
53
|
+
* @throws Error for an array without `items` or a `type` it does not know.
|
|
54
|
+
*/
|
|
55
|
+
declare function convertJsonSchemaToZodSchema(jsonSchema: JsonSchema, required: boolean): z.ZodSchema;
|
|
56
|
+
/**
|
|
57
|
+
* Converts AG-UI tools (the run's frontend tools, `ctx.input.tools`) to an AI
|
|
58
|
+
* SDK `ToolSet`, for `streamText` calls in a `type: "aisdk"` factory.
|
|
59
|
+
*
|
|
60
|
+
* The tools have no `execute`, so the AI SDK leaves their calls to the
|
|
61
|
+
* client. Their JSON Schema goes to the model unchanged, and the arguments
|
|
62
|
+
* are validated against it.
|
|
63
|
+
*
|
|
64
|
+
* @param tools - AG-UI tools whose `parameters` are JSON Schema objects.
|
|
65
|
+
* @throws Error when a tool's `parameters` is not a JSON Schema object.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* streamText({ model, tools: convertToolsToVercelAITools(ctx.input.tools) })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function convertToolsToVercelAITools(tools: RunAgentInput["tools"]): ToolSet;
|
|
72
|
+
/**
|
|
73
|
+
* Converts TanStack AI tools to an AI SDK `ToolSet`, for `streamText` calls in
|
|
74
|
+
* a `type: "aisdk"` factory.
|
|
75
|
+
*
|
|
76
|
+
* - A tool with `execute` keeps it. The AI SDK runs it with the parsed input.
|
|
77
|
+
* - A tool without `execute` stays client-side: the AI SDK leaves its calls
|
|
78
|
+
* to the client.
|
|
79
|
+
* - `inputSchema` can be JSON Schema or a Standard Schema such as Zod.
|
|
80
|
+
*
|
|
81
|
+
* A typical use is the learned-skill tools of the run:
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { streamText } from "ai";
|
|
85
|
+
* import { toAISDKTools } from "@copilotkit/runtime/agent/ai-sdk";
|
|
86
|
+
*
|
|
87
|
+
* factory: (ctx) =>
|
|
88
|
+
* streamText({
|
|
89
|
+
* model,
|
|
90
|
+
* system: ctx.learnedSkills.catalog,
|
|
91
|
+
* messages,
|
|
92
|
+
* tools: toAISDKTools(ctx.learnedSkills.tools),
|
|
93
|
+
* }),
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @param tools - TanStack server or client tools, as plain objects or from
|
|
97
|
+
* `toolDefinition()`.
|
|
98
|
+
* @throws Error when a Standard Schema cannot describe itself as JSON Schema.
|
|
99
|
+
*/
|
|
100
|
+
declare function toAISDKTools(tools: readonly AnyTool[]): ToolSet;
|
|
101
|
+
/**
|
|
102
|
+
* Converts tools made with `defineTool()` to an AI SDK `ToolSet`, for
|
|
103
|
+
* `streamText` calls in a `type: "aisdk"` factory.
|
|
104
|
+
*
|
|
105
|
+
* Each tool offers its JSON Schema to the model. Its `execute` validates the
|
|
106
|
+
* arguments with the tool's parameters schema and runs your `execute` with the
|
|
107
|
+
* parsed output. A tool without `execute` (an interrupt tool) stays
|
|
108
|
+
* client-side.
|
|
109
|
+
*
|
|
110
|
+
* @param tools - Tools from `defineTool()`.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* streamText({ model, tools: convertToolDefinitionsToVercelAITools([weatherTool]) })
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function convertToolDefinitionsToVercelAITools(tools: readonly ToolDefinition[]): ToolSet;
|
|
117
|
+
//#endregion
|
|
118
|
+
export { type CreateSafeUrlDownloadOptions, MessageConversionOptions, type SafeUrlDownloadOptions, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createSafeUrlDownload, toAISDKTools };
|
|
119
|
+
//# sourceMappingURL=ai-sdk.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk.d.mts","names":[],"sources":["../../src/agent/ai-sdk/index.ts"],"mappings":";;;;;;;;;AA8NA;;UAAiB,wBAAA;EAEf;EAAA,qBAAA;EAmBc;EAjBd,wBAAA;AAAA;;;;;;;;;;;;;AAkGD;;iBAjFe,oCAAA,CACd,QAAA,EAAU,OAAA,IACV,OAAA,GAAS,wBAAA,GAA6B,YAAA;;;;UAoF9B,UAAA;EACR,IAAA;EAQA,WAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,QAAA;EACA,KAAA,GAAQ,UAAA;EACR,IAAA;EAIA,KAAA,GAAQ,UAAA;EACR,KAAA,GAAQ,UAAA;AAAA;;;;;;;;;;iBAYM,4BAAA,CACd,UAAA,EAAY,UAAA,EACZ,QAAA,YACC,CAAA,CAAE,SAAA;;;;;;;;;;;AA8GL;;;;;iBAAgB,2BAAA,CAA4B,KAAA,EAAO,aAAA,YAAsB,OAAA;;;;AAwFzE;;;;;;;;;AA+BA;;;;;;;;;;;;;;;;iBA/BgB,YAAA,CAAa,KAAA,WAAgB,OAAA,KAAS,OAAA;;;;;;;;;;;;;;;;iBA+BtC,qCAAA,CACd,KAAA,WAAgB,cAAA,KAAgB,OAAA"}
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { createSafeUrlDownload } from "./ai-sdk/url-download.mjs";
|
|
2
|
+
import { safeParseToolArgs, schemaToJsonSchema } from "@copilotkit/shared";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { RENDER_A2UI_TOOL } from "@ag-ui/a2ui-middleware";
|
|
5
|
+
import { Validator } from "@cfworker/json-schema";
|
|
6
|
+
import { jsonSchema, tool } from "ai";
|
|
7
|
+
|
|
8
|
+
//#region src/agent/ai-sdk/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* `@copilotkit/runtime/agent/ai-sdk`: helpers for `type: "aisdk"` factories.
|
|
11
|
+
*
|
|
12
|
+
* This is the only runtime entry that imports `ai` at module scope. An app
|
|
13
|
+
* that imports it uses the AI SDK, so `ai` must be installed.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* A tool result or user part can name a provider file handle (`file` source).
|
|
17
|
+
* It is neither bytes nor a URL, and the AI SDK cannot send it to the
|
|
18
|
+
* provider, so the part is dropped with a warning.
|
|
19
|
+
*/
|
|
20
|
+
function warnDroppedFileSource(what) {
|
|
21
|
+
console.warn(`[CopilotKit] Dropping a ${what} that references a provider file handle: it is not a URL or inline data, so it cannot be sent to the model here.`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The AI SDK output for an AG-UI tool message.
|
|
25
|
+
*
|
|
26
|
+
* A text-only result is one text output. A URL part becomes its URL as text.
|
|
27
|
+
* A result with inline media is a content list: the text entry first, when
|
|
28
|
+
* there is any, then each media part with its bytes and media type. A
|
|
29
|
+
* media-only result is media alone. A result whose parts were all dropped is
|
|
30
|
+
* the empty string, because AG-UI 1.0 requires every call to be answered.
|
|
31
|
+
*/
|
|
32
|
+
function toolResultOutput(content) {
|
|
33
|
+
if (typeof content === "string") return {
|
|
34
|
+
type: "text",
|
|
35
|
+
value: content
|
|
36
|
+
};
|
|
37
|
+
const segments = [];
|
|
38
|
+
const media = [];
|
|
39
|
+
let open = false;
|
|
40
|
+
for (const part of content) if (part.type === "text") {
|
|
41
|
+
if (open) segments[segments.length - 1] += part.text;
|
|
42
|
+
else segments.push(part.text);
|
|
43
|
+
open = true;
|
|
44
|
+
} else if (part.source.type === "file") warnDroppedFileSource(`${part.type} part in a tool result`);
|
|
45
|
+
else if (part.source.type === "url") {
|
|
46
|
+
segments.push(part.source.value);
|
|
47
|
+
open = false;
|
|
48
|
+
} else {
|
|
49
|
+
media.push({
|
|
50
|
+
type: "media",
|
|
51
|
+
data: part.source.value,
|
|
52
|
+
mediaType: part.source.mimeType
|
|
53
|
+
});
|
|
54
|
+
open = false;
|
|
55
|
+
}
|
|
56
|
+
const text = segments.join("\n");
|
|
57
|
+
if (media.length === 0) return {
|
|
58
|
+
type: "text",
|
|
59
|
+
value: text
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
type: "content",
|
|
63
|
+
value: [...text.length > 0 ? [{
|
|
64
|
+
type: "text",
|
|
65
|
+
text
|
|
66
|
+
}] : [], ...media]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** A URL from the request, or `null` (logged) when it does not parse. */
|
|
70
|
+
function parseContentUrl(value, what) {
|
|
71
|
+
try {
|
|
72
|
+
return new URL(value);
|
|
73
|
+
} catch {
|
|
74
|
+
console.error(`[CopilotKit] convertUserMessageContent: invalid URL "${value}" in ${what} part, skipping`);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Converts AG-UI user message content to AI SDK user content: plain strings,
|
|
80
|
+
* modality parts (image, audio, video, document), and the legacy `binary`
|
|
81
|
+
* part.
|
|
82
|
+
*/
|
|
83
|
+
function convertUserMessageContent(content) {
|
|
84
|
+
if (!content) return "";
|
|
85
|
+
if (typeof content === "string") return content;
|
|
86
|
+
const parts = [];
|
|
87
|
+
for (const part of content) {
|
|
88
|
+
if (!part || typeof part !== "object" || !("type" in part)) continue;
|
|
89
|
+
switch (part.type) {
|
|
90
|
+
case "text":
|
|
91
|
+
if (part.text) parts.push({
|
|
92
|
+
type: "text",
|
|
93
|
+
text: part.text
|
|
94
|
+
});
|
|
95
|
+
break;
|
|
96
|
+
case "image": {
|
|
97
|
+
const { source } = part;
|
|
98
|
+
if (!source) break;
|
|
99
|
+
if (source.type === "data") parts.push({
|
|
100
|
+
type: "image",
|
|
101
|
+
image: source.value,
|
|
102
|
+
mediaType: source.mimeType
|
|
103
|
+
});
|
|
104
|
+
else if (source.type === "file") warnDroppedFileSource("image part");
|
|
105
|
+
else {
|
|
106
|
+
const url = parseContentUrl(source.value, "image");
|
|
107
|
+
if (url) parts.push({
|
|
108
|
+
type: "image",
|
|
109
|
+
image: url,
|
|
110
|
+
mediaType: source.mimeType
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case "audio":
|
|
116
|
+
case "video":
|
|
117
|
+
case "document": {
|
|
118
|
+
const { source } = part;
|
|
119
|
+
if (!source) break;
|
|
120
|
+
if (source.type === "data") parts.push({
|
|
121
|
+
type: "file",
|
|
122
|
+
data: source.value,
|
|
123
|
+
mediaType: source.mimeType
|
|
124
|
+
});
|
|
125
|
+
else if (source.type === "file") warnDroppedFileSource(`${part.type} part`);
|
|
126
|
+
else {
|
|
127
|
+
const url = parseContentUrl(source.value, part.type);
|
|
128
|
+
if (url) parts.push({
|
|
129
|
+
type: "file",
|
|
130
|
+
data: url,
|
|
131
|
+
mediaType: source.mimeType ?? "application/octet-stream"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "binary": {
|
|
137
|
+
const mimeType = part.mimeType ?? "application/octet-stream";
|
|
138
|
+
const isImage = mimeType.startsWith("image/");
|
|
139
|
+
const data = part.data ? part.data : part.url ? parseContentUrl(part.url, "binary") : null;
|
|
140
|
+
if (!data) break;
|
|
141
|
+
parts.push(isImage ? {
|
|
142
|
+
type: "image",
|
|
143
|
+
image: data,
|
|
144
|
+
mediaType: mimeType
|
|
145
|
+
} : {
|
|
146
|
+
type: "file",
|
|
147
|
+
data,
|
|
148
|
+
mediaType: mimeType
|
|
149
|
+
});
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
default: {
|
|
153
|
+
const unknownPart = part;
|
|
154
|
+
console.error(`[CopilotKit] convertUserMessageContent: unrecognized content part type "${unknownPart.type}", skipping`);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return parts.length > 0 ? parts : "";
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Converts AG-UI messages to AI SDK `ModelMessage`s, for `streamText` calls in
|
|
163
|
+
* a `type: "aisdk"` factory.
|
|
164
|
+
*
|
|
165
|
+
* System and developer messages are dropped unless the matching option is on.
|
|
166
|
+
* Tool results keep their text and inline media.
|
|
167
|
+
*
|
|
168
|
+
* @param messages - The run's AG-UI messages, usually `ctx.input.messages`.
|
|
169
|
+
* @param options - Which system and developer messages to forward.
|
|
170
|
+
*
|
|
171
|
+
* ```ts
|
|
172
|
+
* streamText({ model, messages: convertMessagesToVercelAISDKMessages(ctx.input.messages) })
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
function convertMessagesToVercelAISDKMessages(messages, options = {}) {
|
|
176
|
+
const result = [];
|
|
177
|
+
for (const message of messages) if (message.role === "system" && options.forwardSystemMessages) {
|
|
178
|
+
const systemMsg = {
|
|
179
|
+
role: "system",
|
|
180
|
+
content: message.content ?? ""
|
|
181
|
+
};
|
|
182
|
+
result.push(systemMsg);
|
|
183
|
+
} else if (message.role === "developer" && options.forwardDeveloperMessages) {
|
|
184
|
+
const systemMsg = {
|
|
185
|
+
role: "system",
|
|
186
|
+
content: message.content ?? ""
|
|
187
|
+
};
|
|
188
|
+
result.push(systemMsg);
|
|
189
|
+
} else if (message.role === "assistant") {
|
|
190
|
+
const parts = message.content ? [{
|
|
191
|
+
type: "text",
|
|
192
|
+
text: message.content
|
|
193
|
+
}] : [];
|
|
194
|
+
const toolCalls = message.toolCalls ?? [];
|
|
195
|
+
for (const toolCall of toolCalls) parts.push({
|
|
196
|
+
type: "tool-call",
|
|
197
|
+
toolCallId: toolCall.id,
|
|
198
|
+
toolName: toolCall.function.name,
|
|
199
|
+
input: safeParseToolArgs(toolCall.function.arguments),
|
|
200
|
+
...toolCall.encryptedValue ? { providerOptions: { google: { thoughtSignature: toolCall.encryptedValue } } } : {}
|
|
201
|
+
});
|
|
202
|
+
const assistantMsg = {
|
|
203
|
+
role: "assistant",
|
|
204
|
+
content: parts
|
|
205
|
+
};
|
|
206
|
+
result.push(assistantMsg);
|
|
207
|
+
} else if (message.role === "user") {
|
|
208
|
+
const userMsg = {
|
|
209
|
+
role: "user",
|
|
210
|
+
content: convertUserMessageContent(message.content)
|
|
211
|
+
};
|
|
212
|
+
result.push(userMsg);
|
|
213
|
+
} else if (message.role === "tool") {
|
|
214
|
+
const toolName = messages.flatMap((msg) => msg.role === "assistant" ? msg.toolCalls ?? [] : []).find((toolCall) => toolCall.id === message.toolCallId)?.function.name ?? "unknown";
|
|
215
|
+
const toolMsg = {
|
|
216
|
+
role: "tool",
|
|
217
|
+
content: [{
|
|
218
|
+
type: "tool-result",
|
|
219
|
+
toolCallId: message.toolCallId,
|
|
220
|
+
toolName,
|
|
221
|
+
output: toolResultOutput(message.content)
|
|
222
|
+
}]
|
|
223
|
+
};
|
|
224
|
+
result.push(toolMsg);
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Converts a JSON Schema to a Zod schema, for `type: "aisdk"` factories that
|
|
230
|
+
* need a Zod schema for an AG-UI tool.
|
|
231
|
+
*
|
|
232
|
+
* @param jsonSchema - The schema: objects, strings (with `enum`), numbers,
|
|
233
|
+
* integers, booleans, arrays, `null`, and `anyOf` / `oneOf` unions.
|
|
234
|
+
* @param required - When false, the result is `.optional()`.
|
|
235
|
+
* @throws Error for an array without `items` or a `type` it does not know.
|
|
236
|
+
*/
|
|
237
|
+
function convertJsonSchemaToZodSchema(jsonSchema, required) {
|
|
238
|
+
const describe = (schema) => jsonSchema.description ? schema.describe(jsonSchema.description) : schema;
|
|
239
|
+
if (jsonSchema.type === "null") {
|
|
240
|
+
const schema = describe(z.null());
|
|
241
|
+
return required ? schema : schema.optional();
|
|
242
|
+
}
|
|
243
|
+
const unionVariants = jsonSchema.anyOf ?? jsonSchema.oneOf;
|
|
244
|
+
if (Array.isArray(unionVariants) && unionVariants.length > 0) {
|
|
245
|
+
if (unionVariants.length === 1) return convertJsonSchemaToZodSchema(unionVariants[0], required);
|
|
246
|
+
const variantSchemas = unionVariants.map((variant) => convertJsonSchemaToZodSchema(variant, true));
|
|
247
|
+
const schema = describe(z.union(variantSchemas));
|
|
248
|
+
return required ? schema : schema.optional();
|
|
249
|
+
}
|
|
250
|
+
if (!jsonSchema.type) return required ? z.object({}) : z.object({}).optional();
|
|
251
|
+
if (jsonSchema.type === "object") {
|
|
252
|
+
const spec = {};
|
|
253
|
+
if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) return !required ? z.object(spec).optional() : z.object(spec);
|
|
254
|
+
const requiredKeys = new Set(jsonSchema.required ?? []);
|
|
255
|
+
for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, requiredKeys.has(key));
|
|
256
|
+
const schema = describe(z.object(spec));
|
|
257
|
+
return required ? schema : schema.optional();
|
|
258
|
+
} else if (jsonSchema.type === "string") {
|
|
259
|
+
if (jsonSchema.enum && jsonSchema.enum.length > 0) {
|
|
260
|
+
const schema = describe(z.enum(jsonSchema.enum));
|
|
261
|
+
return required ? schema : schema.optional();
|
|
262
|
+
}
|
|
263
|
+
const schema = describe(z.string());
|
|
264
|
+
return required ? schema : schema.optional();
|
|
265
|
+
} else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
|
|
266
|
+
const schema = describe(z.number());
|
|
267
|
+
return required ? schema : schema.optional();
|
|
268
|
+
} else if (jsonSchema.type === "boolean") {
|
|
269
|
+
const schema = describe(z.boolean());
|
|
270
|
+
return required ? schema : schema.optional();
|
|
271
|
+
} else if (jsonSchema.type === "array") {
|
|
272
|
+
if (!jsonSchema.items) throw new Error("Array type must have items property");
|
|
273
|
+
const itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
|
|
274
|
+
const schema = describe(z.array(itemSchema));
|
|
275
|
+
return required ? schema : schema.optional();
|
|
276
|
+
}
|
|
277
|
+
console.error("Invalid JSON schema:", JSON.stringify(jsonSchema, null, 2));
|
|
278
|
+
throw new Error("Invalid JSON schema");
|
|
279
|
+
}
|
|
280
|
+
const JSON_SCHEMA_TYPES = [
|
|
281
|
+
"object",
|
|
282
|
+
"string",
|
|
283
|
+
"number",
|
|
284
|
+
"integer",
|
|
285
|
+
"boolean",
|
|
286
|
+
"array"
|
|
287
|
+
];
|
|
288
|
+
function isJsonSchema(obj) {
|
|
289
|
+
if (typeof obj !== "object" || obj === null) return false;
|
|
290
|
+
if (Object.keys(obj).length === 0) return true;
|
|
291
|
+
return "type" in obj && typeof obj.type === "string" && JSON_SCHEMA_TYPES.includes(obj.type);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Converts AG-UI tools (the run's frontend tools, `ctx.input.tools`) to an AI
|
|
295
|
+
* SDK `ToolSet`, for `streamText` calls in a `type: "aisdk"` factory.
|
|
296
|
+
*
|
|
297
|
+
* The tools have no `execute`, so the AI SDK leaves their calls to the
|
|
298
|
+
* client. Their JSON Schema goes to the model unchanged, and the arguments
|
|
299
|
+
* are validated against it.
|
|
300
|
+
*
|
|
301
|
+
* @param tools - AG-UI tools whose `parameters` are JSON Schema objects.
|
|
302
|
+
* @throws Error when a tool's `parameters` is not a JSON Schema object.
|
|
303
|
+
*
|
|
304
|
+
* ```ts
|
|
305
|
+
* streamText({ model, tools: convertToolsToVercelAITools(ctx.input.tools) })
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
function convertToolsToVercelAITools(tools) {
|
|
309
|
+
const result = {};
|
|
310
|
+
for (const tool$1 of tools) {
|
|
311
|
+
if (!isJsonSchema(tool$1.parameters)) throw new Error(`Invalid JSON schema for tool ${tool$1.name}`);
|
|
312
|
+
const validator = new Validator(tool$1.parameters, "7");
|
|
313
|
+
result[tool$1.name] = tool({
|
|
314
|
+
description: tool$1.description,
|
|
315
|
+
inputSchema: jsonSchema(tool$1.parameters, { validate: (value) => {
|
|
316
|
+
return validator.validate(value).valid ? {
|
|
317
|
+
success: true,
|
|
318
|
+
value
|
|
319
|
+
} : {
|
|
320
|
+
success: false,
|
|
321
|
+
error: /* @__PURE__ */ new Error(`Invalid arguments for tool ${tool$1.name}`)
|
|
322
|
+
};
|
|
323
|
+
} }),
|
|
324
|
+
...tool$1.name === RENDER_A2UI_TOOL.name ? { strict: false } : {}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
/** Whether a TanStack `inputSchema` is a Standard Schema (Zod, Valibot, ArkType). */
|
|
330
|
+
function isStandardSchema(schema) {
|
|
331
|
+
return "~standard" in schema;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The AI SDK input schema for a TanStack tool. No schema means no arguments.
|
|
335
|
+
* A Standard Schema also validates the input, so `execute` gets the parsed
|
|
336
|
+
* output (for example with Zod defaults applied), as in `chat()`.
|
|
337
|
+
*/
|
|
338
|
+
function toolInputSchema(name, schema) {
|
|
339
|
+
if (!schema) return jsonSchema({
|
|
340
|
+
type: "object",
|
|
341
|
+
properties: {}
|
|
342
|
+
});
|
|
343
|
+
if (!isStandardSchema(schema)) return jsonSchema(schema);
|
|
344
|
+
return jsonSchema(schemaToJsonSchema(schema), { validate: async (value) => {
|
|
345
|
+
const parsed = await schema["~standard"].validate(value);
|
|
346
|
+
if ("value" in parsed) return {
|
|
347
|
+
success: true,
|
|
348
|
+
value: parsed.value
|
|
349
|
+
};
|
|
350
|
+
const details = parsed.issues.map((issue) => issue.message).join("; ");
|
|
351
|
+
return {
|
|
352
|
+
success: false,
|
|
353
|
+
error: /* @__PURE__ */ new Error(`Invalid arguments for tool ${name}: ${details}`)
|
|
354
|
+
};
|
|
355
|
+
} });
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Converts TanStack AI tools to an AI SDK `ToolSet`, for `streamText` calls in
|
|
359
|
+
* a `type: "aisdk"` factory.
|
|
360
|
+
*
|
|
361
|
+
* - A tool with `execute` keeps it. The AI SDK runs it with the parsed input.
|
|
362
|
+
* - A tool without `execute` stays client-side: the AI SDK leaves its calls
|
|
363
|
+
* to the client.
|
|
364
|
+
* - `inputSchema` can be JSON Schema or a Standard Schema such as Zod.
|
|
365
|
+
*
|
|
366
|
+
* A typical use is the learned-skill tools of the run:
|
|
367
|
+
*
|
|
368
|
+
* ```ts
|
|
369
|
+
* import { streamText } from "ai";
|
|
370
|
+
* import { toAISDKTools } from "@copilotkit/runtime/agent/ai-sdk";
|
|
371
|
+
*
|
|
372
|
+
* factory: (ctx) =>
|
|
373
|
+
* streamText({
|
|
374
|
+
* model,
|
|
375
|
+
* system: ctx.learnedSkills.catalog,
|
|
376
|
+
* messages,
|
|
377
|
+
* tools: toAISDKTools(ctx.learnedSkills.tools),
|
|
378
|
+
* }),
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* @param tools - TanStack server or client tools, as plain objects or from
|
|
382
|
+
* `toolDefinition()`.
|
|
383
|
+
* @throws Error when a Standard Schema cannot describe itself as JSON Schema.
|
|
384
|
+
*/
|
|
385
|
+
function toAISDKTools(tools) {
|
|
386
|
+
const result = {};
|
|
387
|
+
for (const tanstackTool of tools) {
|
|
388
|
+
const { execute } = tanstackTool;
|
|
389
|
+
result[tanstackTool.name] = tool({
|
|
390
|
+
description: tanstackTool.description,
|
|
391
|
+
inputSchema: toolInputSchema(tanstackTool.name, tanstackTool.inputSchema),
|
|
392
|
+
...execute ? { execute: (input) => execute(input) } : {},
|
|
393
|
+
...tanstackTool.needsApproval ? { needsApproval: true } : {}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Converts tools made with `defineTool()` to an AI SDK `ToolSet`, for
|
|
400
|
+
* `streamText` calls in a `type: "aisdk"` factory.
|
|
401
|
+
*
|
|
402
|
+
* Each tool offers its JSON Schema to the model. Its `execute` validates the
|
|
403
|
+
* arguments with the tool's parameters schema and runs your `execute` with the
|
|
404
|
+
* parsed output. A tool without `execute` (an interrupt tool) stays
|
|
405
|
+
* client-side.
|
|
406
|
+
*
|
|
407
|
+
* @param tools - Tools from `defineTool()`.
|
|
408
|
+
*
|
|
409
|
+
* ```ts
|
|
410
|
+
* streamText({ model, tools: convertToolDefinitionsToVercelAITools([weatherTool]) })
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
function convertToolDefinitionsToVercelAITools(tools) {
|
|
414
|
+
return toAISDKTools(tools);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
//#endregion
|
|
418
|
+
export { convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createSafeUrlDownload, toAISDKTools };
|
|
419
|
+
//# sourceMappingURL=ai-sdk.mjs.map
|