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
|
@@ -13,6 +13,7 @@ export interface WorkflowEntryInput {
|
|
|
13
13
|
readonly limits?: RunInput["limits"];
|
|
14
14
|
readonly sessionTimeoutMs?: number | false;
|
|
15
15
|
readonly serializedContext: Record<string, unknown>;
|
|
16
|
+
readonly taskId?: string;
|
|
16
17
|
}
|
|
17
18
|
export interface WorkflowEntryResult {
|
|
18
19
|
readonly output: unknown;
|
|
@@ -26,7 +27,7 @@ export interface WorkflowEntryResult {
|
|
|
26
27
|
*
|
|
27
28
|
* Owns the stable command inbox, its channel alias, and the session lifecycle; each turn-owned
|
|
28
29
|
* turn resolves its own runtime actions in-line and reports back only
|
|
29
|
-
* `done`/`park` via the closed
|
|
30
|
+
* `done`/`park` via the closed-contract {@link NextDriverAction}. The
|
|
30
31
|
* only session-shape flag the driver reads (besides identity) is
|
|
31
32
|
* `hasProxyInputRequests`, the documented short-circuit for hook-payload
|
|
32
33
|
* routing to any descendant still active when the parent parks.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{CHANNEL_CONTEXT_KEY_NAME,SESSION_CALLBACK_CONTEXT_KEY_NAME}from"#context/key-names.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{isTaskOwnedSerializedContext}from"#execution/tasks/child/instructions.js";import{SUBAGENT_ADAPTER_KIND}from"#execution/subagent-adapter-state.js";import{activeTurnId}from"#harness/active-turn-id.js";import{readSerializedSubagentDepth}from"#harness/subagent-depth.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTaskTurnStartedStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#execution/delegated-parent-notification.js";import{createDelegatedSubagentErrorResult}from"#execution/delegated-parent-result.js";import{fireSessionCallbackStep}from"#execution/session-callback-step.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{finalizeDone}from"#execution/workflow-entry-finalization.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{finalizeTerminalSession}from"#execution/finalize-terminal-session.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";async function workflowEntry(r){"use workflow";let{workflowRunId:i,workflowStartedAt:l}=getWorkflowMetadata(),u=r.serializedContext[`eve.continuationToken`]||``,m=r.serializedContext[`eve.mode`],h=r.serializedContext[`eve.capabilities`],_=r.serializedContext[`eve.bundle`];r.serializedContext[`eve.sessionId`]=i;let S=getWritable(),w={activeTurnId:void 0,caller:void 0,callerResolved:!1,lastSessionState:void 0,serializedContext:r.serializedContext,terminalEmitted:!1};try{let a=readRootSessionId(r.serializedContext),o=readSerializedSubagentDepth(r.serializedContext),g=r.serializedContext[`eve.dynamicSubagentAgentConfig`],v=createSessionCommandInbox(),y=sessionCommandHookToken(i),b=`${i}:auth`,x,C;try{let[n,d,p,T]=await Promise.allSettled([createSessionStep({compiledArtifactsSource:_.source,continuationToken:u,dynamicSubagentAgentConfig:g,inheritedLimits:r.limits,nodeId:_.nodeId,outputSchema:r.input.outputSchema,rootSessionId:a,sessionId:i,subagentDepth:o,taskOwned:isTaskOwnedSerializedContext(r.serializedContext)}),v.claimStable(y),v.claimAuthorization(b),v.rekeyContinuation(u)]);if(n.status===`rejected`)throw n.reason;if(d.status===`rejected`)throw d.reason;if(p.status===`rejected`)throw p.reason;if(T.status===`rejected`){if(isHookConflictError(T.reason))return(r.activityCollectorRunId!==void 0||r.continuationConflictCommand!==void 0)&&await settleContinuationConflictStep({activityCollectorRunId:r.activityCollectorRunId,command:r.continuationConflictCommand,continuationToken:u,ownerSessionId:typeof T.reason.conflictingRunId==`string`?T.reason.conflictingRunId:void 0}),{output:``};throw T.reason}x=n.value.state,w.lastSessionState=x,hasGuaranteedRootLineage(r.serializedContext)||(w.caller=await resolveInitialTurnCallerStep({serializedContext:r.serializedContext})),w.callerResolved=!0,C=await runDriverLoop({capabilities:h,commandInbox:v,driverWritable:S,initialInput:{deliveryMetadata:r.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...r.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:r.input.message,context:r.input.context,outputSchema:r.input.outputSchema},readClientContext(r.input))],requestId:readChannelRequestId(r.serializedContext)},crashCleanupState:w,mode:m,serializedContext:r.serializedContext,sessionState:x,sessionTimeoutDeadline:r.sessionTimeoutMs===!1?void 0:new Date(l.getTime()+(r.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS)),stableCommandToken:y})}finally{await v.dispose()}return C.kind===`result`?C.result:await finalizeTerminalSession({caller:w.caller,driverWritable:S,mode:m,notifyCaller:C.notifyCaller,serializedContext:C.serializedContext,sessionState:C.sessionState,terminalState:w})}catch(e){if(w.lastSessionState!==void 0&&await terminateChildSessionsStep({serializedContext:w.serializedContext,sessionState:w.lastSessionState}),!w.terminalEmitted)if(await emitTerminalSessionFailureStep({error:normalizeSerializableError(e),parentWritable:S,serializedContext:w.serializedContext,turnId:w.activeTurnId}),m===`task`)await fireSessionCallbackStep({error:normalizeSerializableError(e),serializedContext:r.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(r.serializedContext,e),serializedContext:r.serializedContext});else{let t=await resolveCallerForCrash(w,r.serializedContext);t!==void 0&&await notifyTurnCallerStep({caller:t,lifecycle:`terminal`,sessionId:i,settled:{isError:!0,output:e}})}throw createSafeOuterWorkflowError()}}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}function hasGuaranteedRootLineage(e){if(e[SESSION_CALLBACK_CONTEXT_KEY_NAME]!==void 0||e[`eve.parentSession`]!==void 0||e[`eve.subagentDepth`]!==void 0)return!1;let t=e[CHANNEL_CONTEXT_KEY_NAME];if(typeof t!=`object`||!t)return!1;let n=Reflect.get(t,`kind`);return typeof n==`string`&&n!==SUBAGENT_ADAPTER_KIND}async function runDriverLoop(e){let t=e.commandInbox,n=new Map,nextParkedActivity=async r=>{let c=new Set(r.expectedAttemptIds);for(let e of n.keys())c.has(e)||n.delete(e);for(;;){if(c.size>0&&[...c].every(e=>n.has(e))){let e=[...c].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e}}let r=await nextTurnDelivery({awaitAuthorizationCallbacks:c.size>0,bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,commandInbox:t,deferDeliveries:e.mode===`task`&&c.size>0,driverWritable:e.driverWritable,seenTaskDeliveries:s,stateCursor:l});if(r.kind!==`authorization`)return r;for(let e of r.payloads){let t=e.authorizationCallback;typeof t?.attemptId==`string`&&c.has(t.attemptId)&&!n.has(t.attemptId)&&n.set(t.attemptId,e)}if(r.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e}}}},r=0,nextTurnControlToken=()=>`${e.sessionState.sessionId}:turn-control:${String(r++)}`,i=[],a=[],o=new Set,s=new Set,c=e.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:e.sessionTimeoutDeadline,token:e.stableCommandToken}),l=new SessionStateCursor({serializedContext:e.serializedContext,sessionState:e.sessionState}),d,runTurn=async n=>{let r=e.crashCleanupState.caller;r?.taskId!==void 0&&(s.add(r.taskId),await notifyTaskTurnStartedStep({caller:r,childSessionId:l.sessionState.sessionId,childTurnId:activeTurnId(l.sessionState.emissionState)}));let c=r===void 0?l.serializedContext:await bindTurnCallerContextStep({caller:r,serializedContext:l.serializedContext}),f=activeTurnId(l.sessionState.emissionState);e.crashCleanupState.activeTurnId=f;let p=await dispatchAndAwaitTurn({bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,capabilities:e.capabilities,commandInbox:t,controlToken:nextTurnControlToken(),delivery:n,mode:e.mode,parentWritable:e.driverWritable,serializedContext:c,seenTaskDeliveries:s,sessionState:l.sessionState});return e.crashCleanupState.activeTurnId=p.action.kind===`park`&&p.action.cancelled===!0?f:void 0,e.crashCleanupState.lastSessionState=p.action.sessionState,e.crashCleanupState.serializedContext=p.action.serializedContext,p.action.kind===`done`&&(e.crashCleanupState.terminalEmitted=!0),await d?.(),d=p.dispose,l.adoptState(p.action),p.action};try{await c?.start();let n=await runTurn(e.initialInput);for(;;){if(n.kind===`done`)return{kind:`result`,result:await finalizeDone({action:n,caller:e.crashCleanupState.caller,mode:e.mode})};if(n.kind!==`park`)throw Error(`Driver received unexpected turn action "${n.kind}".`);if(n.cancelled===!0){let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),e.crashCleanupState.activeTurnId=void 0,e.crashCleanupState.lastSessionState=l.sessionState,e.crashCleanupState.serializedContext=l.serializedContext;let n={caller:e.crashCleanupState.caller,sessionId:l.sessionState.sessionId};await notifyCancelledTaskCallerStep(t.usage===void 0?n:{...n,usage:t.usage})}l.sessionState.continuationToken&&await t.rekeyContinuation(l.sessionState.continuationToken);let r=n.settled;n.cancelled!==!0&&r!==void 0?(e.crashCleanupState.caller!==void 0&&await notifyTurnCallerStep({caller:e.crashCleanupState.caller,lifecycle:`parked`,sessionId:l.sessionState.sessionId,settled:r}),e.crashCleanupState.caller=void 0):n.cancelled===!0&&(e.crashCleanupState.caller=void 0);let i=await nextParkedActivity({expectedAttemptIds:n.authorizationAttemptIds??[]});if(e.crashCleanupState.lastSessionState=l.sessionState,e.crashCleanupState.serializedContext=l.serializedContext,i.kind===`authorization-resume`){n=await runTurn({kind:`deliver`,payloads:i.payloads});continue}if(i.kind===`expired`)return{kind:`terminal`,notifyCaller:!0,serializedContext:l.serializedContext,sessionState:l.sessionState};if(i.kind===`reset`)return{kind:`terminal`,notifyCaller:!1,serializedContext:l.serializedContext,sessionState:l.sessionState};if(i.kind===`clear`||i.kind===`compact`){n=await runTurn({kind:i.kind});continue}if(i.kind===`closed`)return{kind:`terminal`,notifyCaller:!1,serializedContext:l.serializedContext,sessionState:l.sessionState};if(i.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:l.serializedContext,sessionState:l.sessionState});let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),n={...n,settled:void 0},e.crashCleanupState.caller=void 0,e.crashCleanupState.lastSessionState=l.sessionState,e.crashCleanupState.serializedContext=l.serializedContext;continue}i.delivery.caller!==void 0&&(e.crashCleanupState.caller=i.delivery.caller),n=await runTurn(i.delivery)}}finally{await d?.(),await c?.dispose()}}export{workflowEntry};
|
|
1
|
+
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{fireSessionCallbackStep}from"#subagents/callback-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{createDelegatedSubagentErrorResult}from"#subagents/parent-result.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{rebaseTaskAgentHandleMutations}from"#subagents/handles/rebase.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{finalizeDone,finalizeExpiredSession}from"#execution/workflow-entry-finalization.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";async function workflowEntry(c){"use workflow";let{workflowRunId:d,workflowStartedAt:f}=getWorkflowMetadata(),p=c.serializedContext[`eve.continuationToken`]||``,v=c.serializedContext[`eve.mode`],y=c.serializedContext[`eve.capabilities`],b=c.serializedContext[`eve.bundle`];c.serializedContext[`eve.sessionId`]=d;let x=getWritable(),C={caller:void 0,callerResolved:!1,lastSessionState:void 0,serializedContext:c.serializedContext,terminalEmitted:!1};try{let r=readRootSessionId(c.serializedContext),i=c.serializedContext[`eve.dynamicSubagentAgentConfig`],l=createSessionCommandInbox(),u=sessionCommandHookToken(d),m=`${d}:auth`,h,g;try{let[n,s,_,S]=await Promise.allSettled([createSessionStep({compiledArtifactsSource:b.source,continuationToken:p,dynamicSubagentAgentConfig:i,inheritedLimits:c.limits,nodeId:b.nodeId,outputSchema:c.input.outputSchema,rootSessionId:r,sessionId:d,taskId:c.taskId}),l.claimStable(u),l.claimAuthorization(m),l.rekeyContinuation(p)]);if(n.status===`rejected`)throw n.reason;if(s.status===`rejected`)throw s.reason;if(_.status===`rejected`)throw _.reason;if(S.status===`rejected`){if(isHookConflictError(S.reason))return(c.activityCollectorRunId!==void 0||c.continuationConflictCommand!==void 0)&&await settleContinuationConflictStep({activityCollectorRunId:c.activityCollectorRunId,command:c.continuationConflictCommand,continuationToken:p,ownerSessionId:typeof S.reason.conflictingRunId==`string`?S.reason.conflictingRunId:void 0}),{output:``};throw S.reason}h=n.value.state,C.lastSessionState=h,C.caller=hasDelegatedCallerContext(c.serializedContext)?await resolveInitialTurnCallerStep({serializedContext:c.serializedContext}):void 0,C.callerResolved=!0,g=await runDriverLoop({capabilities:y,commandInbox:l,driverWritable:x,initialInput:{deliveryMetadata:c.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...c.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:c.input.message,context:c.input.context,outputSchema:c.input.outputSchema},readClientContext(c.input))],requestId:readChannelRequestId(c.serializedContext)},crashCleanupState:C,mode:v,serializedContext:c.serializedContext,sessionState:h,sessionTimeoutDeadline:c.sessionTimeoutMs===!1?void 0:new Date(f.getTime()+(c.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS)),stableCommandToken:u})}finally{await l.dispose()}return g.kind===`result`?g.result:await finalizeExpiredSession({caller:C.caller,driverWritable:x,mode:v,serializedContext:g.serializedContext,sessionState:g.sessionState,terminalState:C})}catch(e){let t=C.terminalEmitted;throw!C.terminalEmitted&&C.lastSessionState!==void 0&&await terminateChildSessionsStep({serializedContext:C.serializedContext,sessionState:C.lastSessionState}),C.terminalEmitted||=(await emitTerminalSessionFailureStep({error:normalizeSerializableError(e),parentWritable:x,serializedContext:C.serializedContext,turnId:C.turnId}),!0),t||(v===`task`?(await fireSessionCallbackStep({error:normalizeSerializableError(e),serializedContext:C.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(C.serializedContext,e),serializedContext:C.serializedContext})):(C.caller!==void 0||!C.callerResolved)&&await notifyTurnCallerStep({caller:await resolveCallerForCrash(C,C.serializedContext),lifecycle:`terminal`,sessionId:d,settled:{isError:!0,output:e}})),createSafeOuterWorkflowError()}}function hasDelegatedCallerContext(e){if(e[`eve.sessionCallback`]!==void 0)return!0;let t=e[`eve.channel`];return typeof t==`object`&&!!t&&Reflect.get(t,`kind`)===`subagent`}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runDriverLoop(e){let t=e.commandInbox,n=new Map,nextParkedActivity=async r=>{let c=new Set(r.expectedAttemptIds);for(let e of n.keys())c.has(e)||n.delete(e);for(;;){if(c.size>0&&[...c].every(e=>n.has(e))){let e=[...c].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e}}let r=await nextTurnDelivery({awaitAuthorizationCallbacks:c.size>0,bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,commandInbox:t,deferDeliveries:e.mode===`task`&&c.size>0,driverWritable:e.driverWritable,seenTaskDeliveries:s,stateCursor:l});if(r.kind!==`authorization`)return r;for(let e of r.payloads){let t=e.authorizationCallback;typeof t?.attemptId==`string`&&c.has(t.attemptId)&&!n.has(t.attemptId)&&n.set(t.attemptId,e)}if(r.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e}}}},r=0,nextTurnControlToken=()=>`${e.sessionState.sessionId}:turn-control:${String(r++)}`,i=[],a=[],o=new Set,s=new Set,l=new SessionStateCursor({serializedContext:e.serializedContext,sessionState:e.sessionState}),u=e.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:e.sessionTimeoutDeadline,token:e.stableCommandToken}),m,runTurn=async n=>{let c=l.sessionState,u=e.crashCleanupState.caller;u?.taskId!==void 0&&s.add(u.taskId);let d=u===void 0?l.serializedContext:await bindTurnCallerContextStep({caller:u,serializedContext:l.serializedContext});e.crashCleanupState.turnId=`turn_${String(r)}`;let p=await dispatchAndAwaitTurn({bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,capabilities:e.capabilities,commandInbox:t,controlToken:nextTurnControlToken(),delivery:n,mode:e.mode,parentWritable:e.driverWritable,serializedContext:d,seenTaskDeliveries:s,sessionState:l.sessionState});await m?.(),m=p.dispose;let h=l.sessionState===c?p.action:rebaseTaskAgentHandleMutations(p.action,l.sessionState,c);return l.adoptState(h),e.crashCleanupState.lastSessionState=l.sessionState,e.crashCleanupState.serializedContext=l.serializedContext,h};try{await u?.start();let n=await runTurn(e.initialInput);for(;;){if(n.kind===`done`)return{kind:`result`,result:await finalizeDone({action:n,caller:e.crashCleanupState.caller,mode:e.mode,terminalState:e.crashCleanupState})};if(n.kind!==`park`)throw Error(`Driver received unexpected turn action "${n.kind}".`);if(n.cancelled===!0){let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),e.crashCleanupState.serializedContext=l.serializedContext;let n={caller:e.crashCleanupState.caller,sessionId:l.sessionState.sessionId};await notifyCancelledTaskCallerStep(t.usage===void 0?n:{...n,usage:t.usage}),e.crashCleanupState.lastSessionState=l.sessionState}l.sessionState.continuationToken&&await t.rekeyContinuation(l.sessionState.continuationToken);let r=n.settled;n.cancelled!==!0&&r!==void 0?(e.crashCleanupState.caller!==void 0&&await notifyTurnCallerStep({caller:e.crashCleanupState.caller,lifecycle:`parked`,sessionId:l.sessionState.sessionId,settled:r}),e.crashCleanupState.caller=void 0):n.cancelled===!0&&(e.crashCleanupState.caller=void 0);let i=await nextParkedActivity({expectedAttemptIds:n.authorizationAttemptIds??[]});if(e.crashCleanupState.lastSessionState=l.sessionState,i.kind===`authorization-resume`){n=await runTurn({kind:`deliver`,payloads:i.payloads});continue}if(i.kind===`expired`)return{kind:`expired`,serializedContext:l.serializedContext,sessionState:l.sessionState};if(i.kind===`reset`)return{kind:`result`,result:await finalizeExpiredSession({caller:e.crashCleanupState.caller,driverWritable:e.driverWritable,mode:e.mode,serializedContext:l.serializedContext,sessionState:l.sessionState,terminalState:e.crashCleanupState})};if(i.kind===`clear`||i.kind===`compact`){n=await runTurn({kind:i.kind});continue}if(i.kind===`closed`)return{kind:`result`,result:await finalizeExpiredSession({caller:e.crashCleanupState.caller,driverWritable:e.driverWritable,mode:e.mode,serializedContext:l.serializedContext,sessionState:l.sessionState,terminalState:e.crashCleanupState})};if(i.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:l.serializedContext,sessionState:l.sessionState});let t=await settleCancelledTurnStep({parentWritable:e.driverWritable,serializedContext:l.serializedContext,sessionState:l.sessionState});l.adoptState(t),e.crashCleanupState.serializedContext=l.serializedContext,n={...n,settled:void 0},e.crashCleanupState.caller=void 0,e.crashCleanupState.lastSessionState=l.sessionState;continue}i.delivery.caller!==void 0&&(e.crashCleanupState.caller=i.delivery.caller),n=await runTurn(i.delivery)}}finally{await m?.(),await u?.dispose()}}export{workflowEntry};
|
|
@@ -36,7 +36,7 @@ export declare const activityCollectorWorkflowReference: {
|
|
|
36
36
|
workflowId: string;
|
|
37
37
|
};
|
|
38
38
|
/** Stable workflow reference for authored workflow tool runs. */
|
|
39
|
-
export declare const
|
|
39
|
+
export declare const workflowToolRunWorkflowReference: {
|
|
40
40
|
workflowId: string;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomBytes}from"node:crypto";import{createEveActivityRoutePath}from"#protocol/routes.js";import{createLogger,logError}from"#internal/logging.js";import{getChannelActivityPresentation}from"#channel/activity-renderer.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{ActivityObserverKey}from"#context/keys.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{normalizePersistedMessageStreamEvent}from"#protocol/message-version.js";import{cancelRun,getHookByToken,getRun,getWorld,start}from"#internal/workflow/runtime.js";import{
|
|
1
|
+
import{randomBytes}from"node:crypto";import{createEveActivityRoutePath}from"#protocol/routes.js";import{createLogger,logError}from"#internal/logging.js";import{getChannelActivityPresentation}from"#channel/activity-renderer.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{ActivityObserverKey}from"#context/keys.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{normalizePersistedMessageStreamEvent}from"#protocol/message-version.js";import{cancelRun,getHookByToken,getRun,getWorld,start}from"#internal/workflow/runtime.js";import{serializeContext}from"#context/serialize.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeSessionInbox}from"#execution/wire/session-inbox-resume.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{initializeSessionInstrumentation}from"#instrumentation/runtime.js";import{createWorkflowCallbackUrl,resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";import{buildInvocationAttributes}from"#internal/invocation/metadata.js";import{isAgentTraceContext}from"#tracing/agent-trace-context.js";import{ACTIVITY_COLLECTOR_WORKFLOW_NAME,SESSION_TIMEOUT_WORKFLOW_NAME,TASK_RUN_WORKFLOW_NAME,TURN_WORKFLOW_NAME,WORKFLOW_ENTRY_NAME,WORKFLOW_TOOL_RUN_WORKFLOW_NAME}from"#execution/stable-workflow-names.js";const EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),COMMAND_HOOK_READY_TIMEOUT_MS=3e4,STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},turnWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TURN_WORKFLOW_NAME}`},sessionTimeoutWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${SESSION_TIMEOUT_WORKFLOW_NAME}`},taskRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TASK_RUN_WORKFLOW_NAME}`},activityCollectorWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${ACTIVITY_COLLECTOR_WORKFLOW_NAME}`},workflowToolRunWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_TOOL_RUN_WORKFLOW_NAME}`};function createWorkflowRuntime(n){return{async createSession(a){let o=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:n.compiledArtifactsSource,nodeId:n.nodeId}),s=buildRunContext({bundle:o,dynamicSubagentAgentConfig:n.dynamicSubagentAgentConfig,run:a}),c=resolveEffectiveAgentRuntime(o,s);initializeSessionInstrumentation({agentName:c.turnAgent.id,ctx:s,parentTraceContext:a.parentTraceContext});let l=c.limits?.sessionTimeoutMs,u,d=a.activityObserver;if(a.parent===void 0&&d===void 0&&(getChannelActivityPresentation(a.adapter)?.renderers.length??0)>0){let n=serializeContext(s),r=randomBytes(32).toString(`base64url`),i={expiresAt:new Date(Date.now()+(typeof l==`number`?l:864e5)).toISOString(),serializedContext:n,token:r};try{u=(await startWorkflowOnCurrentDeployment(activityCollectorWorkflowReference,[i])).runId,d={sink:{url:createWorkflowCallbackUrl(resolveWorkflowCallbackBaseUrl(process.env.VERCEL_URL?`https://${process.env.VERCEL_URL}`:`http://localhost:3000`),createEveActivityRoutePath(r)),version:1}},s.set(ActivityObserverKey,d)}catch{await cancelActivityCollector(u),u=void 0,log.warn(`failed to start activity collector`)}}let f=serializeContext(s),p=readParentLineage(f),m={input:a.input,limits:a.limits,serializedContext:f},h=a.taskId??a.callback?.taskId;h!==void 0&&(m.taskId=h),u!==void 0&&(m.activityCollectorRunId=u),a.continuationConflictCommand!==void 0&&(m.continuationConflictCommand=a.continuationConflictCommand),l!==void 0&&(m.sessionTimeoutMs=l);let g={...p.sessionId===void 0?buildSessionAttributes({inputMessage:a.title??a.input.message,serializedContext:f}):buildSubagentRootAttributes({identity:{nodeId:o.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:p.callId,parentSessionId:p.sessionId,parentTurnId:p.turnId,rootSessionId:p.rootSessionId??p.sessionId,serializedContext:f}),...a.externalInvocation===void 0?{}:buildInvocationAttributes(a.externalInvocation)},_;try{_=await startWorkflowOnCurrentDeployment(workflowEntryReference,[m],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(g)})}catch(e){throw await cancelActivityCollector(u),logError(log,`failed to start workflow run`,e,{continuationToken:a.continuationToken}),e}let v,getEvents=()=>(v??=parseNdjsonStream(()=>getRun(_.runId).getReadable(),normalizePersistedEvent),v);return{get events(){return getEvents()},sessionId:_.runId}},async dispatchContinuation(e){return await dispatchWorkflowCommand(e.continuationToken,e.command)},async dispatchSession(e){return await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),e.command)},async getEventStream(e,t){return parseNdjsonStream(()=>getRun(e).getReadable({startIndex:t?.startIndex}),normalizePersistedEvent)},async getStreamTailIndex(e){let t=getRun(e).getReadable();try{return await t.getTailIndex()}finally{await t.cancel().catch(()=>{})}},async resolveContinuation(e){try{return{sessionId:(await getHookByToken(e)).runId}}catch(t){if(HookNotFoundError.is(t))return;throw logError(log,`failed to resolve session by continuation token`,t,{continuationToken:e}),t}}}}function normalizePersistedEvent(e){return normalizePersistedMessageStreamEvent(e)}async function cancelActivityCollector(e){if(e!==void 0)try{await cancelRun(await getWorld(),e,{cancelReason:`Root session creation did not complete`})}catch{log.warn(`failed to cancel unowned activity collector`)}}async function dispatchWorkflowCommand(e,t){let n;try{n=normalizeWorkflowHook(await resumeSessionInbox(e,t))}catch(n){if(isInactiveCommandTarget(n))return inactiveCommandResult(t);throw logError(log,`failed to dispatch session command`,n,{command:t.kind,token:e}),n}return t.kind===`reset`&&await waitForCommandHookRelease(sessionCommandHookToken(n.runId),n.runId),activeCommandResult(t,n.runId)}function activeCommandResult(e,t){return e.kind===`reset`?{previousSessionId:t,status:`reset`}:(e.kind,{sessionId:t,status:`accepted`})}function inactiveCommandResult(e){return e.kind===`send`?{status:`session_not_active`}:e.kind===`cancel`?{status:`no_active_turn`}:{status:`no_active_session`}}async function requestWorkflowTurnCancellation(e){let t={kind:`cancel`};return e.taskId!==void 0&&(t.taskId=e.taskId),e.turnId!==void 0&&(t.turnId=e.turnId),await dispatchWorkflowCommand(sessionCommandHookToken(e.sessionId),t)}function isInactiveCommandTarget(e){if(HookNotFoundError.is(e))return!0;for(let t of walkCauseChain(e))if(WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}async function waitForCommandHookOwner(e){let t=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;)try{return normalizeWorkflowHook(await getHookByToken(e))}catch(e){if(!HookNotFoundError.is(e)||Date.now()>=t)throw e;await new Promise(e=>setTimeout(e,20))}}async function waitForCommandHookRelease(e,t){let n=Date.now()+COMMAND_HOOK_READY_TIMEOUT_MS;for(;;){try{if(normalizeWorkflowHook(await getHookByToken(e)).runId!==t)return}catch(e){if(HookNotFoundError.is(e))return;throw e}if(Date.now()>=n)throw Error(`Timed out waiting for session "${t}" to release its command inbox.`);await new Promise(e=>setTimeout(e,20))}}async function startWorkflowOnCurrentDeployment(e,t,n){return await startWorkflowOnDeployment(e,t,process.env.VERCEL_DEPLOYMENT_ID?.trim()||void 0,n)}async function startWorkflowOnAcceptedDeployment(e,t,n,r){return n===void 0?await startWorkflowOnCurrentDeployment(e,t,r):await startWorkflowOnDeployment(e,t,n,r)}async function startWorkflowOnDeployment(e,t,n,r){return await withWorkflowStartContext(async()=>n===void 0?r===void 0?await start(e,t):await start(e,t,r):await start(e,t,{...r,deploymentId:n}))}async function withWorkflowStartContext(e){let t=context.active(),n=isAgentTraceContext(t)?trace.deleteSpan(t):t;return await context.with(n,e)}function normalizeWorkflowHook(e){if(typeof e!=`object`||!e||!(`runId`in e))throw Error(`Workflow hook did not include a run id.`);let t=e.runId;if(typeof t!=`string`||t.length===0)throw Error(`Workflow hook did not include a run id.`);return{runId:t}}export{activityCollectorWorkflowReference,createWorkflowRuntime,requestWorkflowTurnCancellation,sessionTimeoutWorkflowReference,startWorkflowOnAcceptedDeployment,startWorkflowOnCurrentDeployment,taskRunWorkflowReference,turnWorkflowReference,waitForCommandHookOwner,workflowEntryReference,workflowToolRunWorkflowReference};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler,defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,HandleEventKey,ModeKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,TasksEnabledKey,TurnTaskDeliveryKey,TurnTaskStateKey}from"#context/keys.js";import{createAuthorizationCompletedEvent,createSessionStartedEvent,createTurnStartedEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{dispatchDynamicSubagentEvent,refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{coalesceTurnInputs}from"#harness/messages.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{TASK_UPDATE_SESSION_INSTRUCTION,isTaskOwnedSerializedContext}from"#execution/tasks/child/instructions.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{activeTurnId}from"#harness/active-turn-id.js";import{preserveSerializedAgentTraceState}from"#tracing/agent-trace-context-store.js";import{deferMismatchedInlineTurnStep}from"#execution/accepted-delivery-deployment.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{getRuntimeActionKeysFromWorkflowInterrupt,isWorkflowRuntimeActionInterrupt}from"#harness/workflow-runtime-action-state.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{dispatchDynamicToolEvent,rebindMissingCompiledDynamicToolCallbacks,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}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{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{readTurnSleepDurationMs}from"#harness/turn-sleep.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{dispatchDynamicInstructionEvent,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchMemoryLifecycleEvent}from"#context/memory-event-lifecycle.js";import{preserveSerializedInstrumentationState}from"#instrumentation/state.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{derivePendingState}from"#execution/pending-turn-state.js";import{forwardTaskEventToSessionCallback}from"#execution/task-event-callback.js";import{resolveEffectiveOutputSchema}from"#execution/effective-output-schema.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{appendTaskAgentAnnouncement}from"#execution/tasks/parent/agent-views.js";import{resolveInitiatingTaskContext,resolveTaskDeliveryContext}from"#tasks/delivery-context.js";import{readRetainedBackgroundToolResult,runBackgroundStep}from"#execution/tasks/parent/tool-execution.js";import{prepareWorkflowPreambleTrace}from"#execution/workflow-trace-context.js";import{createExecutionHistoryView}from"#execution/history-view.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{preserveCancelledTurnMessage}from"#execution/cancelled-turn-message.js";function channelDeliveryErrorCode(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`&&t.length>0)return t}return`CHANNEL_DELIVERY_FAILED`}async function turnStep(a){"use step";let o=deferMismatchedInlineTurnStep(a);if(o!==void 0)return o;let s=a,c=await readDurableSession(s.sessionState),l=await deserializeContext(s.serializedContext);a.input?.kind===`deliver`&&(l.set(TurnTaskDeliveryKey,`none`),l.delete(TurnTaskStateKey));let u=l.require(ChannelKey),d=l.require(BundleKey),f=d.resolvedAgent.config?.experimental?.tasks===!0;l.set(TasksEnabledKey,f);let p=resolveEffectiveAgentRuntime(d,l),m=isTaskOwnedSerializedContext(s.serializedContext)&&f&&p.turnAgent.tools.some(e=>e.kind===`authored-tool`&&e.behavior?.handling?.kind===`dispatch`&&e.behavior.handling.target.kind===`task-update`);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&l.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let h=getPendingAuthorization(c.state),g;if(h&&s.input?.kind===`deliver`){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(h,s.input.payloads);if(s={...s,input:{...s.input,payloads:t}},e.length>0){let n=e.map(e=>e.result);l.set(PendingAuthorizationResultKey,n),c={...c,state:clearPendingAuthorization(c.state,n.map(e=>e.attemptId??e.name))},g=e,t.length===0&&(s={...s,input:void 0})}}s.input?.kind===`deliver`&&s.input.auth!==void 0&&l.set(AuthKey,s.input.auth??null);let _=hydrateDurableSession({compactionOverrides:{thresholdPercent:p.thresholdPercent},durable:c,turnAgent:p.turnAgent}),v=createExecutionHistoryView(_),y=bindSessionInstrumentation({agentName:p.turnAgent.id,ctx:l,rootSessionId:_.rootSessionId??_.sessionId,sessionId:_.sessionId}),b=getHarnessEmissionState(_.state);a.input?.kind===`deliver`&&await contextStorage.run(l,()=>y?.instrumentChannelDelivery({agentName:d.turnAgent.id,ctx:l,delivery:a.input,rootSessionId:_.rootSessionId??_.sessionId,sequence:b.sequence,sessionId:_.sessionId,turnId:activeTurnId(b)}));let failChannelDeliveries=async e=>{await contextStorage.run(l,()=>y?.instrumentChannelDelivery({ctx:l,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await y?.flush()},x=buildAdapterContext(u,l),S;if(s.input?.kind===`deliver`){let e=[];try{for(let n of s.input.payloads){let r=u.deliver?await u.deliver(n,x):defaultDeliverResult(n);r!=null&&e.push(r)}}catch(e){throw await failChannelDeliveries(e),e}S=e.length===0?void 0:e.reduce(coalesceTurnInputs)}else s.input?.kind===`runtime-action-result`&&(s.input.acceptedAtMsByCallId!==void 0&&l.set(RuntimeActionSettlementTimesKey,s.input.acceptedAtMsByCallId),S={runtimeActionResults:s.input.results});if(S!==void 0&&a.input?.kind===`deliver`&&a.input.taskDeliveryId!==void 0){let e=resolveTaskDeliveryContext({state:c.state,taskDeliveryId:a.input.taskDeliveryId});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),S={...S,context:[...S.context??[],e.context]})}if(f&&l.get(TurnTaskDeliveryKey)===`none`){let e=resolveInitiatingTaskContext({state:c.state,turnId:activeTurnId(b)});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),l.set(TurnTaskStateKey,e.context))}if(s.input?.kind===`deliver`&&setChannelContext(l,{...u,state:{...x.state}}),s.input?.kind===`deliver`&&S===void 0){await contextStorage.run(l,()=>y?.instrumentChannelDelivery({ctx:l,includeTurn:!1,outcome:`completed`})),await y?.flush();let e=reconcileSessionContinuationToken(l,_),t=serializeContext(l),r=e===_?s.sessionState:createDurableSessionState({session:e});return{action:`park`,...derivePendingState(e),serializedContext:t,sessionState:r,tasksEnabled:f}}let C=d.hookRegistry,w=bindDynamicConnections(l,d.resolvedAgent),T=d.resolvedAgent.dynamicInstructionsResolvers??[],E=d.resolvedAgent.dynamicSkillResolvers??[],D=d.subagentRegistry.dynamicResolvers??[],O=d.resolvedAgent.dynamicToolResolvers??[],k={...d.graph.root,turnAgent:p.turnAgent},A=buildRuntimeIdentity(k);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(d.compiledArtifactsSource);if(!b.sessionStarted)l.set(SessionDynamicSubagentRuntimeRevisionKey,t),l.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=createSessionStartedEvent({runtime:A});await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:l,resolvers:D,event:e,messages:v.initial.messages,runtimeRevision:t}),refreshDynamicSessionToolsForRuntimeRevision({ctx:l,resolvers:O,event:e,messages:v.initial.messages,runtimeRevision:t})]),await rebindMissingCompiledDynamicToolCallbacks({ctx:l,event:createTurnStartedEvent({sequence:b.sequence,turnId:activeTurnId(b)}),messages:v.initial.messages,resolvers:O})}}catch(e){throw await failChannelDeliveries(e),e}let j=s.parentWritable.getWriter(),emit=async t=>{let n=await callAdapterEventHandler(u,t,x);setChannelContext(l,{...u,state:{...x.state}});let r=stampMessageStreamEvent(n);return await j.write(encodeMessageStreamEvent(r)),r},handleEvent=async(e,t)=>{let n=await forwardTaskEventToSessionCallback(l,e)?stampMessageStreamEvent(e):await emit(e),r=await dispatchMemoryLifecycleEvent({abortSignal:s.abortSignal,appRoot:k.agent?.metadata?.appRoot??``,ctx:l,event:e,memories:k.agent?.memories??[],messages:t,nodeId:d.nodeId??`__root__`});observeSessionActivity({ctx:l,event:n,sessionId:_.sessionId}),await dispatchStreamEventHooks({ctx:l,registry:C,event:n}),n.type!==`step.started`&&await dispatchDynamicModelEvent({ctx:l,dynamicModel:p.turnAgent.dynamicModel,event:n,messages:r,scope:{moduleMap:d.moduleMap,nodeId:d.nodeId}}),await w.dispatch(n),await dispatchDynamicSubagentEvent({ctx:l,resolvers:D,event:n,messages:r}),await dispatchDynamicToolEvent({ctx:l,resolvers:O,event:n,messages:r}),await dispatchDynamicSkillEvent({ctx:l,resolvers:E,event:n,messages:r}),await dispatchDynamicInstructionEvent({ctx:l,resolvers:T,event:n,messages:r})},M=l.require(ModeKey),N;try{throwIfTurnAborted(s.abortSignal),N=await runBackgroundStep(l,_,async e=>{l.setVirtualContext(HandleEventKey,handleEvent);let t=resolveEffectiveOutputSchema({agentOutputSchema:p.turnAgent.outputSchema,input:S,mode:M,session:e});if(await w.rehydrate(b,A,isHarnessBetweenTurns(t)),g){let e=getHarnessEmissionState(t.state);if(isHarnessBetweenTurns(t)){prepareDynamicInstructionPreamble(l,v.messages(t));let n=[],r=await prepareWorkflowPreambleTrace({emissionState:e,instrumentation:y});try{e=await emitTurnPreamble(handleEvent,{},e,A,r)}finally{n=drainDynamicInstructionUserMessages(l),t={...t,history:[...t.history,...n]}}t=setHarnessEmissionState(t,e)}for(let{authorization:t,result:n}of g){let r=h?.challenges.find(e=>e.attemptId===n.attemptId)?.candidateId;await handleEvent(createAuthorizationCompletedEvent({attemptId:n.attemptId,authorization:t,candidateId:r,name:n.name,outcome:`authorized`,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId}))}}let n=l.get(CapabilitiesKey);return(async(e,t)=>{let r=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:p.thresholdPercent},session:e,systemPromptAdditions:m?[TASK_UPDATE_SESSION_INSTRUCTION]:void 0,turnAgent:p.turnAgent}),i=f?await appendTaskAgentAnnouncement(r,v.messages(r)):r;return createExecutionNodeStep({abortSignal:s.abortSignal,capabilities:n,clearOnly:s.input?.kind===`clear`,compactOnly:s.input?.kind===`compact`,createRuntime:createWorkflowRuntime,handleEvent,historyProjector:v.projector,historyView:v.prepare(i),instrumentation:y,mode:M,modelResolutionScope:{moduleMap:d.moduleMap,nodeId:d.nodeId},node:k,workflowMaxSubagents:r.workflowMaxSubagents})(i,t)})(t,S)})}catch(e){if(!isTurnCancellation(e))throw await failChannelDeliveries(e),e;j.releaseLock();let t=serializeContext(l),n=readRetainedBackgroundToolResult(l),r=await preserveCancelledTurnMessage(n?.backgroundTaskSession??_,S);return{action:`cancelled`,...n===void 0?{}:{backgroundTaskState:createDurableSessionState({session:r}),backgroundTasks:n.backgroundTasks},serializedContext:preserveSerializedInstrumentationState(preserveSerializedAgentTraceState(preserveSerializedSessionDynamicModelSelection(s.serializedContext,t),t),t),sessionState:createDurableSessionState({session:r})}}let P=reconcileSessionContinuationToken(l,N.session),F=serializeContext(l);N={...N,session:P};let I=createDurableSessionState({session:N.session}),L=readTurnSleepDurationMs(l),R=L===void 0?{}:{sleepDurationMs:L},z=N.backgroundTasks===void 0||N.backgroundTaskSession===void 0?{}:{backgroundTaskState:createDurableSessionState({session:N.backgroundTaskSession}),backgroundTasks:N.backgroundTasks};if(N.next!==null&&typeof N.next==`object`&&`done`in N.next){if(M===`task`&&hasPendingInputBatch(N.session.state))throw j.releaseLock(),Error(`Task mode cannot complete while input requests remain pending.`);await j.close();let e=getTurnUsageState(N.session.state)?.session;return{action:`done`,...z,output:N.next.output,isError:N.next.isError,...R,serializedContext:F,sessionState:I,usage:e===void 0?void 0:toUsage(e),usageDelta:takeSessionUsageDelta(N.session).delta}}if(N.next===null){j.releaseLock();let e=getPendingWorkflowInterrupt(N.session.state);if(e!==void 0&&isWorkflowRuntimeActionInterrupt(e.interrupt))return{action:`dispatch-workflow-runtime-actions`,...z,pendingRuntimeActionKeys:getRuntimeActionKeysFromWorkflowInterrupt(e.interrupt),...R,serializedContext:F,sessionState:I};let t=derivePendingState(N.session);if(N.settledTurn!==void 0){let{delta:e,session:n}=takeSessionUsageDelta(N.session);return{action:`park`,...z,...t,...R,serializedContext:F,sessionState:createDurableSessionState({session:n}),settled:{output:N.settledTurn.output,isError:N.settledTurn.isError,usage:e},tasksEnabled:f}}return{action:`park`,...z,...t,...R,serializedContext:F,sessionState:I,tasksEnabled:f}}return j.releaseLock(),{action:`continue`,...z,...R,serializedContext:F,sessionState:I}}export{turnStep};
|
|
1
|
+
import{callAdapterEventHandler,defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,HandleEventKey,ModeKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,TurnTaskDeliveryKey,TurnTaskStateKey}from"#context/keys.js";import{createAuthorizationCompletedEvent,createSessionStartedEvent,createTurnStartedEvent,encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{dispatchDynamicSubagentEvent,refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{coalesceTurnInputs}from"#harness/messages.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{activeTurnId}from"#harness/active-turn-id.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{preserveSerializedAgentTraceState}from"#tracing/agent-trace-context-store.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{getPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{getWorkflowTaskCallIds,isWorkflowTaskInterrupt}from"#harness/workflow-task-state.js";import{TASK_UPDATE_SESSION_INSTRUCTION}from"#tools/framework/task-update.js";import{deferMismatchedInlineTurnStep}from"#execution/accepted-delivery-deployment.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{dispatchDynamicToolEvent,rebindMissingCompiledDynamicToolCallbacks,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}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{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{getTurnUsageState,takeSessionUsageDelta,toUsage}from"#harness/turn-tag-state.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{readTurnSleepDurationMs}from"#harness/turn-sleep.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{dispatchDynamicInstructionEvent,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import{dispatchDynamicSkillEvent}from"#context/dynamic-skill-lifecycle.js";import{dispatchMemoryLifecycleEvent}from"#context/memory-event-lifecycle.js";import{preserveSerializedInstrumentationState}from"#instrumentation/state.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{derivePendingState}from"#execution/pending-turn-state.js";import{forwardTaskEventToSessionCallback}from"#execution/task-event-callback.js";import{resolveEffectiveOutputSchema}from"#execution/effective-output-schema.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{resolveInitiatingTaskContext,resolveTaskDeliveryContext}from"#tasks/delivery-context.js";import{readRetainedBackgroundToolResult,runBackgroundStep}from"#execution/tasks/parent/tool-execution.js";import{prepareWorkflowPreambleTrace}from"#execution/workflow-trace-context.js";import{createExecutionHistoryView}from"#execution/history-view.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{preserveCancelledTurnMessage}from"#execution/cancelled-turn-message.js";function channelDeliveryErrorCode(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`&&t.length>0)return t}return`CHANNEL_DELIVERY_FAILED`}async function turnStep(a){"use step";let o=deferMismatchedInlineTurnStep(a);if(o!==void 0)return o;let s=a,c=await readDurableSession(s.sessionState),l=await deserializeContext(s.serializedContext);a.input?.kind===`deliver`&&(l.set(TurnTaskDeliveryKey,`none`),l.delete(TurnTaskStateKey));let u=l.require(ChannelKey),d=l.require(BundleKey),f=resolveEffectiveAgentRuntime(d,l),p=c.taskId!==void 0&&f.turnAgent.tools.some(e=>e.kind===`authored-tool`&&e.behavior?.handling?.kind===`dispatch`&&e.behavior.handling.target.kind===`task-update`);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&l.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let m=getPendingAuthorization(c.state),h;if(m&&s.input?.kind===`deliver`){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(m,s.input.payloads);if(s={...s,input:{...s.input,payloads:t}},e.length>0){let n=e.map(e=>e.result);l.set(PendingAuthorizationResultKey,n),c={...c,state:clearPendingAuthorization(c.state,n.map(e=>e.attemptId??e.name))},h=e,t.length===0&&(s={...s,input:void 0})}}s.input?.kind===`deliver`&&s.input.auth!==void 0&&l.set(AuthKey,s.input.auth??null);let g=hydrateDurableSession({compactionOverrides:{thresholdPercent:f.thresholdPercent},durable:c,turnAgent:f.turnAgent}),_=createExecutionHistoryView(g),v=bindSessionInstrumentation({agentName:f.turnAgent.id,ctx:l,rootSessionId:g.rootSessionId??g.sessionId,sessionId:g.sessionId}),y=getHarnessEmissionState(g.state);a.input?.kind===`deliver`&&await contextStorage.run(l,()=>v?.instrumentChannelDelivery({agentName:d.turnAgent.id,ctx:l,delivery:a.input,rootSessionId:g.rootSessionId??g.sessionId,sequence:y.sequence,sessionId:g.sessionId,turnId:activeTurnId(y)}));let failChannelDeliveries=async e=>{await contextStorage.run(l,()=>v?.instrumentChannelDelivery({ctx:l,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await v?.flush()},b=buildAdapterContext(u,l),x;if(s.input?.kind===`deliver`){let e=[];try{for(let n of s.input.payloads){let r=u.deliver?await u.deliver(n,b):defaultDeliverResult(n);r!=null&&e.push(r)}}catch(e){throw await failChannelDeliveries(e),e}x=e.length===0?void 0:e.reduce(coalesceTurnInputs)}else s.input?.kind===`runtime-action-result`&&(s.input.acceptedAtMsByCallId!==void 0&&l.set(RuntimeActionSettlementTimesKey,s.input.acceptedAtMsByCallId),x={runtimeActionResults:s.input.results});if(x!==void 0&&a.input?.kind===`deliver`&&a.input.taskDeliveryId!==void 0){let e=resolveTaskDeliveryContext({state:c.state,taskDeliveryId:a.input.taskDeliveryId});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),x={...x,context:[...x.context??[],e.context]})}if(l.get(TurnTaskDeliveryKey)===`none`){let e=resolveInitiatingTaskContext({state:c.state,turnId:activeTurnId(y)});e!==void 0&&(l.set(TurnTaskDeliveryKey,e.phase),l.set(TurnTaskStateKey,e.context))}if(s.input?.kind===`deliver`&&setChannelContext(l,{...u,state:{...b.state}}),s.input?.kind===`deliver`&&x===void 0){await contextStorage.run(l,()=>v?.instrumentChannelDelivery({ctx:l,includeTurn:!1,outcome:`completed`})),await v?.flush();let e=reconcileSessionContinuationToken(l,g),t=serializeContext(l),r=e===g?s.sessionState:createDurableSessionState({session:e});return{action:`park`,...derivePendingState(e),serializedContext:t,sessionState:r}}let S=d.hookRegistry,C=bindDynamicConnections(l,d.resolvedAgent),w=d.resolvedAgent.dynamicInstructionsResolvers??[],T=d.resolvedAgent.dynamicSkillResolvers??[],E=d.subagentRegistry.dynamicResolvers??[],D=d.resolvedAgent.dynamicToolResolvers??[],O={...d.graph.root,turnAgent:f.turnAgent},k=buildRuntimeIdentity(O);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(d.compiledArtifactsSource);if(!y.sessionStarted)l.set(SessionDynamicSubagentRuntimeRevisionKey,t),l.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=createSessionStartedEvent({runtime:k});await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:l,resolvers:E,event:e,messages:_.initial.messages,runtimeRevision:t}),refreshDynamicSessionToolsForRuntimeRevision({ctx:l,resolvers:D,event:e,messages:_.initial.messages,runtimeRevision:t})]),await rebindMissingCompiledDynamicToolCallbacks({ctx:l,event:createTurnStartedEvent({sequence:y.sequence,turnId:activeTurnId(y)}),messages:_.initial.messages,resolvers:D})}}catch(e){throw await failChannelDeliveries(e),e}let A=s.parentWritable.getWriter(),emit=async t=>{let n=await callAdapterEventHandler(u,t,b);setChannelContext(l,{...u,state:{...b.state}});let r=stampMessageStreamEvent(n);return await A.write(encodeMessageStreamEvent(r)),r},handleEvent=async(e,t)=>{let n=await forwardTaskEventToSessionCallback(l,e)?stampMessageStreamEvent(e):await emit(e),r=await dispatchMemoryLifecycleEvent({abortSignal:s.abortSignal,appRoot:O.agent?.metadata?.appRoot??``,ctx:l,event:e,memories:O.agent?.memories??[],messages:t,nodeId:d.nodeId??`__root__`});observeSessionActivity({ctx:l,event:n,sessionId:g.sessionId}),await dispatchStreamEventHooks({ctx:l,registry:S,event:n}),n.type!==`step.started`&&await dispatchDynamicModelEvent({ctx:l,dynamicModel:f.turnAgent.dynamicModel,event:n,messages:r,scope:{moduleMap:d.moduleMap,nodeId:d.nodeId}}),await C.dispatch(n),await dispatchDynamicSubagentEvent({ctx:l,resolvers:E,event:n,messages:r}),await dispatchDynamicToolEvent({ctx:l,resolvers:D,event:n,messages:r}),await dispatchDynamicSkillEvent({ctx:l,resolvers:T,event:n,messages:r}),await dispatchDynamicInstructionEvent({ctx:l,resolvers:w,event:n,messages:r})},j=l.require(ModeKey),M;try{throwIfTurnAborted(s.abortSignal),M=await runBackgroundStep(l,g,async e=>{l.setVirtualContext(HandleEventKey,handleEvent);let t=resolveEffectiveOutputSchema({agentOutputSchema:f.turnAgent.outputSchema,input:x,mode:j,session:e});if(await C.rehydrate(y,k,isHarnessBetweenTurns(t)),h){let e=getHarnessEmissionState(t.state);if(isHarnessBetweenTurns(t)){prepareDynamicInstructionPreamble(l,_.messages(t));let n=[],r=await prepareWorkflowPreambleTrace({emissionState:e,instrumentation:v});try{e=await emitTurnPreamble(handleEvent,{},e,k,r)}finally{n=drainDynamicInstructionUserMessages(l),t={...t,history:[...t.history,...n]}}t=setHarnessEmissionState(t,e)}for(let{authorization:t,result:n}of h){let r=m?.challenges.find(e=>e.attemptId===n.attemptId)?.candidateId;await handleEvent(createAuthorizationCompletedEvent({attemptId:n.attemptId,authorization:t,candidateId:r,name:n.name,outcome:`authorized`,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId}))}}let n=l.get(CapabilitiesKey);return(async(e,t)=>{let r=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:f.thresholdPercent},session:e,systemPromptAdditions:p?[TASK_UPDATE_SESSION_INSTRUCTION]:void 0,turnAgent:f.turnAgent}),i=r;return createExecutionNodeStep({abortSignal:s.abortSignal,capabilities:n,clearOnly:s.input?.kind===`clear`,compactOnly:s.input?.kind===`compact`,createRuntime:createWorkflowRuntime,handleEvent,historyProjector:_.projector,historyView:_.prepare(i),instrumentation:v,mode:j,modelResolutionScope:{moduleMap:d.moduleMap,nodeId:d.nodeId},node:O,workflowMaxSubagents:r.workflowMaxSubagents})(i,t)})(t,x)})}catch(e){if(!isTurnCancellation(e))throw await failChannelDeliveries(e),e;A.releaseLock();let t=serializeContext(l),n=readRetainedBackgroundToolResult(l),r=await preserveCancelledTurnMessage(n?.backgroundTaskSession??g,x);return{action:`cancelled`,...n===void 0?{}:{backgroundTaskState:createDurableSessionState({session:r}),backgroundTasks:n.backgroundTasks},serializedContext:preserveSerializedInstrumentationState(preserveSerializedAgentTraceState(preserveSerializedSessionDynamicModelSelection(s.serializedContext,t),t),t),sessionState:createDurableSessionState({session:r})}}let N=reconcileSessionContinuationToken(l,M.session),P=serializeContext(l);M={...M,session:N};let F=createDurableSessionState({session:M.session}),I=readTurnSleepDurationMs(l),L=I===void 0?{}:{sleepDurationMs:I},R=M.backgroundTasks===void 0||M.backgroundTaskSession===void 0?{}:{backgroundTaskState:createDurableSessionState({session:M.backgroundTaskSession}),backgroundTasks:M.backgroundTasks};if(M.next!==null&&typeof M.next==`object`&&`done`in M.next){if(j===`task`&&hasPendingInputBatch(M.session.state))throw A.releaseLock(),Error(`Task mode cannot complete while input requests remain pending.`);await A.close();let e=getTurnUsageState(M.session.state)?.session;return{action:`done`,...R,output:M.next.output,isError:M.next.isError,...L,serializedContext:P,sessionState:F,usage:e===void 0?void 0:toUsage(e),usageDelta:takeSessionUsageDelta(M.session).delta}}if(M.next===null){A.releaseLock();let e=getPendingWorkflowInterrupt(M.session.state);if(e!==void 0&&isWorkflowTaskInterrupt(e.interrupt))return{action:`dispatch-workflow-tasks`,...R,pendingTaskCallIds:getWorkflowTaskCallIds(e.interrupt),...L,serializedContext:P,sessionState:F};let t=derivePendingState(M.session);if(M.settledTurn!==void 0){let{delta:e,session:n}=takeSessionUsageDelta(M.session);return{action:`park`,...R,...t,...L,serializedContext:P,sessionState:createDurableSessionState({session:n}),settled:{output:M.settledTurn.output,isError:M.settledTurn.isError,usage:e}}}return{action:`park`,...R,...t,...L,serializedContext:P,sessionState:F}}return A.releaseLock(),{action:`continue`,...R,...L,serializedContext:P,sessionState:F}}export{turnStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createAgentSourceRegistry,defineProgrammaticAgentSource,loadProgrammaticModuleNamespace,memoizeModuleNamespaceFactories}from"#compiler/source-graph.js";const revision=`eve@${resolveInstalledPackageInfo().version}:compiled-manifest-v46`,localDefaults=defineProgrammaticAgentSource({id:`eve:defaults`,revision,modules:[{logicalPath:`agent.ts`,loadNamespace:()=>import(`#framework/sources/modules/agent.js`)},{logicalPath:`sandbox.ts`,semanticRevision:`eve:default-sandbox:v1`,loadNamespace:()=>import(`#framework/sources/modules/sandbox.js`)},{logicalPath:`tools/bash.ts`,loadNamespace:()=>import(`#tools/provided/bash.js`)},{logicalPath:`tools/read_file.ts`,loadNamespace:()=>import(`#tools/provided/read-file.js`)},{logicalPath:`tools/write_file.ts`,loadNamespace:()=>import(`#tools/provided/write-file.js`)},{logicalPath:`tools/todo.ts`,loadNamespace:()=>import(`#tools/provided/todo.js`)},{logicalPath:`tools/web_fetch.ts`,loadNamespace:()=>import(`#tools/provided/web-fetch.js`)},{logicalPath:`tools/load_skill.ts`,loadNamespace:()=>import(`#tools/provided/load-skill.js`)},{logicalPath:`tools/connection_search.ts`,loadNamespace:()=>import(`#tools/framework/connection-search.js`)},{logicalPath:`tools/ask_question.ts`,loadNamespace:()=>import(`#tools/framework/ask-question.js`)},{logicalPath:`tools/
|
|
1
|
+
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createAgentSourceRegistry,defineProgrammaticAgentSource,loadProgrammaticModuleNamespace,memoizeModuleNamespaceFactories}from"#compiler/source-graph.js";const revision=`eve@${resolveInstalledPackageInfo().version}:compiled-manifest-v46`,localDefaults=defineProgrammaticAgentSource({id:`eve:defaults`,revision,modules:[{logicalPath:`agent.ts`,loadNamespace:()=>import(`#framework/sources/modules/agent.js`)},{logicalPath:`sandbox.ts`,semanticRevision:`eve:default-sandbox:v1`,loadNamespace:()=>import(`#framework/sources/modules/sandbox.js`)},{logicalPath:`tools/bash.ts`,loadNamespace:()=>import(`#tools/provided/bash.js`)},{logicalPath:`tools/read_file.ts`,loadNamespace:()=>import(`#tools/provided/read-file.js`)},{logicalPath:`tools/write_file.ts`,loadNamespace:()=>import(`#tools/provided/write-file.js`)},{logicalPath:`tools/todo.ts`,loadNamespace:()=>import(`#tools/provided/todo.js`)},{logicalPath:`tools/web_fetch.ts`,loadNamespace:()=>import(`#tools/provided/web-fetch.js`)},{logicalPath:`tools/load_skill.ts`,loadNamespace:()=>import(`#tools/provided/load-skill.js`)},{logicalPath:`tools/connection_search.ts`,loadNamespace:()=>import(`#tools/framework/connection-search.js`)},{logicalPath:`tools/ask_question.ts`,loadNamespace:()=>import(`#tools/framework/ask-question.js`)},{logicalPath:`tools/task_update.ts`,loadNamespace:()=>import(`#tools/framework/task-update.js`)},{logicalPath:`tools/task_cancel.ts`,loadNamespace:()=>import(`#tools/framework/task-cancel.js`)},{logicalPath:`tools/web_search.ts`,loadNamespace:()=>import(`#tools/provided/web-search.js`)}]}),rootDefaults=defineProgrammaticAgentSource({id:`eve:root-defaults`,revision,modules:[{logicalPath:`tools/agent.ts`,loadNamespace:()=>import(`#tools/framework/agent.js`)},{logicalPath:`channels/eve.ts`,loadNamespace:()=>import(`#framework/sources/modules/eve-channel.js`)},{logicalPath:`channels/home.ts`,loadNamespace:()=>import(`#framework/sources/modules/home-channel.js`)}]}),memoryWrapperTemplateSource=defineProgrammaticAgentSource({id:`eve:memory-wrapper`,revision,modules:[{logicalPath:`tools/memory-wrapper.ts`,loadNamespace:async e=>{let{loadMemoryWrapperNamespace:t}=await import(`#framework/sources/modules/memory-wrapper.js`);return await t(e)}}]}),frameworkAgentSourceRegistry=createAgentSourceRegistry([{applyTo:`all-local-nodes`,source:localDefaults},{applyTo:`root`,source:rootDefaults}],{templates:[memoryWrapperTemplateSource]}),memoryWrapperTemplate=frameworkAgentSourceRegistry.templates.get(memoryWrapperTemplateSource.id);async function loadFrameworkProgrammaticModule(e,t){return memoizeModuleNamespaceFactories(await loadProgrammaticModuleNamespace({backing:e,dependencyNamespaces:t,registries:[frameworkAgentSourceRegistry]}))}export{frameworkAgentSourceRegistry,loadFrameworkProgrammaticModule,memoryWrapperTemplate};
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import type { ToolSet } from "ai";
|
|
2
2
|
import type { HarnessToolDefinition } from "#harness/execute-tool.js";
|
|
3
3
|
import type { HarnessSession, HarnessToolMap } from "#harness/types.js";
|
|
4
|
-
type AdvertisedToolSession = Pick<HarnessSession, "rootSessionId" | "
|
|
4
|
+
type AdvertisedToolSession = Pick<HarnessSession, "rootSessionId" | "taskId">;
|
|
5
5
|
type AdvertisedToolMapInput = {
|
|
6
|
-
readonly canRequestInput?: boolean;
|
|
7
|
-
readonly delegatedCaller?: boolean;
|
|
8
6
|
readonly session: AdvertisedToolSession;
|
|
9
7
|
readonly tools: HarnessToolMap;
|
|
10
8
|
};
|
|
11
9
|
type AdvertisedToolDefinitionsInput = {
|
|
12
|
-
readonly canRequestInput?: boolean;
|
|
13
|
-
readonly delegatedCaller?: boolean;
|
|
14
10
|
readonly session: AdvertisedToolSession;
|
|
15
11
|
readonly tools: readonly HarnessToolDefinition[];
|
|
16
12
|
};
|
|
17
13
|
type AdvertisedModelToolsInput = {
|
|
18
|
-
readonly canRequestInput?: boolean;
|
|
19
|
-
readonly delegatedCaller?: boolean;
|
|
20
14
|
readonly modelTools: ToolSet;
|
|
21
15
|
readonly session: HarnessSession;
|
|
22
16
|
readonly tools: HarnessToolMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ensureWorkflowContinuationSecurity,getWorkflowContinuationSecurity}from"#harness/workflow-continuation-security.js";import{applyWorkflowTool}from"#harness/workflow-sandbox.js";function getAdvertisedTools(e){return`modelTools`in e?getAdvertisedModelTools(e):isToolDefinitionList(e.tools)?filterUnavailableToolDefinitions(e.tools,e.session):filterUnavailableToolMap(e.tools,e.session)}async function getAdvertisedModelTools(r){let i=filterUnavailableToolMap(r.tools,r.session);if(r.workflow===void 0)return{harnessTools:i,modelTools:r.modelTools,session:r.session};let a=filterWorkflowHostToolsForRootSession(i,r.session);if(a.size===0)return{harnessTools:i,modelTools:r.modelTools,session:r.session};let o=ensureWorkflowContinuationSecurity(r.session),{modelTools:s}=await applyWorkflowTool({continuationSecurity:getWorkflowContinuationSecurity(o),harnessTools:a,maxSubagents:r.workflow.maxSubagents,tools:r.modelTools});return{harnessTools:i,modelTools:s,session:o}}function filterUnavailableToolDefinitions(e,t){let n=[];for(let r of e)shouldHideTool(r,t)||n.push(r);return n}function filterUnavailableToolMap(e,t){let n=new Map;for(let[r,i]of e)shouldHideTool(i,t)||n.set(r,i);return n}function filterWorkflowHostToolsForRootSession(e,t){let n=new Map;if(t.rootSessionId!==void 0)return n;for(let[t,r]of e)r.resultKind===`subagent`&&n.set(t,r);return n}function shouldHideTool(e,t){let n=t.rootSessionId!==void 0;return e.rootOnly===!0||e.behavior?.availability.includes(`root-session`)===!0?n:e.behavior?.availability.includes(`delegated-task-child`)===!0&&t.taskId===void 0}function isToolDefinitionList(e){return Array.isArray(e)}export{getAdvertisedTools};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { ContextKey } from "#context/key.js";
|
|
2
2
|
import type { ToolExecuteOptions } from "#tools/definition.js";
|
|
3
3
|
import type { TaskExec } from "#tools/task.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { AgentView } from "#subagents/handles/prompt.js";
|
|
5
|
+
import type { JsonValue } from "#shared/json.js";
|
|
5
6
|
export interface BackgroundExecutableTool {
|
|
6
|
-
readonly behavior?: PreparedToolBehavior;
|
|
7
7
|
readonly execute: (input: unknown, options: ToolExecuteOptions, task: TaskExec) => unknown;
|
|
8
|
+
readonly executeInput?: (input: unknown) => JsonValue;
|
|
8
9
|
readonly name: string;
|
|
10
|
+
readonly nodeId?: string;
|
|
11
|
+
readonly resultKind?: "subagent" | "tool";
|
|
12
|
+
/** Present when the execute body runs in the task-owned durable workflow. */
|
|
13
|
+
readonly workflowId?: string;
|
|
9
14
|
}
|
|
10
15
|
export interface BackgroundToolCall {
|
|
11
16
|
readonly callId: string;
|
|
@@ -22,6 +27,7 @@ export interface BackgroundToolCallBatch {
|
|
|
22
27
|
setTool(name: string, definition?: BackgroundExecutableTool): void;
|
|
23
28
|
}
|
|
24
29
|
export interface BackgroundToolExecutor {
|
|
30
|
+
readAgentViews?(): Promise<readonly AgentView[]>;
|
|
25
31
|
execute(input: {
|
|
26
32
|
readonly batch: BackgroundToolCallBatch;
|
|
27
33
|
readonly definition: BackgroundExecutableTool;
|
|
@@ -1,72 +1,79 @@
|
|
|
1
1
|
import type { ModelMessage, ToolSet, TypedToolCall } from "ai";
|
|
2
|
-
import type { RuntimeActionRequest } from "#shared/action-types.js";
|
|
3
|
-
import type { PendingDispatchAction } from "#shared/dispatch-action.js";
|
|
2
|
+
import type { RuntimeActionRequest, RuntimeToolCallActionRequest, RuntimeWorkflowTaskRequest } from "#shared/action-types.js";
|
|
4
3
|
import { type JsonObject } from "#shared/json.js";
|
|
5
4
|
import type { HarnessEmitFn, HarnessSession, HarnessToolMap, SessionStateMap, StepInput } from "#harness/types.js";
|
|
6
5
|
/**
|
|
7
|
-
* Serializable event coordinates for one pending
|
|
6
|
+
* Serializable event coordinates for one pending coordination batch.
|
|
8
7
|
*
|
|
9
8
|
* Runtime action results are projected back onto the parent stream using the
|
|
10
9
|
* same turn and step identity as the originating `actions.requested` batch.
|
|
11
10
|
*/
|
|
12
|
-
interface
|
|
11
|
+
interface PendingCoordinationEventMetadata {
|
|
13
12
|
readonly sequence: number;
|
|
14
13
|
readonly stepIndex: number;
|
|
15
14
|
readonly turnId: string;
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
|
-
* Serializable pending
|
|
17
|
+
* Serializable pending coordination batch stored on `session.state`.
|
|
19
18
|
*
|
|
20
19
|
* Child ownership does not live here: the agent handle store records every
|
|
21
20
|
* dispatched child (from before its start side effect) and is the sole
|
|
22
21
|
* authority for continuing, settling, and cancelling children.
|
|
23
22
|
*/
|
|
24
|
-
export interface
|
|
25
|
-
|
|
26
|
-
readonly
|
|
23
|
+
export interface PendingCoordinationBatch {
|
|
24
|
+
/** Framework task controls deferred to the turn owner. */
|
|
25
|
+
readonly runtimeActions: readonly RuntimeToolCallActionRequest[];
|
|
26
|
+
/** Authored-tool and subagent workflow tasks pending coordination. */
|
|
27
|
+
readonly tasks: readonly RuntimeWorkflowTaskRequest[];
|
|
28
|
+
readonly event: PendingCoordinationEventMetadata;
|
|
29
|
+
readonly localFanoutSize?: number;
|
|
27
30
|
readonly responseMessages: readonly ModelMessage[];
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
|
-
* Outcome of resolving a pending
|
|
33
|
+
* Outcome of resolving a pending coordination batch.
|
|
31
34
|
*/
|
|
32
|
-
interface
|
|
35
|
+
interface ResolvePendingCoordinationResult {
|
|
33
36
|
readonly messages: ModelMessage[];
|
|
34
37
|
readonly outcome: "continue" | "resolved" | "unresolved";
|
|
35
38
|
readonly session: HarnessSession;
|
|
36
39
|
}
|
|
37
|
-
/** Returns the pending
|
|
38
|
-
export declare function
|
|
40
|
+
/** Returns the pending coordination batch stored on the session, if any. */
|
|
41
|
+
export declare function getPendingCoordinationBatch(state: SessionStateMap | undefined): PendingCoordinationBatch | undefined;
|
|
39
42
|
/**
|
|
40
|
-
* Returns true when the session is parked on
|
|
43
|
+
* Returns true when the session is parked on pending task/control coordination.
|
|
41
44
|
*/
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function
|
|
45
|
+
export declare function hasPendingCoordinationBatch(state: SessionStateMap | undefined): boolean;
|
|
46
|
+
export declare function clearPendingCoordinationBatch(session: HarnessSession): HarnessSession;
|
|
44
47
|
/**
|
|
45
|
-
* Stores one pending
|
|
48
|
+
* Stores one pending coordination batch on the session.
|
|
46
49
|
*/
|
|
47
|
-
export declare function
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
50
|
+
export declare function setPendingCoordinationBatch(input: {
|
|
51
|
+
readonly runtimeActions: readonly RuntimeToolCallActionRequest[];
|
|
52
|
+
readonly tasks: readonly RuntimeWorkflowTaskRequest[];
|
|
53
|
+
readonly event: PendingCoordinationEventMetadata;
|
|
54
|
+
readonly localFanoutSize?: number;
|
|
50
55
|
readonly responseMessages: readonly ModelMessage[];
|
|
51
56
|
readonly session: HarnessSession;
|
|
52
57
|
}): HarnessSession;
|
|
53
|
-
/** Rejects
|
|
54
|
-
export declare function
|
|
58
|
+
/** Rejects a batch before any result or side effect can bind ambiguously by call id. */
|
|
59
|
+
export declare function assertUniqueCoordinationCallIds(requests: readonly {
|
|
60
|
+
readonly callId: string;
|
|
61
|
+
}[]): void;
|
|
55
62
|
/**
|
|
56
|
-
* Resolves one pending
|
|
63
|
+
* Resolves one pending coordination batch back into model history.
|
|
57
64
|
*
|
|
58
65
|
* When all expected runtime action results are present, this appends the
|
|
59
66
|
* stored assistant tool-call messages plus synthesized tool-result messages to
|
|
60
67
|
* history, clears the pending batch, and emits `subagent.completed` and
|
|
61
68
|
* `action.result` events back onto the parent stream.
|
|
62
69
|
*/
|
|
63
|
-
export declare function
|
|
70
|
+
export declare function resolvePendingCoordination(input: {
|
|
64
71
|
readonly emit?: HarnessEmitFn;
|
|
65
72
|
readonly session: HarnessSession;
|
|
66
73
|
readonly stepInput?: StepInput;
|
|
67
74
|
/** Definitions whose `toModelOutput` projects a workflow tool's result for the model. */
|
|
68
75
|
readonly tools?: HarnessToolMap;
|
|
69
|
-
}): Promise<
|
|
76
|
+
}): Promise<ResolvePendingCoordinationResult>;
|
|
70
77
|
/**
|
|
71
78
|
* Projects one AI SDK tool call into the eve runtime-action contract.
|
|
72
79
|
*/
|
|
@@ -74,11 +81,17 @@ export declare function createRuntimeActionRequestFromToolCall(input: {
|
|
|
74
81
|
readonly toolCall: TypedToolCall<ToolSet>;
|
|
75
82
|
readonly tools: HarnessToolMap;
|
|
76
83
|
}): RuntimeActionRequest;
|
|
77
|
-
/** Projects one
|
|
78
|
-
export declare function
|
|
84
|
+
/** Projects one deferred harness tool call into task/control coordination. */
|
|
85
|
+
export declare function createCoordinationRequestFromToolCall(input: {
|
|
79
86
|
readonly toolCall: TypedToolCall<ToolSet>;
|
|
80
87
|
readonly tools: HarnessToolMap;
|
|
81
|
-
}):
|
|
88
|
+
}): {
|
|
89
|
+
readonly kind: "runtime-action";
|
|
90
|
+
readonly request: RuntimeToolCallActionRequest;
|
|
91
|
+
} | {
|
|
92
|
+
readonly kind: "task";
|
|
93
|
+
readonly request: RuntimeWorkflowTaskRequest;
|
|
94
|
+
};
|
|
82
95
|
/**
|
|
83
96
|
* Coerces an AI SDK tool-call `input` into the runtime-action `JsonObject`
|
|
84
97
|
* contract, throwing a `TypeError` (with the original as `cause`) that names
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createActionResultEvent}from"#protocol/message.js";import{parseJsonObject}from"#shared/json.js";import{findWorkflowToolRun,isInboxSubagentResultFromRecordedWorkflowToolRun,removeWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{clearProxyInputRequestsForChild,clearProxyInputRequestsWhere}from"#harness/proxy-input-requests.js";import{settleAgentTurn}from"#subagents/handles/transitions.js";import{accumulateSessionUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{findRunningAgentHandle,isResultBoundToRunningHandle}from"#subagents/handles/query.js";import{resolveRuntimeActionResultsForCallIds}from"#runtime/actions/results.js";import{normalizeToolModelOutput}from"#harness/tool-model-output.js";const PENDING_COORDINATION_BATCH_KEY=`eve.runtime.pendingCoordinationBatch`;function readSubagentResultOutcome(e){return e.origin===`child`?e.outcome:void 0}function getPendingCoordinationBatch(e){let t=e?.[PENDING_COORDINATION_BATCH_KEY];if(typeof t!=`object`||!t)return;let n=t;if(!(!Array.isArray(n.runtimeActions)||!Array.isArray(n.tasks)||!Array.isArray(n.responseMessages)||typeof n.event!=`object`||n.event===null))return n}function hasPendingCoordinationBatch(e){return getPendingCoordinationBatch(e)!==void 0}function clearPendingCoordinationBatch(e){if(e.state?.[PENDING_COORDINATION_BATCH_KEY]===void 0)return e;let t={...e.state};return delete t[PENDING_COORDINATION_BATCH_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function setPendingCoordinationBatch(e){assertUniqueCoordinationCallIds([...e.runtimeActions,...e.tasks]);let t={...e.session.state};return t[PENDING_COORDINATION_BATCH_KEY]={runtimeActions:[...e.runtimeActions],tasks:[...e.tasks],event:e.event,localFanoutSize:e.localFanoutSize,responseMessages:[...e.responseMessages]},{...e.session,state:t}}function assertUniqueCoordinationCallIds(e){let t=new Set;for(let n of e){if(t.has(n.callId))throw Error(`Coordination batch contains duplicate callId "${n.callId}".`);t.add(n.callId)}}function resolveReadyCoordinationResults(e){let t=getPendingCoordinationBatch(e.session.state);if(t!==void 0)return resolveResultsForCoordinationBatch({batch:t,results:e.results,state:e.session.state})}function resolveResultsForCoordinationBatch(e){return resolveRuntimeActionResultsForCallIds({pendingCallIds:[...e.batch.runtimeActions,...e.batch.tasks].map(e=>e.callId),results:e.results.filter(t=>isResultBoundToRunningHandle(e.state,t)||t.kind===`subagent-result`&&isInboxSubagentResultFromRecordedWorkflowToolRun(e.state,t))})}async function resolvePendingCoordination(t){let r=getPendingCoordinationBatch(t.session.state);if(r===void 0)return{messages:[...t.session.history],outcome:`continue`,session:t.session};let i=resolveReadyCoordinationResults({results:t.stepInput?.runtimeActionResults??[],session:t.session});if(i===void 0)return{messages:[...t.session.history],outcome:`unresolved`,session:t.session};if(t.emit!==void 0)for(let n of i){if(n.kind===`subagent-result`&&n.isError!==!0){let e=readBackgroundTaskReceipt(n),r={callId:n.callId,output:typeof n.output==`string`?n.output:JSON.stringify(n.output),subagentName:n.subagentName};await t.emit({data:e===void 0?r:{...r,backgroundTask:e},type:`subagent.completed`})}await t.emit(createActionResultEvent({result:n,sequence:r.event.sequence,stepIndex:r.event.stepIndex,turnId:r.event.turnId}))}let a=t.session;for(let e of i){if(e.kind!==`subagent-result`||e.origin!==`child`||readBackgroundTaskReceipt(e)!==void 0)continue;let t=findRunningAgentHandle(a.state,{callId:e.callId});if(t===void 0)continue;let n=readSubagentResultOutcome(e);if(n===void 0)continue;n.kind===`terminal`&&`continuationToken`in t.address&&(a=clearProxyInputRequestsForChild(a,t.address.continuationToken));let r=settleAgentTurn(a,{operationId:t.operation.id,outcome:n});r.kind===`settled`&&(a=r.session)}for(let e of i){if(e.kind!==`tool-result`)continue;let t=findWorkflowToolRun(a.state,e.callId);t!==void 0&&(a=removeWorkflowToolRun(clearProxyInputRequestsWhere(a,e=>e.answerHook?.runId===t.runId),t.callId))}for(let e of i){if(e.kind!==`subagent-result`)continue;let t=findWorkflowToolRun(a.state,e.callId);t?.resultKind===`subagent`&&(a=removeWorkflowToolRun(clearProxyInputRequestsForChild(a,t.hookToken),t.callId))}let o={...a.state};delete o[PENDING_COORDINATION_BATCH_KEY],a={...a,state:Object.keys(o).length>0?o:void 0};for(let e of i){if(e.kind!==`subagent-result`)continue;let t=readSubagentResultOutcome(e);t!==void 0&&(a=setTurnUsageState(a,accumulateSessionUsage({previous:getTurnUsageState(a.state),usage:t.usageDelta})))}let s=[];for(let e of i){switch(e.kind){case`load-skill-result`:s.push({output:toToolResultOutput(e),toolCallId:e.callId,toolName:`load_skill`,type:`tool-result`});continue;case`subagent-result`:s.push({output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.subagentName,type:`tool-result`});continue;case`tool-result`:s.push({output:await projectToolResultOutput(e,t.tools?.get(e.toolName)),toolCallId:e.callId,toolName:e.toolName,type:`tool-result`});continue}throw Error(`Unsupported runtime action result kind "${String(e)}".`)}let c=[...a.history,...r.responseMessages];return s.length>0&&c.push({content:s,role:`tool`}),{messages:c,outcome:`resolved`,session:a}}function readBackgroundTaskReceipt(e){return`backgroundTask`in e?e.backgroundTask:void 0}function createRuntimeActionRequestFromToolCall(e){return e.tools.get(e.toolCall.toolName)?.frameworkAction===`load-skill`?{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`load-skill`}:{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`tool-call`,toolName:e.toolCall.toolName}}function createCoordinationRequestFromToolCall(e){let t=e.tools.get(e.toolCall.toolName),n=resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName});if(t?.runtimeAction?.kind===`task-control`)return{kind:`runtime-action`,request:{callId:e.toolCall.toolCallId,input:n,kind:`tool-call`,toolName:e.toolCall.toolName}};if(t?.workflowId!==void 0)return{kind:`task`,request:{callId:e.toolCall.toolCallId,executeInput:t.executeInput?.(n),input:n,kind:`workflow-task`,resultKind:t.resultKind,toolName:e.toolCall.toolName,workflowId:t.workflowId}};throw Error(`Deferred tool "${e.toolCall.toolName}" has no task or runtime action.`)}function resolveToolCallInputObject(e,n){if(e==null||typeof e==`string`&&e.trim()===``)return{};try{return parseJsonObject(typeof e==`string`?parseJsonStringInput(e):e)}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`Failed to parse tool-call arguments for "${n.toolName}" (${n.callId}): ${t}`,{cause:e})}}function parseJsonStringInput(e){return JSON.parse(e)}async function projectToolResultOutput(e,t){return e.isError===!0||t?.toModelOutput===void 0?toToolResultOutput(e):normalizeToolModelOutput({output:await t.toModelOutput(e.output),toolCallId:e.callId,toolName:e.toolName})}function toToolResultOutput(e){return typeof e.output==`string`?e.isError===!0?{type:`error-text`,value:e.output}:{type:`text`,value:e.output}:e.isError===!0?{type:`error-json`,value:toMutableJsonValue(e.output)}:{type:`json`,value:toMutableJsonValue(e.output)}}function toMutableJsonValue(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return e.map(e=>toMutableJsonValue(e));let t={};for(let[n,r]of Object.entries(e))t[n]=toMutableJsonValue(r);return t}export{assertUniqueCoordinationCallIds,clearPendingCoordinationBatch,createCoordinationRequestFromToolCall,createRuntimeActionRequestFromToolCall,getPendingCoordinationBatch,hasPendingCoordinationBatch,resolvePendingCoordination,resolveToolCallInputObject,setPendingCoordinationBatch};
|
|
@@ -53,7 +53,7 @@ export declare function advanceStep(state: HarnessEmissionState): HarnessEmissio
|
|
|
53
53
|
* Emits `turn.completed` and either `session.waiting` or `session.completed`.
|
|
54
54
|
* Returns updated emission state with an incremented sequence.
|
|
55
55
|
*/
|
|
56
|
-
export declare function emitTurnEpilogue(emitFn: HarnessEmitFn, state: HarnessEmissionState, mode: RunMode
|
|
56
|
+
export declare function emitTurnEpilogue(emitFn: HarnessEmitFn, state: HarnessEmissionState, mode: RunMode): Promise<HarnessEmissionState>;
|
|
57
57
|
/**
|
|
58
58
|
* Maps an AI SDK finish reason string to the eve-owned
|
|
59
59
|
* {@link AssistantStepFinishReason} union. Unknown values become `"other"`.
|
|
@@ -76,5 +76,12 @@ interface StreamActionEmissionOptions {
|
|
|
76
76
|
readonly excludedActionToolNames: ReadonlySet<string>;
|
|
77
77
|
readonly tools: HarnessToolMap;
|
|
78
78
|
}
|
|
79
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Consumes the AI SDK `fullStream` and emits real-time text and reasoning
|
|
81
|
+
* events.
|
|
82
|
+
*
|
|
83
|
+
* Emits local tool events in source order. Provider calls that arrive in one
|
|
84
|
+
* stream batch into one request event before their first result. A result
|
|
85
|
+
* without a streamed call resumes a call from an earlier step.
|
|
86
|
+
*/
|
|
80
87
|
export declare function emitStreamContent(emitFn: HarnessEmitFn, state: HarnessEmissionState, fullStream: AsyncIterable<TextStreamPart<ToolSet>>, options?: StreamActionEmissionOptions): Promise<EmittedStreamContent>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createActionInputAppendedEvent,createActionPartialEvent,createActionResultEvent,createActionsRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{createRuntimeActionRequestFromToolCall}from"#harness/
|
|
1
|
+
import{createActionInputAppendedEvent,createActionPartialEvent,createActionResultEvent,createActionsRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{createRuntimeActionRequestFromToolCall}from"#harness/coordination.js";import{createRuntimeToolResultFromStepResult,createRuntimeToolResultFromToolError,createToolResultMessagePartFromToolError}from"#harness/action-result-helpers.js";import{hasEmptyDeliverySentinel}from"#shared/empty-delivery.js";import{createInvalidToolCallInputError,isInvalidToolCall,resolveProviderToolCallRequest}from"#harness/tool-call-input-errors.js";import{createProviderStreamActionBatch}from"#harness/stream-actions.js";import{normalizeModelStreamError}from"#harness/model-call-error.js";import{createOrderedStreamEmitter}from"#harness/ordered-stream-emitter.js";import{interruptStreamOnFailure}from"#harness/interruptible-stream.js";import{isInlineAuthorizationToolResult}from"#harness/inline-tool-authorization.js";import{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission-state.js";async function emitTurnPreamble(e,t,n,r,i){let a=`turn_${n.sequence}`;return n.sessionStarted||await e(createSessionStartedEvent({runtime:r,trace:i})),await e(createTurnStartedEvent({sequence:n.sequence,trace:i,turnId:a})),t.message!==void 0&&await e(createMessageReceivedEvent({message:t.message,sequence:n.sequence,turnId:a})),{sessionStarted:!0,sequence:n.sequence,stepIndex:0,turnId:a}}async function emitStepStarted(e,t,n,r){await e(createStepStartedEvent({modelId:n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId}),r)}async function emitStepAndTurnFailed(e,t,n){await e(createStepFailedEvent({...n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId})),await e(createTurnFailedEvent({...n,sequence:t.sequence,turnId:t.turnId}))}async function emitFailedStep(e,t,n){await emitStepAndTurnFailed(e,t,n),await e(createSessionFailedEvent(n))}async function emitRecoverableFailedTurn(e,t,n){return await emitStepAndTurnFailed(e,t,n),await e(createSessionWaitingEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function advanceStep(e){return{...e,stepIndex:e.stepIndex+1}}async function emitTurnEpilogue(e,t,n){return await e(createTurnCompletedEvent({sequence:t.sequence,turnId:t.turnId})),n===`conversation`?await e(createSessionWaitingEvent()):await e(createSessionCompletedEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function normalizeAssistantStepFinishReason(e){switch(e){case`content-filter`:case`error`:case`length`:case`stop`:case`tool-calls`:return e;default:return`other`}}function readSubagentBackgroundTaskReceipt(e,t){if(e.isError===!0||t?.get(e.toolName)?.resultKind!==`subagent`||typeof e.output!=`object`||e.output===null||Array.isArray(e.output))return;let n=Reflect.get(e.output,`status`),r=Reflect.get(e.output,`taskId`);return n===`working`&&typeof r==`string`?{status:n,taskId:r}:void 0}async function emitStreamContent(e,t,n,r){let i=createOrderedStreamEmitter(e),a=createProviderStreamActionBatch({emitFn:i.emit,state:t});try{return await consumeStreamContent(i.emit,t,interruptStreamOnFailure(n,i.failureSignal),a,r)}finally{try{await a.cancel()}finally{await i.closeAndDrain()}}}async function consumeStreamContent(o,s,c,l,u){let d=``,f=``,p=`stop`,m,h=new Set,g=new Set,_=new Set,v=new Set,y=new Set,b=new Set,x=[],S=[],C=new Map,flushCurrentMessage=async()=>{f.length!==0&&(await o(createMessageCompletedEvent({finishReason:`tool-calls`,message:f,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId})),f=``)},emitActionInput=async(t,n,r)=>o(createActionInputAppendedEvent({callId:t,inputTextDelta:r,sequence:s.sequence,stepIndex:s.stepIndex,toolName:n,turnId:s.turnId})),emitActionRequest=async e=>{g.has(e.callId)||(f.trim().length>0&&await flushCurrentMessage(),g.add(e.callId),await o(createActionsRequestedEvent({actions:[e],sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId})))},collectProviderToolCall=async e=>{if(v.has(e.toolCallId)||(v.add(e.toolCallId),g.has(e.toolCallId)))return;g.add(e.toolCallId),f.trim().length>0&&await flushCurrentMessage();let t=resolveProviderToolCallRequest(e);if(t.toolError!==void 0){b.add(e.toolCallId),await emitActionResult(createRuntimeToolResultFromToolError(t.toolError)),y.add(e.toolCallId),S.push(createToolResultMessagePartFromToolError(t.toolError));return}l.observe(t.request)},emitActionResult=async e=>{if(_.has(e.callId))return;_.add(e.callId);let t=readSubagentBackgroundTaskReceipt(e,u?.tools);t!==void 0&&await o({data:{backgroundTask:t,callId:e.callId,output:typeof e.output==`string`?e.output:JSON.stringify(e.output),subagentName:e.toolName},type:`subagent.completed`}),await o(createActionResultEvent({result:e,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId}))},emitActionPartial=async e=>{await o(createActionPartialEvent({result:e,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId}))},emitToolCall=async e=>{if(isInvalidToolCall(e)){b.add(e.toolCallId);return}if(!(u===void 0||u.excludedActionToolNames.has(e.toolName)))try{await emitActionRequest(createRuntimeActionRequestFromToolCall({toolCall:e,tools:u.tools}))}catch(t){if(t instanceof TypeError){let n=createInvalidToolCallInputError({error:t,toolCall:e});b.add(e.toolCallId),f.trim().length>0&&await flushCurrentMessage(),await emitActionResult(createRuntimeToolResultFromToolError(n)),y.add(e.toolCallId),S.push(createToolResultMessagePartFromToolError(n));return}throw t}};for await(let e of c)if(m===void 0)switch(e.type){case`reasoning-delta`:await l.flush(),d+=e.text,await o(createReasoningAppendedEvent({reasoningDelta:e.text,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId}));break;case`text-delta`:await l.flush(),d.trim().length>0&&(await o(createReasoningCompletedEvent({reasoning:d,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId})),d=``),f+=e.text,await o(createMessageAppendedEvent({messageDelta:e.text,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId}));break;case`tool-input-start`:if(u===void 0||e.providerExecuted===!0||u.excludedActionToolNames.has(e.toolName)){C.delete(e.id);break}await l.flush(),f.trim().length>0&&await flushCurrentMessage(),C.set(e.id,{toolName:e.toolName});break;case`tool-input-delta`:{let t=C.get(e.id);if(t===void 0)break;await l.flush(),await emitActionInput(e.id,t.toolName,e.delta);break}case`tool-input-end`:C.delete(e.id);break;case`tool-call`:{let t=e;C.delete(t.toolCallId),h.add(t.toolCallId),t.providerExecuted===!0?await collectProviderToolCall(t):(await l.flush(),await emitToolCall(t));break}case`tool-result`:{let t=e;if(t.preliminary===!0){t.providerExecuted!==!0&&await emitActionPartial(createRuntimeToolResultFromStepResult(t));break}if(t.providerExecuted===!0){await collectProviderToolCall({input:`input`in t?t.input:void 0,toolCallId:t.toolCallId,toolName:t.toolName}),await l.flush(),await emitActionResult(createRuntimeToolResultFromStepResult(t));break}if(h.has(e.toolCallId)){if(isInlineAuthorizationToolResult(t))break;g.has(e.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromStepResult(t)),y.add(e.toolCallId));break}if(await l.flush(),await flushCurrentMessage(),isInlineAuthorizationToolResult(t)){y.add(e.toolCallId),x.push(t);break}await emitActionResult(createRuntimeToolResultFromStepResult(t)),y.add(e.toolCallId);break}case`tool-error`:{let t=e;t.providerExecuted===!0?(await collectProviderToolCall(t),await l.flush(),await emitActionResult(createRuntimeToolResultFromToolError(t))):g.has(t.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromToolError(t)),y.add(t.toolCallId),S.push(createToolResultMessagePartFromToolError(t)));break}case`finish-step`:p=normalizeAssistantStepFinishReason(e.finishReason),await l.flush();break;case`error`:m=normalizeModelStreamError(e.error);break;case`abort`:throw new DOMException(e.reason??`The model stream was aborted.`,`AbortError`);default:break}if(await l.flush(),m!==void 0)throw m;return d.trim().length>0&&await o(createReasoningCompletedEvent({reasoning:d,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId})),p!==`tool-calls`&&hasEmptyDeliverySentinel(f)?await o(createMessageCompletedEvent({finishReason:p,message:null,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId})):f.trim().length>0&&await o(createMessageCompletedEvent({finishReason:p,message:f,sequence:s.sequence,stepIndex:s.stepIndex,turnId:s.turnId})),{emittedActionCallIds:g,handledInlineToolResultCallIds:y,invalidInputToolCallIds:b,inlineAuthorizationResults:x,trailingInlineToolResultParts:S}}export{advanceStep,emitFailedStep,emitRecoverableFailedTurn,emitStepStarted,emitStreamContent,emitTurnEpilogue,emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,normalizeAssistantStepFinishReason,setHarnessEmissionState};
|
|
@@ -2,7 +2,19 @@ import type { FlexibleSchema } from "ai";
|
|
|
2
2
|
import type { Approval } from "#approval/definition.js";
|
|
3
3
|
import type { ToolExecuteOptions } from "#tools/definition.js";
|
|
4
4
|
import type { TaskExec } from "#tools/task.js";
|
|
5
|
+
import type { JsonValue } from "#shared/json.js";
|
|
5
6
|
import type { PreparedToolBehavior } from "#tools/behavior.js";
|
|
7
|
+
/**
|
|
8
|
+
* Runtime-owned action metadata attached to one harness-visible tool.
|
|
9
|
+
*
|
|
10
|
+
* `task-control` marks the parent-side background task tools
|
|
11
|
+
* (`task_cancel`, `task_update`): they carry no child
|
|
12
|
+
* address of their own — the dispatch step resolves targets through the
|
|
13
|
+
* session task index by tool name.
|
|
14
|
+
*/
|
|
15
|
+
export type HarnessRuntimeActionDefinition = {
|
|
16
|
+
readonly kind: "task-control";
|
|
17
|
+
};
|
|
6
18
|
/**
|
|
7
19
|
* Unified harness-owned tool definition.
|
|
8
20
|
*/
|
|
@@ -11,10 +23,50 @@ export interface HarnessToolDefinition {
|
|
|
11
23
|
readonly behavior?: PreparedToolBehavior;
|
|
12
24
|
readonly description: string;
|
|
13
25
|
readonly execute?: (input: any, options: ToolExecuteOptions, task?: TaskExec) => any;
|
|
26
|
+
/** Optional JSON input substituted when this tool starts its workflow body. */
|
|
27
|
+
readonly executeInput?: (input: unknown) => JsonValue;
|
|
14
28
|
readonly execution?: "background";
|
|
29
|
+
readonly frameworkAction?: "load-skill";
|
|
15
30
|
readonly inputSchema: FlexibleSchema;
|
|
16
31
|
readonly name: string;
|
|
32
|
+
/** Runtime graph node for a framework subagent workflow body. */
|
|
33
|
+
readonly nodeId?: string;
|
|
17
34
|
readonly approval?: Approval;
|
|
18
35
|
readonly outputSchema?: FlexibleSchema;
|
|
36
|
+
/**
|
|
37
|
+
* How the result of this workflow-backed tool is settled: as a
|
|
38
|
+
* `subagent-result` (delegation tools — `behavior.handling.target.kind` is
|
|
39
|
+
* `subagent-call`, `remote-agent-call`, or `self-agent-call`) or as an
|
|
40
|
+
* ordinary `tool-result` (authored workflow tools). Absent means `"tool"`.
|
|
41
|
+
*
|
|
42
|
+
* On the definition itself this duplicates the dispatch target kind; it
|
|
43
|
+
* exists because the value must survive past the tool map. `buildToolSet`,
|
|
44
|
+
* `createCoordinationRequestFromToolCall`, and the workflow sandbox host
|
|
45
|
+
* tool copy it into the `RuntimeWorkflowTaskRequest`, which `startWorkflowTask`
|
|
46
|
+
* persists on the `WorkflowToolRunRecord` in session state and the run echoes
|
|
47
|
+
* back on every `WorkflowToolRunRef` inbox message. The owner turn then routes
|
|
48
|
+
* outcomes, counts the workflow subagent budget, and decides whether child
|
|
49
|
+
* usage accrues without access to a `HarnessToolMap`. Harness-side readers
|
|
50
|
+
* (`advertised-tools`, `emission`, the background tool executor) use it to
|
|
51
|
+
* expose only delegation tools inside workflow sandboxes, emit task receipts,
|
|
52
|
+
* and reserve/claim agent handles for subagent starts.
|
|
53
|
+
*
|
|
54
|
+
* The persisted copy is dropped by `removeWorkflowToolRun` when the run
|
|
55
|
+
* settles, or `clearWorkflowToolRuns` at turn end.
|
|
56
|
+
*
|
|
57
|
+
* TODO: once subagent starts no longer need harness-specific handling,
|
|
58
|
+
* derive this from `behavior.handling.target.kind` at the projection points
|
|
59
|
+
* above and remove the field.
|
|
60
|
+
*/
|
|
61
|
+
readonly resultKind?: "subagent" | "tool";
|
|
62
|
+
/**
|
|
63
|
+
* Advertise this tool only to the root session, hiding it from subagent
|
|
64
|
+
* sessions. Set on the injected `agent` self-delegation tool so children
|
|
65
|
+
* cannot delegate recursively. Absent means visible everywhere.
|
|
66
|
+
*/
|
|
67
|
+
readonly rootOnly?: boolean;
|
|
68
|
+
readonly runtimeAction?: HarnessRuntimeActionDefinition;
|
|
19
69
|
readonly toModelOutput?: (output: unknown) => unknown;
|
|
70
|
+
/** Present when this tool starts an associated durable workflow. */
|
|
71
|
+
readonly workflowId?: string;
|
|
20
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getPendingInputBatches,queueDeferredStepInput,removePendingInputBatches}from"#harness/pending-input-batches.js";import{buildResolvedInputBatch}from"#harness/input-request-resolution.js";import{appendResolvedBatchTranscript,compactStepInput,finishResolvedInput,responsesForBatches}from"#harness/hitl/pending-input-resolution.js";import{isSessionLimitContinuationRequest,resolveSessionLimitContinuation}from"#harness/session-limit-continuation.js";function isSessionLimitInputBatch(e){let t=e.requests.some(e=>e.kind===`session-limit`);if(t&&e.requests.some(e=>e.kind!==`session-limit`))throw TypeError(`Session-limit pending input batches must contain only session-limit requests.`);return t}function resolveSessionLimitInput(e){let r=new Set(e.responses.map(e=>e.requestId));if(!(e.pendingBatch.requests.some(e=>r.has(e.requestId))&&e.pendingBatch.requests.every(e=>r.has(e.requestId))))return{deferredMessage:!0,outcome:`unresolved`,messages:[...e.baseHistory],session:queueDeferredStepInput(e.session,compactStepInput(e.resolvedStepInput))};let i=e.batches.filter(t=>t!==e.pendingBatch),a=responsesForBatches(e.responses,i),o=i.some(e=>e.requests.some(e=>isSessionLimitContinuationRequest(e))),s=[...e.baseHistory];appendResolvedBatchTranscript(s,e.pendingBatch,[]);let c=removePendingInputBatches(e.session,[e.pendingBatch]),l=resolveSessionLimitContinuation({requests:e.pendingBatch.requests,responses:e.responses});return finishResolvedInput({deferTurnInput:e.deferTurnInput||o,leftoverResponses:a,limitContinuation:l,messages:s,resolvedInputs:[buildResolvedInputBatch(e.pendingBatch,e.responses)].filter(e=>e!==void 0),resolvedStepInput:e.resolvedStepInput,session:c})}function clearPendingSessionLimitPrompt(t){let n=getPendingInputBatches(t.state).filter(e=>e.requests.length>0&&e.requests.every(e=>isSessionLimitContinuationRequest(e)));return n.length===0?t:removePendingInputBatches(t,n)}export{clearPendingSessionLimitPrompt,isSessionLimitInputBatch,resolveSessionLimitInput};
|