eve 0.69.0 → 0.70.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/channel/task-card.d.ts +3 -3
- package/dist/src/channel/task-card.js +1 -1
- package/dist/src/channel/types.d.ts +18 -0
- package/dist/src/chunks/{use-eve-agent-Dab2MnT2.js → use-eve-agent-CJQeE7-t.js} +1873 -1236
- package/dist/src/chunks/{use-eve-agent-D_5129A9.js → use-eve-agent-DdemtY6C.js} +1874 -1234
- package/dist/src/cli/dev/command.js +1 -1
- package/dist/src/cli/dev/console-records-preload.d.ts +1 -0
- package/dist/src/cli/dev/console-records-preload.js +1 -0
- package/dist/src/cli/dev/console-records.d.ts +17 -0
- package/dist/src/cli/dev/console-records.js +3 -0
- package/dist/src/cli/dev/diagnostic-sink.d.ts +1 -0
- package/dist/src/cli/dev/local-server-process.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +2 -1
- package/dist/src/cli/dev/tui/blocks.js +3 -3
- package/dist/src/cli/dev/tui/conversation-view.d.ts +54 -0
- package/dist/src/cli/dev/tui/conversation-view.js +1 -0
- package/dist/src/cli/dev/tui/flow-drawer.d.ts +5 -2
- package/dist/src/cli/dev/tui/flow-drawer.js +1 -1
- package/dist/src/cli/dev/tui/log-display-mode.d.ts +4 -10
- package/dist/src/cli/dev/tui/log-display-mode.js +1 -1
- package/dist/src/cli/dev/tui/message-queue.d.ts +7 -63
- package/dist/src/cli/dev/tui/message-queue.js +3 -1
- package/dist/src/cli/dev/tui/prompt-commands.d.ts +7 -7
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/question-panel.d.ts +3 -1
- package/dist/src/cli/dev/tui/question-panel.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +58 -195
- package/dist/src/cli/dev/tui/runner.js +3 -3
- package/dist/src/cli/dev/tui/task-activity.d.ts +11 -24
- package/dist/src/cli/dev/tui/task-activity.js +1 -1
- package/dist/src/cli/dev/tui/task-records.d.ts +17 -0
- package/dist/src/cli/dev/tui/task-records.js +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +15 -37
- package/dist/src/cli/dev/tui/terminal-renderer.js +10 -13
- package/dist/src/cli/dev/tui/terminal-tool-part.d.ts +2 -0
- package/dist/src/cli/dev/tui/terminal-tool-part.js +1 -0
- package/dist/src/cli/dev/tui/test/fake-eve-server.d.ts +34 -0
- package/dist/src/cli/dev/tui/test/fake-eve-server.js +1 -0
- package/dist/src/cli/dev/tui/test/index.d.ts +1 -0
- package/dist/src/cli/dev/tui/test/index.js +1 -1
- package/dist/src/cli/dev/tui/tool-block-groups.js +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.d.ts +1 -0
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/cli/dev/tui/tool-rows.d.ts +1 -0
- package/dist/src/cli/dev/tui/tool-rows.js +2 -2
- package/dist/src/cli/dev/tui/transcript-parts.d.ts +81 -0
- package/dist/src/cli/dev/tui/transcript-parts.js +3 -0
- package/dist/src/cli/dev/tui/transcript.d.ts +47 -0
- package/dist/src/cli/dev/tui/transcript.js +1 -0
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/dev/tui/turn-clock.d.ts +11 -26
- package/dist/src/cli/dev/tui/turn-clock.js +1 -1
- package/dist/src/cli/dev/tui/types.d.ts +2 -4
- package/dist/src/cli/dev/ui-options.js +1 -1
- package/dist/src/client/agent-stream-follower.d.ts +26 -0
- package/dist/src/client/agent-stream-follower.js +1 -0
- package/dist/src/client/authorization-message-parts.js +1 -1
- package/dist/src/client/conversation-client.d.ts +40 -0
- package/dist/src/client/conversation-client.js +1 -0
- package/dist/src/client/conversation-reducer.d.ts +29 -0
- package/dist/src/client/conversation-reducer.js +1 -0
- package/dist/src/client/conversation-state.d.ts +110 -0
- package/dist/src/client/conversation-state.js +1 -0
- package/dist/src/client/eve-agent-projection.d.ts +24 -7
- package/dist/src/client/eve-agent-projection.js +1 -1
- package/dist/src/client/eve-agent-store-helpers.d.ts +21 -2
- package/dist/src/client/eve-agent-store-helpers.js +2 -2
- package/dist/src/client/eve-agent-store-state.d.ts +15 -3
- package/dist/src/client/eve-agent-store.d.ts +10 -1
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/index.d.ts +4 -1
- package/dist/src/client/index.js +1 -1
- package/dist/src/client/message-reducer-primitives.d.ts +1 -2
- package/dist/src/client/message-reducer-primitives.js +1 -1
- package/dist/src/client/message-reducer-types.d.ts +9 -2
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/message-run-parts.d.ts +10 -6
- package/dist/src/client/message-run-parts.js +1 -1
- package/dist/src/client/optimistic-message-submissions.d.ts +6 -4
- package/dist/src/client/optimistic-message-submissions.js +1 -1
- package/dist/src/client/reducer.d.ts +5 -1
- package/dist/src/client/session-turn-dispatch.d.ts +15 -0
- package/dist/src/client/session-turn-dispatch.js +1 -0
- package/dist/src/client/session-utils.d.ts +27 -10
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +2 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/{gray-matter → js-yaml}/LICENSE +2 -2
- package/dist/src/compiled/js-yaml/index.d.ts +12 -0
- package/dist/src/compiled/js-yaml/index.js +34 -0
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/context/keys.d.ts +5 -2
- package/dist/src/context/keys.js +1 -1
- package/dist/src/context/provider.d.ts +5 -9
- package/dist/src/context/run-step.d.ts +4 -4
- package/dist/src/context/run-step.js +1 -1
- package/dist/src/context/serialize.d.ts +5 -1
- package/dist/src/context/serialize.js +1 -1
- package/dist/src/evals/loaders/yaml.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.js +1 -1
- package/dist/src/evals/runner/execute-task.js +1 -1
- package/dist/src/evals/session.js +2 -2
- package/dist/src/evals/types.d.ts +16 -0
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/agent-sessions/context.d.ts +4 -2
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +6 -4
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +4 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +10 -4
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/legacy-remote-agent/protocol.d.ts +8 -0
- package/dist/src/execution/legacy-remote-agent/protocol.js +1 -1
- package/dist/src/execution/legacy-session/completion-step.d.ts +2 -0
- package/dist/src/execution/legacy-session/completion-step.js +1 -1
- package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
- package/dist/src/execution/legacy-session/prepare-step.d.ts +1 -0
- package/dist/src/execution/legacy-session/prepare-step.js +1 -1
- package/dist/src/execution/legacy-session/snapshot.d.ts +8 -4
- package/dist/src/execution/legacy-session/snapshot.js +1 -1
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/publish-session-events.d.ts +27 -7
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/reconcile-session-continuation-token.d.ts +2 -2
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session/active-turn.d.ts +97 -0
- package/dist/src/execution/session/active-turn.js +1 -0
- package/dist/src/execution/session/checkpoint-migrations.d.ts +23 -0
- package/dist/src/execution/session/checkpoint-migrations.js +1 -0
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/finalization.js +1 -1
- package/dist/src/execution/session/handoff-steps.d.ts +24 -5
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +10 -6
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +19 -13
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/next-input.d.ts +2 -10
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/pending-turn-state.d.ts +2 -0
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/program.d.ts +2 -0
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/state-cursor.d.ts +22 -16
- package/dist/src/execution/session/state-cursor.js +1 -1
- package/dist/src/execution/session/state-delta.d.ts +8 -1
- package/dist/src/execution/session/state-delta.js +1 -1
- package/dist/src/execution/session/turn-event-handler.js +1 -1
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step-types.d.ts +20 -4
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn-waiting-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +22 -3
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session.d.ts +5 -5
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +5 -4
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +2 -2
- package/dist/src/execution/tasks/task-id-input.d.ts +1 -1
- package/dist/src/execution/tasks/task-id-input.js +1 -1
- package/dist/src/execution/terminal-session-completion-step.d.ts +2 -0
- package/dist/src/execution/terminal-session-completion-step.js +1 -1
- package/dist/src/execution/terminal-session-failure-step.d.ts +2 -0
- package/dist/src/execution/terminal-session-failure-step.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/connection-target.d.ts +5 -0
- package/dist/src/execution/tools/connection-target.js +1 -1
- package/dist/src/execution/tools/connection-tools.js +2 -2
- package/dist/src/execution/tools/workflow/start.d.ts +3 -3
- package/dist/src/harness/authorization.d.ts +15 -2
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/cancelled-turn-emission.d.ts +2 -1
- package/dist/src/harness/cancelled-turn-emission.js +1 -1
- package/dist/src/harness/coordination.d.ts +5 -3
- package/dist/src/harness/emission.d.ts +5 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/held-requests.d.ts +18 -0
- package/dist/src/harness/held-requests.js +1 -0
- package/dist/src/harness/hitl/approval-input-requests.d.ts +16 -0
- package/dist/src/harness/hitl/approval-input-requests.js +1 -1
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-requests.d.ts +0 -4
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/model-call-error.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +4 -4
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/turn-tag-state.d.ts +2 -0
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +23 -11
- package/dist/src/instrumentation/channel-delivery.d.ts +1 -0
- package/dist/src/instrumentation/channel-delivery.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +4 -0
- package/dist/src/instrumentation/memory.d.ts +2 -0
- package/dist/src/instrumentation/memory.js +1 -1
- package/dist/src/instrumentation/native-events.d.ts +1 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/runtime.d.ts +4 -3
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/session-init.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +14 -6
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/authored-package-boundary.d.ts +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/bundler/extension-mount-plugin.js +1 -1
- package/dist/src/internal/helpers/frontmatter.d.ts +24 -0
- package/dist/src/internal/helpers/frontmatter.js +1 -0
- package/dist/src/internal/helpers/markdown.js +1 -3
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -1
- package/dist/src/internal/node-esm-compat-banner.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +27 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +2 -2
- package/dist/src/protocol/message.d.ts +41 -3
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/slack/action-status.d.ts +2 -2
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/channels/slack/approval-cards.d.ts +15 -0
- package/dist/src/public/channels/slack/approval-cards.js +2 -0
- package/dist/src/public/channels/slack/auth.d.ts +2 -0
- package/dist/src/public/channels/slack/auth.js +1 -1
- package/dist/src/public/channels/slack/connections.d.ts +15 -11
- package/dist/src/public/channels/slack/connections.js +1 -1
- package/dist/src/public/channels/slack/defaults.d.ts +1 -15
- package/dist/src/public/channels/slack/defaults.js +3 -4
- package/dist/src/public/channels/slack/hitl.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +10 -2
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/index.d.ts +2 -0
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/input-response.js +1 -1
- package/dist/src/public/channels/slack/interaction-cards.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/limits.d.ts +5 -3
- package/dist/src/public/channels/slack/private-approval-delivery.js +1 -1
- package/dist/src/public/channels/slack/renderers.d.ts +1 -1
- package/dist/src/public/channels/slack/renderers.js +1 -1
- package/dist/src/public/channels/slack/reply-delivery.d.ts +72 -0
- package/dist/src/public/channels/slack/reply-delivery.js +1 -0
- package/dist/src/public/channels/slack/sign-in-cancel.d.ts +20 -0
- package/dist/src/public/channels/slack/sign-in-cancel.js +1 -0
- package/dist/src/public/channels/slack/slackChannel.d.ts +15 -0
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/task-card.js +1 -1
- package/dist/src/public/channels/teams/defaults.d.ts +1 -1
- package/dist/src/public/channels/teams/defaults.js +2 -2
- package/dist/src/public/definitions/channel.d.ts +1 -0
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/state.d.ts +2 -0
- package/dist/src/public/definitions/state.js +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/server.d.ts +2 -0
- package/dist/src/public/next/server.js +1 -2
- package/dist/src/public/nuxt/module.d.ts +6 -0
- package/dist/src/public/nuxt/module.js +1 -1
- package/dist/src/react/index.d.ts +3 -0
- package/dist/src/react/index.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +7 -5
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/connections/openapi-spec.d.ts +1 -4
- package/dist/src/runtime/connections/openapi-spec.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.d.ts +2 -0
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/setup/boxes/deploy-project.js +1 -1
- package/dist/src/setup/integrations/web/setup.js +6 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +5 -5
- package/dist/src/setup/scaffold/create/web-template.js +61 -35
- package/dist/src/setup/vercel-project-framework.js +1 -1
- package/dist/src/shared/display-name.d.ts +15 -0
- package/dist/src/shared/display-name.js +1 -0
- package/dist/src/shared/framework-eve-server.d.ts +43 -0
- package/dist/src/shared/framework-eve-server.js +2 -0
- package/dist/src/shared/token-usage.d.ts +2 -0
- package/dist/src/shared/token-usage.js +1 -1
- package/dist/src/shared/trace-root.d.ts +8 -0
- package/dist/src/shared/trace-root.js +1 -0
- package/dist/src/subagents/callback-route.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +3 -3
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/subagents/invocation.d.ts +3 -1
- package/dist/src/subagents/parent-notification.d.ts +7 -7
- package/dist/src/subagents/parent-notification.js +1 -1
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/svelte/index.d.ts +3 -0
- package/dist/src/svelte/index.js +2 -2
- package/dist/src/svelte/use-eve-agent.d.ts +7 -4
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/load-skill.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tracing/agent-action-instrumentation.js +1 -1
- package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
- package/dist/src/tracing/agent-memory-instrumentation.js +1 -1
- package/dist/src/tracing/agent-otel-attributes.d.ts +6 -0
- package/dist/src/tracing/agent-otel-attributes.js +1 -1
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-runtime-context.d.ts +1 -1
- package/dist/src/tracing/agent-otel-runtime-context.js +1 -1
- package/dist/src/tracing/agent-otel-session-context.js +1 -1
- package/dist/src/tracing/agent-span-contract.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-context-codec.d.ts +4 -0
- package/dist/src/tracing/agent-trace-context-codec.js +1 -1
- package/dist/src/tracing/agent-trace-span-processor.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +3 -0
- package/dist/src/tracing/conversation-context.d.ts +10 -0
- package/dist/src/tracing/conversation-context.js +1 -1
- package/dist/src/tracing/otel-registration.js +1 -1
- package/dist/src/vue/index.d.ts +3 -0
- package/dist/src/vue/index.js +2 -2
- package/dist/src/vue/use-eve-agent.d.ts +7 -3
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/slack.mdx +60 -13
- package/docs/concepts/built-in-tools.md +3 -2
- package/docs/concepts/execution-model-and-durability.mdx +3 -1
- package/docs/concepts/sessions-runs-and-streaming.md +4 -4
- package/docs/connections/overview.mdx +9 -3
- package/docs/evals/reporters.mdx +4 -0
- package/docs/extensions.md +15 -3
- package/docs/guides/client/streaming.mdx +7 -6
- package/docs/guides/deployment/vercel.mdx +2 -1
- package/docs/guides/dev-tui.md +17 -17
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/guides/frontend/nuxt.mdx +24 -4
- package/docs/guides/frontend/overview.mdx +44 -38
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +4 -10
- package/docs/guides/frontend/use-eve-agent-vue.mdx +4 -10
- package/docs/guides/instrumentation/otel.mdx +24 -6
- package/docs/guides/remote-agents.md +26 -8
- package/docs/reference/cli.md +4 -4
- package/docs/tools/human-in-the-loop.md +4 -4
- package/docs/tools/overview.mdx +1 -1
- package/docs/tools/tasks.md +8 -8
- package/package.json +2 -2
- package/dist/src/cli/dev/tui/steering-stream.d.ts +0 -15
- package/dist/src/cli/dev/tui/steering-stream.js +0 -1
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +0 -134
- package/dist/src/cli/dev/tui/subagent-pump.js +0 -1
- package/dist/src/compiled/gray-matter/index.d.ts +0 -62
- package/dist/src/compiled/gray-matter/index.js +0 -48
- package/dist/src/internal/helpers/gray-matter.d.ts +0 -25
- package/dist/src/internal/helpers/gray-matter.js +0 -1
- package/dist/src/public/nuxt/dev-server.d.ts +0 -25
- package/dist/src/public/nuxt/dev-server.js +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ChannelAdapterContext } from "#channel/adapter.js";
|
|
2
2
|
import { type ContextContainer } from "#context/container.js";
|
|
3
3
|
import { type DurableSession, type DurableSessionState } from "#execution/durable-session-store.js";
|
|
4
|
-
import
|
|
4
|
+
import { type HarnessModelMessage } from "#harness/messages.js";
|
|
5
|
+
import type { HandleEventFn, HarnessSession, HarnessSessionBase } from "#harness/types.js";
|
|
5
6
|
import { type MessageStreamEvent, type UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
6
7
|
/**
|
|
7
8
|
* Whose event a session publishes. Every event reaches the channel adapter, the
|
|
@@ -22,6 +23,10 @@ export interface SessionStepState {
|
|
|
22
23
|
readonly sessionState: DurableSessionState;
|
|
23
24
|
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
24
25
|
}
|
|
26
|
+
/** A {@link SessionStepState} with the conversation history, for a step that reads or changes it. */
|
|
27
|
+
export interface SessionHistoryStepState extends SessionStepState {
|
|
28
|
+
readonly history: HarnessModelMessage[];
|
|
29
|
+
}
|
|
25
30
|
/** The context and session state a publication leaves behind. */
|
|
26
31
|
export interface PublishedSessionEvents {
|
|
27
32
|
readonly serializedContext: Record<string, unknown>;
|
|
@@ -41,29 +46,44 @@ export interface RestoredSessionStep {
|
|
|
41
46
|
readonly durableSession: DurableSession;
|
|
42
47
|
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
43
48
|
}
|
|
49
|
+
/** A {@link RestoredSessionStep} with the history, so its publication sees a whole session. */
|
|
50
|
+
export interface RestoredSessionHistoryStep extends RestoredSessionStep {
|
|
51
|
+
readonly history: HarnessModelMessage[];
|
|
52
|
+
}
|
|
44
53
|
export declare function restoreSessionStep(step: SessionStepState): Promise<RestoredSessionStep>;
|
|
45
|
-
/**
|
|
46
|
-
|
|
54
|
+
/**
|
|
55
|
+
* What a session step publishes, and how it changes the session the
|
|
56
|
+
* publication leaves. `S` is a {@link HarnessSession} only for a step
|
|
57
|
+
* restored with its history.
|
|
58
|
+
*/
|
|
59
|
+
export interface SessionStepPublication<T, R, S extends HarnessSessionBase = HarnessSessionBase> {
|
|
47
60
|
readonly origin: SessionEventOrigin;
|
|
48
61
|
/** Where a relayed input batch came from; the channel adapter and its forwarding see it. */
|
|
49
62
|
readonly inputSource?: string;
|
|
50
63
|
/** Emits the step's events in the session's context scope. */
|
|
51
|
-
publish(emit: HandleEventFn, session:
|
|
64
|
+
publish(emit: HandleEventFn, session: S): Promise<T>;
|
|
52
65
|
/**
|
|
53
66
|
* Changes the step makes to the session once the scope has committed it,
|
|
54
67
|
* before its continuation token is reconciled.
|
|
55
68
|
*/
|
|
56
|
-
updateSession?(session:
|
|
69
|
+
updateSession?(session: S, published: T): SessionUpdate<R, S>;
|
|
57
70
|
}
|
|
58
71
|
/** The session a step keeps, and anything it derived while changing it. */
|
|
59
|
-
export interface SessionUpdate<R> {
|
|
60
|
-
readonly session:
|
|
72
|
+
export interface SessionUpdate<R, S extends HarnessSessionBase = HarnessSessionBase> {
|
|
73
|
+
readonly session: S;
|
|
61
74
|
readonly result?: R;
|
|
62
75
|
}
|
|
63
76
|
/**
|
|
64
77
|
* Publishes from a step that owns the session. Returns the context and session
|
|
65
78
|
* state to adopt, and the result of `updateSession`. `step.ctx` is updated in place.
|
|
79
|
+
* The history is published and returned only when the step was restored with it.
|
|
66
80
|
*/
|
|
81
|
+
export declare function publishFromSessionStep<T, R = undefined>(step: RestoredSessionHistoryStep, publication: SessionStepPublication<T, R, HarnessSession>): Promise<{
|
|
82
|
+
readonly published: PublishedSessionEvents & {
|
|
83
|
+
readonly history: HarnessModelMessage[];
|
|
84
|
+
};
|
|
85
|
+
readonly result: R | undefined;
|
|
86
|
+
}>;
|
|
67
87
|
export declare function publishFromSessionStep<T, R = undefined>(step: RestoredSessionStep, publication: SessionStepPublication<T, R>): Promise<{
|
|
68
88
|
readonly published: PublishedSessionEvents;
|
|
69
89
|
readonly result: R | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{ParentSessionKey,TurnDeliveryIdsKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState}from"#harness/emission.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{activeTurnId}from"#harness/active-turn-id.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{ParentSessionKey,TurnDeliveryIdsKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{validateHarnessModelMessages}from"#harness/messages.js";import{getHarnessEmissionState}from"#harness/emission.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{activeTurnId}from"#harness/active-turn-id.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{withContextScope}from"#context/run-step.js";import{forwardSessionInput}from"#execution/forward-session-input.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";const log=createLogger(`execution.publish-session-events`);async function publishSessionEvents(e,t){return await publishEventsFromStep(e,`own`,t)}async function relaySessionEvents(e,t){return await publishEventsFromStep(e,`relayed`,t)}async function publishEventsFromStep(e,t,n){if(n.length===0)return{serializedContext:e.serializedContext,sessionState:e.sessionState};let{published:r}=await publishFromSessionStep(await restoreSessionStep(e),{origin:t,async publish(e){for(let t of n)await e(t)}});return r}async function restoreSessionStep(e){return{ctx:await deserializeContext(e.serializedContext),durableSession:readDurableSession(e.sessionState),sessionWritable:e.sessionWritable}}async function publishFromSessionStep(e,t){let{ctx:n}=e,r=await publishInSessionScope(e,t),i=t.updateSession?.(r.session,r.result)??{session:r.session},a=reconcileSessionContinuationToken(n,i.session);return{published:{serializedContext:serializeContext(n),sessionState:createDurableSessionState({session:a}),...`history`in a&&{history:a.history}},result:i.result}}async function publishInSessionScope(e,t){let{ctx:n}=e,r=resolveEffectiveAgentRuntime(n.require(BundleKey),n),i=hydrateDurableSession({compactionOverrides:{thresholdPercent:r.thresholdPercent},durable:e.durableSession,turnAgent:r.turnAgent}),a=e.history===void 0?i:{...i,history:validateHarnessModelMessages(e.history)},o=t.origin===`own`?bindSessionInstrumentation({agentName:r.turnAgent.id,ctx:n,rootSessionId:a.rootSessionId??a.sessionId,sessionId:a.sessionId}):void 0,s=openSessionEventPublisher({ctx:n,inputSource:t.inputSource,origin:t.origin,sessionWritable:e.sessionWritable});try{return await withContextScope(n,a,async n=>{let r=o?.createHandleEvent({handleEvent:s.publish,turnId:activeTurnId(getHarnessEmissionState(e.durableSession.state))})??s.publish;return{result:await t.publish(r,n),session:n}})}finally{await o?.flush(),s.writer.release()}}function openSessionEventPublisher(e){let{ctx:t,origin:n}=e,r=createSessionEventDispatcher(e),i=openSessionEventWriter({deliveryIds:()=>n===`own`?t.get(TurnDeliveryIdsKey):void 0,sessionWritable:e.sessionWritable}),emit=async e=>await i.write(await r.deliver(e));return{dispatcher:r,writer:i,emit,async publish(e){await r.runHooks(await emit(e))}}}function createSessionEventDispatcher(e){let{ctx:t,inputSource:n}=e,r=t.require(ChannelKey),i=buildAdapterContext(r,t);return{adapterCtx:i,async deliver(e){let a=await forwardSessionInput(t,e,n)?e:await callAdapterEventHandler(r,e,n===void 0?i:{...i,inputSource:n});return setChannelContext(t,{...r,state:{...i.state}}),a},async runHooks(e,n){await dispatchStreamEventHooks({cancelTurn:n,ctx:t,event:e,registry:t.require(BundleKey).hookRegistry})}}}function openSessionEventWriter(e){let t=e.sessionWritable.getWriter(),n=!1,release=()=>{n||(n=!0,t.releaseLock())};return{async write(n){let r=stampMessageStreamEvent(n,e.deliveryIds());return await t.write(encodeMessageStreamEvent(r)),r},close:async()=>{await t.close(),release()},release}}async function publishTerminalSessionEvent(e){let t=e.serializedContext[`eve.sessionId`]??``,n={errorId:e.errorId,sessionId:t},{type:r}=e.event,i,a;try{i=await deserializeContext(e.serializedContext),a=openSessionEventPublisher({ctx:i,origin:`own`,sessionWritable:e.sessionWritable})}catch(t){log.error(`failed to restore context for terminal ${r} event`,{...n,error:t}),await writeUnroutedSessionEvent(e.sessionWritable,e.event).catch(e=>log.error(`failed to write terminal ${r} event`,{...n,error:e}));return}let publish=async e=>{await a.emit(e)},o;try{o=bindSessionInstrumentation({agentName:i.require(BundleKey).turnAgent.id,ctx:i,rootSessionId:i.get(ParentSessionKey)?.rootSessionId??t,sessionId:t})}catch(e){log.error(`failed to bind instrumentation for terminal ${r} event`,{...n,error:e})}let s=o?.createHandleEvent({handleEvent:publish,turnId:e.turnId})??publish;try{await contextStorage.run(i,()=>s(e.event))}catch(e){log.error(`failed to publish terminal ${r} event`,{...n,error:e})}finally{a.writer.release();try{await o?.flush()}catch(e){log.error(`failed to flush instrumentation after terminal ${r} event`,{...n,error:e})}}}async function writeUnroutedSessionEvent(e,t){let n=openSessionEventWriter({deliveryIds:()=>void 0,sessionWritable:e});try{await n.write(t)}finally{n.release()}}export{openSessionEventPublisher,publishFromSessionStep,publishSessionEvents,publishTerminalSessionEvent,relaySessionEvents,restoreSessionStep};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ContextAccessor } from "#context/key.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HarnessSessionBase } from "#harness/types.js";
|
|
3
3
|
/** Re-stamps a session after a channel handler selects a new current continuation address. */
|
|
4
|
-
export declare function reconcileSessionContinuationToken(ctx: ContextAccessor, session:
|
|
4
|
+
export declare function reconcileSessionContinuationToken<S extends HarnessSessionBase>(ctx: ContextAccessor, session: S): S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConversationContextKey}from"#shared/conversation-context.js";import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationHookTokensKey,ContinuationTokenKey,ConversationIdKey,DynamicSubagentAgentConfigKey,InitiatorAuthKey,LegacyRemoteAgentCallerKey,ParentSessionKey,ParentTraceContextKey,ScheduleIdKey,SessionCallbackKey,SessionTitleKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{resolveInstrumentationEnvironment}from"#internal/application/dev-environment.js";import{readConversationId}from"#shared/conversation-identity.js";import{setChannelContext}from"#execution/channel-context.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{buildConversationContext}from"#channel/conversation-context.js";function buildRunContext(e){let{bundle:t,run:n}=e,r=new ContextContainer,i=n.auth,a=readConversationId(n.conversationId);if(a!==void 0&&r.set(ConversationIdKey,a),r.set(BundleKey,t),setChannelContext(r,n.adapter,{channelName:n.channelName}),r.set(ConversationContextKey,buildConversationContext(n,resolveInstrumentationEnvironment())),n.parent===void 0){let e=deriveSessionTitle(n.title??n.input.message);e!==void 0&&r.set(SessionTitleKey,e)}if(n.channelMetadata!==void 0){let e=r.get(ChannelInstrumentationKey);r.set(ChannelInstrumentationKey,{channelType:e?.channelType??n.channelMetadata.channelType,kind:e?.kind??n.channelMetadata.kind,metadata:n.channelMetadata.metadata})}n.continuationToken!==void 0&&(r.set(ContinuationTokenKey,n.continuationToken),r.set(ContinuationHookTokensKey,[n.continuationToken])),r.set(AuthKey,i),(n.initiatorAuth!==void 0||n.input.message!==void 0)&&r.set(InitiatorAuthKey,n.initiatorAuth??i),e.dynamicSubagentAgentConfig!==void 0&&r.set(DynamicSubagentAgentConfigKey,e.dynamicSubagentAgentConfig),n.capabilities!==void 0&&r.set(CapabilitiesKey,n.capabilities),n.requestId!==void 0&&r.set(ChannelRequestIdKey,n.requestId);let o=contextStorage.getStore()?.get(ScheduleIdKey);return o!==void 0&&r.set(ScheduleIdKey,o),n.delivery!==void 0&&r.set(ChannelDeliveryKey,n.delivery),n.callback!==void 0&&r.set(SessionCallbackKey,n.callback),n.legacyRemoteAgentCaller!==void 0&&r.set(LegacyRemoteAgentCallerKey,n.legacyRemoteAgentCaller),n.parent!==void 0&&r.set(ParentSessionKey,n.parent),n.parentTraceContext!==void 0&&r.set(ParentTraceContextKey,n.parentTraceContext),r}export{buildRunContext};
|
|
1
|
+
import{ConversationContextKey}from"#shared/conversation-context.js";import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationHookTokensKey,ContinuationTokenKey,ConversationIdKey,DynamicSubagentAgentConfigKey,InitiatorAuthKey,LegacyRemoteAgentCallerKey,ParentSessionKey,ParentTraceContextKey,ScheduleIdKey,SessionCallbackKey,SessionTitleKey,TraceRootKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{resolveInstrumentationEnvironment}from"#internal/application/dev-environment.js";import{readConversationId}from"#shared/conversation-identity.js";import{setChannelContext}from"#execution/channel-context.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{buildConversationContext}from"#channel/conversation-context.js";function buildRunContext(e){let{bundle:t,run:n}=e,r=new ContextContainer,i=n.auth,a=readConversationId(n.conversationId);if(a!==void 0&&r.set(ConversationIdKey,a),r.set(BundleKey,t),setChannelContext(r,n.adapter,{channelName:n.channelName}),r.set(ConversationContextKey,buildConversationContext(n,resolveInstrumentationEnvironment())),n.parent===void 0||n.traceRoot?.kind===`own`){let e=deriveSessionTitle(n.title??n.input.message);e!==void 0&&r.set(SessionTitleKey,e)}if(n.channelMetadata!==void 0){let e=r.get(ChannelInstrumentationKey);r.set(ChannelInstrumentationKey,{channelType:e?.channelType??n.channelMetadata.channelType,kind:e?.kind??n.channelMetadata.kind,metadata:n.channelMetadata.metadata})}n.continuationToken!==void 0&&(r.set(ContinuationTokenKey,n.continuationToken),r.set(ContinuationHookTokensKey,[n.continuationToken])),r.set(AuthKey,i),(n.initiatorAuth!==void 0||n.input.message!==void 0)&&r.set(InitiatorAuthKey,n.initiatorAuth??i),e.dynamicSubagentAgentConfig!==void 0&&r.set(DynamicSubagentAgentConfigKey,e.dynamicSubagentAgentConfig),n.capabilities!==void 0&&r.set(CapabilitiesKey,n.capabilities),n.requestId!==void 0&&r.set(ChannelRequestIdKey,n.requestId);let o=contextStorage.getStore()?.get(ScheduleIdKey);return o!==void 0&&r.set(ScheduleIdKey,o),n.delivery!==void 0&&r.set(ChannelDeliveryKey,n.delivery),n.callback!==void 0&&r.set(SessionCallbackKey,n.callback),n.legacyRemoteAgentCaller!==void 0&&r.set(LegacyRemoteAgentCallerKey,n.legacyRemoteAgentCaller),n.parent!==void 0&&r.set(ParentSessionKey,n.parent),n.traceRoot!==void 0&&r.set(TraceRootKey,n.traceRoot),n.parentTraceContext!==void 0&&r.set(ParentTraceContextKey,n.parentTraceContext),r}export{buildRunContext};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { DeliverHookPayload, TurnCaller } from "#channel/types.js";
|
|
2
|
+
import { type SteeringOptions } from "#execution/session/input-queue.js";
|
|
3
|
+
import type { SessionExecutionInput } from "#execution/session/turn.js";
|
|
4
|
+
import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
|
|
5
|
+
import type { RuntimeActionResult } from "#shared/action-types.js";
|
|
6
|
+
export type RuntimeEvent = {
|
|
7
|
+
readonly kind: "runtime-action-result";
|
|
8
|
+
readonly results: readonly RuntimeActionResult[];
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: "workflow";
|
|
11
|
+
readonly message: WorkflowToolRunMessage;
|
|
12
|
+
}
|
|
13
|
+
/** A steering message that answered no pending request arrived during the wait. */
|
|
14
|
+
| {
|
|
15
|
+
readonly kind: "steering";
|
|
16
|
+
}
|
|
17
|
+
/** A `task_wait` call's timeout passed. */
|
|
18
|
+
| {
|
|
19
|
+
readonly kind: "timeout";
|
|
20
|
+
readonly callId: string;
|
|
21
|
+
}
|
|
22
|
+
/** A delivery or sign-in callback was admitted; a held request may be answered. */
|
|
23
|
+
| {
|
|
24
|
+
readonly kind: "input";
|
|
25
|
+
} | "cancelled";
|
|
26
|
+
/**
|
|
27
|
+
* Admission policy, cancellation, and steering for one active turn.
|
|
28
|
+
* Deliveries admitted while a model step runs stay in the shared queue until
|
|
29
|
+
* the turn reaches a committed boundary; a runtime-action wait routes them
|
|
30
|
+
* eagerly so a proxied child can receive the answer it is blocked on.
|
|
31
|
+
*
|
|
32
|
+
* The pump signals cancellation and eligible steering immediately. Cancellation
|
|
33
|
+
* aborts the turn; steering only interrupts generation before assistant output
|
|
34
|
+
* or local tool execution. Both retain ordered admission at the next boundary.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ActiveTurn {
|
|
37
|
+
private readonly admitted;
|
|
38
|
+
private readonly routedToChildren;
|
|
39
|
+
private readonly runtimeResults;
|
|
40
|
+
private readonly controller;
|
|
41
|
+
private readonly expectedTurnId;
|
|
42
|
+
private readonly input;
|
|
43
|
+
/** Who alone steers the turn: its principal, or its delegated caller. */
|
|
44
|
+
private readonly identity;
|
|
45
|
+
private readonly unsubscribe;
|
|
46
|
+
private unsubscribeDelivery;
|
|
47
|
+
private steeringController;
|
|
48
|
+
/** The delegated caller of the latest message the turn read. */
|
|
49
|
+
caller: TurnCaller | undefined;
|
|
50
|
+
constructor(input: SessionExecutionInput, owner: {
|
|
51
|
+
readonly caller: TurnCaller | undefined;
|
|
52
|
+
readonly principal: string;
|
|
53
|
+
});
|
|
54
|
+
private readonly signalSteering;
|
|
55
|
+
get signal(): AbortSignal;
|
|
56
|
+
dispose(): void;
|
|
57
|
+
get steeringSignal(): AbortSignal;
|
|
58
|
+
private resetSteering;
|
|
59
|
+
/** Admits everything the pump accepted while the last step ran. */
|
|
60
|
+
admitBoundary(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Steering admitted during this turn, routed to children first and coalesced.
|
|
63
|
+
* The next step reads it as input, so its signal must not interrupt that
|
|
64
|
+
* step; only deliveries still unread re-signal the next generation.
|
|
65
|
+
*/
|
|
66
|
+
takeSteering(options?: SteeringOptions): Promise<DeliverHookPayload | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* Removes the admitted run messages the session applies at once instead of
|
|
69
|
+
* in a runtime wait, or only those of `kind`.
|
|
70
|
+
*/
|
|
71
|
+
takeBoundaryMessages(kind?: "agent-started"): WorkflowToolRunMessage[];
|
|
72
|
+
/**
|
|
73
|
+
* Next runtime result, workflow message, steering, or timeout, admitting
|
|
74
|
+
* inbox traffic while waiting. Deliveries admitted before the wait began are
|
|
75
|
+
* routed first, so a message that arrived as the calls started still steers.
|
|
76
|
+
* `timers` are durable sleeps raced against the inbox.
|
|
77
|
+
*/
|
|
78
|
+
nextRuntimeEvent(timers: readonly Promise<string>[]): Promise<RuntimeEvent>;
|
|
79
|
+
/**
|
|
80
|
+
* Takes one admitted delivery that answers a pending input request, from any
|
|
81
|
+
* responder: an approver need not be the turn's own person. Returns
|
|
82
|
+
* `undefined` when no admitted delivery answers one.
|
|
83
|
+
*/
|
|
84
|
+
takeInputResponses(requestIds: ReadonlySet<string>): DeliverHookPayload | undefined;
|
|
85
|
+
/** Resolves with the id of the call whose timer won, or `undefined` once inbox input is ready. */
|
|
86
|
+
private waitForInboxOrTimer;
|
|
87
|
+
private cancelsThisTurn;
|
|
88
|
+
/** Admits one payload; returns whether it was a delivery or sign-in callback. */
|
|
89
|
+
private admit;
|
|
90
|
+
/**
|
|
91
|
+
* During a runtime wait, descendant-bound answers cannot wait for the
|
|
92
|
+
* boundary. Returns whether a newly routed delivery still steers: it
|
|
93
|
+
* answered nothing, so its message is for the model.
|
|
94
|
+
*/
|
|
95
|
+
private routeAdmittedToChildren;
|
|
96
|
+
private abort;
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{coalesceDeliveries}from"#harness/messages.js";import{activeTurnId}from"#harness/active-turn-id.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{admitSessionInboxPayload}from"#execution/session/admission.js";import{isSteeringMessage}from"#execution/session/input-queue.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";import{decodeSessionInboxPayload}from"#execution/session-inbox/protocol.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";var ActiveTurn=class{admitted=new Set;routedToChildren=new Set;runtimeResults=[];controller=new AbortController;expectedTurnId;input;identity;unsubscribe;unsubscribeDelivery;steeringController=new AbortController;caller;constructor(e,t){this.input=e,this.caller=t.caller,this.identity={callerCallId:t.caller?.callId,principal:t.principal},this.expectedTurnId=activeTurnId(e.cursor.sessionState.emissionState),this.unsubscribe=e.inbox.onInterrupt(e=>{this.cancelsThisTurn(e)&&this.abort()}),this.unsubscribeDelivery=e.inbox.onDelivery(this.signalSteering)}signalSteering=e=>{let t;try{t=decodeSessionInboxPayload(e)}catch{return}t.kind===`deliver`&&isSteeringMessage(t,this.identity)&&!this.input.cursor.sessionState.hasProxyInputRequests&&this.steeringController.abort()};get signal(){return this.controller.signal}dispose(){this.unsubscribe(),this.unsubscribeDelivery()}get steeringSignal(){return this.steeringController.signal}resetSteering(){this.steeringController.signal.aborted&&(this.unsubscribeDelivery(),this.steeringController=new AbortController,this.unsubscribeDelivery=this.input.inbox.onDelivery(this.signalSteering))}async admitBoundary(){let e=this.input.inbox.drain();for(let t of e)await this.admit(t)}async takeSteering(e){let t=[];for(;;){let n=this.input.queue.takeSteering(this.admitted,this.identity,e);if(n===void 0)break;for(let e of n.sequences)this.admitted.delete(e);let r=await routeSelectedDelivery(n,this.input.cursor);if(r.kind===`cancel-turn`){this.abort();break}r.kind===`turn`&&t.push(r.delivery)}if(this.resetSteering(),t.length===0)return;let n=t.length===1?t[0]:coalesceDeliveries(t);return n.caller!==void 0&&(this.caller=n.caller),n}takeBoundaryMessages(e){let t=[],n=[];for(let r of this.runtimeResults){let i=asBoundaryMessage(r);i===void 0||e!==void 0&&i.kind!==e?n.push(r):t.push(i)}return this.runtimeResults.splice(0,this.runtimeResults.length,...n),t}async nextRuntimeEvent(e){for(;;){let t=await this.routeAdmittedToChildren();if(this.signal.aborted)return`cancelled`;if(t)return{kind:`steering`};let n=this.runtimeResults.shift();if(n!==void 0)return n;let r=await this.waitForInboxOrTimer(e);if(r!==void 0)return{callId:r,kind:`timeout`};let i=await this.input.inbox.next();if(i===void 0)throw Error(`Session inbox closed before runtime actions completed.`);if(await this.admit(i))return{kind:`input`}}}takeInputResponses(e){for(let t of this.admitted){let n=this.input.queue.delivery(t);if(n!==void 0&&n.payloads.some(t=>t.inputResponses?.some(t=>e.has(t.requestId))))return this.admitted.delete(t),this.input.queue.replaceDelivery(t,void 0),n}}async waitForInboxOrTimer(e){if(e.length===0||this.input.inbox.hasPending())return;let t=this.input.inbox.whenPending().then(()=>void 0);return await Promise.race([t,...e])}cancelsThisTurn(e){return e.kind===`reset`?!0:e.kind===`cancel`?e.turnId===void 0||e.turnId===this.expectedTurnId:!1}async admit(e){let t=await admitSessionInboxPayload(e,this.input);switch(t.kind){case`delivery`:return this.admitted.add(t.admission.sequence),!0;case`runtime-action-result`:return this.runtimeResults.push({kind:`runtime-action-result`,results:t.payload.results}),!1;case`workflow`:return this.runtimeResults.push({kind:`workflow`,message:t.message}),!1;case`cancel`:return this.cancelsThisTurn(e)&&this.abort(),!1;case`consumed`:return e.kind===`authorization-callback`}}async routeAdmittedToChildren(){let e=!1;for(let t of this.admitted){if(this.routedToChildren.has(t))continue;let n=this.input.queue.delivery(t);if(n===void 0){this.admitted.delete(t);continue}this.routedToChildren.add(t);let r=await this.input.cursor.advance(e=>routeDeliverToChildren({delivery:n,...e}));if(r.kind===`cancel-turn`)return this.input.queue.replaceDelivery(t,void 0),this.admitted.delete(t),this.abort(),!1;if(this.input.queue.replaceDelivery(t,r.remainder),r.remainder===void 0){this.admitted.delete(t);continue}isSteeringMessage(r.remainder,this.identity)&&(e=!0)}return e}abort(){this.controller.signal.aborted||this.controller.abort(new TurnCancelledError)}};function asBoundaryMessage(e){if(e!==`cancelled`&&e.kind===`workflow`&&(e.message.from.taskId!==void 0||e.message.kind===`agent-started`))return e.message}export{ActiveTurn};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SessionCheckpoint } from "#execution/session/handoff.js";
|
|
2
|
+
/**
|
|
3
|
+
* Oldest checkpoint a successor upgrades (eve 0.66.0). Earlier checkpoints
|
|
4
|
+
* predate the sandbox provider and dynamic skill manifest contracts and lack
|
|
5
|
+
* data the current reader requires.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MIN_SESSION_CHECKPOINT_VERSION = 8;
|
|
8
|
+
export type SessionCheckpointMigration = {
|
|
9
|
+
readonly kind: "current";
|
|
10
|
+
readonly checkpoint: SessionCheckpoint;
|
|
11
|
+
/** Idle child sessions the current build no longer tracks; the successor stops them. */
|
|
12
|
+
readonly childRunIdsToStop: readonly string[];
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "incompatible";
|
|
15
|
+
readonly detail: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Upgrades a checkpoint written by an older eve build to the current shape.
|
|
19
|
+
* Pure, so the session workflow can run it before validation. Newer
|
|
20
|
+
* checkpoints and those older than {@link MIN_SESSION_CHECKPOINT_VERSION} are
|
|
21
|
+
* incompatible.
|
|
22
|
+
*/
|
|
23
|
+
export declare function migrateSessionCheckpoint(checkpoint: unknown): SessionCheckpointMigration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject}from"#shared/guards.js";import{SESSION_CHECKPOINT_VERSION}from"#execution/session/handoff.js";const MIN_SESSION_CHECKPOINT_VERSION=8,CHECKPOINT_UPGRADES={8:e=>{let{mode:t,...n}=e;return{...n,serializedContext:omitKeys(readRecord(n,`serializedContext`),[`eve.mode`])}},9:(e,t)=>{let n=readRecord(e,`sessionState`),r=readRecord(n,`snapshot`),{taskId:i,...a}=readRecord(r,`session`);return{...e,serializedContext:upgradeLegacyCaller(omitKeys(readRecord(e,`serializedContext`),[`eve.activityObserver`,`eve.activityPendingBlockers`,`eve.activityRootTurnId`,`eve.connectionSearchResults`,`eve.internal.backgroundToolExecution`,`eve.runtime.taskDeliveryPolicy`,`eve.turnTaskDelivery`])),sessionState:{...n,snapshot:{...r,session:{...a,history:readArray(a,`history`).map(renameBackgroundTaskMessage),state:upgradeSessionState(a.state,t)}}}}},10:e=>{let t=readRecord(e,`sessionState`),n=readRecord(t,`snapshot`),{history:r,...i}=readRecord(n,`session`);return t.version!==1&&refuse(`durable session version is not 1`),Array.isArray(r)||refuse(`session history is missing`),{...e,history:r,sessionState:{...t,snapshot:{...n,session:i},version:2}}}};function migrateSessionCheckpoint(e){if(!isObject(e))return{kind:`incompatible`,detail:`checkpoint is not an object`};let{version:t}=e;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<8||t>SESSION_CHECKPOINT_VERSION)return{kind:`incompatible`,detail:`checkpoint version ${JSON.stringify(t)} is outside the supported range 8-${SESSION_CHECKPOINT_VERSION}`};let n={childRunIdsToStop:[]},r=e;try{for(let e=t;e<SESSION_CHECKPOINT_VERSION;e++){let t=CHECKPOINT_UPGRADES[e];t===void 0&&refuse(`no upgrade from checkpoint version ${e}`),r={...t(r,n),version:e+1}}}catch(e){if(!(e instanceof CheckpointRefusal))throw e;return{kind:`incompatible`,detail:`checkpoint version ${t}: ${e.message}`}}return isCurrentCheckpoint(r)?{kind:`current`,checkpoint:r,childRunIdsToStop:n.childRunIdsToStop}:{kind:`incompatible`,detail:`checkpoint version ${t} is incomplete`}}function isCurrentCheckpoint(e){return isObject(e)&&e.version===SESSION_CHECKPOINT_VERSION&&Array.isArray(e.history)&&isObject(e.serializedContext)&&isObject(e.sessionState)}var CheckpointRefusal=class extends Error{};function refuse(e){throw new CheckpointRefusal(e)}function readRecord(e,t){let n=e[t];return isObject(n)||refuse(`${t} is not an object`),n}function readArray(e,t){let n=e[t];return Array.isArray(n)||refuse(`${t} is not an array`),n}function omitKeys(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)))}function upgradeLegacyCaller(e){let t=e[`eve.sessionCallback`];if(!isObject(t))return e;let{taskId:n,...r}=t;return{...e,"eve.legacyRemoteAgentCaller":typeof n==`string`&&n.length>0?{taskId:n}:{},"eve.sessionCallback":r}}function renameBackgroundTaskMessage(e){return isObject(e)&&e.role===`user`&&e.kind===`execution.background_task`?{...e,kind:`task.result`}:e}function upgradeSessionState(e,t){return isObject(e)?omitKeys(e,[...dropSettledWorkflowToolRuns(e),...stopIdleSubagents(e,t)]):e}function dropSettledWorkflowToolRuns(e){let t=e[`eve.workflowTool`];if(!isObject(t)||t.version!==3)return[];let n=t.runs;return(!Array.isArray(n)||!n.every(e=>isObject(e)&&e.lifetime===`session`&&isObject(e.task)&&e.task.outcome!==void 0))&&refuse(`workflow tool run registry version 3 holds unsettled runs`),[`eve.workflowTool`]}function stopIdleSubagents(e,t){let n=e[`eve.agent.handles`];if(n===void 0)return[];(!isObject(n)||!Array.isArray(n.handles))&&refuse(`subagent handles are malformed`);for(let e of n.handles){(!isObject(e)||e.phase!==`parked`&&e.phase!==`available`)&&refuse(`a subagent session is still working`);let n=e.address;isObject(n)&&(n.kind===`agent/local`||n.kind===`agent/self`)&&typeof n.sessionId==`string`&&n.sessionId.length>0&&t.childRunIdsToStop.push(n.sessionId)}return[`eve.agent.handles`]}export{MIN_SESSION_CHECKPOINT_VERSION,migrateSessionCheckpoint};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{SESSION_INBOX_CONTEXT_KEY,sessionCommandHookToken}from"#execution/session-inbox/address.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{DEFAULT_SESSION_TIMEOUT_MS,sessionTimeoutDeadline}from"#execution/session/timeout.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{createSessionInbox}from"#execution/session-inbox/inbox.js";import{failSession,runPreparedSession}from"#execution/session/program.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";import{signalSessionOwnerActivationStep,validateSessionCheckpointStep}from"#execution/session/handoff-steps.js";async function workflowEntry(e){"use workflow";let t=e.kind===`initial`?await bootInitialOwner(e,getWorkflowMetadata().workflowRunId):await bootHandoffOwner(e);return t===void 0?{output:``}:{output:(await runPreparedSession(t.session,t.inbox)).output}}function stampSessionIdentity(e,t){return{...e,"eve.sessionId":t,[SESSION_INBOX_CONTEXT_KEY]:{sessionId:t}}}async function bootInitialOwner(e,t){let n=stampSessionIdentity(e.serializedContext,t),r=getWritable(),i=createSessionInbox(t),{workflowStartedAt:a}=getWorkflowMetadata(),o=e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS,s=n[`eve.continuationToken`]||``,c=n[`eve.bundle`];try{let[l,u,d]=await Promise.allSettled([createSessionStep({compiledArtifactsSource:c.source,continuationToken:s,dynamicSubagentAgentConfig:n[`eve.dynamicSubagentAgentConfig`],inheritedLimits:e.limits,nodeId:c.nodeId,outputSchema:e.input.outputSchema,rootSessionId:readRootSessionId(n),sessionId:t}),i.claimSessionHook(sessionCommandHookToken(t)),s===``?Promise.resolve():i.claimSessionHook(s)]);if(l.status===`rejected`)throw l.reason;if(u.status===`rejected`)throw u.reason;if(d.status===`rejected`){if(!isHookConflictError(d.reason))throw d.reason;e.continuationConflictCommand!==void 0&&await settleContinuationConflictStep({command:e.continuationConflictCommand,continuationToken:s}),await i.dispose();return}return{inbox:i,session:{anchor:{kind:`self`},caller:
|
|
1
|
+
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{SESSION_INBOX_CONTEXT_KEY,sessionCommandHookToken}from"#execution/session-inbox/address.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{DEFAULT_SESSION_TIMEOUT_MS,sessionTimeoutDeadline}from"#execution/session/timeout.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{createSessionInbox}from"#execution/session-inbox/inbox.js";import{failSession,runPreparedSession}from"#execution/session/program.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";import{signalSessionOwnerActivationStep,stopUntrackedChildSessionsStep,validateSessionCheckpointStep}from"#execution/session/handoff-steps.js";import{migrateSessionCheckpoint}from"#execution/session/checkpoint-migrations.js";async function workflowEntry(e){"use workflow";let t=e.kind===`initial`?await bootInitialOwner(e,getWorkflowMetadata().workflowRunId):await bootHandoffOwner(e);return t===void 0?{output:``}:{output:(await runPreparedSession(t.session,t.inbox)).output}}function stampSessionIdentity(e,t){return{...e,"eve.sessionId":t,[SESSION_INBOX_CONTEXT_KEY]:{sessionId:t}}}async function bootInitialOwner(e,t){let n=stampSessionIdentity(e.serializedContext,t),r=getWritable(),i=createSessionInbox(t),{workflowStartedAt:a}=getWorkflowMetadata(),o=e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS,s=n[`eve.continuationToken`]||``,c=n[`eve.bundle`];try{let[l,u,d,f]=await Promise.allSettled([createSessionStep({compiledArtifactsSource:c.source,continuationToken:s,dynamicSubagentAgentConfig:n[`eve.dynamicSubagentAgentConfig`],inheritedLimits:e.limits,nodeId:c.nodeId,outputSchema:e.input.outputSchema,rootSessionId:readRootSessionId(n),sessionId:t}),i.claimSessionHook(sessionCommandHookToken(t)),s===``?Promise.resolve():i.claimSessionHook(s),hasDelegatedSessionContext(n)?resolveInitialTurnCallerStep({serializedContext:n}):Promise.resolve(void 0)]);if(l.status===`rejected`)throw l.reason;if(u.status===`rejected`)throw u.reason;if(d.status===`rejected`){if(!isHookConflictError(d.reason))throw d.reason;e.continuationConflictCommand!==void 0&&await settleContinuationConflictStep({command:e.continuationConflictCommand,continuationToken:s}),await i.dispose();return}if(f.status===`rejected`)throw f.reason;return{inbox:i,session:{anchor:{kind:`self`},caller:f.value,capabilities:n[`eve.capabilities`],deploymentId:e.ownerDeploymentId,history:l.value.history,initialInput:createInitialDelivery(e,n),awaitFirstMessage:e.input.message===void 0,retention:e.retention,serializedContext:n,sessionId:t,sessionState:l.value.state,sessionTimeoutMs:o,sessionTimeoutDeadline:sessionTimeoutDeadline(o,a.getTime()),sessionWritable:r}}}catch(e){return await i.dispose(),await failSession({error:e,serializedContext:n,sessionId:t,sessionState:void 0,sessionWritable:r})}}async function bootHandoffOwner(e){let{sessionId:t}=e,n=createSessionInbox(t),r,i,a;try{let o=migrateSessionCheckpoint(e.checkpoint),s=await validateSessionCheckpointStep({migration:o,sessionId:t});if(o.kind===`incompatible`||s.kind===`incompatible`){let t=await n.release();await signalSessionOwnerActivationStep({activation:{kind:`incompatible`,payloads:t,reason:`checkpoint-version`},token:e.activationToken});return}({checkpoint:r,childRunIdsToStop:i}=o),a=stampSessionIdentity(r.serializedContext,t),await n.claimSessionHooks(sessionHookTokens({serializedContext:a,sessionState:r.sessionState})),await signalSessionOwnerActivationStep({activation:{kind:`active`},token:e.activationToken})}catch(t){let r=await n.release();await signalSessionOwnerActivationStep({activation:{error:normalizeSerializableError(t),kind:`failed`,payloads:r},token:e.activationToken});return}return i.length>0&&await stopUntrackedChildSessionsStep({runIds:i,sessionId:t}),{inbox:n,session:{anchor:{kind:`successor`},caller:e.delivery.caller,capabilities:r.capabilities,deploymentId:e.ownerDeploymentId,history:r.history,initialInput:e.delivery,awaitFirstMessage:!1,retention:r.retention,serializedContext:a,sessionId:t,sessionState:r.sessionState,sessionTimeoutMs:r.sessionTimeoutMs,sessionTimeoutDeadline:sessionTimeoutDeadline(r.sessionTimeoutMs,Date.now()),sessionWritable:e.sessionWritable}}}function createInitialDelivery(e,t){if(e.input.message!==void 0)return{deliveryMetadata:t[`eve.channelDelivery`]===void 0?void 0:[{...t[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:e.input.message,context:e.input.context,outputSchema:e.input.outputSchema,state:e.input.state},readClientContext(e.input))],requestId:readChannelRequestId(t)}}workflowEntry.workflowId=`workflow//eve//workflowEntry`;export{workflowEntry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{liveTaskRuns,readTaskTable}from"#execution/tasks/table.js";import{getSessionUsage,takeSessionUsageDelta}from"#harness/turn-tag-state.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";import{notifyTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";async function finalizeSession(e,t){let{serializedContext:n,sessionState:r}=t.cursor;r!==void 0&&liveTaskRuns(readTaskTable(r.snapshot?.session?.state)).length>0&&await terminateChildSessionsStep({sessionState:r});let i=r?.snapshot.session,a=i===void 0?void 0:getSessionUsage(i);e.kind===`expired`?await emitTerminalSessionCompletionStep({sessionWritable:t.sessionWritable,serializedContext:n,usage:a}):e.kind===`failed`&&await emitTerminalSessionFailureStep({error:normalizeSerializableError(e.error),sessionWritable:t.sessionWritable,serializedContext:n,turnId:e.turnId,usage:a});let o=settledResult(e,t);if(t.caller!==void 0){let e={output:o.output,usage:o.turnUsage};o.isError&&(e.isError=!0),await notifyTurnCallerStep({caller:t.caller,lifecycle:`terminal`,sessionId:r?.sessionId??n[`eve.sessionId`],settled:e})}return e.kind===`done`?{isError:e.action.isError,output:e.action.output,usage:e.action.usage,usageDelta:e.action.usageDelta}:{isError:o.isError,output:o.output,usage:o.sessionUsage,usageDelta:o.turnUsage}}function settledResult(e,t){let n=t.cursor.sessionState?.snapshot.session,r=n===void 0||t.caller===void 0?{}:{sessionUsage:getSessionUsage(n),turnUsage:takeSessionUsageDelta(n).delta};switch(e.kind){case`done`:return{isError:e.action.isError===!0,output:e.action.output,sessionUsage:e.action.usage,turnUsage:e.action.usageDelta};case`expired`:return t.caller===void 0?{isError:!1,output:``}:{isError:!0,output:`The session ended before the delegated task completed.`,...r};case`failed`:return{isError:!0,output:normalizeSerializableError(e.error),...r}}}export{finalizeSession};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { SessionCheckpointMigration } from "#execution/session/checkpoint-migrations.js";
|
|
1
2
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
-
import { type
|
|
3
|
+
import { type SessionOwnerActivation } from "#execution/session/handoff.js";
|
|
3
4
|
/** Parses retained work with this deployment's code before deciding whether it can move. */
|
|
4
5
|
export declare function isSessionStateIdleForHandoff(sessionState: DurableSessionState): boolean;
|
|
5
6
|
/** Reads durable work using the source deployment's handoff contract. */
|
|
@@ -13,14 +14,32 @@ export type SessionCheckpointValidation = {
|
|
|
13
14
|
readonly reason: "checkpoint-version";
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
|
-
* Validates
|
|
17
|
+
* Validates an upgraded checkpoint and resolves the target deployment's
|
|
18
|
+
* compiled bundle.
|
|
17
19
|
*
|
|
18
|
-
* A
|
|
19
|
-
* it returns rather than throws: retrying the step can never change it.
|
|
20
|
+
* A checkpoint this deployment cannot read is a settled answer, not a fault,
|
|
21
|
+
* so it returns rather than throws: retrying the step can never change it.
|
|
20
22
|
*/
|
|
21
23
|
export declare function validateSessionCheckpointStep(input: {
|
|
22
|
-
readonly
|
|
24
|
+
readonly migration: SessionCheckpointMigration;
|
|
25
|
+
readonly sessionId: string;
|
|
23
26
|
}): Promise<SessionCheckpointValidation>;
|
|
27
|
+
/**
|
|
28
|
+
* Stops idle subagent sessions an older owner kept resumable, after this owner
|
|
29
|
+
* activates. Best effort: a child that cannot be stopped ends at its own timeout.
|
|
30
|
+
*/
|
|
31
|
+
export declare function stopUntrackedChildSessionsStep(input: {
|
|
32
|
+
readonly runIds: readonly string[];
|
|
33
|
+
readonly sessionId: string;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
/** Records why the owner kept a session it tried to move, so a stuck handoff is visible. */
|
|
36
|
+
export declare function reportSessionHandoffRetainedStep(input: {
|
|
37
|
+
readonly error?: string;
|
|
38
|
+
readonly reason: "activation-failed" | "checkpoint-incompatible";
|
|
39
|
+
readonly sessionId: string;
|
|
40
|
+
readonly sourceDeploymentId: string;
|
|
41
|
+
readonly targetDeploymentId: string;
|
|
42
|
+
}): Promise<void>;
|
|
24
43
|
export declare function signalSessionOwnerActivationStep(input: {
|
|
25
44
|
readonly activation: SessionOwnerActivation;
|
|
26
45
|
readonly token: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject}from"#shared/guards.js";import{getSandboxEnvironmentRuntime}from"#shared/sandbox-environment.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getResolvedRuntimeAgentNode}from"#runtime/graph.js";import{readDurableSession}from"#execution/durable-session-store.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{deserializeContext}from"#context/serialize.js";import{resumeHook}from"#internal/workflow/runtime.js";import{SESSION_CHECKPOINT_VERSION}from"#execution/session/handoff.js";function isSessionStateIdleForHandoff(e){let{state:t}=readDurableSession(e),n=getBlockingWorkflowToolRuns(t);if([`eve.runtime.pendingAuthorization`,`eve.runtime.pendingInputBatch`,`eve.runtime.pendingCoordinationBatch`,`eve.runtime.deferredStepInput`,`eve.harness.pendingWorkflowInterrupt`].some(e=>t?.[e]!==void 0))return!1;let r=t?.[`eve.runtime.pendingInputBatches`];if(r!==void 0&&(!Array.isArray(r)||r.length>0))return!1;let i=t?.[`eve.runtime.proxyInputRequests`];return i!==void 0&&(!isObject(i)||Object.keys(i).length>0)?!1:n.length===0}async function isSessionIdleForHandoffStep(e){"use step";return isSessionStateIdleForHandoff(e.sessionState)}async function validateSessionCheckpointStep(e){"use step";let{
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{isObject}from"#shared/guards.js";import{walkCauseChain}from"#shared/errors.js";import{getSandboxEnvironmentRuntime}from"#shared/sandbox-environment.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{getResolvedRuntimeAgentNode}from"#runtime/graph.js";import{readDurableSession}from"#execution/durable-session-store.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{IncompatibleStateLayoutError,deserializeContext}from"#context/serialize.js";import{EntityConflictError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{cancelRun,getWorld,resumeHook}from"#internal/workflow/runtime.js";import{SESSION_CHECKPOINT_VERSION}from"#execution/session/handoff.js";const log=createLogger(`execution.handoff`);function isSessionStateIdleForHandoff(e){let{state:t}=readDurableSession(e),n=getBlockingWorkflowToolRuns(t);if([`eve.runtime.pendingAuthorization`,`eve.runtime.pendingInputBatch`,`eve.runtime.pendingCoordinationBatch`,`eve.runtime.deferredStepInput`,`eve.harness.pendingWorkflowInterrupt`].some(e=>t?.[e]!==void 0))return!1;let r=t?.[`eve.runtime.pendingInputBatches`];if(r!==void 0&&(!Array.isArray(r)||r.length>0))return!1;let i=t?.[`eve.runtime.proxyInputRequests`];return i!==void 0&&(!isObject(i)||Object.keys(i).length>0)?!1:n.length===0}async function isSessionIdleForHandoffStep(e){"use step";return isSessionStateIdleForHandoff(e.sessionState)}async function validateSessionCheckpointStep(e){"use step";let{migration:t}=e,unreadable=t=>(log.warn(`session handoff refused: this deployment cannot read the checkpoint`,{detail:t,readableCheckpointVersion:SESSION_CHECKPOINT_VERSION,sessionId:e.sessionId}),{kind:`incompatible`,reason:`checkpoint-version`});if(t.kind===`incompatible`)return unreadable(t.detail);let{checkpoint:n}=t,r=n.sessionTimeoutMs;if(r!==!1&&(typeof r!=`number`||!Number.isFinite(r)||r<0))throw Error(`Session checkpoint contains an invalid timeout duration.`);let i;try{i=await deserializeContext(n.serializedContext)}catch(e){if(e instanceof IncompatibleStateLayoutError)return unreadable(e.message);throw e}let a=i.require(BundleKey),o=readDurableSession(n.sessionState).sandboxState?.session;if(o!=null){let e=getResolvedRuntimeAgentNode(a.graph,a.nodeId).sandboxRegistry.sandbox.inheritance?.definition??getResolvedRuntimeAgentNode(a.graph,a.nodeId).sandboxRegistry.sandbox.definition;if(e.kind!==`independent`)throw Error(`Session checkpoint sandbox has no resolved provider.`);let t=getSandboxEnvironmentRuntime(e.environment);if(o.providerName!==t.providerName||o.stateProtocolVersion!==t.stateProtocolVersion)throw Error(`Session checkpoint sandbox provider state is incompatible.`)}if(!isSessionStateIdleForHandoff(n.sessionState))throw Error(`Session checkpoint contains pending work and cannot be handed off.`);return{kind:`valid`}}async function stopUntrackedChildSessionsStep(e){"use step";let t=await getWorld();for(let n of e.runIds)if(n!==e.sessionId)try{await cancelRun(t,n,{cancelReason:`Session upgraded`})}catch(t){[...walkCauseChain(t)].some(e=>EntityConflictError.is(e)||RunExpiredError.is(e)||WorkflowRunNotFoundError.is(e))||logError(log,`could not stop a subagent session after handoff`,t,{childRunId:n,sessionId:e.sessionId})}}async function reportSessionHandoffRetainedStep(e){"use step";log.warn(`session handoff failed; the current owner keeps the session`,{...e,checkpointVersion:SESSION_CHECKPOINT_VERSION})}async function signalSessionOwnerActivationStep(e){"use step";await resumeHook(e.token,e.activation)}async function signalSessionAnchorStep(e){"use step";await resumeHook(e.token,e.result)}export{isSessionIdleForHandoffStep,isSessionStateIdleForHandoff,reportSessionHandoffRetainedStep,signalSessionAnchorStep,signalSessionOwnerActivationStep,stopUntrackedChildSessionsStep,validateSessionCheckpointStep};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SessionCapabilities } from "#channel/types.js";
|
|
2
2
|
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
3
|
+
import type { HarnessModelMessage } from "#harness/messages.js";
|
|
3
4
|
import type { SessionInboxHandle, SessionInboxPayload } from "#execution/session-inbox/inbox.js";
|
|
4
5
|
import type { TurnSelection } from "#execution/session/input-queue.js";
|
|
5
6
|
import type { WorkflowEntryResult } from "#execution/session/entry-input.js";
|
|
@@ -7,15 +8,17 @@ import type { AgentWorkflowRetentionDefinition } from "#shared/agent-definition.
|
|
|
7
8
|
/**
|
|
8
9
|
* Cross-deployment checkpoint contract. The successor may run a different eve
|
|
9
10
|
* build than the owner that produced it; bump when any field changes shape so
|
|
10
|
-
* an
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* an older successor rejects the handoff instead of misreading state.
|
|
12
|
+
*
|
|
13
|
+
* A newer successor must always accept older checkpoints: every bump adds the
|
|
14
|
+
* upgrade from the previous version in `checkpoint-migrations.ts`.
|
|
13
15
|
*/
|
|
14
|
-
export declare const SESSION_CHECKPOINT_VERSION =
|
|
16
|
+
export declare const SESSION_CHECKPOINT_VERSION = 11;
|
|
15
17
|
/** Everything a successor needs to continue an idle session. Hooks are derived from the state. */
|
|
16
18
|
export interface SessionCheckpoint {
|
|
17
19
|
readonly version: typeof SESSION_CHECKPOINT_VERSION;
|
|
18
20
|
readonly capabilities?: SessionCapabilities;
|
|
21
|
+
readonly history: HarnessModelMessage[];
|
|
19
22
|
readonly retention?: AgentWorkflowRetentionDefinition;
|
|
20
23
|
readonly serializedContext: Record<string, unknown>;
|
|
21
24
|
readonly sessionState: DurableSessionState;
|
|
@@ -41,7 +44,7 @@ type SessionTransferOutcome = {
|
|
|
41
44
|
readonly reason: "same-deployment" | "missing-deployment" | "not-idle" | "busy" | "accepted-during-release" | "activation-failed" | "checkpoint-incompatible" | "known-incompatible";
|
|
42
45
|
};
|
|
43
46
|
interface SessionHandoffInput {
|
|
44
|
-
readonly checkpoint: Omit<SessionCheckpoint, "serializedContext" | "sessionState" | "version">;
|
|
47
|
+
readonly checkpoint: Omit<SessionCheckpoint, "history" | "serializedContext" | "sessionState" | "version">;
|
|
45
48
|
readonly deploymentId: string;
|
|
46
49
|
readonly inbox: SessionInboxHandle;
|
|
47
50
|
readonly isInitialOwner: boolean;
|
|
@@ -70,7 +73,7 @@ export declare class SessionHandoff {
|
|
|
70
73
|
* outcome states whether the successor activated or this owner retained the
|
|
71
74
|
* session. Candidate failures recover locally rather than escaping.
|
|
72
75
|
*/
|
|
73
|
-
tryTransfer(selection: TurnSelection, state: Pick<SessionCheckpoint, "serializedContext" | "sessionState">): Promise<SessionTransferOutcome>;
|
|
76
|
+
tryTransfer(selection: TurnSelection, state: Pick<SessionCheckpoint, "history" | "serializedContext" | "sessionState">): Promise<SessionTransferOutcome>;
|
|
74
77
|
/** After a transfer, the original run parks until the final owner reports the session result. */
|
|
75
78
|
awaitAnchoredResult(): Promise<WorkflowEntryResult>;
|
|
76
79
|
disposeAnchor(): Promise<void>;
|
|
@@ -78,6 +81,7 @@ export declare class SessionHandoff {
|
|
|
78
81
|
private startAndActivate;
|
|
79
82
|
/** Reclaims the exact hook set and replays payloads accepted while it was released. */
|
|
80
83
|
private recover;
|
|
84
|
+
private reportRetained;
|
|
81
85
|
private ensureAnchor;
|
|
82
86
|
}
|
|
83
87
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionHandoffMarkerToken}from"#execution/session-inbox/address.js";import{startSessionOwnerStep}from"#execution/workflow-runtime.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook}from"#execution/hook-ownership.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{isSessionIdleForHandoffStep}from"#execution/session/handoff-steps.js";import{readAcceptedDeploymentId}from"#execution/session/accepted-deployment.js";const SESSION_CHECKPOINT_VERSION=
|
|
1
|
+
import{isObject}from"#shared/guards.js";import{sessionHandoffMarkerToken}from"#execution/session-inbox/address.js";import{startSessionOwnerStep}from"#execution/workflow-runtime.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook}from"#execution/hook-ownership.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{isSessionIdleForHandoffStep,reportSessionHandoffRetainedStep}from"#execution/session/handoff-steps.js";import{readAcceptedDeploymentId}from"#execution/session/accepted-deployment.js";const SESSION_CHECKPOINT_VERSION=11;function sessionAnchorToken(e){return`${e}:anchor`}var SessionHandoff=class{input;anchor;incompatibleTargetDeploymentIds=new Set;constructor(e){this.input=e}async tryTransfer(e,t){let{deploymentId:n,inbox:r}=this.input,i=readAcceptedDeploymentId(e.delivery);if(i===void 0)return{kind:`retained`,reason:`missing-deployment`};if(i===n)return{kind:`retained`,reason:`same-deployment`};if(this.incompatibleTargetDeploymentIds.has(i))return{kind:`retained`,reason:`known-incompatible`};if(!e.handoffEligible)return{kind:`retained`,reason:`busy`};if(!await isSessionIdleForHandoffStep({sessionState:t.sessionState}))return{kind:`retained`,reason:`not-idle`};let a={...this.input.checkpoint,...t,version:11},o=sessionHookTokens(t);await this.ensureAnchor();let s=o.map(e=>createHook({token:sessionHandoffMarkerToken(e)}));await Promise.all(s.map(e=>claimHookOwnership(e)));let c;try{let t=await r.release();if(t.length>0)return await this.recover(o,t),{kind:`retained`,reason:`accepted-during-release`};let n=[];try{let t=await this.startAndActivate(a,e.delivery,i);if(t.kind===`active`)return{kind:`transferred`};n=t.payloads,t.kind===`incompatible`?(this.incompatibleTargetDeploymentIds.add(i),c={reason:`checkpoint-incompatible`}):c={error:t.error,reason:`activation-failed`}}catch(e){c={error:e,reason:`activation-failed`}}await this.recover(o,n)}finally{await Promise.all(s.map(e=>disposeHook(e)))}return await this.reportRetained(c.reason,i,c.error),{kind:`retained`,reason:c.reason}}async awaitAnchoredResult(){if(this.anchor===void 0)throw Error(`Session anchor was never claimed.`);try{return await this.anchor}finally{await this.disposeAnchor()}}async disposeAnchor(){if(this.anchor===void 0)return;let e=this.anchor;this.anchor=void 0,await disposeHook(e)}async startAndActivate(e,t,n){let r=createHook({token:`${getWorkflowMetadata().workflowRunId}:handoff`});await claimHookOwnership(r);try{return await startSessionOwnerStep({activationToken:r.token,anchorRunId:this.input.sessionId,checkpoint:e,delivery:t,targetDeploymentId:n}),await r}finally{await disposeHook(r)}}async recover(e,t){await this.input.inbox.claimSessionHooks(e),this.input.inbox.restore(t)}async reportRetained(e,t,n){let r=isObject(n)&&typeof n.message==`string`?n.message:void 0;await reportSessionHandoffRetainedStep({error:r,reason:e,sessionId:this.input.sessionId,sourceDeploymentId:this.input.deploymentId,targetDeploymentId:t})}async ensureAnchor(){this.input.isInitialOwner&&this.anchor===void 0&&(this.anchor=createHook({token:sessionAnchorToken(this.input.sessionId)}),await claimHookOwnership(this.anchor))}};export{SESSION_CHECKPOINT_VERSION,SessionHandoff,sessionAnchorToken};
|
|
@@ -19,9 +19,6 @@ export interface TurnSelection {
|
|
|
19
19
|
export type SessionInputSelection = TurnSelection | {
|
|
20
20
|
readonly control: SessionControl;
|
|
21
21
|
readonly kind: "control";
|
|
22
|
-
} | {
|
|
23
|
-
readonly kind: "authorization-resume";
|
|
24
|
-
readonly payloads: readonly DeliverPayload[];
|
|
25
22
|
};
|
|
26
23
|
/**
|
|
27
24
|
* Ordered, admitted session input. Entries are private; callers receive typed
|
|
@@ -36,21 +33,22 @@ export declare class SessionInputQueue {
|
|
|
36
33
|
enqueueControl(control: SessionControl): void;
|
|
37
34
|
/** Keeps one payload per authorization attempt; a repeated callback for the same attempt is dropped. */
|
|
38
35
|
enqueueAuthorization(payloads: readonly DeliverPayload[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* Removes and returns the queued callbacks for `attemptIds` once every one
|
|
38
|
+
* has arrived, so a turn holding several sign-ins resumes when all are done.
|
|
39
|
+
*/
|
|
40
|
+
takeAuthorizations(attemptIds: ReadonlySet<string>): DeliverPayload[] | undefined;
|
|
39
41
|
delivery(sequence: number): DeliverHookPayload | undefined;
|
|
40
42
|
replaceDelivery(sequence: number, delivery: DeliverHookPayload | undefined): void;
|
|
41
|
-
takeSteering(admitted: ReadonlySet<number>, turn: SteeringTurn): TurnSelection | undefined;
|
|
43
|
+
takeSteering(admitted: ReadonlySet<number>, turn: SteeringTurn, options?: SteeringOptions): TurnSelection | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Takes the next turn or control. Sign-ins end with the turn that raised
|
|
46
|
+
* them, so a callback still queued between turns is stale and dropped.
|
|
47
|
+
*/
|
|
42
48
|
takeNext(options?: {
|
|
43
|
-
/**
|
|
44
|
-
* Attempt ids of the open authorization challenge. Callbacks for other
|
|
45
|
-
* attempts are stale and dropped; once every expected attempt has
|
|
46
|
-
* reported, the collected payloads resume the challenge ahead of
|
|
47
|
-
* ordinary input.
|
|
48
|
-
*/
|
|
49
|
-
readonly expectedAttemptIds?: ReadonlySet<string>;
|
|
50
49
|
/** Sequence of a delivery admitted while nothing else was pending. */
|
|
51
50
|
readonly freshSequence?: number;
|
|
52
51
|
}): SessionInputSelection | undefined;
|
|
53
|
-
private takeSelectionAt;
|
|
54
52
|
/**
|
|
55
53
|
* Consecutive deliveries of one authenticated principal and one delegated
|
|
56
54
|
* call share a turn, as they would steer it. Claims may change between
|
|
@@ -65,11 +63,19 @@ export interface SteeringTurn {
|
|
|
65
63
|
readonly callerCallId: string | undefined;
|
|
66
64
|
readonly principal: string;
|
|
67
65
|
}
|
|
66
|
+
export interface SteeringOptions {
|
|
67
|
+
/**
|
|
68
|
+
* The turn waits on its own person for a sign-in or approval. Their message
|
|
69
|
+
* steers even with `turnPolicy: "queue"`: queued, it would wait for a turn
|
|
70
|
+
* that cannot end until they act.
|
|
71
|
+
*/
|
|
72
|
+
readonly heldOnPerson?: boolean;
|
|
73
|
+
}
|
|
68
74
|
/**
|
|
69
75
|
* Only the turn's own principal steers it; another principal's message waits
|
|
70
76
|
* for the turn to end. A delivery without auth acts as the session's current
|
|
71
77
|
* identity, which is the turn's.
|
|
72
78
|
*/
|
|
73
|
-
export declare function isSteeringDelivery(delivery: DeliverHookPayload, turn: SteeringTurn): boolean;
|
|
79
|
+
export declare function isSteeringDelivery(delivery: DeliverHookPayload, turn: SteeringTurn, options?: SteeringOptions): boolean;
|
|
74
80
|
/** A steering delivery with a message for the model, not only answers to requests. */
|
|
75
81
|
export declare function isSteeringMessage(delivery: DeliverHookPayload, turn: SteeringTurn): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{coalesceDeliveries}from"#harness/messages.js";import{ANONYMOUS_PRINCIPAL,principalOf}from"#execution/session/principal.js";var SessionInputQueue=class{entries=[];nextSequence=0;get pendingCount(){return this.entries.length}enqueueDelivery(e){let t={delivery:e,sequence:this.nextSequence++};return this.entries.push({...t,kind:`delivery`}),t}enqueueControl(e){this.entries.push({control:e,kind:`control`,sequence:this.nextSequence++})}enqueueAuthorization(e){for(let t of e){let e=authorizationAttemptId(t);e!==void 0&&(this.entries.some(t=>t.kind===`authorization`&&t.attemptId===e)||this.entries.push({attemptId:e,kind:`authorization`,payload:t,sequence:this.nextSequence++}))}}delivery(e){return this.entries.find(t=>t.kind===`delivery`&&t.sequence===e)?.delivery}replaceDelivery(e,t){let n=this.entries.findIndex(t=>t.kind===`delivery`&&t.sequence===e);if(!(n<0)){if(t===void 0){this.entries.splice(n,1);return}this.entries[n]={delivery:t,kind:`delivery`,sequence:e}}}takeSteering(e,t){let
|
|
1
|
+
import{coalesceDeliveries}from"#harness/messages.js";import{ANONYMOUS_PRINCIPAL,principalOf}from"#execution/session/principal.js";var SessionInputQueue=class{entries=[];nextSequence=0;get pendingCount(){return this.entries.length}enqueueDelivery(e){let t={delivery:e,sequence:this.nextSequence++};return this.entries.push({...t,kind:`delivery`}),t}enqueueControl(e){this.entries.push({control:e,kind:`control`,sequence:this.nextSequence++})}enqueueAuthorization(e){for(let t of e){let e=authorizationAttemptId(t);e!==void 0&&(this.entries.some(t=>t.kind===`authorization`&&t.attemptId===e)||this.entries.push({attemptId:e,kind:`authorization`,payload:t,sequence:this.nextSequence++}))}}takeAuthorizations(e){let t=this.entries.filter(t=>t.kind===`authorization`&&e.has(t.attemptId));if(!(t.length===0||new Set(t.map(e=>e.attemptId)).size<e.size))return this.retain(e=>!t.includes(e)),t.map(e=>e.payload)}delivery(e){return this.entries.find(t=>t.kind===`delivery`&&t.sequence===e)?.delivery}replaceDelivery(e,t){let n=this.entries.findIndex(t=>t.kind===`delivery`&&t.sequence===e);if(!(n<0)){if(t===void 0){this.entries.splice(n,1);return}this.entries[n]={delivery:t,kind:`delivery`,sequence:e}}}takeSteering(e,t,n){let r=this.entries.filter(r=>r.kind===`delivery`&&e.has(r.sequence)&&isSteeringDelivery(r.delivery,t,n));if(r.length!==0)return this.retain(e=>e.kind!==`delivery`||!r.includes(e)),{delivery:combine(r),handoffEligible:!1,kind:`turn`,sequences:r.map(({sequence:e})=>e)}}takeNext(e){this.retain(e=>e.kind!==`authorization`);let t=this.entries.shift();if(t===void 0)return;if(t.kind===`control`)return{control:t.control,kind:`control`};let n=[t,...this.takeFollowingDeliveriesFrom(t)],r=n.map(({sequence:e})=>e),i=combine(n);return{delivery:i,handoffEligible:r.length===1&&r[0]===e?.freshSequence&&i.caller===void 0&&this.entries.length===0,kind:`turn`,sequences:r}}takeFollowingDeliveriesFrom(e){let t=principalOf(e.delivery.auth),n=[],r=e.delivery.caller?.callId;for(;;){let e=this.entries[0];if(e?.kind!==`delivery`||t===ANONYMOUS_PRINCIPAL||principalOf(e.delivery.auth)!==t||r!==void 0&&e.delivery.caller!==void 0&&e.delivery.caller.callId!==r)break;n.push(e),this.entries.shift(),r??=e.delivery.caller?.callId}return n}retain(e){let t=this.entries.filter(e);this.entries.splice(0,this.entries.length,...t)}};function isSteeringDelivery(e,t,n){return(n?.heldOnPerson===!0||(e.turnPolicy??`steer`)===`steer`)&&(e.caller===void 0||e.caller.callId===t.callerCallId)&&(e.auth===void 0||principalOf(e.auth)===t.principal)}function isSteeringMessage(e,t){return isSteeringDelivery(e,t)&&e.payloads.some(e=>e.message!==void 0&&e.inputResponses===void 0)}function combine(e){return e.length===1?e[0].delivery:coalesceDeliveries(e.map(({delivery:e})=>e))}function authorizationAttemptId(e){let t=e.authorizationCallback;return typeof t?.attemptId==`string`?t.attemptId:void 0}export{SessionInputQueue,isSteeringDelivery,isSteeringMessage};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DeliverPayload } from "#channel/types.js";
|
|
2
1
|
import type { SessionControl, SessionInputQueue, TurnSelection } from "#execution/session/input-queue.js";
|
|
3
2
|
import type { SessionInboxReader } from "#execution/session-inbox/inbox.js";
|
|
4
3
|
import type { SessionStateCursor } from "#execution/session/state-cursor.js";
|
|
@@ -6,9 +5,6 @@ import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.
|
|
|
6
5
|
export type NextTurnInstruction = {
|
|
7
6
|
readonly kind: "workflow";
|
|
8
7
|
readonly message: WorkflowToolRunMessage;
|
|
9
|
-
} | {
|
|
10
|
-
readonly kind: "authorization-resume";
|
|
11
|
-
readonly payloads: readonly DeliverPayload[];
|
|
12
8
|
} | {
|
|
13
9
|
readonly kind: SessionControl;
|
|
14
10
|
} | {
|
|
@@ -21,16 +17,12 @@ export type NextTurnInstruction = {
|
|
|
21
17
|
readonly kind: "cancel-working-tasks";
|
|
22
18
|
} | TurnSelection;
|
|
23
19
|
/**
|
|
24
|
-
* Waits for the next input the parked owner must act on.
|
|
25
|
-
*
|
|
26
|
-
* resume the challenge once every expected attempt has reported; ordinary
|
|
27
|
-
* deliveries keep starting turns in the meantime. Fully routed descendant
|
|
28
|
-
* deliveries leave nothing for the parent, so the wait continues.
|
|
20
|
+
* Waits for the next input the parked owner must act on. Fully routed
|
|
21
|
+
* descendant deliveries leave nothing for the parent, so the wait continues.
|
|
29
22
|
*/
|
|
30
23
|
export declare function nextTurnDelivery(input: {
|
|
31
24
|
readonly inbox: SessionInboxReader;
|
|
32
25
|
readonly cursor: SessionStateCursor;
|
|
33
|
-
readonly expectedAttemptIds?: ReadonlySet<string>;
|
|
34
26
|
readonly hasWorkingTasks: () => boolean;
|
|
35
27
|
readonly queue: SessionInputQueue;
|
|
36
28
|
}): Promise<NextTurnInstruction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{admitSessionInboxPayload}from"#execution/session/admission.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";async function nextTurnDelivery(e){let{inbox:t,cursor:n,queue:r}=e,i;for(;;){let a=r.takeNext({freshSequence:t.hasPending()?void 0:i});if(a?.kind===`control`)return{kind:a.control};if(a?.kind===`turn`){let e=await routeSelectedDelivery(a,n);if(e.kind===`cancel-turn`)return e;if(e.kind===`consumed`)continue;return e}let o=r.pendingCount===0,s=await t.next();if(s===void 0)return{kind:`closed`};let c=await admitSessionInboxPayload(s,e);if(i=o&&c.kind===`delivery`?c.admission.sequence:void 0,c.kind===`workflow`)return{kind:`workflow`,message:c.message};if(c.kind===`cancel`&&e.hasWorkingTasks())return{kind:`cancel-working-tasks`}}}export{nextTurnDelivery};
|
|
@@ -5,6 +5,8 @@ export declare function derivePendingState(session: HarnessSession): {
|
|
|
5
5
|
readonly authorizationAttemptIds?: readonly string[];
|
|
6
6
|
readonly hasPendingAuthorization: boolean;
|
|
7
7
|
readonly hasPendingInputBatch: boolean;
|
|
8
|
+
/** The pending batch has workflow tool runs to start; task tool calls are answered by the session. */
|
|
9
|
+
readonly hasRunsToDispatch?: boolean;
|
|
8
10
|
readonly pendingCoordinationCallIds?: readonly string[];
|
|
9
11
|
readonly pendingTaskToolCalls?: readonly TaskToolCall[];
|
|
10
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getPendingCoordinationBatch,pendingCoordinationCallIds}from"#harness/coordination.js";import{getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}from"#harness/input-requests.js";import{pendingTaskToolCalls}from"#execution/tasks/calls.js";function derivePendingState(e){let t=getPendingCoordinationBatch(e.state),n=getPendingAuthorization(e.state),r={authorizationAttemptIds:n?.challenges.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),hasPendingAuthorization:n!==void 0,hasPendingInputBatch:hasPendingInputBatch(e.state)};return t===void 0?r:{...r,pendingCoordinationCallIds:pendingCoordinationCallIds(t),pendingTaskToolCalls:pendingTaskToolCalls(t.responseMessages)}}export{derivePendingState};
|
|
1
|
+
import{getPendingCoordinationBatch,pendingCoordinationCallIds}from"#harness/coordination.js";import{getPendingAuthorization}from"#harness/authorization.js";import{hasPendingInputBatch}from"#harness/input-requests.js";import{pendingTaskToolCalls}from"#execution/tasks/calls.js";function derivePendingState(e){let t=getPendingCoordinationBatch(e.state),n=getPendingAuthorization(e.state),r={authorizationAttemptIds:n?.challenges.flatMap(e=>e.attemptId===void 0?[]:[e.attemptId]),hasPendingAuthorization:n!==void 0,hasPendingInputBatch:hasPendingInputBatch(e.state)};return t===void 0?r:{...r,hasRunsToDispatch:t.tasks.length>0,pendingCoordinationCallIds:pendingCoordinationCallIds(t),pendingTaskToolCalls:pendingTaskToolCalls(t.responseMessages)}}export{derivePendingState};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeliverHookPayload, SessionCapabilities, TurnCaller } from "#channel/types.js";
|
|
2
2
|
import type { AgentWorkflowRetentionDefinition } from "#shared/agent-definition.js";
|
|
3
3
|
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
4
|
+
import type { HarnessModelMessage } from "#harness/messages.js";
|
|
4
5
|
import { type SessionInboxHandle } from "#execution/session-inbox/inbox.js";
|
|
5
6
|
import type { WorkflowEntryResult } from "#execution/session/entry-input.js";
|
|
6
7
|
/**
|
|
@@ -20,6 +21,7 @@ export interface SessionBoot {
|
|
|
20
21
|
readonly caller: TurnCaller | undefined;
|
|
21
22
|
readonly capabilities?: SessionCapabilities;
|
|
22
23
|
readonly deploymentId: string;
|
|
24
|
+
readonly history: HarnessModelMessage[];
|
|
23
25
|
readonly initialInput: DeliverHookPayload | undefined;
|
|
24
26
|
/** Parks on the inbox before any session-scoped lifecycle work. */
|
|
25
27
|
readonly awaitFirstMessage: boolean;
|