eve 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/channel/types.d.ts +12 -19
- package/dist/src/chunks/{use-eve-agent-DUMU6dap.js → use-eve-agent-B4xN7-fK.js} +4 -4
- package/dist/src/chunks/{use-eve-agent-B5I-k6Ek.js → use-eve-agent-C3vUG5g2.js} +4 -4
- package/dist/src/cli/acp/command.d.ts +1 -1
- package/dist/src/cli/acp/command.js +2 -2
- package/dist/src/cli/agent-command.d.ts +5 -0
- package/dist/src/cli/agent-command.js +1 -0
- package/dist/src/cli/application-command.d.ts +2 -0
- package/dist/src/cli/commands/build.d.ts +1 -1
- package/dist/src/cli/commands/build.js +1 -1
- package/dist/src/cli/commands/deploy.d.ts +2 -0
- package/dist/src/cli/commands/deploy.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.d.ts +14 -0
- package/dist/src/cli/commands/init-agent-workspace.js +1 -0
- package/dist/src/cli/commands/init-repl.js +1 -1
- package/dist/src/cli/commands/init.d.ts +2 -13
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/integration-connect.js +1 -1
- package/dist/src/cli/commands/link.d.ts +2 -0
- package/dist/src/cli/commands/link.js +1 -1
- package/dist/src/cli/commands/preconditions.d.ts +15 -0
- package/dist/src/cli/commands/preconditions.js +1 -1
- package/dist/src/cli/commands/register-integration-commands.d.ts +1 -1
- package/dist/src/cli/commands/register-integration-commands.js +1 -1
- package/dist/src/cli/commands/register-registry-commands.js +2 -2
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/environment.d.ts +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/local-server-process.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/invoke/command.d.ts +1 -1
- package/dist/src/cli/invoke/command.js +1 -1
- package/dist/src/cli/option-parsers.d.ts +1 -0
- package/dist/src/cli/option-parsers.js +1 -1
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/agent-info-schema.d.ts +0 -1
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/message-action-parts.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +1 -0
- package/dist/src/context/keys.d.ts +0 -3
- package/dist/src/context/keys.js +1 -1
- package/dist/src/discover/project.js +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/evals/mock-model.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/activity-work-id.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/channel-context.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +103 -0
- package/dist/src/execution/coordination-dispatch-shared.js +1 -0
- package/dist/src/execution/coordination-dispatch-step.d.ts +7 -0
- package/dist/src/execution/coordination-dispatch-step.js +1 -0
- package/dist/src/execution/create-session-step.d.ts +1 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/dispatch-action-failures.d.ts +5 -5
- package/dist/src/execution/dispatch-action-failures.js +1 -1
- package/dist/src/execution/dispatch-start-operation.d.ts +1 -1
- package/dist/src/execution/dispatch-start-operation.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +1 -1
- package/dist/src/execution/inline-turn.js +1 -1
- package/dist/src/execution/next-driver-action.d.ts +7 -10
- package/dist/src/execution/node-step.d.ts +1 -2
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/pending-turn-state.d.ts +1 -2
- package/dist/src/execution/pending-turn-state.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session-command-inbox.d.ts +2 -3
- package/dist/src/execution/session.d.ts +1 -1
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +1 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/task-event-callback.js +1 -1
- package/dist/src/execution/tasks/child/steps.d.ts +18 -18
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/update-step.d.ts +6 -0
- package/dist/src/execution/tasks/child/update-step.js +1 -0
- package/dist/src/execution/tasks/child/update.d.ts +7 -10
- package/dist/src/execution/tasks/child/update.js +1 -1
- package/dist/src/execution/tasks/child/workflow.d.ts +21 -29
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/control-shared.d.ts +6 -17
- package/dist/src/execution/tasks/parent/control-shared.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +15 -50
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +19 -34
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +5 -15
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/run-parent.d.ts +2 -2
- package/dist/src/execution/tasks/parent/task-cancel.d.ts +11 -0
- package/dist/src/execution/tasks/parent/task-cancel.js +1 -0
- package/dist/src/execution/tasks/parent/tool-execution.d.ts +2 -3
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/subagent/accept-event-step.d.ts +7 -0
- package/dist/src/execution/tools/subagent/accept-event-step.js +1 -0
- package/dist/src/execution/tools/subagent/emit-called-step.d.ts +9 -0
- package/dist/src/execution/tools/subagent/emit-called-step.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +51 -0
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +37 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +55 -0
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -0
- package/dist/src/execution/tools/subagent/receipt-identity.d.ts +11 -0
- package/dist/src/execution/tools/subagent/receipt-identity.js +1 -0
- package/dist/src/execution/{dispatch-runtime-actions-start.d.ts → tools/subagent/start.d.ts} +17 -5
- package/dist/src/execution/tools/subagent/start.js +1 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +24 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -0
- package/dist/src/execution/tools/subagent/task-cancel.d.ts +10 -0
- package/dist/src/execution/tools/subagent/task-cancel.js +1 -0
- package/dist/src/execution/tools/tasks.d.ts +10 -0
- package/dist/src/execution/tools/tasks.js +1 -0
- package/dist/src/execution/{tool-run → tools/workflow}/answer.d.ts +1 -1
- package/dist/src/execution/tools/workflow/answer.js +1 -0
- package/dist/src/execution/tools/workflow/ask.d.ts +22 -0
- package/dist/src/execution/tools/workflow/ask.js +1 -0
- package/dist/src/execution/tools/workflow/background.d.ts +18 -0
- package/dist/src/execution/tools/workflow/background.js +1 -0
- package/dist/src/execution/tools/workflow/body.d.ts +25 -0
- package/dist/src/execution/tools/workflow/body.js +1 -0
- package/dist/src/execution/tools/workflow/cancel.d.ts +11 -0
- package/dist/src/execution/tools/workflow/cancel.js +1 -0
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +7 -0
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -0
- package/dist/src/execution/tools/workflow/messages.d.ts +88 -0
- package/dist/src/execution/tools/workflow/messages.js +1 -0
- package/dist/src/execution/tools/workflow/owner-inbox.d.ts +13 -0
- package/dist/src/execution/tools/workflow/owner-inbox.js +1 -0
- package/dist/src/execution/tools/workflow/owner.d.ts +13 -0
- package/dist/src/execution/tools/workflow/owner.js +1 -0
- package/dist/src/execution/tools/workflow/run-control.d.ts +18 -0
- package/dist/src/execution/tools/workflow/run-control.js +1 -0
- package/dist/src/execution/tools/workflow/start.d.ts +33 -0
- package/dist/src/execution/tools/workflow/start.js +1 -0
- package/dist/src/execution/tools/workflow/types.d.ts +26 -0
- package/dist/src/execution/tools/workflow/types.js +1 -0
- package/dist/src/execution/tools/workflow/workflow.d.ts +3 -0
- package/dist/src/execution/tools/workflow/workflow.js +1 -0
- package/dist/src/execution/turn-workflow-tool-run.d.ts +16 -0
- package/dist/src/execution/turn-workflow-tool-run.js +1 -0
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
- package/dist/src/execution/wire/session-inbox-contract.js +1 -1
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +6 -2
- package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.d.ts +3 -3
- package/dist/src/execution/wire/session-inbox-wire.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v1.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v4.d.ts +267 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.d.ts +3 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.js +1 -0
- package/dist/src/execution/workflow-entry-finalization.d.ts +6 -0
- package/dist/src/execution/workflow-entry-finalization.js +1 -1
- package/dist/src/execution/workflow-entry.d.ts +2 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +1 -7
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/background-tools.d.ts +8 -2
- package/dist/src/harness/{runtime-actions.d.ts → coordination.d.ts} +40 -27
- package/dist/src/harness/coordination.js +1 -0
- package/dist/src/harness/emission.d.ts +9 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +52 -0
- package/dist/src/harness/hitl/session-limit-input-requests.js +1 -1
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +6 -2
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/step-hooks.d.ts +1 -2
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-call-action.js +1 -1
- package/dist/src/harness/tool-call-input-errors.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +3 -1
- package/dist/src/harness/types.d.ts +4 -7
- package/dist/src/harness/workflow-interrupt-state.js +1 -1
- package/dist/src/harness/workflow-lifecycle.d.ts +10 -0
- package/dist/src/harness/workflow-lifecycle.js +1 -1
- package/dist/src/harness/workflow-sandbox.d.ts +1 -1
- package/dist/src/harness/workflow-sandbox.js +2 -2
- package/dist/src/harness/workflow-subagent-limit.d.ts +7 -7
- package/dist/src/harness/workflow-subagent-limit.js +1 -1
- package/dist/src/harness/workflow-task-state.d.ts +9 -0
- package/dist/src/harness/workflow-task-state.js +1 -0
- package/dist/src/harness/workflow-tool-runs.d.ts +27 -0
- package/dist/src/harness/workflow-tool-runs.js +1 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/parent-lineage.js +1 -1
- package/dist/src/internal/agent-name.d.ts +4 -0
- package/dist/src/internal/agent-name.js +1 -0
- package/dist/src/internal/agent-workspace.d.ts +15 -0
- package/dist/src/internal/agent-workspace.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +1 -1
- package/dist/src/internal/nitro/host/start-production-server.js +3 -3
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/project-context.d.ts +26 -0
- package/dist/src/internal/project-context.js +1 -0
- package/dist/src/internal/vercel/assemble-eve-services.d.ts +17 -0
- package/dist/src/internal/vercel/assemble-eve-services.js +1 -0
- package/dist/src/internal/vercel/build-agent-workspace.d.ts +3 -0
- package/dist/src/internal/vercel/build-agent-workspace.js +1 -0
- package/dist/src/internal/vercel/build-command.d.ts +4 -0
- package/dist/src/internal/vercel/build-command.js +1 -0
- package/dist/src/internal/vercel/eve-service-contribution.d.ts +27 -0
- package/dist/src/internal/vercel/eve-service-contribution.js +1 -0
- package/dist/src/internal/vercel/vercel-service-config-operations.d.ts +18 -0
- package/dist/src/internal/vercel/vercel-service-config-operations.js +1 -0
- package/dist/src/internal/vercel/vercel-service-name.d.ts +6 -0
- package/dist/src/internal/vercel/vercel-service-name.js +1 -0
- package/dist/src/internal/vercel/vercel-services-config.d.ts +53 -0
- package/dist/src/internal/vercel/vercel-services-config.js +1 -0
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/protocol/message.d.ts +2 -0
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/memory/file/backends/vercel-blob.js +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/public/workflow/index.d.ts +3 -1
- package/dist/src/public/workflow/index.js +1 -1
- package/dist/src/runtime/actions/results.d.ts +3 -3
- package/dist/src/runtime/actions/results.js +1 -1
- package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
- package/dist/src/runtime/agent/bootstrap.d.ts +1 -0
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/channels/registry.js +1 -1
- package/dist/src/runtime/prompt/compose.d.ts +0 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +16 -1
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/subagents/workflow-reference.d.ts +5 -0
- package/dist/src/runtime/subagents/workflow-reference.js +1 -0
- package/dist/src/runtime/subagents/workflow.d.ts +8 -0
- package/dist/src/runtime/subagents/workflow.js +1 -0
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/setup/integrations/discord/setup.js +1 -1
- package/dist/src/setup/integrations/file-memory/vercel.js +1 -1
- package/dist/src/setup/integrations/linear/setup.js +1 -1
- package/dist/src/setup/integrations/linq/setup.js +3 -3
- package/dist/src/setup/integrations/shopify/setup.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/update/channels.d.ts +4 -12
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/shared/action-types.d.ts +74 -14
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/json.js +1 -1
- package/dist/src/shared/workflow-sandbox.d.ts +1 -1
- package/dist/src/{execution/subagent-adapter-state.d.ts → subagents/adapter-state.d.ts} +2 -0
- package/dist/src/{execution/subagent-adapter-state.js → subagents/adapter-state.js} +1 -1
- package/dist/src/subagents/adapter.js +1 -0
- package/dist/src/{harness → subagents}/agent-handle-errors.d.ts +6 -0
- package/dist/src/subagents/agent-handle-errors.js +1 -0
- package/dist/src/subagents/callback-route.js +1 -0
- package/dist/src/subagents/callback-step.js +1 -0
- package/dist/src/{execution/agent-continuation-bundle.d.ts → subagents/continuation-bundle.d.ts} +1 -1
- package/dist/src/subagents/continuation-bundle.js +1 -0
- package/dist/src/{execution/subagent-event-proxy-step.d.ts → subagents/event-proxy-step.d.ts} +2 -8
- package/dist/src/subagents/event-proxy-step.js +1 -0
- package/dist/src/subagents/handle-dispatch.d.ts +54 -0
- package/dist/src/subagents/handle-dispatch.js +1 -0
- package/dist/src/{harness → subagents}/handles/prompt.d.ts +4 -4
- package/dist/src/{harness → subagents}/handles/prompt.js +1 -1
- package/dist/src/{harness → subagents}/handles/query.d.ts +8 -2
- package/dist/src/subagents/handles/query.js +1 -0
- package/dist/src/subagents/handles/rebase.d.ts +4 -0
- package/dist/src/subagents/handles/rebase.js +1 -0
- package/dist/src/{harness → subagents}/handles/store.d.ts +90 -15
- package/dist/src/subagents/handles/store.js +1 -0
- package/dist/src/subagents/handles/transitions.d.ts +103 -0
- package/dist/src/subagents/handles/transitions.js +1 -0
- package/dist/src/{execution/delegated-parent-notification.d.ts → subagents/parent-notification.d.ts} +1 -7
- package/dist/src/subagents/parent-notification.js +1 -0
- package/dist/src/subagents/parent-result.js +1 -0
- package/dist/src/{execution/remote-agent-dispatch.d.ts → subagents/remote-dispatch.d.ts} +3 -2
- package/dist/src/subagents/remote-dispatch.js +1 -0
- package/dist/src/{execution/subagent-start-local.d.ts → subagents/start-local.d.ts} +5 -6
- package/dist/src/subagents/start-local.js +1 -0
- package/dist/src/{execution/subagent-start-remote.d.ts → subagents/start-remote.d.ts} +5 -5
- package/dist/src/subagents/start-remote.js +1 -0
- package/dist/src/{execution/subagent-tool.d.ts → subagents/tool.d.ts} +5 -3
- package/dist/src/subagents/tool.js +1 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/json.js +1 -1
- package/dist/src/tasks/session-index.d.ts +2 -3
- package/dist/src/tasks/session-index.js +1 -1
- package/dist/src/tasks/task-id.d.ts +3 -4
- package/dist/src/tasks/task-id.js +1 -1
- package/dist/src/tasks/transitions.d.ts +3 -47
- package/dist/src/tasks/transitions.js +1 -1
- package/dist/src/tasks/types.d.ts +69 -247
- package/dist/src/tasks/types.js +1 -1
- package/dist/src/tools/dynamic.d.ts +3 -1
- package/dist/src/tools/framework/agent.d.ts +18 -2
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/framework/task-cancel.d.ts +2 -6
- package/dist/src/tools/framework/task-contract.d.ts +44 -65
- package/dist/src/tools/framework/task-contract.js +1 -1
- package/dist/src/tools/framework/task-update.d.ts +1 -0
- package/dist/src/tools/framework/task-update.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/concepts/built-in-tools.md +9 -90
- package/docs/concepts/context-control.md +2 -2
- package/docs/concepts/execution-model-and-durability.mdx +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +3 -3
- package/docs/guides/deployment/vercel.mdx +20 -2
- package/docs/guides/dynamic-capabilities.md +2 -2
- package/docs/guides/frontend/overview.mdx +1 -1
- package/docs/guides/instrumentation-providers.md +242 -0
- package/docs/guides/instrumentation.md +2 -0
- package/docs/guides/meta.json +1 -0
- package/docs/guides/remote-agents.md +8 -9
- package/docs/reference/cli.md +5 -2
- package/docs/sandbox.mdx +2 -0
- package/docs/subagents/index.mdx +9 -8
- package/docs/tools/overview.mdx +11 -10
- package/docs/tools/workflows.mdx +52 -18
- package/package.json +1 -1
- package/dist/src/execution/agent-continuation-bundle.js +0 -1
- package/dist/src/execution/agent-handle-dispatch.d.ts +0 -79
- package/dist/src/execution/agent-handle-dispatch.js +0 -1
- package/dist/src/execution/delegated-parent-notification.js +0 -1
- package/dist/src/execution/delegated-parent-result.js +0 -1
- package/dist/src/execution/delegation-tool.d.ts +0 -10
- package/dist/src/execution/delegation-tool.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +0 -165
- package/dist/src/execution/dispatch-runtime-actions-shared.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-start.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-step.d.ts +0 -18
- package/dist/src/execution/dispatch-runtime-actions-step.js +0 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.d.ts +0 -18
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +0 -1
- package/dist/src/execution/finalize-terminal-session.d.ts +0 -17
- package/dist/src/execution/finalize-terminal-session.js +0 -1
- package/dist/src/execution/prepared-agent-action.d.ts +0 -7
- package/dist/src/execution/prepared-agent-action.js +0 -1
- package/dist/src/execution/remote-agent-dispatch.js +0 -1
- package/dist/src/execution/session-callback-route.js +0 -1
- package/dist/src/execution/session-callback-step.js +0 -1
- package/dist/src/execution/subagent-adapter.js +0 -1
- package/dist/src/execution/subagent-event-proxy-step.js +0 -1
- package/dist/src/execution/subagent-start-local.js +0 -1
- package/dist/src/execution/subagent-start-remote.js +0 -1
- package/dist/src/execution/subagent-tool.js +0 -1
- package/dist/src/execution/tasks/child/instructions.d.ts +0 -3
- package/dist/src/execution/tasks/child/instructions.js +0 -1
- package/dist/src/execution/tasks/parent/agent-identity.d.ts +0 -13
- package/dist/src/execution/tasks/parent/agent-identity.js +0 -1
- package/dist/src/execution/tasks/parent/agent-views.d.ts +0 -7
- package/dist/src/execution/tasks/parent/agent-views.js +0 -1
- package/dist/src/execution/tasks/parent/continuation-dispatch.d.ts +0 -43
- package/dist/src/execution/tasks/parent/continuation-dispatch.js +0 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +0 -19
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +0 -1
- package/dist/src/execution/tool-run/answer.js +0 -1
- package/dist/src/execution/tool-run/background.d.ts +0 -14
- package/dist/src/execution/tool-run/background.js +0 -1
- package/dist/src/execution/tool-run/cancel.d.ts +0 -7
- package/dist/src/execution/tool-run/cancel.js +0 -1
- package/dist/src/execution/tool-run/dispatch.d.ts +0 -24
- package/dist/src/execution/tool-run/dispatch.js +0 -1
- package/dist/src/execution/tool-run/emit-run-report-step.d.ts +0 -7
- package/dist/src/execution/tool-run/emit-run-report-step.js +0 -1
- package/dist/src/execution/tool-run/messages.d.ts +0 -70
- package/dist/src/execution/tool-run/messages.js +0 -1
- package/dist/src/execution/tool-run/owner-inbox.d.ts +0 -11
- package/dist/src/execution/tool-run/owner-inbox.js +0 -1
- package/dist/src/execution/tool-run/owner.d.ts +0 -13
- package/dist/src/execution/tool-run/owner.js +0 -1
- package/dist/src/execution/tool-run/run-control.d.ts +0 -18
- package/dist/src/execution/tool-run/run-control.js +0 -1
- package/dist/src/execution/tool-run/start.d.ts +0 -11
- package/dist/src/execution/tool-run/start.js +0 -1
- package/dist/src/execution/tool-run/types.d.ts +0 -21
- package/dist/src/execution/tool-run/types.js +0 -1
- package/dist/src/execution/tool-run/workflow.d.ts +0 -9
- package/dist/src/execution/tool-run/workflow.js +0 -1
- package/dist/src/execution/tools/subagent/local.d.ts +0 -40
- package/dist/src/execution/tools/subagent/local.js +0 -1
- package/dist/src/execution/tools/subagent/remote.d.ts +0 -26
- package/dist/src/execution/tools/subagent/remote.js +0 -1
- package/dist/src/harness/agent-handle-errors.js +0 -1
- package/dist/src/harness/handles/query.js +0 -1
- package/dist/src/harness/handles/store.js +0 -1
- package/dist/src/harness/handles/transitions.d.ts +0 -167
- package/dist/src/harness/handles/transitions.js +0 -1
- package/dist/src/harness/runtime-actions.js +0 -1
- package/dist/src/harness/subagent-depth.d.ts +0 -10
- package/dist/src/harness/subagent-depth.js +0 -1
- package/dist/src/harness/tool-runs.d.ts +0 -21
- package/dist/src/harness/tool-runs.js +0 -1
- package/dist/src/harness/workflow-runtime-action-state.d.ts +0 -9
- package/dist/src/harness/workflow-runtime-action-state.js +0 -1
- package/dist/src/runtime/actions/keys.d.ts +0 -14
- package/dist/src/runtime/actions/keys.js +0 -1
- package/dist/src/tasks/wire.d.ts +0 -25
- package/dist/src/tasks/wire.js +0 -1
- /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.d.ts +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.js +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.d.ts +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.js +0 -0
- /package/dist/src/{execution/subagent-adapter.d.ts → subagents/adapter.d.ts} +0 -0
- /package/dist/src/{execution/session-callback-route.d.ts → subagents/callback-route.d.ts} +0 -0
- /package/dist/src/{execution/session-callback-step.d.ts → subagents/callback-step.d.ts} +0 -0
- /package/dist/src/{harness → subagents}/handles/operation-id.d.ts +0 -0
- /package/dist/src/{harness → subagents}/handles/operation-id.js +0 -0
- /package/dist/src/{harness → subagents}/handles/state-key.d.ts +0 -0
- /package/dist/src/{harness → subagents}/handles/state-key.js +0 -0
- /package/dist/src/{execution/subagent-hitl-proxy.d.ts → subagents/hitl-proxy.d.ts} +0 -0
- /package/dist/src/{execution/subagent-hitl-proxy.js → subagents/hitl-proxy.js} +0 -0
- /package/dist/src/{execution/subagent-invocation.d.ts → subagents/invocation.d.ts} +0 -0
- /package/dist/src/{execution/subagent-invocation.js → subagents/invocation.js} +0 -0
- /package/dist/src/{execution/delegated-parent-result.d.ts → subagents/parent-result.d.ts} +0 -0
- /package/dist/src/{execution/remote-agent-route-url.d.ts → subagents/remote-route-url.d.ts} +0 -0
- /package/dist/src/{execution/remote-agent-route-url.js → subagents/remote-route-url.js} +0 -0
- /package/dist/src/{harness/subagent-token-budget.d.ts → subagents/token-budget.d.ts} +0 -0
- /package/dist/src/{harness/subagent-token-budget.js → subagents/token-budget.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resumeHook}from"#internal/workflow/runtime.js";async function forwardLocalTaskUpdateStep(e){"use step";await resumeHook(e.parentContinuationToken,e.update)}export{forwardLocalTaskUpdateStep};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { ChannelAdapter } from "#channel/adapter.js";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
readonly updateEpoch: string;
|
|
10
|
-
readonly serializedContext: Record<string, unknown> | undefined;
|
|
11
|
-
}): Promise<RuntimeActionResult>;
|
|
2
|
+
import type { TaskInboundUpdate } from "#tasks/types.js";
|
|
3
|
+
/** Delivers a task update through the local child adapter or remote callback. */
|
|
4
|
+
export declare function deliverTaskUpdate(input: {
|
|
5
|
+
readonly adapter?: ChannelAdapter;
|
|
6
|
+
readonly callback: unknown;
|
|
7
|
+
readonly update: TaskInboundUpdate;
|
|
8
|
+
}): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{fireTaskUpdateCallbackStep}from"#subagents/callback-step.js";import{forwardLocalTaskUpdateStep}from"#execution/tasks/child/update-step.js";import{SUBAGENT_ADAPTER_KIND,isSubagentAdapterState}from"#subagents/adapter-state.js";async function deliverTaskUpdate(e){let t=e.adapter?.state;return e.adapter?.kind===SUBAGENT_ADAPTER_KIND&&isSubagentAdapterState(t)&&t.taskId!==void 0?(await forwardLocalTaskUpdateStep({parentContinuationToken:t.parentContinuationToken,update:e.update}),t.taskId):await fireTaskUpdateCallbackStep({callback:e.callback,callId:e.update.callId,message:e.update.message,updateEpoch:e.update.updateEpoch,updateIndex:e.update.updateIndex})}export{deliverTaskUpdate};
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type TaskView } from "#tasks/types.js";
|
|
3
|
-
/** Input for one durable task run. */
|
|
1
|
+
import { type WorkflowBodyDefinition } from "#execution/tools/workflow/body.js";
|
|
2
|
+
import { type TaskInputRequest, type TaskView } from "#tasks/types.js";
|
|
4
3
|
export interface TaskRunWorkflowInput {
|
|
5
|
-
/** Activity sink and work identity for best-effort terminal settlement. */
|
|
6
|
-
readonly activityObserver?: ActivityObserverConfig;
|
|
7
|
-
/** Private task inbox token; a routing credential, never model-visible. */
|
|
8
|
-
readonly taskInboxToken: string;
|
|
9
|
-
/** The creation view, normally `working`. */
|
|
10
4
|
readonly initialView: TaskView;
|
|
11
|
-
/** Parent session delivery token used to wake the task's owning parent. */
|
|
12
5
|
readonly parentContinuationToken: string;
|
|
6
|
+
readonly taskInboxToken: string;
|
|
7
|
+
readonly workflow?: WorkflowBodyDefinition;
|
|
8
|
+
}
|
|
9
|
+
/** A workflow-body question routed through the task that owns the workflow tool run. */
|
|
10
|
+
interface WorkflowToolRunTaskInputRequestBase {
|
|
11
|
+
readonly kind: "task-input-request";
|
|
12
|
+
readonly replyTo: string;
|
|
13
|
+
readonly sequence: number;
|
|
14
|
+
readonly stepIndex: number;
|
|
15
|
+
readonly turnId: string;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* change nothing.
|
|
23
|
-
*
|
|
24
|
-
* Wake policy: a transition into a ready status — terminal or
|
|
25
|
-
* `input_required` — and an explicit child `task_update` deliver a
|
|
26
|
-
* framework notification to the parent session. A parked parent starts
|
|
27
|
-
* a turn; an active turn observes the delivery at its next safe boundary.
|
|
28
|
-
*
|
|
29
|
-
* The run ends when the task reaches a terminal status. Its view
|
|
30
|
-
* stream stays readable, so terminal tasks remain peekable; the
|
|
31
|
-
* disposed hook makes any later command fail loudly instead of queueing
|
|
32
|
-
* against a finished task.
|
|
33
|
-
*/
|
|
17
|
+
export type WorkflowToolRunTaskInputRequest = WorkflowToolRunTaskInputRequestBase & ({
|
|
18
|
+
readonly request: TaskInputRequest;
|
|
19
|
+
readonly requests?: never;
|
|
20
|
+
} | {
|
|
21
|
+
readonly request?: never;
|
|
22
|
+
readonly requests: readonly TaskInputRequest[];
|
|
23
|
+
});
|
|
24
|
+
/** Owns lifecycle for one background task and consumes its executor traffic. */
|
|
34
25
|
export declare function taskRunWorkflow(input: TaskRunWorkflowInput): Promise<void>;
|
|
26
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{isReadyTaskStatus,isTerminalTaskStatus,readTaskInputRequestId
|
|
1
|
+
import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{isReadyTaskStatus,isTerminalTaskStatus,readTaskInputRequestId}from"#tasks/types.js";import{appendTaskViewStep,deliverTaskInputResponsesStep,wakeTaskAgentRequestParentStep,wakeTaskAuthorizationParentStep,wakeTaskParentStep,wakeTaskUpdateParentStep,wakeWorkflowTaskInputRequestParentStep}from"#execution/tasks/child/steps.js";import{createWorkflowBodyRef,executeWorkflowBody}from"#execution/tools/workflow/body.js";import{deriveWorkflowToolRunOwner}from"#execution/tools/workflow/messages.js";import{createChannelReader,raceChannelReads}from"#execution/tools/workflow/owner-channels.js";import{openWorkflowToolRunOwnerChannels}from"#execution/tools/workflow/owner.js";import{workflowToolRunOutcomeToTaskCommand,workflowToolRunReportToTaskUpdate,workflowToolRunRequestToTaskInputRequest}from"#execution/tools/workflow/owner-inbox.js";import{applyTaskTransition}from"#tasks/transitions.js";async function taskRunWorkflow(a){"use workflow";let o=createHook({token:a.taskInboxToken}),c=openWorkflowToolRunOwnerChannels(a.taskInboxToken),l=[...c.readers,createChannelReader(`commands`,o)],u=!1,d=a.initialView,f=!1,p=!1,m,h=[],g=0,_={ownerRequests:[]},v=new Map,y=new AbortController,b,x=a.workflow===void 0;try{try{await claimHookOwnership(o),u=!0}catch(e){if(isHookConflictError(e))return;throw e}for(await appendTaskViewStep({view:d});!isFinished();){let e=await raceChannelReads(b===void 0?l:[...l,b]);if(e.channel===`body`){if(x=!0,b=void 0,e.next.done)continue;await applyPayload({command:workflowToolRunOutcomeToTaskCommand({from:createWorkflowBodyRef({...a.workflow,execution:`background`}),result:e.next.value}),kind:`task-command`}),d.status===`cancelled`&&f&&!p&&await wakeTaskParentStep({token:a.parentContinuationToken,view:d});continue}if(e.next.done)return;if(e.channel===`report`){await applyPayload(workflowToolRunReportToTaskUpdate(e.next.value,d.taskId,g++));continue}if(e.channel===`outcome`){await applyPayload({command:workflowToolRunOutcomeToTaskCommand(e.next.value),kind:`task-command`});continue}if(e.channel===`request`){let t=e.next.value,n=t.request.kind;if(n===`agent-invoke`||n===`agent-settled`||n===`authorization-request`){await handleOwnerRequest(t);continue}t.requestCoordinates===void 0&&v.set(t.replyTo,{runId:t.from.runId}),await applyPayload(workflowToolRunRequestToTaskInputRequest(t));continue}await applyPayload(e.next.value)}}finally{u&&(await c.dispose(),await disposeHook(o))}function isFinished(){return isTerminalTaskStatus(d.status)&&f&&x}async function handleUpdate(e){f&&!isTerminalTaskStatus(d.status)?await wakeTaskUpdateParentStep({token:a.parentContinuationToken,update:e,view:d}):h.push(e)}async function applyPayload(e){let t=e.kind===`task-command`&&e.command.kind===`ready`,n=e.kind===`task-command`&&e.command.kind===`reject-dispatch`;if((t||n)&&(f=!0),n&&(p=!0),(t||n)&&(n||isTerminalTaskStatus(d.status)?x=!0:a.workflow!==void 0&&b===void 0&&!x&&(b=createChannelReader(`body`,awaitBodyResult(executeWorkflowBody({...a.workflow,execution:`background`,owner:deriveWorkflowToolRunOwner(a.taskInboxToken)},y.signal)))),await flushPendingTraffic()),e.kind===`task-input-request`&&(m=e),e.kind===`task-update`){await handleUpdate(e);return}let r;if(e.kind===`input-response`)r=d.status===`input_required`?await resolveAnsweredCommand(d,e,v.get(e.childContinuationToken)):void 0;else if(e.kind===`task-input-request`)r={inputRequests:e.requests??[e.request],kind:`require-input`};else if(e.kind===`task-command`)r=e.command;else return;if(r===void 0)return;if(t&&isTerminalTaskStatus(d.status)){await flushUpdates(!0),await wakeTaskParentStep({token:a.parentContinuationToken,view:d});return}let o=d,s=applyTaskTransition(d,r);s.action===`accepted`&&(d=s.view,await appendTaskViewStep({view:d}),r.kind===`cancel`&&(y.abort(Error(`Task ${d.taskId} was cancelled.`)),b===void 0&&(x=!0)),isTerminalTaskStatus(d.status)||await flushUpdates(),m!==void 0&&f&&d.status===`input_required`?(await wakeWorkflowTaskInputRequestParentStep({request:m,taskId:d.taskId,token:a.parentContinuationToken}),m=void 0):!p&&f&&(r.kind!==`cancel`||x)&&(!isTerminalTaskStatus(o.status)&&isTerminalTaskStatus(d.status)||!isReadyTaskStatus(o.status)&&isReadyTaskStatus(d.status)&&m===void 0)&&await wakeTaskParentStep({token:a.parentContinuationToken,view:d}),d.status!==`input_required`&&(m=void 0))}async function flushUpdates(e=!1){if(!(!f||isTerminalTaskStatus(d.status)&&!e)){for(let e of h)await wakeTaskUpdateParentStep({token:a.parentContinuationToken,update:e,view:d});h=[]}}async function handleOwnerRequest(e){if(!(p||isTerminalTaskStatus(d.status))){if(!f){_.ownerRequests.push(e);return}await wakeTaskOwnerRequestParent(e)}}async function flushPendingTraffic(){if(!p)for(let e of _.ownerRequests)await wakeTaskOwnerRequestParent(e);_.ownerRequests.length=0}async function wakeTaskOwnerRequestParent(e){if(e.request.kind===`authorization-request`){await wakeTaskAuthorizationParentStep({request:e.request,taskId:d.taskId,token:a.parentContinuationToken});return}await wakeTaskAgentRequestParentStep({request:e,taskId:d.taskId,token:a.parentContinuationToken})}}async function*awaitBodyResult(e){yield await e}async function resolveAnsweredCommand(e,t,n){if(t.taskId!==e.taskId)return;let r=new Set(e.inputRequests.flatMap(e=>{let t=readTaskInputRequestId(e);return t===void 0?[]:[t]})),i=t.inputResponses.map(e=>e.requestId).filter(e=>r.has(e));if(i.length!==0)return await deliverTaskInputResponsesStep({answer:t,answerHook:n,requestIds:i})===`delivered`?{kind:`answered`,requestIds:i}:void 0}export{taskRunWorkflow};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { RuntimeSession } from "#
|
|
2
|
-
import {
|
|
3
|
-
import type { RuntimeActionResult } from "#shared/action-types.js";
|
|
4
|
-
import type { TaskControlInvocation } from "#shared/dispatch-action.js";
|
|
1
|
+
import type { HarnessSession as RuntimeSession } from "#harness/types.js";
|
|
2
|
+
import type { RuntimeActionResult, RuntimeToolCallActionRequest } from "#shared/action-types.js";
|
|
5
3
|
import { type SessionTaskIndexEntry } from "#tasks/session-index.js";
|
|
6
|
-
import {
|
|
4
|
+
import type { TaskView } from "#tasks/types.js";
|
|
7
5
|
/**
|
|
8
6
|
* Result and lookup helpers shared by the task-control executors
|
|
9
7
|
* (`task_cancel` in the dispatch module,
|
|
@@ -20,18 +18,9 @@ export declare function lookupTaskEntries(session: RuntimeSession, taskIds: read
|
|
|
20
18
|
/** Reads the latest view of every entry, defaulting to `working`. */
|
|
21
19
|
export declare function readTaskViews(entries: readonly SessionTaskIndexEntry[]): Promise<TaskView[]>;
|
|
22
20
|
export declare function readTaskView(entry: SessionTaskIndexEntry): Promise<TaskView>;
|
|
23
|
-
/** Finds the persistent address record for one task-owned agent. */
|
|
24
|
-
export declare function findTaskAgentAddress(session: RuntimeSession, agentId: string): Extract<AgentHandle, {
|
|
25
|
-
phase: "addressed";
|
|
26
|
-
}> | undefined;
|
|
27
|
-
/** Returns the one nonterminal task owning an agent, if any. */
|
|
28
|
-
export declare function findActiveTaskForAgent(session: RuntimeSession, agentId: string, parentTurnId?: string, parentStepIndex?: number): Promise<{
|
|
29
|
-
readonly entry: SessionTaskIndexEntry;
|
|
30
|
-
readonly view: TaskView;
|
|
31
|
-
} | undefined>;
|
|
32
21
|
/** One successful task-control result carrying full task views. */
|
|
33
|
-
export declare function createTaskViewsResult(action:
|
|
22
|
+
export declare function createTaskViewsResult(action: RuntimeToolCallActionRequest, views: readonly TaskView[]): RuntimeActionResult;
|
|
34
23
|
/** One task-control error the model can act on. */
|
|
35
|
-
export declare function createTaskControlError(action:
|
|
24
|
+
export declare function createTaskControlError(action: RuntimeToolCallActionRequest, message: string): RuntimeActionResult;
|
|
36
25
|
/** The ownership error for ids outside this session's task index. */
|
|
37
|
-
export declare function createUnknownTasksError(action:
|
|
26
|
+
export declare function createUnknownTasksError(action: RuntimeToolCallActionRequest, unknown: readonly string[]): RuntimeActionResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{taskViewsToJson}from"#tasks/json.js";function lookupTaskEntries(e,n){let r=[],i=[];for(let a of n){let n=findSessionTaskEntry(e.state,a);n===void 0?i.push(a):r.push(n)}return i.length>0?{kind:`unknown`,unknown:i}:{entries:r,kind:`found`}}async function readTaskViews(e){return Promise.all(e.map(readTaskView))}async function readTaskView(t){try{return await readLatestTaskView({taskRunId:t.taskRunId})??createPendingTaskView(t)}catch(e){if(isTaskWorkflowTargetGone(e)&&t.terminalView!==void 0)return t.terminalView;throw e}}function createPendingTaskView(e){let t={metadata:e.metadata,status:`working`,taskId:e.taskId};return e.executor===void 0?t:{...t,executor:{binding:e.executor}}}function createTaskViewsResult(e,t){return{callId:e.callId,kind:`tool-result`,output:taskViewsToJson(t),toolName:e.toolName}}function createTaskControlError(e,t){return{callId:e.callId,isError:!0,kind:`tool-result`,output:{message:t},toolName:e.toolName}}function createUnknownTasksError(e,t){return createTaskControlError(e,`Unknown task ids: ${t.join(`, `)}. Tasks belong to the session that created them.`)}export{createTaskControlError,createTaskViewsResult,createUnknownTasksError,lookupTaskEntries,readTaskView,readTaskViews};
|
|
@@ -1,72 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* builds metadata and the parked-tool-call receipt, records the session
|
|
4
|
-
* index, and defines failure semantics for an unacknowledged dispatch.
|
|
2
|
+
* Generic task creation, readiness acknowledgement, and dispatch rejection.
|
|
5
3
|
* Task-run transport (start/command/view) lives in `run-parent.ts`, which
|
|
6
|
-
*
|
|
4
|
+
* Callers compose these primitives around their own executor policy.
|
|
7
5
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
import type { RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
10
|
-
import type { RuntimeSubagentChildResult } from "#shared/action-types.js";
|
|
6
|
+
import type { HarnessSession } from "#harness/types.js";
|
|
11
7
|
import type { JsonValue } from "#shared/json.js";
|
|
12
8
|
import type { TaskExecutorBinding } from "#tools/task.js";
|
|
13
|
-
import { type
|
|
9
|
+
import { type TaskMetadata } from "#tasks/types.js";
|
|
14
10
|
/** A prepared background task: identity plus its started durable run. */
|
|
15
11
|
export interface BackgroundTask {
|
|
16
12
|
readonly taskInboxToken: string;
|
|
17
13
|
readonly createdByStepIndex?: number;
|
|
18
14
|
readonly createdByTurnId: string;
|
|
19
15
|
readonly executor?: TaskExecutorBinding;
|
|
20
|
-
readonly metadata:
|
|
16
|
+
readonly metadata: TaskMetadata;
|
|
21
17
|
readonly taskId: string;
|
|
22
18
|
readonly taskRunId: string;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Creates the durable task record for one delegated subagent call,
|
|
30
|
-
* before the child dispatch side effect. The task must exist first so
|
|
31
|
-
* a fast child always finds a live command hook; a duplicate replay
|
|
32
|
-
* re-derives the same token and the loser exits on the hook claim.
|
|
33
|
-
*/
|
|
34
|
-
export declare function beginDelegatedTask(input: {
|
|
35
|
-
readonly activityObserver?: ActivityObserverConfig;
|
|
36
|
-
readonly agentId: string;
|
|
20
|
+
type BackgroundTaskDraft = Omit<BackgroundTask, "taskRunId">;
|
|
21
|
+
/** Derives the replay-stable task identity before its owning run is started. */
|
|
22
|
+
export declare function prepareBackgroundTask(input: {
|
|
37
23
|
readonly callId: string;
|
|
38
|
-
readonly
|
|
39
|
-
readonly name: string;
|
|
24
|
+
readonly metadata: TaskMetadata;
|
|
40
25
|
readonly parentSessionId: string;
|
|
41
26
|
readonly parentStepIndex?: number;
|
|
42
27
|
readonly parentTurnId: string;
|
|
43
|
-
readonly session:
|
|
44
|
-
}):
|
|
45
|
-
/**
|
|
28
|
+
readonly session: HarnessSession;
|
|
29
|
+
}): BackgroundTaskDraft;
|
|
30
|
+
/** Starts a lifecycle-only task run for a non-workflow external executor. */
|
|
46
31
|
export declare function beginBackgroundTask(input: {
|
|
47
|
-
readonly activityObserver?: ActivityObserverConfig;
|
|
48
32
|
readonly callId: string;
|
|
49
|
-
readonly metadata:
|
|
33
|
+
readonly metadata: TaskMetadata;
|
|
50
34
|
readonly parentSessionId: string;
|
|
51
35
|
readonly parentStepIndex?: number;
|
|
52
36
|
readonly parentTurnId: string;
|
|
53
|
-
readonly session:
|
|
37
|
+
readonly session: HarnessSession;
|
|
54
38
|
}): Promise<BackgroundTask>;
|
|
55
|
-
/**
|
|
56
|
-
* Settles a delegated dispatch that acknowledged a child: persists the task
|
|
57
|
-
* in the session index and returns the receipt that resolves the originating
|
|
58
|
-
* tool call. Agent identity and routing remain in the persistent address
|
|
59
|
-
* record; task state owns execution availability.
|
|
60
|
-
*/
|
|
61
|
-
export declare function settleDelegatedDispatch(input: {
|
|
62
|
-
readonly callId: string;
|
|
63
|
-
readonly session: RuntimeSession;
|
|
64
|
-
readonly subagentName: string;
|
|
65
|
-
readonly task: DelegatedTask;
|
|
66
|
-
}): Promise<{
|
|
67
|
-
readonly receipt: RuntimeSubagentChildResult;
|
|
68
|
-
readonly session: RuntimeSession;
|
|
69
|
-
}>;
|
|
70
39
|
/** Releases task events only after the parent session index committed. */
|
|
71
40
|
export declare function acknowledgeDelegatedTasksStep(input: {
|
|
72
41
|
readonly tasks: readonly {
|
|
@@ -75,13 +44,9 @@ export declare function acknowledgeDelegatedTasksStep(input: {
|
|
|
75
44
|
readonly taskRunId: string;
|
|
76
45
|
}[];
|
|
77
46
|
}): Promise<void>;
|
|
78
|
-
/** Fails an indexed task whose child dispatch was definitively rejected. */
|
|
79
|
-
export declare function failDelegatedDispatch(input: {
|
|
80
|
-
readonly error: JsonValue;
|
|
81
|
-
readonly task: DelegatedTask;
|
|
82
|
-
}): Promise<void>;
|
|
83
47
|
/** Silently terminates a task whose child dispatch failed before parent indexing. */
|
|
84
48
|
export declare function rejectDelegatedDispatch(input: {
|
|
85
49
|
readonly error: JsonValue;
|
|
86
50
|
readonly task: BackgroundTask;
|
|
87
51
|
}): Promise<void>;
|
|
52
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionCommandHookToken}from"#execution/session-command-token.js";import{
|
|
1
|
+
import{sessionCommandHookToken}from"#execution/session-command-token.js";import{readLatestTaskView,sendTaskCommand,sendTaskCommandToOwner,startTaskRun,waitForTaskCommandOwner}from"#execution/tasks/parent/run-parent.js";import{isTerminalTaskStatus}from"#tasks/types.js";import{deriveTaskId,deriveTaskInboxToken}from"#tasks/task-id.js";function prepareBackgroundTask(e){let t=deriveTaskId({callId:e.callId,parentSessionId:e.parentSessionId,parentTurnId:e.parentTurnId});return{taskInboxToken:deriveTaskInboxToken({parentContinuationToken:e.session.continuationToken,taskId:t}),createdByStepIndex:e.parentStepIndex??0,createdByTurnId:e.parentTurnId,metadata:e.metadata,taskId:t}}async function beginBackgroundTask(t){let n=prepareBackgroundTask(t);await startTaskRun({taskInboxToken:n.taskInboxToken,initialView:{metadata:n.metadata,status:`working`,taskId:n.taskId},parentContinuationToken:sessionCommandHookToken(t.session.sessionId)});let r=await waitForTaskCommandOwner({taskInboxToken:n.taskInboxToken});return{...n,taskRunId:r.runId}}async function acknowledgeDelegatedTasksStep(e){"use step";for(let n of e.tasks){if(await sendTaskCommandToOwner({command:{kind:`ready`},taskInboxToken:n.taskInboxToken,retryUnreachable:{attempts:20,delayMs:250}})!==void 0)continue;let e=await readLatestTaskView({taskRunId:n.taskRunId});if(!(e!==void 0&&isTerminalTaskStatus(e.status)))throw Error(`Task run "${n.taskId}" did not accept its readiness command.`)}}async function rejectDelegatedDispatch(e){await sendTaskCommand({command:{data:e.error,kind:`reject-dispatch`},taskInboxToken:e.task.taskInboxToken,retryUnreachable:{attempts:20,delayMs:250}})}export{acknowledgeDelegatedTasksStep,beginBackgroundTask,prepareBackgroundTask,rejectDelegatedDispatch};
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import type { RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
2
1
|
import type { ChannelAdapter } from "#channel/adapter.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import
|
|
6
|
-
import type {
|
|
2
|
+
import type { HarnessSession as RuntimeSession } from "#harness/types.js";
|
|
3
|
+
import type { BackgroundTask } from "#execution/tasks/parent/delegate.js";
|
|
4
|
+
import { type TaskExecutorCancel } from "#execution/tasks/parent/task-cancel.js";
|
|
5
|
+
import type { RuntimeActionResult, RuntimeToolCallActionRequest } from "#shared/action-types.js";
|
|
7
6
|
import type { SessionTaskIndexEntry } from "#tasks/session-index.js";
|
|
8
|
-
import { type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* Returns the current session alongside the action result.
|
|
17
|
-
*/
|
|
7
|
+
import { type TaskInboundUpdate, type TaskView } from "#tasks/types.js";
|
|
8
|
+
export type DeliverTaskUpdate = (input: {
|
|
9
|
+
readonly adapter?: ChannelAdapter;
|
|
10
|
+
readonly callback: unknown;
|
|
11
|
+
readonly update: TaskInboundUpdate;
|
|
12
|
+
}) => Promise<string | undefined>;
|
|
13
|
+
export declare function isTaskControlAction(action: RuntimeToolCallActionRequest): boolean;
|
|
18
14
|
export declare function executeTaskControlAction(input: {
|
|
19
|
-
readonly action:
|
|
15
|
+
readonly action: RuntimeToolCallActionRequest;
|
|
20
16
|
readonly adapter?: ChannelAdapter;
|
|
21
|
-
readonly bundle: CompiledBundle;
|
|
17
|
+
readonly bundle: import("#runtime/sessions/runtime-context-keys.js").CompiledBundle;
|
|
18
|
+
readonly cancelOwnedWork?: TaskExecutorCancel;
|
|
19
|
+
readonly deliverUpdate?: DeliverTaskUpdate;
|
|
22
20
|
readonly parentStepIndex?: number;
|
|
23
21
|
readonly parentTurnId: string;
|
|
24
22
|
readonly serializedContext?: Record<string, unknown>;
|
|
@@ -26,25 +24,12 @@ export declare function executeTaskControlAction(input: {
|
|
|
26
24
|
}): Promise<{
|
|
27
25
|
readonly result: RuntimeActionResult;
|
|
28
26
|
readonly session: RuntimeSession;
|
|
29
|
-
readonly pendingTask?:
|
|
27
|
+
readonly pendingTask?: BackgroundTask;
|
|
30
28
|
}>;
|
|
31
|
-
/** Commits
|
|
29
|
+
/** Commits cancellation, then stops task-owned child work and its lifecycle run. */
|
|
32
30
|
export declare function cancelOwnedTask(input: {
|
|
33
|
-
readonly
|
|
31
|
+
readonly cancelOwnedWork?: TaskExecutorCancel;
|
|
34
32
|
readonly entry: SessionTaskIndexEntry;
|
|
35
33
|
readonly serializedContext?: Record<string, unknown>;
|
|
36
|
-
readonly session
|
|
34
|
+
readonly session?: RuntimeSession;
|
|
37
35
|
}): Promise<TaskView>;
|
|
38
|
-
/**
|
|
39
|
-
* Sends the cooperative abort to the child identified by a subagent
|
|
40
|
-
* executor binding. Failures are logged, never thrown: the task is already
|
|
41
|
-
* terminal when this runs, so the worst outcome is a child that runs to
|
|
42
|
-
* completion and has its callback refused.
|
|
43
|
-
*/
|
|
44
|
-
export declare function propagateSubagentExecutorCancel(input: {
|
|
45
|
-
readonly bundle: CompiledBundle | undefined;
|
|
46
|
-
readonly childTurnId?: string;
|
|
47
|
-
readonly executor: SubagentExecutorData;
|
|
48
|
-
readonly serializedContext?: Record<string, unknown>;
|
|
49
|
-
readonly taskId: string;
|
|
50
|
-
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{sendTaskCommand}from"#execution/tasks/parent/run-parent.js";import{isTerminalTaskStatus}from"#tasks/types.js";import{createTaskControlError,createTaskViewsResult,createUnknownTasksError,lookupTaskEntries,readTaskView}from"#execution/tasks/parent/control-shared.js";import{cancelTaskOwnedWork}from"#execution/tasks/parent/task-cancel.js";import{TASK_CANCEL_TOOL_NAME,TASK_TOOL_NAMES,TASK_UPDATE_TOOL_NAME}from"#tools/framework/task-contract.js";function isTaskControlAction(e){return e.kind===`tool-call`&&TASK_TOOL_NAMES.has(e.toolName)}async function executeTaskControlAction(e){let{action:t,session:o}=e;if(t.toolName===TASK_UPDATE_TOOL_NAME){let r=t.input.message;if(typeof r!=`string`||r.trim()===``)return{result:createTaskControlError(t,"Provide a non-empty `message`."),session:o};let i={callId:t.callId,kind:`task-update`,message:r,updateEpoch:e.parentTurnId,updateIndex:e.parentStepIndex??0},a=await e.deliverUpdate?.({adapter:e.adapter,callback:e.serializedContext?.[`eve.sessionCallback`],update:i});return{result:a===void 0?createTaskControlError(t,`task_update requires a task-owned session.`):{callId:t.callId,kind:`tool-result`,output:{status:`sent`,taskId:a},toolName:t.toolName},session:o}}let s=readTaskIds(t.input);if(s===void 0||s.length===0)return{result:createTaskControlError(t,"Provide a non-empty `taskIds` array."),session:o};let c=lookupTaskEntries(o,s);if(c.kind===`unknown`)return{result:createUnknownTasksError(t,c.unknown),session:o};if(t.toolName!==TASK_CANCEL_TOOL_NAME)return{result:createTaskControlError(t,`Unsupported task control "${t.toolName}".`),session:o};let l=[];for(let t of c.entries)l.push(await cancelOwnedTask({cancelOwnedWork:e.cancelOwnedWork,entry:t,serializedContext:e.serializedContext,session:o}));return{result:createTaskViewsResult(t,l),session:o}}async function cancelOwnedTask(n){let r=await sendTaskCommand({command:{kind:`cancel`},taskInboxToken:n.entry.taskInboxToken}),i=await readTaskView(n.entry);for(let e=0;e<10&&!isTerminalTaskStatus(i.status);e+=1)await new Promise(e=>setTimeout(e,250)),i=await readTaskView(n.entry);if(!isTerminalTaskStatus(i.status))throw Error(`Task "${n.entry.taskId}" did not commit cancellation before timeout.`);return i.status!==`cancelled`||r!==`delivered`||await cancelTaskOwnedWork({cancelOwnedWork:n.cancelOwnedWork,entry:n.entry,serializedContext:n.serializedContext,session:n.session}),i}function readTaskIds(e){let t=e.taskIds;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&e.trim()!==``)}export{cancelOwnedTask,executeTaskControlAction,isTaskControlAction};
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import type { SubagentInputRequestHookPayload } from "#channel/types.js";
|
|
2
|
-
import type { SubagentAuthorizationEventHookPayload } from "#channel/types.js";
|
|
3
1
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
4
|
-
import {
|
|
5
|
-
/** Validates and
|
|
2
|
+
import type { TaskInputRequestDelivery, TaskView } from "#tasks/types.js";
|
|
3
|
+
/** Validates and records a generic task-owned workflow request. */
|
|
6
4
|
export declare function recordTaskInputRequestStep(input: {
|
|
7
|
-
readonly
|
|
8
|
-
readonly serializedContext: Record<string, unknown>;
|
|
5
|
+
readonly request: TaskInputRequestDelivery;
|
|
9
6
|
readonly sessionState: DurableSessionState;
|
|
10
|
-
readonly taskId: string;
|
|
11
7
|
}): Promise<{
|
|
12
8
|
readonly accepted: false;
|
|
13
9
|
readonly sessionState: DurableSessionState;
|
|
14
10
|
} | {
|
|
15
11
|
readonly accepted: true;
|
|
16
|
-
readonly
|
|
12
|
+
readonly request: TaskInputRequestDelivery;
|
|
17
13
|
readonly sessionState: DurableSessionState;
|
|
18
14
|
}>;
|
|
19
|
-
/**
|
|
20
|
-
export declare function acceptTaskAuthorizationEventStep(input: {
|
|
21
|
-
readonly hookPayload: SubagentAuthorizationEventHookPayload;
|
|
22
|
-
readonly sessionState: DurableSessionState;
|
|
23
|
-
readonly taskId: string;
|
|
24
|
-
}): Promise<boolean>;
|
|
25
|
-
/** Caches terminal task views before their workflow runs can expire. */
|
|
15
|
+
/** Caches terminal task views before their workflow runs expire. */
|
|
26
16
|
export declare function recordTerminalTaskViewsStep(input: {
|
|
27
17
|
readonly sessionState: DurableSessionState;
|
|
28
18
|
readonly views: readonly TaskView[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEveTaskInputRoutePath}from"#protocol/routes.js";import{isInputRequest}from"#shared/input.js";import{
|
|
1
|
+
import{createEveTaskInputRoutePath}from"#protocol/routes.js";import{isInputRequest}from"#shared/input.js";import{readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{createTaskInputRequestId,upsertProxyInputRequestState}from"#harness/proxy-input-requests.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{cacheTerminalTaskView,findSessionTaskEntry}from"#tasks/session-index.js";import{applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{createTaskInputCapabilityToken}from"#execution/task-input-capability.js";import{createRemoteTaskInputCallbackUrl}from"#execution/workflow-callback-url.js";async function recordTaskInputRequestStep(i){"use step";let a=await readDurableSession(i.sessionState),o=findSessionTaskEntry(a.state,i.request.taskId),s=i.request.requests??[i.request.request];if(o===void 0||s.length===0||!s.every(isInputRequest))return{accepted:!1,sessionState:i.sessionState};let c=await readLatestTaskView({taskRunId:o.taskRunId}),l=s.map(e=>e.requestId);if(c?.status!==`input_required`||c.inputRequests.length!==l.length||!c.inputRequests.every((e,t)=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Reflect.get(e,`requestId`)===l[t]))return{accepted:!1,sessionState:i.sessionState};let u=s.map(e=>({...e,requestId:createTaskInputRequestId(i.request.taskId,e.requestId)})),d=getAgentHandleStore(a.state)?.handles.find(e=>e.phase===`claimed`&&e.ownerId===i.request.taskId),f=d?.phase===`claimed`&&d.address.kind===`agent/remote`?createRemoteTaskInputCallbackUrl(d.address.url,createEveTaskInputRoutePath(createTaskInputCapabilityToken(i.request.replyTo))):void 0,p=upsertProxyInputRequestState({entries:s.map((e,t)=>{let n=u[t],r={childContinuationToken:i.request.replyTo,childRequestId:e.requestId,kind:e.kind,taskId:i.request.taskId};return f!==void 0&&(r.childResponseUrl=f),[n.requestId,r]}),forChildContinuationToken:i.request.replyTo,state:a.state});return{accepted:!0,request:i.request.requests===void 0?{...i.request,request:u[0]}:{...i.request,request:void 0,requests:u},sessionState:{...i.sessionState,hasProxyInputRequests:!0,snapshot:{session:{...a,state:p},version:i.sessionState.version}}}}async function recordTerminalTaskViewsStep(e){"use step";let t=await readDurableSession(e.sessionState),r=t;for(let t of e.views){if(findSessionTaskEntry(r.state,t.taskId)===void 0)continue;let e=cacheTerminalTaskView(r.state,t);e!==r.state&&(r={...r,state:e}),r=applyTaskAgentHandleCommand(r,{kind:`release-owner`,ownerId:t.taskId}).session}return r===t?e.sessionState:{...e.sessionState,snapshot:{session:r,version:e.sessionState.version}}}export{recordTaskInputRequestStep,recordTerminalTaskViewsStep};
|
|
@@ -3,8 +3,8 @@ import { type TaskCommand, type TaskRunInboundPayload, type TaskView } from "#ta
|
|
|
3
3
|
/**
|
|
4
4
|
* Node-side controls for durable task runs — the generic transport layer.
|
|
5
5
|
* This module only speaks `TaskCommand`/`TaskView`; it knows nothing about
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* executor implementations, receipts, or the session index. Caller-specific
|
|
7
|
+
* policy composes these primitives.
|
|
8
8
|
*
|
|
9
9
|
* Every export must be called from inside a `"use step"` body; none of
|
|
10
10
|
* these are steps themselves so dispatch and tool steps can compose them
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SessionTaskIndexEntry } from "#tasks/session-index.js";
|
|
2
|
+
export interface TaskExecutorCancelContext {
|
|
3
|
+
readonly entry: SessionTaskIndexEntry;
|
|
4
|
+
readonly serializedContext?: Record<string, unknown>;
|
|
5
|
+
readonly session?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export type TaskExecutorCancel = (input: TaskExecutorCancelContext) => Promise<void>;
|
|
8
|
+
/** Cancels policy-specific work associated with one task. */
|
|
9
|
+
export declare function cancelTaskOwnedWork(input: TaskExecutorCancelContext & {
|
|
10
|
+
readonly cancelOwnedWork?: TaskExecutorCancel;
|
|
11
|
+
}): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cancelRun,getRun,getWorld}from"#internal/workflow/runtime.js";import{cancelWorkflowToolRun}from"#execution/tools/workflow/cancel.js";import{readWorkflowToolExecutorAddress}from"#execution/tools/workflow/types.js";async function cancelTaskOwnedWork(t){let n=readWorkflowToolExecutorAddress(t.entry.executor);n!==void 0&&await cancelWorkflowToolRun(n,`Task ${t.entry.taskId} was cancelled.`),await t.cancelOwnedWork?.(t);let r=Date.now()+1e3;for(;Date.now()<r;){try{let e=await getRun(t.entry.taskRunId).status;if(e!==`pending`&&e!==`running`)return}catch{return}await new Promise(e=>setTimeout(e,50))}try{await cancelRun(await getWorld(),t.entry.taskRunId,{cancelReason:`Task ${t.entry.taskId} was cancelled.`})}catch{}}export{cancelTaskOwnedWork};
|
|
@@ -10,7 +10,7 @@ export declare function runBackgroundStep(ctx: ContextContainer, session: Harnes
|
|
|
10
10
|
/**
|
|
11
11
|
* Makes background tool work transactional with the harness step.
|
|
12
12
|
*
|
|
13
|
-
* Concretely: when the model calls a background tool
|
|
13
|
+
* Concretely: when the model calls a background tool,
|
|
14
14
|
* the tool does real external work mid-step — it creates a task run and
|
|
15
15
|
* delivers commands to its inbox — while the step itself can still fail. This
|
|
16
16
|
* provider scopes that work to the step so it either lands with the step or
|
|
@@ -23,8 +23,7 @@ export declare function runBackgroundStep(ctx: ContextContainer, session: Harnes
|
|
|
23
23
|
*
|
|
24
24
|
* - `commit` — step succeeded. Compensates executions that never settled
|
|
25
25
|
* (the tool neither delegated nor completed its task), then records the
|
|
26
|
-
* task entries
|
|
27
|
-
* persisted.
|
|
26
|
+
* task entries onto the session being persisted.
|
|
28
27
|
* - `rollback` — step failed. Compensates incomplete executions, and settled
|
|
29
28
|
* ones too — unless the cause is turn cancellation: those tasks are already
|
|
30
29
|
* running, so they are retained for {@link readRetainedBackgroundToolResult}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEveCallbackRoutePath}from"#protocol/routes.js";import{loadContext}from"#context/container.js";import{parseJsonValue}from"#shared/json.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState}from"#harness/emission.js";import{recordTaskAgentAddress}from"#harness/handles/transitions.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{cancelToolRun}from"#execution/tool-run/cancel.js";import{runStep}from"#context/run-step.js";import{activeTurnId}from"#harness/active-turn-id.js";import{propagateSubagentExecutorCancel}from"#execution/tasks/parent/dispatch.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";import{readWorkflowToolExecutor}from"#execution/tool-run/background.js";import{CallbackBaseUrlKey,isAuthorizationSignal}from"#harness/authorization.js";import{sendTaskCommand,sendTaskInboundPayload}from"#execution/tasks/parent/run-parent.js";import{recordSessionTask}from"#tasks/session-index.js";import{readSubagentExecutor}from"#tasks/types.js";import{beginBackgroundTask,rejectDelegatedDispatch}from"#execution/tasks/parent/delegate.js";import{BackgroundToolExecutorKey}from"#harness/background-tools.js";import{isAsyncIterable}from"#shared/async-iterable.js";import{createTaskDelegated,isTaskDelegated}from"#tools/task.js";function runBackgroundStep(e,t,n){return runStep(e,t,n,[backgroundToolExecutionProvider])}const backgroundToolExecutionProvider={key:BackgroundToolExecutorKey,create(e,t){return{value:new BackgroundToolExecutionScope(t,e.get(BundleKey))}},async commit(e,t){return await requireExecutionScope(e).commit(t)},async rollback(e,t){await requireExecutionScope(e).rollback(t)},decorateStepResult(e,t){return requireExecutionScope(e).decorate(t)}};function readRetainedBackgroundToolResult(e){let t=e.get(BackgroundToolExecutorKey);return t instanceof BackgroundToolExecutionScope?t.retainedResult():void 0}var BackgroundToolExecutionScope=class{bundle;executions=new Map;records=[];retained=!1;initialSession;constructor(e,t){this.bundle=t,this.initialSession=e}execute(e){let t=this.executions.get(e.options.toolCallId);if(t!==void 0)return t;if(!e.batch.calls.some(t=>t.callId===e.options.toolCallId))throw Error(`Background tool call "${e.options.toolCallId}" was not registered before execution.`);let n=this.start(e);return this.executions.set(e.options.toolCallId,n),n}async commit(e){let t=this.records.filter(e=>!e.settled);return t.length>0&&await compensateBackgroundToolExecution(t,Error(`Background tool execution did not delegate or complete its task.`),this.bundle),this.apply(e)}decorate(e){let t=this.resultFields();return t===void 0?e:{...e,...t}}async rollback(e){let t=this.records.filter(e=>e.settled),n=this.records.filter(e=>!e.settled);if(n.length>0&&await compensateBackgroundToolExecution(n,e,this.bundle),t.length!==0){if(isTurnCancellation(e)){this.retained=!0;return}await compensateBackgroundToolExecution(t,e,this.bundle)}}retainedResult(){return this.retained?this.resultFields():void 0}apply(e){let t=e;for(let e of this.records){if(!e.settled||e.task===void 0)continue;let n=readSubagentExecutor(e.task.executor);n!==void 0&&(t=recordTaskAgentAddress(t,n)),t=recordSessionTask(t,e.task)}return t}resultFields(){let e=this.records.flatMap(e=>e.settled&&e.task!==void 0?[e.task]:[]);if(e.length!==0)return{backgroundTaskSession:this.apply(this.initialSession),backgroundTasks:e.map(({taskInboxToken:e,taskId:t,taskRunId:n})=>({taskInboxToken:e,taskId:t,taskRunId:n}))}}async start(r){let a={settled:!1};this.records.push(a);let o=getHarnessEmissionState(this.initialSession.state),s=await beginBackgroundTask({callId:r.options.toolCallId,metadata:{kind:`tool`,name:r.definition.name},parentSessionId:this.initialSession.sessionId,parentStepIndex:o.stepIndex,parentTurnId:activeTurnId(o),session:this.initialSession});a.task=s;let c=loadContext().get(CallbackBaseUrlKey),l={taskId:s.taskId,token:s.taskInboxToken,...c===void 0?{}:{url:createWorkflowCallbackUrl(c,createEveCallbackRoutePath(s.taskInboxToken))}},u={batch:r.batch.calls,binding:l,delegated:({executor:e,receipt:t})=>createTaskDelegated({binding:l,executor:e,receipt:t}),send:createTaskSender(s,r.options.toolCallId),session:this.initialSession,task:s},d=r.definition.execute(r.toolInput,r.options,u);if(isAsyncIterable(d))throw Error(`Background tools cannot return AsyncIterable output.`);let f=await d;return isAuthorizationSignal(f)?f:isTaskDelegated(f)?(await deliverTaskCommand(s,{executor:f.executor,kind:`bind`}),a.task={...s,executor:f.executor},a.settled=!0,f.receipt):(await deliverTaskCommand(s,{data:parseJsonValue(f),kind:`complete`}),a.settled=!0,f)}};function requireExecutionScope(e){if(!(e instanceof BackgroundToolExecutionScope))throw Error(`The background tool executor is not owned by the task runtime.`);return e}async function deliverTaskCommand(e,t){if(await sendTaskCommand({command:t,taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${t.kind}".`)}function createTaskSender(e,t){let n=0;return async r=>{if(r.kind!==`update`){await deliverTaskCommand(e,r);return}if(await sendTaskInboundPayload({payload:{callId:t,kind:`task-update`,message:r.message,updateEpoch:e.taskId,updateIndex:n++},taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${r.kind}".`)}}async function compensateBackgroundToolExecution(e,t,n){let r=[];for(let i of e.toReversed()){if(i.task===void 0)continue;try{await rejectDelegatedDispatch({error:{code:`PARENT_STEP_FAILED`,message:t instanceof Error?t.message:String(t)},task:i.task})}catch(e){r.push(e)}let e=readSubagentExecutor(i.task.executor);e!==void 0&&await propagateSubagentExecutorCancel({bundle:n,executor:e,taskId:i.task.taskId});let a=readWorkflowToolExecutor(i.task.executor);a!==void 0&&await cancelToolRun(a,`The step that started the tool failed.`)}if(r.length>0)throw AggregateError([t,...r],`Background tool execution failed and its tasks could not all be rejected.`,{cause:t})}export{backgroundToolExecutionProvider,readRetainedBackgroundToolResult,runBackgroundStep};
|
|
1
|
+
import{createEveCallbackRoutePath}from"#protocol/routes.js";import{sessionCommandHookToken}from"#execution/session-command-token.js";import{loadContext}from"#context/container.js";import{parseJsonValue}from"#shared/json.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{parseWorkflowToolInput}from"#execution/tools/workflow/background.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{runStep}from"#context/run-step.js";import{activeTurnId}from"#harness/active-turn-id.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";import{CallbackBaseUrlKey,isAuthorizationSignal}from"#harness/authorization.js";import{sendTaskCommand,sendTaskInboundPayload,startTaskRun,waitForTaskCommandOwner}from"#execution/tasks/parent/run-parent.js";import{recordSessionTask}from"#tasks/session-index.js";import{applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{BackgroundToolExecutorKey}from"#harness/background-tools.js";import{isAsyncIterable}from"#shared/async-iterable.js";import{createTaskDelegated,isTaskDelegated}from"#tools/task.js";import{beginBackgroundTask,prepareBackgroundTask,rejectDelegatedDispatch}from"#execution/tasks/parent/delegate.js";import{createSubagentReceiptIdentity}from"#execution/tools/subagent/receipt-identity.js";const IN_PROCESS_WORKFLOW_EXECUTOR={data:{},kind:`workflow-task`};function runBackgroundStep(e,t,n){return runStep(e,t,n,[backgroundToolExecutionProvider])}const backgroundToolExecutionProvider={key:BackgroundToolExecutorKey,create(e,t){return{value:new BackgroundToolExecutionScope(t)}},async commit(e,t){return await requireExecutionScope(e).commit(t)},async rollback(e,t){await requireExecutionScope(e).rollback(t)},decorateStepResult(e,t){return requireExecutionScope(e).decorate(t)}};function readRetainedBackgroundToolResult(e){let t=e.get(BackgroundToolExecutorKey);return t instanceof BackgroundToolExecutionScope?t.retainedResult():void 0}var BackgroundToolExecutionScope=class{executions=new Map;records=[];agentHandleSession;agentHandlesChanged=!1;retained=!1;initialSession;constructor(e){this.initialSession=e,this.agentHandleSession=e}execute(e){let t=this.executions.get(e.options.toolCallId);if(t!==void 0)return t;if(!e.batch.calls.some(t=>t.callId===e.options.toolCallId))throw Error(`Background tool call "${e.options.toolCallId}" was not registered before execution.`);let n=this.start(e);return this.executions.set(e.options.toolCallId,n),n}async readAgentViews(){return(getAgentHandleStore(this.agentHandleSession.state)?.handles??[]).flatMap(e=>e.phase===`reserved`?[]:e.phase===`available`?[{availability:`available`,id:e.identity.id,name:e.identity.name}]:e.phase===`claimed`?[{availability:`busy`,id:e.identity.id,name:e.identity.name,taskId:e.ownerId,taskStatus:`working`}]:[])}async commit(e){let t=this.records.filter(e=>!e.settled);return t.length>0&&await this.compensate(t,Error(`Background tool execution did not delegate or complete its task.`)),this.apply(e)}decorate(e){let t=this.resultFields();return t===void 0?e:{...e,...t}}async rollback(e){let t=this.records.filter(e=>e.settled),n=this.records.filter(e=>!e.settled);if(n.length>0&&await this.compensate(n,e),t.length!==0){if(isTurnCancellation(e)){this.retained=!0;return}await this.compensate(t,e)}}retainedResult(){return this.retained?this.resultFields():void 0}apply(e){let t=e;for(let e of this.records)!e.settled||e.task===void 0||(t=recordSessionTask(t,e.task));return this.agentHandlesChanged&&(t=writeHandles(t,getAgentHandleStore(this.agentHandleSession.state)?.handles??[])),t}resultFields(){let e=this.records.flatMap(e=>e.settled&&e.task!==void 0?[e.task]:[]);if(e.length!==0)return{backgroundTaskSession:this.apply(this.initialSession),backgroundTasks:e.map(({taskInboxToken:e,taskId:t,taskRunId:n})=>({taskInboxToken:e,taskId:t,taskRunId:n}))}}async start(t){let i={settled:!1};this.records.push(i);let a=getHarnessEmissionState(this.initialSession.state),o=loadContext(),c=await this.startTask({ctx:o,emission:a,input:t,record:i}),l=c.task;i.task=l;let u=o.get(CallbackBaseUrlKey),d={taskId:l.taskId,token:l.taskInboxToken,...u===void 0?{}:{url:createWorkflowCallbackUrl(u,createEveCallbackRoutePath(l.taskInboxToken))}},f={batch:t.batch.calls,binding:d,delegated:({executor:e,receipt:t})=>createTaskDelegated({binding:d,executor:e,receipt:t}),send:createTaskSender(l,t.options.toolCallId),session:this.initialSession,task:l};if(t.definition.workflowId!==void 0)return i.settled=!0,{...c.receipt,status:`working`,taskId:l.taskId};let p=t.definition.execute(t.toolInput,t.options,f);if(isAsyncIterable(p))throw Error(`Background tools cannot return AsyncIterable output.`);let m=await p;return isAuthorizationSignal(m)?m:isTaskDelegated(m)?(m.executor!==void 0&&(await deliverTaskCommand(l,{executor:m.executor,kind:`bind`}),i.task={...l,executor:m.executor}),i.settled=!0,c.receipt===void 0?m.receipt:{...m.receipt,...c.receipt}):(await deliverTaskCommand(l,{data:parseJsonValue(m),kind:`complete`}),i.settled=!0,m)}async startTask(e){let n=e.input.definition.workflowId===void 0?void 0:{...e.input.definition,workflowId:e.input.definition.workflowId},r=n===void 0?void 0:parseWorkflowToolInput(e.input.toolInput,e.input.definition.name),a=activeTurnId(e.emission),s=n?.resultKind===`subagent`&&r!==void 0?projectSubagentTask({ctx:e.ctx,input:r,name:e.input.definition.name,nodeId:n.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:a}}):void 0;if(s!==void 0&&s.identity===void 0&&!hasAgentHandle(this.agentHandleSession,s.metadata.agentId)){let{agentId:t,...i}=r;r=i,s=projectSubagentTask({ctx:e.ctx,input:i,name:e.input.definition.name,nodeId:n.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:a}})}let l={callId:e.input.options.toolCallId,metadata:s?.metadata??{kind:`tool`,name:e.input.definition.name},parentSessionId:this.initialSession.sessionId,parentStepIndex:e.emission.stepIndex,parentTurnId:a,session:this.initialSession};if(n===void 0)return{task:await beginBackgroundTask({callId:l.callId,metadata:l.metadata,parentSessionId:l.parentSessionId,parentStepIndex:l.parentStepIndex,parentTurnId:l.parentTurnId,session:l.session})};if(r===void 0)throw Error(`Background workflow tool "${e.input.definition.name}" has no input.`);let u=prepareBackgroundTask(l);if(n.resultKind===`subagent`&&s!==void 0&&s.identity!==void 0){let t=s.identity;if(this.applyAgentHandleCommand({identity:t.identity,callId:l.callId,kind:`reserve`,operationId:t.operation.id,ownerId:u.taskId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${t.operation.id}".`);e.record.reservation={agentId:t.identity.id,operationId:t.operation.id}}if(n.resultKind===`subagent`&&s!==void 0&&s.identity===void 0){let t=deriveAgentOperationId({callId:l.callId,parentSessionId:l.parentSessionId,parentTurnId:a}),n=this.applyAgentHandleCommand({agentId:s.metadata.agentId,callId:l.callId,expectedTarget:s.metadata.mode,invokedName:s.metadata.name,kind:`claim`,operationId:t,ownerId:u.taskId});readClaimedHandle(n)?e.record.claim={operationId:t,taskId:u.taskId}:throwAgentClaimError(s.metadata.agentId,n)}await startTaskRun({initialView:{metadata:u.metadata,status:`working`,taskId:u.taskId},parentContinuationToken:sessionCommandHookToken(this.initialSession.sessionId),taskInboxToken:u.taskInboxToken,workflow:{callId:l.callId,executeInput:n.executeInput?.(r),input:r,resultKind:n.resultKind,session:buildCallbackContext().session,stepIndex:e.emission.stepIndex,toolName:e.input.definition.name,workflowId:n.workflowId}});let d=await waitForTaskCommandOwner({taskInboxToken:u.taskInboxToken}),f={...u,executor:IN_PROCESS_WORKFLOW_EXECUTOR,taskRunId:d.runId};return e.record.task=f,n.resultKind!==`subagent`||s===void 0?{task:f}:(s.identity,{receipt:s.receipt,task:f})}applyAgentHandleCommand(e){let t=applyTaskAgentHandleCommand(this.agentHandleSession,e);return t.session!==this.agentHandleSession&&(this.agentHandleSession=t.session,this.agentHandlesChanged=!0),t.result}async compensate(e,t){let n=[];for(let r of e.toReversed()){if(r.task!==void 0)try{await rejectDelegatedDispatch({error:{code:`PARENT_STEP_FAILED`,message:t instanceof Error?t.message:String(t)},task:r.task})}catch(e){n.push(e)}r.claim!==void 0&&this.applyAgentHandleCommand({kind:`release-owner`,ownerId:r.claim.taskId}),r.reservation!==void 0&&r.task!==void 0&&this.applyAgentHandleCommand({agentId:r.reservation.agentId,kind:`remove`,ownerId:r.task.taskId})}if(n.length>0)throw AggregateError([t,...n],`Background tool execution failed and its tasks could not all be rejected.`,{cause:t})}};function hasAgentHandle(e,t){return getAgentHandleStore(e.state)?.handles.some(e=>e.identity.id===t)===!0}function projectSubagentTask(e){let t=e.input.agentId;if(typeof t==`string`&&t.trim()!==``)return{metadata:{agentId:t,kind:`subagent`,mode:readSubagentTaskMode(e.ctx,e.nodeId),name:e.name},receipt:{agentId:t}};let n=createSubagentReceiptIdentity({callId:e.taskInput.callId,nodeId:e.nodeId,parentSessionId:e.taskInput.parentSessionId,parentTurnId:e.taskInput.parentTurnId,subagentName:e.name});return{identity:n,metadata:{agentId:n.identity.id,kind:`subagent`,mode:readSubagentTaskMode(e.ctx,e.nodeId),name:e.name},receipt:{agentId:n.identity.id}}}function readSubagentTaskMode(e,t){let n=getDynamicSubagentSelection(e,t);return n===void 0?(e.get(BundleKey)?.subagentRegistry.subagentsByNodeId.get(t))?.definition.kind===`remote`?`remote`:`local`:n.kind===`remote`?`remote`:`local`}function requireExecutionScope(e){if(!(e instanceof BackgroundToolExecutionScope))throw Error(`The background tool executor is not owned by the task runtime.`);return e}async function deliverTaskCommand(e,t){if(await sendTaskCommand({command:t,taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${t.kind}".`)}function createTaskSender(e,t){let n=0;return async r=>{if(r.kind!==`update`){await deliverTaskCommand(e,r);return}if(await sendTaskInboundPayload({payload:{callId:t,kind:`task-update`,message:r.message,updateEpoch:e.taskId,updateIndex:n++},taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${r.kind}".`)}}function readClaimedHandle(e){return e.kind===`ready`&&e.handle?.phase===`claimed`}function throwAgentClaimError(e,t){throw t.kind===`mismatch`?Error(JSON.stringify({code:AGENT_MISMATCH,message:`Agent "${e}" no longer matches this subagent definition. Start a new agent instead.`})):t.kind===`busy`?Error(JSON.stringify({code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:e,agentName:t.handle.identity.name,ownerId:`ownerId`in t.handle?t.handle.ownerId:void 0})})):Error(JSON.stringify({code:AGENT_UNREACHABLE,message:`Agent with id "${e}" is no longer reachable.`}))}export{backgroundToolExecutionProvider,readRetainedBackgroundToolResult,runBackgroundStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{cancelRun,getWorld}from"#internal/workflow/runtime.js";import{
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{cancelRun,getWorld}from"#internal/workflow/runtime.js";import{deserializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{resetRemoteAgentSession,resolveRemoteAgentForAction,resolveRemoteAgentStreamHeaders}from"#subagents/remote-dispatch.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{getDynamicSubagentSelection}from"#context/dynamic-subagent-lifecycle.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{cancelOwnedTask}from"#execution/tasks/parent/dispatch.js";import{cancelBackgroundAgentTask}from"#execution/tools/subagent/task-cancel.js";import{getSessionTaskIndex}from"#tasks/session-index.js";const log=createLogger(`execution.terminate-child-sessions`);async function terminateChildSessionsStep(e){"use step";let o;try{o=await readDurableSession(e.sessionState)}catch(n){logError(log,`failed to read child sessions for termination`,n,{parentSessionId:e.sessionState.sessionId});return}let s=readSessionTaskIndex(o.state,o.sessionId),c=getAgentHandleStore(o.state)?.handles??[],l=c.some(e=>`address`in e&&e.address.kind===`agent/remote`),u;if(s.length>0||l){if(e.serializedContext===void 0)throw Error(`Child finalization requires serialized runtime context.`);let t=await deserializeContext(e.serializedContext);u={bundle:t.require(BundleKey),ctx:t}}if(s.length>0){let{bundle:n,ctx:r}=u,i=resolveEffectiveAgentRuntime(n,r),a=hydrateDurableSession({durable:o,turnAgent:i.turnAgent});for(let n of s)try{await cancelOwnedTask({cancelOwnedWork:cancelBackgroundAgentTask,entry:n,serializedContext:e.serializedContext,session:a})}catch(e){logError(log,`failed to cancel task during parent finalization`,e,{parentSessionId:o.sessionId,taskId:n.taskId})}}if(c.length!==0)for(let e of c){if(!(`address`in e)){log.debug(`skipping unaddressed child`,{agentId:e.identity.id,parentSessionId:o.sessionId});continue}try{if(e.address.kind===`agent/remote`)if(e.address.credentialResolver!==void 0){let t=e.address.credentialResolver.resolverId;await resetRemoteAgentSession({headers:t===void 0?{}:await resolveRemoteAgentStreamHeaders({bundle:u.bundle,name:e.identity.name,resolverId:t,url:e.address.url}),remote:{name:e.identity.name,url:e.address.url},sessionId:e.address.sessionId})}else{let t=getDynamicSubagentSelection(u.ctx,e.identity.nodeId),n=resolveRemoteAgentForAction({dynamicRemoteAgent:t?.kind===`remote`?t.remoteAgent:void 0,nodeId:e.identity.nodeId,registry:u.bundle.subagentRegistry.subagentsByNodeId,remoteAgentName:e.identity.name});n.url===e.address.url?await resetRemoteAgentSession({remote:n,sessionId:e.address.sessionId}):await resetRemoteAgentSession({headers:{},remote:{name:e.identity.name,url:e.address.url},sessionId:e.address.sessionId})}else await cancelRun(await getWorld(),e.address.sessionId,{cancelReason:`Parent session ended`})}catch(n){logError(log,`failed to terminate child session`,n,{agentId:e.identity.id,childSessionId:e.address.sessionId,kind:e.address.kind,parentSessionId:o.sessionId})}}}function readSessionTaskIndex(e,n){try{return getSessionTaskIndex(e)}catch(e){return logError(log,`failed to read the task index during parent finalization`,e,{parentSessionId:n}),[]}}export{terminateChildSessionsStep};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
+
import { type TaskAuthorizationEventDelivery } from "#tasks/types.js";
|
|
3
|
+
/** Validates that a task child's authorization event came from an agent the task owns. */
|
|
4
|
+
export declare function acceptTaskAuthorizationEventStep(input: {
|
|
5
|
+
readonly delivery: TaskAuthorizationEventDelivery;
|
|
6
|
+
readonly sessionState: DurableSessionState;
|
|
7
|
+
}): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{findSessionTaskEntry}from"#tasks/session-index.js";import{isTerminalTaskStatus}from"#tasks/types.js";async function acceptTaskAuthorizationEventStep(t){"use step";let{hookPayload:n,taskId:r}=t.delivery,i=await readDurableSession(t.sessionState),a=findSessionTaskEntry(i.state,r);if(a===void 0)return!1;let o=getAgentHandleStore(i.state)?.handles??[],s=o.find(e=>e.phase===`claimed`&&e.ownerId===r&&e.identity.name===n.subagentName&&e.address.sessionId===n.childSessionId),c=o.filter(e=>e.phase===`reserved`&&e.ownerId===r&&e.identity.name===n.subagentName);if(s===void 0&&c.length!==1)return!1;let l=await readLatestTaskView({taskRunId:a.taskRunId});return l!==void 0&&!isTerminalTaskStatus(l.status)}export{acceptTaskAuthorizationEventStep};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
2
|
+
/** Emits an already-projected task-owned `subagent.called` event on the parent stream. */
|
|
3
|
+
export declare function emitTaskSubagentCalledStep(input: {
|
|
4
|
+
readonly event: UnstampedMessageStreamEvent;
|
|
5
|
+
readonly parentWritable: WritableStream<Uint8Array>;
|
|
6
|
+
readonly serializedContext: Record<string, unknown>;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
readonly serializedContext: Record<string, unknown>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";async function emitTaskSubagentCalledStep(e){"use step";let t=await deserializeContext(e.serializedContext),n=t.require(ChannelKey),r=await callAdapterEventHandler(n,e.event,buildAdapterContext(n,t)),i=e.parentWritable.getWriter();try{await i.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))}finally{i.releaseLock()}return{serializedContext:serializeContext(t)}}export{emitTaskSubagentCalledStep};
|