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
|
@@ -28,3 +28,8 @@ export declare function resolveWorkflowCallbackBaseUrl(metadataUrl: string): str
|
|
|
28
28
|
* `new URL(path, base)` would drop for absolute paths.
|
|
29
29
|
*/
|
|
30
30
|
export declare function createWorkflowCallbackUrl(baseUrl: string, callbackPath: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Builds a callback to a remote task child without disclosing this deployment's
|
|
33
|
+
* protection bypass secret to an authored external origin.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createRemoteTaskInputCallbackUrl(baseUrl: string, callbackPath: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_PUBLIC_ROUTE_PREFIX_ENV,normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";function resolveVercelProductionCallbackBaseUrl(){return process.env.VERCEL_ENV===`production`&&process.env.VERCEL_PROJECT_PRODUCTION_URL?`https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`:null}function resolveWorkflowCallbackBaseUrl(n){let r=process.env.WORKFLOW_LOCAL_BASE_URL?.trim()||void 0,i=(resolveVercelProductionCallbackBaseUrl()??r??n).replace(/\/$/,``),a=normalizePublicRoutePrefix(process.env[EVE_PUBLIC_ROUTE_PREFIX_ENV]);return a===void 0?i:`${i}${a}`}function createWorkflowCallbackUrl(e,t){let
|
|
1
|
+
import{EVE_PUBLIC_ROUTE_PREFIX_ENV,normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";const VERCEL_PROTECTION_BYPASS_QUERY=`x-vercel-protection-bypass`,VERCEL_CALLBACK_HOST_ENVS=[`VERCEL_URL`,`VERCEL_BRANCH_URL`,`VERCEL_PROJECT_PRODUCTION_URL`];function resolveVercelProductionCallbackBaseUrl(){return process.env.VERCEL_ENV===`production`&&process.env.VERCEL_PROJECT_PRODUCTION_URL?`https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`:null}function resolveWorkflowCallbackBaseUrl(n){let r=process.env.WORKFLOW_LOCAL_BASE_URL?.trim()||void 0,i=(resolveVercelProductionCallbackBaseUrl()??r??n).replace(/\/$/,``),a=normalizePublicRoutePrefix(process.env[EVE_PUBLIC_ROUTE_PREFIX_ENV]);return a===void 0?i:`${i}${a}`}function createWorkflowCallbackUrl(e,t){let r=new URL(`${e.replace(/\/$/,``)}${t}`),i=process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();return i&&r.searchParams.set(VERCEL_PROTECTION_BYPASS_QUERY,i),r.toString()}function createRemoteTaskInputCallbackUrl(e,t){let i=new URL(`${e.replace(/\/$/,``)}${t}`),a=process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim(),o=VERCEL_CALLBACK_HOST_ENVS.some(e=>process.env[e]?.trim().toLowerCase()===i.hostname.toLowerCase());return a&&i.protocol===`https:`&&o&&i.searchParams.set(VERCEL_PROTECTION_BYPASS_QUERY,a),i.toString()}export{createRemoteTaskInputCallbackUrl,createWorkflowCallbackUrl,resolveVercelProductionCallbackBaseUrl,resolveWorkflowCallbackBaseUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionCommandHookToken}from"#execution/session-command-token.js";import{readSerializedSubagentDepth}from"#harness/subagent-depth.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{notifyDelegatedParentStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#execution/delegated-parent-notification.js";import{createDelegatedSubagentErrorResult,createDelegatedSubagentSuccessResult}from"#execution/delegated-parent-result.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{fireSessionCallbackStep}from"#execution/session-callback-step.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";async function workflowEntry(e){"use workflow";let{workflowRunId:s,workflowStartedAt:f}=getWorkflowMetadata(),p=e.serializedContext[`eve.continuationToken`]||``,m=e.serializedContext[`eve.mode`],h=e.serializedContext[`eve.capabilities`],g=e.serializedContext[`eve.bundle`];e.serializedContext[`eve.sessionId`]=s;let _=getWritable(),v={caller:void 0,callerResolved:!1,lastSessionState:void 0};try{let i=readRootSessionId(e.serializedContext),a=readSerializedSubagentDepth(e.serializedContext),o=e.serializedContext[`eve.dynamicSubagentAgentConfig`],{state:c}=await createSessionStep({compiledArtifactsSource:g.source,continuationToken:p,dynamicSubagentAgentConfig:o,inheritedLimits:e.limits,nodeId:g.nodeId,outputSchema:e.input.outputSchema,rootSessionId:i,sessionId:s,subagentDepth:a});v.lastSessionState=c,v.caller=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext}),v.callerResolved=!0;let l=await runDriverLoop({capabilities:h,driverWritable:_,initialInput:{deliveryMetadata:e.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...e.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[{message:e.input.message,context:e.input.context,outputSchema:e.input.outputSchema}],requestId:readChannelRequestId(e.serializedContext)},crashCleanupState:v,mode:m,serializedContext:e.serializedContext,sessionState:c,sessionTimeoutDeadline:e.sessionTimeoutMs===!1?void 0:new Date(f.getTime()+(e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS))});return l.kind===`result`?l.result:await finalizeExpiredSession({caller:v.caller,driverWritable:_,mode:m,serializedContext:l.serializedContext,sessionState:l.sessionState})}catch(t){throw v.lastSessionState!==void 0&&await terminateChildSessionsStep({sessionState:v.lastSessionState}),await emitTerminalSessionFailureStep({error:normalizeSerializableError(t),parentWritable:_,serializedContext:e.serializedContext}),m===`task`?(await fireSessionCallbackStep({error:normalizeSerializableError(t),serializedContext:e.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(e.serializedContext,t),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:await resolveCallerForCrash(v,e.serializedContext),lifecycle:`terminal`,sessionId:s,settled:{isError:!0,output:t}}),createSafeOuterWorkflowError()}}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runDriverLoop(t){let n=new Map,nextParkedActivity=async e=>{let r=e.sessionState,s=new Set(e.expectedAttemptIds);for(let e of n.keys())s.has(e)||n.delete(e);for(;;){if(s.size>0&&[...s].every(e=>n.has(e))){let e=[...s].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e,sessionState:r}}let e=await nextTurnDelivery({awaitAuthorizationCallbacks:s.size>0,bufferedDeliveries:i,bufferedSessionControls:a,commandInbox:o,deferDeliveries:t.mode===`task`&&s.size>0,driverWritable:t.driverWritable,sessionState:r});if(r=e.sessionState,e.kind!==`authorization`)return e;for(let t of e.payloads){let e=t.authorizationCallback;typeof e?.attemptId==`string`&&s.has(e.attemptId)&&!n.has(e.attemptId)&&n.set(e.attemptId,t)}if(e.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e,sessionState:r}}}},r=0,nextTurnControlToken=()=>`${t.sessionState.sessionId}:turn-control:${String(r++)}`,i=[],a=[],o=createSessionCommandInbox(),c=sessionCommandHookToken(t.sessionState.sessionId);await o.claimStable(c),await o.claimAuthorization(`${t.sessionState.sessionId}:auth`);let u=t.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:t.sessionTimeoutDeadline,token:c}),d,runTurn=async e=>{let n=await dispatchAndAwaitTurn({bufferedDeliveries:i,bufferedSessionControls:a,capabilities:t.capabilities,commandInbox:o,controlToken:nextTurnControlToken(),delivery:e.delivery,mode:t.mode,parentWritable:t.driverWritable,serializedContext:e.serializedContext,sessionState:e.sessionState});return await d?.(),d=n.dispose,n.action};try{t.sessionState.continuationToken&&await o.rekeyContinuation(t.sessionState.continuationToken),await u?.start();let e=await runTurn({delivery:t.initialInput,serializedContext:t.serializedContext,sessionState:t.sessionState});for(t.crashCleanupState.lastSessionState=e.sessionState;;){if(e.kind===`done`)return{kind:`result`,result:await finalizeDone({action:e,caller:t.crashCleanupState.caller,mode:t.mode})};if(e.kind!==`park`)throw Error(`Driver received unexpected turn action "${e.kind}".`);if(e.cancelled===!0){let n=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:e.serializedContext,sessionState:e.sessionState});e={...e,serializedContext:n.serializedContext,sessionState:n.sessionState},t.crashCleanupState.lastSessionState=e.sessionState}e.sessionState.continuationToken&&await o.rekeyContinuation(e.sessionState.continuationToken);let n=e.settled;e.cancelled!==!0&&n!==void 0?(await notifyTurnCallerStep({caller:t.crashCleanupState.caller,lifecycle:`parked`,sessionId:e.sessionState.sessionId,settled:n}),t.crashCleanupState.caller=void 0):e.cancelled===!0&&(t.crashCleanupState.caller=void 0);let r=await nextParkedActivity({expectedAttemptIds:e.authorizationAttemptIds??[],sessionState:e.sessionState});if(e={...e,sessionState:r.sessionState},t.crashCleanupState.lastSessionState=e.sessionState,r.kind===`authorization-resume`){e=await runTurn({delivery:{kind:`deliver`,payloads:r.payloads},serializedContext:e.serializedContext,sessionState:e.sessionState}),t.crashCleanupState.lastSessionState=e.sessionState;continue}if(r.kind===`expired`)return{kind:`expired`,serializedContext:e.serializedContext,sessionState:e.sessionState};if(r.kind===`reset`)return await terminateChildSessionsStep({sessionState:e.sessionState}),{kind:`result`,result:{output:``}};if(r.kind===`clear`||r.kind===`compact`){e=await runTurn({delivery:{kind:r.kind},serializedContext:e.serializedContext,sessionState:e.sessionState}),t.crashCleanupState.lastSessionState=e.sessionState;continue}if(r.kind===`closed`)return{kind:`result`,result:{output:``}};if(r.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:e.serializedContext,sessionState:e.sessionState});let n=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:e.serializedContext,sessionState:e.sessionState});e={...e,serializedContext:n.serializedContext,sessionState:n.sessionState,settled:void 0},t.crashCleanupState.caller=void 0,t.crashCleanupState.lastSessionState=e.sessionState;continue}r.deliver.caller!==void 0&&(t.crashCleanupState.caller=r.deliver.caller),e=await runTurn({delivery:{...r.remainder,kind:`deliver`},serializedContext:e.serializedContext,sessionState:e.sessionState}),t.crashCleanupState.lastSessionState=e.sessionState}}finally{await d?.(),await u?.dispose(),await o.dispose()}}async function finalizeExpiredSession(e){return await terminateChildSessionsStep({sessionState:e.sessionState}),await emitTerminalSessionCompletionStep({parentWritable:e.driverWritable,serializedContext:e.serializedContext}),e.mode===`task`?(await fireSessionCallbackStep({output:``,serializedContext:e.serializedContext,status:`completed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentSuccessResult(e.serializedContext,``),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.sessionState.sessionId,settled:{output:``}}),{output:``}}async function finalizeDone(e){let{output:t,serializedContext:n}=e.action,r=e.action.isError===!0;if(await terminateChildSessionsStep({sessionState:e.action.sessionState}),e.mode===`task`)await fireSessionCallbackStep({error:r?t:void 0,output:r?void 0:t,serializedContext:n,status:r?`failed`:`completed`,usage:r?void 0:e.action.usage}),await notifyDelegatedParentStep({result:r?createDelegatedSubagentErrorResult(n,t):createDelegatedSubagentSuccessResult(n,t),serializedContext:n,usage:r?void 0:e.action.usage});else{let n={output:t,usage:e.action.usageDelta};r&&(n.isError=!0),await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.action.sessionState.sessionId,settled:n})}return{output:t}}export{workflowEntry};
|
|
1
|
+
import{sessionCommandHookToken}from"#execution/session-command-token.js";import{readSerializedSubagentDepth}from"#harness/subagent-depth.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{activeTurnId}from"#harness/active-turn-id.js";import{fireSessionCallbackStep}from"#execution/session-callback-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTaskTurnStartedStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#execution/delegated-parent-notification.js";import{createDelegatedSubagentErrorResult,createDelegatedSubagentSuccessResult}from"#execution/delegated-parent-result.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";async function workflowEntry(e){"use workflow";let{workflowRunId:o,workflowStartedAt:s}=getWorkflowMetadata(),u=e.serializedContext[`eve.continuationToken`]||``,d=e.serializedContext[`eve.mode`],f=e.serializedContext[`eve.capabilities`],p=e.serializedContext[`eve.bundle`];e.serializedContext[`eve.sessionId`]=o;let h=getWritable(),v={caller:void 0,callerResolved:!1,lastSessionState:void 0};try{let i=readRootSessionId(e.serializedContext),a=readSerializedSubagentDepth(e.serializedContext),c=e.serializedContext[`eve.dynamicSubagentAgentConfig`],{state:l}=await createSessionStep({compiledArtifactsSource:p.source,continuationToken:u,dynamicSubagentAgentConfig:c,inheritedLimits:e.limits,nodeId:p.nodeId,outputSchema:e.input.outputSchema,rootSessionId:i,sessionId:o,subagentDepth:a});v.lastSessionState=l,v.caller=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext}),v.callerResolved=!0;let m=await runDriverLoop({capabilities:f,driverWritable:h,initialInput:{deliveryMetadata:e.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...e.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[{message:e.input.message,context:e.input.context,outputSchema:e.input.outputSchema}],requestId:readChannelRequestId(e.serializedContext)},crashCleanupState:v,mode:d,serializedContext:e.serializedContext,sessionState:l,sessionTimeoutDeadline:e.sessionTimeoutMs===!1?void 0:new Date(s.getTime()+(e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS))});return m.kind===`result`?m.result:await finalizeExpiredSession({caller:v.caller,driverWritable:h,mode:d,serializedContext:m.serializedContext,sessionState:m.sessionState})}catch(t){throw v.lastSessionState!==void 0&&await terminateChildSessionsStep({serializedContext:e.serializedContext,sessionState:v.lastSessionState}),await emitTerminalSessionFailureStep({error:normalizeSerializableError(t),parentWritable:h,serializedContext:e.serializedContext}),d===`task`?(await fireSessionCallbackStep({error:normalizeSerializableError(t),serializedContext:e.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(e.serializedContext,t),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:await resolveCallerForCrash(v,e.serializedContext),lifecycle:`terminal`,sessionId:o,settled:{isError:!0,output:t}}),createSafeOuterWorkflowError()}}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runDriverLoop(t){let n=new Map,nextParkedActivity=async e=>{let r=new Set(e.expectedAttemptIds);for(let e of n.keys())r.has(e)||n.delete(e);for(;;){if(r.size>0&&[...r].every(e=>n.has(e))){let e=[...r].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e}}let e=await nextTurnDelivery({awaitAuthorizationCallbacks:r.size>0,bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:c,commandInbox:m,deferDeliveries:t.mode===`task`&&r.size>0,driverWritable:t.driverWritable,seenTaskDeliveries:l,stateCursor:v});if(e.kind!==`authorization`)return e;for(let t of e.payloads){let e=t.authorizationCallback;typeof e?.attemptId==`string`&&r.has(e.attemptId)&&!n.has(e.attemptId)&&n.set(e.attemptId,t)}if(e.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e}}}},r=0,nextTurnControlToken=()=>`${t.sessionState.sessionId}:turn-control:${String(r++)}`,i=[],a=[],c=new Set,l=new Set,m=createSessionCommandInbox(),g=sessionCommandHookToken(t.sessionState.sessionId);await m.claimStable(g),await m.claimAuthorization(`${t.sessionState.sessionId}:auth`);let _=t.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:t.sessionTimeoutDeadline,token:g}),v=new SessionStateCursor({serializedContext:t.serializedContext,sessionState:t.sessionState}),y,runTurn=async e=>{let n=t.crashCleanupState.caller;n?.taskId!==void 0&&(l.add(n.taskId),await notifyTaskTurnStartedStep({caller:n,childSessionId:v.sessionState.sessionId,childTurnId:activeTurnId(v.sessionState.emissionState)}));let r=await bindTurnCallerContextStep({caller:n,serializedContext:v.serializedContext}),o=await dispatchAndAwaitTurn({bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:c,capabilities:t.capabilities,commandInbox:m,controlToken:nextTurnControlToken(),delivery:e,mode:t.mode,parentWritable:t.driverWritable,serializedContext:r,seenTaskDeliveries:l,sessionState:v.sessionState});return await y?.(),y=o.dispose,v.adoptState(o.action),t.crashCleanupState.lastSessionState=v.sessionState,o.action};try{if(t.sessionState.continuationToken)try{await m.rekeyContinuation(t.sessionState.continuationToken)}catch(e){if(!isHookConflictError(e))throw e;return{kind:`result`,result:{output:``}}}await _?.start();let e=await runTurn(t.initialInput);for(;;){if(e.kind===`done`)return{kind:`result`,result:await finalizeDone({action:e,caller:t.crashCleanupState.caller,mode:t.mode})};if(e.kind!==`park`)throw Error(`Driver received unexpected turn action "${e.kind}".`);if(e.cancelled===!0){let e=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:v.serializedContext,sessionState:v.sessionState});v.adoptState(e);let n={caller:t.crashCleanupState.caller,sessionId:v.sessionState.sessionId};await notifyCancelledTaskCallerStep(e.usage===void 0?n:{...n,usage:e.usage}),t.crashCleanupState.lastSessionState=v.sessionState}v.sessionState.continuationToken&&await m.rekeyContinuation(v.sessionState.continuationToken);let n=e.settled;e.cancelled!==!0&&n!==void 0?(await notifyTurnCallerStep({caller:t.crashCleanupState.caller,lifecycle:`parked`,sessionId:v.sessionState.sessionId,settled:n}),t.crashCleanupState.caller=void 0):e.cancelled===!0&&(t.crashCleanupState.caller=void 0);let r=await nextParkedActivity({expectedAttemptIds:e.authorizationAttemptIds??[]});if(t.crashCleanupState.lastSessionState=v.sessionState,r.kind===`authorization-resume`){e=await runTurn({kind:`deliver`,payloads:r.payloads});continue}if(r.kind===`expired`)return{kind:`expired`,serializedContext:v.serializedContext,sessionState:v.sessionState};if(r.kind===`reset`)return await terminateChildSessionsStep({serializedContext:v.serializedContext,sessionState:v.sessionState}),{kind:`result`,result:{output:``}};if(r.kind===`clear`||r.kind===`compact`){e=await runTurn({kind:r.kind});continue}if(r.kind===`closed`)return{kind:`result`,result:{output:``}};if(r.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:v.serializedContext,sessionState:v.sessionState});let n=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:v.serializedContext,sessionState:v.sessionState});v.adoptState(n),e={...e,settled:void 0},t.crashCleanupState.caller=void 0,t.crashCleanupState.lastSessionState=v.sessionState;continue}r.delivery.caller!==void 0&&(t.crashCleanupState.caller=r.delivery.caller),e=await runTurn(r.delivery)}}finally{await y?.(),await _?.dispose(),await m.dispose()}}async function finalizeExpiredSession(e){return await terminateChildSessionsStep({serializedContext:e.serializedContext,sessionState:e.sessionState}),await emitTerminalSessionCompletionStep({parentWritable:e.driverWritable,serializedContext:e.serializedContext}),e.mode===`task`?(await fireSessionCallbackStep({output:``,serializedContext:e.serializedContext,status:`completed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentSuccessResult(e.serializedContext,``),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.sessionState.sessionId,settled:{output:``}}),{output:``}}async function finalizeDone(e){let{output:t,serializedContext:n}=e.action,r=e.action.isError===!0;if(await terminateChildSessionsStep({serializedContext:n,sessionState:e.action.sessionState}),e.mode===`task`)await fireSessionCallbackStep({error:r?t:void 0,output:r?void 0:t,serializedContext:n,status:r?`failed`:`completed`,usage:e.action.usage}),await notifyDelegatedParentStep({result:r?createDelegatedSubagentErrorResult(n,t):createDelegatedSubagentSuccessResult(n,t),serializedContext:n,usage:e.action.usage});else{let n={output:t,usage:e.action.usageDelta};r&&(n.isError=!0),await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.action.sessionState.sessionId,settled:n})}return{output:t}}export{workflowEntry};
|
|
@@ -14,6 +14,9 @@ export declare const LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE = "deploymentId 'late
|
|
|
14
14
|
* template) read this single set so they cannot drift.
|
|
15
15
|
*/
|
|
16
16
|
export declare const STABLE_WORKFLOW_NAMES: ReadonlySet<string>;
|
|
17
|
+
interface WorkflowHookRecord {
|
|
18
|
+
readonly runId: string;
|
|
19
|
+
}
|
|
17
20
|
/**
|
|
18
21
|
* Stable workflow reference used by `start()` to locate the workflow
|
|
19
22
|
* entrypoint registered by the Workflow DevKit builder. The id omits
|
|
@@ -37,6 +40,10 @@ export declare const turnWorkflowReference: {
|
|
|
37
40
|
export declare const sessionTimeoutWorkflowReference: {
|
|
38
41
|
workflowId: string;
|
|
39
42
|
};
|
|
43
|
+
/** Stable workflow reference for durable task runs (`experimental.tasks`). */
|
|
44
|
+
export declare const taskRunWorkflowReference: {
|
|
45
|
+
workflowId: string;
|
|
46
|
+
};
|
|
40
47
|
/**
|
|
41
48
|
* Creates a workflow-backed runtime whose long-lived driver owns the
|
|
42
49
|
* event stream and dispatches each turn as a child workflow run.
|
|
@@ -48,8 +55,10 @@ export declare function createWorkflowRuntime(config: {
|
|
|
48
55
|
}): Runtime;
|
|
49
56
|
/** Requests cancellation through a session's stable command inbox. */
|
|
50
57
|
export declare function requestWorkflowTurnCancellation(input: CancelTurnInput): Promise<CancelTurnResult>;
|
|
58
|
+
export declare function waitForCommandHookOwner(token: string): Promise<WorkflowHookRecord>;
|
|
51
59
|
/**
|
|
52
60
|
* Starts a workflow on the latest deployment when latest routing applies,
|
|
53
61
|
* while preserving local/dev worlds that do not implement latest routing.
|
|
54
62
|
*/
|
|
55
63
|
export declare function startWorkflowPreferLatest<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, options?: StartOptionsWithoutDeploymentId): Promise<Run<unknown> | Run<TResult>>;
|
|
64
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{RuntimeSessionOwnershipConflictError}from"#execution/runtime-errors.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{serializeContext}from"#context/serialize.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{getHookByToken,getRun,resumeHook,start}from"#internal/workflow/runtime.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{sendCommandToDelivery}from"#execution/session-command-wire.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";const WORKFLOW_ENTRY_NAME=`workflowEntry`,TURN_WORKFLOW_NAME=`turnWorkflow`,SESSION_TIMEOUT_WORKFLOW_NAME=`sessionTimeoutWorkflow`,EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),COMMAND_HOOK_READY_TIMEOUT_MS=3e4,LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE=`deploymentId 'latest' requires a World that implements resolveLatestDeploymentId()`,STABLE_WORKFLOW_NAMES=new Set([WORKFLOW_ENTRY_NAME,TURN_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME]),STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},turnWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TURN_WORKFLOW_NAME}`},sessionTimeoutWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${SESSION_TIMEOUT_WORKFLOW_NAME}`};function createWorkflowRuntime(e){return{async createSession(i){let a=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId}),o=buildRunContext({bundle:a,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,run:i}),s=resolveEffectiveAgentRuntime(a,o),c=serializeContext(o),l=readParentLineage(c),u=s.limits?.sessionTimeoutMs,d={input:i.input,limits:i.limits,serializedContext:c};u!==void 0&&(d.sessionTimeoutMs=u);let f=l.sessionId===void 0?buildSessionAttributes({inputMessage:i.title??i.input.message,serializedContext:c}):buildSubagentRootAttributes({identity:{nodeId:a.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:l.callId,parentSessionId:l.sessionId,parentTurnId:l.turnId,rootSessionId:l.rootSessionId??l.sessionId,serializedContext:c}),p;try{p=await startWorkflowPreferLatest(workflowEntryReference,[d],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(f)})}catch(e){throw logError(log,`failed to start workflow run`,e,{continuationToken:i.continuationToken}),e}if(
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{RuntimeSessionOwnershipConflictError}from"#execution/runtime-errors.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{serializeContext}from"#context/serialize.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{getHookByToken,getRun,resumeHook,start}from"#internal/workflow/runtime.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{sendCommandToDelivery}from"#execution/session-command-wire.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";import{buildInvocationAttributes}from"#internal/invocation/metadata.js";const WORKFLOW_ENTRY_NAME=`workflowEntry`,TURN_WORKFLOW_NAME=`turnWorkflow`,SESSION_TIMEOUT_WORKFLOW_NAME=`sessionTimeoutWorkflow`,TASK_RUN_WORKFLOW_NAME=`taskRunWorkflow`,EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),COMMAND_HOOK_READY_TIMEOUT_MS=3e4,LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE=`deploymentId 'latest' requires a World that implements resolveLatestDeploymentId()`,STABLE_WORKFLOW_NAMES=new Set([WORKFLOW_ENTRY_NAME,TURN_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,TASK_RUN_WORKFLOW_NAME]),STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},turnWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TURN_WORKFLOW_NAME}`},sessionTimeoutWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${SESSION_TIMEOUT_WORKFLOW_NAME}`},taskRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TASK_RUN_WORKFLOW_NAME}`};function createWorkflowRuntime(e){return{async createSession(i){let a=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId}),o=buildRunContext({bundle:a,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,run:i}),s=resolveEffectiveAgentRuntime(a,o),c=serializeContext(o),l=readParentLineage(c),u=s.limits?.sessionTimeoutMs,d={input:i.input,limits:i.limits,serializedContext:c};u!==void 0&&(d.sessionTimeoutMs=u);let f={...l.sessionId===void 0?buildSessionAttributes({inputMessage:i.title??i.input.message,serializedContext:c}):buildSubagentRootAttributes({identity:{nodeId:a.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:l.callId,parentSessionId:l.sessionId,parentTurnId:l.turnId,rootSessionId:l.rootSessionId??l.sessionId,serializedContext:c}),...i.externalInvocation===void 0?{}:buildInvocationAttributes(i.externalInvocation)},p;try{p=await startWorkflowPreferLatest(workflowEntryReference,[d],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(f)})}catch(e){throw logError(log,`failed to start workflow run`,e,{continuationToken:i.continuationToken}),e}if(i.continuationToken){let e=await waitForCommandHookOwner(i.continuationToken);if(e.runId!==p.runId)throw new RuntimeSessionOwnershipConflictError({continuationToken:i.continuationToken,ownerSessionId:e.runId,sessionId:p.runId})}await waitForOwnedCommandHook(sessionCommandHookToken(p.runId),p.runId);let m,getEvents=()=>(m??=parseNdjsonStream(()=>getRun(p.runId).getReadable()),m);return{get events(){return getEvents()},sessionId:p.runId}},async dispatchContinuation(e){return await dispatchWorkflowCommand(e.continuationToken,e.command)},async dispatchSession(e){return await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),e.command)},async getEventStream(e,t){return parseNdjsonStream(()=>getRun(e).getReadable({startIndex:t?.startIndex}))},async getStreamTailIndex(e){let t=getRun(e).getReadable();try{return await t.getTailIndex()}finally{await t.cancel().catch(()=>{})}},async resolveContinuation(e){try{return{sessionId:(await getHookByToken(e)).runId}}catch(n){if(HookNotFoundError.is(n))return;throw logError(log,`failed to resolve session by continuation token`,n,{continuationToken:e}),n}}}}async function dispatchWorkflowCommand(e,n){let i;try{i=normalizeWorkflowHook(await resumeHook(e,sessionHookPayload(n)))}catch(r){if(isInactiveCommandTarget(r))return inactiveCommandResult(n);throw logError(log,`failed to dispatch session command`,r,{command:n.kind,token:e}),r}return n.kind===`reset`&&await waitForCommandHookRelease(sessionCommandHookToken(i.runId),i.runId),activeCommandResult(n,i.runId)}function sessionHookPayload(e){return e.kind===`send`?sendCommandToDelivery(e):e}function activeCommandResult(e,t){return e.kind===`reset`?{previousSessionId:t,status:`reset`}:(e.kind,{sessionId:t,status:`accepted`})}function inactiveCommandResult(e){return e.kind===`send`?{status:`session_not_active`}:e.kind===`cancel`?{status:`no_active_turn`}:{status:`no_active_session`}}async function requestWorkflowTurnCancellation(e){let t={kind:`cancel`};return e.taskId!==void 0&&(t.taskId=e.taskId),e.turnId!==void 0&&(t.turnId=e.turnId),await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),t)}function isInactiveCommandTarget(e){if(HookNotFoundError.is(e))return!0;for(let t of walkCauseChain(e))if(WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}async function waitForOwnedCommandHook(e,t){let r=await waitForCommandHookOwner(e);if(r.runId!==t)throw new RuntimeSessionOwnershipConflictError({continuationToken:e,ownerSessionId:r.runId,sessionId:t})}async function waitForCommandHookOwner(e){let t=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;)try{return normalizeWorkflowHook(await getHookByToken(e))}catch(e){if(!HookNotFoundError.is(e)||Date.now()>=t)throw e;await new Promise(e=>setTimeout(e,20))}}async function waitForCommandHookRelease(e,t){let n=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;){try{if(normalizeWorkflowHook(await getHookByToken(e)).runId!==t)return}catch(e){if(HookNotFoundError.is(e))return;throw e}if(Date.now()>=n)throw Error(`Timed out waiting for session "${t}" to release its command inbox.`);await new Promise(e=>setTimeout(e,20))}}async function startWorkflowPreferLatest(e,t,n){if(!shouldRouteToLatestDeployment())return n===void 0?await start(e,t):await start(e,t,n);try{return await start(e,t,{...n,deploymentId:`latest`})}catch(r){if(!isLatestDeploymentUnsupportedError(r))throw r;return n===void 0?await start(e,t):await start(e,t,n)}}function shouldRouteToLatestDeployment(){return process.env.VERCEL_ENV===`production`||isEveDevEnvironment()}function isLatestDeploymentUnsupportedError(e){return e instanceof Error&&e.message.includes(`deploymentId 'latest' requires a World that implements resolveLatestDeploymentId()`)}function normalizeWorkflowHook(e){if(typeof e!=`object`||!e||!(`runId`in e))throw Error(`Workflow hook did not include a run id.`);let t=e.runId;if(typeof t!=`string`||t.length===0)throw Error(`Workflow hook did not include a run id.`);return{runId:t}}export{LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE,STABLE_WORKFLOW_NAMES,createWorkflowRuntime,requestWorkflowTurnCancellation,sessionTimeoutWorkflowReference,startWorkflowPreferLatest,taskRunWorkflowReference,turnWorkflowReference,waitForCommandHookOwner,workflowEntryReference};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SettledTurn } from "#harness/types.js";
|
|
2
2
|
import type { TokenUsage } from "#shared/token-usage.js";
|
|
3
|
-
import type { JsonObject } from "#shared/json.js";
|
|
4
|
-
import type { RunMode } from "#shared/run-mode.js";
|
|
5
3
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
6
4
|
import type { TurnStepInput } from "#execution/durable-session-migrations/turn-workflow.js";
|
|
7
5
|
/**
|
|
@@ -44,6 +42,12 @@ export type DurableStepResult = {
|
|
|
44
42
|
readonly hasPendingAuthorization: boolean;
|
|
45
43
|
readonly hasPendingInputBatch: boolean;
|
|
46
44
|
readonly pendingRuntimeActionKeys?: readonly string[];
|
|
45
|
+
/**
|
|
46
|
+
* Selects the dispatch step for `pendingRuntimeActionKeys`:
|
|
47
|
+
* `dispatchTaskStep` when the agent runs `experimental.tasks`,
|
|
48
|
+
* `dispatchRuntimeActionsStep` otherwise (including when absent).
|
|
49
|
+
*/
|
|
50
|
+
readonly tasksEnabled?: boolean;
|
|
47
51
|
readonly sleepDurationMs?: number;
|
|
48
52
|
readonly serializedContext: Record<string, unknown>;
|
|
49
53
|
readonly sessionState: DurableSessionState;
|
|
@@ -60,21 +64,3 @@ export type { TurnStepInput };
|
|
|
60
64
|
* Runs one atomic harness step inside a durable `"use step"` boundary.
|
|
61
65
|
*/
|
|
62
66
|
export declare function turnStep(rawInput: TurnStepInput): Promise<DurableStepResult>;
|
|
63
|
-
/**
|
|
64
|
-
* Resolves the single output schema in effect for this turn, decoupling schema
|
|
65
|
-
* enforcement from {@link RunMode}: downstream the harness reads
|
|
66
|
-
* `session.outputSchema` unconditionally and never re-derives it from mode.
|
|
67
|
-
*
|
|
68
|
-
* A run-scoped (client-supplied) schema on the turn's {@link StepInput} always
|
|
69
|
-
* wins. With no run-scoped schema, a task run adopts the agent's declared
|
|
70
|
-
* return schema — its function-output contract, which only applies when the
|
|
71
|
-
* agent is invoked as a function (subagent / schedule / job), i.e. task mode.
|
|
72
|
-
* A conversation run with no run-scoped schema enforces nothing. Continuation
|
|
73
|
-
* steps (no new `StepInput`) preserve whatever is already in effect.
|
|
74
|
-
*/
|
|
75
|
-
export declare function resolveEffectiveOutputSchema(input: {
|
|
76
|
-
readonly agentOutputSchema: JsonObject | undefined;
|
|
77
|
-
readonly input: StepInput | undefined;
|
|
78
|
-
readonly mode: RunMode;
|
|
79
|
-
readonly session: HarnessSession;
|
|
80
|
-
}): HarnessSession;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler,defaultDeliverResult}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ModeKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey}from"#context/keys.js";import{createAuthorizationCompletedEvent,createSessionStartedEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{contextStorage}from"#context/container.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{dispatchDynamicSubagentEvent,refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{coalesceTurnInputs}from"#harness/messages.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{getPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{preserveSerializedAgentTraceState}from"#tracing/agent-trace-context-store.js";import{activeTurnId}from"#harness/active-turn-id.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{getRuntimeActionKeysFromWorkflowInterrupt,isWorkflowRuntimeActionInterrupt}from"#harness/workflow-runtime-action-state.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{runStep}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{hasPendingInputBatch}from"#harness/input-requests.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{getRuntimeActionRequestKey}from"#runtime/actions/keys.js";import{dispatchDynamicInstructionEvent,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchDynamicToolEvent,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{channelDeliveryErrorCode,instrumentChannelDelivery}from"#harness/channel-delivery-instrumentation.js";import{preserveSerializedInstrumentationState}from"#harness/instrumentation/state.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{readTurnSleepDurationMs}from"#harness/turn-sleep.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{prepareWorkflowPreambleTrace}from"#execution/workflow-trace-context.js";import{recordSubagentUsageSpans}from"#execution/subagent-usage-span.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";async function turnStep(a){"use step";let o=a,s=await readDurableSession(o.sessionState),c=await deserializeContext(o.serializedContext),l=c.require(ChannelKey),u=c.require(BundleKey),d=resolveEffectiveAgentRuntime(u,c);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&c.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let f=getPendingAuthorization(s.state),p;if(f&&o.input?.kind===`deliver`){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(f,o.input.payloads);if(o={...o,input:{...o.input,payloads:t}},e.length>0){let n=e.map(e=>e.result);c.set(PendingAuthorizationResultKey,n),s={...s,state:clearPendingAuthorization(s.state,n.map(e=>e.attemptId??e.name))},p=e,t.length===0&&(o={...o,input:void 0})}}o.input?.kind===`deliver`&&o.input.auth!==void 0&&c.set(AuthKey,o.input.auth??null);let m=hydrateDurableSession({compactionOverrides:{thresholdPercent:d.thresholdPercent},durable:s,turnAgent:d.turnAgent}),h=getInstrumentationRuntime(),g=getHarnessEmissionState(m.state);a.input?.kind===`deliver`&&await contextStorage.run(c,()=>instrumentChannelDelivery({agentName:u.turnAgent.id,ctx:c,delivery:a.input,hooks:h?.hooks,rootSessionId:m.rootSessionId??m.sessionId,sequence:g.sequence,sessionId:m.sessionId,turnId:activeTurnId(g)}));let failChannelDeliveries=async e=>{await contextStorage.run(c,()=>instrumentChannelDelivery({ctx:c,error:e,errorCode:channelDeliveryErrorCode(e),hooks:h?.hooks,includeTurn:!1,outcome:`failed`})),await h?.forceFlush()},_=buildAdapterContext(l,c),v;if(o.input?.kind===`deliver`){let e=[];try{for(let n of o.input.payloads){let r=l.deliver?await l.deliver(n,_):defaultDeliverResult(n);r!=null&&e.push(r)}}catch(e){throw await failChannelDeliveries(e),e}v=e.length===0?void 0:e.reduce(coalesceTurnInputs)}else o.input?.kind===`runtime-action-result`&&(recordSubagentUsageSpans(o.input.results),o.input.acceptedAtMsByCallId!==void 0&&c.set(RuntimeActionSettlementTimesKey,o.input.acceptedAtMsByCallId),v={runtimeActionResults:o.input.results});if(o.input?.kind===`deliver`&&setChannelContext(c,{...l,state:{..._.state}}),o.input?.kind===`deliver`&&v===void 0){await contextStorage.run(c,()=>instrumentChannelDelivery({ctx:c,hooks:h?.hooks,includeTurn:!1,outcome:`completed`})),await h?.forceFlush();let e=reconcileSessionContinuationToken(c,m),t=serializeContext(c),n=e===m?o.sessionState:createDurableSessionState({session:e});return{action:`park`,...derivePendingState(e),serializedContext:t,sessionState:n}}let y=u.hookRegistry,b=u.resolvedAgent.dynamicInstructionsResolvers??[],x=u.resolvedAgent.dynamicSkillResolvers??[],S=u.subagentRegistry.dynamicResolvers??[],C=u.resolvedAgent.config?.experimental?.subagentPersistentSessions===!0,w=u.resolvedAgent.dynamicToolResolvers??[],T={...u.graph.root,turnAgent:d.turnAgent},E=buildRuntimeIdentity(T);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(u.compiledArtifactsSource);if(!g.sessionStarted)c.set(SessionDynamicSubagentRuntimeRevisionKey,t),c.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=createSessionStartedEvent({runtime:E});await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:c,resolvers:S,event:e,messages:m.history,persistentSessions:C,runtimeRevision:t}),refreshDynamicSessionToolsForRuntimeRevision({ctx:c,resolvers:w,event:e,messages:m.history,runtimeRevision:t})])}}catch(e){throw await failChannelDeliveries(e),e}let D=o.parentWritable.getWriter(),emit=async t=>{let n=await callAdapterEventHandler(l,t,_);setChannelContext(c,{...l,state:{..._.state}});let r=stampMessageStreamEvent(n);return await D.write(encodeMessageStreamEvent(r)),r},handleEvent=async(e,t)=>{let n=await emit(e);await dispatchStreamEventHooks({ctx:c,registry:y,event:n}),n.type!==`step.started`&&await dispatchDynamicModelEvent({ctx:c,dynamicModel:d.turnAgent.dynamicModel,event:n,messages:t??[],scope:{moduleMap:u.moduleMap,nodeId:u.nodeId}}),await dispatchDynamicSubagentEvent({ctx:c,resolvers:S,event:n,messages:t??[],persistentSessions:C}),await dispatchDynamicToolEvent({ctx:c,resolvers:w,event:n,messages:t??[]}),await dispatchDynamicSkillEvent({ctx:c,resolvers:x,event:n,messages:t??[]}),await dispatchDynamicInstructionEvent({ctx:c,resolvers:b,event:n,messages:t??[]})},O=c.require(ModeKey),k;try{throwIfTurnAborted(o.abortSignal),k=await runStep(c,m,async e=>{let t=resolveEffectiveOutputSchema({agentOutputSchema:d.turnAgent.outputSchema,input:v,mode:O,session:e});if(p){let e=getHarnessEmissionState(t.state);if(isHarnessBetweenTurns(t)){prepareDynamicInstructionPreamble(c,t.history);let n=[],r=await prepareWorkflowPreambleTrace({ctx:c,emissionState:e,runtimeIdentity:E,session:t});try{e=await emitTurnPreamble(handleEvent,{},e,E,r)}finally{n=drainDynamicInstructionUserMessages(c),t={...t,history:[...t.history,...n]}}t=setHarnessEmissionState(t,e)}for(let{authorization:t,result:n}of p){let r=f?.challenges.find(e=>e.attemptId===n.attemptId)?.candidateId;await handleEvent(createAuthorizationCompletedEvent({authorization:t,candidateId:r,name:n.name,outcome:`authorized`,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId}))}}let n=c.get(CapabilitiesKey);return(async(e,t)=>{let r=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:d.thresholdPercent},session:e,turnAgent:d.turnAgent});return createExecutionNodeStep({abortSignal:o.abortSignal,capabilities:n,clearOnly:o.input?.kind===`clear`,compactOnly:o.input?.kind===`compact`,createRuntime:createWorkflowRuntime,handleEvent,mode:O,modelResolutionScope:{moduleMap:u.moduleMap,nodeId:u.nodeId},node:T,workflowMaxSubagents:r.workflowMaxSubagents})(r,t)})(t,v)})}catch(e){if(!isTurnCancellation(e))throw await failChannelDeliveries(e),e;D.releaseLock();let t=serializeContext(c);return{action:`cancelled`,serializedContext:preserveSerializedInstrumentationState(preserveSerializedAgentTraceState(o.serializedContext,t),t),sessionState:o.sessionState}}let A=reconcileSessionContinuationToken(c,k.session),j=serializeContext(c);k={...k,session:A};let M=createDurableSessionState({session:k.session}),N=readTurnSleepDurationMs(c),P=N===void 0?{}:{sleepDurationMs:N};if(k.next!==null&&typeof k.next==`object`&&`done`in k.next){if(O===`task`&&hasPendingInputBatch(k.session.state))throw D.releaseLock(),Error(`Task mode cannot complete while input requests remain pending.`);await D.close();let e=getTurnUsageState(k.session.state)?.session;return{action:`done`,output:k.next.output,isError:k.next.isError,...P,serializedContext:j,sessionState:M,usage:e===void 0?void 0:toUsage(e),usageDelta:takeSessionUsageDelta(k.session).delta}}if(k.next===null){D.releaseLock();let e=getPendingWorkflowInterrupt(k.session.state);if(e!==void 0&&isWorkflowRuntimeActionInterrupt(e.interrupt))return{action:`dispatch-workflow-runtime-actions`,pendingRuntimeActionKeys:getRuntimeActionKeysFromWorkflowInterrupt(e.interrupt),...P,serializedContext:j,sessionState:M};let t=derivePendingState(k.session);if(k.settledTurn!==void 0){let{delta:e,session:n}=takeSessionUsageDelta(k.session);return{action:`park`,...t,...P,serializedContext:j,sessionState:createDurableSessionState({session:n}),settled:{output:k.settledTurn.output,isError:k.settledTurn.isError,usage:e}}}return{action:`park`,...t,...P,serializedContext:j,sessionState:M}}return D.releaseLock(),{action:`continue`,...P,serializedContext:j,sessionState:M}}function derivePendingState(e){let t=getPendingRuntimeActionBatch(e.state),n=getPendingAuthorization(e.state),r={authorizationAttemptIds:n?.challenges.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),authorizationNames:n?.challenges.map(e=>e.name),hasPendingAuthorization:n!==void 0,hasPendingInputBatch:hasPendingInputBatch(e.state)};return t===void 0?r:{...r,pendingRuntimeActionKeys:t.actions.map(e=>getRuntimeActionRequestKey(e))}}function resolveEffectiveOutputSchema(e){let{agentOutputSchema:t,input:n,mode:r,session:i}=e;return n?.outputSchema===void 0?r===`task`&&i.outputSchema===void 0&&t!==void 0?{...i,outputSchema:t}:i:{...i,outputSchema:n.outputSchema}}export{resolveEffectiveOutputSchema,turnStep};
|
|
1
|
+
import{callAdapterEventHandler,defaultDeliverResult}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ModeKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey}from"#context/keys.js";import{createAuthorizationCompletedEvent,createSessionStartedEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{contextStorage}from"#context/container.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{dispatchDynamicSubagentEvent,refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{coalesceTurnInputs}from"#harness/messages.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{preserveSerializedAgentTraceState}from"#tracing/agent-trace-context-store.js";import{getPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{getRuntimeActionKeysFromWorkflowInterrupt,isWorkflowRuntimeActionInterrupt}from"#harness/workflow-runtime-action-state.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{runStep}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{activeTurnId}from"#harness/active-turn-id.js";import{hasPendingInputBatch}from"#harness/input-requests.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{getRuntimeActionRequestKey}from"#runtime/actions/keys.js";import{dispatchDynamicInstructionEvent,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchDynamicToolEvent,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{channelDeliveryErrorCode,instrumentChannelDelivery}from"#harness/channel-delivery-instrumentation.js";import{preserveSerializedInstrumentationState}from"#harness/instrumentation/state.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{readTurnSleepDurationMs}from"#harness/turn-sleep.js";import{forwardTaskEventToSessionCallback}from"#execution/task-event-callback.js";import{resolveEffectiveOutputSchema}from"#execution/effective-output-schema.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{appendTaskAgentAnnouncement}from"#execution/tasks/parent/agent-views.js";import{prepareWorkflowPreambleTrace}from"#execution/workflow-trace-context.js";import{recordSubagentUsageSpans}from"#execution/subagent-usage-span.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";async function turnStep(a){"use step";let o=a,s=await readDurableSession(o.sessionState),c=await deserializeContext(o.serializedContext),l=c.require(ChannelKey),u=c.require(BundleKey),d=u.resolvedAgent.config?.experimental?.tasks===!0,f=resolveEffectiveAgentRuntime(u,c);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&c.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let p=getPendingAuthorization(s.state),m;if(p&&o.input?.kind===`deliver`){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(p,o.input.payloads);if(o={...o,input:{...o.input,payloads:t}},e.length>0){let n=e.map(e=>e.result);c.set(PendingAuthorizationResultKey,n),s={...s,state:clearPendingAuthorization(s.state,n.map(e=>e.attemptId??e.name))},m=e,t.length===0&&(o={...o,input:void 0})}}o.input?.kind===`deliver`&&o.input.auth!==void 0&&c.set(AuthKey,o.input.auth??null);let h=hydrateDurableSession({compactionOverrides:{thresholdPercent:f.thresholdPercent},durable:s,turnAgent:f.turnAgent}),g=getInstrumentationRuntime(),_=getHarnessEmissionState(h.state);a.input?.kind===`deliver`&&await contextStorage.run(c,()=>instrumentChannelDelivery({agentName:u.turnAgent.id,ctx:c,delivery:a.input,hooks:g?.hooks,rootSessionId:h.rootSessionId??h.sessionId,sequence:_.sequence,sessionId:h.sessionId,turnId:activeTurnId(_)}));let failChannelDeliveries=async e=>{await contextStorage.run(c,()=>instrumentChannelDelivery({ctx:c,error:e,errorCode:channelDeliveryErrorCode(e),hooks:g?.hooks,includeTurn:!1,outcome:`failed`})),await g?.forceFlush()},v=buildAdapterContext(l,c),y;if(o.input?.kind===`deliver`){let e=[];try{for(let n of o.input.payloads){let r=l.deliver?await l.deliver(n,v):defaultDeliverResult(n);r!=null&&e.push(r)}}catch(e){throw await failChannelDeliveries(e),e}y=e.length===0?void 0:e.reduce(coalesceTurnInputs)}else o.input?.kind===`runtime-action-result`&&(recordSubagentUsageSpans(o.input.results),o.input.acceptedAtMsByCallId!==void 0&&c.set(RuntimeActionSettlementTimesKey,o.input.acceptedAtMsByCallId),y={runtimeActionResults:o.input.results});if(o.input?.kind===`deliver`&&setChannelContext(c,{...l,state:{...v.state}}),o.input?.kind===`deliver`&&y===void 0){await contextStorage.run(c,()=>instrumentChannelDelivery({ctx:c,hooks:g?.hooks,includeTurn:!1,outcome:`completed`})),await g?.forceFlush();let e=reconcileSessionContinuationToken(c,h),t=serializeContext(c),n=e===h?o.sessionState:createDurableSessionState({session:e});return{action:`park`,...derivePendingState(e),serializedContext:t,sessionState:n,tasksEnabled:d}}let b=u.hookRegistry,x=u.resolvedAgent.dynamicInstructionsResolvers??[],S=u.resolvedAgent.dynamicSkillResolvers??[],C=u.subagentRegistry.dynamicResolvers??[],w=d||u.resolvedAgent.config?.experimental?.subagentPersistentSessions===!0,T=u.resolvedAgent.dynamicToolResolvers??[],E={...u.graph.root,turnAgent:f.turnAgent},D=buildRuntimeIdentity(E);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(u.compiledArtifactsSource);if(!_.sessionStarted)c.set(SessionDynamicSubagentRuntimeRevisionKey,t),c.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=createSessionStartedEvent({runtime:D});await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:c,resolvers:C,event:e,messages:h.history,persistentSessions:w,runtimeRevision:t}),refreshDynamicSessionToolsForRuntimeRevision({ctx:c,resolvers:T,event:e,messages:h.history,runtimeRevision:t})])}}catch(e){throw await failChannelDeliveries(e),e}let O=o.parentWritable.getWriter(),emit=async t=>{let n=await callAdapterEventHandler(l,t,v);setChannelContext(c,{...l,state:{...v.state}});let r=stampMessageStreamEvent(n);return await O.write(encodeMessageStreamEvent(r)),r},handleEvent=async(e,t)=>{await forwardTaskEventToSessionCallback(c,e);let n=await emit(e);await dispatchStreamEventHooks({ctx:c,registry:b,event:n}),n.type!==`step.started`&&await dispatchDynamicModelEvent({ctx:c,dynamicModel:f.turnAgent.dynamicModel,event:n,messages:t??[],scope:{moduleMap:u.moduleMap,nodeId:u.nodeId}}),await dispatchDynamicSubagentEvent({ctx:c,resolvers:C,event:n,messages:t??[],persistentSessions:w}),await dispatchDynamicToolEvent({ctx:c,resolvers:T,event:n,messages:t??[]}),await dispatchDynamicSkillEvent({ctx:c,resolvers:S,event:n,messages:t??[]}),await dispatchDynamicInstructionEvent({ctx:c,resolvers:x,event:n,messages:t??[]})},k=c.require(ModeKey),A;try{throwIfTurnAborted(o.abortSignal),A=await runStep(c,h,async e=>{let t=resolveEffectiveOutputSchema({agentOutputSchema:f.turnAgent.outputSchema,input:y,mode:k,session:e});if(m){let e=getHarnessEmissionState(t.state);if(isHarnessBetweenTurns(t)){prepareDynamicInstructionPreamble(c,t.history);let n=[],r=await prepareWorkflowPreambleTrace({ctx:c,emissionState:e,runtimeIdentity:D,session:t});try{e=await emitTurnPreamble(handleEvent,{},e,D,r)}finally{n=drainDynamicInstructionUserMessages(c),t={...t,history:[...t.history,...n]}}t=setHarnessEmissionState(t,e)}for(let{authorization:t,result:n}of m){let r=p?.challenges.find(e=>e.attemptId===n.attemptId)?.candidateId;await handleEvent(createAuthorizationCompletedEvent({attemptId:n.attemptId,authorization:t,candidateId:r,name:n.name,outcome:`authorized`,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId}))}}let n=c.get(CapabilitiesKey);return(async(e,t)=>{let r=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:f.thresholdPercent},session:e,turnAgent:f.turnAgent}),i=d?await appendTaskAgentAnnouncement(r):r;return createExecutionNodeStep({abortSignal:o.abortSignal,capabilities:n,clearOnly:o.input?.kind===`clear`,compactOnly:o.input?.kind===`compact`,createRuntime:createWorkflowRuntime,handleEvent,mode:k,modelResolutionScope:{moduleMap:u.moduleMap,nodeId:u.nodeId},node:E,workflowMaxSubagents:r.workflowMaxSubagents})(i,t)})(t,y)})}catch(e){if(!isTurnCancellation(e))throw await failChannelDeliveries(e),e;O.releaseLock();let t=serializeContext(c);return{action:`cancelled`,serializedContext:preserveSerializedInstrumentationState(preserveSerializedAgentTraceState(preserveSerializedSessionDynamicModelSelection(o.serializedContext,t),t),t),sessionState:o.sessionState}}let j=reconcileSessionContinuationToken(c,A.session),M=serializeContext(c);A={...A,session:j};let N=createDurableSessionState({session:A.session}),P=readTurnSleepDurationMs(c),F=P===void 0?{}:{sleepDurationMs:P};if(A.next!==null&&typeof A.next==`object`&&`done`in A.next){if(k===`task`&&hasPendingInputBatch(A.session.state))throw O.releaseLock(),Error(`Task mode cannot complete while input requests remain pending.`);await O.close();let e=getTurnUsageState(A.session.state)?.session;return{action:`done`,output:A.next.output,isError:A.next.isError,...F,serializedContext:M,sessionState:N,usage:e===void 0?void 0:toUsage(e),usageDelta:takeSessionUsageDelta(A.session).delta}}if(A.next===null){O.releaseLock();let e=getPendingWorkflowInterrupt(A.session.state);if(e!==void 0&&isWorkflowRuntimeActionInterrupt(e.interrupt))return{action:`dispatch-workflow-runtime-actions`,pendingRuntimeActionKeys:getRuntimeActionKeysFromWorkflowInterrupt(e.interrupt),...F,serializedContext:M,sessionState:N};let t=derivePendingState(A.session);if(A.settledTurn!==void 0){let{delta:e,session:n}=takeSessionUsageDelta(A.session);return{action:`park`,...t,...F,serializedContext:M,sessionState:createDurableSessionState({session:n}),settled:{output:A.settledTurn.output,isError:A.settledTurn.isError,usage:e},tasksEnabled:d}}return{action:`park`,...t,...F,serializedContext:M,sessionState:N,tasksEnabled:d}}return O.releaseLock(),{action:`continue`,...F,serializedContext:M,sessionState:N}}function derivePendingState(e){let t=getPendingRuntimeActionBatch(e.state),n=getPendingAuthorization(e.state),r={authorizationAttemptIds:n?.challenges.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),authorizationNames:n?.challenges.map(e=>e.name),hasPendingAuthorization:n!==void 0,hasPendingInputBatch:hasPendingInputBatch(e.state)};return t===void 0?r:{...r,pendingRuntimeActionKeys:t.actions.map(e=>getRuntimeActionRequestKey(e))}}export{turnStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveSubagentDepth}from"#harness/subagent-depth.js";import{AGENT_TOOL_NAME}from"#runtime/framework-tools/agent.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{ensureWorkflowContinuationSecurity,getWorkflowContinuationSecurity}from"#harness/workflow-continuation-security.js";import{applyWorkflowTool}from"#harness/workflow-sandbox.js";function getAdvertisedTools(e){return`modelTools`in e?getAdvertisedModelTools(e):isToolDefinitionList(e.tools)?filterUnavailableDelegationToolDefinitions(e.tools,e.session):filterUnavailableDelegationToolMap(e.tools,e.session)}async function getAdvertisedModelTools(e){let t=filterUnavailableDelegationToolMap(e.tools,e.session);if(e.workflow===void 0)return{harnessTools:t,modelTools:e.modelTools,session:e.session};let n=filterWorkflowHostToolsForRootSession(t,e.session);if(n.size===0)return{harnessTools:t,modelTools:e.modelTools,session:e.session};let
|
|
1
|
+
import{resolveSubagentDepth}from"#harness/subagent-depth.js";import{AGENT_TOOL_NAME}from"#runtime/framework-tools/agent.js";import{TASK_TOOL_NAMES}from"#runtime/framework-tools/tasks.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{ensureWorkflowContinuationSecurity,getWorkflowContinuationSecurity}from"#harness/workflow-continuation-security.js";import{applyWorkflowTool}from"#harness/workflow-sandbox.js";function getAdvertisedTools(e){return`modelTools`in e?getAdvertisedModelTools(e):isToolDefinitionList(e.tools)?filterUnavailableDelegationToolDefinitions(e.tools,e.session):filterUnavailableDelegationToolMap(e.tools,e.session)}async function getAdvertisedModelTools(e){let t=filterUnavailableDelegationToolMap(e.tools,e.session);if(e.workflow===void 0)return{harnessTools:t,modelTools:e.modelTools,session:e.session};let n=filterWorkflowHostToolsForRootSession(t,e.session);if(n.size===0)return{harnessTools:t,modelTools:e.modelTools,session:e.session};let r=ensureWorkflowContinuationSecurity(e.session),{modelTools:a}=await applyWorkflowTool({continuationSecurity:getWorkflowContinuationSecurity(r),harnessTools:n,lifecycle:e.workflow.lifecycle?.({session:r,tools:n}),maxSubagents:e.workflow.maxSubagents,tools:e.modelTools});return{harnessTools:t,modelTools:a,session:r}}function filterUnavailableDelegationToolDefinitions(e,t){let n=[];for(let r of e)shouldHideDelegationTool(r,t)||n.push(r);return n}function filterUnavailableDelegationToolMap(e,t){let n=new Map;for(let[r,i]of e)shouldHideDelegationTool(i,t)||n.set(r,i);return n}function filterWorkflowHostToolsForRootSession(t,n){let r=new Map,i=resolveSubagentDepth(n);if(n.rootSessionId!==void 0||i.currentDepth>0)return r;for(let[e,n]of t)isDelegatedRuntimeActionTool(n)&&r.set(e,n);return r}function isDelegatedRuntimeActionTool(e){let t=e.runtimeAction;return t?.kind===`subagent-call`||t?.kind===`remote-agent-call`}function shouldHideDelegationTool(t,n){return isRootOnlyFrameworkTool(t)?n.rootSessionId!==void 0||resolveSubagentDepth(n).currentDepth>0:!1}function isRootOnlyFrameworkTool(e){return e.name===AGENT_TOOL_NAME&&e.runtimeAction?.kind===`subagent-call`&&e.runtimeAction.nodeId===ROOT_RUNTIME_AGENT_NODE_ID||TASK_TOOL_NAMES.has(e.name)}function isToolDefinitionList(e){return Array.isArray(e)}export{getAdvertisedTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEveConnectionCallbackRoutePath}from"#protocol/routes.js";import{SessionIdKey}from"#context/keys.js";import{loadContext}from"#context/container.js";import{ContextKey}from"#context/key.js";import{createUlid}from"#shared/ulid.js";const AUTHORIZATION_BRAND=`__eveAuthorization`,AUTHORIZATION_PENDING_BRAND=`__eveAuthorizationPending`;function requestAuthorization(e){return{[AUTHORIZATION_BRAND]:!0,challenges:e}}function redactSignalResume(e){return requestAuthorization(e.challenges.map(e=>({attemptId:e.attemptId,candidateId:e.candidateId,name:e.name,challenge:e.challenge,hookUrl:e.hookUrl})))}function getAuthorizationResult(e){let t=loadContext().get(PendingAuthorizationResultKey);if(!(!t||t.length===0))return e===void 0?t[0]:t.find(t=>t.name===e)}function consumeAuthorizationResult(e){let t=loadContext(),r=t.get(PendingAuthorizationResultKey);if(!r||r.length===0)return;let i=r.findIndex(t=>t.name===e);if(i===-1)return;let a=r[i],o=r.filter((e,t)=>t!==i);return t.delete(PendingAuthorizationResultKey),o.length>0&&t.set(PendingAuthorizationResultKey,o),a}function getHookUrl(r,
|
|
1
|
+
import{createEveConnectionCallbackRoutePath}from"#protocol/routes.js";import{SessionIdKey}from"#context/keys.js";import{loadContext}from"#context/container.js";import{ContextKey}from"#context/key.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{createUlid}from"#shared/ulid.js";const AUTHORIZATION_BRAND=`__eveAuthorization`,AUTHORIZATION_PENDING_BRAND=`__eveAuthorizationPending`;function requestAuthorization(e){return{[AUTHORIZATION_BRAND]:!0,challenges:e}}function redactSignalResume(e){return requestAuthorization(e.challenges.map(e=>({attemptId:e.attemptId,candidateId:e.candidateId,name:e.name,challenge:e.challenge,hookUrl:e.hookUrl})))}function getAuthorizationResult(e){let t=loadContext().get(PendingAuthorizationResultKey);if(!(!t||t.length===0))return e===void 0?t[0]:t.find(t=>t.name===e)}function consumeAuthorizationResult(e){let t=loadContext(),r=t.get(PendingAuthorizationResultKey);if(!r||r.length===0)return;let i=r.findIndex(t=>t.name===e);if(i===-1)return;let a=r[i],o=r.filter((e,t)=>t!==i);return t.delete(PendingAuthorizationResultKey),o.length>0&&t.set(PendingAuthorizationResultKey,o),a}function getHookUrl(r,a){let o=loadContext(),s=o.get(SessionIdKey),c=o.get(CallbackBaseUrlKey);return!s||!c?void 0:createWorkflowCallbackUrl(c,createEveConnectionCallbackRoutePath(r,a,authHookToken(s)))}function createAuthorizationAttempt(e){let t=createUlid(),n=getHookUrl(e,t);return n===void 0?void 0:{attemptId:t,hookUrl:n}}function isAuthorizationSignal(e){return typeof e!=`object`||!e?!1:e[AUTHORIZATION_BRAND]===!0}function isAuthorizationPendingModelOutput(e){return typeof e!=`object`||!e?!1:e[AUTHORIZATION_PENDING_BRAND]===!0}function authorizationPendingAsJsonObject(e){return{[AUTHORIZATION_PENDING_BRAND]:!0,connections:[...e.connections]}}function modelFacingAuthorizationOutput(e){return authorizationPendingAsJsonObject({connections:e.challenges.map(e=>e.name)})}function authorizationPendingModelText(e){return e.length===0?`Authorization required. Waiting for the user to sign in.`:e.length===1?`Authorization required for ${e[0]}. Waiting for the user to sign in.`:`Authorization required for ${e.join(`, `)}. Waiting for the user to sign in.`}function isPendingAuthorizationToolOutput(e){return isAuthorizationPendingModelOutput(e)||isAuthorizationSignal(e)}function authHookToken(e){return`${e}:auth`}const PendingAuthorizationResultKey=new ContextKey(`eve.pendingAuthorizationResult`),CallbackBaseUrlKey=new ContextKey(`eve.callbackBaseUrl`),PENDING_AUTHORIZATION_KEY=`eve.runtime.pendingAuthorization`;function setPendingAuthorization(e,t){let n=getPendingAuthorization(e)?.challenges??[],r=getSupersededAuthorizationChallenges(e,t.challenges);return{...e,[PENDING_AUTHORIZATION_KEY]:{challenges:[...n.filter(e=>!r.includes(e)),...t.challenges]}}}function getSupersededAuthorizationChallenges(e,t){return(getPendingAuthorization(e)?.challenges??[]).filter(e=>t.some(t=>e.name===t.name&&samePrincipal(e.principal,t.principal)))}function samePrincipal(e,t){return e===void 0||t===void 0?e===t:e.type===`app`||t.type===`app`?e.type===t.type:e.id===t.id&&e.issuer===t.issuer}function clearPendingAuthorization(e,t){if(e===void 0||e[PENDING_AUTHORIZATION_KEY]===void 0)return e;if(t!==void 0){if(t.length===0)return e;let n=getPendingAuthorization(e);if(n!==void 0){let r=new Set(t),i=n.challenges.filter(e=>!r.has(e.attemptId??e.name));if(i.length>0)return{...e,[PENDING_AUTHORIZATION_KEY]:{challenges:i}}}}let n={...e};return delete n[PENDING_AUTHORIZATION_KEY],Object.keys(n).length>0?n:void 0}function getPendingAuthorization(e){if(!e)return;let t=e[PENDING_AUTHORIZATION_KEY];if(!(typeof t!=`object`||!t))return t}function hasPendingAuthorization(e){return getPendingAuthorization(e)!==void 0}export{CallbackBaseUrlKey,PendingAuthorizationResultKey,authHookToken,authorizationPendingAsJsonObject,authorizationPendingModelText,clearPendingAuthorization,consumeAuthorizationResult,createAuthorizationAttempt,getAuthorizationResult,getHookUrl,getPendingAuthorization,getSupersededAuthorizationChallenges,hasPendingAuthorization,isAuthorizationPendingModelOutput,isAuthorizationSignal,isPendingAuthorizationToolOutput,modelFacingAuthorizationOutput,redactSignalResume,requestAuthorization,setPendingAuthorization};
|
|
@@ -6,12 +6,19 @@ import type { ToolExecuteOptions } from "#shared/tool-definition.js";
|
|
|
6
6
|
*
|
|
7
7
|
* These tools are surfaced to the model without a local `execute` function.
|
|
8
8
|
* The harness records the tool call and the runtime executes it later.
|
|
9
|
+
*
|
|
10
|
+
* `task-control` marks the `experimental.tasks` parent tools
|
|
11
|
+
* (`task_peek`, `task_cancel`): they carry no child
|
|
12
|
+
* address of their own — the dispatch step resolves targets through the
|
|
13
|
+
* session task index by tool name.
|
|
9
14
|
*/
|
|
10
15
|
export type HarnessRuntimeActionDefinition = {
|
|
11
16
|
readonly kind: "remote-agent-call" | "subagent-call";
|
|
12
17
|
readonly nodeId: string;
|
|
13
18
|
readonly remoteAgentName?: string;
|
|
14
19
|
readonly subagentName: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "task-control";
|
|
15
22
|
};
|
|
16
23
|
/**
|
|
17
24
|
* Unified harness-owned tool definition.
|
|
@@ -6,6 +6,15 @@ import type { AgentHandle, AgentHandleStore } from "#harness/handles/store.js";
|
|
|
6
6
|
* than authored user input.
|
|
7
7
|
*/
|
|
8
8
|
export declare const AGENTS_SNIPPET_LABEL = "[Agents]";
|
|
9
|
+
/** Model-safe projection of one persistent task-mode agent. */
|
|
10
|
+
export interface AgentView {
|
|
11
|
+
readonly availability: "available" | "busy";
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly statusLine?: string;
|
|
15
|
+
readonly taskId?: string;
|
|
16
|
+
readonly taskStatus?: "working" | "input_required";
|
|
17
|
+
}
|
|
9
18
|
/** Returns the resumable handles: the only phase the model may continue. */
|
|
10
19
|
export declare function projectParkedAgentHandles(store: AgentHandleStore): readonly Extract<AgentHandle, {
|
|
11
20
|
phase: "parked";
|
|
@@ -16,6 +25,8 @@ export declare function projectParkedAgentHandles(store: AgentHandleStore): read
|
|
|
16
25
|
* delivery coordinates never render.
|
|
17
26
|
*/
|
|
18
27
|
export declare function renderAgentsSnippet(store: AgentHandleStore): string;
|
|
28
|
+
/** Renders task-derived availability without exposing private addresses. */
|
|
29
|
+
export declare function renderAgentViewsSnippet(views: readonly AgentView[]): string;
|
|
19
30
|
/**
|
|
20
31
|
* Returns an append-only announcement when the visible handle listing
|
|
21
32
|
* changed since the last one in history, or `undefined` when it is
|
|
@@ -35,6 +46,7 @@ export declare function renderAgentsSnippet(store: AgentHandleStore): string;
|
|
|
35
46
|
* eve-injected so the model does not attribute it to the user.
|
|
36
47
|
*/
|
|
37
48
|
export declare function resolveAgentsAnnouncement(input: {
|
|
49
|
+
readonly agentViews?: readonly AgentView[];
|
|
38
50
|
readonly messages: readonly ModelMessage[];
|
|
39
51
|
readonly store: AgentHandleStore | undefined;
|
|
40
52
|
}): string | undefined;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
const AGENTS_SNIPPET_LABEL=`[Agents]`;function projectParkedAgentHandles(e){return e.handles.filter(e=>e.phase===`parked`)}function renderAgentsSnippet(t){let n=projectParkedAgentHandles(t).map(e=>`<agent id="${escapeXml(e.identity.id)}" name="${escapeXml(e.identity.name)}">${escapeXml(e.lastStatus===``?`(no status)`:e.lastStatus)}</agent>`);return[AGENTS_SNIPPET_LABEL,`<agents>`,...n,`</agents>`].join(`
|
|
2
|
-
`)}function
|
|
2
|
+
`)}function renderAgentViewsSnippet(t){let n=t.map(e=>{let t=e.taskId===void 0||e.taskStatus===void 0?``:` taskId="${escapeXml(e.taskId)}" taskStatus="${e.taskStatus}"`,n=e.statusLine??(e.availability===`busy`?`(busy)`:`(available)`);return`<agent id="${escapeXml(e.id)}" name="${escapeXml(e.name)}" availability="${e.availability}"${t}>${escapeXml(n)}</agent>`});return[AGENTS_SNIPPET_LABEL,`<agents>`,...n,`</agents>`].join(`
|
|
3
|
+
`)}function resolveAgentsAnnouncement(e){let t=e.messages.findLast(e=>e.role===`user`&&typeof e.content==`string`&&e.content.startsWith(`[Agents]`)),n=e.store??{handles:[]},r=e.agentViews?.length??projectParkedAgentHandles(n).length;if(t===void 0&&r===0)return;let i=e.agentViews===void 0?renderAgentsSnippet(n):renderAgentViewsSnippet(e.agentViews);return t?.content===i?void 0:i}function escapeXml(e){return e.replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}export{AGENTS_SNIPPET_LABEL,projectParkedAgentHandles,renderAgentViewsSnippet,renderAgentsSnippet,resolveAgentsAnnouncement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_HANDLES_STATE_KEY}from"#harness/handles/state-key.js";function readAgentHandles(t){let n=t?.[AGENT_HANDLES_STATE_KEY];if(n===void 0)return[];let r=n.handles;return Array.isArray(r)?r:[]}function findRunningAgentHandle(e,t){return readAgentHandles(e).find(e=>e.phase===`running`&&e.operation.callId===t.callId)}function isResultBoundToRunningHandle(e,t){return t.kind!==`subagent-result`||t.origin===`dispatch`||findRunningAgentHandle(e,{callId:t.callId})!==void 0}function isInboxSubagentResultFromRunningHandle(e,t){return findRunningAgentHandle(e,{callId:t.callId})!==void 0}export{findRunningAgentHandle,isInboxSubagentResultFromRunningHandle,isResultBoundToRunningHandle};
|
|
1
|
+
import{AGENT_HANDLES_STATE_KEY}from"#harness/handles/state-key.js";function readAgentHandles(t){let n=t?.[AGENT_HANDLES_STATE_KEY];if(n===void 0)return[];let r=n.handles;return Array.isArray(r)?r:[]}function findRunningAgentHandle(e,t){return readAgentHandles(e).find(e=>e.phase===`running`&&e.operation.callId===t.callId)}function isResultBoundToRunningHandle(e,t){return t.kind!==`subagent-result`||t.origin===`dispatch`||t.backgroundTask!==void 0||findRunningAgentHandle(e,{callId:t.callId})!==void 0}function isInboxSubagentResultFromRunningHandle(e,t){return findRunningAgentHandle(e,{callId:t.callId})!==void 0}export{findRunningAgentHandle,isInboxSubagentResultFromRunningHandle,isResultBoundToRunningHandle};
|
|
@@ -74,7 +74,7 @@ export type AgentAddress = {
|
|
|
74
74
|
/**
|
|
75
75
|
* Durable ownership record for one delegated child.
|
|
76
76
|
*
|
|
77
|
-
*
|
|
77
|
+
* Outside tasks mode, the store owns the full nonterminal lifecycle:
|
|
78
78
|
*
|
|
79
79
|
* - `starting` — the parent committed intent to start; the child may or
|
|
80
80
|
* may not exist yet.
|
|
@@ -82,7 +82,9 @@ export type AgentAddress = {
|
|
|
82
82
|
* - `parked` — the child is idle and resumable; only this phase is
|
|
83
83
|
* model-visible.
|
|
84
84
|
*
|
|
85
|
-
* A terminal child has no handle: settlement deletes it.
|
|
85
|
+
* A terminal child has no legacy handle: settlement deletes it. Tasks mode
|
|
86
|
+
* instead keeps an `addressed` record whose availability is derived from the
|
|
87
|
+
* tasks bound to its persistent child session.
|
|
86
88
|
*/
|
|
87
89
|
export type AgentHandle = {
|
|
88
90
|
readonly phase: "starting";
|
|
@@ -99,6 +101,11 @@ export type AgentHandle = {
|
|
|
99
101
|
readonly identity: AgentIdentity;
|
|
100
102
|
readonly address: AgentAddress;
|
|
101
103
|
readonly lastStatus: string;
|
|
104
|
+
} | {
|
|
105
|
+
/** Persistent task-mode identity and routing, with no execution claim. */
|
|
106
|
+
readonly phase: "addressed";
|
|
107
|
+
readonly identity: AgentIdentity;
|
|
108
|
+
readonly address: AgentAddress;
|
|
102
109
|
};
|
|
103
110
|
/** Lifecycle phase of a delegated agent handle. */
|
|
104
111
|
export type AgentHandlePhase = AgentHandle["phase"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_HANDLES_STATE_KEY}from"./state-key.js";import{z}from"#compiled/zod/index.js";const nonEmptyString=z.string().min(1),identitySchema=z.strictObject({id:nonEmptyString,name:nonEmptyString,nodeId:nonEmptyString}),startOperationSchema=z.strictObject({callId:nonEmptyString,id:nonEmptyString,kind:z.literal(`start`),parentTurnId:nonEmptyString}),continueOperationSchema=z.strictObject({callId:nonEmptyString,id:nonEmptyString,kind:z.literal(`continue`),parentTurnId:nonEmptyString,previousStatus:z.string().max(120)}),startTargetSchema=z.discriminatedUnion(`kind`,[z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/local`)}),z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/self`)}),z.strictObject({callbackBaseUrl:z.url(),kind:z.literal(`agent/remote`),url:z.url()})]),addressSchema=z.discriminatedUnion(`kind`,[z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/local`),sessionId:nonEmptyString}),z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/self`),sessionId:nonEmptyString}),z.strictObject({callbackBaseUrl:z.url(),kind:z.literal(`agent/remote`),sessionId:nonEmptyString,url:z.url()})]),agentHandleSchema=z.discriminatedUnion(`phase`,[z.strictObject({identity:identitySchema,operation:startOperationSchema,phase:z.literal(`starting`),target:startTargetSchema}),z.strictObject({address:addressSchema,identity:identitySchema,operation:z.discriminatedUnion(`kind`,[startOperationSchema,continueOperationSchema]),phase:z.literal(`running`)}),z.strictObject({address:addressSchema,identity:identitySchema,lastStatus:z.string().max(120),phase:z.literal(`parked`)})]),agentHandleStoreSchema=z.strictObject({handles:z.array(agentHandleSchema)}).refine(e=>new Set(e.handles.map(e=>e.identity.id)).size===e.handles.length,{message:`Agent handle ids must be unique.`});function deriveAgentId(e,t){return`ag_${e}:${t.slice(0,12)}`}function formatAgentStatus(e){return(typeof e==`string`?e:JSON.stringify(e)??``).replaceAll(/\s+/g,` `).trim().slice(0,120)}function assertPersistableAgentHandleStore(e){let t=agentHandleStoreSchema.safeParse(e);if(!t.success)throw Error(`Refusing to persist a corrupt agent handle store: ${t.error.message}`);return t.data}function getAgentHandleStore(t){let n=t?.[AGENT_HANDLES_STATE_KEY];if(n===void 0)return;let r=agentHandleStoreSchema.safeParse(n);if(!r.success)throw Error(`Corrupt agent handle store under session state key "${AGENT_HANDLES_STATE_KEY}": ${r.error.message}`);return r.data}export{AGENT_HANDLES_STATE_KEY,assertPersistableAgentHandleStore,deriveAgentId,formatAgentStatus,getAgentHandleStore};
|
|
1
|
+
import{AGENT_HANDLES_STATE_KEY}from"./state-key.js";import{z}from"#compiled/zod/index.js";const nonEmptyString=z.string().min(1),identitySchema=z.strictObject({id:nonEmptyString,name:nonEmptyString,nodeId:nonEmptyString}),startOperationSchema=z.strictObject({callId:nonEmptyString,id:nonEmptyString,kind:z.literal(`start`),parentTurnId:nonEmptyString}),continueOperationSchema=z.strictObject({callId:nonEmptyString,id:nonEmptyString,kind:z.literal(`continue`),parentTurnId:nonEmptyString,previousStatus:z.string().max(120)}),startTargetSchema=z.discriminatedUnion(`kind`,[z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/local`)}),z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/self`)}),z.strictObject({callbackBaseUrl:z.url(),kind:z.literal(`agent/remote`),url:z.url()})]),addressSchema=z.discriminatedUnion(`kind`,[z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/local`),sessionId:nonEmptyString}),z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/self`),sessionId:nonEmptyString}),z.strictObject({callbackBaseUrl:z.url(),kind:z.literal(`agent/remote`),sessionId:nonEmptyString,url:z.url()})]),agentHandleSchema=z.discriminatedUnion(`phase`,[z.strictObject({identity:identitySchema,operation:startOperationSchema,phase:z.literal(`starting`),target:startTargetSchema}),z.strictObject({address:addressSchema,identity:identitySchema,operation:z.discriminatedUnion(`kind`,[startOperationSchema,continueOperationSchema]),phase:z.literal(`running`)}),z.strictObject({address:addressSchema,identity:identitySchema,lastStatus:z.string().max(120),phase:z.literal(`parked`)}),z.strictObject({address:addressSchema,identity:identitySchema,phase:z.literal(`addressed`)})]),agentHandleStoreSchema=z.strictObject({handles:z.array(agentHandleSchema)}).refine(e=>new Set(e.handles.map(e=>e.identity.id)).size===e.handles.length,{message:`Agent handle ids must be unique.`});function deriveAgentId(e,t){return`ag_${e}:${t.slice(0,12)}`}function formatAgentStatus(e){return(typeof e==`string`?e:JSON.stringify(e)??``).replaceAll(/\s+/g,` `).trim().slice(0,120)}function assertPersistableAgentHandleStore(e){let t=agentHandleStoreSchema.safeParse(e);if(!t.success)throw Error(`Refusing to persist a corrupt agent handle store: ${t.error.message}`);return t.data}function getAgentHandleStore(t){let n=t?.[AGENT_HANDLES_STATE_KEY];if(n===void 0)return;let r=agentHandleStoreSchema.safeParse(n);if(!r.success)throw Error(`Corrupt agent handle store under session state key "${AGENT_HANDLES_STATE_KEY}": ${r.error.message}`);return r.data}export{AGENT_HANDLES_STATE_KEY,assertPersistableAgentHandleStore,deriveAgentId,formatAgentStatus,getAgentHandleStore};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AgentAddress, type AgentHandle, type AgentIdentity, type ContinueOperation, type StartOperation } from "#harness/handles/store.js";
|
|
2
|
-
import type { HarnessSession } from "#harness/types.js";
|
|
2
|
+
import type { HarnessSession, SessionStateMap } from "#harness/types.js";
|
|
3
3
|
import type { AgentTurnOutcome } from "#shared/agent-turn-outcome.js";
|
|
4
4
|
/**
|
|
5
5
|
* Records intent to start a fresh child. Must be applied to the step's
|
|
@@ -68,6 +68,15 @@ export declare function confirmAgentStarted(session: HarnessSession, input: {
|
|
|
68
68
|
readonly operationId: string;
|
|
69
69
|
readonly address: AgentAddress;
|
|
70
70
|
}): HarnessSession;
|
|
71
|
+
/** Confirms a task-mode child as a persistent identity/address record. */
|
|
72
|
+
export declare function confirmTaskAgentAddress(session: HarnessSession, input: {
|
|
73
|
+
readonly operationId: string;
|
|
74
|
+
readonly address: AgentAddress;
|
|
75
|
+
}): HarnessSession;
|
|
76
|
+
/** Removes a task-mode address after permanent delivery failure. */
|
|
77
|
+
export declare function removeTaskAgentAddress(session: HarnessSession, agentId: string): HarnessSession;
|
|
78
|
+
/** State-only variant used while consuming a terminal task wake. */
|
|
79
|
+
export declare function removeTaskAgentAddressFromState(state: SessionStateMap | undefined, agentId: string): SessionStateMap;
|
|
71
80
|
/**
|
|
72
81
|
* Resolves a dispatch that definitively failed.
|
|
73
82
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_HANDLES_STATE_KEY,assertPersistableAgentHandleStore,formatAgentStatus,getAgentHandleStore}from"#harness/handles/store.js";function prepareAgentStart(e,t){let n=getAgentHandleStore(e.state)?.handles??[];if(n.some(e=>e.identity.id===t.identity.id))throw Error(`Agent handle "${t.identity.id}" already exists.`);return writeHandles(e,[...n,{identity:t.identity,operation:t.operation,phase:`starting`,target:t.target}])}function prepareAgentContinuation(e,t){let n=getAgentHandleStore(e.state)?.handles??[],i=n.find(e=>e.identity.id===t.agentId);if(i===void 0)return{kind:`unknown`};if(i.identity.name!==t.invokedName)return{kind:`mismatch`};if(i.phase===`running`&&i.operation.id===t.operation.id)return{handle:i,kind:`ready`,session:e};if(i.phase!==`parked`)return{kind:`busy`};let a={address:i.address,identity:i.identity,operation:{...t.operation,previousStatus:i.lastStatus},phase:`running`};return{handle:a,kind:`ready`,session:writeHandles(e,n.map(e=>e.identity.id===t.agentId?a:e))}}function findActiveHandle(e,t){return e.find(e=>e.phase
|
|
1
|
+
import{AGENT_HANDLES_STATE_KEY,assertPersistableAgentHandleStore,formatAgentStatus,getAgentHandleStore}from"#harness/handles/store.js";function prepareAgentStart(e,t){let n=getAgentHandleStore(e.state)?.handles??[];if(n.some(e=>e.identity.id===t.identity.id))throw Error(`Agent handle "${t.identity.id}" already exists.`);return writeHandles(e,[...n,{identity:t.identity,operation:t.operation,phase:`starting`,target:t.target}])}function prepareAgentContinuation(e,t){let n=getAgentHandleStore(e.state)?.handles??[],i=n.find(e=>e.identity.id===t.agentId);if(i===void 0)return{kind:`unknown`};if(i.identity.name!==t.invokedName)return{kind:`mismatch`};if(i.phase===`running`&&i.operation.id===t.operation.id)return{handle:i,kind:`ready`,session:e};if(i.phase!==`parked`)return{kind:`busy`};let a={address:i.address,identity:i.identity,operation:{...t.operation,previousStatus:i.lastStatus},phase:`running`};return{handle:a,kind:`ready`,session:writeHandles(e,n.map(e=>e.identity.id===t.agentId?a:e))}}function findActiveHandle(e,t){return e.find(e=>(e.phase===`starting`||e.phase===`running`)&&e.operation.id===t)}function confirmAgentStarted(e,t){let n=getAgentHandleStore(e.state)?.handles??[],i=findActiveHandle(n,t.operationId);if(i===void 0)throw Error(`No prepared agent handle for operation "${t.operationId}".`);return i.phase===`running`?e:writeHandles(e,n.map(e=>e===i?{address:t.address,identity:i.identity,operation:i.operation,phase:`running`}:e))}function confirmTaskAgentAddress(e,t){let n=getAgentHandleStore(e.state)?.handles??[],i=findActiveHandle(n,t.operationId);if(i===void 0)throw Error(`No prepared agent handle for operation "${t.operationId}".`);if(i.phase===`running`)throw Error(`Task agent operation "${t.operationId}" was confirmed as a running handle.`);return writeHandles(e,n.map(e=>e===i?{address:t.address,identity:i.identity,phase:`addressed`}:e))}function removeTaskAgentAddress(e,t){return{...e,state:removeTaskAgentAddressFromState(e.state,t)}}function removeTaskAgentAddressFromState(n,i){let a=getAgentHandleStore(n)?.handles??[];return{...n,[AGENT_HANDLES_STATE_KEY]:assertPersistableAgentHandleStore({handles:a.filter(e=>!(e.phase===`addressed`&&e.identity.id===i))})}}function rejectAgentEffect(e,t){let n=getAgentHandleStore(e.state)?.handles??[],i=findActiveHandle(n,t.operationId);if(i===void 0)return e;if(t.disposition===`retryable`&&i.phase===`running`){let{operation:t}=i;if(t.kind===`continue`)return writeHandles(e,n.map(e=>e===i?{address:i.address,identity:i.identity,lastStatus:t.previousStatus,phase:`parked`}:e))}return writeHandles(e,n.filter(e=>e!==i))}function abandonRunningAgentTurns(e){let t=getAgentHandleStore(e.state)?.handles??[];return t.some(e=>e.phase===`running`)?writeHandles(e,t.map(e=>e.phase===`running`?{address:e.address,identity:e.identity,lastStatus:`(cancelled)`,phase:`parked`}:e)):e}function settleAgentTurn(e,t){let i=getAgentHandleStore(e.state)?.handles??[],a=i.find(e=>e.phase===`running`&&e.operation.id===t.operationId);if(a===void 0||a.phase!==`running`)return{kind:`ignored`,reason:`unknown-operation`};if(t.outcome.kind===`terminal`)return{kind:`settled`,session:writeHandles(e,i.filter(e=>e!==a))};let{result:o}=t.outcome,s=o.kind===`succeeded`?formatAgentStatus(o.output):o.kind===`failed`?formatAgentStatus(o.error):`(cancelled)`;return{kind:`settled`,session:writeHandles(e,i.map(e=>e===a?{address:a.address,identity:a.identity,lastStatus:s,phase:`parked`}:e))}}function writeHandles(n,r){return{...n,state:{...n.state,[AGENT_HANDLES_STATE_KEY]:assertPersistableAgentHandleStore({handles:r})}}}export{abandonRunningAgentTurns,confirmAgentStarted,confirmTaskAgentAddress,prepareAgentContinuation,prepareAgentStart,rejectAgentEffect,removeTaskAgentAddress,removeTaskAgentAddressFromState,settleAgentTurn};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{createInstrumentationSetupContext}from"#harness/instrumentation/setup-context.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV}from"#internal/workflow/development-world-protocol.js";import{agentRuns,localTraces}from"#public/instrumentation/otel.js";import{installInstrumentationRuntime}from"#tracing/install-instrumentation-runtime.js";import{collectOtelPipeline}from"#tracing/otel-declaration.js";import{isInstrumentationDisabled,isInstrumentationProvider}from"#public/instrumentation/provider.js";const INSTRUMENTATION_PROVIDERS_GLOBAL_KEY=Symbol.for(`eve.harness-instrumentation-providers`),globalContainer=globalThis;function providerRegistry(){let e=globalContainer[INSTRUMENTATION_PROVIDERS_GLOBAL_KEY];if(e!==void 0)return e;let t=new Map;return globalContainer[INSTRUMENTATION_PROVIDERS_GLOBAL_KEY]=t,t}function seedInstrumentationProviders(){let e=providerRegistry();process.env.VERCEL_ENV===`production`&&e.set(`agent-runs`,agentRuns()),process.env[DEVELOPMENT_WORKER_APP_ROOT_ENV]!==void 0&&e.set(`local`,localTraces())}async function registerInstrumentationProvider(e){if(isInstrumentationDisabled(e.value)){providerRegistry().delete(e.slot);return}if(!isInstrumentationProvider(e.value))throw Error(`The default export of "instrumentation/${e.slot}" is not an instrumentation provider. Return the result of \`defineInstrumentation\` or \`disableInstrumentation\` from it.`);providerRegistry().set(e.slot,e.value),await e.value.setup?.(createInstrumentationSetupContext(e.agentName))}function getInstrumentationProviders(){return[...providerRegistry()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({provider:t,slot:e}))}function finalizeInstrumentationProviders(t){let n=getInstrumentationProviders()
|
|
1
|
+
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{createInstrumentationSetupContext}from"#harness/instrumentation/setup-context.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV}from"#internal/workflow/development-world-protocol.js";import{agentRuns,localTraces}from"#public/instrumentation/otel.js";import{installInstrumentationRuntime}from"#tracing/install-instrumentation-runtime.js";import{collectOtelPipeline}from"#tracing/otel-declaration.js";import{isInstrumentationDisabled,isInstrumentationProvider}from"#public/instrumentation/provider.js";const INSTRUMENTATION_PROVIDERS_GLOBAL_KEY=Symbol.for(`eve.harness-instrumentation-providers`),globalContainer=globalThis;function providerRegistry(){let e=globalContainer[INSTRUMENTATION_PROVIDERS_GLOBAL_KEY];if(e!==void 0)return e;let t=new Map;return globalContainer[INSTRUMENTATION_PROVIDERS_GLOBAL_KEY]=t,t}function seedInstrumentationProviders(){let e=providerRegistry();process.env.VERCEL_ENV===`production`&&e.set(`agent-runs`,agentRuns()),process.env[DEVELOPMENT_WORKER_APP_ROOT_ENV]!==void 0&&e.set(`local`,localTraces())}async function registerInstrumentationProvider(e){if(isInstrumentationDisabled(e.value)){providerRegistry().delete(e.slot);return}if(!isInstrumentationProvider(e.value))throw Error(`The default export of "instrumentation/${e.slot}" is not an instrumentation provider. Return the result of \`defineInstrumentation\` or \`disableInstrumentation\` from it.`);providerRegistry().set(e.slot,e.value),await e.value.setup?.(createInstrumentationSetupContext(e.agentName))}function getInstrumentationProviders(){return[...providerRegistry()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({provider:t,slot:e}))}function finalizeInstrumentationProviders(t){let n=getInstrumentationProviders(),r=n.map(toProviderDefinition),i=collectOtelPipeline(n.map(e=>e.provider));return installInstrumentationRuntime({collected:i,frameworkVersion:resolveInstalledPackageInfo().version,providers:r,runtimeContextResolvers:i.runtimeContextResolvers,serviceName:t.serviceName})}async function shutdownInstrumentationProviders(){await getInstrumentationRuntime()?.shutdown()}function toProviderDefinition(e){return{capture:e.provider.capture,events:e.provider.events,flush:e.provider.flush,name:e.slot,shutdown:e.provider.shutdown,stateNamespace:`authored:${e.slot}`}}export{finalizeInstrumentationProviders,getInstrumentationProviders,registerInstrumentationProvider,seedInstrumentationProviders,shutdownInstrumentationProviders};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ModelMessage, SystemModelMessage } from "ai";
|
|
2
2
|
import type { HarnessEmissionState } from "#harness/emission.js";
|
|
3
3
|
import type { HarnessSession } from "#harness/types.js";
|
|
4
|
+
import type { RuntimeContextResolver } from "#tracing/otel-declaration.js";
|
|
4
5
|
import type { InstrumentationDefinition } from "#public/instrumentation/index.js";
|
|
5
6
|
export interface BuildTelemetryRuntimeContextInput {
|
|
6
7
|
readonly eveVersion: string;
|
|
@@ -11,6 +12,7 @@ export interface BuildTelemetryRuntimeContextInput {
|
|
|
11
12
|
readonly instructions: string | SystemModelMessage | undefined;
|
|
12
13
|
readonly messages: readonly ModelMessage[];
|
|
13
14
|
};
|
|
15
|
+
readonly providerResolvers?: readonly RuntimeContextResolver[];
|
|
14
16
|
readonly session: HarnessSession;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,formatError}from"#internal/logging.js";import{normalizeInstrumentationChannelKind,resolveInstrumentationProjection}from"#internal/instrumentation.js";import{AuthKey,ChannelInstrumentationKey,InitiatorAuthKey,ParentSessionKey}from"#context/keys.js";import{parseJsonObject,parseJsonValue}from"#shared/json.js";import{contextStorage}from"#context/container.js";const log=createLogger(`harness.instrumentation-runtime-context`);function buildTelemetryRuntimeContext(e){
|
|
1
|
+
import{createLogger,formatError}from"#internal/logging.js";import{normalizeInstrumentationChannelKind,resolveInstrumentationProjection}from"#internal/instrumentation.js";import{AuthKey,ChannelInstrumentationKey,InitiatorAuthKey,ParentSessionKey}from"#context/keys.js";import{parseJsonObject,parseJsonValue}from"#shared/json.js";import{contextStorage}from"#context/container.js";const log=createLogger(`harness.instrumentation-runtime-context`);function buildTelemetryRuntimeContext(e){let t=e.authored!==void 0,r=e.providerResolvers!==void 0&&e.providerResolvers.length>0;if(!t&&!r)return;let i=resolveStepStartedRuntimeContext(e),o=resolveProviderRuntimeContext(e),s=contextStorage.getStore()?.get(ChannelInstrumentationKey);return{...i,...o,"eve.channel.kind":normalizeInstrumentationChannelKind(s?.kind),"eve.environment":e.environment,"eve.session.id":e.session.sessionId,"eve.step.index":String(e.emissionState.stepIndex),"eve.turn.id":e.emissionState.turnId,"eve.turn.sequence":String(e.emissionState.sequence),"eve.version":e.eveVersion}}function buildInstrumentationStepStartedInput(e){let t=contextStorage.getStore(),r=t?.get(ChannelInstrumentationKey);return{channel:{kind:normalizeInstrumentationChannelKind(r?.kind),metadata:snapshotForInstrumentation(r?.metadata,`channel.metadata`)??{}},modelInput:snapshotForInstrumentation(e.modelInput,`modelInput`)??{instructions:void 0,messages:[]},session:{auth:projectSessionAuth(t),id:e.session.sessionId,parent:snapshotForInstrumentation(t?.get(ParentSessionKey),`session.parent`)},step:{index:e.emissionState.stepIndex},turn:{id:e.emissionState.turnId,sequence:e.emissionState.sequence}}}function filterAuthoredRuntimeContext(e,t){let n={};for(let[r,i]of Object.entries(e)){if(r.startsWith(`eve.`)){log.warn(`ignoring reserved instrumentation runtime context key`,{key:r,source:t});continue}n[r]=i}return Object.keys(n).length>0?n:void 0}function resolveStepStartedRuntimeContext(e){let n=e.authored?.events?.[`step.started`];if(n===void 0)return;let i=`events["step.started"]`,a=resolveInstrumentationProjection({invoke:()=>{let t=buildInstrumentationStepStartedInput(e);return n(t)},log,source:i});if(a===void 0)return;if(!(`runtimeContext`in a)){log.warn(`ignoring instrumentation event result because runtimeContext is missing`,{source:i});return}let o;try{o=parseJsonObject(a.runtimeContext)}catch(e){log.warn(`ignoring instrumentation event result because runtimeContext is invalid`,{error:formatError(e),source:i});return}return filterAuthoredRuntimeContext(o,i)}function resolveProviderRuntimeContext(e){let t=e.providerResolvers;if(t===void 0||t.length===0)return;let n={},i=!1;for(let a of t){let t=`provider.runtimeContext`,o=resolveInstrumentationProjection({invoke:()=>{let t=buildInstrumentationStepStartedInput(e);return a(t)},log,source:t});if(o===void 0)continue;let s=filterAuthoredRuntimeContext(o,t);s!==void 0&&(Object.assign(n,s),i=!0)}return i?n:void 0}function projectSessionAuth(e){let t=e?.get(AuthKey)??null,n=e?.get(InitiatorAuthKey)??t;return{current:snapshotForInstrumentation(t,`session.auth.current`)??null,initiator:snapshotForInstrumentation(n,`session.auth.initiator`)??null}}function snapshotForInstrumentation(e,n){if(e!==void 0)try{return parseJsonValue(e)}catch(e){log.warn(`dropping non-serializable instrumentation snapshot`,{error:formatError(e),source:n});return}}export{buildTelemetryRuntimeContext};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InstrumentationContextRunner, InstrumentationHooks, InstrumentationSessionStartedEvent, InstrumentationTraceContext, InstrumentationTurnStartedEvent } from "#harness/instrumentation/lifecycle.js";
|
|
2
|
-
import type { OtelHarnessSettings } from "#tracing/otel-declaration.js";
|
|
2
|
+
import type { OtelHarnessSettings, RuntimeContextResolver } from "#tracing/otel-declaration.js";
|
|
3
3
|
/** Process-wide runtime consumed by every harness execution surface. */
|
|
4
4
|
export interface InstrumentationRuntime {
|
|
5
5
|
readonly forceFlush: () => Promise<void>;
|
|
@@ -7,6 +7,8 @@ export interface InstrumentationRuntime {
|
|
|
7
7
|
readonly prepareSessionTrace?: (event: InstrumentationSessionStartedEvent) => Promise<InstrumentationTraceContext>;
|
|
8
8
|
readonly prepareTurnTrace?: (event: InstrumentationTurnStartedEvent) => Promise<InstrumentationTraceContext>;
|
|
9
9
|
otelSettings: OtelHarnessSettings | undefined;
|
|
10
|
+
/** Provider `runtimeContext` resolvers, collected at install time. */
|
|
11
|
+
readonly runtimeContextResolvers?: readonly RuntimeContextResolver[];
|
|
10
12
|
readonly runInContext: InstrumentationContextRunner;
|
|
11
13
|
readonly shutdown: () => Promise<void>;
|
|
12
14
|
}
|
|
@@ -6,12 +6,20 @@ export interface ProxyInputRequest {
|
|
|
6
6
|
/** Batch semantics are optional so sessions written before this field remain routable. */
|
|
7
7
|
readonly batch?: ProxyInputRequestBatch;
|
|
8
8
|
readonly childContinuationToken: string;
|
|
9
|
+
/** Child-local id restored before forwarding a namespaced task response. */
|
|
10
|
+
readonly childRequestId?: string;
|
|
11
|
+
/** Trusted parent-derived capability URL for a remote task child. */
|
|
12
|
+
readonly childResponseUrl?: string;
|
|
9
13
|
readonly kind: InputRequestKind;
|
|
14
|
+
/** Present when the route is authorized by a parent-owned durable task. */
|
|
15
|
+
readonly taskId?: string;
|
|
10
16
|
}
|
|
11
17
|
export interface ProxyInputRequestBatch {
|
|
12
18
|
readonly approvalRequestIds: readonly string[];
|
|
13
19
|
readonly requestIds: readonly string[];
|
|
14
20
|
}
|
|
21
|
+
/** Parent-visible id for one task-owned child-local input request. */
|
|
22
|
+
export declare function createTaskInputRequestId(taskId: string, childRequestId: string): string;
|
|
15
23
|
/**
|
|
16
24
|
* Returns the proxy-routing map as a fresh `Map`. Never returns a live
|
|
17
25
|
* reference so accidental mutation cannot corrupt session state.
|
|
@@ -23,15 +31,22 @@ export declare function getProxyInputRequests(state: SessionStateMap | undefined
|
|
|
23
31
|
*/
|
|
24
32
|
export declare function hasProxyInputRequests(state: SessionStateMap | undefined): boolean;
|
|
25
33
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
34
|
+
* Replaces prior entries for `forChildContinuationToken` with the provided
|
|
35
|
+
* ones. A child raising a fresh batch overwrites its prior batch so the
|
|
36
|
+
* parent never keeps stale request metadata. Other children's routes stay
|
|
37
|
+
* independently answerable.
|
|
29
38
|
*/
|
|
30
39
|
export declare function upsertProxyInputRequests(input: {
|
|
31
40
|
readonly entries: readonly (readonly [requestId: string, route: ProxyInputRequest])[];
|
|
32
41
|
readonly forChildContinuationToken: string;
|
|
33
42
|
readonly session: HarnessSession;
|
|
34
43
|
}): HarnessSession;
|
|
44
|
+
/** State-only variant for control-plane steps that already hold a durable projection. */
|
|
45
|
+
export declare function upsertProxyInputRequestState(input: {
|
|
46
|
+
readonly entries: readonly (readonly [requestId: string, route: ProxyInputRequest])[];
|
|
47
|
+
readonly forChildContinuationToken: string;
|
|
48
|
+
readonly state: SessionStateMap | undefined;
|
|
49
|
+
}): SessionStateMap | undefined;
|
|
35
50
|
/**
|
|
36
51
|
* Removes every entry for `childContinuationToken`. Called when a
|
|
37
52
|
* child subagent finishes so stale clicks no longer route to it.
|
|
@@ -41,6 +56,8 @@ export declare function clearProxyInputRequestsForChild(session: HarnessSession,
|
|
|
41
56
|
export declare function retireProxyInputRequests<T extends {
|
|
42
57
|
readonly state?: SessionStateMap;
|
|
43
58
|
}>(session: T, requestIds: readonly string[]): T;
|
|
59
|
+
/** Removes every proxy route owned by one durable task. */
|
|
60
|
+
export declare function clearProxyInputRequestsForTask(session: HarnessSession, taskId: string): HarnessSession;
|
|
44
61
|
/**
|
|
45
62
|
* Removes every proxy entry. Called when a cancelled turn orphans its
|
|
46
63
|
* descendants so stale HITL responses no longer route to them.
|
|
@@ -50,4 +67,4 @@ export declare function clearAllProxyInputRequests(session: HarnessSession): Har
|
|
|
50
67
|
* Projects a {@link SubagentInputRequestHookPayload} into the
|
|
51
68
|
* `(requestId, route)` tuples the session stores.
|
|
52
69
|
*/
|
|
53
|
-
export declare function toProxyInputRequestEntries(payload: SubagentInputRequestHookPayload): readonly (readonly [requestId: string, route: ProxyInputRequest])[];
|
|
70
|
+
export declare function toProxyInputRequestEntries(payload: SubagentInputRequestHookPayload, taskId?: string): readonly (readonly [requestId: string, route: ProxyInputRequest])[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const PROXY_INPUT_REQUESTS_KEY=`eve.runtime.proxyInputRequests`,PROXY_INPUT_REQUEST_KINDS={question:!0,"session-limit":!0,"tool-approval":!0};function getProxyInputRequests(e){return new Map(Object.entries(readMap(e)))}function hasProxyInputRequests(e){for(let t of Object.keys(readMap(e)))return!0;return!1}function upsertProxyInputRequests(e){
|
|
1
|
+
import{isLoopbackHostname}from"#shared/network-address.js";const PROXY_INPUT_REQUESTS_KEY=`eve.runtime.proxyInputRequests`,PROXY_INPUT_REQUEST_KINDS={question:!0,"session-limit":!0,"tool-approval":!0};function createTaskInputRequestId(e,t){return`${e}:${t}`}function getProxyInputRequests(e){return new Map(Object.entries(readMap(e)))}function hasProxyInputRequests(e){for(let t of Object.keys(readMap(e)))return!0;return!1}function upsertProxyInputRequests(e){return{...e.session,state:upsertProxyInputRequestState({entries:e.entries,forChildContinuationToken:e.forChildContinuationToken,state:e.session.state})}}function upsertProxyInputRequestState(e){let n={};for(let[t,r]of Object.entries(readMap(e.state)))r.childContinuationToken!==e.forChildContinuationToken&&(n[t]=r);for(let[t,r]of e.entries)n[t]=r;let r={...e.state};return Object.keys(n).length===0?delete r[PROXY_INPUT_REQUESTS_KEY]:r[PROXY_INPUT_REQUESTS_KEY]=n,Object.keys(r).length>0?r:void 0}function clearProxyInputRequestsForChild(e,t){let n=readMap(e.state),r={},i=!1;for(let[e,a]of Object.entries(n)){if(a.childContinuationToken===t){i=!0;continue}r[e]=a}return i?writeMap(e,r):e}function retireProxyInputRequests(e,t){let n={...readMap(e.state)},r=!1;for(let e of t)Object.hasOwn(n,e)&&(delete n[e],r=!0);return r?writeMap(e,n):e}function clearProxyInputRequestsForTask(e,t){let n=readMap(e.state),r={},i=!1;for(let[e,a]of Object.entries(n))a.taskId===t?i=!0:r[e]=a;return i?writeMap(e,r):e}function clearAllProxyInputRequests(e){return hasProxyInputRequests(e.state)?writeMap(e,{}):e}function toProxyInputRequestEntries(e,t){let n={approvalRequestIds:e.event.requests.flatMap(e=>e.kind===`tool-approval`?[e.requestId]:[]),requestIds:e.event.requests.map(e=>e.requestId)};return e.event.requests.map(r=>{let i={batch:n,childContinuationToken:e.childContinuationToken,kind:r.kind};return t!==void 0&&(i.taskId=t),[r.requestId,i]})}function readMap(e){let n=e?.[PROXY_INPUT_REQUESTS_KEY];if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){let n=parseProxyInputRequest(t,e);n!==void 0&&(r[e]=n)}return r}function writeMap(e,n){let r={...e.state};return Object.keys(n).length===0?(delete r[PROXY_INPUT_REQUESTS_KEY],{...e,state:Object.keys(r).length>0?r:void 0}):(r[PROXY_INPUT_REQUESTS_KEY]=n,{...e,state:r})}function parseProxyInputRequest(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||!(`childContinuationToken`in e)||!(`kind`in e)||typeof e.childContinuationToken!=`string`||!isInputRequestKind(e.kind))return;let n=`taskId`in e?e.taskId:void 0,r=`childRequestId`in e?e.childRequestId:void 0,i=`childResponseUrl`in e?e.childResponseUrl:void 0;if(n!==void 0&&(typeof n!=`string`||n.length===0)||r!==void 0&&(typeof r!=`string`||r.length===0)||n===void 0!=(r===void 0)||i!==void 0&&(typeof i!=`string`||!isAllowedChildResponseUrl(i)))return;let a=`batch`in e?parseProxyInputRequestBatch(e.batch):void 0,o={childContinuationToken:e.childContinuationToken,kind:e.kind};return a!==void 0&&a.requestIds.includes(t)&&(o.batch=a),typeof r==`string`&&(o.childRequestId=r),typeof i==`string`&&(o.childResponseUrl=i),typeof n==`string`&&(o.taskId=n),o}function parseProxyInputRequestBatch(e){if(typeof e!=`object`||!e||Array.isArray(e)||!(`approvalRequestIds`in e)||!(`requestIds`in e)||!isStringArray(e.approvalRequestIds)||!isStringArray(e.requestIds))return;let t=new Set(e.requestIds);if(!(t.size!==e.requestIds.length||e.approvalRequestIds.some(e=>!t.has(e))))return{approvalRequestIds:e.approvalRequestIds,requestIds:e.requestIds}}function isStringArray(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function isAllowedChildResponseUrl(t){let n;try{n=new URL(t)}catch{return!1}return n.protocol===`https:`||n.protocol===`http:`&&isLoopbackHostname(n.hostname)}function isInputRequestKind(e){return typeof e==`string`&&Object.hasOwn(PROXY_INPUT_REQUEST_KINDS,e)}export{clearAllProxyInputRequests,clearProxyInputRequestsForChild,clearProxyInputRequestsForTask,createTaskInputRequestId,getProxyInputRequests,hasProxyInputRequests,retireProxyInputRequests,toProxyInputRequestEntries,upsertProxyInputRequestState,upsertProxyInputRequests};
|