eve 0.68.0 → 0.70.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 +132 -0
- package/bin/eve.js +15 -0
- package/dist/src/_virtual/_rolldown/runtime.js +1 -1
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/approval/definition.d.ts +19 -5
- package/dist/src/channel/adapter.d.ts +2 -0
- package/dist/src/channel/auth/oidc.js +1 -1
- package/dist/src/channel/channel-address.d.ts +1 -4
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/channel-operations.d.ts +4 -11
- package/dist/src/channel/channel-operations.js +1 -1
- package/dist/src/channel/compiled-channel.d.ts +0 -2
- package/dist/src/channel/compiled-channel.js +2 -2
- package/dist/src/channel/cross-channel-receive.d.ts +1 -3
- package/dist/src/channel/cross-channel-receive.js +1 -1
- package/dist/src/channel/forwarded-principal.js +1 -1
- package/dist/src/channel/schedule-auth.d.ts +16 -0
- package/dist/src/channel/schedule-auth.js +1 -1
- package/dist/src/channel/session-callback.js +1 -1
- package/dist/src/channel/session.d.ts +3 -8
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/task-card.d.ts +121 -0
- package/dist/src/channel/task-card.js +1 -0
- package/dist/src/channel/types.d.ts +30 -57
- package/dist/src/chunks/{use-eve-agent-D4HVZBjn.js → use-eve-agent-CJQeE7-t.js} +2058 -1331
- package/dist/src/chunks/{use-eve-agent-DXcE_8Ja.js → use-eve-agent-DdemtY6C.js} +2061 -1331
- package/dist/src/cli/commands/info.d.ts +11 -0
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.js +1 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/command-options.d.ts +2 -2
- 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 +21 -19
- package/dist/src/cli/dev/tui/blocks.js +4 -4
- package/dist/src/cli/dev/tui/command-typeahead.d.ts +3 -6
- 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/diagnostic-presentation.d.ts +10 -0
- package/dist/src/cli/dev/tui/diagnostic-presentation.js +3 -2
- 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.js +1 -1
- package/dist/src/cli/dev/tui/prompt-placeholder.d.ts +2 -0
- package/dist/src/cli/dev/tui/prompt-placeholder.js +1 -0
- 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/rail.d.ts +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +60 -174
- package/dist/src/cli/dev/tui/runner.js +3 -3
- package/dist/src/cli/dev/tui/status-line.d.ts +4 -2
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/task-activity.d.ts +59 -0
- package/dist/src/cli/dev/tui/task-activity.js +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +18 -57
- 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/theme.d.ts +1 -1
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tool-block-groups.d.ts +6 -9
- package/dist/src/cli/dev/tui/tool-block-groups.js +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.d.ts +17 -3
- 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/traces/trace-conversation.js +3 -1
- package/dist/src/cli/dev/tui/traces/trace-view.js +1 -1
- package/dist/src/cli/dev/tui/transcript-parts.d.ts +73 -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 +13 -9
- package/dist/src/cli/dev/ui-options.d.ts +2 -2
- package/dist/src/cli/dev/ui-options.js +1 -1
- package/dist/src/cli/option-parsers.d.ts +3 -1
- package/dist/src/cli/option-parsers.js +1 -1
- package/dist/src/cli/ui/terminal-text.js +1 -1
- package/dist/src/client/agent-info-schema.d.ts +150 -9
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/agent-session.d.ts +28 -0
- package/dist/src/client/agent-session.js +1 -0
- 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 +20 -1
- 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 +5 -1
- package/dist/src/client/index.js +1 -1
- package/dist/src/client/message-action-parts.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/message-task-parts.d.ts +8 -0
- package/dist/src/client/message-task-parts.js +1 -0
- 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-controls.d.ts +0 -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 +29 -2
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.d.ts +8 -16
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/stream-version.js +1 -1
- package/dist/src/client/types.d.ts +4 -5
- package/dist/src/compiled/.vendor-stamp.json +3 -2
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/@vercel/connect/LICENSE +202 -0
- package/dist/src/compiled/@vercel/connect/authorization-details.d.ts +11 -0
- package/dist/src/compiled/@vercel/connect/authorization.d.ts +47 -0
- package/dist/src/compiled/@vercel/connect/connector.d.ts +32 -0
- package/dist/src/compiled/@vercel/connect/index.d.ts +5 -0
- package/dist/src/compiled/@vercel/connect/index.js +26 -0
- package/dist/src/compiled/@vercel/connect/installation.d.ts +48 -0
- package/dist/src/compiled/@vercel/connect/token.d.ts +137 -0
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiler/bundled-extension.d.ts +7 -1
- package/dist/src/compiler/bundled-extension.js +1 -1
- package/dist/src/compiler/default-tool-policy.d.ts +2 -2
- package/dist/src/compiler/default-tool-policy.js +1 -1
- package/dist/src/compiler/development-extensions.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +54 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/extension-mount-bindings.d.ts +5 -0
- package/dist/src/compiler/extension-mount-bindings.js +1 -0
- package/dist/src/compiler/load-binding-namespace.d.ts +10 -2
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/compiler/manifest.d.ts +19 -17
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/module-lifecycle.d.ts +2 -2
- package/dist/src/compiler/module-lifecycle.js +1 -1
- package/dist/src/compiler/module-map.d.ts +1 -1
- package/dist/src/compiler/module-map.js +3 -3
- package/dist/src/compiler/normalize-manifest-helpers.d.ts +18 -1
- package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
- package/dist/src/compiler/normalize-manifest-types.d.ts +2 -0
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/compiler/project-sources.d.ts +4 -0
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/compiler/remote-agent-node.js +1 -1
- package/dist/src/compiler/source-graph.d.ts +5 -0
- package/dist/src/compiler/source-graph.js +1 -1
- package/dist/src/computer-use/extension/lib/computer-use-sandbox.d.ts +8 -0
- package/dist/src/computer-use/extension/lib/computer-use-sandbox.js +3 -3
- package/dist/src/computer-use/extension/lib/computer-use.d.ts +2 -0
- package/dist/src/computer-use/extension/lib/computer-use.js +2 -1
- package/dist/src/computer-use/extension/tools/computer_use.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-subagent-lifecycle.d.ts +5 -0
- 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 -1
- package/dist/src/context/key-names.d.ts +0 -1
- package/dist/src/context/key-names.js +1 -1
- package/dist/src/context/keys.d.ts +12 -15
- package/dist/src/context/keys.js +1 -1
- package/dist/src/context/memory-lifecycle.js +1 -1
- package/dist/src/context/memory-tools.d.ts +0 -1
- package/dist/src/context/provider.d.ts +5 -11
- package/dist/src/context/run-step.d.ts +5 -6
- package/dist/src/context/run-step.js +1 -1
- package/dist/src/context/serialize.js +1 -1
- package/dist/src/discover/bundled-extension.js +1 -1
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/extensions.d.ts +0 -7
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/discover/manifest.d.ts +4 -0
- package/dist/src/evals/assertions/run.d.ts +4 -3
- package/dist/src/evals/assertions/run.js +1 -1
- package/dist/src/evals/index.d.ts +1 -1
- package/dist/src/evals/match.d.ts +4 -4
- package/dist/src/evals/mock-model.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.d.ts +3 -3
- 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/runner/reporters/assertion-scores.d.ts +19 -0
- package/dist/src/evals/runner/reporters/assertion-scores.js +1 -0
- package/dist/src/evals/runner/reporters/braintrust.js +1 -1
- package/dist/src/evals/runner/reporters/datadog-client.d.ts +123 -0
- package/dist/src/evals/runner/reporters/datadog-client.js +4 -0
- package/dist/src/evals/runner/reporters/datadog.d.ts +9 -98
- package/dist/src/evals/runner/reporters/datadog.js +2 -3
- package/dist/src/evals/session-content.js +1 -1
- package/dist/src/evals/session.d.ts +4 -4
- package/dist/src/evals/session.js +2 -2
- package/dist/src/evals/types.d.ts +34 -15
- package/dist/src/eve-channel/create-request.d.ts +5 -4
- package/dist/src/eve-channel/create-request.js +1 -1
- package/dist/src/eve-channel/index.d.ts +0 -9
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +3 -7
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/eve-channel/support.d.ts +15 -5
- package/dist/src/eve-channel/support.js +1 -1
- package/dist/src/eve-channel/turn-policy-request.d.ts +2 -0
- package/dist/src/eve-channel/turn-policy-request.js +1 -0
- package/dist/src/eve-channel/types.d.ts +4 -0
- package/dist/src/execution/agent-sessions/context.d.ts +62 -0
- package/dist/src/execution/agent-sessions/context.js +1 -0
- package/dist/src/{subagents/remote-dispatch.d.ts → execution/agent-sessions/remote.d.ts} +17 -40
- package/dist/src/execution/agent-sessions/remote.js +1 -0
- package/dist/src/execution/agent-sessions/requests.d.ts +20 -0
- package/dist/src/execution/agent-sessions/requests.js +1 -0
- package/dist/src/execution/agent-sessions/session.d.ts +12 -0
- package/dist/src/execution/agent-sessions/session.js +1 -0
- package/dist/src/execution/agent-sessions/steps.d.ts +59 -0
- package/dist/src/execution/agent-sessions/steps.js +1 -0
- package/dist/src/execution/agent-sessions/target.d.ts +45 -0
- package/dist/src/execution/agent-sessions/target.js +1 -0
- package/dist/src/execution/agent-sessions/usage.d.ts +18 -0
- package/dist/src/execution/agent-sessions/usage.js +1 -0
- package/dist/src/execution/authorization-callback-match.d.ts +2 -4
- package/dist/src/execution/authorization-callback-match.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.d.ts +1 -5
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/connection-announcement.d.ts +7 -0
- package/dist/src/execution/connection-announcement.js +4 -0
- package/dist/src/execution/continuation-conflict-step.d.ts +2 -3
- package/dist/src/execution/continuation-conflict-step.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +12 -28
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.d.ts +3 -2
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +4 -3
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +10 -5
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-connections.js +1 -1
- package/dist/src/execution/dynamic-workflow/program-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/schema.d.ts +1 -3
- package/dist/src/execution/dynamic-workflow/schema.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.d.ts +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
- package/dist/src/execution/forward-session-input.d.ts +4 -0
- package/dist/src/execution/forward-session-input.js +1 -0
- package/dist/src/execution/legacy-remote-agent/protocol.d.ts +41 -0
- package/dist/src/execution/legacy-remote-agent/protocol.js +1 -0
- package/dist/src/execution/legacy-session/authorization.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/inbox.js +1 -1
- package/dist/src/execution/legacy-session/input.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/model-call-batching.js +1 -1
- package/dist/src/execution/node-step.d.ts +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/proxied-deliver-step.d.ts +9 -6
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/publish-session-events.d.ts +150 -0
- package/dist/src/execution/publish-session-events.js +1 -0
- package/dist/src/execution/reconcile-session-continuation-token.d.ts +2 -2
- package/dist/src/execution/route-child-delivery.d.ts +5 -4
- package/dist/src/execution/route-child-delivery.js +1 -3
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/prewarm.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/admission.d.ts +1 -12
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/entry-input.d.ts +0 -2
- 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 +13 -2
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +21 -5
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +44 -39
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/next-input.d.ts +7 -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/principal.d.ts +14 -0
- package/dist/src/execution/session/principal.js +1 -0
- package/dist/src/execution/session/program.d.ts +2 -0
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/route-selected-delivery.js +1 -1
- package/dist/src/execution/session/state-cursor.d.ts +26 -18
- package/dist/src/execution/session/state-cursor.js +1 -1
- package/dist/src/execution/session/state-delta.d.ts +40 -0
- package/dist/src/execution/session/state-delta.js +1 -0
- package/dist/src/execution/session/timeout-steps.js +1 -1
- package/dist/src/execution/session/turn-event-handler.d.ts +2 -2
- package/dist/src/execution/session/turn-event-handler.js +1 -1
- package/dist/src/execution/session/turn-step-result.d.ts +1 -3
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step-types.d.ts +37 -19
- package/dist/src/execution/session/turn-step.d.ts +2 -2
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn-waiting-step.d.ts +4 -0
- package/dist/src/execution/session/turn-waiting-step.js +1 -0
- package/dist/src/execution/session/turn.d.ts +41 -3
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-callback-request.js +1 -1
- package/dist/src/execution/session-event-stream.d.ts +33 -0
- package/dist/src/execution/session-event-stream.js +1 -0
- package/dist/src/execution/session-inbox/inbox.d.ts +2 -0
- package/dist/src/execution/session-inbox/inbox.js +1 -1
- package/dist/src/execution/session-inbox/protocol.js +1 -1
- package/dist/src/execution/session-inbox/release-step.js +1 -1
- package/dist/src/execution/session-inbox/resume.js +1 -1
- package/dist/src/execution/session-workflow-tool-run.d.ts +11 -2
- package/dist/src/execution/session-workflow-tool-run.js +1 -1
- package/dist/src/execution/session.d.ts +5 -6
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +23 -10
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +0 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/tasks/calls.d.ts +42 -0
- package/dist/src/execution/tasks/calls.js +1 -0
- package/dist/src/execution/tasks/model-step.d.ts +58 -0
- package/dist/src/execution/tasks/model-step.js +1 -0
- package/dist/src/execution/tasks/render.d.ts +66 -0
- package/dist/src/execution/tasks/render.js +8 -0
- package/dist/src/execution/tasks/session.d.ts +19 -0
- package/dist/src/execution/tasks/session.js +1 -0
- package/dist/src/execution/tasks/start.d.ts +34 -0
- package/dist/src/execution/tasks/start.js +1 -0
- package/dist/src/execution/tasks/steps.d.ts +31 -0
- package/dist/src/execution/tasks/steps.js +1 -0
- package/dist/src/execution/tasks/table.d.ts +192 -0
- package/dist/src/execution/tasks/table.js +1 -0
- package/dist/src/execution/tasks/task-id-input.d.ts +19 -0
- package/dist/src/execution/tasks/task-id-input.js +1 -0
- package/dist/src/execution/tasks/tool-entry-point.d.ts +11 -0
- package/dist/src/execution/tasks/tool-entry-point.js +1 -0
- package/dist/src/execution/tasks/workflow-target.d.ts +2 -0
- package/dist/src/execution/tasks/workflow-target.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/terminate-child-sessions-step.d.ts +2 -9
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.d.ts +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/agent-router.d.ts +1 -1
- package/dist/src/execution/tools/agent-router.js +1 -1
- package/dist/src/execution/tools/connection-approval.d.ts +25 -0
- package/dist/src/execution/tools/connection-approval.js +1 -0
- package/dist/src/execution/tools/connection-search-rank.d.ts +21 -0
- package/dist/src/execution/tools/connection-search-rank.js +1 -0
- package/dist/src/execution/tools/connection-target.d.ts +18 -0
- package/dist/src/execution/tools/connection-target.js +1 -0
- package/dist/src/execution/tools/connection-tools.d.ts +10 -0
- package/dist/src/execution/tools/connection-tools.js +2 -0
- package/dist/src/execution/tools/load-skill.js +1 -1
- package/dist/src/execution/tools/workflow/answer.d.ts +7 -4
- package/dist/src/execution/tools/workflow/answer.js +1 -1
- package/dist/src/execution/tools/workflow/ask.d.ts +73 -10
- package/dist/src/execution/tools/workflow/ask.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +60 -19
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/cancel.d.ts +7 -2
- package/dist/src/execution/tools/workflow/cancel.js +1 -1
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +10 -4
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -1
- package/dist/src/execution/tools/workflow/{background.d.ts → harness-definition.d.ts} +6 -6
- package/dist/src/execution/tools/workflow/harness-definition.js +1 -0
- package/dist/src/execution/tools/workflow/interrupt.d.ts +6 -0
- package/dist/src/execution/tools/workflow/interrupt.js +1 -0
- package/dist/src/execution/tools/workflow/messages.d.ts +135 -10
- package/dist/src/execution/tools/workflow/messages.js +1 -1
- package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
- package/dist/src/execution/tools/workflow/owner.d.ts +15 -4
- package/dist/src/execution/tools/workflow/owner.js +1 -1
- package/dist/src/execution/tools/workflow/serve.d.ts +3 -0
- package/dist/src/execution/tools/workflow/serve.js +1 -0
- package/dist/src/execution/tools/workflow/start.d.ts +18 -11
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/tools/workflow/types.d.ts +0 -10
- package/dist/src/execution/tools/workflow/withdraw-step.d.ts +31 -0
- package/dist/src/execution/tools/workflow/withdraw-step.js +1 -0
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +3 -5
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -1
- package/dist/src/execution/tools/workflow/workflow.d.ts +3 -3
- package/dist/src/execution/tools/workflow/workflow.js +1 -1
- package/dist/src/execution/web-fetch/request.js +1 -1
- package/dist/src/execution/workflow-callback-url.d.ts +0 -5
- package/dist/src/execution/workflow-callback-url.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +3 -5
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-webhook-route.js +1 -1
- package/dist/src/extensions/code/extension/lib/connect-authentication.js +1 -1
- package/dist/src/extensions/code/extension/lib/github-shell.js +1 -1
- package/dist/src/extensions/code/extension/lib/prwatch-github.js +1 -1
- package/dist/src/framework/sources/modules/agent.d.ts +1 -0
- package/dist/src/framework/sources/modules/agent.js +1 -1
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/action-presentation.js +1 -1
- package/dist/src/harness/action-result-helpers.d.ts +1 -0
- package/dist/src/harness/action-result-helpers.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +1 -1
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/announcements.d.ts +22 -0
- package/dist/src/harness/announcements.js +1 -0
- package/dist/src/harness/approval-candidates.d.ts +10 -2
- package/dist/src/harness/approval-candidates.js +1 -1
- package/dist/src/harness/approval-delivery-coordinator.d.ts +4 -5
- package/dist/src/harness/approval-delivery-coordinator.js +1 -1
- package/dist/src/harness/approval-recheck.d.ts +7 -0
- package/dist/src/harness/approval-recheck.js +1 -0
- package/dist/src/harness/authorization-event-fields.d.ts +13 -0
- package/dist/src/harness/authorization-event-fields.js +1 -0
- package/dist/src/harness/authorization.d.ts +17 -3
- 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 +36 -30
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/current-messages.d.ts +6 -1
- package/dist/src/harness/current-messages.js +1 -1
- package/dist/src/harness/emission.d.ts +11 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +4 -15
- 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/hitl/session-limit-input-requests.d.ts +2 -0
- package/dist/src/harness/hitl/session-limit-input-requests.js +1 -1
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-request-resolution.d.ts +5 -2
- package/dist/src/harness/input-request-resolution.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/messages.d.ts +11 -3
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/model-call-error.js +1 -1
- package/dist/src/harness/nested-actions.d.ts +23 -0
- package/dist/src/harness/nested-actions.js +1 -0
- package/dist/src/harness/pending-input-batches.d.ts +8 -6
- package/dist/src/harness/pending-input-batches.js +1 -1
- package/dist/src/harness/provider-tool-history.d.ts +7 -2
- package/dist/src/harness/provider-tool-history.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +45 -40
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tool-model-output.js +1 -1
- package/dist/src/harness/tool-presentation.js +1 -1
- package/dist/src/harness/tools.d.ts +1 -5
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +8 -5
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +25 -21
- package/dist/src/harness/workflow-dispatch.d.ts +30 -0
- package/dist/src/harness/workflow-dispatch.js +1 -0
- package/dist/src/harness/workflow-tool-runs.d.ts +5 -65
- package/dist/src/harness/workflow-tool-runs.js +1 -1
- 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 +7 -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 -7
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/runtime.d.ts +5 -7
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/session-init.js +1 -1
- package/dist/src/instrumentation/state.d.ts +0 -6
- package/dist/src/instrumentation/state.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.d.ts +10 -0
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +20 -6
- package/dist/src/internal/authored-module-loader.js +2 -2
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/authored-package-boundary.d.ts +3 -0
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/bundler/extension-mount-plugin.d.ts +14 -0
- package/dist/src/internal/bundler/extension-mount-plugin.js +1 -0
- package/dist/src/internal/bundler/extension-scope-plugin.d.ts +8 -11
- package/dist/src/internal/bundler/extension-scope-plugin.js +2 -3
- package/dist/src/internal/invocation/workflow-execution.d.ts +2 -2
- package/dist/src/internal/invocation/workflow-execution.js +1 -1
- package/dist/src/internal/mount-state.d.ts +1 -0
- package/dist/src/internal/mount-state.js +1 -0
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
- package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
- package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/node-esm-compat-banner.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/internal/workflow-bundle/authored-workflow-directives.d.ts +4 -3
- package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.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/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/models/auto.d.ts +6 -0
- package/dist/src/models/auto.js +2 -2
- package/dist/src/protocol/message-version.d.ts +1 -0
- package/dist/src/protocol/message-version.js +1 -1
- package/dist/src/protocol/message.d.ts +166 -69
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/remote-agent-protocol.d.ts +16 -0
- package/dist/src/protocol/remote-agent-protocol.js +1 -0
- package/dist/src/protocol/routes.d.ts +0 -6
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/protocol/task-tools.d.ts +21 -0
- package/dist/src/protocol/task-tools.js +1 -0
- package/dist/src/public/channels/auth.js +1 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +25 -16
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
- package/dist/src/public/channels/chat-sdk/input-actions.d.ts +8 -0
- package/dist/src/public/channels/chat-sdk/input-actions.js +1 -0
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/linq/linqChannel.js +1 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/slack/action-status.d.ts +11 -12
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/channels/slack/api.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/attachments.js +1 -1
- package/dist/src/public/channels/slack/auth.d.ts +5 -0
- package/dist/src/public/channels/slack/auth.js +1 -1
- package/dist/src/public/channels/slack/connections.d.ts +20 -16
- package/dist/src/public/channels/slack/connections.js +1 -1
- package/dist/src/public/channels/slack/defaults.d.ts +13 -33
- package/dist/src/public/channels/slack/defaults.js +3 -4
- package/dist/src/public/channels/slack/hitl.d.ts +22 -13
- package/dist/src/public/channels/slack/hitl.js +2 -2
- 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 +6 -3
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/input-response.d.ts +1 -5
- 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 +76 -0
- package/dist/src/public/channels/slack/renderers.js +1 -0
- 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/session-operations.d.ts +6 -0
- package/dist/src/public/channels/slack/session-operations.js +1 -1
- 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 +62 -103
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/task-card.d.ts +24 -0
- package/dist/src/public/channels/slack/task-card.js +1 -0
- 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/channels/telegram/hitl.d.ts +7 -1
- package/dist/src/public/channels/telegram/hitl.js +2 -1
- package/dist/src/public/channels/telegram/state.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +5 -0
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +7 -1
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/connections/mcp.d.ts +4 -6
- package/dist/src/public/definitions/connections/openapi.d.ts +7 -8
- package/dist/src/public/definitions/extension.d.ts +2 -2
- package/dist/src/public/definitions/extension.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +4 -4
- package/dist/src/public/definitions/state.d.ts +4 -2
- package/dist/src/public/definitions/state.js +1 -1
- package/dist/src/public/memory/index.d.ts +0 -1
- package/dist/src/public/models/openai/index.d.ts +1 -1
- package/dist/src/public/models/openai/index.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/public/schedules/index.d.ts +1 -0
- package/dist/src/public/schedules/index.js +1 -1
- package/dist/src/public/server/index.d.ts +28 -0
- package/dist/src/public/server/index.js +1 -0
- package/dist/src/public/tools/index.d.ts +3 -2
- package/dist/src/public/tools/index.js +1 -1
- package/dist/src/public/tools/no-reply.d.ts +1 -0
- package/dist/src/public/tools/no-reply.js +1 -0
- 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/agent/bootstrap-model-utils.d.ts +6 -7
- package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
- package/dist/src/runtime/agent/bootstrap.d.ts +0 -1
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/agent/mock-model-fixtures.d.ts +1 -1
- package/dist/src/runtime/agent/mock-model-fixtures.js +2 -2
- package/dist/src/runtime/channels/registry.js +1 -1
- package/dist/src/runtime/connections/mcp-client.d.ts +1 -9
- package/dist/src/runtime/connections/mcp-client.js +1 -1
- package/dist/src/runtime/connections/openapi-client.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.d.ts +3 -1
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/runtime/connections/tool-result.d.ts +27 -0
- package/dist/src/runtime/connections/tool-result.js +2 -0
- package/dist/src/runtime/connections/tool-signature.d.ts +14 -0
- package/dist/src/runtime/connections/tool-signature.js +1 -0
- package/dist/src/runtime/local-dev-capability.js +1 -1
- package/dist/src/runtime/prompt/compose.d.ts +1 -3
- package/dist/src/runtime/prompt/compose.js +3 -3
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/sessions/runtime-context-keys.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +1 -16
- package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -1
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/subagents/workflow-reference.d.ts +6 -3
- package/dist/src/runtime/subagents/workflow-reference.js +1 -1
- package/dist/src/runtime/subagents/workflow.d.ts +12 -6
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/self-modification/extension/classify-registry-item.d.ts +3 -0
- package/dist/src/self-modification/extension/classify-registry-item.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
- package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/instructions.js +7 -7
- package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/tools/search_registry.d.ts +2 -0
- package/dist/src/self-modification/extension/subagents/agent/tools/search_registry.js +1 -1
- package/dist/src/self-modification/scaffold.d.ts +2 -0
- package/dist/src/self-modification/scaffold.js +7 -0
- package/dist/src/self-modification/setup.js +1 -7
- package/dist/src/setup/boxes/deploy-project.js +1 -1
- package/dist/src/setup/boxes/select-model.js +1 -1
- package/dist/src/setup/integrations/shopify/templates.d.ts +1 -1
- package/dist/src/setup/integrations/shopify/templates.js +31 -19
- package/dist/src/setup/integrations/web/setup.js +6 -2
- package/dist/src/setup/scaffold/create/agent-paths.d.ts +5 -0
- package/dist/src/setup/scaffold/create/agent-paths.js +1 -0
- package/dist/src/setup/scaffold/create/instructions-template.d.ts +1 -0
- package/dist/src/setup/scaffold/create/instructions-template.js +8 -0
- package/dist/src/setup/scaffold/create/project.js +3 -10
- package/dist/src/setup/scaffold/create/web-template.d.ts +2 -2
- package/dist/src/setup/scaffold/create/web-template.js +28 -9
- package/dist/src/setup/vercel-project-framework.js +1 -1
- package/dist/src/shared/action-request-name.d.ts +3 -0
- package/dist/src/shared/action-request-name.js +1 -0
- package/dist/src/shared/action-types.d.ts +49 -21
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +0 -7
- package/dist/src/shared/chatgpt-model.d.ts +1 -1
- package/dist/src/shared/chatgpt-model.js +1 -1
- package/dist/src/shared/connection-types.d.ts +2 -8
- package/dist/src/shared/default-agent-model.d.ts +10 -1
- package/dist/src/shared/default-agent-model.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/extension-mount.d.ts +2 -0
- package/dist/src/shared/extension-mount.js +1 -0
- package/dist/src/shared/format-duration.d.ts +2 -0
- package/dist/src/shared/format-duration.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/input.d.ts +1 -0
- package/dist/src/shared/memory-state.d.ts +1 -0
- package/dist/src/shared/memory-state.js +1 -1
- package/dist/src/shared/model-helper.d.ts +2 -2
- package/dist/src/shared/model-helper.js +1 -1
- package/dist/src/shared/model-summary.d.ts +2 -6
- package/dist/src/shared/model-summary.js +1 -1
- package/dist/src/shared/presentation-text.d.ts +5 -0
- package/dist/src/shared/presentation-text.js +1 -1
- package/dist/src/shared/serialized-observability-state.d.ts +0 -4
- package/dist/src/shared/serialized-observability-state.js +1 -1
- 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/shared/value-delta.d.ts +39 -0
- package/dist/src/shared/value-delta.js +1 -0
- package/dist/src/subagents/adapter-state.d.ts +0 -2
- package/dist/src/subagents/adapter-state.js +1 -1
- package/dist/src/subagents/adapter.js +1 -1
- package/dist/src/subagents/callback-route.js +1 -1
- package/dist/src/subagents/event-proxy-step.d.ts +16 -29
- package/dist/src/subagents/event-proxy-step.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +38 -20
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/subagents/invocation.d.ts +4 -3
- package/dist/src/subagents/parent-notification.d.ts +2 -1
- package/dist/src/subagents/parent-notification.js +1 -1
- package/dist/src/subagents/token-budget.d.ts +8 -9
- package/dist/src/subagents/token-budget.js +1 -1
- package/dist/src/subagents/tool.d.ts +6 -12
- 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/behavior.d.ts +5 -5
- package/dist/src/tools/definition.d.ts +50 -14
- package/dist/src/tools/definition.js +1 -1
- package/dist/src/tools/durable-callbacks.d.ts +1 -1
- package/dist/src/tools/dynamic.d.ts +6 -0
- package/dist/src/tools/framework/agent-contract.d.ts +2 -5
- package/dist/src/tools/framework/agent-contract.js +1 -1
- package/dist/src/tools/framework/agent.d.ts +2 -5
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/framework/connection-tools.d.ts +3 -0
- package/dist/src/tools/framework/connection-tools.js +1 -0
- package/dist/src/tools/provided/agent-router.d.ts +6 -3
- package/dist/src/tools/provided/agent-router.js +1 -1
- package/dist/src/{execution/tools → tools/provided}/ask-question-workflow.d.ts +3 -4
- package/dist/src/tools/provided/ask-question-workflow.js +1 -0
- package/dist/src/tools/provided/ask-question.d.ts +20 -5
- package/dist/src/tools/provided/ask-question.js +2 -1
- package/dist/src/tools/provided/interrupted.d.ts +18 -0
- package/dist/src/tools/provided/interrupted.js +1 -0
- package/dist/src/tools/provided/load-skill.js +1 -1
- package/dist/src/tools/provided/no-reply.d.ts +19 -0
- package/dist/src/tools/provided/no-reply.js +1 -0
- package/dist/src/tools/provided/sleep-workflow.d.ts +4 -0
- package/dist/src/tools/provided/sleep-workflow.js +1 -0
- package/dist/src/tools/provided/sleep.d.ts +11 -5
- package/dist/src/tools/provided/sleep.js +1 -1
- package/dist/src/tools/provided/task-cancel.d.ts +6 -0
- package/dist/src/tools/provided/task-cancel.js +1 -0
- package/dist/src/tools/provided/task-wait.d.ts +9 -0
- package/dist/src/tools/provided/task-wait.js +1 -0
- package/dist/src/tools/provided/workflow.d.ts +2 -2
- package/dist/src/tools/provided/workflow.js +1 -1
- package/dist/src/tools/schema-emission.d.ts +23 -0
- package/dist/src/tools/schema-emission.js +1 -0
- package/dist/src/tools/schema.d.ts +22 -8
- package/dist/src/tools/schema.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +187 -85
- package/dist/src/tools/workflow-definition.js +1 -1
- package/dist/src/tools/workflow-entry-point.d.ts +3 -0
- package/dist/src/tools/workflow-entry-point.js +1 -0
- package/dist/src/tracing/agent-action-instrumentation.d.ts +1 -3
- 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-invocation-coordinator.d.ts +9 -18
- package/dist/src/tracing/agent-invocation-coordinator.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-content.d.ts +0 -2
- package/dist/src/tracing/agent-otel-content.js +3 -3
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-runtime-context.d.ts +20 -0
- 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-otel-usage.js +1 -1
- package/dist/src/tracing/agent-span-contract.d.ts +1 -1
- package/dist/src/tracing/agent-span-contract.js +1 -1
- package/dist/src/tracing/agent-span-id-generator.d.ts +0 -1
- package/dist/src/tracing/agent-span-id-generator.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-context-codec.d.ts +5 -2
- package/dist/src/tracing/agent-trace-context-codec.js +1 -1
- package/dist/src/tracing/agent-trace-context-store.d.ts +2 -27
- package/dist/src/tracing/agent-trace-context-store.js +1 -1
- package/dist/src/tracing/agent-trace-span-processor.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +4 -19
- package/dist/src/tracing/content-attributes.js +1 -1
- package/dist/src/tracing/conversation-context.d.ts +10 -0
- package/dist/src/tracing/conversation-context.js +1 -1
- package/dist/src/tracing/install-instrumentation-runtime.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/agent-config.md +36 -13
- package/docs/channels/chat-sdk.mdx +15 -4
- package/docs/channels/custom.mdx +89 -17
- package/docs/channels/eve.mdx +1 -1
- package/docs/channels/mcp.mdx +1 -1
- package/docs/channels/overview.mdx +14 -56
- package/docs/channels/slack.mdx +287 -45
- package/docs/channels/telegram.mdx +2 -0
- package/docs/concepts/built-in-tools.md +37 -28
- package/docs/concepts/context-control.md +2 -2
- package/docs/concepts/execution-model-and-durability.mdx +10 -11
- package/docs/concepts/sessions-runs-and-streaming.md +69 -49
- package/docs/connections/mcp.mdx +4 -4
- package/docs/connections/openapi.mdx +2 -2
- package/docs/connections/overview.mdx +11 -5
- package/docs/evals/assertions.mdx +5 -5
- package/docs/evals/cases.mdx +1 -1
- package/docs/evals/reporters.mdx +10 -4
- package/docs/extensions.md +22 -2
- package/docs/guides/client/streaming.mdx +33 -12
- package/docs/guides/deployment/vercel.mdx +2 -1
- package/docs/guides/dev-tui.md +26 -16
- package/docs/guides/dynamic-capabilities.md +6 -4
- package/docs/guides/evaluate.md +29 -2
- package/docs/guides/frontend/nuxt.mdx +24 -4
- package/docs/guides/frontend/overview.mdx +45 -41
- 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/hooks.md +16 -12
- package/docs/guides/instrumentation/instrumentation.mdx +2 -0
- package/docs/guides/instrumentation/otel.mdx +24 -6
- package/docs/guides/remote-agents.md +38 -22
- package/docs/guides/self-modification.md +10 -0
- package/docs/instructions.mdx +1 -1
- package/docs/patterns/multi-tenant-approvals.md +1 -1
- package/docs/protocols/ucp.mdx +20 -16
- package/docs/reference/cli.md +64 -11
- package/docs/reference/typescript-api.md +43 -41
- package/docs/schedules.mdx +14 -34
- package/docs/subagents/index.mdx +24 -56
- package/docs/tools/human-in-the-loop.md +50 -15
- package/docs/tools/meta.json +1 -1
- package/docs/tools/overview.mdx +80 -60
- package/docs/tools/tasks-upgrade.md +201 -0
- package/docs/tools/tasks.md +315 -0
- package/docs/tools/workflows.mdx +368 -154
- package/package.json +18 -12
- package/dist/src/channel/activity-renderer.d.ts +0 -21
- package/dist/src/channel/activity-renderer.js +0 -1
- package/dist/src/channel/activity-sink.d.ts +0 -2
- package/dist/src/channel/activity-sink.js +0 -1
- 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 -142
- package/dist/src/cli/dev/tui/subagent-pump.js +0 -1
- package/dist/src/eve-channel/activity-observer-request.d.ts +0 -7
- package/dist/src/eve-channel/activity-observer-request.js +0 -1
- package/dist/src/eve-channel/delivery-policy-request.d.ts +0 -4
- package/dist/src/eve-channel/delivery-policy-request.js +0 -1
- package/dist/src/execution/activity-cohort.d.ts +0 -20
- package/dist/src/execution/activity-cohort.js +0 -1
- package/dist/src/execution/activity-collector.d.ts +0 -12
- package/dist/src/execution/activity-collector.js +0 -1
- package/dist/src/execution/activity-events.d.ts +0 -8
- package/dist/src/execution/activity-events.js +0 -1
- package/dist/src/execution/activity-route.d.ts +0 -2
- package/dist/src/execution/activity-route.js +0 -1
- package/dist/src/execution/activity-work-id.d.ts +0 -9
- package/dist/src/execution/activity-work-id.js +0 -1
- package/dist/src/execution/activity-work.d.ts +0 -30
- package/dist/src/execution/activity-work.js +0 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +0 -7
- package/dist/src/execution/cancel-indexed-session-tasks-step.js +0 -1
- package/dist/src/execution/dispatch-action-failures.d.ts +0 -8
- package/dist/src/execution/dispatch-action-failures.js +0 -1
- package/dist/src/execution/dispatch-start-operation.d.ts +0 -15
- package/dist/src/execution/dispatch-start-operation.js +0 -1
- package/dist/src/execution/publish-channel-event.d.ts +0 -23
- package/dist/src/execution/publish-channel-event.js +0 -1
- package/dist/src/execution/scheduled-launch-delivery.d.ts +0 -7
- package/dist/src/execution/scheduled-launch-delivery.js +0 -1
- package/dist/src/execution/session/event-sink.d.ts +0 -26
- package/dist/src/execution/session/event-sink.js +0 -1
- package/dist/src/execution/session-activity-projection.d.ts +0 -16
- package/dist/src/execution/session-activity-projection.js +0 -1
- package/dist/src/execution/session-activity-renderer-step.d.ts +0 -15
- package/dist/src/execution/session-activity-renderer-step.js +0 -1
- package/dist/src/execution/session-activity.d.ts +0 -3
- package/dist/src/execution/session-activity.js +0 -1
- package/dist/src/execution/submit-activity.d.ts +0 -7
- package/dist/src/execution/submit-activity.js +0 -1
- package/dist/src/execution/task-event-callback.d.ts +0 -12
- package/dist/src/execution/task-event-callback.js +0 -1
- package/dist/src/execution/task-input-capability.d.ts +0 -4
- package/dist/src/execution/task-input-capability.js +0 -1
- package/dist/src/execution/task-input-response-route.d.ts +0 -2
- package/dist/src/execution/task-input-response-route.js +0 -1
- package/dist/src/execution/tasks/child/notify.d.ts +0 -44
- package/dist/src/execution/tasks/child/notify.js +0 -1
- package/dist/src/execution/tasks/parent/control-shared.d.ts +0 -23
- package/dist/src/execution/tasks/parent/control-shared.js +0 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +0 -35
- package/dist/src/execution/tasks/parent/delegate.js +0 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +0 -22
- package/dist/src/execution/tasks/parent/dispatch.js +0 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +0 -27
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +0 -1
- package/dist/src/execution/tasks/parent/run-parent.d.ts +0 -58
- package/dist/src/execution/tasks/parent/run-parent.js +0 -1
- package/dist/src/execution/tasks/parent/subagent-task-projection.d.ts +0 -26
- package/dist/src/execution/tasks/parent/subagent-task-projection.js +0 -1
- package/dist/src/execution/tasks/parent/task-cancel.d.ts +0 -12
- package/dist/src/execution/tasks/parent/task-cancel.js +0 -1
- package/dist/src/execution/tasks/parent/tool-execution.d.ts +0 -45
- package/dist/src/execution/tasks/parent/tool-execution.js +0 -1
- package/dist/src/execution/terminal-session-event.d.ts +0 -13
- package/dist/src/execution/terminal-session-event.js +0 -1
- package/dist/src/execution/tools/ask-question-workflow.js +0 -1
- package/dist/src/execution/tools/ask-question.d.ts +0 -19
- package/dist/src/execution/tools/ask-question.js +0 -2
- package/dist/src/execution/tools/connection-search.d.ts +0 -2
- package/dist/src/execution/tools/connection-search.js +0 -2
- package/dist/src/execution/tools/sleep-workflow.d.ts +0 -3
- package/dist/src/execution/tools/sleep-workflow.js +0 -1
- package/dist/src/execution/tools/sleep.d.ts +0 -10
- package/dist/src/execution/tools/sleep.js +0 -1
- package/dist/src/execution/tools/subagent/accept-event-step.d.ts +0 -7
- package/dist/src/execution/tools/subagent/accept-event-step.js +0 -1
- package/dist/src/execution/tools/subagent/emit-event-step.d.ts +0 -12
- package/dist/src/execution/tools/subagent/emit-event-step.js +0 -1
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +0 -42
- package/dist/src/execution/tools/subagent/invoke-agent.js +0 -1
- package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +0 -44
- package/dist/src/execution/tools/subagent/invoke-preparation.js +0 -1
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +0 -64
- package/dist/src/execution/tools/subagent/invoke-step.js +0 -1
- package/dist/src/execution/tools/subagent/receipt-identity.d.ts +0 -11
- package/dist/src/execution/tools/subagent/receipt-identity.js +0 -1
- package/dist/src/execution/tools/subagent/start.d.ts +0 -51
- package/dist/src/execution/tools/subagent/start.js +0 -1
- package/dist/src/execution/tools/subagent/steer.d.ts +0 -13
- package/dist/src/execution/tools/subagent/steer.js +0 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +0 -24
- package/dist/src/execution/tools/subagent/task-agent-requests.js +0 -1
- package/dist/src/execution/tools/subagent/task-cancel.d.ts +0 -10
- package/dist/src/execution/tools/subagent/task-cancel.js +0 -1
- package/dist/src/execution/tools/tasks.d.ts +0 -3
- package/dist/src/execution/tools/tasks.js +0 -1
- package/dist/src/execution/tools/workflow/background.js +0 -1
- package/dist/src/execution/tools/workflow/workflow-owner-background.d.ts +0 -14
- package/dist/src/execution/tools/workflow/workflow-owner-background.js +0 -1
- package/dist/src/harness/background-tools.d.ts +0 -45
- package/dist/src/harness/background-tools.js +0 -1
- package/dist/src/instrumentation/background-task-runtime.d.ts +0 -18
- package/dist/src/instrumentation/background-task-runtime.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.3.0/node_modules/@vercel/cli-config/dist/index.js +0 -21
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/envpath.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/errors.js +0 -2
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/errutils.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/exec.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/fsutils.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/index.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/lookup.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.1/node_modules/@vercel/cli-exec/dist/safety.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/authorization.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/connector.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/index.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/installation.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/base-url.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/default-scopes.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/env.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/internal/url-validation.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_connect@2.3.3_@ai-sdk_mcp@2.0.52_zod@4.5.4__@auth_core@0.41.2_@chat-adapter_sla_a37674779346d612fa7d2ca9bd316494/node_modules/@vercel/connect/dist/token.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/auth-errors.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/exchange-vercel-oidc-token.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-context.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-sync.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-with-refresh.js +0 -2
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/index.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/oauth.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-error.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-io.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token-util.js +0 -2
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/token.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/verify-vercel-oidc-token.js +0 -1
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.9/node_modules/@vercel/oidc/dist/version.js +0 -1
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js +0 -1
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js +0 -1
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js +0 -1
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js +0 -1
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js +0 -1
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -1
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js +0 -1
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/command.js +0 -1
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js +0 -2
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/kill.js +0 -1
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/promise.js +0 -1
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stdio.js +0 -1
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stream.js +0 -1
- package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js +0 -1
- package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js +0 -1
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/core.js +0 -1
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/main.js +0 -1
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/realtime.js +0 -1
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/signals.js +0 -1
- package/dist/src/node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js +0 -1
- package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js +0 -1
- package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js +0 -1
- package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/index.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/decrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/encrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/decrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/encrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/decrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/encrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/embedded.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/thumbprint.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/local.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/remote.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/sign.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/verify.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/sign.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/verify.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/sign.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/verify.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/decrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/encrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/produce.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/sign.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/unsecured.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/verify.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/export.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_key_pair.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_secret.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/import.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/aesgcmkw.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/buffer_utils.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/cek.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_iv_length.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_key_type.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_p2s.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/crypto_key.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/decrypt_key_management.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/encrypt_key_management.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/epoch.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/invalid_key_input.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_disjoint.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_jwk.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_object.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/iv.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/jwt_claims_set.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/private_symbols.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/secs.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_algorithms.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_crit.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/aeskw.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/asn1.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/base64url.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/cbc_tag.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_cek_length.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_key_length.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ciphers.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/decrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/digest.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/dsa_digest.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ecdhes.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/encrypt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/fetch_jwks.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/generate.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_named_curve.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_sign_verify_key.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/hmac_digest.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_like.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_object.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/jwk_to_key.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/key_to_jwk.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/node_key.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/normalize_key.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/pbes2kw.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/random.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/rsaes.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/runtime.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/sign.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/timing_safe_equal.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/verify.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/webcrypto.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/base64url.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_jwt.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_protected_header.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/errors.js +0 -1
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/runtime.js +0 -1
- package/dist/src/node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js +0 -1
- package/dist/src/node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js +0 -1
- package/dist/src/node_modules/.pnpm/npm-run-path@4.0.1/node_modules/npm-run-path/index.js +0 -1
- package/dist/src/node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js +0 -1
- package/dist/src/node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js +0 -1
- package/dist/src/node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js +0 -1
- package/dist/src/node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js +0 -1
- package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +0 -1
- package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +0 -1
- package/dist/src/node_modules/.pnpm/strip-final-newline@2.0.0/node_modules/strip-final-newline/index.js +0 -2
- package/dist/src/node_modules/.pnpm/which@2.0.2/node_modules/which/which.js +0 -1
- package/dist/src/protocol/activity.d.ts +0 -112
- package/dist/src/protocol/activity.js +0 -1
- package/dist/src/protocol/agent-handle-error.d.ts +0 -13
- package/dist/src/protocol/agent-handle-error.js +0 -1
- package/dist/src/public/channels/slack/activity-plan.d.ts +0 -5
- package/dist/src/public/channels/slack/activity-plan.js +0 -1
- package/dist/src/public/channels/slack/activity.d.ts +0 -63
- package/dist/src/public/channels/slack/activity.js +0 -2
- package/dist/src/public/nuxt/dev-server.d.ts +0 -25
- package/dist/src/public/nuxt/dev-server.js +0 -1
- package/dist/src/public/tools/connection-search.d.ts +0 -1
- package/dist/src/public/tools/connection-search.js +0 -1
- package/dist/src/public/tools/task-cancel.d.ts +0 -1
- package/dist/src/public/tools/task-cancel.js +0 -1
- package/dist/src/runtime/prompt/connections.d.ts +0 -9
- package/dist/src/runtime/prompt/connections.js +0 -2
- package/dist/src/shared/empty-delivery.d.ts +0 -3
- package/dist/src/shared/empty-delivery.js +0 -1
- package/dist/src/subagents/agent-handle-errors.d.ts +0 -25
- package/dist/src/subagents/agent-handle-errors.js +0 -1
- package/dist/src/subagents/callback-step.d.ts +0 -11
- package/dist/src/subagents/callback-step.js +0 -1
- package/dist/src/subagents/continuation-bundle.d.ts +0 -13
- package/dist/src/subagents/continuation-bundle.js +0 -1
- package/dist/src/subagents/handle-dispatch.d.ts +0 -65
- package/dist/src/subagents/handle-dispatch.js +0 -1
- package/dist/src/subagents/handles/operation-id.d.ts +0 -15
- package/dist/src/subagents/handles/operation-id.js +0 -1
- package/dist/src/subagents/handles/prompt.d.ts +0 -52
- package/dist/src/subagents/handles/prompt.js +0 -3
- package/dist/src/subagents/handles/query.d.ts +0 -41
- package/dist/src/subagents/handles/query.js +0 -1
- package/dist/src/subagents/handles/state-key.d.ts +0 -8
- package/dist/src/subagents/handles/state-key.js +0 -1
- package/dist/src/subagents/handles/store.d.ts +0 -217
- package/dist/src/subagents/handles/store.js +0 -1
- package/dist/src/subagents/handles/transitions.d.ts +0 -103
- package/dist/src/subagents/handles/transitions.js +0 -1
- package/dist/src/subagents/remote-dispatch.js +0 -1
- package/dist/src/subagents/start-local.d.ts +0 -29
- package/dist/src/subagents/start-local.js +0 -1
- package/dist/src/subagents/start-remote.d.ts +0 -21
- package/dist/src/subagents/start-remote.js +0 -1
- package/dist/src/tasks/delivery-context.d.ts +0 -32
- package/dist/src/tasks/delivery-context.js +0 -4
- package/dist/src/tasks/delivery-policy.d.ts +0 -14
- package/dist/src/tasks/delivery-policy.js +0 -1
- package/dist/src/tasks/json.d.ts +0 -88
- package/dist/src/tasks/json.js +0 -1
- package/dist/src/tasks/notification.d.ts +0 -10
- package/dist/src/tasks/notification.js +0 -1
- package/dist/src/tasks/task-id.d.ts +0 -31
- package/dist/src/tasks/task-id.js +0 -1
- package/dist/src/tasks/task-inbox-token.d.ts +0 -2
- package/dist/src/tasks/task-inbox-token.js +0 -1
- package/dist/src/tasks/transitions.d.ts +0 -17
- package/dist/src/tasks/transitions.js +0 -1
- package/dist/src/tasks/types.d.ts +0 -138
- package/dist/src/tasks/types.js +0 -1
- package/dist/src/tools/framework/connection-search.d.ts +0 -3
- package/dist/src/tools/framework/connection-search.js +0 -1
- package/dist/src/tools/framework/task-cancel.d.ts +0 -4
- package/dist/src/tools/framework/task-cancel.js +0 -1
- package/dist/src/tools/framework/task-contract.d.ts +0 -19
- package/dist/src/tools/framework/task-contract.js +0 -1
- package/dist/src/tools/native-definition.d.ts +0 -7
- package/dist/src/tools/native-definition.js +0 -1
- package/dist/src/tracing/agent-invocation-terminal.d.ts +0 -18
- package/dist/src/tracing/agent-invocation-terminal.js +0 -1
- /package/dist/src/execution/{tools/subagent → agent-sessions}/metadata.d.ts +0 -0
- /package/dist/src/execution/{tools/subagent → agent-sessions}/metadata.js +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{ToolLoopAgent,isStepCount}from"ai";import{readClientContext}from"#internal/client-context.js";import{createErrorId,createLogger,formatError,logError}from"#internal/logging.js";import{contextStorage}from"#context/container.js";import{AuthKey,HistoryStateKey,ParentSessionKey,ScheduleIdKey,SessionCallbackKey,StaticModelReferenceKey
|
|
1
|
+
import{ToolLoopAgent,isStepCount}from"ai";import{readClientContext}from"#internal/client-context.js";import{createErrorId,createLogger,formatError,logError}from"#internal/logging.js";import{contextStorage}from"#context/container.js";import{AuthKey,HistoryStateKey,ParentSessionKey,ScheduleIdKey,SessionCallbackKey,StaticModelReferenceKey}from"#context/keys.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{toErrorMessage}from"#shared/errors.js";import{createActionResultEvent,createApprovalCandidateEvent,createApprovalSettledEvent,createAuthorizationCompletedEvent,createAuthorizationRequiredEvent,createCompactionCompletedEvent,createCompactionRequestedEvent,createContextClearedEvent,createInputRequestedEvent,createInputResolvedEvent,createMessageCompletedEvent,createResultCompletedEvent,createSessionWaitingEvent,createStepStartedEvent,createTurnWaitingEvent}from"#protocol/message.js";import{toModelSchema}from"#tools/schema.js";import{resolveProviderHeaders}from"#internal/gateway.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{TOOL_RESULT_BOUNDARY,createFrameworkUserMessage,createUserMessage,followsToolResults,frameworkMessageKindForStepInput,normalizeModelMessages,normalizeUserContent,resolveAssistantStepText,validateHarnessModelMessages}from"#harness/messages.js";import{getEffectiveModelSelection}from"#context/effective-model.js";import{drainMemoryCommit,prepareMemoryCompaction,prepareMemoryPreamble}from"#context/memory-lifecycle.js";import{canonicalizeMemoryRecords,clearMemorySessionState,shouldCanonicalizeMemory}from"#shared/memory-state.js";import{advanceStep,emitFailedStep,emitRecoverableFailedTurn,emitStepStarted,emitStreamContent,emitTurnEpilogue,emitTurnPreamble,getHarnessEmissionState,setHarnessEmissionState}from"#harness/emission.js";import{renderFinalOutputWhileWorkingError}from"#execution/tasks/render.js";import{renderPendingApprovalsInstruction,renderPendingApprovalsSnippet}from"#harness/hitl/approval-prompt.js";import{setTimeout}from"node:timers/promises";import{resolveConversationId}from"#shared/conversation-identity.js";import{accumulateTurnUsage,getSessionUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{getPendingCoordinationBatch,resolvePendingCoordination,setPendingCoordinationBatch}from"#harness/coordination.js";import{hydrateSandboxAttachments,stageAttachmentsToSandbox}from"#harness/attachment-staging.js";import{getPendingAnnouncements}from"#harness/announcements.js";import{activeTurnId}from"#harness/active-turn-id.js";import{buildDynamicSubagentTools}from"#context/dynamic-subagent-lifecycle.js";import{createHistoryViewPreparer}from"#shared/history-view.js";import{isDynamicModelSelectionError}from"#context/dynamic-model-lifecycle.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{getPendingAuthorization,getSupersededAuthorizationChallenges,setPendingAuthorization}from"#harness/authorization.js";import{appendPendingInputBatch,consumeDeferredStepInput,getApprovedTools,getPendingInputRequestIds,hasRunnableDeferredStepInput,hasStepInput,resolvePendingInput,selectApprovalReplayBatch}from"#harness/input-requests.js";import{buildDynamicInstructionMessages,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble}from"#context/dynamic-instruction-lifecycle.js";import{PendingSkillAnnouncementKey}from"#context/dynamic-skill-lifecycle.js";import{getPendingInputBatches,queueDeferredStepInput}from"#harness/pending-input-batches.js";import{setEveAttributes}from"#runtime/attributes/emit.js";import{authorizationEventFields}from"#harness/authorization-event-fields.js";import{declinedSignInEvents,withdrawHeldSignIns}from"#harness/held-requests.js";import{createToolResultMessagePartFromToolError,isToolResultError}from"#harness/action-result-helpers.js";import{summarizeKnownError}from"#harness/semantic-errors/index.js";import{getApprovalAuditState,markApprovalCandidateHistoryEventEmitted,markApprovalCandidatePendingEventEmitted,markApprovalSettlementEventEmitted}from"#harness/approval-candidates.js";import{estimateTokens}from"#harness/token-estimate.js";import{extractToolApprovalInputRequests}from"#harness/input-extraction.js";import{clearTurnClientContextState,getTurnClientContextState,setTurnClientContextState}from"#harness/turn-client-context.js";import{getInvalidToolCallInputError,isInvalidToolCall}from"#harness/tool-call-input-errors.js";import{ContentFilteredModelResponseError,EmptyModelResponseError,classifyModelCallError,extractModelCallErrorDetails,extractUnsupportedProviderToolTypes,extractUpstreamRejectionMessage,isNoOutputGeneratedError}from"#harness/model-call-error.js";import{interruptStreamOnFailure}from"#harness/interruptible-stream.js";import{resolveInlineAuthorizationInterrupt}from"#harness/inline-tool-authorization.js";import{createCurrentMessages,hasTailApprovalResponse}from"#harness/current-messages.js";import{applyLastToolCacheBreakpoint,applySystemCacheBreakpoint,detectPromptCachePath,getAnthropicCacheMarker}from"#harness/prompt-cache.js";import{resolveCallProviderOptions}from"#harness/provider-safety.js";import{requireSessionModelReference}from"#harness/types.js";import{GenerationSteering}from"#harness/generation-steering.js";import{estimateRequestEnvelope,getRequestEnvelopeTokens,setRequestEnvelopeTokens}from"#harness/request-envelope.js";import{buildDynamicTools,buildResponseAuthorizationTools}from"#context/build-dynamic-tools.js";import{compactMessages,getInputTokenCount,resolveCompactionModel,shouldCompact}from"#harness/compaction.js";import{collectDeferredCalls,dispatchApprovedWorkflowCalls}from"#harness/workflow-dispatch.js";import{applySessionLimitContinuation,enforceSessionUsageLimit}from"#harness/session-limit-enforcement.js";import{coordinateApprovalDelivery}from"#harness/approval-delivery-coordinator.js";import{convertStaleResponsesToUserMessage,dropStaleSessionLimitContinuationResponses}from"#harness/stale-input-responses.js";import{normalizeProviderToolHistory}from"#harness/provider-tool-history.js";import{appendTaskContext,isTaskTool,taskSystemMessages,withTaskTools,workingTaskIds}from"#execution/tasks/model-step.js";import{extractWorkflowStreamWriteErrorDetails}from"#harness/workflow-stream-error.js";import{getAdvertisedTools}from"#harness/advertised-tools.js";import{resolveFrameworkToolFromUpstreamType}from"#harness/provider-tools.js";import{buildStepHooks,emitStepActions,readGatewayGenerationId}from"#harness/step-hooks.js";import{buildToolApproval,buildToolSetFromDefinitions,buildToolSetWithProviderTools}from"#harness/tools.js";import{FINAL_OUTPUT_TOOL_NAME,buildFinalOutputTool}from"#harness/final-output.js";const environment=process.env.NODE_ENV??`unknown`,eveVersion=resolveInstalledPackageInfo().version,log=createLogger(`harness.tool-loop`);function logToolExecutionError(e){e.toolOutput.type!==`tool-error`||isTurnCancellation(e.toolOutput.error)||logError(log,`tool execution failed`,e.toolOutput.error,{toolName:e.toolCall.toolName,toolCallId:e.toolCall.toolCallId})}function mergeSystemInstructions(e){if(e.length===0)return;if(e.length===1)return{...e[0]};let t;for(let n of e)n.providerOptions!==void 0&&(t={...t,...n.providerOptions});let n={role:`system`,content:e.map(e=>e.content).join(`
|
|
2
2
|
|
|
3
|
-
`)};return t!==void 0&&(n.providerOptions=t),n}function buildGatewayAttributionHeaders(e,t){let n=resolveProviderHeaders(e);if(n===void 0)return;let r=t?.agentName??t?.agentId,i=process.env.VERCEL_PROJECT_PRODUCTION_URL||process.env.VERCEL_URL,a=i?`https://${i}`:void 0,o={...n};return r&&(o[`x-title`]=r),a&&(o[`http-referer`]=a),o}async function resolveEffectiveRuntimeModel(e){if(e.ctx===void 0){let t=e.session.agent.modelReference;if(t===void 0)throw Error(`Dynamic model selection is unavailable outside an eve runtime context.`);return{model:await e.config.resolveModel(t),session:e.session}}let t=getEffectiveModelSelection(e.ctx);if(t===null)throw Error(`Dynamic model selection is required before model-dependent work begins. Add a matching resolver handler that returns a concrete model.`);return{model:t.model===void 0?await e.config.resolveModel(t.reference):t.model,session:updateSessionModelReference(e.session,t.reference)}}function updateSessionModelReference(e,t){return e.agent.modelReference===t?e:{...e,agent:{...e.agent,modelReference:t},compaction:updateCompactionThresholdForModelReference({compaction:e.compaction,modelReference:t})}}function updateCompactionThresholdForModelReference(e){return e.modelReference.contextWindowTokens===void 0?e.compaction:{...e.compaction,threshold:Math.max(1,Math.floor(e.modelReference.contextWindowTokens*(e.compaction.thresholdPercent??.9)))}}function buildHarnessToolsWithDynamicSubagents(e,t){let n=new Map(e);if(t===void 0)return n;for(let e of buildDynamicSubagentTools(t)){if(n.has(e.name))throw Error(`Dynamic subagent "${e.name}" collides with another runtime-visible tool name.`);n.set(e.name,e)}return n}function createToolLoopHarness(e){e.instrumentation?.installAiSdkWarningLogger();let t=e.handleEvent;async function runStep(t,n){let executeStep=async r=>{let i=r?.session??t,a=new GenerationSteering({abortSignal:e.abortSignal,steeringSignal:e.steeringSignal,outputStarted:getHarnessEmissionState(i.state).assistantOutputStarted});try{return await executeStepBody(i,a,n,r)}finally{a.dispose()}};return e.instrumentation?.runStep({environment,eveVersion,hasInput:hasStepInput(n),session:t},executeStep)??executeStep()}async function executeStepBody(n,r,i,a){let o=n,s=createHistoryViewPreparer({previous:e.historyView,projector:e.historyProjector});s(o.history,o.state);let projectHistory=(e,t)=>s(e,t).messages,c=getHarnessEmissionState(o.state),l=contextStorage.getStore();l!==void 0&&!l.has(StaticModelReferenceKey)&&l.setVirtualContext(StaticModelReferenceKey,o.agent.dynamicModel===!0?null:o.agent.modelReference??null);let u=l?.get(ParentSessionKey),d=l?.get(SessionCallbackKey),f=u!==void 0||d!==void 0,p,m=a?.createHandleEvent({getAttemptScope:()=>p,handleEvent:t,turnId:activeTurnId(c)})??t,h=m===void 0?void 0:async(e,t)=>{r.beforeEvent(e),await m(e,t)},failModelSelection=async(t,n)=>{if(throwIfTurnAborted(e.abortSignal),a?.recordError(t),!h)throw t;let r=createErrorId(),i=toErrorMessage(t);return log.error(`model selection failed terminally`,{error:t,errorId:r,sessionId:o.sessionId,turnId:n.turnId}),await emitFailedStep(h,n,{code:`MODEL_SELECTION_FAILED`,details:{errorId:r},message:i,sessionId:o.sessionId}),{next:f?{done:!0,isError:!0,output:i}:{done:!0,output:``},session:o}},failBoundaryEvent=async(t,n)=>{if(throwIfTurnAborted(e.abortSignal),isTurnCancellation(t))throw t;if(isDynamicModelSelectionError(t))return failModelSelection(t,n);throw t},preparePreambleTrace=async()=>await a?.preparePreamble({sequence:c.sequence,sessionStarted:c.sessionStarted,traceContext:a?.traceContext,turnId:activeTurnId(c)});if(e.clearOnly===!0)return o={...o,state:clearMemorySessionState(o.state)},o=replaceSessionHistory(o,[]),await h?.(createContextClearedEvent({sequence:c.sequence,sessionId:o.sessionId,turnId:activeTurnId(c)})),await h?.(createSessionWaitingEvent()),{next:null,session:o};if(e.compactOnly===!0){if(o.history.length>0)try{let t=contextStorage.getStore(),n=await resolveEffectiveRuntimeModel({config:e,ctx:t,session:o});o=n.session,o=(await maybeCompact({abortSignal:e.abortSignal,auth:t?.get(AuthKey)??null,emit:h,emissionState:{...c,turnId:activeTurnId(c)},force:!0,historyProjector:e.historyProjector,messages:[...o.history],model:n.model,requestEnvelopeTokens:getRequestEnvelopeTokens(o),resolveModel:e.resolveModel,runtimeIdentity:e.runtimeIdentity,session:o,telemetry:a?.telemetry()})).session}catch(e){logError(log,`manual session compaction failed`,e,{sessionId:o.sessionId})}return await h?.(createSessionWaitingEvent()),{next:null,session:o}}let g=consumeDeferredStepInput$1({input:i,session:o});o=g.session;let _=getPendingCoordinationBatch(o.state),v=await resolvePendingCoordination({emit:h,session:o,stepInput:g.input,tools:e.tools});if(v.outcome===`unresolved`)return{next:null,session:v.session};o=v.session;let y=getPendingInputRequestIds(o.state),b=convertStaleResponsesToUserMessage({history:v.messages,pendingRequestIds:y,stepInput:dropStaleSessionLimitContinuationResponses({pendingRequestIds:y,stepInput:g.input})}),x=b.stepInput,S=b.kind===`converted`?{...x,message:b.displayMessage}:x,C=contextStorage.getStore(),prepareApprovalTools=async t=>(t?.event!==void 0&&await e.prepareApprovalTurn?.(t.event),C!==void 0&&await e.resolveStepDynamicTools?.({ctx:C,event:createStepStartedEvent({modelId:o.agent.modelReference?.id??`dynamic`,...t?.event??c}),messages:projectHistory(v.messages,o.state)}),buildResponseAuthorizationTools({authoredTools:e.tools,context:C})),w=getPendingAuthorization(o.state)?.challenges??[],T=await coordinateApprovalDelivery({session:o,stepInput:x,tools:e.tools,prepareTools:async t=>{let n=getPendingInputBatches(o.state).find(e=>e.requests.some(e=>e.requestId===t.requestId)),r=await prepareApprovalTools(n),i=n?.toolReplayIdentities?.[t.requestId];if(i!==void 0&&e.toolReplayIdentity?.(t.action.toolName)!==i){let e=new Map(r);return e.delete(t.action.toolName),e}return r}});if(o=T.session,h){for(let e of T.feedback)await h(createMessageCompletedEvent({message:e,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId}));let e=getApprovalAuditState(o.state);for(let t of w)e.candidateHistory.some(e=>e.candidateId===t.candidateId&&e.status===`timed-out`&&e.eventEmitted!==!0)&&await h(createAuthorizationCompletedEvent({attemptId:t.attemptId,authorization:t.challenge,candidateId:t.candidateId,name:t.name,outcome:`failed`,reason:`The approval response expired. Please submit a new response.`,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId}));for(let t of e.activeCandidates.filter(e=>e.pendingEventEmitted!==!0))await h(createApprovalCandidateEvent({candidateId:t.candidateId,outcome:`pending`,requestId:t.requestId,responderPrincipalId:t.responder.principalId,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId})),o={...o,state:markApprovalCandidatePendingEventEmitted({candidateId:t.candidateId,state:o.state})};for(let t of e.candidateHistory.filter(e=>e.eventEmitted!==!0&&e.status!==`allowed`))await h(createApprovalCandidateEvent({candidateId:t.candidateId,outcome:t.status,requestId:t.requestId,responderPrincipalId:t.responder.principalId,reason:t.reason,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId})),o={...o,state:markApprovalCandidateHistoryEventEmitted({candidateId:t.candidateId,state:o.state})};for(let t of e.settlements.filter(e=>e.eventEmitted!==!0))await h(createApprovalSettledEvent({outcome:t.outcome===`allowed`?`approved`:`cancelled`,requestId:t.requestId,responderPrincipalId:t.actor.principalId,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId})),o={...o,state:markApprovalSettlementEventEmitted({requestId:t.requestId,state:o.state})}}if(T.kind===`park`)return{next:null,session:o};if(T.kind===`continue-coordination`)return{next:runStep,session:T.stepInput===void 0?o:queueDeferredStepInput(o,T.stepInput)};if(T.challenges.length>0){if(h)for(let e of T.challenges)await h(createAuthorizationRequiredEvent({authorization:e.challenge,candidateId:e.candidateId,description:e.challenge.instructions??`Authorization required for ${e.name}`,name:e.name,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId,webhookUrl:e.hookUrl}));let e=T.stepInput===void 0?o:queueDeferredStepInput(o,T.stepInput);return{next:null,session:{...e,state:setPendingAuthorization(e.state,{challenges:T.challenges})}}}let E=selectApprovalReplayBatch(o,T.stepInput),D=E===void 0?e.tools:await prepareApprovalTools(E),O=resolvePendingInput({activeTurnId:_?.event.turnId??activeTurnId(c),history:v.messages,internalStep:!isHarnessBetweenTurns(o),resolveApprovalKey:resolveApprovalKeyFromTools(D),session:o,stepInput:T.stepInput});if(O.outcome===`unresolved`){let t=v.outcome===`resolved`?{...O.session,history:validateHarnessModelMessages(v.messages)}:O.session;if(h&&O.deferredMessage===!0&&hasStepInput(i)){let n=createTurnInputMessages(x);l!==void 0&&(prepareDynamicInstructionPreamble(l,projectHistory(t.history,t.state)),prepareMemoryPreamble(l,{history:t.history,input:n,projector:e.historyProjector,state:t.state}));let r=[],i;try{let r=await preparePreambleTrace();c=await emitTurnPreamble(h,S??{},c,projectHistory([...t.history,...n],t.state),e.runtimeIdentity,r)}catch(e){return r=l===void 0?[]:drainDynamicInstructionUserMessages(l),i=l===void 0?void 0:drainMemoryCommit(l),t={...t,history:validateHarnessModelMessages([...i?.history??t.history,...r]),state:i?.state??t.state},o=t,failBoundaryEvent(e,{sessionStarted:!0,sequence:c.sequence,stepIndex:0,turnId:activeTurnId(c)})}return r=l===void 0?[]:drainDynamicInstructionUserMessages(l),i=l===void 0?void 0:drainMemoryCommit(l),t={...t,history:validateHarnessModelMessages([...i?.history??t.history,...r]),state:i?.state??t.state},c=await emitTurnEpilogue(h,c),{next:null,session:setHarnessEmissionState(t,c)}}return v.outcome===`resolved`?(h&&(c=await emitTurnEpilogue(h,c),t=setHarnessEmissionState(t,c)),{next:null,session:t}):(T.kind===`responses-completed`&&isHarnessBetweenTurns(O.session)&&getPendingAuthorization(O.session.state)===void 0&&await h?.(createSessionWaitingEvent()),{next:null,session:O.session})}if(O.resolvedInputs!==void 0)for(let e of O.resolvedInputs)await a?.publishInputResolutions({batch:e,sessionId:o.sessionId}),h&&await h(createInputResolvedEvent({resolutions:e.inputs.map(e=>{let t={kind:e.request.kind,outcome:e.outcome,requestId:e.request.requestId};return e.response===void 0?t:{...t,response:e.response}}),sequence:e.event.sequence,stepIndex:e.event.stepIndex,turnId:e.event.turnId}));if(h&&O.rejectedActions)for(let e of O.rejectedActions)for(let t of e.results)await h(createActionResultEvent({rejected:!0,result:t,sequence:e.event.sequence,stepIndex:e.event.stepIndex,turnId:e.event.turnId}));let k=activeTurnId(c),A=getTurnClientContextState(O.session.state,k),j=O.deferredContext===!0?void 0:readClientContext(x),ee=(j??A?.messages)?.map(e=>createFrameworkUserMessage(`context.instruction`,e))??[],M=[];if(x?.context!==void 0&&O.deferredContext!==!0)for(let e of x.context)M.push(createFrameworkUserMessage(`context.instruction`,e));let te=frameworkMessageKindForStepInput(x),ne=normalizeUserContent(x?.message),N=ne!==void 0&&!O.deferredMessage&&!O.consumedMessage?await stageAttachmentsToSandbox(ne):void 0;N!==void 0&&M.push(te===void 0?createUserMessage(`user`,N):createFrameworkUserMessage(te,N));let P=[],F;if(h&&(hasStepInput(x)||hasStepInput(T.stepInput))){l!==void 0&&(prepareDynamicInstructionPreamble(l,projectHistory(O.session.history,O.session.state)),prepareMemoryPreamble(l,{history:O.messages,input:[...ee,...M],projector:e.historyProjector,state:O.session.state}));try{let t=await preparePreambleTrace();c=await emitTurnPreamble(h,S??{},c,projectHistory([...O.messages,...ee,...M],O.session.state),e.runtimeIdentity,t)}catch(e){return P=l===void 0?[]:drainDynamicInstructionUserMessages(l),F=l===void 0?void 0:drainMemoryCommit(l),o={...O.session,history:validateHarnessModelMessages([...F?.history??O.session.history,...P]),state:F?.state??O.session.state},failBoundaryEvent(e,{sessionStarted:!0,sequence:c.sequence,stepIndex:0,turnId:activeTurnId(c)})}P=l===void 0?[]:drainDynamicInstructionUserMessages(l),F=l===void 0?void 0:drainMemoryCommit(l),a?.setTurnId(c.turnId)}let re=F?.history??O.session.history,ie=O.session.history.length;o=setHarnessEmissionState({...O.session,history:validateHarnessModelMessages([...re,...P]),state:F?.state??O.session.state},c);let I=validateHarnessModelMessages([...F?.history??O.messages.slice(0,ie),...P,...F===void 0?O.messages.slice(ie):[]]),L=await applySessionLimitContinuation({config:e,emit:h,emissionState:c,limitContinuation:O.limitContinuation,session:o});if(L.result!==null)return L.result;o=L.session;let ae=getAgentHandleStore(o.state);if(!hasUnansweredToolCall(I)){let e=await l?.get(BackgroundToolExecutorKey)?.readAgentViews?.(),t=e===void 0||e.length===0?void 0:[...projectParkedAgentHandles(ae??{handles:[]}).map(e=>({availability:`available`,id:e.identity.id,name:e.identity.name,statusLine:e.phase===`parked`?e.lastStatus:void 0})),...e],n=resolveAgentsAnnouncement({agentViews:t,messages:projectHistory(I,o.state),store:ae});n!==void 0&&I.push(createFrameworkUserMessage(`context.state`,n))}let R=A;j!==void 0&&(R={insertionIndex:A?.insertionIndex??I.length,messages:j,turnId:k}),R!==void 0&&(o=setTurnClientContextState(o,R)),I=[...I,...M];let createModelMessages=e=>{if(R===void 0||R.messages.length===0)return[...e];let t=Math.min(Math.max(0,R.insertionIndex),e.length);return[...e.slice(0,t),...R.messages.map(e=>createFrameworkUserMessage(`context.instruction`,e)),...e.slice(t)]},z=validateHarnessModelMessages(projectHistory(createModelMessages(I),o.state)),B=l,V;try{B!==void 0&&e.dispatchDynamicModelEvent!==void 0&&await e.dispatchDynamicModelEvent({ctx:B,event:{data:{sequence:c.sequence,stepIndex:c.stepIndex,turnId:activeTurnId(c)},type:`step.started`},messages:z}),V=await resolveEffectiveRuntimeModel({config:e,ctx:B,session:o})}catch(e){return failModelSelection(e,c)}o=V.session;let H=V.model,oe=detectPromptCachePath(H),U=oe.kind===`anthropic-direct`?getAnthropicCacheMarker():void 0,se=buildGatewayAttributionHeaders(H,e.runtimeIdentity);if(z=validateHarnessModelMessages(normalizeModelMessages(projectHistory(createModelMessages(I),o.state))),h)try{await emitStepStarted(h,c,requireSessionModelReference(o).id,z)}catch(e){return failBoundaryEvent(e,c)}let ce=(O.resolvedInputs??[]).flatMap(e=>e.inputs.filter(e=>e.outcome===`approved`));if(ce.length>0){let t=buildResponseAuthorizationTools({authoredTools:e.tools,context:B});for(let{request:n,toolReplayIdentity:r}of ce){if(r!==void 0&&e.toolReplayIdentity?.(n.action.toolName)!==r)throw Error(`The connection for this tool call changed or is unavailable. Request a new tool call and approval.`);if(!t.has(n.action.toolName))throw Error(`The approved tool is no longer available. Request a new tool call and approval.`)}}let W=getApprovedTools(o,resolveApprovalKeyFromTools(buildResponseAuthorizationTools({authoredTools:e.tools,context:B}))),le=c.sequence===0,ue=le&&B?.get(ScheduleIdKey)!==void 0,G=resolveDeliveryPolicy({hasScheduleProvenance:ue,hasOutputSchema:o.outputSchema!==void 0,isChild:B?.get(ParentSessionKey)!==void 0,isFirstTurn:le,taskDeliveryPhase:B?.get(TurnTaskDeliveryKey),taskDeliveryPolicy:B?.get(TaskDeliveryPolicyKey)}),createRequestMessages=()=>{let e=createCurrentMessages(I,{historyState:B?.get(HistoryStateKey),currentTurnMessages:M,projectedMessages:z});B!==void 0&&e.addSystem(buildDynamicInstructionMessages(B));let t=B?.get(TurnTaskDeliveryKey)===`initiating`?resolveInitiatingTaskContext({state:o.state,turnId:k}):void 0;e.addAnnouncements({availableSkills:B?.get(PendingSkillAnnouncementKey),taskState:t?.context,deliveryInstruction:G.instruction});let n=renderPendingApprovalsInstruction(getPendingInputBatches(o.state).flatMap(e=>e.requests));return n!==void 0&&e.add(n,`context.state`,{cacheFriendly:!1}),e},K=createRequestMessages(),q,finishSteeredStep=()=>(throwIfTurnAborted(e.abortSignal),B?.set(HistoryStateKey,K.historyState),q!==void 0&&(o=setTurnUsageState(o,accumulateTurnUsage({previous:getTurnUsageState(o.state),turnId:c.turnId,usage:q}))),{steered:!0,next:runStep,session:setHarnessEmissionState({...o,history:[...K.history]},advanceStep(c))}),J=[],withTrailingUserNote=(e,t)=>t?[...e,createFrameworkUserMessage(`execution.retry`,t)]:[...e],prepareModelInstructions=e=>{let t=e?[{role:`system`,content:e}]:[],n=o.agent.system?[{role:`system`,content:o.agent.system}]:[],r=K.systemMessages.length>0||t.length>0?[...t,...n,...K.systemMessages]:void 0,i=r!==void 0&&U?applySystemCacheBreakpoint(r,U):r;return i===void 0?o.agent.system??void 0:mergeSystemInstructions(i)},prepareModelCallInput=e=>{let t=prepareModelInstructions(e);return{instructions:t,telemetryRuntimeContext:a?.resolveRuntimeContext({eveVersion,emissionState:c,environment,modelInput:{instructions:t,messages:J},session:o})}},de=e.tools,Y=0,X,throwIfCompactionFailed=()=>{if(X!==void 0)throw X.error},prepareModelTools=async t=>{let n=buildHarnessToolsWithDynamicSubagents(e.tools,B),i=createBackgroundToolCallBatch(),a=getAdvertisedTools({session:o,tools:n});de=a;let s=await buildToolSetWithProviderTools({approvedTools:W,backgroundBatch:i,disabledProviderTools:t.disabledProviderTools,modelReference:requireSessionModelReference(o),tools:a}),c=new Map(a);if(B!==void 0){let e=getAdvertisedTools({session:o,tools:buildDynamicTools(B)}),n=buildToolSetFromDefinitions({approvedTools:W,backgroundBatch:i,disabledProviderTools:t.disabledProviderTools,tools:e});for(let[e,t]of Object.entries(n)){let n=a.get(e);if(n?.runtimeAction!==void 0||n?.workflowId!==void 0)throw Error(`Dynamic tool "${e}" collides with a coordination-visible deferred tool.`);s[e]=t}let r=new Set;for(let t of e)r.has(t.name)||(r.add(t.name),c.set(t.name,t))}o.outputSchema!==void 0&&(s[FINAL_OUTPUT_TOOL_NAME]=buildFinalOutputTool(o.outputSchema));let l=await getAdvertisedTools({modelTools:s,session:o,tools:a});o=l.session;let u=l.modelTools,d=U?applyLastToolCacheBreakpoint(u,U):u;for(let e of Object.values(d)){e.inputSchema=toModelSchema(e.inputSchema,`input`),e.outputSchema!==void 0&&(e.outputSchema=toModelSchema(e.outputSchema,`output`));let t=e.execute;t!==void 0&&(e.execute=(...e)=>(r.protectToolExecution(),t(...e)));let n=e.onInputAvailable;n!==void 0&&(e.onInputAvailable=(...e)=>(r.protectToolExecution(),n(...e)))}return{effectiveTools:d,backgroundBatch:i,advertisedHarnessTools:a,modelTools:u,presentationTools:c}},runSingleModelCall=async t=>{let{effectiveTools:n,backgroundBatch:i,advertisedHarnessTools:s,modelTools:l,presentationTools:u}=await prepareModelTools(t);K=createRequestMessages(),Y=await estimateRequestEnvelope({history:z,instructions:prepareModelInstructions(t.extraSystemNote),messages:withTrailingUserNote(K.nonSystemMessages,t.trailingUserNote),tools:n});let d=R===void 0?void 0:Math.max(0,I.length-R.insertionIndex),f=await(async()=>{try{return await maybeCompact({abortSignal:e.abortSignal,auth:B?.get(AuthKey)??null,emit:h,emissionState:c,historyProjector:e.historyProjector,messages:[...I],model:H,promptMessages:createModelMessages(I),requestEnvelopeTokens:Y,resolveModel:e.resolveModel,runtimeIdentity:e.runtimeIdentity,session:o,telemetry:a?.telemetry()})}catch(e){throw X={error:e},e}})();o=f.session,f.compacted&&(I=f.messages,R!==void 0&&d!==void 0&&(R={...R,insertionIndex:Math.max(0,I.length-d)},o=setTurnClientContextState(o,R)),o={...o,compaction:{recentWindowSize:o.compaction.recentWindowSize,threshold:o.compaction.threshold,thresholdPercent:o.compaction.thresholdPercent}},z=validateHarnessModelMessages(normalizeModelMessages(projectHistory(createModelMessages(I),o.state))),K=createRequestMessages(),{effectiveTools:n,backgroundBatch:i,advertisedHarnessTools:s,modelTools:l,presentationTools:u}=await prepareModelTools(t),Y=await estimateRequestEnvelope({history:z,instructions:prepareModelInstructions(t.extraSystemNote),messages:withTrailingUserNote(K.nonSystemMessages,t.trailingUserNote),tools:n})),Y=Math.max(0,Y-(estimateTokens(K.history)-estimateTokens(I))),r.begin(),J=await hydrateSandboxAttachments(K.nonSystemMessages);let{instructions:m,telemetryRuntimeContext:g={}}=prepareModelCallInput(t.extraSystemNote);t.retryReason&&(g[`eve.retry.reason`]=t.retryReason);let _=withTrailingUserNote(J,t.trailingUserNote),v=activeTurnId(c),y=a?.prepareAttempt({attemptIndex:t.attemptIndex,runtimeContext:g,stepIndex:c.stepIndex,turnId:v});p=y?.scope;let b=buildStepHooks({auth:B?.get(AuthKey)??null,cachePath:oe,emit:h,emissionState:c,emitStepStarted:t.suppressStepStartedEmission!==!0,marker:U,session:o}),x={headers:se,instructions:m,model:H,onLanguageModelCallEnd(e){if(!r.interrupted){q=extractTokenUsageDelta({usage:e.usage,costUsd:extractGatewayCostUsd(e.providerMetadata)});for(let t of e.content)t.type!==`tool-call`||t.providerExecuted===!0||isInvalidToolCall(t)||i.register({callId:t.toolCallId,input:t.input,toolName:t.toolName})}},onToolExecutionEnd:logToolExecutionError,onError(e){r.interrupted||summarizeKnownError(e.error)?.tags.includes(`config`)!==!0&&logError(log,`tool-loop stream error`,e.error)},onStepEnd:b.onStepEnd,onStepStart:b.onStepStart,prepareStep:b.prepareStep,reasoning:o.agent.modelReference?.reasoning??o.agent.reasoning,runtimeContext:g,stopWhen:isStepCount(1),telemetry:y?.telemetry,toolApproval:buildToolApproval(l,r.signal),tools:n},S=new ToolLoopAgent(x),executeModelCall=async()=>{if(h){let t=[...e.tools].filter(([e,t])=>t.runtimeAction!==void 0&&s.get(e)===void 0).map(([e])=>e),n=new Set([FINAL_OUTPUT_TOOL_NAME,...t]),i=await S.stream({abortSignal:r.signal,messages:_}),{emittedActionCallIds:a,handledInlineToolResultCallIds:o,invalidInputToolCallIds:l,inlineAuthorizationResults:d,trailingInlineToolResultParts:f}=await emitStreamContent(h,c,interruptStreamOnFailure(i.fullStream,r.signal),{excludedActionToolNames:n,tools:u});throwIfTurnAborted(e.abortSignal),r.check();let[p,m]=await Promise.all([b.stepResult,i.responseMessages]);if(p.finishReason===`content-filter`)throw new ContentFilteredModelResponseError(readGatewayGenerationId(p.providerMetadata));if(isEmptyModelResponse(p)&&extractToolResultCallIds(m).size===0&&d.length===0&&f.length===0)throw new EmptyModelResponseError;await emitStepActions(h,c,p,{emittedActionCallIds:a,excludedActionCallIds:l,excludedActionToolNames:n,handledInlineToolResultCallIds:o,tools:u});let g=p.toolResults,v=new Map(g.map(e=>[e.toolCallId,e]));for(let e of d)v.set(e.toolCallId,e);return withAccumulatedResponseMessages({invalidInputToolCallIds:l,responseMessages:appendMissingToolResultMessages({append:f,responseMessages:m}),stepResult:p,toolResults:[...v.values()]})}let t=await S.generate({abortSignal:r.signal,messages:_});throwIfTurnAborted(e.abortSignal),r.check();let n=await b.stepResult;if(n.finishReason===`content-filter`)throw new ContentFilteredModelResponseError(readGatewayGenerationId(n.providerMetadata));if(isEmptyModelResponse(n)&&extractToolResultCallIds(t.responseMessages).size===0)throw new EmptyModelResponseError;return withAccumulatedResponseMessages({responseMessages:t.responseMessages,stepResult:n})};try{let e=await executeModelCall();return await y?.complete(),e}catch(e){return r.interrupted?await y?.complete():await y?.fail(e),r.check(),rethrowNoOutputAsEmptyResponse(e)}},fe=0,runOneModelCall=async e=>runModelCallWithRetries(t=>runSingleModelCall({...e,attemptIndex:fe++,suppressStepStartedEmission:t!==1||e.suppressStepStartedEmission}),{sessionId:o.sessionId,turnId:c.turnId,canRetry:()=>X===void 0},r.signal),pe=await enforceSessionUsageLimit({config:e,emit:h,emissionState:c,messages:z,session:o});if(pe!==null)return pe;let Z;try{Z=await runOneModelCall({suppressStepStartedEmission:!0})}catch(t){if(throwIfCompactionFailed(),throwIfTurnAborted(e.abortSignal),r.interrupted)return finishSteeredStep();let n=await runModelCallRecoveryPipeline({error:t,stages:[e=>attemptUnsupportedProviderToolRecovery({error:e.error,runOneModelCall,sessionId:o.sessionId,turnId:c.turnId}),e=>attemptEmptyResponseRecovery({emptyDeliveryEnabled:G.allowsEmptyDelivery,error:e.error,retryCallOptions:e.retryCallOptions,runOneModelCall,sessionId:o.sessionId,turnId:c.turnId})]});if(throwIfCompactionFailed(),throwIfTurnAborted(e.abortSignal),r.interrupted)return finishSteeredStep();if(n.outcome===`recovered`)Z=n.result;else{let e=n.error;if(a?.recordError(e),!h)throw e;let t=extractWorkflowStreamWriteErrorDetails(e);if(t!==null){let n=createErrorId();return log.error(`workflow stream write failed — parking session for retry by the user`,{...t,errorId:n,error:e,sessionId:o.sessionId,turnId:c.turnId}),c=await emitRecoverableFailedTurn(h,c,{code:`WORKFLOW_STREAM_WRITE_FAILED`,continuationToken:o.continuationToken,details:{...t,errorId:n},message:toErrorMessage(e)}),{next:null,session:setHarnessEmissionState(o,c)}}let r=classifyModelCallError(e),i=createErrorId(),s=summarizeKnownError(e),l=s===null?extractUpstreamRejectionMessage(e):null,u=s?.message??l?.message??toErrorMessage(e),d=s?.hint===void 0?u:`${u} ${s.hint}`,p=extractModelCallErrorDetails(e),m=buildModelCallFailureDetails({catalogSummary:s,error:e,errorId:i,modelCallDetails:p,upstreamRejection:l}),g=buildModelCallFailureLogFields({error:e,errorId:i,modelCallDetails:p,recognized:s!==null||l!==null,sessionId:o.sessionId,turnId:c.turnId});if(r===`terminal`)return s===null?log.error(l?.message??`model call failed terminally`,g):log.error(`${s.name}: ${s.message}`,{errorId:i,hint:s.hint,sessionId:o.sessionId,turnId:c.turnId}),await emitFailedStep(h,c,{code:`MODEL_CALL_FAILED`,details:m,message:u,sessionId:o.sessionId}),{next:f?{done:!0,isError:!0,output:d}:{done:!0,output:``},session:o};log.error(l?.message??`model call failed — parking session for retry by the user`,g),c=await emitRecoverableFailedTurn(h,c,{code:`MODEL_CALL_FAILED`,continuationToken:o.continuationToken,details:m,message:u});let _={isError:!0,output:d};return o={...o,outputSchema:void 0},{next:null,session:setHarnessEmissionState(o,c),settledTurn:_}}}let Q=accumulateTurnUsage({previous:getTurnUsageState(o.state),turnId:c.turnId,usage:extractTokenUsageDelta({costUsd:extractGatewayCostUsd(Z.providerMetadata),usage:Z.usage})});o=setTurnUsageState(o,Q),q=void 0;let $;try{$=formatLanguageModelGatewayId(H)}catch{$=void 0}await setEveAttributes({"$eve.model":$,"$eve.input_tokens":Q.inputTokens,"$eve.output_tokens":Q.outputTokens,"$eve.cache_read_tokens":Q.cacheReadTokens,"$eve.cache_write_tokens":Q.cacheWriteTokens,"$eve.cost_usd":Q.sawCost?Q.costUsd:void 0,"$eve.tool_count":e.tools.size});let me;try{r.check(),me=await handleStepResult({config:e,emit:h,emissionState:r.outputStarted?{...c,assistantOutputStarted:!0}:c,requestEnvelopeTokens:Y,durableModelPromptMessageCount:R===void 0||R.messages.length===0?J.length:void 0,promptMessages:K.history,result:Z,runStep,session:o,coordinationTools:de})}catch(t){if(throwIfTurnAborted(e.abortSignal),r.interrupted)return finishSteeredStep();throw t}return B?.set(HistoryStateKey,K.historyState),me}return runStep}function extractTokenUsageDelta(e){let t=e.usage;if(t!==void 0||e.costUsd!==void 0)return{cacheReadTokens:t?.inputTokenDetails?.cacheReadTokens,cacheWriteTokens:t?.inputTokenDetails?.cacheWriteTokens,costUsd:e.costUsd,inputTokens:t?.inputTokens,outputTokens:t?.outputTokens}}function extractGatewayCostUsd(e){let t=readGatewayMetadata(e)?.cost;if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`){let e=Number(t);return Number.isFinite(e)?e:void 0}}function readGatewayMetadata(e){let t=e?.gateway;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}function buildModelCallFailureDetails(e){let{catalogSummary:t,error:n,errorId:r,modelCallDetails:i,upstreamRejection:a}=e;if(t!==null){let e={errorId:r,message:t.message,name:t.name,semanticErrorId:t.id,...i};return t.hint!==void 0&&(e.hint=t.hint),e}return a===null?{...formatError(n,r),...i}:{errorId:r,message:toErrorMessage(n),name:a.name,...i}}function buildModelCallFailureLogFields(e){let t={errorId:e.errorId,sessionId:e.sessionId,turnId:e.turnId};return e.recognized?{...t,details:e.modelCallDetails}:{...t,error:e.error}}async function runModelCallRecoveryPipeline(e){let t=e.error,n;for(let r of e.stages){let e=await r({error:t,retryCallOptions:n});if(e.outcome===`recovered`)return e;e.outcome===`failed`&&(t=e.error,n=e.retryCallOptions)}return{outcome:`failed`,error:t}}function withAccumulatedResponseMessages(e){let{stepResult:t}=e;return{content:t.content,finishReason:t.finishReason,...e.invalidInputToolCallIds===void 0?{}:{invalidInputToolCallIds:e.invalidInputToolCallIds},providerMetadata:t.providerMetadata,response:{...t.response,messages:[...e.responseMessages]},text:t.text,toolCalls:t.toolCalls,toolResults:e.toolResults===void 0?t.toolResults:[...e.toolResults],usage:t.usage}}function appendMissingToolResultMessages(e){let t=extractToolResultCallIds(e.responseMessages),n=e.append.filter(e=>!t.has(e.toolCallId));return[...e.responseMessages,...n.length>0?[{role:`tool`,content:[...n]}]:[]]}function getInvalidToolCallInputErrors(e){let t=[];for(let n of e.toolCalls){if(n.toolName===FINAL_OUTPUT_TOOL_NAME)continue;let e=getInvalidToolCallInputError({toolCall:n});e!==void 0&&t.push(e)}return t}function extractToolResultCallIds(e){let t=new Set;for(let n of e)if(Array.isArray(n.content))for(let e of n.content)typeof e==`object`&&e&&e.type===`tool-result`&&t.add(e.toolCallId);return t}function hasUnansweredToolCall(e){let t=new Set,n=new Set;for(let r of e)if(Array.isArray(r.content))for(let e of r.content)typeof e==`object`&&e&&(e.type===`tool-call`&&t.add(e.toolCallId),e.type===`tool-result`&&n.add(e.toolCallId));for(let e of t)if(!n.has(e))return!0;return!1}async function attemptUnsupportedProviderToolRecovery(e){let t=extractUnsupportedProviderToolTypes(e.error);if(t.length===0)return{outcome:`skipped`};let n=[];for(let e of t){let t=resolveFrameworkToolFromUpstreamType(e);t!==null&&!n.includes(t)&&n.push(t)}if(n.length===0)return{outcome:`skipped`};log.warn(`disabling unsupported provider tool(s); retrying step once`,{disabled:n,sessionId:e.sessionId,turnId:e.turnId,upstreamTypes:t});let r={disabledProviderTools:new Set(n),extraSystemNote:buildDisabledToolNote(n)};try{return{outcome:`recovered`,result:await e.runOneModelCall({...r,suppressStepStartedEmission:!0})}}catch(e){return{outcome:`failed`,error:e,retryCallOptions:r}}}function buildDisabledToolNote(e){let t=e.join(`, `);return`The following ${e.length===1?`tool is`:`tools are`} not available with the current model and has been removed: ${t}. Proceed using the remaining tools or your training knowledge.`}function isEmptyModelResponse(e){return e.toolCalls.length===0&&e.toolResults.length===0&&resolveAssistantStepText(e.response.messages,e.text)===null}function rethrowNoOutputAsEmptyResponse(e){throw isNoOutputGeneratedError(e)?new EmptyModelResponseError({cause:e}):e}const EMPTY_RESPONSE_NUDGE=`Your previous reply was empty and was not delivered. Continue the current user request. Reuse completed results when they satisfy the request. If existing results are stale or insufficient, use the appropriate read tools to get fresh results. Do not repeat writes or other side effects that already completed. Do not mention this notice.`;function buildEmptyResponseNudge(e){return e?`${EMPTY_RESPONSE_NUDGE} If the current task explicitly requires conditional delivery and there is nothing to report, reply with exactly ${EMPTY_DELIVERY_SENTINEL}.`:EMPTY_RESPONSE_NUDGE}async function attemptEmptyResponseRecovery(e){if(!(e.error instanceof EmptyModelResponseError))return{outcome:`skipped`};log.warn(`empty model response; reissuing the model call once`,{sessionId:e.sessionId,turnId:e.turnId});try{return{outcome:`recovered`,result:await e.runOneModelCall({...e.retryCallOptions,retryReason:`empty-response`,suppressStepStartedEmission:!0,trailingUserNote:buildEmptyResponseNudge(e.emptyDeliveryEnabled)})}}catch(t){return{outcome:`failed`,error:t,retryCallOptions:e.retryCallOptions}}}async function handleStepResult(e){let{config:t,emit:n,promptMessages:r,result:i,runStep:a}=e,{emissionState:o,session:s}=e,c=resolveAssistantStepText(i.response.messages,i.text),l=i.finishReason!==`tool-calls`&&i.toolCalls.length===0&&hasEmptyDeliverySentinel(c),u=getInvalidToolCallInputErrors({toolCalls:i.toolCalls}),d=new Set([...i.invalidInputToolCallIds??[],...i.toolCalls.filter(isInvalidToolCall).map(e=>e.toolCallId),...u.map(e=>e.toolCallId)]),f=l?[]:appendMissingToolResultMessages({append:u.map(e=>createToolResultMessagePartFromToolError(e)),responseMessages:i.response.messages}),p=l?null:c,m=new Set;for(let e of[...i.content??[],...i.toolResults??[]])(e.type===`tool-result`||e.type===`tool-error`)&&e.providerExecuted===!0&&m.add(e.toolCallId);let h=normalizeProviderToolHistory({messages:f,providerExecutedOutcomeIds:m}),g=h.messages,_=setRequestEnvelopeTokens({...s,compaction:createNextCompactionConfig(s.compaction,e.durableModelPromptMessageCount,i)},i.usage?.inputTokens!==void 0&&e.durableModelPromptMessageCount!==void 0?e.requestEnvelopeTokens:void 0),v=extractToolApprovalInputRequests({content:i.content??[],excludedCallIds:d}),y=v,b=renderPendingApprovalsSnippet(v),x=g.findIndex(e=>e.role!==`tool`),S=x===-1?g:g.slice(0,x),C=g.slice(S.length),w=validateHarnessModelMessages([...r,...S,...b===void 0?[]:[createFrameworkUserMessage(`context.state`,b)]]),T=getAdvertisedTools({session:_,tools:e.coordinationTools}),E=(i.toolCalls??[]).filter(e=>!d.has(e.toolCallId)).filter(t=>isDeferredHarnessTool(e.coordinationTools.get(t.toolName))).filter(e=>isDeferredHarnessTool(T.get(e.toolName))?!0:(log.warn(`deferred tool call blocked because tool is not advertised`,{callId:e.toolCallId,sessionId:_.sessionId,toolName:e.toolName}),!1)).map(e=>createCoordinationRequestFromToolCall({toolCall:e,tools:T}));if(E.length>0){let e=E.flatMap(e=>e.kind===`runtime-action`?[e.request]:[]),i=E.flatMap(e=>e.kind===`task`?[e.request]:[]);if(y.length===0)return{next:null,session:setHarnessEmissionState(setPendingCoordinationBatch({runtimeActions:e,tasks:i,event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},responseMessages:g,session:{..._,history:validateHarnessModelMessages(r)}}),advanceStep(o))};let a=setPendingCoordinationBatch({runtimeActions:e,tasks:i,event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},responseMessages:C,session:{..._,history:w}});return a=appendPendingInputBatch({event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},requests:y,toolReplayIdentities:captureToolReplayIdentities(t,v),responseMessages:[],session:a}),n&&await n(createInputRequestedEvent({requests:y,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),{next:null,session:setHarnessEmissionState(a,advanceStep(o))}}if(y.length>0){let e=buildResponseAuthorizationTools({authoredTools:t.tools,context:contextStorage.getStore()}),r=appendPendingInputBatch({event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},requests:y,toolReplayIdentities:captureToolReplayIdentities(t,v),responseAuthRequiredRequestIds:v.filter(t=>{let n=e.get(t.action.toolName)?.approval;return n!==void 0&&typeof n!=`function`&&n.response!==void 0}).map(e=>e.requestId),responseMessages:C,session:{..._,history:w}});return n&&(await n(createInputRequestedEvent({requests:y,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),o=await emitTurnEpilogue(n,o),r=setHarnessEmissionState(r,o)),{next:hasRunnableDeferredStepInput(r)?a:null,session:r}}let D=resolveInlineAuthorizationInterrupt({messages:[...r,...g],toolResults:i.toolResults});if(D){let{challenges:e,history:t}=D;if(n){for(let t of getSupersededAuthorizationChallenges(_.state,e))await n(createAuthorizationCompletedEvent({attemptId:t.attemptId,authorization:t.challenge,name:t.name,outcome:`failed`,reason:`Superseded by a newer authorization attempt.`,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));for(let t of e)await n(createAuthorizationRequiredEvent({attemptId:t.attemptId,authorization:t.challenge,name:t.name,description:t.challenge.instructions??`Authorization required for ${t.name}`,webhookUrl:t.hookUrl,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));o=await emitTurnEpilogue(n,o)}return{next:null,session:setHarnessEmissionState({..._,history:validateHarnessModelMessages(t),state:setPendingAuthorization(_.state,{challenges:e})},o)}}let O=g,k=validateHarnessModelMessages([...r,...O]),A={..._,history:k};return(A.outputSchema===void 0||extractFinalOutput(i)===void 0)&&(O.at(-1)?.role===`tool`||h.outcomeEndsResponse||hasRunnableDeferredStepInput(A))?(n&&(o=advanceStep(o),A=setHarnessEmissionState(A,o)),{next:a,session:A}):finishTurn({emissionState:o,emit:n,history:r,result:i,schema:A.outputSchema,session:A,stepOutput:p})}function isDeferredHarnessTool(e){return e?.runtimeAction!==void 0||e?.workflowId!==void 0&&e.execution!==`background`}const OUTPUT_SCHEMA_NOT_FULFILLED={code:`OUTPUT_SCHEMA_NOT_FULFILLED`,message:`The agent could not produce a result matching the requested schema.`};function extractFinalOutput(e){return(e.toolCalls??[]).find(e=>e.toolName===FINAL_OUTPUT_TOOL_NAME&&!isInvalidToolCall(e))?.input}function persistStructuredAssistantTurn(e,t,n){return{...e,history:[...t,{content:JSON.stringify(n),role:`assistant`}],outputSchema:void 0}}async function emitStructuredResult(e,t,n){return await e(createResultCompletedEvent({result:n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId})),emitTurnEpilogue(e,t)}async function finishTurn(e){let{emit:t,history:n,result:r,schema:i,stepOutput:a}=e,{emissionState:o,session:s}=e;if(s=clearTurnClientContextState(s),i===void 0)return t&&(o=await emitTurnEpilogue(t,o),s=setHarnessEmissionState(s,o)),{next:null,session:s,settledTurn:{output:a??``}};let c=extractFinalOutput(r);if(c===void 0){s={...s,outputSchema:void 0},t&&(o=await emitRecoverableFailedTurn(t,o,{...OUTPUT_SCHEMA_NOT_FULFILLED,continuationToken:s.continuationToken}),s=setHarnessEmissionState(s,o));let e={isError:!0,output:OUTPUT_SCHEMA_NOT_FULFILLED.message};return{next:null,session:s,settledTurn:e}}return s=persistStructuredAssistantTurn(s,n,c),t&&(o=await emitStructuredResult(t,o,c),s=setHarnessEmissionState(s,o)),{next:null,session:s,settledTurn:{output:c}}}function createNextCompactionConfig(e,t,n){let r={recentWindowSize:e.recentWindowSize,threshold:e.threshold,thresholdPercent:e.thresholdPercent};return n.usage?.inputTokens!==void 0&&t!==void 0&&(r.lastKnownInputTokens=n.usage.inputTokens,r.lastKnownPromptMessageCount=t),r}function replaceSessionHistory(e,t){return contextStorage.getStore()?.delete(HistoryStateKey),{...e,history:t,compaction:{recentWindowSize:e.compaction.recentWindowSize,threshold:e.compaction.threshold,thresholdPercent:e.compaction.thresholdPercent}}}async function maybeCompact(e){let{emit:t,emissionState:n}=e,r=e.messages,i=e.session,a=e.promptMessages??r,o=validateHarnessModelMessages(e.historyProjector?.({messages:a,state:i.state})??a),s=e.force===!0||shouldCompact(o,i.compaction,e.requestEnvelopeTokens,getRequestEnvelopeTokens(i)),c=shouldCanonicalizeMemory(r);if(!s&&!c)return{compacted:!1,messages:r,session:i};let l=await resolveCompactionModel({compactionModelReference:i.agent.compactionModelReference,model:e.model,modelReference:requireSessionModelReference(i),resolveModel:e.resolveModel}),u=i.agent.compactionModelReference??requireSessionModelReference(i),d=resolveCallProviderOptions({auth:e.auth,conversationId:resolveConversationId(i.rootSessionId??i.sessionId),model:l.model,modelReference:u,providerOptions:l.providerOptions});if(t){let a=contextStorage.getStore();a!==void 0&&prepareMemoryCompaction(a,{history:r,state:i.state}),await t(createCompactionRequestedEvent({modelId:formatLanguageModelGatewayId(l.model),sequence:n.sequence,sessionId:i.sessionId,stepIndex:n.stepIndex,turnId:n.turnId,usageInputTokens:getInputTokenCount(o,i.compaction,e.requestEnvelopeTokens,getRequestEnvelopeTokens(i))}),o)}let f=canonicalizeMemoryRecords(r),p=validateHarnessModelMessages(e.historyProjector?.({messages:f.ordinary,state:i.state})??f.ordinary),m=e.requestEnvelopeTokens??0,h={...i.compaction,threshold:Math.max(1,i.compaction.threshold-m),lastKnownInputTokens:i.compaction.lastKnownInputTokens===void 0?void 0:Math.max(0,i.compaction.lastKnownInputTokens-Math.min(getRequestEnvelopeTokens(i)??0,m))},g=s?await compactMessages([...p],l.model,h,d,e.telemetry,buildGatewayAttributionHeaders(l.model,e.runtimeIdentity),e.abortSignal,e.force===!0,e.requestEnvelopeTokens===void 0?void 0:Math.max(0,getInputTokenCount(o,i.compaction,m,getRequestEnvelopeTokens(i))-m)):[...p];if(r=validateHarnessModelMessages([...f.memory,...g]),t){let a=contextStorage.getStore();if(a!==void 0&&prepareMemoryCompaction(a,{history:r,state:i.state}),await t(createCompactionCompletedEvent({modelId:formatLanguageModelGatewayId(l.model),sequence:n.sequence,sessionId:i.sessionId,stepIndex:n.stepIndex,turnId:n.turnId}),e.historyProjector?.({messages:r,state:i.state})??r),a!==void 0){let e=drainMemoryCommit(a);e!==void 0&&(r=validateHarnessModelMessages(e.history),i={...i,state:e.state})}}return{compacted:!0,messages:r,session:replaceSessionHistory(i,r)}}function captureToolReplayIdentities(e,t){let n=t.flatMap(t=>{let n=e.toolReplayIdentity?.(t.action.toolName);return n===void 0?[]:[[t.requestId,n]]});return n.length===0?void 0:Object.fromEntries(n)}function resolveApprovalKeyFromTools(e){return t=>{let n=e.get(t.action.toolName);if(n?.approvalKey!==void 0)return n.approvalKey(t.action.input)}}async function runModelCallWithRetries(e,t,n){for(let r=1;;r++){n.throwIfAborted();try{return await e(r)}catch(e){if(n.throwIfAborted(),t.canRetry?.()===!1||r===3||classifyModelCallError(e)!==`retry`)throw e;let i=500*2**(r-1)+Math.floor(Math.random()*250);log.warn(`model call failed transiently — retrying`,{attempt:r,delayMs:i,sessionId:t.sessionId,turnId:t.turnId,error:e}),await setTimeout(i,void 0,{signal:n})}}}export{appendMissingToolResultMessages,createToolLoopHarness};
|
|
3
|
+
`)};return t!==void 0&&(n.providerOptions=t),n}function buildGatewayAttributionHeaders(e,t){let n=resolveProviderHeaders(e);if(n===void 0)return;let r=t?.agentName??t?.agentId,i=process.env.VERCEL_PROJECT_PRODUCTION_URL||process.env.VERCEL_URL,a=i?`https://${i}`:void 0,o={...n};return r&&(o[`x-title`]=r),a&&(o[`http-referer`]=a),o}async function resolveEffectiveRuntimeModel(e){if(e.ctx===void 0){let t=e.session.agent.modelReference;if(t===void 0)throw Error(`Dynamic model selection is unavailable outside an eve runtime context.`);return{model:await e.config.resolveModel(t),session:e.session}}let t=getEffectiveModelSelection(e.ctx);if(t===null)throw Error(`Dynamic model selection is required before model-dependent work begins. Add a matching resolver handler that returns a concrete model.`);return{model:t.model===void 0?await e.config.resolveModel(t.reference):t.model,session:updateSessionModelReference(e.session,t.reference)}}function updateSessionModelReference(e,t){return e.agent.modelReference===t?e:{...e,agent:{...e.agent,modelReference:t},compaction:updateCompactionThresholdForModelReference({compaction:e.compaction,modelReference:t})}}function updateCompactionThresholdForModelReference(e){return e.modelReference.contextWindowTokens===void 0?e.compaction:{...e.compaction,threshold:Math.max(1,Math.floor(e.modelReference.contextWindowTokens*(e.compaction.thresholdPercent??.9)))}}function buildHarnessToolsWithDynamicSubagents(e,t){let n=new Map(e);if(t===void 0)return n;for(let e of buildDynamicSubagentTools(t)){if(n.has(e.name))throw Error(`Dynamic subagent "${e.name}" collides with another runtime-visible tool name.`);n.set(e.name,e)}return n}function createToolLoopHarness(e){e.instrumentation?.installAiSdkWarningLogger();let t=e.handleEvent;async function runStep(t,n){let executeStep=async r=>{let i=r?.session??t,a=new GenerationSteering({abortSignal:e.abortSignal,steeringSignal:e.steeringSignal,outputStarted:getHarnessEmissionState(i.state).assistantOutputStarted});try{return await executeStepBody(i,a,n,r)}finally{a.dispose()}};return e.instrumentation?.runStep({environment,eveVersion,hasInput:hasStepInput(n),session:t},executeStep)??executeStep()}async function executeStepBody(n,r,i,a){let o=n,s=createHistoryViewPreparer({previous:e.historyView,projector:e.historyProjector});s(o.history,o.state);let projectHistory=(e,t)=>s(e,t).messages,c=getHarnessEmissionState(o.state),l=contextStorage.getStore();l!==void 0&&!l.has(StaticModelReferenceKey)&&l.setVirtualContext(StaticModelReferenceKey,o.agent.dynamicModel===!0?null:o.agent.modelReference??null);let u=l?.get(ParentSessionKey),d=l?.get(SessionCallbackKey),f=u!==void 0||d!==void 0,p=f||l?.get(ScheduleIdKey)!==void 0,m,h=a?.createHandleEvent({getAttemptScope:()=>m,handleEvent:t,turnId:activeTurnId(c)})??t,g=h===void 0?void 0:async(e,t)=>{r.beforeEvent(e),await h(e,t)},failModelSelection=async(t,n)=>{if(throwIfTurnAborted(e.abortSignal),a?.recordError(t),!g)throw t;let r=createErrorId(),i=toErrorMessage(t);return log.error(`model selection failed terminally`,{error:t,errorId:r,sessionId:o.sessionId,turnId:n.turnId}),await emitFailedStep(g,n,{code:`MODEL_SELECTION_FAILED`,details:{errorId:r},message:i,sessionId:o.sessionId,usage:getSessionUsage(o)}),{next:f?{done:!0,isError:!0,output:i}:{done:!0,output:``},session:o}},failBoundaryEvent=async(t,n)=>{if(throwIfTurnAborted(e.abortSignal),isTurnCancellation(t))throw t;if(isDynamicModelSelectionError(t))return failModelSelection(t,n);throw t},preparePreambleTrace=async()=>await a?.preparePreamble({sequence:c.sequence,sessionStarted:c.sessionStarted,traceContext:a?.traceContext,turnId:activeTurnId(c)});if(e.clearOnly===!0)return o={...o,state:clearMemorySessionState(o.state)},o=replaceSessionHistory(o,[]),await g?.(createContextClearedEvent({sequence:c.sequence,sessionId:o.sessionId,turnId:activeTurnId(c)})),await g?.(createSessionWaitingEvent(getSessionUsage(o))),{next:null,session:o};if(e.compactOnly===!0){if(o.history.length>0)try{let t=contextStorage.getStore(),n=await resolveEffectiveRuntimeModel({config:e,ctx:t,session:o});o=n.session,o=(await maybeCompact({abortSignal:e.abortSignal,auth:t?.get(AuthKey)??null,emit:g,emissionState:{...c,turnId:activeTurnId(c)},force:!0,historyProjector:e.historyProjector,messages:[...o.history],model:n.model,requestEnvelopeTokens:getRequestEnvelopeTokens(o),resolveModel:e.resolveModel,runtimeIdentity:e.runtimeIdentity,session:o,telemetry:a?.telemetry()})).session}catch(e){logError(log,`manual session compaction failed`,e,{sessionId:o.sessionId})}return await g?.(createSessionWaitingEvent(getSessionUsage(o))),{next:null,session:o}}let _=getPendingCoordinationBatch(o.state),v=_===void 0?consumeDeferredStepInput({input:i,session:o}):{input:i,session:o};o=v.session;let y=await resolvePendingCoordination({emit:g,session:o,stepInput:v.input,tools:e.tools});if(y.outcome===`unresolved`)return{next:null,session:y.session};o=y.session;let b=getPendingInputRequestIds(o.state),x=convertStaleResponsesToUserMessage({history:y.messages,pendingRequestIds:b,stepInput:dropStaleSessionLimitContinuationResponses({pendingRequestIds:b,stepInput:v.input})}),S=x.stepInput;if(i?.message!==void 0||x.kind===`converted`){let e=withdrawHeldSignIns(o.state,{completedAt:Date.now(),reason:STEERED_SIGN_IN_REASON});if(o={...o,state:e.state},e.withdrawn.length>0){if(g)for(let t of declinedSignInEvents(e.withdrawn,STEERED_SIGN_IN_REASON,c))await g(t);let t=[...new Set(e.withdrawn.map(e=>e.name))];S={...S,context:[...S?.context??[],`Sign-in to ${t.join(`, `)} was cancelled because the user sent a new message instead. Ask to sign in again only if the new message still needs it.`]}}}let C=x.kind===`converted`?{...S,message:x.displayMessage}:S,w=contextStorage.getStore(),prepareApprovalTools=async t=>(t?.event!==void 0&&await e.prepareApprovalTurn?.(t.event),w!==void 0&&await e.resolveStepDynamicTools?.({ctx:w,event:createStepStartedEvent({modelId:o.agent.modelReference?.id??`dynamic`,...t?.event??c}),messages:projectHistory(y.messages,o.state)}),buildResponseAuthorizationTools({authoredTools:e.tools,context:w})),T=getPendingAuthorization(o.state)?.challenges??[],E=await coordinateApprovalDelivery({session:o,stepInput:S,tools:e.tools,prepareTools:async e=>{let t=getPendingInputBatches(o.state).find(t=>t.requests.some(t=>t.requestId===e.requestId));return await prepareApprovalTools(t)}});if(o=E.session,g){for(let e of E.feedback)await g(createMessageCompletedEvent({message:e,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId}));let e=getApprovalAuditState(o.state);for(let t of T)e.candidateHistory.some(e=>e.candidateId===t.candidateId&&e.status===`timed-out`&&e.eventEmitted!==!0)&&await g(createAuthorizationCompletedEvent({...authorizationEventFields(t),outcome:`failed`,reason:`The approval response expired. Please submit a new response.`,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId}));for(let t of e.activeCandidates.filter(e=>e.pendingEventEmitted!==!0))await g(createApprovalCandidateEvent({candidateId:t.candidateId,outcome:`pending`,requestId:t.requestId,responderPrincipalId:t.responder.principalId,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId})),o={...o,state:markApprovalCandidatePendingEventEmitted({candidateId:t.candidateId,state:o.state})};for(let t of e.candidateHistory.filter(e=>e.eventEmitted!==!0&&e.status!==`allowed`))await g(createApprovalCandidateEvent({candidateId:t.candidateId,outcome:t.status,requestId:t.requestId,responderPrincipalId:t.responder.principalId,reason:t.reason,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId})),o={...o,state:markApprovalCandidateHistoryEventEmitted({candidateId:t.candidateId,state:o.state})};for(let t of e.settlements.filter(e=>e.eventEmitted!==!0))await g(createApprovalSettledEvent({outcome:t.outcome===`allowed`?`approved`:`cancelled`,requestId:t.requestId,responderPrincipalId:t.actor.principalId,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId})),o={...o,state:markApprovalSettlementEventEmitted({requestId:t.requestId,state:o.state})}}if(E.kind===`park`)return{next:null,session:o};if(E.kind===`continue-coordination`)return{next:runStep,session:E.stepInput===void 0?o:queueDeferredStepInput(o,E.stepInput)};if(E.challenges.length>0){if(g){for(let e of E.challenges)await g(createAuthorizationRequiredEvent({...authorizationEventFields(e),description:e.challenge.instructions??`Authorization required for ${e.name}`,sequence:c.sequence,stepIndex:c.stepIndex,turnId:c.turnId,webhookUrl:e.hookUrl}));c=await holdTurnForRequest(g,c,o)}let e=E.stepInput===void 0?o:queueDeferredStepInput(o,E.stepInput);return{held:{kind:`request`},next:null,session:setHarnessEmissionState({...e,state:setPendingAuthorization(e.state,{challenges:E.challenges})},c)}}let D=_!==void 0&&hasTailApprovalResponse(y.messages)?_:selectApprovalReplayBatch(o,E.stepInput),O=D===void 0?e.tools:await prepareApprovalTools(D),k=resolvePendingInput({history:y.messages,resolveApprovalKey:resolveApprovalKeyFromTools(O),session:o,stepInput:E.stepInput});if(k.outcome===`unresolved`){let e=y.outcome===`resolved`?{...k.session,history:validateHarnessModelMessages(y.messages)}:k.session;return g&&(c=await holdTurnForRequest(g,c,e),e=setHarnessEmissionState(e,c)),{held:{kind:`request`},next:null,session:e}}if(k.resolvedInputs!==void 0)for(let e of k.resolvedInputs)await a?.publishInputResolutions({batch:e,sessionId:o.sessionId}),g&&await g(createInputResolvedEvent({resolutions:e.inputs.map(e=>{let t={kind:e.request.kind,outcome:e.outcome,requestId:e.request.requestId};return e.response===void 0?t:{...t,response:e.response}}),sequence:e.event.sequence,stepIndex:e.event.stepIndex,turnId:e.event.turnId}));if(g&&k.rejectedActions)for(let e of k.rejectedActions)for(let t of e.results)await g(createActionResultEvent({rejected:!0,result:t,sequence:e.event.sequence,stepIndex:e.event.stepIndex,turnId:e.event.turnId}));let ee=activeTurnId(c),A=getTurnClientContextState(k.session.state,ee),j=k.deferredContext===!0?void 0:readClientContext(S),M=(j??A?.messages)?.map(e=>createFrameworkUserMessage(`context.instruction`,e))??[],N=[];if(S?.context!==void 0&&k.deferredContext!==!0)for(let e of S.context)N.push(createFrameworkUserMessage(`context.instruction`,e));let P=frameworkMessageKindForStepInput(S),F=normalizeUserContent(S?.message),I=F!==void 0&&!k.deferredMessage&&!k.consumedMessage?await stageAttachmentsToSandbox(F):void 0;I!==void 0&&N.push(P===void 0?createUserMessage(`user`,I):createFrameworkUserMessage(P,I));let L=[],R;if(g&&(hasStepInput(S)||hasStepInput(E.stepInput))){l!==void 0&&(prepareDynamicInstructionPreamble(l,projectHistory(k.session.history,k.session.state)),prepareMemoryPreamble(l,{history:k.messages,input:[...M,...N],projector:e.historyProjector,state:k.session.state}));try{let t=await preparePreambleTrace();c=await emitTurnPreamble(g,k.deferredMessage===!0?{...C,message:void 0}:C??{},c,projectHistory([...k.messages,...M,...N],k.session.state),e.runtimeIdentity,t)}catch(e){return L=l===void 0?[]:drainDynamicInstructionUserMessages(l),R=l===void 0?void 0:drainMemoryCommit(l),o={...k.session,history:validateHarnessModelMessages([...k.session.history,...R?.recalledMessages??[],...L]),state:R?.state??k.session.state},failBoundaryEvent(e,{sessionStarted:!0,sequence:c.sequence,stepIndex:0,turnId:activeTurnId(c)})}L=l===void 0?[]:drainDynamicInstructionUserMessages(l),R=l===void 0?void 0:drainMemoryCommit(l),a?.setTurnId(c.turnId)}let te=k.session.history.length,ne=[...R?.recalledMessages??[],...L];o=setHarnessEmissionState({...k.session,history:validateHarnessModelMessages([...k.session.history,...ne]),state:R?.state??k.session.state},c);let z=validateHarnessModelMessages([...k.messages.slice(0,te),...ne,...k.messages.slice(te)]),B=await applySessionLimitContinuation({config:e,emit:g,emissionState:c,limitContinuation:k.limitContinuation,session:o});if(B.result!==null)return B.result;if(o=B.session,!hasUnansweredToolCall(z)){let t=await appendTaskContext({messages:z,projectHistory,session:o,tools:e.tools});o=t.session,z.push(...t.messages)}let V=A;j!==void 0&&(V={insertionIndex:A?.insertionIndex??z.length,messages:j,turnId:ee}),V!==void 0&&(o=setTurnClientContextState(o,V));let re=I!==void 0&&P===void 0&&followsToolResults(z);z=[...z,...re?[{content:TOOL_RESULT_BOUNDARY,role:`assistant`}]:[],...N];let createModelMessages=e=>{if(V===void 0||V.messages.length===0)return[...e];let t=Math.min(Math.max(0,V.insertionIndex),e.length);return[...e.slice(0,t),...V.messages.map(e=>createFrameworkUserMessage(`context.instruction`,e)),...e.slice(t)]},H=validateHarnessModelMessages(projectHistory(createModelMessages(z),o.state)),U=l,W;try{U!==void 0&&e.dispatchDynamicModelEvent!==void 0&&await e.dispatchDynamicModelEvent({ctx:U,event:{data:{sequence:c.sequence,stepIndex:c.stepIndex,turnId:activeTurnId(c)},type:`step.started`},messages:H}),W=await resolveEffectiveRuntimeModel({config:e,ctx:U,session:o})}catch(e){return failModelSelection(e,c)}o=W.session;let G=W.model,ie=detectPromptCachePath(G),K=ie.kind===`anthropic-direct`?getAnthropicCacheMarker():void 0,ae=buildGatewayAttributionHeaders(G,e.runtimeIdentity);if(H=validateHarnessModelMessages(normalizeModelMessages(projectHistory(createModelMessages(z),o.state))),g)try{await emitStepStarted(g,c,requireSessionModelReference(o).id,H)}catch(e){return failBoundaryEvent(e,c)}let oe=(k.resolvedInputs??[]).flatMap(e=>e.inputs.filter(e=>e.outcome===`approved`));if(oe.length>0){let t=buildResponseAuthorizationTools({authoredTools:e.tools,context:U});for(let{request:e}of oe)if(!t.has(e.action.toolName))throw Error(`The approved tool is no longer available. Request a new tool call and approval.`)}let se=getApprovedTools(o,resolveApprovalKeyFromTools(buildResponseAuthorizationTools({authoredTools:e.tools,context:U}))),ce=e.tools,le=new Map,createRequestMessages=()=>{let e=createCurrentMessages(z,{historyState:U?.get(HistoryStateKey),currentTurnMessages:N,projectedMessages:H});U!==void 0&&e.addSystem(buildDynamicInstructionMessages(U)),e.addSystem(taskSystemMessages(ce,{finalReplyOnly:p})),e.addAnnouncements({availableSkills:U?.get(PendingSkillAnnouncementKey),keyed:getPendingAnnouncements(U)});let t=renderPendingApprovalsInstruction(getPendingInputBatches(o.state).flatMap(e=>e.requests));return t!==void 0&&e.add(t,`context.state`,{cacheFriendly:!1}),e},q=createRequestMessages(),J,finishSteeredStep=()=>(throwIfTurnAborted(e.abortSignal),U?.set(HistoryStateKey,q.historyState),J!==void 0&&(o=setTurnUsageState(o,accumulateTurnUsage({previous:getTurnUsageState(o.state),turnId:c.turnId,usage:J}))),{steered:!0,next:runStep,session:setHarnessEmissionState({...o,history:[...q.history]},advanceStep(c))}),Y=[],withTrailingUserNote=(e,t)=>t?[...e,createFrameworkUserMessage(`execution.retry`,t)]:[...e],prepareModelInstructions=e=>{let t=e?[{role:`system`,content:e}]:[],n=o.agent.system?[{role:`system`,content:o.agent.system}]:[],r=q.systemMessages.length>0||t.length>0?[...t,...n,...q.systemMessages]:void 0,i=r!==void 0&&K?applySystemCacheBreakpoint(r,K):r;return i===void 0?o.agent.system??void 0:mergeSystemInstructions(i)},prepareModelCallInput=e=>{let t=prepareModelInstructions(e);return{instructions:t,telemetryRuntimeContext:a?.resolveRuntimeContext({eveVersion,emissionState:c,environment,modelInput:{instructions:t,messages:Y},session:o})}},X=0,Z,throwIfCompactionFailed=()=>{if(Z!==void 0)throw Z.error},prepareModelTools=async t=>{let n=buildHarnessToolsWithDynamicSubagents(e.tools,U),i=withTaskTools(getAdvertisedTools({session:o,tools:n}));ce=i;let a=await buildToolSetWithProviderTools({approvedTools:se,disabledProviderTools:t.disabledProviderTools,modelReference:requireSessionModelReference(o),tools:i}),s=new Map(i);if(U!==void 0){let e=getAdvertisedTools({session:o,tools:buildDynamicTools(U)}),n=buildToolSetFromDefinitions({approvedTools:se,disabledProviderTools:t.disabledProviderTools,tools:e});for(let[e,t]of Object.entries(n)){if(i.get(e)?.workflowId!==void 0)throw Error(`Dynamic tool "${e}" collides with a coordination-visible deferred tool.`);a[e]=t}let r=new Set;for(let t of e)r.has(t.name)||(r.add(t.name),s.set(t.name,t))}o.outputSchema!==void 0&&(a[FINAL_OUTPUT_TOOL_NAME]=buildFinalOutputTool(o.outputSchema));let c=await getAdvertisedTools({modelTools:a,session:o,tools:i});o=c.session;let l=c.modelTools,u=new Map;if(!f&&o.outputSchema===void 0)for(let[e,t]of Object.entries(l)){let n=s.get(e)?.endsTurn;t.type!==`provider`&&n!==void 0&&n!==!1&&(u.set(e,n),n===!0&&(t.description=`${t.description??``}\n\n${ENDS_TURN_TOOL_NOTE}`.trimStart()))}le=u;let d=K?applyLastToolCacheBreakpoint(l,K):l;for(let e of Object.values(d)){e.inputSchema=toModelSchema(e.inputSchema,`input`),e.outputSchema!==void 0&&(e.outputSchema=toModelSchema(e.outputSchema,`output`));let t=e.execute;t!==void 0&&(e.execute=(...e)=>(r.protectToolExecution(),t(...e)))}return{effectiveTools:d,modelTools:l,presentationTools:s}},runSingleModelCall=async t=>{let{effectiveTools:n,modelTools:i,presentationTools:s}=await prepareModelTools(t);q=createRequestMessages(),X=await estimateRequestEnvelope({history:H,instructions:prepareModelInstructions(t.extraSystemNote),messages:withTrailingUserNote(q.nonSystemMessages,t.trailingUserNote),tools:n});let l=V===void 0?void 0:Math.max(0,z.length-V.insertionIndex),u=await(async()=>{try{return await maybeCompact({abortSignal:e.abortSignal,auth:U?.get(AuthKey)??null,emit:g,emissionState:c,historyProjector:e.historyProjector,messages:[...z],model:G,promptMessages:createModelMessages(z),requestEnvelopeTokens:X,resolveModel:e.resolveModel,runtimeIdentity:e.runtimeIdentity,session:o,telemetry:a?.telemetry()})}catch(e){throw Z={error:e},e}})();o=u.session,u.compacted&&(z=u.messages,V!==void 0&&l!==void 0&&(V={...V,insertionIndex:Math.max(0,z.length-l)},o=setTurnClientContextState(o,V)),o={...o,compaction:{recentWindowSize:o.compaction.recentWindowSize,threshold:o.compaction.threshold,thresholdPercent:o.compaction.thresholdPercent}},H=validateHarnessModelMessages(normalizeModelMessages(projectHistory(createModelMessages(z),o.state))),q=createRequestMessages(),{effectiveTools:n,modelTools:i,presentationTools:s}=await prepareModelTools(t),X=await estimateRequestEnvelope({history:H,instructions:prepareModelInstructions(t.extraSystemNote),messages:withTrailingUserNote(q.nonSystemMessages,t.trailingUserNote),tools:n})),X=Math.max(0,X-(estimateTokens(q.history)-estimateTokens(z))),r.begin(),Y=await hydrateSandboxAttachments(q.nonSystemMessages);let{instructions:d,telemetryRuntimeContext:f={}}=prepareModelCallInput(t.extraSystemNote);t.retryReason&&(f[`eve.retry.reason`]=t.retryReason);let h=withTrailingUserNote(Y,t.trailingUserNote),_=activeTurnId(c),v=a?.prepareAttempt({attemptIndex:t.attemptIndex,runtimeContext:f,stepIndex:c.stepIndex,turnId:_});m=v?.scope;let y=buildStepHooks({auth:U?.get(AuthKey)??null,cachePath:ie,emit:g,emissionState:c,emitStepStarted:t.suppressStepStartedEmission!==!0,marker:K,session:o}),b={headers:ae,instructions:d,model:G,onLanguageModelCallEnd(e){r.interrupted||(J=extractTokenUsageDelta({usage:e.usage,costUsd:extractGatewayCostUsd(e.providerMetadata)}))},onToolExecutionEnd:logToolExecutionError,onError(e){r.interrupted||summarizeKnownError(e.error)?.tags.includes(`config`)!==!0&&logError(log,`tool-loop stream error`,e.error)},onStepEnd:y.onStepEnd,onStepStart:y.onStepStart,prepareStep:y.prepareStep,reasoning:o.agent.modelReference?.reasoning??o.agent.reasoning,runtimeContext:f,stopWhen:isStepCount(1),telemetry:v?.telemetry,toolApproval:buildToolApproval(i,r.signal),tools:n},x=new ToolLoopAgent(b),executeModelCall=async()=>{if(g){let t=new Set([FINAL_OUTPUT_TOOL_NAME]),n=await x.stream({abortSignal:r.signal,messages:h}),{emittedActionCallIds:i,handledInlineToolResultCallIds:a,invalidInputToolCallIds:l,inlineAuthorizationResults:u,trailingInlineToolResultParts:d}=await emitStreamContent(g,c,interruptStreamOnFailure(n.fullStream,r.signal),{excludedActionToolNames:t,hidesHeldText:p&&workingTaskIds(o).length>0,tools:s});throwIfTurnAborted(e.abortSignal),r.check();let[f,m]=await Promise.all([y.stepResult,n.responseMessages]);if(f.finishReason===`content-filter`)throw new ContentFilteredModelResponseError(readGatewayGenerationId(f.providerMetadata));if(isEmptyModelResponse(f)&&extractToolResultCallIds(m).size===0&&u.length===0&&d.length===0)throw new EmptyModelResponseError;await emitStepActions(g,c,f,{emittedActionCallIds:i,excludedActionCallIds:l,excludedActionToolNames:t,handledInlineToolResultCallIds:a,tools:s});let _=f.toolResults,v=new Map(_.map(e=>[e.toolCallId,e]));for(let e of u)v.set(e.toolCallId,e);return withAccumulatedResponseMessages({invalidInputToolCallIds:l,responseMessages:appendMissingToolResultMessages({append:d,responseMessages:m}),stepResult:f,toolResults:[...v.values()]})}let t=await x.generate({abortSignal:r.signal,messages:h});throwIfTurnAborted(e.abortSignal),r.check();let n=await y.stepResult;if(n.finishReason===`content-filter`)throw new ContentFilteredModelResponseError(readGatewayGenerationId(n.providerMetadata));if(isEmptyModelResponse(n)&&extractToolResultCallIds(t.responseMessages).size===0)throw new EmptyModelResponseError;return withAccumulatedResponseMessages({responseMessages:t.responseMessages,stepResult:n})};try{let e=await executeModelCall();return await v?.complete(),e}catch(e){return r.interrupted?await v?.complete():await v?.fail(e),r.check(),rethrowNoOutputAsEmptyResponse(e)}},ue=0,runOneModelCall=async e=>runModelCallWithRetries(t=>runSingleModelCall({...e,attemptIndex:ue++,suppressStepStartedEmission:t!==1||e.suppressStepStartedEmission}),{sessionId:o.sessionId,turnId:c.turnId,canRetry:()=>Z===void 0},r.signal),de=dispatchApprovedWorkflowCalls({messages:z,resolvedInputs:k.resolvedInputs,session:o,tools:buildResponseAuthorizationTools({authoredTools:e.tools,context:U})});if(de!==void 0)return{next:null,session:setHarnessEmissionState(de,advanceStep(c))};let fe=await enforceSessionUsageLimit({config:e,emit:g,emissionState:c,messages:H,session:o});if(fe!==null)return fe;let Q;try{Q=await runOneModelCall({suppressStepStartedEmission:!0})}catch(t){if(throwIfCompactionFailed(),throwIfTurnAborted(e.abortSignal),r.interrupted)return finishSteeredStep();let n=await runModelCallRecoveryPipeline({error:t,stages:[e=>attemptUnsupportedProviderToolRecovery({error:e.error,runOneModelCall,sessionId:o.sessionId,turnId:c.turnId}),e=>attemptEmptyResponseRecovery({error:e.error,retryCallOptions:e.retryCallOptions,runOneModelCall,sessionId:o.sessionId,turnId:c.turnId})]});if(throwIfCompactionFailed(),throwIfTurnAborted(e.abortSignal),r.interrupted)return finishSteeredStep();if(n.outcome===`recovered`)Q=n.result;else{let e=n.error;if(a?.recordError(e),!g)throw e;let t=extractWorkflowStreamWriteErrorDetails(e);if(t!==null){let n=createErrorId();return log.error(`workflow stream write failed — parking session for retry by the user`,{...t,errorId:n,error:e,sessionId:o.sessionId,turnId:c.turnId}),c=await emitRecoverableFailedTurn(g,c,{code:`WORKFLOW_STREAM_WRITE_FAILED`,continuationToken:o.continuationToken,usage:getSessionUsage(o),details:{...t,errorId:n},message:toErrorMessage(e)}),{next:null,session:setHarnessEmissionState(o,c)}}let r=classifyModelCallError(e),i=createErrorId(),s=summarizeKnownError(e),l=s===null?extractUpstreamRejectionMessage(e):null,u=s?.message??l?.message??toErrorMessage(e),d=s?.hint===void 0?u:`${u} ${s.hint}`,p=extractModelCallErrorDetails(e),m=buildModelCallFailureDetails({catalogSummary:s,error:e,errorId:i,modelCallDetails:p,upstreamRejection:l}),h=buildModelCallFailureLogFields({error:e,errorId:i,modelCallDetails:p,recognized:s!==null||l!==null,sessionId:o.sessionId,turnId:c.turnId});if(r===`terminal`)return s===null?log.error(l?.message??`model call failed terminally`,h):log.error(`${s.name}: ${s.message}`,{errorId:i,hint:s.hint,sessionId:o.sessionId,turnId:c.turnId}),await emitFailedStep(g,c,{code:`MODEL_CALL_FAILED`,details:m,message:u,sessionId:o.sessionId,usage:getSessionUsage(o)}),{next:f?{done:!0,isError:!0,output:d}:{done:!0,output:``},session:o};log.error(l?.message??`model call failed — parking session for retry by the user`,h),c=await emitRecoverableFailedTurn(g,c,{code:`MODEL_CALL_FAILED`,continuationToken:o.continuationToken,usage:getSessionUsage(o),details:m,message:u});let _={isError:!0,output:d};return o={...o,outputSchema:void 0},{next:null,session:setHarnessEmissionState(o,c),settledTurn:_}}}let $=accumulateTurnUsage({previous:getTurnUsageState(o.state),turnId:c.turnId,usage:extractTokenUsageDelta({costUsd:extractGatewayCostUsd(Q.providerMetadata),usage:Q.usage})});o=setTurnUsageState(o,$),J=void 0;let pe;try{pe=formatLanguageModelGatewayId(G)}catch{pe=void 0}await setEveAttributes({"$eve.model":pe,"$eve.input_tokens":$.inputTokens,"$eve.output_tokens":$.outputTokens,"$eve.cache_read_tokens":$.cacheReadTokens,"$eve.cache_write_tokens":$.cacheWriteTokens,"$eve.cost_usd":$.sawCost?$.costUsd:void 0,"$eve.tool_count":e.tools.size});let me;try{r.check(),me=await handleStepResult({config:e,emit:g,emissionState:r.outputStarted?{...c,assistantOutputStarted:!0}:c,requestEnvelopeTokens:X,durableModelPromptMessageCount:V===void 0||V.messages.length===0?Y.length:void 0,promptMessages:q.history,result:Q,runStep,session:o,coordinationTools:ce,endsTurnTools:le})}catch(t){if(throwIfTurnAborted(e.abortSignal),r.interrupted)return finishSteeredStep();throw t}return U?.set(HistoryStateKey,q.historyState),me}return runStep}function extractTokenUsageDelta(e){let t=e.usage;if(t!==void 0||e.costUsd!==void 0)return{cacheReadTokens:t?.inputTokenDetails?.cacheReadTokens,cacheWriteTokens:t?.inputTokenDetails?.cacheWriteTokens,costUsd:e.costUsd,inputTokens:t?.inputTokens,outputTokens:t?.outputTokens}}function extractGatewayCostUsd(e){let t=readGatewayMetadata(e)?.cost;if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`){let e=Number(t);return Number.isFinite(e)?e:void 0}}function readGatewayMetadata(e){let t=e?.gateway;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}function buildModelCallFailureDetails(e){let{catalogSummary:t,error:n,errorId:r,modelCallDetails:i,upstreamRejection:a}=e;if(t!==null){let e={errorId:r,message:t.message,name:t.name,semanticErrorId:t.id,...i};return t.hint!==void 0&&(e.hint=t.hint),e}return a===null?{...formatError(n,r),...i}:{errorId:r,message:toErrorMessage(n),name:a.name,...i}}function buildModelCallFailureLogFields(e){let t={errorId:e.errorId,sessionId:e.sessionId,turnId:e.turnId};return e.recognized?{...t,details:e.modelCallDetails}:{...t,error:e.error}}async function runModelCallRecoveryPipeline(e){let t=e.error,n;for(let r of e.stages){let e=await r({error:t,retryCallOptions:n});if(e.outcome===`recovered`)return e;e.outcome===`failed`&&(t=e.error,n=e.retryCallOptions)}return{outcome:`failed`,error:t}}function withAccumulatedResponseMessages(e){let{stepResult:t}=e;return{content:t.content,finishReason:t.finishReason,...e.invalidInputToolCallIds===void 0?{}:{invalidInputToolCallIds:e.invalidInputToolCallIds},providerMetadata:t.providerMetadata,response:{...t.response,messages:[...e.responseMessages]},text:t.text,toolCalls:t.toolCalls,toolResults:e.toolResults===void 0?t.toolResults:[...e.toolResults],usage:t.usage}}function appendMissingToolResultMessages(e){let t=extractToolResultCallIds(e.responseMessages),n=e.append.filter(e=>!t.has(e.toolCallId));return[...e.responseMessages,...n.length>0?[{role:`tool`,content:[...n]}]:[]]}function getInvalidToolCallInputErrors(e){let t=[];for(let n of e.toolCalls){if(n.toolName===FINAL_OUTPUT_TOOL_NAME)continue;let e=getInvalidToolCallInputError({toolCall:n});e!==void 0&&t.push(e)}return t}function extractToolResultCallIds(e){let t=new Set;for(let n of e)if(Array.isArray(n.content))for(let e of n.content)typeof e==`object`&&e&&e.type===`tool-result`&&t.add(e.toolCallId);return t}function hasUnansweredToolCall(e){let t=new Set,n=new Set;for(let r of e)if(Array.isArray(r.content))for(let e of r.content)typeof e==`object`&&e&&(e.type===`tool-call`&&t.add(e.toolCallId),e.type===`tool-result`&&n.add(e.toolCallId));for(let e of t)if(!n.has(e))return!0;return!1}async function attemptUnsupportedProviderToolRecovery(e){let t=extractUnsupportedProviderToolTypes(e.error);if(t.length===0)return{outcome:`skipped`};let n=[];for(let e of t){let t=resolveFrameworkToolFromUpstreamType(e);t!==null&&!n.includes(t)&&n.push(t)}if(n.length===0)return{outcome:`skipped`};log.warn(`disabling unsupported provider tool(s); retrying step once`,{disabled:n,sessionId:e.sessionId,turnId:e.turnId,upstreamTypes:t});let r={disabledProviderTools:new Set(n),extraSystemNote:buildDisabledToolNote(n)};try{return{outcome:`recovered`,result:await e.runOneModelCall({...r,suppressStepStartedEmission:!0})}}catch(e){return{outcome:`failed`,error:e,retryCallOptions:r}}}function buildDisabledToolNote(e){let t=e.join(`, `);return`The following ${e.length===1?`tool is`:`tools are`} not available with the current model and has been removed: ${t}. Proceed using the remaining tools or your training knowledge.`}function isEmptyModelResponse(e){return e.toolCalls.length===0&&e.toolResults.length===0&&resolveAssistantStepText(e.response.messages,e.text)===null}function rethrowNoOutputAsEmptyResponse(e){throw isNoOutputGeneratedError(e)?new EmptyModelResponseError({cause:e}):e}async function attemptEmptyResponseRecovery(e){if(!(e.error instanceof EmptyModelResponseError))return{outcome:`skipped`};log.warn(`empty model response; reissuing the model call once`,{sessionId:e.sessionId,turnId:e.turnId});try{return{outcome:`recovered`,result:await e.runOneModelCall({...e.retryCallOptions,retryReason:`empty-response`,suppressStepStartedEmission:!0,trailingUserNote:`Your previous reply was empty and was not delivered. Continue the current user request. Reuse completed results when they satisfy the request. If existing results are stale or insufficient, use the appropriate read tools to get fresh results. Do not repeat writes or other side effects that already completed. Do not mention this notice.`})}}catch(t){return{outcome:`failed`,error:t,retryCallOptions:e.retryCallOptions}}}async function handleStepResult(e){let{config:t,emit:n,promptMessages:r,result:i,runStep:a}=e,{emissionState:o,session:s}=e,c=resolveAssistantStepText(i.response.messages,i.text),l=getInvalidToolCallInputErrors({toolCalls:i.toolCalls}),u=new Set([...i.invalidInputToolCallIds??[],...i.toolCalls.filter(isInvalidToolCall).map(e=>e.toolCallId),...l.map(e=>e.toolCallId)]),d=appendMissingToolResultMessages({append:l.map(e=>createToolResultMessagePartFromToolError(e)),responseMessages:i.response.messages}),f=new Set;for(let e of[...i.content??[],...i.toolResults??[]])(e.type===`tool-result`||e.type===`tool-error`)&&e.providerExecuted===!0&&f.add(e.toolCallId);let p=normalizeProviderToolHistory({messages:d,providerExecutedOutcomeIds:f}),m=p.messages,h=setRequestEnvelopeTokens({...s,compaction:createNextCompactionConfig(s.compaction,e.durableModelPromptMessageCount,i)},i.usage?.inputTokens!==void 0&&e.durableModelPromptMessageCount!==void 0?e.requestEnvelopeTokens:void 0),g=extractToolApprovalInputRequests({content:i.content??[],excludedCallIds:u}),_=g,v=renderPendingApprovalsSnippet(g),y=m.findIndex(e=>e.role!==`tool`),b=y===-1?m:m.slice(0,y),x=m.slice(b.length),S=validateHarnessModelMessages([...r,...b,...v===void 0?[]:[createFrameworkUserMessage(`context.state`,v)]]),C=getAdvertisedTools({session:h,tools:e.coordinationTools}),w=new Set([...g.map(e=>e.action.callId),...extractToolResultCallIds(m)]),T=(i.toolCalls??[]).filter(e=>!u.has(e.toolCallId)).filter(e=>!w.has(e.toolCallId)).filter(t=>isDeferredHarnessTool(e.coordinationTools.get(t.toolName))).filter(e=>isDeferredHarnessTool(C.get(e.toolName))?!0:(log.warn(`deferred tool call blocked because tool is not advertised`,{callId:e.toolCallId,sessionId:h.sessionId,toolName:e.toolName}),!1)),E=collectDeferredCalls({session:h,toolCalls:T,tools:C,turnId:o.turnId}),D=E.workflowRequests;if(T.length>0){if(_.length===0)return{next:null,session:setHarnessEmissionState(setPendingCoordinationBatch({tasks:D,event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},responseMessages:m,session:{...E.session,history:validateHarnessModelMessages(r)}}),advanceStep(o))};let e=setPendingCoordinationBatch({tasks:D,event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},responseMessages:x,session:{...E.session,history:S}});return e=appendPendingInputBatch({event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},requests:_,responseAuthRequiredRequestIds:responsePolicyRequestIds(t,g),responseMessages:[],session:e}),n&&await n(createInputRequestedEvent({requests:_,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),{next:null,session:setHarnessEmissionState(e,advanceStep(o))}}if(_.length>0){let e=appendPendingInputBatch({event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},requests:_,responseAuthRequiredRequestIds:responsePolicyRequestIds(t,g),responseMessages:x,session:{...h,history:S}}),r=hasRunnableDeferredStepInput(e);return n&&(await n(createInputRequestedEvent({requests:_,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),r||(o=await holdTurnForRequest(n,o,e),e=setHarnessEmissionState(e,o))),r?{next:a,session:e}:{held:{kind:`request`},next:null,session:e}}let O=resolveInlineAuthorizationInterrupt({messages:[...r,...m],toolResults:i.toolResults});if(O){let{challenges:e,history:t}=O;if(n){for(let t of getSupersededAuthorizationChallenges(h.state,e))await n(createAuthorizationCompletedEvent({...authorizationEventFields(t),outcome:`failed`,reason:`Superseded by a newer authorization attempt.`,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));for(let t of e)await n(createAuthorizationRequiredEvent({...authorizationEventFields(t),description:t.challenge.instructions??`Authorization required for ${t.name}`,webhookUrl:t.hookUrl,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));o=await holdTurnForRequest(n,o,h)}return{held:{kind:`request`},next:null,session:setHarnessEmissionState({...h,history:validateHarnessModelMessages(t),state:setPendingAuthorization(h.state,{challenges:e})},o)}}let k=m,ee=validateHarnessModelMessages([...r,...k]),A={...h,history:ee},j=A.outputSchema!==void 0&&extractFinalOutput(i)!==void 0,M=workingTaskIds(A),N=j&&M.length>0,P=k;N&&(P=rejectFinalOutput(k,i,M),A={...A,history:validateHarnessModelMessages([...r,...P])});let F=await stepEndsTurn(i,k,e.endsTurnTools),I=(!j||N)&&(P.at(-1)?.role===`tool`&&!F||p.outcomeEndsResponse||hasRunnableDeferredStepInput(A)),L=!I&&M.length>0;return I||L?(n&&(o=advanceStep(o),A=setHarnessEmissionState(A,o)),L?(n&&await n(createTurnWaitingEvent({on:`tasks`,sequence:o.sequence,turnId:o.turnId,usage:getSessionUsage(A)})),{held:{kind:`tasks`,taskIds:M},next:null,session:A}):{next:a,session:A}):finishTurn({emissionState:o,emit:n,history:r,result:i,schema:A.outputSchema,session:A,stepOutput:F?null:c})}async function holdTurnForRequest(e,t,n){let r=advanceStep(t);return await e(createTurnWaitingEvent({on:`input`,sequence:r.sequence,turnId:r.turnId,usage:getSessionUsage(n)})),r}const STEERED_SIGN_IN_REASON=`Cancelled because a new message arrived.`,ENDS_TURN_TOOL_NOTE=`Calling this tool ends your turn once it succeeds: do not write a reply or call other tools in the same step. If it fails, you will see the error and can continue.`;async function stepEndsTurn(e,t,n){let r=e.toolCalls??[];if(r.length===0)return!1;let i=new Map;for(let e of t)if(e.role===`tool`)for(let t of e.content)t.type===`tool-result`&&i.set(t.toolCallId,t.output);if(!r.every(e=>{let t=i.get(e.toolCallId);return n.has(e.toolName)&&t!==void 0&&!isToolResultError(t)}))return!1;let a=new Map((e.toolResults??[]).map(e=>[e.toolCallId,e.output]));for(let e of r){let t=n.get(e.toolName);if(typeof t==`function`&&!await callEndsTurn(t,a.get(e.toolCallId),e))return!1}return!0}async function callEndsTurn(e,t,n){try{return await e(t)===!0}catch(e){return log.warn(`endsTurn threw; continuing the turn`,{callId:n.toolCallId,error:e,toolName:n.toolName}),!1}}function isDeferredHarnessTool(e){return e?.workflowId!==void 0||isTaskTool(e)}function rejectFinalOutput(e,t,n){let r=(t.toolCalls??[]).find(e=>e.toolName===FINAL_OUTPUT_TOOL_NAME);if(r===void 0)return[...e];let i={output:{type:`error-text`,value:renderFinalOutputWhileWorkingError(n)},toolCallId:r.toolCallId,toolName:FINAL_OUTPUT_TOOL_NAME,type:`tool-result`};return[...e,{content:[i],role:`tool`}]}const OUTPUT_SCHEMA_NOT_FULFILLED={code:`OUTPUT_SCHEMA_NOT_FULFILLED`,message:`The agent could not produce a result matching the requested schema.`};function extractFinalOutput(e){return(e.toolCalls??[]).find(e=>e.toolName===FINAL_OUTPUT_TOOL_NAME&&!isInvalidToolCall(e))?.input}function persistStructuredAssistantTurn(e,t,n){return{...e,history:[...t,{content:JSON.stringify(n),role:`assistant`}],outputSchema:void 0}}async function emitStructuredResult(e,t,n,r,i){return await e(createResultCompletedEvent({result:n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId})),emitTurnEpilogue(e,t,r,i)}async function finishTurn(e){let{emit:t,history:n,result:r,schema:i,stepOutput:a}=e,{emissionState:o,session:s}=e;if(s=clearTurnClientContextState(s),i===void 0)return t&&(o=await emitTurnEpilogue(t,o,s.history,getSessionUsage(s)),s=setHarnessEmissionState(s,o)),{next:null,session:s,settledTurn:{output:a??``}};let c=extractFinalOutput(r);if(c===void 0){s={...s,outputSchema:void 0},t&&(o=await emitRecoverableFailedTurn(t,o,{...OUTPUT_SCHEMA_NOT_FULFILLED,continuationToken:s.continuationToken,usage:getSessionUsage(s)}),s=setHarnessEmissionState(s,o));let e={isError:!0,output:OUTPUT_SCHEMA_NOT_FULFILLED.message};return{next:null,session:s,settledTurn:e}}return s=persistStructuredAssistantTurn(s,n,c),t&&(o=await emitStructuredResult(t,o,c,s.history,getSessionUsage(s)),s=setHarnessEmissionState(s,o)),{next:null,session:s,settledTurn:{output:c}}}function createNextCompactionConfig(e,t,n){let r={recentWindowSize:e.recentWindowSize,threshold:e.threshold,thresholdPercent:e.thresholdPercent};return n.usage?.inputTokens!==void 0&&t!==void 0&&(r.lastKnownInputTokens=n.usage.inputTokens,r.lastKnownPromptMessageCount=t),r}function replaceSessionHistory(e,t){return contextStorage.getStore()?.delete(HistoryStateKey),{...e,history:t,compaction:{recentWindowSize:e.compaction.recentWindowSize,threshold:e.compaction.threshold,thresholdPercent:e.compaction.thresholdPercent}}}async function maybeCompact(e){let{emit:t,emissionState:n}=e,r=e.messages,i=e.session,a=e.promptMessages??r,o=validateHarnessModelMessages(e.historyProjector?.({messages:a,state:i.state})??a),s=e.force===!0||shouldCompact(o,i.compaction,e.requestEnvelopeTokens,getRequestEnvelopeTokens(i)),c=shouldCanonicalizeMemory(r);if(!s&&!c)return{compacted:!1,messages:r,session:i};let l=await resolveCompactionModel({compactionModelReference:i.agent.compactionModelReference,model:e.model,modelReference:requireSessionModelReference(i),resolveModel:e.resolveModel}),u=i.agent.compactionModelReference??requireSessionModelReference(i),d=resolveCallProviderOptions({auth:e.auth,conversationId:resolveConversationId(i.rootSessionId??i.sessionId),model:l.model,modelReference:u,providerOptions:l.providerOptions});if(t){let a=contextStorage.getStore();a!==void 0&&prepareMemoryCompaction(a,{history:r,state:i.state}),await t(createCompactionRequestedEvent({modelId:formatLanguageModelGatewayId(l.model),sequence:n.sequence,sessionId:i.sessionId,stepIndex:n.stepIndex,turnId:n.turnId,usageInputTokens:getInputTokenCount(o,i.compaction,e.requestEnvelopeTokens,getRequestEnvelopeTokens(i))}),o)}let f=canonicalizeMemoryRecords(r),p=validateHarnessModelMessages(e.historyProjector?.({messages:f.ordinary,state:i.state})??f.ordinary),m=e.requestEnvelopeTokens??0,h={...i.compaction,threshold:Math.max(1,i.compaction.threshold-m),lastKnownInputTokens:i.compaction.lastKnownInputTokens===void 0?void 0:Math.max(0,i.compaction.lastKnownInputTokens-Math.min(getRequestEnvelopeTokens(i)??0,m))},g=s?await compactMessages([...p],l.model,h,d,e.telemetry,buildGatewayAttributionHeaders(l.model,e.runtimeIdentity),e.abortSignal,e.force===!0,e.requestEnvelopeTokens===void 0?void 0:Math.max(0,getInputTokenCount(o,i.compaction,m,getRequestEnvelopeTokens(i))-m)):[...p];if(r=validateHarnessModelMessages([...f.memory,...g]),t){let a=contextStorage.getStore();if(a!==void 0&&prepareMemoryCompaction(a,{history:r,state:i.state}),await t(createCompactionCompletedEvent({modelId:formatLanguageModelGatewayId(l.model),sequence:n.sequence,sessionId:i.sessionId,stepIndex:n.stepIndex,turnId:n.turnId}),e.historyProjector?.({messages:r,state:i.state})??r),a!==void 0){let e=drainMemoryCommit(a);e!==void 0&&(r=validateHarnessModelMessages([...r,...e.recalledMessages]),i={...i,state:e.state})}}return{compacted:!0,messages:r,session:replaceSessionHistory(i,r)}}function responsePolicyRequestIds(e,t){let n=buildResponseAuthorizationTools({authoredTools:e.tools,context:contextStorage.getStore()});return t.filter(e=>{let t=n.get(e.action.toolName)?.approval;return t!==void 0&&typeof t!=`function`&&t.response!==void 0}).map(e=>e.requestId)}function resolveApprovalKeyFromTools(e){return t=>{let n=e.get(t.action.toolName);if(n?.approvalKey!==void 0)return n.approvalKey(t.action.input)}}async function runModelCallWithRetries(e,t,n){for(let r=1;;r++){n.throwIfAborted();try{return await e(r)}catch(e){if(n.throwIfAborted(),t.canRetry?.()===!1||r===3||classifyModelCallError(e)!==`retry`)throw e;let i=500*2**(r-1)+Math.floor(Math.random()*250);log.warn(`model call failed transiently — retrying`,{attempt:r,delayMs:i,sessionId:t.sessionId,turnId:t.turnId,error:e}),await setTimeout(i,void 0,{signal:n})}}}export{appendMissingToolResultMessages,createToolLoopHarness};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{z}from"#compiled/zod/index.js";import{parseJsonValue}from"#shared/json.js";import{formatValidationError}from"#runtime/validation.js";import{withToolOutputSerializationError}from"#harness/tool-output-serialization.js";const log=createLogger(`harness.tool-model-output`),CONTENT_FILE_WARN_BYTES=3145728,UNSUPPORTED_FILE_DATA_TAGS=new Set([`url`,`reference`,`text`]),toolModelOutputPartSchema=z.discriminatedUnion(`type`,[z.object({type:z.literal(`text`),text:z.string()}),z.object({type:z.literal(`file`),data:z.object({type:z.literal(`data`),data:z.string()}),mediaType:z.string().min(1),filename:z.string().optional()})]),toolModelOutputSchema=z.discriminatedUnion(`type`,[z.object({type:z.literal(`text`),value:z.string()}),z.object({type:z.literal(`json`),value:z.unknown()}),z.object({type:z.literal(`content`),value:z.array(toolModelOutputPartSchema).min(1)})]);function normalizeToolJsonOutput(e){let t=e.output===void 0?null:e.output;return withToolOutputSerializationError(e,()=>(parseJsonValue(t),t))}function normalizeToolModelOutput(e){return withToolOutputSerializationError({boundary:`toModelOutput`,toolCallId:e.toolCallId,toolName:e.toolName},()=>{assertSupportedFilePartData(e.output);let t=toolModelOutputSchema.safeParse(e.output);if(!t.success)throw TypeError(formatValidationError(t.error));let n=t.data;if(n.type===`json`)return{type:`json`,value:normalizeToolJsonOutput({boundary:`toModelOutput`,output:n.value,toolCallId:e.toolCallId,toolName:e.toolName})};if(n.type===`content`)for(let t of n.value)t.type===`file`&&warnOversizedFilePayload(t,e.toolName);return n})}function assertSupportedFilePartData(e){if(typeof e!=`object`||!e)return;let t=e;if(t.type===`content`&&Array.isArray(t.value))for(let e of t.value){if(typeof e!=`object`||!e)continue;let t=e;if(t.type!==`file`)continue;let n=t.data,r=typeof n==`object`&&n?n.data:void 0;if(isBinaryPayload(n)||isBinaryPayload(r))throw TypeError(`Expected file content part data to be a base64 string, received raw bytes. Base64-encode binary payloads before returning them from toModelOutput.`);let i=typeof n==`object`&&n?n.type:void 0;if(typeof i==`string`&&UNSUPPORTED_FILE_DATA_TAGS.has(i))throw TypeError(`File content part data tag "${i}" is not supported yet; only { type: "data" } with a base64 string is accepted.`)}}function warnOversizedFilePayload(e,t){let n=Math.floor(e.data.data.length*3/4);n<=CONTENT_FILE_WARN_BYTES||log.warn(`content-part file payload exceeds the inline size guideline — it is persisted in history and re-sent on every subsequent model call`,{estimatedBytes:n,mediaType:e.mediaType,toolName:t,warnBytes:CONTENT_FILE_WARN_BYTES})}function isBinaryPayload(e){return e instanceof Uint8Array||e instanceof ArrayBuffer}export{normalizeToolJsonOutput,normalizeToolModelOutput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{normalizePresentationText}from"#shared/presentation-text.js";import{parseJsonObject}from"#shared/json.js";function projectResultPresentation(e,t,n,r){return projectPresentationText(e?.label?.complete,t,n,r)}function projectDeltaPresentation(e,t,n,r){return projectPresentationText(e?.label?.delta,t,n,r)}function projectPresentationText(e,t,n,r){if(e!==void 0&&n!==void 0)try{let i=normalizePresentationText(e(parseJsonObject(n),r));return i===``?void 0:{[t]:{label:i}}}catch{return}}export{projectDeltaPresentation,projectResultPresentation};
|
|
@@ -3,7 +3,6 @@ import type { RuntimeModelReference } from "#runtime/agent/bootstrap.js";
|
|
|
3
3
|
import type { HarnessToolDefinition } from "#harness/execute-tool.js";
|
|
4
4
|
import type { HarnessToolMap } from "#harness/types.js";
|
|
5
5
|
import type { ToolExecuteOptions } from "#tools/definition.js";
|
|
6
|
-
import { type BackgroundToolCallBatch } from "#harness/background-tools.js";
|
|
7
6
|
/**
|
|
8
7
|
* Builds an AI SDK `ToolSet` from unified harness tool definitions.
|
|
9
8
|
*
|
|
@@ -17,7 +16,6 @@ import { type BackgroundToolCallBatch } from "#harness/background-tools.js";
|
|
|
17
16
|
*/
|
|
18
17
|
export declare function buildToolSet(input: {
|
|
19
18
|
readonly approvedTools?: ReadonlySet<string>;
|
|
20
|
-
readonly backgroundBatch?: BackgroundToolCallBatch;
|
|
21
19
|
readonly disabledProviderTools?: ReadonlySet<string>;
|
|
22
20
|
readonly tools: HarnessToolMap;
|
|
23
21
|
}): ToolSet;
|
|
@@ -29,7 +27,6 @@ export declare function buildToolSet(input: {
|
|
|
29
27
|
*/
|
|
30
28
|
export declare function buildToolSetFromDefinitions(input: {
|
|
31
29
|
readonly approvedTools?: ReadonlySet<string>;
|
|
32
|
-
readonly backgroundBatch?: BackgroundToolCallBatch;
|
|
33
30
|
readonly disabledProviderTools?: ReadonlySet<string>;
|
|
34
31
|
readonly tools: readonly HarnessToolDefinition[];
|
|
35
32
|
}): ToolSet;
|
|
@@ -40,7 +37,7 @@ export declare function buildToolSetFromDefinitions(input: {
|
|
|
40
37
|
* omits OAuth URLs, user codes, and hook URLs from model-facing history.
|
|
41
38
|
* Returns `undefined` for client-side tools (no `execute`).
|
|
42
39
|
*/
|
|
43
|
-
export declare function wrapToolExecute(definition: HarnessToolDefinition
|
|
40
|
+
export declare function wrapToolExecute(definition: HarnessToolDefinition): ((input: any, options: ToolExecuteOptions) => Promise<any> | AsyncIterable<any>) | undefined;
|
|
44
41
|
/**
|
|
45
42
|
* Builds the AI SDK ToolSet for one harness step.
|
|
46
43
|
*
|
|
@@ -62,7 +59,6 @@ export declare function wrapToolExecute(definition: HarnessToolDefinition, backg
|
|
|
62
59
|
*/
|
|
63
60
|
export declare function buildToolSetWithProviderTools(input: {
|
|
64
61
|
readonly approvedTools?: ReadonlySet<string>;
|
|
65
|
-
readonly backgroundBatch?: BackgroundToolCallBatch;
|
|
66
62
|
readonly disabledProviderTools?: ReadonlySet<string>;
|
|
67
63
|
readonly modelReference: RuntimeModelReference;
|
|
68
64
|
readonly tools: HarnessToolMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{tool}from"ai";import{isObject}from"#shared/guards.js";import{loadContext}from"#context/container.js";import{toModelSchema}from"#tools/schema.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{resolveApprovalPolicy}from"#approval/definition.js";import{authorizationPendingModelText,isAuthorizationPendingModelOutput,isAuthorizationSignal,modelFacingAuthorizationOutput}from"#harness/authorization.js";import{
|
|
1
|
+
import{tool}from"ai";import{isObject}from"#shared/guards.js";import{loadContext}from"#context/container.js";import{toModelSchema}from"#tools/schema.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{resolveApprovalPolicy}from"#approval/definition.js";import{authorizationPendingModelText,isAuthorizationPendingModelOutput,isAuthorizationSignal,modelFacingAuthorizationOutput}from"#harness/authorization.js";import{isApprovedToolCall,markApprovalRecheck}from"#harness/approval-recheck.js";import{normalizeToolJsonOutput,normalizeToolModelOutput}from"#harness/tool-model-output.js";import{stashToolInterrupt}from"#harness/tool-interrupts.js";import{resolveWebSearchBackend,resolveWebSearchProviderTool}from"#harness/provider-tools.js";import{isAsyncIterable}from"#shared/async-iterable.js";const toolApprovals=new WeakMap;function buildToolSet(e){let t={},n=e.disabledProviderTools;for(let r of e.tools.values()){if(n?.has(r.name))continue;let i=r.toModelOutput,a=buildApprovalFn(r,e),o=tool({description:r.description,execute:wrapToolExecute(r),inputSchema:toModelSchema(r.inputSchema,`input`),strict:!1,outputSchema:toModelSchema(r.outputSchema,`output`),...r.execute===void 0?i===void 0?{}:{toModelOutput:async({output:e,toolCallId:t})=>normalizeToolModelOutput({output:await i(e),toolCallId:t,toolName:r.name})}:{toModelOutput:async({output:e,toolCallId:t})=>isAuthorizationPendingModelOutput(e)?{type:`text`,value:authorizationPendingModelText(e.connections)}:i===void 0?typeof e==`string`?{type:`text`,value:e}:normalizeToolModelOutput({output:{type:`json`,value:e??null},toolCallId:t,toolName:r.name}):normalizeToolModelOutput({output:await i(e),toolCallId:t,toolName:r.name})}});t[r.name]=o,r.approval!==void 0&&toolApprovals.set(o,a)}return t}function buildToolSetFromDefinitions(e){let t=new Map;for(let n of e.tools)t.has(n.name)||t.set(n.name,n);return buildToolSet({approvedTools:e.approvedTools,disabledProviderTools:e.disabledProviderTools,tools:t})}function wrapToolExecute(e){let t=e.execute;if(t!==void 0)return(n,r)=>{let i;try{i=t(n,r)}catch(e){return Promise.reject(e)}return isAsyncIterable(i)?normalizeToolExecuteIterable(i,e.name,r):Promise.resolve(i).then(t=>normalizeToolExecuteOutput(t,e.name,r))}}async function*normalizeToolExecuteIterable(e,t,n){for await(let r of e)yield normalizeToolExecuteOutput(r,t,n)}function normalizeToolExecuteOutput(e,t,n){return isAuthorizationSignal(e)?(stashToolInterrupt(loadContext(),n.toolCallId,e),modelFacingAuthorizationOutput(e)):normalizeToolJsonOutput({boundary:`execute`,output:e,toolCallId:n.toolCallId,toolName:t})}async function buildToolSetWithProviderTools(e){let t=e.disabledProviderTools,n={...buildToolSet({approvedTools:e.approvedTools,disabledProviderTools:t,tools:e.tools})};for(let r of e.tools.values()){let i=r.behavior?.handling;if(i?.kind===`provider-tool`&&r.execute===void 0&&!t?.has(r.name)){let t=resolveWebSearchBackend(e.modelReference,i.provider);t===null?delete n[r.name]:n[r.name]=await resolveWebSearchProviderTool(t)}}return n}function buildApprovalFn(e,t){return async(n,r,i,a)=>{if(e.approval===void 0)return;let o=isObject(n)?n:void 0,s={...buildCallbackContext(),abortSignal:i??new AbortController().signal,approvedTools:t.approvedTools??new Set,callId:r,toolInput:o,toolName:e.name},c=await resolveApprovalPolicy(e.approval)(a?markApprovalRecheck(s):s);return typeof c==`boolean`?c?`user-approval`:`not-applicable`:c}}function buildToolApproval(e,t){return async({toolCall:n,messages:r})=>{let i=e[n.toolName];return i===void 0?void 0:await toolApprovals.get(i)?.(n.input,n.toolCallId,t,isApprovedToolCall(r,n.toolCallId))}}export{buildToolApproval,buildToolSet,buildToolSetFromDefinitions,buildToolSetWithProviderTools,wrapToolExecute};
|
|
@@ -47,6 +47,8 @@ export interface TurnUsageState extends TokenUsageTotals {
|
|
|
47
47
|
/** Reads the stored per-turn token state, or `undefined` when absent. */
|
|
48
48
|
export declare function getTurnUsageState(state: SessionStateMap | undefined): TurnUsageState | undefined;
|
|
49
49
|
export declare function getSessionTokenUsage(session: Pick<HarnessSession, "state">): TokenUsageTotals;
|
|
50
|
+
/** The session's usage so far, delegated spend included. */
|
|
51
|
+
export declare function getSessionUsage(session: Pick<HarnessSession, "state">): TokenUsage;
|
|
50
52
|
/** Projects a {@link TokenUsageTotals} down to the cross-cutting {@link TokenUsage} shape. */
|
|
51
53
|
export declare function toUsage(totals: TokenUsageTotals): TokenUsage;
|
|
52
54
|
/**
|
|
@@ -107,11 +109,12 @@ export declare function accumulateTurnUsage(input: {
|
|
|
107
109
|
readonly usage: TokenUsageDelta | undefined;
|
|
108
110
|
}): TurnUsageState;
|
|
109
111
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* attribute only the parent's own model
|
|
113
|
-
* the caller's durable `agent.action`
|
|
114
|
-
* token limits and the remaining-quota
|
|
112
|
+
* Adds usage to session totals without touching the in-flight turn totals:
|
|
113
|
+
* the delegated spend a parent counts, or a run's tally of what its
|
|
114
|
+
* `ctx.agent` sessions spent. Turn tags attribute only the parent's own model
|
|
115
|
+
* calls (child spend is attributed by the caller's durable `agent.action`
|
|
116
|
+
* span); session totals feed the session token limits and the remaining-quota
|
|
117
|
+
* budget granted to later delegations.
|
|
115
118
|
*/
|
|
116
119
|
export declare function accumulateSessionUsage(input: {
|
|
117
120
|
readonly previous: TurnUsageState | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findRuntimeUsageLimitViolation,grantRuntimeUsageLimits,remainingRuntimeUsageQuota,resolveRuntimeUsageLimits}from"#harness/session-usage-limits.js";const HARNESS_TURN_USAGE_STATE_KEY=`eve.harness.turnUsage`,REPORTED_SESSION_USAGE_STATE_KEY=`eve.harness.reportedSessionUsage`,SESSION_RUNTIME_USAGE_LIMIT_KEY=`eve.harness.sessionRuntimeTokenLimit`,ZERO_TOKEN_USAGE={cacheReadTokens:0,cacheWriteTokens:0,costUsd:0,inputTokens:0,outputTokens:0,sawCost:!1};function getTurnUsageState(e){return e?.[HARNESS_TURN_USAGE_STATE_KEY]}function getSessionTokenUsage(e){return getTurnUsageState(e.state)?.session??ZERO_TOKEN_USAGE}function toUsage(e){return{cacheReadTokens:e.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens,costUsd:e.sawCost?e.costUsd:void 0,inputTokens:e.inputTokens,outputTokens:e.outputTokens}}function getSessionRuntimeUsageLimits(e){let t=e.state?.[SESSION_RUNTIME_USAGE_LIMIT_KEY];return resolveRuntimeUsageLimits({configured:configuredSessionUsageLimits(e),stored:t})}function bumpSessionRuntimeUsageLimits(e){let t=getSessionTokenUsage(e),n=grantRuntimeUsageLimits({configured:configuredSessionUsageLimits(e),usage:t});return{...e,state:{...e.state,[SESSION_RUNTIME_USAGE_LIMIT_KEY]:n}}}function getSessionRemainingUsageQuota(e){let t=getSessionTokenUsage(e),n=getSessionRuntimeUsageLimits(e);return remainingRuntimeUsageQuota({runtime:n,usage:t})}function getSessionUsageLimitViolation(e){let t=getSessionTokenUsage(e),n=getSessionRuntimeUsageLimits(e);return findRuntimeUsageLimitViolation({configured:configuredSessionUsageLimits(e),runtime:n,usage:t})}function configuredSessionUsageLimits(e){return{costUsd:e.limits?.maxTokenCostUsdPerSession,inputTokens:e.limits?.maxInputTokensPerSession,outputTokens:e.limits?.maxOutputTokensPerSession}}function takeSessionUsageDelta(e){let t=getSessionTokenUsage(e),n=e.state?.[REPORTED_SESSION_USAGE_STATE_KEY]??ZERO_TOKEN_USAGE;return{delta:{cacheReadTokens:t.cacheReadTokens-n.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens-n.cacheWriteTokens,costUsd:t.sawCost||n.sawCost?t.costUsd-n.costUsd:void 0,inputTokens:t.inputTokens-n.inputTokens,outputTokens:t.outputTokens-n.outputTokens},session:{...e,state:{...e.state,[REPORTED_SESSION_USAGE_STATE_KEY]:t}}}}function setTurnUsageState(e,t){return{...e,state:{...e.state,[HARNESS_TURN_USAGE_STATE_KEY]:t}}}function accumulateTurnUsage(e){let t=toTokenUsageDelta(e.usage),n=e.previous?.session??ZERO_TOKEN_USAGE;return{...addTokenUsage(e.previous!==void 0&&e.previous.turnId===e.turnId?e.previous:ZERO_TOKEN_USAGE,t),turnId:e.turnId,session:addTokenUsage(n,t)}}function accumulateSessionUsage(e){let t=toTokenUsageDelta(e.usage),n=e.previous??{...ZERO_TOKEN_USAGE,session:ZERO_TOKEN_USAGE,turnId:``};return{...n,session:addTokenUsage(n.session,t)}}function addTokenUsage(e,t){return{cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens+t.cacheWriteTokens,costUsd:e.costUsd+t.costUsd,inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,sawCost:e.sawCost||t.sawCost}}function toTokenUsageDelta(e){if(e===void 0)return ZERO_TOKEN_USAGE;let t=e.inputTokens??0,n=e.outputTokens??0;return{cacheReadTokens:e.cacheReadTokens??0,cacheWriteTokens:e.cacheWriteTokens??0,costUsd:e.costUsd??0,inputTokens:t,outputTokens:n,sawCost:e.costUsd!==void 0}}export{accumulateSessionUsage,accumulateTurnUsage,bumpSessionRuntimeUsageLimits,getSessionRemainingUsageQuota,getSessionRuntimeUsageLimits,getSessionTokenUsage,getSessionUsageLimitViolation,getTurnUsageState,setTurnUsageState,takeSessionUsageDelta,toUsage};
|
|
1
|
+
import{findRuntimeUsageLimitViolation,grantRuntimeUsageLimits,remainingRuntimeUsageQuota,resolveRuntimeUsageLimits}from"#harness/session-usage-limits.js";const HARNESS_TURN_USAGE_STATE_KEY=`eve.harness.turnUsage`,REPORTED_SESSION_USAGE_STATE_KEY=`eve.harness.reportedSessionUsage`,SESSION_RUNTIME_USAGE_LIMIT_KEY=`eve.harness.sessionRuntimeTokenLimit`,ZERO_TOKEN_USAGE={cacheReadTokens:0,cacheWriteTokens:0,costUsd:0,inputTokens:0,outputTokens:0,sawCost:!1};function getTurnUsageState(e){return e?.[HARNESS_TURN_USAGE_STATE_KEY]}function getSessionTokenUsage(e){return getTurnUsageState(e.state)?.session??ZERO_TOKEN_USAGE}function getSessionUsage(e){return toUsage(getSessionTokenUsage(e))}function toUsage(e){return{cacheReadTokens:e.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens,costUsd:e.sawCost?e.costUsd:void 0,inputTokens:e.inputTokens,outputTokens:e.outputTokens}}function getSessionRuntimeUsageLimits(e){let t=e.state?.[SESSION_RUNTIME_USAGE_LIMIT_KEY];return resolveRuntimeUsageLimits({configured:configuredSessionUsageLimits(e),stored:t})}function bumpSessionRuntimeUsageLimits(e){let t=getSessionTokenUsage(e),n=grantRuntimeUsageLimits({configured:configuredSessionUsageLimits(e),usage:t});return{...e,state:{...e.state,[SESSION_RUNTIME_USAGE_LIMIT_KEY]:n}}}function getSessionRemainingUsageQuota(e){let t=getSessionTokenUsage(e),n=getSessionRuntimeUsageLimits(e);return remainingRuntimeUsageQuota({runtime:n,usage:t})}function getSessionUsageLimitViolation(e){let t=getSessionTokenUsage(e),n=getSessionRuntimeUsageLimits(e);return findRuntimeUsageLimitViolation({configured:configuredSessionUsageLimits(e),runtime:n,usage:t})}function configuredSessionUsageLimits(e){return{costUsd:e.limits?.maxTokenCostUsdPerSession,inputTokens:e.limits?.maxInputTokensPerSession,outputTokens:e.limits?.maxOutputTokensPerSession}}function takeSessionUsageDelta(e){let t=getSessionTokenUsage(e),n=e.state?.[REPORTED_SESSION_USAGE_STATE_KEY]??ZERO_TOKEN_USAGE;return{delta:{cacheReadTokens:t.cacheReadTokens-n.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens-n.cacheWriteTokens,costUsd:t.sawCost||n.sawCost?t.costUsd-n.costUsd:void 0,inputTokens:t.inputTokens-n.inputTokens,outputTokens:t.outputTokens-n.outputTokens},session:{...e,state:{...e.state,[REPORTED_SESSION_USAGE_STATE_KEY]:t}}}}function setTurnUsageState(e,t){return{...e,state:{...e.state,[HARNESS_TURN_USAGE_STATE_KEY]:t}}}function accumulateTurnUsage(e){let t=toTokenUsageDelta(e.usage),n=e.previous?.session??ZERO_TOKEN_USAGE;return{...addTokenUsage(e.previous!==void 0&&e.previous.turnId===e.turnId?e.previous:ZERO_TOKEN_USAGE,t),turnId:e.turnId,session:addTokenUsage(n,t)}}function accumulateSessionUsage(e){let t=toTokenUsageDelta(e.usage),n=e.previous??{...ZERO_TOKEN_USAGE,session:ZERO_TOKEN_USAGE,turnId:``};return{...n,session:addTokenUsage(n.session,t)}}function addTokenUsage(e,t){return{cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens+t.cacheWriteTokens,costUsd:e.costUsd+t.costUsd,inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,sawCost:e.sawCost||t.sawCost}}function toTokenUsageDelta(e){if(e===void 0)return ZERO_TOKEN_USAGE;let t=e.inputTokens??0,n=e.outputTokens??0;return{cacheReadTokens:e.cacheReadTokens??0,cacheWriteTokens:e.cacheWriteTokens??0,costUsd:e.costUsd??0,inputTokens:t,outputTokens:n,sawCost:e.costUsd!==void 0}}export{accumulateSessionUsage,accumulateTurnUsage,bumpSessionRuntimeUsageLimits,getSessionRemainingUsageQuota,getSessionRuntimeUsageLimits,getSessionTokenUsage,getSessionUsage,getSessionUsageLimitViolation,getTurnUsageState,setTurnUsageState,takeSessionUsageDelta,toUsage};
|
|
@@ -55,16 +55,14 @@ export type SessionAgent = SessionAgentBase & ({
|
|
|
55
55
|
readonly modelReference?: RuntimeModelReference;
|
|
56
56
|
});
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* functions. The harness resolves those at step time via injected config.
|
|
58
|
+
* A {@link HarnessSession} without its conversation history. Session steps
|
|
59
|
+
* that only publish events or change `state` rebuild this, so the history
|
|
60
|
+
* never becomes part of their Workflow step input.
|
|
62
61
|
*/
|
|
63
|
-
export interface
|
|
62
|
+
export interface HarnessSessionBase {
|
|
64
63
|
readonly agent: SessionAgent;
|
|
65
64
|
readonly compaction: CompactionConfig;
|
|
66
65
|
readonly continuationToken: string;
|
|
67
|
-
readonly history: HarnessModelMessage[];
|
|
68
66
|
readonly limits?: SessionLimits;
|
|
69
67
|
readonly outputSchema?: JsonObject;
|
|
70
68
|
/**
|
|
@@ -79,8 +77,15 @@ export interface HarnessSession {
|
|
|
79
77
|
readonly sessionId: string;
|
|
80
78
|
readonly sandboxState?: SandboxState;
|
|
81
79
|
readonly state?: SessionStateMap;
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Serializable session state passed between harness and runtime.
|
|
83
|
+
*
|
|
84
|
+
* Only contains plain data -- no resolved model instances or tool execute
|
|
85
|
+
* functions. The harness resolves those at step time via injected config.
|
|
86
|
+
*/
|
|
87
|
+
export interface HarnessSession extends HarnessSessionBase {
|
|
88
|
+
readonly history: HarnessModelMessage[];
|
|
84
89
|
}
|
|
85
90
|
export declare function requireSessionModelReference(session: HarnessSession): RuntimeModelReference;
|
|
86
91
|
/**
|
|
@@ -183,15 +188,6 @@ export interface SettledTurn {
|
|
|
183
188
|
*/
|
|
184
189
|
export interface StepResult {
|
|
185
190
|
readonly steered?: true;
|
|
186
|
-
/** Background-tool effects projected onto the session that entered this step. */
|
|
187
|
-
readonly backgroundTaskSession?: HarnessSession;
|
|
188
|
-
/** Durable tasks started by background tools and awaiting the parent commit barrier. */
|
|
189
|
-
readonly backgroundTasks?: readonly {
|
|
190
|
-
readonly callId?: string;
|
|
191
|
-
readonly taskInboxToken: string;
|
|
192
|
-
readonly taskId: string;
|
|
193
|
-
readonly taskRunId: string;
|
|
194
|
-
}[];
|
|
195
191
|
readonly next: StepNext;
|
|
196
192
|
readonly session: HarnessSession;
|
|
197
193
|
/**
|
|
@@ -199,7 +195,19 @@ export interface StepResult {
|
|
|
199
195
|
* across the park boundary so a delegated parent can be notified.
|
|
200
196
|
*/
|
|
201
197
|
readonly settledTurn?: SettledTurn;
|
|
198
|
+
/**
|
|
199
|
+
* Present when the turn stays open: the model ended it while tasks work, or
|
|
200
|
+
* it waits on a sign-in or tool approval it raised. It resumes when a task
|
|
201
|
+
* settles, or when the person answers, steers, or cancels.
|
|
202
|
+
*/
|
|
203
|
+
readonly held?: TurnHold;
|
|
202
204
|
}
|
|
205
|
+
export type TurnHold = {
|
|
206
|
+
readonly kind: "tasks";
|
|
207
|
+
readonly taskIds: readonly string[];
|
|
208
|
+
} | {
|
|
209
|
+
readonly kind: "request";
|
|
210
|
+
};
|
|
203
211
|
/**
|
|
204
212
|
* A single step of AI work. Takes the current session and optional user input,
|
|
205
213
|
* returns the updated session and an instruction for the runtime.
|
|
@@ -256,15 +264,11 @@ export interface ToolLoopHarnessConfig {
|
|
|
256
264
|
* Omitted in production until an instrumentation runtime opts in.
|
|
257
265
|
*/
|
|
258
266
|
readonly instrumentation?: SessionInstrumentation;
|
|
259
|
-
/** Whether this node enables framework background-task behavior. */
|
|
260
|
-
readonly tasksEnabled?: boolean;
|
|
261
267
|
/** Restores runtime resources for the originating turn before approval work. */
|
|
262
268
|
readonly prepareApprovalTurn?: (event: {
|
|
263
269
|
readonly sequence: number;
|
|
264
270
|
readonly turnId: string;
|
|
265
271
|
}) => Promise<void>;
|
|
266
|
-
/** Opaque runtime identity retained by a pending approval batch. */
|
|
267
|
-
readonly toolReplayIdentity?: (toolName: string) => string | undefined;
|
|
268
272
|
/** Resolves persisted step-scoped tools before an approval policy reads them. */
|
|
269
273
|
readonly resolveStepDynamicTools?: (input: {
|
|
270
274
|
readonly ctx: AlsContext;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
2
|
+
import { type CoordinationToolCall } from "#harness/coordination.js";
|
|
3
|
+
import type { ResolvedInputBatch } from "#harness/input-request-resolution.js";
|
|
4
|
+
import type { HarnessSession, HarnessToolMap } from "#harness/types.js";
|
|
5
|
+
import type { RuntimeWorkflowTaskRequest } from "#shared/action-types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Parks the step on the workflow tools a person just approved. The approval
|
|
8
|
+
* tool message moves into the batch's response so workflow results join it:
|
|
9
|
+
* AI SDK then resumes approved sibling tools without replaying the workflows.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dispatchApprovedWorkflowCalls(input: {
|
|
12
|
+
readonly messages: readonly ModelMessage[];
|
|
13
|
+
readonly resolvedInputs: readonly ResolvedInputBatch[] | undefined;
|
|
14
|
+
readonly session: HarnessSession;
|
|
15
|
+
readonly tools: HarnessToolMap;
|
|
16
|
+
}): HarnessSession | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Turns a step's deferred calls into workflow runs, committing a task record
|
|
19
|
+
* for each call that starts a task. Task tool calls stay in the response
|
|
20
|
+
* alone: the session reads them from there.
|
|
21
|
+
*/
|
|
22
|
+
export declare function collectDeferredCalls(input: {
|
|
23
|
+
readonly session: HarnessSession;
|
|
24
|
+
readonly toolCalls: readonly CoordinationToolCall[];
|
|
25
|
+
readonly tools: HarnessToolMap;
|
|
26
|
+
readonly turnId: string;
|
|
27
|
+
}): {
|
|
28
|
+
readonly session: HarnessSession;
|
|
29
|
+
readonly workflowRequests: readonly RuntimeWorkflowTaskRequest[];
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{validateHarnessModelMessages}from"#harness/messages.js";import{createCoordinationRequestFromToolCall,resolveToolCallInputObject,setPendingCoordinationBatch}from"#harness/coordination.js";import{hasTailApprovalResponse}from"#harness/current-messages.js";import{commitCallEntry,isTaskTool}from"#execution/tasks/model-step.js";function dispatchApprovedWorkflowCalls(e){for(let t of e.resolvedInputs??[]){let n=t.inputs.filter(({outcome:t,request:n})=>t===`approved`&&e.tools.get(n.action.toolName)?.workflowId!==void 0);if(n.length===0)continue;if(!hasTailApprovalResponse(e.messages))throw Error(`Approved workflow calls must follow their approval tool message.`);let r=collectDeferredCalls({session:e.session,toolCalls:n.map(({request:e})=>({input:e.action.input,toolCallId:e.action.callId,toolName:e.action.toolName})),tools:e.tools,turnId:t.event.turnId});return setPendingCoordinationBatch({tasks:r.workflowRequests,event:t.event,responseMessages:e.messages.slice(-1),session:{...r.session,history:validateHarnessModelMessages(e.messages.slice(0,-1))}})}}function collectDeferredCalls(e){let{session:t}=e,n=[];for(let r of e.toolCalls){let i=e.tools.get(r.toolName);if(isTaskTool(i))continue;let a=commitCallEntry(t,{callId:r.toolCallId,definition:i,input:resolveToolCallInputObject(r.input,{callId:r.toolCallId,toolName:r.toolName}),toolName:r.toolName,turnId:e.turnId});t=a.session,n.push(createCoordinationRequestFromToolCall({entry:a.entry,input:a.input,toolCall:r,tools:e.tools}))}return{session:t,workflowRequests:n}}export{collectDeferredCalls,dispatchApprovedWorkflowCalls};
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import type { RuntimeToolResultActionResult } from "#shared/action-types.js";
|
|
2
2
|
import type { SessionStateMap } from "#harness/types.js";
|
|
3
|
-
import { type ActivityWorkIdentityV1 } from "#protocol/activity.js";
|
|
4
|
-
import { type TaskMetadata, type TaskStatus, type TaskView } from "#tasks/types.js";
|
|
5
|
-
import type { DurableDynamicSubagentSelection, SessionAuth } from "#context/keys.js";
|
|
6
3
|
export declare const WORKFLOW_TOOL_RUNS_STATE_KEY = "eve.workflowTool";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly metadata: TaskMetadata;
|
|
10
|
-
readonly dispatchContext: TaskAgentDispatchContext;
|
|
11
|
-
readonly activityWorkIdentity?: ActivityWorkIdentityV1;
|
|
12
|
-
readonly cohortId?: string;
|
|
13
|
-
/** Parent-owned outcome. Read through readWorkflowTaskView before consuming it. */
|
|
14
|
-
readonly outcome?: unknown;
|
|
15
|
-
}
|
|
16
|
-
interface WorkflowToolRunBase {
|
|
4
|
+
/** One workflow tool call the originating turn waits on. */
|
|
5
|
+
export interface BlockingWorkflowToolRun {
|
|
17
6
|
readonly callId: string;
|
|
18
7
|
readonly toolName: string;
|
|
19
8
|
readonly origin: {
|
|
@@ -25,60 +14,12 @@ interface WorkflowToolRunBase {
|
|
|
25
14
|
readonly hookToken: string;
|
|
26
15
|
};
|
|
27
16
|
}
|
|
28
|
-
export type BlockingWorkflowToolRun = WorkflowToolRunBase & {
|
|
29
|
-
readonly lifetime: "turn";
|
|
30
|
-
};
|
|
31
|
-
export type BackgroundWorkflowToolRun = WorkflowToolRunBase & {
|
|
32
|
-
readonly lifetime: "session";
|
|
33
|
-
readonly task: WorkflowTaskPayload;
|
|
34
|
-
};
|
|
35
|
-
export type WorkflowToolRun = BlockingWorkflowToolRun | BackgroundWorkflowToolRun;
|
|
36
|
-
export interface TaskAgentDispatchContext {
|
|
37
|
-
readonly auth: SessionAuth;
|
|
38
|
-
readonly sessionDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>;
|
|
39
|
-
readonly turnDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>;
|
|
40
|
-
}
|
|
41
|
-
/** Decode retained output only when it is consumed, independently of ownership reads. */
|
|
42
|
-
export declare function readWorkflowTaskView(task: WorkflowTaskPayload): TaskView | undefined;
|
|
43
|
-
export declare function getWorkflowToolRuns(state: SessionStateMap | undefined): readonly WorkflowToolRun[];
|
|
44
|
-
/** Parent-observed lifecycle state. Input requests are tracked on the parent session instead. */
|
|
45
|
-
export type BackgroundTaskState = Exclude<TaskStatus, "input_required">;
|
|
46
|
-
/** A background run with its decoded lifecycle view. */
|
|
47
|
-
export type BackgroundTask = TaskView & {
|
|
48
|
-
/** Overlapping work reported together; a task without a join target starts its own cohort. */
|
|
49
|
-
readonly cohortId: string;
|
|
50
|
-
/** The parent turn that started the task. */
|
|
51
|
-
readonly turnId: string;
|
|
52
|
-
readonly run: BackgroundWorkflowToolRun;
|
|
53
|
-
};
|
|
54
|
-
export interface BackgroundTaskFilter {
|
|
55
|
-
readonly state?: BackgroundTaskState | readonly BackgroundTaskState[];
|
|
56
|
-
readonly cohortId?: string;
|
|
57
|
-
readonly turnId?: string;
|
|
58
|
-
}
|
|
59
|
-
export interface BackgroundTasks {
|
|
60
|
-
get(taskId: string): BackgroundTask | undefined;
|
|
61
|
-
query(filter?: BackgroundTaskFilter): readonly BackgroundTask[];
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Read-only parent view: a task without a recorded terminal outcome is working.
|
|
65
|
-
* Only returned tasks are decoded, so one corrupt retained outcome cannot block
|
|
66
|
-
* reads of unrelated tasks, and working-only reads never decode.
|
|
67
|
-
*/
|
|
68
|
-
export declare function getBackgroundTasks(state: SessionStateMap | undefined): BackgroundTasks;
|
|
69
17
|
export declare function getBlockingWorkflowToolRuns(state: SessionStateMap | undefined, turnId?: string): readonly BlockingWorkflowToolRun[];
|
|
70
|
-
/** Registration is idempotent by originating turn and call
|
|
18
|
+
/** Registration is idempotent by originating turn and call. */
|
|
71
19
|
export declare function registerWorkflowToolRun<T extends {
|
|
72
20
|
readonly state?: SessionStateMap;
|
|
73
|
-
}>(session: T, entry:
|
|
74
|
-
/**
|
|
75
|
-
export declare function recordWorkflowTaskView(state: SessionStateMap | undefined, view: TaskView): {
|
|
76
|
-
readonly state: SessionStateMap | undefined;
|
|
77
|
-
readonly view: TaskView;
|
|
78
|
-
/** True only when this call recorded the task's first outcome. */
|
|
79
|
-
readonly firstOutcome: boolean;
|
|
80
|
-
};
|
|
81
|
-
/** Removes only this turn's waiting calls. Session-owned task payloads are never pruned here. */
|
|
21
|
+
}>(session: T, entry: BlockingWorkflowToolRun): T;
|
|
22
|
+
/** Removes this turn's waiting calls, or only one of them when `callId` is given. */
|
|
82
23
|
export declare function removeBlockingWorkflowToolRuns<T extends {
|
|
83
24
|
readonly state?: SessionStateMap;
|
|
84
25
|
}>(session: T, turnId: string, callId?: string): T;
|
|
@@ -86,4 +27,3 @@ export declare function removeBlockingWorkflowToolRuns<T extends {
|
|
|
86
27
|
export declare function findBlockingWorkflowToolRun(state: SessionStateMap | undefined, callId: string, turnId?: string): BlockingWorkflowToolRun | undefined;
|
|
87
28
|
/** The turn inbox is shared; a result settles a call only if the turn recorded that run. */
|
|
88
29
|
export declare function isInboxToolResultFromRecordedWorkflowToolRun(state: SessionStateMap | undefined, result: RuntimeToolResultActionResult): boolean;
|
|
89
|
-
export {};
|