eve 0.81.0 → 0.82.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 +37 -0
- package/dist/src/channel/channel-address.d.ts +21 -2
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/channel-operations.d.ts +32 -1
- package/dist/src/channel/channel-operations.js +1 -1
- package/dist/src/channel/delivery-idempotency.d.ts +4 -0
- package/dist/src/channel/delivery-idempotency.js +1 -0
- package/dist/src/channel/routes.d.ts +6 -0
- package/dist/src/channel/session.d.ts +5 -0
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +14 -11
- package/dist/src/chunks/{use-eve-agent-Bp6nbhfV.js → use-eve-agent-DTu78IAF.js} +36 -0
- package/dist/src/chunks/{use-eve-agent-DLkjJIm3.js → use-eve-agent-DlznYwQk.js} +36 -0
- package/dist/src/cli/dev/command-options.d.ts +1 -0
- package/dist/src/cli/dev/diagnostic-dump.js +1 -1
- package/dist/src/cli/run.d.ts +1 -0
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/message-reducer-types.d.ts +7 -3
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/transcript-reducer.d.ts +6 -3
- package/dist/src/client/transcript-reducer.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +19 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/load-binding-namespace.d.ts +2 -0
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/module-lifecycle.d.ts +1 -1
- package/dist/src/compiler/module-lifecycle.js +1 -1
- package/dist/src/compiler/module-map.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/project-sources.d.ts +6 -0
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/context/keys.d.ts +2 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/evals/cli/eval-state-directory.d.ts +7 -0
- package/dist/src/evals/cli/eval-state-directory.js +1 -0
- package/dist/src/evals/cli/eval.js +2 -2
- package/dist/src/eve-channel/create-request.d.ts +2 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +2 -1
- package/dist/src/eve-channel/request.js +1 -2
- package/dist/src/eve-channel/support.d.ts +11 -1
- package/dist/src/eve-channel/support.js +2 -1
- package/dist/src/eve-channel/types.d.ts +25 -0
- package/dist/src/execution/agent-sessions/context.d.ts +2 -13
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/agent-sessions/runtime-overrides.d.ts +5 -0
- package/dist/src/execution/agent-sessions/runtime-overrides.js +1 -0
- package/dist/src/execution/agent-sessions/session.d.ts +2 -2
- package/dist/src/execution/agent-sessions/session.js +1 -1
- package/dist/src/execution/agent-sessions/steps.d.ts +2 -0
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +5 -5
- package/dist/src/execution/coordination-dispatch-step.d.ts +17 -2
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +5 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +0 -1
- package/dist/src/execution/dynamic-connection-recovery.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/effective-agent-config.d.ts +8 -2
- package/dist/src/execution/effective-agent-config.js +1 -1
- package/dist/src/execution/hook-ownership.d.ts +8 -0
- package/dist/src/execution/hook-ownership.js +1 -1
- package/dist/src/execution/install-workflow-deployment-id.d.ts +3 -0
- package/dist/src/execution/install-workflow-deployment-id.js +1 -0
- package/dist/src/execution/legacy-session/turn-workflow.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/runtime-context.d.ts +2 -0
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/entry-input.d.ts +20 -8
- package/dist/src/execution/session/entry-input.js +1 -1
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/finalization.js +1 -1
- package/dist/src/execution/session/handoff-steps.d.ts +75 -13
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +73 -34
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +5 -1
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/pending-history.d.ts +5 -0
- package/dist/src/execution/session/pending-history.js +1 -0
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/program.d.ts +1 -1
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/run-watch.d.ts +22 -0
- package/dist/src/execution/session/run-watch.js +1 -0
- package/dist/src/execution/session/timeout-control.d.ts +18 -4
- package/dist/src/execution/session/timeout-control.js +1 -1
- package/dist/src/execution/session/timeout.d.ts +1 -2
- package/dist/src/execution/session/timeout.js +1 -1
- package/dist/src/execution/session/turn-event-handler.js +1 -1
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn-waiting-step.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-inbox/address.d.ts +4 -1
- package/dist/src/execution/session-inbox/end-stranded-session.js +1 -1
- package/dist/src/execution/session-inbox/hook-release.d.ts +9 -2
- package/dist/src/execution/session-inbox/hook-release.js +1 -1
- package/dist/src/execution/session-inbox/inbox.d.ts +66 -6
- package/dist/src/execution/session-inbox/inbox.js +1 -1
- package/dist/src/execution/session-inbox/protocol.js +1 -1
- package/dist/src/execution/session-inbox/resume.d.ts +4 -3
- package/dist/src/execution/session.d.ts +0 -12
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/tasks/model-step.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +4 -4
- package/dist/src/execution/tasks/start.js +1 -1
- package/dist/src/execution/tasks/steps.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +2 -2
- package/dist/src/execution/workflow-runtime.d.ts +11 -12
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/budget-request.d.ts +12 -6
- package/dist/src/harness/hitl/budget-request.js +1 -1
- package/dist/src/harness/hitl/budget.d.ts +7 -1
- package/dist/src/harness/hitl/budget.js +1 -1
- package/dist/src/harness/hitl/coordinator.js +1 -1
- package/dist/src/harness/hitl/delivery.d.ts +1 -1
- package/dist/src/harness/hitl/delivery.js +1 -1
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/intake.d.ts +2 -2
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/messages.d.ts +5 -0
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/model-call/call.d.ts +2 -2
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/request.d.ts +2 -2
- package/dist/src/harness/session-machine/transitions.d.ts +3 -1
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/harness/step/context.d.ts +3 -0
- package/dist/src/harness/step/context.js +1 -1
- package/dist/src/harness/step/intake.d.ts +5 -2
- package/dist/src/harness/step/intake.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +7 -26
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +10 -25
- package/dist/src/instrumentation/content.d.ts +1 -1
- package/dist/src/instrumentation/content.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +4 -2
- package/dist/src/internal/application/build-profile.d.ts +3 -0
- package/dist/src/internal/application/build-profile.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +2 -2
- package/dist/src/internal/application/dev-environment.d.ts +13 -0
- package/dist/src/internal/application/dev-environment.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/authored-definition/connection.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-module-build-options.d.ts +7 -0
- package/dist/src/internal/authored-module-build-options.js +1 -0
- package/dist/src/internal/authored-module-graph.d.ts +13 -0
- package/dist/src/internal/authored-module-graph.js +1 -0
- package/dist/src/internal/authored-module-loader.d.ts +22 -1
- package/dist/src/internal/authored-module-loader.js +1 -3
- package/dist/src/internal/authored-module.d.ts +7 -0
- package/dist/src/internal/authored-module.js +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/bundler/nitro-rolldown.d.ts +5 -1
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/internal/development-programmatic-source-loader.d.ts +1 -0
- package/dist/src/internal/development-programmatic-source-loader.js +1 -1
- package/dist/src/internal/mcp/skills.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-generation-metadata.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-deployment-id.d.ts +8 -0
- package/dist/src/internal/nitro/host/build-deployment-id.js +1 -0
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-server-state.js +1 -1
- package/dist/src/internal/nitro/host/skill-server-assets.js +1 -1
- package/dist/src/internal/nitro/host/stage-build-deployment-id.d.ts +2 -0
- package/dist/src/internal/nitro/host/stage-build-deployment-id.js +1 -0
- package/dist/src/internal/nitro/host/start-production-server.d.ts +1 -0
- package/dist/src/internal/nitro/host/start-production-server.js +3 -3
- package/dist/src/internal/nitro/routes/schedule-task.d.ts +3 -0
- package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
- package/dist/src/internal/programmatic-source-loader.d.ts +1 -0
- package/dist/src/internal/programmatic-source-loader.js +1 -1
- package/dist/src/internal/schedules/disabled.d.ts +2 -0
- package/dist/src/internal/schedules/disabled.js +1 -0
- 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-data-directory.d.ts +2 -1
- package/dist/src/internal/workflow/local-world-data-directory.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/protocol/message.d.ts +27 -1
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +13 -0
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/chat-sdk/fetch-message.d.ts +10 -0
- package/dist/src/public/channels/chat-sdk/fetch-message.js +1 -0
- package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
- package/dist/src/public/channels/chat-sdk/messageToUserContent.d.ts +2 -1
- package/dist/src/public/channels/chat-sdk/messageToUserContent.js +1 -1
- package/dist/src/public/channels/chat-sdk/reply-context.d.ts +15 -0
- package/dist/src/public/channels/chat-sdk/reply-context.js +2 -0
- package/dist/src/public/channels/discord/discordChannel.d.ts +3 -0
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/github/dispatch.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +3 -0
- package/dist/src/public/channels/imessage-tapbacks.d.ts +74 -0
- package/dist/src/public/channels/imessage-tapbacks.js +1 -0
- package/dist/src/public/channels/index.d.ts +2 -1
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/channels/linear/linearChannel.d.ts +3 -0
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/linq/inboundContent.d.ts +7 -0
- package/dist/src/public/channels/linq/inboundContent.js +1 -1
- package/dist/src/public/channels/linq/index.d.ts +1 -0
- package/dist/src/public/channels/linq/index.js +1 -1
- package/dist/src/public/channels/linq/linqChannel.d.ts +17 -1
- package/dist/src/public/channels/linq/linqChannel.js +1 -1
- package/dist/src/public/channels/photon/attachments.d.ts +5 -2
- package/dist/src/public/channels/photon/attachments.js +1 -1
- package/dist/src/public/channels/photon/inboundContent.d.ts +7 -0
- package/dist/src/public/channels/photon/inboundContent.js +2 -1
- package/dist/src/public/channels/photon/index.d.ts +1 -0
- package/dist/src/public/channels/photon/index.js +1 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +17 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +14 -1
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/model-context.d.ts +7 -0
- package/dist/src/public/channels/slack/model-context.js +1 -1
- package/dist/src/public/channels/slack/reply-delivery.d.ts +5 -0
- package/dist/src/public/channels/slack/reply-delivery.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +17 -3
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +3 -0
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +3 -0
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/definitions/agent.d.ts +1 -1
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +1 -0
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/runtime/agent/resolve-model.d.ts +4 -0
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +2 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
- package/dist/src/runtime/types.d.ts +3 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +31 -42
- package/dist/src/shared/gateway-routing.d.ts +20 -0
- package/dist/src/shared/gateway-routing.js +1 -0
- package/dist/src/shared/session-history.d.ts +22 -0
- package/dist/src/shared/session-history.js +1 -0
- package/dist/src/shared/skill-package.js +1 -1
- package/dist/src/subagents/tool.d.ts +1 -3
- 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/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +14 -1
- package/dist/src/tracing/eve/agent-otel-provider.js +1 -1
- package/dist/src/tracing/eve/conversation-context.d.ts +4 -1
- package/dist/src/tracing/eve/conversation-context.js +1 -1
- package/dist/src/tracing/eve/gateway.d.ts +5 -0
- package/dist/src/tracing/eve/gateway.js +1 -1
- package/dist/src/tracing/eve/invoke-tool-span.js +1 -1
- package/dist/src/tracing/eve/operation-input.d.ts +0 -12
- package/dist/src/tracing/eve/operation-input.js +1 -1
- package/dist/src/tracing/eve/otel-registration.js +1 -1
- package/dist/src/tracing/eve/policy.d.ts +1 -1
- package/dist/src/tracing/eve/policy.js +1 -1
- package/dist/src/tracing/eve/session.d.ts +5 -2
- package/dist/src/tracing/eve/session.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/README.md +1 -0
- package/docs/agent-config.md +108 -65
- package/docs/channels/chat-sdk.mdx +10 -3
- package/docs/channels/custom.mdx +38 -6
- package/docs/channels/eve.mdx +73 -0
- package/docs/channels/linq.mdx +51 -0
- package/docs/channels/photon.mdx +68 -2
- package/docs/channels/slack.mdx +6 -2
- package/docs/concepts/built-in-tools.md +1 -1
- package/docs/concepts/execution-model-and-durability.mdx +27 -11
- package/docs/concepts/sessions-runs-and-streaming.md +9 -8
- package/docs/connections/overview.mdx +1 -1
- package/docs/experimental/dynamic-schedules.mdx +186 -0
- package/docs/experimental/meta.json +4 -0
- package/docs/guides/client/streaming.mdx +1 -0
- package/docs/guides/deployment/self-hosting.md +3 -0
- package/docs/guides/hooks.md +21 -1
- package/docs/guides/instrumentation/otel.mdx +20 -0
- package/docs/memory/overview.mdx +2 -1
- package/docs/patterns/dynamic-scheduling.md +3 -1
- package/docs/patterns/meta.json +1 -0
- package/docs/patterns/voice-notes.md +67 -0
- package/docs/reference/cli.md +14 -7
- package/docs/sandbox/index.mdx +2 -0
- package/docs/schedules.mdx +2 -0
- package/docs/subagents/index.mdx +2 -0
- package/docs/tools/overview.mdx +2 -1
- package/docs/tools/tasks-upgrade.md +12 -7
- package/docs/tools/tasks.md +10 -6
- package/docs/tools/workflows.mdx +36 -5
- package/docs/tutorial/connect-a-warehouse.mdx +1 -1
- package/docs/tutorial/run-analysis.mdx +1 -1
- package/package.json +1 -1
- package/dist/src/execution/run-session-limits.d.ts +0 -12
- package/dist/src/execution/run-session-limits.js +0 -1
- package/dist/src/harness/session-usage-limits.d.ts +0 -49
- package/dist/src/harness/session-usage-limits.js +0 -1
- package/dist/src/subagents/token-budget.d.ts +0 -15
- package/dist/src/subagents/token-budget.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dispatchDynamicSubagentEvent}from"#context/dynamic-subagent-lifecycle.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{dispatchDynamicToolEvent}from"#context/dynamic-tool-lifecycle.js";import{TurnCancelledError,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{dispatchDynamicInstructionEvent}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchMemoryLifecycleEvent}from"#context/memory-event-lifecycle.js";const HOOK_CANCELLABLE_EVENTS={"action.input.appended":!0,"action.partial":!0,"action.result":!0,"actions.requested":!0,"agent.started":!1,"approval.candidate":!0,"approval.settled":!0,"authorization.completed":!0,"authorization.required":!0,"compaction.completed":!0,"compaction.requested":!0,"context.cleared":!1,"input.requested":!0,"input.resolved":!0,"message.appended":!0,"message.completed":!0,"message.received":!0,"reasoning.appended":!0,"reasoning.completed":!0,"result.completed":!0,"session.completed":!1,"session.failed":!1,"session.started":!0,"session.waiting":!1,"step.completed":!0,"step.failed":!1,"step.started":!0,"task.settled":!1,"task.started":!1,"turn.cancelled":!1,"turn.completed":!1,"turn.failed":!1,"turn.started":!0,"turn.waiting":!1};function isHookCancellableEvent(e){return HOOK_CANCELLABLE_EVENTS[e]===!0}function createTurnEventHandler(e){let{abortSignal:t,bundle:n,ctx:r,effectiveAgent:i,effectiveNode:a}=e,{publisher:o}=e;return async(s,c)=>{let l=await o.emit(s),u=await dispatchMemoryLifecycleEvent({abortSignal:t,appRoot:a.agent?.metadata?.appRoot??``,ctx:r,event:s,instrumentation:e.instrumentation?.memory,memories:a.agent?.memories??[],messages:c,nodeId:n.nodeId??`__root__`}),d=e.canCancelTurn&&isHookCancellableEvent(l.type)?()=>e.hookCancellation.abort(new TurnCancelledError):void 0;await o.dispatcher.runHooks(l,d),l.type!==`step.started`&&await dispatchDynamicModelEvent({abortSignal:t,ctx:r,dynamicModel:i.turnAgent.dynamicModel,event:l,messages:u,scope:{moduleMap:n.moduleMap,nodeId:n.nodeId}}),await e.dynamicConnections.dispatch(l),await dispatchDynamicSubagentEvent({ctx:r,resolvers:n.subagentRegistry.dynamicResolvers??[],event:l,messages:u}),await dispatchDynamicToolEvent({ctx:r,resolvers:n.resolvedAgent.dynamicToolResolvers??[],event:l,messages:u}),await dispatchDynamicSkillEvent({ctx:r,resolvers:n.resolvedAgent.dynamicSkillResolvers??[],event:l,messages:u}),await dispatchDynamicInstructionEvent({ctx:r,resolvers:n.resolvedAgent.dynamicInstructionsResolvers??[],event:l,messages:u}),d!==void 0&&throwIfTurnAborted(e.hookCancellation.signal)}}export{createTurnEventHandler,isHookCancellableEvent};
|
|
1
|
+
import{dispatchDynamicSubagentEvent}from"#context/dynamic-subagent-lifecycle.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{dispatchDynamicToolEvent}from"#context/dynamic-tool-lifecycle.js";import{TurnCancelledError,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{dispatchDynamicInstructionEvent}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchMemoryLifecycleEvent}from"#context/memory-event-lifecycle.js";const HOOK_CANCELLABLE_EVENTS={"action.input.appended":!0,"action.partial":!0,"action.result":!0,"actions.requested":!0,"agent.started":!1,"approval.candidate":!0,"approval.settled":!0,"authorization.completed":!0,"authorization.required":!0,"compaction.completed":!0,"compaction.requested":!0,"context.cleared":!1,"history.imported":!1,"input.requested":!0,"input.resolved":!0,"message.appended":!0,"message.completed":!0,"message.received":!0,"reasoning.appended":!0,"reasoning.completed":!0,"result.completed":!0,"session.completed":!1,"session.failed":!1,"session.started":!0,"session.waiting":!1,"step.completed":!0,"step.failed":!1,"step.started":!0,"task.settled":!1,"task.started":!1,"turn.cancelled":!1,"turn.completed":!1,"turn.failed":!1,"turn.started":!0,"turn.waiting":!1};function isHookCancellableEvent(e){return HOOK_CANCELLABLE_EVENTS[e]===!0}function createTurnEventHandler(e){let{abortSignal:t,bundle:n,ctx:r,effectiveAgent:i,effectiveNode:a}=e,{publisher:o}=e;return async(s,c)=>{let l=await o.emit(s),u=await dispatchMemoryLifecycleEvent({abortSignal:t,appRoot:a.agent?.metadata?.appRoot??``,ctx:r,event:s,instrumentation:e.instrumentation?.memory,memories:a.agent?.memories??[],messages:c,nodeId:n.nodeId??`__root__`}),d=e.canCancelTurn&&isHookCancellableEvent(l.type)?()=>e.hookCancellation.abort(new TurnCancelledError):void 0;await o.dispatcher.runHooks(l,d),l.type!==`step.started`&&await dispatchDynamicModelEvent({abortSignal:t,ctx:r,dynamicModel:i.turnAgent.dynamicModel,event:l,messages:u,scope:{moduleMap:n.moduleMap,nodeId:n.nodeId}}),await e.dynamicConnections.dispatch(l),await dispatchDynamicSubagentEvent({ctx:r,resolvers:n.subagentRegistry.dynamicResolvers??[],event:l,messages:u}),await dispatchDynamicToolEvent({ctx:r,resolvers:n.resolvedAgent.dynamicToolResolvers??[],event:l,messages:u}),await dispatchDynamicSkillEvent({ctx:r,resolvers:n.resolvedAgent.dynamicSkillResolvers??[],event:l,messages:u}),await dispatchDynamicInstructionEvent({ctx:r,resolvers:n.resolvedAgent.dynamicInstructionsResolvers??[],event:l,messages:u}),d!==void 0&&throwIfTurnAborted(e.hookCancellation.signal)}}export{createTurnEventHandler,isHookCancellableEvent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{storedProjection}from"#harness/session-machine/view.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{createDurableSessionValues}from"#execution/durable-session-store.js";import{
|
|
1
|
+
import{storedProjection}from"#harness/session-machine/view.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{createDurableSessionValues}from"#execution/durable-session-store.js";import{ownOpenRequestIds}from"#harness/session-machine/transitions.js";import{sessionView}from"#harness/session-machine/commit.js";import{derivePendingState}from"#execution/session/pending-turn-state.js";function resolveSessionStepResult(e,t){let n={serializedContext:t,...createDurableSessionValues(e.session)};if(e.steered)return{action:`steered`,...n};if(e.next!==null&&typeof e.next==`object`&&`done`in e.next){let t=getTurnUsageState(e.session.state)?.session;return{action:`done`,output:e.next.output,isError:e.next.isError,...n,usage:t===void 0?void 0:toUsage(t),usageDelta:takeSessionUsageDelta(e.session).delta}}if(e.held?.kind===`tasks`)return{action:`held`,hold:`tasks`,...n,taskIds:e.held.taskIds};if(e.held?.kind===`request`){let t=storedProjection(e.session.state),r=derivePendingState(e.session,t);return{action:`held`,authorizationAttemptIds:r.authorizationAttemptIds??[],hasPendingInputBatch:r.hasPendingInputBatch,hold:`request`,inputRequestIds:[...ownOpenRequestIds(sessionView(t,e.session.state))],...n}}if(e.next===null){let{hasRunsToDispatch:r,pendingCoordinationCallIds:i,pendingTaskToolCalls:a}=derivePendingState(e.session,storedProjection(e.session.state)),o={hasRunsToDispatch:r,pendingCoordinationCallIds:i,pendingTaskToolCalls:a};if(e.settledTurn!==void 0){let{delta:n,session:r}=takeSessionUsageDelta(e.session);return{action:`park`,...o,serializedContext:t,...createDurableSessionValues(r),settled:{output:e.settledTurn.output,isError:e.settledTurn.isError,usage:n}}}return{action:`park`,...o,...n}}return{action:`continue`,...n}}export{resolveSessionStepResult};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{currentProjection,enterSessionProjection,saveSessionProjection}from"#harness/session-machine/current.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,HandleEventKey,InitiatorAuthKey,OccurrenceIdKey,ParentSessionKey,ScheduleIdKey,ScheduleInstanceKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,SessionTitleKey,StaticModelReferenceKey,TurnDeliveryIdsKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{coalesceTurnInputs,validateHarnessModelMessages}from"#harness/messages.js";import{activeTurnId,isBetweenTurns,storedProjection,turnPosition}from"#harness/session-machine/view.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{createDurableSessionValues,readDurableSession}from"#execution/durable-session-store.js";import{runStep}from"#context/run-step.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{readHitlState}from"#harness/hitl/index.js";import*as agentTraceState from"#tracing/eve/agent-trace-context-store.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey}from"#harness/authorization.js";import{refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{openSessionEventPublisher}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{dropClosedRecords,saveTransition,sessionView}from"#harness/session-machine/commit.js";import{matchSignIns}from"#harness/session-machine/transitions.js";import{sessionStartedForResolvers,turnStartedForResolvers}from"#harness/session-machine/resolver-events.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{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{createTurnEventHandler}from"#execution/session/turn-event-handler.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{bindTurnCallerContext}from"#subagents/parent-notification.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{recoverDynamicConnectionRehydration}from"#execution/dynamic-connection-recovery.js";import{setEveAttributes}from"#runtime/attributes/emit.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{attributeAnswers}from"#execution/session/answer-caller.js";import{resolveSessionStepResult}from"#execution/session/turn-step-result.js";import{countRunUsage}from"#execution/agent-sessions/usage.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{createExecutionHistoryView}from"#execution/history-view.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 await withSessionStateDelta(e,e=>runSessionStep({...e,serializedContext:bindTurnCallerContext(e.caller,e.serializedContext)}))}async function runSessionStep(e){let t={};try{return await runSessionStepBody(e,t)}finally{await t.title}}async function runSessionStepBody(e,t){let n=e.input?.delivery,r=n,i=e.input?.runtimeResults,a=readDurableSession(e.sessionState);for(let e of i?.delegatedUsage??[])a=countRunUsage(a,e);let o=await deserializeContext(e.serializedContext);enterSessionProjection(o,a.state);let s=o.require(ChannelKey),c=o.require(BundleKey),l=resolveEffectiveAgentRuntime(c,o);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&o.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let{signIns:u}=readHitlState(a.state),d;if(u.length>0&&r!==void 0){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(u,r.payloads);if(r={...r,payloads:t},e.length>0){let n=e.map(e=>e.result.attemptId),i=e.map(e=>e.result);o.set(PendingAuthorizationResultKey,i);let s=sessionView(storedProjection(a.state),a.state),c=matchSignIns(s,{attemptIds:n});if(c.events.length!==0)throw Error(`matchSignIns must not emit events.`);a=saveTransition(a,c),d=e,t.length===0&&(r=void 0)}}r?.payloads.some(e=>e.message!==void 0)&&(o.delete(ScheduleIdKey),o.delete(ScheduleInstanceKey),o.delete(OccurrenceIdKey),r.schedule!==void 0&&(o.set(ScheduleIdKey,r.schedule.definition),r.schedule.instance!==void 0&&o.set(ScheduleInstanceKey,r.schedule.instance),r.schedule.occurrenceId!==void 0&&o.set(OccurrenceIdKey,r.schedule.occurrenceId)));let f=o.get(AuthKey),p=o.has(InitiatorAuthKey);r?.auth!==void 0&&(o.set(AuthKey,r.auth??null),o.has(InitiatorAuthKey)||o.set(InitiatorAuthKey,r.auth??null));let m=r===void 0?d?.find(({challenge:e})=>e.candidateId===void 0)?.challenge.requester:void 0;m!==void 0&&o.set(AuthKey,m);let h={...hydrateDurableSession({compactionOverrides:{thresholdPercent:l.thresholdPercent},durable:a,turnAgent:l.turnAgent}),history:validateHarnessModelMessages(e.history)},g=createExecutionHistoryView(h),_=bindSessionInstrumentation({agentName:l.turnAgent.id,ctx:o,rootSessionId:h.rootSessionId??h.sessionId,sessionId:h.sessionId}),v=turnPosition(currentProjection(o)),y=isBetweenTurns(currentProjection(o));if(!v.sessionStarted&&!o.has(SessionTitleKey)&&!o.has(ParentSessionKey)){let e=n?.payloads.find(e=>e.message!==void 0)?.message,r=deriveSessionTitle(n?.title??e);r!==void 0&&(o.set(SessionTitleKey,r),t.title=setEveAttributes({"$eve.title":r}))}n!==void 0&&(await contextStorage.run(o,()=>_?.preparePreamble({sequence:v.sequence,sessionStarted:v.sessionStarted})),await contextStorage.run(o,()=>_?.instrumentChannelDelivery({agentName:c.turnAgent.id,ctx:o,delivery:n,rootSessionId:h.rootSessionId??h.sessionId,sequence:v.sequence,sessionId:h.sessionId,turnId:activeTurnId(v)})));let failChannelDeliveries=async e=>{await contextStorage.run(o,()=>_?.instrumentChannelDelivery({ctx:o,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await _?.flush()},b=openSessionEventPublisher({ctx:o,origin:`own`,sessionWritable:e.sessionWritable}),{adapterCtx:x}=b.dispatcher,S=new AbortController,C=e.abortSignal===void 0?S.signal:AbortSignal.any([e.abortSignal,S.signal]);try{let u=bindDynamicConnections(o,c.resolvedAgent),m={...c.graph.root,turnAgent:l.turnAgent},w=!1,T=createTurnEventHandler({abortSignal:C,bundle:c,canCancelTurn:e.input?.control===void 0,hookCancellation:S,ctx:o,dynamicConnections:u,effectiveAgent:l,effectiveNode:m,instrumentation:_,publisher:b}),handleEvent=async(e,t)=>{e.type===`compaction.completed`&&(w=!0),await T(e,t)},E=r!==void 0&&!y?structuredClone(x.state):void 0,D;if(r!==void 0){let e=[];try{for(let t of r.payloads){let n=s.deliver?await s.deliver(t,x):defaultDeliverResult(t);n!=null&&e.push(n)}}catch(e){throw await failChannelDeliveries(e),e}D=e.length===0?void 0:e.reduce(coalesceTurnInputs)}let O=r?.auth===void 0?void 0:attributeAnswers({responder:r.auth,state:a.state,stepInput:D});if(O!==void 0&&(D=O,f===void 0?o.delete(AuthKey):o.set(AuthKey,f),p||o.delete(InitiatorAuthKey)),r!==void 0&&D===void 0&&!y)f===void 0?o.delete(AuthKey):o.set(AuthKey,f),x.state=E;else if(n?.payloads.some(e=>e.message!==void 0)){let e=n.deliveryMetadata?.map(e=>e.deliveryId)??[];o.set(TurnDeliveryIdsKey,v.turnId?[...new Set([...o.get(TurnDeliveryIdsKey)??[],...e])]:e)}else!v.sessionStarted&&o.get(ChannelDeliveryKey)!==void 0&&o.set(TurnDeliveryIdsKey,[o.require(ChannelDeliveryKey).deliveryId]);if(i!==void 0&&(i.acceptedAtMsByCallId!==void 0&&o.set(RuntimeActionSettlementTimesKey,i.acceptedAtMsByCallId),D={...D,runtimeActionResults:i.results}),n!==void 0){let e={...s,state:{...x.state}};setChannelContext(o,e)}if(r!==void 0&&D===void 0&&y){await contextStorage.run(o,()=>_?.instrumentChannelDelivery({ctx:o,includeTurn:!1,outcome:`completed`})),await _?.flush();let t=saveSessionProjection(reconcileSessionContinuationToken(o,h),o),n=serializeContext(o),r=t===h?{history:e.history,sessionState:e.sessionState}:createDurableSessionValues(t);return{action:`park`,...derivePendingState(t,currentProjection(o)),serializedContext:n,...r}}let k=c.subagentRegistry.dynamicResolvers??[],A=c.resolvedAgent.dynamicToolResolvers??[],j=buildRuntimeIdentity(m);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(c.compiledArtifactsSource),n=v.sessionStarted;if(o.setVirtualContext(StaticModelReferenceKey,l.turnAgent.model??null),!n)o.set(SessionDynamicSubagentRuntimeRevisionKey,t),o.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=sessionStartedForResolvers(j);await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:o,resolvers:k,event:e,messages:g.initial.messages,runtimeRevision:t}),contextStorage.run(o,async()=>await refreshDynamicSessionToolsForRuntimeRevision({ctx:o,resolvers:A,event:e,messages:g.initial.messages,runtimeRevision:t}))]),y||await rebindMissingCompiledDynamicToolCallbacks({ctx:o,event:turnStartedForResolvers({sequence:v.sequence,turnId:activeTurnId(v)}),messages:g.initial.messages,resolvers:A})}}catch(e){throw await failChannelDeliveries(e),e}let M=c.resolvedAgent.config?.experimental?.workflow?.modelCallsPerStep??1,N=o.get(CapabilitiesKey),runHarnessStep=async(n,r,i)=>{let a=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:l.thresholdPercent},session:n,turnAgent:l.turnAgent});return createExecutionNodeStep({steeringSignal:e.steeringSignal,abortSignal:C,capabilities:N,clearOnly:e.input?.control===`clear`,compactOnly:e.input?.control===`compact`,createRuntime:createWorkflowRuntime,handleEvent,prepareApprovalTurn:e=>u.dispatch(turnStartedForResolvers(e)),signInCompletions:i,historyProjector:g.projector,historyView:g.prepare(a),instrumentation:_,modelResolutionScope:{moduleMap:c.moduleMap,nodeId:c.nodeId},node:m,titleAttributeWrite:t.title})(a,r)},P,F;try{throwIfTurnAborted(C),F=await runModelCallBatch({steeringSignal:e.steeringSignal,initialInput:D,initialSession:h,modelCallsPerStep:M,runStep:async({firstCall:e,session:t,stepInput:n})=>{let r=await runStep(o,t,async t=>{o.setVirtualContext(HandleEventKey,handleEvent),o.setVirtualContext(StaticModelReferenceKey,l.turnAgent.model??null);let r=e&&D?.outputSchema!==void 0?{...t,outputSchema:D.outputSchema}:t,i=turnPosition(currentProjection(o));try{await u.rehydrate(i,j,isBetweenTurns(currentProjection(o))?void 0:{sequence:i.sequence,turnId:activeTurnId(i)})}catch(e){let t=await recoverDynamicConnectionRehydration({emit:handleEvent,error:e,projection:currentProjection(o),session:r});if(t!==void 0)return t;throw e}let a=e&&d!==void 0?d.map(({challenge:e})=>e):void 0;return runHarnessStep(r,n,a)});r.settledTurn===void 0&&throwIfTurnAborted(C);let i={...r,session:saveSessionProjection(r.session,o)};return P={result:i,serializedContext:serializeContext(o)},i}})}catch(t){if(!isTurnCancellation(t)&&!C.aborted)throw await failChannelDeliveries(t),t;return createCancelledModelCallBatchResult({beforeBatchContext:e.serializedContext,checkpoint:P,ctx:o,initialSession:h,stepInput:D})}let I=saveSessionProjection(dropClosedRecords(reconcileSessionContinuationToken(o,F.session),currentProjection(o)),o);agentTraceState.pruneAgentTraceState(o,I.sessionId,I.state);let L=serializeContext(o);F={...F,session:I};let R=resolveSessionStepResult(F,L);return R.action===`done`&&await b.writer.close(),w?{...R,compacted:!0}:R}finally{b.writer.release()}}export{turnStep};
|
|
1
|
+
import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{currentProjection,enterSessionProjection,saveSessionProjection}from"#harness/session-machine/current.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,HandleEventKey,InitiatorAuthKey,OccurrenceIdKey,ParentSessionKey,ScheduleIdKey,ScheduleInstanceKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,SessionTitleKey,StaticModelReferenceKey,TurnDeliveryIdsKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{coalesceTurnInputs,validateHarnessModelMessages}from"#harness/messages.js";import{activeTurnId,isBetweenTurns,storedProjection,turnPosition}from"#harness/session-machine/view.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{createDurableSessionValues,readDurableSession}from"#execution/durable-session-store.js";import{runStep}from"#context/run-step.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{readHitlState}from"#harness/hitl/index.js";import*as agentTraceState from"#tracing/eve/agent-trace-context-store.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey}from"#harness/authorization.js";import{refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{resolveEffectiveAgentRuntime,resolveSessionUsageLimit}from"#execution/effective-agent-config.js";import{openSessionEventPublisher}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{matchSignIns}from"#harness/session-machine/transitions.js";import{readPendingHistory,withoutPendingHistory}from"#execution/session/pending-history.js";import{dropClosedRecords,saveTransition,sessionView}from"#harness/session-machine/commit.js";import{sessionStartedForResolvers,turnStartedForResolvers}from"#harness/session-machine/resolver-events.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{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{createTurnEventHandler}from"#execution/session/turn-event-handler.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{bindTurnCallerContext}from"#subagents/parent-notification.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{recoverDynamicConnectionRehydration}from"#execution/dynamic-connection-recovery.js";import{setEveAttributes}from"#runtime/attributes/emit.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{attributeAnswers}from"#execution/session/answer-caller.js";import{resolveSessionStepResult}from"#execution/session/turn-step-result.js";import{countRunUsage}from"#execution/agent-sessions/usage.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{createExecutionHistoryView}from"#execution/history-view.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 await withSessionStateDelta(e,e=>runSessionStep({...e,serializedContext:bindTurnCallerContext(e.caller,e.serializedContext)}))}async function runSessionStep(e){let t={};try{return await runSessionStepBody(e,t)}finally{await t.title}}async function runSessionStepBody(e,t){let n=e.input?.delivery,r=n,i=e.input?.runtimeResults,a=readDurableSession(e.sessionState);for(let e of i?.delegatedUsage??[])a=countRunUsage(a,e);let o=await deserializeContext(e.serializedContext);enterSessionProjection(o,a.state);let s=o.require(ChannelKey),c=o.require(BundleKey),l=resolveEffectiveAgentRuntime(c,o);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&o.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let{signIns:u}=readHitlState(a.state),d;if(u.length>0&&r!==void 0){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(u,r.payloads);if(r={...r,payloads:t},e.length>0){let n=e.map(e=>e.result.attemptId),i=e.map(e=>e.result);o.set(PendingAuthorizationResultKey,i);let s=sessionView(storedProjection(a.state),a.state),c=matchSignIns(s,{attemptIds:n});if(c.events.length!==0)throw Error(`matchSignIns must not emit events.`);a=saveTransition(a,c),d=e,t.length===0&&(r=void 0)}}r?.payloads.some(e=>e.message!==void 0)&&(o.delete(ScheduleIdKey),o.delete(ScheduleInstanceKey),o.delete(OccurrenceIdKey),r.schedule!==void 0&&(o.set(ScheduleIdKey,r.schedule.definition),r.schedule.instance!==void 0&&o.set(ScheduleInstanceKey,r.schedule.instance),r.schedule.occurrenceId!==void 0&&o.set(OccurrenceIdKey,r.schedule.occurrenceId)));let f=o.get(AuthKey),p=o.has(InitiatorAuthKey);r?.auth!==void 0&&(o.set(AuthKey,r.auth??null),o.has(InitiatorAuthKey)||o.set(InitiatorAuthKey,r.auth??null));let m=r===void 0?d?.find(({challenge:e})=>e.candidateId===void 0)?.challenge.requester:void 0;m!==void 0&&o.set(AuthKey,m);let h=r?.payloads.some(e=>e.message!==void 0)===!0?readPendingHistory(a.state):[],g={...hydrateDurableSession({compactionOverrides:{thresholdPercent:l.thresholdPercent},durable:a,turnAgent:l.turnAgent}),history:validateHarnessModelMessages(e.history)},_=createExecutionHistoryView(g),v=bindSessionInstrumentation({agentName:l.turnAgent.id,ctx:o,rootSessionId:g.rootSessionId??g.sessionId,sessionId:g.sessionId}),y=turnPosition(currentProjection(o)),b=isBetweenTurns(currentProjection(o));if(!y.sessionStarted&&!o.has(SessionTitleKey)&&!o.has(ParentSessionKey)){let e=n?.payloads.find(e=>e.message!==void 0)?.message,r=deriveSessionTitle(n?.title??e);r!==void 0&&(o.set(SessionTitleKey,r),t.title=setEveAttributes({"$eve.title":r}))}n!==void 0&&(await contextStorage.run(o,()=>v?.preparePreamble({sequence:y.sequence,sessionStarted:y.sessionStarted})),await contextStorage.run(o,()=>v?.instrumentChannelDelivery({agentName:c.turnAgent.id,ctx:o,delivery:n,rootSessionId:g.rootSessionId??g.sessionId,sequence:y.sequence,sessionId:g.sessionId,turnId:activeTurnId(y)})));let failChannelDeliveries=async e=>{await contextStorage.run(o,()=>v?.instrumentChannelDelivery({ctx:o,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await v?.flush()},x=openSessionEventPublisher({ctx:o,origin:`own`,sessionWritable:e.sessionWritable}),{adapterCtx:S}=x.dispatcher,C=new AbortController,w=e.abortSignal===void 0?C.signal:AbortSignal.any([e.abortSignal,C.signal]);try{let u=bindDynamicConnections(o,c.resolvedAgent),m={...c.graph.root,turnAgent:l.turnAgent},T=resolveSessionUsageLimit(c),E=!1,D=createTurnEventHandler({abortSignal:w,bundle:c,canCancelTurn:e.input?.control===void 0,hookCancellation:C,ctx:o,dynamicConnections:u,effectiveAgent:l,effectiveNode:m,instrumentation:v,publisher:x}),handleEvent=async(e,t)=>{e.type===`compaction.completed`&&(E=!0),await D(e,t)},O=r!==void 0&&!b?structuredClone(S.state):void 0,k;if(r!==void 0){let e=[];try{for(let t of r.payloads){let n=s.deliver?await s.deliver(t,S):defaultDeliverResult(t);if(n!=null){let r=[...e.length===0?h:[],...t.history??[]];e.push(r.length===0?n:{...n,history:r})}}}catch(e){throw await failChannelDeliveries(e),e}e.length>0&&h.length>0&&(g={...g,state:withoutPendingHistory(g.state)}),k=e.length===0?void 0:e.reduce(coalesceTurnInputs)}let A=r?.auth===void 0?void 0:attributeAnswers({responder:r.auth,state:a.state,stepInput:k});if(A!==void 0&&(k=A,f===void 0?o.delete(AuthKey):o.set(AuthKey,f),p||o.delete(InitiatorAuthKey)),r!==void 0&&k===void 0&&!b)f===void 0?o.delete(AuthKey):o.set(AuthKey,f),S.state=O;else if(n?.payloads.some(e=>e.message!==void 0)){let e=n.deliveryMetadata?.map(e=>e.deliveryId)??[];o.set(TurnDeliveryIdsKey,y.turnId?[...new Set([...o.get(TurnDeliveryIdsKey)??[],...e])]:e)}else!y.sessionStarted&&o.get(ChannelDeliveryKey)!==void 0&&o.set(TurnDeliveryIdsKey,[o.require(ChannelDeliveryKey).deliveryId]);if(i!==void 0&&(i.acceptedAtMsByCallId!==void 0&&o.set(RuntimeActionSettlementTimesKey,i.acceptedAtMsByCallId),k={...k,runtimeActionResults:i.results}),n!==void 0){let e={...s,state:{...S.state}};setChannelContext(o,e)}if(r!==void 0&&k===void 0&&b){await contextStorage.run(o,()=>v?.instrumentChannelDelivery({ctx:o,includeTurn:!1,outcome:`completed`})),await v?.flush();let t=saveSessionProjection(reconcileSessionContinuationToken(o,g),o),n=serializeContext(o),r=t===g?{history:e.history,sessionState:e.sessionState}:createDurableSessionValues(t);return{action:`park`,...derivePendingState(t,currentProjection(o)),serializedContext:n,...r}}let j=c.subagentRegistry.dynamicResolvers??[],M=c.resolvedAgent.dynamicToolResolvers??[],N=buildRuntimeIdentity(m);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(c.compiledArtifactsSource),n=y.sessionStarted;if(o.setVirtualContext(StaticModelReferenceKey,l.turnAgent.model??null),!n)o.set(SessionDynamicSubagentRuntimeRevisionKey,t),o.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=sessionStartedForResolvers(N);await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:o,resolvers:j,event:e,messages:_.initial.messages,runtimeRevision:t}),contextStorage.run(o,async()=>await refreshDynamicSessionToolsForRuntimeRevision({ctx:o,resolvers:M,event:e,messages:_.initial.messages,runtimeRevision:t}))]),b||await rebindMissingCompiledDynamicToolCallbacks({ctx:o,event:turnStartedForResolvers({sequence:y.sequence,turnId:activeTurnId(y)}),messages:_.initial.messages,resolvers:M})}}catch(e){throw await failChannelDeliveries(e),e}let P=c.resolvedAgent.config?.experimental?.workflow?.modelCallsPerStep??1,F=o.get(CapabilitiesKey),runHarnessStep=async(n,r,i)=>{let a=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:l.thresholdPercent},session:n,turnAgent:l.turnAgent});return createExecutionNodeStep({steeringSignal:e.steeringSignal,abortSignal:w,capabilities:F,clearOnly:e.input?.control===`clear`,compactOnly:e.input?.control===`compact`,createRuntime:createWorkflowRuntime,handleEvent,prepareApprovalTurn:e=>u.dispatch(turnStartedForResolvers(e)),signInCompletions:i,historyProjector:_.projector,historyView:_.prepare(a),instrumentation:v,modelResolutionScope:{moduleMap:c.moduleMap,nodeId:c.nodeId},node:m,sessionUsageLimit:T,titleAttributeWrite:t.title})(a,r)},I,L;try{throwIfTurnAborted(w),L=await runModelCallBatch({steeringSignal:e.steeringSignal,initialInput:k,initialSession:g,modelCallsPerStep:P,runStep:async({firstCall:e,session:t,stepInput:n})=>{let r=await runStep(o,t,async t=>{o.setVirtualContext(HandleEventKey,handleEvent),o.setVirtualContext(StaticModelReferenceKey,l.turnAgent.model??null);let r=e&&k?.outputSchema!==void 0?{...t,outputSchema:k.outputSchema}:t,i=turnPosition(currentProjection(o));try{await u.rehydrate(i,N,isBetweenTurns(currentProjection(o))?void 0:{sequence:i.sequence,turnId:activeTurnId(i)})}catch(e){let t=await recoverDynamicConnectionRehydration({emit:handleEvent,error:e,projection:currentProjection(o),session:r});if(t!==void 0)return t;throw e}let a=e&&d!==void 0?d.map(({challenge:e})=>e):void 0;return runHarnessStep(r,n,a)});r.settledTurn===void 0&&throwIfTurnAborted(w);let i={...r,session:saveSessionProjection(r.session,o)};return I={result:i,serializedContext:serializeContext(o)},i}})}catch(t){if(!isTurnCancellation(t)&&!w.aborted)throw await failChannelDeliveries(t),t;return createCancelledModelCallBatchResult({beforeBatchContext:e.serializedContext,checkpoint:I,ctx:o,initialSession:g,stepInput:k})}let R=saveSessionProjection(dropClosedRecords(reconcileSessionContinuationToken(o,L.session),currentProjection(o)),o);agentTraceState.pruneAgentTraceState(o,R.sessionId,R.state);let z=serializeContext(o);L={...L,session:R};let B=resolveSessionStepResult(L,z);return B.action===`done`&&await x.writer.close(),E?{...B,compacted:!0}:B}finally{x.writer.release()}}export{turnStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{storedProjection}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-store.js";import{publishSessionEvents}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{
|
|
1
|
+
import{storedProjection}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-store.js";import{publishSessionEvents}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{hold}from"#harness/session-machine/transitions.js";import{sessionView}from"#harness/session-machine/commit.js";async function publishTurnWaitingStep(e){"use step";return await withSessionStateDelta(e,async e=>{let t=readDurableSession(e.sessionState),n=sessionView(storedProjection(t.state),t.state),{events:r}=hold(n,{on:`tasks`});return r.length===0?{serializedContext:e.serializedContext,sessionState:e.sessionState}:await publishSessionEvents(e,r)})}export{publishTurnWaitingStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{TASK_WAIT_TOOL_NAME}from"#protocol/task-tools.js";import{renderTaskWaitResult}from"#execution/tasks/render.js";import{taskWaitResult}from"#execution/tasks/table.js";import{sleep}from"#compiled/@workflow/core/index.js";import{findBlockingWorkflowToolRun,getBlockingWorkflowToolRuns,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{handleWorkflowToolRunMessage,isAppliedRunMessage,takeLeadingAppliedRunMessages}from"#execution/session-workflow-tool-run.js";import{resolveTurnPrincipal}from"#execution/session/principal.js";import{answerTaskCancel,cancelWorkingTasks,sessionTaskTable}from"#execution/tasks/session.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{dispatchCoordinationStep}from"#execution/coordination-dispatch-step.js";import{taskToolResult}from"#execution/tasks/calls.js";import{publishTurnWaitingStep}from"#execution/session/turn-waiting-step.js";import{applyRunMessagesStep}from"#execution/tools/workflow/apply-run-messages-step.js";import{interruptWorkflowToolRun}from"#execution/tools/workflow/interrupt.js";import{turnStep}from"#execution/session/turn-step.js";import{ActiveTurn}from"#execution/session/active-turn.js";import{resolveRuntimeActionResultsForCallIds}from"#runtime/actions/results.js";import{startTaskToolCallsStep,traceTaskToolCallStep}from"#execution/session/task-tool-tracing-step.js";function hasDelegatedCallerContext(e){if(e[`eve.sessionCallback`]!==void 0)return!0;let t=e[`eve.channel`];return typeof t==`object`&&!!t&&Reflect.get(t,`kind`)===`subagent`}var SessionExecution=class{input;constructor(e){this.input=e}get cursor(){return this.input.cursor}async runTurn(e,t={}){let n;try{n=new ActiveTurn(this.input,{caller:t.caller,principal:resolveTurnPrincipal(e,this.input.cursor.serializedContext)},t.control)}catch(e){throw t.control?.dispose(),e}try{let t=await this.runTurnSteps(n,e);return await this.handleBoundaryMessages(n.takeBoundaryMessages(),t.kind===`done`),t.kind===`park`&&t.settled!==void 0&&await cancelWorkingTasks(this.input.cursor,`turn_ended`),{...t,...n.caller!==void 0&&{caller:n.caller},...n.compacted&&{compacted:!0}}}finally{n.dispose()}}async handleBoundaryMessages(e,t=!1,n){let r=[];for(let i of e)isAppliedRunMessage(i)?(!t||i.kind!==`agent-started`)&&r.push(i):(await this.applyRunMessages(r,n),r=[],await handleWorkflowToolRunMessage({cursor:this.input.cursor,message:i}));await this.applyRunMessages(r,n)}async applyRunMessages(e,t){if(e.length===0)return;let{cancelled:n}=await this.input.cursor.advance(n=>applyRunMessagesStep({...n,canCancelTurn:t!==void 0,messages:e}));n&&t?.abort()}async runTurnSteps(e,t){let n=t,r=e.caller;for(;;){let{cursor:t}=this.input,i=r;r=void 0;let a=await t.advanceWithHistory(t=>turnStep({...t,abortSignal:e.signal,caller:i,input:n,steeringSignal:e.steeringSignal}));a.compacted===!0&&(e.compacted=!0);let o=a.action===`park`?a.pendingCoordinationCallIds:void 0,s=a.action===`park`&&a.settled!==void 0,c=this.input.queue.nextAdmission;await e.admitBoundary();let l=a.action===`done`;if(await this.handleBoundaryMessages(e.takeBoundaryMessages(),l,l?void 0:e),a.action===`cancelled`||!s&&e.signal.aborted&&o===void 0)return await this.finishCancelledTurn(e);if(a.action===`done`)return{isError:a.isError,kind:`done`,output:a.output??``,usage:a.usage,usageDelta:a.usageDelta};if(a.action===`held`&&a.hold===`request`){if(a.hasPendingInputBatch&&this.input.capabilities?.requestInput!==!0&&!hasDelegatedCallerContext(this.input.cursor.serializedContext))throw Error(`This session cannot request human input, so it cannot wait for a tool approval or question. Configure unattended tools with an approval policy that does not require human input.`);let t=await this.waitForHeldRequest(e,a,c);if(t===`cancelled`)return await this.finishCancelledTurn(e);n={delivery:t};continue}if(a.action===`held`){if(await this.waitForHeldTurn(e)===`cancelled`)return await this.finishCancelledTurn(e);let t=await e.takeSteering();n=t===void 0?void 0:{delivery:t};continue}if(o!==void 0&&a.action===`park`){let t=a.hasRunsToDispatch===!1?[]:await this.dispatchRuns(),r=t.length===0?void 0:Date.now(),i=await this.waitForRuntimeActionResults({initialAcceptedAtMs:r,initialResults:t,taskToolCalls:a.pendingTaskToolCalls??[],pendingCallIds:o,turn:e});if(i===`cancelled`)return await this.finishCancelledTurn(e);n={delivery:await e.takeSteering(),runtimeResults:i};continue}if(a.action===`park`)return{kind:`park`,settled:a.settled};let u=await e.takeSteering();n=u===void 0?void 0:{delivery:u}}}async dispatchRuns(){return(await this.input.cursor.advance(e=>dispatchCoordinationStep({action:`park`,workflowToolRunOwner:{inbox:sessionInboxHookToken(sessionCommandHookToken(this.input.sessionId))},...e}))).results}async handleWorkflowMessage(e,t){if(isAppliedRunMessage(e)){let n=t?.takeAppliedRunMessages()??takeLeadingAppliedRunMessages(this.input.inbox);await this.applyRunMessages([e,...n],t);return}return await handleWorkflowToolRunMessage({cursor:this.input.cursor,message:e})}async cancelTurnWork(){let{cursor:e}=this.input;mayWaitOnWorkflowToolRuns(e.sessionState)&&await cancelDescendantTurnsStep({serializedContext:e.serializedContext,sessionState:e.sessionState}),await cancelWorkingTasks(e,`turn_cancelled`)}async finishCancelledTurn(e){return await this.handleBoundaryMessages(e.takeBoundaryMessages(`agent-started`)),await this.cancelTurnWork(),{cancelled:!0,kind:`park`}}async waitForHeldTurn(e){let t=!1;for(;;){let n={interrupted:t,timedOut:!1};if(taskWaitResult(sessionTaskTable(this.input.cursor),n)!==void 0)return`woke`;let r=await e.nextRuntimeEvent([]);if(r===`cancelled`)return r;switch(r.kind){case`steering`:t=!0;continue;case`workflow`:await this.handleWorkflowMessage(r.message,e);continue;case`input`:case`runtime-action-result`:case`timeout`:continue}}}async waitForHeldRequest(e,t,n){let r=new Set(t.authorizationAttemptIds),i=new Set(t.inputRequestIds);for(;;){let t=this.input.queue.takeAuthorizations(r);if(t!==void 0)return{kind:`deliver`,payloads:t};let a=await e.takeInputResponses(i);if(a!==void 0)return a;let o=await e.takeSteering({heldSince:n});if(o!==void 0)return o;let s=await e.nextRuntimeEvent([]);if(s===`cancelled`)return s;s.kind===`workflow`&&await this.handleWorkflowMessage(s.message,e)}}async waitForRuntimeActionResults(e){let t=[...e.initialResults],n=!1,r=new Map,i=new Map;if(e.initialAcceptedAtMs!==void 0)for(let n of t)r.set(n.callId,e.initialAcceptedAtMs);let accept=e=>{t.push(e),r.set(e.callId,Date.now())},a=await this.answerTaskToolCalls(e.taskToolCalls,accept);try{for(;;){a=await this.resolveTaskWaits(a,n,accept);let o=resolveRuntimeActionResultsForCallIds({pendingCallIds:e.pendingCallIds,results:t});if(o!==void 0){let e=o.flatMap(e=>{let t=i.get(e.callId);return t===void 0?[]:[t]});return{acceptedAtMsByCallId:Object.fromEntries(o.map(e=>[e.callId,r.get(e.callId)])),...e.length>0&&{delegatedUsage:e},results:o}}let s=a.flatMap(e=>e.timer===void 0?[]:[e.timer]),c=await e.turn.nextRuntimeEvent(s);if(c===`cancelled`)return c;if(c.kind===`timeout`){for(let e of a)e.callId===c.callId&&(e.timedOut=!0);continue}if(c.kind===`input`)continue;if(c.kind===`steering`){n||await this.interruptWaitedWorkflowCalls(e.pendingCallIds,t),n=!0;continue}if(c.kind===`runtime-action-result`){let e=this.input.cursor.sessionState.snapshot.session.state,n=c.results.filter(t=>t.kind===`tool-result`&&isInboxToolResultFromRecordedWorkflowToolRun(e,t));if(n.length>0){let e=Date.now();t.push(...n);for(let t of n)r.set(t.callId,e)}continue}let l=await this.handleWorkflowMessage(c.message,e.turn);l!==void 0&&(accept(l),c.message.kind===`outcome`&&c.message.usage!==void 0&&i.set(l.callId,c.message.usage))}}finally{for(let e of a)await this.traceTaskWait(e,void 0,!0)}}async resolveTaskWaits(e,t,n){let r=sessionTaskTable(this.input.cursor),i=[];for(let a of e){let e=taskWaitResult(r,{interrupted:t,timedOut:a.timedOut});if(e===void 0){i.push(a);continue}let o=renderTaskWaitResult(e,Date.now()-a.startedAtMs);await this.traceTaskWait(a,o,t),n(taskToolResult(a.callId,TASK_WAIT_TOOL_NAME,o))}return i}async answerTaskToolCalls(e,t){let n=[],r=e.length===0?0:await startTaskToolCallsStep();for(let i of e)if(i.kind===TASK_WAIT_TOOL_NAME)n.push(startTaskWait(i,r));else{let e;try{e=await answerTaskCancel(this.input.cursor,i)}catch(e){throw await this.input.cursor.advance(e=>traceTaskToolCallStep(e,{callId:i.callId,toolName:i.kind,startedAtMs:r,completedAtMs:Date.now(),input:{taskId:i.taskId},failed:!0})),e}await this.input.cursor.advance(t=>traceTaskToolCallStep(t,{callId:i.callId,toolName:i.kind,startedAtMs:r,completedAtMs:Date.now(),input:{taskId:i.taskId},output:e.output})),t(e)}let i=await this.resolveTaskWaits(n,!1,t);return i.length>0&&await this.input.cursor.advance(publishTurnWaitingStep),i}async traceTaskWait(e,t,n=!1){await this.input.cursor.advance(r=>traceTaskToolCallStep(r,{callId:e.callId,toolName:TASK_WAIT_TOOL_NAME,startedAtMs:e.startedAtMs,completedAtMs:Date.now(),input:e.input,output:t,failed:n}))}async interruptWaitedWorkflowCalls(e,t){let n=this.input.cursor.sessionState.snapshot.session.state,r=new Set(t.map(e=>e.callId)),i=e.filter(e=>!r.has(e)).flatMap(e=>{let t=findBlockingWorkflowToolRun(n,e);return t===void 0?[]:[t.address]});await Promise.all(i.map(e=>interruptWorkflowToolRun(e)))}};function startTaskWait(e,t){let{callId:n,timeoutMs:r}=e,i=r===void 0?void 0:sleep(r).then(()=>n);return{callId:n,startedAtMs:t,input:r===void 0?{}:{timeoutSeconds:r/1e3},timedOut:r===0,timer:i}}function mayWaitOnWorkflowToolRuns(e){try{return getBlockingWorkflowToolRuns(e.snapshot?.session?.state).length>0}catch{return!0}}export{SessionExecution,hasDelegatedCallerContext};
|
|
1
|
+
import{sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{TASK_WAIT_TOOL_NAME}from"#protocol/task-tools.js";import{renderTaskWaitResult}from"#execution/tasks/render.js";import{sleep}from"#compiled/@workflow/core/index.js";import{findBlockingWorkflowToolRun,getBlockingWorkflowToolRuns,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{taskWaitResult}from"#execution/tasks/table.js";import{handleWorkflowToolRunMessage,isAppliedRunMessage,takeLeadingAppliedRunMessages}from"#execution/session-workflow-tool-run.js";import{resolveTurnPrincipal}from"#execution/session/principal.js";import{answerTaskCancel,cancelWorkingTasks,sessionTaskTable}from"#execution/tasks/session.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{dispatchCoordinationStep,publishTaskStartedStep}from"#execution/coordination-dispatch-step.js";import{taskToolResult}from"#execution/tasks/calls.js";import{publishTurnWaitingStep}from"#execution/session/turn-waiting-step.js";import{applyRunMessagesStep}from"#execution/tools/workflow/apply-run-messages-step.js";import{interruptWorkflowToolRun}from"#execution/tools/workflow/interrupt.js";import{turnStep}from"#execution/session/turn-step.js";import{ActiveTurn}from"#execution/session/active-turn.js";import{resolveRuntimeActionResultsForCallIds}from"#runtime/actions/results.js";import{startTaskToolCallsStep,traceTaskToolCallStep}from"#execution/session/task-tool-tracing-step.js";function hasDelegatedCallerContext(e){if(e[`eve.sessionCallback`]!==void 0)return!0;let t=e[`eve.channel`];return typeof t==`object`&&!!t&&Reflect.get(t,`kind`)===`subagent`}var SessionExecution=class{input;constructor(e){this.input=e}get cursor(){return this.input.cursor}async runTurn(e,t={}){let n;try{n=new ActiveTurn(this.input,{caller:t.caller,principal:resolveTurnPrincipal(e,this.input.cursor.serializedContext)},t.control)}catch(e){throw t.control?.dispose(),e}try{let t=await this.runTurnSteps(n,e);return await this.handleBoundaryMessages(n.takeBoundaryMessages(),t.kind===`done`),t.kind===`park`&&t.settled!==void 0&&await cancelWorkingTasks(this.input.cursor,`turn_ended`),{...t,...n.caller!==void 0&&{caller:n.caller},...n.compacted&&{compacted:!0}}}finally{n.dispose()}}async handleBoundaryMessages(e,t=!1,n){let r=[];for(let i of e)isAppliedRunMessage(i)?(!t||i.kind!==`agent-started`)&&r.push(i):(await this.applyRunMessages(r,n),r=[],await handleWorkflowToolRunMessage({cursor:this.input.cursor,message:i}));await this.applyRunMessages(r,n)}async applyRunMessages(e,t){if(e.length===0)return;let{cancelled:n}=await this.input.cursor.advance(n=>applyRunMessagesStep({...n,canCancelTurn:t!==void 0,messages:e}));n&&t?.abort()}async runTurnSteps(e,t){let n=t,r=e.caller;for(;;){let{cursor:t}=this.input,i=r;r=void 0;let a=await t.advanceWithHistory(t=>turnStep({...t,abortSignal:e.signal,caller:i,input:n,steeringSignal:e.steeringSignal}));a.compacted===!0&&(e.compacted=!0);let o=a.action===`park`?a.pendingCoordinationCallIds:void 0,s=a.action===`park`&&a.settled!==void 0,c=this.input.queue.nextAdmission;await e.admitBoundary();let l=a.action===`done`;if(await this.handleBoundaryMessages(e.takeBoundaryMessages(),l,l?void 0:e),a.action===`cancelled`||!s&&e.signal.aborted&&o===void 0)return await this.finishCancelledTurn(e);if(a.action===`done`)return{isError:a.isError,kind:`done`,output:a.output??``,usage:a.usage,usageDelta:a.usageDelta};if(a.action===`held`&&a.hold===`request`){if(a.hasPendingInputBatch&&this.input.capabilities?.requestInput!==!0&&!hasDelegatedCallerContext(this.input.cursor.serializedContext))throw Error(`This session cannot request human input, so it cannot wait for a tool approval or question. Configure unattended tools with an approval policy that does not require human input.`);let t=await this.waitForHeldRequest(e,a,c);if(t===`cancelled`)return await this.finishCancelledTurn(e);n={delivery:t};continue}if(a.action===`held`){if(await this.waitForHeldTurn(e)===`cancelled`)return await this.finishCancelledTurn(e);let t=await e.takeSteering();n=t===void 0?void 0:{delivery:t};continue}if(o!==void 0&&a.action===`park`){let t=a.hasRunsToDispatch===!1?[]:await this.dispatchRuns(),r=t.length===0?void 0:Date.now(),i=await this.waitForRuntimeActionResults({initialAcceptedAtMs:r,initialResults:t,taskToolCalls:a.pendingTaskToolCalls??[],pendingCallIds:o,turn:e});if(i===`cancelled`)return await this.finishCancelledTurn(e);n={delivery:await e.takeSteering(),runtimeResults:i};continue}if(a.action===`park`)return{kind:`park`,settled:a.settled};let u=await e.takeSteering();n=u===void 0?void 0:{delivery:u}}}async dispatchRuns(){let{cursor:e}=this.input,t=await e.advance(({serializedContext:e,sessionState:t})=>dispatchCoordinationStep({action:`park`,serializedContext:e,sessionState:t,workflowToolRunOwner:{inbox:sessionInboxHookToken(sessionCommandHookToken(this.input.sessionId))}}));return t.started.length>0&&await e.advance(e=>publishTaskStartedStep({...e,started:t.started})),t.results}async handleWorkflowMessage(e,t){if(isAppliedRunMessage(e)){let n=t?.takeAppliedRunMessages()??takeLeadingAppliedRunMessages(this.input.inbox);await this.applyRunMessages([e,...n],t);return}return await handleWorkflowToolRunMessage({cursor:this.input.cursor,message:e})}async cancelTurnWork(){let{cursor:e}=this.input;mayWaitOnWorkflowToolRuns(e.sessionState)&&await cancelDescendantTurnsStep({serializedContext:e.serializedContext,sessionState:e.sessionState}),await cancelWorkingTasks(e,`turn_cancelled`)}async finishCancelledTurn(e){return await this.handleBoundaryMessages(e.takeBoundaryMessages(`agent-started`)),await this.cancelTurnWork(),{cancelled:!0,kind:`park`}}async waitForHeldTurn(e){let t=!1;for(;;){let n={interrupted:t,timedOut:!1};if(taskWaitResult(sessionTaskTable(this.input.cursor),n)!==void 0)return`woke`;let r=await e.nextRuntimeEvent([]);if(r===`cancelled`)return r;switch(r.kind){case`steering`:t=!0;continue;case`workflow`:await this.handleWorkflowMessage(r.message,e);continue;case`input`:case`runtime-action-result`:case`timeout`:continue}}}async waitForHeldRequest(e,t,n){let r=new Set(t.authorizationAttemptIds),i=new Set(t.inputRequestIds);for(;;){let t=this.input.queue.takeAuthorizations(r);if(t!==void 0)return{kind:`deliver`,payloads:t};let a=await e.takeInputResponses(i);if(a!==void 0)return a;let o=await e.takeSteering({heldSince:n});if(o!==void 0)return o;let s=await e.nextRuntimeEvent([]);if(s===`cancelled`)return s;s.kind===`workflow`&&await this.handleWorkflowMessage(s.message,e)}}async waitForRuntimeActionResults(e){let t=[...e.initialResults],n=!1,r=new Map,i=new Map;if(e.initialAcceptedAtMs!==void 0)for(let n of t)r.set(n.callId,e.initialAcceptedAtMs);let accept=e=>{t.push(e),r.set(e.callId,Date.now())},a=await this.answerTaskToolCalls(e.taskToolCalls,accept);try{for(;;){a=await this.resolveTaskWaits(a,n,accept);let o=resolveRuntimeActionResultsForCallIds({pendingCallIds:e.pendingCallIds,results:t});if(o!==void 0){let e=o.flatMap(e=>{let t=i.get(e.callId);return t===void 0?[]:[t]});return{acceptedAtMsByCallId:Object.fromEntries(o.map(e=>[e.callId,r.get(e.callId)])),...e.length>0&&{delegatedUsage:e},results:o}}let s=a.flatMap(e=>e.timer===void 0?[]:[e.timer]),c=await e.turn.nextRuntimeEvent(s);if(c===`cancelled`)return c;if(c.kind===`timeout`){for(let e of a)e.callId===c.callId&&(e.timedOut=!0);continue}if(c.kind===`input`)continue;if(c.kind===`steering`){n||await this.interruptWaitedWorkflowCalls(e.pendingCallIds,t),n=!0;continue}if(c.kind===`runtime-action-result`){let e=this.input.cursor.sessionState.snapshot.session.state,n=c.results.filter(t=>t.kind===`tool-result`&&isInboxToolResultFromRecordedWorkflowToolRun(e,t));if(n.length>0){let e=Date.now();t.push(...n);for(let t of n)r.set(t.callId,e)}continue}let l=await this.handleWorkflowMessage(c.message,e.turn);l!==void 0&&(accept(l),c.message.kind===`outcome`&&c.message.usage!==void 0&&i.set(l.callId,c.message.usage))}}finally{for(let e of a)await this.traceTaskWait(e,void 0,!0)}}async resolveTaskWaits(e,t,n){let r=sessionTaskTable(this.input.cursor),i=[];for(let a of e){let e=taskWaitResult(r,{interrupted:t,timedOut:a.timedOut});if(e===void 0){i.push(a);continue}let o=renderTaskWaitResult(e,Date.now()-a.startedAtMs);await this.traceTaskWait(a,o,t),n(taskToolResult(a.callId,TASK_WAIT_TOOL_NAME,o))}return i}async answerTaskToolCalls(e,t){let n=[],r=e.length===0?0:await startTaskToolCallsStep();for(let i of e)if(i.kind===TASK_WAIT_TOOL_NAME)n.push(startTaskWait(i,r));else{let e;try{e=await answerTaskCancel(this.input.cursor,i)}catch(e){throw await this.input.cursor.advance(e=>traceTaskToolCallStep(e,{callId:i.callId,toolName:i.kind,startedAtMs:r,completedAtMs:Date.now(),input:{taskId:i.taskId},failed:!0})),e}await this.input.cursor.advance(t=>traceTaskToolCallStep(t,{callId:i.callId,toolName:i.kind,startedAtMs:r,completedAtMs:Date.now(),input:{taskId:i.taskId},output:e.output})),t(e)}let i=await this.resolveTaskWaits(n,!1,t);return i.length>0&&await this.input.cursor.advance(publishTurnWaitingStep),i}async traceTaskWait(e,t,n=!1){await this.input.cursor.advance(r=>traceTaskToolCallStep(r,{callId:e.callId,toolName:TASK_WAIT_TOOL_NAME,startedAtMs:e.startedAtMs,completedAtMs:Date.now(),input:e.input,output:t,failed:n}))}async interruptWaitedWorkflowCalls(e,t){let n=this.input.cursor.sessionState.snapshot.session.state,r=new Set(t.map(e=>e.callId)),i=e.filter(e=>!r.has(e)).flatMap(e=>{let t=findBlockingWorkflowToolRun(n,e);return t===void 0?[]:[t.address]});await Promise.all(i.map(e=>interruptWorkflowToolRun(e)))}};function startTaskWait(e,t){let{callId:n,timeoutMs:r}=e,i=r===void 0?void 0:sleep(r).then(()=>n);return{callId:n,startedAtMs:t,input:r===void 0?{}:{timeoutSeconds:r/1e3},timedOut:r===0,timer:i}}function mayWaitOnWorkflowToolRuns(e){try{return getBlockingWorkflowToolRuns(e.snapshot?.session?.state).length>0}catch{return!0}}export{SessionExecution,hasDelegatedCallerContext};
|
|
@@ -21,5 +21,8 @@ export declare function sessionInboxHookToken(token: string): string;
|
|
|
21
21
|
export declare function isSessionInboxHookToken(token: string): boolean;
|
|
22
22
|
/** Logical address behind a physical session inbox hook token; `undefined` for any other hook. */
|
|
23
23
|
export declare function logicalSessionInboxToken(token: string): string | undefined;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Marker an owner older than handoff version 3 leaves while it releases its
|
|
26
|
+
* hooks, so ingress can tell "handoff in progress" from "no session".
|
|
27
|
+
*/
|
|
25
28
|
export declare function sessionHandoffMarkerToken(token: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{logicalSessionInboxToken,sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{cancelRun,getRun,getWorld}from"#internal/workflow/runtime.js";import{isInactiveWorkflowRunError}from"#internal/workflow/is-inactive-workflow-run-error.js";import{logicalSessionToken,requireSessionId}from"#execution/session-inbox/resume.js";import{sessionFailed}from"#harness/session-machine/transitions.js";import{findSessionHookHolder}from"#execution/session-inbox/owner.js";import{EVE_SESSION_ATTRIBUTE,EVE_TYPE_ATTRIBUTE}from"#execution/eve-workflow-attributes.js";import{waitForSessionHooksRelease}from"#execution/session-inbox/hook-release.js";const log=createLogger(`execution.session-inbox`);async function endStrandedSession(e,t,n){let r=typeof t==`string`?await resolveStrandedSessionId(e):t.sessionId,{ownerRunId:i}=e,a=await getWorld();await assertStillServesSession(r,i);let o=await listOwnedSessionTokens(a,i);return await publishTerminalEvent(r,n),await cancelRuns(a,[i,r],`Session ended: its deployment was retired`),await waitForSessionHooksRelease([sessionCommandHookToken(r),logicalSessionToken(t),...o],i),log.warn(`Reset stranded session`,{currentEveVersion:resolveInstalledPackageInfo().version,previousEveVersion:e.eveVersion??`unknown`,previousSessionId:r,trigger:n}),r}async function assertStillServesSession(e,t){let n=await findSessionHookHolder(sessionInboxHookToken(sessionCommandHookToken(e)));if(n!==void 0&&n.runId!==t)throw Error(`Session "${e}" changed owners while it was being reset. Nothing was ended; retry the request.`)}async function publishTerminalEvent(e,t){let n=getRun(e).getWritable().getWriter(),r=(async()=>(await n.write(encodeMessageStreamEvent(stampMessageStreamEvent(sessionFailed({code:`session_stranded`,details:{trigger:t},message:`This session is no longer available.`,sessionId:e,usage:void 0})))),await n.close(),!0))();r.catch(()=>{});let i,a=new Promise(e=>{i=setTimeout(()=>e(!1),5e3)});try{await Promise.race([r,a])||log.warn(`Timed out finishing the stranded session stream`,{sessionId:e})}catch{log.warn(`Could not finish the stranded session stream`,{sessionId:e})}finally{clearTimeout(i),n.releaseLock()}}async function cancelRuns(e,t,n){for(let r of new Set(t))try{await cancelRun(e,r,{cancelReason:n})}catch(e){if(!isInactiveWorkflowRunError(e))throw e}}async function resolveStrandedSessionId(e){let{attributes:t,runId:n}=e.ownerRun,r=t[EVE_SESSION_ATTRIBUTE];if(r!==void 0)return r;if(e.hook!==void 0)try{return requireSessionId(await e.hook.metadata)}catch{}if(t[EVE_TYPE_ATTRIBUTE]!==void 0)return n;throw Error(`Cannot reset stranded session owner run "${n}": it does not record which session it serves. Cancel the run directly.`)}async function listOwnedSessionTokens(e,t){let n=[],r;for(let i=0;i<10;i++){let i=await e.hooks.list({pagination:{cursor:r,limit:100},resolveData:`none`,runId:t});for(let e of i.data){let t=logicalSessionInboxToken(e.token);t!==void 0&&n.push(t)}if(!i.hasMore||i.cursor===null)break;r=i.cursor}return n}export{endStrandedSession};
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{logicalSessionInboxToken,sessionCommandHookToken,sessionInboxHookToken}from"#execution/session-inbox/address.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{cancelRun,getRun,getWorld}from"#internal/workflow/runtime.js";import{isInactiveWorkflowRunError}from"#internal/workflow/is-inactive-workflow-run-error.js";import{logicalSessionToken,requireSessionId}from"#execution/session-inbox/resume.js";import{sessionFailed}from"#harness/session-machine/transitions.js";import{findSessionHookHolder}from"#execution/session-inbox/owner.js";import{EVE_SESSION_ATTRIBUTE,EVE_TYPE_ATTRIBUTE}from"#execution/eve-workflow-attributes.js";import{waitForSessionHooksRelease}from"#execution/session-inbox/hook-release.js";const log=createLogger(`execution.session-inbox`);async function endStrandedSession(e,t,n){let r=typeof t==`string`?await resolveStrandedSessionId(e):t.sessionId,{ownerRunId:i}=e,a=await getWorld();await assertStillServesSession(r,i);let o=await listOwnedSessionTokens(a,i);return await publishTerminalEvent(r,n),await cancelRuns(a,[i,r],`Session ended: its deployment was retired`),await waitForSessionHooksRelease([sessionCommandHookToken(r),logicalSessionToken(t),...o],{ownerRunId:i,sessionId:r}),log.warn(`Reset stranded session`,{currentEveVersion:resolveInstalledPackageInfo().version,previousEveVersion:e.eveVersion??`unknown`,previousSessionId:r,trigger:n}),r}async function assertStillServesSession(e,t){let n=await findSessionHookHolder(sessionInboxHookToken(sessionCommandHookToken(e)));if(n!==void 0&&n.runId!==t)throw Error(`Session "${e}" changed owners while it was being reset. Nothing was ended; retry the request.`)}async function publishTerminalEvent(e,t){let n=getRun(e).getWritable().getWriter(),r=(async()=>(await n.write(encodeMessageStreamEvent(stampMessageStreamEvent(sessionFailed({code:`session_stranded`,details:{trigger:t},message:`This session is no longer available.`,sessionId:e,usage:void 0})))),await n.close(),!0))();r.catch(()=>{});let i,a=new Promise(e=>{i=setTimeout(()=>e(!1),5e3)});try{await Promise.race([r,a])||log.warn(`Timed out finishing the stranded session stream`,{sessionId:e})}catch{log.warn(`Could not finish the stranded session stream`,{sessionId:e})}finally{clearTimeout(i),n.releaseLock()}}async function cancelRuns(e,t,n){for(let r of new Set(t))try{await cancelRun(e,r,{cancelReason:n})}catch(e){if(!isInactiveWorkflowRunError(e))throw e}}async function resolveStrandedSessionId(e){let{attributes:t,runId:n}=e.ownerRun,r=t[EVE_SESSION_ATTRIBUTE];if(r!==void 0)return r;if(e.hook!==void 0)try{return requireSessionId(await e.hook.metadata)}catch{}if(t[EVE_TYPE_ATTRIBUTE]!==void 0)return n;throw Error(`Cannot reset stranded session owner run "${n}": it does not record which session it serves. Cancel the run directly.`)}async function listOwnedSessionTokens(e,t){let n=[],r;for(let i=0;i<10;i++){let i=await e.hooks.list({pagination:{cursor:r,limit:100},resolveData:`none`,runId:t});for(let e of i.data){let t=logicalSessionInboxToken(e.token);t!==void 0&&n.push(t)}if(!i.hasMore||i.cursor===null)break;r=i.cursor}return n}export{endStrandedSession};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
/** Longest ingress waits for a session hook to change hands. */
|
|
2
2
|
export declare const SESSION_HOOK_HANDOVER_TIMEOUT_MS = 30000;
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Waits until no run serving `session` holds any of the logical addresses. A
|
|
5
|
+
* handoff successor serves the same session, so only the session's end (or
|
|
6
|
+
* an unrelated run claiming the address afterwards) satisfies the wait.
|
|
7
|
+
*/
|
|
8
|
+
export declare function waitForSessionHooksRelease(logicalTokens: Iterable<string>, session: {
|
|
9
|
+
readonly ownerRunId: string;
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionInboxHookToken}from"#execution/session-inbox/address.js";import{findSessionHookHolder}from"#execution/session-inbox/owner.js";const SESSION_HOOK_HANDOVER_TIMEOUT_MS=3e4;async function waitForSessionHooksRelease(e,t){await Promise.all([...new Set(e)].map(e=>waitForHookRelease(sessionInboxHookToken(e),t)))}async function waitForHookRelease(e,t){let n=Date.now()+SESSION_HOOK_HANDOVER_TIMEOUT_MS;for(;;){if(
|
|
1
|
+
import{sessionInboxHookToken}from"#execution/session-inbox/address.js";import{requireSessionId}from"#execution/session-inbox/resume.js";import{findSessionHookHolder}from"#execution/session-inbox/owner.js";const SESSION_HOOK_HANDOVER_TIMEOUT_MS=3e4;async function waitForSessionHooksRelease(e,t){await Promise.all([...new Set(e)].map(e=>waitForHookRelease(sessionInboxHookToken(e),t)))}async function waitForHookRelease(e,t){let n=Date.now()+SESSION_HOOK_HANDOVER_TIMEOUT_MS;for(;;){if(!await servesSession(e,t))return;if(Date.now()>=n)throw Error(`Timed out waiting for session "${t.sessionId}" to release inbox "${e}".`);await new Promise(e=>setTimeout(e,20))}}async function servesSession(e,t){let n=await findSessionHookHolder(e);if(n===void 0)return!1;try{if(n.hook!==void 0)return requireSessionId(await n.hook.metadata)===t.sessionId}catch{}return n.runId===t.ownerRunId}export{SESSION_HOOK_HANDOVER_TIMEOUT_MS,waitForSessionHooksRelease};
|
|
@@ -11,12 +11,31 @@ export interface SessionFailurePayload {
|
|
|
11
11
|
readonly kind: "session-failure";
|
|
12
12
|
readonly error: string;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* One part of the previous owner's accepted-but-unread payloads after a
|
|
16
|
+
* handoff. The runtime sends these commands; channel request bodies cannot
|
|
17
|
+
* supply them.
|
|
18
|
+
*/
|
|
19
|
+
export interface SessionHandoverPayload {
|
|
20
|
+
readonly kind: "handover";
|
|
21
|
+
/** The handoff attempt this answers; see {@link SessionHookBatchClaimOptions.handover}. */
|
|
22
|
+
readonly attemptKey: string;
|
|
23
|
+
/** Parts apply in index order; a retried send repeats its index. */
|
|
24
|
+
readonly index: number;
|
|
25
|
+
/** The last part; reads resume once every part before it has been applied. */
|
|
26
|
+
readonly final?: true;
|
|
27
|
+
readonly payloads: readonly Exclude<SessionInboxPayload, SessionHandoverPayload>[];
|
|
28
|
+
}
|
|
29
|
+
export type SessionInboxPayload = SessionFailurePayload | SessionHandoverPayload | HookPayload | SessionCommand | WorkflowToolRunMessage | AuthorizationCallbackPayload;
|
|
30
|
+
/**
|
|
31
|
+
* While a handover is awaited (see {@link SessionHookBatchClaimOptions.handover}),
|
|
32
|
+
* reads expose nothing; interrupt handlers still fire on arrival.
|
|
33
|
+
*/
|
|
15
34
|
export interface SessionInboxReader {
|
|
16
35
|
/**
|
|
17
36
|
* Waits for and removes the next accepted payload in arrival order, or
|
|
18
|
-
* `undefined` once
|
|
19
|
-
* time; the owner program is strictly sequential.
|
|
37
|
+
* `undefined` once no hook can deliver any more (released or taken over).
|
|
38
|
+
* Only one consumer waits at a time; the owner program is strictly sequential.
|
|
20
39
|
*/
|
|
21
40
|
next(): Promise<SessionInboxPayload | undefined>;
|
|
22
41
|
/** Removes every payload accepted so far, in arrival order. */
|
|
@@ -33,21 +52,62 @@ export interface SessionInboxReader {
|
|
|
33
52
|
* consumer still processes it in order.
|
|
34
53
|
*/
|
|
35
54
|
onInterrupt(handler: (payload: SessionInboxPayload) => void): () => void;
|
|
36
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Observes readable deliveries without consuming them; replays unread
|
|
57
|
+
* deliveries on subscription and when a handover arrives, so handlers must
|
|
58
|
+
* be idempotent.
|
|
59
|
+
*/
|
|
37
60
|
onDelivery(handler: (payload: SessionInboxPayload) => void): () => void;
|
|
38
61
|
/** Requeues payloads a successor handed back, ahead of everything pumped since. */
|
|
39
62
|
restore(payloads: readonly SessionInboxPayload[]): void;
|
|
40
63
|
}
|
|
64
|
+
export interface SessionHookClaimOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Take the address over from the run that holds it instead of conflicting.
|
|
67
|
+
* Still rejects with `HookConflictError` when the holder's runtime cannot be
|
|
68
|
+
* taken from; throws `FatalError` when the World does not support it. A
|
|
69
|
+
* token this inbox already holds is claimed again on a fresh hook.
|
|
70
|
+
*/
|
|
71
|
+
readonly force?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface SessionHookBatchClaimOptions extends SessionHookClaimOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Expect a `handover` for this attempt key. Before any hook is created,
|
|
76
|
+
* reads stop exposing anything; as its parts arrive on any hook, their
|
|
77
|
+
* payloads take their place after what was queued at this call and ahead of
|
|
78
|
+
* everything accepted since. Reads resume after the final part.
|
|
79
|
+
*/
|
|
80
|
+
readonly handover?: string;
|
|
81
|
+
}
|
|
41
82
|
export interface SessionInboxOwnership {
|
|
42
83
|
/** Logical tokens currently claimed, in claim order. */
|
|
43
84
|
readonly claimedTokens: readonly string[];
|
|
44
|
-
claimSessionHook(token: string): Promise<void>;
|
|
85
|
+
claimSessionHook(token: string, options?: SessionHookClaimOptions): Promise<void>;
|
|
45
86
|
/** Registers every token as one batch; all claims settle before the first failure propagates. */
|
|
46
|
-
claimSessionHooks(tokens: readonly string[]): Promise<void>;
|
|
87
|
+
claimSessionHooks(tokens: readonly string[], options?: SessionHookBatchClaimOptions): Promise<void>;
|
|
47
88
|
}
|
|
48
89
|
export interface SessionInbox extends SessionInboxReader, SessionInboxOwnership {
|
|
49
90
|
}
|
|
50
91
|
export interface SessionInboxHandle extends SessionInbox {
|
|
92
|
+
/** A handover is expected and has not arrived; the session must not move again until it does. */
|
|
93
|
+
readonly awaitingHandover: boolean;
|
|
94
|
+
/** Resolves once no handover is awaited: it arrived, was abandoned, or the inbox closed. */
|
|
95
|
+
whenHandoverSettled(): Promise<void>;
|
|
96
|
+
/** Stops waiting for `attemptKey`'s handover, which can no longer arrive; queued payloads become readable. */
|
|
97
|
+
abandonHandover(attemptKey: string): void;
|
|
98
|
+
/** Resolves the first time a read waits on an awaited handover. */
|
|
99
|
+
whenBlockedOnHandover(): Promise<void>;
|
|
100
|
+
/** Resolves when the next payload arrives on any hook, readable or not. */
|
|
101
|
+
whenArrival(): Promise<void>;
|
|
102
|
+
/** Another run force-claimed every hook this inbox held. */
|
|
103
|
+
readonly takenOver: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Resolves once another run has force-claimed every hook this inbox held.
|
|
106
|
+
* Every payload delivered before the takeover is queued by then. Rejects if
|
|
107
|
+
* a reader fails, if the inbox is released or disposed first, or once
|
|
108
|
+
* `signal` aborts.
|
|
109
|
+
*/
|
|
110
|
+
whenTakenOver(signal?: AbortSignal): Promise<void>;
|
|
51
111
|
dispose(): Promise<void>;
|
|
52
112
|
/** Disposes every hook and returns each payload the hooks accepted but the owner never read. */
|
|
53
113
|
release(): Promise<SessionInboxPayload[]>;
|
|
@@ -1 +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`||e.kind===`session-failure`}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
|
|
1
|
+
import{sessionInboxHookToken}from"#execution/session-inbox/address.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookForceClaimedError}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`||e.kind===`session-failure`}function isDelivery(e){return e.kind===`send`||e.kind===`deliver`}function createSessionInbox(e){let t=[],n=[],r=new Set,i=new Set,a=new Set,o,s,c=new Set,l=new Set,u=!1,d=!1,notify=()=>{for(let e of r)e();r.clear()},wait=()=>new Promise(e=>r.add(e)),closed=()=>t.every(e=>e.closed||e.stopping),gated=()=>s!==void 0&&t.length>0,hasReadable=()=>!gated()&&n.length>0,throwIfFailed=()=>{if(o!==void 0)throw o.error},observe=(e,t,n)=>{for(let r of t)if(n(r))for(let t of e)t(r)},openHandover=()=>{s=void 0,observe(a,n,isDelivery),notify()},blockedOnHandover=()=>{if(gated()){for(let e of c)e();c.clear()}},acceptHandover=e=>{let t=s;if(t===void 0||e.attemptKey!==t.attemptKey||e.index<t.nextPart||t.parts.has(e.index))return;t.parts.set(e.index,e);let r=[];for(;;){let e=t.parts.get(t.nextPart);if(e===void 0)break;if(e.final===!0){observe(i,r,isInterrupt),openHandover();return}t.parts.delete(t.nextPart),t.nextPart+=1,n.splice(t.index,0,...e.payloads),t.index+=e.payloads.length,r.push(...e.payloads)}observe(i,r,isInterrupt),notify()},pump=async e=>{let r=e.hook[Symbol.asyncIterator]();try{for(;!e.stopping;){let e=await r.next();if(e.done)break;let t=e.value;for(let e of l)e();if(l.clear(),t.kind===`workflow-batch`){n.push(...t.messages),notify();continue}if(t.kind===`handover`){acceptHandover(t);continue}n.push(t),gated()||observe(a,[t],isDelivery),observe(i,[t],isInterrupt),notify()}}catch(n){if(e.stopping||e.replaced)return;isHookForceClaimedError(n)?(t.splice(t.indexOf(e),1),u=!0):o={error:n}}finally{e.closed=!0,notify()}},stop=async()=>{let e=t.splice(0);s=void 0,u=!1,d=!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,r={})=>{if(!n)throw Error(`A session alias requires a nonempty continuation token.`);let i=r.force===!0,a=t.find(e=>e.token===n);if(a!==void 0&&!i)return await a.registered;if(a===void 0&&t.length>=256)throw Error(`A session may claim at most 256 addresses.`);let o={token:n,hook:createHook({token:sessionInboxHookToken(n),metadata:{sessionId:e},...i&&{experimental_force:!0}}),stopping:!1,closed:!1,replaced:!1};a===void 0?t.push(o):(a.replaced=!0,t.splice(t.indexOf(a),1,o)),d=!1;try{o.registered=claimHookOwnership(o.hook),await o.registered,u=!1,pump(o)}catch(e){throw a===void 0||a.closed?t.splice(t.indexOf(o),1):(a.replaced=!1,t.splice(t.indexOf(o),1,a)),e}};return{get claimedTokens(){return t.map(({token:e})=>e)},get awaitingHandover(){return s!==void 0},async whenHandoverSettled(){for(;s!==void 0;)await wait()},abandonHandover(e){s?.attemptKey===e&&openHandover()},whenBlockedOnHandover(){return new Promise(e=>c.add(e))},whenArrival(){return new Promise(e=>l.add(e))},get takenOver(){return u&&t.length===0},claimSessionHook,async claimSessionHooks(e,t={}){t.handover!==void 0&&(s={attemptKey:t.handover,index:n.length,nextPart:0,parts:new Map});let r=await Promise.allSettled([...new Set(e)].map(e=>claimSessionHook(e,t)));for(let e of r)if(e.status===`rejected`)throw e.reason},async whenTakenOver(e){for(e?.addEventListener(`abort`,notify,{once:!0});t.length>0||!u;){if(throwIfFailed(),d)throw Error(`The session inbox was released before a takeover.`);if(e?.aborted===!0)throw e.reason;await wait()}},async next(){for(;;){if(throwIfFailed(),hasReadable())return n.shift();if(closed())return;blockedOnHandover(),await wait()}},drain(){return throwIfFailed(),gated()?[]:n.splice(0)},takeLeading(e){throwIfFailed();let t=[];if(gated())return t;for(let r=n[0];r!==void 0&&e(r);r=n[0])t.push(r),n.shift();return t},hasPending(){return throwIfFailed(),hasReadable()},async whenPending(){for(;o===void 0&&!hasReadable()&&!closed();)blockedOnHandover(),await wait()},onInterrupt(e){return i.add(e),()=>i.delete(e)},onDelivery(e){if(a.add(e),!gated())for(let t of n)isDelivery(t)&&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),s!==void 0&&(s.index+=e.length),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===`agent-started`||e.kind===`started`||e.kind===`report`||e.kind===`reply`||e.kind===`request`||e.kind===`withdraw`||e.kind===`usage`||e.kind===`outcome`}export{createSessionInbox,isInterrupt,isWorkflowMessage};
|
|
@@ -1 +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,schedule:n.schedule,title:n.title,caller:n.caller,deliveryMetadata:n.delivery===void 0?void 0:[{...n.delivery,payloadIndex:0}],kind:`deliver`,payloads:[n.payload],requestId:n.requestId,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};
|
|
1
|
+
import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";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;if(t.kind===`send`||t.kind===`deliver`)try{validateDeliveryIdempotencyKey(t.idempotencyKey)}catch(e){throw new SessionInboxPayloadError(e.message)}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{idempotencyKey:n.idempotencyKey,auth:n.auth,schedule:n.schedule,title:n.title,caller:n.caller,deliveryMetadata:n.delivery===void 0?void 0:[{...n.delivery,payloadIndex:0}],kind:`deliver`,payloads:[n.payload],requestId:n.requestId,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};
|
|
@@ -7,9 +7,10 @@ export interface ResumedSessionInboxHook {
|
|
|
7
7
|
readonly sessionId: Promise<string>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Resumes the current owner with the current command shape.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Resumes the current owner with the current command shape. Owners on
|
|
11
|
+
* handoff version 3 never leave an address unowned. An older owner releases
|
|
12
|
+
* its hooks before its successor claims them and leaves a marker for that
|
|
13
|
+
* interval, so delivery retries instead of
|
|
13
14
|
* reporting the session gone and letting a channel start a replacement.
|
|
14
15
|
* The retry window bounds this request, not the handoff: a marker that
|
|
15
16
|
* outlives it throws {@link SessionHandoffPendingError}.
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import type { DurableSession } from "#execution/durable-session-store.js";
|
|
2
2
|
import type { HarnessSession, HarnessSessionBase } from "#harness/types.js";
|
|
3
3
|
import type { RuntimeTurnAgent } from "#runtime/agent/bootstrap.js";
|
|
4
|
-
export declare const DEFAULT_ROOT_MAX_INPUT_TOKENS_PER_SESSION = 40000000;
|
|
5
|
-
/**
|
|
6
|
-
* Authored session token limits before resolution. `false` means the author
|
|
7
|
-
* explicitly uncapped the axis (skipping the root default). Resolution maps
|
|
8
|
-
* this shape onto the numeric {@link SessionLimits} the harness checks.
|
|
9
|
-
*/
|
|
10
|
-
interface AuthoredSessionLimits {
|
|
11
|
-
readonly maxInputTokensPerSession?: number | false;
|
|
12
|
-
readonly maxOutputTokensPerSession?: number | false;
|
|
13
|
-
readonly maxTokenCostUsdPerSession?: number | false;
|
|
14
|
-
}
|
|
15
4
|
/**
|
|
16
5
|
* Creates the durable compaction configuration used by one harness session.
|
|
17
6
|
*/
|
|
@@ -44,7 +33,6 @@ interface CreateSessionInput {
|
|
|
44
33
|
readonly rootSessionId?: string;
|
|
45
34
|
readonly sessionId: string;
|
|
46
35
|
readonly turnAgent: RuntimeTurnAgent;
|
|
47
|
-
readonly limits?: AuthoredSessionLimits;
|
|
48
36
|
readonly outputSchema?: HarnessSession["outputSchema"];
|
|
49
37
|
}
|
|
50
38
|
/** Creates a fresh {@link HarnessSession} from the current `turnAgent`. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";
|
|
1
|
+
import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";function createCompactionConfig(e={}){let t=e.thresholdPercent??.9,n={recentWindowSize:10,threshold:e.contextWindowTokens===void 0?1e5:Math.max(1,Math.floor(e.contextWindowTokens*t)),thresholdPercent:t};return e.lastKnownInputTokens===void 0?n:{...n,lastKnownInputTokens:e.lastKnownInputTokens,lastKnownPromptMessageCount:e.lastKnownPromptMessageCount}}function createSession(e){let{turnAgent:t}=e,n=createSessionToolDefinitions(t),r={agent:createSessionAgent(t,createSessionSystemPrompt(t),n),compaction:createCompactionConfig({contextWindowTokens:t.model?.contextWindowTokens,thresholdPercent:e.compactionOverrides?.thresholdPercent}),continuationToken:e.continuationToken,history:[...t.initialMessages??[]],sessionId:e.sessionId};return e.rootSessionId!==void 0&&(r.rootSessionId=e.rootSessionId),e.outputSchema!==void 0&&(r.outputSchema=e.outputSchema),r}function createSessionAgent(e,t,n){let r={compactionModelReference:e.compactionModel,reasoning:e.reasoning,system:t,tools:n};if(e.model!==void 0)return{...r,modelReference:e.model};if(e.dynamicModel!==void 0)return{...r,dynamicModel:!0};throw Error(`Cannot create a session before dynamic subagent config is selected.`)}function refreshSessionFromTurnAgent(e){return{...e.session,agent:createSessionAgent(e.turnAgent,createSessionSystemPrompt(e.turnAgent),createSessionToolDefinitions(e.turnAgent)),compaction:createCompactionConfig({contextWindowTokens:e.turnAgent.model?.contextWindowTokens,lastKnownInputTokens:e.session.compaction.lastKnownInputTokens,lastKnownPromptMessageCount:e.session.compaction.lastKnownPromptMessageCount,thresholdPercent:e.compactionOverrides?.thresholdPercent})}}function createSessionSystemPrompt(e){let t=formatAvailableSkillsSection(e.listedSkills??[]);return(t===null?e.instructions:[...e.instructions,t]).join(`
|
|
2
2
|
|
|
3
|
-
`)}function mintSubagentContinuationToken(e){return`subagent:${e??crypto.randomUUID()}`}function projectToDurableSession(e){let t={agent:{system:e.agent.system},continuationToken:e.continuationToken,sessionId:e.sessionId};return(e.compaction.lastKnownInputTokens!==void 0||e.compaction.lastKnownPromptMessageCount!==void 0)&&(t.compaction={lastKnownInputTokens:e.compaction.lastKnownInputTokens,lastKnownPromptMessageCount:e.compaction.lastKnownPromptMessageCount}),e.rootSessionId!==void 0&&(t.rootSessionId=e.rootSessionId),e.
|
|
3
|
+
`)}function mintSubagentContinuationToken(e){return`subagent:${e??crypto.randomUUID()}`}function projectToDurableSession(e){let t={agent:{system:e.agent.system},continuationToken:e.continuationToken,sessionId:e.sessionId};return(e.compaction.lastKnownInputTokens!==void 0||e.compaction.lastKnownPromptMessageCount!==void 0)&&(t.compaction={lastKnownInputTokens:e.compaction.lastKnownInputTokens,lastKnownPromptMessageCount:e.compaction.lastKnownPromptMessageCount}),e.rootSessionId!==void 0&&(t.rootSessionId=e.rootSessionId),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),e.sandboxState!==void 0&&(t.sandboxState=e.sandboxState),e.state!==void 0&&(t.state=e.state),t}function hydrateDurableSession(e){let{durable:t,turnAgent:n}=e,r=createSessionToolDefinitions(n),i={agent:createSessionAgent(n,t.agent.system,r),compaction:createCompactionConfig({contextWindowTokens:n.model?.contextWindowTokens,lastKnownInputTokens:t.compaction?.lastKnownInputTokens,lastKnownPromptMessageCount:t.compaction?.lastKnownPromptMessageCount,thresholdPercent:e.compactionOverrides?.thresholdPercent}),continuationToken:t.continuationToken,sessionId:t.sessionId};return t.rootSessionId!==void 0&&(i.rootSessionId=t.rootSessionId),t.outputSchema!==void 0&&(i.outputSchema=t.outputSchema),t.sandboxState!==void 0&&(i.sandboxState=t.sandboxState),t.state!==void 0&&(i.state=t.state),i}function createSessionToolDefinitions(e){return e.tools.map(e=>({description:e.description??``,inputSchema:e.inputSchema,name:e.name,outputSchema:e.outputSchema}))}export{createCompactionConfig,createSession,hydrateDurableSession,mintSubagentContinuationToken,projectToDurableSession,refreshSessionFromTurnAgent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{currentProjection}from"#harness/session-machine/current.js";import{runtimeWait,storedProjection}from"#harness/session-machine/view.js";import{getTurnUsageState,takeSessionUsageDelta}from"#harness/turn-tag-state.js";import{removeBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{retireCancelledCandidates}from"#harness/hitl/index.js";import{publishFromSessionStep,restoreSessionStep}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{
|
|
1
|
+
import{currentProjection}from"#harness/session-machine/current.js";import{runtimeWait,storedProjection}from"#harness/session-machine/view.js";import{getTurnUsageState,takeSessionUsageDelta}from"#harness/turn-tag-state.js";import{removeBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{retireCancelledCandidates}from"#harness/hitl/index.js";import{publishFromSessionStep,restoreSessionStep}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{cancel}from"#harness/session-machine/transitions.js";import{applyTransition,sessionView}from"#harness/session-machine/commit.js";async function settleCancelledTurnStep(e){"use step";return await withSessionStateDelta(e,settleCancelledTurn)}async function settleCancelledTurn(e){let t={...await restoreSessionStep(e),history:e.history},n=t.durableSession.state,r=runtimeWait(n)?.event.turnId??storedProjection(n).activeTurnId??``,{published:i,result:a}=await publishFromSessionStep(t,{origin:`own`,publish:(e,n)=>applyTransition(n,cancel(sessionView(currentProjection(t.ctx),n.state)),e),updateSession(t,n){let i=removeBlockingWorkflowToolRuns(retireCancelledCandidates({...n,outputSchema:void 0}),r);if(!e.reportUsage||getTurnUsageState(n.state)===void 0)return{session:i};let a=takeSessionUsageDelta(i);return{result:a.delta,session:a.session}}});return a===void 0?i:{...i,usage:a}}export{settleCancelledTurn,settleCancelledTurnStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TASK_CANCEL_TOOL_NAME,TASK_WAIT_TOOL_NAME}from"#protocol/task-tools.js";import{createFrameworkUserMessage}from"#harness/messages.js";import{FINAL_REPLY_TASK_SYSTEM_BLOCK,TASKS_NOTE_LABEL,TASK_SYSTEM_BLOCK,renderModelOutputText,renderTaskResults,renderTasksNote}from"#execution/tasks/render.js";import{
|
|
1
|
+
import{TASK_CANCEL_TOOL_NAME,TASK_WAIT_TOOL_NAME}from"#protocol/task-tools.js";import{createFrameworkUserMessage}from"#harness/messages.js";import{FINAL_REPLY_TASK_SYSTEM_BLOCK,TASKS_NOTE_LABEL,TASK_SYSTEM_BLOCK,renderModelOutputText,renderTaskResults,renderTasksNote}from"#execution/tasks/render.js";import{entryPointOf,isAgentTool}from"#execution/tasks/tool-entry-point.js";import{createTask,idleTasks,readTaskTable,takeTaskResults,workingTasks,writeTaskTable}from"#execution/tasks/table.js";import{observeToolOutput}from"#tool-stubs/execute.js";import{splitTaskIdInput}from"#execution/tasks/task-id-input.js";import{taskCancelTool}from"#tools/provided/task-cancel.js";import{taskWaitTool}from"#tools/provided/task-wait.js";function isTaskTool(e){return e?.frameworkAction===`task-wait`||e?.frameworkAction===`task-cancel`}function isWorkflowTool(e){return e?.workflowId!==void 0||isTaskTool(e)}function withTaskTools(e){return new Map([...e,[TASK_WAIT_TOOL_NAME,taskWaitTool],[TASK_CANCEL_TOOL_NAME,taskCancelTool]])}function taskSystemMessages(e,t){return e?[{content:t.finalReplyOnly?FINAL_REPLY_TASK_SYSTEM_BLOCK:TASK_SYSTEM_BLOCK,role:`system`}]:[]}function commitCallEntry(e,t){let n=entryPointOf(t.definition);switch(n){case`execute`:return{entry:{entryPoint:n},input:t.input,session:e};case`task`:return commitTask(e,t,n,t.input);case`serve`:{let{input:r,taskId:i}=splitTaskIdInput(t.input);return i===void 0?commitTask(e,t,n,r):{entry:{entryPoint:`receive`,taskId:i},input:r,session:e}}}}function commitTask(e,t,n,r){let i=createTask(readTaskTable(e.state),{callId:t.callId,kind:isAgentTool(t.definition)?`agent`:`tool`,name:t.toolName,resumable:n===`serve`,turnId:t.turnId});return{entry:{entryPoint:n,taskId:i.taskId},input:r,session:writeTaskTable(e,i.table)}}function workingTaskIds(e){return workingTasks(readTaskTable(e.state)).map(e=>e.id)}async function appendTaskContext(e){let t=[],n=await deliverTaskResults(e);n.message!==void 0&&t.push(createFrameworkUserMessage(`task.result`,n.message));let r=resolveTasksNote({messages:e.projectHistory([...e.messages,...t],n.session.state),session:n.session});return r!==void 0&&t.push(createFrameworkUserMessage(`context.state`,r)),{messages:t,session:n.session}}async function deliverTaskResults(e){let{table:t,taken:n}=takeTaskResults(readTaskTable(e.session.state));if(n.length===0)return{session:e.session};let r=[];for(let t of n)for(let n of t.results)r.push(await toResultBlock(t,n,e.tools.get(t.name)));return{message:renderTaskResults(r),session:writeTaskTable(e.session,t)}}async function toResultBlock(e,t,n){let r={taskId:e.id,tool:e.name};return t.status===`failed`?{...r,body:t.error,status:`failed`}:{...r,body:await projectOutput(e.name,t,n),status:`completed`}}async function projectOutput(e,t,n){return n?.toModelOutput===void 0?renderModelOutputText(t.output):await observeToolOutput(e,t.calls??[],async()=>renderModelOutputText(await n.toModelOutput(t.output)),()=>renderModelOutputText(t.output))}function resolveTasksNote(e){let t=readTaskTable(e.session.state),n=workingTasks(t).map(toListedTask),r=idleTasks(t).map(toListedTask),i=e.messages.findLast(isTasksNote);if(i===void 0&&n.length===0&&r.length===0)return;let a=renderTasksNote({idle:r,working:n});return i?.content===a?void 0:a}function toListedTask(e){return{id:e.id,tool:e.name}}function isTasksNote(e){return e.role===`user`&&typeof e.content==`string`&&e.content.startsWith(TASKS_NOTE_LABEL)}export{appendTaskContext,commitCallEntry,isTaskTool,isWorkflowTool,taskSystemMessages,withTaskTools,workingTaskIds};
|
|
@@ -6,7 +6,7 @@ import type { RuntimeToolResultActionResult, RuntimeWorkflowTaskRequest, Workflo
|
|
|
6
6
|
type TaskDispatchInput = StartWorkflowTaskInput & {
|
|
7
7
|
readonly taskId: string;
|
|
8
8
|
};
|
|
9
|
-
/** The call's answer, and the task start the dispatch
|
|
9
|
+
/** The call's answer, and the task start the dispatch reports for it. */
|
|
10
10
|
interface TaskDispatchResult {
|
|
11
11
|
readonly result: RuntimeToolResultActionResult;
|
|
12
12
|
readonly session: HarnessSessionBase;
|
|
@@ -18,9 +18,9 @@ type TaskRunEntry = Extract<WorkflowToolRunEntry, {
|
|
|
18
18
|
}>;
|
|
19
19
|
/**
|
|
20
20
|
* Starts the run for a task its model step committed, once, and answers the
|
|
21
|
-
* call with its receipt and the `task.started`
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* call with its receipt and the `task.started` data the next step publishes.
|
|
22
|
+
* Runs inside the dispatch step, where the task's cap is enforced: past it,
|
|
23
|
+
* the record is dropped and the call fails.
|
|
24
24
|
*/
|
|
25
25
|
export declare function startTaskRun(input: StartWorkflowTaskInput & {
|
|
26
26
|
readonly entry: TaskRunEntry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{TOO_MANY_TASKS_CODE,UNKNOWN_TASK_CODE}from"#protocol/task-tools.js";import{renderTaskReceipt,renderTaskSentReceipt,renderTooManyTasksError,renderUnknownTaskError}from"#execution/tasks/render.js";import{MAX_WORKING_TASKS,findTask,isTaskAvailable,isTaskWorking,readTaskTable,recordTaskCall,recordTaskRun,removeTask,workingTasks,writeTaskTable}from"#execution/tasks/table.js";import{
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{TOO_MANY_TASKS_CODE,UNKNOWN_TASK_CODE}from"#protocol/task-tools.js";import{renderTaskReceipt,renderTaskSentReceipt,renderTooManyTasksError,renderUnknownTaskError}from"#execution/tasks/render.js";import{startFailureResult,startWorkflowToolCallRun}from"#execution/tools/workflow/start.js";import{MAX_WORKING_TASKS,findTask,isTaskAvailable,isTaskWorking,readTaskTable,recordTaskCall,recordTaskRun,removeTask,workingTasks,writeTaskTable}from"#execution/tasks/table.js";import{sendTaskRunCommands}from"#execution/tasks/steps.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.tasks`);async function startTaskRun(e){let{entry:t,session:n,task:r}=e,{taskId:i}=t,a={...e,taskId:i},o=startReceipt(a,t.entryPoint===`serve`),s=readTaskTable(n.state),c=startableTask(s,i);if(c===void 0)return{result:o,session:n};let l=tooManyTasks(a,s);if(l!==void 0)return{result:l,session:writeTaskTable(n,removeTask(s,i))};let u;try{u=await startWorkflowToolCallRun(e,t)}catch(e){return logError(log,`task run failed to start`,e,{taskId:i,toolName:r.toolName}),{result:startFailureResult(r,e),session:writeTaskTable(n,removeTask(s,i))}}return{result:o,session:writeTaskTable(n,recordTaskRun(s,i,u)),started:taskStartedEvent(a,c)}}async function sendToTask(e){let{session:t,task:n,taskId:r}=e,i=readTaskTable(t.state),a=findTask(i,r);if(!isTaskAvailable(a,n.toolName))return{result:unknownTaskResult(e),session:t};if(!isTaskWorking(a)){let n=tooManyTasks(e,i);if(n!==void 0)return{result:n,session:t}}let o=recordTaskCall(i,r,{agentContext:e.agentContext,auth:e.auth,callId:n.callId,executeInput:n.executeInput,input:n.input,sequence:e.batchEvent.sequence,stepIndex:e.batchEvent.stepIndex,turnId:e.batchEvent.turnId});return o.send!==void 0&&await sendTaskRunCommands(o.send),{result:toolResult(e,renderTaskSentReceipt(r)),session:writeTaskTable(t,o.table),started:taskStartedEvent(e,a)}}function runEntryToStart(e,t){let{entry:n}=t;switch(n.entryPoint){case`execute`:return{entryPoint:`execute`};case`task`:case`serve`:return startableTask(e,n.taskId)===void 0?void 0:n;case`receive`:return}}function startableTask(e,t){let n=findTask(e,t);return n!==void 0&&isTaskWorking(n)?n:void 0}function startsEveryRun(e,t){return!t.some(e=>e.entry.entryPoint===`receive`)&&hasTaskSlots(e,t.filter(t=>t.entry.entryPoint!==`execute`&&runEntryToStart(e,t)!==void 0).length)}function runningTasks(e){return workingTasks(e).filter(e=>e.run!==void 0)}function hasTaskSlots(e,t){return runningTasks(e).length+t<=MAX_WORKING_TASKS}function tooManyTasks(e,t){if(hasTaskSlots(t,1))return;let n=runningTasks(t).map(e=>e.id);return createRuntimeToolResultFromValue({callId:e.task.callId,isError:!0,output:{code:TOO_MANY_TASKS_CODE,message:renderTooManyTasksError(MAX_WORKING_TASKS,n)},toolName:e.task.toolName})}function unknownTaskResult(e){return createRuntimeToolResultFromValue({callId:e.task.callId,isError:!0,output:{code:UNKNOWN_TASK_CODE,message:renderUnknownTaskError(e.taskId,e.task.toolName)},toolName:e.task.toolName})}function taskStartedEvent(e,t){return{callId:e.task.callId,kind:t.kind,name:e.task.toolName,taskId:e.taskId,turnId:e.batchEvent.turnId}}function startReceipt(e,t){return toolResult(e,renderTaskReceipt({id:e.taskId,resumable:t,tool:e.task.toolName}))}function toolResult(e,t){return createRuntimeToolResultFromValue({callId:e.task.callId,output:t,toolName:e.task.toolName})}export{runEntryToStart,sendToTask,startTaskRun,startsEveryRun};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resumeHook}from"#internal/workflow/runtime.js";import{
|
|
1
|
+
import{resumeHook}from"#internal/workflow/runtime.js";import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{readHitlState}from"#harness/hitl/index.js";import{commitSessionStep}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{cancelTask,findTask,finishTaskRun,markTaskRunStarted,readTaskTable,recordTaskRunUsage,settleRemainingTaskCalls,settleTaskCalls,writeTaskTable}from"#execution/tasks/table.js";import{finishRun,settleTask}from"#harness/session-machine/transitions.js";import{countRunUsage}from"#execution/agent-sessions/usage.js";import{workflowToolRunFailureOutput}from"#execution/tools/workflow/owner-inbox.js";import{ignoreGoneTarget}from"#execution/tasks/workflow-target.js";async function applyTaskRunMessage(e){let{message:t}=e,n=t.from.taskId,r=readDurableSession(e.sessionState);if(n===void 0)return{serializedContext:e.serializedContext,sessionState:e.sessionState};let i=readTaskTable(r.state),a=[],o=[];switch(t.kind){case`started`:{let e=markTaskRunStarted(i,n,t.from.runId);i=e.table,e.held!==void 0&&await sendTaskRunCommands(e.held);break}case`reply`:{({session:r,table:i}=countTaskRunUsage(r,i,n,t));let e={output:t.output,status:`completed`},o=findTask(i,n),s=settleTaskCalls(i,{callIds:t.callIds,outcome:e,taskId:n});i=s.table,a.push(...taskSettled(o,s.settled,e));break}case`usage`:({session:r,table:i}=countTaskRunUsage(r,i,n,t));break;case`outcome`:{({session:r,table:i}=countTaskRunUsage(r,i,n,t));let e=toOutcome(t),s=findTask(i,n),c=settleRemainingTaskCalls(i,n,e);a.push(...taskSettled(s,c.settled,e)),i=finishTaskRun(c.table,n,t.from.runId);let l=runRequestIds(r,t.from.runId);o.push(e=>finishRun(e,{requestIds:l,taskId:n}));break}}return await commitTaskDecisions(e,saveTable(e.sessionState,r,i),{settles:a,withdraws:o})}async function cancelTasksStep(e){"use step";return await withSessionStateDelta(e,cancelTasks)}async function cancelTasks(e){let t=readDurableSession(e.sessionState),n=readTaskTable(t.state),r=[],i=[],a={reason:e.reason,status:`cancelled`};for(let o of e.taskIds){let e=findTask(n,o),s=cancelTask(n,o);if(n=s.table,r.push(...taskSettled(e,s.settled,a)),s.send!==void 0){if(e?.resumable===!1){let e=runRequestIds(t,s.send.run.runId);i.push(t=>finishRun(t,{requestIds:e,taskId:o}))}await sendTaskRunCommands(s.send)}}return await commitTaskDecisions(e,saveTable(e.sessionState,t,n),{settles:r,withdraws:i})}async function commitTaskDecisions(e,t,n){let r=await commitSessionStep({...e,sessionState:t},e=>n.withdraws.map(t=>t(e)),{origin:`relayed`});return await commitSessionStep({...e,...r},e=>n.settles.map(t=>t(e)),{origin:`own`})}function taskSettled(e,t,n){return e===void 0?[]:[r=>settleTask(r,{calls:t,outcome:n,task:e})]}async function sendTaskRunCommands(e){for(let t of e.commands)await ignoreGoneTarget(resumeHook(e.run.hookToken,toControlMessage(t)))}function toControlMessage(e){switch(e.kind){case`cancel`:return{kind:`cancel`,reason:`The task was cancelled.`};case`call`:return{call:e.call,kind:`call`}}}function toOutcome(e){switch(e.result.status){case`completed`:return{output:e.result.output,status:`completed`};case`failed`:return{error:failureMessage(e),status:`failed`};case`cancelled`:return{status:`cancelled`}}}function failureMessage(e){let t=workflowToolRunFailureOutput(e);if(typeof t==`string`)return t;let n=typeof t==`object`&&t?Reflect.get(t,`message`):void 0;return typeof n==`string`?n:JSON.stringify(t)}function countTaskRunUsage(e,t,n,r){let i=findTask(t,n)?.run;return r.usage===void 0||i?.runId!==r.from.runId?{session:e,table:t}:{session:countRunUsage(e,r.usage,i.usage),table:recordTaskRunUsage(t,n,r.usage)}}function runRequestIds(e,t){return[...readHitlState(e.state).relays].filter(([,e])=>e.runId===t).map(([e])=>e)}function saveTable(e,t,n){return replaceDurableSessionSnapshot({session:writeTaskTable(t,n),state:e})}export{applyTaskRunMessage,cancelTasksStep,sendTaskRunCommands};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{readDurableSession}from"#execution/durable-session-store.js";import{cancelWorkflowToolRun}from"#execution/tools/workflow/cancel.js";import{liveTaskRuns,readTaskTable}from"#execution/tasks/table.js";const log=createLogger(`execution.terminate-child-sessions`);async function terminateChildSessionsStep(e){"use step";let t;try{t=readDurableSession(e.sessionState)}catch(t){logError(log,`failed to read child sessions for termination`,t,{parentSessionId:e.sessionState.sessionId});return}await stopTaskRuns(t)}async function stopTaskRuns(e){let t=liveTaskRuns(readTaskTable(e.state));await Promise.all(t.map(e=>cancelWorkflowToolRun(e,{kind:`end`,reason:`The session ended.`})))}export{terminateChildSessionsStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{decide}from"#ai/decide.js";async function runAgentRouterTask(e,t){"use workflow";let n=await chooseTarget(e.message,descriptions(t),t.abortSignal),{message:r,status:i}=await(await t.agent(n).send(e.message,{signal:t.abortSignal})).result();if(i===`failed`)throw Error(`Agent "${n}" failed to handle the task.`);return r??null}async function chooseTarget(e,t,n){"use step";let r=Object.keys(t);if(r.length===0)throw Error(`agentRouter requires at least one available agent with a description.`);return r.length===1?r[0]:(await decide({abortSignal:n,state:{message:e},questions:{route:{type:`choice`,instructions:`Which subagent should handle this task?`,criteria:t}}})).answers.route.choice}function descriptions(e){return Object.fromEntries(Object.entries(e.agents).flatMap(([e,t])=>{let n=t.description.trim();return n.length===0?[]:[[e,n]]}))}runAgentRouterTask.workflowId=`workflow//eve@0.
|
|
1
|
+
import{decide}from"#ai/decide.js";async function runAgentRouterTask(e,t){"use workflow";let n=await chooseTarget(e.message,descriptions(t),t.abortSignal),{message:r,status:i}=await(await t.agent(n).send(e.message,{signal:t.abortSignal})).result();if(i===`failed`)throw Error(`Agent "${n}" failed to handle the task.`);return r??null}async function chooseTarget(e,t,n){"use step";let r=Object.keys(t);if(r.length===0)throw Error(`agentRouter requires at least one available agent with a description.`);return r.length===1?r[0]:(await decide({abortSignal:n,state:{message:e},questions:{route:{type:`choice`,instructions:`Which subagent should handle this task?`,criteria:t}}})).answers.route.choice}function descriptions(e){return Object.fromEntries(Object.entries(e.agents).flatMap(([e,t])=>{let n=t.description.trim();return n.length===0?[]:[[e,n]]}))}runAgentRouterTask.workflowId=`workflow//eve@0.82.0//runAgentRouterTask`;export{runAgentRouterTask};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SessionContext } from "#context/session-context.js";
|
|
2
2
|
import type { AgentSessionContext } from "#execution/agent-sessions/context.js";
|
|
3
3
|
import { type RunUsageTally } from "#execution/agent-sessions/usage.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { WorkflowSharedContext } from "#tools/workflow-definition.js";
|
|
5
5
|
import { WorkflowToolRunAsks } from "#execution/tools/workflow/ask.js";
|
|
6
6
|
import type { WorkflowBodyCommand, WorkflowToolRunOutcome, WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
|
|
7
7
|
import type { WorkflowToolRunInbox } from "#execution/tools/workflow/owner.js";
|
|
@@ -74,7 +74,7 @@ export declare function resolveWorkflowEntryPoint<TEntryPoint>(input: WorkflowBo
|
|
|
74
74
|
* `session` (whose turn is the call's), come from the entry point, which
|
|
75
75
|
* knows its calls.
|
|
76
76
|
*/
|
|
77
|
-
export declare function createSharedContext(input: WorkflowBodyInput, agent:
|
|
77
|
+
export declare function createSharedContext(input: WorkflowBodyInput, agent: WorkflowSharedContext["agent"], askPerson: WorkflowSharedContext["ask"]): Omit<ToolContext & WorkflowSharedContext, "abortSignal" | "agents" | "callId" | "messages" | "session">;
|
|
78
78
|
/** `ctx.agents` for a call: the agents its context lists, frozen. */
|
|
79
79
|
export declare function createAgentsView(context: AgentSessionContext): WorkflowSharedContext["agents"];
|
|
80
80
|
export declare class WorkflowToolRunCancelledError extends Error {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { DispatchSessionInput, Runtime, SessionCommand, SessionCommandResult } from "#channel/types.js";
|
|
2
2
|
import { type Run, type StartOptionsWithoutDeploymentId, type WorkflowFunction, type WorkflowMetadata } from "#internal/workflow/runtime.js";
|
|
3
3
|
import type { RuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
|
|
4
|
-
import {
|
|
5
|
-
import type { SessionCheckpoint } from "#execution/session/handoff.js";
|
|
4
|
+
import type { AgentSessionRuntimeOverrides } from "#execution/agent-sessions/runtime-overrides.js";
|
|
6
5
|
import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js";
|
|
7
6
|
interface WorkflowHookRecord {
|
|
8
7
|
readonly runId: string;
|
|
@@ -35,19 +34,11 @@ export declare const connectionEventDeliveryWorkflowReference: {
|
|
|
35
34
|
* whose original run retains the public event stream across owner handoffs.
|
|
36
35
|
*/
|
|
37
36
|
export declare function createWorkflowRuntime(config: {
|
|
37
|
+
readonly agentSessionRuntimeOverrides?: AgentSessionRuntimeOverrides;
|
|
38
38
|
readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
|
|
39
39
|
readonly dynamicSubagentAgentConfig?: DynamicSubagentAgentConfig;
|
|
40
40
|
readonly nodeId?: string;
|
|
41
41
|
}): Runtime;
|
|
42
|
-
export type SessionOwnerStartInput = SessionHandoffStart & {
|
|
43
|
-
readonly activationToken: string;
|
|
44
|
-
/** Original run whose stream stays the public session stream. */
|
|
45
|
-
readonly anchorRunId: string;
|
|
46
|
-
readonly checkpoint: SessionCheckpoint;
|
|
47
|
-
readonly targetDeploymentId: string;
|
|
48
|
-
};
|
|
49
|
-
/** Starts a successor owner and binds its output to the original session stream. */
|
|
50
|
-
export declare function startSessionOwnerStep(input: SessionOwnerStartInput): Promise<void>;
|
|
51
42
|
/**
|
|
52
43
|
* Sends one command to a session through its stable command inbox. A caller
|
|
53
44
|
* holding the session id asked for that exact session, so a send to a
|
|
@@ -55,7 +46,9 @@ export declare function startSessionOwnerStep(input: SessionOwnerStartInput): Pr
|
|
|
55
46
|
*/
|
|
56
47
|
export declare function dispatchWorkflowSessionCommand<TCommand extends SessionCommand>(input: DispatchSessionInput<TCommand>): Promise<SessionCommandResult<TCommand>>;
|
|
57
48
|
/** The session holding a continuation token's inbox, if any does. */
|
|
58
|
-
export declare function resolveContinuation(continuationToken: string
|
|
49
|
+
export declare function resolveContinuation(continuationToken: string, options?: {
|
|
50
|
+
readonly runnable?: boolean;
|
|
51
|
+
}): Promise<{
|
|
59
52
|
sessionId: string;
|
|
60
53
|
} | undefined>;
|
|
61
54
|
/**
|
|
@@ -79,4 +72,10 @@ export declare function pollUntil<T>(check: () => Promise<T | undefined>, timeou
|
|
|
79
72
|
export declare function hasRunEnded(runId: string): Promise<boolean>;
|
|
80
73
|
/** Starts a workflow on the deployment executing this call. */
|
|
81
74
|
export declare function startWorkflowOnCurrentDeployment<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, options?: StartOptionsWithoutDeploymentId): Promise<Run<unknown> | Run<TResult>>;
|
|
75
|
+
/**
|
|
76
|
+
* Starts a run on an exact deployment. Every run eve starts records the eve
|
|
77
|
+
* version that started it: ingress and the stranded replay guard read it to
|
|
78
|
+
* decide whether this build can still execute the run.
|
|
79
|
+
*/
|
|
80
|
+
export declare function startWorkflowOnDeployment<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, deploymentId: string, options?: StartOptionsWithoutDeploymentId): Promise<Run<unknown> | Run<TResult>>;
|
|
82
81
|
export {};
|