@bubblebrain-ai/bubble 0.0.51 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -12
- package/dist/agent/routing-catalog.js +3 -2
- package/dist/agent/subagent/router.js +5 -0
- package/dist/agent/subagent/runtime.d.ts +1 -0
- package/dist/agent/subagent/runtime.js +13 -1
- package/dist/agent/subagent-control.d.ts +4 -0
- package/dist/agent/subagent-control.js +1 -0
- package/dist/agent/subagent-store.js +2 -0
- package/dist/agent/workflow/control.d.ts +2 -0
- package/dist/agent/workflow/runs.d.ts +1 -0
- package/dist/agent/workflow/runs.js +3 -0
- package/dist/agent.d.ts +11 -1
- package/dist/agent.js +158 -57
- package/dist/bin.js +2 -44
- package/dist/config.d.ts +14 -1
- package/dist/config.js +45 -4
- package/dist/context/budget.d.ts +7 -1
- package/dist/context/budget.js +25 -2
- package/dist/context/compact-llm.d.ts +1 -1
- package/dist/context/compact-llm.js +5 -2
- package/dist/context/overflow.js +2 -0
- package/dist/context/projector.d.ts +8 -0
- package/dist/context/projector.js +55 -6
- package/dist/context/tool-output-truncate.d.ts +17 -1
- package/dist/context/tool-output-truncate.js +171 -49
- package/dist/feishu/agent-host/run-driver.js +3 -0
- package/dist/feishu/serve.js +2 -0
- package/dist/goal/command.d.ts +1 -1
- package/dist/goal/command.js +7 -2
- package/dist/main.d.ts +1 -1
- package/dist/main.js +38 -8
- package/dist/memory/db.js +0 -7
- package/dist/model-catalog.js +25 -6
- package/dist/model-config.js +3 -2
- package/dist/model-pricing.d.ts +24 -5
- package/dist/model-pricing.js +0 -0
- package/dist/model-selection.js +13 -4
- package/dist/network/chatgpt-transport.js +0 -34
- package/dist/network/errors.d.ts +19 -0
- package/dist/network/errors.js +24 -0
- package/dist/network/provider-transport.d.ts +0 -4
- package/dist/network/provider-transport.js +3 -35
- package/dist/network/retry.d.ts +6 -1
- package/dist/network/retry.js +9 -0
- package/dist/provider-model-policy.d.ts +16 -0
- package/dist/provider-model-policy.js +33 -0
- package/dist/provider-registry.d.ts +1 -1
- package/dist/provider-registry.js +80 -11
- package/dist/provider-transform.js +32 -4
- package/dist/provider.d.ts +6 -2
- package/dist/provider.js +100 -11
- package/dist/question/controller.js +5 -4
- package/dist/question/normalize.d.ts +6 -0
- package/dist/question/normalize.js +11 -0
- package/dist/rewind.d.ts +20 -0
- package/dist/rewind.js +29 -0
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +11 -3
- package/dist/session.d.ts +7 -0
- package/dist/session.js +20 -0
- package/dist/skills/discovery.js +18 -0
- package/dist/skills/registry.d.ts +12 -2
- package/dist/skills/registry.js +40 -5
- package/dist/skills/types.d.ts +2 -0
- package/dist/slash-commands/commands.js +120 -81
- package/dist/slash-commands/registry.d.ts +2 -1
- package/dist/slash-commands/registry.js +3 -0
- package/dist/slash-commands/types.d.ts +22 -4
- package/dist/stats/usage.d.ts +3 -1
- package/dist/stats/usage.js +22 -13
- package/dist/tasks/manager.d.ts +4 -2
- package/dist/tasks/manager.js +34 -9
- package/dist/tasks/promotion.d.ts +2 -2
- package/dist/tasks/promotion.js +2 -2
- package/dist/tools/agent-lifecycle.js +4 -0
- package/dist/tools/bash.d.ts +3 -1
- package/dist/tools/bash.js +13 -2
- package/dist/tools/grep.d.ts +5 -1
- package/dist/tools/grep.js +318 -69
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/question.js +5 -4
- package/dist/tools/read.js +40 -21
- package/dist/tui/animation-clock.d.ts +14 -0
- package/dist/tui/animation-clock.js +34 -0
- package/dist/tui/app.d.ts +176 -0
- package/dist/tui/app.js +1647 -0
- package/dist/tui/components/approval-dialog.d.ts +43 -0
- package/dist/tui/components/approval-dialog.js +247 -0
- package/dist/tui/components/bottom-sheet.d.ts +9 -0
- package/dist/tui/components/bottom-sheet.js +32 -0
- package/dist/tui/components/context-info.d.ts +54 -0
- package/dist/tui/components/context-info.js +388 -0
- package/dist/tui/components/feedback-dialog.d.ts +56 -0
- package/dist/tui/components/feedback-dialog.js +262 -0
- package/dist/tui/components/feishu-setup-dialog.d.ts +65 -0
- package/dist/tui/components/feishu-setup-dialog.js +332 -0
- package/dist/tui/components/image-preview.d.ts +32 -0
- package/dist/tui/components/image-preview.js +130 -0
- package/dist/tui/components/plan-dialog.d.ts +34 -0
- package/dist/tui/components/plan-dialog.js +196 -0
- package/dist/tui/components/provider-key-input.d.ts +18 -0
- package/dist/tui/components/provider-key-input.js +49 -0
- package/dist/tui/components/question-dialog.d.ts +25 -0
- package/dist/tui/components/question-dialog.js +263 -0
- package/dist/tui/components/responsive-transcript.d.ts +31 -0
- package/dist/tui/components/responsive-transcript.js +77 -0
- package/dist/tui/components/rewind-picker.d.ts +62 -0
- package/dist/tui/components/rewind-picker.js +317 -0
- package/dist/tui/components/session-picker.d.ts +49 -0
- package/dist/tui/components/session-picker.js +303 -0
- package/dist/tui/components/skills-panel.d.ts +59 -0
- package/dist/tui/components/skills-panel.js +568 -0
- package/dist/tui/components/stats-panel.d.ts +40 -0
- package/dist/tui/components/stats-panel.js +301 -0
- package/dist/tui/components/streaming-message.d.ts +69 -0
- package/dist/tui/components/streaming-message.js +393 -0
- package/dist/tui/components/subagent-inspector.d.ts +28 -0
- package/dist/tui/components/subagent-inspector.js +127 -0
- package/dist/tui/components/task-inspector.d.ts +26 -0
- package/dist/tui/components/task-inspector.js +70 -0
- package/dist/tui/components/tasks-pane.d.ts +88 -0
- package/dist/tui/components/tasks-pane.js +416 -0
- package/dist/tui/components/transcript.d.ts +96 -0
- package/dist/tui/components/transcript.js +771 -0
- package/dist/tui/components/welcome.d.ts +20 -0
- package/dist/tui/components/welcome.js +133 -0
- package/dist/tui/components/workflow-inspector.d.ts +30 -0
- package/dist/tui/components/workflow-inspector.js +136 -0
- package/dist/tui/composer-autocomplete.d.ts +61 -0
- package/dist/tui/composer-autocomplete.js +383 -0
- package/dist/tui/composer-style.d.ts +7 -0
- package/dist/tui/composer-style.js +29 -0
- package/dist/tui/controller/agent-event-reducer.d.ts +75 -0
- package/dist/tui/controller/agent-event-reducer.js +238 -0
- package/dist/tui/controller/composer-controller.d.ts +95 -0
- package/dist/tui/controller/composer-controller.js +502 -0
- package/dist/tui/controller/controller.d.ts +194 -0
- package/dist/tui/controller/controller.js +1035 -0
- package/dist/tui/controller/effects.d.ts +71 -0
- package/dist/tui/controller/effects.js +1 -0
- package/dist/tui/controller/goal-runtime-controller.d.ts +47 -0
- package/dist/tui/controller/goal-runtime-controller.js +202 -0
- package/dist/tui/controller/input-queue-machine.d.ts +71 -0
- package/dist/tui/controller/input-queue-machine.js +121 -0
- package/dist/tui/controller/intents.d.ts +56 -0
- package/dist/tui/controller/intents.js +6 -0
- package/dist/tui/controller/overlay-controller.d.ts +64 -0
- package/dist/tui/controller/overlay-controller.js +129 -0
- package/dist/tui/controller/ports.d.ts +57 -0
- package/dist/tui/controller/ports.js +9 -0
- package/dist/tui/controller/session-transition.d.ts +54 -0
- package/dist/tui/controller/session-transition.js +68 -0
- package/dist/tui/controller/state.d.ts +14 -0
- package/dist/tui/controller/state.js +36 -0
- package/dist/tui/controller/task-runtime-controller.d.ts +66 -0
- package/dist/tui/controller/task-runtime-controller.js +158 -0
- package/dist/tui/footer.d.ts +37 -0
- package/dist/tui/footer.js +80 -0
- package/dist/{tui-ink → tui/formatting}/edit-diff.d.ts +1 -1
- package/dist/{tui-ink → tui/formatting}/edit-diff.js +1 -1
- package/dist/{tui-ink/app-helpers.d.ts → tui/formatting/summary.d.ts} +4 -4
- package/dist/{tui-ink/app-helpers.js → tui/formatting/summary.js} +2 -2
- package/dist/tui/fullscreen.d.ts +48 -0
- package/dist/tui/fullscreen.js +255 -0
- package/dist/tui/image-display.d.ts +4 -0
- package/dist/tui/image-display.js +30 -12
- package/dist/tui/markdown-style.d.ts +5 -0
- package/dist/tui/markdown-style.js +23 -0
- package/dist/{tui-ink → tui/model}/composer-buffer.js +1 -1
- package/dist/tui/model/composer-types.d.ts +17 -0
- package/dist/tui/model/composer-types.js +1 -0
- package/dist/{tui-ink → tui/model}/display-history.d.ts +7 -1
- package/dist/{tui-ink → tui/model}/display-reconstruct.d.ts +1 -1
- package/dist/{tui-ink → tui/model}/display-reconstruct.js +54 -6
- package/dist/{tui-ink → tui/model}/file-mentions.d.ts +2 -0
- package/dist/{tui-ink → tui/model}/file-mentions.js +4 -0
- package/dist/tui/model/image-attachment.d.ts +15 -0
- package/dist/tui/model/image-attachment.js +1 -0
- package/dist/{tui-ink → tui/model}/image-paste.d.ts +7 -1
- package/dist/{tui-ink → tui/model}/image-paste.js +46 -0
- package/dist/tui/model/input-history.d.ts +1 -0
- package/dist/tui/model/input-history.js +1 -0
- package/dist/{tui-ink → tui/model}/input-queue.d.ts +1 -1
- package/dist/{tui-ink → tui/model}/recent-activity.js +1 -1
- package/dist/{tui-ink → tui/model}/subagent-view.d.ts +17 -2
- package/dist/{tui-ink → tui/model}/subagent-view.js +125 -4
- package/dist/{tui-ink → tui/model}/submit-dedupe.d.ts +1 -1
- package/dist/tui/model/theme-style.d.ts +10 -0
- package/dist/tui/model/theme-style.js +79 -0
- package/dist/{tui-ink → tui/model}/theme.d.ts +11 -23
- package/dist/{tui-ink → tui/model}/theme.js +23 -38
- package/dist/{tui-ink → tui/model}/trace-groups.d.ts +2 -0
- package/dist/{tui-ink → tui/model}/trace-groups.js +91 -30
- package/dist/tui/model/trace-interaction.d.ts +63 -0
- package/dist/tui/model/trace-interaction.js +87 -0
- package/dist/tui/model-picker-data.d.ts +1 -2
- package/dist/tui/model-picker-data.js +8 -1
- package/dist/tui/model-switch.js +2 -0
- package/dist/{tui-ink → tui}/run-session-picker.d.ts +2 -3
- package/dist/tui/run-session-picker.js +64 -0
- package/dist/tui/run.d.ts +72 -0
- package/dist/tui/run.js +139 -0
- package/dist/tui/terminal/multiplexer.d.ts +5 -0
- package/dist/tui/terminal/multiplexer.js +14 -0
- package/dist/tui/testing/fake-agent.d.ts +24 -0
- package/dist/tui/testing/fake-agent.js +22 -0
- package/dist/tui/testing/spy-host.d.ts +21 -0
- package/dist/tui/testing/spy-host.js +55 -0
- package/dist/tui/trace-groups.js +27 -6
- package/dist/types.d.ts +7 -0
- package/node_modules/@bubblebrain-ai/pi-tui/LICENSE +21 -0
- package/node_modules/@bubblebrain-ai/pi-tui/README.md +854 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/alt-screen-search.d.ts +26 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/alt-screen-search.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/alt-screen-search.js +121 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/alt-screen-search.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/autocomplete.d.ts +86 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/autocomplete.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/autocomplete.js +649 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/autocomplete.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/alt-screen-flash.d.ts +13 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/alt-screen-flash.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/alt-screen-flash.js +36 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/alt-screen-flash.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/box.d.ts +22 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/box.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/box.js +99 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/box.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/cancellable-loader.d.ts +22 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/cancellable-loader.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/cancellable-loader.js +36 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/cancellable-loader.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/editor.d.ts +330 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/editor.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/editor.js +2344 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/editor.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/h-stack.d.ts +7 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/h-stack.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/h-stack.js +43 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/h-stack.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/image.d.ts +28 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/image.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/image.js +82 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/image.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/input.d.ts +48 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/input.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/input.js +390 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/input.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/loader.d.ts +31 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/loader.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/loader.js +67 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/loader.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/markdown.d.ts +103 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/markdown.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/markdown.js +797 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/markdown.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/scroll-view.d.ts +56 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/scroll-view.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/scroll-view.js +179 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/scroll-view.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/select-list.d.ts +53 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/select-list.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/select-list.js +175 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/select-list.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/settings-list.d.ts +50 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/settings-list.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/settings-list.js +174 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/settings-list.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/spacer.d.ts +12 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/spacer.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/spacer.js +22 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/spacer.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/stack.d.ts +32 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/stack.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/stack.js +109 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/stack.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/text.d.ts +19 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/text.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/text.js +81 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/text.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/truncated-text.d.ts +13 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/truncated-text.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/truncated-text.js +48 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/truncated-text.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/v-stack.d.ts +8 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/v-stack.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/v-stack.js +26 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/components/v-stack.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/editor-component.d.ts +39 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/editor-component.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/editor-component.js +2 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/editor-component.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/fuzzy.d.ts +16 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/fuzzy.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/fuzzy.js +110 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/fuzzy.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/index.d.ts +31 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/index.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/index.js +42 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/index.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keybindings.d.ts +273 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keybindings.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keybindings.js +231 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keybindings.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keys.d.ts +184 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keys.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keys.js +1174 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/keys.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/kill-ring.d.ts +28 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/kill-ring.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/kill-ring.js +46 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/kill-ring.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/latex.d.ts +10 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/latex.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/latex.js +1268 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/latex.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout-node.d.ts +40 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout-node.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout-node.js +6 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout-node.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout.d.ts +42 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout.js +335 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/layout.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/native-modifiers.d.ts +3 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/native-modifiers.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/native-modifiers.js +60 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/native-modifiers.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/stdin-buffer.d.ts +56 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/stdin-buffer.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/stdin-buffer.js +363 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/stdin-buffer.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-colors.d.ts +10 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-colors.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-colors.js +59 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-colors.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-image.d.ts +116 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-image.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-image.js +518 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal-image.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal.d.ts +142 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal.js +544 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/terminal.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/testing.d.ts +11 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/testing.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/testing.js +11 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/testing.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.d.ts +140 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.js +1334 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-main-screen.d.ts +39 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-main-screen.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-main-screen.js +536 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-main-screen.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.d.ts +338 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.js +1016 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/undo-stack.d.ts +17 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/undo-stack.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/undo-stack.js +27 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/undo-stack.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/utils.d.ts +96 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/utils.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/utils.js +1193 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/utils.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/word-navigation.d.ts +25 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/word-navigation.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/word-navigation.js +96 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/src/word-navigation.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/test/virtual-terminal.d.ts +73 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/test/virtual-terminal.d.ts.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/test/virtual-terminal.js +188 -0
- package/node_modules/@bubblebrain-ai/pi-tui/dist/test/virtual-terminal.js.map +1 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/darwin/README.md +20 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/darwin/build.sh +62 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/darwin/src/darwin-modifiers.c +70 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/win32/README.md +22 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/win32/build.mjs +229 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/node_modules/@bubblebrain-ai/pi-tui/native/win32/src/win32-console-mode.c +119 -0
- package/node_modules/@bubblebrain-ai/pi-tui/package.json +66 -0
- package/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/node_modules/get-east-asian-width/index.js +30 -0
- package/node_modules/get-east-asian-width/license +9 -0
- package/node_modules/get-east-asian-width/lookup-data.js +21 -0
- package/node_modules/get-east-asian-width/lookup.js +138 -0
- package/node_modules/get-east-asian-width/package.json +71 -0
- package/node_modules/get-east-asian-width/readme.md +65 -0
- package/node_modules/get-east-asian-width/utilities.js +24 -0
- package/package.json +23 -10
- package/packages/pi-tui/node_modules/marked/LICENSE +44 -0
- package/packages/pi-tui/node_modules/marked/README.md +115 -0
- package/packages/pi-tui/node_modules/marked/bin/main.js +284 -0
- package/packages/pi-tui/node_modules/marked/bin/marked.js +16 -0
- package/packages/pi-tui/node_modules/marked/lib/marked.d.ts +760 -0
- package/packages/pi-tui/node_modules/marked/lib/marked.esm.js +77 -0
- package/packages/pi-tui/node_modules/marked/lib/marked.esm.js.map +7 -0
- package/packages/pi-tui/node_modules/marked/lib/marked.umd.js +79 -0
- package/packages/pi-tui/node_modules/marked/lib/marked.umd.js.map +7 -0
- package/packages/pi-tui/node_modules/marked/man/marked.1 +113 -0
- package/packages/pi-tui/node_modules/marked/man/marked.1.md +93 -0
- package/packages/pi-tui/node_modules/marked/package.json +103 -0
- package/dist/tui-ink/app.d.ts +0 -76
- package/dist/tui-ink/app.js +0 -2377
- package/dist/tui-ink/approval/approval-dialog.d.ts +0 -13
- package/dist/tui-ink/approval/approval-dialog.js +0 -184
- package/dist/tui-ink/approval/diff-view.d.ts +0 -7
- package/dist/tui-ink/approval/diff-view.js +0 -44
- package/dist/tui-ink/approval/select.d.ts +0 -35
- package/dist/tui-ink/approval/select.js +0 -98
- package/dist/tui-ink/code-highlight.d.ts +0 -8
- package/dist/tui-ink/code-highlight.js +0 -121
- package/dist/tui-ink/command-palette.d.ts +0 -32
- package/dist/tui-ink/command-palette.js +0 -158
- package/dist/tui-ink/compaction-progress.d.ts +0 -19
- package/dist/tui-ink/compaction-progress.js +0 -74
- package/dist/tui-ink/detect-theme.d.ts +0 -1
- package/dist/tui-ink/detect-theme.js +0 -1
- package/dist/tui-ink/feedback-dialog.d.ts +0 -19
- package/dist/tui-ink/feedback-dialog.js +0 -133
- package/dist/tui-ink/feishu-setup-picker.d.ts +0 -5
- package/dist/tui-ink/feishu-setup-picker.js +0 -271
- package/dist/tui-ink/footer.d.ts +0 -26
- package/dist/tui-ink/footer.js +0 -51
- package/dist/tui-ink/input-box.d.ts +0 -189
- package/dist/tui-ink/input-box.js +0 -1279
- package/dist/tui-ink/input-history.d.ts +0 -1
- package/dist/tui-ink/input-history.js +0 -1
- package/dist/tui-ink/markdown.d.ts +0 -103
- package/dist/tui-ink/markdown.js +0 -747
- package/dist/tui-ink/message-list.d.ts +0 -49
- package/dist/tui-ink/message-list.js +0 -841
- package/dist/tui-ink/model-picker.d.ts +0 -143
- package/dist/tui-ink/model-picker.js +0 -966
- package/dist/tui-ink/plan-confirm.d.ts +0 -7
- package/dist/tui-ink/plan-confirm.js +0 -115
- package/dist/tui-ink/question-dialog.d.ts +0 -8
- package/dist/tui-ink/question-dialog.js +0 -135
- package/dist/tui-ink/rewind-picker.d.ts +0 -8
- package/dist/tui-ink/rewind-picker.js +0 -102
- package/dist/tui-ink/run-session-picker.js +0 -22
- package/dist/tui-ink/run.d.ts +0 -62
- package/dist/tui-ink/run.js +0 -103
- package/dist/tui-ink/session-picker.d.ts +0 -10
- package/dist/tui-ink/session-picker.js +0 -113
- package/dist/tui-ink/stats-panel.d.ts +0 -11
- package/dist/tui-ink/stats-panel.js +0 -65
- package/dist/tui-ink/subagent-inspector.d.ts +0 -21
- package/dist/tui-ink/subagent-inspector.js +0 -205
- package/dist/tui-ink/use-terminal-size.d.ts +0 -4
- package/dist/tui-ink/use-terminal-size.js +0 -48
- package/dist/tui-ink/waiting-indicator.d.ts +0 -12
- package/dist/tui-ink/waiting-indicator.js +0 -129
- package/dist/tui-ink/welcome.d.ts +0 -25
- package/dist/tui-ink/welcome.js +0 -88
- package/dist/tui-ink/wordmark.d.ts +0 -8
- package/dist/tui-ink/wordmark.js +0 -103
- /package/dist/{tui-ink → tui/model}/composer-buffer.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/display-history.js +0 -0
- /package/dist/{tui-ink → tui/model}/input-queue.js +0 -0
- /package/dist/{tui-ink → tui/model}/key-events.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/key-events.js +0 -0
- /package/dist/{tui-ink → tui/model}/paste-operation-tracker.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/paste-operation-tracker.js +0 -0
- /package/dist/{tui-ink → tui/model}/recent-activity.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/submit-dedupe.js +0 -0
- /package/dist/{tui-ink → tui/model}/sync-output.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/sync-output.js +0 -0
- /package/dist/{tui-ink → tui/model}/terminal-env.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/terminal-env.js +0 -0
- /package/dist/{tui-ink → tui/model}/terminal-mouse.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/terminal-mouse.js +0 -0
- /package/dist/{tui-ink → tui/model}/width.d.ts +0 -0
- /package/dist/{tui-ink → tui/model}/width.js +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export type KeyboardProtocolNegotiationSequence = {
|
|
2
|
+
type: "kitty-flags";
|
|
3
|
+
flags: number;
|
|
4
|
+
} | {
|
|
5
|
+
type: "device-attributes";
|
|
6
|
+
};
|
|
7
|
+
export declare function parseKeyboardProtocolNegotiationSequence(sequence: string): KeyboardProtocolNegotiationSequence | undefined;
|
|
8
|
+
export declare function isAppleTerminalSession(): boolean;
|
|
9
|
+
export declare function normalizeNativeShiftEnterInput(data: string, shouldDetectNativeShiftEnter: boolean, isShiftPressed: boolean): string;
|
|
10
|
+
export declare function normalizeAppleTerminalInput(data: string, isAppleTerminal: boolean, isShiftPressed: boolean): string;
|
|
11
|
+
/** A long wall-clock gap while the event loop could not run is the portable
|
|
12
|
+
* signal Node exposes for laptop sleep/wake. */
|
|
13
|
+
export declare function isTerminalWakeGap(elapsedMs: number, thresholdMs?: number): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Minimal terminal interface for TUI
|
|
16
|
+
*/
|
|
17
|
+
export interface Terminal {
|
|
18
|
+
start(onInput: (data: string) => void, onResize: () => void, onResume?: () => void): void;
|
|
19
|
+
stop(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Drain stdin before exiting to prevent Kitty key release events from
|
|
22
|
+
* leaking to the parent shell over slow SSH connections.
|
|
23
|
+
* @param maxMs - Maximum time to drain (default: 1000ms)
|
|
24
|
+
* @param idleMs - Exit early if no input arrives within this time (default: 50ms)
|
|
25
|
+
*/
|
|
26
|
+
drainInput(maxMs?: number, idleMs?: number): Promise<void>;
|
|
27
|
+
write(data: string): void;
|
|
28
|
+
get columns(): number;
|
|
29
|
+
get rows(): number;
|
|
30
|
+
get kittyProtocolActive(): boolean;
|
|
31
|
+
moveBy(lines: number): void;
|
|
32
|
+
hideCursor(): void;
|
|
33
|
+
showCursor(): void;
|
|
34
|
+
clearLine(): void;
|
|
35
|
+
clearFromCursor(): void;
|
|
36
|
+
clearScreen(): void;
|
|
37
|
+
setTitle(title: string): void;
|
|
38
|
+
setProgress(active: boolean): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve how long to wait for the rest of an escape sequence before
|
|
42
|
+
* dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus
|
|
43
|
+
* another byte, so high-latency transports need a longer reassembly window.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveEscapeTimeoutMs(env?: NodeJS.ProcessEnv): number;
|
|
46
|
+
/**
|
|
47
|
+
* Real terminal using process.stdin/stdout
|
|
48
|
+
*/
|
|
49
|
+
export declare class ProcessTerminal implements Terminal {
|
|
50
|
+
private wasRaw;
|
|
51
|
+
private inputHandler?;
|
|
52
|
+
private resizeHandler?;
|
|
53
|
+
private resumeHandler?;
|
|
54
|
+
private _kittyProtocolActive;
|
|
55
|
+
private _modifyOtherKeysActive;
|
|
56
|
+
private keyboardProtocolPushed;
|
|
57
|
+
private keyboardProtocolNegotiationBuffer;
|
|
58
|
+
private keyboardProtocolBufferFlushTimer?;
|
|
59
|
+
private stdinBuffer?;
|
|
60
|
+
private stdinDataHandler?;
|
|
61
|
+
private progressInterval?;
|
|
62
|
+
private wakeCheckInterval?;
|
|
63
|
+
private lastWakeCheckAt;
|
|
64
|
+
private lastWakeRecoveryAt?;
|
|
65
|
+
private readonly handleContinue;
|
|
66
|
+
private writeLogPath;
|
|
67
|
+
get kittyProtocolActive(): boolean;
|
|
68
|
+
get modifyOtherKeysActive(): boolean;
|
|
69
|
+
start(onInput: (data: string) => void, onResize: () => void, onResume?: () => void): void;
|
|
70
|
+
/**
|
|
71
|
+
* Reassert every terminal-side input contract after system wake. macOS may
|
|
72
|
+
* preserve tty raw flags while leaving Node stdin paused or Ghostty's
|
|
73
|
+
* private keyboard modes reset.
|
|
74
|
+
*/
|
|
75
|
+
private recoverAfterWake;
|
|
76
|
+
private startWakeRecovery;
|
|
77
|
+
private checkForWake;
|
|
78
|
+
/**
|
|
79
|
+
* SIGCONT and the overdue watchdog timer are commonly delivered together
|
|
80
|
+
* after a long process suspension. Collapse them into one atomic recovery so
|
|
81
|
+
* the freshly rebuilt stdin parser cannot be torn down a second time while
|
|
82
|
+
* the user is already typing or pasting.
|
|
83
|
+
*/
|
|
84
|
+
private requestWakeRecovery;
|
|
85
|
+
private stopWakeRecovery;
|
|
86
|
+
private resetKeyboardInputPipeline;
|
|
87
|
+
/**
|
|
88
|
+
* Set up StdinBuffer to split batched input into individual sequences.
|
|
89
|
+
* This ensures components receive single events, making matchesKey/isKeyRelease work correctly.
|
|
90
|
+
*
|
|
91
|
+
* Also watches for Kitty protocol response and enables it when detected.
|
|
92
|
+
* This is done here (after stdinBuffer parsing) rather than on raw stdin
|
|
93
|
+
* to handle the case where the response arrives split across multiple events.
|
|
94
|
+
*/
|
|
95
|
+
private setupStdinBuffer;
|
|
96
|
+
/**
|
|
97
|
+
* Query terminal for Kitty keyboard protocol support and enable it if available.
|
|
98
|
+
*
|
|
99
|
+
* Kitty's progressive enhancement detection requires requesting the desired
|
|
100
|
+
* flags before querying them. The trailing DA query is a sentinel supported by
|
|
101
|
+
* terminals that do not know Kitty keyboard protocol; receiving DA before a
|
|
102
|
+
* Kitty response enables modifyOtherKeys fallback without a startup timeout.
|
|
103
|
+
*
|
|
104
|
+
* The requested flags are:
|
|
105
|
+
* - 1 = disambiguate escape codes
|
|
106
|
+
* - 2 = report event types (press/repeat/release)
|
|
107
|
+
* - 4 = report alternate keys (shifted key, base layout key)
|
|
108
|
+
*/
|
|
109
|
+
private queryAndEnableKittyProtocol;
|
|
110
|
+
private handleKeyboardProtocolNegotiationSequence;
|
|
111
|
+
private readKeyboardProtocolNegotiationSequence;
|
|
112
|
+
private setKeyboardProtocolNegotiationBuffer;
|
|
113
|
+
private clearKeyboardProtocolNegotiationBuffer;
|
|
114
|
+
private flushKeyboardProtocolNegotiationBufferAsInput;
|
|
115
|
+
private scheduleKeyboardProtocolNegotiationBufferFlush;
|
|
116
|
+
private clearKeyboardProtocolNegotiationBufferFlushTimer;
|
|
117
|
+
private forwardInputSequence;
|
|
118
|
+
private enableModifyOtherKeys;
|
|
119
|
+
private disableModifyOtherKeys;
|
|
120
|
+
/**
|
|
121
|
+
* On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin
|
|
122
|
+
* console handle so the terminal sends VT sequences for modified keys
|
|
123
|
+
* (e.g. \x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW
|
|
124
|
+
* discards modifier state and Shift+Tab arrives as plain \t.
|
|
125
|
+
*/
|
|
126
|
+
private enableWindowsVTInput;
|
|
127
|
+
drainInput(maxMs?: number, idleMs?: number): Promise<void>;
|
|
128
|
+
stop(): void;
|
|
129
|
+
write(data: string): void;
|
|
130
|
+
get columns(): number;
|
|
131
|
+
get rows(): number;
|
|
132
|
+
moveBy(lines: number): void;
|
|
133
|
+
hideCursor(): void;
|
|
134
|
+
showCursor(): void;
|
|
135
|
+
clearLine(): void;
|
|
136
|
+
clearFromCursor(): void;
|
|
137
|
+
clearScreen(): void;
|
|
138
|
+
setTitle(title: string): void;
|
|
139
|
+
setProgress(active: boolean): void;
|
|
140
|
+
private clearProgressInterval;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/terminal.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { setKittyProtocolActive } from "./keys.js";
|
|
6
|
+
import { isNativeModifierPressed } from "./native-modifiers.js";
|
|
7
|
+
import { StdinBuffer } from "./stdin-buffer.js";
|
|
8
|
+
const cjsRequire = createRequire(import.meta.url);
|
|
9
|
+
const TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;
|
|
10
|
+
const TERMINAL_PROGRESS_ACTIVE_SEQUENCE = "\x1b]9;4;3\x07";
|
|
11
|
+
const TERMINAL_PROGRESS_CLEAR_SEQUENCE = "\x1b]9;4;0\x07";
|
|
12
|
+
const NATIVE_SHIFT_ENTER_SEQUENCE = "\x1b[13;2u";
|
|
13
|
+
const DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;
|
|
14
|
+
const KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS = 150;
|
|
15
|
+
const KITTY_KEYBOARD_PROTOCOL_QUERY = `\x1b[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\x1b[?u\x1b[c`;
|
|
16
|
+
const TERMINAL_WAKE_CHECK_INTERVAL_MS = 1_000;
|
|
17
|
+
const TERMINAL_WAKE_GAP_MS = 5_000;
|
|
18
|
+
const TERMINAL_WAKE_RECOVERY_COOLDOWN_MS = 2_000;
|
|
19
|
+
export function parseKeyboardProtocolNegotiationSequence(sequence) {
|
|
20
|
+
const kittyFlags = sequence.match(/^\x1b\[\?(\d+)u$/);
|
|
21
|
+
if (kittyFlags) {
|
|
22
|
+
return { type: "kitty-flags", flags: Number.parseInt(kittyFlags[1], 10) };
|
|
23
|
+
}
|
|
24
|
+
if (/^\x1b\[\?[\d;]*c$/.test(sequence)) {
|
|
25
|
+
return { type: "device-attributes" };
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
function isKeyboardProtocolNegotiationSequencePrefix(sequence) {
|
|
30
|
+
return sequence === "\x1b[" || /^\x1b\[\?[\d;]*$/.test(sequence);
|
|
31
|
+
}
|
|
32
|
+
export function isAppleTerminalSession() {
|
|
33
|
+
return process.platform === "darwin" && process.env.TERM_PROGRAM === "Apple_Terminal";
|
|
34
|
+
}
|
|
35
|
+
export function normalizeNativeShiftEnterInput(data, shouldDetectNativeShiftEnter, isShiftPressed) {
|
|
36
|
+
if (shouldDetectNativeShiftEnter && data === "\r" && isShiftPressed)
|
|
37
|
+
return NATIVE_SHIFT_ENTER_SEQUENCE;
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
export function normalizeAppleTerminalInput(data, isAppleTerminal, isShiftPressed) {
|
|
41
|
+
return normalizeNativeShiftEnterInput(data, isAppleTerminal, isShiftPressed);
|
|
42
|
+
}
|
|
43
|
+
/** A long wall-clock gap while the event loop could not run is the portable
|
|
44
|
+
* signal Node exposes for laptop sleep/wake. */
|
|
45
|
+
export function isTerminalWakeGap(elapsedMs, thresholdMs = TERMINAL_WAKE_GAP_MS) {
|
|
46
|
+
return Number.isFinite(elapsedMs) && elapsedMs >= thresholdMs;
|
|
47
|
+
}
|
|
48
|
+
const DEFAULT_ESCAPE_TIMEOUT_MS = 10;
|
|
49
|
+
const DEFAULT_SSH_ESCAPE_TIMEOUT_MS = 100;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve how long to wait for the rest of an escape sequence before
|
|
52
|
+
* dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus
|
|
53
|
+
* another byte, so high-latency transports need a longer reassembly window.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveEscapeTimeoutMs(env = process.env) {
|
|
56
|
+
const configured = Number(env.PI_TUI_ESC_TIMEOUT);
|
|
57
|
+
if (Number.isFinite(configured) && configured > 0) {
|
|
58
|
+
return configured;
|
|
59
|
+
}
|
|
60
|
+
if (env.SSH_CONNECTION || env.SSH_TTY) {
|
|
61
|
+
return DEFAULT_SSH_ESCAPE_TIMEOUT_MS;
|
|
62
|
+
}
|
|
63
|
+
return DEFAULT_ESCAPE_TIMEOUT_MS;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Real terminal using process.stdin/stdout
|
|
67
|
+
*/
|
|
68
|
+
export class ProcessTerminal {
|
|
69
|
+
constructor() {
|
|
70
|
+
this.wasRaw = false;
|
|
71
|
+
this._kittyProtocolActive = false;
|
|
72
|
+
this._modifyOtherKeysActive = false;
|
|
73
|
+
this.keyboardProtocolPushed = false;
|
|
74
|
+
this.keyboardProtocolNegotiationBuffer = "";
|
|
75
|
+
this.lastWakeCheckAt = 0;
|
|
76
|
+
this.handleContinue = () => this.requestWakeRecovery();
|
|
77
|
+
this.writeLogPath = (() => {
|
|
78
|
+
const env = process.env.PI_TUI_WRITE_LOG || "";
|
|
79
|
+
if (!env)
|
|
80
|
+
return "";
|
|
81
|
+
try {
|
|
82
|
+
if (fs.statSync(env).isDirectory()) {
|
|
83
|
+
const now = new Date();
|
|
84
|
+
const ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}_${String(now.getHours()).padStart(2, "0")}-${String(now.getMinutes()).padStart(2, "0")}-${String(now.getSeconds()).padStart(2, "0")}`;
|
|
85
|
+
return path.join(env, `tui-${ts}-${process.pid}.log`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Not an existing directory - use as-is (file path)
|
|
90
|
+
}
|
|
91
|
+
return env;
|
|
92
|
+
})();
|
|
93
|
+
}
|
|
94
|
+
get kittyProtocolActive() {
|
|
95
|
+
return this._kittyProtocolActive;
|
|
96
|
+
}
|
|
97
|
+
get modifyOtherKeysActive() {
|
|
98
|
+
return this._modifyOtherKeysActive;
|
|
99
|
+
}
|
|
100
|
+
start(onInput, onResize, onResume) {
|
|
101
|
+
this.inputHandler = onInput;
|
|
102
|
+
this.resizeHandler = onResize;
|
|
103
|
+
this.resumeHandler = onResume;
|
|
104
|
+
// Save previous state and enable raw mode
|
|
105
|
+
this.wasRaw = process.stdin.isRaw || false;
|
|
106
|
+
if (process.stdin.setRawMode) {
|
|
107
|
+
process.stdin.setRawMode(true);
|
|
108
|
+
}
|
|
109
|
+
process.stdin.setEncoding("utf8");
|
|
110
|
+
process.stdin.resume();
|
|
111
|
+
// Enable bracketed paste mode - terminal will wrap pastes in \x1b[200~ ... \x1b[201~
|
|
112
|
+
process.stdout.write("\x1b[?2004h");
|
|
113
|
+
// Set up resize handler immediately
|
|
114
|
+
process.stdout.on("resize", this.resizeHandler);
|
|
115
|
+
// Refresh terminal dimensions - they may be stale after suspend/resume
|
|
116
|
+
// (SIGWINCH is lost while process is stopped). Unix only.
|
|
117
|
+
if (process.platform !== "win32") {
|
|
118
|
+
process.kill(process.pid, "SIGWINCH");
|
|
119
|
+
}
|
|
120
|
+
// On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends
|
|
121
|
+
// VT escape sequences (e.g. \x1b[Z for Shift+Tab) instead of raw console
|
|
122
|
+
// events that lose modifier information. Must run AFTER setRawMode(true)
|
|
123
|
+
// since that resets console mode flags.
|
|
124
|
+
this.enableWindowsVTInput();
|
|
125
|
+
// Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.
|
|
126
|
+
// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
|
127
|
+
this.queryAndEnableKittyProtocol();
|
|
128
|
+
this.startWakeRecovery();
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Reassert every terminal-side input contract after system wake. macOS may
|
|
132
|
+
* preserve tty raw flags while leaving Node stdin paused or Ghostty's
|
|
133
|
+
* private keyboard modes reset.
|
|
134
|
+
*/
|
|
135
|
+
recoverAfterWake() {
|
|
136
|
+
if (!this.inputHandler)
|
|
137
|
+
return;
|
|
138
|
+
if (process.stdin.setRawMode)
|
|
139
|
+
process.stdin.setRawMode(true);
|
|
140
|
+
process.stdin.setEncoding("utf8");
|
|
141
|
+
this.resetKeyboardInputPipeline();
|
|
142
|
+
process.stdin.resume();
|
|
143
|
+
process.stdout.write("\x1b[?2004h");
|
|
144
|
+
this.queryAndEnableKittyProtocol();
|
|
145
|
+
// Dimensions and the alternate-screen buffer can both be stale even when
|
|
146
|
+
// macOS did not deliver a SIGWINCH for the wake.
|
|
147
|
+
this.resizeHandler?.();
|
|
148
|
+
this.resumeHandler?.();
|
|
149
|
+
}
|
|
150
|
+
startWakeRecovery() {
|
|
151
|
+
this.stopWakeRecovery();
|
|
152
|
+
this.lastWakeCheckAt = Date.now();
|
|
153
|
+
this.lastWakeRecoveryAt = undefined;
|
|
154
|
+
this.wakeCheckInterval = setInterval(() => {
|
|
155
|
+
this.checkForWake();
|
|
156
|
+
}, TERMINAL_WAKE_CHECK_INTERVAL_MS);
|
|
157
|
+
this.wakeCheckInterval.unref?.();
|
|
158
|
+
if (process.platform !== "win32")
|
|
159
|
+
process.on("SIGCONT", this.handleContinue);
|
|
160
|
+
}
|
|
161
|
+
checkForWake(now = Date.now()) {
|
|
162
|
+
const elapsed = now - this.lastWakeCheckAt;
|
|
163
|
+
this.lastWakeCheckAt = now;
|
|
164
|
+
if (isTerminalWakeGap(elapsed))
|
|
165
|
+
this.requestWakeRecovery(now);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* SIGCONT and the overdue watchdog timer are commonly delivered together
|
|
169
|
+
* after a long process suspension. Collapse them into one atomic recovery so
|
|
170
|
+
* the freshly rebuilt stdin parser cannot be torn down a second time while
|
|
171
|
+
* the user is already typing or pasting.
|
|
172
|
+
*/
|
|
173
|
+
requestWakeRecovery(now = Date.now()) {
|
|
174
|
+
this.lastWakeCheckAt = now;
|
|
175
|
+
if (this.lastWakeRecoveryAt !== undefined) {
|
|
176
|
+
const elapsedSinceRecovery = now - this.lastWakeRecoveryAt;
|
|
177
|
+
if (elapsedSinceRecovery >= 0 && elapsedSinceRecovery < TERMINAL_WAKE_RECOVERY_COOLDOWN_MS) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
this.lastWakeRecoveryAt = now;
|
|
182
|
+
this.recoverAfterWake();
|
|
183
|
+
}
|
|
184
|
+
stopWakeRecovery() {
|
|
185
|
+
if (this.wakeCheckInterval) {
|
|
186
|
+
clearInterval(this.wakeCheckInterval);
|
|
187
|
+
this.wakeCheckInterval = undefined;
|
|
188
|
+
}
|
|
189
|
+
if (process.platform !== "win32")
|
|
190
|
+
process.removeListener("SIGCONT", this.handleContinue);
|
|
191
|
+
this.lastWakeRecoveryAt = undefined;
|
|
192
|
+
}
|
|
193
|
+
resetKeyboardInputPipeline() {
|
|
194
|
+
const shouldPopKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;
|
|
195
|
+
this.clearKeyboardProtocolNegotiationBuffer();
|
|
196
|
+
if (shouldPopKittyProtocol)
|
|
197
|
+
process.stdout.write("\x1b[<u");
|
|
198
|
+
this.keyboardProtocolPushed = false;
|
|
199
|
+
this._kittyProtocolActive = false;
|
|
200
|
+
setKittyProtocolActive(false);
|
|
201
|
+
this.disableModifyOtherKeys();
|
|
202
|
+
if (this.stdinBuffer) {
|
|
203
|
+
this.stdinBuffer.destroy();
|
|
204
|
+
this.stdinBuffer = undefined;
|
|
205
|
+
}
|
|
206
|
+
if (this.stdinDataHandler) {
|
|
207
|
+
process.stdin.removeListener("data", this.stdinDataHandler);
|
|
208
|
+
this.stdinDataHandler = undefined;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Set up StdinBuffer to split batched input into individual sequences.
|
|
213
|
+
* This ensures components receive single events, making matchesKey/isKeyRelease work correctly.
|
|
214
|
+
*
|
|
215
|
+
* Also watches for Kitty protocol response and enables it when detected.
|
|
216
|
+
* This is done here (after stdinBuffer parsing) rather than on raw stdin
|
|
217
|
+
* to handle the case where the response arrives split across multiple events.
|
|
218
|
+
*/
|
|
219
|
+
setupStdinBuffer() {
|
|
220
|
+
this.stdinBuffer = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });
|
|
221
|
+
// Forward individual sequences to the input handler
|
|
222
|
+
this.stdinBuffer.on("data", (sequence) => {
|
|
223
|
+
const negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence);
|
|
224
|
+
if (negotiationSequence === "pending") {
|
|
225
|
+
this.scheduleKeyboardProtocolNegotiationBufferFlush();
|
|
226
|
+
return; // Wait briefly for the rest of a split Kitty response.
|
|
227
|
+
}
|
|
228
|
+
if (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
this.forwardInputSequence(sequence);
|
|
232
|
+
});
|
|
233
|
+
// Re-wrap paste content with bracketed paste markers for existing editor handling
|
|
234
|
+
this.stdinBuffer.on("paste", (content) => {
|
|
235
|
+
if (this.inputHandler) {
|
|
236
|
+
this.inputHandler(`\x1b[200~${content}\x1b[201~`);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
// Handler that pipes stdin data through the buffer
|
|
240
|
+
this.stdinDataHandler = (data) => {
|
|
241
|
+
this.stdinBuffer.process(data);
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Query terminal for Kitty keyboard protocol support and enable it if available.
|
|
246
|
+
*
|
|
247
|
+
* Kitty's progressive enhancement detection requires requesting the desired
|
|
248
|
+
* flags before querying them. The trailing DA query is a sentinel supported by
|
|
249
|
+
* terminals that do not know Kitty keyboard protocol; receiving DA before a
|
|
250
|
+
* Kitty response enables modifyOtherKeys fallback without a startup timeout.
|
|
251
|
+
*
|
|
252
|
+
* The requested flags are:
|
|
253
|
+
* - 1 = disambiguate escape codes
|
|
254
|
+
* - 2 = report event types (press/repeat/release)
|
|
255
|
+
* - 4 = report alternate keys (shifted key, base layout key)
|
|
256
|
+
*/
|
|
257
|
+
queryAndEnableKittyProtocol() {
|
|
258
|
+
this.setupStdinBuffer();
|
|
259
|
+
process.stdin.on("data", this.stdinDataHandler);
|
|
260
|
+
this.keyboardProtocolPushed = true;
|
|
261
|
+
this.clearKeyboardProtocolNegotiationBuffer();
|
|
262
|
+
process.stdout.write(KITTY_KEYBOARD_PROTOCOL_QUERY);
|
|
263
|
+
}
|
|
264
|
+
handleKeyboardProtocolNegotiationSequence(negotiationSequence) {
|
|
265
|
+
if (!negotiationSequence)
|
|
266
|
+
return false;
|
|
267
|
+
this.clearKeyboardProtocolNegotiationBuffer();
|
|
268
|
+
if (negotiationSequence.type === "kitty-flags") {
|
|
269
|
+
if (negotiationSequence.flags !== 0) {
|
|
270
|
+
this.disableModifyOtherKeys();
|
|
271
|
+
if (!this._kittyProtocolActive) {
|
|
272
|
+
this._kittyProtocolActive = true;
|
|
273
|
+
setKittyProtocolActive(true);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.enableModifyOtherKeys();
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
if (!this._kittyProtocolActive) {
|
|
282
|
+
this.enableModifyOtherKeys();
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
readKeyboardProtocolNegotiationSequence(sequence) {
|
|
287
|
+
if (this.keyboardProtocolNegotiationBuffer) {
|
|
288
|
+
const bufferedSequence = this.keyboardProtocolNegotiationBuffer + sequence;
|
|
289
|
+
const negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);
|
|
290
|
+
if (negotiationSequence) {
|
|
291
|
+
this.clearKeyboardProtocolNegotiationBuffer();
|
|
292
|
+
return negotiationSequence;
|
|
293
|
+
}
|
|
294
|
+
if (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {
|
|
295
|
+
this.setKeyboardProtocolNegotiationBuffer(bufferedSequence);
|
|
296
|
+
return "pending";
|
|
297
|
+
}
|
|
298
|
+
this.flushKeyboardProtocolNegotiationBufferAsInput();
|
|
299
|
+
}
|
|
300
|
+
const negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);
|
|
301
|
+
if (negotiationSequence)
|
|
302
|
+
return negotiationSequence;
|
|
303
|
+
if (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {
|
|
304
|
+
this.setKeyboardProtocolNegotiationBuffer(sequence);
|
|
305
|
+
return "pending";
|
|
306
|
+
}
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
setKeyboardProtocolNegotiationBuffer(sequence) {
|
|
310
|
+
this.clearKeyboardProtocolNegotiationBufferFlushTimer();
|
|
311
|
+
this.keyboardProtocolNegotiationBuffer = sequence;
|
|
312
|
+
}
|
|
313
|
+
clearKeyboardProtocolNegotiationBuffer() {
|
|
314
|
+
this.clearKeyboardProtocolNegotiationBufferFlushTimer();
|
|
315
|
+
this.keyboardProtocolNegotiationBuffer = "";
|
|
316
|
+
}
|
|
317
|
+
flushKeyboardProtocolNegotiationBufferAsInput() {
|
|
318
|
+
if (!this.keyboardProtocolNegotiationBuffer)
|
|
319
|
+
return;
|
|
320
|
+
const sequence = this.keyboardProtocolNegotiationBuffer;
|
|
321
|
+
this.clearKeyboardProtocolNegotiationBuffer();
|
|
322
|
+
this.forwardInputSequence(sequence);
|
|
323
|
+
}
|
|
324
|
+
scheduleKeyboardProtocolNegotiationBufferFlush() {
|
|
325
|
+
if (!this.keyboardProtocolNegotiationBuffer || this.keyboardProtocolBufferFlushTimer)
|
|
326
|
+
return;
|
|
327
|
+
this.keyboardProtocolBufferFlushTimer = setTimeout(() => {
|
|
328
|
+
this.keyboardProtocolBufferFlushTimer = undefined;
|
|
329
|
+
this.flushKeyboardProtocolNegotiationBufferAsInput();
|
|
330
|
+
}, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);
|
|
331
|
+
}
|
|
332
|
+
clearKeyboardProtocolNegotiationBufferFlushTimer() {
|
|
333
|
+
if (!this.keyboardProtocolBufferFlushTimer)
|
|
334
|
+
return;
|
|
335
|
+
clearTimeout(this.keyboardProtocolBufferFlushTimer);
|
|
336
|
+
this.keyboardProtocolBufferFlushTimer = undefined;
|
|
337
|
+
}
|
|
338
|
+
forwardInputSequence(sequence) {
|
|
339
|
+
if (!this.inputHandler)
|
|
340
|
+
return;
|
|
341
|
+
const shouldDetectNativeShiftEnter = sequence === "\r" && (isAppleTerminalSession() || process.platform === "win32");
|
|
342
|
+
const input = normalizeNativeShiftEnterInput(sequence, shouldDetectNativeShiftEnter, shouldDetectNativeShiftEnter && isNativeModifierPressed("shift"));
|
|
343
|
+
this.inputHandler(input);
|
|
344
|
+
}
|
|
345
|
+
enableModifyOtherKeys() {
|
|
346
|
+
if (this._kittyProtocolActive || this._modifyOtherKeysActive)
|
|
347
|
+
return;
|
|
348
|
+
process.stdout.write("\x1b[>4;2m");
|
|
349
|
+
this._modifyOtherKeysActive = true;
|
|
350
|
+
}
|
|
351
|
+
disableModifyOtherKeys() {
|
|
352
|
+
if (!this._modifyOtherKeysActive)
|
|
353
|
+
return;
|
|
354
|
+
process.stdout.write("\x1b[>4;0m");
|
|
355
|
+
this._modifyOtherKeysActive = false;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin
|
|
359
|
+
* console handle so the terminal sends VT sequences for modified keys
|
|
360
|
+
* (e.g. \x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW
|
|
361
|
+
* discards modifier state and Shift+Tab arrives as plain \t.
|
|
362
|
+
*/
|
|
363
|
+
enableWindowsVTInput() {
|
|
364
|
+
if (process.platform !== "win32")
|
|
365
|
+
return;
|
|
366
|
+
try {
|
|
367
|
+
const arch = process.arch;
|
|
368
|
+
if (arch !== "x64" && arch !== "arm64")
|
|
369
|
+
return;
|
|
370
|
+
// Dynamic require so non-Windows and bundled/browser paths never load the
|
|
371
|
+
// native helper. In the npm package native/ is next to dist/; in compiled
|
|
372
|
+
// binary archives native/ is copied next to the executable.
|
|
373
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
374
|
+
const nativePath = path.join("native", "win32", "prebuilds", `win32-${arch}`, "win32-console-mode.node");
|
|
375
|
+
const candidates = [
|
|
376
|
+
path.join(moduleDir, "..", nativePath),
|
|
377
|
+
path.join(moduleDir, nativePath),
|
|
378
|
+
path.join(path.dirname(process.execPath), nativePath),
|
|
379
|
+
];
|
|
380
|
+
for (const modulePath of candidates) {
|
|
381
|
+
try {
|
|
382
|
+
const helper = cjsRequire(modulePath);
|
|
383
|
+
helper.enableVirtualTerminalInput?.();
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
catch {
|
|
387
|
+
// Try the next possible packaging location.
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
// Native helper not available — Shift+Tab won't be distinguishable from Tab.
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
async drainInput(maxMs = 1000, idleMs = 50) {
|
|
396
|
+
const shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;
|
|
397
|
+
this.clearKeyboardProtocolNegotiationBuffer();
|
|
398
|
+
if (shouldDisableKittyProtocol) {
|
|
399
|
+
// Disable Kitty keyboard protocol first so any late key releases
|
|
400
|
+
// do not generate new Kitty escape sequences.
|
|
401
|
+
process.stdout.write("\x1b[<u");
|
|
402
|
+
this.keyboardProtocolPushed = false;
|
|
403
|
+
this._kittyProtocolActive = false;
|
|
404
|
+
setKittyProtocolActive(false);
|
|
405
|
+
}
|
|
406
|
+
this.disableModifyOtherKeys();
|
|
407
|
+
const previousHandler = this.inputHandler;
|
|
408
|
+
this.inputHandler = undefined;
|
|
409
|
+
let lastDataTime = Date.now();
|
|
410
|
+
const onData = () => {
|
|
411
|
+
lastDataTime = Date.now();
|
|
412
|
+
};
|
|
413
|
+
process.stdin.on("data", onData);
|
|
414
|
+
const endTime = Date.now() + maxMs;
|
|
415
|
+
try {
|
|
416
|
+
while (true) {
|
|
417
|
+
const now = Date.now();
|
|
418
|
+
const timeLeft = endTime - now;
|
|
419
|
+
if (timeLeft <= 0)
|
|
420
|
+
break;
|
|
421
|
+
if (now - lastDataTime >= idleMs)
|
|
422
|
+
break;
|
|
423
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
finally {
|
|
427
|
+
process.stdin.removeListener("data", onData);
|
|
428
|
+
this.inputHandler = previousHandler;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
stop() {
|
|
432
|
+
this.stopWakeRecovery();
|
|
433
|
+
if (this.clearProgressInterval()) {
|
|
434
|
+
process.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);
|
|
435
|
+
}
|
|
436
|
+
// Disable bracketed paste mode
|
|
437
|
+
process.stdout.write("\x1b[?2004l");
|
|
438
|
+
const shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;
|
|
439
|
+
this.clearKeyboardProtocolNegotiationBuffer();
|
|
440
|
+
// Disable Kitty keyboard protocol if not already done by drainInput()
|
|
441
|
+
if (shouldDisableKittyProtocol) {
|
|
442
|
+
process.stdout.write("\x1b[<u");
|
|
443
|
+
this.keyboardProtocolPushed = false;
|
|
444
|
+
this._kittyProtocolActive = false;
|
|
445
|
+
setKittyProtocolActive(false);
|
|
446
|
+
}
|
|
447
|
+
this.disableModifyOtherKeys();
|
|
448
|
+
// Clean up StdinBuffer
|
|
449
|
+
if (this.stdinBuffer) {
|
|
450
|
+
this.stdinBuffer.destroy();
|
|
451
|
+
this.stdinBuffer = undefined;
|
|
452
|
+
}
|
|
453
|
+
// Remove event handlers
|
|
454
|
+
if (this.stdinDataHandler) {
|
|
455
|
+
process.stdin.removeListener("data", this.stdinDataHandler);
|
|
456
|
+
this.stdinDataHandler = undefined;
|
|
457
|
+
}
|
|
458
|
+
this.inputHandler = undefined;
|
|
459
|
+
if (this.resizeHandler) {
|
|
460
|
+
process.stdout.removeListener("resize", this.resizeHandler);
|
|
461
|
+
this.resizeHandler = undefined;
|
|
462
|
+
}
|
|
463
|
+
this.resumeHandler = undefined;
|
|
464
|
+
// Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being
|
|
465
|
+
// re-interpreted after raw mode is disabled. This fixes a race condition
|
|
466
|
+
// where Ctrl+D could close the parent shell over SSH.
|
|
467
|
+
process.stdin.pause();
|
|
468
|
+
// Restore raw mode state
|
|
469
|
+
if (process.stdin.setRawMode) {
|
|
470
|
+
process.stdin.setRawMode(this.wasRaw);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
write(data) {
|
|
474
|
+
process.stdout.write(data);
|
|
475
|
+
if (this.writeLogPath) {
|
|
476
|
+
try {
|
|
477
|
+
fs.appendFileSync(this.writeLogPath, data, { encoding: "utf8" });
|
|
478
|
+
}
|
|
479
|
+
catch {
|
|
480
|
+
// Ignore logging errors
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
get columns() {
|
|
485
|
+
return process.stdout.columns || Number(process.env.COLUMNS) || 80;
|
|
486
|
+
}
|
|
487
|
+
get rows() {
|
|
488
|
+
return process.stdout.rows || Number(process.env.LINES) || 24;
|
|
489
|
+
}
|
|
490
|
+
moveBy(lines) {
|
|
491
|
+
if (lines > 0) {
|
|
492
|
+
// Move down
|
|
493
|
+
process.stdout.write(`\x1b[${lines}B`);
|
|
494
|
+
}
|
|
495
|
+
else if (lines < 0) {
|
|
496
|
+
// Move up
|
|
497
|
+
process.stdout.write(`\x1b[${-lines}A`);
|
|
498
|
+
}
|
|
499
|
+
// lines === 0: no movement
|
|
500
|
+
}
|
|
501
|
+
hideCursor() {
|
|
502
|
+
process.stdout.write("\x1b[?25l");
|
|
503
|
+
}
|
|
504
|
+
showCursor() {
|
|
505
|
+
process.stdout.write("\x1b[?25h");
|
|
506
|
+
}
|
|
507
|
+
clearLine() {
|
|
508
|
+
process.stdout.write("\x1b[K");
|
|
509
|
+
}
|
|
510
|
+
clearFromCursor() {
|
|
511
|
+
process.stdout.write("\x1b[J");
|
|
512
|
+
}
|
|
513
|
+
clearScreen() {
|
|
514
|
+
process.stdout.write("\x1b[2J\x1b[H"); // Clear screen and move to home (1,1)
|
|
515
|
+
}
|
|
516
|
+
setTitle(title) {
|
|
517
|
+
// OSC 0;title BEL - set terminal window title
|
|
518
|
+
process.stdout.write(`\x1b]0;${title}\x07`);
|
|
519
|
+
}
|
|
520
|
+
setProgress(active) {
|
|
521
|
+
if (active) {
|
|
522
|
+
// OSC 9;4;3 - indeterminate progress
|
|
523
|
+
process.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);
|
|
524
|
+
if (!this.progressInterval) {
|
|
525
|
+
this.progressInterval = setInterval(() => {
|
|
526
|
+
process.stdout.write(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);
|
|
527
|
+
}, TERMINAL_PROGRESS_KEEPALIVE_MS);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
this.clearProgressInterval();
|
|
532
|
+
// OSC 9;4;0 - clear progress
|
|
533
|
+
process.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
clearProgressInterval() {
|
|
537
|
+
if (!this.progressInterval)
|
|
538
|
+
return false;
|
|
539
|
+
clearInterval(this.progressInterval);
|
|
540
|
+
this.progressInterval = undefined;
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
//# sourceMappingURL=terminal.js.map
|