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
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{expectFunction,expectObjectRecord}from"#internal/authored-module.js";import{createEveCallbackRoutePath,createEveSessionCancelRoutePath,createEveSessionRoutePath}from"#protocol/routes.js";import{CancelTurnResponseSchema}from"#protocol/cancel-turn.js";import{formatSubagentInput,normalizeRequestedOutputSchema}from"#execution/subagent-invocation.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{AgentHandleError}from"#protocol/agent-handle-error.js";import{formatTraceparent}from"#protocol/traceparent.js";const CreateSessionResponseSchema=z.object({ok:z.literal(!0),sessionId:z.string().min(1),status:z.literal(`accepted`)});var RemoteAgentCancelRequestError=class extends Error{retryable;constructor(e,t){super(e),this.name=`RemoteAgentCancelRequestError`,this.retryable=t.retryable}};async function startRemoteAgentSession(e){let t=e.callbackToken??e.session.continuationToken;if(!t)throw Error(`Cannot dispatch remote agent without a parent continuation token.`);if(!e.callbackBaseUrl)throw Error(`Cannot dispatch remote agent without a callback base URL.`);let n=buildForwardedPrincipalField(e),i={capabilities:{},callback:{callId:e.action.callId,subagentName:e.action.remoteAgentName,token:t,url:createWorkflowCallbackUrl(e.callbackBaseUrl,createEveCallbackRoutePath(t))},message:formatRemoteAgentCallInputMessage({action:e.action,persistentSession:e.persistentSessions,remote:e.remote}),mode:e.persistentSessions===!0?`conversation`:`task`,outputSchema:normalizeRequestedOutputSchema(e.action.input.outputSchema)??e.remote.outputSchema};n!==void 0&&(i.forwardedPrincipal=n);let a=await resolveRemoteAgentRequestHeaders(e.remote),o=formatTraceparent(e.parentTraceContext);if(o!==void 0){for(let e of Object.keys(a))e.toLowerCase()===`traceparent`&&delete a[e];a.traceparent=o}let s=await fetch(createRemoteAgentSessionUrl(e.remote),{body:JSON.stringify(i),headers:{"content-type":`application/json`,...a},method:`POST`});if(!s.ok)throw Error(`Remote agent "${e.action.remoteAgentName}" create-session request failed with HTTP ${s.status}.`);let c;try{c=await s.json()}catch{throw Error(`Remote agent "${e.action.remoteAgentName}" create-session response was not valid JSON.`)}let l=CreateSessionResponseSchema.safeParse(c);if(!l.success)throw Error(`Remote agent "${e.action.remoteAgentName}" create-session response was invalid.`);return{sessionId:l.data.sessionId}}async function continueRemoteAgentSession(e){let t=await fetch(createRemoteAgentContinueUrl(e.remote,e.sessionId),{body:JSON.stringify({callback:e.callback,message:e.message,outputSchema:e.outputSchema}),headers:{"content-type":`application/json`,...await resolveRemoteAgentRequestHeaders(e.remote)},method:`POST`});if(!t.ok){let n=await readRemoteAgentErrorCode(t),r=t.status===404||n===AgentHandleError.SessionNotResumable.code;throw new RemoteAgentContinueRequestError(`Remote agent "${e.remote.name}" continue-session request failed${r?` permanently`:``} with HTTP ${t.status}.`,{retryable:!r})}}var RemoteAgentContinueRequestError=class extends Error{retryable;constructor(e,t){super(e),this.name=`RemoteAgentContinueRequestError`,this.retryable=t.retryable}};function isRetryableRemoteAgentContinueError(e){return!(e instanceof RemoteAgentContinueRequestError)||e.retryable}async function readRemoteAgentErrorCode(e){let t;try{t=await e.json()}catch{return}if(typeof t!=`object`||!t)return;let n=Reflect.get(t,`code`);return typeof n==`string`?n:void 0}function buildForwardedPrincipalField(e){if(e.remote.forwardPrincipal!==!0||e.auth===null||e.auth===void 0)return;let t={current:e.auth};return e.initiatorAuth!==null&&e.initiatorAuth!==void 0&&(t.initiator=e.initiatorAuth),t}async function cancelRemoteAgentTurn(e){let t=await resolveRemoteAgentRequestHeaders(e.remote),n=await fetch(createRemoteAgentCancelTurnUrl(e.remote,e.sessionId),{headers:t,method:`POST`});if(!n.ok)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn request failed with HTTP ${n.status}.`,{retryable:isRetryableRemoteCancelStatus(n.status)});let r;try{r=await n.json()}catch{throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was not valid JSON.`,{retryable:!1})}let i=CancelTurnResponseSchema.safeParse(r);if(!i.success||i.data.status===`accepted`&&i.data.sessionId!==e.sessionId)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was invalid.`,{retryable:!1});return i.data.status===`accepted`?{sessionId:i.data.sessionId,status:`accepted`}:{status:`no_active_turn`}}function isRetryableRemoteAgentCancelError(e){return!(e instanceof RemoteAgentCancelRequestError)||e.retryable}function resolveRemoteAgentForAction(e){let t=e.registry.get(e.nodeId)?.definition;if(e.dynamicRemoteAgent!==void 0){if(t===void 0)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);let n=resolveDynamicRemoteAgentCredentials(e.dynamicRemoteAgent),r=e.dynamicRemoteAgent,i={description:r.description,kind:`remote`,logicalPath:t.logicalPath,name:e.remoteAgentName,nodeId:e.nodeId,outputSchema:r.outputSchema,path:r.path,sourceId:t.sourceId,sourceKind:`module`,url:r.url};return r.forwardPrincipal!==void 0&&(i.forwardPrincipal=r.forwardPrincipal),n.auth!==void 0&&(i.auth=n.auth),n.headers!==void 0&&(i.headers=n.headers),i}if(t?.kind!==`remote`)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);return t}function resolveDynamicRemoteAgentCredentials(e){if(e.credentialsStepId===void 0)return{};let r=getStepRegistry().get(e.credentialsStepId);if(r===void 0)throw Error(`Dynamic remote subagent credentials function "${e.credentialsStepId}" is not registered.`);let i=expectObjectRecord(r(),`Dynamic remote subagent credentials are invalid.`),a={};return i.auth!==void 0&&(a.auth=expectFunction(i.auth,`Dynamic remote subagent auth is invalid.`)),i.headers!==void 0&&(a.headers=resolveDynamicRemoteAgentHeaders(i.headers)),a}function resolveDynamicRemoteAgentHeaders(e){if(typeof e==`function`)return e;let t=expectObjectRecord(e,`Dynamic remote subagent headers are invalid.`);for(let e of Object.values(t))if(typeof e!=`string`)throw Error(`Dynamic remote subagent headers are invalid.`);return t}function getStepRegistry(){let e=Symbol.for(`@workflow/core//registeredSteps`),t=globalThis,n=t[e];return n===void 0&&(n=new Map,t[e]=n),n}function createRemoteAgentSessionUrl(e){return createRemoteAgentRouteUrl(e.url,e.path)}function createRemoteAgentCancelTurnUrl(e,t){return createRemoteAgentRouteUrl(e.url,createEveSessionCancelRoutePath(t))}function createRemoteAgentContinueUrl(e,t){return createRemoteAgentRouteUrl(e.url,createEveSessionRoutePath(t))}function
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{expectFunction,expectObjectRecord}from"#internal/authored-module.js";import{createEveCallbackRoutePath,createEveSessionCancelRoutePath,createEveSessionRoutePath}from"#protocol/routes.js";import{CancelTurnResponseSchema}from"#protocol/cancel-turn.js";import{formatSubagentInput,normalizeRequestedOutputSchema}from"#execution/subagent-invocation.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{readTaskIdFromInboxToken}from"#tasks/task-id.js";import{AgentHandleError}from"#protocol/agent-handle-error.js";import{createRemoteAgentRouteUrl}from"#execution/remote-agent-route-url.js";import{formatTraceparent}from"#protocol/traceparent.js";const CreateSessionResponseSchema=z.object({ok:z.literal(!0),sessionId:z.string().min(1),status:z.literal(`accepted`)});var RemoteAgentCancelRequestError=class extends Error{retryable;constructor(e,t){super(e),this.name=`RemoteAgentCancelRequestError`,this.retryable=t.retryable}};async function startRemoteAgentSession(e){let t=e.callbackToken??e.session.continuationToken;if(!t)throw Error(`Cannot dispatch remote agent without a parent continuation token.`);if(!e.callbackBaseUrl)throw Error(`Cannot dispatch remote agent without a callback base URL.`);let n=buildForwardedPrincipalField(e),i={capabilities:{},callback:{callId:e.action.callId,subagentName:e.action.remoteAgentName,taskId:readTaskIdFromInboxToken(t),token:t,url:createWorkflowCallbackUrl(e.callbackBaseUrl,createEveCallbackRoutePath(t))},message:formatRemoteAgentCallInputMessage({action:e.action,persistentSession:e.persistentSessions,remote:e.remote}),mode:e.persistentSessions===!0?`conversation`:`task`,outputSchema:normalizeRequestedOutputSchema(e.action.input.outputSchema)??e.remote.outputSchema};n!==void 0&&(i.forwardedPrincipal=n),e.operationId!==void 0&&(i.operationId=e.operationId);let a=await resolveRemoteAgentRequestHeaders(e.remote),o=formatTraceparent(e.parentTraceContext);if(o!==void 0){for(let e of Object.keys(a))e.toLowerCase()===`traceparent`&&delete a[e];a.traceparent=o}let s=await fetch(createRemoteAgentSessionUrl(e.remote),{body:JSON.stringify(i),headers:{"content-type":`application/json`,...a},method:`POST`});if(!s.ok)throw Error(`Remote agent "${e.action.remoteAgentName}" create-session request failed with HTTP ${s.status}.`);let c;try{c=await s.json()}catch{throw Error(`Remote agent "${e.action.remoteAgentName}" create-session response was not valid JSON.`)}let l=CreateSessionResponseSchema.safeParse(c);if(!l.success)throw Error(`Remote agent "${e.action.remoteAgentName}" create-session response was invalid.`);return{sessionId:l.data.sessionId}}async function continueRemoteAgentSession(e){let t=await fetch(createRemoteAgentContinueUrl(e.remote,e.sessionId),{body:JSON.stringify({callback:e.callback,message:e.message,outputSchema:e.outputSchema}),headers:{"content-type":`application/json`,...await resolveRemoteAgentRequestHeaders(e.remote)},method:`POST`});if(!t.ok){let n=await readRemoteAgentErrorCode(t),r=t.status===404||n===AgentHandleError.SessionNotResumable.code;throw new RemoteAgentContinueRequestError(`Remote agent "${e.remote.name}" continue-session request failed${r?` permanently`:``} with HTTP ${t.status}.`,{deliveryAmbiguous:isAmbiguousRemoteContinueStatus(t.status),retryable:!r})}}var RemoteAgentContinueRequestError=class extends Error{deliveryAmbiguous;retryable;constructor(e,t){super(e),this.name=`RemoteAgentContinueRequestError`,this.deliveryAmbiguous=t.deliveryAmbiguous,this.retryable=t.retryable}};function isRetryableRemoteAgentContinueError(e){return!(e instanceof RemoteAgentContinueRequestError)||e.retryable}function isAmbiguousRemoteAgentContinueError(e){return!(e instanceof RemoteAgentContinueRequestError)||e.deliveryAmbiguous}function isAmbiguousRemoteContinueStatus(e){return e===408||e===425||e>=500}async function readRemoteAgentErrorCode(e){let t;try{t=await e.json()}catch{return}if(typeof t!=`object`||!t)return;let n=Reflect.get(t,`code`);return typeof n==`string`?n:void 0}function buildForwardedPrincipalField(e){if(e.remote.forwardPrincipal!==!0||e.auth===null||e.auth===void 0)return;let t={current:e.auth};return e.initiatorAuth!==null&&e.initiatorAuth!==void 0&&(t.initiator=e.initiatorAuth),t}async function cancelRemoteAgentTurn(e){let t=await resolveRemoteAgentRequestHeaders(e.remote),n=await fetch(createRemoteAgentCancelTurnUrl(e.remote,e.sessionId),{body:e.turnId===void 0&&e.taskId===void 0?void 0:JSON.stringify({taskId:e.taskId,turnId:e.turnId}),headers:t,method:`POST`});if(!n.ok)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn request failed with HTTP ${n.status}.`,{retryable:isRetryableRemoteCancelStatus(n.status)});let r;try{r=await n.json()}catch{throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was not valid JSON.`,{retryable:!1})}let i=CancelTurnResponseSchema.safeParse(r);if(!i.success||i.data.status===`accepted`&&i.data.sessionId!==e.sessionId)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was invalid.`,{retryable:!1});return i.data.status===`accepted`?{sessionId:i.data.sessionId,status:`accepted`}:{status:`no_active_turn`}}function isRetryableRemoteAgentCancelError(e){return!(e instanceof RemoteAgentCancelRequestError)||e.retryable}function resolveRemoteAgentForAction(e){let t=e.registry.get(e.nodeId)?.definition;if(e.dynamicRemoteAgent!==void 0){if(t===void 0)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);let n=resolveDynamicRemoteAgentCredentials(e.dynamicRemoteAgent),r=e.dynamicRemoteAgent,i={description:r.description,kind:`remote`,logicalPath:t.logicalPath,name:e.remoteAgentName,nodeId:e.nodeId,outputSchema:r.outputSchema,path:r.path,sourceId:t.sourceId,sourceKind:`module`,url:r.url};return r.forwardPrincipal!==void 0&&(i.forwardPrincipal=r.forwardPrincipal),n.auth!==void 0&&(i.auth=n.auth),n.headers!==void 0&&(i.headers=n.headers),i}if(t?.kind!==`remote`)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);return t}async function resolveRemoteAgentStreamHeaders(e){if(e.resolverId===void 0)return{};let t=new Set([e.bundle.graph.root,...e.bundle.graph.nodesByNodeId.values()]);for(let n of t){let t=n.subagentRegistry.subagentsByNodeId.get(e.resolverId)?.definition;if(t!==void 0){if(t.kind!==`remote`||t.name!==e.name||t.url!==e.url)throw Error(`Remote child stream resolver does not match the authored remote agent.`);return await resolveRemoteAgentRequestHeaders(t)}}return await resolveRemoteAgentRequestHeaders(resolveDynamicRemoteAgentCredentials({credentialsStepId:e.resolverId,description:``,path:``,url:e.url}))}function resolveDynamicRemoteAgentCredentials(e){if(e.credentialsStepId===void 0)return{};let r=getStepRegistry().get(e.credentialsStepId);if(r===void 0)throw Error(`Dynamic remote subagent credentials function "${e.credentialsStepId}" is not registered.`);let i=expectObjectRecord(r(),`Dynamic remote subagent credentials are invalid.`),a={};return i.auth!==void 0&&(a.auth=expectFunction(i.auth,`Dynamic remote subagent auth is invalid.`)),i.headers!==void 0&&(a.headers=resolveDynamicRemoteAgentHeaders(i.headers)),a}function resolveDynamicRemoteAgentHeaders(e){if(typeof e==`function`)return e;let t=expectObjectRecord(e,`Dynamic remote subagent headers are invalid.`);for(let e of Object.values(t))if(typeof e!=`string`)throw Error(`Dynamic remote subagent headers are invalid.`);return t}function getStepRegistry(){let e=Symbol.for(`@workflow/core//registeredSteps`),t=globalThis,n=t[e];return n===void 0&&(n=new Map,t[e]=n),n}function createRemoteAgentSessionUrl(e){return createRemoteAgentRouteUrl(e.url,e.path)}function createRemoteAgentCancelTurnUrl(e,t){return createRemoteAgentRouteUrl(e.url,createEveSessionCancelRoutePath(t))}function createRemoteAgentContinueUrl(e,t){return createRemoteAgentRouteUrl(e.url,createEveSessionRoutePath(t))}function isRetryableRemoteCancelStatus(e){return e===408||e===425||e===429||e>=500}async function resolveRemoteAgentRequestHeaders(e){let t={};return e.headers!==void 0&&Object.assign(t,typeof e.headers==`function`?await e.headers():e.headers),e.auth!==void 0&&Object.assign(t,(await e.auth()).headers),t}function formatRemoteAgentCallInputMessage(e){let t=typeof e.action.input.message==`string`?e.action.input.message:``;return formatSubagentInput({description:e.remote.description,message:t,name:e.action.remoteAgentName,persistentSession:e.persistentSession,type:`remote`}).message}export{RemoteAgentContinueRequestError,cancelRemoteAgentTurn,continueRemoteAgentSession,isAmbiguousRemoteAgentContinueError,isRetryableRemoteAgentCancelError,isRetryableRemoteAgentContinueError,resolveRemoteAgentForAction,resolveRemoteAgentStreamHeaders,startRemoteAgentSession};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function createRemoteAgentRouteUrl(e,t){return new URL(t.replace(/^\/+/,``),`${trimTrailingSlash(e)}/`).toString()}function trimTrailingSlash(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{createRemoteAgentRouteUrl};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeliverHookPayload } from "#channel/types.js";
|
|
2
2
|
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
3
|
-
import { type RoutedDeliverResult } from "#execution/
|
|
3
|
+
import { type RoutedDeliverResult } from "#execution/proxied-deliver-step.js";
|
|
4
4
|
/**
|
|
5
5
|
* Coalesces inbound deliver payloads and routes any descendant-bound input
|
|
6
6
|
* responses down to the owning child. A descendant session-limit Stop is
|
|
@@ -15,4 +15,5 @@ export declare function routeDeliverToChildren(input: {
|
|
|
15
15
|
readonly delivery: DeliverHookPayload;
|
|
16
16
|
readonly parentWritable: WritableStream<Uint8Array>;
|
|
17
17
|
readonly sessionState: DurableSessionState;
|
|
18
|
+
readonly serializedContext: Record<string, unknown>;
|
|
18
19
|
}): Promise<RoutedDeliverResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{routeProxiedDeliverStep}from"#execution/
|
|
1
|
+
import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{routeProxiedDeliverStep}from"#execution/proxied-deliver-step.js";import{emitRecordedTaskAuthorizationEventStep,emitRecordedTaskInputRequestStep}from"#execution/subagent-event-proxy-step.js";import{acceptTaskAuthorizationEventStep,recordTaskInputRequestStep,recordTerminalTaskViewsStep}from"#execution/tasks/parent/hitl-proxy-steps.js";async function routeDeliverToChildren(i){let a=coalesceDeliverPayloads(i.delivery.payloads),o=i.serializedContext,s=i.sessionState;(a.task?.views?.length??0)>0&&(s=await recordTerminalTaskViewsStep({sessionState:s,views:a.task?.views??[]}));for(let e of a.task?.inputRequests??[]){let t=await recordTaskInputRequestStep({hookPayload:e.hookPayload,serializedContext:o,sessionState:s,taskId:e.taskId});if(s=t.sessionState,!t.accepted)continue;let n=await emitRecordedTaskInputRequestStep({hookPayload:t.hookPayload,parentWritable:i.parentWritable,serializedContext:o,sessionState:s});o=n.serializedContext,s=n.sessionState}for(let e of a.task?.authorizationEvents??[]){if(!await acceptTaskAuthorizationEventStep({hookPayload:e.hookPayload,sessionState:s,taskId:e.taskId}))continue;let t=await emitRecordedTaskAuthorizationEventStep({hookPayload:e.hookPayload,parentWritable:i.parentWritable,serializedContext:o,sessionState:s});o=t.serializedContext,s=t.sessionState}let c=[],l=[];for(let[e,t]of i.delivery.payloads.entries()){let n={...t};if(delete n.task,Object.keys(n).length===0)continue;let r=c.length;c.push(n);for(let t of i.delivery.deliveryMetadata??[])t.payloadIndex===e&&l.push({...t,payloadIndex:r})}let u=c.length===0?void 0:{...i.delivery,deliveryMetadata:l.length===0?void 0:l,payloads:c};return u===void 0?{kind:`continue`,remainder:void 0,serializedContext:o,sessionState:s}:s.hasProxyInputRequests?await routeProxiedDeliverStep({delivery:u,parentWritable:i.parentWritable,serializedContext:o,sessionState:s}):{kind:`continue`,remainder:u,serializedContext:o,sessionState:s}}export{routeDeliverToChildren};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdir,readdir,rm,stat,utimes,writeFile}from"node:fs/promises";import
|
|
1
|
+
import{mkdir,readdir,rm,stat,utimes,writeFile}from"node:fs/promises";import{dirname,join}from"node:path";import"node:fs";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";import{createDockerCli}from"#execution/sandbox/bindings/docker-cli.js";import{LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,selectStaleTemplateEntries}from"#execution/sandbox/bindings/local-template-prune.js";const DOCKER_TEMPLATE_IMAGE_REPOSITORY=`eve-sandbox-template`;async function pruneDockerSandboxTemplates(e){let i=e.dockerCli??createDockerCli(),a=resolveDockerTemplateMarkersDirectory(e.appRoot),o;try{o=await readdir(a,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let s=selectStaleTemplateEntries(await Promise.all(o.filter(e=>e.isFile()).map(async e=>{let t=join(a,e.name);return{imageTag:e.name,mtimeMs:(await stat(t)).mtimeMs,path:t}})),{now:e.now??Date.now(),recentWindowMs:e.recentWindowMs??LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,retainCount:e.retainCount??LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT});for(let e of s){let t=await i.run([`rmi`,dockerTemplateImageReferenceFromTag(e.imageTag)]),r=t.exitCode!==0&&/no such image/i.test(t.stderr);(t.exitCode===0||r)&&await rm(e.path,{force:!0})}}function dockerTemplateImageReference(e){return dockerTemplateImageReferenceFromTag(dockerTemplateImageTag(e))}function dockerTemplateImageReferenceFromTag(e){return`${DOCKER_TEMPLATE_IMAGE_REPOSITORY}:${e}`}function dockerTemplateImageTag(e){return`${e.templateKey.toLowerCase()}-${e.optionsHash}`}function resolveDockerTemplateMarkerPath(e,t){return join(resolveDockerTemplateMarkersDirectory(e),dockerTemplateImageTag(t))}async function touchDockerTemplateMarker(t,n){await mkdir(dirname(t),{recursive:!0});try{let e=new Date;await utimes(t,e,e)}catch{await writeFile(t,`${n}\n`)}}async function dockerImageExists(e,t){return(await e.run([`image`,`inspect`,`--format`,`{{.Id}}`,t])).exitCode===0}async function ensureDockerBaseImage(e,t){if(t.pullPolicy===`always`){expectDockerSuccess(await e.run([`pull`,t.image]),`pull base image "${t.image}"`);return}if(!await dockerImageExists(e,t.image)){if(t.pullPolicy===`never`)throw Error(`The local sandbox base image "${t.image}" is not present locally and pullPolicy is "never". Pull the image manually or relax the pull policy.`);expectDockerSuccess(await e.run([`pull`,t.image]),`pull base image "${t.image}"`)}}function resolveDockerTemplateMarkersDirectory(e){return join(resolveSandboxCacheDirectory(e),`docker`,`templates`)}export{DOCKER_TEMPLATE_IMAGE_REPOSITORY,dockerImageExists,dockerTemplateImageReference,ensureDockerBaseImage,pruneDockerSandboxTemplates,resolveDockerTemplateMarkerPath,touchDockerTemplateMarker};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{mkdir,readdir,rename,rm,stat}from"node:fs/promises";import
|
|
1
|
+
import{randomUUID}from"node:crypto";import{mkdir,readdir,rename,rm,stat}from"node:fs/promises";import{dirname,join}from"node:path";import"node:fs";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{copyDirectoryAtomically,createFileBackedInternalSandboxSession,pathExists,resolveLocalBackendSessionRootPath,resolveLocalBackendTemplateRootPath,resolveLocalBackendTemplatesDirectory,touchDirectory,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-backend-utils.js";import{LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,selectStaleTemplateEntries}from"#execution/sandbox/bindings/local-template-prune.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{createBashSandbox,createJustBashHandle,justBashSetNetworkPolicyUnsupported}from"#execution/sandbox/bindings/just-bash-runtime.js";const JUST_BASH_CACHE_DIRECTORY_NAME=`just-bash`,JUST_BASH_BACKEND_NAME=`just-bash`;function createJustBashSandboxBackend(n={}){let i=n.createOptions?.autoInstall??!0,o=n.createOptions?.filesystem;return{name:JUST_BASH_BACKEND_NAME,async prewarm(n){let o=resolveTemplateRootPath(resolveSandboxCacheDirectory(n.runtimeContext.appRoot),n.templateKey);if(await pathExists(o))return await touchDirectory(o),{reused:!0};let s=`${o}.${randomUUID()}.tmp`,u=!1,d=await createBashSandbox({appRoot:n.runtimeContext.appRoot,autoInstall:i,rootPath:s,sessionKey:n.templateKey}),f=buildSandboxSession(createFileBackedInternalSandboxSession({id:d.sessionKey,sandbox:d}),justBashSetNetworkPolicyUnsupported);try{if(await writeSandboxSeedFiles(f,n.seedFiles),n.bootstrap!==void 0&&(n.log?.(`running sandbox bootstrap`),await n.bootstrap({use:async()=>createLoggingSandboxSession({log:n.log,session:f})})),await d.captureState()===null)throw Error(`Failed to capture local sandbox template state for "${n.templateKey}".`);await mkdir(dirname(o),{recursive:!0});try{await rename(s,o),u=!0}catch(e){if(await pathExists(o))return{reused:!0};throw e}}finally{await d.dispose(),u||await rm(s,{force:!0,recursive:!0}).catch(()=>{})}return{reused:!1}},async create(e){let n=resolveSandboxCacheDirectory(e.runtimeContext.appRoot),r=getLocalRootPath(e.existingMetadata)??resolveSessionRootPath(n,e.sessionKey);if(!await pathExists(r))if(e.templateKey===null)await mkdir(r,{recursive:!0});else{let t=resolveTemplateRootPath(n,e.templateKey);if(!await pathExists(t))throw new SandboxTemplateNotProvisionedError({backendName:JUST_BASH_BACKEND_NAME,templateKey:e.templateKey});await copyDirectoryAtomically(t,r)}return createJustBashHandle(await createBashSandbox({appRoot:e.runtimeContext.appRoot,autoInstall:i,filesystem:o,rootPath:r,sessionKey:e.sessionKey}),JUST_BASH_BACKEND_NAME)}}}async function pruneJustBashSandboxTemplates(e){let t=resolveLocalBackendTemplatesDirectory(resolveSandboxCacheDirectory(e.appRoot),JUST_BASH_CACHE_DIRECTORY_NAME),r=e.now??Date.now(),a=e.recentWindowMs??LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,s=e.retainCount??LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,c;try{c=await readdir(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let l=await Promise.all(c.filter(e=>e.isDirectory()).map(async e=>{let n=join(t,e.name);return{isTemporary:e.name.endsWith(`.tmp`),mtimeMs:(await stat(n)).mtimeMs,path:n}})),u=selectStaleTemplateEntries(l.filter(e=>!e.isTemporary),{now:r,recentWindowMs:a,retainCount:s}),d=selectStaleTemplateEntries(l.filter(e=>e.isTemporary),{now:r,recentWindowMs:a,retainCount:0});await Promise.all([...u,...d].map(async e=>await rm(e.path,{force:!0,recursive:!0})))}function resolveTemplateRootPath(e,t){return resolveLocalBackendTemplateRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function resolveSessionRootPath(e,t){return resolveLocalBackendSessionRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function getLocalRootPath(e){let t=e?.rootPath;return typeof t==`string`?t:void 0}export{JUST_BASH_BACKEND_NAME,createJustBashSandboxBackend,pruneJustBashSandboxTemplates};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdir,rm,stat}from"node:fs/promises";import"node:
|
|
1
|
+
import{readdir,rm,stat}from"node:fs/promises";import{join}from"node:path";import"node:fs";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{resolveLocalBackendSessionRootPath,resolveLocalBackendTemplateRootPath,resolveLocalBackendTemplatesDirectory}from"#execution/sandbox/bindings/local-backend-utils.js";import{LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT}from"#execution/sandbox/bindings/local-template-prune.js";import{readTemplateMetadata,resolveMicrosandboxMetadataPath}from"#execution/sandbox/bindings/microsandbox-metadata.js";import{loadMicrosandboxWithoutInstall,removeSnapshotIfExists}from"#execution/sandbox/bindings/microsandbox-runtime.js";const MICROSANDBOX_CACHE_DIRECTORY_NAME=`microsandbox`;async function pruneMicrosandboxTemplates(e){let t=resolveMicrosandboxTemplatesDirectory(resolveSandboxCacheDirectory(e.appRoot)),n=e.now??Date.now(),r=e.recentWindowMs??LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,a=e.retainCount??LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,o=await readMicrosandboxTemplateDirectories(t),s=o.filter(e=>!e.isTemporary);await Promise.all([...s.map(async(t,i)=>{i<a||n-t.mtimeMs<=r||await removeTemplateDirectory(e.appRoot,t.path,t.metadata)}),...o.filter(e=>e.isTemporary).map(async t=>{n-t.mtimeMs<=r||await removeTemplateDirectory(e.appRoot,t.path,t.metadata)})])}function resolveMicrosandboxTemplateRootPath(e,t){return resolveLocalBackendTemplateRootPath(e,MICROSANDBOX_CACHE_DIRECTORY_NAME,t)}function resolveMicrosandboxTemplatesDirectory(e){return resolveLocalBackendTemplatesDirectory(e,MICROSANDBOX_CACHE_DIRECTORY_NAME)}function resolveMicrosandboxSessionRootPath(e,t){return resolveLocalBackendSessionRootPath(e,MICROSANDBOX_CACHE_DIRECTORY_NAME,t)}async function readMicrosandboxTemplateDirectories(t){let i;try{i=await readdir(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return[];throw e}return(await Promise.all(i.filter(e=>e.isDirectory()).map(async e=>{let i=join(t,e.name);return{isTemporary:e.name.endsWith(`.tmp`),metadata:await readTemplateMetadata(resolveMicrosandboxMetadataPath(i)),mtimeMs:(await stat(i)).mtimeMs,path:i}}))).sort((e,t)=>t.mtimeMs-e.mtimeMs)}async function removeTemplateDirectory(e,n,r){if(await rm(n,{force:!0,recursive:!0}),r===null)return;let i=await loadMicrosandboxWithoutInstall(e);i!==null&&await removeSnapshotIfExists(i,r.snapshotName)}export{pruneMicrosandboxTemplates,resolveMicrosandboxSessionRootPath,resolveMicrosandboxTemplateRootPath,resolveMicrosandboxTemplatesDirectory};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withSandboxTemplatePrewarmLock}from"./template-prewarm-lock.js";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{
|
|
1
|
+
import{withSandboxTemplatePrewarmLock}from"./template-prewarm-lock.js";import{join}from"node:path";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{toErrorMessage}from"#shared/errors.js";import{createBundledRuntimeCompiledArtifactsSource,createDiskRuntimeCompiledArtifactsSource,getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{loadCompiledModuleMapFromAuthoredSource}from"#internal/authored-module-map-loader.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{loadCompileMetadata}from"#runtime/loaders/compile-metadata.js";import{withBundledCompiledArtifacts}from"#runtime/loaders/bundled-artifacts.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{resolveRuntimeAgentGraph}from"#runtime/resolve-agent-graph.js";import{createRuntimeSandboxTemplateKey}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{materializeWorkspaceDirectory}from"#runtime/workspace/seed-files.js";async function prewarmSandboxes(t){let n=await collectPrewarmTargets(t);if(n.length===0)return;let i=createPrewarmSignature(n);if(t.shouldPrewarmSignature?.(i)===!1)return;let a=t.dispatch??(async({backend:e,input:t})=>await e.prewarm(t));t.log?.(`eve: initializing ${formatSandboxTemplateCount(n.length)}...`);let o=(await Promise.all(n.map(async({backend:n,label:i,input:o})=>{let logBackendProgress=e=>{shouldLogSandboxPrewarmProgress(e)&&t.log?.(`eve: sandbox template "${i}" (${n.name}): ${e}`)},s;try{s=await withSandboxTemplatePrewarmLock({appRoot:o.runtimeContext.appRoot,backendName:n.name,templateKey:o.templateKey},async()=>await a({backend:n,input:{...o,log:t.log===void 0?void 0:logBackendProgress}}))}catch(e){let a=formatPrewarmFailureForEnvironment({backendName:n.name,error:e});throw t.log?.(`eve: failed to initialize sandbox template "${i}" on backend "${n.name}": ${toErrorMessage(a)}`),a}return s}))).filter(e=>e.reused).length;t.log?.(`eve: initialized ${formatSandboxTemplateCount(n.length)} (${o} reused, ${n.length-o} built).`),t.onPrewarmSignature?.(i)}async function prewarmAppSandboxes(e){let t=e.compiledArtifactsSource??createAuthoredSourceRuntimeCompiledArtifactsSource(e.appRoot);if(t.kind!==`disk`)throw Error(`prewarmAppSandboxes requires disk-backed compiled artifacts.`);let n=await(e.loadAgentGraph??loadGraphFromArtifacts)({compiledArtifactsSource:t});await prewarmSandboxes({appRoot:getRuntimeCompiledArtifactsSandboxAppRoot(t)??e.appRoot,compileDirectoryPath:resolveRuntimeCompilerArtifactPaths(t.appRoot).compileDirectoryPath,compiledArtifactsSource:t,dispatch:e.dispatch,graph:n,log:e.log,onPrewarmSignature:e.onPrewarmSignature,shouldPrewarmSignature:e.shouldPrewarmSignature})}async function prewarmBuiltAppSandboxes(e){let r=join(e.appRoot,`.output`),o=createDiskRuntimeCompiledArtifactsSource(r,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:e.appRoot}),[c,l,u]=await Promise.all([loadCompileMetadata({compiledArtifactsSource:o}),loadCompiledManifest({compiledArtifactsSource:o}),loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:o})]);await withBundledCompiledArtifacts({manifest:l,metadata:c??void 0,moduleMap:u,sessionId:`built-app-prewarm`},async()=>{let t=createBundledRuntimeCompiledArtifactsSource(),n=await resolveRuntimeAgentGraph({manifest:l,moduleMap:u});await prewarmSandboxes({appRoot:e.appRoot,compileDirectoryPath:resolveRuntimeCompilerArtifactPaths(r).compileDirectoryPath,compiledArtifactsSource:t,dispatch:e.dispatch,graph:n,log:e.log})})}async function collectPrewarmTargets(e){let t={appRoot:e.appRoot},n=[];return await Promise.all(collectNodeSandboxes(e.graph).map(async({definition:r,nodeId:i,workspaceResourceRoot:a})=>{let o=createRuntimeSandboxTemplatePlan({definition:r,workspaceResourceRoot:a}),s=await createRuntimeSandboxTemplateKey({backendName:r.backend.name,compiledArtifactsSource:e.compiledArtifactsSource,nodeId:i,sourceId:r.sourceId,templatePlan:o});s!==null&&n.push({backend:r.backend,label:formatLabel(i),input:{bootstrap:r.bootstrap,seedFiles:await loadResourceRootSeedFiles({compileDirectoryPath:e.compileDirectoryPath,workspaceResourceRoot:a}),runtimeContext:t,templateKey:s},signature:`${r.backend.name}:${i}:${s}`})})),n.sort((e,t)=>e.label.localeCompare(t.label))}async function loadResourceRootSeedFiles(e){return e.workspaceResourceRoot.contentHash===void 0&&e.workspaceResourceRoot.rootEntries.length===0?[]:(await materializeWorkspaceDirectory(`${e.compileDirectoryPath}/${e.workspaceResourceRoot.logicalPath}`)).map(e=>({content:e.content,path:e.path}))}async function loadGraphFromArtifacts(e){let[t,n]=await Promise.all([loadCompiledManifest({compiledArtifactsSource:e.compiledArtifactsSource}),loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:e.compiledArtifactsSource})]);return await resolveRuntimeAgentGraph({manifest:t,moduleMap:n})}function collectNodeSandboxes(e){return[...e.nodesByNodeId.entries()].flatMap(([e,t])=>{let n=t.sandboxRegistry.sandbox;return n===null?[]:[{...n,nodeId:e}]})}function formatLabel(e){return e===ROOT_RUNTIME_AGENT_NODE_ID?`root`:e}function createPrewarmSignature(e){return e.map(e=>e.signature).sort().join(`
|
|
2
2
|
`)}function formatSandboxTemplateCount(e){return`${e} sandbox ${e===1?`template`:`templates`}`}function shouldLogSandboxPrewarmProgress(e){return!e.startsWith(`checking `)&&!e.startsWith(`reusing `)&&e!==`loading microsandbox runtime`&&e!==`microsandbox runtime ready`}function formatPrewarmFailureForEnvironment(e){return!isVercelEnvironment()||!isLocalSandboxBackend(e.backendName)?e.error:Error(`The ${e.backendName} sandbox backend is not available when deploying on Vercel. Vercel build containers cannot run local Docker containers or microsandbox VMs. Use defaultBackend() so eve selects Vercel Sandbox on Vercel, or configure a Vercel-compatible backend explicitly, such as vercel(). Original ${e.backendName} error: ${toErrorMessage(e.error)}`,{cause:e.error})}function isVercelEnvironment(){return!!process.env.VERCEL?.trim()}function isLocalSandboxBackend(e){return e===`docker`||e===`microsandbox`}export{prewarmAppSandboxes,prewarmBuiltAppSandboxes,prewarmSandboxes};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import type { SubagentAuthorizationEvent } from "#channel/types.js";
|
|
1
2
|
import type { TokenUsage } from "#shared/token-usage.js";
|
|
3
|
+
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
4
|
+
/** Sends task-owned remote HITL and authorization events to the parent callback capability. */
|
|
5
|
+
export declare function fireTaskEventCallbackStep(input: {
|
|
6
|
+
readonly callback: unknown;
|
|
7
|
+
readonly childContinuationToken: string;
|
|
8
|
+
readonly childSessionId: string;
|
|
9
|
+
readonly event: SubagentAuthorizationEvent | Extract<UnstampedMessageStreamEvent, {
|
|
10
|
+
type: "input.requested";
|
|
11
|
+
}>;
|
|
12
|
+
}): Promise<void>;
|
|
2
13
|
/**
|
|
3
14
|
* Sends the configured session terminal callback.
|
|
4
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{SessionCallbackKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{SESSION_FAILED}from"#harness/agent-handle-errors.js";import{parseSessionCallback}from"#channel/session-callback.js";import{postSessionCallbackRequest}from"#execution/session-callback-request.js";const log=createLogger(`execution.session-callback`);async function
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{SessionCallbackKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{SESSION_FAILED}from"#harness/agent-handle-errors.js";import{parseSessionCallback}from"#channel/session-callback.js";import{postSessionCallbackRequest}from"#execution/session-callback-request.js";const log=createLogger(`execution.session-callback`);async function fireTaskEventCallbackStep(e){"use step";let t=parseSerializedSessionCallback(e.callback);if(t.taskId===void 0)return;let n=e.event.type===`input.requested`,r=n?`task.input-requested`:`task.authorization`,i=await postSessionCallbackRequest({body:{callId:t.callId,childContinuationToken:e.childContinuationToken,childSessionId:e.childSessionId,event:n?e.event.data:e.event,kind:r,subagentName:t.subagentName,taskId:t.taskId},url:t.url});if(!i.ok)throw Error(`Task event callback failed with HTTP ${i.status}.`)}async function fireSessionCallbackStep(e){"use step";let i=e.serializedContext[`eve.sessionId`]??``,o=e.serializedContext[SessionCallbackKey.name];if(o!==void 0)try{let t=parseSerializedSessionCallback(o),a=await postSessionCallbackRequest({body:e.status===`completed`?buildCompletedCallbackBody({callback:t,output:e.output,sessionId:i,usage:e.usage}):{callId:t.callId,error:{code:SESSION_FAILED,message:toErrorMessage(e.error)},kind:`session.failed`,sessionId:i,subagentName:t.subagentName,usage:e.usage},url:t.url});if(!a.ok)throw Error(`Session callback failed with HTTP ${a.status}.`)}catch(e){throw log.error(`failed to post session callback`,{error:e,sessionId:i}),e}}function buildCompletedCallbackBody(e){let t={callId:e.callback.callId,kind:`session.completed`,output:e.output??``,sessionId:e.sessionId,subagentName:e.callback.subagentName};return e.usage===void 0?t:{...t,usage:e.usage}}function parseSerializedSessionCallback(e){let t=parseSessionCallback(e);if(!t.ok)throw Error(`Serialized session callback is invalid.`,{cause:t.cause});return t.callback}export{fireSessionCallbackStep,fireTaskEventCallbackStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function sendCommandToDelivery(e){return{auth:e.auth,caller:e.caller,deliveryMetadata:e.delivery===void 0?void 0:[{...e.delivery,payloadIndex:0}],kind:`deliver`,payload:e.payload,payloads:[e.payload],requestId:e.requestId,turnPolicy:e.turnPolicy}}export{sendCommandToDelivery};
|
|
1
|
+
function sendCommandToDelivery(e){return{auth:e.auth,caller:e.caller,deliveryMetadata:e.delivery===void 0?void 0:[{...e.delivery,payloadIndex:0}],kind:`deliver`,payload:e.payload,payloads:[e.payload],requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy}}export{sendCommandToDelivery};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
+
/** A durable-state transition; absent fields keep the cursor's current value. */
|
|
3
|
+
export interface SessionStateTransition {
|
|
4
|
+
readonly serializedContext?: Record<string, unknown>;
|
|
5
|
+
readonly sessionState?: DurableSessionState;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Owns the mutable serialized-context / session-state pair that durable
|
|
9
|
+
* steps thread through a run. Holders adopt each step's transition instead
|
|
10
|
+
* of rebinding both values by hand at every callsite.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SessionStateCursor {
|
|
13
|
+
private currentSerializedContext;
|
|
14
|
+
private currentSessionState;
|
|
15
|
+
constructor(input: {
|
|
16
|
+
readonly serializedContext: Record<string, unknown>;
|
|
17
|
+
readonly sessionState: DurableSessionState;
|
|
18
|
+
});
|
|
19
|
+
/** Latest adopted serialized runtime context. */
|
|
20
|
+
get serializedContext(): Record<string, unknown>;
|
|
21
|
+
/** Latest adopted durable session state. */
|
|
22
|
+
get sessionState(): DurableSessionState;
|
|
23
|
+
/** Adopts a state transition; fields a step did not change carry forward. */
|
|
24
|
+
adoptState(transition: SessionStateTransition): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var SessionStateCursor=class{currentSerializedContext;currentSessionState;constructor(e){this.currentSerializedContext=e.serializedContext,this.currentSessionState=e.sessionState}get serializedContext(){return this.currentSerializedContext}get sessionState(){return this.currentSessionState}adoptState(e){this.currentSerializedContext=e.serializedContext??this.currentSerializedContext,this.currentSessionState=e.sessionState??this.currentSessionState}};export{SessionStateCursor};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
+
import type { TokenUsage } from "#shared/token-usage.js";
|
|
2
3
|
export interface CancelledTurnSettleResult {
|
|
3
4
|
readonly serializedContext: Record<string, unknown>;
|
|
4
5
|
readonly sessionState: DurableSessionState;
|
|
6
|
+
readonly usage?: TokenUsage;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* Settles one cancelled turn: emits `turn.cancelled` → `session.waiting`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler}from"#channel/adapter.js";import{ChannelInstrumentationKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{abandonRunningAgentTurns}from"#harness/handles/transitions.js";import{deserializeContext,serializeContext}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{buildAdapterContext}from"#channel/adapter-context.js";import{clearPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{ChannelInstrumentationKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{abandonRunningAgentTurns}from"#harness/handles/transitions.js";import{deserializeContext,serializeContext}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{buildAdapterContext}from"#channel/adapter-context.js";import{clearPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{clearPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{clearAllProxyInputRequests,getProxyInputRequests,hasProxyInputRequests}from"#harness/proxy-input-requests.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{withContextScope}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{activeTurnId}from"#harness/active-turn-id.js";import{emitCancelledTurn}from"#harness/cancelled-turn-emission.js";import{clearPendingSessionLimitPrompt}from"#harness/input-requests.js";import{createInstrumentationHandleEvent}from"#harness/instrumentation/native-events.js";import{getTurnUsageState,toUsage}from"#harness/turn-tag-state.js";async function settleCancelledTurnStep(a){"use step";let o=await readDurableSession(a.sessionState),s=await deserializeContext(a.serializedContext),c=s.require(ChannelKey),l=buildAdapterContext(c,s),u=s.require(BundleKey),d=resolveEffectiveAgentRuntime(u,s),f=getInstrumentationRuntime(),p=hydrateDurableSession({compactionOverrides:{thresholdPercent:d.thresholdPercent},durable:o,turnAgent:d.turnAgent}),m=getHarnessEmissionState(o.state),h=[...getProxyInputRequests(o.state).values()].some(e=>e.kind===`session-limit`);if(!(isHarnessBetweenTurns(p)&&hasProxyInputRequests(o.state)&&!h)){let n=a.parentWritable.getWriter();try{let r=await withContextScope(s,p,async r=>{let baseEmit=async t=>{let r=await callAdapterEventHandler(c,t,l);setChannelContext(s,{...c,state:{...l.state}});let i=stampMessageStreamEvent(r);await n.write(encodeMessageStreamEvent(i)),await dispatchStreamEventHooks({ctx:s,event:i,registry:u.hookRegistry})};return{result:await emitCancelledTurn(createInstrumentationHandleEvent({agentName:u.turnAgent.id,channelKind:s.get(ChannelInstrumentationKey)?.kind,handleEvent:baseEmit,hooks:f?.hooks,sessionId:p.sessionId,turnId:activeTurnId(m)})??baseEmit,m),session:r}});m=r.result,p=r.session}finally{await f?.forceFlush(),n.releaseLock()}}let g=reconcileSessionContinuationToken(s,setHarnessEmissionState(clearPendingSessionLimitPrompt(clearAllProxyInputRequests(clearPendingWorkflowInterrupt(clearPendingRuntimeActionBatch(abandonRunningAgentTurns(p))))),m)),_=getTurnUsageState(p.state)?.session,v={serializedContext:serializeContext(s),sessionState:createDurableSessionState({session:g})};return _===void 0?v:{...v,usage:toUsage(_)}}export{settleCancelledTurnStep};
|
|
@@ -13,11 +13,26 @@ export declare function runProxySubagentEventStep(input: {
|
|
|
13
13
|
readonly serializedContext: Record<string, unknown>;
|
|
14
14
|
readonly sessionState: DurableSessionState;
|
|
15
15
|
}): Promise<ProxySubagentEventResult>;
|
|
16
|
+
/** Emits a task request whose proxy routes were committed by a prior step. */
|
|
17
|
+
export declare function emitRecordedTaskInputRequestStep(input: {
|
|
18
|
+
readonly hookPayload: SubagentInputRequestHookPayload;
|
|
19
|
+
readonly parentWritable: WritableStream<Uint8Array>;
|
|
20
|
+
readonly serializedContext: Record<string, unknown>;
|
|
21
|
+
readonly sessionState: DurableSessionState;
|
|
22
|
+
}): Promise<ProxySubagentEventResult>;
|
|
23
|
+
/** Emits a task authorization event after its ownership was validated. */
|
|
24
|
+
export declare function emitRecordedTaskAuthorizationEventStep(input: {
|
|
25
|
+
readonly hookPayload: SubagentAuthorizationEventHookPayload;
|
|
26
|
+
readonly parentWritable: WritableStream<Uint8Array>;
|
|
27
|
+
readonly serializedContext: Record<string, unknown>;
|
|
28
|
+
readonly sessionState: DurableSessionState;
|
|
29
|
+
}): Promise<ProxySubagentEventResult>;
|
|
16
30
|
/** Applies one proxied child event to an already-hydrated parent context. */
|
|
17
31
|
export declare function emitProxiedSubagentEvent(input: {
|
|
18
32
|
readonly ctx: ContextContainer;
|
|
19
33
|
readonly durableSession: DurableSession;
|
|
20
34
|
readonly hookPayload: SubagentEventHookPayload;
|
|
21
35
|
readonly parentWritable: WritableStream<Uint8Array>;
|
|
36
|
+
readonly recordProxyInputRequests?: boolean;
|
|
22
37
|
}): Promise<ProxySubagentEventResult>;
|
|
23
38
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler}from"#channel/adapter.js";import{ModeKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}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{buildAdapterContext}from"#channel/adapter-context.js";import{upsertProxyInputRequests}from"#harness/proxy-input-requests.js";import{emitProxiedInputRequest}from"#execution/subagent-hitl-proxy.js";import{setChannelContext}from"#execution/channel-context.js";import{withContextScope}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";async function runProxySubagentEventStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable})}async function emitProxiedSubagentEvent(i){let{ctx:a}=i,o=a.require(ChannelKey),s=resolveEffectiveAgentRuntime(a.require(BundleKey),a),c=hydrateDurableSession({compactionOverrides:{thresholdPercent:s.thresholdPercent},durable:i.durableSession,turnAgent:s.turnAgent}),l=buildAdapterContext(o,a),u=i.parentWritable.getWriter(),d,f;try{let emit=async t=>{let r=await callAdapterEventHandler(o,t,l);await u.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))},r=await withContextScope(a,c,async e=>{if(i.hookPayload.kind===`subagent-authorization-event`)return await emit(i.hookPayload.event),{result:void 0,session:e};let n=await emitProxiedInputRequest({emit,hookPayload:i.hookPayload,mode:a.require(ModeKey),session:e});return{result:n.entries,session:n.session}});d=r.result,f=r.session}finally{u.releaseLock()}setChannelContext(a,{...o,state:{...l.state}}),d!==void 0&&i.hookPayload.kind===`subagent-input-request`&&(f=upsertProxyInputRequests({entries:d,forChildContinuationToken:i.hookPayload.childContinuationToken,session:f}));let p=reconcileSessionContinuationToken(a,f);return{serializedContext:serializeContext(a),sessionState:createDurableSessionState({session:p})}}export{emitProxiedSubagentEvent,runProxySubagentEventStep};
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{ModeKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}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{buildAdapterContext}from"#channel/adapter-context.js";import{upsertProxyInputRequests}from"#harness/proxy-input-requests.js";import{emitProxiedInputRequest}from"#execution/subagent-hitl-proxy.js";import{setChannelContext}from"#execution/channel-context.js";import{withContextScope}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";async function runProxySubagentEventStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable})}async function emitRecordedTaskInputRequestStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable,recordProxyInputRequests:!1})}async function emitRecordedTaskAuthorizationEventStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable,recordProxyInputRequests:!1})}async function emitProxiedSubagentEvent(i){let{ctx:a}=i,o=a.require(ChannelKey),s=resolveEffectiveAgentRuntime(a.require(BundleKey),a),c=hydrateDurableSession({compactionOverrides:{thresholdPercent:s.thresholdPercent},durable:i.durableSession,turnAgent:s.turnAgent}),l=buildAdapterContext(o,a),u=i.parentWritable.getWriter(),d,f;try{let emit=async t=>{let r=await callAdapterEventHandler(o,t,l);await u.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))},r=await withContextScope(a,c,async e=>{if(i.hookPayload.kind===`subagent-authorization-event`)return await emit(i.hookPayload.event),{result:void 0,session:e};let n=await emitProxiedInputRequest({emit,hookPayload:i.hookPayload,mode:a.require(ModeKey),session:e});return{result:n.entries,session:n.session}});d=r.result,f=r.session}finally{u.releaseLock()}setChannelContext(a,{...o,state:{...l.state}}),i.recordProxyInputRequests!==!1&&d!==void 0&&i.hookPayload.kind===`subagent-input-request`&&(f=upsertProxyInputRequests({entries:d,forChildContinuationToken:i.hookPayload.childContinuationToken,session:f}));let p=reconcileSessionContinuationToken(a,f);return{serializedContext:serializeContext(a),sessionState:createDurableSessionState({session:p})}}export{emitProxiedSubagentEvent,emitRecordedTaskAuthorizationEventStep,emitRecordedTaskInputRequestStep,runProxySubagentEventStep};
|
|
@@ -17,19 +17,25 @@ export declare function emitProxiedInputRequest(input: {
|
|
|
17
17
|
readonly entries: readonly (readonly [requestId: string, route: ProxyInputRequest])[];
|
|
18
18
|
readonly session: HarnessSession;
|
|
19
19
|
}>;
|
|
20
|
+
/** One proxied-child bucket of a routed deliver payload. */
|
|
21
|
+
export interface RoutedChildDelivery {
|
|
22
|
+
readonly childContinuationToken: string;
|
|
23
|
+
readonly childResponseUrl?: string;
|
|
24
|
+
readonly payload: {
|
|
25
|
+
readonly inputResponses: readonly InputResponse[];
|
|
26
|
+
};
|
|
27
|
+
/** Parent-visible request IDs safe to retire once this bucket is forwarded. */
|
|
28
|
+
readonly retireRequestIds: readonly string[];
|
|
29
|
+
/** Present when the child is owned by a task run, which delivers on the parent's behalf. */
|
|
30
|
+
readonly taskId?: string;
|
|
31
|
+
}
|
|
20
32
|
/**
|
|
21
33
|
* Outcome of splitting one deliver payload by the session's proxy map.
|
|
22
34
|
* `forSelf` is the parent-local remainder (or `undefined` when fully
|
|
23
35
|
* routed); `forChildren` carries one entry per descendant token.
|
|
24
36
|
*/
|
|
25
37
|
export interface RoutedDeliverPayload {
|
|
26
|
-
readonly forChildren: readonly
|
|
27
|
-
readonly childContinuationToken: string;
|
|
28
|
-
readonly payload: {
|
|
29
|
-
readonly inputResponses: readonly InputResponse[];
|
|
30
|
-
};
|
|
31
|
-
readonly retireRequestIds: readonly string[];
|
|
32
|
-
}[];
|
|
38
|
+
readonly forChildren: readonly RoutedChildDelivery[];
|
|
33
39
|
readonly forSelf: DeliverPayload | undefined;
|
|
34
40
|
readonly parentAction: {
|
|
35
41
|
readonly kind: "cancel-turn";
|
|
@@ -37,6 +43,7 @@ export interface RoutedDeliverPayload {
|
|
|
37
43
|
}
|
|
38
44
|
/** Splits a deliver payload into parent-local and proxied-child buckets. */
|
|
39
45
|
export declare function routeDeliverPayload(input: {
|
|
46
|
+
readonly allowRoute?: (requestId: string, route: ProxyInputRequest) => boolean;
|
|
40
47
|
readonly payload: DeliverPayload;
|
|
41
48
|
readonly state: SessionStateMap | undefined;
|
|
42
49
|
}): RoutedDeliverPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInputRequestedEvent}from"#protocol/message.js";import{emitTurnEpilogue,getHarnessEmissionState,setHarnessEmissionState}from"#harness/emission.js";import{getProxyInputRequests,toProxyInputRequestEntries}from"#harness/proxy-input-requests.js";import{SESSION_LIMIT_STOP_OPTION_ID}from"#harness/session-limit-continuation.js";async function emitProxiedInputRequest(i){await i.emit(createInputRequestedEvent({requests:i.hookPayload.event.requests,sequence:i.hookPayload.event.sequence,stepIndex:i.hookPayload.event.stepIndex,turnId:i.hookPayload.event.turnId}));let o=i.session;if(i.mode===`conversation`){let e=getHarnessEmissionState(i.session.state),a=await emitTurnEpilogue(i.emit,e,i.mode);o=setHarnessEmissionState(i.session,a)}return{entries:toProxyInputRequestEntries(i.hookPayload),session:o}}function routeDeliverPayload(e){let t=getProxyInputRequests(e.state),n=e.payload.inputResponses??[],r=new Map,a=[],s;for(let
|
|
1
|
+
import{createInputRequestedEvent}from"#protocol/message.js";import{emitTurnEpilogue,getHarnessEmissionState,setHarnessEmissionState}from"#harness/emission.js";import{getProxyInputRequests,toProxyInputRequestEntries}from"#harness/proxy-input-requests.js";import{SESSION_LIMIT_STOP_OPTION_ID}from"#harness/session-limit-continuation.js";async function emitProxiedInputRequest(i){await i.emit(createInputRequestedEvent({requests:i.hookPayload.event.requests,sequence:i.hookPayload.event.sequence,stepIndex:i.hookPayload.event.stepIndex,turnId:i.hookPayload.event.turnId}));let o=i.session;if(i.mode===`conversation`){let e=getHarnessEmissionState(i.session.state),a=await emitTurnEpilogue(i.emit,e,i.mode);o=setHarnessEmissionState(i.session,a)}return{entries:toProxyInputRequestEntries(i.hookPayload),session:o}}function routeDeliverPayload(e){let t=getProxyInputRequests(e.state),n=e.payload.inputResponses??[],r=new Map,a=[],s;for(let i of n){let n=t.get(i.requestId);if(n===void 0||e.allowRoute?.(i.requestId,n)===!1){a.push(i);continue}n.kind===`session-limit`&&i.optionId===SESSION_LIMIT_STOP_OPTION_ID&&(s={kind:`cancel-turn`});let c=n.taskId===void 0?n.childContinuationToken:`${n.childContinuationToken}\0${n.childResponseUrl??`local`}\0${n.taskId}`,l=r.get(c);l===void 0?r.set(c,{childContinuationToken:n.childContinuationToken,parentRequestIds:[i.requestId],responses:[toChildInputResponse(i,n)],routes:[n],...n.childResponseUrl!==void 0&&{childResponseUrl:n.childResponseUrl},...n.taskId!==void 0&&{taskId:n.taskId}}):(l.parentRequestIds.push(i.requestId),l.responses.push(toChildInputResponse(i,n)),l.routes.push(n))}let c=[...r.values()].map(({childContinuationToken:e,childResponseUrl:n,parentRequestIds:r,responses:i,routes:a,taskId:o})=>{let s=new Set(r),c=new Set(s);for(let n of a)if(n.batch!==void 0&&batchResolves({batch:n.batch,childContinuationToken:e,entries:t,responseIds:s}))for(let e of n.batch.requestIds)c.add(e);return{childContinuationToken:e,payload:{inputResponses:i},retireRequestIds:[...c],...n!==void 0&&{childResponseUrl:n},...o!==void 0&&{taskId:o}}}),l={};for(let[t,n]of Object.entries(e.payload))t===`inputResponses`||n===void 0||(l[t]=n);return a.length>0&&(l.inputResponses=a),{forChildren:c,forSelf:Object.keys(l).length>0?l:void 0,parentAction:s}}function batchResolves(e){return e.batch.approvalRequestIds.length===0||e.batch.approvalRequestIds.every(t=>{let n=e.entries.get(t);return n===void 0||!sameBatch(n,e)||e.responseIds.has(t)})}function sameBatch(e,t){return e.childContinuationToken===t.childContinuationToken&&e.batch?.requestIds.length===t.batch.requestIds.length&&e.batch.requestIds.every((e,n)=>e===t.batch.requestIds[n])}function toChildInputResponse(e,t){return t.childRequestId===void 0?e:{...e,requestId:t.childRequestId}}export{emitProxiedInputRequest,routeDeliverPayload};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DispatchOutcome, RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
import { buildSubagentRunInput, type SubagentInputSource } from "#execution/subagent-tool.js";
|
|
3
|
+
import { createWorkflowRuntime } from "#execution/workflow-runtime.js";
|
|
4
|
+
import type { RuntimeSubagentCallActionRequest } from "#runtime/actions/types.js";
|
|
5
|
+
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
6
|
+
type DynamicSubagentAgentConfig = Parameters<typeof createWorkflowRuntime>[0]["dynamicSubagentAgentConfig"];
|
|
7
|
+
/** Starts one local subagent after dispatch planning has selected its target. */
|
|
8
|
+
export declare function startLocalSubagent(input: {
|
|
9
|
+
readonly action: RuntimeSubagentCallActionRequest;
|
|
10
|
+
readonly auth: Parameters<typeof buildSubagentRunInput>[0]["auth"];
|
|
11
|
+
readonly batchEvent: {
|
|
12
|
+
readonly sequence: number;
|
|
13
|
+
readonly turnId: string;
|
|
14
|
+
};
|
|
15
|
+
readonly bundle: CompiledBundle;
|
|
16
|
+
readonly capabilities: Parameters<typeof buildSubagentRunInput>[0]["capabilities"];
|
|
17
|
+
readonly channelMetadata: Parameters<typeof buildSubagentRunInput>[0]["channelMetadata"];
|
|
18
|
+
readonly currentSession: RuntimeSession;
|
|
19
|
+
readonly dynamicSubagentAgentConfig?: DynamicSubagentAgentConfig;
|
|
20
|
+
readonly fanoutSize: number;
|
|
21
|
+
readonly initiatorAuth: Parameters<typeof buildSubagentRunInput>[0]["initiatorAuth"];
|
|
22
|
+
readonly parentContinuationToken: string | undefined;
|
|
23
|
+
readonly parentTraceContext: Parameters<typeof buildSubagentRunInput>[0]["parentTraceContext"];
|
|
24
|
+
readonly persistentSessions: boolean;
|
|
25
|
+
readonly session: RuntimeSession;
|
|
26
|
+
readonly source: SubagentInputSource;
|
|
27
|
+
readonly taskOwned: boolean;
|
|
28
|
+
}): Promise<DispatchOutcome>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{isRuntimeSessionOwnershipConflictError}from"#execution/runtime-errors.js";import{toErrorMessage}from"#shared/errors.js";import{SUBAGENT_START_FAILED}from"#harness/agent-handle-errors.js";import{confirmAgentStarted,confirmTaskAgentAddress,prepareAgentStart,rejectAgentEffect}from"#harness/handles/transitions.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{buildSubagentRunInput}from"#execution/subagent-tool.js";import{mintStartOperation}from"#execution/dispatch-start-operation.js";const log=createLogger(`execution.subagent-start-local`);async function startLocalSubagent(e){let{action:t,source:n}=e,r=createWorkflowRuntime({compiledArtifactsSource:e.bundle.compiledArtifactsSource,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,nodeId:t.nodeId}),{childContinuationToken:i,runInput:a}=buildSubagentRunInput({action:t,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:n}),o=n.type===`runtime`?`agent/self`:`agent/local`,{identity:s,operation:c}=mintStartOperation({callId:t.callId,name:t.subagentName,nodeId:t.nodeId,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),l=prepareAgentStart(e.currentSession,{identity:s,operation:c,target:{continuationToken:i,kind:o}}),u;try{u=(await r.createSession(a)).sessionId}catch(e){if(!isRuntimeSessionOwnershipConflictError(e))return logError(log,`local subagent start failed`,e,{callId:t.callId,nodeId:t.nodeId,subagentName:t.subagentName}),{kind:`error`,result:{callId:t.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:SUBAGENT_START_FAILED,message:toErrorMessage(e)},subagentName:t.subagentName},session:rejectAgentEffect(l,{disposition:`dead`,operationId:c.id})};u=e.ownerSessionId}let d={continuationToken:i,kind:o,sessionId:u};return{address:d,callId:t.callId,kind:`called`,name:t.name,session:e.taskOwned?confirmTaskAgentAddress(l,{address:d,operationId:c.id}):confirmAgentStarted(l,{address:d,operationId:c.id}),toolName:t.subagentName}}export{startLocalSubagent};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DispatchOutcome, RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
import { resolveRemoteAgentForAction, startRemoteAgentSession } from "#execution/remote-agent-dispatch.js";
|
|
3
|
+
import type { RuntimeRemoteAgentCallActionRequest } from "#runtime/actions/types.js";
|
|
4
|
+
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
5
|
+
/** Starts one remote subagent after dispatch planning has selected its target. */
|
|
6
|
+
export declare function startRemoteSubagent(input: {
|
|
7
|
+
readonly action: RuntimeRemoteAgentCallActionRequest;
|
|
8
|
+
readonly auth: Parameters<typeof startRemoteAgentSession>[0]["auth"];
|
|
9
|
+
readonly batchEvent: {
|
|
10
|
+
readonly sequence: number;
|
|
11
|
+
readonly turnId: string;
|
|
12
|
+
};
|
|
13
|
+
readonly bundle: CompiledBundle;
|
|
14
|
+
readonly callbackBaseUrl: string | undefined;
|
|
15
|
+
readonly currentSession: RuntimeSession;
|
|
16
|
+
readonly dynamicRemoteAgent?: NonNullable<Parameters<typeof resolveRemoteAgentForAction>[0]["dynamicRemoteAgent"]>;
|
|
17
|
+
readonly initiatorAuth: Parameters<typeof startRemoteAgentSession>[0]["initiatorAuth"];
|
|
18
|
+
readonly parentContinuationToken: string | undefined;
|
|
19
|
+
readonly parentTraceContext: Parameters<typeof startRemoteAgentSession>[0]["parentTraceContext"];
|
|
20
|
+
readonly persistentSessions: boolean;
|
|
21
|
+
readonly session: RuntimeSession;
|
|
22
|
+
readonly taskOwned: boolean;
|
|
23
|
+
}): Promise<DispatchOutcome>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/remote-agent-dispatch.js";import{confirmAgentStarted,confirmTaskAgentAddress,prepareAgentStart,rejectAgentEffect}from"#harness/handles/transitions.js";import{createRemoteAgentStartFailureResult}from"#execution/dispatch-action-failures.js";import{mintStartOperation}from"#execution/dispatch-start-operation.js";const log=createLogger(`execution.subagent-start-remote`);async function startRemoteSubagent(e){let{action:r}=e,i,a;try{if(e.callbackBaseUrl===void 0)throw Error(`Cannot dispatch remote agent without a callback base URL.`);i=e.callbackBaseUrl,a=resolveRemoteAgentForAction({dynamicRemoteAgent:e.dynamicRemoteAgent,nodeId:r.nodeId,remoteAgentName:r.remoteAgentName,registry:e.bundle.subagentRegistry.subagentsByNodeId})}catch(n){return logError(log,`remote agent start failed`,n,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:r,error:n}),session:e.currentSession}}let{identity:o,operation:s}=mintStartOperation({callId:r.callId,name:r.remoteAgentName,nodeId:r.nodeId,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),c=prepareAgentStart(e.currentSession,{identity:o,operation:s,target:{callbackBaseUrl:i,kind:`agent/remote`,url:a.url}});try{let t=await startRemoteAgentSession({action:r,auth:e.auth,callbackBaseUrl:i,callbackToken:e.parentContinuationToken,initiatorAuth:e.initiatorAuth,operationId:s.id,parentTraceContext:e.parentTraceContext,persistentSessions:e.persistentSessions,remote:a,session:e.session}),n={callbackBaseUrl:i,kind:`agent/remote`,sessionId:t.sessionId,url:a.url};return{address:n,callId:r.callId,kind:`called`,name:r.name,session:e.taskOwned?confirmTaskAgentAddress(c,{address:n,operationId:s.id}):confirmAgentStarted(c,{address:n,operationId:s.id}),toolName:r.remoteAgentName}}catch(e){return logError(log,`remote agent start failed`,e,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:r,error:e}),session:rejectAgentEffect(c,{disposition:`dead`,operationId:s.id})}}}export{startRemoteSubagent};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContextContainer } from "#context/container.js";
|
|
2
|
+
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
3
|
+
/**
|
|
4
|
+
* Forwards one task child's blocking transition to its parent's session
|
|
5
|
+
* callback.
|
|
6
|
+
*
|
|
7
|
+
* Task children report HITL and authorization transitions to the parent's
|
|
8
|
+
* task run before local emission, so the run can block/unblock the task
|
|
9
|
+
* under one durable decision. A session without a callback capability
|
|
10
|
+
* (non-delegated runs) is a no-op, as is any event outside the three
|
|
11
|
+
* blocking transitions.
|
|
12
|
+
*/
|
|
13
|
+
export declare function forwardTaskEventToSessionCallback(ctx: ContextContainer, event: UnstampedMessageStreamEvent): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ContinuationTokenKey,SessionCallbackKey,SessionIdKey}from"#context/keys.js";import{fireTaskEventCallbackStep}from"#execution/session-callback-step.js";async function forwardTaskEventToSessionCallback(e,t){let n=e.get(SessionCallbackKey);n!==void 0&&(t.type!==`input.requested`&&t.type!==`authorization.required`&&t.type!==`authorization.completed`||await fireTaskEventCallbackStep({callback:n,childContinuationToken:e.require(ContinuationTokenKey),childSessionId:e.require(SessionIdKey),event:t}))}export{forwardTaskEventToSessionCallback};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Narrows one private create-once session token to task-input delivery only. */
|
|
2
|
+
export declare function createTaskInputCapabilityToken(operationToken: string): string;
|
|
3
|
+
/** Resolves a task-input capability to the create-once session hook it may address. */
|
|
4
|
+
export declare function readTaskInputTargetToken(capabilityToken: string): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const OPERATION_TOKEN_PREFIX=`eve:eve:op:`,TASK_INPUT_TOKEN_PREFIX=`eve:task-input:`,TOKEN_DIGEST=/^[a-f0-9]{32}$/;function createTaskInputCapabilityToken(n){let r=readTokenDigest(n,OPERATION_TOKEN_PREFIX);if(r===void 0)throw Error(`Remote task input requires an eve create-once session capability.`);return`${TASK_INPUT_TOKEN_PREFIX}${r}`}function readTaskInputTargetToken(n){let r=readTokenDigest(n,TASK_INPUT_TOKEN_PREFIX);return r===void 0?void 0:`${OPERATION_TOKEN_PREFIX}${r}`}function readTokenDigest(e,t){if(!e.startsWith(t))return;let r=e.slice(t.length);return TOKEN_DIGEST.test(r)?r:void 0}export{createTaskInputCapabilityToken,readTaskInputTargetToken};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type TaskInboundAnswerInput, type TaskInboundAuthorizationEvent, type TaskInboundInputRequest, type TaskView } from "#tasks/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Appends one full task view to the owning task run's `eve.task`
|
|
4
|
+
* stream. Only the task run workflow calls this, which is what makes
|
|
5
|
+
* the run the single writer readers can trust without re-validating.
|
|
6
|
+
*/
|
|
7
|
+
export declare function appendTaskViewStep(input: {
|
|
8
|
+
readonly view: TaskView;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
/** Re-emits a task-owned child authorization event through the parent channel. */
|
|
11
|
+
export declare function wakeTaskAuthorizationParentStep(input: {
|
|
12
|
+
readonly request: TaskInboundAuthorizationEvent;
|
|
13
|
+
readonly taskId: string;
|
|
14
|
+
readonly token: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Wakes the parent session with a framework task notification.
|
|
18
|
+
*
|
|
19
|
+
* Rides the ordinary session delivery path: a parked parent starts a
|
|
20
|
+
* turn carrying this message, while an active turn observes it at the
|
|
21
|
+
* next safe boundary through the driver's normal delivery routing. A
|
|
22
|
+
* parent whose session already ended is a tolerated no-op.
|
|
23
|
+
*/
|
|
24
|
+
export declare function wakeTaskParentStep(input: {
|
|
25
|
+
readonly token: string;
|
|
26
|
+
readonly view: TaskView;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/** Sends an exact local-task HITL batch to the parent's pre-model router. */
|
|
29
|
+
export declare function wakeTaskInputRequestParentStep(input: {
|
|
30
|
+
readonly request: TaskInboundInputRequest;
|
|
31
|
+
readonly taskId: string;
|
|
32
|
+
readonly token: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Forwards answered input to the blocked child.
|
|
36
|
+
*
|
|
37
|
+
* The task run performs this itself so the child unblocks and the
|
|
38
|
+
* view leaves `input_required` under one durable decision. Returns
|
|
39
|
+
* `unreachable` when the child hook is already gone, which leaves the
|
|
40
|
+
* outstanding batch untouched rather than reporting a task as working
|
|
41
|
+
* when nothing received the answer.
|
|
42
|
+
*/
|
|
43
|
+
export declare function deliverTaskInputResponsesStep(input: {
|
|
44
|
+
readonly answer: TaskInboundAnswerInput;
|
|
45
|
+
readonly requestIds: readonly string[];
|
|
46
|
+
}): Promise<"delivered" | "unreachable">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{resumeHook}from"#internal/workflow/runtime.js";import{getWritable}from"#compiled/@workflow/core/index.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{TASK_VIEW_STREAM_NAMESPACE,isTerminalTaskStatus,taskAuthorizationRequestId}from"#tasks/types.js";const log=createLogger(`execution.tasks.run`);async function appendTaskViewStep(e){"use step";let t=getWritable({namespace:TASK_VIEW_STREAM_NAMESPACE}).getWriter();try{await t.write(e.view)}finally{t.releaseLock()}}async function wakeTaskAuthorizationParentStep(e){"use step";let n={callId:e.request.callId,childSessionId:e.request.childSessionId,event:e.request.event,kind:`subagent-authorization-event`,subagentName:e.request.subagentName},r=e.request.event.data,i={task:{authorizationEvents:[{hookPayload:n,taskId:e.taskId}]}};e.request.event.type===`authorization.required`&&(i.message=`Background task ${e.taskId} needs authorization.`);let a={kind:`send`,payload:i,taskDeliveryId:`${e.taskId}:authorization:${e.request.event.type}:${r.turnId}:${r.stepIndex}:${r.sequence}:${taskAuthorizationRequestId(e.request.event)}`};try{await resumeHook(e.token,a)}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}async function wakeTaskParentStep(e){"use step";let n={message:formatTaskNotification(e.view)};isTerminalTaskStatus(e.view.status)&&(n.task={views:[e.view]});let r={kind:`send`,payload:n,taskDeliveryId:`${e.view.taskId}:ready:${e.view.status}`};try{await resumeHook(e.token,r)}catch(t){if(isTaskWorkflowTargetGone(t)){log.warn(`task wake target is gone; the parent session already ended`,{status:e.view.status,taskId:e.view.taskId});return}throw t}}async function wakeTaskInputRequestParentStep(e){"use step";let n={kind:`send`,payload:{task:{inputRequests:[{hookPayload:e.request,taskId:e.taskId}]}},taskDeliveryId:`${e.taskId}:input:${e.request.event.turnId}:${e.request.event.stepIndex}:${e.request.event.sequence}`};try{await resumeHook(e.token,n)}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}async function deliverTaskInputResponsesStep(e){"use step";let n=new Set(e.requestIds),r={auth:e.answer.auth,kind:`send`,payload:{inputResponses:e.answer.inputResponses.filter(e=>n.has(e.requestId))},taskDeliveryId:`${e.answer.taskId}:${[...e.requestIds].sort().join(`,`)}`};try{if(e.answer.childResponseUrl!==void 0){let t=await fetch(e.answer.childResponseUrl,{body:JSON.stringify({inputResponses:r.payload.inputResponses}),headers:{"content-type":`application/json`},method:`POST`,redirect:`error`});if(t.status===404)return`unreachable`;if(!t.ok)throw Error(`Remote task input delivery failed with HTTP ${t.status}.`)}else await resumeHook(e.answer.childContinuationToken,r);return`delivered`}catch(t){if(isTaskWorkflowTargetGone(t))return log.warn(`task input answer target is gone; the child turn already ended`,{taskId:e.answer.taskId}),`unreachable`;throw t}}function formatTaskNotification(e){let t=`Background task ${e.taskId} (${e.metadata.name})`;return e.status===`input_required`?`${t} needs input. Use task_peek to inspect the outstanding requests.`:`${t} is ${e.status}. Use task_peek to read its output.`}export{appendTaskViewStep,deliverTaskInputResponsesStep,wakeTaskAuthorizationParentStep,wakeTaskInputRequestParentStep,wakeTaskParentStep};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type TaskView } from "#tasks/types.js";
|
|
2
|
+
/** Input for one durable task run. */
|
|
3
|
+
export interface TaskRunWorkflowInput {
|
|
4
|
+
/** Private task inbox token; a routing credential, never model-visible. */
|
|
5
|
+
readonly taskInboxToken: string;
|
|
6
|
+
/** The creation view, normally `working`. */
|
|
7
|
+
readonly initialView: TaskView;
|
|
8
|
+
/** Parent session delivery token used to wake the task's owning parent. */
|
|
9
|
+
readonly parentContinuationToken: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The durable task run: single writer for one task's lifecycle.
|
|
13
|
+
*
|
|
14
|
+
* Consumes commands and child wire payloads over its private hook,
|
|
15
|
+
* applies the pure transition function, and appends a full `TaskView`
|
|
16
|
+
* per accepted command to its `eve.task` run stream. Competing
|
|
17
|
+
* completion, cancellation, and input transitions serialize here;
|
|
18
|
+
* rejected commands (for example a late child result after `cancelled`)
|
|
19
|
+
* change nothing.
|
|
20
|
+
*
|
|
21
|
+
* Wake policy: a transition into a ready status — terminal or
|
|
22
|
+
* `input_required` — delivers a framework notification to the parent
|
|
23
|
+
* session. A parked parent starts a turn; an active turn observes the
|
|
24
|
+
* delivery at its next safe boundary. Nothing else wakes the parent.
|
|
25
|
+
*
|
|
26
|
+
* The run ends when the task reaches a terminal status. Its view
|
|
27
|
+
* stream stays readable, so terminal tasks remain peekable; the
|
|
28
|
+
* disposed hook makes any later command fail loudly instead of queueing
|
|
29
|
+
* against a finished task.
|
|
30
|
+
*/
|
|
31
|
+
export declare function taskRunWorkflow(input: TaskRunWorkflowInput): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{isReadyTaskStatus,isTerminalTaskStatus,readTaskInputRequestId,readTaskUsage}from"#tasks/types.js";import{appendTaskViewStep,deliverTaskInputResponsesStep,wakeTaskAuthorizationParentStep,wakeTaskInputRequestParentStep,wakeTaskParentStep}from"#execution/tasks/child/steps.js";import{applyTaskTransition}from"#tasks/transitions.js";import{translateTaskInboundPayload}from"#tasks/wire.js";function isTaskRunFinished(e,t){return!isTerminalTaskStatus(e.status)||!t?!1:e.status!==`cancelled`||e.executor?.lifecycle===`terminal`}async function taskRunWorkflow(i){"use workflow";let a=createHook({token:i.taskInboxToken}),o=a[Symbol.asyncIterator](),s=!1;try{try{await claimHookOwnership(a),s=!0}catch(e){if(isHookConflictError(e))return;throw e}let e=i.initialView,n,c=[],l=!1;for(await appendTaskViewStep({view:e});!isTaskRunFinished(e,l);){let t=await o.next();if(t.done===!0)return;let r=t.value.kind===`subagent-authorization-event`?{...t.value,kind:`authorization-event`}:t.value;if(r.kind===`authorization-event`&&(r.event.type===`approval.candidate`||r.event.type===`approval.settled`))continue;let a=r.kind===`task-command`&&r.command.kind===`ready`,s=r.kind===`task-command`&&r.command.kind===`reject-dispatch`;(a||s)&&(l=!0),r.kind===`subagent-input-request`&&(n=r),r.kind===`authorization-event`&&c.push(r);let u=e.status===`cancelled`&&r.kind===`runtime-action-result`,d=r.kind===`input-response`,f;if(u)f={kind:`settle-executor`,usage:readTaskUsage(r.results[0]?.outcome?.usageDelta)};else if(d){if(e.status!==`input_required`)continue;f=await resolveAnsweredCommand(e,r)}else f=translateTaskInboundPayload(r);if(f===void 0)continue;if(a&&isTerminalTaskStatus(e.status)){await wakeTaskParentStep({token:i.parentContinuationToken,view:e});continue}let p=applyTaskTransition(e,f);if(p.outcome!==`accepted`)continue;let m=!isTerminalTaskStatus(e.status)&&isTerminalTaskStatus(p.view.status),h=!isReadyTaskStatus(e.status)&&isReadyTaskStatus(p.view.status);e=p.view,await appendTaskViewStep({view:e});let g=l&&!m?c:[];for(let t of g)await wakeTaskAuthorizationParentStep({request:t,taskId:e.taskId,token:i.parentContinuationToken});(m||g.length>0)&&(c=[]),n!==void 0&&l&&e.status===`input_required`?(await wakeTaskInputRequestParentStep({request:n,taskId:e.taskId,token:i.parentContinuationToken}),n=void 0):!s&&g.length===0&&l&&(m||h&&n===void 0)&&await wakeTaskParentStep({token:i.parentContinuationToken,view:e}),e.status!==`input_required`&&(n=void 0)}}finally{s&&await disposeHook(a)}}async function resolveAnsweredCommand(e,t){if(t.taskId!==e.taskId)return;let n=new Set(e.inputRequests.flatMap(e=>{let t=readTaskInputRequestId(e);return t===void 0?[]:[t]})),r=t.inputResponses.map(e=>e.requestId).filter(e=>n.has(e));return r.length===0?void 0:await deliverTaskInputResponsesStep({answer:t,requestIds:r})===`delivered`?{kind:`answered`,requestIds:r}:void 0}export{taskRunWorkflow};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RuntimeAgentHandleAction } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
/** Resolves the persistent agent identity attached to one delegated task. */
|
|
3
|
+
export declare function describeTaskAgent(input: {
|
|
4
|
+
readonly action: RuntimeAgentHandleAction;
|
|
5
|
+
readonly agentId?: string;
|
|
6
|
+
readonly parentSessionId: string;
|
|
7
|
+
readonly parentTurnId: string;
|
|
8
|
+
}): {
|
|
9
|
+
readonly agentId: string;
|
|
10
|
+
readonly callId: string;
|
|
11
|
+
readonly mode: "local" | "remote";
|
|
12
|
+
readonly name: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mintStartOperation}from"#execution/dispatch-start-operation.js";function describeTaskAgent(e){let{action:t}=e,n=t.kind===`remote-agent-call`?t.remoteAgentName:t.subagentName;return{agentId:e.agentId??mintStartOperation({callId:t.callId,name:n,nodeId:t.nodeId,parentSessionId:e.parentSessionId,parentTurnId:e.parentTurnId}).identity.id,callId:t.callId,mode:t.kind===`remote-agent-call`?`remote`:`local`,name:n}}export{describeTaskAgent};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HarnessSession } from "#harness/types.js";
|
|
2
|
+
import { type AgentView } from "#harness/handles/prompt.js";
|
|
3
|
+
/** Derives model-visible task-agent availability from authoritative task views. */
|
|
4
|
+
export declare function readTaskAgentViews(session: HarnessSession): Promise<readonly AgentView[]>;
|
|
5
|
+
/** Appends the changed task-agent projection before the next model call. */
|
|
6
|
+
export declare function appendTaskAgentAnnouncement(session: HarnessSession): Promise<HarnessSession>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatAgentStatus,getAgentHandleStore}from"#harness/handles/store.js";import{getSessionTaskIndex}from"#tasks/session-index.js";import{resolveAgentsAnnouncement}from"#harness/handles/prompt.js";import{readTaskViews}from"#execution/tasks/parent/control-shared.js";async function readTaskAgentViews(r){let a=(getAgentHandleStore(r.state)?.handles??[]).filter(e=>e.phase===`addressed`);if(a.length===0)return[];let o=await readTaskViews(getSessionTaskIndex(r.state)),s=new Map;for(let e of o){let t=s.get(e.metadata.agentId)??[];s.set(e.metadata.agentId,[...t,e])}return a.map(t=>{let n=s.get(t.identity.id)??[],r=n.filter(e=>e.status===`working`||e.status===`input_required`);if(r.length>1)throw Error(`Agent "${t.identity.id}" has more than one nonterminal task.`);let i=r[0];if(i!==void 0){let e=i.status===`input_required`?`input_required`:`working`;return{availability:`busy`,id:t.identity.id,name:t.identity.name,taskId:i.taskId,taskStatus:e}}let a=n.at(-1);return{availability:`available`,id:t.identity.id,name:t.identity.name,statusLine:a?.lastOutput===void 0?void 0:formatAgentStatus(a.lastOutput.data)}})}async function appendTaskAgentAnnouncement(e){let n=resolveAgentsAnnouncement({agentViews:await readTaskAgentViews(e),messages:e.history,store:getAgentHandleStore(e.state)});return n===void 0?e:{...e,history:[...e.history,{content:n,role:`user`}]}}export{appendTaskAgentAnnouncement,readTaskAgentViews};
|