eve 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/src/channel/routes.d.ts +13 -3
- package/dist/src/channel/routes.js +1 -1
- package/dist/src/channel/session-callback.js +1 -1
- package/dist/src/channel/session.d.ts +2 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +41 -0
- package/dist/src/chunks/{use-eve-agent-COmP-H8R.js → use-eve-agent-BbSsu99c.js} +79 -32
- package/dist/src/chunks/{use-eve-agent-CnppTEFk.js → use-eve-agent-Dt8Y5QtW.js} +78 -31
- package/dist/src/cli/acp/command.d.ts +2 -1
- package/dist/src/cli/acp/command.js +2 -2
- package/dist/src/cli/application-command.d.ts +8 -0
- package/dist/src/cli/application-command.js +1 -0
- package/dist/src/cli/application-root.d.ts +8 -0
- package/dist/src/cli/application-root.js +1 -0
- package/dist/src/cli/commands/build.d.ts +2 -1
- package/dist/src/cli/commands/build.js +1 -1
- package/dist/src/cli/commands/init-git.js +1 -1
- package/dist/src/cli/commands/init-recovery.d.ts +3 -0
- package/dist/src/cli/commands/init-recovery.js +3 -0
- package/dist/src/cli/commands/init-repl.js +1 -1
- package/dist/src/cli/commands/init-target.d.ts +21 -0
- package/dist/src/cli/commands/init-target.js +1 -0
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/register-integration-commands.d.ts +2 -1
- package/dist/src/cli/commands/register-integration-commands.js +1 -1
- package/dist/src/cli/commands/register-project-commands.d.ts +2 -1
- package/dist/src/cli/commands/register-project-commands.js +1 -1
- package/dist/src/cli/commands/register-registry-commands.d.ts +2 -1
- package/dist/src/cli/commands/register-registry-commands.js +4 -1
- package/dist/src/cli/commands/registry-recovery.d.ts +14 -0
- package/dist/src/cli/commands/registry-recovery.js +1 -0
- package/dist/src/cli/commands/registry.d.ts +2 -5
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/diagnostic-dump.js +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +8 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +27 -22
- package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +16 -0
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/cli/invoke/command.d.ts +3 -2
- package/dist/src/cli/invoke/command.js +1 -1
- package/dist/src/cli/run.d.ts +3 -2
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/eve-agent-store.d.ts +15 -3
- package/dist/src/client/eve-agent-store.js +2 -2
- package/dist/src/client/message-response.d.ts +10 -2
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/open-stream.d.ts +2 -0
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +5 -1
- package/dist/src/compiled/@ai-sdk/otel/index.js +3 -3
- package/dist/src/compiled/@chat-adapter/slack/index.js +25 -25
- package/dist/src/compiled/@modelcontextprotocol/server/LICENSE +216 -0
- package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +98 -0
- package/dist/src/compiled/@modelcontextprotocol/server/index.js +80 -0
- package/dist/src/compiled/@opentelemetry/api/index.js +1 -1
- package/dist/src/compiled/@opentelemetry/otlp-transformer/index.js +1 -1
- package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +61 -61
- package/dist/src/compiled/@vercel/oidc/index.js +14 -14
- package/dist/src/compiled/@vercel/otel/index.js +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +1 -1
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +2 -2
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +13 -13
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-BoH7JsWp.js → attribute-changes-DZtQkszH.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/chunk-5MU5Z6L3-B_3nkJFi.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{chunk-NWCAEW5Y-Oxw40oRR.js → chunk-NWCAEW5Y-BgbcH0OK.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-DlFv0aHY.js → dist-CPlyFOVo.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-tJoQXAF6.js → dist-DpYyXbJv.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-CRTn4Sg8.js → dist-xQXN70ED.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/esm-seIr7a6j.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{frames-CTpeJYEQ.js → frames-BBs-9k1d.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{functions-CeeNvKsq.js → functions-DAYiHNti.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-bsd-WEBNKY2R-CEYkx6Nv.js → getMachineId-bsd-WEBNKY2R-BTaxrQ52.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-darwin-LT47KAXP-DPwWlhif.js → getMachineId-darwin-LT47KAXP-DhYmwE_R.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-linux-LTVQO6VW-DAFXHwZp.js → getMachineId-linux-LTVQO6VW-Dru_L5ru.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-unsupported-UKWBA27G-BZKOI8mG.js → getMachineId-unsupported-UKWBA27G-DGfoqVW1.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-win-NLJKOPY6-r7_CJB5o.js → getMachineId-win-NLJKOPY6-CLM98q4X.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{private-tvMBynnC.js → private-UQtz8ZcW.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{resume-hook-BPQHjeY5.js → resume-hook-CYtSorp6.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{rolldown-runtime-DaDcL9Zw.js → rolldown-runtime-8V8biNmG.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{run-DQ5dOyjm.js → run-Cjo0A3NO.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{signal-exit-C8vsI6zj.js → signal-exit-o3IPQwwv.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/sleep-C1P0OWBm.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{token-DHD-q-fS.js → token-DGzfw-Vb.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{token-DtCUEpJs.js → token-DNbxVpeq.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/token-util-BneBe0g5.js +27 -0
- package/dist/src/compiled/_chunks/workflow/{token-util-Ldar52H7.js → token-util-DjMgNdXS.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{undici-CUIybhQ2.js → undici-BBG5cZTy.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{wait-until-DK2lnH6U.js → wait-until-CT1ve8qB.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/{wrapper-CMGju7QA.js → wrapper-CQNxP9mU.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/{ws-transport-Csi6Cydc.js → ws-transport-beXxD0s_.js} +1 -1
- package/dist/src/compiled/env-runner/node-worker.js +1 -1
- package/dist/src/compiled/jose/index.js +1 -1
- package/dist/src/compiled/shadcn-registry/index.js +403 -403
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/compile-agent.js +2 -2
- package/dist/src/compiler/extension-compatibility.d.ts +20 -10
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-extension.d.ts +8 -5
- package/dist/src/compiler/normalize-extension.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-subagent.d.ts +1 -1
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/context/serialized-dynamic-model-selection.d.ts +2 -0
- package/dist/src/context/serialized-dynamic-model-selection.js +1 -0
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/extensions.d.ts +0 -6
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/evals/cli/eval.d.ts +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/agent-handle-dispatch.d.ts +15 -1
- package/dist/src/execution/agent-handle-dispatch.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/delegated-parent-notification.d.ts +17 -0
- package/dist/src/execution/delegated-parent-notification.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +155 -0
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -0
- package/dist/src/execution/dispatch-runtime-actions-step.d.ts +18 -14
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.d.ts +7 -2
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
- package/dist/src/execution/effective-output-schema.d.ts +21 -0
- package/dist/src/execution/effective-output-schema.js +1 -0
- package/dist/src/execution/eve-workflow-attributes.d.ts +2 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/parked-delivery-wait.d.ts +8 -12
- package/dist/src/execution/parked-delivery-wait.js +1 -1
- package/dist/src/execution/{route-proxied-deliver-step.d.ts → proxied-deliver-step.d.ts} +7 -4
- package/dist/src/execution/proxied-deliver-step.js +1 -0
- package/dist/src/execution/remote-agent-dispatch.d.ts +32 -0
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/remote-agent-route-url.d.ts +2 -0
- package/dist/src/execution/remote-agent-route-url.js +1 -0
- package/dist/src/execution/route-child-delivery.d.ts +2 -1
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/session-callback-step.d.ts +11 -0
- package/dist/src/execution/session-callback-step.js +1 -1
- package/dist/src/execution/session-command-wire.js +1 -1
- package/dist/src/execution/session-state-cursor.d.ts +25 -0
- package/dist/src/execution/session-state-cursor.js +1 -0
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +2 -0
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-event-proxy-step.d.ts +15 -0
- package/dist/src/execution/subagent-event-proxy-step.js +1 -1
- package/dist/src/execution/subagent-hitl-proxy.d.ts +14 -7
- package/dist/src/execution/subagent-hitl-proxy.js +1 -1
- package/dist/src/execution/subagent-start-local.d.ts +29 -0
- package/dist/src/execution/subagent-start-local.js +1 -0
- package/dist/src/execution/subagent-start-remote.d.ts +23 -0
- package/dist/src/execution/subagent-start-remote.js +1 -0
- package/dist/src/execution/task-event-callback.d.ts +13 -0
- package/dist/src/execution/task-event-callback.js +1 -0
- package/dist/src/execution/task-input-capability.d.ts +4 -0
- package/dist/src/execution/task-input-capability.js +1 -0
- package/dist/src/execution/tasks/child/steps.d.ts +46 -0
- package/dist/src/execution/tasks/child/steps.js +1 -0
- package/dist/src/execution/tasks/child/workflow.d.ts +31 -0
- package/dist/src/execution/tasks/child/workflow.js +1 -0
- package/dist/src/execution/tasks/parent/agent-identity.d.ts +13 -0
- package/dist/src/execution/tasks/parent/agent-identity.js +1 -0
- package/dist/src/execution/tasks/parent/agent-views.d.ts +6 -0
- package/dist/src/execution/tasks/parent/agent-views.js +1 -0
- package/dist/src/execution/tasks/parent/continuation-dispatch.d.ts +37 -0
- package/dist/src/execution/tasks/parent/continuation-dispatch.js +1 -0
- package/dist/src/execution/tasks/parent/control-shared.d.ts +36 -0
- package/dist/src/execution/tasks/parent/control-shared.js +1 -0
- package/dist/src/execution/tasks/parent/delegate.d.ts +70 -0
- package/dist/src/execution/tasks/parent/delegate.js +1 -0
- package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +19 -0
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -0
- package/dist/src/execution/tasks/parent/dispatch.d.ts +33 -0
- package/dist/src/execution/tasks/parent/dispatch.js +1 -0
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +29 -0
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -0
- package/dist/src/execution/tasks/parent/run-parent.d.ts +72 -0
- package/dist/src/execution/tasks/parent/run-parent.js +1 -0
- package/dist/src/execution/tasks/parent/send.d.ts +25 -0
- package/dist/src/execution/tasks/parent/send.js +1 -0
- package/dist/src/execution/tasks/workflow-target.d.ts +2 -0
- package/dist/src/execution/tasks/workflow-target.js +1 -0
- package/dist/src/execution/terminate-child-sessions-step.d.ts +1 -0
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/turn-control-receiver.d.ts +10 -0
- package/dist/src/execution/turn-control-receiver.js +1 -1
- package/dist/src/execution/turn-dispatch.d.ts +2 -0
- package/dist/src/execution/turn-dispatch.js +1 -1
- package/dist/src/execution/turn-execution-cursor.d.ts +2 -8
- package/dist/src/execution/turn-execution-cursor.js +1 -1
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-callback-url.d.ts +5 -0
- package/dist/src/execution/workflow-callback-url.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +9 -0
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.d.ts +7 -21
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +7 -0
- package/dist/src/harness/handles/prompt.d.ts +12 -0
- package/dist/src/harness/handles/prompt.js +2 -1
- package/dist/src/harness/handles/query.js +1 -1
- package/dist/src/harness/handles/store.d.ts +9 -2
- package/dist/src/harness/handles/store.js +1 -1
- package/dist/src/harness/handles/transitions.d.ts +10 -1
- package/dist/src/harness/handles/transitions.js +1 -1
- package/dist/src/harness/instrumentation/providers.js +1 -1
- package/dist/src/harness/instrumentation/runtime-context.d.ts +2 -0
- package/dist/src/harness/instrumentation/runtime-context.js +1 -1
- package/dist/src/harness/instrumentation/runtime.d.ts +3 -1
- package/dist/src/harness/proxy-input-requests.d.ts +21 -4
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/runtime-actions.d.ts +2 -0
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/workflow-runtime-action-state.js +1 -1
- package/dist/src/internal/application/cache-metadata.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +2 -2
- package/dist/src/internal/application/optional-package-install.js +1 -1
- package/dist/src/internal/application/output-publication-lock.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-module-evaluation-error.js +4 -4
- package/dist/src/internal/authored-module-loader.js +3 -3
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
- package/dist/src/internal/bundler/extension-scope-plugin.js +1 -1
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/internal/instrumentation-layout.js +1 -1
- package/dist/src/internal/invocation/agent-invocation.d.ts +54 -0
- package/dist/src/internal/invocation/agent-invocation.js +1 -0
- package/dist/src/internal/invocation/attributes.d.ts +2 -0
- package/dist/src/internal/invocation/attributes.js +1 -0
- package/dist/src/internal/invocation/metadata.d.ts +9 -0
- package/dist/src/internal/invocation/metadata.js +1 -0
- package/dist/src/internal/invocation/workflow-execution.d.ts +32 -0
- package/dist/src/internal/invocation/workflow-execution.js +1 -0
- package/dist/src/internal/materialized-authored-modules.js +1 -1
- package/dist/src/internal/mcp/http-security.d.ts +12 -0
- package/dist/src/internal/mcp/http-security.js +1 -0
- package/dist/src/internal/mcp/protected-resource.d.ts +9 -0
- package/dist/src/internal/mcp/protected-resource.js +1 -0
- package/dist/src/internal/mcp/streamable-http-server.d.ts +51 -0
- package/dist/src/internal/mcp/streamable-http-server.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts-retention.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-local-roots.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
- package/dist/src/internal/nitro/host/application-route-registry.d.ts +88 -0
- package/dist/src/internal/nitro/host/application-route-registry.js +1 -0
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-extension.js +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/channel-routes.d.ts +4 -11
- package/dist/src/internal/nitro/host/channel-routes.js +3 -3
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +3 -3
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-runner.js +1 -1
- package/dist/src/internal/nitro/host/dev-workspace-extensions.js +1 -1
- package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
- package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/start-production-server.js +2 -2
- package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +14 -0
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.d.ts +2 -0
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/process/pnpm.js +1 -1
- package/dist/src/internal/vercel-agent-summary.d.ts +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/internal/workflow/development-world-server.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +12 -8
- package/dist/src/internal/workflow-bundle/builder-support.js +8 -7
- package/dist/src/internal/workflow-bundle/builder.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +2 -3
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/protocol/message.d.ts +28 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/routes.d.ts +14 -0
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/auth.d.ts +36 -0
- package/dist/src/public/channels/auth.js +1 -1
- package/dist/src/public/channels/discord/discordChannel.d.ts +2 -0
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/eve.d.ts +2 -0
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/github/dispatch.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +2 -0
- package/dist/src/public/channels/linear/linearChannel.d.ts +2 -0
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/mcp.d.ts +19 -0
- package/dist/src/public/channels/mcp.js +1 -0
- package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +2 -0
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +3 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +2 -0
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +2 -0
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/twilioChannel.d.ts +2 -0
- package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/instrumentation/index.d.ts +9 -3
- package/dist/src/public/next/server.js +1 -1
- package/dist/src/public/nuxt/dev-server.js +1 -1
- package/dist/src/public/sveltekit/dev-server.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +4 -4
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/actions/types.d.ts +9 -0
- package/dist/src/runtime/actions/types.js +1 -1
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/connections/authorization-complete-page.js +70 -28
- package/dist/src/runtime/framework-channels/index.js +1 -1
- package/dist/src/runtime/framework-tools/index.js +1 -1
- package/dist/src/runtime/framework-tools/tasks.d.ts +95 -0
- package/dist/src/runtime/framework-tools/tasks.js +1 -0
- package/dist/src/runtime/prompt/compose.d.ts +1 -0
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/session-callback-route.js +1 -1
- package/dist/src/runtime/task-input-response-route.d.ts +5 -0
- package/dist/src/runtime/task-input-response-route.js +1 -0
- package/dist/src/services/inspect-application.js +1 -1
- package/dist/src/setup/primitives/pm/pnpm.js +2 -2
- package/dist/src/setup/primitives/run-vercel.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/extension.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +8 -86
- package/dist/src/setup/scaffold/version-tokens.js +1 -1
- package/dist/src/setup/scaffold/workspace-root.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +7 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +3 -3
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/json.d.ts +88 -0
- package/dist/src/tasks/json.js +1 -0
- package/dist/src/tasks/session-index.d.ts +48 -0
- package/dist/src/tasks/session-index.js +1 -0
- package/dist/src/tasks/task-id.d.ts +34 -0
- package/dist/src/tasks/task-id.js +1 -0
- package/dist/src/tasks/transitions.d.ts +23 -0
- package/dist/src/tasks/transitions.js +1 -0
- package/dist/src/tasks/types.d.ts +295 -0
- package/dist/src/tasks/types.js +1 -0
- package/dist/src/tasks/wire.d.ts +26 -0
- package/dist/src/tasks/wire.js +1 -0
- package/dist/src/tracing/install-instrumentation-runtime.d.ts +2 -1
- package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/otel-declaration.d.ts +32 -3
- package/dist/src/tracing/otel-declaration.js +1 -1
- package/dist/src/tracing/otel-registration.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +3 -3
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +1 -1
- package/docs/channels/discord.mdx +1 -1
- package/docs/channels/eve.mdx +15 -2
- package/docs/channels/github.mdx +1 -1
- package/docs/channels/linear.mdx +1 -1
- package/docs/channels/overview.mdx +1 -1
- package/docs/channels/photon.mdx +1 -1
- package/docs/channels/slack.mdx +1 -1
- package/docs/channels/teams.mdx +1 -1
- package/docs/channels/telegram.mdx +1 -1
- package/docs/channels/twilio.mdx +1 -1
- package/docs/extensions.md +10 -6
- package/docs/guides/client/streaming.mdx +7 -6
- package/docs/guides/frontend/overview.mdx +10 -8
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +10 -10
- package/docs/guides/frontend/use-eve-agent-vue.mdx +10 -10
- package/docs/install-integrations.mdx +4 -0
- package/docs/reference/cli.md +1 -1
- package/docs/schedules.mdx +2 -2
- package/docs/tools/human-in-the-loop.md +3 -1
- package/package.json +7 -1
- package/dist/src/compiled/_chunks/workflow/chunk-5MU5Z6L3-CaJgXkVg.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-CzdoBiqy.js +0 -1
- package/dist/src/compiled/_chunks/workflow/src-Cj3P1ChQ.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-util-DNwIAn_u.js +0 -27
- package/dist/src/execution/route-proxied-deliver-step.js +0 -1
|
@@ -41,7 +41,24 @@ export declare function notifyTurnCallerStep(input: {
|
|
|
41
41
|
readonly sessionId: string;
|
|
42
42
|
readonly settled: SettledTurnNotification;
|
|
43
43
|
}): Promise<void>;
|
|
44
|
+
/** Settles a task-owned caller after the child turn is cooperatively cancelled. */
|
|
45
|
+
export declare function notifyCancelledTaskCallerStep(input: {
|
|
46
|
+
readonly caller: TurnCaller | undefined;
|
|
47
|
+
readonly sessionId: string;
|
|
48
|
+
readonly usage?: TokenUsage;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
/** Binds a durable task to the exact child turn before execution starts. */
|
|
51
|
+
export declare function notifyTaskTurnStartedStep(input: {
|
|
52
|
+
readonly caller: TurnCaller | undefined;
|
|
53
|
+
readonly childSessionId: string;
|
|
54
|
+
readonly childTurnId: string;
|
|
55
|
+
}): Promise<void>;
|
|
44
56
|
/** Resolves the caller that created a delegated conversation session. */
|
|
45
57
|
export declare function resolveInitialTurnCallerStep(input: {
|
|
46
58
|
readonly serializedContext: Record<string, unknown>;
|
|
47
59
|
}): Promise<TurnCaller | undefined>;
|
|
60
|
+
/** Rebinds child event forwarding to the task that owns the next accepted turn. */
|
|
61
|
+
export declare function bindTurnCallerContextStep(input: {
|
|
62
|
+
readonly caller: TurnCaller | undefined;
|
|
63
|
+
readonly serializedContext: Record<string, unknown>;
|
|
64
|
+
}): Promise<Record<string, unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{SessionCallbackKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{parseJsonValue}from"#shared/json.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{SUBAGENT_EXECUTION_FAILED}from"#harness/agent-handle-errors.js";import{deserializeContext}from"#context/serialize.js";import{parseSessionCallback}from"#channel/session-callback.js";import{SUBAGENT_ADAPTER_KIND,isSubagentAdapterState}from"#execution/subagent-adapter-state.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeHook}from"#internal/workflow/runtime.js";import{postSessionCallbackRequest}from"#execution/session-callback-request.js";const log=createLogger(`execution.delegated-parent-notification`);async function notifyDelegatedParentStep(e){"use step";if(e.result===void 0)return;let t=(await deserializeContext(e.serializedContext)).get(ChannelKey);if(t?.kind!==SUBAGENT_ADAPTER_KIND)return;let n=String(t.state?.parentContinuationToken??``);n!==``&&await resumeHook(n,{kind:`runtime-action-result`,results:[e.usage===void 0
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{SessionCallbackKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{parseJsonValue}from"#shared/json.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{SUBAGENT_EXECUTION_FAILED}from"#harness/agent-handle-errors.js";import{readTaskIdFromInboxToken}from"#tasks/task-id.js";import{deserializeContext}from"#context/serialize.js";import{parseSessionCallback}from"#channel/session-callback.js";import{SUBAGENT_ADAPTER_KIND,isSubagentAdapterState}from"#execution/subagent-adapter-state.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeHook}from"#internal/workflow/runtime.js";import{postSessionCallbackRequest}from"#execution/session-callback-request.js";const log=createLogger(`execution.delegated-parent-notification`);async function notifyDelegatedParentStep(e){"use step";if(e.result===void 0)return;let t=(await deserializeContext(e.serializedContext)).get(ChannelKey);if(t?.kind!==SUBAGENT_ADAPTER_KIND)return;let n=String(t.state?.parentContinuationToken??``);n!==``&&await resumeHook(n,{kind:`runtime-action-result`,results:[e.usage===void 0?e.result:{...e.result,outcome:{...e.result.outcome,usageDelta:e.usage},usage:e.usage}]})}const ZERO_TOKEN_USAGE={cacheReadTokens:0,cacheWriteTokens:0,inputTokens:0,outputTokens:0};async function notifyTurnCallerStep(e){"use step";if(e.caller===void 0)return;let t=createSettledTurnResult({caller:e.caller,lifecycle:e.lifecycle,sessionId:e.sessionId,settled:e.settled});if(e.caller.replyTo.kind===`callback`){await postSettledTurnCallback({result:t,sessionId:e.sessionId,url:e.caller.replyTo.url});return}await resumeSettledTurnHook(e.caller.replyTo.token,t)}async function notifyCancelledTaskCallerStep(e){"use step";if(e.caller?.taskId===void 0)return;let t=e.usage??ZERO_TOKEN_USAGE,n={callId:e.caller.callId,kind:`subagent-result`,origin:`child`,outcome:{kind:`parked`,result:{kind:`cancelled`},usageDelta:t},output:``,subagentName:e.caller.subagentName},r=e.usage===void 0?n:{...n,usage:e.usage};if(e.caller.replyTo.kind===`callback`){await postSettledTurnCallback({result:r,sessionId:e.sessionId,url:e.caller.replyTo.url});return}await resumeSettledTurnHook(e.caller.replyTo.token,r)}async function notifyTaskTurnStartedStep(e){"use step";let t=e.caller?.taskId;if(e.caller===void 0||t===void 0)return;let n={childSessionId:e.childSessionId,childTurnId:e.childTurnId,kind:`turn-started`,taskId:t};if(e.caller.replyTo.kind===`hook`){await resumeHook(e.caller.replyTo.token,n);return}let r=await postSessionCallbackRequest({body:{callId:e.caller.callId,kind:`turn.started`,sessionId:e.childSessionId,subagentName:e.caller.subagentName,taskId:t,turnId:e.childTurnId},url:e.caller.replyTo.url});if(!r.ok)throw Error(`Task turn-start callback failed with HTTP ${r.status}.`)}function createSettledTurnResult(e){let t=e.settled.usage??ZERO_TOKEN_USAGE;if(e.settled.isError===!0){let r={code:SUBAGENT_EXECUTION_FAILED,message:toErrorMessage(e.settled.output)};return{callId:e.caller.callId,isError:!0,kind:`subagent-result`,origin:`child`,outcome:{kind:e.lifecycle,result:{error:r,kind:`failed`},usageDelta:t},output:r,subagentName:e.caller.subagentName}}let i=parseJsonValue(e.settled.output),o={callId:e.caller.callId,kind:`subagent-result`,origin:`child`,outcome:{kind:e.lifecycle,result:{kind:`succeeded`,output:i},usageDelta:t},output:i,subagentName:e.caller.subagentName};return e.settled.usage===void 0?o:{...o,usage:e.settled.usage}}async function resolveInitialTurnCallerStep(e){"use step";let n=e.serializedContext[SessionCallbackKey.name];if(n!==void 0){let e=parseSessionCallback(n);if(!e.ok)throw Error(`Serialized session callback is invalid.`,{cause:e.cause});return{callId:e.callback.callId,replyTo:{kind:`callback`,token:e.callback.token,url:e.callback.url},subagentName:e.callback.subagentName,taskId:e.callback.taskId??readTaskIdFromInboxToken(e.callback.token)}}let r=(await deserializeContext(e.serializedContext)).get(ChannelKey);if(!(r?.kind!==SUBAGENT_ADAPTER_KIND||!isSubagentAdapterState(r.state)))return{callId:r.state.callId,replyTo:{kind:`hook`,token:r.state.parentContinuationToken},subagentName:r.state.subagentName,taskId:readTaskIdFromInboxToken(r.state.parentContinuationToken)}}async function bindTurnCallerContextStep(e){"use step";let n=e.caller;if(n?.taskId===void 0)return e.serializedContext;if(n.replyTo.kind===`callback`)return{...e.serializedContext,[SessionCallbackKey.name]:{callId:n.callId,subagentName:n.subagentName,taskId:n.taskId,token:n.replyTo.token,url:n.replyTo.url}};let r=e.serializedContext[ChannelKey.name];if(typeof r!=`object`||!r||Reflect.get(r,`kind`)!==SUBAGENT_ADAPTER_KIND||!isSubagentAdapterState(Reflect.get(r,`state`)))throw Error(`Task-owned local turn is missing its subagent adapter binding.`);let a=Reflect.get(r,`state`);return{...e.serializedContext,[ChannelKey.name]:{...r,state:{...a,callId:n.callId,parentContinuationToken:n.replyTo.token,subagentName:n.subagentName}}}}async function postSettledTurnCallback(e){let{sessionId:t}=e;if(e.result.isError===!0){await postCallbackPayload({payload:{callId:e.result.callId,error:e.result.output,kind:`turn.failed`,outcome:e.result.outcome,sessionId:t,subagentName:e.result.subagentName},url:e.url});return}await postCallbackPayload({payload:{callId:e.result.callId,kind:`turn.completed`,outcome:e.result.outcome,output:e.result.output,sessionId:t,subagentName:e.result.subagentName},url:e.url})}async function postCallbackPayload(e){let t=await postSessionCallbackRequest({body:e.payload,url:e.url});if(!t.ok)throw Error(`Turn callback failed with HTTP ${t.status}.`)}async function resumeSettledTurnHook(e,t){try{await resumeHook(e,{kind:`runtime-action-result`,results:[t]})}catch(n){if(!HookNotFoundError.is(n))throw n;log.warn(`turn caller hook no longer exists`,{callId:t.callId,callerToken:e})}}export{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTaskTurnStartedStep,notifyTurnCallerStep,resolveInitialTurnCallerStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{coalesceTurnInputs}from"#harness/messages.js";const COALESCED_DELIVER_FIELDS=[`context`,`inputResponses`,`message`,`outputSchema`];function coalesceDeliverPayloads(n){if(n.length===0)return{};if(n.length===1)return n[0]??{};let r={},i={};for(let t of n){for(let[e,n]of Object.entries(t))n!==void 0&&(r[e]=n);
|
|
1
|
+
import{coalesceTurnInputs}from"#harness/messages.js";const COALESCED_DELIVER_FIELDS=[`context`,`inputResponses`,`message`,`outputSchema`,`task`];function coalesceDeliverPayloads(n){if(n.length===0)return{};if(n.length===1)return n[0]??{};let r={},i=[],a=[],o=[],s={};for(let t of n){i.push(...t.task?.inputRequests??[]),a.push(...t.task?.authorizationEvents??[]),o.push(...t.task?.views??[]);for(let[e,n]of Object.entries(t))n!==void 0&&(r[e]=n);s=coalesceTurnInputs(s,t)}for(let e of COALESCED_DELIVER_FIELDS)delete r[e];let c={};return i.length>0&&(c.inputRequests=i),a.length>0&&(c.authorizationEvents=a),o.length>0&&(c.views=o),Object.keys(c).length>0&&(r.task=c),Object.assign(r,s)}export{coalesceDeliverPayloads};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machinery shared by the two runtime-action dispatch steps:
|
|
3
|
+
* `dispatchRuntimeActionsStep` (plain mode) and `dispatchTaskStep`
|
|
4
|
+
* (task mode). Both run the same preflight → plan → dispatch → emit
|
|
5
|
+
* skeleton over one pending batch and differ only in the per-entry
|
|
6
|
+
* delegation lifecycle, so planning, subagent starts, and the
|
|
7
|
+
* replay-safe `subagent.called` emission tail live here.
|
|
8
|
+
*/
|
|
9
|
+
import { type ChannelAdapter, type ChannelAdapterContext } from "#channel/adapter.js";
|
|
10
|
+
import { type CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
11
|
+
import { type DispatchOutcome, type RuntimeAgentHandleAction, type RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
12
|
+
import { getPendingRuntimeActionBatch } from "#harness/runtime-actions.js";
|
|
13
|
+
import type { RuntimeActionResult, RuntimeRemoteAgentCallActionRequest, RuntimeSubagentCallActionRequest, RuntimeSubagentDispatchFailure, RuntimeToolCallActionRequest } from "#runtime/actions/types.js";
|
|
14
|
+
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
15
|
+
import { buildSubagentRunInput, type SubagentInputSource } from "#execution/subagent-tool.js";
|
|
16
|
+
import { getDynamicSubagentSelection } from "#context/dynamic-subagent-lifecycle.js";
|
|
17
|
+
type DynamicSubagentAgentConfig = NonNullable<Extract<ReturnType<typeof getDynamicSubagentSelection>, {
|
|
18
|
+
readonly kind: "subagent";
|
|
19
|
+
}>["agentConfig"]>;
|
|
20
|
+
type DynamicRemoteAgentConfig = NonNullable<Extract<ReturnType<typeof getDynamicSubagentSelection>, {
|
|
21
|
+
readonly kind: "remote";
|
|
22
|
+
}>["remoteAgent"]>;
|
|
23
|
+
export type DispatchPlanEntry = {
|
|
24
|
+
readonly kind: "resume";
|
|
25
|
+
readonly action: RuntimeAgentHandleAction;
|
|
26
|
+
readonly agentId: string;
|
|
27
|
+
readonly dynamicRemoteAgent?: DynamicRemoteAgentConfig;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: "reject";
|
|
30
|
+
readonly result: RuntimeSubagentDispatchFailure;
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "start";
|
|
33
|
+
readonly target: DispatchStartTarget;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "task-control";
|
|
36
|
+
readonly action: RuntimeToolCallActionRequest;
|
|
37
|
+
};
|
|
38
|
+
export type DispatchStartTarget = {
|
|
39
|
+
readonly kind: "local";
|
|
40
|
+
readonly action: RuntimeSubagentCallActionRequest;
|
|
41
|
+
readonly dynamicSubagentAgentConfig?: DynamicSubagentAgentConfig;
|
|
42
|
+
readonly source: SubagentInputSource;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "remote";
|
|
45
|
+
readonly action: RuntimeRemoteAgentCallActionRequest;
|
|
46
|
+
readonly dynamicRemoteAgent?: DynamicRemoteAgentConfig;
|
|
47
|
+
};
|
|
48
|
+
/** Input contract shared by both dispatch steps so the turn workflow can select either. */
|
|
49
|
+
export interface RuntimeActionDispatchInput {
|
|
50
|
+
readonly callbackBaseUrl?: string;
|
|
51
|
+
/** Internal hook that receives child completion and HITL payloads. */
|
|
52
|
+
readonly parentContinuationToken?: string;
|
|
53
|
+
readonly parentWritable: WritableStream<Uint8Array>;
|
|
54
|
+
readonly serializedContext: Record<string, unknown>;
|
|
55
|
+
readonly sessionState: DurableSessionState;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Result contract shared by both dispatch steps. `pendingTasks` is
|
|
59
|
+
* always empty in plain mode; keeping it on both keeps the turn
|
|
60
|
+
* workflow's acknowledgement call site uniform.
|
|
61
|
+
*/
|
|
62
|
+
export interface RuntimeActionDispatchResult {
|
|
63
|
+
readonly results: readonly RuntimeActionResult[];
|
|
64
|
+
readonly sessionState: DurableSessionState;
|
|
65
|
+
readonly pendingTasks: readonly {
|
|
66
|
+
readonly taskInboxToken: string;
|
|
67
|
+
readonly taskId: string;
|
|
68
|
+
readonly taskRunId: string;
|
|
69
|
+
}[];
|
|
70
|
+
}
|
|
71
|
+
/** Everything preflight produces before either step's dispatch loop runs. */
|
|
72
|
+
export interface PreparedRuntimeActionDispatch {
|
|
73
|
+
readonly adapter: ChannelAdapter;
|
|
74
|
+
readonly adapterCtx: ChannelAdapterContext;
|
|
75
|
+
readonly auth: Parameters<typeof buildSubagentRunInput>[0]["auth"];
|
|
76
|
+
readonly batch: NonNullable<ReturnType<typeof getPendingRuntimeActionBatch>>;
|
|
77
|
+
readonly bundle: CompiledBundle;
|
|
78
|
+
readonly capabilities: Parameters<typeof buildSubagentRunInput>[0]["capabilities"];
|
|
79
|
+
readonly channelMetadata: Parameters<typeof buildSubagentRunInput>[0]["channelMetadata"];
|
|
80
|
+
/**
|
|
81
|
+
* Number of freshly started local subagents in the plan. The parent's
|
|
82
|
+
* remaining token quota is split across these, the children that
|
|
83
|
+
* actually receive an enforced cap: continuations already run under
|
|
84
|
+
* their own budget, and remote agents run on their own deployment
|
|
85
|
+
* under their own limits, so neither dilutes the local shares.
|
|
86
|
+
*/
|
|
87
|
+
readonly fanoutSize: number;
|
|
88
|
+
readonly initiatorAuth: Parameters<typeof buildSubagentRunInput>[0]["initiatorAuth"];
|
|
89
|
+
readonly parentTraceContext: Parameters<typeof buildSubagentRunInput>[0]["parentTraceContext"];
|
|
90
|
+
readonly serializedContext: Record<string, unknown>;
|
|
91
|
+
readonly plan: readonly DispatchPlanEntry[];
|
|
92
|
+
readonly session: RuntimeSession;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Runs every dispatch precondition that may throw — durable reads, context
|
|
96
|
+
* deserialization, handle-store validation, and batch planning — before
|
|
97
|
+
* the caller acquires the parent stream writer, so a preflight failure
|
|
98
|
+
* never leaks the writer lock. Returns undefined when no actions are
|
|
99
|
+
* pending.
|
|
100
|
+
*/
|
|
101
|
+
export declare function prepareRuntimeActionDispatch(input: {
|
|
102
|
+
readonly serializedContext: Record<string, unknown>;
|
|
103
|
+
readonly sessionState: DurableSessionState;
|
|
104
|
+
/**
|
|
105
|
+
* Classify `task_peek` / `task_cancel` / `task_send` calls as
|
|
106
|
+
* task-control plan entries. Only task mode plans them; in plain mode
|
|
107
|
+
* those calls fail as unsupported batch actions.
|
|
108
|
+
*/
|
|
109
|
+
readonly taskControls: boolean;
|
|
110
|
+
}): Promise<PreparedRuntimeActionDispatch | undefined>;
|
|
111
|
+
/**
|
|
112
|
+
* Emits the parent `subagent.called` control-plane event for one adopted
|
|
113
|
+
* child. Emission is observability, not control flow: a failure is logged
|
|
114
|
+
* and swallowed, because a throw escaping the dispatch loop would durably
|
|
115
|
+
* replay the step and re-dispatch children that already started.
|
|
116
|
+
*/
|
|
117
|
+
export declare function emitSubagentCalled(input: {
|
|
118
|
+
readonly adapter: ChannelAdapter;
|
|
119
|
+
readonly adapterCtx: ChannelAdapterContext;
|
|
120
|
+
readonly batchEvent: {
|
|
121
|
+
readonly sequence: number;
|
|
122
|
+
readonly turnId: string;
|
|
123
|
+
};
|
|
124
|
+
readonly entry: Extract<DispatchPlanEntry, {
|
|
125
|
+
readonly kind: "resume" | "start";
|
|
126
|
+
}>;
|
|
127
|
+
readonly outcome: Extract<DispatchOutcome, {
|
|
128
|
+
readonly kind: "called";
|
|
129
|
+
}>;
|
|
130
|
+
readonly sessionId: string;
|
|
131
|
+
readonly writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
/** Starts one planned fresh child against its local or remote target. */
|
|
134
|
+
export declare function startSubagent(input: {
|
|
135
|
+
readonly auth: Parameters<typeof buildSubagentRunInput>[0]["auth"];
|
|
136
|
+
readonly batchEvent: {
|
|
137
|
+
readonly sequence: number;
|
|
138
|
+
readonly turnId: string;
|
|
139
|
+
};
|
|
140
|
+
readonly bundle: CompiledBundle;
|
|
141
|
+
readonly callbackBaseUrl: string | undefined;
|
|
142
|
+
readonly capabilities: Parameters<typeof buildSubagentRunInput>[0]["capabilities"];
|
|
143
|
+
readonly channelMetadata: Parameters<typeof buildSubagentRunInput>[0]["channelMetadata"];
|
|
144
|
+
readonly currentSession: RuntimeSession;
|
|
145
|
+
readonly fanoutSize: number;
|
|
146
|
+
readonly initiatorAuth: Parameters<typeof buildSubagentRunInput>[0]["initiatorAuth"];
|
|
147
|
+
readonly parentContinuationToken: string | undefined;
|
|
148
|
+
readonly parentTraceContext: Parameters<typeof buildSubagentRunInput>[0]["parentTraceContext"];
|
|
149
|
+
readonly persistentSessions: boolean;
|
|
150
|
+
readonly serializedContext: Record<string, unknown>;
|
|
151
|
+
readonly session: RuntimeSession;
|
|
152
|
+
readonly taskOwned: boolean;
|
|
153
|
+
readonly target: DispatchStartTarget;
|
|
154
|
+
}): Promise<DispatchOutcome>;
|
|
155
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey}from"#context/keys.js";import{createSubagentCalledEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getAgentHandleStore}from"#harness/handles/store.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{isAgentHandleAction}from"#execution/agent-handle-dispatch.js";import{readActionTraceContext,readSessionTraceContext}from"#tracing/agent-trace-context-store.js";import{assertUniqueRuntimeActionCallIds,getPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{createRecursiveAgentRootOnlyResult,createUnavailableDynamicSubagentResult,getSubagentName}from"#execution/dispatch-action-failures.js";import{startLocalSubagent}from"#execution/subagent-start-local.js";import{startRemoteSubagent}from"#execution/subagent-start-remote.js";import"#execution/subagent-tool.js";import{resolveSubagentDepth}from"#harness/subagent-depth.js";import{isTaskControlAction}from"#execution/tasks/parent/dispatch.js";const log=createLogger(`execution.dispatch-runtime-actions`);async function prepareRuntimeActionDispatch(e){let t=await readDurableSession(e.sessionState),n=getPendingRuntimeActionBatch(t.state);if(n===void 0||n.actions.length===0)return;assertUniqueRuntimeActionCallIds(n.actions);let s=await deserializeContext(e.serializedContext),c=s.require(BundleKey),l=resolveEffectiveAgentRuntime(c,s),u=hydrateDurableSession({compactionOverrides:{thresholdPercent:l.thresholdPercent},durable:t,turnAgent:l.turnAgent}),d=s.require(ChannelKey);getAgentHandleStore(t.state);let f=planDispatch({actions:n.actions,bundle:c,ctx:s,session:u,taskControls:e.taskControls});return{adapter:d,adapterCtx:buildAdapterContext(d,s),auth:s.get(AuthKey)??null,batch:n,bundle:c,capabilities:s.get(CapabilitiesKey),channelMetadata:s.get(ChannelInstrumentationKey),fanoutSize:f.filter(e=>e.kind===`start`&&e.target.kind===`local`).length,initiatorAuth:s.get(InitiatorAuthKey)??null,parentTraceContext:readSessionTraceContext(e.serializedContext,u.sessionId),plan:f,serializedContext:e.serializedContext,session:u}}async function emitSubagentCalled(e){let{entry:r,outcome:i}=e;try{let t=r.kind===`resume`?r.action:r.target.action,a=r.kind===`resume`?r.dynamicRemoteAgent:r.target.kind===`remote`?r.target.dynamicRemoteAgent:void 0,o=await callAdapterEventHandler(e.adapter,createSubagentCalledEvent({callId:i.callId,childSessionId:i.address.sessionId,name:i.name,remote:i.address.kind===`agent/remote`?{resolverId:a===void 0?t.nodeId:a.credentialsStepId,url:i.address.url}:void 0,sequence:e.batchEvent.sequence,sessionId:e.sessionId,toolName:i.toolName,turnId:e.batchEvent.turnId,workflowId:workflowEntryReference.workflowId}),e.adapterCtx);await e.writer.write(encodeMessageStreamEvent(stampMessageStreamEvent(o)))}catch(e){logError(log,`subagent.called emission failed`,e,{callId:i.callId,childSessionId:i.address.sessionId,toolName:i.toolName})}}function planDispatch(e){let t=getAgentHandleStore(e.session.state)?.handles??[];return e.actions.map(n=>{if(e.taskControls&&isTaskControlAction(n))return{action:n,kind:`task-control`};let r=n.input.agentId,i=typeof r==`string`&&r.trim()!==``?r:void 0;if(i!==void 0&&isAgentHandleAction(n)){if(t.some(e=>e.identity.id===i)){let t=e.bundle.subagentRegistry.dynamicNodeIds?.has(n.nodeId)===!0?getDynamicSubagentSelection(e.ctx,n.nodeId):void 0;return{action:n,agentId:i,dynamicRemoteAgent:n.kind===`remote-agent-call`&&t?.kind===`remote`?t.remoteAgent:void 0,kind:`resume`}}log.warn(`unknown agentId on subagent call; starting a new agent`,{agentId:i,callId:n.callId})}return classifyFreshStart({action:n,bundle:e.bundle,ctx:e.ctx,session:e.session})})}function classifyFreshStart(e){let{action:t}=e,n=e.bundle.subagentRegistry.subagentsByNodeId,r=resolveSubagentDepth(e.session),i=e.session.rootSessionId!==void 0||r.currentDepth>0,a=(t.kind===`subagent-call`||t.kind===`remote-agent-call`)&&e.bundle.subagentRegistry.dynamicNodeIds?.has(t.nodeId)===!0,o=a?getDynamicSubagentSelection(e.ctx,t.nodeId):void 0;if(a&&(o===void 0||t.kind===`subagent-call`&&o.kind!==`subagent`||t.kind===`remote-agent-call`&&o.kind!==`remote`)){let e=getSubagentName(t);return log.warn(`dynamic subagent call blocked after availability changed`,{callId:t.callId,nodeId:t.nodeId,subagentName:e}),{kind:`reject`,result:createUnavailableDynamicSubagentResult(t)}}if(isRecursiveAgentAction(t,n)&&i)return log.warn(`recursive agent call blocked outside the root session`,{callId:t.callId,currentDepth:r.currentDepth,nodeId:t.nodeId,subagentName:t.subagentName}),{kind:`reject`,result:createRecursiveAgentRootOnlyResult(t)};switch(t.kind){case`subagent-call`:{let e=o?.kind===`subagent`?o.agentConfig:void 0,r=n.get(t.nodeId),i=e?.description??(r?.definition.kind===`subagent`?r.definition.description:void 0);return{kind:`start`,target:{action:t,dynamicSubagentAgentConfig:e,kind:`local`,source:i===void 0?{type:`runtime`}:{description:i,type:`local`}}}}case`remote-agent-call`:return{kind:`start`,target:{action:t,dynamicRemoteAgent:o?.kind===`remote`?o.remoteAgent:void 0,kind:`remote`}};default:throw Error(`Unsupported runtime action kind "${t.kind}" in workflow runtime.`)}}async function startSubagent(e){let t=readActionTraceContext(e.serializedContext,e.session.sessionId,e.batchEvent.turnId,e.target.action.callId)??e.parentTraceContext;switch(e.target.kind){case`local`:return startLocalSubagent({action:e.target.action,auth:e.auth,batchEvent:e.batchEvent,bundle:e.bundle,capabilities:e.capabilities,channelMetadata:e.channelMetadata,currentSession:e.currentSession,dynamicSubagentAgentConfig:e.target.dynamicSubagentAgentConfig,fanoutSize:e.fanoutSize,initiatorAuth:e.initiatorAuth,parentContinuationToken:e.parentContinuationToken,parentTraceContext:t,persistentSessions:e.persistentSessions,session:e.session,source:e.target.source,taskOwned:e.taskOwned});case`remote`:return startRemoteSubagent({action:e.target.action,auth:e.auth,batchEvent:e.batchEvent,bundle:e.bundle,callbackBaseUrl:e.callbackBaseUrl,currentSession:e.currentSession,dynamicRemoteAgent:e.target.dynamicRemoteAgent,initiatorAuth:e.initiatorAuth,parentContinuationToken:e.parentContinuationToken,parentTraceContext:t,persistentSessions:e.persistentSessions,session:e.session,taskOwned:e.taskOwned});default:return e.target}}function isRecursiveAgentAction(e,t){return e.kind===`subagent-call`&&e.subagentName===`agent`&&!t.has(e.nodeId)}export{emitSubagentCalled,prepareRuntimeActionDispatch,startSubagent};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Starts or continues every pending runtime action for the parked parent
|
|
3
|
+
* session, with children reporting straight back to the parent turn via
|
|
4
|
+
* `parentContinuationToken`.
|
|
5
|
+
*
|
|
6
|
+
* The batch is classified into a dispatch plan first (reject / resume /
|
|
7
|
+
* start), then each entry dispatches and emits one
|
|
8
|
+
* parent `subagent.called` control-plane event through a single tail.
|
|
9
|
+
* Every start commits an agent handle (`starting`) before its side effect
|
|
10
|
+
* and confirms it (`running`) once the child reports coordinates, so the
|
|
11
|
+
* returned snapshot-bearing state owns every child it may have created.
|
|
12
|
+
*
|
|
13
|
+
* Agents running `experimental.tasks` never reach this step: the turn
|
|
14
|
+
* workflow selects `dispatchTaskStep`, the task-mode sibling that wraps
|
|
15
|
+
* each dispatch in the delegated-task lifecycle.
|
|
16
|
+
*/
|
|
17
|
+
import { type RuntimeActionDispatchInput, type RuntimeActionDispatchResult } from "#execution/dispatch-runtime-actions-shared.js";
|
|
18
|
+
export declare function dispatchRuntimeActionsStep(input: RuntimeActionDispatchInput): Promise<RuntimeActionDispatchResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{createSubagentCalledEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/remote-agent-dispatch.js";import{SUBAGENT_START_FAILED}from"#harness/agent-handle-errors.js";import{confirmAgentStarted,prepareAgentStart,rejectAgentEffect}from"#harness/handles/transitions.js";import{createWorkflowRuntime,workflowEntryReference}from"#execution/workflow-runtime.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#harness/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{dispatchToAgentHandle,isAgentHandleAction}from"#execution/agent-handle-dispatch.js";import{createAgentContinuationBundle}from"#execution/agent-continuation-bundle.js";import{getPendingRuntimeActionBatch,setPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{createRecursiveAgentRootOnlyResult,createRemoteAgentStartFailureResult,createUnavailableDynamicSubagentResult,getSubagentName}from"#execution/dispatch-action-failures.js";import{mintStartOperation}from"#execution/dispatch-start-operation.js";import{buildSubagentRunInput}from"#execution/subagent-tool.js";import*as traceState from"#tracing/agent-trace-context-store.js";import{resolveSubagentDepth}from"#harness/subagent-depth.js";import{activeTurnId}from"#harness/active-turn-id.js";const log=createLogger(`execution.dispatch-runtime-actions`);async function dispatchRuntimeActionsStep(e){"use step";let s=await readDurableSession(e.sessionState),p=getPendingRuntimeActionBatch(s.state);if(p===void 0||p.actions.length===0)return{results:[],sessionState:e.sessionState};let m=p.event.turnId||activeTurnId(e.sessionState.emissionState),h={...p.event,turnId:m},g=await deserializeContext(e.serializedContext),_=g.require(BundleKey),v=resolveEffectiveAgentRuntime(_,g),y=setPendingRuntimeActionBatch({...p,event:h,session:hydrateDurableSession({compactionOverrides:{thresholdPercent:v.thresholdPercent},durable:s,turnAgent:v.turnAgent})}),b=g.require(ChannelKey),x=g.get(AuthKey)??null,S=g.get(CapabilitiesKey),C=g.get(ChannelInstrumentationKey),w=g.get(InitiatorAuthKey)??null,T=buildAdapterContext(b,g),E=traceState.readSessionTraceContext(e.serializedContext,y.sessionId),D=_.resolvedAgent.config?.experimental?.subagentPersistentSessions===!0;getAgentHandleStore(s.state);let O=planDispatch({actions:p.actions,bundle:_,ctx:g,session:y}),k=e.parentWritable.getWriter(),A=O.filter(e=>e.kind===`start`&&e.target.kind===`local`).length,j=y,M=[];try{for(let r of O){if(r.kind===`reject`){M.push(r.result);continue}let i;switch(r.kind){case`resume`:i=await dispatchToAgentHandle({action:r.action,agentId:r.agentId,bundle:createAgentContinuationBundle({action:r.action,bundle:_,dynamicRemoteAgent:r.dynamicRemoteAgent}),currentSession:j,parentToken:e.parentContinuationToken??y.continuationToken,parentTurnId:m});break;case`start`:i=await startSubagent({auth:x,batchEvent:h,bundle:_,callbackBaseUrl:e.callbackBaseUrl,capabilities:S,channelMetadata:C,currentSession:j,fanoutSize:A,initiatorAuth:w,parentContinuationToken:e.parentContinuationToken,parentTraceContext:traceState.readActionTraceContext(e.serializedContext,y.sessionId,p.event.turnId,r.target.action.callId)??E,persistentSessions:D,session:y,target:r.target});break}if(j=i.session,i.kind===`error`){M.push(i.result);continue}try{let e=await callAdapterEventHandler(b,createSubagentCalledEvent({callId:i.callId,childSessionId:i.address.sessionId,name:i.name,remote:i.address.kind===`agent/remote`?{url:i.address.url}:void 0,sequence:h.sequence,sessionId:y.sessionId,toolName:i.toolName,turnId:m,workflowId:workflowEntryReference.workflowId}),T);await k.write(encodeMessageStreamEvent(stampMessageStreamEvent(e)))}catch(e){logError(log,`subagent.called emission failed`,e,{callId:i.callId,childSessionId:i.address.sessionId,toolName:i.toolName})}}}finally{k.releaseLock()}return{results:M,sessionState:j===y&&p.event.turnId===m?e.sessionState:createDurableSessionState({session:j})}}function planDispatch(e){let t=getAgentHandleStore(e.session.state)?.handles??[];return e.actions.map(n=>{let r=n.input.agentId,i=typeof r==`string`&&r.trim()!==``?r:void 0;if(i!==void 0&&isAgentHandleAction(n)){if(t.some(e=>e.identity.id===i)){let t=e.bundle.subagentRegistry.dynamicNodeIds?.has(n.nodeId)===!0?getDynamicSubagentSelection(e.ctx,n.nodeId):void 0;return{action:n,agentId:i,dynamicRemoteAgent:n.kind===`remote-agent-call`&&t?.kind===`remote`?t.remoteAgent:void 0,kind:`resume`}}log.warn(`unknown agentId on subagent call; starting a new agent`,{agentId:i,callId:n.callId})}return classifyFreshStart({action:n,bundle:e.bundle,ctx:e.ctx,session:e.session})})}function classifyFreshStart(e){let{action:t}=e,n=e.bundle.subagentRegistry.subagentsByNodeId,r=resolveSubagentDepth(e.session),i=e.session.rootSessionId!==void 0||r.currentDepth>0,a=(t.kind===`subagent-call`||t.kind===`remote-agent-call`)&&e.bundle.subagentRegistry.dynamicNodeIds?.has(t.nodeId)===!0,o=a?getDynamicSubagentSelection(e.ctx,t.nodeId):void 0;if(a&&(o===void 0||t.kind===`subagent-call`&&o.kind!==`subagent`||t.kind===`remote-agent-call`&&o.kind!==`remote`)){let e=getSubagentName(t);return log.warn(`dynamic subagent call blocked after availability changed`,{callId:t.callId,nodeId:t.nodeId,subagentName:e}),{kind:`reject`,result:createUnavailableDynamicSubagentResult(t)}}if(isRecursiveAgentAction(t,n)&&i)return log.warn(`recursive agent call blocked outside the root session`,{callId:t.callId,currentDepth:r.currentDepth,nodeId:t.nodeId,subagentName:t.subagentName}),{kind:`reject`,result:createRecursiveAgentRootOnlyResult(t)};switch(t.kind){case`subagent-call`:{let e=o?.kind===`subagent`?o.agentConfig:void 0,r=n.get(t.nodeId),i=e?.description??(r?.definition.kind===`subagent`?r.definition.description:void 0);return{kind:`start`,target:{action:t,dynamicSubagentAgentConfig:e,kind:`local`,source:i===void 0?{type:`runtime`}:{description:i,type:`local`}}}}case`remote-agent-call`:return{kind:`start`,target:{action:t,dynamicRemoteAgent:o?.kind===`remote`?o.remoteAgent:void 0,kind:`remote`}};default:throw Error(`Unsupported runtime action kind "${t.kind}" in workflow runtime.`)}}async function startSubagent(e){switch(e.target.kind){case`local`:return startLocalSubagent({action:e.target.action,auth:e.auth,batchEvent:e.batchEvent,bundle:e.bundle,capabilities:e.capabilities,channelMetadata:e.channelMetadata,currentSession:e.currentSession,dynamicSubagentAgentConfig:e.target.dynamicSubagentAgentConfig,fanoutSize:e.fanoutSize,initiatorAuth:e.initiatorAuth,parentContinuationToken:e.parentContinuationToken,parentTraceContext:e.parentTraceContext,persistentSessions:e.persistentSessions,session:e.session,source:e.target.source});case`remote`:return startRemoteSubagent({action:e.target.action,auth:e.auth,batchEvent:e.batchEvent,bundle:e.bundle,callbackBaseUrl:e.callbackBaseUrl,currentSession:e.currentSession,dynamicRemoteAgent:e.target.dynamicRemoteAgent,initiatorAuth:e.initiatorAuth,parentContinuationToken:e.parentContinuationToken,parentTraceContext:e.parentTraceContext,persistentSessions:e.persistentSessions,session:e.session});default:return e.target}}async function startLocalSubagent(e){let{action:n,source:r}=e,i=createWorkflowRuntime({compiledArtifactsSource:e.bundle.compiledArtifactsSource,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,nodeId:n.nodeId}),{childContinuationToken:a,runInput:o}=buildSubagentRunInput({action:n,auth:e.auth,batchEvent:e.batchEvent,capabilities:e.capabilities,channelMetadata:e.channelMetadata,fanoutSize:e.fanoutSize,initiatorAuth:e.initiatorAuth,parentContinuationToken:e.parentContinuationToken,parentTraceContext:e.parentTraceContext,persistentSessions:e.persistentSessions,session:e.session,source:r}),c=r.type===`runtime`?`agent/self`:`agent/local`,{identity:l,operation:u}=mintStartOperation({callId:n.callId,name:n.subagentName,nodeId:n.nodeId,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),d=prepareAgentStart(e.currentSession,{identity:l,operation:u,target:{continuationToken:a,kind:c}}),f;try{f=(await i.createSession(o)).sessionId}catch(e){return logError(log,`local subagent start failed`,e,{callId:n.callId,nodeId:n.nodeId,subagentName:n.subagentName}),{kind:`error`,result:{callId:n.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:SUBAGENT_START_FAILED,message:toErrorMessage(e)},subagentName:n.subagentName},session:rejectAgentEffect(d,{disposition:`dead`,operationId:u.id})}}let p={continuationToken:a,kind:c,sessionId:f};return{address:p,callId:n.callId,kind:`called`,name:n.name,session:confirmAgentStarted(d,{address:p,operationId:u.id}),toolName:n.subagentName}}async function startRemoteSubagent(e){let{action:n}=e,r,i;try{if(e.callbackBaseUrl===void 0)throw Error(`Cannot dispatch remote agent without a callback base URL.`);r=e.callbackBaseUrl,i=resolveRemoteAgentForAction({dynamicRemoteAgent:e.dynamicRemoteAgent,nodeId:n.nodeId,remoteAgentName:n.remoteAgentName,registry:e.bundle.subagentRegistry.subagentsByNodeId})}catch(r){return logError(log,`remote agent start failed`,r,{remoteAgentName:n.remoteAgentName,nodeId:n.nodeId,callId:n.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:n,error:r}),session:e.currentSession}}let{identity:a,operation:o}=mintStartOperation({callId:n.callId,name:n.remoteAgentName,nodeId:n.nodeId,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),s=prepareAgentStart(e.currentSession,{identity:a,operation:o,target:{callbackBaseUrl:r,kind:`agent/remote`,url:i.url}});try{let t=await startRemoteAgentSession({action:n,auth:e.auth,callbackBaseUrl:r,callbackToken:e.parentContinuationToken,initiatorAuth:e.initiatorAuth,parentTraceContext:e.parentTraceContext,persistentSessions:e.persistentSessions,remote:i,session:e.session}),a={callbackBaseUrl:r,kind:`agent/remote`,sessionId:t.sessionId,url:i.url};return{address:a,callId:n.callId,kind:`called`,name:n.name,session:confirmAgentStarted(s,{address:a,operationId:o.id}),toolName:n.remoteAgentName}}catch(e){return logError(log,`remote agent start failed`,e,{remoteAgentName:n.remoteAgentName,nodeId:n.nodeId,callId:n.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:n,error:e}),session:rejectAgentEffect(s,{disposition:`dead`,operationId:o.id})}}}function isRecursiveAgentAction(e,t){return e.kind===`subagent-call`&&e.subagentName===`agent`&&!t.has(e.nodeId)}export{dispatchRuntimeActionsStep};
|
|
1
|
+
import{createDurableSessionState}from"#execution/durable-session-store.js";import{dispatchToAgentHandle}from"#execution/agent-handle-dispatch.js";import{createAgentContinuationBundle}from"#execution/agent-continuation-bundle.js";import{emitSubagentCalled,prepareRuntimeActionDispatch,startSubagent}from"#execution/dispatch-runtime-actions-shared.js";async function dispatchRuntimeActionsStep(n){"use step";let r=await prepareRuntimeActionDispatch({serializedContext:n.serializedContext,sessionState:n.sessionState,taskControls:!1});if(r===void 0)return{results:[],sessionState:n.sessionState,pendingTasks:[]};let{batch:i,bundle:a,session:o}=r,s=a.resolvedAgent.config?.experimental?.subagentPersistentSessions===!0,c=n.parentWritable.getWriter(),l=o,u=[];try{for(let e of r.plan){if(e.kind===`reject`){u.push(e.result);continue}if(e.kind===`task-control`)throw Error(`Task-control actions require the task dispatch step.`);let t;switch(e.kind){case`resume`:t=await dispatchToAgentHandle({action:e.action,agentId:e.agentId,bundle:createAgentContinuationBundle({action:e.action,bundle:a,dynamicRemoteAgent:e.dynamicRemoteAgent}),currentSession:l,parentToken:n.parentContinuationToken??o.continuationToken,parentTurnId:i.event.turnId});break;case`start`:t=await startSubagent({auth:r.auth,batchEvent:i.event,bundle:a,callbackBaseUrl:n.callbackBaseUrl,capabilities:r.capabilities,channelMetadata:r.channelMetadata,currentSession:l,fanoutSize:r.fanoutSize,initiatorAuth:r.initiatorAuth,parentContinuationToken:n.parentContinuationToken,parentTraceContext:r.parentTraceContext,persistentSessions:s,serializedContext:r.serializedContext,session:o,taskOwned:!1,target:e.target});break}if(l=t.session,t.kind===`error`){u.push(t.result);continue}await emitSubagentCalled({adapter:r.adapter,adapterCtx:r.adapterCtx,batchEvent:i.event,entry:e,outcome:t,sessionId:o.sessionId,writer:c})}}finally{c.releaseLock()}return{results:u,sessionState:l===o?n.sessionState:createDurableSessionState({session:l}),pendingTasks:[]}}export{dispatchRuntimeActionsStep};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { RuntimeActionResult } from "#runtime/actions/types.js";
|
|
3
3
|
/** Dispatches the child-agent action currently blocking a dynamic workflow. */
|
|
4
4
|
export declare function dispatchWorkflowRuntimeActionsStep(input: {
|
|
5
5
|
readonly callbackBaseUrl?: string;
|
|
@@ -8,6 +8,11 @@ export declare function dispatchWorkflowRuntimeActionsStep(input: {
|
|
|
8
8
|
readonly serializedContext: Record<string, unknown>;
|
|
9
9
|
readonly sessionState: DurableSessionState;
|
|
10
10
|
}): Promise<{
|
|
11
|
-
readonly results: readonly
|
|
11
|
+
readonly results: readonly RuntimeActionResult[];
|
|
12
12
|
readonly sessionState: DurableSessionState;
|
|
13
|
+
readonly pendingTasks: readonly {
|
|
14
|
+
readonly taskInboxToken: string;
|
|
15
|
+
readonly taskId: string;
|
|
16
|
+
readonly taskRunId: string;
|
|
17
|
+
}[];
|
|
13
18
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{setPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{getSubagentDelegationName,isSubagentDelegationAction}from"#harness/subagent-depth.js";import{dispatchRuntimeActionsStep}from"#execution/dispatch-runtime-actions-step.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{buildRuntimeActionsFromWorkflowInterrupt}from"#harness/workflow-runtime-action-state.js";import{planWorkflowSubagentDispatch}from"#harness/workflow-subagent-limit.js";const log=createLogger(`execution.dispatch-workflow-runtime-actions`);async function dispatchWorkflowRuntimeActionsStep(e){"use step";let n=await readDurableSession(e.sessionState),r=getPendingWorkflowInterrupt(n.state);if(r===void 0)return{results:[],sessionState:e.sessionState};let i=buildRuntimeActionsFromWorkflowInterrupt(r.interrupt);if(i.length===0)return{results:[],sessionState:e.sessionState};let a=await deserializeContext(e.serializedContext),o=
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{setPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{getSubagentDelegationName,isSubagentDelegationAction}from"#harness/subagent-depth.js";import{dispatchRuntimeActionsStep}from"#execution/dispatch-runtime-actions-step.js";import{dispatchTaskStep}from"#execution/tasks/parent/dispatch-task-step.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{buildRuntimeActionsFromWorkflowInterrupt}from"#harness/workflow-runtime-action-state.js";import{planWorkflowSubagentDispatch}from"#harness/workflow-subagent-limit.js";const log=createLogger(`execution.dispatch-workflow-runtime-actions`);async function dispatchWorkflowRuntimeActionsStep(e){"use step";let n=await readDurableSession(e.sessionState),r=getPendingWorkflowInterrupt(n.state);if(r===void 0)return{results:[],sessionState:e.sessionState,pendingTasks:[]};let i=buildRuntimeActionsFromWorkflowInterrupt(r.interrupt);if(i.length===0)return{results:[],sessionState:e.sessionState,pendingTasks:[]};let a=await deserializeContext(e.serializedContext),o=a.require(BundleKey),s=resolveEffectiveAgentRuntime(o,a),c=planWorkflowSubagentDispatch({actions:i,interrupt:r.interrupt,maxSubagents:n.workflowMaxSubagents}),l=c.blocked.map(e=>(log.warn(`workflow subagent limit reached; blocking delegated call`,{callId:e.callId,maxSubagents:c.maxSubagents,subagentName:isSubagentDelegationAction(e)?getSubagentDelegationName(e):e.kind,usedCalls:c.usedCalls}),createWorkflowSubagentLimitResult({action:e,plan:c})));if(c.allowed.length===0)return{results:l,sessionState:e.sessionState,pendingTasks:[]};let u=hydrateDurableSession({compactionOverrides:{thresholdPercent:s.thresholdPercent},durable:n,turnAgent:s.turnAgent}),d=setPendingRuntimeActionBatch({actions:c.allowed,event:{sequence:0,stepIndex:0,turnId:`workflow-dispatch`},responseMessages:[],session:u}),f=await(o.resolvedAgent.config?.experimental?.tasks===!0?dispatchTaskStep:dispatchRuntimeActionsStep)({callbackBaseUrl:e.callbackBaseUrl,parentContinuationToken:e.parentContinuationToken,parentWritable:e.parentWritable,serializedContext:e.serializedContext,sessionState:createDurableSessionState({session:d})});return l.length===0?f:{results:[...f.results,...l],sessionState:f.sessionState,pendingTasks:f.pendingTasks}}function createWorkflowSubagentLimitResult(e){let t=isSubagentDelegationAction(e.action)?getSubagentDelegationName(e.action):e.action.kind;return{callId:e.action.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`WORKFLOW_SUBAGENT_LIMIT_REACHED`,maxSubagents:e.plan.maxSubagents,message:`Workflow subagent limit reached (${String(e.plan.maxSubagents)}); "${t}" was not called.`},subagentName:t}}export{dispatchWorkflowRuntimeActionsStep};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HarnessSession, StepInput } from "#harness/types.js";
|
|
2
|
+
import type { JsonObject } from "#shared/json.js";
|
|
3
|
+
import type { RunMode } from "#shared/run-mode.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the single output schema in effect for this turn, decoupling schema
|
|
6
|
+
* enforcement from {@link RunMode}: downstream the harness reads
|
|
7
|
+
* `session.outputSchema` unconditionally and never re-derives it from mode.
|
|
8
|
+
*
|
|
9
|
+
* A run-scoped (client-supplied) schema on the turn's {@link StepInput} always
|
|
10
|
+
* wins. With no run-scoped schema, a task run adopts the agent's declared
|
|
11
|
+
* return schema — its function-output contract, which only applies when the
|
|
12
|
+
* agent is invoked as a function (subagent / schedule / job), i.e. task mode.
|
|
13
|
+
* A conversation run with no run-scoped schema enforces nothing. Continuation
|
|
14
|
+
* steps (no new `StepInput`) preserve whatever is already in effect.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveEffectiveOutputSchema(input: {
|
|
17
|
+
readonly agentOutputSchema: JsonObject | undefined;
|
|
18
|
+
readonly input: StepInput | undefined;
|
|
19
|
+
readonly mode: RunMode;
|
|
20
|
+
readonly session: HarnessSession;
|
|
21
|
+
}): HarnessSession;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function resolveEffectiveOutputSchema(e){let{agentOutputSchema:t,input:n,mode:r,session:i}=e;return n?.outputSchema===void 0?r===`task`&&i.outputSchema===void 0&&t!==void 0?{...i,outputSchema:t}:i:{...i,outputSchema:n.outputSchema}}export{resolveEffectiveOutputSchema};
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
* - `$eve.trigger` — channel adapter kind (session/subagent rows)
|
|
24
24
|
* - `$eve.title` — truncated session title from the first user message
|
|
25
25
|
* - `$eve.channel_request_id` — inbound channel request id
|
|
26
|
+
* - `$eve.invocation_token` — channel-local continuation token for an external invocation
|
|
27
|
+
* - `$eve.invocation_owner` — SHA-256 fingerprint of the invocation's initiating principal
|
|
26
28
|
*/
|
|
27
29
|
import type { EveAttributeValue } from "#runtime/attributes/normalize.js";
|
|
28
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{UNSPECIFIED_INPUT_SCHEMA}from"#shared/tool-schema.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{createHarnessDelegationToolDefinition}from"#execution/delegation-tool.js";import{PERSISTENT_SUBAGENT_TOOL_INPUT_SCHEMA,SUBAGENT_TOOL_INPUT_SCHEMA}from"#runtime/subagents/registry.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{createToolLoopHarness}from"#harness/tool-loop.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{AGENT_TOOL_DESCRIPTION,AGENT_TOOL_NAME,isImplicitAgentToolAvailable}from"#runtime/framework-tools/agent.js";import{findRegisteredRuntimeTool}from"#runtime/tools/registry.js";import{preserveFrameworkStateOnCompaction}from"#execution/compaction.js";const log=createLogger(`execution.node-step`);function createExecutionNodeStep(e){let t=createRuntimeModelResolver(e.modelResolutionScope),n=e.node.turnAgent.dynamicModel===void 0?void 0:createRuntimeDynamicModelEventDispatcher(e.modelResolutionScope,e.node.turnAgent.dynamicModel),r=createNodeHarnessTools({node:e.node}),i=getInstrumentationRuntime(),a=createToolLoopHarness({abortSignal:e.abortSignal,capabilities:e.capabilities,clearOnly:e.clearOnly,compactOnly:e.compactOnly,workflow:e.node.agent.workflowTool!==void 0,workflowMaxSubagents:e.workflowMaxSubagents,webSearchProvider:e.node.agent.webSearchProvider,handleEvent:e.handleEvent,instrumentation:i,mode:e.mode,onCompaction:preserveFrameworkStateOnCompaction,persistentSubagentSessions:e.node.agent.config?.experimental?.subagentPersistentSessions===!0,dispatchDynamicModelEvent:n,resolveModel:t,runtimeIdentity:buildRuntimeIdentity(e.node),tools:r});return i===void 0?a:async(e,t)=>{try{return await a(e,t)}finally{await i.forceFlush()}}}function buildRuntimeIdentity(e){let n=resolveInstalledPackageInfo(),r={agentId:e.turnAgent.id,agentName:e.agent.config?.name,eveVersion:n.version},i=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),a=process.env.VERCEL_GIT_COMMIT_REF?.trim(),o=process.env.VERCEL_DEPLOYMENT_CREATED_AT?.trim();return i||a||o?{...r,build:{deployedAt:o||void 0,gitBranch:a||void 0,gitSha:i||void 0}}:r}function createRuntimeModelResolver(e){return t=>resolveRuntimeModelReference(t,e)}function createRuntimeDynamicModelEventDispatcher(e,t){return n=>dispatchDynamicModelEvent({ctx:n.ctx,dynamicModel:t,event:n.event,messages:n.messages,scope:e})}function createNodeHarnessTools(e){let t=new Map;for(let n of e.node.turnAgent.tools){let r=resolveHarnessToolDefinition({node:e.node,tool:n});r!==null&&t.set(n.name,r)}
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{UNSPECIFIED_INPUT_SCHEMA}from"#shared/tool-schema.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{createHarnessDelegationToolDefinition}from"#execution/delegation-tool.js";import{PERSISTENT_SUBAGENT_TOOL_INPUT_SCHEMA,SUBAGENT_TOOL_INPUT_SCHEMA}from"#runtime/subagents/registry.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{createToolLoopHarness}from"#harness/tool-loop.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{AGENT_TOOL_DESCRIPTION,AGENT_TOOL_NAME,isImplicitAgentToolAvailable}from"#runtime/framework-tools/agent.js";import{createTaskToolHarnessDefinitions,isTaskToolAvailable}from"#runtime/framework-tools/tasks.js";import{findRegisteredRuntimeTool}from"#runtime/tools/registry.js";import{preserveFrameworkStateOnCompaction}from"#execution/compaction.js";const log=createLogger(`execution.node-step`);function createExecutionNodeStep(e){let t=createRuntimeModelResolver(e.modelResolutionScope),n=e.node.turnAgent.dynamicModel===void 0?void 0:createRuntimeDynamicModelEventDispatcher(e.modelResolutionScope,e.node.turnAgent.dynamicModel),r=createNodeHarnessTools({node:e.node}),i=getInstrumentationRuntime(),a=createToolLoopHarness({abortSignal:e.abortSignal,capabilities:e.capabilities,clearOnly:e.clearOnly,compactOnly:e.compactOnly,workflow:e.node.agent.workflowTool!==void 0,workflowMaxSubagents:e.workflowMaxSubagents,webSearchProvider:e.node.agent.webSearchProvider,handleEvent:e.handleEvent,instrumentation:i,mode:e.mode,onCompaction:preserveFrameworkStateOnCompaction,persistentSubagentSessions:e.node.agent.config?.experimental?.tasks===!0||e.node.agent.config?.experimental?.subagentPersistentSessions===!0,dispatchDynamicModelEvent:n,resolveModel:t,runtimeIdentity:buildRuntimeIdentity(e.node),tools:r});return i===void 0?a:async(e,t)=>{try{return await a(e,t)}finally{await i.forceFlush()}}}function buildRuntimeIdentity(e){let n=resolveInstalledPackageInfo(),r={agentId:e.turnAgent.id,agentName:e.agent.config?.name,eveVersion:n.version},i=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),a=process.env.VERCEL_GIT_COMMIT_REF?.trim(),o=process.env.VERCEL_DEPLOYMENT_CREATED_AT?.trim();return i||a||o?{...r,build:{deployedAt:o||void 0,gitBranch:a||void 0,gitSha:i||void 0}}:r}function createRuntimeModelResolver(e){return t=>resolveRuntimeModelReference(t,e)}function createRuntimeDynamicModelEventDispatcher(e,t){return n=>dispatchDynamicModelEvent({ctx:n.ctx,dynamicModel:t,event:n.event,messages:n.messages,scope:e})}function createNodeHarnessTools(e){let t=new Map;for(let n of e.node.turnAgent.tools){let r=resolveHarnessToolDefinition({node:e.node,tool:n});r!==null&&t.set(n.name,r)}isImplicitAgentToolAvailable({disabledFrameworkTools:e.node.agent.disabledFrameworkTools,hasAuthoredAgentTool:t.has(AGENT_TOOL_NAME),nodeId:e.node.nodeId})&&t.set(AGENT_TOOL_NAME,{description:AGENT_TOOL_DESCRIPTION,inputSchema:e.node.agent.config?.experimental?.tasks===!0||e.node.agent.config?.experimental?.subagentPersistentSessions===!0?PERSISTENT_SUBAGENT_TOOL_INPUT_SCHEMA:SUBAGENT_TOOL_INPUT_SCHEMA,name:AGENT_TOOL_NAME,runtimeAction:{kind:`subagent-call`,nodeId:e.node.nodeId,subagentName:AGENT_TOOL_NAME}});let n=e.node.agent.config?.experimental?.tasks===!0;for(let r of createTaskToolHarnessDefinitions())isTaskToolAvailable({disabledFrameworkTools:e.node.agent.disabledFrameworkTools,hasAuthoredTool:t.has(r.name),tasksEnabled:n,toolName:r.name})&&t.set(r.name,r);return t}function resolveHarnessToolDefinition(e){if(e.tool.kind===`subagent`||e.tool.kind===`remote`)return createHarnessDelegationToolDefinition(e.tool);let t=findRegisteredRuntimeTool(e.node.toolRegistry,e.tool.name);if(t===null)return log.warn(`declared tool is not registered — omitting from toolset`,{toolName:e.tool.name,nodeId:e.node.nodeId}),null;let r=t.definition,i=r.sourceId.startsWith(`eve:`),o=r.execute;return{approvalKey:r.approvalKey,description:r.description,execute:resolveAuthoredExecute({isFrameworkTool:i,rawExecute:o,scope:r.name}),frameworkAction:i&&r.name===LOAD_SKILL_TOOL_NAME?`load-skill`:void 0,inputSchema:r.inputSchema??UNSPECIFIED_INPUT_SCHEMA,name:r.name,approval:r.approval,outputSchema:r.outputSchema,toModelOutput:r.toModelOutput}}function resolveAuthoredExecute(e){let{isFrameworkTool:t,rawExecute:n,scope:i}=e;return n===void 0?void 0:t?n:createToolExecuteWithAuth({execute:n,scope:i})}export{buildRuntimeIdentity,createExecutionNodeStep,createNodeHarnessTools};
|
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
import type { DeliverHookPayload, DeliverPayload } from "#channel/types.js";
|
|
2
|
-
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
3
2
|
import type { SessionCommandInbox } from "#execution/session-command-inbox.js";
|
|
3
|
+
import type { SessionStateCursor } from "#execution/session-state-cursor.js";
|
|
4
4
|
/** One authorization-callback read surfaced during a parked wait. */
|
|
5
5
|
export interface AuthorizationCallbackInstruction {
|
|
6
6
|
readonly kind: "authorization";
|
|
7
7
|
/** True when the authorization hook closed; no further callbacks can arrive. */
|
|
8
8
|
readonly closed: boolean;
|
|
9
9
|
readonly payloads: readonly DeliverPayload[];
|
|
10
|
-
readonly sessionState: DurableSessionState;
|
|
11
10
|
}
|
|
12
11
|
/** What the parked driver should do with the next session activity. */
|
|
13
12
|
export type NextTurnInstruction = {
|
|
14
13
|
readonly kind: "clear";
|
|
15
|
-
readonly sessionState: DurableSessionState;
|
|
16
14
|
} | {
|
|
17
15
|
readonly kind: "compact";
|
|
18
|
-
readonly sessionState: DurableSessionState;
|
|
19
16
|
} | {
|
|
20
17
|
readonly kind: "expired";
|
|
21
|
-
readonly sessionState: DurableSessionState;
|
|
22
18
|
} | {
|
|
23
19
|
readonly kind: "reset";
|
|
24
|
-
readonly sessionState: DurableSessionState;
|
|
25
20
|
} | {
|
|
26
21
|
readonly kind: "closed";
|
|
27
|
-
readonly sessionState: DurableSessionState;
|
|
28
22
|
} | {
|
|
29
23
|
readonly kind: "cancel-turn";
|
|
30
|
-
readonly sessionState: DurableSessionState;
|
|
31
24
|
} | AuthorizationCallbackInstruction | {
|
|
32
25
|
readonly kind: "turn";
|
|
33
|
-
readonly
|
|
34
|
-
readonly remainder: DeliverHookPayload;
|
|
35
|
-
readonly sessionState: DurableSessionState;
|
|
26
|
+
readonly delivery: DeliverHookPayload;
|
|
36
27
|
};
|
|
37
28
|
/**
|
|
38
29
|
* Awaits the next delivery that requires driver action while the session
|
|
@@ -46,13 +37,18 @@ export type NextTurnInstruction = {
|
|
|
46
37
|
* without producing a parent turn (no-op cancels, fully-routed descendant
|
|
47
38
|
* deliveries) — so an open challenge's callback surfaces as an
|
|
48
39
|
* `"authorization"` instruction no matter when it arrives.
|
|
40
|
+
*
|
|
41
|
+
* Routing steps mutate durable state; each transition is adopted into the
|
|
42
|
+
* caller-owned `stateCursor`, so returns carry only the instruction kind.
|
|
49
43
|
*/
|
|
50
44
|
export declare function nextTurnDelivery(input: {
|
|
51
45
|
readonly awaitAuthorizationCallbacks?: boolean;
|
|
52
46
|
readonly bufferedDeliveries: DeliverHookPayload[];
|
|
53
47
|
readonly bufferedSessionControls: Array<"clear" | "compact" | "expired" | "reset">;
|
|
48
|
+
readonly cancelledTaskIds?: Set<string>;
|
|
54
49
|
readonly commandInbox: SessionCommandInbox;
|
|
55
50
|
readonly deferDeliveries?: boolean;
|
|
56
51
|
readonly driverWritable: WritableStream<Uint8Array>;
|
|
57
|
-
readonly
|
|
52
|
+
readonly seenTaskDeliveries?: Set<string>;
|
|
53
|
+
readonly stateCursor: SessionStateCursor;
|
|
58
54
|
}): Promise<NextTurnInstruction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{coalesceDeliveries}from"#harness/messages.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{sendCommandToDelivery}from"#execution/session-command-wire.js";async function nextTurnDelivery(e){if(e.awaitAuthorizationCallbacks!==!0)return await awaitNextTurnDelivery(e);e.commandInbox.setAuthorizationWindow(!0);try{return await awaitNextTurnDelivery(e)}finally{e.commandInbox.setAuthorizationWindow(!1)}}async function awaitNextTurnDelivery(e){let n=e.
|
|
1
|
+
import{coalesceDeliveries}from"#harness/messages.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{sendCommandToDelivery}from"#execution/session-command-wire.js";async function nextTurnDelivery(e){if(e.awaitAuthorizationCallbacks!==!0)return await awaitNextTurnDelivery(e);e.commandInbox.setAuthorizationWindow(!0);try{return await awaitNextTurnDelivery(e)}finally{e.commandInbox.setAuthorizationWindow(!1)}}async function awaitNextTurnDelivery(e){let n=e.cancelledTaskIds??new Set,r=e.seenTaskDeliveries??new Set;for(;;){let i=await waitForNextSessionAction({bufferedDeliveries:e.bufferedDeliveries,bufferedSessionControls:e.bufferedSessionControls,cancelledTaskIds:n,commandInbox:e.commandInbox,deferDeliveries:e.deferDeliveries,seenTaskDeliveries:r});if(i.kind===`authorization`)return i;if(i.kind!==`delivery`)return{kind:i.kind};let a=i.delivery;if(a===null)return{kind:`closed`};let o=await routeDeliverToChildren({delivery:a,parentWritable:e.driverWritable,serializedContext:e.stateCursor.serializedContext,sessionState:e.stateCursor.sessionState});if(e.stateCursor.adoptState(o),o.kind===`cancel-turn`)return{kind:`cancel-turn`};if(o.remainder!==void 0)return{delivery:o.remainder,kind:`turn`}}}async function waitForNextSessionAction(e){let t=e.bufferedSessionControls.shift();if(t!==void 0)return{kind:t};for(;e.bufferedDeliveries[0]!==void 0&&isCancelledTaskDelivery(e.bufferedDeliveries[0],e.cancelledTaskIds);)e.bufferedDeliveries.shift();if(e.deferDeliveries!==!0&&!e.commandInbox.hasReadyAuthorization()&&e.bufferedDeliveries.length>0)return{delivery:takeBufferedTurnDelivery(e.bufferedDeliveries),kind:`delivery`};for(;;){let{result:t,source:r}=await e.commandInbox.nextWithSource();if(e.commandInbox.consumeNext(),r===`authorization`)return t.done?{closed:!0,kind:`authorization`,payloads:[]}:{closed:!1,kind:`authorization`,payloads:t.value.kind===`deliver`?t.value.payloads:[]};if(t.done)return{delivery:null,kind:`delivery`};if(t.value.kind===`session-timeout`)return{kind:`expired`};if(t.value.kind===`clear`||t.value.kind===`compact`||t.value.kind===`reset`)return{kind:t.value.kind};if(t.value.kind===`cancel`){if(t.value.taskId!==void 0){e.cancelledTaskIds.add(t.value.taskId);let n=e.bufferedDeliveries.filter(t=>!isCancelledTaskDelivery(t,e.cancelledTaskIds));e.bufferedDeliveries.splice(0,e.bufferedDeliveries.length,...n)}continue}if(t.value.kind===`runtime-action-result`)continue;let i=t.value.taskDeliveryId??t.value.caller?.taskId;if(i!==void 0&&isCancelledTaskDeliveryId(i,e.cancelledTaskIds))continue;if(i!==void 0){if(e.seenTaskDeliveries.has(i))continue;e.seenTaskDeliveries.add(i)}if(t.value.kind===`deliver`){if(e.deferDeliveries===!0){e.bufferedDeliveries.push(t.value);continue}return{delivery:t.value,kind:`delivery`}}let a=sendCommandToDelivery(t.value);if(e.deferDeliveries===!0){e.bufferedDeliveries.push(a);continue}return{delivery:a,kind:`delivery`}}}function isCancelledTaskDelivery(e,t){let n=e.taskDeliveryId??e.caller?.taskId;return n!==void 0&&isCancelledTaskDeliveryId(n,t)}function isCancelledTaskDeliveryId(e,t){return[...t].some(t=>e===t||e.startsWith(`${t}:`))}function takeBufferedTurnDelivery(t){let n=t.shift();if(n===void 0)throw Error(`Cannot take a turn delivery from an empty buffer.`);let r=[n],i=n.caller;for(;t.length>0;){let e=t[0];if(e===void 0||n.taskDeliveryId!==void 0||e.taskDeliveryId!==void 0||i!==void 0&&e.caller!==void 0)break;let a=t.shift();if(a===void 0)throw Error(`Buffered turn delivery disappeared while partitioning.`);r.push(a),i??=a.caller}return coalesceDeliveries(r)}export{nextTurnDelivery};
|
|
@@ -2,33 +2,36 @@ import type { DeliverHookPayload, DeliverPayload, SessionAuthContext } from "#ch
|
|
|
2
2
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
3
3
|
export type RoutedDeliverResult = {
|
|
4
4
|
readonly kind: "cancel-turn";
|
|
5
|
+
readonly serializedContext: Record<string, unknown>;
|
|
5
6
|
readonly sessionState: DurableSessionState;
|
|
6
7
|
} | {
|
|
7
8
|
readonly kind: "continue";
|
|
8
9
|
readonly remainder: DeliverHookPayload | undefined;
|
|
10
|
+
readonly serializedContext: Record<string, unknown>;
|
|
9
11
|
readonly sessionState: DurableSessionState;
|
|
10
12
|
};
|
|
11
13
|
type LegacyRoutedDeliverResult = {
|
|
12
14
|
readonly kind: "cancel-turn";
|
|
15
|
+
readonly serializedContext: Record<string, unknown>;
|
|
13
16
|
readonly sessionState: DurableSessionState;
|
|
14
17
|
} | {
|
|
15
18
|
readonly kind: "continue";
|
|
16
19
|
readonly remainder: DeliverPayload | undefined;
|
|
20
|
+
readonly serializedContext: Record<string, unknown>;
|
|
17
21
|
readonly sessionState: DurableSessionState;
|
|
18
22
|
};
|
|
19
|
-
/**
|
|
20
|
-
* Splits an inbound deliver payload into parent-local and proxied-child buckets.
|
|
21
|
-
* Successfully forwarded request IDs are retired from the returned snapshot.
|
|
22
|
-
*/
|
|
23
|
+
/** Splits an envelope and validates task routes before forwarding descendant input. */
|
|
23
24
|
export declare function routeProxiedDeliverStep(input: {
|
|
24
25
|
readonly delivery: DeliverHookPayload;
|
|
25
26
|
readonly parentWritable: WritableStream<Uint8Array>;
|
|
27
|
+
readonly serializedContext?: Record<string, unknown>;
|
|
26
28
|
readonly sessionState: DurableSessionState;
|
|
27
29
|
}): Promise<RoutedDeliverResult>;
|
|
28
30
|
export declare function routeProxiedDeliverStep(input: {
|
|
29
31
|
readonly auth?: SessionAuthContext | null;
|
|
30
32
|
readonly parentWritable: WritableStream<Uint8Array>;
|
|
31
33
|
readonly payload: DeliverPayload;
|
|
34
|
+
readonly serializedContext?: Record<string, unknown>;
|
|
32
35
|
readonly sessionState: DurableSessionState;
|
|
33
36
|
}): Promise<LegacyRoutedDeliverResult>;
|
|
34
37
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{resumeHook}from"#internal/workflow/runtime.js";import{createTaskInputRequestId,retireProxyInputRequests}from"#harness/proxy-input-requests.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{routeDeliverPayload}from"#execution/subagent-hitl-proxy.js";import{sendTaskInboundPayload}from"#execution/tasks/parent/run-parent.js";import{findSessionTaskEntry}from"#tasks/session-index.js";async function routeProxiedDeliverStep(r){"use step";let l=await readDurableSession(r.sessionState),u=!(`delivery`in r),d=`delivery`in r?r.delivery:{auth:r.auth,kind:`deliver`,payloads:[r.payload]},f=new Map,p=new Map,m;for(let[e,t]of d.payloads.entries()){let n=routeDeliverPayload({allowRoute:(e,t)=>t.taskId===void 0||findSessionTaskEntry(l.state,t.taskId)!==void 0,payload:t,state:l.state});m??=n.parentAction,n.forSelf!==void 0&&f.set(e,n.forSelf);for(let[t,r]of n.forChildren.entries()){let i=r.taskId===void 0?r.childContinuationToken:[r.childContinuationToken,r.childResponseUrl??``,r.taskId].join(`\0`),a=p.get(i)??{childContinuationToken:r.childContinuationToken,childResponseUrl:r.childResponseUrl,metadata:[],payloads:[],retireRequestIds:[],sourcePayloadIndexes:[],taskId:r.taskId},o=a.payloads.length;if(a.payloads.push(r.payload),a.retireRequestIds.push(...r.retireRequestIds),a.sourcePayloadIndexes.push(e),n.forSelf===void 0&&t===0)for(let t of d.deliveryMetadata??[])t.payloadIndex===e&&a.metadata.push({...t,payloadIndex:o});p.set(i,a)}}let h=!1;for(let e of p.values()){let t=e.taskId;if(t!==void 0){let n=findSessionTaskEntry(l.state,t);if(n===void 0){mergeStrandedResponses(f,e,t);continue}if(await sendTaskInboundPayload({taskInboxToken:n.taskInboxToken,payload:{auth:d.auth,childContinuationToken:e.childContinuationToken,childResponseUrl:e.childResponseUrl,inputResponses:coalesceDeliverPayloads(e.payloads).inputResponses??[],kind:`input-response`,taskId:t}})===`unreachable`){mergeStrandedResponses(f,e,t);continue}l=retireProxyInputRequests(l,e.retireRequestIds),h=!0;continue}let r={...d,deliveryMetadata:e.metadata.length===0?void 0:e.metadata,payloads:e.payloads};await resumeHook(e.childContinuationToken,{...r,payload:coalesceDeliverPayloads(e.payloads)}),l=retireProxyInputRequests(l,e.retireRequestIds),h=!0}let g={serializedContext:r.serializedContext??{},sessionState:h?replaceDurableSessionSnapshot({session:l,state:r.sessionState}):r.sessionState};if(m!==void 0)return{...g,...m};let _=[...f].sort(([e],[t])=>e-t),v=_.flatMap(([e],t)=>(d.deliveryMetadata??[]).filter(t=>t.payloadIndex===e).map(e=>({...e,payloadIndex:t}))),y=_.length===0?void 0:u?coalesceDeliverPayloads(_.map(([,e])=>e)):{...d,deliveryMetadata:v.length===0?void 0:v,payloads:_.map(([,e])=>e)};return{...g,kind:`continue`,remainder:y}}function mergeStrandedResponses(e,t,n){for(let[i,a]of t.payloads.entries()){let o=t.sourcePayloadIndexes[i];if(o===void 0)continue;let s=(a.inputResponses??[]).map(e=>({...e,requestId:createTaskInputRequestId(n,e.requestId)}));if(s.length===0)continue;let c=e.get(o);e.set(o,{...c,inputResponses:[...c?.inputResponses??[],...s]})}}export{routeProxiedDeliverStep};
|
|
@@ -3,6 +3,7 @@ import type { HarnessSession } from "#harness/types.js";
|
|
|
3
3
|
import type { RuntimeRemoteAgentCallActionRequest } from "#runtime/actions/types.js";
|
|
4
4
|
import type { RuntimeSubagentRegistry } from "#runtime/subagents/registry.js";
|
|
5
5
|
import type { DynamicRemoteAgentConfig } from "#runtime/subagents/dynamic-remote-agent-config.js";
|
|
6
|
+
import type { CompiledRuntimeAgentBundle } from "#runtime/sessions/compiled-agent-cache.js";
|
|
6
7
|
import type { ResolvedRuntimeRemoteAgentNode } from "#runtime/types.js";
|
|
7
8
|
import type { JsonObject } from "#shared/json.js";
|
|
8
9
|
type RemoteAgentSessionCoordinates = {
|
|
@@ -16,6 +17,12 @@ export declare function startRemoteAgentSession(input: {
|
|
|
16
17
|
readonly callbackToken?: string;
|
|
17
18
|
/** The root initiator's principal, forwarded alongside {@link auth}. */
|
|
18
19
|
readonly initiatorAuth?: SessionAuthContext | null;
|
|
20
|
+
/**
|
|
21
|
+
* Replay-stable identity of this create attempt. A retried dispatch step
|
|
22
|
+
* re-sends the same value, letting the receiver return the child it already
|
|
23
|
+
* created instead of starting a second one.
|
|
24
|
+
*/
|
|
25
|
+
readonly operationId?: string;
|
|
19
26
|
/**
|
|
20
27
|
* Whether the dispatching agent opted into
|
|
21
28
|
* `experimental.subagentPersistentSessions`. Persistent remote children run
|
|
@@ -31,6 +38,7 @@ export declare function continueRemoteAgentSession(input: {
|
|
|
31
38
|
readonly callback: {
|
|
32
39
|
readonly callId: string;
|
|
33
40
|
readonly subagentName: string;
|
|
41
|
+
readonly taskId?: string;
|
|
34
42
|
readonly token: string;
|
|
35
43
|
readonly url: string;
|
|
36
44
|
};
|
|
@@ -45,8 +53,10 @@ export declare function continueRemoteAgentSession(input: {
|
|
|
45
53
|
* with real instances instead of re-encoding the classification.
|
|
46
54
|
*/
|
|
47
55
|
export declare class RemoteAgentContinueRequestError extends Error {
|
|
56
|
+
readonly deliveryAmbiguous: boolean;
|
|
48
57
|
readonly retryable: boolean;
|
|
49
58
|
constructor(message: string, options: {
|
|
59
|
+
readonly deliveryAmbiguous: boolean;
|
|
50
60
|
readonly retryable: boolean;
|
|
51
61
|
});
|
|
52
62
|
}
|
|
@@ -60,9 +70,13 @@ export declare class RemoteAgentContinueRequestError extends Error {
|
|
|
60
70
|
* whose response was lost).
|
|
61
71
|
*/
|
|
62
72
|
export declare function isRetryableRemoteAgentContinueError(error: unknown): boolean;
|
|
73
|
+
/** Whether the callee may have accepted the continuation before delivery failed. */
|
|
74
|
+
export declare function isAmbiguousRemoteAgentContinueError(error: unknown): boolean;
|
|
63
75
|
export declare function cancelRemoteAgentTurn(input: {
|
|
64
76
|
readonly remote: ResolvedRuntimeRemoteAgentNode;
|
|
65
77
|
readonly sessionId: string;
|
|
78
|
+
readonly taskId?: string;
|
|
79
|
+
readonly turnId?: string;
|
|
66
80
|
}): Promise<CancelTurnResult>;
|
|
67
81
|
export declare function isRetryableRemoteAgentCancelError(error: unknown): boolean;
|
|
68
82
|
export declare function resolveRemoteAgentForAction(input: {
|
|
@@ -71,4 +85,22 @@ export declare function resolveRemoteAgentForAction(input: {
|
|
|
71
85
|
readonly registry: RuntimeSubagentRegistry["subagentsByNodeId"];
|
|
72
86
|
readonly remoteAgentName: string;
|
|
73
87
|
}): ResolvedRuntimeRemoteAgentNode;
|
|
88
|
+
/**
|
|
89
|
+
* Resolves authored outbound headers for a server-authored remote child event.
|
|
90
|
+
*
|
|
91
|
+
* `resolverId` is the key persisted on the `subagent.called` event (see
|
|
92
|
+
* `SubagentCalledStreamEvent`): it identifies the authored credential
|
|
93
|
+
* functions, never their resolved values. Lookup order mirrors how dispatch
|
|
94
|
+
* chose the key — first as a subagent node id (static remote definition),
|
|
95
|
+
* then as a `credentialsStepId` in the step registry (dynamic remote
|
|
96
|
+
* definition). The matched static definition must still agree with the
|
|
97
|
+
* event's `name`/`url`, so a stale or mismatched key fails closed rather
|
|
98
|
+
* than minting headers for the wrong upstream.
|
|
99
|
+
*/
|
|
100
|
+
export declare function resolveRemoteAgentStreamHeaders(input: {
|
|
101
|
+
readonly bundle: CompiledRuntimeAgentBundle;
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly resolverId?: string;
|
|
104
|
+
readonly url: string;
|
|
105
|
+
}): Promise<Record<string, string>>;
|
|
74
106
|
export {};
|