@linxiraos/pi-tui 1.4.4 → 1.4.7
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 +208 -207
- package/README.md +34 -34
- 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/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +2 -0
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/table-chart.d.ts +4 -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 +2 -0
- package/dist/types/chrome/context-map.d.ts +15 -0
- package/dist/types/chrome/context-presentation.d.ts +48 -0
- package/dist/types/chrome/context-view-model.d.ts +77 -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 +20 -8
- package/dist/types/components/editor.d.ts +8 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/loader.d.ts +1 -1
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +11 -1
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/overlays/advisor-config.d.ts +6 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/ask-dialog.d.ts +12 -3
- package/dist/types/overlays/btw-history-panel.d.ts +16 -2
- package/dist/types/overlays/btw-history.d.ts +7 -0
- package/dist/types/overlays/btw-panel.d.ts +2 -0
- package/dist/types/overlays/context-viewer-format.d.ts +42 -0
- package/dist/types/overlays/context-viewer-overview.d.ts +70 -0
- package/dist/types/overlays/context-viewer.d.ts +25 -0
- package/dist/types/overlays/hook-input.d.ts +1 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/mcp-add-wizard.d.ts +2 -0
- package/dist/types/overlays/model-browser.d.ts +10 -1
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/pause-screen.d.ts +13 -3
- 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/running-subagent-badge.d.ts +7 -1
- package/dist/types/overlays/session-selector.d.ts +22 -2
- package/dist/types/prompt/composer.d.ts +43 -0
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/prompt/macos-spelling.d.ts +2 -2
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +38 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/output-pane.d.ts +1 -1
- package/dist/types/render/render-utils.d.ts +7 -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 +3 -3
- package/dist/types/status-line/context-usage.d.ts +42 -35
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/terminal-capabilities.d.ts +7 -0
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme.d.ts +0 -23
- package/dist/types/tools/ask.d.ts +4 -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/edit.d.ts +3 -1
- package/dist/types/tools/fetch.d.ts +1 -0
- package/dist/types/tools/github.d.ts +3 -0
- package/dist/types/tools/grouped-file-output.d.ts +2 -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 +7 -6
- package/dist/types/tools/native-view.d.ts +1 -1
- package/dist/types/tools/read.d.ts +3 -0
- 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 +9 -1
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/wait.d.ts +16 -2
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +9 -2
- package/dist/types/vim.d.ts +39 -0
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +20 -0
- package/src/app-keybindings.ts +20 -0
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -50
- 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 +2 -0
- package/src/chat/bash-execution.ts +13 -1
- package/src/chat/chat-transcript-builder.ts +58 -28
- 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/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/read-tool-group.ts +1 -2
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/skill-message.ts +2 -6
- package/src/chat/table-chart.d.ts +4 -3
- package/src/chat/table-chart.ts +10 -4
- 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 +2 -0
- package/src/chat/transcript-render-helpers.ts +66 -24
- package/src/chrome/context-map.ts +62 -0
- package/src/chrome/context-presentation.ts +26 -0
- package/src/chrome/context-view-model.ts +73 -0
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-container.ts +89 -59
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +20 -8
- package/src/chrome/transcript-status.ts +29 -29
- package/src/components/editor.d.ts +8 -0
- package/src/components/editor.ts +465 -14
- package/src/components/image.d.ts +20 -0
- package/src/components/image.ts +83 -18
- package/src/components/loader.d.ts +1 -1
- package/src/components/loader.ts +1 -1
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +225 -13
- package/src/hotkeys-markdown.ts +2 -0
- package/src/native/backend.ts +5 -66
- package/src/native/blobs.d.ts +11 -1
- package/src/native/blobs.ts +5 -3
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/overlays/advisor-config.ts +10 -12
- package/src/overlays/agent-hub-projection.d.ts +3 -1
- package/src/overlays/agent-hub-projection.ts +6 -5
- package/src/overlays/agent-hub.ts +51 -42
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/ask-dialog.ts +125 -35
- package/src/overlays/btw-history-panel.ts +124 -12
- package/src/overlays/btw-history.ts +11 -0
- package/src/overlays/btw-panel.ts +8 -4
- package/src/overlays/context-viewer-format.ts +145 -0
- package/src/overlays/context-viewer-overview.ts +381 -0
- package/src/overlays/context-viewer.ts +728 -0
- package/src/overlays/hook-input.ts +2 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/login-dialog.ts +31 -5
- package/src/overlays/mcp-add-wizard.ts +6 -1
- package/src/overlays/model-browser.ts +37 -0
- 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/pause-screen.ts +166 -33
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/running-subagent-badge.ts +12 -1
- package/src/overlays/session-selector.ts +313 -42
- package/src/overlays/settings-defs.ts +1 -0
- package/src/overlays/usage-dashboard.ts +20 -14
- package/src/prompt/composer.ts +216 -1
- 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/prompt/macos-spelling.ts +24 -15
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/hyperlink.d.ts +38 -7
- package/src/render/hyperlink.ts +102 -23
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/output-pane.d.ts +1 -1
- package/src/render/output-pane.ts +60 -17
- package/src/render/render-utils.d.ts +7 -1
- package/src/render/render-utils.ts +11 -2
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +3 -1
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +194 -392
- 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 +10 -14
- package/src/status-line/context-usage.ts +122 -597
- package/src/status-line/host.ts +6 -2
- package/src/terminal-capabilities.d.ts +7 -0
- package/src/terminal-capabilities.ts +10 -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 +1 -1
- package/src/theme/symbols.ts +16 -0
- package/src/theme/theme.d.ts +0 -23
- package/src/theme/theme.ts +2 -75
- package/src/tools/ask.d.ts +4 -0
- package/src/tools/ask.ts +4 -0
- package/src/tools/ast-grep.ts +3 -2
- 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 +7 -23
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +9 -6
- package/src/tools/edit.d.ts +3 -1
- package/src/tools/edit.ts +8 -4
- package/src/tools/eval.ts +14 -4
- package/src/tools/fetch.d.ts +1 -0
- package/src/tools/fetch.ts +1 -0
- package/src/tools/find.ts +3 -10
- package/src/tools/github.d.ts +3 -0
- package/src/tools/github.ts +23 -3
- package/src/tools/glob.ts +4 -3
- package/src/tools/grep.ts +3 -4
- package/src/tools/grouped-file-output.d.ts +2 -0
- package/src/tools/grouped-file-output.ts +8 -2
- 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 -42
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +36 -15
- package/src/tools/mcp.d.ts +7 -6
- package/src/tools/mcp.ts +41 -15
- package/src/tools/native-view.d.ts +1 -1
- package/src/tools/native-view.ts +3 -3
- package/src/tools/read.d.ts +3 -0
- package/src/tools/read.ts +3 -1
- 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 +9 -1
- package/src/tools/task.ts +59 -16
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/vibe.ts +14 -3
- package/src/tools/wait.d.ts +16 -2
- package/src/tools/wait.ts +16 -2
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +18 -9
- package/src/tui.d.ts +9 -2
- package/src/tui.ts +102 -34
- package/src/vim.d.ts +39 -0
- package/src/vim.ts +313 -22
- 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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
-
import { pathToFileURL } from "node:url";
|
|
3
2
|
import type { AssistantMessage, Usage } from "@linxiraos/pi-ai";
|
|
4
3
|
import { type Component } from "../tui";
|
|
5
4
|
import { Container } from "../tui";
|
|
@@ -876,7 +875,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
876
875
|
const linkPath = linkPathForTargets(row.targets);
|
|
877
876
|
const spans: TspSpan[] = [];
|
|
878
877
|
if (filePath) {
|
|
879
|
-
const href = linkPath
|
|
878
|
+
const href = linkPath ? fileHref(linkPath) : undefined;
|
|
880
879
|
spans.push(span(filePath, "path", href ? { href } : undefined));
|
|
881
880
|
} else {
|
|
882
881
|
spans.push(span("…", "toolOutput"));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replies: text the agent sends to a scheme whose writes are `reply`-scoped (`out://`)
|
|
3
|
+
* is its mid-turn message to the user, drawn as assistant prose so it can answer
|
|
4
|
+
* without ending its turn.
|
|
5
|
+
* - A `write` call to a reply URL draws as {@link ReplyWriteComponent}, streaming as the
|
|
6
|
+
* call's arguments arrive, instead of a tool card.
|
|
7
|
+
* - Text a tool's commands write there (`printf … > out://` in bash) arrives in the
|
|
8
|
+
* tool's result `details.replies` ({@link toolResultReplies}); transcripts draw each
|
|
9
|
+
* one as a prose block after the call ({@link replyDisplayMessage}).
|
|
10
|
+
*/
|
|
11
|
+
import type { AssistantMessage } from "@linxiraos/pi-ai";
|
|
12
|
+
import type { ImageBudget } from "../components/image";
|
|
13
|
+
import { AssistantMessageComponent } from "./assistant-message";
|
|
14
|
+
import type { ToolExecutionHandle, ToolResultFrame } from "./tool-execution";
|
|
15
|
+
/**
|
|
16
|
+
* Whether a `toolName` call writes to a reply URL. `undefined` while streamed args cannot tell yet:
|
|
17
|
+
* no path so far, or a path that could still grow into a reply URL (`ou`, `out:/`). Callers holding
|
|
18
|
+
* final args treat `undefined` as `false`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isReplyWrite(toolName: string, args: unknown): boolean | undefined;
|
|
21
|
+
/** Display options of a reply block; the rest of its presentation follows the assistant prose defaults. */
|
|
22
|
+
export interface ReplyWriteOptions {
|
|
23
|
+
/** Repaint request for figures and images that finish loading after a render. */
|
|
24
|
+
readonly requestRender?: () => void;
|
|
25
|
+
readonly imageBudget?: ImageBudget;
|
|
26
|
+
/** Resolved local destinations of Markdown links, as for assistant text. */
|
|
27
|
+
readonly linkTargets?: ReadonlyMap<string, string>;
|
|
28
|
+
}
|
|
29
|
+
/** Replies a tool result carries in `details.replies` (text its commands wrote to a reply URL), oldest first. */
|
|
30
|
+
export declare function toolResultReplies(details: unknown): readonly string[];
|
|
31
|
+
/** Assistant message drawing reply text. No provider turn backs it, so its identity fields stay empty. */
|
|
32
|
+
export declare function replyDisplayMessage(text: string, errorMessage?: string): AssistantMessage;
|
|
33
|
+
/**
|
|
34
|
+
* A reply write ({@link isReplyWrite}) drawn as assistant prose. The call's lifecycle arrives
|
|
35
|
+
* through {@link ToolExecutionHandle}: streamed args grow the text, final args settle it, and
|
|
36
|
+
* the result seals the block, a failure showing its error under the text. It is a reply, not
|
|
37
|
+
* tool activity, so hiding tool activity leaves it on screen.
|
|
38
|
+
*/
|
|
39
|
+
export declare class ReplyWriteComponent extends AssistantMessageComponent implements ToolExecutionHandle {
|
|
40
|
+
#private;
|
|
41
|
+
constructor(options?: ReplyWriteOptions);
|
|
42
|
+
updateArgs(args: unknown): void;
|
|
43
|
+
setArgsComplete(): void;
|
|
44
|
+
setExecutionStarted(): void;
|
|
45
|
+
updateResult(result: ToolResultFrame, isPartial?: boolean): void;
|
|
46
|
+
parkAsBackground(): void;
|
|
47
|
+
seal(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replies: text the agent sends to a scheme whose writes are `reply`-scoped (`out://`)
|
|
3
|
+
* is its mid-turn message to the user, drawn as assistant prose so it can answer
|
|
4
|
+
* without ending its turn.
|
|
5
|
+
* - A `write` call to a reply URL draws as {@link ReplyWriteComponent}, streaming as the
|
|
6
|
+
* call's arguments arrive, instead of a tool card.
|
|
7
|
+
* - Text a tool's commands write there (`printf … > out://` in bash) arrives in the
|
|
8
|
+
* tool's result `details.replies` ({@link toolResultReplies}); transcripts draw each
|
|
9
|
+
* one as a prose block after the call ({@link replyDisplayMessage}).
|
|
10
|
+
*/
|
|
11
|
+
import type { AssistantMessage, Usage } from "@linxiraos/pi-ai";
|
|
12
|
+
import { isRecord } from "@linxiraos/pi-utils";
|
|
13
|
+
import type { ImageBudget } from "../components/image";
|
|
14
|
+
import { internalUrlSchemeSpec, internalUrlSchemeSpecs, splitUrlScheme } from "../tools/url-scheme-host";
|
|
15
|
+
import { AssistantMessageComponent } from "./assistant-message";
|
|
16
|
+
import type { ToolExecutionHandle, ToolResultFrame } from "./tool-execution";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Whether a `toolName` call writes to a reply URL. `undefined` while streamed args cannot tell yet:
|
|
20
|
+
* no path so far, or a path that could still grow into a reply URL (`ou`, `out:/`). Callers holding
|
|
21
|
+
* final args treat `undefined` as `false`.
|
|
22
|
+
*/
|
|
23
|
+
export function isReplyWrite(toolName: string, args: unknown): boolean | undefined {
|
|
24
|
+
if (toolName !== "write") return false;
|
|
25
|
+
if (!isRecord(args)) return undefined;
|
|
26
|
+
const target = typeof args.path === "string" ? args.path : args.file_path;
|
|
27
|
+
if (typeof target !== "string") return undefined;
|
|
28
|
+
const url = splitUrlScheme(target);
|
|
29
|
+
if (url) return internalUrlSchemeSpec(url.scheme)?.write?.scope === "reply";
|
|
30
|
+
const lower = target.toLowerCase();
|
|
31
|
+
for (const [scheme, spec] of internalUrlSchemeSpecs()) {
|
|
32
|
+
if (spec.write?.scope === "reply" && `${scheme}://`.startsWith(lower)) return undefined;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Display options of a reply block; the rest of its presentation follows the assistant prose defaults. */
|
|
38
|
+
export interface ReplyWriteOptions {
|
|
39
|
+
/** Repaint request for figures and images that finish loading after a render. */
|
|
40
|
+
readonly requestRender?: () => void;
|
|
41
|
+
readonly imageBudget?: ImageBudget;
|
|
42
|
+
/** Resolved local destinations of Markdown links, as for assistant text. */
|
|
43
|
+
readonly linkTargets?: ReadonlyMap<string, string>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const NO_USAGE: Usage = {
|
|
47
|
+
input: 0,
|
|
48
|
+
output: 0,
|
|
49
|
+
cacheRead: 0,
|
|
50
|
+
cacheWrite: 0,
|
|
51
|
+
totalTokens: 0,
|
|
52
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Replies a tool result carries in `details.replies` (text its commands wrote to a reply URL), oldest first. */
|
|
56
|
+
export function toolResultReplies(details: unknown): readonly string[] {
|
|
57
|
+
if (!isRecord(details) || !Array.isArray(details.replies)) return [];
|
|
58
|
+
return details.replies.filter((reply): reply is string => typeof reply === "string");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Assistant message drawing reply text. No provider turn backs it, so its identity fields stay empty. */
|
|
62
|
+
export function replyDisplayMessage(text: string, errorMessage?: string): AssistantMessage {
|
|
63
|
+
return {
|
|
64
|
+
role: "assistant",
|
|
65
|
+
content: [{ type: "text", text }],
|
|
66
|
+
api: "",
|
|
67
|
+
provider: "",
|
|
68
|
+
model: "",
|
|
69
|
+
usage: NO_USAGE,
|
|
70
|
+
stopReason: errorMessage === undefined ? "stop" : "error",
|
|
71
|
+
errorMessage,
|
|
72
|
+
timestamp: 0,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A reply write ({@link isReplyWrite}) drawn as assistant prose. The call's lifecycle arrives
|
|
78
|
+
* through {@link ToolExecutionHandle}: streamed args grow the text, final args settle it, and
|
|
79
|
+
* the result seals the block, a failure showing its error under the text. It is a reply, not
|
|
80
|
+
* tool activity, so hiding tool activity leaves it on screen.
|
|
81
|
+
*/
|
|
82
|
+
export class ReplyWriteComponent extends AssistantMessageComponent implements ToolExecutionHandle {
|
|
83
|
+
#text = "";
|
|
84
|
+
#argsComplete = false;
|
|
85
|
+
|
|
86
|
+
constructor(options: ReplyWriteOptions = {}) {
|
|
87
|
+
super(undefined, false, options.requestRender, [], options.imageBudget, true, options.linkTargets);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
updateArgs(args: unknown): void {
|
|
91
|
+
const text = isRecord(args) && typeof args.content === "string" ? args.content : "";
|
|
92
|
+
if (text === this.#text || this.isTranscriptBlockFinalized()) return;
|
|
93
|
+
this.#text = text;
|
|
94
|
+
this.#draw();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setArgsComplete(): void {
|
|
98
|
+
if (this.#argsComplete || this.isTranscriptBlockFinalized()) return;
|
|
99
|
+
this.#argsComplete = true;
|
|
100
|
+
this.#draw();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setExecutionStarted(): void {}
|
|
104
|
+
|
|
105
|
+
updateResult(result: ToolResultFrame, isPartial = false): void {
|
|
106
|
+
if (isPartial || this.isTranscriptBlockFinalized()) return;
|
|
107
|
+
this.#argsComplete = true;
|
|
108
|
+
const error = result.isError
|
|
109
|
+
? result.content
|
|
110
|
+
.filter(block => block.type === "text")
|
|
111
|
+
.map(block => block.text ?? "")
|
|
112
|
+
.join("\n")
|
|
113
|
+
: undefined;
|
|
114
|
+
this.updateContent(replyDisplayMessage(this.#text, error));
|
|
115
|
+
this.markTranscriptBlockFinalized();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
parkAsBackground(): void {}
|
|
119
|
+
|
|
120
|
+
seal(): void {
|
|
121
|
+
this.markTranscriptBlockFinalized();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#draw(): void {
|
|
125
|
+
this.updateContent(replyDisplayMessage(this.#text), { transient: !this.#argsComplete });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TextContent } from "@linxiraos/pi-ai";
|
|
2
|
-
import { pathToFileURL } from "node:url";
|
|
3
2
|
import { type Component } from "../tui";
|
|
4
3
|
import { Box } from "../components/box";
|
|
5
4
|
import { Disclosure } from "../components/disclosure";
|
|
@@ -10,6 +9,7 @@ import { Text } from "../components/text";
|
|
|
10
9
|
import { getMarkdownTheme, theme } from "../theme";
|
|
11
10
|
import type { CustomMessage, SkillPromptDetails } from "./messages";
|
|
12
11
|
import { fileHyperlink } from "../render";
|
|
12
|
+
import { tryFileUri } from "../render/hyperlink";
|
|
13
13
|
import { collapseSkillTokens, skillChipLabel, skillChipStyle, skillToken } from "../prompt/composer-attachments";
|
|
14
14
|
import { tuiText, tuiTextFmt } from "../i18n";
|
|
15
15
|
import { type UserBubbleOptions, UserMessageComponent, userBubbleColor } from "./user-message";
|
|
@@ -88,11 +88,7 @@ export class SkillMessageComponent extends Container {
|
|
|
88
88
|
const leading = display.startsWith(label) && /^\s*$/.test(display.charAt(label.length));
|
|
89
89
|
const draft = leading ? display.slice(label.length).trim() : display;
|
|
90
90
|
const head: TspSpan[] = [
|
|
91
|
-
span(
|
|
92
|
-
label,
|
|
93
|
-
"customMessageLabel strong",
|
|
94
|
-
details?.path ? { href: pathToFileURL(details.path).href } : undefined,
|
|
95
|
-
),
|
|
91
|
+
span(label, "customMessageLabel strong", details?.path ? { href: tryFileUri(details.path) } : undefined),
|
|
96
92
|
];
|
|
97
93
|
if (typeof details?.lineCount === "number") {
|
|
98
94
|
head.push(span(` ${details.lineCount} ${details.lineCount === 1 ? "line" : "lines"}`, "muted"));
|
|
@@ -19,10 +19,11 @@ export interface TableChartRequest {
|
|
|
19
19
|
readonly guess: ChartPlan;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Picks the chart for a
|
|
23
|
-
*
|
|
22
|
+
* Picks the chart for a table under `smart`: a plan, or `null` for no chart.
|
|
23
|
+
* A rejection falls back to the local guess; `undefined` (no judge to ask
|
|
24
|
+
* right now) keeps the guess at once, exactly as `always` would draw it.
|
|
24
25
|
*/
|
|
25
|
-
export type TableChartPlanner = (request: TableChartRequest) => Promise<ChartPlan | null
|
|
26
|
+
export type TableChartPlanner = (request: TableChartRequest) => Promise<ChartPlan | null> | undefined;
|
|
26
27
|
/**
|
|
27
28
|
* The chart under a table: its SVG, colored with figure tokens (`var(--accent)`, …)
|
|
28
29
|
* still to resolve; none; or a smart pick on its way (the promise settles once the cache holds it).
|
package/src/chat/table-chart.ts
CHANGED
|
@@ -37,10 +37,11 @@ export interface TableChartRequest {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Picks the chart for a
|
|
41
|
-
*
|
|
40
|
+
* Picks the chart for a table under `smart`: a plan, or `null` for no chart.
|
|
41
|
+
* A rejection falls back to the local guess; `undefined` (no judge to ask
|
|
42
|
+
* right now) keeps the guess at once, exactly as `always` would draw it.
|
|
42
43
|
*/
|
|
43
|
-
export type TableChartPlanner = (request: TableChartRequest) => Promise<ChartPlan | null
|
|
44
|
+
export type TableChartPlanner = (request: TableChartRequest) => Promise<ChartPlan | null> | undefined;
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* The chart under a table: its SVG, colored with figure tokens (`var(--accent)`, …)
|
|
@@ -126,7 +127,12 @@ export function lookupTableChart(table: Tokens.Table): ChartLookup {
|
|
|
126
127
|
if (entry.chart !== undefined) return entry.chart;
|
|
127
128
|
if (entry.pending) return entry.pending;
|
|
128
129
|
const { analysis, guess } = entry;
|
|
129
|
-
|
|
130
|
+
const pick = chartPlanner!({ markdown: table.raw, table: analysis, guess: guess! });
|
|
131
|
+
if (!pick) {
|
|
132
|
+
entry.chart = drawChart(analysis, guess!, true);
|
|
133
|
+
return entry.chart;
|
|
134
|
+
}
|
|
135
|
+
entry.pending = pick.then(
|
|
130
136
|
plan => {
|
|
131
137
|
entry.chart = plan ? drawChart(analysis, plan) : null;
|
|
132
138
|
},
|
|
@@ -35,7 +35,6 @@ export interface ToolExecutionHandle extends Component {
|
|
|
35
35
|
setArgsComplete(toolCallId?: string): void;
|
|
36
36
|
setExecutionStarted(toolCallId?: string): void;
|
|
37
37
|
setExpanded(expanded: boolean): void;
|
|
38
|
-
setToolActivityVisible(visible: boolean): void;
|
|
39
38
|
/** Mark the call parked: it returned, but stays tracked for async job frames. */
|
|
40
39
|
parkAsBackground(): void;
|
|
41
40
|
/** Seal the block as final history and stop its animations. */
|
|
@@ -102,7 +101,7 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
102
101
|
* component-scoped so the TUI reuses every other root subtree (issue #4377).
|
|
103
102
|
*/
|
|
104
103
|
tickSpinner(frame: number): void;
|
|
105
|
-
/**
|
|
104
|
+
/** Hold visible results until their figures and Kitty images are ready for immutable scrollback. */
|
|
106
105
|
isTranscriptBlockPending(): boolean;
|
|
107
106
|
/**
|
|
108
107
|
* Whether this block is ready to retire as immutable history. Partial
|
|
@@ -126,6 +126,9 @@ function cardPreview(preview: NativeToolView["preview"]): TspPreview | undefined
|
|
|
126
126
|
/** The describe hooks of a registry renderer or of a custom tool object. */
|
|
127
127
|
type ToolDescriber = Pick<ToolRenderer, "describeCall" | "describeResult" | "mergeCallAndResult">;
|
|
128
128
|
|
|
129
|
+
/** Optional kinds of the host's vocabulary the describe hooks branch on. */
|
|
130
|
+
type NativeHostKinds = Required<Pick<RenderResultContextOptions, "media" | "json">>;
|
|
131
|
+
|
|
129
132
|
class SafeToolRendererComponent implements Component {
|
|
130
133
|
#toolName: string;
|
|
131
134
|
#stage: ToolRendererStage;
|
|
@@ -233,7 +236,6 @@ export interface ToolExecutionHandle extends Component {
|
|
|
233
236
|
setArgsComplete(toolCallId?: string): void;
|
|
234
237
|
setExecutionStarted(toolCallId?: string): void;
|
|
235
238
|
setExpanded(expanded: boolean): void;
|
|
236
|
-
setToolActivityVisible(visible: boolean): void;
|
|
237
239
|
/** Mark the call parked: it returned, but stays tracked for async job frames. */
|
|
238
240
|
parkAsBackground(): void;
|
|
239
241
|
/** Seal the block as final history and stop its animations. */
|
|
@@ -711,14 +713,15 @@ export class ToolExecutionComponent extends Container {
|
|
|
711
713
|
// Convert async - catch errors from processing
|
|
712
714
|
convertImageToPngShared(image)
|
|
713
715
|
.then(converted => {
|
|
716
|
+
this.#kittyConversionsAwaited.delete(key);
|
|
714
717
|
this.#kittyConverted.set(key, converted);
|
|
715
718
|
this.#displayInputVersion++;
|
|
716
719
|
this.#updateDisplay();
|
|
717
720
|
this.#ui.requestRender();
|
|
718
721
|
})
|
|
719
722
|
.catch(() => {
|
|
720
|
-
// Ignore conversion failures - display will use original image format
|
|
721
723
|
this.#kittyConversionsAwaited.delete(key);
|
|
724
|
+
this.#ui.requestRender();
|
|
722
725
|
});
|
|
723
726
|
}
|
|
724
727
|
}
|
|
@@ -859,9 +862,12 @@ export class ToolExecutionComponent extends Container {
|
|
|
859
862
|
}
|
|
860
863
|
}
|
|
861
864
|
|
|
862
|
-
/**
|
|
865
|
+
/** Hold visible results until their figures and Kitty images are ready for immutable scrollback. */
|
|
863
866
|
isTranscriptBlockPending(): boolean {
|
|
864
|
-
return
|
|
867
|
+
return (
|
|
868
|
+
this.#toolActivityVisible &&
|
|
869
|
+
((this.#showImages && this.#kittyConversionsAwaited.size > 0) || this.#figure?.pending === true)
|
|
870
|
+
);
|
|
865
871
|
}
|
|
866
872
|
|
|
867
873
|
/**
|
|
@@ -1018,7 +1024,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
1018
1024
|
override describe(cx?: DescribeContext): NativeNode {
|
|
1019
1025
|
if (this.#toolName === "wait" && this.#isBenignSkip()) return EMPTY_NODE;
|
|
1020
1026
|
const dataFirst = cx?.supports("tool") === true;
|
|
1021
|
-
const
|
|
1027
|
+
const host: NativeHostKinds = { media: cx?.supports("media") === true, json: cx?.supports("json") === true };
|
|
1022
1028
|
const key = [
|
|
1023
1029
|
dataFirst,
|
|
1024
1030
|
this.#resultVersion,
|
|
@@ -1031,11 +1037,12 @@ export class ToolExecutionComponent extends Container {
|
|
|
1031
1037
|
this.#showImages,
|
|
1032
1038
|
this.#displayInputVersion,
|
|
1033
1039
|
this.#toolActivityVisible,
|
|
1034
|
-
media,
|
|
1040
|
+
host.media,
|
|
1041
|
+
host.json,
|
|
1035
1042
|
getThemeEpoch(),
|
|
1036
1043
|
];
|
|
1037
1044
|
return this.#native.get(key, () =>
|
|
1038
|
-
withHidden(dataFirst ? this.#describeTool(
|
|
1045
|
+
withHidden(dataFirst ? this.#describeTool(host) : this.#describeCard(host), !this.#toolActivityVisible),
|
|
1039
1046
|
);
|
|
1040
1047
|
}
|
|
1041
1048
|
|
|
@@ -1081,8 +1088,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
1081
1088
|
* The data-first `tool` node (§7.2): the renderer's head data, status,
|
|
1082
1089
|
* timer, exit and intent as props; its body as borderless children.
|
|
1083
1090
|
*/
|
|
1084
|
-
#describeTool(
|
|
1085
|
-
const view = this.#nativeView(
|
|
1091
|
+
#describeTool(host: NativeHostKinds): NativeNode {
|
|
1092
|
+
const view = this.#nativeView(host);
|
|
1086
1093
|
const status = this.#nativeStatus();
|
|
1087
1094
|
const head = view.tool;
|
|
1088
1095
|
const late = this.#lateDiagnosticsParts();
|
|
@@ -1151,8 +1158,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
1151
1158
|
return spans;
|
|
1152
1159
|
}
|
|
1153
1160
|
|
|
1154
|
-
#describeCard(
|
|
1155
|
-
const view = this.#nativeView(
|
|
1161
|
+
#describeCard(host: NativeHostKinds): NativeNode {
|
|
1162
|
+
const view = this.#nativeView(host);
|
|
1156
1163
|
const status = this.#nativeStatus();
|
|
1157
1164
|
const late = this.#lateDiagnosticsParts();
|
|
1158
1165
|
const fallbackHead = this.#fallbackHead(view);
|
|
@@ -1206,10 +1213,10 @@ export class ToolExecutionComponent extends Container {
|
|
|
1206
1213
|
* the result view (merged renderers) or the call head over both bodies.
|
|
1207
1214
|
* A renderer that throws falls back to the generic card.
|
|
1208
1215
|
*/
|
|
1209
|
-
#nativeView(
|
|
1216
|
+
#nativeView(host: NativeHostKinds): NativeToolView {
|
|
1210
1217
|
const status = this.#nativeStatus();
|
|
1211
1218
|
const options: RenderResultContextOptions = {
|
|
1212
|
-
|
|
1219
|
+
...host,
|
|
1213
1220
|
expanded: this.#expanded,
|
|
1214
1221
|
isPartial: this.#isPartial,
|
|
1215
1222
|
argsComplete: this.#argsComplete,
|
|
@@ -9,6 +9,7 @@ import { type TranscriptEntryLike as TranscriptEntry } from "./transcript-entry"
|
|
|
9
9
|
import type { SessionMessageEntryLike as SessionMessageEntry } from "./transcript-entry";
|
|
10
10
|
import { type ThemeColor } from "../theme";
|
|
11
11
|
import type { ChatTranscriptBuilder } from "./chat-transcript-builder";
|
|
12
|
+
import type { DescribeContext } from "../native/node";
|
|
12
13
|
/** One selectable transcript item: a message entry plus its rendered block range. */
|
|
13
14
|
export interface OutlineTarget {
|
|
14
15
|
/** Entry the selection resolves to; extended over trailing componentless tool results. */
|
|
@@ -63,6 +64,12 @@ export declare class OutlineRowCache {
|
|
|
63
64
|
export declare function appendOutlineEntries(builder: ChatTranscriptBuilder, entries: TranscriptEntry[]): OutlineTarget[];
|
|
64
65
|
/** Per-target "renders at least one non-blank row" flags at the given rows. */
|
|
65
66
|
export declare function outlineVisibility(childRows: readonly (readonly string[])[], targets: readonly OutlineTarget[]): boolean[];
|
|
67
|
+
/**
|
|
68
|
+
* Per-target "describes something that shows" flags: {@link outlineVisibility}
|
|
69
|
+
* for a TSP page, where blocks describe nodes instead of rendering rows. An
|
|
70
|
+
* empty `col`/`row` (an interrupted turn with no output) shows nothing.
|
|
71
|
+
*/
|
|
72
|
+
export declare function describedVisibility(blocks: readonly Component[], targets: readonly OutlineTarget[], cx: DescribeContext): boolean[];
|
|
66
73
|
/** Dotted horizontal rule with rounded corners, spanning the outline width. */
|
|
67
74
|
export declare function outlineRule(left: string, right: string, innerWidth: number, color?: ThemeColor, caption?: string): string;
|
|
68
75
|
/** Wrap pre-rendered rows in the dotted outline (rules above/below, `┆` sides). */
|
|
@@ -17,6 +17,7 @@ import { type ThemeColor, theme } from "../theme";
|
|
|
17
17
|
import type { ChatTranscriptBuilder } from "./chat-transcript-builder";
|
|
18
18
|
import { padToWidth } from "../render/utils";
|
|
19
19
|
import { isUsageRowBlock } from "../overlays/usage-row";
|
|
20
|
+
import type { DescribeContext, NativeChild } from "../native/node";
|
|
20
21
|
|
|
21
22
|
/** One selectable transcript item: a message entry plus its rendered block range. */
|
|
22
23
|
export interface OutlineTarget {
|
|
@@ -148,6 +149,32 @@ export function outlineVisibility(
|
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Per-target "describes something that shows" flags: {@link outlineVisibility}
|
|
154
|
+
* for a TSP page, where blocks describe nodes instead of rendering rows. An
|
|
155
|
+
* empty `col`/`row` (an interrupted turn with no output) shows nothing.
|
|
156
|
+
*/
|
|
157
|
+
export function describedVisibility(
|
|
158
|
+
blocks: readonly Component[],
|
|
159
|
+
targets: readonly OutlineTarget[],
|
|
160
|
+
cx: DescribeContext,
|
|
161
|
+
): boolean[] {
|
|
162
|
+
return targets.map(target => {
|
|
163
|
+
for (let index = target.start; index < target.end; index++) {
|
|
164
|
+
if (shows(blocks[index]!, cx)) return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Whether `child` describes a node that shows: a layout `col`/`row` only through a child that does. */
|
|
171
|
+
function shows(child: NativeChild, cx: DescribeContext): boolean {
|
|
172
|
+
const node = "k" in child ? child : child.describe?.(cx);
|
|
173
|
+
if (!node) return false;
|
|
174
|
+
if (node.k !== "col" && node.k !== "row") return true;
|
|
175
|
+
return (node.c ?? []).some(grandchild => shows(grandchild, cx));
|
|
176
|
+
}
|
|
177
|
+
|
|
151
178
|
/** Dotted horizontal rule with rounded corners, spanning the outline width. */
|
|
152
179
|
export function outlineRule(
|
|
153
180
|
left: string,
|
|
@@ -55,6 +55,8 @@ export declare function assistantHasVisibleContent(message: AssistantAgentMessag
|
|
|
55
55
|
export declare function splitAssistantMessageToolTimeline(message: AssistantAgentMessage): {
|
|
56
56
|
beforeTools: AssistantAgentMessage;
|
|
57
57
|
afterToolCalls: ReadonlyMap<string, AssistantAgentMessage>;
|
|
58
|
+
/** Index in `message.content` of each after-tool segment's first block, by tool-call id. */
|
|
59
|
+
contentOffsets: ReadonlyMap<string, number>;
|
|
58
60
|
hasToolCalls: boolean;
|
|
59
61
|
lastToolCallId?: string;
|
|
60
62
|
};
|
|
@@ -5,13 +5,16 @@
|
|
|
5
5
|
* here keeps the two byte-for-byte identical.
|
|
6
6
|
*/
|
|
7
7
|
import type { AgentMessage } from "@linxiraos/pi-agent-core";
|
|
8
|
+
import type { TspSpan } from "@linxiraos/pi-wire";
|
|
8
9
|
import { type Component } from "../tui";
|
|
9
|
-
import { formatBytes, formatDuration } from "@linxiraos/pi-utils";
|
|
10
|
+
import { formatBytes, formatCount, formatDuration } from "@linxiraos/pi-utils";
|
|
11
|
+
import { span } from "../native/describe";
|
|
10
12
|
import type { JobSnapshot } from "../tools/wait";
|
|
11
13
|
import type { DaemonSnapshot } from "../tools/daemon";
|
|
12
14
|
import { type CustomMessage, type FileMentionMessage, resolveAbortLabel, shouldRenderAbortReason } from "./messages";
|
|
13
15
|
import { createIrcMessageCard } from "../tools/wait";
|
|
14
16
|
import { formatArtifactErrorNotice, type OutputMeta } from "../tools/output-meta";
|
|
17
|
+
import type { OutputArtifactError } from "../tools/streaming-output";
|
|
15
18
|
import { replaceTabs, TRUNCATE_LENGTHS, truncateToWidth } from "../render/render-utils";
|
|
16
19
|
import { canonicalizeMessage } from "./thinking-display";
|
|
17
20
|
import { ToolActivityContainer } from "../chrome/tool-activity";
|
|
@@ -58,26 +61,40 @@ export function buildAsyncResultBlock(message: CustomOrHookMessage): ToolActivit
|
|
|
58
61
|
const rows: TranscriptStatusRow[] = [];
|
|
59
62
|
for (const job of jobs) {
|
|
60
63
|
const jobId = job.jobId ?? "unknown";
|
|
61
|
-
const
|
|
64
|
+
const type = job.type ?? "job";
|
|
62
65
|
const duration = typeof job.durationMs === "number" ? formatDuration(job.durationMs) : undefined;
|
|
63
66
|
rows.push({
|
|
64
67
|
parts: [
|
|
65
68
|
{ text: `${theme.status.done} Background job completed`, color: "success" },
|
|
66
|
-
{ text:
|
|
69
|
+
{ text: `[${type}]`, color: "dim" },
|
|
67
70
|
{ text: jobId, color: "accent" },
|
|
68
71
|
duration ? { text: `(${duration})`, color: "dim" } : undefined,
|
|
69
72
|
],
|
|
73
|
+
native: {
|
|
74
|
+
tone: "success",
|
|
75
|
+
message: [span("Background job completed"), ...facts([type, jobId, duration])],
|
|
76
|
+
},
|
|
70
77
|
});
|
|
71
|
-
if (job.meta?.artifactError)
|
|
72
|
-
rows.push({ parts: [{ text: formatArtifactErrorNotice(job.meta.artifactError), color: "warning" }] });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (details?.meta?.artifactError) {
|
|
76
|
-
rows.push({ parts: [{ text: formatArtifactErrorNotice(details.meta.artifactError), color: "warning" }] });
|
|
78
|
+
if (job.meta?.artifactError) rows.push(artifactErrorRow(job.meta.artifactError));
|
|
77
79
|
}
|
|
80
|
+
if (details?.meta?.artifactError) rows.push(artifactErrorRow(details.meta.artifactError));
|
|
78
81
|
return new ToolActivityContainer(new TranscriptStatusBlock(rows));
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
/** The warning row under a background job whose output artifact could not be saved. */
|
|
85
|
+
function artifactErrorRow(error: OutputArtifactError): TranscriptStatusRow {
|
|
86
|
+
const notice = formatArtifactErrorNotice(error);
|
|
87
|
+
return { parts: [{ text: notice, color: "warning" }], native: { tone: "warning", message: [span(notice)] } };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Native notice spans for a row's trailing facts (kind, id, duration): each
|
|
92
|
+
* after a dim ` · `, absent ones skipped.
|
|
93
|
+
*/
|
|
94
|
+
function facts(values: readonly (string | undefined)[]): TspSpan[] {
|
|
95
|
+
return values.flatMap(value => (value ? [span(" · ", "dim"), span(value, "dim")] : []));
|
|
96
|
+
}
|
|
97
|
+
|
|
81
98
|
/**
|
|
82
99
|
* Render a `launch-completion` custom message (terminal supervised-process
|
|
83
100
|
* exits from the launch broker) as a transcript block of one compact
|
|
@@ -88,10 +105,15 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
|
|
|
88
105
|
const rows: TranscriptStatusRow[] = [];
|
|
89
106
|
const daemons = details?.daemons ?? [];
|
|
90
107
|
if (daemons.length === 0 && typeof message.content === "string") {
|
|
91
|
-
rows.push({
|
|
108
|
+
rows.push({
|
|
109
|
+
parts: [{ text: `${theme.status.done} ${message.content}`, color: "dim" }],
|
|
110
|
+
native: { tone: "success", message: [span(message.content)] },
|
|
111
|
+
});
|
|
92
112
|
}
|
|
93
113
|
for (const daemon of daemons) {
|
|
94
114
|
const failed = daemon.state === "failed" || (daemon.exitCode !== undefined && daemon.exitCode !== 0);
|
|
115
|
+
const label = failed ? "Supervised process failed" : "Supervised process completed";
|
|
116
|
+
const exit = daemon.exitCode !== undefined ? `exit ${daemon.exitCode}` : undefined;
|
|
95
117
|
const duration =
|
|
96
118
|
daemon.exitedAt !== undefined && daemon.startedAt !== undefined
|
|
97
119
|
? formatDuration(daemon.exitedAt - daemon.startedAt)
|
|
@@ -99,12 +121,16 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
|
|
|
99
121
|
rows.push({
|
|
100
122
|
parts: [
|
|
101
123
|
failed
|
|
102
|
-
? { text: `${theme.status.error}
|
|
103
|
-
: { text: `${theme.status.done}
|
|
124
|
+
? { text: `${theme.status.error} ${label}`, color: "error" }
|
|
125
|
+
: { text: `${theme.status.done} ${label}`, color: "success" },
|
|
104
126
|
{ text: daemon.name, color: "accent" },
|
|
105
|
-
|
|
127
|
+
exit ? { text: `(${exit})`, color: "dim" } : undefined,
|
|
106
128
|
duration ? { text: `(${duration})`, color: "dim" } : undefined,
|
|
107
129
|
],
|
|
130
|
+
native: {
|
|
131
|
+
tone: failed ? "error" : "success",
|
|
132
|
+
message: [span(label), span(" "), span(daemon.name, "mono"), ...facts([exit, duration])],
|
|
133
|
+
},
|
|
108
134
|
});
|
|
109
135
|
}
|
|
110
136
|
return new ToolActivityContainer(new TranscriptStatusBlock(rows));
|
|
@@ -160,25 +186,30 @@ export function buildIrcMessageCard(message: CustomOrHookMessage, getExpanded: (
|
|
|
160
186
|
export function buildFileMentionBlock(files: FileMentionMessage["files"], indent: number): TranscriptBlock {
|
|
161
187
|
const rows: TranscriptStatusRow[] = [];
|
|
162
188
|
for (const file of files) {
|
|
163
|
-
let
|
|
189
|
+
let detail: string;
|
|
164
190
|
if (file.skippedReason === "tooLarge" || file.skippedReason === "binary") {
|
|
165
191
|
const size = typeof file.byteSize === "number" ? formatBytes(file.byteSize) : "unknown size";
|
|
166
|
-
|
|
192
|
+
detail = file.skippedReason === "binary" ? `skipped: binary, ${size}` : `skipped: ${size}`;
|
|
167
193
|
} else {
|
|
168
|
-
|
|
169
|
-
? "
|
|
194
|
+
detail = file.image
|
|
195
|
+
? "image"
|
|
170
196
|
: file.lineCount === undefined
|
|
171
|
-
? "
|
|
172
|
-
:
|
|
197
|
+
? "unknown lines"
|
|
198
|
+
: formatCount("line", file.lineCount);
|
|
173
199
|
}
|
|
174
200
|
rows.push({
|
|
175
201
|
parts: [
|
|
176
|
-
{ text: theme.tree.last, color: "dim"
|
|
202
|
+
{ text: theme.tree.last, color: "dim" },
|
|
177
203
|
{ text: "Read", color: "muted" },
|
|
178
204
|
{ text: file.path, color: "accent" },
|
|
179
|
-
{ text:
|
|
205
|
+
{ text: `(${detail})`, color: "dim" },
|
|
180
206
|
],
|
|
181
207
|
indent,
|
|
208
|
+
native: {
|
|
209
|
+
tone: "info",
|
|
210
|
+
icon: "read",
|
|
211
|
+
message: [span("Read"), span(" "), span(file.path, "path"), ...facts([detail])],
|
|
212
|
+
},
|
|
182
213
|
});
|
|
183
214
|
}
|
|
184
215
|
return new TranscriptStatusBlock(rows);
|
|
@@ -207,11 +238,14 @@ export function assistantHasVisibleContent(message: AssistantAgentMessage): bool
|
|
|
207
238
|
export function splitAssistantMessageToolTimeline(message: AssistantAgentMessage): {
|
|
208
239
|
beforeTools: AssistantAgentMessage;
|
|
209
240
|
afterToolCalls: ReadonlyMap<string, AssistantAgentMessage>;
|
|
241
|
+
/** Index in `message.content` of each after-tool segment's first block, by tool-call id. */
|
|
242
|
+
contentOffsets: ReadonlyMap<string, number>;
|
|
210
243
|
hasToolCalls: boolean;
|
|
211
244
|
lastToolCallId?: string;
|
|
212
245
|
} {
|
|
213
246
|
const beforeTools: AssistantAgentMessage["content"] = [];
|
|
214
247
|
const afterToolCalls = new Map<string, AssistantAgentMessage>();
|
|
248
|
+
const contentOffsets = new Map<string, number>();
|
|
215
249
|
let pendingAfterTool: AssistantAgentMessage["content"] = [];
|
|
216
250
|
let lastToolCallId: string | undefined;
|
|
217
251
|
let sawToolCall = false;
|
|
@@ -230,11 +264,13 @@ export function splitAssistantMessageToolTimeline(message: AssistantAgentMessage
|
|
|
230
264
|
pendingAfterTool = [];
|
|
231
265
|
};
|
|
232
266
|
|
|
233
|
-
for (
|
|
267
|
+
for (let index = 0; index < message.content.length; index++) {
|
|
268
|
+
const content = message.content[index]!;
|
|
234
269
|
if (content.type === "toolCall") {
|
|
235
270
|
flushPendingAfterTool();
|
|
236
271
|
sawToolCall = true;
|
|
237
272
|
lastToolCallId = content.id;
|
|
273
|
+
contentOffsets.set(content.id, index + 1);
|
|
238
274
|
continue;
|
|
239
275
|
}
|
|
240
276
|
if (sawToolCall) {
|
|
@@ -246,10 +282,16 @@ export function splitAssistantMessageToolTimeline(message: AssistantAgentMessage
|
|
|
246
282
|
flushPendingAfterTool();
|
|
247
283
|
|
|
248
284
|
if (!sawToolCall) {
|
|
249
|
-
return { beforeTools: message, afterToolCalls, hasToolCalls: false };
|
|
285
|
+
return { beforeTools: message, afterToolCalls, contentOffsets, hasToolCalls: false };
|
|
250
286
|
}
|
|
251
287
|
|
|
252
|
-
return {
|
|
288
|
+
return {
|
|
289
|
+
beforeTools: displaySegment(beforeTools),
|
|
290
|
+
afterToolCalls,
|
|
291
|
+
contentOffsets,
|
|
292
|
+
hasToolCalls: true,
|
|
293
|
+
lastToolCallId,
|
|
294
|
+
};
|
|
253
295
|
}
|
|
254
296
|
|
|
255
297
|
/**
|