@linxiraos/pi-tui 1.4.6 → 1.4.9
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/CHANGELOG.md +162 -244
- package/README.md +41 -35
- package/dist/types/app-keybindings.d.ts +20 -0
- package/dist/types/apps/session-picker.d.ts +5 -0
- package/dist/types/charts/chart-plan.d.ts +9 -7
- package/dist/types/charts/table-data.d.ts +4 -2
- package/dist/types/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +6 -1
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/eval-execution.d.ts +2 -0
- package/dist/types/chat/execution-shared.d.ts +14 -8
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/figure-markdown.d.ts +2 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/svg-figure.d.ts +5 -0
- package/dist/types/chat/table-chart.d.ts +6 -3
- package/dist/types/chat/tool-execution.d.ts +1 -2
- package/dist/types/chat/transcript-outline.d.ts +7 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +13 -3
- package/dist/types/chrome/dynamic-border.d.ts +6 -0
- package/dist/types/chrome/index.d.ts +1 -0
- package/dist/types/chrome/transcript-notice.d.ts +35 -0
- package/dist/types/chrome/transcript-status.d.ts +21 -9
- package/dist/types/components/editor.d.ts +23 -6
- package/dist/types/components/image.d.ts +6 -0
- package/dist/types/components/loader.d.ts +2 -0
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/keybinding-matchers.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +2 -1
- package/dist/types/native/describe.d.ts +4 -2
- package/dist/types/native/node.d.ts +2 -3
- package/dist/types/native/overlay.d.ts +42 -2
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/btw-history-panel.d.ts +15 -0
- package/dist/types/overlays/btw-history.d.ts +24 -0
- package/dist/types/overlays/btw-inject.d.ts +22 -0
- package/dist/types/overlays/btw-panel.d.ts +7 -0
- package/dist/types/overlays/hook-editor.d.ts +2 -0
- package/dist/types/overlays/jobs-panel.d.ts +4 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/model-browser.d.ts +11 -2
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
- package/dist/types/overlays/rewind-selector.d.ts +1 -1
- package/dist/types/overlays/session-selector.d.ts +33 -4
- package/dist/types/prompt/composer.d.ts +56 -5
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +25 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/render-utils.d.ts +23 -1
- package/dist/types/setup/scenes/glyph.d.ts +1 -1
- package/dist/types/setup/scenes/model.d.ts +1 -1
- package/dist/types/setup/scenes/outro.d.ts +5 -4
- package/dist/types/setup/scenes/sign-in.d.ts +13 -8
- package/dist/types/setup/scenes/types.d.ts +16 -1
- package/dist/types/setup/startup-splash.d.ts +1 -1
- package/dist/types/setup/wizard-overlay.d.ts +11 -7
- package/dist/types/setup/wizard.d.ts +5 -1
- package/dist/types/status-line/component.d.ts +1 -1
- package/dist/types/status-line/context-usage.d.ts +28 -6
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/status-line/startup.d.ts +0 -15
- package/dist/types/terminal-capabilities.d.ts +1 -1
- package/dist/types/theme/symbols.d.ts +3 -1
- package/dist/types/theme/theme-class.d.ts +1 -0
- package/dist/types/theme/theme.d.ts +1 -24
- package/dist/types/theme/tui-adapters.d.ts +2 -0
- package/dist/types/thinking.d.ts +8 -6
- package/dist/types/tools/ast-grep.d.ts +2 -0
- package/dist/types/tools/bash-interactive.d.ts +6 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +6 -4
- package/dist/types/tools/eval.d.ts +2 -0
- package/dist/types/tools/find.d.ts +1 -1
- package/dist/types/tools/grouped-file-output.d.ts +100 -19
- package/dist/types/tools/hashline-format.d.ts +5 -0
- package/dist/types/tools/irc.d.ts +6 -0
- package/dist/types/tools/json-tree.d.ts +23 -4
- package/dist/types/tools/lsp.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +6 -5
- package/dist/types/tools/native-view.d.ts +3 -1
- package/dist/types/tools/output-meta.d.ts +27 -0
- package/dist/types/tools/read.d.ts +14 -4
- package/dist/types/tools/renderer.d.ts +2 -0
- package/dist/types/tools/streaming-output.d.ts +11 -0
- package/dist/types/tools/task.d.ts +13 -4
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/wait.d.ts +2 -0
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +19 -2
- package/dist/types/utils.d.ts +4 -0
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +20 -0
- package/src/app-keybindings.ts +20 -0
- package/src/apps/git/git-tui.ts +10 -17
- package/src/apps/git/sidebar.ts +21 -35
- package/src/apps/ps-top.ts +4 -12
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -79
- package/src/charts/table-data.d.ts +4 -2
- package/src/charts/table-data.ts +55 -6
- package/src/chat/advisor-message.ts +2 -0
- package/src/chat/assistant-message.d.ts +15 -3
- package/src/chat/assistant-message.ts +137 -19
- package/src/chat/background-tan-message.ts +4 -0
- package/src/chat/bash-execution.d.ts +6 -1
- package/src/chat/bash-execution.ts +26 -9
- package/src/chat/chat-transcript-builder.ts +63 -30
- package/src/chat/compaction-summary-message.ts +2 -1
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/eval-execution.d.ts +2 -0
- package/src/chat/eval-execution.ts +14 -7
- package/src/chat/execution-shared.d.ts +14 -8
- package/src/chat/execution-shared.ts +39 -18
- package/src/chat/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/figure-markdown.d.ts +2 -0
- package/src/chat/figure-markdown.ts +6 -4
- package/src/chat/read-tool-group.ts +56 -36
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/svg-figure.d.ts +5 -0
- package/src/chat/svg-figure.ts +55 -16
- package/src/chat/table-chart.d.ts +6 -3
- package/src/chat/table-chart.ts +29 -6
- package/src/chat/tool-execution.d.ts +1 -2
- package/src/chat/tool-execution.ts +20 -13
- package/src/chat/transcript-outline.d.ts +7 -0
- package/src/chat/transcript-outline.ts +27 -0
- package/src/chat/transcript-render-helpers.d.ts +13 -3
- package/src/chat/transcript-render-helpers.ts +134 -44
- package/src/chrome/dynamic-border.d.ts +6 -0
- package/src/chrome/dynamic-border.ts +28 -2
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +21 -9
- package/src/chrome/transcript-status.ts +32 -30
- package/src/components/editor.d.ts +23 -6
- package/src/components/editor.ts +133 -25
- package/src/components/image.d.ts +6 -0
- package/src/components/image.ts +13 -0
- package/src/components/key-value-list.ts +9 -9
- package/src/components/loader.d.ts +2 -0
- package/src/components/loader.ts +7 -0
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +116 -6
- package/src/components/section.ts +1 -9
- package/src/components/table.ts +1 -9
- package/src/hotkeys-markdown.ts +1 -0
- package/src/keybinding-matchers.d.ts +7 -0
- package/src/keybinding-matchers.ts +13 -0
- package/src/native/backend.ts +10 -67
- package/src/native/blobs.d.ts +2 -1
- package/src/native/blobs.ts +3 -2
- package/src/native/describe.d.ts +4 -2
- package/src/native/describe.ts +9 -4
- package/src/native/node.d.ts +2 -3
- package/src/native/node.ts +2 -3
- package/src/native/overlay.d.ts +42 -2
- package/src/native/overlay.ts +124 -16
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +25 -5
- package/src/overlays/advisor-config.ts +1 -10
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/btw-history-panel.ts +106 -14
- package/src/overlays/btw-history.ts +65 -0
- package/src/overlays/btw-inject.ts +91 -0
- package/src/overlays/btw-panel.ts +53 -12
- package/src/overlays/extensions/extension-dashboard.ts +7 -8
- package/src/overlays/hook-editor.ts +6 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/jobs-panel.ts +82 -22
- package/src/overlays/login-dialog.ts +39 -31
- package/src/overlays/mcp-add-wizard.ts +1 -1
- package/src/overlays/model-browser.ts +106 -10
- package/src/overlays/model-hub.ts +1 -7
- package/src/overlays/model-picker.ts +1 -10
- package/src/overlays/oauth-selector.ts +44 -6
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/session-selector.ts +338 -47
- package/src/overlays/settings-defs.ts +2 -2
- package/src/overlays/tree-selector.ts +83 -27
- package/src/overlays/usage-dashboard.ts +9 -18
- package/src/prompt/composer.ts +233 -6
- package/src/prompt/custom-editor.ts +6 -1
- package/src/prompt/emoji-autocomplete.ts +0 -2
- package/src/prompt/interactive-context-helpers.ts +29 -4
- package/src/render/code-cell.ts +1 -1
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/file-list.ts +4 -7
- package/src/render/hyperlink.d.ts +25 -7
- package/src/render/hyperlink.ts +65 -9
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/render-utils.d.ts +23 -1
- package/src/render/render-utils.ts +38 -6
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +4 -2
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +196 -400
- package/src/setup/scenes/theme.ts +2 -0
- package/src/setup/scenes/types.ts +18 -1
- package/src/setup/startup-splash.ts +8 -7
- package/src/setup/wizard-overlay.ts +164 -35
- package/src/setup/wizard.ts +11 -2
- package/src/status-line/component.ts +4 -10
- package/src/status-line/context-usage.ts +72 -21
- package/src/status-line/host.ts +6 -2
- package/src/status-line/startup.ts +36 -70
- package/src/terminal-capabilities.d.ts +1 -1
- package/src/terminal-capabilities.ts +5 -0
- package/src/terminal.ts +24 -2
- package/src/theme/defaults.json +1 -0
- package/src/theme/loader.ts +1 -1
- package/src/theme/symbols.d.ts +3 -1
- package/src/theme/symbols.ts +16 -9
- package/src/theme/theme-class.d.ts +1 -0
- package/src/theme/theme-class.ts +15 -3
- package/src/theme/theme.d.ts +1 -24
- package/src/theme/theme.ts +3 -75
- package/src/theme/tui-adapters.d.ts +2 -0
- package/src/theme/tui-adapters.ts +8 -3
- package/src/thinking.d.ts +8 -6
- package/src/thinking.ts +17 -11
- package/src/tmux.ts +1 -0
- package/src/tools/agent-tree.ts +13 -11
- package/src/tools/ask.ts +24 -37
- package/src/tools/ast-edit.ts +48 -93
- package/src/tools/ast-grep.d.ts +2 -0
- package/src/tools/ast-grep.ts +31 -67
- package/src/tools/bash-interactive.d.ts +49 -0
- package/src/tools/bash-interactive.ts +6 -1
- package/src/tools/bash.d.ts +2 -0
- package/src/tools/bash.ts +9 -0
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +10 -7
- package/src/tools/edit.ts +50 -43
- package/src/tools/eval.d.ts +2 -0
- package/src/tools/eval.ts +16 -4
- package/src/tools/fetch.ts +2 -1
- package/src/tools/find.d.ts +1 -1
- package/src/tools/find.ts +13 -5
- package/src/tools/github.ts +14 -46
- package/src/tools/glob.ts +2 -1
- package/src/tools/grep.ts +47 -277
- package/src/tools/grouped-file-output.d.ts +100 -19
- package/src/tools/grouped-file-output.ts +414 -103
- package/src/tools/hashline-format.d.ts +5 -0
- package/src/tools/hashline-format.ts +5 -0
- package/src/tools/irc.d.ts +6 -0
- package/src/tools/irc.ts +6 -0
- package/src/tools/job-widget.ts +13 -1
- package/src/tools/json-tree.d.ts +23 -4
- package/src/tools/json-tree.ts +132 -46
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +246 -47
- package/src/tools/mcp.d.ts +6 -5
- package/src/tools/mcp.ts +20 -12
- package/src/tools/native-view.d.ts +3 -1
- package/src/tools/native-view.ts +12 -6
- package/src/tools/output-meta.d.ts +27 -0
- package/src/tools/output-meta.ts +68 -4
- package/src/tools/proc-render.ts +3 -3
- package/src/tools/read.d.ts +14 -4
- package/src/tools/read.ts +20 -5
- package/src/tools/renderer.d.ts +2 -0
- package/src/tools/renderer.ts +2 -0
- package/src/tools/streaming-output.d.ts +11 -0
- package/src/tools/streaming-output.ts +41 -0
- package/src/tools/task.d.ts +13 -4
- package/src/tools/task.ts +100 -97
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/vibe.ts +4 -4
- package/src/tools/wait.d.ts +2 -0
- package/src/tools/wait.ts +8 -5
- package/src/tools/write.ts +17 -27
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +19 -10
- package/src/tui.d.ts +19 -2
- package/src/tui.ts +134 -24
- package/src/utils.d.ts +4 -0
- package/src/utils.ts +10 -0
- package/dist/types/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/alabaster.json +0 -103
- package/src/theme/defaults/amethyst.json +0 -106
- package/src/theme/defaults/anthracite.json +0 -103
- package/src/theme/defaults/basalt.json +0 -101
- package/src/theme/defaults/birch.json +0 -105
- package/src/theme/defaults/dark-abyss.json +0 -101
- package/src/theme/defaults/dark-arctic.json +0 -114
- package/src/theme/defaults/dark-aurora.json +0 -105
- package/src/theme/defaults/dark-catppuccin.json +0 -117
- package/src/theme/defaults/dark-cavern.json +0 -101
- package/src/theme/defaults/dark-celestial.json +0 -116
- package/src/theme/defaults/dark-copper.json +0 -105
- package/src/theme/defaults/dark-cosmos.json +0 -100
- package/src/theme/defaults/dark-cyberpunk.json +0 -112
- package/src/theme/defaults/dark-dracula.json +0 -108
- package/src/theme/defaults/dark-eclipse.json +0 -101
- package/src/theme/defaults/dark-ember.json +0 -105
- package/src/theme/defaults/dark-equinox.json +0 -100
- package/src/theme/defaults/dark-forest.json +0 -106
- package/src/theme/defaults/dark-github.json +0 -115
- package/src/theme/defaults/dark-gruvbox.json +0 -122
- package/src/theme/defaults/dark-lavender.json +0 -105
- package/src/theme/defaults/dark-lunar.json +0 -99
- package/src/theme/defaults/dark-midnight.json +0 -105
- package/src/theme/defaults/dark-monochrome.json +0 -104
- package/src/theme/defaults/dark-monokai.json +0 -108
- package/src/theme/defaults/dark-nebula.json +0 -100
- package/src/theme/defaults/dark-neon-noir.json +0 -110
- package/src/theme/defaults/dark-nord.json +0 -108
- package/src/theme/defaults/dark-ocean.json +0 -111
- package/src/theme/defaults/dark-one.json +0 -110
- package/src/theme/defaults/dark-poimandres.json +0 -125
- package/src/theme/defaults/dark-rainforest.json +0 -101
- package/src/theme/defaults/dark-reef.json +0 -101
- package/src/theme/defaults/dark-retro.json +0 -102
- package/src/theme/defaults/dark-rose-pine.json +0 -106
- package/src/theme/defaults/dark-sakura.json +0 -105
- package/src/theme/defaults/dark-slate.json +0 -105
- package/src/theme/defaults/dark-solarized.json +0 -107
- package/src/theme/defaults/dark-solstice.json +0 -100
- package/src/theme/defaults/dark-starfall.json +0 -101
- package/src/theme/defaults/dark-sunset.json +0 -109
- package/src/theme/defaults/dark-swamp.json +0 -100
- package/src/theme/defaults/dark-synthwave.json +0 -113
- package/src/theme/defaults/dark-taiga.json +0 -101
- package/src/theme/defaults/dark-terminal.json +0 -105
- package/src/theme/defaults/dark-tokyo-night.json +0 -111
- package/src/theme/defaults/dark-tundra.json +0 -101
- package/src/theme/defaults/dark-twilight.json +0 -101
- package/src/theme/defaults/dark-volcanic.json +0 -101
- package/src/theme/defaults/graphite.json +0 -102
- package/src/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/index.ts +0 -203
- package/src/theme/defaults/light-arctic.json +0 -117
- package/src/theme/defaults/light-aurora-day.json +0 -101
- package/src/theme/defaults/light-canyon.json +0 -101
- package/src/theme/defaults/light-catppuccin.json +0 -116
- package/src/theme/defaults/light-cirrus.json +0 -100
- package/src/theme/defaults/light-coral.json +0 -105
- package/src/theme/defaults/light-cyberpunk.json +0 -106
- package/src/theme/defaults/light-dawn.json +0 -100
- package/src/theme/defaults/light-dunes.json +0 -101
- package/src/theme/defaults/light-eucalyptus.json +0 -105
- package/src/theme/defaults/light-forest.json +0 -110
- package/src/theme/defaults/light-frost.json +0 -105
- package/src/theme/defaults/light-github.json +0 -125
- package/src/theme/defaults/light-glacier.json +0 -101
- package/src/theme/defaults/light-gruvbox.json +0 -118
- package/src/theme/defaults/light-haze.json +0 -100
- package/src/theme/defaults/light-honeycomb.json +0 -105
- package/src/theme/defaults/light-lagoon.json +0 -101
- package/src/theme/defaults/light-lavender.json +0 -105
- package/src/theme/defaults/light-meadow.json +0 -101
- package/src/theme/defaults/light-mint.json +0 -105
- package/src/theme/defaults/light-monochrome.json +0 -111
- package/src/theme/defaults/light-ocean.json +0 -109
- package/src/theme/defaults/light-one.json +0 -109
- package/src/theme/defaults/light-opal.json +0 -101
- package/src/theme/defaults/light-orchard.json +0 -101
- package/src/theme/defaults/light-paper.json +0 -105
- package/src/theme/defaults/light-poimandres.json +0 -125
- package/src/theme/defaults/light-prism.json +0 -100
- package/src/theme/defaults/light-retro.json +0 -108
- package/src/theme/defaults/light-sand.json +0 -105
- package/src/theme/defaults/light-savanna.json +0 -101
- package/src/theme/defaults/light-solarized.json +0 -112
- package/src/theme/defaults/light-soleil.json +0 -100
- package/src/theme/defaults/light-sunset.json +0 -109
- package/src/theme/defaults/light-synthwave.json +0 -108
- package/src/theme/defaults/light-tokyo-night.json +0 -121
- package/src/theme/defaults/light-wetland.json +0 -101
- package/src/theme/defaults/light-zenith.json +0 -99
- package/src/theme/defaults/limestone.json +0 -104
- package/src/theme/defaults/mahogany.json +0 -107
- package/src/theme/defaults/marble.json +0 -103
- package/src/theme/defaults/obsidian.json +0 -101
- package/src/theme/defaults/onyx.json +0 -101
- package/src/theme/defaults/pearl.json +0 -103
- package/src/theme/defaults/porcelain.json +0 -101
- package/src/theme/defaults/quartz.json +0 -106
- package/src/theme/defaults/sandstone.json +0 -105
- package/src/theme/defaults/titanium.json +0 -100
|
@@ -3,7 +3,7 @@ import type { CompactionSettings } from "@linxiraos/pi-agent-core/compaction";
|
|
|
3
3
|
import { effectiveReserveTokens, resolveThresholdTokens } from "@linxiraos/pi-agent-core/compaction";
|
|
4
4
|
import type { Tool as AiTool, Model } from "@linxiraos/pi-ai";
|
|
5
5
|
import { renderToolExamples } from "@linxiraos/pi-ai/dialect";
|
|
6
|
-
import { toolWireSchema } from "@linxiraos/pi-ai/utils/schema";
|
|
6
|
+
import { stripSchemaDescriptions, toolWireSchema } from "@linxiraos/pi-ai/utils/schema";
|
|
7
7
|
|
|
8
8
|
interface ContextSkill {
|
|
9
9
|
readonly name: string;
|
|
@@ -128,6 +128,11 @@ export interface NonMessageTokenSource {
|
|
|
128
128
|
readonly state?: {
|
|
129
129
|
readonly tools?: readonly ContextTool[];
|
|
130
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* Whether requests to `model` ship description-stripped tool specs because
|
|
133
|
+
* the catalog rides in the system prompt (`Agent.prunesToolDescriptions`).
|
|
134
|
+
*/
|
|
135
|
+
prunesToolDescriptions?(model: Model | undefined): boolean;
|
|
131
136
|
};
|
|
132
137
|
readonly skills?: readonly ContextSkill[];
|
|
133
138
|
/** Provider-facing, session-frozen descriptions when available. */
|
|
@@ -166,7 +171,10 @@ type ToolSchemaSource = readonly ContextTool[];
|
|
|
166
171
|
|
|
167
172
|
interface ToolSchemaTokenCache {
|
|
168
173
|
revision: number;
|
|
169
|
-
byTokenizer: WeakMap<
|
|
174
|
+
byTokenizer: WeakMap<
|
|
175
|
+
Tokenizer,
|
|
176
|
+
{ revision: number; sourceRevision: number; pruneDescriptions: boolean; tokens: number }
|
|
177
|
+
>;
|
|
170
178
|
}
|
|
171
179
|
|
|
172
180
|
/**
|
|
@@ -216,12 +224,24 @@ export interface ToolSchemaFragments {
|
|
|
216
224
|
readonly schemaError?: string;
|
|
217
225
|
}
|
|
218
226
|
|
|
227
|
+
/** How {@link toolSchemaFragments} renders one tool definition. */
|
|
228
|
+
export interface ToolSchemaFragmentOptions {
|
|
229
|
+
/** Also return `display`: the same fragments with the schema JSON indented by this many spaces. */
|
|
230
|
+
displayIndent?: number;
|
|
231
|
+
/**
|
|
232
|
+
* Mirror `normalizeTools({ pruneDescriptions: true })`: the wire spec is the
|
|
233
|
+
* name plus the description-stripped schema, with no description or examples.
|
|
234
|
+
*/
|
|
235
|
+
pruneDescriptions?: boolean;
|
|
236
|
+
}
|
|
237
|
+
|
|
219
238
|
/**
|
|
220
239
|
* Provider-visible text of one tool definition. `displayIndent` additionally
|
|
221
240
|
* returns `display`, the same fragments with the schema JSON indented, from
|
|
222
241
|
* the same schema conversion.
|
|
223
242
|
*/
|
|
224
|
-
export function toolSchemaFragments(tool: ContextTool,
|
|
243
|
+
export function toolSchemaFragments(tool: ContextTool, options: ToolSchemaFragmentOptions = {}): ToolSchemaFragments {
|
|
244
|
+
const { displayIndent, pruneDescriptions = false } = options;
|
|
225
245
|
// Extension-supplied tools may carry a non-string name/description or a
|
|
226
246
|
// parameters value whose wire schema stringifies to `undefined` (e.g. a
|
|
227
247
|
// callable schema that escaped normalization). A non-string fragment is
|
|
@@ -234,7 +254,7 @@ export function toolSchemaFragments(tool: ContextTool, displayIndent?: number):
|
|
|
234
254
|
display?.push(shown);
|
|
235
255
|
};
|
|
236
256
|
if (typeof name === "string") push(name);
|
|
237
|
-
if (typeof description === "string") push(description);
|
|
257
|
+
if (!pruneDescriptions && typeof description === "string") push(description);
|
|
238
258
|
try {
|
|
239
259
|
const wireTool: AiTool = {
|
|
240
260
|
name,
|
|
@@ -242,12 +262,14 @@ export function toolSchemaFragments(tool: ContextTool, displayIndent?: number):
|
|
|
242
262
|
parameters: parameters as AiTool["parameters"],
|
|
243
263
|
examples: tool.examples,
|
|
244
264
|
};
|
|
245
|
-
const
|
|
265
|
+
const fullSchema = toolWireSchema(wireTool) ?? {};
|
|
266
|
+
const wireSchema = pruneDescriptions ? stripSchemaDescriptions(fullSchema) : fullSchema;
|
|
246
267
|
const wireJson = JSON.stringify(wireSchema);
|
|
247
268
|
if (typeof wireJson === "string")
|
|
248
269
|
push(wireJson, display ? JSON.stringify(wireSchema, null, displayIndent) : wireJson);
|
|
249
|
-
// The agent loop appends rendered examples to the wire description
|
|
250
|
-
|
|
270
|
+
// The agent loop appends rendered examples to the wire description,
|
|
271
|
+
// which pruning empties.
|
|
272
|
+
const examplesBlock = pruneDescriptions ? undefined : renderToolExamples(wireTool);
|
|
251
273
|
if (examplesBlock) push(examplesBlock);
|
|
252
274
|
} catch (error) {
|
|
253
275
|
// Schema may contain functions or cycles.
|
|
@@ -256,23 +278,41 @@ export function toolSchemaFragments(tool: ContextTool, displayIndent?: number):
|
|
|
256
278
|
return { fragments, display };
|
|
257
279
|
}
|
|
258
280
|
|
|
281
|
+
/** Inputs that select which tool-schema estimate applies, beyond the roster and tokenizer. */
|
|
282
|
+
export interface ToolSchemaEstimateOptions {
|
|
283
|
+
/** Caller settings/source revision; a change invalidates the cached estimate. */
|
|
284
|
+
sourceRevision?: number;
|
|
285
|
+
/** Count the description-stripped specs sent when the catalog rides in the system prompt. */
|
|
286
|
+
pruneDescriptions?: boolean;
|
|
287
|
+
}
|
|
288
|
+
|
|
259
289
|
/**
|
|
260
290
|
* Estimate provider-visible tool-schema tokens.
|
|
261
291
|
*
|
|
262
292
|
* Results are cached by roster-array identity, tokenizer identity, the
|
|
263
|
-
* caller-supplied settings/source revision, and the roster's
|
|
264
|
-
* metadata revision. Callers whose descriptions or schemas are
|
|
265
|
-
* must either advance `sourceRevision` or call
|
|
293
|
+
* caller-supplied settings/source revision, the prune mode, and the roster's
|
|
294
|
+
* explicit dynamic metadata revision. Callers whose descriptions or schemas are
|
|
295
|
+
* live getters must either advance `sourceRevision` or call
|
|
266
296
|
* {@link invalidateToolSchemaMetadata} when those inputs change.
|
|
267
297
|
*/
|
|
268
|
-
export function estimateToolSchemaTokens(
|
|
298
|
+
export function estimateToolSchemaTokens(
|
|
299
|
+
tools: ToolSchemaSource,
|
|
300
|
+
tokenizer: Tokenizer,
|
|
301
|
+
options: ToolSchemaEstimateOptions = {},
|
|
302
|
+
): number {
|
|
303
|
+
const { sourceRevision = 0, pruneDescriptions = false } = options;
|
|
269
304
|
const cache = toolSchemaTokenCache(tools);
|
|
270
305
|
const cached = cache.byTokenizer.get(tokenizer);
|
|
271
|
-
if (
|
|
306
|
+
if (
|
|
307
|
+
cached?.revision === cache.revision &&
|
|
308
|
+
cached.sourceRevision === sourceRevision &&
|
|
309
|
+
cached.pruneDescriptions === pruneDescriptions
|
|
310
|
+
)
|
|
311
|
+
return cached.tokens;
|
|
272
312
|
|
|
273
|
-
const fragments = tools.flatMap(tool => toolSchemaFragments(tool).fragments);
|
|
313
|
+
const fragments = tools.flatMap(tool => toolSchemaFragments(tool, { pruneDescriptions }).fragments);
|
|
274
314
|
const tokens = tokenizer.countTokens(fragments);
|
|
275
|
-
cache.byTokenizer.set(tokenizer, { revision: cache.revision, sourceRevision, tokens });
|
|
315
|
+
cache.byTokenizer.set(tokenizer, { revision: cache.revision, sourceRevision, pruneDescriptions, tokens });
|
|
276
316
|
return tokens;
|
|
277
317
|
}
|
|
278
318
|
|
|
@@ -281,9 +321,9 @@ export function estimateContextToolSchemaTokens(
|
|
|
281
321
|
tools: ToolSchemaSource,
|
|
282
322
|
tokenizer: Tokenizer,
|
|
283
323
|
model: Model | undefined,
|
|
284
|
-
|
|
324
|
+
options: ToolSchemaEstimateOptions = {},
|
|
285
325
|
): number {
|
|
286
|
-
return model?.toolSchemasInContext === false ? 0 : estimateToolSchemaTokens(tools, tokenizer,
|
|
326
|
+
return model?.toolSchemasInContext === false ? 0 : estimateToolSchemaTokens(tools, tokenizer, options);
|
|
287
327
|
}
|
|
288
328
|
|
|
289
329
|
/**
|
|
@@ -293,15 +333,17 @@ export function estimateContextToolSchemaTokens(
|
|
|
293
333
|
*
|
|
294
334
|
* Exposed so callers like `StatusLineComponent` can cache the non-message
|
|
295
335
|
* total separately from the growing message total. A model switch can change
|
|
296
|
-
* which tool schemas occupy context without changing the roster
|
|
336
|
+
* which tool schemas occupy context without changing the roster; a prune-mode
|
|
337
|
+
* change (`Agent.prunesToolDescriptions`) changes how much of each spec ships.
|
|
297
338
|
*/
|
|
298
339
|
// The per-turn threshold and compaction paths call these helpers repeatedly.
|
|
299
|
-
// Cache by prompt, roster, skills, tokenizer, revision,
|
|
300
|
-
// setSystemPrompt/setTools replace their arrays rather than mutating them.
|
|
340
|
+
// Cache by prompt, roster, skills, tokenizer, revision, model schema policy, and
|
|
341
|
+
// prune mode; setSystemPrompt/setTools replace their arrays rather than mutating them.
|
|
301
342
|
interface NonMessageTokenCache {
|
|
302
343
|
systemPromptRef: readonly string[];
|
|
303
344
|
toolsRef: ToolSchemaSource;
|
|
304
345
|
toolSchemasInContext: boolean;
|
|
346
|
+
pruneToolDescriptions: boolean;
|
|
305
347
|
toolsRevision: number;
|
|
306
348
|
sourceRevision: number;
|
|
307
349
|
skillful: boolean;
|
|
@@ -335,6 +377,7 @@ function nonMessageTokenCacheEntry(
|
|
|
335
377
|
const systemPromptRef = session.systemPrompt ?? EMPTY_STRING_PARTS;
|
|
336
378
|
const toolsRef = session.agent?.state?.tools ?? EMPTY_TOOLS;
|
|
337
379
|
const toolSchemasInContext = session.model?.toolSchemasInContext !== false;
|
|
380
|
+
const pruneToolDescriptions = session.agent?.prunesToolDescriptions?.(session.model) === true;
|
|
338
381
|
const toolsRevision = getToolSchemaMetadataRevision(toolsRef);
|
|
339
382
|
const skillsRef = session.renderedSkills ?? session.skills ?? EMPTY_SKILLS;
|
|
340
383
|
let entry = cachedSession[NON_MESSAGE_TOKEN_CACHE];
|
|
@@ -343,6 +386,7 @@ function nonMessageTokenCacheEntry(
|
|
|
343
386
|
entry.systemPromptRef === systemPromptRef &&
|
|
344
387
|
entry.toolsRef === toolsRef &&
|
|
345
388
|
entry.toolSchemasInContext === toolSchemasInContext &&
|
|
389
|
+
entry.pruneToolDescriptions === pruneToolDescriptions &&
|
|
346
390
|
entry.toolsRevision === toolsRevision &&
|
|
347
391
|
entry.sourceRevision === sourceRevision &&
|
|
348
392
|
entry.skillsRef === skillsRef &&
|
|
@@ -354,6 +398,7 @@ function nonMessageTokenCacheEntry(
|
|
|
354
398
|
systemPromptRef,
|
|
355
399
|
toolsRef,
|
|
356
400
|
toolSchemasInContext,
|
|
401
|
+
pruneToolDescriptions,
|
|
357
402
|
toolsRevision,
|
|
358
403
|
sourceRevision,
|
|
359
404
|
skillful: true,
|
|
@@ -377,7 +422,10 @@ export function computeNonMessageTokens(
|
|
|
377
422
|
const tools = session.agent?.state?.tools ?? EMPTY_TOOLS;
|
|
378
423
|
const tokens =
|
|
379
424
|
tokenizer.countTokens(Array.from(systemPromptParts, part => part ?? "")) +
|
|
380
|
-
estimateContextToolSchemaTokens(tools, tokenizer, session.model,
|
|
425
|
+
estimateContextToolSchemaTokens(tools, tokenizer, session.model, {
|
|
426
|
+
sourceRevision,
|
|
427
|
+
pruneDescriptions: entry.pruneToolDescriptions,
|
|
428
|
+
});
|
|
381
429
|
entry.tokens = tokens;
|
|
382
430
|
return tokens;
|
|
383
431
|
}
|
|
@@ -409,7 +457,10 @@ export function computeNonMessageBreakdown(
|
|
|
409
457
|
renderedSkills(session.renderedSkills ?? session.skills ?? EMPTY_SKILLS, tools),
|
|
410
458
|
tokenizer,
|
|
411
459
|
);
|
|
412
|
-
const toolsTokens = estimateContextToolSchemaTokens(tools, tokenizer, session.model,
|
|
460
|
+
const toolsTokens = estimateContextToolSchemaTokens(tools, tokenizer, session.model, {
|
|
461
|
+
sourceRevision,
|
|
462
|
+
pruneDescriptions: entry.pruneToolDescriptions,
|
|
463
|
+
});
|
|
413
464
|
const systemPromptParts = session.systemPrompt ?? EMPTY_STRING_PARTS;
|
|
414
465
|
const systemContextTokens = tokenizer.countTokens(Array.from(systemPromptParts.slice(1), part => part ?? ""));
|
|
415
466
|
const systemPromptTokens = Math.max(0, tokenizer.countTokens(systemPromptParts[0] ?? "") - skillsTokens);
|
package/src/status-line/host.ts
CHANGED
|
@@ -102,8 +102,12 @@ export interface StatusLineHost<TSession extends StatusLineSession = StatusLineS
|
|
|
102
102
|
calculateTokensPerSecond(messages: readonly AgentMessage[], isStreaming: boolean): number | null;
|
|
103
103
|
limitMatchesActiveAccount(report: UsageReport, limit: UsageLimit, identity: StatusAccountIdentity): boolean;
|
|
104
104
|
classifyResetExpiry?(report: UsageReport, nowMs: number): StatusResetExpiry | undefined;
|
|
105
|
-
/**
|
|
106
|
-
|
|
105
|
+
/**
|
|
106
|
+
* One-line warning for saved resets anywhere in the pool that are about to expire.
|
|
107
|
+
* The host owns deduplication: a returned warning counts as shown, so each saved
|
|
108
|
+
* reset is warned about once, not once per refresh or conversation.
|
|
109
|
+
*/
|
|
110
|
+
resetExpiryNotice?(session: TSession, reports: readonly UsageReport[], nowMs: number): string | undefined;
|
|
107
111
|
computeCompactionBoundaries(session: TSession, contextWindow: number, model?: Model): CompactionBoundaries | null;
|
|
108
112
|
}
|
|
109
113
|
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* statusLine.attachToEditor(editor, getComposerStyle(shape));
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
+
import { type } from "@linxiraos/pi-omptype";
|
|
16
17
|
import type { ThinkingLevel } from "@linxiraos/pi-agent-core";
|
|
17
18
|
import type { Model } from "@linxiraos/pi-catalog/types";
|
|
18
|
-
import { isRecord } from "@linxiraos/pi-utils/type-guards";
|
|
19
19
|
import { parseThinkingLevel } from "../thinking";
|
|
20
20
|
import { StatusLineComponent } from "./component";
|
|
21
21
|
import type { CompactionBoundaries } from "./context-usage";
|
|
@@ -100,82 +100,48 @@ export function createStartupStatusLine(data: StatusLineStartupData): StatusLine
|
|
|
100
100
|
return statusLine;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
return typeof value === "string" && values.some(candidate => candidate === value);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function isOptionalBoolean(value: unknown): boolean {
|
|
108
|
-
return value === undefined || typeof value === "boolean";
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function isSegmentList(value: unknown): boolean {
|
|
112
|
-
return value === undefined || (Array.isArray(value) && value.every(id => isOneOf(STATUS_LINE_SEGMENT_IDS, id)));
|
|
113
|
-
}
|
|
103
|
+
const SegmentIds = type.enumerated(...STATUS_LINE_SEGMENT_IDS).array();
|
|
114
104
|
|
|
115
105
|
/** Shallow check of persisted settings; nested segment options are trusted as written by this version. */
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
isOptionalBoolean(value.compactThinkingLevel)
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Check the model fields the status line reads; the rest is trusted as serialized by this version. */
|
|
133
|
-
function isPersistedModel(value: unknown): value is Model {
|
|
134
|
-
return (
|
|
135
|
-
isRecord(value) &&
|
|
136
|
-
typeof value.id === "string" &&
|
|
137
|
-
typeof value.name === "string" &&
|
|
138
|
-
typeof value.provider === "string" &&
|
|
139
|
-
typeof value.api === "string" &&
|
|
140
|
-
typeof value.contextWindow === "number"
|
|
141
|
-
);
|
|
142
|
-
}
|
|
106
|
+
const StatusLineSettingsShape = type({
|
|
107
|
+
"preset?": type.enumerated(...STATUS_LINE_PRESET_VALUES),
|
|
108
|
+
"leftSegments?": SegmentIds,
|
|
109
|
+
"rightSegments?": SegmentIds,
|
|
110
|
+
"separator?": type.enumerated(...STATUS_LINE_SEPARATOR_VALUES),
|
|
111
|
+
"segmentOptions?": "Record<string, unknown>",
|
|
112
|
+
"contextLine?": type.enumerated(...CONTEXT_LINE_MODE_VALUES),
|
|
113
|
+
"showHookStatus?": "boolean",
|
|
114
|
+
"sessionAccent?": "boolean",
|
|
115
|
+
"transparent?": "boolean",
|
|
116
|
+
"compactThinkingLevel?": "boolean",
|
|
117
|
+
});
|
|
143
118
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
119
|
+
const StartupDataShape = type({
|
|
120
|
+
"+": "delete",
|
|
121
|
+
settings: StatusLineSettingsShape,
|
|
122
|
+
gitEnabled: "boolean",
|
|
123
|
+
// Only the fields the status line reads; the rest is trusted as serialized by this version.
|
|
124
|
+
"model?": { id: "string", name: "string", provider: "string", api: "string", contextWindow: "number" },
|
|
125
|
+
"thinkingLevel?": "string",
|
|
126
|
+
autoThinking: "boolean",
|
|
127
|
+
fastMode: "boolean",
|
|
128
|
+
usingSubscription: "boolean",
|
|
129
|
+
autoCompactEnabled: "boolean",
|
|
130
|
+
compactionBoundaries: type({ "+": "delete", thresholdPercent: "number", speculationPercent: "number | null" }).or(
|
|
131
|
+
"null",
|
|
132
|
+
),
|
|
133
|
+
});
|
|
151
134
|
|
|
152
135
|
/** Validate persisted {@link StatusLineStartupData}; `undefined` for anything malformed. */
|
|
153
136
|
export function readStatusLineStartupData(value: unknown): StatusLineStartupData | undefined {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (value.thinkingLevel !== undefined && thinkingLevel === undefined) return undefined;
|
|
159
|
-
const compactionBoundaries = readCompactionBoundaries(value.compactionBoundaries);
|
|
160
|
-
if (
|
|
161
|
-
typeof value.gitEnabled !== "boolean" ||
|
|
162
|
-
typeof value.autoThinking !== "boolean" ||
|
|
163
|
-
typeof value.fastMode !== "boolean" ||
|
|
164
|
-
typeof value.usingSubscription !== "boolean" ||
|
|
165
|
-
typeof value.autoCompactEnabled !== "boolean" ||
|
|
166
|
-
compactionBoundaries === undefined
|
|
167
|
-
) {
|
|
168
|
-
return undefined;
|
|
169
|
-
}
|
|
137
|
+
const data = StartupDataShape(value);
|
|
138
|
+
if (data instanceof type.errors) return undefined;
|
|
139
|
+
const thinkingLevel = data.thinkingLevel === undefined ? undefined : parseThinkingLevel(data.thinkingLevel);
|
|
140
|
+
if (data.thinkingLevel !== undefined && thinkingLevel === undefined) return undefined;
|
|
170
141
|
return {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
model,
|
|
142
|
+
...data,
|
|
143
|
+
settings: data.settings as StatusLineSettings,
|
|
144
|
+
model: data.model as Model | undefined,
|
|
174
145
|
thinkingLevel,
|
|
175
|
-
autoThinking: value.autoThinking,
|
|
176
|
-
fastMode: value.fastMode,
|
|
177
|
-
usingSubscription: value.usingSubscription,
|
|
178
|
-
autoCompactEnabled: value.autoCompactEnabled,
|
|
179
|
-
compactionBoundaries,
|
|
180
146
|
};
|
|
181
147
|
}
|
|
@@ -18,7 +18,7 @@ export declare enum NotifyProtocol {
|
|
|
18
18
|
Osc99 = "\u001B]99;;",
|
|
19
19
|
Osc9 = "\u001B]9;"
|
|
20
20
|
}
|
|
21
|
-
export type TerminalId = "kitty" | "ghostty" | "wezterm" | "iterm2" | "vscode" | "alacritty" | "warp" | "orca" | "otty" | "rio" | "tern" | "monstar" | "zetawork" | "base" | "trueColor";
|
|
21
|
+
export type TerminalId = "kitty" | "ghostty" | "wezterm" | "iterm2" | "vscode" | "alacritty" | "warp" | "orca" | "otty" | "rio" | "tern" | "monstar" | "rex" | "zetawork" | "base" | "trueColor";
|
|
22
22
|
/** Terminal capability details used for rendering and protocol selection. */
|
|
23
23
|
export declare class TerminalInfo {
|
|
24
24
|
readonly id: TerminalId;
|
|
@@ -67,6 +67,7 @@ export type TerminalId =
|
|
|
67
67
|
| "rio"
|
|
68
68
|
| "tern"
|
|
69
69
|
| "monstar"
|
|
70
|
+
| "rex"
|
|
70
71
|
| "zetawork"
|
|
71
72
|
| "base"
|
|
72
73
|
| "trueColor";
|
|
@@ -644,6 +645,8 @@ const KNOWN_TERMINALS = Object.freeze({
|
|
|
644
645
|
// OSC 99, and OSC 66 text sizing are outside rio's supported set and keep
|
|
645
646
|
// the conservative defaults.
|
|
646
647
|
rio: new TerminalInfo("rio", ImageProtocol.Kitty, true, true),
|
|
648
|
+
// Rex (TERM_PROGRAM=rex / TERM=xterm-rex): only Kitty graphics is confirmed.
|
|
649
|
+
rex: new TerminalInfo("rex", ImageProtocol.Kitty, true, false),
|
|
647
650
|
// Tern (Stencil's terminal, `stencil-term`) sets TERM_PROGRAM=tern and
|
|
648
651
|
// implements Kitty graphics, OSC 8 and OSC 9/99 notifications. Whether zeta
|
|
649
652
|
// renders natively (Tern Surface Protocol) is decided by the `hello`
|
|
@@ -693,6 +696,7 @@ export function detectTerminalId(env: NodeJS.ProcessEnv = Bun.env): TerminalId {
|
|
|
693
696
|
if (caseEq(program, "rio")) return "rio";
|
|
694
697
|
if (caseEq(program, "tern")) return "tern";
|
|
695
698
|
if (caseEq(program, "monstar")) return "monstar";
|
|
699
|
+
if (caseEq(program, "rex")) return "rex";
|
|
696
700
|
if (caseEq(program, "zetawork")) return "zetawork";
|
|
697
701
|
return null;
|
|
698
702
|
}
|
|
@@ -745,6 +749,7 @@ export function detectTerminalId(env: NodeJS.ProcessEnv = Bun.env): TerminalId {
|
|
|
745
749
|
|
|
746
750
|
if (TERM?.toLowerCase().includes("ghostty")) return "ghostty";
|
|
747
751
|
if (TERM && caseEq(TERM, "monstar")) return "monstar";
|
|
752
|
+
if (TERM && caseEq(TERM, "xterm-rex")) return "rex";
|
|
748
753
|
|
|
749
754
|
if (COLORTERM) {
|
|
750
755
|
if (caseEq(COLORTERM, "truecolor") || caseEq(COLORTERM, "24bit")) return "trueColor";
|
package/src/terminal.ts
CHANGED
|
@@ -774,7 +774,8 @@ type Da1SentinelOwner =
|
|
|
774
774
|
| { kind: "privateMode"; mode: number }
|
|
775
775
|
| { kind: "osc99Probe"; id: string }
|
|
776
776
|
| { kind: "glyphProtocol"; phase: "support" | "confirm" }
|
|
777
|
-
| { kind: "tsp" }
|
|
777
|
+
| { kind: "tsp" }
|
|
778
|
+
| { kind: "drain"; answered: () => void };
|
|
778
779
|
|
|
779
780
|
let nextOsc99ProbeId = 1;
|
|
780
781
|
|
|
@@ -1607,6 +1608,10 @@ export class ProcessTerminal implements Terminal {
|
|
|
1607
1608
|
if (owner.phase === this.#glyphProtocolPhase) this.#resolveGlyphProtocolSupport(false);
|
|
1608
1609
|
break;
|
|
1609
1610
|
}
|
|
1611
|
+
case "drain": {
|
|
1612
|
+
owner.answered();
|
|
1613
|
+
break;
|
|
1614
|
+
}
|
|
1610
1615
|
case "tsp": {
|
|
1611
1616
|
// DA1 before any `tsp;r` reply: the terminal doesn't speak TSP.
|
|
1612
1617
|
this.#resolveTspSupport(
|
|
@@ -2314,12 +2319,29 @@ export class ProcessTerminal implements Terminal {
|
|
|
2314
2319
|
process.stdin.on("data", onData);
|
|
2315
2320
|
const endTime = Date.now() + maxMs;
|
|
2316
2321
|
|
|
2322
|
+
// A terminal that answers DA1 (`#sixelSupport` is set from its first
|
|
2323
|
+
// reply) answers this one after everything it sent before reading it:
|
|
2324
|
+
// replies to output already written (TSP acks for the last frames, which
|
|
2325
|
+
// a terminal may send well after the idle window) are read here instead
|
|
2326
|
+
// of reaching the shell as typed text.
|
|
2327
|
+
let sentinelAnswered = true;
|
|
2328
|
+
if (this.#sixelSupport !== undefined && !this.#dead) {
|
|
2329
|
+
sentinelAnswered = false;
|
|
2330
|
+
this.#da1SentinelOwners.push({
|
|
2331
|
+
kind: "drain",
|
|
2332
|
+
answered: () => {
|
|
2333
|
+
sentinelAnswered = true;
|
|
2334
|
+
},
|
|
2335
|
+
});
|
|
2336
|
+
this.#safeWrite("\x1b[c");
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2317
2339
|
try {
|
|
2318
2340
|
while (true) {
|
|
2319
2341
|
const now = Date.now();
|
|
2320
2342
|
const timeLeft = endTime - now;
|
|
2321
2343
|
if (timeLeft <= 0) break;
|
|
2322
|
-
if (now - lastDataTime >= idleMs) break;
|
|
2344
|
+
if (sentinelAnswered && now - lastDataTime >= idleMs) break;
|
|
2323
2345
|
await new Promise(resolve => setTimeout(resolve, Math.min(idleMs, timeLeft)));
|
|
2324
2346
|
}
|
|
2325
2347
|
} finally {
|