@qduc/term2 0.14.0 → 0.16.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/README.md +324 -316
- package/dist/agent.d.ts +5 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +23 -61
- package/dist/agent.js.map +1 -1
- package/dist/app-helpers.d.ts +4 -0
- package/dist/app-helpers.d.ts.map +1 -1
- package/dist/app-helpers.js +6 -0
- package/dist/app-helpers.js.map +1 -1
- package/dist/app.d.ts +2 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +265 -27
- package/dist/app.js.map +1 -1
- package/dist/cli.js +123 -30
- package/dist/cli.js.map +1 -1
- package/dist/commands/auto-approve-command.js +3 -3
- package/dist/commands/auto-approve-command.js.map +1 -1
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +4 -0
- package/dist/commands/compact-command.js.map +1 -1
- package/dist/commands/effort-command.js +1 -1
- package/dist/commands/effort-command.js.map +1 -1
- package/dist/commands/guarded-settings-command.d.ts +3 -1
- package/dist/commands/guarded-settings-command.d.ts.map +1 -1
- package/dist/commands/guarded-settings-command.js +17 -5
- package/dist/commands/guarded-settings-command.js.map +1 -1
- package/dist/commands/mode-commands.d.ts +9 -2
- package/dist/commands/mode-commands.d.ts.map +1 -1
- package/dist/commands/mode-commands.js +12 -3
- package/dist/commands/mode-commands.js.map +1 -1
- package/dist/commands/model-command.js +1 -1
- package/dist/commands/model-command.js.map +1 -1
- package/dist/commands/resume-command.d.ts +10 -0
- package/dist/commands/resume-command.d.ts.map +1 -0
- package/dist/commands/resume-command.js +40 -0
- package/dist/commands/resume-command.js.map +1 -0
- package/dist/commands/usage-command.d.ts +10 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +11 -1
- package/dist/commands/usage-command.js.map +1 -1
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.js +5 -4
- package/dist/components/ErrorBoundary.js.map +1 -1
- package/dist/components/InputBox.d.ts +2 -0
- package/dist/components/InputBox.d.ts.map +1 -1
- package/dist/components/InputBox.js +59 -8
- package/dist/components/InputBox.js.map +1 -1
- package/dist/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/components/MarkdownRenderer.js +16 -15
- package/dist/components/MarkdownRenderer.js.map +1 -1
- package/dist/components/common/MenuContainer.d.ts +25 -2
- package/dist/components/common/MenuContainer.d.ts.map +1 -1
- package/dist/components/common/MenuContainer.js +35 -11
- package/dist/components/common/MenuContainer.js.map +1 -1
- package/dist/components/common/ScrollableTabBar.d.ts.map +1 -1
- package/dist/components/common/ScrollableTabBar.js +5 -4
- package/dist/components/common/ScrollableTabBar.js.map +1 -1
- package/dist/components/input/ApplicationInputSurface.d.ts +4 -5
- package/dist/components/input/ApplicationInputSurface.d.ts.map +1 -1
- package/dist/components/input/ApplicationInputSurface.js.map +1 -1
- package/dist/components/input/FirstRunSetupPrompt.d.ts.map +1 -1
- package/dist/components/input/FirstRunSetupPrompt.js +5 -4
- package/dist/components/input/FirstRunSetupPrompt.js.map +1 -1
- package/dist/components/input/MenuSurface.d.ts.map +1 -1
- package/dist/components/input/MenuSurface.js +10 -3
- package/dist/components/input/MenuSurface.js.map +1 -1
- package/dist/components/input/ModelMenuSession.d.ts.map +1 -1
- package/dist/components/input/ModelMenuSession.js +2 -1
- package/dist/components/input/ModelMenuSession.js.map +1 -1
- package/dist/components/input/PendingQueueList.d.ts +2 -0
- package/dist/components/input/PendingQueueList.d.ts.map +1 -1
- package/dist/components/input/PendingQueueList.js +26 -6
- package/dist/components/input/PendingQueueList.js.map +1 -1
- package/dist/components/input/ProviderMenuSession.d.ts.map +1 -1
- package/dist/components/input/ProviderMenuSession.js +1 -0
- package/dist/components/input/ProviderMenuSession.js.map +1 -1
- package/dist/components/input/SettingsValueMenuSession.d.ts.map +1 -1
- package/dist/components/input/SettingsValueMenuSession.js +8 -1
- package/dist/components/input/SettingsValueMenuSession.js.map +1 -1
- package/dist/components/layout/BackgroundTaskManager.d.ts +2 -0
- package/dist/components/layout/BackgroundTaskManager.d.ts.map +1 -1
- package/dist/components/layout/BackgroundTaskManager.js +166 -73
- package/dist/components/layout/BackgroundTaskManager.js.map +1 -1
- package/dist/components/layout/BackgroundTasksPanel.d.ts +12 -3
- package/dist/components/layout/BackgroundTasksPanel.d.ts.map +1 -1
- package/dist/components/layout/BackgroundTasksPanel.js +197 -62
- package/dist/components/layout/BackgroundTasksPanel.js.map +1 -1
- package/dist/components/layout/Banner.d.ts +0 -1
- package/dist/components/layout/Banner.d.ts.map +1 -1
- package/dist/components/layout/Banner.js +43 -73
- package/dist/components/layout/Banner.js.map +1 -1
- package/dist/components/layout/BottomArea.d.ts +17 -6
- package/dist/components/layout/BottomArea.d.ts.map +1 -1
- package/dist/components/layout/BottomArea.js +44 -19
- package/dist/components/layout/BottomArea.js.map +1 -1
- package/dist/components/layout/DiffView.js +5 -5
- package/dist/components/layout/DiffView.js.map +1 -1
- package/dist/components/layout/StatusBar.d.ts +9 -1
- package/dist/components/layout/StatusBar.d.ts.map +1 -1
- package/dist/components/layout/StatusBar.js +332 -80
- package/dist/components/layout/StatusBar.js.map +1 -1
- package/dist/components/layout/background-task-clock.d.ts +43 -0
- package/dist/components/layout/background-task-clock.d.ts.map +1 -0
- package/dist/components/layout/background-task-clock.js +46 -0
- package/dist/components/layout/background-task-clock.js.map +1 -0
- package/dist/components/layout/live-task-rows.d.ts +16 -0
- package/dist/components/layout/live-task-rows.d.ts.map +1 -0
- package/dist/components/layout/live-task-rows.js +28 -0
- package/dist/components/layout/live-task-rows.js.map +1 -0
- package/dist/components/layout/terminal-text-budget.d.ts +4 -0
- package/dist/components/layout/terminal-text-budget.d.ts.map +1 -0
- package/dist/components/layout/terminal-text-budget.js +18 -0
- package/dist/components/layout/terminal-text-budget.js.map +1 -0
- package/dist/components/menu/CopyMenu.d.ts.map +1 -1
- package/dist/components/menu/CopyMenu.js +4 -3
- package/dist/components/menu/CopyMenu.js.map +1 -1
- package/dist/components/menu/MentorPoolSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/MentorPoolSelectionMenu.js +28 -21
- package/dist/components/menu/MentorPoolSelectionMenu.js.map +1 -1
- package/dist/components/menu/ModelSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/ModelSelectionMenu.js +43 -17
- package/dist/components/menu/ModelSelectionMenu.js.map +1 -1
- package/dist/components/menu/PathSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/PathSelectionMenu.js +4 -3
- package/dist/components/menu/PathSelectionMenu.js.map +1 -1
- package/dist/components/menu/ProviderSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/ProviderSelectionMenu.js +71 -26
- package/dist/components/menu/ProviderSelectionMenu.js.map +1 -1
- package/dist/components/menu/RewindMenu.d.ts.map +1 -1
- package/dist/components/menu/RewindMenu.js +4 -3
- package/dist/components/menu/RewindMenu.js.map +1 -1
- package/dist/components/menu/SettingsSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SettingsSelectionMenu.js +30 -25
- package/dist/components/menu/SettingsSelectionMenu.js.map +1 -1
- package/dist/components/menu/SettingsValueSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SettingsValueSelectionMenu.js +22 -20
- package/dist/components/menu/SettingsValueSelectionMenu.js.map +1 -1
- package/dist/components/menu/SkillSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SkillSelectionMenu.js +33 -23
- package/dist/components/menu/SkillSelectionMenu.js.map +1 -1
- package/dist/components/menu/SlashCommandMenu.d.ts.map +1 -1
- package/dist/components/menu/SlashCommandMenu.js +11 -6
- package/dist/components/menu/SlashCommandMenu.js.map +1 -1
- package/dist/components/message/ChatMessage.js +2 -2
- package/dist/components/message/ChatMessage.js.map +1 -1
- package/dist/components/message/CodeContextSearchRenderer.d.ts.map +1 -1
- package/dist/components/message/CodeContextSearchRenderer.js +8 -11
- package/dist/components/message/CodeContextSearchRenderer.js.map +1 -1
- package/dist/components/message/CommandGroupSummary.d.ts +9 -0
- package/dist/components/message/CommandGroupSummary.d.ts.map +1 -0
- package/dist/components/message/CommandGroupSummary.js +39 -0
- package/dist/components/message/CommandGroupSummary.js.map +1 -0
- package/dist/components/message/CommandMessage.d.ts +8 -0
- package/dist/components/message/CommandMessage.d.ts.map +1 -1
- package/dist/components/message/CommandMessage.js +159 -110
- package/dist/components/message/CommandMessage.js.map +1 -1
- package/dist/components/message/GrepRenderer.d.ts.map +1 -1
- package/dist/components/message/GrepRenderer.js +5 -8
- package/dist/components/message/GrepRenderer.js.map +1 -1
- package/dist/components/message/MemoryRenderer.d.ts +1 -0
- package/dist/components/message/MemoryRenderer.d.ts.map +1 -1
- package/dist/components/message/MemoryRenderer.js +19 -17
- package/dist/components/message/MemoryRenderer.js.map +1 -1
- package/dist/components/message/MessageList.d.ts +6 -3
- package/dist/components/message/MessageList.d.ts.map +1 -1
- package/dist/components/message/MessageList.js +68 -13
- package/dist/components/message/MessageList.js.map +1 -1
- package/dist/components/message/ReadFileRenderer.d.ts.map +1 -1
- package/dist/components/message/ReadFileRenderer.js +5 -6
- package/dist/components/message/ReadFileRenderer.js.map +1 -1
- package/dist/components/message/SubagentActivityMessage.d.ts.map +1 -1
- package/dist/components/message/SubagentActivityMessage.js +21 -15
- package/dist/components/message/SubagentActivityMessage.js.map +1 -1
- package/dist/components/message/WebFetchRenderer.d.ts.map +1 -1
- package/dist/components/message/WebFetchRenderer.js +7 -11
- package/dist/components/message/WebFetchRenderer.js.map +1 -1
- package/dist/components/message/WebSearchRenderer.d.ts.map +1 -1
- package/dist/components/message/WebSearchRenderer.js +5 -10
- package/dist/components/message/WebSearchRenderer.js.map +1 -1
- package/dist/components/message/command-grouping.d.ts +66 -0
- package/dist/components/message/command-grouping.d.ts.map +1 -0
- package/dist/components/message/command-grouping.js +184 -0
- package/dist/components/message/command-grouping.js.map +1 -0
- package/dist/components/message/command-message-helpers.d.ts +11 -37
- package/dist/components/message/command-message-helpers.d.ts.map +1 -1
- package/dist/components/message/command-message-helpers.js +62 -8
- package/dist/components/message/command-message-helpers.js.map +1 -1
- package/dist/components/message/useCommandVisibility.d.ts.map +1 -1
- package/dist/components/message/useCommandVisibility.js +5 -4
- package/dist/components/message/useCommandVisibility.js.map +1 -1
- package/dist/components/prompt/ApprovalPrompt.d.ts +1 -1
- package/dist/components/prompt/ApprovalPrompt.d.ts.map +1 -1
- package/dist/components/prompt/ApprovalPrompt.js +286 -156
- package/dist/components/prompt/ApprovalPrompt.js.map +1 -1
- package/dist/components/prompt/HandoffConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/HandoffConfirmationPrompt.js +3 -2
- package/dist/components/prompt/HandoffConfirmationPrompt.js.map +1 -1
- package/dist/components/prompt/InputSurgeConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/InputSurgeConfirmationPrompt.js +5 -4
- package/dist/components/prompt/InputSurgeConfirmationPrompt.js.map +1 -1
- package/dist/components/prompt/LargeUncachedConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/LargeUncachedConfirmationPrompt.js +4 -3
- package/dist/components/prompt/LargeUncachedConfirmationPrompt.js.map +1 -1
- package/dist/components/prompt/ModeSwitchConfirmationPrompt.d.ts +11 -0
- package/dist/components/prompt/ModeSwitchConfirmationPrompt.d.ts.map +1 -0
- package/dist/components/prompt/ModeSwitchConfirmationPrompt.js +51 -0
- package/dist/components/prompt/ModeSwitchConfirmationPrompt.js.map +1 -0
- package/dist/components/prompt/QueuePausedPrompt.d.ts.map +1 -1
- package/dist/components/prompt/QueuePausedPrompt.js +15 -8
- package/dist/components/prompt/QueuePausedPrompt.js.map +1 -1
- package/dist/components/prompt/StandardModeConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/StandardModeConfirmationPrompt.js +3 -2
- package/dist/components/prompt/StandardModeConfirmationPrompt.js.map +1 -1
- package/dist/components/theme.d.ts +58 -3
- package/dist/components/theme.d.ts.map +1 -1
- package/dist/components/theme.js +84 -17
- package/dist/components/theme.js.map +1 -1
- package/dist/contracts/application-stream.d.ts +21 -0
- package/dist/contracts/application-stream.d.ts.map +1 -1
- package/dist/contracts/conversation.d.ts +24 -1
- package/dist/contracts/conversation.d.ts.map +1 -1
- package/dist/contracts/conversation.js +8 -0
- package/dist/contracts/conversation.js.map +1 -1
- package/dist/contracts/streamed-model-turn.d.ts +22 -1
- package/dist/contracts/streamed-model-turn.d.ts.map +1 -1
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/session-runtime.d.ts +10 -0
- package/dist/core/session-runtime.d.ts.map +1 -0
- package/dist/core/session-runtime.js +9 -0
- package/dist/core/session-runtime.js.map +1 -0
- package/dist/gateway/assertion.d.ts +41 -0
- package/dist/gateway/assertion.d.ts.map +1 -0
- package/dist/gateway/assertion.js +168 -0
- package/dist/gateway/assertion.js.map +1 -0
- package/dist/gateway/contracts.d.ts +141 -0
- package/dist/gateway/contracts.d.ts.map +1 -0
- package/dist/gateway/contracts.js +24 -0
- package/dist/gateway/contracts.js.map +1 -0
- package/dist/gateway/dynamic-workspace-registry.d.ts +76 -0
- package/dist/gateway/dynamic-workspace-registry.d.ts.map +1 -0
- package/dist/gateway/dynamic-workspace-registry.js +403 -0
- package/dist/gateway/dynamic-workspace-registry.js.map +1 -0
- package/dist/gateway/gateway.d.ts +95 -0
- package/dist/gateway/gateway.d.ts.map +1 -0
- package/dist/gateway/gateway.js +1960 -0
- package/dist/gateway/gateway.js.map +1 -0
- package/dist/gateway/index.d.ts +22 -0
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/gateway/index.js +22 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/interaction-protocol.d.ts +76 -0
- package/dist/gateway/interaction-protocol.d.ts.map +1 -0
- package/dist/gateway/interaction-protocol.js +548 -0
- package/dist/gateway/interaction-protocol.js.map +1 -0
- package/dist/gateway/launcher-seam.d.ts +18 -0
- package/dist/gateway/launcher-seam.d.ts.map +1 -0
- package/dist/gateway/launcher-seam.js +43 -0
- package/dist/gateway/launcher-seam.js.map +1 -0
- package/dist/gateway/launcher.d.ts +8 -0
- package/dist/gateway/launcher.d.ts.map +1 -0
- package/dist/gateway/launcher.js +20 -0
- package/dist/gateway/launcher.js.map +1 -0
- package/dist/gateway/lifecycle.d.ts +12 -0
- package/dist/gateway/lifecycle.d.ts.map +1 -0
- package/dist/gateway/lifecycle.js +38 -0
- package/dist/gateway/lifecycle.js.map +1 -0
- package/dist/gateway/pairing.d.ts +25 -0
- package/dist/gateway/pairing.d.ts.map +1 -0
- package/dist/gateway/pairing.js +107 -0
- package/dist/gateway/pairing.js.map +1 -0
- package/dist/gateway/persistence/admission-persistence.d.ts +82 -0
- package/dist/gateway/persistence/admission-persistence.d.ts.map +1 -0
- package/dist/gateway/persistence/admission-persistence.js +215 -0
- package/dist/gateway/persistence/admission-persistence.js.map +1 -0
- package/dist/gateway/persistence/contracts.d.ts +94 -0
- package/dist/gateway/persistence/contracts.d.ts.map +1 -0
- package/dist/gateway/persistence/contracts.js +32 -0
- package/dist/gateway/persistence/contracts.js.map +1 -0
- package/dist/gateway/persistence/coordinator.d.ts +27 -0
- package/dist/gateway/persistence/coordinator.d.ts.map +1 -0
- package/dist/gateway/persistence/coordinator.js +194 -0
- package/dist/gateway/persistence/coordinator.js.map +1 -0
- package/dist/gateway/persistence/event-journal.d.ts +31 -0
- package/dist/gateway/persistence/event-journal.d.ts.map +1 -0
- package/dist/gateway/persistence/event-journal.js +378 -0
- package/dist/gateway/persistence/event-journal.js.map +1 -0
- package/dist/gateway/persistence/interaction-checkpoint.d.ts +17 -0
- package/dist/gateway/persistence/interaction-checkpoint.d.ts.map +1 -0
- package/dist/gateway/persistence/interaction-checkpoint.js +75 -0
- package/dist/gateway/persistence/interaction-checkpoint.js.map +1 -0
- package/dist/gateway/persistence/projection.d.ts +53 -0
- package/dist/gateway/persistence/projection.d.ts.map +1 -0
- package/dist/gateway/persistence/projection.js +226 -0
- package/dist/gateway/persistence/projection.js.map +1 -0
- package/dist/gateway/persistence/retention.d.ts +16 -0
- package/dist/gateway/persistence/retention.d.ts.map +1 -0
- package/dist/gateway/persistence/retention.js +93 -0
- package/dist/gateway/persistence/retention.js.map +1 -0
- package/dist/gateway/persistence/session-index.d.ts +34 -0
- package/dist/gateway/persistence/session-index.d.ts.map +1 -0
- package/dist/gateway/persistence/session-index.js +348 -0
- package/dist/gateway/persistence/session-index.js.map +1 -0
- package/dist/gateway/persistence/session-persistence.d.ts +68 -0
- package/dist/gateway/persistence/session-persistence.d.ts.map +1 -0
- package/dist/gateway/persistence/session-persistence.js +165 -0
- package/dist/gateway/persistence/session-persistence.js.map +1 -0
- package/dist/gateway/persistence/storage.d.ts +13 -0
- package/dist/gateway/persistence/storage.d.ts.map +1 -0
- package/dist/gateway/persistence/storage.js +87 -0
- package/dist/gateway/persistence/storage.js.map +1 -0
- package/dist/gateway/replay-ledger.d.ts +30 -0
- package/dist/gateway/replay-ledger.d.ts.map +1 -0
- package/dist/gateway/replay-ledger.js +83 -0
- package/dist/gateway/replay-ledger.js.map +1 -0
- package/dist/gateway/runtime-factory.d.ts +93 -0
- package/dist/gateway/runtime-factory.d.ts.map +1 -0
- package/dist/gateway/runtime-factory.js +242 -0
- package/dist/gateway/runtime-factory.js.map +1 -0
- package/dist/gateway/safe-log.d.ts +15 -0
- package/dist/gateway/safe-log.d.ts.map +1 -0
- package/dist/gateway/safe-log.js +108 -0
- package/dist/gateway/safe-log.js.map +1 -0
- package/dist/gateway/server-session.d.ts +65 -0
- package/dist/gateway/server-session.d.ts.map +1 -0
- package/dist/gateway/server-session.js +284 -0
- package/dist/gateway/server-session.js.map +1 -0
- package/dist/gateway/server.d.ts +65 -0
- package/dist/gateway/server.d.ts.map +1 -0
- package/dist/gateway/server.js +214 -0
- package/dist/gateway/server.js.map +1 -0
- package/dist/gateway/settings-rpc.d.ts +95 -0
- package/dist/gateway/settings-rpc.d.ts.map +1 -0
- package/dist/gateway/settings-rpc.js +227 -0
- package/dist/gateway/settings-rpc.js.map +1 -0
- package/dist/gateway/trusted-clients.d.ts +27 -0
- package/dist/gateway/trusted-clients.d.ts.map +1 -0
- package/dist/gateway/trusted-clients.js +157 -0
- package/dist/gateway/trusted-clients.js.map +1 -0
- package/dist/gateway/worker-boundary.d.ts +41 -0
- package/dist/gateway/worker-boundary.d.ts.map +1 -0
- package/dist/gateway/worker-boundary.js +159 -0
- package/dist/gateway/worker-boundary.js.map +1 -0
- package/dist/gateway/workspace-admission.d.ts +48 -0
- package/dist/gateway/workspace-admission.d.ts.map +1 -0
- package/dist/gateway/workspace-admission.js +358 -0
- package/dist/gateway/workspace-admission.js.map +1 -0
- package/dist/gateway/workspace-boundary-probe.d.ts +18 -0
- package/dist/gateway/workspace-boundary-probe.d.ts.map +1 -0
- package/dist/gateway/workspace-boundary-probe.js +37 -0
- package/dist/gateway/workspace-boundary-probe.js.map +1 -0
- package/dist/hooks/conversation-ui-reducer.d.ts +12 -0
- package/dist/hooks/conversation-ui-reducer.d.ts.map +1 -1
- package/dist/hooks/conversation-ui-reducer.js +12 -1
- package/dist/hooks/conversation-ui-reducer.js.map +1 -1
- package/dist/hooks/settings-completion-config.d.ts.map +1 -1
- package/dist/hooks/settings-completion-config.js +39 -3
- package/dist/hooks/settings-completion-config.js.map +1 -1
- package/dist/hooks/use-app-commands.d.ts +9 -1
- package/dist/hooks/use-app-commands.d.ts.map +1 -1
- package/dist/hooks/use-app-commands.js +34 -14
- package/dist/hooks/use-app-commands.js.map +1 -1
- package/dist/hooks/use-app-keyboard-shortcuts.d.ts +6 -3
- package/dist/hooks/use-app-keyboard-shortcuts.d.ts.map +1 -1
- package/dist/hooks/use-app-keyboard-shortcuts.js +22 -9
- package/dist/hooks/use-app-keyboard-shortcuts.js.map +1 -1
- package/dist/hooks/use-conversation.d.ts +9 -0
- package/dist/hooks/use-conversation.d.ts.map +1 -1
- package/dist/hooks/use-conversation.js +34 -14
- package/dist/hooks/use-conversation.js.map +1 -1
- package/dist/hooks/use-grok-credit-usage.d.ts +20 -0
- package/dist/hooks/use-grok-credit-usage.d.ts.map +1 -0
- package/dist/hooks/use-grok-credit-usage.js +48 -0
- package/dist/hooks/use-grok-credit-usage.js.map +1 -0
- package/dist/hooks/use-opencode-go-usage.d.ts +8 -0
- package/dist/hooks/use-opencode-go-usage.d.ts.map +1 -0
- package/dist/hooks/use-opencode-go-usage.js +45 -0
- package/dist/hooks/use-opencode-go-usage.js.map +1 -0
- package/dist/hooks/use-provider-selection.d.ts +10 -0
- package/dist/hooks/use-provider-selection.d.ts.map +1 -1
- package/dist/hooks/use-provider-selection.js +105 -6
- package/dist/hooks/use-provider-selection.js.map +1 -1
- package/dist/hooks/use-settings-value-completion.d.ts.map +1 -1
- package/dist/hooks/use-settings-value-completion.js +10 -2
- package/dist/hooks/use-settings-value-completion.js.map +1 -1
- package/dist/hooks/use-shell-mode.d.ts +3 -4
- package/dist/hooks/use-shell-mode.d.ts.map +1 -1
- package/dist/hooks/use-shell-mode.js +14 -12
- package/dist/hooks/use-shell-mode.js.map +1 -1
- package/dist/hooks/use-terminal-columns.d.ts +15 -0
- package/dist/hooks/use-terminal-columns.d.ts.map +1 -0
- package/dist/hooks/use-terminal-columns.js +45 -0
- package/dist/hooks/use-terminal-columns.js.map +1 -0
- package/dist/lib/agent-client.d.ts +12 -3
- package/dist/lib/agent-client.d.ts.map +1 -1
- package/dist/lib/agent-client.js +116 -23
- package/dist/lib/agent-client.js.map +1 -1
- package/dist/lib/agent-configuration.d.ts +5 -0
- package/dist/lib/agent-configuration.d.ts.map +1 -1
- package/dist/lib/agent-configuration.js +10 -2
- package/dist/lib/agent-configuration.js.map +1 -1
- package/dist/lib/agent-factory.d.ts +5 -0
- package/dist/lib/agent-factory.d.ts.map +1 -1
- package/dist/lib/agent-factory.js +36 -11
- package/dist/lib/agent-factory.js.map +1 -1
- package/dist/lib/editor-impl.d.ts.map +1 -1
- package/dist/lib/editor-impl.js +14 -17
- package/dist/lib/editor-impl.js.map +1 -1
- package/dist/lib/harness-input-idle.d.ts +16 -0
- package/dist/lib/harness-input-idle.d.ts.map +1 -0
- package/dist/lib/harness-input-idle.js +51 -0
- package/dist/lib/harness-input-idle.js.map +1 -0
- package/dist/lib/input-owner.d.ts +3 -0
- package/dist/lib/input-owner.d.ts.map +1 -1
- package/dist/lib/input-owner.js +2 -0
- package/dist/lib/input-owner.js.map +1 -1
- package/dist/lib/subagent-bridge.d.ts +3 -3
- package/dist/lib/subagent-bridge.d.ts.map +1 -1
- package/dist/lib/subagent-bridge.js +16 -9
- package/dist/lib/subagent-bridge.js.map +1 -1
- package/dist/lib/tool-invoke.d.ts +2 -0
- package/dist/lib/tool-invoke.d.ts.map +1 -1
- package/dist/lib/tool-invoke.js +3 -0
- package/dist/lib/tool-invoke.js.map +1 -1
- package/dist/non-interactive.d.ts.map +1 -1
- package/dist/non-interactive.js +12 -0
- package/dist/non-interactive.js.map +1 -1
- package/dist/prompts/approval-model.md +22 -0
- package/dist/prompts/explorer-delegation-contract.test.ts +22 -0
- package/dist/prompts/gpt-5.6.md +4 -3
- package/dist/prompts/kimi.md +1 -1
- package/dist/prompts/mentor-mode-stub.md +3 -0
- package/dist/prompts/orchestrator-mode-stub.md +3 -0
- package/dist/prompts/orchestrator.md +10 -1
- package/dist/prompts/plan-mode-info.md +3 -3
- package/dist/prompts/plan-mode-stub.md +7 -0
- package/dist/prompts/prefix-quality.test.ts +112 -0
- package/dist/prompts/prompt-constructor.d.ts +2 -0
- package/dist/prompts/prompt-constructor.d.ts.map +1 -1
- package/dist/prompts/prompt-constructor.js +24 -11
- package/dist/prompts/prompt-constructor.js.map +1 -1
- package/dist/prompts/prompt-constructor.test.ts +48 -6
- package/dist/prompts/prompt-constructor.ts +28 -13
- package/dist/prompts/prompt-profiles.d.ts +1 -3
- package/dist/prompts/prompt-profiles.d.ts.map +1 -1
- package/dist/prompts/prompt-profiles.js +2 -7
- package/dist/prompts/prompt-profiles.js.map +1 -1
- package/dist/prompts/prompt-profiles.ts +3 -16
- package/dist/prompts/session-browser.md +3 -0
- package/dist/prompts/subagent-delegation.d.ts +3 -2
- package/dist/prompts/subagent-delegation.d.ts.map +1 -1
- package/dist/prompts/subagent-delegation.js +9 -13
- package/dist/prompts/subagent-delegation.js.map +1 -1
- package/dist/prompts/subagent-delegation.ts +9 -13
- package/dist/prompts/subagents/explorer.md +7 -1
- package/dist/prompts/subagents/librarian.md +2 -0
- package/dist/prompts/subagents/mentor.md +2 -0
- package/dist/prompts/subagents/worker.md +2 -0
- package/dist/providers/ai-sdk-streamed-model.d.ts +5 -0
- package/dist/providers/ai-sdk-streamed-model.d.ts.map +1 -1
- package/dist/providers/ai-sdk-streamed-model.js +64 -1
- package/dist/providers/ai-sdk-streamed-model.js.map +1 -1
- package/dist/providers/chained-wire-state.d.ts +13 -2
- package/dist/providers/chained-wire-state.d.ts.map +1 -1
- package/dist/providers/chained-wire-state.js +17 -10
- package/dist/providers/chained-wire-state.js.map +1 -1
- package/dist/providers/codex-auth.d.ts +70 -2
- package/dist/providers/codex-auth.d.ts.map +1 -1
- package/dist/providers/codex-auth.js +168 -2
- package/dist/providers/codex-auth.js.map +1 -1
- package/dist/providers/codex-responses-model.d.ts +3 -0
- package/dist/providers/codex-responses-model.d.ts.map +1 -1
- package/dist/providers/codex-responses-model.js +314 -162
- package/dist/providers/codex-responses-model.js.map +1 -1
- package/dist/providers/codex-turn-converter.d.ts.map +1 -1
- package/dist/providers/codex-turn-converter.js +7 -1
- package/dist/providers/codex-turn-converter.js.map +1 -1
- package/dist/providers/codex.provider.d.ts +25 -2
- package/dist/providers/codex.provider.d.ts.map +1 -1
- package/dist/providers/codex.provider.js +83 -71
- package/dist/providers/codex.provider.js.map +1 -1
- package/dist/providers/common/provider-errors.d.ts +20 -0
- package/dist/providers/common/provider-errors.d.ts.map +1 -1
- package/dist/providers/common/provider-errors.js +35 -0
- package/dist/providers/common/provider-errors.js.map +1 -1
- package/dist/providers/grok-auth.d.ts +102 -0
- package/dist/providers/grok-auth.d.ts.map +1 -0
- package/dist/providers/grok-auth.js +318 -0
- package/dist/providers/grok-auth.js.map +1 -0
- package/dist/providers/grok-credit-usage.d.ts +53 -0
- package/dist/providers/grok-credit-usage.d.ts.map +1 -0
- package/dist/providers/grok-credit-usage.js +108 -0
- package/dist/providers/grok-credit-usage.js.map +1 -0
- package/dist/providers/grok.provider.d.ts +24 -0
- package/dist/providers/grok.provider.d.ts.map +1 -0
- package/dist/providers/grok.provider.js +153 -0
- package/dist/providers/grok.provider.js.map +1 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/jwt-claims.d.ts +12 -0
- package/dist/providers/jwt-claims.d.ts.map +1 -0
- package/dist/providers/jwt-claims.js +25 -0
- package/dist/providers/jwt-claims.js.map +1 -0
- package/dist/providers/luna-responses-lite-wire-protocol.d.ts +1 -0
- package/dist/providers/luna-responses-lite-wire-protocol.d.ts.map +1 -1
- package/dist/providers/luna-responses-lite-wire-protocol.js +19 -0
- package/dist/providers/luna-responses-lite-wire-protocol.js.map +1 -1
- package/dist/providers/model-catalog/catalog.generated.d.ts +360 -232
- package/dist/providers/model-catalog/catalog.generated.d.ts.map +1 -1
- package/dist/providers/model-catalog/catalog.generated.js +360 -232
- package/dist/providers/model-catalog/catalog.generated.js.map +1 -1
- package/dist/providers/model-catalog/generate-catalog.d.ts.map +1 -1
- package/dist/providers/model-catalog/generate-catalog.js +21 -1
- package/dist/providers/model-catalog/generate-catalog.js.map +1 -1
- package/dist/providers/oauth-account-store.d.ts +89 -0
- package/dist/providers/oauth-account-store.d.ts.map +1 -0
- package/dist/providers/oauth-account-store.js +193 -0
- package/dist/providers/oauth-account-store.js.map +1 -0
- package/dist/providers/oauth-accounts.d.ts +24 -0
- package/dist/providers/oauth-accounts.d.ts.map +1 -0
- package/dist/providers/oauth-accounts.js +37 -0
- package/dist/providers/oauth-accounts.js.map +1 -0
- package/dist/providers/oauth-pkce.d.ts +61 -0
- package/dist/providers/oauth-pkce.d.ts.map +1 -0
- package/dist/providers/oauth-pkce.js +272 -0
- package/dist/providers/oauth-pkce.js.map +1 -0
- package/dist/providers/oauth-session-account.d.ts +5 -0
- package/dist/providers/oauth-session-account.d.ts.map +1 -0
- package/dist/providers/oauth-session-account.js +24 -0
- package/dist/providers/oauth-session-account.js.map +1 -0
- package/dist/providers/openai-chat-completions-model.d.ts.map +1 -1
- package/dist/providers/openai-chat-completions-model.js +37 -16
- package/dist/providers/openai-chat-completions-model.js.map +1 -1
- package/dist/providers/openai-compatible-lazy.js.map +1 -1
- package/dist/providers/openai-compatible.provider.d.ts +5 -0
- package/dist/providers/openai-compatible.provider.d.ts.map +1 -1
- package/dist/providers/openai-compatible.provider.js +40 -3
- package/dist/providers/openai-compatible.provider.js.map +1 -1
- package/dist/providers/openai-responses-model.d.ts +13 -3
- package/dist/providers/openai-responses-model.d.ts.map +1 -1
- package/dist/providers/openai-responses-model.js +92 -39
- package/dist/providers/openai-responses-model.js.map +1 -1
- package/dist/providers/openai.provider.d.ts.map +1 -1
- package/dist/providers/openai.provider.js +23 -2
- package/dist/providers/openai.provider.js.map +1 -1
- package/dist/providers/opencode-go-usage.d.ts +24 -0
- package/dist/providers/opencode-go-usage.d.ts.map +1 -0
- package/dist/providers/opencode-go-usage.js +37 -0
- package/dist/providers/opencode-go-usage.js.map +1 -0
- package/dist/providers/opencode-routing.d.ts +2 -0
- package/dist/providers/opencode-routing.d.ts.map +1 -1
- package/dist/providers/opencode-routing.js +12 -6
- package/dist/providers/opencode-routing.js.map +1 -1
- package/dist/providers/opencode-transport-discovery.d.ts +18 -0
- package/dist/providers/opencode-transport-discovery.d.ts.map +1 -0
- package/dist/providers/opencode-transport-discovery.js +115 -0
- package/dist/providers/opencode-transport-discovery.js.map +1 -0
- package/dist/providers/openrouter.provider.d.ts.map +1 -1
- package/dist/providers/openrouter.provider.js +8 -1
- package/dist/providers/openrouter.provider.js.map +1 -1
- package/dist/providers/provider-opaque-compatibility.d.ts +58 -0
- package/dist/providers/provider-opaque-compatibility.d.ts.map +1 -0
- package/dist/providers/provider-opaque-compatibility.js +80 -0
- package/dist/providers/provider-opaque-compatibility.js.map +1 -0
- package/dist/providers/provider-service.d.ts +1 -1
- package/dist/providers/provider-service.d.ts.map +1 -1
- package/dist/providers/provider-service.js.map +1 -1
- package/dist/providers/registry.d.ts +10 -1
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js.map +1 -1
- package/dist/providers/responses-websocket-sessions.d.ts +26 -0
- package/dist/providers/responses-websocket-sessions.d.ts.map +1 -0
- package/dist/providers/responses-websocket-sessions.js +116 -0
- package/dist/providers/responses-websocket-sessions.js.map +1 -0
- package/dist/providers/retrying-model.d.ts.map +1 -1
- package/dist/providers/retrying-model.js +31 -3
- package/dist/providers/retrying-model.js.map +1 -1
- package/dist/providers/websocket-close-evidence.d.ts +45 -0
- package/dist/providers/websocket-close-evidence.d.ts.map +1 -0
- package/dist/providers/websocket-close-evidence.js +78 -0
- package/dist/providers/websocket-close-evidence.js.map +1 -0
- package/dist/providers/websocket-receive-watchdog.d.ts +9 -1
- package/dist/providers/websocket-receive-watchdog.d.ts.map +1 -1
- package/dist/providers/websocket-receive-watchdog.js +27 -1
- package/dist/providers/websocket-receive-watchdog.js.map +1 -1
- package/dist/providers/websocket-request-dispatch.d.ts +35 -0
- package/dist/providers/websocket-request-dispatch.d.ts.map +1 -0
- package/dist/providers/websocket-request-dispatch.js +23 -0
- package/dist/providers/websocket-request-dispatch.js.map +1 -0
- package/dist/scripts/eval-context-compaction/runner.js +1 -1
- package/dist/scripts/eval-context-compaction/runner.js.map +1 -1
- package/dist/services/agent-runtime/agent-handle.d.ts.map +1 -1
- package/dist/services/agent-runtime/agent-handle.js +8 -5
- package/dist/services/agent-runtime/agent-handle.js.map +1 -1
- package/dist/services/agent-runtime/agent-runtime.d.ts +1 -1
- package/dist/services/agent-runtime/agent-runtime.js +1 -1
- package/dist/services/agent-runtime/application-run-loop.d.ts +37 -9
- package/dist/services/agent-runtime/application-run-loop.d.ts.map +1 -1
- package/dist/services/agent-runtime/application-run-loop.js +512 -219
- package/dist/services/agent-runtime/application-run-loop.js.map +1 -1
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.d.ts +6 -1
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.d.ts.map +1 -1
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.js +72 -4
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.js.map +1 -1
- package/dist/services/agent-runtime/executor.d.ts +1 -1
- package/dist/services/agent-runtime/executor.d.ts.map +1 -1
- package/dist/services/agent-runtime/executor.js +5 -5
- package/dist/services/agent-runtime/executor.js.map +1 -1
- package/dist/services/agent-runtime/generation-guard.d.ts +39 -24
- package/dist/services/agent-runtime/generation-guard.d.ts.map +1 -1
- package/dist/services/agent-runtime/generation-guard.js +100 -97
- package/dist/services/agent-runtime/generation-guard.js.map +1 -1
- package/dist/services/agent-runtime/run-budget.d.ts +131 -0
- package/dist/services/agent-runtime/run-budget.d.ts.map +1 -0
- package/dist/services/agent-runtime/run-budget.js +272 -0
- package/dist/services/agent-runtime/run-budget.js.map +1 -0
- package/dist/services/agent-runtime/tool-invocation-context.d.ts +12 -0
- package/dist/services/agent-runtime/tool-invocation-context.d.ts.map +1 -1
- package/dist/services/agent-runtime/tool-invocation-context.js.map +1 -1
- package/dist/services/agent-runtime/types.d.ts +5 -4
- package/dist/services/agent-runtime/types.d.ts.map +1 -1
- package/dist/services/agent-stream.d.ts.map +1 -1
- package/dist/services/agent-stream.js +3 -1
- package/dist/services/agent-stream.js.map +1 -1
- package/dist/services/approval/approval-decision-executor.d.ts +6 -1
- package/dist/services/approval/approval-decision-executor.d.ts.map +1 -1
- package/dist/services/approval/approval-decision-executor.js +15 -3
- package/dist/services/approval/approval-decision-executor.js.map +1 -1
- package/dist/services/approval/approval-decision-policy.d.ts.map +1 -1
- package/dist/services/approval/approval-decision-policy.js +3 -0
- package/dist/services/approval/approval-decision-policy.js.map +1 -1
- package/dist/services/approval/approval-flow-coordinator.d.ts +2 -0
- package/dist/services/approval/approval-flow-coordinator.d.ts.map +1 -1
- package/dist/services/approval/approval-flow-coordinator.js +14 -2
- package/dist/services/approval/approval-flow-coordinator.js.map +1 -1
- package/dist/services/approval/background-subagent-approval-controller.d.ts +3 -1
- package/dist/services/approval/background-subagent-approval-controller.d.ts.map +1 -1
- package/dist/services/approval/background-subagent-approval-controller.js +7 -4
- package/dist/services/approval/background-subagent-approval-controller.js.map +1 -1
- package/dist/services/approval/shell-auto-approval-resolver.d.ts +5 -0
- package/dist/services/approval/shell-auto-approval-resolver.d.ts.map +1 -1
- package/dist/services/approval/shell-auto-approval-resolver.js +8 -0
- package/dist/services/approval/shell-auto-approval-resolver.js.map +1 -1
- package/dist/services/approval/tool-approval-batch-coordinator.d.ts.map +1 -1
- package/dist/services/approval/tool-approval-batch-coordinator.js +20 -11
- package/dist/services/approval/tool-approval-batch-coordinator.js.map +1 -1
- package/dist/services/approval/tool-ownership-registry.d.ts +5 -1
- package/dist/services/approval/tool-ownership-registry.d.ts.map +1 -1
- package/dist/services/approval/tool-ownership-registry.js +5 -22
- package/dist/services/approval/tool-ownership-registry.js.map +1 -1
- package/dist/services/background-task-activity.d.ts +79 -0
- package/dist/services/background-task-activity.d.ts.map +1 -0
- package/dist/services/background-task-activity.js +34 -0
- package/dist/services/background-task-activity.js.map +1 -0
- package/dist/services/command-message-streaming.d.ts +4 -2
- package/dist/services/command-message-streaming.d.ts.map +1 -1
- package/dist/services/command-message-streaming.js +2 -2
- package/dist/services/command-message-streaming.js.map +1 -1
- package/dist/services/conversation/conversation-adapter-factory.d.ts +6 -2
- package/dist/services/conversation/conversation-adapter-factory.d.ts.map +1 -1
- package/dist/services/conversation/conversation-adapter-factory.js +5 -1
- package/dist/services/conversation/conversation-adapter-factory.js.map +1 -1
- package/dist/services/conversation/conversation-adapter.d.ts +53 -10
- package/dist/services/conversation/conversation-adapter.d.ts.map +1 -1
- package/dist/services/conversation/conversation-adapter.js +252 -43
- package/dist/services/conversation/conversation-adapter.js.map +1 -1
- package/dist/services/conversation/conversation-admission-workflow.d.ts +3 -2
- package/dist/services/conversation/conversation-admission-workflow.d.ts.map +1 -1
- package/dist/services/conversation/conversation-admission-workflow.js +6 -1
- package/dist/services/conversation/conversation-admission-workflow.js.map +1 -1
- package/dist/services/conversation/conversation-decoder.d.ts.map +1 -1
- package/dist/services/conversation/conversation-decoder.js +4 -0
- package/dist/services/conversation/conversation-decoder.js.map +1 -1
- package/dist/services/conversation/conversation-events.d.ts +97 -3
- package/dist/services/conversation/conversation-events.d.ts.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.d.ts +14 -1
- package/dist/services/conversation/conversation-orchestrator.d.ts.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.js +245 -22
- package/dist/services/conversation/conversation-orchestrator.js.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.types.d.ts +6 -1
- package/dist/services/conversation/conversation-orchestrator.types.d.ts.map +1 -1
- package/dist/services/conversation/conversation-persistence.d.ts +60 -3
- package/dist/services/conversation/conversation-persistence.d.ts.map +1 -1
- package/dist/services/conversation/conversation-persistence.js +221 -16
- package/dist/services/conversation/conversation-persistence.js.map +1 -1
- package/dist/services/conversation/conversation-replay.d.ts.map +1 -1
- package/dist/services/conversation/conversation-replay.js +27 -0
- package/dist/services/conversation/conversation-replay.js.map +1 -1
- package/dist/services/conversation/conversation-result-builder.d.ts +6 -2
- package/dist/services/conversation/conversation-result-builder.d.ts.map +1 -1
- package/dist/services/conversation/conversation-result-builder.js +60 -1
- package/dist/services/conversation/conversation-result-builder.js.map +1 -1
- package/dist/services/conversation/conversation-runtime-factory.d.ts +9 -1
- package/dist/services/conversation/conversation-runtime-factory.d.ts.map +1 -1
- package/dist/services/conversation/conversation-runtime-factory.js +5 -1
- package/dist/services/conversation/conversation-runtime-factory.js.map +1 -1
- package/dist/services/conversation/conversation-service.d.ts +32 -3
- package/dist/services/conversation/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation/conversation-service.js +122 -32
- package/dist/services/conversation/conversation-service.js.map +1 -1
- package/dist/services/conversation/conversation-state-projector.d.ts +2 -1
- package/dist/services/conversation/conversation-state-projector.d.ts.map +1 -1
- package/dist/services/conversation/conversation-state-projector.js +31 -3
- package/dist/services/conversation/conversation-state-projector.js.map +1 -1
- package/dist/services/conversation/run-item-normalizer.d.ts.map +1 -1
- package/dist/services/conversation/run-item-normalizer.js +24 -1
- package/dist/services/conversation/run-item-normalizer.js.map +1 -1
- package/dist/services/conversation/session-audit.d.ts +70 -0
- package/dist/services/conversation/session-audit.d.ts.map +1 -0
- package/dist/services/conversation/session-audit.js +164 -0
- package/dist/services/conversation/session-audit.js.map +1 -0
- package/dist/services/conversation/session-browser.d.ts +46 -0
- package/dist/services/conversation/session-browser.d.ts.map +1 -0
- package/dist/services/conversation/session-browser.js +380 -0
- package/dist/services/conversation/session-browser.js.map +1 -0
- package/dist/services/conversation-agent-client.d.ts +21 -2
- package/dist/services/conversation-agent-client.d.ts.map +1 -1
- package/dist/services/cost/model-cost.d.ts +13 -1
- package/dist/services/cost/model-cost.d.ts.map +1 -1
- package/dist/services/cost/model-cost.js +59 -0
- package/dist/services/cost/model-cost.js.map +1 -1
- package/dist/services/cost/subscription-providers.d.ts +2 -0
- package/dist/services/cost/subscription-providers.d.ts.map +1 -0
- package/dist/services/cost/subscription-providers.js +14 -0
- package/dist/services/cost/subscription-providers.js.map +1 -0
- package/dist/services/grok/grok-credit-usage-service.d.ts +62 -0
- package/dist/services/grok/grok-credit-usage-service.d.ts.map +1 -0
- package/dist/services/grok/grok-credit-usage-service.js +137 -0
- package/dist/services/grok/grok-credit-usage-service.js.map +1 -0
- package/dist/services/history-service.d.ts +9 -0
- package/dist/services/history-service.d.ts.map +1 -1
- package/dist/services/history-service.js +49 -2
- package/dist/services/history-service.js.map +1 -1
- package/dist/services/hooks/hook-composition.d.ts +17 -0
- package/dist/services/hooks/hook-composition.d.ts.map +1 -0
- package/dist/services/hooks/hook-composition.js +19 -0
- package/dist/services/hooks/hook-composition.js.map +1 -0
- package/dist/services/input-surge-approval.d.ts +21 -0
- package/dist/services/input-surge-approval.d.ts.map +1 -0
- package/dist/services/input-surge-approval.js +42 -0
- package/dist/services/input-surge-approval.js.map +1 -0
- package/dist/services/large-uncached-input-guard.js +4 -4
- package/dist/services/large-uncached-input-guard.js.map +1 -1
- package/dist/services/logging/assistant-turn-journal.d.ts +15 -0
- package/dist/services/logging/assistant-turn-journal.d.ts.map +1 -1
- package/dist/services/logging/assistant-turn-journal.js +27 -0
- package/dist/services/logging/assistant-turn-journal.js.map +1 -1
- package/dist/services/logging/conversation-log-events.d.ts +35 -1
- package/dist/services/logging/conversation-log-events.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.js +17 -0
- package/dist/services/logging/conversation-log-events.js.map +1 -1
- package/dist/services/logging/conversation-log-writer.d.ts +8 -1
- package/dist/services/logging/conversation-log-writer.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-writer.js +145 -10
- package/dist/services/logging/conversation-log-writer.js.map +1 -1
- package/dist/services/logging/conversation-logger.d.ts.map +1 -1
- package/dist/services/logging/conversation-logger.js +18 -0
- package/dist/services/logging/conversation-logger.js.map +1 -1
- package/dist/services/logging/logging-service.d.ts +6 -6
- package/dist/services/logging/logging-service.d.ts.map +1 -1
- package/dist/services/logging/logging-service.js.map +1 -1
- package/dist/services/logging/provider-traffic.d.ts +17 -1
- package/dist/services/logging/provider-traffic.d.ts.map +1 -1
- package/dist/services/logging/provider-traffic.js +283 -139
- package/dist/services/logging/provider-traffic.js.map +1 -1
- package/dist/services/memory/memory-capabilities.d.ts.map +1 -1
- package/dist/services/memory/memory-capabilities.js +22 -3
- package/dist/services/memory/memory-capabilities.js.map +1 -1
- package/dist/services/memory/memory-search.d.ts +16 -0
- package/dist/services/memory/memory-search.d.ts.map +1 -0
- package/dist/services/memory/memory-search.js +55 -0
- package/dist/services/memory/memory-search.js.map +1 -0
- package/dist/services/memory/memory-store.d.ts +12 -0
- package/dist/services/memory/memory-store.d.ts.map +1 -1
- package/dist/services/memory/memory-store.js +14 -35
- package/dist/services/memory/memory-store.js.map +1 -1
- package/dist/services/mode-notices.d.ts +12 -6
- package/dist/services/mode-notices.d.ts.map +1 -1
- package/dist/services/mode-notices.js +51 -4
- package/dist/services/mode-notices.js.map +1 -1
- package/dist/services/model-service.d.ts +2 -2
- package/dist/services/model-service.d.ts.map +1 -1
- package/dist/services/model-service.js.map +1 -1
- package/dist/services/queue/queue-controller.d.ts +14 -1
- package/dist/services/queue/queue-controller.d.ts.map +1 -1
- package/dist/services/queue/queue-controller.js +51 -6
- package/dist/services/queue/queue-controller.js.map +1 -1
- package/dist/services/retry/chain-recovery-fingerprint.d.ts +10 -0
- package/dist/services/retry/chain-recovery-fingerprint.d.ts.map +1 -0
- package/dist/services/retry/chain-recovery-fingerprint.js +23 -0
- package/dist/services/retry/chain-recovery-fingerprint.js.map +1 -0
- package/dist/services/retry/in-loop-model-retry.d.ts +12 -0
- package/dist/services/retry/in-loop-model-retry.d.ts.map +1 -0
- package/dist/services/retry/in-loop-model-retry.js +115 -0
- package/dist/services/retry/in-loop-model-retry.js.map +1 -0
- package/dist/services/retry/recovery-executor.d.ts.map +1 -1
- package/dist/services/retry/recovery-executor.js +2 -0
- package/dist/services/retry/recovery-executor.js.map +1 -1
- package/dist/services/retry/recovery-policy.d.ts.map +1 -1
- package/dist/services/retry/recovery-policy.js +4 -0
- package/dist/services/retry/recovery-policy.js.map +1 -1
- package/dist/services/retry/retry-classifier.d.ts.map +1 -1
- package/dist/services/retry/retry-classifier.js +42 -4
- package/dist/services/retry/retry-classifier.js.map +1 -1
- package/dist/services/retry/retry-contracts.d.ts +14 -0
- package/dist/services/retry/retry-contracts.d.ts.map +1 -1
- package/dist/services/retry/retry-error-classification.d.ts +17 -3
- package/dist/services/retry/retry-error-classification.d.ts.map +1 -1
- package/dist/services/retry/retry-error-classification.js +58 -13
- package/dist/services/retry/retry-error-classification.js.map +1 -1
- package/dist/services/retry/retry-errors.d.ts +4 -0
- package/dist/services/retry/retry-errors.d.ts.map +1 -1
- package/dist/services/retry/retry-errors.js +7 -0
- package/dist/services/retry/retry-errors.js.map +1 -1
- package/dist/services/retry/retry-event-presenter.d.ts.map +1 -1
- package/dist/services/retry/retry-event-presenter.js +20 -0
- package/dist/services/retry/retry-event-presenter.js.map +1 -1
- package/dist/services/retry/upstream-retry-policy.d.ts.map +1 -1
- package/dist/services/retry/upstream-retry-policy.js +40 -7
- package/dist/services/retry/upstream-retry-policy.js.map +1 -1
- package/dist/services/runtime-setting-router.d.ts.map +1 -1
- package/dist/services/runtime-setting-router.js +13 -2
- package/dist/services/runtime-setting-router.js.map +1 -1
- package/dist/services/service-interfaces.d.ts +96 -13
- package/dist/services/service-interfaces.d.ts.map +1 -1
- package/dist/services/session/background-check-in-scheduler.d.ts +44 -0
- package/dist/services/session/background-check-in-scheduler.d.ts.map +1 -0
- package/dist/services/session/background-check-in-scheduler.js +88 -0
- package/dist/services/session/background-check-in-scheduler.js.map +1 -0
- package/dist/services/session/background-task-control.d.ts +6 -0
- package/dist/services/session/background-task-control.d.ts.map +1 -1
- package/dist/services/session/background-task-control.js +35 -7
- package/dist/services/session/background-task-control.js.map +1 -1
- package/dist/services/session/background-task-liveness.d.ts +2 -18
- package/dist/services/session/background-task-liveness.d.ts.map +1 -1
- package/dist/services/session/background-task-liveness.js +7 -22
- package/dist/services/session/background-task-liveness.js.map +1 -1
- package/dist/services/session/continuation-plan-applier.d.ts.map +1 -1
- package/dist/services/session/continuation-plan-applier.js +23 -0
- package/dist/services/session/continuation-plan-applier.js.map +1 -1
- package/dist/services/session/continuation-recovery-handler.d.ts +2 -0
- package/dist/services/session/continuation-recovery-handler.d.ts.map +1 -1
- package/dist/services/session/continuation-recovery-handler.js +7 -1
- package/dist/services/session/continuation-recovery-handler.js.map +1 -1
- package/dist/services/session/initial-input-preparer.d.ts +2 -1
- package/dist/services/session/initial-input-preparer.d.ts.map +1 -1
- package/dist/services/session/initial-input-preparer.js +3 -1
- package/dist/services/session/initial-input-preparer.js.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.d.ts +1 -0
- package/dist/services/session/initial-turn-recovery-handler.d.ts.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.js +12 -2
- package/dist/services/session/initial-turn-recovery-handler.js.map +1 -1
- package/dist/services/session/repetition-detector.d.ts +0 -4
- package/dist/services/session/repetition-detector.d.ts.map +1 -1
- package/dist/services/session/repetition-detector.js +0 -7
- package/dist/services/session/repetition-detector.js.map +1 -1
- package/dist/services/session/session-client-factory.d.ts +3 -1
- package/dist/services/session/session-client-factory.d.ts.map +1 -1
- package/dist/services/session/session-client-factory.js +2 -2
- package/dist/services/session/session-client-factory.js.map +1 -1
- package/dist/services/session/session-composition.d.ts +9 -2
- package/dist/services/session/session-composition.d.ts.map +1 -1
- package/dist/services/session/session-composition.js +151 -37
- package/dist/services/session/session-composition.js.map +1 -1
- package/dist/services/session/session-lifecycle.d.ts +8 -0
- package/dist/services/session/session-lifecycle.d.ts.map +1 -1
- package/dist/services/session/session-lifecycle.js +4 -0
- package/dist/services/session/session-lifecycle.js.map +1 -1
- package/dist/services/session/session-stream-processor.d.ts +2 -0
- package/dist/services/session/session-stream-processor.d.ts.map +1 -1
- package/dist/services/session/session-stream-processor.js +9 -15
- package/dist/services/session/session-stream-processor.js.map +1 -1
- package/dist/services/session/terminal-result-collector.d.ts +2 -2
- package/dist/services/session/terminal-result-collector.d.ts.map +1 -1
- package/dist/services/session/terminal-result-collector.js +2 -1
- package/dist/services/session/terminal-result-collector.js.map +1 -1
- package/dist/services/session/turn-attempt-factory.d.ts +3 -1
- package/dist/services/session/turn-attempt-factory.d.ts.map +1 -1
- package/dist/services/session/turn-attempt-factory.js +1 -0
- package/dist/services/session/turn-attempt-factory.js.map +1 -1
- package/dist/services/session/turn-attempt.d.ts +3 -0
- package/dist/services/session/turn-attempt.d.ts.map +1 -1
- package/dist/services/session/turn-attempt.js +5 -0
- package/dist/services/session/turn-attempt.js.map +1 -1
- package/dist/services/session/turn-coordinator.d.ts +2 -2
- package/dist/services/session/turn-coordinator.d.ts.map +1 -1
- package/dist/services/session/turn-coordinator.js +31 -6
- package/dist/services/session/turn-coordinator.js.map +1 -1
- package/dist/services/session/turn-workflow.d.ts +4 -1
- package/dist/services/session/turn-workflow.d.ts.map +1 -1
- package/dist/services/session/turn-workflow.js +52 -8
- package/dist/services/session/turn-workflow.js.map +1 -1
- package/dist/services/settings/settings-persistence.d.ts +33 -0
- package/dist/services/settings/settings-persistence.d.ts.map +1 -1
- package/dist/services/settings/settings-persistence.js +102 -4
- package/dist/services/settings/settings-persistence.js.map +1 -1
- package/dist/services/settings/settings-schema.d.ts +92 -0
- package/dist/services/settings/settings-schema.d.ts.map +1 -1
- package/dist/services/settings/settings-schema.js +119 -9
- package/dist/services/settings/settings-schema.js.map +1 -1
- package/dist/services/settings/settings-service.d.ts +66 -3
- package/dist/services/settings/settings-service.d.ts.map +1 -1
- package/dist/services/settings/settings-service.js +211 -28
- package/dist/services/settings/settings-service.js.map +1 -1
- package/dist/services/settings/settings-service.mock.d.ts +1 -1
- package/dist/services/settings/settings-service.mock.d.ts.map +1 -1
- package/dist/services/settings/settings-service.mock.js +3 -6
- package/dist/services/settings/settings-service.mock.js.map +1 -1
- package/dist/services/settings/settings-sources.d.ts.map +1 -1
- package/dist/services/settings/settings-sources.js +21 -0
- package/dist/services/settings/settings-sources.js.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts +28 -0
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts.map +1 -0
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js +171 -0
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js.map +1 -0
- package/dist/services/shell/background-shell-registry.d.ts +10 -0
- package/dist/services/shell/background-shell-registry.d.ts.map +1 -1
- package/dist/services/shell/background-shell-registry.js +9 -1
- package/dist/services/shell/background-shell-registry.js.map +1 -1
- package/dist/services/shell/background-shell-watches.d.ts +28 -3
- package/dist/services/shell/background-shell-watches.d.ts.map +1 -1
- package/dist/services/shell/background-shell-watches.js +41 -9
- package/dist/services/shell/background-shell-watches.js.map +1 -1
- package/dist/services/shell/shell-interaction-session.d.ts +4 -5
- package/dist/services/shell/shell-interaction-session.d.ts.map +1 -1
- package/dist/services/shell/shell-interaction-session.js +8 -20
- package/dist/services/shell/shell-interaction-session.js.map +1 -1
- package/dist/services/ssh-service.d.ts +81 -9
- package/dist/services/ssh-service.d.ts.map +1 -1
- package/dist/services/ssh-service.js +211 -37
- package/dist/services/ssh-service.js.map +1 -1
- package/dist/services/stream-event-processor.d.ts +2 -0
- package/dist/services/stream-event-processor.d.ts.map +1 -1
- package/dist/services/stream-event-processor.js +32 -7
- package/dist/services/stream-event-processor.js.map +1 -1
- package/dist/services/subagents/execution-runner.d.ts +1 -1
- package/dist/services/subagents/execution-runner.d.ts.map +1 -1
- package/dist/services/subagents/execution-runner.js +34 -22
- package/dist/services/subagents/execution-runner.js.map +1 -1
- package/dist/services/subagents/foreground-subagent-lease.d.ts +11 -1
- package/dist/services/subagents/foreground-subagent-lease.d.ts.map +1 -1
- package/dist/services/subagents/foreground-subagent-lease.js +10 -1
- package/dist/services/subagents/foreground-subagent-lease.js.map +1 -1
- package/dist/services/subagents/mentor-runner.d.ts +1 -1
- package/dist/services/subagents/mentor-runner.d.ts.map +1 -1
- package/dist/services/subagents/mentor-runner.js +12 -3
- package/dist/services/subagents/mentor-runner.js.map +1 -1
- package/dist/services/subagents/nested-runner.d.ts +11 -1
- package/dist/services/subagents/nested-runner.d.ts.map +1 -1
- package/dist/services/subagents/nested-runner.js +79 -11
- package/dist/services/subagents/nested-runner.js.map +1 -1
- package/dist/services/subagents/runtime.d.ts.map +1 -1
- package/dist/services/subagents/runtime.js +7 -0
- package/dist/services/subagents/runtime.js.map +1 -1
- package/dist/services/subagents/subagent-async-registry.d.ts +4 -0
- package/dist/services/subagents/subagent-async-registry.d.ts.map +1 -1
- package/dist/services/subagents/subagent-async-registry.js +81 -17
- package/dist/services/subagents/subagent-async-registry.js.map +1 -1
- package/dist/services/subagents/subagent-manager.d.ts +1 -1
- package/dist/services/subagents/subagent-manager.d.ts.map +1 -1
- package/dist/services/subagents/subagent-manager.js +4 -4
- package/dist/services/subagents/subagent-manager.js.map +1 -1
- package/dist/services/subagents/subagent-notification-store.d.ts +47 -2
- package/dist/services/subagents/subagent-notification-store.d.ts.map +1 -1
- package/dist/services/subagents/subagent-notification-store.js +33 -0
- package/dist/services/subagents/subagent-notification-store.js.map +1 -1
- package/dist/services/subagents/subagent-run-control.d.ts +9 -1
- package/dist/services/subagents/subagent-run-control.d.ts.map +1 -1
- package/dist/services/subagents/subagent-run-control.js +12 -13
- package/dist/services/subagents/subagent-run-control.js.map +1 -1
- package/dist/services/subagents/tool-policy.d.ts.map +1 -1
- package/dist/services/subagents/tool-policy.js +20 -7
- package/dist/services/subagents/tool-policy.js.map +1 -1
- package/dist/services/subagents/types.d.ts +25 -2
- package/dist/services/subagents/types.d.ts.map +1 -1
- package/dist/services/subagents/types.js.map +1 -1
- package/dist/services/subagents/utils.d.ts +5 -1
- package/dist/services/subagents/utils.d.ts.map +1 -1
- package/dist/services/subagents/utils.js +33 -2
- package/dist/services/subagents/utils.js.map +1 -1
- package/dist/services/tool-execution-ledger.d.ts.map +1 -1
- package/dist/services/tool-execution-ledger.js +5 -1
- package/dist/services/tool-execution-ledger.js.map +1 -1
- package/dist/services/workspace/active-workspace-root.d.ts +6 -0
- package/dist/services/workspace/active-workspace-root.d.ts.map +1 -1
- package/dist/services/workspace/active-workspace-root.js +22 -0
- package/dist/services/workspace/active-workspace-root.js.map +1 -1
- package/dist/test-helpers/ink-testing.d.ts.map +1 -1
- package/dist/test-helpers/ink-testing.js +4 -1
- package/dist/test-helpers/ink-testing.js.map +1 -1
- package/dist/test-helpers/terminal-e2e.d.ts.map +1 -1
- package/dist/test-helpers/terminal-e2e.js +12 -2
- package/dist/test-helpers/terminal-e2e.js.map +1 -1
- package/dist/tools/agent/activate-skill.d.ts.map +1 -1
- package/dist/tools/agent/activate-skill.js +2 -2
- package/dist/tools/agent/activate-skill.js.map +1 -1
- package/dist/tools/agent/ask-mentor.d.ts.map +1 -1
- package/dist/tools/agent/ask-mentor.js +2 -2
- package/dist/tools/agent/ask-mentor.js.map +1 -1
- package/dist/tools/agent/ask-user-constants.d.ts +2 -2
- package/dist/tools/agent/ask-user-constants.d.ts.map +1 -1
- package/dist/tools/agent/ask-user-constants.js +1 -1
- package/dist/tools/agent/ask-user-constants.js.map +1 -1
- package/dist/tools/agent/ask-user.d.ts.map +1 -1
- package/dist/tools/agent/ask-user.js +2 -0
- package/dist/tools/agent/ask-user.js.map +1 -1
- package/dist/tools/agent/run-subagent-async.d.ts +2 -11
- package/dist/tools/agent/run-subagent-async.d.ts.map +1 -1
- package/dist/tools/agent/run-subagent-async.js +8 -2
- package/dist/tools/agent/run-subagent-async.js.map +1 -1
- package/dist/tools/agent/run-subagent.d.ts.map +1 -1
- package/dist/tools/agent/run-subagent.js +44 -29
- package/dist/tools/agent/run-subagent.js.map +1 -1
- package/dist/tools/file/apply-patch.d.ts +2 -0
- package/dist/tools/file/apply-patch.d.ts.map +1 -1
- package/dist/tools/file/apply-patch.js +58 -14
- package/dist/tools/file/apply-patch.js.map +1 -1
- package/dist/tools/file/code-context.d.ts +5 -0
- package/dist/tools/file/code-context.d.ts.map +1 -1
- package/dist/tools/file/code-context.js +18 -6
- package/dist/tools/file/code-context.js.map +1 -1
- package/dist/tools/file/create-file.d.ts.map +1 -1
- package/dist/tools/file/create-file.js +11 -5
- package/dist/tools/file/create-file.js.map +1 -1
- package/dist/tools/file/edit-healing.d.ts +7 -0
- package/dist/tools/file/edit-healing.d.ts.map +1 -1
- package/dist/tools/file/edit-healing.js +7 -7
- package/dist/tools/file/edit-healing.js.map +1 -1
- package/dist/tools/file/glob.d.ts +3 -0
- package/dist/tools/file/glob.d.ts.map +1 -1
- package/dist/tools/file/glob.js +9 -3
- package/dist/tools/file/glob.js.map +1 -1
- package/dist/tools/file/grep.d.ts +5 -0
- package/dist/tools/file/grep.d.ts.map +1 -1
- package/dist/tools/file/grep.js +10 -6
- package/dist/tools/file/grep.js.map +1 -1
- package/dist/tools/file/patch-healing.d.ts +31 -0
- package/dist/tools/file/patch-healing.d.ts.map +1 -0
- package/dist/tools/file/patch-healing.js +231 -0
- package/dist/tools/file/patch-healing.js.map +1 -0
- package/dist/tools/file/read-file.d.ts +3 -0
- package/dist/tools/file/read-file.d.ts.map +1 -1
- package/dist/tools/file/read-file.js +9 -3
- package/dist/tools/file/read-file.js.map +1 -1
- package/dist/tools/file/search-replace.d.ts.map +1 -1
- package/dist/tools/file/search-replace.js +24 -6
- package/dist/tools/file/search-replace.js.map +1 -1
- package/dist/tools/format-helpers.d.ts +6 -0
- package/dist/tools/format-helpers.d.ts.map +1 -1
- package/dist/tools/format-helpers.js +23 -0
- package/dist/tools/format-helpers.js.map +1 -1
- package/dist/tools/memory/memory-tools.d.ts.map +1 -1
- package/dist/tools/memory/memory-tools.js +324 -61
- package/dist/tools/memory/memory-tools.js.map +1 -1
- package/dist/tools/session-browser/session-browser-tools.d.ts +4 -0
- package/dist/tools/session-browser/session-browser-tools.d.ts.map +1 -0
- package/dist/tools/session-browser/session-browser-tools.js +47 -0
- package/dist/tools/session-browser/session-browser-tools.js.map +1 -0
- package/dist/tools/system/shell.d.ts +16 -1
- package/dist/tools/system/shell.d.ts.map +1 -1
- package/dist/tools/system/shell.js +97 -25
- package/dist/tools/system/shell.js.map +1 -1
- package/dist/tools/types.d.ts +8 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/web/web-fetch.d.ts.map +1 -1
- package/dist/tools/web/web-fetch.js +2 -2
- package/dist/tools/web/web-fetch.js.map +1 -1
- package/dist/tools/web/web-search.d.ts.map +1 -1
- package/dist/tools/web/web-search.js +2 -2
- package/dist/tools/web/web-search.js.map +1 -1
- package/dist/types/message.d.ts +1 -1
- package/dist/types/message.d.ts.map +1 -1
- package/dist/utils/ai/provider-credentials.d.ts +1 -1
- package/dist/utils/ai/provider-credentials.d.ts.map +1 -1
- package/dist/utils/ai/provider-credentials.js +18 -2
- package/dist/utils/ai/provider-credentials.js.map +1 -1
- package/dist/utils/ai/token-usage.d.ts +3 -1
- package/dist/utils/ai/token-usage.d.ts.map +1 -1
- package/dist/utils/ai/token-usage.js +7 -2
- package/dist/utils/ai/token-usage.js.map +1 -1
- package/dist/utils/apply-diff.d.ts.map +1 -1
- package/dist/utils/apply-diff.js +8 -0
- package/dist/utils/apply-diff.js.map +1 -1
- package/dist/utils/busy-turn-guard.d.ts +17 -0
- package/dist/utils/busy-turn-guard.d.ts.map +1 -0
- package/dist/utils/busy-turn-guard.js +24 -0
- package/dist/utils/busy-turn-guard.js.map +1 -0
- package/dist/utils/conversation/conversation-event-handler.d.ts.map +1 -1
- package/dist/utils/conversation/conversation-event-handler.js +88 -9
- package/dist/utils/conversation/conversation-event-handler.js.map +1 -1
- package/dist/utils/error-helpers.d.ts.map +1 -1
- package/dist/utils/error-helpers.js +8 -0
- package/dist/utils/error-helpers.js.map +1 -1
- package/dist/utils/inject-warning-into-tool-output.d.ts +30 -0
- package/dist/utils/inject-warning-into-tool-output.d.ts.map +1 -1
- package/dist/utils/inject-warning-into-tool-output.js +39 -0
- package/dist/utils/inject-warning-into-tool-output.js.map +1 -1
- package/dist/utils/output/bounded-json.d.ts +33 -0
- package/dist/utils/output/bounded-json.d.ts.map +1 -0
- package/dist/utils/output/bounded-json.js +59 -0
- package/dist/utils/output/bounded-json.js.map +1 -0
- package/dist/utils/output/output-trim.d.ts.map +1 -1
- package/dist/utils/output/output-trim.js +7 -7
- package/dist/utils/output/output-trim.js.map +1 -1
- package/dist/utils/output/text-snippet.d.ts +6 -0
- package/dist/utils/output/text-snippet.d.ts.map +1 -0
- package/dist/utils/output/text-snippet.js +106 -0
- package/dist/utils/output/text-snippet.js.map +1 -0
- package/dist/utils/output/tty-osc.d.ts +1 -1
- package/dist/utils/output/tty-osc.js +1 -1
- package/dist/utils/resume-list.d.ts +3 -1
- package/dist/utils/resume-list.d.ts.map +1 -1
- package/dist/utils/resume-list.js +3 -2
- package/dist/utils/resume-list.js.map +1 -1
- package/dist/utils/settings-command.d.ts.map +1 -1
- package/dist/utils/settings-command.js +120 -6
- package/dist/utils/settings-command.js.map +1 -1
- package/dist/utils/shell/execute-shell.d.ts +8 -0
- package/dist/utils/shell/execute-shell.d.ts.map +1 -1
- package/dist/utils/shell/execute-shell.js +36 -30
- package/dist/utils/shell/execute-shell.js.map +1 -1
- package/dist/utils/shell/sandbox/sandbox-env.d.ts +1 -0
- package/dist/utils/shell/sandbox/sandbox-env.d.ts.map +1 -1
- package/dist/utils/shell/sandbox/sandbox-env.js +2 -0
- package/dist/utils/shell/sandbox/sandbox-env.js.map +1 -1
- package/dist/utils/shell/sandbox/sandbox-policy.d.ts +4 -0
- package/dist/utils/shell/sandbox/sandbox-policy.d.ts.map +1 -1
- package/dist/utils/shell/sandbox/sandbox-policy.js +1 -1
- package/dist/utils/shell/sandbox/sandbox-policy.js.map +1 -1
- package/dist/utils/shell/sandbox/shell-sandbox-runner.d.ts +1 -0
- package/dist/utils/shell/sandbox/shell-sandbox-runner.d.ts.map +1 -1
- package/dist/utils/shell/sandbox/shell-sandbox-runner.js +21 -3
- package/dist/utils/shell/sandbox/shell-sandbox-runner.js.map +1 -1
- package/dist/utils/shell/shell-child-registry.d.ts +11 -0
- package/dist/utils/shell/shell-child-registry.d.ts.map +1 -0
- package/dist/utils/shell/shell-child-registry.js +40 -0
- package/dist/utils/shell/shell-child-registry.js.map +1 -0
- package/dist/utils/shell/shell-output.d.ts.map +1 -1
- package/dist/utils/shell/shell-output.js +10 -6
- package/dist/utils/shell/shell-output.js.map +1 -1
- package/dist/utils/shell/temp-sweep.d.ts +28 -0
- package/dist/utils/shell/temp-sweep.d.ts.map +1 -0
- package/dist/utils/shell/temp-sweep.js +140 -0
- package/dist/utils/shell/temp-sweep.js.map +1 -0
- package/dist/utils/streaming/extract-command-messages.d.ts +12 -5
- package/dist/utils/streaming/extract-command-messages.d.ts.map +1 -1
- package/dist/utils/streaming/extract-command-messages.js +29 -33
- package/dist/utils/streaming/extract-command-messages.js.map +1 -1
- package/dist/utils/streaming/streaming-session-factory.d.ts +8 -0
- package/dist/utils/streaming/streaming-session-factory.d.ts.map +1 -1
- package/dist/utils/streaming/streaming-session-factory.js +3 -0
- package/dist/utils/streaming/streaming-session-factory.js.map +1 -1
- package/dist/utils/value-suggestions.d.ts +8 -0
- package/dist/utils/value-suggestions.d.ts.map +1 -1
- package/dist/utils/value-suggestions.js +72 -0
- package/dist/utils/value-suggestions.js.map +1 -1
- package/package.json +17 -11
- package/dist/utils/output/synchronized-output.d.ts +0 -35
- package/dist/utils/output/synchronized-output.d.ts.map +0 -1
- package/dist/utils/output/synchronized-output.js +0 -66
- package/dist/utils/output/synchronized-output.js.map +0 -1
|
@@ -5,13 +5,16 @@ import { isZodToolParameterSchema } from '../../tools/types.js';
|
|
|
5
5
|
import { normalizeToolParameters } from '../../lib/tool-invoke.js';
|
|
6
6
|
import { isCancellationError, isHarnessInvariantError } from '../../lib/harness-invariant-error.js';
|
|
7
7
|
import { ApprovalLedger } from './tool-invocation-context.js';
|
|
8
|
+
import { RunBudget, isRunBudgetInteraction, } from './run-budget.js';
|
|
8
9
|
import { addTokenUsage, normalizeUsage } from '../../utils/ai/token-usage.js';
|
|
9
10
|
import { computeModelCost } from '../../services/cost/model-cost.js';
|
|
10
11
|
import { getCatalogPricingVersion, getModelPricing } from '../../services/cost/pricing.js';
|
|
11
|
-
import {
|
|
12
|
+
import { GenerationGuard, GenerationGuardError, GenerationStreamDeadlines, } from './generation-guard.js';
|
|
13
|
+
import { classifyInLoopModelRetry, sleepWithAbort } from '../retry/in-loop-model-retry.js';
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
14
|
-
* — the SDK-era `callModelInputFilter` hook is deliberately
|
|
15
|
+
* Compatibility error for legacy callers without a staged run budget. The loop
|
|
16
|
+
* owns turn counting — the SDK-era `callModelInputFilter` hook is deliberately
|
|
17
|
+
* not reintroduced.
|
|
15
18
|
*/
|
|
16
19
|
export class MaxTurnsExceededError extends Error {
|
|
17
20
|
maxTurns;
|
|
@@ -66,7 +69,7 @@ class EventQueue {
|
|
|
66
69
|
*/
|
|
67
70
|
let nextCostRequestSeq = 0;
|
|
68
71
|
let nextToolBatchSeq = 0;
|
|
69
|
-
const DEFAULT_MAX_PARALLEL_TOOL_CALLS =
|
|
72
|
+
const DEFAULT_MAX_PARALLEL_TOOL_CALLS = 3;
|
|
70
73
|
/**
|
|
71
74
|
* Small provider-neutral agent loop. It owns model-turn sequencing and tool
|
|
72
75
|
* execution; providers only implement `StreamedModelTurn`.
|
|
@@ -74,7 +77,6 @@ const DEFAULT_MAX_PARALLEL_TOOL_CALLS = 4;
|
|
|
74
77
|
export class ApplicationRunLoop {
|
|
75
78
|
#deps;
|
|
76
79
|
#contextCompactionSessionState;
|
|
77
|
-
#maxParallelToolCalls;
|
|
78
80
|
#activeAbortController = null;
|
|
79
81
|
#runInFlight = false;
|
|
80
82
|
#segmentGeneration = 0;
|
|
@@ -97,10 +99,11 @@ export class ApplicationRunLoop {
|
|
|
97
99
|
*/
|
|
98
100
|
#turnOpen = false;
|
|
99
101
|
#pendingSteers = [];
|
|
102
|
+
/** The run whose budget an out-of-band grant applies to, held across a pause. */
|
|
103
|
+
#activeRunBudgetState;
|
|
100
104
|
constructor(deps) {
|
|
101
105
|
this.#deps = deps;
|
|
102
106
|
this.#contextCompactionSessionState = deps.contextCompactionSessionState ?? { disabled: false };
|
|
103
|
-
this.#maxParallelToolCalls = Math.max(1, Math.floor(deps.maxParallelToolCalls ?? DEFAULT_MAX_PARALLEL_TOOL_CALLS));
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
106
109
|
* Declare a turn open, making it steerable before its first run exists.
|
|
@@ -139,6 +142,38 @@ export class ApplicationRunLoop {
|
|
|
139
142
|
this.#activeAbortController?.abort();
|
|
140
143
|
this.#activeAbortController = null;
|
|
141
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Grant one finite continuation extension to the current logical run.
|
|
147
|
+
*
|
|
148
|
+
* The interactive prompt calls this before resuming because it has to show
|
|
149
|
+
* the human a refusal rather than a silent stop. The grant is recorded so the
|
|
150
|
+
* matching `approve` does not charge a second one.
|
|
151
|
+
*/
|
|
152
|
+
grantRunBudgetExtension(grantedBy = 'human') {
|
|
153
|
+
const state = this.#activeRunBudgetState;
|
|
154
|
+
if (!state?.runBudget)
|
|
155
|
+
return { granted: false, extensionsGranted: 0 };
|
|
156
|
+
const grant = state.runBudget.grantExtension(grantedBy);
|
|
157
|
+
if (grant.granted)
|
|
158
|
+
state.runBudgetGrantConsumed = true;
|
|
159
|
+
return grant;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Charge this interaction's extension unless a caller already took it.
|
|
163
|
+
*
|
|
164
|
+
* An ungranted arrival here means nobody was prompted — the continuation
|
|
165
|
+
* applier, non-interactive mode, `--auto-approve`. That is a parent-class
|
|
166
|
+
* grant, so it is capped and eventually refuses.
|
|
167
|
+
*/
|
|
168
|
+
#takeRunBudgetGrant(state) {
|
|
169
|
+
if (state.runBudgetGrantConsumed) {
|
|
170
|
+
state.runBudgetGrantConsumed = false;
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
if (!state.runBudget)
|
|
174
|
+
return true;
|
|
175
|
+
return state.runBudget.grantExtension('parent').granted;
|
|
176
|
+
}
|
|
142
177
|
/**
|
|
143
178
|
* Hand the running turn a user message to send with its next model request.
|
|
144
179
|
*
|
|
@@ -255,7 +290,9 @@ export class ApplicationRunLoop {
|
|
|
255
290
|
history: normalizeHistory(input),
|
|
256
291
|
// A response ID is usable only after its provider origin is recorded.
|
|
257
292
|
// This also makes old callers that omit providerId fail closed.
|
|
258
|
-
responseId: options.
|
|
293
|
+
responseId: options.disableChainingForAttempt !== true &&
|
|
294
|
+
options.providerId &&
|
|
295
|
+
options.supportsConversationChaining === true
|
|
259
296
|
? options.previousResponseId ?? undefined
|
|
260
297
|
: undefined,
|
|
261
298
|
pendingApprovals: [],
|
|
@@ -265,6 +302,7 @@ export class ApplicationRunLoop {
|
|
|
265
302
|
? options.providerId
|
|
266
303
|
: undefined,
|
|
267
304
|
requestPreparation: options.requestPreparation,
|
|
305
|
+
disableChainingForAttempt: options.disableChainingForAttempt === true,
|
|
268
306
|
sessionId: options.sessionId,
|
|
269
307
|
turnId: options.turnId,
|
|
270
308
|
hookScope: options.hookScope,
|
|
@@ -272,13 +310,36 @@ export class ApplicationRunLoop {
|
|
|
272
310
|
approvals: options.approvals ?? new ApprovalLedger(),
|
|
273
311
|
turnCount: 0,
|
|
274
312
|
maxTurns: options.maxTurns,
|
|
313
|
+
...(options.runBudget
|
|
314
|
+
? {
|
|
315
|
+
runBudget: new RunBudget(options.runBudget),
|
|
316
|
+
onRunBudgetEvent: options.onRunBudgetEvent,
|
|
317
|
+
wrapUpOnCriticalRunBudget: options.wrapUpOnCriticalRunBudget,
|
|
318
|
+
runBudgetEscalation: options.runBudget.escalation,
|
|
319
|
+
}
|
|
320
|
+
: {}),
|
|
275
321
|
automaticCompactionsThisRun: 0,
|
|
276
322
|
};
|
|
277
323
|
state.approve = (interruption) => {
|
|
324
|
+
if (isRunBudgetInteraction(interruption)) {
|
|
325
|
+
// Continuing past an exhausted envelope must cost a finite extension no
|
|
326
|
+
// matter which surface answered. A caller that already took the grant
|
|
327
|
+
// (the interactive prompt, which needs the outcome before resuming)
|
|
328
|
+
// marks it consumed; every other path — the continuation applier,
|
|
329
|
+
// non-interactive, --auto-approve — lands here ungranted and takes it
|
|
330
|
+
// now. Without this, an auto-approved 'y' would resume with every stage
|
|
331
|
+
// still latched and never check in again.
|
|
332
|
+
state.runBudgetInteractionDecision = this.#takeRunBudgetGrant(state) ? 'continue' : 'stop';
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
278
335
|
state.approvalDecision = 'approved';
|
|
279
336
|
state.approvalDecisionCallId = getInterruptionCallId(interruption);
|
|
280
337
|
};
|
|
281
338
|
state.reject = (interruption, approvalOptions) => {
|
|
339
|
+
if (isRunBudgetInteraction(interruption)) {
|
|
340
|
+
state.runBudgetInteractionDecision = 'stop';
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
282
343
|
state.approvalDecision = 'rejected';
|
|
283
344
|
state.approvalDecisionCallId = getInterruptionCallId(interruption);
|
|
284
345
|
state.approvalMessage = approvalOptions?.message;
|
|
@@ -304,6 +365,15 @@ export class ApplicationRunLoop {
|
|
|
304
365
|
// Handles created before cost accounting existed have no record list.
|
|
305
366
|
if (!state.costRecords)
|
|
306
367
|
state.costRecords = [];
|
|
368
|
+
if (!state.runBudget && options.runBudget) {
|
|
369
|
+
state.runBudget = new RunBudget(options.runBudget);
|
|
370
|
+
}
|
|
371
|
+
if (options.runBudget)
|
|
372
|
+
state.runBudgetEscalation = options.runBudget.escalation;
|
|
373
|
+
if (options.onRunBudgetEvent)
|
|
374
|
+
state.onRunBudgetEvent = options.onRunBudgetEvent;
|
|
375
|
+
if (options.wrapUpOnCriticalRunBudget)
|
|
376
|
+
state.wrapUpOnCriticalRunBudget = true;
|
|
307
377
|
// Response IDs are provider-owned. A handle from before provenance was
|
|
308
378
|
// recorded, a missing providerId, or a provider switch must never forward
|
|
309
379
|
// its opaque ID. In particular, do not use previousResponseId as a
|
|
@@ -342,6 +412,11 @@ export class ApplicationRunLoop {
|
|
|
342
412
|
// root closure for callers that do not provide one again.
|
|
343
413
|
if (options.requestPreparation)
|
|
344
414
|
state.requestPreparation = options.requestPreparation;
|
|
415
|
+
if (options.disableChainingForAttempt === true) {
|
|
416
|
+
state.disableChainingForAttempt = true;
|
|
417
|
+
state.responseId = undefined;
|
|
418
|
+
state.responseProviderId = undefined;
|
|
419
|
+
}
|
|
345
420
|
if (options.sessionId !== undefined)
|
|
346
421
|
state.sessionId = options.sessionId;
|
|
347
422
|
if (options.turnId !== undefined)
|
|
@@ -357,6 +432,7 @@ export class ApplicationRunLoop {
|
|
|
357
432
|
const controller = new AbortController();
|
|
358
433
|
this.#activeAbortController = controller;
|
|
359
434
|
this.#runInFlight = true;
|
|
435
|
+
state.runBudget?.resume();
|
|
360
436
|
// This segment is running, so the turn is no longer paused between them.
|
|
361
437
|
this.#turnPaused = false;
|
|
362
438
|
if (options.signal) {
|
|
@@ -375,6 +451,15 @@ export class ApplicationRunLoop {
|
|
|
375
451
|
get turn() {
|
|
376
452
|
return { count: state.turnCount, max: state.maxTurns };
|
|
377
453
|
},
|
|
454
|
+
get budget() {
|
|
455
|
+
return state.runBudget
|
|
456
|
+
? {
|
|
457
|
+
takeSoftEvidence: () => state.runBudget?.takeSoftEvidence(),
|
|
458
|
+
takeStallEvidence: () => state.runBudget?.takeStallEvidence(),
|
|
459
|
+
remainingPolicy: () => state.runBudget?.remainingPolicy(),
|
|
460
|
+
}
|
|
461
|
+
: undefined;
|
|
462
|
+
},
|
|
378
463
|
};
|
|
379
464
|
const output = [];
|
|
380
465
|
const stream = createAgentStream({
|
|
@@ -404,6 +489,7 @@ export class ApplicationRunLoop {
|
|
|
404
489
|
throw error;
|
|
405
490
|
})
|
|
406
491
|
.finally(() => {
|
|
492
|
+
state.runBudget?.pause();
|
|
407
493
|
if (segmentGeneration !== this.#segmentGeneration)
|
|
408
494
|
return;
|
|
409
495
|
if (this.#activeAbortController === controller)
|
|
@@ -415,10 +501,13 @@ export class ApplicationRunLoop {
|
|
|
415
501
|
// that ends with nothing outstanding has truly finished the turn, and
|
|
416
502
|
// then anything still waiting has to be sent as its own turn instead.
|
|
417
503
|
const pendingApprovals = state.pendingApprovals?.length ?? 0;
|
|
504
|
+
const pendingBudgetInteraction = state.pendingRunBudgetInteraction !== undefined;
|
|
418
505
|
const cancelled = stream.cancelled === true;
|
|
419
|
-
this.#turnPaused = pendingApprovals > 0 && !cancelled && exitError === undefined;
|
|
506
|
+
this.#turnPaused = (pendingApprovals > 0 || pendingBudgetInteraction) && !cancelled && exitError === undefined;
|
|
420
507
|
if (this.#turnPaused)
|
|
421
508
|
return;
|
|
509
|
+
if (this.#activeRunBudgetState === state)
|
|
510
|
+
this.#activeRunBudgetState = undefined;
|
|
422
511
|
// A declared turn outlives its segments — this one may be about to be
|
|
423
512
|
// retried, or resumed past a post-execute gate. Its owner says when it
|
|
424
513
|
// is over.
|
|
@@ -426,17 +515,33 @@ export class ApplicationRunLoop {
|
|
|
426
515
|
return;
|
|
427
516
|
this.#releasePendingSteers({
|
|
428
517
|
pendingApprovals,
|
|
518
|
+
pendingBudgetInteraction,
|
|
429
519
|
cancelled,
|
|
430
520
|
error: exitError instanceof Error ? exitError.name : exitError ? String(exitError) : undefined,
|
|
431
521
|
turnCount: state.turnCount,
|
|
432
522
|
});
|
|
433
523
|
});
|
|
524
|
+
this.#activeRunBudgetState = state.runBudget ? state : undefined;
|
|
434
525
|
return stream;
|
|
435
526
|
}
|
|
436
527
|
async #execute(state, stream, queue, options, toolContext, requestAbortController) {
|
|
437
528
|
while (true) {
|
|
438
529
|
if (options.signal?.aborted)
|
|
439
530
|
throw Object.assign(new Error('Operation aborted'), { name: 'AbortError' });
|
|
531
|
+
if (state.pendingRunBudgetInteraction) {
|
|
532
|
+
if (state.runBudgetInteractionDecision === 'stop') {
|
|
533
|
+
state.pendingRunBudgetInteraction = undefined;
|
|
534
|
+
state.runBudgetInteractionDecision = undefined;
|
|
535
|
+
return finish(stream, state, queue);
|
|
536
|
+
}
|
|
537
|
+
if (state.runBudgetInteractionDecision === 'continue') {
|
|
538
|
+
state.pendingRunBudgetInteraction = undefined;
|
|
539
|
+
state.runBudgetInteractionDecision = undefined;
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
440
545
|
state.pendingApprovals ??= state.pendingApproval ? [state.pendingApproval] : [];
|
|
441
546
|
if (state.pendingApprovals.length > 0 && state.approvalDecision) {
|
|
442
547
|
const selectedIndex = state.approvalDecisionCallId
|
|
@@ -475,184 +580,296 @@ export class ApplicationRunLoop {
|
|
|
475
580
|
if (options.stopAfterApprovalResolution)
|
|
476
581
|
return finish(stream, state, queue);
|
|
477
582
|
}
|
|
583
|
+
// A budget interaction can park a response after its tool calls are
|
|
584
|
+
// recorded but before any body runs. Resume those retained calls only
|
|
585
|
+
// after processing an ordinary approval decision for that same plan.
|
|
586
|
+
if (state.toolPlan) {
|
|
587
|
+
await this.#settleToolPlan(state, stream, queue, toolContext);
|
|
588
|
+
if (state.pendingApprovals?.length) {
|
|
589
|
+
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
590
|
+
this.#turnPaused = true;
|
|
591
|
+
return finish(stream, state, queue);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
478
594
|
// The request boundary: every tool result of the previous round is in
|
|
479
595
|
// history, and the next request has not been built. A user message
|
|
480
596
|
// admitted here reaches the model in sequence, mid-turn.
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
state.responseId = undefined;
|
|
494
|
-
state.responseProviderId = undefined;
|
|
495
|
-
if (compaction.costRecords?.length) {
|
|
496
|
-
state.costRecords ??= [];
|
|
497
|
-
state.costRecords.push(...compaction.costRecords);
|
|
498
|
-
}
|
|
499
|
-
state.automaticCompactionsThisRun = (state.automaticCompactionsThisRun ?? 0) + 1;
|
|
500
|
-
outputPush(stream, queue, {
|
|
501
|
-
type: 'context_compaction_completed',
|
|
502
|
-
provider: state.currentProviderId ?? 'unknown',
|
|
503
|
-
strategy: 'local',
|
|
504
|
-
durationMs: Math.max(0, Date.now() - compactionStartedAt),
|
|
597
|
+
if (!state.requestBoundaryReady) {
|
|
598
|
+
this.#admitPendingSteers(state, stream, queue);
|
|
599
|
+
this.#evaluateRunBudget(state, stream, queue);
|
|
600
|
+
if (state.pendingRunBudgetInteraction)
|
|
601
|
+
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
602
|
+
if (options.boundaryCompaction) {
|
|
603
|
+
const compactionStartedAt = Date.now();
|
|
604
|
+
const compaction = await options.boundaryCompaction.compact({
|
|
605
|
+
history: state.history,
|
|
606
|
+
automaticCompactionsThisRun: state.automaticCompactionsThisRun ?? 0,
|
|
607
|
+
signal: options.signal,
|
|
608
|
+
onStarted: (provider) => outputPush(stream, queue, { type: 'context_compaction_started', provider, strategy: 'local' }),
|
|
505
609
|
});
|
|
610
|
+
if (compaction.kind === 'compacted') {
|
|
611
|
+
state.history.splice(0, state.history.length, ...compaction.history);
|
|
612
|
+
state.input.splice(0, state.input.length, ...normalizeApplicationInput(compaction.modelInput));
|
|
613
|
+
state.responseId = undefined;
|
|
614
|
+
state.responseProviderId = undefined;
|
|
615
|
+
if (compaction.costRecords?.length) {
|
|
616
|
+
state.costRecords ??= [];
|
|
617
|
+
state.costRecords.push(...compaction.costRecords);
|
|
618
|
+
}
|
|
619
|
+
state.automaticCompactionsThisRun = (state.automaticCompactionsThisRun ?? 0) + 1;
|
|
620
|
+
outputPush(stream, queue, {
|
|
621
|
+
type: 'context_compaction_completed',
|
|
622
|
+
provider: state.currentProviderId ?? 'unknown',
|
|
623
|
+
strategy: 'local',
|
|
624
|
+
durationMs: Math.max(0, Date.now() - compactionStartedAt),
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
else if (compaction.kind === 'failed') {
|
|
628
|
+
outputPush(stream, queue, {
|
|
629
|
+
type: 'context_compaction_failed',
|
|
630
|
+
provider: compaction.provider,
|
|
631
|
+
strategy: 'local',
|
|
632
|
+
durationMs: Math.max(0, Date.now() - compactionStartedAt),
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
// Summarization is an asynchronous part of this same request
|
|
636
|
+
// boundary. Admit anything that arrived while it was in flight after
|
|
637
|
+
// applying a replacement, so the steer cannot be overwritten by the
|
|
638
|
+
// checkpoint or miss a terminal model request.
|
|
639
|
+
this.#admitPendingSteers(state, stream, queue);
|
|
640
|
+
this.#evaluateRunBudget(state, stream, queue);
|
|
641
|
+
if (state.pendingRunBudgetInteraction)
|
|
642
|
+
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
506
643
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
644
|
+
state.turnCount += 1;
|
|
645
|
+
this.#evaluateRunBudget(state, stream, queue);
|
|
646
|
+
if (state.pendingRunBudgetInteraction) {
|
|
647
|
+
state.requestBoundaryReady = true;
|
|
648
|
+
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
649
|
+
}
|
|
650
|
+
// Retain the legacy error only for callers that have not adopted staged
|
|
651
|
+
// budgets. A configured run budget turns the same count into critical
|
|
652
|
+
// evidence and lets the decision surface choose what happens next.
|
|
653
|
+
if (!state.runBudget && state.maxTurns !== undefined && state.turnCount > state.maxTurns) {
|
|
654
|
+
throw new MaxTurnsExceededError(state.maxTurns);
|
|
514
655
|
}
|
|
515
|
-
// Summarization is an asynchronous part of this same request
|
|
516
|
-
// boundary. Admit anything that arrived while it was in flight after
|
|
517
|
-
// applying a replacement, so the steer cannot be overwritten by the
|
|
518
|
-
// checkpoint or miss a terminal model request.
|
|
519
|
-
this.#admitPendingSteers(state, stream, queue);
|
|
520
656
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
throw new MaxTurnsExceededError(state.maxTurns);
|
|
657
|
+
else {
|
|
658
|
+
state.requestBoundaryReady = undefined;
|
|
524
659
|
}
|
|
525
660
|
const model = await this.#deps.resolveModel(state.agent.model);
|
|
526
|
-
|
|
527
|
-
|
|
661
|
+
const maxRetries = state.agent.modelSettings?.retry?.maxRetries ?? 0;
|
|
662
|
+
let attempt = 0;
|
|
663
|
+
let streamedToolCalls = [];
|
|
528
664
|
let completion;
|
|
665
|
+
let sawToolCall = false;
|
|
666
|
+
let activeRequestId = '';
|
|
667
|
+
let activeRequest;
|
|
529
668
|
let pendingNativeReasoning;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
:
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
continue;
|
|
588
|
-
}
|
|
589
|
-
if (event.type === 'text_delta') {
|
|
590
|
-
generationGuard.observeText(event.text);
|
|
591
|
-
outputPush(stream, queue, { type: 'text_delta', text: event.text });
|
|
592
|
-
continue;
|
|
593
|
-
}
|
|
594
|
-
if (event.type === 'codex_rate_limits') {
|
|
595
|
-
outputPush(stream, queue, { type: 'codex_rate_limits', rateLimits: event.rateLimits });
|
|
596
|
-
continue;
|
|
669
|
+
let criticalWrapUp = false;
|
|
670
|
+
while (true) {
|
|
671
|
+
streamedToolCalls = [];
|
|
672
|
+
completion = undefined;
|
|
673
|
+
sawToolCall = false;
|
|
674
|
+
pendingNativeReasoning = undefined;
|
|
675
|
+
// Stable process-unique request id, allocated immediately before dispatch
|
|
676
|
+
// so a cost record can be settled exactly once (success or failure).
|
|
677
|
+
activeRequestId = this.#nextRequestId();
|
|
678
|
+
const requestId = activeRequestId;
|
|
679
|
+
const outputLengthBefore = stream.output.length;
|
|
680
|
+
const newItemsLengthBefore = stream.newItems.length;
|
|
681
|
+
const inputLengthBefore = state.input.length;
|
|
682
|
+
const historyLengthBefore = state.history.length;
|
|
683
|
+
const criticalWrapUpDispatchedBefore = state.criticalWrapUpDispatched;
|
|
684
|
+
let provisionalTextCharacters = 0;
|
|
685
|
+
let provisionalReasoningCharacters = 0;
|
|
686
|
+
let provisionalTextDeltas = 0;
|
|
687
|
+
let provisionalReasoningDeltas = 0;
|
|
688
|
+
criticalWrapUp = state.criticalWrapUpPending === true && state.criticalWrapUpDispatched !== true;
|
|
689
|
+
if (criticalWrapUp)
|
|
690
|
+
state.criticalWrapUpDispatched = true;
|
|
691
|
+
const disableChaining = state.disableChainingForAttempt === true;
|
|
692
|
+
if (disableChaining) {
|
|
693
|
+
state.disableChainingForAttempt = false;
|
|
694
|
+
state.responseId = undefined;
|
|
695
|
+
state.responseProviderId = undefined;
|
|
696
|
+
}
|
|
697
|
+
const request = {
|
|
698
|
+
instructions: criticalWrapUp
|
|
699
|
+
? `${state.agent.instructions}\n\nBudget containment is terminal. Do not call tools. In this one final response, summarize what you completed, the evidence you have, and what remains.`
|
|
700
|
+
: state.agent.instructions,
|
|
701
|
+
...(state.supportsConversationChaining &&
|
|
702
|
+
!disableChaining &&
|
|
703
|
+
state.responseId &&
|
|
704
|
+
state.responseProviderId !== undefined &&
|
|
705
|
+
state.responseProviderId === state.currentProviderId
|
|
706
|
+
? { previousResponseId: state.responseId }
|
|
707
|
+
: {}),
|
|
708
|
+
...(disableChaining ? { disableChaining: true } : {}),
|
|
709
|
+
input: state.input,
|
|
710
|
+
tools: toModelTools(criticalWrapUp ? [] : state.agent.tools),
|
|
711
|
+
applicationTools: criticalWrapUp ? [] : state.agent.tools,
|
|
712
|
+
...(state.agent.modelSettings?.temperature !== undefined
|
|
713
|
+
? { temperature: state.agent.modelSettings.temperature }
|
|
714
|
+
: {}),
|
|
715
|
+
...(state.agent.modelSettings?.reasoning ? { reasoning: state.agent.modelSettings.reasoning } : {}),
|
|
716
|
+
...(state.agent.modelSettings?.maxTokens !== undefined
|
|
717
|
+
? { maxTokens: state.agent.modelSettings.maxTokens }
|
|
718
|
+
: {}),
|
|
719
|
+
...(state.agent.outputType !== undefined ? { outputType: state.agent.outputType } : {}),
|
|
720
|
+
...(state.agent.modelSettings?.codex ? { codex: state.agent.modelSettings.codex } : {}),
|
|
721
|
+
...(state.agent.modelSettings?.providerData
|
|
722
|
+
? {
|
|
723
|
+
providerOptions: this.#contextCompactionSessionState.disabled
|
|
724
|
+
? Object.fromEntries(Object.entries(state.agent.modelSettings.providerData).filter(([key]) => key !== 'contextCompaction'))
|
|
725
|
+
: state.agent.modelSettings.providerData,
|
|
597
726
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
727
|
+
: {}),
|
|
728
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
729
|
+
};
|
|
730
|
+
activeRequest = request;
|
|
731
|
+
const generationGuard = new GenerationGuard({
|
|
732
|
+
maxOutputCharacters: state.agent.modelSettings?.maxStreamOutputChars,
|
|
733
|
+
maxTextCharacters: state.agent.modelSettings?.maxStreamOutputChars,
|
|
734
|
+
maxReasoningCharacters: state.agent.modelSettings?.maxStreamOutputChars,
|
|
735
|
+
maxToolArgumentCharacters: state.agent.modelSettings?.maxStreamOutputChars,
|
|
736
|
+
maxCumulativeToolArgumentCharacters: state.agent.modelSettings?.maxStreamOutputChars,
|
|
737
|
+
requestDeadlineMs: state.agent.modelSettings?.maxModelRequestDurationMs,
|
|
738
|
+
maxStreamIdleMs: state.agent.modelSettings?.maxModelStreamIdleMs,
|
|
739
|
+
...options.generationGuard,
|
|
740
|
+
});
|
|
741
|
+
const consume = async () => {
|
|
742
|
+
const deadline = new GenerationStreamDeadlines({ totalMs: generationGuard.requestDeadlineMs, idleMs: generationGuard.maxStreamIdleMs }, () => requestAbortController.abort(), () => generationGuard.progress);
|
|
743
|
+
let iterator;
|
|
744
|
+
let iteratorFinished = false;
|
|
745
|
+
try {
|
|
746
|
+
iterator = model.stream(request)[Symbol.asyncIterator]();
|
|
747
|
+
while (true) {
|
|
748
|
+
const next = await deadline.wait(iterator.next());
|
|
749
|
+
if (next.done) {
|
|
750
|
+
iteratorFinished = true;
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
// Any streamed event is transport activity: re-arm the inactivity
|
|
754
|
+
// window so long legitimate reasoning is never mistaken for a stall.
|
|
755
|
+
deadline.recordActivity();
|
|
756
|
+
const event = next.value;
|
|
757
|
+
if (event.type === 'completion') {
|
|
758
|
+
generationGuard.observeCompletion(event.output);
|
|
759
|
+
completion = event;
|
|
760
|
+
continue;
|
|
761
|
+
}
|
|
762
|
+
if (event.type === 'text_delta') {
|
|
763
|
+
generationGuard.observeText(event.text);
|
|
764
|
+
provisionalTextCharacters += event.text.length;
|
|
765
|
+
provisionalTextDeltas++;
|
|
766
|
+
outputPush(stream, queue, { type: 'text_delta', text: event.text });
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (event.type === 'codex_rate_limits') {
|
|
770
|
+
outputPush(stream, queue, { type: 'codex_rate_limits', rateLimits: event.rateLimits });
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
if (event.type === 'reasoning_delta') {
|
|
774
|
+
const accepted = generationGuard.observeReasoning(event.text);
|
|
775
|
+
if (!accepted)
|
|
776
|
+
continue;
|
|
777
|
+
const forwarded = accepted === event.text ? event : { ...event, text: accepted };
|
|
778
|
+
pendingNativeReasoning = appendNativeReasoning(pendingNativeReasoning, forwarded);
|
|
779
|
+
provisionalReasoningCharacters += accepted.length;
|
|
780
|
+
provisionalReasoningDeltas++;
|
|
781
|
+
outputPush(stream, queue, { type: 'reasoning_delta', text: accepted });
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
if (event.type === 'tool_call_streaming_delta') {
|
|
785
|
+
generationGuard.observeToolArgumentProgress(event.argumentCharCount);
|
|
786
|
+
outputPush(stream, queue, event);
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
if (event.type === 'context_compaction_started' || event.type === 'context_compaction_completed') {
|
|
790
|
+
outputPush(stream, queue, event);
|
|
791
|
+
continue;
|
|
792
|
+
}
|
|
793
|
+
if (event.type === 'tool_call') {
|
|
794
|
+
generationGuard.observeToolCall(event.arguments);
|
|
795
|
+
pendingNativeReasoning = commitPendingNativeReasoning(state, stream, queue, pendingNativeReasoning);
|
|
796
|
+
sawToolCall = true;
|
|
797
|
+
streamedToolCalls.push(event);
|
|
798
|
+
}
|
|
603
799
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
800
|
+
}
|
|
801
|
+
finally {
|
|
802
|
+
deadline.dispose();
|
|
803
|
+
if (iterator && !iteratorFinished)
|
|
804
|
+
void iterator.return?.().catch(() => undefined);
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
const dispatch = async () => {
|
|
808
|
+
state.requestPreparation?.prepare(request);
|
|
809
|
+
await consume();
|
|
810
|
+
};
|
|
811
|
+
try {
|
|
812
|
+
if (state.requestPreparation)
|
|
813
|
+
await state.requestPreparation.run(dispatch);
|
|
814
|
+
else
|
|
815
|
+
await dispatch();
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
catch (error) {
|
|
819
|
+
if (error instanceof GenerationGuardError)
|
|
820
|
+
requestAbortController.abort();
|
|
821
|
+
const decision = classifyInLoopModelRetry(error, attempt, maxRetries);
|
|
822
|
+
if (decision.retryable && !options.signal?.aborted) {
|
|
823
|
+
attempt++;
|
|
824
|
+
state.input.splice(inputLengthBefore);
|
|
825
|
+
state.history.splice(historyLengthBefore);
|
|
826
|
+
state.criticalWrapUpDispatched = criticalWrapUpDispatchedBefore;
|
|
827
|
+
stream.output.splice(outputLengthBefore);
|
|
828
|
+
if (stream.newItems !== stream.output) {
|
|
829
|
+
stream.newItems.splice(newItemsLengthBefore);
|
|
608
830
|
}
|
|
609
|
-
if (
|
|
610
|
-
|
|
611
|
-
|
|
831
|
+
if (provisionalTextDeltas > 0 || provisionalReasoningDeltas > 0) {
|
|
832
|
+
queue.push({
|
|
833
|
+
type: 'model_attempt_rollback',
|
|
834
|
+
textCharacters: provisionalTextCharacters,
|
|
835
|
+
reasoningCharacters: provisionalReasoningCharacters,
|
|
836
|
+
textDeltas: provisionalTextDeltas,
|
|
837
|
+
reasoningDeltas: provisionalReasoningDeltas,
|
|
838
|
+
});
|
|
612
839
|
}
|
|
613
|
-
if (
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
streamedToolCalls.push(event);
|
|
840
|
+
if (decision.kind === 'chain_recovery') {
|
|
841
|
+
state.disableChainingForAttempt = true;
|
|
842
|
+
state.responseId = undefined;
|
|
843
|
+
state.responseProviderId = undefined;
|
|
618
844
|
}
|
|
845
|
+
this.#deps.logDiagnostic?.('Retrying model request in run loop', {
|
|
846
|
+
attempt,
|
|
847
|
+
maxRetries,
|
|
848
|
+
kind: decision.kind,
|
|
849
|
+
delayMs: decision.delayMs,
|
|
850
|
+
error: error instanceof Error ? error.message : String(error),
|
|
851
|
+
});
|
|
852
|
+
await (this.#deps.waitBeforeModelRetry ?? sleepWithAbort)(decision.delayMs, options.signal);
|
|
853
|
+
continue;
|
|
619
854
|
}
|
|
855
|
+
// Dispatch began, but no terminal completion was accepted. Record an
|
|
856
|
+
// unpriced marker so the summary stays honest (partial) rather than
|
|
857
|
+
// appearing exact. Observational only: the error still propagates.
|
|
858
|
+
const cancelled = error instanceof Error && error.name === 'AbortError';
|
|
859
|
+
const record = this.#appendCostRecord(state, {
|
|
860
|
+
requestId,
|
|
861
|
+
provider: state.currentProviderId,
|
|
862
|
+
model: state.agent.model,
|
|
863
|
+
tier: resolveServiceTier(request),
|
|
864
|
+
outcome: cancelled ? 'cancelled' : 'failed',
|
|
865
|
+
});
|
|
866
|
+
// Only the live queue sees cost records: `output`/`newItems` feed
|
|
867
|
+
// persistence and replay, and a cost event must never become a
|
|
868
|
+
// restored history item.
|
|
869
|
+
queue.push({ type: 'cost_update', record });
|
|
870
|
+
this.#evaluateRunBudget(state, stream, queue);
|
|
871
|
+
throw error;
|
|
620
872
|
}
|
|
621
|
-
finally {
|
|
622
|
-
deadline.dispose();
|
|
623
|
-
if (iterator && !iteratorFinished)
|
|
624
|
-
void iterator.return?.().catch(() => undefined);
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
const dispatch = async () => {
|
|
628
|
-
state.requestPreparation?.prepare(request);
|
|
629
|
-
await consume();
|
|
630
|
-
};
|
|
631
|
-
try {
|
|
632
|
-
if (state.requestPreparation)
|
|
633
|
-
await state.requestPreparation.run(dispatch);
|
|
634
|
-
else
|
|
635
|
-
await dispatch();
|
|
636
|
-
}
|
|
637
|
-
catch (error) {
|
|
638
|
-
if (error instanceof GenerationGuardError)
|
|
639
|
-
requestAbortController.abort();
|
|
640
|
-
// Dispatch began, but no terminal completion was accepted. Record an
|
|
641
|
-
// unpriced marker so the summary stays honest (partial) rather than
|
|
642
|
-
// appearing exact. Observational only: the error still propagates.
|
|
643
|
-
const cancelled = error instanceof Error && error.name === 'AbortError';
|
|
644
|
-
const record = this.#appendCostRecord(state, {
|
|
645
|
-
requestId,
|
|
646
|
-
provider: state.currentProviderId,
|
|
647
|
-
model: state.agent.model,
|
|
648
|
-
tier: resolveServiceTier(request),
|
|
649
|
-
outcome: cancelled ? 'cancelled' : 'failed',
|
|
650
|
-
});
|
|
651
|
-
// Only the live queue sees cost records: `output`/`newItems` feed
|
|
652
|
-
// persistence and replay, and a cost event must never become a
|
|
653
|
-
// restored history item.
|
|
654
|
-
queue.push({ type: 'cost_update', record });
|
|
655
|
-
throw error;
|
|
656
873
|
}
|
|
657
874
|
if (!completion) {
|
|
658
875
|
// A few application-owned model fixtures (and legacy adapters) end a
|
|
@@ -662,6 +879,8 @@ export class ApplicationRunLoop {
|
|
|
662
879
|
// fails closed as an incomplete model turn.
|
|
663
880
|
if (streamedToolCalls.length === 0)
|
|
664
881
|
throw new Error('Application model turn ended without completion');
|
|
882
|
+
if (criticalWrapUp)
|
|
883
|
+
return finish(stream, state, queue);
|
|
665
884
|
await this.#dispatchToolCalls(state, stream, queue, streamedToolCalls, toolContext);
|
|
666
885
|
if (state.pendingApprovals && state.pendingApprovals.length > 0) {
|
|
667
886
|
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
@@ -670,6 +889,7 @@ export class ApplicationRunLoop {
|
|
|
670
889
|
}
|
|
671
890
|
continue;
|
|
672
891
|
}
|
|
892
|
+
const finalCompletion = completion;
|
|
673
893
|
// Commit the authoritative terminal state before handling terminal-only
|
|
674
894
|
// tool calls. Approval may pause immediately after this point, and the
|
|
675
895
|
// continuation must still carry the response that produced the calls.
|
|
@@ -678,7 +898,7 @@ export class ApplicationRunLoop {
|
|
|
678
898
|
// chaining, while still exposing the completed provider response on the
|
|
679
899
|
// current stream for diagnostics.
|
|
680
900
|
if (state.supportsConversationChaining && state.currentProviderId !== undefined) {
|
|
681
|
-
state.responseId =
|
|
901
|
+
state.responseId = finalCompletion.responseId;
|
|
682
902
|
state.responseProviderId = state.currentProviderId;
|
|
683
903
|
}
|
|
684
904
|
else {
|
|
@@ -686,8 +906,8 @@ export class ApplicationRunLoop {
|
|
|
686
906
|
state.responseProviderId = undefined;
|
|
687
907
|
}
|
|
688
908
|
let normalizedCompletionUsage;
|
|
689
|
-
if (
|
|
690
|
-
normalizedCompletionUsage = normalizeModelUsage(
|
|
909
|
+
if (finalCompletion.usage !== undefined) {
|
|
910
|
+
normalizedCompletionUsage = normalizeModelUsage(finalCompletion.usage);
|
|
691
911
|
if (normalizedCompletionUsage) {
|
|
692
912
|
const accumulated = addTokenUsage(normalizeModelUsage(state.usage), normalizedCompletionUsage);
|
|
693
913
|
state.usage = {
|
|
@@ -708,7 +928,7 @@ export class ApplicationRunLoop {
|
|
|
708
928
|
else {
|
|
709
929
|
// Providers may carry a future/opaque usage shape. Preserve the old
|
|
710
930
|
// pass-through behavior when normalization cannot recognize it.
|
|
711
|
-
state.usage =
|
|
931
|
+
state.usage = finalCompletion.usage;
|
|
712
932
|
}
|
|
713
933
|
}
|
|
714
934
|
else {
|
|
@@ -722,27 +942,33 @@ export class ApplicationRunLoop {
|
|
|
722
942
|
// persistence and replay, and a cost event must never become a restored
|
|
723
943
|
// history item.
|
|
724
944
|
const record = this.#appendCostRecord(state, {
|
|
725
|
-
requestId,
|
|
945
|
+
requestId: activeRequestId,
|
|
726
946
|
provider: state.currentProviderId,
|
|
727
947
|
model: state.agent.model,
|
|
728
|
-
tier: resolveServiceTier(
|
|
948
|
+
tier: activeRequest ? resolveServiceTier(activeRequest) : 'standard',
|
|
729
949
|
outcome: 'completed',
|
|
730
950
|
usage: normalizedCompletionUsage,
|
|
731
|
-
providerUsd:
|
|
951
|
+
providerUsd: finalCompletion.costUsd,
|
|
732
952
|
});
|
|
733
953
|
queue.push({ type: 'cost_update', record });
|
|
734
|
-
|
|
735
|
-
|
|
954
|
+
// Cost and usage arrive in the same completion metadata, so surface both
|
|
955
|
+
// live. The footer is a per-request indicator: emit this request's own
|
|
956
|
+
// usage, never the run accumulator in `state.usage`.
|
|
957
|
+
if (normalizedCompletionUsage)
|
|
958
|
+
queue.push({ type: 'usage_update', usage: normalizedCompletionUsage });
|
|
959
|
+
this.#evaluateRunBudget(state, stream, queue);
|
|
960
|
+
stream.lastResponseId = finalCompletion.responseId;
|
|
961
|
+
stream.rawResponses?.push(finalCompletion);
|
|
736
962
|
// Some provider adapters report function calls only in the terminal
|
|
737
963
|
// completion rather than as separate stream events. Their reasoning may
|
|
738
964
|
// likewise be terminal-only, so associate it before replaying calls.
|
|
739
965
|
const toolCalls = [...streamedToolCalls];
|
|
740
966
|
if (!sawToolCall) {
|
|
741
|
-
for (const item of
|
|
967
|
+
for (const item of finalCompletion.output) {
|
|
742
968
|
if (item.type === 'reasoning')
|
|
743
969
|
pendingNativeReasoning = appendNativeReasoning(pendingNativeReasoning, item);
|
|
744
970
|
}
|
|
745
|
-
for (const item of
|
|
971
|
+
for (const item of finalCompletion.output) {
|
|
746
972
|
if (item.type !== 'tool_call')
|
|
747
973
|
continue;
|
|
748
974
|
pendingNativeReasoning = commitPendingNativeReasoning(state, stream, queue, pendingNativeReasoning);
|
|
@@ -750,8 +976,6 @@ export class ApplicationRunLoop {
|
|
|
750
976
|
toolCalls.push(item);
|
|
751
977
|
}
|
|
752
978
|
}
|
|
753
|
-
if (toolCalls.length > 0)
|
|
754
|
-
await this.#dispatchToolCalls(state, stream, queue, toolCalls, toolContext);
|
|
755
979
|
// A native reasoning item belongs to the completed assistant turn even
|
|
756
980
|
// when no tool call follows it. Commit it before assistant text so both
|
|
757
981
|
// stateless continuation and persisted canonical history retain the
|
|
@@ -762,7 +986,7 @@ export class ApplicationRunLoop {
|
|
|
762
986
|
// applies compaction's replacement rule; keeping the item here also
|
|
763
987
|
// makes it available to an in-flight tool continuation before that
|
|
764
988
|
// terminal history commit occurs.
|
|
765
|
-
for (const item of
|
|
989
|
+
for (const item of finalCompletion.output) {
|
|
766
990
|
if (item.type !== 'provider_opaque')
|
|
767
991
|
continue;
|
|
768
992
|
const historyItem = {
|
|
@@ -773,7 +997,7 @@ export class ApplicationRunLoop {
|
|
|
773
997
|
state.input.push(item);
|
|
774
998
|
outputPush(stream, queue, { type: 'item', item });
|
|
775
999
|
}
|
|
776
|
-
const assistantText =
|
|
1000
|
+
const assistantText = finalCompletion.output
|
|
777
1001
|
.filter((item) => item.type === 'message')
|
|
778
1002
|
.flatMap((item) => item.content)
|
|
779
1003
|
.map((part) => part.text)
|
|
@@ -789,13 +1013,34 @@ export class ApplicationRunLoop {
|
|
|
789
1013
|
outputPush(stream, queue, { type: 'item', item });
|
|
790
1014
|
state.input.push({ type: 'message', role: 'assistant', content: [{ type: 'text', text: assistantText }] });
|
|
791
1015
|
}
|
|
1016
|
+
// Tool calls are dispatched only after the reasoning, provider-opaque,
|
|
1017
|
+
// and assistant-text items from the same completion are committed. A
|
|
1018
|
+
// response that carries both prose and a tool call must serialize as
|
|
1019
|
+
// text -> function_call -> function_call_result; dispatching first left
|
|
1020
|
+
// the text stranded after its own tool result, where the assistant
|
|
1021
|
+
// message merger glued it onto the *next* turn's tool call and every
|
|
1022
|
+
// request ended with a bare assistant message. Models read that as a
|
|
1023
|
+
// turn truncated mid-sentence and restart instead of progressing.
|
|
1024
|
+
if (!state.criticalWrapUpPending && toolCalls.length > 0) {
|
|
1025
|
+
await this.#dispatchToolCalls(state, stream, queue, toolCalls, toolContext);
|
|
1026
|
+
}
|
|
1027
|
+
// A critical subagent gets exactly this final tool-free model call.
|
|
1028
|
+
if (criticalWrapUp)
|
|
1029
|
+
return finish(stream, state, queue);
|
|
1030
|
+
if (state.pendingRunBudgetInteraction && toolCalls.length > 0) {
|
|
1031
|
+
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
1032
|
+
}
|
|
792
1033
|
if (state.pendingApprovals.length > 0) {
|
|
793
1034
|
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
794
1035
|
this.#turnPaused = true;
|
|
795
1036
|
return finish(stream, state, queue);
|
|
796
1037
|
}
|
|
797
|
-
if (!sawToolCall)
|
|
1038
|
+
if (!sawToolCall) {
|
|
1039
|
+
// Evidence discovered when a response has already completed needs no
|
|
1040
|
+
// human boundary: there is no later request or tool to block.
|
|
1041
|
+
state.pendingRunBudgetInteraction = undefined;
|
|
798
1042
|
return finish(stream, state, queue);
|
|
1043
|
+
}
|
|
799
1044
|
}
|
|
800
1045
|
}
|
|
801
1046
|
async #dispatchToolCalls(state, stream, queue, events, toolContext) {
|
|
@@ -829,6 +1074,14 @@ export class ApplicationRunLoop {
|
|
|
829
1074
|
// would apply schema defaults before execute. web_fetch relies on its
|
|
830
1075
|
// executor fallbacks on the strict JSON-schema path.
|
|
831
1076
|
entry.params = normalizeToolParameters(parseArguments(event.arguments), definition.parameters);
|
|
1077
|
+
const stallEvent = state.runBudget?.observeToolCall({
|
|
1078
|
+
name: event.name,
|
|
1079
|
+
argumentsText: event.arguments,
|
|
1080
|
+
effect: definition.effect,
|
|
1081
|
+
});
|
|
1082
|
+
if (stallEvent) {
|
|
1083
|
+
this.#emitRunBudgetEvent(state, stallEvent, 'Tool stall evidence', stream, queue);
|
|
1084
|
+
}
|
|
832
1085
|
// Consult this run's ledger before prompting: a decision already taken
|
|
833
1086
|
// (in the parent run and replayed in, or earlier in this run) must not
|
|
834
1087
|
// prompt again. This is what makes approval replay observable.
|
|
@@ -870,12 +1123,17 @@ export class ApplicationRunLoop {
|
|
|
870
1123
|
approvalPending: entry.status === 'approval_pending',
|
|
871
1124
|
})),
|
|
872
1125
|
});
|
|
873
|
-
|
|
1126
|
+
// A main-agent budget escalation is a real boundary: retain the planned
|
|
1127
|
+
// calls, but do not execute one more tool while human judgement is pending.
|
|
1128
|
+
if (!state.pendingRunBudgetInteraction) {
|
|
1129
|
+
await this.#settleToolPlan(state, stream, queue, toolContext);
|
|
1130
|
+
}
|
|
874
1131
|
}
|
|
875
1132
|
async #settleToolPlan(state, stream, queue, toolContext) {
|
|
876
1133
|
const plan = state.toolPlan;
|
|
877
1134
|
if (!plan)
|
|
878
1135
|
return;
|
|
1136
|
+
const maxParallelToolCalls = Math.max(1, Math.floor(this.#deps.resolveMaxParallelToolCalls?.() ?? DEFAULT_MAX_PARALLEL_TOOL_CALLS));
|
|
879
1137
|
while (true) {
|
|
880
1138
|
const firstPending = plan.find((entry) => entry.status !== 'completed');
|
|
881
1139
|
if (!firstPending) {
|
|
@@ -890,8 +1148,7 @@ export class ApplicationRunLoop {
|
|
|
890
1148
|
continue;
|
|
891
1149
|
if (entry.status === 'approval_pending')
|
|
892
1150
|
break;
|
|
893
|
-
if (group.length > 0 &&
|
|
894
|
-
(!entry.parallelSafe || !group[0].parallelSafe || group.length >= this.#maxParallelToolCalls))
|
|
1151
|
+
if (group.length > 0 && (!entry.parallelSafe || !group[0].parallelSafe || group.length >= maxParallelToolCalls))
|
|
895
1152
|
break;
|
|
896
1153
|
group.push(entry);
|
|
897
1154
|
if (!entry.parallelSafe)
|
|
@@ -902,8 +1159,16 @@ export class ApplicationRunLoop {
|
|
|
902
1159
|
batchId,
|
|
903
1160
|
callIds: group.map((entry) => entry.event.id),
|
|
904
1161
|
parallel: group.length > 1,
|
|
1162
|
+
maxParallelToolCalls,
|
|
905
1163
|
dispatchOrder: group.map((entry) => entry.event.id),
|
|
906
1164
|
});
|
|
1165
|
+
for (const entry of group) {
|
|
1166
|
+
outputPush(stream, queue, {
|
|
1167
|
+
type: 'tool_call_dispatched',
|
|
1168
|
+
callId: entry.event.id,
|
|
1169
|
+
toolName: entry.event.name,
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
907
1172
|
if (group.length > 1) {
|
|
908
1173
|
const results = await Promise.allSettled(group.map((entry) => this.#invokePlannedTool(entry, toolContext, state)));
|
|
909
1174
|
const rejected = results.find((result) => result.status === 'rejected');
|
|
@@ -940,6 +1205,7 @@ export class ApplicationRunLoop {
|
|
|
940
1205
|
state.history.push(resultItem);
|
|
941
1206
|
state.input.push({ type: 'tool_result', id: entry.event.id, output });
|
|
942
1207
|
outputPush(stream, queue, { type: 'item', item: resultItem });
|
|
1208
|
+
this.#evaluateRunBudget(state, stream, queue);
|
|
943
1209
|
}
|
|
944
1210
|
/**
|
|
945
1211
|
* A tool that throws must not take the run down with it.
|
|
@@ -987,15 +1253,6 @@ export class ApplicationRunLoop {
|
|
|
987
1253
|
throw error;
|
|
988
1254
|
}
|
|
989
1255
|
const message = error instanceof Error ? error.message : String(error);
|
|
990
|
-
// Feeding the same failure back forever is its own failure mode: some
|
|
991
|
-
// errors no argument can fix. Repeat the identical result once, then say
|
|
992
|
-
// so plainly rather than inviting a third identical attempt.
|
|
993
|
-
const repeated = state ? countRepeatedFailure(state, definition.name, params, message) : 1;
|
|
994
|
-
if (repeated > MAX_IDENTICAL_TOOL_FAILURES) {
|
|
995
|
-
const result = `Error: ${message}\n\nThis exact call has now failed ${repeated} times with the same error. Do not call ${definition.name} with these arguments again — either change your approach or report the problem to the user.`;
|
|
996
|
-
await this.#notifyToolLifecycle(() => this.#deps.toolLifecycle?.error(lifecycleContext, error, Date.now() - startedAt, true));
|
|
997
|
-
return result;
|
|
998
|
-
}
|
|
999
1256
|
const result = `Error: ${message}`;
|
|
1000
1257
|
await this.#notifyToolLifecycle(() => this.#deps.toolLifecycle?.error(lifecycleContext, error, Date.now() - startedAt, true));
|
|
1001
1258
|
return result;
|
|
@@ -1020,6 +1277,52 @@ export class ApplicationRunLoop {
|
|
|
1020
1277
|
state.costRecords = [...(state.costRecords ?? []), record];
|
|
1021
1278
|
return record;
|
|
1022
1279
|
}
|
|
1280
|
+
#evaluateRunBudget(state, stream, queue) {
|
|
1281
|
+
if (!state.runBudget)
|
|
1282
|
+
return;
|
|
1283
|
+
for (const event of state.runBudget.evaluate({
|
|
1284
|
+
turns: state.turnCount,
|
|
1285
|
+
costRecords: state.costRecords ?? [],
|
|
1286
|
+
})) {
|
|
1287
|
+
this.#emitRunBudgetEvent(state, event, 'Run budget evidence', stream, queue);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
#emitRunBudgetEvent(state, event, message, stream, queue) {
|
|
1291
|
+
if (state.runBudgetEscalation === 'disabled') {
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
if (event.type === 'budget_stage' && event.stage === 'critical' && state.wrapUpOnCriticalRunBudget) {
|
|
1295
|
+
state.criticalWrapUpPending = true;
|
|
1296
|
+
}
|
|
1297
|
+
if (!state.wrapUpOnCriticalRunBudget &&
|
|
1298
|
+
!state.pendingRunBudgetInteraction &&
|
|
1299
|
+
state.runBudgetEscalation !== 'warn' &&
|
|
1300
|
+
this.#requiresHumanBudgetDecision(event)) {
|
|
1301
|
+
state.pendingRunBudgetInteraction = { type: 'run_budget_interaction', event };
|
|
1302
|
+
state.runBudgetGrantConsumed = false;
|
|
1303
|
+
}
|
|
1304
|
+
if (stream && queue)
|
|
1305
|
+
outputPush(stream, queue, { type: 'run_budget', evidence: event });
|
|
1306
|
+
try {
|
|
1307
|
+
state.onRunBudgetEvent?.(event);
|
|
1308
|
+
}
|
|
1309
|
+
catch {
|
|
1310
|
+
// Evidence observers are delivery adapters, not budget owners.
|
|
1311
|
+
this.#deps.logDiagnostic?.('Run budget event observer failed', { type: event.type });
|
|
1312
|
+
}
|
|
1313
|
+
this.#deps.logDiagnostic?.(message, event);
|
|
1314
|
+
}
|
|
1315
|
+
#requiresHumanBudgetDecision(event) {
|
|
1316
|
+
return event.type === 'tool_stall' || (event.type === 'budget_stage' && event.stage !== 'soft');
|
|
1317
|
+
}
|
|
1318
|
+
#pauseForRunBudgetInteraction(state, stream, queue) {
|
|
1319
|
+
const interaction = state.pendingRunBudgetInteraction;
|
|
1320
|
+
if (!interaction)
|
|
1321
|
+
return finish(stream, state, queue);
|
|
1322
|
+
stream.interruptions = [interaction];
|
|
1323
|
+
this.#turnPaused = true;
|
|
1324
|
+
return finish(stream, state, queue);
|
|
1325
|
+
}
|
|
1023
1326
|
async #notifyToolLifecycle(operation) {
|
|
1024
1327
|
if (!operation)
|
|
1025
1328
|
return;
|
|
@@ -1032,27 +1335,6 @@ export class ApplicationRunLoop {
|
|
|
1032
1335
|
}
|
|
1033
1336
|
}
|
|
1034
1337
|
}
|
|
1035
|
-
/**
|
|
1036
|
-
* How many times an identical failing call is fed back before the loop stops
|
|
1037
|
-
* inviting retries. One repeat is worth allowing: a transient failure resolves,
|
|
1038
|
-
* and a model given the error often corrects on its second attempt.
|
|
1039
|
-
*/
|
|
1040
|
-
const MAX_IDENTICAL_TOOL_FAILURES = 2;
|
|
1041
|
-
function countRepeatedFailure(state, toolName, params, message) {
|
|
1042
|
-
let key;
|
|
1043
|
-
try {
|
|
1044
|
-
key = JSON.stringify([toolName, params, message]);
|
|
1045
|
-
}
|
|
1046
|
-
catch {
|
|
1047
|
-
// Unserializable params cannot be compared for identity; treat every such
|
|
1048
|
-
// failure as distinct rather than collapsing unrelated calls together.
|
|
1049
|
-
return 1;
|
|
1050
|
-
}
|
|
1051
|
-
state.toolFailureCounts ??= new Map();
|
|
1052
|
-
const count = (state.toolFailureCounts.get(key) ?? 0) + 1;
|
|
1053
|
-
state.toolFailureCounts.set(key, count);
|
|
1054
|
-
return count;
|
|
1055
|
-
}
|
|
1056
1338
|
function outputPush(stream, queue, item) {
|
|
1057
1339
|
stream.output.push(item);
|
|
1058
1340
|
if (stream.newItems !== stream.output)
|
|
@@ -1078,6 +1360,15 @@ function finish(stream, state, queue) {
|
|
|
1078
1360
|
* Chat-Completions continuation field. Generic reasoning remains display-only
|
|
1079
1361
|
* so providers with different native formats are not given a foreign field.
|
|
1080
1362
|
*/
|
|
1363
|
+
/**
|
|
1364
|
+
* True when any lane namespace in the metadata carries an `encrypted_content`
|
|
1365
|
+
* blob — the shape every Responses adapter produces, whichever vendor it is.
|
|
1366
|
+
*/
|
|
1367
|
+
function hasNamespacedEncryptedReasoning(metadata) {
|
|
1368
|
+
if (!metadata)
|
|
1369
|
+
return false;
|
|
1370
|
+
return Object.values(metadata).some((value) => asRecord(value)?.encrypted_content !== undefined);
|
|
1371
|
+
}
|
|
1081
1372
|
function appendNativeReasoning(current, event) {
|
|
1082
1373
|
const nativeReasoning = event.providerMetadata?.reasoning_content;
|
|
1083
1374
|
if (typeof nativeReasoning === 'string') {
|
|
@@ -1094,8 +1385,10 @@ function appendNativeReasoning(current, event) {
|
|
|
1094
1385
|
}
|
|
1095
1386
|
// Responses providers return encrypted reasoning only on their terminal
|
|
1096
1387
|
// output. Their metadata is namespaced, so retain it without turning it into
|
|
1097
|
-
// the Chat-Completions-only reasoning_content convention.
|
|
1098
|
-
|
|
1388
|
+
// the Chat-Completions-only reasoning_content convention. Match on the
|
|
1389
|
+
// namespaced shape rather than an allowlist of lane names: an allowlist
|
|
1390
|
+
// silently drops the reasoning of every Responses lane added later.
|
|
1391
|
+
if (hasNamespacedEncryptedReasoning(event.providerMetadata)) {
|
|
1099
1392
|
return {
|
|
1100
1393
|
...(event.id ? { id: event.id } : current?.id ? { id: current.id } : {}),
|
|
1101
1394
|
text: event.text,
|