@linxiraos/pi-tui 1.4.13 → 1.5.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.
- package/CHANGELOG.md +17 -34
- package/dist/types/chat/messages.d.ts +2 -0
- package/dist/types/chat/spotlight.d.ts +8 -3
- package/dist/types/chat/transcript-render-helpers.d.ts +5 -0
- package/dist/types/components/editor.d.ts +4 -1
- package/dist/types/html-form/data.d.ts +56 -0
- package/dist/types/html-form/dialog.d.ts +51 -0
- package/dist/types/html-form/media.d.ts +28 -0
- package/dist/types/html-form/paginate.d.ts +43 -0
- package/dist/types/html-form/parse.d.ts +99 -0
- package/dist/types/overlays/ask-dialog.d.ts +11 -6
- package/dist/types/overlays/copy-targets.d.ts +8 -6
- package/dist/types/overlays/hook-editor.d.ts +3 -1
- package/dist/types/overlays/hub-frame.d.ts +2 -0
- package/dist/types/overlays/model-hub.d.ts +2 -0
- package/dist/types/overlays/team-hub.d.ts +150 -0
- package/dist/types/render/row-moves.d.ts +41 -0
- package/dist/types/status-line/component.d.ts +5 -0
- package/dist/types/status-line/host.d.ts +2 -2
- package/dist/types/status-line/schema.d.ts +1 -1
- package/dist/types/status-line/types.d.ts +8 -0
- package/dist/types/tools/ask.d.ts +11 -49
- package/dist/types/tools/autoresearch.d.ts +2 -2
- package/dist/types/tools/eval.d.ts +4 -0
- package/dist/types/tools/grouped-file-output.d.ts +2 -0
- package/dist/types/tools/shell-viz.d.ts +6 -2
- package/dist/types/tools/xd-url.d.ts +6 -0
- package/dist/types/windows-input-mode.d.ts +8 -0
- package/package.json +9 -9
- package/src/charts/table-data.ts +18 -5
- package/src/chat/chat-transcript-builder.ts +27 -10
- package/src/chat/image-loading.ts +55 -0
- package/src/chat/messages.d.ts +2 -0
- package/src/chat/messages.ts +3 -0
- package/src/chat/spotlight.d.ts +8 -3
- package/src/chat/spotlight.ts +23 -11
- package/src/chat/tool-execution.ts +5 -0
- package/src/chat/transcript-render-helpers.d.ts +5 -0
- package/src/chat/transcript-render-helpers.ts +13 -0
- package/src/chrome/transcript-container.ts +1 -1
- package/src/components/editor.d.ts +4 -1
- package/src/components/editor.ts +3 -2
- package/src/components/markdown.ts +70 -12
- package/src/html-form/data.d.ts +56 -0
- package/src/html-form/data.ts +177 -0
- package/src/html-form/dialog.ts +1450 -0
- package/src/html-form/media.ts +105 -0
- package/src/html-form/paginate.ts +99 -0
- package/src/html-form/parse.d.ts +99 -0
- package/src/html-form/parse.ts +568 -0
- package/src/lang-from-path.ts +1 -0
- package/src/latex-block.ts +3 -3
- package/src/latex-to-unicode.ts +18 -5
- package/src/overlays/ask-dialog.ts +69 -52
- package/src/overlays/copy-targets.d.ts +8 -6
- package/src/overlays/copy-targets.ts +25 -46
- package/src/overlays/hook-editor.ts +16 -15
- package/src/overlays/hub-frame.ts +8 -1
- package/src/overlays/model-hub.ts +12 -2
- package/src/overlays/spotlight-sheet.ts +18 -18
- package/src/overlays/team-hub.ts +901 -0
- package/src/render/row-moves.d.ts +41 -0
- package/src/render/row-moves.ts +109 -0
- package/src/setup/wizard-overlay.ts +7 -3
- package/src/status-line/component.ts +19 -0
- package/src/status-line/footer.ts +2 -2
- package/src/status-line/host.ts +2 -2
- package/src/status-line/presets.ts +6 -6
- package/src/status-line/schema.ts +2 -1
- package/src/status-line/segments.ts +31 -4
- package/src/status-line/startup.ts +1 -1
- package/src/status-line/types.ts +8 -0
- package/src/stdin-buffer.ts +15 -1
- package/src/terminal-capabilities.ts +12 -3
- package/src/terminal.ts +41 -3
- package/src/tools/ask.d.ts +11 -49
- package/src/tools/ask.ts +201 -606
- package/src/tools/autoresearch.ts +2 -2
- package/src/tools/debug.ts +31 -38
- package/src/tools/eval.d.ts +4 -0
- package/src/tools/eval.ts +4 -0
- package/src/tools/grep.ts +38 -16
- package/src/tools/grouped-file-output.d.ts +2 -0
- package/src/tools/grouped-file-output.ts +5 -0
- package/src/tools/shell-viz-render.ts +37 -6
- package/src/tools/shell-viz.d.ts +6 -2
- package/src/tools/shell-viz.ts +19 -6
- package/src/tools/xd-url.d.ts +6 -0
- package/src/tools/xd-url.ts +19 -1
- package/src/tui.ts +129 -1
- package/src/windows-input-mode.d.ts +8 -0
- package/src/windows-input-mode.ts +13 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Team Hub overlay: the TUI surface for a Team.
|
|
3
|
+
*
|
|
4
|
+
* It is a UI, not an Agent: no team-root session, no AGENTS.md, no transcript.
|
|
5
|
+
* The left pane lists database rooms and the PM/engineer roster; the right pane
|
|
6
|
+
* shows one room's ordered `room_events` (or the selected engineer's real
|
|
7
|
+
* worktrees). Posting writes a room event through the same database service the
|
|
8
|
+
* CLI uses. Missing data stays honest: an empty team shows no invented rooms,
|
|
9
|
+
* agents, or statuses.
|
|
10
|
+
*/
|
|
11
|
+
import { type SidebarEntry } from "./hub-frame.js";
|
|
12
|
+
import type { Component } from "../tui.js";
|
|
13
|
+
import type { TUI } from "../tui.js";
|
|
14
|
+
export type TeamHubRoomKind = "pm" | "coordination" | "room";
|
|
15
|
+
export interface TeamHubRoom {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
kind: TeamHubRoomKind;
|
|
19
|
+
pmId: string | null;
|
|
20
|
+
pmName: string | null;
|
|
21
|
+
memberCount: number;
|
|
22
|
+
/** Latest host-assigned event sequence, or null for a room with no events. */
|
|
23
|
+
lastSeq: number | null;
|
|
24
|
+
lastSentAt: number | null;
|
|
25
|
+
}
|
|
26
|
+
export interface TeamHubMember {
|
|
27
|
+
agentId: string;
|
|
28
|
+
role: string;
|
|
29
|
+
/** Display label resolved from a real PM/engineer row, never an absolute path. */
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
export interface TeamHubEvent {
|
|
33
|
+
seq: number;
|
|
34
|
+
/** Unix seconds, assigned by the host. */
|
|
35
|
+
sentAt: number;
|
|
36
|
+
senderAgentId: string;
|
|
37
|
+
senderLabel: string;
|
|
38
|
+
kind: string;
|
|
39
|
+
body: string;
|
|
40
|
+
replyTo: number | null;
|
|
41
|
+
}
|
|
42
|
+
export interface TeamHubRoomView {
|
|
43
|
+
room: TeamHubRoom;
|
|
44
|
+
members: TeamHubMember[];
|
|
45
|
+
events: TeamHubEvent[];
|
|
46
|
+
}
|
|
47
|
+
export interface TeamHubWorktree {
|
|
48
|
+
id: string;
|
|
49
|
+
kind: "home" | "task";
|
|
50
|
+
name: string;
|
|
51
|
+
branch: string;
|
|
52
|
+
path: string;
|
|
53
|
+
}
|
|
54
|
+
export interface TeamHubPm {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
engineerCount: number;
|
|
58
|
+
}
|
|
59
|
+
export interface TeamHubEngineer {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
pmId: string;
|
|
63
|
+
pmName: string;
|
|
64
|
+
execution: "normal" | "vibe";
|
|
65
|
+
worktrees: TeamHubWorktree[];
|
|
66
|
+
}
|
|
67
|
+
export interface TeamHubSnapshot {
|
|
68
|
+
teamId: string;
|
|
69
|
+
teamName: string;
|
|
70
|
+
/** False when the marker exists but the global Team database has no team row. */
|
|
71
|
+
dbAvailable: boolean;
|
|
72
|
+
/** Honest explanation (missing DB row, requested room gone, …). */
|
|
73
|
+
warning?: string;
|
|
74
|
+
pms: TeamHubPm[];
|
|
75
|
+
engineers: TeamHubEngineer[];
|
|
76
|
+
rooms: TeamHubRoom[];
|
|
77
|
+
selectedRoom: TeamHubRoomView | null;
|
|
78
|
+
}
|
|
79
|
+
/** What the overlay needs from the host; the coding-agent supplies real DB I/O. */
|
|
80
|
+
export interface TeamHubDataSource {
|
|
81
|
+
load(options?: {
|
|
82
|
+
room?: string;
|
|
83
|
+
preferPmId?: string;
|
|
84
|
+
}): Promise<TeamHubSnapshot>;
|
|
85
|
+
post(input: {
|
|
86
|
+
room: string;
|
|
87
|
+
body: string;
|
|
88
|
+
sender?: string;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
seq: number;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
export interface TeamHubDeps {
|
|
94
|
+
source: TeamHubDataSource;
|
|
95
|
+
onDone: () => void;
|
|
96
|
+
requestRender: () => void;
|
|
97
|
+
/** TUI handle for terminal height and input focus; tests may omit it. */
|
|
98
|
+
ui?: TUI;
|
|
99
|
+
/** Focus the Hub on this PM on first load (a PM-root launch). */
|
|
100
|
+
initialPmId?: string;
|
|
101
|
+
/** Open Agent Hub (subagent control stays there); omitted in a standalone Hub. */
|
|
102
|
+
openAgentHub?: () => void;
|
|
103
|
+
}
|
|
104
|
+
export type TeamHubEntryKind = "separator" | "label" | "room" | "pm" | "engineer";
|
|
105
|
+
export interface TeamHubSidebarEntry extends SidebarEntry<TeamHubEntryKind> {
|
|
106
|
+
roomName?: string;
|
|
107
|
+
agentId?: string;
|
|
108
|
+
pmId?: string;
|
|
109
|
+
}
|
|
110
|
+
/** Rooms in display order: shared first, then PM rooms, then arbitrary rooms. */
|
|
111
|
+
export declare function sortTeamHubRooms(rooms: readonly TeamHubRoom[]): TeamHubRoom[];
|
|
112
|
+
/** Events are always displayed in ascending host `seq` order. */
|
|
113
|
+
export declare function orderTeamHubEvents(events: readonly TeamHubEvent[]): TeamHubEvent[];
|
|
114
|
+
/** New events since this Hub opened (or since the room was last viewed). */
|
|
115
|
+
export declare function teamHubUnread(room: TeamHubRoom, baseline: ReadonlyMap<string, number>): number;
|
|
116
|
+
/**
|
|
117
|
+
* Flatten the snapshot into sidebar rows. A filter matches room/agent labels and
|
|
118
|
+
* annotations; section labels disappear while filtering so only matches remain.
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildTeamHubEntries(snapshot: TeamHubSnapshot | undefined, filter?: string, baseline?: ReadonlyMap<string, number>): TeamHubSidebarEntry[];
|
|
121
|
+
/** Move the selection by `delta`, skipping section labels and separators. */
|
|
122
|
+
export declare function moveTeamHubSelection(entries: readonly TeamHubSidebarEntry[], currentId: string | undefined, delta: number): string | undefined;
|
|
123
|
+
/** First room of a scope, used by `g` (shared) and PM-focused launches. */
|
|
124
|
+
export declare function selectTeamHubRoom(rooms: readonly TeamHubRoom[], scope: "shared" | "pm", pmId?: string): TeamHubRoom | undefined;
|
|
125
|
+
/** `p`: the next room owned by `pmId`, wrapping; undefined when the PM owns none. */
|
|
126
|
+
export declare function nextTeamHubPmRoom(rooms: readonly TeamHubRoom[], currentRoom: string | undefined, pmId: string | undefined): TeamHubRoom | undefined;
|
|
127
|
+
/** Filter room events for `/` (body, sender, kind, or sequence). */
|
|
128
|
+
export declare function filterTeamHubEvents(events: readonly TeamHubEvent[], filter: string): TeamHubEvent[];
|
|
129
|
+
/** `HH:MM` for today, `MM-DD HH:MM` otherwise. Pure for tests. */
|
|
130
|
+
export declare function formatTeamHubTime(sentAt: number, now?: Date): string;
|
|
131
|
+
export interface TeamHubEventParts {
|
|
132
|
+
time: string;
|
|
133
|
+
sender: string;
|
|
134
|
+
reply: string | null;
|
|
135
|
+
body: string;
|
|
136
|
+
}
|
|
137
|
+
/** Plain single-line breakdown of an event; the renderer styles each part. */
|
|
138
|
+
export declare function describeTeamHubEvent(event: TeamHubEvent, now?: Date): TeamHubEventParts;
|
|
139
|
+
/** Width-aware plain text for one event (used by tests and non-themed hosts). */
|
|
140
|
+
export declare function formatTeamHubEvent(event: TeamHubEvent, width: number, now?: Date): string[];
|
|
141
|
+
export declare class TeamHubOverlayComponent implements Component {
|
|
142
|
+
#private;
|
|
143
|
+
constructor(deps: TeamHubDeps);
|
|
144
|
+
/** Resolves after the latest database read settles (initial load or refresh). */
|
|
145
|
+
get ready(): Promise<void>;
|
|
146
|
+
dispose(): void;
|
|
147
|
+
invalidate(): void;
|
|
148
|
+
handleInput(data: string): void;
|
|
149
|
+
render(width: number): readonly string[];
|
|
150
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Row-move planning for paints a terminal may present half-applied.
|
|
3
|
+
*
|
|
4
|
+
* Without synchronized output (DEC 2026) a terminal can show any prefix of a
|
|
5
|
+
* frame's bytes. Repainting a viewport whose content shifted row by row,
|
|
6
|
+
* top-down, then exposes rows already rewritten above rows that have not moved
|
|
7
|
+
* yet, and the seam shows the shifted rows twice. Moving the surviving rows
|
|
8
|
+
* with delete-line/insert-line first keeps every intermediate screen a
|
|
9
|
+
* coherent, shifted copy of the previous frame, and leaves only the rows that
|
|
10
|
+
* really changed to rewrite.
|
|
11
|
+
*
|
|
12
|
+
* Rows are integer keys: {@link BLANK_ROW} for an empty row,
|
|
13
|
+
* {@link UNKNOWN_ROW} for committed history the planner does not model (never
|
|
14
|
+
* matched, never moved), and any other value for one distinct line.
|
|
15
|
+
*/
|
|
16
|
+
/** Key of an empty row. */
|
|
17
|
+
export declare const BLANK_ROW = 0;
|
|
18
|
+
/** Key of a row whose content is not modeled; it matches nothing. */
|
|
19
|
+
export declare const UNKNOWN_ROW = -1;
|
|
20
|
+
/** `count` rows starting at screen row `from` move to start at `to`; the rows they vacate turn blank. */
|
|
21
|
+
export interface RowMove {
|
|
22
|
+
readonly from: number;
|
|
23
|
+
readonly to: number;
|
|
24
|
+
readonly count: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The band move that turns the most rows of `screen` into `target`, or
|
|
28
|
+
* `undefined` when no move saves a row rewrite. Only rows at or below `base`
|
|
29
|
+
* are moved or vacated. An upward move never lands on row 0: it deletes lines
|
|
30
|
+
* at its destination, and Terminal.app archives lines deleted from the top row
|
|
31
|
+
* into scrollback.
|
|
32
|
+
*/
|
|
33
|
+
export declare function findRowMove(screen: readonly number[], target: readonly number[], base: number): RowMove | undefined;
|
|
34
|
+
/** Apply `move` to a screen model, as {@link rowMoveSequence} applies it to the terminal. */
|
|
35
|
+
export declare function applyRowMove(screen: number[], move: RowMove): void;
|
|
36
|
+
/**
|
|
37
|
+
* Terminal bytes performing `move` on a `height`-row screen with default
|
|
38
|
+
* margins: rows outside the band and its vacated rows keep their place. Lines
|
|
39
|
+
* inserted or deleted take the current background, so callers reset SGR first.
|
|
40
|
+
*/
|
|
41
|
+
export declare function rowMoveSequence(move: RowMove, height: number): string;
|
|
@@ -96,6 +96,11 @@ export declare class StatusLineComponent<TSession extends StatusLineSession = St
|
|
|
96
96
|
setVibeModeStatus(status: {
|
|
97
97
|
enabled: boolean;
|
|
98
98
|
} | undefined): void;
|
|
99
|
+
setLeadModeStatus(status: {
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
} | undefined): void;
|
|
102
|
+
/** Team breadcrumb; `undefined` hides the segment (outside a Team, or a plain subdirectory). */
|
|
103
|
+
setTeamBreadcrumb(label: string | undefined): void;
|
|
99
104
|
/** Mirror of the editor's modal state; `undefined` clears it (Vim mode off). */
|
|
100
105
|
setVimStatus(status: NonNullable<SegmentContext["vim"]> | undefined): void;
|
|
101
106
|
/**
|
|
@@ -114,7 +114,7 @@ export interface StatusLineSession {
|
|
|
114
114
|
};
|
|
115
115
|
};
|
|
116
116
|
modelRegistry: {
|
|
117
|
-
|
|
117
|
+
isUsingSubscription(model: Model): boolean;
|
|
118
118
|
};
|
|
119
119
|
getContextUsage(): {
|
|
120
120
|
tokens: number;
|
|
@@ -161,7 +161,7 @@ export interface FooterSession {
|
|
|
161
161
|
isAutoThinking: boolean;
|
|
162
162
|
autoResolvedThinkingLevel(): string | undefined;
|
|
163
163
|
getContextUsage: StatusLineSession["getContextUsage"];
|
|
164
|
-
modelRegistry: Pick<StatusLineSession["modelRegistry"], "
|
|
164
|
+
modelRegistry: Pick<StatusLineSession["modelRegistry"], "isUsingSubscription">;
|
|
165
165
|
/**
|
|
166
166
|
* Cumulative session rollup. Unlike the active-window stats it spans every
|
|
167
167
|
* entry in the session, so compaction does not reset the counters, and it
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Status line segment identifiers accepted by custom status-line settings. */
|
|
2
|
-
export declare const STATUS_LINE_SEGMENT_IDS: readonly ["pi", "status", "model", "mode", "path", "git", "pr", "subagents", "token_in", "token_out", "token_total", "token_rate", "cost", "context_pct", "context_total", "time_spent", "time", "session", "hostname", "cache_read", "cache_write", "cache_hit", "cache", "session_name", "usage", "turn_stats", "stream", "vim"];
|
|
2
|
+
export declare const STATUS_LINE_SEGMENT_IDS: readonly ["pi", "status", "model", "mode", "team", "path", "git", "pr", "subagents", "token_in", "token_out", "token_total", "token_rate", "cost", "context_pct", "context_total", "time_spent", "time", "session", "hostname", "cache_read", "cache_write", "cache_hit", "cache", "session_name", "usage", "turn_stats", "stream", "vim"];
|
|
3
3
|
/** One identifier from the supported status-line segment catalog. */
|
|
4
4
|
export type StatusLineSegmentId = (typeof STATUS_LINE_SEGMENT_IDS)[number];
|
|
5
5
|
/** Baseline segments used when Custom is selected without segment overrides. */
|
|
@@ -99,6 +99,14 @@ export interface SegmentContext {
|
|
|
99
99
|
vibeMode: {
|
|
100
100
|
enabled: boolean;
|
|
101
101
|
} | null;
|
|
102
|
+
/** Lead (PM) mode indicator; optional so existing context fixtures stay valid. */
|
|
103
|
+
leadMode?: {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
} | null;
|
|
106
|
+
/** Team breadcrumb (`Team / PM / repo / engineer / worktree`) when the cwd resolves into a team. */
|
|
107
|
+
team?: {
|
|
108
|
+
label: string;
|
|
109
|
+
} | null;
|
|
102
110
|
/** Modal editing state, or null when `tui.vimMode` is off. */
|
|
103
111
|
vim: {
|
|
104
112
|
mode: "insert" | "normal" | "visual" | "visual-line" | "replace";
|
|
@@ -1,74 +1,36 @@
|
|
|
1
1
|
import type { NativeToolView, ToolRenderResult } from "./renderer.js";
|
|
2
2
|
import { type Component } from "../index.js";
|
|
3
3
|
import type { RenderResultOptions } from "./renderer.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
id: string;
|
|
8
|
-
question: string;
|
|
9
|
-
options: string[];
|
|
10
|
-
multi: boolean;
|
|
11
|
-
selectedOptions: string[];
|
|
12
|
-
customInput?: string;
|
|
13
|
-
/** Optional note attached to the selected answer in the rich ask dialog. */
|
|
14
|
-
note?: string;
|
|
15
|
-
/** Label of the option the note is on; unset when it is on the custom answer. */
|
|
16
|
-
noteOption?: string;
|
|
17
|
-
/** True when the answer was auto-selected because the dialog timed out. */
|
|
18
|
-
timedOut?: boolean;
|
|
19
|
-
}
|
|
20
|
-
/** Answers and redirect metadata displayed for an ask tool result. */
|
|
4
|
+
import type { Theme } from "../theme/theme.js";
|
|
5
|
+
import { type FormAnswer } from "../html-form/data.js";
|
|
6
|
+
/** Answers displayed for an ask tool result. */
|
|
21
7
|
export interface AskToolDetails {
|
|
22
|
-
question
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
selectedOptions?: string[];
|
|
26
|
-
customInput?: string;
|
|
27
|
-
/** Optional note attached to the selected answer in the rich ask dialog. */
|
|
28
|
-
note?: string;
|
|
29
|
-
/** Label of the option the note is on; unset when it is on the custom answer. */
|
|
30
|
-
noteOption?: string;
|
|
31
|
-
/** True when the answer was auto-selected because the dialog timed out. */
|
|
8
|
+
/** Each named field's question and answer text, in form order (from `formAnswers`). */
|
|
9
|
+
answers: FormAnswer[];
|
|
10
|
+
/** The deadline submitted the form's current values instead of the user. */
|
|
32
11
|
timedOut?: boolean;
|
|
33
|
-
/** Multi-part question mode */
|
|
34
|
-
results?: QuestionResult[];
|
|
35
|
-
/** Chat redirect: the user chose "Chat about this" instead of answering. */
|
|
36
|
-
chatRedirect?: boolean;
|
|
37
|
-
/** Questions surfaced when chatRedirect is true. */
|
|
38
|
-
questions?: string[];
|
|
39
|
-
}
|
|
40
|
-
interface AskRenderOption {
|
|
41
|
-
label: string;
|
|
42
|
-
description?: string;
|
|
43
12
|
}
|
|
44
13
|
interface AskRenderArgs {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
multi?: boolean;
|
|
48
|
-
questions?: Array<{
|
|
49
|
-
id: string;
|
|
50
|
-
question: string;
|
|
51
|
-
options: AskRenderOption[];
|
|
52
|
-
multi?: boolean;
|
|
53
|
-
}>;
|
|
14
|
+
/** The form the model asks with; streams in partially. */
|
|
15
|
+
html?: string;
|
|
54
16
|
}
|
|
55
17
|
/**
|
|
56
18
|
* Marker glyph for a question option. Single-choice questions render circular radio
|
|
57
19
|
* buttons (pick one); multi-select questions render rectangular checkboxes (pick many).
|
|
58
20
|
*/
|
|
59
21
|
export declare function optionMarker(uiTheme: Theme, multi: boolean | undefined, selected: boolean): string;
|
|
60
|
-
/** Render question forms and their
|
|
22
|
+
/** Render HTML question forms and their submitted answers. */
|
|
61
23
|
export declare const askToolRenderer: {
|
|
62
24
|
describeCall(args: AskRenderArgs): NativeToolView | undefined;
|
|
63
25
|
describeResult(result: ToolRenderResult<AskToolDetails>, _options?: RenderResultOptions, args?: AskRenderArgs): NativeToolView | undefined;
|
|
64
26
|
mergeCallAndResult: true;
|
|
65
|
-
renderCall(args: AskRenderArgs,
|
|
27
|
+
renderCall(args: AskRenderArgs, options: RenderResultOptions, uiTheme: Theme): Component;
|
|
66
28
|
renderResult(result: {
|
|
67
29
|
content: Array<{
|
|
68
30
|
type: string;
|
|
69
31
|
text?: string;
|
|
70
32
|
}>;
|
|
71
33
|
details?: AskToolDetails;
|
|
72
|
-
},
|
|
34
|
+
}, options: RenderResultOptions, uiTheme: Theme, args?: AskRenderArgs): Component;
|
|
73
35
|
};
|
|
74
36
|
export {};
|
|
@@ -161,12 +161,12 @@ export interface UpdateNotesDetails {
|
|
|
161
161
|
/** Render update-notes tool calls and results. */
|
|
162
162
|
export declare const updateNotesToolRenderer: {
|
|
163
163
|
renderCall(args: {
|
|
164
|
-
body
|
|
164
|
+
body?: string;
|
|
165
165
|
append_idea?: string;
|
|
166
166
|
}, _options: import("./renderer.js").RenderResultOptions, theme: Theme): Text;
|
|
167
167
|
renderResult(result: ToolRenderResult<UpdateNotesDetails>, _options: import("./renderer.js").RenderResultContextOptions, theme: Theme): Text;
|
|
168
168
|
describeCall(args: {
|
|
169
|
-
body
|
|
169
|
+
body?: string;
|
|
170
170
|
append_idea?: string;
|
|
171
171
|
}): NativeToolView;
|
|
172
172
|
describeResult(result: ToolRenderResult<UpdateNotesDetails>): NativeToolView | undefined;
|
|
@@ -68,6 +68,10 @@ export interface EvalCellResult {
|
|
|
68
68
|
export interface EvalToolDetails {
|
|
69
69
|
cells?: EvalCellResult[];
|
|
70
70
|
images?: ImageContent[];
|
|
71
|
+
/**
|
|
72
|
+
* Call-level status events, written by older builds beside or instead of `cells`; current results
|
|
73
|
+
* keep them on each cell only.
|
|
74
|
+
*/
|
|
71
75
|
statusEvents?: EvalStatusEvent[];
|
|
72
76
|
/** Evictable events dropped from the front of `statusEvents` (see {@link recordStatusEvent}). */
|
|
73
77
|
statusEventsElided?: number;
|
|
@@ -54,6 +54,8 @@ export interface FileMatchSection {
|
|
|
54
54
|
export declare function formatFileMatches(files: string[], grouped: boolean, renderFile: (filePath: string) => FileMatchSection): GroupedFilesOutput;
|
|
55
55
|
/** Whether a row of grouped output is a code-frame row the search matched (`*12│…`). */
|
|
56
56
|
export declare function isMatchRow(line: string): boolean;
|
|
57
|
+
/** Whether a row of grouped output is a `#` directory or file header; single-file scopes print none. */
|
|
58
|
+
export declare function isGroupedHeader(line: string): boolean;
|
|
57
59
|
/** Per-line classification of grouped output, used by renderers for file rows and hyperlinks. */
|
|
58
60
|
export interface GroupedLineContext {
|
|
59
61
|
/** Directory header, file header, or any non-header body/content line. */
|
|
@@ -4,8 +4,12 @@ import type { ShellTrace, ShellVizPreferences, ShellVizPresentation } from "@lin
|
|
|
4
4
|
export type ShellVisualizationSource = RunTrace | ShellVisualization;
|
|
5
5
|
/** Bind the immutable snapshot before publishing it; live paints borrow the actual run. */
|
|
6
6
|
export declare function attachShellTrace(snapshot: ShellTrace, trace: RunTrace): void;
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Historical traces restore their canonical native archive only once per snapshot.
|
|
9
|
+
* `undefined` when the engine rejects the snapshot (e.g. a `tool_result` hook rewrote
|
|
10
|
+
* `script`); callers then render the plain command and output.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shellVisualization(snapshot: ShellTrace): ShellVisualizationSource | undefined;
|
|
9
13
|
/** Python-like Pseudo, all layers enabled, one pane, live, paused, normal speed. */
|
|
10
14
|
export declare function defaultShellVizPreferences(): ShellVizPreferences;
|
|
11
15
|
/** Render through native ownership; an explicit replay cursor never uses the normal output sink. */
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
export declare const XD_URL_PREFIX = "xd://";
|
|
3
3
|
/** Returns the canonical tool name from a bare or `xd://`-prefixed spelling. */
|
|
4
4
|
export declare function stripXdUrlPrefix(name: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Drop peelable trailing selectors that some bridges append to file reads.
|
|
7
|
+
* Device URLs advertise `selectors: "none"`, so these must not become part of
|
|
8
|
+
* the mounted tool name (`wiki_observe:raw`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function stripXdPeelableSelectors(name: string): string;
|
|
5
11
|
/**
|
|
6
12
|
* Parse an `xd://` URL into its device target.
|
|
7
13
|
* Returns `null` for other or malformed URLs and `name: null` for the root.
|
|
@@ -31,6 +31,14 @@ export declare class Win32InputModeDecoder {
|
|
|
31
31
|
#private;
|
|
32
32
|
/** Whether relayed VT text is held waiting for the rest of its sequence. */
|
|
33
33
|
get hasPendingSequence(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the held relayed text is an OSC/DCS/APC string still waiting for
|
|
36
|
+
* its terminator (a TSP event, a clipboard or colour reply). Unlike a lone
|
|
37
|
+
* ESC or a short CSI, releasing it early cannot be mistaken for a key: the
|
|
38
|
+
* head would be handed on as a fragment and the tail typed as text. A bare
|
|
39
|
+
* two-byte introducer is not a string yet: it may be an Alt chord (Alt+]).
|
|
40
|
+
*/
|
|
41
|
+
get hasPendingString(): boolean;
|
|
34
42
|
/**
|
|
35
43
|
* Release held VT text as-is. The caller invokes this once no further bytes
|
|
36
44
|
* arrived in time, so a lone relayed ESC still acts as the Escape key.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@linxiraos/pi-tui",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"description": "Terminal User Interface library with differential rendering for efficient text-based applications",
|
|
6
6
|
"homepage": "https://linxira-os.github.io/zeta/",
|
|
7
7
|
"author": "Linxira-OS",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"gen:glyphs": "bun scripts/gen-glyphs.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@linxiraos/zeta-schema": "1.
|
|
42
|
-
"@linxiraos/pi-agent-core": "1.
|
|
43
|
-
"@linxiraos/pi-ai": "1.
|
|
44
|
-
"@linxiraos/pi-catalog": "1.
|
|
45
|
-
"@linxiraos/pi-natives": "1.
|
|
46
|
-
"@linxiraos/pi-utils": "1.
|
|
47
|
-
"@linxiraos/pi-wire": "1.
|
|
48
|
-
"@linxiraos/zeta-compact": "1.
|
|
41
|
+
"@linxiraos/zeta-schema": "1.5.0",
|
|
42
|
+
"@linxiraos/pi-agent-core": "1.5.0",
|
|
43
|
+
"@linxiraos/pi-ai": "1.5.0",
|
|
44
|
+
"@linxiraos/pi-catalog": "1.5.0",
|
|
45
|
+
"@linxiraos/pi-natives": "1.5.0",
|
|
46
|
+
"@linxiraos/pi-utils": "1.5.0",
|
|
47
|
+
"@linxiraos/pi-wire": "1.5.0",
|
|
48
|
+
"@linxiraos/zeta-compact": "1.5.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"kitty-vt-wasm": "^0.2.0"
|
package/src/charts/table-data.ts
CHANGED
|
@@ -1059,12 +1059,25 @@ function findComposition(measures: readonly TableColumn[], rows: readonly number
|
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
1061
|
if (sums.size > 0) {
|
|
1062
|
-
//
|
|
1063
|
-
const
|
|
1062
|
+
// Rounding tolerance can admit both A ≈ B + C and B ≈ A + C; neither is a usable composition.
|
|
1063
|
+
const active = new Set<number>();
|
|
1064
|
+
const leaves = (index: number): number[] | undefined => {
|
|
1065
|
+
if (active.has(index)) return undefined;
|
|
1066
|
+
const parts = sums.get(index);
|
|
1067
|
+
if (!parts) return [index];
|
|
1068
|
+
active.add(index);
|
|
1069
|
+
const branches = parts.map(part => leaves(part.index));
|
|
1070
|
+
active.delete(index);
|
|
1071
|
+
return branches.every((branch): branch is number[] => branch !== undefined) ? branches.flat() : undefined;
|
|
1072
|
+
};
|
|
1073
|
+
const expanded = new Map([...sums.keys()].map(index => [index, leaves(index)]));
|
|
1074
|
+
if ([...expanded.values()].some(parts => parts === undefined)) return undefined;
|
|
1075
|
+
// Acyclic now, so some whole is nobody's part.
|
|
1064
1076
|
const nested = new Set([...sums.values()].flatMap(parts => parts.map(part => part.index)));
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1067
|
-
|
|
1077
|
+
const root = [...sums.keys()]
|
|
1078
|
+
.filter(index => !nested.has(index))
|
|
1079
|
+
.sort((a, b) => expanded.get(b)!.length - expanded.get(a)!.length)[0]!;
|
|
1080
|
+
return { whole: root, parts: expanded.get(root)!.sort((a, b) => a - b), exact: true };
|
|
1068
1081
|
}
|
|
1069
1082
|
const whole = pool.find(column => WHOLE_HEADER.test(column.header));
|
|
1070
1083
|
if (!whole) return undefined;
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
buildAsyncResultComponent,
|
|
40
40
|
buildFileMentionBlock,
|
|
41
41
|
buildIrcMessageCard,
|
|
42
|
+
buildParentIrcMessageCard,
|
|
42
43
|
buildLaunchCompletionBlock,
|
|
43
44
|
normalizeToolArgs,
|
|
44
45
|
resolveAssistantErrorPresentation,
|
|
@@ -65,7 +66,7 @@ import {
|
|
|
65
66
|
import { groupedReadUsageCallIds, ReadToolGroupComponent, readArgsCollapseIntoGroup } from "./read-tool-group";
|
|
66
67
|
import { isReplyWrite, ReplyWriteComponent, replyDisplayMessage, toolResultReplies } from "./reply-write";
|
|
67
68
|
import { SkillMessageComponent } from "./skill-message";
|
|
68
|
-
import { ToolExecutionComponent, type ToolExecutionHandle } from "./tool-execution";
|
|
69
|
+
import { toolRenderName, ToolExecutionComponent, type ToolExecutionHandle } from "./tool-execution";
|
|
69
70
|
import { TranscriptContainer } from "../chrome/transcript-container";
|
|
70
71
|
import { createUsageRowBlock, TurnUsageTally, turnElapsedMs } from "../overlays/usage-row";
|
|
71
72
|
import { CollapsedSyntheticMessageComponent, UserMessageComponent } from "./user-message";
|
|
@@ -328,6 +329,12 @@ export class ChatTranscriptBuilder {
|
|
|
328
329
|
// A user prompt closes the poll-displacement window, same as the live path.
|
|
329
330
|
if (message.role === "user") this.#resolveWaitingPoll();
|
|
330
331
|
if (message.role === "user") this.#resolveTodoSnapshot();
|
|
332
|
+
if (message.role === "user" && message.parentIrc) {
|
|
333
|
+
this.container.addChild(
|
|
334
|
+
buildParentIrcMessageCard(message.parentIrc, message.timestamp, () => this.#expanded),
|
|
335
|
+
);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
331
338
|
const userText = message.role === "user" ? textContent(message.content) : "";
|
|
332
339
|
if (userText) {
|
|
333
340
|
const isSynthetic = message.role === "developer" ? true : (message.synthetic ?? false);
|
|
@@ -476,10 +483,16 @@ export class ChatTranscriptBuilder {
|
|
|
476
483
|
|
|
477
484
|
for (const content of message.content) {
|
|
478
485
|
if (content.type !== "toolCall") continue;
|
|
479
|
-
|
|
486
|
+
// Mirror the live path (event-controller/ui-helpers): look the registry
|
|
487
|
+
// entry up by the wire name, then route and construct the card under
|
|
488
|
+
// the canonical name so `toolRenderers[toolName]` resolves identically
|
|
489
|
+
// live and rebuilt.
|
|
490
|
+
const tool = this.#deps.getTool?.(content.name);
|
|
491
|
+
const renderToolName = toolRenderName(content.name, tool);
|
|
492
|
+
this.#resolveWaitingPoll(renderToolName);
|
|
480
493
|
|
|
481
494
|
const afterToolSegment = timeline.afterToolCalls.get(content.id);
|
|
482
|
-
if (
|
|
495
|
+
if (renderToolName === "read" && readArgsCollapseIntoGroup(content.arguments)) {
|
|
483
496
|
if (hasErrorStop && errorMessage) {
|
|
484
497
|
const group = this.#ensureReadGroup();
|
|
485
498
|
group.updateArgs(content.arguments, content.id);
|
|
@@ -502,9 +515,9 @@ export class ChatTranscriptBuilder {
|
|
|
502
515
|
|
|
503
516
|
this.#readGroup?.seal();
|
|
504
517
|
this.#readGroup = null;
|
|
505
|
-
const builtIn = this.#deps.isBuiltInTool?.(
|
|
518
|
+
const builtIn = this.#deps.isBuiltInTool?.(renderToolName) ?? true;
|
|
506
519
|
let component: ToolExecutionHandle;
|
|
507
|
-
if (builtIn && isReplyWrite(
|
|
520
|
+
if (builtIn && isReplyWrite(renderToolName, content.arguments) === true) {
|
|
508
521
|
const reply = new ReplyWriteComponent({
|
|
509
522
|
requestRender: () => this.#deps.requestRender(),
|
|
510
523
|
imageBudget: this.#deps.ui.imageBudget,
|
|
@@ -516,7 +529,7 @@ export class ChatTranscriptBuilder {
|
|
|
516
529
|
component = reply;
|
|
517
530
|
} else {
|
|
518
531
|
const card = new ToolExecutionComponent(
|
|
519
|
-
|
|
532
|
+
renderToolName,
|
|
520
533
|
content.arguments,
|
|
521
534
|
{
|
|
522
535
|
useBuiltInRenderer: builtIn,
|
|
@@ -525,7 +538,7 @@ export class ChatTranscriptBuilder {
|
|
|
525
538
|
showImages: displayPreferences.showImages,
|
|
526
539
|
transcriptPresenters: false,
|
|
527
540
|
},
|
|
528
|
-
|
|
541
|
+
tool,
|
|
529
542
|
this.#deps.ui,
|
|
530
543
|
this.#deps.cwd,
|
|
531
544
|
content.id,
|
|
@@ -561,7 +574,11 @@ export class ChatTranscriptBuilder {
|
|
|
561
574
|
|
|
562
575
|
#appendToolResult(message: Extract<AgentMessage, { role: "toolResult" }>): void {
|
|
563
576
|
const pending = this.#pendingTools.get(message.toolCallId);
|
|
564
|
-
|
|
577
|
+
// Mirror the call side: resolve the wire toolName through the registry so
|
|
578
|
+
// aliased results route under the canonical name their call was built with.
|
|
579
|
+
const tool = this.#deps.getTool?.(message.toolName);
|
|
580
|
+
const renderToolName = toolRenderName(message.toolName, tool);
|
|
581
|
+
const isReadGroupResult = renderToolName === "read" && (!pending || pending instanceof ReadToolGroupComponent);
|
|
565
582
|
if (isReadGroupResult) {
|
|
566
583
|
let component = pending;
|
|
567
584
|
if (!component) {
|
|
@@ -591,10 +608,10 @@ export class ChatTranscriptBuilder {
|
|
|
591
608
|
if (!pending) return;
|
|
592
609
|
pending.updateResult(message, false, message.toolCallId);
|
|
593
610
|
this.#pendingTools.delete(message.toolCallId);
|
|
594
|
-
if (
|
|
611
|
+
if (renderToolName === "wait" && pending instanceof ToolExecutionComponent && pending.isDisplaceableBlock()) {
|
|
595
612
|
this.#waitingPoll = pending;
|
|
596
613
|
} else if (
|
|
597
|
-
|
|
614
|
+
renderToolName === "todo" &&
|
|
598
615
|
pending instanceof ToolExecutionComponent &&
|
|
599
616
|
pending.canBeDisplacedBy("todo")
|
|
600
617
|
) {
|
|
@@ -77,6 +77,58 @@ export class InvalidImageDataError extends Error {
|
|
|
77
77
|
*/
|
|
78
78
|
const DECODE_PROBE_EDGE_PX = 1;
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Whether a JPEG stream reaches an EOI marker.
|
|
82
|
+
*
|
|
83
|
+
* `Bun.Image` renders a truncated JPEG by padding the rows its missing scan
|
|
84
|
+
* data never covered, so a successful decode cannot tell a complete file from
|
|
85
|
+
* one cut mid-scan. Strict decoders — the ones behind vision providers — reject
|
|
86
|
+
* those bytes with "unsupported image", and the provider fails the whole
|
|
87
|
+
* request. Walk the marker structure instead: segments carry their length, and
|
|
88
|
+
* entropy-coded scan data is skipped by JPEG's byte-stuffing rules, so an EOI
|
|
89
|
+
* inside an embedded thumbnail cannot be mistaken for the file's end. Metadata
|
|
90
|
+
* appended after the EOI (MPF, motion photos) still passes.
|
|
91
|
+
*/
|
|
92
|
+
function jpegStreamIsComplete(bytes: Uint8Array): boolean {
|
|
93
|
+
if (bytes.length < 4 || bytes[0] !== 0xff || bytes[1] !== 0xd8) return false;
|
|
94
|
+
let offset = 2;
|
|
95
|
+
while (offset < bytes.length) {
|
|
96
|
+
if (bytes[offset] !== 0xff) return false;
|
|
97
|
+
let markOffset = offset + 1;
|
|
98
|
+
while (markOffset < bytes.length && bytes[markOffset] === 0xff) markOffset++;
|
|
99
|
+
if (markOffset >= bytes.length) return false;
|
|
100
|
+
const marker = bytes[markOffset];
|
|
101
|
+
if (marker === 0xd9) return true;
|
|
102
|
+
offset = markOffset + 1;
|
|
103
|
+
if (marker === 0x01 || (marker >= 0xd0 && marker <= 0xd7)) continue;
|
|
104
|
+
if (marker === 0xd8) return false;
|
|
105
|
+
if (offset + 1 >= bytes.length) return false;
|
|
106
|
+
const segmentLength = (bytes[offset] << 8) | bytes[offset + 1];
|
|
107
|
+
if (segmentLength < 2) return false;
|
|
108
|
+
offset += segmentLength;
|
|
109
|
+
if (offset > bytes.length) return false;
|
|
110
|
+
if (marker === 0xda) {
|
|
111
|
+
// Entropy-coded data: 0xFF is stuffed as FF00, restart markers are
|
|
112
|
+
// standalone, and every other following byte opens the next segment.
|
|
113
|
+
while (true) {
|
|
114
|
+
const next = bytes.indexOf(0xff, offset);
|
|
115
|
+
if (next < 0) return false;
|
|
116
|
+
let scan = next + 1;
|
|
117
|
+
while (scan < bytes.length && bytes[scan] === 0xff) scan++;
|
|
118
|
+
if (scan >= bytes.length) return false;
|
|
119
|
+
const code = bytes[scan];
|
|
120
|
+
if (code === 0x00 || (code >= 0xd0 && code <= 0xd7)) {
|
|
121
|
+
offset = scan + 1;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
offset = next;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
80
132
|
/**
|
|
81
133
|
* Why an image cannot be decoded, or `null` when it decodes.
|
|
82
134
|
*
|
|
@@ -95,6 +147,9 @@ export async function imageDecodeFailureReason(image: ImageContent): Promise<str
|
|
|
95
147
|
if (detected && detected.mimeType !== image.mimeType.toLowerCase()) {
|
|
96
148
|
return `declared ${image.mimeType} but contains ${detected.mimeType}`;
|
|
97
149
|
}
|
|
150
|
+
if (image.mimeType.toLowerCase() === "image/jpeg" && !jpegStreamIsComplete(bytes)) {
|
|
151
|
+
return "truncated JPEG data: no EOI marker";
|
|
152
|
+
}
|
|
98
153
|
try {
|
|
99
154
|
// Decode in full (that is what catches a hole in the compressed stream),
|
|
100
155
|
// then terminate into a 1x1 raster's bytes instead of re-encoding at the
|