eve 0.50.0 → 0.51.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 +18 -0
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/channel/types.d.ts +12 -19
- package/dist/src/chunks/{use-eve-agent-DUMU6dap.js → use-eve-agent-B4xN7-fK.js} +4 -4
- package/dist/src/chunks/{use-eve-agent-B5I-k6Ek.js → use-eve-agent-C3vUG5g2.js} +4 -4
- package/dist/src/cli/acp/command.d.ts +1 -1
- package/dist/src/cli/acp/command.js +2 -2
- package/dist/src/cli/agent-command.d.ts +5 -0
- package/dist/src/cli/agent-command.js +1 -0
- package/dist/src/cli/application-command.d.ts +2 -0
- package/dist/src/cli/commands/build.d.ts +1 -1
- package/dist/src/cli/commands/build.js +1 -1
- package/dist/src/cli/commands/deploy.d.ts +2 -0
- package/dist/src/cli/commands/deploy.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.d.ts +14 -0
- package/dist/src/cli/commands/init-agent-workspace.js +1 -0
- package/dist/src/cli/commands/init-repl.js +1 -1
- package/dist/src/cli/commands/init.d.ts +2 -13
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/integration-connect.js +1 -1
- package/dist/src/cli/commands/link.d.ts +2 -0
- package/dist/src/cli/commands/link.js +1 -1
- package/dist/src/cli/commands/preconditions.d.ts +15 -0
- package/dist/src/cli/commands/preconditions.js +1 -1
- package/dist/src/cli/commands/register-integration-commands.d.ts +1 -1
- package/dist/src/cli/commands/register-integration-commands.js +1 -1
- package/dist/src/cli/commands/register-registry-commands.js +2 -2
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/environment.d.ts +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/local-server-process.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/invoke/command.d.ts +1 -1
- package/dist/src/cli/invoke/command.js +1 -1
- package/dist/src/cli/option-parsers.d.ts +1 -0
- package/dist/src/cli/option-parsers.js +1 -1
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/agent-info-schema.d.ts +0 -1
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/message-action-parts.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +1 -0
- package/dist/src/context/keys.d.ts +0 -3
- package/dist/src/context/keys.js +1 -1
- package/dist/src/discover/project.js +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/evals/mock-model.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/activity-work-id.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/channel-context.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +103 -0
- package/dist/src/execution/coordination-dispatch-shared.js +1 -0
- package/dist/src/execution/coordination-dispatch-step.d.ts +7 -0
- package/dist/src/execution/coordination-dispatch-step.js +1 -0
- package/dist/src/execution/create-session-step.d.ts +1 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/dispatch-action-failures.d.ts +5 -5
- package/dist/src/execution/dispatch-action-failures.js +1 -1
- package/dist/src/execution/dispatch-start-operation.d.ts +1 -1
- package/dist/src/execution/dispatch-start-operation.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +1 -1
- package/dist/src/execution/inline-turn.js +1 -1
- package/dist/src/execution/next-driver-action.d.ts +7 -10
- package/dist/src/execution/node-step.d.ts +1 -2
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/pending-turn-state.d.ts +1 -2
- package/dist/src/execution/pending-turn-state.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session-command-inbox.d.ts +2 -3
- package/dist/src/execution/session.d.ts +1 -1
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +1 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/task-event-callback.js +1 -1
- package/dist/src/execution/tasks/child/steps.d.ts +18 -18
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/update-step.d.ts +6 -0
- package/dist/src/execution/tasks/child/update-step.js +1 -0
- package/dist/src/execution/tasks/child/update.d.ts +7 -10
- package/dist/src/execution/tasks/child/update.js +1 -1
- package/dist/src/execution/tasks/child/workflow.d.ts +21 -29
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/control-shared.d.ts +6 -17
- package/dist/src/execution/tasks/parent/control-shared.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +15 -50
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +19 -34
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +5 -15
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/run-parent.d.ts +2 -2
- package/dist/src/execution/tasks/parent/task-cancel.d.ts +11 -0
- package/dist/src/execution/tasks/parent/task-cancel.js +1 -0
- package/dist/src/execution/tasks/parent/tool-execution.d.ts +2 -3
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/subagent/accept-event-step.d.ts +7 -0
- package/dist/src/execution/tools/subagent/accept-event-step.js +1 -0
- package/dist/src/execution/tools/subagent/emit-called-step.d.ts +9 -0
- package/dist/src/execution/tools/subagent/emit-called-step.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +51 -0
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +37 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +55 -0
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -0
- package/dist/src/execution/tools/subagent/receipt-identity.d.ts +11 -0
- package/dist/src/execution/tools/subagent/receipt-identity.js +1 -0
- package/dist/src/execution/{dispatch-runtime-actions-start.d.ts → tools/subagent/start.d.ts} +17 -5
- package/dist/src/execution/tools/subagent/start.js +1 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +24 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -0
- package/dist/src/execution/tools/subagent/task-cancel.d.ts +10 -0
- package/dist/src/execution/tools/subagent/task-cancel.js +1 -0
- package/dist/src/execution/tools/tasks.d.ts +10 -0
- package/dist/src/execution/tools/tasks.js +1 -0
- package/dist/src/execution/{tool-run → tools/workflow}/answer.d.ts +1 -1
- package/dist/src/execution/tools/workflow/answer.js +1 -0
- package/dist/src/execution/tools/workflow/ask.d.ts +22 -0
- package/dist/src/execution/tools/workflow/ask.js +1 -0
- package/dist/src/execution/tools/workflow/background.d.ts +18 -0
- package/dist/src/execution/tools/workflow/background.js +1 -0
- package/dist/src/execution/tools/workflow/body.d.ts +25 -0
- package/dist/src/execution/tools/workflow/body.js +1 -0
- package/dist/src/execution/tools/workflow/cancel.d.ts +11 -0
- package/dist/src/execution/tools/workflow/cancel.js +1 -0
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +7 -0
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -0
- package/dist/src/execution/tools/workflow/messages.d.ts +88 -0
- package/dist/src/execution/tools/workflow/messages.js +1 -0
- package/dist/src/execution/tools/workflow/owner-inbox.d.ts +13 -0
- package/dist/src/execution/tools/workflow/owner-inbox.js +1 -0
- package/dist/src/execution/tools/workflow/owner.d.ts +13 -0
- package/dist/src/execution/tools/workflow/owner.js +1 -0
- package/dist/src/execution/tools/workflow/run-control.d.ts +18 -0
- package/dist/src/execution/tools/workflow/run-control.js +1 -0
- package/dist/src/execution/tools/workflow/start.d.ts +33 -0
- package/dist/src/execution/tools/workflow/start.js +1 -0
- package/dist/src/execution/tools/workflow/types.d.ts +26 -0
- package/dist/src/execution/tools/workflow/types.js +1 -0
- package/dist/src/execution/tools/workflow/workflow.d.ts +3 -0
- package/dist/src/execution/tools/workflow/workflow.js +1 -0
- package/dist/src/execution/turn-workflow-tool-run.d.ts +16 -0
- package/dist/src/execution/turn-workflow-tool-run.js +1 -0
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
- package/dist/src/execution/wire/session-inbox-contract.js +1 -1
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +6 -2
- package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.d.ts +3 -3
- package/dist/src/execution/wire/session-inbox-wire.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v1.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v4.d.ts +267 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.d.ts +3 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.js +1 -0
- package/dist/src/execution/workflow-entry-finalization.d.ts +6 -0
- package/dist/src/execution/workflow-entry-finalization.js +1 -1
- package/dist/src/execution/workflow-entry.d.ts +2 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +1 -7
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/background-tools.d.ts +8 -2
- package/dist/src/harness/{runtime-actions.d.ts → coordination.d.ts} +40 -27
- package/dist/src/harness/coordination.js +1 -0
- package/dist/src/harness/emission.d.ts +9 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +52 -0
- package/dist/src/harness/hitl/session-limit-input-requests.js +1 -1
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +6 -2
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/step-hooks.d.ts +1 -2
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-call-action.js +1 -1
- package/dist/src/harness/tool-call-input-errors.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +3 -1
- package/dist/src/harness/types.d.ts +4 -7
- package/dist/src/harness/workflow-interrupt-state.js +1 -1
- package/dist/src/harness/workflow-lifecycle.d.ts +10 -0
- package/dist/src/harness/workflow-lifecycle.js +1 -1
- package/dist/src/harness/workflow-sandbox.d.ts +1 -1
- package/dist/src/harness/workflow-sandbox.js +2 -2
- package/dist/src/harness/workflow-subagent-limit.d.ts +7 -7
- package/dist/src/harness/workflow-subagent-limit.js +1 -1
- package/dist/src/harness/workflow-task-state.d.ts +9 -0
- package/dist/src/harness/workflow-task-state.js +1 -0
- package/dist/src/harness/workflow-tool-runs.d.ts +27 -0
- package/dist/src/harness/workflow-tool-runs.js +1 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/parent-lineage.js +1 -1
- package/dist/src/internal/agent-name.d.ts +4 -0
- package/dist/src/internal/agent-name.js +1 -0
- package/dist/src/internal/agent-workspace.d.ts +15 -0
- package/dist/src/internal/agent-workspace.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +1 -1
- package/dist/src/internal/nitro/host/start-production-server.js +3 -3
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/project-context.d.ts +26 -0
- package/dist/src/internal/project-context.js +1 -0
- package/dist/src/internal/vercel/assemble-eve-services.d.ts +17 -0
- package/dist/src/internal/vercel/assemble-eve-services.js +1 -0
- package/dist/src/internal/vercel/build-agent-workspace.d.ts +3 -0
- package/dist/src/internal/vercel/build-agent-workspace.js +1 -0
- package/dist/src/internal/vercel/build-command.d.ts +4 -0
- package/dist/src/internal/vercel/build-command.js +1 -0
- package/dist/src/internal/vercel/eve-service-contribution.d.ts +27 -0
- package/dist/src/internal/vercel/eve-service-contribution.js +1 -0
- package/dist/src/internal/vercel/vercel-service-config-operations.d.ts +18 -0
- package/dist/src/internal/vercel/vercel-service-config-operations.js +1 -0
- package/dist/src/internal/vercel/vercel-service-name.d.ts +6 -0
- package/dist/src/internal/vercel/vercel-service-name.js +1 -0
- package/dist/src/internal/vercel/vercel-services-config.d.ts +53 -0
- package/dist/src/internal/vercel/vercel-services-config.js +1 -0
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/protocol/message.d.ts +2 -0
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/memory/file/backends/vercel-blob.js +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/public/workflow/index.d.ts +3 -1
- package/dist/src/public/workflow/index.js +1 -1
- package/dist/src/runtime/actions/results.d.ts +3 -3
- package/dist/src/runtime/actions/results.js +1 -1
- package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
- package/dist/src/runtime/agent/bootstrap.d.ts +1 -0
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/channels/registry.js +1 -1
- package/dist/src/runtime/prompt/compose.d.ts +0 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +16 -1
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/subagents/workflow-reference.d.ts +5 -0
- package/dist/src/runtime/subagents/workflow-reference.js +1 -0
- package/dist/src/runtime/subagents/workflow.d.ts +8 -0
- package/dist/src/runtime/subagents/workflow.js +1 -0
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/setup/integrations/discord/setup.js +1 -1
- package/dist/src/setup/integrations/file-memory/vercel.js +1 -1
- package/dist/src/setup/integrations/linear/setup.js +1 -1
- package/dist/src/setup/integrations/linq/setup.js +3 -3
- package/dist/src/setup/integrations/shopify/setup.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/update/channels.d.ts +4 -12
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/shared/action-types.d.ts +74 -14
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/json.js +1 -1
- package/dist/src/shared/workflow-sandbox.d.ts +1 -1
- package/dist/src/{execution/subagent-adapter-state.d.ts → subagents/adapter-state.d.ts} +2 -0
- package/dist/src/{execution/subagent-adapter-state.js → subagents/adapter-state.js} +1 -1
- package/dist/src/subagents/adapter.js +1 -0
- package/dist/src/{harness → subagents}/agent-handle-errors.d.ts +6 -0
- package/dist/src/subagents/agent-handle-errors.js +1 -0
- package/dist/src/subagents/callback-route.js +1 -0
- package/dist/src/subagents/callback-step.js +1 -0
- package/dist/src/{execution/agent-continuation-bundle.d.ts → subagents/continuation-bundle.d.ts} +1 -1
- package/dist/src/subagents/continuation-bundle.js +1 -0
- package/dist/src/{execution/subagent-event-proxy-step.d.ts → subagents/event-proxy-step.d.ts} +2 -8
- package/dist/src/subagents/event-proxy-step.js +1 -0
- package/dist/src/subagents/handle-dispatch.d.ts +54 -0
- package/dist/src/subagents/handle-dispatch.js +1 -0
- package/dist/src/{harness → subagents}/handles/prompt.d.ts +4 -4
- package/dist/src/{harness → subagents}/handles/prompt.js +1 -1
- package/dist/src/{harness → subagents}/handles/query.d.ts +8 -2
- package/dist/src/subagents/handles/query.js +1 -0
- package/dist/src/subagents/handles/rebase.d.ts +4 -0
- package/dist/src/subagents/handles/rebase.js +1 -0
- package/dist/src/{harness → subagents}/handles/store.d.ts +90 -15
- package/dist/src/subagents/handles/store.js +1 -0
- package/dist/src/subagents/handles/transitions.d.ts +103 -0
- package/dist/src/subagents/handles/transitions.js +1 -0
- package/dist/src/{execution/delegated-parent-notification.d.ts → subagents/parent-notification.d.ts} +1 -7
- package/dist/src/subagents/parent-notification.js +1 -0
- package/dist/src/subagents/parent-result.js +1 -0
- package/dist/src/{execution/remote-agent-dispatch.d.ts → subagents/remote-dispatch.d.ts} +3 -2
- package/dist/src/subagents/remote-dispatch.js +1 -0
- package/dist/src/{execution/subagent-start-local.d.ts → subagents/start-local.d.ts} +5 -6
- package/dist/src/subagents/start-local.js +1 -0
- package/dist/src/{execution/subagent-start-remote.d.ts → subagents/start-remote.d.ts} +5 -5
- package/dist/src/subagents/start-remote.js +1 -0
- package/dist/src/{execution/subagent-tool.d.ts → subagents/tool.d.ts} +5 -3
- package/dist/src/subagents/tool.js +1 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/json.js +1 -1
- package/dist/src/tasks/session-index.d.ts +2 -3
- package/dist/src/tasks/session-index.js +1 -1
- package/dist/src/tasks/task-id.d.ts +3 -4
- package/dist/src/tasks/task-id.js +1 -1
- package/dist/src/tasks/transitions.d.ts +3 -47
- package/dist/src/tasks/transitions.js +1 -1
- package/dist/src/tasks/types.d.ts +69 -247
- package/dist/src/tasks/types.js +1 -1
- package/dist/src/tools/dynamic.d.ts +3 -1
- package/dist/src/tools/framework/agent.d.ts +18 -2
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/framework/task-cancel.d.ts +2 -6
- package/dist/src/tools/framework/task-contract.d.ts +44 -65
- package/dist/src/tools/framework/task-contract.js +1 -1
- package/dist/src/tools/framework/task-update.d.ts +1 -0
- package/dist/src/tools/framework/task-update.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/concepts/built-in-tools.md +9 -90
- package/docs/concepts/context-control.md +2 -2
- package/docs/concepts/execution-model-and-durability.mdx +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +3 -3
- package/docs/guides/deployment/vercel.mdx +20 -2
- package/docs/guides/dynamic-capabilities.md +2 -2
- package/docs/guides/frontend/overview.mdx +1 -1
- package/docs/guides/instrumentation-providers.md +242 -0
- package/docs/guides/instrumentation.md +2 -0
- package/docs/guides/meta.json +1 -0
- package/docs/guides/remote-agents.md +8 -9
- package/docs/reference/cli.md +5 -2
- package/docs/sandbox.mdx +2 -0
- package/docs/subagents/index.mdx +9 -8
- package/docs/tools/overview.mdx +11 -10
- package/docs/tools/workflows.mdx +52 -18
- package/package.json +1 -1
- package/dist/src/execution/agent-continuation-bundle.js +0 -1
- package/dist/src/execution/agent-handle-dispatch.d.ts +0 -79
- package/dist/src/execution/agent-handle-dispatch.js +0 -1
- package/dist/src/execution/delegated-parent-notification.js +0 -1
- package/dist/src/execution/delegated-parent-result.js +0 -1
- package/dist/src/execution/delegation-tool.d.ts +0 -10
- package/dist/src/execution/delegation-tool.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +0 -165
- package/dist/src/execution/dispatch-runtime-actions-shared.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-start.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-step.d.ts +0 -18
- package/dist/src/execution/dispatch-runtime-actions-step.js +0 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.d.ts +0 -18
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +0 -1
- package/dist/src/execution/finalize-terminal-session.d.ts +0 -17
- package/dist/src/execution/finalize-terminal-session.js +0 -1
- package/dist/src/execution/prepared-agent-action.d.ts +0 -7
- package/dist/src/execution/prepared-agent-action.js +0 -1
- package/dist/src/execution/remote-agent-dispatch.js +0 -1
- package/dist/src/execution/session-callback-route.js +0 -1
- package/dist/src/execution/session-callback-step.js +0 -1
- package/dist/src/execution/subagent-adapter.js +0 -1
- package/dist/src/execution/subagent-event-proxy-step.js +0 -1
- package/dist/src/execution/subagent-start-local.js +0 -1
- package/dist/src/execution/subagent-start-remote.js +0 -1
- package/dist/src/execution/subagent-tool.js +0 -1
- package/dist/src/execution/tasks/child/instructions.d.ts +0 -3
- package/dist/src/execution/tasks/child/instructions.js +0 -1
- package/dist/src/execution/tasks/parent/agent-identity.d.ts +0 -13
- package/dist/src/execution/tasks/parent/agent-identity.js +0 -1
- package/dist/src/execution/tasks/parent/agent-views.d.ts +0 -7
- package/dist/src/execution/tasks/parent/agent-views.js +0 -1
- package/dist/src/execution/tasks/parent/continuation-dispatch.d.ts +0 -43
- package/dist/src/execution/tasks/parent/continuation-dispatch.js +0 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +0 -19
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +0 -1
- package/dist/src/execution/tool-run/answer.js +0 -1
- package/dist/src/execution/tool-run/background.d.ts +0 -14
- package/dist/src/execution/tool-run/background.js +0 -1
- package/dist/src/execution/tool-run/cancel.d.ts +0 -7
- package/dist/src/execution/tool-run/cancel.js +0 -1
- package/dist/src/execution/tool-run/dispatch.d.ts +0 -24
- package/dist/src/execution/tool-run/dispatch.js +0 -1
- package/dist/src/execution/tool-run/emit-run-report-step.d.ts +0 -7
- package/dist/src/execution/tool-run/emit-run-report-step.js +0 -1
- package/dist/src/execution/tool-run/messages.d.ts +0 -70
- package/dist/src/execution/tool-run/messages.js +0 -1
- package/dist/src/execution/tool-run/owner-inbox.d.ts +0 -11
- package/dist/src/execution/tool-run/owner-inbox.js +0 -1
- package/dist/src/execution/tool-run/owner.d.ts +0 -13
- package/dist/src/execution/tool-run/owner.js +0 -1
- package/dist/src/execution/tool-run/run-control.d.ts +0 -18
- package/dist/src/execution/tool-run/run-control.js +0 -1
- package/dist/src/execution/tool-run/start.d.ts +0 -11
- package/dist/src/execution/tool-run/start.js +0 -1
- package/dist/src/execution/tool-run/types.d.ts +0 -21
- package/dist/src/execution/tool-run/types.js +0 -1
- package/dist/src/execution/tool-run/workflow.d.ts +0 -9
- package/dist/src/execution/tool-run/workflow.js +0 -1
- package/dist/src/execution/tools/subagent/local.d.ts +0 -40
- package/dist/src/execution/tools/subagent/local.js +0 -1
- package/dist/src/execution/tools/subagent/remote.d.ts +0 -26
- package/dist/src/execution/tools/subagent/remote.js +0 -1
- package/dist/src/harness/agent-handle-errors.js +0 -1
- package/dist/src/harness/handles/query.js +0 -1
- package/dist/src/harness/handles/store.js +0 -1
- package/dist/src/harness/handles/transitions.d.ts +0 -167
- package/dist/src/harness/handles/transitions.js +0 -1
- package/dist/src/harness/runtime-actions.js +0 -1
- package/dist/src/harness/subagent-depth.d.ts +0 -10
- package/dist/src/harness/subagent-depth.js +0 -1
- package/dist/src/harness/tool-runs.d.ts +0 -21
- package/dist/src/harness/tool-runs.js +0 -1
- package/dist/src/harness/workflow-runtime-action-state.d.ts +0 -9
- package/dist/src/harness/workflow-runtime-action-state.js +0 -1
- package/dist/src/runtime/actions/keys.d.ts +0 -14
- package/dist/src/runtime/actions/keys.js +0 -1
- package/dist/src/tasks/wire.d.ts +0 -25
- package/dist/src/tasks/wire.js +0 -1
- /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.d.ts +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.js +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.d.ts +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.js +0 -0
- /package/dist/src/{execution/subagent-adapter.d.ts → subagents/adapter.d.ts} +0 -0
- /package/dist/src/{execution/session-callback-route.d.ts → subagents/callback-route.d.ts} +0 -0
- /package/dist/src/{execution/session-callback-step.d.ts → subagents/callback-step.d.ts} +0 -0
- /package/dist/src/{harness → subagents}/handles/operation-id.d.ts +0 -0
- /package/dist/src/{harness → subagents}/handles/operation-id.js +0 -0
- /package/dist/src/{harness → subagents}/handles/state-key.d.ts +0 -0
- /package/dist/src/{harness → subagents}/handles/state-key.js +0 -0
- /package/dist/src/{execution/subagent-hitl-proxy.d.ts → subagents/hitl-proxy.d.ts} +0 -0
- /package/dist/src/{execution/subagent-hitl-proxy.js → subagents/hitl-proxy.js} +0 -0
- /package/dist/src/{execution/subagent-invocation.d.ts → subagents/invocation.d.ts} +0 -0
- /package/dist/src/{execution/subagent-invocation.js → subagents/invocation.js} +0 -0
- /package/dist/src/{execution/delegated-parent-result.d.ts → subagents/parent-result.d.ts} +0 -0
- /package/dist/src/{execution/remote-agent-route-url.d.ts → subagents/remote-route-url.d.ts} +0 -0
- /package/dist/src/{execution/remote-agent-route-url.js → subagents/remote-route-url.js} +0 -0
- /package/dist/src/{harness/subagent-token-budget.d.ts → subagents/token-budget.d.ts} +0 -0
- /package/dist/src/{harness/subagent-token-budget.js → subagents/token-budget.js} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** Shared owner-side dispatch context preparation. */
|
|
2
|
+
import type { ActivityObserverConfig } from "#channel/types.js";
|
|
3
|
+
import { type ChannelAdapter, type ChannelAdapterContext } from "#channel/adapter.js";
|
|
4
|
+
import { type LocalDevRequestProvenance } from "#context/keys.js";
|
|
5
|
+
import { ContextContainer } from "#context/container.js";
|
|
6
|
+
import { type CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
7
|
+
import type { RuntimeSession } from "#subagents/handle-dispatch.js";
|
|
8
|
+
import type { ActivityWorkIdentityV1 } from "#protocol/activity.js";
|
|
9
|
+
import type { RuntimeActionResult, RuntimeToolCallActionRequest, RuntimeWorkflowTaskRequest } from "#shared/action-types.js";
|
|
10
|
+
import type { SessionParent } from "#channel/types.js";
|
|
11
|
+
import { type DurableSessionState, readDurableSession } from "#execution/durable-session-store.js";
|
|
12
|
+
import { buildSubagentRunInput } from "#subagents/tool.js";
|
|
13
|
+
export type DispatchPlanEntry = {
|
|
14
|
+
readonly kind: "task-control";
|
|
15
|
+
readonly action: RuntimeToolCallActionRequest;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "workflow-task";
|
|
18
|
+
readonly task: RuntimeWorkflowTaskRequest;
|
|
19
|
+
};
|
|
20
|
+
/** Input shared by direct and Workflow-originated owner-side dispatch. */
|
|
21
|
+
export interface CoordinationDispatchInput {
|
|
22
|
+
readonly callbackBaseUrl?: string;
|
|
23
|
+
/** Internal hook that receives child completion and HITL payloads. */
|
|
24
|
+
readonly parentContinuationToken?: string;
|
|
25
|
+
readonly parentWritable: WritableStream<Uint8Array>;
|
|
26
|
+
readonly serializedContext: Record<string, unknown>;
|
|
27
|
+
readonly sessionState: DurableSessionState;
|
|
28
|
+
}
|
|
29
|
+
/** Owner-side results plus any task-control work that still needs acknowledgement. */
|
|
30
|
+
export interface CoordinationDispatchResult {
|
|
31
|
+
readonly results: readonly RuntimeActionResult[];
|
|
32
|
+
readonly sessionState: DurableSessionState;
|
|
33
|
+
readonly pendingTasks: readonly {
|
|
34
|
+
readonly taskInboxToken: string;
|
|
35
|
+
readonly taskId: string;
|
|
36
|
+
readonly taskRunId: string;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
/** Everything preflight produces before either step's dispatch loop runs. */
|
|
40
|
+
export interface PreparedCoordinationDispatch<PlanEntry = DispatchPlanEntry> {
|
|
41
|
+
readonly adapter: ChannelAdapter;
|
|
42
|
+
readonly adapterCtx: ChannelAdapterContext;
|
|
43
|
+
readonly auth: Parameters<typeof buildSubagentRunInput>[0]["auth"];
|
|
44
|
+
readonly batch: DispatchBatch;
|
|
45
|
+
readonly bundle: CompiledBundle;
|
|
46
|
+
readonly capabilities: Parameters<typeof buildSubagentRunInput>[0]["capabilities"];
|
|
47
|
+
readonly channelMetadata: Parameters<typeof buildSubagentRunInput>[0]["channelMetadata"];
|
|
48
|
+
/** Number of local children sharing the parent's remaining token quota. */
|
|
49
|
+
readonly fanoutSize: number;
|
|
50
|
+
readonly initiatorAuth: Parameters<typeof buildSubagentRunInput>[0]["initiatorAuth"];
|
|
51
|
+
readonly localDevRequest?: LocalDevRequestProvenance;
|
|
52
|
+
/** Lineage of the session running this dispatch, when it is itself a delegated child. */
|
|
53
|
+
readonly parentSession: SessionParent | undefined;
|
|
54
|
+
readonly parentTraceContext: Parameters<typeof buildSubagentRunInput>[0]["parentTraceContext"];
|
|
55
|
+
readonly activityObserver?: ActivityObserverConfig & {
|
|
56
|
+
readonly workIdentity: ActivityWorkIdentityV1;
|
|
57
|
+
};
|
|
58
|
+
readonly sandboxSessionId: string;
|
|
59
|
+
readonly serializedContext: Record<string, unknown>;
|
|
60
|
+
readonly plan: readonly PlanEntry[];
|
|
61
|
+
readonly session: RuntimeSession;
|
|
62
|
+
readonly sessionState: DurableSessionState;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Runs every dispatch precondition that may throw — durable reads, context
|
|
66
|
+
* deserialization, handle-store validation, and batch planning — before
|
|
67
|
+
* the caller acquires the parent stream writer, so a preflight failure
|
|
68
|
+
* never leaks the writer lock. Returns undefined when no actions are
|
|
69
|
+
* pending.
|
|
70
|
+
*/
|
|
71
|
+
export declare function prepareCoordinationDispatch(input: {
|
|
72
|
+
readonly serializedContext: Record<string, unknown>;
|
|
73
|
+
readonly sessionState: DurableSessionState;
|
|
74
|
+
}): Promise<PreparedCoordinationDispatch | undefined>;
|
|
75
|
+
interface DispatchBatch {
|
|
76
|
+
readonly event: {
|
|
77
|
+
readonly sequence: number;
|
|
78
|
+
readonly stepIndex: number;
|
|
79
|
+
readonly turnId: string;
|
|
80
|
+
};
|
|
81
|
+
readonly localFanoutSize?: number;
|
|
82
|
+
readonly requests: readonly {
|
|
83
|
+
readonly callId: string;
|
|
84
|
+
}[];
|
|
85
|
+
}
|
|
86
|
+
export declare function prepareActionDispatch<PlanEntry>(input: {
|
|
87
|
+
readonly batch: DispatchBatch;
|
|
88
|
+
readonly ctx: ContextContainer;
|
|
89
|
+
readonly durableSession: Awaited<ReturnType<typeof readDurableSession>>;
|
|
90
|
+
readonly fanoutSize?: number;
|
|
91
|
+
readonly plan: (input: {
|
|
92
|
+
readonly bundle: CompiledBundle;
|
|
93
|
+
readonly ctx: ContextContainer;
|
|
94
|
+
readonly requests: DispatchBatch["requests"];
|
|
95
|
+
readonly session: RuntimeSession;
|
|
96
|
+
}) => readonly PlanEntry[];
|
|
97
|
+
readonly planSharesSandbox?: (input: {
|
|
98
|
+
readonly bundle: CompiledBundle;
|
|
99
|
+
readonly plan: readonly PlanEntry[];
|
|
100
|
+
}) => boolean;
|
|
101
|
+
readonly serializedContext: Record<string, unknown>;
|
|
102
|
+
}): Promise<Omit<PreparedCoordinationDispatch<PlanEntry>, "sessionState">>;
|
|
103
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"#channel/adapter.js";import"#context/container.js";import{ActivityObserverKey,AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey,LocalDevRequestKey,ParentSessionKey,SandboxKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deriveRootTurnActivityWorkId}from"#execution/activity-work-id.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{withContextScope}from"#context/run-step.js";import{assertUniqueCoordinationCallIds,getPendingCoordinationBatch,setPendingCoordinationBatch}from"#harness/coordination.js";import{activeTurnId}from"#harness/active-turn-id.js";import{hydrateDurableSession}from"#execution/session.js";import"#subagents/tool.js";import{readSessionTraceContext}from"#tracing/agent-trace-context-store.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{isTaskControlAction}from"#execution/tasks/parent/dispatch.js";async function prepareCoordinationDispatch(e){let t=await readDurableSession(e.sessionState),n=getPendingCoordinationBatch(t.state);if(n===void 0)return;let r=[...n.runtimeActions,...n.tasks];if(r.length===0)return;let i=n.event.turnId||activeTurnId(e.sessionState.emissionState),a=n.event.turnId===i?n.event:{...n.event,turnId:i},o=await deserializeContext(e.serializedContext),s=await prepareActionDispatch({batch:{event:a,localFanoutSize:n.localFanoutSize,requests:r},ctx:o,durableSession:t,plan:()=>planDispatch({requests:r}),serializedContext:e.serializedContext});if(a===n.event)return{...s,sessionState:e.sessionState};let c=setPendingCoordinationBatch({...n,event:a,session:s.session});return{...s,session:c,sessionState:createDurableSessionState({session:c})}}async function prepareActionDispatch(l){let{batch:u,durableSession:d}=l;assertUniqueCoordinationCallIds(u.requests);let f=l.ctx,p=f.require(BundleKey),m=resolveEffectiveAgentRuntime(p,f),h=hydrateDurableSession({compactionOverrides:{thresholdPercent:m.thresholdPercent},durable:d,turnAgent:m.turnAgent}),g=f.require(ChannelKey);getAgentHandleStore(d.state);let _=l.plan({bundle:p,ctx:f,requests:u.requests,session:h}),v=resolveActiveSandboxSessionId(g.state,h.sessionId);if(l.planSharesSandbox?.({bundle:p,plan:_})===!0)try{h=(await withContextScope(f,h,async e=>(await f.require(SandboxKey).get(),{result:void 0,session:e}))).session}finally{f.clearVirtualContext()}return{adapter:g,adapterCtx:buildAdapterContext(g,f),auth:f.get(AuthKey)??null,batch:u,bundle:p,capabilities:f.get(CapabilitiesKey),channelMetadata:f.get(ChannelInstrumentationKey),fanoutSize:l.fanoutSize??u.localFanoutSize??0,initiatorAuth:f.get(InitiatorAuthKey)??null,localDevRequest:f.get(LocalDevRequestKey),parentSession:f.get(ParentSessionKey),parentTraceContext:readSessionTraceContext(l.serializedContext,h.sessionId),plan:_,activityObserver:resolvePreparedActivity(f.get(ActivityObserverKey),h,u.event.turnId),sandboxSessionId:v,serializedContext:l.serializedContext,session:h}}function resolvePreparedActivity(e,t,n){if(e!==void 0)return{sink:e.sink,workIdentity:e.workIdentity??{id:deriveRootTurnActivityWorkId({sessionId:t.sessionId,turnId:n}),kind:`root-turn`,rootSessionId:t.rootSessionId??t.sessionId,rootTurnId:n,sessionId:t.sessionId,turnId:n}}}function resolveActiveSandboxSessionId(e,t){if(typeof e!=`object`||!e)return t;let n=e.sandboxSessionId;return typeof n==`string`&&n.length>0?n:t}function planDispatch(e){return e.requests.map(e=>{if(e.kind===`tool-call`){if(!isTaskControlAction(e))throw Error(`Unsupported task control "${e.toolName}".`);return{action:e,kind:`task-control`}}if(e.kind===`workflow-task`)return{kind:`workflow-task`,task:e};throw Error(`Unsupported coordination request "${String(e.kind)}".`)})}export{prepareActionDispatch,prepareCoordinationDispatch};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Starts workflow-tool runs for pending blocking actions from either source. */
|
|
2
|
+
import { type CoordinationDispatchInput, type CoordinationDispatchResult } from "#execution/coordination-dispatch-shared.js";
|
|
3
|
+
type CoordinationDispatchStepInput = CoordinationDispatchInput & {
|
|
4
|
+
readonly action: "park" | "dispatch-workflow-tasks";
|
|
5
|
+
};
|
|
6
|
+
export declare function dispatchCoordinationStep(input: CoordinationDispatchStepInput): Promise<CoordinationDispatchResult>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{setPendingCoordinationBatch}from"#harness/coordination.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{executeTaskControlAction}from"#execution/tasks/parent/dispatch.js";import{prepareCoordinationDispatch}from"#execution/coordination-dispatch-shared.js";import{cancelBackgroundAgentTask}from"#execution/tools/subagent/task-cancel.js";import{deliverTaskUpdate}from"#execution/tasks/child/update.js";import{startWorkflowTask}from"#execution/tools/workflow/start.js";import{getPendingWorkflowInterrupt,setPendingWorkflowUsedCalls}from"#harness/workflow-interrupt-state.js";import{planWorkflowSubagentDispatch}from"#harness/workflow-subagent-limit.js";import{buildWorkflowTasksFromInterrupt}from"#harness/workflow-task-state.js";const workflowTaskLog=createLogger(`execution.dispatch-workflow-tasks`);async function dispatchCoordinationStep(e){"use step";let t=e.action===`dispatch-workflow-tasks`?await normalizeWorkflowTaskInterrupt(e):{results:[],sessionState:e.sessionState},n=await prepareCoordinationDispatch({serializedContext:e.serializedContext,sessionState:t.sessionState});if(n===void 0)return{results:t.results,sessionState:t.sessionState,pendingTasks:[]};let{batch:i,session:a}=n,o=a,s=[],p=[];for(let t of n.plan){if(t.kind===`workflow-task`){let r=await startWorkflowTask({auth:n.auth,batchEvent:i.event,initiatorAuth:n.initiatorAuth,parentContinuationToken:e.parentContinuationToken??a.continuationToken,parentSession:n.parentSession,session:o,task:t.task});o=r.session,r.result!==void 0&&s.push(r.result);continue}if(t.kind===`task-control`){let e=await executeTaskControlAction({action:t.action,adapter:n.adapter,bundle:n.bundle,cancelOwnedWork:cancelBackgroundAgentTask,deliverUpdate:deliverTaskUpdate,parentStepIndex:i.event.stepIndex,parentTurnId:i.event.turnId,serializedContext:n.serializedContext,session:o});o=e.session,e.pendingTask!==void 0&&p.push(e.pendingTask),s.push(e.result);continue}}return{results:[...s,...t.results],sessionState:o===a?n.sessionState:createDurableSessionState({session:o}),pendingTasks:p}}async function normalizeWorkflowTaskInterrupt(e){let c=await readDurableSession(e.sessionState),l=getPendingWorkflowInterrupt(c.state);if(l===void 0)return{results:[],sessionState:e.sessionState};let u=buildWorkflowTasksFromInterrupt(l.interrupt);if(u.length===0)return{results:[],sessionState:e.sessionState};let d=await deserializeContext(e.serializedContext),f=resolveEffectiveAgentRuntime(d.require(BundleKey),d),m=planWorkflowSubagentDispatch({tasks:u,maxSubagents:c.workflowMaxSubagents,usedCalls:l.usedCalls}),h=m.blocked.map(e=>(workflowTaskLog.warn(`workflow subagent limit reached; blocking delegated call`,{callId:e.callId,maxSubagents:m.maxSubagents,subagentName:getWorkflowTaskName(e),usedCalls:m.usedCalls}),createWorkflowSubagentLimitResult({action:e,plan:m})));if(m.allowed.length===0)return{results:h,sessionState:e.sessionState};let g=setPendingWorkflowUsedCalls({session:hydrateDurableSession({compactionOverrides:{thresholdPercent:f.thresholdPercent},durable:c,turnAgent:f.turnAgent}),usedCalls:l.usedCalls+m.allowed.filter(e=>e.resultKind===`subagent`).length});return{results:h,sessionState:createDurableSessionState({session:setPendingCoordinationBatch({runtimeActions:[],tasks:m.allowed,event:{sequence:0,stepIndex:0,turnId:`workflow-dispatch`},responseMessages:[],session:g})})}}function createWorkflowSubagentLimitResult(e){let t=getWorkflowTaskName(e.action);return{callId:e.action.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`WORKFLOW_SUBAGENT_LIMIT_REACHED`,maxSubagents:e.plan.maxSubagents,message:`Workflow subagent limit reached (${String(e.plan.maxSubagents)}); "${t}" was not called.`},subagentName:t}}function getWorkflowTaskName(e){return e.resultKind===`subagent`?e.toolName:e.kind}export{dispatchCoordinationStep};
|
|
@@ -27,6 +27,5 @@ export declare function createSessionStep(input: {
|
|
|
27
27
|
readonly nodeId?: string;
|
|
28
28
|
readonly rootSessionId?: string;
|
|
29
29
|
readonly sessionId: string;
|
|
30
|
-
readonly
|
|
31
|
-
readonly taskOwned?: boolean;
|
|
30
|
+
readonly taskId?: string;
|
|
32
31
|
}): Promise<CreateSessionStepResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDurableSessionState}from"#execution/durable-session-store.js";import{
|
|
1
|
+
import{createDurableSessionState}from"#execution/durable-session-store.js";import{createSession}from"#execution/session.js";import{resolveEffectiveAgentRuntimeFromConfig}from"#execution/effective-agent-config.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{resolveDurableCompiledArtifactsSource}from"#runtime/durable-compiled-artifacts-source.js";import{resolveInheritedTokenLimit}from"#execution/run-session-limits.js";import{TASK_UPDATE_SESSION_INSTRUCTION}from"#tools/framework/task-update.js";async function createSessionStep(t){"use step";let n=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:resolveDurableCompiledArtifactsSource(t.compiledArtifactsSource),nodeId:t.nodeId}),r=resolveEffectiveAgentRuntimeFromConfig(n,t.dynamicSubagentAgentConfig),i=t.taskId!==void 0&&r.turnAgent.tools.some(e=>e.kind===`authored-tool`&&e.behavior?.handling?.kind===`dispatch`&&e.behavior.handling.target.kind===`task-update`);return{state:createDurableSessionState({session:createSession({compactionOverrides:{thresholdPercent:r.thresholdPercent},continuationToken:t.continuationToken,limits:{maxInputTokensPerSession:resolveInheritedTokenLimit({configured:r.limits?.maxInputTokensPerSession,inherited:t.inheritedLimits?.maxInputTokensPerSession}),maxOutputTokensPerSession:resolveInheritedTokenLimit({configured:r.limits?.maxOutputTokensPerSession,inherited:t.inheritedLimits?.maxOutputTokensPerSession})},outputSchema:t.outputSchema,rootSessionId:t.rootSessionId,sessionId:t.sessionId,systemPromptAdditions:i?[TASK_UPDATE_SESSION_INSTRUCTION]:void 0,taskId:t.taskId,turnAgent:r.turnAgent,workflowMaxSubagents:n.resolvedAgent.workflowTool?.maxSubagents})})}}export{createSessionStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{coalesceTurnInputs}from"#harness/messages.js";const COALESCED_DELIVER_FIELDS=[`context`,`inputResponses`,`message`,`outputSchema`,`task`];function coalesceDeliverPayloads(n){if(n.length===0)return{};if(n.length===1)return n[0]??{};let r={},i=[],a=[],o=[],s={};for(let t of n){i.push(...t.task?.inputRequests??[]),a.push(...t.task?.
|
|
1
|
+
import{coalesceTurnInputs}from"#harness/messages.js";const COALESCED_DELIVER_FIELDS=[`context`,`inputResponses`,`message`,`outputSchema`,`task`];function coalesceDeliverPayloads(n){if(n.length===0)return{};if(n.length===1)return n[0]??{};let r={},i=[],a=[],o=[],s=[],c={};for(let t of n){i.push(...t.task?.inputRequests??[]),a.push(...t.task?.agentRequests??[]),o.push(...t.task?.authorizationEvents??[]),s.push(...t.task?.views??[]);for(let[e,n]of Object.entries(t))n!==void 0&&(r[e]=n);c=coalesceTurnInputs(c,t)}for(let e of COALESCED_DELIVER_FIELDS)delete r[e];let l={};return i.length>0&&(l.inputRequests=i),a.length>0&&(l.agentRequests=a),o.length>0&&(l.authorizationEvents=o),s.length>0&&(l.views=s),Object.keys(l).length>0&&(r.task=l),Object.assign(r,c)}export{coalesceDeliverPayloads};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function createUnavailableDynamicSubagentResult(action:
|
|
3
|
-
export declare function getSubagentName(action:
|
|
1
|
+
import type { RuntimeRemoteAgentDispatchRequest, RuntimeSubagentDispatchRequest, RuntimeSubagentDispatchFailure } from "#shared/action-types.js";
|
|
2
|
+
export declare function createUnavailableDynamicSubagentResult(action: RuntimeSubagentDispatchRequest | RuntimeRemoteAgentDispatchRequest): RuntimeSubagentDispatchFailure;
|
|
3
|
+
export declare function getSubagentName(action: RuntimeSubagentDispatchRequest | RuntimeRemoteAgentDispatchRequest): string;
|
|
4
4
|
export declare function createRemoteAgentStartFailureResult(input: {
|
|
5
|
-
readonly action:
|
|
5
|
+
readonly action: RuntimeRemoteAgentDispatchRequest;
|
|
6
6
|
readonly error: unknown;
|
|
7
7
|
}): RuntimeSubagentDispatchFailure;
|
|
8
|
-
export declare function createRecursiveAgentRootOnlyResult(action:
|
|
8
|
+
export declare function createRecursiveAgentRootOnlyResult(action: RuntimeSubagentDispatchRequest): RuntimeSubagentDispatchFailure;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toErrorMessage}from"#shared/errors.js";import{REMOTE_AGENT_START_FAILED}from"#
|
|
1
|
+
import{toErrorMessage}from"#shared/errors.js";import{REMOTE_AGENT_START_FAILED}from"#subagents/agent-handle-errors.js";function createUnavailableDynamicSubagentResult(e){let t=getSubagentName(e);return{callId:e.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`SUBAGENT_UNAVAILABLE`,message:`Subagent "${t}" is not available in the current session context.`},subagentName:t}}function getSubagentName(e){return e.kind===`remote-agent-call`?e.remoteAgentName:e.subagentName}function createRemoteAgentStartFailureResult(n){return{callId:n.action.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:REMOTE_AGENT_START_FAILED,message:toErrorMessage(n.error)},subagentName:n.action.remoteAgentName}}function createRecursiveAgentRootOnlyResult(e){return{callId:e.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`RECURSIVE_AGENT_ROOT_ONLY`,message:`The built-in "agent" tool is only available to the root session.`},subagentName:e.subagentName}}export{createRecursiveAgentRootOnlyResult,createRemoteAgentStartFailureResult,createUnavailableDynamicSubagentResult,getSubagentName};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentIdentity, type StartOperation } from "#
|
|
1
|
+
import { type AgentIdentity, type StartOperation } from "#subagents/handles/store.js";
|
|
2
2
|
/**
|
|
3
3
|
* Mints deterministic parent-controlled ownership data before the child exists,
|
|
4
4
|
* so durable step replays derive the same handle record.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{deriveAgentOperationId}from"#
|
|
1
|
+
import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{deriveAgentId}from"#subagents/handles/store.js";function mintStartOperation(e){let t=deriveAgentOperationId({callId:e.callId,parentSessionId:e.parentSessionId,parentTurnId:e.parentTurnId});return{identity:{id:deriveAgentId(e.name,t),name:e.name,nodeId:e.nodeId},operation:{callId:e.callId,id:t,kind:`start`,parentTurnId:e.parentTurnId}}}export{mintStartOperation};
|
|
@@ -73,7 +73,7 @@ export interface DurableSession {
|
|
|
73
73
|
readonly outputSchema?: JsonObject;
|
|
74
74
|
readonly state?: SessionStateMap;
|
|
75
75
|
readonly sandboxState?: SandboxState;
|
|
76
|
-
readonly
|
|
76
|
+
readonly taskId?: string;
|
|
77
77
|
readonly workflowMaxSubagents?: number;
|
|
78
78
|
readonly agent: {
|
|
79
79
|
readonly system: string;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* - `$eve.type` — `"session" | "turn" | "subagent"`
|
|
18
18
|
* - `$eve.parent` — sessionId of the **immediate** parent
|
|
19
19
|
* - `$eve.root` — sessionId of the **root** session in the chain
|
|
20
|
-
* - `$eve.parent_call` — parent
|
|
20
|
+
* - `$eve.parent_call` — parent task tool-call id (subagent rows only)
|
|
21
21
|
* - `$eve.parent_turn` — parent turn id that dispatched the subagent (subagent rows only)
|
|
22
22
|
* - `$eve.subagent` — active compiled graph node id (subagent rows only)
|
|
23
23
|
* - `$eve.trigger` — channel adapter kind (session/subagent rows)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{activeTurnId}from"#harness/active-turn-id.js";import{readAcceptedDeploymentId}from"#execution/accepted-delivery-deployment.js";import{reportDroppedWirePayloadStep}from"#execution/report-dropped-wire-payload-step.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{SessionInboxWireError,sessionInboxWire}from"#execution/wire/session-inbox-wire.js";import{turnStep}from"#execution/workflow-steps.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";async function runInlineTurn(n){let i=readAcceptedDeploymentId(n.delivery);if(i===void 0)return{kind:`child`};let a=new InlineTurnControl({bufferedDeliveries:n.bufferedDeliveries,bufferedSessionControls:n.bufferedSessionControls,cancelledTaskIds:n.cancelledTaskIds,commandInbox:n.commandInbox,expectedTurnId:activeTurnId(n.sessionState.emissionState),seenTaskDeliveries:n.seenTaskDeliveries}),o=new SessionStateCursor({serializedContext:n.serializedContext,sessionState:n.sessionState}),s=n.delivery;for(;;){let e={serializedContext:o.serializedContext,sessionState:o.sessionState},t=await a.waitForStep(turnStep({abortSignal:a.signal,acceptedDeploymentId:i,input:s,parentWritable:n.parentWritable,serializedContext:o.serializedContext,sessionState:o.sessionState}));if(t.requiresChildDispatch===!0)return childOutcome(a);let r={beforeStep:e,result:t};if(a.initialCancellation!==void 0||t.action===`cancelled`||t.sleepDurationMs!==void 0||(t.backgroundTasks?.length??0)>0)return childOutcome(a,r);if(t.action===`done`)return{action:{isError:t.isError,kind:`done`,output:t.output??``,serializedContext:t.serializedContext,sessionState:t.sessionState,usage:t.usage,usageDelta:t.usageDelta},kind:`result`};if(t.action===`dispatch-workflow-
|
|
1
|
+
import{activeTurnId}from"#harness/active-turn-id.js";import{readAcceptedDeploymentId}from"#execution/accepted-delivery-deployment.js";import{reportDroppedWirePayloadStep}from"#execution/report-dropped-wire-payload-step.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{SessionInboxWireError,sessionInboxWire}from"#execution/wire/session-inbox-wire.js";import{turnStep}from"#execution/workflow-steps.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";async function runInlineTurn(n){let i=readAcceptedDeploymentId(n.delivery);if(i===void 0)return{kind:`child`};let a=new InlineTurnControl({bufferedDeliveries:n.bufferedDeliveries,bufferedSessionControls:n.bufferedSessionControls,cancelledTaskIds:n.cancelledTaskIds,commandInbox:n.commandInbox,expectedTurnId:activeTurnId(n.sessionState.emissionState),seenTaskDeliveries:n.seenTaskDeliveries}),o=new SessionStateCursor({serializedContext:n.serializedContext,sessionState:n.sessionState}),s=n.delivery;for(;;){let e={serializedContext:o.serializedContext,sessionState:o.sessionState},t=await a.waitForStep(turnStep({abortSignal:a.signal,acceptedDeploymentId:i,input:s,parentWritable:n.parentWritable,serializedContext:o.serializedContext,sessionState:o.sessionState}));if(t.requiresChildDispatch===!0)return childOutcome(a);let r={beforeStep:e,result:t};if(a.initialCancellation!==void 0||t.action===`cancelled`||t.sleepDurationMs!==void 0||(t.backgroundTasks?.length??0)>0)return childOutcome(a,r);if(t.action===`done`)return{action:{isError:t.isError,kind:`done`,output:t.output??``,serializedContext:t.serializedContext,sessionState:t.sessionState,usage:t.usage,usageDelta:t.usageDelta},kind:`result`};if(t.action===`dispatch-workflow-tasks`||t.action===`park`&&t.pendingCoordinationCallIds!==void 0)return childOutcome(a,r);if(t.action===`park`)return t.hasPendingAuthorization||t.hasPendingInputBatch&&n.capabilities?.requestInput===!0||n.mode===`conversation`?{action:{authorizationAttemptIds:t.authorizationAttemptIds,authorizationNames:t.authorizationNames,kind:`park`,serializedContext:t.serializedContext,sessionState:t.sessionState,settled:t.settled},kind:`result`}:childOutcome(a,r);let c=o.sessionState.continuationToken;o.adoptState(t),o.sessionState.continuationToken!==``&&o.sessionState.continuationToken!==c&&await n.commandInbox.rekeyContinuation(o.sessionState.continuationToken),s=void 0}}function childOutcome(e,t){return{initialCancellation:e.initialCancellation,initialStep:t,kind:`child`}}var InlineTurnControl=class{bufferedDeliveries;bufferedSessionControls;cancelledTaskIds;commandInbox;controller=new AbortController;expectedTurnId;seenTaskDeliveries;cancellation;constructor(e){this.bufferedDeliveries=e.bufferedDeliveries,this.bufferedSessionControls=e.bufferedSessionControls,this.cancelledTaskIds=e.cancelledTaskIds??new Set,this.commandInbox=e.commandInbox,this.expectedTurnId=e.expectedTurnId,this.seenTaskDeliveries=e.seenTaskDeliveries??new Set}get initialCancellation(){return this.cancellation}get signal(){return this.controller.signal}async waitForStep(e){let t=e.then(e=>({kind:`step`,result:e}));for(;;){let e=await Promise.race([t,this.commandInbox.next().then(e=>({kind:`command`,result:e}))]);if(e.kind===`step`)return e.result;if(e.result.done)throw Error(`Session command inbox closed before the inline turn step settled.`);this.commandInbox.consumeNext(),await this.handle(e.result.value)}}abort(e){this.controller.signal.aborted||(this.cancellation=e,this.controller.abort(new TurnCancelledError))}acceptTaskDelivery(e){let t=e.taskDeliveryId??e.caller?.taskId;return t===void 0?!0:this.originatesFromCancelledTask(t)||this.seenTaskDeliveries.has(t)?!1:(this.seenTaskDeliveries.add(t),!0)}async handle(e){if(e.kind===`runtime-action-result`)return;let t;try{t=sessionInboxWire.decode(e)}catch(e){if(!(e instanceof SessionInboxWireError))throw e;await reportDroppedWirePayloadStep({detail:e.message,family:`session-inbox`});return}if(t.kind===`deliver`){if(!this.acceptTaskDelivery(t))return;this.bufferedDeliveries.push(t),t.turnPolicy===`steer`&&deliveryHasMessage(t)&&this.abort({});return}if(t.kind===`clear`||t.kind===`compact`){this.bufferedSessionControls.push(t.kind);return}if(t.kind===`session-timeout`){this.bufferedSessionControls.push(`expired`);return}if(t.kind===`reset`){this.bufferedSessionControls.push(`reset`),this.abort({});return}if(t.kind===`cancel`){t.taskId!==void 0&&this.discardTaskDeliveries(t.taskId);let e=t.taskId!==void 0&&t.turnId!==void 0&&t.turnId!==this.expectedTurnId?void 0:t.turnId;(e===void 0||e===this.expectedTurnId)&&this.abort(e===void 0?{}:{turnId:e})}}discardTaskDeliveries(e){this.cancelledTaskIds.add(e);let t=this.bufferedDeliveries.filter(e=>!this.shouldDiscard(e));this.bufferedDeliveries.splice(0,this.bufferedDeliveries.length,...t)}originatesFromCancelledTask(e){return[...this.cancelledTaskIds].some(t=>e===t||e.startsWith(`${t}:`))}shouldDiscard(e){let t=e.taskDeliveryId??e.caller?.taskId;return t!==void 0&&this.originatesFromCancelledTask(t)}};function deliveryHasMessage(e){return e.payloads.some(e=>e.message!==void 0)}export{runInlineTurn};
|
|
@@ -39,15 +39,12 @@ export type DurableStepResult = ({
|
|
|
39
39
|
readonly authorizationNames?: readonly string[];
|
|
40
40
|
readonly hasPendingAuthorization: boolean;
|
|
41
41
|
readonly hasPendingInputBatch: boolean;
|
|
42
|
-
readonly
|
|
43
|
-
/** The batch starts workflow tool runs, which report to the turn's run channels. */
|
|
44
|
-
readonly startsWorkflowToolRuns?: boolean;
|
|
45
|
-
readonly tasksEnabled?: boolean;
|
|
42
|
+
readonly pendingCoordinationCallIds?: readonly string[];
|
|
46
43
|
readonly sleepDurationMs?: number;
|
|
47
44
|
readonly settled?: SettledTurn;
|
|
48
45
|
} | {
|
|
49
|
-
readonly action: "dispatch-workflow-
|
|
50
|
-
readonly
|
|
46
|
+
readonly action: "dispatch-workflow-tasks";
|
|
47
|
+
readonly pendingTaskCallIds: readonly string[];
|
|
51
48
|
readonly sleepDurationMs?: number;
|
|
52
49
|
}) & DurableStepResultFields;
|
|
53
50
|
/** Discriminated union the driver workflow body dispatches on. */
|
|
@@ -84,13 +81,13 @@ export type NextDriverAction = {
|
|
|
84
81
|
*/
|
|
85
82
|
readonly settled?: SettledTurn;
|
|
86
83
|
} | {
|
|
87
|
-
readonly kind: "dispatch-
|
|
88
|
-
readonly
|
|
84
|
+
readonly kind: "dispatch-coordination";
|
|
85
|
+
readonly pendingCallIds: readonly string[];
|
|
89
86
|
readonly sessionState: DurableSessionState;
|
|
90
87
|
readonly serializedContext: Record<string, unknown>;
|
|
91
88
|
} | {
|
|
92
|
-
readonly kind: "dispatch-workflow-
|
|
93
|
-
readonly
|
|
89
|
+
readonly kind: "dispatch-workflow-tasks";
|
|
90
|
+
readonly pendingCallIds: readonly string[];
|
|
94
91
|
readonly sessionState: DurableSessionState;
|
|
95
92
|
readonly serializedContext: Record<string, unknown>;
|
|
96
93
|
};
|
|
@@ -66,8 +66,7 @@ export declare function buildRuntimeIdentity(node: ResolvedRuntimeAgentNode): Ru
|
|
|
66
66
|
* Resolves unified {@link HarnessToolDefinition}s from the node's registries.
|
|
67
67
|
*
|
|
68
68
|
* For authored tools: copies all lifecycle fields from the resolved definition.
|
|
69
|
-
*
|
|
70
|
-
* background `defineTool` definition from the node's `experimental.tasks` setting.
|
|
69
|
+
* Prepared workflow-task tools share the workflow-tool harness path.
|
|
71
70
|
* Tools without `execute` (provider-managed) get entries with schema but no execute.
|
|
72
71
|
*/
|
|
73
72
|
export declare function createNodeHarnessTools(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{UNSPECIFIED_INPUT_SCHEMA}from"#tools/schema.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{UNSPECIFIED_INPUT_SCHEMA}from"#tools/schema.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{createPreparedWorkflowToolHarnessDefinition,createWorkflowToolHarnessDefinition}from"#execution/tools/workflow/background.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{preparePersistedStepDynamicToolMetadata}from"#context/dynamic-tool-lifecycle.js";import{createToolLoopHarness}from"#harness/tool-loop.js";import{createTaskToolHarnessDefinitions}from"#execution/tools/tasks.js";import{findRegisteredRuntimeTool}from"#runtime/tools/registry.js";import{preserveFrameworkStateOnCompaction}from"#execution/compaction.js";import{ASK_QUESTION_TOOL_NAME}from"#harness/request-input-tool.js";const log=createLogger(`execution.node-step`);function createExecutionNodeStep(e){let t=createRuntimeModelResolver(e.modelResolutionScope),n=e.node.turnAgent.dynamicModel===void 0?void 0:createRuntimeDynamicModelEventDispatcher(e.modelResolutionScope,e.node.turnAgent.dynamicModel),r=createNodeHarnessTools({node:e.node}),i=e.instrumentation,a=i?.prepareExecution(),o=createToolLoopHarness({abortSignal:e.abortSignal,capabilities:e.capabilities,clearOnly:e.clearOnly,compactOnly:e.compactOnly,workflow:e.node.agent.workflowTool!==void 0,workflowMaxSubagents:e.workflowMaxSubagents,handleEvent:e.handleEvent,historyProjector:e.historyProjector,historyView:e.historyView,instrumentation:a,mode:e.mode,onCompaction:preserveFrameworkStateOnCompaction,resolveStepDynamicTools:t=>preparePersistedStepDynamicToolMetadata({...t,resolvers:e.node.agent.dynamicToolResolvers??[]}),dispatchDynamicModelEvent:n,resolveModel:t,runtimeIdentity:buildRuntimeIdentity(e.node),tools:r});return i===void 0?o:async(e,t)=>{try{return await o(e,t)}finally{await i.flush()}}}function buildRuntimeIdentity(e){let n=resolveInstalledPackageInfo(),r={agentId:e.turnAgent.id,agentName:e.agent.config?.name,eveVersion:n.version},i=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),a=process.env.VERCEL_GIT_COMMIT_REF?.trim(),o=process.env.VERCEL_DEPLOYMENT_CREATED_AT?.trim();return i||a||o?{...r,build:{deployedAt:o||void 0,gitBranch:a||void 0,gitSha:i||void 0}}:r}function createRuntimeModelResolver(e){return t=>resolveRuntimeModelReference(t,e)}function createRuntimeDynamicModelEventDispatcher(e,t){return n=>dispatchDynamicModelEvent({ctx:n.ctx,dynamicModel:t,event:n.event,messages:n.messages,scope:e})}function createNodeHarnessTools(e){let t=new Map;for(let n of e.node.turnAgent.tools){let r=resolveHarnessToolDefinition({node:e.node,tool:n});r!==null&&t.set(n.name,r)}return t}function resolveHarnessToolDefinition(e){let t=findRegisteredRuntimeTool(e.node.toolRegistry,e.tool.name);return isPreparedRuntimeWorkflowTool(e.tool)?t===null?createPreparedWorkflowToolHarnessDefinition(e.tool):createWorkflowToolHarnessDefinition({definition:createRegisteredHarnessToolDefinition({behavior:e.tool.behavior,definition:t.definition,rootOnly:e.tool.rootOnly}),nodeId:e.tool.task.nodeId,resultKind:e.tool.task.resultKind,workflowId:e.tool.task.workflowId}):t===null?(log.warn(`declared tool is not registered — omitting from toolset`,{toolName:e.tool.name,nodeId:e.node.nodeId}),null):createRegisteredHarnessToolDefinition({behavior:e.tool.behavior,definition:t.definition,rootOnly:e.tool.rootOnly})}function isPreparedRuntimeWorkflowTool(e){return e.task!==void 0}function createRegisteredHarnessToolDefinition(e){let t=e.definition;if(t.owner.kind===`framework`){let n=createTaskToolHarnessDefinitions().find(e=>e.name===t.name);if(n!==void 0)return{...n,behavior:e.behavior}}let r=t.execute,i=t.owner.kind===`framework`&&t.name===ASK_QUESTION_TOOL_NAME;return{approvalKey:t.approvalKey,behavior:e.behavior,description:t.description,execution:t.execution,execute:i?void 0:resolveAuthoredExecute({rawExecute:r,scope:t.name}),frameworkAction:t.owner.kind===`framework`&&t.name===LOAD_SKILL_TOOL_NAME?`load-skill`:void 0,inputSchema:t.inputSchema??UNSPECIFIED_INPUT_SCHEMA,name:t.name,approval:t.approval,outputSchema:t.outputSchema,rootOnly:e.rootOnly,toModelOutput:t.toModelOutput}}function resolveAuthoredExecute(e){let{rawExecute:t,scope:n}=e;return t===void 0?void 0:createToolExecuteWithAuth({execute:t,scope:n})}export{buildRuntimeIdentity,createExecutionNodeStep,createNodeHarnessTools};
|
|
@@ -5,6 +5,5 @@ export declare function derivePendingState(session: HarnessSession): {
|
|
|
5
5
|
readonly authorizationNames?: readonly string[];
|
|
6
6
|
readonly hasPendingAuthorization: boolean;
|
|
7
7
|
readonly hasPendingInputBatch: boolean;
|
|
8
|
-
readonly
|
|
9
|
-
readonly startsWorkflowToolRuns?: boolean;
|
|
8
|
+
readonly pendingCoordinationCallIds?: readonly string[];
|
|
10
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getPendingCoordinationBatch}from"#harness/coordination.js";import{getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}from"#harness/input-requests.js";function derivePendingState(t){let n=getPendingCoordinationBatch(t.state),r=getPendingAuthorization(t.state),i={authorizationAttemptIds:r?.challenges.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),authorizationNames:r?.challenges.map(e=>e.name),hasPendingAuthorization:r!==void 0,hasPendingInputBatch:hasPendingInputBatch(t.state)};return n===void 0?i:{...i,pendingCoordinationCallIds:[...n.runtimeActions,...n.tasks].map(e=>e.callId)}}export{derivePendingState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{createTaskInputRequestId,retireProxyInputRequests}from"#harness/proxy-input-requests.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{routeDeliverPayload}from"#
|
|
1
|
+
import{readDurableSession,replaceDurableSessionSnapshot}from"#execution/durable-session-store.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{createTaskInputRequestId,retireProxyInputRequests}from"#harness/proxy-input-requests.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{routeDeliverPayload}from"#subagents/hitl-proxy.js";import{sendTaskInboundPayload}from"#execution/tasks/parent/run-parent.js";import{resumeWorkflowToolRunAnswers}from"#execution/tools/workflow/answer.js";import{findSessionTaskEntry}from"#tasks/session-index.js";async function routeProxiedDeliverStep(r){"use step";let l=await readDurableSession(r.sessionState),u=!(`delivery`in r),d=`delivery`in r?r.delivery:{auth:r.auth,kind:`deliver`,payloads:[r.payload]},f=new Map,p=new Map,m;for(let[e,t]of d.payloads.entries()){let n=routeDeliverPayload({allowRoute:(e,t)=>t.taskId===void 0||findSessionTaskEntry(l.state,t.taskId)!==void 0,payload:t,state:l.state});m??=n.parentAction,n.forSelf!==void 0&&f.set(e,n.forSelf);for(let[t,r]of n.forChildren.entries()){let i=r.taskId===void 0?r.childContinuationToken:[r.childContinuationToken,r.childResponseUrl??``,r.taskId].join(`\0`),a=p.get(i)??{answerHook:r.answerHook,childContinuationToken:r.childContinuationToken,childResponseUrl:r.childResponseUrl,metadata:[],payloads:[],retireRequestIds:[],sourcePayloadIndexes:[],taskId:r.taskId},o=a.payloads.length;if(a.payloads.push(r.payload),a.retireRequestIds.push(...r.retireRequestIds),a.sourcePayloadIndexes.push(e),n.forSelf===void 0&&t===0)for(let t of d.deliveryMetadata??[])t.payloadIndex===e&&a.metadata.push({...t,payloadIndex:o});p.set(i,a)}}let h=!1;for(let e of p.values()){let t=e.taskId;if(t!==void 0){let n=findSessionTaskEntry(l.state,t);if(n===void 0){mergeStrandedResponses(f,e,t);continue}if(await sendTaskInboundPayload({taskInboxToken:n.taskInboxToken,payload:{auth:d.auth,childContinuationToken:e.childContinuationToken,childResponseUrl:e.childResponseUrl,inputResponses:coalesceDeliverPayloads(e.payloads).inputResponses??[],kind:`input-response`,taskId:t}})===`unreachable`){mergeStrandedResponses(f,e,t);continue}l=retireProxyInputRequests(l,e.retireRequestIds),h=!0;continue}if(e.answerHook!==void 0){await resumeWorkflowToolRunAnswers(e.childContinuationToken,coalesceDeliverPayloads(e.payloads).inputResponses),l=retireProxyInputRequests(l,e.retireRequestIds),h=!0;continue}let r={...d,deliveryMetadata:e.metadata.length===0?void 0:e.metadata,payloads:e.payloads};await resumeSessionInbox(e.childContinuationToken,r),l=retireProxyInputRequests(l,e.retireRequestIds),h=!0}let g={serializedContext:r.serializedContext??{},sessionState:h?replaceDurableSessionSnapshot({session:l,state:r.sessionState}):r.sessionState};if(m!==void 0)return{...g,...m};let _=[...f].sort(([e],[t])=>e-t),v=_.flatMap(([e],t)=>(d.deliveryMetadata??[]).filter(t=>t.payloadIndex===e).map(e=>({...e,payloadIndex:t}))),y=_.length===0?void 0:u?coalesceDeliverPayloads(_.map(([,e])=>e)):{...d,deliveryMetadata:v.length===0?void 0:v,payloads:_.map(([,e])=>e)};return{...g,kind:`continue`,remainder:y}}function mergeStrandedResponses(e,t,n){for(let[i,a]of t.payloads.entries()){let o=t.sourcePayloadIndexes[i];if(o===void 0)continue;let s=(a.inputResponses??[]).map(e=>({...e,requestId:createTaskInputRequestId(n,e.requestId)}));if(s.length===0)continue;let c=e.get(o);e.set(o,{...c,inputResponses:[...c?.inputResponses??[],...s]})}}export{routeProxiedDeliverStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{routeProxiedDeliverStep}from"#execution/proxied-deliver-step.js";import{
|
|
1
|
+
import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{routeProxiedDeliverStep}from"#execution/proxied-deliver-step.js";import{emitRecordedTaskInputRequestStep,runProxySubagentEventStep}from"#subagents/event-proxy-step.js";import{recordTaskInputRequestStep,recordTerminalTaskViewsStep}from"#execution/tasks/parent/hitl-proxy-steps.js";import{acceptTaskAuthorizationEventStep}from"#execution/tools/subagent/accept-event-step.js";import{applyTaskAgentRequest}from"#execution/tools/subagent/task-agent-requests.js";async function routeDeliverToChildren(i){let a=coalesceDeliverPayloads(i.delivery.payloads),o=i.serializedContext,s=i.sessionState;for(let e of a.task?.inputRequests??[]){let t=await recordTaskInputRequestStep({request:e,sessionState:s});if(s=t.sessionState,!t.accepted)continue;let r=await emitRecordedTaskInputRequestStep({parentWritable:i.parentWritable,request:t.request,serializedContext:o,sessionState:s});o=r.serializedContext,s=r.sessionState}for(let e of a.task?.agentRequests??[]){let t=await applyTaskAgentRequest({...e,ownerId:e.taskId},{parentWritable:i.parentWritable,serializedContext:o,sessionState:s});o=t.serializedContext,s=t.sessionState}for(let e of a.task?.authorizationEvents??[]){if(!await acceptTaskAuthorizationEventStep({delivery:e,sessionState:s}))continue;let t=await runProxySubagentEventStep({hookPayload:e.hookPayload,parentWritable:i.parentWritable,serializedContext:o,sessionState:s});o=t.serializedContext,s=t.sessionState}(a.task?.views?.length??0)>0&&(s=await recordTerminalTaskViewsStep({sessionState:s,views:a.task?.views??[]}));let c=[],l=[];for(let[e,t]of i.delivery.payloads.entries()){let n={...t};if(delete n.task,Object.keys(n).length===0)continue;let r=c.length;c.push(n);for(let t of i.delivery.deliveryMetadata??[])t.payloadIndex===e&&l.push({...t,payloadIndex:r})}let u=c.length===0?void 0:{...i.delivery,deliveryMetadata:l.length===0?void 0:l,payloads:c};return u===void 0?{kind:`continue`,remainder:void 0,serializedContext:o,sessionState:s}:s.hasProxyInputRequests?await routeProxiedDeliverStep({delivery:u,parentWritable:i.parentWritable,serializedContext:o,sessionState:s}):{kind:`continue`,remainder:u,serializedContext:o,sessionState:s}}export{routeDeliverToChildren};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ContextContainer,contextStorage}from"#context/container.js";import{ActivityObserverKey,AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,DynamicSubagentAgentConfigKey,InitiatorAuthKey,ModeKey,ParentSessionKey,ParentTraceContextKey,ScheduleIdKey,SessionCallbackKey
|
|
1
|
+
import{ContextContainer,contextStorage}from"#context/container.js";import{ActivityObserverKey,AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,DynamicSubagentAgentConfigKey,InitiatorAuthKey,ModeKey,ParentSessionKey,ParentTraceContextKey,ScheduleIdKey,SessionCallbackKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{setChannelContext}from"#execution/channel-context.js";function buildRunContext(t){let{bundle:n,run:r}=t,i=new ContextContainer,a=r.auth;if(i.set(BundleKey,n),setChannelContext(i,r.adapter,{channelName:r.channelName}),r.channelMetadata!==void 0){let e=i.get(ChannelInstrumentationKey);i.set(ChannelInstrumentationKey,{channelType:e?.channelType??r.channelMetadata.channelType,kind:e?.kind??r.channelMetadata.kind,metadata:r.channelMetadata.metadata})}r.continuationToken!==void 0&&i.set(ContinuationTokenKey,r.continuationToken),i.set(ModeKey,r.mode),i.set(AuthKey,a),i.set(InitiatorAuthKey,r.initiatorAuth??a),t.dynamicSubagentAgentConfig!==void 0&&i.set(DynamicSubagentAgentConfigKey,t.dynamicSubagentAgentConfig),r.capabilities!==void 0&&i.set(CapabilitiesKey,r.capabilities),r.requestId!==void 0&&i.set(ChannelRequestIdKey,r.requestId);let o=contextStorage.getStore()?.get(ScheduleIdKey);return o!==void 0&&i.set(ScheduleIdKey,o),r.delivery!==void 0&&i.set(ChannelDeliveryKey,r.delivery),r.callback!==void 0&&i.set(SessionCallbackKey,r.callback),r.activityObserver!==void 0&&i.set(ActivityObserverKey,r.activityObserver),r.parent!==void 0&&i.set(ParentSessionKey,r.parent),r.parentTraceContext!==void 0&&i.set(ParentTraceContextKey,r.parentTraceContext),i}export{buildRunContext};
|
|
@@ -2,9 +2,8 @@ import type { DeliverHookPayload, RuntimeActionResultHookPayload, SessionCommand
|
|
|
2
2
|
/**
|
|
3
3
|
* Payloads accepted by a session driver's stable and channel aliases.
|
|
4
4
|
*
|
|
5
|
-
* This union is the hook's transport typing only
|
|
6
|
-
*
|
|
7
|
-
* which owns the versioned wire schema and its legacy-shape fallbacks.
|
|
5
|
+
* This union is the hook's transport typing only. The driver routes payloads
|
|
6
|
+
* after the inbox surfaces them; the inbox owns no command semantics.
|
|
8
7
|
*/
|
|
9
8
|
export type SessionInboxPayload = DeliverHookPayload | RuntimeActionResultHookPayload | SessionCommand | SessionTimeoutHookPayload;
|
|
10
9
|
/** Which hook family produced an inbox read. */
|
|
@@ -45,8 +45,8 @@ export interface CreateSessionInput {
|
|
|
45
45
|
readonly turnAgent: RuntimeTurnAgent;
|
|
46
46
|
readonly limits?: AuthoredSessionLimits;
|
|
47
47
|
readonly outputSchema?: HarnessSession["outputSchema"];
|
|
48
|
-
readonly subagentDepth?: number;
|
|
49
48
|
readonly systemPromptAdditions?: readonly string[];
|
|
49
|
+
readonly taskId?: string;
|
|
50
50
|
readonly workflowMaxSubagents?: number;
|
|
51
51
|
}
|
|
52
52
|
/** Creates a fresh {@link HarnessSession} from the current `turnAgent`. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";const DEFAULT_ROOT_MAX_INPUT_TOKENS_PER_SESSION=4e7;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({additions:e.systemPromptAdditions,turnAgent: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),r.limits=resolveSessionLimits(e),e.outputSchema!==void 0&&(r.outputSchema=e.outputSchema),e.
|
|
1
|
+
import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";const DEFAULT_ROOT_MAX_INPUT_TOKENS_PER_SESSION=4e7;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({additions:e.systemPromptAdditions,turnAgent: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),r.limits=resolveSessionLimits(e),e.outputSchema!==void 0&&(r.outputSchema=e.outputSchema),e.taskId!==void 0&&(r.taskId=e.taskId),e.workflowMaxSubagents!==void 0&&(r.workflowMaxSubagents=e.workflowMaxSubagents),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({additions:e.systemPromptAdditions,turnAgent: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(t){let n=formatAvailableSkillsSection(t.turnAgent.availableSkills??[]);return[...n===null?t.turnAgent.instructions:[...t.turnAgent.instructions,n],...t.additions??[]].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,history:e.history,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.limits!==void 0&&(t.limits=e.limits),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),e.sandboxState!==void 0&&(t.sandboxState=e.sandboxState),e.state!==void 0&&(t.state=e.state),e.
|
|
3
|
+
`)}function mintSubagentContinuationToken(e){return`subagent:${e??crypto.randomUUID()}`}function projectToDurableSession(e){let t={agent:{system:e.agent.system},continuationToken:e.continuationToken,history:e.history,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.limits!==void 0&&(t.limits=e.limits),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),e.sandboxState!==void 0&&(t.sandboxState=e.sandboxState),e.state!==void 0&&(t.state=e.state),e.taskId!==void 0&&(t.taskId=e.taskId),e.workflowMaxSubagents!==void 0&&(t.workflowMaxSubagents=e.workflowMaxSubagents),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,history:t.history,sessionId:t.sessionId};return t.rootSessionId!==void 0&&(i.rootSessionId=t.rootSessionId),t.limits!==void 0&&(i.limits=t.limits),t.outputSchema!==void 0&&(i.outputSchema=t.outputSchema),t.sandboxState!==void 0&&(i.sandboxState=t.sandboxState),t.state!==void 0&&(i.state=t.state),t.taskId!==void 0&&(i.taskId=t.taskId),t.workflowMaxSubagents!==void 0&&(i.workflowMaxSubagents=t.workflowMaxSubagents),i}function createSessionToolDefinitions(e){return e.tools.map(e=>({description:e.description??``,inputSchema:e.inputSchema,name:e.name,outputSchema:e.outputSchema}))}function resolveSessionLimits(e){let n=e.rootSessionId!==void 0,r=resolveSessionTokenLimit({authored:e.limits?.maxInputTokensPerSession,fallback:n?void 0:DEFAULT_ROOT_MAX_INPUT_TOKENS_PER_SESSION}),i=resolveSessionTokenLimit({authored:e.limits?.maxOutputTokensPerSession,fallback:void 0}),a={};return r!==void 0&&(a.maxInputTokensPerSession=r),i!==void 0&&(a.maxOutputTokensPerSession=i),a}function resolveSessionTokenLimit(e){return e.authored===!1?void 0:e.authored??e.fallback}export{DEFAULT_ROOT_MAX_INPUT_TOKENS_PER_SESSION,createCompactionConfig,createSession,hydrateDurableSession,mintSubagentContinuationToken,projectToDurableSession,refreshSessionFromTurnAgent};
|
|
@@ -7,7 +7,7 @@ export interface CancelledTurnSettleResult {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Settles one cancelled turn: emits `turn.cancelled` → `session.waiting`,
|
|
10
|
-
* drops pending
|
|
10
|
+
* drops pending coordination state, and persists the between-turns
|
|
11
11
|
* session. Runs in the *driver* run, whose wake sources exclude the
|
|
12
12
|
* cancel hook, so a queued cancel wake cannot re-dispatch it.
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler}from"#channel/adapter.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{clearWorkflowToolRuns,getWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{withContextScope}from"#context/run-step.js";import{clearPendingCoordinationBatch}from"#harness/coordination.js";import{activeTurnId}from"#harness/active-turn-id.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{clearPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{clearAllProxyInputRequests,getProxyInputRequests,hasProxyInputRequests}from"#harness/proxy-input-requests.js";import{clearPendingSessionLimitPrompt}from"#harness/input-requests.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{observeSessionActivity}from"#execution/session-activity-projection.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{emitCancelledTurn}from"#harness/cancelled-turn-emission.js";import{abandonAgentInvocationOwners,abandonRunningAgentTurns}from"#subagents/handles/transitions.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{getTurnUsageState,toUsage}from"#harness/turn-tag-state.js";async function settleCancelledTurnStep(a){"use step";let o=await readDurableSession(a.sessionState),s=await deserializeContext(a.serializedContext),c=s.require(ChannelKey),l=buildAdapterContext(c,s),u=s.require(BundleKey),d=resolveEffectiveAgentRuntime(u,s),f=hydrateDurableSession({compactionOverrides:{thresholdPercent:d.thresholdPercent},durable:o,turnAgent:d.turnAgent}),p=bindSessionInstrumentation({agentName:d.turnAgent.id,ctx:s,rootSessionId:f.rootSessionId??f.sessionId,sessionId:f.sessionId}),m=getHarnessEmissionState(o.state),h=[...getProxyInputRequests(o.state).values()].some(e=>e.kind===`session-limit`);if(!(isHarnessBetweenTurns(f)&&hasProxyInputRequests(o.state)&&!h)){let t=a.parentWritable.getWriter();try{let n=await withContextScope(s,f,async n=>{let baseEmit=async n=>{let r=await callAdapterEventHandler(c,n,l);setChannelContext(s,{...c,state:{...l.state}});let i=stampMessageStreamEvent(r);await t.write(encodeMessageStreamEvent(i)),observeSessionActivity({ctx:s,event:i,sessionId:f.sessionId}),await dispatchStreamEventHooks({ctx:s,event:i,registry:u.hookRegistry})};return{result:await emitCancelledTurn(p?.createHandleEvent({handleEvent:baseEmit,turnId:activeTurnId(m)})??baseEmit,m),session:n}});m=n.result,f=n.session}finally{await p?.flush(),t.releaseLock()}}let g=getWorkflowToolRuns(f.state);f=abandonAgentInvocationOwners(f,new Set(g.map(e=>e.runId)));let _=reconcileSessionContinuationToken(s,setHarnessEmissionState(clearPendingSessionLimitPrompt(clearAllProxyInputRequests(clearPendingWorkflowInterrupt(clearPendingCoordinationBatch(clearWorkflowToolRuns(abandonRunningAgentTurns({...f,outputSchema:void 0})))))),m)),v=getTurnUsageState(f.state)?.session,y={serializedContext:serializeContext(s),sessionState:createDurableSessionState({session:_})};return v===void 0?y:{...y,usage:toUsage(v)}}export{settleCancelledTurnStep};
|
|
@@ -7,6 +7,6 @@ export declare const WORKFLOW_ENTRY_NAME = "workflowEntry";
|
|
|
7
7
|
export declare const TURN_WORKFLOW_NAME = "turnWorkflow";
|
|
8
8
|
export declare const SESSION_TIMEOUT_WORKFLOW_NAME = "sessionTimeoutWorkflow";
|
|
9
9
|
export declare const TASK_RUN_WORKFLOW_NAME = "taskRunWorkflow";
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const WORKFLOW_TOOL_RUN_WORKFLOW_NAME = "workflowToolRunWorkflow";
|
|
11
11
|
export declare const ACTIVITY_COLLECTOR_WORKFLOW_NAME = "activityCollectorWorkflow";
|
|
12
12
|
export declare const STABLE_WORKFLOW_NAMES: ReadonlySet<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const WORKFLOW_ENTRY_NAME=`workflowEntry`,TURN_WORKFLOW_NAME=`turnWorkflow`,SESSION_TIMEOUT_WORKFLOW_NAME=`sessionTimeoutWorkflow`,TASK_RUN_WORKFLOW_NAME=`taskRunWorkflow`,
|
|
1
|
+
const WORKFLOW_ENTRY_NAME=`workflowEntry`,TURN_WORKFLOW_NAME=`turnWorkflow`,SESSION_TIMEOUT_WORKFLOW_NAME=`sessionTimeoutWorkflow`,TASK_RUN_WORKFLOW_NAME=`taskRunWorkflow`,WORKFLOW_TOOL_RUN_WORKFLOW_NAME=`workflowToolRunWorkflow`,ACTIVITY_COLLECTOR_WORKFLOW_NAME=`activityCollectorWorkflow`,STABLE_WORKFLOW_NAMES=new Set([WORKFLOW_ENTRY_NAME,TURN_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,TASK_RUN_WORKFLOW_NAME,WORKFLOW_TOOL_RUN_WORKFLOW_NAME,ACTIVITY_COLLECTOR_WORKFLOW_NAME]);export{ACTIVITY_COLLECTOR_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,STABLE_WORKFLOW_NAMES,TASK_RUN_WORKFLOW_NAME,TURN_WORKFLOW_NAME,WORKFLOW_ENTRY_NAME,WORKFLOW_TOOL_RUN_WORKFLOW_NAME};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ContinuationTokenKey,SessionCallbackKey,SessionIdKey}from"#context/keys.js";import{fireTaskEventCallbackStep}from"#
|
|
1
|
+
import{ContinuationTokenKey,SessionCallbackKey,SessionIdKey}from"#context/keys.js";import{fireTaskEventCallbackStep}from"#subagents/callback-step.js";async function forwardTaskEventToSessionCallback(e,t){let n=e.get(SessionCallbackKey);return n?.taskId===void 0||t.type!==`input.requested`&&t.type!==`authorization.required`&&t.type!==`authorization.completed`?!1:(await fireTaskEventCallbackStep({callback:n,childContinuationToken:e.require(ContinuationTokenKey),childSessionId:e.require(SessionIdKey),event:t}),!0)}export{forwardTaskEventToSessionCallback};
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WorkflowToolAuthorizationRequest, WorkflowToolRunRequestMessage } from "#execution/tools/workflow/messages.js";
|
|
2
|
+
import type { WorkflowToolRunTaskInputRequest } from "./workflow.js";
|
|
2
3
|
import type { AnswerHookRoute } from "#harness/proxy-input-requests.js";
|
|
3
|
-
import type
|
|
4
|
-
import { type TaskInboundAnswerInput, type TaskInboundAuthorizationEvent, type TaskInboundInputRequest, type TaskInboundUpdate, type TaskView } from "#tasks/types.js";
|
|
4
|
+
import { type TaskInboundAnswerInput, type TaskInboundUpdate, type TaskView } from "#tasks/types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Appends one full task view to the owning task run's `eve.task`
|
|
7
7
|
* stream. Only the task run workflow calls this, which is what makes
|
|
8
8
|
* the run the single writer readers can trust without re-validating.
|
|
9
9
|
*/
|
|
10
10
|
export declare function appendTaskViewStep(input: {
|
|
11
|
-
readonly activityObserver?: ActivityObserverConfig;
|
|
12
11
|
readonly view: TaskView;
|
|
13
12
|
}): Promise<void>;
|
|
14
|
-
export declare function projectTaskActivitySettlement(input: {
|
|
15
|
-
readonly activityObserver: ActivityObserverConfig | undefined;
|
|
16
|
-
readonly settledAt: string;
|
|
17
|
-
readonly view: TaskView;
|
|
18
|
-
}): readonly ActivityEventV1[];
|
|
19
|
-
/** Re-emits a task-owned child authorization event through the parent channel. */
|
|
20
|
-
export declare function wakeTaskAuthorizationParentStep(input: {
|
|
21
|
-
readonly request: TaskInboundAuthorizationEvent;
|
|
22
|
-
readonly taskId: string;
|
|
23
|
-
readonly token: string;
|
|
24
|
-
}): Promise<void>;
|
|
25
13
|
/**
|
|
26
14
|
* Wakes the parent session with a framework task notification.
|
|
27
15
|
*
|
|
@@ -40,9 +28,21 @@ export declare function wakeTaskUpdateParentStep(input: {
|
|
|
40
28
|
readonly update: TaskInboundUpdate;
|
|
41
29
|
readonly view: TaskView;
|
|
42
30
|
}): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
export declare function
|
|
45
|
-
readonly request:
|
|
31
|
+
/** Forwards one agent spawn or settlement request to the parent session. */
|
|
32
|
+
export declare function wakeTaskAgentRequestParentStep(input: {
|
|
33
|
+
readonly request: WorkflowToolRunRequestMessage;
|
|
34
|
+
readonly taskId: string;
|
|
35
|
+
readonly token: string;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
/** Re-emits a task child's authorization event through the parent channel. */
|
|
38
|
+
export declare function wakeTaskAuthorizationParentStep(input: {
|
|
39
|
+
readonly request: WorkflowToolAuthorizationRequest;
|
|
40
|
+
readonly taskId: string;
|
|
41
|
+
readonly token: string;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
/** Sends a workflow-body question to the owning parent's pre-model router. */
|
|
44
|
+
export declare function wakeWorkflowTaskInputRequestParentStep(input: {
|
|
45
|
+
readonly request: WorkflowToolRunTaskInputRequest;
|
|
46
46
|
readonly taskId: string;
|
|
47
47
|
readonly token: string;
|
|
48
48
|
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{getWritable}from"#compiled/@workflow/core/index.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{getWritable}from"#compiled/@workflow/core/index.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{resumeWorkflowToolRunAnswers}from"#execution/tools/workflow/answer.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{TASK_VIEW_STREAM_NAMESPACE,isTerminalTaskStatus,taskAuthorizationRequestId}from"#tasks/types.js";const log=createLogger(`execution.tasks.run`);async function appendTaskViewStep(e){"use step";let n=getWritable({namespace:TASK_VIEW_STREAM_NAMESPACE}).getWriter();try{await n.write(e.view)}finally{n.releaseLock()}}async function wakeTaskParentStep(e){"use step";let t={message:formatTaskNotification(e.view)};isTerminalTaskStatus(e.view.status)&&(t.task={views:[e.view]});let r={kind:`send`,payload:t,taskDeliveryId:`${e.view.taskId}:ready:${e.view.status}`};try{await resumeSessionInbox(e.token,r)}catch(t){if(isTaskWorkflowTargetGone(t)){log.warn(`task wake target is gone; the parent session already ended`,{status:e.view.status,taskId:e.view.taskId});return}throw t}}async function wakeTaskUpdateParentStep(e){"use step";let t={kind:`send`,payload:{message:`Background task ${e.view.taskId} (${e.view.metadata.name}) update: ${e.update.message}`},taskDeliveryId:`${e.view.taskId}:update:${e.update.updateEpoch}:${e.update.updateIndex}:${e.update.callId}`};try{await resumeSessionInbox(e.token,t)}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}async function wakeTaskAgentRequestParentStep(e){"use step";let t=e.request.request;if(t.kind!==`agent-invoke`&&t.kind!==`agent-settled`)throw Error(`Cannot forward task input as an agent request.`);let r={replyTo:e.request.replyTo,request:t,taskId:e.taskId},i=t.kind===`agent-invoke`?t.invocationId:`${t.result.callId}:settled`,a={kind:`send`,payload:{task:{agentRequests:[r]}},taskDeliveryId:`${e.taskId}:agent:${e.request.from.runId}:${i}`};try{await resumeSessionInbox(e.token,a)}catch(e){if(!isTaskWorkflowTargetGone(e))throw e}}async function wakeTaskAuthorizationParentStep(e){"use step";let{event:t}=e.request,r=t.event.data,i={task:{authorizationEvents:[{hookPayload:t,taskId:e.taskId}]}};t.event.type===`authorization.required`&&(i.message=`Background task ${e.taskId} needs authorization.`);let a={kind:`send`,payload:i,taskDeliveryId:`${e.taskId}:authorization:${t.event.type}:${r.turnId}:${r.stepIndex}:${r.sequence}:${taskAuthorizationRequestId(t.event)}`};try{await resumeSessionInbox(e.token,a)}catch(e){if(!isTaskWorkflowTargetGone(e))throw e}}async function wakeWorkflowTaskInputRequestParentStep(e){"use step";let t={kind:`send`,payload:{task:{inputRequests:[e.request.requests===void 0?{replyTo:e.request.replyTo,request:e.request.request,sequence:e.request.sequence,stepIndex:e.request.stepIndex,taskId:e.taskId,turnId:e.request.turnId}:{replyTo:e.request.replyTo,requests:e.request.requests,sequence:e.request.sequence,stepIndex:e.request.stepIndex,taskId:e.taskId,turnId:e.request.turnId}]}},taskDeliveryId:`${e.taskId}:input:${e.request.turnId}:${e.request.stepIndex}:${e.request.sequence}`};try{await resumeSessionInbox(e.token,t)}catch(e){if(!isTaskWorkflowTargetGone(e))throw e}}async function deliverTaskInputResponsesStep(e){"use step";let t=new Set(e.requestIds),i={auth:e.answer.auth,kind:`send`,payload:{inputResponses:e.answer.inputResponses.filter(e=>t.has(e.requestId))},taskDeliveryId:`${e.answer.taskId}:${[...e.requestIds].sort().join(`,`)}`};try{if(e.answer.childResponseUrl!==void 0){let t=await fetch(e.answer.childResponseUrl,{body:JSON.stringify({inputResponses:i.payload.inputResponses}),headers:{"content-type":`application/json`},method:`POST`,redirect:`error`});if(t.status===404)return`unreachable`;if(!t.ok)throw Error(`Remote task input delivery failed with HTTP ${t.status}.`)}else e.answerHook===void 0?await resumeSessionInbox(e.answer.childContinuationToken,i):await resumeWorkflowToolRunAnswers(e.answer.childContinuationToken,i.payload.inputResponses);return`delivered`}catch(t){if(isTaskWorkflowTargetGone(t))return log.warn(`task input answer target is gone; the child turn already ended`,{taskId:e.answer.taskId}),`unreachable`;throw t}}function formatTaskNotification(e){let t=`Background task ${e.taskId} (${e.metadata.name})`;return e.status===`input_required`?`${t} needs input.`:e.status===`completed`?`${t} is completed.\n\nResult:\n${formatTaskOutput(e.lastOutput.data)}`:e.status===`failed`?`${t} failed.\n\nError:\n${formatTaskOutput(e.lastOutput.data)}`:`${t} is cancelled.`}function formatTaskOutput(e){return typeof e==`string`?e:JSON.stringify(e)??`null`}export{appendTaskViewStep,deliverTaskInputResponsesStep,formatTaskNotification,wakeTaskAgentRequestParentStep,wakeTaskAuthorizationParentStep,wakeTaskParentStep,wakeTaskUpdateParentStep,wakeWorkflowTaskInputRequestParentStep};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TaskInboundUpdate } from "#tasks/types.js";
|
|
2
|
+
/** Forwards a local task-owned child's progress update to its active parent hook. */
|
|
3
|
+
export declare function forwardLocalTaskUpdateStep(input: {
|
|
4
|
+
readonly parentContinuationToken: string;
|
|
5
|
+
readonly update: TaskInboundUpdate;
|
|
6
|
+
}): Promise<void>;
|