@adhdev/daemon-standalone 0.9.82-rc.317 → 0.9.82-rc.318
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.js +542 -513
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30075,10 +30075,10 @@ var require_dist3 = __commonJS({
|
|
|
30075
30075
|
}
|
|
30076
30076
|
function getDaemonBuildInfo() {
|
|
30077
30077
|
if (cached2) return cached2;
|
|
30078
|
-
const commit = readInjected(true ? "
|
|
30079
|
-
const commitShort = readInjected(true ? "
|
|
30080
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30081
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30078
|
+
const commit = readInjected(true ? "506ca246e28984a3b699b04c4601117f62ba2d81" : void 0) ?? "unknown";
|
|
30079
|
+
const commitShort = readInjected(true ? "506ca246" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30080
|
+
const version2 = readInjected(true ? "0.9.82-rc.318" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30081
|
+
const builtAt = readInjected(true ? "2026-06-18T12:46:41.804Z" : void 0);
|
|
30082
30082
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30083
30083
|
return cached2;
|
|
30084
30084
|
}
|
|
@@ -37685,6 +37685,404 @@ Next step: ${nextStep}`;
|
|
|
37685
37685
|
init_dist();
|
|
37686
37686
|
}
|
|
37687
37687
|
});
|
|
37688
|
+
var import_session_host_core22;
|
|
37689
|
+
var init_spawn_env = __esm2({
|
|
37690
|
+
"src/cli-adapters/spawn-env.ts"() {
|
|
37691
|
+
"use strict";
|
|
37692
|
+
import_session_host_core22 = require_dist();
|
|
37693
|
+
}
|
|
37694
|
+
});
|
|
37695
|
+
function stripAnsi(str) {
|
|
37696
|
+
return str.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
37697
|
+
}
|
|
37698
|
+
function parseCount(params, fallback = 1) {
|
|
37699
|
+
const first = Number(String(params || "").split(";")[0] || fallback);
|
|
37700
|
+
return Math.max(1, Number.isFinite(first) ? first : fallback);
|
|
37701
|
+
}
|
|
37702
|
+
function isCombiningMark(ch) {
|
|
37703
|
+
return /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/.test(ch);
|
|
37704
|
+
}
|
|
37705
|
+
function isWideCodePoint(ch) {
|
|
37706
|
+
const cp = ch.codePointAt(0) || 0;
|
|
37707
|
+
return cp >= 4352 && (cp <= 4447 || cp === 9001 || cp === 9002 || cp >= 11904 && cp <= 42191 && cp !== 12351 || cp >= 44032 && cp <= 55203 || cp >= 63744 && cp <= 64255 || cp >= 65040 && cp <= 65049 || cp >= 65072 && cp <= 65135 || cp >= 65280 && cp <= 65376 || cp >= 65504 && cp <= 65510 || cp >= 127744 && cp <= 129791);
|
|
37708
|
+
}
|
|
37709
|
+
function stripTerminalNoise(str) {
|
|
37710
|
+
return String(str || "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, "").replace(/\r+/g, "\n").replace(/[ \t]+\n/g, "\n").replace(/\n{4,}/g, "\n\n\n");
|
|
37711
|
+
}
|
|
37712
|
+
function sanitizeTerminalText(str) {
|
|
37713
|
+
const accumulator = new TerminalTranscriptAccumulator();
|
|
37714
|
+
return stripTerminalNoise(stripAnsi(accumulator.append(str)));
|
|
37715
|
+
}
|
|
37716
|
+
function listCliScriptNames(scripts) {
|
|
37717
|
+
if (!scripts) return [];
|
|
37718
|
+
return Object.entries(scripts).filter(([, fn]) => typeof fn === "function").map(([name]) => name);
|
|
37719
|
+
}
|
|
37720
|
+
function splitCliScreenLines(text) {
|
|
37721
|
+
return String(text || "").replace(/\u0007/g, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n").map((line) => line.replace(/\s+$/, ""));
|
|
37722
|
+
}
|
|
37723
|
+
function isPromptLikeCliLine(line) {
|
|
37724
|
+
const trimmed = String(line || "").trim();
|
|
37725
|
+
if (!trimmed) return false;
|
|
37726
|
+
return /^[❯›>]\s*(?:$|\S.*)$/.test(trimmed);
|
|
37727
|
+
}
|
|
37728
|
+
function buildCliScreenSnapshot(text) {
|
|
37729
|
+
const normalizedText = String(text || "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
37730
|
+
const rawLines = splitCliScreenLines(normalizedText);
|
|
37731
|
+
const lines = rawLines.map((line, index, arr) => {
|
|
37732
|
+
const trimmed = String(line || "").trim();
|
|
37733
|
+
return {
|
|
37734
|
+
index,
|
|
37735
|
+
fromTop: index,
|
|
37736
|
+
fromBottom: arr.length - index - 1,
|
|
37737
|
+
text: line,
|
|
37738
|
+
trimmed,
|
|
37739
|
+
isEmpty: trimmed.length === 0
|
|
37740
|
+
};
|
|
37741
|
+
});
|
|
37742
|
+
const nonEmptyLines = lines.filter((line) => !line.isEmpty);
|
|
37743
|
+
const firstNonEmptyLine = nonEmptyLines[0] ?? null;
|
|
37744
|
+
const lastNonEmptyLine = nonEmptyLines[nonEmptyLines.length - 1] ?? null;
|
|
37745
|
+
let promptLineIndex = -1;
|
|
37746
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
37747
|
+
if (isPromptLikeCliLine(lines[i].text)) {
|
|
37748
|
+
promptLineIndex = i;
|
|
37749
|
+
break;
|
|
37750
|
+
}
|
|
37751
|
+
}
|
|
37752
|
+
return {
|
|
37753
|
+
text: normalizedText,
|
|
37754
|
+
lineCount: lines.length,
|
|
37755
|
+
lines,
|
|
37756
|
+
nonEmptyLines,
|
|
37757
|
+
firstNonEmptyLineIndex: firstNonEmptyLine?.index ?? -1,
|
|
37758
|
+
lastNonEmptyLineIndex: lastNonEmptyLine?.index ?? -1,
|
|
37759
|
+
firstNonEmptyLine,
|
|
37760
|
+
lastNonEmptyLine,
|
|
37761
|
+
promptLineIndex,
|
|
37762
|
+
promptLine: promptLineIndex >= 0 ? lines[promptLineIndex] : null,
|
|
37763
|
+
linesAbovePrompt: promptLineIndex >= 0 ? lines.slice(0, promptLineIndex) : [...lines],
|
|
37764
|
+
linesBelowPrompt: promptLineIndex >= 0 ? lines.slice(promptLineIndex + 1) : []
|
|
37765
|
+
};
|
|
37766
|
+
}
|
|
37767
|
+
function findBinary(name) {
|
|
37768
|
+
const trimmed = String(name || "").trim();
|
|
37769
|
+
if (!trimmed) return trimmed;
|
|
37770
|
+
const expanded = trimmed.startsWith("~") ? path10.join(os52.homedir(), trimmed.slice(1)) : trimmed;
|
|
37771
|
+
if (path10.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
37772
|
+
return path10.isAbsolute(expanded) ? expanded : path10.resolve(expanded);
|
|
37773
|
+
}
|
|
37774
|
+
const isWin = os52.platform() === "win32";
|
|
37775
|
+
const paths = (process.env.PATH || "").split(path10.delimiter);
|
|
37776
|
+
const extraDirs = [];
|
|
37777
|
+
if (isWin) {
|
|
37778
|
+
if (process.env.APPDATA) extraDirs.push(path10.join(process.env.APPDATA, "npm"));
|
|
37779
|
+
try {
|
|
37780
|
+
extraDirs.push(path10.dirname(process.execPath));
|
|
37781
|
+
} catch {
|
|
37782
|
+
}
|
|
37783
|
+
} else {
|
|
37784
|
+
extraDirs.push(path10.join(os52.homedir(), ".npm-global", "bin"));
|
|
37785
|
+
extraDirs.push("/usr/local/bin", "/opt/homebrew/bin");
|
|
37786
|
+
try {
|
|
37787
|
+
extraDirs.push(path10.dirname(process.execPath));
|
|
37788
|
+
} catch {
|
|
37789
|
+
}
|
|
37790
|
+
}
|
|
37791
|
+
const searchDirs = [...paths, ...extraDirs];
|
|
37792
|
+
const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
37793
|
+
for (const p of searchDirs) {
|
|
37794
|
+
if (!p) continue;
|
|
37795
|
+
for (const ext of exes) {
|
|
37796
|
+
const fullPath = path10.join(p, trimmed + ext);
|
|
37797
|
+
try {
|
|
37798
|
+
const fs31 = require("fs");
|
|
37799
|
+
if (fs31.existsSync(fullPath)) {
|
|
37800
|
+
const stat2 = fs31.statSync(fullPath);
|
|
37801
|
+
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
37802
|
+
return fullPath;
|
|
37803
|
+
}
|
|
37804
|
+
}
|
|
37805
|
+
} catch {
|
|
37806
|
+
}
|
|
37807
|
+
}
|
|
37808
|
+
}
|
|
37809
|
+
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
37810
|
+
}
|
|
37811
|
+
function isScriptBinary(binaryPath) {
|
|
37812
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
37813
|
+
try {
|
|
37814
|
+
const fs31 = require("fs");
|
|
37815
|
+
const resolved = fs31.realpathSync(binaryPath);
|
|
37816
|
+
const head = Buffer.alloc(8);
|
|
37817
|
+
const fd = fs31.openSync(resolved, "r");
|
|
37818
|
+
fs31.readSync(fd, head, 0, 8, 0);
|
|
37819
|
+
fs31.closeSync(fd);
|
|
37820
|
+
let i = 0;
|
|
37821
|
+
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
37822
|
+
return head[i] === 35 && head[i + 1] === 33;
|
|
37823
|
+
} catch {
|
|
37824
|
+
return false;
|
|
37825
|
+
}
|
|
37826
|
+
}
|
|
37827
|
+
function looksLikeMachOOrElf(filePath) {
|
|
37828
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
37829
|
+
try {
|
|
37830
|
+
const fs31 = require("fs");
|
|
37831
|
+
const resolved = fs31.realpathSync(filePath);
|
|
37832
|
+
const buf = Buffer.alloc(8);
|
|
37833
|
+
const fd = fs31.openSync(resolved, "r");
|
|
37834
|
+
fs31.readSync(fd, buf, 0, 8, 0);
|
|
37835
|
+
fs31.closeSync(fd);
|
|
37836
|
+
let i = 0;
|
|
37837
|
+
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
37838
|
+
const b = buf.subarray(i);
|
|
37839
|
+
if (b.length < 4) return false;
|
|
37840
|
+
if (b[0] === 127 && b[1] === 69 && b[2] === 76 && b[3] === 70) return true;
|
|
37841
|
+
const le = b.readUInt32LE(0);
|
|
37842
|
+
const be = b.readUInt32BE(0);
|
|
37843
|
+
const magics = [4277009102, 4277009103, 3405691582, 3199925962];
|
|
37844
|
+
return magics.some((m) => m === le || m === be);
|
|
37845
|
+
} catch {
|
|
37846
|
+
return false;
|
|
37847
|
+
}
|
|
37848
|
+
}
|
|
37849
|
+
function shSingleQuote(arg) {
|
|
37850
|
+
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
37851
|
+
if (os52.platform() === "win32") {
|
|
37852
|
+
return `"${arg.replace(/"/g, '""')}"`;
|
|
37853
|
+
}
|
|
37854
|
+
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
37855
|
+
}
|
|
37856
|
+
function estimatePromptDisplayLines(text, cols = 80) {
|
|
37857
|
+
const normalized = String(text || "").replace(/\r/g, "");
|
|
37858
|
+
if (!normalized) return 1;
|
|
37859
|
+
return normalized.split("\n").reduce((sum, line) => sum + Math.max(1, Math.ceil(Math.max(1, line.length) / cols)), 0);
|
|
37860
|
+
}
|
|
37861
|
+
function extractPromptRetrySnippet(text) {
|
|
37862
|
+
const lines = String(text || "").replace(/\r/g, "").split("\n").map((line) => line.trim()).filter(Boolean);
|
|
37863
|
+
const candidate = lines[lines.length - 1] || lines[0] || "";
|
|
37864
|
+
return candidate.slice(-120);
|
|
37865
|
+
}
|
|
37866
|
+
function normalizePromptText(text) {
|
|
37867
|
+
return String(text || "").replace(/\s+/g, " ").trim();
|
|
37868
|
+
}
|
|
37869
|
+
function compactPromptText(text) {
|
|
37870
|
+
return String(text || "").replace(/\s+/g, "").trim();
|
|
37871
|
+
}
|
|
37872
|
+
function promptLikelyVisible(screenText, promptSnippet) {
|
|
37873
|
+
const snippet = normalizePromptText(promptSnippet);
|
|
37874
|
+
if (!snippet) return false;
|
|
37875
|
+
const normalizedScreen = normalizePromptText(screenText);
|
|
37876
|
+
if (normalizedScreen.includes(snippet)) return true;
|
|
37877
|
+
const compactScreen = compactPromptText(screenText);
|
|
37878
|
+
const compactSnippet = compactPromptText(promptSnippet);
|
|
37879
|
+
if (compactSnippet && compactScreen.includes(compactSnippet)) return true;
|
|
37880
|
+
const tokens = snippet.split(/[^A-Za-z0-9_.:/-]+/).map((token) => token.trim()).filter((token) => token.length >= 4);
|
|
37881
|
+
if (tokens.length === 0) return false;
|
|
37882
|
+
const required2 = Math.min(tokens.length, 3);
|
|
37883
|
+
const matched = tokens.filter(
|
|
37884
|
+
(token) => normalizedScreen.includes(token) || compactScreen.includes(compactPromptText(token))
|
|
37885
|
+
).length;
|
|
37886
|
+
return matched >= required2;
|
|
37887
|
+
}
|
|
37888
|
+
function normalizeScreenSnapshot(text) {
|
|
37889
|
+
return sanitizeTerminalText(String(text || "")).replace(/\s+/g, " ").trim();
|
|
37890
|
+
}
|
|
37891
|
+
function parsePatternEntry(x) {
|
|
37892
|
+
if (x instanceof RegExp) return x;
|
|
37893
|
+
if (x && typeof x === "object" && typeof x.source === "string") {
|
|
37894
|
+
try {
|
|
37895
|
+
const s = x;
|
|
37896
|
+
return new RegExp(s.source, s.flags || "");
|
|
37897
|
+
} catch {
|
|
37898
|
+
return null;
|
|
37899
|
+
}
|
|
37900
|
+
}
|
|
37901
|
+
return null;
|
|
37902
|
+
}
|
|
37903
|
+
function coercePatternArray(raw) {
|
|
37904
|
+
if (!Array.isArray(raw)) return [];
|
|
37905
|
+
return raw.map(parsePatternEntry).filter((r) => r != null);
|
|
37906
|
+
}
|
|
37907
|
+
function normalizeCliProviderForRuntime(raw) {
|
|
37908
|
+
const patterns = raw && typeof raw === "object" ? raw.patterns : void 0;
|
|
37909
|
+
return {
|
|
37910
|
+
patterns: {
|
|
37911
|
+
approval: coercePatternArray(
|
|
37912
|
+
patterns && typeof patterns === "object" ? patterns.approval : void 0
|
|
37913
|
+
)
|
|
37914
|
+
}
|
|
37915
|
+
};
|
|
37916
|
+
}
|
|
37917
|
+
var os52;
|
|
37918
|
+
var path10;
|
|
37919
|
+
var TerminalTranscriptAccumulator;
|
|
37920
|
+
var buildCliSpawnEnv;
|
|
37921
|
+
var init_provider_cli_shared = __esm2({
|
|
37922
|
+
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
37923
|
+
"use strict";
|
|
37924
|
+
os52 = __toESM2(require("os"));
|
|
37925
|
+
path10 = __toESM2(require("path"));
|
|
37926
|
+
init_spawn_env();
|
|
37927
|
+
TerminalTranscriptAccumulator = class {
|
|
37928
|
+
lines = [[]];
|
|
37929
|
+
row = 0;
|
|
37930
|
+
col = 0;
|
|
37931
|
+
savedCursor = null;
|
|
37932
|
+
pendingEscape = "";
|
|
37933
|
+
append(data) {
|
|
37934
|
+
const input = this.pendingEscape + String(data || "");
|
|
37935
|
+
this.pendingEscape = "";
|
|
37936
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
37937
|
+
let ch = input[i];
|
|
37938
|
+
if (ch === "\x1B") {
|
|
37939
|
+
const consumed = this.consumeEscape(input.slice(i));
|
|
37940
|
+
if (consumed === 0) {
|
|
37941
|
+
this.pendingEscape = input.slice(i);
|
|
37942
|
+
break;
|
|
37943
|
+
}
|
|
37944
|
+
i += consumed - 1;
|
|
37945
|
+
continue;
|
|
37946
|
+
}
|
|
37947
|
+
const cp = input.codePointAt(i);
|
|
37948
|
+
if (cp && cp > 65535) {
|
|
37949
|
+
ch = String.fromCodePoint(cp);
|
|
37950
|
+
i += 1;
|
|
37951
|
+
}
|
|
37952
|
+
this.writeControlOrChar(ch);
|
|
37953
|
+
}
|
|
37954
|
+
return this.getText();
|
|
37955
|
+
}
|
|
37956
|
+
reset() {
|
|
37957
|
+
this.lines = [[]];
|
|
37958
|
+
this.row = 0;
|
|
37959
|
+
this.col = 0;
|
|
37960
|
+
this.savedCursor = null;
|
|
37961
|
+
this.pendingEscape = "";
|
|
37962
|
+
}
|
|
37963
|
+
getText() {
|
|
37964
|
+
return this.lines.map((line) => line.join("").replace(/[ \t]+$/g, "")).join("\n");
|
|
37965
|
+
}
|
|
37966
|
+
ensureRow(row = this.row) {
|
|
37967
|
+
while (this.lines.length <= row) this.lines.push([]);
|
|
37968
|
+
}
|
|
37969
|
+
writeControlOrChar(ch) {
|
|
37970
|
+
if (ch === "\r") {
|
|
37971
|
+
this.col = 0;
|
|
37972
|
+
return;
|
|
37973
|
+
}
|
|
37974
|
+
if (ch === "\n") {
|
|
37975
|
+
this.row += 1;
|
|
37976
|
+
this.col = 0;
|
|
37977
|
+
this.ensureRow();
|
|
37978
|
+
return;
|
|
37979
|
+
}
|
|
37980
|
+
if (ch === "\b") {
|
|
37981
|
+
this.col = Math.max(0, this.col - 1);
|
|
37982
|
+
return;
|
|
37983
|
+
}
|
|
37984
|
+
if (ch < " " || ch === "\x7F") return;
|
|
37985
|
+
this.ensureRow();
|
|
37986
|
+
const line = this.lines[this.row];
|
|
37987
|
+
if (isCombiningMark(ch) && this.col > 0) {
|
|
37988
|
+
line[this.col - 1] = `${line[this.col - 1] || ""}${ch}`;
|
|
37989
|
+
return;
|
|
37990
|
+
}
|
|
37991
|
+
while (line.length < this.col) line.push(" ");
|
|
37992
|
+
const wide = isWideCodePoint(ch);
|
|
37993
|
+
line[this.col] = ch;
|
|
37994
|
+
if (wide) line[this.col + 1] = "";
|
|
37995
|
+
this.col += wide ? 2 : 1;
|
|
37996
|
+
}
|
|
37997
|
+
consumeEscape(seq) {
|
|
37998
|
+
if (seq.length < 2) return 0;
|
|
37999
|
+
const next = seq[1];
|
|
38000
|
+
if (next === "7") {
|
|
38001
|
+
this.savedCursor = { row: this.row, col: this.col };
|
|
38002
|
+
return 2;
|
|
38003
|
+
}
|
|
38004
|
+
if (next === "8") {
|
|
38005
|
+
if (this.savedCursor) {
|
|
38006
|
+
this.row = this.savedCursor.row;
|
|
38007
|
+
this.col = this.savedCursor.col;
|
|
38008
|
+
this.ensureRow();
|
|
38009
|
+
}
|
|
38010
|
+
return 2;
|
|
38011
|
+
}
|
|
38012
|
+
if (next === "]") {
|
|
38013
|
+
const bel = seq.indexOf("\x07", 2);
|
|
38014
|
+
const st = seq.indexOf("\x1B\\", 2);
|
|
38015
|
+
const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
|
|
38016
|
+
return end;
|
|
38017
|
+
}
|
|
38018
|
+
if (next === "[") {
|
|
38019
|
+
const match = seq.match(/^\x1B\[([0-?]*)([ -/]*)([@-~])/);
|
|
38020
|
+
if (!match) return seq.length < 32 ? 0 : 1;
|
|
38021
|
+
this.applyCsi(match[1] || "", match[3]);
|
|
38022
|
+
return match[0].length;
|
|
38023
|
+
}
|
|
38024
|
+
if (/[P^_X]/.test(next)) {
|
|
38025
|
+
const bel = seq.indexOf("\x07", 2);
|
|
38026
|
+
const st = seq.indexOf("\x1B\\", 2);
|
|
38027
|
+
const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
|
|
38028
|
+
return end;
|
|
38029
|
+
}
|
|
38030
|
+
return 2;
|
|
38031
|
+
}
|
|
38032
|
+
applyCsi(params, final) {
|
|
38033
|
+
const count = parseCount(params);
|
|
38034
|
+
this.ensureRow();
|
|
38035
|
+
if (final === "A") this.row = Math.max(0, this.row - count);
|
|
38036
|
+
else if (final === "B") this.row += count;
|
|
38037
|
+
else if (final === "C") {
|
|
38038
|
+
const line = this.lines[this.row];
|
|
38039
|
+
for (let c = this.col; c < this.col + count; c += 1) {
|
|
38040
|
+
if (line[c] === void 0) line[c] = " ";
|
|
38041
|
+
}
|
|
38042
|
+
this.col += count;
|
|
38043
|
+
} else if (final === "D") this.col = Math.max(0, this.col - count);
|
|
38044
|
+
else if (final === "G") this.col = Math.max(0, count - 1);
|
|
38045
|
+
else if (final === "H" || final === "f") {
|
|
38046
|
+
const parts = String(params || "").split(";");
|
|
38047
|
+
this.row = Math.max(0, (Number(parts[0] || 1) || 1) - 1);
|
|
38048
|
+
this.col = Math.max(0, (Number(parts[1] || 1) || 1) - 1);
|
|
38049
|
+
} else if (final === "J") {
|
|
38050
|
+
const mode = Number(params || 0) || 0;
|
|
38051
|
+
if (mode === 2 || mode === 3) {
|
|
38052
|
+
this.lines = [[]];
|
|
38053
|
+
this.row = 0;
|
|
38054
|
+
this.col = 0;
|
|
38055
|
+
} else if (mode === 0) {
|
|
38056
|
+
this.lines[this.row] = this.lines[this.row].slice(0, this.col);
|
|
38057
|
+
this.lines.splice(this.row + 1);
|
|
38058
|
+
} else if (mode === 1) {
|
|
38059
|
+
for (let r = 0; r < this.row; r += 1) this.lines[r] = [];
|
|
38060
|
+
const line = this.lines[this.row];
|
|
38061
|
+
for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
|
|
38062
|
+
}
|
|
38063
|
+
} else if (final === "K") {
|
|
38064
|
+
const mode = Number(params || 0) || 0;
|
|
38065
|
+
const line = this.lines[this.row];
|
|
38066
|
+
if (mode === 2) this.lines[this.row] = [];
|
|
38067
|
+
else if (mode === 1) {
|
|
38068
|
+
for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
|
|
38069
|
+
} else {
|
|
38070
|
+
this.lines[this.row] = line.slice(0, this.col);
|
|
38071
|
+
}
|
|
38072
|
+
} else if (final === "s") {
|
|
38073
|
+
this.savedCursor = { row: this.row, col: this.col };
|
|
38074
|
+
} else if (final === "u") {
|
|
38075
|
+
if (this.savedCursor) {
|
|
38076
|
+
this.row = this.savedCursor.row;
|
|
38077
|
+
this.col = this.savedCursor.col;
|
|
38078
|
+
}
|
|
38079
|
+
}
|
|
38080
|
+
this.ensureRow();
|
|
38081
|
+
}
|
|
38082
|
+
};
|
|
38083
|
+
buildCliSpawnEnv = import_session_host_core22.sanitizeSpawnEnv;
|
|
38084
|
+
}
|
|
38085
|
+
});
|
|
37688
38086
|
function parseVersion(raw) {
|
|
37689
38087
|
const match = raw.match(/v?(\d+\.\d+(?:\.\d+)?(?:-[a-zA-Z0-9.]+)?)/);
|
|
37690
38088
|
return match ? match[1] : raw.split("\n")[0].slice(0, 100);
|
|
@@ -37696,22 +38094,31 @@ Next step: ${nextStep}`;
|
|
|
37696
38094
|
function expandHome(value) {
|
|
37697
38095
|
const trimmed = value.trim();
|
|
37698
38096
|
if (!trimmed.startsWith("~")) return trimmed;
|
|
37699
|
-
return
|
|
38097
|
+
return path11.join(os6.homedir(), trimmed.slice(1));
|
|
37700
38098
|
}
|
|
37701
38099
|
function isExplicitCommandPath(command) {
|
|
37702
38100
|
const trimmed = command.trim();
|
|
37703
|
-
return
|
|
38101
|
+
return path11.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
37704
38102
|
}
|
|
37705
38103
|
function resolveCommandPath(command) {
|
|
37706
38104
|
const trimmed = command.trim();
|
|
37707
38105
|
if (!trimmed) return null;
|
|
37708
38106
|
if (isExplicitCommandPath(trimmed)) {
|
|
37709
38107
|
const expanded = expandHome(trimmed);
|
|
37710
|
-
const candidate =
|
|
38108
|
+
const candidate = path11.isAbsolute(expanded) ? expanded : path11.resolve(expanded);
|
|
37711
38109
|
return (0, import_fs9.existsSync)(candidate) ? candidate : null;
|
|
37712
38110
|
}
|
|
37713
38111
|
return null;
|
|
37714
38112
|
}
|
|
38113
|
+
async function resolveDetectionPath(command, whichCmd) {
|
|
38114
|
+
const explicitPath = resolveCommandPath(command);
|
|
38115
|
+
if (explicitPath) return explicitPath;
|
|
38116
|
+
const whichResult = await execAsync(`${whichCmd} ${shellQuote(command)}`);
|
|
38117
|
+
if (whichResult) return whichResult.split("\n")[0];
|
|
38118
|
+
const resolved = findBinary(command);
|
|
38119
|
+
if (path11.isAbsolute(resolved) && (0, import_fs9.existsSync)(resolved)) return resolved;
|
|
38120
|
+
return null;
|
|
38121
|
+
}
|
|
37715
38122
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
37716
38123
|
return new Promise((resolve24) => {
|
|
37717
38124
|
const child = (0, import_child_process.exec)(cmd, {
|
|
@@ -37729,17 +38136,15 @@ Next step: ${nextStep}`;
|
|
|
37729
38136
|
});
|
|
37730
38137
|
}
|
|
37731
38138
|
async function detectCLIs(providerLoader, options) {
|
|
37732
|
-
const platform10 =
|
|
38139
|
+
const platform10 = os6.platform();
|
|
37733
38140
|
const whichCmd = platform10 === "win32" ? "where" : "which";
|
|
37734
38141
|
const includeVersion = options?.includeVersion !== false;
|
|
37735
38142
|
const cliList = providerLoader ? providerLoader.getCliDetectionList() : [];
|
|
37736
38143
|
const results = await Promise.all(
|
|
37737
38144
|
cliList.map(async (cli) => {
|
|
37738
38145
|
try {
|
|
37739
|
-
const
|
|
37740
|
-
|
|
37741
|
-
if (!pathResult) return { ...cli, installed: false };
|
|
37742
|
-
const firstPath = explicitPath || pathResult.split("\n")[0];
|
|
38146
|
+
const firstPath = await resolveDetectionPath(cli.command, whichCmd);
|
|
38147
|
+
if (!firstPath) return { ...cli, installed: false };
|
|
37743
38148
|
let version2;
|
|
37744
38149
|
if (includeVersion) {
|
|
37745
38150
|
const versionCommands = [
|
|
@@ -37773,13 +38178,11 @@ Next step: ${nextStep}`;
|
|
|
37773
38178
|
const cliList = providerLoader.getCliDetectionList();
|
|
37774
38179
|
const target = cliList.find((c) => c.id === resolvedId);
|
|
37775
38180
|
if (target) {
|
|
37776
|
-
const platform10 =
|
|
38181
|
+
const platform10 = os6.platform();
|
|
37777
38182
|
const whichCmd = platform10 === "win32" ? "where" : "which";
|
|
37778
38183
|
try {
|
|
37779
|
-
const
|
|
37780
|
-
|
|
37781
|
-
if (!pathResult) return null;
|
|
37782
|
-
const firstPath = explicitPath || pathResult.split("\n")[0];
|
|
38184
|
+
const firstPath = await resolveDetectionPath(target.command, whichCmd);
|
|
38185
|
+
if (!firstPath) return null;
|
|
37783
38186
|
let version2;
|
|
37784
38187
|
if (options?.includeVersion !== false) {
|
|
37785
38188
|
const versionCommands = [
|
|
@@ -37809,16 +38212,17 @@ Next step: ${nextStep}`;
|
|
|
37809
38212
|
return all.find((c) => c.id === resolvedId && c.installed) || null;
|
|
37810
38213
|
}
|
|
37811
38214
|
var import_child_process;
|
|
37812
|
-
var
|
|
37813
|
-
var
|
|
38215
|
+
var os6;
|
|
38216
|
+
var path11;
|
|
37814
38217
|
var import_fs9;
|
|
37815
38218
|
var init_cli_detector = __esm2({
|
|
37816
38219
|
"src/detection/cli-detector.ts"() {
|
|
37817
38220
|
"use strict";
|
|
37818
38221
|
import_child_process = require("child_process");
|
|
37819
|
-
|
|
37820
|
-
|
|
38222
|
+
os6 = __toESM2(require("os"));
|
|
38223
|
+
path11 = __toESM2(require("path"));
|
|
37821
38224
|
import_fs9 = require("fs");
|
|
38225
|
+
init_provider_cli_shared();
|
|
37822
38226
|
}
|
|
37823
38227
|
});
|
|
37824
38228
|
function readSettings(state) {
|
|
@@ -40425,16 +40829,16 @@ Next step: ${nextStep}`;
|
|
|
40425
40829
|
sourcesProviding: () => sourcesProviding
|
|
40426
40830
|
});
|
|
40427
40831
|
function adhdevDir() {
|
|
40428
|
-
return
|
|
40832
|
+
return path16.join(os11.homedir(), ".adhdev");
|
|
40429
40833
|
}
|
|
40430
40834
|
function externalRoot() {
|
|
40431
|
-
return
|
|
40835
|
+
return path16.join(adhdevDir(), "external");
|
|
40432
40836
|
}
|
|
40433
40837
|
function sourcesFilePath() {
|
|
40434
|
-
return
|
|
40838
|
+
return path16.join(adhdevDir(), SOURCES_FILENAME);
|
|
40435
40839
|
}
|
|
40436
40840
|
function activeFilePath() {
|
|
40437
|
-
return
|
|
40841
|
+
return path16.join(adhdevDir(), ACTIVE_FILENAME);
|
|
40438
40842
|
}
|
|
40439
40843
|
function ensureAdhdevDir() {
|
|
40440
40844
|
const d = adhdevDir();
|
|
@@ -40501,7 +40905,7 @@ Next step: ${nextStep}`;
|
|
|
40501
40905
|
for (const sourceEntry of entries) {
|
|
40502
40906
|
if (!sourceEntry.isDirectory()) continue;
|
|
40503
40907
|
const sourceName = sourceEntry.name;
|
|
40504
|
-
const sourceDir =
|
|
40908
|
+
const sourceDir = path16.join(root, sourceName);
|
|
40505
40909
|
const providers = {};
|
|
40506
40910
|
let categoryEntries;
|
|
40507
40911
|
try {
|
|
@@ -40512,7 +40916,7 @@ Next step: ${nextStep}`;
|
|
|
40512
40916
|
for (const categoryEntry of categoryEntries) {
|
|
40513
40917
|
if (!categoryEntry.isDirectory()) continue;
|
|
40514
40918
|
const category = categoryEntry.name;
|
|
40515
|
-
const categoryDir =
|
|
40919
|
+
const categoryDir = path16.join(sourceDir, category);
|
|
40516
40920
|
let typeEntries;
|
|
40517
40921
|
try {
|
|
40518
40922
|
typeEntries = fs8.readdirSync(categoryDir, { withFileTypes: true });
|
|
@@ -40522,9 +40926,9 @@ Next step: ${nextStep}`;
|
|
|
40522
40926
|
const types = [];
|
|
40523
40927
|
for (const typeEntry of typeEntries) {
|
|
40524
40928
|
if (!typeEntry.isDirectory()) continue;
|
|
40525
|
-
const typeDir =
|
|
40526
|
-
const hasV1 = fs8.existsSync(
|
|
40527
|
-
const hasV0 = fs8.existsSync(
|
|
40929
|
+
const typeDir = path16.join(categoryDir, typeEntry.name);
|
|
40930
|
+
const hasV1 = fs8.existsSync(path16.join(typeDir, "provider.v1.json"));
|
|
40931
|
+
const hasV0 = fs8.existsSync(path16.join(typeDir, "provider.json"));
|
|
40528
40932
|
if (hasV1 || hasV0) types.push(typeEntry.name);
|
|
40529
40933
|
}
|
|
40530
40934
|
if (types.length > 0) providers[category] = types;
|
|
@@ -40548,16 +40952,16 @@ Next step: ${nextStep}`;
|
|
|
40548
40952
|
return { source: candidates[0], ambiguous: true, candidates };
|
|
40549
40953
|
}
|
|
40550
40954
|
var fs8;
|
|
40551
|
-
var
|
|
40552
|
-
var
|
|
40955
|
+
var os11;
|
|
40956
|
+
var path16;
|
|
40553
40957
|
var SOURCES_FILENAME;
|
|
40554
40958
|
var ACTIVE_FILENAME;
|
|
40555
40959
|
var init_external_sources = __esm2({
|
|
40556
40960
|
"src/providers/external-sources.ts"() {
|
|
40557
40961
|
"use strict";
|
|
40558
40962
|
fs8 = __toESM2(require("fs"));
|
|
40559
|
-
|
|
40560
|
-
|
|
40963
|
+
os11 = __toESM2(require("os"));
|
|
40964
|
+
path16 = __toESM2(require("path"));
|
|
40561
40965
|
SOURCES_FILENAME = "providers-sources.json";
|
|
40562
40966
|
ACTIVE_FILENAME = "providers-active.json";
|
|
40563
40967
|
}
|
|
@@ -40679,21 +41083,21 @@ Next step: ${nextStep}`;
|
|
|
40679
41083
|
function getTerminalBackendRuntimeStatus() {
|
|
40680
41084
|
return { backend: "ghostty-vt" };
|
|
40681
41085
|
}
|
|
40682
|
-
var
|
|
41086
|
+
var import_session_host_core32;
|
|
40683
41087
|
var DEFAULT_SCROLLBACK;
|
|
40684
41088
|
var TerminalScreen;
|
|
40685
41089
|
var init_terminal_screen = __esm2({
|
|
40686
41090
|
"src/cli-adapters/terminal-screen.ts"() {
|
|
40687
41091
|
"use strict";
|
|
40688
41092
|
init_ghostty_vt_backend();
|
|
40689
|
-
|
|
41093
|
+
import_session_host_core32 = require_dist();
|
|
40690
41094
|
DEFAULT_SCROLLBACK = 2e3;
|
|
40691
41095
|
TerminalScreen = class {
|
|
40692
41096
|
backendKind = "ghostty-vt";
|
|
40693
41097
|
rows;
|
|
40694
41098
|
cols;
|
|
40695
41099
|
terminal;
|
|
40696
|
-
constructor(rows =
|
|
41100
|
+
constructor(rows = import_session_host_core32.DEFAULT_SESSION_HOST_ROWS, cols = import_session_host_core32.DEFAULT_SESSION_HOST_COLS) {
|
|
40697
41101
|
this.rows = Math.max(1, rows | 0);
|
|
40698
41102
|
this.cols = Math.max(1, cols | 0);
|
|
40699
41103
|
this.terminal = this.createBackend();
|
|
@@ -40735,18 +41139,30 @@ Next step: ${nextStep}`;
|
|
|
40735
41139
|
};
|
|
40736
41140
|
}
|
|
40737
41141
|
});
|
|
40738
|
-
|
|
40739
|
-
|
|
40740
|
-
|
|
40741
|
-
"use strict";
|
|
40742
|
-
import_session_host_core32 = require_dist();
|
|
41142
|
+
function resolveWin32GlobalBin(trimmed) {
|
|
41143
|
+
if (path17.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\")) {
|
|
41144
|
+
return null;
|
|
40743
41145
|
}
|
|
40744
|
-
|
|
41146
|
+
const extraDirs = [];
|
|
41147
|
+
if (process.env.APPDATA) extraDirs.push(path17.join(process.env.APPDATA, "npm"));
|
|
41148
|
+
try {
|
|
41149
|
+
extraDirs.push(path17.dirname(process.execPath));
|
|
41150
|
+
} catch {
|
|
41151
|
+
}
|
|
41152
|
+
for (const dir of extraDirs) {
|
|
41153
|
+
if (!dir) continue;
|
|
41154
|
+
for (const ext of WIN_EXEC_EXT) {
|
|
41155
|
+
const full = path17.join(dir, trimmed + ext);
|
|
41156
|
+
if ((0, import_fs13.existsSync)(full)) return full;
|
|
41157
|
+
}
|
|
41158
|
+
}
|
|
41159
|
+
return null;
|
|
41160
|
+
}
|
|
40745
41161
|
function resolveWin32Executable(command) {
|
|
40746
41162
|
if (process.platform !== "win32") return command;
|
|
40747
41163
|
const trimmed = (command || "").trim();
|
|
40748
41164
|
if (!trimmed) return command;
|
|
40749
|
-
if (
|
|
41165
|
+
if (path17.isAbsolute(trimmed) && (0, import_fs13.existsSync)(trimmed)) return trimmed;
|
|
40750
41166
|
try {
|
|
40751
41167
|
const out = (0, import_child_process4.execFileSync)("where", [trimmed], {
|
|
40752
41168
|
encoding: "utf8",
|
|
@@ -40754,24 +41170,28 @@ Next step: ${nextStep}`;
|
|
|
40754
41170
|
}).trim();
|
|
40755
41171
|
if (out) {
|
|
40756
41172
|
const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
40757
|
-
const direct = matches.find((m) => DIRECT_EXEC_EXT.has(
|
|
41173
|
+
const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path17.extname(m).toLowerCase()));
|
|
40758
41174
|
return direct || matches[0] || command;
|
|
40759
41175
|
}
|
|
40760
41176
|
} catch {
|
|
40761
41177
|
}
|
|
41178
|
+
const globalBin = resolveWin32GlobalBin(trimmed);
|
|
41179
|
+
if (globalBin) return globalBin;
|
|
40762
41180
|
return command;
|
|
40763
41181
|
}
|
|
40764
41182
|
var import_child_process4;
|
|
40765
41183
|
var import_fs13;
|
|
40766
|
-
var
|
|
41184
|
+
var path17;
|
|
40767
41185
|
var DIRECT_EXEC_EXT;
|
|
41186
|
+
var WIN_EXEC_EXT;
|
|
40768
41187
|
var init_resolve_executable = __esm2({
|
|
40769
41188
|
"src/cli-adapters/resolve-executable.ts"() {
|
|
40770
41189
|
"use strict";
|
|
40771
41190
|
import_child_process4 = require("child_process");
|
|
40772
41191
|
import_fs13 = require("fs");
|
|
40773
|
-
|
|
41192
|
+
path17 = __toESM2(require("path"));
|
|
40774
41193
|
DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
|
|
41194
|
+
WIN_EXEC_EXT = [".exe", ".com", ".cmd", ".bat"];
|
|
40775
41195
|
}
|
|
40776
41196
|
});
|
|
40777
41197
|
var pty_transport_exports = {};
|
|
@@ -40782,20 +41202,20 @@ Next step: ${nextStep}`;
|
|
|
40782
41202
|
if (cachedPty !== void 0) return cachedPty;
|
|
40783
41203
|
try {
|
|
40784
41204
|
cachedPty = require("node-pty");
|
|
40785
|
-
(0,
|
|
41205
|
+
(0, import_session_host_core22.ensureNodePtySpawnHelperPermissions)();
|
|
40786
41206
|
} catch {
|
|
40787
41207
|
cachedPty = null;
|
|
40788
41208
|
}
|
|
40789
41209
|
return cachedPty;
|
|
40790
41210
|
}
|
|
40791
|
-
var
|
|
41211
|
+
var os12;
|
|
40792
41212
|
var cachedPty;
|
|
40793
41213
|
var NodePtyRuntimeTransport;
|
|
40794
41214
|
var NodePtyTransportFactory;
|
|
40795
41215
|
var init_pty_transport = __esm2({
|
|
40796
41216
|
"src/cli-adapters/pty-transport.ts"() {
|
|
40797
41217
|
"use strict";
|
|
40798
|
-
|
|
41218
|
+
os12 = __toESM2(require("os"));
|
|
40799
41219
|
init_spawn_env();
|
|
40800
41220
|
init_resolve_executable();
|
|
40801
41221
|
NodePtyRuntimeTransport = class {
|
|
@@ -40835,9 +41255,9 @@ Next step: ${nextStep}`;
|
|
|
40835
41255
|
try {
|
|
40836
41256
|
const fs31 = require("fs");
|
|
40837
41257
|
const stat2 = fs31.statSync(cwd);
|
|
40838
|
-
if (!stat2.isDirectory()) cwd =
|
|
41258
|
+
if (!stat2.isDirectory()) cwd = os12.homedir();
|
|
40839
41259
|
} catch {
|
|
40840
|
-
cwd =
|
|
41260
|
+
cwd = os12.homedir();
|
|
40841
41261
|
}
|
|
40842
41262
|
}
|
|
40843
41263
|
const handle = pty.spawn(resolveWin32Executable(command), args, {
|
|
@@ -40852,397 +41272,6 @@ Next step: ${nextStep}`;
|
|
|
40852
41272
|
};
|
|
40853
41273
|
}
|
|
40854
41274
|
});
|
|
40855
|
-
function stripAnsi(str) {
|
|
40856
|
-
return str.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
40857
|
-
}
|
|
40858
|
-
function parseCount(params, fallback = 1) {
|
|
40859
|
-
const first = Number(String(params || "").split(";")[0] || fallback);
|
|
40860
|
-
return Math.max(1, Number.isFinite(first) ? first : fallback);
|
|
40861
|
-
}
|
|
40862
|
-
function isCombiningMark(ch) {
|
|
40863
|
-
return /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/.test(ch);
|
|
40864
|
-
}
|
|
40865
|
-
function isWideCodePoint(ch) {
|
|
40866
|
-
const cp = ch.codePointAt(0) || 0;
|
|
40867
|
-
return cp >= 4352 && (cp <= 4447 || cp === 9001 || cp === 9002 || cp >= 11904 && cp <= 42191 && cp !== 12351 || cp >= 44032 && cp <= 55203 || cp >= 63744 && cp <= 64255 || cp >= 65040 && cp <= 65049 || cp >= 65072 && cp <= 65135 || cp >= 65280 && cp <= 65376 || cp >= 65504 && cp <= 65510 || cp >= 127744 && cp <= 129791);
|
|
40868
|
-
}
|
|
40869
|
-
function stripTerminalNoise(str) {
|
|
40870
|
-
return String(str || "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, "").replace(/\r+/g, "\n").replace(/[ \t]+\n/g, "\n").replace(/\n{4,}/g, "\n\n\n");
|
|
40871
|
-
}
|
|
40872
|
-
function sanitizeTerminalText(str) {
|
|
40873
|
-
const accumulator = new TerminalTranscriptAccumulator();
|
|
40874
|
-
return stripTerminalNoise(stripAnsi(accumulator.append(str)));
|
|
40875
|
-
}
|
|
40876
|
-
function listCliScriptNames(scripts) {
|
|
40877
|
-
if (!scripts) return [];
|
|
40878
|
-
return Object.entries(scripts).filter(([, fn]) => typeof fn === "function").map(([name]) => name);
|
|
40879
|
-
}
|
|
40880
|
-
function splitCliScreenLines(text) {
|
|
40881
|
-
return String(text || "").replace(/\u0007/g, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n").map((line) => line.replace(/\s+$/, ""));
|
|
40882
|
-
}
|
|
40883
|
-
function isPromptLikeCliLine(line) {
|
|
40884
|
-
const trimmed = String(line || "").trim();
|
|
40885
|
-
if (!trimmed) return false;
|
|
40886
|
-
return /^[❯›>]\s*(?:$|\S.*)$/.test(trimmed);
|
|
40887
|
-
}
|
|
40888
|
-
function buildCliScreenSnapshot(text) {
|
|
40889
|
-
const normalizedText = String(text || "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
40890
|
-
const rawLines = splitCliScreenLines(normalizedText);
|
|
40891
|
-
const lines = rawLines.map((line, index, arr) => {
|
|
40892
|
-
const trimmed = String(line || "").trim();
|
|
40893
|
-
return {
|
|
40894
|
-
index,
|
|
40895
|
-
fromTop: index,
|
|
40896
|
-
fromBottom: arr.length - index - 1,
|
|
40897
|
-
text: line,
|
|
40898
|
-
trimmed,
|
|
40899
|
-
isEmpty: trimmed.length === 0
|
|
40900
|
-
};
|
|
40901
|
-
});
|
|
40902
|
-
const nonEmptyLines = lines.filter((line) => !line.isEmpty);
|
|
40903
|
-
const firstNonEmptyLine = nonEmptyLines[0] ?? null;
|
|
40904
|
-
const lastNonEmptyLine = nonEmptyLines[nonEmptyLines.length - 1] ?? null;
|
|
40905
|
-
let promptLineIndex = -1;
|
|
40906
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
40907
|
-
if (isPromptLikeCliLine(lines[i].text)) {
|
|
40908
|
-
promptLineIndex = i;
|
|
40909
|
-
break;
|
|
40910
|
-
}
|
|
40911
|
-
}
|
|
40912
|
-
return {
|
|
40913
|
-
text: normalizedText,
|
|
40914
|
-
lineCount: lines.length,
|
|
40915
|
-
lines,
|
|
40916
|
-
nonEmptyLines,
|
|
40917
|
-
firstNonEmptyLineIndex: firstNonEmptyLine?.index ?? -1,
|
|
40918
|
-
lastNonEmptyLineIndex: lastNonEmptyLine?.index ?? -1,
|
|
40919
|
-
firstNonEmptyLine,
|
|
40920
|
-
lastNonEmptyLine,
|
|
40921
|
-
promptLineIndex,
|
|
40922
|
-
promptLine: promptLineIndex >= 0 ? lines[promptLineIndex] : null,
|
|
40923
|
-
linesAbovePrompt: promptLineIndex >= 0 ? lines.slice(0, promptLineIndex) : [...lines],
|
|
40924
|
-
linesBelowPrompt: promptLineIndex >= 0 ? lines.slice(promptLineIndex + 1) : []
|
|
40925
|
-
};
|
|
40926
|
-
}
|
|
40927
|
-
function findBinary(name) {
|
|
40928
|
-
const trimmed = String(name || "").trim();
|
|
40929
|
-
if (!trimmed) return trimmed;
|
|
40930
|
-
const expanded = trimmed.startsWith("~") ? path17.join(os12.homedir(), trimmed.slice(1)) : trimmed;
|
|
40931
|
-
if (path17.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
40932
|
-
return path17.isAbsolute(expanded) ? expanded : path17.resolve(expanded);
|
|
40933
|
-
}
|
|
40934
|
-
const isWin = os12.platform() === "win32";
|
|
40935
|
-
const paths = (process.env.PATH || "").split(path17.delimiter);
|
|
40936
|
-
const extraDirs = [];
|
|
40937
|
-
if (isWin) {
|
|
40938
|
-
if (process.env.APPDATA) extraDirs.push(path17.join(process.env.APPDATA, "npm"));
|
|
40939
|
-
try {
|
|
40940
|
-
extraDirs.push(path17.dirname(process.execPath));
|
|
40941
|
-
} catch {
|
|
40942
|
-
}
|
|
40943
|
-
} else {
|
|
40944
|
-
extraDirs.push(path17.join(os12.homedir(), ".npm-global", "bin"));
|
|
40945
|
-
extraDirs.push("/usr/local/bin", "/opt/homebrew/bin");
|
|
40946
|
-
try {
|
|
40947
|
-
extraDirs.push(path17.dirname(process.execPath));
|
|
40948
|
-
} catch {
|
|
40949
|
-
}
|
|
40950
|
-
}
|
|
40951
|
-
const searchDirs = [...paths, ...extraDirs];
|
|
40952
|
-
const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
40953
|
-
for (const p of searchDirs) {
|
|
40954
|
-
if (!p) continue;
|
|
40955
|
-
for (const ext of exes) {
|
|
40956
|
-
const fullPath = path17.join(p, trimmed + ext);
|
|
40957
|
-
try {
|
|
40958
|
-
const fs31 = require("fs");
|
|
40959
|
-
if (fs31.existsSync(fullPath)) {
|
|
40960
|
-
const stat2 = fs31.statSync(fullPath);
|
|
40961
|
-
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
40962
|
-
return fullPath;
|
|
40963
|
-
}
|
|
40964
|
-
}
|
|
40965
|
-
} catch {
|
|
40966
|
-
}
|
|
40967
|
-
}
|
|
40968
|
-
}
|
|
40969
|
-
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
40970
|
-
}
|
|
40971
|
-
function isScriptBinary(binaryPath) {
|
|
40972
|
-
if (!path17.isAbsolute(binaryPath)) return false;
|
|
40973
|
-
try {
|
|
40974
|
-
const fs31 = require("fs");
|
|
40975
|
-
const resolved = fs31.realpathSync(binaryPath);
|
|
40976
|
-
const head = Buffer.alloc(8);
|
|
40977
|
-
const fd = fs31.openSync(resolved, "r");
|
|
40978
|
-
fs31.readSync(fd, head, 0, 8, 0);
|
|
40979
|
-
fs31.closeSync(fd);
|
|
40980
|
-
let i = 0;
|
|
40981
|
-
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
40982
|
-
return head[i] === 35 && head[i + 1] === 33;
|
|
40983
|
-
} catch {
|
|
40984
|
-
return false;
|
|
40985
|
-
}
|
|
40986
|
-
}
|
|
40987
|
-
function looksLikeMachOOrElf(filePath) {
|
|
40988
|
-
if (!path17.isAbsolute(filePath)) return false;
|
|
40989
|
-
try {
|
|
40990
|
-
const fs31 = require("fs");
|
|
40991
|
-
const resolved = fs31.realpathSync(filePath);
|
|
40992
|
-
const buf = Buffer.alloc(8);
|
|
40993
|
-
const fd = fs31.openSync(resolved, "r");
|
|
40994
|
-
fs31.readSync(fd, buf, 0, 8, 0);
|
|
40995
|
-
fs31.closeSync(fd);
|
|
40996
|
-
let i = 0;
|
|
40997
|
-
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
40998
|
-
const b = buf.subarray(i);
|
|
40999
|
-
if (b.length < 4) return false;
|
|
41000
|
-
if (b[0] === 127 && b[1] === 69 && b[2] === 76 && b[3] === 70) return true;
|
|
41001
|
-
const le = b.readUInt32LE(0);
|
|
41002
|
-
const be = b.readUInt32BE(0);
|
|
41003
|
-
const magics = [4277009102, 4277009103, 3405691582, 3199925962];
|
|
41004
|
-
return magics.some((m) => m === le || m === be);
|
|
41005
|
-
} catch {
|
|
41006
|
-
return false;
|
|
41007
|
-
}
|
|
41008
|
-
}
|
|
41009
|
-
function shSingleQuote(arg) {
|
|
41010
|
-
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
41011
|
-
if (os12.platform() === "win32") {
|
|
41012
|
-
return `"${arg.replace(/"/g, '""')}"`;
|
|
41013
|
-
}
|
|
41014
|
-
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
41015
|
-
}
|
|
41016
|
-
function estimatePromptDisplayLines(text, cols = 80) {
|
|
41017
|
-
const normalized = String(text || "").replace(/\r/g, "");
|
|
41018
|
-
if (!normalized) return 1;
|
|
41019
|
-
return normalized.split("\n").reduce((sum, line) => sum + Math.max(1, Math.ceil(Math.max(1, line.length) / cols)), 0);
|
|
41020
|
-
}
|
|
41021
|
-
function extractPromptRetrySnippet(text) {
|
|
41022
|
-
const lines = String(text || "").replace(/\r/g, "").split("\n").map((line) => line.trim()).filter(Boolean);
|
|
41023
|
-
const candidate = lines[lines.length - 1] || lines[0] || "";
|
|
41024
|
-
return candidate.slice(-120);
|
|
41025
|
-
}
|
|
41026
|
-
function normalizePromptText(text) {
|
|
41027
|
-
return String(text || "").replace(/\s+/g, " ").trim();
|
|
41028
|
-
}
|
|
41029
|
-
function compactPromptText(text) {
|
|
41030
|
-
return String(text || "").replace(/\s+/g, "").trim();
|
|
41031
|
-
}
|
|
41032
|
-
function promptLikelyVisible(screenText, promptSnippet) {
|
|
41033
|
-
const snippet = normalizePromptText(promptSnippet);
|
|
41034
|
-
if (!snippet) return false;
|
|
41035
|
-
const normalizedScreen = normalizePromptText(screenText);
|
|
41036
|
-
if (normalizedScreen.includes(snippet)) return true;
|
|
41037
|
-
const compactScreen = compactPromptText(screenText);
|
|
41038
|
-
const compactSnippet = compactPromptText(promptSnippet);
|
|
41039
|
-
if (compactSnippet && compactScreen.includes(compactSnippet)) return true;
|
|
41040
|
-
const tokens = snippet.split(/[^A-Za-z0-9_.:/-]+/).map((token) => token.trim()).filter((token) => token.length >= 4);
|
|
41041
|
-
if (tokens.length === 0) return false;
|
|
41042
|
-
const required2 = Math.min(tokens.length, 3);
|
|
41043
|
-
const matched = tokens.filter(
|
|
41044
|
-
(token) => normalizedScreen.includes(token) || compactScreen.includes(compactPromptText(token))
|
|
41045
|
-
).length;
|
|
41046
|
-
return matched >= required2;
|
|
41047
|
-
}
|
|
41048
|
-
function normalizeScreenSnapshot(text) {
|
|
41049
|
-
return sanitizeTerminalText(String(text || "")).replace(/\s+/g, " ").trim();
|
|
41050
|
-
}
|
|
41051
|
-
function parsePatternEntry(x) {
|
|
41052
|
-
if (x instanceof RegExp) return x;
|
|
41053
|
-
if (x && typeof x === "object" && typeof x.source === "string") {
|
|
41054
|
-
try {
|
|
41055
|
-
const s = x;
|
|
41056
|
-
return new RegExp(s.source, s.flags || "");
|
|
41057
|
-
} catch {
|
|
41058
|
-
return null;
|
|
41059
|
-
}
|
|
41060
|
-
}
|
|
41061
|
-
return null;
|
|
41062
|
-
}
|
|
41063
|
-
function coercePatternArray(raw) {
|
|
41064
|
-
if (!Array.isArray(raw)) return [];
|
|
41065
|
-
return raw.map(parsePatternEntry).filter((r) => r != null);
|
|
41066
|
-
}
|
|
41067
|
-
function normalizeCliProviderForRuntime(raw) {
|
|
41068
|
-
const patterns = raw && typeof raw === "object" ? raw.patterns : void 0;
|
|
41069
|
-
return {
|
|
41070
|
-
patterns: {
|
|
41071
|
-
approval: coercePatternArray(
|
|
41072
|
-
patterns && typeof patterns === "object" ? patterns.approval : void 0
|
|
41073
|
-
)
|
|
41074
|
-
}
|
|
41075
|
-
};
|
|
41076
|
-
}
|
|
41077
|
-
var os12;
|
|
41078
|
-
var path17;
|
|
41079
|
-
var TerminalTranscriptAccumulator;
|
|
41080
|
-
var buildCliSpawnEnv;
|
|
41081
|
-
var init_provider_cli_shared = __esm2({
|
|
41082
|
-
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
41083
|
-
"use strict";
|
|
41084
|
-
os12 = __toESM2(require("os"));
|
|
41085
|
-
path17 = __toESM2(require("path"));
|
|
41086
|
-
init_spawn_env();
|
|
41087
|
-
TerminalTranscriptAccumulator = class {
|
|
41088
|
-
lines = [[]];
|
|
41089
|
-
row = 0;
|
|
41090
|
-
col = 0;
|
|
41091
|
-
savedCursor = null;
|
|
41092
|
-
pendingEscape = "";
|
|
41093
|
-
append(data) {
|
|
41094
|
-
const input = this.pendingEscape + String(data || "");
|
|
41095
|
-
this.pendingEscape = "";
|
|
41096
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
41097
|
-
let ch = input[i];
|
|
41098
|
-
if (ch === "\x1B") {
|
|
41099
|
-
const consumed = this.consumeEscape(input.slice(i));
|
|
41100
|
-
if (consumed === 0) {
|
|
41101
|
-
this.pendingEscape = input.slice(i);
|
|
41102
|
-
break;
|
|
41103
|
-
}
|
|
41104
|
-
i += consumed - 1;
|
|
41105
|
-
continue;
|
|
41106
|
-
}
|
|
41107
|
-
const cp = input.codePointAt(i);
|
|
41108
|
-
if (cp && cp > 65535) {
|
|
41109
|
-
ch = String.fromCodePoint(cp);
|
|
41110
|
-
i += 1;
|
|
41111
|
-
}
|
|
41112
|
-
this.writeControlOrChar(ch);
|
|
41113
|
-
}
|
|
41114
|
-
return this.getText();
|
|
41115
|
-
}
|
|
41116
|
-
reset() {
|
|
41117
|
-
this.lines = [[]];
|
|
41118
|
-
this.row = 0;
|
|
41119
|
-
this.col = 0;
|
|
41120
|
-
this.savedCursor = null;
|
|
41121
|
-
this.pendingEscape = "";
|
|
41122
|
-
}
|
|
41123
|
-
getText() {
|
|
41124
|
-
return this.lines.map((line) => line.join("").replace(/[ \t]+$/g, "")).join("\n");
|
|
41125
|
-
}
|
|
41126
|
-
ensureRow(row = this.row) {
|
|
41127
|
-
while (this.lines.length <= row) this.lines.push([]);
|
|
41128
|
-
}
|
|
41129
|
-
writeControlOrChar(ch) {
|
|
41130
|
-
if (ch === "\r") {
|
|
41131
|
-
this.col = 0;
|
|
41132
|
-
return;
|
|
41133
|
-
}
|
|
41134
|
-
if (ch === "\n") {
|
|
41135
|
-
this.row += 1;
|
|
41136
|
-
this.col = 0;
|
|
41137
|
-
this.ensureRow();
|
|
41138
|
-
return;
|
|
41139
|
-
}
|
|
41140
|
-
if (ch === "\b") {
|
|
41141
|
-
this.col = Math.max(0, this.col - 1);
|
|
41142
|
-
return;
|
|
41143
|
-
}
|
|
41144
|
-
if (ch < " " || ch === "\x7F") return;
|
|
41145
|
-
this.ensureRow();
|
|
41146
|
-
const line = this.lines[this.row];
|
|
41147
|
-
if (isCombiningMark(ch) && this.col > 0) {
|
|
41148
|
-
line[this.col - 1] = `${line[this.col - 1] || ""}${ch}`;
|
|
41149
|
-
return;
|
|
41150
|
-
}
|
|
41151
|
-
while (line.length < this.col) line.push(" ");
|
|
41152
|
-
const wide = isWideCodePoint(ch);
|
|
41153
|
-
line[this.col] = ch;
|
|
41154
|
-
if (wide) line[this.col + 1] = "";
|
|
41155
|
-
this.col += wide ? 2 : 1;
|
|
41156
|
-
}
|
|
41157
|
-
consumeEscape(seq) {
|
|
41158
|
-
if (seq.length < 2) return 0;
|
|
41159
|
-
const next = seq[1];
|
|
41160
|
-
if (next === "7") {
|
|
41161
|
-
this.savedCursor = { row: this.row, col: this.col };
|
|
41162
|
-
return 2;
|
|
41163
|
-
}
|
|
41164
|
-
if (next === "8") {
|
|
41165
|
-
if (this.savedCursor) {
|
|
41166
|
-
this.row = this.savedCursor.row;
|
|
41167
|
-
this.col = this.savedCursor.col;
|
|
41168
|
-
this.ensureRow();
|
|
41169
|
-
}
|
|
41170
|
-
return 2;
|
|
41171
|
-
}
|
|
41172
|
-
if (next === "]") {
|
|
41173
|
-
const bel = seq.indexOf("\x07", 2);
|
|
41174
|
-
const st = seq.indexOf("\x1B\\", 2);
|
|
41175
|
-
const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
|
|
41176
|
-
return end;
|
|
41177
|
-
}
|
|
41178
|
-
if (next === "[") {
|
|
41179
|
-
const match = seq.match(/^\x1B\[([0-?]*)([ -/]*)([@-~])/);
|
|
41180
|
-
if (!match) return seq.length < 32 ? 0 : 1;
|
|
41181
|
-
this.applyCsi(match[1] || "", match[3]);
|
|
41182
|
-
return match[0].length;
|
|
41183
|
-
}
|
|
41184
|
-
if (/[P^_X]/.test(next)) {
|
|
41185
|
-
const bel = seq.indexOf("\x07", 2);
|
|
41186
|
-
const st = seq.indexOf("\x1B\\", 2);
|
|
41187
|
-
const end = bel >= 0 && (st < 0 || bel < st) ? bel + 1 : st >= 0 ? st + 2 : 0;
|
|
41188
|
-
return end;
|
|
41189
|
-
}
|
|
41190
|
-
return 2;
|
|
41191
|
-
}
|
|
41192
|
-
applyCsi(params, final) {
|
|
41193
|
-
const count = parseCount(params);
|
|
41194
|
-
this.ensureRow();
|
|
41195
|
-
if (final === "A") this.row = Math.max(0, this.row - count);
|
|
41196
|
-
else if (final === "B") this.row += count;
|
|
41197
|
-
else if (final === "C") {
|
|
41198
|
-
const line = this.lines[this.row];
|
|
41199
|
-
for (let c = this.col; c < this.col + count; c += 1) {
|
|
41200
|
-
if (line[c] === void 0) line[c] = " ";
|
|
41201
|
-
}
|
|
41202
|
-
this.col += count;
|
|
41203
|
-
} else if (final === "D") this.col = Math.max(0, this.col - count);
|
|
41204
|
-
else if (final === "G") this.col = Math.max(0, count - 1);
|
|
41205
|
-
else if (final === "H" || final === "f") {
|
|
41206
|
-
const parts = String(params || "").split(";");
|
|
41207
|
-
this.row = Math.max(0, (Number(parts[0] || 1) || 1) - 1);
|
|
41208
|
-
this.col = Math.max(0, (Number(parts[1] || 1) || 1) - 1);
|
|
41209
|
-
} else if (final === "J") {
|
|
41210
|
-
const mode = Number(params || 0) || 0;
|
|
41211
|
-
if (mode === 2 || mode === 3) {
|
|
41212
|
-
this.lines = [[]];
|
|
41213
|
-
this.row = 0;
|
|
41214
|
-
this.col = 0;
|
|
41215
|
-
} else if (mode === 0) {
|
|
41216
|
-
this.lines[this.row] = this.lines[this.row].slice(0, this.col);
|
|
41217
|
-
this.lines.splice(this.row + 1);
|
|
41218
|
-
} else if (mode === 1) {
|
|
41219
|
-
for (let r = 0; r < this.row; r += 1) this.lines[r] = [];
|
|
41220
|
-
const line = this.lines[this.row];
|
|
41221
|
-
for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
|
|
41222
|
-
}
|
|
41223
|
-
} else if (final === "K") {
|
|
41224
|
-
const mode = Number(params || 0) || 0;
|
|
41225
|
-
const line = this.lines[this.row];
|
|
41226
|
-
if (mode === 2) this.lines[this.row] = [];
|
|
41227
|
-
else if (mode === 1) {
|
|
41228
|
-
for (let c = 0; c <= Math.min(this.col, line.length - 1); c += 1) line[c] = " ";
|
|
41229
|
-
} else {
|
|
41230
|
-
this.lines[this.row] = line.slice(0, this.col);
|
|
41231
|
-
}
|
|
41232
|
-
} else if (final === "s") {
|
|
41233
|
-
this.savedCursor = { row: this.row, col: this.col };
|
|
41234
|
-
} else if (final === "u") {
|
|
41235
|
-
if (this.savedCursor) {
|
|
41236
|
-
this.row = this.savedCursor.row;
|
|
41237
|
-
this.col = this.savedCursor.col;
|
|
41238
|
-
}
|
|
41239
|
-
}
|
|
41240
|
-
this.ensureRow();
|
|
41241
|
-
}
|
|
41242
|
-
};
|
|
41243
|
-
buildCliSpawnEnv = import_session_host_core32.sanitizeSpawnEnv;
|
|
41244
|
-
}
|
|
41245
|
-
});
|
|
41246
41275
|
function compile(re, flags) {
|
|
41247
41276
|
try {
|
|
41248
41277
|
return new RegExp(re, flags ?? "");
|
|
@@ -47207,14 +47236,14 @@ ${lastSnapshot}`;
|
|
|
47207
47236
|
init_git_worktree();
|
|
47208
47237
|
init_config();
|
|
47209
47238
|
var fs5 = __toESM2(require("fs"));
|
|
47210
|
-
var
|
|
47239
|
+
var os7 = __toESM2(require("os"));
|
|
47211
47240
|
var path52 = __toESM2(require("path"));
|
|
47212
47241
|
var import_crypto22 = require("crypto");
|
|
47213
47242
|
var MAX_WORKSPACES = 50;
|
|
47214
47243
|
function expandPath(p) {
|
|
47215
47244
|
const t = (p || "").trim();
|
|
47216
47245
|
if (!t) return "";
|
|
47217
|
-
if (t.startsWith("~")) return path52.join(
|
|
47246
|
+
if (t.startsWith("~")) return path52.join(os7.homedir(), t.slice(1).replace(/^\//, ""));
|
|
47218
47247
|
return path52.resolve(t);
|
|
47219
47248
|
}
|
|
47220
47249
|
function validateWorkspacePath(absPath) {
|
|
@@ -47287,7 +47316,7 @@ ${lastSnapshot}`;
|
|
|
47287
47316
|
};
|
|
47288
47317
|
}
|
|
47289
47318
|
if (a.useHome === true) {
|
|
47290
|
-
return { ok: true, path:
|
|
47319
|
+
return { ok: true, path: os7.homedir(), source: "home" };
|
|
47291
47320
|
}
|
|
47292
47321
|
return {
|
|
47293
47322
|
ok: false,
|
|
@@ -48831,7 +48860,7 @@ ${lastSnapshot}`;
|
|
|
48831
48860
|
var import_util3 = require("util");
|
|
48832
48861
|
var import_fs12 = require("fs");
|
|
48833
48862
|
var import_os22 = require("os");
|
|
48834
|
-
var
|
|
48863
|
+
var path12 = __toESM2(require("path"));
|
|
48835
48864
|
var execAsync2 = (0, import_util3.promisify)(import_child_process2.exec);
|
|
48836
48865
|
var BUILTIN_IDE_DEFINITIONS = [];
|
|
48837
48866
|
var registeredIDEs = /* @__PURE__ */ new Map();
|
|
@@ -48851,9 +48880,9 @@ ${lastSnapshot}`;
|
|
|
48851
48880
|
function findCliCommand(command) {
|
|
48852
48881
|
const trimmed = String(command || "").trim();
|
|
48853
48882
|
if (!trimmed) return null;
|
|
48854
|
-
if (
|
|
48855
|
-
const candidate = trimmed.startsWith("~") ?
|
|
48856
|
-
const resolved =
|
|
48883
|
+
if (path12.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
|
|
48884
|
+
const candidate = trimmed.startsWith("~") ? path12.join((0, import_os22.homedir)(), trimmed.slice(1)) : trimmed;
|
|
48885
|
+
const resolved = path12.isAbsolute(candidate) ? candidate : path12.resolve(candidate);
|
|
48857
48886
|
return (0, import_fs12.existsSync)(resolved) ? resolved : null;
|
|
48858
48887
|
}
|
|
48859
48888
|
const isWin = (0, import_os22.platform)() === "win32";
|
|
@@ -48862,7 +48891,7 @@ ${lastSnapshot}`;
|
|
|
48862
48891
|
for (const p of paths) {
|
|
48863
48892
|
if (!p) continue;
|
|
48864
48893
|
for (const ext of exes) {
|
|
48865
|
-
const fullPath =
|
|
48894
|
+
const fullPath = path12.join(p, trimmed + ext);
|
|
48866
48895
|
try {
|
|
48867
48896
|
if ((0, import_fs12.existsSync)(fullPath)) {
|
|
48868
48897
|
const stat2 = (0, import_fs12.statSync)(fullPath);
|
|
@@ -48890,7 +48919,7 @@ ${lastSnapshot}`;
|
|
|
48890
48919
|
function checkPathExists(paths) {
|
|
48891
48920
|
const home = (0, import_os22.homedir)();
|
|
48892
48921
|
for (const p of paths) {
|
|
48893
|
-
const normalized = p.startsWith("~") ?
|
|
48922
|
+
const normalized = p.startsWith("~") ? path12.join(home, p.slice(1)) : p;
|
|
48894
48923
|
if (normalized.includes("*")) {
|
|
48895
48924
|
const username = home.split(/[\\/]/).pop() || "";
|
|
48896
48925
|
const resolved = normalized.replace("*", username);
|
|
@@ -48913,8 +48942,8 @@ ${lastSnapshot}`;
|
|
|
48913
48942
|
if ((0, import_fs12.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
48914
48943
|
}
|
|
48915
48944
|
if (!resolvedCli && appPath && os30 === "win32") {
|
|
48916
|
-
const { dirname:
|
|
48917
|
-
const appDir =
|
|
48945
|
+
const { dirname: dirname16 } = await import("path");
|
|
48946
|
+
const appDir = dirname16(appPath);
|
|
48918
48947
|
const candidates = [
|
|
48919
48948
|
`${appDir}\\\\bin\\\\${def.cli}.cmd`,
|
|
48920
48949
|
`${appDir}\\\\bin\\\\${def.cli}`,
|
|
@@ -48945,14 +48974,14 @@ ${lastSnapshot}`;
|
|
|
48945
48974
|
return results;
|
|
48946
48975
|
}
|
|
48947
48976
|
init_cli_detector();
|
|
48948
|
-
var
|
|
48977
|
+
var os72 = __toESM2(require("os"));
|
|
48949
48978
|
var import_child_process3 = require("child_process");
|
|
48950
48979
|
var import_util22 = require("util");
|
|
48951
48980
|
var execAsync3 = (0, import_util22.promisify)(import_child_process3.exec);
|
|
48952
48981
|
var cachedDarwinAvail = null;
|
|
48953
48982
|
var darwinMemoryInterval = null;
|
|
48954
48983
|
async function updateDarwinMemoryCache() {
|
|
48955
|
-
if (
|
|
48984
|
+
if (os72.platform() !== "darwin") return;
|
|
48956
48985
|
try {
|
|
48957
48986
|
const { stdout } = await execAsync3("vm_stat", {
|
|
48958
48987
|
encoding: "utf-8",
|
|
@@ -48976,19 +49005,19 @@ ${lastSnapshot}`;
|
|
|
48976
49005
|
const fileBacked = counts["file_backed"] ?? 0;
|
|
48977
49006
|
const availPages = free + inactive + speculative + purgeable + fileBacked;
|
|
48978
49007
|
const bytes = availPages * pageSize;
|
|
48979
|
-
cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes,
|
|
49008
|
+
cachedDarwinAvail = Number.isFinite(bytes) && bytes >= 0 ? Math.min(bytes, os72.totalmem()) : null;
|
|
48980
49009
|
} catch {
|
|
48981
49010
|
}
|
|
48982
49011
|
}
|
|
48983
49012
|
function getHostMemorySnapshot() {
|
|
48984
|
-
if (
|
|
49013
|
+
if (os72.platform() === "darwin" && !darwinMemoryInterval) {
|
|
48985
49014
|
updateDarwinMemoryCache();
|
|
48986
49015
|
darwinMemoryInterval = setInterval(updateDarwinMemoryCache, 3e3);
|
|
48987
49016
|
darwinMemoryInterval.unref();
|
|
48988
49017
|
}
|
|
48989
|
-
const totalMem =
|
|
48990
|
-
const freeMem =
|
|
48991
|
-
const availableMem =
|
|
49018
|
+
const totalMem = os72.totalmem();
|
|
49019
|
+
const freeMem = os72.freemem();
|
|
49020
|
+
const availableMem = os72.platform() === "darwin" ? cachedDarwinAvail ?? freeMem : freeMem;
|
|
48992
49021
|
return {
|
|
48993
49022
|
totalMem,
|
|
48994
49023
|
freeMem,
|
|
@@ -51328,9 +51357,9 @@ ${cleanBody}`;
|
|
|
51328
51357
|
return cleanTitle || cleanBody;
|
|
51329
51358
|
}
|
|
51330
51359
|
var fs52 = __toESM2(require("fs"));
|
|
51331
|
-
var
|
|
51332
|
-
var
|
|
51333
|
-
var HISTORY_DIR =
|
|
51360
|
+
var path13 = __toESM2(require("path"));
|
|
51361
|
+
var os8 = __toESM2(require("os"));
|
|
51362
|
+
var HISTORY_DIR = path13.join(os8.homedir(), ".adhdev", "history");
|
|
51334
51363
|
var RETAIN_DAYS = 30;
|
|
51335
51364
|
var SAVED_HISTORY_INDEX_VERSION = 1;
|
|
51336
51365
|
var SAVED_HISTORY_INDEX_FILE = ".saved-history-index.json";
|
|
@@ -51516,7 +51545,7 @@ ${cleanBody}`;
|
|
|
51516
51545
|
function buildSavedHistoryFileSignatureMap(dir, files) {
|
|
51517
51546
|
return new Map(files.map((file2) => {
|
|
51518
51547
|
try {
|
|
51519
|
-
const stat2 = fs52.statSync(
|
|
51548
|
+
const stat2 = fs52.statSync(path13.join(dir, file2));
|
|
51520
51549
|
return [file2, `${file2}:${stat2.size}:${Math.trunc(stat2.mtimeMs)}`];
|
|
51521
51550
|
} catch {
|
|
51522
51551
|
return [file2, `${file2}:missing`];
|
|
@@ -51527,7 +51556,7 @@ ${cleanBody}`;
|
|
|
51527
51556
|
return files.map((file2) => fileSignatures.get(file2) || `${file2}:missing`).join("|");
|
|
51528
51557
|
}
|
|
51529
51558
|
function getSavedHistoryIndexFilePath(dir) {
|
|
51530
|
-
return
|
|
51559
|
+
return path13.join(dir, SAVED_HISTORY_INDEX_FILE);
|
|
51531
51560
|
}
|
|
51532
51561
|
function getSavedHistoryIndexLockPath(dir) {
|
|
51533
51562
|
return `${getSavedHistoryIndexFilePath(dir)}${SAVED_HISTORY_INDEX_LOCK_SUFFIX}`;
|
|
@@ -51629,7 +51658,7 @@ ${cleanBody}`;
|
|
|
51629
51658
|
}
|
|
51630
51659
|
for (const file2 of Array.from(currentEntries.keys())) {
|
|
51631
51660
|
if (incomingFiles.has(file2)) continue;
|
|
51632
|
-
if (!fs52.existsSync(
|
|
51661
|
+
if (!fs52.existsSync(path13.join(dir, file2))) {
|
|
51633
51662
|
currentEntries.delete(file2);
|
|
51634
51663
|
}
|
|
51635
51664
|
}
|
|
@@ -51655,7 +51684,7 @@ ${cleanBody}`;
|
|
|
51655
51684
|
const indexStat = fs52.statSync(getSavedHistoryIndexFilePath(dir));
|
|
51656
51685
|
const files = listHistoryFiles(dir);
|
|
51657
51686
|
for (const file2 of files) {
|
|
51658
|
-
const stat2 = fs52.statSync(
|
|
51687
|
+
const stat2 = fs52.statSync(path13.join(dir, file2));
|
|
51659
51688
|
if (stat2.mtimeMs > indexStat.mtimeMs) return true;
|
|
51660
51689
|
}
|
|
51661
51690
|
return false;
|
|
@@ -51665,14 +51694,14 @@ ${cleanBody}`;
|
|
|
51665
51694
|
}
|
|
51666
51695
|
function buildSavedHistoryFileSignature(dir, file2) {
|
|
51667
51696
|
try {
|
|
51668
|
-
const stat2 = fs52.statSync(
|
|
51697
|
+
const stat2 = fs52.statSync(path13.join(dir, file2));
|
|
51669
51698
|
return `${file2}:${stat2.size}:${Math.trunc(stat2.mtimeMs)}`;
|
|
51670
51699
|
} catch {
|
|
51671
51700
|
return `${file2}:missing`;
|
|
51672
51701
|
}
|
|
51673
51702
|
}
|
|
51674
51703
|
function persistSavedHistoryFileSummaryEntry(agentType, dir, file2, updater) {
|
|
51675
|
-
const filePath =
|
|
51704
|
+
const filePath = path13.join(dir, file2);
|
|
51676
51705
|
const result = withLockedPersistedSavedHistoryIndex(dir, (entries) => {
|
|
51677
51706
|
const currentEntry = entries.get(file2) || null;
|
|
51678
51707
|
const nextSummary = updater(currentEntry?.summary || null);
|
|
@@ -51745,7 +51774,7 @@ ${cleanBody}`;
|
|
|
51745
51774
|
function computeSavedHistoryFileSummary(dir, file2) {
|
|
51746
51775
|
const historySessionId = extractSavedHistorySessionIdFromFile(file2);
|
|
51747
51776
|
if (!historySessionId) return null;
|
|
51748
|
-
const filePath =
|
|
51777
|
+
const filePath = path13.join(dir, file2);
|
|
51749
51778
|
const content = fs52.readFileSync(filePath, "utf-8");
|
|
51750
51779
|
const lines = content.split("\n").filter(Boolean);
|
|
51751
51780
|
let messageCount = 0;
|
|
@@ -51832,7 +51861,7 @@ ${cleanBody}`;
|
|
|
51832
51861
|
const summaryBySessionId = /* @__PURE__ */ new Map();
|
|
51833
51862
|
const nextPersistedEntries = /* @__PURE__ */ new Map();
|
|
51834
51863
|
for (const file2 of files.slice().sort()) {
|
|
51835
|
-
const filePath =
|
|
51864
|
+
const filePath = path13.join(dir, file2);
|
|
51836
51865
|
const signature = fileSignatures.get(file2) || `${file2}:missing`;
|
|
51837
51866
|
const cached22 = savedHistoryFileSummaryCache.get(filePath);
|
|
51838
51867
|
const persisted = persistedEntries.get(file2);
|
|
@@ -51952,12 +51981,12 @@ ${cleanBody}`;
|
|
|
51952
51981
|
});
|
|
51953
51982
|
}
|
|
51954
51983
|
if (newMessages.length === 0) return;
|
|
51955
|
-
const dir =
|
|
51984
|
+
const dir = path13.join(HISTORY_DIR, this.sanitize(agentType));
|
|
51956
51985
|
fs52.mkdirSync(dir, { recursive: true });
|
|
51957
51986
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
51958
51987
|
const filePrefix = effectiveHistoryKey ? `${this.sanitize(effectiveHistoryKey)}_` : "";
|
|
51959
51988
|
const fileName = `${filePrefix}${date5}.jsonl`;
|
|
51960
|
-
const filePath =
|
|
51989
|
+
const filePath = path13.join(dir, fileName);
|
|
51961
51990
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
51962
51991
|
fs52.appendFileSync(filePath, lines, "utf-8");
|
|
51963
51992
|
updateSavedHistoryIndexForAppendedMessages(agentType, dir, fileName, effectiveHistoryKey, newMessages);
|
|
@@ -52048,11 +52077,11 @@ ${cleanBody}`;
|
|
|
52048
52077
|
const ws = String(workspace || "").trim();
|
|
52049
52078
|
if (!id || !ws) return;
|
|
52050
52079
|
try {
|
|
52051
|
-
const dir =
|
|
52080
|
+
const dir = path13.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52052
52081
|
fs52.mkdirSync(dir, { recursive: true });
|
|
52053
52082
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
52054
52083
|
const fileName = `${this.sanitize(id)}_${date5}.jsonl`;
|
|
52055
|
-
const filePath =
|
|
52084
|
+
const filePath = path13.join(dir, fileName);
|
|
52056
52085
|
const record2 = {
|
|
52057
52086
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
52058
52087
|
receivedAt: Date.now(),
|
|
@@ -52098,14 +52127,14 @@ ${cleanBody}`;
|
|
|
52098
52127
|
this.lastSeenCounts.set(toDedupKey, Math.max(fromCount, this.lastSeenCounts.get(toDedupKey) || 0));
|
|
52099
52128
|
this.lastSeenCounts.delete(fromDedupKey);
|
|
52100
52129
|
}
|
|
52101
|
-
const dir =
|
|
52130
|
+
const dir = path13.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52102
52131
|
if (!fs52.existsSync(dir)) return;
|
|
52103
52132
|
const fromPrefix = `${this.sanitize(fromId)}_`;
|
|
52104
52133
|
const toPrefix = `${this.sanitize(toId)}_`;
|
|
52105
52134
|
const files = fs52.readdirSync(dir).filter((file2) => file2.startsWith(fromPrefix) && file2.endsWith(".jsonl"));
|
|
52106
52135
|
for (const file2 of files) {
|
|
52107
|
-
const sourcePath =
|
|
52108
|
-
const targetPath =
|
|
52136
|
+
const sourcePath = path13.join(dir, file2);
|
|
52137
|
+
const targetPath = path13.join(dir, `${toPrefix}${file2.slice(fromPrefix.length)}`);
|
|
52109
52138
|
const sourceLines = fs52.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
52110
52139
|
const rewritten = sourceLines.map((line) => {
|
|
52111
52140
|
try {
|
|
@@ -52139,13 +52168,13 @@ ${cleanBody}`;
|
|
|
52139
52168
|
const sessionId = String(historySessionId || "").trim();
|
|
52140
52169
|
if (!sessionId) return;
|
|
52141
52170
|
try {
|
|
52142
|
-
const dir =
|
|
52171
|
+
const dir = path13.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52143
52172
|
if (!fs52.existsSync(dir)) return;
|
|
52144
52173
|
const prefix = `${this.sanitize(sessionId)}_`;
|
|
52145
52174
|
const files = fs52.readdirSync(dir).filter((file2) => file2.startsWith(prefix) && file2.endsWith(".jsonl")).sort();
|
|
52146
52175
|
const seen = /* @__PURE__ */ new Set();
|
|
52147
52176
|
for (const file2 of files) {
|
|
52148
|
-
const filePath =
|
|
52177
|
+
const filePath = path13.join(dir, file2);
|
|
52149
52178
|
const lines = fs52.readFileSync(filePath, "utf-8").split("\n").filter(Boolean);
|
|
52150
52179
|
const next = [];
|
|
52151
52180
|
for (const line of lines) {
|
|
@@ -52199,11 +52228,11 @@ ${cleanBody}`;
|
|
|
52199
52228
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
52200
52229
|
const agentDirs = fs52.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
52201
52230
|
for (const dir of agentDirs) {
|
|
52202
|
-
const dirPath =
|
|
52231
|
+
const dirPath = path13.join(HISTORY_DIR, dir.name);
|
|
52203
52232
|
const files = fs52.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
52204
52233
|
let removedAny = false;
|
|
52205
52234
|
for (const file2 of files) {
|
|
52206
|
-
const filePath =
|
|
52235
|
+
const filePath = path13.join(dirPath, file2);
|
|
52207
52236
|
const stat2 = fs52.statSync(filePath);
|
|
52208
52237
|
if (stat2.mtimeMs < cutoff) {
|
|
52209
52238
|
fs52.unlinkSync(filePath);
|
|
@@ -52406,7 +52435,7 @@ ${cleanBody}`;
|
|
|
52406
52435
|
const seen = /* @__PURE__ */ new Set();
|
|
52407
52436
|
let readAllFiles = true;
|
|
52408
52437
|
for (let f = 0; f < files.length; f++) {
|
|
52409
|
-
const filePath =
|
|
52438
|
+
const filePath = path13.join(dir, files[f]);
|
|
52410
52439
|
const remaining = Math.max(0, needed - collected.length);
|
|
52411
52440
|
const perFileNeeded = Math.min(needed, remaining + BOUNDED_TAIL_SLACK);
|
|
52412
52441
|
const { lines, coversWholeFile } = readFileTailLines(filePath, perFileNeeded);
|
|
@@ -52439,7 +52468,7 @@ ${cleanBody}`;
|
|
|
52439
52468
|
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
|
|
52440
52469
|
try {
|
|
52441
52470
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
52442
|
-
const dir =
|
|
52471
|
+
const dir = path13.join(HISTORY_DIR, sanitized);
|
|
52443
52472
|
if (!fs52.existsSync(dir)) return { messages: [], hasMore: false };
|
|
52444
52473
|
const files = listHistoryFiles(dir, historySessionId);
|
|
52445
52474
|
const bounded = isBoundedTailRequest(limit, offset, excludeRecentCount);
|
|
@@ -52462,7 +52491,7 @@ ${cleanBody}`;
|
|
|
52462
52491
|
const allMessages = [];
|
|
52463
52492
|
const seen = /* @__PURE__ */ new Set();
|
|
52464
52493
|
for (const file2 of files) {
|
|
52465
|
-
const filePath =
|
|
52494
|
+
const filePath = path13.join(dir, file2);
|
|
52466
52495
|
const content = fs52.readFileSync(filePath, "utf-8");
|
|
52467
52496
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
52468
52497
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -52486,7 +52515,7 @@ ${cleanBody}`;
|
|
|
52486
52515
|
function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
|
|
52487
52516
|
try {
|
|
52488
52517
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
52489
|
-
const dir =
|
|
52518
|
+
const dir = path13.join(HISTORY_DIR, sanitized);
|
|
52490
52519
|
if (!fs52.existsSync(dir)) {
|
|
52491
52520
|
savedHistorySessionCache.delete(sanitized);
|
|
52492
52521
|
return { sessions: [], hasMore: false };
|
|
@@ -52547,11 +52576,11 @@ ${cleanBody}`;
|
|
|
52547
52576
|
}
|
|
52548
52577
|
function readExistingSessionStartRecord(agentType, historySessionId) {
|
|
52549
52578
|
try {
|
|
52550
|
-
const dir =
|
|
52579
|
+
const dir = path13.join(HISTORY_DIR, agentType);
|
|
52551
52580
|
if (!fs52.existsSync(dir)) return null;
|
|
52552
52581
|
const files = listHistoryFiles(dir, historySessionId).sort();
|
|
52553
52582
|
for (const file2 of files) {
|
|
52554
|
-
const lines = fs52.readFileSync(
|
|
52583
|
+
const lines = fs52.readFileSync(path13.join(dir, file2), "utf-8").split("\n").filter(Boolean);
|
|
52555
52584
|
for (const line of lines) {
|
|
52556
52585
|
try {
|
|
52557
52586
|
const parsed = JSON.parse(line);
|
|
@@ -52571,16 +52600,16 @@ ${cleanBody}`;
|
|
|
52571
52600
|
function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
|
|
52572
52601
|
if (records.length === 0) return false;
|
|
52573
52602
|
try {
|
|
52574
|
-
const dir =
|
|
52603
|
+
const dir = path13.join(HISTORY_DIR, agentType);
|
|
52575
52604
|
fs52.mkdirSync(dir, { recursive: true });
|
|
52576
52605
|
const prefix = `${historySessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
|
|
52577
52606
|
for (const file2 of fs52.readdirSync(dir)) {
|
|
52578
52607
|
if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
|
|
52579
|
-
fs52.unlinkSync(
|
|
52608
|
+
fs52.unlinkSync(path13.join(dir, file2));
|
|
52580
52609
|
}
|
|
52581
52610
|
}
|
|
52582
52611
|
const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
|
|
52583
|
-
const filePath =
|
|
52612
|
+
const filePath = path13.join(dir, `${prefix}${targetDate}.jsonl`);
|
|
52584
52613
|
fs52.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
|
|
52585
52614
|
`, "utf-8");
|
|
52586
52615
|
invalidatePersistedSavedHistoryIndex(agentType, dir);
|
|
@@ -55133,8 +55162,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
55133
55162
|
return fn() || null;
|
|
55134
55163
|
}
|
|
55135
55164
|
var fs6 = __toESM2(require("fs"));
|
|
55136
|
-
var
|
|
55137
|
-
var
|
|
55165
|
+
var os9 = __toESM2(require("os"));
|
|
55166
|
+
var path14 = __toESM2(require("path"));
|
|
55138
55167
|
var import_node_crypto3 = require("crypto");
|
|
55139
55168
|
init_logger();
|
|
55140
55169
|
init_debug_config();
|
|
@@ -56173,7 +56202,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
56173
56202
|
function normalizeComparableWorkspace(value) {
|
|
56174
56203
|
const text = typeof value === "string" ? value.trim() : "";
|
|
56175
56204
|
if (!text) return "";
|
|
56176
|
-
return
|
|
56205
|
+
return path14.resolve(text);
|
|
56177
56206
|
}
|
|
56178
56207
|
function isCurrentRuntimePtySafelyAttributed(args) {
|
|
56179
56208
|
if (args.adapter.cliType !== "codex-cli") return false;
|
|
@@ -56658,7 +56687,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
56658
56687
|
}
|
|
56659
56688
|
function getChatDebugBundleDir() {
|
|
56660
56689
|
const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
|
|
56661
|
-
return override ||
|
|
56690
|
+
return override || path14.join(os9.homedir(), ".adhdev", "debug-bundles", "chat");
|
|
56662
56691
|
}
|
|
56663
56692
|
function safeBundleIdSegment(value, fallback) {
|
|
56664
56693
|
const normalized = String(value || fallback).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
@@ -56715,7 +56744,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
56715
56744
|
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
56716
56745
|
const dir = getChatDebugBundleDir();
|
|
56717
56746
|
fs6.mkdirSync(dir, { recursive: true });
|
|
56718
|
-
const savedPath =
|
|
56747
|
+
const savedPath = path14.join(dir, `${bundleId}.json`);
|
|
56719
56748
|
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
56720
56749
|
`;
|
|
56721
56750
|
fs6.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
@@ -58277,8 +58306,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
58277
58306
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
58278
58307
|
}
|
|
58279
58308
|
var fs7 = __toESM2(require("fs"));
|
|
58280
|
-
var
|
|
58281
|
-
var
|
|
58309
|
+
var path15 = __toESM2(require("path"));
|
|
58310
|
+
var os10 = __toESM2(require("os"));
|
|
58282
58311
|
var KEY_TO_VK = {
|
|
58283
58312
|
Backspace: 8,
|
|
58284
58313
|
Tab: 9,
|
|
@@ -58532,27 +58561,27 @@ ${effect.notification.body || ""}`.trim();
|
|
|
58532
58561
|
function resolveSafePath(requestedPath) {
|
|
58533
58562
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
58534
58563
|
const inputPath = rawPath || ".";
|
|
58535
|
-
const home =
|
|
58564
|
+
const home = os10.homedir();
|
|
58536
58565
|
if (inputPath.startsWith("~")) {
|
|
58537
|
-
return
|
|
58566
|
+
return path15.resolve(path15.join(home, inputPath.slice(1)));
|
|
58538
58567
|
}
|
|
58539
58568
|
if (process.platform === "win32") {
|
|
58540
58569
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
58541
|
-
if (
|
|
58542
|
-
return
|
|
58570
|
+
if (path15.win32.isAbsolute(normalized)) {
|
|
58571
|
+
return path15.win32.normalize(normalized);
|
|
58543
58572
|
}
|
|
58544
|
-
return
|
|
58573
|
+
return path15.win32.resolve(normalized);
|
|
58545
58574
|
}
|
|
58546
|
-
if (
|
|
58547
|
-
return
|
|
58575
|
+
if (path15.isAbsolute(inputPath)) {
|
|
58576
|
+
return path15.normalize(inputPath);
|
|
58548
58577
|
}
|
|
58549
|
-
return
|
|
58578
|
+
return path15.resolve(inputPath);
|
|
58550
58579
|
}
|
|
58551
58580
|
function listDirectoryEntriesSafe(dirPath) {
|
|
58552
58581
|
const entries = fs7.readdirSync(dirPath, { withFileTypes: true });
|
|
58553
58582
|
const files = [];
|
|
58554
58583
|
for (const entry of entries) {
|
|
58555
|
-
const entryPath =
|
|
58584
|
+
const entryPath = path15.join(dirPath, entry.name);
|
|
58556
58585
|
try {
|
|
58557
58586
|
if (entry.isDirectory()) {
|
|
58558
58587
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -58606,7 +58635,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
58606
58635
|
async function handleFileWrite(h, args) {
|
|
58607
58636
|
try {
|
|
58608
58637
|
const filePath = resolveSafePath(args?.path);
|
|
58609
|
-
fs7.mkdirSync(
|
|
58638
|
+
fs7.mkdirSync(path15.dirname(filePath), { recursive: true });
|
|
58610
58639
|
fs7.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
58611
58640
|
return { success: true, path: filePath };
|
|
58612
58641
|
} catch (e) {
|
|
@@ -78760,7 +78789,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78760
78789
|
};
|
|
78761
78790
|
}
|
|
78762
78791
|
const { existsSync: existsSync44, readFileSync: readFileSync35, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
78763
|
-
const { dirname:
|
|
78792
|
+
const { dirname: dirname16 } = await import("path");
|
|
78764
78793
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
78765
78794
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
78766
78795
|
let hermesBaseConfig = null;
|
|
@@ -78795,7 +78824,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78795
78824
|
};
|
|
78796
78825
|
}
|
|
78797
78826
|
try {
|
|
78798
|
-
mkdirSync21(
|
|
78827
|
+
mkdirSync21(dirname16(mcpConfigPath), { recursive: true });
|
|
78799
78828
|
} catch (error48) {
|
|
78800
78829
|
const message = `Could not prepare MCP config path for automatic setup: ${error48?.message || error48}`;
|
|
78801
78830
|
LOG2.error("MeshCoordinator", message);
|
|
@@ -78805,7 +78834,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78805
78834
|
const hadExistingMcpConfig = existsSync44(mcpConfigPath);
|
|
78806
78835
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
78807
78836
|
if (hermesBaseConfig) {
|
|
78808
|
-
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome,
|
|
78837
|
+
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname16(mcpConfigPath));
|
|
78809
78838
|
}
|
|
78810
78839
|
if (hadExistingMcpConfig) {
|
|
78811
78840
|
try {
|
|
@@ -78843,7 +78872,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78843
78872
|
const cliArgs = [];
|
|
78844
78873
|
const launchEnv = {};
|
|
78845
78874
|
if (configFormat === "hermes_config_yaml") {
|
|
78846
|
-
launchEnv.HERMES_HOME =
|
|
78875
|
+
launchEnv.HERMES_HOME = dirname16(mcpConfigPath);
|
|
78847
78876
|
launchEnv.HERMES_IGNORE_USER_CONFIG = "";
|
|
78848
78877
|
}
|
|
78849
78878
|
let autoImportContextFilePath;
|