eve 0.50.0 → 0.51.1
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 +41 -0
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/channel/session.d.ts +2 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +16 -20
- package/dist/src/chunks/{use-eve-agent-B5I-k6Ek.js → use-eve-agent-3DZuvuWE.js} +21 -10
- package/dist/src/chunks/{use-eve-agent-DUMU6dap.js → use-eve-agent-D7apPojZ.js} +21 -10
- 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/agent-instructions.d.ts +3 -1
- package/dist/src/cli/commands/agent-instructions.js +1 -1
- 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.d.ts +2 -13
- package/dist/src/cli/commands/init.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-project-commands.d.ts +1 -1
- package/dist/src/cli/commands/register-project-commands.js +1 -1
- package/dist/src/cli/commands/register-registry-commands.js +2 -2
- 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/run-interactive-ui.js +1 -1
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +3 -1
- package/dist/src/cli/dev/tui/setup-commands.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/client/open-stream.js +1 -1
- package/dist/src/client/session-controls.d.ts +3 -0
- package/dist/src/client/session-controls.js +1 -1
- package/dist/src/client/session.d.ts +4 -1
- package/dist/src/compiled/.vendor-stamp.json +11 -11
- package/dist/src/compiled/@clack/core/LICENSE +9 -0
- package/dist/src/compiled/@clack/core/index.d.ts +363 -0
- package/dist/src/compiled/@clack/core/index.js +20 -0
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +34 -92
- package/dist/src/compiled/@vercel/sandbox/api-client/base-client.d.ts +1 -1
- package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
- package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +13 -29
- package/dist/src/compiled/@vercel/sandbox/constants.d.ts +11 -1
- package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -3
- package/dist/src/compiled/@vercel/sandbox/index.js +9 -9
- package/dist/src/compiled/@vercel/sandbox/sandbox-user.d.ts +5 -6
- package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +79 -67
- package/dist/src/compiled/@vercel/sandbox/session.d.ts +5 -3
- package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +9 -0
- package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/api-client.d.ts +86 -1
- package/dist/src/compiled/@vercel/sandbox-drives/api-client/index.d.ts +2 -0
- package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/validators.d.ts +26 -1
- package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/constants.d.ts +2 -2
- package/dist/src/compiled/@vercel/{sandbox → sandbox-drives}/drive.d.ts +10 -0
- package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/index.d.ts +3 -2
- package/dist/src/compiled/@vercel/sandbox-drives/index.js +9 -0
- package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/sandbox.d.ts +35 -6
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/private.d.ts +2 -4
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +9 -7
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +13 -0
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +54 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/serialization.d.ts +24 -2
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/error-codes.d.ts +2 -0
- package/dist/src/compiled/@workflow/errors/index.d.ts +19 -0
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +46 -2
- package/dist/src/compiled/@workflow/world/events.d.ts +26 -1
- package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world/runs.d.ts +2 -2
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
- package/dist/src/compiled/_chunks/node/{auth-BSKyPAEP.js → auth-Bx1Aoyfo.js} +1 -1
- package/dist/src/compiled/_chunks/node/{auth-YpKlwhP1.js → auth-CA8ZMfB8.js} +1 -1
- package/dist/src/compiled/_chunks/node/esm-CE0tAvRh.js +7 -0
- package/dist/src/compiled/_chunks/node/version-BC6t2Txc.js +1 -0
- package/dist/src/compiled/_chunks/node/version-DSQqVZ5T.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-BwAadFfB.js → attribute-changes-03lzo29R.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-BIdMK5N8.js +40 -0
- package/dist/src/compiled/_chunks/workflow/dist-DMQ3CtWt.js +3 -0
- package/dist/src/compiled/_chunks/workflow/frames-Boesh7kU.js +3 -0
- package/dist/src/compiled/_chunks/workflow/{private-CZFMABEf.js → private-CKx3PkSS.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{resume-hook-BToMtPbH.js → resume-hook-C6eL-S_T.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/run-BV0S6Zc2.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-Bh3jP9ii.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-l-cwfJvm.js +15 -0
- package/dist/src/compiled/_chunks/workflow/{ws-transport-PnVVxT0R.js → ws-transport-BagXNxCE.js} +1 -1
- package/dist/src/compiler/compile-from-memory.d.ts +1 -0
- package/dist/src/compiler/extension-compatibility.d.ts +20 -20
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +2 -2
- 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/compiler/normalize-tool.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/extensions.d.ts +2 -0
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/discover/filesystem.d.ts +1 -0
- package/dist/src/discover/filesystem.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/evals/runner/execute-task.js +1 -1
- package/dist/src/evals/session-cleanup.d.ts +7 -0
- package/dist/src/evals/session-cleanup.js +1 -0
- package/dist/src/evals/session.d.ts +4 -0
- package/dist/src/evals/session.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +1 -0
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/execution/activity-collector.js +1 -1
- package/dist/src/execution/activity-work-id.js +1 -1
- package/dist/src/execution/activity-work.d.ts +8 -0
- package/dist/src/execution/activity-work.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +6 -0
- package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -0
- 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.d.ts +2 -0
- package/dist/src/execution/inline-turn.js +1 -1
- package/dist/src/execution/next-driver-action.d.ts +7 -13
- package/dist/src/execution/node-step.d.ts +1 -2
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/parked-delivery-wait.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/run-session-limits.d.ts +5 -5
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-sdk-types.d.ts +4 -4
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/session-activity-projection.js +1 -1
- package/dist/src/execution/session-activity.js +1 -1
- package/dist/src/execution/session-command-inbox.d.ts +2 -3
- package/dist/src/execution/session-timeout-workflow.js +1 -1
- package/dist/src/execution/session.d.ts +2 -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 +19 -11
- 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 -27
- 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 -48
- 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/subagent-task-projection.d.ts +26 -0
- package/dist/src/execution/tasks/parent/subagent-task-projection.js +1 -0
- 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/sleep-workflow.d.ts +3 -0
- package/dist/src/execution/tools/sleep-workflow.js +1 -0
- package/dist/src/execution/tools/sleep.d.ts +1 -5
- package/dist/src/execution/tools/sleep.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-cancellation-control.d.ts +1 -0
- package/dist/src/execution/turn-cancellation-control.js +1 -1
- package/dist/src/execution/turn-cancellation-token.d.ts +1 -0
- package/dist/src/execution/turn-control-receiver.d.ts +3 -0
- package/dist/src/execution/turn-control-receiver.js +1 -1
- package/dist/src/execution/turn-dispatch.d.ts +2 -0
- package/dist/src/execution/turn-dispatch.js +1 -1
- 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 +14 -2
- package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
- package/dist/src/execution/wire/session-inbox-resume.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/wire/session-inbox-wire.v5.d.ts +341 -0
- package/dist/src/execution/wire/session-inbox-wire.v5.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v5.migration.d.ts +3 -0
- package/dist/src/execution/wire/session-inbox-wire.v5.migration.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v6.d.ts +341 -0
- package/dist/src/execution/wire/session-inbox-wire.v6.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/session-limit-continuation.d.ts +5 -5
- package/dist/src/harness/session-limit-continuation.js +1 -1
- package/dist/src/harness/session-limit-enforcement.d.ts +4 -4
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/session-usage-limits.d.ts +48 -0
- package/dist/src/harness/session-usage-limits.js +1 -0
- 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 +20 -21
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +9 -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/application/build-output-environment.d.ts +1 -0
- package/dist/src/internal/application/build-output-environment.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/eve-project-root.d.ts +8 -0
- package/dist/src/internal/eve-project-root.js +1 -0
- package/dist/src/internal/invocation/workflow-execution.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +1 -0
- package/dist/src/internal/nitro/host/create-application-nitro.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/host/types.d.ts +2 -0
- package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +1 -0
- package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/project-context.d.ts +31 -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 +28 -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/reference.d.ts +2 -0
- package/dist/src/internal/workflow/reference.js +1 -0
- package/dist/src/internal/workflow-bundle/authored-workflow-modules.d.ts +0 -9
- package/dist/src/internal/workflow-bundle/authored-workflow-modules.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/workflow-transformer.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/channels/slack/activity-plan.d.ts +4 -0
- package/dist/src/public/channels/slack/activity-plan.js +1 -0
- package/dist/src/public/channels/slack/activity.d.ts +45 -2
- package/dist/src/public/channels/slack/activity.js +2 -1
- package/dist/src/public/channels/slack/index.d.ts +1 -1
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/memory/file/backends/vercel-blob.js +1 -1
- package/dist/src/public/memory/index.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/nuxt/index.js +1 -1
- package/dist/src/public/nuxt/module.d.ts +3 -2
- package/dist/src/public/nuxt/module.js +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +9 -5
- package/dist/src/public/sandbox/vercel.d.ts +1 -1
- package/dist/src/public/sandbox/vercel.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/self-modification/agent.d.ts +22 -0
- package/dist/src/self-modification/agent.js +1 -0
- package/dist/src/self-modification/extension/classify-registry-item.d.ts +19 -0
- package/dist/src/self-modification/extension/classify-registry-item.js +1 -0
- package/dist/src/self-modification/extension/eve-add.d.ts +56 -0
- package/dist/src/self-modification/extension/eve-add.js +2 -0
- package/dist/src/self-modification/extension/extension.d.ts +2 -0
- package/dist/src/self-modification/extension/extension.js +1 -0
- package/dist/src/self-modification/extension/instructions.d.ts +4 -0
- package/dist/src/self-modification/extension/instructions.js +23 -0
- package/dist/src/self-modification/extension/source-lock.d.ts +2 -0
- package/dist/src/self-modification/extension/source-lock.js +1 -0
- package/dist/src/self-modification/extension/tools/edit_file.d.ts +16 -0
- package/dist/src/self-modification/extension/tools/edit_file.js +1 -0
- package/dist/src/self-modification/extension/tools/registry_add.d.ts +52 -0
- package/dist/src/self-modification/extension/tools/registry_add.js +1 -0
- package/dist/src/self-modification/extension/tools/search_models.d.ts +22 -0
- package/dist/src/self-modification/extension/tools/search_models.js +1 -0
- package/dist/src/self-modification/extension/tools/search_registry.d.ts +103 -0
- package/dist/src/self-modification/extension/tools/search_registry.js +1 -0
- package/dist/src/self-modification/filesystem.d.ts +6 -0
- package/dist/src/self-modification/filesystem.js +1 -0
- package/dist/src/self-modification/sandbox.d.ts +2 -0
- package/dist/src/self-modification/sandbox.js +1 -0
- package/dist/src/services/dev-client/target.d.ts +3 -1
- package/dist/src/setup/boxes/select-model.d.ts +3 -21
- package/dist/src/setup/boxes/select-model.js +1 -1
- package/dist/src/setup/cli/prompt-ui.js +4 -4
- package/dist/src/setup/cli/select-component.d.ts +1 -1
- package/dist/src/setup/cli/select-component.js +1 -1
- package/dist/src/setup/flows/model.d.ts +3 -0
- package/dist/src/setup/flows/model.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/prompter.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/setup/scaffold/update/web-options.js +1 -1
- package/dist/src/shared/action-types.d.ts +103 -30
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +13 -0
- package/dist/src/shared/agent-turn-outcome.d.ts +2 -0
- package/dist/src/shared/agent-turn-outcome.js +1 -1
- package/dist/src/shared/extension-package-contract.d.ts +2 -0
- package/dist/src/shared/extension-package-contract.js +1 -1
- package/dist/src/shared/gateway-model-catalog.d.ts +21 -0
- package/dist/src/shared/gateway-model-catalog.js +1 -0
- package/dist/src/shared/json.js +1 -1
- package/dist/src/shared/sandbox-network-policy.d.ts +1 -1
- package/dist/src/shared/token-usage.d.ts +11 -15
- package/dist/src/shared/token-usage.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/subagents/token-budget.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 +70 -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/tools/provided/sleep.d.ts +2 -2
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +24 -19
- package/docs/channels/eve.mdx +1 -1
- package/docs/concepts/built-in-tools.md +10 -91
- 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 +11 -3
- package/docs/guides/client/streaming.mdx +1 -1
- 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/memory/overview.mdx +1 -1
- package/docs/reference/cli.md +5 -2
- package/docs/sandbox.mdx +3 -1
- package/docs/subagents/index.mdx +9 -8
- package/docs/tools/overview.mdx +11 -10
- package/docs/tools/workflows.mdx +52 -18
- package/package.json +38 -13
- package/dist/src/compiled/@vercel/sandbox-delete/api-client/index.d.ts +0 -2
- package/dist/src/compiled/@vercel/sandbox-delete/index.js +0 -9
- package/dist/src/compiled/@vercel/sandbox-stable/LICENSE +0 -201
- package/dist/src/compiled/@vercel/sandbox-stable/_async-retry.d.ts +0 -8
- package/dist/src/compiled/@vercel/sandbox-stable/_workflow-serde.d.ts +0 -5
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-client.d.ts +0 -1456
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-error.d.ts +0 -29
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/base-client.d.ts +0 -39
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/file-writer.d.ts +0 -66
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/index.d.ts +0 -2
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/validators.d.ts +0 -899
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/with-retry.d.ts +0 -10
- package/dist/src/compiled/@vercel/sandbox-stable/auth/error.d.ts +0 -15
- package/dist/src/compiled/@vercel/sandbox-stable/auth/file.d.ts +0 -18
- package/dist/src/compiled/@vercel/sandbox-stable/auth/index.d.ts +0 -6
- package/dist/src/compiled/@vercel/sandbox-stable/auth/oauth.d.ts +0 -111
- package/dist/src/compiled/@vercel/sandbox-stable/auth/poll-for-token.d.ts +0 -28
- package/dist/src/compiled/@vercel/sandbox-stable/auth/project.d.ts +0 -40
- package/dist/src/compiled/@vercel/sandbox-stable/command.d.ts +0 -292
- package/dist/src/compiled/@vercel/sandbox-stable/constants.d.ts +0 -5
- package/dist/src/compiled/@vercel/sandbox-stable/execution-context.d.ts +0 -116
- package/dist/src/compiled/@vercel/sandbox-stable/filesystem.d.ts +0 -258
- package/dist/src/compiled/@vercel/sandbox-stable/index.d.ts +0 -12
- package/dist/src/compiled/@vercel/sandbox-stable/index.js +0 -1
- package/dist/src/compiled/@vercel/sandbox-stable/network-policy.d.ts +0 -169
- package/dist/src/compiled/@vercel/sandbox-stable/proxy.d.ts +0 -55
- package/dist/src/compiled/@vercel/sandbox-stable/sandbox-user.d.ts +0 -212
- package/dist/src/compiled/@vercel/sandbox-stable/sandbox.d.ts +0 -1216
- package/dist/src/compiled/@vercel/sandbox-stable/session.d.ts +0 -433
- package/dist/src/compiled/@vercel/sandbox-stable/snapshot.d.ts +0 -229
- package/dist/src/compiled/@vercel/sandbox-stable/utils/get-credentials.d.ts +0 -21
- package/dist/src/compiled/@vercel/sandbox-stable/utils/paginator.d.ts +0 -16
- package/dist/src/compiled/@vercel/sandbox-stable/utils/resolveSignal.d.ts +0 -15
- package/dist/src/compiled/@vercel/sandbox-stable/utils/sandbox-snapshot.d.ts +0 -11
- package/dist/src/compiled/@vercel/sandbox-stable/utils/types.d.ts +0 -11
- package/dist/src/compiled/_chunks/node/decode_jwt-Col8JOnf.js +0 -7
- package/dist/src/compiled/_chunks/node/version-BYHw-SDY.js +0 -1
- package/dist/src/compiled/_chunks/node/version-DH6yRy-M.js +0 -1
- package/dist/src/compiled/_chunks/workflow/dist-CgbVZs5l.js +0 -40
- package/dist/src/compiled/_chunks/workflow/dist-DjojkP5e.js +0 -3
- package/dist/src/compiled/_chunks/workflow/frames-CZ9eHShe.js +0 -3
- package/dist/src/compiled/_chunks/workflow/run-DzyAoGh4.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-3_A5uOp-.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wait-until-BtySPYD0.js +0 -15
- 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/session-token-limits.d.ts +0 -41
- package/dist/src/harness/session-token-limits.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/subagent-token-budget.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/turn-sleep.d.ts +0 -12
- package/dist/src/harness/turn-sleep.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/node_modules/.pnpm/@clack_core@1.3.1/node_modules/@clack/core/dist/index.js +0 -16
- package/dist/src/node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js +0 -1
- package/dist/src/node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js +0 -1
- package/dist/src/node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js +0 -1
- package/dist/src/node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js +0 -5
- package/dist/src/node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.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/compiled/@vercel/{sandbox-delete → sandbox-drives}/LICENSE +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/_async-retry.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/_workflow-serde.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/api-error.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/base-client.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/file-writer.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/api-client/with-retry.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/error.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/file.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/index.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/oauth.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/poll-for-token.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/auth/project.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/command.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/execution-context.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/filesystem.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/network-policy.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/proxy.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/sandbox-user.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/session.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/snapshot.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/get-credentials.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/paginator.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/resolveSignal.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/sandbox-snapshot.d.ts +0 -0
- /package/dist/src/compiled/@vercel/{sandbox-delete → sandbox-drives}/utils/types.d.ts +0 -0
- /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/{execution/subagent-event-proxy-step.d.ts → subagents/event-proxy-step.d.ts}
RENAMED
|
@@ -2,6 +2,7 @@ import type { SubagentAuthorizationEventHookPayload, SubagentInputRequestHookPay
|
|
|
2
2
|
import type { ContextContainer } from "#context/container.js";
|
|
3
3
|
import { type DurableSession, type DurableSessionState } from "#execution/durable-session-store.js";
|
|
4
4
|
import type { AnswerHookRoute } from "#harness/proxy-input-requests.js";
|
|
5
|
+
import type { TaskInputRequestDelivery } from "#tasks/types.js";
|
|
5
6
|
type SubagentEventHookPayload = SubagentAuthorizationEventHookPayload | SubagentInputRequestHookPayload;
|
|
6
7
|
interface ProxySubagentEventResult {
|
|
7
8
|
readonly serializedContext: Record<string, unknown>;
|
|
@@ -17,14 +18,7 @@ export declare function runProxySubagentEventStep(input: {
|
|
|
17
18
|
}): Promise<ProxySubagentEventResult>;
|
|
18
19
|
/** Emits a task request whose proxy routes were committed by a prior step. */
|
|
19
20
|
export declare function emitRecordedTaskInputRequestStep(input: {
|
|
20
|
-
readonly
|
|
21
|
-
readonly parentWritable: WritableStream<Uint8Array>;
|
|
22
|
-
readonly serializedContext: Record<string, unknown>;
|
|
23
|
-
readonly sessionState: DurableSessionState;
|
|
24
|
-
}): Promise<ProxySubagentEventResult>;
|
|
25
|
-
/** Emits a task authorization event after its ownership was validated. */
|
|
26
|
-
export declare function emitRecordedTaskAuthorizationEventStep(input: {
|
|
27
|
-
readonly hookPayload: SubagentAuthorizationEventHookPayload;
|
|
21
|
+
readonly request: TaskInputRequestDelivery;
|
|
28
22
|
readonly parentWritable: WritableStream<Uint8Array>;
|
|
29
23
|
readonly serializedContext: Record<string, unknown>;
|
|
30
24
|
readonly sessionState: DurableSessionState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{ModeKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{emitTurnEpilogue,getHarnessEmissionState,setHarnessEmissionState}from"#harness/emission.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{hydrateDurableSession}from"#execution/session.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{withContextScope}from"#context/run-step.js";import{upsertProxyInputRequests}from"#harness/proxy-input-requests.js";import{emitProxiedInputRequest}from"#subagents/hitl-proxy.js";import{setChannelContext}from"#execution/channel-context.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";async function runProxySubagentEventStep(e){"use step";let t=await readDurableSession(e.sessionState),n=await deserializeContext(e.serializedContext);return emitProxiedSubagentEvent({answerHook:e.answerHook,ctx:n,durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable})}async function emitRecordedTaskInputRequestStep(e){"use step";let t=await readDurableSession(e.sessionState);return await emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:{callId:e.request.taskId,childContinuationToken:e.request.replyTo,childSessionId:e.request.taskId,event:{requests:e.request.requests??[e.request.request],sequence:e.request.sequence,stepIndex:e.request.stepIndex,turnId:e.request.turnId},kind:`subagent-input-request`,subagentName:e.request.taskId},parentWritable:e.parentWritable,recordProxyInputRequests:!1})}async function emitProxiedSubagentEvent(i){let{ctx:a}=i,o=a.require(ChannelKey),s=resolveEffectiveAgentRuntime(a.require(BundleKey),a),c=hydrateDurableSession({compactionOverrides:{thresholdPercent:s.thresholdPercent},durable:i.durableSession,turnAgent:s.turnAgent}),l=buildAdapterContext(o,a),u=i.parentWritable.getWriter(),d,f;try{let emit=async t=>{let r=await callAdapterEventHandler(o,t,l);await u.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))},r=await withContextScope(a,c,async e=>{if(i.hookPayload.kind===`subagent-authorization-event`)return await emit(i.hookPayload.event),{result:void 0,session:await closeStandaloneAuthorizationEvent({emit,eventType:i.hookPayload.event.type,mode:a.require(ModeKey),session:e})};let n=await emitProxiedInputRequest({emit,hookPayload:i.hookPayload,mode:a.require(ModeKey),session:e});return{result:n.entries,session:n.session}});d=r.result,f=r.session}finally{u.releaseLock()}if(setChannelContext(a,{...o,state:{...l.state}}),i.recordProxyInputRequests!==!1&&d!==void 0&&i.hookPayload.kind===`subagent-input-request`){let e=i.answerHook;f=upsertProxyInputRequests({entries:e===void 0?d:d.map(([t,n])=>[t,{...n,answerHook:e}]),forChildContinuationToken:i.hookPayload.childContinuationToken,session:f})}let p=reconcileSessionContinuationToken(a,f);return{serializedContext:serializeContext(a),sessionState:createDurableSessionState({session:p})}}async function closeStandaloneAuthorizationEvent(e){if(e.mode!==`conversation`||e.eventType!==`authorization.required`&&e.eventType!==`authorization.completed`)return e.session;let t=getHarnessEmissionState(e.session.state),n=await emitTurnEpilogue(e.emit,t,e.mode);return setHarnessEmissionState(e.session,n)}export{emitProxiedSubagentEvent,emitRecordedTaskInputRequestStep,runProxySubagentEventStep};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Continuation delivery for task-owned agent sessions. */
|
|
2
|
+
import type { SessionAuthContext } from "#channel/types.js";
|
|
3
|
+
import type { AgentAddress } from "#subagents/handles/store.js";
|
|
4
|
+
import type { RuntimeAgentDispatchRequest, RuntimeRemoteAgentDispatchRequest, RuntimeSubagentDispatchRequest, RuntimeSubagentDispatchFailure } from "#shared/action-types.js";
|
|
5
|
+
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
6
|
+
import type { hydrateDurableSession } from "#execution/session.js";
|
|
7
|
+
import type { TaskOwnedAgentHandle } from "#subagents/handles/store.js";
|
|
8
|
+
/** Agent-task requests that may address an agent handle via `agentId`. */
|
|
9
|
+
export type RuntimeAgentHandleAction = RuntimeRemoteAgentDispatchRequest | RuntimeSubagentDispatchRequest;
|
|
10
|
+
/** Narrows an action to the kinds that may carry an `agentId` continuation. */
|
|
11
|
+
export declare function isAgentHandleAction(action: RuntimeAgentDispatchRequest): action is RuntimeAgentHandleAction;
|
|
12
|
+
/** Hydrated parent session snapshot threaded through dispatch. */
|
|
13
|
+
export type RuntimeSession = ReturnType<typeof hydrateDurableSession>;
|
|
14
|
+
/**
|
|
15
|
+
* Outcome of dispatching one planned agent task: an adopted child ready for
|
|
16
|
+
* the `subagent.called` emission tail, or a per-task error result.
|
|
17
|
+
* Either way the (possibly updated) session snapshot rides along.
|
|
18
|
+
*
|
|
19
|
+
* `address` is the same confirmed {@link AgentAddress} recorded on the
|
|
20
|
+
* child's running handle; consumers project it into wire shapes (e.g. the
|
|
21
|
+
* flat `childSessionId` / `remote` fields of `subagent.called`) at the
|
|
22
|
+
* emission site instead of this type re-encoding them.
|
|
23
|
+
*/
|
|
24
|
+
export type DispatchOutcome = {
|
|
25
|
+
readonly address: AgentAddress;
|
|
26
|
+
readonly callId: string;
|
|
27
|
+
readonly kind: "called";
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly session: RuntimeSession;
|
|
30
|
+
readonly toolName: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly deliveryAmbiguous?: boolean;
|
|
33
|
+
readonly deliveryPermanent?: boolean;
|
|
34
|
+
readonly kind: "error";
|
|
35
|
+
readonly result: RuntimeSubagentDispatchFailure;
|
|
36
|
+
readonly session: RuntimeSession;
|
|
37
|
+
};
|
|
38
|
+
/** Delivers a continuation after the session handle store atomically claimed it for one owner. */
|
|
39
|
+
export declare function dispatchToClaimedAgentAddress(input: {
|
|
40
|
+
readonly action: RuntimeAgentHandleAction;
|
|
41
|
+
readonly auth: SessionAuthContext | null;
|
|
42
|
+
readonly bundle: CompiledBundle;
|
|
43
|
+
readonly currentSession: RuntimeSession;
|
|
44
|
+
readonly parentToken: string;
|
|
45
|
+
readonly handle: Extract<TaskOwnedAgentHandle, {
|
|
46
|
+
phase: "claimed";
|
|
47
|
+
}>;
|
|
48
|
+
readonly taskId?: string;
|
|
49
|
+
}): Promise<DispatchOutcome>;
|
|
50
|
+
export declare function createAgentErrorResult(input: {
|
|
51
|
+
readonly action: RuntimeAgentHandleAction;
|
|
52
|
+
readonly code: string;
|
|
53
|
+
readonly message: string;
|
|
54
|
+
}): RuntimeSubagentDispatchFailure;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createEveCallbackRoutePath}from"#protocol/routes.js";import{createLogger,logError}from"#internal/logging.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{continueRemoteAgentSession,isAmbiguousRemoteAgentContinueError,isRetryableRemoteAgentContinueError,resolveRemoteAgentForAction}from"#subagents/remote-dispatch.js";import{AGENT_UNREACHABLE}from"#subagents/agent-handle-errors.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{readTaskIdFromInboxToken}from"#tasks/task-inbox-token.js";import{isRuntimeNoActiveSessionError}from"#execution/runtime-errors.js";import{normalizeRequestedOutputSchema}from"#subagents/invocation.js";import{err,ok}from"#shared/result.js";const log=createLogger(`execution.agent-handle-dispatch`);function isAgentHandleAction(e){return e.kind===`subagent-call`||e.kind===`remote-agent-call`}async function dispatchToClaimedAgentAddress(e){return await dispatchToAgentAddress(e)}async function dispatchToAgentAddress(e){let{action:t,handle:r}=e,i=r.identity.id,a=await deliverToAgentAddress({action:t,address:r.address,auth:e.auth,bundle:e.bundle,identity:r.identity,parentToken:e.parentToken,taskId:e.taskId});if(!a.ok){let{cause:o,permanent:s}=a.error;return logError(log,`task agent delivery failed`,o,{agentId:i,callId:t.callId,nodeId:r.identity.nodeId,permanent:s,subagentName:r.identity.name}),{deliveryAmbiguous:a.error.deliveryAmbiguous,deliveryPermanent:s,kind:`error`,result:createAgentErrorResult({action:t,code:AGENT_UNREACHABLE,message:s?`Agent "${r.identity.name}" with id "${i}" is no longer reachable.`:`Agent "${r.identity.name}" with id "${i}" is temporarily unreachable. Try again.`}),session:e.currentSession}}return{address:r.address,callId:t.callId,kind:`called`,name:t.name,session:e.currentSession,toolName:r.identity.name}}async function deliverToAgentAddress(t){let{action:n,address:c,bundle:l,identity:u}=t;if(c.kind===`agent/remote`){let r;try{r=resolveRemoteAgentForAction({nodeId:u.nodeId,remoteAgentName:u.name,registry:l.subagentRegistry.subagentsByNodeId})}catch(e){return err({cause:e,deliveryAmbiguous:!1,permanent:!0})}try{await continueRemoteAgentSession({auth:t.auth,callback:{callId:n.callId,subagentName:u.name,taskId:t.taskId??readTaskIdFromInboxToken(t.parentToken),token:t.parentToken,url:createWorkflowCallbackUrl(c.callbackBaseUrl,createEveCallbackRoutePath(t.parentToken))},message:readSubagentMessage(n),outputSchema:normalizeRequestedOutputSchema(n.input.outputSchema),remote:{...r,url:c.url},sessionId:c.sessionId})}catch(e){return err({cause:e,deliveryAmbiguous:isAmbiguousRemoteAgentContinueError(e),permanent:!isRetryableRemoteAgentContinueError(e)})}return ok(void 0)}let d=createWorkflowRuntime({compiledArtifactsSource:l.compiledArtifactsSource,nodeId:u.nodeId});try{if((await d.dispatchSession({command:{auth:t.auth,caller:{callId:n.callId,replyTo:{kind:`hook`,token:t.parentToken},subagentName:u.name,taskId:t.taskId??readTaskIdFromInboxToken(t.parentToken)},kind:`send`,payload:{message:readSubagentMessage(n),outputSchema:normalizeRequestedOutputSchema(n.input.outputSchema)}},sessionId:c.sessionId})).status===`session_not_active`)return err({cause:Error(`Agent session "${c.sessionId}" is no longer active.`),deliveryAmbiguous:!1,permanent:!0})}catch(e){let t=isRuntimeNoActiveSessionError(e);return err({cause:e,deliveryAmbiguous:!t,permanent:t})}return ok(void 0)}function createAgentErrorResult(e){return{callId:e.action.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:e.code,message:e.message},subagentName:e.action.kind===`remote-agent-call`?e.action.remoteAgentName:e.action.subagentName}}function readSubagentMessage(e){return typeof e.input.message==`string`?e.input.message:``}export{createAgentErrorResult,dispatchToClaimedAgentAddress,isAgentHandleAction};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelMessage } from "ai";
|
|
2
|
-
import type { AgentHandle, AgentHandleStore } from "#
|
|
2
|
+
import type { AgentHandle, AgentHandleStore } from "#subagents/handles/store.js";
|
|
3
3
|
/**
|
|
4
4
|
* Label prefixing every framework-injected agents announcement. Mock model
|
|
5
5
|
* adapters use it to treat announcements as transparent scaffolding rather
|
|
@@ -15,12 +15,12 @@ export interface AgentView {
|
|
|
15
15
|
readonly taskId?: string;
|
|
16
16
|
readonly taskStatus?: "working" | "input_required";
|
|
17
17
|
}
|
|
18
|
-
/** Returns the resumable handles: the only
|
|
18
|
+
/** Returns the resumable handles: the only phases the model may continue. */
|
|
19
19
|
export declare function projectParkedAgentHandles(store: AgentHandleStore): readonly Extract<AgentHandle, {
|
|
20
|
-
phase: "parked";
|
|
20
|
+
phase: "available" | "parked";
|
|
21
21
|
}>[];
|
|
22
22
|
/**
|
|
23
|
-
* Renders the model-visible agent listing. Only
|
|
23
|
+
* Renders the model-visible agent listing. Only idle handles appear:
|
|
24
24
|
* starting and running children cannot accept a continuation, and private
|
|
25
25
|
* delivery coordinates never render.
|
|
26
26
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const AGENTS_SNIPPET_LABEL=`[Agents]`;function projectParkedAgentHandles(e){return e.handles.filter(e=>e.phase===`parked`)}function renderAgentsSnippet(t){let n=projectParkedAgentHandles(t).map(e
|
|
1
|
+
const AGENTS_SNIPPET_LABEL=`[Agents]`;function projectParkedAgentHandles(e){return e.handles.filter(e=>e.phase===`available`||e.phase===`parked`)}function renderAgentsSnippet(t){let n=projectParkedAgentHandles(t).map(e=>{let t=e.phase===`parked`?e.lastStatus:`(available)`;return`<agent id="${escapeXml(e.identity.id)}" name="${escapeXml(e.identity.name)}">${escapeXml(t===``?`(no status)`:t)}</agent>`});return[AGENTS_SNIPPET_LABEL,`<agents>`,...n,`</agents>`].join(`
|
|
2
2
|
`)}function renderAgentViewsSnippet(t){let n=t.map(e=>{let t=e.taskId===void 0||e.taskStatus===void 0?``:` taskId="${escapeXml(e.taskId)}" taskStatus="${e.taskStatus}"`,n=e.statusLine??(e.availability===`busy`?`(busy)`:`(available)`);return`<agent id="${escapeXml(e.id)}" name="${escapeXml(e.name)}" availability="${e.availability}"${t}>${escapeXml(n)}</agent>`});return[AGENTS_SNIPPET_LABEL,`<agents>`,...n,`</agents>`].join(`
|
|
3
3
|
`)}function resolveAgentsAnnouncement(e){let t=e.messages.findLast(e=>e.role===`user`&&typeof e.content==`string`&&e.content.startsWith(`[Agents]`)),n=e.store??{handles:[]},r=e.agentViews?.length??projectParkedAgentHandles(n).length;if(t===void 0&&r===0)return;let i=e.agentViews===void 0?renderAgentsSnippet(n):renderAgentViewsSnippet(e.agentViews);return t?.content===i?void 0:i}function escapeXml(e){return e.replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}export{AGENTS_SNIPPET_LABEL,projectParkedAgentHandles,renderAgentViewsSnippet,renderAgentsSnippet,resolveAgentsAnnouncement};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { RuntimeActionResult, RuntimeSubagentChildResult } from "#shared/action-types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TurnOwnedAgentHandle } from "#subagents/handles/store.js";
|
|
3
3
|
import type { SessionStateMap } from "#harness/types.js";
|
|
4
4
|
/** A handle with one outstanding operation and a confirmed child address. */
|
|
5
|
-
export type RunningAgentHandle = Extract<
|
|
5
|
+
export type RunningAgentHandle = Extract<TurnOwnedAgentHandle, {
|
|
6
6
|
phase: "running";
|
|
7
7
|
}>;
|
|
8
|
+
/** Preserves driver-owned task leases when a concurrent turn returns an older snapshot. */
|
|
9
|
+
export declare function mergeTaskOwnedAgentHandlesIntoTurnState(input: {
|
|
10
|
+
readonly baseState: SessionStateMap | undefined;
|
|
11
|
+
readonly driverState: SessionStateMap | undefined;
|
|
12
|
+
readonly turnState: SessionStateMap | undefined;
|
|
13
|
+
}): SessionStateMap | undefined;
|
|
8
14
|
/**
|
|
9
15
|
* Finds the running agent handle a child-produced result must settle: the
|
|
10
16
|
* handle whose recorded operation carries the result's callId.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AGENT_HANDLES_STATE_KEY}from"#subagents/handles/state-key.js";function readAgentHandles(t){let n=t?.[AGENT_HANDLES_STATE_KEY];if(n===void 0)return[];let r=n.handles;return Array.isArray(r)?r:[]}function mergeTaskOwnedAgentHandlesIntoTurnState(t){let n=new Map(readAgentHandles(t.baseState).map(e=>[e.identity.id,e])),r=new Map(readAgentHandles(t.driverState).map(e=>[e.identity.id,e])),i=new Set([...n.keys(),...r.keys()]);for(let e of i)handlesEqual(n.get(e),r.get(e))&&i.delete(e);if(i.size===0)return t.turnState;let a=[];for(let e of readAgentHandles(t.turnState)){if(!i.has(e.identity.id)){a.push(e);continue}let t=r.get(e.identity.id);if(!handlesEqual(e,n.get(e.identity.id))&&!handlesEqual(e,t))throw Error(`Agent handle "${e.identity.id}" changed ownership while its turn was running.`);t!==void 0&&a.push(t),i.delete(e.identity.id)}for(let e of i){let t=r.get(e);t!==void 0&&a.push(t)}return{...t.turnState,[AGENT_HANDLES_STATE_KEY]:{handles:a}}}function handlesEqual(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>valuesEqual(Reflect.get(e,n),Reflect.get(t,n)))}function valuesEqual(e,t){if(e===t)return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>valuesEqual(Reflect.get(e,n),Reflect.get(t,n)))}function findRunningAgentHandle(e,t){return readAgentHandles(e).find(e=>e.phase===`running`&&e.operation.callId===t.callId)}function isResultBoundToRunningHandle(e,t){return t.kind!==`subagent-result`||t.origin===`dispatch`||t.backgroundTask!==void 0||findRunningAgentHandle(e,{callId:t.callId})!==void 0}function isInboxSubagentResultFromRunningHandle(e,t){return findRunningAgentHandle(e,{callId:t.callId})!==void 0}export{findRunningAgentHandle,isInboxSubagentResultFromRunningHandle,isResultBoundToRunningHandle,mergeTaskOwnedAgentHandlesIntoTurnState};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
+
import type { TurnDriverAction } from "#execution/turn-control-receiver.js";
|
|
3
|
+
/** Preserves handle leases accepted by the driver against a turn's older snapshot. */
|
|
4
|
+
export declare function rebaseTaskAgentHandleMutations(action: TurnDriverAction, driverState: DurableSessionState, baseState: DurableSessionState): TurnDriverAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mergeTaskOwnedAgentHandlesIntoTurnState}from"#subagents/handles/query.js";function rebaseTaskAgentHandleMutations(e,t,n){let r=e.sessionState.snapshot;if(r===void 0)throw Error(`Cannot merge task-owned agent handles into a session state without a snapshot.`);return{...e,sessionState:{...e.sessionState,snapshot:{...r,session:{...r.session,state:mergeTaskOwnedAgentHandlesIntoTurnState({baseState:n.snapshot?.session.state,driverState:t.snapshot?.session.state,turnState:r.session.state})}}}}}export{rebaseTaskAgentHandleMutations};
|
|
@@ -80,21 +80,13 @@ export type AgentAddress = {
|
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* Outside tasks mode, the store owns the full nonterminal lifecycle:
|
|
83
|
+
* Parent-turn-owned lifecycle: `starting → running → parked ↔ running`.
|
|
86
84
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* - `parked` — the child is idle and resumable; only this phase is
|
|
91
|
-
* model-visible.
|
|
92
|
-
*
|
|
93
|
-
* A terminal child has no legacy handle: settlement deletes it. Tasks mode
|
|
94
|
-
* instead keeps an `addressed` record whose availability is derived from the
|
|
95
|
-
* tasks bound to its persistent child session.
|
|
85
|
+
* `starting` owns a start intent before the child has an address, `running`
|
|
86
|
+
* owns one outstanding child turn, and `parked` retains an idle, resumable
|
|
87
|
+
* child. A terminal child or dead dispatch leaves this union entirely.
|
|
96
88
|
*/
|
|
97
|
-
export type
|
|
89
|
+
export type TurnOwnedAgentHandle = {
|
|
98
90
|
readonly phase: "starting";
|
|
99
91
|
readonly identity: AgentIdentity;
|
|
100
92
|
readonly operation: StartOperation;
|
|
@@ -109,18 +101,93 @@ export type AgentHandle = {
|
|
|
109
101
|
readonly identity: AgentIdentity;
|
|
110
102
|
readonly address: AgentAddress;
|
|
111
103
|
readonly lastStatus: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Workflow-owner lifecycle: `reserved → claimed → available ↔ claimed`.
|
|
107
|
+
*
|
|
108
|
+
* `reserved` leases a fresh identity before start, `claimed` leases an
|
|
109
|
+
* addressed child turn to one task or workflow-tool run, and `available`
|
|
110
|
+
* retains the idle address between invocations. A terminal child leaves this
|
|
111
|
+
* union entirely.
|
|
112
|
+
*/
|
|
113
|
+
export type TaskOwnedAgentHandle = {
|
|
114
|
+
/** Fresh identity leased to one owner before the child's address is confirmed. */
|
|
115
|
+
readonly phase: "reserved";
|
|
116
|
+
readonly identity: AgentIdentity;
|
|
117
|
+
readonly operationId: string;
|
|
118
|
+
readonly callId?: string;
|
|
119
|
+
readonly ownerId: string;
|
|
120
|
+
} | {
|
|
121
|
+
/** Addressed child turn leased until its owner releases it. */
|
|
122
|
+
readonly phase: "claimed";
|
|
123
|
+
readonly identity: AgentIdentity;
|
|
124
|
+
readonly operationId: string;
|
|
125
|
+
readonly callId?: string;
|
|
126
|
+
readonly address: AgentAddress;
|
|
127
|
+
readonly ownerId: string;
|
|
112
128
|
} | {
|
|
113
|
-
/**
|
|
114
|
-
readonly phase: "
|
|
129
|
+
/** Idle addressed child with no owner lease, ready for a later invocation to claim. */
|
|
130
|
+
readonly phase: "available";
|
|
115
131
|
readonly identity: AgentIdentity;
|
|
116
132
|
readonly address: AgentAddress;
|
|
117
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Durable ownership record for one delegated child.
|
|
136
|
+
*
|
|
137
|
+
* The two execution policies share an identity namespace and serialized store,
|
|
138
|
+
* but their lifecycle states and transitions are disjoint. A terminal child has
|
|
139
|
+
* no handle: settlement deletes it.
|
|
140
|
+
*/
|
|
141
|
+
export type AgentHandle = TurnOwnedAgentHandle | TaskOwnedAgentHandle;
|
|
118
142
|
/** Lifecycle phase of a delegated agent handle. */
|
|
119
143
|
export type AgentHandlePhase = AgentHandle["phase"];
|
|
120
144
|
/** Session-state collection of delegated agent handles. */
|
|
121
145
|
export interface AgentHandleStore {
|
|
122
146
|
readonly handles: readonly AgentHandle[];
|
|
123
147
|
}
|
|
148
|
+
export declare const EMPTY_AGENT_HANDLE_STORE: AgentHandleStore;
|
|
149
|
+
/** One serialized owner-lease mutation against the shared agent handle store. */
|
|
150
|
+
export type AgentHandleStoreCommand = {
|
|
151
|
+
readonly kind: "read";
|
|
152
|
+
} | {
|
|
153
|
+
readonly identity: AgentIdentity;
|
|
154
|
+
readonly kind: "reserve";
|
|
155
|
+
readonly operationId: string;
|
|
156
|
+
readonly callId?: string;
|
|
157
|
+
readonly ownerId: string;
|
|
158
|
+
} | {
|
|
159
|
+
readonly address: AgentAddress;
|
|
160
|
+
readonly kind: "confirm";
|
|
161
|
+
readonly operationId: string;
|
|
162
|
+
readonly ownerId: string;
|
|
163
|
+
} | {
|
|
164
|
+
readonly agentId: string;
|
|
165
|
+
readonly expectedTarget: "local" | "remote";
|
|
166
|
+
readonly callId?: string;
|
|
167
|
+
readonly invokedName: string;
|
|
168
|
+
readonly kind: "claim";
|
|
169
|
+
readonly operationId: string;
|
|
170
|
+
readonly ownerId: string;
|
|
171
|
+
} | {
|
|
172
|
+
readonly agentId: string;
|
|
173
|
+
readonly kind: "remove";
|
|
174
|
+
readonly ownerId: string;
|
|
175
|
+
} | {
|
|
176
|
+
readonly kind: "release-owner";
|
|
177
|
+
readonly ownerId: string;
|
|
178
|
+
};
|
|
179
|
+
export type AgentHandleStoreCommandResult = {
|
|
180
|
+
readonly kind: "ready";
|
|
181
|
+
readonly handle?: TaskOwnedAgentHandle;
|
|
182
|
+
} | {
|
|
183
|
+
readonly kind: "busy";
|
|
184
|
+
readonly handle: AgentHandle;
|
|
185
|
+
} | {
|
|
186
|
+
readonly kind: "mismatch";
|
|
187
|
+
readonly handle: AgentHandle;
|
|
188
|
+
} | {
|
|
189
|
+
readonly kind: "unknown";
|
|
190
|
+
};
|
|
124
191
|
/** Derives the model-visible agent id from the first start operation. */
|
|
125
192
|
export declare function deriveAgentId(name: string, startOperationId: string): string;
|
|
126
193
|
/** Collapses whitespace and truncates output into a handle status line. */
|
|
@@ -132,6 +199,8 @@ export declare function formatAgentStatus(output: unknown): string;
|
|
|
132
199
|
* driver-side reader (`query.ts`) trust stored values without revalidating.
|
|
133
200
|
*/
|
|
134
201
|
export declare function assertPersistableAgentHandleStore(store: AgentHandleStore): AgentHandleStore;
|
|
202
|
+
/** Parses one complete command before the session inbox routes it to the handle store. */
|
|
203
|
+
export declare function parseAgentHandleStoreCommand(value: unknown): AgentHandleStoreCommand | undefined;
|
|
135
204
|
/**
|
|
136
205
|
* Reads and validates the agent handle store from session state.
|
|
137
206
|
*
|
|
@@ -140,3 +209,9 @@ export declare function assertPersistableAgentHandleStore(store: AgentHandleStor
|
|
|
140
209
|
* transition silently replace every delegated child's delivery coordinates.
|
|
141
210
|
*/
|
|
142
211
|
export declare function getAgentHandleStore(state: SessionStateMap | undefined): AgentHandleStore | undefined;
|
|
212
|
+
/** Writes the validated agent handle store under its single session-state key. */
|
|
213
|
+
export declare function setAgentHandleStore(state: SessionStateMap | undefined, store: AgentHandleStore): SessionStateMap;
|
|
214
|
+
/** Writes a validated handle list to a session-shaped value. */
|
|
215
|
+
export declare function writeHandles<Session extends {
|
|
216
|
+
readonly state?: SessionStateMap;
|
|
217
|
+
}>(session: Session, handles: readonly AgentHandle[]): Session;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AGENT_HANDLES_STATE_KEY}from"./state-key.js";import{z}from"#compiled/zod/index.js";const EMPTY_AGENT_HANDLE_STORE={handles:[]},nonEmptyString=z.string().min(1),identitySchema=z.strictObject({id:nonEmptyString,name:nonEmptyString,nodeId:nonEmptyString}),startOperationSchema=z.strictObject({callId:nonEmptyString,id:nonEmptyString,kind:z.literal(`start`),parentTurnId:nonEmptyString}),continueOperationSchema=z.strictObject({callId:nonEmptyString,id:nonEmptyString,kind:z.literal(`continue`),parentTurnId:nonEmptyString,previousStatus:z.string().max(120)}),startTargetSchema=z.discriminatedUnion(`kind`,[z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/local`)}),z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/self`)}),z.strictObject({callbackBaseUrl:z.url(),credentialResolver:z.strictObject({resolverId:nonEmptyString.optional()}).optional(),kind:z.literal(`agent/remote`),url:z.url()})]),addressSchema=z.discriminatedUnion(`kind`,[z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/local`),sessionId:nonEmptyString}),z.strictObject({continuationToken:nonEmptyString,kind:z.literal(`agent/self`),sessionId:nonEmptyString}),z.strictObject({callbackBaseUrl:z.url(),credentialResolver:z.strictObject({resolverId:nonEmptyString.optional()}).optional(),kind:z.literal(`agent/remote`),sessionId:nonEmptyString,url:z.url()})]),agentHandleStoreCommandSchema=z.discriminatedUnion(`kind`,[z.strictObject({kind:z.literal(`read`)}),z.strictObject({identity:identitySchema,callId:nonEmptyString.optional(),kind:z.literal(`reserve`),operationId:nonEmptyString,ownerId:nonEmptyString}),z.strictObject({address:addressSchema,kind:z.literal(`confirm`),operationId:nonEmptyString,ownerId:nonEmptyString}),z.strictObject({agentId:nonEmptyString,callId:nonEmptyString.optional(),expectedTarget:z.enum([`local`,`remote`]),invokedName:nonEmptyString,kind:z.literal(`claim`),operationId:nonEmptyString,ownerId:nonEmptyString}),z.strictObject({agentId:nonEmptyString,kind:z.literal(`remove`),ownerId:nonEmptyString}),z.strictObject({kind:z.literal(`release-owner`),ownerId:nonEmptyString})]),turnOwnedAgentHandleSchema=z.discriminatedUnion(`phase`,[z.strictObject({identity:identitySchema,operation:startOperationSchema,phase:z.literal(`starting`),target:startTargetSchema}),z.strictObject({address:addressSchema,identity:identitySchema,operation:z.discriminatedUnion(`kind`,[startOperationSchema,continueOperationSchema]),phase:z.literal(`running`)}),z.strictObject({address:addressSchema,identity:identitySchema,lastStatus:z.string().max(120),phase:z.literal(`parked`)})]),taskOwnedAgentHandleSchema=z.discriminatedUnion(`phase`,[z.strictObject({callId:nonEmptyString.optional(),identity:identitySchema,operationId:nonEmptyString,phase:z.literal(`reserved`),ownerId:nonEmptyString}),z.strictObject({address:addressSchema,callId:nonEmptyString.optional(),identity:identitySchema,operationId:nonEmptyString,phase:z.literal(`claimed`),ownerId:nonEmptyString}),z.strictObject({address:addressSchema,identity:identitySchema,phase:z.literal(`available`)})]),agentHandleSchema=z.union([turnOwnedAgentHandleSchema,taskOwnedAgentHandleSchema]),agentHandleStoreSchema=z.strictObject({handles:z.array(agentHandleSchema)}).refine(e=>new Set(e.handles.map(e=>e.identity.id)).size===e.handles.length,{message:`Agent handle ids must be unique.`});function deriveAgentId(e,t){return`ag_${e}:${t.slice(0,12)}`}function formatAgentStatus(e){return(typeof e==`string`?e:JSON.stringify(e)??``).replaceAll(/\s+/g,` `).trim().slice(0,120)}function assertPersistableAgentHandleStore(e){let t=agentHandleStoreSchema.safeParse(e);if(!t.success)throw Error(`Refusing to persist a corrupt agent handle store: ${t.error.message}`);return t.data}function parseAgentHandleStoreCommand(e){let t=agentHandleStoreCommandSchema.safeParse(e);return t.success?t.data:void 0}function getAgentHandleStore(t){let n=t?.[AGENT_HANDLES_STATE_KEY];if(n===void 0)return;let r=agentHandleStoreSchema.safeParse(n);if(!r.success)throw Error(`Corrupt agent handle store under session state key "${AGENT_HANDLES_STATE_KEY}": ${r.error.message}`);return r.data}function setAgentHandleStore(t,n){return{...t,[AGENT_HANDLES_STATE_KEY]:assertPersistableAgentHandleStore(n)}}function writeHandles(e,t){return{...e,state:setAgentHandleStore(e.state,{handles:t})}}export{AGENT_HANDLES_STATE_KEY,EMPTY_AGENT_HANDLE_STORE,assertPersistableAgentHandleStore,deriveAgentId,formatAgentStatus,getAgentHandleStore,parseAgentHandleStoreCommand,setAgentHandleStore,writeHandles};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type AgentAddress, type AgentHandleStore, type AgentHandleStoreCommand, type AgentHandleStoreCommandResult, type AgentIdentity, type StartOperation, type TurnOwnedAgentHandle } from "#subagents/handles/store.js";
|
|
2
|
+
import type { HarnessSession, SessionStateMap } from "#harness/types.js";
|
|
3
|
+
import type { AgentTurnOutcome } from "#shared/agent-turn-outcome.js";
|
|
4
|
+
/**
|
|
5
|
+
* Records intent to start a fresh child. Must be applied to the step's
|
|
6
|
+
* working snapshot before the start side effect runs, so the returned state
|
|
7
|
+
* owns any child the step may have created.
|
|
8
|
+
*
|
|
9
|
+
* The guarantee is intra-step, not exactly-once: the prepared handle
|
|
10
|
+
* durably commits only when the enclosing dispatch step's result commits.
|
|
11
|
+
* A crash between an accepted start and that commit replays the step from
|
|
12
|
+
* the pre-step snapshot and re-runs the side effect.
|
|
13
|
+
*
|
|
14
|
+
* Throws when the identity or operation already exists: fresh starts mint
|
|
15
|
+
* a new identity, so a collision means corrupted derivation, not a replay.
|
|
16
|
+
*/
|
|
17
|
+
export declare function prepareAgentStart(session: HarnessSession, input: {
|
|
18
|
+
readonly identity: AgentIdentity;
|
|
19
|
+
readonly operation: StartOperation;
|
|
20
|
+
readonly target: AgentStartTargetInput;
|
|
21
|
+
}): HarnessSession;
|
|
22
|
+
type AgentStartTargetInput = Extract<TurnOwnedAgentHandle, {
|
|
23
|
+
phase: "starting";
|
|
24
|
+
}>["target"];
|
|
25
|
+
/**
|
|
26
|
+
* Confirms a started child: `starting` becomes `running` with the child's
|
|
27
|
+
* confirmed address. Throws when no starting handle carries the operation,
|
|
28
|
+
* because confirming an unprepared start means ownership was never
|
|
29
|
+
* committed. Re-confirming an already-running handle with the same
|
|
30
|
+
* operation and address is a replay no-op.
|
|
31
|
+
*/
|
|
32
|
+
export declare function confirmAgentStarted(session: HarnessSession, input: {
|
|
33
|
+
readonly operationId: string;
|
|
34
|
+
readonly address: AgentAddress;
|
|
35
|
+
}): HarnessSession;
|
|
36
|
+
/**
|
|
37
|
+
* Resolves a dispatch that definitively failed.
|
|
38
|
+
*
|
|
39
|
+
* - A dead start or dead continuation deletes the handle: there is no
|
|
40
|
+
* child left to own.
|
|
41
|
+
* - A retryable continuation failure restores `parked` with the status the
|
|
42
|
+
* handle showed before the delivery, so the model may retry the same
|
|
43
|
+
* `agentId` later.
|
|
44
|
+
*
|
|
45
|
+
* Unknown operations are a no-op: the failure raced a settlement that
|
|
46
|
+
* already resolved the handle.
|
|
47
|
+
*/
|
|
48
|
+
export declare function rejectAgentEffect(session: HarnessSession, input: {
|
|
49
|
+
readonly operationId: string;
|
|
50
|
+
readonly disposition: "dead" | "retryable";
|
|
51
|
+
}): HarnessSession;
|
|
52
|
+
/**
|
|
53
|
+
* Parks every running child when the parent abandons a cancelled turn.
|
|
54
|
+
*
|
|
55
|
+
* Cancellation requests each running descendant's cancellation and then
|
|
56
|
+
* tears down the turn inbox — the only hook a child settlement can
|
|
57
|
+
* resume — so no later settlement can move these handles. Without this
|
|
58
|
+
* transition they would stay `running` forever: invisible to the model,
|
|
59
|
+
* unresumable, and retried by every future cancellation.
|
|
60
|
+
*
|
|
61
|
+
* A cancelled child settles its own turn as a park, so `parked` with
|
|
62
|
+
* `"(cancelled)"` mirrors {@link settleAgentTurn}'s cancelled outcome. If
|
|
63
|
+
* the child instead died, a later continuation attempt discovers the dead
|
|
64
|
+
* session and {@link rejectAgentEffect} deletes the handle.
|
|
65
|
+
*/
|
|
66
|
+
export declare function abandonRunningAgentTurns(session: HarnessSession): HarnessSession;
|
|
67
|
+
/** Result of applying a settled child turn to the store. */
|
|
68
|
+
export type SettleAgentTurnResult = {
|
|
69
|
+
readonly kind: "settled";
|
|
70
|
+
readonly session: HarnessSession;
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "ignored";
|
|
73
|
+
readonly reason: "unknown-operation";
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Applies one settled child turn: `running` becomes `parked` for a parked
|
|
77
|
+
* outcome or is deleted for a terminal outcome.
|
|
78
|
+
*
|
|
79
|
+
* The settlement must carry the operation currently recorded on the
|
|
80
|
+
* running handle; anything else is ignored so a stale delivery can never
|
|
81
|
+
* move a newer turn.
|
|
82
|
+
*/
|
|
83
|
+
export declare function settleAgentTurn(session: HarnessSession, input: {
|
|
84
|
+
readonly operationId: string;
|
|
85
|
+
readonly outcome: AgentTurnOutcome;
|
|
86
|
+
}): SettleAgentTurnResult;
|
|
87
|
+
/** Applies one atomic owner lease command to the shared agent handle store. */
|
|
88
|
+
export declare function applyAgentHandleStoreCommand(store: AgentHandleStore, command: AgentHandleStoreCommand): {
|
|
89
|
+
readonly result: AgentHandleStoreCommandResult;
|
|
90
|
+
readonly store: AgentHandleStore;
|
|
91
|
+
};
|
|
92
|
+
/** Parks child turns still owned by workflow runs when their parent turn is cancelled. */
|
|
93
|
+
export declare function abandonAgentInvocationOwners<Session extends {
|
|
94
|
+
readonly state?: SessionStateMap;
|
|
95
|
+
}>(session: Session, ownerIds: ReadonlySet<string>): Session;
|
|
96
|
+
/** Applies one owner-scoped handle transition to a harness session. */
|
|
97
|
+
export declare function applyTaskAgentHandleCommand<Session extends {
|
|
98
|
+
readonly state?: SessionStateMap;
|
|
99
|
+
}>(session: Session, command: AgentHandleStoreCommand): {
|
|
100
|
+
readonly result: AgentHandleStoreCommandResult;
|
|
101
|
+
readonly session: Session;
|
|
102
|
+
};
|
|
103
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EMPTY_AGENT_HANDLE_STORE,formatAgentStatus,getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";function prepareAgentStart(e,t){let i=getAgentHandleStore(e.state)?.handles??[];if(i.some(e=>e.identity.id===t.identity.id))throw Error(`Agent handle "${t.identity.id}" already exists.`);return writeHandles(e,[...i,{identity:t.identity,operation:t.operation,phase:`starting`,target:t.target}])}function findActiveHandle(e,t){return e.find(e=>(e.phase===`starting`||e.phase===`running`)&&e.operation.id===t)}function confirmAgentStarted(e,t){let i=getAgentHandleStore(e.state)?.handles??[],a=findActiveHandle(i,t.operationId);if(a===void 0)throw Error(`No prepared agent handle for operation "${t.operationId}".`);return a.phase===`running`?e:writeHandles(e,i.map(e=>e===a?{address:t.address,identity:a.identity,operation:a.operation,phase:`running`}:e))}function rejectAgentEffect(e,t){let i=getAgentHandleStore(e.state)?.handles??[],a=findActiveHandle(i,t.operationId);if(a===void 0)return e;if(t.disposition===`retryable`&&a.phase===`running`){let{operation:t}=a;if(t.kind===`continue`)return writeHandles(e,i.map(e=>e===a?{address:a.address,identity:a.identity,lastStatus:t.previousStatus,phase:`parked`}:e))}return writeHandles(e,i.filter(e=>e!==a))}function abandonRunningAgentTurns(e){let t=getAgentHandleStore(e.state)?.handles??[];return t.some(e=>e.phase===`running`)?writeHandles(e,t.map(e=>e.phase===`running`?{address:e.address,identity:e.identity,lastStatus:`(cancelled)`,phase:`parked`}:e)):e}function settleAgentTurn(e,i){let a=getAgentHandleStore(e.state)?.handles??[],o=a.find(e=>e.phase===`running`&&e.operation.id===i.operationId);if(o===void 0||o.phase!==`running`)return{kind:`ignored`,reason:`unknown-operation`};if(i.outcome.kind===`terminal`)return{kind:`settled`,session:writeHandles(e,a.filter(e=>e!==o))};let{result:s}=i.outcome,c=s.kind===`succeeded`?formatAgentStatus(s.output):s.kind===`failed`?formatAgentStatus(s.error):`(cancelled)`;return{kind:`settled`,session:writeHandles(e,a.map(e=>e===o?{address:o.address,identity:o.identity,lastStatus:c,phase:`parked`}:e))}}function applyAgentHandleStoreCommand(e,t){switch(t.kind){case`read`:return{result:{kind:`ready`},store:e};case`reserve`:{let n=e.handles.find(e=>e.identity.id===t.identity.id);if(n!==void 0)return(n.phase===`reserved`||n.phase===`claimed`)&&n.operationId===t.operationId&&n.ownerId===t.ownerId?{result:{handle:n,kind:`ready`},store:e}:{result:{handle:n,kind:`busy`},store:e};let r={callId:t.callId,identity:t.identity,operationId:t.operationId,phase:`reserved`,ownerId:t.ownerId};return{result:{handle:r,kind:`ready`},store:{handles:[...e.handles,r]}}}case`confirm`:{let n=e.handles.find(e=>(e.phase===`claimed`||e.phase===`reserved`)&&e.operationId===t.operationId&&e.ownerId===t.ownerId);return n===void 0?{result:{kind:`unknown`},store:e}:n.phase===`claimed`?{result:{handle:n,kind:`ready`},store:e}:replaceHandle(e,n,{address:t.address,callId:n.callId,identity:n.identity,operationId:n.operationId,phase:`claimed`,ownerId:n.ownerId})}case`claim`:{let n=e.handles.find(e=>e.identity.id===t.agentId);return n===void 0?{result:{kind:`unknown`},store:e}:n.phase===`starting`||n.phase===`running`||n.identity.name!==t.invokedName||n.phase!==`reserved`&&n.address.kind===`agent/remote`!=(t.expectedTarget===`remote`)?{result:{handle:n,kind:`mismatch`},store:e}:n.phase===`claimed`?n.operationId===t.operationId&&n.ownerId===t.ownerId?{result:{handle:n,kind:`ready`},store:e}:{result:{handle:n,kind:`busy`},store:e}:n.phase===`reserved`?{result:{handle:n,kind:`busy`},store:e}:replaceHandle(e,n,{address:n.address,callId:t.callId,identity:n.identity,operationId:t.operationId,phase:`claimed`,ownerId:t.ownerId})}case`remove`:{let n=e.handles.find(e=>e.identity.id===t.agentId);return n===void 0?{result:{kind:`ready`},store:e}:n.phase===`claimed`&&n.ownerId!==t.ownerId?{result:{handle:n,kind:`busy`},store:e}:{result:{kind:`ready`},store:{handles:e.handles.filter(e=>e!==n)}}}case`release-owner`:{let n=e.handles.flatMap(e=>e.phase===`reserved`&&e.ownerId===t.ownerId?[]:e.phase!==`claimed`||e.ownerId!==t.ownerId?[e]:[{address:e.address,identity:e.identity,phase:`available`}]);return{result:{kind:`ready`},store:handlesEqual(e.handles,n)?e:{handles:n}}}}}function abandonAgentInvocationOwners(e,t){let i=getAgentHandleStore(e.state)?.handles??[],a=i.flatMap(e=>e.phase===`reserved`&&t.has(e.ownerId)?[]:e.phase!==`claimed`||!t.has(e.ownerId)?[e]:[{address:e.address,identity:e.identity,lastStatus:`(cancelled)`,phase:`parked`}]);return handlesEqual(i,a)?e:writeHandles(e,a)}function applyTaskAgentHandleCommand(t,i){let a=getAgentHandleStore(t.state)??EMPTY_AGENT_HANDLE_STORE,o=applyAgentHandleStoreCommand(a,i);return{result:o.result,session:o.store===a?t:writeHandles(t,o.store.handles)}}function replaceHandle(e,t,n){return{result:{handle:n,kind:`ready`},store:{handles:e.handles.map(e=>e===t?n:e)}}}function handlesEqual(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{abandonAgentInvocationOwners,abandonRunningAgentTurns,applyAgentHandleStoreCommand,applyTaskAgentHandleCommand,confirmAgentStarted,prepareAgentStart,rejectAgentEffect,settleAgentTurn};
|
package/dist/src/{execution/delegated-parent-notification.d.ts → subagents/parent-notification.d.ts}
RENAMED
|
@@ -41,18 +41,12 @@ export declare function notifyTurnCallerStep(input: {
|
|
|
41
41
|
readonly sessionId: string;
|
|
42
42
|
readonly settled: SettledTurnNotification;
|
|
43
43
|
}): Promise<void>;
|
|
44
|
-
/** Settles a
|
|
44
|
+
/** Settles a workflow-owned caller after the child turn is cooperatively cancelled. */
|
|
45
45
|
export declare function notifyCancelledTaskCallerStep(input: {
|
|
46
46
|
readonly caller: TurnCaller | undefined;
|
|
47
47
|
readonly sessionId: string;
|
|
48
48
|
readonly usage?: TokenUsage;
|
|
49
49
|
}): Promise<void>;
|
|
50
|
-
/** Binds a durable task to the exact child turn before execution starts. */
|
|
51
|
-
export declare function notifyTaskTurnStartedStep(input: {
|
|
52
|
-
readonly caller: TurnCaller | undefined;
|
|
53
|
-
readonly childSessionId: string;
|
|
54
|
-
readonly childTurnId: string;
|
|
55
|
-
}): Promise<void>;
|
|
56
50
|
/** Resolves the caller that created a delegated conversation session. */
|
|
57
51
|
export declare function resolveInitialTurnCallerStep(input: {
|
|
58
52
|
readonly serializedContext: Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{ActivityObserverKey,SessionCallbackKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{parseJsonValue}from"#shared/json.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{parseSessionCallback}from"#channel/session-callback.js";import{resumeHook}from"#internal/workflow/runtime.js";import{deserializeContext}from"#context/serialize.js";import{HookNotFoundError}from"#compiled/@workflow/errors/index.js";import{SUBAGENT_EXECUTION_FAILED}from"#subagents/agent-handle-errors.js";import{postSessionCallbackRequest}from"#execution/session-callback-request.js";import{SUBAGENT_ADAPTER_KIND,isSubagentAdapterState}from"#subagents/adapter-state.js";import{readTaskIdFromInboxToken}from"#tasks/task-inbox-token.js";const log=createLogger(`execution.delegated-parent-notification`);async function notifyDelegatedParentStep(e){"use step";if(e.result===void 0)return;let t=(await deserializeContext(e.serializedContext)).get(ChannelKey);if(t?.kind!==SUBAGENT_ADAPTER_KIND)return;let n=String(t.state?.parentContinuationToken??``);n!==``&&await resumeHook(n,{kind:`runtime-action-result`,results:[e.usage===void 0?e.result:{...e.result,outcome:{...e.result.outcome,usageDelta:e.usage},usage:e.usage}]})}const ZERO_TOKEN_USAGE={cacheReadTokens:0,cacheWriteTokens:0,inputTokens:0,outputTokens:0};async function notifyTurnCallerStep(e){"use step";if(e.caller===void 0)return;let t=createSettledTurnResult({caller:e.caller,lifecycle:e.lifecycle,sessionId:e.sessionId,settled:e.settled});if(e.caller.replyTo.kind===`callback`){await postSettledTurnCallback({result:t,sessionId:e.sessionId,url:e.caller.replyTo.url});return}await resumeSettledTurnHook(e.caller.replyTo.token,t)}async function notifyCancelledTaskCallerStep(e){"use step";if(e.caller===void 0)return;let t=e.usage??ZERO_TOKEN_USAGE,n={code:SUBAGENT_EXECUTION_FAILED,message:`The agent invocation was cancelled.`},r={callId:e.caller.callId,isError:!0,kind:`subagent-result`,origin:`child`,outcome:{kind:`parked`,result:{kind:`cancelled`},usageDelta:t},output:n,subagentName:e.caller.subagentName},i=e.usage===void 0?r:{...r,usage:e.usage};if(e.caller.replyTo.kind===`callback`){await postSettledTurnCallback({result:i,sessionId:e.sessionId,url:e.caller.replyTo.url});return}await resumeSettledTurnHook(e.caller.replyTo.token,i)}function createSettledTurnResult(e){let t=e.settled.usage??ZERO_TOKEN_USAGE;if(e.settled.isError===!0){let n={code:SUBAGENT_EXECUTION_FAILED,message:toErrorMessage(e.settled.output)};return{callId:e.caller.callId,isError:!0,kind:`subagent-result`,origin:`child`,outcome:{kind:e.lifecycle,result:{error:n,kind:`failed`},usageDelta:t},output:n,subagentName:e.caller.subagentName}}let n=parseJsonValue(e.settled.output),a={callId:e.caller.callId,kind:`subagent-result`,origin:`child`,outcome:{kind:e.lifecycle,result:{kind:`succeeded`,output:n},usageDelta:t},output:n,subagentName:e.caller.subagentName};return e.settled.usage===void 0?a:{...a,usage:e.settled.usage}}async function resolveInitialTurnCallerStep(e){"use step";let t=e.serializedContext[SessionCallbackKey.name];if(t!==void 0){let e=parseSessionCallback(t);if(!e.ok)throw Error(`Serialized session callback is invalid.`,{cause:e.cause});return{callId:e.callback.callId,replyTo:{kind:`callback`,token:e.callback.token,url:e.callback.url},subagentName:e.callback.subagentName,taskId:e.callback.taskId??readTaskIdFromInboxToken(e.callback.token)}}let r=(await deserializeContext(e.serializedContext)).get(ChannelKey);if(!(r?.kind!==SUBAGENT_ADAPTER_KIND||!isSubagentAdapterState(r.state)))return{callId:r.state.callId,replyTo:{kind:`hook`,token:r.state.parentContinuationToken},subagentName:r.state.subagentName,taskId:r.state.taskId??readTaskIdFromInboxToken(r.state.parentContinuationToken)}}async function bindTurnCallerContextStep(e){"use step";let r=e.caller;if(r===void 0)return e.serializedContext;let i=r.activityObserver===void 0?e.serializedContext:{...e.serializedContext,[ActivityObserverKey.name]:r.activityObserver};if(r.replyTo.kind===`callback`){let e={callId:r.callId,subagentName:r.subagentName,token:r.replyTo.token,url:r.replyTo.url};return{...i,[SessionCallbackKey.name]:r.taskId===void 0?e:{...e,taskId:r.taskId}}}let o=i[ChannelKey.name];if(typeof o!=`object`||!o||Reflect.get(o,`kind`)!==SUBAGENT_ADAPTER_KIND||!isSubagentAdapterState(Reflect.get(o,`state`)))throw Error(`Delegated local turn is missing its subagent adapter binding.`);let{taskId:s,...c}=Reflect.get(o,`state`),l={...c,callId:r.callId,parentContinuationToken:r.replyTo.token,subagentName:r.subagentName};return r.taskId!==void 0&&(l.taskId=r.taskId),{...i,[ChannelKey.name]:{...o,state:l}}}async function postSettledTurnCallback(e){let{sessionId:t}=e;if(e.result.isError===!0){await postCallbackPayload({payload:{callId:e.result.callId,error:e.result.output,kind:`turn.failed`,outcome:e.result.outcome,sessionId:t,subagentName:e.result.subagentName},url:e.url});return}await postCallbackPayload({payload:{callId:e.result.callId,kind:`turn.completed`,outcome:e.result.outcome,output:e.result.output,sessionId:t,subagentName:e.result.subagentName},url:e.url})}async function postCallbackPayload(e){let t=await postSessionCallbackRequest({body:e.payload,url:e.url});if(!t.ok)throw Error(`Turn callback failed with HTTP ${t.status}.`)}async function resumeSettledTurnHook(e,t){try{await resumeHook(e,{kind:`runtime-action-result`,results:[t]})}catch(n){if(!HookNotFoundError.is(n))throw n;log.warn(`turn caller hook no longer exists`,{callId:t.callId,callerToken:e})}}export{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTurnCallerStep,resolveInitialTurnCallerStep};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toErrorMessage}from"#shared/errors.js";import{CHANNEL_CONTEXT_KEY_NAME}from"#context/key-names.js";import{SUBAGENT_EXECUTION_FAILED}from"#subagents/agent-handle-errors.js";import{SUBAGENT_ADAPTER_KIND}from"#subagents/adapter-state.js";const ZERO_TOKEN_USAGE={cacheReadTokens:0,cacheWriteTokens:0,inputTokens:0,outputTokens:0};function createDelegatedSubagentSuccessResult(e,n){let i=e[CHANNEL_CONTEXT_KEY_NAME];if(i?.kind===SUBAGENT_ADAPTER_KIND)return{callId:String(i.state?.callId??``),kind:`subagent-result`,origin:`child`,outcome:{kind:`terminal`,result:{kind:`succeeded`,output:n},usageDelta:ZERO_TOKEN_USAGE},output:n,subagentName:String(i.state?.subagentName??``)}}function createDelegatedSubagentErrorResult(t,r){let i=createDelegatedSubagentSuccessResult(t,``);if(i===void 0)return;let a={code:SUBAGENT_EXECUTION_FAILED,message:toErrorMessage(r)};return{...i,isError:!0,outcome:{kind:`terminal`,result:{error:a,kind:`failed`},usageDelta:ZERO_TOKEN_USAGE},output:a}}export{createDelegatedSubagentErrorResult,createDelegatedSubagentSuccessResult};
|
|
@@ -2,7 +2,7 @@ import { type ResetResponse } from "#protocol/reset-session.js";
|
|
|
2
2
|
import type { ActivityObserverConfig, CancelTurnResult, SessionAuthContext, SessionTraceContext } from "#channel/types.js";
|
|
3
3
|
import type { ChannelAudience } from "#shared/channel-audience.js";
|
|
4
4
|
import type { HarnessSession } from "#harness/types.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { RuntimeRemoteAgentDispatchRequest } from "#shared/action-types.js";
|
|
6
6
|
import type { RuntimeSubagentRegistry } from "#runtime/subagents/registry.js";
|
|
7
7
|
import type { DynamicRemoteAgentConfig } from "#runtime/subagents/dynamic-remote-agent-config.js";
|
|
8
8
|
import type { CompiledRuntimeAgentBundle } from "#runtime/sessions/compiled-agent-cache.js";
|
|
@@ -12,7 +12,7 @@ type RemoteAgentSessionCoordinates = {
|
|
|
12
12
|
readonly sessionId: string;
|
|
13
13
|
};
|
|
14
14
|
export declare function startRemoteAgentSession(input: {
|
|
15
|
-
readonly action:
|
|
15
|
+
readonly action: RuntimeRemoteAgentDispatchRequest;
|
|
16
16
|
/** The dispatching turn's session principal, forwarded when `remote.forwardPrincipal` is set. */
|
|
17
17
|
readonly auth?: SessionAuthContext | null;
|
|
18
18
|
readonly callbackBaseUrl: string | undefined;
|
|
@@ -30,6 +30,7 @@ export declare function startRemoteAgentSession(input: {
|
|
|
30
30
|
readonly parentTraceContext?: SessionTraceContext;
|
|
31
31
|
readonly remote: ResolvedRuntimeRemoteAgentNode;
|
|
32
32
|
readonly session: HarnessSession;
|
|
33
|
+
readonly taskId?: string;
|
|
33
34
|
}): Promise<RemoteAgentSessionCoordinates>;
|
|
34
35
|
/** Continues one remote-agent session by its immutable session ID. */
|
|
35
36
|
export declare function continueRemoteAgentSession(input: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{createEveCallbackRoutePath,createEveSessionCancelRoutePath,createEveSessionResetRoutePath,createEveSessionRoutePath}from"#protocol/routes.js";import{expectFunction,expectObjectRecord}from"#internal/authored-module.js";import{CancelTurnResponseSchema}from"#protocol/cancel-turn.js";import{ResetResponseSchema}from"#protocol/reset-session.js";import{formatTraceparent}from"#protocol/traceparent.js";import{writeForwardedAudienceBaggage}from"#protocol/baggage.js";import{decisionToTraceContentCeiling}from"#shared/forwarded-trace-policy.js";import{createWorkflowCallbackUrl}from"#execution/workflow-callback-url.js";import{readTaskIdFromInboxToken}from"#tasks/task-inbox-token.js";import{formatSubagentInput,normalizeRequestedOutputSchema}from"#subagents/invocation.js";import{AgentHandleError}from"#protocol/agent-handle-error.js";import{createRemoteAgentRouteUrl}from"#subagents/remote-route-url.js";const CreateSessionResponseSchema=z.object({ok:z.literal(!0),sessionId:z.string().min(1),status:z.literal(`accepted`)});var RemoteAgentCancelRequestError=class extends Error{retryable;constructor(e,t){super(e),this.name=`RemoteAgentCancelRequestError`,this.retryable=t.retryable}};async function startRemoteAgentSession(e){let n=e.callbackToken??e.session.continuationToken;if(!n)throw Error(`Cannot dispatch remote agent without a parent continuation token.`);if(!e.callbackBaseUrl)throw Error(`Cannot dispatch remote agent without a callback base URL.`);let r=buildForwardedPrincipalField(e),i={capabilities:{},callback:{callId:e.action.callId,subagentName:e.action.remoteAgentName,taskId:e.taskId??readTaskIdFromInboxToken(n),token:n,url:createWorkflowCallbackUrl(e.callbackBaseUrl,createEveCallbackRoutePath(n))},message:formatRemoteAgentCallInputMessage({action:e.action,remote:e.remote}),mode:`conversation`,outputSchema:normalizeRequestedOutputSchema(e.action.input.outputSchema)??e.remote.outputSchema};e.activityObserver!==void 0&&(i.activityObserver=e.activityObserver),r!==void 0&&(i.forwardedPrincipal=r),e.operationId!==void 0&&(i.operationId=e.operationId);let a=await resolveRemoteAgentRequestHeaders(e.remote),o=formatTraceparent(e.parentTraceContext);o!==void 0&&setHeader(a,`traceparent`,o),setHeader(a,`baggage`,writeForwardedAudienceBaggage(readHeader(a,`baggage`),buildForwardedTraceAssertion({forwardedPrincipal:r,originAudience:e.originAudience,parentTraceContext:e.parentTraceContext,traceparent:o})));let s=await fetch(createRemoteAgentSessionUrl(e.remote),{body:JSON.stringify(i),headers:{"content-type":`application/json`,...a},method:`POST`});if(!s.ok)throw Error(`Remote agent "${e.action.remoteAgentName}" create-session request failed with HTTP ${s.status}.`);let c;try{c=await s.json()}catch{throw Error(`Remote agent "${e.action.remoteAgentName}" create-session response was not valid JSON.`)}let l=CreateSessionResponseSchema.safeParse(c);if(!l.success)throw Error(`Remote agent "${e.action.remoteAgentName}" create-session response was invalid.`);return{sessionId:l.data.sessionId}}function buildForwardedTraceAssertion(e){let t=decisionToTraceContentCeiling(e.parentTraceContext?.decision);if(!(e.forwardedPrincipal===void 0||e.parentTraceContext===void 0||(e.parentTraceContext.traceFlags&1)!=1||e.traceparent===void 0||t===void 0))return{ceiling:t,originAudience:e.originAudience??`unknown`}}async function continueRemoteAgentSession(e){let t=buildForwardedPrincipalField(e),n={activityObserver:e.activityObserver,callback:e.callback,message:e.message,outputSchema:e.outputSchema};t!==void 0&&(n.forwardedPrincipal=t);let r=await fetch(createRemoteAgentContinueUrl(e.remote,e.sessionId),{body:JSON.stringify(n),headers:{"content-type":`application/json`,...await resolveRemoteAgentRequestHeaders(e.remote)},method:`POST`});if(!r.ok){let n=await readRemoteAgentErrorCode(r),i=r.status===404||n===AgentHandleError.SessionNotResumable.code,a=r.status===400&&t!==void 0?` The receiver may support forwarded principals only on session creation; upgrade it before retrying.`:``;throw new RemoteAgentContinueRequestError(`Remote agent "${e.remote.name}" continue-session request failed${i?` permanently`:``} with HTTP ${r.status}.${a}`,{deliveryAmbiguous:isAmbiguousRemoteContinueStatus(r.status),retryable:!i})}}var RemoteAgentContinueRequestError=class extends Error{deliveryAmbiguous;retryable;constructor(e,t){super(e),this.name=`RemoteAgentContinueRequestError`,this.deliveryAmbiguous=t.deliveryAmbiguous,this.retryable=t.retryable}};function isRetryableRemoteAgentContinueError(e){return!(e instanceof RemoteAgentContinueRequestError)||e.retryable}function isAmbiguousRemoteAgentContinueError(e){return!(e instanceof RemoteAgentContinueRequestError)||e.deliveryAmbiguous}function isAmbiguousRemoteContinueStatus(e){return e===408||e===425||e>=500}async function readRemoteAgentErrorCode(e){let t;try{t=await e.json()}catch{return}if(typeof t!=`object`||!t)return;let n=Reflect.get(t,`code`);return typeof n==`string`?n:void 0}function buildForwardedPrincipalField(e){if(e.remote.forwardPrincipal!==!0||e.auth===null||e.auth===void 0)return;let t={current:e.auth};return e.initiatorAuth!==null&&e.initiatorAuth!==void 0&&(t.initiator=e.initiatorAuth),t}async function cancelRemoteAgentTurn(e){let t=e.headers??await resolveRemoteAgentRequestHeaders(e.remote),n=await fetch(createRemoteAgentCancelTurnUrl(e.remote,e.sessionId),{body:e.turnId===void 0&&e.taskId===void 0?void 0:JSON.stringify({taskId:e.taskId,turnId:e.turnId}),headers:t,method:`POST`});if(!n.ok)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn request failed with HTTP ${n.status}.`,{retryable:isRetryableRemoteCancelStatus(n.status)});let r;try{r=await n.json()}catch{throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was not valid JSON.`,{retryable:!1})}let i=CancelTurnResponseSchema.safeParse(r);if(!i.success||i.data.status===`accepted`&&i.data.sessionId!==e.sessionId)throw new RemoteAgentCancelRequestError(`Remote agent "${e.remote.name}" cancel-turn response was invalid.`,{retryable:!1});return i.data.status===`accepted`?{sessionId:i.data.sessionId,status:`accepted`}:{status:`no_active_turn`}}function readHeader(e,t){let n=Object.keys(e).find(e=>e.toLowerCase()===t);return n===void 0?void 0:e[n]}function setHeader(e,t,n){for(let n of Object.keys(e))n.toLowerCase()===t&&delete e[n];n!==void 0&&(e[t]=n)}async function resetRemoteAgentSession(e){let t=e.headers??await resolveRemoteAgentRequestHeaders(e.remote),n=await fetch(createRemoteAgentRouteUrl(e.remote.url,createEveSessionResetRoutePath(e.sessionId)),{body:JSON.stringify({reason:`Parent session ended`}),headers:{"content-type":`application/json`,...t},method:`POST`});if(!n.ok)throw Error(`Remote agent "${e.remote.name}" reset-session request failed with HTTP ${n.status}.`);let i=ResetResponseSchema.safeParse(await n.json());if(!i.success||i.data.status===`reset`&&i.data.previousSessionId!==e.sessionId)throw Error(`Remote agent "${e.remote.name}" reset-session response was invalid.`);return i.data}function isRetryableRemoteAgentCancelError(e){return!(e instanceof RemoteAgentCancelRequestError)||e.retryable}function resolveRemoteAgentForAction(e){let t=e.registry.get(e.nodeId)?.definition;if(e.dynamicRemoteAgent!==void 0){if(t===void 0)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);let n=resolveDynamicRemoteAgentCredentials(e.dynamicRemoteAgent),r=e.dynamicRemoteAgent,i={description:r.description,kind:`remote`,logicalPath:t.logicalPath,name:e.remoteAgentName,nodeId:e.nodeId,outputSchema:r.outputSchema,path:r.path,sourceId:t.sourceId,sourceKind:`module`,url:r.url};return r.forwardPrincipal!==void 0&&(i.forwardPrincipal=r.forwardPrincipal),n.auth!==void 0&&(i.auth=n.auth),n.headers!==void 0&&(i.headers=n.headers),i}if(t?.kind!==`remote`)throw Error(`Missing remote agent "${e.remoteAgentName}" in runtime registry.`);return t}async function resolveRemoteAgentStreamHeaders(e){if(e.resolverId===void 0)return{};let t=new Set([e.bundle.graph.root,...e.bundle.graph.nodesByNodeId.values()]);for(let n of t){let t=n.subagentRegistry.subagentsByNodeId.get(e.resolverId)?.definition;if(t!==void 0){if(t.kind!==`remote`||t.name!==e.name||t.url!==e.url)throw Error(`Remote child stream resolver does not match the authored remote agent.`);return await resolveRemoteAgentRequestHeaders(t)}}return await resolveRemoteAgentRequestHeaders(resolveDynamicRemoteAgentCredentials({credentialsStepId:e.resolverId,description:``,path:``,url:e.url}))}function resolveDynamicRemoteAgentCredentials(e){if(e.credentialsStepId===void 0)return{};let t=getStepRegistry().get(e.credentialsStepId);if(t===void 0)throw Error(`Dynamic remote subagent credentials function "${e.credentialsStepId}" is not registered.`);let n=expectObjectRecord(t(),`Dynamic remote subagent credentials are invalid.`),r={};return n.auth!==void 0&&(r.auth=expectFunction(n.auth,`Dynamic remote subagent auth is invalid.`)),n.headers!==void 0&&(r.headers=resolveDynamicRemoteAgentHeaders(n.headers)),r}function resolveDynamicRemoteAgentHeaders(e){if(typeof e==`function`)return e;let t=expectObjectRecord(e,`Dynamic remote subagent headers are invalid.`);for(let e of Object.values(t))if(typeof e!=`string`)throw Error(`Dynamic remote subagent headers are invalid.`);return t}function getStepRegistry(){let e=Symbol.for(`@workflow/core//registeredSteps`),t=globalThis,n=t[e];return n===void 0&&(n=new Map,t[e]=n),n}function createRemoteAgentSessionUrl(e){return createRemoteAgentRouteUrl(e.url,e.path)}function createRemoteAgentCancelTurnUrl(e,t){return createRemoteAgentRouteUrl(e.url,createEveSessionCancelRoutePath(t))}function createRemoteAgentContinueUrl(e,t){return createRemoteAgentRouteUrl(e.url,createEveSessionRoutePath(t))}function isRetryableRemoteCancelStatus(e){return e===408||e===425||e===429||e>=500}async function resolveRemoteAgentRequestHeaders(e){let t={};return e.headers!==void 0&&Object.assign(t,typeof e.headers==`function`?await e.headers():e.headers),e.auth!==void 0&&Object.assign(t,(await e.auth()).headers),t}function formatRemoteAgentCallInputMessage(e){let t=typeof e.action.input.message==`string`?e.action.input.message:``;return formatSubagentInput({description:e.remote.description,message:t,name:e.action.remoteAgentName,type:`remote`}).message}export{RemoteAgentContinueRequestError,cancelRemoteAgentTurn,continueRemoteAgentSession,isAmbiguousRemoteAgentContinueError,isRetryableRemoteAgentCancelError,isRetryableRemoteAgentContinueError,resetRemoteAgentSession,resolveRemoteAgentForAction,resolveRemoteAgentStreamHeaders,startRemoteAgentSession};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { DispatchOutcome, RuntimeSession } from "#
|
|
1
|
+
import type { DispatchOutcome, RuntimeSession } from "#subagents/handle-dispatch.js";
|
|
2
2
|
import type { LocalDevRequestProvenance } from "#context/keys.js";
|
|
3
|
-
import { buildSubagentRunInput, type SubagentInputSource } from "#
|
|
3
|
+
import { buildSubagentRunInput, type SubagentInputSource } from "#subagents/tool.js";
|
|
4
4
|
import { createWorkflowRuntime } from "#execution/workflow-runtime.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { RuntimeSubagentDispatchRequest } from "#shared/action-types.js";
|
|
6
6
|
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
7
7
|
type DynamicSubagentAgentConfig = Parameters<typeof createWorkflowRuntime>[0]["dynamicSubagentAgentConfig"];
|
|
8
8
|
/** Starts one local subagent after dispatch planning has selected its target. */
|
|
9
9
|
export declare function startLocalSubagent(input: {
|
|
10
|
-
readonly action:
|
|
10
|
+
readonly action: RuntimeSubagentDispatchRequest;
|
|
11
11
|
readonly auth: Parameters<typeof buildSubagentRunInput>[0]["auth"];
|
|
12
12
|
readonly batchEvent: {
|
|
13
13
|
readonly sequence: number;
|
|
@@ -25,9 +25,8 @@ export declare function startLocalSubagent(input: {
|
|
|
25
25
|
readonly parentTraceContext: Parameters<typeof buildSubagentRunInput>[0]["parentTraceContext"];
|
|
26
26
|
readonly activityObserver?: Parameters<typeof buildSubagentRunInput>[0]["activityObserver"];
|
|
27
27
|
readonly sandboxSessionId: string;
|
|
28
|
-
readonly selfAgent: boolean;
|
|
29
28
|
readonly session: RuntimeSession;
|
|
30
29
|
readonly source: SubagentInputSource;
|
|
31
|
-
readonly
|
|
30
|
+
readonly taskId?: string;
|
|
32
31
|
}): Promise<DispatchOutcome>;
|
|
33
32
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{ContextContainer,contextStorage}from"#context/container.js";import{toErrorMessage}from"#shared/errors.js";import{createWorkflowRuntime,waitForCommandHookOwner}from"#execution/workflow-runtime.js";import{buildSubagentRunInput}from"#subagents/tool.js";import{SUBAGENT_START_FAILED}from"#subagents/agent-handle-errors.js";const log=createLogger(`execution.subagent-start-local`);async function startLocalSubagent(e){let{action:n,source:r}=e,i=createWorkflowRuntime({compiledArtifactsSource:e.bundle.compiledArtifactsSource,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,nodeId:n.nodeId}),{childContinuationToken:a,runInput:o}=buildSubagentRunInput({action:n,auth:e.auth,batchEvent:e.batchEvent,capabilities:e.capabilities,channelMetadata:e.channelMetadata,fanoutSize:e.fanoutSize,initiatorAuth:e.initiatorAuth,graph:e.bundle.graph,parentContinuationToken:e.parentContinuationToken,parentTraceContext:e.parentTraceContext,activityObserver:e.activityObserver,sandboxSessionId:e.sandboxSessionId,session:e.session,selfAgent:r.type===`runtime`,source:r,taskId:e.taskId}),s=r.type===`runtime`?`agent/self`:`agent/local`,c;try{await contextStorage.run(new ContextContainer({localDevRequest:e.localDevRequest}),()=>i.createSession(o)),c=(await waitForCommandHookOwner(a)).runId}catch(t){return logError(log,`local subagent start failed`,t,{callId:n.callId,nodeId:n.nodeId,subagentName:n.subagentName}),{kind:`error`,result:{callId:n.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:SUBAGENT_START_FAILED,message:toErrorMessage(t)},subagentName:n.subagentName},session:e.currentSession}}return{address:{continuationToken:a,kind:s,sessionId:c},callId:n.callId,kind:`called`,name:n.name,session:e.currentSession,toolName:n.subagentName}}export{startLocalSubagent};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { DispatchOutcome, RuntimeSession } from "#
|
|
2
|
-
import { resolveRemoteAgentForAction, startRemoteAgentSession } from "#
|
|
3
|
-
import type {
|
|
1
|
+
import type { DispatchOutcome, RuntimeSession } from "#subagents/handle-dispatch.js";
|
|
2
|
+
import { resolveRemoteAgentForAction, startRemoteAgentSession } from "#subagents/remote-dispatch.js";
|
|
3
|
+
import type { RuntimeRemoteAgentDispatchRequest } from "#shared/action-types.js";
|
|
4
4
|
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
5
5
|
import type { ChannelAudience } from "#shared/channel-audience.js";
|
|
6
6
|
/** Starts one remote subagent after dispatch planning has selected its target. */
|
|
7
7
|
export declare function startRemoteSubagent(input: {
|
|
8
|
-
readonly action:
|
|
8
|
+
readonly action: RuntimeRemoteAgentDispatchRequest;
|
|
9
9
|
readonly auth: Parameters<typeof startRemoteAgentSession>[0]["auth"];
|
|
10
10
|
readonly batchEvent: {
|
|
11
11
|
readonly sequence: number;
|
|
@@ -21,5 +21,5 @@ export declare function startRemoteSubagent(input: {
|
|
|
21
21
|
readonly parentTraceContext: Parameters<typeof startRemoteAgentSession>[0]["parentTraceContext"];
|
|
22
22
|
readonly activityObserver?: Parameters<typeof startRemoteAgentSession>[0]["activityObserver"];
|
|
23
23
|
readonly session: RuntimeSession;
|
|
24
|
-
readonly
|
|
24
|
+
readonly taskId?: string;
|
|
25
25
|
}): Promise<DispatchOutcome>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#subagents/remote-dispatch.js";import{deriveChildActivityObserverConfig}from"#execution/activity-work.js";import{createRemoteAgentStartFailureResult}from"#execution/dispatch-action-failures.js";import{mintStartOperation}from"#execution/dispatch-start-operation.js";const log=createLogger(`execution.subagent-start-remote`);async function startRemoteSubagent(e){let{action:r}=e,i=deriveChildActivityObserverConfig({activityObserver:e.activityObserver,callId:r.callId,kind:`remote-agent`,name:r.remoteAgentName,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),a,o;try{if(e.callbackBaseUrl===void 0)throw Error(`Cannot dispatch remote agent without a callback base URL.`);a=e.callbackBaseUrl,o=resolveRemoteAgentForAction({dynamicRemoteAgent:e.dynamicRemoteAgent,nodeId:r.nodeId,remoteAgentName:r.remoteAgentName,registry:e.bundle.subagentRegistry.subagentsByNodeId})}catch(n){return logError(log,`remote agent start failed`,n,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:r,error:n}),session:e.currentSession}}let{operation:s}=mintStartOperation({callId:r.callId,name:r.remoteAgentName,nodeId:r.nodeId,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),c={resolverId:e.dynamicRemoteAgent===void 0?r.nodeId:e.dynamicRemoteAgent.credentialsStepId};try{let t=await startRemoteAgentSession({action:r,auth:e.auth,callbackBaseUrl:a,callbackToken:e.parentContinuationToken,originAudience:e.originAudience,initiatorAuth:e.initiatorAuth,operationId:s.id,parentTraceContext:e.parentTraceContext,activityObserver:i,remote:o,session:e.session,taskId:e.taskId});return{address:{callbackBaseUrl:a,credentialResolver:c,kind:`agent/remote`,sessionId:t.sessionId,url:o.url},callId:r.callId,kind:`called`,name:r.name,session:e.currentSession,toolName:r.remoteAgentName}}catch(n){return logError(log,`remote agent start failed`,n,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:r,error:n}),session:e.currentSession}}}export{startRemoteSubagent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getSessionRemainingUsageQuota}from"#harness/turn-tag-state.js";function resolveRemainingSessionTokenLimits(t,n=1){let r=Math.max(1,Math.floor(n)),i=getSessionRemainingUsageQuota(t),a={maxInputTokensPerSession:grantTokenShare(i.inputTokens,r),maxOutputTokensPerSession:grantTokenShare(i.outputTokens,r)},o=grantCostShare(i.costUsd,r);return o!==!1&&(a.maxTokenCostUsdPerSession=o),a}function grantTokenShare(e,t){return e!==!1&&Math.floor(e/t)}function grantCostShare(e,t){return e!==!1&&e/t}export{resolveRemainingSessionTokenLimits};
|