@qduc/term2 0.7.2 → 0.7.3
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 +1 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +17 -1
- package/dist/agent.js.map +1 -1
- package/dist/agent.test.js +36 -0
- package/dist/agent.test.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +57 -12
- package/dist/app.js.map +1 -1
- package/dist/cli.integration.test.js +60 -4
- package/dist/cli.integration.test.js.map +1 -1
- package/dist/cli.js +33 -2
- package/dist/cli.js.map +1 -1
- package/dist/components/ApprovalPrompt.ask-user.test.d.ts +2 -0
- package/dist/components/ApprovalPrompt.ask-user.test.d.ts.map +1 -0
- package/dist/components/ApprovalPrompt.ask-user.test.js +108 -0
- package/dist/components/ApprovalPrompt.ask-user.test.js.map +1 -0
- package/dist/components/ApprovalPrompt.d.ts +4 -4
- package/dist/components/ApprovalPrompt.d.ts.map +1 -1
- package/dist/components/ApprovalPrompt.js +76 -13
- package/dist/components/ApprovalPrompt.js.map +1 -1
- package/dist/components/BottomArea.d.ts +7 -2
- package/dist/components/BottomArea.d.ts.map +1 -1
- package/dist/components/BottomArea.js +11 -6
- package/dist/components/BottomArea.js.map +1 -1
- package/dist/components/BottomArea.test.js +4 -3
- package/dist/components/BottomArea.test.js.map +1 -1
- package/dist/components/Common/MenuContainer.d.ts +3 -2
- package/dist/components/Common/MenuContainer.d.ts.map +1 -1
- package/dist/components/Common/MenuContainer.js +14 -2
- package/dist/components/Common/MenuContainer.js.map +1 -1
- package/dist/components/Common/MenuContainer.test.d.ts +2 -0
- package/dist/components/Common/MenuContainer.test.d.ts.map +1 -0
- package/dist/components/Common/MenuContainer.test.js +66 -0
- package/dist/components/Common/MenuContainer.test.js.map +1 -0
- package/dist/components/Input/PopupManager.d.ts +14 -0
- package/dist/components/Input/PopupManager.d.ts.map +1 -1
- package/dist/components/Input/PopupManager.js +6 -4
- package/dist/components/Input/PopupManager.js.map +1 -1
- package/dist/components/Input/popup-props.d.ts +3 -1
- package/dist/components/Input/popup-props.d.ts.map +1 -1
- package/dist/components/Input/popup-props.js +12 -1
- package/dist/components/Input/popup-props.js.map +1 -1
- package/dist/components/Input/popup-props.test.js +9 -0
- package/dist/components/Input/popup-props.test.js.map +1 -1
- package/dist/components/InputBox.d.ts +7 -0
- package/dist/components/InputBox.d.ts.map +1 -1
- package/dist/components/InputBox.js +81 -30
- package/dist/components/InputBox.js.map +1 -1
- package/dist/components/InputBox.test.js +133 -10
- package/dist/components/InputBox.test.js.map +1 -1
- package/dist/components/LargeUncachedConfirmationPrompt.d.ts +2 -1
- package/dist/components/LargeUncachedConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/LargeUncachedConfirmationPrompt.js +8 -3
- package/dist/components/LargeUncachedConfirmationPrompt.js.map +1 -1
- package/dist/components/LargeUncachedConfirmationPrompt.test.js +5 -4
- package/dist/components/LargeUncachedConfirmationPrompt.test.js.map +1 -1
- package/dist/components/MessageList.d.ts +2 -1
- package/dist/components/MessageList.d.ts.map +1 -1
- package/dist/components/MessageList.js +6 -1
- package/dist/components/MessageList.js.map +1 -1
- package/dist/components/MessageList.test.js +26 -0
- package/dist/components/MessageList.test.js.map +1 -1
- package/dist/components/PathSelectionMenu.d.ts +1 -0
- package/dist/components/PathSelectionMenu.d.ts.map +1 -1
- package/dist/components/PathSelectionMenu.js +11 -9
- package/dist/components/PathSelectionMenu.js.map +1 -1
- package/dist/components/PathSelectionMenu.test.d.ts +2 -0
- package/dist/components/PathSelectionMenu.test.d.ts.map +1 -0
- package/dist/components/PathSelectionMenu.test.js +17 -0
- package/dist/components/PathSelectionMenu.test.js.map +1 -0
- package/dist/components/ProviderSelectionMenu.d.ts +15 -0
- package/dist/components/ProviderSelectionMenu.d.ts.map +1 -0
- package/dist/components/ProviderSelectionMenu.js +172 -0
- package/dist/components/ProviderSelectionMenu.js.map +1 -0
- package/dist/components/ProviderSelectionMenu.test.d.ts +2 -0
- package/dist/components/ProviderSelectionMenu.test.d.ts.map +1 -0
- package/dist/components/ProviderSelectionMenu.test.js +97 -0
- package/dist/components/ProviderSelectionMenu.test.js.map +1 -0
- package/dist/components/SettingsValueSelectionMenu.d.ts +2 -1
- package/dist/components/SettingsValueSelectionMenu.d.ts.map +1 -1
- package/dist/components/SettingsValueSelectionMenu.js +12 -6
- package/dist/components/SettingsValueSelectionMenu.js.map +1 -1
- package/dist/components/StatusBar.d.ts +1 -0
- package/dist/components/StatusBar.d.ts.map +1 -1
- package/dist/components/StatusBar.js +3 -2
- package/dist/components/StatusBar.js.map +1 -1
- package/dist/components/StatusBar.test.js +11 -0
- package/dist/components/StatusBar.test.js.map +1 -1
- package/dist/context/InputContext.d.ts +1 -1
- package/dist/context/InputContext.d.ts.map +1 -1
- package/dist/context/InputContext.js.map +1 -1
- package/dist/hooks/use-app-commands.d.ts +2 -1
- package/dist/hooks/use-app-commands.d.ts.map +1 -1
- package/dist/hooks/use-app-commands.js +11 -2
- package/dist/hooks/use-app-commands.js.map +1 -1
- package/dist/hooks/use-app-commands.test.js +2 -0
- package/dist/hooks/use-app-commands.test.js.map +1 -1
- package/dist/hooks/use-conversation.clear.test.js +31 -0
- package/dist/hooks/use-conversation.clear.test.js.map +1 -1
- package/dist/hooks/use-conversation.d.ts +4 -1
- package/dist/hooks/use-conversation.d.ts.map +1 -1
- package/dist/hooks/use-conversation.js +18 -2
- package/dist/hooks/use-conversation.js.map +1 -1
- package/dist/hooks/use-escape-key.d.ts +12 -3
- package/dist/hooks/use-escape-key.d.ts.map +1 -1
- package/dist/hooks/use-escape-key.js +25 -11
- package/dist/hooks/use-escape-key.js.map +1 -1
- package/dist/hooks/use-escape-key.test.js +154 -14
- package/dist/hooks/use-escape-key.test.js.map +1 -1
- package/dist/hooks/use-mode-handlers.d.ts +13 -1
- package/dist/hooks/use-mode-handlers.d.ts.map +1 -1
- package/dist/hooks/use-mode-handlers.js +22 -1
- package/dist/hooks/use-mode-handlers.js.map +1 -1
- package/dist/hooks/use-mode-handlers.test.d.ts +2 -0
- package/dist/hooks/use-mode-handlers.test.d.ts.map +1 -0
- package/dist/hooks/use-mode-handlers.test.js +119 -0
- package/dist/hooks/use-mode-handlers.test.js.map +1 -0
- package/dist/hooks/use-path-completion.d.ts +10 -3
- package/dist/hooks/use-path-completion.d.ts.map +1 -1
- package/dist/hooks/use-path-completion.js +53 -9
- package/dist/hooks/use-path-completion.js.map +1 -1
- package/dist/hooks/use-path-completion.test.js +61 -49
- package/dist/hooks/use-path-completion.test.js.map +1 -1
- package/dist/hooks/use-provider-selection.d.ts +60 -0
- package/dist/hooks/use-provider-selection.d.ts.map +1 -0
- package/dist/hooks/use-provider-selection.js +767 -0
- package/dist/hooks/use-provider-selection.js.map +1 -0
- package/dist/hooks/use-provider-selection.test.d.ts +2 -0
- package/dist/hooks/use-provider-selection.test.d.ts.map +1 -0
- package/dist/hooks/use-provider-selection.test.js +793 -0
- package/dist/hooks/use-provider-selection.test.js.map +1 -0
- package/dist/hooks/use-runtime-settings.d.ts.map +1 -1
- package/dist/hooks/use-runtime-settings.js +2 -2
- package/dist/hooks/use-runtime-settings.js.map +1 -1
- package/dist/hooks/use-selection.d.ts +3 -1
- package/dist/hooks/use-selection.d.ts.map +1 -1
- package/dist/hooks/use-selection.js +115 -24
- package/dist/hooks/use-selection.js.map +1 -1
- package/dist/hooks/use-selection.test.js +96 -2
- package/dist/hooks/use-selection.test.js.map +1 -1
- package/dist/hooks/use-settings-value-completion.d.ts +3 -0
- package/dist/hooks/use-settings-value-completion.d.ts.map +1 -1
- package/dist/hooks/use-settings-value-completion.js +140 -18
- package/dist/hooks/use-settings-value-completion.js.map +1 -1
- package/dist/hooks/use-settings-value-completion.test.js +71 -1
- package/dist/hooks/use-settings-value-completion.test.js.map +1 -1
- package/dist/hooks/use-trigger-detection.d.ts +4 -2
- package/dist/hooks/use-trigger-detection.d.ts.map +1 -1
- package/dist/hooks/use-trigger-detection.js +42 -8
- package/dist/hooks/use-trigger-detection.js.map +1 -1
- package/dist/hooks/use-trigger-detection.test.js +2 -1
- package/dist/hooks/use-trigger-detection.test.js.map +1 -1
- package/dist/lib/openai-agent-client.chat.test.js +8 -0
- package/dist/lib/openai-agent-client.chat.test.js.map +1 -1
- package/dist/lib/openai-agent-client.d.ts +11 -6
- package/dist/lib/openai-agent-client.d.ts.map +1 -1
- package/dist/lib/openai-agent-client.js +199 -15
- package/dist/lib/openai-agent-client.js.map +1 -1
- package/dist/lib/openai-agent-client.public-methods.test.js +326 -23
- package/dist/lib/openai-agent-client.public-methods.test.js.map +1 -1
- package/dist/lib/openai-agent-client.test.js +62 -0
- package/dist/lib/openai-agent-client.test.js.map +1 -1
- package/dist/lib/tool-invoke.d.ts +27 -0
- package/dist/lib/tool-invoke.d.ts.map +1 -1
- package/dist/lib/tool-invoke.js +124 -95
- package/dist/lib/tool-invoke.js.map +1 -1
- package/dist/lib/tool-invoke.test.js +84 -22
- package/dist/lib/tool-invoke.test.js.map +1 -1
- package/dist/non-interactive.d.ts +2 -1
- package/dist/non-interactive.d.ts.map +1 -1
- package/dist/non-interactive.js +10 -2
- package/dist/non-interactive.js.map +1 -1
- package/dist/prompts/orchestrator.md +27 -41
- package/dist/prompts/plan-mode-info.md +2 -0
- package/dist/prompts/prompt-constructor.d.ts.map +1 -1
- package/dist/prompts/prompt-constructor.js +8 -0
- package/dist/prompts/prompt-constructor.js.map +1 -1
- package/dist/prompts/prompt-constructor.test.js +13 -0
- package/dist/prompts/prompt-constructor.test.js.map +1 -1
- package/dist/prompts/prompt-constructor.test.ts +16 -0
- package/dist/prompts/prompt-constructor.ts +10 -0
- package/dist/prompts/subagent-delegation.d.ts.map +1 -1
- package/dist/prompts/subagent-delegation.js +17 -1
- package/dist/prompts/subagent-delegation.js.map +1 -1
- package/dist/prompts/subagent-delegation.test.js +21 -0
- package/dist/prompts/subagent-delegation.test.js.map +1 -1
- package/dist/prompts/subagent-delegation.test.ts +26 -0
- package/dist/prompts/subagent-delegation.ts +17 -1
- package/dist/prompts/subagents/base-anthropic.md +3 -0
- package/dist/prompts/subagents/base-codex.md +3 -0
- package/dist/prompts/subagents/base-gpt-5-modern.md +3 -0
- package/dist/prompts/subagents/base-simple.md +3 -0
- package/dist/prompts/subagents/explorer.md +8 -10
- package/dist/prompts/subagents/researcher.md +2 -1
- package/dist/prompts/subagents/worker.md +12 -3
- package/dist/prompts/subagents/worktree-hygiene.md +6 -0
- package/dist/providers/ai-sdk-anthropic.provider.d.ts +4 -1
- package/dist/providers/ai-sdk-anthropic.provider.d.ts.map +1 -1
- package/dist/providers/ai-sdk-anthropic.provider.js +65 -22
- package/dist/providers/ai-sdk-anthropic.provider.js.map +1 -1
- package/dist/providers/ai-sdk-anthropic.provider.test.js +24 -1
- package/dist/providers/ai-sdk-anthropic.provider.test.js.map +1 -1
- package/dist/providers/anthropic-middleware.d.ts +25 -0
- package/dist/providers/anthropic-middleware.d.ts.map +1 -0
- package/dist/providers/anthropic-middleware.js +32 -0
- package/dist/providers/anthropic-middleware.js.map +1 -0
- package/dist/providers/anthropic-middleware.test.d.ts +2 -0
- package/dist/providers/anthropic-middleware.test.d.ts.map +1 -0
- package/dist/providers/anthropic-middleware.test.js +142 -0
- package/dist/providers/anthropic-middleware.test.js.map +1 -0
- package/dist/providers/codex-responses-model.d.ts.map +1 -1
- package/dist/providers/codex-responses-model.js +47 -30
- package/dist/providers/codex-responses-model.js.map +1 -1
- package/dist/providers/codex-responses-model.test.js +31 -0
- package/dist/providers/codex-responses-model.test.js.map +1 -1
- package/dist/providers/codex.provider.d.ts.map +1 -1
- package/dist/providers/codex.provider.js +16 -9
- package/dist/providers/codex.provider.js.map +1 -1
- package/dist/providers/codex.provider.test.js +2 -1
- package/dist/providers/codex.provider.test.js.map +1 -1
- package/dist/providers/custom-provider-adapter.test.js +6 -2
- package/dist/providers/custom-provider-adapter.test.js.map +1 -1
- package/dist/providers/fallback-responses-model.d.ts +3 -1
- package/dist/providers/fallback-responses-model.d.ts.map +1 -1
- package/dist/providers/fallback-responses-model.js +22 -3
- package/dist/providers/fallback-responses-model.js.map +1 -1
- package/dist/providers/fallback-responses-model.test.js +36 -8
- package/dist/providers/fallback-responses-model.test.js.map +1 -1
- package/dist/providers/fetch/composer.d.ts +1 -0
- package/dist/providers/fetch/composer.d.ts.map +1 -1
- package/dist/providers/fetch/composer.js +1 -0
- package/dist/providers/fetch/composer.js.map +1 -1
- package/dist/providers/fetch/composer.test.js +58 -17
- package/dist/providers/fetch/composer.test.js.map +1 -1
- package/dist/providers/fetch/logging-middleware.d.ts +3 -2
- package/dist/providers/fetch/logging-middleware.d.ts.map +1 -1
- package/dist/providers/fetch/logging-middleware.js +5 -2
- package/dist/providers/fetch/logging-middleware.js.map +1 -1
- package/dist/providers/openai-compatible-lazy.d.ts.map +1 -1
- package/dist/providers/openai-compatible-lazy.js +2 -1
- package/dist/providers/openai-compatible-lazy.js.map +1 -1
- package/dist/providers/openai-compatible-middleware.d.ts +5 -2
- package/dist/providers/openai-compatible-middleware.d.ts.map +1 -1
- package/dist/providers/openai-compatible-middleware.js +8 -11
- package/dist/providers/openai-compatible-middleware.js.map +1 -1
- package/dist/providers/openai-compatible.provider.d.ts +5 -1
- package/dist/providers/openai-compatible.provider.d.ts.map +1 -1
- package/dist/providers/openai-compatible.provider.js +59 -37
- package/dist/providers/openai-compatible.provider.js.map +1 -1
- package/dist/providers/openai-compatible.provider.test.js +67 -3
- package/dist/providers/openai-compatible.provider.test.js.map +1 -1
- package/dist/providers/openai.provider.d.ts +8 -1
- package/dist/providers/openai.provider.d.ts.map +1 -1
- package/dist/providers/openai.provider.js +43 -10
- package/dist/providers/openai.provider.js.map +1 -1
- package/dist/providers/openai.provider.test.js +53 -16
- package/dist/providers/openai.provider.test.js.map +1 -1
- package/dist/providers/opencode-routing.d.ts +4 -0
- package/dist/providers/opencode-routing.d.ts.map +1 -0
- package/dist/providers/opencode-routing.js +14 -0
- package/dist/providers/opencode-routing.js.map +1 -0
- package/dist/providers/opencode-session.d.ts +19 -0
- package/dist/providers/opencode-session.d.ts.map +1 -0
- package/dist/providers/opencode-session.js +76 -0
- package/dist/providers/opencode-session.js.map +1 -0
- package/dist/providers/opencode.provider.d.ts +0 -8
- package/dist/providers/opencode.provider.d.ts.map +1 -1
- package/dist/providers/opencode.provider.js +0 -32
- package/dist/providers/opencode.provider.js.map +1 -1
- package/dist/providers/opencode.provider.test.d.ts +2 -0
- package/dist/providers/opencode.provider.test.d.ts.map +1 -0
- package/dist/providers/opencode.provider.test.js +186 -0
- package/dist/providers/opencode.provider.test.js.map +1 -0
- package/dist/providers/openrouter.provider.createRunner.test.js +5 -0
- package/dist/providers/openrouter.provider.createRunner.test.js.map +1 -1
- package/dist/providers/openrouter.provider.d.ts.map +1 -1
- package/dist/providers/openrouter.provider.js +8 -4
- package/dist/providers/openrouter.provider.js.map +1 -1
- package/dist/providers/registry.d.ts +3 -0
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js.map +1 -1
- package/dist/providers/registry.test.js +1 -0
- package/dist/providers/registry.test.js.map +1 -1
- package/dist/scripts/eval-auto-approval/runner.js +4 -0
- package/dist/scripts/eval-auto-approval/runner.js.map +1 -1
- package/dist/services/conversation-integration.test.js +8 -4
- package/dist/services/conversation-integration.test.js.map +1 -1
- package/dist/services/conversation-persistence.test.js +7 -0
- package/dist/services/conversation-persistence.test.js.map +1 -1
- package/dist/services/conversation-replay.d.ts.map +1 -1
- package/dist/services/conversation-replay.js +95 -4
- package/dist/services/conversation-replay.js.map +1 -1
- package/dist/services/conversation-replay.test.js +312 -0
- package/dist/services/conversation-replay.test.js.map +1 -1
- package/dist/services/conversation-result-builder.test.js +9 -0
- package/dist/services/conversation-result-builder.test.js.map +1 -1
- package/dist/services/conversation-service.d.ts +3 -1
- package/dist/services/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation-service.js +3 -0
- package/dist/services/conversation-service.js.map +1 -1
- package/dist/services/conversation-session-reasoning.test.js +5 -1
- package/dist/services/conversation-session-reasoning.test.js.map +1 -1
- package/dist/services/conversation-session.auto-approval.test.js +25 -1
- package/dist/services/conversation-session.auto-approval.test.js.map +1 -1
- package/dist/services/conversation-session.d.ts +7 -2
- package/dist/services/conversation-session.d.ts.map +1 -1
- package/dist/services/conversation-session.js +70 -45
- package/dist/services/conversation-session.js.map +1 -1
- package/dist/services/file-service.d.ts +20 -4
- package/dist/services/file-service.d.ts.map +1 -1
- package/dist/services/file-service.js +111 -52
- package/dist/services/file-service.js.map +1 -1
- package/dist/services/file-service.test.d.ts +2 -0
- package/dist/services/file-service.test.d.ts.map +1 -0
- package/dist/services/file-service.test.js +60 -0
- package/dist/services/file-service.test.js.map +1 -0
- package/dist/services/logging-service.d.ts +0 -3
- package/dist/services/logging-service.d.ts.map +1 -1
- package/dist/services/logging-service.js +12 -8
- package/dist/services/logging-service.js.map +1 -1
- package/dist/services/mode-notices.d.ts +4 -5
- package/dist/services/mode-notices.d.ts.map +1 -1
- package/dist/services/mode-notices.js +4 -5
- package/dist/services/mode-notices.js.map +1 -1
- package/dist/services/notification-service.d.ts +31 -11
- package/dist/services/notification-service.d.ts.map +1 -1
- package/dist/services/notification-service.js +88 -40
- package/dist/services/notification-service.js.map +1 -1
- package/dist/services/notification-service.test.js +135 -62
- package/dist/services/notification-service.test.js.map +1 -1
- package/dist/services/provider-traffic.d.ts +8 -9
- package/dist/services/provider-traffic.d.ts.map +1 -1
- package/dist/services/provider-traffic.js +24 -12
- package/dist/services/provider-traffic.js.map +1 -1
- package/dist/services/provider-traffic.test.js +51 -1
- package/dist/services/provider-traffic.test.js.map +1 -1
- package/dist/services/service-interfaces.d.ts +12 -16
- package/dist/services/service-interfaces.d.ts.map +1 -1
- package/dist/services/session-context-service.d.ts +8 -0
- package/dist/services/session-context-service.d.ts.map +1 -0
- package/dist/services/session-context-service.js +19 -0
- package/dist/services/session-context-service.js.map +1 -0
- package/dist/services/session-context-service.test.d.ts +2 -0
- package/dist/services/session-context-service.test.d.ts.map +1 -0
- package/dist/services/session-context-service.test.js +38 -0
- package/dist/services/session-context-service.test.js.map +1 -0
- package/dist/services/settings-env.d.ts.map +1 -1
- package/dist/services/settings-env.js +4 -1
- package/dist/services/settings-env.js.map +1 -1
- package/dist/services/settings-persistence.d.ts.map +1 -1
- package/dist/services/settings-persistence.js +0 -1
- package/dist/services/settings-persistence.js.map +1 -1
- package/dist/services/settings-persistence.test.js +2 -2
- package/dist/services/settings-persistence.test.js.map +1 -1
- package/dist/services/settings-schema.d.ts +9 -0
- package/dist/services/settings-schema.d.ts.map +1 -1
- package/dist/services/settings-schema.js +15 -4
- package/dist/services/settings-schema.js.map +1 -1
- package/dist/services/settings-service.d.ts +8 -0
- package/dist/services/settings-service.d.ts.map +1 -1
- package/dist/services/settings-service.js +58 -21
- package/dist/services/settings-service.js.map +1 -1
- package/dist/services/shell-auto-approval-evaluator.d.ts +3 -2
- package/dist/services/shell-auto-approval-evaluator.d.ts.map +1 -1
- package/dist/services/shell-auto-approval-evaluator.js +3 -3
- package/dist/services/shell-auto-approval-evaluator.js.map +1 -1
- package/dist/services/shell-auto-approval-evaluator.test.js +20 -0
- package/dist/services/shell-auto-approval-evaluator.test.js.map +1 -1
- package/dist/services/shell-auto-approval-resolver.d.ts +2 -1
- package/dist/services/shell-auto-approval-resolver.d.ts.map +1 -1
- package/dist/services/shell-auto-approval-resolver.js +2 -0
- package/dist/services/shell-auto-approval-resolver.js.map +1 -1
- package/dist/services/shell-auto-approval-resolver.test.js +10 -0
- package/dist/services/shell-auto-approval-resolver.test.js.map +1 -1
- package/dist/services/subagents/subagent-manager.d.ts +2 -1
- package/dist/services/subagents/subagent-manager.d.ts.map +1 -1
- package/dist/services/subagents/subagent-manager.js +182 -13
- package/dist/services/subagents/subagent-manager.js.map +1 -1
- package/dist/services/subagents/subagent-manager.test.js +548 -17
- package/dist/services/subagents/subagent-manager.test.js.map +1 -1
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js +2 -2
- package/dist/tools/apply-patch.js.map +1 -1
- package/dist/tools/ask-user-constants.d.ts +7 -0
- package/dist/tools/ask-user-constants.d.ts.map +1 -0
- package/dist/tools/ask-user-constants.js +7 -0
- package/dist/tools/ask-user-constants.js.map +1 -0
- package/dist/tools/ask-user.d.ts +11 -0
- package/dist/tools/ask-user.d.ts.map +1 -0
- package/dist/tools/ask-user.js +56 -0
- package/dist/tools/ask-user.js.map +1 -0
- package/dist/tools/ask-user.test.d.ts +2 -0
- package/dist/tools/ask-user.test.d.ts.map +1 -0
- package/dist/tools/ask-user.test.js +129 -0
- package/dist/tools/ask-user.test.js.map +1 -0
- package/dist/tools/format-helpers.d.ts +13 -0
- package/dist/tools/format-helpers.d.ts.map +1 -1
- package/dist/tools/format-helpers.js +34 -0
- package/dist/tools/format-helpers.js.map +1 -1
- package/dist/tools/format-helpers.test.d.ts +2 -0
- package/dist/tools/format-helpers.test.d.ts.map +1 -0
- package/dist/tools/format-helpers.test.js +51 -0
- package/dist/tools/format-helpers.test.js.map +1 -0
- package/dist/tools/search-replace.d.ts.map +1 -1
- package/dist/tools/search-replace.js +2 -2
- package/dist/tools/search-replace.js.map +1 -1
- package/dist/tools/tool-names.d.ts +1 -0
- package/dist/tools/tool-names.d.ts.map +1 -1
- package/dist/tools/tool-names.js +1 -0
- package/dist/tools/tool-names.js.map +1 -1
- package/dist/utils/command-safety/_scratch-classify.test.d.ts +2 -0
- package/dist/utils/command-safety/_scratch-classify.test.d.ts.map +1 -0
- package/dist/utils/command-safety/_scratch-classify.test.js +22 -0
- package/dist/utils/command-safety/_scratch-classify.test.js.map +1 -0
- package/dist/utils/command-safety/constants.d.ts.map +1 -1
- package/dist/utils/command-safety/constants.js +21 -0
- package/dist/utils/command-safety/constants.js.map +1 -1
- package/dist/utils/command-safety/handlers/git-handler.d.ts.map +1 -1
- package/dist/utils/command-safety/handlers/git-handler.js +28 -2
- package/dist/utils/command-safety/handlers/git-handler.js.map +1 -1
- package/dist/utils/command-safety/path-analysis.d.ts.map +1 -1
- package/dist/utils/command-safety/path-analysis.js +6 -0
- package/dist/utils/command-safety/path-analysis.js.map +1 -1
- package/dist/utils/command-safety/scratch-classify.test.d.ts +2 -0
- package/dist/utils/command-safety/scratch-classify.test.d.ts.map +1 -0
- package/dist/utils/command-safety/scratch-classify.test.js +22 -0
- package/dist/utils/command-safety/scratch-classify.test.js.map +1 -0
- package/dist/utils/command-safety/scratch-tally.test.d.ts +2 -0
- package/dist/utils/command-safety/scratch-tally.test.d.ts.map +1 -0
- package/dist/utils/command-safety/scratch-tally.test.js +68 -0
- package/dist/utils/command-safety/scratch-tally.test.js.map +1 -0
- package/dist/utils/command-safety.evaluator-false-positives.test.d.ts +2 -0
- package/dist/utils/command-safety.evaluator-false-positives.test.d.ts.map +1 -0
- package/dist/utils/command-safety.evaluator-false-positives.test.js +72 -0
- package/dist/utils/command-safety.evaluator-false-positives.test.js.map +1 -0
- package/dist/utils/header-sanitizer.d.ts +2 -0
- package/dist/utils/header-sanitizer.d.ts.map +1 -0
- package/dist/utils/header-sanitizer.js +38 -0
- package/dist/utils/header-sanitizer.js.map +1 -0
- package/dist/utils/header-sanitizer.test.d.ts +2 -0
- package/dist/utils/header-sanitizer.test.d.ts.map +1 -0
- package/dist/utils/header-sanitizer.test.js +56 -0
- package/dist/utils/header-sanitizer.test.js.map +1 -0
- package/dist/utils/home-directory-start-guard.d.ts +10 -0
- package/dist/utils/home-directory-start-guard.d.ts.map +1 -0
- package/dist/utils/home-directory-start-guard.js +20 -0
- package/dist/utils/home-directory-start-guard.js.map +1 -0
- package/dist/utils/home-directory-start-guard.test.d.ts +2 -0
- package/dist/utils/home-directory-start-guard.test.d.ts.map +1 -0
- package/dist/utils/home-directory-start-guard.test.js +40 -0
- package/dist/utils/home-directory-start-guard.test.js.map +1 -0
- package/dist/utils/inject-warning-into-tool-output.d.ts +2 -0
- package/dist/utils/inject-warning-into-tool-output.d.ts.map +1 -0
- package/dist/utils/inject-warning-into-tool-output.js +66 -0
- package/dist/utils/inject-warning-into-tool-output.js.map +1 -0
- package/dist/utils/provider-traffic-extractor.d.ts +1 -0
- package/dist/utils/provider-traffic-extractor.d.ts.map +1 -1
- package/dist/utils/provider-traffic-extractor.js +1 -0
- package/dist/utils/provider-traffic-extractor.js.map +1 -1
- package/dist/utils/provider-traffic-extractor.test.js +2 -0
- package/dist/utils/provider-traffic-extractor.test.js.map +1 -1
- package/dist/utils/token-usage.d.ts +3 -1
- package/dist/utils/token-usage.d.ts.map +1 -1
- package/dist/utils/token-usage.js +7 -2
- package/dist/utils/token-usage.js.map +1 -1
- package/dist/utils/token-usage.test.js +15 -0
- package/dist/utils/token-usage.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,53 +1,92 @@
|
|
|
1
|
-
import { getTtyWriter, writeOscSequence } from '../utils/tty-osc.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
function supportsOsc777(env) {
|
|
1
|
+
import { getTtyWriter as defaultGetTtyWriter, writeOscSequence } from '../utils/tty-osc.js';
|
|
2
|
+
const OSC777_TERM_PROGRAMS = new Set(['ghostty', 'wezterm', 'foot', 'warpterminal']);
|
|
3
|
+
const OSC777_TERM_EXACT = new Set(['foot']);
|
|
4
|
+
const OSC777_TERM_PREFIXES = ['xterm-ghostty', 'foot'];
|
|
5
|
+
const OSC9_TERM_PROGRAMS = new Set(['iterm.app', 'wezterm', 'warpterminal']);
|
|
6
|
+
const OSC9_TERM_EXACT = new Set(['rio']);
|
|
7
|
+
const OSC9_TERM_PREFIXES = ['wezterm', 'rio'];
|
|
8
|
+
function supportsOsc777(env = process.env) {
|
|
9
9
|
const termProgram = env.TERM_PROGRAM?.toLowerCase();
|
|
10
10
|
if (termProgram && OSC777_TERM_PROGRAMS.has(termProgram)) {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
const term = env.TERM?.toLowerCase();
|
|
14
14
|
if (term) {
|
|
15
|
-
if (
|
|
15
|
+
if (OSC777_TERM_EXACT.has(term))
|
|
16
16
|
return true;
|
|
17
|
-
if (OSC777_TERM_PREFIXES.some((prefix) => term.startsWith(prefix)))
|
|
17
|
+
if (OSC777_TERM_PREFIXES.some((prefix) => term.startsWith(prefix))) {
|
|
18
18
|
return true;
|
|
19
|
+
}
|
|
19
20
|
}
|
|
20
21
|
return false;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* Semicolons are used as field separators in OSC 777.
|
|
25
|
-
*/
|
|
26
|
-
function sanitize(text) {
|
|
27
|
-
// eslint-disable-next-line no-control-regex
|
|
28
|
-
return text.replace(/[\x1b\x07;]/g, '');
|
|
23
|
+
function canUseBell(env = process.env, stream = process.stdout) {
|
|
24
|
+
return Boolean(stream.isTTY && !env.CI);
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
function supportsOsc9(env = process.env) {
|
|
27
|
+
const termProgram = env.TERM_PROGRAM?.toLowerCase();
|
|
28
|
+
if (termProgram && OSC9_TERM_PROGRAMS.has(termProgram)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const term = env.TERM?.toLowerCase();
|
|
32
|
+
if (term) {
|
|
33
|
+
if (OSC9_TERM_EXACT.has(term))
|
|
34
|
+
return true;
|
|
35
|
+
if (OSC9_TERM_PREFIXES.some((prefix) => term.startsWith(prefix))) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
40
38
|
}
|
|
41
|
-
return
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
function getNotificationMethod(env = process.env, stream = process.stdout) {
|
|
42
|
+
if (env.CI)
|
|
43
|
+
return undefined;
|
|
44
|
+
if (supportsOsc777(env))
|
|
45
|
+
return 'osc777';
|
|
46
|
+
if (supportsOsc9(env))
|
|
47
|
+
return 'osc9';
|
|
48
|
+
if (canUseBell(env, stream))
|
|
49
|
+
return 'bell';
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
function escapeOsc(value) {
|
|
53
|
+
return value.replace(/\x1b/g, '').replace(/\x07/g, '').replace(/;/g, ',');
|
|
42
54
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
function buildNotificationSequence(title, message, env = process.env, stream = process.stdout) {
|
|
56
|
+
const method = getNotificationMethod(env, stream);
|
|
57
|
+
if (method === 'osc777') {
|
|
58
|
+
return `\x1b]777;notify;${escapeOsc(title)};${escapeOsc(message)}\x07`;
|
|
59
|
+
}
|
|
60
|
+
if (method === 'osc9') {
|
|
61
|
+
return `\x1b]9;${escapeOsc(message)}\x07`;
|
|
62
|
+
}
|
|
63
|
+
if (method === 'bell') {
|
|
64
|
+
return '\x07';
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
function notify(title, message, options = {}) {
|
|
69
|
+
const env = options.env ?? process.env;
|
|
70
|
+
const stream = options.stream ?? process.stdout;
|
|
71
|
+
const method = getNotificationMethod(env, stream);
|
|
72
|
+
if (method === 'osc777') {
|
|
73
|
+
stream.write(`\x1b]777;notify;${escapeOsc(title)};${escapeOsc(message)}\x07`);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (method === 'osc9') {
|
|
77
|
+
stream.write(`\x1b]9;${escapeOsc(message)}\x07`);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (method === 'bell') {
|
|
81
|
+
stream.write('\x07');
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
function sendNotification(title, message, opts = {}) {
|
|
48
87
|
const env = opts.env ?? process.env;
|
|
49
|
-
const getWriter = opts.getTtyWriter ?? getTtyWriter;
|
|
50
88
|
const logger = opts.logger;
|
|
89
|
+
const stream = opts.stream ?? process.stdout;
|
|
51
90
|
if (logger) {
|
|
52
91
|
logger.debug('sendNotification called', {
|
|
53
92
|
title,
|
|
@@ -55,14 +94,23 @@ export function sendNotification(title, message, opts = {}) {
|
|
|
55
94
|
termProgram: env.TERM_PROGRAM,
|
|
56
95
|
term: env.TERM,
|
|
57
96
|
supportsOsc777: supportsOsc777(env),
|
|
97
|
+
supportsOsc9: supportsOsc9(env),
|
|
98
|
+
canUseBell: canUseBell(env, stream),
|
|
58
99
|
});
|
|
59
100
|
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
101
|
+
const getWriter = opts.getTtyWriter ?? defaultGetTtyWriter;
|
|
102
|
+
const writer = getWriter();
|
|
103
|
+
if (!writer)
|
|
104
|
+
return false;
|
|
105
|
+
const sequence = buildNotificationSequence(title, message, env, stream);
|
|
106
|
+
if (!sequence)
|
|
107
|
+
return false;
|
|
108
|
+
if (sequence === '\x07') {
|
|
109
|
+
writer(sequence);
|
|
110
|
+
return true;
|
|
65
111
|
}
|
|
66
|
-
writeOscSequence(
|
|
112
|
+
writeOscSequence(sequence, { env, getTtyWriter: () => writer });
|
|
113
|
+
return true;
|
|
67
114
|
}
|
|
115
|
+
export { notify, supportsOsc777, supportsOsc9, canUseBell, getNotificationMethod, buildNotificationSequence, sendNotification, };
|
|
68
116
|
//# sourceMappingURL=notification-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-service.js","sourceRoot":"","sources":["../../source/services/notification-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"notification-service.js","sourceRoot":"","sources":["../../source/services/notification-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;AAsB5G,MAAM,oBAA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rB,yBAAyB,EACzB,gBAAgB,GACjB,CAAC"}
|
|
@@ -1,78 +1,151 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
test('buildNotificationSequence uses OSC 9 for unknown terminals', (t) => {
|
|
5
|
-
const seq = buildNotificationSequence('Title', 'Message', {});
|
|
6
|
-
t.is(seq, '\x1b]9;Message\x07');
|
|
7
|
-
});
|
|
8
|
-
test('buildNotificationSequence uses OSC 777 for ghostty', (t) => {
|
|
9
|
-
const seq = buildNotificationSequence('Alert', 'Done', { TERM_PROGRAM: 'ghostty' });
|
|
10
|
-
t.is(seq, '\x1b]777;notify;Alert;Done\x07');
|
|
11
|
-
});
|
|
12
|
-
test('buildNotificationSequence uses OSC 777 for kitty (TERM=xterm-kitty)', (t) => {
|
|
13
|
-
const seq = buildNotificationSequence('Alert', 'Done', { TERM: 'xterm-kitty' });
|
|
14
|
-
t.is(seq, '\x1b]777;notify;Alert;Done\x07');
|
|
15
|
-
});
|
|
16
|
-
test('buildNotificationSequence uses OSC 777 for WezTerm', (t) => {
|
|
17
|
-
const seq = buildNotificationSequence('T', 'M', { TERM_PROGRAM: 'WezTerm' });
|
|
18
|
-
t.is(seq, '\x1b]777;notify;T;M\x07');
|
|
19
|
-
});
|
|
20
|
-
test('buildNotificationSequence uses OSC 777 for foot', (t) => {
|
|
21
|
-
const seq = buildNotificationSequence('T', 'M', { TERM: 'foot' });
|
|
22
|
-
t.is(seq, '\x1b]777;notify;T;M\x07');
|
|
23
|
-
});
|
|
24
|
-
test('buildNotificationSequence uses OSC 9 for iterm2', (t) => {
|
|
25
|
-
const seq = buildNotificationSequence('T', 'M', { TERM_PROGRAM: 'iTerm.app' });
|
|
26
|
-
t.is(seq, '\x1b]9;M\x07');
|
|
27
|
-
});
|
|
28
|
-
test('buildNotificationSequence uses OSC 9 for generic xterm', (t) => {
|
|
29
|
-
const seq = buildNotificationSequence('T', 'M', { TERM: 'xterm-256color', TERM_PROGRAM: undefined });
|
|
30
|
-
t.is(seq, '\x1b]9;M\x07');
|
|
31
|
-
});
|
|
32
|
-
// ── Sanitization ────────────────────────────────────────────────────────────
|
|
33
|
-
test('buildNotificationSequence strips semicolons from title and message', (t) => {
|
|
34
|
-
const seq = buildNotificationSequence('Ti;tle', 'Me;ssage', { TERM_PROGRAM: 'ghostty' });
|
|
35
|
-
t.is(seq, '\x1b]777;notify;Title;Message\x07');
|
|
36
|
-
});
|
|
37
|
-
test('buildNotificationSequence strips ESC characters from title and message', (t) => {
|
|
38
|
-
const seq = buildNotificationSequence('Ti\x1btle', 'Me\x1bssage', { TERM_PROGRAM: 'ghostty' });
|
|
39
|
-
t.is(seq, '\x1b]777;notify;Title;Message\x07');
|
|
40
|
-
});
|
|
41
|
-
test('buildNotificationSequence strips BEL characters from title and message', (t) => {
|
|
42
|
-
const seq = buildNotificationSequence('Ti\x07tle', 'Me\x07ssage', { TERM_PROGRAM: 'ghostty' });
|
|
43
|
-
t.is(seq, '\x1b]777;notify;Title;Message\x07');
|
|
44
|
-
});
|
|
45
|
-
test('buildNotificationSequence strips semicolons from OSC 9 message', (t) => {
|
|
46
|
-
const seq = buildNotificationSequence('T', 'Me;ss;age', {});
|
|
47
|
-
t.is(seq, '\x1b]9;Message\x07');
|
|
48
|
-
});
|
|
49
|
-
// ── sendNotification ────────────────────────────────────────────────────────
|
|
50
|
-
test('sendNotification writes OSC sequence to the injected writer', (t) => {
|
|
2
|
+
import { canUseBell, getNotificationMethod, notify, sendNotification, supportsOsc777, supportsOsc9, buildNotificationSequence, } from './notification-service.js';
|
|
3
|
+
function createStream(isTTY) {
|
|
51
4
|
let written = '';
|
|
52
|
-
|
|
53
|
-
|
|
5
|
+
return {
|
|
6
|
+
isTTY,
|
|
7
|
+
get written() {
|
|
8
|
+
return written;
|
|
9
|
+
},
|
|
10
|
+
write(data) {
|
|
11
|
+
written += data;
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
test('supportsOsc777 recognizes supported terminals', (t) => {
|
|
17
|
+
t.true(supportsOsc777({ TERM_PROGRAM: 'ghostty' }));
|
|
18
|
+
t.true(supportsOsc777({ TERM_PROGRAM: 'WezTerm' }));
|
|
19
|
+
t.true(supportsOsc777({ TERM: 'foot' }));
|
|
20
|
+
t.true(supportsOsc777({ TERM: 'foot-extra' }));
|
|
21
|
+
t.true(supportsOsc777({ TERM: 'xterm-ghostty-256color' }));
|
|
22
|
+
});
|
|
23
|
+
test('supportsOsc777 excludes kitty and unrelated terminals', (t) => {
|
|
24
|
+
t.false(supportsOsc777({ TERM_PROGRAM: 'kitty' }));
|
|
25
|
+
t.false(supportsOsc777({ TERM: 'xterm-kitty' }));
|
|
26
|
+
t.false(supportsOsc777({ TERM_PROGRAM: 'iTerm.app' }));
|
|
27
|
+
});
|
|
28
|
+
test('supportsOsc9 recognizes explicitly supported terminals', (t) => {
|
|
29
|
+
t.true(supportsOsc9({ TERM_PROGRAM: 'iTerm.app' }));
|
|
30
|
+
t.true(supportsOsc9({ TERM_PROGRAM: 'WezTerm' }));
|
|
31
|
+
t.true(supportsOsc9({ TERM_PROGRAM: 'WarpTerminal' }));
|
|
32
|
+
t.true(supportsOsc9({ TERM: 'rio' }));
|
|
33
|
+
t.true(supportsOsc9({ TERM: 'rio-256color' }));
|
|
34
|
+
t.true(supportsOsc9({ TERM: 'wezterm' }));
|
|
35
|
+
});
|
|
36
|
+
test('supportsOsc9 excludes generic and unrelated terminals', (t) => {
|
|
37
|
+
t.false(supportsOsc9({ TERM: 'xterm-256color' }));
|
|
38
|
+
t.false(supportsOsc9({ TERM_PROGRAM: 'ghostty' }));
|
|
39
|
+
t.false(supportsOsc9({ TERM_PROGRAM: 'kitty' }));
|
|
40
|
+
t.false(supportsOsc9({}));
|
|
41
|
+
});
|
|
42
|
+
test('canUseBell requires a real TTY and non-CI environment', (t) => {
|
|
43
|
+
t.true(canUseBell({ TERM: 'xterm-256color' }, { isTTY: true }));
|
|
44
|
+
t.true(canUseBell({ TERM: 'dumb' }, { isTTY: true }));
|
|
45
|
+
t.false(canUseBell({ TERM: 'xterm-256color', CI: '1' }, { isTTY: true }));
|
|
46
|
+
t.false(canUseBell({ TERM: 'xterm-256color' }, { isTTY: false }));
|
|
47
|
+
t.true(canUseBell({}, { isTTY: true }));
|
|
48
|
+
});
|
|
49
|
+
test('getNotificationMethod prefers OSC 777 over bell', (t) => {
|
|
50
|
+
const stream = { isTTY: true };
|
|
51
|
+
t.is(getNotificationMethod({ TERM_PROGRAM: 'ghostty', TERM: 'xterm-256color' }, stream), 'osc777');
|
|
52
|
+
});
|
|
53
|
+
test('getNotificationMethod falls back to OSC 9 for explicitly supported terminals', (t) => {
|
|
54
|
+
const stream = { isTTY: true };
|
|
55
|
+
t.is(getNotificationMethod({ TERM_PROGRAM: 'iTerm.app', TERM: 'xterm-256color' }, stream), 'osc9');
|
|
56
|
+
t.is(getNotificationMethod({ TERM: 'rio' }, stream), 'osc9');
|
|
57
|
+
});
|
|
58
|
+
test('getNotificationMethod returns undefined when no notification path is available', (t) => {
|
|
59
|
+
const stream = { isTTY: true };
|
|
60
|
+
t.is(getNotificationMethod({ TERM: 'xterm-256color', CI: '1' }, stream), undefined);
|
|
61
|
+
t.is(getNotificationMethod({ TERM: 'dumb' }, { isTTY: false }), undefined);
|
|
62
|
+
});
|
|
63
|
+
test('getNotificationMethod falls back to bell for dumb terminals on a TTY', (t) => {
|
|
64
|
+
const stream = { isTTY: true };
|
|
65
|
+
t.is(getNotificationMethod({ TERM: 'dumb' }, stream), 'bell');
|
|
66
|
+
t.is(getNotificationMethod({ TERM: 'xterm-256color' }, stream), 'bell');
|
|
67
|
+
});
|
|
68
|
+
test('notify writes OSC 777 for capable terminals and sanitizes payloads', (t) => {
|
|
69
|
+
const stream = createStream(true);
|
|
70
|
+
const result = notify('Ti;tle\x1b', 'Me\x07ss;age', {
|
|
71
|
+
env: { TERM_PROGRAM: 'ghostty' },
|
|
72
|
+
stream,
|
|
73
|
+
});
|
|
74
|
+
t.true(result);
|
|
75
|
+
t.is(stream.written, '\x1b]777;notify;Ti,tle;Mess,age\x07');
|
|
76
|
+
});
|
|
77
|
+
test('notify writes OSC 9 fallback for explicitly supported terminals', (t) => {
|
|
78
|
+
const stream = createStream(true);
|
|
79
|
+
const result = notify('Alert', 'Done', {
|
|
80
|
+
env: { TERM_PROGRAM: 'iTerm.app', TERM: 'xterm-256color' },
|
|
81
|
+
stream,
|
|
82
|
+
});
|
|
83
|
+
t.true(result);
|
|
84
|
+
t.is(stream.written, '\x1b]9;Done\x07');
|
|
85
|
+
});
|
|
86
|
+
test('notify returns false when no notification method is available', (t) => {
|
|
87
|
+
const stream = createStream(false);
|
|
88
|
+
const result = notify('T', 'M', {
|
|
89
|
+
env: { TERM: 'dumb' },
|
|
90
|
+
stream,
|
|
91
|
+
});
|
|
92
|
+
t.false(result);
|
|
93
|
+
t.is(stream.written, '');
|
|
94
|
+
});
|
|
95
|
+
test('buildNotificationSequence mirrors the selected notification method', (t) => {
|
|
96
|
+
t.is(buildNotificationSequence('A', 'B', { TERM_PROGRAM: 'ghostty' }, { isTTY: true }), '\x1b]777;notify;A;B\x07');
|
|
97
|
+
t.is(buildNotificationSequence('A', 'B', { TERM_PROGRAM: 'iTerm.app' }, { isTTY: true }), '\x1b]9;B\x07');
|
|
98
|
+
t.is(buildNotificationSequence('A', 'B', { TERM: 'xterm-256color' }, { isTTY: true }), '\x07');
|
|
99
|
+
t.is(buildNotificationSequence('A', 'B', {}, { isTTY: false }), '');
|
|
100
|
+
t.is(buildNotificationSequence('A', 'B', { TERM: 'dumb' }, { isTTY: true }), '\x07');
|
|
101
|
+
t.is(buildNotificationSequence('A', 'B', { TERM: 'dumb' }, { isTTY: false }), '');
|
|
102
|
+
});
|
|
103
|
+
test('sendNotification supports injected tty writers for compatibility', (t) => {
|
|
104
|
+
let written = '';
|
|
105
|
+
const result = sendNotification('Alert', 'Done', {
|
|
106
|
+
env: { TERM_PROGRAM: 'ghostty' },
|
|
107
|
+
stream: { isTTY: true },
|
|
54
108
|
getTtyWriter: () => (data) => {
|
|
55
109
|
written = data;
|
|
56
110
|
},
|
|
57
111
|
});
|
|
58
|
-
t.
|
|
112
|
+
t.true(result);
|
|
113
|
+
t.is(written, '\x1b]777;notify;Alert;Done\x07');
|
|
114
|
+
});
|
|
115
|
+
test('sendNotification wraps OSC sequences for tmux passthrough', (t) => {
|
|
116
|
+
let written = '';
|
|
117
|
+
const result = sendNotification('Alert', 'Done', {
|
|
118
|
+
env: { TERM_PROGRAM: 'ghostty', TMUX: '/tmp/tmux' },
|
|
119
|
+
stream: { isTTY: true },
|
|
120
|
+
getTtyWriter: () => (data) => {
|
|
121
|
+
written = data;
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
t.true(result);
|
|
125
|
+
t.is(written, '\x1bPtmux;\x1b\x1b\x1b]777;notify;Alert;Done\x07\x1b\\');
|
|
59
126
|
});
|
|
60
|
-
test('sendNotification
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
127
|
+
test('sendNotification uses OSC 9 fallback through tty writer', (t) => {
|
|
128
|
+
let written = '';
|
|
129
|
+
const result = sendNotification('Alert', 'Done', {
|
|
130
|
+
env: { TERM_PROGRAM: 'iTerm.app', TERM: 'xterm-256color' },
|
|
131
|
+
stream: { isTTY: false },
|
|
132
|
+
getTtyWriter: () => (data) => {
|
|
133
|
+
written = data;
|
|
134
|
+
},
|
|
66
135
|
});
|
|
136
|
+
t.true(result);
|
|
137
|
+
t.is(written, '\x1b]9;Done\x07');
|
|
67
138
|
});
|
|
68
|
-
test('sendNotification
|
|
139
|
+
test('sendNotification uses bell for unknown terminals on a TTY', (t) => {
|
|
69
140
|
let written = '';
|
|
70
|
-
sendNotification('Alert', 'Done', {
|
|
71
|
-
env: {
|
|
141
|
+
const result = sendNotification('Alert', 'Done', {
|
|
142
|
+
env: { TERM: 'xterm-256color' },
|
|
143
|
+
stream: { isTTY: true },
|
|
72
144
|
getTtyWriter: () => (data) => {
|
|
73
145
|
written = data;
|
|
74
146
|
},
|
|
75
147
|
});
|
|
76
|
-
t.
|
|
148
|
+
t.true(result);
|
|
149
|
+
t.is(written, '\x07');
|
|
77
150
|
});
|
|
78
151
|
//# sourceMappingURL=notification-service.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-service.test.js","sourceRoot":"","sources":["../../source/services/notification-service.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"notification-service.test.js","sourceRoot":"","sources":["../../source/services/notification-service.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AAEnC,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,OAAO;QACL,KAAK;QACL,IAAI,OAAO;YACT,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,CAAC,IAAY;YAChB,OAAO,IAAI,IAAI,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;KACqD,CAAC;AAC3D,CAAC;AAED,IAAI,CAAC,+CAA+C,EAAE,CAAC,CAAC,EAAE,EAAE;IAC1D,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,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,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;KACF,CAAC,CAAC;IAEH,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACf,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,2DAA2D,EAAE,CAAC,CAAC,EAAE,EAAE;IACtE,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE;QAC/C,GAAG,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;QAC/B,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAwB;QAC7C,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;KACF,CAAC,CAAC;IAEH,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACf,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
export declare const TRAFFIC_TEXT_LIMIT = 100;
|
|
2
|
-
export type SessionTrafficContext
|
|
3
|
-
sessionId: string;
|
|
4
|
-
sessionStartedAt: string;
|
|
5
|
-
firstUserMessagePreview?: string;
|
|
6
|
-
mode?: string;
|
|
7
|
-
traceId?: string;
|
|
8
|
-
evaluator?: boolean;
|
|
9
|
-
};
|
|
2
|
+
export type { SessionTrafficContext } from './service-interfaces.js';
|
|
10
3
|
export type SentTrafficRecord = {
|
|
11
4
|
requestId: string;
|
|
12
5
|
timestamp: string;
|
|
13
6
|
provider: string;
|
|
14
7
|
model: string;
|
|
8
|
+
modelClass?: string;
|
|
9
|
+
modelWrapperClass?: string;
|
|
15
10
|
sessionId: string;
|
|
16
11
|
sessionStartedAt: string;
|
|
17
12
|
mode?: string;
|
|
@@ -56,11 +51,14 @@ type RequestStartInput = {
|
|
|
56
51
|
timestamp: string;
|
|
57
52
|
provider: string;
|
|
58
53
|
model: string;
|
|
54
|
+
modelClass?: string;
|
|
55
|
+
modelWrapperClass?: string;
|
|
59
56
|
sessionId: string;
|
|
60
57
|
sessionStartedAt: string;
|
|
61
58
|
mode?: string;
|
|
62
59
|
firstUserMessagePreview?: string;
|
|
63
60
|
sentBody: Record<string, unknown>;
|
|
61
|
+
headers?: Record<string, string>;
|
|
64
62
|
evaluator?: boolean;
|
|
65
63
|
};
|
|
66
64
|
type RequestCompleteInput = {
|
|
@@ -68,6 +66,8 @@ type RequestCompleteInput = {
|
|
|
68
66
|
timestamp: string;
|
|
69
67
|
provider: string;
|
|
70
68
|
model: string;
|
|
69
|
+
modelClass?: string;
|
|
70
|
+
modelWrapperClass?: string;
|
|
71
71
|
sessionId: string;
|
|
72
72
|
sessionStartedAt: string;
|
|
73
73
|
mode?: string;
|
|
@@ -83,5 +83,4 @@ export declare class ProviderTrafficArtifactStore {
|
|
|
83
83
|
recordRequestStart(input: RequestStartInput): void;
|
|
84
84
|
recordRequestComplete(input: RequestCompleteInput): void;
|
|
85
85
|
}
|
|
86
|
-
export {};
|
|
87
86
|
//# sourceMappingURL=provider-traffic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-traffic.d.ts","sourceRoot":"","sources":["../../source/services/provider-traffic.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAGtC,
|
|
1
|
+
{"version":3,"file":"provider-traffic.d.ts","sourceRoot":"","sources":["../../source/services/provider-traffic.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAGtC,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,S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;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,qBAAa,4BAA4B;;gBAI3B,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAI5C,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAkClD,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI;CA0GzD"}
|
|
@@ -28,10 +28,23 @@ const normalizePreview = (text) => {
|
|
|
28
28
|
return normalized;
|
|
29
29
|
return normalized.slice(0, PREVIEW_LIMIT);
|
|
30
30
|
};
|
|
31
|
+
const sanitizeContentArray = (content) => content.map((item) => {
|
|
32
|
+
const record = asRecord(item);
|
|
33
|
+
if (!record)
|
|
34
|
+
return item;
|
|
35
|
+
if (record.type === 'text' && typeof record.text === 'string') {
|
|
36
|
+
return { ...record, text: truncateTrafficText(record.text) };
|
|
37
|
+
}
|
|
38
|
+
return item;
|
|
39
|
+
});
|
|
31
40
|
const sanitizeInstructionLikeValue = (value) => {
|
|
32
|
-
if (typeof value
|
|
33
|
-
return value;
|
|
34
|
-
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
return truncateTrafficText(value);
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
return sanitizeContentArray(value);
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
35
48
|
};
|
|
36
49
|
const sanitizeToolDefinitions = (tools) => {
|
|
37
50
|
if (!Array.isArray(tools))
|
|
@@ -50,15 +63,6 @@ const sanitizeToolDefinitions = (tools) => {
|
|
|
50
63
|
return 'unknown-tool';
|
|
51
64
|
});
|
|
52
65
|
};
|
|
53
|
-
const sanitizeContentArray = (content) => content.map((item) => {
|
|
54
|
-
const record = asRecord(item);
|
|
55
|
-
if (!record)
|
|
56
|
-
return item;
|
|
57
|
-
if (record.type === 'text' && typeof record.text === 'string') {
|
|
58
|
-
return { ...record, text: truncateTrafficText(record.text) };
|
|
59
|
-
}
|
|
60
|
-
return item;
|
|
61
|
-
});
|
|
62
66
|
const sanitizeReasoningDetails = (reasoningDetails) => {
|
|
63
67
|
if (!Array.isArray(reasoningDetails))
|
|
64
68
|
return reasoningDetails;
|
|
@@ -92,6 +96,9 @@ export const sanitizeSentTrafficBody = (body) => {
|
|
|
92
96
|
if (Object.prototype.hasOwnProperty.call(sanitized, 'instructions')) {
|
|
93
97
|
sanitized.instructions = sanitizeInstructionLikeValue(sanitized.instructions);
|
|
94
98
|
}
|
|
99
|
+
if (Object.prototype.hasOwnProperty.call(sanitized, 'system')) {
|
|
100
|
+
sanitized.system = sanitizeInstructionLikeValue(sanitized.system);
|
|
101
|
+
}
|
|
95
102
|
if (Array.isArray(sanitized.messages)) {
|
|
96
103
|
sanitized.messages = sanitized.messages.map((item) => {
|
|
97
104
|
const record = asRecord(item);
|
|
@@ -496,8 +503,11 @@ export class ProviderTrafficArtifactStore {
|
|
|
496
503
|
timestamp: input.timestamp,
|
|
497
504
|
provider: input.provider,
|
|
498
505
|
model: input.model,
|
|
506
|
+
...(input.modelClass ? { modelClass: input.modelClass } : {}),
|
|
507
|
+
...(input.modelWrapperClass ? { modelWrapperClass: input.modelWrapperClass } : {}),
|
|
499
508
|
sessionId: input.sessionId,
|
|
500
509
|
mode: input.mode ?? 'unknown',
|
|
510
|
+
...(input.headers ? { headers: input.headers } : {}),
|
|
501
511
|
body: sanitizeSentTrafficBody(input.sentBody),
|
|
502
512
|
};
|
|
503
513
|
fs.writeFileSync(requestPath, `${JSON.stringify(sentRecord, null, 2)}\n`, 'utf8');
|
|
@@ -525,6 +535,8 @@ export class ProviderTrafficArtifactStore {
|
|
|
525
535
|
timestamp: input.timestamp,
|
|
526
536
|
provider: input.provider,
|
|
527
537
|
model: input.model,
|
|
538
|
+
...(input.modelClass ? { modelClass: input.modelClass } : {}),
|
|
539
|
+
...(input.modelWrapperClass ? { modelWrapperClass: input.modelWrapperClass } : {}),
|
|
528
540
|
sessionId: input.sessionId,
|
|
529
541
|
mode: input.mode ?? 'unknown',
|
|
530
542
|
...(input.receivedSummary ? { summary: input.receivedSummary } : {}),
|