@copilotkit/runtime 2.0.0-rc.6 → 2.0.0-rc.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -4
- package/dist/agent/{url-download.cjs → ai-sdk/url-download.cjs} +19 -76
- package/dist/agent/ai-sdk/url-download.cjs.map +1 -0
- package/dist/agent/{url-download.d.cts → ai-sdk/url-download.d.cts} +11 -8
- package/dist/agent/ai-sdk/url-download.d.cts.map +1 -0
- package/dist/agent/{url-download.d.mts → ai-sdk/url-download.d.mts} +11 -8
- package/dist/agent/ai-sdk/url-download.d.mts.map +1 -0
- package/dist/agent/{url-download.mjs → ai-sdk/url-download.mjs} +20 -74
- package/dist/agent/ai-sdk/url-download.mjs.map +1 -0
- package/dist/agent/ai-sdk.cjs +425 -0
- package/dist/agent/ai-sdk.cjs.map +1 -0
- package/dist/agent/ai-sdk.d.cts +119 -0
- package/dist/agent/ai-sdk.d.cts.map +1 -0
- package/dist/agent/ai-sdk.d.mts +119 -0
- package/dist/agent/ai-sdk.d.mts.map +1 -0
- package/dist/agent/ai-sdk.mjs +419 -0
- package/dist/agent/ai-sdk.mjs.map +1 -0
- package/dist/agent/classic-tools.cjs +185 -0
- package/dist/agent/classic-tools.cjs.map +1 -0
- package/dist/agent/classic-tools.mjs +183 -0
- package/dist/agent/classic-tools.mjs.map +1 -0
- package/dist/agent/converters/aisdk.cjs +17 -4
- package/dist/agent/converters/aisdk.cjs.map +1 -1
- package/dist/agent/converters/aisdk.d.cts.map +1 -1
- package/dist/agent/converters/aisdk.d.mts.map +1 -1
- package/dist/agent/converters/aisdk.mjs +18 -2
- package/dist/agent/converters/aisdk.mjs.map +1 -1
- package/dist/agent/converters/tanstack.cjs +202 -30
- package/dist/agent/converters/tanstack.cjs.map +1 -1
- package/dist/agent/converters/tanstack.d.cts +90 -6
- package/dist/agent/converters/tanstack.d.cts.map +1 -1
- package/dist/agent/converters/tanstack.d.mts +90 -6
- package/dist/agent/converters/tanstack.d.mts.map +1 -1
- package/dist/agent/converters/tanstack.mjs +202 -29
- package/dist/agent/converters/tanstack.mjs.map +1 -1
- package/dist/agent/learned-skills.cjs +15 -17
- package/dist/agent/learned-skills.cjs.map +1 -1
- package/dist/agent/learned-skills.d.cts +9 -3
- package/dist/agent/learned-skills.d.cts.map +1 -1
- package/dist/agent/learned-skills.d.mts +9 -3
- package/dist/agent/learned-skills.d.mts.map +1 -1
- package/dist/agent/learned-skills.mjs +15 -16
- package/dist/agent/learned-skills.mjs.map +1 -1
- package/dist/agent/model.cjs +42 -0
- package/dist/agent/model.cjs.map +1 -0
- package/dist/agent/model.d.cts +19 -0
- package/dist/agent/model.d.cts.map +1 -0
- package/dist/agent/model.d.mts +19 -0
- package/dist/agent/model.d.mts.map +1 -0
- package/dist/agent/model.mjs +41 -0
- package/dist/agent/model.mjs.map +1 -0
- package/dist/agent/state-delta.cjs +0 -1
- package/dist/agent/state-delta.cjs.map +1 -1
- package/dist/agent.cjs +558 -0
- package/dist/agent.cjs.map +1 -0
- package/dist/agent.d.cts +455 -0
- package/dist/agent.d.cts.map +1 -0
- package/dist/agent.d.mts +455 -0
- package/dist/agent.d.mts.map +1 -0
- package/dist/agent.mjs +551 -0
- package/dist/agent.mjs.map +1 -0
- package/dist/index.cjs +23 -28
- package/dist/index.d.cts +14 -14
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +8 -8
- package/dist/internal/learned-skills.d.cts +1 -1
- package/dist/internal/learned-skills.d.mts +1 -1
- package/dist/node.cjs +2 -3
- package/dist/node.d.cts +3 -3
- package/dist/node.d.mts +3 -3
- package/dist/node.mjs +3 -3
- package/dist/runtime/core/channel-manager.cjs +10 -2
- package/dist/runtime/core/channel-manager.cjs.map +1 -1
- package/dist/runtime/core/channel-manager.d.cts +1 -1
- package/dist/runtime/core/channel-manager.d.mts +1 -1
- package/dist/runtime/core/channel-manager.mjs +10 -1
- package/dist/runtime/core/channel-manager.mjs.map +1 -1
- package/dist/runtime/core/debug-event-bus.cjs +4 -3
- package/dist/runtime/core/debug-event-bus.cjs.map +1 -1
- package/dist/runtime/core/debug-event-bus.d.cts +5 -1
- package/dist/runtime/core/debug-event-bus.d.cts.map +1 -1
- package/dist/runtime/core/debug-event-bus.d.mts +4 -0
- package/dist/runtime/core/debug-event-bus.d.mts.map +1 -1
- package/dist/runtime/core/debug-event-bus.mjs +5 -3
- package/dist/runtime/core/debug-event-bus.mjs.map +1 -1
- package/dist/runtime/core/fetch-cors.cjs.map +1 -1
- package/dist/runtime/core/fetch-cors.d.cts +2 -2
- package/dist/runtime/core/fetch-cors.d.cts.map +1 -1
- package/dist/runtime/core/fetch-cors.d.mts +2 -2
- package/dist/runtime/core/fetch-cors.d.mts.map +1 -1
- package/dist/runtime/core/fetch-cors.mjs.map +1 -1
- package/dist/runtime/core/fetch-handler.cjs +17 -14
- package/dist/runtime/core/fetch-handler.cjs.map +1 -1
- package/dist/runtime/core/fetch-handler.d.cts +22 -14
- package/dist/runtime/core/fetch-handler.d.cts.map +1 -1
- package/dist/runtime/core/fetch-handler.d.mts +22 -14
- package/dist/runtime/core/fetch-handler.d.mts.map +1 -1
- package/dist/runtime/core/fetch-handler.mjs +9 -5
- package/dist/runtime/core/fetch-handler.mjs.map +1 -1
- package/dist/runtime/core/hooks.cjs.map +1 -1
- package/dist/runtime/core/hooks.d.cts +5 -5
- package/dist/runtime/core/hooks.d.cts.map +1 -1
- package/dist/runtime/core/hooks.d.mts +5 -5
- package/dist/runtime/core/hooks.d.mts.map +1 -1
- package/dist/runtime/core/hooks.mjs.map +1 -1
- package/dist/runtime/core/learning.cjs.map +1 -1
- package/dist/runtime/core/learning.d.cts +9 -9
- package/dist/runtime/core/learning.d.cts.map +1 -1
- package/dist/runtime/core/learning.d.mts +8 -8
- package/dist/runtime/core/learning.d.mts.map +1 -1
- package/dist/runtime/core/learning.mjs.map +1 -1
- package/dist/runtime/core/logger.cjs +105 -14
- package/dist/runtime/core/logger.cjs.map +1 -1
- package/dist/runtime/core/logger.d.cts +26 -9
- package/dist/runtime/core/logger.d.cts.map +1 -1
- package/dist/runtime/core/logger.d.mts +26 -9
- package/dist/runtime/core/logger.d.mts.map +1 -1
- package/dist/runtime/core/logger.mjs +105 -12
- package/dist/runtime/core/logger.mjs.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.cjs +3 -4
- package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -1
- package/dist/runtime/core/middleware-sse-parser.mjs +2 -2
- package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -1
- package/dist/runtime/core/middleware.cjs +5 -5
- package/dist/runtime/core/middleware.cjs.map +1 -1
- package/dist/runtime/core/middleware.d.cts +3 -3
- package/dist/runtime/core/middleware.d.cts.map +1 -1
- package/dist/runtime/core/middleware.d.mts +3 -3
- package/dist/runtime/core/middleware.d.mts.map +1 -1
- package/dist/runtime/core/middleware.mjs +4 -3
- package/dist/runtime/core/middleware.mjs.map +1 -1
- package/dist/runtime/core/package-info.cjs +1 -1
- package/dist/runtime/core/package-info.mjs +1 -1
- package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -1
- package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -1
- package/dist/runtime/core/runtime.cjs +44 -46
- package/dist/runtime/core/runtime.cjs.map +1 -1
- package/dist/runtime/core/runtime.d.cts +178 -91
- package/dist/runtime/core/runtime.d.cts.map +1 -1
- package/dist/runtime/core/runtime.d.mts +178 -91
- package/dist/runtime/core/runtime.d.mts.map +1 -1
- package/dist/runtime/core/runtime.mjs +42 -42
- package/dist/runtime/core/runtime.mjs.map +1 -1
- package/dist/runtime/endpoints/auto-start-channels.cjs +3 -4
- package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -1
- package/dist/runtime/endpoints/auto-start-channels.mjs +2 -2
- package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.cjs +4 -8
- package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.d.cts +4 -5
- package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.d.mts +4 -5
- package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -1
- package/dist/runtime/endpoints/node-fetch-handler.mjs +3 -5
- package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -1
- package/dist/runtime/endpoints/node.cjs +7 -5
- package/dist/runtime/endpoints/node.cjs.map +1 -1
- package/dist/runtime/endpoints/node.d.cts +16 -16
- package/dist/runtime/endpoints/node.d.cts.map +1 -1
- package/dist/runtime/endpoints/node.d.mts +16 -16
- package/dist/runtime/endpoints/node.d.mts.map +1 -1
- package/dist/runtime/endpoints/node.mjs +9 -7
- package/dist/runtime/endpoints/node.mjs.map +1 -1
- package/dist/runtime/event-transforms/index.d.cts +4 -0
- package/dist/runtime/event-transforms/index.d.mts +4 -0
- package/dist/runtime/event-transforms/index.mjs +5 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs +277 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts +61 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts +61 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs +276 -0
- package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.cjs +68 -0
- package/dist/runtime/event-transforms/recorded-events.cjs.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.d.cts +27 -0
- package/dist/runtime/event-transforms/recorded-events.d.cts.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.d.mts +27 -0
- package/dist/runtime/event-transforms/recorded-events.d.mts.map +1 -0
- package/dist/runtime/event-transforms/recorded-events.mjs +68 -0
- package/dist/runtime/event-transforms/recorded-events.mjs.map +1 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.cjs +289 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.cjs.map +1 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.mjs +288 -0
- package/dist/runtime/event-transforms/streaming-json-scanner.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.cjs +106 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.mjs +106 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs +422 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs +422 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs +84 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts +41 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts +41 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs +83 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.cjs +694 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.mjs +694 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.mjs.map +1 -0
- package/dist/runtime/generative-ui/generative-ui-middleware.cjs +0 -1
- package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -1
- package/dist/runtime/generative-ui/index.d.cts +1 -0
- package/dist/runtime/generative-ui/index.d.mts +1 -0
- package/dist/runtime/generative-ui/surface-writer.cjs +4 -5
- package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -1
- package/dist/runtime/generative-ui/surface-writer.d.cts +1 -1
- package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -1
- package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -1
- package/dist/runtime/generative-ui/surface-writer.mjs +5 -5
- package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -1
- package/dist/runtime/handlers/get-runtime-info.cjs +24 -6
- package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -1
- package/dist/runtime/handlers/get-runtime-info.mjs +25 -7
- package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -1
- package/dist/runtime/handlers/handle-connect.cjs +3 -8
- package/dist/runtime/handlers/handle-connect.cjs.map +1 -1
- package/dist/runtime/handlers/handle-connect.mjs +3 -8
- package/dist/runtime/handlers/handle-connect.mjs.map +1 -1
- package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -1
- package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-learning.cjs +2 -3
- package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-metadata.cjs +2 -3
- package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -1
- package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -1
- package/dist/runtime/handlers/handle-run.cjs +11 -16
- package/dist/runtime/handlers/handle-run.cjs.map +1 -1
- package/dist/runtime/handlers/handle-run.mjs +8 -12
- package/dist/runtime/handlers/handle-run.mjs.map +1 -1
- package/dist/runtime/handlers/handle-stop.cjs +5 -5
- package/dist/runtime/handlers/handle-stop.cjs.map +1 -1
- package/dist/runtime/handlers/handle-stop.mjs +2 -1
- package/dist/runtime/handlers/handle-stop.mjs.map +1 -1
- package/dist/runtime/handlers/handle-suggest.cjs +6 -3
- package/dist/runtime/handlers/handle-suggest.cjs.map +1 -1
- package/dist/runtime/handlers/handle-suggest.mjs +6 -2
- package/dist/runtime/handlers/handle-suggest.mjs.map +1 -1
- package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -1
- package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -1
- package/dist/runtime/handlers/handle-transcribe.cjs +0 -1
- package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -1
- package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/annotate.cjs +8 -8
- package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/annotate.mjs +5 -4
- package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/connect.cjs +6 -2
- package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/connect.mjs +6 -2
- package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/memories.cjs +28 -23
- package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/memories.mjs +12 -6
- package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/run.cjs +38 -30
- package/dist/runtime/handlers/intelligence/run.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/run.mjs +37 -28
- package/dist/runtime/handlers/intelligence/run.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/thread-names.cjs +6 -5
- package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/thread-names.mjs +3 -1
- package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -1
- package/dist/runtime/handlers/intelligence/threads.cjs +40 -31
- package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -1
- package/dist/runtime/handlers/intelligence/threads.mjs +18 -8
- package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -1
- package/dist/runtime/handlers/shared/agent-utils.cjs +50 -46
- package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/runtime/handlers/shared/agent-utils.mjs +47 -42
- package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/runtime/handlers/shared/cloud-telemetry.cjs +0 -1
- package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -1
- package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -1
- package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -1
- package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +4 -3
- package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
- package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +4 -3
- package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
- package/dist/runtime/handlers/shared/sse-response.cjs +77 -78
- package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -1
- package/dist/runtime/handlers/shared/sse-response.mjs +77 -77
- package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.cjs +4 -3
- package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -1
- package/dist/runtime/handlers/shared/thread-access.mjs +4 -3
- package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -1
- package/dist/runtime/handlers/sse/connect.cjs +2 -0
- package/dist/runtime/handlers/sse/connect.cjs.map +1 -1
- package/dist/runtime/handlers/sse/connect.mjs +2 -0
- package/dist/runtime/handlers/sse/connect.mjs.map +1 -1
- package/dist/runtime/handlers/sse/run.cjs +5 -2
- package/dist/runtime/handlers/sse/run.cjs.map +1 -1
- package/dist/runtime/handlers/sse/run.mjs +5 -2
- package/dist/runtime/handlers/sse/run.mjs.map +1 -1
- package/dist/runtime/index.d.cts +13 -18
- package/dist/runtime/index.d.mts +13 -18
- package/dist/runtime/intelligence-platform/analytics-context.cjs +84 -0
- package/dist/runtime/intelligence-platform/analytics-context.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/analytics-context.mjs +83 -0
- package/dist/runtime/intelligence-platform/analytics-context.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/client.cjs +30 -4
- package/dist/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/client.d.cts +25 -2
- package/dist/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/runtime/intelligence-platform/client.d.mts +25 -2
- package/dist/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/runtime/intelligence-platform/client.mjs +30 -3
- package/dist/runtime/intelligence-platform/client.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/learning-management.cjs +7 -8
- package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/learning-management.mjs +7 -7
- package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +104 -110
- package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +8 -2
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +8 -2
- package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +104 -109
- package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/config.cjs +0 -1
- package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +22 -19
- package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -1
- package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +22 -19
- package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/stop-run.cjs +50 -0
- package/dist/runtime/intelligence-platform/stop-run.cjs.map +1 -0
- package/dist/runtime/intelligence-platform/stop-run.mjs +50 -0
- package/dist/runtime/intelligence-platform/stop-run.mjs.map +1 -0
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +3 -3
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +2 -1
- package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -1
- package/dist/runtime/intelligence-platform/trajectories.cjs +2 -3
- package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -1
- package/dist/runtime/intelligence-platform/trajectories.mjs +2 -2
- package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -1
- package/dist/runtime/node.d.cts +2 -2
- package/dist/runtime/node.d.mts +2 -2
- package/dist/runtime/runner/agent-runner.cjs +0 -1
- package/dist/runtime/runner/agent-runner.cjs.map +1 -1
- package/dist/runtime/runner/agent-runner.d.cts +9 -0
- package/dist/runtime/runner/agent-runner.d.cts.map +1 -1
- package/dist/runtime/runner/agent-runner.d.mts +9 -0
- package/dist/runtime/runner/agent-runner.d.mts.map +1 -1
- package/dist/runtime/runner/agent-runner.mjs.map +1 -1
- package/dist/runtime/runner/in-memory.cjs +0 -1
- package/dist/runtime/runner/in-memory.cjs.map +1 -1
- package/dist/runtime/runner/index.d.cts +1 -1
- package/dist/runtime/runner/index.d.mts +1 -1
- package/dist/runtime/runner/index.mjs +1 -1
- package/dist/runtime/runner/intelligence.cjs +55 -9
- package/dist/runtime/runner/intelligence.cjs.map +1 -1
- package/dist/runtime/runner/intelligence.d.cts +12 -1
- package/dist/runtime/runner/intelligence.d.cts.map +1 -1
- package/dist/runtime/runner/intelligence.d.mts +12 -1
- package/dist/runtime/runner/intelligence.d.mts.map +1 -1
- package/dist/runtime/runner/intelligence.mjs +56 -10
- package/dist/runtime/runner/intelligence.mjs.map +1 -1
- package/dist/runtime/telemetry/disclosure.cjs +2 -3
- package/dist/runtime/telemetry/disclosure.cjs.map +1 -1
- package/dist/runtime/telemetry/disclosure.mjs +3 -3
- package/dist/runtime/telemetry/disclosure.mjs.map +1 -1
- package/dist/runtime/telemetry/events.d.cts +1 -1
- package/dist/runtime/telemetry/events.d.mts +1 -1
- package/dist/runtime/telemetry/instance-created.cjs +33 -12
- package/dist/runtime/telemetry/instance-created.cjs.map +1 -1
- package/dist/runtime/telemetry/instance-created.mjs +33 -12
- package/dist/runtime/telemetry/instance-created.mjs.map +1 -1
- package/dist/runtime/telemetry/telemetry-client.cjs +0 -5
- package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/runtime/telemetry/telemetry-client.mjs +0 -4
- package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/runtime/telemetry/telemetry-identity.cjs +0 -1
- package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -1
- package/dist/v2/index.d.cts +242 -0
- package/dist/v2/index.d.mts +242 -0
- package/dist/v2/node.d.cts +18 -0
- package/dist/v2/node.d.mts +18 -0
- package/package.json +84 -29
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/agent/converters/index.d.mts +0 -2
- package/dist/agent/index.cjs +0 -1328
- package/dist/agent/index.cjs.map +0 -1
- package/dist/agent/index.d.cts +0 -467
- package/dist/agent/index.d.cts.map +0 -1
- package/dist/agent/index.d.mts +0 -468
- package/dist/agent/index.d.mts.map +0 -1
- package/dist/agent/index.mjs +0 -1318
- package/dist/agent/index.mjs.map +0 -1
- package/dist/agent/mcp-tool-names.cjs +0 -82
- package/dist/agent/mcp-tool-names.cjs.map +0 -1
- package/dist/agent/mcp-tool-names.mjs +0 -80
- package/dist/agent/mcp-tool-names.mjs.map +0 -1
- package/dist/agent/url-download.cjs.map +0 -1
- package/dist/agent/url-download.d.cts.map +0 -1
- package/dist/agent/url-download.d.mts.map +0 -1
- package/dist/agent/url-download.mjs.map +0 -1
- package/dist/runtime/index.d.cts.map +0 -1
- package/dist/runtime/index.d.mts.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const require_usage = require('../../agent/converters/usage.cjs');
|
|
2
|
+
let _copilotkit_shared = require("@copilotkit/shared");
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/generative-ui/a2ui-v09-actions.ts
|
|
5
|
+
/** The 1.0 action of the user event that started the run, if one did. */
|
|
6
|
+
function readAction(envelope) {
|
|
7
|
+
const message = envelope?.metadata.extensions.copilotkit_action;
|
|
8
|
+
if (!require_usage.isRecord(message) || !require_usage.isRecord(message.action)) return void 0;
|
|
9
|
+
const { name, surfaceId, sourceComponentId, context, timestamp } = message.action;
|
|
10
|
+
if (typeof name !== "string" || typeof surfaceId !== "string") return;
|
|
11
|
+
return {
|
|
12
|
+
name,
|
|
13
|
+
surfaceId,
|
|
14
|
+
sourceComponentId: typeof sourceComponentId === "string" ? sourceComponentId : "",
|
|
15
|
+
context: require_usage.isRecord(context) ? context : {},
|
|
16
|
+
timestamp: typeof timestamp === "string" ? timestamp : (/* @__PURE__ */ new Date()).toISOString()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* True when the surface was converted from A2UI v0.9. The first of these
|
|
21
|
+
* that knows the surface decides:
|
|
22
|
+
* 1. The summary of the surface in the envelope (`copilotkit_surfaces`).
|
|
23
|
+
* 2. The last `generative-ui-surface` activity message of the surface.
|
|
24
|
+
* 3. `agentVersion`.
|
|
25
|
+
*/
|
|
26
|
+
function isV09Surface(surfaces, messages, surfaceId, agentVersion) {
|
|
27
|
+
if (Object.hasOwn(surfaces, surfaceId)) return surfaces[surfaceId].a2uiSourceVersion === "0.9";
|
|
28
|
+
const surface = messages.findLast((message) => message.role === "activity" && message.activityType === _copilotkit_shared.GENERATIVE_UI_ACTIVITY_TYPE && require_usage.isRecord(message.content) && message.content.surfaceId === surfaceId);
|
|
29
|
+
if (!surface) return agentVersion === "0.9";
|
|
30
|
+
return surface.content?.a2uiSourceVersion === "0.9";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Removes the visible user message that the 1.0 client added for the click.
|
|
34
|
+
* The client adds it just before the run, so it is the last message.
|
|
35
|
+
*/
|
|
36
|
+
function withoutActionUserMessage(messages) {
|
|
37
|
+
const last = messages.at(-1);
|
|
38
|
+
if (last?.role !== "user" || typeof last.content !== "string") return messages;
|
|
39
|
+
return messages.slice(0, -1);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Turns a click on a surface that the runtime converted from A2UI v0.9 into
|
|
43
|
+
* the v0.9 action that the agent side expects.
|
|
44
|
+
*
|
|
45
|
+
* The 1.0 client sends a click as a visible user message plus
|
|
46
|
+
* `forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_action`. A v0.9
|
|
47
|
+
* agent stack reads `forwardedProps.a2uiAction.userAction` instead. When the
|
|
48
|
+
* run carries a 1.0 action for a surface of v0.9 origin, this returns a new
|
|
49
|
+
* input with `forwardedProps.a2uiAction` set and the visible user message
|
|
50
|
+
* removed. Otherwise it returns `input` unchanged. It never mutates `input`.
|
|
51
|
+
*
|
|
52
|
+
* The visible user message is removed because the v0.9 consumers already
|
|
53
|
+
* turn `a2uiAction` into what the agent sees:
|
|
54
|
+
* - `@ag-ui/a2ui-middleware` appends the action as a private user message,
|
|
55
|
+
* `A2UI user action:` and the action JSON. The Python, Go, Ruby and .NET
|
|
56
|
+
* runtimes append a synthetic `log_a2ui_event` tool call and result, and
|
|
57
|
+
* prompt the model to answer them when they end the conversation. With
|
|
58
|
+
* the visible message kept, the model sees the click twice, and the
|
|
59
|
+
* conversation no longer ends with the action.
|
|
60
|
+
* - `@ag-ui/a2a` attaches `a2uiAction` as a data part to the latest user
|
|
61
|
+
* message, and A2A agents read the data part first.
|
|
62
|
+
* The v0.9 client sent no user message for a click, so with it removed the
|
|
63
|
+
* agent gets the same input as it did from the v0.9 client. The 1.0 client
|
|
64
|
+
* still shows the message in its chat.
|
|
65
|
+
*
|
|
66
|
+
* Origin: the first of these that knows the clicked surface decides.
|
|
67
|
+
* 1. Its summary in the envelope
|
|
68
|
+
* (`forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_surfaces`):
|
|
69
|
+
* `a2uiSourceVersion === "0.9"` means v0.9 origin, left out means 1.0. The
|
|
70
|
+
* 1.0 client copies the tag from the surface's activity content, so this
|
|
71
|
+
* is what decides for runs from the 1.0 client.
|
|
72
|
+
* 2. The last `generative-ui-surface` activity message for the surface in
|
|
73
|
+
* `input.messages` (`a2uiSourceVersion === "0.9"`), for a caller that
|
|
74
|
+
* passes activity messages.
|
|
75
|
+
* 3. `options.agentVersion === "0.9"`.
|
|
76
|
+
*
|
|
77
|
+
* @param input - The run input from the 1.0 client.
|
|
78
|
+
* @param options - `agentVersion`: the fallback when the surface is unknown.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const agentInput = downgradeA2UIV09Action(input, { agentVersion: "0.9" });
|
|
83
|
+
* // agentInput.forwardedProps.a2uiAction.userAction:
|
|
84
|
+
* // { name, surfaceId, sourceComponentId, context, timestamp }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function downgradeA2UIV09Action(input, options = {}) {
|
|
88
|
+
const forwardedProps = input.forwardedProps;
|
|
89
|
+
if (!require_usage.isRecord(forwardedProps) || forwardedProps.a2uiAction !== void 0) return input;
|
|
90
|
+
const envelope = (0, _copilotkit_shared.readCopilotKitUIEnvelope)(forwardedProps);
|
|
91
|
+
const userAction = readAction(envelope);
|
|
92
|
+
if (!envelope || !userAction) return input;
|
|
93
|
+
if (!isV09Surface(envelope.metadata.extensions.copilotkit_surfaces, input.messages, userAction.surfaceId, options.agentVersion)) return input;
|
|
94
|
+
return {
|
|
95
|
+
...input,
|
|
96
|
+
messages: withoutActionUserMessage(input.messages),
|
|
97
|
+
forwardedProps: {
|
|
98
|
+
...forwardedProps,
|
|
99
|
+
a2uiAction: { userAction }
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
exports.downgradeA2UIV09Action = downgradeA2UIV09Action;
|
|
106
|
+
//# sourceMappingURL=a2ui-v09-actions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2ui-v09-actions.cjs","names":["isRecord","GENERATIVE_UI_ACTIVITY_TYPE"],"sources":["../../../src/runtime/generative-ui/a2ui-v09-actions.ts"],"sourcesContent":["import type { Message, RunAgentInput } from \"@ag-ui/client\";\nimport {\n GENERATIVE_UI_ACTIVITY_TYPE,\n readCopilotKitUIEnvelope,\n} from \"@copilotkit/shared\";\nimport type { CopilotKitUIEnvelope } from \"@copilotkit/shared\";\nimport { isRecord } from \"../../agent/converters/usage\";\n\n/**\n * The A2UI v0.9 user action, as the v0.9 client sent it in\n * `forwardedProps.a2uiAction.userAction`. `@ag-ui/a2ui-middleware`,\n * `@ag-ui/a2a` and the CopilotKit runtimes in other languages read this shape.\n */\ninterface A2UIV09UserAction {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n context: Record<string, unknown>;\n timestamp: string;\n}\n\nexport interface DowngradeA2UIV09ActionOptions {\n /**\n * The A2UI version the agent speaks. Used only when neither the envelope\n * summary nor `input.messages` knows the clicked surface.\n */\n agentVersion?: \"0.9\" | \"1.0\";\n}\n\n/** The 1.0 action of the user event that started the run, if one did. */\nfunction readAction(\n envelope: CopilotKitUIEnvelope | undefined,\n): A2UIV09UserAction | undefined {\n const message: unknown = envelope?.metadata.extensions.copilotkit_action;\n if (!isRecord(message) || !isRecord(message.action)) return undefined;\n const { name, surfaceId, sourceComponentId, context, timestamp } =\n message.action;\n if (typeof name !== \"string\" || typeof surfaceId !== \"string\") {\n return undefined;\n }\n return {\n name,\n surfaceId,\n sourceComponentId:\n typeof sourceComponentId === \"string\" ? sourceComponentId : \"\",\n context: isRecord(context) ? context : {},\n timestamp:\n typeof timestamp === \"string\" ? timestamp : new Date().toISOString(),\n };\n}\n\n/**\n * True when the surface was converted from A2UI v0.9. The first of these\n * that knows the surface decides:\n * 1. The summary of the surface in the envelope (`copilotkit_surfaces`).\n * 2. The last `generative-ui-surface` activity message of the surface.\n * 3. `agentVersion`.\n */\nfunction isV09Surface(\n surfaces: CopilotKitUIEnvelope[\"metadata\"][\"extensions\"][\"copilotkit_surfaces\"],\n messages: readonly Message[],\n surfaceId: string,\n agentVersion: DowngradeA2UIV09ActionOptions[\"agentVersion\"],\n) {\n // `readCopilotKitUIEnvelope` checked the summary, so the tag is \"0.9\" or\n // left out. An own-key check: the ids come from the client.\n if (Object.hasOwn(surfaces, surfaceId)) {\n return surfaces[surfaceId].a2uiSourceVersion === \"0.9\";\n }\n const surface = messages.findLast(\n (message) =>\n message.role === \"activity\" &&\n message.activityType === GENERATIVE_UI_ACTIVITY_TYPE &&\n isRecord(message.content) &&\n message.content.surfaceId === surfaceId,\n );\n if (!surface) return agentVersion === \"0.9\";\n // `a2uiSourceVersion` is set by the runtime on surfaces it converted from\n // v0.9. Read it untyped: not every surface content has it.\n const content = (surface as { content?: { a2uiSourceVersion?: unknown } })\n .content;\n return content?.a2uiSourceVersion === \"0.9\";\n}\n\n/**\n * Removes the visible user message that the 1.0 client added for the click.\n * The client adds it just before the run, so it is the last message.\n */\nfunction withoutActionUserMessage(messages: Message[]) {\n const last = messages.at(-1);\n if (last?.role !== \"user\" || typeof last.content !== \"string\") {\n return messages;\n }\n return messages.slice(0, -1);\n}\n\n/**\n * Turns a click on a surface that the runtime converted from A2UI v0.9 into\n * the v0.9 action that the agent side expects.\n *\n * The 1.0 client sends a click as a visible user message plus\n * `forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_action`. A v0.9\n * agent stack reads `forwardedProps.a2uiAction.userAction` instead. When the\n * run carries a 1.0 action for a surface of v0.9 origin, this returns a new\n * input with `forwardedProps.a2uiAction` set and the visible user message\n * removed. Otherwise it returns `input` unchanged. It never mutates `input`.\n *\n * The visible user message is removed because the v0.9 consumers already\n * turn `a2uiAction` into what the agent sees:\n * - `@ag-ui/a2ui-middleware` appends the action as a private user message,\n * `A2UI user action:` and the action JSON. The Python, Go, Ruby and .NET\n * runtimes append a synthetic `log_a2ui_event` tool call and result, and\n * prompt the model to answer them when they end the conversation. With\n * the visible message kept, the model sees the click twice, and the\n * conversation no longer ends with the action.\n * - `@ag-ui/a2a` attaches `a2uiAction` as a data part to the latest user\n * message, and A2A agents read the data part first.\n * The v0.9 client sent no user message for a click, so with it removed the\n * agent gets the same input as it did from the v0.9 client. The 1.0 client\n * still shows the message in its chat.\n *\n * Origin: the first of these that knows the clicked surface decides.\n * 1. Its summary in the envelope\n * (`forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_surfaces`):\n * `a2uiSourceVersion === \"0.9\"` means v0.9 origin, left out means 1.0. The\n * 1.0 client copies the tag from the surface's activity content, so this\n * is what decides for runs from the 1.0 client.\n * 2. The last `generative-ui-surface` activity message for the surface in\n * `input.messages` (`a2uiSourceVersion === \"0.9\"`), for a caller that\n * passes activity messages.\n * 3. `options.agentVersion === \"0.9\"`.\n *\n * @param input - The run input from the 1.0 client.\n * @param options - `agentVersion`: the fallback when the surface is unknown.\n *\n * @example\n * ```ts\n * const agentInput = downgradeA2UIV09Action(input, { agentVersion: \"0.9\" });\n * // agentInput.forwardedProps.a2uiAction.userAction:\n * // { name, surfaceId, sourceComponentId, context, timestamp }\n * ```\n */\nexport function downgradeA2UIV09Action(\n input: RunAgentInput,\n options: DowngradeA2UIV09ActionOptions = {},\n): RunAgentInput {\n const forwardedProps: unknown = input.forwardedProps;\n // A run that already has a v0.9 action keeps it.\n if (!isRecord(forwardedProps) || forwardedProps.a2uiAction !== undefined) {\n return input;\n }\n const envelope = readCopilotKitUIEnvelope(forwardedProps);\n const userAction = readAction(envelope);\n if (!envelope || !userAction) return input;\n if (\n !isV09Surface(\n envelope.metadata.extensions.copilotkit_surfaces,\n input.messages,\n userAction.surfaceId,\n options.agentVersion,\n )\n ) {\n return input;\n }\n return {\n ...input,\n messages: withoutActionUserMessage(input.messages),\n forwardedProps: { ...forwardedProps, a2uiAction: { userAction } },\n };\n}\n"],"mappings":";;;;;AA8BA,SAAS,WACP,UAC+B;CAC/B,MAAM,UAAmB,UAAU,SAAS,WAAW;AACvD,KAAI,CAACA,uBAAS,QAAQ,IAAI,CAACA,uBAAS,QAAQ,OAAO,CAAE,QAAO;CAC5D,MAAM,EAAE,MAAM,WAAW,mBAAmB,SAAS,cACnD,QAAQ;AACV,KAAI,OAAO,SAAS,YAAY,OAAO,cAAc,SACnD;AAEF,QAAO;EACL;EACA;EACA,mBACE,OAAO,sBAAsB,WAAW,oBAAoB;EAC9D,SAASA,uBAAS,QAAQ,GAAG,UAAU,EAAE;EACzC,WACE,OAAO,cAAc,WAAW,6BAAY,IAAI,MAAM,EAAC,aAAa;EACvE;;;;;;;;;AAUH,SAAS,aACP,UACA,UACA,WACA,cACA;AAGA,KAAI,OAAO,OAAO,UAAU,UAAU,CACpC,QAAO,SAAS,WAAW,sBAAsB;CAEnD,MAAM,UAAU,SAAS,UACtB,YACC,QAAQ,SAAS,cACjB,QAAQ,iBAAiBC,kDACzBD,uBAAS,QAAQ,QAAQ,IACzB,QAAQ,QAAQ,cAAc,UACjC;AACD,KAAI,CAAC,QAAS,QAAO,iBAAiB;AAKtC,QAFiB,QACd,SACa,sBAAsB;;;;;;AAOxC,SAAS,yBAAyB,UAAqB;CACrD,MAAM,OAAO,SAAS,GAAG,GAAG;AAC5B,KAAI,MAAM,SAAS,UAAU,OAAO,KAAK,YAAY,SACnD,QAAO;AAET,QAAO,SAAS,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiD9B,SAAgB,uBACd,OACA,UAAyC,EAAE,EAC5B;CACf,MAAM,iBAA0B,MAAM;AAEtC,KAAI,CAACA,uBAAS,eAAe,IAAI,eAAe,eAAe,OAC7D,QAAO;CAET,MAAM,4DAAoC,eAAe;CACzD,MAAM,aAAa,WAAW,SAAS;AACvC,KAAI,CAAC,YAAY,CAAC,WAAY,QAAO;AACrC,KACE,CAAC,aACC,SAAS,SAAS,WAAW,qBAC7B,MAAM,UACN,WAAW,WACX,QAAQ,aACT,CAED,QAAO;AAET,QAAO;EACL,GAAG;EACH,UAAU,yBAAyB,MAAM,SAAS;EAClD,gBAAgB;GAAE,GAAG;GAAgB,YAAY,EAAE,YAAY;GAAE;EAClE"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { isRecord } from "../../agent/converters/usage.mjs";
|
|
2
|
+
import { GENERATIVE_UI_ACTIVITY_TYPE, readCopilotKitUIEnvelope } from "@copilotkit/shared";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/generative-ui/a2ui-v09-actions.ts
|
|
5
|
+
/** The 1.0 action of the user event that started the run, if one did. */
|
|
6
|
+
function readAction(envelope) {
|
|
7
|
+
const message = envelope?.metadata.extensions.copilotkit_action;
|
|
8
|
+
if (!isRecord(message) || !isRecord(message.action)) return void 0;
|
|
9
|
+
const { name, surfaceId, sourceComponentId, context, timestamp } = message.action;
|
|
10
|
+
if (typeof name !== "string" || typeof surfaceId !== "string") return;
|
|
11
|
+
return {
|
|
12
|
+
name,
|
|
13
|
+
surfaceId,
|
|
14
|
+
sourceComponentId: typeof sourceComponentId === "string" ? sourceComponentId : "",
|
|
15
|
+
context: isRecord(context) ? context : {},
|
|
16
|
+
timestamp: typeof timestamp === "string" ? timestamp : (/* @__PURE__ */ new Date()).toISOString()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* True when the surface was converted from A2UI v0.9. The first of these
|
|
21
|
+
* that knows the surface decides:
|
|
22
|
+
* 1. The summary of the surface in the envelope (`copilotkit_surfaces`).
|
|
23
|
+
* 2. The last `generative-ui-surface` activity message of the surface.
|
|
24
|
+
* 3. `agentVersion`.
|
|
25
|
+
*/
|
|
26
|
+
function isV09Surface(surfaces, messages, surfaceId, agentVersion) {
|
|
27
|
+
if (Object.hasOwn(surfaces, surfaceId)) return surfaces[surfaceId].a2uiSourceVersion === "0.9";
|
|
28
|
+
const surface = messages.findLast((message) => message.role === "activity" && message.activityType === GENERATIVE_UI_ACTIVITY_TYPE && isRecord(message.content) && message.content.surfaceId === surfaceId);
|
|
29
|
+
if (!surface) return agentVersion === "0.9";
|
|
30
|
+
return surface.content?.a2uiSourceVersion === "0.9";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Removes the visible user message that the 1.0 client added for the click.
|
|
34
|
+
* The client adds it just before the run, so it is the last message.
|
|
35
|
+
*/
|
|
36
|
+
function withoutActionUserMessage(messages) {
|
|
37
|
+
const last = messages.at(-1);
|
|
38
|
+
if (last?.role !== "user" || typeof last.content !== "string") return messages;
|
|
39
|
+
return messages.slice(0, -1);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Turns a click on a surface that the runtime converted from A2UI v0.9 into
|
|
43
|
+
* the v0.9 action that the agent side expects.
|
|
44
|
+
*
|
|
45
|
+
* The 1.0 client sends a click as a visible user message plus
|
|
46
|
+
* `forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_action`. A v0.9
|
|
47
|
+
* agent stack reads `forwardedProps.a2uiAction.userAction` instead. When the
|
|
48
|
+
* run carries a 1.0 action for a surface of v0.9 origin, this returns a new
|
|
49
|
+
* input with `forwardedProps.a2uiAction` set and the visible user message
|
|
50
|
+
* removed. Otherwise it returns `input` unchanged. It never mutates `input`.
|
|
51
|
+
*
|
|
52
|
+
* The visible user message is removed because the v0.9 consumers already
|
|
53
|
+
* turn `a2uiAction` into what the agent sees:
|
|
54
|
+
* - `@ag-ui/a2ui-middleware` appends the action as a private user message,
|
|
55
|
+
* `A2UI user action:` and the action JSON. The Python, Go, Ruby and .NET
|
|
56
|
+
* runtimes append a synthetic `log_a2ui_event` tool call and result, and
|
|
57
|
+
* prompt the model to answer them when they end the conversation. With
|
|
58
|
+
* the visible message kept, the model sees the click twice, and the
|
|
59
|
+
* conversation no longer ends with the action.
|
|
60
|
+
* - `@ag-ui/a2a` attaches `a2uiAction` as a data part to the latest user
|
|
61
|
+
* message, and A2A agents read the data part first.
|
|
62
|
+
* The v0.9 client sent no user message for a click, so with it removed the
|
|
63
|
+
* agent gets the same input as it did from the v0.9 client. The 1.0 client
|
|
64
|
+
* still shows the message in its chat.
|
|
65
|
+
*
|
|
66
|
+
* Origin: the first of these that knows the clicked surface decides.
|
|
67
|
+
* 1. Its summary in the envelope
|
|
68
|
+
* (`forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_surfaces`):
|
|
69
|
+
* `a2uiSourceVersion === "0.9"` means v0.9 origin, left out means 1.0. The
|
|
70
|
+
* 1.0 client copies the tag from the surface's activity content, so this
|
|
71
|
+
* is what decides for runs from the 1.0 client.
|
|
72
|
+
* 2. The last `generative-ui-surface` activity message for the surface in
|
|
73
|
+
* `input.messages` (`a2uiSourceVersion === "0.9"`), for a caller that
|
|
74
|
+
* passes activity messages.
|
|
75
|
+
* 3. `options.agentVersion === "0.9"`.
|
|
76
|
+
*
|
|
77
|
+
* @param input - The run input from the 1.0 client.
|
|
78
|
+
* @param options - `agentVersion`: the fallback when the surface is unknown.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const agentInput = downgradeA2UIV09Action(input, { agentVersion: "0.9" });
|
|
83
|
+
* // agentInput.forwardedProps.a2uiAction.userAction:
|
|
84
|
+
* // { name, surfaceId, sourceComponentId, context, timestamp }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function downgradeA2UIV09Action(input, options = {}) {
|
|
88
|
+
const forwardedProps = input.forwardedProps;
|
|
89
|
+
if (!isRecord(forwardedProps) || forwardedProps.a2uiAction !== void 0) return input;
|
|
90
|
+
const envelope = readCopilotKitUIEnvelope(forwardedProps);
|
|
91
|
+
const userAction = readAction(envelope);
|
|
92
|
+
if (!envelope || !userAction) return input;
|
|
93
|
+
if (!isV09Surface(envelope.metadata.extensions.copilotkit_surfaces, input.messages, userAction.surfaceId, options.agentVersion)) return input;
|
|
94
|
+
return {
|
|
95
|
+
...input,
|
|
96
|
+
messages: withoutActionUserMessage(input.messages),
|
|
97
|
+
forwardedProps: {
|
|
98
|
+
...forwardedProps,
|
|
99
|
+
a2uiAction: { userAction }
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { downgradeA2UIV09Action };
|
|
106
|
+
//# sourceMappingURL=a2ui-v09-actions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2ui-v09-actions.mjs","names":[],"sources":["../../../src/runtime/generative-ui/a2ui-v09-actions.ts"],"sourcesContent":["import type { Message, RunAgentInput } from \"@ag-ui/client\";\nimport {\n GENERATIVE_UI_ACTIVITY_TYPE,\n readCopilotKitUIEnvelope,\n} from \"@copilotkit/shared\";\nimport type { CopilotKitUIEnvelope } from \"@copilotkit/shared\";\nimport { isRecord } from \"../../agent/converters/usage\";\n\n/**\n * The A2UI v0.9 user action, as the v0.9 client sent it in\n * `forwardedProps.a2uiAction.userAction`. `@ag-ui/a2ui-middleware`,\n * `@ag-ui/a2a` and the CopilotKit runtimes in other languages read this shape.\n */\ninterface A2UIV09UserAction {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n context: Record<string, unknown>;\n timestamp: string;\n}\n\nexport interface DowngradeA2UIV09ActionOptions {\n /**\n * The A2UI version the agent speaks. Used only when neither the envelope\n * summary nor `input.messages` knows the clicked surface.\n */\n agentVersion?: \"0.9\" | \"1.0\";\n}\n\n/** The 1.0 action of the user event that started the run, if one did. */\nfunction readAction(\n envelope: CopilotKitUIEnvelope | undefined,\n): A2UIV09UserAction | undefined {\n const message: unknown = envelope?.metadata.extensions.copilotkit_action;\n if (!isRecord(message) || !isRecord(message.action)) return undefined;\n const { name, surfaceId, sourceComponentId, context, timestamp } =\n message.action;\n if (typeof name !== \"string\" || typeof surfaceId !== \"string\") {\n return undefined;\n }\n return {\n name,\n surfaceId,\n sourceComponentId:\n typeof sourceComponentId === \"string\" ? sourceComponentId : \"\",\n context: isRecord(context) ? context : {},\n timestamp:\n typeof timestamp === \"string\" ? timestamp : new Date().toISOString(),\n };\n}\n\n/**\n * True when the surface was converted from A2UI v0.9. The first of these\n * that knows the surface decides:\n * 1. The summary of the surface in the envelope (`copilotkit_surfaces`).\n * 2. The last `generative-ui-surface` activity message of the surface.\n * 3. `agentVersion`.\n */\nfunction isV09Surface(\n surfaces: CopilotKitUIEnvelope[\"metadata\"][\"extensions\"][\"copilotkit_surfaces\"],\n messages: readonly Message[],\n surfaceId: string,\n agentVersion: DowngradeA2UIV09ActionOptions[\"agentVersion\"],\n) {\n // `readCopilotKitUIEnvelope` checked the summary, so the tag is \"0.9\" or\n // left out. An own-key check: the ids come from the client.\n if (Object.hasOwn(surfaces, surfaceId)) {\n return surfaces[surfaceId].a2uiSourceVersion === \"0.9\";\n }\n const surface = messages.findLast(\n (message) =>\n message.role === \"activity\" &&\n message.activityType === GENERATIVE_UI_ACTIVITY_TYPE &&\n isRecord(message.content) &&\n message.content.surfaceId === surfaceId,\n );\n if (!surface) return agentVersion === \"0.9\";\n // `a2uiSourceVersion` is set by the runtime on surfaces it converted from\n // v0.9. Read it untyped: not every surface content has it.\n const content = (surface as { content?: { a2uiSourceVersion?: unknown } })\n .content;\n return content?.a2uiSourceVersion === \"0.9\";\n}\n\n/**\n * Removes the visible user message that the 1.0 client added for the click.\n * The client adds it just before the run, so it is the last message.\n */\nfunction withoutActionUserMessage(messages: Message[]) {\n const last = messages.at(-1);\n if (last?.role !== \"user\" || typeof last.content !== \"string\") {\n return messages;\n }\n return messages.slice(0, -1);\n}\n\n/**\n * Turns a click on a surface that the runtime converted from A2UI v0.9 into\n * the v0.9 action that the agent side expects.\n *\n * The 1.0 client sends a click as a visible user message plus\n * `forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_action`. A v0.9\n * agent stack reads `forwardedProps.a2uiAction.userAction` instead. When the\n * run carries a 1.0 action for a surface of v0.9 origin, this returns a new\n * input with `forwardedProps.a2uiAction` set and the visible user message\n * removed. Otherwise it returns `input` unchanged. It never mutates `input`.\n *\n * The visible user message is removed because the v0.9 consumers already\n * turn `a2uiAction` into what the agent sees:\n * - `@ag-ui/a2ui-middleware` appends the action as a private user message,\n * `A2UI user action:` and the action JSON. The Python, Go, Ruby and .NET\n * runtimes append a synthetic `log_a2ui_event` tool call and result, and\n * prompt the model to answer them when they end the conversation. With\n * the visible message kept, the model sees the click twice, and the\n * conversation no longer ends with the action.\n * - `@ag-ui/a2a` attaches `a2uiAction` as a data part to the latest user\n * message, and A2A agents read the data part first.\n * The v0.9 client sent no user message for a click, so with it removed the\n * agent gets the same input as it did from the v0.9 client. The 1.0 client\n * still shows the message in its chat.\n *\n * Origin: the first of these that knows the clicked surface decides.\n * 1. Its summary in the envelope\n * (`forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_surfaces`):\n * `a2uiSourceVersion === \"0.9\"` means v0.9 origin, left out means 1.0. The\n * 1.0 client copies the tag from the surface's activity content, so this\n * is what decides for runs from the 1.0 client.\n * 2. The last `generative-ui-surface` activity message for the surface in\n * `input.messages` (`a2uiSourceVersion === \"0.9\"`), for a caller that\n * passes activity messages.\n * 3. `options.agentVersion === \"0.9\"`.\n *\n * @param input - The run input from the 1.0 client.\n * @param options - `agentVersion`: the fallback when the surface is unknown.\n *\n * @example\n * ```ts\n * const agentInput = downgradeA2UIV09Action(input, { agentVersion: \"0.9\" });\n * // agentInput.forwardedProps.a2uiAction.userAction:\n * // { name, surfaceId, sourceComponentId, context, timestamp }\n * ```\n */\nexport function downgradeA2UIV09Action(\n input: RunAgentInput,\n options: DowngradeA2UIV09ActionOptions = {},\n): RunAgentInput {\n const forwardedProps: unknown = input.forwardedProps;\n // A run that already has a v0.9 action keeps it.\n if (!isRecord(forwardedProps) || forwardedProps.a2uiAction !== undefined) {\n return input;\n }\n const envelope = readCopilotKitUIEnvelope(forwardedProps);\n const userAction = readAction(envelope);\n if (!envelope || !userAction) return input;\n if (\n !isV09Surface(\n envelope.metadata.extensions.copilotkit_surfaces,\n input.messages,\n userAction.surfaceId,\n options.agentVersion,\n )\n ) {\n return input;\n }\n return {\n ...input,\n messages: withoutActionUserMessage(input.messages),\n forwardedProps: { ...forwardedProps, a2uiAction: { userAction } },\n };\n}\n"],"mappings":";;;;;AA8BA,SAAS,WACP,UAC+B;CAC/B,MAAM,UAAmB,UAAU,SAAS,WAAW;AACvD,KAAI,CAAC,SAAS,QAAQ,IAAI,CAAC,SAAS,QAAQ,OAAO,CAAE,QAAO;CAC5D,MAAM,EAAE,MAAM,WAAW,mBAAmB,SAAS,cACnD,QAAQ;AACV,KAAI,OAAO,SAAS,YAAY,OAAO,cAAc,SACnD;AAEF,QAAO;EACL;EACA;EACA,mBACE,OAAO,sBAAsB,WAAW,oBAAoB;EAC9D,SAAS,SAAS,QAAQ,GAAG,UAAU,EAAE;EACzC,WACE,OAAO,cAAc,WAAW,6BAAY,IAAI,MAAM,EAAC,aAAa;EACvE;;;;;;;;;AAUH,SAAS,aACP,UACA,UACA,WACA,cACA;AAGA,KAAI,OAAO,OAAO,UAAU,UAAU,CACpC,QAAO,SAAS,WAAW,sBAAsB;CAEnD,MAAM,UAAU,SAAS,UACtB,YACC,QAAQ,SAAS,cACjB,QAAQ,iBAAiB,+BACzB,SAAS,QAAQ,QAAQ,IACzB,QAAQ,QAAQ,cAAc,UACjC;AACD,KAAI,CAAC,QAAS,QAAO,iBAAiB;AAKtC,QAFiB,QACd,SACa,sBAAsB;;;;;;AAOxC,SAAS,yBAAyB,UAAqB;CACrD,MAAM,OAAO,SAAS,GAAG,GAAG;AAC5B,KAAI,MAAM,SAAS,UAAU,OAAO,KAAK,YAAY,SACnD,QAAO;AAET,QAAO,SAAS,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiD9B,SAAgB,uBACd,OACA,UAAyC,EAAE,EAC5B;CACf,MAAM,iBAA0B,MAAM;AAEtC,KAAI,CAAC,SAAS,eAAe,IAAI,eAAe,eAAe,OAC7D,QAAO;CAET,MAAM,WAAW,yBAAyB,eAAe;CACzD,MAAM,aAAa,WAAW,SAAS;AACvC,KAAI,CAAC,YAAY,CAAC,WAAY,QAAO;AACrC,KACE,CAAC,aACC,SAAS,SAAS,WAAW,qBAC7B,MAAM,UACN,WAAW,WACX,QAAQ,aACT,CAED,QAAO;AAET,QAAO;EACL,GAAG;EACH,UAAU,yBAAyB,MAAM,SAAS;EAClD,gBAAgB;GAAE,GAAG;GAAgB,YAAY,EAAE,YAAY;GAAE;EAClE"}
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
let _copilotkit_shared = require("@copilotkit/shared");
|
|
2
|
+
let _ag_ui_a2ui_middleware = require("@ag-ui/a2ui-middleware");
|
|
3
|
+
let _copilotkit_shared_generative_ui = require("@copilotkit/shared/generative-ui");
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/generative-ui/a2ui-v09-catalog.ts
|
|
6
|
+
/** Id of the A2UI v0.9 basic catalog. */
|
|
7
|
+
const A2UI_V09_BASIC_CATALOG_ID = "https://a2ui.org/specification/v0_9/basic_catalog.json";
|
|
8
|
+
const CAPABILITIES_CONTEXT_DESCRIPTION = "A2UI catalog capabilities: available catalog IDs and custom component definitions the client can render.";
|
|
9
|
+
const GENERATION_GUIDELINES_CONTEXT_DESCRIPTION = "A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.";
|
|
10
|
+
const DESIGN_GUIDELINES_CONTEXT_DESCRIPTION = "A2UI design guidelines — visual design rules, component hierarchy tips, and action handler patterns.";
|
|
11
|
+
/** The components of the v0.9 basic catalog. The 1.0 standard catalog has each of them. */
|
|
12
|
+
const V09_BASIC_COMPONENTS = new Set([
|
|
13
|
+
"Text",
|
|
14
|
+
"Image",
|
|
15
|
+
"Icon",
|
|
16
|
+
"Video",
|
|
17
|
+
"AudioPlayer",
|
|
18
|
+
"Row",
|
|
19
|
+
"Column",
|
|
20
|
+
"List",
|
|
21
|
+
"Card",
|
|
22
|
+
"Tabs",
|
|
23
|
+
"Modal",
|
|
24
|
+
"Divider",
|
|
25
|
+
"Button",
|
|
26
|
+
"TextField",
|
|
27
|
+
"CheckBox",
|
|
28
|
+
"ChoicePicker",
|
|
29
|
+
"Slider",
|
|
30
|
+
"DateTimeInput"
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* The props (and events and slots) of standard components that v0.9 names
|
|
34
|
+
* differently: component → 1.0 name → v0.9 name. Every other prop has the
|
|
35
|
+
* same name in both versions.
|
|
36
|
+
*/
|
|
37
|
+
const V10_TO_V09_PROP_NAMES = { Button: { onClick: "action" } };
|
|
38
|
+
const COMMON = "common_types.json#/$defs/";
|
|
39
|
+
const ref = (name) => ({ $ref: `${COMMON}${name}` });
|
|
40
|
+
/**
|
|
41
|
+
* The v0.9 common types the schemas reference, in their v0.9 shapes, so
|
|
42
|
+
* every `common_types.json#/$defs/<Name>` ref resolves within the payload.
|
|
43
|
+
*/
|
|
44
|
+
const V09_COMMON_TYPES = {
|
|
45
|
+
ComponentId: {
|
|
46
|
+
type: "string",
|
|
47
|
+
description: "The unique identifier for a component, used for both definitions and references within the same surface."
|
|
48
|
+
},
|
|
49
|
+
ComponentCommon: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
id: ref("ComponentId"),
|
|
53
|
+
accessibility: ref("AccessibilityAttributes")
|
|
54
|
+
},
|
|
55
|
+
required: ["id"]
|
|
56
|
+
},
|
|
57
|
+
AccessibilityAttributes: {
|
|
58
|
+
type: "object",
|
|
59
|
+
description: "Attributes to enhance accessibility when using assistive technologies like screen readers.",
|
|
60
|
+
properties: {
|
|
61
|
+
label: ref("DynamicString"),
|
|
62
|
+
description: ref("DynamicString")
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
ChildList: { oneOf: [{
|
|
66
|
+
type: "array",
|
|
67
|
+
items: ref("ComponentId"),
|
|
68
|
+
description: "A static list of child component IDs."
|
|
69
|
+
}, {
|
|
70
|
+
type: "object",
|
|
71
|
+
description: "A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",
|
|
72
|
+
properties: {
|
|
73
|
+
componentId: ref("ComponentId"),
|
|
74
|
+
path: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "The path to the list of component property objects in the data model."
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
required: ["componentId", "path"],
|
|
80
|
+
additionalProperties: false
|
|
81
|
+
}] },
|
|
82
|
+
DataBinding: {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: { path: {
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "A JSON Pointer path to a value in the data model."
|
|
87
|
+
} },
|
|
88
|
+
required: ["path"],
|
|
89
|
+
additionalProperties: false
|
|
90
|
+
},
|
|
91
|
+
FunctionCall: {
|
|
92
|
+
type: "object",
|
|
93
|
+
description: "Invokes a named function on the client.",
|
|
94
|
+
properties: {
|
|
95
|
+
call: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "The name of the function to call."
|
|
98
|
+
},
|
|
99
|
+
args: {
|
|
100
|
+
type: "object",
|
|
101
|
+
description: "Arguments passed to the function.",
|
|
102
|
+
additionalProperties: ref("DynamicValue")
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
required: ["call"],
|
|
106
|
+
additionalProperties: false
|
|
107
|
+
},
|
|
108
|
+
DynamicValue: {
|
|
109
|
+
description: "A value that can be a literal, a path, or a function call returning any type.",
|
|
110
|
+
anyOf: [
|
|
111
|
+
{ type: "string" },
|
|
112
|
+
{ type: "number" },
|
|
113
|
+
{ type: "boolean" },
|
|
114
|
+
{ type: "array" },
|
|
115
|
+
ref("DataBinding"),
|
|
116
|
+
ref("FunctionCall")
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
DynamicString: { anyOf: [
|
|
120
|
+
{ type: "string" },
|
|
121
|
+
ref("DataBinding"),
|
|
122
|
+
ref("FunctionCall")
|
|
123
|
+
] },
|
|
124
|
+
DynamicNumber: { anyOf: [
|
|
125
|
+
{ type: "number" },
|
|
126
|
+
ref("DataBinding"),
|
|
127
|
+
ref("FunctionCall")
|
|
128
|
+
] },
|
|
129
|
+
DynamicBoolean: { anyOf: [
|
|
130
|
+
{ type: "boolean" },
|
|
131
|
+
ref("DataBinding"),
|
|
132
|
+
ref("FunctionCall")
|
|
133
|
+
] },
|
|
134
|
+
DynamicStringList: { anyOf: [
|
|
135
|
+
{
|
|
136
|
+
type: "array",
|
|
137
|
+
items: { type: "string" }
|
|
138
|
+
},
|
|
139
|
+
ref("DataBinding"),
|
|
140
|
+
ref("FunctionCall")
|
|
141
|
+
] },
|
|
142
|
+
Action: {
|
|
143
|
+
description: "Defines an interaction handler that can either trigger a server-side event or execute a local client-side function.",
|
|
144
|
+
oneOf: [{
|
|
145
|
+
type: "object",
|
|
146
|
+
description: "Triggers a server-side event.",
|
|
147
|
+
properties: { event: {
|
|
148
|
+
type: "object",
|
|
149
|
+
properties: {
|
|
150
|
+
name: {
|
|
151
|
+
type: "string",
|
|
152
|
+
description: "The name of the action to be dispatched to the server."
|
|
153
|
+
},
|
|
154
|
+
context: {
|
|
155
|
+
type: "object",
|
|
156
|
+
description: "A JSON object containing the key-value pairs for the action context. Values can be literals or paths.",
|
|
157
|
+
additionalProperties: ref("DynamicValue")
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
required: ["name"],
|
|
161
|
+
additionalProperties: false
|
|
162
|
+
} },
|
|
163
|
+
required: ["event"],
|
|
164
|
+
additionalProperties: false
|
|
165
|
+
}, {
|
|
166
|
+
type: "object",
|
|
167
|
+
description: "Executes a local client-side function.",
|
|
168
|
+
properties: { functionCall: ref("FunctionCall") },
|
|
169
|
+
required: ["functionCall"],
|
|
170
|
+
additionalProperties: false
|
|
171
|
+
}]
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
function isRecord(value) {
|
|
175
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
176
|
+
}
|
|
177
|
+
/** 1.0 binding and call syntax in a description, written the v0.9 way. */
|
|
178
|
+
function v09Text(text) {
|
|
179
|
+
return text.replaceAll("\"@path\"", "\"path\"").replaceAll("\"@call\"", "\"call\"");
|
|
180
|
+
}
|
|
181
|
+
/** The v0.9 dynamic type of a literal schema that is just a primitive type. */
|
|
182
|
+
const DYNAMIC_TYPES = {
|
|
183
|
+
string: "DynamicString",
|
|
184
|
+
number: "DynamicNumber",
|
|
185
|
+
boolean: "DynamicBoolean"
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* A prop value as v0.9 states it: its literal schema, a `{ path }` binding
|
|
189
|
+
* or a `{ call }` function call. A plain string, number, boolean or string
|
|
190
|
+
* list is the v0.9 `Dynamic*` type of the same meaning. A component
|
|
191
|
+
* reference stays one.
|
|
192
|
+
*
|
|
193
|
+
* Only the prop itself is made dynamic, as in the v0.9 basic catalog: the
|
|
194
|
+
* 1.0 catalog marks every nested value dynamic too, which makes the
|
|
195
|
+
* standard catalog several times larger.
|
|
196
|
+
*/
|
|
197
|
+
function dynamicValue(schema) {
|
|
198
|
+
if (!isRecord(schema)) return ref("DynamicValue");
|
|
199
|
+
const v09 = v09Schema(schema);
|
|
200
|
+
if ((0, _copilotkit_shared.childRefKind)(schema)) return v09;
|
|
201
|
+
const { description, ...literal } = v09;
|
|
202
|
+
const text = typeof description === "string" ? { description } : {};
|
|
203
|
+
const keys = Object.keys(literal);
|
|
204
|
+
if (keys.length === 1 && typeof literal.type === "string") {
|
|
205
|
+
const dynamic = DYNAMIC_TYPES[literal.type];
|
|
206
|
+
if (dynamic) return {
|
|
207
|
+
...ref(dynamic),
|
|
208
|
+
...text
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const items = literal.items;
|
|
212
|
+
if (keys.length === 2 && literal.type === "array" && isRecord(items) && Object.keys(items).length === 1 && items.type === "string") return {
|
|
213
|
+
...ref("DynamicStringList"),
|
|
214
|
+
...text
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
...text,
|
|
218
|
+
anyOf: [
|
|
219
|
+
literal,
|
|
220
|
+
ref("DataBinding"),
|
|
221
|
+
ref("FunctionCall")
|
|
222
|
+
]
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/** A copy of a schema, with its descriptions written the v0.9 way. */
|
|
226
|
+
function v09Schema(value) {
|
|
227
|
+
if (Array.isArray(value)) return value.map(v09Schema);
|
|
228
|
+
if (!isRecord(value)) return value;
|
|
229
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, key === "description" && typeof child === "string" ? v09Text(child) : v09Schema(child)]));
|
|
230
|
+
}
|
|
231
|
+
const mapValues = (record, transform) => Object.fromEntries(Object.entries(record).map(([key, value]) => [key, transform(value)]));
|
|
232
|
+
/** An object schema with each of its properties made dynamic. */
|
|
233
|
+
function dynamicProperties(schema) {
|
|
234
|
+
const result = v09Schema(schema);
|
|
235
|
+
if (isRecord(schema.properties)) result.properties = mapValues(schema.properties, dynamicValue);
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Local refs (`#/...`) of a props schema, pointing to where the schema is
|
|
240
|
+
* embedded in the payload instead of to the root of the props schema.
|
|
241
|
+
*/
|
|
242
|
+
function rebaseRefs(value, base) {
|
|
243
|
+
if (Array.isArray(value)) return value.map((item) => rebaseRefs(item, base));
|
|
244
|
+
if (!isRecord(value)) return value;
|
|
245
|
+
const result = mapValues(value, (child) => rebaseRefs(child, base));
|
|
246
|
+
const target = result.$ref;
|
|
247
|
+
if (target === "#") result.$ref = base;
|
|
248
|
+
else if (typeof target === "string" && target.startsWith("#/")) result.$ref = `${base}${target.slice(1)}`;
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
/** A JSON Pointer segment: `acme/Card` is `acme~1Card`. */
|
|
252
|
+
function pointerSegment(name) {
|
|
253
|
+
return name.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* One component in the v0.9 inline catalog format: `ComponentCommon` and
|
|
257
|
+
* the props, events and slots of the 1.0 manifest under their v0.9 names.
|
|
258
|
+
*/
|
|
259
|
+
function componentSchema(name, manifest, renames) {
|
|
260
|
+
const v09Name = (key) => renames[key] ?? key;
|
|
261
|
+
const { properties, required, description, $defs, definitions } = manifest.props;
|
|
262
|
+
const fields = {};
|
|
263
|
+
for (const [key, schema] of Object.entries(isRecord(properties) ? properties : {})) fields[key] = dynamicValue(schema);
|
|
264
|
+
for (const [key, event] of Object.entries(manifest.events ?? {})) fields[key] = {
|
|
265
|
+
...ref("Action"),
|
|
266
|
+
...event.description ? { description: v09Text(event.description) } : {}
|
|
267
|
+
};
|
|
268
|
+
for (const [key, kind] of Object.entries(manifest.slots ?? {})) fields[key] = ref(kind === "single" ? "ComponentId" : "ChildList");
|
|
269
|
+
const order = [...manifest.parameterOrder ?? [], ...Object.keys(fields)];
|
|
270
|
+
const ordered = { component: { const: name } };
|
|
271
|
+
for (const key of order) if (Object.hasOwn(fields, key)) ordered[v09Name(key)] = fields[key];
|
|
272
|
+
const defs = {
|
|
273
|
+
...isRecord($defs) ? { $defs: v09Schema($defs) } : {},
|
|
274
|
+
...isRecord(definitions) ? { definitions: v09Schema(definitions) } : {}
|
|
275
|
+
};
|
|
276
|
+
const text = manifest.description ?? description;
|
|
277
|
+
const body = rebaseRefs({
|
|
278
|
+
properties: ordered,
|
|
279
|
+
required: ["component", ...Array.isArray(required) ? required.filter((key) => typeof key === "string").map(v09Name) : []],
|
|
280
|
+
...defs
|
|
281
|
+
}, `#/components/${pointerSegment(name)}/allOf/1`);
|
|
282
|
+
return {
|
|
283
|
+
...typeof text === "string" ? { description: v09Text(text) } : {},
|
|
284
|
+
allOf: [ref("ComponentCommon"), body]
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** A function in the v0.9 inline catalog `functions` format. */
|
|
288
|
+
function functionSchema(name, description, returnType, parameters) {
|
|
289
|
+
return {
|
|
290
|
+
name,
|
|
291
|
+
...description ? { description: v09Text(description) } : {},
|
|
292
|
+
returnType: returnType === "validationResult" ? "boolean" : returnType ?? "any",
|
|
293
|
+
parameters
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The functions a v0.9 `{ call }` may name: the basic ones, which v0.9 names
|
|
298
|
+
* the same, then the app functions the renderer may call.
|
|
299
|
+
*/
|
|
300
|
+
function catalogFunctions(functions) {
|
|
301
|
+
const result = Object.entries(_copilotkit_shared.A2UI_BASIC_FUNCTIONS).filter(([name]) => !Object.hasOwn(functions, name)).map(([name, info]) => functionSchema(name, info.description, info.returnType, (0, _copilotkit_shared_generative_ui.argsSchemaFromSignature)(info.parameters)));
|
|
302
|
+
for (const [name, fn] of Object.entries(functions)) {
|
|
303
|
+
if (!(0, _copilotkit_shared.functionCallers)(fn).renderer) continue;
|
|
304
|
+
result.push(functionSchema(name, fn.description, fn.returnType, dynamicProperties(fn.parameters)));
|
|
305
|
+
}
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The capabilities entry: the catalog id, then the components beyond the
|
|
310
|
+
* v0.9 basic catalog, by name. Their schemas are in the schema entry, so
|
|
311
|
+
* they are not repeated here.
|
|
312
|
+
*/
|
|
313
|
+
function capabilitiesValue(catalogId, names) {
|
|
314
|
+
const lines = ["Available A2UI catalog:"];
|
|
315
|
+
if (names === void 0) {
|
|
316
|
+
lines.push(`- ${catalogId}`);
|
|
317
|
+
return lines.join("\n");
|
|
318
|
+
}
|
|
319
|
+
const extra = names.filter((name) => !V09_BASIC_COMPONENTS.has(name));
|
|
320
|
+
const nameSet = new Set(names);
|
|
321
|
+
const isSuperset = [...V09_BASIC_COMPONENTS].every((name) => nameSet.has(name));
|
|
322
|
+
if (catalogId === A2UI_V09_BASIC_CATALOG_ID && isSuperset && !extra.length) {
|
|
323
|
+
lines.push(`- ${catalogId} (basic catalog)`);
|
|
324
|
+
return lines.join("\n");
|
|
325
|
+
}
|
|
326
|
+
lines.push(`- ${catalogId}`);
|
|
327
|
+
if (isSuperset) lines.push(" Extends the basic catalog with all standard components plus:");
|
|
328
|
+
else {
|
|
329
|
+
lines.push(" Custom catalog (does NOT include all basic components).");
|
|
330
|
+
lines.push(" Custom components:");
|
|
331
|
+
}
|
|
332
|
+
for (const name of extra) lines.push(` - ${name}`);
|
|
333
|
+
return lines.join("\n");
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Builds the A2UI v0.9 catalog context for a run, from the generative UI
|
|
337
|
+
* envelope the client sent (`forwardedProps.copilotkit.ui`).
|
|
338
|
+
*
|
|
339
|
+
* The entries are the ones the v0.9 client sent, with the same descriptions:
|
|
340
|
+
* the catalog capabilities, the component schema (the v0.9 inline catalog
|
|
341
|
+
* format that `A2UIMiddleware` reads, and replaces when it has a server
|
|
342
|
+
* schema), and the v0.9 generation and design guidelines. Without the
|
|
343
|
+
* component schemas in the envelope, only the capabilities entry is built.
|
|
344
|
+
*
|
|
345
|
+
* The components are the v0.9 basic ones of the standard catalog and the
|
|
346
|
+
* UI's own components: the other standard components (Title, Chart, ...)
|
|
347
|
+
* are left out, as a v0.9 agent never knew them and they would make the
|
|
348
|
+
* schema about three times larger. A component of the UI's own that has the
|
|
349
|
+
* name of a standard component counts as the standard one.
|
|
350
|
+
*
|
|
351
|
+
* Components keep their names. Props, events and slots keep their 1.0 names
|
|
352
|
+
* except for `V10_TO_V09_PROP_NAMES` on standard components;
|
|
353
|
+
* values take a v0.9 `{ path }` binding or `{ call }` function call, events
|
|
354
|
+
* take a v0.9 action, and slots a v0.9 `ComponentId` or `ChildList`.
|
|
355
|
+
*
|
|
356
|
+
* The catalog id is the v0.9 basic catalog id when the UI includes the 1.0
|
|
357
|
+
* standard catalog, which has every v0.9 basic component: v0.9 agents and
|
|
358
|
+
* prompts already use that id, and `A2UIMiddleware` stamps the id of the
|
|
359
|
+
* schema entry into the surfaces it creates. Otherwise it is the id of the
|
|
360
|
+
* UI, since the basic id would promise components the UI does not have.
|
|
361
|
+
*
|
|
362
|
+
* @param input - The run input.
|
|
363
|
+
* @returns The catalog id the v0.9 agent should use and the context
|
|
364
|
+
* entries, or `undefined` when the run has no generative UI envelope.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* const v09 = buildA2UIV09CatalogContext(input);
|
|
369
|
+
* if (v09) input = { ...input, context: [...input.context, ...v09.context] };
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
function buildA2UIV09CatalogContext(input) {
|
|
373
|
+
const envelope = (0, _copilotkit_shared.readCopilotKitUIEnvelope)(input.forwardedProps);
|
|
374
|
+
if (!envelope) return void 0;
|
|
375
|
+
const manifest = (0, _copilotkit_shared.envelopeToManifest)(envelope);
|
|
376
|
+
const extendsStandard = (manifest.catalogIds ?? [manifest.catalogId]).includes(_copilotkit_shared_generative_ui.STANDARD_CATALOG_ID);
|
|
377
|
+
const catalogId = extendsStandard ? A2UI_V09_BASIC_CATALOG_ID : manifest.catalogId;
|
|
378
|
+
if (!manifest.hasComponents) return {
|
|
379
|
+
catalogId,
|
|
380
|
+
context: [{
|
|
381
|
+
description: CAPABILITIES_CONTEXT_DESCRIPTION,
|
|
382
|
+
value: capabilitiesValue(catalogId, void 0)
|
|
383
|
+
}]
|
|
384
|
+
};
|
|
385
|
+
const components = {};
|
|
386
|
+
for (const [name, component] of Object.entries(manifest.components)) {
|
|
387
|
+
const isStandard = extendsStandard && Object.hasOwn(_copilotkit_shared_generative_ui.standardDeclarations, name);
|
|
388
|
+
if (isStandard && !V09_BASIC_COMPONENTS.has(name)) continue;
|
|
389
|
+
components[name] = componentSchema(name, component, isStandard && V10_TO_V09_PROP_NAMES[name] || {});
|
|
390
|
+
}
|
|
391
|
+
const schema = {
|
|
392
|
+
catalogId,
|
|
393
|
+
components,
|
|
394
|
+
functions: catalogFunctions(manifest.functions),
|
|
395
|
+
"common_types.json": { $defs: V09_COMMON_TYPES }
|
|
396
|
+
};
|
|
397
|
+
return {
|
|
398
|
+
catalogId,
|
|
399
|
+
context: [
|
|
400
|
+
{
|
|
401
|
+
description: CAPABILITIES_CONTEXT_DESCRIPTION,
|
|
402
|
+
value: capabilitiesValue(catalogId, Object.keys(components))
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
description: _ag_ui_a2ui_middleware.A2UI_SCHEMA_CONTEXT_DESCRIPTION,
|
|
406
|
+
value: JSON.stringify(schema)
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
description: GENERATION_GUIDELINES_CONTEXT_DESCRIPTION,
|
|
410
|
+
value: _copilotkit_shared.A2UI_DEFAULT_GENERATION_GUIDELINES
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
description: DESIGN_GUIDELINES_CONTEXT_DESCRIPTION,
|
|
414
|
+
value: _copilotkit_shared.A2UI_DEFAULT_DESIGN_GUIDELINES
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
//#endregion
|
|
421
|
+
exports.buildA2UIV09CatalogContext = buildA2UIV09CatalogContext;
|
|
422
|
+
//# sourceMappingURL=a2ui-v09-catalog.cjs.map
|