@oh-my-pi/pi-tui 18.8.9 → 18.9.0

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 (71) hide show
  1. package/CHANGELOG.md +32 -199
  2. package/dist/types/charts/chart-plan.d.ts +586 -10
  3. package/dist/types/charts/chart-svg.d.ts +31 -6
  4. package/dist/types/charts/table-data.d.ts +66 -3
  5. package/dist/types/chat/table-chart.d.ts +3 -2
  6. package/dist/types/chat/user-message.d.ts +12 -1
  7. package/dist/types/chrome/shared.d.ts +9 -0
  8. package/dist/types/chrome/transcript-container.d.ts +1 -0
  9. package/dist/types/components/editor.d.ts +6 -0
  10. package/dist/types/components/form.d.ts +1 -0
  11. package/dist/types/components/markdown.d.ts +7 -0
  12. package/dist/types/components/tree-view.d.ts +7 -0
  13. package/dist/types/loop-watchdog.d.ts +8 -7
  14. package/dist/types/overlays/agent-hub-projection.d.ts +4 -3
  15. package/dist/types/overlays/agent-hub-types.d.ts +9 -0
  16. package/dist/types/overlays/annotation-overlay.d.ts +2 -0
  17. package/dist/types/overlays/model-browser.d.ts +9 -1
  18. package/dist/types/overlays/settings-defs.d.ts +1 -0
  19. package/dist/types/overlays/usage-display.d.ts +3 -1
  20. package/dist/types/setup/scenes/types.d.ts +1 -0
  21. package/dist/types/status-line/component.d.ts +2 -0
  22. package/dist/types/status-line/host.d.ts +4 -1
  23. package/dist/types/status-line/types.d.ts +9 -0
  24. package/dist/types/terminal.d.ts +7 -0
  25. package/dist/types/theme/schema.d.ts +11 -2
  26. package/dist/types/theme/theme-class.d.ts +7 -0
  27. package/dist/types/tools/eval.d.ts +21 -2
  28. package/dist/types/tools/output-meta.d.ts +11 -1
  29. package/dist/types/tools/streaming-output.d.ts +9 -0
  30. package/package.json +9 -9
  31. package/src/charts/chart-plan.ts +4669 -95
  32. package/src/charts/chart-svg.ts +3971 -360
  33. package/src/charts/table-data.ts +1051 -44
  34. package/src/chat/assistant-message.ts +27 -9
  35. package/src/chat/chat-transcript-builder.ts +1 -3
  36. package/src/chat/table-chart.ts +7 -11
  37. package/src/chat/user-message.ts +40 -2
  38. package/src/chrome/shared.ts +53 -0
  39. package/src/chrome/transcript-container.ts +32 -9
  40. package/src/components/editor.ts +38 -5
  41. package/src/components/form.ts +8 -0
  42. package/src/components/markdown.ts +45 -2
  43. package/src/components/settings-list.ts +2 -0
  44. package/src/components/tree-view.ts +38 -8
  45. package/src/loop-watchdog.ts +18 -13
  46. package/src/overlays/agent-hub-projection.ts +51 -14
  47. package/src/overlays/agent-hub-types.ts +6 -0
  48. package/src/overlays/annotation-overlay.ts +2 -1
  49. package/src/overlays/model-browser.ts +43 -7
  50. package/src/overlays/model-hub.ts +12 -19
  51. package/src/overlays/settings-defs.ts +4 -3
  52. package/src/overlays/settings-selector.ts +10 -1
  53. package/src/overlays/tree-selector.ts +21 -16
  54. package/src/overlays/usage-display.ts +10 -4
  55. package/src/setup/scenes/model.ts +2 -1
  56. package/src/setup/scenes/types.ts +1 -0
  57. package/src/status-line/component.ts +53 -3
  58. package/src/status-line/host.ts +4 -1
  59. package/src/status-line/segments.ts +14 -5
  60. package/src/status-line/types.ts +10 -0
  61. package/src/terminal.ts +39 -4
  62. package/src/theme/schema-validation.ts +1 -0
  63. package/src/theme/schema.ts +14 -1
  64. package/src/theme/theme-class.ts +26 -1
  65. package/src/theme/theme-schema.json +5 -1
  66. package/src/tools/eval.ts +56 -16
  67. package/src/tools/output-meta.ts +23 -3
  68. package/src/tools/streaming-output.ts +29 -2
  69. package/src/tools/todo.ts +4 -1
  70. package/src/tui.ts +15 -6
  71. package/src/windows-input-mode.ts +8 -0
@@ -8,13 +8,37 @@
8
8
  *
9
9
  * Styled after Apple's charts and Tern's UI: a UI sans (Geist where Tern
10
10
  * provides it), muted labels, hairline gridlines that recede behind the
11
- * marks, bars and cells with rounded corners, smooth lines over a soft area
12
- * fill, dot legends. 13-unit labels land near the terminal's own glyph size
11
+ * marks, bars and cells with rounded corners, smooth lines (over a soft area
12
+ * fill where the axis starts at zero), dot legends, one hue across small
13
+ * multiples' columns with gray for context. 13-unit labels land near the terminal's own glyph size
13
14
  * at 16 user units per row; bolded table cells draw at full strength while
14
- * their neighbours recede.
15
+ * their neighbours recede. Grouped categories ({@link ChartSpec.groups}) name
16
+ * each group once beside its members, the groups parted by a gap; a name too
17
+ * long for its column wraps to two lines ({@link categoryLabels}). A few
18
+ * outliers far above the rest break a bar axis instead of flattening it
19
+ * ({@link outlierTier}); reference rows ({@link ChartSpec.reference}) draw a
20
+ * dashed rule through their group.
21
+ *
22
+ * Every chart opens with a header ({@link drawHeader}): the semibold title a
23
+ * planner set ({@link ChartSpec.title}, the one fact worth stating; its key
24
+ * figure in the accent), a muted
25
+ * note on how the data is encoded, and the series key right-aligned on the
26
+ * title's line when it fits. Marks size to
27
+ * the row count ({@link barMetrics}); strong heat cells and share segments
28
+ * print their figures in a theme-adaptive dark {@link ink}. Reusable
29
+ * annotation primitives — {@link band}, {@link referenceRule},
30
+ * {@link callout} — draw the {@link ChartSpec.annotations} a planner lays on.
31
+ *
32
+ * Axes tick on round steps in one unit (`0, 2, 4` for counts, `50s, 100s`,
33
+ * `25 GiB` where the table wrote binary sizes, thousands separated). Meaning
34
+ * layers on top: each contest's best value carries a quiet `best` tag (an
35
+ * outline in a heatmap), estimates (`~15`) among measured figures draw as
36
+ * dashed, faint bars ({@link barRect}), moves of a measure with a polarity read in `success`
37
+ * or `error` (transitions, factors, signed deltas), and status cells badge
38
+ * their row's name with a colored dot keyed under the chart.
15
39
  */
16
- import type { ChartSpec } from "./chart-plan.js";
17
- import type { Dimension } from "./table-data.js";
40
+ import { type ChartSpec } from "./chart-plan.js";
41
+ import { type Dimension } from "./table-data.js";
18
42
  /** A drawn chart: the SVG document and its size in user units. */
19
43
  export interface ChartSvg {
20
44
  readonly svg: string;
@@ -29,6 +53,7 @@ export declare function chartAlt(spec: ChartSpec): string;
29
53
  * A value in base units as an axis label: durations and sizes in the unit,
30
54
  * counts compacted under the suffix (`12k`, `3.4M`), that `magnitude` reads
31
55
  * best in — the value's own size by default, an axis' largest tick to keep
32
- * its labels in one unit.
56
+ * its labels in one unit. Sizes read in decimal units (`20 GB`), or binary
57
+ * ones (`16 GiB`) when `unit` is `iB`.
33
58
  */
34
59
  export declare function formatValue(value: number, dim: Dimension, unit: string, magnitude?: number): string;
@@ -43,10 +43,22 @@ export interface NumberCell {
43
43
  /** `a–b`: `b`, in the same base units. */
44
44
  readonly upper?: number;
45
45
  /**
46
- * `a/b`: `b`. {@link analyzeTable} reads a score (`12/12`, `154/160`) as the
47
- * percent of `b` reached; a pair (`85 / 147` under `Edit / read calls`) keeps `a`.
46
+ * `a/b`: `b`. {@link analyzeTable} reads a score (`12/12`, `154/160`, a mean
47
+ * like `0.6/4`) as the percent of `b` reached, unless its column also holds a
48
+ * plain fraction; a pair (`85 / 147` under `Edit / read calls`) keeps `a`.
48
49
  */
49
50
  readonly denominator?: number;
51
+ /**
52
+ * `a ± e` (`3.67s ± 0.69`, `~404ms ± 60`, `$0.72 (±0.16)`): `e`, in the same base units — the
53
+ * spread the table states around the value; {@link figure} then writes both (`3.67s ± 0.69`).
54
+ */
55
+ readonly error?: number;
56
+ /**
57
+ * A slash list of measurements in one unit (`79 / 124 µs`, `1,864 ms /
58
+ * 2,678 ms`, `**675ms** / 680ms`): every listed value, the first included,
59
+ * in base units, 2–4 of them. `value` is the first.
60
+ */
61
+ readonly values?: readonly number[];
50
62
  }
51
63
  /** A cell that is not a quantity. */
52
64
  export interface OtherCell {
@@ -75,17 +87,47 @@ export interface TableColumn {
75
87
  readonly mixed: boolean;
76
88
  /** Numeric cells are mostly scores out of a total (`12/12`), read as percent of it. */
77
89
  readonly scores: boolean;
90
+ /**
91
+ * Per row, the status its cell leads with ({@link cellStatus}), when most
92
+ * of the column's cells lead with one: a pass/fail or progress column.
93
+ */
94
+ readonly statuses?: readonly (Status | undefined)[];
78
95
  /** Every numeric data cell holds the same value: an echoed setting, not a measure. */
79
96
  readonly constant: boolean;
80
97
  /** Share of numeric cells written with an explicit sign. */
81
98
  readonly signedShare: number;
82
99
  /** Share of numeric cells written as `a → b`. */
83
100
  readonly arrowShare: number;
101
+ /**
102
+ * Index of the measure column this one restates, read from the values: a
103
+ * proportional copy (`pass` 33/38 beside `pass%` 87%, `Samples` beside `% of
104
+ * Total`, `Leverage vs $200` beside the cost) or a running total of it
105
+ * (`Offset` summing `Verts`). Such a column is never a measure of its own.
106
+ */
107
+ readonly restates?: number;
108
+ }
109
+ /**
110
+ * Measure columns that add up, read from the values: leaf `parts` summing to
111
+ * `whole` in every row (`Cached + Uncached input = Input`, `Input + Output =
112
+ * Total` → parts Cached, Uncached input, Output of Total), or — when not
113
+ * `exact` — parts falling within a `Total` column, the rest unlisted (`New +
114
+ * Edited ≤ Prose total`).
115
+ */
116
+ export interface Composition {
117
+ /** Column the parts make up; absent when only a judge says the parts form a whole. */
118
+ readonly whole: number | undefined;
119
+ /** Leaf part columns, in table order. */
120
+ readonly parts: readonly number[];
121
+ /** The parts sum to the whole within the written precision in every row. */
122
+ readonly exact: boolean;
84
123
  }
85
124
  /** A table read for charting. */
86
125
  export interface TableAnalysis {
87
126
  readonly columns: readonly TableColumn[];
88
- /** Category labels: the first text or temporal column, else a sequence or index column. */
127
+ /**
128
+ * Category labels: the first text or temporal column not made only of codes
129
+ * (`#2233`, `00`), else the first text column, else a sequence or index column.
130
+ */
89
131
  readonly label: TableColumn | undefined;
90
132
  /** Plottable measure columns, constant ones excluded. */
91
133
  readonly measures: readonly TableColumn[];
@@ -93,7 +135,21 @@ export interface TableAnalysis {
93
135
  readonly rows: readonly number[];
94
136
  /** Total/summary rows (`Total`, `Average`, …), kept out of the scale. */
95
137
  readonly totals: readonly number[];
138
+ /** Measure columns adding up to a whole, when the values show it. */
139
+ readonly composition?: Composition;
96
140
  }
141
+ /**
142
+ * What a status cell (`ok`, `FAIL`, `pending`, ✅) says about its row: `good`
143
+ * passed or landed, `bad` failed or broke, `warn` partly or flaky, `pending`
144
+ * not settled yet.
145
+ */
146
+ export type Status = "good" | "bad" | "warn" | "pending";
147
+ /**
148
+ * The status a cell's text leads with (`FAIL`, `✓ via mmdc`, `**pending**`,
149
+ * `1 ok`), or `undefined` for any other text. A count before the word
150
+ * (`3 ok`) still reads as the word's status.
151
+ */
152
+ export declare function cellStatus(text: string): Status | undefined;
97
153
  /**
98
154
  * Strip inline Markdown from a cell: links keep their text; bold, italics,
99
155
  * strikethrough, code spans and `<br>` keep their content.
@@ -106,6 +162,13 @@ export declare function plainCell(markdown: string): {
106
162
  export declare function parseCell(markdown: string): Cell;
107
163
  /** Read a table's columns and rows for charting. Cells are the raw Markdown of each cell. */
108
164
  export declare function analyzeTable(header: readonly string[], rows: readonly (readonly string[])[]): TableAnalysis;
165
+ /**
166
+ * Half the last written digit of `cell`, in base units (`6,313k` → 500,
167
+ * `38.5%` → 0.05): how far its value may sit from the exact quantity it
168
+ * rounds. A score (`33/38` read as percent) and a whole count written in full
169
+ * (`46`, `1,980`) are exact.
170
+ */
171
+ export declare function writtenSlack(cell: NumberCell): number;
109
172
  /** Strictly increasing or strictly decreasing. */
110
173
  export declare function isMonotonic(values: readonly number[]): boolean;
111
174
  /** Whether `cell` reads as a number. */
@@ -5,12 +5,13 @@ import type { ImageBudget } from "../components/image.js";
5
5
  import type { NativeNode } from "../native/node.js";
6
6
  import type { Component } from "../tui.js";
7
7
  /**
8
- * `smart`: a model picks the kind and columns of multi-series tables;
8
+ * `smart`: a model refines the local guess where meaning decides (kind,
9
+ * columns, row names, ordering, polarity, focus, title; see {@link shouldJudge});
9
10
  * `always`: the local best guess charts every table it reads as numeric;
10
11
  * `off`: tables stay tables.
11
12
  */
12
13
  export type TableChartMode = "smart" | "always" | "off";
13
- /** A multi-series table the host's planner picks a chart for. */
14
+ /** A table the host's planner picks a chart for ({@link shouldJudge}). */
14
15
  export interface TableChartRequest {
15
16
  /** The table's Markdown source. */
16
17
  readonly markdown: string;
@@ -1,3 +1,4 @@
1
+ import type { AnimationFrame, TranscriptPresentationTarget } from "../chrome/transcript-container.js";
1
2
  import { type Component, Container } from "../tui.js";
2
3
  import type { ImageContent } from "@oh-my-pi/pi-ai";
3
4
  import type { ReactionTarget } from "./reaction.js";
@@ -30,7 +31,7 @@ export declare function userBubbleColor(options?: UserBubbleOptions, tokenRegex?
30
31
  * (see {@link ReactionTarget}) drawn right-aligned in the bubble's top padding row;
31
32
  * a live-steered message carries a `*` marker left-aligned in the same row.
32
33
  */
33
- export declare class UserMessageComponent extends Container implements ReactionTarget {
34
+ export declare class UserMessageComponent extends Container implements ReactionTarget, TranscriptPresentationTarget {
34
35
  #private;
35
36
  constructor(text: string, options?: UserBubbleOptions);
36
37
  releaseRenderCaches(): void;
@@ -46,6 +47,16 @@ export declare class UserMessageComponent extends Container implements ReactionT
46
47
  describe(cx?: DescribeContext): NativeNode;
47
48
  /** Hover toolbar clicks: omp's own copy and rewind commands. */
48
49
  handleNativeEvent(event: NativeUiEvent): void;
50
+ /** Apply the transcript allocator's current viewport reservation. */
51
+ setTranscriptAllocation(rows: number, _frame?: AnimationFrame): void;
52
+ isTranscriptBlockFinalized(): boolean;
53
+ /**
54
+ * Single-row emergency representation for the overflow transcript layout:
55
+ * renders the first content line instead of the blank top padding row, and
56
+ * omits OSC 133 shell integration markers so moving live blocks across the
57
+ * viewport does not leave stale prompt marks on lines it no longer occupies.
58
+ */
59
+ renderTranscriptBlockEmergencyRow(width: number): string | undefined;
49
60
  render(width: number): readonly string[];
50
61
  }
51
62
  /**
@@ -1,5 +1,14 @@
1
1
  import type { TabBarTheme } from "../components/tab-bar.js";
2
2
  /** Compact single-line display text for statuses; unlike titles, collapse padding and trim. */
3
3
  export declare function sanitizeStatusText(text: string): string;
4
+ /**
5
+ * Like {@link sanitizeStatusText}, but keeps 7-bit SGR so extensions can colour
6
+ * `ctx.ui.setStatus` text. Every other escape (OSC links/titles, DCS/PM/APC,
7
+ * 7- and 8-bit CSI), C0/C1, lone surrogates, newlines and tabs are sanitized at
8
+ * least as strictly as in `sanitizeStatusText`; space runs collapse and edges
9
+ * trim (`String#trim` whitespace) by visible text, regardless of SGR placement.
10
+ * A styled result always ends with `\x1b[0m`.
11
+ */
12
+ export declare function sanitizeHookStatusText(input: string): string;
4
13
  /** Shared tab bar theme used by fullscreen overlays (settings, agent hub). */
5
14
  export declare function getTabBarTheme(): TabBarTheme;
@@ -63,6 +63,7 @@ export interface TranscriptViewportSpan {
63
63
  export declare class TranscriptContainer extends Container {
64
64
  #private;
65
65
  addChild(component: Component): void;
66
+ /** Removes `component` if {@link canRemoveBlock} allows it; otherwise does nothing. */
66
67
  removeChild(component: Component): void;
67
68
  clear(): void;
68
69
  setToolActivityVisible(visible: boolean): void;
@@ -149,6 +149,12 @@ export declare class Editor implements Component, Focusable {
149
149
  * cursor. The host styles it (ANSI allowed). Re-evaluated on every render, so hosts can derive
150
150
  * it from live state. */
151
151
  placeholder?: () => string | undefined;
152
+ /** Whole-message prediction for the next prompt, painted as ghost text after the cursor while
153
+ * the single-line buffer is a strict prefix of it, the cursor sits at its end, and no
154
+ * autocomplete is open. A shown prediction replaces the {@link placeholder}; Tab or Right inserts
155
+ * the rest without submitting. Must be a single line. Re-evaluated on every render, so hosts can
156
+ * derive it from live state. */
157
+ prediction?: () => string | undefined;
152
158
  constructor(theme: EditorTheme);
153
159
  /** Return bounded editor content, cursor, and transient child state for debug inspection. */
154
160
  debugState(): Record<string, unknown>;
@@ -44,6 +44,7 @@ export declare class FormField implements Component, Focusable, MouseRoutable {
44
44
  /** Label, description, details, preview, the control, error, summary, hint and footer as one column. */
45
45
  describe(_cx: DescribeContext): NativeNode;
46
46
  get focused(): boolean;
47
+ get hasError(): boolean;
47
48
  get debugChildren(): readonly Component[];
48
49
  set focused(value: boolean);
49
50
  setUseTerminalCursor(useTerminalCursor: boolean): void;
@@ -53,6 +53,13 @@ export declare function clearRenderCache(): void;
53
53
  export interface DefaultTextStyle {
54
54
  /** Foreground color function */
55
55
  color?: (text: string) => string;
56
+ /**
57
+ * The `color` foreground is prose-level: semantically-themed markdown spans
58
+ * (headings, links) keep their own `md*` theme colors instead of being
59
+ * painted over by it, while plain text runs still use `color`. Unset keeps
60
+ * the historical behavior where `color` paints every run.
61
+ */
62
+ proseFg?: boolean;
56
63
  /** Background color function */
57
64
  bgColor?: (text: string) => string;
58
65
  /** Bold text */
@@ -34,6 +34,13 @@ export interface FlattenTreeOptions<T, K extends TreeKey> {
34
34
  rootDepth?: number;
35
35
  /** Override the display depth inherited by direct children. */
36
36
  getChildDepth?: (item: T, row: TreeRow<T, K>, children: readonly T[]) => number;
37
+ /**
38
+ * Reuse the parent ancestor list when a child keeps the same display depth
39
+ * and the current item has no siblings (`siblingCount === 1`). Otherwise
40
+ * retain the current item as an ancestor so connector gutters remain
41
+ * accurate, including when the item has multiple children.
42
+ */
43
+ compactSameDepthAncestors?: boolean;
37
44
  /** Stop projection after this many structural items. Omit for no traversal cap. */
38
45
  maxItems?: number;
39
46
  }
@@ -21,13 +21,14 @@ interface LoopWatchdogTimer {
21
21
  cancel?(): void;
22
22
  }
23
23
  /**
24
- * Always-on event-loop lag probe. Each tick is scheduled `intervalMs` ahead of
25
- * a recorded deadline; a tick that fires `thresholdMs` past its deadline means
26
- * the loop was blocked that long. The overshoot is logged once on the rising
27
- * edge (one block ⇒ one line, deduped via `#wasBlocked`), tagged with the phase
28
- * active during the elapsed interval via {@link takeRecentLoopPhase} — which
29
- * survives the synchronous push/pop the instrumented hot paths do before this
30
- * delayed tick can run — so the stall names its cause instead of "unknown".
24
+ * Always-on event-loop lag probe. Each tick is scheduled `intervalMs` ahead,
25
+ * with that target recorded as its deadline; a tick that fires `thresholdMs`
26
+ * past its deadline means the loop was blocked that long. The overshoot is
27
+ * logged once on the rising edge (one block ⇒ one line, deduped via
28
+ * `#wasBlocked`). Attribution via
29
+ * {@link takeLoopPhaseAttribution} totals each innermost phase only after the tick's
30
+ * deadline. A phase is named, with `phaseMs`, only when its total outweighs all
31
+ * unlabeled time in that late window; otherwise the block remains "unknown".
31
32
  *
32
33
  * The handle is `unref`'d so the probe never keeps the process alive, and stop()
33
34
  * cancels the armed timer when the handle exposes `cancel` (the default
@@ -15,11 +15,12 @@ interface AgentTreeProjection<TRecord extends AgentRecordLike> {
15
15
  export declare const STATUS_ORDER: Record<AgentStatus, number>;
16
16
  /** Exact observer usage for one roster entry. */
17
17
  export declare function progressMetrics(observed: ObservableSession | undefined): AgentMetrics | undefined;
18
- /** Live session whose own messages back a row's metrics when no observer progress exists. */
18
+ /** Live session used to cache a row's direct assistant usage, including with observer progress. */
19
19
  export declare function hubFallbackStatsSession<TRecord extends AgentRecordLike>(ref: TRecord, observed: ObservableSession | undefined): NonNullable<TRecord["session"]> | undefined;
20
20
  /**
21
- * One roster row's usage: live observer progress, then persisted history, then
22
- * the cached fallback read of a live session (populated by {@link aggregateMetrics}).
21
+ * Preserve progress/history for non-cost metrics, overlaying cumulative direct-session cost.
22
+ * Persisted `history.metrics.cost` is a leaf-scoped snapshot, so it never overrides live
23
+ * progress; only the cumulative direct-cost sources do.
23
24
  */
24
25
  export declare function hubRowMetrics<TRecord extends AgentRecordLike>(ref: TRecord, observed: ObservableSession | undefined, sessionMetrics: WeakMap<object, {
25
26
  metrics: AgentMetrics | undefined;
@@ -28,6 +28,13 @@ export interface AgentHubSession {
28
28
  messages: AgentMessage[];
29
29
  };
30
30
  };
31
+ /** Existing session ledger includes off-transcript model usage and nested-task attribution. */
32
+ readonly sessionManager?: {
33
+ getUsageStatistics(): {
34
+ cost: number;
35
+ subagentCost: number;
36
+ };
37
+ };
31
38
  getSessionStats(): {
32
39
  tokens: {
33
40
  input: number;
@@ -64,6 +71,8 @@ export interface AgentRecordLike {
64
71
  resolvedModel?: string;
65
72
  resolvedModelIsFallback?: boolean;
66
73
  metrics?: AgentMetricsSummary;
74
+ /** Cumulative own-session assistant and model_usage cost, excluding nested task results. */
75
+ directCost?: number;
67
76
  readOnly?: boolean;
68
77
  outputPath?: string;
69
78
  patchPath?: string;
@@ -19,6 +19,8 @@ export interface CodeReviewOverlayCallbacks extends AnnotationOverlayCallbacks {
19
19
  export interface TextReviewOverlayCallbacks extends AnnotationOverlayCallbacks {
20
20
  onComplete(result: TextReviewOverlayResult | undefined): void;
21
21
  }
22
+ /** Splits a text source into the overlay's 1-based annotatable lines. */
23
+ export declare function splitTextLines(text: string): string[];
22
24
  /** A fullscreen, annotated diff picker that only relies on public OMP APIs. */
23
25
  export declare class AnnotationOverlay implements Focusable {
24
26
  #private;
@@ -1,5 +1,5 @@
1
1
  import type { Model } from "@oh-my-pi/pi-ai";
2
- import type { ModelKind } from "@oh-my-pi/pi-catalog/types";
2
+ import { type ModelKind } from "@oh-my-pi/pi-catalog/types";
3
3
  import type { Component } from "../tui.js";
4
4
  import type { SgrMouseEvent } from "../mouse.js";
5
5
  import { type ConfiguredThinkingLevel } from "../thinking.js";
@@ -103,6 +103,14 @@ export type RoleAssignments = Record<string, RoleAssignment | undefined>;
103
103
  * the alt+p session picker.
104
104
  */
105
105
  export declare function resolveRoleAssignments(settings: ModelBrowserSource, allModels: ReadonlyArray<Model>, autoCandidates: ReadonlyArray<Model>): RoleAssignments;
106
+ /**
107
+ * Role-resolution pool for a `--models`/`enabledModels` scope: the scoped
108
+ * models plus every available non-chat runner (judge, search, image, …). The
109
+ * scope only filters chat models (it feeds Ctrl+P cycling) and runtime role
110
+ * resolution ignores it for other kinds, so displayed role assignments must too.
111
+ * Shared by the /models hub and the session picker.
112
+ */
113
+ export declare function scopedRolePool(scoped: ReadonlyArray<Model>, registry: ModelBrowserRegistry): Model[];
106
114
  /** Wrap raw models into browser items. */
107
115
  export declare function buildBrowserItems(models: ReadonlyArray<Model>): ModelBrowserItem[];
108
116
  /** Options for {@link sortModelItems}. */
@@ -44,6 +44,7 @@ export type AnyUiMetadata = UiBase & {
44
44
  options?: ReadonlyArray<SubmenuOption> | "runtime";
45
45
  secret?: boolean;
46
46
  ordered?: boolean;
47
+ editor?: "json";
47
48
  };
48
49
  /** Structural schema entries supplied by the application host. */
49
50
  export interface SettingsDisplayEntry {
@@ -1,4 +1,4 @@
1
- import type { UsageLimit, UsageReport, UsageResetCredits } from "@oh-my-pi/pi-ai";
1
+ import type { UsageLimit, UsageReport, UsageResetCreditDetail, UsageResetCredits } from "@oh-my-pi/pi-ai";
2
2
  /** Include the usage tier in a limit title unless its label already names it. */
3
3
  export declare function formatLimitTitle(limit: UsageLimit): string;
4
4
  /** Human-readable quota scope for a normalized saved-reset window ID. */
@@ -10,6 +10,8 @@ export interface UsageResetSummary {
10
10
  soonestExpiry?: string;
11
11
  unavailableReason?: string;
12
12
  }
13
+ /** Expiry (epoch ms) of a credit that still banks a reset, whether or not it can be spent now. */
14
+ export declare function bankedResetCreditExpiryMs(credit: UsageResetCreditDetail): number | undefined;
13
15
  /**
14
16
  * Normalize old count-only and current provider reset metadata for display.
15
17
  * `availableCount` is banked inventory; `redeemableCount` is the subset that
@@ -28,6 +28,7 @@ export interface SetupHost extends SetupUiHost {
28
28
  readonly disabledProviders: readonly string[];
29
29
  readonly authStorage: AuthStorage;
30
30
  readonly modelSource: ModelBrowserSource;
31
+ /** Available and catalog models of every kind; role chips resolve over all of them, rows list chat models. */
31
32
  getModels(): {
32
33
  available: Model[];
33
34
  all: Model[];
@@ -111,6 +111,8 @@ export declare class StatusLineComponent<TSession extends StatusLineSession = St
111
111
  setRecording(recording: boolean): void;
112
112
  /** Set the callback that presents detected Codex reset celebrations, or clear it with `undefined`. */
113
113
  setCodexResetFireworksHandler(handler: ((event: CodexResetFireworksEvent) => void) | undefined): void;
114
+ /** Set the callback that presents the first pool-wide saved-reset expiry warning, or clear it with `undefined`. */
115
+ setResetExpiryNoticeHandler(handler: ((notice: string) => void) | undefined): void;
114
116
  setHookStatus(key: string, text: string | undefined): void;
115
117
  watchBranch(onBranchChange: () => void): void;
116
118
  dispose(): void;
@@ -2,7 +2,7 @@ import type { AgentMessage, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
2
2
  import type { Tool, UsageLimit, UsageReport } from "@oh-my-pi/pi-ai";
3
3
  import type { Model } from "@oh-my-pi/pi-catalog/types";
4
4
  import type { CompactionBoundaries } from "./context-usage.js";
5
- import type { StatusLineSettings } from "./types.js";
5
+ import type { StatusLineSettings, StatusResetExpiry } from "./types.js";
6
6
  export interface StatusAccountIdentity {
7
7
  accountId?: string;
8
8
  email?: string;
@@ -126,6 +126,9 @@ export interface StatusLineHost<TSession extends StatusLineSession = StatusLineS
126
126
  }>;
127
127
  calculateTokensPerSecond(messages: readonly AgentMessage[], isStreaming: boolean): number | null;
128
128
  limitMatchesActiveAccount(report: UsageReport, limit: UsageLimit, identity: StatusAccountIdentity): boolean;
129
+ classifyResetExpiry?(report: UsageReport, nowMs: number): StatusResetExpiry | undefined;
130
+ /** One-line warning for saved resets anywhere in the pool that expire within 24 hours. */
131
+ resetExpiryNotice?(reports: readonly UsageReport[], nowMs: number): string | undefined;
129
132
  computeCompactionBoundaries(session: TSession, contextWindow: number, model?: Model): CompactionBoundaries | null;
130
133
  }
131
134
  export interface FooterHost {
@@ -223,9 +223,18 @@ export interface SegmentContext {
223
223
  expiryHours?: number;
224
224
  expired?: boolean;
225
225
  unavailableReason?: string;
226
+ expiring?: StatusResetExpiry;
226
227
  };
227
228
  } | null;
228
229
  }
230
+ /** How close an account's saved resets are to expiring, when it is worth a warning. */
231
+ export interface StatusResetExpiry {
232
+ /** `soon`: within 7 days; `imminent`: within 24 hours. */
233
+ tier: "soon" | "imminent";
234
+ count: number;
235
+ /** Expiry of the reset the warning is about (epoch ms); it can be later than the soonest banked one. */
236
+ expiresAtMs: number;
237
+ }
229
238
  export interface RenderedSegment {
230
239
  content: string;
231
240
  visible: boolean;
@@ -230,6 +230,12 @@ export interface Terminal {
230
230
  * `status` is the DECRPM value when the terminal answered DECRQM.
231
231
  */
232
232
  onPrivateModeReport?(callback: PrivateModeReportHandler): void;
233
+ /**
234
+ * Report whether DA1 advertises SIXEL (attribute 4), replaying the latest
235
+ * advertisement to late subscribers. A missing attribute does not rule out
236
+ * support discovered through another graphics query.
237
+ */
238
+ onSixelSupport?(callback: (supported: boolean) => void): void;
233
239
  /**
234
240
  * Register a callback fired once the startup Glyph Protocol handshake
235
241
  * resolves (see {@link GlyphProtocolReportHandler}). A subscriber that
@@ -310,6 +316,7 @@ export declare class ProcessTerminal implements Terminal {
310
316
  refreshAppearance(requestToken?: TerminalAppearanceRequestToken): TerminalAppearanceRequestToken | void;
311
317
  onPrivateModeReport(callback: PrivateModeReportHandler): void;
312
318
  onGlyphProtocolReport(callback: GlyphProtocolReportHandler): void;
319
+ onSixelSupport(callback: (supported: boolean) => void): void;
313
320
  onTspHello(callback: TspHelloHandler): void;
314
321
  get tspProbePending(): boolean;
315
322
  get tspExpected(): boolean;
@@ -1,10 +1,19 @@
1
1
  import type { SpinnerFramesOverride } from "./symbols.js";
2
2
  export type ColorValue = string | number;
3
+ /**
4
+ * Tokens a theme is allowed to omit. They resolve to the terminal default
5
+ * foreground, so `Theme.fg()` stays total for callers that paint a token a theme
6
+ * never declared (e.g. a `modelTags.<role>.color` reference) while
7
+ * `Theme.hasColor()` still reports them as unset.
8
+ */
9
+ export declare const OPTIONAL_THEME_COLOR_RECORD: {
10
+ assistantMessageText: true;
11
+ };
3
12
  export interface ThemeJson {
4
13
  $schema?: string;
5
14
  name: string;
6
15
  vars?: Record<string, ColorValue>;
7
- colors: Omit<Record<ThemeColor | ThemeBg, ColorValue>, "thinkingMax"> & {
16
+ colors: Omit<Record<ThemeColor | ThemeBg, ColorValue>, "thinkingMax" | keyof typeof OPTIONAL_THEME_COLOR_RECORD> & Partial<Record<keyof typeof OPTIONAL_THEME_COLOR_RECORD, ColorValue>> & {
8
17
  thinkingMax?: ColorValue;
9
18
  };
10
19
  export?: {
@@ -36,7 +45,7 @@ export interface ThemeJson {
36
45
  spinnerFrames?: SpinnerFramesOverride;
37
46
  };
38
47
  }
39
- export type ThemeColor = "accent" | "border" | "borderAccent" | "borderMuted" | "success" | "error" | "warning" | "muted" | "dim" | "text" | "thinkingText" | "userMessageText" | "customMessageText" | "customMessageLabel" | "toolTitle" | "toolOutput" | "mdHeading" | "mdLink" | "mdLinkUrl" | "mdCode" | "mdCodeBlock" | "mdCodeBlockBorder" | "mdQuote" | "mdQuoteBorder" | "mdHr" | "mdListBullet" | "toolDiffAdded" | "toolDiffRemoved" | "toolDiffContext" | "syntaxComment" | "syntaxKeyword" | "syntaxFunction" | "syntaxVariable" | "syntaxString" | "syntaxNumber" | "syntaxType" | "syntaxOperator" | "syntaxPunctuation" | "thinkingOff" | "thinkingMinimal" | "thinkingLow" | "thinkingMedium" | "thinkingHigh" | "thinkingXhigh" | "thinkingMax" | "bashMode" | "pythonMode" | "statusLineSep" | "statusLineModel" | "statusLinePath" | "statusLineGitClean" | "statusLineGitDirty" | "statusLineContext" | "statusLineSpend" | "statusLineStaged" | "statusLineDirty" | "statusLineUntracked" | "statusLineOutput" | "statusLineCost" | "statusLineSubagents";
48
+ export type ThemeColor = "accent" | "border" | "borderAccent" | "borderMuted" | "success" | "error" | "warning" | "muted" | "dim" | "text" | "assistantMessageText" | "thinkingText" | "userMessageText" | "customMessageText" | "customMessageLabel" | "toolTitle" | "toolOutput" | "mdHeading" | "mdLink" | "mdLinkUrl" | "mdCode" | "mdCodeBlock" | "mdCodeBlockBorder" | "mdQuote" | "mdQuoteBorder" | "mdHr" | "mdListBullet" | "toolDiffAdded" | "toolDiffRemoved" | "toolDiffContext" | "syntaxComment" | "syntaxKeyword" | "syntaxFunction" | "syntaxVariable" | "syntaxString" | "syntaxNumber" | "syntaxType" | "syntaxOperator" | "syntaxPunctuation" | "thinkingOff" | "thinkingMinimal" | "thinkingLow" | "thinkingMedium" | "thinkingHigh" | "thinkingXhigh" | "thinkingMax" | "bashMode" | "pythonMode" | "statusLineSep" | "statusLineModel" | "statusLinePath" | "statusLineGitClean" | "statusLineGitDirty" | "statusLineContext" | "statusLineSpend" | "statusLineStaged" | "statusLineDirty" | "statusLineUntracked" | "statusLineOutput" | "statusLineCost" | "statusLineSubagents";
40
49
  /** Check if a string is a valid ThemeColor value */
41
50
  export declare function isValidThemeColor(color: string): color is ThemeColor;
42
51
  export type ThemeBg = "selectedBg" | "userMessageBg" | "customMessageBg" | "toolPendingBg" | "toolSuccessBg" | "toolErrorBg" | "statusLineBg";
@@ -54,6 +54,13 @@ export declare class Theme {
54
54
  * against. Built once per instance and frozen; callers share the object.
55
55
  */
56
56
  get sessionAccentInputs(): SessionAccentTheme;
57
+ /**
58
+ * True when the theme paints `color` with a real foreground — i.e. the token
59
+ * exists and is not the empty string (terminal default, `\x1b[39m`). Optional
60
+ * tokens absent from the theme JSON are also false. Callers use this to keep
61
+ * terminal-default behavior byte-for-byte when an optional token is unset.
62
+ */
63
+ hasColor(color: ThemeColor): boolean;
57
64
  fg(color: ThemeColor, text: string): string;
58
65
  /** Apply a foreground, replacing terminal-default tokens with the theme's contrast-safe fallback. */
59
66
  fgResolved(color: ThemeColor, text: string): string;
@@ -24,6 +24,8 @@ export interface EvalCellResult {
24
24
  durationMs?: number;
25
25
  exitCode?: number;
26
26
  statusEvents?: EvalStatusEvent[];
27
+ /** Discrete events dropped from the front of `statusEvents` (see {@link recordStatusEvent}). */
28
+ statusEventsElided?: number;
27
29
  hasMarkdown?: boolean;
28
30
  }
29
31
  /** Tool result detail object surfaced to the UI/transcript. */
@@ -32,6 +34,8 @@ export interface EvalToolDetails {
32
34
  jsonOutputs?: unknown[];
33
35
  images?: ImageContent[];
34
36
  statusEvents?: EvalStatusEvent[];
37
+ /** Discrete events dropped from the front of `statusEvents` (see {@link recordStatusEvent}). */
38
+ statusEventsElided?: number;
35
39
  isError?: boolean;
36
40
  meta?: OutputMeta;
37
41
  /** First backend that produced cells. Kept for transcript compatibility. */
@@ -74,13 +78,28 @@ export declare function statusEventKey(event: {
74
78
  op: string;
75
79
  [key: string]: unknown;
76
80
  }): string | undefined;
81
+ /**
82
+ * Discrete status events a log keeps. A cell polling a helper in a loop emits
83
+ * one event per call (hundreds of thousands), and every live update and the
84
+ * persisted tool result would otherwise carry them all.
85
+ */
86
+ export declare const MAX_STATUS_EVENTS = 200;
87
+ /** A status event list plus the count of discrete events dropped from its front. */
88
+ export type StatusEventLog = Pick<EvalCellResult, "statusEvents" | "statusEventsElided">;
77
89
  /**
78
90
  * Append or replace a status event. Progress snapshots (see
79
91
  * {@link statusEventKey}) coalesce in place, preserving first-seen order; every
80
- * other op is a discrete action and simply appends. Keeps the persisted event
81
- * list bounded even when a subagent or batch emits hundreds of progress ticks.
92
+ * other op is a discrete action and simply appends.
82
93
  */
83
94
  export declare function upsertStatusEvent(events: EvalStatusEvent[], event: EvalStatusEvent): void;
95
+ /**
96
+ * {@link upsertStatusEvent} into a bounded log. Past {@link MAX_STATUS_EVENTS},
97
+ * the oldest discrete event is dropped and counted. Snapshots stay, since agent
98
+ * cards read them, and so does the newest committed `todo` result, which the
99
+ * session todo panel refreshes from. Renderers already show only the newest
100
+ * events behind an "… N earlier" row.
101
+ */
102
+ export declare function recordStatusEvent(log: StatusEventLog, event: EvalStatusEvent): void;
84
103
  /** Render eval code cells, structured display output, and progress events. */
85
104
  export declare const evalToolRenderer: {
86
105
  animatedPendingPreview: true;
@@ -84,12 +84,22 @@ export interface LimitsMeta {
84
84
  reached: number;
85
85
  suggestion: number;
86
86
  };
87
- /** `unit` may be absent in sessions persisted before it was recorded. */
87
+ /**
88
+ * `unit` may be absent in sessions persisted before it was recorded. `lines` is
89
+ * the first-to-last range of cut lines, and `selectorBase` the target a
90
+ * `:raw:<line>-<line>` selector reads one of them whole from (an artifact's
91
+ * `artifact://<id>` stands in when absent).
92
+ */
88
93
  columnTruncated?: {
89
94
  maxColumn: number;
90
95
  unit?: "bytes" | "chars";
91
96
  artifactId?: string;
92
97
  artifactElidedBytes?: number;
98
+ lines?: {
99
+ first: number;
100
+ last: number;
101
+ };
102
+ selectorBase?: string;
93
103
  };
94
104
  }
95
105
  /**
@@ -31,6 +31,15 @@ export interface OutputSummary {
31
31
  columnDroppedBytes?: number;
32
32
  /** Number of distinct lines that hit the per-line column cap. */
33
33
  columnTruncatedLines?: number;
34
+ /**
35
+ * 1-indexed first and last lines the column cap cut, numbered as in the
36
+ * artifact. Absent when the numbering cannot match the artifact (an inline
37
+ * substitute was capped, or `replace()` rewrote the buffer).
38
+ */
39
+ columnTruncatedRange?: {
40
+ first: number;
41
+ last: number;
42
+ };
34
43
  /** Configured per-line column cap in effect (UTF-8 bytes), when > 0. */
35
44
  columnMax?: number;
36
45
  /** Artifact ID for internal URL access (artifact://<id>) when truncated */