@adhdev/daemon-core 0.6.53 → 0.6.55
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/dist/index.d.ts +76 -34
- package/dist/index.js +714 -271
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/providers/_builtin/_helpers/index.js +26 -26
- package/providers/_builtin/cli/aider-cli/provider.json +37 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/detect_status.js +20 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_approval.js +10 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_output.js +49 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/claude-cli/provider.json +9 -2
- package/providers/_builtin/cli/claude-cli/scripts/1.0/detect_status.js +31 -0
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_approval.js +38 -0
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_output.js +164 -0
- package/providers/_builtin/cli/claude-cli/scripts/1.0/scripts.js +42 -0
- package/providers/_builtin/cli/codex-cli/provider.json +9 -2
- package/providers/_builtin/cli/codex-cli/scripts/1.0/detect_status.js +20 -0
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_approval.js +15 -0
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_output.js +68 -0
- package/providers/_builtin/cli/codex-cli/scripts/1.0/scripts.js +11 -0
- package/providers/_builtin/cli/cursor-cli/provider.json +37 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/detect_status.js +19 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_approval.js +10 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/gemini-cli/provider.json +9 -2
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/detect_status.js +26 -0
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_approval.js +22 -0
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_output.js +71 -0
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/scripts.js +12 -0
- package/providers/_builtin/cli/github-copilot-cli/provider.json +37 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/detect_status.js +19 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_approval.js +9 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/goose-cli/provider.json +37 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/detect_status.js +20 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_approval.js +10 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/opencode-cli/provider.json +37 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/detect_status.js +15 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_approval.js +9 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/extension/cline/scripts/1.0/focus_editor.js +5 -5
- package/providers/_builtin/extension/cline/scripts/1.0/list_chats.js +11 -11
- package/providers/_builtin/extension/cline/scripts/1.0/list_models.js +6 -6
- package/providers/_builtin/extension/cline/scripts/1.0/list_modes.js +5 -5
- package/providers/_builtin/extension/cline/scripts/1.0/new_session.js +12 -12
- package/providers/_builtin/extension/cline/scripts/1.0/open_panel.js +7 -7
- package/providers/_builtin/extension/cline/scripts/1.0/read_chat.js +29 -29
- package/providers/_builtin/extension/cline/scripts/1.0/resolve_action.js +19 -19
- package/providers/_builtin/extension/cline/scripts/1.0/send_message.js +15 -15
- package/providers/_builtin/extension/cline/scripts/1.0/set_mode.js +4 -4
- package/providers/_builtin/extension/cline/scripts/1.0/set_model.js +4 -4
- package/providers/_builtin/extension/cline/scripts/1.0/switch_session.js +21 -21
- package/providers/_builtin/extension/codex/scripts/1.0/explore_controls_webview.js +2 -2
- package/providers/_builtin/extension/codex/scripts/1.0/list_models.js +1 -1
- package/providers/_builtin/extension/codex/scripts/1.0/list_modes.js +1 -1
- package/providers/_builtin/extension/codex/scripts/1.0/new_session.js +2 -2
- package/providers/_builtin/extension/codex/scripts/1.0/read_chat.js +6 -6
- package/providers/_builtin/extension/codex/scripts/1.0/resolve_action.js +3 -3
- package/providers/_builtin/extension/codex/scripts/1.0/set_model.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/focus_editor.js +2 -2
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_chats.js +19 -19
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_models.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_modes.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/new_session.js +17 -17
- package/providers/_builtin/ide/antigravity/scripts/1.0/read_chat.js +41 -41
- package/providers/_builtin/ide/antigravity/scripts/1.0/resolve_action.js +6 -6
- package/providers/_builtin/ide/antigravity/scripts/1.0/send_message.js +13 -13
- package/providers/_builtin/ide/antigravity/scripts/1.0/set_model.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/switch_session.js +13 -13
- package/providers/_builtin/ide/cursor/scripts/1.0/dismiss_notification.js +3 -3
- package/providers/_builtin/ide/cursor/scripts/1.0/focus_editor.js +1 -1
- package/providers/_builtin/ide/cursor/scripts/1.0/list_models.js +12 -12
- package/providers/_builtin/ide/cursor/scripts/1.0/list_modes.js +5 -5
- package/providers/_builtin/ide/cursor/scripts/1.0/list_notifications.js +2 -2
- package/providers/_builtin/ide/cursor/scripts/1.0/list_sessions.js +5 -5
- package/providers/_builtin/ide/cursor/scripts/1.0/new_session.js +1 -1
- package/providers/_builtin/ide/cursor/scripts/1.0/open_panel.js +3 -3
- package/providers/_builtin/ide/cursor/scripts/1.0/read_chat.js +9 -9
- package/providers/_builtin/ide/cursor/scripts/1.0/resolve_action.js +4 -4
- package/providers/_builtin/ide/cursor/scripts/1.0/send_message.js +5 -5
- package/providers/_builtin/ide/cursor/scripts/1.0/set_mode.js +4 -4
- package/providers/_builtin/ide/cursor/scripts/1.0/set_model.js +12 -12
- package/providers/_builtin/ide/cursor/scripts/1.0/switch_session.js +2 -2
- package/providers/_builtin/ide/kiro/scripts/1.0/focus_editor.js +2 -2
- package/providers/_builtin/ide/kiro/scripts/1.0/open_panel.js +7 -7
- package/providers/_builtin/ide/kiro/scripts/1.0/resolve_action.js +3 -3
- package/providers/_builtin/ide/kiro/scripts/1.0/send_message.js +4 -4
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_sessions.js +2 -2
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_new_session.js +5 -5
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_read_chat.js +13 -13
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_resolve_action.js +1 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_send_message.js +8 -8
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_mode.js +1 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_model.js +1 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_switch_session.js +3 -3
- package/providers/_builtin/ide/pearai/.tmp/after_rich.json +157 -0
- package/providers/_builtin/ide/pearai/.tmp/after_rich_raw.json +161 -0
- package/providers/_builtin/ide/pearai/.tmp/after_switch.json +592 -0
- package/providers/_builtin/ide/pearai/.tmp/after_switch_raw.json +596 -0
- package/providers/_builtin/ide/pearai/.tmp/home_dump_raw.json +176 -0
- package/providers/_builtin/ide/pearai/.tmp/items_raw.json +778 -0
- package/providers/_builtin/ide/pearai/.tmp/webview_dump.json +157 -0
- package/providers/_builtin/ide/pearai/.tmp/webview_dump_raw.json +161 -0
- package/providers/_builtin/ide/pearai/provider.json +1 -3
- package/providers/_builtin/ide/pearai/scripts/1.0/focus_editor.js +12 -16
- package/providers/_builtin/ide/pearai/scripts/1.0/list_models.js +45 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/list_modes.js +44 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/list_sessions.js +82 -27
- package/providers/_builtin/ide/pearai/scripts/1.0/new_session.js +26 -43
- package/providers/_builtin/ide/pearai/scripts/1.0/open_panel.js +10 -33
- package/providers/_builtin/ide/pearai/scripts/1.0/read_chat.js +169 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/resolve_action.js +47 -41
- package/providers/_builtin/ide/pearai/scripts/1.0/scripts.js +36 -7
- package/providers/_builtin/ide/pearai/scripts/1.0/send_message.js +97 -22
- package/providers/_builtin/ide/pearai/scripts/1.0/set_mode.js +51 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/set_model.js +54 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/switch_session.js +81 -0
- package/providers/_builtin/ide/trae/scripts/1.0/focus_editor.js +2 -2
- package/providers/_builtin/ide/trae/scripts/1.0/list_chats.js +2 -2
- package/providers/_builtin/ide/trae/scripts/1.0/new_session.js +4 -4
- package/providers/_builtin/ide/trae/scripts/1.0/open_panel.js +6 -6
- package/providers/_builtin/ide/trae/scripts/1.0/read_chat.js +13 -13
- package/providers/_builtin/ide/trae/scripts/1.0/resolve_action.js +3 -3
- package/providers/_builtin/ide/trae/scripts/1.0/send_message.js +11 -11
- package/providers/_builtin/ide/trae/scripts/1.0/switch_session.js +2 -2
- package/providers/_builtin/ide/windsurf/scripts/1.0/focus_editor.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_chats.js +4 -4
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_sessions.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0/new_session.js +9 -9
- package/providers/_builtin/ide/windsurf/scripts/1.0/open_panel.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0/resolve_action.js +8 -8
- package/providers/_builtin/ide/windsurf/scripts/1.0/switch_session.js +8 -8
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/focus_editor.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_chats.js +12 -12
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/new_session.js +15 -15
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/open_panel.js +10 -10
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/read_chat.js +33 -33
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/resolve_action.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/send_message.js +16 -16
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/switch_session.js +7 -7
- package/providers/_builtin/registry.json +76 -3
- package/src/cli-adapters/provider-cli-adapter.ts +267 -251
- package/src/cli-adapters/terminal-screen.ts +268 -0
- package/src/commands/chat-commands.ts +41 -15
- package/src/commands/cli-manager.ts +4 -2
- package/src/daemon/dev-server.ts +245 -35
- package/src/providers/acp-provider-instance.ts +1 -1
- package/src/providers/cli-provider-instance.ts +21 -8
- package/src/providers/provider-loader.ts +3 -2
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_list_models.js +0 -43
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_list_modes.js +0 -35
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_list_sessions.js +0 -62
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_new_session.js +0 -49
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_read_chat.js +0 -92
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_resolve_action.js +0 -59
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_send_message.js +0 -72
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_set_mode.js +0 -36
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_set_model.js +0 -36
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_switch_session.js +0 -34
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal VT screen model for PTY parsing.
|
|
3
|
+
*
|
|
4
|
+
* This is not a full terminal emulator. It exists to turn raw PTY output into a
|
|
5
|
+
* stable "current screen" snapshot so provider parsers can inspect visible UI
|
|
6
|
+
* state instead of reparsing the full accumulated log stream.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function clamp(value: number, min: number, max: number): number {
|
|
10
|
+
return Math.max(min, Math.min(max, value));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class TerminalScreen {
|
|
14
|
+
private rows: number;
|
|
15
|
+
private cols: number;
|
|
16
|
+
private cursorRow = 0;
|
|
17
|
+
private cursorCol = 0;
|
|
18
|
+
private savedRow = 0;
|
|
19
|
+
private savedCol = 0;
|
|
20
|
+
private lines: string[][];
|
|
21
|
+
|
|
22
|
+
constructor(rows = 40, cols = 120) {
|
|
23
|
+
this.rows = rows;
|
|
24
|
+
this.cols = cols;
|
|
25
|
+
this.lines = this.makeLines(rows, cols);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
reset(rows = this.rows, cols = this.cols): void {
|
|
29
|
+
this.rows = rows;
|
|
30
|
+
this.cols = cols;
|
|
31
|
+
this.cursorRow = 0;
|
|
32
|
+
this.cursorCol = 0;
|
|
33
|
+
this.savedRow = 0;
|
|
34
|
+
this.savedCol = 0;
|
|
35
|
+
this.lines = this.makeLines(rows, cols);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resize(rows: number, cols: number): void {
|
|
39
|
+
const nextRows = Math.max(1, rows | 0);
|
|
40
|
+
const nextCols = Math.max(1, cols | 0);
|
|
41
|
+
const next = this.makeLines(nextRows, nextCols);
|
|
42
|
+
const copyRows = Math.min(this.rows, nextRows);
|
|
43
|
+
const copyCols = Math.min(this.cols, nextCols);
|
|
44
|
+
for (let r = 0; r < copyRows; r++) {
|
|
45
|
+
for (let c = 0; c < copyCols; c++) {
|
|
46
|
+
next[r][c] = this.lines[r][c];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
this.rows = nextRows;
|
|
50
|
+
this.cols = nextCols;
|
|
51
|
+
this.lines = next;
|
|
52
|
+
this.cursorRow = clamp(this.cursorRow, 0, this.rows - 1);
|
|
53
|
+
this.cursorCol = clamp(this.cursorCol, 0, this.cols - 1);
|
|
54
|
+
this.savedRow = clamp(this.savedRow, 0, this.rows - 1);
|
|
55
|
+
this.savedCol = clamp(this.savedCol, 0, this.cols - 1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
write(data: string): void {
|
|
59
|
+
let i = 0;
|
|
60
|
+
while (i < data.length) {
|
|
61
|
+
const ch = data[i];
|
|
62
|
+
|
|
63
|
+
if (ch === '\x1b') {
|
|
64
|
+
const consumed = this.consumeEscape(data, i);
|
|
65
|
+
i = consumed > i ? consumed : i + 1;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (ch === '\r') {
|
|
70
|
+
this.cursorCol = 0;
|
|
71
|
+
i++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (ch === '\n') {
|
|
76
|
+
this.newLine();
|
|
77
|
+
i++;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (ch === '\b') {
|
|
82
|
+
this.cursorCol = Math.max(0, this.cursorCol - 1);
|
|
83
|
+
i++;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (ch === '\t') {
|
|
88
|
+
const nextStop = Math.min(this.cols - 1, this.cursorCol + (8 - (this.cursorCol % 8 || 8)));
|
|
89
|
+
while (this.cursorCol < nextStop) this.putChar(' ');
|
|
90
|
+
i++;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (ch >= ' ' && ch !== '\x7f') {
|
|
95
|
+
this.putChar(ch);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
i++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
getText(): string {
|
|
103
|
+
const raw = this.lines.map(line => line.join('').replace(/\s+$/, ''));
|
|
104
|
+
let start = 0;
|
|
105
|
+
let end = raw.length;
|
|
106
|
+
while (start < end && raw[start] === '') start++;
|
|
107
|
+
while (end > start && raw[end - 1] === '') end--;
|
|
108
|
+
return raw.slice(start, end).join('\n');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private consumeEscape(data: string, start: number): number {
|
|
112
|
+
const next = data[start + 1];
|
|
113
|
+
if (!next) return start + 1;
|
|
114
|
+
|
|
115
|
+
if (next === '[') {
|
|
116
|
+
let end = start + 2;
|
|
117
|
+
while (end < data.length && !/[@-~]/.test(data[end])) end++;
|
|
118
|
+
if (end >= data.length) return data.length;
|
|
119
|
+
this.applyCsi(data.slice(start + 2, end), data[end]);
|
|
120
|
+
return end + 1;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (next === ']') {
|
|
124
|
+
let end = start + 2;
|
|
125
|
+
while (end < data.length) {
|
|
126
|
+
if (data[end] === '\x07') return end + 1;
|
|
127
|
+
if (data[end] === '\x1b' && data[end + 1] === '\\') return end + 2;
|
|
128
|
+
end++;
|
|
129
|
+
}
|
|
130
|
+
return data.length;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (next === '7') {
|
|
134
|
+
this.savedRow = this.cursorRow;
|
|
135
|
+
this.savedCol = this.cursorCol;
|
|
136
|
+
return start + 2;
|
|
137
|
+
}
|
|
138
|
+
if (next === '8') {
|
|
139
|
+
this.cursorRow = this.savedRow;
|
|
140
|
+
this.cursorCol = this.savedCol;
|
|
141
|
+
return start + 2;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return start + 2;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private applyCsi(paramText: string, finalChar: string): void {
|
|
148
|
+
const privateMode = paramText.startsWith('?');
|
|
149
|
+
const normalized = privateMode ? paramText.slice(1) : paramText;
|
|
150
|
+
const params = normalized.length > 0
|
|
151
|
+
? normalized.split(';').map(p => parseInt(p || '0', 10) || 0)
|
|
152
|
+
: [0];
|
|
153
|
+
|
|
154
|
+
switch (finalChar) {
|
|
155
|
+
case 'A':
|
|
156
|
+
this.cursorRow = clamp(this.cursorRow - (params[0] || 1), 0, this.rows - 1);
|
|
157
|
+
return;
|
|
158
|
+
case 'B':
|
|
159
|
+
this.cursorRow = clamp(this.cursorRow + (params[0] || 1), 0, this.rows - 1);
|
|
160
|
+
return;
|
|
161
|
+
case 'C':
|
|
162
|
+
this.cursorCol = clamp(this.cursorCol + (params[0] || 1), 0, this.cols - 1);
|
|
163
|
+
return;
|
|
164
|
+
case 'D':
|
|
165
|
+
this.cursorCol = clamp(this.cursorCol - (params[0] || 1), 0, this.cols - 1);
|
|
166
|
+
return;
|
|
167
|
+
case 'E':
|
|
168
|
+
this.cursorRow = clamp(this.cursorRow + (params[0] || 1), 0, this.rows - 1);
|
|
169
|
+
this.cursorCol = 0;
|
|
170
|
+
return;
|
|
171
|
+
case 'F':
|
|
172
|
+
this.cursorRow = clamp(this.cursorRow - (params[0] || 1), 0, this.rows - 1);
|
|
173
|
+
this.cursorCol = 0;
|
|
174
|
+
return;
|
|
175
|
+
case 'G':
|
|
176
|
+
this.cursorCol = clamp((params[0] || 1) - 1, 0, this.cols - 1);
|
|
177
|
+
return;
|
|
178
|
+
case 'H':
|
|
179
|
+
case 'f': {
|
|
180
|
+
const row = (params[0] || 1) - 1;
|
|
181
|
+
const col = (params[1] || 1) - 1;
|
|
182
|
+
this.cursorRow = clamp(row, 0, this.rows - 1);
|
|
183
|
+
this.cursorCol = clamp(col, 0, this.cols - 1);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
case 'J': {
|
|
187
|
+
const mode = params[0] || 0;
|
|
188
|
+
if (mode === 2 || mode === 3) {
|
|
189
|
+
this.reset(this.rows, this.cols);
|
|
190
|
+
} else if (mode === 0) {
|
|
191
|
+
this.clearToEndOfScreen();
|
|
192
|
+
} else if (mode === 1) {
|
|
193
|
+
this.clearToStartOfScreen();
|
|
194
|
+
}
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
case 'K': {
|
|
198
|
+
const mode = params[0] || 0;
|
|
199
|
+
if (mode === 2) this.clearLine(this.cursorRow, 0, this.cols - 1);
|
|
200
|
+
else if (mode === 1) this.clearLine(this.cursorRow, 0, this.cursorCol);
|
|
201
|
+
else this.clearLine(this.cursorRow, this.cursorCol, this.cols - 1);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
case 'm':
|
|
205
|
+
return;
|
|
206
|
+
case 's':
|
|
207
|
+
this.savedRow = this.cursorRow;
|
|
208
|
+
this.savedCol = this.cursorCol;
|
|
209
|
+
return;
|
|
210
|
+
case 'u':
|
|
211
|
+
this.cursorRow = this.savedRow;
|
|
212
|
+
this.cursorCol = this.savedCol;
|
|
213
|
+
return;
|
|
214
|
+
case 'h':
|
|
215
|
+
case 'l':
|
|
216
|
+
if (privateMode && (normalized === '1049' || normalized === '47')) {
|
|
217
|
+
this.reset(this.rows, this.cols);
|
|
218
|
+
}
|
|
219
|
+
return;
|
|
220
|
+
default:
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private putChar(ch: string): void {
|
|
226
|
+
if (this.cursorRow < 0 || this.cursorRow >= this.rows) return;
|
|
227
|
+
if (this.cursorCol < 0) this.cursorCol = 0;
|
|
228
|
+
if (this.cursorCol >= this.cols) this.newLine();
|
|
229
|
+
this.lines[this.cursorRow][this.cursorCol] = ch;
|
|
230
|
+
this.cursorCol++;
|
|
231
|
+
if (this.cursorCol >= this.cols) this.newLine();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private newLine(): void {
|
|
235
|
+
this.cursorCol = 0;
|
|
236
|
+
if (this.cursorRow >= this.rows - 1) {
|
|
237
|
+
this.lines.shift();
|
|
238
|
+
this.lines.push(Array.from({ length: this.cols }, () => ' '));
|
|
239
|
+
} else {
|
|
240
|
+
this.cursorRow++;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private clearLine(row: number, start: number, end: number): void {
|
|
245
|
+
if (row < 0 || row >= this.rows) return;
|
|
246
|
+
for (let c = clamp(start, 0, this.cols - 1); c <= clamp(end, 0, this.cols - 1); c++) {
|
|
247
|
+
this.lines[row][c] = ' ';
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private clearToEndOfScreen(): void {
|
|
252
|
+
this.clearLine(this.cursorRow, this.cursorCol, this.cols - 1);
|
|
253
|
+
for (let r = this.cursorRow + 1; r < this.rows; r++) {
|
|
254
|
+
this.clearLine(r, 0, this.cols - 1);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private clearToStartOfScreen(): void {
|
|
259
|
+
for (let r = 0; r < this.cursorRow; r++) {
|
|
260
|
+
this.clearLine(r, 0, this.cols - 1);
|
|
261
|
+
}
|
|
262
|
+
this.clearLine(this.cursorRow, 0, this.cursorCol);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
private makeLines(rows: number, cols: number): string[][] {
|
|
266
|
+
return Array.from({ length: rows }, () => Array.from({ length: cols }, () => ' '));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -7,6 +7,10 @@ import type { CommandResult, CommandHelpers } from './handler.js';
|
|
|
7
7
|
import { readChatHistory } from '../config/chat-history.js';
|
|
8
8
|
import { LOG } from '../logging/logger.js';
|
|
9
9
|
|
|
10
|
+
function getTargetedCliAdapter(h: CommandHelpers, args: any, providerType?: string) {
|
|
11
|
+
return h.getCliAdapter(args?._targetInstance || h.currentIdeType || providerType);
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export async function handleChatHistory(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
11
15
|
const { agentType, offset, limit, instanceId } = args;
|
|
12
16
|
try {
|
|
@@ -20,13 +24,13 @@ export async function handleChatHistory(h: CommandHelpers, args: any): Promise<C
|
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export async function handleReadChat(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
23
|
-
const provider = h.getProvider();
|
|
27
|
+
const provider = h.getProvider(args?.agentType);
|
|
24
28
|
|
|
25
29
|
const _log = (msg: string) => LOG.debug('Command', `[read_chat] ${msg}`);
|
|
26
30
|
|
|
27
31
|
// CLI / ACP category: read from adapter
|
|
28
32
|
if (provider?.category === 'cli' || provider?.category === 'acp') {
|
|
29
|
-
const adapter = h
|
|
33
|
+
const adapter = getTargetedCliAdapter(h, args, provider.type);
|
|
30
34
|
if (adapter) {
|
|
31
35
|
_log(`${provider.category} adapter: ${(adapter as any).cliType}`);
|
|
32
36
|
const status = (adapter as any).getStatus?.();
|
|
@@ -140,7 +144,7 @@ export async function handleSendChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
140
144
|
const text = args?.text || args?.message;
|
|
141
145
|
if (!text) return { success: false, error: 'text required' };
|
|
142
146
|
const _log = (msg: string) => LOG.debug('Command', `[send_chat] ${msg}`);
|
|
143
|
-
const provider = h.getProvider();
|
|
147
|
+
const provider = h.getProvider(args?.agentType);
|
|
144
148
|
|
|
145
149
|
const _logSendSuccess = (method: string, targetAgent?: string) => {
|
|
146
150
|
h.historyWriter.appendNewMessages(
|
|
@@ -154,7 +158,7 @@ export async function handleSendChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
154
158
|
|
|
155
159
|
// CLI / ACP category: transmit via adapter
|
|
156
160
|
if (provider?.category === 'cli' || provider?.category === 'acp') {
|
|
157
|
-
const adapter = h
|
|
161
|
+
const adapter = getTargetedCliAdapter(h, args, provider.type);
|
|
158
162
|
if (adapter) {
|
|
159
163
|
_log(`${provider.category} adapter: ${(adapter as any).cliType}`);
|
|
160
164
|
try {
|
|
@@ -305,7 +309,7 @@ export async function handleSendChat(h: CommandHelpers, args: any): Promise<Comm
|
|
|
305
309
|
}
|
|
306
310
|
|
|
307
311
|
export async function handleListChats(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
308
|
-
const provider = h.getProvider();
|
|
312
|
+
const provider = h.getProvider(args?.agentType);
|
|
309
313
|
|
|
310
314
|
// Extension: via AgentStreamManager
|
|
311
315
|
if (provider?.category === 'extension' && h.agentStream && h.getCdp()) {
|
|
@@ -355,7 +359,17 @@ export async function handleListChats(h: CommandHelpers, args: any): Promise<Com
|
|
|
355
359
|
}
|
|
356
360
|
|
|
357
361
|
export async function handleNewChat(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
358
|
-
const provider = h.getProvider();
|
|
362
|
+
const provider = h.getProvider(args?.agentType);
|
|
363
|
+
|
|
364
|
+
if (provider?.category === 'cli') {
|
|
365
|
+
const adapter = getTargetedCliAdapter(h, args, provider.type);
|
|
366
|
+
if (!adapter) return { success: false, error: 'CLI adapter not running' };
|
|
367
|
+
if (typeof (adapter as any).clearHistory === 'function') {
|
|
368
|
+
(adapter as any).clearHistory();
|
|
369
|
+
return { success: true, cleared: true };
|
|
370
|
+
}
|
|
371
|
+
return { success: false, error: 'new_chat not supported by this CLI provider' };
|
|
372
|
+
}
|
|
359
373
|
|
|
360
374
|
if (provider?.category === 'extension' && h.agentStream && h.getCdp()) {
|
|
361
375
|
const ok = await h.agentStream.newAgentSession(h.getCdp()!, provider.type, h.currentIdeType);
|
|
@@ -386,7 +400,7 @@ export async function handleNewChat(h: CommandHelpers, args: any): Promise<Comma
|
|
|
386
400
|
}
|
|
387
401
|
|
|
388
402
|
export async function handleSwitchChat(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
389
|
-
const provider = h.getProvider();
|
|
403
|
+
const provider = h.getProvider(args?.agentType);
|
|
390
404
|
const ideType = h.currentIdeType;
|
|
391
405
|
const sessionId = args?.sessionId || args?.id || args?.chatId;
|
|
392
406
|
if (!sessionId) return { success: false, error: 'sessionId required' };
|
|
@@ -473,12 +487,12 @@ export async function handleSwitchChat(h: CommandHelpers, args: any): Promise<Co
|
|
|
473
487
|
}
|
|
474
488
|
|
|
475
489
|
export async function handleSetMode(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
476
|
-
const provider = h.getProvider();
|
|
490
|
+
const provider = h.getProvider(args?.agentType);
|
|
477
491
|
const mode = args?.mode || 'agent';
|
|
478
492
|
|
|
479
493
|
// ACP provider
|
|
480
494
|
if (provider?.category === 'acp') {
|
|
481
|
-
const adapter = h
|
|
495
|
+
const adapter = getTargetedCliAdapter(h, args, provider.type);
|
|
482
496
|
if (adapter) {
|
|
483
497
|
const acpInstance = (adapter as any)._acpInstance;
|
|
484
498
|
if (acpInstance && typeof acpInstance.onEvent === 'function') {
|
|
@@ -526,14 +540,14 @@ export async function handleSetMode(h: CommandHelpers, args: any): Promise<Comma
|
|
|
526
540
|
}
|
|
527
541
|
|
|
528
542
|
export async function handleChangeModel(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
529
|
-
const provider = h.getProvider();
|
|
543
|
+
const provider = h.getProvider(args?.agentType);
|
|
530
544
|
const model = args?.model;
|
|
531
545
|
|
|
532
546
|
LOG.info('Command', `[change_model] model=${model} provider=${provider?.type} category=${provider?.category} ideType=${h.currentIdeType} providerType=${h.currentProviderType}`);
|
|
533
547
|
|
|
534
548
|
// ACP provider
|
|
535
549
|
if (provider?.category === 'acp') {
|
|
536
|
-
const adapter = h
|
|
550
|
+
const adapter = getTargetedCliAdapter(h, args, provider.type);
|
|
537
551
|
LOG.info('Command', `[change_model] ACP adapter found: ${!!adapter}, type=${(adapter as any)?.cliType}, hasAcpInstance=${!!(adapter as any)?._acpInstance}`);
|
|
538
552
|
if (adapter) {
|
|
539
553
|
const acpInstance = (adapter as any)._acpInstance;
|
|
@@ -587,11 +601,11 @@ export async function handleSetThoughtLevel(h: CommandHelpers, args: any): Promi
|
|
|
587
601
|
const value = args?.value;
|
|
588
602
|
if (!configId || !value) return { success: false, error: 'configId and value required' };
|
|
589
603
|
|
|
590
|
-
const provider = h.getProvider();
|
|
604
|
+
const provider = h.getProvider(args?.agentType);
|
|
591
605
|
if (!provider || provider.category !== 'acp') {
|
|
592
606
|
return { success: false, error: 'set_thought_level only for ACP providers' };
|
|
593
607
|
}
|
|
594
|
-
const adapter = h
|
|
608
|
+
const adapter = getTargetedCliAdapter(h, args, provider.type);
|
|
595
609
|
const acpInstance = adapter?._acpInstance;
|
|
596
610
|
if (!acpInstance) return { success: false, error: 'ACP instance not found' };
|
|
597
611
|
|
|
@@ -605,7 +619,7 @@ export async function handleSetThoughtLevel(h: CommandHelpers, args: any): Promi
|
|
|
605
619
|
}
|
|
606
620
|
|
|
607
621
|
export async function handleResolveAction(h: CommandHelpers, args: any): Promise<CommandResult> {
|
|
608
|
-
const provider = h.getProvider();
|
|
622
|
+
const provider = h.getProvider(args?.agentType);
|
|
609
623
|
const action = args?.action || 'approve';
|
|
610
624
|
const button = args?.button || args?.buttonText
|
|
611
625
|
|| (action === 'approve' ? 'Accept' : action === 'reject' ? 'Reject' : 'Accept');
|
|
@@ -614,8 +628,20 @@ export async function handleResolveAction(h: CommandHelpers, args: any): Promise
|
|
|
614
628
|
|
|
615
629
|
// 0. CLI / ACP category: navigate approval dialog via PTY arrow keys + Enter
|
|
616
630
|
if (provider?.category === 'cli') {
|
|
617
|
-
const adapter = h
|
|
631
|
+
const adapter = getTargetedCliAdapter(h, args, provider.type);
|
|
618
632
|
if (!adapter) return { success: false, error: 'CLI adapter not running' };
|
|
633
|
+
|
|
634
|
+
// Handle data-driven resolve actions (like from the dashboard 'Fix' button)
|
|
635
|
+
if (args?.data && typeof (adapter as any).resolveAction === 'function') {
|
|
636
|
+
try {
|
|
637
|
+
await (adapter as any).resolveAction(args.data);
|
|
638
|
+
LOG.info('Command', `[resolveAction] CLI PTY → resolveAction triggered with data payload`);
|
|
639
|
+
return { success: true, method: 'cli-resolve-action' };
|
|
640
|
+
} catch (e: any) {
|
|
641
|
+
return { success: false, error: `CLI resolveAction failed: ${e.message}` };
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
619
645
|
const status = (adapter as any).getStatus?.();
|
|
620
646
|
if (status?.status !== 'waiting_approval') {
|
|
621
647
|
return { success: false, error: 'Not in approval state' };
|
|
@@ -83,7 +83,8 @@ export class DaemonCliManager {
|
|
|
83
83
|
const provider = this.providerLoader.getMeta(normalizedType);
|
|
84
84
|
if (provider && provider.category === 'cli' && provider.patterns && provider.spawn) {
|
|
85
85
|
console.log(chalk.cyan(` 📦 Using provider: ${provider.name} (${provider.type})`));
|
|
86
|
-
|
|
86
|
+
const resolvedProvider = this.providerLoader.resolve(normalizedType) || provider;
|
|
87
|
+
return new ProviderCliAdapter(resolvedProvider as any, workingDir, cliArgs);
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
throw new Error(`No CLI provider found for '${cliType}'. Create a provider.js in providers/cli/${cliType}/`);
|
|
@@ -182,7 +183,8 @@ export class DaemonCliManager {
|
|
|
182
183
|
// If InstanceManager exists, manage as CliProviderInstance unified
|
|
183
184
|
const instanceManager = this.deps.getInstanceManager();
|
|
184
185
|
if (provider && instanceManager) {
|
|
185
|
-
const
|
|
186
|
+
const resolvedProvider = this.providerLoader.resolve(cliType, { version: cliInfo.version }) || provider;
|
|
187
|
+
const cliInstance = new CliProviderInstance(resolvedProvider, resolvedDir, cliArgs, key);
|
|
186
188
|
try {
|
|
187
189
|
await instanceManager.addInstance(key, cliInstance, {
|
|
188
190
|
serverConn: this.deps.getServerConn(),
|