@copilotkit/runtime 2.0.0-next.1 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +135 -1
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/agent/converters/aisdk.cjs +355 -0
- package/dist/agent/converters/aisdk.cjs.map +1 -0
- package/dist/agent/converters/aisdk.d.cts +22 -0
- package/dist/agent/converters/aisdk.d.cts.map +1 -0
- package/dist/agent/converters/aisdk.d.mts +22 -0
- package/dist/agent/converters/aisdk.d.mts.map +1 -0
- package/dist/agent/converters/aisdk.mjs +351 -0
- package/dist/agent/converters/aisdk.mjs.map +1 -0
- package/dist/agent/converters/index.d.mts +2 -0
- package/dist/agent/converters/tanstack.cjs +374 -0
- package/dist/agent/converters/tanstack.cjs.map +1 -0
- package/dist/agent/converters/tanstack.d.cts +83 -0
- package/dist/agent/converters/tanstack.d.cts.map +1 -0
- package/dist/agent/converters/tanstack.d.mts +83 -0
- package/dist/agent/converters/tanstack.d.mts.map +1 -0
- package/dist/agent/converters/tanstack.mjs +372 -0
- package/dist/agent/converters/tanstack.mjs.map +1 -0
- package/dist/agent/converters/usage.cjs +68 -0
- package/dist/agent/converters/usage.cjs.map +1 -0
- package/dist/agent/converters/usage.d.cts +19 -0
- package/dist/agent/converters/usage.d.cts.map +1 -0
- package/dist/agent/converters/usage.d.mts +19 -0
- package/dist/agent/converters/usage.d.mts.map +1 -0
- package/dist/agent/converters/usage.mjs +62 -0
- package/dist/agent/converters/usage.mjs.map +1 -0
- package/dist/agent/index.cjs +1328 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +467 -0
- package/dist/agent/index.d.cts.map +1 -0
- package/dist/agent/index.d.mts +468 -0
- package/dist/agent/index.d.mts.map +1 -0
- package/dist/agent/index.mjs +1318 -0
- package/dist/agent/index.mjs.map +1 -0
- package/dist/agent/learned-skills.cjs +76 -0
- package/dist/agent/learned-skills.cjs.map +1 -0
- package/dist/agent/learned-skills.d.cts +15 -0
- package/dist/agent/learned-skills.d.cts.map +1 -0
- package/dist/agent/learned-skills.d.mts +15 -0
- package/dist/agent/learned-skills.d.mts.map +1 -0
- package/dist/agent/learned-skills.mjs +74 -0
- package/dist/agent/learned-skills.mjs.map +1 -0
- package/dist/agent/mcp-tool-names.cjs +82 -0
- package/dist/agent/mcp-tool-names.cjs.map +1 -0
- package/dist/agent/mcp-tool-names.mjs +80 -0
- package/dist/agent/mcp-tool-names.mjs.map +1 -0
- package/dist/agent/state-delta.cjs +321 -0
- package/dist/agent/state-delta.cjs.map +1 -0
- package/dist/agent/state-delta.mjs +320 -0
- package/dist/agent/state-delta.mjs.map +1 -0
- package/dist/agent/url-download.cjs +503 -0
- package/dist/agent/url-download.cjs.map +1 -0
- package/dist/agent/url-download.d.cts +79 -0
- package/dist/agent/url-download.d.cts.map +1 -0
- package/dist/agent/url-download.d.mts +79 -0
- package/dist/agent/url-download.d.mts.map +1 -0
- package/dist/agent/url-download.mjs +500 -0
- package/dist/agent/url-download.mjs.map +1 -0
- package/dist/index.cjs +75 -0
- package/dist/index.d.cts +24 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.mjs +17 -5598
- package/dist/internal/learned-skills.cjs +21 -0
- package/dist/internal/learned-skills.d.cts +9 -0
- package/dist/internal/learned-skills.d.mts +9 -0
- package/dist/internal/learned-skills.mjs +9 -0
- package/dist/node.cjs +7 -0
- package/dist/node.d.cts +4 -0
- package/dist/node.d.mts +4 -0
- package/dist/node.mjs +4 -0
- package/dist/runtime/core/channel-activation-config.cjs +87 -0
- package/dist/runtime/core/channel-activation-config.cjs.map +1 -0
- package/dist/runtime/core/channel-activation-config.d.cts +39 -0
- package/dist/runtime/core/channel-activation-config.d.cts.map +1 -0
- package/dist/runtime/core/channel-activation-config.d.mts +39 -0
- package/dist/runtime/core/channel-activation-config.d.mts.map +1 -0
- package/dist/runtime/core/channel-activation-config.mjs +85 -0
- package/dist/runtime/core/channel-activation-config.mjs.map +1 -0
- package/dist/runtime/core/channel-manager.cjs +973 -0
- package/dist/runtime/core/channel-manager.cjs.map +1 -0
- package/dist/runtime/core/channel-manager.d.cts +166 -0
- package/dist/runtime/core/channel-manager.d.cts.map +1 -0
- package/dist/runtime/core/channel-manager.d.mts +167 -0
- package/dist/runtime/core/channel-manager.d.mts.map +1 -0
- package/dist/runtime/core/channel-manager.mjs +972 -0
- package/dist/runtime/core/channel-manager.mjs.map +1 -0
- package/dist/runtime/core/debug-event-bus.cjs +57 -0
- package/dist/runtime/core/debug-event-bus.cjs.map +1 -0
- package/dist/runtime/core/debug-event-bus.d.cts +18 -0
- package/dist/runtime/core/debug-event-bus.d.cts.map +1 -0
- package/dist/runtime/core/debug-event-bus.d.mts +18 -0
- package/dist/runtime/core/debug-event-bus.d.mts.map +1 -0
- package/dist/runtime/core/debug-event-bus.mjs +55 -0
- package/dist/runtime/core/debug-event-bus.mjs.map +1 -0
- package/dist/runtime/core/fetch-cors.cjs +71 -0
- package/dist/runtime/core/fetch-cors.cjs.map +1 -0
- package/dist/runtime/core/fetch-cors.d.cts +19 -0
- package/dist/runtime/core/fetch-cors.d.cts.map +1 -0
- package/dist/runtime/core/fetch-cors.d.mts +19 -0
- package/dist/runtime/core/fetch-cors.d.mts.map +1 -0
- package/dist/runtime/core/fetch-cors.mjs +69 -0
- package/dist/runtime/core/fetch-cors.mjs.map +1 -0
- package/dist/runtime/core/fetch-handler.cjs +539 -0
- package/dist/runtime/core/fetch-handler.cjs.map +1 -0
- package/dist/runtime/core/fetch-handler.d.cts +99 -0
- package/dist/runtime/core/fetch-handler.d.cts.map +1 -0
- package/dist/runtime/core/fetch-handler.d.mts +99 -0
- package/dist/runtime/core/fetch-handler.d.mts.map +1 -0
- package/dist/runtime/core/fetch-handler.mjs +538 -0
- package/dist/runtime/core/fetch-handler.mjs.map +1 -0
- package/dist/runtime/core/fetch-router.cjs +141 -0
- package/dist/runtime/core/fetch-router.cjs.map +1 -0
- package/dist/runtime/core/fetch-router.mjs +140 -0
- package/dist/runtime/core/fetch-router.mjs.map +1 -0
- package/dist/runtime/core/hooks.cjs +28 -0
- package/dist/runtime/core/hooks.cjs.map +1 -0
- package/dist/runtime/core/hooks.d.cts +121 -0
- package/dist/runtime/core/hooks.d.cts.map +1 -0
- package/dist/runtime/core/hooks.d.mts +121 -0
- package/dist/runtime/core/hooks.d.mts.map +1 -0
- package/dist/runtime/core/hooks.mjs +24 -0
- package/dist/runtime/core/hooks.mjs.map +1 -0
- package/dist/runtime/core/learning.cjs +61 -0
- package/dist/runtime/core/learning.cjs.map +1 -0
- package/dist/runtime/core/learning.d.cts +61 -0
- package/dist/runtime/core/learning.d.cts.map +1 -0
- package/dist/runtime/core/learning.d.mts +61 -0
- package/dist/runtime/core/learning.d.mts.map +1 -0
- package/dist/runtime/core/learning.mjs +56 -0
- package/dist/runtime/core/learning.mjs.map +1 -0
- package/dist/runtime/core/logger.cjs +21 -0
- package/dist/runtime/core/logger.cjs.map +1 -0
- package/dist/runtime/core/logger.d.cts +12 -0
- package/dist/runtime/core/logger.d.cts.map +1 -0
- package/dist/runtime/core/logger.d.mts +12 -0
- package/dist/runtime/core/logger.d.mts.map +1 -0
- package/dist/runtime/core/logger.mjs +18 -0
- package/dist/runtime/core/logger.mjs.map +1 -0
- package/dist/runtime/core/middleware-sse-parser.cjs +149 -0
- package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -0
- package/dist/runtime/core/middleware-sse-parser.d.cts +21 -0
- package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -0
- package/dist/runtime/core/middleware-sse-parser.d.mts +21 -0
- package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -0
- package/dist/runtime/core/middleware-sse-parser.mjs +148 -0
- package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -0
- package/dist/runtime/core/middleware.cjs +34 -0
- package/dist/runtime/core/middleware.cjs.map +1 -0
- package/dist/runtime/core/middleware.d.cts +31 -0
- package/dist/runtime/core/middleware.d.cts.map +1 -0
- package/dist/runtime/core/middleware.d.mts +31 -0
- package/dist/runtime/core/middleware.d.mts.map +1 -0
- package/dist/runtime/core/middleware.mjs +32 -0
- package/dist/runtime/core/middleware.mjs.map +1 -0
- package/dist/runtime/core/package-info.cjs +9 -0
- package/dist/runtime/core/package-info.cjs.map +1 -0
- package/dist/runtime/core/package-info.mjs +7 -0
- package/dist/runtime/core/package-info.mjs.map +1 -0
- package/dist/runtime/core/runtime-error-reporter.cjs +21 -0
- package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -0
- package/dist/runtime/core/runtime-error-reporter.mjs +18 -0
- package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -0
- package/dist/runtime/core/runtime.cjs +256 -0
- package/dist/runtime/core/runtime.cjs.map +1 -0
- package/dist/runtime/core/runtime.d.cts +481 -0
- package/dist/runtime/core/runtime.d.cts.map +1 -0
- package/dist/runtime/core/runtime.d.mts +481 -0
- package/dist/runtime/core/runtime.d.mts.map +1 -0
- package/dist/runtime/core/runtime.mjs +249 -0
- package/dist/runtime/core/runtime.mjs.map +1 -0
- package/dist/runtime/endpoints/auto-start-channels.cjs +46 -0
- package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -0
- package/dist/runtime/endpoints/auto-start-channels.mjs +45 -0
- package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -0
- package/dist/runtime/endpoints/node-fetch-handler.cjs +75 -0
- package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -0
- package/dist/runtime/endpoints/node-fetch-handler.d.cts +11 -0
- package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -0
- package/dist/runtime/endpoints/node-fetch-handler.d.mts +11 -0
- package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -0
- package/dist/runtime/endpoints/node-fetch-handler.mjs +73 -0
- package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -0
- package/dist/runtime/endpoints/node.cjs +16 -0
- package/dist/runtime/endpoints/node.cjs.map +1 -0
- package/dist/runtime/endpoints/node.d.cts +104 -0
- package/dist/runtime/endpoints/node.d.cts.map +1 -0
- package/dist/runtime/endpoints/node.d.mts +104 -0
- package/dist/runtime/endpoints/node.d.mts.map +1 -0
- package/dist/runtime/endpoints/node.mjs +16 -0
- package/dist/runtime/endpoints/node.mjs.map +1 -0
- package/dist/runtime/endpoints/single-route-helpers.cjs +130 -0
- package/dist/runtime/endpoints/single-route-helpers.cjs.map +1 -0
- package/dist/runtime/endpoints/single-route-helpers.mjs +125 -0
- package/dist/runtime/endpoints/single-route-helpers.mjs.map +1 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.cjs +393 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.d.cts +20 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.d.cts.map +1 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.d.mts +20 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.d.mts.map +1 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.mjs +392 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.mjs.map +1 -0
- package/dist/runtime/generative-ui/index.d.cts +2 -0
- package/dist/runtime/generative-ui/index.d.mts +2 -0
- package/dist/runtime/generative-ui/surface-writer.cjs +85 -0
- package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -0
- package/dist/runtime/generative-ui/surface-writer.d.cts +32 -0
- package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -0
- package/dist/runtime/generative-ui/surface-writer.d.mts +32 -0
- package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -0
- package/dist/runtime/generative-ui/surface-writer.mjs +84 -0
- package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -0
- package/dist/runtime/handlers/get-runtime-info.cjs +140 -0
- package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -0
- package/dist/runtime/handlers/get-runtime-info.mjs +140 -0
- package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -0
- package/dist/runtime/handlers/handle-connect.cjs +62 -0
- package/dist/runtime/handlers/handle-connect.cjs.map +1 -0
- package/dist/runtime/handlers/handle-connect.mjs +62 -0
- package/dist/runtime/handlers/handle-connect.mjs.map +1 -0
- package/dist/runtime/handlers/handle-debug-events.cjs +33 -0
- package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -0
- package/dist/runtime/handlers/handle-debug-events.mjs +33 -0
- package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -0
- package/dist/runtime/handlers/handle-inspector-learning.cjs +56 -0
- package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -0
- package/dist/runtime/handlers/handle-inspector-learning.mjs +55 -0
- package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -0
- package/dist/runtime/handlers/handle-inspector-metadata.cjs +36 -0
- package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -0
- package/dist/runtime/handlers/handle-inspector-metadata.mjs +35 -0
- package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -0
- package/dist/runtime/handlers/handle-run.cjs +111 -0
- package/dist/runtime/handlers/handle-run.cjs.map +1 -0
- package/dist/runtime/handlers/handle-run.mjs +110 -0
- package/dist/runtime/handlers/handle-run.mjs.map +1 -0
- package/dist/runtime/handlers/handle-stop.cjs +102 -0
- package/dist/runtime/handlers/handle-stop.cjs.map +1 -0
- package/dist/runtime/handlers/handle-stop.mjs +101 -0
- package/dist/runtime/handlers/handle-stop.mjs.map +1 -0
- package/dist/runtime/handlers/handle-suggest.cjs +83 -0
- package/dist/runtime/handlers/handle-suggest.cjs.map +1 -0
- package/dist/runtime/handlers/handle-suggest.mjs +82 -0
- package/dist/runtime/handlers/handle-suggest.mjs.map +1 -0
- package/dist/runtime/handlers/handle-trajectory-connect.cjs +40 -0
- package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -0
- package/dist/runtime/handlers/handle-trajectory-connect.mjs +39 -0
- package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -0
- package/dist/runtime/handlers/handle-transcribe.cjs +112 -0
- package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -0
- package/dist/runtime/handlers/handle-transcribe.mjs +111 -0
- package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -0
- package/dist/runtime/handlers/header-utils.cjs +185 -0
- package/dist/runtime/handlers/header-utils.cjs.map +1 -0
- package/dist/runtime/handlers/header-utils.d.cts +53 -0
- package/dist/runtime/handlers/header-utils.d.cts.map +1 -0
- package/dist/runtime/handlers/header-utils.d.mts +53 -0
- package/dist/runtime/handlers/header-utils.d.mts.map +1 -0
- package/dist/runtime/handlers/header-utils.mjs +183 -0
- package/dist/runtime/handlers/header-utils.mjs.map +1 -0
- package/dist/runtime/handlers/intelligence/annotate.cjs +83 -0
- package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -0
- package/dist/runtime/handlers/intelligence/annotate.mjs +82 -0
- package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -0
- package/dist/runtime/handlers/intelligence/connect.cjs +68 -0
- package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -0
- package/dist/runtime/handlers/intelligence/connect.mjs +68 -0
- package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -0
- package/dist/runtime/handlers/intelligence/memories.cjs +260 -0
- package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -0
- package/dist/runtime/handlers/intelligence/memories.mjs +254 -0
- package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -0
- package/dist/runtime/handlers/intelligence/run.cjs +283 -0
- package/dist/runtime/handlers/intelligence/run.cjs.map +1 -0
- package/dist/runtime/handlers/intelligence/run.mjs +282 -0
- package/dist/runtime/handlers/intelligence/run.mjs.map +1 -0
- package/dist/runtime/handlers/intelligence/thread-names.cjs +172 -0
- package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -0
- package/dist/runtime/handlers/intelligence/thread-names.mjs +171 -0
- package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -0
- package/dist/runtime/handlers/intelligence/threads.cjs +399 -0
- package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -0
- package/dist/runtime/handlers/intelligence/threads.mjs +390 -0
- package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -0
- package/dist/runtime/handlers/shared/agent-utils.cjs +267 -0
- package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -0
- package/dist/runtime/handlers/shared/agent-utils.mjs +262 -0
- package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -0
- package/dist/runtime/handlers/shared/cloud-telemetry.cjs +30 -0
- package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -0
- package/dist/runtime/handlers/shared/cloud-telemetry.mjs +29 -0
- package/dist/runtime/handlers/shared/cloud-telemetry.mjs.map +1 -0
- package/dist/runtime/handlers/shared/describe-endpoint.cjs +25 -0
- package/dist/runtime/handlers/shared/describe-endpoint.cjs.map +1 -0
- package/dist/runtime/handlers/shared/describe-endpoint.mjs +24 -0
- package/dist/runtime/handlers/shared/describe-endpoint.mjs.map +1 -0
- package/dist/runtime/handlers/shared/intelligence-utils.cjs +24 -0
- package/dist/runtime/handlers/shared/intelligence-utils.cjs.map +1 -0
- package/dist/runtime/handlers/shared/intelligence-utils.mjs +23 -0
- package/dist/runtime/handlers/shared/intelligence-utils.mjs.map +1 -0
- package/dist/runtime/handlers/shared/json-response.cjs +14 -0
- package/dist/runtime/handlers/shared/json-response.cjs.map +1 -0
- package/dist/runtime/handlers/shared/json-response.mjs +12 -0
- package/dist/runtime/handlers/shared/json-response.mjs.map +1 -0
- package/dist/runtime/handlers/shared/mcp-apps-servers.cjs +22 -0
- package/dist/runtime/handlers/shared/mcp-apps-servers.cjs.map +1 -0
- package/dist/runtime/handlers/shared/mcp-apps-servers.mjs +22 -0
- package/dist/runtime/handlers/shared/mcp-apps-servers.mjs.map +1 -0
- package/dist/runtime/handlers/shared/memory-policy.cjs +78 -0
- package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -0
- package/dist/runtime/handlers/shared/memory-policy.mjs +77 -0
- package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -0
- package/dist/runtime/handlers/shared/platform-error.cjs +39 -0
- package/dist/runtime/handlers/shared/platform-error.cjs.map +1 -0
- package/dist/runtime/handlers/shared/platform-error.mjs +39 -0
- package/dist/runtime/handlers/shared/platform-error.mjs.map +1 -0
- package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +50 -0
- package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -0
- package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +49 -0
- package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -0
- package/dist/runtime/handlers/shared/sse-keep-alive.cjs +68 -0
- package/dist/runtime/handlers/shared/sse-keep-alive.cjs.map +1 -0
- package/dist/runtime/handlers/shared/sse-keep-alive.mjs +66 -0
- package/dist/runtime/handlers/shared/sse-keep-alive.mjs.map +1 -0
- package/dist/runtime/handlers/shared/sse-response.cjs +237 -0
- package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -0
- package/dist/runtime/handlers/shared/sse-response.mjs +236 -0
- package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -0
- package/dist/runtime/handlers/shared/thread-access.cjs +137 -0
- package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -0
- package/dist/runtime/handlers/shared/thread-access.d.cts +28 -0
- package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -0
- package/dist/runtime/handlers/shared/thread-access.d.mts +28 -0
- package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -0
- package/dist/runtime/handlers/shared/thread-access.mjs +132 -0
- package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -0
- package/dist/runtime/handlers/sse/connect.cjs +23 -0
- package/dist/runtime/handlers/sse/connect.cjs.map +1 -0
- package/dist/runtime/handlers/sse/connect.mjs +23 -0
- package/dist/runtime/handlers/sse/connect.mjs.map +1 -0
- package/dist/runtime/handlers/sse/run.cjs +44 -0
- package/dist/runtime/handlers/sse/run.cjs.map +1 -0
- package/dist/runtime/handlers/sse/run.mjs +44 -0
- package/dist/runtime/handlers/sse/run.mjs.map +1 -0
- package/dist/runtime/index.d.cts +29 -0
- package/dist/runtime/index.d.cts.map +1 -0
- package/dist/runtime/index.d.mts +29 -0
- package/dist/runtime/index.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/client.cjs +1338 -0
- package/dist/runtime/intelligence-platform/client.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/client.d.cts +824 -0
- package/dist/runtime/intelligence-platform/client.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/client.d.mts +824 -0
- package/dist/runtime/intelligence-platform/client.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/client.mjs +1334 -0
- package/dist/runtime/intelligence-platform/client.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/experimental.d.cts +26 -0
- package/dist/runtime/intelligence-platform/experimental.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/experimental.d.mts +26 -0
- package/dist/runtime/intelligence-platform/experimental.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/index.d.cts +3 -0
- package/dist/runtime/intelligence-platform/index.d.mts +3 -0
- package/dist/runtime/intelligence-platform/learned-skills.cjs +95 -0
- package/dist/runtime/intelligence-platform/learned-skills.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/learned-skills.d.cts +43 -0
- package/dist/runtime/intelligence-platform/learned-skills.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/learned-skills.d.mts +43 -0
- package/dist/runtime/intelligence-platform/learned-skills.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/learned-skills.mjs +92 -0
- package/dist/runtime/intelligence-platform/learned-skills.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/learning-management.cjs +203 -0
- package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/learning-management.d.cts +111 -0
- package/dist/runtime/intelligence-platform/learning-management.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/learning-management.d.mts +111 -0
- package/dist/runtime/intelligence-platform/learning-management.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/learning-management.mjs +193 -0
- package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +131 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +10 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +10 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +127 -0
- package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.cjs +65 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.d.cts +47 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.d.mts +47 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.mjs +65 -0
- package/dist/runtime/intelligence-platform/skill-registry/config.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.cjs +10 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts +7 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts +7 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.mjs +10 -0
- package/dist/runtime/intelligence-platform/skill-registry/errors.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +7 -0
- package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +7 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +247 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts +36 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts +36 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +246 -0
- package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs +41 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts +12 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts +12 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs +38 -0
- package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs +92 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts +27 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts +27 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs +91 -0
- package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +142 -0
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +141 -0
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/trajectories.cjs +95 -0
- package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/trajectories.d.cts +11 -0
- package/dist/runtime/intelligence-platform/trajectories.d.cts.map +1 -0
- package/dist/runtime/intelligence-platform/trajectories.d.mts +11 -0
- package/dist/runtime/intelligence-platform/trajectories.d.mts.map +1 -0
- package/dist/runtime/intelligence-platform/trajectories.mjs +91 -0
- package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -0
- package/dist/runtime/node.d.cts +2 -0
- package/dist/runtime/node.d.mts +2 -0
- package/dist/runtime/runner/agent-runner.cjs +82 -0
- package/dist/runtime/runner/agent-runner.cjs.map +1 -0
- package/dist/runtime/runner/agent-runner.d.cts +151 -0
- package/dist/runtime/runner/agent-runner.d.cts.map +1 -0
- package/dist/runtime/runner/agent-runner.d.mts +151 -0
- package/dist/runtime/runner/agent-runner.d.mts.map +1 -0
- package/dist/runtime/runner/agent-runner.mjs +73 -0
- package/dist/runtime/runner/agent-runner.mjs.map +1 -0
- package/dist/runtime/runner/in-memory.cjs +741 -0
- package/dist/runtime/runner/in-memory.cjs.map +1 -0
- package/dist/runtime/runner/in-memory.d.cts +427 -0
- package/dist/runtime/runner/in-memory.d.cts.map +1 -0
- package/dist/runtime/runner/in-memory.d.mts +427 -0
- package/dist/runtime/runner/in-memory.d.mts.map +1 -0
- package/dist/runtime/runner/in-memory.mjs +734 -0
- package/dist/runtime/runner/in-memory.mjs.map +1 -0
- package/dist/runtime/runner/index.d.cts +5 -0
- package/dist/runtime/runner/index.d.mts +5 -0
- package/dist/runtime/runner/index.mjs +6 -0
- package/dist/runtime/runner/intelligence.cjs +617 -0
- package/dist/runtime/runner/intelligence.cjs.map +1 -0
- package/dist/runtime/runner/intelligence.d.cts +104 -0
- package/dist/runtime/runner/intelligence.d.cts.map +1 -0
- package/dist/runtime/runner/intelligence.d.mts +104 -0
- package/dist/runtime/runner/intelligence.d.mts.map +1 -0
- package/dist/runtime/runner/intelligence.mjs +616 -0
- package/dist/runtime/runner/intelligence.mjs.map +1 -0
- package/dist/runtime/telemetry/disclosure.cjs +25 -0
- package/dist/runtime/telemetry/disclosure.cjs.map +1 -0
- package/dist/runtime/telemetry/disclosure.mjs +24 -0
- package/dist/runtime/telemetry/disclosure.mjs.map +1 -0
- package/dist/runtime/telemetry/events.d.cts +66 -0
- package/dist/runtime/telemetry/events.d.cts.map +1 -0
- package/dist/runtime/telemetry/events.d.mts +66 -0
- package/dist/runtime/telemetry/events.d.mts.map +1 -0
- package/dist/runtime/telemetry/instance-created.cjs +34 -0
- package/dist/runtime/telemetry/instance-created.cjs.map +1 -0
- package/dist/runtime/telemetry/instance-created.mjs +34 -0
- package/dist/runtime/telemetry/instance-created.mjs.map +1 -0
- package/dist/runtime/telemetry/telemetry-client.cjs +108 -0
- package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -0
- package/dist/runtime/telemetry/telemetry-client.d.cts +10 -0
- package/dist/runtime/telemetry/telemetry-client.d.cts.map +1 -0
- package/dist/runtime/telemetry/telemetry-client.d.mts +10 -0
- package/dist/runtime/telemetry/telemetry-client.d.mts.map +1 -0
- package/dist/runtime/telemetry/telemetry-client.mjs +107 -0
- package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -0
- package/dist/runtime/telemetry/telemetry-identity.cjs +12 -0
- package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -0
- package/dist/runtime/telemetry/telemetry-identity.mjs +11 -0
- package/dist/runtime/telemetry/telemetry-identity.mjs.map +1 -0
- package/dist/runtime/transcription-service/transcription-service.cjs +7 -0
- package/dist/runtime/transcription-service/transcription-service.cjs.map +1 -0
- package/dist/runtime/transcription-service/transcription-service.d.cts +14 -0
- package/dist/runtime/transcription-service/transcription-service.d.cts.map +1 -0
- package/dist/runtime/transcription-service/transcription-service.d.mts +14 -0
- package/dist/runtime/transcription-service/transcription-service.d.mts.map +1 -0
- package/dist/runtime/transcription-service/transcription-service.mjs +6 -0
- package/dist/runtime/transcription-service/transcription-service.mjs.map +1 -0
- package/package.json +104 -105
- package/.eslintrc.js +0 -7
- package/CHANGELOG.md +0 -2920
- package/__snapshots__/schema/schema.graphql +0 -371
- package/dist/index.d.ts +0 -1494
- package/dist/index.js +0 -5641
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/langgraph.d.ts +0 -284
- package/dist/langgraph.js +0 -211
- package/dist/langgraph.js.map +0 -1
- package/dist/langgraph.mjs +0 -206
- package/dist/langgraph.mjs.map +0 -1
- package/dist/v2/index.d.ts +0 -2
- package/dist/v2/index.js +0 -22
- package/dist/v2/index.js.map +0 -1
- package/dist/v2/index.mjs +0 -5
- package/dist/v2/index.mjs.map +0 -1
- package/jest.config.js +0 -10
- package/scripts/generate-gql-schema.ts +0 -13
- package/src/agents/langgraph/event-source.ts +0 -329
- package/src/agents/langgraph/events.ts +0 -377
- package/src/graphql/inputs/action.input.ts +0 -16
- package/src/graphql/inputs/agent-session.input.ts +0 -13
- package/src/graphql/inputs/agent-state.input.ts +0 -13
- package/src/graphql/inputs/cloud-guardrails.input.ts +0 -16
- package/src/graphql/inputs/cloud.input.ts +0 -8
- package/src/graphql/inputs/context-property.input.ts +0 -10
- package/src/graphql/inputs/copilot-context.input.ts +0 -10
- package/src/graphql/inputs/custom-property.input.ts +0 -15
- package/src/graphql/inputs/extensions.input.ts +0 -21
- package/src/graphql/inputs/forwarded-parameters.input.ts +0 -22
- package/src/graphql/inputs/frontend.input.ts +0 -14
- package/src/graphql/inputs/generate-copilot-response.input.ts +0 -59
- package/src/graphql/inputs/load-agent-state.input.ts +0 -10
- package/src/graphql/inputs/message.input.ts +0 -110
- package/src/graphql/inputs/meta-event.input.ts +0 -18
- package/src/graphql/message-conversion/agui-to-gql.test.ts +0 -1263
- package/src/graphql/message-conversion/agui-to-gql.ts +0 -333
- package/src/graphql/message-conversion/gql-to-agui.test.ts +0 -1580
- package/src/graphql/message-conversion/gql-to-agui.ts +0 -278
- package/src/graphql/message-conversion/index.ts +0 -2
- package/src/graphql/message-conversion/roundtrip-conversion.test.ts +0 -526
- package/src/graphql/resolvers/copilot.resolver.ts +0 -708
- package/src/graphql/resolvers/state.resolver.ts +0 -27
- package/src/graphql/types/agents-response.type.ts +0 -19
- package/src/graphql/types/base/index.ts +0 -10
- package/src/graphql/types/converted/index.ts +0 -176
- package/src/graphql/types/copilot-response.type.ts +0 -138
- package/src/graphql/types/enums.ts +0 -38
- package/src/graphql/types/extensions-response.type.ts +0 -23
- package/src/graphql/types/guardrails-result.type.ts +0 -20
- package/src/graphql/types/load-agent-state-response.type.ts +0 -17
- package/src/graphql/types/message-status.type.ts +0 -42
- package/src/graphql/types/meta-events.type.ts +0 -71
- package/src/graphql/types/response-status.type.ts +0 -66
- package/src/index.ts +0 -4
- package/src/langgraph.ts +0 -1
- package/src/lib/cloud/index.ts +0 -4
- package/src/lib/error-messages.ts +0 -200
- package/src/lib/index.ts +0 -52
- package/src/lib/integrations/index.ts +0 -6
- package/src/lib/integrations/nest/index.ts +0 -14
- package/src/lib/integrations/nextjs/app-router.ts +0 -38
- package/src/lib/integrations/nextjs/pages-router.ts +0 -39
- package/src/lib/integrations/node-express/index.ts +0 -14
- package/src/lib/integrations/node-http/index.ts +0 -143
- package/src/lib/integrations/node-http/request-handler.ts +0 -111
- package/src/lib/integrations/shared.ts +0 -161
- package/src/lib/logger.ts +0 -28
- package/src/lib/observability.ts +0 -160
- package/src/lib/runtime/__tests__/copilot-runtime-error.test.ts +0 -169
- package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +0 -464
- package/src/lib/runtime/agent-integrations/langgraph/agent.ts +0 -209
- package/src/lib/runtime/agent-integrations/langgraph/consts.ts +0 -34
- package/src/lib/runtime/agent-integrations/langgraph/index.ts +0 -2
- package/src/lib/runtime/copilot-runtime.ts +0 -710
- package/src/lib/runtime/mcp-tools-utils.ts +0 -254
- package/src/lib/runtime/retry-utils.ts +0 -96
- package/src/lib/runtime/telemetry-agent-runner.ts +0 -139
- package/src/lib/runtime/types.ts +0 -49
- package/src/lib/runtime/utils.ts +0 -87
- package/src/lib/streaming.ts +0 -202
- package/src/lib/telemetry-client.ts +0 -64
- package/src/service-adapters/anthropic/anthropic-adapter.ts +0 -452
- package/src/service-adapters/anthropic/utils.ts +0 -152
- package/src/service-adapters/bedrock/bedrock-adapter.ts +0 -73
- package/src/service-adapters/conversion.ts +0 -67
- package/src/service-adapters/empty/empty-adapter.ts +0 -38
- package/src/service-adapters/events.ts +0 -294
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +0 -84
- package/src/service-adapters/google/google-genai-adapter.test.ts +0 -104
- package/src/service-adapters/google/google-genai-adapter.ts +0 -88
- package/src/service-adapters/groq/groq-adapter.ts +0 -203
- package/src/service-adapters/index.ts +0 -18
- package/src/service-adapters/langchain/langchain-adapter.ts +0 -111
- package/src/service-adapters/langchain/langserve.ts +0 -88
- package/src/service-adapters/langchain/types.ts +0 -14
- package/src/service-adapters/langchain/utils.ts +0 -313
- package/src/service-adapters/openai/openai-adapter.ts +0 -283
- package/src/service-adapters/openai/openai-assistant-adapter.ts +0 -344
- package/src/service-adapters/openai/utils.ts +0 -199
- package/src/service-adapters/service-adapter.ts +0 -41
- package/src/service-adapters/shared/error-utils.ts +0 -61
- package/src/service-adapters/shared/index.ts +0 -1
- package/src/service-adapters/unify/unify-adapter.ts +0 -151
- package/src/utils/failed-response-status-reasons.ts +0 -70
- package/src/utils/index.ts +0 -1
- package/src/v2/index.ts +0 -3
- package/tests/global.d.ts +0 -13
- package/tests/service-adapters/anthropic/allowlist-approach.test.ts +0 -226
- package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +0 -389
- package/tests/service-adapters/openai/allowlist-approach.test.ts +0 -238
- package/tests/service-adapters/openai/openai-adapter.test.ts +0 -301
- package/tests/setup.jest.ts +0 -21
- package/tests/tsconfig.json +0 -10
- package/tsconfig.json +0 -13
- package/tsup.config.ts +0 -20
- package/typedoc.json +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.mjs","names":[],"sources":["../../../src/runtime/core/hooks.ts"],"sourcesContent":["/**\n * Lifecycle hooks for CopilotKit runtime request processing.\n *\n * Hooks let you intercept requests at various stages of the pipeline:\n * - `onRequest`: Before routing — auth, correlation IDs, header injection\n * - `onBeforeHandler`: After routing — route-specific authorization\n * - `onResponse`: After handler — add headers, log, set cookies\n * - `onError`: On error — custom error responses\n *\n * @example\n * ```typescript\n * const handler = createCopilotRuntimeHandler({\n * runtime,\n * hooks: {\n * onRequest: async ({ request }) => {\n * const token = request.headers.get(\"authorization\");\n * if (!token) throw new Response(\"Unauthorized\", { status: 401 });\n * },\n * onResponse: async ({ response }) => {\n * const headers = new Headers(response.headers);\n * headers.set(\"x-copilot-version\", \"2.0\");\n * return new Response(response.body, { ...response, headers });\n * },\n * },\n * });\n * ```\n */\n\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"./runtime\";\n\n/* ------------------------------------------------------------------------------------------------\n * Route info\n * --------------------------------------------------------------------------------------------- */\n\nexport type RouteInfo =\n | { method: \"agent/run\"; agentId: string }\n | { method: \"agent/suggest\"; agentId: string }\n | { method: \"agent/connect\"; agentId: string }\n | { method: \"trajectory/connect\"; trajectoryId: string }\n | { method: \"agent/stop\"; agentId: string; threadId: string }\n | { method: \"info\" }\n | { method: \"inspector/metadata\" }\n | { method: \"inspector/learning\" }\n | { method: \"transcribe\" }\n | { method: \"threads/list\" }\n | { method: \"threads/subscribe\" }\n | { method: \"threads/update\"; threadId: string }\n | { method: \"threads/archive\"; threadId: string }\n | { method: \"threads/messages\"; threadId: string }\n | { method: \"threads/events\"; threadId: string }\n | { method: \"threads/state\"; threadId: string }\n | { method: \"threads/clear\" }\n | { method: \"memories/list\" }\n | { method: \"memories/recall\" }\n | { method: \"memories/subscribe\" }\n | { method: \"memories/mutate\"; memoryId: string }\n | { method: \"annotate\" }\n | { method: \"cpk-debug-events\" };\n\n/* ------------------------------------------------------------------------------------------------\n * Hook contexts\n * --------------------------------------------------------------------------------------------- */\n\nexport interface HookContext {\n /** The incoming Fetch Request (possibly modified by prior hooks). */\n request: Request;\n /** The resolved URL pathname. */\n path: string;\n /** The CopilotRuntimeLike instance. */\n runtime: CopilotRuntimeLike;\n}\n\nexport interface HandlerHookContext extends HookContext {\n /** The resolved route information. */\n route: RouteInfo;\n}\n\nexport interface ResponseHookContext extends HookContext {\n /** The Response produced by the handler. */\n response: Response;\n /** The resolved route information. */\n route: RouteInfo;\n}\n\nexport interface ErrorHookContext extends HookContext {\n /** The error that occurred. */\n error: unknown;\n /** The route info, if routing had already succeeded. */\n route?: RouteInfo;\n}\n\n/* ------------------------------------------------------------------------------------------------\n * Hooks interface\n * --------------------------------------------------------------------------------------------- */\n\nexport interface CopilotRuntimeHooks {\n /**\n * Called at the start of every request, before routing.\n * Use to validate auth, attach headers, initialize correlation IDs, etc.\n *\n * Return a modified Request to replace the original, or void to continue.\n * Throw a Response to short-circuit with an early response.\n */\n onRequest?: (ctx: HookContext) => MaybePromise<Request | void>;\n\n /**\n * Called after routing is resolved but before the handler executes.\n * Receives the resolved route info (method, agentId, threadId).\n *\n * Use to do route-specific authorization, attach headers for agent calls, etc.\n * Return a modified Request or void.\n * Throw a Response to short-circuit.\n */\n onBeforeHandler?: (ctx: HandlerHookContext) => MaybePromise<Request | void>;\n\n /**\n * Called after the handler produces a Response, before it's sent to the client.\n * Use to set cookies, add debugging headers, log, etc.\n *\n * Return a modified Response to replace the original, or void.\n */\n onResponse?: (ctx: ResponseHookContext) => MaybePromise<Response | void>;\n\n /**\n * Called when an error occurs during request processing.\n * Return a Response to override the default error response, or void to use the default.\n */\n onError?: (ctx: ErrorHookContext) => MaybePromise<Response | void>;\n}\n\n/* ------------------------------------------------------------------------------------------------\n * Internal hook runners\n * --------------------------------------------------------------------------------------------- */\n\nexport async function runOnRequest(\n hooks: CopilotRuntimeHooks | undefined,\n ctx: HookContext,\n): Promise<Request> {\n if (!hooks?.onRequest) return ctx.request;\n const result = await hooks.onRequest(ctx);\n return result instanceof Request ? result : ctx.request;\n}\n\nexport async function runOnBeforeHandler(\n hooks: CopilotRuntimeHooks | undefined,\n ctx: HandlerHookContext,\n): Promise<Request> {\n if (!hooks?.onBeforeHandler) return ctx.request;\n const result = await hooks.onBeforeHandler(ctx);\n return result instanceof Request ? result : ctx.request;\n}\n\nexport async function runOnResponse(\n hooks: CopilotRuntimeHooks | undefined,\n ctx: ResponseHookContext,\n): Promise<Response> {\n if (!hooks?.onResponse) return ctx.response;\n const result = await hooks.onResponse(ctx);\n return result instanceof Response ? result : ctx.response;\n}\n\nexport async function runOnError(\n hooks: CopilotRuntimeHooks | undefined,\n ctx: ErrorHookContext,\n): Promise<Response | void> {\n if (!hooks?.onError) return;\n return hooks.onError(ctx);\n}\n"],"mappings":";AAuIA,eAAsB,aACpB,OACA,KACkB;AAClB,KAAI,CAAC,OAAO,UAAW,QAAO,IAAI;CAClC,MAAM,SAAS,MAAM,MAAM,UAAU,IAAI;AACzC,QAAO,kBAAkB,UAAU,SAAS,IAAI;;AAGlD,eAAsB,mBACpB,OACA,KACkB;AAClB,KAAI,CAAC,OAAO,gBAAiB,QAAO,IAAI;CACxC,MAAM,SAAS,MAAM,MAAM,gBAAgB,IAAI;AAC/C,QAAO,kBAAkB,UAAU,SAAS,IAAI;;AAGlD,eAAsB,cACpB,OACA,KACmB;AACnB,KAAI,CAAC,OAAO,WAAY,QAAO,IAAI;CACnC,MAAM,SAAS,MAAM,MAAM,WAAW,IAAI;AAC1C,QAAO,kBAAkB,WAAW,SAAS,IAAI;;AAGnD,eAAsB,WACpB,OACA,KAC0B;AAC1B,KAAI,CAAC,OAAO,QAAS;AACrB,QAAO,MAAM,QAAQ,IAAI"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/runtime/core/learning.ts
|
|
3
|
+
/** Checks configuration without invoking a selector that requires a real run. */
|
|
4
|
+
function hasLearningContainerConfiguration(runtime) {
|
|
5
|
+
return runtime.intelligence?.ɵgetLearningContainerId?.() !== void 0 || runtime.learning?.containerId !== void 0;
|
|
6
|
+
}
|
|
7
|
+
/** Resolves bounded, validated Space IDs selected by application server code. */
|
|
8
|
+
async function resolveTrajectoryLearningContainerIds(selector, input, signal) {
|
|
9
|
+
signal?.throwIfAborted();
|
|
10
|
+
if (!selector) return void 0;
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const onAbort = () => controller.abort(signal?.reason);
|
|
13
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
14
|
+
const timeout = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Trajectory Learning Container selection timed out")), 5e3);
|
|
15
|
+
let onCancelled;
|
|
16
|
+
try {
|
|
17
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
18
|
+
onCancelled = () => reject(controller.signal.reason);
|
|
19
|
+
controller.signal.addEventListener("abort", onCancelled, { once: true });
|
|
20
|
+
});
|
|
21
|
+
const selection = new Promise((resolve) => {
|
|
22
|
+
resolve(selector(input, controller.signal));
|
|
23
|
+
});
|
|
24
|
+
const value = await Promise.race([selection, cancelled]);
|
|
25
|
+
controller.signal.throwIfAborted();
|
|
26
|
+
if (value == null) return void 0;
|
|
27
|
+
if (!Array.isArray(value) || value.length > 100) throw new Error("Trajectory Learning Container selection must be an array of at most 100 IDs");
|
|
28
|
+
return [...new Set(Array.from(value, assertStableLearningContainerId))];
|
|
29
|
+
} finally {
|
|
30
|
+
clearTimeout(timeout);
|
|
31
|
+
signal?.removeEventListener("abort", onAbort);
|
|
32
|
+
if (onCancelled) controller.signal.removeEventListener("abort", onCancelled);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const STABLE_CONTAINER_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
36
|
+
/** Validates and returns a stable Learning Container ID. */
|
|
37
|
+
function assertStableLearningContainerId(value) {
|
|
38
|
+
if (typeof value !== "string" || value.length < 1 || value.length > 64 || !STABLE_CONTAINER_ID.test(value)) throw new Error("Learning Container must use a 1-64 character stable ID with lowercase letters, numbers, and single hyphens");
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
/** Resolves and validates a public Intelligence Learning Container selection. */
|
|
42
|
+
async function resolveLearningContainerSelector(selector, input) {
|
|
43
|
+
const value = await selector(input);
|
|
44
|
+
if (value == null) return void 0;
|
|
45
|
+
return assertStableLearningContainerId(value);
|
|
46
|
+
}
|
|
47
|
+
/** Resolves the configured Container once for one web or Channel run. */
|
|
48
|
+
async function resolveLearningContainerId(config, input) {
|
|
49
|
+
if (config === void 0) return void 0;
|
|
50
|
+
const value = typeof config.containerId === "function" ? await config.containerId(input) : config.containerId;
|
|
51
|
+
if (value == null) return void 0;
|
|
52
|
+
return assertStableLearningContainerId(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.assertStableLearningContainerId = assertStableLearningContainerId;
|
|
57
|
+
exports.hasLearningContainerConfiguration = hasLearningContainerConfiguration;
|
|
58
|
+
exports.resolveLearningContainerId = resolveLearningContainerId;
|
|
59
|
+
exports.resolveLearningContainerSelector = resolveLearningContainerSelector;
|
|
60
|
+
exports.resolveTrajectoryLearningContainerIds = resolveTrajectoryLearningContainerIds;
|
|
61
|
+
//# sourceMappingURL=learning.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning.cjs","names":[],"sources":["../../../src/runtime/core/learning.ts"],"sourcesContent":["import type { RunAgentInput } from \"@ag-ui/client\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"./runtime\";\n\n/** Checks configuration without invoking a selector that requires a real run. */\nexport function hasLearningContainerConfiguration(\n runtime: CopilotRuntimeLike,\n): boolean {\n return (\n runtime.intelligence?.ɵgetLearningContainerId?.() !== undefined ||\n runtime.learning?.containerId !== undefined\n );\n}\n\n/** Application user resolved by an Intelligence runtime. */\nexport interface CopilotRuntimeUser {\n readonly id: string;\n readonly name: string;\n}\n\n/** Context for choosing a Learning Container through the public Intelligence SDK. */\nexport type LearningContainerSelectorInput =\n | {\n readonly surface: \"web\";\n readonly user: CopilotRuntimeUser;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n }\n | {\n readonly surface: \"channel\";\n readonly user: CopilotRuntimeUser | null;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n };\n\n/** Chooses one developer-created Learning Container for an Intelligence run. */\nexport type GetLearningContainerId = (\n input: LearningContainerSelectorInput,\n) => MaybePromise<string | null | undefined>;\n\n/**\n * Context for assigning browser activity to Learning Spaces. The Runtime\n * verifies `user`; the browser chooses `trajectoryId`, which is only checked\n * to be a UUID.\n */\nexport interface TrajectoryLearningContainerSelectorInput {\n readonly trajectoryId: string;\n readonly user: CopilotRuntimeUser;\n}\n\n/**\n * Selects existing Learning Spaces without requiring an agent run or Thread.\n * The optional signal cancels on request abort or the five-second deadline.\n */\nexport type GetTrajectoryLearningContainerIds = (\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n) => MaybePromise<readonly string[] | null | undefined>;\n\n/** Resolves bounded, validated Space IDs selected by application server code. */\nexport async function resolveTrajectoryLearningContainerIds(\n selector: GetTrajectoryLearningContainerIds | undefined,\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n): Promise<readonly string[] | undefined> {\n signal?.throwIfAborted();\n if (!selector) return undefined;\n const controller = new AbortController();\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n const timeout = setTimeout(\n () =>\n controller.abort(\n new Error(\"Trajectory Learning Container selection timed out\"),\n ),\n 5_000,\n );\n let onCancelled: (() => void) | undefined;\n try {\n const cancelled = new Promise<never>((_resolve, reject) => {\n onCancelled = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onCancelled, { once: true });\n });\n const selection = new Promise<readonly string[] | null | undefined>(\n (resolve) => {\n resolve(selector(input, controller.signal));\n },\n );\n const value = await Promise.race([selection, cancelled]);\n controller.signal.throwIfAborted();\n if (value == null) return undefined;\n if (!Array.isArray(value) || value.length > 100) {\n throw new Error(\n \"Trajectory Learning Container selection must be an array of at most 100 IDs\",\n );\n }\n // Array.from visits holes in sparse arrays, so they fail validation.\n return [...new Set(Array.from(value, assertStableLearningContainerId))];\n } finally {\n clearTimeout(timeout);\n signal?.removeEventListener(\"abort\", onAbort);\n if (onCancelled)\n controller.signal.removeEventListener(\"abort\", onCancelled);\n }\n}\n\n/** Context for choosing one Learning Container for an Intelligence run. */\nexport type CopilotRuntimeLearningContext =\n | {\n readonly surface: \"web\";\n readonly request: Request;\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n }\n | {\n readonly surface: \"channel\";\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n readonly deliveryId: string;\n };\n\n/** Assigns each Intelligence Thread to one developer-created Learning Container. */\nexport interface CopilotRuntimeLearningConfig {\n readonly containerId:\n | string\n | ((\n input: CopilotRuntimeLearningContext,\n ) => MaybePromise<string | null | undefined>);\n}\n\nconst STABLE_CONTAINER_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** Validates and returns a stable Learning Container ID. */\nexport function assertStableLearningContainerId(value: unknown): string {\n if (\n typeof value !== \"string\" ||\n value.length < 1 ||\n value.length > 64 ||\n !STABLE_CONTAINER_ID.test(value)\n ) {\n throw new Error(\n \"Learning Container must use a 1-64 character stable ID with lowercase letters, numbers, and single hyphens\",\n );\n }\n return value;\n}\n\n/** Resolves and validates a public Intelligence Learning Container selection. */\nexport async function resolveLearningContainerSelector(\n selector: GetLearningContainerId,\n input: LearningContainerSelectorInput,\n): Promise<string | undefined> {\n const value = await selector(input);\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n\n/** Resolves the configured Container once for one web or Channel run. */\nexport async function resolveLearningContainerId(\n config: CopilotRuntimeLearningConfig | undefined,\n input: CopilotRuntimeLearningContext,\n): Promise<string | undefined> {\n if (config === undefined) return undefined;\n const value =\n typeof config.containerId === \"function\"\n ? await config.containerId(input)\n : config.containerId;\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n"],"mappings":";;;AAKA,SAAgB,kCACd,SACS;AACT,QACE,QAAQ,cAAc,2BAA2B,KAAK,UACtD,QAAQ,UAAU,gBAAgB;;;AAkDtC,eAAsB,sCACpB,UACA,OACA,QACwC;AACxC,SAAQ,gBAAgB;AACxB,KAAI,CAAC,SAAU,QAAO;CACtB,MAAM,aAAa,IAAI,iBAAiB;CACxC,MAAM,gBAAgB,WAAW,MAAM,QAAQ,OAAO;AACtD,SAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;CAC1D,MAAM,UAAU,iBAEZ,WAAW,sBACT,IAAI,MAAM,oDAAoD,CAC/D,EACH,IACD;CACD,IAAI;AACJ,KAAI;EACF,MAAM,YAAY,IAAI,SAAgB,UAAU,WAAW;AACzD,uBAAoB,OAAO,WAAW,OAAO,OAAO;AACpD,cAAW,OAAO,iBAAiB,SAAS,aAAa,EAAE,MAAM,MAAM,CAAC;IACxE;EACF,MAAM,YAAY,IAAI,SACnB,YAAY;AACX,WAAQ,SAAS,OAAO,WAAW,OAAO,CAAC;IAE9C;EACD,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC,WAAW,UAAU,CAAC;AACxD,aAAW,OAAO,gBAAgB;AAClC,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,IAC1C,OAAM,IAAI,MACR,8EACD;AAGH,SAAO,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,OAAO,gCAAgC,CAAC,CAAC;WAC/D;AACR,eAAa,QAAQ;AACrB,UAAQ,oBAAoB,SAAS,QAAQ;AAC7C,MAAI,YACF,YAAW,OAAO,oBAAoB,SAAS,YAAY;;;AAgCjE,MAAM,sBAAsB;;AAG5B,SAAgB,gCAAgC,OAAwB;AACtE,KACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,SAAS,MACf,CAAC,oBAAoB,KAAK,MAAM,CAEhC,OAAM,IAAI,MACR,6GACD;AAEH,QAAO;;;AAIT,eAAsB,iCACpB,UACA,OAC6B;CAC7B,MAAM,QAAQ,MAAM,SAAS,MAAM;AACnC,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM;;;AAI/C,eAAsB,2BACpB,QACA,OAC6B;AAC7B,KAAI,WAAW,OAAW,QAAO;CACjC,MAAM,QACJ,OAAO,OAAO,gBAAgB,aAC1B,MAAM,OAAO,YAAY,MAAM,GAC/B,OAAO;AACb,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import "./runtime.cjs";
|
|
2
|
+
import { MaybePromise } from "@copilotkit/shared";
|
|
3
|
+
import { RunAgentInput } from "@ag-ui/client";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/core/learning.d.ts
|
|
6
|
+
/** Application user resolved by an Intelligence runtime. */
|
|
7
|
+
interface CopilotRuntimeUser {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
/** Context for choosing a Learning Container through the public Intelligence SDK. */
|
|
12
|
+
type LearningContainerSelectorInput = {
|
|
13
|
+
readonly surface: "web";
|
|
14
|
+
readonly user: CopilotRuntimeUser;
|
|
15
|
+
readonly agentId: string;
|
|
16
|
+
readonly input: Readonly<RunAgentInput>;
|
|
17
|
+
} | {
|
|
18
|
+
readonly surface: "channel";
|
|
19
|
+
readonly user: CopilotRuntimeUser | null;
|
|
20
|
+
readonly agentId: string;
|
|
21
|
+
readonly input: Readonly<RunAgentInput>;
|
|
22
|
+
};
|
|
23
|
+
/** Chooses one developer-created Learning Container for an Intelligence run. */
|
|
24
|
+
type GetLearningContainerId = (input: LearningContainerSelectorInput) => MaybePromise<string | null | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Context for assigning browser activity to Learning Spaces. The Runtime
|
|
27
|
+
* verifies `user`; the browser chooses `trajectoryId`, which is only checked
|
|
28
|
+
* to be a UUID.
|
|
29
|
+
*/
|
|
30
|
+
interface TrajectoryLearningContainerSelectorInput {
|
|
31
|
+
readonly trajectoryId: string;
|
|
32
|
+
readonly user: CopilotRuntimeUser;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Selects existing Learning Spaces without requiring an agent run or Thread.
|
|
36
|
+
* The optional signal cancels on request abort or the five-second deadline.
|
|
37
|
+
*/
|
|
38
|
+
type GetTrajectoryLearningContainerIds = (input: TrajectoryLearningContainerSelectorInput, signal?: AbortSignal) => MaybePromise<readonly string[] | null | undefined>;
|
|
39
|
+
/** Context for choosing one Learning Container for an Intelligence run. */
|
|
40
|
+
type CopilotRuntimeLearningContext = {
|
|
41
|
+
readonly surface: "web";
|
|
42
|
+
readonly request: Request;
|
|
43
|
+
readonly threadId: string;
|
|
44
|
+
readonly runId: string;
|
|
45
|
+
readonly agentId: string;
|
|
46
|
+
readonly userId: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly surface: "channel";
|
|
49
|
+
readonly threadId: string;
|
|
50
|
+
readonly runId: string;
|
|
51
|
+
readonly agentId: string;
|
|
52
|
+
readonly userId: string;
|
|
53
|
+
readonly deliveryId: string;
|
|
54
|
+
};
|
|
55
|
+
/** Assigns each Intelligence Thread to one developer-created Learning Container. */
|
|
56
|
+
interface CopilotRuntimeLearningConfig {
|
|
57
|
+
readonly containerId: string | ((input: CopilotRuntimeLearningContext) => MaybePromise<string | null | undefined>);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeUser, GetLearningContainerId, GetTrajectoryLearningContainerIds, LearningContainerSelectorInput, TrajectoryLearningContainerSelectorInput };
|
|
61
|
+
//# sourceMappingURL=learning.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning.d.cts","names":[],"sources":["../../../src/runtime/core/learning.ts"],"mappings":";;;;;AAeA;AAAA,UAAiB,kBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;AAAA;AAIX;AAAA,KAAY,8BAAA;EAAA,SAEG,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;EAAA,SAGhB,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;;KAInB,sBAAA,IACV,KAAA,EAAO,8BAAA,KACJ,YAAA;;;;;;UAOY,wCAAA;EAAA,SACN,YAAA;EAAA,SACA,IAAA,EAAM,kBAAA;AAAA;;;;;KAOL,iCAAA,IACV,KAAA,EAAO,wCAAA,EACP,MAAA,GAAS,WAAA,KACN,YAAA;;KAkDO,6BAAA;EAAA,SAEG,OAAA;EAAA,SACA,OAAA,EAAS,OAAA;EAAA,SACT,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;AAAA;;UAIE,4BAAA;EAAA,SACN,WAAA,aAGH,KAAA,EAAO,6BAAA,KACJ,YAAA;AAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import "./runtime.mjs";
|
|
2
|
+
import { MaybePromise } from "@copilotkit/shared";
|
|
3
|
+
import { RunAgentInput } from "@ag-ui/client";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/core/learning.d.ts
|
|
6
|
+
/** Application user resolved by an Intelligence runtime. */
|
|
7
|
+
interface CopilotRuntimeUser {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
/** Context for choosing a Learning Container through the public Intelligence SDK. */
|
|
12
|
+
type LearningContainerSelectorInput = {
|
|
13
|
+
readonly surface: "web";
|
|
14
|
+
readonly user: CopilotRuntimeUser;
|
|
15
|
+
readonly agentId: string;
|
|
16
|
+
readonly input: Readonly<RunAgentInput>;
|
|
17
|
+
} | {
|
|
18
|
+
readonly surface: "channel";
|
|
19
|
+
readonly user: CopilotRuntimeUser | null;
|
|
20
|
+
readonly agentId: string;
|
|
21
|
+
readonly input: Readonly<RunAgentInput>;
|
|
22
|
+
};
|
|
23
|
+
/** Chooses one developer-created Learning Container for an Intelligence run. */
|
|
24
|
+
type GetLearningContainerId = (input: LearningContainerSelectorInput) => MaybePromise<string | null | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Context for assigning browser activity to Learning Spaces. The Runtime
|
|
27
|
+
* verifies `user`; the browser chooses `trajectoryId`, which is only checked
|
|
28
|
+
* to be a UUID.
|
|
29
|
+
*/
|
|
30
|
+
interface TrajectoryLearningContainerSelectorInput {
|
|
31
|
+
readonly trajectoryId: string;
|
|
32
|
+
readonly user: CopilotRuntimeUser;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Selects existing Learning Spaces without requiring an agent run or Thread.
|
|
36
|
+
* The optional signal cancels on request abort or the five-second deadline.
|
|
37
|
+
*/
|
|
38
|
+
type GetTrajectoryLearningContainerIds = (input: TrajectoryLearningContainerSelectorInput, signal?: AbortSignal) => MaybePromise<readonly string[] | null | undefined>;
|
|
39
|
+
/** Context for choosing one Learning Container for an Intelligence run. */
|
|
40
|
+
type CopilotRuntimeLearningContext = {
|
|
41
|
+
readonly surface: "web";
|
|
42
|
+
readonly request: Request;
|
|
43
|
+
readonly threadId: string;
|
|
44
|
+
readonly runId: string;
|
|
45
|
+
readonly agentId: string;
|
|
46
|
+
readonly userId: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly surface: "channel";
|
|
49
|
+
readonly threadId: string;
|
|
50
|
+
readonly runId: string;
|
|
51
|
+
readonly agentId: string;
|
|
52
|
+
readonly userId: string;
|
|
53
|
+
readonly deliveryId: string;
|
|
54
|
+
};
|
|
55
|
+
/** Assigns each Intelligence Thread to one developer-created Learning Container. */
|
|
56
|
+
interface CopilotRuntimeLearningConfig {
|
|
57
|
+
readonly containerId: string | ((input: CopilotRuntimeLearningContext) => MaybePromise<string | null | undefined>);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeUser, GetLearningContainerId, GetTrajectoryLearningContainerIds, LearningContainerSelectorInput, TrajectoryLearningContainerSelectorInput };
|
|
61
|
+
//# sourceMappingURL=learning.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning.d.mts","names":[],"sources":["../../../src/runtime/core/learning.ts"],"mappings":";;;;;AAeA;AAAA,UAAiB,kBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;AAAA;AAIX;AAAA,KAAY,8BAAA;EAAA,SAEG,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;EAAA,SAGhB,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;;KAInB,sBAAA,IACV,KAAA,EAAO,8BAAA,KACJ,YAAA;;;;;;UAOY,wCAAA;EAAA,SACN,YAAA;EAAA,SACA,IAAA,EAAM,kBAAA;AAAA;;;;;KAOL,iCAAA,IACV,KAAA,EAAO,wCAAA,EACP,MAAA,GAAS,WAAA,KACN,YAAA;;KAkDO,6BAAA;EAAA,SAEG,OAAA;EAAA,SACA,OAAA,EAAS,OAAA;EAAA,SACT,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;AAAA;;UAIE,4BAAA;EAAA,SACN,WAAA,aAGH,KAAA,EAAO,6BAAA,KACJ,YAAA;AAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/runtime/core/learning.ts
|
|
2
|
+
/** Checks configuration without invoking a selector that requires a real run. */
|
|
3
|
+
function hasLearningContainerConfiguration(runtime) {
|
|
4
|
+
return runtime.intelligence?.ɵgetLearningContainerId?.() !== void 0 || runtime.learning?.containerId !== void 0;
|
|
5
|
+
}
|
|
6
|
+
/** Resolves bounded, validated Space IDs selected by application server code. */
|
|
7
|
+
async function resolveTrajectoryLearningContainerIds(selector, input, signal) {
|
|
8
|
+
signal?.throwIfAborted();
|
|
9
|
+
if (!selector) return void 0;
|
|
10
|
+
const controller = new AbortController();
|
|
11
|
+
const onAbort = () => controller.abort(signal?.reason);
|
|
12
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
13
|
+
const timeout = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Trajectory Learning Container selection timed out")), 5e3);
|
|
14
|
+
let onCancelled;
|
|
15
|
+
try {
|
|
16
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
17
|
+
onCancelled = () => reject(controller.signal.reason);
|
|
18
|
+
controller.signal.addEventListener("abort", onCancelled, { once: true });
|
|
19
|
+
});
|
|
20
|
+
const selection = new Promise((resolve) => {
|
|
21
|
+
resolve(selector(input, controller.signal));
|
|
22
|
+
});
|
|
23
|
+
const value = await Promise.race([selection, cancelled]);
|
|
24
|
+
controller.signal.throwIfAborted();
|
|
25
|
+
if (value == null) return void 0;
|
|
26
|
+
if (!Array.isArray(value) || value.length > 100) throw new Error("Trajectory Learning Container selection must be an array of at most 100 IDs");
|
|
27
|
+
return [...new Set(Array.from(value, assertStableLearningContainerId))];
|
|
28
|
+
} finally {
|
|
29
|
+
clearTimeout(timeout);
|
|
30
|
+
signal?.removeEventListener("abort", onAbort);
|
|
31
|
+
if (onCancelled) controller.signal.removeEventListener("abort", onCancelled);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const STABLE_CONTAINER_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
35
|
+
/** Validates and returns a stable Learning Container ID. */
|
|
36
|
+
function assertStableLearningContainerId(value) {
|
|
37
|
+
if (typeof value !== "string" || value.length < 1 || value.length > 64 || !STABLE_CONTAINER_ID.test(value)) throw new Error("Learning Container must use a 1-64 character stable ID with lowercase letters, numbers, and single hyphens");
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
/** Resolves and validates a public Intelligence Learning Container selection. */
|
|
41
|
+
async function resolveLearningContainerSelector(selector, input) {
|
|
42
|
+
const value = await selector(input);
|
|
43
|
+
if (value == null) return void 0;
|
|
44
|
+
return assertStableLearningContainerId(value);
|
|
45
|
+
}
|
|
46
|
+
/** Resolves the configured Container once for one web or Channel run. */
|
|
47
|
+
async function resolveLearningContainerId(config, input) {
|
|
48
|
+
if (config === void 0) return void 0;
|
|
49
|
+
const value = typeof config.containerId === "function" ? await config.containerId(input) : config.containerId;
|
|
50
|
+
if (value == null) return void 0;
|
|
51
|
+
return assertStableLearningContainerId(value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { assertStableLearningContainerId, hasLearningContainerConfiguration, resolveLearningContainerId, resolveLearningContainerSelector, resolveTrajectoryLearningContainerIds };
|
|
56
|
+
//# sourceMappingURL=learning.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning.mjs","names":[],"sources":["../../../src/runtime/core/learning.ts"],"sourcesContent":["import type { RunAgentInput } from \"@ag-ui/client\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"./runtime\";\n\n/** Checks configuration without invoking a selector that requires a real run. */\nexport function hasLearningContainerConfiguration(\n runtime: CopilotRuntimeLike,\n): boolean {\n return (\n runtime.intelligence?.ɵgetLearningContainerId?.() !== undefined ||\n runtime.learning?.containerId !== undefined\n );\n}\n\n/** Application user resolved by an Intelligence runtime. */\nexport interface CopilotRuntimeUser {\n readonly id: string;\n readonly name: string;\n}\n\n/** Context for choosing a Learning Container through the public Intelligence SDK. */\nexport type LearningContainerSelectorInput =\n | {\n readonly surface: \"web\";\n readonly user: CopilotRuntimeUser;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n }\n | {\n readonly surface: \"channel\";\n readonly user: CopilotRuntimeUser | null;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n };\n\n/** Chooses one developer-created Learning Container for an Intelligence run. */\nexport type GetLearningContainerId = (\n input: LearningContainerSelectorInput,\n) => MaybePromise<string | null | undefined>;\n\n/**\n * Context for assigning browser activity to Learning Spaces. The Runtime\n * verifies `user`; the browser chooses `trajectoryId`, which is only checked\n * to be a UUID.\n */\nexport interface TrajectoryLearningContainerSelectorInput {\n readonly trajectoryId: string;\n readonly user: CopilotRuntimeUser;\n}\n\n/**\n * Selects existing Learning Spaces without requiring an agent run or Thread.\n * The optional signal cancels on request abort or the five-second deadline.\n */\nexport type GetTrajectoryLearningContainerIds = (\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n) => MaybePromise<readonly string[] | null | undefined>;\n\n/** Resolves bounded, validated Space IDs selected by application server code. */\nexport async function resolveTrajectoryLearningContainerIds(\n selector: GetTrajectoryLearningContainerIds | undefined,\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n): Promise<readonly string[] | undefined> {\n signal?.throwIfAborted();\n if (!selector) return undefined;\n const controller = new AbortController();\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n const timeout = setTimeout(\n () =>\n controller.abort(\n new Error(\"Trajectory Learning Container selection timed out\"),\n ),\n 5_000,\n );\n let onCancelled: (() => void) | undefined;\n try {\n const cancelled = new Promise<never>((_resolve, reject) => {\n onCancelled = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onCancelled, { once: true });\n });\n const selection = new Promise<readonly string[] | null | undefined>(\n (resolve) => {\n resolve(selector(input, controller.signal));\n },\n );\n const value = await Promise.race([selection, cancelled]);\n controller.signal.throwIfAborted();\n if (value == null) return undefined;\n if (!Array.isArray(value) || value.length > 100) {\n throw new Error(\n \"Trajectory Learning Container selection must be an array of at most 100 IDs\",\n );\n }\n // Array.from visits holes in sparse arrays, so they fail validation.\n return [...new Set(Array.from(value, assertStableLearningContainerId))];\n } finally {\n clearTimeout(timeout);\n signal?.removeEventListener(\"abort\", onAbort);\n if (onCancelled)\n controller.signal.removeEventListener(\"abort\", onCancelled);\n }\n}\n\n/** Context for choosing one Learning Container for an Intelligence run. */\nexport type CopilotRuntimeLearningContext =\n | {\n readonly surface: \"web\";\n readonly request: Request;\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n }\n | {\n readonly surface: \"channel\";\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n readonly deliveryId: string;\n };\n\n/** Assigns each Intelligence Thread to one developer-created Learning Container. */\nexport interface CopilotRuntimeLearningConfig {\n readonly containerId:\n | string\n | ((\n input: CopilotRuntimeLearningContext,\n ) => MaybePromise<string | null | undefined>);\n}\n\nconst STABLE_CONTAINER_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** Validates and returns a stable Learning Container ID. */\nexport function assertStableLearningContainerId(value: unknown): string {\n if (\n typeof value !== \"string\" ||\n value.length < 1 ||\n value.length > 64 ||\n !STABLE_CONTAINER_ID.test(value)\n ) {\n throw new Error(\n \"Learning Container must use a 1-64 character stable ID with lowercase letters, numbers, and single hyphens\",\n );\n }\n return value;\n}\n\n/** Resolves and validates a public Intelligence Learning Container selection. */\nexport async function resolveLearningContainerSelector(\n selector: GetLearningContainerId,\n input: LearningContainerSelectorInput,\n): Promise<string | undefined> {\n const value = await selector(input);\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n\n/** Resolves the configured Container once for one web or Channel run. */\nexport async function resolveLearningContainerId(\n config: CopilotRuntimeLearningConfig | undefined,\n input: CopilotRuntimeLearningContext,\n): Promise<string | undefined> {\n if (config === undefined) return undefined;\n const value =\n typeof config.containerId === \"function\"\n ? await config.containerId(input)\n : config.containerId;\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n"],"mappings":";;AAKA,SAAgB,kCACd,SACS;AACT,QACE,QAAQ,cAAc,2BAA2B,KAAK,UACtD,QAAQ,UAAU,gBAAgB;;;AAkDtC,eAAsB,sCACpB,UACA,OACA,QACwC;AACxC,SAAQ,gBAAgB;AACxB,KAAI,CAAC,SAAU,QAAO;CACtB,MAAM,aAAa,IAAI,iBAAiB;CACxC,MAAM,gBAAgB,WAAW,MAAM,QAAQ,OAAO;AACtD,SAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;CAC1D,MAAM,UAAU,iBAEZ,WAAW,sBACT,IAAI,MAAM,oDAAoD,CAC/D,EACH,IACD;CACD,IAAI;AACJ,KAAI;EACF,MAAM,YAAY,IAAI,SAAgB,UAAU,WAAW;AACzD,uBAAoB,OAAO,WAAW,OAAO,OAAO;AACpD,cAAW,OAAO,iBAAiB,SAAS,aAAa,EAAE,MAAM,MAAM,CAAC;IACxE;EACF,MAAM,YAAY,IAAI,SACnB,YAAY;AACX,WAAQ,SAAS,OAAO,WAAW,OAAO,CAAC;IAE9C;EACD,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC,WAAW,UAAU,CAAC;AACxD,aAAW,OAAO,gBAAgB;AAClC,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,IAC1C,OAAM,IAAI,MACR,8EACD;AAGH,SAAO,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,OAAO,gCAAgC,CAAC,CAAC;WAC/D;AACR,eAAa,QAAQ;AACrB,UAAQ,oBAAoB,SAAS,QAAQ;AAC7C,MAAI,YACF,YAAW,OAAO,oBAAoB,SAAS,YAAY;;;AAgCjE,MAAM,sBAAsB;;AAG5B,SAAgB,gCAAgC,OAAwB;AACtE,KACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,SAAS,MACf,CAAC,oBAAoB,KAAK,MAAM,CAEhC,OAAM,IAAI,MACR,6GACD;AAEH,QAAO;;;AAIT,eAAsB,iCACpB,UACA,OAC6B;CAC7B,MAAM,QAAQ,MAAM,SAAS,MAAM;AACnC,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM;;;AAI/C,eAAsB,2BACpB,QACA,OAC6B;AAC7B,KAAI,WAAW,OAAW,QAAO;CACjC,MAAM,QACJ,OAAO,OAAO,gBAAgB,aAC1B,MAAM,OAAO,YAAY,MAAM,GAC/B,OAAO;AACb,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let pino = require("pino");
|
|
3
|
+
pino = require_runtime.__toESM(pino);
|
|
4
|
+
let pino_pretty = require("pino-pretty");
|
|
5
|
+
pino_pretty = require_runtime.__toESM(pino_pretty);
|
|
6
|
+
|
|
7
|
+
//#region src/runtime/core/logger.ts
|
|
8
|
+
function createLogger(options) {
|
|
9
|
+
const { level, component } = options || {};
|
|
10
|
+
const stream = (0, pino_pretty.default)({ colorize: true });
|
|
11
|
+
const logger = (0, pino.default)({
|
|
12
|
+
level: process.env.LOG_LEVEL || level || "error",
|
|
13
|
+
base: null
|
|
14
|
+
}, stream);
|
|
15
|
+
if (component) return logger.child({ component });
|
|
16
|
+
else return logger;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.createLogger = createLogger;
|
|
21
|
+
//# sourceMappingURL=logger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.cjs","names":[],"sources":["../../../src/runtime/core/logger.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CopilotRuntimeLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — createLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LogLevel:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport createPinoLogger from \"pino\";\nimport pretty from \"pino-pretty\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport type CopilotRuntimeLogger = ReturnType<typeof createLogger>;\n\nexport function createLogger(options?: {\n level?: LogLevel;\n component?: string;\n}) {\n const { level, component } = options || {};\n const stream = pretty({ colorize: true });\n\n const logger = createPinoLogger(\n {\n level: process.env.LOG_LEVEL || level || \"error\",\n // Drop `pid` and `hostname` with pino's own `base` switch rather than\n // with `redact`. pino 9 validates every redact path by calling\n // `Function(...)`, and edge runtimes such as Cloudflare Workers forbid\n // code generation from strings. That throws while the logger is being\n // built, and the validator reports the first path in the array, so the\n // failure surfaces as the misleading \"redact paths array contains an\n // invalid path (pid)\". `base: null` produces identical output and needs\n // no code generation. See issue #2355.\n base: null,\n },\n stream,\n );\n\n if (component) {\n return logger.child({ component });\n } else {\n return logger;\n }\n}\n"],"mappings":";;;;;;;AAqCA,SAAgB,aAAa,SAG1B;CACD,MAAM,EAAE,OAAO,cAAc,WAAW,EAAE;CAC1C,MAAM,kCAAgB,EAAE,UAAU,MAAM,CAAC;CAEzC,MAAM,2BACJ;EACE,OAAO,QAAQ,IAAI,aAAa,SAAS;EASzC,MAAM;EACP,EACD,OACD;AAED,KAAI,UACF,QAAO,OAAO,MAAM,EAAE,WAAW,CAAC;KAElC,QAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import createPinoLogger from "pino";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/core/logger.d.ts
|
|
4
|
+
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
5
|
+
type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
|
|
6
|
+
declare function createLogger(options?: {
|
|
7
|
+
level?: LogLevel;
|
|
8
|
+
component?: string;
|
|
9
|
+
}): createPinoLogger.Logger<never, boolean>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { CopilotRuntimeLogger };
|
|
12
|
+
//# sourceMappingURL=logger.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.cts","names":[],"sources":["../../../src/runtime/core/logger.ts"],"mappings":";;;KAiCY,QAAA;AAAA,KAEA,oBAAA,GAAuB,UAAA,QAAkB,YAAA;AAAA,iBAErC,YAAA,CAAa,OAAA;EAC3B,KAAA,GAAQ,QAAA;EACR,SAAA;AAAA,IACD,gBAAA,CAAA,MAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import createPinoLogger from "pino";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/core/logger.d.ts
|
|
4
|
+
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
5
|
+
type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
|
|
6
|
+
declare function createLogger(options?: {
|
|
7
|
+
level?: LogLevel;
|
|
8
|
+
component?: string;
|
|
9
|
+
}): createPinoLogger.Logger<never, boolean>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { CopilotRuntimeLogger };
|
|
12
|
+
//# sourceMappingURL=logger.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.mts","names":[],"sources":["../../../src/runtime/core/logger.ts"],"mappings":";;;KAiCY,QAAA;AAAA,KAEA,oBAAA,GAAuB,UAAA,QAAkB,YAAA;AAAA,iBAErC,YAAA,CAAa,OAAA;EAC3B,KAAA,GAAQ,QAAA;EACR,SAAA;AAAA,IACD,gBAAA,CAAA,MAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import createPinoLogger from "pino";
|
|
2
|
+
import pretty from "pino-pretty";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/core/logger.ts
|
|
5
|
+
function createLogger(options) {
|
|
6
|
+
const { level, component } = options || {};
|
|
7
|
+
const stream = pretty({ colorize: true });
|
|
8
|
+
const logger = createPinoLogger({
|
|
9
|
+
level: process.env.LOG_LEVEL || level || "error",
|
|
10
|
+
base: null
|
|
11
|
+
}, stream);
|
|
12
|
+
if (component) return logger.child({ component });
|
|
13
|
+
else return logger;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createLogger };
|
|
18
|
+
//# sourceMappingURL=logger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":[],"sources":["../../../src/runtime/core/logger.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CopilotRuntimeLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — createLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LogLevel:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport createPinoLogger from \"pino\";\nimport pretty from \"pino-pretty\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport type CopilotRuntimeLogger = ReturnType<typeof createLogger>;\n\nexport function createLogger(options?: {\n level?: LogLevel;\n component?: string;\n}) {\n const { level, component } = options || {};\n const stream = pretty({ colorize: true });\n\n const logger = createPinoLogger(\n {\n level: process.env.LOG_LEVEL || level || \"error\",\n // Drop `pid` and `hostname` with pino's own `base` switch rather than\n // with `redact`. pino 9 validates every redact path by calling\n // `Function(...)`, and edge runtimes such as Cloudflare Workers forbid\n // code generation from strings. That throws while the logger is being\n // built, and the validator reports the first path in the array, so the\n // failure surfaces as the misleading \"redact paths array contains an\n // invalid path (pid)\". `base: null` produces identical output and needs\n // no code generation. See issue #2355.\n base: null,\n },\n stream,\n );\n\n if (component) {\n return logger.child({ component });\n } else {\n return logger;\n }\n}\n"],"mappings":";;;;AAqCA,SAAgB,aAAa,SAG1B;CACD,MAAM,EAAE,OAAO,cAAc,WAAW,EAAE;CAC1C,MAAM,SAAS,OAAO,EAAE,UAAU,MAAM,CAAC;CAEzC,MAAM,SAAS,iBACb;EACE,OAAO,QAAQ,IAAI,aAAa,SAAS;EASzC,MAAM;EACP,EACD,OACD;AAED,KAAI,UACF,QAAO,OAAO,MAAM,EAAE,WAAW,CAAC;KAElC,QAAO"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let _copilotkit_shared = require("@copilotkit/shared");
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/core/middleware-sse-parser.ts
|
|
5
|
+
/**
|
|
6
|
+
* Parse a cloned SSE Response body into structured messages.
|
|
7
|
+
* Returns empty results for non-SSE responses.
|
|
8
|
+
*/
|
|
9
|
+
async function parseSSEResponse(response) {
|
|
10
|
+
if (!(response.headers.get("content-type") ?? "").includes("text/event-stream")) return { messages: [] };
|
|
11
|
+
let text;
|
|
12
|
+
try {
|
|
13
|
+
text = await response.text();
|
|
14
|
+
} catch {
|
|
15
|
+
_copilotkit_shared.logger.warn("Failed to read SSE response body in afterRequestMiddleware");
|
|
16
|
+
return { messages: [] };
|
|
17
|
+
}
|
|
18
|
+
if (!text.trim()) return { messages: [] };
|
|
19
|
+
let threadId;
|
|
20
|
+
let runId;
|
|
21
|
+
const messagesById = /* @__PURE__ */ new Map();
|
|
22
|
+
const toolCallsById = /* @__PURE__ */ new Map();
|
|
23
|
+
const toolCallParent = /* @__PURE__ */ new Map();
|
|
24
|
+
let snapshotMessages;
|
|
25
|
+
const linkToolCallParent = (toolCallId, parentMessageId) => {
|
|
26
|
+
const parent = parentMessageId ? messagesById.get(parentMessageId) : void 0;
|
|
27
|
+
const parentId = parentMessageId && (!parent || parent.role === "assistant") ? parentMessageId : toolCallId;
|
|
28
|
+
if (!messagesById.has(parentId)) messagesById.set(parentId, {
|
|
29
|
+
id: parentId,
|
|
30
|
+
role: "assistant"
|
|
31
|
+
});
|
|
32
|
+
toolCallParent.set(toolCallId, parentId);
|
|
33
|
+
};
|
|
34
|
+
for (const line of text.split("\n")) {
|
|
35
|
+
const trimmed = line.trim();
|
|
36
|
+
if (!trimmed.startsWith("data:")) continue;
|
|
37
|
+
let event;
|
|
38
|
+
try {
|
|
39
|
+
event = JSON.parse(trimmed.slice(5).trim());
|
|
40
|
+
} catch {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
switch (event.type) {
|
|
44
|
+
case "RUN_STARTED":
|
|
45
|
+
threadId = event.threadId;
|
|
46
|
+
runId = event.runId;
|
|
47
|
+
break;
|
|
48
|
+
case "MESSAGES_SNAPSHOT":
|
|
49
|
+
if (Array.isArray(event.messages)) snapshotMessages = event.messages;
|
|
50
|
+
break;
|
|
51
|
+
case "TEXT_MESSAGE_START":
|
|
52
|
+
messagesById.set(event.messageId, {
|
|
53
|
+
id: event.messageId,
|
|
54
|
+
role: event.role ?? "assistant",
|
|
55
|
+
content: ""
|
|
56
|
+
});
|
|
57
|
+
break;
|
|
58
|
+
case "TEXT_MESSAGE_CONTENT": {
|
|
59
|
+
const msg = messagesById.get(event.messageId);
|
|
60
|
+
if (msg) msg.content = (msg.content ?? "") + (event.delta ?? "");
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case "TEXT_MESSAGE_CHUNK":
|
|
64
|
+
if (event.messageId) {
|
|
65
|
+
const existing = messagesById.get(event.messageId);
|
|
66
|
+
if (existing) existing.content = (existing.content ?? "") + (event.delta ?? "");
|
|
67
|
+
else messagesById.set(event.messageId, {
|
|
68
|
+
id: event.messageId,
|
|
69
|
+
role: event.role ?? "assistant",
|
|
70
|
+
content: event.delta ?? ""
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case "TOOL_CALL_START": {
|
|
75
|
+
const tc = {
|
|
76
|
+
id: event.toolCallId,
|
|
77
|
+
name: event.toolCallName,
|
|
78
|
+
args: ""
|
|
79
|
+
};
|
|
80
|
+
toolCallsById.set(event.toolCallId, tc);
|
|
81
|
+
linkToolCallParent(event.toolCallId, event.parentMessageId);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "TOOL_CALL_ARGS": {
|
|
85
|
+
const tc = toolCallsById.get(event.toolCallId);
|
|
86
|
+
if (tc) tc.args += event.delta ?? "";
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case "TOOL_CALL_CHUNK":
|
|
90
|
+
if (event.toolCallId) {
|
|
91
|
+
let tc = toolCallsById.get(event.toolCallId);
|
|
92
|
+
if (!tc) {
|
|
93
|
+
tc = {
|
|
94
|
+
id: event.toolCallId,
|
|
95
|
+
name: event.toolCallName ?? "",
|
|
96
|
+
args: ""
|
|
97
|
+
};
|
|
98
|
+
toolCallsById.set(event.toolCallId, tc);
|
|
99
|
+
linkToolCallParent(event.toolCallId, event.parentMessageId);
|
|
100
|
+
}
|
|
101
|
+
if (event.toolCallName) tc.name = event.toolCallName;
|
|
102
|
+
tc.args += event.delta ?? "";
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
case "TOOL_CALL_END": {
|
|
106
|
+
const tc = toolCallsById.get(event.toolCallId);
|
|
107
|
+
const parentId = toolCallParent.get(event.toolCallId);
|
|
108
|
+
if (tc && parentId) {
|
|
109
|
+
const parent = messagesById.get(parentId);
|
|
110
|
+
if (parent) {
|
|
111
|
+
parent.toolCalls = parent.toolCalls ?? [];
|
|
112
|
+
parent.toolCalls.push(tc);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case "TOOL_CALL_RESULT": {
|
|
118
|
+
let resultContent = event.content;
|
|
119
|
+
if (Array.isArray(resultContent)) resultContent = resultContent.filter((part) => part && typeof part.text === "string").map((part) => part.text).join("");
|
|
120
|
+
messagesById.set(event.messageId, {
|
|
121
|
+
id: event.messageId,
|
|
122
|
+
role: "tool",
|
|
123
|
+
content: resultContent,
|
|
124
|
+
toolCallId: event.toolCallId
|
|
125
|
+
});
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (const [toolCallId, tc] of toolCallsById) {
|
|
131
|
+
const parentId = toolCallParent.get(toolCallId);
|
|
132
|
+
if (!parentId) continue;
|
|
133
|
+
const parent = messagesById.get(parentId);
|
|
134
|
+
if (!parent) continue;
|
|
135
|
+
if (!parent.toolCalls?.some((t) => t.id === tc.id)) {
|
|
136
|
+
parent.toolCalls = parent.toolCalls ?? [];
|
|
137
|
+
parent.toolCalls.push(tc);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
messages: snapshotMessages ?? [...messagesById.values()],
|
|
142
|
+
threadId,
|
|
143
|
+
runId
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
exports.parseSSEResponse = parseSSEResponse;
|
|
149
|
+
//# sourceMappingURL=middleware-sse-parser.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-sse-parser.cjs","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"sourcesContent":["import { logger } from \"@copilotkit/shared\";\n\nexport interface ParsedSSEResult {\n messages: Message[];\n threadId?: string;\n runId?: string;\n}\n\n/** Minimal message shape reconstructed from AG-UI events. */\nexport interface Message {\n id: string;\n role: string;\n content?: string;\n toolCalls?: ToolCall[];\n toolCallId?: string;\n}\n\ninterface ToolCall {\n id: string;\n name: string;\n args: string;\n}\n\n/**\n * Parse a cloned SSE Response body into structured messages.\n * Returns empty results for non-SSE responses.\n */\nexport async function parseSSEResponse(\n response: Response,\n): Promise<ParsedSSEResult> {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"text/event-stream\")) {\n return { messages: [] };\n }\n\n let text: string;\n try {\n text = await response.text();\n } catch {\n logger.warn(\"Failed to read SSE response body in afterRequestMiddleware\");\n return { messages: [] };\n }\n\n if (!text.trim()) {\n return { messages: [] };\n }\n\n let threadId: string | undefined;\n let runId: string | undefined;\n const messagesById = new Map<string, Message>();\n const toolCallsById = new Map<string, ToolCall>();\n const toolCallParent = new Map<string, string>(); // toolCallId → messageId\n let snapshotMessages: Message[] | undefined;\n\n // Link a tool call to its assistant message the way @ag-ui/client does. A\n // tool-only turn streams no TEXT_MESSAGE_START, so the parent may not exist\n // yet; create it, keyed by toolCallId when parentMessageId is missing or\n // names a non-assistant message.\n const linkToolCallParent = (toolCallId: string, parentMessageId?: string) => {\n const parent = parentMessageId\n ? messagesById.get(parentMessageId)\n : undefined;\n const parentId =\n parentMessageId && (!parent || parent.role === \"assistant\")\n ? parentMessageId\n : toolCallId;\n if (!messagesById.has(parentId)) {\n messagesById.set(parentId, { id: parentId, role: \"assistant\" });\n }\n toolCallParent.set(toolCallId, parentId);\n };\n\n for (const line of text.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"data:\")) continue;\n\n let event: Record<string, any>;\n try {\n event = JSON.parse(trimmed.slice(5).trim());\n } catch {\n continue;\n }\n\n switch (event.type) {\n case \"RUN_STARTED\":\n threadId = event.threadId;\n runId = event.runId;\n break;\n\n case \"MESSAGES_SNAPSHOT\":\n if (Array.isArray(event.messages)) {\n snapshotMessages = event.messages;\n }\n break;\n\n case \"TEXT_MESSAGE_START\":\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: \"\",\n });\n break;\n\n case \"TEXT_MESSAGE_CONTENT\": {\n const msg = messagesById.get(event.messageId);\n if (msg) {\n msg.content = (msg.content ?? \"\") + (event.delta ?? \"\");\n }\n break;\n }\n\n case \"TEXT_MESSAGE_CHUNK\": {\n // Chunk format: combined start+content. First chunk creates the\n // message, subsequent chunks append delta to content.\n if (event.messageId) {\n const existing = messagesById.get(event.messageId);\n if (existing) {\n existing.content = (existing.content ?? \"\") + (event.delta ?? \"\");\n } else {\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: event.delta ?? \"\",\n });\n }\n }\n break;\n }\n\n case \"TOOL_CALL_START\": {\n const tc: ToolCall = {\n id: event.toolCallId,\n name: event.toolCallName,\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n break;\n }\n\n case \"TOOL_CALL_ARGS\": {\n const tc = toolCallsById.get(event.toolCallId);\n if (tc) {\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_CHUNK\": {\n // Chunk format: combined start+args. First chunk for a given\n // toolCallId creates the tool call, subsequent chunks append delta.\n if (event.toolCallId) {\n let tc = toolCallsById.get(event.toolCallId);\n if (!tc) {\n tc = {\n id: event.toolCallId,\n name: event.toolCallName ?? \"\",\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n }\n if (event.toolCallName) {\n tc.name = event.toolCallName;\n }\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_END\": {\n const tc = toolCallsById.get(event.toolCallId);\n const parentId = toolCallParent.get(event.toolCallId);\n if (tc && parentId) {\n const parent = messagesById.get(parentId);\n if (parent) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n break;\n }\n\n case \"TOOL_CALL_RESULT\": {\n // langchain-mcp-adapters may send content as an array of\n // {type:\"text\", text:string} objects instead of a plain string.\n let resultContent = event.content;\n if (Array.isArray(resultContent)) {\n resultContent = resultContent\n .filter((part: any) => part && typeof part.text === \"string\")\n .map((part: any) => part.text)\n .join(\"\");\n }\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: \"tool\",\n content: resultContent,\n toolCallId: event.toolCallId,\n });\n break;\n }\n }\n }\n\n // Attach any tool calls not yet linked to their parent message.\n // This handles TOOL_CALL_CHUNK flows which don't emit TOOL_CALL_END.\n for (const [toolCallId, tc] of toolCallsById) {\n const parentId = toolCallParent.get(toolCallId);\n if (!parentId) continue;\n const parent = messagesById.get(parentId);\n if (!parent) continue;\n const alreadyAttached = parent.toolCalls?.some((t) => t.id === tc.id);\n if (!alreadyAttached) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n\n // Prefer MESSAGES_SNAPSHOT if present (contains full history).\n // Otherwise reconstruct from individual events.\n const messages = snapshotMessages ?? [...messagesById.values()];\n\n return { messages, threadId, runId };\n}\n"],"mappings":";;;;;;;;AA2BA,eAAsB,iBACpB,UAC0B;AAE1B,KAAI,EADgB,SAAS,QAAQ,IAAI,eAAe,IAAI,IAC3C,SAAS,oBAAoB,CAC5C,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;AACJ,KAAI;AACF,SAAO,MAAM,SAAS,MAAM;SACtB;AACN,4BAAO,KAAK,6DAA6D;AACzE,SAAO,EAAE,UAAU,EAAE,EAAE;;AAGzB,KAAI,CAAC,KAAK,MAAM,CACd,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;CACJ,IAAI;CACJ,MAAM,+BAAe,IAAI,KAAsB;CAC/C,MAAM,gCAAgB,IAAI,KAAuB;CACjD,MAAM,iCAAiB,IAAI,KAAqB;CAChD,IAAI;CAMJ,MAAM,sBAAsB,YAAoB,oBAA6B;EAC3E,MAAM,SAAS,kBACX,aAAa,IAAI,gBAAgB,GACjC;EACJ,MAAM,WACJ,oBAAoB,CAAC,UAAU,OAAO,SAAS,eAC3C,kBACA;AACN,MAAI,CAAC,aAAa,IAAI,SAAS,CAC7B,cAAa,IAAI,UAAU;GAAE,IAAI;GAAU,MAAM;GAAa,CAAC;AAEjE,iBAAe,IAAI,YAAY,SAAS;;AAG1C,MAAK,MAAM,QAAQ,KAAK,MAAM,KAAK,EAAE;EACnC,MAAM,UAAU,KAAK,MAAM;AAC3B,MAAI,CAAC,QAAQ,WAAW,QAAQ,CAAE;EAElC,IAAI;AACJ,MAAI;AACF,WAAQ,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,MAAM,CAAC;UACrC;AACN;;AAGF,UAAQ,MAAM,MAAd;GACE,KAAK;AACH,eAAW,MAAM;AACjB,YAAQ,MAAM;AACd;GAEF,KAAK;AACH,QAAI,MAAM,QAAQ,MAAM,SAAS,CAC/B,oBAAmB,MAAM;AAE3B;GAEF,KAAK;AACH,iBAAa,IAAI,MAAM,WAAW;KAChC,IAAI,MAAM;KACV,MAAM,MAAM,QAAQ;KACpB,SAAS;KACV,CAAC;AACF;GAEF,KAAK,wBAAwB;IAC3B,MAAM,MAAM,aAAa,IAAI,MAAM,UAAU;AAC7C,QAAI,IACF,KAAI,WAAW,IAAI,WAAW,OAAO,MAAM,SAAS;AAEtD;;GAGF,KAAK;AAGH,QAAI,MAAM,WAAW;KACnB,MAAM,WAAW,aAAa,IAAI,MAAM,UAAU;AAClD,SAAI,SACF,UAAS,WAAW,SAAS,WAAW,OAAO,MAAM,SAAS;SAE9D,cAAa,IAAI,MAAM,WAAW;MAChC,IAAI,MAAM;MACV,MAAM,MAAM,QAAQ;MACpB,SAAS,MAAM,SAAS;MACzB,CAAC;;AAGN;GAGF,KAAK,mBAAmB;IACtB,MAAM,KAAe;KACnB,IAAI,MAAM;KACV,MAAM,MAAM;KACZ,MAAM;KACP;AACD,kBAAc,IAAI,MAAM,YAAY,GAAG;AACvC,uBAAmB,MAAM,YAAY,MAAM,gBAAgB;AAC3D;;GAGF,KAAK,kBAAkB;IACrB,MAAM,KAAK,cAAc,IAAI,MAAM,WAAW;AAC9C,QAAI,GACF,IAAG,QAAQ,MAAM,SAAS;AAE5B;;GAGF,KAAK;AAGH,QAAI,MAAM,YAAY;KACpB,IAAI,KAAK,cAAc,IAAI,MAAM,WAAW;AAC5C,SAAI,CAAC,IAAI;AACP,WAAK;OACH,IAAI,MAAM;OACV,MAAM,MAAM,gBAAgB;OAC5B,MAAM;OACP;AACD,oBAAc,IAAI,MAAM,YAAY,GAAG;AACvC,yBAAmB,MAAM,YAAY,MAAM,gBAAgB;;AAE7D,SAAI,MAAM,aACR,IAAG,OAAO,MAAM;AAElB,QAAG,QAAQ,MAAM,SAAS;;AAE5B;GAGF,KAAK,iBAAiB;IACpB,MAAM,KAAK,cAAc,IAAI,MAAM,WAAW;IAC9C,MAAM,WAAW,eAAe,IAAI,MAAM,WAAW;AACrD,QAAI,MAAM,UAAU;KAClB,MAAM,SAAS,aAAa,IAAI,SAAS;AACzC,SAAI,QAAQ;AACV,aAAO,YAAY,OAAO,aAAa,EAAE;AACzC,aAAO,UAAU,KAAK,GAAG;;;AAG7B;;GAGF,KAAK,oBAAoB;IAGvB,IAAI,gBAAgB,MAAM;AAC1B,QAAI,MAAM,QAAQ,cAAc,CAC9B,iBAAgB,cACb,QAAQ,SAAc,QAAQ,OAAO,KAAK,SAAS,SAAS,CAC5D,KAAK,SAAc,KAAK,KAAK,CAC7B,KAAK,GAAG;AAEb,iBAAa,IAAI,MAAM,WAAW;KAChC,IAAI,MAAM;KACV,MAAM;KACN,SAAS;KACT,YAAY,MAAM;KACnB,CAAC;AACF;;;;AAON,MAAK,MAAM,CAAC,YAAY,OAAO,eAAe;EAC5C,MAAM,WAAW,eAAe,IAAI,WAAW;AAC/C,MAAI,CAAC,SAAU;EACf,MAAM,SAAS,aAAa,IAAI,SAAS;AACzC,MAAI,CAAC,OAAQ;AAEb,MAAI,CADoB,OAAO,WAAW,MAAM,MAAM,EAAE,OAAO,GAAG,GAAG,EAC/C;AACpB,UAAO,YAAY,OAAO,aAAa,EAAE;AACzC,UAAO,UAAU,KAAK,GAAG;;;AAQ7B,QAAO;EAAE,UAFQ,oBAAoB,CAAC,GAAG,aAAa,QAAQ,CAAC;EAE5C;EAAU;EAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/runtime/core/middleware-sse-parser.d.ts
|
|
2
|
+
/** Minimal message shape reconstructed from AG-UI events. */
|
|
3
|
+
interface Message {
|
|
4
|
+
id: string;
|
|
5
|
+
role: string;
|
|
6
|
+
content?: string;
|
|
7
|
+
toolCalls?: ToolCall[];
|
|
8
|
+
toolCallId?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ToolCall {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
args: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse a cloned SSE Response body into structured messages.
|
|
17
|
+
* Returns empty results for non-SSE responses.
|
|
18
|
+
*/
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Message };
|
|
21
|
+
//# sourceMappingURL=middleware-sse-parser.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-sse-parser.d.cts","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"mappings":";;UASiB,OAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA,GAAY,QAAA;EACZ,UAAA;AAAA;AAAA,UAGQ,QAAA;EACR,EAAA;EACA,IAAA;EACA,IAAA;AAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/runtime/core/middleware-sse-parser.d.ts
|
|
2
|
+
/** Minimal message shape reconstructed from AG-UI events. */
|
|
3
|
+
interface Message {
|
|
4
|
+
id: string;
|
|
5
|
+
role: string;
|
|
6
|
+
content?: string;
|
|
7
|
+
toolCalls?: ToolCall[];
|
|
8
|
+
toolCallId?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ToolCall {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
args: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse a cloned SSE Response body into structured messages.
|
|
17
|
+
* Returns empty results for non-SSE responses.
|
|
18
|
+
*/
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Message };
|
|
21
|
+
//# sourceMappingURL=middleware-sse-parser.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-sse-parser.d.mts","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"mappings":";;UASiB,OAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA,GAAY,QAAA;EACZ,UAAA;AAAA;AAAA,UAGQ,QAAA;EACR,EAAA;EACA,IAAA;EACA,IAAA;AAAA"}
|