eve 0.55.0 → 0.57.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 +58 -0
- package/dist/src/channel/adapter-context.d.ts +1 -1
- package/dist/src/channel/adapter.d.ts +2 -2
- package/dist/src/channel/audience.d.ts +3 -3
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/conversation-context.d.ts +4 -2
- package/dist/src/channel/conversation-context.js +1 -1
- package/dist/src/channel/session.d.ts +4 -3
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +7 -4
- package/dist/src/chunks/{use-eve-agent-D-KQzzyW.js → use-eve-agent-C2APNCdP.js} +45 -22
- package/dist/src/chunks/{use-eve-agent-CxPlg0KL.js → use-eve-agent-D0YnDLi_.js} +45 -22
- package/dist/src/cli/commands/init.d.ts +2 -6
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/registry-metadata.d.ts +0 -18
- package/dist/src/cli/commands/registry-metadata.js +1 -1
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.js +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/commands/trace-detail.js +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/run-interactive-ui.js +1 -1
- package/dist/src/cli/dev/tui/agent-header.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +3 -6
- package/dist/src/cli/dev/tui/blocks.js +3 -3
- package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
- package/dist/src/cli/dev/tui/markdown.d.ts +8 -1
- package/dist/src/cli/dev/tui/markdown.js +7 -7
- package/dist/src/cli/dev/tui/message-queue.d.ts +11 -7
- package/dist/src/cli/dev/tui/message-queue.js +1 -1
- package/dist/src/cli/dev/tui/model-editor.d.ts +1 -1
- package/dist/src/cli/dev/tui/model-editor.js +1 -1
- package/dist/src/cli/dev/tui/prompt-command-handler.d.ts +0 -3
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.d.ts +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/question-panel.js +1 -1
- package/dist/src/cli/dev/tui/remote-auth-result.js +1 -1
- package/dist/src/cli/dev/tui/remote-auth.js +1 -1
- package/dist/src/cli/dev/tui/remote-startup.d.ts +10 -0
- package/dist/src/cli/dev/tui/remote-startup.js +1 -0
- package/dist/src/cli/dev/tui/runner.d.ts +16 -19
- package/dist/src/cli/dev/tui/runner.js +3 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +7 -13
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/cli/dev/tui/setup-issues.d.ts +1 -1
- package/dist/src/cli/dev/tui/setup-issues.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.d.ts +5 -17
- package/dist/src/cli/dev/tui/setup-panel.js +5 -6
- package/dist/src/cli/dev/tui/status-line.d.ts +1 -8
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/steering-stream.d.ts +15 -0
- package/dist/src/cli/dev/tui/steering-stream.js +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +8 -3
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/test/mock-terminal.d.ts +2 -2
- package/dist/src/cli/dev/tui/test/mock-terminal.js +1 -1
- package/dist/src/cli/dev/tui/theme.d.ts +0 -2
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tui.d.ts +4 -1
- package/dist/src/cli/dev/tui/vercel-status.d.ts +4 -2
- package/dist/src/cli/dev/tui/vercel-status.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/cli/telemetry/index.d.ts +1 -1
- package/dist/src/cli/telemetry/index.js +1 -1
- package/dist/src/cli/ui/terminal-text.js +1 -1
- package/dist/src/client/agent-info-schema.d.ts +2 -57
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/eve-agent-store-state.d.ts +19 -0
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/ndjson.d.ts +2 -0
- package/dist/src/client/ndjson.js +3 -3
- package/dist/src/client/open-stream.d.ts +1 -0
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -0
- package/dist/src/compiled/@workflow/core/runtime.js +2 -2
- package/dist/src/compiled/@workflow/core/serialization.js +1 -0
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +2 -2
- package/dist/src/compiled/_chunks/workflow/attribute-changes-DTFAjP0J.js +6 -0
- package/dist/src/compiled/_chunks/workflow/{dist-PLkAQ-U7.js → dist-C5KCXSdI.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{frames-BvATzM2t.js → frames-DJw9L4rO.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/global-DFW-hO6M.js +1 -0
- package/dist/src/compiled/_chunks/workflow/helpers-ClCA9Lmc.js +1 -0
- package/dist/src/compiled/_chunks/workflow/logger-D6vwIEf9.js +13 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-_baK8jaT.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-CRdL17z4.js +1 -0
- package/dist/src/compiled/_chunks/workflow/serialization-CWYPL4Eq.js +3 -0
- package/dist/src/compiled/_chunks/workflow/sleep-BL0kgJnT.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-DyIt9lEx.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{ws-transport-CVezyWwZ.js → ws-transport-Dl5FG4Sw.js} +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +27 -8
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +12 -11
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-tool.d.ts +0 -3
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/compiler/validate-artifact.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +5 -1
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/audience.d.ts +2 -2
- package/dist/src/eve-channel/audience.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.js +4 -3
- package/dist/src/eve-channel/types.d.ts +5 -5
- package/dist/src/execution/activity-cohort.js +1 -1
- package/dist/src/execution/activity-collector.js +1 -1
- package/dist/src/execution/authorization-callback-match.d.ts +2 -1
- package/dist/src/execution/authorization-callback-match.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.d.ts +1 -1
- package/dist/src/execution/connections/callback-route.d.ts +1 -11
- package/dist/src/execution/connections/callback-route.js +1 -1
- package/dist/src/execution/continuation-conflict-step.d.ts +0 -1
- package/dist/src/execution/continuation-conflict-step.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +1 -1
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.d.ts +2 -2
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +1 -1
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +10 -49
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/program-step.d.ts +21 -0
- package/dist/src/execution/dynamic-workflow/program-step.js +1 -0
- package/dist/src/execution/dynamic-workflow/schema.d.ts +36 -0
- package/dist/src/execution/dynamic-workflow/schema.js +1 -0
- package/dist/src/execution/dynamic-workflow/security-step.d.ts +3 -0
- package/dist/src/execution/dynamic-workflow/security-step.js +1 -0
- package/dist/src/execution/dynamic-workflow/tool.d.ts +8 -0
- package/dist/src/execution/dynamic-workflow/tool.js +1 -0
- package/dist/src/execution/dynamic-workflow/workflow.d.ts +10 -0
- package/dist/src/execution/dynamic-workflow/workflow.js +1 -0
- package/dist/src/execution/eve-workflow-attributes.d.ts +2 -17
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/execution/hook-ownership.d.ts +2 -4
- package/dist/src/execution/hook-ownership.js +1 -1
- package/dist/src/execution/legacy-session/authorization.d.ts +9 -0
- package/dist/src/execution/legacy-session/authorization.js +1 -0
- package/dist/src/execution/legacy-session/completion-step.d.ts +10 -0
- package/dist/src/execution/legacy-session/completion-step.js +1 -0
- package/dist/src/execution/legacy-session/inbox.d.ts +24 -0
- package/dist/src/execution/legacy-session/inbox.js +1 -0
- package/dist/src/execution/legacy-session/input.d.ts +19 -0
- package/dist/src/execution/legacy-session/input.js +1 -0
- package/dist/src/execution/legacy-session/interrupt-step.d.ts +3 -0
- package/dist/src/execution/legacy-session/interrupt-step.js +1 -0
- package/dist/src/execution/legacy-session/prepare-step.d.ts +24 -0
- package/dist/src/execution/legacy-session/prepare-step.js +1 -0
- package/dist/src/execution/legacy-session/snapshot.d.ts +12 -0
- package/dist/src/execution/legacy-session/snapshot.js +1 -0
- package/dist/src/execution/legacy-session/turn-workflow.d.ts +8 -0
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -0
- package/dist/src/execution/model-call-batching.d.ts +1 -0
- package/dist/src/execution/model-call-batching.js +1 -1
- package/dist/src/execution/node-step.d.ts +1 -5
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/proxied-deliver-step.d.ts +2 -20
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/reconcile-session-continuation-token.d.ts +1 -1
- package/dist/src/execution/report-dropped-wire-payload-step.d.ts +1 -1
- package/dist/src/execution/route-child-delivery.d.ts +2 -2
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/bindings/eve-image.js +1 -1
- package/dist/src/execution/session/accepted-deployment.d.ts +3 -0
- package/dist/src/execution/session/accepted-deployment.js +1 -0
- package/dist/src/execution/session/admission.d.ts +38 -0
- package/dist/src/execution/session/admission.js +1 -0
- package/dist/src/execution/session/entry-input.d.ts +42 -0
- package/dist/src/execution/session/entry-input.js +1 -0
- package/dist/src/execution/session/entry.d.ts +13 -0
- package/dist/src/execution/session/entry.js +1 -0
- package/dist/src/execution/session/event-sink.d.ts +31 -0
- package/dist/src/execution/session/event-sink.js +1 -0
- package/dist/src/execution/session/finalization.d.ts +33 -0
- package/dist/src/execution/session/finalization.js +1 -0
- package/dist/src/execution/session/handoff-steps.d.ts +22 -0
- package/dist/src/execution/session/handoff-steps.js +1 -0
- package/dist/src/execution/session/handoff.d.ts +69 -0
- package/dist/src/execution/session/handoff.js +1 -0
- package/dist/src/execution/session/hook-tokens.d.ts +11 -0
- package/dist/src/execution/session/hook-tokens.js +1 -0
- package/dist/src/execution/session/input-queue.d.ts +72 -0
- package/dist/src/execution/session/input-queue.js +1 -0
- package/dist/src/execution/session/next-input.d.ts +32 -0
- package/dist/src/execution/session/next-input.js +1 -0
- package/dist/src/execution/{pending-turn-state.d.ts → session/pending-turn-state.d.ts} +0 -1
- package/dist/src/execution/{pending-turn-state.js → session/pending-turn-state.js} +1 -1
- package/dist/src/execution/session/program.d.ts +47 -0
- package/dist/src/execution/session/program.js +1 -0
- package/dist/src/execution/session/route-selected-delivery.d.ts +9 -0
- package/dist/src/execution/session/route-selected-delivery.js +1 -0
- package/dist/src/execution/session/state-cursor.d.ts +31 -0
- package/dist/src/execution/session/state-cursor.js +1 -0
- package/dist/src/execution/{session-timeout-control.d.ts → session/timeout-control.d.ts} +1 -1
- package/dist/src/execution/session/timeout-control.js +1 -0
- package/dist/src/execution/{session-timeout-steps.d.ts → session/timeout-steps.d.ts} +3 -2
- package/dist/src/execution/session/timeout-steps.js +1 -0
- package/dist/src/execution/{session-timeout-workflow.d.ts → session/timeout-workflow.d.ts} +3 -1
- package/dist/src/execution/session/timeout-workflow.js +1 -0
- package/dist/src/execution/session/timeout.d.ts +3 -0
- package/dist/src/execution/session/timeout.js +1 -0
- package/dist/src/execution/session/turn-step-result.d.ts +4 -0
- package/dist/src/execution/session/turn-step-result.js +1 -0
- package/dist/src/execution/session/turn-step-types.d.ts +68 -0
- package/dist/src/execution/session/turn-step-types.js +1 -0
- package/dist/src/execution/{workflow-steps.d.ts → session/turn-step.d.ts} +1 -2
- package/dist/src/execution/session/turn-step.js +1 -0
- package/dist/src/execution/session/turn.d.ts +31 -0
- package/dist/src/execution/session/turn.js +1 -0
- package/dist/src/execution/session-inbox/address.d.ts +21 -0
- package/dist/src/execution/session-inbox/address.js +1 -0
- package/dist/src/execution/session-inbox/inbox.d.ts +54 -0
- package/dist/src/execution/session-inbox/inbox.js +1 -0
- package/dist/src/execution/session-inbox/protocol.d.ts +10 -0
- package/dist/src/execution/session-inbox/protocol.js +1 -0
- package/dist/src/execution/session-inbox/release-step.d.ts +5 -0
- package/dist/src/execution/session-inbox/release-step.js +1 -0
- package/dist/src/execution/session-inbox/resume.d.ts +21 -0
- package/dist/src/execution/session-inbox/resume.js +1 -0
- package/dist/src/execution/{turn-workflow-tool-run.d.ts → session-workflow-tool-run.d.ts} +2 -2
- package/dist/src/execution/session-workflow-tool-run.js +1 -0
- package/dist/src/execution/session.d.ts +0 -1
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/skills/instructions.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +1 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/task-input-response-route.js +1 -1
- package/dist/src/execution/tasks/child/steps.d.ts +1 -1
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +7 -0
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/terminal-session-completion-step.d.ts +1 -1
- package/dist/src/execution/terminal-session-event.d.ts +1 -1
- package/dist/src/execution/terminal-session-event.js +1 -1
- package/dist/src/execution/terminal-session-failure-step.d.ts +1 -1
- package/dist/src/execution/terminal-session-failure-step.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
- package/dist/src/execution/tools/subagent/emit-called-step.d.ts +1 -1
- package/dist/src/execution/tools/subagent/emit-called-step.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +1 -1
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +6 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +2 -0
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
- package/dist/src/execution/tools/subagent/steer.d.ts +13 -0
- package/dist/src/execution/tools/subagent/steer.js +1 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +1 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -1
- package/dist/src/execution/tools/subagent/task-cancel.js +1 -1
- package/dist/src/execution/tools/workflow/ask.d.ts +0 -9
- package/dist/src/execution/tools/workflow/ask.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +0 -2
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +1 -1
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -1
- package/dist/src/execution/tools/workflow/messages.d.ts +0 -1
- package/dist/src/execution/tools/workflow/messages.js +1 -1
- package/dist/src/execution/tools/workflow/owner.d.ts +3 -1
- package/dist/src/execution/tools/workflow/owner.js +1 -1
- package/dist/src/execution/tools/workflow/resume-hook-step.d.ts +1 -1
- package/dist/src/execution/tools/workflow/step-context.d.ts +0 -1
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/tools/workflow/workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +15 -18
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +0 -3
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/authorization.d.ts +5 -37
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/emission-state.d.ts +1 -0
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/generation-steering.d.ts +22 -0
- package/dist/src/harness/generation-steering.js +1 -0
- package/dist/src/harness/messages.d.ts +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/prompt-cache.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +1 -1
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/semantic-errors/rules/gateway.js +1 -1
- package/dist/src/harness/semantic-errors/signals.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/types.d.ts +2 -21
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/channel-delivery.js +1 -1
- package/dist/src/instrumentation/content.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +6 -7
- package/dist/src/instrumentation/native-events.d.ts +2 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/session-context.d.ts +2 -0
- package/dist/src/instrumentation/session-context.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +3 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/connection.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.d.ts +3 -4
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/gateway.d.ts +1 -0
- package/dist/src/internal/gateway.js +1 -1
- package/dist/src/internal/model-auth/api-key.d.ts +7 -0
- package/dist/src/internal/model-auth/api-key.js +1 -0
- package/dist/src/internal/model-auth/available-models.d.ts +2 -0
- package/dist/src/internal/model-auth/available-models.js +1 -0
- package/dist/src/internal/model-auth/development-broker-client.d.ts +3 -0
- package/dist/src/internal/model-auth/development-broker-client.js +1 -0
- package/dist/src/internal/model-auth/development-broker-protocol.d.ts +12 -0
- package/dist/src/internal/model-auth/development-broker-protocol.js +1 -0
- package/dist/src/internal/model-auth/development-broker-server.d.ts +4 -0
- package/dist/src/internal/model-auth/development-broker-server.js +1 -0
- package/dist/src/internal/model-auth/gateway-credential.d.ts +2 -0
- package/dist/src/internal/model-auth/gateway-credential.js +1 -0
- package/dist/src/internal/model-auth/store.d.ts +16 -0
- package/dist/src/internal/model-auth/store.js +1 -0
- package/dist/src/internal/model-auth/transport.d.ts +6 -0
- package/dist/src/internal/model-auth/transport.js +1 -0
- package/dist/src/internal/model-auth/vercel-cli.d.ts +7 -0
- package/dist/src/internal/model-auth/vercel-cli.js +1 -0
- package/dist/src/internal/model-auth/vercel-team.d.ts +3 -0
- package/dist/src/internal/model-auth/vercel-team.js +1 -0
- package/dist/src/internal/model-auth/vercel.d.ts +13 -0
- package/dist/src/internal/model-auth/vercel.js +1 -0
- 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-host-fingerprint.js +1 -1
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/workflow-sandbox-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/internal/resolve-model-endpoint-status.d.ts +2 -0
- package/dist/src/internal/resolve-model-endpoint-status.js +1 -1
- package/dist/src/internal/vercel/api-resource.d.ts +4 -0
- package/dist/src/internal/vercel/api-resource.js +1 -0
- package/dist/src/internal/vercel/eve-service-contribution.js +1 -1
- package/dist/src/internal/vercel/vercel-services-config.d.ts +2 -0
- package/dist/src/internal/vercel/vercel-services-config.js +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/local-world-delivery-timeouts.d.ts +1 -1
- package/dist/src/internal/workflow/runtime.d.ts +1 -6
- package/dist/src/internal/workflow/runtime.js +1 -1
- package/dist/src/internal/workflow/vercel-world-defaults.d.ts +4 -0
- package/dist/src/internal/workflow/vercel-world-defaults.js +1 -0
- package/dist/src/protocol/activity.js +1 -1
- package/dist/src/protocol/message.d.ts +8 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/routes.d.ts +0 -2
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/chat-sdk/audience.d.ts +2 -2
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/audience.d.ts +2 -2
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/connections/index.d.ts +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/definitions/connections/mcp.d.ts +1 -1
- package/dist/src/public/definitions/connections/openapi.d.ts +1 -1
- package/dist/src/public/models/anthropic/index.d.ts +3 -0
- package/dist/src/public/models/anthropic/index.js +1 -0
- package/dist/src/public/models/openai/chatgpt/codex-app-server.js +1 -1
- package/dist/src/public/models/openai/chatgpt/credential-store.js +1 -1
- package/dist/src/public/models/openai/chatgpt/oauth.js +1 -1
- package/dist/src/public/models/openai/chatgpt/transport.js +1 -1
- package/dist/src/public/models/openai/index.d.ts +4 -2
- package/dist/src/public/models/openai/index.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +1 -1
- package/dist/src/public/tools/workflow.d.ts +1 -4
- package/dist/src/public/tools/workflow.js +1 -1
- package/dist/src/public/vercel/index.d.ts +2 -1
- package/dist/src/public/vercel/index.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/connections/authorization-tokens.d.ts +2 -4
- package/dist/src/runtime/connections/principal.d.ts +6 -6
- package/dist/src/runtime/connections/principal.js +1 -1
- 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/resolve-tool.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +3 -9
- package/dist/src/self-modification/agent.js +1 -1
- package/dist/src/self-modification/extension/classify-registry-item.d.ts +3 -3
- package/dist/src/self-modification/extension/classify-registry-item.js +1 -1
- package/dist/src/self-modification/extension/tools/search_registry.d.ts +1 -7
- package/dist/src/self-modification/extension/tools/search_registry.js +1 -1
- package/dist/src/self-modification/setup.d.ts +9 -3
- package/dist/src/self-modification/setup.js +2 -2
- package/dist/src/setup/cli/option-row.d.ts +2 -1
- package/dist/src/setup/cli/option-row.js +1 -1
- package/dist/src/setup/cli/prompt-ui.d.ts +2 -0
- package/dist/src/setup/cli/prompt-ui.js +1 -1
- package/dist/src/setup/cli/select-state.d.ts +1 -1
- package/dist/src/setup/cli/select-state.js +1 -1
- package/dist/src/setup/flows/chatgpt-auth.js +1 -1
- package/dist/src/setup/flows/deploy.d.ts +4 -9
- package/dist/src/setup/flows/deploy.js +1 -1
- package/dist/src/setup/flows/ensure-vercel-project.js +1 -1
- package/dist/src/setup/flows/install-vercel-cli.d.ts +2 -3
- package/dist/src/setup/flows/login.d.ts +3 -1
- package/dist/src/setup/flows/login.js +1 -1
- package/dist/src/setup/flows/model-login-connection.d.ts +36 -0
- package/dist/src/setup/flows/model-login-connection.js +1 -0
- package/dist/src/setup/flows/model-login-progress.d.ts +7 -0
- package/dist/src/setup/flows/model-login-progress.js +1 -0
- package/dist/src/setup/flows/model-login.d.ts +22 -0
- package/dist/src/setup/flows/model-login.js +1 -0
- package/dist/src/setup/flows/model-source-change.d.ts +7 -0
- package/dist/src/setup/flows/model-source-change.js +1 -1
- package/dist/src/setup/flows/model.d.ts +6 -24
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/flows/registry.d.ts +3 -19
- package/dist/src/setup/flows/registry.js +1 -1
- package/dist/src/setup/flows/vercel-model-login.d.ts +5 -0
- package/dist/src/setup/flows/vercel-model-login.js +1 -0
- package/dist/src/setup/integrations/self-modification/setup.d.ts +2 -0
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/project-resolution.js +1 -1
- package/dist/src/setup/prompter.d.ts +3 -1
- package/dist/src/setup/provider-settings.d.ts +19 -6
- package/dist/src/setup/provider-settings.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +6 -2
- package/dist/src/setup/vercel-project.js +0 -0
- package/dist/src/setup/with-spinner.d.ts +1 -1
- package/dist/src/setup/with-spinner.js +1 -1
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +6 -4
- package/dist/src/shared/channel-definition.d.ts +2 -2
- package/dist/src/shared/chatgpt-model.d.ts +2 -2
- package/dist/src/shared/chatgpt-model.js +1 -1
- package/dist/src/shared/connection-types.d.ts +20 -7
- package/dist/src/shared/conversation-context.d.ts +15 -0
- package/dist/src/shared/model-connection.d.ts +17 -0
- package/dist/src/shared/model-connection.js +1 -0
- package/dist/src/shared/model-endpoint-status.d.ts +2 -1
- package/dist/src/shared/model-helper.d.ts +26 -0
- package/dist/src/shared/model-helper.js +1 -0
- package/dist/src/shared/package-version.d.ts +2 -0
- package/dist/src/shared/package-version.js +1 -0
- package/dist/src/shared/validate-authorization.js +1 -1
- package/dist/src/shared/vercel-services.d.ts +1 -0
- package/dist/src/shared/vercel-services.js +1 -1
- package/dist/src/shared/workflow-sandbox.d.ts +18 -12
- package/dist/src/shared/workflow-sandbox.js +1 -1
- package/dist/src/source-change/agent-config-ast.d.ts +6 -0
- package/dist/src/source-change/agent-config-ast.js +1 -1
- package/dist/src/source-change/apply-model-selection.d.ts +3 -1
- package/dist/src/source-change/apply-model-selection.js +1 -2
- package/dist/src/source-change/static-source-change.js +1 -1
- package/dist/src/subagents/callback-route.js +1 -1
- package/dist/src/subagents/event-proxy-step.d.ts +3 -3
- package/dist/src/subagents/event-proxy-step.js +1 -1
- package/dist/src/subagents/handle-dispatch.d.ts +12 -2
- package/dist/src/subagents/handle-dispatch.js +1 -1
- package/dist/src/subagents/handles/operation-id.d.ts +1 -1
- package/dist/src/subagents/handles/query.d.ts +0 -6
- package/dist/src/subagents/handles/query.js +1 -1
- package/dist/src/subagents/handles/state-key.d.ts +1 -1
- package/dist/src/subagents/handles/store.d.ts +1 -1
- package/dist/src/subagents/handles/store.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +1 -1
- package/dist/src/subagents/parent-notification.d.ts +2 -2
- package/dist/src/subagents/parent-result.d.ts +1 -1
- package/dist/src/subagents/remote-dispatch.d.ts +1 -1
- package/dist/src/subagents/remote-dispatch.js +1 -1
- package/dist/src/subagents/start-local.js +1 -1
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/session-index.d.ts +11 -0
- package/dist/src/tasks/session-index.js +1 -1
- package/dist/src/tasks/types.d.ts +1 -1
- package/dist/src/tools/auth.d.ts +5 -6
- package/dist/src/tools/provided/workflow.d.ts +12 -0
- package/dist/src/tools/provided/workflow.js +1 -0
- package/dist/src/tools/workflow-program-input.d.ts +6 -0
- package/dist/src/tools/workflow-program-input.js +1 -0
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-runtime-context.d.ts +2 -1
- package/dist/src/tracing/agent-otel-runtime-context.js +1 -1
- package/dist/src/tracing/agent-otel-session-context.js +1 -1
- package/dist/src/tracing/agent-otel-usage.js +1 -1
- package/dist/src/tracing/agent-span-contract.d.ts +1 -0
- package/dist/src/tracing/agent-span-contract.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-context-codec.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +2 -0
- package/dist/src/tracing/content-attributes.js +1 -1
- package/dist/src/tracing/local-instrumentation-runtime.d.ts +1 -1
- package/dist/src/tracing/local-instrumentation-runtime.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +23 -23
- package/docs/channels/chat-sdk.mdx +11 -2
- package/docs/channels/custom.mdx +32 -16
- package/docs/channels/eve.mdx +21 -19
- package/docs/channels/linear.mdx +7 -3
- package/docs/channels/linq.mdx +1 -1
- package/docs/channels/overview.mdx +17 -2
- package/docs/channels/photon.mdx +4 -1
- package/docs/channels/slack.mdx +12 -2
- package/docs/concepts/execution-model-and-durability.mdx +62 -13
- package/docs/concepts/sessions-runs-and-streaming.md +14 -5
- package/docs/connections/mcp.mdx +4 -1
- package/docs/connections/openapi.mdx +8 -2
- package/docs/connections/overview.mdx +16 -13
- package/docs/getting-started.mdx +8 -4
- package/docs/guides/deployment/self-hosting.md +1 -1
- package/docs/guides/deployment/vercel.mdx +3 -3
- package/docs/guides/dev-tui.md +58 -31
- package/docs/guides/dynamic-capabilities.md +4 -4
- package/docs/guides/frontend/overview.mdx +3 -1
- package/docs/guides/hooks.md +1 -1
- package/docs/guides/instrumentation/meta.json +5 -0
- package/docs/guides/instrumentation/otel.mdx +149 -0
- package/docs/guides/instrumentation/overview.md +199 -0
- package/docs/guides/instrumentation/providers.mdx +169 -0
- package/docs/guides/meta.json +0 -1
- package/docs/guides/remote-agents.md +19 -21
- package/docs/install-integrations.mdx +2 -4
- package/docs/memory/custom-provider.md +1 -1
- package/docs/patterns/multi-tenant-auth.md +3 -3
- package/docs/protocols/acp.md +1 -1
- package/docs/reference/cli.md +16 -16
- package/docs/reference/telemetry.md +1 -1
- package/docs/reference/typescript-api.md +21 -14
- package/docs/sandbox.mdx +3 -3
- package/docs/subagents/index.mdx +4 -4
- package/docs/tools/workflows.mdx +57 -2
- package/docs/tutorial/how-it-runs.mdx +1 -1
- package/package.json +6 -1
- package/dist/src/cli/commands/init-repl.d.ts +0 -80
- package/dist/src/cli/commands/init-repl.js +0 -1
- package/dist/src/cli/commands/init-self-modification.d.ts +0 -7
- package/dist/src/cli/commands/init-self-modification.js +0 -1
- package/dist/src/cli/commands/registry-package.d.ts +0 -52
- package/dist/src/cli/commands/registry-package.js +0 -1
- package/dist/src/cli/dev/tui/prompt-placeholder.d.ts +0 -12
- package/dist/src/cli/dev/tui/prompt-placeholder.js +0 -1
- package/dist/src/cli/dev/tui/remote-auth-command.d.ts +0 -11
- package/dist/src/cli/dev/tui/remote-auth-command.js +0 -3
- package/dist/src/compiled/_chunks/workflow/attribute-changes-BAcgmlXp.js +0 -20
- package/dist/src/compiled/_chunks/workflow/private-CFJkQA7R.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-BEHe0Uut.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-ChHLjaCt.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-BB2HuVie.js +0 -1
- package/dist/src/execution/accepted-delivery-deployment.d.ts +0 -7
- package/dist/src/execution/accepted-delivery-deployment.js +0 -1
- package/dist/src/execution/dispatch-turn-step.d.ts +0 -5
- package/dist/src/execution/dispatch-turn-step.js +0 -1
- package/dist/src/execution/durable-session-migrations/chain.d.ts +0 -38
- package/dist/src/execution/durable-session-migrations/chain.js +0 -1
- package/dist/src/execution/durable-session-migrations/snapshot.d.ts +0 -6
- package/dist/src/execution/durable-session-migrations/snapshot.js +0 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow-v0-to-v1.d.ts +0 -12
- package/dist/src/execution/durable-session-migrations/turn-workflow-v0-to-v1.js +0 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow-v1-to-v2.d.ts +0 -2
- package/dist/src/execution/durable-session-migrations/turn-workflow-v1-to-v2.js +0 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow.d.ts +0 -88
- package/dist/src/execution/durable-session-migrations/turn-workflow.js +0 -1
- package/dist/src/execution/forward-turn-cancellation-step.d.ts +0 -6
- package/dist/src/execution/forward-turn-cancellation-step.js +0 -1
- package/dist/src/execution/forward-turn-delivery-step.d.ts +0 -6
- package/dist/src/execution/forward-turn-delivery-step.js +0 -1
- package/dist/src/execution/inline-turn.d.ts +0 -31
- package/dist/src/execution/inline-turn.js +0 -1
- package/dist/src/execution/next-driver-action.d.ts +0 -93
- package/dist/src/execution/parked-delivery-wait.d.ts +0 -54
- package/dist/src/execution/parked-delivery-wait.js +0 -1
- package/dist/src/execution/session-command-inbox.d.ts +0 -52
- package/dist/src/execution/session-command-inbox.js +0 -1
- package/dist/src/execution/session-command-token.d.ts +0 -6
- package/dist/src/execution/session-command-token.js +0 -1
- package/dist/src/execution/session-state-cursor.d.ts +0 -25
- package/dist/src/execution/session-state-cursor.js +0 -1
- package/dist/src/execution/session-timeout-control.js +0 -1
- package/dist/src/execution/session-timeout-steps.js +0 -1
- package/dist/src/execution/session-timeout-workflow.js +0 -1
- package/dist/src/execution/session-timeout.d.ts +0 -2
- package/dist/src/execution/session-timeout.js +0 -1
- package/dist/src/execution/turn-cancellation-control.d.ts +0 -30
- package/dist/src/execution/turn-cancellation-control.js +0 -1
- package/dist/src/execution/turn-cancellation-token.d.ts +0 -10
- package/dist/src/execution/turn-cancellation-token.js +0 -1
- package/dist/src/execution/turn-control-protocol.d.ts +0 -36
- package/dist/src/execution/turn-control-protocol.js +0 -1
- package/dist/src/execution/turn-control-receiver.d.ts +0 -54
- package/dist/src/execution/turn-control-receiver.js +0 -1
- package/dist/src/execution/turn-dispatch.d.ts +0 -39
- package/dist/src/execution/turn-dispatch.js +0 -1
- package/dist/src/execution/turn-execution-cursor.d.ts +0 -49
- package/dist/src/execution/turn-execution-cursor.js +0 -1
- package/dist/src/execution/turn-workflow-tool-run.js +0 -1
- package/dist/src/execution/turn-workflow.d.ts +0 -13
- package/dist/src/execution/turn-workflow.js +0 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +0 -38
- package/dist/src/execution/wire/session-inbox-contract.js +0 -1
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +0 -47
- package/dist/src/execution/wire/session-inbox-encoder.js +0 -1
- package/dist/src/execution/wire/session-inbox-resume.d.ts +0 -12
- package/dist/src/execution/wire/session-inbox-resume.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.d.ts +0 -29
- package/dist/src/execution/wire/session-inbox-wire.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v0.d.ts +0 -5
- package/dist/src/execution/wire/session-inbox-wire.v0.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v1.d.ts +0 -237
- package/dist/src/execution/wire/session-inbox-wire.v1.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v2-migration.d.ts +0 -2
- package/dist/src/execution/wire/session-inbox-wire.v2-migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v2.d.ts +0 -478
- package/dist/src/execution/wire/session-inbox-wire.v2.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v2.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v2.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v3.d.ts +0 -480
- package/dist/src/execution/wire/session-inbox-wire.v3.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v3.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v3.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v4.d.ts +0 -267
- package/dist/src/execution/wire/session-inbox-wire.v4.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v5.d.ts +0 -341
- package/dist/src/execution/wire/session-inbox-wire.v5.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v5.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v5.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v6.d.ts +0 -341
- package/dist/src/execution/wire/session-inbox-wire.v6.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v7.d.ts +0 -342
- package/dist/src/execution/wire/session-inbox-wire.v7.js +0 -1
- package/dist/src/execution/workflow-entry-crash.d.ts +0 -39
- package/dist/src/execution/workflow-entry-crash.js +0 -1
- package/dist/src/execution/workflow-entry-finalization.d.ts +0 -28
- package/dist/src/execution/workflow-entry-finalization.js +0 -1
- package/dist/src/execution/workflow-entry.d.ts +0 -37
- package/dist/src/execution/workflow-entry.js +0 -1
- package/dist/src/execution/workflow-steps.js +0 -1
- package/dist/src/harness/workflow-continuation-security.d.ts +0 -5
- package/dist/src/harness/workflow-continuation-security.js +0 -1
- package/dist/src/harness/workflow-interrupt-state.d.ts +0 -20
- package/dist/src/harness/workflow-interrupt-state.js +0 -1
- package/dist/src/harness/workflow-lifecycle.d.ts +0 -32
- package/dist/src/harness/workflow-lifecycle.js +0 -1
- package/dist/src/harness/workflow-sandbox.d.ts +0 -28
- package/dist/src/harness/workflow-sandbox.js +0 -2
- package/dist/src/harness/workflow-subagent-limit.d.ts +0 -28
- package/dist/src/harness/workflow-subagent-limit.js +0 -1
- package/dist/src/harness/workflow-task-state.d.ts +0 -9
- package/dist/src/harness/workflow-task-state.js +0 -1
- package/dist/src/harness/workflow-tool-description.d.ts +0 -22
- package/dist/src/harness/workflow-tool-description.js +0 -37
- package/dist/src/subagents/handles/rebase.d.ts +0 -4
- package/dist/src/subagents/handles/rebase.js +0 -1
- package/dist/src/tools/workflow.d.ts +0 -37
- package/dist/src/tools/workflow.js +0 -1
- package/docs/guides/instrumentation-providers.md +0 -249
- package/docs/guides/instrumentation.md +0 -453
- /package/dist/src/{execution/next-driver-action.js → client/eve-agent-store-state.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler}from"#channel/adapter.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";async function emitTaskSubagentCalledStep(e){"use step";let t=await deserializeContext(e.serializedContext),n=t.require(ChannelKey),r=await callAdapterEventHandler(n,e.event,buildAdapterContext(n,t)),i=e.
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";async function emitTaskSubagentCalledStep(e){"use step";let t=await deserializeContext(e.serializedContext),n=t.require(ChannelKey),r=await callAdapterEventHandler(n,e.event,buildAdapterContext(n,t)),i=e.sessionWritable.getWriter();try{await i.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))}finally{i.releaseLock()}return{serializedContext:serializeContext(t)}}export{emitTaskSubagentCalledStep};
|
|
@@ -12,7 +12,7 @@ export type InternalAgentInput = {
|
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Asks the owning session to spawn an agent for a workflow tool run. Spawning
|
|
15
|
-
* needs owner-held material (auth, capabilities,
|
|
15
|
+
* needs owner-held material (auth, capabilities, the agent handle
|
|
16
16
|
* store) that a workflow tool body never has.
|
|
17
17
|
*/
|
|
18
18
|
export interface AgentInvocationRequest {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionCommandHookToken}from"#execution/session-
|
|
1
|
+
import{sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{createHook}from"#compiled/@workflow/core/index.js";import{disposeHook}from"#execution/hook-ownership.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{readWorkflowToolRunOwner,readWorkflowToolRunRef}from"#execution/tools/workflow/ask.js";async function agent(e,t,n){return readWorkflowToolRunRef(e),validateAgentInput({...n,target:t}),await invokeAgent(e,{agentId:n.agentId,message:n.message,outputSchema:n.outputSchema,target:t})}async function invokeAgent(e,t,n={}){validateAgentInput(t);let r=readWorkflowToolRunRef(e),i=readWorkflowToolRunOwner(e),a=createHook(),o=n.invocationId??`${e.callId}:${a.token}`;try{await resumeHookStep(i.inbox,{kind:`request`,from:r,replyTo:a.token,request:{input:t,invocationId:o,kind:`agent-invoke`}});let s=a[Symbol.asyncIterator]();for(;;){let t=await nextAgentReply(s,e.abortSignal);if(t.done)break;let c=t.value;if(c.kind===`runtime-action-result`){let e=c.results.find(e=>e.kind===`subagent-result`&&e.callId===o);if(e!==void 0){if(e.origin===`child`&&await resumeHookStep(i.inbox,{kind:`request`,from:r,replyTo:a.token,request:{kind:`agent-settled`,result:e}}),n.returnResult===!0&&r.execution===`blocking`)return e;if(e.isError===!0)throw e.output;return e.output}continue}if(c.kind===`subagent-input-request`){await resumeHookStep(i.inbox,{kind:`request`,from:r,replyTo:c.childSessionInbox?.sessionId===c.childSessionId?sessionInboxHookToken(sessionCommandHookToken(c.childSessionInbox.sessionId)):c.childContinuationToken,request:{kind:`input-batch`,requests:c.event.requests},requestCoordinates:{sequence:c.event.sequence,stepIndex:c.event.stepIndex,turnId:c.event.turnId}});continue}await resumeHookStep(i.inbox,{kind:`request`,from:r,replyTo:a.token,request:{event:c,kind:`authorization-request`}})}}finally{try{await disposeHook(a)}catch{}}throw Error(`Agent "${t.target}" closed without a result.`)}async function nextAgentReply(e,t){if(t===void 0)return await e.next();if(t.aborted)throw t.reason;let n,r=new Promise((e,t)=>{n=t}),abort=()=>n?.(t.reason);t.addEventListener(`abort`,abort,{once:!0});try{return await Promise.race([e.next(),r])}finally{t.removeEventListener(`abort`,abort)}}function validateAgentInput(e){if(typeof e.target!=`string`||e.target.trim()===``)throw TypeError(`agent() requires a non-empty agent name as its first argument.`);if(typeof e.message!=`string`||e.message.trim()===``)throw TypeError("agent() requires a non-empty `message`.")}export{agent,invokeAgent,validateAgentInput};
|
|
@@ -27,6 +27,7 @@ export declare function prepareOwnerAgentInvocation(input: {
|
|
|
27
27
|
readonly knownAgentIds?: readonly string[];
|
|
28
28
|
readonly serializedContext: Record<string, unknown>;
|
|
29
29
|
readonly sessionState: DurableSessionState;
|
|
30
|
+
readonly taskId?: string;
|
|
30
31
|
}): Promise<Omit<PreparedCoordinationDispatch<OwnerAgentDispatchPlanEntry>, "sessionState">>;
|
|
31
32
|
export declare function planAgentDispatch(input: {
|
|
32
33
|
readonly action: RuntimeAgentDispatchRequest;
|
|
@@ -35,3 +36,8 @@ export declare function planAgentDispatch(input: {
|
|
|
35
36
|
readonly knownAgentIds?: readonly string[];
|
|
36
37
|
readonly session: RuntimeSession;
|
|
37
38
|
}): OwnerAgentDispatchPlanEntry;
|
|
39
|
+
export declare function resolveAgentInvocationAction(input: {
|
|
40
|
+
readonly ctx: ContextReader;
|
|
41
|
+
readonly input: AgentInvocationRequest["input"];
|
|
42
|
+
readonly invocationId: string;
|
|
43
|
+
}): RuntimeAgentDispatchRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{SessionDynamicSubagentSelectionsKey,TurnDynamicSubagentSelectionsKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{activeTurnId}from"#harness/active-turn-id.js";import{prepareActionDispatch}from"#execution/coordination-dispatch-shared.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{AGENT_TOOL_DESCRIPTION,AGENT_TOOL_NAME}from"#tools/framework/agent-contract.js";import{isAgentHandleAction}from"#subagents/handle-dispatch.js";import{createRecursiveAgentRootOnlyResult,createUnavailableDynamicSubagentResult,getSubagentName}from"#execution/dispatch-action-failures.js";const log=createLogger(`execution.agent-invocation`);async function prepareOwnerAgentInvocation(e){let t=
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{SessionDynamicSubagentSelectionsKey,TurnDynamicSubagentSelectionsKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{activeTurnId}from"#harness/active-turn-id.js";import{prepareActionDispatch}from"#execution/coordination-dispatch-shared.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{AGENT_TOOL_DESCRIPTION,AGENT_TOOL_NAME}from"#tools/framework/agent-contract.js";import{isAgentHandleAction}from"#subagents/handle-dispatch.js";import{createRecursiveAgentRootOnlyResult,createUnavailableDynamicSubagentResult,getSubagentName}from"#execution/dispatch-action-failures.js";const log=createLogger(`execution.agent-invocation`);async function prepareOwnerAgentInvocation(e){let t=readDurableSession(e.sessionState),n=await deserializeContext(e.serializedContext),r=getHarnessEmissionState(t.state),i=e.taskId===void 0?void 0:findSessionTaskEntry(t.state,e.taskId),a=resolveAgentInvocationAction({ctx:n,input:e.invocation,invocationId:e.invocationId});return await prepareActionDispatch({batch:{requests:[a],event:{...r,stepIndex:i?.createdByStepIndex??r.stepIndex,turnId:i?.createdByTurnId??activeTurnId(r)}},ctx:n,durableSession:t,fanoutSize:1,plan:({bundle:t,ctx:n,session:r})=>[planAgentDispatch({action:a,bundle:t,ctx:n,knownAgentIds:e.knownAgentIds,session:r})],planSharesSandbox:({bundle:e,plan:t})=>ownerPlanSharesSandbox({bundle:e,plan:t}),serializedContext:e.serializedContext})}function planAgentDispatch(e){let t=new Set(e.knownAgentIds??(getAgentHandleStore(e.session.state)?.handles??[]).map(e=>e.identity.id)),n=e.action.input.agentId,r=typeof n==`string`&&n.trim()!==``?n:void 0;if(r!==void 0&&isAgentHandleAction(e.action)){if(t.has(r)){let t=e.bundle.subagentRegistry.dynamicNodeIds?.has(e.action.nodeId)===!0?getDynamicSubagentSelection(e.ctx,e.action.nodeId):void 0;return{action:e.action,agentId:r,dynamicRemoteAgent:e.action.kind===`remote-agent-call`&&t?.kind===`remote`?t.remoteAgent:void 0,kind:`resume`}}log.warn(`unknown agentId on subagent call; starting a new agent`,{agentId:r,callId:e.action.callId})}return classifyFreshStart(e)}function classifyFreshStart(e){let{action:t}=e,n=e.bundle.subagentRegistry.subagentsByNodeId,r=e.bundle.subagentRegistry.dynamicNodeIds?.has(t.nodeId)===!0,i=r?getDynamicSubagentSelection(e.ctx,t.nodeId):void 0;if(r&&(i===void 0||t.kind===`subagent-call`&&i.kind!==`subagent`||t.kind===`remote-agent-call`&&i.kind!==`remote`))return log.warn(`dynamic subagent call blocked after availability changed`,{callId:t.callId,nodeId:t.nodeId,subagentName:getSubagentName(t)}),{kind:`reject`,result:createUnavailableDynamicSubagentResult(t)};if(isRecursiveAgentAction(t,n)&&e.session.rootSessionId!==void 0)return log.warn(`recursive agent call blocked outside the root session`,{callId:t.callId,nodeId:t.nodeId,rootSessionId:e.session.rootSessionId,subagentName:t.subagentName}),{kind:`reject`,result:createRecursiveAgentRootOnlyResult(t)};if(t.kind===`remote-agent-call`)return{kind:`start`,target:{action:t,dynamicRemoteAgent:i?.kind===`remote`?i.remoteAgent:void 0,kind:`remote`}};let a=i?.kind===`subagent`?i.agentConfig:void 0,o=n.get(t.nodeId),s=a?.description??(o?.definition.kind===`subagent`?o.definition.description:void 0);return{kind:`start`,target:{action:t,dynamicSubagentAgentConfig:a,kind:`local`,source:s===void 0?{outputSchema:e.bundle.turnAgent.outputSchema,type:`runtime`}:{description:s,outputSchema:a?.outputSchema??e.bundle.graph?.nodesByNodeId.get(t.nodeId)?.turnAgent?.outputSchema,type:`local`}}}}function ownerPlanSharesSandbox(e){return e.plan.some(t=>{if(t.kind!==`start`||t.target.kind!==`local`)return!1;let n=t.target.action;return n.subagentName===`agent`&&!e.bundle.subagentRegistry.subagentsByNodeId.has(n.nodeId)||e.bundle.graph?.nodesByNodeId.get(n.nodeId)?.sandboxRegistry.sandbox.definition.inheritsParent===!0})}function isRecursiveAgentAction(e,t){return e.kind===`subagent-call`&&e.subagentName===`agent`&&!t.has(e.nodeId)}function resolveAgentInvocationAction(e){let t=e.ctx.require(BundleKey),n=t.subagentRegistry.subagentsByName.get(e.input.target),r=n===void 0?Object.values({...e.ctx.get(SessionDynamicSubagentSelectionsKey),...e.ctx.get(TurnDynamicSubagentSelectionsKey)}).find(t=>t!==null&&t.prepared?.name===e.input.target):void 0,i=n?.definition??r?.prepared??(e.input.target===AGENT_TOOL_NAME&&t.nodeId===void 0?{description:AGENT_TOOL_DESCRIPTION,kind:`subagent`,name:AGENT_TOOL_NAME,nodeId:ROOT_RUNTIME_AGENT_NODE_ID}:void 0);if(i===void 0)throw Error(`Agent target "${e.input.target}" is not available to this agent.`);let a={message:e.input.message};e.input.agentId!==void 0&&(a.agentId=e.input.agentId),e.input.outputSchema!==void 0&&(a.outputSchema=e.input.outputSchema);let o={callId:e.invocationId,description:i.description??``,input:a,name:i.name,nodeId:i.nodeId};return i.kind===`remote`?{...o,kind:`remote-agent-call`,remoteAgentName:i.name}:{...o,kind:`subagent-call`,subagentName:i.name}}export{planAgentDispatch,prepareOwnerAgentInvocation,resolveAgentInvocationAction};
|
|
@@ -31,6 +31,8 @@ export declare function dispatchAgentInvocation(input: {
|
|
|
31
31
|
readonly serializedContext: Record<string, unknown>;
|
|
32
32
|
readonly sessionState: DurableSessionState;
|
|
33
33
|
readonly ownerId: string;
|
|
34
|
+
/** Optional creator snapshot used only to prepare this invocation. */
|
|
35
|
+
readonly invocationContext?: Record<string, unknown>;
|
|
34
36
|
readonly taskId?: string | undefined;
|
|
35
37
|
}): Promise<AgentInvocationDispatchResult>;
|
|
36
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSubagentCalledEvent}from"#protocol/message.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{projectToDurableSession}from"#execution/session.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{clearProxyInputRequestsForChild,clearProxyInputRequestsForTask}from"#harness/proxy-input-requests.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{abandonAgentInvocationOwners,applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{accumulateSessionUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{isTerminalTaskStatus}from"#tasks/types.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{createSubagentReceiptIdentity}from"#execution/tools/subagent/receipt-identity.js";import{createAgentErrorResult,dispatchToClaimedAgentAddress}from"#subagents/handle-dispatch.js";import{createAgentContinuationBundle}from"#subagents/continuation-bundle.js";import{startSubagent}from"#execution/tools/subagent/start.js";import{prepareOwnerAgentInvocation}from"#execution/tools/subagent/invoke-preparation.js";import{prepareAgentInvocationTrace}from"#tracing/agent-invocation-coordinator.js";import{flushAgentInvocationTraces,settleAgentInvocationTrace}from"#tracing/agent-invocation-terminal.js";async function dispatchAgentInvocation(e){let t=await readDurableSession(e.sessionState),n=getAgentHandleStore(t.state)?.handles??[],r=await prepareOwnerAgentInvocation({invocation:e.request.input,invocationId:e.request.invocationId,knownAgentIds:n.map(e=>e.identity.id),serializedContext:e.serializedContext,sessionState:e.sessionState}),i=r.plan[0];if(i===void 0)throw Error(`Agent invocation produced no executable plan entry.`);if(i.kind===`reject`)return{kind:`failed`,result:i.result,serializedContext:r.serializedContext,sessionState:e.sessionState};let a=i.kind===`start`?i.target.action:i.action,o=prepareAgentInvocationTrace({conversation:r.inheritedConversation,invocation:a,ownerId:e.ownerId,serializedContext:r.serializedContext,sessionId:r.session.sessionId,sessionState:t.state,startTimeMs:Date.now(),taskId:e.taskId,turnId:r.batch.event.turnId}),s=r.activityObserver===void 0||e.activityWorkIdentity===void 0?void 0:{sink:r.activityObserver.sink,workIdentity:e.activityWorkIdentity},c=r.session,currentAgentHandles=()=>getAgentHandleStore(c.state)?.handles??[],sessionState=()=>replaceDurableSessionSnapshot({session:projectToDurableSession(c),state:e.sessionState}),failed=async e=>({kind:`failed`,result:e,serializedContext:await flushAgentInvocationTraces(o.fail(e)),sessionState:sessionState()}),applyHandleCommand=e=>{let t=applyTaskAgentHandleCommand(c,e);return c=t.session,t.result},l,u;if(i.kind===`resume`){let t=currentAgentHandles().filter(t=>t.phase===`claimed`&&t.ownerId===e.ownerId&&t.callId===i.action.callId&&t.identity.id===i.agentId);if(t.length>1)throw Error(`Invocation owner "${e.ownerId}" has multiple claims for "${i.action.callId}".`);let n=t[0];if(n===void 0){let t=deriveAgentOperationId({callId:i.action.callId,parentSessionId:r.session.sessionId,parentTurnId:r.batch.event.turnId}),a=applyHandleCommand({agentId:i.agentId,callId:i.action.callId,expectedTarget:i.action.kind===`remote-agent-call`?`remote`:`local`,invokedName:i.action.kind===`remote-agent-call`?i.action.remoteAgentName:i.action.subagentName,kind:`claim`,operationId:t,ownerId:e.ownerId});if(n=readClaimedHandle(a),n===void 0)return failed(createTaskClaimError(i.action,i.agentId,a))}let a=createAgentContinuationBundle({action:i.action,bundle:r.bundle,dynamicRemoteAgent:i.dynamicRemoteAgent});l=await dispatchToClaimedAgentAddress({activityObserver:s,action:i.action,auth:r.auth,bundle:a,currentSession:c,parentToken:e.replyTo,handle:n,taskId:e.taskId}),l.kind===`error`&&l.deliveryPermanent===!0&&applyHandleCommand({agentId:i.agentId,kind:`remove`,ownerId:e.ownerId}),u=n.identity.id}else{let t=i.target.action,n=currentAgentHandles().filter(n=>n.phase===`reserved`&&n.ownerId===e.ownerId&&n.callId===t.callId&&n.identity.name===t.name&&n.identity.nodeId===t.nodeId),a=n.length===1?{identity:n[0].identity,operation:{id:n[0].operationId}}:createSubagentReceiptIdentity({callId:t.callId,subagentName:t.kind===`remote-agent-call`?t.remoteAgentName:t.subagentName,nodeId:t.nodeId,parentSessionId:r.session.sessionId,parentTurnId:r.batch.event.turnId});if(n.length>1)throw Error(`Invocation owner "${e.ownerId}" has multiple reservations for "${t.callId}".`);if(n.length===0&&applyHandleCommand({identity:a.identity,callId:t.callId,kind:`reserve`,operationId:a.operation.id,ownerId:e.ownerId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${a.operation.id}".`);if(l=await startSubagent({auth:r.auth,batchEvent:r.batch.event,bundle:r.bundle,callbackBaseUrl:e.callbackBaseUrl,capabilities:r.capabilities,channelMetadata:r.channelMetadata,inheritedConversation:r.inheritedConversation,currentSession:c,fanoutSize:r.fanoutSize,initiatorAuth:r.initiatorAuth,localDevRequest:r.localDevRequest,parentContinuationToken:e.replyTo,activityObserver:r.activityObserver,taskActivityObserver:s,sandboxSessionId:r.sandboxSessionId,session:c,taskId:e.taskId,target:i.target,trace:o.dispatch}),u=a.identity.id,l.kind===`error`)applyHandleCommand({agentId:u,kind:`remove`,ownerId:e.ownerId});else if(readClaimedHandle(applyHandleCommand({address:l.address,kind:`confirm`,operationId:a.operation.id,ownerId:e.ownerId}))===void 0)throw Error(`Agent handle store could not confirm start operation "${a.operation.id}".`)}if(l.kind===`error`)return failed(l.result);let d=i.kind===`resume`?i.action:i.target.action,f=i.kind===`resume`?i.dynamicRemoteAgent:i.target.kind===`remote`?i.target.dynamicRemoteAgent:void 0,p=createSubagentCalledEvent({agentId:u,callId:l.callId,childSessionId:l.address.sessionId,name:l.name,remote:l.address.kind===`agent/remote`?{resolverId:f===void 0?d.nodeId:f.credentialsStepId,url:l.address.url}:void 0,sequence:r.batch.event.sequence,sessionId:r.session.sessionId,toolName:l.toolName,turnId:r.batch.event.turnId,workflowId:workflowEntryReference.workflowId});return e.emit!==void 0&&await e.emit(p),{kind:`dispatched`,agentId:u,event:p,serializedContext:o.serializedContext,sessionState:sessionState()}}async function dispatchTaskAgentInvocationStep(e){"use step";let t;if(e.taskId!==void 0){let n=await readDurableSession(e.sessionState),r=findSessionTaskEntry(n.state,e.taskId);if(r===void 0)return{kind:`not-admitted`,sessionState:e.sessionState};let i=await readLatestTaskView({taskRunId:r.taskRunId});if(i===void 0||isTerminalTaskStatus(i.status))return{kind:`not-admitted`,sessionState:e.sessionState};r.metadata.kind===`subagent`&&(t=r.activityWorkIdentity)}return await dispatchAgentInvocation({...e,activityWorkIdentity:t,callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url)})}async function settleTaskAgentInvocationStep(e){"use step";let t=await readDurableSession(e.sessionState),n=await flushAgentInvocationTraces(settleAgentInvocationTrace({acceptedAtMs:Date.now(),result:e.result,serializedContext:e.serializedContext,sessionId:t.sessionId})),r=getAgentHandleStore(t.state)?.handles??[],i=r.filter(t=>t.phase===`claimed`&&t.ownerId===e.ownerId),a=i.find(t=>t.phase===`claimed`&&t.callId===e.result.callId)??(i.length===1?i[0]:void 0);if(a?.phase!==`claimed`)return{serializedContext:n,sessionState:e.sessionState};let o=e.result.outcome.kind===`terminal`?r.filter(e=>e!==a):r.map(t=>t===a?e.result.outcome.result.kind===`cancelled`?{address:a.address,identity:a.identity,lastStatus:`(cancelled)`,phase:`parked`}:{address:a.address,identity:a.identity,phase:`available`}:t),s=writeHandles(t,o);return e.result.outcome.kind===`terminal`&&(s=e.taskId===void 0?`continuationToken`in a.address?clearProxyInputRequestsForChild(s,a.address.continuationToken):s:clearProxyInputRequestsForTask(s,e.taskId)),e.accumulateUsage!==!1&&(s=setTurnUsageState(s,accumulateSessionUsage({previous:getTurnUsageState(s.state),usage:e.result.outcome.usageDelta}))),{serializedContext:n,sessionState:replaceDurableSessionSnapshot({session:s,state:e.sessionState})}}async function releaseAgentInvocationOwnerStep(e){"use step";let t=await readDurableSession(e.sessionState),n=e.cancelled?abandonAgentInvocationOwners(t,new Set([e.ownerId])):applyTaskAgentHandleCommand(t,{kind:`release-owner`,ownerId:e.ownerId}).session;return{sessionState:n===t?e.sessionState:replaceDurableSessionSnapshot({session:n,state:e.sessionState})}}function readClaimedHandle(e){let t=e.kind===`ready`?e.handle:void 0;return t?.phase===`claimed`?t:void 0}function createTaskClaimError(e,t,n){return n.kind===`mismatch`?createAgentErrorResult({action:e,code:AGENT_MISMATCH,message:`Agent "${t}" no longer matches this subagent definition. Start a new agent instead.`}):n.kind===`busy`?createAgentErrorResult({action:e,code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:t,agentName:n.handle.identity.name,ownerId:`ownerId`in n.handle?n.handle.ownerId:void 0})}):createAgentErrorResult({action:e,code:AGENT_UNREACHABLE,message:`Agent with id "${t}" is no longer reachable.`})}export{dispatchAgentInvocation,dispatchTaskAgentInvocationStep,releaseAgentInvocationOwnerStep,settleTaskAgentInvocationStep};
|
|
1
|
+
import{AuthKey,InitiatorAuthKey,SessionDynamicSubagentSelectionsKey,TurnDynamicSubagentSelectionsKey}from"#context/keys.js";import{createSubagentCalledEvent}from"#protocol/message.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{projectToDurableSession}from"#execution/session.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{clearProxyInputRequestsForChild,clearProxyInputRequestsForTask}from"#harness/proxy-input-requests.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{accumulateSessionUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{abandonAgentInvocationOwners,applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{isTerminalTaskStatus}from"#tasks/types.js";import{createSubagentReceiptIdentity}from"#execution/tools/subagent/receipt-identity.js";import{createAgentErrorResult,dispatchToClaimedAgentAddress}from"#subagents/handle-dispatch.js";import{createAgentContinuationBundle}from"#subagents/continuation-bundle.js";import{startSubagent}from"#execution/tools/subagent/start.js";import{prepareOwnerAgentInvocation}from"#execution/tools/subagent/invoke-preparation.js";import{prepareAgentInvocationTrace}from"#tracing/agent-invocation-coordinator.js";import{flushAgentInvocationTraces,settleAgentInvocationTrace}from"#tracing/agent-invocation-terminal.js";async function dispatchAgentInvocation(e){let t=readDurableSession(e.sessionState),n=getAgentHandleStore(t.state)?.handles??[],r=await prepareOwnerAgentInvocation({invocation:e.request.input,invocationId:e.request.invocationId,knownAgentIds:n.map(e=>e.identity.id),serializedContext:e.invocationContext??e.serializedContext,sessionState:e.sessionState,taskId:e.taskId}),i=r.plan[0];if(i===void 0)throw Error(`Agent invocation produced no executable plan entry.`);if(i.kind===`reject`)return{kind:`failed`,result:i.result,serializedContext:e.serializedContext,sessionState:e.sessionState};let a=i.kind===`start`?i.target.action:i.action,o=prepareAgentInvocationTrace({conversation:r.inheritedConversation,invocation:a,ownerId:e.ownerId,serializedContext:e.serializedContext,sessionId:r.session.sessionId,sessionState:t.state,startTimeMs:Date.now(),taskId:e.taskId,turnId:r.batch.event.turnId}),s=r.activityObserver===void 0||e.activityWorkIdentity===void 0?void 0:{sink:r.activityObserver.sink,workIdentity:e.activityWorkIdentity},c=r.session,currentAgentHandles=()=>getAgentHandleStore(c.state)?.handles??[],sessionState=()=>replaceDurableSessionSnapshot({session:projectToDurableSession(c),state:e.sessionState}),failed=async e=>({kind:`failed`,result:e,serializedContext:await flushAgentInvocationTraces(o.fail(e)),sessionState:sessionState()}),applyHandleCommand=e=>{let t=applyTaskAgentHandleCommand(c,e);return c=t.session,t.result},l,u;if(i.kind===`resume`){let t=currentAgentHandles().filter(t=>t.phase===`claimed`&&t.ownerId===e.ownerId&&t.callId===i.action.callId&&t.identity.id===i.agentId);if(t.length>1)throw Error(`Invocation owner "${e.ownerId}" has multiple claims for "${i.action.callId}".`);let n=t[0];if(n===void 0){let t=deriveAgentOperationId({callId:i.action.callId,parentSessionId:r.session.sessionId,parentTurnId:r.batch.event.turnId}),a=applyHandleCommand({agentId:i.agentId,callId:i.action.callId,expectedTarget:i.action.kind===`remote-agent-call`?`remote`:`local`,invokedName:i.action.kind===`remote-agent-call`?i.action.remoteAgentName:i.action.subagentName,kind:`claim`,operationId:t,ownerId:e.ownerId});if(n=readClaimedHandle(a),n===void 0)return failed(createTaskClaimError(i.action,i.agentId,a))}let a=createAgentContinuationBundle({action:i.action,bundle:r.bundle,dynamicRemoteAgent:i.dynamicRemoteAgent});l=await dispatchToClaimedAgentAddress({activityObserver:s,action:i.action,auth:r.auth,bundle:a,currentSession:c,handle:n,reply:e.taskId===void 0?{kind:`reply`,parentToken:e.replyTo}:{kind:`reply`,parentToken:e.replyTo,taskId:e.taskId}}),l.kind===`error`&&l.deliveryPermanent===!0&&applyHandleCommand({agentId:i.agentId,kind:`remove`,ownerId:e.ownerId}),u=n.identity.id}else{let t=i.target.action,n=currentAgentHandles().filter(n=>n.phase===`reserved`&&n.ownerId===e.ownerId&&n.callId===t.callId&&n.identity.name===t.name&&n.identity.nodeId===t.nodeId),a=n.length===1?{identity:n[0].identity,operation:{id:n[0].operationId}}:createSubagentReceiptIdentity({callId:t.callId,subagentName:t.kind===`remote-agent-call`?t.remoteAgentName:t.subagentName,nodeId:t.nodeId,parentSessionId:r.session.sessionId,parentTurnId:r.batch.event.turnId});if(n.length>1)throw Error(`Invocation owner "${e.ownerId}" has multiple reservations for "${t.callId}".`);if(n.length===0&&applyHandleCommand({identity:a.identity,callId:t.callId,kind:`reserve`,operationId:a.operation.id,ownerId:e.ownerId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${a.operation.id}".`);if(l=await startSubagent({auth:r.auth,batchEvent:r.batch.event,bundle:r.bundle,callbackBaseUrl:e.callbackBaseUrl,capabilities:r.capabilities,channelMetadata:r.channelMetadata,inheritedConversation:r.inheritedConversation,currentSession:c,fanoutSize:r.fanoutSize,initiatorAuth:r.initiatorAuth,localDevRequest:r.localDevRequest,parentContinuationToken:e.replyTo,activityObserver:r.activityObserver,taskActivityObserver:s,sandboxSessionId:r.sandboxSessionId,session:c,taskId:e.taskId,target:i.target,trace:o.dispatch}),u=a.identity.id,l.kind===`error`)applyHandleCommand({agentId:u,kind:`remove`,ownerId:e.ownerId});else if(readClaimedHandle(applyHandleCommand({address:l.address,kind:`confirm`,operationId:a.operation.id,ownerId:e.ownerId}))===void 0)throw Error(`Agent handle store could not confirm start operation "${a.operation.id}".`)}if(l.kind===`error`)return failed(l.result);let d=i.kind===`resume`?i.action:i.target.action,f=i.kind===`resume`?i.dynamicRemoteAgent:i.target.kind===`remote`?i.target.dynamicRemoteAgent:void 0,p=createSubagentCalledEvent({agentId:u,callId:l.callId,childSessionId:l.address.sessionId,name:l.name,remote:l.address.kind===`agent/remote`?{resolverId:f===void 0?d.nodeId:f.credentialsStepId,url:l.address.url}:void 0,sequence:r.batch.event.sequence,sessionId:r.session.sessionId,toolName:l.toolName,turnId:r.batch.event.turnId,workflowId:workflowEntryReference.workflowId});return e.emit!==void 0&&await e.emit(p),{kind:`dispatched`,agentId:u,event:p,serializedContext:o.serializedContext,sessionState:sessionState()}}async function dispatchTaskAgentInvocationStep(e){"use step";let t,n;if(e.taskId!==void 0){let r=readDurableSession(e.sessionState),i=findSessionTaskEntry(r.state,e.taskId);if(i===void 0)return{kind:`not-admitted`,sessionState:e.sessionState};let a=await readLatestTaskView({taskRunId:i.taskRunId});if(a===void 0||isTerminalTaskStatus(a.status))return{kind:`not-admitted`,sessionState:e.sessionState};if(`legacy`in i.dispatchContext)return missingTaskDispatchContext(e);n=i.dispatchContext,i.metadata.kind===`subagent`&&(t=i.activityWorkIdentity)}return await dispatchAgentInvocation({...e,activityWorkIdentity:t,callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url),invocationContext:n===void 0?void 0:applyTaskDispatchContext(e.serializedContext,n)})}function missingTaskDispatchContext(e){return{kind:`failed`,result:{callId:e.request.invocationId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`AGENT_INVOCATION_AUTH_UNAVAILABLE`,message:`The background task predates captured authentication context.`},subagentName:e.request.input.target},sessionState:e.sessionState}}function applyTaskDispatchContext(e,t){let n={...e,[AuthKey.name]:t.auth.current,[InitiatorAuthKey.name]:t.auth.initiator};for(let[e,r]of[[SessionDynamicSubagentSelectionsKey.name,t.sessionDynamicSubagentSelections],[TurnDynamicSubagentSelectionsKey.name,t.turnDynamicSubagentSelections]])r===void 0?delete n[e]:n[e]=r;return n}async function settleTaskAgentInvocationStep(e){"use step";let t=readDurableSession(e.sessionState),n=await flushAgentInvocationTraces(settleAgentInvocationTrace({acceptedAtMs:Date.now(),result:e.result,serializedContext:e.serializedContext,sessionId:t.sessionId})),r=getAgentHandleStore(t.state)?.handles??[],i=r.filter(t=>t.phase===`claimed`&&t.ownerId===e.ownerId),a=i.find(t=>t.phase===`claimed`&&t.callId===e.result.callId)??(i.length===1?i[0]:void 0);if(a?.phase!==`claimed`)return{serializedContext:n,sessionState:e.sessionState};let o=e.result.outcome.kind===`terminal`?r.filter(e=>e!==a):r.map(t=>t===a?e.result.outcome.result.kind===`cancelled`?{address:a.address,identity:a.identity,lastStatus:`(cancelled)`,phase:`parked`}:{address:a.address,identity:a.identity,phase:`available`}:t),s=writeHandles(t,o);return e.result.outcome.kind===`terminal`&&(s=e.taskId===void 0?`continuationToken`in a.address?clearProxyInputRequestsForChild(s,a.address.continuationToken):s:clearProxyInputRequestsForTask(s,e.taskId)),e.accumulateUsage!==!1&&(s=setTurnUsageState(s,accumulateSessionUsage({previous:getTurnUsageState(s.state),usage:e.result.outcome.usageDelta}))),{serializedContext:n,sessionState:replaceDurableSessionSnapshot({session:s,state:e.sessionState})}}async function releaseAgentInvocationOwnerStep(e){"use step";let t=readDurableSession(e.sessionState),n=e.cancelled?abandonAgentInvocationOwners(t,new Set([e.ownerId])):applyTaskAgentHandleCommand(t,{kind:`release-owner`,ownerId:e.ownerId}).session;return{sessionState:n===t?e.sessionState:replaceDurableSessionSnapshot({session:n,state:e.sessionState})}}function readClaimedHandle(e){let t=e.kind===`ready`?e.handle:void 0;return t?.phase===`claimed`?t:void 0}function createTaskClaimError(e,t,n){return n.kind===`mismatch`?createAgentErrorResult({action:e,code:AGENT_MISMATCH,message:`Agent "${t}" no longer matches this subagent definition. Start a new agent instead.`}):n.kind===`busy`?createAgentErrorResult({action:e,code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:t,agentName:n.handle.identity.name,ownerId:`ownerId`in n.handle?n.handle.ownerId:void 0})}):createAgentErrorResult({action:e,code:AGENT_UNREACHABLE,message:`Agent with id "${t}" is no longer reachable.`})}export{dispatchAgentInvocation,dispatchTaskAgentInvocationStep,releaseAgentInvocationOwnerStep,settleTaskAgentInvocationStep};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContextReader } from "#context/key.js";
|
|
2
|
+
import type { HarnessSession } from "#harness/types.js";
|
|
3
|
+
import type { JsonObject } from "#shared/json.js";
|
|
4
|
+
import type { TaskOwnedAgentHandle } from "#subagents/handles/store.js";
|
|
5
|
+
export declare function steerBackgroundAgent(input: {
|
|
6
|
+
readonly ctx: ContextReader;
|
|
7
|
+
readonly handle: Extract<TaskOwnedAgentHandle, {
|
|
8
|
+
phase: "claimed";
|
|
9
|
+
}>;
|
|
10
|
+
readonly callId: string;
|
|
11
|
+
readonly input: JsonObject;
|
|
12
|
+
readonly session: HarnessSession;
|
|
13
|
+
}): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveAgentInvocationAction}from"./invoke-preparation.js";import{AuthKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{dispatchToClaimedAgentAddress}from"#subagents/handle-dispatch.js";import{createAgentContinuationBundle}from"#subagents/continuation-bundle.js";import{normalizeRequestedOutputSchema}from"#subagents/invocation.js";async function steerBackgroundAgent(e){let t=resolveAgentInvocationAction({ctx:e.ctx,invocationId:e.callId,input:{agentId:e.handle.identity.id,message:typeof e.input.message==`string`?e.input.message:``,outputSchema:normalizeRequestedOutputSchema(e.input.outputSchema),target:e.handle.identity.name}}),n=getDynamicSubagentSelection(e.ctx,e.handle.identity.nodeId),r=await dispatchToClaimedAgentAddress({action:t,auth:e.ctx.get(AuthKey)??null,bundle:createAgentContinuationBundle({action:t,bundle:e.ctx.require(BundleKey),dynamicRemoteAgent:n?.kind===`remote`?n.remoteAgent:void 0}),currentSession:e.session,handle:e.handle,reply:{kind:`steer`}});if(r.kind===`error`)throw Error(JSON.stringify(r.result.output))}export{steerBackgroundAgent};
|
|
@@ -8,7 +8,7 @@ export interface AgentRequestDelivery {
|
|
|
8
8
|
readonly taskId?: string;
|
|
9
9
|
}
|
|
10
10
|
export interface TaskAgentRequestContext {
|
|
11
|
-
readonly
|
|
11
|
+
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
12
12
|
readonly serializedContext: Record<string, unknown>;
|
|
13
13
|
readonly sessionState: DurableSessionState;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{dispatchTaskAgentInvocationStep,settleTaskAgentInvocationStep}from"#execution/tools/subagent/invoke-step.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{emitTaskSubagentCalledStep}from"#execution/tools/subagent/emit-called-step.js";async function applyTaskAgentRequest(e,t){let{request:n}=e;switch(n.kind){case`agent-settled`:{let r=await settleTaskAgentInvocationStep({accumulateUsage:e.accumulateUsage,ownerId:e.ownerId,result:n.result,serializedContext:t.serializedContext,sessionState:t.sessionState,taskId:e.taskId});return{serializedContext:r.serializedContext,sessionState:r.sessionState}}case`agent-invoke`:{let r=await dispatchTaskAgentInvocationStep({ownerId:e.ownerId,replyTo:e.replyTo,request:n,serializedContext:t.serializedContext,sessionState:t.sessionState,taskId:e.taskId});switch(r.kind){case`dispatched`:return{serializedContext:(await emitTaskSubagentCalledStep({event:r.event,sessionWritable:t.sessionWritable,serializedContext:r.serializedContext??t.serializedContext})).serializedContext,sessionState:r.sessionState};case`failed`:return await resumeHookStep(e.replyTo,{kind:`runtime-action-result`,results:[r.result]}),{serializedContext:r.serializedContext??t.serializedContext,sessionState:r.sessionState};case`not-admitted`:return{serializedContext:t.serializedContext,sessionState:r.sessionState}}}}}export{applyTaskAgentRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{requestWorkflowTurnCancellation}from"#execution/workflow-runtime.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{cancelRemoteAgentTurn,resolveRemoteAgentForAction}from"#subagents/remote-dispatch.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";const log=createLogger(`execution.agent-invocation-cancel`),cancelBackgroundAgentTask=async e=>{if(e.session===void 0||e.serializedContext===void 0)return;let t=e.session,n=getAgentHandleStore(t.state)?.handles.find(t=>t.phase===`claimed`&&t.ownerId===e.entry.taskId);if(n===void 0||n.phase!==`claimed`)return;if(n.address.kind!==`agent/remote`){await requestWorkflowTurnCancellation({sessionId:n.address.sessionId});return}let r=await deserializeContext(e.serializedContext),i=r.require(BundleKey),a=getDynamicSubagentSelection(r,n.identity.nodeId),o=resolveRemoteAgentForAction({dynamicRemoteAgent:a?.kind===`remote`?a.remoteAgent:void 0,nodeId:n.identity.nodeId,registry:i.subagentRegistry.subagentsByNodeId,remoteAgentName:n.identity.name});await cancelRemoteAgentTurn({remote:{...o,url:n.address.url},sessionId:n.address.sessionId})};async function cancelAgentInvocationOwnerStep(e){"use step";let t=
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{requestWorkflowTurnCancellation}from"#execution/workflow-runtime.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{cancelRemoteAgentTurn,resolveRemoteAgentForAction}from"#subagents/remote-dispatch.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";const log=createLogger(`execution.agent-invocation-cancel`),cancelBackgroundAgentTask=async e=>{if(e.session===void 0||e.serializedContext===void 0)return;let t=e.session,n=getAgentHandleStore(t.state)?.handles.find(t=>t.phase===`claimed`&&t.ownerId===e.entry.taskId);if(n===void 0||n.phase!==`claimed`)return;if(n.address.kind!==`agent/remote`){await requestWorkflowTurnCancellation({sessionId:n.address.sessionId});return}let r=await deserializeContext(e.serializedContext),i=r.require(BundleKey),a=getDynamicSubagentSelection(r,n.identity.nodeId),o=resolveRemoteAgentForAction({dynamicRemoteAgent:a?.kind===`remote`?a.remoteAgent:void 0,nodeId:n.identity.nodeId,registry:i.subagentRegistry.subagentsByNodeId,remoteAgentName:n.identity.name});await cancelRemoteAgentTurn({remote:{...o,url:n.address.url},sessionId:n.address.sessionId})};async function cancelAgentInvocationOwnerStep(e){"use step";let t=readDurableSession(e.sessionState),n=(getAgentHandleStore(t.state)?.handles??[]).filter(t=>t.phase===`claimed`&&t.ownerId===e.ownerId);if(n.length===0)return;let r=n.some(e=>e.address.kind===`agent/remote`)?await deserializeContext(e.serializedContext):void 0;await Promise.all(n.map(async t=>{try{if(t.address.kind!==`agent/remote`){await requestWorkflowTurnCancellation({sessionId:t.address.sessionId});return}let e=r.require(BundleKey),n=getDynamicSubagentSelection(r,t.identity.nodeId),i=resolveRemoteAgentForAction({dynamicRemoteAgent:n?.kind===`remote`?n.remoteAgent:void 0,nodeId:t.identity.nodeId,registry:e.subagentRegistry.subagentsByNodeId,remoteAgentName:t.identity.name});await cancelRemoteAgentTurn({remote:{...i,url:t.address.url},sessionId:t.address.sessionId})}catch(n){logError(log,`failed to cancel workflow-owned agent turn`,n,{agentId:t.identity.id,childSessionId:t.address.sessionId,ownerId:e.ownerId})}}))}export{cancelAgentInvocationOwnerStep,cancelBackgroundAgentTask};
|
|
@@ -2,14 +2,6 @@ import { type Hook } from "#compiled/@workflow/core/index.js";
|
|
|
2
2
|
import type { WorkflowToolRunOwner, WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
|
|
3
3
|
import type { ToolContext, ToolInputRequest, ToolInputResponse } from "#tools/definition.js";
|
|
4
4
|
export interface WorkflowToolRunContext {
|
|
5
|
-
readonly authorizationSupported?: boolean;
|
|
6
|
-
/** Compatibility for already-started two-run background workflows. */
|
|
7
|
-
readonly admission?: Promise<{
|
|
8
|
-
readonly status: "accepted";
|
|
9
|
-
} | {
|
|
10
|
-
readonly status: "rejected";
|
|
11
|
-
readonly reason: string;
|
|
12
|
-
}>;
|
|
13
5
|
readonly from: WorkflowToolRunRef;
|
|
14
6
|
readonly owner: WorkflowToolRunOwner;
|
|
15
7
|
}
|
|
@@ -17,6 +9,5 @@ export declare function attachWorkflowToolRunContext(ctx: ToolContext, context:
|
|
|
17
9
|
export declare function findWorkflowToolRunContext(value: unknown): WorkflowToolRunContext | undefined;
|
|
18
10
|
export declare function readWorkflowToolRunRef(ctx: ToolContext): WorkflowToolRunRef;
|
|
19
11
|
export declare function readWorkflowToolRunOwner(ctx: ToolContext): WorkflowToolRunOwner;
|
|
20
|
-
export declare function readWorkflowToolRunAdmission(ctx: ToolContext): WorkflowToolRunContext["admission"];
|
|
21
12
|
/** Returns an answer hook which may be awaited or raced with another workflow operation. */
|
|
22
13
|
export declare function ask(ctx: ToolContext, request: ToolInputRequest): Hook<ToolInputResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{workflowToolContextErrorMessage}from"#shared/workflow-tool-context.js";import{createHook}from"#compiled/@workflow/core/index.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";const WORKFLOW_TOOL_RUN_CONTEXT=Symbol.for(`eve.workflow-tool-run.context`);function attachWorkflowToolRunContext(e,t){Object.defineProperty(e,WORKFLOW_TOOL_RUN_CONTEXT,{enumerable:!1,value:t})}function readWorkflowToolRunContext(e,t){let n=e?.[WORKFLOW_TOOL_RUN_CONTEXT];if(n===void 0)throw Error(workflowToolContextErrorMessage(t));return n}function findWorkflowToolRunContext(e){return typeof e==`object`&&e?e[WORKFLOW_TOOL_RUN_CONTEXT]:void 0}function readWorkflowToolRunRef(e){return readWorkflowToolRunContext(e,`agent`).from}function readWorkflowToolRunOwner(e){return readWorkflowToolRunContext(e,`agent`).owner}function
|
|
1
|
+
import{workflowToolContextErrorMessage}from"#shared/workflow-tool-context.js";import{createHook}from"#compiled/@workflow/core/index.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";const WORKFLOW_TOOL_RUN_CONTEXT=Symbol.for(`eve.workflow-tool-run.context`);function attachWorkflowToolRunContext(e,t){Object.defineProperty(e,WORKFLOW_TOOL_RUN_CONTEXT,{enumerable:!1,value:t})}function readWorkflowToolRunContext(e,t){let n=e?.[WORKFLOW_TOOL_RUN_CONTEXT];if(n===void 0)throw Error(workflowToolContextErrorMessage(t));return n}function findWorkflowToolRunContext(e){return typeof e==`object`&&e?e[WORKFLOW_TOOL_RUN_CONTEXT]:void 0}function readWorkflowToolRunRef(e){return readWorkflowToolRunContext(e,`agent`).from}function readWorkflowToolRunOwner(e){return readWorkflowToolRunContext(e,`agent`).owner}function ask(e,t){let n=readWorkflowToolRunContext(e,`ask`),r=createHook();return resumeHookStep(n.owner.inbox,{kind:`request`,from:n.from,replyTo:r.token,request:{kind:`ask`,request:t}}),r}export{ask,attachWorkflowToolRunContext,findWorkflowToolRunContext,readWorkflowToolRunOwner,readWorkflowToolRunRef};
|
|
@@ -2,8 +2,6 @@ import type { SessionContext } from "#context/session-context.js";
|
|
|
2
2
|
import { type WorkflowToolRunOutcome, type WorkflowToolRunOwner, type WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
|
|
3
3
|
import type { JsonObject, JsonValue } from "#shared/json.js";
|
|
4
4
|
export interface WorkflowBodyDefinition {
|
|
5
|
-
/** Advertised by the parent driver; absent on runs started before this capability. */
|
|
6
|
-
readonly authorizationSupported?: boolean;
|
|
7
5
|
readonly callId: string;
|
|
8
6
|
readonly executeInput?: JsonValue;
|
|
9
7
|
readonly input: JsonObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{createTaskMessage}from"#tools/task.js";import{ask,attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{agent}from"#execution/tools/subagent/invoke-agent.js";import"#execution/tools/workflow/messages.js";import{
|
|
1
|
+
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{createTaskMessage}from"#tools/task.js";import{ask,attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{agent}from"#execution/tools/subagent/invoke-agent.js";import"#execution/tools/workflow/messages.js";import{readRegisteredWorkflow}from"#execution/workflow-registry.js";async function executeWorkflowBody(e,t){let n=createWorkflowBodyRef(e),r=createWorkflowBodyContext(e,t);attachWorkflowToolRunContext(r,{from:n,owner:e.owner});let i=0;try{let t=resolveWorkflowToolExecute(e),a=e.execution===`background`?createWorkflowTaskExec(e):void 0,o=t(e.executeInput??e.input,r,a),s;if(!isAsyncIterable(o))s=await o;else{let t=o[Symbol.asyncIterator](),r,a=await t.next();for(;a.done!==!0;){r=a.value;let o={from:n,update:a.value};await resumeHookStep(e.owner.inbox,{kind:`report`,...o}),i+=1,a=await t.next()}s=a.value??(e.execution===`blocking`?r:void 0)??null}return{outcome:{output:s,status:`completed`},reportCount:i}}catch(e){return t.aborted?{outcome:{reason:t.reason instanceof Error?t.reason.message:String(t.reason??``),status:`cancelled`},reportCount:i}:{outcome:{error:normalizeSerializableError(e),status:`failed`},reportCount:i}}}function createWorkflowBodyRef(e){return{callId:e.callId,execution:e.execution,input:e.input,resultKind:e.resultKind,runId:e.runId??getWorkflowMetadata().workflowRunId,sequence:e.session.turn.sequence,stepIndex:e.stepIndex,toolName:e.toolName,turnId:e.session.turn.id}}function resolveWorkflowToolExecute(e){let t=readRegisteredWorkflow(e.workflowId);if(typeof t!=`function`)throw Error(`Tool "${e.toolName}" is not registered as a workflow in this deployment (${e.workflowId}). The tool was renamed or removed after this run started.`);return t}function createWorkflowBodyContext(e,t){let unavailable=(t,n)=>{throw Error(`ctx.${t} is not available inside a workflow tool; ${n}. Tool "${e.toolName}" runs as a durable workflow body, which only replays deterministic code.`)},n={agent:((e,t)=>agent(n,e,t)),ask:e=>ask(n,e),abortSignal:t,callId:e.callId,getSandbox:()=>unavailable(`getSandbox()`,`the session sandbox belongs to the turn`),getSkill:()=>unavailable(`getSkill()`,`skills are read through the session sandbox`),getToken:()=>unavailable(`getToken()`,`pass ctx directly to a "use step" helper to resolve credentials`),requireAuth:()=>unavailable(`requireAuth()`,`pass ctx directly to a "use step" helper to request authorization`),session:e.session,toolName:e.toolName};return n}function createWorkflowTaskExec(e){if(e.taskId===void 0)throw Error(`Background workflow tool "${e.toolName}" has no task id.`);return{binding:{taskId:e.taskId,token:e.taskId},postMessage:createTaskMessage,send(){throw Error(`task.send() was replaced by yielded task descriptors.`)},session:void 0,task:void 0,taskId:e.taskId}}function isAsyncIterable(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}export{createWorkflowBodyRef,executeWorkflowBody};
|
|
@@ -2,6 +2,6 @@ import type { WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
|
|
|
2
2
|
import type { JsonValue } from "#shared/json.js";
|
|
3
3
|
export declare function emitWorkflowToolRunReportStep(input: {
|
|
4
4
|
readonly from: WorkflowToolRunRef;
|
|
5
|
-
readonly
|
|
5
|
+
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
6
6
|
readonly update: JsonValue;
|
|
7
7
|
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createActionPartialEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";async function emitWorkflowToolRunReportStep(e){"use step";let t=createActionPartialEvent({result:createRuntimeToolResultFromValue({callId:e.from.callId,output:e.update,toolName:e.from.toolName}),sequence:e.from.sequence,stepIndex:e.from.stepIndex,turnId:e.from.turnId}),n=e.
|
|
1
|
+
import{createActionPartialEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";async function emitWorkflowToolRunReportStep(e){"use step";let t=createActionPartialEvent({result:createRuntimeToolResultFromValue({callId:e.from.callId,output:e.update,toolName:e.from.toolName}),sequence:e.from.sequence,stepIndex:e.from.stepIndex,turnId:e.from.turnId}),n=e.sessionWritable.getWriter();try{await n.write(encodeMessageStreamEvent(stampMessageStreamEvent(t)))}finally{n.releaseLock()}}export{emitWorkflowToolRunReportStep};
|
|
@@ -81,7 +81,6 @@ export type WorkflowToolRunMessage = ({
|
|
|
81
81
|
} & WorkflowToolRunRequestMessage) | ({
|
|
82
82
|
readonly kind: "outcome";
|
|
83
83
|
} & WorkflowToolRunOutcomeMessage);
|
|
84
|
-
export declare const workflowToolRunHook: import("#compiled/@workflow/core/index.js").TypedHook<WorkflowToolRunMessage, WorkflowToolRunMessage>;
|
|
85
84
|
export type WorkflowToolRunControlMessage = {
|
|
86
85
|
readonly kind: "cancel";
|
|
87
86
|
readonly reason: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function isWorkflowToolRunControlMessage(e){if(typeof e!=`object`||!e)return!1;let{kind:t,reason:n}=e;return t===`cancel`&&typeof n==`string`}export{isWorkflowToolRunControlMessage};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { WorkflowToolRunMessage, WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js";
|
|
2
2
|
import { type ChannelReader } from "#execution/tools/workflow/owner-channels.js";
|
|
3
3
|
export interface WorkflowToolRunOwnerInbox {
|
|
4
|
+
dispose(): Promise<void>;
|
|
4
5
|
readonly owner: WorkflowToolRunOwner;
|
|
5
6
|
readonly reader: ChannelReader<"workflow", WorkflowToolRunMessage>;
|
|
6
7
|
}
|
|
8
|
+
/** Background task workflows have their own lifecycle, outside a session inbox. */
|
|
7
9
|
export declare function openWorkflowToolRunOwnerInbox(): WorkflowToolRunOwnerInbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createHook}from"#compiled/@workflow/core/index.js";import{disposeHook}from"#execution/hook-ownership.js";import{createChannelReader}from"#execution/tools/workflow/owner-channels.js";function openWorkflowToolRunOwnerInbox(){let e=createHook();return{dispose:()=>disposeHook(e),owner:{inbox:e.token},reader:createChannelReader(`workflow`,e)}}export{openWorkflowToolRunOwnerInbox};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** `resumeHook` as a step, so the runtime API stays out of the
|
|
1
|
+
/** `resumeHook` as a step, so the runtime API stays out of the owner. */
|
|
2
2
|
export declare function resumeHookStep(token: string, payload: unknown, options?: {
|
|
3
3
|
readonly ifPresent?: boolean;
|
|
4
4
|
}): Promise<void>;
|
|
@@ -5,7 +5,6 @@ export type WorkflowStepAuthorizationResult = AuthorizationResult & {
|
|
|
5
5
|
readonly name: string;
|
|
6
6
|
};
|
|
7
7
|
export interface WorkflowStepContext {
|
|
8
|
-
readonly authorizationSupported: boolean;
|
|
9
8
|
readonly callId: string;
|
|
10
9
|
readonly toolName: string;
|
|
11
10
|
readonly session: SessionContext["session"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,InitiatorAuthKey,SessionIdKey,SessionKey}from"#context/keys.js";import{getStepMetadata}from"#compiled/@workflow/core/index.js";import{AuthorizationHookKey,CallbackBaseUrlKey,PendingAuthorizationResultKey,isAuthorizationSignal}from"#harness/authorization.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{buildBaseToolContext}from"#context/build-base-tool-context.js";import{createAuthorizationContext}from"#runtime/authorization-context.js";import{
|
|
1
|
+
import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,InitiatorAuthKey,SessionIdKey,SessionKey}from"#context/keys.js";import{getStepMetadata}from"#compiled/@workflow/core/index.js";import{AuthorizationHookKey,CallbackBaseUrlKey,PendingAuthorizationResultKey,isAuthorizationSignal}from"#harness/authorization.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{buildBaseToolContext}from"#context/build-base-tool-context.js";import{createAuthorizationContext}from"#runtime/authorization-context.js";import{isConnectionAuthorizationFailedError}from"#connections/errors.js";import{completeWorkflowStepAuthorization}from"#execution/tools/workflow/authorization-completion.js";import"#execution/tools/workflow/step-context.js";function withWorkflowStepAuthorization(e){let wrapped=async function(t){let{args:n,context:r}=t;getStepMetadata();let i=new ContextContainer;return i.set(AuthKey,r.session.auth.current),i.set(InitiatorAuthKey,r.session.auth.initiator),i.set(SessionIdKey,r.session.id),i.setVirtualContext(SessionKey,{...r.session,sessionId:r.session.id}),i.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(r.baseUrl)),i.setVirtualContext(AuthorizationHookKey,r.token),i.setVirtualContext(PendingAuthorizationResultKey,r.authorizationResults),contextStorage.run(i,async()=>{let a=createAuthorizationContext({scope:r.toolName,completeAuthorization:completeWorkflowStepAuthorization}),o={...buildBaseToolContext({toolName:r.toolName,options:{abortSignal:r.abortSignal,toolCallId:r.callId}}),getToken:a.getToken,requireAuth:a.requireAuth},s;try{s=await a.run(()=>Reflect.apply(e,this,n.map((e,n)=>t.contextIndexes.includes(n)?o:e)))}catch(e){throw isConnectionAuthorizationFailedError(e)&&!e.retryable&&Object.assign(e,{fatal:!0}),e}let c=i.get(PendingAuthorizationResultKey)??[],l=r.authorizationResults.filter(e=>!c.includes(e)).map(e=>e.attemptId);return isAuthorizationSignal(s)?{kind:`authorization-required`,signal:s,authorized:l}:{kind:`result`,output:s,authorized:l}})};return Object.defineProperty(wrapped,"maxRetries",{get:()=>Reflect.get(e,`maxRetries`)}),wrapped}export{withWorkflowStepAuthorization};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAuthorizationCompletedEvent,createAuthorizationRequiredEvent}from"#protocol/message.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{disposeHook}from"#execution/hook-ownership.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{findWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";function workflowToolStep(e,t){return new Proxy(e,{apply(e,n,r){let i=findWorkflowContextArgument(r);return i===void 0?Reflect.apply(e,n,r):executeAuthorizedStep(t,n,r,i)}})}function findWorkflowContextArgument(e){for(let t of e){let e=findWorkflowToolRunContext(t);if(e!==void 0)return{ctx:t,run:e}}}async function executeAuthorizedStep(e,t,n,r){let{ctx:i,run:a}=r,o=[],s=new Map;for(;;){let r=createHook();try{let c;try{c=await invokeAuthorizedStep({args:n,authorizationResults:o,callbackToken:r.token,ctx:i,execute:e,receiver:t
|
|
1
|
+
import{createAuthorizationCompletedEvent,createAuthorizationRequiredEvent}from"#protocol/message.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{disposeHook}from"#execution/hook-ownership.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{findWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";function workflowToolStep(e,t){return new Proxy(e,{apply(e,n,r){let i=findWorkflowContextArgument(r);return i===void 0?Reflect.apply(e,n,r):executeAuthorizedStep(t,n,r,i)}})}function findWorkflowContextArgument(e){for(let t of e){let e=findWorkflowToolRunContext(t);if(e!==void 0)return{ctx:t,run:e}}}async function executeAuthorizedStep(e,t,n,r){let{ctx:i,run:a}=r,o=[],s=new Map;for(;;){let r=createHook();try{let c;try{c=await invokeAuthorizedStep({args:n,authorizationResults:o,callbackToken:r.token,ctx:i,execute:e,receiver:t})}catch(e){throw i.abortSignal.aborted||await reportPendingAsFailed(a,i.abortSignal,s),e}if(await reconcileCompletedAuthorizations(a,i.abortSignal,s,o,c.authorized),c.kind===`result`)return await reportPendingAsFailed(a,i.abortSignal,s),c.output;await collectAuthorizationCallbacks({authorizationResults:o,callback:r,challenges:c.signal.challenges,ctx:i,pending:s,run:a})}finally{await disposeHook(r)}}}async function invokeAuthorizedStep(e){let{args:t,authorizationResults:n,callbackToken:r,ctx:i,execute:a,receiver:o}=e,s={callId:i.callId,toolName:i.toolName,session:i.session,abortSignal:i.abortSignal,baseUrl:getWorkflowMetadata().url,token:r,authorizationResults:n},c={args:t.map(e=>e===i?null:e),context:s,contextIndexes:t.flatMap((e,t)=>e===i?[t]:[])};return await a.call(o,c)}async function reconcileCompletedAuthorizations(e,t,n,r,i){let a=new Set(i);for(let r of a){let i=n.get(r);i!==void 0&&await reportAuthorization(e,t,i,`authorized`),n.delete(r)}for(let e=r.length-1;e>=0;e--){let t=r[e];t!==void 0&&a.has(t.attemptId)&&r.splice(e,1)}}async function collectAuthorizationCallbacks(e){let{authorizationResults:t,callback:n,challenges:r,ctx:i,pending:a,run:o}=e;for(let e of r){let r=requireAttemptId(e);a.set(r.attemptId,r),await reportAuthorization(o,i.abortSignal,r);try{let e=await waitForCallback(n,r,i.abortSignal);t.push({name:r.name,instanceId:r.instanceId,attemptId:r.attemptId,hookUrl:r.hookUrl,principal:r.principal,resume:r.resume,callback:e})}catch(e){throw i.abortSignal.aborted||await reportAuthorization(o,i.abortSignal,r,`failed`),e}}}function requireAttemptId(e){if(e.attemptId===void 0)throw Error(`Workflow authorization challenge "${e.name}" has no attempt id.`);return e}async function reportPendingAsFailed(e,t,n){for(let r of n.values())await reportAuthorization(e,t,r,`failed`)}async function reportAuthorization(e,t,n,r){let i={attemptId:n.attemptId,name:n.name,sequence:e.from.sequence,stepIndex:e.from.stepIndex,turnId:e.from.turnId,authorization:n.challenge},a=r===void 0?createAuthorizationRequiredEvent({...i,description:`Sign in to ${n.name} to continue.`,webhookUrl:n.hookUrl}):createAuthorizationCompletedEvent({...i,outcome:r}),o=createHook();try{await withAbort(resumeHookStep(e.owner.inbox,{kind:`request`,from:e.from,replyTo:o.token,request:{kind:`authorization-request`,event:{kind:`subagent-authorization-event`,callId:e.from.callId,childSessionId:e.from.runId,subagentName:e.from.toolName,event:a}}}),t),await withAbort(o,t)}finally{await disposeHook(o)}}async function waitForCallback(e,t,n){let r=e[Symbol.asyncIterator]();for(;;){let e=await withAbort(r.next(),n);if(e.done)throw Error(`Authorization callback closed before sign-in completed.`);let i=readCallback(e.value,t);if(i!==void 0)return i}}async function withAbort(e,t){let abort,n=new Promise((e,n)=>{abort=()=>n(t.reason??Error(`Workflow authorization cancelled.`)),t.addEventListener(`abort`,abort,{once:!0}),t.aborted&&abort()});try{return await Promise.race([e,n])}finally{t.removeEventListener(`abort`,abort)}}function readCallback(e,t){if(typeof e==`object`&&e&&`payloads`in e&&Array.isArray(e.payloads))for(let n of e.payloads){let e=n?.authorizationCallback;if(e?.attemptId!==t.attemptId||e?.connectionName!==t.name)continue;let r=e.callback;if(!(typeof r?.method!=`string`||typeof r.params!=`object`||r.params===null||Array.isArray(r.params))&&Object.values(r.params).every(e=>typeof e==`string`)&&(r.body===void 0||typeof r.body==`string`))return r}}export{workflowToolStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sleep}from"#compiled/@workflow/core/index.js";import{
|
|
1
|
+
import{sleep}from"#compiled/@workflow/core/index.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{createWorkflowBodyRef,executeWorkflowBody}from"#execution/tools/workflow/body.js";import{openWorkflowToolRunControlInbox}from"#execution/tools/workflow/run-control.js";async function workflowToolRunWorkflow(e){"use workflow";let t=openWorkflowToolRunControlInbox(e.hookToken),n={...e,execution:e.execution??`blocking`},r=createWorkflowBodyRef(n),i=executeWorkflowBody(n,t.signal).then(({outcome:e})=>{if(e.status===`completed`)return e.output;throw e.status===`failed`?e.error:t.signal.reason??Error(e.reason??`Workflow tool run cancelled.`)}),a=i.catch(()=>{}),o;try{o={output:await Promise.race([i,t.cancelled]),status:`completed`}}catch(e){t.signal.aborted?(await Promise.race([a,sleep(`30s`)]),o={reason:t.reason(),status:`cancelled`}):o={error:normalizeSerializableError(e),status:`failed`}}let s={from:r,result:o};await resumeHookStep(e.owner.inbox,{kind:`outcome`,...s},{ifPresent:o.status===`cancelled`})}workflowToolRunWorkflow.workflowId=`workflow//eve//workflowToolRunWorkflow`;export{workflowToolRunWorkflow};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { CancelTurnInput, CancelTurnResult, Runtime } from "#channel/types.js";
|
|
1
|
+
import type { CancelTurnInput, CancelTurnResult, DeliverHookPayload, Runtime } from "#channel/types.js";
|
|
2
2
|
import { type Run, type StartOptionsWithoutDeploymentId, type WorkflowFunction, type WorkflowMetadata } from "#internal/workflow/runtime.js";
|
|
3
3
|
import type { RuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
|
|
4
|
+
import type { SessionCheckpoint } from "#execution/session/handoff.js";
|
|
4
5
|
import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js";
|
|
5
6
|
interface WorkflowHookRecord {
|
|
6
7
|
readonly runId: string;
|
|
@@ -8,21 +9,12 @@ interface WorkflowHookRecord {
|
|
|
8
9
|
/**
|
|
9
10
|
* Stable workflow reference used by `start()` to locate the workflow
|
|
10
11
|
* entrypoint registered by the Workflow DevKit builder. The id omits
|
|
11
|
-
* the package version stamp so the long-lived
|
|
12
|
+
* the package version stamp so the long-lived owner can rotate across
|
|
12
13
|
* deployments without rewriting the registry key.
|
|
13
14
|
*/
|
|
14
15
|
export declare const workflowEntryReference: {
|
|
15
16
|
workflowId: string;
|
|
16
17
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Stable workflow reference used by the driver to dispatch per-turn
|
|
19
|
-
* child workflow runs. The id omits the package version stamp so an
|
|
20
|
-
* explicitly stamped accepting deployment can resolve the workflow even
|
|
21
|
-
* when its eve version differs from the driver's deployment.
|
|
22
|
-
*/
|
|
23
|
-
export declare const turnWorkflowReference: {
|
|
24
|
-
workflowId: string;
|
|
25
|
-
};
|
|
26
18
|
/** Stable workflow reference for session deadline timers. */
|
|
27
19
|
export declare const sessionTimeoutWorkflowReference: {
|
|
28
20
|
workflowId: string;
|
|
@@ -40,14 +32,24 @@ export declare const workflowToolRunWorkflowReference: {
|
|
|
40
32
|
workflowId: string;
|
|
41
33
|
};
|
|
42
34
|
/**
|
|
43
|
-
* Creates a workflow-backed runtime whose
|
|
44
|
-
*
|
|
35
|
+
* Creates a workflow-backed runtime whose current owner executes turns and
|
|
36
|
+
* whose original run retains the public event stream across owner handoffs.
|
|
45
37
|
*/
|
|
46
38
|
export declare function createWorkflowRuntime(config: {
|
|
47
39
|
readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
|
|
48
40
|
readonly dynamicSubagentAgentConfig?: DynamicSubagentAgentConfig;
|
|
49
41
|
readonly nodeId?: string;
|
|
50
42
|
}): Runtime;
|
|
43
|
+
export interface SessionOwnerStartInput {
|
|
44
|
+
readonly activationToken: string;
|
|
45
|
+
/** Original run whose stream stays the public session stream. */
|
|
46
|
+
readonly anchorRunId: string;
|
|
47
|
+
readonly checkpoint: SessionCheckpoint;
|
|
48
|
+
readonly delivery: DeliverHookPayload;
|
|
49
|
+
readonly targetDeploymentId: string;
|
|
50
|
+
}
|
|
51
|
+
/** Starts a successor owner and binds its output to the original session stream. */
|
|
52
|
+
export declare function startSessionOwnerStep(input: SessionOwnerStartInput): Promise<void>;
|
|
51
53
|
/** Requests cancellation through a session's stable command inbox. */
|
|
52
54
|
export declare function requestWorkflowTurnCancellation(input: CancelTurnInput): Promise<CancelTurnResult>;
|
|
53
55
|
/**
|
|
@@ -58,9 +60,4 @@ export declare function requestWorkflowTurnCancellation(input: CancelTurnInput):
|
|
|
58
60
|
export declare function waitForCommandHookOwner(token: string): Promise<WorkflowHookRecord>;
|
|
59
61
|
/** Starts a workflow on the deployment executing this call. */
|
|
60
62
|
export declare function startWorkflowOnCurrentDeployment<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, options?: StartOptionsWithoutDeploymentId): Promise<Run<unknown> | Run<TResult>>;
|
|
61
|
-
/**
|
|
62
|
-
* Starts on the deployment that accepted a delivery when one was stamped,
|
|
63
|
-
* otherwise stays on the deployment executing this call.
|
|
64
|
-
*/
|
|
65
|
-
export declare function startWorkflowOnAcceptedDeployment<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, acceptedDeploymentId: string | undefined, options?: StartOptionsWithoutDeploymentId): Promise<Run<unknown> | Run<TResult>>;
|
|
66
63
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomBytes}from"node:crypto";import{createEveActivityRoutePath}from"#protocol/routes.js";import{createLogger,logError}from"#internal/logging.js";import{getChannelActivityPresentation}from"#channel/activity-renderer.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{ActivityObserverKey}from"#context/keys.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{normalizePersistedMessageStreamEvent}from"#protocol/message-version.js";import{cancelRun,getRawHookByToken,getRun,getWorld,start}from"#internal/workflow/runtime.js";import{serializeContext}from"#context/serialize.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{initializeSessionInstrumentation}from"#instrumentation/runtime.js";import{createWorkflowCallbackUrl,resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";import{buildInvocationAttributes}from"#internal/invocation/metadata.js";import{isAgentTraceContext}from"#tracing/agent-trace-context.js";import{ACTIVITY_COLLECTOR_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,TASK_RUN_WORKFLOW_NAME,TURN_WORKFLOW_NAME,WORKFLOW_ENTRY_NAME,WORKFLOW_TOOL_RUN_WORKFLOW_NAME}from"#execution/stable-workflow-names.js";const EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),COMMAND_HOOK_READY_TIMEOUT_MS=3e4,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}`},activityCollectorWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${ACTIVITY_COLLECTOR_WORKFLOW_NAME}`},workflowToolRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_TOOL_RUN_WORKFLOW_NAME}`};function createWorkflowRuntime(e){return{async createSession(t){let n=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId}),r=buildRunContext({bundle:n,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,run:t}),i=resolveEffectiveAgentRuntime(n,r);initializeSessionInstrumentation({agentName:i.turnAgent.id,ctx:r});let a=i.limits?.sessionTimeoutMs,o=n.resolvedAgent.config?.experimental?.workflow?.retention,s,c=t.activityObserver;if(t.parent===void 0&&c===void 0&&(getChannelActivityPresentation(t.adapter)?.renderers.length??0)>0){let e=serializeContext(r),t=randomBytes(32).toString(`base64url`),n={expiresAt:new Date(Date.now()+(typeof a==`number`?a:864e5)).toISOString(),serializedContext:e,token:t};try{s=(await startWorkflowOnCurrentDeployment(activityCollectorWorkflowReference,[n],{experimental_retention:o})).runId;let e=process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:`http://localhost:3000`,i=resolveWorkflowCallbackBaseUrl(e);c={sink:{url:createWorkflowCallbackUrl(i,createEveActivityRoutePath(t)),version:1}},r.set(ActivityObserverKey,c)}catch{await cancelActivityCollector(s),s=void 0,log.warn(`failed to start activity collector`)}}let l=serializeContext(r),u=readParentLineage(l),d={input:t.input,limits:t.limits,serializedContext:l},f=t.taskId??t.callback?.taskId;f!==void 0&&(d.taskId=f),s!==void 0&&(d.activityCollectorRunId=s),t.continuationConflictCommand!==void 0&&(d.continuationConflictCommand=t.continuationConflictCommand),a!==void 0&&(d.sessionTimeoutMs=a),o!==void 0&&(d.retention=o);let p={...u.sessionId===void 0?buildSessionAttributes({inputMessage:t.title??t.input.message,serializedContext:l}):buildSubagentRootAttributes({identity:{nodeId:n.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:u.callId,parentSessionId:u.sessionId,parentTurnId:u.turnId,rootSessionId:u.rootSessionId??u.sessionId,serializedContext:l}),...t.externalInvocation===void 0?{}:buildInvocationAttributes(t.externalInvocation)},m;try{m=await startWorkflowOnCurrentDeployment(workflowEntryReference,[d],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(p),experimental_retention:o})}catch(e){throw await cancelActivityCollector(s),logError(log,`failed to start workflow run`,e,{continuationToken:t.continuationToken}),e}let h,getEvents=()=>(h??=parseNdjsonStream(()=>getRun(m.runId).getReadable(),normalizePersistedEvent),h);return{get events(){return getEvents()},sessionId:m.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}),normalizePersistedEvent)},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 getRawHookByToken(e)).runId}}catch(t){if(HookNotFoundError.is(t))return;throw logError(log,`failed to resolve session by continuation token`,t,{continuationToken:e}),t}}}}function normalizePersistedEvent(e){return normalizePersistedMessageStreamEvent(e)}async function cancelActivityCollector(e){if(e!==void 0)try{await cancelRun(await getWorld(),e,{cancelReason:`Root session creation did not complete`})}catch{log.warn(`failed to cancel unowned activity collector`)}}async function dispatchWorkflowCommand(e,t){let n;try{n=normalizeWorkflowHook(await resumeSessionInbox(e,t))}catch(n){if(isInactiveCommandTarget(n))return inactiveCommandResult(t);throw logError(log,`failed to dispatch session command`,n,{command:t.kind,token:e}),n}return t.kind===`reset`&&await waitForCommandHookRelease(sessionCommandHookToken(n.runId),n.runId),activeCommandResult(t,n.runId)}function activeCommandResult(e,t){return e.kind===`reset`?{previousSessionId:t,status:`reset`}:e.kind===`send`&&e.delivery!==void 0?{sessionId:t,status:`accepted`,deliveryId:e.delivery.deliveryId}:{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.tasks!==void 0&&(t.tasks=e.tasks),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 waitForCommandHookOwner(e){let t=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;)try{return normalizeWorkflowHook(await getRawHookByToken(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 getRawHookByToken(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 startWorkflowOnCurrentDeployment(e,t,n){return await startWorkflowOnDeployment(e,t,process.env.VERCEL_DEPLOYMENT_ID?.trim()||void 0,n)}async function startWorkflowOnAcceptedDeployment(e,t,n,r){return n===void 0?await startWorkflowOnCurrentDeployment(e,t,r):await startWorkflowOnDeployment(e,t,n,r)}async function startWorkflowOnDeployment(e,t,n,r){return await withWorkflowStartContext(async()=>n===void 0?r===void 0?await start(e,t):await start(e,t,r):await start(e,t,{...r,deploymentId:n}))}async function withWorkflowStartContext(e){let t=context.active(),n=isAgentTraceContext(t)?trace.deleteSpan(t):t;return await context.with(n,e)}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{activityCollectorWorkflowReference,createWorkflowRuntime,requestWorkflowTurnCancellation,sessionTimeoutWorkflowReference,startWorkflowOnAcceptedDeployment,startWorkflowOnCurrentDeployment,taskRunWorkflowReference,turnWorkflowReference,waitForCommandHookOwner,workflowEntryReference,workflowToolRunWorkflowReference};
|
|
1
|
+
import{randomBytes}from"node:crypto";import{createEveActivityRoutePath}from"#protocol/routes.js";import{createLogger,logError}from"#internal/logging.js";import{getChannelActivityPresentation}from"#channel/activity-renderer.js";import{sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{ActivityObserverKey}from"#context/keys.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{normalizePersistedMessageStreamEvent}from"#protocol/message-version.js";import{cancelRun,getHookByToken,getRun,getWorld,start}from"#internal/workflow/runtime.js";import{serializeContext}from"#context/serialize.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{AcceptedSessionIdentityError,resolveSessionInbox,resumeSessionInbox}from"#execution/session-inbox/resume.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{initializeSessionInstrumentation}from"#instrumentation/runtime.js";import{createWorkflowCallbackUrl,resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";import{buildInvocationAttributes}from"#internal/invocation/metadata.js";import{isAgentTraceContext}from"#tracing/agent-trace-context.js";import{ACTIVITY_COLLECTOR_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,TASK_RUN_WORKFLOW_NAME,WORKFLOW_ENTRY_NAME,WORKFLOW_TOOL_RUN_WORKFLOW_NAME}from"#execution/stable-workflow-names.js";const EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),COMMAND_HOOK_READY_TIMEOUT_MS=3e4,STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},sessionTimeoutWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${SESSION_TIMEOUT_WORKFLOW_NAME}`},taskRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TASK_RUN_WORKFLOW_NAME}`},activityCollectorWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${ACTIVITY_COLLECTOR_WORKFLOW_NAME}`},workflowToolRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_TOOL_RUN_WORKFLOW_NAME}`};function createWorkflowRuntime(e){return{async createSession(t){let n=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId}),r=buildRunContext({bundle:n,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,run:t}),i=resolveEffectiveAgentRuntime(n,r);initializeSessionInstrumentation({agentName:i.turnAgent.id,ctx:r});let a=i.limits?.sessionTimeoutMs,o=n.resolvedAgent.config?.experimental?.workflow?.retention,s,c=t.activityObserver;if(t.parent===void 0&&c===void 0&&(getChannelActivityPresentation(t.adapter)?.renderers.length??0)>0){let e=serializeContext(r),t=randomBytes(32).toString(`base64url`),n={expiresAt:new Date(Date.now()+(typeof a==`number`?a:864e5)).toISOString(),serializedContext:e,token:t};try{s=(await startWorkflowOnCurrentDeployment(activityCollectorWorkflowReference,[n],{experimental_retention:o})).runId;let e=process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:`http://localhost:3000`,i=resolveWorkflowCallbackBaseUrl(e);c={sink:{url:createWorkflowCallbackUrl(i,createEveActivityRoutePath(t)),version:1}},r.set(ActivityObserverKey,c)}catch{await cancelActivityCollector(s),s=void 0,log.warn(`failed to start activity collector`)}}let l=serializeContext(r),u=readParentLineage(l),d={kind:`initial`,input:t.input,ownerDeploymentId:await resolveCurrentWorkflowDeploymentId(),serializedContext:l},f=t.taskId??t.callback?.taskId;t.limits!==void 0&&(d.limits=t.limits),f!==void 0&&(d.taskId=f),s!==void 0&&(d.activityCollectorRunId=s),t.continuationConflictCommand!==void 0&&(d.continuationConflictCommand=t.continuationConflictCommand),a!==void 0&&(d.sessionTimeoutMs=a),o!==void 0&&(d.retention=o);let p={...u.sessionId===void 0?buildSessionAttributes({serializedContext:l}):buildSubagentRootAttributes({identity:{nodeId:n.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:u.callId,parentSessionId:u.sessionId,parentTurnId:u.turnId,rootSessionId:u.rootSessionId??u.sessionId,serializedContext:l}),...t.externalInvocation===void 0?{}:buildInvocationAttributes(t.externalInvocation)},m;try{let e={allowReservedAttributes:!0,attributes:normalizeEveAttributes(p)};o!==void 0&&(e.experimental_retention=o),m=await startWorkflowOnDeployment(workflowEntryReference,[d],d.ownerDeploymentId,e)}catch(e){throw await cancelActivityCollector(s),logError(log,`failed to start workflow run`,e,{continuationToken:t.continuationToken}),e}let h,getEvents=()=>(h??=parseNdjsonStream(()=>getRun(m.runId).getReadable(),normalizePersistedEvent),h);return{get events(){return getEvents()},sessionId:m.runId}},async dispatchContinuation(e){return await dispatchWorkflowCommand(e.continuationToken,e.command)},async dispatchSession(e){return await dispatchWorkflowCommand({sessionId:e.sessionId},e.command)},async getEventStream(e,t){return parseNdjsonStream(()=>getRun(e).getReadable({startIndex:t?.startIndex}),normalizePersistedEvent)},async getStreamTailIndex(e){let t=getRun(e).getReadable();try{return await t.getTailIndex()}finally{await t.cancel().catch(()=>{})}},async resolveContinuation(e){try{return await resolveSessionInbox(e)}catch(t){if(HookNotFoundError.is(t))return;throw logError(log,`failed to resolve session by continuation token`,t,{continuationToken:e}),t}}}}async function startSessionOwnerStep(e){"use step";let t={activationToken:e.activationToken,checkpoint:e.checkpoint,delivery:e.delivery,kind:`handoff`,ownerDeploymentId:e.targetDeploymentId,sessionWritable:getRun(e.anchorRunId).getWritable(),sessionId:e.anchorRunId};await startWorkflowOnDeployment(workflowEntryReference,[t],e.targetDeploymentId,e.checkpoint.retention===void 0?void 0:{experimental_retention:e.checkpoint.retention})}function normalizePersistedEvent(e){return normalizePersistedMessageStreamEvent(e)}async function cancelActivityCollector(e){if(e!==void 0)try{await cancelRun(await getWorld(),e,{cancelReason:`Root session creation did not complete`})}catch{log.warn(`failed to cancel unowned activity collector`)}}async function dispatchWorkflowCommand(e,t){let n;try{let r=await resumeSessionInbox(e,t);n={runId:r.ownerRunId,sessionId:await r.sessionId}}catch(n){if(isInactiveCommandTarget(n))return inactiveCommandResult(t);throw logError(log,`failed to dispatch session command`,n,{command:t.kind,token:e}),n}if(t.kind===`reset`){let t=typeof e==`string`?e:sessionCommandHookToken(e.sessionId),r=new Set([sessionCommandHookToken(n.sessionId),t]);await Promise.all([...r].map(e=>waitForHookRelease(sessionInboxHookToken(e),n.runId)))}return activeCommandResult(t,n.sessionId)}function activeCommandResult(e,t){return e.kind===`reset`?{previousSessionId:t,status:`reset`}:e.kind===`send`&&e.delivery!==void 0?{sessionId:t,status:`accepted`,deliveryId:e.delivery.deliveryId}:{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.tasks!==void 0&&(t.tasks=e.tasks),e.turnId!==void 0&&(t.turnId=e.turnId),await dispatchWorkflowCommand({sessionId:e.sessionId},t)}function isInactiveCommandTarget(e){if(e instanceof AcceptedSessionIdentityError)return!1;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 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 waitForHookRelease(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 inbox "${e}".`);await new Promise(e=>setTimeout(e,20))}}async function startWorkflowOnCurrentDeployment(e,t,n){return await startWorkflowOnDeployment(e,t,await resolveCurrentWorkflowDeploymentId(),n)}async function startWorkflowOnDeployment(e,t,n,r){return await withWorkflowStartContext(async()=>{if(n.length===0||n===`latest`)throw Error(`Workflow starts require an exact deployment id.`);return await start(e,t,{...r,deploymentId:n})})}async function resolveCurrentWorkflowDeploymentId(){let e=process.env.VERCEL_DEPLOYMENT_ID?.trim()||await(await getWorld()).getDeploymentId();if(e.length===0||e===`latest`)throw Error(`Workflow runtime could not resolve an exact deployment id.`);return e}async function withWorkflowStartContext(e){let t=context.active(),n=isAgentTraceContext(t)?trace.deleteSpan(t):t;return await context.with(n,e)}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{activityCollectorWorkflowReference,createWorkflowRuntime,requestWorkflowTurnCancellation,sessionTimeoutWorkflowReference,startSessionOwnerStep,startWorkflowOnCurrentDeployment,taskRunWorkflowReference,waitForCommandHookOwner,workflowEntryReference,workflowToolRunWorkflowReference};
|
|
@@ -14,9 +14,6 @@ type AdvertisedModelToolsInput = {
|
|
|
14
14
|
readonly modelTools: ToolSet;
|
|
15
15
|
readonly session: HarnessSession;
|
|
16
16
|
readonly tools: HarnessToolMap;
|
|
17
|
-
readonly workflow?: {
|
|
18
|
-
readonly maxSubagents?: number;
|
|
19
|
-
};
|
|
20
17
|
};
|
|
21
18
|
type AdvertisedModelTools = {
|
|
22
19
|
readonly harnessTools: HarnessToolMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function getAdvertisedTools(e){return`modelTools`in e?getAdvertisedModelTools(e):isToolDefinitionList(e.tools)?filterUnavailableToolDefinitions(e.tools,e.session):filterUnavailableToolMap(e.tools,e.session)}async function getAdvertisedModelTools(e){return{harnessTools:filterUnavailableToolMap(e.tools,e.session),modelTools:e.modelTools,session:e.session}}function filterUnavailableToolDefinitions(e,t){let n=[];for(let r of e)shouldHideTool(r,t)||n.push(r);return n}function filterUnavailableToolMap(e,t){let n=new Map;for(let[r,i]of e)shouldHideTool(i,t)||n.set(r,i);return n}function shouldHideTool(e,t){let n=t.rootSessionId!==void 0;return e.rootOnly===!0||e.behavior?.availability.includes(`root-session`)===!0?n:e.behavior?.availability.includes(`delegated-task-child`)===!0&&t.taskId===void 0}function isToolDefinitionList(e){return Array.isArray(e)}export{getAdvertisedTools};
|
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authorization request/result API for tool execution.
|
|
3
|
-
*
|
|
4
|
-
* Public API:
|
|
5
|
-
* - {@link requestAuthorization} — return from execute to suspend for auth
|
|
6
|
-
* - {@link getAuthorizationResult} — read the callback on resume
|
|
7
|
-
* - {@link createAuthorizationAttempt} — mint one correlated callback URL
|
|
8
|
-
* - {@link isAuthorizationSignal} — type guard
|
|
9
|
-
*
|
|
10
|
-
* ## Resume lifecycle
|
|
11
|
-
*
|
|
12
|
-
* `attemptId` binds the callback to one challenge generation, while `resume`
|
|
13
|
-
* carries strategy data from
|
|
14
|
-
* `startAuthorization` to `completeAuthorization` across the park:
|
|
15
|
-
*
|
|
16
|
-
* 1. `startAuthorization` returns `{ challenge, resume? }`. The runtime
|
|
17
|
-
* stores `resume` on the {@link AuthorizationChallenge} and journals it
|
|
18
|
-
* onto `session.state` via {@link setPendingAuthorization} when the turn
|
|
19
|
-
* parks — so it survives the suspend/resume across a `"use step"`
|
|
20
|
-
* boundary.
|
|
21
|
-
* 2. The IdP redirect hits the framework callback route, which parses it
|
|
22
|
-
* (see `projectAuthorizationCallback` — params only, no headers) and
|
|
23
|
-
* resumes the workflow.
|
|
24
|
-
* 3. On resume the journaled `resume` is paired with the parsed callback
|
|
25
|
-
* into an {@link AuthorizationResult} and handed back to
|
|
26
|
-
* `completeAuthorization({ resume, callback })`.
|
|
27
|
-
*
|
|
28
|
-
* `resume` is serialized across workflow steps to survive the park.
|
|
29
|
-
* Provider-owned strategies (Vercel Connect) omit it so nothing crosses
|
|
30
|
-
* the boundary; a custom PKCE strategy uses it to carry the verifier (or a
|
|
31
|
-
* nonce that re-derives it) from start to finish.
|
|
32
|
-
*/
|
|
33
1
|
import { ContextKey } from "#context/key.js";
|
|
34
2
|
import type { ConnectionAuthorizationChallenge } from "#connections/errors.js";
|
|
35
3
|
import type { AuthorizationCallback, ConnectionPrincipal } from "#shared/connection-types.js";
|
|
@@ -112,9 +80,9 @@ export declare function consumeAuthorizationResult(name: string, instanceId?: st
|
|
|
112
80
|
* Builds a callback URL for external systems. `name` and `attemptId` identify
|
|
113
81
|
* the exact challenge in the URL path.
|
|
114
82
|
*
|
|
115
|
-
* By default the URL embeds the session's
|
|
83
|
+
* By default the URL embeds the session's stable inbox token.
|
|
116
84
|
* A runtime with its own continuation supplies that hook through AuthorizationHookKey.
|
|
117
|
-
* It is independent of the continuation token, so channel
|
|
85
|
+
* It is independent of the continuation token, so channel aliasing mid-turn
|
|
118
86
|
* does not invalidate the callback URL.
|
|
119
87
|
*
|
|
120
88
|
* Returns `undefined` if no callback address is available.
|
|
@@ -144,9 +112,9 @@ export declare function modelFacingAuthorizationOutput(signal: AuthorizationSign
|
|
|
144
112
|
export declare function authorizationPendingModelText(connections: readonly string[]): string;
|
|
145
113
|
export declare function isPendingAuthorizationToolOutput(value: unknown): boolean;
|
|
146
114
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
115
|
+
* Physical hook token embedded in a session's authorization callback URLs.
|
|
116
|
+
* The callback route resumes exactly this hook, so it is the stable inbox's
|
|
117
|
+
* physical address rather than its logical session token.
|
|
150
118
|
*/
|
|
151
119
|
export declare function authHookToken(sessionId: string): string;
|
|
152
120
|
interface NamedAuthorizationResult extends AuthorizationResult {
|