eve 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/channel/types.d.ts +12 -19
- package/dist/src/chunks/{use-eve-agent-DUMU6dap.js → use-eve-agent-B4xN7-fK.js} +4 -4
- package/dist/src/chunks/{use-eve-agent-B5I-k6Ek.js → use-eve-agent-C3vUG5g2.js} +4 -4
- package/dist/src/cli/acp/command.d.ts +1 -1
- package/dist/src/cli/acp/command.js +2 -2
- package/dist/src/cli/agent-command.d.ts +5 -0
- package/dist/src/cli/agent-command.js +1 -0
- package/dist/src/cli/application-command.d.ts +2 -0
- package/dist/src/cli/commands/build.d.ts +1 -1
- package/dist/src/cli/commands/build.js +1 -1
- package/dist/src/cli/commands/deploy.d.ts +2 -0
- package/dist/src/cli/commands/deploy.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.d.ts +14 -0
- package/dist/src/cli/commands/init-agent-workspace.js +1 -0
- package/dist/src/cli/commands/init-repl.js +1 -1
- package/dist/src/cli/commands/init.d.ts +2 -13
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/integration-connect.js +1 -1
- package/dist/src/cli/commands/link.d.ts +2 -0
- package/dist/src/cli/commands/link.js +1 -1
- package/dist/src/cli/commands/preconditions.d.ts +15 -0
- package/dist/src/cli/commands/preconditions.js +1 -1
- package/dist/src/cli/commands/register-integration-commands.d.ts +1 -1
- package/dist/src/cli/commands/register-integration-commands.js +1 -1
- package/dist/src/cli/commands/register-registry-commands.js +2 -2
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/environment.d.ts +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/local-server-process.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/invoke/command.d.ts +1 -1
- package/dist/src/cli/invoke/command.js +1 -1
- package/dist/src/cli/option-parsers.d.ts +1 -0
- package/dist/src/cli/option-parsers.js +1 -1
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/agent-info-schema.d.ts +0 -1
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/message-action-parts.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +1 -0
- package/dist/src/context/keys.d.ts +0 -3
- package/dist/src/context/keys.js +1 -1
- package/dist/src/discover/project.js +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/evals/mock-model.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/activity-work-id.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/channel-context.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +103 -0
- package/dist/src/execution/coordination-dispatch-shared.js +1 -0
- package/dist/src/execution/coordination-dispatch-step.d.ts +7 -0
- package/dist/src/execution/coordination-dispatch-step.js +1 -0
- package/dist/src/execution/create-session-step.d.ts +1 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/dispatch-action-failures.d.ts +5 -5
- package/dist/src/execution/dispatch-action-failures.js +1 -1
- package/dist/src/execution/dispatch-start-operation.d.ts +1 -1
- package/dist/src/execution/dispatch-start-operation.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +1 -1
- package/dist/src/execution/inline-turn.js +1 -1
- package/dist/src/execution/next-driver-action.d.ts +7 -10
- package/dist/src/execution/node-step.d.ts +1 -2
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/pending-turn-state.d.ts +1 -2
- package/dist/src/execution/pending-turn-state.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session-command-inbox.d.ts +2 -3
- package/dist/src/execution/session.d.ts +1 -1
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +1 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/task-event-callback.js +1 -1
- package/dist/src/execution/tasks/child/steps.d.ts +18 -18
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/update-step.d.ts +6 -0
- package/dist/src/execution/tasks/child/update-step.js +1 -0
- package/dist/src/execution/tasks/child/update.d.ts +7 -10
- package/dist/src/execution/tasks/child/update.js +1 -1
- package/dist/src/execution/tasks/child/workflow.d.ts +21 -29
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/control-shared.d.ts +6 -17
- package/dist/src/execution/tasks/parent/control-shared.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +15 -50
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +19 -34
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +5 -15
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/run-parent.d.ts +2 -2
- package/dist/src/execution/tasks/parent/task-cancel.d.ts +11 -0
- package/dist/src/execution/tasks/parent/task-cancel.js +1 -0
- package/dist/src/execution/tasks/parent/tool-execution.d.ts +2 -3
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/subagent/accept-event-step.d.ts +7 -0
- package/dist/src/execution/tools/subagent/accept-event-step.js +1 -0
- package/dist/src/execution/tools/subagent/emit-called-step.d.ts +9 -0
- package/dist/src/execution/tools/subagent/emit-called-step.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +51 -0
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +37 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +55 -0
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -0
- package/dist/src/execution/tools/subagent/receipt-identity.d.ts +11 -0
- package/dist/src/execution/tools/subagent/receipt-identity.js +1 -0
- package/dist/src/execution/{dispatch-runtime-actions-start.d.ts → tools/subagent/start.d.ts} +17 -5
- package/dist/src/execution/tools/subagent/start.js +1 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +24 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -0
- package/dist/src/execution/tools/subagent/task-cancel.d.ts +10 -0
- package/dist/src/execution/tools/subagent/task-cancel.js +1 -0
- package/dist/src/execution/tools/tasks.d.ts +10 -0
- package/dist/src/execution/tools/tasks.js +1 -0
- package/dist/src/execution/{tool-run → tools/workflow}/answer.d.ts +1 -1
- package/dist/src/execution/tools/workflow/answer.js +1 -0
- package/dist/src/execution/tools/workflow/ask.d.ts +22 -0
- package/dist/src/execution/tools/workflow/ask.js +1 -0
- package/dist/src/execution/tools/workflow/background.d.ts +18 -0
- package/dist/src/execution/tools/workflow/background.js +1 -0
- package/dist/src/execution/tools/workflow/body.d.ts +25 -0
- package/dist/src/execution/tools/workflow/body.js +1 -0
- package/dist/src/execution/tools/workflow/cancel.d.ts +11 -0
- package/dist/src/execution/tools/workflow/cancel.js +1 -0
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +7 -0
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -0
- package/dist/src/execution/tools/workflow/messages.d.ts +88 -0
- package/dist/src/execution/tools/workflow/messages.js +1 -0
- package/dist/src/execution/tools/workflow/owner-inbox.d.ts +13 -0
- package/dist/src/execution/tools/workflow/owner-inbox.js +1 -0
- package/dist/src/execution/tools/workflow/owner.d.ts +13 -0
- package/dist/src/execution/tools/workflow/owner.js +1 -0
- package/dist/src/execution/tools/workflow/run-control.d.ts +18 -0
- package/dist/src/execution/tools/workflow/run-control.js +1 -0
- package/dist/src/execution/tools/workflow/start.d.ts +33 -0
- package/dist/src/execution/tools/workflow/start.js +1 -0
- package/dist/src/execution/tools/workflow/types.d.ts +26 -0
- package/dist/src/execution/tools/workflow/types.js +1 -0
- package/dist/src/execution/tools/workflow/workflow.d.ts +3 -0
- package/dist/src/execution/tools/workflow/workflow.js +1 -0
- package/dist/src/execution/turn-workflow-tool-run.d.ts +16 -0
- package/dist/src/execution/turn-workflow-tool-run.js +1 -0
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
- package/dist/src/execution/wire/session-inbox-contract.js +1 -1
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +6 -2
- package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.d.ts +3 -3
- package/dist/src/execution/wire/session-inbox-wire.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v1.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v4.d.ts +267 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.d.ts +3 -0
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.js +1 -0
- package/dist/src/execution/workflow-entry-finalization.d.ts +6 -0
- package/dist/src/execution/workflow-entry-finalization.js +1 -1
- package/dist/src/execution/workflow-entry.d.ts +2 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +1 -7
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/background-tools.d.ts +8 -2
- package/dist/src/harness/{runtime-actions.d.ts → coordination.d.ts} +40 -27
- package/dist/src/harness/coordination.js +1 -0
- package/dist/src/harness/emission.d.ts +9 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +52 -0
- package/dist/src/harness/hitl/session-limit-input-requests.js +1 -1
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +6 -2
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/step-hooks.d.ts +1 -2
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-call-action.js +1 -1
- package/dist/src/harness/tool-call-input-errors.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +3 -1
- package/dist/src/harness/types.d.ts +4 -7
- package/dist/src/harness/workflow-interrupt-state.js +1 -1
- package/dist/src/harness/workflow-lifecycle.d.ts +10 -0
- package/dist/src/harness/workflow-lifecycle.js +1 -1
- package/dist/src/harness/workflow-sandbox.d.ts +1 -1
- package/dist/src/harness/workflow-sandbox.js +2 -2
- package/dist/src/harness/workflow-subagent-limit.d.ts +7 -7
- package/dist/src/harness/workflow-subagent-limit.js +1 -1
- package/dist/src/harness/workflow-task-state.d.ts +9 -0
- package/dist/src/harness/workflow-task-state.js +1 -0
- package/dist/src/harness/workflow-tool-runs.d.ts +27 -0
- package/dist/src/harness/workflow-tool-runs.js +1 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/parent-lineage.js +1 -1
- package/dist/src/internal/agent-name.d.ts +4 -0
- package/dist/src/internal/agent-name.js +1 -0
- package/dist/src/internal/agent-workspace.d.ts +15 -0
- package/dist/src/internal/agent-workspace.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +1 -1
- package/dist/src/internal/nitro/host/start-production-server.js +3 -3
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/project-context.d.ts +26 -0
- package/dist/src/internal/project-context.js +1 -0
- package/dist/src/internal/vercel/assemble-eve-services.d.ts +17 -0
- package/dist/src/internal/vercel/assemble-eve-services.js +1 -0
- package/dist/src/internal/vercel/build-agent-workspace.d.ts +3 -0
- package/dist/src/internal/vercel/build-agent-workspace.js +1 -0
- package/dist/src/internal/vercel/build-command.d.ts +4 -0
- package/dist/src/internal/vercel/build-command.js +1 -0
- package/dist/src/internal/vercel/eve-service-contribution.d.ts +27 -0
- package/dist/src/internal/vercel/eve-service-contribution.js +1 -0
- package/dist/src/internal/vercel/vercel-service-config-operations.d.ts +18 -0
- package/dist/src/internal/vercel/vercel-service-config-operations.js +1 -0
- package/dist/src/internal/vercel/vercel-service-name.d.ts +6 -0
- package/dist/src/internal/vercel/vercel-service-name.js +1 -0
- package/dist/src/internal/vercel/vercel-services-config.d.ts +53 -0
- package/dist/src/internal/vercel/vercel-services-config.js +1 -0
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/protocol/message.d.ts +2 -0
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/memory/file/backends/vercel-blob.js +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/public/workflow/index.d.ts +3 -1
- package/dist/src/public/workflow/index.js +1 -1
- package/dist/src/runtime/actions/results.d.ts +3 -3
- package/dist/src/runtime/actions/results.js +1 -1
- package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
- package/dist/src/runtime/agent/bootstrap.d.ts +1 -0
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/channels/registry.js +1 -1
- package/dist/src/runtime/prompt/compose.d.ts +0 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +16 -1
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/subagents/workflow-reference.d.ts +5 -0
- package/dist/src/runtime/subagents/workflow-reference.js +1 -0
- package/dist/src/runtime/subagents/workflow.d.ts +8 -0
- package/dist/src/runtime/subagents/workflow.js +1 -0
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/setup/integrations/discord/setup.js +1 -1
- package/dist/src/setup/integrations/file-memory/vercel.js +1 -1
- package/dist/src/setup/integrations/linear/setup.js +1 -1
- package/dist/src/setup/integrations/linq/setup.js +3 -3
- package/dist/src/setup/integrations/shopify/setup.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/update/channels.d.ts +4 -12
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/shared/action-types.d.ts +74 -14
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/json.js +1 -1
- package/dist/src/shared/workflow-sandbox.d.ts +1 -1
- package/dist/src/{execution/subagent-adapter-state.d.ts → subagents/adapter-state.d.ts} +2 -0
- package/dist/src/{execution/subagent-adapter-state.js → subagents/adapter-state.js} +1 -1
- package/dist/src/subagents/adapter.js +1 -0
- package/dist/src/{harness → subagents}/agent-handle-errors.d.ts +6 -0
- package/dist/src/subagents/agent-handle-errors.js +1 -0
- package/dist/src/subagents/callback-route.js +1 -0
- package/dist/src/subagents/callback-step.js +1 -0
- package/dist/src/{execution/agent-continuation-bundle.d.ts → subagents/continuation-bundle.d.ts} +1 -1
- package/dist/src/subagents/continuation-bundle.js +1 -0
- package/dist/src/{execution/subagent-event-proxy-step.d.ts → subagents/event-proxy-step.d.ts} +2 -8
- package/dist/src/subagents/event-proxy-step.js +1 -0
- package/dist/src/subagents/handle-dispatch.d.ts +54 -0
- package/dist/src/subagents/handle-dispatch.js +1 -0
- package/dist/src/{harness → subagents}/handles/prompt.d.ts +4 -4
- package/dist/src/{harness → subagents}/handles/prompt.js +1 -1
- package/dist/src/{harness → subagents}/handles/query.d.ts +8 -2
- package/dist/src/subagents/handles/query.js +1 -0
- package/dist/src/subagents/handles/rebase.d.ts +4 -0
- package/dist/src/subagents/handles/rebase.js +1 -0
- package/dist/src/{harness → subagents}/handles/store.d.ts +90 -15
- package/dist/src/subagents/handles/store.js +1 -0
- package/dist/src/subagents/handles/transitions.d.ts +103 -0
- package/dist/src/subagents/handles/transitions.js +1 -0
- package/dist/src/{execution/delegated-parent-notification.d.ts → subagents/parent-notification.d.ts} +1 -7
- package/dist/src/subagents/parent-notification.js +1 -0
- package/dist/src/subagents/parent-result.js +1 -0
- package/dist/src/{execution/remote-agent-dispatch.d.ts → subagents/remote-dispatch.d.ts} +3 -2
- package/dist/src/subagents/remote-dispatch.js +1 -0
- package/dist/src/{execution/subagent-start-local.d.ts → subagents/start-local.d.ts} +5 -6
- package/dist/src/subagents/start-local.js +1 -0
- package/dist/src/{execution/subagent-start-remote.d.ts → subagents/start-remote.d.ts} +5 -5
- package/dist/src/subagents/start-remote.js +1 -0
- package/dist/src/{execution/subagent-tool.d.ts → subagents/tool.d.ts} +5 -3
- package/dist/src/subagents/tool.js +1 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/json.js +1 -1
- package/dist/src/tasks/session-index.d.ts +2 -3
- package/dist/src/tasks/session-index.js +1 -1
- package/dist/src/tasks/task-id.d.ts +3 -4
- package/dist/src/tasks/task-id.js +1 -1
- package/dist/src/tasks/transitions.d.ts +3 -47
- package/dist/src/tasks/transitions.js +1 -1
- package/dist/src/tasks/types.d.ts +69 -247
- package/dist/src/tasks/types.js +1 -1
- package/dist/src/tools/dynamic.d.ts +3 -1
- package/dist/src/tools/framework/agent.d.ts +18 -2
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/framework/task-cancel.d.ts +2 -6
- package/dist/src/tools/framework/task-contract.d.ts +44 -65
- package/dist/src/tools/framework/task-contract.js +1 -1
- package/dist/src/tools/framework/task-update.d.ts +1 -0
- package/dist/src/tools/framework/task-update.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/concepts/built-in-tools.md +9 -90
- package/docs/concepts/context-control.md +2 -2
- package/docs/concepts/execution-model-and-durability.mdx +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +3 -3
- package/docs/guides/deployment/vercel.mdx +20 -2
- package/docs/guides/dynamic-capabilities.md +2 -2
- package/docs/guides/frontend/overview.mdx +1 -1
- package/docs/guides/instrumentation-providers.md +242 -0
- package/docs/guides/instrumentation.md +2 -0
- package/docs/guides/meta.json +1 -0
- package/docs/guides/remote-agents.md +8 -9
- package/docs/reference/cli.md +5 -2
- package/docs/sandbox.mdx +2 -0
- package/docs/subagents/index.mdx +9 -8
- package/docs/tools/overview.mdx +11 -10
- package/docs/tools/workflows.mdx +52 -18
- package/package.json +1 -1
- package/dist/src/execution/agent-continuation-bundle.js +0 -1
- package/dist/src/execution/agent-handle-dispatch.d.ts +0 -79
- package/dist/src/execution/agent-handle-dispatch.js +0 -1
- package/dist/src/execution/delegated-parent-notification.js +0 -1
- package/dist/src/execution/delegated-parent-result.js +0 -1
- package/dist/src/execution/delegation-tool.d.ts +0 -10
- package/dist/src/execution/delegation-tool.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +0 -165
- package/dist/src/execution/dispatch-runtime-actions-shared.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-start.js +0 -1
- package/dist/src/execution/dispatch-runtime-actions-step.d.ts +0 -18
- package/dist/src/execution/dispatch-runtime-actions-step.js +0 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.d.ts +0 -18
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +0 -1
- package/dist/src/execution/finalize-terminal-session.d.ts +0 -17
- package/dist/src/execution/finalize-terminal-session.js +0 -1
- package/dist/src/execution/prepared-agent-action.d.ts +0 -7
- package/dist/src/execution/prepared-agent-action.js +0 -1
- package/dist/src/execution/remote-agent-dispatch.js +0 -1
- package/dist/src/execution/session-callback-route.js +0 -1
- package/dist/src/execution/session-callback-step.js +0 -1
- package/dist/src/execution/subagent-adapter.js +0 -1
- package/dist/src/execution/subagent-event-proxy-step.js +0 -1
- package/dist/src/execution/subagent-start-local.js +0 -1
- package/dist/src/execution/subagent-start-remote.js +0 -1
- package/dist/src/execution/subagent-tool.js +0 -1
- package/dist/src/execution/tasks/child/instructions.d.ts +0 -3
- package/dist/src/execution/tasks/child/instructions.js +0 -1
- package/dist/src/execution/tasks/parent/agent-identity.d.ts +0 -13
- package/dist/src/execution/tasks/parent/agent-identity.js +0 -1
- package/dist/src/execution/tasks/parent/agent-views.d.ts +0 -7
- package/dist/src/execution/tasks/parent/agent-views.js +0 -1
- package/dist/src/execution/tasks/parent/continuation-dispatch.d.ts +0 -43
- package/dist/src/execution/tasks/parent/continuation-dispatch.js +0 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +0 -19
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +0 -1
- package/dist/src/execution/tool-run/answer.js +0 -1
- package/dist/src/execution/tool-run/background.d.ts +0 -14
- package/dist/src/execution/tool-run/background.js +0 -1
- package/dist/src/execution/tool-run/cancel.d.ts +0 -7
- package/dist/src/execution/tool-run/cancel.js +0 -1
- package/dist/src/execution/tool-run/dispatch.d.ts +0 -24
- package/dist/src/execution/tool-run/dispatch.js +0 -1
- package/dist/src/execution/tool-run/emit-run-report-step.d.ts +0 -7
- package/dist/src/execution/tool-run/emit-run-report-step.js +0 -1
- package/dist/src/execution/tool-run/messages.d.ts +0 -70
- package/dist/src/execution/tool-run/messages.js +0 -1
- package/dist/src/execution/tool-run/owner-inbox.d.ts +0 -11
- package/dist/src/execution/tool-run/owner-inbox.js +0 -1
- package/dist/src/execution/tool-run/owner.d.ts +0 -13
- package/dist/src/execution/tool-run/owner.js +0 -1
- package/dist/src/execution/tool-run/run-control.d.ts +0 -18
- package/dist/src/execution/tool-run/run-control.js +0 -1
- package/dist/src/execution/tool-run/start.d.ts +0 -11
- package/dist/src/execution/tool-run/start.js +0 -1
- package/dist/src/execution/tool-run/types.d.ts +0 -21
- package/dist/src/execution/tool-run/types.js +0 -1
- package/dist/src/execution/tool-run/workflow.d.ts +0 -9
- package/dist/src/execution/tool-run/workflow.js +0 -1
- package/dist/src/execution/tools/subagent/local.d.ts +0 -40
- package/dist/src/execution/tools/subagent/local.js +0 -1
- package/dist/src/execution/tools/subagent/remote.d.ts +0 -26
- package/dist/src/execution/tools/subagent/remote.js +0 -1
- package/dist/src/harness/agent-handle-errors.js +0 -1
- package/dist/src/harness/handles/query.js +0 -1
- package/dist/src/harness/handles/store.js +0 -1
- package/dist/src/harness/handles/transitions.d.ts +0 -167
- package/dist/src/harness/handles/transitions.js +0 -1
- package/dist/src/harness/runtime-actions.js +0 -1
- package/dist/src/harness/subagent-depth.d.ts +0 -10
- package/dist/src/harness/subagent-depth.js +0 -1
- package/dist/src/harness/tool-runs.d.ts +0 -21
- package/dist/src/harness/tool-runs.js +0 -1
- package/dist/src/harness/workflow-runtime-action-state.d.ts +0 -9
- package/dist/src/harness/workflow-runtime-action-state.js +0 -1
- package/dist/src/runtime/actions/keys.d.ts +0 -14
- package/dist/src/runtime/actions/keys.js +0 -1
- package/dist/src/tasks/wire.d.ts +0 -25
- package/dist/src/tasks/wire.js +0 -1
- /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.d.ts +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/owner-channels.js +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.d.ts +0 -0
- /package/dist/src/execution/{tool-run → tools/workflow}/resume-hook-step.js +0 -0
- /package/dist/src/{execution/subagent-adapter.d.ts → subagents/adapter.d.ts} +0 -0
- /package/dist/src/{execution/session-callback-route.d.ts → subagents/callback-route.d.ts} +0 -0
- /package/dist/src/{execution/session-callback-step.d.ts → subagents/callback-step.d.ts} +0 -0
- /package/dist/src/{harness → subagents}/handles/operation-id.d.ts +0 -0
- /package/dist/src/{harness → subagents}/handles/operation-id.js +0 -0
- /package/dist/src/{harness → subagents}/handles/state-key.d.ts +0 -0
- /package/dist/src/{harness → subagents}/handles/state-key.js +0 -0
- /package/dist/src/{execution/subagent-hitl-proxy.d.ts → subagents/hitl-proxy.d.ts} +0 -0
- /package/dist/src/{execution/subagent-hitl-proxy.js → subagents/hitl-proxy.js} +0 -0
- /package/dist/src/{execution/subagent-invocation.d.ts → subagents/invocation.d.ts} +0 -0
- /package/dist/src/{execution/subagent-invocation.js → subagents/invocation.js} +0 -0
- /package/dist/src/{execution/delegated-parent-result.d.ts → subagents/parent-result.d.ts} +0 -0
- /package/dist/src/{execution/remote-agent-route-url.d.ts → subagents/remote-route-url.d.ts} +0 -0
- /package/dist/src/{execution/remote-agent-route-url.js → subagents/remote-route-url.js} +0 -0
- /package/dist/src/{harness/subagent-token-budget.d.ts → subagents/token-budget.d.ts} +0 -0
- /package/dist/src/{harness/subagent-token-budget.js → subagents/token-budget.js} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SessionAuth, SessionParent } from "#context/session-context.js";
|
|
2
|
+
import type { RuntimeSession } from "#subagents/handle-dispatch.js";
|
|
3
|
+
import type { RuntimeToolResultActionResult, RuntimeWorkflowTaskRequest } from "#shared/action-types.js";
|
|
4
|
+
import type { WorkflowToolRunInput } from "#execution/tools/workflow/types.js";
|
|
5
|
+
export declare function deriveWorkflowToolRunHookToken(input: {
|
|
6
|
+
readonly callId: string;
|
|
7
|
+
readonly parentSessionId: string;
|
|
8
|
+
readonly parentTurnId: string;
|
|
9
|
+
}): string;
|
|
10
|
+
/** Resolves once the workflow tool run owns its hook. Call from a `"use step"` body. */
|
|
11
|
+
export declare function startWorkflowToolRun(input: Omit<WorkflowToolRunInput, "hookToken"> & {
|
|
12
|
+
readonly hookToken?: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
readonly hookToken: string;
|
|
15
|
+
readonly runId: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** Starts one durable workflow task and records it on the owning session. */
|
|
18
|
+
export declare function startWorkflowTask(input: {
|
|
19
|
+
readonly auth: SessionAuth["current"];
|
|
20
|
+
readonly batchEvent: {
|
|
21
|
+
readonly sequence: number;
|
|
22
|
+
readonly stepIndex: number;
|
|
23
|
+
readonly turnId: string;
|
|
24
|
+
};
|
|
25
|
+
readonly initiatorAuth: SessionAuth["initiator"];
|
|
26
|
+
readonly parentContinuationToken: string;
|
|
27
|
+
readonly parentSession: SessionParent | undefined;
|
|
28
|
+
readonly session: RuntimeSession;
|
|
29
|
+
readonly task: RuntimeWorkflowTaskRequest;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
readonly result?: RuntimeToolResultActionResult;
|
|
32
|
+
readonly session: RuntimeSession;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,waitForCommandHookOwner,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{recordWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{deriveWorkflowToolRunOwner}from"#execution/tools/workflow/messages.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);function deriveWorkflowToolRunHookToken(e){return`eve:workflow-tool-run:${deriveAgentOperationId(e)}`}async function startWorkflowToolRun(e){let t=e.hookToken??deriveWorkflowToolRunHookToken({callId:e.callId,parentSessionId:e.session.id,parentTurnId:e.session.turn.id});return await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}]),{hookToken:t,runId:(await waitForCommandHookOwner(t)).runId}}async function startWorkflowTask(e){let{task:n,batchEvent:r,session:i}=e;try{let t=await startWorkflowToolRun({callId:n.callId,executeInput:n.executeInput,input:n.input,owner:deriveWorkflowToolRunOwner(e.parentContinuationToken),resultKind:n.resultKind,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:i.sessionId,parent:e.parentSession,turn:{id:r.turnId,sequence:r.sequence}},stepIndex:r.stepIndex,toolName:n.toolName,workflowId:n.workflowId});return{session:recordWorkflowToolRun(i,{callId:n.callId,hookToken:t.hookToken,resultKind:n.resultKind??`tool`,runId:t.runId,toolName:n.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:n.callId,toolName:n.toolName}),{result:createRuntimeToolResultFromValue({callId:n.callId,isError:!0,output:toError(e),toolName:n.toolName}),session:i}}}export{deriveWorkflowToolRunHookToken,startWorkflowTask,startWorkflowToolRun};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SessionContext } from "#context/session-context.js";
|
|
2
|
+
import type { JsonObject, JsonValue } from "#shared/json.js";
|
|
3
|
+
import type { TaskExecutorBinding } from "#tools/task.js";
|
|
4
|
+
import type { WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js";
|
|
5
|
+
export type WorkflowToolRunSessionContext = SessionContext["session"];
|
|
6
|
+
export declare const WORKFLOW_TOOL_EXECUTOR_KIND = "workflow-tool";
|
|
7
|
+
/** Private task executor binding for the workflow tool run doing the task's work. */
|
|
8
|
+
export declare function createWorkflowToolExecutorBinding(input: WorkflowToolRunAddress): TaskExecutorBinding;
|
|
9
|
+
export declare function readWorkflowToolExecutorAddress(executor: TaskExecutorBinding | undefined): WorkflowToolRunAddress | undefined;
|
|
10
|
+
export interface WorkflowToolRunInput {
|
|
11
|
+
readonly callId: string;
|
|
12
|
+
readonly execution?: "background" | "blocking";
|
|
13
|
+
readonly executeInput?: JsonValue;
|
|
14
|
+
readonly hookToken: string;
|
|
15
|
+
readonly input: JsonObject;
|
|
16
|
+
readonly owner: WorkflowToolRunOwner;
|
|
17
|
+
readonly resultKind?: "subagent" | "tool";
|
|
18
|
+
readonly session: WorkflowToolRunSessionContext;
|
|
19
|
+
readonly stepIndex: number;
|
|
20
|
+
readonly toolName: string;
|
|
21
|
+
readonly workflowId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkflowToolRunAddress {
|
|
24
|
+
readonly hookToken: string;
|
|
25
|
+
readonly runId: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const WORKFLOW_TOOL_EXECUTOR_KIND=`workflow-tool`;function createWorkflowToolExecutorBinding(t){return{data:{hookToken:t.hookToken,runId:t.runId},kind:WORKFLOW_TOOL_EXECUTOR_KIND}}function readWorkflowToolExecutorAddress(e){if(e?.kind!==`workflow-tool`)return;let t=e.data.hookToken,n=e.data.runId;return typeof t==`string`&&typeof n==`string`?{hookToken:t,runId:n}:void 0}export{WORKFLOW_TOOL_EXECUTOR_KIND,createWorkflowToolExecutorBinding,readWorkflowToolExecutorAddress};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sleep}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{createWorkflowBodyRef,executeWorkflowBody}from"#execution/tools/workflow/body.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{openWorkflowToolRunControlInbox}from"#execution/tools/workflow/run-control.js";async function workflowToolRunWorkflow(i){"use workflow";let a=openWorkflowToolRunControlInbox(i.hookToken),o=!1;try{try{await claimHookOwnership(a.hook),o=!0}catch(e){if(isHookConflictError(e))return;throw e}let n={...i,execution:i.execution??`blocking`},r=createWorkflowBodyRef(n),s=executeWorkflowBody(n,a.signal).then(e=>{if(e.status===`completed`)return e.output;throw e.status===`failed`?e.error:a.signal.reason??Error(e.reason??`Workflow tool run cancelled.`)}),c=s.catch(()=>{}),l;try{l={output:await Promise.race([s,a.cancelled]),status:`completed`}}catch(t){a.signal.aborted?(await Promise.race([c,sleep(`30s`)]),l={reason:a.reason(),status:`cancelled`}):l={error:normalizeSerializableError(t),status:`failed`}}let u={from:r,result:l};await resumeHookStep(i.owner.outcome,u,{ifPresent:l.status===`cancelled`})}finally{o&&await disposeHook(a.hook)}}export{workflowToolRunWorkflow};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WorkflowToolRunOutcomeMessage, WorkflowToolRunRequestMessage } from "#execution/tools/workflow/messages.js";
|
|
2
|
+
import type { TurnExecutionCursor } from "#execution/turn-execution-cursor.js";
|
|
3
|
+
import type { RuntimeActionResult } from "#shared/action-types.js";
|
|
4
|
+
interface HandlerInput<T> {
|
|
5
|
+
readonly callbackMetadataUrl: string;
|
|
6
|
+
readonly cursor: TurnExecutionCursor;
|
|
7
|
+
readonly message: T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Settles a workflow tool run outcome against the turn's recorded runs and
|
|
11
|
+
* returns the runtime action result the turn should accept, or `undefined`
|
|
12
|
+
* when the outcome does not bind to a run this turn owns.
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleWorkflowToolRunOutcome(input: HandlerInput<WorkflowToolRunOutcomeMessage>): Promise<RuntimeActionResult | undefined>;
|
|
15
|
+
export declare function handleWorkflowToolRunRequest(input: HandlerInput<WorkflowToolRunRequestMessage>): Promise<void>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{findWorkflowToolRun,isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{cancelAgentInvocationOwnerStep}from"#execution/tools/subagent/task-cancel.js";import{runProxySubagentEventStep}from"#subagents/event-proxy-step.js";import{applyTaskAgentRequest}from"#execution/tools/subagent/task-agent-requests.js";import{workflowToolRunOutcomeToSubagentResult,workflowToolRunOutcomeToToolResult,workflowToolRunRequestToInputRequestPayload}from"#execution/tools/workflow/owner-inbox.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{releaseAgentInvocationOwnerStep}from"#execution/tools/subagent/invoke-step.js";async function handleWorkflowToolRunOutcome(i){let{cursor:a,message:o}=i,s=findWorkflowToolRun(a.sessionState.snapshot?.session.state,o.from.callId);if(s?.runId!==o.from.runId)return;let c=s.resultKind===`subagent`?await settleSubagentOutcome(i):workflowToolRunOutcomeToToolResult(o);await cancelAgentInvocationOwnerStep({ownerId:o.from.runId,serializedContext:a.serializedContext,sessionState:a.sessionState});let l=await releaseAgentInvocationOwnerStep({cancelled:o.result.status===`cancelled`,ownerId:o.from.runId,sessionState:a.sessionState});await a.adopt({serializedContext:a.serializedContext,sessionState:l.sessionState});let u=a.sessionState.snapshot?.session.state;return(c.kind===`subagent-result`?c.callId===o.from.callId&&isInboxSubagentResultFromRecordedWorkflowToolRun(u,c):isInboxToolResultFromRecordedWorkflowToolRun(u,c))?c:void 0}async function settleSubagentOutcome(e){let{cursor:t,message:n}=e,r=workflowToolRunOutcomeToSubagentResult(n);return r.origin===`child`&&await t.adopt(await applyTaskAgentRequest({accumulateUsage:!1,ownerId:n.from.runId,replyTo:n.from.runId,request:{kind:`agent-settled`,result:r}},requestContext(e))),r}async function handleWorkflowToolRunRequest(t){let{cursor:n,message:r}=t;if(r.request.kind===`agent-invoke`||r.request.kind===`agent-settled`){if(findWorkflowToolRun(n.sessionState.snapshot?.session.state,r.from.callId)?.runId!==r.from.runId){r.request.kind===`agent-invoke`&&await resumeHookStep(r.replyTo,{kind:`runtime-action-result`,results:[{callId:r.request.invocationId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:`AGENT_INVOCATION_NOT_ADMITTED`,message:`The workflow tool run no longer owns this agent invocation.`},subagentName:r.request.input.target}]});return}await n.adopt(await applyTaskAgentRequest({accumulateUsage:r.from.resultKind!==`subagent`,ownerId:r.from.runId,replyTo:r.replyTo,request:r.request},requestContext(t)));return}if(r.request.kind===`authorization-request`){await n.adopt(await runProxySubagentEventStep({hookPayload:r.request.event,parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}));return}await n.adopt(await runProxySubagentEventStep({...r.requestCoordinates===void 0?{answerHook:{runId:r.from.runId}}:{},hookPayload:workflowToolRunRequestToInputRequestPayload(r),parentWritable:n.parentWritable,serializedContext:n.serializedContext,sessionState:n.sessionState}))}function requestContext(e){return{callbackBaseUrl:resolveWorkflowCallbackBaseUrl(e.callbackMetadataUrl),parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}}export{handleWorkflowToolRunOutcome,handleWorkflowToolRunRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHook,getWorkflowMetadata,sleep}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{isInboxToolResultFromRecordedRun}from"#harness/tool-runs.js";import{activeTurnId}from"#harness/active-turn-id.js";import{migrateTurnWorkflowInput}from"#execution/durable-session-migrations/turn-workflow.js";import{dispatchRuntimeActionsStep}from"#execution/dispatch-runtime-actions-step.js";import{dispatchTaskStep}from"#execution/tasks/parent/dispatch-task-step.js";import{turnStep}from"#execution/workflow-steps.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{getRuntimeActionResultKey}from"#runtime/actions/keys.js";import{runProxySubagentEventStep}from"#execution/subagent-event-proxy-step.js";import{createChannelReader,raceChannelReads}from"#execution/tool-run/owner-channels.js";import{openRunOwnerChannels}from"#execution/tool-run/owner.js";import{runOutcomeToToolResult,runRequestToInputRequestPayload}from"#execution/tool-run/owner-inbox.js";import{acknowledgeDelegatedTasksStep}from"#execution/tasks/parent/delegate.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{sendTurnControlStep}from"#execution/turn-control-protocol.js";import{isInboxSubagentResultFromRunningHandle}from"#harness/handles/query.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{dispatchWorkflowRuntimeActionsStep}from"#execution/dispatch-workflow-runtime-actions-step.js";import{emitRunReportStep}from"#execution/tool-run/emit-run-report-step.js";import{createTurnCancellationControl}from"#execution/turn-cancellation-control.js";import{TurnExecutionCursor}from"#execution/turn-execution-cursor.js";import{resolveRuntimeActionResultsForKeys}from"#runtime/actions/results.js";const TASK_MODE_WAIT_ERROR_MESSAGE="Task mode cannot wait for follow-up input (`next: null`).";async function turnWorkflow(e){"use workflow";let t=migrateTurnWorkflowInput(e);return t.driverCapabilities?.turnInbox===!0?runTurnOwnedWorkflow(t):runLegacyTurnWorkflow(t)}async function runTurnOwnedWorkflow(n){let s=createHook({token:`${n.completionToken}:inbox`}),l=createChannelReader(`inbox`,s),d=n.initialStep,f=new TurnExecutionCursor({controlToken:n.completionToken,parentWritable:n.stepInput.parentWritable,serializedContext:d?.beforeStep.serializedContext??n.stepInput.serializedContext,sessionState:d?.beforeStep.sessionState??n.stepInput.sessionState}),p=0,nextDeliveryRequestId=()=>`${s.token}:delivery:${String(p++)}`,m=[],h=n.stepInput.input,g=!1,_,v;try{try{await claimHookOwnership(s),g=!0}catch(e){if(isHookConflictError(e))return;throw e}for(n.driverCapabilities?.cancelledTurnSettle===!0&&(v=await createTurnCancellationControl({controlToken:n.completionToken,expectedTurnId:activeTurnId(f.sessionState.emissionState),initialPayload:n.initialCancellation}));;){let e=d?.beforeStep??{serializedContext:f.serializedContext,sessionState:f.sessionState},r=d?.result??await turnStep(f.createStepInput(h,v?.signal));d=void 0;let i=r.action===`dispatch-workflow-runtime-actions`||r.action===`park`?r.pendingRuntimeActionKeys:void 0,a=(r.backgroundTasks?.length??0)>0;if(a){if(r.backgroundTaskState===void 0)throw Error(`Background tasks were returned without their committed session state.`);await f.adopt({serializedContext:e.serializedContext,sessionState:r.backgroundTaskState}),await acknowledgeDelegatedTasksStep({tasks:r.backgroundTasks??[]})}if(r.action===`cancelled`){await f.adopt({serializedContext:r.serializedContext,sessionState:r.backgroundTaskState??r.sessionState}),await finishCancelledTurn({bufferedDeliveries:m,cancellation:v,cursor:f});return}if(v?.signal.aborted===!0&&(i===void 0||a)){await f.adopt({serializedContext:preserveSerializedSessionDynamicModelSelection(e.serializedContext,r.serializedContext),sessionState:f.sessionState}),await finishCancelledTurn({bufferedDeliveries:m,cancellation:v,cursor:f});return}if(r.sleepDurationMs!==void 0&&await waitForTurnSleep(r.sleepDurationMs,v)===`cancel`){await finishCancelledTurn({bufferedDeliveries:m,cancellation:v,cursor:f});return}if(r.action===`done`){await v?.dispose(),await f.finish(r,{kind:`done`,output:r.output??``,isError:r.isError,usage:r.usage,usageDelta:r.usageDelta},m);return}if(i!==void 0){await f.adopt(r),r.action===`park`&&r.startsWorkflowToolRuns===!0&&(_??=openRunOwnerChannels(s.token));let e=r.action===`park`&&r.tasksEnabled,n;n=r.action===`dispatch-workflow-runtime-actions`?dispatchWorkflowRuntimeActionsStep:e?dispatchTaskStep:dispatchRuntimeActionsStep;let a=await n({callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url),parentContinuationToken:s.token,parentWritable:f.parentWritable,serializedContext:f.serializedContext,sessionState:f.sessionState}),c=a.results.length===0?void 0:Date.now();await f.adopt(a),await acknowledgeDelegatedTasksStep({tasks:a.pendingTasks});let u=await waitForRuntimeActionResults({bufferedDeliveries:m,cancellation:v,cursor:f,inboxToken:s.token,initialAcceptedAtMs:c,initialResults:a.results,nextDeliveryRequestId,readers:_===void 0?[l]:[..._.readers,l],pendingActionKeys:i});if(u===`cancelled`){h=void 0;continue}if(u===`cancel-turn`){await finishCancelledTurn({bufferedDeliveries:m,cancellation:v,cursor:f});return}h={kind:`runtime-action-result`,...u};continue}if(r.action===`park`){if(!(r.hasPendingAuthorization||r.hasPendingInputBatch&&n.capabilities?.requestInput===!0||n.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);await v?.dispose(),await f.finish(r,{authorizationAttemptIds:r.authorizationAttemptIds,authorizationNames:r.authorizationNames,kind:`park`,settled:r.settled},m);return}await f.adopt(r),h=void 0}}catch(e){throw await f.send({error:normalizeSerializableError(e),kind:`turn-error`}),e}finally{v!==void 0&&await v.dispose(),_!==void 0&&await _.dispose(),g&&await disposeHook(s)}}async function finishCancelledTurn(e){await cancelDescendantTurnsStep({serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}),await e.cancellation?.dispose(),await e.cursor.finish({sessionState:e.cursor.sessionState},{cancelled:!0,kind:`park`},e.bufferedDeliveries)}async function waitForTurnSleep(e,t){if(t?.signal.aborted===!0)return`cancel`;let r=sleep(e).then(()=>`slept`);return t===void 0?r:Promise.race([r,t.requested])}async function waitForRuntimeActionResults(e){let t,n=[...e.initialResults],r=new Map;if(e.initialAcceptedAtMs!==void 0)for(let t of e.initialResults)r.set(getRuntimeActionResultKey(t),e.initialAcceptedAtMs);for(;;){let i=resolveRuntimeActionResultsForKeys({pendingKeys:e.pendingActionKeys,results:n});if(i!==void 0)return t!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:t}),{acceptedAtMsByCallId:Object.fromEntries(i.map(e=>[e.callId,r.get(getRuntimeActionResultKey(e))])),results:i};e.cursor.sessionState.hasProxyInputRequests&&t===void 0&&(t=e.nextDeliveryRequestId(),await e.cursor.send({continuationToken:e.cursor.sessionState.continuationToken,inboxToken:e.inboxToken,kind:`turn-delivery-request`,requestId:t}));let a=await raceChannelReads(e.readers,e.cancellation?.requested);if(a===`cancel`)return t!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:t}),`cancelled`;if(a.next.done)throw Error(`Turn inbox closed before runtime actions completed.`);if(a.channel===`outcome`){let t=runOutcomeToToolResult(a.next.value),i=e.cursor.sessionState.snapshot?.session.state;if(isInboxToolResultFromRecordedRun(i,t)){let e=Date.now();n.push(t),r.set(getRuntimeActionResultKey(t),e)}continue}if(a.channel===`request`){let t=await runProxySubagentEventStep({answerHook:{runId:a.next.value.from.runId},hookPayload:runRequestToInputRequestPayload(a.next.value),parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});await e.cursor.adopt(t);continue}if(a.channel===`report`){await emitRunReportStep({from:a.next.value.from,parentWritable:e.cursor.parentWritable,update:a.next.value.update});continue}let o=a.next.value;if(o.kind===`runtime-action-result`){let t=e.cursor.sessionState.snapshot?.session.state,i=o.results.filter(e=>e.kind===`tool-result`?isInboxToolResultFromRecordedRun(t,e):isInboxSubagentResultFromRunningHandle(t,e));if(i.length>0){let e=Date.now();n.push(...i);for(let t of i)r.set(getRuntimeActionResultKey(t),e)}continue}if(o.kind===`subagent-input-request`||o.kind===`subagent-authorization-event`){let t=await runProxySubagentEventStep({hookPayload:o,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});await e.cursor.adopt(t);continue}if(o.kind===`driver-delivery`&&o.requestId===t){await e.cursor.send({kind:`turn-delivery-accepted`,requestId:o.requestId}),t=void 0;let n=await routeDeliverToChildren({delivery:o.delivery,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});if(await e.cursor.adopt({serializedContext:n.serializedContext??e.cursor.serializedContext,sessionState:n.sessionState??e.cursor.sessionState}),n.kind===`cancel-turn`)return n.kind;n.remainder!==void 0&&e.bufferedDeliveries.push(n.remainder)}}}async function runLegacyTurnWorkflow(e){let t=e.stepInput;try{for(;;){let r=await turnStep(t);if(r.action!==`cancelled`&&r.sleepDurationMs!==void 0&&await sleep(r.sleepDurationMs),r.action===`done`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`done`,output:r.output??``,isError:r.isError,serializedContext:r.serializedContext,sessionState:r.sessionState,usage:r.usage,usageDelta:r.usageDelta},kind:`turn-result`}});return}if(r.action===`dispatch-workflow-runtime-actions`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`dispatch-workflow-runtime-actions`,pendingActionKeys:r.pendingRuntimeActionKeys,serializedContext:r.serializedContext,sessionState:r.sessionState},kind:`turn-result`}});return}if(r.action===`park`){let t=r.pendingRuntimeActionKeys;if(!(t!==void 0||r.hasPendingAuthorization||r.hasPendingInputBatch&&e.capabilities?.requestInput===!0||e.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);let n=t===void 0?{kind:`park`,serializedContext:r.serializedContext,sessionState:r.sessionState,authorizationAttemptIds:r.authorizationAttemptIds,authorizationNames:r.authorizationNames,settled:r.settled}:{kind:`dispatch-runtime-actions`,pendingActionKeys:t,serializedContext:r.serializedContext,sessionState:r.sessionState};await sendTurnControlStep({controlToken:e.completionToken,payload:{action:n,kind:`turn-result`}});return}t={input:void 0,parentWritable:t.parentWritable,serializedContext:r.serializedContext,sessionState:r.sessionState}}}catch(t){throw await sendTurnControlStep({controlToken:e.completionToken,payload:{error:normalizeSerializableError(t),kind:`turn-error`}}),t}}export{turnWorkflow};
|
|
1
|
+
import{createHook,getWorkflowMetadata,sleep}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{isInboxSubagentResultFromRecordedWorkflowToolRun,isInboxToolResultFromRecordedWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{activeTurnId}from"#harness/active-turn-id.js";import{migrateTurnWorkflowInput}from"#execution/durable-session-migrations/turn-workflow.js";import{turnStep}from"#execution/workflow-steps.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{runProxySubagentEventStep}from"#subagents/event-proxy-step.js";import{createChannelReader,raceChannelReads}from"#execution/tools/workflow/owner-channels.js";import{openWorkflowToolRunOwnerChannels}from"#execution/tools/workflow/owner.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{acknowledgeDelegatedTasksStep}from"#execution/tasks/parent/delegate.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{sendTurnControlStep}from"#execution/turn-control-protocol.js";import{findRunningAgentHandle,isInboxSubagentResultFromRunningHandle}from"#subagents/handles/query.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{dispatchCoordinationStep}from"#execution/coordination-dispatch-step.js";import{emitWorkflowToolRunReportStep}from"#execution/tools/workflow/emit-workflow-tool-run-report-step.js";import{createTurnCancellationControl}from"#execution/turn-cancellation-control.js";import{TurnExecutionCursor}from"#execution/turn-execution-cursor.js";import{resolveRuntimeActionResultsForCallIds}from"#runtime/actions/results.js";import{handleWorkflowToolRunOutcome,handleWorkflowToolRunRequest}from"#execution/turn-workflow-tool-run.js";const TASK_MODE_WAIT_ERROR_MESSAGE="Task mode cannot wait for follow-up input (`next: null`).";async function turnWorkflow(e){"use workflow";let t=migrateTurnWorkflowInput(e);return t.driverCapabilities?.turnInbox===!0?runTurnOwnedWorkflow(t):runLegacyTurnWorkflow(t)}async function runTurnOwnedWorkflow(n){let o=createHook({token:`${n.completionToken}:inbox`}),s=createChannelReader(`inbox`,o),l=n.initialStep,u=new TurnExecutionCursor({controlToken:n.completionToken,parentWritable:n.stepInput.parentWritable,serializedContext:l?.beforeStep.serializedContext??n.stepInput.serializedContext,sessionState:l?.beforeStep.sessionState??n.stepInput.sessionState}),d=0,nextDeliveryRequestId=()=>`${o.token}:delivery:${String(d++)}`,f=[],p=n.stepInput.input,m=!1,h,g;try{try{await claimHookOwnership(o),m=!0}catch(e){if(isHookConflictError(e))return;throw e}h=openWorkflowToolRunOwnerChannels(o.token);let e=[...h.readers,s];for(n.driverCapabilities?.cancelledTurnSettle===!0&&(g=await createTurnCancellationControl({controlToken:n.completionToken,expectedTurnId:activeTurnId(u.sessionState.emissionState),initialPayload:n.initialCancellation}));;){let r=l?.beforeStep??{serializedContext:u.serializedContext,sessionState:u.sessionState},i=l?.result??await turnStep(u.createStepInput(p,g?.signal));l=void 0;let a=i.action===`dispatch-workflow-tasks`?i.pendingTaskCallIds:i.action===`park`?i.pendingCoordinationCallIds:void 0,s=(i.backgroundTasks?.length??0)>0;if(s){if(i.backgroundTaskState===void 0)throw Error(`Background tasks were returned without their committed session state.`);await u.adopt({serializedContext:r.serializedContext,sessionState:i.backgroundTaskState}),await acknowledgeDelegatedTasksStep({tasks:i.backgroundTasks??[]})}if(i.action===`cancelled`){await u.adopt({serializedContext:i.serializedContext,sessionState:i.backgroundTaskState??i.sessionState}),await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}if(g?.signal.aborted===!0&&(a===void 0||s)){await u.adopt({serializedContext:preserveSerializedSessionDynamicModelSelection(r.serializedContext,i.serializedContext),sessionState:u.sessionState}),await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}if(i.sleepDurationMs!==void 0&&await waitForTurnSleep(i.sleepDurationMs,g)===`cancel`){await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}if(i.action===`done`){await g?.dispose(),await u.finish(i,{kind:`done`,output:i.output??``,isError:i.isError,usage:i.usage,usageDelta:i.usageDelta},f);return}if(a!==void 0&&(i.action===`park`||i.action===`dispatch-workflow-tasks`)){await u.adopt(i);let n=await dispatchCoordinationStep({action:i.action,callbackBaseUrl:resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url),parentContinuationToken:o.token,parentWritable:u.parentWritable,serializedContext:u.serializedContext,sessionState:u.sessionState}),r=n.results.length===0?void 0:Date.now();await u.adopt(n),await acknowledgeDelegatedTasksStep({tasks:n.pendingTasks});let s=await waitForRuntimeActionResults({bufferedDeliveries:f,cancellation:g,cursor:u,inboxToken:o.token,initialAcceptedAtMs:r,initialResults:n.results,nextDeliveryRequestId,readers:e,pendingCallIds:a});if(s===`cancelled`){p=void 0;continue}if(s===`cancel-turn`){await finishCancelledTurn({bufferedDeliveries:f,cancellation:g,cursor:u});return}p={kind:`runtime-action-result`,...s};continue}if(i.action===`park`){if(!(i.hasPendingAuthorization||i.hasPendingInputBatch&&n.capabilities?.requestInput===!0||n.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);await g?.dispose(),await u.finish(i,{authorizationAttemptIds:i.authorizationAttemptIds,authorizationNames:i.authorizationNames,kind:`park`,settled:i.settled},f);return}await u.adopt(i),p=void 0}}catch(e){throw await u.send({error:normalizeSerializableError(e),kind:`turn-error`}),e}finally{g!==void 0&&await g.dispose(),h!==void 0&&await h.dispose(),m&&await disposeHook(o)}}async function finishCancelledTurn(e){await cancelDescendantTurnsStep({serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState}),await e.cancellation?.dispose(),await e.cursor.finish({sessionState:e.cursor.sessionState},{cancelled:!0,kind:`park`},e.bufferedDeliveries)}async function waitForTurnSleep(e,t){if(t?.signal.aborted===!0)return`cancel`;let r=sleep(e).then(()=>`slept`);return t===void 0?r:Promise.race([r,t.requested])}async function waitForRuntimeActionResults(e){let n,r=[...e.initialResults],i=new Map;if(e.initialAcceptedAtMs!==void 0)for(let t of e.initialResults)i.set(t.callId,e.initialAcceptedAtMs);for(;;){let a=resolveRuntimeActionResultsForCallIds({pendingCallIds:e.pendingCallIds,results:r});if(a!==void 0)return n!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:n}),{acceptedAtMsByCallId:Object.fromEntries(a.map(e=>[e.callId,i.get(e.callId)])),results:a};e.cursor.sessionState.hasProxyInputRequests&&n===void 0&&(n=e.nextDeliveryRequestId(),await e.cursor.send({continuationToken:e.cursor.sessionState.continuationToken,inboxToken:e.inboxToken,kind:`turn-delivery-request`,requestId:n}));let c=await raceChannelReads(e.readers,e.cancellation?.requested);if(c===`cancel`)return n!==void 0&&await e.cursor.send({kind:`turn-delivery-cancelled`,requestId:n}),`cancelled`;if(c.next.done)throw Error(`Turn inbox closed before runtime actions completed.`);if(c.channel===`outcome`){let n=await handleWorkflowToolRunOutcome({callbackMetadataUrl:getWorkflowMetadata().url,cursor:e.cursor,message:c.next.value});n!==void 0&&(r.push(n),i.set(n.callId,Date.now()));continue}if(c.channel===`request`){await handleWorkflowToolRunRequest({callbackMetadataUrl:getWorkflowMetadata().url,cursor:e.cursor,message:c.next.value});continue}if(c.channel===`report`){await emitWorkflowToolRunReportStep({from:c.next.value.from,parentWritable:e.cursor.parentWritable,update:c.next.value.update});continue}let l=c.next.value;if(l.kind===`runtime-action-result`){let t=e.cursor.sessionState.snapshot?.session.state,n=l.results.filter(e=>e.kind===`tool-result`?isInboxToolResultFromRecordedWorkflowToolRun(t,e):e.origin===`child`&&isInboxSubagentResultFromRunningHandle(t,e)||isInboxSubagentResultFromRecordedWorkflowToolRun(t,e));if(n.length>0){let e=Date.now();r.push(...n);for(let t of n)i.set(t.callId,e)}continue}if(l.kind===`subagent-input-request`||l.kind===`subagent-authorization-event`){let t=findRunningAgentHandle(e.cursor.sessionState.snapshot?.session.state,{callId:l.callId});if(t?.identity.name!==l.subagentName||t.address.sessionId!==l.childSessionId)continue;let n=await runProxySubagentEventStep({hookPayload:l,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});await e.cursor.adopt(n);continue}if(l.kind===`driver-delivery`&&l.requestId===n){await e.cursor.send({kind:`turn-delivery-accepted`,requestId:l.requestId}),n=void 0;let t=await routeDeliverToChildren({delivery:l.delivery,parentWritable:e.cursor.parentWritable,serializedContext:e.cursor.serializedContext,sessionState:e.cursor.sessionState});if(await e.cursor.adopt({serializedContext:t.serializedContext??e.cursor.serializedContext,sessionState:t.sessionState??e.cursor.sessionState}),t.kind===`cancel-turn`)return t.kind;t.remainder!==void 0&&e.bufferedDeliveries.push(t.remainder)}}}async function runLegacyTurnWorkflow(e){let t=e.stepInput;try{for(;;){let r=await turnStep(t);if(r.action!==`cancelled`&&r.sleepDurationMs!==void 0&&await sleep(r.sleepDurationMs),r.action===`done`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`done`,output:r.output??``,isError:r.isError,serializedContext:r.serializedContext,sessionState:r.sessionState,usage:r.usage,usageDelta:r.usageDelta},kind:`turn-result`}});return}if(r.action===`dispatch-workflow-tasks`){await sendTurnControlStep({controlToken:e.completionToken,payload:{action:{kind:`dispatch-workflow-tasks`,pendingCallIds:r.pendingTaskCallIds,serializedContext:r.serializedContext,sessionState:r.sessionState},kind:`turn-result`}});return}if(r.action===`park`){let t=r.pendingCoordinationCallIds;if(!(t!==void 0||r.hasPendingAuthorization||r.hasPendingInputBatch&&e.capabilities?.requestInput===!0||e.mode===`conversation`))throw Error(TASK_MODE_WAIT_ERROR_MESSAGE);let n=t===void 0?{kind:`park`,serializedContext:r.serializedContext,sessionState:r.sessionState,authorizationAttemptIds:r.authorizationAttemptIds,authorizationNames:r.authorizationNames,settled:r.settled}:{kind:`dispatch-coordination`,pendingCallIds:t,serializedContext:r.serializedContext,sessionState:r.sessionState};await sendTurnControlStep({controlToken:e.completionToken,payload:{action:n,kind:`turn-result`}});return}t={input:void 0,parentWritable:t.parentWritable,serializedContext:r.serializedContext,sessionState:r.sessionState}}}catch(t){throw await sendTurnControlStep({controlToken:e.completionToken,payload:{error:normalizeSerializableError(t),kind:`turn-error`}}),t}}export{turnWorkflow};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Every explicit session-inbox wire version still supported by producers. */
|
|
2
|
-
export declare const SESSION_INBOX_WIRE_VERSIONS: readonly [1, 2, 3];
|
|
2
|
+
export declare const SESSION_INBOX_WIRE_VERSIONS: readonly [1, 2, 3, 4];
|
|
3
3
|
export type SessionInboxWireVersion = (typeof SESSION_INBOX_WIRE_VERSIONS)[number];
|
|
4
4
|
/** Current persisted session-inbox wire version. */
|
|
5
|
-
export declare const SESSION_INBOX_WIRE_VERSION: 1 | 2 | 3;
|
|
5
|
+
export declare const SESSION_INBOX_WIRE_VERSION: 1 | 2 | 3 | 4;
|
|
6
6
|
/** Hook metadata field advertising the consumer's inbox wire capability. */
|
|
7
7
|
export declare const SESSION_INBOX_WIRE_VERSION_METADATA_KEY = "sessionInboxWireVersion";
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const SESSION_INBOX_WIRE_VERSIONS=[1,2,3],SESSION_INBOX_WIRE_VERSION=SESSION_INBOX_WIRE_VERSIONS[SESSION_INBOX_WIRE_VERSIONS.length-1],SESSION_INBOX_WIRE_VERSION_METADATA_KEY=`sessionInboxWireVersion`;function isSessionInboxWireVersion(t){return SESSION_INBOX_WIRE_VERSIONS.some(e=>e===t)}var SessionInboxWireError=class extends Error{constructor(e){super(e),this.name=`SessionInboxWireError`}};export{SESSION_INBOX_WIRE_VERSION,SESSION_INBOX_WIRE_VERSIONS,SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion};
|
|
1
|
+
const SESSION_INBOX_WIRE_VERSIONS=[1,2,3,4],SESSION_INBOX_WIRE_VERSION=SESSION_INBOX_WIRE_VERSIONS[SESSION_INBOX_WIRE_VERSIONS.length-1],SESSION_INBOX_WIRE_VERSION_METADATA_KEY=`sessionInboxWireVersion`;function isSessionInboxWireVersion(t){return SESSION_INBOX_WIRE_VERSIONS.some(e=>e===t)}var SessionInboxWireError=class extends Error{constructor(e){super(e),this.name=`SessionInboxWireError`}};export{SESSION_INBOX_WIRE_VERSION,SESSION_INBOX_WIRE_VERSIONS,SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion};
|
|
@@ -3,9 +3,10 @@ import { type SessionInboxWireV1 } from "#execution/wire/session-inbox-wire.v1.j
|
|
|
3
3
|
import { type SessionInboxWireV2 } from "#execution/wire/session-inbox-wire.v2.js";
|
|
4
4
|
import { type SessionInboxWireV3 } from "#execution/wire/session-inbox-wire.v3.js";
|
|
5
5
|
import { type SessionInboxWireTarget, type SessionInboxWireVersion } from "#execution/wire/session-inbox-contract.js";
|
|
6
|
+
import { type SessionInboxWireV4 } from "#execution/wire/session-inbox-wire.v4.js";
|
|
6
7
|
type SessionInboxCommand = DeliverHookPayload | SessionCommand | SessionTimeoutHookPayload;
|
|
7
8
|
/** Current wire type consumed after migration. */
|
|
8
|
-
export type SessionInboxWire =
|
|
9
|
+
export type SessionInboxWire = SessionInboxWireV4;
|
|
9
10
|
type LegacySessionInboxWireTarget = Extract<SessionInboxWireTarget, {
|
|
10
11
|
readonly version: 0;
|
|
11
12
|
}>;
|
|
@@ -19,11 +20,14 @@ declare function encode(command: SessionInboxCommand, target: {
|
|
|
19
20
|
declare function encode(command: SessionInboxCommand, target: {
|
|
20
21
|
readonly version: 3;
|
|
21
22
|
}): SessionInboxWireV3;
|
|
23
|
+
declare function encode(command: SessionInboxCommand, target: {
|
|
24
|
+
readonly version: 4;
|
|
25
|
+
}): SessionInboxWireV4;
|
|
22
26
|
declare function encode(command: SessionInboxCommand, target: {
|
|
23
27
|
readonly version: SessionInboxWireVersion;
|
|
24
28
|
}): unknown;
|
|
25
29
|
declare function encode(command: SessionInboxCommand, target: LegacySessionInboxWireTarget): Record<string, unknown>;
|
|
26
|
-
declare function encode(command: SessionInboxCommand, target: SessionInboxWireTarget): SessionInboxWireV1 | SessionInboxWireV2 | SessionInboxWireV3 | Record<string, unknown>;
|
|
30
|
+
declare function encode(command: SessionInboxCommand, target: SessionInboxWireTarget): SessionInboxWireV1 | SessionInboxWireV2 | SessionInboxWireV3 | SessionInboxWireV4 | Record<string, unknown>;
|
|
27
31
|
/** Server/step-safe producer facade. */
|
|
28
32
|
export declare const sessionInboxWire: {
|
|
29
33
|
readonly encode: typeof encode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{encodeSessionCommandV1}from"#execution/wire/session-inbox-wire.v1.js";import{encodeSessionCommandV2}from"#execution/wire/session-inbox-wire.v2.js";import{encodeSessionCommandV3}from"#execution/wire/session-inbox-wire.v3.js";import{encodeSessionCommandV0}from"#execution/wire/session-inbox-wire.v0.js";const versionedEncoders={1:e=>encodeSessionCommandV1(withoutAcceptedDeployment(e)),2:e=>encodeSessionCommandV2(withoutAcceptedDeployment(e)),3:encodeSessionCommandV3};function encode(r,i){if(i.version===0){let e=encodeSessionCommandV0(encodeSessionCommandV1(withoutAcceptedDeployment(r)),i.variant)
|
|
1
|
+
import{SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{encodeSessionCommandV1}from"#execution/wire/session-inbox-wire.v1.js";import{encodeSessionCommandV2}from"#execution/wire/session-inbox-wire.v2.js";import{encodeSessionCommandV3}from"#execution/wire/session-inbox-wire.v3.js";import{encodeSessionCommandV0}from"#execution/wire/session-inbox-wire.v0.js";import{encodeSessionCommandV4}from"#execution/wire/session-inbox-wire.v4.js";const versionedEncoders={1:e=>encodeSessionCommandV1(withoutAcceptedDeployment(e)),2:e=>encodeSessionCommandV2(withoutAcceptedDeployment(e)),3:encodeSessionCommandV3,4:encodeSessionCommandV4};function encode(r,i){if(i.version===0){let e=i.variant===`send`&&r.kind===`send`&&r.payload.task!==void 0?encodeSessionCommandV4(r):void 0,t=encodeSessionCommandV0(encodeSessionCommandV1(withoutCurrentTaskMessages(withoutAcceptedDeployment(r))),i.variant);e?.kind===`deliver`&&(t={...t,payload:e.payload});let a=t,o=a.delivery,s=readAcceptedDeploymentId(r);return i.variant!==`send`||s===void 0||a.kind!==`send`||typeof o!=`object`||!o?t:{...t,delivery:{...o,acceptedDeploymentId:s}}}if(isSessionInboxWireVersion(i.version))return versionedEncoders[i.version](r);throw new SessionInboxWireError(`Cannot encode session inbox payload for unknown wire version ${JSON.stringify(i.version)}.`)}function withoutCurrentTaskMessages(e){if(e.kind!==`send`||e.payload.task===void 0)return e;let{agentRequests:t,inputRequests:n,...r}=e.payload.task;return{...e,payload:{...e.payload,task:r}}}function withoutAcceptedDeployment(e){if(e.kind===`send`&&e.delivery?.acceptedDeploymentId!==void 0){let{acceptedDeploymentId:t,...n}=e.delivery;return{...e,delivery:n}}return e.kind!==`deliver`||e.deliveryMetadata===void 0?e:{...e,deliveryMetadata:e.deliveryMetadata.map(e=>{let{acceptedDeploymentId:t,...n}=e;return n})}}function readAcceptedDeploymentId(e){if(e.kind===`send`)return e.delivery?.acceptedDeploymentId;if(e.kind===`deliver`)return e.deliveryMetadata?.find(e=>e.payloadIndex===0)?.acceptedDeploymentId}const sessionInboxWire={encode};export{sessionInboxWire};
|
|
@@ -18,9 +18,9 @@ export { SessionInboxWireError } from "#execution/wire/session-inbox-contract.js
|
|
|
18
18
|
/**
|
|
19
19
|
* Decodes a persisted inbox payload or throws {@link SessionInboxWireError}.
|
|
20
20
|
*
|
|
21
|
-
* Unknown newer versions and shape mismatches both throw: a
|
|
22
|
-
* with an operator-visible signal is the designed failure; a
|
|
23
|
-
* delivery is the bug this module exists to prevent.
|
|
21
|
+
* Unknown newer versions and migration-bound shape mismatches both throw: a
|
|
22
|
+
* lost delivery with an operator-visible signal is the designed failure; a
|
|
23
|
+
* reinterpreted delivery is the bug this module exists to prevent.
|
|
24
24
|
*/
|
|
25
25
|
declare function decode(value: unknown): DecodedSessionInbox;
|
|
26
26
|
/** Workflow-safe consumer facade. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SESSION_INBOX_WIRE_VERSION,SessionInboxWireError,SessionInboxWireError as SessionInboxWireError$1}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV0Migration}from"#execution/wire/session-inbox-wire.v0.js";import{runMigrationChain}from"#execution/durable-session-migrations/chain.js";import{normalizeSessionInboxWireV2}from"#execution/wire/session-inbox-wire.v2-migration.js";import{sessionInboxWireV1Migration}from"#execution/wire/session-inbox-wire.v2.migration.js";import{sessionInboxWireV2Migration}from"#execution/wire/session-inbox-wire.v3.migration.js";const WIRE_LABEL=`session inbox payload`,sessionInboxMigrations=[sessionInboxWireV0Migration,sessionInboxWireV1Migration,sessionInboxWireV2Migration];function decode(
|
|
1
|
+
import{isObject}from"#shared/guards.js";import{SESSION_INBOX_WIRE_VERSION,SessionInboxWireError,SessionInboxWireError as SessionInboxWireError$1}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV0Migration}from"#execution/wire/session-inbox-wire.v0.js";import{runMigrationChain}from"#execution/durable-session-migrations/chain.js";import{normalizeSessionInboxWireV2}from"#execution/wire/session-inbox-wire.v2-migration.js";import{sessionInboxWireV1Migration}from"#execution/wire/session-inbox-wire.v2.migration.js";import{sessionInboxWireV2Migration}from"#execution/wire/session-inbox-wire.v3.migration.js";import{sessionInboxWireV3Migration}from"#execution/wire/session-inbox-wire.v4.migration.js";const WIRE_LABEL=`session inbox payload`,sessionInboxMigrations=[sessionInboxWireV0Migration,sessionInboxWireV1Migration,sessionInboxWireV2Migration,sessionInboxWireV3Migration];function decode(e){let n=typeof e==`object`&&e&&`version`in e?e.version:void 0;if(typeof e==`object`&&e&&`version`in e&&typeof n!=`number`)throw new SessionInboxWireError$1(`${WIRE_LABEL}: value has no numeric "version" field.`);let r=normalizeSessionInboxWireV2(e);if((n===1||n===2||n===3)&&containsCurrentTaskMessages(r))throw new SessionInboxWireError$1(`${WIRE_LABEL} does not match wire version ${n}.`);let i;try{i=runMigrationChain({initialVersion:0,label:WIRE_LABEL,migrations:sessionInboxMigrations,targetVersion:SESSION_INBOX_WIRE_VERSION,value:r})}catch(e){throw new SessionInboxWireError$1(e instanceof Error?e.message:String(e))}let a=normalizeSessionInboxWireV2(i);if(a.version!==SESSION_INBOX_WIRE_VERSION)throw new SessionInboxWireError$1(`${WIRE_LABEL} declares version ${JSON.stringify(a.version)}, expected ${SESSION_INBOX_WIRE_VERSION}.`);if(typeof n==`number`&&n>=2&&a.kind===`deliver`&&!(`payload`in a))throw new SessionInboxWireError$1(`${WIRE_LABEL} does not match wire version ${n}.`);return normalizeWire(a)}const sessionInboxWire={decode};function containsCurrentTaskMessages(t){return!isObject(t)||t.kind!==`deliver`?!1:(Array.isArray(t.payloads)?t.payloads:[]).some(t=>{if(!isObject(t)||!isObject(t.task))return!1;if(Object.hasOwn(t.task,`agentRequests`))return!0;let n=t.task.inputRequests;return Array.isArray(n)&&n.some(t=>isObject(t)&&(`request`in t||`requests`in t))})}function normalizeWire(e){switch(e.kind){case`deliver`:return{auth:e.auth,caller:e.caller,deliveryMetadata:e.deliveryMetadata,kind:`deliver`,payloads:e.payloads,requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy};case`session-timeout`:return{kind:`session-timeout`};case`clear`:return{kind:`clear`};case`compact`:return{kind:`compact`};case`reset`:return{kind:`reset`,reason:e.reason};case`cancel`:return{kind:`cancel`,taskId:e.taskId,turnId:e.turnId};default:throw new SessionInboxWireError$1(`${WIRE_LABEL} has an unrecognized kind ${JSON.stringify(e.kind)}.`)}}export{SessionInboxWireError,sessionInboxWire};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{inputRequestSchema,inputResponseSchema}from"#shared/input.js";import{formatValidationError}from"#runtime/validation.js";import{jsonObjectSchema,jsonValueSchema}from"#shared/json-schemas.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{inputRequestSchema,inputResponseSchema}from"#shared/input.js";import{formatValidationError}from"#runtime/validation.js";import{jsonObjectSchema,jsonValueSchema}from"#shared/json-schemas.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{SessionInboxWireError}from"#execution/wire/session-inbox-contract.js";import{tokenUsageSchema}from"#shared/token-usage.js";const providerOptionsSchema=z.record(z.string(),jsonObjectSchema),textPartSchema=z.object({providerOptions:providerOptionsSchema.optional(),text:z.string(),type:z.literal(`text`)}).strict(),binaryDataSchema=z.custom(e=>typeof e==`string`||e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof URL,`Expected a string, URL, Uint8Array, or ArrayBuffer.`),imagePartSchema=z.object({image:binaryDataSchema,mediaType:z.string().optional(),providerOptions:providerOptionsSchema.optional(),type:z.literal(`image`)}).strict(),filePartSchema=z.object({data:binaryDataSchema,filename:z.string().optional(),mediaType:z.string(),providerOptions:providerOptionsSchema.optional(),type:z.literal(`file`)}).strict(),userContentSchema=z.union([z.string(),z.array(z.discriminatedUnion(`type`,[textPartSchema,imagePartSchema,filePartSchema]))]),eventCoordinateSchema=z.number().int().nonnegative(),opaqueObjectSchema=z.custom(e=>typeof e==`object`&&!!e&&!Array.isArray(e),`Expected an object.`),subagentInputRequestHookPayloadSchema=z.object({callId:z.string(),childContinuationToken:z.string(),childSessionId:z.string(),event:z.object({requests:z.array(inputRequestSchema),sequence:eventCoordinateSchema,stepIndex:eventCoordinateSchema,turnId:z.string()}).strict(),kind:z.literal(`subagent-input-request`),subagentName:z.string()}).strict(),subagentAuthorizationEventHookPayloadSchema=z.object({callId:z.string(),childSessionId:z.string(),event:opaqueObjectSchema,kind:z.literal(`subagent-authorization-event`),subagentName:z.string()}).strict(),taskMetadataSchema=z.union([z.object({agentId:z.string(),kind:z.literal(`subagent`),mode:z.enum([`local`,`remote`]),name:z.string()}).strict(),z.object({kind:z.string(),name:z.string()}).strict()]),taskViewBase={executor:z.object({binding:z.object({data:z.record(z.string(),jsonValueSchema),kind:z.string()}).strict().optional(),childSessionId:z.string().optional(),childTurnId:z.string().optional(),lifecycle:z.enum([`parked`,`terminal`]).optional()}).strict().optional(),metadata:taskMetadataSchema,taskId:z.string(),usage:tokenUsageSchema.optional()},taskViewSchema=z.discriminatedUnion(`status`,[z.object({...taskViewBase,status:z.literal(`working`)}).strict(),z.object({...taskViewBase,inputRequests:z.array(jsonValueSchema),status:z.literal(`input_required`)}).strict(),z.object({...taskViewBase,lastOutput:z.object({data:jsonValueSchema,type:z.literal(`result`)}).strict(),status:z.literal(`completed`)}).strict(),z.object({...taskViewBase,lastOutput:z.object({data:jsonValueSchema,type:z.literal(`error`)}).strict(),status:z.literal(`failed`)}).strict(),z.object({...taskViewBase,status:z.literal(`cancelled`)}).strict()]),taskPayloadSchema=z.object({authorizationEvents:z.array(z.object({hookPayload:subagentAuthorizationEventHookPayloadSchema,taskId:z.string()}).strict()).optional(),inputRequests:z.array(z.object({hookPayload:subagentInputRequestHookPayloadSchema,taskId:z.string()}).strict()).optional(),views:z.array(taskViewSchema).optional()}).strict(),deliverPayloadSchema=z.object({context:z.array(z.string()).optional(),inputResponses:z.array(inputResponseSchema).optional(),message:userContentSchema.optional(),outputSchema:jsonObjectSchema.optional(),task:taskPayloadSchema.optional()}).loose(),authSchema=z.object({attributes:z.record(z.string(),z.union([z.string(),z.array(z.string())])),authenticator:z.string(),issuer:z.string().optional(),principalId:z.string(),principalType:z.string(),subject:z.string().optional()}).strict(),callerSchema=z.object({callId:z.string(),replyTo:z.discriminatedUnion(`kind`,[z.object({kind:z.literal(`hook`),token:z.string()}).strict(),z.object({kind:z.literal(`callback`),token:z.string(),url:z.string()}).strict()]),subagentName:z.string(),taskId:z.string().optional()}).strict(),callerProjectionSchema=callerSchema.strip(),traceContextSchema=z.object({spanId:z.string(),traceFlags:z.number(),traceId:z.string()}).strict(),deliveryMetadataSchema=z.object({channelKind:z.string(),channelName:z.string(),deliveryId:z.string(),payloadIndex:z.number().int().nonnegative(),requestId:z.string().optional(),requestTraceContext:traceContextSchema.optional()}).strict(),version=z.literal(1),sessionInboxWireV1Schema=z.discriminatedUnion(`kind`,[z.object({auth:authSchema.nullable().optional(),caller:callerSchema.optional(),deliveryMetadata:z.array(deliveryMetadataSchema).optional(),kind:z.literal(`deliver`),payload:deliverPayloadSchema.optional(),payloads:z.array(deliverPayloadSchema),requestId:z.string().optional(),taskDeliveryId:z.string().optional(),turnPolicy:z.enum([`queue`,`steer`]).optional(),version}).strict(),z.object({kind:z.literal(`session-timeout`),version}).strict(),z.object({kind:z.literal(`clear`),version}).strict(),z.object({kind:z.literal(`compact`),version}).strict(),z.object({kind:z.literal(`reset`),reason:z.string().optional(),version}).strict(),z.object({kind:z.literal(`cancel`),taskId:z.string().optional(),turnId:z.string().optional(),version}).strict()]);function encodeSessionCommandV1(e){let t=toV1Command(e),n=t.kind===`send`?{auth:t.auth,caller:t.caller,deliveryMetadata:t.delivery===void 0?void 0:[{...t.delivery,payloadIndex:0}],kind:`deliver`,payload:t.payload,payloads:[t.payload],requestId:t.requestId,taskDeliveryId:t.taskDeliveryId,turnPolicy:t.turnPolicy,version:1}:t.kind===`deliver`?{...t,payload:coalesceDeliverPayloads(t.payloads),version:1}:{...t,version:1},r=sessionInboxWireV1Schema.safeParse(n);if(!r.success)throw new SessionInboxWireError(`Produced a session inbox payload that does not match wire version 1: ${formatValidationError(r.error)}`);return r.data}function toV1Command(e){return!(`caller`in e)||e.caller===void 0?e:{...e,caller:toV1Caller(e.caller)}}function toV1Caller(e){let t=callerProjectionSchema.safeParse(e);if(!t.success)throw new SessionInboxWireError(`Produced a session inbox payload that does not match wire version 1: ${formatValidationError(t.error)}`);return t.data}export{encodeSessionCommandV1,sessionInboxWireV1Schema};
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { z } from "#compiled/zod/index.js";
|
|
2
|
+
import type { DeliverHookPayload, SessionCommand, SessionTimeoutHookPayload } from "#channel/types.js";
|
|
3
|
+
import type { TaskView } from "#tasks/types.js";
|
|
4
|
+
/** Version 4 replaces executor-specific task envelopes with typed workflow-run requests. */
|
|
5
|
+
export declare const sessionInboxWireV4Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6
|
+
auth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
7
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
8
|
+
authenticator: z.ZodString;
|
|
9
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
10
|
+
principalId: z.ZodString;
|
|
11
|
+
principalType: z.ZodString;
|
|
12
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strict>>>;
|
|
14
|
+
kind: z.ZodLiteral<"deliver">;
|
|
15
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
taskDeliveryId: z.ZodOptional<z.ZodString>;
|
|
17
|
+
turnPolicy: z.ZodOptional<z.ZodEnum<{
|
|
18
|
+
queue: "queue";
|
|
19
|
+
steer: "steer";
|
|
20
|
+
}>>;
|
|
21
|
+
caller: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
callId: z.ZodString;
|
|
23
|
+
replyTo: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
24
|
+
kind: z.ZodLiteral<"hook">;
|
|
25
|
+
token: z.ZodString;
|
|
26
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"callback">;
|
|
28
|
+
token: z.ZodString;
|
|
29
|
+
url: z.ZodString;
|
|
30
|
+
}, z.core.$strict>], "kind">;
|
|
31
|
+
subagentName: z.ZodString;
|
|
32
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
activityObserver: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
sink: z.ZodObject<{
|
|
35
|
+
url: z.ZodString;
|
|
36
|
+
version: z.ZodLiteral<1>;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
workIdentity: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
kind: z.ZodEnum<{
|
|
42
|
+
"remote-agent": "remote-agent";
|
|
43
|
+
"root-turn": "root-turn";
|
|
44
|
+
subagent: "subagent";
|
|
45
|
+
task: "task";
|
|
46
|
+
}>;
|
|
47
|
+
name: z.ZodOptional<z.ZodString>;
|
|
48
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
49
|
+
rootSessionId: z.ZodString;
|
|
50
|
+
rootTurnId: z.ZodString;
|
|
51
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
52
|
+
turnId: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strict>>;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
deliveryMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
57
|
+
channelKind: z.ZodString;
|
|
58
|
+
channelName: z.ZodString;
|
|
59
|
+
deliveryId: z.ZodString;
|
|
60
|
+
payloadIndex: z.ZodNumber;
|
|
61
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
requestTraceContext: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
spanId: z.ZodString;
|
|
64
|
+
traceFlags: z.ZodNumber;
|
|
65
|
+
traceId: z.ZodString;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
acceptedDeploymentId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strict>>>;
|
|
69
|
+
payload: z.ZodObject<{
|
|
70
|
+
context: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
72
|
+
optionId: z.ZodOptional<z.ZodString>;
|
|
73
|
+
requestId: z.ZodString;
|
|
74
|
+
text: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strict>>>;
|
|
76
|
+
message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
77
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
78
|
+
text: z.ZodString;
|
|
79
|
+
type: z.ZodLiteral<"text">;
|
|
80
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
81
|
+
image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
82
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
83
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
84
|
+
type: z.ZodLiteral<"image">;
|
|
85
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
86
|
+
data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
87
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
88
|
+
mediaType: z.ZodString;
|
|
89
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
90
|
+
type: z.ZodLiteral<"file">;
|
|
91
|
+
}, z.core.$strict>], "type">>]>>;
|
|
92
|
+
outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
|
|
93
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
94
|
+
agentRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
95
|
+
replyTo: z.ZodString;
|
|
96
|
+
request: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
97
|
+
input: z.ZodObject<{
|
|
98
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
99
|
+
message: z.ZodString;
|
|
100
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>>;
|
|
101
|
+
target: z.ZodString;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
invocationId: z.ZodString;
|
|
104
|
+
kind: z.ZodLiteral<"agent-invoke">;
|
|
105
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
106
|
+
kind: z.ZodLiteral<"agent-settled">;
|
|
107
|
+
result: z.ZodObject<{
|
|
108
|
+
backgroundTask: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
status: z.ZodLiteral<"working">;
|
|
110
|
+
taskId: z.ZodString;
|
|
111
|
+
}, z.core.$strict>>;
|
|
112
|
+
callId: z.ZodString;
|
|
113
|
+
isError: z.ZodOptional<z.ZodBoolean>;
|
|
114
|
+
kind: z.ZodLiteral<"subagent-result">;
|
|
115
|
+
origin: z.ZodLiteral<"child">;
|
|
116
|
+
outcome: z.ZodType<import("../../shared/agent-turn-outcome.ts").AgentTurnOutcome, unknown, z.core.$ZodTypeInternals<import("../../shared/agent-turn-outcome.ts").AgentTurnOutcome, unknown>>;
|
|
117
|
+
output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
|
|
118
|
+
subagentName: z.ZodString;
|
|
119
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
cacheReadTokens: z.ZodNumber;
|
|
121
|
+
cacheWriteTokens: z.ZodNumber;
|
|
122
|
+
inputTokens: z.ZodNumber;
|
|
123
|
+
outputTokens: z.ZodNumber;
|
|
124
|
+
}, z.core.$strip>>;
|
|
125
|
+
}, z.core.$strict>;
|
|
126
|
+
}, z.core.$strict>], "kind">;
|
|
127
|
+
taskId: z.ZodString;
|
|
128
|
+
}, z.core.$strict>>>;
|
|
129
|
+
authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
130
|
+
hookPayload: z.ZodObject<{
|
|
131
|
+
callId: z.ZodString;
|
|
132
|
+
childSessionId: z.ZodString;
|
|
133
|
+
event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
|
|
134
|
+
kind: z.ZodLiteral<"subagent-authorization-event">;
|
|
135
|
+
subagentName: z.ZodString;
|
|
136
|
+
}, z.core.$strict>;
|
|
137
|
+
taskId: z.ZodString;
|
|
138
|
+
}, z.core.$strict>>>;
|
|
139
|
+
inputRequests: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
140
|
+
replyTo: z.ZodString;
|
|
141
|
+
sequence: z.ZodNumber;
|
|
142
|
+
stepIndex: z.ZodNumber;
|
|
143
|
+
taskId: z.ZodString;
|
|
144
|
+
turnId: z.ZodString;
|
|
145
|
+
request: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
|
|
146
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
147
|
+
replyTo: z.ZodString;
|
|
148
|
+
sequence: z.ZodNumber;
|
|
149
|
+
stepIndex: z.ZodNumber;
|
|
150
|
+
taskId: z.ZodString;
|
|
151
|
+
turnId: z.ZodString;
|
|
152
|
+
requests: z.ZodArray<z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>;
|
|
153
|
+
}, z.core.$loose>]>>>;
|
|
154
|
+
views: z.ZodOptional<z.ZodArray<z.ZodType<TaskView, unknown, z.core.$ZodTypeInternals<TaskView, unknown>>>>;
|
|
155
|
+
}, z.core.$strict>>;
|
|
156
|
+
}, z.core.$loose>;
|
|
157
|
+
payloads: z.ZodArray<z.ZodObject<{
|
|
158
|
+
context: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
159
|
+
inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
160
|
+
optionId: z.ZodOptional<z.ZodString>;
|
|
161
|
+
requestId: z.ZodString;
|
|
162
|
+
text: z.ZodOptional<z.ZodString>;
|
|
163
|
+
}, z.core.$strict>>>;
|
|
164
|
+
message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
165
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
166
|
+
text: z.ZodString;
|
|
167
|
+
type: z.ZodLiteral<"text">;
|
|
168
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
169
|
+
image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
170
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
171
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
172
|
+
type: z.ZodLiteral<"image">;
|
|
173
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
174
|
+
data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
175
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
176
|
+
mediaType: z.ZodString;
|
|
177
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
178
|
+
type: z.ZodLiteral<"file">;
|
|
179
|
+
}, z.core.$strict>], "type">>]>>;
|
|
180
|
+
outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
|
|
181
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
182
|
+
agentRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
183
|
+
replyTo: z.ZodString;
|
|
184
|
+
request: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
185
|
+
input: z.ZodObject<{
|
|
186
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
187
|
+
message: z.ZodString;
|
|
188
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>>;
|
|
189
|
+
target: z.ZodString;
|
|
190
|
+
}, z.core.$strict>;
|
|
191
|
+
invocationId: z.ZodString;
|
|
192
|
+
kind: z.ZodLiteral<"agent-invoke">;
|
|
193
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
194
|
+
kind: z.ZodLiteral<"agent-settled">;
|
|
195
|
+
result: z.ZodObject<{
|
|
196
|
+
backgroundTask: z.ZodOptional<z.ZodObject<{
|
|
197
|
+
status: z.ZodLiteral<"working">;
|
|
198
|
+
taskId: z.ZodString;
|
|
199
|
+
}, z.core.$strict>>;
|
|
200
|
+
callId: z.ZodString;
|
|
201
|
+
isError: z.ZodOptional<z.ZodBoolean>;
|
|
202
|
+
kind: z.ZodLiteral<"subagent-result">;
|
|
203
|
+
origin: z.ZodLiteral<"child">;
|
|
204
|
+
outcome: z.ZodType<import("../../shared/agent-turn-outcome.ts").AgentTurnOutcome, unknown, z.core.$ZodTypeInternals<import("../../shared/agent-turn-outcome.ts").AgentTurnOutcome, unknown>>;
|
|
205
|
+
output: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
|
|
206
|
+
subagentName: z.ZodString;
|
|
207
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
208
|
+
cacheReadTokens: z.ZodNumber;
|
|
209
|
+
cacheWriteTokens: z.ZodNumber;
|
|
210
|
+
inputTokens: z.ZodNumber;
|
|
211
|
+
outputTokens: z.ZodNumber;
|
|
212
|
+
}, z.core.$strip>>;
|
|
213
|
+
}, z.core.$strict>;
|
|
214
|
+
}, z.core.$strict>], "kind">;
|
|
215
|
+
taskId: z.ZodString;
|
|
216
|
+
}, z.core.$strict>>>;
|
|
217
|
+
authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
218
|
+
hookPayload: z.ZodObject<{
|
|
219
|
+
callId: z.ZodString;
|
|
220
|
+
childSessionId: z.ZodString;
|
|
221
|
+
event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
|
|
222
|
+
kind: z.ZodLiteral<"subagent-authorization-event">;
|
|
223
|
+
subagentName: z.ZodString;
|
|
224
|
+
}, z.core.$strict>;
|
|
225
|
+
taskId: z.ZodString;
|
|
226
|
+
}, z.core.$strict>>>;
|
|
227
|
+
inputRequests: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
228
|
+
replyTo: z.ZodString;
|
|
229
|
+
sequence: z.ZodNumber;
|
|
230
|
+
stepIndex: z.ZodNumber;
|
|
231
|
+
taskId: z.ZodString;
|
|
232
|
+
turnId: z.ZodString;
|
|
233
|
+
request: z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>;
|
|
234
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
235
|
+
replyTo: z.ZodString;
|
|
236
|
+
sequence: z.ZodNumber;
|
|
237
|
+
stepIndex: z.ZodNumber;
|
|
238
|
+
taskId: z.ZodString;
|
|
239
|
+
turnId: z.ZodString;
|
|
240
|
+
requests: z.ZodArray<z.ZodType<import("../../shared/json.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonValue, unknown>>>;
|
|
241
|
+
}, z.core.$loose>]>>>;
|
|
242
|
+
views: z.ZodOptional<z.ZodArray<z.ZodType<TaskView, unknown, z.core.$ZodTypeInternals<TaskView, unknown>>>>;
|
|
243
|
+
}, z.core.$strict>>;
|
|
244
|
+
}, z.core.$loose>>;
|
|
245
|
+
version: z.ZodLiteral<4>;
|
|
246
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
247
|
+
kind: z.ZodLiteral<"session-timeout">;
|
|
248
|
+
version: z.ZodLiteral<4>;
|
|
249
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
250
|
+
kind: z.ZodLiteral<"clear">;
|
|
251
|
+
version: z.ZodLiteral<4>;
|
|
252
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
253
|
+
kind: z.ZodLiteral<"compact">;
|
|
254
|
+
version: z.ZodLiteral<4>;
|
|
255
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
256
|
+
kind: z.ZodLiteral<"reset">;
|
|
257
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
258
|
+
version: z.ZodLiteral<4>;
|
|
259
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
260
|
+
kind: z.ZodLiteral<"cancel">;
|
|
261
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
262
|
+
turnId: z.ZodOptional<z.ZodString>;
|
|
263
|
+
version: z.ZodLiteral<4>;
|
|
264
|
+
}, z.core.$strict>], "kind">;
|
|
265
|
+
export type SessionInboxWireV4 = z.infer<typeof sessionInboxWireV4Schema>;
|
|
266
|
+
/** Builds and validates one complete version-4 wire value. */
|
|
267
|
+
export declare function encodeSessionCommandV4(command: DeliverHookPayload | SessionCommand | SessionTimeoutHookPayload): SessionInboxWireV4;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{formatValidationError}from"#runtime/validation.js";import{jsonValueSchema}from"#shared/json-schemas.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{SessionInboxWireError}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV3Schema}from"#execution/wire/session-inbox-wire.v3.js";import{tokenUsageSchema}from"#shared/token-usage.js";import{runtimeSubagentChildResultSchema}from"#shared/action-types.js";const taskMetadataSchema=z.object({agentId:z.string().optional(),kind:z.string(),mode:z.enum([`local`,`remote`]).optional(),name:z.string()}).strict(),taskViewBase={executor:z.object({binding:z.object({data:z.record(z.string(),jsonValueSchema),kind:z.string()}).strict().optional()}).strict().optional(),metadata:taskMetadataSchema,taskId:z.string(),usage:tokenUsageSchema.optional()},taskViewSchema=z.discriminatedUnion(`status`,[z.object({...taskViewBase,status:z.literal(`working`)}).strict(),z.object({...taskViewBase,inputRequests:z.array(jsonValueSchema),status:z.literal(`input_required`)}).strict(),z.object({...taskViewBase,lastOutput:z.object({data:jsonValueSchema,type:z.literal(`result`)}).strict(),status:z.literal(`completed`)}).strict(),z.object({...taskViewBase,lastOutput:z.object({data:jsonValueSchema,type:z.literal(`error`)}).strict(),status:z.literal(`failed`)}).strict(),z.object({...taskViewBase,status:z.literal(`cancelled`)}).strict()]),eventCoordinateSchema=z.number().int().nonnegative(),taskInputRequestBase={replyTo:z.string(),sequence:eventCoordinateSchema,stepIndex:eventCoordinateSchema,taskId:z.string(),turnId:z.string()},taskInputRequestSchema=z.union([z.object({...taskInputRequestBase,request:jsonValueSchema}).loose(),z.object({...taskInputRequestBase,requests:z.array(jsonValueSchema)}).loose()]),agentInvocationInputSchema=z.object({agentId:z.string().optional(),message:z.string(),outputSchema:z.record(z.string(),jsonValueSchema).optional(),target:z.string()}).strict(),taskAgentRequestSchema=z.object({replyTo:z.string(),request:z.discriminatedUnion(`kind`,[z.object({input:agentInvocationInputSchema,invocationId:z.string(),kind:z.literal(`agent-invoke`)}).strict(),z.object({kind:z.literal(`agent-settled`),result:runtimeSubagentChildResultSchema}).strict()]),taskId:z.string()}).strict(),subagentAuthorizationEventHookPayloadSchema=z.object({callId:z.string(),childSessionId:z.string(),event:z.custom(e=>typeof e==`object`&&!!e&&!Array.isArray(e),`Expected an object.`),kind:z.literal(`subagent-authorization-event`),subagentName:z.string()}).strict(),taskAuthorizationEventSchema=z.object({hookPayload:subagentAuthorizationEventHookPayloadSchema,taskId:z.string()}).strict(),taskPayloadV4Schema=z.object({agentRequests:z.array(taskAgentRequestSchema).optional(),authorizationEvents:z.array(taskAuthorizationEventSchema).optional(),inputRequests:z.array(taskInputRequestSchema).optional(),views:z.array(taskViewSchema).optional()}).strict(),v3=sessionInboxWireV3Schema.options,v3Deliver=v3[0],deliverPayloadV4Schema=v3Deliver.shape.payload.extend({task:taskPayloadV4Schema.optional()}),version=z.literal(4),sessionInboxWireV4Schema=z.discriminatedUnion(`kind`,[v3Deliver.extend({payload:deliverPayloadV4Schema,payloads:z.array(deliverPayloadV4Schema),version}),v3[1].extend({version}),v3[2].extend({version}),v3[3].extend({version}),v3[4].extend({version}),v3[5].extend({version})]);function encodeSessionCommandV4(e){let t=e.kind===`send`?{auth:e.auth,caller:e.caller,deliveryMetadata:e.delivery===void 0?void 0:[{...e.delivery,payloadIndex:0}],kind:`deliver`,payload:e.payload,payloads:[e.payload],requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy,version:4}:e.kind===`deliver`?{...e,payload:coalesceDeliverPayloads(e.payloads),version:4}:{...e,version:4},n=sessionInboxWireV4Schema.safeParse(t);if(!n.success)throw new SessionInboxWireError(`Produced a session inbox payload that does not match wire version 4: ${formatValidationError(n.error)}`);return n.data}export{encodeSessionCommandV4,sessionInboxWireV4Schema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject}from"#shared/guards.js";const sessionInboxWireV3Migration={from:3,migrate(t){if(!isObject(t))throw Error(`session inbox wire v3 value is not an object.`);return t.kind===`deliver`?{...t,payload:migratePayload(t.payload),payloads:Array.isArray(t.payloads)?t.payloads.map(migratePayload):t.payloads,version:4}:{...t,version:4}},to:4};function migratePayload(t){if(!isObject(t)||!isObject(t.task))return t;let n=t.task;return{...t,task:{agentRequests:n.agentRequests,authorizationEvents:n.authorizationEvents,inputRequests:migrateInputRequests(n.inputRequests),views:Array.isArray(n.views)?n.views.map(migrateTaskView):n.views}}}function migrateInputRequests(t){if(Array.isArray(t))return t.flatMap(t=>{if(!isObject(t))return[];if(`request`in t||`requests`in t)return[t];if(!isObject(t.hookPayload)||typeof t.taskId!=`string`)return[];let n=t.hookPayload,r=n.event;return typeof n.childContinuationToken!=`string`||!isObject(r)||!Array.isArray(r.requests)||typeof r.sequence!=`number`||typeof r.stepIndex!=`number`||typeof r.turnId!=`string`?[]:r.requests.map(e=>({...t,replyTo:n.childContinuationToken,request:e,sequence:r.sequence,stepIndex:r.stepIndex,taskId:t.taskId,turnId:r.turnId}))})}function migrateTaskView(t){return!isObject(t)||!isObject(t.executor)?t:{...t,executor:t.executor.binding===void 0?void 0:{binding:t.executor.binding}}}export{sessionInboxWireV3Migration};
|
|
@@ -8,6 +8,9 @@ export declare function finalizeExpiredSession(input: {
|
|
|
8
8
|
readonly mode: RunMode;
|
|
9
9
|
readonly serializedContext: Record<string, unknown>;
|
|
10
10
|
readonly sessionState: DurableSessionState;
|
|
11
|
+
readonly terminalState?: {
|
|
12
|
+
terminalEmitted: boolean;
|
|
13
|
+
};
|
|
11
14
|
}): Promise<{
|
|
12
15
|
readonly output: unknown;
|
|
13
16
|
}>;
|
|
@@ -17,6 +20,9 @@ export declare function finalizeDone(input: {
|
|
|
17
20
|
};
|
|
18
21
|
readonly caller: TurnCaller | undefined;
|
|
19
22
|
readonly mode: RunMode;
|
|
23
|
+
readonly terminalState?: {
|
|
24
|
+
terminalEmitted: boolean;
|
|
25
|
+
};
|
|
20
26
|
}): Promise<{
|
|
21
27
|
readonly output: unknown;
|
|
22
28
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{fireSessionCallbackStep}from"#subagents/callback-step.js";import{notifyDelegatedParentStep,notifyTurnCallerStep}from"#subagents/parent-notification.js";import{createDelegatedSubagentErrorResult,createDelegatedSubagentSuccessResult}from"#subagents/parent-result.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";async function finalizeExpiredSession(t){return await terminateChildSessionsStep({serializedContext:t.serializedContext,sessionState:t.sessionState}),await emitTerminalSessionCompletionStep({parentWritable:t.driverWritable,serializedContext:t.serializedContext}),t.terminalState!==void 0&&(t.terminalState.terminalEmitted=!0),t.mode===`task`?(await fireSessionCallbackStep({output:``,serializedContext:t.serializedContext,status:`completed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentSuccessResult(t.serializedContext,``),serializedContext:t.serializedContext})):t.caller!==void 0&&await notifyTurnCallerStep({caller:t.caller,lifecycle:`terminal`,sessionId:t.sessionState.sessionId,settled:{output:``}}),{output:``}}async function finalizeDone(n){let{output:r,serializedContext:i}=n.action,a=n.action.isError===!0;if(await terminateChildSessionsStep({serializedContext:i,sessionState:n.action.sessionState}),n.terminalState!==void 0&&(n.terminalState.terminalEmitted=!0),n.mode===`task`)await fireSessionCallbackStep({error:a?r:void 0,output:a?void 0:r,serializedContext:i,status:a?`failed`:`completed`,usage:n.action.usage}),await notifyDelegatedParentStep({result:a?createDelegatedSubagentErrorResult(i,r):createDelegatedSubagentSuccessResult(i,r),serializedContext:i,usage:n.action.usage});else{let e={output:r,usage:n.action.usageDelta};a&&(e.isError=!0),n.caller!==void 0&&await notifyTurnCallerStep({caller:n.caller,lifecycle:`terminal`,sessionId:n.action.sessionState.sessionId,settled:e})}return{output:r}}export{finalizeDone,finalizeExpiredSession};
|