@qduc/term2 0.27.0 → 0.29.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 +6 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +14 -4
- 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 +64 -11
- package/dist/app.js.map +1 -1
- package/dist/build-info.json +6 -0
- package/dist/cli.js +199 -46
- 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 +7 -0
- package/dist/components/layout/Banner.d.ts.map +1 -1
- package/dist/components/layout/Banner.js +25 -4
- 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 +8 -7
- 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 +10 -0
- package/dist/contracts/streamed-model-turn.d.ts.map +1 -1
- package/dist/contracts/streamed-model-turn.js +7 -1
- package/dist/contracts/streamed-model-turn.js.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 +6 -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-config.d.ts.map +1 -1
- package/dist/hooks/settings-completion-config.js +0 -1
- package/dist/hooks/settings-completion-config.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 +9 -6
- package/dist/lib/agent-client.d.ts.map +1 -1
- package/dist/lib/agent-client.js +48 -26
- package/dist/lib/agent-client.js.map +1 -1
- package/dist/lib/agent-configuration.d.ts +4 -0
- package/dist/lib/agent-configuration.d.ts.map +1 -1
- package/dist/lib/agent-configuration.js +14 -1
- package/dist/lib/agent-configuration.js.map +1 -1
- package/dist/lib/agent-factory.d.ts +4 -0
- package/dist/lib/agent-factory.d.ts.map +1 -1
- package/dist/lib/agent-factory.js +4 -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/prompts/explorer-delegation-contract.test.ts +1 -1
- package/dist/prompts/{gpt-5.6.md → gpt.md} +13 -1
- package/dist/prompts/prompt-constructor.d.ts +14 -3
- package/dist/prompts/prompt-constructor.d.ts.map +1 -1
- package/dist/prompts/prompt-constructor.js +4 -5
- package/dist/prompts/prompt-constructor.js.map +1 -1
- package/dist/prompts/prompt-constructor.test.ts +82 -114
- package/dist/prompts/prompt-constructor.ts +14 -8
- package/dist/prompts/prompt-profiles.d.ts.map +1 -1
- package/dist/prompts/prompt-profiles.js +3 -39
- package/dist/prompts/prompt-profiles.js.map +1 -1
- package/dist/prompts/prompt-profiles.ts +3 -40
- package/dist/prompts/tool-surface-guidance.d.ts +2 -1
- package/dist/prompts/tool-surface-guidance.d.ts.map +1 -1
- package/dist/prompts/tool-surface-guidance.js +22 -9
- package/dist/prompts/tool-surface-guidance.js.map +1 -1
- package/dist/prompts/tool-surface-guidance.ts +26 -8
- package/dist/prompts/unified-gpt-prompt.test.ts +53 -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 +16 -7
- 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 +5 -4
- 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/model-catalog/catalog.generated.d.ts +145 -89
- package/dist/providers/model-catalog/catalog.generated.d.ts.map +1 -1
- package/dist/providers/model-catalog/catalog.generated.js +145 -89
- package/dist/providers/model-catalog/catalog.generated.js.map +1 -1
- package/dist/providers/model-catalog/generate-catalog.d.ts.map +1 -1
- package/dist/providers/model-catalog/generate-catalog.js +18 -1
- package/dist/providers/model-catalog/generate-catalog.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 +3 -6
- package/dist/providers/openai-responses-model.d.ts.map +1 -1
- package/dist/providers/openai-responses-model.js +11 -2
- 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/scripts/eval-gpt6-prompts.js +60 -25
- package/dist/scripts/eval-gpt6-prompts.js.map +1 -1
- package/dist/scripts/gpt6-probe-tools.d.ts +4 -0
- package/dist/scripts/gpt6-probe-tools.d.ts.map +1 -0
- package/dist/scripts/gpt6-probe-tools.js +43 -0
- package/dist/scripts/gpt6-probe-tools.js.map +1 -0
- 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 +238 -433
- 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 +1 -5
- package/dist/services/conversation/conversation-adapter.d.ts.map +1 -1
- package/dist/services/conversation/conversation-adapter.js +4 -6
- 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 +170 -32
- 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/conversation-agent-client.d.ts +2 -4
- package/dist/services/conversation-agent-client.d.ts.map +1 -1
- 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 +5 -16
- package/dist/services/memory/memory-capabilities.d.ts.map +1 -1
- package/dist/services/memory/memory-capabilities.js +30 -191
- 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 +5 -12
- package/dist/services/memory/memory-store.d.ts.map +1 -1
- package/dist/services/memory/memory-store.js +18 -13
- 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/sandboxed-code-host/host-types.d.ts +4 -2
- package/dist/services/sandboxed-code-host/host-types.d.ts.map +1 -1
- package/dist/services/sandboxed-code-host/host-types.js.map +1 -1
- package/dist/services/sandboxed-code-host/host-worker.d.ts.map +1 -1
- package/dist/services/sandboxed-code-host/host-worker.js +6 -3
- package/dist/services/sandboxed-code-host/host-worker.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 +45 -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-attempt-factory.d.ts +0 -2
- package/dist/services/session/turn-attempt-factory.d.ts.map +1 -1
- package/dist/services/session/turn-attempt-factory.js.map +1 -1
- package/dist/services/session/turn-attempt.d.ts +0 -5
- package/dist/services/session/turn-attempt.d.ts.map +1 -1
- package/dist/services/session/turn-attempt.js +0 -9
- package/dist/services/session/turn-attempt.js.map +1 -1
- package/dist/services/session/turn-coordinator.d.ts +2 -1
- package/dist/services/session/turn-coordinator.d.ts.map +1 -1
- package/dist/services/session/turn-coordinator.js +1 -1
- package/dist/services/session/turn-coordinator.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 +1 -76
- 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 -29
- package/dist/services/settings/settings-schema.d.ts.map +1 -1
- package/dist/services/settings/settings-schema.js +11 -9
- package/dist/services/settings/settings-schema.js.map +1 -1
- package/dist/services/settings/settings-sources.d.ts +0 -1
- package/dist/services/settings/settings-sources.d.ts.map +1 -1
- package/dist/services/settings/settings-sources.js +0 -1
- package/dist/services/settings/settings-sources.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 -3
- package/dist/services/settings/settings-ui-metadata.js.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts +1 -2
- 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 -45
- 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 +13 -7
- 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 +6 -4
- 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/file/upstream-apply-patch.d.ts.map +1 -1
- package/dist/tools/file/upstream-apply-patch.js +17 -4
- package/dist/tools/file/upstream-apply-patch.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 +2 -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 +53 -8
- 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 +17 -1
- package/dist/tools/system/run-code/run-code.js.map +1 -1
- package/dist/tools/system/shell.d.ts +1 -4
- package/dist/tools/system/shell.d.ts.map +1 -1
- package/dist/tools/system/shell.js +7 -26
- 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/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/execute-shell.js +3 -0
- package/dist/utils/shell/execute-shell.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/sandbox/sandbox-policy.d.ts.map +1 -1
- package/dist/utils/shell/sandbox/sandbox-policy.js +0 -4
- package/dist/utils/shell/sandbox/sandbox-policy.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 -10
- 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/prompts/codex.md +0 -104
- package/dist/prompts/fragments/gpt-6.md +0 -13
- package/dist/prompts/gpt-5-modern.md +0 -114
- package/dist/prompts/gpt-5.4-mini.md +0 -111
- package/dist/prompts/gpt-5.5.md +0 -108
- package/dist/prompts/memory.md +0 -9
- 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
- package/dist/services/rtk-service.d.ts +0 -23
- package/dist/services/rtk-service.d.ts.map +0 -1
- package/dist/services/rtk-service.js +0 -251
- package/dist/services/rtk-service.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createContinuationHandle, unwrapContinuationHandle, } from '../../contracts/continuation-handle.js';
|
|
3
3
|
import { createAgentStream } from '../agent-stream.js';
|
|
4
|
+
import { ASSISTANT_TEXT_PART_SEPARATOR } from '../../contracts/streamed-model-turn.js';
|
|
4
5
|
import { getRunCodeExecutionResult, runCodeExecutionMetadata } from '../../tools/system/run-code/run-code-execution.js';
|
|
5
6
|
import { isZodToolParameterSchema } from '../../tools/types.js';
|
|
6
|
-
import {
|
|
7
|
-
import { isCancellationError, isHarnessInvariantError } from '../../lib/harness-invariant-error.js';
|
|
7
|
+
import { describeError } from '../../utils/error-helpers.js';
|
|
8
8
|
import { ApprovalLedger } from './tool-invocation-context.js';
|
|
9
9
|
import { RunBudget, isRunBudgetInteraction, } from './run-budget.js';
|
|
10
10
|
import { addTokenUsage, normalizeUsage } from '../../utils/ai/token-usage.js';
|
|
@@ -14,6 +14,8 @@ import { getCatalogPricingVersion, getModelPricing } from '../../services/cost/p
|
|
|
14
14
|
import { DEFAULT_TOOL_ARGUMENT_RUNAWAY_SIGNATURE, GenerationGuard, GenerationGuardError, GenerationStreamDeadlines, ToolArgumentRunawayGuard, } from './generation-guard.js';
|
|
15
15
|
import { classifyInLoopModelRetry, sleepWithAbort } from '../retry/in-loop-model-retry.js';
|
|
16
16
|
import { buildFailureObservation } from '../decision-shadow/failure-observation.js';
|
|
17
|
+
import { TurnInputMailbox } from './turn-input-mailbox.js';
|
|
18
|
+
import { ToolCallExecution } from './tool-call-execution.js';
|
|
17
19
|
/**
|
|
18
20
|
* Tool results may carry provider-neutral content parts (for example the
|
|
19
21
|
* image returned by read_file). Preserve only the known multimodal shape;
|
|
@@ -83,8 +85,6 @@ class EventQueue {
|
|
|
83
85
|
* turns and silently drop later turns' records.
|
|
84
86
|
*/
|
|
85
87
|
let nextCostRequestSeq = 0;
|
|
86
|
-
let nextToolBatchSeq = 0;
|
|
87
|
-
const DEFAULT_MAX_PARALLEL_TOOL_CALLS = 3;
|
|
88
88
|
/**
|
|
89
89
|
* Small provider-neutral agent loop. It owns model-turn sequencing and tool
|
|
90
90
|
* execution; providers only implement `StreamedModelTurn`.
|
|
@@ -92,33 +92,15 @@ const DEFAULT_MAX_PARALLEL_TOOL_CALLS = 3;
|
|
|
92
92
|
export class ApplicationRunLoop {
|
|
93
93
|
#deps;
|
|
94
94
|
#contextCompactionSessionState;
|
|
95
|
+
#turnInputMailbox;
|
|
95
96
|
#activeAbortController = null;
|
|
96
|
-
#runInFlight = false;
|
|
97
97
|
#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
98
|
/** The run whose budget an out-of-band grant applies to, held across a pause. */
|
|
118
99
|
#activeRunBudgetState;
|
|
119
100
|
constructor(deps) {
|
|
120
101
|
this.#deps = deps;
|
|
121
102
|
this.#contextCompactionSessionState = deps.contextCompactionSessionState ?? { disabled: false };
|
|
103
|
+
this.#turnInputMailbox = new TurnInputMailbox((message, meta) => this.#deps.logDiagnostic?.(message, meta));
|
|
122
104
|
}
|
|
123
105
|
#observeTerminalFailure(error, request) {
|
|
124
106
|
this.#observeDecisionShadow('failure_triage', () => {
|
|
@@ -147,25 +129,19 @@ export class ApplicationRunLoop {
|
|
|
147
129
|
* be admitted now.
|
|
148
130
|
*/
|
|
149
131
|
openTurn() {
|
|
150
|
-
this.#
|
|
151
|
-
this.#turnOpen = true;
|
|
152
|
-
this.#turnPaused = false;
|
|
132
|
+
this.#turnInputMailbox.openTurn();
|
|
153
133
|
}
|
|
154
134
|
/**
|
|
155
135
|
* Declare the turn over. Whatever is still waiting had no boundary left, so
|
|
156
136
|
* it is handed back for the caller to send as its own turn.
|
|
157
137
|
*/
|
|
158
138
|
closeTurn() {
|
|
159
|
-
this.#
|
|
160
|
-
this.#turnPaused = false;
|
|
161
|
-
this.#releasePendingSteers({ reason: 'turn_closed' });
|
|
139
|
+
this.#turnInputMailbox.closeTurn();
|
|
162
140
|
}
|
|
163
141
|
abort() {
|
|
164
142
|
this.abortSegment();
|
|
165
143
|
// An aborted turn will not resume, so nothing may keep waiting on it.
|
|
166
|
-
this.#
|
|
167
|
-
this.#turnPaused = false;
|
|
168
|
-
this.#releasePendingSteers({ reason: 'aborted' });
|
|
144
|
+
this.#turnInputMailbox.abortTurn();
|
|
169
145
|
}
|
|
170
146
|
/**
|
|
171
147
|
* Stop the segment currently streaming without judging the turn's fate.
|
|
@@ -209,6 +185,15 @@ export class ApplicationRunLoop {
|
|
|
209
185
|
return true;
|
|
210
186
|
return state.runBudget.grantExtension('parent').granted;
|
|
211
187
|
}
|
|
188
|
+
#createToolCallExecution() {
|
|
189
|
+
return new ToolCallExecution({
|
|
190
|
+
toolLifecycle: this.#deps.toolLifecycle,
|
|
191
|
+
getOnToolDispatch: this.#deps.getOnToolDispatch,
|
|
192
|
+
resolveMaxParallelToolCalls: this.#deps.resolveMaxParallelToolCalls,
|
|
193
|
+
isMaxTurnsExceeded: (error) => error instanceof MaxTurnsExceededError,
|
|
194
|
+
logDiagnostic: this.#deps.logDiagnostic,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
212
197
|
/**
|
|
213
198
|
* Hand the running turn a user message to send with its next model request.
|
|
214
199
|
*
|
|
@@ -234,32 +219,21 @@ export class ApplicationRunLoop {
|
|
|
234
219
|
* only released or admitted.
|
|
235
220
|
*/
|
|
236
221
|
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
|
-
});
|
|
222
|
+
return this.#turnInputMailbox.offer(items, options);
|
|
244
223
|
}
|
|
245
224
|
/**
|
|
246
225
|
* Drop a still-waiting steer before it reaches a request boundary. Returns
|
|
247
226
|
* `false` when the id is unknown, including when it was already admitted.
|
|
248
227
|
*
|
|
249
|
-
* Invariant: this and
|
|
250
|
-
* latter drains
|
|
228
|
+
* Invariant: this and `TurnInputMailbox.admitAtRequestBoundary` are both synchronous,
|
|
229
|
+
* and the latter drains the mailbox in a single pass — so the two can never
|
|
251
230
|
* interleave. A retraction is decided in the same tick against whatever is
|
|
252
|
-
* currently
|
|
231
|
+
* currently pending; once an item has been admitted it is no
|
|
253
232
|
* longer in that array for this method to find. No locking is needed to
|
|
254
233
|
* close the race between "the user retracts" and "the turn admits".
|
|
255
234
|
*/
|
|
256
235
|
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;
|
|
236
|
+
return this.#turnInputMailbox.retract(id);
|
|
263
237
|
}
|
|
264
238
|
/**
|
|
265
239
|
* Replace a waiting steer's items in place, keeping its position (and thus
|
|
@@ -268,21 +242,7 @@ export class ApplicationRunLoop {
|
|
|
268
242
|
* same synchronicity invariant as `retractSteer`.
|
|
269
243
|
*/
|
|
270
244
|
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');
|
|
245
|
+
return this.#turnInputMailbox.edit(id, items);
|
|
286
246
|
}
|
|
287
247
|
/**
|
|
288
248
|
* Append waiting steers to the turn as ordinary user messages.
|
|
@@ -291,24 +251,6 @@ export class ApplicationRunLoop {
|
|
|
291
251
|
* folded into a tool result — so the provider sees the user speaking after
|
|
292
252
|
* the tool results of the round that was in flight when they typed.
|
|
293
253
|
*/
|
|
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
254
|
startStream(agent, input, options = {}) {
|
|
313
255
|
// Without a declared turn scope, a fresh stream is the only evidence this
|
|
314
256
|
// loop gets that a new turn has begun: anything still waiting belonged to
|
|
@@ -316,14 +258,15 @@ export class ApplicationRunLoop {
|
|
|
316
258
|
// With one, this call may equally be the same turn restarting after a
|
|
317
259
|
// retry, which the loop cannot tell apart — so `openTurn`/`closeTurn` own
|
|
318
260
|
// the decision instead.
|
|
319
|
-
this.#
|
|
320
|
-
if (!this.#turnOpen)
|
|
321
|
-
this.#releasePendingSteers({ reason: 'superseded_by_new_turn' });
|
|
261
|
+
this.#turnInputMailbox.startStream();
|
|
322
262
|
const state = {
|
|
323
263
|
agent,
|
|
264
|
+
toolExecution: this.#createToolCallExecution(),
|
|
324
265
|
recoveryBudget: options.recoveryBudget,
|
|
325
266
|
input: normalizeInput(input),
|
|
326
267
|
history: normalizeHistory(input),
|
|
268
|
+
compactionHistory: options.compactionHistory,
|
|
269
|
+
usesDeltaHistory: Boolean(options.previousResponseId) && options.disableChainingForAttempt !== true,
|
|
327
270
|
// A response ID is usable only after its provider origin is recorded.
|
|
328
271
|
// This also makes old callers that omit providerId fail closed.
|
|
329
272
|
responseId: options.disableChainingForAttempt !== true &&
|
|
@@ -331,7 +274,6 @@ export class ApplicationRunLoop {
|
|
|
331
274
|
options.supportsConversationChaining === true
|
|
332
275
|
? options.previousResponseId ?? undefined
|
|
333
276
|
: undefined,
|
|
334
|
-
pendingApprovals: [],
|
|
335
277
|
supportsConversationChaining: options.supportsConversationChaining === true,
|
|
336
278
|
currentProviderId: options.providerId,
|
|
337
279
|
responseProviderId: options.providerId && options.supportsConversationChaining === true && options.previousResponseId
|
|
@@ -393,11 +335,8 @@ export class ApplicationRunLoop {
|
|
|
393
335
|
state.approvals = new ApprovalLedger();
|
|
394
336
|
// A continuation handle from before approval batching carried only the
|
|
395
337
|
// 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
|
-
}
|
|
338
|
+
if (!state.toolExecution)
|
|
339
|
+
state.toolExecution = this.#createToolCallExecution();
|
|
401
340
|
// Handles created before cost accounting existed have no record list.
|
|
402
341
|
if (!state.costRecords)
|
|
403
342
|
state.costRecords = [];
|
|
@@ -448,6 +387,8 @@ export class ApplicationRunLoop {
|
|
|
448
387
|
// root closure for callers that do not provide one again.
|
|
449
388
|
if (options.requestPreparation)
|
|
450
389
|
state.requestPreparation = options.requestPreparation;
|
|
390
|
+
if (options.compactionHistory)
|
|
391
|
+
state.compactionHistory = options.compactionHistory;
|
|
451
392
|
if (options.disableChainingForAttempt === true) {
|
|
452
393
|
state.disableChainingForAttempt = true;
|
|
453
394
|
state.responseId = undefined;
|
|
@@ -467,10 +408,8 @@ export class ApplicationRunLoop {
|
|
|
467
408
|
this.abortSegment();
|
|
468
409
|
const controller = new AbortController();
|
|
469
410
|
this.#activeAbortController = controller;
|
|
470
|
-
this.#
|
|
411
|
+
this.#turnInputMailbox.startSegment();
|
|
471
412
|
state.runBudget?.resume();
|
|
472
|
-
// This segment is running, so the turn is no longer paused between them.
|
|
473
|
-
this.#turnPaused = false;
|
|
474
413
|
if (options.signal) {
|
|
475
414
|
if (options.signal.aborted)
|
|
476
415
|
controller.abort();
|
|
@@ -531,42 +470,43 @@ export class ApplicationRunLoop {
|
|
|
531
470
|
return;
|
|
532
471
|
if (this.#activeAbortController === controller)
|
|
533
472
|
this.#activeAbortController = null;
|
|
534
|
-
this.#runInFlight = false;
|
|
535
473
|
// A segment that ends holding approvals has paused the turn, not ended
|
|
536
474
|
// it: the caller resumes through continueRunStream, which offers
|
|
537
475
|
// another request boundary. Injections wait for it. Only a segment
|
|
538
476
|
// that ends with nothing outstanding has truly finished the turn, and
|
|
539
477
|
// then anything still waiting has to be sent as its own turn instead.
|
|
540
|
-
const pendingApprovals = state.pendingApprovals
|
|
478
|
+
const pendingApprovals = state.toolExecution.pendingApprovals.length;
|
|
541
479
|
const pendingBudgetInteraction = state.pendingRunBudgetInteraction !== undefined;
|
|
542
480
|
const cancelled = stream.cancelled === true;
|
|
543
|
-
|
|
544
|
-
|
|
481
|
+
const turnPaused = (pendingApprovals > 0 || pendingBudgetInteraction) && !cancelled && exitError === undefined;
|
|
482
|
+
this.#turnInputMailbox.settleSegment({
|
|
483
|
+
paused: turnPaused,
|
|
484
|
+
reason: {
|
|
485
|
+
pendingApprovals,
|
|
486
|
+
pendingBudgetInteraction,
|
|
487
|
+
cancelled,
|
|
488
|
+
error: exitError instanceof Error ? exitError.name : exitError ? String(exitError) : undefined,
|
|
489
|
+
turnCount: state.turnCount,
|
|
490
|
+
},
|
|
491
|
+
});
|
|
492
|
+
if (turnPaused)
|
|
545
493
|
return;
|
|
546
494
|
if (this.#activeRunBudgetState === state)
|
|
547
495
|
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
496
|
});
|
|
561
497
|
this.#activeRunBudgetState = state.runBudget ? state : undefined;
|
|
562
498
|
return stream;
|
|
563
499
|
}
|
|
564
500
|
/** Route boundary advice through the same admission lane as mode notices. */
|
|
565
501
|
#queuePendingSystemNotice(text) {
|
|
566
|
-
this.#
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
502
|
+
this.#turnInputMailbox.enqueueInternal({ type: 'message', role: 'user', content: `[Mode Notice] ${text}` });
|
|
503
|
+
}
|
|
504
|
+
#admitPendingSteers(state, stream, queue) {
|
|
505
|
+
this.#turnInputMailbox.admitAtRequestBoundary((item) => {
|
|
506
|
+
state.history.push(item);
|
|
507
|
+
state.input.push(...normalizeApplicationInput([item]));
|
|
508
|
+
outputPush(stream, queue, { type: 'item', item });
|
|
509
|
+
}, state.turnCount);
|
|
570
510
|
}
|
|
571
511
|
async #execute(state, stream, queue, options, toolContext, requestAbortController) {
|
|
572
512
|
while (true) {
|
|
@@ -586,35 +526,14 @@ export class ApplicationRunLoop {
|
|
|
586
526
|
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
587
527
|
}
|
|
588
528
|
}
|
|
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];
|
|
529
|
+
if (state.toolExecution.pendingApprovals.length > 0 && state.approvalDecision) {
|
|
530
|
+
state.toolExecution.resolveApproval(state.approvalDecisionCallId, state.approvalDecision, state.approvalMessage, state.approvals);
|
|
611
531
|
state.approvalDecision = undefined;
|
|
612
532
|
state.approvalDecisionCallId = undefined;
|
|
613
533
|
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;
|
|
534
|
+
await state.toolExecution.settle(this.#toolCallContext(state, stream, queue, toolContext));
|
|
535
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
536
|
+
if (state.toolExecution.pendingApprovals.length > 0) {
|
|
618
537
|
return finish(stream, state, queue);
|
|
619
538
|
}
|
|
620
539
|
// Nothing is outstanding, so this segment is terminal — see
|
|
@@ -627,11 +546,10 @@ export class ApplicationRunLoop {
|
|
|
627
546
|
// A budget interaction can park a response after its tool calls are
|
|
628
547
|
// recorded but before any body runs. Resume those retained calls only
|
|
629
548
|
// 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;
|
|
549
|
+
if (state.toolExecution.hasPlan) {
|
|
550
|
+
await state.toolExecution.settle(this.#toolCallContext(state, stream, queue, toolContext));
|
|
551
|
+
if (state.toolExecution.pendingApprovals.length) {
|
|
552
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
635
553
|
return finish(stream, state, queue);
|
|
636
554
|
}
|
|
637
555
|
}
|
|
@@ -643,25 +561,36 @@ export class ApplicationRunLoop {
|
|
|
643
561
|
this.#evaluateRunBudget(state, stream, queue);
|
|
644
562
|
if (state.pendingRunBudgetInteraction)
|
|
645
563
|
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
646
|
-
const
|
|
564
|
+
const compactionHistoryResult = state.usesDeltaHistory
|
|
565
|
+
? state.compactionHistory
|
|
566
|
+
? mergeChainedCompactionHistory(state.compactionHistory, state.history)
|
|
567
|
+
: { kind: 'skipped', reason: 'missing_snapshot' }
|
|
568
|
+
: { kind: 'ready', history: state.history };
|
|
569
|
+
const boundaryDecision = options.onRequestBoundary?.(compactionHistoryResult.kind === 'ready' ? compactionHistoryResult.history : state.history, (text) => this.#queuePendingSystemNotice(text), {
|
|
647
570
|
...(state.lastCompletedInputTokens !== undefined
|
|
648
571
|
? { lastCompletedInputTokens: state.lastCompletedInputTokens }
|
|
649
572
|
: {}),
|
|
573
|
+
...(compactionHistoryResult.kind === 'skipped'
|
|
574
|
+
? { compactionSkipReason: compactionHistoryResult.reason }
|
|
575
|
+
: {}),
|
|
650
576
|
});
|
|
651
|
-
|
|
577
|
+
const compactionHistory = compactionHistoryResult.kind === 'ready' ? compactionHistoryResult.history : undefined;
|
|
578
|
+
if (options.boundaryCompaction && compactionHistory && !boundaryDecision?.deferCompaction) {
|
|
652
579
|
const compactionStartedAt = Date.now();
|
|
653
580
|
const compaction = await options.boundaryCompaction.compact({
|
|
654
|
-
history:
|
|
581
|
+
history: compactionHistory,
|
|
655
582
|
automaticCompactionsThisRun: state.automaticCompactionsThisRun ?? 0,
|
|
656
583
|
lastCompletedInputTokens: state.lastCompletedInputTokens,
|
|
657
584
|
signal: options.signal,
|
|
658
585
|
onStarted: (provider) => outputPush(stream, queue, { type: 'context_compaction_started', provider, strategy: 'local' }),
|
|
659
586
|
});
|
|
660
587
|
if (compaction.kind === 'compacted') {
|
|
588
|
+
state.compactedDuringRun = true;
|
|
661
589
|
state.history.splice(0, state.history.length, ...compaction.history);
|
|
662
590
|
state.input.splice(0, state.input.length, ...normalizeApplicationInput(compaction.modelInput));
|
|
663
591
|
state.responseId = undefined;
|
|
664
592
|
state.responseProviderId = undefined;
|
|
593
|
+
state.usesDeltaHistory = false;
|
|
665
594
|
if (compaction.costRecords?.length) {
|
|
666
595
|
state.costRecords ??= [];
|
|
667
596
|
state.costRecords.push(...compaction.costRecords);
|
|
@@ -740,6 +669,7 @@ export class ApplicationRunLoop {
|
|
|
740
669
|
let provisionalReasoningCharacters = 0;
|
|
741
670
|
let provisionalTextDeltas = 0;
|
|
742
671
|
let provisionalReasoningDeltas = 0;
|
|
672
|
+
let lastTextPartId;
|
|
743
673
|
criticalWrapUp = state.criticalWrapUpPending === true && state.criticalWrapUpDispatched !== true;
|
|
744
674
|
if (criticalWrapUp)
|
|
745
675
|
state.criticalWrapUpDispatched = true;
|
|
@@ -749,10 +679,19 @@ export class ApplicationRunLoop {
|
|
|
749
679
|
state.responseId = undefined;
|
|
750
680
|
state.responseProviderId = undefined;
|
|
751
681
|
}
|
|
682
|
+
// A per-request signal lets a recoverable guard trip cancel only this
|
|
683
|
+
// provider request; the segment signal still cancels everything.
|
|
684
|
+
const requestSignal = new AbortController();
|
|
685
|
+
const abortRequest = () => requestSignal.abort();
|
|
686
|
+
if (options.signal?.aborted)
|
|
687
|
+
requestSignal.abort();
|
|
688
|
+
else
|
|
689
|
+
options.signal?.addEventListener('abort', abortRequest, { once: true });
|
|
690
|
+
const requestInstructions = state.agent.resolveInstructionsForRequest?.() ?? state.agent.instructions;
|
|
752
691
|
const request = {
|
|
753
692
|
instructions: criticalWrapUp
|
|
754
|
-
? `${
|
|
755
|
-
:
|
|
693
|
+
? `${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.`
|
|
694
|
+
: requestInstructions,
|
|
756
695
|
...(state.supportsConversationChaining &&
|
|
757
696
|
!disableChaining &&
|
|
758
697
|
state.responseId &&
|
|
@@ -780,7 +719,7 @@ export class ApplicationRunLoop {
|
|
|
780
719
|
: state.agent.modelSettings.providerData,
|
|
781
720
|
}
|
|
782
721
|
: {}),
|
|
783
|
-
|
|
722
|
+
signal: requestSignal.signal,
|
|
784
723
|
...(state.recoveryBudget ? { recoveryBudget: state.recoveryBudget } : {}),
|
|
785
724
|
};
|
|
786
725
|
activeRequest = request;
|
|
@@ -824,11 +763,18 @@ export class ApplicationRunLoop {
|
|
|
824
763
|
continue;
|
|
825
764
|
}
|
|
826
765
|
if (event.type === 'text_delta') {
|
|
766
|
+
const startsNewPart = event.partId !== undefined &&
|
|
767
|
+
lastTextPartId !== undefined &&
|
|
768
|
+
event.partId !== lastTextPartId &&
|
|
769
|
+
event.text.length > 0;
|
|
770
|
+
if (event.partId !== undefined && event.text.length > 0)
|
|
771
|
+
lastTextPartId = event.partId;
|
|
772
|
+
const text = startsNewPart ? `${ASSISTANT_TEXT_PART_SEPARATOR}${event.text}` : event.text;
|
|
827
773
|
toolArgumentRunaway?.observeText();
|
|
828
|
-
generationGuard.observeText(
|
|
829
|
-
provisionalTextCharacters +=
|
|
774
|
+
generationGuard.observeText(text);
|
|
775
|
+
provisionalTextCharacters += text.length;
|
|
830
776
|
provisionalTextDeltas++;
|
|
831
|
-
outputPush(stream, queue, { type: 'text_delta', text
|
|
777
|
+
outputPush(stream, queue, { type: 'text_delta', text });
|
|
832
778
|
continue;
|
|
833
779
|
}
|
|
834
780
|
if (event.type === 'codex_rate_limits') {
|
|
@@ -884,7 +830,12 @@ export class ApplicationRunLoop {
|
|
|
884
830
|
break;
|
|
885
831
|
}
|
|
886
832
|
catch (error) {
|
|
887
|
-
|
|
833
|
+
const recoverOversizedToolArgument = isOversizedToolArgumentTrip(error) &&
|
|
834
|
+
(state.oversizedToolArgumentRecoveries ?? 0) < MAX_OVERSIZED_TOOL_ARGUMENT_RECOVERIES &&
|
|
835
|
+
!options.signal?.aborted;
|
|
836
|
+
if (recoverOversizedToolArgument)
|
|
837
|
+
requestSignal.abort();
|
|
838
|
+
else if (error instanceof GenerationGuardError)
|
|
888
839
|
requestAbortController.abort();
|
|
889
840
|
const decision = classifyInLoopModelRetry(error, attempt, maxRetries, Math.random, {
|
|
890
841
|
previousResponseId: activeRequest?.previousResponseId,
|
|
@@ -904,6 +855,23 @@ export class ApplicationRunLoop {
|
|
|
904
855
|
});
|
|
905
856
|
}
|
|
906
857
|
};
|
|
858
|
+
if (recoverOversizedToolArgument) {
|
|
859
|
+
// No tool ran: a call is dispatched only after its arguments
|
|
860
|
+
// complete. Discard the partial response and ask for smaller calls.
|
|
861
|
+
state.oversizedToolArgumentRecoveries = (state.oversizedToolArgumentRecoveries ?? 0) + 1;
|
|
862
|
+
state.input.splice(inputLengthBefore);
|
|
863
|
+
state.history.splice(historyLengthBefore);
|
|
864
|
+
state.criticalWrapUpDispatched = criticalWrapUpDispatchedBefore;
|
|
865
|
+
rollbackProvisionalAttempt();
|
|
866
|
+
this.#deps.logDiagnostic?.('Recovering oversized tool argument in run loop', {
|
|
867
|
+
code: error.code,
|
|
868
|
+
recovery: state.oversizedToolArgumentRecoveries,
|
|
869
|
+
maxRecoveries: MAX_OVERSIZED_TOOL_ARGUMENT_RECOVERIES,
|
|
870
|
+
});
|
|
871
|
+
this.#queuePendingSystemNotice(oversizedToolArgumentNotice(error.message));
|
|
872
|
+
this.#admitPendingSteers(state, stream, queue);
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
907
875
|
if (decision.retryable && !options.signal?.aborted) {
|
|
908
876
|
attempt++;
|
|
909
877
|
state.input.splice(inputLengthBefore);
|
|
@@ -920,7 +888,7 @@ export class ApplicationRunLoop {
|
|
|
920
888
|
maxRetries,
|
|
921
889
|
kind: decision.kind,
|
|
922
890
|
delayMs: decision.delayMs,
|
|
923
|
-
error:
|
|
891
|
+
error: describeError(error),
|
|
924
892
|
});
|
|
925
893
|
await (this.#deps.waitBeforeModelRetry ?? sleepWithAbort)(decision.delayMs, options.signal);
|
|
926
894
|
continue;
|
|
@@ -955,6 +923,9 @@ export class ApplicationRunLoop {
|
|
|
955
923
|
});
|
|
956
924
|
throw error;
|
|
957
925
|
}
|
|
926
|
+
finally {
|
|
927
|
+
options.signal?.removeEventListener('abort', abortRequest);
|
|
928
|
+
}
|
|
958
929
|
}
|
|
959
930
|
if (!completion) {
|
|
960
931
|
// A few application-owned model fixtures (and legacy adapters) end a
|
|
@@ -976,11 +947,10 @@ export class ApplicationRunLoop {
|
|
|
976
947
|
return finish(stream, state, queue);
|
|
977
948
|
}
|
|
978
949
|
await this.#dispatchToolCalls(state, stream, queue, streamedToolCalls, toolContext);
|
|
979
|
-
if (state.
|
|
950
|
+
if (state.toolExecution.terminateAfterExecution)
|
|
980
951
|
return finish(stream, state, queue);
|
|
981
|
-
if (state.
|
|
982
|
-
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
983
|
-
this.#turnPaused = true;
|
|
952
|
+
if (state.toolExecution.pendingApprovals.length > 0) {
|
|
953
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
984
954
|
return finish(stream, state, queue);
|
|
985
955
|
}
|
|
986
956
|
continue;
|
|
@@ -1105,7 +1075,10 @@ export class ApplicationRunLoop {
|
|
|
1105
1075
|
continue;
|
|
1106
1076
|
const historyItem = {
|
|
1107
1077
|
...item.item,
|
|
1108
|
-
providerOpaque: {
|
|
1078
|
+
providerOpaque: {
|
|
1079
|
+
provider: item.provider,
|
|
1080
|
+
...(item.sourceProvider ? { sourceProvider: item.sourceProvider } : {}),
|
|
1081
|
+
},
|
|
1109
1082
|
};
|
|
1110
1083
|
state.history.push(historyItem);
|
|
1111
1084
|
state.input.push(item);
|
|
@@ -1118,7 +1091,8 @@ export class ApplicationRunLoop {
|
|
|
1118
1091
|
// must not enter the canonical history: the truthy check used to let
|
|
1119
1092
|
// "\n\n" through, accumulating junk in model context.
|
|
1120
1093
|
.map((part) => part.text)
|
|
1121
|
-
.
|
|
1094
|
+
.filter((text) => text.length > 0)
|
|
1095
|
+
.join(ASSISTANT_TEXT_PART_SEPARATOR)
|
|
1122
1096
|
.trim();
|
|
1123
1097
|
if (assistantText) {
|
|
1124
1098
|
stream.finalOutput = assistantText;
|
|
@@ -1142,7 +1116,7 @@ export class ApplicationRunLoop {
|
|
|
1142
1116
|
if (!state.criticalWrapUpPending && toolCalls.length > 0) {
|
|
1143
1117
|
await this.#dispatchToolCalls(state, stream, queue, toolCalls, toolContext);
|
|
1144
1118
|
}
|
|
1145
|
-
if (state.
|
|
1119
|
+
if (state.toolExecution.terminateAfterExecution)
|
|
1146
1120
|
return finish(stream, state, queue);
|
|
1147
1121
|
// A critical subagent gets exactly this final tool-free model call.
|
|
1148
1122
|
if (criticalWrapUp)
|
|
@@ -1150,9 +1124,8 @@ export class ApplicationRunLoop {
|
|
|
1150
1124
|
if (state.pendingRunBudgetInteraction && toolCalls.length > 0) {
|
|
1151
1125
|
return this.#pauseForRunBudgetInteraction(state, stream, queue);
|
|
1152
1126
|
}
|
|
1153
|
-
if (state.pendingApprovals.length > 0) {
|
|
1154
|
-
stream.interruptions = state.pendingApprovals.map((item) => item.interruption);
|
|
1155
|
-
this.#turnPaused = true;
|
|
1127
|
+
if (state.toolExecution.pendingApprovals.length > 0) {
|
|
1128
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
1156
1129
|
return finish(stream, state, queue);
|
|
1157
1130
|
}
|
|
1158
1131
|
if (!sawToolCall) {
|
|
@@ -1164,178 +1137,51 @@ export class ApplicationRunLoop {
|
|
|
1164
1137
|
}
|
|
1165
1138
|
}
|
|
1166
1139
|
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 = {
|
|
1140
|
+
const context = this.#toolCallContext(state, stream, queue, toolContext);
|
|
1141
|
+
await state.toolExecution.plan(events, context);
|
|
1142
|
+
stream.interruptions = state.toolExecution.pendingApprovals.map((item) => item.interruption);
|
|
1143
|
+
if (!state.pendingRunBudgetInteraction)
|
|
1144
|
+
await state.toolExecution.settle(context);
|
|
1145
|
+
}
|
|
1146
|
+
#toolCallContext(state, stream, queue, toolContext) {
|
|
1147
|
+
return {
|
|
1148
|
+
tools: state.agent.tools,
|
|
1149
|
+
approvals: state.approvals,
|
|
1150
|
+
toolContext,
|
|
1151
|
+
sessionId: state.sessionId,
|
|
1152
|
+
turnId: state.turnId,
|
|
1153
|
+
hookScope: state.hookScope,
|
|
1154
|
+
onCall: (event) => {
|
|
1155
|
+
const callItem = {
|
|
1156
|
+
type: event.toolType === 'custom' ? 'custom_tool_call' : 'function_call',
|
|
1231
1157
|
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,
|
|
1158
|
+
name: event.name,
|
|
1159
|
+
...(event.toolType === 'custom' ? { input: event.arguments } : { arguments: event.arguments }),
|
|
1244
1160
|
};
|
|
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) {
|
|
1161
|
+
state.history.push(callItem);
|
|
1162
|
+
state.input.push({
|
|
1163
|
+
type: 'tool_call',
|
|
1164
|
+
id: event.id,
|
|
1165
|
+
name: event.name,
|
|
1166
|
+
arguments: event.arguments,
|
|
1167
|
+
...(event.toolType ? { toolType: event.toolType } : {}),
|
|
1168
|
+
});
|
|
1169
|
+
outputPush(stream, queue, { type: 'item', item: callItem });
|
|
1170
|
+
},
|
|
1171
|
+
onDispatch: (entry) => {
|
|
1301
1172
|
outputPush(stream, queue, {
|
|
1302
1173
|
type: 'tool_call_dispatched',
|
|
1303
1174
|
callId: entry.event.id,
|
|
1304
1175
|
toolName: entry.event.name,
|
|
1305
1176
|
});
|
|
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);
|
|
1177
|
+
},
|
|
1178
|
+
onToolStall: (input) => {
|
|
1179
|
+
const stallEvent = state.runBudget?.observeToolCall(input);
|
|
1180
|
+
if (stallEvent)
|
|
1181
|
+
this.#emitRunBudgetEvent(state, stallEvent, 'Tool stall evidence', stream, queue);
|
|
1182
|
+
},
|
|
1183
|
+
onResult: (entry, result) => this.#appendToolResult(state, stream, queue, entry, result),
|
|
1184
|
+
};
|
|
1339
1185
|
}
|
|
1340
1186
|
#appendToolResult(state, stream, queue, entry, result) {
|
|
1341
1187
|
const runCodeExecution = getRunCodeExecutionResult(result);
|
|
@@ -1363,57 +1209,6 @@ export class ApplicationRunLoop {
|
|
|
1363
1209
|
outputPush(stream, queue, { type: 'item', item: resultItem });
|
|
1364
1210
|
this.#evaluateRunBudget(state, stream, queue);
|
|
1365
1211
|
}
|
|
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
1212
|
#nextRequestId() {
|
|
1418
1213
|
nextCostRequestSeq += 1;
|
|
1419
1214
|
return `req-${nextCostRequestSeq}`;
|
|
@@ -1477,33 +1272,8 @@ export class ApplicationRunLoop {
|
|
|
1477
1272
|
if (!interaction)
|
|
1478
1273
|
return finish(stream, state, queue);
|
|
1479
1274
|
stream.interruptions = [interaction];
|
|
1480
|
-
this.#turnPaused = true;
|
|
1481
1275
|
return finish(stream, state, queue);
|
|
1482
1276
|
}
|
|
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
1277
|
}
|
|
1508
1278
|
function isLunaChainedRequest(state, request) {
|
|
1509
1279
|
return (state.currentProviderId === 'codex' &&
|
|
@@ -1513,6 +1283,12 @@ function isLunaChainedRequest(state, request) {
|
|
|
1513
1283
|
request.input.length === 1 &&
|
|
1514
1284
|
request.input[0]?.type === 'tool_result');
|
|
1515
1285
|
}
|
|
1286
|
+
function getInterruptionCallId(value) {
|
|
1287
|
+
if (typeof value !== 'object' || value === null)
|
|
1288
|
+
return undefined;
|
|
1289
|
+
const callId = value.callId;
|
|
1290
|
+
return typeof callId === 'string' ? callId : undefined;
|
|
1291
|
+
}
|
|
1516
1292
|
function outputPush(stream, queue, item) {
|
|
1517
1293
|
stream.output.push(item);
|
|
1518
1294
|
if (stream.newItems !== stream.output)
|
|
@@ -1521,6 +1297,7 @@ function outputPush(stream, queue, item) {
|
|
|
1521
1297
|
}
|
|
1522
1298
|
function finish(stream, state, queue) {
|
|
1523
1299
|
stream.history = state.history;
|
|
1300
|
+
stream.historyReplacedByCompaction = state.compactedDuringRun === true;
|
|
1524
1301
|
stream.terminalCause = state.terminalCause;
|
|
1525
1302
|
stream.latestProviderInputTokens = state.lastCompletedInputTokens;
|
|
1526
1303
|
if (state.supportsConversationChaining &&
|
|
@@ -1623,31 +1400,6 @@ function normalizeModelUsage(usage) {
|
|
|
1623
1400
|
reasoningTokens: rawUsage.outputTokens?.reasoning ?? rawUsage.reasoningTokens,
|
|
1624
1401
|
});
|
|
1625
1402
|
}
|
|
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
1403
|
function toModelTools(tools) {
|
|
1652
1404
|
return tools.map((tool) => tool.modelTool
|
|
1653
1405
|
? {
|
|
@@ -1685,6 +1437,37 @@ function normalizeHistory(input) {
|
|
|
1685
1437
|
return [{ type: 'message', role: 'user', content: input }];
|
|
1686
1438
|
return Array.isArray(input) ? [...input] : [input];
|
|
1687
1439
|
}
|
|
1440
|
+
function mergeChainedCompactionHistory(sessionHistory, deltaHistory) {
|
|
1441
|
+
const firstDeltaItem = deltaHistory[0];
|
|
1442
|
+
if (!firstDeltaItem || firstDeltaItem.type !== 'message' || firstDeltaItem.role !== 'user') {
|
|
1443
|
+
return { kind: 'skipped', reason: 'user_mismatch' };
|
|
1444
|
+
}
|
|
1445
|
+
let latestUserIndex = -1;
|
|
1446
|
+
for (let index = sessionHistory.length - 1; index >= 0; index--) {
|
|
1447
|
+
const item = sessionHistory[index];
|
|
1448
|
+
if (item.type === 'message' && item.role === 'user') {
|
|
1449
|
+
latestUserIndex = index;
|
|
1450
|
+
break;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
if (latestUserIndex < 0)
|
|
1454
|
+
return { kind: 'skipped', reason: 'user_mismatch' };
|
|
1455
|
+
const latestSessionUser = sessionHistory[latestUserIndex];
|
|
1456
|
+
const normalizedDeltaUser = normalizeApplicationInput([firstDeltaItem]);
|
|
1457
|
+
const normalizedSessionUser = normalizeApplicationInput([latestSessionUser]);
|
|
1458
|
+
if (JSON.stringify(normalizedDeltaUser) !== JSON.stringify(normalizedSessionUser)) {
|
|
1459
|
+
return { kind: 'skipped', reason: 'user_mismatch' };
|
|
1460
|
+
}
|
|
1461
|
+
return {
|
|
1462
|
+
kind: 'ready',
|
|
1463
|
+
history: [
|
|
1464
|
+
...sessionHistory.slice(0, latestUserIndex),
|
|
1465
|
+
firstDeltaItem,
|
|
1466
|
+
...sessionHistory.slice(latestUserIndex + 1),
|
|
1467
|
+
...deltaHistory.slice(1),
|
|
1468
|
+
],
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1688
1471
|
function asRecord(value) {
|
|
1689
1472
|
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
|
|
1690
1473
|
}
|
|
@@ -1814,7 +1597,14 @@ function isProviderOpaque(item) {
|
|
|
1814
1597
|
function normalizeInputItem(item) {
|
|
1815
1598
|
if (isProviderOpaque(item)) {
|
|
1816
1599
|
const { providerOpaque: _marker, ...providerItem } = item;
|
|
1817
|
-
return [
|
|
1600
|
+
return [
|
|
1601
|
+
{
|
|
1602
|
+
type: 'provider_opaque',
|
|
1603
|
+
provider: item.providerOpaque.provider,
|
|
1604
|
+
...(item.providerOpaque.sourceProvider ? { sourceProvider: item.providerOpaque.sourceProvider } : {}),
|
|
1605
|
+
item: providerItem,
|
|
1606
|
+
},
|
|
1607
|
+
];
|
|
1818
1608
|
}
|
|
1819
1609
|
if (item.type === 'function_call' || item.type === 'custom_tool_call') {
|
|
1820
1610
|
return [
|
|
@@ -1866,4 +1656,19 @@ function normalizeInputItem(item) {
|
|
|
1866
1656
|
}
|
|
1867
1657
|
return [{ type: 'message', role, content }];
|
|
1868
1658
|
}
|
|
1659
|
+
/**
|
|
1660
|
+
* A legitimate but oversized tool call (usually one large edit) trips the
|
|
1661
|
+
* tool-argument caps. Unlike runaway output it is answerable: tell the model
|
|
1662
|
+
* the call never ran and let it split the work, a bounded number of times.
|
|
1663
|
+
*/
|
|
1664
|
+
const MAX_OVERSIZED_TOOL_ARGUMENT_RECOVERIES = 2;
|
|
1665
|
+
function isOversizedToolArgumentTrip(error) {
|
|
1666
|
+
return (error instanceof GenerationGuardError &&
|
|
1667
|
+
(error.code === 'tool_argument_characters' || error.code === 'cumulative_tool_argument_characters'));
|
|
1668
|
+
}
|
|
1669
|
+
function oversizedToolArgumentNotice(guardMessage) {
|
|
1670
|
+
return (`Your previous response was discarded and its tool call was not executed. ${guardMessage} ` +
|
|
1671
|
+
'Redo the work in smaller tool calls, each well under that limit — for example, several targeted ' +
|
|
1672
|
+
'patches instead of rewriting a whole file in one call.');
|
|
1673
|
+
}
|
|
1869
1674
|
//# sourceMappingURL=application-run-loop.js.map
|