@qduc/term2 0.6.1 → 0.7.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/dist/agent.d.ts +9 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +138 -69
- package/dist/agent.js.map +1 -1
- package/dist/agent.test.js +165 -15
- package/dist/agent.test.js.map +1 -1
- package/dist/app.d.ts +14 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +168 -28
- package/dist/app.js.map +1 -1
- package/dist/app.large-uncached-warning.test.d.ts +2 -0
- package/dist/app.large-uncached-warning.test.d.ts.map +1 -0
- package/dist/app.large-uncached-warning.test.js +15 -0
- package/dist/app.large-uncached-warning.test.js.map +1 -0
- package/dist/app.startup-banner.test.js +3 -19
- package/dist/app.startup-banner.test.js.map +1 -1
- package/dist/cli.js +139 -69
- package/dist/cli.js.map +1 -1
- package/dist/components/Banner.d.ts.map +1 -1
- package/dist/components/Banner.js +35 -17
- package/dist/components/Banner.js.map +1 -1
- package/dist/components/BottomArea.d.ts +7 -1
- package/dist/components/BottomArea.d.ts.map +1 -1
- package/dist/components/BottomArea.js +8 -6
- package/dist/components/BottomArea.js.map +1 -1
- package/dist/components/BottomArea.test.js +14 -1
- package/dist/components/BottomArea.test.js.map +1 -1
- package/dist/components/CommandMessage.d.ts.map +1 -1
- package/dist/components/CommandMessage.js +31 -1
- package/dist/components/CommandMessage.js.map +1 -1
- package/dist/components/CommandMessage.test.js +150 -31
- package/dist/components/CommandMessage.test.js.map +1 -1
- package/dist/components/Common/MenuContainer.d.ts +20 -0
- package/dist/components/Common/MenuContainer.d.ts.map +1 -0
- package/dist/components/Common/MenuContainer.js +52 -0
- package/dist/components/Common/MenuContainer.js.map +1 -0
- package/dist/components/Common/ScrollableTabBar.d.ts +26 -0
- package/dist/components/Common/ScrollableTabBar.d.ts.map +1 -0
- package/dist/components/Common/ScrollableTabBar.js +26 -0
- package/dist/components/Common/ScrollableTabBar.js.map +1 -0
- package/dist/components/Common/compute-visible-tabs.d.ts +16 -0
- package/dist/components/Common/compute-visible-tabs.d.ts.map +1 -0
- package/dist/components/Common/compute-visible-tabs.js +53 -0
- package/dist/components/Common/compute-visible-tabs.js.map +1 -0
- package/dist/components/Common/compute-visible-tabs.test.d.ts +2 -0
- package/dist/components/Common/compute-visible-tabs.test.d.ts.map +1 -0
- package/dist/components/Common/compute-visible-tabs.test.js +97 -0
- package/dist/components/Common/compute-visible-tabs.test.js.map +1 -0
- package/dist/components/HandoffConfirmationPrompt.d.ts +9 -0
- package/dist/components/HandoffConfirmationPrompt.d.ts.map +1 -0
- package/dist/components/HandoffConfirmationPrompt.js +38 -0
- package/dist/components/HandoffConfirmationPrompt.js.map +1 -0
- package/dist/components/HandoffConfirmationPrompt.test.d.ts +2 -0
- package/dist/components/HandoffConfirmationPrompt.test.d.ts.map +1 -0
- package/dist/components/HandoffConfirmationPrompt.test.js +12 -0
- package/dist/components/HandoffConfirmationPrompt.test.js.map +1 -0
- package/dist/components/Input/PopupManager.d.ts +5 -1
- package/dist/components/Input/PopupManager.d.ts.map +1 -1
- package/dist/components/Input/PopupManager.js +2 -2
- package/dist/components/Input/PopupManager.js.map +1 -1
- package/dist/components/Input/popup-key-navigation.js +2 -2
- package/dist/components/Input/popup-key-navigation.js.map +1 -1
- package/dist/components/Input/popup-key-navigation.test.js +5 -3
- package/dist/components/Input/popup-key-navigation.test.js.map +1 -1
- package/dist/components/Input/popup-props.d.ts.map +1 -1
- package/dist/components/Input/popup-props.js +4 -0
- package/dist/components/Input/popup-props.js.map +1 -1
- package/dist/components/Input/popup-props.test.d.ts +2 -0
- package/dist/components/Input/popup-props.test.d.ts.map +1 -0
- package/dist/components/Input/popup-props.test.js +70 -0
- package/dist/components/Input/popup-props.test.js.map +1 -0
- package/dist/components/InputBox.d.ts +0 -1
- package/dist/components/InputBox.d.ts.map +1 -1
- package/dist/components/InputBox.js +66 -14
- package/dist/components/InputBox.js.map +1 -1
- package/dist/components/InputBox.test.js +192 -12
- package/dist/components/InputBox.test.js.map +1 -1
- package/dist/components/MessageList.d.ts +1 -0
- package/dist/components/MessageList.d.ts.map +1 -1
- package/dist/components/MessageList.js.map +1 -1
- package/dist/components/ModelSelectionMenu.d.ts.map +1 -1
- package/dist/components/ModelSelectionMenu.debug.test.d.ts +2 -0
- package/dist/components/ModelSelectionMenu.debug.test.d.ts.map +1 -0
- package/dist/components/ModelSelectionMenu.debug.test.js.map +1 -0
- package/dist/components/ModelSelectionMenu.js +29 -125
- package/dist/components/ModelSelectionMenu.js.map +1 -1
- package/dist/components/ModelSelectionMenu.test.js +9 -5
- package/dist/components/ModelSelectionMenu.test.js.map +1 -1
- package/dist/components/PathSelectionMenu.d.ts.map +1 -1
- package/dist/components/PathSelectionMenu.js +15 -55
- package/dist/components/PathSelectionMenu.js.map +1 -1
- package/dist/components/SettingsSelectionMenu.d.ts +4 -1
- package/dist/components/SettingsSelectionMenu.d.ts.map +1 -1
- package/dist/components/SettingsSelectionMenu.js +48 -104
- package/dist/components/SettingsSelectionMenu.js.map +1 -1
- package/dist/components/SettingsSelectionMenu.scroll.test.js +140 -0
- package/dist/components/SettingsSelectionMenu.scroll.test.js.map +1 -1
- package/dist/components/SettingsSelectionMenu.test.js +38 -5
- package/dist/components/SettingsSelectionMenu.test.js.map +1 -1
- package/dist/components/SettingsValueSelectionMenu.d.ts.map +1 -1
- package/dist/components/SettingsValueSelectionMenu.js +24 -51
- package/dist/components/SettingsValueSelectionMenu.js.map +1 -1
- package/dist/components/SlashCommandMenu.d.ts +1 -0
- package/dist/components/SlashCommandMenu.d.ts.map +1 -1
- package/dist/components/SlashCommandMenu.js +11 -14
- package/dist/components/SlashCommandMenu.js.map +1 -1
- package/dist/components/StatusBar.d.ts +2 -0
- package/dist/components/StatusBar.d.ts.map +1 -1
- package/dist/components/StatusBar.js +35 -2
- package/dist/components/StatusBar.js.map +1 -1
- package/dist/components/StatusBar.test.js +32 -0
- package/dist/components/StatusBar.test.js.map +1 -1
- package/dist/components/UndoSelectionMenu.d.ts.map +1 -1
- package/dist/components/UndoSelectionMenu.js +6 -33
- package/dist/components/UndoSelectionMenu.js.map +1 -1
- package/dist/context/InputContext.stability.test.js +9 -7
- package/dist/context/InputContext.stability.test.js.map +1 -1
- package/dist/env-setup.js +1 -0
- package/dist/env-setup.js.map +1 -1
- package/dist/hooks/use-app-commands.d.ts +22 -2
- package/dist/hooks/use-app-commands.d.ts.map +1 -1
- package/dist/hooks/use-app-commands.js +43 -3
- package/dist/hooks/use-app-commands.js.map +1 -1
- package/dist/hooks/use-app-commands.test.js +135 -1
- package/dist/hooks/use-app-commands.test.js.map +1 -1
- package/dist/hooks/use-conversation.clear.test.js +12 -7
- package/dist/hooks/use-conversation.clear.test.js.map +1 -1
- package/dist/hooks/use-conversation.d.ts +21 -1
- package/dist/hooks/use-conversation.d.ts.map +1 -1
- package/dist/hooks/use-conversation.js +81 -9
- package/dist/hooks/use-conversation.js.map +1 -1
- package/dist/hooks/use-escape-key.d.ts +8 -1
- package/dist/hooks/use-escape-key.d.ts.map +1 -1
- package/dist/hooks/use-escape-key.js +15 -4
- package/dist/hooks/use-escape-key.js.map +1 -1
- package/dist/hooks/use-escape-key.test.js +135 -28
- package/dist/hooks/use-escape-key.test.js.map +1 -1
- package/dist/hooks/use-input-history.test.js +14 -8
- package/dist/hooks/use-input-history.test.js.map +1 -1
- package/dist/hooks/use-mode-handlers.d.ts +12 -1
- package/dist/hooks/use-mode-handlers.d.ts.map +1 -1
- package/dist/hooks/use-mode-handlers.js +31 -1
- package/dist/hooks/use-mode-handlers.js.map +1 -1
- package/dist/hooks/use-model-selection.d.ts +6 -1
- package/dist/hooks/use-model-selection.d.ts.map +1 -1
- package/dist/hooks/use-model-selection.js +50 -8
- package/dist/hooks/use-model-selection.js.map +1 -1
- package/dist/hooks/use-model-selection.test.js +306 -50
- package/dist/hooks/use-model-selection.test.js.map +1 -1
- package/dist/hooks/use-path-completion.d.ts +4 -0
- package/dist/hooks/use-path-completion.d.ts.map +1 -1
- package/dist/hooks/use-path-completion.js +23 -17
- package/dist/hooks/use-path-completion.js.map +1 -1
- package/dist/hooks/use-path-completion.test.d.ts +2 -0
- package/dist/hooks/use-path-completion.test.d.ts.map +1 -0
- package/dist/hooks/use-path-completion.test.js +54 -0
- package/dist/hooks/use-path-completion.test.js.map +1 -0
- package/dist/hooks/use-runtime-settings.d.ts.map +1 -1
- package/dist/hooks/use-runtime-settings.js +7 -2
- package/dist/hooks/use-runtime-settings.js.map +1 -1
- package/dist/hooks/use-runtime-settings.test.d.ts +2 -0
- package/dist/hooks/use-runtime-settings.test.d.ts.map +1 -0
- package/dist/hooks/use-runtime-settings.test.js +45 -0
- package/dist/hooks/use-runtime-settings.test.js.map +1 -0
- package/dist/hooks/use-selection.d.ts +6 -2
- package/dist/hooks/use-selection.d.ts.map +1 -1
- package/dist/hooks/use-selection.js +53 -16
- package/dist/hooks/use-selection.js.map +1 -1
- package/dist/hooks/use-selection.test.d.ts +2 -0
- package/dist/hooks/use-selection.test.d.ts.map +1 -0
- package/dist/hooks/use-selection.test.js +132 -0
- package/dist/hooks/use-selection.test.js.map +1 -0
- package/dist/hooks/use-settings-completion.d.ts +19 -0
- package/dist/hooks/use-settings-completion.d.ts.map +1 -1
- package/dist/hooks/use-settings-completion.js +106 -18
- package/dist/hooks/use-settings-completion.js.map +1 -1
- package/dist/hooks/use-settings-completion.scroll.test.js +68 -29
- package/dist/hooks/use-settings-completion.scroll.test.js.map +1 -1
- package/dist/hooks/use-settings-completion.test.js +36 -1
- package/dist/hooks/use-settings-completion.test.js.map +1 -1
- package/dist/hooks/use-settings-value-completion.d.ts +7 -1
- package/dist/hooks/use-settings-value-completion.d.ts.map +1 -1
- package/dist/hooks/use-settings-value-completion.js +18 -7
- package/dist/hooks/use-settings-value-completion.js.map +1 -1
- package/dist/hooks/use-slash-commands.d.ts +5 -0
- package/dist/hooks/use-slash-commands.d.ts.map +1 -1
- package/dist/hooks/use-slash-commands.js +22 -2
- package/dist/hooks/use-slash-commands.js.map +1 -1
- package/dist/hooks/use-trigger-detection.test.js +9 -6
- package/dist/hooks/use-trigger-detection.test.js.map +1 -1
- package/dist/hooks/use-undo-selection.d.ts +4 -0
- package/dist/hooks/use-undo-selection.d.ts.map +1 -1
- package/dist/hooks/use-undo-selection.js +18 -1
- package/dist/hooks/use-undo-selection.js.map +1 -1
- package/dist/inspect_zod.d.ts +2 -0
- package/dist/inspect_zod.d.ts.map +1 -0
- package/dist/inspect_zod.js +16 -0
- package/dist/inspect_zod.js.map +1 -0
- package/dist/lib/openai-agent-client.d.ts +10 -3
- package/dist/lib/openai-agent-client.d.ts.map +1 -1
- package/dist/lib/openai-agent-client.js +191 -37
- package/dist/lib/openai-agent-client.js.map +1 -1
- package/dist/lib/openai-agent-client.public-methods.test.js +193 -0
- package/dist/lib/openai-agent-client.public-methods.test.js.map +1 -1
- package/dist/lib/openai-agent-client.test.js +71 -1
- package/dist/lib/openai-agent-client.test.js.map +1 -1
- package/dist/lib/tool-invoke.d.ts +3 -2
- package/dist/lib/tool-invoke.d.ts.map +1 -1
- package/dist/lib/tool-invoke.js +213 -10
- package/dist/lib/tool-invoke.js.map +1 -1
- package/dist/lib/tool-invoke.test.js +103 -0
- package/dist/lib/tool-invoke.test.js.map +1 -1
- package/dist/prompts/codex.md +105 -97
- package/dist/prompts/fragments/gpt-5.3-codex.md +7 -0
- package/dist/prompts/fragments/gpt-5.4-small.md +6 -0
- package/dist/prompts/fragments/gpt-5.4.md +7 -0
- package/dist/prompts/fragments/gpt-5.5.md +7 -0
- package/dist/prompts/gpt-5-modern.md +96 -54
- package/dist/prompts/gpt-5.md +7 -4
- package/dist/prompts/plan-mode-info.md +14 -3
- package/dist/prompts/prompt-constructor.d.ts +19 -0
- package/dist/prompts/prompt-constructor.d.ts.map +1 -0
- package/dist/prompts/prompt-constructor.js +53 -0
- package/dist/prompts/prompt-constructor.js.map +1 -0
- package/dist/prompts/prompt-constructor.test.d.ts +2 -0
- package/dist/prompts/prompt-constructor.test.d.ts.map +1 -0
- package/dist/prompts/prompt-constructor.test.js +99 -0
- package/dist/prompts/prompt-constructor.test.js.map +1 -0
- package/dist/prompts/prompt-constructor.test.ts +112 -0
- package/dist/prompts/prompt-constructor.ts +91 -0
- package/dist/prompts/prompt-profiles.d.ts +17 -0
- package/dist/prompts/prompt-profiles.d.ts.map +1 -0
- package/dist/prompts/prompt-profiles.js +61 -0
- package/dist/prompts/prompt-profiles.js.map +1 -0
- package/dist/prompts/prompt-profiles.ts +77 -0
- package/dist/prompts/prompt-selector.d.ts.map +1 -1
- package/dist/prompts/prompt-selector.js +3 -21
- package/dist/prompts/prompt-selector.js.map +1 -1
- package/dist/prompts/prompt-selector.ts +3 -25
- package/dist/prompts/reasoning-efficiency.d.ts.map +1 -1
- package/dist/prompts/reasoning-efficiency.js +2 -0
- package/dist/prompts/reasoning-efficiency.js.map +1 -1
- package/dist/prompts/reasoning-efficiency.test.d.ts +2 -0
- package/dist/prompts/reasoning-efficiency.test.d.ts.map +1 -0
- package/dist/prompts/reasoning-efficiency.test.js +11 -0
- package/dist/prompts/reasoning-efficiency.test.js.map +1 -0
- package/dist/prompts/reasoning-efficiency.test.ts +12 -0
- package/dist/prompts/reasoning-efficiency.ts +2 -0
- package/dist/prompts/search-via-shell.test.js +19 -16
- package/dist/prompts/search-via-shell.test.js.map +1 -1
- package/dist/prompts/search-via-shell.test.ts +20 -16
- package/dist/prompts/subagent-delegation.test.js +12 -10
- package/dist/prompts/subagent-delegation.test.js.map +1 -1
- package/dist/prompts/subagent-delegation.test.ts +13 -10
- package/dist/prompts/worktree-hygiene.md +9 -0
- package/dist/providers/ai-sdk-logging-fetch.d.ts.map +1 -1
- package/dist/providers/ai-sdk-logging-fetch.js +78 -3
- package/dist/providers/ai-sdk-logging-fetch.js.map +1 -1
- package/dist/providers/ai-sdk-logging-fetch.test.js +143 -0
- package/dist/providers/ai-sdk-logging-fetch.test.js.map +1 -1
- package/dist/providers/ai-sdk-openai-compatible.provider.d.ts +0 -2
- package/dist/providers/ai-sdk-openai-compatible.provider.d.ts.map +1 -1
- package/dist/providers/ai-sdk-openai-compatible.provider.js +4 -8
- package/dist/providers/ai-sdk-openai-compatible.provider.js.map +1 -1
- package/dist/providers/ai-sdk-openai-compatible.provider.test.js +1 -119
- package/dist/providers/ai-sdk-openai-compatible.provider.test.js.map +1 -1
- package/dist/providers/codex-responses-model.d.ts +20 -0
- package/dist/providers/codex-responses-model.d.ts.map +1 -0
- package/dist/providers/codex-responses-model.js +170 -0
- package/dist/providers/codex-responses-model.js.map +1 -0
- package/dist/providers/codex-responses-model.test.d.ts +2 -0
- package/dist/providers/codex-responses-model.test.d.ts.map +1 -0
- package/dist/providers/codex-responses-model.test.js +240 -0
- package/dist/providers/codex-responses-model.test.js.map +1 -0
- package/dist/providers/codex.provider.d.ts +29 -0
- package/dist/providers/codex.provider.d.ts.map +1 -0
- package/dist/providers/codex.provider.js +486 -0
- package/dist/providers/codex.provider.js.map +1 -0
- package/dist/providers/codex.provider.test.d.ts +2 -0
- package/dist/providers/codex.provider.test.d.ts.map +1 -0
- package/dist/providers/codex.provider.test.js +634 -0
- package/dist/providers/codex.provider.test.js.map +1 -0
- package/dist/providers/custom-provider-adapter.test.js +56 -0
- package/dist/providers/custom-provider-adapter.test.js.map +1 -1
- package/dist/providers/fallback-responses-model.d.ts +20 -0
- package/dist/providers/fallback-responses-model.d.ts.map +1 -0
- package/dist/providers/fallback-responses-model.js +277 -0
- package/dist/providers/fallback-responses-model.js.map +1 -0
- package/dist/providers/fallback-responses-model.test.d.ts +2 -0
- package/dist/providers/fallback-responses-model.test.d.ts.map +1 -0
- package/dist/providers/fallback-responses-model.test.js +279 -0
- package/dist/providers/fallback-responses-model.test.js.map +1 -0
- package/dist/providers/fetch/compose.d.ts +7 -0
- package/dist/providers/fetch/compose.d.ts.map +1 -0
- package/dist/providers/fetch/compose.js +20 -0
- package/dist/providers/fetch/compose.js.map +1 -0
- package/dist/providers/fetch/composer.d.ts +13 -0
- package/dist/providers/fetch/composer.d.ts.map +1 -0
- package/dist/providers/fetch/composer.js +15 -0
- package/dist/providers/fetch/composer.js.map +1 -0
- package/dist/providers/fetch/composer.test.d.ts +2 -0
- package/dist/providers/fetch/composer.test.d.ts.map +1 -0
- package/dist/providers/fetch/composer.test.js +448 -0
- package/dist/providers/fetch/composer.test.js.map +1 -0
- package/dist/providers/fetch/logging-middleware.d.ts +16 -0
- package/dist/providers/fetch/logging-middleware.d.ts.map +1 -0
- package/dist/providers/fetch/logging-middleware.js +214 -0
- package/dist/providers/fetch/logging-middleware.js.map +1 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/llama-cpp.provider.d.ts +3 -0
- package/dist/providers/llama-cpp.provider.d.ts.map +1 -0
- package/dist/providers/llama-cpp.provider.js +34 -0
- package/dist/providers/llama-cpp.provider.js.map +1 -0
- package/dist/providers/openai-compatible-behavior-gate.test.js +1 -42
- package/dist/providers/openai-compatible-behavior-gate.test.js.map +1 -1
- package/dist/providers/openai-compatible-middleware.d.ts +7 -0
- package/dist/providers/openai-compatible-middleware.d.ts.map +1 -0
- package/dist/providers/openai-compatible-middleware.js +133 -0
- package/dist/providers/openai-compatible-middleware.js.map +1 -0
- package/dist/providers/openai-compatible-models.d.ts +6 -0
- package/dist/providers/openai-compatible-models.d.ts.map +1 -0
- package/dist/providers/openai-compatible-models.js +17 -0
- package/dist/providers/openai-compatible-models.js.map +1 -0
- package/dist/providers/openai-compatible-response-normalizer.d.ts +7 -0
- package/dist/providers/openai-compatible-response-normalizer.d.ts.map +1 -0
- package/dist/providers/openai-compatible-response-normalizer.js +58 -0
- package/dist/providers/openai-compatible-response-normalizer.js.map +1 -0
- package/dist/providers/openai-compatible.provider.d.ts +4 -1
- package/dist/providers/openai-compatible.provider.d.ts.map +1 -1
- package/dist/providers/openai-compatible.provider.js +68 -324
- package/dist/providers/openai-compatible.provider.js.map +1 -1
- package/dist/providers/openai-compatible.provider.test.js +106 -1
- package/dist/providers/openai-compatible.provider.test.js.map +1 -1
- package/dist/providers/openai.provider.js +42 -10
- package/dist/providers/openai.provider.js.map +1 -1
- package/dist/providers/openai.provider.test.d.ts +2 -0
- package/dist/providers/openai.provider.test.d.ts.map +1 -0
- package/dist/providers/openai.provider.test.js +22 -0
- package/dist/providers/openai.provider.test.js.map +1 -0
- package/dist/providers/opencode.provider.d.ts +19 -0
- package/dist/providers/opencode.provider.d.ts.map +1 -0
- package/dist/providers/opencode.provider.js +45 -0
- package/dist/providers/opencode.provider.js.map +1 -0
- package/dist/providers/openrouter.provider.d.ts +2 -3
- package/dist/providers/openrouter.provider.d.ts.map +1 -1
- package/dist/providers/openrouter.provider.js +23 -24
- package/dist/providers/openrouter.provider.js.map +1 -1
- package/dist/providers/openrouter.provider.request-preprocessing.test.js +12 -9
- package/dist/providers/openrouter.provider.request-preprocessing.test.js.map +1 -1
- package/dist/providers/registry.d.ts +1 -0
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js.map +1 -1
- package/dist/providers/registry.test.js +6 -22
- package/dist/providers/registry.test.js.map +1 -1
- package/dist/scripts/eval-auto-approval/dataset.d.ts +2 -2
- package/dist/services/approval-flow-coordinator.d.ts.map +1 -1
- package/dist/services/approval-flow-coordinator.js +17 -1
- package/dist/services/approval-flow-coordinator.js.map +1 -1
- package/dist/services/approval-flow-coordinator.test.js +22 -0
- package/dist/services/approval-flow-coordinator.test.js.map +1 -1
- package/dist/services/command-message-streaming.d.ts.map +1 -1
- package/dist/services/command-message-streaming.js +0 -3
- package/dist/services/command-message-streaming.js.map +1 -1
- package/dist/services/command-message-streaming.test.js +4 -2
- package/dist/services/command-message-streaming.test.js.map +1 -1
- package/dist/services/conversation-clear-save.test.js +38 -66
- package/dist/services/conversation-clear-save.test.js.map +1 -1
- package/dist/services/conversation-events.d.ts +44 -1
- package/dist/services/conversation-events.d.ts.map +1 -1
- package/dist/services/conversation-integration.test.js +3 -1
- package/dist/services/conversation-integration.test.js.map +1 -1
- package/dist/services/conversation-log-events.d.ts +107 -0
- package/dist/services/conversation-log-events.d.ts.map +1 -0
- package/dist/services/conversation-log-events.js +12 -0
- package/dist/services/conversation-log-events.js.map +1 -0
- package/dist/services/conversation-log-writer.d.ts +40 -0
- package/dist/services/conversation-log-writer.d.ts.map +1 -0
- package/dist/services/conversation-log-writer.js +264 -0
- package/dist/services/conversation-log-writer.js.map +1 -0
- package/dist/services/conversation-persistence-types.d.ts +14 -0
- package/dist/services/conversation-persistence-types.d.ts.map +1 -0
- package/dist/services/conversation-persistence-types.js +2 -0
- package/dist/services/conversation-persistence-types.js.map +1 -0
- package/dist/services/conversation-persistence.d.ts +38 -39
- package/dist/services/conversation-persistence.d.ts.map +1 -1
- package/dist/services/conversation-persistence.js +270 -82
- package/dist/services/conversation-persistence.js.map +1 -1
- package/dist/services/conversation-persistence.test.js +472 -637
- package/dist/services/conversation-persistence.test.js.map +1 -1
- package/dist/services/conversation-replay.d.ts +26 -0
- package/dist/services/conversation-replay.d.ts.map +1 -0
- package/dist/services/conversation-replay.js +252 -0
- package/dist/services/conversation-replay.js.map +1 -0
- package/dist/services/conversation-replay.test.d.ts +2 -0
- package/dist/services/conversation-replay.test.d.ts.map +1 -0
- package/dist/services/conversation-replay.test.js +153 -0
- package/dist/services/conversation-replay.test.js.map +1 -0
- package/dist/services/conversation-result-builder.d.ts.map +1 -1
- package/dist/services/conversation-result-builder.js +8 -2
- package/dist/services/conversation-result-builder.js.map +1 -1
- package/dist/services/conversation-result-builder.test.js +53 -0
- package/dist/services/conversation-result-builder.test.js.map +1 -1
- package/dist/services/conversation-retry-policy.d.ts +17 -0
- package/dist/services/conversation-retry-policy.d.ts.map +1 -1
- package/dist/services/conversation-retry-policy.js +35 -5
- package/dist/services/conversation-retry-policy.js.map +1 -1
- package/dist/services/conversation-retry-policy.test.js +56 -1
- package/dist/services/conversation-retry-policy.test.js.map +1 -1
- package/dist/services/conversation-service.d.ts +9 -0
- package/dist/services/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation-service.js +18 -0
- package/dist/services/conversation-service.js.map +1 -1
- package/dist/services/conversation-session.d.ts +14 -0
- package/dist/services/conversation-session.d.ts.map +1 -1
- package/dist/services/conversation-session.js +426 -51
- package/dist/services/conversation-session.js.map +1 -1
- package/dist/services/input-surge-guard.d.ts +4 -0
- package/dist/services/input-surge-guard.d.ts.map +1 -1
- package/dist/services/input-surge-guard.js +2 -2
- package/dist/services/input-surge-guard.js.map +1 -1
- package/dist/services/input-surge-guard.test.js +15 -1
- package/dist/services/input-surge-guard.test.js.map +1 -1
- package/dist/services/large-uncached-input-guard.d.ts +35 -0
- package/dist/services/large-uncached-input-guard.d.ts.map +1 -0
- package/dist/services/large-uncached-input-guard.js +127 -0
- package/dist/services/large-uncached-input-guard.js.map +1 -0
- package/dist/services/large-uncached-input-guard.test.d.ts +2 -0
- package/dist/services/large-uncached-input-guard.test.d.ts.map +1 -0
- package/dist/services/large-uncached-input-guard.test.js +160 -0
- package/dist/services/large-uncached-input-guard.test.js.map +1 -0
- package/dist/services/model-service.d.ts +2 -0
- package/dist/services/model-service.d.ts.map +1 -1
- package/dist/services/model-service.js +7 -0
- package/dist/services/model-service.js.map +1 -1
- package/dist/services/provider-traffic.d.ts.map +1 -1
- package/dist/services/provider-traffic.js +82 -24
- package/dist/services/provider-traffic.js.map +1 -1
- package/dist/services/provider-traffic.test.js +98 -6
- package/dist/services/provider-traffic.test.js.map +1 -1
- package/dist/services/rtk-service.d.ts.map +1 -1
- package/dist/services/rtk-service.js +1 -2
- package/dist/services/rtk-service.js.map +1 -1
- package/dist/services/settings-schema.d.ts +36 -28
- package/dist/services/settings-schema.d.ts.map +1 -1
- package/dist/services/settings-schema.js +7 -2
- package/dist/services/settings-schema.js.map +1 -1
- package/dist/services/settings-sources.d.ts.map +1 -1
- package/dist/services/settings-sources.js +1 -0
- package/dist/services/settings-sources.js.map +1 -1
- package/dist/services/stream-event-processor.d.ts +4 -0
- package/dist/services/stream-event-processor.d.ts.map +1 -1
- package/dist/services/stream-event-processor.js +78 -39
- package/dist/services/stream-event-processor.js.map +1 -1
- package/dist/services/stream-event-processor.test.js +71 -0
- package/dist/services/stream-event-processor.test.js.map +1 -1
- package/dist/services/subagents/subagent-manager.d.ts.map +1 -1
- package/dist/services/subagents/subagent-manager.js +88 -16
- package/dist/services/subagents/subagent-manager.js.map +1 -1
- package/dist/services/subagents/subagent-manager.test.js +354 -0
- package/dist/services/subagents/subagent-manager.test.js.map +1 -1
- package/dist/services/terminal-result-collector.d.ts.map +1 -1
- package/dist/services/terminal-result-collector.js +6 -1
- package/dist/services/terminal-result-collector.js.map +1 -1
- package/dist/services/tool-call-arguments.d.ts +20 -0
- package/dist/services/tool-call-arguments.d.ts.map +1 -0
- package/dist/services/tool-call-arguments.js +49 -0
- package/dist/services/tool-call-arguments.js.map +1 -0
- package/dist/services/tool-execution-ledger.d.ts +35 -0
- package/dist/services/tool-execution-ledger.d.ts.map +1 -0
- package/dist/services/tool-execution-ledger.js +204 -0
- package/dist/services/tool-execution-ledger.js.map +1 -0
- package/dist/services/tool-execution-ledger.test.d.ts +2 -0
- package/dist/services/tool-execution-ledger.test.d.ts.map +1 -0
- package/dist/services/tool-execution-ledger.test.js +96 -0
- package/dist/services/tool-execution-ledger.test.js.map +1 -0
- package/dist/tools/apply-patch.d.ts +8 -0
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js +157 -2
- package/dist/tools/apply-patch.js.map +1 -1
- package/dist/tools/apply-patch.test.js +81 -0
- package/dist/tools/apply-patch.test.js.map +1 -1
- package/dist/tools/search-replace.d.ts.map +1 -1
- package/dist/tools/search-replace.js +92 -140
- package/dist/tools/search-replace.js.map +1 -1
- package/dist/utils/conversation-event-handler.d.ts.map +1 -1
- package/dist/utils/conversation-event-handler.js +33 -1
- package/dist/utils/conversation-event-handler.js.map +1 -1
- package/dist/utils/conversation-event-handler.test.js +103 -0
- package/dist/utils/conversation-event-handler.test.js.map +1 -1
- package/dist/utils/error-helpers.d.ts +1 -0
- package/dist/utils/error-helpers.d.ts.map +1 -1
- package/dist/utils/error-helpers.js +61 -0
- package/dist/utils/error-helpers.js.map +1 -1
- package/dist/utils/error-helpers.test.js +13 -1
- package/dist/utils/error-helpers.test.js.map +1 -1
- package/dist/utils/ink-render-options.d.ts +1 -1
- 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/project-tree.d.ts +14 -0
- package/dist/utils/project-tree.d.ts.map +1 -0
- package/dist/utils/project-tree.js +111 -0
- package/dist/utils/project-tree.js.map +1 -0
- package/dist/utils/project-tree.test.d.ts +2 -0
- package/dist/utils/project-tree.test.d.ts.map +1 -0
- package/dist/utils/project-tree.test.js +149 -0
- package/dist/utils/project-tree.test.js.map +1 -0
- package/dist/utils/streaming-session-factory.d.ts +2 -0
- package/dist/utils/streaming-session-factory.d.ts.map +1 -1
- package/dist/utils/streaming-session-factory.js +4 -0
- package/dist/utils/streaming-session-factory.js.map +1 -1
- package/dist/utils/terminal-clear.d.ts +7 -0
- package/dist/utils/terminal-clear.d.ts.map +1 -0
- package/dist/utils/terminal-clear.js +5 -0
- package/dist/utils/terminal-clear.js.map +1 -0
- package/dist/utils/terminal-clear.test.d.ts +2 -0
- package/dist/utils/terminal-clear.test.d.ts.map +1 -0
- package/dist/utils/terminal-clear.test.js +13 -0
- package/dist/utils/terminal-clear.test.js.map +1 -0
- package/package.json +2 -2
- package/dist/agent.lite-mode.test.d.ts +0 -2
- package/dist/agent.lite-mode.test.d.ts.map +0 -1
- package/dist/agent.lite-mode.test.js +0 -39
- package/dist/agent.lite-mode.test.js.map +0 -1
- package/dist/components/ApprovalPrompt.test.d.ts +0 -2
- package/dist/components/ApprovalPrompt.test.d.ts.map +0 -1
- package/dist/components/ApprovalPrompt.test.js +0 -23
- package/dist/components/ApprovalPrompt.test.js.map +0 -1
- package/dist/components/LiveResponse.test.d.ts +0 -2
- package/dist/components/LiveResponse.test.d.ts.map +0 -1
- package/dist/components/LiveResponse.test.js +0 -13
- package/dist/components/LiveResponse.test.js.map +0 -1
- package/dist/components/ModelSelectionMenu.error-tabs.test.d.ts +0 -2
- package/dist/components/ModelSelectionMenu.error-tabs.test.d.ts.map +0 -1
- package/dist/components/ModelSelectionMenu.error-tabs.test.js +0 -18
- package/dist/components/ModelSelectionMenu.error-tabs.test.js.map +0 -1
- package/dist/components/TextInput.d.ts +0 -42
- package/dist/components/TextInput.d.ts.map +0 -1
- package/dist/components/TextInput.js +0 -398
- package/dist/components/TextInput.js.map +0 -1
- package/dist/components/TextInput.test.d.ts +0 -2
- package/dist/components/TextInput.test.d.ts.map +0 -1
- package/dist/components/TextInput.test.js +0 -75
- package/dist/components/TextInput.test.js.map +0 -1
- package/dist/debug_ask_mentor.d.ts +0 -2
- package/dist/debug_ask_mentor.d.ts.map +0 -1
- package/dist/debug_ask_mentor.js +0 -73
- package/dist/debug_ask_mentor.js.map +0 -1
- package/dist/hooks/use-conversation.max-turns-undo.test.d.ts +0 -2
- package/dist/hooks/use-conversation.max-turns-undo.test.d.ts.map +0 -1
- package/dist/hooks/use-conversation.max-turns-undo.test.js +0 -118
- package/dist/hooks/use-conversation.max-turns-undo.test.js.map +0 -1
- package/dist/lib/shell.d.ts +0 -7
- package/dist/lib/shell.d.ts.map +0 -1
- package/dist/lib/shell.js +0 -56
- package/dist/lib/shell.js.map +0 -1
- package/dist/modes/companion/command-index.d.ts +0 -26
- package/dist/modes/companion/command-index.d.ts.map +0 -1
- package/dist/modes/companion/command-index.js +0 -50
- package/dist/modes/companion/command-index.js.map +0 -1
- package/dist/modes/companion/command-index.test.d.ts +0 -2
- package/dist/modes/companion/command-index.test.d.ts.map +0 -1
- package/dist/modes/companion/command-index.test.js +0 -86
- package/dist/modes/companion/command-index.test.js.map +0 -1
- package/dist/modes/companion/companion-app.d.ts +0 -12
- package/dist/modes/companion/companion-app.d.ts.map +0 -1
- package/dist/modes/companion/companion-app.js +0 -297
- package/dist/modes/companion/companion-app.js.map +0 -1
- package/dist/modes/companion/companion-session.d.ts +0 -63
- package/dist/modes/companion/companion-session.d.ts.map +0 -1
- package/dist/modes/companion/companion-session.js +0 -146
- package/dist/modes/companion/companion-session.js.map +0 -1
- package/dist/modes/companion/companion-session.test.d.ts +0 -2
- package/dist/modes/companion/companion-session.test.d.ts.map +0 -1
- package/dist/modes/companion/companion-session.test.js +0 -28
- package/dist/modes/companion/companion-session.test.js.map +0 -1
- package/dist/modes/companion/components/status-bar.d.ts +0 -13
- package/dist/modes/companion/components/status-bar.d.ts.map +0 -1
- package/dist/modes/companion/components/status-bar.js +0 -26
- package/dist/modes/companion/components/status-bar.js.map +0 -1
- package/dist/modes/companion/context-buffer.d.ts +0 -65
- package/dist/modes/companion/context-buffer.d.ts.map +0 -1
- package/dist/modes/companion/context-buffer.js +0 -156
- package/dist/modes/companion/context-buffer.js.map +0 -1
- package/dist/modes/companion/context-buffer.test.d.ts +0 -2
- package/dist/modes/companion/context-buffer.test.d.ts.map +0 -1
- package/dist/modes/companion/context-buffer.test.js +0 -154
- package/dist/modes/companion/context-buffer.test.js.map +0 -1
- package/dist/modes/companion/event-detector.d.ts +0 -46
- package/dist/modes/companion/event-detector.d.ts.map +0 -1
- package/dist/modes/companion/event-detector.js +0 -169
- package/dist/modes/companion/event-detector.js.map +0 -1
- package/dist/modes/companion/event-detector.test.d.ts +0 -2
- package/dist/modes/companion/event-detector.test.d.ts.map +0 -1
- package/dist/modes/companion/event-detector.test.js +0 -121
- package/dist/modes/companion/event-detector.test.js.map +0 -1
- package/dist/modes/companion/index.d.ts +0 -33
- package/dist/modes/companion/index.d.ts.map +0 -1
- package/dist/modes/companion/index.js +0 -21
- package/dist/modes/companion/index.js.map +0 -1
- package/dist/modes/companion/input-key-mapper.d.ts +0 -3
- package/dist/modes/companion/input-key-mapper.d.ts.map +0 -1
- package/dist/modes/companion/input-key-mapper.js +0 -31
- package/dist/modes/companion/input-key-mapper.js.map +0 -1
- package/dist/modes/companion/input-key-mapper.test.d.ts +0 -2
- package/dist/modes/companion/input-key-mapper.test.d.ts.map +0 -1
- package/dist/modes/companion/input-key-mapper.test.js +0 -26
- package/dist/modes/companion/input-key-mapper.test.js.map +0 -1
- package/dist/modes/companion/input-parser.d.ts +0 -53
- package/dist/modes/companion/input-parser.d.ts.map +0 -1
- package/dist/modes/companion/input-parser.js +0 -114
- package/dist/modes/companion/input-parser.js.map +0 -1
- package/dist/modes/companion/input-parser.test.d.ts +0 -2
- package/dist/modes/companion/input-parser.test.d.ts.map +0 -1
- package/dist/modes/companion/input-parser.test.js +0 -123
- package/dist/modes/companion/input-parser.test.js.map +0 -1
- package/dist/modes/companion/mode-manager.d.ts +0 -41
- package/dist/modes/companion/mode-manager.d.ts.map +0 -1
- package/dist/modes/companion/mode-manager.js +0 -56
- package/dist/modes/companion/mode-manager.js.map +0 -1
- package/dist/modes/companion/mode-manager.test.d.ts +0 -2
- package/dist/modes/companion/mode-manager.test.d.ts.map +0 -1
- package/dist/modes/companion/mode-manager.test.js +0 -65
- package/dist/modes/companion/mode-manager.test.js.map +0 -1
- package/dist/modes/companion/output-classifier.d.ts +0 -15
- package/dist/modes/companion/output-classifier.d.ts.map +0 -1
- package/dist/modes/companion/output-classifier.js +0 -77
- package/dist/modes/companion/output-classifier.js.map +0 -1
- package/dist/modes/companion/output-classifier.test.d.ts +0 -2
- package/dist/modes/companion/output-classifier.test.d.ts.map +0 -1
- package/dist/modes/companion/output-classifier.test.js +0 -133
- package/dist/modes/companion/output-classifier.test.js.map +0 -1
- package/dist/modes/companion/pty-wrapper.d.ts +0 -46
- package/dist/modes/companion/pty-wrapper.d.ts.map +0 -1
- package/dist/modes/companion/pty-wrapper.js +0 -143
- package/dist/modes/companion/pty-wrapper.js.map +0 -1
- package/dist/modes/companion/safety-classifier.d.ts +0 -31
- package/dist/modes/companion/safety-classifier.d.ts.map +0 -1
- package/dist/modes/companion/safety-classifier.js +0 -140
- package/dist/modes/companion/safety-classifier.js.map +0 -1
- package/dist/modes/companion/safety-classifier.test.d.ts +0 -2
- package/dist/modes/companion/safety-classifier.test.d.ts.map +0 -1
- package/dist/modes/companion/safety-classifier.test.js +0 -151
- package/dist/modes/companion/safety-classifier.test.js.map +0 -1
- package/dist/modes/companion/summarizer.d.ts +0 -24
- package/dist/modes/companion/summarizer.d.ts.map +0 -1
- package/dist/modes/companion/summarizer.js +0 -132
- package/dist/modes/companion/summarizer.js.map +0 -1
- package/dist/modes/companion/terminal-history.d.ts +0 -27
- package/dist/modes/companion/terminal-history.d.ts.map +0 -1
- package/dist/modes/companion/terminal-history.js +0 -142
- package/dist/modes/companion/terminal-history.js.map +0 -1
- package/dist/prompts/simple-mentor.md +0 -215
- package/dist/providers/ai-sdk-openai.provider.d.ts +0 -14
- package/dist/providers/ai-sdk-openai.provider.d.ts.map +0 -1
- package/dist/providers/ai-sdk-openai.provider.js +0 -18
- package/dist/providers/ai-sdk-openai.provider.js.map +0 -1
- package/dist/providers/github-copilot/converters.d.ts +0 -45
- package/dist/providers/github-copilot/converters.d.ts.map +0 -1
- package/dist/providers/github-copilot/converters.js +0 -118
- package/dist/providers/github-copilot/converters.js.map +0 -1
- package/dist/providers/github-copilot/converters.test.d.ts +0 -2
- package/dist/providers/github-copilot/converters.test.d.ts.map +0 -1
- package/dist/providers/github-copilot/converters.test.js +0 -162
- package/dist/providers/github-copilot/converters.test.js.map +0 -1
- package/dist/providers/github-copilot/github-copilot.provider.d.ts +0 -2
- package/dist/providers/github-copilot/github-copilot.provider.d.ts.map +0 -1
- package/dist/providers/github-copilot/github-copilot.provider.js +0 -75
- package/dist/providers/github-copilot/github-copilot.provider.js.map +0 -1
- package/dist/providers/github-copilot/github-copilot.provider.test.d.ts +0 -2
- package/dist/providers/github-copilot/github-copilot.provider.test.d.ts.map +0 -1
- package/dist/providers/github-copilot/github-copilot.provider.test.js +0 -26
- package/dist/providers/github-copilot/github-copilot.provider.test.js.map +0 -1
- package/dist/providers/github-copilot/index.d.ts +0 -4
- package/dist/providers/github-copilot/index.d.ts.map +0 -1
- package/dist/providers/github-copilot/index.js +0 -4
- package/dist/providers/github-copilot/index.js.map +0 -1
- package/dist/providers/github-copilot/model.d.ts +0 -24
- package/dist/providers/github-copilot/model.d.ts.map +0 -1
- package/dist/providers/github-copilot/model.delta.test.d.ts +0 -2
- package/dist/providers/github-copilot/model.delta.test.d.ts.map +0 -1
- package/dist/providers/github-copilot/model.delta.test.js +0 -15
- package/dist/providers/github-copilot/model.delta.test.js.map +0 -1
- package/dist/providers/github-copilot/model.js +0 -498
- package/dist/providers/github-copilot/model.js.map +0 -1
- package/dist/providers/github-copilot/model.test.d.ts +0 -2
- package/dist/providers/github-copilot/model.test.d.ts.map +0 -1
- package/dist/providers/github-copilot/model.test.js +0 -63
- package/dist/providers/github-copilot/model.test.js.map +0 -1
- package/dist/providers/github-copilot/provider.d.ts +0 -15
- package/dist/providers/github-copilot/provider.d.ts.map +0 -1
- package/dist/providers/github-copilot/provider.js +0 -25
- package/dist/providers/github-copilot/provider.js.map +0 -1
- package/dist/providers/github-copilot/provider.test.d.ts +0 -2
- package/dist/providers/github-copilot/provider.test.d.ts.map +0 -1
- package/dist/providers/github-copilot/provider.test.js +0 -52
- package/dist/providers/github-copilot/provider.test.js.map +0 -1
- package/dist/providers/github-copilot/utils.d.ts +0 -20
- package/dist/providers/github-copilot/utils.d.ts.map +0 -1
- package/dist/providers/github-copilot/utils.js +0 -142
- package/dist/providers/github-copilot/utils.js.map +0 -1
- package/dist/providers/github-copilot/utils.test.d.ts +0 -2
- package/dist/providers/github-copilot/utils.test.d.ts.map +0 -1
- package/dist/providers/github-copilot/utils.test.js +0 -21
- package/dist/providers/github-copilot/utils.test.js.map +0 -1
- package/dist/providers/openai-compatible/api.d.ts +0 -17
- package/dist/providers/openai-compatible/api.d.ts.map +0 -1
- package/dist/providers/openai-compatible/api.js +0 -58
- package/dist/providers/openai-compatible/api.js.map +0 -1
- package/dist/providers/openai-compatible/model.d.ts +0 -17
- package/dist/providers/openai-compatible/model.d.ts.map +0 -1
- package/dist/providers/openai-compatible/model.js +0 -473
- package/dist/providers/openai-compatible/model.js.map +0 -1
- package/dist/providers/openai-compatible/provider.d.ts +0 -22
- package/dist/providers/openai-compatible/provider.d.ts.map +0 -1
- package/dist/providers/openai-compatible/provider.js +0 -43
- package/dist/providers/openai-compatible/provider.js.map +0 -1
- package/dist/providers/openai-compatible/reasoning-content.test.d.ts +0 -2
- package/dist/providers/openai-compatible/reasoning-content.test.d.ts.map +0 -1
- package/dist/providers/openai-compatible/reasoning-content.test.js +0 -258
- package/dist/providers/openai-compatible/reasoning-content.test.js.map +0 -1
- package/dist/providers/openai-compatible/utils.d.ts +0 -3
- package/dist/providers/openai-compatible/utils.d.ts.map +0 -1
- package/dist/providers/openai-compatible/utils.js +0 -11
- package/dist/providers/openai-compatible/utils.js.map +0 -1
- package/dist/providers/openrouter/api.d.ts +0 -39
- package/dist/providers/openrouter/api.d.ts.map +0 -1
- package/dist/providers/openrouter/api.js +0 -164
- package/dist/providers/openrouter/api.js.map +0 -1
- package/dist/providers/openrouter/converters.d.ts +0 -8
- package/dist/providers/openrouter/converters.d.ts.map +0 -1
- package/dist/providers/openrouter/converters.js +0 -391
- package/dist/providers/openrouter/converters.js.map +0 -1
- package/dist/providers/openrouter/converters.test.d.ts +0 -2
- package/dist/providers/openrouter/converters.test.d.ts.map +0 -1
- package/dist/providers/openrouter/converters.test.js +0 -179
- package/dist/providers/openrouter/converters.test.js.map +0 -1
- package/dist/providers/openrouter/index.d.ts +0 -4
- package/dist/providers/openrouter/index.d.ts.map +0 -1
- package/dist/providers/openrouter/index.js +0 -4
- package/dist/providers/openrouter/index.js.map +0 -1
- package/dist/providers/openrouter/model.d.ts +0 -14
- package/dist/providers/openrouter/model.d.ts.map +0 -1
- package/dist/providers/openrouter/model.js +0 -457
- package/dist/providers/openrouter/model.js.map +0 -1
- package/dist/providers/openrouter/provider.d.ts +0 -15
- package/dist/providers/openrouter/provider.d.ts.map +0 -1
- package/dist/providers/openrouter/provider.js +0 -21
- package/dist/providers/openrouter/provider.js.map +0 -1
- package/dist/providers/openrouter/reasoning-content.test.d.ts +0 -2
- package/dist/providers/openrouter/reasoning-content.test.d.ts.map +0 -1
- package/dist/providers/openrouter/reasoning-content.test.js +0 -122
- package/dist/providers/openrouter/reasoning-content.test.js.map +0 -1
- package/dist/providers/openrouter/utils.d.ts +0 -11
- package/dist/providers/openrouter/utils.d.ts.map +0 -1
- package/dist/providers/openrouter/utils.js +0 -29
- package/dist/providers/openrouter/utils.js.map +0 -1
- package/dist/providers/openrouter.api.retry.test.d.ts +0 -2
- package/dist/providers/openrouter.api.retry.test.d.ts.map +0 -1
- package/dist/providers/openrouter.api.retry.test.js +0 -148
- package/dist/providers/openrouter.api.retry.test.js.map +0 -1
- package/dist/providers/openrouter.test.d.ts +0 -2
- package/dist/providers/openrouter.test.d.ts.map +0 -1
- package/dist/providers/openrouter.test.js +0 -1449
- package/dist/providers/openrouter.test.js.map +0 -1
- package/dist/safety-checker.js +0 -57
- package/dist/services/check_mock.d.ts +0 -2
- package/dist/services/check_mock.d.ts.map +0 -1
- package/dist/services/check_mock.js +0 -22
- package/dist/services/check_mock.js.map +0 -1
- package/dist/services/conversation-service.test.d.ts +0 -2
- package/dist/services/conversation-service.test.d.ts.map +0 -1
- package/dist/services/conversation-service.test.js +0 -156
- package/dist/services/conversation-service.test.js.map +0 -1
- package/dist/services/subagents/reasoning-inheritance.test.d.ts +0 -2
- package/dist/services/subagents/reasoning-inheritance.test.d.ts.map +0 -1
- package/dist/services/subagents/reasoning-inheritance.test.js +0 -73
- package/dist/services/subagents/reasoning-inheritance.test.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -10
- package/dist/tools/bash.d.ts.map +0 -1
- package/dist/tools/bash.js +0 -55
- package/dist/tools/bash.js.map +0 -1
- package/dist/utils/command-safety.d.ts +0 -21
- package/dist/utils/command-safety.d.ts.map +0 -1
- package/dist/utils/command-safety.devnull.test.d.ts +0 -2
- package/dist/utils/command-safety.devnull.test.d.ts.map +0 -1
- package/dist/utils/command-safety.devnull.test.js +0 -13
- package/dist/utils/command-safety.devnull.test.js.map +0 -1
- package/dist/utils/command-safety.js +0 -348
- package/dist/utils/command-safety.js.map +0 -1
- package/dist/utils/extract-command-messages.test.d.ts +0 -2
- package/dist/utils/extract-command-messages.test.d.ts.map +0 -1
- package/dist/utils/provider-traffic-extractor.repro.test.d.ts +0 -2
- package/dist/utils/provider-traffic-extractor.repro.test.d.ts.map +0 -1
- package/dist/utils/provider-traffic-extractor.repro.test.js.map +0 -1
|
@@ -3,18 +3,23 @@ import fs from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import * as persistenceModule from './conversation-persistence.js';
|
|
6
|
+
import { createConversationLogWriter, LockConflictError } from './conversation-log-writer.js';
|
|
6
7
|
let testDir = '';
|
|
7
|
-
// Clean up all conversation files before and after each test
|
|
8
8
|
function cleanupAll() {
|
|
9
9
|
if (testDir && fs.existsSync(testDir)) {
|
|
10
10
|
fs.rmSync(testDir, { recursive: true, force: true });
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
const stubLogger = {
|
|
14
|
+
error: () => { },
|
|
15
|
+
warn: () => { },
|
|
16
|
+
info: () => { },
|
|
17
|
+
debug: () => { },
|
|
18
|
+
trace: () => { },
|
|
19
|
+
getCorrelationId: () => undefined,
|
|
20
|
+
};
|
|
21
|
+
function emptySnapshot() {
|
|
22
|
+
return { history: [], previousResponseId: null, toolLedger: [] };
|
|
18
23
|
}
|
|
19
24
|
test.beforeEach(() => {
|
|
20
25
|
testDir = fs.mkdtempSync(path.join(os.tmpdir(), 'term2-conversations-test-'));
|
|
@@ -30,684 +35,514 @@ test.serial('generateId: returns a valid UUID', (t) => {
|
|
|
30
35
|
t.regex(id, /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
|
|
31
36
|
});
|
|
32
37
|
test.serial('generateId: returns unique IDs', (t) => {
|
|
33
|
-
|
|
34
|
-
const id2 = persistenceModule.generateId();
|
|
35
|
-
t.not(id1, id2);
|
|
38
|
+
t.not(persistenceModule.generateId(), persistenceModule.generateId());
|
|
36
39
|
});
|
|
37
40
|
test.serial('getResumeCommand: returns correct format', (t) => {
|
|
38
41
|
const id = 'test-uuid-123';
|
|
39
|
-
// Local (no SSH)
|
|
40
42
|
t.is(persistenceModule.getResumeCommand(id), 'term2 --resume test-uuid-123');
|
|
41
|
-
// SSH with host
|
|
42
43
|
t.is(persistenceModule.getResumeCommand(id, 'user@host'), 'term2 --ssh user@host --resume test-uuid-123');
|
|
43
|
-
|
|
44
|
-
t.is(persistenceModule.getResumeCommand(id, 'user@host', '/path
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// SSH with host and default port 22 (should be omitted)
|
|
48
|
-
t.is(persistenceModule.getResumeCommand(id, 'user@host', '/path/to/project', 22), 'term2 --ssh user@host --remote-dir /path/to/project --resume test-uuid-123');
|
|
49
|
-
});
|
|
50
|
-
test.serial('saveConversation: creates file and last.json pointer', (t) => {
|
|
44
|
+
t.is(persistenceModule.getResumeCommand(id, 'user@host', '/path'), 'term2 --ssh user@host --remote-dir /path --resume test-uuid-123');
|
|
45
|
+
t.is(persistenceModule.getResumeCommand(id, 'user@host', '/path', 2222), 'term2 --ssh user@host --remote-dir /path --ssh-port 2222 --resume test-uuid-123');
|
|
46
|
+
});
|
|
47
|
+
test.serial('writer + loadConversation: round-trips a basic conversation', (t) => {
|
|
51
48
|
const id = persistenceModule.generateId();
|
|
52
|
-
const
|
|
49
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
50
|
+
writer.init({
|
|
53
51
|
id,
|
|
54
|
-
createdAt:
|
|
55
|
-
|
|
52
|
+
createdAt: '2026-05-26T00:00:00.000Z',
|
|
53
|
+
projectPath: '/workspace/x',
|
|
56
54
|
model: 'gpt-4o',
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
provider: 'openai',
|
|
56
|
+
});
|
|
57
|
+
writer.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hello' } });
|
|
58
|
+
writer.append({
|
|
59
|
+
type: 'assistant_final',
|
|
60
|
+
message: { id: 'b1', sender: 'bot', status: 'finalized', text: 'hi there' },
|
|
61
|
+
finalText: 'hi there',
|
|
62
|
+
snapshot: {
|
|
63
|
+
history: [
|
|
64
|
+
{ role: 'user', type: 'message', content: 'hello' },
|
|
65
|
+
{ role: 'assistant', type: 'message', content: 'hi there' },
|
|
66
|
+
],
|
|
67
|
+
previousResponseId: 'resp-1',
|
|
68
|
+
toolLedger: [],
|
|
69
|
+
model: 'gpt-4o',
|
|
70
|
+
provider: 'openai',
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
void writer.close();
|
|
74
|
+
const restored = persistenceModule.loadConversation(id);
|
|
75
|
+
t.truthy(restored);
|
|
76
|
+
t.is(restored.id, id);
|
|
77
|
+
t.is(restored.previousResponseId, 'resp-1');
|
|
78
|
+
t.is(restored.history.length, 2);
|
|
79
|
+
t.is(restored.messages.length, 2);
|
|
80
|
+
t.is(restored.messages[0].sender, 'user');
|
|
81
|
+
t.is(restored.messages[1].sender, 'bot');
|
|
82
|
+
});
|
|
83
|
+
test.serial('loadConversation: returns null for missing id', (t) => {
|
|
84
|
+
t.is(persistenceModule.loadConversation('nope'), null);
|
|
85
|
+
});
|
|
86
|
+
test.serial('replay: mid-turn crash with tool_started inserts recovery notice', (t) => {
|
|
78
87
|
const id = persistenceModule.generateId();
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
|
|
88
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
89
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
90
|
+
// First turn completes cleanly
|
|
91
|
+
writer.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'do it' } });
|
|
92
|
+
writer.append({
|
|
93
|
+
type: 'assistant_final',
|
|
94
|
+
message: { id: 'b1', sender: 'bot', status: 'finalized', text: 'done' },
|
|
95
|
+
finalText: 'done',
|
|
96
|
+
snapshot: {
|
|
97
|
+
history: [{ role: 'user', type: 'message', content: 'do it' }],
|
|
98
|
+
previousResponseId: 'r1',
|
|
99
|
+
toolLedger: [],
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
// Second turn: user submits, tool starts, then crash
|
|
103
|
+
writer.append({ type: 'user_message', message: { id: 'u2', sender: 'user', text: 'more' } });
|
|
104
|
+
writer.append({ type: 'tool_started', toolCallId: 'call-1', toolName: 'shell', arguments: {} });
|
|
105
|
+
void writer.close();
|
|
106
|
+
const restored = persistenceModule.loadConversation(id);
|
|
107
|
+
t.truthy(restored);
|
|
108
|
+
t.true(restored.replayWarnings.some((w) => w.includes('interrupted')));
|
|
109
|
+
// Recovery system message present in history
|
|
110
|
+
const hasRecovery = restored.history.some((item) => item?.role === 'system' && typeof item.content === 'string' && item.content.includes('Recovered'));
|
|
111
|
+
t.true(hasRecovery);
|
|
112
|
+
// The interrupted system message is on UI messages
|
|
113
|
+
t.true(restored.messages.some((m) => m.sender === 'system' && String(m.text).includes('interrupted')));
|
|
114
|
+
});
|
|
115
|
+
test.serial('replay: user_message only with no assistant_final flags interruption', (t) => {
|
|
97
116
|
const id = persistenceModule.generateId();
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
t.is(saved.messages[0].status, 'completed');
|
|
109
|
-
t.is(saved.messages[0].success, false);
|
|
110
|
-
// Cleanup
|
|
111
|
-
fs.rmSync(path.dirname(filePath), { recursive: true, force: true });
|
|
112
|
-
});
|
|
113
|
-
test.serial('saveConversation: writes repaired history for duplicated tool replay artifacts', (t) => {
|
|
117
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
118
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
119
|
+
writer.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi' } });
|
|
120
|
+
void writer.close();
|
|
121
|
+
const restored = persistenceModule.loadConversation(id);
|
|
122
|
+
t.truthy(restored);
|
|
123
|
+
t.true(restored.replayWarnings.length > 0);
|
|
124
|
+
t.true(restored.messages.some((m) => m.sender === 'system' && String(m.text).includes('interrupted')));
|
|
125
|
+
});
|
|
126
|
+
test.serial('replay: settings_changed updates restored model', (t) => {
|
|
114
127
|
const id = persistenceModule.generateId();
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const filePath = persistenceModule.saveConversation(conversation);
|
|
130
|
-
const saved = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
131
|
-
t.is(saved.previousResponseId, 'resp-123');
|
|
132
|
-
t.is(saved.history.length, 3);
|
|
133
|
-
t.deepEqual(saved.history.filter((item) => item.callId === 'call-read').map((item) => item.id), ['fc_1', 'fcr_1']);
|
|
134
|
-
});
|
|
135
|
-
test.serial('loadConversation: returns null for non-existent id', (t) => {
|
|
136
|
-
const result = persistenceModule.loadConversation('non-existent-id');
|
|
137
|
-
t.is(result, null);
|
|
138
|
-
});
|
|
139
|
-
test.serial('loadConversation: returns saved conversation', (t) => {
|
|
128
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
129
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z', model: 'gpt-4o' });
|
|
130
|
+
writer.append({ type: 'settings_changed', key: 'agent.model', value: 'gpt-5' });
|
|
131
|
+
writer.append({
|
|
132
|
+
type: 'assistant_final',
|
|
133
|
+
message: { id: 'b1', sender: 'bot', status: 'finalized', text: 'ok' },
|
|
134
|
+
finalText: 'ok',
|
|
135
|
+
snapshot: { history: [], previousResponseId: null, toolLedger: [], model: 'gpt-5' },
|
|
136
|
+
});
|
|
137
|
+
void writer.close();
|
|
138
|
+
const restored = persistenceModule.loadConversation(id);
|
|
139
|
+
t.is(restored.model, 'gpt-5');
|
|
140
|
+
});
|
|
141
|
+
test.serial('replay: undo with snapshot replaces state', (t) => {
|
|
140
142
|
const id = persistenceModule.generateId();
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
143
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
144
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
145
|
+
writer.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'first' } });
|
|
146
|
+
writer.append({
|
|
147
|
+
type: 'assistant_final',
|
|
148
|
+
message: { id: 'b1', sender: 'bot', status: 'finalized', text: 'A' },
|
|
149
|
+
finalText: 'A',
|
|
150
|
+
snapshot: {
|
|
151
|
+
history: [{ role: 'user', type: 'message', content: 'first' }],
|
|
152
|
+
previousResponseId: 'r1',
|
|
153
|
+
toolLedger: [],
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
writer.append({ type: 'user_message', message: { id: 'u2', sender: 'user', text: 'second' } });
|
|
157
|
+
writer.append({
|
|
158
|
+
type: 'assistant_final',
|
|
159
|
+
message: { id: 'b2', sender: 'bot', status: 'finalized', text: 'B' },
|
|
160
|
+
finalText: 'B',
|
|
161
|
+
snapshot: {
|
|
162
|
+
history: [{ role: 'user', type: 'message', content: 'first' }],
|
|
163
|
+
previousResponseId: 'r2',
|
|
164
|
+
toolLedger: [],
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
writer.append({ type: 'undo', removedUserTurns: 1, snapshot: emptySnapshot() });
|
|
168
|
+
void writer.close();
|
|
169
|
+
const restored = persistenceModule.loadConversation(id);
|
|
170
|
+
t.is(restored.history.length, 0);
|
|
171
|
+
t.is(restored.previousResponseId, null);
|
|
172
|
+
});
|
|
173
|
+
test.serial('replay: corrupt line is skipped', (t) => {
|
|
162
174
|
const id = persistenceModule.generateId();
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
t.is(
|
|
185
|
-
});
|
|
186
|
-
test.serial('
|
|
175
|
+
fs.mkdirSync(testDir, { recursive: true });
|
|
176
|
+
const filePath = path.join(testDir, `${id}.jsonl`);
|
|
177
|
+
const goodInit = JSON.stringify({
|
|
178
|
+
v: 1,
|
|
179
|
+
seq: 1,
|
|
180
|
+
ts: '2026-05-26T00:00:00.000Z',
|
|
181
|
+
event: { type: 'session_init', id, createdAt: '2026-05-26T00:00:00.000Z' },
|
|
182
|
+
});
|
|
183
|
+
const goodFinal = JSON.stringify({
|
|
184
|
+
v: 1,
|
|
185
|
+
seq: 3,
|
|
186
|
+
ts: '2026-05-26T00:00:01.000Z',
|
|
187
|
+
event: {
|
|
188
|
+
type: 'assistant_final',
|
|
189
|
+
message: { id: 'b1', sender: 'bot', status: 'finalized', text: 'ok' },
|
|
190
|
+
finalText: 'ok',
|
|
191
|
+
snapshot: { history: [], previousResponseId: 'r1', toolLedger: [] },
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
fs.writeFileSync(filePath, `${goodInit}\n{not json\n${goodFinal}\n`, 'utf-8');
|
|
195
|
+
const restored = persistenceModule.loadConversation(id);
|
|
196
|
+
t.is(restored.previousResponseId, 'r1');
|
|
197
|
+
});
|
|
198
|
+
test.serial('lock: collision throws LockConflictError', (t) => {
|
|
187
199
|
const id = persistenceModule.generateId();
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
200
|
+
const w1 = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
201
|
+
w1.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
202
|
+
const w2 = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
203
|
+
t.throws(() => w2.init({ id, createdAt: '2026-05-26T00:00:00.000Z' }), { instanceOf: LockConflictError });
|
|
204
|
+
void w1.close();
|
|
205
|
+
});
|
|
206
|
+
test.serial('lock: released on writer close, second writer succeeds', async (t) => {
|
|
207
|
+
const id = persistenceModule.generateId();
|
|
208
|
+
const w1 = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
209
|
+
w1.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
210
|
+
await w1.close();
|
|
211
|
+
const w2 = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
212
|
+
t.notThrows(() => w2.init({ id, createdAt: '2026-05-26T00:00:00.000Z' }));
|
|
213
|
+
await w2.close();
|
|
214
|
+
});
|
|
215
|
+
test.serial('forkConversation: copies the source jsonl to a new id', (t) => {
|
|
216
|
+
const srcId = persistenceModule.generateId();
|
|
217
|
+
const dstId = persistenceModule.generateId();
|
|
218
|
+
const writer = createConversationLogWriter({ sessionId: srcId, dir: testDir, logger: stubLogger });
|
|
219
|
+
writer.init({ id: srcId, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
220
|
+
writer.append({
|
|
221
|
+
type: 'assistant_final',
|
|
222
|
+
message: { id: 'b1', sender: 'bot', status: 'finalized', text: 'A' },
|
|
223
|
+
finalText: 'A',
|
|
224
|
+
snapshot: {
|
|
225
|
+
history: [{ role: 'user', type: 'message', content: 'hi' }],
|
|
226
|
+
previousResponseId: 'r1',
|
|
227
|
+
toolLedger: [],
|
|
197
228
|
},
|
|
198
|
-
previousResponseId: null,
|
|
199
|
-
history: [],
|
|
200
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
201
|
-
};
|
|
202
|
-
persistenceModule.saveConversation(conversation);
|
|
203
|
-
const loaded = persistenceModule.loadConversation(id);
|
|
204
|
-
t.deepEqual(loaded?.appMode, {
|
|
205
|
-
liteMode: false,
|
|
206
|
-
mentorMode: true,
|
|
207
|
-
planMode: true,
|
|
208
|
-
orchestratorMode: false,
|
|
209
229
|
});
|
|
230
|
+
void writer.close();
|
|
231
|
+
t.true(persistenceModule.forkConversation(srcId, dstId));
|
|
232
|
+
const restored = persistenceModule.loadConversation(dstId);
|
|
233
|
+
t.is(restored.previousResponseId, 'r1');
|
|
210
234
|
});
|
|
211
|
-
test.serial('
|
|
235
|
+
test.serial('listConversations: lists sessions sorted by mtime desc', (t) => {
|
|
236
|
+
const id1 = persistenceModule.generateId();
|
|
237
|
+
const w1 = createConversationLogWriter({ sessionId: id1, dir: testDir, logger: stubLogger });
|
|
238
|
+
w1.init({ id: id1, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/p1' });
|
|
239
|
+
void w1.close();
|
|
240
|
+
// Sleep to ensure mtime differs
|
|
241
|
+
const target = Date.now() + 20;
|
|
242
|
+
while (Date.now() < target) {
|
|
243
|
+
/* spin */
|
|
244
|
+
}
|
|
245
|
+
const id2 = persistenceModule.generateId();
|
|
246
|
+
const w2 = createConversationLogWriter({ sessionId: id2, dir: testDir, logger: stubLogger });
|
|
247
|
+
w2.init({ id: id2, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/p2' });
|
|
248
|
+
void w2.close();
|
|
249
|
+
const list = persistenceModule.listConversations();
|
|
250
|
+
t.is(list.length, 2);
|
|
251
|
+
t.is(list[0].id, id2);
|
|
252
|
+
t.is(list[0].projectPath, '/p2');
|
|
253
|
+
});
|
|
254
|
+
test.serial('loadConversation: returns null when expected project path differs', (t) => {
|
|
212
255
|
const id = persistenceModule.generateId();
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
history: [],
|
|
220
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
221
|
-
};
|
|
222
|
-
persistenceModule.saveConversation(conversation);
|
|
223
|
-
const loaded = persistenceModule.loadConversation(id, '/workspace/beta');
|
|
224
|
-
t.is(loaded, null);
|
|
225
|
-
});
|
|
226
|
-
test.serial('loadConversationForProject: reports project mismatch for existing conversation in another path', (t) => {
|
|
256
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
257
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/workspace/alpha' });
|
|
258
|
+
void writer.close();
|
|
259
|
+
t.is(persistenceModule.loadConversation(id, '/workspace/beta'), null);
|
|
260
|
+
});
|
|
261
|
+
test.serial('loadConversationForProject: reports project mismatch', (t) => {
|
|
227
262
|
const id = persistenceModule.generateId();
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
updatedAt: new Date().toISOString(),
|
|
232
|
-
projectPath: '/workspace/alpha',
|
|
233
|
-
previousResponseId: null,
|
|
234
|
-
history: [],
|
|
235
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
236
|
-
};
|
|
237
|
-
persistenceModule.saveConversation(conversation);
|
|
263
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
264
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/workspace/alpha' });
|
|
265
|
+
void writer.close();
|
|
238
266
|
const result = persistenceModule.loadConversationForProject(id, '/workspace/beta');
|
|
239
267
|
t.is(result.status, 'project_mismatch');
|
|
240
|
-
if (result.status !== 'project_mismatch') {
|
|
241
|
-
t.fail('expected project_mismatch');
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
t.is(result.conversation.id, id);
|
|
245
268
|
});
|
|
246
|
-
test.serial('loadConversationForProject:
|
|
247
|
-
|
|
248
|
-
t.is(result.status, 'not_found');
|
|
269
|
+
test.serial('loadConversationForProject: not_found for missing', (t) => {
|
|
270
|
+
t.is(persistenceModule.loadConversationForProject('missing', '/x').status, 'not_found');
|
|
249
271
|
});
|
|
250
|
-
test.serial('
|
|
251
|
-
const id = persistenceModule.generateId();
|
|
252
|
-
const conversation = {
|
|
253
|
-
id,
|
|
254
|
-
createdAt: new Date().toISOString(),
|
|
255
|
-
updatedAt: new Date().toISOString(),
|
|
256
|
-
projectPath: '/workspace/alpha',
|
|
257
|
-
previousResponseId: null,
|
|
258
|
-
history: [],
|
|
259
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
260
|
-
};
|
|
261
|
-
persistenceModule.saveConversation(conversation);
|
|
262
|
-
const loaded = persistenceModule.loadConversation(id, '/workspace/alpha');
|
|
263
|
-
t.truthy(loaded);
|
|
264
|
-
t.is(loaded.id, id);
|
|
265
|
-
});
|
|
266
|
-
test.serial('loadConversation: unscoped loads keep backward-compatible behavior', (t) => {
|
|
267
|
-
const id = persistenceModule.generateId();
|
|
268
|
-
const conversation = {
|
|
269
|
-
id,
|
|
270
|
-
createdAt: new Date().toISOString(),
|
|
271
|
-
updatedAt: new Date().toISOString(),
|
|
272
|
-
projectPath: '/workspace/alpha',
|
|
273
|
-
previousResponseId: null,
|
|
274
|
-
history: [],
|
|
275
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
276
|
-
};
|
|
277
|
-
persistenceModule.saveConversation(conversation);
|
|
278
|
-
const loaded = persistenceModule.loadConversation(id);
|
|
279
|
-
t.truthy(loaded);
|
|
280
|
-
t.is(loaded.id, id);
|
|
281
|
-
});
|
|
282
|
-
test.serial('loadLastConversation: returns null when no last.json exists', (t) => {
|
|
283
|
-
const result = persistenceModule.loadLastConversation();
|
|
284
|
-
t.is(result, null);
|
|
285
|
-
});
|
|
286
|
-
test.serial('loadLastConversation: returns the last saved conversation', (t) => {
|
|
272
|
+
test.serial('loadLastConversation: returns the last written conversation', (t) => {
|
|
287
273
|
const id1 = persistenceModule.generateId();
|
|
274
|
+
const w1 = createConversationLogWriter({ sessionId: id1, dir: testDir, logger: stubLogger });
|
|
275
|
+
w1.init({ id: id1, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
276
|
+
w1.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi' } });
|
|
277
|
+
void w1.close();
|
|
278
|
+
const target = Date.now() + 20;
|
|
279
|
+
while (Date.now() < target) {
|
|
280
|
+
/* spin */
|
|
281
|
+
}
|
|
288
282
|
const id2 = persistenceModule.generateId();
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
previousResponseId: null,
|
|
294
|
-
history: [],
|
|
295
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'first' }],
|
|
296
|
-
};
|
|
297
|
-
const conv2 = {
|
|
298
|
-
id: id2,
|
|
299
|
-
createdAt: new Date().toISOString(),
|
|
300
|
-
updatedAt: new Date().toISOString(),
|
|
301
|
-
previousResponseId: null,
|
|
302
|
-
history: [],
|
|
303
|
-
messages: [{ id: 'msg-2', sender: 'user', text: 'second' }],
|
|
304
|
-
};
|
|
305
|
-
persistenceModule.saveConversation(conv1);
|
|
306
|
-
persistenceModule.saveConversation(conv2);
|
|
283
|
+
const w2 = createConversationLogWriter({ sessionId: id2, dir: testDir, logger: stubLogger });
|
|
284
|
+
w2.init({ id: id2, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
285
|
+
w2.append({ type: 'user_message', message: { id: 'u2', sender: 'user', text: 'hi2' } });
|
|
286
|
+
void w2.close();
|
|
307
287
|
const last = persistenceModule.loadLastConversation();
|
|
308
288
|
t.truthy(last);
|
|
309
289
|
t.is(last.id, id2);
|
|
310
|
-
// Cleanup
|
|
311
|
-
fs.rmSync(persistenceModule.getConversationsDirForTest(), { recursive: true, force: true });
|
|
312
290
|
});
|
|
313
|
-
test.serial('loadLastConversation:
|
|
291
|
+
test.serial('loadLastConversation: does not save last.json for empty conversation', (t) => {
|
|
314
292
|
const id = persistenceModule.generateId();
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
id,
|
|
319
|
-
createdAt: new Date().toISOString(),
|
|
320
|
-
updatedAt: new Date().toISOString(),
|
|
321
|
-
previousResponseId: null,
|
|
322
|
-
history: [
|
|
323
|
-
{ role: 'user', type: 'message', content: 'Inspect' },
|
|
324
|
-
{ type: 'function_call', id: 'fc_1', callId: 'call-read', name: 'read_file', arguments: '{}' },
|
|
325
|
-
{ type: 'function_call_result', id: 'fcr_1', callId: 'call-read', output: 'contents' },
|
|
326
|
-
{ type: 'function_call', id: 'fc_2', callId: 'call-read', name: 'read_file', arguments: '{}' },
|
|
327
|
-
{ type: 'function_call_result', id: 'fcr_2', callId: 'call-read', output: 'contents' },
|
|
328
|
-
],
|
|
329
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'Inspect' }],
|
|
330
|
-
}, null, 2), 'utf-8');
|
|
331
|
-
fs.writeFileSync(path.join(dir, 'last.json'), JSON.stringify({ id }), 'utf-8');
|
|
293
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
294
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
295
|
+
void writer.close();
|
|
332
296
|
const last = persistenceModule.loadLastConversation();
|
|
333
|
-
t.truthy(last);
|
|
334
|
-
t.true(last.historyRepair?.repaired);
|
|
335
|
-
t.is(last.history.length, 3);
|
|
336
|
-
});
|
|
337
|
-
test.serial('loadLastConversation: returns most recent conversation for expected project path', (t) => {
|
|
338
|
-
const projectAOlder = persistenceModule.generateId();
|
|
339
|
-
const projectANewer = persistenceModule.generateId();
|
|
340
|
-
const projectBNewer = persistenceModule.generateId();
|
|
341
|
-
persistenceModule.saveConversation({
|
|
342
|
-
id: projectAOlder,
|
|
343
|
-
createdAt: '2024-01-01T00:00:00.000Z',
|
|
344
|
-
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
345
|
-
projectPath: '/workspace/alpha',
|
|
346
|
-
previousResponseId: null,
|
|
347
|
-
history: [],
|
|
348
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'alpha older' }],
|
|
349
|
-
});
|
|
350
|
-
waitForDistinctTimestamp();
|
|
351
|
-
persistenceModule.saveConversation({
|
|
352
|
-
id: projectANewer,
|
|
353
|
-
createdAt: '2024-01-02T00:00:00.000Z',
|
|
354
|
-
updatedAt: '2024-01-02T00:00:00.000Z',
|
|
355
|
-
projectPath: '/workspace/alpha',
|
|
356
|
-
previousResponseId: null,
|
|
357
|
-
history: [],
|
|
358
|
-
messages: [{ id: 'msg-2', sender: 'user', text: 'alpha newer' }],
|
|
359
|
-
});
|
|
360
|
-
waitForDistinctTimestamp();
|
|
361
|
-
persistenceModule.saveConversation({
|
|
362
|
-
id: projectBNewer,
|
|
363
|
-
createdAt: '2024-01-03T00:00:00.000Z',
|
|
364
|
-
updatedAt: '2024-01-03T00:00:00.000Z',
|
|
365
|
-
projectPath: '/workspace/beta',
|
|
366
|
-
previousResponseId: null,
|
|
367
|
-
history: [],
|
|
368
|
-
messages: [{ id: 'msg-3', sender: 'user', text: 'beta newer' }],
|
|
369
|
-
});
|
|
370
|
-
const last = persistenceModule.loadLastConversation('/workspace/alpha');
|
|
371
|
-
t.truthy(last);
|
|
372
|
-
t.is(last.id, projectANewer);
|
|
373
|
-
});
|
|
374
|
-
test.serial('loadLastConversation: returns null when no conversation matches expected project path', (t) => {
|
|
375
|
-
persistenceModule.saveConversation({
|
|
376
|
-
id: persistenceModule.generateId(),
|
|
377
|
-
createdAt: new Date().toISOString(),
|
|
378
|
-
updatedAt: new Date().toISOString(),
|
|
379
|
-
projectPath: '/workspace/alpha',
|
|
380
|
-
previousResponseId: null,
|
|
381
|
-
history: [],
|
|
382
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'alpha' }],
|
|
383
|
-
});
|
|
384
|
-
const last = persistenceModule.loadLastConversation('/workspace/beta');
|
|
385
297
|
t.is(last, null);
|
|
298
|
+
t.false(fs.existsSync(path.join(testDir, 'last.json')));
|
|
386
299
|
});
|
|
387
|
-
test.serial('
|
|
388
|
-
|
|
389
|
-
const conversation = {
|
|
390
|
-
id,
|
|
391
|
-
createdAt: new Date().toISOString(),
|
|
392
|
-
updatedAt: new Date().toISOString(),
|
|
393
|
-
previousResponseId: null,
|
|
394
|
-
history: [],
|
|
395
|
-
messages: [],
|
|
396
|
-
};
|
|
397
|
-
persistenceModule.saveConversation(conversation);
|
|
398
|
-
const result = persistenceModule.deleteConversation(id);
|
|
399
|
-
t.true(result);
|
|
400
|
-
t.is(persistenceModule.loadConversation(id), null);
|
|
401
|
-
// Cleanup
|
|
402
|
-
fs.rmSync(persistenceModule.getConversationsDirForTest(), { recursive: true, force: true });
|
|
403
|
-
});
|
|
404
|
-
test.serial('deleteConversation: returns false for non-existent id', (t) => {
|
|
405
|
-
const result = persistenceModule.deleteConversation('non-existent');
|
|
406
|
-
t.false(result);
|
|
407
|
-
});
|
|
408
|
-
test.serial('listConversations: returns empty array when no conversations exist', (t) => {
|
|
409
|
-
// Ensure dir exists but is empty
|
|
410
|
-
const dir = persistenceModule.getConversationsDirForTest();
|
|
411
|
-
if (fs.existsSync(dir)) {
|
|
412
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
413
|
-
}
|
|
414
|
-
const list = persistenceModule.listConversations();
|
|
415
|
-
t.deepEqual(list, []);
|
|
300
|
+
test.serial('hasConversationContent: returns false for missing conversation', (t) => {
|
|
301
|
+
t.false(persistenceModule.hasConversationContent('non-existent-id'));
|
|
416
302
|
});
|
|
417
|
-
test.serial('
|
|
303
|
+
test.serial('hasConversationContent: returns false for empty conversation', (t) => {
|
|
418
304
|
const id = persistenceModule.generateId();
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
const rawData = {
|
|
425
|
-
id,
|
|
426
|
-
createdAt: new Date().toISOString(),
|
|
427
|
-
updatedAt: new Date().toISOString(),
|
|
428
|
-
appMode: {
|
|
429
|
-
mentorMode: false,
|
|
430
|
-
liteMode: false,
|
|
431
|
-
planMode: false,
|
|
432
|
-
// orchestratorMode is intentionally absent (old format)
|
|
433
|
-
},
|
|
434
|
-
previousResponseId: null,
|
|
435
|
-
history: [],
|
|
436
|
-
messages: [],
|
|
437
|
-
};
|
|
438
|
-
fs.writeFileSync(path.join(dir, `${id}.json`), JSON.stringify(rawData, null, 2), 'utf-8');
|
|
439
|
-
// loadConversation should not throw — it returns null on error
|
|
440
|
-
const loaded = persistenceModule.loadConversation(id);
|
|
441
|
-
t.truthy(loaded);
|
|
442
|
-
// orchestratorMode should be absent or false-y, not throw
|
|
443
|
-
const orchestratorMode = loaded?.appMode?.orchestratorMode;
|
|
444
|
-
t.falsy(orchestratorMode, 'orchestratorMode missing from old save should not be truthy');
|
|
445
|
-
});
|
|
446
|
-
test.serial('loadConversation: save with orchestratorMode: true is correctly restored', (t) => {
|
|
447
|
-
const id = persistenceModule.generateId();
|
|
448
|
-
const conversation = {
|
|
449
|
-
id,
|
|
450
|
-
createdAt: new Date().toISOString(),
|
|
451
|
-
updatedAt: new Date().toISOString(),
|
|
452
|
-
appMode: {
|
|
453
|
-
mentorMode: false,
|
|
454
|
-
liteMode: false,
|
|
455
|
-
planMode: false,
|
|
456
|
-
orchestratorMode: true,
|
|
457
|
-
},
|
|
458
|
-
previousResponseId: null,
|
|
459
|
-
history: [],
|
|
460
|
-
messages: [],
|
|
461
|
-
};
|
|
462
|
-
persistenceModule.saveConversation(conversation);
|
|
463
|
-
const loaded = persistenceModule.loadConversation(id);
|
|
464
|
-
t.truthy(loaded);
|
|
465
|
-
t.is(loaded?.appMode?.orchestratorMode, true);
|
|
466
|
-
});
|
|
467
|
-
test.serial('listConversations: returns conversations sorted by updatedAt descending', (t) => {
|
|
468
|
-
const id1 = persistenceModule.generateId();
|
|
469
|
-
const id2 = persistenceModule.generateId();
|
|
470
|
-
const conv1 = {
|
|
471
|
-
id: id1,
|
|
472
|
-
createdAt: '2024-01-01T00:00:00.000Z',
|
|
473
|
-
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
474
|
-
previousResponseId: null,
|
|
475
|
-
history: [],
|
|
476
|
-
messages: [],
|
|
477
|
-
};
|
|
478
|
-
const conv2 = {
|
|
479
|
-
id: id2,
|
|
480
|
-
createdAt: '2024-01-02T00:00:00.000Z',
|
|
481
|
-
updatedAt: '2024-01-02T00:00:00.000Z',
|
|
482
|
-
previousResponseId: null,
|
|
483
|
-
history: [],
|
|
484
|
-
messages: [],
|
|
485
|
-
};
|
|
486
|
-
// Save conv1 first
|
|
487
|
-
persistenceModule.saveConversation(conv1);
|
|
488
|
-
// Wait a moment so updatedAt differs
|
|
489
|
-
waitForDistinctTimestamp();
|
|
490
|
-
// Save conv2 second (should have later updatedAt)
|
|
491
|
-
persistenceModule.saveConversation(conv2);
|
|
492
|
-
const list = persistenceModule.listConversations();
|
|
493
|
-
t.is(list.length, 2);
|
|
494
|
-
t.is(list[0].id, id2); // Most recently saved first
|
|
495
|
-
t.is(list[1].id, id1);
|
|
305
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
306
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
307
|
+
void writer.close();
|
|
308
|
+
t.false(persistenceModule.hasConversationContent(id));
|
|
496
309
|
});
|
|
497
|
-
test.serial('
|
|
498
|
-
const id = persistenceModule.generateId();
|
|
499
|
-
const conversation = {
|
|
500
|
-
id,
|
|
501
|
-
createdAt: new Date().toISOString(),
|
|
502
|
-
updatedAt: new Date().toISOString(),
|
|
503
|
-
sshHost: 'myhost.example.com',
|
|
504
|
-
previousResponseId: null,
|
|
505
|
-
history: [],
|
|
506
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
507
|
-
};
|
|
508
|
-
persistenceModule.saveConversation(conversation);
|
|
509
|
-
const loaded = persistenceModule.loadConversation(id, undefined, 'myhost.example.com');
|
|
510
|
-
t.truthy(loaded);
|
|
511
|
-
t.is(loaded.id, id);
|
|
512
|
-
t.is(loaded.sshHost, 'myhost.example.com');
|
|
513
|
-
});
|
|
514
|
-
test.serial('conversationMatchesProject: loadConversation with mismatched sshHost returns null', (t) => {
|
|
515
|
-
const id = persistenceModule.generateId();
|
|
516
|
-
const conversation = {
|
|
517
|
-
id,
|
|
518
|
-
createdAt: new Date().toISOString(),
|
|
519
|
-
updatedAt: new Date().toISOString(),
|
|
520
|
-
sshHost: 'myhost.example.com',
|
|
521
|
-
previousResponseId: null,
|
|
522
|
-
history: [],
|
|
523
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
524
|
-
};
|
|
525
|
-
persistenceModule.saveConversation(conversation);
|
|
526
|
-
const loaded = persistenceModule.loadConversation(id, undefined, 'otherhost.example.com');
|
|
527
|
-
t.is(loaded, null);
|
|
528
|
-
});
|
|
529
|
-
test.serial('conversationMatchesProject: loading remote conversation from local session (no expectedSshHost) returns null', (t) => {
|
|
530
|
-
const id = persistenceModule.generateId();
|
|
531
|
-
const conversation = {
|
|
532
|
-
id,
|
|
533
|
-
createdAt: new Date().toISOString(),
|
|
534
|
-
updatedAt: new Date().toISOString(),
|
|
535
|
-
sshHost: 'remote.example.com',
|
|
536
|
-
projectPath: '/workspace/project',
|
|
537
|
-
previousResponseId: null,
|
|
538
|
-
history: [],
|
|
539
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
540
|
-
};
|
|
541
|
-
persistenceModule.saveConversation(conversation);
|
|
542
|
-
// Local session (expectedProjectPath given, but no expectedSshHost)
|
|
543
|
-
// should reject a remote conversation that has sshHost
|
|
544
|
-
const loaded = persistenceModule.loadConversation(id, '/workspace/project', undefined);
|
|
545
|
-
t.is(loaded, null);
|
|
546
|
-
});
|
|
547
|
-
test.serial('conversationMatchesProject: loading local conversation from remote session (no conversation.sshHost) returns null', (t) => {
|
|
310
|
+
test.serial('hasConversationContent: returns true for user_message', (t) => {
|
|
548
311
|
const id = persistenceModule.generateId();
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
projectPath: '/workspace/project',
|
|
555
|
-
previousResponseId: null,
|
|
556
|
-
history: [],
|
|
557
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
558
|
-
};
|
|
559
|
-
persistenceModule.saveConversation(conversation);
|
|
560
|
-
// Remote session (expectedSshHost given) should reject a local conversation
|
|
561
|
-
const loaded = persistenceModule.loadConversation(id, '/workspace/project', 'remote.example.com');
|
|
562
|
-
t.is(loaded, null);
|
|
563
|
-
});
|
|
564
|
-
test.serial('loadConversationForProject: returns project_mismatch for sshHost mismatch', (t) => {
|
|
565
|
-
const id = persistenceModule.generateId();
|
|
566
|
-
const conversation = {
|
|
567
|
-
id,
|
|
568
|
-
createdAt: new Date().toISOString(),
|
|
569
|
-
updatedAt: new Date().toISOString(),
|
|
570
|
-
sshHost: 'myhost.example.com',
|
|
571
|
-
projectPath: '/workspace/alpha',
|
|
572
|
-
previousResponseId: null,
|
|
573
|
-
history: [],
|
|
574
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
575
|
-
};
|
|
576
|
-
persistenceModule.saveConversation(conversation);
|
|
577
|
-
const result = persistenceModule.loadConversationForProject(id, '/workspace/alpha', 'otherhost.example.com');
|
|
578
|
-
t.is(result.status, 'project_mismatch');
|
|
579
|
-
if (result.status === 'project_mismatch') {
|
|
580
|
-
t.is(result.conversation.id, id);
|
|
581
|
-
t.is(result.conversation.sshHost, 'myhost.example.com');
|
|
582
|
-
}
|
|
312
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
313
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
314
|
+
writer.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi' } });
|
|
315
|
+
void writer.close();
|
|
316
|
+
t.true(persistenceModule.hasConversationContent(id));
|
|
583
317
|
});
|
|
584
|
-
test.serial('
|
|
318
|
+
test.serial('hasConversationContent: returns true for assistant_final', (t) => {
|
|
585
319
|
const id = persistenceModule.generateId();
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
persistenceModule.saveConversation(conversation);
|
|
597
|
-
const result = persistenceModule.loadConversationForProject(id, '/workspace/beta', 'myhost.example.com');
|
|
598
|
-
t.is(result.status, 'project_mismatch');
|
|
599
|
-
if (result.status === 'project_mismatch') {
|
|
600
|
-
t.is(result.conversation.id, id);
|
|
601
|
-
}
|
|
320
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
321
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
322
|
+
writer.append({
|
|
323
|
+
type: 'assistant_final',
|
|
324
|
+
message: { id: 'a1', sender: 'bot', status: 'finalized', text: 'hello' },
|
|
325
|
+
finalText: 'hello',
|
|
326
|
+
snapshot: emptySnapshot(),
|
|
327
|
+
});
|
|
328
|
+
void writer.close();
|
|
329
|
+
t.true(persistenceModule.hasConversationContent(id));
|
|
602
330
|
});
|
|
603
|
-
test.serial('
|
|
331
|
+
test.serial('hasConversationContent: skips corrupt lines and finds content', (t) => {
|
|
604
332
|
const id = persistenceModule.generateId();
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
};
|
|
615
|
-
persistenceModule.saveConversation(conversation);
|
|
616
|
-
const result = persistenceModule.loadConversationForProject(id, '/workspace/alpha', 'myhost.example.com');
|
|
617
|
-
t.is(result.status, 'loaded');
|
|
618
|
-
if (result.status === 'loaded') {
|
|
619
|
-
t.is(result.conversation.id, id);
|
|
620
|
-
t.is(result.conversation.sshHost, 'myhost.example.com');
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
test.serial('loadConversationForProject: SSH host matching is case-insensitive', (t) => {
|
|
333
|
+
const filePath = path.join(testDir, `${id}.jsonl`);
|
|
334
|
+
fs.writeFileSync(filePath, '{"v":1,"seq":1,"ts":"2026-05-26T00:00:00.000Z","event":{"type":"session_init","id":"' +
|
|
335
|
+
id +
|
|
336
|
+
'","createdAt":"2026-05-26T00:00:00.000Z"}}\n' +
|
|
337
|
+
'this is not json\n' +
|
|
338
|
+
'{"v":1,"seq":2,"ts":"2026-05-26T00:00:01.000Z","event":{"type":"user_message","message":{"id":"u1","sender":"user","text":"hi"}}}\n', 'utf-8');
|
|
339
|
+
t.true(persistenceModule.hasConversationContent(id));
|
|
340
|
+
});
|
|
341
|
+
test.serial('deleteConversation: removes the jsonl and clears last.json', (t) => {
|
|
624
342
|
const id = persistenceModule.generateId();
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
343
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
344
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
345
|
+
writer.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi' } });
|
|
346
|
+
void writer.close();
|
|
347
|
+
t.true(persistenceModule.deleteConversation(id));
|
|
348
|
+
t.false(fs.existsSync(path.join(testDir, `${id}.jsonl`)));
|
|
349
|
+
t.false(fs.existsSync(path.join(testDir, 'last.json')));
|
|
350
|
+
});
|
|
351
|
+
test.serial('subagent_completed and corresponding records omit nestedRunResult', (t) => {
|
|
352
|
+
const id = persistenceModule.generateId();
|
|
353
|
+
const writer = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
354
|
+
writer.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
355
|
+
// 1. Log subagent_completed event
|
|
356
|
+
writer.append({
|
|
357
|
+
type: 'subagent_completed',
|
|
358
|
+
result: {
|
|
359
|
+
agentId: 'sub-agent-1',
|
|
360
|
+
role: 'worker',
|
|
361
|
+
status: 'completed',
|
|
362
|
+
finalText: 'Task resolved successfully',
|
|
363
|
+
filesChanged: ['src/app.ts'],
|
|
364
|
+
toolsUsed: [{ toolName: 'create_file', count: 1 }],
|
|
365
|
+
usage: { prompt_tokens: 120, completion_tokens: 80, total_tokens: 200 },
|
|
366
|
+
nestedRunResult: {
|
|
367
|
+
state: {
|
|
368
|
+
history: [{ role: 'user', content: 'test' }],
|
|
369
|
+
generatedItems: ['item1'],
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
},
|
|
655
373
|
});
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
374
|
+
// 2. Log tool_result event with JSON string containing nestedRunResult
|
|
375
|
+
writer.append({
|
|
376
|
+
type: 'tool_result',
|
|
377
|
+
callId: 'call-subagent-1',
|
|
378
|
+
toolName: 'run_subagent',
|
|
379
|
+
status: 'completed',
|
|
380
|
+
output: JSON.stringify({
|
|
381
|
+
status: 'completed',
|
|
382
|
+
finalText: 'Result text',
|
|
383
|
+
nestedRunResult: { state: { internalStuff: 'hidden' } },
|
|
384
|
+
}),
|
|
665
385
|
});
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
386
|
+
// 3. Log assistant_final event with nestedRunResult in snapshot
|
|
387
|
+
writer.append({
|
|
388
|
+
type: 'assistant_final',
|
|
389
|
+
message: { id: 'b1', sender: 'bot', status: 'finalized', text: 'all done' },
|
|
390
|
+
finalText: 'all done',
|
|
391
|
+
snapshot: {
|
|
392
|
+
history: [
|
|
393
|
+
{
|
|
394
|
+
role: 'tool',
|
|
395
|
+
type: 'function_call_result',
|
|
396
|
+
name: 'run_subagent',
|
|
397
|
+
output: JSON.stringify({
|
|
398
|
+
status: 'completed',
|
|
399
|
+
finalText: 'Snapshot result text',
|
|
400
|
+
nestedRunResult: { state: { internalStuff: 'hidden' } },
|
|
401
|
+
}),
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
previousResponseId: 'resp-1',
|
|
405
|
+
toolLedger: [
|
|
406
|
+
{
|
|
407
|
+
turnId: 'turn-1',
|
|
408
|
+
callId: 'call-subagent-1',
|
|
409
|
+
toolName: 'run_subagent',
|
|
410
|
+
status: 'completed',
|
|
411
|
+
startedAt: '2026-05-26T00:00:00.000Z',
|
|
412
|
+
output: {
|
|
413
|
+
status: 'completed',
|
|
414
|
+
nestedRunResult: { state: { internalStuff: 'hidden' } },
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
},
|
|
675
419
|
});
|
|
676
|
-
|
|
420
|
+
void writer.close();
|
|
421
|
+
// Load raw file contents to check what was written to disk
|
|
422
|
+
const filePath = path.join(testDir, `${id}.jsonl`);
|
|
423
|
+
const lines = fs.readFileSync(filePath, 'utf-8').trim().split('\n');
|
|
424
|
+
// Parse lines to check events
|
|
425
|
+
const envelopes = lines.map((line) => JSON.parse(line));
|
|
426
|
+
// Find subagent_completed
|
|
427
|
+
const completedEnv = envelopes.find((env) => env.event?.type === 'subagent_completed');
|
|
428
|
+
t.truthy(completedEnv);
|
|
429
|
+
t.is(completedEnv.event.result.status, 'completed');
|
|
430
|
+
t.is(completedEnv.event.result.finalText, 'Task resolved successfully');
|
|
431
|
+
t.deepEqual(completedEnv.event.result.filesChanged, ['src/app.ts']);
|
|
432
|
+
t.is(completedEnv.event.result.nestedRunResult, undefined);
|
|
433
|
+
// Find tool_result
|
|
434
|
+
const toolResultEnv = envelopes.find((env) => env.event?.type === 'tool_result');
|
|
435
|
+
t.truthy(toolResultEnv);
|
|
436
|
+
t.is(toolResultEnv.event.toolName, 'run_subagent');
|
|
437
|
+
const parsedOutput = JSON.parse(toolResultEnv.event.output);
|
|
438
|
+
t.is(parsedOutput.status, 'completed');
|
|
439
|
+
t.is(parsedOutput.finalText, 'Result text');
|
|
440
|
+
t.is(parsedOutput.nestedRunResult, undefined);
|
|
441
|
+
// Find assistant_final and check snapshot
|
|
442
|
+
const finalEnv = envelopes.find((env) => env.event?.type === 'assistant_final');
|
|
443
|
+
t.truthy(finalEnv);
|
|
444
|
+
const snapHistoryOutput = JSON.parse(finalEnv.event.snapshot.history[0].output);
|
|
445
|
+
t.is(snapHistoryOutput.status, 'completed');
|
|
446
|
+
t.is(snapHistoryOutput.finalText, 'Snapshot result text');
|
|
447
|
+
t.is(snapHistoryOutput.nestedRunResult, undefined);
|
|
448
|
+
t.is(finalEnv.event.snapshot.toolLedger[0].output.status, 'completed');
|
|
449
|
+
t.is(finalEnv.event.snapshot.toolLedger[0].output.nestedRunResult, undefined);
|
|
450
|
+
});
|
|
451
|
+
test.serial('saveLastConversation: stores per-project last conversation', (t) => {
|
|
452
|
+
const id1 = persistenceModule.generateId();
|
|
453
|
+
const w1 = createConversationLogWriter({ sessionId: id1, dir: testDir, logger: stubLogger });
|
|
454
|
+
w1.init({ id: id1, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/project-a' });
|
|
455
|
+
w1.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi a' } });
|
|
456
|
+
void w1.close();
|
|
457
|
+
const id2 = persistenceModule.generateId();
|
|
458
|
+
const w2 = createConversationLogWriter({ sessionId: id2, dir: testDir, logger: stubLogger });
|
|
459
|
+
w2.init({ id: id2, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/project-b' });
|
|
460
|
+
w2.append({ type: 'user_message', message: { id: 'u2', sender: 'user', text: 'hi b' } });
|
|
461
|
+
void w2.close();
|
|
462
|
+
const lastA = persistenceModule.loadLastConversation('/project-a');
|
|
463
|
+
t.truthy(lastA);
|
|
464
|
+
t.is(lastA.id, id1);
|
|
465
|
+
const lastB = persistenceModule.loadLastConversation('/project-b');
|
|
466
|
+
t.truthy(lastB);
|
|
467
|
+
t.is(lastB.id, id2);
|
|
468
|
+
});
|
|
469
|
+
test.serial('saveLastConversation: stores per-ssh-host last conversation', (t) => {
|
|
470
|
+
const id1 = persistenceModule.generateId();
|
|
471
|
+
const w1 = createConversationLogWriter({ sessionId: id1, dir: testDir, logger: stubLogger });
|
|
472
|
+
w1.init({ id: id1, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/remote', sshHost: 'host-a' });
|
|
473
|
+
w1.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi a' } });
|
|
474
|
+
void w1.close();
|
|
475
|
+
const id2 = persistenceModule.generateId();
|
|
476
|
+
const w2 = createConversationLogWriter({ sessionId: id2, dir: testDir, logger: stubLogger });
|
|
477
|
+
w2.init({ id: id2, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/remote', sshHost: 'host-b' });
|
|
478
|
+
w2.append({ type: 'user_message', message: { id: 'u2', sender: 'user', text: 'hi b' } });
|
|
479
|
+
void w2.close();
|
|
480
|
+
const lastA = persistenceModule.loadLastConversation('/remote', 'host-a');
|
|
481
|
+
t.truthy(lastA);
|
|
482
|
+
t.is(lastA.id, id1);
|
|
483
|
+
const lastB = persistenceModule.loadLastConversation('/remote', 'host-b');
|
|
484
|
+
t.truthy(lastB);
|
|
485
|
+
t.is(lastB.id, id2);
|
|
486
|
+
});
|
|
487
|
+
test.serial('loadLastConversation: falls back to scanning when no last.json entry matches', (t) => {
|
|
488
|
+
const id = persistenceModule.generateId();
|
|
489
|
+
const w = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
490
|
+
w.init({ id, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/fallback' });
|
|
491
|
+
w.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi' } });
|
|
492
|
+
void w.close();
|
|
493
|
+
// Directly overwrite last.json so the entry has no projectPath
|
|
494
|
+
fs.writeFileSync(path.join(testDir, 'last.json'), JSON.stringify({ entries: [{ id, updatedAt: new Date().toISOString() }] }), 'utf-8');
|
|
495
|
+
const last = persistenceModule.loadLastConversation('/fallback');
|
|
677
496
|
t.truthy(last);
|
|
678
|
-
t.is(last.id,
|
|
679
|
-
});
|
|
680
|
-
test.serial('loadLastConversation: returns null when no conversation matches both project and ssh', (t) => {
|
|
681
|
-
persistenceModule.saveConversation({
|
|
682
|
-
id: persistenceModule.generateId(),
|
|
683
|
-
createdAt: new Date().toISOString(),
|
|
684
|
-
updatedAt: new Date().toISOString(),
|
|
685
|
-
projectPath: '/workspace/alpha',
|
|
686
|
-
sshHost: 'myhost.example.com',
|
|
687
|
-
previousResponseId: null,
|
|
688
|
-
history: [],
|
|
689
|
-
messages: [{ id: 'msg-1', sender: 'user', text: 'hello' }],
|
|
690
|
-
});
|
|
691
|
-
const last = persistenceModule.loadLastConversation('/workspace/alpha', 'otherhost.example.com');
|
|
692
|
-
t.is(last, null);
|
|
497
|
+
t.is(last.id, id);
|
|
693
498
|
});
|
|
694
|
-
test.serial('
|
|
499
|
+
test.serial('loadLastConversation: migrates old last.json format', (t) => {
|
|
695
500
|
const id = persistenceModule.generateId();
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
};
|
|
706
|
-
persistenceModule.saveConversation(conversation);
|
|
707
|
-
// No filters at all — should pass through
|
|
708
|
-
const loaded = persistenceModule.loadConversation(id);
|
|
709
|
-
t.truthy(loaded);
|
|
710
|
-
t.is(loaded.id, id);
|
|
711
|
-
t.is(loaded.sshHost, 'myhost.example.com');
|
|
501
|
+
const w = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
502
|
+
w.init({ id, createdAt: '2026-05-26T00:00:00.000Z' });
|
|
503
|
+
w.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi' } });
|
|
504
|
+
void w.close();
|
|
505
|
+
// Simulate old format
|
|
506
|
+
fs.writeFileSync(path.join(testDir, 'last.json'), JSON.stringify({ id, updatedAt: '2026-05-26T00:00:00.000Z' }), 'utf-8');
|
|
507
|
+
const last = persistenceModule.loadLastConversation();
|
|
508
|
+
t.truthy(last);
|
|
509
|
+
t.is(last.id, id);
|
|
712
510
|
});
|
|
511
|
+
test.serial('deleteConversation: removes only matching entry from last.json', (t) => {
|
|
512
|
+
const id1 = persistenceModule.generateId();
|
|
513
|
+
const w1 = createConversationLogWriter({ sessionId: id1, dir: testDir, logger: stubLogger });
|
|
514
|
+
w1.init({ id: id1, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/project-a' });
|
|
515
|
+
w1.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi a' } });
|
|
516
|
+
void w1.close();
|
|
517
|
+
const id2 = persistenceModule.generateId();
|
|
518
|
+
const w2 = createConversationLogWriter({ sessionId: id2, dir: testDir, logger: stubLogger });
|
|
519
|
+
w2.init({ id: id2, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/project-b' });
|
|
520
|
+
w2.append({ type: 'user_message', message: { id: 'u2', sender: 'user', text: 'hi b' } });
|
|
521
|
+
void w2.close();
|
|
522
|
+
t.true(persistenceModule.deleteConversation(id1));
|
|
523
|
+
t.false(fs.existsSync(path.join(testDir, `${id1}.jsonl`)));
|
|
524
|
+
t.true(fs.existsSync(path.join(testDir, 'last.json')));
|
|
525
|
+
const lastB = persistenceModule.loadLastConversation('/project-b');
|
|
526
|
+
t.truthy(lastB);
|
|
527
|
+
t.is(lastB.id, id2);
|
|
528
|
+
});
|
|
529
|
+
test.serial('saveLastConversation: updates entry when projectPath changes for same id', (t) => {
|
|
530
|
+
const id = persistenceModule.generateId();
|
|
531
|
+
const w = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
532
|
+
w.init({ id, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/old-path' });
|
|
533
|
+
w.append({ type: 'user_message', message: { id: 'u1', sender: 'user', text: 'hi' } });
|
|
534
|
+
void w.close();
|
|
535
|
+
// Re-open same session with different project path (simulating rotate or manual update)
|
|
536
|
+
const w2 = createConversationLogWriter({ sessionId: id, dir: testDir, logger: stubLogger });
|
|
537
|
+
w2.init({ id, createdAt: '2026-05-26T00:00:00.000Z', projectPath: '/new-path' });
|
|
538
|
+
w2.append({ type: 'user_message', message: { id: 'u2', sender: 'user', text: 'hi again' } });
|
|
539
|
+
void w2.close();
|
|
540
|
+
t.is(persistenceModule.loadLastConversation('/old-path'), null);
|
|
541
|
+
const lastNew = persistenceModule.loadLastConversation('/new-path');
|
|
542
|
+
t.truthy(lastNew);
|
|
543
|
+
t.is(lastNew.id, id);
|
|
544
|
+
});
|
|
545
|
+
// Suppress unused-event-import lint
|
|
546
|
+
const _ev = null;
|
|
547
|
+
void _ev;
|
|
713
548
|
//# sourceMappingURL=conversation-persistence.test.js.map
|