@adhdev/daemon-standalone 1.0.58-rc.48 → 1.0.58-rc.49
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 +543 -444
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -36911,10 +36911,10 @@ var require_dist3 = __commonJS({
|
|
|
36911
36911
|
}
|
|
36912
36912
|
function getDaemonBuildInfo() {
|
|
36913
36913
|
if (cached2) return cached2;
|
|
36914
|
-
const commit = readInjected(true ? "
|
|
36915
|
-
const commitShort = readInjected(true ? "
|
|
36916
|
-
const version2 = readInjected(true ? "1.0.58-rc.
|
|
36917
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
36914
|
+
const commit = readInjected(true ? "292b03556e3572a379ade751d01258eb8d2b9cbe" : void 0) ?? "unknown";
|
|
36915
|
+
const commitShort = readInjected(true ? "292b0355" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36916
|
+
const version2 = readInjected(true ? "1.0.58-rc.49" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36917
|
+
const builtAt = readInjected(true ? "2026-08-30T10:52:00.096Z" : void 0);
|
|
36918
36918
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
36919
36919
|
return cached2;
|
|
36920
36920
|
}
|
|
@@ -42679,11 +42679,11 @@ child.on('exit', () => process.exit(0));
|
|
|
42679
42679
|
}
|
|
42680
42680
|
function windowsExtraBinDirs() {
|
|
42681
42681
|
const dirs = [];
|
|
42682
|
-
const
|
|
42682
|
+
const fs67 = require("fs");
|
|
42683
42683
|
const push = (dir) => {
|
|
42684
42684
|
if (!dir) return;
|
|
42685
42685
|
try {
|
|
42686
|
-
if (
|
|
42686
|
+
if (fs67.existsSync(dir)) dirs.push(dir);
|
|
42687
42687
|
} catch {
|
|
42688
42688
|
}
|
|
42689
42689
|
};
|
|
@@ -42699,12 +42699,12 @@ child.on('exit', () => process.exit(0));
|
|
|
42699
42699
|
}
|
|
42700
42700
|
function unixExtraBinDirs() {
|
|
42701
42701
|
const dirs = [];
|
|
42702
|
-
const
|
|
42702
|
+
const fs67 = require("fs");
|
|
42703
42703
|
const home = os9.homedir();
|
|
42704
42704
|
const push = (dir) => {
|
|
42705
42705
|
if (!dir) return;
|
|
42706
42706
|
try {
|
|
42707
|
-
if (
|
|
42707
|
+
if (fs67.existsSync(dir)) dirs.push(dir);
|
|
42708
42708
|
} catch {
|
|
42709
42709
|
}
|
|
42710
42710
|
};
|
|
@@ -42743,9 +42743,9 @@ child.on('exit', () => process.exit(0));
|
|
|
42743
42743
|
for (const ext of exes) {
|
|
42744
42744
|
const fullPath = path13.join(p, trimmed + ext);
|
|
42745
42745
|
try {
|
|
42746
|
-
const
|
|
42747
|
-
if (
|
|
42748
|
-
const stat2 =
|
|
42746
|
+
const fs67 = require("fs");
|
|
42747
|
+
if (fs67.existsSync(fullPath)) {
|
|
42748
|
+
const stat2 = fs67.statSync(fullPath);
|
|
42749
42749
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
42750
42750
|
return fullPath;
|
|
42751
42751
|
}
|
|
@@ -42759,12 +42759,12 @@ child.on('exit', () => process.exit(0));
|
|
|
42759
42759
|
function isScriptBinary(binaryPath) {
|
|
42760
42760
|
if (!path13.isAbsolute(binaryPath)) return false;
|
|
42761
42761
|
try {
|
|
42762
|
-
const
|
|
42763
|
-
const resolved =
|
|
42762
|
+
const fs67 = require("fs");
|
|
42763
|
+
const resolved = fs67.realpathSync(binaryPath);
|
|
42764
42764
|
const head = Buffer.alloc(8);
|
|
42765
|
-
const fd =
|
|
42766
|
-
|
|
42767
|
-
|
|
42765
|
+
const fd = fs67.openSync(resolved, "r");
|
|
42766
|
+
fs67.readSync(fd, head, 0, 8, 0);
|
|
42767
|
+
fs67.closeSync(fd);
|
|
42768
42768
|
let i = 0;
|
|
42769
42769
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
42770
42770
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -42775,12 +42775,12 @@ child.on('exit', () => process.exit(0));
|
|
|
42775
42775
|
function looksLikeMachOOrElf(filePath) {
|
|
42776
42776
|
if (!path13.isAbsolute(filePath)) return false;
|
|
42777
42777
|
try {
|
|
42778
|
-
const
|
|
42779
|
-
const resolved =
|
|
42778
|
+
const fs67 = require("fs");
|
|
42779
|
+
const resolved = fs67.realpathSync(filePath);
|
|
42780
42780
|
const buf = Buffer.alloc(8);
|
|
42781
|
-
const fd =
|
|
42782
|
-
|
|
42783
|
-
|
|
42781
|
+
const fd = fs67.openSync(resolved, "r");
|
|
42782
|
+
fs67.readSync(fd, buf, 0, 8, 0);
|
|
42783
|
+
fs67.closeSync(fd);
|
|
42784
42784
|
let i = 0;
|
|
42785
42785
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
42786
42786
|
const b = buf.subarray(i);
|
|
@@ -71276,8 +71276,8 @@ ${rendered}`, "utf-8");
|
|
|
71276
71276
|
if (!(0, import_node_fs3.existsSync)(filePath)) return;
|
|
71277
71277
|
if (owned) {
|
|
71278
71278
|
try {
|
|
71279
|
-
const
|
|
71280
|
-
|
|
71279
|
+
const fs67 = require("fs");
|
|
71280
|
+
fs67.unlinkSync(filePath);
|
|
71281
71281
|
} catch {
|
|
71282
71282
|
}
|
|
71283
71283
|
return;
|
|
@@ -71290,8 +71290,8 @@ ${rendered}`, "utf-8");
|
|
|
71290
71290
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
71291
71291
|
if (!remaining.trim()) {
|
|
71292
71292
|
try {
|
|
71293
|
-
const
|
|
71294
|
-
|
|
71293
|
+
const fs67 = require("fs");
|
|
71294
|
+
fs67.unlinkSync(filePath);
|
|
71295
71295
|
} catch {
|
|
71296
71296
|
}
|
|
71297
71297
|
} else {
|
|
@@ -77397,9 +77397,30 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
77397
77397
|
const cleaned = cleanupHistoryContent(agentType, message.role, message.content);
|
|
77398
77398
|
return `${message.kind || "standard"}:${message.role}:${normalizeHistoryComparable(cleaned)}`;
|
|
77399
77399
|
}
|
|
77400
|
-
function isAdjacentHistoryDuplicate(agentType, previous, next) {
|
|
77400
|
+
function isAdjacentHistoryDuplicate(agentType, previous, next, signatureFor = buildHistoryMessageSignature) {
|
|
77401
77401
|
if (!previous || !next) return false;
|
|
77402
|
-
return
|
|
77402
|
+
return signatureFor(agentType, previous) === signatureFor(agentType, next);
|
|
77403
|
+
}
|
|
77404
|
+
function dedupeAdjacentHistoryMessages(agentType, messages) {
|
|
77405
|
+
const deduped = [];
|
|
77406
|
+
let lastTurn = null;
|
|
77407
|
+
const signatureCache = /* @__PURE__ */ new WeakMap();
|
|
77408
|
+
const signatureFor = (currentAgentType, message) => {
|
|
77409
|
+
const key2 = message;
|
|
77410
|
+
const cached5 = signatureCache.get(key2);
|
|
77411
|
+
if (cached5 !== void 0) return cached5;
|
|
77412
|
+
const signature = buildHistoryMessageSignature(currentAgentType, message);
|
|
77413
|
+
signatureCache.set(key2, signature);
|
|
77414
|
+
return signature;
|
|
77415
|
+
};
|
|
77416
|
+
for (const message of messages) {
|
|
77417
|
+
const previous = deduped[deduped.length - 1];
|
|
77418
|
+
if (isAdjacentHistoryDuplicate(agentType, previous, message, signatureFor)) continue;
|
|
77419
|
+
if (message.role !== "system" && isAdjacentHistoryDuplicate(agentType, lastTurn, message, signatureFor)) continue;
|
|
77420
|
+
deduped.push(message);
|
|
77421
|
+
if (message.role !== "system") lastTurn = message;
|
|
77422
|
+
}
|
|
77423
|
+
return deduped;
|
|
77403
77424
|
}
|
|
77404
77425
|
function collapseReplayAssistantTurns(messages, historyBehavior) {
|
|
77405
77426
|
if (!historyBehavior?.collapseConsecutiveAssistantTurns) return messages;
|
|
@@ -77896,15 +77917,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
77896
77917
|
function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeRecentCount = 0, historyBehavior) {
|
|
77897
77918
|
const allMessages = records.map((message) => sanitizeHistoryMessage(agentType, message)).filter(Boolean);
|
|
77898
77919
|
allMessages.sort((a, b) => a.receivedAt - b.receivedAt);
|
|
77899
|
-
const chronological =
|
|
77900
|
-
let lastTurn = null;
|
|
77901
|
-
for (const message of allMessages) {
|
|
77902
|
-
const previous = chronological[chronological.length - 1];
|
|
77903
|
-
if (isAdjacentHistoryDuplicate(agentType, previous, message)) continue;
|
|
77904
|
-
if (message.role !== "system" && isAdjacentHistoryDuplicate(agentType, lastTurn, message)) continue;
|
|
77905
|
-
chronological.push(message);
|
|
77906
|
-
if (message.role !== "system") lastTurn = message;
|
|
77907
|
-
}
|
|
77920
|
+
const chronological = dedupeAdjacentHistoryMessages(agentType, allMessages);
|
|
77908
77921
|
const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
|
|
77909
77922
|
const boundedLimit = normalizePaginationNumber(limit, 30, 1);
|
|
77910
77923
|
const boundedOffset = normalizePaginationNumber(offset, 0, 0);
|
|
@@ -78847,15 +78860,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
78847
78860
|
next.push(sanitized);
|
|
78848
78861
|
}
|
|
78849
78862
|
next.sort((a, b) => a.receivedAt - b.receivedAt);
|
|
78850
|
-
const dedupedAdjacent =
|
|
78851
|
-
let lastTurn = null;
|
|
78852
|
-
for (const entry of next) {
|
|
78853
|
-
const previous = dedupedAdjacent[dedupedAdjacent.length - 1];
|
|
78854
|
-
if (isAdjacentHistoryDuplicate(agentType, previous, entry)) continue;
|
|
78855
|
-
if (entry.role !== "system" && isAdjacentHistoryDuplicate(agentType, lastTurn, entry)) continue;
|
|
78856
|
-
dedupedAdjacent.push(entry);
|
|
78857
|
-
if (entry.role !== "system") lastTurn = entry;
|
|
78858
|
-
}
|
|
78863
|
+
const dedupedAdjacent = dedupeAdjacentHistoryMessages(agentType, next);
|
|
78859
78864
|
const collapsed = collapseReplayAssistantTurns(dedupedAdjacent, historyBehavior);
|
|
78860
78865
|
if (collapsed.length === 0) {
|
|
78861
78866
|
fs17.unlinkSync(filePath);
|
|
@@ -89135,13 +89140,15 @@ ${cleanBody}`;
|
|
|
89135
89140
|
oversized: 0,
|
|
89136
89141
|
dropped: 0,
|
|
89137
89142
|
collectorUnavailable: 0,
|
|
89138
|
-
sourcePending: 0
|
|
89143
|
+
sourcePending: 0,
|
|
89144
|
+
ptyDirtyCoalesced: 0
|
|
89139
89145
|
};
|
|
89140
89146
|
}
|
|
89141
89147
|
function redactSessionId(id) {
|
|
89142
89148
|
return id.length <= 8 ? id : `${id.slice(0, 8)}\u2026(${id.length})`;
|
|
89143
89149
|
}
|
|
89144
89150
|
function configureTranscriptProjection(deps) {
|
|
89151
|
+
activeService?.dispose();
|
|
89145
89152
|
activeService = deps ? new TranscriptProjectionService(deps) : null;
|
|
89146
89153
|
return activeService;
|
|
89147
89154
|
}
|
|
@@ -89151,8 +89158,12 @@ ${cleanBody}`;
|
|
|
89151
89158
|
function markTranscriptSessionDirty(sessionId) {
|
|
89152
89159
|
activeService?.markDirty(sessionId);
|
|
89153
89160
|
}
|
|
89161
|
+
function markTranscriptPtyOutputActivity(sessionId) {
|
|
89162
|
+
activeService?.markPtyOutputActivity(sessionId);
|
|
89163
|
+
}
|
|
89154
89164
|
var import_node_crypto4;
|
|
89155
89165
|
var MAX_TRACKED_SESSIONS;
|
|
89166
|
+
var TRANSCRIPT_PTY_DIRTY_THROTTLE_MS;
|
|
89156
89167
|
var TranscriptProjectionService;
|
|
89157
89168
|
var activeService;
|
|
89158
89169
|
var init_transcript_publisher = __esm2({
|
|
@@ -89165,6 +89176,7 @@ ${cleanBody}`;
|
|
|
89165
89176
|
init_transcript_observation();
|
|
89166
89177
|
init_transcript_mode();
|
|
89167
89178
|
MAX_TRACKED_SESSIONS = 512;
|
|
89179
|
+
TRANSCRIPT_PTY_DIRTY_THROTTLE_MS = 350;
|
|
89168
89180
|
TranscriptProjectionService = class {
|
|
89169
89181
|
deps;
|
|
89170
89182
|
epoch;
|
|
@@ -89176,6 +89188,9 @@ ${cleanBody}`;
|
|
|
89176
89188
|
inFlight = /* @__PURE__ */ new Set();
|
|
89177
89189
|
pendingObservation = /* @__PURE__ */ new Map();
|
|
89178
89190
|
pendingPull = /* @__PURE__ */ new Set();
|
|
89191
|
+
/** PTY-only leading+trailing throttle state; direct dirty triggers bypass it. */
|
|
89192
|
+
ptyDirtyTimers = /* @__PURE__ */ new Map();
|
|
89193
|
+
ptyDirtyTrailing = /* @__PURE__ */ new Set();
|
|
89179
89194
|
constructor(deps) {
|
|
89180
89195
|
this.deps = deps;
|
|
89181
89196
|
this.epoch = deps.epoch ?? (0, import_node_crypto4.randomUUID)();
|
|
@@ -89209,6 +89224,41 @@ ${cleanBody}`;
|
|
|
89209
89224
|
if (!this.admitSession(sessionId)) return;
|
|
89210
89225
|
void this.runPull(sessionId);
|
|
89211
89226
|
}
|
|
89227
|
+
/**
|
|
89228
|
+
* PTY-output trigger. Pull the leading edge immediately, then collapse all
|
|
89229
|
+
* repaint chunks in the window into one trailing pull. The trailing pull is
|
|
89230
|
+
* mandatory even for a single byte because providers may append their JSONL
|
|
89231
|
+
* record just after writing the corresponding terminal output.
|
|
89232
|
+
*/
|
|
89233
|
+
markPtyOutputActivity(sessionId) {
|
|
89234
|
+
if (!sessionId) return;
|
|
89235
|
+
if (this.mode() === "off") return;
|
|
89236
|
+
if (!this.deps.collectObservation) {
|
|
89237
|
+
this.counters.collectorUnavailable++;
|
|
89238
|
+
return;
|
|
89239
|
+
}
|
|
89240
|
+
if (this.ptyDirtyTimers.has(sessionId)) {
|
|
89241
|
+
this.ptyDirtyTrailing.add(sessionId);
|
|
89242
|
+
this.counters.ptyDirtyCoalesced++;
|
|
89243
|
+
return;
|
|
89244
|
+
}
|
|
89245
|
+
this.markDirty(sessionId);
|
|
89246
|
+
this.ptyDirtyTrailing.add(sessionId);
|
|
89247
|
+
this.armPtyDirtyTimer(sessionId);
|
|
89248
|
+
}
|
|
89249
|
+
armPtyDirtyTimer(sessionId) {
|
|
89250
|
+
const timer = setTimeout(() => {
|
|
89251
|
+
if (!this.ptyDirtyTrailing.delete(sessionId)) {
|
|
89252
|
+
this.ptyDirtyTimers.delete(sessionId);
|
|
89253
|
+
return;
|
|
89254
|
+
}
|
|
89255
|
+
this.ptyDirtyTimers.delete(sessionId);
|
|
89256
|
+
this.armPtyDirtyTimer(sessionId);
|
|
89257
|
+
this.markDirty(sessionId);
|
|
89258
|
+
}, TRANSCRIPT_PTY_DIRTY_THROTTLE_MS);
|
|
89259
|
+
timer.unref?.();
|
|
89260
|
+
this.ptyDirtyTimers.set(sessionId, timer);
|
|
89261
|
+
}
|
|
89212
89262
|
/**
|
|
89213
89263
|
* Explicit alias for the restart/activation seed-read entry point (design
|
|
89214
89264
|
* §5.2: "activation 직후와 daemon restart 직후에는 해당 세션을 즉시
|
|
@@ -89316,6 +89366,12 @@ ${cleanBody}`;
|
|
|
89316
89366
|
get trackedSessionCount() {
|
|
89317
89367
|
return this.sessionState.size;
|
|
89318
89368
|
}
|
|
89369
|
+
/** Stop deferred PTY work when the singleton is replaced or disarmed. */
|
|
89370
|
+
dispose() {
|
|
89371
|
+
for (const timer of this.ptyDirtyTimers.values()) clearTimeout(timer);
|
|
89372
|
+
this.ptyDirtyTimers.clear();
|
|
89373
|
+
this.ptyDirtyTrailing.clear();
|
|
89374
|
+
}
|
|
89319
89375
|
};
|
|
89320
89376
|
activeService = null;
|
|
89321
89377
|
}
|
|
@@ -93416,8 +93472,8 @@ ${cleanBody}`;
|
|
|
93416
93472
|
let cwd = options.cwd;
|
|
93417
93473
|
if (cwd) {
|
|
93418
93474
|
try {
|
|
93419
|
-
const
|
|
93420
|
-
const stat2 =
|
|
93475
|
+
const fs67 = require("fs");
|
|
93476
|
+
const stat2 = fs67.statSync(cwd);
|
|
93421
93477
|
if (!stat2.isDirectory()) cwd = os19.homedir();
|
|
93422
93478
|
} catch {
|
|
93423
93479
|
cwd = os19.homedir();
|
|
@@ -95538,7 +95594,7 @@ ${tail}`;
|
|
|
95538
95594
|
}
|
|
95539
95595
|
function probeGitAncestry(cwd, ancestor, descendant) {
|
|
95540
95596
|
try {
|
|
95541
|
-
if (!
|
|
95597
|
+
if (!fs52.existsSync(cwd)) return "undeterminable";
|
|
95542
95598
|
} catch {
|
|
95543
95599
|
return "undeterminable";
|
|
95544
95600
|
}
|
|
@@ -95609,7 +95665,7 @@ ${tail}`;
|
|
|
95609
95665
|
};
|
|
95610
95666
|
if (present()) return true;
|
|
95611
95667
|
try {
|
|
95612
|
-
if (!
|
|
95668
|
+
if (!fs52.existsSync(submoduleRepoPath) || !fs52.existsSync(baseSubmoduleRepoPath)) return false;
|
|
95613
95669
|
} catch {
|
|
95614
95670
|
return false;
|
|
95615
95671
|
}
|
|
@@ -95751,7 +95807,7 @@ ${tail}`;
|
|
|
95751
95807
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
95752
95808
|
};
|
|
95753
95809
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
95754
|
-
if (!
|
|
95810
|
+
if (!fs52.existsSync(worktreeSubmodulePath)) return false;
|
|
95755
95811
|
try {
|
|
95756
95812
|
await runGit4(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
95757
95813
|
} catch {
|
|
@@ -95793,7 +95849,7 @@ ${tail}`;
|
|
|
95793
95849
|
};
|
|
95794
95850
|
let submoduleDefaultBranch = "main";
|
|
95795
95851
|
try {
|
|
95796
|
-
if (!
|
|
95852
|
+
if (!fs52.existsSync(submodulePath)) {
|
|
95797
95853
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
95798
95854
|
entry.publishRequired = true;
|
|
95799
95855
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -95958,7 +96014,7 @@ ${tail}`;
|
|
|
95958
96014
|
};
|
|
95959
96015
|
}
|
|
95960
96016
|
}
|
|
95961
|
-
var
|
|
96017
|
+
var fs52;
|
|
95962
96018
|
var import_node_child_process9;
|
|
95963
96019
|
var import_path18;
|
|
95964
96020
|
var GIT2;
|
|
@@ -95969,7 +96025,7 @@ ${tail}`;
|
|
|
95969
96025
|
var init_mesh_refine_gitlink_utils = __esm2({
|
|
95970
96026
|
"src/mesh/mesh-refine-gitlink-utils.ts"() {
|
|
95971
96027
|
"use strict";
|
|
95972
|
-
|
|
96028
|
+
fs52 = __toESM2(require("fs"));
|
|
95973
96029
|
import_node_child_process9 = require("child_process");
|
|
95974
96030
|
import_path18 = require("path");
|
|
95975
96031
|
init_logger();
|
|
@@ -96026,7 +96082,7 @@ ${tail}`;
|
|
|
96026
96082
|
if (!baseCommit || !branchCommit) return "undeterminable";
|
|
96027
96083
|
if (baseCommit === branchCommit) return "not_diverged";
|
|
96028
96084
|
try {
|
|
96029
|
-
if (!
|
|
96085
|
+
if (!fs53.existsSync(submoduleRepoPath)) return "undeterminable";
|
|
96030
96086
|
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
96031
96087
|
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
96032
96088
|
} catch {
|
|
@@ -96361,7 +96417,7 @@ ${tail}`;
|
|
|
96361
96417
|
}
|
|
96362
96418
|
return { ok: true, branchHead };
|
|
96363
96419
|
}
|
|
96364
|
-
var
|
|
96420
|
+
var fs53;
|
|
96365
96421
|
var import_path19;
|
|
96366
96422
|
var import_node_child_process10;
|
|
96367
96423
|
var SUBMODULE_PUBLISH_REQUIRED_RECOMMENDED_ACTION;
|
|
@@ -96369,7 +96425,7 @@ ${tail}`;
|
|
|
96369
96425
|
var init_mesh_refine_submodule_converge = __esm2({
|
|
96370
96426
|
"src/mesh/mesh-refine-submodule-converge.ts"() {
|
|
96371
96427
|
"use strict";
|
|
96372
|
-
|
|
96428
|
+
fs53 = __toESM2(require("fs"));
|
|
96373
96429
|
import_path19 = require("path");
|
|
96374
96430
|
import_node_child_process10 = require("child_process");
|
|
96375
96431
|
init_mesh_refine_gitlink_utils();
|
|
@@ -96385,12 +96441,12 @@ ${tail}`;
|
|
|
96385
96441
|
function writeValidationFailureLog(workspace, index, candidate, streams, now = () => /* @__PURE__ */ new Date()) {
|
|
96386
96442
|
try {
|
|
96387
96443
|
const dir = (0, import_path20.join)(workspace, REFINE_VALIDATION_LOG_DIR);
|
|
96388
|
-
|
|
96444
|
+
fs54.mkdirSync(dir, { recursive: true });
|
|
96389
96445
|
const stamp2 = now().toISOString().replace(/[:.]/g, "-");
|
|
96390
96446
|
const file2 = (0, import_path20.join)(dir, `refine-${stamp2}-${index}.log`);
|
|
96391
96447
|
const asText = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
96392
96448
|
const shown = candidate.displayCommand || [candidate.command, ...candidate.args || []].join(" ");
|
|
96393
|
-
|
|
96449
|
+
fs54.writeFileSync(
|
|
96394
96450
|
file2,
|
|
96395
96451
|
`# refine validation failure
|
|
96396
96452
|
# command: ${shown}
|
|
@@ -96987,7 +97043,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
96987
97043
|
return newTree || void 0;
|
|
96988
97044
|
} finally {
|
|
96989
97045
|
try {
|
|
96990
|
-
|
|
97046
|
+
fs54.rmSync(tmpIndex, { force: true });
|
|
96991
97047
|
} catch {
|
|
96992
97048
|
}
|
|
96993
97049
|
}
|
|
@@ -97062,7 +97118,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97062
97118
|
return newTree || void 0;
|
|
97063
97119
|
} finally {
|
|
97064
97120
|
try {
|
|
97065
|
-
|
|
97121
|
+
fs54.rmSync(tmpIndex, { force: true });
|
|
97066
97122
|
} catch {
|
|
97067
97123
|
}
|
|
97068
97124
|
}
|
|
@@ -97251,9 +97307,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97251
97307
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
97252
97308
|
};
|
|
97253
97309
|
const dependenciesLikelyMissing = (cwd) => {
|
|
97254
|
-
if (!
|
|
97255
|
-
if (
|
|
97256
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
97310
|
+
if (!fs54.existsSync((0, import_path20.join)(cwd, "package.json"))) return false;
|
|
97311
|
+
if (fs54.existsSync((0, import_path20.join)(cwd, "node_modules"))) return false;
|
|
97312
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs54.existsSync((0, import_path20.join)(cwd, lock)));
|
|
97257
97313
|
};
|
|
97258
97314
|
const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
|
|
97259
97315
|
const isDaemonScopedCommand = (candidate) => {
|
|
@@ -97423,7 +97479,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97423
97479
|
return summary;
|
|
97424
97480
|
}
|
|
97425
97481
|
var import_path20;
|
|
97426
|
-
var
|
|
97482
|
+
var fs54;
|
|
97427
97483
|
var import_node_child_process11;
|
|
97428
97484
|
var REFINE_VALIDATION_TIMEOUT_MS;
|
|
97429
97485
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES;
|
|
@@ -97435,7 +97491,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97435
97491
|
init_refine_config();
|
|
97436
97492
|
init_worktree_bootstrap_config();
|
|
97437
97493
|
import_path20 = require("path");
|
|
97438
|
-
|
|
97494
|
+
fs54 = __toESM2(require("fs"));
|
|
97439
97495
|
import_node_child_process11 = require("child_process");
|
|
97440
97496
|
init_resolve_executable();
|
|
97441
97497
|
init_mesh_refine_worker_cap();
|
|
@@ -112932,7 +112988,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
112932
112988
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
112933
112989
|
return { success: false, error: `unknown category: ${category}` };
|
|
112934
112990
|
}
|
|
112935
|
-
const
|
|
112991
|
+
const fs67 = require("fs");
|
|
112936
112992
|
const path64 = require("path");
|
|
112937
112993
|
try {
|
|
112938
112994
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -112941,9 +112997,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
112941
112997
|
if (!targetDir.startsWith(installRootResolved + path64.sep)) {
|
|
112942
112998
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
112943
112999
|
}
|
|
112944
|
-
const hadUpstreamDir =
|
|
113000
|
+
const hadUpstreamDir = fs67.existsSync(targetDir);
|
|
112945
113001
|
if (hadUpstreamDir) {
|
|
112946
|
-
|
|
113002
|
+
fs67.rmSync(targetDir, { recursive: true, force: true });
|
|
112947
113003
|
}
|
|
112948
113004
|
let channelDeactivated = false;
|
|
112949
113005
|
try {
|
|
@@ -112972,28 +113028,28 @@ ${effect.notification.body || ""}`.trim();
|
|
|
112972
113028
|
* the UI and by the update checker.
|
|
112973
113029
|
*/
|
|
112974
113030
|
handleListInstalledProviders(_args) {
|
|
112975
|
-
const
|
|
113031
|
+
const fs67 = require("fs");
|
|
112976
113032
|
const path64 = require("path");
|
|
112977
113033
|
const installRoot = this.getUpstreamInstallRoot();
|
|
112978
|
-
if (!
|
|
113034
|
+
if (!fs67.existsSync(installRoot)) return { success: true, providers: [] };
|
|
112979
113035
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
112980
113036
|
const items = [];
|
|
112981
113037
|
for (const category of CATEGORIES) {
|
|
112982
113038
|
const categoryDir = path64.join(installRoot, category);
|
|
112983
|
-
if (!
|
|
113039
|
+
if (!fs67.existsSync(categoryDir)) continue;
|
|
112984
113040
|
let entries;
|
|
112985
113041
|
try {
|
|
112986
|
-
entries =
|
|
113042
|
+
entries = fs67.readdirSync(categoryDir);
|
|
112987
113043
|
} catch {
|
|
112988
113044
|
continue;
|
|
112989
113045
|
}
|
|
112990
113046
|
for (const type2 of entries) {
|
|
112991
113047
|
const v1Path = path64.join(categoryDir, type2, "provider.v1.json");
|
|
112992
113048
|
const v0Path = path64.join(categoryDir, type2, "provider.json");
|
|
112993
|
-
const manifestPath =
|
|
113049
|
+
const manifestPath = fs67.existsSync(v1Path) ? v1Path : fs67.existsSync(v0Path) ? v0Path : null;
|
|
112994
113050
|
if (!manifestPath) continue;
|
|
112995
113051
|
try {
|
|
112996
|
-
const m = JSON.parse(
|
|
113052
|
+
const m = JSON.parse(fs67.readFileSync(manifestPath, "utf-8"));
|
|
112997
113053
|
const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
112998
113054
|
const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
112999
113055
|
items.push({
|
|
@@ -113259,7 +113315,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113259
113315
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
113260
113316
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
113261
113317
|
}
|
|
113262
|
-
const
|
|
113318
|
+
const fs67 = require("fs");
|
|
113263
113319
|
const path64 = require("path");
|
|
113264
113320
|
const { spawnSync: spawnSync3 } = require("child_process");
|
|
113265
113321
|
const file2 = ext.loadExternalSources();
|
|
@@ -113270,8 +113326,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113270
113326
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
113271
113327
|
}
|
|
113272
113328
|
const sourceDir = path64.join(ext.externalRoot(), requestedName);
|
|
113273
|
-
if (!
|
|
113274
|
-
if (
|
|
113329
|
+
if (!fs67.existsSync(ext.externalRoot())) fs67.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
113330
|
+
if (fs67.existsSync(sourceDir)) {
|
|
113275
113331
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
113276
113332
|
}
|
|
113277
113333
|
const clone2 = spawnSync3("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -113281,7 +113337,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113281
113337
|
});
|
|
113282
113338
|
if (clone2.status !== 0) {
|
|
113283
113339
|
try {
|
|
113284
|
-
|
|
113340
|
+
fs67.rmSync(sourceDir, { recursive: true, force: true });
|
|
113285
113341
|
} catch {
|
|
113286
113342
|
}
|
|
113287
113343
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -113325,15 +113381,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113325
113381
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
113326
113382
|
if (!name) return { success: false, error: "name is required" };
|
|
113327
113383
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
113328
|
-
const
|
|
113384
|
+
const fs67 = require("fs");
|
|
113329
113385
|
const path64 = require("path");
|
|
113330
113386
|
const file2 = ext.loadExternalSources();
|
|
113331
113387
|
const match = file2.sources.find((s2) => s2.name === name);
|
|
113332
113388
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
113333
113389
|
const sourceDir = path64.join(ext.externalRoot(), name);
|
|
113334
|
-
if (
|
|
113390
|
+
if (fs67.existsSync(sourceDir)) {
|
|
113335
113391
|
try {
|
|
113336
|
-
|
|
113392
|
+
fs67.rmSync(sourceDir, { recursive: true, force: true });
|
|
113337
113393
|
} catch (e) {
|
|
113338
113394
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
113339
113395
|
}
|
|
@@ -115978,14 +116034,14 @@ ${marker}`,
|
|
|
115978
116034
|
}
|
|
115979
116035
|
},
|
|
115980
116036
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
115981
|
-
const
|
|
116037
|
+
const fs67 = await import("fs");
|
|
115982
116038
|
const path64 = await import("path");
|
|
115983
116039
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
115984
116040
|
const dir = path64.join(getConfigDir22(), "coordinator-prompts");
|
|
115985
116041
|
const entries = {};
|
|
115986
116042
|
try {
|
|
115987
|
-
if (
|
|
115988
|
-
for (const name of
|
|
116043
|
+
if (fs67.existsSync(dir)) {
|
|
116044
|
+
for (const name of fs67.readdirSync(dir)) {
|
|
115989
116045
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
115990
116046
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
115991
116047
|
const m = matchAppend || matchOverride;
|
|
@@ -115995,7 +116051,7 @@ ${marker}`,
|
|
|
115995
116051
|
const full = path64.join(dir, name);
|
|
115996
116052
|
let content = "";
|
|
115997
116053
|
try {
|
|
115998
|
-
content =
|
|
116054
|
+
content = fs67.readFileSync(full, "utf8");
|
|
115999
116055
|
} catch {
|
|
116000
116056
|
}
|
|
116001
116057
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -116009,7 +116065,7 @@ ${marker}`,
|
|
|
116009
116065
|
return { success: true, dir, entries };
|
|
116010
116066
|
},
|
|
116011
116067
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
116012
|
-
const
|
|
116068
|
+
const fs67 = await import("fs");
|
|
116013
116069
|
const path64 = await import("path");
|
|
116014
116070
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
116015
116071
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -116022,11 +116078,11 @@ ${marker}`,
|
|
|
116022
116078
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
116023
116079
|
const full = path64.join(dir, filename);
|
|
116024
116080
|
try {
|
|
116025
|
-
|
|
116081
|
+
fs67.mkdirSync(dir, { recursive: true });
|
|
116026
116082
|
if (content.trim()) {
|
|
116027
|
-
|
|
116028
|
-
} else if (
|
|
116029
|
-
|
|
116083
|
+
fs67.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
116084
|
+
} else if (fs67.existsSync(full)) {
|
|
116085
|
+
fs67.unlinkSync(full);
|
|
116030
116086
|
}
|
|
116031
116087
|
return { success: true, path: full, kind, key: key2 };
|
|
116032
116088
|
} catch (error48) {
|
|
@@ -117073,7 +117129,7 @@ ${marker}`,
|
|
|
117073
117129
|
var import_fs22 = require("fs");
|
|
117074
117130
|
var import_child_process11 = require("child_process");
|
|
117075
117131
|
var import_chalk = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
117076
|
-
var
|
|
117132
|
+
var fs422 = __toESM2(require("fs"));
|
|
117077
117133
|
var path46 = __toESM2(require("path"));
|
|
117078
117134
|
var fs31 = __toESM2(require("fs"));
|
|
117079
117135
|
var os23 = __toESM2(require("os"));
|
|
@@ -118933,7 +118989,7 @@ ${marker}`,
|
|
|
118933
118989
|
return { start, end };
|
|
118934
118990
|
}
|
|
118935
118991
|
init_evaluator();
|
|
118936
|
-
var
|
|
118992
|
+
var fs33 = __toESM2(require("fs"));
|
|
118937
118993
|
var os24 = __toESM2(require("os"));
|
|
118938
118994
|
var path39 = __toESM2(require("path"));
|
|
118939
118995
|
init_logger();
|
|
@@ -118999,6 +119055,66 @@ ${marker}`,
|
|
|
118999
119055
|
}
|
|
119000
119056
|
}
|
|
119001
119057
|
}
|
|
119058
|
+
var fs322 = __toESM2(require("fs"));
|
|
119059
|
+
var PARSED_JSONL_CACHE_MAX_ENTRIES = 8;
|
|
119060
|
+
var PARSED_JSONL_CACHE_MAX_SOURCE_BYTES = 16 * 1024 * 1024;
|
|
119061
|
+
var parsedJsonlCache = /* @__PURE__ */ new Map();
|
|
119062
|
+
var parsedJsonlCacheSourceBytes = 0;
|
|
119063
|
+
var parsedJsonlCacheStats = { hits: 0, misses: 0, fileReads: 0, parsePasses: 0 };
|
|
119064
|
+
function parsedJsonlSignature(stat2) {
|
|
119065
|
+
return `${stat2.dev}:${stat2.ino}:${stat2.size}:${stat2.mtimeMs}:${stat2.ctimeMs}`;
|
|
119066
|
+
}
|
|
119067
|
+
function storeParsedJsonlCache(p, entry) {
|
|
119068
|
+
const prior = parsedJsonlCache.get(p);
|
|
119069
|
+
if (prior) parsedJsonlCacheSourceBytes -= prior.sourceBytes;
|
|
119070
|
+
parsedJsonlCache.delete(p);
|
|
119071
|
+
if (entry.sourceBytes > PARSED_JSONL_CACHE_MAX_SOURCE_BYTES) return;
|
|
119072
|
+
parsedJsonlCache.set(p, entry);
|
|
119073
|
+
parsedJsonlCacheSourceBytes += entry.sourceBytes;
|
|
119074
|
+
while (parsedJsonlCache.size > PARSED_JSONL_CACHE_MAX_ENTRIES || parsedJsonlCacheSourceBytes > PARSED_JSONL_CACHE_MAX_SOURCE_BYTES) {
|
|
119075
|
+
const oldestKey = parsedJsonlCache.keys().next().value;
|
|
119076
|
+
if (oldestKey === void 0) break;
|
|
119077
|
+
const oldest = parsedJsonlCache.get(oldestKey);
|
|
119078
|
+
if (oldest) parsedJsonlCacheSourceBytes -= oldest.sourceBytes;
|
|
119079
|
+
parsedJsonlCache.delete(oldestKey);
|
|
119080
|
+
}
|
|
119081
|
+
}
|
|
119082
|
+
function readJsonlLines(p, forceRefresh = false) {
|
|
119083
|
+
let stat2;
|
|
119084
|
+
try {
|
|
119085
|
+
stat2 = fs322.statSync(p);
|
|
119086
|
+
} catch {
|
|
119087
|
+
return [];
|
|
119088
|
+
}
|
|
119089
|
+
const signature = parsedJsonlSignature(stat2);
|
|
119090
|
+
const cached5 = parsedJsonlCache.get(p);
|
|
119091
|
+
if (!forceRefresh && cached5?.signature === signature) {
|
|
119092
|
+
parsedJsonlCacheStats.hits++;
|
|
119093
|
+
parsedJsonlCache.delete(p);
|
|
119094
|
+
parsedJsonlCache.set(p, cached5);
|
|
119095
|
+
return cached5.lines;
|
|
119096
|
+
}
|
|
119097
|
+
parsedJsonlCacheStats.misses++;
|
|
119098
|
+
let text;
|
|
119099
|
+
try {
|
|
119100
|
+
text = fs322.readFileSync(p, "utf8");
|
|
119101
|
+
parsedJsonlCacheStats.fileReads++;
|
|
119102
|
+
} catch {
|
|
119103
|
+
return [];
|
|
119104
|
+
}
|
|
119105
|
+
parsedJsonlCacheStats.parsePasses++;
|
|
119106
|
+
const out = [];
|
|
119107
|
+
for (const line of text.split("\n")) {
|
|
119108
|
+
const trimmed = line.trim();
|
|
119109
|
+
if (!trimmed) continue;
|
|
119110
|
+
try {
|
|
119111
|
+
out.push(JSON.parse(trimmed));
|
|
119112
|
+
} catch {
|
|
119113
|
+
}
|
|
119114
|
+
}
|
|
119115
|
+
storeParsedJsonlCache(p, { signature, sourceBytes: stat2.size, lines: out });
|
|
119116
|
+
return out;
|
|
119117
|
+
}
|
|
119002
119118
|
var UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
119003
119119
|
function executeNativeHistory(cfg, input) {
|
|
119004
119120
|
if (!cfg?.source) return null;
|
|
@@ -119148,14 +119264,15 @@ ${marker}`,
|
|
|
119148
119264
|
const wsRaw = typeof input.workspace === "string" ? input.workspace : "";
|
|
119149
119265
|
let wsReal = wsRaw;
|
|
119150
119266
|
try {
|
|
119151
|
-
if (wsRaw) wsReal =
|
|
119267
|
+
if (wsRaw) wsReal = fs33.realpathSync(wsRaw);
|
|
119152
119268
|
} catch {
|
|
119153
119269
|
}
|
|
119154
119270
|
LOG2.debug("NativeHistory", `jsonl unresolved: tried=${JSON.stringify(resolved)} sessionId=${requestedSessionId || "(none)"} wsRaw=${JSON.stringify(wsRaw)} wsReal=${JSON.stringify(wsReal)} rawSlug=${JSON.stringify(claudeProjectDirName(wsRaw))} realSlug=${JSON.stringify(claudeProjectDirName(wsReal))} (concrete miss + raw-slug retry + projects scan all failed)`);
|
|
119155
119271
|
return null;
|
|
119156
119272
|
}
|
|
119157
119273
|
const mtime = safeMtimeMs(sourcePath);
|
|
119158
|
-
const
|
|
119274
|
+
const forceRefresh = input.forceRefresh === true || input.args?.forceRefresh === true;
|
|
119275
|
+
const lines = readJsonlLines(sourcePath, forceRefresh);
|
|
119159
119276
|
if (lines.length === 0) return null;
|
|
119160
119277
|
const transcriptWorkspace = readSessionMetaWorkspace(lines) ?? (src.workspace_from_sidecar ? readSidecarWorkspace(sourcePath, src.workspace_from_sidecar) : void 0) ?? (src.workspace_from_input ? workspaceFromInputIfSlugMatches(sourcePath, input) : void 0);
|
|
119161
119278
|
let providerSessionId;
|
|
@@ -119290,7 +119407,7 @@ ${marker}`,
|
|
|
119290
119407
|
} else {
|
|
119291
119408
|
let stat2 = null;
|
|
119292
119409
|
try {
|
|
119293
|
-
stat2 =
|
|
119410
|
+
stat2 = fs33.statSync(resolved);
|
|
119294
119411
|
} catch {
|
|
119295
119412
|
}
|
|
119296
119413
|
if (stat2 && stat2.isFile()) {
|
|
@@ -119305,7 +119422,7 @@ ${marker}`,
|
|
|
119305
119422
|
const resolvedRaw = expandPath2(src.path, input, { skipWorkspaceRealpath: true });
|
|
119306
119423
|
if (resolvedRaw && resolvedRaw !== resolved) {
|
|
119307
119424
|
try {
|
|
119308
|
-
const rawStat =
|
|
119425
|
+
const rawStat = fs33.statSync(resolvedRaw);
|
|
119309
119426
|
if (rawStat.isFile()) sourcePath = resolvedRaw;
|
|
119310
119427
|
else if (rawStat.isDirectory()) {
|
|
119311
119428
|
sourcePath = pickExactSessionFile(resolvedRaw, filePat, requestedSessionId) || (requestedSessionId ? null : newestRecentFile(resolvedRaw, filePat, windowMs, sessionFloor));
|
|
@@ -119322,7 +119439,7 @@ ${marker}`,
|
|
|
119322
119439
|
}
|
|
119323
119440
|
function claimKeyForPath(p) {
|
|
119324
119441
|
try {
|
|
119325
|
-
return
|
|
119442
|
+
return fs33.realpathSync(p);
|
|
119326
119443
|
} catch {
|
|
119327
119444
|
return p;
|
|
119328
119445
|
}
|
|
@@ -119384,7 +119501,7 @@ ${marker}`,
|
|
|
119384
119501
|
function listSidecarWorkspaceCandidates(template, pattern, windowMs, sessionFloorMs, workspaceHint, sidecar) {
|
|
119385
119502
|
let wsResolved = workspaceHint;
|
|
119386
119503
|
try {
|
|
119387
|
-
wsResolved =
|
|
119504
|
+
wsResolved = fs33.realpathSync(workspaceHint);
|
|
119388
119505
|
} catch {
|
|
119389
119506
|
}
|
|
119390
119507
|
const dirs = expandDirGlob(template);
|
|
@@ -119398,7 +119515,7 @@ ${marker}`,
|
|
|
119398
119515
|
if (!ws) continue;
|
|
119399
119516
|
let wsReal = ws;
|
|
119400
119517
|
try {
|
|
119401
|
-
wsReal =
|
|
119518
|
+
wsReal = fs33.realpathSync(ws);
|
|
119402
119519
|
} catch {
|
|
119403
119520
|
}
|
|
119404
119521
|
if (ws !== workspaceHint && wsReal !== wsResolved) continue;
|
|
@@ -119419,7 +119536,7 @@ ${marker}`,
|
|
|
119419
119536
|
function readSidecarWorkspace(sourcePath, cfg) {
|
|
119420
119537
|
try {
|
|
119421
119538
|
const sidecar = path39.resolve(path39.dirname(sourcePath), cfg.rel_path);
|
|
119422
|
-
const parsed = JSON.parse(
|
|
119539
|
+
const parsed = JSON.parse(fs33.readFileSync(sidecar, "utf8"));
|
|
119423
119540
|
const v = jsonPathGet(parsed, cfg.workspace_path);
|
|
119424
119541
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
119425
119542
|
} catch {
|
|
@@ -119507,7 +119624,7 @@ ${marker}`,
|
|
|
119507
119624
|
if (!wsRaw) return void 0;
|
|
119508
119625
|
let wsReal = wsRaw;
|
|
119509
119626
|
try {
|
|
119510
|
-
wsReal =
|
|
119627
|
+
wsReal = fs33.realpathSync(wsRaw);
|
|
119511
119628
|
} catch {
|
|
119512
119629
|
}
|
|
119513
119630
|
const slugs = /* @__PURE__ */ new Set();
|
|
@@ -119535,27 +119652,9 @@ ${marker}`,
|
|
|
119535
119652
|
}
|
|
119536
119653
|
return void 0;
|
|
119537
119654
|
}
|
|
119538
|
-
function readJsonlLines(p) {
|
|
119539
|
-
let text;
|
|
119540
|
-
try {
|
|
119541
|
-
text = fs322.readFileSync(p, "utf8");
|
|
119542
|
-
} catch {
|
|
119543
|
-
return [];
|
|
119544
|
-
}
|
|
119545
|
-
const out = [];
|
|
119546
|
-
for (const line of text.split("\n")) {
|
|
119547
|
-
const trimmed = line.trim();
|
|
119548
|
-
if (!trimmed) continue;
|
|
119549
|
-
try {
|
|
119550
|
-
out.push(JSON.parse(trimmed));
|
|
119551
|
-
} catch {
|
|
119552
|
-
}
|
|
119553
|
-
}
|
|
119554
|
-
return out;
|
|
119555
|
-
}
|
|
119556
119655
|
function executeSqlite(src, input) {
|
|
119557
119656
|
const resolved = expandPath2(src.path, input);
|
|
119558
|
-
if (!resolved || !
|
|
119657
|
+
if (!resolved || !fs33.existsSync(resolved)) return null;
|
|
119559
119658
|
let Database;
|
|
119560
119659
|
try {
|
|
119561
119660
|
Database = loadBetterSqlite3();
|
|
@@ -119694,7 +119793,7 @@ ${marker}`,
|
|
|
119694
119793
|
let workspaceResolved = workspaceRaw;
|
|
119695
119794
|
if (workspaceRaw && !opts?.skipWorkspaceRealpath) {
|
|
119696
119795
|
try {
|
|
119697
|
-
workspaceResolved =
|
|
119796
|
+
workspaceResolved = fs33.realpathSync(workspaceRaw);
|
|
119698
119797
|
} catch {
|
|
119699
119798
|
}
|
|
119700
119799
|
}
|
|
@@ -119736,7 +119835,7 @@ ${marker}`,
|
|
|
119736
119835
|
if (!base) return null;
|
|
119737
119836
|
let baseStat = null;
|
|
119738
119837
|
try {
|
|
119739
|
-
baseStat =
|
|
119838
|
+
baseStat = fs33.statSync(base);
|
|
119740
119839
|
} catch {
|
|
119741
119840
|
return null;
|
|
119742
119841
|
}
|
|
@@ -119744,7 +119843,7 @@ ${marker}`,
|
|
|
119744
119843
|
const needle = `${requestedSessionId.toLowerCase()}.jsonl`;
|
|
119745
119844
|
const dirsToScan = [base];
|
|
119746
119845
|
try {
|
|
119747
|
-
for (const entry of
|
|
119846
|
+
for (const entry of fs33.readdirSync(base, { withFileTypes: true })) {
|
|
119748
119847
|
if (entry.isDirectory()) dirsToScan.push(path39.join(base, entry.name));
|
|
119749
119848
|
}
|
|
119750
119849
|
} catch {
|
|
@@ -119752,7 +119851,7 @@ ${marker}`,
|
|
|
119752
119851
|
for (const dir of dirsToScan) {
|
|
119753
119852
|
let entries;
|
|
119754
119853
|
try {
|
|
119755
|
-
entries =
|
|
119854
|
+
entries = fs33.readdirSync(dir, { withFileTypes: true });
|
|
119756
119855
|
} catch {
|
|
119757
119856
|
continue;
|
|
119758
119857
|
}
|
|
@@ -119792,7 +119891,7 @@ ${marker}`,
|
|
|
119792
119891
|
for (const d of dirs) {
|
|
119793
119892
|
let entries;
|
|
119794
119893
|
try {
|
|
119795
|
-
entries =
|
|
119894
|
+
entries = fs33.readdirSync(d, { withFileTypes: true });
|
|
119796
119895
|
} catch {
|
|
119797
119896
|
continue;
|
|
119798
119897
|
}
|
|
@@ -119805,7 +119904,7 @@ ${marker}`,
|
|
|
119805
119904
|
const candidate = path39.join(d, seg);
|
|
119806
119905
|
let stat2 = null;
|
|
119807
119906
|
try {
|
|
119808
|
-
stat2 =
|
|
119907
|
+
stat2 = fs33.statSync(candidate);
|
|
119809
119908
|
} catch {
|
|
119810
119909
|
continue;
|
|
119811
119910
|
}
|
|
@@ -119849,7 +119948,7 @@ ${marker}`,
|
|
|
119849
119948
|
function walkAllDirs(root, out) {
|
|
119850
119949
|
let entries;
|
|
119851
119950
|
try {
|
|
119852
|
-
entries =
|
|
119951
|
+
entries = fs33.readdirSync(root, { withFileTypes: true });
|
|
119853
119952
|
} catch {
|
|
119854
119953
|
return;
|
|
119855
119954
|
}
|
|
@@ -119865,7 +119964,7 @@ ${marker}`,
|
|
|
119865
119964
|
for (const d of dirs) {
|
|
119866
119965
|
let entries;
|
|
119867
119966
|
try {
|
|
119868
|
-
entries =
|
|
119967
|
+
entries = fs33.readdirSync(d, { withFileTypes: true });
|
|
119869
119968
|
} catch {
|
|
119870
119969
|
continue;
|
|
119871
119970
|
}
|
|
@@ -119892,7 +119991,7 @@ ${marker}`,
|
|
|
119892
119991
|
if (!resolved) continue;
|
|
119893
119992
|
let entries;
|
|
119894
119993
|
try {
|
|
119895
|
-
entries =
|
|
119994
|
+
entries = fs33.readdirSync(resolved, { withFileTypes: true });
|
|
119896
119995
|
} catch {
|
|
119897
119996
|
continue;
|
|
119898
119997
|
}
|
|
@@ -119921,7 +120020,7 @@ ${marker}`,
|
|
|
119921
120020
|
let workspaceResolved = workspaceRaw;
|
|
119922
120021
|
if (workspaceRaw) {
|
|
119923
120022
|
try {
|
|
119924
|
-
workspaceResolved =
|
|
120023
|
+
workspaceResolved = fs33.realpathSync(workspaceRaw);
|
|
119925
120024
|
} catch {
|
|
119926
120025
|
}
|
|
119927
120026
|
}
|
|
@@ -119946,7 +120045,7 @@ ${marker}`,
|
|
|
119946
120045
|
function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
|
|
119947
120046
|
let entries;
|
|
119948
120047
|
try {
|
|
119949
|
-
entries =
|
|
120048
|
+
entries = fs33.readdirSync(dir, { withFileTypes: true });
|
|
119950
120049
|
} catch {
|
|
119951
120050
|
return null;
|
|
119952
120051
|
}
|
|
@@ -119963,14 +120062,14 @@ ${marker}`,
|
|
|
119963
120062
|
}
|
|
119964
120063
|
function safeMtimeMs(p) {
|
|
119965
120064
|
try {
|
|
119966
|
-
return Math.floor(
|
|
120065
|
+
return Math.floor(fs33.statSync(p).mtimeMs);
|
|
119967
120066
|
} catch {
|
|
119968
120067
|
return 0;
|
|
119969
120068
|
}
|
|
119970
120069
|
}
|
|
119971
120070
|
function safeBirthtimeMs(p) {
|
|
119972
120071
|
try {
|
|
119973
|
-
const st =
|
|
120072
|
+
const st = fs33.statSync(p);
|
|
119974
120073
|
const birth = Math.floor(st.birthtimeMs);
|
|
119975
120074
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
119976
120075
|
} catch {
|
|
@@ -120031,10 +120130,10 @@ ${marker}`,
|
|
|
120031
120130
|
}
|
|
120032
120131
|
function readCandidateSessionMeta(filePath) {
|
|
120033
120132
|
try {
|
|
120034
|
-
const fd =
|
|
120133
|
+
const fd = fs33.openSync(filePath, "r");
|
|
120035
120134
|
try {
|
|
120036
120135
|
const buf = Buffer.alloc(8192);
|
|
120037
|
-
const bytes =
|
|
120136
|
+
const bytes = fs33.readSync(fd, buf, 0, buf.length, 0);
|
|
120038
120137
|
if (bytes <= 0) return null;
|
|
120039
120138
|
const text = buf.subarray(0, bytes).toString("utf8");
|
|
120040
120139
|
const nl = text.indexOf("\n");
|
|
@@ -120052,7 +120151,7 @@ ${marker}`,
|
|
|
120052
120151
|
sessionTimestampMs: Number.isFinite(tsMs) ? tsMs : void 0
|
|
120053
120152
|
};
|
|
120054
120153
|
} finally {
|
|
120055
|
-
|
|
120154
|
+
fs33.closeSync(fd);
|
|
120056
120155
|
}
|
|
120057
120156
|
} catch {
|
|
120058
120157
|
return null;
|
|
@@ -120062,7 +120161,7 @@ ${marker}`,
|
|
|
120062
120161
|
if (!sessionFloorMs || !workspaceHint || candidatePaths.length === 0) return null;
|
|
120063
120162
|
let workspaceResolved = workspaceHint;
|
|
120064
120163
|
try {
|
|
120065
|
-
workspaceResolved =
|
|
120164
|
+
workspaceResolved = fs33.realpathSync(workspaceHint);
|
|
120066
120165
|
} catch {
|
|
120067
120166
|
}
|
|
120068
120167
|
let best = null;
|
|
@@ -120071,7 +120170,7 @@ ${marker}`,
|
|
|
120071
120170
|
if (!meta3 || !meta3.cwd || meta3.sessionTimestampMs == null) continue;
|
|
120072
120171
|
let candidateCwd = meta3.cwd;
|
|
120073
120172
|
try {
|
|
120074
|
-
candidateCwd =
|
|
120173
|
+
candidateCwd = fs33.realpathSync(meta3.cwd);
|
|
120075
120174
|
} catch {
|
|
120076
120175
|
}
|
|
120077
120176
|
if (candidateCwd !== workspaceResolved && meta3.cwd !== workspaceHint) continue;
|
|
@@ -120084,7 +120183,7 @@ ${marker}`,
|
|
|
120084
120183
|
function listMatchingFiles(dir, pattern) {
|
|
120085
120184
|
let entries;
|
|
120086
120185
|
try {
|
|
120087
|
-
entries =
|
|
120186
|
+
entries = fs33.readdirSync(dir, { withFileTypes: true });
|
|
120088
120187
|
} catch {
|
|
120089
120188
|
return [];
|
|
120090
120189
|
}
|
|
@@ -120376,12 +120475,12 @@ ${marker}`,
|
|
|
120376
120475
|
}
|
|
120377
120476
|
return t.negate ? !result : result;
|
|
120378
120477
|
}
|
|
120379
|
-
var
|
|
120478
|
+
var fs40 = __toESM2(require("fs"));
|
|
120380
120479
|
init_logger();
|
|
120381
|
-
var
|
|
120480
|
+
var fs39 = __toESM2(require("fs"));
|
|
120382
120481
|
var os28 = __toESM2(require("os"));
|
|
120383
120482
|
var path45 = __toESM2(require("path"));
|
|
120384
|
-
var
|
|
120483
|
+
var fs34 = __toESM2(require("fs"));
|
|
120385
120484
|
var path40 = __toESM2(require("path"));
|
|
120386
120485
|
function extractTimestampValue(value) {
|
|
120387
120486
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
@@ -120395,7 +120494,7 @@ ${marker}`,
|
|
|
120395
120494
|
}
|
|
120396
120495
|
function statMtimeMs(filePath) {
|
|
120397
120496
|
try {
|
|
120398
|
-
return
|
|
120497
|
+
return fs34.statSync(filePath).mtimeMs;
|
|
120399
120498
|
} catch {
|
|
120400
120499
|
return 0;
|
|
120401
120500
|
}
|
|
@@ -120478,7 +120577,7 @@ ${marker}`,
|
|
|
120478
120577
|
function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
|
|
120479
120578
|
let raw;
|
|
120480
120579
|
try {
|
|
120481
|
-
raw =
|
|
120580
|
+
raw = fs34.readFileSync(filePath, "utf-8");
|
|
120482
120581
|
} catch {
|
|
120483
120582
|
return { messages: [], usageRecords: [] };
|
|
120484
120583
|
}
|
|
@@ -120564,7 +120663,7 @@ ${marker}`,
|
|
|
120564
120663
|
if (!sessionPath || !path40.isAbsolute(sessionPath)) return null;
|
|
120565
120664
|
const basename22 = path40.basename(sessionPath, ".jsonl");
|
|
120566
120665
|
if (!isSafeSessionId(basename22)) return null;
|
|
120567
|
-
if (!
|
|
120666
|
+
if (!fs34.existsSync(sessionPath)) return null;
|
|
120568
120667
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
120569
120668
|
const { messages, usageRecords } = parseTranscriptFile(sessionPath, basename22);
|
|
120570
120669
|
if (messages.length === 0) return null;
|
|
@@ -120587,7 +120686,7 @@ ${marker}`,
|
|
|
120587
120686
|
}
|
|
120588
120687
|
return session;
|
|
120589
120688
|
}
|
|
120590
|
-
var
|
|
120689
|
+
var fs35 = __toESM2(require("fs"));
|
|
120591
120690
|
var path41 = __toESM2(require("path"));
|
|
120592
120691
|
init_native_turn_signal();
|
|
120593
120692
|
var CODEX_DEFAULT_COMPLETION_SIGNAL = {
|
|
@@ -120608,7 +120707,7 @@ ${marker}`,
|
|
|
120608
120707
|
}
|
|
120609
120708
|
function statMtimeMs2(filePath) {
|
|
120610
120709
|
try {
|
|
120611
|
-
return
|
|
120710
|
+
return fs35.statSync(filePath).mtimeMs;
|
|
120612
120711
|
} catch {
|
|
120613
120712
|
return 0;
|
|
120614
120713
|
}
|
|
@@ -120724,7 +120823,7 @@ ${marker}`,
|
|
|
120724
120823
|
}
|
|
120725
120824
|
function readSessionMeta(filePath) {
|
|
120726
120825
|
try {
|
|
120727
|
-
const firstLine =
|
|
120826
|
+
const firstLine = fs35.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
|
|
120728
120827
|
if (!firstLine) return null;
|
|
120729
120828
|
const parsed = JSON.parse(firstLine);
|
|
120730
120829
|
if (String(parsed.type ?? "") !== "session_meta") return null;
|
|
@@ -120736,7 +120835,7 @@ ${marker}`,
|
|
|
120736
120835
|
function parseSessionFile(filePath, sessionId, workspaceFallback, completionSignal = CODEX_DEFAULT_COMPLETION_SIGNAL) {
|
|
120737
120836
|
let raw;
|
|
120738
120837
|
try {
|
|
120739
|
-
raw =
|
|
120838
|
+
raw = fs35.readFileSync(filePath, "utf-8");
|
|
120740
120839
|
} catch {
|
|
120741
120840
|
return { messages: [], usageRecords: [], turnTerminalMarkers: [] };
|
|
120742
120841
|
}
|
|
@@ -120872,7 +120971,7 @@ ${marker}`,
|
|
|
120872
120971
|
}
|
|
120873
120972
|
function readSession2(sessionPath, nativeHistory) {
|
|
120874
120973
|
if (!sessionPath || !path41.isAbsolute(sessionPath)) return null;
|
|
120875
|
-
if (!
|
|
120974
|
+
if (!fs35.existsSync(sessionPath)) return null;
|
|
120876
120975
|
const meta3 = readSessionMeta(sessionPath);
|
|
120877
120976
|
const metaId = String(meta3?.id ?? "").trim();
|
|
120878
120977
|
const basename22 = path41.basename(sessionPath, ".jsonl");
|
|
@@ -120911,7 +121010,7 @@ ${marker}`,
|
|
|
120911
121010
|
if (turnTerminalMarkers.length > 0) session.turnTerminalMarkers = turnTerminalMarkers;
|
|
120912
121011
|
return session;
|
|
120913
121012
|
}
|
|
120914
|
-
var
|
|
121013
|
+
var fs36 = __toESM2(require("fs"));
|
|
120915
121014
|
var path422 = __toESM2(require("path"));
|
|
120916
121015
|
var os25 = __toESM2(require("os"));
|
|
120917
121016
|
init_load_better_sqlite3();
|
|
@@ -120928,7 +121027,7 @@ ${marker}`,
|
|
|
120928
121027
|
}
|
|
120929
121028
|
function statMtimeMs3(filePath) {
|
|
120930
121029
|
try {
|
|
120931
|
-
return
|
|
121030
|
+
return fs36.statSync(filePath).mtimeMs;
|
|
120932
121031
|
} catch {
|
|
120933
121032
|
return 0;
|
|
120934
121033
|
}
|
|
@@ -120957,12 +121056,12 @@ ${marker}`,
|
|
|
120957
121056
|
function findBrainTranscriptPath(sessionId) {
|
|
120958
121057
|
if (!isUuidLike(sessionId)) return null;
|
|
120959
121058
|
const logsRoot = resolvePathInside(brainRoot(), sessionId, ".system_generated", "logs");
|
|
120960
|
-
if (!logsRoot || !
|
|
120961
|
-
const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null &&
|
|
121059
|
+
if (!logsRoot || !fs36.existsSync(logsRoot)) return null;
|
|
121060
|
+
const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null && fs36.existsSync(p));
|
|
120962
121061
|
if (candidates.length === 0) {
|
|
120963
121062
|
let entries = [];
|
|
120964
121063
|
try {
|
|
120965
|
-
entries =
|
|
121064
|
+
entries = fs36.readdirSync(logsRoot, { withFileTypes: true });
|
|
120966
121065
|
} catch {
|
|
120967
121066
|
return null;
|
|
120968
121067
|
}
|
|
@@ -120988,7 +121087,7 @@ ${marker}`,
|
|
|
120988
121087
|
function parseBrainTranscript(filePath, sessionId, workspace) {
|
|
120989
121088
|
let raw;
|
|
120990
121089
|
try {
|
|
120991
|
-
raw =
|
|
121090
|
+
raw = fs36.readFileSync(filePath, "utf-8");
|
|
120992
121091
|
} catch {
|
|
120993
121092
|
return null;
|
|
120994
121093
|
}
|
|
@@ -121048,7 +121147,7 @@ ${marker}`,
|
|
|
121048
121147
|
const sourcePath = historyJsonlPath();
|
|
121049
121148
|
let lines = [];
|
|
121050
121149
|
try {
|
|
121051
|
-
lines =
|
|
121150
|
+
lines = fs36.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
121052
121151
|
} catch {
|
|
121053
121152
|
return [];
|
|
121054
121153
|
}
|
|
@@ -121096,7 +121195,7 @@ ${marker}`,
|
|
|
121096
121195
|
function parsePbFile(filePath, sessionId) {
|
|
121097
121196
|
let buf;
|
|
121098
121197
|
try {
|
|
121099
|
-
buf =
|
|
121198
|
+
buf = fs36.readFileSync(filePath);
|
|
121100
121199
|
} catch {
|
|
121101
121200
|
return null;
|
|
121102
121201
|
}
|
|
@@ -121561,7 +121660,7 @@ ${marker}`,
|
|
|
121561
121660
|
}
|
|
121562
121661
|
}
|
|
121563
121662
|
const pbPath = resolvePathInside(conversationsRoot(), `${sessionId}.pb`);
|
|
121564
|
-
if (pbPath &&
|
|
121663
|
+
if (pbPath && fs36.existsSync(pbPath)) {
|
|
121565
121664
|
const pbMessages = parsePbFile(pbPath, sessionId);
|
|
121566
121665
|
if (pbMessages && pbMessages.length > 0) {
|
|
121567
121666
|
return {
|
|
@@ -121580,7 +121679,7 @@ ${marker}`,
|
|
|
121580
121679
|
}
|
|
121581
121680
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
121582
121681
|
if (!sessionPath || !path422.isAbsolute(sessionPath)) return null;
|
|
121583
|
-
if (!
|
|
121682
|
+
if (!fs36.existsSync(sessionPath)) return null;
|
|
121584
121683
|
const sourceMtimeMs = statMtimeMs3(sessionPath);
|
|
121585
121684
|
const brainRootPath = brainRoot();
|
|
121586
121685
|
if (sessionPath.startsWith(brainRootPath + path422.sep) && sessionPath.endsWith(".jsonl")) {
|
|
@@ -121639,7 +121738,7 @@ ${marker}`,
|
|
|
121639
121738
|
}
|
|
121640
121739
|
return null;
|
|
121641
121740
|
}
|
|
121642
|
-
var
|
|
121741
|
+
var fs37 = __toESM2(require("fs"));
|
|
121643
121742
|
var path43 = __toESM2(require("path"));
|
|
121644
121743
|
var os26 = __toESM2(require("os"));
|
|
121645
121744
|
init_load_better_sqlite3();
|
|
@@ -121647,13 +121746,13 @@ ${marker}`,
|
|
|
121647
121746
|
var HERMES_LEGACY_SESSIONS_DIR = path43.join(os26.homedir(), ".hermes", "sessions");
|
|
121648
121747
|
function statMtimeMs4(p) {
|
|
121649
121748
|
try {
|
|
121650
|
-
return Math.floor(
|
|
121749
|
+
return Math.floor(fs37.statSync(p).mtimeMs);
|
|
121651
121750
|
} catch {
|
|
121652
121751
|
return 0;
|
|
121653
121752
|
}
|
|
121654
121753
|
}
|
|
121655
121754
|
function openDb() {
|
|
121656
|
-
if (!
|
|
121755
|
+
if (!fs37.existsSync(HERMES_STATE_DB)) return null;
|
|
121657
121756
|
try {
|
|
121658
121757
|
const Database = loadBetterSqlite3();
|
|
121659
121758
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
@@ -121821,10 +121920,10 @@ ${marker}`,
|
|
|
121821
121920
|
}
|
|
121822
121921
|
}
|
|
121823
121922
|
}
|
|
121824
|
-
if (!path43.isAbsolute(sessionPath) || !
|
|
121923
|
+
if (!path43.isAbsolute(sessionPath) || !fs37.existsSync(sessionPath)) return null;
|
|
121825
121924
|
let raw;
|
|
121826
121925
|
try {
|
|
121827
|
-
raw = JSON.parse(
|
|
121926
|
+
raw = JSON.parse(fs37.readFileSync(sessionPath, "utf8"));
|
|
121828
121927
|
} catch {
|
|
121829
121928
|
return null;
|
|
121830
121929
|
}
|
|
@@ -121864,7 +121963,7 @@ ${marker}`,
|
|
|
121864
121963
|
if (s2 === "tool" || s2 === "tool_result" || s2 === "function") return "assistant";
|
|
121865
121964
|
return "system";
|
|
121866
121965
|
}
|
|
121867
|
-
var
|
|
121966
|
+
var fs38 = __toESM2(require("fs"));
|
|
121868
121967
|
var path44 = __toESM2(require("path"));
|
|
121869
121968
|
var os27 = __toESM2(require("os"));
|
|
121870
121969
|
function grokSessionsRoot() {
|
|
@@ -121876,7 +121975,7 @@ ${marker}`,
|
|
|
121876
121975
|
}
|
|
121877
121976
|
function statMtimeMs5(filePath) {
|
|
121878
121977
|
try {
|
|
121879
|
-
return
|
|
121978
|
+
return fs38.statSync(filePath).mtimeMs;
|
|
121880
121979
|
} catch {
|
|
121881
121980
|
return 0;
|
|
121882
121981
|
}
|
|
@@ -121887,7 +121986,7 @@ ${marker}`,
|
|
|
121887
121986
|
function workspaceCandidates(workspace) {
|
|
121888
121987
|
const out = [workspace];
|
|
121889
121988
|
try {
|
|
121890
|
-
const real =
|
|
121989
|
+
const real = fs38.realpathSync(workspace);
|
|
121891
121990
|
if (real && real !== workspace) out.push(real);
|
|
121892
121991
|
} catch {
|
|
121893
121992
|
}
|
|
@@ -121896,22 +121995,22 @@ ${marker}`,
|
|
|
121896
121995
|
function resolveGrokPath(workspace, sessionId) {
|
|
121897
121996
|
if (!sessionId || !isUuidLike2(sessionId)) return null;
|
|
121898
121997
|
const root = grokSessionsRoot();
|
|
121899
|
-
if (!
|
|
121998
|
+
if (!fs38.existsSync(root)) return null;
|
|
121900
121999
|
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
121901
122000
|
if (!candidate) continue;
|
|
121902
122001
|
const file2 = path44.join(root, encodeWorkspaceDir(candidate), sessionId, "chat_history.jsonl");
|
|
121903
|
-
if (
|
|
122002
|
+
if (fs38.existsSync(file2)) return file2;
|
|
121904
122003
|
}
|
|
121905
122004
|
let entries = [];
|
|
121906
122005
|
try {
|
|
121907
|
-
entries =
|
|
122006
|
+
entries = fs38.readdirSync(root, { withFileTypes: true });
|
|
121908
122007
|
} catch {
|
|
121909
122008
|
return null;
|
|
121910
122009
|
}
|
|
121911
122010
|
for (const entry of entries) {
|
|
121912
122011
|
if (!entry.isDirectory()) continue;
|
|
121913
122012
|
const file2 = path44.join(root, entry.name, sessionId, "chat_history.jsonl");
|
|
121914
|
-
if (
|
|
122013
|
+
if (fs38.existsSync(file2)) return file2;
|
|
121915
122014
|
}
|
|
121916
122015
|
return null;
|
|
121917
122016
|
}
|
|
@@ -121965,7 +122064,7 @@ ${marker}`,
|
|
|
121965
122064
|
}
|
|
121966
122065
|
function readSessionCreatedAtMs(sessionDir) {
|
|
121967
122066
|
try {
|
|
121968
|
-
const summary = JSON.parse(
|
|
122067
|
+
const summary = JSON.parse(fs38.readFileSync(path44.join(sessionDir, "summary.json"), "utf8"));
|
|
121969
122068
|
const created = summary?.created_at;
|
|
121970
122069
|
if (typeof created === "string") {
|
|
121971
122070
|
const parsed = Date.parse(created);
|
|
@@ -121978,7 +122077,7 @@ ${marker}`,
|
|
|
121978
122077
|
function readSession5(sourcePath, sessionId, workspace) {
|
|
121979
122078
|
let text;
|
|
121980
122079
|
try {
|
|
121981
|
-
text =
|
|
122080
|
+
text = fs38.readFileSync(sourcePath, "utf8");
|
|
121982
122081
|
} catch {
|
|
121983
122082
|
return null;
|
|
121984
122083
|
}
|
|
@@ -122028,26 +122127,26 @@ ${marker}`,
|
|
|
122028
122127
|
}
|
|
122029
122128
|
function listSessions(workspace, limit = 50) {
|
|
122030
122129
|
const root = grokSessionsRoot();
|
|
122031
|
-
if (!
|
|
122130
|
+
if (!fs38.existsSync(root)) return [];
|
|
122032
122131
|
const dirs = [];
|
|
122033
122132
|
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
122034
122133
|
if (!candidate) continue;
|
|
122035
122134
|
const dir = path44.join(root, encodeWorkspaceDir(candidate));
|
|
122036
|
-
if (
|
|
122135
|
+
if (fs38.existsSync(dir)) dirs.push(dir);
|
|
122037
122136
|
}
|
|
122038
122137
|
if (dirs.length === 0) return [];
|
|
122039
122138
|
const out = [];
|
|
122040
122139
|
for (const dir of dirs) {
|
|
122041
122140
|
let entries = [];
|
|
122042
122141
|
try {
|
|
122043
|
-
entries =
|
|
122142
|
+
entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
122044
122143
|
} catch {
|
|
122045
122144
|
continue;
|
|
122046
122145
|
}
|
|
122047
122146
|
for (const entry of entries) {
|
|
122048
122147
|
if (!entry.isDirectory() || !isUuidLike2(entry.name)) continue;
|
|
122049
122148
|
const sourcePath = path44.join(dir, entry.name, "chat_history.jsonl");
|
|
122050
|
-
if (!
|
|
122149
|
+
if (!fs38.existsSync(sourcePath)) continue;
|
|
122051
122150
|
const session = readSession5(sourcePath, entry.name, workspace);
|
|
122052
122151
|
if (!session || session.messages.length === 0) continue;
|
|
122053
122152
|
const first = session.messages[0];
|
|
@@ -122077,10 +122176,10 @@ ${marker}`,
|
|
|
122077
122176
|
}
|
|
122078
122177
|
function listSessionsAllWorkspaces(limit = 50) {
|
|
122079
122178
|
const root = grokSessionsRoot();
|
|
122080
|
-
if (!
|
|
122179
|
+
if (!fs38.existsSync(root)) return [];
|
|
122081
122180
|
let dirs = [];
|
|
122082
122181
|
try {
|
|
122083
|
-
dirs =
|
|
122182
|
+
dirs = fs38.readdirSync(root, { withFileTypes: true });
|
|
122084
122183
|
} catch {
|
|
122085
122184
|
return [];
|
|
122086
122185
|
}
|
|
@@ -122128,7 +122227,7 @@ ${marker}`,
|
|
|
122128
122227
|
const ownerConfirmed = reader === "antigravity-cli" ? resolved?.ownerConfirmed === true : void 0;
|
|
122129
122228
|
if (input.forceRefresh === true || input.args?.forceRefresh === true) {
|
|
122130
122229
|
try {
|
|
122131
|
-
|
|
122230
|
+
fs39.statSync(sourcePath);
|
|
122132
122231
|
} catch {
|
|
122133
122232
|
}
|
|
122134
122233
|
}
|
|
@@ -122193,10 +122292,10 @@ ${marker}`,
|
|
|
122193
122292
|
}
|
|
122194
122293
|
function resolveClaudePath(workspace, sessionId) {
|
|
122195
122294
|
const dir = path45.join(os28.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
122196
|
-
if (!
|
|
122295
|
+
if (!fs39.existsSync(dir)) return null;
|
|
122197
122296
|
if (sessionId) {
|
|
122198
122297
|
const candidate = path45.join(dir, `${sessionId}.jsonl`);
|
|
122199
|
-
if (
|
|
122298
|
+
if (fs39.existsSync(candidate)) return candidate;
|
|
122200
122299
|
}
|
|
122201
122300
|
return null;
|
|
122202
122301
|
}
|
|
@@ -122214,7 +122313,7 @@ ${marker}`,
|
|
|
122214
122313
|
if (key2) {
|
|
122215
122314
|
const pinned = codexRuntimeBindings.get(key2);
|
|
122216
122315
|
if (pinned) {
|
|
122217
|
-
if (
|
|
122316
|
+
if (fs39.existsSync(pinned)) return pinned;
|
|
122218
122317
|
codexRuntimeBindings.delete(key2);
|
|
122219
122318
|
}
|
|
122220
122319
|
}
|
|
@@ -122223,7 +122322,7 @@ ${marker}`,
|
|
|
122223
122322
|
return resolved;
|
|
122224
122323
|
}
|
|
122225
122324
|
function findCodexPathBySessionId(root, sessionId) {
|
|
122226
|
-
if (!
|
|
122325
|
+
if (!fs39.existsSync(root)) return null;
|
|
122227
122326
|
const needle = sessionId.toLowerCase();
|
|
122228
122327
|
const matches = [];
|
|
122229
122328
|
const stack = [root];
|
|
@@ -122231,7 +122330,7 @@ ${marker}`,
|
|
|
122231
122330
|
const current = stack.pop();
|
|
122232
122331
|
let entries = [];
|
|
122233
122332
|
try {
|
|
122234
|
-
entries =
|
|
122333
|
+
entries = fs39.readdirSync(current, { withFileTypes: true });
|
|
122235
122334
|
} catch {
|
|
122236
122335
|
continue;
|
|
122237
122336
|
}
|
|
@@ -122251,7 +122350,7 @@ ${marker}`,
|
|
|
122251
122350
|
return matches[0]?.p ?? null;
|
|
122252
122351
|
}
|
|
122253
122352
|
function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
|
|
122254
|
-
if (!
|
|
122353
|
+
if (!fs39.existsSync(root) || !workspace) return null;
|
|
122255
122354
|
const workspaceResolved = resolveRealPath(workspace);
|
|
122256
122355
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
122257
122356
|
const matches = [];
|
|
@@ -122260,7 +122359,7 @@ ${marker}`,
|
|
|
122260
122359
|
const current = stack.pop();
|
|
122261
122360
|
let entries = [];
|
|
122262
122361
|
try {
|
|
122263
|
-
entries =
|
|
122362
|
+
entries = fs39.readdirSync(current, { withFileTypes: true });
|
|
122264
122363
|
} catch {
|
|
122265
122364
|
continue;
|
|
122266
122365
|
}
|
|
@@ -122285,10 +122384,10 @@ ${marker}`,
|
|
|
122285
122384
|
}
|
|
122286
122385
|
function readCodexSessionMeta(filePath) {
|
|
122287
122386
|
try {
|
|
122288
|
-
const fd =
|
|
122387
|
+
const fd = fs39.openSync(filePath, "r");
|
|
122289
122388
|
try {
|
|
122290
122389
|
const buffer = Buffer.alloc(8192);
|
|
122291
|
-
const bytes =
|
|
122390
|
+
const bytes = fs39.readSync(fd, buffer, 0, buffer.length, 0);
|
|
122292
122391
|
if (bytes <= 0) return null;
|
|
122293
122392
|
const text = buffer.subarray(0, bytes).toString("utf8");
|
|
122294
122393
|
const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
|
|
@@ -122303,7 +122402,7 @@ ${marker}`,
|
|
|
122303
122402
|
timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
|
|
122304
122403
|
};
|
|
122305
122404
|
} finally {
|
|
122306
|
-
|
|
122405
|
+
fs39.closeSync(fd);
|
|
122307
122406
|
}
|
|
122308
122407
|
} catch {
|
|
122309
122408
|
return null;
|
|
@@ -122311,7 +122410,7 @@ ${marker}`,
|
|
|
122311
122410
|
}
|
|
122312
122411
|
function resolveRealPath(value) {
|
|
122313
122412
|
try {
|
|
122314
|
-
return
|
|
122413
|
+
return fs39.realpathSync(value);
|
|
122315
122414
|
} catch {
|
|
122316
122415
|
return value;
|
|
122317
122416
|
}
|
|
@@ -122333,19 +122432,19 @@ ${marker}`,
|
|
|
122333
122432
|
const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
|
|
122334
122433
|
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
122335
122434
|
const dbPath = path45.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
122336
|
-
if (
|
|
122435
|
+
if (fs39.existsSync(dbPath)) {
|
|
122337
122436
|
if (owner) claimAntigravityConversation(sessionId, owner);
|
|
122338
122437
|
return { path: dbPath, ownerConfirmed: true };
|
|
122339
122438
|
}
|
|
122340
122439
|
}
|
|
122341
122440
|
const brainRoot2 = path45.join(agyRoot, "brain");
|
|
122342
|
-
if (
|
|
122441
|
+
if (fs39.existsSync(brainRoot2)) {
|
|
122343
122442
|
const cutoff = spawnAwareCutoff(sessionStartedAtMs);
|
|
122344
122443
|
const nonEmptyBrain = (uuid3, p) => {
|
|
122345
122444
|
const t = path45.join(p, ".system_generated", "logs", "transcript.jsonl");
|
|
122346
|
-
return
|
|
122445
|
+
return fs39.existsSync(t) && safeSize(t) > 0 ? t : null;
|
|
122347
122446
|
};
|
|
122348
|
-
const all =
|
|
122447
|
+
const all = fs39.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
|
|
122349
122448
|
const p = path45.join(brainRoot2, e.name);
|
|
122350
122449
|
return { uuid: e.name, p, mtime: safeMtime(p), birth: safeBirthtime(p) };
|
|
122351
122450
|
}).filter((e) => e.mtime >= cutoff);
|
|
@@ -122376,7 +122475,7 @@ ${marker}`,
|
|
|
122376
122475
|
function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
|
|
122377
122476
|
let entries = [];
|
|
122378
122477
|
try {
|
|
122379
|
-
entries =
|
|
122478
|
+
entries = fs39.readdirSync(convRoot, { withFileTypes: true });
|
|
122380
122479
|
} catch {
|
|
122381
122480
|
return null;
|
|
122382
122481
|
}
|
|
@@ -122414,9 +122513,9 @@ ${marker}`,
|
|
|
122414
122513
|
void workspace;
|
|
122415
122514
|
void sessionId;
|
|
122416
122515
|
const dbPath = path45.join(os28.homedir(), ".hermes", "state.db");
|
|
122417
|
-
if (
|
|
122516
|
+
if (fs39.existsSync(dbPath)) return dbPath;
|
|
122418
122517
|
const dir = path45.join(os28.homedir(), ".hermes", "sessions");
|
|
122419
|
-
if (!
|
|
122518
|
+
if (!fs39.existsSync(dir)) return null;
|
|
122420
122519
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
122421
122520
|
}
|
|
122422
122521
|
function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
|
|
@@ -122455,7 +122554,7 @@ ${marker}`,
|
|
|
122455
122554
|
function newestRecentFile2(dir, pattern) {
|
|
122456
122555
|
try {
|
|
122457
122556
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
122458
|
-
const entries =
|
|
122557
|
+
const entries = fs39.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path45.join(dir, e.name), mtime: safeMtime(path45.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
122459
122558
|
return entries[0]?.p ?? null;
|
|
122460
122559
|
} catch {
|
|
122461
122560
|
return null;
|
|
@@ -122463,14 +122562,14 @@ ${marker}`,
|
|
|
122463
122562
|
}
|
|
122464
122563
|
function safeMtime(p) {
|
|
122465
122564
|
try {
|
|
122466
|
-
return Math.floor(
|
|
122565
|
+
return Math.floor(fs39.statSync(p).mtimeMs);
|
|
122467
122566
|
} catch {
|
|
122468
122567
|
return 0;
|
|
122469
122568
|
}
|
|
122470
122569
|
}
|
|
122471
122570
|
function safeBirthtime(p) {
|
|
122472
122571
|
try {
|
|
122473
|
-
const st =
|
|
122572
|
+
const st = fs39.statSync(p);
|
|
122474
122573
|
const birth = Math.floor(st.birthtimeMs);
|
|
122475
122574
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
122476
122575
|
} catch {
|
|
@@ -122479,7 +122578,7 @@ ${marker}`,
|
|
|
122479
122578
|
}
|
|
122480
122579
|
function safeSize(p) {
|
|
122481
122580
|
try {
|
|
122482
|
-
return
|
|
122581
|
+
return fs39.statSync(p).size;
|
|
122483
122582
|
} catch {
|
|
122484
122583
|
return 0;
|
|
122485
122584
|
}
|
|
@@ -122775,19 +122874,19 @@ ${marker}`,
|
|
|
122775
122874
|
return attrs;
|
|
122776
122875
|
}
|
|
122777
122876
|
function readTailJsonlLines(filePath, maxBytes) {
|
|
122778
|
-
const stat2 =
|
|
122877
|
+
const stat2 = fs40.statSync(filePath);
|
|
122779
122878
|
const size = stat2.size;
|
|
122780
122879
|
const start = size > maxBytes ? size - maxBytes : 0;
|
|
122781
122880
|
const length = size - start;
|
|
122782
122881
|
if (length <= 0) return [];
|
|
122783
|
-
const fd =
|
|
122882
|
+
const fd = fs40.openSync(filePath, "r");
|
|
122784
122883
|
let text;
|
|
122785
122884
|
try {
|
|
122786
122885
|
const buf = Buffer.alloc(length);
|
|
122787
|
-
const bytes =
|
|
122886
|
+
const bytes = fs40.readSync(fd, buf, 0, length, start);
|
|
122788
122887
|
text = buf.subarray(0, bytes).toString("utf8");
|
|
122789
122888
|
} finally {
|
|
122790
|
-
|
|
122889
|
+
fs40.closeSync(fd);
|
|
122791
122890
|
}
|
|
122792
122891
|
const rawLines = text.split("\n");
|
|
122793
122892
|
if (start > 0 && rawLines.length > 0) rawLines.shift();
|
|
@@ -122896,7 +122995,7 @@ ${text}` : text;
|
|
|
122896
122995
|
}
|
|
122897
122996
|
return messages.filter((m) => typeof m.content === "string" && m.content.trim().length > 0);
|
|
122898
122997
|
}
|
|
122899
|
-
var
|
|
122998
|
+
var fs41 = __toESM2(require("fs"));
|
|
122900
122999
|
var import_node_crypto6 = require("crypto");
|
|
122901
123000
|
init_provider_cli_shared();
|
|
122902
123001
|
init_logger();
|
|
@@ -123253,7 +123352,7 @@ ${text}` : text;
|
|
|
123253
123352
|
* (claude-cli specs/4.0.json), which previously stubbed the method to false. */
|
|
123254
123353
|
lastApprovalResolvedAt = 0;
|
|
123255
123354
|
constructor(specPath, workingDir, cliArgs, extraEnv, transportFactory, sessionId, manifestTuning) {
|
|
123256
|
-
const raw = JSON.parse(
|
|
123355
|
+
const raw = JSON.parse(fs41.readFileSync(specPath, "utf8"));
|
|
123257
123356
|
this.spec = {
|
|
123258
123357
|
id: raw.id,
|
|
123259
123358
|
name: raw.name,
|
|
@@ -124619,10 +124718,10 @@ ${text}` : text;
|
|
|
124619
124718
|
function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory, sessionId, removeArgs) {
|
|
124620
124719
|
const resolvedSpecPath = provider._resolvedSpecPath;
|
|
124621
124720
|
const dir = provider._resolvedProviderDir;
|
|
124622
|
-
let specPath = resolvedSpecPath &&
|
|
124721
|
+
let specPath = resolvedSpecPath && fs422.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
|
|
124623
124722
|
if (!specPath && dir) {
|
|
124624
124723
|
const legacy = path46.join(dir, "spec.json");
|
|
124625
|
-
if (
|
|
124724
|
+
if (fs422.existsSync(legacy)) specPath = legacy;
|
|
124626
124725
|
}
|
|
124627
124726
|
if (!specPath) {
|
|
124628
124727
|
throw new Error(formatNoResolvableSpecError(provider.type, dir));
|
|
@@ -124724,7 +124823,7 @@ ${text}` : text;
|
|
|
124724
124823
|
init_summary_metadata();
|
|
124725
124824
|
var os30 = __toESM2(require("os"));
|
|
124726
124825
|
var crypto6 = __toESM2(require("crypto"));
|
|
124727
|
-
var
|
|
124826
|
+
var fs46 = __toESM2(require("fs"));
|
|
124728
124827
|
function shouldUseBracketedPasteForEnvelope(input) {
|
|
124729
124828
|
return input.parts.some((part) => part.type === "image");
|
|
124730
124829
|
}
|
|
@@ -124979,7 +125078,7 @@ ${text}` : text;
|
|
|
124979
125078
|
var os29 = __toESM2(require("os"));
|
|
124980
125079
|
var path47 = __toESM2(require("path"));
|
|
124981
125080
|
var crypto5 = __toESM2(require("crypto"));
|
|
124982
|
-
var
|
|
125081
|
+
var fs43 = __toESM2(require("fs"));
|
|
124983
125082
|
var IMAGE_MIME_EXTENSIONS = {
|
|
124984
125083
|
"image/png": ".png",
|
|
124985
125084
|
"image/jpeg": ".jpg",
|
|
@@ -125014,9 +125113,9 @@ ${text}` : text;
|
|
|
125014
125113
|
if (!part.data) return null;
|
|
125015
125114
|
const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
|
|
125016
125115
|
if (!rawData) return null;
|
|
125017
|
-
|
|
125116
|
+
fs43.mkdirSync(dir, { recursive: true });
|
|
125018
125117
|
const filePath = path47.join(dir, safeInputImageBasename(index, part.mimeType));
|
|
125019
|
-
|
|
125118
|
+
fs43.writeFileSync(filePath, Buffer.from(rawData, "base64"));
|
|
125020
125119
|
cleanupStaleMaterializedImages(dir);
|
|
125021
125120
|
return filePath;
|
|
125022
125121
|
}
|
|
@@ -125028,14 +125127,14 @@ ${text}` : text;
|
|
|
125028
125127
|
if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
|
|
125029
125128
|
lastMaterializedImageCleanupAt = now;
|
|
125030
125129
|
try {
|
|
125031
|
-
const entries =
|
|
125130
|
+
const entries = fs43.readdirSync(dir);
|
|
125032
125131
|
for (const entry of entries) {
|
|
125033
125132
|
if (!entry.startsWith("adhdev-input-image-")) continue;
|
|
125034
125133
|
const fullPath = path47.join(dir, entry);
|
|
125035
125134
|
try {
|
|
125036
|
-
const stat2 =
|
|
125135
|
+
const stat2 = fs43.statSync(fullPath);
|
|
125037
125136
|
if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
|
|
125038
|
-
|
|
125137
|
+
fs43.unlinkSync(fullPath);
|
|
125039
125138
|
}
|
|
125040
125139
|
} catch {
|
|
125041
125140
|
}
|
|
@@ -125491,7 +125590,7 @@ ${text}` : text;
|
|
|
125491
125590
|
if (missingEvidence) return { action: "suppress", missingEvidence };
|
|
125492
125591
|
return { action: "inline_fire", missingEvidence: false };
|
|
125493
125592
|
}
|
|
125494
|
-
var
|
|
125593
|
+
var fs44 = __toESM2(require("fs"));
|
|
125495
125594
|
function createSqliteProbeCache() {
|
|
125496
125595
|
return { db: null, dbPath: null, missingUntil: 0 };
|
|
125497
125596
|
}
|
|
@@ -125511,7 +125610,7 @@ ${text}` : text;
|
|
|
125511
125610
|
};
|
|
125512
125611
|
addDir(workingDir);
|
|
125513
125612
|
try {
|
|
125514
|
-
addDir(
|
|
125613
|
+
addDir(fs44.realpathSync.native(workingDir));
|
|
125515
125614
|
} catch {
|
|
125516
125615
|
}
|
|
125517
125616
|
return Array.from(dirs);
|
|
@@ -125925,7 +126024,7 @@ ${buttons.join("\n")}`;
|
|
|
125925
126024
|
}
|
|
125926
126025
|
return adapterStatus;
|
|
125927
126026
|
}
|
|
125928
|
-
var
|
|
126027
|
+
var fs45 = __toESM2(require("fs"));
|
|
125929
126028
|
init_contracts2();
|
|
125930
126029
|
init_chat_message_normalization();
|
|
125931
126030
|
init_chat_history();
|
|
@@ -126129,7 +126228,7 @@ ${buttons.join("\n")}`;
|
|
|
126129
126228
|
}
|
|
126130
126229
|
if (host.lastExternalCompletionProbe?.sourcePath) {
|
|
126131
126230
|
try {
|
|
126132
|
-
|
|
126231
|
+
fs45.statSync(host.lastExternalCompletionProbe.sourcePath);
|
|
126133
126232
|
} catch {
|
|
126134
126233
|
}
|
|
126135
126234
|
}
|
|
@@ -127445,7 +127544,7 @@ ${buttons.join("\n")}`;
|
|
|
127445
127544
|
const resolvedDbPath = probe.dbPath.replace(/^~/, os30.homedir());
|
|
127446
127545
|
const now = Date.now();
|
|
127447
127546
|
if (this.sqliteProbeCache.missingUntil > now) return null;
|
|
127448
|
-
if (!
|
|
127547
|
+
if (!fs46.existsSync(resolvedDbPath)) {
|
|
127449
127548
|
this.sqliteProbeCache.missingUntil = now + 1e4;
|
|
127450
127549
|
return null;
|
|
127451
127550
|
}
|
|
@@ -132849,7 +132948,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
132849
132948
|
var net3 = __toESM2(require("net"));
|
|
132850
132949
|
var os322 = __toESM2(require("os"));
|
|
132851
132950
|
var path56 = __toESM2(require("path"));
|
|
132852
|
-
var
|
|
132951
|
+
var fs51 = __toESM2(require("fs"));
|
|
132853
132952
|
var path55 = __toESM2(require("path"));
|
|
132854
132953
|
var chokidar = __toESM2(require_chokidar());
|
|
132855
132954
|
init_logger();
|
|
@@ -133350,7 +133449,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133350
133449
|
init_contract();
|
|
133351
133450
|
init_track_identity();
|
|
133352
133451
|
init_config_dir();
|
|
133353
|
-
var
|
|
133452
|
+
var fs47 = __toESM2(require("fs"));
|
|
133354
133453
|
var path51 = __toESM2(require("path"));
|
|
133355
133454
|
var crypto8 = __toESM2(require("crypto"));
|
|
133356
133455
|
init_config();
|
|
@@ -133386,13 +133485,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133386
133485
|
/** Create a fresh staging directory. Caller must clean it up (or gc will). */
|
|
133387
133486
|
createStagingDir(kind) {
|
|
133388
133487
|
const dir = path51.join(this.stagingDir, `${kind}-${process.pid}-${crypto8.randomBytes(6).toString("hex")}`);
|
|
133389
|
-
|
|
133488
|
+
fs47.mkdirSync(dir, { recursive: true });
|
|
133390
133489
|
return dir;
|
|
133391
133490
|
}
|
|
133392
133491
|
removeStagingDir(dir) {
|
|
133393
133492
|
if (!dir.startsWith(this.stagingDir + path51.sep)) return;
|
|
133394
133493
|
try {
|
|
133395
|
-
|
|
133494
|
+
fs47.rmSync(dir, { recursive: true, force: true });
|
|
133396
133495
|
} catch {
|
|
133397
133496
|
}
|
|
133398
133497
|
}
|
|
@@ -133408,7 +133507,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133408
133507
|
}
|
|
133409
133508
|
hasObject(digest) {
|
|
133410
133509
|
try {
|
|
133411
|
-
return
|
|
133510
|
+
return fs47.statSync(this.getObjectDir(digest)).isDirectory();
|
|
133412
133511
|
} catch {
|
|
133413
133512
|
return false;
|
|
133414
133513
|
}
|
|
@@ -133426,8 +133525,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133426
133525
|
this.removeStagingDir(stagedObjectDir);
|
|
133427
133526
|
return objectDir;
|
|
133428
133527
|
}
|
|
133429
|
-
|
|
133430
|
-
|
|
133528
|
+
fs47.mkdirSync(this.objectsDir, { recursive: true });
|
|
133529
|
+
fs47.renameSync(stagedObjectDir, objectDir);
|
|
133431
133530
|
return objectDir;
|
|
133432
133531
|
}
|
|
133433
133532
|
// ─── Pointers ────────────────────────────────────────────
|
|
@@ -133439,10 +133538,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133439
133538
|
*/
|
|
133440
133539
|
getPointer(channel, providerType) {
|
|
133441
133540
|
const file2 = this.pointerPath(channel, providerType);
|
|
133442
|
-
if (!
|
|
133541
|
+
if (!fs47.existsSync(file2)) return null;
|
|
133443
133542
|
let parsed;
|
|
133444
133543
|
try {
|
|
133445
|
-
parsed = JSON.parse(
|
|
133544
|
+
parsed = JSON.parse(fs47.readFileSync(file2, "utf-8"));
|
|
133446
133545
|
} catch (e) {
|
|
133447
133546
|
throw new ProviderChannelError(
|
|
133448
133547
|
"STORE_CORRUPT",
|
|
@@ -133470,7 +133569,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133470
133569
|
const dir = this.activeDir(channel);
|
|
133471
133570
|
let files = [];
|
|
133472
133571
|
try {
|
|
133473
|
-
files =
|
|
133572
|
+
files = fs47.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
133474
133573
|
} catch {
|
|
133475
133574
|
return { pointers, errors };
|
|
133476
133575
|
}
|
|
@@ -133491,7 +133590,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133491
133590
|
const activations = [];
|
|
133492
133591
|
for (const pointer of pointers.values()) {
|
|
133493
133592
|
const objectDir = this.getObjectDir(pointer.active.digest);
|
|
133494
|
-
if (!
|
|
133593
|
+
if (!fs47.existsSync(objectDir)) {
|
|
133495
133594
|
errors.push(new ProviderChannelError(
|
|
133496
133595
|
"STORE_CORRUPT",
|
|
133497
133596
|
`active object ${pointer.active.digest} for "${pointer.active.providerType}" is missing \u2014 skipping (fail closed)`,
|
|
@@ -133560,9 +133659,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133560
133659
|
/** Remove an activation pointer (e.g. provider uninstalled). */
|
|
133561
133660
|
removePointer(channel, providerType) {
|
|
133562
133661
|
const file2 = this.pointerPath(channel, providerType);
|
|
133563
|
-
if (!
|
|
133662
|
+
if (!fs47.existsSync(file2)) return false;
|
|
133564
133663
|
try {
|
|
133565
|
-
|
|
133664
|
+
fs47.rmSync(file2, { force: true });
|
|
133566
133665
|
return true;
|
|
133567
133666
|
} catch {
|
|
133568
133667
|
return false;
|
|
@@ -133570,11 +133669,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133570
133669
|
}
|
|
133571
133670
|
writePointerAtomic(channel, providerType, pointer) {
|
|
133572
133671
|
const dir = this.activeDir(channel);
|
|
133573
|
-
|
|
133672
|
+
fs47.mkdirSync(dir, { recursive: true });
|
|
133574
133673
|
const file2 = this.pointerPath(channel, providerType);
|
|
133575
133674
|
const tmp = path51.join(dir, `.${providerType}.${process.pid}.${crypto8.randomBytes(4).toString("hex")}.tmp`);
|
|
133576
|
-
|
|
133577
|
-
|
|
133675
|
+
fs47.writeFileSync(tmp, JSON.stringify(pointer, null, 2), "utf-8");
|
|
133676
|
+
fs47.renameSync(tmp, file2);
|
|
133578
133677
|
}
|
|
133579
133678
|
// ─── GC (N=2 retention) ──────────────────────────────────
|
|
133580
133679
|
/**
|
|
@@ -133590,13 +133689,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133590
133689
|
const dir = this.activeDir(channel);
|
|
133591
133690
|
let files = [];
|
|
133592
133691
|
try {
|
|
133593
|
-
files =
|
|
133692
|
+
files = fs47.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
133594
133693
|
} catch {
|
|
133595
133694
|
continue;
|
|
133596
133695
|
}
|
|
133597
133696
|
for (const file2 of files) {
|
|
133598
133697
|
try {
|
|
133599
|
-
const parsed = JSON.parse(
|
|
133698
|
+
const parsed = JSON.parse(fs47.readFileSync(path51.join(dir, file2), "utf-8"));
|
|
133600
133699
|
if (typeof parsed?.active?.digest === "string") referenced.add(parsed.active.digest);
|
|
133601
133700
|
if (typeof parsed?.previous?.digest === "string") referenced.add(parsed.previous.digest);
|
|
133602
133701
|
} catch {
|
|
@@ -133606,7 +133705,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133606
133705
|
const removedObjects = [];
|
|
133607
133706
|
let objectNames = [];
|
|
133608
133707
|
try {
|
|
133609
|
-
objectNames =
|
|
133708
|
+
objectNames = fs47.readdirSync(this.objectsDir);
|
|
133610
133709
|
} catch {
|
|
133611
133710
|
objectNames = [];
|
|
133612
133711
|
}
|
|
@@ -133614,7 +133713,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133614
133713
|
const digest = `sha256:${name}`;
|
|
133615
133714
|
if (referenced.has(digest)) continue;
|
|
133616
133715
|
try {
|
|
133617
|
-
|
|
133716
|
+
fs47.rmSync(path51.join(this.objectsDir, name), { recursive: true, force: true });
|
|
133618
133717
|
removedObjects.push(digest);
|
|
133619
133718
|
} catch {
|
|
133620
133719
|
}
|
|
@@ -133622,13 +133721,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133622
133721
|
let removedStaging = 0;
|
|
133623
133722
|
let stagingEntries = [];
|
|
133624
133723
|
try {
|
|
133625
|
-
stagingEntries =
|
|
133724
|
+
stagingEntries = fs47.readdirSync(this.stagingDir);
|
|
133626
133725
|
} catch {
|
|
133627
133726
|
stagingEntries = [];
|
|
133628
133727
|
}
|
|
133629
133728
|
for (const name of stagingEntries) {
|
|
133630
133729
|
try {
|
|
133631
|
-
|
|
133730
|
+
fs47.rmSync(path51.join(this.stagingDir, name), { recursive: true, force: true });
|
|
133632
133731
|
removedStaging++;
|
|
133633
133732
|
} catch {
|
|
133634
133733
|
}
|
|
@@ -133639,10 +133738,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133639
133738
|
return { removedObjects, removedStaging };
|
|
133640
133739
|
}
|
|
133641
133740
|
};
|
|
133642
|
-
var
|
|
133741
|
+
var fs50 = __toESM2(require("fs"));
|
|
133643
133742
|
var path53 = __toESM2(require("path"));
|
|
133644
133743
|
init_contract();
|
|
133645
|
-
var
|
|
133744
|
+
var fs48 = __toESM2(require("fs"));
|
|
133646
133745
|
var path522 = __toESM2(require("path"));
|
|
133647
133746
|
var import_crypto18 = require("crypto");
|
|
133648
133747
|
init_contract();
|
|
@@ -133661,7 +133760,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133661
133760
|
const hash2 = (0, import_crypto18.createHash)("sha256");
|
|
133662
133761
|
for (const relPath of relPaths) {
|
|
133663
133762
|
const absPath = path522.join(rootDir, ...relPath.split("/"));
|
|
133664
|
-
const bytes =
|
|
133763
|
+
const bytes = fs48.readFileSync(absPath);
|
|
133665
133764
|
hash2.update(relPath, "utf8");
|
|
133666
133765
|
hash2.update("\0");
|
|
133667
133766
|
hash2.update(String(bytes.length), "utf8");
|
|
@@ -133673,7 +133772,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133673
133772
|
function collectRegularFiles(rootDir, dir, out, providerType) {
|
|
133674
133773
|
let entries;
|
|
133675
133774
|
try {
|
|
133676
|
-
entries =
|
|
133775
|
+
entries = fs48.readdirSync(dir, { withFileTypes: true });
|
|
133677
133776
|
} catch (e) {
|
|
133678
133777
|
throw new ProviderChannelError(
|
|
133679
133778
|
"ENTRY_TREE_INVALID",
|
|
@@ -133698,12 +133797,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133698
133797
|
out.push(rel);
|
|
133699
133798
|
}
|
|
133700
133799
|
}
|
|
133701
|
-
var
|
|
133800
|
+
var fs49 = __toESM2(require("fs"));
|
|
133702
133801
|
var zlib = __toESM2(require("zlib"));
|
|
133703
133802
|
var import_promises6 = require("stream/promises");
|
|
133704
133803
|
async function extractTarballGz(tarPath, destDir) {
|
|
133705
133804
|
const tarFs = require_tar_fs();
|
|
133706
|
-
await (0, import_promises6.pipeline)(
|
|
133805
|
+
await (0, import_promises6.pipeline)(fs49.createReadStream(tarPath), zlib.createGunzip(), tarFs.extract(destDir));
|
|
133707
133806
|
}
|
|
133708
133807
|
var REGISTRY_LIST_LIMIT = 100;
|
|
133709
133808
|
var ProviderChannelRuntime = class {
|
|
@@ -133826,7 +133925,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133826
133925
|
try {
|
|
133827
133926
|
const tarPath = path53.join(stagingRoot, "providers.tar.gz");
|
|
133828
133927
|
const extractDir = path53.join(stagingRoot, "repo");
|
|
133829
|
-
|
|
133928
|
+
fs50.mkdirSync(extractDir, { recursive: true });
|
|
133830
133929
|
try {
|
|
133831
133930
|
await this.downloadFile(this.providerTarballUrl, tarPath);
|
|
133832
133931
|
await this.extractTarball(tarPath, extractDir);
|
|
@@ -133884,8 +133983,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133884
133983
|
let relDir;
|
|
133885
133984
|
try {
|
|
133886
133985
|
relDir = path53.relative(repoRoot, artifactDir).split(path53.sep).join("/");
|
|
133887
|
-
|
|
133888
|
-
|
|
133986
|
+
fs50.mkdirSync(path53.join(objStaging, entry.category), { recursive: true });
|
|
133987
|
+
fs50.renameSync(artifactDir, path53.join(objStaging, entry.category, path53.basename(artifactDir)));
|
|
133889
133988
|
} catch (e) {
|
|
133890
133989
|
this.store.removeStagingDir(objStaging);
|
|
133891
133990
|
return { code: "TRANSPORT_FAILED", message: `failed to stage artifact tree: ${e?.message || e}`, providerType: entry.providerType };
|
|
@@ -133924,7 +134023,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133924
134023
|
function findTarballRepoRoot(extractDir) {
|
|
133925
134024
|
let entries;
|
|
133926
134025
|
try {
|
|
133927
|
-
entries =
|
|
134026
|
+
entries = fs50.readdirSync(extractDir, { withFileTypes: true });
|
|
133928
134027
|
} catch {
|
|
133929
134028
|
return null;
|
|
133930
134029
|
}
|
|
@@ -133936,7 +134035,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133936
134035
|
const categoryDir = path53.join(repoRoot, entry.category);
|
|
133937
134036
|
let candidates;
|
|
133938
134037
|
try {
|
|
133939
|
-
candidates =
|
|
134038
|
+
candidates = fs50.readdirSync(categoryDir, { withFileTypes: true });
|
|
133940
134039
|
} catch {
|
|
133941
134040
|
return null;
|
|
133942
134041
|
}
|
|
@@ -133947,8 +134046,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133947
134046
|
for (const manifestName of ["provider.v1.json", "provider.json"]) {
|
|
133948
134047
|
const manifestPath = path53.join(dir, manifestName);
|
|
133949
134048
|
try {
|
|
133950
|
-
if (!
|
|
133951
|
-
const manifest = JSON.parse(
|
|
134049
|
+
if (!fs50.existsSync(manifestPath)) continue;
|
|
134050
|
+
const manifest = JSON.parse(fs50.readFileSync(manifestPath, "utf-8"));
|
|
133952
134051
|
if (manifest?.type === entry.providerType) return dir;
|
|
133953
134052
|
break;
|
|
133954
134053
|
} catch {
|
|
@@ -133965,14 +134064,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133965
134064
|
const scan = (dir) => {
|
|
133966
134065
|
let entries;
|
|
133967
134066
|
try {
|
|
133968
|
-
entries =
|
|
134067
|
+
entries = fs50.readdirSync(dir, { withFileTypes: true });
|
|
133969
134068
|
} catch {
|
|
133970
134069
|
return;
|
|
133971
134070
|
}
|
|
133972
134071
|
const manifest = entries.find((e) => e.isFile() && (e.name === "provider.v1.json" || e.name === "provider.json"));
|
|
133973
134072
|
if (manifest) {
|
|
133974
134073
|
try {
|
|
133975
|
-
const parsed = JSON.parse(
|
|
134074
|
+
const parsed = JSON.parse(fs50.readFileSync(path53.join(dir, manifest.name), "utf-8"));
|
|
133976
134075
|
if (typeof parsed?.type === "string" && parsed.type.trim()) targets.add(parsed.type);
|
|
133977
134076
|
} catch {
|
|
133978
134077
|
}
|
|
@@ -134037,7 +134136,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134037
134136
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
134038
134137
|
return;
|
|
134039
134138
|
}
|
|
134040
|
-
const ws =
|
|
134139
|
+
const ws = fs50.createWriteStream(destPath);
|
|
134041
134140
|
res.pipe(ws);
|
|
134042
134141
|
ws.on("finish", () => {
|
|
134043
134142
|
ws.close();
|
|
@@ -134198,9 +134297,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134198
134297
|
static siblingRefusalLogged = /* @__PURE__ */ new Set();
|
|
134199
134298
|
static looksLikeProviderRoot(candidate) {
|
|
134200
134299
|
try {
|
|
134201
|
-
if (!
|
|
134300
|
+
if (!fs51.existsSync(candidate) || !fs51.statSync(candidate).isDirectory()) return false;
|
|
134202
134301
|
return ["ide", "extension", "cli", "acp"].some(
|
|
134203
|
-
(category) =>
|
|
134302
|
+
(category) => fs51.existsSync(path55.join(candidate, category))
|
|
134204
134303
|
);
|
|
134205
134304
|
} catch {
|
|
134206
134305
|
return false;
|
|
@@ -134208,7 +134307,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134208
134307
|
}
|
|
134209
134308
|
static hasProviderRootMarker(candidate) {
|
|
134210
134309
|
try {
|
|
134211
|
-
return
|
|
134310
|
+
return fs51.existsSync(path55.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
134212
134311
|
} catch {
|
|
134213
134312
|
return false;
|
|
134214
134313
|
}
|
|
@@ -134295,12 +134394,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134295
134394
|
const configDir = getConfigDir2();
|
|
134296
134395
|
const oldDir = path55.join(configDir, "marketplace");
|
|
134297
134396
|
const newDir = path55.join(configDir, "external");
|
|
134298
|
-
if (!
|
|
134299
|
-
if (
|
|
134397
|
+
if (!fs51.existsSync(oldDir)) return;
|
|
134398
|
+
if (fs51.existsSync(newDir)) {
|
|
134300
134399
|
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
134301
134400
|
return;
|
|
134302
134401
|
}
|
|
134303
|
-
|
|
134402
|
+
fs51.renameSync(oldDir, newDir);
|
|
134304
134403
|
this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
|
|
134305
134404
|
} catch (e) {
|
|
134306
134405
|
this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
|
|
@@ -134420,7 +134519,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134420
134519
|
this.providers.clear();
|
|
134421
134520
|
this.providerAvailability.clear();
|
|
134422
134521
|
let upstreamCount = 0;
|
|
134423
|
-
if (!this.disableUpstream &&
|
|
134522
|
+
if (!this.disableUpstream && fs51.existsSync(this.upstreamDir)) {
|
|
134424
134523
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
134425
134524
|
if (upstreamCount > 0) {
|
|
134426
134525
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -134430,10 +134529,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134430
134529
|
}
|
|
134431
134530
|
this.loadVerifiedChannelActivations();
|
|
134432
134531
|
const externalDir = path55.join(getConfigDir2(), "external");
|
|
134433
|
-
if (
|
|
134532
|
+
if (fs51.existsSync(externalDir)) {
|
|
134434
134533
|
const rootEntries = (() => {
|
|
134435
134534
|
try {
|
|
134436
|
-
return
|
|
134535
|
+
return fs51.readdirSync(externalDir, { withFileTypes: true });
|
|
134437
134536
|
} catch {
|
|
134438
134537
|
return [];
|
|
134439
134538
|
}
|
|
@@ -134482,7 +134581,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134482
134581
|
}
|
|
134483
134582
|
}
|
|
134484
134583
|
}
|
|
134485
|
-
if (
|
|
134584
|
+
if (fs51.existsSync(this.userDir)) {
|
|
134486
134585
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
134487
134586
|
if (userCount > 0) {
|
|
134488
134587
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -134620,7 +134719,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134620
134719
|
if (this.countVerifiedChannelPointers() > 0) return null;
|
|
134621
134720
|
if (this.hasUpstream()) return this.syncVerifiedChannel();
|
|
134622
134721
|
try {
|
|
134623
|
-
|
|
134722
|
+
fs51.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
134624
134723
|
} catch {
|
|
134625
134724
|
}
|
|
134626
134725
|
return this.syncVerifiedChannel({ bootstrapAll: true });
|
|
@@ -134631,7 +134730,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134631
134730
|
}
|
|
134632
134731
|
readChannelActivationStamp() {
|
|
134633
134732
|
try {
|
|
134634
|
-
return JSON.parse(
|
|
134733
|
+
return JSON.parse(fs51.readFileSync(this.channelActivationStampPath(), "utf-8"));
|
|
134635
134734
|
} catch {
|
|
134636
134735
|
return null;
|
|
134637
134736
|
}
|
|
@@ -134679,8 +134778,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134679
134778
|
}
|
|
134680
134779
|
}
|
|
134681
134780
|
try {
|
|
134682
|
-
|
|
134683
|
-
|
|
134781
|
+
fs51.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
134782
|
+
fs51.writeFileSync(stampPath, JSON.stringify({
|
|
134684
134783
|
daemonVersion: this.daemonVersion,
|
|
134685
134784
|
channel: this.channel,
|
|
134686
134785
|
syncedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -134824,10 +134923,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134824
134923
|
* Check if upstream directory exists and has providers.
|
|
134825
134924
|
*/
|
|
134826
134925
|
hasUpstream() {
|
|
134827
|
-
if (!
|
|
134926
|
+
if (!fs51.existsSync(this.upstreamDir)) return false;
|
|
134828
134927
|
try {
|
|
134829
|
-
return
|
|
134830
|
-
(d) =>
|
|
134928
|
+
return fs51.readdirSync(this.upstreamDir).some(
|
|
134929
|
+
(d) => fs51.statSync(path55.join(this.upstreamDir, d)).isDirectory()
|
|
134831
134930
|
);
|
|
134832
134931
|
} catch {
|
|
134833
134932
|
return false;
|
|
@@ -135376,7 +135475,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135376
135475
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
135377
135476
|
if (providerDir) {
|
|
135378
135477
|
const fullDir = path55.join(providerDir, entry.scriptDir);
|
|
135379
|
-
resolved._resolvedScriptsPath =
|
|
135478
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135380
135479
|
}
|
|
135381
135480
|
matched = true;
|
|
135382
135481
|
}
|
|
@@ -135395,7 +135494,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135395
135494
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
135396
135495
|
if (providerDir) {
|
|
135397
135496
|
const fullDir = path55.join(providerDir, base.defaultScriptDir);
|
|
135398
|
-
resolved._resolvedScriptsPath =
|
|
135497
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135399
135498
|
}
|
|
135400
135499
|
}
|
|
135401
135500
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -135413,7 +135512,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135413
135512
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
135414
135513
|
if (providerDir) {
|
|
135415
135514
|
const fullDir = path55.join(providerDir, dirOverride);
|
|
135416
|
-
resolved._resolvedScriptsPath =
|
|
135515
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135417
135516
|
}
|
|
135418
135517
|
}
|
|
135419
135518
|
} else if (override.scripts) {
|
|
@@ -135430,7 +135529,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135430
135529
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
135431
135530
|
if (providerDir) {
|
|
135432
135531
|
const fullDir = path55.join(providerDir, base.defaultScriptDir);
|
|
135433
|
-
resolved._resolvedScriptsPath =
|
|
135532
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135434
135533
|
}
|
|
135435
135534
|
}
|
|
135436
135535
|
}
|
|
@@ -135448,7 +135547,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135448
135547
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
135449
135548
|
if (!override || typeof override.path !== "string") continue;
|
|
135450
135549
|
const fullPath = path55.join(providerDir2, override.path);
|
|
135451
|
-
if (!
|
|
135550
|
+
if (!fs51.existsSync(fullPath)) {
|
|
135452
135551
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
135453
135552
|
continue;
|
|
135454
135553
|
}
|
|
@@ -135478,7 +135577,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135478
135577
|
}
|
|
135479
135578
|
if (providerDir) {
|
|
135480
135579
|
try {
|
|
135481
|
-
const
|
|
135580
|
+
const fs67 = require("fs");
|
|
135482
135581
|
const path64 = require("path");
|
|
135483
135582
|
const candidates = [];
|
|
135484
135583
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -135490,13 +135589,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135490
135589
|
}
|
|
135491
135590
|
candidates.push(path64.join(providerDir, "specs", "default.json"));
|
|
135492
135591
|
candidates.push(path64.join(providerDir, "spec.json"));
|
|
135493
|
-
const specPath = candidates.find((p) =>
|
|
135592
|
+
const specPath = candidates.find((p) => fs67.existsSync(p));
|
|
135494
135593
|
let nh;
|
|
135495
135594
|
if (specPath) {
|
|
135496
135595
|
resolved._resolvedSpecPath = specPath;
|
|
135497
135596
|
let specControls;
|
|
135498
135597
|
try {
|
|
135499
|
-
const rawSpec = JSON.parse(
|
|
135598
|
+
const rawSpec = JSON.parse(fs67.readFileSync(specPath, "utf8"));
|
|
135500
135599
|
specControls = rawSpec.control_bar;
|
|
135501
135600
|
nh = rawSpec.native_history;
|
|
135502
135601
|
} catch {
|
|
@@ -135539,7 +135638,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135539
135638
|
}
|
|
135540
135639
|
} else if (nh.override_path) {
|
|
135541
135640
|
const overrideFile = path64.resolve(providerDir, nh.override_path);
|
|
135542
|
-
if (
|
|
135641
|
+
if (fs67.existsSync(overrideFile)) {
|
|
135543
135642
|
try {
|
|
135544
135643
|
registerProviderScriptRootSafely(path64.dirname(path64.dirname(providerDir)));
|
|
135545
135644
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -135598,7 +135697,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135598
135697
|
return null;
|
|
135599
135698
|
}
|
|
135600
135699
|
const dir = path55.join(providerDir, scriptDir);
|
|
135601
|
-
if (!
|
|
135700
|
+
if (!fs51.existsSync(dir)) {
|
|
135602
135701
|
this.debugLog(`[loadScriptsFromDir] ${type2}: dir not found: ${dir}`);
|
|
135603
135702
|
return null;
|
|
135604
135703
|
}
|
|
@@ -135606,7 +135705,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135606
135705
|
const cached5 = this.scriptsCache.get(dir);
|
|
135607
135706
|
if (cached5) return cached5;
|
|
135608
135707
|
const scriptsJs = path55.join(dir, "scripts.js");
|
|
135609
|
-
if (
|
|
135708
|
+
if (fs51.existsSync(scriptsJs)) {
|
|
135610
135709
|
try {
|
|
135611
135710
|
delete require.cache[require.resolve(scriptsJs)];
|
|
135612
135711
|
const loaded = require(scriptsJs);
|
|
@@ -135627,9 +135726,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135627
135726
|
watch() {
|
|
135628
135727
|
this.stopWatch();
|
|
135629
135728
|
const watchDir = (dir) => {
|
|
135630
|
-
if (!
|
|
135729
|
+
if (!fs51.existsSync(dir)) {
|
|
135631
135730
|
try {
|
|
135632
|
-
|
|
135731
|
+
fs51.mkdirSync(dir, { recursive: true });
|
|
135633
135732
|
} catch {
|
|
135634
135733
|
return;
|
|
135635
135734
|
}
|
|
@@ -135692,11 +135791,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135692
135791
|
}
|
|
135693
135792
|
/** Count provider files (provider.v1.json or provider.json — at most one per dir). */
|
|
135694
135793
|
countProviders(dir) {
|
|
135695
|
-
if (!
|
|
135794
|
+
if (!fs51.existsSync(dir)) return 0;
|
|
135696
135795
|
let count = 0;
|
|
135697
135796
|
const scan = (d) => {
|
|
135698
135797
|
try {
|
|
135699
|
-
const entries =
|
|
135798
|
+
const entries = fs51.readdirSync(d, { withFileTypes: true });
|
|
135700
135799
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
135701
135800
|
if (hasManifest) count++;
|
|
135702
135801
|
for (const entry of entries) {
|
|
@@ -135926,13 +136025,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135926
136025
|
if (!provider) return null;
|
|
135927
136026
|
const cat = provider.category;
|
|
135928
136027
|
const searchRoots = this.getProviderRoots();
|
|
135929
|
-
const hasManifest = (dir) =>
|
|
136028
|
+
const hasManifest = (dir) => fs51.existsSync(path55.join(dir, "provider.v1.json")) || fs51.existsSync(path55.join(dir, "provider.json"));
|
|
135930
136029
|
const readManifestType = (dir) => {
|
|
135931
136030
|
for (const file2 of ["provider.v1.json", "provider.json"]) {
|
|
135932
136031
|
const p = path55.join(dir, file2);
|
|
135933
|
-
if (!
|
|
136032
|
+
if (!fs51.existsSync(p)) continue;
|
|
135934
136033
|
try {
|
|
135935
|
-
const data = JSON.parse(
|
|
136034
|
+
const data = JSON.parse(fs51.readFileSync(p, "utf-8"));
|
|
135936
136035
|
if (typeof data?.type === "string") return data.type;
|
|
135937
136036
|
} catch {
|
|
135938
136037
|
}
|
|
@@ -135940,13 +136039,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135940
136039
|
return null;
|
|
135941
136040
|
};
|
|
135942
136041
|
for (const root of searchRoots) {
|
|
135943
|
-
if (!
|
|
136042
|
+
if (!fs51.existsSync(root)) continue;
|
|
135944
136043
|
const candidate = this.getProviderDir(root, cat, type2);
|
|
135945
136044
|
if (hasManifest(candidate)) return candidate;
|
|
135946
136045
|
const catDir = path55.join(root, cat);
|
|
135947
|
-
if (
|
|
136046
|
+
if (fs51.existsSync(catDir)) {
|
|
135948
136047
|
try {
|
|
135949
|
-
for (const entry of
|
|
136048
|
+
for (const entry of fs51.readdirSync(catDir, { withFileTypes: true })) {
|
|
135950
136049
|
if (!entry.isDirectory()) continue;
|
|
135951
136050
|
const entryDir = path55.join(catDir, entry.name);
|
|
135952
136051
|
const manifestType = readManifestType(entryDir);
|
|
@@ -135965,7 +136064,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135965
136064
|
*/
|
|
135966
136065
|
buildScriptWrappersFromDir(dir) {
|
|
135967
136066
|
const scriptsJs = path55.join(dir, "scripts.js");
|
|
135968
|
-
if (
|
|
136067
|
+
if (fs51.existsSync(scriptsJs)) {
|
|
135969
136068
|
try {
|
|
135970
136069
|
delete require.cache[require.resolve(scriptsJs)];
|
|
135971
136070
|
return require(scriptsJs);
|
|
@@ -135975,13 +136074,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135975
136074
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
135976
136075
|
const result = {};
|
|
135977
136076
|
try {
|
|
135978
|
-
for (const file2 of
|
|
136077
|
+
for (const file2 of fs51.readdirSync(dir)) {
|
|
135979
136078
|
if (!file2.endsWith(".js")) continue;
|
|
135980
136079
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
135981
136080
|
const filePath = path55.join(dir, file2);
|
|
135982
136081
|
result[scriptName] = (...args) => {
|
|
135983
136082
|
try {
|
|
135984
|
-
let content =
|
|
136083
|
+
let content = fs51.readFileSync(filePath, "utf-8");
|
|
135985
136084
|
if (args[0] && typeof args[0] === "object") {
|
|
135986
136085
|
for (const [key2, val] of Object.entries(args[0])) {
|
|
135987
136086
|
let v = val;
|
|
@@ -136027,12 +136126,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136027
136126
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
136028
136127
|
*/
|
|
136029
136128
|
loadDir(dir, excludeDirs) {
|
|
136030
|
-
if (!
|
|
136129
|
+
if (!fs51.existsSync(dir)) return 0;
|
|
136031
136130
|
let count = 0;
|
|
136032
136131
|
const scan = (d) => {
|
|
136033
136132
|
let entries;
|
|
136034
136133
|
try {
|
|
136035
|
-
entries =
|
|
136134
|
+
entries = fs51.readdirSync(d, { withFileTypes: true });
|
|
136036
136135
|
} catch {
|
|
136037
136136
|
return;
|
|
136038
136137
|
}
|
|
@@ -136042,7 +136141,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136042
136141
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
136043
136142
|
const jsonPath = path55.join(d, manifestFile);
|
|
136044
136143
|
try {
|
|
136045
|
-
const raw =
|
|
136144
|
+
const raw = fs51.readFileSync(jsonPath, "utf-8");
|
|
136046
136145
|
const mod = JSON.parse(raw);
|
|
136047
136146
|
if (hasV1 && (mod?.category === "cli" || mod?.category === "acp")) {
|
|
136048
136147
|
try {
|
|
@@ -136081,7 +136180,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136081
136180
|
} else {
|
|
136082
136181
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
136083
136182
|
const scriptsPath = path55.join(d, "scripts.js");
|
|
136084
|
-
if (!hasCompatibility &&
|
|
136183
|
+
if (!hasCompatibility && fs51.existsSync(scriptsPath)) {
|
|
136085
136184
|
try {
|
|
136086
136185
|
registerProviderScriptRootSafely(path55.dirname(path55.dirname(d)));
|
|
136087
136186
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -136459,7 +136558,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136459
136558
|
}
|
|
136460
136559
|
} else if (plat === "win32") {
|
|
136461
136560
|
try {
|
|
136462
|
-
const
|
|
136561
|
+
const fs67 = require("fs");
|
|
136463
136562
|
const appNameMap = getMacAppIdentifiers();
|
|
136464
136563
|
const appName = appNameMap[ideId];
|
|
136465
136564
|
if (appName) {
|
|
@@ -136468,8 +136567,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136468
136567
|
appName,
|
|
136469
136568
|
"storage.json"
|
|
136470
136569
|
);
|
|
136471
|
-
if (
|
|
136472
|
-
const data = JSON.parse(
|
|
136570
|
+
if (fs67.existsSync(storagePath)) {
|
|
136571
|
+
const data = JSON.parse(fs67.readFileSync(storagePath, "utf-8"));
|
|
136473
136572
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
136474
136573
|
if (workspaces.length > 0) {
|
|
136475
136574
|
const recent = workspaces[0];
|
|
@@ -137169,7 +137268,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137169
137268
|
normalizeRepoMeshDeclarativeConfig: normalizeRepoMeshDeclarativeConfig2,
|
|
137170
137269
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
137171
137270
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
137172
|
-
const { existsSync: existsSync76, readFileSync:
|
|
137271
|
+
const { existsSync: existsSync76, readFileSync: readFileSync60, mkdirSync: mkdirSync35, writeFileSync: writeFileSync33 } = await import("fs");
|
|
137173
137272
|
const { dirname: dirname26, join: join75 } = await import("path");
|
|
137174
137273
|
const yaml6 = await Promise.resolve().then(() => (init_js_yaml(), js_yaml_exports));
|
|
137175
137274
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
@@ -137180,7 +137279,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137180
137279
|
const candidate = join75(workspace, relative8);
|
|
137181
137280
|
if (!existsSync76(candidate)) continue;
|
|
137182
137281
|
try {
|
|
137183
|
-
const text =
|
|
137282
|
+
const text = readFileSync60(candidate, "utf-8");
|
|
137184
137283
|
const parsed = /\.json$/i.test(candidate) ? JSON.parse(text) : yaml6.load(text);
|
|
137185
137284
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
137186
137285
|
baseDoc = parsed;
|
|
@@ -139274,7 +139373,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
139274
139373
|
}
|
|
139275
139374
|
};
|
|
139276
139375
|
var import_path222 = require("path");
|
|
139277
|
-
var
|
|
139376
|
+
var fs55 = __toESM2(require("fs"));
|
|
139278
139377
|
init_logger();
|
|
139279
139378
|
init_mesh_host_ownership();
|
|
139280
139379
|
init_coordinator_registry();
|
|
@@ -139579,15 +139678,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139579
139678
|
}
|
|
139580
139679
|
if (cliType === "codex-cli") {
|
|
139581
139680
|
const repoMcpConfigPath = (0, import_path222.join)(workspace, ".mcp.json");
|
|
139582
|
-
if (
|
|
139681
|
+
if (fs55.existsSync(repoMcpConfigPath)) {
|
|
139583
139682
|
try {
|
|
139584
139683
|
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
139585
|
-
|
|
139684
|
+
fs55.readFileSync(repoMcpConfigPath, "utf-8"),
|
|
139586
139685
|
"claude_mcp_json"
|
|
139587
139686
|
);
|
|
139588
139687
|
const existingServers2 = repoMcpConfig.mcpServers;
|
|
139589
139688
|
if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
|
|
139590
|
-
|
|
139689
|
+
fs55.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
139591
139690
|
...repoMcpConfig,
|
|
139592
139691
|
mcpServers: {
|
|
139593
139692
|
...existingServers2,
|
|
@@ -139751,7 +139850,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139751
139850
|
workspace
|
|
139752
139851
|
};
|
|
139753
139852
|
}
|
|
139754
|
-
const { existsSync: existsSync76, readFileSync:
|
|
139853
|
+
const { existsSync: existsSync76, readFileSync: readFileSync60, writeFileSync: writeFileSync33, copyFileSync: copyFileSync4, mkdirSync: mkdirSync35 } = await import("fs");
|
|
139755
139854
|
const { dirname: dirname26 } = await import("path");
|
|
139756
139855
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
139757
139856
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -139803,7 +139902,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139803
139902
|
}
|
|
139804
139903
|
if (hadExistingMcpConfig) {
|
|
139805
139904
|
try {
|
|
139806
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
139905
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync60(mcpConfigPath, "utf-8"), configFormat);
|
|
139807
139906
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
139808
139907
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
139809
139908
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -139958,7 +140057,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139958
140057
|
}
|
|
139959
140058
|
}
|
|
139960
140059
|
};
|
|
139961
|
-
var
|
|
140060
|
+
var fs56 = __toESM2(require("fs"));
|
|
139962
140061
|
var import_os5 = require("os");
|
|
139963
140062
|
init_config();
|
|
139964
140063
|
init_git_status();
|
|
@@ -140341,7 +140440,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140341
140440
|
}
|
|
140342
140441
|
}
|
|
140343
140442
|
if (workspace) {
|
|
140344
|
-
if (!
|
|
140443
|
+
if (!fs56.existsSync(workspace)) {
|
|
140345
140444
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
140346
140445
|
let remoteProbeApplied = false;
|
|
140347
140446
|
if (inlineTransitGit) {
|
|
@@ -140482,7 +140581,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140482
140581
|
const pendingRetentionCounters2 = { ...getPendingRetentionCounters() };
|
|
140483
140582
|
const turnPresentationCounters = getTurnPresentationMetrics();
|
|
140484
140583
|
const previewFreshness = (() => {
|
|
140485
|
-
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate &&
|
|
140584
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs56.existsSync(candidate));
|
|
140486
140585
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
140487
140586
|
})();
|
|
140488
140587
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -140682,7 +140781,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140682
140781
|
init_logger();
|
|
140683
140782
|
init_mesh_dual_write();
|
|
140684
140783
|
init_transcript_publisher();
|
|
140685
|
-
var
|
|
140784
|
+
var fs57 = __toESM2(require("fs"));
|
|
140686
140785
|
var path57 = __toESM2(require("path"));
|
|
140687
140786
|
init_config_dir();
|
|
140688
140787
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
@@ -140731,7 +140830,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140731
140830
|
currentFile = path57.join(dir, `commands-${today}.jsonl`);
|
|
140732
140831
|
if (dirChanged) {
|
|
140733
140832
|
try {
|
|
140734
|
-
|
|
140833
|
+
fs57.mkdirSync(dir, { recursive: true });
|
|
140735
140834
|
} catch {
|
|
140736
140835
|
}
|
|
140737
140836
|
cleanOldFiles();
|
|
@@ -140739,7 +140838,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140739
140838
|
}
|
|
140740
140839
|
function cleanOldFiles() {
|
|
140741
140840
|
try {
|
|
140742
|
-
const files =
|
|
140841
|
+
const files = fs57.readdirSync(currentDir).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
140743
140842
|
const cutoff = /* @__PURE__ */ new Date();
|
|
140744
140843
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
140745
140844
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -140747,7 +140846,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140747
140846
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
140748
140847
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
140749
140848
|
try {
|
|
140750
|
-
|
|
140849
|
+
fs57.unlinkSync(path57.join(currentDir, file2));
|
|
140751
140850
|
} catch {
|
|
140752
140851
|
}
|
|
140753
140852
|
}
|
|
@@ -140757,14 +140856,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140757
140856
|
}
|
|
140758
140857
|
function checkSize() {
|
|
140759
140858
|
try {
|
|
140760
|
-
const stat2 =
|
|
140859
|
+
const stat2 = fs57.statSync(currentFile);
|
|
140761
140860
|
if (stat2.size > MAX_FILE_SIZE) {
|
|
140762
140861
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
140763
140862
|
try {
|
|
140764
|
-
|
|
140863
|
+
fs57.unlinkSync(backup);
|
|
140765
140864
|
} catch {
|
|
140766
140865
|
}
|
|
140767
|
-
|
|
140866
|
+
fs57.renameSync(currentFile, backup);
|
|
140768
140867
|
}
|
|
140769
140868
|
} catch {
|
|
140770
140869
|
}
|
|
@@ -140797,15 +140896,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140797
140896
|
...entry.error ? { err: entry.error } : {},
|
|
140798
140897
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
140799
140898
|
});
|
|
140800
|
-
|
|
140899
|
+
fs57.appendFileSync(currentFile, line + "\n");
|
|
140801
140900
|
} catch {
|
|
140802
140901
|
}
|
|
140803
140902
|
}
|
|
140804
140903
|
function getRecentCommands(count = 50) {
|
|
140805
140904
|
try {
|
|
140806
140905
|
refreshCurrentFile();
|
|
140807
|
-
if (!
|
|
140808
|
-
const content =
|
|
140906
|
+
if (!fs57.existsSync(currentFile)) return [];
|
|
140907
|
+
const content = fs57.readFileSync(currentFile, "utf-8");
|
|
140809
140908
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
140810
140909
|
return lines.slice(-count).map((line) => {
|
|
140811
140910
|
try {
|
|
@@ -140832,10 +140931,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140832
140931
|
init_mesh_host_ownership();
|
|
140833
140932
|
init_repo_mesh_types();
|
|
140834
140933
|
init_mesh_config();
|
|
140835
|
-
var
|
|
140934
|
+
var fs59 = __toESM2(require("fs"));
|
|
140836
140935
|
init_mesh_node_identity();
|
|
140837
140936
|
init_router_refine();
|
|
140838
|
-
var
|
|
140937
|
+
var fs58 = __toESM2(require("fs"));
|
|
140839
140938
|
var import_node_os22 = require("os");
|
|
140840
140939
|
var import_path23 = require("path");
|
|
140841
140940
|
init_logger();
|
|
@@ -140866,7 +140965,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140866
140965
|
return out;
|
|
140867
140966
|
}
|
|
140868
140967
|
function repoRootUsable(repoRoot) {
|
|
140869
|
-
return typeof repoRoot === "string" && repoRoot.trim().length > 0 &&
|
|
140968
|
+
return typeof repoRoot === "string" && repoRoot.trim().length > 0 && fs58.existsSync(repoRoot.trim());
|
|
140870
140969
|
}
|
|
140871
140970
|
function meshWorktreeBaseDir(mesh) {
|
|
140872
140971
|
const v = mesh?.policy?.worktreeBaseDir;
|
|
@@ -140935,14 +141034,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140935
141034
|
return false;
|
|
140936
141035
|
}
|
|
140937
141036
|
async function bestEffortRemoveWorktreeDir(self, dir) {
|
|
140938
|
-
if (!dir || !
|
|
141037
|
+
if (!dir || !fs58.existsSync(dir)) return { removed: true, residue: false };
|
|
140939
141038
|
const sleep3 = (ms) => new Promise((resolve32) => setTimeout(resolve32, ms));
|
|
140940
141039
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
140941
141040
|
let lastErr;
|
|
140942
141041
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
140943
141042
|
try {
|
|
140944
|
-
|
|
140945
|
-
if (!
|
|
141043
|
+
fs58.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
141044
|
+
if (!fs58.existsSync(dir)) return { removed: true, residue: false };
|
|
140946
141045
|
lastErr = new Error("directory still present after rmSync");
|
|
140947
141046
|
} catch (e) {
|
|
140948
141047
|
lastErr = e;
|
|
@@ -140953,7 +141052,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140953
141052
|
}
|
|
140954
141053
|
await sleep3(150 * (attempt + 1));
|
|
140955
141054
|
}
|
|
140956
|
-
return
|
|
141055
|
+
return fs58.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
140957
141056
|
}
|
|
140958
141057
|
async function precheckLocalWorktreeRemovable(self, args) {
|
|
140959
141058
|
const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
|
|
@@ -140966,10 +141065,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140966
141065
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
|
|
140967
141066
|
};
|
|
140968
141067
|
}
|
|
140969
|
-
if (!
|
|
141068
|
+
if (!fs58.existsSync(workspace)) return { ok: true };
|
|
140970
141069
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
140971
141070
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
140972
|
-
if (!repoRoot || !
|
|
141071
|
+
if (!repoRoot || !fs58.existsSync(repoRoot)) {
|
|
140973
141072
|
return {
|
|
140974
141073
|
ok: false,
|
|
140975
141074
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -140989,7 +141088,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140989
141088
|
const normalizePath2 = (value) => {
|
|
140990
141089
|
const resolved = (0, import_path23.resolve)(value);
|
|
140991
141090
|
try {
|
|
140992
|
-
return
|
|
141091
|
+
return fs58.realpathSync(resolved);
|
|
140993
141092
|
} catch {
|
|
140994
141093
|
return resolved;
|
|
140995
141094
|
}
|
|
@@ -141090,13 +141189,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141090
141189
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
141091
141190
|
};
|
|
141092
141191
|
}
|
|
141093
|
-
const worktreeExists =
|
|
141192
|
+
const worktreeExists = fs58.existsSync(workspace);
|
|
141094
141193
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
141095
141194
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
141096
141195
|
if (!worktreeExists) {
|
|
141097
141196
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
141098
141197
|
}
|
|
141099
|
-
if (!repoRoot || !
|
|
141198
|
+
if (!repoRoot || !fs58.existsSync(repoRoot)) {
|
|
141100
141199
|
return {
|
|
141101
141200
|
success: false,
|
|
141102
141201
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -141116,7 +141215,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141116
141215
|
const normalizePath2 = (value) => {
|
|
141117
141216
|
const resolved = (0, import_path23.resolve)(value);
|
|
141118
141217
|
try {
|
|
141119
|
-
return
|
|
141218
|
+
return fs58.realpathSync(resolved);
|
|
141120
141219
|
} catch {
|
|
141121
141220
|
return resolved;
|
|
141122
141221
|
}
|
|
@@ -141333,7 +141432,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141333
141432
|
});
|
|
141334
141433
|
return String(stdout || "").trim();
|
|
141335
141434
|
};
|
|
141336
|
-
const workspaceMissing = !args.workspace || !
|
|
141435
|
+
const workspaceMissing = !args.workspace || !fs58.existsSync(args.workspace);
|
|
141337
141436
|
let head = "";
|
|
141338
141437
|
const branch = typeof args.node?.worktreeBranch === "string" ? args.node.worktreeBranch.trim() : "";
|
|
141339
141438
|
if (workspaceMissing) {
|
|
@@ -142383,7 +142482,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
142383
142482
|
const tombstones = this.removedInlineMeshNodeIds.get(meshId);
|
|
142384
142483
|
if (!tombstones?.size || !tombstones.has(nodeId)) return false;
|
|
142385
142484
|
const workspace = readStringValue(node?.workspace);
|
|
142386
|
-
if (workspace &&
|
|
142485
|
+
if (workspace && fs59.existsSync(workspace)) {
|
|
142387
142486
|
tombstones.delete(nodeId);
|
|
142388
142487
|
if (tombstones.size === 0) this.removedInlineMeshNodeIds.delete(meshId);
|
|
142389
142488
|
return false;
|
|
@@ -142404,7 +142503,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
142404
142503
|
const nodeId = readInlineMeshNodeId(node);
|
|
142405
142504
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
142406
142505
|
const workspace = readStringValue(node?.workspace);
|
|
142407
|
-
if (workspace &&
|
|
142506
|
+
if (workspace && fs59.existsSync(workspace)) {
|
|
142408
142507
|
tombstones.delete(nodeId);
|
|
142409
142508
|
return true;
|
|
142410
142509
|
}
|
|
@@ -143203,7 +143302,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
143203
143302
|
markChatOutputActivity(sessionId) {
|
|
143204
143303
|
const cfg = this.opts.chatTail;
|
|
143205
143304
|
if (!sessionId || !(cfg?.isCliSession?.(sessionId) ?? false)) return;
|
|
143206
|
-
|
|
143305
|
+
markTranscriptPtyOutputActivity(sessionId);
|
|
143207
143306
|
this.chatOutputActiveAt.set(sessionId, this.now());
|
|
143208
143307
|
if (this.chatOutputFlushTimer) return;
|
|
143209
143308
|
if (cfg?.scheduleGate && !cfg.scheduleGate()) return;
|
|
@@ -145529,7 +145628,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145529
145628
|
};
|
|
145530
145629
|
init_io_contracts();
|
|
145531
145630
|
init_chat_message_normalization();
|
|
145532
|
-
var
|
|
145631
|
+
var fs60 = __toESM2(require("fs"));
|
|
145533
145632
|
var path58 = __toESM2(require("path"));
|
|
145534
145633
|
var os33 = __toESM2(require("os"));
|
|
145535
145634
|
var import_os6 = require("os");
|
|
@@ -145546,8 +145645,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145546
145645
|
}
|
|
145547
145646
|
load() {
|
|
145548
145647
|
try {
|
|
145549
|
-
if (
|
|
145550
|
-
this.history = JSON.parse(
|
|
145648
|
+
if (fs60.existsSync(getArchivePath2())) {
|
|
145649
|
+
this.history = JSON.parse(fs60.readFileSync(getArchivePath2(), "utf-8"));
|
|
145551
145650
|
}
|
|
145552
145651
|
} catch {
|
|
145553
145652
|
this.history = {};
|
|
@@ -145584,8 +145683,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145584
145683
|
}
|
|
145585
145684
|
save() {
|
|
145586
145685
|
try {
|
|
145587
|
-
|
|
145588
|
-
|
|
145686
|
+
fs60.mkdirSync(path58.dirname(getArchivePath2()), { recursive: true });
|
|
145687
|
+
fs60.writeFileSync(getArchivePath2(), JSON.stringify(this.history, null, 2));
|
|
145589
145688
|
} catch {
|
|
145590
145689
|
}
|
|
145591
145690
|
}
|
|
@@ -145610,8 +145709,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145610
145709
|
for (const ext of exes) {
|
|
145611
145710
|
const fullPath = path58.join(p, name + ext);
|
|
145612
145711
|
try {
|
|
145613
|
-
if (
|
|
145614
|
-
const stat2 =
|
|
145712
|
+
if (fs60.existsSync(fullPath)) {
|
|
145713
|
+
const stat2 = fs60.statSync(fullPath);
|
|
145615
145714
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
145616
145715
|
return fullPath;
|
|
145617
145716
|
}
|
|
@@ -145658,9 +145757,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145658
145757
|
if (p.includes("*")) {
|
|
145659
145758
|
const home = os33.homedir();
|
|
145660
145759
|
const resolved = p.replace(/\*/g, home.split(path58.sep).pop() || "");
|
|
145661
|
-
if (
|
|
145760
|
+
if (fs60.existsSync(resolved)) return resolved;
|
|
145662
145761
|
} else {
|
|
145663
|
-
if (
|
|
145762
|
+
if (fs60.existsSync(p)) return p;
|
|
145664
145763
|
}
|
|
145665
145764
|
}
|
|
145666
145765
|
return null;
|
|
@@ -145668,7 +145767,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145668
145767
|
async function getMacAppVersion(appPath) {
|
|
145669
145768
|
if ((0, import_os6.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
145670
145769
|
const plistPath = path58.join(appPath, "Contents", "Info.plist");
|
|
145671
|
-
if (!
|
|
145770
|
+
if (!fs60.existsSync(plistPath)) return null;
|
|
145672
145771
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
145673
145772
|
return raw || null;
|
|
145674
145773
|
}
|
|
@@ -145695,7 +145794,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145695
145794
|
let resolvedBin = cliBin;
|
|
145696
145795
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
145697
145796
|
const bundled = path58.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
145698
|
-
if (provider.cli &&
|
|
145797
|
+
if (provider.cli && fs60.existsSync(bundled)) resolvedBin = bundled;
|
|
145699
145798
|
}
|
|
145700
145799
|
info.installed = !!(appPath || resolvedBin);
|
|
145701
145800
|
info.path = appPath || null;
|
|
@@ -145741,7 +145840,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145741
145840
|
return results;
|
|
145742
145841
|
}
|
|
145743
145842
|
var http3 = __toESM2(require("http"));
|
|
145744
|
-
var
|
|
145843
|
+
var fs64 = __toESM2(require("fs"));
|
|
145745
145844
|
var path62 = __toESM2(require("path"));
|
|
145746
145845
|
init_config();
|
|
145747
145846
|
function generateFiles(type2, name, category, opts = {}) {
|
|
@@ -146087,7 +146186,7 @@ async (params) => {
|
|
|
146087
146186
|
}
|
|
146088
146187
|
init_logger();
|
|
146089
146188
|
init_builders();
|
|
146090
|
-
var
|
|
146189
|
+
var fs61 = __toESM2(require("fs"));
|
|
146091
146190
|
var path59 = __toESM2(require("path"));
|
|
146092
146191
|
init_logger();
|
|
146093
146192
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -146268,17 +146367,17 @@ async (params) => {
|
|
|
146268
146367
|
}
|
|
146269
146368
|
let scriptsPath = "";
|
|
146270
146369
|
const directScripts = path59.join(dir, "scripts.js");
|
|
146271
|
-
if (
|
|
146370
|
+
if (fs61.existsSync(directScripts)) {
|
|
146272
146371
|
scriptsPath = directScripts;
|
|
146273
146372
|
} else {
|
|
146274
146373
|
const scriptsDir = path59.join(dir, "scripts");
|
|
146275
|
-
if (
|
|
146276
|
-
const versions =
|
|
146277
|
-
return
|
|
146374
|
+
if (fs61.existsSync(scriptsDir)) {
|
|
146375
|
+
const versions = fs61.readdirSync(scriptsDir).filter((d) => {
|
|
146376
|
+
return fs61.statSync(path59.join(scriptsDir, d)).isDirectory();
|
|
146278
146377
|
}).sort().reverse();
|
|
146279
146378
|
for (const ver of versions) {
|
|
146280
146379
|
const p = path59.join(scriptsDir, ver, "scripts.js");
|
|
146281
|
-
if (
|
|
146380
|
+
if (fs61.existsSync(p)) {
|
|
146282
146381
|
scriptsPath = p;
|
|
146283
146382
|
break;
|
|
146284
146383
|
}
|
|
@@ -146290,7 +146389,7 @@ async (params) => {
|
|
|
146290
146389
|
return;
|
|
146291
146390
|
}
|
|
146292
146391
|
try {
|
|
146293
|
-
const source =
|
|
146392
|
+
const source = fs61.readFileSync(scriptsPath, "utf-8");
|
|
146294
146393
|
const hints = {};
|
|
146295
146394
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
146296
146395
|
let match;
|
|
@@ -147103,7 +147202,7 @@ async (params) => {
|
|
|
147103
147202
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
147104
147203
|
}
|
|
147105
147204
|
}
|
|
147106
|
-
var
|
|
147205
|
+
var fs62 = __toESM2(require("fs"));
|
|
147107
147206
|
var path60 = __toESM2(require("path"));
|
|
147108
147207
|
function slugifyFixtureName(value) {
|
|
147109
147208
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -147119,10 +147218,10 @@ async (params) => {
|
|
|
147119
147218
|
function readCliFixture(ctx, type2, name) {
|
|
147120
147219
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
147121
147220
|
const filePath = path60.join(fixtureDir, `${name}.json`);
|
|
147122
|
-
if (!
|
|
147221
|
+
if (!fs62.existsSync(filePath)) {
|
|
147123
147222
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
147124
147223
|
}
|
|
147125
|
-
return JSON.parse(
|
|
147224
|
+
return JSON.parse(fs62.readFileSync(filePath, "utf-8"));
|
|
147126
147225
|
}
|
|
147127
147226
|
function getExerciseTranscriptText(result) {
|
|
147128
147227
|
const parts = [];
|
|
@@ -147872,7 +147971,7 @@ async (params) => {
|
|
|
147872
147971
|
return;
|
|
147873
147972
|
}
|
|
147874
147973
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
147875
|
-
|
|
147974
|
+
fs62.mkdirSync(fixtureDir, { recursive: true });
|
|
147876
147975
|
const name = slugifyFixtureName(String(body?.name || `${type2}-${Date.now()}`));
|
|
147877
147976
|
const result = await runCliExerciseInternal(ctx, { ...request, type: type2 });
|
|
147878
147977
|
const fixture = {
|
|
@@ -147900,7 +147999,7 @@ async (params) => {
|
|
|
147900
147999
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
147901
148000
|
};
|
|
147902
148001
|
const filePath = path60.join(fixtureDir, `${name}.json`);
|
|
147903
|
-
|
|
148002
|
+
fs62.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
147904
148003
|
ctx.json(res, 200, {
|
|
147905
148004
|
saved: true,
|
|
147906
148005
|
name,
|
|
@@ -147918,14 +148017,14 @@ async (params) => {
|
|
|
147918
148017
|
async function handleCliFixtureList(ctx, type2, _req, res) {
|
|
147919
148018
|
try {
|
|
147920
148019
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
147921
|
-
if (!
|
|
148020
|
+
if (!fs62.existsSync(fixtureDir)) {
|
|
147922
148021
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
147923
148022
|
return;
|
|
147924
148023
|
}
|
|
147925
|
-
const fixtures =
|
|
148024
|
+
const fixtures = fs62.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
147926
148025
|
const fullPath = path60.join(fixtureDir, file2);
|
|
147927
148026
|
try {
|
|
147928
|
-
const raw = JSON.parse(
|
|
148027
|
+
const raw = JSON.parse(fs62.readFileSync(fullPath, "utf-8"));
|
|
147929
148028
|
return {
|
|
147930
148029
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
147931
148030
|
path: fullPath,
|
|
@@ -148056,7 +148155,7 @@ async (params) => {
|
|
|
148056
148155
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
148057
148156
|
}
|
|
148058
148157
|
}
|
|
148059
|
-
var
|
|
148158
|
+
var fs63 = __toESM2(require("fs"));
|
|
148060
148159
|
var path61 = __toESM2(require("path"));
|
|
148061
148160
|
var os34 = __toESM2(require("os"));
|
|
148062
148161
|
var import_session_host_core10 = require_dist();
|
|
@@ -148105,10 +148204,10 @@ async (params) => {
|
|
|
148105
148204
|
return fallback?.type || null;
|
|
148106
148205
|
}
|
|
148107
148206
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
148108
|
-
if (!
|
|
148109
|
-
const versions =
|
|
148207
|
+
if (!fs63.existsSync(scriptsDir)) return null;
|
|
148208
|
+
const versions = fs63.readdirSync(scriptsDir).filter((d) => {
|
|
148110
148209
|
try {
|
|
148111
|
-
return
|
|
148210
|
+
return fs63.statSync(path61.join(scriptsDir, d)).isDirectory();
|
|
148112
148211
|
} catch {
|
|
148113
148212
|
return false;
|
|
148114
148213
|
}
|
|
@@ -148130,13 +148229,13 @@ async (params) => {
|
|
|
148130
148229
|
if (!sourceDir) {
|
|
148131
148230
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
148132
148231
|
}
|
|
148133
|
-
if (!
|
|
148134
|
-
|
|
148135
|
-
|
|
148232
|
+
if (!fs63.existsSync(desiredDir)) {
|
|
148233
|
+
fs63.mkdirSync(path61.dirname(desiredDir), { recursive: true });
|
|
148234
|
+
fs63.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
148136
148235
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
148137
148236
|
}
|
|
148138
148237
|
const providerJson = path61.join(desiredDir, "provider.json");
|
|
148139
|
-
if (!
|
|
148238
|
+
if (!fs63.existsSync(providerJson)) {
|
|
148140
148239
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
148141
148240
|
}
|
|
148142
148241
|
return { dir: desiredDir };
|
|
@@ -148144,15 +148243,15 @@ async (params) => {
|
|
|
148144
148243
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
148145
148244
|
if (!referenceType) return {};
|
|
148146
148245
|
const refDir = ctx.findProviderDir(referenceType);
|
|
148147
|
-
if (!refDir || !
|
|
148246
|
+
if (!refDir || !fs63.existsSync(refDir)) return {};
|
|
148148
148247
|
const referenceScripts = {};
|
|
148149
148248
|
const scriptsDir = path61.join(refDir, "scripts");
|
|
148150
148249
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
148151
148250
|
if (!latestDir) return referenceScripts;
|
|
148152
|
-
for (const file2 of
|
|
148251
|
+
for (const file2 of fs63.readdirSync(latestDir)) {
|
|
148153
148252
|
if (!file2.endsWith(".js")) continue;
|
|
148154
148253
|
try {
|
|
148155
|
-
referenceScripts[file2] =
|
|
148254
|
+
referenceScripts[file2] = fs63.readFileSync(path61.join(latestDir, file2), "utf-8");
|
|
148156
148255
|
} catch {
|
|
148157
148256
|
}
|
|
148158
148257
|
}
|
|
@@ -148261,15 +148360,15 @@ async (params) => {
|
|
|
148261
148360
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
148262
148361
|
const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
148263
148362
|
const tmpDir = path61.join(os34.tmpdir(), "adhdev-autoimpl");
|
|
148264
|
-
if (!
|
|
148363
|
+
if (!fs63.existsSync(tmpDir)) fs63.mkdirSync(tmpDir, { recursive: true });
|
|
148265
148364
|
const promptFile = path61.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
|
|
148266
|
-
|
|
148365
|
+
fs63.writeFileSync(promptFile, prompt, "utf-8");
|
|
148267
148366
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
148268
148367
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
148269
148368
|
const spawn7 = agentProvider?.spawn;
|
|
148270
148369
|
if (!spawn7?.command) {
|
|
148271
148370
|
try {
|
|
148272
|
-
|
|
148371
|
+
fs63.unlinkSync(promptFile);
|
|
148273
148372
|
} catch {
|
|
148274
148373
|
}
|
|
148275
148374
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -148372,7 +148471,7 @@ async (params) => {
|
|
|
148372
148471
|
} catch {
|
|
148373
148472
|
}
|
|
148374
148473
|
try {
|
|
148375
|
-
|
|
148474
|
+
fs63.unlinkSync(promptFile);
|
|
148376
148475
|
} catch {
|
|
148377
148476
|
}
|
|
148378
148477
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})`);
|
|
@@ -148596,7 +148695,7 @@ async (params) => {
|
|
|
148596
148695
|
}
|
|
148597
148696
|
});
|
|
148598
148697
|
try {
|
|
148599
|
-
|
|
148698
|
+
fs63.unlinkSync(promptFile);
|
|
148600
148699
|
} catch {
|
|
148601
148700
|
}
|
|
148602
148701
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -148701,10 +148800,10 @@ async (params) => {
|
|
|
148701
148800
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
148702
148801
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
148703
148802
|
lines.push("");
|
|
148704
|
-
for (const file2 of
|
|
148803
|
+
for (const file2 of fs63.readdirSync(latestScriptsDir)) {
|
|
148705
148804
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
148706
148805
|
try {
|
|
148707
|
-
const content =
|
|
148806
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
148708
148807
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
148709
148808
|
lines.push("```javascript");
|
|
148710
148809
|
lines.push(content);
|
|
@@ -148714,14 +148813,14 @@ async (params) => {
|
|
|
148714
148813
|
}
|
|
148715
148814
|
}
|
|
148716
148815
|
}
|
|
148717
|
-
const refFiles =
|
|
148816
|
+
const refFiles = fs63.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
148718
148817
|
if (refFiles.length > 0) {
|
|
148719
148818
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
148720
148819
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
148721
148820
|
lines.push("");
|
|
148722
148821
|
for (const file2 of refFiles) {
|
|
148723
148822
|
try {
|
|
148724
|
-
const content =
|
|
148823
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
148725
148824
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
148726
148825
|
lines.push("```javascript");
|
|
148727
148826
|
lines.push(content);
|
|
@@ -148766,7 +148865,7 @@ async (params) => {
|
|
|
148766
148865
|
const loadGuide = (name) => {
|
|
148767
148866
|
try {
|
|
148768
148867
|
const p = path61.join(docsDir, name);
|
|
148769
|
-
if (
|
|
148868
|
+
if (fs63.existsSync(p)) return fs63.readFileSync(p, "utf-8");
|
|
148770
148869
|
} catch {
|
|
148771
148870
|
}
|
|
148772
148871
|
return null;
|
|
@@ -149010,11 +149109,11 @@ async (params) => {
|
|
|
149010
149109
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
149011
149110
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
149012
149111
|
lines.push("");
|
|
149013
|
-
for (const file2 of
|
|
149112
|
+
for (const file2 of fs63.readdirSync(latestScriptsDir)) {
|
|
149014
149113
|
if (!file2.endsWith(".js")) continue;
|
|
149015
149114
|
if (!targetFileNames.has(file2)) continue;
|
|
149016
149115
|
try {
|
|
149017
|
-
const content =
|
|
149116
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
149018
149117
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
149019
149118
|
lines.push("```javascript");
|
|
149020
149119
|
lines.push(content);
|
|
@@ -149023,14 +149122,14 @@ async (params) => {
|
|
|
149023
149122
|
} catch {
|
|
149024
149123
|
}
|
|
149025
149124
|
}
|
|
149026
|
-
const refFiles =
|
|
149125
|
+
const refFiles = fs63.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
149027
149126
|
if (refFiles.length > 0) {
|
|
149028
149127
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
149029
149128
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
149030
149129
|
lines.push("");
|
|
149031
149130
|
for (const file2 of refFiles) {
|
|
149032
149131
|
try {
|
|
149033
|
-
const content =
|
|
149132
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
149034
149133
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
149035
149134
|
lines.push("```javascript");
|
|
149036
149135
|
lines.push(content);
|
|
@@ -149067,7 +149166,7 @@ async (params) => {
|
|
|
149067
149166
|
const loadGuide = (name) => {
|
|
149068
149167
|
try {
|
|
149069
149168
|
const p = path61.join(docsDir, name);
|
|
149070
|
-
if (
|
|
149169
|
+
if (fs63.existsSync(p)) return fs63.readFileSync(p, "utf-8");
|
|
149071
149170
|
} catch {
|
|
149072
149171
|
}
|
|
149073
149172
|
return null;
|
|
@@ -149806,7 +149905,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149806
149905
|
path62.join(process.cwd(), "packages/web-devconsole/dist")
|
|
149807
149906
|
];
|
|
149808
149907
|
for (const dir of candidates) {
|
|
149809
|
-
if (
|
|
149908
|
+
if (fs64.existsSync(path62.join(dir, "index.html"))) return dir;
|
|
149810
149909
|
}
|
|
149811
149910
|
return null;
|
|
149812
149911
|
}
|
|
@@ -149818,7 +149917,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149818
149917
|
}
|
|
149819
149918
|
const htmlPath = path62.join(distDir, "index.html");
|
|
149820
149919
|
try {
|
|
149821
|
-
const html =
|
|
149920
|
+
const html = fs64.readFileSync(htmlPath, "utf-8");
|
|
149822
149921
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
149823
149922
|
res.end(html);
|
|
149824
149923
|
} catch (e) {
|
|
@@ -149848,7 +149947,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149848
149947
|
return;
|
|
149849
149948
|
}
|
|
149850
149949
|
try {
|
|
149851
|
-
const content =
|
|
149950
|
+
const content = fs64.readFileSync(filePath);
|
|
149852
149951
|
const ext = path62.extname(filePath);
|
|
149853
149952
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
149854
149953
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -149957,14 +150056,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149957
150056
|
const files = [];
|
|
149958
150057
|
const scan = (d, prefix) => {
|
|
149959
150058
|
try {
|
|
149960
|
-
for (const entry of
|
|
150059
|
+
for (const entry of fs64.readdirSync(d, { withFileTypes: true })) {
|
|
149961
150060
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
149962
150061
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
149963
150062
|
if (entry.isDirectory()) {
|
|
149964
150063
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
149965
150064
|
scan(path62.join(d, entry.name), rel);
|
|
149966
150065
|
} else {
|
|
149967
|
-
const stat2 =
|
|
150066
|
+
const stat2 = fs64.statSync(path62.join(d, entry.name));
|
|
149968
150067
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
149969
150068
|
}
|
|
149970
150069
|
}
|
|
@@ -149992,11 +150091,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149992
150091
|
this.json(res, 403, { error: "Forbidden" });
|
|
149993
150092
|
return;
|
|
149994
150093
|
}
|
|
149995
|
-
if (!
|
|
150094
|
+
if (!fs64.existsSync(fullPath) || fs64.statSync(fullPath).isDirectory()) {
|
|
149996
150095
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
149997
150096
|
return;
|
|
149998
150097
|
}
|
|
149999
|
-
const content =
|
|
150098
|
+
const content = fs64.readFileSync(fullPath, "utf-8");
|
|
150000
150099
|
this.json(res, 200, { type: type2, path: filePath, content, lines: content.split("\n").length });
|
|
150001
150100
|
}
|
|
150002
150101
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -150018,9 +150117,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150018
150117
|
return;
|
|
150019
150118
|
}
|
|
150020
150119
|
try {
|
|
150021
|
-
if (
|
|
150022
|
-
|
|
150023
|
-
|
|
150120
|
+
if (fs64.existsSync(fullPath)) fs64.copyFileSync(fullPath, fullPath + ".bak");
|
|
150121
|
+
fs64.mkdirSync(path62.dirname(fullPath), { recursive: true });
|
|
150122
|
+
fs64.writeFileSync(fullPath, content, "utf-8");
|
|
150024
150123
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
150025
150124
|
this.providerLoader.reload();
|
|
150026
150125
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -150037,8 +150136,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150037
150136
|
}
|
|
150038
150137
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
150039
150138
|
const p = path62.join(dir, name);
|
|
150040
|
-
if (
|
|
150041
|
-
const source =
|
|
150139
|
+
if (fs64.existsSync(p)) {
|
|
150140
|
+
const source = fs64.readFileSync(p, "utf-8");
|
|
150042
150141
|
this.json(res, 200, { type: type2, path: p, source, lines: source.split("\n").length });
|
|
150043
150142
|
return;
|
|
150044
150143
|
}
|
|
@@ -150057,11 +150156,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150057
150156
|
this.json(res, 404, { error: `Provider not found: ${type2}` });
|
|
150058
150157
|
return;
|
|
150059
150158
|
}
|
|
150060
|
-
const target =
|
|
150159
|
+
const target = fs64.existsSync(path62.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
150061
150160
|
const targetPath = path62.join(dir, target);
|
|
150062
150161
|
try {
|
|
150063
|
-
if (
|
|
150064
|
-
|
|
150162
|
+
if (fs64.existsSync(targetPath)) fs64.copyFileSync(targetPath, targetPath + ".bak");
|
|
150163
|
+
fs64.writeFileSync(targetPath, source, "utf-8");
|
|
150065
150164
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
150066
150165
|
this.providerLoader.reload();
|
|
150067
150166
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -150207,20 +150306,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150207
150306
|
let targetDir;
|
|
150208
150307
|
targetDir = this.providerLoader.getUserProviderDir(category, type2);
|
|
150209
150308
|
const jsonPath = path62.join(targetDir, "provider.json");
|
|
150210
|
-
if (
|
|
150309
|
+
if (fs64.existsSync(jsonPath)) {
|
|
150211
150310
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
150212
150311
|
return;
|
|
150213
150312
|
}
|
|
150214
150313
|
try {
|
|
150215
150314
|
const result = generateFiles(type2, name, category, { cdpPorts, cli, processName, installPath, binary: binary2, extensionId, version: version2, osPaths, processNames });
|
|
150216
|
-
|
|
150217
|
-
|
|
150315
|
+
fs64.mkdirSync(targetDir, { recursive: true });
|
|
150316
|
+
fs64.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
150218
150317
|
const createdFiles = ["provider.json"];
|
|
150219
150318
|
if (result.files) {
|
|
150220
150319
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
150221
150320
|
const fullPath = path62.join(targetDir, relPath);
|
|
150222
|
-
|
|
150223
|
-
|
|
150321
|
+
fs64.mkdirSync(path62.dirname(fullPath), { recursive: true });
|
|
150322
|
+
fs64.writeFileSync(fullPath, content, "utf-8");
|
|
150224
150323
|
createdFiles.push(relPath);
|
|
150225
150324
|
}
|
|
150226
150325
|
}
|
|
@@ -150269,10 +150368,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150269
150368
|
}
|
|
150270
150369
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
150271
150370
|
getLatestScriptVersionDir(scriptsDir) {
|
|
150272
|
-
if (!
|
|
150273
|
-
const versions =
|
|
150371
|
+
if (!fs64.existsSync(scriptsDir)) return null;
|
|
150372
|
+
const versions = fs64.readdirSync(scriptsDir).filter((d) => {
|
|
150274
150373
|
try {
|
|
150275
|
-
return
|
|
150374
|
+
return fs64.statSync(path62.join(scriptsDir, d)).isDirectory();
|
|
150276
150375
|
} catch {
|
|
150277
150376
|
return false;
|
|
150278
150377
|
}
|
|
@@ -150294,13 +150393,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150294
150393
|
if (!sourceDir) {
|
|
150295
150394
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
150296
150395
|
}
|
|
150297
|
-
if (!
|
|
150298
|
-
|
|
150299
|
-
|
|
150396
|
+
if (!fs64.existsSync(desiredDir)) {
|
|
150397
|
+
fs64.mkdirSync(path62.dirname(desiredDir), { recursive: true });
|
|
150398
|
+
fs64.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
150300
150399
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
150301
150400
|
}
|
|
150302
150401
|
const providerJson = path62.join(desiredDir, "provider.json");
|
|
150303
|
-
if (!
|
|
150402
|
+
if (!fs64.existsSync(providerJson)) {
|
|
150304
150403
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
150305
150404
|
}
|
|
150306
150405
|
return { dir: desiredDir };
|
|
@@ -151109,7 +151208,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151109
151208
|
}
|
|
151110
151209
|
}
|
|
151111
151210
|
var import_child_process14 = require("child_process");
|
|
151112
|
-
var
|
|
151211
|
+
var fs65 = __toESM2(require("fs"));
|
|
151113
151212
|
var os35 = __toESM2(require("os"));
|
|
151114
151213
|
var path63 = __toESM2(require("path"));
|
|
151115
151214
|
var import_session_host_core14 = require_dist();
|
|
@@ -151136,7 +151235,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151136
151235
|
path63.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
151137
151236
|
];
|
|
151138
151237
|
for (const candidate of packagedCandidates) {
|
|
151139
|
-
if (
|
|
151238
|
+
if (fs65.existsSync(candidate)) {
|
|
151140
151239
|
return candidate;
|
|
151141
151240
|
}
|
|
151142
151241
|
}
|
|
@@ -151156,8 +151255,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151156
151255
|
function getPid() {
|
|
151157
151256
|
try {
|
|
151158
151257
|
const pidFile = getPidFile();
|
|
151159
|
-
if (!
|
|
151160
|
-
const pid = Number.parseInt(
|
|
151258
|
+
if (!fs65.existsSync(pidFile)) return null;
|
|
151259
|
+
const pid = Number.parseInt(fs65.readFileSync(pidFile, "utf8").trim(), 10);
|
|
151161
151260
|
return Number.isFinite(pid) ? pid : null;
|
|
151162
151261
|
} catch {
|
|
151163
151262
|
return null;
|
|
@@ -151207,7 +151306,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151207
151306
|
if (markerIndex === -1) return;
|
|
151208
151307
|
const activePrefix = entry.slice(0, markerIndex);
|
|
151209
151308
|
const candidates = resolveConptyPrebuildCandidates(activePrefix);
|
|
151210
|
-
const found = candidates.find((candidate) =>
|
|
151309
|
+
const found = candidates.find((candidate) => fs65.existsSync(candidate));
|
|
151211
151310
|
if (!found) {
|
|
151212
151311
|
throw new Error(
|
|
151213
151312
|
`conpty.node missing at boot despite passing the install-time gate \u2014 likely deleted post-install (checked: ${candidates.join(", ")}). Every session-host spawn would crash requiring node-pty; refusing to spawn.`
|
|
@@ -151224,8 +151323,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151224
151323
|
let logFd = null;
|
|
151225
151324
|
if (options.spawnStdio === "logfile") {
|
|
151226
151325
|
const logDir = path63.join(instance().configDir, "logs");
|
|
151227
|
-
|
|
151228
|
-
logFd =
|
|
151326
|
+
fs65.mkdirSync(logDir, { recursive: true });
|
|
151327
|
+
logFd = fs65.openSync(path63.join(logDir, "session-host.log"), "a");
|
|
151229
151328
|
stdio = ["ignore", logFd, logFd];
|
|
151230
151329
|
}
|
|
151231
151330
|
const child = (0, import_child_process14.spawn)(nodeExecutable, [entry], {
|
|
@@ -151250,7 +151349,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151250
151349
|
if (typeof child?.unref === "function") child.unref();
|
|
151251
151350
|
if (logFd !== null) {
|
|
151252
151351
|
try {
|
|
151253
|
-
|
|
151352
|
+
fs65.closeSync(logFd);
|
|
151254
151353
|
} catch {
|
|
151255
151354
|
}
|
|
151256
151355
|
}
|
|
@@ -151268,8 +151367,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151268
151367
|
const pidFile = getPidFile();
|
|
151269
151368
|
let keepPidFile = false;
|
|
151270
151369
|
try {
|
|
151271
|
-
if (
|
|
151272
|
-
const pid = Number.parseInt(
|
|
151370
|
+
if (fs65.existsSync(pidFile)) {
|
|
151371
|
+
const pid = Number.parseInt(fs65.readFileSync(pidFile, "utf8").trim(), 10);
|
|
151273
151372
|
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
151274
151373
|
const managed = isManagedPid(pid);
|
|
151275
151374
|
if (managed) {
|
|
@@ -151289,7 +151388,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151289
151388
|
} finally {
|
|
151290
151389
|
if (!keepPidFile) {
|
|
151291
151390
|
try {
|
|
151292
|
-
|
|
151391
|
+
fs65.unlinkSync(pidFile);
|
|
151293
151392
|
} catch {
|
|
151294
151393
|
}
|
|
151295
151394
|
}
|
|
@@ -151325,7 +151424,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151325
151424
|
}
|
|
151326
151425
|
if (!reported) return;
|
|
151327
151426
|
if (pathsEquivalent(reported, currentEntry)) return;
|
|
151328
|
-
const reportedExists =
|
|
151427
|
+
const reportedExists = fs65.existsSync(reported);
|
|
151329
151428
|
LOG2.warn(
|
|
151330
151429
|
"SessionHost",
|
|
151331
151430
|
`Reachable session-host reports it is running from ${reported}${reportedExists ? "" : " (which no longer exists)"}, but this install runs from ${currentEntry}. That host would fail every create_session loading node-pty from its own prefix; stopping it so a current one is spawned in its place.`
|
|
@@ -151553,8 +151652,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151553
151652
|
const res = await fetch(extension.vsixUrl);
|
|
151554
151653
|
if (res.ok) {
|
|
151555
151654
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
151556
|
-
const
|
|
151557
|
-
|
|
151655
|
+
const fs67 = await import("fs");
|
|
151656
|
+
fs67.writeFileSync(vsixPath, buffer);
|
|
151558
151657
|
return new Promise((resolve32) => {
|
|
151559
151658
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
151560
151659
|
(0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -154363,7 +154462,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
154363
154462
|
Object.values(V1_PRIMITIVE_CATALOG).flat()
|
|
154364
154463
|
);
|
|
154365
154464
|
var V1_CONTRACT_VERSION = "1.0.0";
|
|
154366
|
-
var
|
|
154465
|
+
var fs66 = __toESM2(require("fs"));
|
|
154367
154466
|
var import_chalk2 = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
154368
154467
|
init_dist();
|
|
154369
154468
|
var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
|
|
@@ -154518,7 +154617,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
154518
154617
|
console.log(import_chalk2.default.gray(` Backup: ${status.paths.backupFile}`));
|
|
154519
154618
|
let snapshotMtimeMs = null;
|
|
154520
154619
|
try {
|
|
154521
|
-
snapshotMtimeMs =
|
|
154620
|
+
snapshotMtimeMs = fs66.statSync(status.paths.snapshotFile).mtimeMs;
|
|
154522
154621
|
} catch {
|
|
154523
154622
|
}
|
|
154524
154623
|
console.log(import_chalk2.default.gray(
|