@esso0428/pi-subagents 0.17.16 → 0.17.18
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 +11 -0
- package/ROADMAP.md +87 -0
- package/docs/post-0.17.6-agents-roster-viewer-spec.md +42 -0
- package/docs/post-0.17.6-durable-history-spec.md +41 -0
- package/docs/post-0.17.6-feature-specs.md +50 -0
- package/docs/post-0.17.6-nested-agents-spec.md +38 -0
- package/docs/post-0.17.6-recovery-shutdown-spec.md +46 -0
- package/docs/post-0.17.6-ui-latency-baseline-spec.md +46 -0
- package/docs/post-0.17.6-workflow-rpc-lifecycle-spec.md +54 -0
- package/package.json +1 -1
- package/src/agent-history.ts +2 -54
- package/src/agent-manager.ts +406 -1288
- package/src/agent-runner.ts +27 -251
- package/src/agent-types.ts +32 -188
- package/src/cross-extension-rpc.ts +20 -96
- package/src/custom-agents.ts +13 -170
- package/src/index.ts +480 -1920
- package/src/invocation-config.ts +3 -118
- package/src/model-resolver.ts +0 -18
- package/src/output-file.ts +6 -61
- package/src/prompts.ts +2 -45
- package/src/schedule.ts +14 -35
- package/src/settings.ts +2 -301
- package/src/status-note.ts +1 -66
- package/src/types.ts +10 -177
- package/src/ui/agent-widget.ts +57 -278
- package/src/ui/conversation-blocks.ts +0 -6
- package/src/ui/conversation-timeline.ts +25 -139
- package/src/ui/conversation-viewer.ts +48 -212
- package/src/ui/schedule-menu.ts +8 -9
- package/src/usage.ts +2 -109
- package/src/worktree.ts +55 -69
- package/dist/abortable.d.ts +0 -13
- package/dist/abortable.d.ts.map +0 -1
- package/dist/abortable.js +0 -43
- package/dist/abortable.js.map +0 -1
- package/dist/agent-color.d.ts +0 -36
- package/dist/agent-color.d.ts.map +0 -1
- package/dist/agent-color.js +0 -124
- package/dist/agent-color.js.map +0 -1
- package/dist/agent-file-toggle.d.ts +0 -126
- package/dist/agent-file-toggle.d.ts.map +0 -1
- package/dist/agent-file-toggle.js +0 -259
- package/dist/agent-file-toggle.js.map +0 -1
- package/dist/agent-history-list.d.ts +0 -19
- package/dist/agent-history-list.d.ts.map +0 -1
- package/dist/agent-history-list.js +0 -69
- package/dist/agent-history-list.js.map +0 -1
- package/dist/agent-history.d.ts +0 -35
- package/dist/agent-history.d.ts.map +0 -1
- package/dist/agent-history.js +0 -188
- package/dist/agent-history.js.map +0 -1
- package/dist/agent-manager.d.ts +0 -503
- package/dist/agent-manager.d.ts.map +0 -1
- package/dist/agent-manager.js +0 -1572
- package/dist/agent-manager.js.map +0 -1
- package/dist/agent-recovery.d.ts +0 -37
- package/dist/agent-recovery.d.ts.map +0 -1
- package/dist/agent-recovery.js +0 -171
- package/dist/agent-recovery.js.map +0 -1
- package/dist/agent-runner.d.ts +0 -303
- package/dist/agent-runner.d.ts.map +0 -1
- package/dist/agent-runner.js +0 -1003
- package/dist/agent-runner.js.map +0 -1
- package/dist/agent-types.d.ts +0 -120
- package/dist/agent-types.d.ts.map +0 -1
- package/dist/agent-types.js +0 -301
- package/dist/agent-types.js.map +0 -1
- package/dist/child-context.d.ts +0 -3
- package/dist/child-context.d.ts.map +0 -1
- package/dist/child-context.js +0 -13
- package/dist/child-context.js.map +0 -1
- package/dist/context.d.ts +0 -13
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -57
- package/dist/context.js.map +0 -1
- package/dist/cross-extension-rpc.d.ts +0 -67
- package/dist/cross-extension-rpc.d.ts.map +0 -1
- package/dist/cross-extension-rpc.js +0 -139
- package/dist/cross-extension-rpc.js.map +0 -1
- package/dist/custom-agents.d.ts +0 -55
- package/dist/custom-agents.d.ts.map +0 -1
- package/dist/custom-agents.js +0 -309
- package/dist/custom-agents.js.map +0 -1
- package/dist/default-agents.d.ts +0 -8
- package/dist/default-agents.d.ts.map +0 -1
- package/dist/default-agents.js +0 -123
- package/dist/default-agents.js.map +0 -1
- package/dist/enabled-models.d.ts +0 -50
- package/dist/enabled-models.d.ts.map +0 -1
- package/dist/enabled-models.js +0 -146
- package/dist/enabled-models.js.map +0 -1
- package/dist/env.d.ts +0 -7
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -29
- package/dist/env.js.map +0 -1
- package/dist/group-join.d.ts +0 -33
- package/dist/group-join.d.ts.map +0 -1
- package/dist/group-join.js +0 -117
- package/dist/group-join.js.map +0 -1
- package/dist/index.d.ts +0 -51
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3687
- package/dist/index.js.map +0 -1
- package/dist/invocation-config.d.ts +0 -108
- package/dist/invocation-config.d.ts.map +0 -1
- package/dist/invocation-config.js +0 -84
- package/dist/invocation-config.js.map +0 -1
- package/dist/memory.d.ts +0 -54
- package/dist/memory.d.ts.map +0 -1
- package/dist/memory.js +0 -166
- package/dist/memory.js.map +0 -1
- package/dist/mention-clone.d.ts +0 -88
- package/dist/mention-clone.d.ts.map +0 -1
- package/dist/mention-clone.js +0 -154
- package/dist/mention-clone.js.map +0 -1
- package/dist/mention.d.ts +0 -82
- package/dist/mention.d.ts.map +0 -1
- package/dist/mention.js +0 -132
- package/dist/mention.js.map +0 -1
- package/dist/model-resolver.d.ts +0 -37
- package/dist/model-resolver.d.ts.map +0 -1
- package/dist/model-resolver.js +0 -96
- package/dist/model-resolver.js.map +0 -1
- package/dist/model-scope.d.ts +0 -50
- package/dist/model-scope.d.ts.map +0 -1
- package/dist/model-scope.js +0 -49
- package/dist/model-scope.js.map +0 -1
- package/dist/nested-tools.d.ts +0 -57
- package/dist/nested-tools.d.ts.map +0 -1
- package/dist/nested-tools.js +0 -301
- package/dist/nested-tools.js.map +0 -1
- package/dist/nico-overrides.d.ts +0 -54
- package/dist/nico-overrides.d.ts.map +0 -1
- package/dist/nico-overrides.js +0 -170
- package/dist/nico-overrides.js.map +0 -1
- package/dist/output-file.d.ts +0 -44
- package/dist/output-file.d.ts.map +0 -1
- package/dist/output-file.js +0 -156
- package/dist/output-file.js.map +0 -1
- package/dist/prompts.d.ts +0 -56
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -92
- package/dist/prompts.js.map +0 -1
- package/dist/schedule-store.d.ts +0 -39
- package/dist/schedule-store.d.ts.map +0 -1
- package/dist/schedule-store.js +0 -156
- package/dist/schedule-store.js.map +0 -1
- package/dist/schedule.d.ts +0 -110
- package/dist/schedule.d.ts.map +0 -1
- package/dist/schedule.js +0 -360
- package/dist/schedule.js.map +0 -1
- package/dist/settings.d.ts +0 -354
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js +0 -247
- package/dist/settings.js.map +0 -1
- package/dist/skill-loader.d.ts +0 -25
- package/dist/skill-loader.d.ts.map +0 -1
- package/dist/skill-loader.js +0 -94
- package/dist/skill-loader.js.map +0 -1
- package/dist/status-note.d.ts +0 -62
- package/dist/status-note.d.ts.map +0 -1
- package/dist/status-note.js +0 -86
- package/dist/status-note.js.map +0 -1
- package/dist/structured-output.d.ts +0 -62
- package/dist/structured-output.d.ts.map +0 -1
- package/dist/structured-output.js +0 -113
- package/dist/structured-output.js.map +0 -1
- package/dist/types.d.ts +0 -372
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
- package/dist/ui/agent-mention.d.ts +0 -83
- package/dist/ui/agent-mention.d.ts.map +0 -1
- package/dist/ui/agent-mention.js +0 -188
- package/dist/ui/agent-mention.js.map +0 -1
- package/dist/ui/agent-widget.d.ts +0 -241
- package/dist/ui/agent-widget.d.ts.map +0 -1
- package/dist/ui/agent-widget.js +0 -992
- package/dist/ui/agent-widget.js.map +0 -1
- package/dist/ui/ccstyle/diff/ansi-utils.d.ts +0 -11
- package/dist/ui/ccstyle/diff/ansi-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/ansi-utils.js +0 -145
- package/dist/ui/ccstyle/diff/ansi-utils.js.map +0 -1
- package/dist/ui/ccstyle/diff/diff-presentation.d.ts +0 -12
- package/dist/ui/ccstyle/diff/diff-presentation.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/diff-presentation.js +0 -48
- package/dist/ui/ccstyle/diff/diff-presentation.js.map +0 -1
- package/dist/ui/ccstyle/diff/diff-renderer.d.ts +0 -46
- package/dist/ui/ccstyle/diff/diff-renderer.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/diff-renderer.js +0 -2049
- package/dist/ui/ccstyle/diff/diff-renderer.js.map +0 -1
- package/dist/ui/ccstyle/diff/line-width-safety.d.ts +0 -12
- package/dist/ui/ccstyle/diff/line-width-safety.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/line-width-safety.js +0 -58
- package/dist/ui/ccstyle/diff/line-width-safety.js.map +0 -1
- package/dist/ui/ccstyle/diff/render-utils.d.ts +0 -6
- package/dist/ui/ccstyle/diff/render-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/render-utils.js +0 -25
- package/dist/ui/ccstyle/diff/render-utils.js.map +0 -1
- package/dist/ui/ccstyle/diff/shiki-highlight.d.ts +0 -19
- package/dist/ui/ccstyle/diff/shiki-highlight.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/shiki-highlight.js +0 -85
- package/dist/ui/ccstyle/diff/shiki-highlight.js.map +0 -1
- package/dist/ui/ccstyle/diff/types.d.ts +0 -22
- package/dist/ui/ccstyle/diff/types.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/types.js +0 -10
- package/dist/ui/ccstyle/diff/types.js.map +0 -1
- package/dist/ui/ccstyle/diff/write-display-utils.d.ts +0 -2
- package/dist/ui/ccstyle/diff/write-display-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/write-display-utils.js +0 -12
- package/dist/ui/ccstyle/diff/write-display-utils.js.map +0 -1
- package/dist/ui/ccstyle/tool-renderer.d.ts +0 -17
- package/dist/ui/ccstyle/tool-renderer.d.ts.map +0 -1
- package/dist/ui/ccstyle/tool-renderer.js +0 -74
- package/dist/ui/ccstyle/tool-renderer.js.map +0 -1
- package/dist/ui/ccstyle/tool-result.d.ts +0 -44
- package/dist/ui/ccstyle/tool-result.d.ts.map +0 -1
- package/dist/ui/ccstyle/tool-result.js +0 -423
- package/dist/ui/ccstyle/tool-result.js.map +0 -1
- package/dist/ui/conversation-blocks.d.ts +0 -46
- package/dist/ui/conversation-blocks.d.ts.map +0 -1
- package/dist/ui/conversation-blocks.js +0 -313
- package/dist/ui/conversation-blocks.js.map +0 -1
- package/dist/ui/conversation-nvim.d.ts +0 -8
- package/dist/ui/conversation-nvim.d.ts.map +0 -1
- package/dist/ui/conversation-nvim.js +0 -117
- package/dist/ui/conversation-nvim.js.map +0 -1
- package/dist/ui/conversation-role.d.ts +0 -13
- package/dist/ui/conversation-role.d.ts.map +0 -1
- package/dist/ui/conversation-role.js +0 -39
- package/dist/ui/conversation-role.js.map +0 -1
- package/dist/ui/conversation-search.d.ts +0 -39
- package/dist/ui/conversation-search.d.ts.map +0 -1
- package/dist/ui/conversation-search.js +0 -124
- package/dist/ui/conversation-search.js.map +0 -1
- package/dist/ui/conversation-timeline.d.ts +0 -102
- package/dist/ui/conversation-timeline.d.ts.map +0 -1
- package/dist/ui/conversation-timeline.js +0 -555
- package/dist/ui/conversation-timeline.js.map +0 -1
- package/dist/ui/conversation-viewer.d.ts +0 -138
- package/dist/ui/conversation-viewer.d.ts.map +0 -1
- package/dist/ui/conversation-viewer.js +0 -1175
- package/dist/ui/conversation-viewer.js.map +0 -1
- package/dist/ui/schedule-menu.d.ts +0 -17
- package/dist/ui/schedule-menu.d.ts.map +0 -1
- package/dist/ui/schedule-menu.js +0 -95
- package/dist/ui/schedule-menu.js.map +0 -1
- package/dist/ui/select-item.d.ts +0 -28
- package/dist/ui/select-item.d.ts.map +0 -1
- package/dist/ui/select-item.js +0 -35
- package/dist/ui/select-item.js.map +0 -1
- package/dist/ui/viewer-keys.d.ts +0 -21
- package/dist/ui/viewer-keys.d.ts.map +0 -1
- package/dist/ui/viewer-keys.js +0 -18
- package/dist/ui/viewer-keys.js.map +0 -1
- package/dist/ui/workflow-card.d.ts +0 -176
- package/dist/ui/workflow-card.d.ts.map +0 -1
- package/dist/ui/workflow-card.js +0 -333
- package/dist/ui/workflow-card.js.map +0 -1
- package/dist/ui/workflow-dialog.d.ts +0 -306
- package/dist/ui/workflow-dialog.d.ts.map +0 -1
- package/dist/ui/workflow-dialog.js +0 -844
- package/dist/ui/workflow-dialog.js.map +0 -1
- package/dist/ui/workflow-menu.d.ts +0 -42
- package/dist/ui/workflow-menu.d.ts.map +0 -1
- package/dist/ui/workflow-menu.js +0 -127
- package/dist/ui/workflow-menu.js.map +0 -1
- package/dist/usage.d.ts +0 -136
- package/dist/usage.d.ts.map +0 -1
- package/dist/usage.js +0 -121
- package/dist/usage.js.map +0 -1
- package/dist/workflow/collisions.d.ts +0 -96
- package/dist/workflow/collisions.d.ts.map +0 -1
- package/dist/workflow/collisions.js +0 -89
- package/dist/workflow/collisions.js.map +0 -1
- package/dist/workflow/entry.d.ts +0 -33
- package/dist/workflow/entry.d.ts.map +0 -1
- package/dist/workflow/entry.js +0 -30
- package/dist/workflow/entry.js.map +0 -1
- package/dist/workflow/host.d.ts +0 -63
- package/dist/workflow/host.d.ts.map +0 -1
- package/dist/workflow/host.js +0 -363
- package/dist/workflow/host.js.map +0 -1
- package/dist/workflow/journal.d.ts +0 -98
- package/dist/workflow/journal.d.ts.map +0 -1
- package/dist/workflow/journal.js +0 -121
- package/dist/workflow/journal.js.map +0 -1
- package/dist/workflow/json-schema.d.ts +0 -52
- package/dist/workflow/json-schema.d.ts.map +0 -1
- package/dist/workflow/json-schema.js +0 -112
- package/dist/workflow/json-schema.js.map +0 -1
- package/dist/workflow/meta.d.ts +0 -68
- package/dist/workflow/meta.d.ts.map +0 -1
- package/dist/workflow/meta.js +0 -318
- package/dist/workflow/meta.js.map +0 -1
- package/dist/workflow/progress.d.ts +0 -225
- package/dist/workflow/progress.d.ts.map +0 -1
- package/dist/workflow/progress.js +0 -362
- package/dist/workflow/progress.js.map +0 -1
- package/dist/workflow/runtime.d.ts +0 -335
- package/dist/workflow/runtime.d.ts.map +0 -1
- package/dist/workflow/runtime.js +0 -831
- package/dist/workflow/runtime.js.map +0 -1
- package/dist/workflow/saved.d.ts +0 -91
- package/dist/workflow/saved.d.ts.map +0 -1
- package/dist/workflow/saved.js +0 -204
- package/dist/workflow/saved.js.map +0 -1
- package/dist/workflow/task.d.ts +0 -137
- package/dist/workflow/task.d.ts.map +0 -1
- package/dist/workflow/task.js +0 -208
- package/dist/workflow/task.js.map +0 -1
- package/dist/workflow/tool-description.d.ts +0 -39
- package/dist/workflow/tool-description.d.ts.map +0 -1
- package/dist/workflow/tool-description.js +0 -200
- package/dist/workflow/tool-description.js.map +0 -1
- package/dist/workflow/worker-source.d.ts +0 -48
- package/dist/workflow/worker-source.d.ts.map +0 -1
- package/dist/workflow/worker-source.js +0 -779
- package/dist/workflow/worker-source.js.map +0 -1
- package/dist/worktree.d.ts +0 -53
- package/dist/worktree.d.ts.map +0 -1
- package/dist/worktree.js +0 -165
- package/dist/worktree.js.map +0 -1
- package/dist/write-execution.d.ts +0 -42
- package/dist/write-execution.d.ts.map +0 -1
- package/dist/write-execution.js +0 -138
- package/dist/write-execution.js.map +0 -1
- package/dist/xml.d.ts +0 -11
- package/dist/xml.d.ts.map +0 -1
- package/dist/xml.js +0 -13
- package/dist/xml.js.map +0 -1
- package/src/abortable.ts +0 -43
- package/src/agent-color.ts +0 -161
- package/src/agent-file-toggle.ts +0 -269
- package/src/child-context.ts +0 -15
- package/src/mention-clone.ts +0 -196
- package/src/mention.ts +0 -141
- package/src/model-scope.ts +0 -70
- package/src/nested-tools.ts +0 -424
- package/src/structured-output.ts +0 -130
- package/src/ui/agent-mention.ts +0 -216
- package/src/ui/select-item.ts +0 -45
- package/src/ui/workflow-card.ts +0 -470
- package/src/ui/workflow-dialog.ts +0 -1115
- package/src/ui/workflow-menu.ts +0 -166
- package/src/workflow/collisions.ts +0 -123
- package/src/workflow/entry.ts +0 -47
- package/src/workflow/host.ts +0 -403
- package/src/workflow/journal.ts +0 -164
- package/src/workflow/json-schema.ts +0 -128
- package/src/workflow/meta.ts +0 -325
- package/src/workflow/progress.ts +0 -550
- package/src/workflow/runtime.ts +0 -1219
- package/src/workflow/saved.ts +0 -217
- package/src/workflow/task.ts +0 -302
- package/src/workflow/tool-description.ts +0 -200
- package/src/workflow/worker-source.ts +0 -781
- package/src/xml.ts +0 -13
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as CodingAgent from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import type { MarkdownOptions, MarkdownTheme } from "@earendil-works/pi-tui";
|
|
4
3
|
import {
|
|
5
4
|
type Component,
|
|
6
5
|
Markdown,
|
|
6
|
+
Text,
|
|
7
7
|
type TUI,
|
|
8
8
|
type TuiMouseEvent,
|
|
9
9
|
truncateToWidth,
|
|
10
|
-
wrapTextWithAnsi,
|
|
11
10
|
} from "@earendil-works/pi-tui";
|
|
12
|
-
import type { AgentRecord
|
|
11
|
+
import type { AgentRecord } from "../types.js";
|
|
13
12
|
import type { Theme } from "./agent-widget.js";
|
|
14
13
|
import { showMoreHintText } from "./ccstyle/diff/render-utils.js";
|
|
15
14
|
import {
|
|
@@ -74,7 +73,6 @@ export interface ConversationTimelineChange {
|
|
|
74
73
|
export interface ConversationTimelineOptions {
|
|
75
74
|
cwd?: string;
|
|
76
75
|
record?: AgentRecord;
|
|
77
|
-
markdownMode?: () => ViewerMarkdownMode;
|
|
78
76
|
onChange?: (change: ConversationTimelineChange) => void;
|
|
79
77
|
}
|
|
80
78
|
|
|
@@ -82,60 +80,12 @@ function safeWidth(width: number): number {
|
|
|
82
80
|
return Math.max(1, Math.floor(Number.isFinite(width) ? width : 1));
|
|
83
81
|
}
|
|
84
82
|
|
|
85
|
-
const MARKDOWN_OPTIONS: MarkdownOptions = {
|
|
86
|
-
preserveOrderedListMarkers: true,
|
|
87
|
-
preserveBackslashEscapes: true,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
function fallbackMarkdownTheme(theme: Theme): MarkdownTheme {
|
|
91
|
-
const sgr = (on: number, off: number) => (text: string) => `\x1b[${on}m${text}\x1b[${off}m`;
|
|
92
|
-
return {
|
|
93
|
-
heading: text => theme.bold(theme.fg("accent", text)),
|
|
94
|
-
link: text => theme.fg("accent", text),
|
|
95
|
-
linkUrl: text => theme.fg("muted", text),
|
|
96
|
-
code: text => theme.fg("muted", text),
|
|
97
|
-
codeBlock: text => theme.fg("muted", text),
|
|
98
|
-
codeBlockBorder: text => theme.fg("dim", text),
|
|
99
|
-
quote: text => theme.fg("muted", text),
|
|
100
|
-
quoteBorder: text => theme.fg("dim", text),
|
|
101
|
-
hr: text => theme.fg("dim", text),
|
|
102
|
-
listBullet: text => theme.fg("accent", text),
|
|
103
|
-
bold: text => theme.bold(text),
|
|
104
|
-
italic: sgr(3, 23),
|
|
105
|
-
underline: sgr(4, 24),
|
|
106
|
-
strikethrough: sgr(9, 29),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function resolveMarkdownTheme(theme: Theme): MarkdownTheme {
|
|
111
|
-
try {
|
|
112
|
-
const markdownTheme = getMarkdownTheme();
|
|
113
|
-
markdownTheme.heading("probe");
|
|
114
|
-
return markdownTheme;
|
|
115
|
-
} catch {
|
|
116
|
-
return fallbackMarkdownTheme(theme);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
83
|
function resultContent(result: ConversationToolResultSnapshot): Array<Record<string, unknown>> {
|
|
121
84
|
if (Array.isArray(result.content)) return result.content as Array<Record<string, unknown>>;
|
|
122
85
|
if (typeof result.content === "string") return [{ type: "text", text: result.content }];
|
|
123
86
|
return [];
|
|
124
87
|
}
|
|
125
88
|
|
|
126
|
-
const RESULT_MAX_CHARS = 16_000;
|
|
127
|
-
|
|
128
|
-
function humanCount(n: number): string {
|
|
129
|
-
if (n < 1_000) return `${n}`;
|
|
130
|
-
const thousands = n < 999_950;
|
|
131
|
-
const value = thousands ? n / 1_000 : n / 1_000_000;
|
|
132
|
-
return `${value.toFixed(1).replace(/\.0$/, "")}${thousands ? "k" : "M"}`;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function truncationNote(elided: number): string {
|
|
136
|
-
return `... (truncated, ${humanCount(elided)} more character${elided === 1 ? "" : "s"})`;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
89
|
function fallbackToolLines(block: ConversationBlock, width: number, expanded = false, hovered = false, theme?: Theme): string[] {
|
|
140
90
|
const summary = block.toolLine || block.fullText || block.toolName || "tool";
|
|
141
91
|
const output = block.toolResult
|
|
@@ -223,8 +173,6 @@ export class ConversationTimeline implements Component {
|
|
|
223
173
|
private lastClickedToolCallId: string | undefined;
|
|
224
174
|
private lastClickedPoint: { x: number; y: number } | undefined;
|
|
225
175
|
private toolComponents = new Map<string, Component & { handleMouse?: (event: TuiMouseEvent) => unknown }>();
|
|
226
|
-
private markdownCache = new WeakMap<object, { markdown: Markdown; text: string; failed?: boolean }>();
|
|
227
|
-
private lastWidth = 0;
|
|
228
176
|
private snapshot: ConversationTimelineSnapshot = {
|
|
229
177
|
lines: [],
|
|
230
178
|
messageStarts: [],
|
|
@@ -233,6 +181,7 @@ export class ConversationTimeline implements Component {
|
|
|
233
181
|
blockSpans: [],
|
|
234
182
|
toolSpans: [],
|
|
235
183
|
};
|
|
184
|
+
private lastWidth = 0;
|
|
236
185
|
|
|
237
186
|
constructor(
|
|
238
187
|
private readonly tui: TUI,
|
|
@@ -274,11 +223,6 @@ export class ConversationTimeline implements Component {
|
|
|
274
223
|
return this.showTools;
|
|
275
224
|
}
|
|
276
225
|
|
|
277
|
-
setMarkdownMode(mode: () => ViewerMarkdownMode): void {
|
|
278
|
-
this.options.markdownMode = mode;
|
|
279
|
-
this.invalidate();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
226
|
setFocusedToolCallId(id: string | undefined): void {
|
|
283
227
|
// Focus changes are view state. The rendered rows do not change, so keep
|
|
284
228
|
// the snapshot and its Markdown/tool output cache intact.
|
|
@@ -323,6 +267,8 @@ export class ConversationTimeline implements Component {
|
|
|
323
267
|
|
|
324
268
|
render(width: number): string[] {
|
|
325
269
|
const requestedWidth = safeWidth(width);
|
|
270
|
+
if (this.lastWidth === requestedWidth) return this.snapshot.lines.map((line) => line.text);
|
|
271
|
+
|
|
326
272
|
const lines: TimelineRenderLine[] = [];
|
|
327
273
|
const messageStarts: number[] = [];
|
|
328
274
|
const messageBlocks: ConversationBlock[] = [];
|
|
@@ -377,12 +323,26 @@ export class ConversationTimeline implements Component {
|
|
|
377
323
|
continue;
|
|
378
324
|
}
|
|
379
325
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
326
|
+
try {
|
|
327
|
+
const markdown = new Markdown(block.markdown || "∅", 2, 0, getMarkdownTheme(), {
|
|
328
|
+
color: (text) => this.theme.fg(
|
|
329
|
+
block.role === "user" ? "userMessageText" : block.role === "meta" ? "muted" : "text",
|
|
330
|
+
text,
|
|
331
|
+
),
|
|
332
|
+
});
|
|
333
|
+
for (const line of markdown.render(requestedWidth)) {
|
|
334
|
+
lines.push({ text: truncateToWidth(line, requestedWidth), plain: stripAnsi(line), blockIndex, railable: true });
|
|
335
|
+
}
|
|
336
|
+
} catch {
|
|
337
|
+
try {
|
|
338
|
+
for (const line of new Text(block.markdown || "∅").render(requestedWidth)) {
|
|
339
|
+
lines.push({ text: truncateToWidth(line, requestedWidth), plain: stripAnsi(line), blockIndex, railable: true });
|
|
340
|
+
}
|
|
341
|
+
} catch {
|
|
342
|
+
for (const line of (block.markdown || "∅").split("\n")) {
|
|
343
|
+
lines.push({ text: truncateToWidth(line, requestedWidth), plain: line, blockIndex, railable: true });
|
|
344
|
+
}
|
|
345
|
+
}
|
|
386
346
|
}
|
|
387
347
|
blockSpans.push({ blockIndex: snapshotBlockIndex, startLine: blockStartLine, height: lines.length - blockStartLine });
|
|
388
348
|
}
|
|
@@ -393,13 +353,6 @@ export class ConversationTimeline implements Component {
|
|
|
393
353
|
}
|
|
394
354
|
|
|
395
355
|
private renderToolLines(block: ConversationBlock, width: number): { rendered: string[]; hintLine: number } {
|
|
396
|
-
const mode = this.options.markdownMode?.() ?? "assistant";
|
|
397
|
-
if (block.toolResult && (mode === "all" || block.toolArguments === undefined)) {
|
|
398
|
-
return {
|
|
399
|
-
rendered: mode === "all" ? this.renderToolMarkdownLines(block, width) : this.renderToolRawLines(block, width),
|
|
400
|
-
hintLine: -1,
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
356
|
const id = block.toolCallId;
|
|
404
357
|
let component: (Component & { handleMouse?: (event: TuiMouseEvent) => unknown }) | undefined;
|
|
405
358
|
if (id) {
|
|
@@ -446,73 +399,6 @@ export class ConversationTimeline implements Component {
|
|
|
446
399
|
return { rendered, hintLine };
|
|
447
400
|
}
|
|
448
401
|
|
|
449
|
-
private toolOutputText(block: ConversationBlock): string {
|
|
450
|
-
const output = block.toolResult ? resultContent(block.toolResult)
|
|
451
|
-
.filter(item => item.type === "text" && typeof item.text === "string")
|
|
452
|
-
.map(item => item.text as string)
|
|
453
|
-
.join("\n") : "";
|
|
454
|
-
return output || block.fullText || block.toolLine || "(no output)";
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
private renderToolRawLines(block: ConversationBlock, width: number): string[] {
|
|
458
|
-
const source = this.toolOutputText(block);
|
|
459
|
-
const capped = source.length > RESULT_MAX_CHARS
|
|
460
|
-
? `${source.slice(0, RESULT_MAX_CHARS)}\n${truncationNote(source.length - RESULT_MAX_CHARS)}`
|
|
461
|
-
: source;
|
|
462
|
-
try {
|
|
463
|
-
return wrapTextWithAnsi(capped, width).map(line => this.theme.fg("dim", truncateToWidth(line, width)));
|
|
464
|
-
} catch {
|
|
465
|
-
return capped.split("\n").map(line => this.theme.fg("dim", truncateToWidth(line, width)));
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
private renderToolMarkdownLines(block: ConversationBlock, width: number): string[] {
|
|
470
|
-
const source = this.toolOutputText(block);
|
|
471
|
-
if (source.length <= RESULT_MAX_CHARS) return this.renderMarkdown(block, source, width, true);
|
|
472
|
-
const prefix = source.slice(0, RESULT_MAX_CHARS);
|
|
473
|
-
return [
|
|
474
|
-
...this.renderMarkdown(block, prefix, width, true),
|
|
475
|
-
this.theme.fg("dim", truncationNote(source.length - RESULT_MAX_CHARS)),
|
|
476
|
-
];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
private renderMarkdown(block: ConversationBlock, text: string, width: number, dim: boolean): string[] {
|
|
480
|
-
let entry = this.markdownCache.get(block);
|
|
481
|
-
if (!entry) {
|
|
482
|
-
const defaultStyle = {
|
|
483
|
-
color: (value: string) => this.theme.fg(
|
|
484
|
-
dim ? "dim" : block.role === "user" ? "userMessageText" : block.role === "meta" ? "muted" : "text",
|
|
485
|
-
value,
|
|
486
|
-
),
|
|
487
|
-
};
|
|
488
|
-
entry = {
|
|
489
|
-
markdown: new Markdown(text, 0, 0, resolveMarkdownTheme(this.theme), defaultStyle, MARKDOWN_OPTIONS),
|
|
490
|
-
text,
|
|
491
|
-
};
|
|
492
|
-
this.markdownCache.set(block, entry);
|
|
493
|
-
} else if (entry.text !== text) {
|
|
494
|
-
const shouldRetry = !text.startsWith(entry.text);
|
|
495
|
-
entry.markdown.setText(text);
|
|
496
|
-
entry.text = text;
|
|
497
|
-
if (shouldRetry) entry.failed = false;
|
|
498
|
-
}
|
|
499
|
-
if (entry.failed) return dim ? this.renderToolRawLines(block, width) : this.renderLiteralText(text, width);
|
|
500
|
-
try {
|
|
501
|
-
return entry.markdown.render(width).map(line => truncateToWidth(line, width));
|
|
502
|
-
} catch {
|
|
503
|
-
entry.failed = true;
|
|
504
|
-
return dim ? this.renderToolRawLines(block, width) : this.renderLiteralText(text, width);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
private renderLiteralText(text: string, width: number): string[] {
|
|
509
|
-
try {
|
|
510
|
-
return wrapTextWithAnsi(text || "∅", width).map(line => truncateToWidth(line, width));
|
|
511
|
-
} catch {
|
|
512
|
-
return text.split("\n").map(line => truncateToWidth(line, width));
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
402
|
/**
|
|
517
403
|
* Hover only changes styling in a tool card. Re-render those rows in place
|
|
518
404
|
* and leave the Markdown rows and their spans untouched.
|