veryfront 0.1.1237 → 0.1.1239
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/esm/cli/auth/login.d.ts +24 -2
- package/esm/cli/auth/login.d.ts.map +1 -1
- package/esm/cli/auth/login.js +444 -35
- package/esm/cli/commands/build/error-handler.d.ts.map +1 -1
- package/esm/cli/commands/build/error-handler.js +41 -3
- package/esm/cli/commands/build/handler.d.ts.map +1 -1
- package/esm/cli/commands/build/handler.js +1 -1
- package/esm/cli/commands/dev/command.d.ts.map +1 -1
- package/esm/cli/commands/dev/command.js +14 -1
- package/esm/cli/commands/dev/inference-status.d.ts +6 -0
- package/esm/cli/commands/dev/inference-status.d.ts.map +1 -1
- package/esm/cli/commands/dev/inference-status.js +14 -2
- package/esm/cli/commands/generate/command.d.ts.map +1 -1
- package/esm/cli/commands/generate/command.js +61 -0
- package/esm/cli/commands/init/init-command.d.ts.map +1 -1
- package/esm/cli/commands/init/init-command.js +23 -31
- package/esm/cli/commands/install/registry.d.ts.map +1 -1
- package/esm/cli/commands/install/registry.js +6 -9
- package/esm/cli/commands/login/command-help.d.ts.map +1 -1
- package/esm/cli/commands/login/command-help.js +3 -1
- package/esm/cli/commands/pull/command.d.ts +1 -0
- package/esm/cli/commands/pull/command.d.ts.map +1 -1
- package/esm/cli/commands/pull/command.js +49 -6
- package/esm/cli/commands/push/command-help.d.ts.map +1 -1
- package/esm/cli/commands/push/command-help.js +7 -0
- package/esm/cli/commands/push/command.d.ts +23 -12
- package/esm/cli/commands/push/command.d.ts.map +1 -1
- package/esm/cli/commands/push/command.js +461 -44
- package/esm/cli/commands/push/plan.d.ts +35 -0
- package/esm/cli/commands/push/plan.d.ts.map +1 -0
- package/esm/cli/commands/push/plan.js +96 -0
- package/esm/cli/commands/schedule/handler.d.ts +21 -2
- package/esm/cli/commands/schedule/handler.d.ts.map +1 -1
- package/esm/cli/commands/schedule/handler.js +74 -27
- package/esm/cli/commands/schema/command-help.js +1 -1
- package/esm/cli/commands/up/command.js +1 -1
- package/esm/cli/commands/webhook/handler.d.ts.map +1 -1
- package/esm/cli/commands/webhook/handler.js +3 -1
- package/esm/cli/router.d.ts.map +1 -1
- package/esm/cli/router.js +27 -5
- package/esm/cli/shared/args.d.ts +15 -1
- package/esm/cli/shared/args.d.ts.map +1 -1
- package/esm/cli/shared/args.js +56 -3
- package/esm/cli/shared/config.d.ts +11 -2
- package/esm/cli/shared/config.d.ts.map +1 -1
- package/esm/cli/shared/config.js +72 -27
- package/esm/cli/shared/project-creation.js +1 -1
- package/esm/cli/sync/state.d.ts +20 -0
- package/esm/cli/sync/state.d.ts.map +1 -0
- package/esm/cli/sync/state.js +193 -0
- package/esm/deno.js +2 -2
- package/esm/extensions/ext-llm-anthropic/src/anthropic-request-builder.d.ts.map +1 -1
- package/esm/extensions/ext-llm-anthropic/src/anthropic-request-builder.js +852 -21
- package/esm/extensions/ext-observability-sentry/src/policy.d.ts +2 -0
- package/esm/extensions/ext-observability-sentry/src/policy.d.ts.map +1 -1
- package/esm/extensions/ext-observability-sentry/src/policy.js +214 -3
- package/esm/src/agent/conversation/delegation-policy.d.ts +2 -0
- package/esm/src/agent/conversation/delegation-policy.d.ts.map +1 -1
- package/esm/src/agent/conversation/delegation-policy.js +13 -3
- package/esm/src/agent/conversation/hosted-terminal.d.ts.map +1 -1
- package/esm/src/agent/conversation/hosted-terminal.js +6 -2
- package/esm/src/agent/conversation/run-chunk-mirror.d.ts.map +1 -1
- package/esm/src/agent/conversation/run-chunk-mirror.js +14 -2
- package/esm/src/agent/factory.d.ts.map +1 -1
- package/esm/src/agent/factory.js +22 -11
- package/esm/src/agent/hosted/chat-runtime-tool-assembly.d.ts +2 -0
- package/esm/src/agent/hosted/chat-runtime-tool-assembly.d.ts.map +1 -1
- package/esm/src/agent/hosted/chat-runtime-tool-assembly.js +6 -1
- package/esm/src/agent/hosted/child-fork-execution-runner.d.ts +2 -1
- package/esm/src/agent/hosted/child-fork-execution-runner.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-fork-execution-runner.js +6 -3
- package/esm/src/agent/hosted/child-fork-step-message-preparation.d.ts +12 -3
- package/esm/src/agent/hosted/child-fork-step-message-preparation.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-fork-step-message-preparation.js +16 -3
- package/esm/src/agent/hosted/cloud-agent-chat-execution.d.ts +1 -1
- package/esm/src/agent/hosted/cloud-agent-chat-execution.d.ts.map +1 -1
- package/esm/src/agent/hosted/cloud-agent-chat-execution.js +3 -3
- package/esm/src/agent/hosted/cloud-agent-child-tools.d.ts +11 -0
- package/esm/src/agent/hosted/cloud-agent-child-tools.d.ts.map +1 -1
- package/esm/src/agent/hosted/cloud-agent-child-tools.js +2 -3
- package/esm/src/agent/hosted/cloud-agent-config.d.ts +1 -0
- package/esm/src/agent/hosted/cloud-agent-config.d.ts.map +1 -1
- package/esm/src/agent/hosted/cloud-runtime-system-messages.d.ts +16 -1
- package/esm/src/agent/hosted/cloud-runtime-system-messages.d.ts.map +1 -1
- package/esm/src/agent/hosted/cloud-runtime-system-messages.js +13 -3
- package/esm/src/agent/hosted/default-chat-runtime.d.ts +2 -1
- package/esm/src/agent/hosted/default-chat-runtime.d.ts.map +1 -1
- package/esm/src/agent/hosted/default-chat-runtime.js +18 -7
- package/esm/src/agent/hosted/default-invoke-agent-tool.d.ts +2 -1
- package/esm/src/agent/hosted/default-invoke-agent-tool.d.ts.map +1 -1
- package/esm/src/agent/hosted/default-invoke-agent-tool.js +11 -3
- package/esm/src/agent/hosted/default-project-steering-refresh.d.ts +2 -1
- package/esm/src/agent/hosted/default-project-steering-refresh.d.ts.map +1 -1
- package/esm/src/agent/hosted/default-project-steering-refresh.js +4 -1
- package/esm/src/agent/hosted/runtime-state-resolver.d.ts +6 -4
- package/esm/src/agent/hosted/runtime-state-resolver.d.ts.map +1 -1
- package/esm/src/agent/hosted/runtime-state-resolver.js +8 -11
- package/esm/src/agent/index.d.ts +3 -3
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/project/agent-runtime.d.ts.map +1 -1
- package/esm/src/agent/project/agent-runtime.js +6 -3
- package/esm/src/agent/runtime/agent-definition.d.ts +68 -66
- package/esm/src/agent/runtime/agent-definition.d.ts.map +1 -1
- package/esm/src/agent/runtime/agent-definition.js +15 -2
- package/esm/src/agent/runtime/agent-invocation-contract.d.ts +2 -0
- package/esm/src/agent/runtime/agent-invocation-contract.d.ts.map +1 -1
- package/esm/src/agent/runtime/agent-markdown-adapter.js +1 -1
- package/esm/src/agent/runtime/agent-runtime-step.d.ts +11 -5
- package/esm/src/agent/runtime/agent-runtime-step.d.ts.map +1 -1
- package/esm/src/agent/runtime/agent-runtime-step.js +23 -6
- package/esm/src/agent/runtime/call-context.d.ts +42 -11
- package/esm/src/agent/runtime/call-context.d.ts.map +1 -1
- package/esm/src/agent/runtime/call-context.js +480 -42
- package/esm/src/agent/runtime/chat-stream-handler.d.ts +18 -0
- package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.js +38 -18
- package/esm/src/agent/runtime/effective-agent-system.d.ts +13 -4
- package/esm/src/agent/runtime/effective-agent-system.d.ts.map +1 -1
- package/esm/src/agent/runtime/effective-agent-system.js +29 -0
- package/esm/src/agent/runtime/index.d.ts +1 -0
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +638 -53
- package/esm/src/agent/runtime/load-skill-tool.d.ts +33 -3
- package/esm/src/agent/runtime/load-skill-tool.d.ts.map +1 -1
- package/esm/src/agent/runtime/load-skill-tool.js +152 -21
- package/esm/src/agent/runtime/model-resolution.d.ts +3 -0
- package/esm/src/agent/runtime/model-resolution.d.ts.map +1 -1
- package/esm/src/agent/runtime/model-resolution.js +14 -0
- package/esm/src/agent/runtime/model-transport.d.ts +1 -0
- package/esm/src/agent/runtime/model-transport.d.ts.map +1 -1
- package/esm/src/agent/runtime/model-transport.js +5 -2
- package/esm/src/agent/runtime/run-runtime-context.d.ts +4 -0
- package/esm/src/agent/runtime/run-runtime-context.d.ts.map +1 -1
- package/esm/src/agent/runtime/run-runtime-context.js +9 -3
- package/esm/src/agent/runtime/runtime-tool-config.d.ts +1 -0
- package/esm/src/agent/runtime/runtime-tool-config.d.ts.map +1 -1
- package/esm/src/agent/runtime/skill-prompt.d.ts +3 -0
- package/esm/src/agent/runtime/skill-prompt.d.ts.map +1 -1
- package/esm/src/agent/runtime/skill-prompt.js +113 -25
- package/esm/src/agent/runtime/streamed-assistant-message.d.ts +22 -2
- package/esm/src/agent/runtime/streamed-assistant-message.d.ts.map +1 -1
- package/esm/src/agent/runtime/streamed-assistant-message.js +26 -5
- package/esm/src/agent/runtime/tool-inventory.d.ts.map +1 -1
- package/esm/src/agent/runtime/tool-inventory.js +13 -9
- package/esm/src/agent/runtime/tool-result-continuation.d.ts +4 -2
- package/esm/src/agent/runtime/tool-result-continuation.d.ts.map +1 -1
- package/esm/src/agent/runtime/tool-result-continuation.js +24 -20
- package/esm/src/agent/schemas/agent.schema.d.ts +2 -2
- package/esm/src/agent/service/runtime.js +1 -1
- package/esm/src/agent/streaming/fork-runtime-stream.d.ts +5 -4
- package/esm/src/agent/streaming/fork-runtime-stream.d.ts.map +1 -1
- package/esm/src/agent/types.d.ts +14 -1
- package/esm/src/agent/types.d.ts.map +1 -1
- package/esm/src/chat/chat-ui-message-helpers.d.ts.map +1 -1
- package/esm/src/chat/chat-ui-message-helpers.js +75 -16
- package/esm/src/config/loader.d.ts.map +1 -1
- package/esm/src/config/loader.js +37 -1
- package/esm/src/errors/catalog/build-errors.d.ts.map +1 -1
- package/esm/src/errors/catalog/build-errors.js +14 -0
- package/esm/src/errors/error-registry/build.d.ts +2 -0
- package/esm/src/errors/error-registry/build.d.ts.map +1 -1
- package/esm/src/errors/error-registry/build.js +8 -0
- package/esm/src/errors/error-registry/deploy.d.ts +4 -0
- package/esm/src/errors/error-registry/deploy.d.ts.map +1 -1
- package/esm/src/errors/error-registry/deploy.js +16 -0
- package/esm/src/errors/error-registry.d.ts +3 -0
- package/esm/src/errors/error-registry.d.ts.map +1 -1
- package/esm/src/errors/index.d.ts +2 -1
- package/esm/src/errors/index.d.ts.map +1 -1
- package/esm/src/errors/index.js +4 -3
- package/esm/src/errors/tenant-classification.d.ts +25 -0
- package/esm/src/errors/tenant-classification.d.ts.map +1 -0
- package/esm/src/errors/tenant-classification.js +61 -0
- package/esm/src/extensions/builtin-extensions.d.ts +10 -15
- package/esm/src/extensions/builtin-extensions.d.ts.map +1 -1
- package/esm/src/extensions/builtin-extensions.js +32 -26
- package/esm/src/extensions/deferred-extension.d.ts +4 -4
- package/esm/src/extensions/deferred-extension.js +4 -4
- package/esm/src/extensions/index.d.ts +1 -0
- package/esm/src/extensions/index.d.ts.map +1 -1
- package/esm/src/extensions/index.js +1 -0
- package/esm/src/html/hydration-script-builder/hydration-runtime.generated.js +1 -1
- package/esm/src/integrations/_data.d.ts.map +1 -1
- package/esm/src/integrations/_data.js +6 -0
- package/esm/src/integrations/schema.d.ts +8 -0
- package/esm/src/integrations/schema.d.ts.map +1 -1
- package/esm/src/integrations/schema.js +3 -0
- package/esm/src/integrations/types.d.ts +2 -0
- package/esm/src/integrations/types.d.ts.map +1 -1
- package/esm/src/internal-agents/run-stream.d.ts.map +1 -1
- package/esm/src/internal-agents/run-stream.js +35 -20
- package/esm/src/internal-agents/run-system-prompt.d.ts +7 -2
- package/esm/src/internal-agents/run-system-prompt.d.ts.map +1 -1
- package/esm/src/internal-agents/run-system-prompt.js +19 -13
- package/esm/src/internal-agents/schema.d.ts +2 -0
- package/esm/src/internal-agents/schema.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/loader.js +2 -18
- package/esm/src/modules/react-loader/ssr-module-loader/ssr-dependency-validator.d.ts +11 -0
- package/esm/src/modules/react-loader/ssr-module-loader/ssr-dependency-validator.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/ssr-dependency-validator.js +53 -6
- package/esm/src/observability/application-error-contract.d.ts +4 -0
- package/esm/src/observability/application-error-contract.d.ts.map +1 -1
- package/esm/src/observability/application-errors.d.ts.map +1 -1
- package/esm/src/observability/application-errors.js +64 -3
- package/esm/src/platform/adapters/runtime/deno/http-server.d.ts.map +1 -1
- package/esm/src/platform/adapters/runtime/deno/http-server.js +2 -10
- package/esm/src/platform/adapters/runtime/shared/request-peer.d.ts +14 -0
- package/esm/src/platform/adapters/runtime/shared/request-peer.d.ts.map +1 -1
- package/esm/src/platform/adapters/runtime/shared/request-peer.js +82 -0
- package/esm/src/platform/compat/http/pinned-fetch.d.ts +1 -1
- package/esm/src/provider/runtime-loader/provider-http.d.ts +5 -1
- package/esm/src/provider/runtime-loader/provider-http.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader/provider-http.js +55 -17
- package/esm/src/provider/shared/index.d.ts +1 -0
- package/esm/src/provider/shared/index.d.ts.map +1 -1
- package/esm/src/provider/shared/index.js +2 -0
- package/esm/src/provider/types.d.ts +1 -0
- package/esm/src/provider/types.d.ts.map +1 -1
- package/esm/src/react/components/ui/adapter/builtin/combobox.d.ts +3 -0
- package/esm/src/react/components/ui/adapter/builtin/combobox.d.ts.map +1 -0
- package/esm/src/react/components/ui/adapter/builtin/combobox.js +204 -0
- package/esm/src/react/components/ui/adapter/builtin/dialog.d.ts +3 -0
- package/esm/src/react/components/ui/adapter/builtin/dialog.d.ts.map +1 -0
- package/esm/src/react/components/ui/adapter/builtin/dialog.js +20 -0
- package/esm/src/react/components/ui/adapter/builtin/drawer.d.ts +3 -0
- package/esm/src/react/components/ui/adapter/builtin/drawer.d.ts.map +1 -0
- package/esm/src/react/components/ui/adapter/builtin/drawer.js +21 -0
- package/esm/src/react/components/ui/adapter/builtin/index.d.ts.map +1 -1
- package/esm/src/react/components/ui/adapter/builtin/index.js +10 -0
- package/esm/src/react/components/ui/adapter/builtin/popover.d.ts +3 -0
- package/esm/src/react/components/ui/adapter/builtin/popover.d.ts.map +1 -0
- package/esm/src/react/components/ui/adapter/builtin/popover.js +28 -0
- package/esm/src/react/components/ui/adapter/builtin/tabs.d.ts +3 -0
- package/esm/src/react/components/ui/adapter/builtin/tabs.d.ts.map +1 -0
- package/esm/src/react/components/ui/adapter/builtin/tabs.js +73 -0
- package/esm/src/react/components/ui/adapter/context.d.ts.map +1 -1
- package/esm/src/react/components/ui/adapter/context.js +10 -0
- package/esm/src/react/components/ui/adapter/contract.d.ts +212 -0
- package/esm/src/react/components/ui/adapter/contract.d.ts.map +1 -1
- package/esm/src/react/components/ui/adapter/token-scope.d.ts +24 -0
- package/esm/src/react/components/ui/adapter/token-scope.d.ts.map +1 -0
- package/esm/src/react/components/ui/adapter/token-scope.js +26 -0
- package/esm/src/react/components/ui/alert-dialog.d.ts +101 -0
- package/esm/src/react/components/ui/alert-dialog.d.ts.map +1 -0
- package/esm/src/react/components/ui/alert-dialog.js +181 -0
- package/esm/src/react/components/ui/aspect-ratio.d.ts +18 -0
- package/esm/src/react/components/ui/aspect-ratio.d.ts.map +1 -0
- package/esm/src/react/components/ui/aspect-ratio.js +13 -0
- package/esm/src/react/components/ui/autocomplete.d.ts +67 -0
- package/esm/src/react/components/ui/autocomplete.d.ts.map +1 -0
- package/esm/src/react/components/ui/autocomplete.js +59 -0
- package/esm/src/react/components/ui/breadcrumb.d.ts +86 -0
- package/esm/src/react/components/ui/breadcrumb.d.ts.map +1 -0
- package/esm/src/react/components/ui/breadcrumb.js +67 -0
- package/esm/src/react/components/ui/calendar.d.ts +40 -0
- package/esm/src/react/components/ui/calendar.d.ts.map +1 -0
- package/esm/src/react/components/ui/calendar.js +170 -0
- package/esm/src/react/components/ui/combobox.d.ts +74 -0
- package/esm/src/react/components/ui/combobox.d.ts.map +1 -0
- package/esm/src/react/components/ui/combobox.js +100 -0
- package/esm/src/react/components/ui/context-menu.d.ts +116 -0
- package/esm/src/react/components/ui/context-menu.d.ts.map +1 -0
- package/esm/src/react/components/ui/context-menu.js +168 -0
- package/esm/src/react/components/ui/date-picker.d.ts +69 -0
- package/esm/src/react/components/ui/date-picker.d.ts.map +1 -0
- package/esm/src/react/components/ui/date-picker.js +96 -0
- package/esm/src/react/components/ui/dialog.d.ts +41 -11
- package/esm/src/react/components/ui/dialog.d.ts.map +1 -1
- package/esm/src/react/components/ui/dialog.js +47 -28
- package/esm/src/react/components/ui/drawer.d.ts +31 -8
- package/esm/src/react/components/ui/drawer.d.ts.map +1 -1
- package/esm/src/react/components/ui/drawer.js +33 -22
- package/esm/src/react/components/ui/dropdown-menu.d.ts.map +1 -1
- package/esm/src/react/components/ui/dropdown-menu.js +7 -75
- package/esm/src/react/components/ui/field.d.ts +70 -0
- package/esm/src/react/components/ui/field.d.ts.map +1 -0
- package/esm/src/react/components/ui/field.js +161 -0
- package/esm/src/react/components/ui/file-type.d.ts +9 -8
- package/esm/src/react/components/ui/file-type.d.ts.map +1 -1
- package/esm/src/react/components/ui/file-type.js +8 -8
- package/esm/src/react/components/ui/hover-card.d.ts +82 -0
- package/esm/src/react/components/ui/hover-card.d.ts.map +1 -0
- package/esm/src/react/components/ui/hover-card.js +140 -0
- package/esm/src/react/components/ui/index.d.ts +23 -2
- package/esm/src/react/components/ui/index.d.ts.map +1 -1
- package/esm/src/react/components/ui/index.js +21 -0
- package/esm/src/react/components/ui/input-otp.d.ts +37 -0
- package/esm/src/react/components/ui/input-otp.d.ts.map +1 -0
- package/esm/src/react/components/ui/input-otp.js +42 -0
- package/esm/src/react/components/ui/menu-keyboard.d.ts +8 -0
- package/esm/src/react/components/ui/menu-keyboard.d.ts.map +1 -0
- package/esm/src/react/components/ui/menu-keyboard.js +76 -0
- package/esm/src/react/components/ui/menubar.d.ts +98 -0
- package/esm/src/react/components/ui/menubar.d.ts.map +1 -0
- package/esm/src/react/components/ui/menubar.js +173 -0
- package/esm/src/react/components/ui/meter.d.ts +45 -0
- package/esm/src/react/components/ui/meter.d.ts.map +1 -0
- package/esm/src/react/components/ui/meter.js +59 -0
- package/esm/src/react/components/ui/modal-surface.d.ts +7 -1
- package/esm/src/react/components/ui/modal-surface.d.ts.map +1 -1
- package/esm/src/react/components/ui/modal-surface.js +23 -6
- package/esm/src/react/components/ui/navigation-menu.d.ts +101 -0
- package/esm/src/react/components/ui/navigation-menu.d.ts.map +1 -0
- package/esm/src/react/components/ui/navigation-menu.js +195 -0
- package/esm/src/react/components/ui/number-field.d.ts +46 -0
- package/esm/src/react/components/ui/number-field.d.ts.map +1 -0
- package/esm/src/react/components/ui/number-field.js +121 -0
- package/esm/src/react/components/ui/pagination.d.ts +77 -0
- package/esm/src/react/components/ui/pagination.d.ts.map +1 -0
- package/esm/src/react/components/ui/pagination.js +62 -0
- package/esm/src/react/components/ui/popover.d.ts +42 -13
- package/esm/src/react/components/ui/popover.d.ts.map +1 -1
- package/esm/src/react/components/ui/popover.js +25 -12
- package/esm/src/react/components/ui/scroll-area.d.ts +38 -0
- package/esm/src/react/components/ui/scroll-area.d.ts.map +1 -0
- package/esm/src/react/components/ui/scroll-area.js +35 -0
- package/esm/src/react/components/ui/separator.d.ts +20 -0
- package/esm/src/react/components/ui/separator.d.ts.map +1 -0
- package/esm/src/react/components/ui/separator.js +13 -0
- package/esm/src/react/components/ui/slider.d.ts +44 -0
- package/esm/src/react/components/ui/slider.d.ts.map +1 -0
- package/esm/src/react/components/ui/slider.js +46 -0
- package/esm/src/react/components/ui/status.d.ts +6 -5
- package/esm/src/react/components/ui/status.d.ts.map +1 -1
- package/esm/src/react/components/ui/status.js +4 -4
- package/esm/src/react/components/ui/tabs.d.ts +32 -9
- package/esm/src/react/components/ui/tabs.d.ts.map +1 -1
- package/esm/src/react/components/ui/tabs.js +46 -22
- package/esm/src/react/components/ui/toggle.d.ts +26 -0
- package/esm/src/react/components/ui/toggle.d.ts.map +1 -0
- package/esm/src/react/components/ui/toggle.js +29 -0
- package/esm/src/react/components/ui/use-isomorphic-layout-effect.d.ts +2 -1
- package/esm/src/react/components/ui/use-isomorphic-layout-effect.d.ts.map +1 -1
- package/esm/src/react/components/ui/use-isomorphic-layout-effect.js +6 -3
- package/esm/src/rendering/chunk-optimizer/source-imports.d.ts.map +1 -1
- package/esm/src/rendering/chunk-optimizer/source-imports.js +4 -114
- package/esm/src/rendering/orchestrator/css-candidate-manifest.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/css-candidate-manifest.js +30 -1
- package/esm/src/rendering/orchestrator/module-loader/build-failure.d.ts +10 -0
- package/esm/src/rendering/orchestrator/module-loader/build-failure.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/build-failure.js +50 -3
- package/esm/src/rendering/orchestrator/module-loader/dependency-resolver.d.ts +2 -0
- package/esm/src/rendering/orchestrator/module-loader/dependency-resolver.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/dependency-resolver.js +21 -6
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts +2 -1
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/index.js +190 -7
- package/esm/src/rendering/orchestrator/module-loader/module-persistence.d.ts +4 -0
- package/esm/src/rendering/orchestrator/module-loader/module-persistence.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/module-persistence.js +374 -7
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +12 -1
- package/esm/src/runs/runs-client.d.ts +2 -4
- package/esm/src/runs/runs-client.d.ts.map +1 -1
- package/esm/src/runs/schemas.d.ts +18 -8
- package/esm/src/runs/schemas.d.ts.map +1 -1
- package/esm/src/runs/schemas.js +26 -0
- package/esm/src/runtime/model-call-context.d.ts +6 -1
- package/esm/src/runtime/model-call-context.d.ts.map +1 -1
- package/esm/src/runtime/runtime-bridge.d.ts.map +1 -1
- package/esm/src/runtime/runtime-bridge.js +133 -15
- package/esm/src/schedule/factory.d.ts +8 -2
- package/esm/src/schedule/factory.d.ts.map +1 -1
- package/esm/src/schedule/factory.js +0 -8
- package/esm/src/schedule/index.d.ts +10 -1
- package/esm/src/schedule/index.d.ts.map +1 -1
- package/esm/src/schedule/index.js +9 -0
- package/esm/src/schedule/types.d.ts +30 -11
- package/esm/src/schedule/types.d.ts.map +1 -1
- package/esm/src/schedule/validation.d.ts +17 -0
- package/esm/src/schedule/validation.d.ts.map +1 -1
- package/esm/src/schedule/validation.js +93 -5
- package/esm/src/security/sandbox/worker-pool.d.ts.map +1 -1
- package/esm/src/security/sandbox/worker-pool.js +6 -1
- package/esm/src/server/bootstrap.d.ts.map +1 -1
- package/esm/src/server/bootstrap.js +6 -0
- package/esm/src/server/dev-server/index.d.ts +1 -1
- package/esm/src/server/dev-server/index.d.ts.map +1 -1
- package/esm/src/server/dev-server/server.d.ts +7 -3
- package/esm/src/server/dev-server/server.d.ts.map +1 -1
- package/esm/src/server/dev-server/server.js +12 -3
- package/esm/src/server/dev-server/types.d.ts +7 -1
- package/esm/src/server/dev-server/types.d.ts.map +1 -1
- package/esm/src/server/dev-server.d.ts +1 -1
- package/esm/src/server/dev-server.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/framework-candidates.generated.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/framework-candidates.generated.js +2509 -34
- package/esm/src/server/handlers/dev/projects/index.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/projects/index.js +3 -0
- package/esm/src/server/handlers/request/agent-stream.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/agent-stream.handler.js +29 -24
- package/esm/src/server/index.d.ts +3 -3
- package/esm/src/server/index.d.ts.map +1 -1
- package/esm/src/server/index.js +10 -5
- package/esm/src/server/node-handler.d.ts.map +1 -1
- package/esm/src/server/node-handler.js +4 -1
- package/esm/src/server/production-server.d.ts.map +1 -1
- package/esm/src/server/production-server.js +2 -1
- package/esm/src/server/project-env/cache.d.ts +17 -0
- package/esm/src/server/project-env/cache.d.ts.map +1 -1
- package/esm/src/server/project-env/cache.js +78 -2
- package/esm/src/server/project-env/fetcher.d.ts.map +1 -1
- package/esm/src/server/project-env/fetcher.js +24 -14
- package/esm/src/server/project-env/index.d.ts +1 -1
- package/esm/src/server/project-env/index.d.ts.map +1 -1
- package/esm/src/server/project-env/index.js +1 -1
- package/esm/src/server/project-env/internal-authorization.d.ts +7 -0
- package/esm/src/server/project-env/internal-authorization.d.ts.map +1 -0
- package/esm/src/server/project-env/internal-authorization.js +32 -0
- package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/index.js +1 -1
- package/esm/src/server/runtime-handler/projects-handler.d.ts +1 -1
- package/esm/src/server/runtime-handler/projects-handler.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/projects-handler.js +4 -2
- package/esm/src/transforms/esm/http-bundler.d.ts.map +1 -1
- package/esm/src/transforms/esm/http-bundler.js +6 -5
- package/esm/src/transforms/esm/http-cache-helpers.d.ts +11 -0
- package/esm/src/transforms/esm/http-cache-helpers.d.ts.map +1 -1
- package/esm/src/transforms/esm/http-cache-helpers.js +35 -0
- package/esm/src/transforms/esm/http-cache.d.ts.map +1 -1
- package/esm/src/transforms/esm/http-cache.js +16 -10
- package/esm/src/transforms/esm/specifier-resolver.d.ts.map +1 -1
- package/esm/src/transforms/esm/specifier-resolver.js +87 -7
- package/esm/src/transforms/import-rewriter/strategies/alias-strategy.d.ts +2 -0
- package/esm/src/transforms/import-rewriter/strategies/alias-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/alias-strategy.js +11 -6
- package/esm/src/transforms/md/compiler/md-compiler.d.ts.map +1 -1
- package/esm/src/transforms/md/compiler/md-compiler.js +12 -5
- package/esm/src/transforms/mdx/compiler/frontmatter-extractor.d.ts +2 -0
- package/esm/src/transforms/mdx/compiler/frontmatter-extractor.d.ts.map +1 -1
- package/esm/src/transforms/mdx/compiler/frontmatter-extractor.js +33 -1
- package/esm/src/transforms/mdx/compiler/mdx-compiler.d.ts.map +1 -1
- package/esm/src/transforms/mdx/compiler/mdx-compiler.js +46 -7
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +8 -2
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.js +3 -0
- package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.d.ts +4 -0
- package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.js +44 -8
- package/esm/src/transforms/mdx/esm-module-loader/missing-module.d.ts +2 -0
- package/esm/src/transforms/mdx/esm-module-loader/missing-module.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/missing-module.js +4 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/http-fallback.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/http-fallback.js +5 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/http-fetcher.d.ts +2 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/http-fetcher.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/http-fetcher.js +50 -11
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts +24 -12
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.js +201 -18
- package/esm/src/transforms/mdx/esm-module-loader/types.d.ts +5 -0
- package/esm/src/transforms/mdx/esm-module-loader/types.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/utils/source-spans.d.ts +22 -2
- package/esm/src/transforms/mdx/esm-module-loader/utils/source-spans.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/utils/source-spans.js +2080 -129
- package/esm/src/transforms/mdx/esm-module-loader/utils/stub-module.d.ts +11 -1
- package/esm/src/transforms/mdx/esm-module-loader/utils/stub-module.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/utils/stub-module.js +32 -15
- package/esm/src/transforms/pipeline/stages/compile.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/compile.js +44 -0
- package/esm/src/transforms/shared/specifier-suffix.d.ts +25 -0
- package/esm/src/transforms/shared/specifier-suffix.d.ts.map +1 -0
- package/esm/src/transforms/shared/specifier-suffix.js +43 -0
- package/esm/src/trigger/index.d.ts +2 -2
- package/esm/src/trigger/index.d.ts.map +1 -1
- package/esm/src/trigger/index.js +1 -1
- package/esm/src/trigger/local-runner.d.ts +2 -2
- package/esm/src/trigger/local-runner.d.ts.map +1 -1
- package/esm/src/trigger/local-runner.js +11 -4
- package/esm/src/trigger/target.d.ts +97 -5
- package/esm/src/trigger/target.d.ts.map +1 -1
- package/esm/src/trigger/target.js +175 -5
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/webhook/types.d.ts +21 -6
- package/esm/src/webhook/types.d.ts.map +1 -1
- package/esm/src/webhook/validation.d.ts.map +1 -1
- package/esm/src/webhook/validation.js +27 -39
- package/esm/templates/index.d.ts +1 -1
- package/esm/templates/index.d.ts.map +1 -1
- package/esm/templates/loader.d.ts +6 -6
- package/esm/templates/loader.d.ts.map +1 -1
- package/esm/templates/loader.js +34 -18
- package/esm/templates/manifest.generated.d.ts +3 -0
- package/esm/templates/manifest.generated.d.ts.map +1 -0
- package/esm/templates/manifest.generated.js +2 -0
- package/package.json +8 -8
- package/esm/templates/manifest.d.ts +0 -664
- package/esm/templates/manifest.d.ts.map +0 -1
- package/esm/templates/manifest.js +0 -662
|
@@ -14,6 +14,7 @@ import { getTextFromParts, } from "../types.js";
|
|
|
14
14
|
import { ensureModelReady, resolveModel } from "../../provider/index.js";
|
|
15
15
|
import { generateId } from "../../utils/id.js";
|
|
16
16
|
import { detectPlatform, getPlatformCapabilities } from "../../platform/core-platform.js";
|
|
17
|
+
import { canIdentifyProxyWithoutHooks, isProxyWithoutHooks, } from "../../platform/compat/error-introspection.js";
|
|
17
18
|
import { createAgentMemory } from "../memory/index.js";
|
|
18
19
|
import { serverLogger } from "../../utils/index.js";
|
|
19
20
|
import { addSpanEvent, setActiveSpanErrorStatus as setOtelActiveSpanErrorStatus, setSpanAttributes, withSpan, } from "../../observability/tracing/otlp-setup.js";
|
|
@@ -22,13 +23,14 @@ import { convertToTextGenerationRuntimeRequestMessages } from "./text-generation
|
|
|
22
23
|
import { convertToolsToRuntimeTools } from "./model-tool-converter.js";
|
|
23
24
|
import { bindRuntimeRemoteToolSourcesToCredentialOwner, constrainRuntimeRemoteToolSources, getRuntimeRemoteToolSources, } from "./mcp-server-tool-sources.js";
|
|
24
25
|
import { runWithRuntimeRemoteToolSources } from "./remote-tool-source-context.js";
|
|
25
|
-
import { createStreamState, processStream, } from "./chat-stream-handler.js";
|
|
26
|
+
import { announceStreamedToolCallInput, createStreamState, processStream, } from "./chat-stream-handler.js";
|
|
26
27
|
import { repairToolCall } from "./repair-tool-call.js";
|
|
27
28
|
import { MiddlewareChain } from "../middleware/chain.js";
|
|
28
29
|
import { tryGetCacheKeyContext } from "../../cache/cache-key-builder.js";
|
|
29
30
|
import { isLocalModelRuntime, supportsModelRuntimeToolCalling, } from "../../provider/runtime-inspection.js";
|
|
30
31
|
import { generateText, streamText } from "../../runtime/runtime-bridge.js";
|
|
31
|
-
import {
|
|
32
|
+
import { resolveAgentSystem } from "./effective-agent-system.js";
|
|
33
|
+
import { captureStreamedToolCallInput, collectFinalStreamToolResults, collectGeneratedToolResults, createToolErrorMessage, createToolResultMessage, getProviderExecutedToolNames, getToolResultError, hasSubstantiveAssistantText, isInterruptedClientToolCall, isRecoverablePlaceholderToolCall, isStreamedToolCallIncomplete, materializeStreamedToolCall, shouldContinueAfterStreamStep, } from "./tool-result-continuation.js";
|
|
32
34
|
import { enforceSkillPolicy, FORM_INPUT_TOOL_ID, LOAD_SKILL_TOOL_ID, SUBMITTED_FORM_INPUT_CONTEXT_KEY, } from "./skill-policy-enforcement.js";
|
|
33
35
|
import { AgentLoopSkillState } from "./agent-loop-skill-state.js";
|
|
34
36
|
import { markRuntimeGeneratedUserMessage } from "./runtime-message-origin.js";
|
|
@@ -36,7 +38,7 @@ import { getRuntimeAllowedRemoteTools, getRuntimeForwardedIntegrationToolDefs, g
|
|
|
36
38
|
import { applySourceIntegrationPolicy, } from "../../integrations/source-policy.js";
|
|
37
39
|
import { runWithRemoteIntegrationToolDiscoveryScope } from "../../integrations/remote-tools.js";
|
|
38
40
|
import { prepareAgentRuntimeStep, withIntegrationToolDiscoveryStatus, } from "./agent-runtime-step.js";
|
|
39
|
-
import { buildStreamedAssistantMessage } from "./streamed-assistant-message.js";
|
|
41
|
+
import { buildStreamedAssistantMessage, isPersistedReasoningPart, } from "./streamed-assistant-message.js";
|
|
40
42
|
import { flattenSystemInstructions, hasRuntimeToolInventory, withRuntimeToolInventory, } from "./tool-inventory.js";
|
|
41
43
|
import { captureAgentRunRuntimeContext, withAgentRunRuntimeContext, withAgentRunRuntimeContextMetadata, } from "./run-runtime-context.js";
|
|
42
44
|
// Re-export from submodules
|
|
@@ -74,15 +76,278 @@ import { DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE, getModelMaxOutputTokens } from
|
|
|
74
76
|
import { closeSSEStream, generateMessageId, sendSSE } from "./sse-utils.js";
|
|
75
77
|
import { executeConfiguredTool, getAvailableTools, isDynamicTool, resolveConfiguredTool, } from "./tool-helpers.js";
|
|
76
78
|
import { accumulateUsage, getMaxSteps, normalizeInput } from "./input-utils.js";
|
|
77
|
-
import { resolveRuntimeModel } from "./model-resolution.js";
|
|
79
|
+
import { resolveModelProviderOptionKey, resolveRuntimeModel } from "./model-resolution.js";
|
|
78
80
|
import { stringifyToolError, throwIfAborted } from "./error-utils.js";
|
|
79
81
|
import { resolveTemperatureParameter } from "./model-capabilities.js";
|
|
80
82
|
import { applySkillDelegationOverridesToToolInput } from "./skill-delegation-overrides.js";
|
|
81
83
|
import { resolveAgentModelTransport } from "./model-transport.js";
|
|
82
84
|
import { buildRuntimeUsageTraceAttributes } from "./trace-usage.js";
|
|
83
|
-
import { createToolExposureCheckpoint, createToolExposureState, searchToolExposure, TOOL_SEARCH_TOOL_NAME, } from "./tool-exposure.js";
|
|
85
|
+
import { createToolExposureCheckpoint, createToolExposureState, createToolSearchDefinition, searchToolExposure, TOOL_SEARCH_TOOL_NAME, } from "./tool-exposure.js";
|
|
86
|
+
const ArrayIsArray = Array.isArray;
|
|
87
|
+
const cloneStructuredValue = globalThis.structuredClone;
|
|
88
|
+
const IntrinsicWeakMap = WeakMap;
|
|
89
|
+
const ObjectCreate = Object.create;
|
|
90
|
+
const ObjectDefineProperty = Object.defineProperty;
|
|
91
|
+
const ObjectGetOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
|
|
92
|
+
const ObjectGetPrototypeOf = Object.getPrototypeOf;
|
|
93
|
+
const ObjectPrototype = Object.prototype;
|
|
94
|
+
const ReflectOwnKeys = Reflect.ownKeys;
|
|
84
95
|
const logger = serverLogger.component("agent");
|
|
85
96
|
const EVAL_RETAINED_SKILL_LOADER_TOOL_IDS = ["load_skill", "load_skill_reference"];
|
|
97
|
+
function getStructuredCloneFailureFingerprint(error) {
|
|
98
|
+
if (!(error instanceof DOMException) || error.name !== "DataCloneError") {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return `${error.name}\u0000${error.message}`;
|
|
102
|
+
}
|
|
103
|
+
function captureOpaqueProxyCloneFailureFingerprints() {
|
|
104
|
+
const revokedArrayProxy = Proxy.revocable([], {});
|
|
105
|
+
revokedArrayProxy.revoke();
|
|
106
|
+
const probes = [
|
|
107
|
+
new Proxy({}, {}),
|
|
108
|
+
new Proxy([], {}),
|
|
109
|
+
new Proxy(ObjectCreate(null), {}),
|
|
110
|
+
revokedArrayProxy.proxy,
|
|
111
|
+
];
|
|
112
|
+
const fingerprints = [];
|
|
113
|
+
for (const probe of probes) {
|
|
114
|
+
try {
|
|
115
|
+
cloneStructuredValue(probe);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const fingerprint = getStructuredCloneFailureFingerprint(error);
|
|
119
|
+
if (fingerprint !== undefined && !fingerprints.includes(fingerprint)) {
|
|
120
|
+
fingerprints.push(fingerprint);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return fingerprints;
|
|
125
|
+
}
|
|
126
|
+
const OPAQUE_PROXY_CLONE_FAILURE_FINGERPRINTS = captureOpaqueProxyCloneFailureFingerprints();
|
|
127
|
+
function isOpaqueProxyCloneFailure(error) {
|
|
128
|
+
const fingerprint = getStructuredCloneFailureFingerprint(error);
|
|
129
|
+
return fingerprint !== undefined &&
|
|
130
|
+
OPAQUE_PROXY_CLONE_FAILURE_FINGERPRINTS.includes(fingerprint);
|
|
131
|
+
}
|
|
132
|
+
function isArrayWithoutThrowing(value) {
|
|
133
|
+
try {
|
|
134
|
+
return ArrayIsArray(value);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function shouldRecoverOpaqueProxyContainer(value, fallback) {
|
|
141
|
+
return fallback === "root"
|
|
142
|
+
? isArrayWithoutThrowing(value)
|
|
143
|
+
: fallback !== "opaque" && fallback !== "provider-metadata";
|
|
144
|
+
}
|
|
145
|
+
function getChildRuntimeStateCloneFallback(fallback, parentIsArray, key, providerOptionKey) {
|
|
146
|
+
if (fallback === "root" && parentIsArray) {
|
|
147
|
+
return "message";
|
|
148
|
+
}
|
|
149
|
+
if (fallback === "message" && key === "providerOptions") {
|
|
150
|
+
return "provider-options";
|
|
151
|
+
}
|
|
152
|
+
if (fallback === "provider-options" &&
|
|
153
|
+
(key === "anthropic" || key === "veryfront-cloud" || key === providerOptionKey)) {
|
|
154
|
+
return "provider-bucket";
|
|
155
|
+
}
|
|
156
|
+
if (fallback === "provider-bucket") {
|
|
157
|
+
return key === "cacheControl" ? "cache-control" : "provider-metadata";
|
|
158
|
+
}
|
|
159
|
+
if (fallback === "cache-control") {
|
|
160
|
+
return "provider-metadata";
|
|
161
|
+
}
|
|
162
|
+
return "opaque";
|
|
163
|
+
}
|
|
164
|
+
function isOrdinaryRecordPrototype(prototype) {
|
|
165
|
+
if (prototype === null || prototype === ObjectPrototype) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (isProxyWithoutHooks(prototype)) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
return ObjectGetPrototypeOf(prototype) === null;
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function cloneRuntimeStateMutableValue(value, clones, proxyDetectionAvailable, fallback, providerOptionKey) {
|
|
179
|
+
if (typeof value !== "object" || value === null) {
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
if (proxyDetectionAvailable && isProxyWithoutHooks(value)) {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
const existing = clones.get(value);
|
|
186
|
+
if (existing !== undefined) {
|
|
187
|
+
return existing;
|
|
188
|
+
}
|
|
189
|
+
const inspectFrameworkContainer = shouldRecoverOpaqueProxyContainer(value, fallback);
|
|
190
|
+
if (!proxyDetectionAvailable && fallback === "provider-metadata") {
|
|
191
|
+
// Without host-level Proxy branding, unknown provider metadata cannot be
|
|
192
|
+
// reflected over safely. Keep it opaque instead of structured-cloning it,
|
|
193
|
+
// which would evaluate enumerable accessors. Known cacheControl metadata
|
|
194
|
+
// still follows the descriptor-first framework-container path.
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
if (!proxyDetectionAvailable && !inspectFrameworkContainer) {
|
|
198
|
+
try {
|
|
199
|
+
const clone = cloneStructuredValue(value);
|
|
200
|
+
clones.set(value, clone);
|
|
201
|
+
return clone;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
// Proxy branding is unavailable on browser and edge hosts. Compare the
|
|
205
|
+
// failure with trusted, host-local Proxy failures before reflecting over
|
|
206
|
+
// the value. Unlike matching engine-specific text, this remains valid
|
|
207
|
+
// across engines and localized exception messages. Framework-owned
|
|
208
|
+
// structured-system containers are copied from descriptors before this
|
|
209
|
+
// branch so metadata accessors stay inert. Unknown values still fail
|
|
210
|
+
// closed without reflective Proxy probes.
|
|
211
|
+
if (isOpaqueProxyCloneFailure(error)) {
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
if (getStructuredCloneFailureFingerprint(error) === undefined) {
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const isArray = isArrayWithoutThrowing(value);
|
|
220
|
+
let prototype;
|
|
221
|
+
try {
|
|
222
|
+
prototype = ObjectGetPrototypeOf(value);
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return value;
|
|
226
|
+
}
|
|
227
|
+
if (!isArray && !isOrdinaryRecordPrototype(prototype)) {
|
|
228
|
+
return value;
|
|
229
|
+
}
|
|
230
|
+
let descriptors;
|
|
231
|
+
try {
|
|
232
|
+
descriptors = ObjectGetOwnPropertyDescriptors(value);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return value;
|
|
236
|
+
}
|
|
237
|
+
const clone = isArray ? [] : ObjectCreate(prototype === null ? null : ObjectPrototype);
|
|
238
|
+
clones.set(value, clone);
|
|
239
|
+
const lengthDescriptor = isArray ? descriptors.length : undefined;
|
|
240
|
+
for (const key of ReflectOwnKeys(descriptors)) {
|
|
241
|
+
if (isArray && key === "length") {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const descriptor = descriptors[key];
|
|
245
|
+
if (!descriptor) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if ("value" in descriptor) {
|
|
249
|
+
descriptor.value = cloneRuntimeStateMutableValue(descriptor.value, clones, proxyDetectionAvailable, getChildRuntimeStateCloneFallback(fallback, isArray, key, providerOptionKey), providerOptionKey);
|
|
250
|
+
}
|
|
251
|
+
ObjectDefineProperty(clone, key, descriptor);
|
|
252
|
+
}
|
|
253
|
+
if (lengthDescriptor) {
|
|
254
|
+
ObjectDefineProperty(clone, "length", lengthDescriptor);
|
|
255
|
+
}
|
|
256
|
+
return clone;
|
|
257
|
+
}
|
|
258
|
+
export function cloneRuntimeStateMutableData(value, proxyDetectionAvailable = canIdentifyProxyWithoutHooks, providerOptionKey) {
|
|
259
|
+
return cloneRuntimeStateMutableValue(value, new IntrinsicWeakMap(), proxyDetectionAvailable, "root", providerOptionKey);
|
|
260
|
+
}
|
|
261
|
+
function isTextSseChunk(chunk) {
|
|
262
|
+
const payload = new TextDecoder().decode(chunk);
|
|
263
|
+
if (!payload.startsWith("data: ")) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const event = JSON.parse(payload.slice("data: ".length));
|
|
268
|
+
return event.type === "text-start" || event.type === "text-delta" ||
|
|
269
|
+
event.type === "text-end";
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function isTextEndSseChunk(chunk) {
|
|
276
|
+
const payload = new TextDecoder().decode(chunk);
|
|
277
|
+
if (!payload.startsWith("data: ")) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
const event = JSON.parse(payload.slice("data: ".length));
|
|
282
|
+
return event.type === "text-end";
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function textDeltaFromSseChunk(chunk) {
|
|
289
|
+
const payload = new TextDecoder().decode(chunk);
|
|
290
|
+
if (!payload.startsWith("data: ")) {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
const event = JSON.parse(payload.slice("data: ".length));
|
|
295
|
+
return event.type === "text-delta" && typeof event.delta === "string" ? event.delta : undefined;
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function stripLeadingText(text, remainingPrefixLength) {
|
|
302
|
+
const consumedLength = Math.min(text.length, remainingPrefixLength);
|
|
303
|
+
return {
|
|
304
|
+
text: text.slice(consumedLength),
|
|
305
|
+
remainingPrefixLength: remainingPrefixLength - consumedLength,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function stripTextDeltaPrefixFromSseChunk(chunk, remainingPrefixLength, encoder) {
|
|
309
|
+
const payload = new TextDecoder().decode(chunk);
|
|
310
|
+
if (!payload.startsWith("data: ")) {
|
|
311
|
+
return { chunk, remainingPrefixLength };
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
const event = JSON.parse(payload.slice("data: ".length));
|
|
315
|
+
if (event.type !== "text-delta" || typeof event.delta !== "string") {
|
|
316
|
+
return { chunk, remainingPrefixLength };
|
|
317
|
+
}
|
|
318
|
+
const stripped = stripLeadingText(event.delta, remainingPrefixLength);
|
|
319
|
+
if (stripped.text.length === 0) {
|
|
320
|
+
return { chunk: undefined, remainingPrefixLength: stripped.remainingPrefixLength };
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
chunk: encoder.encode(`data: ${JSON.stringify({ ...event, delta: stripped.text })}\n\n`),
|
|
324
|
+
remainingPrefixLength: stripped.remainingPrefixLength,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
return { chunk, remainingPrefixLength };
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function rewriteRecoveryTextSseChunkId(chunk, fallbackId, encoder) {
|
|
332
|
+
const payload = new TextDecoder().decode(chunk);
|
|
333
|
+
if (!payload.startsWith("data: ")) {
|
|
334
|
+
return chunk;
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
const event = JSON.parse(payload.slice("data: ".length));
|
|
338
|
+
if (event.type !== "text-start" && event.type !== "text-delta" &&
|
|
339
|
+
event.type !== "text-end") {
|
|
340
|
+
return chunk;
|
|
341
|
+
}
|
|
342
|
+
const id = typeof event.id === "string" && event.id.length > 0
|
|
343
|
+
? `${event.id}:recovery`
|
|
344
|
+
: fallbackId;
|
|
345
|
+
return encoder.encode(`data: ${JSON.stringify({ ...event, id })}\n\n`);
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
return chunk;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
86
351
|
function buildGeneratedAssistantMessage(response, metadata) {
|
|
87
352
|
const parts = [];
|
|
88
353
|
if (response.text)
|
|
@@ -212,13 +477,33 @@ const AGENT_WRITE_FINAL_RESPONSE_EXCLUDED_TOOL_NAMES = new Set([
|
|
|
212
477
|
function shouldHideProjectToolAfterAgentWriteSuccess(toolName) {
|
|
213
478
|
return AGENT_WRITE_FINAL_RESPONSE_EXCLUDED_TOOL_NAMES.has(toolName);
|
|
214
479
|
}
|
|
215
|
-
function
|
|
480
|
+
function didReloadProjectAgentWriteTool(result) {
|
|
481
|
+
return result.matches.some((match) => match.status === "loaded" && shouldHideProjectToolAfterAgentWriteSuccess(match.name));
|
|
482
|
+
}
|
|
483
|
+
function compareToolNames(left, right) {
|
|
484
|
+
return left.name < right.name ? -1 : left.name > right.name ? 1 : 0;
|
|
485
|
+
}
|
|
486
|
+
function applyAgentWriteFinalResponseGuard(plan, options) {
|
|
216
487
|
const keep = (tool) => !shouldHideProjectToolAfterAgentWriteSuccess(tool.name);
|
|
217
488
|
for (const toolName of plan.loadedToolNames) {
|
|
218
489
|
if (shouldHideProjectToolAfterAgentWriteSuccess(toolName)) {
|
|
219
490
|
plan.loadedToolNames.delete(toolName);
|
|
220
491
|
}
|
|
221
492
|
}
|
|
493
|
+
if (options.reloadable) {
|
|
494
|
+
const guardedTools = plan.authorized.filter((tool) => !keep(tool));
|
|
495
|
+
const visible = plan.visible.filter(keep);
|
|
496
|
+
const deferredByName = new Map([...plan.deferred, ...guardedTools].map((tool) => [tool.name, tool]));
|
|
497
|
+
if (guardedTools.length > 0 &&
|
|
498
|
+
!visible.some((tool) => tool.name === TOOL_SEARCH_TOOL_NAME)) {
|
|
499
|
+
visible.push(createToolSearchDefinition());
|
|
500
|
+
}
|
|
501
|
+
return {
|
|
502
|
+
...plan,
|
|
503
|
+
visible: visible.sort(compareToolNames),
|
|
504
|
+
deferred: [...deferredByName.values()].sort(compareToolNames),
|
|
505
|
+
};
|
|
506
|
+
}
|
|
222
507
|
return {
|
|
223
508
|
...plan,
|
|
224
509
|
authorized: plan.authorized.filter(keep),
|
|
@@ -226,11 +511,12 @@ function applyAgentWriteFinalResponseGuard(plan) {
|
|
|
226
511
|
deferred: plan.deferred.filter(keep),
|
|
227
512
|
};
|
|
228
513
|
}
|
|
229
|
-
function synchronizeRuntimeToolInventory(systemPrompt, runtimeTools) {
|
|
514
|
+
function synchronizeRuntimeToolInventory(systemPrompt, runtimeTools, deferredTools = []) {
|
|
230
515
|
if (!hasRuntimeToolInventory(systemPrompt)) {
|
|
231
516
|
return systemPrompt;
|
|
232
517
|
}
|
|
233
|
-
|
|
518
|
+
const instructions = withRuntimeToolInventory(systemPrompt, Object.keys(runtimeTools ?? {}).sort(), deferredTools);
|
|
519
|
+
return typeof systemPrompt === "string" ? flattenSystemInstructions(instructions) : instructions;
|
|
234
520
|
}
|
|
235
521
|
function parseToolResultJson(result) {
|
|
236
522
|
try {
|
|
@@ -443,17 +729,23 @@ export class AgentRuntime {
|
|
|
443
729
|
mode,
|
|
444
730
|
});
|
|
445
731
|
}
|
|
446
|
-
async resolveRuntimeState(messages, context, mode, step, systemPrompt) {
|
|
732
|
+
async resolveRuntimeState(messages, context, mode, step, systemPrompt, providerOptionKey) {
|
|
733
|
+
const structuredSystem = Array.isArray(systemPrompt) ? systemPrompt : undefined;
|
|
447
734
|
const refreshed = await this.config.resolveRuntimeState?.({
|
|
448
735
|
agentId: this.id,
|
|
449
736
|
mode,
|
|
450
737
|
step,
|
|
451
|
-
system: systemPrompt
|
|
738
|
+
system: typeof systemPrompt === "string"
|
|
739
|
+
? systemPrompt
|
|
740
|
+
: flattenSystemInstructions(systemPrompt),
|
|
741
|
+
...(structuredSystem === undefined ? {} : {
|
|
742
|
+
structuredSystem: cloneRuntimeStateMutableData(structuredSystem, canIdentifyProxyWithoutHooks, providerOptionKey),
|
|
743
|
+
}),
|
|
452
744
|
messages: [...messages],
|
|
453
745
|
context,
|
|
454
746
|
});
|
|
455
747
|
return {
|
|
456
|
-
systemPrompt: refreshed?.system ?? systemPrompt,
|
|
748
|
+
systemPrompt: refreshed?.structuredSystem ?? refreshed?.system ?? systemPrompt,
|
|
457
749
|
context: refreshed?.context ?? context,
|
|
458
750
|
};
|
|
459
751
|
}
|
|
@@ -504,7 +796,7 @@ export class AgentRuntime {
|
|
|
504
796
|
});
|
|
505
797
|
const inputMessages = normalizeInput(input);
|
|
506
798
|
const messages = await this.prepareTurnMessages(inputMessages);
|
|
507
|
-
const systemPrompt = await this.resolveSystemPrompt();
|
|
799
|
+
const systemPrompt = await this.resolveSystemPrompt(transport.providerOptionKey);
|
|
508
800
|
const agentContext = {
|
|
509
801
|
agentId: this.id,
|
|
510
802
|
model: resolvedModelString,
|
|
@@ -535,7 +827,7 @@ export class AgentRuntime {
|
|
|
535
827
|
debugRuntimeModelRemap(requestedModel, resolvedModelString);
|
|
536
828
|
const inputMessages = normalizeInput(messages);
|
|
537
829
|
const memoryMessages = await this.prepareTurnMessages(inputMessages);
|
|
538
|
-
const systemPrompt = await this.resolveSystemPrompt();
|
|
830
|
+
const systemPrompt = await this.resolveSystemPrompt(transport.providerOptionKey);
|
|
539
831
|
const encoder = new TextEncoder();
|
|
540
832
|
const streamAbortController = new AbortController();
|
|
541
833
|
const forwardAbort = () => {
|
|
@@ -698,6 +990,7 @@ export class AgentRuntime {
|
|
|
698
990
|
sandbox: undefined,
|
|
699
991
|
}
|
|
700
992
|
: runConfig;
|
|
993
|
+
const runtimeStepToolLoading = resolveRuntimeToolLoading(runtimeStepConfig);
|
|
701
994
|
const allowedRemoteToolNames = hasToolReplacements
|
|
702
995
|
? undefined
|
|
703
996
|
: getRuntimeAllowedRemoteTools(this.config);
|
|
@@ -735,7 +1028,8 @@ export class AgentRuntime {
|
|
|
735
1028
|
allowedRemoteToolNames,
|
|
736
1029
|
config: runtimeStepConfig,
|
|
737
1030
|
effectiveModel,
|
|
738
|
-
excludedToolNames: agentWriteFinalResponseToolGuardEnabled
|
|
1031
|
+
excludedToolNames: agentWriteFinalResponseToolGuardEnabled &&
|
|
1032
|
+
runtimeStepToolLoading.mode === "eager"
|
|
739
1033
|
? AGENT_WRITE_FINAL_RESPONSE_EXCLUDED_TOOL_NAMES
|
|
740
1034
|
: undefined,
|
|
741
1035
|
forwardedRemoteToolDefinitions,
|
|
@@ -743,6 +1037,8 @@ export class AgentRuntime {
|
|
|
743
1037
|
supportsToolCalling,
|
|
744
1038
|
messages: currentMessages,
|
|
745
1039
|
mode: "generate",
|
|
1040
|
+
modelRuntime: languageModel,
|
|
1041
|
+
providerOptionKey: resolveModelProviderOptionKey(effectiveModel, languageModel),
|
|
746
1042
|
providerToolNames: supportsToolCalling && !agentWriteFinalResponseToolGuardEnabled
|
|
747
1043
|
? providerTools
|
|
748
1044
|
: [],
|
|
@@ -762,11 +1058,13 @@ export class AgentRuntime {
|
|
|
762
1058
|
currentRuntimeContext = preparedStep.runtimeContext;
|
|
763
1059
|
const toolContext = preparedStep.toolContext;
|
|
764
1060
|
const effectiveToolExposurePlan = agentWriteFinalResponseToolGuardEnabled
|
|
765
|
-
? applyAgentWriteFinalResponseGuard(preparedStep.toolExposurePlan
|
|
1061
|
+
? applyAgentWriteFinalResponseGuard(preparedStep.toolExposurePlan, {
|
|
1062
|
+
reloadable: runtimeStepToolLoading.mode === "deferred",
|
|
1063
|
+
})
|
|
766
1064
|
: preparedStep.toolExposurePlan;
|
|
767
1065
|
const tools = effectiveToolExposurePlan.visible;
|
|
768
1066
|
setSpanAttributes(loopSpan, {
|
|
769
|
-
"tool.loading.mode":
|
|
1067
|
+
"tool.loading.mode": runtimeStepToolLoading.mode,
|
|
770
1068
|
"tool.loading.provenance": toolLoadingResolution.provenance,
|
|
771
1069
|
"tool.catalog.authorized_count": preparedStep.toolExposurePlan.authorized.length,
|
|
772
1070
|
"tool.catalog.visible_count": tools.length,
|
|
@@ -782,7 +1080,9 @@ export class AgentRuntime {
|
|
|
782
1080
|
model: effectiveModel,
|
|
783
1081
|
providerTools: stepProviderTools,
|
|
784
1082
|
});
|
|
785
|
-
currentSystemPrompt = withIntegrationToolDiscoveryStatus(synchronizeRuntimeToolInventory(currentSystemPrompt, runtimeTools
|
|
1083
|
+
currentSystemPrompt = withIntegrationToolDiscoveryStatus(synchronizeRuntimeToolInventory(currentSystemPrompt, runtimeTools, agentWriteFinalResponseToolGuardEnabled
|
|
1084
|
+
? effectiveToolExposurePlan.deferred.filter((tool) => shouldHideProjectToolAfterAgentWriteSuccess(tool.name))
|
|
1085
|
+
: []), preparedStep.integrationToolDiscovery);
|
|
786
1086
|
const response = await withSpan("agent.generate_text", async (span) => {
|
|
787
1087
|
setSpanAttributes(span, {
|
|
788
1088
|
"model.id": effectiveModel,
|
|
@@ -948,6 +1248,9 @@ export class AgentRuntime {
|
|
|
948
1248
|
plan: effectiveToolExposurePlan,
|
|
949
1249
|
state: toolExposureState,
|
|
950
1250
|
});
|
|
1251
|
+
if (didReloadProjectAgentWriteTool(search.result)) {
|
|
1252
|
+
agentWriteFinalResponseToolGuardEnabled = false;
|
|
1253
|
+
}
|
|
951
1254
|
toolCall.status = "completed";
|
|
952
1255
|
toolCall.result = search.result;
|
|
953
1256
|
setSpanAttributes(toolSpan, {
|
|
@@ -1210,6 +1513,11 @@ export class AgentRuntime {
|
|
|
1210
1513
|
let currentSystemPrompt = systemPrompt;
|
|
1211
1514
|
let currentRuntimeContext = runtimeContext;
|
|
1212
1515
|
let agentWriteFinalResponseToolGuardEnabled = false;
|
|
1516
|
+
// One retry gives the model a chance to reconstruct a transport-truncated
|
|
1517
|
+
// batch without allowing a repeatedly broken provider stream to loop.
|
|
1518
|
+
let recoveredInterruptedLocalToolBatch = false;
|
|
1519
|
+
let interruptedLocalToolBatchRecoveryStep;
|
|
1520
|
+
let interruptedLocalToolBatchRecoveryText;
|
|
1213
1521
|
for (let step = 0; step < maxSteps; step++) {
|
|
1214
1522
|
throwIfAborted(abortSignal);
|
|
1215
1523
|
sendSSE(controller, encoder, { type: "step-start" });
|
|
@@ -1224,7 +1532,8 @@ export class AgentRuntime {
|
|
|
1224
1532
|
allowedRemoteToolNames,
|
|
1225
1533
|
config: runtimeStepConfig,
|
|
1226
1534
|
effectiveModel,
|
|
1227
|
-
excludedToolNames: agentWriteFinalResponseToolGuardEnabled
|
|
1535
|
+
excludedToolNames: agentWriteFinalResponseToolGuardEnabled &&
|
|
1536
|
+
toolLoadingResolution.mode === "eager"
|
|
1228
1537
|
? AGENT_WRITE_FINAL_RESPONSE_EXCLUDED_TOOL_NAMES
|
|
1229
1538
|
: undefined,
|
|
1230
1539
|
forwardedRemoteToolDefinitions,
|
|
@@ -1232,6 +1541,8 @@ export class AgentRuntime {
|
|
|
1232
1541
|
supportsToolCalling,
|
|
1233
1542
|
messages: currentMessages,
|
|
1234
1543
|
mode: "stream",
|
|
1544
|
+
modelRuntime: languageModel,
|
|
1545
|
+
providerOptionKey: resolveModelProviderOptionKey(effectiveModel, languageModel),
|
|
1235
1546
|
providerToolNames: supportsToolCalling && !agentWriteFinalResponseToolGuardEnabled
|
|
1236
1547
|
? providerTools
|
|
1237
1548
|
: [],
|
|
@@ -1249,7 +1560,9 @@ export class AgentRuntime {
|
|
|
1249
1560
|
currentRuntimeContext = preparedStep.runtimeContext;
|
|
1250
1561
|
const toolContext = preparedStep.toolContext;
|
|
1251
1562
|
const effectiveToolExposurePlan = agentWriteFinalResponseToolGuardEnabled
|
|
1252
|
-
? applyAgentWriteFinalResponseGuard(preparedStep.toolExposurePlan
|
|
1563
|
+
? applyAgentWriteFinalResponseGuard(preparedStep.toolExposurePlan, {
|
|
1564
|
+
reloadable: toolLoadingResolution.mode === "deferred",
|
|
1565
|
+
})
|
|
1253
1566
|
: preparedStep.toolExposurePlan;
|
|
1254
1567
|
const tools = effectiveToolExposurePlan.visible;
|
|
1255
1568
|
setOtelActiveSpanAttributes({
|
|
@@ -1268,7 +1581,9 @@ export class AgentRuntime {
|
|
|
1268
1581
|
model: effectiveModel,
|
|
1269
1582
|
providerTools: stepProviderTools,
|
|
1270
1583
|
});
|
|
1271
|
-
currentSystemPrompt = withIntegrationToolDiscoveryStatus(synchronizeRuntimeToolInventory(currentSystemPrompt, runtimeTools
|
|
1584
|
+
currentSystemPrompt = withIntegrationToolDiscoveryStatus(synchronizeRuntimeToolInventory(currentSystemPrompt, runtimeTools, agentWriteFinalResponseToolGuardEnabled
|
|
1585
|
+
? effectiveToolExposurePlan.deferred.filter((tool) => shouldHideProjectToolAfterAgentWriteSuccess(tool.name))
|
|
1586
|
+
: []), preparedStep.integrationToolDiscovery);
|
|
1272
1587
|
const runtimeToolNames = Object.keys(runtimeTools ?? {}).sort();
|
|
1273
1588
|
const temperature = this.resolveTemperature(temperatureModelString ?? effectiveModel, providerOptions);
|
|
1274
1589
|
const maxOutputTokens = this.resolveMaxOutputTokens(effectiveModel, maxOutputTokensOverride);
|
|
@@ -1292,11 +1607,152 @@ export class AgentRuntime {
|
|
|
1292
1607
|
abortSignal: streamSignal,
|
|
1293
1608
|
}));
|
|
1294
1609
|
const state = createStreamState();
|
|
1610
|
+
// Hold a possible replay only while it remains a prefix of the text the
|
|
1611
|
+
// client already received. Once it diverges, resume live delivery.
|
|
1612
|
+
const deferInterruptedRecoveryOutput = step === interruptedLocalToolBatchRecoveryStep &&
|
|
1613
|
+
interruptedLocalToolBatchRecoveryText !== undefined;
|
|
1614
|
+
const deferredRecoveryOutput = deferInterruptedRecoveryOutput ? [] : undefined;
|
|
1615
|
+
const previousRecoveryText = interruptedLocalToolBatchRecoveryText ?? "";
|
|
1616
|
+
let deferredRecoverySseText = "";
|
|
1617
|
+
let deferredRecoveryCallbackText = "";
|
|
1618
|
+
let releasedDeferredRecoveryOutput = false;
|
|
1619
|
+
let releasedRecoveryReplacementTextPartId;
|
|
1620
|
+
let suppressedRecoveryReplayTextLength = 0;
|
|
1295
1621
|
const stepTextPartId = textPartId === undefined || step === 0
|
|
1296
1622
|
? textPartId
|
|
1297
1623
|
: `${textPartId}:step:${step}`;
|
|
1298
|
-
|
|
1299
|
-
|
|
1624
|
+
const replacementRecoveryTextPartId = stepTextPartId === undefined
|
|
1625
|
+
? `recovery:step:${step}`
|
|
1626
|
+
: `${stepTextPartId}:recovery`;
|
|
1627
|
+
const remainingRecoveryReplayText = () => previousRecoveryText.slice(suppressedRecoveryReplayTextLength);
|
|
1628
|
+
const flushDeferredRecoveryOutput = (interruptedRecoveryPrefixLength, repeatsInterruptedRecoveryText, useReplacementTextPartId) => {
|
|
1629
|
+
if (deferredRecoveryOutput === undefined)
|
|
1630
|
+
return;
|
|
1631
|
+
let remainingSsePrefixLength = interruptedRecoveryPrefixLength;
|
|
1632
|
+
let remainingCallbackPrefixLength = interruptedRecoveryPrefixLength;
|
|
1633
|
+
for (const output of deferredRecoveryOutput) {
|
|
1634
|
+
if (repeatsInterruptedRecoveryText &&
|
|
1635
|
+
(output.kind === "callback" || output.isTextEvent)) {
|
|
1636
|
+
continue;
|
|
1637
|
+
}
|
|
1638
|
+
if (output.kind === "callback") {
|
|
1639
|
+
const stripped = stripLeadingText(output.chunk, remainingCallbackPrefixLength);
|
|
1640
|
+
remainingCallbackPrefixLength = stripped.remainingPrefixLength;
|
|
1641
|
+
if (stripped.text.length > 0) {
|
|
1642
|
+
callbacks?.onChunk?.(stripped.text);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
else {
|
|
1646
|
+
const textChunk = useReplacementTextPartId && output.isTextEvent
|
|
1647
|
+
? rewriteRecoveryTextSseChunkId(output.chunk, replacementRecoveryTextPartId, encoder)
|
|
1648
|
+
: output.chunk;
|
|
1649
|
+
const stripped = output.isTextEvent
|
|
1650
|
+
? stripTextDeltaPrefixFromSseChunk(textChunk, remainingSsePrefixLength, encoder)
|
|
1651
|
+
: { chunk: textChunk, remainingPrefixLength: remainingSsePrefixLength };
|
|
1652
|
+
remainingSsePrefixLength = stripped.remainingPrefixLength;
|
|
1653
|
+
if (stripped.chunk !== undefined) {
|
|
1654
|
+
controller.enqueue(stripped.chunk);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
deferredRecoveryOutput.length = 0;
|
|
1659
|
+
};
|
|
1660
|
+
const releaseDeferredRecoveryOutputAfterDivergence = () => {
|
|
1661
|
+
if (deferredRecoveryOutput === undefined || releasedDeferredRecoveryOutput)
|
|
1662
|
+
return;
|
|
1663
|
+
const expectedReplayText = remainingRecoveryReplayText();
|
|
1664
|
+
const sseDiverged = !expectedReplayText.startsWith(deferredRecoverySseText);
|
|
1665
|
+
const callbackDiverged = callbacks?.onChunk === undefined ||
|
|
1666
|
+
!expectedReplayText.startsWith(deferredRecoveryCallbackText);
|
|
1667
|
+
if (!sseDiverged || !callbackDiverged)
|
|
1668
|
+
return;
|
|
1669
|
+
const observedRecoveryText = callbacks?.onChunk === undefined
|
|
1670
|
+
? deferredRecoverySseText
|
|
1671
|
+
: deferredRecoveryCallbackText;
|
|
1672
|
+
const extendsPreviousRecoveryText = observedRecoveryText.startsWith(expectedReplayText);
|
|
1673
|
+
flushDeferredRecoveryOutput(extendsPreviousRecoveryText ? expectedReplayText.length : 0, false, !extendsPreviousRecoveryText && suppressedRecoveryReplayTextLength === 0);
|
|
1674
|
+
if (extendsPreviousRecoveryText && suppressedRecoveryReplayTextLength > 0) {
|
|
1675
|
+
suppressedRecoveryReplayTextLength += expectedReplayText.length;
|
|
1676
|
+
}
|
|
1677
|
+
if (!extendsPreviousRecoveryText && suppressedRecoveryReplayTextLength === 0) {
|
|
1678
|
+
releasedRecoveryReplacementTextPartId = replacementRecoveryTextPartId;
|
|
1679
|
+
}
|
|
1680
|
+
releasedDeferredRecoveryOutput = true;
|
|
1681
|
+
};
|
|
1682
|
+
const releaseDeferredRecoveryOutputAfterExactReplay = (isTextEvent) => {
|
|
1683
|
+
if (isTextEvent || deferredRecoveryOutput === undefined || releasedDeferredRecoveryOutput ||
|
|
1684
|
+
deferredRecoverySseText !== remainingRecoveryReplayText() ||
|
|
1685
|
+
(callbacks?.onChunk !== undefined &&
|
|
1686
|
+
deferredRecoveryCallbackText !== remainingRecoveryReplayText())) {
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
flushDeferredRecoveryOutput(remainingRecoveryReplayText().length, false, false);
|
|
1690
|
+
releasedDeferredRecoveryOutput = true;
|
|
1691
|
+
};
|
|
1692
|
+
const releaseDeferredRecoveryNonTextOutput = (isTextEvent) => {
|
|
1693
|
+
if (isTextEvent || deferredRecoveryOutput === undefined || releasedDeferredRecoveryOutput) {
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
const retainedOutput = deferredRecoveryOutput.filter((output) => output.kind === "callback" || output.isTextEvent);
|
|
1697
|
+
for (const output of deferredRecoveryOutput) {
|
|
1698
|
+
if (output.kind === "sse" && !output.isTextEvent) {
|
|
1699
|
+
controller.enqueue(output.chunk);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
deferredRecoveryOutput.length = 0;
|
|
1703
|
+
deferredRecoveryOutput.push(...retainedOutput);
|
|
1704
|
+
};
|
|
1705
|
+
const reconcileDeferredRecoveryTextSegment = (isTextEndEvent) => {
|
|
1706
|
+
if (!isTextEndEvent || deferredRecoveryOutput === undefined ||
|
|
1707
|
+
releasedDeferredRecoveryOutput ||
|
|
1708
|
+
!remainingRecoveryReplayText().startsWith(deferredRecoverySseText) ||
|
|
1709
|
+
(callbacks?.onChunk !== undefined &&
|
|
1710
|
+
!remainingRecoveryReplayText().startsWith(deferredRecoveryCallbackText))) {
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
// A tool or reasoning event closes the current text segment. If that
|
|
1714
|
+
// segment only replayed a prefix the client already received, discard
|
|
1715
|
+
// it now and treat later text as a distinct segment. Otherwise retained
|
|
1716
|
+
// prefix events could be released after the boundary when later text
|
|
1717
|
+
// diverges, duplicating and reordering the replay.
|
|
1718
|
+
suppressedRecoveryReplayTextLength += deferredRecoverySseText.length;
|
|
1719
|
+
deferredRecoveryOutput.length = 0;
|
|
1720
|
+
deferredRecoverySseText = "";
|
|
1721
|
+
deferredRecoveryCallbackText = "";
|
|
1722
|
+
};
|
|
1723
|
+
const stepController = deferredRecoveryOutput === undefined ? controller : {
|
|
1724
|
+
enqueue(chunk) {
|
|
1725
|
+
if (releasedDeferredRecoveryOutput) {
|
|
1726
|
+
controller.enqueue(releasedRecoveryReplacementTextPartId !== undefined
|
|
1727
|
+
? rewriteRecoveryTextSseChunkId(chunk, releasedRecoveryReplacementTextPartId, encoder)
|
|
1728
|
+
: chunk);
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
deferredRecoverySseText += textDeltaFromSseChunk(chunk) ?? "";
|
|
1732
|
+
const isTextEvent = isTextSseChunk(chunk);
|
|
1733
|
+
deferredRecoveryOutput.push({
|
|
1734
|
+
kind: "sse",
|
|
1735
|
+
chunk,
|
|
1736
|
+
isTextEvent,
|
|
1737
|
+
});
|
|
1738
|
+
releaseDeferredRecoveryOutputAfterDivergence();
|
|
1739
|
+
releaseDeferredRecoveryOutputAfterExactReplay(isTextEvent);
|
|
1740
|
+
releaseDeferredRecoveryNonTextOutput(isTextEvent);
|
|
1741
|
+
reconcileDeferredRecoveryTextSegment(isTextEndSseChunk(chunk));
|
|
1742
|
+
},
|
|
1743
|
+
};
|
|
1744
|
+
await processStream(streamSource, state, stepController, encoder, stepTextPartId, {
|
|
1745
|
+
onChunk: deferredRecoveryOutput === undefined ? callbacks?.onChunk : (chunk) => {
|
|
1746
|
+
if (releasedDeferredRecoveryOutput) {
|
|
1747
|
+
callbacks?.onChunk?.(chunk);
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
deferredRecoveryCallbackText += chunk;
|
|
1751
|
+
if (callbacks?.onChunk !== undefined) {
|
|
1752
|
+
deferredRecoveryOutput.push({ kind: "callback", chunk });
|
|
1753
|
+
}
|
|
1754
|
+
releaseDeferredRecoveryOutputAfterDivergence();
|
|
1755
|
+
},
|
|
1300
1756
|
onUsage: (usage) => accumulateUsage(totalUsage, usage),
|
|
1301
1757
|
providerExecutedToolNames: getProviderExecutedToolNames(runtimeTools),
|
|
1302
1758
|
availableToolNames: runtimeToolNames,
|
|
@@ -1312,19 +1768,79 @@ export class AgentRuntime {
|
|
|
1312
1768
|
},
|
|
1313
1769
|
}, abortSignal);
|
|
1314
1770
|
throwIfAborted(abortSignal);
|
|
1771
|
+
const interruptedRecoveryPrefixLength = deferredRecoveryOutput === undefined
|
|
1772
|
+
? 0
|
|
1773
|
+
: state.accumulatedText.startsWith(previousRecoveryText)
|
|
1774
|
+
? previousRecoveryText.length
|
|
1775
|
+
: previousRecoveryText.startsWith(state.accumulatedText)
|
|
1776
|
+
? state.accumulatedText.length
|
|
1777
|
+
: 0;
|
|
1778
|
+
const recoveryPresentationPrefixLength = suppressedRecoveryReplayTextLength > 0
|
|
1779
|
+
? suppressedRecoveryReplayTextLength
|
|
1780
|
+
: interruptedRecoveryPrefixLength;
|
|
1781
|
+
const recoveryPresentationText = state.accumulatedText.slice(recoveryPresentationPrefixLength);
|
|
1782
|
+
const repeatsInterruptedRecoveryText = interruptedRecoveryPrefixLength > 0 &&
|
|
1783
|
+
recoveryPresentationText.length === 0;
|
|
1784
|
+
if (deferredRecoveryOutput !== undefined && !releasedDeferredRecoveryOutput) {
|
|
1785
|
+
flushDeferredRecoveryOutput(interruptedRecoveryPrefixLength, repeatsInterruptedRecoveryText, previousRecoveryText.length > 0 && interruptedRecoveryPrefixLength === 0 &&
|
|
1786
|
+
!repeatsInterruptedRecoveryText && state.accumulatedText.length > 0);
|
|
1787
|
+
}
|
|
1315
1788
|
finalFinishReason = state.finishReason ?? finalFinishReason;
|
|
1316
|
-
const
|
|
1789
|
+
const streamedToolCalls = Array.from(state.toolCalls.values());
|
|
1790
|
+
const finalToolResults = collectFinalStreamToolResults(state);
|
|
1791
|
+
// Recovery replays the whole step, so it also re-emits this step's
|
|
1792
|
+
// reasoning — duplicating it in the live stream and in history, with a
|
|
1793
|
+
// signature that no longer matches the replayed content. Reasoning that
|
|
1794
|
+
// was persisted is reasoning the client already saw, so fail closed.
|
|
1795
|
+
// This is a stopgap: reasoning is default-on across the hosted catalog,
|
|
1796
|
+
// which makes recovery inert on most hosted paths. See #3736 for the
|
|
1797
|
+
// reconciliation protocol that would let it run again.
|
|
1798
|
+
const hasExposedReasoning = state.reasoningParts.some(isPersistedReasoningPart);
|
|
1799
|
+
const canRecoverInterruptedLocalToolBatch = !recoveredInterruptedLocalToolBatch &&
|
|
1800
|
+
step + 1 < maxSteps &&
|
|
1801
|
+
!hasExposedReasoning;
|
|
1802
|
+
const shouldContinue = shouldContinueAfterStreamStep(state, {
|
|
1803
|
+
recoverInterruptedToolCalls: canRecoverInterruptedLocalToolBatch,
|
|
1804
|
+
});
|
|
1805
|
+
const shouldRecoverInterruptedLocalToolBatch = canRecoverInterruptedLocalToolBatch &&
|
|
1806
|
+
shouldContinue &&
|
|
1807
|
+
streamedToolCalls.some(isInterruptedClientToolCall);
|
|
1808
|
+
// Exactly `shouldRecoverInterruptedLocalToolBatch` with the reasoning
|
|
1809
|
+
// gate lifted: the batch this step would have replayed had it not
|
|
1810
|
+
// already exposed reasoning. Re-asking is what separates "recovery was
|
|
1811
|
+
// declined" from "this step merely carried reasoning";
|
|
1812
|
+
// `shouldContinueAfterStreamStep` only reads state, so asking twice has
|
|
1813
|
+
// no side effects, and the cheap conditions short-circuit ahead of it.
|
|
1814
|
+
const declinedRecoveryForExposedReasoning = hasExposedReasoning &&
|
|
1815
|
+
!recoveredInterruptedLocalToolBatch &&
|
|
1816
|
+
step + 1 < maxSteps &&
|
|
1817
|
+
streamedToolCalls.some(isInterruptedClientToolCall) &&
|
|
1818
|
+
shouldContinueAfterStreamStep(state, { recoverInterruptedToolCalls: true });
|
|
1819
|
+
if (declinedRecoveryForExposedReasoning) {
|
|
1820
|
+
logger.warn("Declined interrupted local tool batch recovery after exposed reasoning", {
|
|
1821
|
+
step,
|
|
1822
|
+
toolName: streamedToolCalls.find(isInterruptedClientToolCall)?.name,
|
|
1823
|
+
reasoningPartCount: state.reasoningParts.filter(isPersistedReasoningPart).length,
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
const assistantMessage = buildStreamedAssistantMessage({
|
|
1827
|
+
...state,
|
|
1828
|
+
accumulatedText: recoveryPresentationText,
|
|
1829
|
+
}, {
|
|
1317
1830
|
id: `msg_${Date.now()}_${step}`,
|
|
1318
1831
|
timestamp: Date.now(),
|
|
1832
|
+
}, {
|
|
1833
|
+
preserveRecoverablePlaceholderToolCalls: shouldRecoverInterruptedLocalToolBatch ||
|
|
1834
|
+
!shouldContinue,
|
|
1319
1835
|
});
|
|
1320
1836
|
for (const tc of state.toolCalls.values()) {
|
|
1321
1837
|
const materialized = materializeStreamedToolCall(tc);
|
|
1322
1838
|
if (materialized.kind === "incomplete" && isRecoverablePlaceholderToolCall(tc)) {
|
|
1323
1839
|
// Provisional empty-object placeholder that never finalized. The
|
|
1324
|
-
// model never committed arguments.
|
|
1325
|
-
//
|
|
1326
|
-
//
|
|
1327
|
-
//
|
|
1840
|
+
// model never committed arguments. Preserve it when recovery or
|
|
1841
|
+
// terminalization records a matching tool result; otherwise the
|
|
1842
|
+
// assistant message builder can omit it beside final text. Surface no
|
|
1843
|
+
// input warning or error for the provisional fragment.
|
|
1328
1844
|
continue;
|
|
1329
1845
|
}
|
|
1330
1846
|
if (materialized.kind === "incomplete") {
|
|
@@ -1357,10 +1873,22 @@ export class AgentRuntime {
|
|
|
1357
1873
|
});
|
|
1358
1874
|
}
|
|
1359
1875
|
}
|
|
1360
|
-
|
|
1876
|
+
const stepAssistantText = getTextFromParts(assistantMessage.parts);
|
|
1877
|
+
if (step === interruptedLocalToolBatchRecoveryStep &&
|
|
1878
|
+
suppressedRecoveryReplayTextLength > 0) {
|
|
1879
|
+
latestAssistantText = `${previousRecoveryText}${recoveryPresentationText}`;
|
|
1880
|
+
}
|
|
1881
|
+
else if (step === interruptedLocalToolBatchRecoveryStep && interruptedRecoveryPrefixLength > 0) {
|
|
1882
|
+
latestAssistantText = previousRecoveryText.startsWith(state.accumulatedText)
|
|
1883
|
+
? previousRecoveryText
|
|
1884
|
+
: state.accumulatedText;
|
|
1885
|
+
}
|
|
1886
|
+
else if (hasSubstantiveAssistantText(stepAssistantText) ||
|
|
1887
|
+
step !== interruptedLocalToolBatchRecoveryStep) {
|
|
1888
|
+
latestAssistantText = stepAssistantText;
|
|
1889
|
+
}
|
|
1361
1890
|
currentMessages.push(assistantMessage);
|
|
1362
1891
|
await this.memory.add(assistantMessage);
|
|
1363
|
-
const finalToolResults = collectFinalStreamToolResults(state);
|
|
1364
1892
|
const persistToolResult = async (toolResult) => {
|
|
1365
1893
|
if (currentStepToolResults.has(toolResult.toolCallId)) {
|
|
1366
1894
|
return;
|
|
@@ -1372,40 +1900,94 @@ export class AgentRuntime {
|
|
|
1372
1900
|
await this.memory.add(toolResultMessage);
|
|
1373
1901
|
currentStepToolResults.set(toolResult.toolCallId, toolResultMessage.parts[0]);
|
|
1374
1902
|
};
|
|
1375
|
-
|
|
1903
|
+
const recordIncompleteLocalToolError = async (toolCall, options = {}) => {
|
|
1904
|
+
if (toolCall.providerExecuted === true ||
|
|
1905
|
+
!isStreamedToolCallIncomplete(toolCall) ||
|
|
1906
|
+
finalToolResults.has(toolCall.id)) {
|
|
1907
|
+
return false;
|
|
1908
|
+
}
|
|
1909
|
+
if (options.announceInput === true) {
|
|
1910
|
+
// An interrupted call never reached `tool-input-end`, so its
|
|
1911
|
+
// `tool-input-start` is still buffered and `inputAnnounced` is false
|
|
1912
|
+
// — which would suppress the `tool-output-error` below. On the
|
|
1913
|
+
// declined-recovery path that leaves the client with a reasoning
|
|
1914
|
+
// block and then nothing at all.
|
|
1915
|
+
//
|
|
1916
|
+
// The name is safe to publish here. `tool-call` is what can supersede
|
|
1917
|
+
// a name, and it also sets `inputAvailable`, which fails the guard
|
|
1918
|
+
// above — so reaching this line means no such event arrived and the
|
|
1919
|
+
// buffered name is the only one this call will ever have. It is the
|
|
1920
|
+
// same name recorded below and in the persisted assistant message,
|
|
1921
|
+
// so the card matches a reload. Announcing is idempotent, so a call
|
|
1922
|
+
// surfaced upstream is not reported twice.
|
|
1923
|
+
announceStreamedToolCallInput(controller, encoder, toolCall);
|
|
1924
|
+
}
|
|
1925
|
+
const incompleteToolCall = {
|
|
1926
|
+
id: toolCall.id,
|
|
1927
|
+
name: toolCall.name,
|
|
1928
|
+
args: {},
|
|
1929
|
+
...(toolCall.arguments.length > 0 ? { inputText: toolCall.arguments } : {}),
|
|
1930
|
+
status: "pending",
|
|
1931
|
+
};
|
|
1932
|
+
await this.recordToolError(incompleteToolCall, `Stream terminated before tool-call event fired for "${toolCall.name}". ` +
|
|
1933
|
+
`Received ${toolCall.arguments.length} chars of partial tool-input deltas.`, controller, encoder, currentMessages, toolCalls, {
|
|
1934
|
+
emitSse: toolCall.inputAnnounced === true,
|
|
1935
|
+
includeInResponse: options.includeInResponse,
|
|
1936
|
+
});
|
|
1937
|
+
return true;
|
|
1938
|
+
};
|
|
1939
|
+
if (!shouldContinue) {
|
|
1376
1940
|
for (const toolResult of finalToolResults.values()) {
|
|
1377
1941
|
await persistToolResult(toolResult);
|
|
1378
1942
|
}
|
|
1943
|
+
for (const toolCall of streamedToolCalls) {
|
|
1944
|
+
await recordIncompleteLocalToolError(toolCall, {
|
|
1945
|
+
announceInput: declinedRecoveryForExposedReasoning,
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1379
1948
|
sendSSE(controller, encoder, { type: "step-end" });
|
|
1380
1949
|
break;
|
|
1381
1950
|
}
|
|
1382
1951
|
this.status = "tool_execution";
|
|
1383
|
-
|
|
1952
|
+
if (shouldRecoverInterruptedLocalToolBatch) {
|
|
1953
|
+
// Treat parallel local calls as one batch. Executing the finalized
|
|
1954
|
+
// prefix here could apply only part of the model's intended mutation.
|
|
1955
|
+
recoveredInterruptedLocalToolBatch = true;
|
|
1956
|
+
interruptedLocalToolBatchRecoveryStep = step + 1;
|
|
1957
|
+
interruptedLocalToolBatchRecoveryText = hasSubstantiveAssistantText(stepAssistantText)
|
|
1958
|
+
? stepAssistantText
|
|
1959
|
+
: undefined;
|
|
1960
|
+
}
|
|
1384
1961
|
for (const tc of streamedToolCalls) {
|
|
1385
1962
|
throwIfAborted(abortSignal);
|
|
1963
|
+
if (shouldRecoverInterruptedLocalToolBatch && tc.providerExecuted !== true) {
|
|
1964
|
+
if (await recordIncompleteLocalToolError(tc, { includeInResponse: false })) {
|
|
1965
|
+
continue;
|
|
1966
|
+
}
|
|
1967
|
+
const capturedInput = captureStreamedToolCallInput(tc);
|
|
1968
|
+
const interruptedBatchToolCall = {
|
|
1969
|
+
id: tc.id,
|
|
1970
|
+
name: tc.name,
|
|
1971
|
+
args: capturedInput.args,
|
|
1972
|
+
...(capturedInput.inputText ? { inputText: capturedInput.inputText } : {}),
|
|
1973
|
+
status: "pending",
|
|
1974
|
+
};
|
|
1975
|
+
await this.recordToolError(interruptedBatchToolCall, "Tool execution skipped because another tool call in the same model step " +
|
|
1976
|
+
"was interrupted before its input completed.", controller, encoder, currentMessages, toolCalls);
|
|
1977
|
+
continue;
|
|
1978
|
+
}
|
|
1386
1979
|
if (isRecoverablePlaceholderToolCall(tc)) {
|
|
1387
|
-
// Provisional empty-object placeholder that never finalized.
|
|
1388
|
-
//
|
|
1389
|
-
//
|
|
1390
|
-
// can continue and let the next model call recover the real tool
|
|
1391
|
-
// call without executing or surfacing a stream-termination error.
|
|
1980
|
+
// Provisional empty-object placeholder that never finalized. If the
|
|
1981
|
+
// bounded recovery path was unavailable, do not execute or surface
|
|
1982
|
+
// it as a committed call.
|
|
1392
1983
|
continue;
|
|
1393
1984
|
}
|
|
1394
|
-
if (
|
|
1985
|
+
if (await recordIncompleteLocalToolError(tc)) {
|
|
1395
1986
|
// Stream ended before the provider finalized this tool call. We
|
|
1396
1987
|
// cannot execute it, so record a distinct stream-termination error
|
|
1397
1988
|
// (not a tool-argument parse error) so the parent step and any
|
|
1398
1989
|
// upstream orchestrator (e.g. the child-fork watchdog) see a
|
|
1399
1990
|
// completed step with a clearly-labelled failure and can recover.
|
|
1400
|
-
const incompleteToolCall = {
|
|
1401
|
-
id: tc.id,
|
|
1402
|
-
name: tc.name,
|
|
1403
|
-
args: {},
|
|
1404
|
-
...(tc.arguments.length > 0 ? { inputText: tc.arguments } : {}),
|
|
1405
|
-
status: "pending",
|
|
1406
|
-
};
|
|
1407
|
-
await this.recordToolError(incompleteToolCall, `Stream terminated before tool-call event fired for "${tc.name}". ` +
|
|
1408
|
-
`Received ${tc.arguments.length} chars of partial tool-input deltas.`, controller, encoder, currentMessages, toolCalls, { emitSse: tc.inputAnnounced === true });
|
|
1409
1991
|
continue;
|
|
1410
1992
|
}
|
|
1411
1993
|
const capturedInput = captureStreamedToolCallInput(tc);
|
|
@@ -1503,6 +2085,9 @@ export class AgentRuntime {
|
|
|
1503
2085
|
plan: effectiveToolExposurePlan,
|
|
1504
2086
|
state: toolExposureState,
|
|
1505
2087
|
});
|
|
2088
|
+
if (didReloadProjectAgentWriteTool(search.result)) {
|
|
2089
|
+
agentWriteFinalResponseToolGuardEnabled = false;
|
|
2090
|
+
}
|
|
1506
2091
|
toolCall.status = "completed";
|
|
1507
2092
|
toolCall.result = search.result;
|
|
1508
2093
|
toolCalls.push(toolCall);
|
|
@@ -1669,7 +2254,9 @@ export class AgentRuntime {
|
|
|
1669
2254
|
async recordToolError(toolCall, errorStr, controller, encoder, currentMessages, toolCalls, options = {}) {
|
|
1670
2255
|
toolCall.status = "error";
|
|
1671
2256
|
toolCall.error = errorStr;
|
|
1672
|
-
|
|
2257
|
+
if (options.includeInResponse !== false) {
|
|
2258
|
+
toolCalls.push(toolCall);
|
|
2259
|
+
}
|
|
1673
2260
|
if (options.emitSse !== false) {
|
|
1674
2261
|
const dynamic = isDynamicTool(toolCall.name);
|
|
1675
2262
|
sendSSE(controller, encoder, {
|
|
@@ -1686,13 +2273,11 @@ export class AgentRuntime {
|
|
|
1686
2273
|
/**
|
|
1687
2274
|
* Resolve system prompt (handle string or function)
|
|
1688
2275
|
*/
|
|
1689
|
-
async resolveSystemPrompt() {
|
|
2276
|
+
async resolveSystemPrompt(providerOptionKey) {
|
|
1690
2277
|
const { system } = this.config;
|
|
1691
|
-
if (
|
|
1692
|
-
return
|
|
1693
|
-
|
|
1694
|
-
return system();
|
|
1695
|
-
return "You are a helpful assistant.";
|
|
2278
|
+
if (system === undefined)
|
|
2279
|
+
return "You are a helpful assistant.";
|
|
2280
|
+
return await resolveAgentSystem(system, providerOptionKey);
|
|
1696
2281
|
}
|
|
1697
2282
|
/**
|
|
1698
2283
|
* Compute max steps considering edge config and platform limits.
|