@adhdev/daemon-core 0.7.42 → 0.7.43
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/cli-adapters/provider-cli-adapter.d.ts +2 -4
- package/dist/cli-adapters/pty-transport.d.ts +1 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +4 -0
- package/dist/cli-adapters/terminal-backends/types.d.ts +4 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +4 -0
- package/dist/cli-adapters/terminal-screen.d.ts +4 -0
- package/dist/config/chat-history.d.ts +0 -3
- package/dist/index.js +72 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -116
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider-instance.d.ts +0 -1
- package/dist/status/normalize.js +0 -7
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +0 -7
- package/dist/status/normalize.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/dist/index.js +2 -2
- package/node_modules/@adhdev/session-host-core/dist/index.js.map +1 -1
- package/node_modules/@adhdev/session-host-core/dist/index.mjs +2 -2
- package/node_modules/@adhdev/session-host-core/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +79 -70
- package/src/cli-adapters/pty-transport.ts +2 -0
- package/src/cli-adapters/session-host-transport.ts +1 -0
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +5 -0
- package/src/cli-adapters/terminal-backends/types.ts +1 -0
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +10 -0
- package/src/cli-adapters/terminal-screen.ts +4 -0
- package/src/config/chat-history.ts +3 -55
- package/src/providers/cli-provider-instance.ts +1 -11
- package/src/providers/provider-instance.d.ts +0 -1
- package/src/providers/provider-instance.ts +0 -1
- package/src/status/normalize.ts +0 -4
package/dist/index.mjs
CHANGED
|
@@ -515,6 +515,9 @@ var init_ghostty_vt_backend = __esm({
|
|
|
515
515
|
getText() {
|
|
516
516
|
return this.terminal.formatPlainText({ trim: true }) || "";
|
|
517
517
|
}
|
|
518
|
+
getCursorPosition() {
|
|
519
|
+
return this.terminal.getCursorPosition();
|
|
520
|
+
}
|
|
518
521
|
dispose() {
|
|
519
522
|
this.terminal.dispose();
|
|
520
523
|
}
|
|
@@ -572,6 +575,13 @@ var init_xterm_backend = __esm({
|
|
|
572
575
|
while (last > first && !lines[last - 1]?.trim()) last--;
|
|
573
576
|
return lines.slice(first, last).join("\n");
|
|
574
577
|
}
|
|
578
|
+
getCursorPosition() {
|
|
579
|
+
const buffer = this.terminal.buffer.active;
|
|
580
|
+
return {
|
|
581
|
+
col: Math.max(0, buffer.cursorX || 0),
|
|
582
|
+
row: Math.max(0, buffer.cursorY || 0)
|
|
583
|
+
};
|
|
584
|
+
}
|
|
575
585
|
dispose() {
|
|
576
586
|
this.terminal.dispose();
|
|
577
587
|
}
|
|
@@ -658,6 +668,9 @@ var init_terminal_screen = __esm({
|
|
|
658
668
|
getText() {
|
|
659
669
|
return this.terminal.getText();
|
|
660
670
|
}
|
|
671
|
+
getCursorPosition() {
|
|
672
|
+
return this.terminal.getCursorPosition();
|
|
673
|
+
}
|
|
661
674
|
dispose() {
|
|
662
675
|
this.terminal.dispose();
|
|
663
676
|
}
|
|
@@ -688,6 +701,7 @@ var init_pty_transport = __esm({
|
|
|
688
701
|
this.handle = handle;
|
|
689
702
|
}
|
|
690
703
|
ready = Promise.resolve();
|
|
704
|
+
terminalQueriesHandled = false;
|
|
691
705
|
get pid() {
|
|
692
706
|
return this.handle.pid;
|
|
693
707
|
}
|
|
@@ -744,6 +758,32 @@ function stripTerminalNoise(str) {
|
|
|
744
758
|
function sanitizeTerminalText(str) {
|
|
745
759
|
return stripTerminalNoise(stripAnsi(str));
|
|
746
760
|
}
|
|
761
|
+
function buildCliSpawnEnv(baseEnv, overrides) {
|
|
762
|
+
const env = {};
|
|
763
|
+
const source = { ...baseEnv, ...overrides || {} };
|
|
764
|
+
for (const [key, value] of Object.entries(source)) {
|
|
765
|
+
if (typeof value !== "string") continue;
|
|
766
|
+
env[key] = value;
|
|
767
|
+
}
|
|
768
|
+
for (const key of Object.keys(env)) {
|
|
769
|
+
if (key === "INIT_CWD" || key === "NO_COLOR" || key === "FORCE_COLOR" || key === "npm_command" || key === "npm_execpath" || key === "npm_node_execpath" || key.startsWith("npm_") || key.startsWith("npm_config_") || key.startsWith("npm_package_") || key.startsWith("npm_lifecycle_") || key.startsWith("PNPM_") || key.startsWith("YARN_") || key.startsWith("BUN_")) {
|
|
770
|
+
delete env[key];
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
return env;
|
|
774
|
+
}
|
|
775
|
+
function computeTerminalQueryTail(buffer) {
|
|
776
|
+
const prefixes = ["\x1B[6n", "\x1B[?6n"];
|
|
777
|
+
const maxLength = prefixes.reduce((n, value) => Math.max(n, value.length), 0) - 1;
|
|
778
|
+
const start = Math.max(0, buffer.length - maxLength);
|
|
779
|
+
for (let i = start; i < buffer.length; i++) {
|
|
780
|
+
const suffix = buffer.slice(i);
|
|
781
|
+
if (prefixes.some((pattern) => suffix.length < pattern.length && pattern.startsWith(suffix))) {
|
|
782
|
+
return suffix;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return "";
|
|
786
|
+
}
|
|
747
787
|
function findBinary(name) {
|
|
748
788
|
const isWin = os12.platform() === "win32";
|
|
749
789
|
try {
|
|
@@ -830,36 +870,6 @@ function promptLikelyVisible(screenText, promptSnippet) {
|
|
|
830
870
|
).length;
|
|
831
871
|
return matched >= required;
|
|
832
872
|
}
|
|
833
|
-
function splitHistoryLines(text) {
|
|
834
|
-
return String(text || "").split("\n").map((line) => line.replace(/\s+$/, ""));
|
|
835
|
-
}
|
|
836
|
-
function normalizeHistoryLine(line) {
|
|
837
|
-
return String(line || "").replace(/\s+/g, " ").trim();
|
|
838
|
-
}
|
|
839
|
-
function mergeTerminalHistory(existing, snapshot) {
|
|
840
|
-
const next = String(snapshot || "").trim();
|
|
841
|
-
if (!next) return existing;
|
|
842
|
-
const prev = String(existing || "").trim();
|
|
843
|
-
if (!prev) return next;
|
|
844
|
-
if (prev === next || prev.endsWith(next)) return prev;
|
|
845
|
-
const prevLines = splitHistoryLines(prev);
|
|
846
|
-
const nextLines = splitHistoryLines(next);
|
|
847
|
-
const prevNorm = prevLines.map(normalizeHistoryLine);
|
|
848
|
-
const nextNorm = nextLines.map(normalizeHistoryLine);
|
|
849
|
-
const maxOverlap = Math.min(prevLines.length, nextLines.length);
|
|
850
|
-
for (let overlap = maxOverlap; overlap >= 1; overlap -= 1) {
|
|
851
|
-
const prevTail = prevNorm.slice(prevNorm.length - overlap);
|
|
852
|
-
const nextHead = nextNorm.slice(0, overlap);
|
|
853
|
-
if (prevTail.every((line, index) => line === nextHead[index])) {
|
|
854
|
-
return [...prevLines, ...nextLines.slice(overlap)].join("\n").trim();
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
const compactPrev = prevNorm.join("\n");
|
|
858
|
-
const compactNext = nextNorm.join("\n");
|
|
859
|
-
if (compactPrev.includes(compactNext)) return prev;
|
|
860
|
-
return `${prev}
|
|
861
|
-
${next}`.trim();
|
|
862
|
-
}
|
|
863
873
|
function parsePatternEntry(x) {
|
|
864
874
|
if (x instanceof RegExp) return x;
|
|
865
875
|
if (x && typeof x === "object" && typeof x.source === "string") {
|
|
@@ -971,6 +981,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
971
981
|
pendingOutputParseTimer = null;
|
|
972
982
|
ptyOutputBuffer = "";
|
|
973
983
|
ptyOutputFlushTimer = null;
|
|
984
|
+
pendingTerminalQueryTail = "";
|
|
974
985
|
// Server log forwarding
|
|
975
986
|
serverConn = null;
|
|
976
987
|
logBuffer = [];
|
|
@@ -1002,9 +1013,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
1002
1013
|
/** Full accumulated raw PTY output (with ANSI) */
|
|
1003
1014
|
accumulatedRawBuffer = "";
|
|
1004
1015
|
/** Current visible terminal screen snapshot */
|
|
1005
|
-
terminalScreen = new TerminalScreen(
|
|
1006
|
-
/** Rolling append-only terminal transcript built from screen snapshots */
|
|
1007
|
-
terminalHistory = "";
|
|
1016
|
+
terminalScreen = new TerminalScreen(30, 100);
|
|
1008
1017
|
/** Max accumulated buffer size (last 50KB) */
|
|
1009
1018
|
static MAX_ACCUMULATED_BUFFER = 5e4;
|
|
1010
1019
|
currentTurnScope = null;
|
|
@@ -1026,15 +1035,13 @@ var init_provider_cli_adapter = __esm({
|
|
|
1026
1035
|
return text.slice(start);
|
|
1027
1036
|
}
|
|
1028
1037
|
buildParseInput(baseMessages, partialResponse, scope) {
|
|
1029
|
-
const buffer = scope ? this.sliceFromOffset(this.
|
|
1038
|
+
const buffer = scope ? this.sliceFromOffset(this.accumulatedBuffer, scope.bufferStart) || this.accumulatedBuffer : this.accumulatedBuffer;
|
|
1030
1039
|
const rawBuffer = scope ? this.sliceFromOffset(this.accumulatedRawBuffer, scope.rawBufferStart) || this.accumulatedRawBuffer : this.accumulatedRawBuffer;
|
|
1031
|
-
const terminalHistory = scope ? this.sliceFromOffset(this.terminalHistory, scope.terminalHistoryStart) || this.terminalHistory : this.terminalHistory;
|
|
1032
1040
|
return {
|
|
1033
1041
|
buffer,
|
|
1034
1042
|
rawBuffer,
|
|
1035
1043
|
recentBuffer: buffer.slice(-1e3) || this.recentOutputBuffer,
|
|
1036
1044
|
screenText: this.terminalScreen.getText(),
|
|
1037
|
-
terminalHistory,
|
|
1038
1045
|
messages: [...baseMessages],
|
|
1039
1046
|
partialResponse
|
|
1040
1047
|
};
|
|
@@ -1112,13 +1119,10 @@ var init_provider_cli_adapter = __esm({
|
|
|
1112
1119
|
shellArgs = allArgs;
|
|
1113
1120
|
}
|
|
1114
1121
|
const ptyOpts = {
|
|
1115
|
-
cols:
|
|
1116
|
-
rows:
|
|
1122
|
+
cols: 100,
|
|
1123
|
+
rows: 30,
|
|
1117
1124
|
cwd: this.workingDir,
|
|
1118
|
-
env:
|
|
1119
|
-
...process.env,
|
|
1120
|
-
...spawnConfig.env
|
|
1121
|
-
}
|
|
1125
|
+
env: buildCliSpawnEnv(process.env, spawnConfig.env)
|
|
1122
1126
|
};
|
|
1123
1127
|
try {
|
|
1124
1128
|
this.ptyProcess = this.transportFactory.spawn(shellCmd, shellArgs, ptyOpts);
|
|
@@ -1136,8 +1140,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
1136
1140
|
}
|
|
1137
1141
|
this.ptyProcess.onData((data) => {
|
|
1138
1142
|
if (Date.now() < this.resizeSuppressUntil) return;
|
|
1139
|
-
if (
|
|
1140
|
-
this.
|
|
1143
|
+
if (!this.ptyProcess?.terminalQueriesHandled) {
|
|
1144
|
+
this.respondToTerminalQueries(data);
|
|
1141
1145
|
}
|
|
1142
1146
|
this.pendingOutputParseBuffer += data;
|
|
1143
1147
|
if (!this.pendingOutputParseTimer) {
|
|
@@ -1172,8 +1176,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
1172
1176
|
this.spawnAt = Date.now();
|
|
1173
1177
|
this.startupParseGate = true;
|
|
1174
1178
|
this.startupBuffer = "";
|
|
1175
|
-
this.terminalScreen.reset(
|
|
1176
|
-
this.
|
|
1179
|
+
this.terminalScreen.reset(30, 100);
|
|
1180
|
+
this.pendingTerminalQueryTail = "";
|
|
1177
1181
|
this.currentTurnScope = null;
|
|
1178
1182
|
this.ready = false;
|
|
1179
1183
|
await this.ptyProcess.ready;
|
|
@@ -1183,7 +1187,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
1183
1187
|
// ─── Output Handling ────────────────────────────
|
|
1184
1188
|
handleOutput(rawData) {
|
|
1185
1189
|
this.terminalScreen.write(rawData);
|
|
1186
|
-
this.terminalHistory = mergeTerminalHistory(this.terminalHistory, this.terminalScreen.getText());
|
|
1187
1190
|
const cleanData = sanitizeTerminalText(rawData);
|
|
1188
1191
|
if (this.isWaitingForResponse && cleanData) {
|
|
1189
1192
|
this.responseBuffer = (this.responseBuffer + cleanData).slice(-8e3);
|
|
@@ -1459,8 +1462,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
1459
1462
|
status: this.currentStatus,
|
|
1460
1463
|
messages: [...this.committedMessages],
|
|
1461
1464
|
workingDir: this.workingDir,
|
|
1462
|
-
activeModal: this.activeModal
|
|
1463
|
-
terminalHistory: this.terminalHistory
|
|
1465
|
+
activeModal: this.activeModal
|
|
1464
1466
|
};
|
|
1465
1467
|
}
|
|
1466
1468
|
/**
|
|
@@ -1478,7 +1480,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
1478
1480
|
id: parsed.id || "cli_session",
|
|
1479
1481
|
status: parsed.status || this.currentStatus,
|
|
1480
1482
|
title: parsed.title || this.cliName,
|
|
1481
|
-
terminalHistory: this.terminalHistory,
|
|
1482
1483
|
messages: parsed.messages,
|
|
1483
1484
|
activeModal: parsed.activeModal ?? this.activeModal
|
|
1484
1485
|
};
|
|
@@ -1488,7 +1489,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
1488
1489
|
id: "cli_session",
|
|
1489
1490
|
status: this.currentStatus,
|
|
1490
1491
|
title: this.cliName,
|
|
1491
|
-
terminalHistory: this.terminalHistory,
|
|
1492
1492
|
messages: messages.slice(-50).map((message, index) => ({
|
|
1493
1493
|
id: `msg_${index}`,
|
|
1494
1494
|
role: message.role,
|
|
@@ -1556,10 +1556,9 @@ ${data.message || ""}`.trim();
|
|
|
1556
1556
|
prompt: text,
|
|
1557
1557
|
startedAt: Date.now(),
|
|
1558
1558
|
bufferStart: this.accumulatedBuffer.length,
|
|
1559
|
-
rawBufferStart: this.accumulatedRawBuffer.length
|
|
1560
|
-
terminalHistoryStart: this.terminalHistory.length
|
|
1559
|
+
rawBufferStart: this.accumulatedRawBuffer.length
|
|
1561
1560
|
};
|
|
1562
|
-
LOG.info("CLI", `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart}
|
|
1561
|
+
LOG.info("CLI", `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart} prompt=${JSON.stringify(text).slice(0, 120)}`);
|
|
1563
1562
|
this.submitRetryUsed = false;
|
|
1564
1563
|
this.submitRetryPromptSnippet = extractPromptRetrySnippet(text);
|
|
1565
1564
|
const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet);
|
|
@@ -1744,6 +1743,7 @@ ${data.message || ""}`.trim();
|
|
|
1744
1743
|
this.pendingOutputParseTimer = null;
|
|
1745
1744
|
}
|
|
1746
1745
|
this.pendingOutputParseBuffer = "";
|
|
1746
|
+
this.pendingTerminalQueryTail = "";
|
|
1747
1747
|
if (this.ptyOutputFlushTimer) {
|
|
1748
1748
|
clearTimeout(this.ptyOutputFlushTimer);
|
|
1749
1749
|
this.ptyOutputFlushTimer = null;
|
|
@@ -1783,6 +1783,7 @@ ${data.message || ""}`.trim();
|
|
|
1783
1783
|
this.pendingOutputParseTimer = null;
|
|
1784
1784
|
}
|
|
1785
1785
|
this.pendingOutputParseBuffer = "";
|
|
1786
|
+
this.pendingTerminalQueryTail = "";
|
|
1786
1787
|
if (this.ptyOutputFlushTimer) {
|
|
1787
1788
|
clearTimeout(this.ptyOutputFlushTimer);
|
|
1788
1789
|
this.ptyOutputFlushTimer = null;
|
|
@@ -1809,7 +1810,6 @@ ${data.message || ""}`.trim();
|
|
|
1809
1810
|
this.syncMessageViews();
|
|
1810
1811
|
this.accumulatedBuffer = "";
|
|
1811
1812
|
this.accumulatedRawBuffer = "";
|
|
1812
|
-
this.terminalHistory = "";
|
|
1813
1813
|
this.currentTurnScope = null;
|
|
1814
1814
|
this.submitRetryUsed = false;
|
|
1815
1815
|
this.submitRetryPromptSnippet = "";
|
|
@@ -1818,6 +1818,7 @@ ${data.message || ""}`.trim();
|
|
|
1818
1818
|
this.pendingOutputParseTimer = null;
|
|
1819
1819
|
}
|
|
1820
1820
|
this.pendingOutputParseBuffer = "";
|
|
1821
|
+
this.pendingTerminalQueryTail = "";
|
|
1821
1822
|
if (this.ptyOutputFlushTimer) {
|
|
1822
1823
|
clearTimeout(this.ptyOutputFlushTimer);
|
|
1823
1824
|
this.ptyOutputFlushTimer = null;
|
|
@@ -1879,7 +1880,6 @@ ${data.message || ""}`.trim();
|
|
|
1879
1880
|
structuredMessages: this.structuredMessages.slice(-20),
|
|
1880
1881
|
messageCount: this.committedMessages.length,
|
|
1881
1882
|
screenText: sanitizeTerminalText(this.terminalScreen.getText()).slice(-4e3),
|
|
1882
|
-
terminalHistory: this.terminalHistory.slice(-8e3),
|
|
1883
1883
|
currentTurnScope: this.currentTurnScope,
|
|
1884
1884
|
startupBuffer: this.startupBuffer.slice(-4e3),
|
|
1885
1885
|
recentOutputBuffer: this.recentOutputBuffer.slice(-500),
|
|
@@ -1907,6 +1907,20 @@ ${data.message || ""}`.trim();
|
|
|
1907
1907
|
ptyAlive: !!this.ptyProcess
|
|
1908
1908
|
};
|
|
1909
1909
|
}
|
|
1910
|
+
respondToTerminalQueries(data) {
|
|
1911
|
+
if (!this.ptyProcess || !data) return;
|
|
1912
|
+
const combined = this.pendingTerminalQueryTail + data;
|
|
1913
|
+
const regex = /\x1b\[(\?)?6n/g;
|
|
1914
|
+
let match;
|
|
1915
|
+
while ((match = regex.exec(combined)) !== null) {
|
|
1916
|
+
const cursor = this.terminalScreen.getCursorPosition();
|
|
1917
|
+
const row = Math.max(1, (cursor.row | 0) + 1);
|
|
1918
|
+
const col = Math.max(1, (cursor.col | 0) + 1);
|
|
1919
|
+
const response = match[1] ? `\x1B[?${row};${col}R` : `\x1B[${row};${col}R`;
|
|
1920
|
+
this.ptyProcess.write(response);
|
|
1921
|
+
}
|
|
1922
|
+
this.pendingTerminalQueryTail = computeTerminalQueryTail(combined);
|
|
1923
|
+
}
|
|
1910
1924
|
};
|
|
1911
1925
|
}
|
|
1912
1926
|
});
|
|
@@ -3927,8 +3941,6 @@ var ChatHistoryWriter = class {
|
|
|
3927
3941
|
lastSeenCounts = /* @__PURE__ */ new Map();
|
|
3928
3942
|
/** Last seen message hash per agent (deduplication) */
|
|
3929
3943
|
lastSeenHashes = /* @__PURE__ */ new Map();
|
|
3930
|
-
/** Last seen append-only terminal transcript per agent */
|
|
3931
|
-
lastSeenTerminal = /* @__PURE__ */ new Map();
|
|
3932
3944
|
rotated = false;
|
|
3933
3945
|
/**
|
|
3934
3946
|
* Append new messages to history
|
|
@@ -3986,51 +3998,10 @@ var ChatHistoryWriter = class {
|
|
|
3986
3998
|
} catch {
|
|
3987
3999
|
}
|
|
3988
4000
|
}
|
|
3989
|
-
appendTerminalHistory(agentType, terminalHistory, sessionTitle, instanceId) {
|
|
3990
|
-
const next = String(terminalHistory || "");
|
|
3991
|
-
if (!next.trim()) return;
|
|
3992
|
-
try {
|
|
3993
|
-
const dedupKey = instanceId ? `${agentType}:${instanceId}:terminal` : `${agentType}:terminal`;
|
|
3994
|
-
const prev = this.lastSeenTerminal.get(dedupKey) || "";
|
|
3995
|
-
if (prev === next) return;
|
|
3996
|
-
let delta = "";
|
|
3997
|
-
if (!prev) {
|
|
3998
|
-
delta = next;
|
|
3999
|
-
} else if (next.startsWith(prev)) {
|
|
4000
|
-
delta = next.slice(prev.length);
|
|
4001
|
-
} else if (prev.includes(next)) {
|
|
4002
|
-
this.lastSeenTerminal.set(dedupKey, next);
|
|
4003
|
-
return;
|
|
4004
|
-
} else {
|
|
4005
|
-
delta = `
|
|
4006
|
-
|
|
4007
|
-
[terminal snapshot reset ${(/* @__PURE__ */ new Date()).toISOString()} | ${sessionTitle || agentType}]
|
|
4008
|
-
${next}`;
|
|
4009
|
-
}
|
|
4010
|
-
if (!delta) {
|
|
4011
|
-
this.lastSeenTerminal.set(dedupKey, next);
|
|
4012
|
-
return;
|
|
4013
|
-
}
|
|
4014
|
-
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
4015
|
-
fs3.mkdirSync(dir, { recursive: true });
|
|
4016
|
-
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
4017
|
-
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
4018
|
-
const filePath = path4.join(dir, `${filePrefix}${date}.terminal.log`);
|
|
4019
|
-
fs3.appendFileSync(filePath, delta, "utf-8");
|
|
4020
|
-
this.lastSeenTerminal.set(dedupKey, next);
|
|
4021
|
-
if (!this.rotated) {
|
|
4022
|
-
this.rotated = true;
|
|
4023
|
-
this.rotateOldFiles().catch(() => {
|
|
4024
|
-
});
|
|
4025
|
-
}
|
|
4026
|
-
} catch {
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
4001
|
/** Called when agent session is explicitly changed */
|
|
4030
4002
|
onSessionChange(agentType) {
|
|
4031
4003
|
this.lastSeenHashes.delete(agentType);
|
|
4032
4004
|
this.lastSeenCounts.delete(agentType);
|
|
4033
|
-
this.lastSeenTerminal.delete(`${agentType}:terminal`);
|
|
4034
4005
|
}
|
|
4035
4006
|
/** Delete history files older than 30 days */
|
|
4036
4007
|
async rotateOldFiles() {
|
|
@@ -4883,7 +4854,6 @@ var STATUS_ACTIVE_CHAT_MESSAGE_LIMIT = 60;
|
|
|
4883
4854
|
var STATUS_ACTIVE_CHAT_TOTAL_BYTES_LIMIT = 96 * 1024;
|
|
4884
4855
|
var STATUS_ACTIVE_CHAT_STRING_LIMIT = 4 * 1024;
|
|
4885
4856
|
var STATUS_ACTIVE_CHAT_FALLBACK_STRING_LIMIT = 1024;
|
|
4886
|
-
var STATUS_TERMINAL_HISTORY_LIMIT = 8 * 1024;
|
|
4887
4857
|
var STATUS_INPUT_CONTENT_LIMIT = 2 * 1024;
|
|
4888
4858
|
var STATUS_MODAL_MESSAGE_LIMIT = 2 * 1024;
|
|
4889
4859
|
var STATUS_MODAL_BUTTON_LIMIT = 120;
|
|
@@ -4892,11 +4862,6 @@ function truncateString(value, maxChars) {
|
|
|
4892
4862
|
if (maxChars <= 12) return value.slice(0, Math.max(0, maxChars));
|
|
4893
4863
|
return `${value.slice(0, maxChars - 12)}...[truncated]`;
|
|
4894
4864
|
}
|
|
4895
|
-
function truncateStringTail(value, maxChars) {
|
|
4896
|
-
if (value.length <= maxChars) return value;
|
|
4897
|
-
if (maxChars <= 12) return value.slice(value.length - Math.max(0, maxChars));
|
|
4898
|
-
return `...[truncated]${value.slice(value.length - (maxChars - 12))}`;
|
|
4899
|
-
}
|
|
4900
4865
|
function trimStructuredStrings(value, maxChars) {
|
|
4901
4866
|
if (typeof value === "string") return truncateString(value, maxChars);
|
|
4902
4867
|
if (Array.isArray(value)) return value.map((item) => trimStructuredStrings(item, maxChars));
|
|
@@ -4970,7 +4935,6 @@ function normalizeActiveChatData(activeChat) {
|
|
|
4970
4935
|
(button) => truncateString(String(button || ""), STATUS_MODAL_BUTTON_LIMIT)
|
|
4971
4936
|
)
|
|
4972
4937
|
} : activeChat.activeModal,
|
|
4973
|
-
terminalHistory: activeChat.terminalHistory ? truncateStringTail(activeChat.terminalHistory, STATUS_TERMINAL_HISTORY_LIMIT) : activeChat.terminalHistory,
|
|
4974
4938
|
inputContent: activeChat.inputContent ? truncateString(activeChat.inputContent, STATUS_INPUT_CONTENT_LIMIT) : activeChat.inputContent
|
|
4975
4939
|
};
|
|
4976
4940
|
}
|
|
@@ -9284,7 +9248,7 @@ var CliProviderInstance = class {
|
|
|
9284
9248
|
this.cliArgs = cliArgs;
|
|
9285
9249
|
this.type = provider.type;
|
|
9286
9250
|
this.instanceId = instanceId || crypto3.randomUUID();
|
|
9287
|
-
this.presentationMode = "
|
|
9251
|
+
this.presentationMode = "chat";
|
|
9288
9252
|
this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, transportFactory);
|
|
9289
9253
|
this.monitor = new StatusMonitor();
|
|
9290
9254
|
this.historyWriter = new ChatHistoryWriter();
|
|
@@ -9331,14 +9295,6 @@ var CliProviderInstance = class {
|
|
|
9331
9295
|
const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
|
|
9332
9296
|
const runtime = this.adapter.getRuntimeMetadata();
|
|
9333
9297
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
9334
|
-
if (adapterStatus.terminalHistory?.trim()) {
|
|
9335
|
-
this.historyWriter.appendTerminalHistory(
|
|
9336
|
-
this.type,
|
|
9337
|
-
adapterStatus.terminalHistory,
|
|
9338
|
-
`${this.provider.name} \xB7 ${dirName}`,
|
|
9339
|
-
this.instanceId
|
|
9340
|
-
);
|
|
9341
|
-
}
|
|
9342
9298
|
return {
|
|
9343
9299
|
type: this.type,
|
|
9344
9300
|
name: this.provider.name,
|
|
@@ -9351,7 +9307,6 @@ var CliProviderInstance = class {
|
|
|
9351
9307
|
status: parsedStatus?.status || adapterStatus.status,
|
|
9352
9308
|
messages: Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [],
|
|
9353
9309
|
activeModal: parsedStatus?.activeModal ?? adapterStatus.activeModal,
|
|
9354
|
-
terminalHistory: adapterStatus.terminalHistory,
|
|
9355
9310
|
inputContent: ""
|
|
9356
9311
|
},
|
|
9357
9312
|
workspace: this.workingDir,
|
|
@@ -15942,6 +15897,7 @@ var SessionHostRuntimeTransport = class {
|
|
|
15942
15897
|
this.ready = this.boot();
|
|
15943
15898
|
}
|
|
15944
15899
|
ready;
|
|
15900
|
+
terminalQueriesHandled = true;
|
|
15945
15901
|
client;
|
|
15946
15902
|
dataCallbacks = /* @__PURE__ */ new Set();
|
|
15947
15903
|
exitCallbacks = /* @__PURE__ */ new Set();
|