@qduc/term2 0.27.0 → 0.28.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 +9 -7
- package/dist/acp-v2/session-backend.d.ts +0 -1
- package/dist/acp-v2/session-backend.d.ts.map +1 -1
- package/dist/acp-v2/session-backend.js +0 -1
- package/dist/acp-v2/session-backend.js.map +1 -1
- package/dist/agent.d.ts +4 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +6 -2
- package/dist/agent.js.map +1 -1
- package/dist/app-helpers.d.ts +0 -2
- package/dist/app-helpers.d.ts.map +1 -1
- package/dist/app-helpers.js +1 -1
- package/dist/app-helpers.js.map +1 -1
- package/dist/app.d.ts +9 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +65 -12
- package/dist/app.js.map +1 -1
- package/dist/build-info.json +6 -0
- package/dist/cli.js +192 -41
- package/dist/cli.js.map +1 -1
- package/dist/commands/auto-approve-command.d.ts.map +1 -1
- package/dist/commands/auto-approve-command.js +2 -6
- package/dist/commands/auto-approve-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/goal-command.d.ts +8 -0
- package/dist/commands/goal-command.d.ts.map +1 -0
- package/dist/commands/goal-command.js +49 -0
- package/dist/commands/goal-command.js.map +1 -0
- package/dist/commands/handoff-command.js +1 -1
- package/dist/commands/handoff-command.js.map +1 -1
- package/dist/commands/mode-commands.d.ts +5 -1
- package/dist/commands/mode-commands.d.ts.map +1 -1
- package/dist/commands/mode-commands.js +14 -2
- 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.js +1 -1
- package/dist/commands/resume-command.js.map +1 -1
- package/dist/commands/rewind-command.d.ts.map +1 -1
- package/dist/commands/rewind-command.js +8 -4
- package/dist/commands/rewind-command.js.map +1 -1
- package/dist/commands/sandbox-command.js +1 -1
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.js +1 -3
- package/dist/components/ErrorBoundary.js.map +1 -1
- package/dist/components/InputBox.d.ts +4 -2
- package/dist/components/InputBox.d.ts.map +1 -1
- package/dist/components/InputBox.js +30 -7
- package/dist/components/InputBox.js.map +1 -1
- package/dist/components/MarkdownRenderer.js +1 -1
- package/dist/components/MarkdownRenderer.js.map +1 -1
- package/dist/components/common/MenuContainer.d.ts.map +1 -1
- package/dist/components/common/MenuContainer.js +8 -9
- package/dist/components/common/MenuContainer.js.map +1 -1
- package/dist/components/input/ApplicationInputSurface.d.ts +1 -1
- package/dist/components/input/ApplicationInputSurface.d.ts.map +1 -1
- package/dist/components/input/ApplicationInputSurface.js +5 -2
- 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 +3 -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 +9 -3
- package/dist/components/input/MenuSurface.js.map +1 -1
- package/dist/components/input/PendingQueueList.js +1 -1
- package/dist/components/input/ResumeMenuSession.js +1 -1
- package/dist/components/input/ResumeMenuSession.js.map +1 -1
- package/dist/components/input/menu-bindings.d.ts.map +1 -1
- package/dist/components/input/menu-bindings.js +1 -1
- package/dist/components/input/menu-bindings.js.map +1 -1
- package/dist/components/input/menu-registry.d.ts +0 -3
- package/dist/components/input/menu-registry.d.ts.map +1 -1
- package/dist/components/input/menu-registry.js +0 -3
- package/dist/components/input/menu-registry.js.map +1 -1
- package/dist/components/input/triggers.d.ts +0 -1
- package/dist/components/input/triggers.d.ts.map +1 -1
- package/dist/components/input/triggers.js +1 -1
- package/dist/components/input/triggers.js.map +1 -1
- package/dist/components/layout/BackgroundTaskManager.js +1 -1
- package/dist/components/layout/BackgroundTasksPanel.d.ts +0 -2
- package/dist/components/layout/BackgroundTasksPanel.d.ts.map +1 -1
- package/dist/components/layout/BackgroundTasksPanel.js +0 -1
- package/dist/components/layout/BackgroundTasksPanel.js.map +1 -1
- package/dist/components/layout/Banner.d.ts.map +1 -1
- package/dist/components/layout/Banner.js +2 -1
- package/dist/components/layout/Banner.js.map +1 -1
- package/dist/components/layout/BottomArea.d.ts.map +1 -1
- package/dist/components/layout/BottomArea.js +32 -12
- package/dist/components/layout/BottomArea.js.map +1 -1
- package/dist/components/layout/DiffView.d.ts +1 -1
- package/dist/components/layout/DiffView.d.ts.map +1 -1
- package/dist/components/layout/DiffView.js +1 -1
- package/dist/components/layout/DiffView.js.map +1 -1
- package/dist/components/layout/StatusBar.d.ts.map +1 -1
- package/dist/components/layout/StatusBar.js +14 -11
- package/dist/components/layout/StatusBar.js.map +1 -1
- package/dist/components/menu/CopyMenu.js +1 -1
- package/dist/components/menu/McpSelectionMenu.js +1 -1
- package/dist/components/menu/ModelSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/ModelSelectionMenu.js +4 -1
- package/dist/components/menu/ModelSelectionMenu.js.map +1 -1
- package/dist/components/menu/PathSelectionMenu.js +1 -1
- package/dist/components/menu/ProfileSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/ProfileSelectionMenu.js +6 -4
- package/dist/components/menu/ProfileSelectionMenu.js.map +1 -1
- package/dist/components/menu/ProviderSelectionMenu.js +7 -7
- package/dist/components/menu/ProviderSelectionMenu.js.map +1 -1
- package/dist/components/menu/ResumeSelectionMenu.d.ts +1 -1
- package/dist/components/menu/ResumeSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/ResumeSelectionMenu.js +33 -6
- package/dist/components/menu/ResumeSelectionMenu.js.map +1 -1
- package/dist/components/menu/RewindMenu.js +1 -1
- package/dist/components/menu/SettingsSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SettingsSelectionMenu.js +6 -6
- 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 +14 -5
- 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 +6 -4
- package/dist/components/menu/SkillSelectionMenu.js.map +1 -1
- package/dist/components/menu/StandaloneModelPickerApp.d.ts +1 -1
- package/dist/components/menu/StandaloneModelPickerApp.d.ts.map +1 -1
- package/dist/components/menu/StandaloneModelPickerApp.js +1 -1
- package/dist/components/menu/StandaloneModelPickerApp.js.map +1 -1
- package/dist/components/menu/SubagentPoolSelectionMenu.d.ts +1 -1
- package/dist/components/menu/SubagentPoolSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SubagentPoolSelectionMenu.js +5 -5
- package/dist/components/menu/SubagentPoolSelectionMenu.js.map +1 -1
- package/dist/components/menu/settings-value-formatter.d.ts +0 -1
- package/dist/components/menu/settings-value-formatter.d.ts.map +1 -1
- package/dist/components/menu/settings-value-formatter.js +7 -1
- package/dist/components/menu/settings-value-formatter.js.map +1 -1
- package/dist/components/message/CommandMessage.d.ts.map +1 -1
- package/dist/components/message/CommandMessage.js +15 -3
- package/dist/components/message/CommandMessage.js.map +1 -1
- package/dist/components/message/command-message-helpers.d.ts +3 -0
- package/dist/components/message/command-message-helpers.d.ts.map +1 -1
- package/dist/components/message/command-message-helpers.js +19 -0
- package/dist/components/message/command-message-helpers.js.map +1 -1
- package/dist/components/prompt/ApprovalPrompt.d.ts +1 -0
- package/dist/components/prompt/ApprovalPrompt.d.ts.map +1 -1
- package/dist/components/prompt/ApprovalPrompt.js +139 -69
- package/dist/components/prompt/ApprovalPrompt.js.map +1 -1
- package/dist/components/prompt/ConfirmPrompt.js +1 -1
- package/dist/components/prompt/QueuePausedPrompt.d.ts.map +1 -1
- package/dist/components/prompt/QueuePausedPrompt.js +7 -7
- package/dist/components/prompt/QueuePausedPrompt.js.map +1 -1
- package/dist/context/InputContext.d.ts +1 -2
- package/dist/context/InputContext.d.ts.map +1 -1
- package/dist/context/InputContext.js +1 -1
- package/dist/context/InputContext.js.map +1 -1
- package/dist/contracts/conversation-items.d.ts +3 -1
- package/dist/contracts/conversation-items.d.ts.map +1 -1
- package/dist/contracts/conversation.d.ts +2 -2
- package/dist/contracts/conversation.d.ts.map +1 -1
- package/dist/contracts/conversation.js +0 -2
- package/dist/contracts/conversation.js.map +1 -1
- package/dist/contracts/provider-input.d.ts +1 -0
- package/dist/contracts/provider-input.d.ts.map +1 -1
- package/dist/contracts/streamed-model-turn.d.ts +2 -0
- package/dist/contracts/streamed-model-turn.d.ts.map +1 -1
- package/dist/gateway/assertion.d.ts +0 -1
- package/dist/gateway/assertion.d.ts.map +1 -1
- package/dist/gateway/assertion.js +1 -2
- package/dist/gateway/assertion.js.map +1 -1
- package/dist/gateway/gateway.d.ts +1 -2
- package/dist/gateway/gateway.d.ts.map +1 -1
- package/dist/gateway/gateway.js +1 -2
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/persistence/retention.d.ts +0 -1
- package/dist/gateway/persistence/retention.d.ts.map +1 -1
- package/dist/gateway/persistence/retention.js +1 -1
- package/dist/gateway/persistence/retention.js.map +1 -1
- package/dist/gateway/persistence/session-snapshot.d.ts +0 -1
- package/dist/gateway/persistence/session-snapshot.d.ts.map +1 -1
- package/dist/gateway/persistence/session-snapshot.js +1 -1
- package/dist/gateway/persistence/session-snapshot.js.map +1 -1
- package/dist/gateway/persistence/storage.d.ts +0 -3
- package/dist/gateway/persistence/storage.d.ts.map +1 -1
- package/dist/gateway/persistence/storage.js +2 -2
- package/dist/gateway/persistence/storage.js.map +1 -1
- package/dist/gateway/runtime-factory.d.ts +0 -2
- package/dist/gateway/runtime-factory.d.ts.map +1 -1
- package/dist/gateway/runtime-factory.js +2 -2
- package/dist/gateway/runtime-factory.js.map +1 -1
- package/dist/gateway/safe-log.d.ts +0 -1
- package/dist/gateway/safe-log.d.ts.map +1 -1
- package/dist/gateway/safe-log.js +1 -4
- package/dist/gateway/safe-log.js.map +1 -1
- package/dist/gateway/settings-rpc.d.ts +2 -15
- package/dist/gateway/settings-rpc.d.ts.map +1 -1
- package/dist/gateway/settings-rpc.js +5 -5
- package/dist/gateway/settings-rpc.js.map +1 -1
- package/dist/gateway/worker-boundary.d.ts +0 -4
- package/dist/gateway/worker-boundary.d.ts.map +1 -1
- package/dist/gateway/worker-boundary.js +2 -2
- package/dist/gateway/worker-boundary.js.map +1 -1
- package/dist/hooks/path-completion-filter.d.ts +1 -1
- package/dist/hooks/path-completion-filter.d.ts.map +1 -1
- package/dist/hooks/path-completion-filter.js +1 -1
- package/dist/hooks/path-completion-filter.js.map +1 -1
- package/dist/hooks/settings-completion-logic.d.ts.map +1 -1
- package/dist/hooks/settings-completion-logic.js +5 -1
- package/dist/hooks/settings-completion-logic.js.map +1 -1
- package/dist/hooks/use-app-commands.d.ts +5 -6
- package/dist/hooks/use-app-commands.d.ts.map +1 -1
- package/dist/hooks/use-app-commands.js +21 -8
- package/dist/hooks/use-app-commands.js.map +1 -1
- package/dist/hooks/use-app-keyboard-shortcuts.d.ts +2 -1
- package/dist/hooks/use-app-keyboard-shortcuts.d.ts.map +1 -1
- package/dist/hooks/use-app-keyboard-shortcuts.js +38 -1
- package/dist/hooks/use-app-keyboard-shortcuts.js.map +1 -1
- package/dist/hooks/use-conversation.d.ts +7 -2
- package/dist/hooks/use-conversation.d.ts.map +1 -1
- package/dist/hooks/use-conversation.js +39 -2
- package/dist/hooks/use-conversation.js.map +1 -1
- package/dist/hooks/use-escape-key.js +1 -1
- package/dist/hooks/use-escape-key.js.map +1 -1
- package/dist/hooks/use-first-run-setup.d.ts +0 -1
- package/dist/hooks/use-first-run-setup.d.ts.map +1 -1
- package/dist/hooks/use-first-run-setup.js +0 -2
- package/dist/hooks/use-first-run-setup.js.map +1 -1
- package/dist/hooks/use-input-history.d.ts +1 -0
- package/dist/hooks/use-input-history.d.ts.map +1 -1
- package/dist/hooks/use-input-history.js +1 -0
- package/dist/hooks/use-input-history.js.map +1 -1
- package/dist/hooks/use-resume-selection.d.ts +1 -2
- package/dist/hooks/use-resume-selection.d.ts.map +1 -1
- package/dist/hooks/use-resume-selection.js +3 -4
- package/dist/hooks/use-resume-selection.js.map +1 -1
- package/dist/hooks/use-rewind-selection.d.ts +0 -26
- package/dist/hooks/use-rewind-selection.d.ts.map +1 -1
- package/dist/hooks/use-rewind-selection.js +0 -94
- package/dist/hooks/use-rewind-selection.js.map +1 -1
- package/dist/hooks/use-settings-completion.d.ts.map +1 -1
- package/dist/hooks/use-settings-completion.js +2 -1
- package/dist/hooks/use-settings-completion.js.map +1 -1
- package/dist/hooks/use-skill-selection.d.ts +0 -1
- package/dist/hooks/use-skill-selection.d.ts.map +1 -1
- package/dist/hooks/use-skill-selection.js +0 -1
- package/dist/hooks/use-skill-selection.js.map +1 -1
- package/dist/hooks/use-subagent-pool-selection.d.ts +11 -1
- package/dist/hooks/use-subagent-pool-selection.d.ts.map +1 -1
- package/dist/hooks/use-subagent-pool-selection.js +26 -15
- package/dist/hooks/use-subagent-pool-selection.js.map +1 -1
- package/dist/lib/agent-client.d.ts +8 -2
- package/dist/lib/agent-client.d.ts.map +1 -1
- package/dist/lib/agent-client.js +45 -8
- package/dist/lib/agent-client.js.map +1 -1
- package/dist/lib/agent-configuration.d.ts +2 -0
- package/dist/lib/agent-configuration.d.ts.map +1 -1
- package/dist/lib/agent-configuration.js +3 -0
- package/dist/lib/agent-configuration.js.map +1 -1
- package/dist/lib/agent-factory.d.ts +3 -0
- package/dist/lib/agent-factory.d.ts.map +1 -1
- package/dist/lib/agent-factory.js +3 -1
- package/dist/lib/agent-factory.js.map +1 -1
- package/dist/non-interactive.d.ts +4 -2
- package/dist/non-interactive.d.ts.map +1 -1
- package/dist/non-interactive.js +23 -2
- package/dist/non-interactive.js.map +1 -1
- package/dist/prompts/durable-goal-context.d.ts +4 -0
- package/dist/prompts/durable-goal-context.d.ts.map +1 -0
- package/dist/prompts/durable-goal-context.js +24 -0
- package/dist/prompts/durable-goal-context.js.map +1 -0
- package/dist/prompts/durable-goal-context.test.ts +56 -0
- package/dist/prompts/durable-goal-context.ts +27 -0
- package/dist/providers/ai-sdk-streamed-model.d.ts +0 -5
- package/dist/providers/ai-sdk-streamed-model.d.ts.map +1 -1
- package/dist/providers/ai-sdk-streamed-model.js +1 -1
- package/dist/providers/ai-sdk-streamed-model.js.map +1 -1
- package/dist/providers/codex-auth.d.ts +1 -18
- package/dist/providers/codex-auth.d.ts.map +1 -1
- package/dist/providers/codex-auth.js +6 -19
- package/dist/providers/codex-auth.js.map +1 -1
- package/dist/providers/codex-compact.js +1 -1
- package/dist/providers/codex-compact.js.map +1 -1
- package/dist/providers/codex-responses-model.d.ts +1 -2
- package/dist/providers/codex-responses-model.d.ts.map +1 -1
- package/dist/providers/codex-responses-model.js +3 -2
- package/dist/providers/codex-responses-model.js.map +1 -1
- package/dist/providers/codex-turn-converter.d.ts +1 -3
- package/dist/providers/codex-turn-converter.d.ts.map +1 -1
- package/dist/providers/codex-turn-converter.js +2 -2
- package/dist/providers/codex-turn-converter.js.map +1 -1
- package/dist/providers/codex.provider.d.ts +1 -1
- package/dist/providers/codex.provider.d.ts.map +1 -1
- package/dist/providers/codex.provider.js +1 -1
- package/dist/providers/codex.provider.js.map +1 -1
- package/dist/providers/common/openai-compatible-messages.d.ts +0 -1
- package/dist/providers/common/openai-compatible-messages.d.ts.map +1 -1
- package/dist/providers/common/openai-compatible-messages.js +0 -30
- package/dist/providers/common/openai-compatible-messages.js.map +1 -1
- package/dist/providers/common/openai-compatible-utils.d.ts +0 -8
- package/dist/providers/common/openai-compatible-utils.d.ts.map +1 -1
- package/dist/providers/common/openai-compatible-utils.js +0 -23
- package/dist/providers/common/openai-compatible-utils.js.map +1 -1
- package/dist/providers/grok-auth.d.ts +1 -33
- package/dist/providers/grok-auth.d.ts.map +1 -1
- package/dist/providers/grok-auth.js +9 -9
- package/dist/providers/grok-auth.js.map +1 -1
- package/dist/providers/grok.provider.d.ts +0 -1
- package/dist/providers/grok.provider.d.ts.map +1 -1
- package/dist/providers/grok.provider.js +1 -1
- package/dist/providers/grok.provider.js.map +1 -1
- package/dist/providers/llama-cpp.provider.d.ts +0 -1
- package/dist/providers/llama-cpp.provider.d.ts.map +1 -1
- package/dist/providers/llama-cpp.provider.js +1 -1
- package/dist/providers/llama-cpp.provider.js.map +1 -1
- package/dist/providers/oauth-account-store.d.ts +0 -11
- package/dist/providers/oauth-account-store.d.ts.map +1 -1
- package/dist/providers/oauth-account-store.js +1 -1
- package/dist/providers/oauth-account-store.js.map +1 -1
- package/dist/providers/openai-compatible-middleware.d.ts +0 -1
- package/dist/providers/openai-compatible-middleware.d.ts.map +1 -1
- package/dist/providers/openai-compatible-middleware.js +0 -17
- package/dist/providers/openai-compatible-middleware.js.map +1 -1
- package/dist/providers/openai-compatible.provider.d.ts +0 -1
- package/dist/providers/openai-compatible.provider.d.ts.map +1 -1
- package/dist/providers/openai-compatible.provider.js +1 -1
- package/dist/providers/openai-compatible.provider.js.map +1 -1
- package/dist/providers/openai-request-prefix-binding.d.ts +0 -1
- package/dist/providers/openai-request-prefix-binding.d.ts.map +1 -1
- package/dist/providers/openai-request-prefix-binding.js +0 -3
- package/dist/providers/openai-request-prefix-binding.js.map +1 -1
- package/dist/providers/openai-responses-model.d.ts +1 -6
- package/dist/providers/openai-responses-model.d.ts.map +1 -1
- package/dist/providers/openai-responses-model.js +2 -1
- package/dist/providers/openai-responses-model.js.map +1 -1
- package/dist/providers/opencode-go-usage.d.ts +0 -2
- package/dist/providers/opencode-go-usage.d.ts.map +1 -1
- package/dist/providers/opencode-go-usage.js +1 -1
- package/dist/providers/opencode-go-usage.js.map +1 -1
- package/dist/providers/opencode-session.d.ts +0 -6
- package/dist/providers/opencode-session.d.ts.map +1 -1
- package/dist/providers/opencode-session.js +2 -2
- package/dist/providers/opencode-session.js.map +1 -1
- package/dist/providers/provider-opaque-compatibility.d.ts +3 -1
- package/dist/providers/provider-opaque-compatibility.d.ts.map +1 -1
- package/dist/providers/provider-opaque-compatibility.js +19 -2
- package/dist/providers/provider-opaque-compatibility.js.map +1 -1
- package/dist/providers/provider-service.d.ts +0 -2
- package/dist/providers/provider-service.d.ts.map +1 -1
- package/dist/providers/provider-service.js +1 -1
- package/dist/providers/provider-service.js.map +1 -1
- package/dist/providers/responses-websocket-sessions.d.ts +0 -1
- package/dist/providers/responses-websocket-sessions.d.ts.map +1 -1
- package/dist/providers/responses-websocket-sessions.js +1 -1
- package/dist/providers/responses-websocket-sessions.js.map +1 -1
- package/dist/providers/web-search/exa.provider.d.ts +2 -3
- package/dist/providers/web-search/exa.provider.d.ts.map +1 -1
- package/dist/providers/web-search/exa.provider.js +1 -1
- package/dist/providers/web-search/exa.provider.js.map +1 -1
- package/dist/providers/web-search/index.d.ts +1 -1
- package/dist/providers/web-search/index.d.ts.map +1 -1
- package/dist/providers/web-search/index.js +1 -1
- package/dist/providers/web-search/index.js.map +1 -1
- package/dist/providers/web-search/tavily.provider.d.ts +2 -3
- package/dist/providers/web-search/tavily.provider.d.ts.map +1 -1
- package/dist/providers/web-search/tavily.provider.js +1 -1
- package/dist/providers/web-search/tavily.provider.js.map +1 -1
- package/dist/providers/websocket-abort-race.d.ts +0 -2
- package/dist/providers/websocket-abort-race.d.ts.map +1 -1
- package/dist/providers/websocket-abort-race.js +1 -1
- package/dist/providers/websocket-abort-race.js.map +1 -1
- package/dist/services/agent-runtime/application-run-loop.d.ts +15 -3
- package/dist/services/agent-runtime/application-run-loop.d.ts.map +1 -1
- package/dist/services/agent-runtime/application-run-loop.js +224 -429
- package/dist/services/agent-runtime/application-run-loop.js.map +1 -1
- package/dist/services/agent-runtime/context-compaction/index.d.ts +0 -1
- package/dist/services/agent-runtime/context-compaction/index.d.ts.map +1 -1
- package/dist/services/agent-runtime/context-compaction/index.js +1 -1
- package/dist/services/agent-runtime/context-compaction/index.js.map +1 -1
- package/dist/services/agent-runtime/generation-guard.d.ts +0 -4
- package/dist/services/agent-runtime/generation-guard.d.ts.map +1 -1
- package/dist/services/agent-runtime/generation-guard.js +2 -2
- package/dist/services/agent-runtime/generation-guard.js.map +1 -1
- package/dist/services/agent-runtime/index.d.ts +2 -3
- package/dist/services/agent-runtime/index.d.ts.map +1 -1
- package/dist/services/agent-runtime/index.js +0 -4
- package/dist/services/agent-runtime/index.js.map +1 -1
- package/dist/services/agent-runtime/model-resolver.d.ts +16 -3
- package/dist/services/agent-runtime/model-resolver.d.ts.map +1 -1
- package/dist/services/agent-runtime/model-resolver.js +37 -14
- package/dist/services/agent-runtime/model-resolver.js.map +1 -1
- package/dist/services/agent-runtime/scope-resolver.d.ts +0 -5
- package/dist/services/agent-runtime/scope-resolver.d.ts.map +1 -1
- package/dist/services/agent-runtime/scope-resolver.js +0 -7
- package/dist/services/agent-runtime/scope-resolver.js.map +1 -1
- package/dist/services/agent-runtime/tool-call-execution.d.ts +65 -0
- package/dist/services/agent-runtime/tool-call-execution.d.ts.map +1 -0
- package/dist/services/agent-runtime/tool-call-execution.js +250 -0
- package/dist/services/agent-runtime/tool-call-execution.js.map +1 -0
- package/dist/services/agent-runtime/turn-input-mailbox.d.ts +33 -0
- package/dist/services/agent-runtime/turn-input-mailbox.d.ts.map +1 -0
- package/dist/services/agent-runtime/turn-input-mailbox.js +98 -0
- package/dist/services/agent-runtime/turn-input-mailbox.js.map +1 -0
- package/dist/services/agent-stream.d.ts +2 -0
- package/dist/services/agent-stream.d.ts.map +1 -1
- package/dist/services/agent-stream.js.map +1 -1
- package/dist/services/approval/non-interactive-approval-policy.d.ts +0 -1
- package/dist/services/approval/non-interactive-approval-policy.d.ts.map +1 -1
- package/dist/services/approval/non-interactive-approval-policy.js +1 -1
- package/dist/services/approval/non-interactive-approval-policy.js.map +1 -1
- package/dist/services/approval/session-read-access.d.ts +0 -1
- package/dist/services/approval/session-read-access.d.ts.map +1 -1
- package/dist/services/approval/session-read-access.js +1 -1
- package/dist/services/approval/session-read-access.js.map +1 -1
- package/dist/services/approval/shell-auto-approval-evaluator.d.ts.map +1 -1
- package/dist/services/approval/shell-auto-approval-evaluator.js +2 -4
- package/dist/services/approval/shell-auto-approval-evaluator.js.map +1 -1
- package/dist/services/approval/shell-auto-approval-resolver.d.ts +0 -3
- package/dist/services/approval/shell-auto-approval-resolver.d.ts.map +1 -1
- package/dist/services/approval/shell-auto-approval-resolver.js +3 -7
- package/dist/services/approval/shell-auto-approval-resolver.js.map +1 -1
- package/dist/services/approval/tool-approval-policy-registry.d.ts +1 -0
- package/dist/services/approval/tool-approval-policy-registry.d.ts.map +1 -1
- package/dist/services/approval/tool-approval-policy-registry.js +4 -2
- package/dist/services/approval/tool-approval-policy-registry.js.map +1 -1
- package/dist/services/control-socket/control-command.d.ts +6 -0
- package/dist/services/control-socket/control-command.d.ts.map +1 -0
- package/dist/services/control-socket/control-command.js +161 -0
- package/dist/services/control-socket/control-command.js.map +1 -0
- package/dist/services/control-socket/control-session-port.d.ts +24 -0
- package/dist/services/control-socket/control-session-port.d.ts.map +1 -0
- package/dist/services/control-socket/control-session-port.js +185 -0
- package/dist/services/control-socket/control-session-port.js.map +1 -0
- package/dist/services/control-socket/control-socket.d.ts +130 -0
- package/dist/services/control-socket/control-socket.d.ts.map +1 -0
- package/dist/services/control-socket/control-socket.js +600 -0
- package/dist/services/control-socket/control-socket.js.map +1 -0
- package/dist/services/conversation/conversation-adapter.d.ts +0 -4
- package/dist/services/conversation/conversation-adapter.d.ts.map +1 -1
- package/dist/services/conversation/conversation-adapter.js +1 -1
- package/dist/services/conversation/conversation-adapter.js.map +1 -1
- package/dist/services/conversation/conversation-checkpoint-provenance.d.ts +17 -0
- package/dist/services/conversation/conversation-checkpoint-provenance.d.ts.map +1 -0
- package/dist/services/conversation/conversation-checkpoint-provenance.js +130 -0
- package/dist/services/conversation/conversation-checkpoint-provenance.js.map +1 -0
- package/dist/services/conversation/conversation-decoder.d.ts +4 -0
- package/dist/services/conversation/conversation-decoder.d.ts.map +1 -1
- package/dist/services/conversation/conversation-decoder.js +80 -2
- package/dist/services/conversation/conversation-decoder.js.map +1 -1
- package/dist/services/conversation/conversation-events.d.ts +3 -1
- package/dist/services/conversation/conversation-events.d.ts.map +1 -1
- package/dist/services/conversation/conversation-events.js.map +1 -1
- package/dist/services/conversation/conversation-message-projection.d.ts +0 -1
- package/dist/services/conversation/conversation-message-projection.d.ts.map +1 -1
- package/dist/services/conversation/conversation-message-projection.js +1 -1
- package/dist/services/conversation/conversation-message-projection.js.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.d.ts +9 -0
- package/dist/services/conversation/conversation-orchestrator.d.ts.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.js +111 -29
- package/dist/services/conversation/conversation-orchestrator.js.map +1 -1
- package/dist/services/conversation/conversation-persistence.d.ts +6 -7
- package/dist/services/conversation/conversation-persistence.d.ts.map +1 -1
- package/dist/services/conversation/conversation-persistence.js +74 -39
- package/dist/services/conversation/conversation-persistence.js.map +1 -1
- package/dist/services/conversation/conversation-replay.d.ts +1 -0
- package/dist/services/conversation/conversation-replay.d.ts.map +1 -1
- package/dist/services/conversation/conversation-replay.js +22 -6
- package/dist/services/conversation/conversation-replay.js.map +1 -1
- package/dist/services/conversation/conversation-result-builder.d.ts.map +1 -1
- package/dist/services/conversation/conversation-result-builder.js +7 -1
- package/dist/services/conversation/conversation-result-builder.js.map +1 -1
- package/dist/services/conversation/conversation-runtime-factory.d.ts +0 -2
- package/dist/services/conversation/conversation-runtime-factory.d.ts.map +1 -1
- package/dist/services/conversation/conversation-runtime-factory.js.map +1 -1
- package/dist/services/conversation/conversation-service.d.ts +6 -0
- package/dist/services/conversation/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation/conversation-service.js +6 -2
- package/dist/services/conversation/conversation-service.js.map +1 -1
- package/dist/services/conversation/conversation-state-projector.d.ts +0 -1
- package/dist/services/conversation/conversation-state-projector.d.ts.map +1 -1
- package/dist/services/conversation/conversation-state-projector.js +1 -1
- package/dist/services/conversation/conversation-state-projector.js.map +1 -1
- package/dist/services/conversation/conversation-state-schema.d.ts +0 -20
- package/dist/services/conversation/conversation-state-schema.d.ts.map +1 -1
- package/dist/services/conversation/conversation-state-schema.js +1 -1
- package/dist/services/conversation/conversation-state-schema.js.map +1 -1
- package/dist/services/conversation/conversation-turn-items.d.ts +0 -10
- package/dist/services/conversation/conversation-turn-items.d.ts.map +1 -1
- package/dist/services/conversation/conversation-turn-items.js +4 -13
- package/dist/services/conversation/conversation-turn-items.js.map +1 -1
- package/dist/services/conversation/durable-goal.d.ts +4 -0
- package/dist/services/conversation/durable-goal.d.ts.map +1 -0
- package/dist/services/conversation/durable-goal.js +21 -0
- package/dist/services/conversation/durable-goal.js.map +1 -0
- package/dist/services/conversation/local-checkpoint-projection.d.ts +18 -0
- package/dist/services/conversation/local-checkpoint-projection.d.ts.map +1 -0
- package/dist/services/conversation/local-checkpoint-projection.js +230 -0
- package/dist/services/conversation/local-checkpoint-projection.js.map +1 -0
- package/dist/services/conversation/run-item-normalizer.d.ts.map +1 -1
- package/dist/services/conversation/run-item-normalizer.js +7 -1
- package/dist/services/conversation/run-item-normalizer.js.map +1 -1
- package/dist/services/conversation/semantic-replay-classification.d.ts +11 -0
- package/dist/services/conversation/semantic-replay-classification.d.ts.map +1 -0
- package/dist/services/conversation/semantic-replay-classification.js +13 -0
- package/dist/services/conversation/semantic-replay-classification.js.map +1 -0
- package/dist/services/conversation/semantic-replay-projection.d.ts +20 -0
- package/dist/services/conversation/semantic-replay-projection.d.ts.map +1 -0
- package/dist/services/conversation/semantic-replay-projection.js +145 -0
- package/dist/services/conversation/semantic-replay-projection.js.map +1 -0
- package/dist/services/conversation/session-browser.d.ts +10 -2
- package/dist/services/conversation/session-browser.d.ts.map +1 -1
- package/dist/services/conversation/session-browser.js +27 -5
- package/dist/services/conversation/session-browser.js.map +1 -1
- package/dist/services/conversation/session-index/session-index-database.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-database.js +40 -28
- package/dist/services/conversation/session-index/session-index-database.js.map +1 -1
- package/dist/services/conversation/session-index/session-index-schema.d.ts +1 -2
- package/dist/services/conversation/session-index/session-index-schema.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-schema.js +3 -2
- package/dist/services/conversation/session-index/session-index-schema.js.map +1 -1
- package/dist/services/conversation/session-index/session-index-service.d.ts +0 -1
- package/dist/services/conversation/session-index/session-index-service.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-service.js +1 -1
- package/dist/services/conversation/session-index/session-index-service.js.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker-client.d.ts +0 -1
- package/dist/services/conversation/session-index/session-index-worker-client.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker-client.js +1 -1
- package/dist/services/conversation/session-index/session-index-worker-client.js.map +1 -1
- package/dist/services/conversation/session-log-lifecycle.d.ts +5 -0
- package/dist/services/conversation/session-log-lifecycle.d.ts.map +1 -0
- package/dist/services/conversation/session-log-lifecycle.js +7 -0
- package/dist/services/conversation/session-log-lifecycle.js.map +1 -0
- package/dist/services/decision-shadow/decision-client.d.ts +0 -1
- package/dist/services/decision-shadow/decision-client.d.ts.map +1 -1
- package/dist/services/decision-shadow/decision-client.js +1 -1
- package/dist/services/decision-shadow/decision-client.js.map +1 -1
- package/dist/services/file-service.d.ts +0 -2
- package/dist/services/file-service.d.ts.map +1 -1
- package/dist/services/file-service.js +1 -2
- package/dist/services/file-service.js.map +1 -1
- package/dist/services/hooks/hook-contracts.d.ts +2 -4
- package/dist/services/hooks/hook-contracts.d.ts.map +1 -1
- package/dist/services/hooks/hook-contracts.js +3 -4
- package/dist/services/hooks/hook-contracts.js.map +1 -1
- package/dist/services/hooks/hook-discovery.d.ts +0 -1
- package/dist/services/hooks/hook-discovery.d.ts.map +1 -1
- package/dist/services/hooks/hook-discovery.js +0 -1
- package/dist/services/hooks/hook-discovery.js.map +1 -1
- package/dist/services/hooks/hook-editor-shim.d.ts +0 -2
- package/dist/services/hooks/hook-editor-shim.d.ts.map +1 -1
- package/dist/services/hooks/hook-editor-shim.js +2 -2
- package/dist/services/hooks/hook-editor-shim.js.map +1 -1
- package/dist/services/hooks/hook-module-loader.d.ts +0 -3
- package/dist/services/hooks/hook-module-loader.d.ts.map +1 -1
- package/dist/services/hooks/hook-module-loader.js +0 -1
- package/dist/services/hooks/hook-module-loader.js.map +1 -1
- package/dist/services/hooks/hook-registry.d.ts +0 -1
- package/dist/services/hooks/hook-registry.d.ts.map +1 -1
- package/dist/services/hooks/hook-registry.js +1 -1
- package/dist/services/hooks/hook-registry.js.map +1 -1
- package/dist/services/input-surge-guard.d.ts +0 -1
- package/dist/services/input-surge-guard.d.ts.map +1 -1
- package/dist/services/input-surge-guard.js +1 -1
- package/dist/services/input-surge-guard.js.map +1 -1
- package/dist/services/logging/conversation-log-events.d.ts +41 -2
- package/dist/services/logging/conversation-log-events.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.js.map +1 -1
- package/dist/services/logging/conversation-log-writer.d.ts +3 -11
- package/dist/services/logging/conversation-log-writer.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-writer.js +51 -45
- package/dist/services/logging/conversation-log-writer.js.map +1 -1
- package/dist/services/logging/conversation-logger.d.ts +4 -1
- package/dist/services/logging/conversation-logger.d.ts.map +1 -1
- package/dist/services/logging/conversation-logger.js +22 -2
- package/dist/services/logging/conversation-logger.js.map +1 -1
- package/dist/services/logging/provider-traffic.d.ts +0 -7
- package/dist/services/logging/provider-traffic.d.ts.map +1 -1
- package/dist/services/logging/provider-traffic.js +3 -3
- package/dist/services/logging/provider-traffic.js.map +1 -1
- package/dist/services/mcp/mcp-oauth-provider.d.ts +0 -2
- package/dist/services/mcp/mcp-oauth-provider.d.ts.map +1 -1
- package/dist/services/mcp/mcp-oauth-provider.js +1 -1
- package/dist/services/mcp/mcp-oauth-provider.js.map +1 -1
- package/dist/services/mcp/mcp-oauth-store.d.ts +0 -21
- package/dist/services/mcp/mcp-oauth-store.d.ts.map +1 -1
- package/dist/services/mcp/mcp-oauth-store.js +2 -2
- package/dist/services/mcp/mcp-oauth-store.js.map +1 -1
- package/dist/services/mcp/mcp-status.d.ts +0 -7
- package/dist/services/mcp/mcp-status.d.ts.map +1 -1
- package/dist/services/mcp/mcp-status.js +1 -1
- package/dist/services/mcp/mcp-status.js.map +1 -1
- package/dist/services/memory/memory-capabilities.d.ts +7 -0
- package/dist/services/memory/memory-capabilities.d.ts.map +1 -1
- package/dist/services/memory/memory-capabilities.js +9 -19
- package/dist/services/memory/memory-capabilities.js.map +1 -1
- package/dist/services/memory/memory-search.d.ts +0 -1
- package/dist/services/memory/memory-search.d.ts.map +1 -1
- package/dist/services/memory/memory-search.js +1 -1
- package/dist/services/memory/memory-search.js.map +1 -1
- package/dist/services/memory/memory-store.d.ts +0 -10
- package/dist/services/memory/memory-store.d.ts.map +1 -1
- package/dist/services/memory/memory-store.js +1 -1
- package/dist/services/memory/memory-store.js.map +1 -1
- package/dist/services/models/model-nicknames.d.ts +0 -16
- package/dist/services/models/model-nicknames.d.ts.map +1 -1
- package/dist/services/models/model-nicknames.js +1 -1
- package/dist/services/models/model-nicknames.js.map +1 -1
- package/dist/services/models/model-resolution.js +2 -2
- package/dist/services/models/model-resolution.js.map +1 -1
- package/dist/services/profiles/profile-transition.d.ts +0 -2
- package/dist/services/profiles/profile-transition.d.ts.map +1 -1
- package/dist/services/profiles/profile-transition.js +1 -1
- package/dist/services/profiles/profile-transition.js.map +1 -1
- package/dist/services/profiles/registry.d.ts +1 -11
- package/dist/services/profiles/registry.d.ts.map +1 -1
- package/dist/services/profiles/registry.js +6 -12
- package/dist/services/profiles/registry.js.map +1 -1
- package/dist/services/profiles/resolver.d.ts +1 -7
- package/dist/services/profiles/resolver.d.ts.map +1 -1
- package/dist/services/profiles/resolver.js +0 -45
- package/dist/services/profiles/resolver.js.map +1 -1
- package/dist/services/profiles/schema.d.ts +0 -950
- package/dist/services/profiles/schema.d.ts.map +1 -1
- package/dist/services/profiles/schema.js +5 -5
- package/dist/services/profiles/schema.js.map +1 -1
- package/dist/services/retry/conversation-retry-policy.d.ts +0 -5
- package/dist/services/retry/conversation-retry-policy.d.ts.map +1 -1
- package/dist/services/retry/conversation-retry-policy.js +0 -3
- package/dist/services/retry/conversation-retry-policy.js.map +1 -1
- package/dist/services/retry/retry-recovery-budget.d.ts +0 -10
- package/dist/services/retry/retry-recovery-budget.d.ts.map +1 -1
- package/dist/services/retry/retry-recovery-budget.js +1 -1
- package/dist/services/retry/retry-recovery-budget.js.map +1 -1
- package/dist/services/runtime-setting-router.d.ts +0 -1
- package/dist/services/runtime-setting-router.d.ts.map +1 -1
- package/dist/services/runtime-setting-router.js +1 -1
- package/dist/services/runtime-setting-router.js.map +1 -1
- package/dist/services/session/background-task-control.d.ts +1 -1
- package/dist/services/session/background-task-control.d.ts.map +1 -1
- package/dist/services/session/background-task-control.js +1 -1
- package/dist/services/session/background-task-control.js.map +1 -1
- package/dist/services/session/initial-input-preparer.d.ts.map +1 -1
- package/dist/services/session/initial-input-preparer.js +32 -0
- package/dist/services/session/initial-input-preparer.js.map +1 -1
- package/dist/services/session/pending-interaction-state.d.ts +6 -0
- package/dist/services/session/pending-interaction-state.d.ts.map +1 -1
- package/dist/services/session/pending-interaction-state.js +1 -1
- package/dist/services/session/pending-interaction-state.js.map +1 -1
- package/dist/services/session/session-client-factory.d.ts +1 -11
- package/dist/services/session/session-client-factory.d.ts.map +1 -1
- package/dist/services/session/session-client-factory.js +1 -6
- package/dist/services/session/session-client-factory.js.map +1 -1
- package/dist/services/session/session-composition.d.ts +11 -3
- package/dist/services/session/session-composition.d.ts.map +1 -1
- package/dist/services/session/session-composition.js +44 -8
- package/dist/services/session/session-composition.js.map +1 -1
- package/dist/services/session/session-input-planner.d.ts +5 -0
- package/dist/services/session/session-input-planner.d.ts.map +1 -1
- package/dist/services/session/session-input-planner.js +36 -0
- package/dist/services/session/session-input-planner.js.map +1 -1
- package/dist/services/session/session-stream-processor.d.ts.map +1 -1
- package/dist/services/session/session-stream-processor.js +6 -2
- package/dist/services/session/session-stream-processor.js.map +1 -1
- package/dist/services/session/turn-workflow.d.ts +0 -3
- package/dist/services/session/turn-workflow.d.ts.map +1 -1
- package/dist/services/session/turn-workflow.js +15 -37
- package/dist/services/session/turn-workflow.js.map +1 -1
- package/dist/services/session-rollover/session-rollover-brief.d.ts +0 -1
- package/dist/services/session-rollover/session-rollover-brief.d.ts.map +1 -1
- package/dist/services/session-rollover/session-rollover-brief.js +1 -1
- package/dist/services/session-rollover/session-rollover-brief.js.map +1 -1
- package/dist/services/settings/custom-provider-normalization.d.ts +0 -1
- package/dist/services/settings/custom-provider-normalization.d.ts.map +1 -1
- package/dist/services/settings/custom-provider-normalization.js +1 -1
- package/dist/services/settings/custom-provider-normalization.js.map +1 -1
- package/dist/services/settings/setting-schema-utils.d.ts +0 -2
- package/dist/services/settings/setting-schema-utils.d.ts.map +1 -1
- package/dist/services/settings/setting-schema-utils.js +0 -11
- package/dist/services/settings/setting-schema-utils.js.map +1 -1
- package/dist/services/settings/settings-merger.d.ts +0 -4
- package/dist/services/settings/settings-merger.d.ts.map +1 -1
- package/dist/services/settings/settings-merger.js +1 -1
- package/dist/services/settings/settings-merger.js.map +1 -1
- package/dist/services/settings/settings-schema.d.ts +41 -25
- package/dist/services/settings/settings-schema.d.ts.map +1 -1
- package/dist/services/settings/settings-schema.js +11 -5
- package/dist/services/settings/settings-schema.js.map +1 -1
- package/dist/services/settings/settings-ui-metadata.d.ts +0 -5
- package/dist/services/settings/settings-ui-metadata.d.ts.map +1 -1
- package/dist/services/settings/settings-ui-metadata.js +2 -2
- package/dist/services/settings/settings-ui-metadata.js.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts +0 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js +0 -44
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js.map +1 -1
- package/dist/services/ssh-service.d.ts +0 -23
- package/dist/services/ssh-service.d.ts.map +1 -1
- package/dist/services/ssh-service.js +1 -1
- package/dist/services/ssh-service.js.map +1 -1
- package/dist/services/subagents/role-loader.d.ts +0 -6
- package/dist/services/subagents/role-loader.d.ts.map +1 -1
- package/dist/services/subagents/role-loader.js +12 -6
- package/dist/services/subagents/role-loader.js.map +1 -1
- package/dist/services/subagents/subagent-notification-store.d.ts +0 -2
- package/dist/services/subagents/subagent-notification-store.d.ts.map +1 -1
- package/dist/services/subagents/subagent-notification-store.js +1 -1
- package/dist/services/subagents/subagent-notification-store.js.map +1 -1
- package/dist/services/subagents/subagent-pool-config.d.ts +0 -21
- package/dist/services/subagents/subagent-pool-config.d.ts.map +1 -1
- package/dist/services/subagents/subagent-pool-config.js +2 -2
- package/dist/services/subagents/subagent-pool-config.js.map +1 -1
- package/dist/services/subagents/subagent-role-pool-selector.d.ts +5 -4
- package/dist/services/subagents/subagent-role-pool-selector.d.ts.map +1 -1
- package/dist/services/subagents/subagent-role-pool-selector.js +16 -11
- package/dist/services/subagents/subagent-role-pool-selector.js.map +1 -1
- package/dist/services/subagents/tool-policy.d.ts +0 -1
- package/dist/services/subagents/tool-policy.d.ts.map +1 -1
- package/dist/services/subagents/tool-policy.js +1 -1
- package/dist/services/subagents/tool-policy.js.map +1 -1
- package/dist/services/subagents/types.d.ts +1 -2
- package/dist/services/subagents/types.d.ts.map +1 -1
- package/dist/services/subagents/types.js +0 -1
- package/dist/services/subagents/types.js.map +1 -1
- package/dist/services/subagents/utils.d.ts +0 -3
- package/dist/services/subagents/utils.d.ts.map +1 -1
- package/dist/services/subagents/utils.js +3 -3
- package/dist/services/subagents/utils.js.map +1 -1
- package/dist/services/tool-call-arguments.d.ts +0 -1
- package/dist/services/tool-call-arguments.d.ts.map +1 -1
- package/dist/services/tool-call-arguments.js +0 -15
- package/dist/services/tool-call-arguments.js.map +1 -1
- package/dist/services/tool-execution-ledger.d.ts +0 -4
- package/dist/services/tool-execution-ledger.d.ts.map +1 -1
- package/dist/services/tool-execution-ledger.js +3 -3
- package/dist/services/tool-execution-ledger.js.map +1 -1
- package/dist/services/tool-toggles.d.ts +0 -1
- package/dist/services/tool-toggles.d.ts.map +1 -1
- package/dist/services/tool-toggles.js +0 -3
- package/dist/services/tool-toggles.js.map +1 -1
- package/dist/services/workspace/active-workspace-root.d.ts +0 -4
- package/dist/services/workspace/active-workspace-root.d.ts.map +1 -1
- package/dist/services/workspace/active-workspace-root.js +1 -1
- package/dist/services/workspace/active-workspace-root.js.map +1 -1
- package/dist/services/workspace/worktree-transition.d.ts +0 -2
- package/dist/services/workspace/worktree-transition.d.ts.map +1 -1
- package/dist/services/workspace/worktree-transition.js +1 -1
- package/dist/services/workspace/worktree-transition.js.map +1 -1
- package/dist/tools/agent/ask-user-constants.d.ts +0 -2
- package/dist/tools/agent/ask-user-constants.d.ts.map +1 -1
- package/dist/tools/agent/ask-user-constants.js +0 -2
- package/dist/tools/agent/ask-user-constants.js.map +1 -1
- package/dist/tools/file/apply-patch.d.ts +0 -4
- package/dist/tools/file/apply-patch.d.ts.map +1 -1
- package/dist/tools/file/apply-patch.js +3 -5
- package/dist/tools/file/apply-patch.js.map +1 -1
- package/dist/tools/file/glob.d.ts +1 -2
- package/dist/tools/file/glob.d.ts.map +1 -1
- package/dist/tools/file/glob.js +0 -1
- package/dist/tools/file/glob.js.map +1 -1
- package/dist/tools/file/grep.d.ts +1 -2
- package/dist/tools/file/grep.d.ts.map +1 -1
- package/dist/tools/file/grep.js +1 -3
- package/dist/tools/file/grep.js.map +1 -1
- package/dist/tools/file/search-replace.d.ts.map +1 -1
- package/dist/tools/file/search-replace.js +3 -4
- package/dist/tools/file/search-replace.js.map +1 -1
- package/dist/tools/session-browser/session-browser-tools.js +1 -1
- package/dist/tools/session-browser/session-browser-tools.js.map +1 -1
- package/dist/tools/session-rollover/session-rollover-tool.d.ts.map +1 -1
- package/dist/tools/session-rollover/session-rollover-tool.js +4 -1
- package/dist/tools/session-rollover/session-rollover-tool.js.map +1 -1
- package/dist/tools/system/run-code/index.d.ts +4 -4
- package/dist/tools/system/run-code/index.d.ts.map +1 -1
- package/dist/tools/system/run-code/index.js +1 -4
- package/dist/tools/system/run-code/index.js.map +1 -1
- package/dist/tools/system/run-code/run-code-execution.d.ts +1 -0
- package/dist/tools/system/run-code/run-code-execution.d.ts.map +1 -1
- package/dist/tools/system/run-code/run-code-execution.js.map +1 -1
- package/dist/tools/system/run-code/run-code-runtime-contract.d.ts +1 -0
- package/dist/tools/system/run-code/run-code-runtime-contract.d.ts.map +1 -1
- package/dist/tools/system/run-code/run-code-runtime.d.ts +0 -3
- package/dist/tools/system/run-code/run-code-runtime.d.ts.map +1 -1
- package/dist/tools/system/run-code/run-code-runtime.js +7 -6
- package/dist/tools/system/run-code/run-code-runtime.js.map +1 -1
- package/dist/tools/system/run-code/run-code.d.ts +1 -1
- package/dist/tools/system/run-code/run-code.d.ts.map +1 -1
- package/dist/tools/system/run-code/run-code.js +5 -1
- package/dist/tools/system/run-code/run-code.js.map +1 -1
- package/dist/tools/system/shell.d.ts +1 -2
- package/dist/tools/system/shell.d.ts.map +1 -1
- package/dist/tools/system/shell.js +5 -4
- package/dist/tools/system/shell.js.map +1 -1
- package/dist/tools/system/worktree.d.ts +2 -2
- package/dist/tools/system/worktree.d.ts.map +1 -1
- package/dist/tools/system/worktree.js +1 -2
- package/dist/tools/system/worktree.js.map +1 -1
- package/dist/tools/types.d.ts +1 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/types/message.d.ts +0 -1
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js +0 -1
- package/dist/types/message.js.map +1 -1
- package/dist/types/user-turn.d.ts +6 -0
- package/dist/types/user-turn.d.ts.map +1 -1
- package/dist/types/user-turn.js +1 -0
- package/dist/types/user-turn.js.map +1 -1
- package/dist/utils/conversation/conversation-utils.d.ts.map +1 -1
- package/dist/utils/conversation/conversation-utils.js +1 -2
- package/dist/utils/conversation/conversation-utils.js.map +1 -1
- package/dist/utils/conversation/static-commit-policy.d.ts.map +1 -1
- package/dist/utils/conversation/static-commit-policy.js +1 -0
- package/dist/utils/conversation/static-commit-policy.js.map +1 -1
- package/dist/utils/ink-render-options.d.ts +1 -0
- package/dist/utils/ink-render-options.d.ts.map +1 -1
- package/dist/utils/ink-render-options.js +1 -1
- package/dist/utils/ink-render-options.js.map +1 -1
- package/dist/utils/output/log-truncation.d.ts +0 -1
- package/dist/utils/output/log-truncation.d.ts.map +1 -1
- package/dist/utils/output/log-truncation.js +0 -3
- package/dist/utils/output/log-truncation.js.map +1 -1
- package/dist/utils/project-scope.d.ts +16 -0
- package/dist/utils/project-scope.d.ts.map +1 -0
- package/dist/utils/project-scope.js +62 -0
- package/dist/utils/project-scope.js.map +1 -0
- package/dist/utils/settings-command.d.ts.map +1 -1
- package/dist/utils/settings-command.js +5 -3
- package/dist/utils/settings-command.js.map +1 -1
- package/dist/utils/shell/sandbox/docker-host-control-grants.d.ts +0 -2
- package/dist/utils/shell/sandbox/docker-host-control-grants.d.ts.map +1 -1
- package/dist/utils/shell/sandbox/docker-host-control-grants.js +0 -1
- package/dist/utils/shell/sandbox/docker-host-control-grants.js.map +1 -1
- package/dist/utils/shell/temp-dir.d.ts +0 -1
- package/dist/utils/shell/temp-dir.d.ts.map +1 -1
- package/dist/utils/shell/temp-dir.js +0 -4
- package/dist/utils/shell/temp-dir.js.map +1 -1
- package/dist/utils/slash-command-dispatch.d.ts +1 -1
- package/dist/utils/slash-command-dispatch.d.ts.map +1 -1
- package/dist/utils/slash-command-dispatch.js +35 -3
- package/dist/utils/slash-command-dispatch.js.map +1 -1
- package/dist/utils/streaming/streaming-speed-tracker.d.ts +0 -9
- package/dist/utils/streaming/streaming-speed-tracker.d.ts.map +1 -1
- package/dist/utils/streaming/streaming-speed-tracker.js +1 -1
- package/dist/utils/streaming/streaming-speed-tracker.js.map +1 -1
- package/dist/utils/value-suggestions.d.ts +6 -0
- package/dist/utils/value-suggestions.d.ts.map +1 -1
- package/dist/utils/value-suggestions.js +23 -6
- package/dist/utils/value-suggestions.js.map +1 -1
- package/package.json +2 -3
- package/dist/gateway/index.d.ts +0 -22
- package/dist/gateway/index.d.ts.map +0 -1
- package/dist/gateway/index.js +0 -22
- package/dist/gateway/index.js.map +0 -1
- package/dist/providers/openrouter.d.ts +0 -2
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js +0 -2
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/services/agent-runtime/internal.d.ts +0 -15
- package/dist/services/agent-runtime/internal.d.ts.map +0 -1
- package/dist/services/agent-runtime/internal.js +0 -13
- package/dist/services/agent-runtime/internal.js.map +0 -1
- package/dist/services/openai-root-selector-parity-observer.d.ts +0 -53
- package/dist/services/openai-root-selector-parity-observer.d.ts.map +0 -1
- package/dist/services/openai-root-selector-parity-observer.js +0 -62
- package/dist/services/openai-root-selector-parity-observer.js.map +0 -1
|
@@ -3,8 +3,7 @@ import { createContinuationHandle, unwrapContinuationHandle, } from '../../contr
|
|
|
3
3
|
import { createAgentStream } from '../agent-stream.js';
|
|
4
4
|
import { getRunCodeExecutionResult, runCodeExecutionMetadata } from '../../tools/system/run-code/run-code-execution.js';
|
|
5
5
|
import { isZodToolParameterSchema } from '../../tools/types.js';
|
|
6
|
-
import {
|
|
7
|
-
import { isCancellationError, isHarnessInvariantError } from '../../lib/harness-invariant-error.js';
|
|
6
|
+
import { describeError } from '../../utils/error-helpers.js';
|
|
8
7
|
import { ApprovalLedger } from './tool-invocation-context.js';
|
|
9
8
|
import { RunBudget, isRunBudgetInteraction, } from './run-budget.js';
|
|
10
9
|
import { addTokenUsage, normalizeUsage } from '../../utils/ai/token-usage.js';
|
|
@@ -14,6 +13,8 @@ import { getCatalogPricingVersion, getModelPricing } from '../../services/cost/p
|
|
|
14
13
|
import { DEFAULT_TOOL_ARGUMENT_RUNAWAY_SIGNATURE, GenerationGuard, GenerationGuardError, GenerationStreamDeadlines, ToolArgumentRunawayGuard, } from './generation-guard.js';
|
|
15
14
|
import { classifyInLoopModelRetry, sleepWithAbort } from '../retry/in-loop-model-retry.js';
|
|
16
15
|
import { buildFailureObservation } from '../decision-shadow/failure-observation.js';
|
|
16
|
+
import { TurnInputMailbox } from './turn-input-mailbox.js';
|
|
17
|
+
import { ToolCallExecution } from './tool-call-execution.js';
|
|
17
18
|
/**
|
|
18
19
|
* Tool results may carry provider-neutral content parts (for example the
|
|
19
20
|
* image returned by read_file). Preserve only the known multimodal shape;
|
|
@@ -83,8 +84,6 @@ class EventQueue {
|
|
|
83
84
|
* turns and silently drop later turns' records.
|
|
84
85
|
*/
|
|
85
86
|
let nextCostRequestSeq = 0;
|
|
86
|
-
let nextToolBatchSeq = 0;
|
|
87
|
-
const DEFAULT_MAX_PARALLEL_TOOL_CALLS = 3;
|
|
88
87
|
/**
|
|
89
88
|
* Small provider-neutral agent loop. It owns model-turn sequencing and tool
|
|
90
89
|
* execution; providers only implement `StreamedModelTurn`.
|
|
@@ -92,33 +91,15 @@ const DEFAULT_MAX_PARALLEL_TOOL_CALLS = 3;
|
|
|
92
91
|
export class ApplicationRunLoop {
|
|
93
92
|
#deps;
|
|
94
93
|
#contextCompactionSessionState;
|
|
94
|
+
#turnInputMailbox;
|
|
95
95
|
#activeAbortController = null;
|
|
96
|
-
#runInFlight = false;
|
|
97
96
|
#segmentGeneration = 0;
|
|
98
|
-
/**
|
|
99
|
-
* Set when a segment ends holding approvals, meaning the turn is pausing
|
|
100
|
-
* rather than finishing. Injections offered during the pause wait here for
|
|
101
|
-
* the continuation segment instead of being refused for want of a run.
|
|
102
|
-
*/
|
|
103
|
-
#turnPaused = false;
|
|
104
|
-
/**
|
|
105
|
-
* Set while a caller that owns turn boundaries has a turn open, from before
|
|
106
|
-
* its first request is built until after its last one settles.
|
|
107
|
-
*
|
|
108
|
-
* `#runInFlight` and `#turnPaused` only ever describe a *segment*, so between
|
|
109
|
-
* them they leave every gap in a turn where no run exists yet: the startup
|
|
110
|
-
* before the first request (provider model discovery, hooks, input
|
|
111
|
-
* preparation) and the backoff before a retry restarts the stream. A turn is
|
|
112
|
-
* steerable across those gaps, and only the caller that opened the turn knows
|
|
113
|
-
* they belong to it.
|
|
114
|
-
*/
|
|
115
|
-
#turnOpen = false;
|
|
116
|
-
#pendingSteers = [];
|
|
117
97
|
/** The run whose budget an out-of-band grant applies to, held across a pause. */
|
|
118
98
|
#activeRunBudgetState;
|
|
119
99
|
constructor(deps) {
|
|
120
100
|
this.#deps = deps;
|
|
121
101
|
this.#contextCompactionSessionState = deps.contextCompactionSessionState ?? { disabled: false };
|
|
102
|
+
this.#turnInputMailbox = new TurnInputMailbox((message, meta) => this.#deps.logDiagnostic?.(message, meta));
|
|
122
103
|
}
|
|
123
104
|
#observeTerminalFailure(error, request) {
|
|
124
105
|
this.#observeDecisionShadow('failure_triage', () => {
|
|
@@ -147,25 +128,19 @@ export class ApplicationRunLoop {
|
|
|
147
128
|
* be admitted now.
|
|
148
129
|
*/
|
|
149
130
|
openTurn() {
|
|
150
|
-
this.#
|
|
151
|
-
this.#turnOpen = true;
|
|
152
|
-
this.#turnPaused = false;
|
|
131
|
+
this.#turnInputMailbox.openTurn();
|
|
153
132
|
}
|
|
154
133
|
/**
|
|
155
134
|
* Declare the turn over. Whatever is still waiting had no boundary left, so
|
|
156
135
|
* it is handed back for the caller to send as its own turn.
|
|
157
136
|
*/
|
|
158
137
|
closeTurn() {
|
|
159
|
-
this.#
|
|
160
|
-
this.#turnPaused = false;
|
|
161
|
-
this.#releasePendingSteers({ reason: 'turn_closed' });
|
|
138
|
+
this.#turnInputMailbox.closeTurn();
|
|
162
139
|
}
|
|
163
140
|
abort() {
|
|
164
141
|
this.abortSegment();
|
|
165
142
|
// An aborted turn will not resume, so nothing may keep waiting on it.
|
|
166
|
-
this.#
|
|
167
|
-
this.#turnPaused = false;
|
|
168
|
-
this.#releasePendingSteers({ reason: 'aborted' });
|
|
143
|
+
this.#turnInputMailbox.abortTurn();
|
|
169
144
|
}
|
|
170
145
|
/**
|
|
171
146
|
* Stop the segment currently streaming without judging the turn's fate.
|
|
@@ -209,6 +184,15 @@ export class ApplicationRunLoop {
|
|
|
209
184
|
return true;
|
|
210
185
|
return state.runBudget.grantExtension('parent').granted;
|
|
211
186
|
}
|
|
187
|
+
#createToolCallExecution() {
|
|
188
|
+
return new ToolCallExecution({
|
|
189
|
+
toolLifecycle: this.#deps.toolLifecycle,
|
|
190
|
+
getOnToolDispatch: this.#deps.getOnToolDispatch,
|
|
191
|
+
resolveMaxParallelToolCalls: this.#deps.resolveMaxParallelToolCalls,
|
|
192
|
+
isMaxTurnsExceeded: (error) => error instanceof MaxTurnsExceededError,
|
|
193
|
+
logDiagnostic: this.#deps.logDiagnostic,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
212
196
|
/**
|
|
213
197
|
* Hand the running turn a user message to send with its next model request.
|
|
214
198
|
*
|
|
@@ -234,32 +218,21 @@ export class ApplicationRunLoop {
|
|
|
234
218
|
* only released or admitted.
|
|
235
219
|
*/
|
|
236
220
|
steer(items, options) {
|
|
237
|
-
|
|
238
|
-
return Promise.resolve('released');
|
|
239
|
-
if (!this.#turnOpen && !this.#runInFlight && !this.#turnPaused)
|
|
240
|
-
return Promise.resolve('released');
|
|
241
|
-
return new Promise((resolve) => {
|
|
242
|
-
this.#pendingSteers.push({ id: options?.id, items, resolve });
|
|
243
|
-
});
|
|
221
|
+
return this.#turnInputMailbox.offer(items, options);
|
|
244
222
|
}
|
|
245
223
|
/**
|
|
246
224
|
* Drop a still-waiting steer before it reaches a request boundary. Returns
|
|
247
225
|
* `false` when the id is unknown, including when it was already admitted.
|
|
248
226
|
*
|
|
249
|
-
* Invariant: this and
|
|
250
|
-
* latter drains
|
|
227
|
+
* Invariant: this and `TurnInputMailbox.admitAtRequestBoundary` are both synchronous,
|
|
228
|
+
* and the latter drains the mailbox in a single pass — so the two can never
|
|
251
229
|
* interleave. A retraction is decided in the same tick against whatever is
|
|
252
|
-
* currently
|
|
230
|
+
* currently pending; once an item has been admitted it is no
|
|
253
231
|
* longer in that array for this method to find. No locking is needed to
|
|
254
232
|
* close the race between "the user retracts" and "the turn admits".
|
|
255
233
|
*/
|
|
256
234
|
retractSteer(id) {
|
|
257
|
-
|
|
258
|
-
if (index < 0)
|
|
259
|
-
return false;
|
|
260
|
-
const [steer] = this.#pendingSteers.splice(index, 1);
|
|
261
|
-
steer.resolve('retracted');
|
|
262
|
-
return true;
|
|
235
|
+
return this.#turnInputMailbox.retract(id);
|
|
263
236
|
}
|
|
264
237
|
/**
|
|
265
238
|
* Replace a waiting steer's items in place, keeping its position (and thus
|
|
@@ -268,21 +241,7 @@ export class ApplicationRunLoop {
|
|
|
268
241
|
* same synchronicity invariant as `retractSteer`.
|
|
269
242
|
*/
|
|
270
243
|
editSteer(id, items) {
|
|
271
|
-
|
|
272
|
-
if (index < 0)
|
|
273
|
-
return false;
|
|
274
|
-
this.#pendingSteers[index] = { ...this.#pendingSteers[index], items };
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
/** Settle every steer this run did not admit so callers stop waiting on it. */
|
|
278
|
-
#releasePendingSteers(reason = {}) {
|
|
279
|
-
const pending = this.#pendingSteers;
|
|
280
|
-
this.#pendingSteers = [];
|
|
281
|
-
if (pending.length > 0) {
|
|
282
|
-
this.#deps.logDiagnostic?.('Steer released at run end', { released: pending.length, ...reason });
|
|
283
|
-
}
|
|
284
|
-
for (const steer of pending)
|
|
285
|
-
steer.resolve('released');
|
|
244
|
+
return this.#turnInputMailbox.edit(id, items);
|
|
286
245
|
}
|
|
287
246
|
/**
|
|
288
247
|
* Append waiting steers to the turn as ordinary user messages.
|
|
@@ -291,24 +250,6 @@ export class ApplicationRunLoop {
|
|
|
291
250
|
* folded into a tool result — so the provider sees the user speaking after
|
|
292
251
|
* the tool results of the round that was in flight when they typed.
|
|
293
252
|
*/
|
|
294
|
-
#admitPendingSteers(state, stream, queue) {
|
|
295
|
-
if (this.#pendingSteers.length === 0)
|
|
296
|
-
return;
|
|
297
|
-
const admitted = this.#pendingSteers;
|
|
298
|
-
this.#pendingSteers = [];
|
|
299
|
-
this.#deps.logDiagnostic?.('Steer admitted at request boundary', {
|
|
300
|
-
admitted: admitted.length,
|
|
301
|
-
turnCount: state.turnCount,
|
|
302
|
-
});
|
|
303
|
-
for (const steer of admitted) {
|
|
304
|
-
for (const item of steer.items) {
|
|
305
|
-
state.history.push(item);
|
|
306
|
-
state.input.push(...normalizeApplicationInput([item]));
|
|
307
|
-
outputPush(stream, queue, { type: 'item', item });
|
|
308
|
-
}
|
|
309
|
-
steer.resolve('admitted');
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
253
|
startStream(agent, input, options = {}) {
|
|
313
254
|
// Without a declared turn scope, a fresh stream is the only evidence this
|
|
314
255
|
// loop gets that a new turn has begun: anything still waiting belonged to
|
|
@@ -316,14 +257,15 @@ export class ApplicationRunLoop {
|
|
|
316
257
|
// With one, this call may equally be the same turn restarting after a
|
|
317
258
|
// retry, which the loop cannot tell apart — so `openTurn`/`closeTurn` own
|
|
318
259
|
// the decision instead.
|
|
319
|
-
this.#
|
|
320
|
-
if (!this.#turnOpen)
|
|
321
|
-
this.#releasePendingSteers({ reason: 'superseded_by_new_turn' });
|
|
260
|
+
this.#turnInputMailbox.startStream();
|
|
322
261
|
const state = {
|
|
323
262
|
agent,
|
|
263
|
+
toolExecution: this.#createToolCallExecution(),
|
|
324
264
|
recoveryBudget: options.recoveryBudget,
|
|
325
265
|
input: normalizeInput(input),
|
|
326
266
|
history: normalizeHistory(input),
|
|
267
|
+
compactionHistory: options.compactionHistory,
|
|
268
|
+
usesDeltaHistory: Boolean(options.previousResponseId) && options.disableChainingForAttempt !== true,
|
|
327
269
|
// A response ID is usable only after its provider origin is recorded.
|
|
328
270
|
// This also makes old callers that omit providerId fail closed.
|
|
329
271
|
responseId: options.disableChainingForAttempt !== true &&
|
|
@@ -331,7 +273,6 @@ export class ApplicationRunLoop {
|
|
|
331
273
|
options.supportsConversationChaining === true
|
|
332
274
|
? options.previousResponseId ?? undefined
|
|
333
275
|
: undefined,
|
|
334
|
-
pendingApprovals: [],
|
|
335
276
|
supportsConversationChaining: options.supportsConversationChaining === true,
|
|
336
277
|
currentProviderId: options.providerId,
|
|
337
278
|
responseProviderId: options.providerId && options.supportsConversationChaining === true && options.previousResponseId
|
|
@@ -393,11 +334,8 @@ export class ApplicationRunLoop {
|
|
|
393
334
|
state.approvals = new ApprovalLedger();
|
|
394
335
|
// A continuation handle from before approval batching carried only the
|
|
395
336
|
// current pending item. Normalize it into the queue used by current runs.
|
|
396
|
-
if (!state.
|
|
397
|
-
state.
|
|
398
|
-
if (!state.pendingApproval && state.pendingApprovals.length > 0) {
|
|
399
|
-
state.pendingApproval = state.pendingApprovals[0];
|
|
400
|
-
}
|
|
337
|
+
if (!state.toolExecution)
|
|
338
|
+
state.toolExecution = this.#createToolCallExecution();
|
|
401
339
|
// Handles created before cost accounting existed have no record list.
|
|
402
340
|
if (!state.costRecords)
|
|
403
341
|
state.costRecords = [];
|
|
@@ -448,6 +386,8 @@ export class ApplicationRunLoop {
|
|
|
448
386
|
// root closure for callers that do not provide one again.
|
|
449
387
|
if (options.requestPreparation)
|
|
450
388
|
state.requestPreparation = options.requestPreparation;
|
|
389
|
+
if (options.compactionHistory)
|
|
390
|
+
state.compactionHistory = options.compactionHistory;
|
|
451
391
|
if (options.disableChainingForAttempt === true) {
|
|
452
392
|
state.disableChainingForAttempt = true;
|
|
453
393
|
state.responseId = undefined;
|
|
@@ -467,10 +407,8 @@ export class ApplicationRunLoop {
|
|
|
467
407
|
this.abortSegment();
|
|
468
408
|
const controller = new AbortController();
|
|
469
409
|
this.#activeAbortController = controller;
|
|
470
|
-
this.#
|
|
410
|
+
this.#turnInputMailbox.startSegment();
|
|
471
411
|
state.runBudget?.resume();
|
|
472
|
-
// This segment is running, so the turn is no longer paused between them.
|
|
473
|
-
this.#turnPaused = false;
|
|
474
412
|
if (options.signal) {
|
|
475
413
|
if (options.signal.aborted)
|
|
476
414
|
controller.abort();
|
|
@@ -531,42 +469,43 @@ export class ApplicationRunLoop {
|
|
|
531
469
|
return;
|
|
532
470
|
if (this.#activeAbortController === controller)
|
|
533
471
|
this.#activeAbortController = null;
|
|
534
|
-
this.#runInFlight = false;
|
|
535
472
|
// A segment that ends holding approvals has paused the turn, not ended
|
|
536
473
|
// it: the caller resumes through continueRunStream, which offers
|
|
537
474
|
// another request boundary. Injections wait for it. Only a segment
|
|
538
475
|
// that ends with nothing outstanding has truly finished the turn, and
|
|
539
476
|
// then anything still waiting has to be sent as its own turn instead.
|
|
540
|
-
const pendingApprovals = state.pendingApprovals
|
|
477
|
+
const pendingApprovals = state.toolExecution.pendingApprovals.length;
|
|
541
478
|
const pendingBudgetInteraction = state.pendingRunBudgetInteraction !== undefined;
|
|
542
479
|
const cancelled = stream.cancelled === true;
|
|
543
|
-
|
|
544
|
-
|
|
480
|
+
const turnPaused = (pendingApprovals > 0 || pendingBudgetInteraction) && !cancelled && exitError === undefined;
|
|
481
|
+
this.#turnInputMailbox.settleSegment({
|
|
482
|
+
paused: turnPaused,
|
|
483
|
+
reason: {
|
|
484
|
+
pendingApprovals,
|
|
485
|
+
pendingBudgetInteraction,
|
|
486
|
+
cancelled,
|
|
487
|
+
error: exitError instanceof Error ? exitError.name : exitError ? String(exitError) : undefined,
|
|
488
|
+
turnCount: state.turnCount,
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
if (turnPaused)
|
|
545
492
|
return;
|
|
546
493
|
if (this.#activeRunBudgetState === state)
|
|
547
494
|
this.#activeRunBudgetState = undefined;
|
|
548
|
-
// A declared turn outlives its segments — this one may be about to be
|
|
549
|
-
// retried, or resumed past a post-execute gate. Its owner says when it
|
|
550
|
-
// is over.
|
|
551
|
-
if (this.#turnOpen)
|
|
552
|
-
return;
|
|
553
|
-
this.#releasePendingSteers({
|
|
554
|
-
pendingApprovals,
|
|
555
|
-
pendingBudgetInteraction,
|
|
556
|
-
cancelled,
|
|
557
|
-
error: exitError instanceof Error ? exitError.name : exitError ? String(exitError) : undefined,
|
|
558
|
-
turnCount: state.turnCount,
|
|
559
|
-
});
|
|
560
495
|
});
|
|
561
496
|
this.#activeRunBudgetState = state.runBudget ? state : undefined;
|
|
562
497
|
return stream;
|
|
563
498
|
}
|
|
564
499
|
/** Route boundary advice through the same admission lane as mode notices. */
|
|
565
500
|
#queuePendingSystemNotice(text) {
|
|
566
|
-
this.#
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
501
|
+
this.#turnInputMailbox.enqueueInternal({ type: 'message', role: 'user', content: `[Mode Notice] ${text}` });
|
|
502
|
+
}
|
|
503
|
+
#admitPendingSteers(state, stream, queue) {
|
|
504
|
+
this.#turnInputMailbox.admitAtRequestBoundary((item) => {
|
|
505
|
+
state.history.push(item);
|
|
506
|
+
state.input.push(...normalizeApplicationInput([item]));
|
|
507
|
+
outputPush(stream, queue, { type: 'item', item });
|
|
508
|
+
}, state.turnCount);
|
|
570
509
|
}
|
|
571
510
|
async #execute(state, stream, queue, options, toolContext, requestAbortController) {
|
|
572
511
|
while (true) {
|
|
@@ -586,35 +525,14 @@ export class ApplicationRunLoop {
|
|
|
586
525
|
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
587
526
|
}
|
|
588
527
|
}
|
|
589
|
-
state.pendingApprovals
|
|
590
|
-
|
|
591
|
-
const selectedIndex = state.approvalDecisionCallId
|
|
592
|
-
? state.pendingApprovals.findIndex((pending) => getInterruptionCallId(pending.interruption) === state.approvalDecisionCallId)
|
|
593
|
-
: -1;
|
|
594
|
-
if (state.approvalDecisionCallId && selectedIndex < 0) {
|
|
595
|
-
throw new Error(`Approval decision references unknown pending tool call: ${state.approvalDecisionCallId}`);
|
|
596
|
-
}
|
|
597
|
-
const pendingIndex = selectedIndex >= 0 ? selectedIndex : 0;
|
|
598
|
-
const pending = state.pendingApprovals[pendingIndex];
|
|
599
|
-
const approved = state.approvalDecision === 'approved';
|
|
600
|
-
if (approved) {
|
|
601
|
-
state.approvals.approveTool({ toolName: pending.toolName, callId: pending.callId });
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
state.approvals.rejectTool({ toolName: pending.toolName, callId: pending.callId }, { message: state.approvalMessage });
|
|
605
|
-
}
|
|
606
|
-
pending.plan.status = 'ready';
|
|
607
|
-
if (!approved)
|
|
608
|
-
pending.plan.output = state.approvalMessage ?? 'rejected';
|
|
609
|
-
state.pendingApprovals.splice(pendingIndex, 1);
|
|
610
|
-
state.pendingApproval = state.pendingApprovals[0];
|
|
528
|
+
if (state.toolExecution.pendingApprovals.length > 0 && state.approvalDecision) {
|
|
529
|
+
state.toolExecution.resolveApproval(state.approvalDecisionCallId, state.approvalDecision, state.approvalMessage, state.approvals);
|
|
611
530
|
state.approvalDecision = undefined;
|
|
612
531
|
state.approvalDecisionCallId = undefined;
|
|
613
532
|
state.approvalMessage = undefined;
|
|
614
|
-
await this.#
|
|
615
|
-
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
616
|
-
if (state.pendingApprovals.length > 0) {
|
|
617
|
-
this.#turnPaused = true;
|
|
533
|
+
await state.toolExecution.settle(this.#toolCallContext(state, stream, queue, toolContext));
|
|
534
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
535
|
+
if (state.toolExecution.pendingApprovals.length > 0) {
|
|
618
536
|
return finish(stream, state, queue);
|
|
619
537
|
}
|
|
620
538
|
// Nothing is outstanding, so this segment is terminal — see
|
|
@@ -627,11 +545,10 @@ export class ApplicationRunLoop {
|
|
|
627
545
|
// A budget interaction can park a response after its tool calls are
|
|
628
546
|
// recorded but before any body runs. Resume those retained calls only
|
|
629
547
|
// after processing an ordinary approval decision for that same plan.
|
|
630
|
-
if (state.
|
|
631
|
-
await this.#
|
|
632
|
-
if (state.pendingApprovals
|
|
633
|
-
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
634
|
-
this.#turnPaused = true;
|
|
548
|
+
if (state.toolExecution.hasPlan) {
|
|
549
|
+
await state.toolExecution.settle(this.#toolCallContext(state, stream, queue, toolContext));
|
|
550
|
+
if (state.toolExecution.pendingApprovals.length) {
|
|
551
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
635
552
|
return finish(stream, state, queue);
|
|
636
553
|
}
|
|
637
554
|
}
|
|
@@ -643,25 +560,36 @@ export class ApplicationRunLoop {
|
|
|
643
560
|
this.#evaluateRunBudget(state, stream, queue);
|
|
644
561
|
if (state.pendingRunBudgetInteraction)
|
|
645
562
|
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
646
|
-
const
|
|
563
|
+
const compactionHistoryResult = state.usesDeltaHistory
|
|
564
|
+
? state.compactionHistory
|
|
565
|
+
? mergeChainedCompactionHistory(state.compactionHistory, state.history)
|
|
566
|
+
: { kind: 'skipped', reason: 'missing_snapshot' }
|
|
567
|
+
: { kind: 'ready', history: state.history };
|
|
568
|
+
const boundaryDecision = options.onRequestBoundary?.(compactionHistoryResult.kind === 'ready' ? compactionHistoryResult.history : state.history, (text) => this.#queuePendingSystemNotice(text), {
|
|
647
569
|
...(state.lastCompletedInputTokens !== undefined
|
|
648
570
|
? { lastCompletedInputTokens: state.lastCompletedInputTokens }
|
|
649
571
|
: {}),
|
|
572
|
+
...(compactionHistoryResult.kind === 'skipped'
|
|
573
|
+
? { compactionSkipReason: compactionHistoryResult.reason }
|
|
574
|
+
: {}),
|
|
650
575
|
});
|
|
651
|
-
|
|
576
|
+
const compactionHistory = compactionHistoryResult.kind === 'ready' ? compactionHistoryResult.history : undefined;
|
|
577
|
+
if (options.boundaryCompaction && compactionHistory && !boundaryDecision?.deferCompaction) {
|
|
652
578
|
const compactionStartedAt = Date.now();
|
|
653
579
|
const compaction = await options.boundaryCompaction.compact({
|
|
654
|
-
history:
|
|
580
|
+
history: compactionHistory,
|
|
655
581
|
automaticCompactionsThisRun: state.automaticCompactionsThisRun ?? 0,
|
|
656
582
|
lastCompletedInputTokens: state.lastCompletedInputTokens,
|
|
657
583
|
signal: options.signal,
|
|
658
584
|
onStarted: (provider) => outputPush(stream, queue, { type: 'context_compaction_started', provider, strategy: 'local' }),
|
|
659
585
|
});
|
|
660
586
|
if (compaction.kind === 'compacted') {
|
|
587
|
+
state.compactedDuringRun = true;
|
|
661
588
|
state.history.splice(0, state.history.length, ...compaction.history);
|
|
662
589
|
state.input.splice(0, state.input.length, ...normalizeApplicationInput(compaction.modelInput));
|
|
663
590
|
state.responseId = undefined;
|
|
664
591
|
state.responseProviderId = undefined;
|
|
592
|
+
state.usesDeltaHistory = false;
|
|
665
593
|
if (compaction.costRecords?.length) {
|
|
666
594
|
state.costRecords ??= [];
|
|
667
595
|
state.costRecords.push(...compaction.costRecords);
|
|
@@ -749,10 +677,19 @@ export class ApplicationRunLoop {
|
|
|
749
677
|
state.responseId = undefined;
|
|
750
678
|
state.responseProviderId = undefined;
|
|
751
679
|
}
|
|
680
|
+
// A per-request signal lets a recoverable guard trip cancel only this
|
|
681
|
+
// provider request; the segment signal still cancels everything.
|
|
682
|
+
const requestSignal = new AbortController();
|
|
683
|
+
const abortRequest = () => requestSignal.abort();
|
|
684
|
+
if (options.signal?.aborted)
|
|
685
|
+
requestSignal.abort();
|
|
686
|
+
else
|
|
687
|
+
options.signal?.addEventListener('abort', abortRequest, { once: true });
|
|
688
|
+
const requestInstructions = state.agent.resolveInstructionsForRequest?.() ?? state.agent.instructions;
|
|
752
689
|
const request = {
|
|
753
690
|
instructions: criticalWrapUp
|
|
754
|
-
? `${
|
|
755
|
-
:
|
|
691
|
+
? `${requestInstructions}\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.`
|
|
692
|
+
: requestInstructions,
|
|
756
693
|
...(state.supportsConversationChaining &&
|
|
757
694
|
!disableChaining &&
|
|
758
695
|
state.responseId &&
|
|
@@ -780,7 +717,7 @@ export class ApplicationRunLoop {
|
|
|
780
717
|
: state.agent.modelSettings.providerData,
|
|
781
718
|
}
|
|
782
719
|
: {}),
|
|
783
|
-
|
|
720
|
+
signal: requestSignal.signal,
|
|
784
721
|
...(state.recoveryBudget ? { recoveryBudget: state.recoveryBudget } : {}),
|
|
785
722
|
};
|
|
786
723
|
activeRequest = request;
|
|
@@ -884,7 +821,12 @@ export class ApplicationRunLoop {
|
|
|
884
821
|
break;
|
|
885
822
|
}
|
|
886
823
|
catch (error) {
|
|
887
|
-
|
|
824
|
+
const recoverOversizedToolArgument = isOversizedToolArgumentTrip(error) &&
|
|
825
|
+
(state.oversizedToolArgumentRecoveries ?? 0) < MAX_OVERSIZED_TOOL_ARGUMENT_RECOVERIES &&
|
|
826
|
+
!options.signal?.aborted;
|
|
827
|
+
if (recoverOversizedToolArgument)
|
|
828
|
+
requestSignal.abort();
|
|
829
|
+
else if (error instanceof GenerationGuardError)
|
|
888
830
|
requestAbortController.abort();
|
|
889
831
|
const decision = classifyInLoopModelRetry(error, attempt, maxRetries, Math.random, {
|
|
890
832
|
previousResponseId: activeRequest?.previousResponseId,
|
|
@@ -904,6 +846,23 @@ export class ApplicationRunLoop {
|
|
|
904
846
|
});
|
|
905
847
|
}
|
|
906
848
|
};
|
|
849
|
+
if (recoverOversizedToolArgument) {
|
|
850
|
+
// No tool ran: a call is dispatched only after its arguments
|
|
851
|
+
// complete. Discard the partial response and ask for smaller calls.
|
|
852
|
+
state.oversizedToolArgumentRecoveries = (state.oversizedToolArgumentRecoveries ?? 0) + 1;
|
|
853
|
+
state.input.splice(inputLengthBefore);
|
|
854
|
+
state.history.splice(historyLengthBefore);
|
|
855
|
+
state.criticalWrapUpDispatched = criticalWrapUpDispatchedBefore;
|
|
856
|
+
rollbackProvisionalAttempt();
|
|
857
|
+
this.#deps.logDiagnostic?.('Recovering oversized tool argument in run loop', {
|
|
858
|
+
code: error.code,
|
|
859
|
+
recovery: state.oversizedToolArgumentRecoveries,
|
|
860
|
+
maxRecoveries: MAX_OVERSIZED_TOOL_ARGUMENT_RECOVERIES,
|
|
861
|
+
});
|
|
862
|
+
this.#queuePendingSystemNotice(oversizedToolArgumentNotice(error.message));
|
|
863
|
+
this.#admitPendingSteers(state, stream, queue);
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
907
866
|
if (decision.retryable && !options.signal?.aborted) {
|
|
908
867
|
attempt++;
|
|
909
868
|
state.input.splice(inputLengthBefore);
|
|
@@ -920,7 +879,7 @@ export class ApplicationRunLoop {
|
|
|
920
879
|
maxRetries,
|
|
921
880
|
kind: decision.kind,
|
|
922
881
|
delayMs: decision.delayMs,
|
|
923
|
-
error:
|
|
882
|
+
error: describeError(error),
|
|
924
883
|
});
|
|
925
884
|
await (this.#deps.waitBeforeModelRetry ?? sleepWithAbort)(decision.delayMs, options.signal);
|
|
926
885
|
continue;
|
|
@@ -955,6 +914,9 @@ export class ApplicationRunLoop {
|
|
|
955
914
|
});
|
|
956
915
|
throw error;
|
|
957
916
|
}
|
|
917
|
+
finally {
|
|
918
|
+
options.signal?.removeEventListener('abort', abortRequest);
|
|
919
|
+
}
|
|
958
920
|
}
|
|
959
921
|
if (!completion) {
|
|
960
922
|
// A few application-owned model fixtures (and legacy adapters) end a
|
|
@@ -976,11 +938,10 @@ export class ApplicationRunLoop {
|
|
|
976
938
|
return finish(stream, state, queue);
|
|
977
939
|
}
|
|
978
940
|
await this.#dispatchToolCalls(state, stream, queue, streamedToolCalls, toolContext);
|
|
979
|
-
if (state.
|
|
941
|
+
if (state.toolExecution.terminateAfterExecution)
|
|
980
942
|
return finish(stream, state, queue);
|
|
981
|
-
if (state.
|
|
982
|
-
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
983
|
-
this.#turnPaused = true;
|
|
943
|
+
if (state.toolExecution.pendingApprovals.length > 0) {
|
|
944
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
984
945
|
return finish(stream, state, queue);
|
|
985
946
|
}
|
|
986
947
|
continue;
|
|
@@ -1105,7 +1066,10 @@ export class ApplicationRunLoop {
|
|
|
1105
1066
|
continue;
|
|
1106
1067
|
const historyItem = {
|
|
1107
1068
|
...item.item,
|
|
1108
|
-
providerOpaque: {
|
|
1069
|
+
providerOpaque: {
|
|
1070
|
+
provider: item.provider,
|
|
1071
|
+
...(item.sourceProvider ? { sourceProvider: item.sourceProvider } : {}),
|
|
1072
|
+
},
|
|
1109
1073
|
};
|
|
1110
1074
|
state.history.push(historyItem);
|
|
1111
1075
|
state.input.push(item);
|
|
@@ -1142,7 +1106,7 @@ export class ApplicationRunLoop {
|
|
|
1142
1106
|
if (!state.criticalWrapUpPending && toolCalls.length > 0) {
|
|
1143
1107
|
await this.#dispatchToolCalls(state, stream, queue, toolCalls, toolContext);
|
|
1144
1108
|
}
|
|
1145
|
-
if (state.
|
|
1109
|
+
if (state.toolExecution.terminateAfterExecution)
|
|
1146
1110
|
return finish(stream, state, queue);
|
|
1147
1111
|
// A critical subagent gets exactly this final tool-free model call.
|
|
1148
1112
|
if (criticalWrapUp)
|
|
@@ -1150,9 +1114,8 @@ export class ApplicationRunLoop {
|
|
|
1150
1114
|
if (state.pendingRunBudgetInteraction && toolCalls.length > 0) {
|
|
1151
1115
|
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
1152
1116
|
}
|
|
1153
|
-
if (state.pendingApprovals.length > 0) {
|
|
1154
|
-
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
1155
|
-
this.#turnPaused = true;
|
|
1117
|
+
if (state.toolExecution.pendingApprovals.length > 0) {
|
|
1118
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
1156
1119
|
return finish(stream, state, queue);
|
|
1157
1120
|
}
|
|
1158
1121
|
if (!sawToolCall) {
|
|
@@ -1164,178 +1127,51 @@ export class ApplicationRunLoop {
|
|
|
1164
1127
|
}
|
|
1165
1128
|
}
|
|
1166
1129
|
async #dispatchToolCalls(state, stream, queue, events, toolContext) {
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
state.
|
|
1176
|
-
state.
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
return {
|
|
1185
|
-
event,
|
|
1186
|
-
definition,
|
|
1187
|
-
parallelSafe: false,
|
|
1188
|
-
status: 'ready',
|
|
1189
|
-
};
|
|
1190
|
-
});
|
|
1191
|
-
state.toolPlan = plan;
|
|
1192
|
-
for (const entry of plan) {
|
|
1193
|
-
const { event, definition } = entry;
|
|
1194
|
-
if (!definition) {
|
|
1195
|
-
entry.output = `Unknown tool: ${event.name}`;
|
|
1196
|
-
continue;
|
|
1197
|
-
}
|
|
1198
|
-
// Keep the raw-model invocation contract: normalization repairs the
|
|
1199
|
-
// accepted object shape but intentionally does not Zod-parse it, which
|
|
1200
|
-
// would apply schema defaults before execute. web_fetch relies on its
|
|
1201
|
-
// executor fallbacks on the strict JSON-schema path.
|
|
1202
|
-
try {
|
|
1203
|
-
const parsedArguments = definition.parseModelArguments
|
|
1204
|
-
? definition.parseModelArguments(event.arguments)
|
|
1205
|
-
: parseArguments(event.arguments);
|
|
1206
|
-
entry.params = normalizeToolParameters(parsedArguments, definition.parameters);
|
|
1207
|
-
}
|
|
1208
|
-
catch (error) {
|
|
1209
|
-
entry.output = `Error: Invalid patch: ${error instanceof Error ? error.message : String(error)}`;
|
|
1210
|
-
continue;
|
|
1211
|
-
}
|
|
1212
|
-
const stallEvent = state.runBudget?.observeToolCall({
|
|
1213
|
-
name: event.name,
|
|
1214
|
-
argumentsText: event.arguments,
|
|
1215
|
-
effect: definition.effect,
|
|
1216
|
-
});
|
|
1217
|
-
if (stallEvent) {
|
|
1218
|
-
this.#emitRunBudgetEvent(state, stallEvent, 'Tool stall evidence', stream, queue);
|
|
1219
|
-
}
|
|
1220
|
-
// Consult this run's ledger before prompting: a decision already taken
|
|
1221
|
-
// (in the parent run and replayed in, or earlier in this run) must not
|
|
1222
|
-
// prompt again. This is what makes approval replay observable.
|
|
1223
|
-
const alreadyDecided = state.approvals.isToolApproved({ toolName: event.name, callId: event.id });
|
|
1224
|
-
if (alreadyDecided === false) {
|
|
1225
|
-
entry.output = state.approvals.getRejectionMessage(event.name, event.id) ?? 'Tool execution was not approved.';
|
|
1226
|
-
continue;
|
|
1227
|
-
}
|
|
1228
|
-
if (alreadyDecided !== true && (await definition.needsApproval(entry.params, toolContext))) {
|
|
1229
|
-
entry.status = 'approval_pending';
|
|
1230
|
-
const pending = {
|
|
1130
|
+
const context = this.#toolCallContext(state, stream, queue, toolContext);
|
|
1131
|
+
await state.toolExecution.plan(events, context);
|
|
1132
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
1133
|
+
if (!state.pendingRunBudgetInteraction)
|
|
1134
|
+
await state.toolExecution.settle(context);
|
|
1135
|
+
}
|
|
1136
|
+
#toolCallContext(state, stream, queue, toolContext) {
|
|
1137
|
+
return {
|
|
1138
|
+
tools: state.agent.tools,
|
|
1139
|
+
approvals: state.approvals,
|
|
1140
|
+
toolContext,
|
|
1141
|
+
sessionId: state.sessionId,
|
|
1142
|
+
turnId: state.turnId,
|
|
1143
|
+
hookScope: state.hookScope,
|
|
1144
|
+
onCall: (event) => {
|
|
1145
|
+
const callItem = {
|
|
1146
|
+
type: event.toolType === 'custom' ? 'custom_tool_call' : 'function_call',
|
|
1231
1147
|
callId: event.id,
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
interruption: {
|
|
1235
|
-
type: 'tool_approval_item',
|
|
1236
|
-
rawItem: { type: 'function_call', callId: event.id, name: event.name, arguments: event.arguments },
|
|
1237
|
-
callId: event.id,
|
|
1238
|
-
name: event.name,
|
|
1239
|
-
arguments: event.arguments,
|
|
1240
|
-
},
|
|
1241
|
-
definition,
|
|
1242
|
-
params: entry.params,
|
|
1243
|
-
plan: entry,
|
|
1148
|
+
name: event.name,
|
|
1149
|
+
...(event.toolType === 'custom' ? { input: event.arguments } : { arguments: event.arguments }),
|
|
1244
1150
|
};
|
|
1245
|
-
state.
|
|
1246
|
-
state.
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
toolName: entry.event.name,
|
|
1257
|
-
parallelSafe: entry.parallelSafe,
|
|
1258
|
-
approvalPending: entry.status === 'approval_pending',
|
|
1259
|
-
})),
|
|
1260
|
-
}, { severity: 'debug', eventType: 'tool.parallel.eligibility' });
|
|
1261
|
-
// A main-agent budget escalation is a real boundary: retain the planned
|
|
1262
|
-
// calls, but do not execute one more tool while human judgement is pending.
|
|
1263
|
-
if (!state.pendingRunBudgetInteraction) {
|
|
1264
|
-
await this.#settleToolPlan(state, stream, queue, toolContext);
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
async #settleToolPlan(state, stream, queue, toolContext) {
|
|
1268
|
-
const plan = state.toolPlan;
|
|
1269
|
-
if (!plan)
|
|
1270
|
-
return;
|
|
1271
|
-
const maxParallelToolCalls = Math.max(1, Math.floor(this.#deps.resolveMaxParallelToolCalls?.() ?? DEFAULT_MAX_PARALLEL_TOOL_CALLS));
|
|
1272
|
-
while (true) {
|
|
1273
|
-
const firstPending = plan.find((entry) => entry.status !== 'completed');
|
|
1274
|
-
if (!firstPending) {
|
|
1275
|
-
state.toolPlan = undefined;
|
|
1276
|
-
return;
|
|
1277
|
-
}
|
|
1278
|
-
if (firstPending.status === 'approval_pending')
|
|
1279
|
-
return;
|
|
1280
|
-
const group = [];
|
|
1281
|
-
for (const entry of plan) {
|
|
1282
|
-
if (entry.status === 'completed')
|
|
1283
|
-
continue;
|
|
1284
|
-
if (entry.status === 'approval_pending')
|
|
1285
|
-
break;
|
|
1286
|
-
if (group.length > 0 && (!entry.parallelSafe || !group[0].parallelSafe || group.length >= maxParallelToolCalls))
|
|
1287
|
-
break;
|
|
1288
|
-
group.push(entry);
|
|
1289
|
-
if (!entry.parallelSafe)
|
|
1290
|
-
break;
|
|
1291
|
-
}
|
|
1292
|
-
const batchId = `tool-batch-${++nextToolBatchSeq}`;
|
|
1293
|
-
this.#deps.logDiagnostic?.('tool batch dispatched', {
|
|
1294
|
-
batchId,
|
|
1295
|
-
callIds: group.map((entry) => entry.event.id),
|
|
1296
|
-
parallel: group.length > 1,
|
|
1297
|
-
maxParallelToolCalls,
|
|
1298
|
-
dispatchOrder: group.map((entry) => entry.event.id),
|
|
1299
|
-
}, { severity: 'debug', eventType: 'tool.batch.dispatched' });
|
|
1300
|
-
for (const entry of group) {
|
|
1151
|
+
state.history.push(callItem);
|
|
1152
|
+
state.input.push({
|
|
1153
|
+
type: 'tool_call',
|
|
1154
|
+
id: event.id,
|
|
1155
|
+
name: event.name,
|
|
1156
|
+
arguments: event.arguments,
|
|
1157
|
+
...(event.toolType ? { toolType: event.toolType } : {}),
|
|
1158
|
+
});
|
|
1159
|
+
outputPush(stream, queue, { type: 'item', item: callItem });
|
|
1160
|
+
},
|
|
1161
|
+
onDispatch: (entry) => {
|
|
1301
1162
|
outputPush(stream, queue, {
|
|
1302
1163
|
type: 'tool_call_dispatched',
|
|
1303
1164
|
callId: entry.event.id,
|
|
1304
1165
|
toolName: entry.event.name,
|
|
1305
1166
|
});
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
group[index].result = value;
|
|
1315
|
-
this.#appendToolResult(state, stream, queue, group[index], value);
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
else {
|
|
1319
|
-
const result = await this.#invokePlannedTool(group[0], toolContext, state);
|
|
1320
|
-
group[0].result = result;
|
|
1321
|
-
this.#appendToolResult(state, stream, queue, group[0], result);
|
|
1322
|
-
}
|
|
1323
|
-
this.#deps.logDiagnostic?.('tool batch settled', {
|
|
1324
|
-
batchId,
|
|
1325
|
-
settlementOrder: group.map((entry) => entry.event.id),
|
|
1326
|
-
}, { severity: 'debug', eventType: 'tool.batch.settled' });
|
|
1327
|
-
if (group.some((entry) => shouldTerminateAfterExecution(entry.definition, entry.result))) {
|
|
1328
|
-
state.terminateAfterToolExecution = true;
|
|
1329
|
-
state.toolPlan = undefined;
|
|
1330
|
-
return;
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
async #invokePlannedTool(entry, toolContext, state) {
|
|
1335
|
-
entry.status = 'completed';
|
|
1336
|
-
if (entry.output !== undefined)
|
|
1337
|
-
return entry.output;
|
|
1338
|
-
return this.#invokeTool(entry.definition, entry.params, toolContext, entry.event.id, state);
|
|
1167
|
+
},
|
|
1168
|
+
onToolStall: (input) => {
|
|
1169
|
+
const stallEvent = state.runBudget?.observeToolCall(input);
|
|
1170
|
+
if (stallEvent)
|
|
1171
|
+
this.#emitRunBudgetEvent(state, stallEvent, 'Tool stall evidence', stream, queue);
|
|
1172
|
+
},
|
|
1173
|
+
onResult: (entry, result) => this.#appendToolResult(state, stream, queue, entry, result),
|
|
1174
|
+
};
|
|
1339
1175
|
}
|
|
1340
1176
|
#appendToolResult(state, stream, queue, entry, result) {
|
|
1341
1177
|
const runCodeExecution = getRunCodeExecutionResult(result);
|
|
@@ -1363,57 +1199,6 @@ export class ApplicationRunLoop {
|
|
|
1363
1199
|
outputPush(stream, queue, { type: 'item', item: resultItem });
|
|
1364
1200
|
this.#evaluateRunBudget(state, stream, queue);
|
|
1365
1201
|
}
|
|
1366
|
-
/**
|
|
1367
|
-
* A tool that throws must not take the run down with it.
|
|
1368
|
-
*
|
|
1369
|
-
* Most tools already report failure by returning `Error: ...` as their
|
|
1370
|
-
* output, which the model reads and acts on. The handful that throw got the
|
|
1371
|
-
* opposite treatment for no principled reason: the exception escaped to
|
|
1372
|
-
* `#execute`, closed the event queue, and ended the turn — so the model never
|
|
1373
|
-
* saw a recoverable problem like a path that does not exist, and the caller
|
|
1374
|
-
* lost the whole turn. Worse, `#handleToolCall` pushes the `function_call`
|
|
1375
|
-
* into history before executing, so an escape leaves a call with no matching
|
|
1376
|
-
* result.
|
|
1377
|
-
*
|
|
1378
|
-
* Errors are therefore normalized into tool output, with two exceptions that
|
|
1379
|
-
* must still propagate: cancellation (the run is ending on purpose) and
|
|
1380
|
-
* `HarnessInvariantError` (a bug here, which the model cannot act on).
|
|
1381
|
-
*/
|
|
1382
|
-
async #invokeTool(definition, params, toolContext, callId, state) {
|
|
1383
|
-
const startedAt = Date.now();
|
|
1384
|
-
const attempt = state
|
|
1385
|
-
? ((state.toolAttempts ??= new Map()).set(callId, (state.toolAttempts.get(callId) ?? 0) + 1),
|
|
1386
|
-
state.toolAttempts.get(callId))
|
|
1387
|
-
: 1;
|
|
1388
|
-
const lifecycleContext = {
|
|
1389
|
-
...(state?.sessionId ? { sessionId: state.sessionId } : {}),
|
|
1390
|
-
...(state?.turnId ? { turnId: state.turnId } : {}),
|
|
1391
|
-
toolCallId: callId,
|
|
1392
|
-
toolName: definition.name,
|
|
1393
|
-
normalizedArguments: params,
|
|
1394
|
-
attempt,
|
|
1395
|
-
scope: state?.hookScope ?? 'root',
|
|
1396
|
-
};
|
|
1397
|
-
// Dispatch mark must run before execute so a mid-tool stream failure can
|
|
1398
|
-
// settle the ledger as unknown rather than aborted.
|
|
1399
|
-
this.#deps.getOnToolDispatch?.()?.(callId);
|
|
1400
|
-
await this.#notifyToolLifecycle(() => this.#deps.toolLifecycle?.before(lifecycleContext));
|
|
1401
|
-
try {
|
|
1402
|
-
const result = await definition.execute(params, toolContext, { toolCall: { callId } });
|
|
1403
|
-
await this.#notifyToolLifecycle(() => this.#deps.toolLifecycle?.after(lifecycleContext, result, Date.now() - startedAt));
|
|
1404
|
-
return result;
|
|
1405
|
-
}
|
|
1406
|
-
catch (error) {
|
|
1407
|
-
if (isCancellationError(error) || isHarnessInvariantError(error) || error instanceof MaxTurnsExceededError) {
|
|
1408
|
-
await this.#notifyToolLifecycle(() => this.#deps.toolLifecycle?.error(lifecycleContext, error, Date.now() - startedAt, false));
|
|
1409
|
-
throw error;
|
|
1410
|
-
}
|
|
1411
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1412
|
-
const result = `Error: ${message}`;
|
|
1413
|
-
await this.#notifyToolLifecycle(() => this.#deps.toolLifecycle?.error(lifecycleContext, error, Date.now() - startedAt, true));
|
|
1414
|
-
return result;
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
1202
|
#nextRequestId() {
|
|
1418
1203
|
nextCostRequestSeq += 1;
|
|
1419
1204
|
return `req-${nextCostRequestSeq}`;
|
|
@@ -1477,33 +1262,8 @@ export class ApplicationRunLoop {
|
|
|
1477
1262
|
if (!interaction)
|
|
1478
1263
|
return finish(stream, state, queue);
|
|
1479
1264
|
stream.interruptions = [interaction];
|
|
1480
|
-
this.#turnPaused = true;
|
|
1481
1265
|
return finish(stream, state, queue);
|
|
1482
1266
|
}
|
|
1483
|
-
async #notifyToolLifecycle(operation) {
|
|
1484
|
-
if (!operation)
|
|
1485
|
-
return;
|
|
1486
|
-
try {
|
|
1487
|
-
await operation();
|
|
1488
|
-
}
|
|
1489
|
-
catch {
|
|
1490
|
-
// Lifecycle observers are passive. A broken observer must not alter tool
|
|
1491
|
-
// execution or turn recovery semantics.
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
function shouldTerminateAfterExecution(definition, result) {
|
|
1496
|
-
const policy = definition?.terminateAfterExecution;
|
|
1497
|
-
if (typeof policy === 'boolean')
|
|
1498
|
-
return policy;
|
|
1499
|
-
if (!policy)
|
|
1500
|
-
return false;
|
|
1501
|
-
try {
|
|
1502
|
-
return policy(result);
|
|
1503
|
-
}
|
|
1504
|
-
catch {
|
|
1505
|
-
return false;
|
|
1506
|
-
}
|
|
1507
1267
|
}
|
|
1508
1268
|
function isLunaChainedRequest(state, request) {
|
|
1509
1269
|
return (state.currentProviderId === 'codex' &&
|
|
@@ -1513,6 +1273,12 @@ function isLunaChainedRequest(state, request) {
|
|
|
1513
1273
|
request.input.length === 1 &&
|
|
1514
1274
|
request.input[0]?.type === 'tool_result');
|
|
1515
1275
|
}
|
|
1276
|
+
function getInterruptionCallId(value) {
|
|
1277
|
+
if (typeof value !== 'object' || value === null)
|
|
1278
|
+
return undefined;
|
|
1279
|
+
const callId = value.callId;
|
|
1280
|
+
return typeof callId === 'string' ? callId : undefined;
|
|
1281
|
+
}
|
|
1516
1282
|
function outputPush(stream, queue, item) {
|
|
1517
1283
|
stream.output.push(item);
|
|
1518
1284
|
if (stream.newItems !== stream.output)
|
|
@@ -1521,6 +1287,7 @@ function outputPush(stream, queue, item) {
|
|
|
1521
1287
|
}
|
|
1522
1288
|
function finish(stream, state, queue) {
|
|
1523
1289
|
stream.history = state.history;
|
|
1290
|
+
stream.historyReplacedByCompaction = state.compactedDuringRun === true;
|
|
1524
1291
|
stream.terminalCause = state.terminalCause;
|
|
1525
1292
|
stream.latestProviderInputTokens = state.lastCompletedInputTokens;
|
|
1526
1293
|
if (state.supportsConversationChaining &&
|
|
@@ -1623,31 +1390,6 @@ function normalizeModelUsage(usage) {
|
|
|
1623
1390
|
reasoningTokens: rawUsage.outputTokens?.reasoning ?? rawUsage.reasoningTokens,
|
|
1624
1391
|
});
|
|
1625
1392
|
}
|
|
1626
|
-
function parseArguments(value) {
|
|
1627
|
-
try {
|
|
1628
|
-
return JSON.parse(value);
|
|
1629
|
-
}
|
|
1630
|
-
catch {
|
|
1631
|
-
return {};
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
async function isParallelSafe(definition, params, context) {
|
|
1635
|
-
if (typeof definition.parallelSafe === 'function') {
|
|
1636
|
-
try {
|
|
1637
|
-
return await definition.parallelSafe(params, context);
|
|
1638
|
-
}
|
|
1639
|
-
catch {
|
|
1640
|
-
return false;
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
return definition.parallelSafe === true;
|
|
1644
|
-
}
|
|
1645
|
-
function getInterruptionCallId(value) {
|
|
1646
|
-
if (typeof value !== 'object' || value === null)
|
|
1647
|
-
return undefined;
|
|
1648
|
-
const callId = value.callId;
|
|
1649
|
-
return typeof callId === 'string' ? callId : undefined;
|
|
1650
|
-
}
|
|
1651
1393
|
function toModelTools(tools) {
|
|
1652
1394
|
return tools.map((tool) => tool.modelTool
|
|
1653
1395
|
? {
|
|
@@ -1685,6 +1427,37 @@ function normalizeHistory(input) {
|
|
|
1685
1427
|
return [{ type: 'message', role: 'user', content: input }];
|
|
1686
1428
|
return Array.isArray(input) ? [...input] : [input];
|
|
1687
1429
|
}
|
|
1430
|
+
function mergeChainedCompactionHistory(sessionHistory, deltaHistory) {
|
|
1431
|
+
const firstDeltaItem = deltaHistory[0];
|
|
1432
|
+
if (!firstDeltaItem || firstDeltaItem.type !== 'message' || firstDeltaItem.role !== 'user') {
|
|
1433
|
+
return { kind: 'skipped', reason: 'user_mismatch' };
|
|
1434
|
+
}
|
|
1435
|
+
let latestUserIndex = -1;
|
|
1436
|
+
for (let index = sessionHistory.length - 1; index >= 0; index--) {
|
|
1437
|
+
const item = sessionHistory[index];
|
|
1438
|
+
if (item.type === 'message' && item.role === 'user') {
|
|
1439
|
+
latestUserIndex = index;
|
|
1440
|
+
break;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
if (latestUserIndex < 0)
|
|
1444
|
+
return { kind: 'skipped', reason: 'user_mismatch' };
|
|
1445
|
+
const latestSessionUser = sessionHistory[latestUserIndex];
|
|
1446
|
+
const normalizedDeltaUser = normalizeApplicationInput([firstDeltaItem]);
|
|
1447
|
+
const normalizedSessionUser = normalizeApplicationInput([latestSessionUser]);
|
|
1448
|
+
if (JSON.stringify(normalizedDeltaUser) !== JSON.stringify(normalizedSessionUser)) {
|
|
1449
|
+
return { kind: 'skipped', reason: 'user_mismatch' };
|
|
1450
|
+
}
|
|
1451
|
+
return {
|
|
1452
|
+
kind: 'ready',
|
|
1453
|
+
history: [
|
|
1454
|
+
...sessionHistory.slice(0, latestUserIndex),
|
|
1455
|
+
firstDeltaItem,
|
|
1456
|
+
...sessionHistory.slice(latestUserIndex + 1),
|
|
1457
|
+
...deltaHistory.slice(1),
|
|
1458
|
+
],
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1688
1461
|
function asRecord(value) {
|
|
1689
1462
|
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
|
|
1690
1463
|
}
|
|
@@ -1814,7 +1587,14 @@ function isProviderOpaque(item) {
|
|
|
1814
1587
|
function normalizeInputItem(item) {
|
|
1815
1588
|
if (isProviderOpaque(item)) {
|
|
1816
1589
|
const { providerOpaque: _marker, ...providerItem } = item;
|
|
1817
|
-
return [
|
|
1590
|
+
return [
|
|
1591
|
+
{
|
|
1592
|
+
type: 'provider_opaque',
|
|
1593
|
+
provider: item.providerOpaque.provider,
|
|
1594
|
+
...(item.providerOpaque.sourceProvider ? { sourceProvider: item.providerOpaque.sourceProvider } : {}),
|
|
1595
|
+
item: providerItem,
|
|
1596
|
+
},
|
|
1597
|
+
];
|
|
1818
1598
|
}
|
|
1819
1599
|
if (item.type === 'function_call' || item.type === 'custom_tool_call') {
|
|
1820
1600
|
return [
|
|
@@ -1866,4 +1646,19 @@ function normalizeInputItem(item) {
|
|
|
1866
1646
|
}
|
|
1867
1647
|
return [{ type: 'message', role, content }];
|
|
1868
1648
|
}
|
|
1649
|
+
/**
|
|
1650
|
+
* A legitimate but oversized tool call (usually one large edit) trips the
|
|
1651
|
+
* tool-argument caps. Unlike runaway output it is answerable: tell the model
|
|
1652
|
+
* the call never ran and let it split the work, a bounded number of times.
|
|
1653
|
+
*/
|
|
1654
|
+
const MAX_OVERSIZED_TOOL_ARGUMENT_RECOVERIES = 2;
|
|
1655
|
+
function isOversizedToolArgumentTrip(error) {
|
|
1656
|
+
return (error instanceof GenerationGuardError &&
|
|
1657
|
+
(error.code === 'tool_argument_characters' || error.code === 'cumulative_tool_argument_characters'));
|
|
1658
|
+
}
|
|
1659
|
+
function oversizedToolArgumentNotice(guardMessage) {
|
|
1660
|
+
return (`Your previous response was discarded and its tool call was not executed. ${guardMessage} ` +
|
|
1661
|
+
'Redo the work in smaller tool calls, each well under that limit — for example, several targeted ' +
|
|
1662
|
+
'patches instead of rewriting a whole file in one call.');
|
|
1663
|
+
}
|
|
1869
1664
|
//# sourceMappingURL=application-run-loop.js.map
|