@linxiraos/pi-tui 1.3.2 → 1.4.1

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.
Files changed (116) hide show
  1. package/CHANGELOG.md +181 -181
  2. package/dist/types/apps/session-picker.d.ts +13 -1
  3. package/dist/types/autocomplete.d.ts +6 -0
  4. package/dist/types/components/sparkline.d.ts +34 -0
  5. package/dist/types/index.d.ts +1 -0
  6. package/dist/types/native/describe.d.ts +7 -1
  7. package/dist/types/native/overlay.d.ts +2 -0
  8. package/dist/types/native/tone.d.ts +2 -0
  9. package/dist/types/overlays/agent-hub.d.ts +3 -3
  10. package/dist/types/overlays/approval-dialog.d.ts +15 -1
  11. package/dist/types/overlays/jobs-panel.d.ts +3 -0
  12. package/dist/types/overlays/model-browser.d.ts +1 -1
  13. package/dist/types/overlays/resume-picker.d.ts +293 -0
  14. package/dist/types/overlays/resume-tree.d.ts +353 -0
  15. package/dist/types/overlays/session-selector.d.ts +22 -4
  16. package/dist/types/render/output-block.d.ts +2 -0
  17. package/dist/types/render/tool-card.d.ts +2 -0
  18. package/dist/types/sixel.d.ts +28 -0
  19. package/dist/types/status-line/host.d.ts +3 -0
  20. package/dist/types/terminal-capabilities.d.ts +6 -1
  21. package/dist/types/tools/bash.d.ts +2 -0
  22. package/dist/types/tools/default-renderer.d.ts +3 -0
  23. package/dist/types/tools/eval.d.ts +9 -8
  24. package/dist/types/tools/hub.d.ts +3 -1
  25. package/dist/types/tools/irc.d.ts +11 -1
  26. package/dist/types/tools/job-widget.d.ts +226 -0
  27. package/dist/types/tools/json-tree.d.ts +2 -0
  28. package/dist/types/tools/line-ranges.d.ts +8 -1
  29. package/dist/types/tools/mcp.d.ts +23 -0
  30. package/dist/types/tools/output-meta.d.ts +1 -1
  31. package/dist/types/tools/read.d.ts +8 -2
  32. package/dist/types/tools/renderer.d.ts +8 -2
  33. package/dist/types/tools/result-card.d.ts +1 -1
  34. package/dist/types/tools/streaming-output.d.ts +1 -0
  35. package/dist/types/tools/task.d.ts +12 -0
  36. package/dist/types/tools/wait.d.ts +11 -0
  37. package/package.json +9 -9
  38. package/src/apps/session-picker.ts +20 -2
  39. package/src/autocomplete.d.ts +6 -0
  40. package/src/autocomplete.ts +21 -6
  41. package/src/chat/skill-message.ts +16 -17
  42. package/src/chat/tool-execution.ts +35 -0
  43. package/src/chrome/transcript-container.ts +85 -13
  44. package/src/components/editor.ts +17 -7
  45. package/src/components/image.ts +5 -4
  46. package/src/components/markdown.ts +11 -3
  47. package/src/components/sparkline.d.ts +34 -0
  48. package/src/components/sparkline.ts +89 -0
  49. package/src/index.d.ts +1 -0
  50. package/src/index.ts +1 -0
  51. package/src/native/backend.ts +32 -6
  52. package/src/native/describe.d.ts +7 -1
  53. package/src/native/describe.ts +18 -1
  54. package/src/native/overlay.d.ts +2 -0
  55. package/src/native/overlay.ts +3 -0
  56. package/src/native/tone.d.ts +2 -0
  57. package/src/native/tone.ts +22 -0
  58. package/src/overlays/agent-hub.ts +14 -10
  59. package/src/overlays/agent-transcript-viewer.ts +2 -2
  60. package/src/overlays/agents-hub.ts +2 -1
  61. package/src/overlays/approval-dialog.ts +59 -13
  62. package/src/overlays/hub-frame.ts +2 -1
  63. package/src/overlays/jobs-panel.ts +24 -2
  64. package/src/overlays/model-browser.ts +3 -0
  65. package/src/overlays/model-hub.ts +2 -1
  66. package/src/overlays/resume-picker.ts +706 -0
  67. package/src/overlays/resume-tree.ts +1901 -0
  68. package/src/overlays/session-selector.ts +579 -39
  69. package/src/prompt/attachment-chips.ts +1 -1
  70. package/src/render/output-block.d.ts +2 -0
  71. package/src/render/output-block.ts +25 -12
  72. package/src/render/tool-card.d.ts +2 -0
  73. package/src/render/tool-card.ts +6 -0
  74. package/src/sixel.d.ts +28 -0
  75. package/src/sixel.ts +185 -0
  76. package/src/status-line/component.ts +19 -2
  77. package/src/status-line/host.ts +3 -0
  78. package/src/terminal-capabilities.d.ts +6 -1
  79. package/src/terminal-capabilities.ts +54 -3
  80. package/src/theme/symbols.ts +5 -3
  81. package/src/tools/bash.d.ts +2 -0
  82. package/src/tools/bash.ts +25 -9
  83. package/src/tools/default-renderer.d.ts +3 -0
  84. package/src/tools/default-renderer.ts +54 -17
  85. package/src/tools/eval.d.ts +9 -8
  86. package/src/tools/eval.ts +32 -14
  87. package/src/tools/find.ts +4 -5
  88. package/src/tools/glob.ts +4 -6
  89. package/src/tools/grep.ts +2 -4
  90. package/src/tools/hub.ts +4 -1
  91. package/src/tools/irc.d.ts +11 -1
  92. package/src/tools/irc.ts +11 -1
  93. package/src/tools/job-widget.d.ts +226 -0
  94. package/src/tools/job-widget.ts +1036 -0
  95. package/src/tools/json-tree.d.ts +2 -0
  96. package/src/tools/json-tree.ts +8 -0
  97. package/src/tools/line-ranges.d.ts +8 -1
  98. package/src/tools/line-ranges.ts +23 -13
  99. package/src/tools/mcp.d.ts +23 -0
  100. package/src/tools/mcp.ts +44 -1
  101. package/src/tools/output-meta.d.ts +1 -1
  102. package/src/tools/output-meta.ts +1 -1
  103. package/src/tools/proc-render.ts +1 -0
  104. package/src/tools/read.d.ts +8 -2
  105. package/src/tools/read.ts +64 -21
  106. package/src/tools/renderer.d.ts +8 -2
  107. package/src/tools/renderer.ts +8 -2
  108. package/src/tools/result-card.d.ts +1 -1
  109. package/src/tools/result-card.ts +1 -2
  110. package/src/tools/streaming-output.d.ts +1 -0
  111. package/src/tools/streaming-output.ts +11 -9
  112. package/src/tools/task.d.ts +12 -0
  113. package/src/tools/task.ts +25 -1
  114. package/src/tools/wait.d.ts +11 -0
  115. package/src/tools/wait.ts +296 -147
  116. package/src/tui.ts +45 -5
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Live widgets for background jobs: the rendered state of what a job is
3
+ * doing (a benchmark's requests/s over time, tests passed per model, CI jobs
4
+ * green so far), shown in the `wait` card, the HUD's jobs pill and the jobs
5
+ * sheet.
6
+ *
7
+ * A widget is data, not code. In coding-agent, a cheap model writes a
8
+ * `JobWidgetSpec` once per job (rules that pull numbers out of the job's
9
+ * output streams, and the blocks to draw them with); the job-widgets runtime
10
+ * then applies those rules to every new line and recomputes a
11
+ * {@link JobWidgetView}. Renderers here draw that view as TSP nodes (Tern) or
12
+ * ANSI lines, and never see a rule or a regex.
13
+ */
14
+ import type { TspPropNode, TspSpan, TspTone } from "@linxiraos/pi-wire";
15
+ import type { NativeNode } from "../native/node";
16
+ import type { Theme } from "../theme/theme";
17
+ /** Where a widget's view stands. */
18
+ export type JobWidgetState =
19
+ /** The cheap model is writing the spec; the view holds the model-free fallback meanwhile. */
20
+ "authoring"
21
+ /** The spec's rules drive the view. */
22
+ | "live"
23
+ /** No spec (no model, authoring failed, nothing to read yet): last line and rates only. */
24
+ | "fallback";
25
+ /** A formatted number with the direction it moved, for headlines and stats. */
26
+ export interface JobWidgetTrend {
27
+ /** `▲ 15%`, `▼ 3.2 ms`. */
28
+ text: string;
29
+ /** `success` when the move is toward `better`, `error` away from it, `muted` without a direction. */
30
+ tone: "success" | "error" | "muted";
31
+ }
32
+ /** The headline value: the one number a glance should take away (`186 tok/s`). */
33
+ export interface JobWidgetHeadline {
34
+ /** Formatted value with its unit. */
35
+ text: string;
36
+ /** What the value is, when the title does not already say it (`decode`, `p50`). */
37
+ label?: string;
38
+ trend?: JobWidgetTrend;
39
+ }
40
+ /** A time series drawn as columns, newest right, with optional reference lines. */
41
+ export interface JobWidgetSparkBlock {
42
+ kind: "spark";
43
+ /** What the series measures (`tok/s · nvfp4 b1`). */
44
+ label: string;
45
+ /** At most 48 values, oldest first, already downsampled. */
46
+ values: number[];
47
+ /** Domain of the chart; covers the values and every mark. */
48
+ min: number;
49
+ max: number;
50
+ /** Horizontal reference lines in value units (a target, a baseline). */
51
+ marks?: {
52
+ value: number;
53
+ label: string;
54
+ tone?: TspTone;
55
+ }[];
56
+ /** Latest value, formatted (`186 tok/s`). */
57
+ last: string;
58
+ /** Per-point tooltip text, same length as `values` (`12:04:31 · 186 tok/s`). */
59
+ tips?: string[];
60
+ tone?: TspTone;
61
+ }
62
+ /** One bar per key (a model, a shard): a value against a common maximum. */
63
+ export interface JobWidgetBarsBlock {
64
+ kind: "bars";
65
+ label: string;
66
+ items: {
67
+ label: string;
68
+ value: number;
69
+ text: string;
70
+ tone?: TspTone;
71
+ }[];
72
+ /** The value a full bar stands for. */
73
+ max: number;
74
+ }
75
+ /** Progress of a countable whole (`7/9 trials`). */
76
+ export interface JobWidgetMeterBlock {
77
+ kind: "meter";
78
+ label: string;
79
+ /** 0–1. */
80
+ value: number;
81
+ /** `7/9 trials`. */
82
+ text: string;
83
+ tone?: TspTone;
84
+ }
85
+ /** A few labelled numbers on one line (`p50 41 ms · p99 212 ms · errors 0`). */
86
+ export interface JobWidgetStatBlock {
87
+ kind: "stat";
88
+ items: {
89
+ label: string;
90
+ text: string;
91
+ tone?: TspTone;
92
+ trend?: JobWidgetTrend;
93
+ }[];
94
+ }
95
+ /** One cell per key with its latest state (CI jobs, shards, workers). */
96
+ export interface JobWidgetGridBlock {
97
+ kind: "grid";
98
+ label: string;
99
+ items: {
100
+ label: string;
101
+ text: string;
102
+ tone: TspTone;
103
+ }[];
104
+ }
105
+ /** The latest line a rule captured (the test now running, the current phase). */
106
+ export interface JobWidgetTextBlock {
107
+ kind: "text";
108
+ text: string;
109
+ }
110
+ export type JobWidgetBlock = JobWidgetSparkBlock | JobWidgetBarsBlock | JobWidgetMeterBlock | JobWidgetStatBlock | JobWidgetGridBlock | JobWidgetTextBlock;
111
+ /**
112
+ * Everything a renderer needs to draw one job's widget. Plain JSON: it rides
113
+ * on `JobSnapshot.widget` through `wait` progress updates and is persisted
114
+ * with the final `wait` result, so a sealed card redraws the last state after
115
+ * a session reload.
116
+ */
117
+ export interface JobWidgetView {
118
+ /** Short name of what is being watched (`verb-bench · 3 models`). */
119
+ title: string;
120
+ headline?: JobWidgetHeadline;
121
+ /** What the job is doing now: a subagent's stage, or the last line of output. */
122
+ stage?: string;
123
+ /** Top to bottom; the first block is the primary one, and compact views show only it. */
124
+ blocks: JobWidgetBlock[];
125
+ state: JobWidgetState;
126
+ /** Epoch ms of the newest data the view reflects. */
127
+ updatedAt: number;
128
+ }
129
+ /** A running job's widget, as the HUD and the status line list them. */
130
+ export interface JobWidgetEntry {
131
+ id: string;
132
+ type: JobTileType;
133
+ view: JobWidgetView;
134
+ }
135
+ /** What a glance at a widget reads: its headline, else the primary figure of its blocks. */
136
+ export interface JobWidgetGlance {
137
+ text: string;
138
+ label?: string;
139
+ trend?: JobWidgetTrend;
140
+ }
141
+ /** What one glance at the widget reads: the headline, else the latest figure of its first spark or meter. */
142
+ export declare function jobWidgetGlance(view: JobWidgetView): JobWidgetGlance | undefined;
143
+ /** The widget's first spark cut to its newest `points` values (the HUD's mini chart); undefined without data. */
144
+ export declare function jobWidgetSpark(view: JobWidgetView, points?: number): JobWidgetSparkBlock | undefined;
145
+ /** The entry whose live widget (one a spec drives) saw data last. */
146
+ export declare function latestJobWidget<T extends JobWidgetEntry>(entries: readonly T[]): T | undefined;
147
+ /** The widget as one plain line for tooltips: `verb-bench · 3 models — decode 186 tok/s ▲ 15%`. */
148
+ export declare function jobWidgetSummary(view: JobWidgetView): string;
149
+ /** Spans of a glance: muted label, strong number, toned trend. */
150
+ export declare function jobWidgetGlanceSpans(glance: JobWidgetGlance): TspSpan[];
151
+ /**
152
+ * A glance for the ANSI status line: the figure with its trend, then a
153
+ * `cells`-wide sparkline of the primary spark when there is one.
154
+ */
155
+ export declare function formatJobWidgetGlance(view: JobWidgetView, theme: Theme, cells?: number): string;
156
+ /**
157
+ * A job's whole widget as a TSP subtree (role `zeta.job.widget`), as the jobs
158
+ * sheet details it: a head row (title, stage, headline) over every block.
159
+ */
160
+ export declare function describeJobWidget(view: JobWidgetView): NativeNode;
161
+ /**
162
+ * The HUD jobs pill's hover card: up to four running jobs as tiles, then a
163
+ * count of the rest; undefined without widgets. Its tiles carry no clock:
164
+ * Tern draws the card only once hovered, and a clock drawn then would start
165
+ * from the last time the program wrote.
166
+ */
167
+ export declare function describeJobWidgetsHovercard(entries: readonly JobWidgetEntry[]): TspPropNode | undefined;
168
+ /** The HUD's mini chart: the newest values of the widget's first spark; undefined without one. */
169
+ export declare function describeJobWidgetMiniSpark(view: JobWidgetView): NativeNode | undefined;
170
+ /** Where a tiled job stands. */
171
+ export type JobTileStatus = "running" | "completed" | "failed" | "cancelled";
172
+ /** What kind of job a tile shows: a subagent (`task`) goes by its name, any other job by what it runs. */
173
+ export type JobTileType = "bash" | "task" | "eval";
174
+ /** One job as a tile draws it: who it is, how long it has run, and its widget when it has one. */
175
+ export interface JobTile {
176
+ id: string;
177
+ type: JobTileType;
178
+ status: JobTileStatus;
179
+ /** The job's label (a command): the title of a job that is no subagent, before a widget names it. */
180
+ label: string;
181
+ /** How long the job has run; a tile without it shows no clock. */
182
+ durationMs?: number;
183
+ /** Whether the job is live (its dot pulses, its clock runs); settled and sealed tiles freeze. */
184
+ live: boolean;
185
+ /** The job's widget; only a live one (a spec drives it) draws figures and charts, any lends its stage. */
186
+ widget?: JobWidgetView;
187
+ /** A task's own completion estimate (0–100), drawn as a ring. */
188
+ completionPercent?: number;
189
+ /** What the job is doing now, when its widget names nothing: a task's stage in its own words. */
190
+ stage?: string;
191
+ exitCode?: number;
192
+ }
193
+ /**
194
+ * Jobs as one frame of equal tiles (role `zeta.job.tiles`) that wraps onto
195
+ * more rows when the frame runs out of width.
196
+ */
197
+ export declare function describeJobTiles(tiles: readonly JobTile[]): NativeNode;
198
+ /**
199
+ * One job as a tile (role `zeta.job.tile`): a head line (status, name, id,
200
+ * a task's own completion estimate as a ring, clock), then what a live
201
+ * widget shows (the figure a glance takes away, its primary block, quiet
202
+ * lines of stats) and the stage. With nothing to chart, the stage is the
203
+ * tile's body.
204
+ */
205
+ export declare function describeJobTile(tile: JobTile): NativeNode;
206
+ /**
207
+ * A job's whole widget as terminal lines, each within `width` (capped at 80
208
+ * so bars stay next to their labels): the head line (title, stage, headline
209
+ * at the right), then every block under a shared label column.
210
+ */
211
+ export declare function renderJobWidgetLines(view: JobWidgetView, width: number, theme: Theme): string[];
212
+ /** How the ANSI wait card draws a tile. */
213
+ export interface JobTileLineOptions {
214
+ /** Opens the title line: the caller's status icon and type badge. */
215
+ lead: string;
216
+ /** Closes the title line at the right, after the figure: the duration. */
217
+ meta: string;
218
+ /** Every block rather than the primary one alone (an expanded card). */
219
+ full?: boolean;
220
+ }
221
+ /**
222
+ * A tile as terminal lines within `width`: the lead, name and id with the
223
+ * figure and meta at the right, then a live widget's primary block (every
224
+ * block when `full`) and dim lines of stats and stage, capped at 80 cells.
225
+ */
226
+ export declare function renderJobTileLines(tile: JobTile, width: number, theme: Theme, options: JobTileLineOptions): string[];