eve 0.56.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 +40 -0
- package/dist/src/channel/adapter-context.d.ts +1 -1
- package/dist/src/channel/adapter.d.ts +2 -2
- package/dist/src/channel/channel-address.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-RUGSwq8b.js → use-eve-agent-C2APNCdP.js} +45 -12
- package/dist/src/chunks/{use-eve-agent-CMdMlS7Y.js → use-eve-agent-D0YnDLi_.js} +45 -12
- package/dist/src/cli/commands/init.d.ts +2 -6
- package/dist/src/cli/commands/init.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 +1 -6
- package/dist/src/cli/dev/tui/blocks.js +1 -1
- package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
- 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 +12 -18
- 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 +3 -2
- 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/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/client/agent-info-schema.d.ts +2 -0
- 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 +15 -6
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +3 -1
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.js +4 -3
- 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/create-session-step.d.ts +1 -1
- package/dist/src/execution/durable-session-store.d.ts +10 -48
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +0 -16
- 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 -0
- 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/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.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.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/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 -0
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/channel-delivery.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +1 -0
- package/dist/src/instrumentation/native-events.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/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/dev-authored-source-watcher.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/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/discord/discordChannel.js +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/telegramChannel.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +1 -1
- package/dist/src/public/definitions/channel.js +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/vercel/index.d.ts +2 -1
- package/dist/src/public/vercel/index.js +1 -1
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/self-modification/agent.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 +1 -1
- 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/chatgpt-model.d.ts +2 -2
- package/dist/src/shared/chatgpt-model.js +1 -1
- 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/vercel-services.d.ts +1 -0
- package/dist/src/shared/vercel-services.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.js +1 -1
- package/dist/src/tasks/types.d.ts +1 -1
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- 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/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +22 -22
- package/docs/channels/chat-sdk.mdx +4 -2
- package/docs/channels/custom.mdx +16 -10
- package/docs/channels/eve.mdx +3 -1
- package/docs/channels/linq.mdx +1 -1
- package/docs/channels/overview.mdx +4 -2
- package/docs/channels/photon.mdx +4 -1
- package/docs/channels/slack.mdx +3 -1
- package/docs/concepts/execution-model-and-durability.mdx +62 -13
- package/docs/concepts/sessions-runs-and-streaming.md +14 -5
- package/docs/getting-started.mdx +7 -3
- package/docs/guides/deployment/vercel.mdx +1 -1
- package/docs/guides/dev-tui.md +54 -27
- package/docs/guides/frontend/overview.mdx +3 -1
- package/docs/guides/instrumentation/meta.json +1 -0
- package/docs/memory/custom-provider.md +1 -1
- package/docs/protocols/acp.md +1 -1
- package/docs/reference/cli.md +2 -2
- package/docs/reference/telemetry.md +1 -1
- package/docs/reference/typescript-api.md +12 -5
- package/docs/sandbox.mdx +3 -3
- package/docs/subagents/index.mdx +2 -2
- package/docs/tools/workflows.mdx +1 -1
- 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/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 -85
- 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/subagents/handles/rebase.d.ts +0 -4
- package/dist/src/subagents/handles/rebase.js +0 -1
- /package/dist/src/{execution/next-driver-action.js → client/eve-agent-store-state.js} +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { DeliverHookPayload, DeliverPayload } from "#channel/types.js";
|
|
2
|
+
import type { getSessionTaskCohorts } from "#tasks/session-task-cohorts.js";
|
|
3
|
+
export type SessionControl = "clear" | "compact" | "expired" | "reset";
|
|
4
|
+
type TaskCohorts = ReturnType<typeof getSessionTaskCohorts>;
|
|
5
|
+
export interface DeliveryAdmission {
|
|
6
|
+
readonly delivery: DeliverHookPayload;
|
|
7
|
+
readonly sequence: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TurnSelection {
|
|
10
|
+
readonly delivery: DeliverHookPayload;
|
|
11
|
+
/**
|
|
12
|
+
* True only for a lone, callerless conversational delivery that arrived
|
|
13
|
+
* while nothing else was pending. Such a delivery may move the session to
|
|
14
|
+
* the deployment that accepted it.
|
|
15
|
+
*/
|
|
16
|
+
readonly handoffEligible: boolean;
|
|
17
|
+
readonly kind: "turn";
|
|
18
|
+
/** Sequences of every admission folded into this turn. */
|
|
19
|
+
readonly sequences: readonly number[];
|
|
20
|
+
}
|
|
21
|
+
export type SessionInputSelection = TurnSelection | {
|
|
22
|
+
readonly control: SessionControl;
|
|
23
|
+
readonly kind: "control";
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: "authorization-resume";
|
|
26
|
+
readonly payloads: readonly DeliverPayload[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Ordered, admitted session input, plus the idempotency and cancellation
|
|
30
|
+
* facts for task deliveries this owner has seen. Entries are private; callers
|
|
31
|
+
* receive typed admission and selection values. Everything here is rebuilt
|
|
32
|
+
* deterministically on replay, and a successor never inherits it because
|
|
33
|
+
* handoff requires every indexed task to be terminal.
|
|
34
|
+
*/
|
|
35
|
+
export declare class SessionInputQueue {
|
|
36
|
+
private readonly entries;
|
|
37
|
+
private readonly cancelledTaskIds;
|
|
38
|
+
private readonly seenTaskDeliveryIds;
|
|
39
|
+
private nextSequence;
|
|
40
|
+
get pendingCount(): number;
|
|
41
|
+
/** Admits a delivery unless it repeats or belongs to a cancelled task. */
|
|
42
|
+
enqueueDelivery(delivery: DeliverHookPayload): DeliveryAdmission | undefined;
|
|
43
|
+
/** A caller's own task id counts as seen so its echo is not admitted twice. */
|
|
44
|
+
rememberTask(taskId: string): void;
|
|
45
|
+
isTaskCancelled(taskId: string): boolean;
|
|
46
|
+
enqueueControl(control: SessionControl): void;
|
|
47
|
+
/** Keeps one payload per authorization attempt; a repeated callback for the same attempt is dropped. */
|
|
48
|
+
enqueueAuthorization(payloads: readonly DeliverPayload[]): void;
|
|
49
|
+
delivery(sequence: number): DeliverHookPayload | undefined;
|
|
50
|
+
replaceDelivery(sequence: number, delivery: DeliverHookPayload | undefined): void;
|
|
51
|
+
/** Drops queued notifications from a cancelled task and refuses later ones. */
|
|
52
|
+
cancelTask(taskId: string): void;
|
|
53
|
+
takeSteering(admitted: ReadonlySet<number>, callerCallId: string | undefined): TurnSelection | undefined;
|
|
54
|
+
takeNext(cohorts: TaskCohorts, options?: {
|
|
55
|
+
readonly deferDeliveries?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Attempt ids of the open authorization challenge. Callbacks for other
|
|
58
|
+
* attempts are stale and dropped; once every expected attempt has
|
|
59
|
+
* reported, the collected payloads resume the challenge ahead of
|
|
60
|
+
* ordinary input.
|
|
61
|
+
*/
|
|
62
|
+
readonly expectedAttemptIds?: ReadonlySet<string>;
|
|
63
|
+
/** Sequence of a delivery admitted while nothing else was pending. */
|
|
64
|
+
readonly freshSequence?: number;
|
|
65
|
+
}): SessionInputSelection | undefined;
|
|
66
|
+
private nextActionableIndex;
|
|
67
|
+
private takeSelectionAt;
|
|
68
|
+
private isCancelledTaskDelivery;
|
|
69
|
+
private retain;
|
|
70
|
+
}
|
|
71
|
+
export declare function isSteeringDelivery(delivery: DeliverHookPayload, callerCallId: string | undefined): boolean;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsonValuesEqual}from"#shared/json.js";import{coalesceDeliveries}from"#harness/messages.js";var SessionInputQueue=class{entries=[];cancelledTaskIds=new Set;seenTaskDeliveryIds=new Set;nextSequence=0;get pendingCount(){return this.entries.length}enqueueDelivery(e){let t=taskDeliveryId(e);if(t!==void 0){if(this.seenTaskDeliveryIds.has(t)||this.isCancelledTaskDelivery(t))return;this.seenTaskDeliveryIds.add(t)}let n={delivery:e,sequence:this.nextSequence++};return this.entries.push({...n,kind:`delivery`}),n}rememberTask(e){this.seenTaskDeliveryIds.add(e)}isTaskCancelled(e){return this.cancelledTaskIds.has(e)}enqueueControl(e){this.entries.push({control:e,kind:`control`,sequence:this.nextSequence++})}enqueueAuthorization(e){for(let t of e){let e=authorizationAttemptId(t);e!==void 0&&(this.entries.some(t=>t.kind===`authorization`&&t.attemptId===e)||this.entries.push({attemptId:e,kind:`authorization`,payload:t,sequence:this.nextSequence++}))}}delivery(e){return this.entries.find(t=>t.kind===`delivery`&&t.sequence===e)?.delivery}replaceDelivery(e,t){let n=this.entries.findIndex(t=>t.kind===`delivery`&&t.sequence===e);if(!(n<0)){if(t===void 0){this.entries.splice(n,1);return}this.entries[n]={delivery:t,kind:`delivery`,sequence:e}}}cancelTask(e){this.cancelledTaskIds.add(e),this.retain(t=>t.kind!==`delivery`||!isTaskDelivery(t.delivery,t=>t===e||t.startsWith(`${e}:`)))}takeSteering(e,t){let n=this.entries.filter(n=>n.kind===`delivery`&&e.has(n.sequence)&&isSteeringDelivery(n.delivery,t));if(n.length!==0)return this.retain(e=>e.kind!==`delivery`||!n.includes(e)),{delivery:combine(n),handoffEligible:!1,kind:`turn`,sequences:n.map(({sequence:e})=>e)}}takeNext(e,t){let n=t?.expectedAttemptIds??new Set;if(this.retain(e=>e.kind!==`authorization`||n.has(e.attemptId)),n.size>0){let e=new Map(this.entries.flatMap(e=>e.kind===`authorization`?[[e.attemptId,e.payload]]:[]));if([...n].every(t=>e.has(t)))return this.retain(e=>e.kind!==`authorization`),{kind:`authorization-resume`,payloads:[...n].map(t=>e.get(t))}}let r=this.nextActionableIndex(e,t?.deferDeliveries===!0);if(!(r<0))return this.takeSelectionAt(r,e,t?.freshSequence)}nextActionableIndex(e,t){let n=this.entries.filter(e=>e.kind===`delivery`),r=new Set(n.flatMap(({delivery:e})=>{let t=completionTaskId(e);return t===void 0?[]:[t]})),i=new Set;for(let[t,n]of e)!n.settled&&!r.has(t)&&!this.cancelledTaskIds.has(t)&&i.add(n.cohortId);return this.entries.findIndex(n=>{if(n.kind===`control`)return!0;if(n.kind===`authorization`||t)return!1;let r=completionCohort(n.delivery,e);return r===void 0||!i.has(r)})}takeSelectionAt(e,t,n){let r=this.entries[e];if(r.kind!==`delivery`)return this.entries.splice(e,1),r.kind===`control`?{control:r.control,kind:`control`}:{kind:`authorization-resume`,payloads:[r.payload]};let i=completionCohort(r.delivery,t);if(i!==void 0){let r=this.entries.findLastIndex(e=>e.kind===`delivery`&&completionCohort(e.delivery,t)===i),a=this.entries.findIndex((n,i)=>i>e&&i<r&&(n.kind!==`delivery`||completionCohort(n.delivery,t)===void 0));if(a>=0)return this.takeSelectionAt(a,t,n)}let a=this.entries.splice(e,1)[0];if(a.kind!==`delivery`)throw Error(`Selected a non-delivery entry as a turn.`);let o=[a],s=completionCohort(a.delivery,t);if(s!==void 0){let e=this.entries.filter(e=>e.kind===`delivery`&&completionCohort(e.delivery,t)===s);o.push(...e),this.retain(e=>e.kind!==`delivery`||completionCohort(e.delivery,t)!==s)}else{let t=a.delivery.auth!=null&&a.delivery.auth.principalType!==`anonymous`,n=a.delivery.caller;for(;this.entries.length>e;){let r=this.entries[e];if(r?.kind!==`delivery`||a.delivery.taskDeliveryId!==void 0||r.delivery.taskDeliveryId!==void 0||!t||!jsonValuesEqual(a.delivery.auth,r.delivery.auth)||n!==void 0&&r.delivery.caller!==void 0)break;o.push(this.entries.splice(e,1)[0]),n??=r.delivery.caller}}let c=o.map(({sequence:e})=>e),l=combine(o);return{delivery:l,handoffEligible:c.length===1&&c[0]===n&&l.caller===void 0&&taskDeliveryId(l)===void 0&&this.entries.length===0,kind:`turn`,sequences:c}}isCancelledTaskDelivery(e){for(let t of this.cancelledTaskIds)if(e===t||e.startsWith(`${t}:`))return!0;return!1}retain(e){let t=this.entries.filter(e);this.entries.splice(0,this.entries.length,...t)}};function isSteeringDelivery(e,t){return e.taskDeliveryId===void 0&&(e.turnPolicy??`steer`)===`steer`&&(e.caller===void 0||e.caller.callId===t)}function combine(e){return e.length===1?e[0].delivery:coalesceDeliveries(e.map(({delivery:e})=>e))}function authorizationAttemptId(e){let t=e.authorizationCallback;return typeof t?.attemptId==`string`?t.attemptId:void 0}function taskDeliveryId(e){return e.taskDeliveryId??e.caller?.taskId}function isTaskDelivery(e,t){let n=taskDeliveryId(e);return n!==void 0&&t(n)}function completionCohort(e,t){let n=completionTaskId(e);return n===void 0?void 0:t.get(n)?.cohortId}function completionTaskId(e){if(e.caller===void 0&&e.taskDeliveryId?.endsWith(`:ready:completed`))return e.taskDeliveryId.slice(0,-16)}export{SessionInputQueue,isSteeringDelivery};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DeliverPayload } from "#channel/types.js";
|
|
2
|
+
import type { SessionControl, SessionInputQueue, TurnSelection } from "#execution/session/input-queue.js";
|
|
3
|
+
import type { SessionInboxReader } from "#execution/session-inbox/inbox.js";
|
|
4
|
+
import type { SessionStateCursor } from "#execution/session/state-cursor.js";
|
|
5
|
+
import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
|
|
6
|
+
export type NextTurnInstruction = {
|
|
7
|
+
readonly kind: "workflow";
|
|
8
|
+
readonly message: WorkflowToolRunMessage;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: "authorization-resume";
|
|
11
|
+
readonly payloads: readonly DeliverPayload[];
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: SessionControl;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "closed";
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "cancel-turn";
|
|
18
|
+
} | TurnSelection;
|
|
19
|
+
/**
|
|
20
|
+
* Waits for the next input the parked owner must act on. While an
|
|
21
|
+
* authorization challenge is open, its callbacks collect in the queue and
|
|
22
|
+
* resume the challenge once every expected attempt has reported; ordinary
|
|
23
|
+
* deliveries keep starting turns in the meantime. Fully routed descendant
|
|
24
|
+
* deliveries leave nothing for the parent, so the wait continues.
|
|
25
|
+
*/
|
|
26
|
+
export declare function nextTurnDelivery(input: {
|
|
27
|
+
readonly inbox: SessionInboxReader;
|
|
28
|
+
readonly cursor: SessionStateCursor;
|
|
29
|
+
readonly deferDeliveries?: boolean;
|
|
30
|
+
readonly expectedAttemptIds?: ReadonlySet<string>;
|
|
31
|
+
readonly queue: SessionInputQueue;
|
|
32
|
+
}): Promise<NextTurnInstruction>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";import{admitSessionInboxPayload,applySessionCancellation}from"#execution/session/admission.js";import{getSessionTaskCohorts}from"#tasks/session-task-cohorts.js";async function nextTurnDelivery(e){let{inbox:t,cursor:n,queue:r}=e,i;for(;;){let a=r.takeNext(getSessionTaskCohorts(n.sessionState.snapshot.session.state),{deferDeliveries:e.deferDeliveries,expectedAttemptIds:e.expectedAttemptIds,freshSequence:t.hasPending()?void 0:i});if(a?.kind===`control`)return{kind:a.control};if(a?.kind===`authorization-resume`)return a;if(a?.kind===`turn`){let e=await routeSelectedDelivery(a,n);if(e.kind===`cancel-turn`)return e;if(e.kind===`consumed`)continue;return e}let o=r.pendingCount===0,s=await t.next();if(s===void 0)return{kind:`closed`};let c=await admitSessionInboxPayload(s,e);switch(i=o&&c.kind===`delivery`?c.admission.sequence:void 0,c.kind){case`workflow`:return{kind:`workflow`,message:c.message};case`cancel`:await applySessionCancellation(c.command,e)}}}export{nextTurnDelivery};
|
|
@@ -2,7 +2,6 @@ import type { HarnessSession } from "#harness/types.js";
|
|
|
2
2
|
/** Derives the workflow fields used to select the next action at the park boundary. */
|
|
3
3
|
export declare function derivePendingState(session: HarnessSession): {
|
|
4
4
|
readonly authorizationAttemptIds?: readonly string[];
|
|
5
|
-
readonly authorizationNames?: readonly string[];
|
|
6
5
|
readonly hasPendingAuthorization: boolean;
|
|
7
6
|
readonly hasPendingInputBatch: boolean;
|
|
8
7
|
readonly pendingCoordinationCallIds?: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getPendingCoordinationBatch}from"#harness/coordination.js";import{getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}from"#harness/input-requests.js";function derivePendingState(e){let t=getPendingCoordinationBatch(e.state),n=getPendingAuthorization(e.state),r={authorizationAttemptIds:n?.challenges.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),
|
|
1
|
+
import{getPendingCoordinationBatch}from"#harness/coordination.js";import{getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}from"#harness/input-requests.js";function derivePendingState(e){let t=getPendingCoordinationBatch(e.state),n=getPendingAuthorization(e.state),r={authorizationAttemptIds:n?.challenges.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),hasPendingAuthorization:n!==void 0,hasPendingInputBatch:hasPendingInputBatch(e.state)};return t===void 0?r:{...r,pendingCoordinationCallIds:[...t.runtimeActions,...t.tasks].map(e=>e.callId)}}export{derivePendingState};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DeliverHookPayload, SessionCapabilities, TurnCaller } from "#channel/types.js";
|
|
2
|
+
import type { AgentWorkflowRetentionDefinition } from "#shared/agent-definition.js";
|
|
3
|
+
import type { RunMode } from "#shared/run-mode.js";
|
|
4
|
+
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
5
|
+
import { type SessionInboxHandle } from "#execution/session-inbox/inbox.js";
|
|
6
|
+
import type { WorkflowEntryResult } from "#execution/session/entry-input.js";
|
|
7
|
+
/**
|
|
8
|
+
* Who to tell when this owner exits. The original run anchors the public
|
|
9
|
+
* stream itself; a successor signals the original run. A `self` anchor may
|
|
10
|
+
* also name a `notify` step that runs with the final result, which lets an
|
|
11
|
+
* importer settle whatever predecessor still holds the stream open.
|
|
12
|
+
*/
|
|
13
|
+
export type SessionAnchor = {
|
|
14
|
+
readonly kind: "self";
|
|
15
|
+
readonly notify?: (result: WorkflowEntryResult) => Promise<void>;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "successor";
|
|
18
|
+
};
|
|
19
|
+
export interface SessionBoot {
|
|
20
|
+
readonly anchor: SessionAnchor;
|
|
21
|
+
readonly caller: TurnCaller | undefined;
|
|
22
|
+
readonly capabilities?: SessionCapabilities;
|
|
23
|
+
readonly deploymentId: string;
|
|
24
|
+
readonly initialInput: DeliverHookPayload | undefined;
|
|
25
|
+
readonly mode: RunMode;
|
|
26
|
+
readonly retention?: AgentWorkflowRetentionDefinition;
|
|
27
|
+
readonly serializedContext: Record<string, unknown>;
|
|
28
|
+
readonly sessionId: string;
|
|
29
|
+
readonly sessionState: DurableSessionState;
|
|
30
|
+
readonly sessionTimeoutDeadline?: Date;
|
|
31
|
+
readonly sessionTimeoutMs: number | false;
|
|
32
|
+
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
33
|
+
}
|
|
34
|
+
/** Runs an already prepared owner against its session's existing stream. */
|
|
35
|
+
export declare function runPreparedSession(boot: SessionBoot, inbox: SessionInboxHandle): Promise<WorkflowEntryResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Terminal path for a boot that failed before the session loop could run.
|
|
38
|
+
* The caller is re-resolved from context because no turn ever bound it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function failSession(input: {
|
|
41
|
+
readonly error: unknown;
|
|
42
|
+
readonly mode: RunMode;
|
|
43
|
+
readonly serializedContext: Record<string, unknown>;
|
|
44
|
+
readonly sessionId: string;
|
|
45
|
+
readonly sessionState: DurableSessionState | undefined;
|
|
46
|
+
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
47
|
+
}): Promise<never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import"#execution/session-inbox/inbox.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{signalSessionAnchorStep}from"#execution/session/handoff-steps.js";import{SessionHandoff,sessionAnchorToken}from"#execution/session/handoff.js";import{nextTurnDelivery}from"#execution/session/next-input.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{SessionInputQueue}from"#execution/session/input-queue.js";import{SessionExecution}from"#execution/session/turn.js";import{SessionStateCursor}from"#execution/session/state-cursor.js";import{finalizeSession}from"#execution/session/finalization.js";import{createSessionTimeoutControl}from"#execution/session/timeout-control.js";function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runPreparedSession(e,t){let n=new SessionStateCursor({inbox:t,sessionWritable:e.sessionWritable,serializedContext:e.serializedContext,sessionState:e.sessionState}),r={caller:e.caller,terminalEmitted:!1},i=new SessionHandoff({checkpoint:{capabilities:e.capabilities,mode:e.mode,retention:e.retention,sessionTimeoutMs:e.sessionTimeoutMs},deploymentId:e.deploymentId,inbox:t,isInitialOwner:e.anchor.kind===`self`,sessionId:e.sessionId}),a={output:``,isError:!0};try{let o;try{o=await runSessionLoop(e,{cursor:n,handoff:i,inbox:t,progress:r})}finally{await t.dispose()}return o.kind===`transferred`?e.anchor.kind===`self`?(a=await i.awaitAnchoredResult(),a):{output:``}:(a=await finalizeSession(o.outcome,{caller:r.caller,cursor:n,mode:e.mode,sessionWritable:e.sessionWritable}),r.terminalEmitted=!0,a)}catch(t){throw r.terminalEmitted||await finalizeSession({error:t,kind:`failed`,turnId:r.turnId},{caller:r.caller,cursor:n,mode:e.mode,sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}finally{await reportResultToAnchor(e,a,i)}}async function failSession(e){let t;try{t=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext})}catch{}throw await finalizeSession({error:e.error,kind:`failed`},{caller:t,cursor:{serializedContext:e.serializedContext,sessionState:e.sessionState},mode:e.mode,sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}async function reportResultToAnchor(e,t,n){switch(e.anchor.kind){case`self`:await n.disposeAnchor(),await e.anchor.notify?.(t);return;case`successor`:await signalSessionAnchorStep({result:t,token:sessionAnchorToken(e.sessionId)});return}}async function runSessionLoop(e,t){let{cursor:n,handoff:r,inbox:i,progress:a}=t,o=new SessionInputQueue,s=new SessionExecution({capabilities:e.capabilities,cursor:n,inbox:i,mode:e.mode,queue:o,sessionId:e.sessionId}),c=e.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:e.sessionTimeoutDeadline,sessionId:e.sessionId}),nextParkedActivity=async t=>{for(;;){let r=await nextTurnDelivery({cursor:n,deferDeliveries:e.mode===`task`&&t.size>0,expectedAttemptIds:t,inbox:i,queue:o});if(r.kind!==`workflow`)return r;await s.handleWorkflowMessage(r.message)}},l=0,runTurn=async e=>{let t=a.caller;return t?.taskId!==void 0&&o.rememberTask(t.taskId),t!==void 0&&await n.apply({serializedContext:await bindTurnCallerContextStep({caller:t,serializedContext:n.serializedContext})}),a.turnId=`turn_${String(l++)}`,await s.runTurn(e)},settleCancelledTurn=async()=>{let t=await settleCancelledTurnStep({sessionWritable:e.sessionWritable,serializedContext:n.serializedContext,sessionState:n.sessionState});return await n.apply(t),a.caller=void 0,t};try{let[t,i]=await Promise.allSettled([runTurn(e.initialInput===void 0?void 0:{delivery:e.initialInput}),c?.start()]);if(i.status===`rejected`)throw i.reason;if(t.status===`rejected`)throw t.reason;let o=t.value;for(;;){if(o.kind===`done`)return{kind:`terminal`,outcome:{action:o,kind:`done`}};if(o.cancelled===!0){let t={caller:a.caller,sessionId:e.sessionId},n=await settleCancelledTurn();await notifyCancelledTaskCallerStep(n.usage===void 0?t:{...t,usage:n.usage})}else o.settled!==void 0&&(a.caller!==void 0&&await notifyTurnCallerStep({caller:a.caller,lifecycle:`parked`,sessionId:e.sessionId,settled:o.settled}),a.caller=void 0);let t=await nextParkedActivity(new Set(o.authorizationAttemptIds??[]));switch(t.kind){case`authorization-resume`:o=await runTurn({delivery:{kind:`deliver`,payloads:t.payloads}});continue;case`expired`:case`reset`:case`closed`:return{kind:`terminal`,outcome:{kind:`expired`}};case`clear`:case`compact`:o=await runTurn({control:t.kind});continue;case`cancel-turn`:await cancelDescendantTurnsStep({serializedContext:n.serializedContext,sessionState:n.sessionState}),await settleCancelledTurn(),o={...o,settled:void 0};continue;case`turn`:if((await r.tryTransfer(t,{serializedContext:n.serializedContext,sessionState:n.sessionState})).kind===`transferred`)return{kind:`transferred`};t.delivery.caller!==void 0&&(a.caller=t.delivery.caller),o=await runTurn({delivery:t.delivery});continue}}}finally{await c?.dispose()}}export{failSession,runPreparedSession};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TurnSelection } from "#execution/session/input-queue.js";
|
|
2
|
+
import type { SessionStateCursor } from "#execution/session/state-cursor.js";
|
|
3
|
+
export type RoutedTurnSelection = {
|
|
4
|
+
readonly kind: "cancel-turn";
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: "consumed";
|
|
7
|
+
} | TurnSelection;
|
|
8
|
+
/** Routes one selected delivery exactly once, independent of active/parked mode. */
|
|
9
|
+
export declare function routeSelectedDelivery(selection: TurnSelection, cursor: SessionStateCursor): Promise<RoutedTurnSelection>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{routeDeliverToChildren}from"#execution/route-child-delivery.js";async function routeSelectedDelivery(e,t){let n=await routeDeliverToChildren({delivery:e.delivery,sessionWritable:t.sessionWritable,serializedContext:t.serializedContext,sessionState:t.sessionState});return await t.apply(n),n.kind===`cancel-turn`?{kind:`cancel-turn`}:n.remainder===void 0?{kind:`consumed`}:{...e,delivery:n.remainder}}export{routeSelectedDelivery};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
+
import type { SessionInboxOwnership } from "#execution/session-inbox/inbox.js";
|
|
3
|
+
import type { TurnStepInput, TurnStepPayload } from "#execution/session/turn-step-types.js";
|
|
4
|
+
/** A durable-state transition; absent fields keep the cursor's current value. */
|
|
5
|
+
export interface SessionStateTransition {
|
|
6
|
+
readonly serializedContext?: Record<string, unknown>;
|
|
7
|
+
readonly sessionState?: DurableSessionState;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The one mutable serialized-context / session-state pair owned by the
|
|
11
|
+
* workflow executing a session. Steps return transitions; the cursor adopts
|
|
12
|
+
* them and claims any continuation address a step introduced, so every hook
|
|
13
|
+
* the session answers to is registered before the next step runs.
|
|
14
|
+
*/
|
|
15
|
+
export declare class SessionStateCursor {
|
|
16
|
+
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
17
|
+
private readonly inbox;
|
|
18
|
+
private currentSerializedContext;
|
|
19
|
+
private currentSessionState;
|
|
20
|
+
constructor(input: {
|
|
21
|
+
readonly inbox: Pick<SessionInboxOwnership, "claimSessionHooks">;
|
|
22
|
+
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
23
|
+
readonly serializedContext: Record<string, unknown>;
|
|
24
|
+
readonly sessionState: DurableSessionState;
|
|
25
|
+
});
|
|
26
|
+
get serializedContext(): Record<string, unknown>;
|
|
27
|
+
get sessionState(): DurableSessionState;
|
|
28
|
+
/** Applies a transition after claiming every continuation address it introduced. */
|
|
29
|
+
apply(transition: SessionStateTransition): Promise<void>;
|
|
30
|
+
createStepInput(input: TurnStepPayload | undefined, signals: Pick<TurnStepInput, "abortSignal" | "steeringSignal">): TurnStepInput;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sessionHookTokens}from"#execution/session/hook-tokens.js";var SessionStateCursor=class{sessionWritable;inbox;currentSerializedContext;currentSessionState;constructor(e){this.inbox=e.inbox,this.sessionWritable=e.sessionWritable,this.currentSerializedContext=e.serializedContext,this.currentSessionState=e.sessionState}get serializedContext(){return this.currentSerializedContext}get sessionState(){return this.currentSessionState}async apply(e){let t=e.serializedContext??this.currentSerializedContext,n=e.sessionState??this.currentSessionState;await this.inbox.claimSessionHooks(sessionHookTokens({serializedContext:t,sessionState:n})),this.currentSerializedContext=t,this.currentSessionState=n}createStepInput(e,t){return{...t,input:e,sessionWritable:this.sessionWritable,serializedContext:this.currentSerializedContext,sessionState:this.currentSessionState}}};export{SessionStateCursor};
|
|
@@ -6,5 +6,5 @@ export interface SessionTimeoutControl {
|
|
|
6
6
|
/** Creates a timer controller for one stable session command inbox. */
|
|
7
7
|
export declare function createSessionTimeoutControl(input: {
|
|
8
8
|
readonly deadline: Date;
|
|
9
|
-
readonly
|
|
9
|
+
readonly sessionId: string;
|
|
10
10
|
}): SessionTimeoutControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sessionCommandHookToken}from"#execution/session-inbox/address.js";import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{cancelSessionTimeoutStep,startSessionTimeoutStep}from"#execution/session/timeout-steps.js";function createSessionTimeoutControl(e){let t;return{async dispose(){if(t===void 0)return;let e=t;t=void 0,await cancelSessionTimeoutStep({runId:e.runId})},async start(){t===void 0&&(t=await startSessionTimeoutStep({deadline:e.deadline,ownerRunId:getWorkflowMetadata().workflowRunId,token:sessionCommandHookToken(e.sessionId)}))}}}export{createSessionTimeoutControl};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { SessionTimeoutWorkflowInput } from "#execution/session
|
|
1
|
+
import type { SessionTimeoutWorkflowInput } from "#execution/session/timeout-workflow.js";
|
|
2
2
|
/** Starts the durable timer that signals one session deadline. */
|
|
3
3
|
export declare function startSessionTimeoutStep(input: SessionTimeoutWorkflowInput): Promise<{
|
|
4
4
|
readonly runId: string;
|
|
5
5
|
}>;
|
|
6
|
-
/** Resumes the owning
|
|
6
|
+
/** Resumes the owning session when its durable timer elapses. */
|
|
7
7
|
export declare function signalSessionTimeoutStep(input: {
|
|
8
|
+
readonly ownerRunId: string;
|
|
8
9
|
readonly token: string;
|
|
9
10
|
}): Promise<void>;
|
|
10
11
|
/** Cancels a timer whose session reached another terminal outcome first. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{walkCauseChain}from"#shared/errors.js";import{sessionTimeoutWorkflowReference,startWorkflowOnCurrentDeployment}from"#execution/workflow-runtime.js";import{cancelRun,getWorld}from"#internal/workflow/runtime.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeSessionInbox}from"#execution/session-inbox/resume.js";async function startSessionTimeoutStep(e){"use step";return{runId:(await startWorkflowOnCurrentDeployment(sessionTimeoutWorkflowReference,[e])).runId}}async function signalSessionTimeoutStep(e){"use step";try{await resumeSessionInbox(e.token,{kind:`session-timeout`,ownerRunId:e.ownerRunId})}catch(e){if(!isInactiveTimeoutTarget(e))throw e}}async function cancelSessionTimeoutStep(e){"use step";try{await cancelRun(await getWorld(),e.runId,{cancelReason:`Session ended before its timeout`})}catch(e){if(!isInactiveTimeoutTarget(e))throw e}}function isInactiveTimeoutTarget(e){for(let t of walkCauseChain(e))if(HookNotFoundError.is(t)||WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}export{cancelSessionTimeoutStep,signalSessionTimeoutStep,startSessionTimeoutStep};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface SessionTimeoutWorkflowInput {
|
|
2
2
|
readonly deadline: Date;
|
|
3
|
+
/** Owner run that armed the timer. */
|
|
4
|
+
readonly ownerRunId: string;
|
|
3
5
|
readonly token: string;
|
|
4
6
|
}
|
|
5
|
-
/** Sleeps until the session deadline, then signals its
|
|
7
|
+
/** Sleeps until the session deadline, then signals its current owner. */
|
|
6
8
|
export declare function sessionTimeoutWorkflow(input: SessionTimeoutWorkflowInput): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sleep}from"#compiled/@workflow/core/index.js";import{signalSessionTimeoutStep}from"#execution/session/timeout-steps.js";async function sessionTimeoutWorkflow(e){"use workflow";await sleep(e.deadline),await signalSessionTimeoutStep({ownerRunId:e.ownerRunId,token:e.token})}sessionTimeoutWorkflow.workflowId=`workflow//eve//sessionTimeoutWorkflow`;export{sessionTimeoutWorkflow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const DEFAULT_SESSION_TIMEOUT_MS=2592e6;function sessionTimeoutDeadline(e,t){return e===!1?void 0:new Date(t+e)}export{DEFAULT_SESSION_TIMEOUT_MS,sessionTimeoutDeadline};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DurableStepResult } from "#execution/session/turn-step-types.js";
|
|
2
|
+
import type { StepResult } from "#harness/types.js";
|
|
3
|
+
import type { RunMode } from "#shared/run-mode.js";
|
|
4
|
+
export declare function resolveSessionStepResult(stepResult: StepResult, nextSerializedContext: Record<string, unknown>, mode: RunMode, beforeStepContext: Record<string, unknown>): DurableStepResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDurableSessionState}from"#execution/durable-session-store.js";import{preserveSerializedBackgroundTaskObservabilityState}from"#shared/serialized-observability-state.js";import{derivePendingState}from"#execution/session/pending-turn-state.js";import{hasPendingInputBatch}from"#harness/input-requests.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";function resolveSessionStepResult(e,t,n,r){let i=createDurableSessionState({session:e.session});if(e.steered)return{action:`steered`,serializedContext:t,sessionState:i};let a=e.backgroundTasks===void 0||e.backgroundTaskSession===void 0?{}:{backgroundTaskContext:preserveSerializedBackgroundTaskObservabilityState(r,t,e.backgroundTasks),backgroundTaskState:createDurableSessionState({session:e.backgroundTaskSession}),backgroundTasks:e.backgroundTasks};if(e.next!==null&&typeof e.next==`object`&&`done`in e.next){if(n===`task`&&hasPendingInputBatch(e.session.state))throw Error(`Task mode cannot complete while input requests remain pending.`);let r=getTurnUsageState(e.session.state)?.session;return{action:`done`,...a,output:e.next.output,isError:e.next.isError,serializedContext:t,sessionState:i,usage:r===void 0?void 0:toUsage(r),usageDelta:takeSessionUsageDelta(e.session).delta}}if(e.next===null){let n=derivePendingState(e.session);if(e.settledTurn!==void 0){let{delta:r,session:i}=takeSessionUsageDelta(e.session);return{action:`park`,...a,...n,serializedContext:t,sessionState:createDurableSessionState({session:i}),settled:{output:e.settledTurn.output,isError:e.settledTurn.isError,usage:r}}}return{action:`park`,...a,...n,serializedContext:t,sessionState:i}}return{action:`continue`,...a,serializedContext:t,sessionState:i}}export{resolveSessionStepResult};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { DeliverHookPayload } from "#channel/types.js";
|
|
2
|
+
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
3
|
+
import type { SettledTurn, StepResult } from "#harness/types.js";
|
|
4
|
+
import type { RuntimeActionResult } from "#shared/action-types.js";
|
|
5
|
+
import type { TokenUsage } from "#shared/token-usage.js";
|
|
6
|
+
/** Trusted runtime-action results collected by the session owner. */
|
|
7
|
+
export interface RuntimeActionResultStepInput {
|
|
8
|
+
readonly acceptedAtMsByCallId?: Readonly<Record<string, number>>;
|
|
9
|
+
readonly results: readonly RuntimeActionResult[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Everything one turn step may consume. A step can carry a delivery and a
|
|
13
|
+
* set of runtime results together: steering accepted while a blocking action
|
|
14
|
+
* was in flight is appended ahead of that action's result in the same step.
|
|
15
|
+
*/
|
|
16
|
+
export interface TurnStepPayload {
|
|
17
|
+
readonly control?: "clear" | "compact";
|
|
18
|
+
readonly delivery?: DeliverHookPayload;
|
|
19
|
+
readonly runtimeResults?: RuntimeActionResultStepInput;
|
|
20
|
+
}
|
|
21
|
+
/** Input for one atomic, session-owner-executed turn step. */
|
|
22
|
+
export interface TurnStepInput {
|
|
23
|
+
readonly abortSignal?: AbortSignal;
|
|
24
|
+
readonly steeringSignal?: AbortSignal;
|
|
25
|
+
readonly input: TurnStepPayload | undefined;
|
|
26
|
+
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
27
|
+
readonly serializedContext: Record<string, unknown>;
|
|
28
|
+
readonly sessionState: DurableSessionState;
|
|
29
|
+
}
|
|
30
|
+
interface DurableStepResultFields {
|
|
31
|
+
/** Pre-step context plus the observability state owned by committed background tasks. */
|
|
32
|
+
readonly backgroundTaskContext?: Record<string, unknown>;
|
|
33
|
+
readonly backgroundTaskState?: DurableSessionState;
|
|
34
|
+
readonly backgroundTasks?: StepResult["backgroundTasks"];
|
|
35
|
+
readonly serializedContext: Record<string, unknown>;
|
|
36
|
+
readonly sessionState: DurableSessionState;
|
|
37
|
+
}
|
|
38
|
+
/** Result returned by a session-mutating turn step. */
|
|
39
|
+
export type DurableStepResult = ({
|
|
40
|
+
readonly action: "continue" | "done";
|
|
41
|
+
readonly output?: unknown;
|
|
42
|
+
readonly isError?: boolean;
|
|
43
|
+
readonly usage?: TokenUsage;
|
|
44
|
+
readonly usageDelta?: TokenUsage;
|
|
45
|
+
} | {
|
|
46
|
+
readonly action: "cancelled" | "steered";
|
|
47
|
+
} | {
|
|
48
|
+
readonly action: "park";
|
|
49
|
+
readonly authorizationAttemptIds?: readonly string[];
|
|
50
|
+
readonly hasPendingAuthorization: boolean;
|
|
51
|
+
readonly hasPendingInputBatch: boolean;
|
|
52
|
+
readonly pendingCoordinationCallIds?: readonly string[];
|
|
53
|
+
readonly settled?: SettledTurn;
|
|
54
|
+
}) & DurableStepResultFields;
|
|
55
|
+
/** The only two ways a locally executed conversational turn can settle. */
|
|
56
|
+
export type TurnOutcome = {
|
|
57
|
+
readonly kind: "done";
|
|
58
|
+
readonly output: unknown;
|
|
59
|
+
readonly isError?: boolean;
|
|
60
|
+
readonly usage?: TokenUsage;
|
|
61
|
+
readonly usageDelta?: TokenUsage;
|
|
62
|
+
} | {
|
|
63
|
+
readonly authorizationAttemptIds?: readonly string[];
|
|
64
|
+
readonly cancelled?: true;
|
|
65
|
+
readonly kind: "park";
|
|
66
|
+
readonly settled?: SettledTurn;
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { DurableStepResult } from "#execution/
|
|
2
|
-
import type { TurnStepInput } from "#execution/durable-session-migrations/turn-workflow.js";
|
|
1
|
+
import type { DurableStepResult, TurnStepInput } from "#execution/session/turn-step-types.js";
|
|
3
2
|
export type { TurnStepInput };
|
|
4
3
|
/** Runs a bounded batch of harness model steps inside one durable `"use step"` boundary. */
|
|
5
4
|
export declare function turnStep(rawInput: TurnStepInput): Promise<DurableStepResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,HandleEventKey,ModeKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,StaticModelReferenceKey,TurnDeliveryIdsKey,TurnTaskDeliveryKey}from"#context/keys.js";import{createAuthorizationCompletedEvent,createSessionStartedEvent,createTurnStartedEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{coalesceTurnInputs}from"#harness/messages.js";import{emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{readRetainedBackgroundToolResult,runBackgroundStep}from"#execution/tasks/parent/tool-execution.js";import*as agentTraceState from"#tracing/agent-trace-context-store.js";import{activeTurnId}from"#harness/active-turn-id.js";import{derivePendingState}from"#execution/session/pending-turn-state.js";import{rebindMissingCompiledDynamicToolCallbacks,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{setChannelContext}from"#execution/channel-context.js";import{drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import*as activityCohort from"#execution/activity-cohort.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{resolveSessionStepResult}from"#execution/session/turn-step-result.js";import{createSessionEventSink}from"#execution/session/event-sink.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{resolveEffectiveOutputSchema}from"#execution/effective-output-schema.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{getBackgroundTaskDelivery,markBackgroundTaskStepInput,resolveInitiatingTaskContext,resolveTaskDeliveryContext}from"#tasks/delivery-context.js";import{prepareWorkflowPreambleTrace}from"#execution/workflow-trace-context.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{createExecutionHistoryView}from"#execution/history-view.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{runModelCallBatch}from"#execution/model-call-batching.js";import{createCancelledModelCallBatchResult}from"#execution/cancelled-model-call-batch.js";function channelDeliveryErrorCode(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`&&t.length>0)return t}return`CHANNEL_DELIVERY_FAILED`}async function turnStep(e){"use step";return runSessionStep(e)}async function runSessionStep(e){let t=e.input?.delivery,n=t,r=e.input?.runtimeResults,i=readDurableSession(e.sessionState),a=await deserializeContext(e.serializedContext),o=a.require(ChannelKey),s=a.require(BundleKey),c=resolveEffectiveAgentRuntime(s,a);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&a.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let l=getPendingAuthorization(i.state),u;if(l&&n!==void 0){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(l,n.payloads);if(n={...n,payloads:t},e.length>0){let r=activityCohort.restoreAuthorizationActivity({ctx:a,matches:e,pending:l}),o=e.map(e=>e.result);a.set(PendingAuthorizationResultKey,o),i={...i,state:clearPendingAuthorization(i.state,r)},u=e,t.length===0&&(n=void 0)}}let d=a.get(AuthKey);n?.auth!==void 0&&a.set(AuthKey,n.auth??null);let f=getBackgroundTaskDelivery(n),p=hydrateDurableSession({compactionOverrides:{thresholdPercent:c.thresholdPercent},durable:i,turnAgent:c.turnAgent}),m=createExecutionHistoryView(p),h=bindSessionInstrumentation({agentName:c.turnAgent.id,ctx:a,rootSessionId:p.rootSessionId??p.sessionId,sessionId:p.sessionId}),g=getHarnessEmissionState(p.state);t!==void 0&&await contextStorage.run(a,()=>h?.instrumentChannelDelivery({agentName:s.turnAgent.id,ctx:a,delivery:t,rootSessionId:p.rootSessionId??p.sessionId,sequence:g.sequence,sessionId:p.sessionId,turnId:activeTurnId(g)}));let failChannelDeliveries=async e=>{await contextStorage.run(a,()=>h?.instrumentChannelDelivery({ctx:a,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await h?.flush()},_=createSessionEventSink({abortSignal:e.abortSignal,adapter:o,bundle:s,ctx:a,effectiveAgent:c,instrumentation:h,isFirstTurn:g.sequence===0,sessionWritable:e.sessionWritable,sessionId:p.sessionId}),{adapterCtx:v,dynamicConnections:y,effectiveNode:b,handleEvent:x}=_;try{let S=n!==void 0&&!isHarnessBetweenTurns(p)?structuredClone(v.state):void 0,C;if(n!==void 0){let e=[];try{for(let t of n.payloads){let n=o.deliver?await o.deliver(t,v):defaultDeliverResult(t);n!=null&&e.push(f===void 0?n:markBackgroundTaskStepInput(n))}}catch(e){throw await failChannelDeliveries(e),e}C=e.length===0?void 0:e.reduce(coalesceTurnInputs)}let w=n!==void 0&&C===void 0&&!isHarnessBetweenTurns(p);if(w)d===void 0?a.delete(AuthKey):a.set(AuthKey,d),v.state=S;else if(t!==void 0&&a.set(TurnTaskDeliveryKey,`none`),t?.payloads.some(e=>e.message!==void 0)){let e=t.deliveryMetadata?.map(e=>e.deliveryId)??[];a.set(TurnDeliveryIdsKey,g.turnId?[...new Set([...a.get(TurnDeliveryIdsKey)??[],...e])]:e)}else!g.sessionStarted&&a.get(ChannelDeliveryKey)!==void 0&&a.set(TurnDeliveryIdsKey,[a.require(ChannelDeliveryKey).deliveryId]);r!==void 0&&(r.acceptedAtMsByCallId!==void 0&&a.set(RuntimeActionSettlementTimesKey,r.acceptedAtMsByCallId),C={...C,runtimeActionResults:r.results});let T;if(C!==void 0&&f!==void 0){let e=resolveTaskDeliveryContext({state:i.state,taskDeliveryId:f.taskDeliveryId});e!==void 0&&(a.set(TurnTaskDeliveryKey,e.phase),T=e.rootTurnId,C={...C,context:[...C.context??[],e.context]})}activityCohort.updateActivityRootForDelivery({activeTurnId:activeTurnId(g),ctx:a,delivery:w?void 0:t,sessionState:i.state,taskRootTurnId:T});let E=a.get(TurnTaskDeliveryKey);if(E===`none`||E===`initiating`){let e=resolveInitiatingTaskContext({state:i.state,turnId:activeTurnId(g)});e!==void 0&&a.set(TurnTaskDeliveryKey,e.phase)}if(t!==void 0){let e={...o,state:{...v.state}};setChannelContext(a,e)}if(n!==void 0&&C===void 0&&isHarnessBetweenTurns(p)){await contextStorage.run(a,()=>h?.instrumentChannelDelivery({ctx:a,includeTurn:!1,outcome:`completed`})),await h?.flush();let t=reconcileSessionContinuationToken(a,p),n=serializeContext(a),r=t===p?e.sessionState:createDurableSessionState({session:t});return{action:`park`,...derivePendingState(t),serializedContext:n,sessionState:r}}let D=s.subagentRegistry.dynamicResolvers??[],O=s.resolvedAgent.dynamicToolResolvers??[],k=buildRuntimeIdentity(b);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(s.compiledArtifactsSource),n=g.sessionStarted;if(a.setVirtualContext(StaticModelReferenceKey,c.turnAgent.model??null),!n)a.set(SessionDynamicSubagentRuntimeRevisionKey,t),a.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=createSessionStartedEvent({runtime:k});await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:a,resolvers:D,event:e,messages:m.initial.messages,runtimeRevision:t}),refreshDynamicSessionToolsForRuntimeRevision({ctx:a,resolvers:O,event:e,messages:m.initial.messages,runtimeRevision:t})]),await rebindMissingCompiledDynamicToolCallbacks({ctx:a,event:createTurnStartedEvent({sequence:g.sequence,turnId:activeTurnId(g)}),messages:m.initial.messages,resolvers:O})}}catch(e){throw await failChannelDeliveries(e),e}let A=a.require(ModeKey),j=s.resolvedAgent.config?.experimental?.workflow?.modelCallsPerStep??1,M=a.get(CapabilitiesKey),runHarnessStep=async(t,n)=>{let r=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:c.thresholdPercent},session:t,turnAgent:c.turnAgent});return createExecutionNodeStep({steeringSignal:e.steeringSignal,abortSignal:e.abortSignal,capabilities:M,clearOnly:e.input?.control===`clear`,compactOnly:e.input?.control===`compact`,createRuntime:createWorkflowRuntime,handleEvent:x,historyProjector:m.projector,historyView:m.prepare(r),instrumentation:h,mode:A,modelResolutionScope:{moduleMap:s.moduleMap,nodeId:s.nodeId},node:b})(r,n)},N,P;try{throwIfTurnAborted(e.abortSignal),P=await runModelCallBatch({steeringSignal:e.steeringSignal,initialInput:C,initialSession:p,modelCallsPerStep:j,runStep:async({firstCall:t,session:n,stepInput:r})=>{let i=await runBackgroundStep(a,n,async e=>{a.setVirtualContext(HandleEventKey,x),a.setVirtualContext(StaticModelReferenceKey,c.turnAgent.model??null);let n=t?resolveEffectiveOutputSchema({agentOutputSchema:c.turnAgent.outputSchema,input:C,mode:A,session:e}):e;if(await y.rehydrate(getHarnessEmissionState(n.state),k,isHarnessBetweenTurns(n)),t&&u){let e=getHarnessEmissionState(n.state);if(isHarnessBetweenTurns(n)){prepareDynamicInstructionPreamble(a,m.messages(n));let t=[],r=await prepareWorkflowPreambleTrace({emissionState:e,instrumentation:h});try{e=await emitTurnPreamble(x,{},e,k,r)}finally{t=drainDynamicInstructionUserMessages(a),n={...n,history:[...n.history,...t]}}n=setHarnessEmissionState(n,e)}for(let{authorization:t,result:n}of u){let r=l?.challenges.find(e=>e.attemptId===n.attemptId)?.candidateId;await x(createAuthorizationCompletedEvent({attemptId:n.attemptId,authorization:t,candidateId:r,name:n.name,outcome:`authorized`,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId}))}}return runHarnessStep(n,r)});return throwIfTurnAborted(e.abortSignal),N={result:i,serializedContext:serializeContext(a)},i}})}catch(t){if(!isTurnCancellation(t)&&e.abortSignal?.aborted!==!0)throw await failChannelDeliveries(t),t;let n=readRetainedBackgroundToolResult(a);return h?.rememberBackgroundTasks(n?.backgroundTasks??[]),createCancelledModelCallBatchResult({beforeBatchContext:e.serializedContext,checkpoint:N,ctx:a,initialSession:p,stepInput:C})}h?.rememberBackgroundTasks(P.backgroundTasks??[]);let F=reconcileSessionContinuationToken(a,P.session);agentTraceState.pruneAgentTraceState(a,F.sessionId,F.state);let I=serializeContext(a);P={...P,session:F};let L=resolveSessionStepResult(P,I,A,e.serializedContext);return L.action===`done`&&await _.close(),L}finally{_.release()}}export{turnStep};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SessionCapabilities } from "#channel/types.js";
|
|
2
|
+
import { type SessionInputQueue } from "#execution/session/input-queue.js";
|
|
3
|
+
import type { SessionInboxReader } from "#execution/session-inbox/inbox.js";
|
|
4
|
+
import type { SessionStateCursor } from "#execution/session/state-cursor.js";
|
|
5
|
+
import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
|
|
6
|
+
import type { TurnOutcome, TurnStepPayload } from "#execution/session/turn-step-types.js";
|
|
7
|
+
import type { RunMode } from "#shared/run-mode.js";
|
|
8
|
+
import type { RuntimeActionResult } from "#shared/action-types.js";
|
|
9
|
+
export interface SessionExecutionInput {
|
|
10
|
+
readonly capabilities?: SessionCapabilities;
|
|
11
|
+
readonly cursor: SessionStateCursor;
|
|
12
|
+
readonly inbox: SessionInboxReader;
|
|
13
|
+
readonly mode: RunMode;
|
|
14
|
+
readonly queue: SessionInputQueue;
|
|
15
|
+
readonly sessionId: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Executes conversational turns inside the owning session workflow: runs
|
|
19
|
+
* `turnStep`, services the inbox at committed boundaries, coordinates waits,
|
|
20
|
+
* and settles locally. There is no child run and no transport protocol.
|
|
21
|
+
*/
|
|
22
|
+
export declare class SessionExecution {
|
|
23
|
+
private readonly input;
|
|
24
|
+
constructor(input: SessionExecutionInput);
|
|
25
|
+
get cursor(): SessionStateCursor;
|
|
26
|
+
runTurn(delivery: TurnStepPayload | undefined): Promise<TurnOutcome>;
|
|
27
|
+
private runTurnSteps;
|
|
28
|
+
handleWorkflowMessage(message: WorkflowToolRunMessage): Promise<RuntimeActionResult | undefined>;
|
|
29
|
+
private finishCancelledTurn;
|
|
30
|
+
private waitForRuntimeActionResults;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{coalesceDeliveries}from"#harness/messages.js";import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{activeTurnId}from"#harness/active-turn-id.js";import{decodeSessionInboxPayload}from"#execution/session-inbox/protocol.js";import{isInboxSubagentResultFromRunningHandle}from"#subagents/handles/query.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";import{admitSessionInboxPayload,applySessionCancellation}from"#execution/session/admission.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{isSteeringDelivery}from"#execution/session/input-queue.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{dispatchCoordinationStep}from"#execution/coordination-dispatch-step.js";import{acknowledgeDelegatedTasksStep}from"#execution/tasks/parent/delegate.js";import{handleWorkflowToolRunMessage}from"#execution/session-workflow-tool-run.js";import{turnStep}from"#execution/session/turn-step.js";import{resolveRuntimeActionResultsForCallIds}from"#runtime/actions/results.js";var SessionExecution=class{input;constructor(e){this.input=e}get cursor(){return this.input.cursor}async runTurn(e){let t=new ActiveTurn(this.input,e?.delivery?.caller?.callId);try{return await this.runTurnSteps(t,e)}finally{t.dispose()}}async runTurnSteps(e,t){let n=t;for(;;){let{cursor:t}=this.input,r=t.serializedContext,i=await turnStep(t.createStepInput(n,{abortSignal:e.signal,steeringSignal:e.steeringSignal})),a=i.action===`park`?i.pendingCoordinationCallIds:void 0,o=(i.backgroundTasks?.length??0)>0;if(o){if(i.backgroundTaskState===void 0)throw Error(`Background tasks were returned without their committed session state.`);await t.apply({serializedContext:i.backgroundTaskContext??r,sessionState:i.backgroundTaskState}),await acknowledgeDelegatedTasksStep({tasks:i.backgroundTasks??[]})}if(await t.apply({serializedContext:i.serializedContext,sessionState:i.action===`cancelled`||e.signal.aborted?i.backgroundTaskState??i.sessionState:i.sessionState}),await e.admitBoundary(),e.resetSteering(),i.action===`cancelled`||e.signal.aborted&&(a===void 0||o))return await this.finishCancelledTurn();if(i.action===`done`)return{isError:i.isError,kind:`done`,output:i.output??``,usage:i.usage,usageDelta:i.usageDelta};if(a!==void 0&&i.action===`park`){let r=await dispatchCoordinationStep({action:i.action,callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url),workflowToolRunOwner:{inbox:sessionInboxHookToken(sessionCommandHookToken(this.input.sessionId))},sessionWritable:t.sessionWritable,serializedContext:t.serializedContext,sessionState:t.sessionState}),o=r.results.length===0?void 0:Date.now();await t.apply(r),await acknowledgeDelegatedTasksStep({tasks:r.pendingTasks});let s=await this.waitForRuntimeActionResults({initialAcceptedAtMs:o,initialResults:r.results,pendingCallIds:a,turn:e});if(s===`cancelled`)return await this.finishCancelledTurn();n={delivery:await e.takeSteering(),runtimeResults:s};continue}if(i.action===`park`){if(!(i.hasPendingAuthorization||i.hasPendingInputBatch&&this.input.capabilities?.requestInput===!0||this.input.mode===`conversation`))throw Error("Task mode cannot wait for follow-up input (`next: null`).");return{authorizationAttemptIds:i.authorizationAttemptIds,kind:`park`,settled:i.settled}}let s=await e.takeSteering();n=s===void 0?void 0:{delivery:s}}}async handleWorkflowMessage(e){return await handleWorkflowToolRunMessage({callbackMetadataUrl:getWorkflowMetadata().url,cursor:this.input.cursor,message:e})}async finishCancelledTurn(){let{cursor:e}=this.input;return await cancelDescendantTurnsStep({serializedContext:e.serializedContext,sessionState:e.sessionState}),{cancelled:!0,kind:`park`}}async waitForRuntimeActionResults(e){let t=[...e.initialResults],n=new Map;if(e.initialAcceptedAtMs!==void 0)for(let r of t)n.set(r.callId,e.initialAcceptedAtMs);for(;;){let r=resolveRuntimeActionResultsForCallIds({pendingCallIds:e.pendingCallIds,results:t});if(r!==void 0)return{acceptedAtMsByCallId:Object.fromEntries(r.map(e=>[e.callId,n.get(e.callId)])),results:r};let i=await e.turn.nextRuntimeEvent();if(i===`cancelled`)return i;if(i.kind===`runtime-action-result`){let e=this.input.cursor.sessionState.snapshot.session.state,r=i.results.filter(t=>t.kind===`tool-result`?isInboxToolResultFromRecordedWorkflowToolRun(e,t):t.kind===`subagent-result`?t.origin===`child`&&isInboxSubagentResultFromRunningHandle(e,t)||isInboxSubagentResultFromRecordedWorkflowToolRun(e,t):!1);if(r.length>0){let e=Date.now();t.push(...r);for(let t of r)n.set(t.callId,e)}continue}let a=await this.handleWorkflowMessage(i.message);a!==void 0&&(t.push(a),n.set(a.callId,Date.now()))}}},ActiveTurn=class{admitted=new Set;routedToChildren=new Set;runtimeResults=[];controller=new AbortController;expectedTurnId;input;callerCallId;unsubscribe;unsubscribeDelivery;steeringController=new AbortController;constructor(e,t){this.input=e,this.callerCallId=t,this.expectedTurnId=activeTurnId(e.cursor.sessionState.emissionState),this.unsubscribe=e.inbox.onInterrupt(e=>{this.cancelsThisTurn(e)&&this.abort()}),this.unsubscribeDelivery=e.inbox.onDelivery(this.signalSteering)}signalSteering=e=>{let t;try{t=decodeSessionInboxPayload(e)}catch{return}t.kind===`deliver`&&isSteeringDelivery(t,this.callerCallId)&&!this.input.cursor.sessionState.hasProxyInputRequests&&t.payloads.some(e=>e.message!==void 0&&e.inputResponses===void 0&&e.task===void 0)&&this.steeringController.abort()};get signal(){return this.controller.signal}dispose(){this.unsubscribe(),this.unsubscribeDelivery()}get steeringSignal(){return this.steeringController.signal}resetSteering(){this.steeringController.signal.aborted&&(this.unsubscribeDelivery(),this.steeringController=new AbortController,this.unsubscribeDelivery=this.input.inbox.onDelivery(this.signalSteering))}async admitBoundary(){let e=this.input.inbox.drain();for(let t of e)await this.admit(t)}async takeSteering(){let e=[];for(;;){let t=this.input.queue.takeSteering(this.admitted,this.callerCallId);if(t===void 0)break;for(let e of t.sequences)this.admitted.delete(e);let n=await routeSelectedDelivery(t,this.input.cursor);if(n.kind===`cancel-turn`){this.abort();break}n.kind===`turn`&&e.push(n.delivery)}if(e.length!==0)return e.length===1?e[0]:coalesceDeliveries(e)}async nextRuntimeEvent(){for(;;){if(this.signal.aborted)return`cancelled`;let e=this.runtimeResults.shift();if(e!==void 0)return e;let t=await this.input.inbox.next();if(t===void 0)throw Error(`Session inbox closed before runtime actions completed.`);await this.admit(t),await this.routeAdmittedToChildren()}}cancelsThisTurn(e){return e.kind===`reset`?!0:e.kind===`cancel`?e.turnId===void 0||e.turnId===this.expectedTurnId:!1}async admit(e){let t=await admitSessionInboxPayload(e,this.input);switch(t.kind){case`delivery`:this.admitted.add(t.admission.sequence);return;case`runtime-action-result`:this.runtimeResults.push({kind:`runtime-action-result`,results:t.payload.results});return;case`workflow`:this.runtimeResults.push({kind:`workflow`,message:t.message});return;case`cancel`:if(!this.cancelsThisTurn(e))return;await applySessionCancellation(t.command,this.input),this.abort();return;case`consumed`:return}}async routeAdmittedToChildren(){for(let e of this.admitted){if(this.routedToChildren.has(e))continue;let t=this.input.queue.delivery(e);if(t===void 0){this.admitted.delete(e);continue}this.routedToChildren.add(e);let n=await routeDeliverToChildren({delivery:t,sessionWritable:this.input.cursor.sessionWritable,serializedContext:this.input.cursor.serializedContext,sessionState:this.input.cursor.sessionState});if(await this.input.cursor.apply(n),n.kind===`cancel-turn`){this.input.queue.replaceDelivery(e,void 0),this.admitted.delete(e),this.abort();return}this.input.queue.replaceDelivery(e,n.remainder),n.remainder===void 0&&this.admitted.delete(e)}}abort(){this.controller.signal.aborted||this.controller.abort(new TurnCancelledError)}};export{SessionExecution};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Serialized-context key advertising a session's stable inbox. */
|
|
2
|
+
export declare const SESSION_INBOX_CONTEXT_KEY = "eve.sessionInbox";
|
|
3
|
+
/** Hook metadata key that keeps public identity separate from hook ownership. */
|
|
4
|
+
export declare const SESSION_INBOX_SESSION_ID_METADATA_KEY = "sessionId";
|
|
5
|
+
/** Stable inbox coordinates. The owner and deployment are intentionally absent. */
|
|
6
|
+
export interface SessionInboxAddress {
|
|
7
|
+
readonly sessionId: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function isSessionInboxAddress(value: unknown): value is SessionInboxAddress;
|
|
10
|
+
/** Returns whether a token belongs to eve's framework-reserved session namespace. */
|
|
11
|
+
export declare function isReservedSessionCommandToken(token: string): boolean;
|
|
12
|
+
/** Logical stable command inbox token for a session. */
|
|
13
|
+
export declare function sessionCommandHookToken(sessionId: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Physical hook token for a logical session address. Applied exactly where a
|
|
16
|
+
* hook is created or resumed, so current-generation hooks stay disjoint from
|
|
17
|
+
* hooks owned by pre-cutover drivers that used the logical token directly.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sessionInboxHookToken(token: string): string;
|
|
20
|
+
/** Marker a releasing owner leaves so ingress can tell "handoff in progress" from "no session". */
|
|
21
|
+
export declare function sessionHandoffMarkerToken(token: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const SESSION_INBOX_CONTEXT_KEY=`eve.sessionInbox`,SESSION_INBOX_SESSION_ID_METADATA_KEY=`sessionId`;function isSessionInboxAddress(e){return typeof e==`object`&&!!e&&`sessionId`in e&&typeof e.sessionId==`string`&&e.sessionId.length>0&&!e.sessionId.includes(`:`)}function isReservedSessionCommandToken(e){return e.startsWith(`eve:session:`)||e.startsWith(`eve:inbox:`)}function sessionCommandHookToken(e){return`eve:session:${e}:inbox`}function sessionInboxHookToken(e){return`eve:inbox:v1:${e}`}function sessionHandoffMarkerToken(e){return`eve:inbox:handoff:${e}`}export{SESSION_INBOX_CONTEXT_KEY,SESSION_INBOX_SESSION_ID_METADATA_KEY,isReservedSessionCommandToken,isSessionInboxAddress,sessionCommandHookToken,sessionHandoffMarkerToken,sessionInboxHookToken};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DeliverPayload, HookPayload, SessionCommand } from "#channel/types.js";
|
|
2
|
+
import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
|
|
3
|
+
/** All session addresses accept the same protocol. Callback routes construct
|
|
4
|
+
* their own message kind; they never accept arbitrary session commands. */
|
|
5
|
+
export interface AuthorizationCallbackPayload {
|
|
6
|
+
readonly kind: "authorization-callback";
|
|
7
|
+
readonly payloads: DeliverPayload[];
|
|
8
|
+
}
|
|
9
|
+
export type SessionInboxPayload = HookPayload | SessionCommand | WorkflowToolRunMessage | AuthorizationCallbackPayload;
|
|
10
|
+
export interface SessionInboxReader {
|
|
11
|
+
/**
|
|
12
|
+
* Waits for and removes the next accepted payload in arrival order, or
|
|
13
|
+
* `undefined` once every hook is released. Only one consumer waits at a
|
|
14
|
+
* time; the owner program is strictly sequential.
|
|
15
|
+
*/
|
|
16
|
+
next(): Promise<SessionInboxPayload | undefined>;
|
|
17
|
+
/** Removes every payload accepted so far, in arrival order. */
|
|
18
|
+
drain(): SessionInboxPayload[];
|
|
19
|
+
hasPending(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Called from the pump the moment an interrupt (`cancel`, `reset`,
|
|
22
|
+
* `session-timeout`) is accepted, ahead of any consumer read. Handlers must
|
|
23
|
+
* be synchronous and idempotent. The payload stays in the queue so the
|
|
24
|
+
* consumer still processes it in order.
|
|
25
|
+
*/
|
|
26
|
+
onInterrupt(handler: (payload: SessionInboxPayload) => void): () => void;
|
|
27
|
+
/** Observes deliveries without consuming them; replays unread deliveries on subscription. */
|
|
28
|
+
onDelivery(handler: (payload: SessionInboxPayload) => void): () => void;
|
|
29
|
+
restore(payloads: readonly SessionInboxPayload[]): void;
|
|
30
|
+
}
|
|
31
|
+
export interface SessionInboxOwnership {
|
|
32
|
+
/** Logical tokens currently claimed, in claim order. */
|
|
33
|
+
readonly claimedTokens: readonly string[];
|
|
34
|
+
claimSessionHook(token: string): Promise<void>;
|
|
35
|
+
/** Registers every token as one batch; all claims settle before the first failure propagates. */
|
|
36
|
+
claimSessionHooks(tokens: readonly string[]): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export interface SessionInbox extends SessionInboxReader, SessionInboxOwnership {
|
|
39
|
+
}
|
|
40
|
+
export interface SessionInboxHandle extends SessionInbox {
|
|
41
|
+
dispose(): Promise<void>;
|
|
42
|
+
/** Disposes every hook and returns each payload the hooks accepted but the owner never read. */
|
|
43
|
+
release(): Promise<SessionInboxPayload[]>;
|
|
44
|
+
}
|
|
45
|
+
export declare function isInterrupt(value: SessionInboxPayload): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* One FIFO queue for the session lifetime, fed by a continuous reader per
|
|
48
|
+
* claimed hook. The pump never waits on queue depth: interrupts share each
|
|
49
|
+
* hook's ordered stream, so any backpressure on ordinary payloads would also
|
|
50
|
+
* hold back the cancel behind them. Accepted payloads are already durable on
|
|
51
|
+
* the hook, so the queue is a mirror rather than the source of truth.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createSessionInbox(sessionId: string): SessionInboxHandle;
|
|
54
|
+
export declare function isWorkflowMessage(value: SessionInboxPayload): value is WorkflowToolRunMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sessionInboxHookToken}from"#execution/session-inbox/address.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook}from"#execution/hook-ownership.js";import{releaseSessionHooksStep}from"#execution/session-inbox/release-step.js";function isInterrupt(e){return e.kind===`cancel`||e.kind===`reset`||e.kind===`session-timeout`}function createSessionInbox(e){let t=[],n=[],r=new Set,i=new Set,a=new Set,o,notify=()=>{for(let e of r)e();r.clear()},wait=()=>new Promise(e=>r.add(e)),closed=()=>t.every(e=>e.closed||e.stopping),pump=async e=>{let t=e.hook[Symbol.asyncIterator]();try{for(;!e.stopping;){let e=await t.next();if(e.done)break;if(n.push(e.value),e.value.kind===`send`||e.value.kind===`deliver`)for(let t of a)t(e.value);if(isInterrupt(e.value))for(let t of i)t(e.value);notify()}}catch(t){e.stopping||(o={error:t})}finally{e.closed=!0,notify()}},stop=async()=>{let e=t.splice(0);for(let t of e)t.stopping=!0;notify(),await Promise.all(e.map(({hook:e})=>disposeHook(e)));let r=n.splice(0);return notify(),r},claimSessionHook=async n=>{if(!n)throw Error(`A session alias requires a nonempty continuation token.`);let r=t.find(e=>e.token===n);if(r!==void 0)return await r.registered;if(t.length>=256)throw Error(`A session may claim at most 256 addresses.`);let i={token:n,hook:createHook({token:sessionInboxHookToken(n),metadata:{sessionId:e}}),stopping:!1,closed:!1};t.push(i);try{i.registered=claimHookOwnership(i.hook),await i.registered,pump(i)}catch(e){throw t.splice(t.indexOf(i),1),e}};return{get claimedTokens(){return t.map(({token:e})=>e)},claimSessionHook,async claimSessionHooks(e){let t=await Promise.allSettled([...new Set(e)].map(claimSessionHook));for(let e of t)if(e.status===`rejected`)throw e.reason},async next(){for(;;){if(o!==void 0)throw o.error;if(n.length>0)return n.shift();if(closed())return;await wait()}},drain(){if(o!==void 0)throw o.error;return n.splice(0)},hasPending(){if(o!==void 0)throw o.error;return n.length>0},onInterrupt(e){return i.add(e),()=>i.delete(e)},onDelivery(e){a.add(e);for(let t of n)(t.kind===`send`||t.kind===`deliver`)&&e(t);return()=>a.delete(e)},restore(e){if(t.length===0)throw Error(`Cannot restore session commands before reclaiming the session hooks.`);n.unshift(...e),notify()},async dispose(){await stop()},async release(){return t.length>0&&await releaseSessionHooksStep({ownerRunId:getWorkflowMetadata().workflowRunId,tokens:t.map(({hook:e})=>e.token)}),await stop()}}}function isWorkflowMessage(e){return e.kind===`report`||e.kind===`request`||e.kind===`outcome`}export{createSessionInbox,isInterrupt,isWorkflowMessage};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DeliverHookPayload, SessionCommand, SessionTimeoutHookPayload } from "#channel/types.js";
|
|
2
|
+
export type DecodedSessionInbox = DeliverHookPayload | SessionTimeoutHookPayload | Extract<SessionCommand, {
|
|
3
|
+
readonly kind: "cancel" | "clear" | "compact" | "reset";
|
|
4
|
+
}>;
|
|
5
|
+
/** Invalid current-generation inbox payload. Historical wire shapes are not accepted. */
|
|
6
|
+
export declare class SessionInboxPayloadError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
/** Normalizes the one authored `send` convenience command into a delivery. */
|
|
10
|
+
export declare function decodeSessionInboxPayload(value: unknown): DecodedSessionInbox;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var SessionInboxPayloadError=class extends Error{constructor(e){super(e),this.name=`SessionInboxPayloadError`}};function decodeSessionInboxPayload(e){if(typeof e!=`object`||!e||!(`kind`in e))throw new SessionInboxPayloadError(`Session inbox payload must be an object with a kind.`);let t=e;switch(t.kind){case`send`:{if(t.payload===null||typeof t.payload!=`object`)throw new SessionInboxPayloadError(`Session send payload must be an object.`);let n=e;return{auth:n.auth,caller:n.caller,deliveryMetadata:n.delivery===void 0?void 0:[{...n.delivery,payloadIndex:0}],kind:`deliver`,payloads:[n.payload],requestId:n.requestId,taskDeliveryId:n.taskDeliveryId,turnPolicy:n.turnPolicy}}case`deliver`:if(!Array.isArray(t.payloads))throw new SessionInboxPayloadError(`Session delivery payloads must be an array.`);return e;case`cancel`:case`clear`:case`compact`:case`reset`:case`session-timeout`:return e;default:throw new SessionInboxPayloadError(`Unsupported session inbox payload kind ${JSON.stringify(t.kind)}.`)}}export{SessionInboxPayloadError,decodeSessionInboxPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getWorld}from"#internal/workflow/runtime.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";async function releaseSessionHooksStep(e){"use step";let t=await getWorld(),n=await Promise.allSettled(e.tokens.map(async n=>{let r;try{r=await t.hooks.getByToken(n)}catch(e){if(HookNotFoundError.is(e))return;throw e}if(r.runId!==e.ownerRunId)throw Error(`Cannot release a session hook owned by another workflow.`);await t.events.create(e.ownerRunId,{correlationId:r.hookId,eventData:{token:n},eventType:`hook_disposed`,specVersion:r.specVersion})}));for(let e of n)if(e.status===`rejected`)throw e.reason}export{releaseSessionHooksStep};
|