@agi-fans/dsh-tui 0.25.0 → 0.26.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.
- package/lib/CHANGELOG.md +31 -2
- package/lib/chrome/box.d.ts +7 -0
- package/lib/chrome/box.js +1 -0
- package/lib/chrome/box.js.map +1 -1
- package/lib/chrome/main-screen-renderer.d.ts +2 -0
- package/lib/chrome/main-screen-renderer.js +6 -0
- package/lib/chrome/main-screen-renderer.js.map +1 -1
- package/lib/chrome/renderer.d.ts +12 -0
- package/lib/chrome/renderer.js.map +1 -1
- package/lib/chrome/status-line.js +3 -2
- package/lib/chrome/status-line.js.map +1 -1
- package/lib/chrome/width.d.ts +2 -0
- package/lib/chrome/width.js +10 -0
- package/lib/chrome/width.js.map +1 -1
- package/lib/commands/session.js +23 -12
- package/lib/commands/session.js.map +1 -1
- package/lib/definition.d.ts +16 -2
- package/lib/input/actions.d.ts +1 -1
- package/lib/input/actions.js +16 -5
- package/lib/input/actions.js.map +1 -1
- package/lib/input/clipboard.js +2 -1
- package/lib/input/clipboard.js.map +1 -1
- package/lib/input/editor.js +4 -0
- package/lib/input/editor.js.map +1 -1
- package/lib/input/key-platform.d.ts +2 -0
- package/lib/input/key-platform.js +8 -0
- package/lib/input/key-platform.js.map +1 -0
- package/lib/input/keybindings-config.d.ts +2 -1
- package/lib/input/keybindings-config.js +14 -9
- package/lib/input/keybindings-config.js.map +1 -1
- package/lib/input/keys.d.ts +2 -0
- package/lib/input/keys.js +10 -0
- package/lib/input/keys.js.map +1 -1
- package/lib/locale/zh.d.ts +3 -2
- package/lib/locale/zh.js +3 -2
- package/lib/locale/zh.js.map +1 -1
- package/lib/runtime/help-reader.d.ts +1 -1
- package/lib/runtime/help-reader.js +2 -2
- package/lib/runtime/help-reader.js.map +1 -1
- package/lib/runtime/herdr-agent.d.ts +2 -0
- package/lib/runtime/herdr-agent.js +7 -1
- package/lib/runtime/herdr-agent.js.map +1 -1
- package/lib/runtime/provider-local.d.ts +9 -1
- package/lib/runtime/provider-local.js +247 -51
- package/lib/runtime/provider-local.js.map +1 -1
- package/lib/runtime/terminal-state.d.ts +4 -1
- package/lib/runtime/terminal-state.js +28 -7
- package/lib/runtime/terminal-state.js.map +1 -1
- package/lib/session/session-controller.js +56 -6
- package/lib/session/session-controller.js.map +1 -1
- package/lib/views/file-browser.d.ts +3 -0
- package/lib/views/file-browser.js +1 -0
- package/lib/views/file-browser.js.map +1 -1
- package/lib/views/hotkeys.d.ts +4 -4
- package/lib/views/hotkeys.js +24 -14
- package/lib/views/hotkeys.js.map +1 -1
- package/lib/views/settings-list.js +2 -2
- package/lib/views/settings-list.js.map +1 -1
- package/lib/views/transcript-render.d.ts +1 -0
- package/lib/views/transcript-render.js +25 -12
- package/lib/views/transcript-render.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export interface AgentActivityStatus {
|
|
|
8
8
|
export type TerminalProgramState = AgentActivityState | 'done' | 'error';
|
|
9
9
|
export interface TerminalProgramStatus {
|
|
10
10
|
readonly state: TerminalProgramState;
|
|
11
|
+
readonly title?: string;
|
|
11
12
|
readonly message?: string;
|
|
12
13
|
readonly kind?: TerminalAttentionKind;
|
|
13
14
|
}
|
|
@@ -24,13 +25,15 @@ export declare function terminalProgressSequence(state: TerminalProgramState | '
|
|
|
24
25
|
/** These lifecycle reports can themselves create a terminal notification. */
|
|
25
26
|
export declare function programStatusNeedsAttention(state: TerminalProgramState): boolean;
|
|
26
27
|
export declare function settledProgramState(reason?: string): 'idle' | 'done' | 'error';
|
|
27
|
-
export declare function terminalTitle(mode: TerminalTitleMode, status: TerminalProgramStatus, session: string | undefined, cwd: string, branch?: string): string;
|
|
28
|
+
export declare function terminalTitle(mode: TerminalTitleMode, status: TerminalProgramStatus, session: string | undefined, cwd: string, branch?: string, nativeStatus?: boolean): string;
|
|
28
29
|
export declare class AgentActivityController {
|
|
29
30
|
#private;
|
|
30
31
|
get current(): AgentActivityStatus;
|
|
31
32
|
get program(): TerminalProgramStatus;
|
|
32
33
|
start(): AgentActivityStatus;
|
|
33
34
|
setRunning(running: boolean): AgentActivityStatus | undefined;
|
|
35
|
+
compactionStart(id?: string): AgentActivityStatus | undefined;
|
|
36
|
+
compactionEnd(id?: string, error?: string): AgentActivityStatus | undefined;
|
|
34
37
|
settled(reason: string): void;
|
|
35
38
|
resetResult(): void;
|
|
36
39
|
prompt(message?: string, kind?: TerminalAttentionKind): AgentActivityStatus | undefined;
|
|
@@ -15,9 +15,10 @@ function clean(value, limit) {
|
|
|
15
15
|
export function programStatusSequence(status) {
|
|
16
16
|
if (status === 'clear')
|
|
17
17
|
return '\x1b]7501;state=clear:app=omdsh\x1b\\';
|
|
18
|
+
const title = clean(status.title, 240);
|
|
18
19
|
const message = clean(status.message, 240);
|
|
19
20
|
const kind = status.state === 'blocked' && status.kind !== undefined ? `:kind=${status.kind}` : '';
|
|
20
|
-
return `\x1b]7501;state=${status.state}:app=omdsh${kind}${message === undefined ? '' : `:msg=${Buffer.from(message).toString('base64')}`}\x1b\\`;
|
|
21
|
+
return `\x1b]7501;state=${status.state}:app=omdsh${kind}${title === undefined ? '' : `:title=${Buffer.from(title).toString('base64')}`}${message === undefined ? '' : `:msg=${Buffer.from(message).toString('base64')}`}\x1b\\`;
|
|
21
22
|
}
|
|
22
23
|
export function workingDirectorySequence(cwd) {
|
|
23
24
|
// A directory separator also preserves trailing control bytes in Node's URL conversion.
|
|
@@ -45,22 +46,28 @@ export function settledProgramState(reason = 'completed') {
|
|
|
45
46
|
return 'error';
|
|
46
47
|
}
|
|
47
48
|
const STATE_LABELS = { idle: 'Ready', working: 'Working', blocked: 'Needs input', done: 'Done', error: 'Failed' };
|
|
48
|
-
export function terminalTitle(mode, status, session, cwd, branch) {
|
|
49
|
+
export function terminalTitle(mode, status, session, cwd, branch, nativeStatus = false) {
|
|
49
50
|
if (mode === 'off')
|
|
50
51
|
return '';
|
|
51
|
-
if (mode === 'session')
|
|
52
|
+
if (mode === 'session' || (mode === 'status' && nativeStatus))
|
|
52
53
|
return clean(session, 120) ?? '';
|
|
53
|
-
const
|
|
54
|
+
const workspace = [basename(cwd), branch].filter(Boolean).join(' · ');
|
|
55
|
+
if (nativeStatus)
|
|
56
|
+
return clean(workspace, 120) ?? '';
|
|
57
|
+
const subject = mode === 'workspace' ? workspace : session ?? basename(cwd);
|
|
54
58
|
return clean([STATE_LABELS[status.state], subject, 'omdsh'].filter(Boolean).join(' · '), 120) ?? '';
|
|
55
59
|
}
|
|
56
60
|
export class AgentActivityController {
|
|
57
61
|
#running = false;
|
|
62
|
+
#compacting;
|
|
58
63
|
#prompts = [];
|
|
59
64
|
#last;
|
|
60
65
|
#result = 'idle';
|
|
61
66
|
get current() {
|
|
62
67
|
const prompt = this.#prompts.at(-1);
|
|
63
|
-
return prompt === undefined
|
|
68
|
+
return prompt === undefined
|
|
69
|
+
? { state: this.#running || this.#compacting !== undefined ? 'working' : 'idle' }
|
|
70
|
+
: { state: 'blocked', ...prompt };
|
|
64
71
|
}
|
|
65
72
|
get program() {
|
|
66
73
|
const current = this.current;
|
|
@@ -68,13 +75,27 @@ export class AgentActivityController {
|
|
|
68
75
|
}
|
|
69
76
|
start() { return this.#publish(true); }
|
|
70
77
|
setRunning(running) {
|
|
71
|
-
if (running && !this.#running)
|
|
78
|
+
if (running && !this.#running && this.#compacting === undefined)
|
|
72
79
|
this.#result = 'idle';
|
|
73
80
|
this.#running = running;
|
|
74
81
|
return this.#publish();
|
|
75
82
|
}
|
|
83
|
+
compactionStart(id = '') {
|
|
84
|
+
if (!this.#running && this.#compacting === undefined)
|
|
85
|
+
this.#result = 'idle';
|
|
86
|
+
this.#compacting = id;
|
|
87
|
+
return this.#publish();
|
|
88
|
+
}
|
|
89
|
+
compactionEnd(id, error) {
|
|
90
|
+
if (this.#compacting === undefined || (id !== undefined && this.#compacting !== id))
|
|
91
|
+
return undefined;
|
|
92
|
+
this.#compacting = undefined;
|
|
93
|
+
if (!this.#running)
|
|
94
|
+
this.#result = error === undefined ? 'done' : 'error';
|
|
95
|
+
return this.#publish();
|
|
96
|
+
}
|
|
76
97
|
settled(reason) { this.#result = settledProgramState(reason); }
|
|
77
|
-
resetResult() { this.#result = 'idle'; }
|
|
98
|
+
resetResult() { this.#result = 'idle'; this.#compacting = undefined; }
|
|
78
99
|
prompt(message, kind = 'question') {
|
|
79
100
|
const text = clean(message, 240);
|
|
80
101
|
this.#prompts.push({ kind, ...(text === undefined ? {} : { message: text }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-state.js","sourceRoot":"","sources":["../../src/runtime/terminal-state.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"terminal-state.js","sourceRoot":"","sources":["../../src/runtime/terminal-state.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAYxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAU,CAAA;AAEtF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAU,CAAA;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAA;AAEvD,SAAS,KAAK,CAAC,KAAyB,EAAE,KAAa;IACrD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,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
|
+
#inspectedEvents = [];
|
|
452
453
|
constructor(ctx, tui, options = {}) {
|
|
453
454
|
this.#ctx = ctx;
|
|
454
455
|
this.#tui = tui;
|
|
@@ -564,8 +565,8 @@ export class SessionRuntime {
|
|
|
564
565
|
if (active === undefined)
|
|
565
566
|
return;
|
|
566
567
|
if (event.type === 'working-directory/change') {
|
|
567
|
-
if (session
|
|
568
|
-
tui.setWorkingDirectory?.(currentWorkingDirectory(ctx, session));
|
|
568
|
+
if (session === active.handle.agent.session || session.id === this.#inspectedId) {
|
|
569
|
+
tui.setWorkingDirectory?.(currentWorkingDirectory(ctx, session), { root: session === active.handle.agent.session });
|
|
569
570
|
}
|
|
570
571
|
if (session === active.handle.agent.session) {
|
|
571
572
|
void this.#refreshSkills().catch(error => { ctx.logger.warn(error); });
|
|
@@ -576,11 +577,29 @@ export class SessionRuntime {
|
|
|
576
577
|
const child = ctx.get('agents')?.get(session.id);
|
|
577
578
|
tui.event(event, child === undefined ? undefined : ctx.get('tuiToolPresentation')?.event(child, event));
|
|
578
579
|
this.#tracker.noteEvent(session, event);
|
|
580
|
+
if (shouldRefreshSessionInfoAfter(event))
|
|
581
|
+
tui.setInspectedSubagent(this.#inspectView(session.id));
|
|
579
582
|
return;
|
|
580
583
|
}
|
|
581
584
|
if (session === active.handle.agent.session) {
|
|
582
585
|
if (event.type === 'turn/end')
|
|
583
586
|
tui.setStatus(active.handle.agent.status, { root: true, outcome: event.data.reason.kind });
|
|
587
|
+
else if (this.#inspectedId !== undefined && event.type === 'compaction/start') {
|
|
588
|
+
tui.setStatus(active.handle.agent.status, {
|
|
589
|
+
root: true,
|
|
590
|
+
compaction: { phase: 'start', id: event.data.compactionId },
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
else if (this.#inspectedId !== undefined && event.type === 'compaction/end') {
|
|
594
|
+
tui.setStatus(active.handle.agent.status, {
|
|
595
|
+
root: true,
|
|
596
|
+
compaction: {
|
|
597
|
+
phase: 'end',
|
|
598
|
+
id: event.data.compactionId,
|
|
599
|
+
...(event.data.error === undefined ? {} : { error: event.data.error }),
|
|
600
|
+
},
|
|
601
|
+
});
|
|
602
|
+
}
|
|
584
603
|
if (this.#workflows.apply(event))
|
|
585
604
|
tui.setSubagents(this.#workflows.roster(this.#tracker.snapshot()));
|
|
586
605
|
if (this.#inspectedId === undefined) {
|
|
@@ -638,6 +657,12 @@ export class SessionRuntime {
|
|
|
638
657
|
const projections = ctx.get('sessionProjections');
|
|
639
658
|
if (projections !== undefined) {
|
|
640
659
|
this.#off.push(projections.onChanged((session, key) => {
|
|
660
|
+
if (session.id === this.#inspectedId) {
|
|
661
|
+
if (key === 'sessionStats' || key === 'tokenUsage' || key === 'contextPressure' || key === 'plan'
|
|
662
|
+
|| key === 'permissions' || key === 'agentPreset' || key === 'modelSelection')
|
|
663
|
+
this.#tui.setInspectedSubagent(this.#inspectView(session.id));
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
641
666
|
if (session !== this.#active?.handle.agent.session)
|
|
642
667
|
return;
|
|
643
668
|
if (key === 'sessionStats' || key === 'tokenUsage' || key === 'contextPressure' || key === 'contextBreakdown'
|
|
@@ -1699,6 +1724,7 @@ export class SessionRuntime {
|
|
|
1699
1724
|
const agent = active.handle.agent;
|
|
1700
1725
|
this.#cancelInspectDeliveries();
|
|
1701
1726
|
this.#inspectedId = undefined;
|
|
1727
|
+
this.#inspectedEvents = [];
|
|
1702
1728
|
this.#tui.setInspectedSubagent(undefined);
|
|
1703
1729
|
this.#tui.setStatus(agent.status);
|
|
1704
1730
|
this.#tracker.sync();
|
|
@@ -1810,7 +1836,7 @@ export class SessionRuntime {
|
|
|
1810
1836
|
#inspectView(id, fallbackPhase = 'waiting') {
|
|
1811
1837
|
const view = this.#tracker.snapshot()?.agents.find(agent => agent.id === id);
|
|
1812
1838
|
const mode = view?.mode;
|
|
1813
|
-
|
|
1839
|
+
const descriptor = {
|
|
1814
1840
|
id,
|
|
1815
1841
|
label: view?.label ?? id,
|
|
1816
1842
|
phase: view?.phase ?? fallbackPhase,
|
|
@@ -1818,6 +1844,27 @@ export class SessionRuntime {
|
|
|
1818
1844
|
...(mode === undefined ? {} : { mode }),
|
|
1819
1845
|
writable: isSteerableSubagent(mode),
|
|
1820
1846
|
};
|
|
1847
|
+
if (id !== this.#inspectedId)
|
|
1848
|
+
return descriptor;
|
|
1849
|
+
const session = this.#lookupSession(id);
|
|
1850
|
+
const events = session?.ownEvents() ?? this.#inspectedEvents;
|
|
1851
|
+
this.#inspectedEvents = events;
|
|
1852
|
+
const projection = session === undefined ? undefined : this.#ctx.get('sessionProjections')?.snapshot(session).values;
|
|
1853
|
+
const child = this.#ctx.get('agents')?.get(SessionId(id));
|
|
1854
|
+
const selection = child?.model.current();
|
|
1855
|
+
// Whole-log totals include a seeded parent's history. Child activity
|
|
1856
|
+
// shares the transcript's own-event window; context pressure still
|
|
1857
|
+
// describes the complete model context, including inherited messages.
|
|
1858
|
+
const statsProjection = session !== undefined && session.inheritedEventCount > 0
|
|
1859
|
+
? projection?.contextPressure === undefined ? undefined : { contextPressure: projection.contextPressure }
|
|
1860
|
+
: projection;
|
|
1861
|
+
return {
|
|
1862
|
+
...descriptor,
|
|
1863
|
+
...(selection === undefined ? {} : modelStatus(selection)),
|
|
1864
|
+
stats: sessionStats(events, undefined, statsProjection),
|
|
1865
|
+
controls: { ...sessionControls(projection, child === undefined ? undefined : this.#ctx.get('planMode')?.get(child)),
|
|
1866
|
+
...(session?.header.agentPreset === undefined ? {} : { agentPreset: session.header.agentPreset }) },
|
|
1867
|
+
};
|
|
1821
1868
|
}
|
|
1822
1869
|
#pushSessionInfo() {
|
|
1823
1870
|
const active = this.#active;
|
|
@@ -1838,7 +1885,7 @@ export class SessionRuntime {
|
|
|
1838
1885
|
});
|
|
1839
1886
|
}
|
|
1840
1887
|
#replaceTranscript(agent, reason = 'refresh') {
|
|
1841
|
-
this.#tui.setWorkingDirectory?.(currentWorkingDirectory(this.#ctx, agent.session));
|
|
1888
|
+
this.#tui.setWorkingDirectory?.(currentWorkingDirectory(this.#ctx, agent.session), { root: true });
|
|
1842
1889
|
const events = agent.session.snapshotEvents();
|
|
1843
1890
|
this.#tui.pendingInputs?.reconcile?.(agent.id, new Set(events.flatMap(event => event.type === 'agent/inbox/spliced' ? event.data.inserted.map(message => message.id) : [])));
|
|
1844
1891
|
this.#tracker.observeCatalog(agent.session, events);
|
|
@@ -1867,6 +1914,7 @@ export class SessionRuntime {
|
|
|
1867
1914
|
this.#workflowAbort?.abort();
|
|
1868
1915
|
this.#cancelInspectDeliveries();
|
|
1869
1916
|
this.#inspectedId = undefined;
|
|
1917
|
+
this.#inspectedEvents = [];
|
|
1870
1918
|
this.#tui.setInspectedSubagent(undefined);
|
|
1871
1919
|
const agent = this.#active?.handle.agent;
|
|
1872
1920
|
if (agent === undefined)
|
|
@@ -1900,6 +1948,7 @@ export class SessionRuntime {
|
|
|
1900
1948
|
events = log.events.slice(log.inheritedEventCount);
|
|
1901
1949
|
const change = log.events.findLast(event => event.type === 'working-directory/change');
|
|
1902
1950
|
cwd = change?.type === 'working-directory/change' ? change.data.cwd : log.header.cwd;
|
|
1951
|
+
cwd ??= this.#active === undefined ? process.cwd() : currentWorkingDirectory(this.#ctx, this.#active.handle.agent.session);
|
|
1903
1952
|
}
|
|
1904
1953
|
catch {
|
|
1905
1954
|
if (request === this.#inspectEpoch) {
|
|
@@ -1917,12 +1966,13 @@ export class SessionRuntime {
|
|
|
1917
1966
|
}
|
|
1918
1967
|
this.#tui.pendingInputs?.reconcile?.(id, new Set(events.flatMap(event => event.type === 'agent/inbox/spliced' ? event.data.inserted.map(message => message.id) : [])));
|
|
1919
1968
|
this.#inspectedId = id;
|
|
1969
|
+
this.#inspectedEvents = events;
|
|
1920
1970
|
if (cwd !== undefined)
|
|
1921
|
-
this.#tui.setWorkingDirectory?.(cwd);
|
|
1971
|
+
this.#tui.setWorkingDirectory?.(cwd, { root: false });
|
|
1922
1972
|
const child = this.#ctx.get('agents')?.get(SessionId(id));
|
|
1973
|
+
this.#tui.setInspectedSubagent(this.#inspectView(id, child?.status === 'running' ? 'running' : 'waiting'));
|
|
1923
1974
|
this.#tui.replaceSession(events, child === undefined ? undefined : this.#ctx.get('tuiToolPresentation')?.session(child, events), child?.status ?? 'idle', 'refresh');
|
|
1924
1975
|
this.#replayLivePrefix(id);
|
|
1925
|
-
this.#tui.setInspectedSubagent(this.#inspectView(id, child?.status === 'running' ? 'running' : 'waiting'));
|
|
1926
1976
|
this.#tui.setStatus(child?.status ?? 'idle');
|
|
1927
1977
|
}
|
|
1928
1978
|
async #steerInspected(submission) {
|