@adhdev/daemon-standalone 1.0.58-rc.47 → 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 +579 -447
- 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);
|
|
@@ -68137,6 +68137,35 @@ CREATE TABLE IF NOT EXISTS sq_archive (
|
|
|
68137
68137
|
ledgerReadCache.set(meshId, { entries, cachedAt: Date.now() });
|
|
68138
68138
|
return entries;
|
|
68139
68139
|
}
|
|
68140
|
+
function filteredLedgerCacheKey(opts) {
|
|
68141
|
+
const kinds = opts.kinds ? [...new Set(opts.kinds)].sort() : [];
|
|
68142
|
+
return JSON.stringify([opts.since ?? null, kinds]);
|
|
68143
|
+
}
|
|
68144
|
+
function getCachedFilteredRawEntries(meshId, opts) {
|
|
68145
|
+
const key2 = filteredLedgerCacheKey(opts);
|
|
68146
|
+
let meshCache = filteredLedgerReadCache.get(meshId);
|
|
68147
|
+
if (meshCache) {
|
|
68148
|
+
const now = Date.now();
|
|
68149
|
+
for (const [cachedKey, entry] of meshCache) {
|
|
68150
|
+
if (now - entry.cachedAt >= LEDGER_CACHE_TTL_MS) meshCache.delete(cachedKey);
|
|
68151
|
+
}
|
|
68152
|
+
if (meshCache.size === 0) {
|
|
68153
|
+
filteredLedgerReadCache.delete(meshId);
|
|
68154
|
+
meshCache = void 0;
|
|
68155
|
+
}
|
|
68156
|
+
}
|
|
68157
|
+
const cached5 = meshCache?.get(key2);
|
|
68158
|
+
if (cached5) return cached5.entries;
|
|
68159
|
+
const entries = readLedgerFromStore(meshId, opts);
|
|
68160
|
+
recordLedgerPushdownScan(entries.length);
|
|
68161
|
+
const targetCache = meshCache ?? /* @__PURE__ */ new Map();
|
|
68162
|
+
targetCache.set(key2, { entries, cachedAt: Date.now() });
|
|
68163
|
+
if (!meshCache) filteredLedgerReadCache.set(meshId, targetCache);
|
|
68164
|
+
return entries;
|
|
68165
|
+
}
|
|
68166
|
+
function invalidateFilteredLedgerCache(meshId) {
|
|
68167
|
+
filteredLedgerReadCache.delete(meshId);
|
|
68168
|
+
}
|
|
68140
68169
|
function entryTimeValue(entry) {
|
|
68141
68170
|
const t = new Date(entry.timestamp).getTime();
|
|
68142
68171
|
return Number.isNaN(t) ? NaN : t;
|
|
@@ -68156,19 +68185,24 @@ CREATE TABLE IF NOT EXISTS sq_archive (
|
|
|
68156
68185
|
return true;
|
|
68157
68186
|
}
|
|
68158
68187
|
function recordLedgerAppend(meshId, newEntries) {
|
|
68188
|
+
invalidateFilteredLedgerCache(meshId);
|
|
68159
68189
|
if (!appendToLedgerCache(meshId, newEntries)) invalidateLedgerCache(meshId);
|
|
68160
68190
|
}
|
|
68161
68191
|
function invalidateLedgerCache(meshId) {
|
|
68162
68192
|
ledgerReadCache.delete(meshId);
|
|
68193
|
+
invalidateFilteredLedgerCache(meshId);
|
|
68163
68194
|
}
|
|
68164
68195
|
function clearLedgerImportFlag(meshId) {
|
|
68165
68196
|
ledgerImportDone.delete(meshId);
|
|
68197
|
+
invalidateFilteredLedgerCache(meshId);
|
|
68166
68198
|
}
|
|
68167
68199
|
function invalidateAllLedgerCaches() {
|
|
68168
68200
|
ledgerReadCache.clear();
|
|
68201
|
+
filteredLedgerReadCache.clear();
|
|
68169
68202
|
}
|
|
68170
68203
|
var import_fs12;
|
|
68171
68204
|
var ledgerReadCache;
|
|
68205
|
+
var filteredLedgerReadCache;
|
|
68172
68206
|
var LEDGER_CACHE_TTL_MS;
|
|
68173
68207
|
var ledgerImportStoreRef;
|
|
68174
68208
|
var ledgerImportDone;
|
|
@@ -68183,6 +68217,7 @@ CREATE TABLE IF NOT EXISTS sq_archive (
|
|
|
68183
68217
|
init_logger();
|
|
68184
68218
|
init_mesh_ledger_paths();
|
|
68185
68219
|
ledgerReadCache = /* @__PURE__ */ new Map();
|
|
68220
|
+
filteredLedgerReadCache = /* @__PURE__ */ new Map();
|
|
68186
68221
|
LEDGER_CACHE_TTL_MS = 3e4;
|
|
68187
68222
|
ledgerImportDone = /* @__PURE__ */ new Set();
|
|
68188
68223
|
ledgerScanStats = {
|
|
@@ -68791,12 +68826,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
68791
68826
|
const kinds = opts?.kind?.length ? opts.kind : void 0;
|
|
68792
68827
|
if (!hasSince && !kinds) return getCachedRawEntries(meshId);
|
|
68793
68828
|
try {
|
|
68794
|
-
|
|
68829
|
+
return getCachedFilteredRawEntries(meshId, {
|
|
68795
68830
|
...hasSince ? { since: opts.since } : {},
|
|
68796
68831
|
...kinds ? { kinds } : {}
|
|
68797
68832
|
});
|
|
68798
|
-
recordLedgerPushdownScan(entries.length);
|
|
68799
|
-
return entries;
|
|
68800
68833
|
} catch {
|
|
68801
68834
|
return getCachedRawEntries(meshId);
|
|
68802
68835
|
}
|
|
@@ -71243,8 +71276,8 @@ ${rendered}`, "utf-8");
|
|
|
71243
71276
|
if (!(0, import_node_fs3.existsSync)(filePath)) return;
|
|
71244
71277
|
if (owned) {
|
|
71245
71278
|
try {
|
|
71246
|
-
const
|
|
71247
|
-
|
|
71279
|
+
const fs67 = require("fs");
|
|
71280
|
+
fs67.unlinkSync(filePath);
|
|
71248
71281
|
} catch {
|
|
71249
71282
|
}
|
|
71250
71283
|
return;
|
|
@@ -71257,8 +71290,8 @@ ${rendered}`, "utf-8");
|
|
|
71257
71290
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
71258
71291
|
if (!remaining.trim()) {
|
|
71259
71292
|
try {
|
|
71260
|
-
const
|
|
71261
|
-
|
|
71293
|
+
const fs67 = require("fs");
|
|
71294
|
+
fs67.unlinkSync(filePath);
|
|
71262
71295
|
} catch {
|
|
71263
71296
|
}
|
|
71264
71297
|
} else {
|
|
@@ -77364,9 +77397,30 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
77364
77397
|
const cleaned = cleanupHistoryContent(agentType, message.role, message.content);
|
|
77365
77398
|
return `${message.kind || "standard"}:${message.role}:${normalizeHistoryComparable(cleaned)}`;
|
|
77366
77399
|
}
|
|
77367
|
-
function isAdjacentHistoryDuplicate(agentType, previous, next) {
|
|
77400
|
+
function isAdjacentHistoryDuplicate(agentType, previous, next, signatureFor = buildHistoryMessageSignature) {
|
|
77368
77401
|
if (!previous || !next) return false;
|
|
77369
|
-
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;
|
|
77370
77424
|
}
|
|
77371
77425
|
function collapseReplayAssistantTurns(messages, historyBehavior) {
|
|
77372
77426
|
if (!historyBehavior?.collapseConsecutiveAssistantTurns) return messages;
|
|
@@ -77863,15 +77917,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
77863
77917
|
function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeRecentCount = 0, historyBehavior) {
|
|
77864
77918
|
const allMessages = records.map((message) => sanitizeHistoryMessage(agentType, message)).filter(Boolean);
|
|
77865
77919
|
allMessages.sort((a, b) => a.receivedAt - b.receivedAt);
|
|
77866
|
-
const chronological =
|
|
77867
|
-
let lastTurn = null;
|
|
77868
|
-
for (const message of allMessages) {
|
|
77869
|
-
const previous = chronological[chronological.length - 1];
|
|
77870
|
-
if (isAdjacentHistoryDuplicate(agentType, previous, message)) continue;
|
|
77871
|
-
if (message.role !== "system" && isAdjacentHistoryDuplicate(agentType, lastTurn, message)) continue;
|
|
77872
|
-
chronological.push(message);
|
|
77873
|
-
if (message.role !== "system") lastTurn = message;
|
|
77874
|
-
}
|
|
77920
|
+
const chronological = dedupeAdjacentHistoryMessages(agentType, allMessages);
|
|
77875
77921
|
const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
|
|
77876
77922
|
const boundedLimit = normalizePaginationNumber(limit, 30, 1);
|
|
77877
77923
|
const boundedOffset = normalizePaginationNumber(offset, 0, 0);
|
|
@@ -78814,15 +78860,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
78814
78860
|
next.push(sanitized);
|
|
78815
78861
|
}
|
|
78816
78862
|
next.sort((a, b) => a.receivedAt - b.receivedAt);
|
|
78817
|
-
const dedupedAdjacent =
|
|
78818
|
-
let lastTurn = null;
|
|
78819
|
-
for (const entry of next) {
|
|
78820
|
-
const previous = dedupedAdjacent[dedupedAdjacent.length - 1];
|
|
78821
|
-
if (isAdjacentHistoryDuplicate(agentType, previous, entry)) continue;
|
|
78822
|
-
if (entry.role !== "system" && isAdjacentHistoryDuplicate(agentType, lastTurn, entry)) continue;
|
|
78823
|
-
dedupedAdjacent.push(entry);
|
|
78824
|
-
if (entry.role !== "system") lastTurn = entry;
|
|
78825
|
-
}
|
|
78863
|
+
const dedupedAdjacent = dedupeAdjacentHistoryMessages(agentType, next);
|
|
78826
78864
|
const collapsed = collapseReplayAssistantTurns(dedupedAdjacent, historyBehavior);
|
|
78827
78865
|
if (collapsed.length === 0) {
|
|
78828
78866
|
fs17.unlinkSync(filePath);
|
|
@@ -89102,13 +89140,15 @@ ${cleanBody}`;
|
|
|
89102
89140
|
oversized: 0,
|
|
89103
89141
|
dropped: 0,
|
|
89104
89142
|
collectorUnavailable: 0,
|
|
89105
|
-
sourcePending: 0
|
|
89143
|
+
sourcePending: 0,
|
|
89144
|
+
ptyDirtyCoalesced: 0
|
|
89106
89145
|
};
|
|
89107
89146
|
}
|
|
89108
89147
|
function redactSessionId(id) {
|
|
89109
89148
|
return id.length <= 8 ? id : `${id.slice(0, 8)}\u2026(${id.length})`;
|
|
89110
89149
|
}
|
|
89111
89150
|
function configureTranscriptProjection(deps) {
|
|
89151
|
+
activeService?.dispose();
|
|
89112
89152
|
activeService = deps ? new TranscriptProjectionService(deps) : null;
|
|
89113
89153
|
return activeService;
|
|
89114
89154
|
}
|
|
@@ -89118,8 +89158,12 @@ ${cleanBody}`;
|
|
|
89118
89158
|
function markTranscriptSessionDirty(sessionId) {
|
|
89119
89159
|
activeService?.markDirty(sessionId);
|
|
89120
89160
|
}
|
|
89161
|
+
function markTranscriptPtyOutputActivity(sessionId) {
|
|
89162
|
+
activeService?.markPtyOutputActivity(sessionId);
|
|
89163
|
+
}
|
|
89121
89164
|
var import_node_crypto4;
|
|
89122
89165
|
var MAX_TRACKED_SESSIONS;
|
|
89166
|
+
var TRANSCRIPT_PTY_DIRTY_THROTTLE_MS;
|
|
89123
89167
|
var TranscriptProjectionService;
|
|
89124
89168
|
var activeService;
|
|
89125
89169
|
var init_transcript_publisher = __esm2({
|
|
@@ -89132,6 +89176,7 @@ ${cleanBody}`;
|
|
|
89132
89176
|
init_transcript_observation();
|
|
89133
89177
|
init_transcript_mode();
|
|
89134
89178
|
MAX_TRACKED_SESSIONS = 512;
|
|
89179
|
+
TRANSCRIPT_PTY_DIRTY_THROTTLE_MS = 350;
|
|
89135
89180
|
TranscriptProjectionService = class {
|
|
89136
89181
|
deps;
|
|
89137
89182
|
epoch;
|
|
@@ -89143,6 +89188,9 @@ ${cleanBody}`;
|
|
|
89143
89188
|
inFlight = /* @__PURE__ */ new Set();
|
|
89144
89189
|
pendingObservation = /* @__PURE__ */ new Map();
|
|
89145
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();
|
|
89146
89194
|
constructor(deps) {
|
|
89147
89195
|
this.deps = deps;
|
|
89148
89196
|
this.epoch = deps.epoch ?? (0, import_node_crypto4.randomUUID)();
|
|
@@ -89176,6 +89224,41 @@ ${cleanBody}`;
|
|
|
89176
89224
|
if (!this.admitSession(sessionId)) return;
|
|
89177
89225
|
void this.runPull(sessionId);
|
|
89178
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
|
+
}
|
|
89179
89262
|
/**
|
|
89180
89263
|
* Explicit alias for the restart/activation seed-read entry point (design
|
|
89181
89264
|
* §5.2: "activation 직후와 daemon restart 직후에는 해당 세션을 즉시
|
|
@@ -89283,6 +89366,12 @@ ${cleanBody}`;
|
|
|
89283
89366
|
get trackedSessionCount() {
|
|
89284
89367
|
return this.sessionState.size;
|
|
89285
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
|
+
}
|
|
89286
89375
|
};
|
|
89287
89376
|
activeService = null;
|
|
89288
89377
|
}
|
|
@@ -93383,8 +93472,8 @@ ${cleanBody}`;
|
|
|
93383
93472
|
let cwd = options.cwd;
|
|
93384
93473
|
if (cwd) {
|
|
93385
93474
|
try {
|
|
93386
|
-
const
|
|
93387
|
-
const stat2 =
|
|
93475
|
+
const fs67 = require("fs");
|
|
93476
|
+
const stat2 = fs67.statSync(cwd);
|
|
93388
93477
|
if (!stat2.isDirectory()) cwd = os19.homedir();
|
|
93389
93478
|
} catch {
|
|
93390
93479
|
cwd = os19.homedir();
|
|
@@ -95505,7 +95594,7 @@ ${tail}`;
|
|
|
95505
95594
|
}
|
|
95506
95595
|
function probeGitAncestry(cwd, ancestor, descendant) {
|
|
95507
95596
|
try {
|
|
95508
|
-
if (!
|
|
95597
|
+
if (!fs52.existsSync(cwd)) return "undeterminable";
|
|
95509
95598
|
} catch {
|
|
95510
95599
|
return "undeterminable";
|
|
95511
95600
|
}
|
|
@@ -95576,7 +95665,7 @@ ${tail}`;
|
|
|
95576
95665
|
};
|
|
95577
95666
|
if (present()) return true;
|
|
95578
95667
|
try {
|
|
95579
|
-
if (!
|
|
95668
|
+
if (!fs52.existsSync(submoduleRepoPath) || !fs52.existsSync(baseSubmoduleRepoPath)) return false;
|
|
95580
95669
|
} catch {
|
|
95581
95670
|
return false;
|
|
95582
95671
|
}
|
|
@@ -95718,7 +95807,7 @@ ${tail}`;
|
|
|
95718
95807
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
95719
95808
|
};
|
|
95720
95809
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
95721
|
-
if (!
|
|
95810
|
+
if (!fs52.existsSync(worktreeSubmodulePath)) return false;
|
|
95722
95811
|
try {
|
|
95723
95812
|
await runGit4(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
95724
95813
|
} catch {
|
|
@@ -95760,7 +95849,7 @@ ${tail}`;
|
|
|
95760
95849
|
};
|
|
95761
95850
|
let submoduleDefaultBranch = "main";
|
|
95762
95851
|
try {
|
|
95763
|
-
if (!
|
|
95852
|
+
if (!fs52.existsSync(submodulePath)) {
|
|
95764
95853
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
95765
95854
|
entry.publishRequired = true;
|
|
95766
95855
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -95925,7 +96014,7 @@ ${tail}`;
|
|
|
95925
96014
|
};
|
|
95926
96015
|
}
|
|
95927
96016
|
}
|
|
95928
|
-
var
|
|
96017
|
+
var fs52;
|
|
95929
96018
|
var import_node_child_process9;
|
|
95930
96019
|
var import_path18;
|
|
95931
96020
|
var GIT2;
|
|
@@ -95936,7 +96025,7 @@ ${tail}`;
|
|
|
95936
96025
|
var init_mesh_refine_gitlink_utils = __esm2({
|
|
95937
96026
|
"src/mesh/mesh-refine-gitlink-utils.ts"() {
|
|
95938
96027
|
"use strict";
|
|
95939
|
-
|
|
96028
|
+
fs52 = __toESM2(require("fs"));
|
|
95940
96029
|
import_node_child_process9 = require("child_process");
|
|
95941
96030
|
import_path18 = require("path");
|
|
95942
96031
|
init_logger();
|
|
@@ -95993,7 +96082,7 @@ ${tail}`;
|
|
|
95993
96082
|
if (!baseCommit || !branchCommit) return "undeterminable";
|
|
95994
96083
|
if (baseCommit === branchCommit) return "not_diverged";
|
|
95995
96084
|
try {
|
|
95996
|
-
if (!
|
|
96085
|
+
if (!fs53.existsSync(submoduleRepoPath)) return "undeterminable";
|
|
95997
96086
|
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
95998
96087
|
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
95999
96088
|
} catch {
|
|
@@ -96328,7 +96417,7 @@ ${tail}`;
|
|
|
96328
96417
|
}
|
|
96329
96418
|
return { ok: true, branchHead };
|
|
96330
96419
|
}
|
|
96331
|
-
var
|
|
96420
|
+
var fs53;
|
|
96332
96421
|
var import_path19;
|
|
96333
96422
|
var import_node_child_process10;
|
|
96334
96423
|
var SUBMODULE_PUBLISH_REQUIRED_RECOMMENDED_ACTION;
|
|
@@ -96336,7 +96425,7 @@ ${tail}`;
|
|
|
96336
96425
|
var init_mesh_refine_submodule_converge = __esm2({
|
|
96337
96426
|
"src/mesh/mesh-refine-submodule-converge.ts"() {
|
|
96338
96427
|
"use strict";
|
|
96339
|
-
|
|
96428
|
+
fs53 = __toESM2(require("fs"));
|
|
96340
96429
|
import_path19 = require("path");
|
|
96341
96430
|
import_node_child_process10 = require("child_process");
|
|
96342
96431
|
init_mesh_refine_gitlink_utils();
|
|
@@ -96352,12 +96441,12 @@ ${tail}`;
|
|
|
96352
96441
|
function writeValidationFailureLog(workspace, index, candidate, streams, now = () => /* @__PURE__ */ new Date()) {
|
|
96353
96442
|
try {
|
|
96354
96443
|
const dir = (0, import_path20.join)(workspace, REFINE_VALIDATION_LOG_DIR);
|
|
96355
|
-
|
|
96444
|
+
fs54.mkdirSync(dir, { recursive: true });
|
|
96356
96445
|
const stamp2 = now().toISOString().replace(/[:.]/g, "-");
|
|
96357
96446
|
const file2 = (0, import_path20.join)(dir, `refine-${stamp2}-${index}.log`);
|
|
96358
96447
|
const asText = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
96359
96448
|
const shown = candidate.displayCommand || [candidate.command, ...candidate.args || []].join(" ");
|
|
96360
|
-
|
|
96449
|
+
fs54.writeFileSync(
|
|
96361
96450
|
file2,
|
|
96362
96451
|
`# refine validation failure
|
|
96363
96452
|
# command: ${shown}
|
|
@@ -96954,7 +97043,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
96954
97043
|
return newTree || void 0;
|
|
96955
97044
|
} finally {
|
|
96956
97045
|
try {
|
|
96957
|
-
|
|
97046
|
+
fs54.rmSync(tmpIndex, { force: true });
|
|
96958
97047
|
} catch {
|
|
96959
97048
|
}
|
|
96960
97049
|
}
|
|
@@ -97029,7 +97118,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97029
97118
|
return newTree || void 0;
|
|
97030
97119
|
} finally {
|
|
97031
97120
|
try {
|
|
97032
|
-
|
|
97121
|
+
fs54.rmSync(tmpIndex, { force: true });
|
|
97033
97122
|
} catch {
|
|
97034
97123
|
}
|
|
97035
97124
|
}
|
|
@@ -97218,9 +97307,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97218
97307
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
97219
97308
|
};
|
|
97220
97309
|
const dependenciesLikelyMissing = (cwd) => {
|
|
97221
|
-
if (!
|
|
97222
|
-
if (
|
|
97223
|
-
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)));
|
|
97224
97313
|
};
|
|
97225
97314
|
const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
|
|
97226
97315
|
const isDaemonScopedCommand = (candidate) => {
|
|
@@ -97390,7 +97479,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97390
97479
|
return summary;
|
|
97391
97480
|
}
|
|
97392
97481
|
var import_path20;
|
|
97393
|
-
var
|
|
97482
|
+
var fs54;
|
|
97394
97483
|
var import_node_child_process11;
|
|
97395
97484
|
var REFINE_VALIDATION_TIMEOUT_MS;
|
|
97396
97485
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES;
|
|
@@ -97402,7 +97491,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97402
97491
|
init_refine_config();
|
|
97403
97492
|
init_worktree_bootstrap_config();
|
|
97404
97493
|
import_path20 = require("path");
|
|
97405
|
-
|
|
97494
|
+
fs54 = __toESM2(require("fs"));
|
|
97406
97495
|
import_node_child_process11 = require("child_process");
|
|
97407
97496
|
init_resolve_executable();
|
|
97408
97497
|
init_mesh_refine_worker_cap();
|
|
@@ -112899,7 +112988,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
112899
112988
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
112900
112989
|
return { success: false, error: `unknown category: ${category}` };
|
|
112901
112990
|
}
|
|
112902
|
-
const
|
|
112991
|
+
const fs67 = require("fs");
|
|
112903
112992
|
const path64 = require("path");
|
|
112904
112993
|
try {
|
|
112905
112994
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -112908,9 +112997,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
112908
112997
|
if (!targetDir.startsWith(installRootResolved + path64.sep)) {
|
|
112909
112998
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
112910
112999
|
}
|
|
112911
|
-
const hadUpstreamDir =
|
|
113000
|
+
const hadUpstreamDir = fs67.existsSync(targetDir);
|
|
112912
113001
|
if (hadUpstreamDir) {
|
|
112913
|
-
|
|
113002
|
+
fs67.rmSync(targetDir, { recursive: true, force: true });
|
|
112914
113003
|
}
|
|
112915
113004
|
let channelDeactivated = false;
|
|
112916
113005
|
try {
|
|
@@ -112939,28 +113028,28 @@ ${effect.notification.body || ""}`.trim();
|
|
|
112939
113028
|
* the UI and by the update checker.
|
|
112940
113029
|
*/
|
|
112941
113030
|
handleListInstalledProviders(_args) {
|
|
112942
|
-
const
|
|
113031
|
+
const fs67 = require("fs");
|
|
112943
113032
|
const path64 = require("path");
|
|
112944
113033
|
const installRoot = this.getUpstreamInstallRoot();
|
|
112945
|
-
if (!
|
|
113034
|
+
if (!fs67.existsSync(installRoot)) return { success: true, providers: [] };
|
|
112946
113035
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
112947
113036
|
const items = [];
|
|
112948
113037
|
for (const category of CATEGORIES) {
|
|
112949
113038
|
const categoryDir = path64.join(installRoot, category);
|
|
112950
|
-
if (!
|
|
113039
|
+
if (!fs67.existsSync(categoryDir)) continue;
|
|
112951
113040
|
let entries;
|
|
112952
113041
|
try {
|
|
112953
|
-
entries =
|
|
113042
|
+
entries = fs67.readdirSync(categoryDir);
|
|
112954
113043
|
} catch {
|
|
112955
113044
|
continue;
|
|
112956
113045
|
}
|
|
112957
113046
|
for (const type2 of entries) {
|
|
112958
113047
|
const v1Path = path64.join(categoryDir, type2, "provider.v1.json");
|
|
112959
113048
|
const v0Path = path64.join(categoryDir, type2, "provider.json");
|
|
112960
|
-
const manifestPath =
|
|
113049
|
+
const manifestPath = fs67.existsSync(v1Path) ? v1Path : fs67.existsSync(v0Path) ? v0Path : null;
|
|
112961
113050
|
if (!manifestPath) continue;
|
|
112962
113051
|
try {
|
|
112963
|
-
const m = JSON.parse(
|
|
113052
|
+
const m = JSON.parse(fs67.readFileSync(manifestPath, "utf-8"));
|
|
112964
113053
|
const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
112965
113054
|
const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
112966
113055
|
items.push({
|
|
@@ -113226,7 +113315,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113226
113315
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
113227
113316
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
113228
113317
|
}
|
|
113229
|
-
const
|
|
113318
|
+
const fs67 = require("fs");
|
|
113230
113319
|
const path64 = require("path");
|
|
113231
113320
|
const { spawnSync: spawnSync3 } = require("child_process");
|
|
113232
113321
|
const file2 = ext.loadExternalSources();
|
|
@@ -113237,8 +113326,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113237
113326
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
113238
113327
|
}
|
|
113239
113328
|
const sourceDir = path64.join(ext.externalRoot(), requestedName);
|
|
113240
|
-
if (!
|
|
113241
|
-
if (
|
|
113329
|
+
if (!fs67.existsSync(ext.externalRoot())) fs67.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
113330
|
+
if (fs67.existsSync(sourceDir)) {
|
|
113242
113331
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
113243
113332
|
}
|
|
113244
113333
|
const clone2 = spawnSync3("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -113248,7 +113337,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113248
113337
|
});
|
|
113249
113338
|
if (clone2.status !== 0) {
|
|
113250
113339
|
try {
|
|
113251
|
-
|
|
113340
|
+
fs67.rmSync(sourceDir, { recursive: true, force: true });
|
|
113252
113341
|
} catch {
|
|
113253
113342
|
}
|
|
113254
113343
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -113292,15 +113381,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113292
113381
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
113293
113382
|
if (!name) return { success: false, error: "name is required" };
|
|
113294
113383
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
113295
|
-
const
|
|
113384
|
+
const fs67 = require("fs");
|
|
113296
113385
|
const path64 = require("path");
|
|
113297
113386
|
const file2 = ext.loadExternalSources();
|
|
113298
113387
|
const match = file2.sources.find((s2) => s2.name === name);
|
|
113299
113388
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
113300
113389
|
const sourceDir = path64.join(ext.externalRoot(), name);
|
|
113301
|
-
if (
|
|
113390
|
+
if (fs67.existsSync(sourceDir)) {
|
|
113302
113391
|
try {
|
|
113303
|
-
|
|
113392
|
+
fs67.rmSync(sourceDir, { recursive: true, force: true });
|
|
113304
113393
|
} catch (e) {
|
|
113305
113394
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
113306
113395
|
}
|
|
@@ -115945,14 +116034,14 @@ ${marker}`,
|
|
|
115945
116034
|
}
|
|
115946
116035
|
},
|
|
115947
116036
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
115948
|
-
const
|
|
116037
|
+
const fs67 = await import("fs");
|
|
115949
116038
|
const path64 = await import("path");
|
|
115950
116039
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
115951
116040
|
const dir = path64.join(getConfigDir22(), "coordinator-prompts");
|
|
115952
116041
|
const entries = {};
|
|
115953
116042
|
try {
|
|
115954
|
-
if (
|
|
115955
|
-
for (const name of
|
|
116043
|
+
if (fs67.existsSync(dir)) {
|
|
116044
|
+
for (const name of fs67.readdirSync(dir)) {
|
|
115956
116045
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
115957
116046
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
115958
116047
|
const m = matchAppend || matchOverride;
|
|
@@ -115962,7 +116051,7 @@ ${marker}`,
|
|
|
115962
116051
|
const full = path64.join(dir, name);
|
|
115963
116052
|
let content = "";
|
|
115964
116053
|
try {
|
|
115965
|
-
content =
|
|
116054
|
+
content = fs67.readFileSync(full, "utf8");
|
|
115966
116055
|
} catch {
|
|
115967
116056
|
}
|
|
115968
116057
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -115976,7 +116065,7 @@ ${marker}`,
|
|
|
115976
116065
|
return { success: true, dir, entries };
|
|
115977
116066
|
},
|
|
115978
116067
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
115979
|
-
const
|
|
116068
|
+
const fs67 = await import("fs");
|
|
115980
116069
|
const path64 = await import("path");
|
|
115981
116070
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
115982
116071
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -115989,11 +116078,11 @@ ${marker}`,
|
|
|
115989
116078
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
115990
116079
|
const full = path64.join(dir, filename);
|
|
115991
116080
|
try {
|
|
115992
|
-
|
|
116081
|
+
fs67.mkdirSync(dir, { recursive: true });
|
|
115993
116082
|
if (content.trim()) {
|
|
115994
|
-
|
|
115995
|
-
} else if (
|
|
115996
|
-
|
|
116083
|
+
fs67.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
116084
|
+
} else if (fs67.existsSync(full)) {
|
|
116085
|
+
fs67.unlinkSync(full);
|
|
115997
116086
|
}
|
|
115998
116087
|
return { success: true, path: full, kind, key: key2 };
|
|
115999
116088
|
} catch (error48) {
|
|
@@ -117040,7 +117129,7 @@ ${marker}`,
|
|
|
117040
117129
|
var import_fs22 = require("fs");
|
|
117041
117130
|
var import_child_process11 = require("child_process");
|
|
117042
117131
|
var import_chalk = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
117043
|
-
var
|
|
117132
|
+
var fs422 = __toESM2(require("fs"));
|
|
117044
117133
|
var path46 = __toESM2(require("path"));
|
|
117045
117134
|
var fs31 = __toESM2(require("fs"));
|
|
117046
117135
|
var os23 = __toESM2(require("os"));
|
|
@@ -118900,7 +118989,7 @@ ${marker}`,
|
|
|
118900
118989
|
return { start, end };
|
|
118901
118990
|
}
|
|
118902
118991
|
init_evaluator();
|
|
118903
|
-
var
|
|
118992
|
+
var fs33 = __toESM2(require("fs"));
|
|
118904
118993
|
var os24 = __toESM2(require("os"));
|
|
118905
118994
|
var path39 = __toESM2(require("path"));
|
|
118906
118995
|
init_logger();
|
|
@@ -118966,6 +119055,66 @@ ${marker}`,
|
|
|
118966
119055
|
}
|
|
118967
119056
|
}
|
|
118968
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
|
+
}
|
|
118969
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;
|
|
118970
119119
|
function executeNativeHistory(cfg, input) {
|
|
118971
119120
|
if (!cfg?.source) return null;
|
|
@@ -119115,14 +119264,15 @@ ${marker}`,
|
|
|
119115
119264
|
const wsRaw = typeof input.workspace === "string" ? input.workspace : "";
|
|
119116
119265
|
let wsReal = wsRaw;
|
|
119117
119266
|
try {
|
|
119118
|
-
if (wsRaw) wsReal =
|
|
119267
|
+
if (wsRaw) wsReal = fs33.realpathSync(wsRaw);
|
|
119119
119268
|
} catch {
|
|
119120
119269
|
}
|
|
119121
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)`);
|
|
119122
119271
|
return null;
|
|
119123
119272
|
}
|
|
119124
119273
|
const mtime = safeMtimeMs(sourcePath);
|
|
119125
|
-
const
|
|
119274
|
+
const forceRefresh = input.forceRefresh === true || input.args?.forceRefresh === true;
|
|
119275
|
+
const lines = readJsonlLines(sourcePath, forceRefresh);
|
|
119126
119276
|
if (lines.length === 0) return null;
|
|
119127
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);
|
|
119128
119278
|
let providerSessionId;
|
|
@@ -119257,7 +119407,7 @@ ${marker}`,
|
|
|
119257
119407
|
} else {
|
|
119258
119408
|
let stat2 = null;
|
|
119259
119409
|
try {
|
|
119260
|
-
stat2 =
|
|
119410
|
+
stat2 = fs33.statSync(resolved);
|
|
119261
119411
|
} catch {
|
|
119262
119412
|
}
|
|
119263
119413
|
if (stat2 && stat2.isFile()) {
|
|
@@ -119272,7 +119422,7 @@ ${marker}`,
|
|
|
119272
119422
|
const resolvedRaw = expandPath2(src.path, input, { skipWorkspaceRealpath: true });
|
|
119273
119423
|
if (resolvedRaw && resolvedRaw !== resolved) {
|
|
119274
119424
|
try {
|
|
119275
|
-
const rawStat =
|
|
119425
|
+
const rawStat = fs33.statSync(resolvedRaw);
|
|
119276
119426
|
if (rawStat.isFile()) sourcePath = resolvedRaw;
|
|
119277
119427
|
else if (rawStat.isDirectory()) {
|
|
119278
119428
|
sourcePath = pickExactSessionFile(resolvedRaw, filePat, requestedSessionId) || (requestedSessionId ? null : newestRecentFile(resolvedRaw, filePat, windowMs, sessionFloor));
|
|
@@ -119289,7 +119439,7 @@ ${marker}`,
|
|
|
119289
119439
|
}
|
|
119290
119440
|
function claimKeyForPath(p) {
|
|
119291
119441
|
try {
|
|
119292
|
-
return
|
|
119442
|
+
return fs33.realpathSync(p);
|
|
119293
119443
|
} catch {
|
|
119294
119444
|
return p;
|
|
119295
119445
|
}
|
|
@@ -119351,7 +119501,7 @@ ${marker}`,
|
|
|
119351
119501
|
function listSidecarWorkspaceCandidates(template, pattern, windowMs, sessionFloorMs, workspaceHint, sidecar) {
|
|
119352
119502
|
let wsResolved = workspaceHint;
|
|
119353
119503
|
try {
|
|
119354
|
-
wsResolved =
|
|
119504
|
+
wsResolved = fs33.realpathSync(workspaceHint);
|
|
119355
119505
|
} catch {
|
|
119356
119506
|
}
|
|
119357
119507
|
const dirs = expandDirGlob(template);
|
|
@@ -119365,7 +119515,7 @@ ${marker}`,
|
|
|
119365
119515
|
if (!ws) continue;
|
|
119366
119516
|
let wsReal = ws;
|
|
119367
119517
|
try {
|
|
119368
|
-
wsReal =
|
|
119518
|
+
wsReal = fs33.realpathSync(ws);
|
|
119369
119519
|
} catch {
|
|
119370
119520
|
}
|
|
119371
119521
|
if (ws !== workspaceHint && wsReal !== wsResolved) continue;
|
|
@@ -119386,7 +119536,7 @@ ${marker}`,
|
|
|
119386
119536
|
function readSidecarWorkspace(sourcePath, cfg) {
|
|
119387
119537
|
try {
|
|
119388
119538
|
const sidecar = path39.resolve(path39.dirname(sourcePath), cfg.rel_path);
|
|
119389
|
-
const parsed = JSON.parse(
|
|
119539
|
+
const parsed = JSON.parse(fs33.readFileSync(sidecar, "utf8"));
|
|
119390
119540
|
const v = jsonPathGet(parsed, cfg.workspace_path);
|
|
119391
119541
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
119392
119542
|
} catch {
|
|
@@ -119474,7 +119624,7 @@ ${marker}`,
|
|
|
119474
119624
|
if (!wsRaw) return void 0;
|
|
119475
119625
|
let wsReal = wsRaw;
|
|
119476
119626
|
try {
|
|
119477
|
-
wsReal =
|
|
119627
|
+
wsReal = fs33.realpathSync(wsRaw);
|
|
119478
119628
|
} catch {
|
|
119479
119629
|
}
|
|
119480
119630
|
const slugs = /* @__PURE__ */ new Set();
|
|
@@ -119502,27 +119652,9 @@ ${marker}`,
|
|
|
119502
119652
|
}
|
|
119503
119653
|
return void 0;
|
|
119504
119654
|
}
|
|
119505
|
-
function readJsonlLines(p) {
|
|
119506
|
-
let text;
|
|
119507
|
-
try {
|
|
119508
|
-
text = fs322.readFileSync(p, "utf8");
|
|
119509
|
-
} catch {
|
|
119510
|
-
return [];
|
|
119511
|
-
}
|
|
119512
|
-
const out = [];
|
|
119513
|
-
for (const line of text.split("\n")) {
|
|
119514
|
-
const trimmed = line.trim();
|
|
119515
|
-
if (!trimmed) continue;
|
|
119516
|
-
try {
|
|
119517
|
-
out.push(JSON.parse(trimmed));
|
|
119518
|
-
} catch {
|
|
119519
|
-
}
|
|
119520
|
-
}
|
|
119521
|
-
return out;
|
|
119522
|
-
}
|
|
119523
119655
|
function executeSqlite(src, input) {
|
|
119524
119656
|
const resolved = expandPath2(src.path, input);
|
|
119525
|
-
if (!resolved || !
|
|
119657
|
+
if (!resolved || !fs33.existsSync(resolved)) return null;
|
|
119526
119658
|
let Database;
|
|
119527
119659
|
try {
|
|
119528
119660
|
Database = loadBetterSqlite3();
|
|
@@ -119661,7 +119793,7 @@ ${marker}`,
|
|
|
119661
119793
|
let workspaceResolved = workspaceRaw;
|
|
119662
119794
|
if (workspaceRaw && !opts?.skipWorkspaceRealpath) {
|
|
119663
119795
|
try {
|
|
119664
|
-
workspaceResolved =
|
|
119796
|
+
workspaceResolved = fs33.realpathSync(workspaceRaw);
|
|
119665
119797
|
} catch {
|
|
119666
119798
|
}
|
|
119667
119799
|
}
|
|
@@ -119703,7 +119835,7 @@ ${marker}`,
|
|
|
119703
119835
|
if (!base) return null;
|
|
119704
119836
|
let baseStat = null;
|
|
119705
119837
|
try {
|
|
119706
|
-
baseStat =
|
|
119838
|
+
baseStat = fs33.statSync(base);
|
|
119707
119839
|
} catch {
|
|
119708
119840
|
return null;
|
|
119709
119841
|
}
|
|
@@ -119711,7 +119843,7 @@ ${marker}`,
|
|
|
119711
119843
|
const needle = `${requestedSessionId.toLowerCase()}.jsonl`;
|
|
119712
119844
|
const dirsToScan = [base];
|
|
119713
119845
|
try {
|
|
119714
|
-
for (const entry of
|
|
119846
|
+
for (const entry of fs33.readdirSync(base, { withFileTypes: true })) {
|
|
119715
119847
|
if (entry.isDirectory()) dirsToScan.push(path39.join(base, entry.name));
|
|
119716
119848
|
}
|
|
119717
119849
|
} catch {
|
|
@@ -119719,7 +119851,7 @@ ${marker}`,
|
|
|
119719
119851
|
for (const dir of dirsToScan) {
|
|
119720
119852
|
let entries;
|
|
119721
119853
|
try {
|
|
119722
|
-
entries =
|
|
119854
|
+
entries = fs33.readdirSync(dir, { withFileTypes: true });
|
|
119723
119855
|
} catch {
|
|
119724
119856
|
continue;
|
|
119725
119857
|
}
|
|
@@ -119759,7 +119891,7 @@ ${marker}`,
|
|
|
119759
119891
|
for (const d of dirs) {
|
|
119760
119892
|
let entries;
|
|
119761
119893
|
try {
|
|
119762
|
-
entries =
|
|
119894
|
+
entries = fs33.readdirSync(d, { withFileTypes: true });
|
|
119763
119895
|
} catch {
|
|
119764
119896
|
continue;
|
|
119765
119897
|
}
|
|
@@ -119772,7 +119904,7 @@ ${marker}`,
|
|
|
119772
119904
|
const candidate = path39.join(d, seg);
|
|
119773
119905
|
let stat2 = null;
|
|
119774
119906
|
try {
|
|
119775
|
-
stat2 =
|
|
119907
|
+
stat2 = fs33.statSync(candidate);
|
|
119776
119908
|
} catch {
|
|
119777
119909
|
continue;
|
|
119778
119910
|
}
|
|
@@ -119816,7 +119948,7 @@ ${marker}`,
|
|
|
119816
119948
|
function walkAllDirs(root, out) {
|
|
119817
119949
|
let entries;
|
|
119818
119950
|
try {
|
|
119819
|
-
entries =
|
|
119951
|
+
entries = fs33.readdirSync(root, { withFileTypes: true });
|
|
119820
119952
|
} catch {
|
|
119821
119953
|
return;
|
|
119822
119954
|
}
|
|
@@ -119832,7 +119964,7 @@ ${marker}`,
|
|
|
119832
119964
|
for (const d of dirs) {
|
|
119833
119965
|
let entries;
|
|
119834
119966
|
try {
|
|
119835
|
-
entries =
|
|
119967
|
+
entries = fs33.readdirSync(d, { withFileTypes: true });
|
|
119836
119968
|
} catch {
|
|
119837
119969
|
continue;
|
|
119838
119970
|
}
|
|
@@ -119859,7 +119991,7 @@ ${marker}`,
|
|
|
119859
119991
|
if (!resolved) continue;
|
|
119860
119992
|
let entries;
|
|
119861
119993
|
try {
|
|
119862
|
-
entries =
|
|
119994
|
+
entries = fs33.readdirSync(resolved, { withFileTypes: true });
|
|
119863
119995
|
} catch {
|
|
119864
119996
|
continue;
|
|
119865
119997
|
}
|
|
@@ -119888,7 +120020,7 @@ ${marker}`,
|
|
|
119888
120020
|
let workspaceResolved = workspaceRaw;
|
|
119889
120021
|
if (workspaceRaw) {
|
|
119890
120022
|
try {
|
|
119891
|
-
workspaceResolved =
|
|
120023
|
+
workspaceResolved = fs33.realpathSync(workspaceRaw);
|
|
119892
120024
|
} catch {
|
|
119893
120025
|
}
|
|
119894
120026
|
}
|
|
@@ -119913,7 +120045,7 @@ ${marker}`,
|
|
|
119913
120045
|
function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
|
|
119914
120046
|
let entries;
|
|
119915
120047
|
try {
|
|
119916
|
-
entries =
|
|
120048
|
+
entries = fs33.readdirSync(dir, { withFileTypes: true });
|
|
119917
120049
|
} catch {
|
|
119918
120050
|
return null;
|
|
119919
120051
|
}
|
|
@@ -119930,14 +120062,14 @@ ${marker}`,
|
|
|
119930
120062
|
}
|
|
119931
120063
|
function safeMtimeMs(p) {
|
|
119932
120064
|
try {
|
|
119933
|
-
return Math.floor(
|
|
120065
|
+
return Math.floor(fs33.statSync(p).mtimeMs);
|
|
119934
120066
|
} catch {
|
|
119935
120067
|
return 0;
|
|
119936
120068
|
}
|
|
119937
120069
|
}
|
|
119938
120070
|
function safeBirthtimeMs(p) {
|
|
119939
120071
|
try {
|
|
119940
|
-
const st =
|
|
120072
|
+
const st = fs33.statSync(p);
|
|
119941
120073
|
const birth = Math.floor(st.birthtimeMs);
|
|
119942
120074
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
119943
120075
|
} catch {
|
|
@@ -119998,10 +120130,10 @@ ${marker}`,
|
|
|
119998
120130
|
}
|
|
119999
120131
|
function readCandidateSessionMeta(filePath) {
|
|
120000
120132
|
try {
|
|
120001
|
-
const fd =
|
|
120133
|
+
const fd = fs33.openSync(filePath, "r");
|
|
120002
120134
|
try {
|
|
120003
120135
|
const buf = Buffer.alloc(8192);
|
|
120004
|
-
const bytes =
|
|
120136
|
+
const bytes = fs33.readSync(fd, buf, 0, buf.length, 0);
|
|
120005
120137
|
if (bytes <= 0) return null;
|
|
120006
120138
|
const text = buf.subarray(0, bytes).toString("utf8");
|
|
120007
120139
|
const nl = text.indexOf("\n");
|
|
@@ -120019,7 +120151,7 @@ ${marker}`,
|
|
|
120019
120151
|
sessionTimestampMs: Number.isFinite(tsMs) ? tsMs : void 0
|
|
120020
120152
|
};
|
|
120021
120153
|
} finally {
|
|
120022
|
-
|
|
120154
|
+
fs33.closeSync(fd);
|
|
120023
120155
|
}
|
|
120024
120156
|
} catch {
|
|
120025
120157
|
return null;
|
|
@@ -120029,7 +120161,7 @@ ${marker}`,
|
|
|
120029
120161
|
if (!sessionFloorMs || !workspaceHint || candidatePaths.length === 0) return null;
|
|
120030
120162
|
let workspaceResolved = workspaceHint;
|
|
120031
120163
|
try {
|
|
120032
|
-
workspaceResolved =
|
|
120164
|
+
workspaceResolved = fs33.realpathSync(workspaceHint);
|
|
120033
120165
|
} catch {
|
|
120034
120166
|
}
|
|
120035
120167
|
let best = null;
|
|
@@ -120038,7 +120170,7 @@ ${marker}`,
|
|
|
120038
120170
|
if (!meta3 || !meta3.cwd || meta3.sessionTimestampMs == null) continue;
|
|
120039
120171
|
let candidateCwd = meta3.cwd;
|
|
120040
120172
|
try {
|
|
120041
|
-
candidateCwd =
|
|
120173
|
+
candidateCwd = fs33.realpathSync(meta3.cwd);
|
|
120042
120174
|
} catch {
|
|
120043
120175
|
}
|
|
120044
120176
|
if (candidateCwd !== workspaceResolved && meta3.cwd !== workspaceHint) continue;
|
|
@@ -120051,7 +120183,7 @@ ${marker}`,
|
|
|
120051
120183
|
function listMatchingFiles(dir, pattern) {
|
|
120052
120184
|
let entries;
|
|
120053
120185
|
try {
|
|
120054
|
-
entries =
|
|
120186
|
+
entries = fs33.readdirSync(dir, { withFileTypes: true });
|
|
120055
120187
|
} catch {
|
|
120056
120188
|
return [];
|
|
120057
120189
|
}
|
|
@@ -120343,12 +120475,12 @@ ${marker}`,
|
|
|
120343
120475
|
}
|
|
120344
120476
|
return t.negate ? !result : result;
|
|
120345
120477
|
}
|
|
120346
|
-
var
|
|
120478
|
+
var fs40 = __toESM2(require("fs"));
|
|
120347
120479
|
init_logger();
|
|
120348
|
-
var
|
|
120480
|
+
var fs39 = __toESM2(require("fs"));
|
|
120349
120481
|
var os28 = __toESM2(require("os"));
|
|
120350
120482
|
var path45 = __toESM2(require("path"));
|
|
120351
|
-
var
|
|
120483
|
+
var fs34 = __toESM2(require("fs"));
|
|
120352
120484
|
var path40 = __toESM2(require("path"));
|
|
120353
120485
|
function extractTimestampValue(value) {
|
|
120354
120486
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
@@ -120362,7 +120494,7 @@ ${marker}`,
|
|
|
120362
120494
|
}
|
|
120363
120495
|
function statMtimeMs(filePath) {
|
|
120364
120496
|
try {
|
|
120365
|
-
return
|
|
120497
|
+
return fs34.statSync(filePath).mtimeMs;
|
|
120366
120498
|
} catch {
|
|
120367
120499
|
return 0;
|
|
120368
120500
|
}
|
|
@@ -120445,7 +120577,7 @@ ${marker}`,
|
|
|
120445
120577
|
function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
|
|
120446
120578
|
let raw;
|
|
120447
120579
|
try {
|
|
120448
|
-
raw =
|
|
120580
|
+
raw = fs34.readFileSync(filePath, "utf-8");
|
|
120449
120581
|
} catch {
|
|
120450
120582
|
return { messages: [], usageRecords: [] };
|
|
120451
120583
|
}
|
|
@@ -120531,7 +120663,7 @@ ${marker}`,
|
|
|
120531
120663
|
if (!sessionPath || !path40.isAbsolute(sessionPath)) return null;
|
|
120532
120664
|
const basename22 = path40.basename(sessionPath, ".jsonl");
|
|
120533
120665
|
if (!isSafeSessionId(basename22)) return null;
|
|
120534
|
-
if (!
|
|
120666
|
+
if (!fs34.existsSync(sessionPath)) return null;
|
|
120535
120667
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
120536
120668
|
const { messages, usageRecords } = parseTranscriptFile(sessionPath, basename22);
|
|
120537
120669
|
if (messages.length === 0) return null;
|
|
@@ -120554,7 +120686,7 @@ ${marker}`,
|
|
|
120554
120686
|
}
|
|
120555
120687
|
return session;
|
|
120556
120688
|
}
|
|
120557
|
-
var
|
|
120689
|
+
var fs35 = __toESM2(require("fs"));
|
|
120558
120690
|
var path41 = __toESM2(require("path"));
|
|
120559
120691
|
init_native_turn_signal();
|
|
120560
120692
|
var CODEX_DEFAULT_COMPLETION_SIGNAL = {
|
|
@@ -120575,7 +120707,7 @@ ${marker}`,
|
|
|
120575
120707
|
}
|
|
120576
120708
|
function statMtimeMs2(filePath) {
|
|
120577
120709
|
try {
|
|
120578
|
-
return
|
|
120710
|
+
return fs35.statSync(filePath).mtimeMs;
|
|
120579
120711
|
} catch {
|
|
120580
120712
|
return 0;
|
|
120581
120713
|
}
|
|
@@ -120691,7 +120823,7 @@ ${marker}`,
|
|
|
120691
120823
|
}
|
|
120692
120824
|
function readSessionMeta(filePath) {
|
|
120693
120825
|
try {
|
|
120694
|
-
const firstLine =
|
|
120826
|
+
const firstLine = fs35.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
|
|
120695
120827
|
if (!firstLine) return null;
|
|
120696
120828
|
const parsed = JSON.parse(firstLine);
|
|
120697
120829
|
if (String(parsed.type ?? "") !== "session_meta") return null;
|
|
@@ -120703,7 +120835,7 @@ ${marker}`,
|
|
|
120703
120835
|
function parseSessionFile(filePath, sessionId, workspaceFallback, completionSignal = CODEX_DEFAULT_COMPLETION_SIGNAL) {
|
|
120704
120836
|
let raw;
|
|
120705
120837
|
try {
|
|
120706
|
-
raw =
|
|
120838
|
+
raw = fs35.readFileSync(filePath, "utf-8");
|
|
120707
120839
|
} catch {
|
|
120708
120840
|
return { messages: [], usageRecords: [], turnTerminalMarkers: [] };
|
|
120709
120841
|
}
|
|
@@ -120839,7 +120971,7 @@ ${marker}`,
|
|
|
120839
120971
|
}
|
|
120840
120972
|
function readSession2(sessionPath, nativeHistory) {
|
|
120841
120973
|
if (!sessionPath || !path41.isAbsolute(sessionPath)) return null;
|
|
120842
|
-
if (!
|
|
120974
|
+
if (!fs35.existsSync(sessionPath)) return null;
|
|
120843
120975
|
const meta3 = readSessionMeta(sessionPath);
|
|
120844
120976
|
const metaId = String(meta3?.id ?? "").trim();
|
|
120845
120977
|
const basename22 = path41.basename(sessionPath, ".jsonl");
|
|
@@ -120878,7 +121010,7 @@ ${marker}`,
|
|
|
120878
121010
|
if (turnTerminalMarkers.length > 0) session.turnTerminalMarkers = turnTerminalMarkers;
|
|
120879
121011
|
return session;
|
|
120880
121012
|
}
|
|
120881
|
-
var
|
|
121013
|
+
var fs36 = __toESM2(require("fs"));
|
|
120882
121014
|
var path422 = __toESM2(require("path"));
|
|
120883
121015
|
var os25 = __toESM2(require("os"));
|
|
120884
121016
|
init_load_better_sqlite3();
|
|
@@ -120895,7 +121027,7 @@ ${marker}`,
|
|
|
120895
121027
|
}
|
|
120896
121028
|
function statMtimeMs3(filePath) {
|
|
120897
121029
|
try {
|
|
120898
|
-
return
|
|
121030
|
+
return fs36.statSync(filePath).mtimeMs;
|
|
120899
121031
|
} catch {
|
|
120900
121032
|
return 0;
|
|
120901
121033
|
}
|
|
@@ -120924,12 +121056,12 @@ ${marker}`,
|
|
|
120924
121056
|
function findBrainTranscriptPath(sessionId) {
|
|
120925
121057
|
if (!isUuidLike(sessionId)) return null;
|
|
120926
121058
|
const logsRoot = resolvePathInside(brainRoot(), sessionId, ".system_generated", "logs");
|
|
120927
|
-
if (!logsRoot || !
|
|
120928
|
-
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));
|
|
120929
121061
|
if (candidates.length === 0) {
|
|
120930
121062
|
let entries = [];
|
|
120931
121063
|
try {
|
|
120932
|
-
entries =
|
|
121064
|
+
entries = fs36.readdirSync(logsRoot, { withFileTypes: true });
|
|
120933
121065
|
} catch {
|
|
120934
121066
|
return null;
|
|
120935
121067
|
}
|
|
@@ -120955,7 +121087,7 @@ ${marker}`,
|
|
|
120955
121087
|
function parseBrainTranscript(filePath, sessionId, workspace) {
|
|
120956
121088
|
let raw;
|
|
120957
121089
|
try {
|
|
120958
|
-
raw =
|
|
121090
|
+
raw = fs36.readFileSync(filePath, "utf-8");
|
|
120959
121091
|
} catch {
|
|
120960
121092
|
return null;
|
|
120961
121093
|
}
|
|
@@ -121015,7 +121147,7 @@ ${marker}`,
|
|
|
121015
121147
|
const sourcePath = historyJsonlPath();
|
|
121016
121148
|
let lines = [];
|
|
121017
121149
|
try {
|
|
121018
|
-
lines =
|
|
121150
|
+
lines = fs36.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
121019
121151
|
} catch {
|
|
121020
121152
|
return [];
|
|
121021
121153
|
}
|
|
@@ -121063,7 +121195,7 @@ ${marker}`,
|
|
|
121063
121195
|
function parsePbFile(filePath, sessionId) {
|
|
121064
121196
|
let buf;
|
|
121065
121197
|
try {
|
|
121066
|
-
buf =
|
|
121198
|
+
buf = fs36.readFileSync(filePath);
|
|
121067
121199
|
} catch {
|
|
121068
121200
|
return null;
|
|
121069
121201
|
}
|
|
@@ -121528,7 +121660,7 @@ ${marker}`,
|
|
|
121528
121660
|
}
|
|
121529
121661
|
}
|
|
121530
121662
|
const pbPath = resolvePathInside(conversationsRoot(), `${sessionId}.pb`);
|
|
121531
|
-
if (pbPath &&
|
|
121663
|
+
if (pbPath && fs36.existsSync(pbPath)) {
|
|
121532
121664
|
const pbMessages = parsePbFile(pbPath, sessionId);
|
|
121533
121665
|
if (pbMessages && pbMessages.length > 0) {
|
|
121534
121666
|
return {
|
|
@@ -121547,7 +121679,7 @@ ${marker}`,
|
|
|
121547
121679
|
}
|
|
121548
121680
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
121549
121681
|
if (!sessionPath || !path422.isAbsolute(sessionPath)) return null;
|
|
121550
|
-
if (!
|
|
121682
|
+
if (!fs36.existsSync(sessionPath)) return null;
|
|
121551
121683
|
const sourceMtimeMs = statMtimeMs3(sessionPath);
|
|
121552
121684
|
const brainRootPath = brainRoot();
|
|
121553
121685
|
if (sessionPath.startsWith(brainRootPath + path422.sep) && sessionPath.endsWith(".jsonl")) {
|
|
@@ -121606,7 +121738,7 @@ ${marker}`,
|
|
|
121606
121738
|
}
|
|
121607
121739
|
return null;
|
|
121608
121740
|
}
|
|
121609
|
-
var
|
|
121741
|
+
var fs37 = __toESM2(require("fs"));
|
|
121610
121742
|
var path43 = __toESM2(require("path"));
|
|
121611
121743
|
var os26 = __toESM2(require("os"));
|
|
121612
121744
|
init_load_better_sqlite3();
|
|
@@ -121614,13 +121746,13 @@ ${marker}`,
|
|
|
121614
121746
|
var HERMES_LEGACY_SESSIONS_DIR = path43.join(os26.homedir(), ".hermes", "sessions");
|
|
121615
121747
|
function statMtimeMs4(p) {
|
|
121616
121748
|
try {
|
|
121617
|
-
return Math.floor(
|
|
121749
|
+
return Math.floor(fs37.statSync(p).mtimeMs);
|
|
121618
121750
|
} catch {
|
|
121619
121751
|
return 0;
|
|
121620
121752
|
}
|
|
121621
121753
|
}
|
|
121622
121754
|
function openDb() {
|
|
121623
|
-
if (!
|
|
121755
|
+
if (!fs37.existsSync(HERMES_STATE_DB)) return null;
|
|
121624
121756
|
try {
|
|
121625
121757
|
const Database = loadBetterSqlite3();
|
|
121626
121758
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
@@ -121788,10 +121920,10 @@ ${marker}`,
|
|
|
121788
121920
|
}
|
|
121789
121921
|
}
|
|
121790
121922
|
}
|
|
121791
|
-
if (!path43.isAbsolute(sessionPath) || !
|
|
121923
|
+
if (!path43.isAbsolute(sessionPath) || !fs37.existsSync(sessionPath)) return null;
|
|
121792
121924
|
let raw;
|
|
121793
121925
|
try {
|
|
121794
|
-
raw = JSON.parse(
|
|
121926
|
+
raw = JSON.parse(fs37.readFileSync(sessionPath, "utf8"));
|
|
121795
121927
|
} catch {
|
|
121796
121928
|
return null;
|
|
121797
121929
|
}
|
|
@@ -121831,7 +121963,7 @@ ${marker}`,
|
|
|
121831
121963
|
if (s2 === "tool" || s2 === "tool_result" || s2 === "function") return "assistant";
|
|
121832
121964
|
return "system";
|
|
121833
121965
|
}
|
|
121834
|
-
var
|
|
121966
|
+
var fs38 = __toESM2(require("fs"));
|
|
121835
121967
|
var path44 = __toESM2(require("path"));
|
|
121836
121968
|
var os27 = __toESM2(require("os"));
|
|
121837
121969
|
function grokSessionsRoot() {
|
|
@@ -121843,7 +121975,7 @@ ${marker}`,
|
|
|
121843
121975
|
}
|
|
121844
121976
|
function statMtimeMs5(filePath) {
|
|
121845
121977
|
try {
|
|
121846
|
-
return
|
|
121978
|
+
return fs38.statSync(filePath).mtimeMs;
|
|
121847
121979
|
} catch {
|
|
121848
121980
|
return 0;
|
|
121849
121981
|
}
|
|
@@ -121854,7 +121986,7 @@ ${marker}`,
|
|
|
121854
121986
|
function workspaceCandidates(workspace) {
|
|
121855
121987
|
const out = [workspace];
|
|
121856
121988
|
try {
|
|
121857
|
-
const real =
|
|
121989
|
+
const real = fs38.realpathSync(workspace);
|
|
121858
121990
|
if (real && real !== workspace) out.push(real);
|
|
121859
121991
|
} catch {
|
|
121860
121992
|
}
|
|
@@ -121863,22 +121995,22 @@ ${marker}`,
|
|
|
121863
121995
|
function resolveGrokPath(workspace, sessionId) {
|
|
121864
121996
|
if (!sessionId || !isUuidLike2(sessionId)) return null;
|
|
121865
121997
|
const root = grokSessionsRoot();
|
|
121866
|
-
if (!
|
|
121998
|
+
if (!fs38.existsSync(root)) return null;
|
|
121867
121999
|
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
121868
122000
|
if (!candidate) continue;
|
|
121869
122001
|
const file2 = path44.join(root, encodeWorkspaceDir(candidate), sessionId, "chat_history.jsonl");
|
|
121870
|
-
if (
|
|
122002
|
+
if (fs38.existsSync(file2)) return file2;
|
|
121871
122003
|
}
|
|
121872
122004
|
let entries = [];
|
|
121873
122005
|
try {
|
|
121874
|
-
entries =
|
|
122006
|
+
entries = fs38.readdirSync(root, { withFileTypes: true });
|
|
121875
122007
|
} catch {
|
|
121876
122008
|
return null;
|
|
121877
122009
|
}
|
|
121878
122010
|
for (const entry of entries) {
|
|
121879
122011
|
if (!entry.isDirectory()) continue;
|
|
121880
122012
|
const file2 = path44.join(root, entry.name, sessionId, "chat_history.jsonl");
|
|
121881
|
-
if (
|
|
122013
|
+
if (fs38.existsSync(file2)) return file2;
|
|
121882
122014
|
}
|
|
121883
122015
|
return null;
|
|
121884
122016
|
}
|
|
@@ -121932,7 +122064,7 @@ ${marker}`,
|
|
|
121932
122064
|
}
|
|
121933
122065
|
function readSessionCreatedAtMs(sessionDir) {
|
|
121934
122066
|
try {
|
|
121935
|
-
const summary = JSON.parse(
|
|
122067
|
+
const summary = JSON.parse(fs38.readFileSync(path44.join(sessionDir, "summary.json"), "utf8"));
|
|
121936
122068
|
const created = summary?.created_at;
|
|
121937
122069
|
if (typeof created === "string") {
|
|
121938
122070
|
const parsed = Date.parse(created);
|
|
@@ -121945,7 +122077,7 @@ ${marker}`,
|
|
|
121945
122077
|
function readSession5(sourcePath, sessionId, workspace) {
|
|
121946
122078
|
let text;
|
|
121947
122079
|
try {
|
|
121948
|
-
text =
|
|
122080
|
+
text = fs38.readFileSync(sourcePath, "utf8");
|
|
121949
122081
|
} catch {
|
|
121950
122082
|
return null;
|
|
121951
122083
|
}
|
|
@@ -121995,26 +122127,26 @@ ${marker}`,
|
|
|
121995
122127
|
}
|
|
121996
122128
|
function listSessions(workspace, limit = 50) {
|
|
121997
122129
|
const root = grokSessionsRoot();
|
|
121998
|
-
if (!
|
|
122130
|
+
if (!fs38.existsSync(root)) return [];
|
|
121999
122131
|
const dirs = [];
|
|
122000
122132
|
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
122001
122133
|
if (!candidate) continue;
|
|
122002
122134
|
const dir = path44.join(root, encodeWorkspaceDir(candidate));
|
|
122003
|
-
if (
|
|
122135
|
+
if (fs38.existsSync(dir)) dirs.push(dir);
|
|
122004
122136
|
}
|
|
122005
122137
|
if (dirs.length === 0) return [];
|
|
122006
122138
|
const out = [];
|
|
122007
122139
|
for (const dir of dirs) {
|
|
122008
122140
|
let entries = [];
|
|
122009
122141
|
try {
|
|
122010
|
-
entries =
|
|
122142
|
+
entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
122011
122143
|
} catch {
|
|
122012
122144
|
continue;
|
|
122013
122145
|
}
|
|
122014
122146
|
for (const entry of entries) {
|
|
122015
122147
|
if (!entry.isDirectory() || !isUuidLike2(entry.name)) continue;
|
|
122016
122148
|
const sourcePath = path44.join(dir, entry.name, "chat_history.jsonl");
|
|
122017
|
-
if (!
|
|
122149
|
+
if (!fs38.existsSync(sourcePath)) continue;
|
|
122018
122150
|
const session = readSession5(sourcePath, entry.name, workspace);
|
|
122019
122151
|
if (!session || session.messages.length === 0) continue;
|
|
122020
122152
|
const first = session.messages[0];
|
|
@@ -122044,10 +122176,10 @@ ${marker}`,
|
|
|
122044
122176
|
}
|
|
122045
122177
|
function listSessionsAllWorkspaces(limit = 50) {
|
|
122046
122178
|
const root = grokSessionsRoot();
|
|
122047
|
-
if (!
|
|
122179
|
+
if (!fs38.existsSync(root)) return [];
|
|
122048
122180
|
let dirs = [];
|
|
122049
122181
|
try {
|
|
122050
|
-
dirs =
|
|
122182
|
+
dirs = fs38.readdirSync(root, { withFileTypes: true });
|
|
122051
122183
|
} catch {
|
|
122052
122184
|
return [];
|
|
122053
122185
|
}
|
|
@@ -122095,7 +122227,7 @@ ${marker}`,
|
|
|
122095
122227
|
const ownerConfirmed = reader === "antigravity-cli" ? resolved?.ownerConfirmed === true : void 0;
|
|
122096
122228
|
if (input.forceRefresh === true || input.args?.forceRefresh === true) {
|
|
122097
122229
|
try {
|
|
122098
|
-
|
|
122230
|
+
fs39.statSync(sourcePath);
|
|
122099
122231
|
} catch {
|
|
122100
122232
|
}
|
|
122101
122233
|
}
|
|
@@ -122160,10 +122292,10 @@ ${marker}`,
|
|
|
122160
122292
|
}
|
|
122161
122293
|
function resolveClaudePath(workspace, sessionId) {
|
|
122162
122294
|
const dir = path45.join(os28.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
122163
|
-
if (!
|
|
122295
|
+
if (!fs39.existsSync(dir)) return null;
|
|
122164
122296
|
if (sessionId) {
|
|
122165
122297
|
const candidate = path45.join(dir, `${sessionId}.jsonl`);
|
|
122166
|
-
if (
|
|
122298
|
+
if (fs39.existsSync(candidate)) return candidate;
|
|
122167
122299
|
}
|
|
122168
122300
|
return null;
|
|
122169
122301
|
}
|
|
@@ -122181,7 +122313,7 @@ ${marker}`,
|
|
|
122181
122313
|
if (key2) {
|
|
122182
122314
|
const pinned = codexRuntimeBindings.get(key2);
|
|
122183
122315
|
if (pinned) {
|
|
122184
|
-
if (
|
|
122316
|
+
if (fs39.existsSync(pinned)) return pinned;
|
|
122185
122317
|
codexRuntimeBindings.delete(key2);
|
|
122186
122318
|
}
|
|
122187
122319
|
}
|
|
@@ -122190,7 +122322,7 @@ ${marker}`,
|
|
|
122190
122322
|
return resolved;
|
|
122191
122323
|
}
|
|
122192
122324
|
function findCodexPathBySessionId(root, sessionId) {
|
|
122193
|
-
if (!
|
|
122325
|
+
if (!fs39.existsSync(root)) return null;
|
|
122194
122326
|
const needle = sessionId.toLowerCase();
|
|
122195
122327
|
const matches = [];
|
|
122196
122328
|
const stack = [root];
|
|
@@ -122198,7 +122330,7 @@ ${marker}`,
|
|
|
122198
122330
|
const current = stack.pop();
|
|
122199
122331
|
let entries = [];
|
|
122200
122332
|
try {
|
|
122201
|
-
entries =
|
|
122333
|
+
entries = fs39.readdirSync(current, { withFileTypes: true });
|
|
122202
122334
|
} catch {
|
|
122203
122335
|
continue;
|
|
122204
122336
|
}
|
|
@@ -122218,7 +122350,7 @@ ${marker}`,
|
|
|
122218
122350
|
return matches[0]?.p ?? null;
|
|
122219
122351
|
}
|
|
122220
122352
|
function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
|
|
122221
|
-
if (!
|
|
122353
|
+
if (!fs39.existsSync(root) || !workspace) return null;
|
|
122222
122354
|
const workspaceResolved = resolveRealPath(workspace);
|
|
122223
122355
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
122224
122356
|
const matches = [];
|
|
@@ -122227,7 +122359,7 @@ ${marker}`,
|
|
|
122227
122359
|
const current = stack.pop();
|
|
122228
122360
|
let entries = [];
|
|
122229
122361
|
try {
|
|
122230
|
-
entries =
|
|
122362
|
+
entries = fs39.readdirSync(current, { withFileTypes: true });
|
|
122231
122363
|
} catch {
|
|
122232
122364
|
continue;
|
|
122233
122365
|
}
|
|
@@ -122252,10 +122384,10 @@ ${marker}`,
|
|
|
122252
122384
|
}
|
|
122253
122385
|
function readCodexSessionMeta(filePath) {
|
|
122254
122386
|
try {
|
|
122255
|
-
const fd =
|
|
122387
|
+
const fd = fs39.openSync(filePath, "r");
|
|
122256
122388
|
try {
|
|
122257
122389
|
const buffer = Buffer.alloc(8192);
|
|
122258
|
-
const bytes =
|
|
122390
|
+
const bytes = fs39.readSync(fd, buffer, 0, buffer.length, 0);
|
|
122259
122391
|
if (bytes <= 0) return null;
|
|
122260
122392
|
const text = buffer.subarray(0, bytes).toString("utf8");
|
|
122261
122393
|
const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
|
|
@@ -122270,7 +122402,7 @@ ${marker}`,
|
|
|
122270
122402
|
timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
|
|
122271
122403
|
};
|
|
122272
122404
|
} finally {
|
|
122273
|
-
|
|
122405
|
+
fs39.closeSync(fd);
|
|
122274
122406
|
}
|
|
122275
122407
|
} catch {
|
|
122276
122408
|
return null;
|
|
@@ -122278,7 +122410,7 @@ ${marker}`,
|
|
|
122278
122410
|
}
|
|
122279
122411
|
function resolveRealPath(value) {
|
|
122280
122412
|
try {
|
|
122281
|
-
return
|
|
122413
|
+
return fs39.realpathSync(value);
|
|
122282
122414
|
} catch {
|
|
122283
122415
|
return value;
|
|
122284
122416
|
}
|
|
@@ -122300,19 +122432,19 @@ ${marker}`,
|
|
|
122300
122432
|
const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
|
|
122301
122433
|
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
122302
122434
|
const dbPath = path45.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
122303
|
-
if (
|
|
122435
|
+
if (fs39.existsSync(dbPath)) {
|
|
122304
122436
|
if (owner) claimAntigravityConversation(sessionId, owner);
|
|
122305
122437
|
return { path: dbPath, ownerConfirmed: true };
|
|
122306
122438
|
}
|
|
122307
122439
|
}
|
|
122308
122440
|
const brainRoot2 = path45.join(agyRoot, "brain");
|
|
122309
|
-
if (
|
|
122441
|
+
if (fs39.existsSync(brainRoot2)) {
|
|
122310
122442
|
const cutoff = spawnAwareCutoff(sessionStartedAtMs);
|
|
122311
122443
|
const nonEmptyBrain = (uuid3, p) => {
|
|
122312
122444
|
const t = path45.join(p, ".system_generated", "logs", "transcript.jsonl");
|
|
122313
|
-
return
|
|
122445
|
+
return fs39.existsSync(t) && safeSize(t) > 0 ? t : null;
|
|
122314
122446
|
};
|
|
122315
|
-
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) => {
|
|
122316
122448
|
const p = path45.join(brainRoot2, e.name);
|
|
122317
122449
|
return { uuid: e.name, p, mtime: safeMtime(p), birth: safeBirthtime(p) };
|
|
122318
122450
|
}).filter((e) => e.mtime >= cutoff);
|
|
@@ -122343,7 +122475,7 @@ ${marker}`,
|
|
|
122343
122475
|
function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
|
|
122344
122476
|
let entries = [];
|
|
122345
122477
|
try {
|
|
122346
|
-
entries =
|
|
122478
|
+
entries = fs39.readdirSync(convRoot, { withFileTypes: true });
|
|
122347
122479
|
} catch {
|
|
122348
122480
|
return null;
|
|
122349
122481
|
}
|
|
@@ -122381,9 +122513,9 @@ ${marker}`,
|
|
|
122381
122513
|
void workspace;
|
|
122382
122514
|
void sessionId;
|
|
122383
122515
|
const dbPath = path45.join(os28.homedir(), ".hermes", "state.db");
|
|
122384
|
-
if (
|
|
122516
|
+
if (fs39.existsSync(dbPath)) return dbPath;
|
|
122385
122517
|
const dir = path45.join(os28.homedir(), ".hermes", "sessions");
|
|
122386
|
-
if (!
|
|
122518
|
+
if (!fs39.existsSync(dir)) return null;
|
|
122387
122519
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
122388
122520
|
}
|
|
122389
122521
|
function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
|
|
@@ -122422,7 +122554,7 @@ ${marker}`,
|
|
|
122422
122554
|
function newestRecentFile2(dir, pattern) {
|
|
122423
122555
|
try {
|
|
122424
122556
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
122425
|
-
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);
|
|
122426
122558
|
return entries[0]?.p ?? null;
|
|
122427
122559
|
} catch {
|
|
122428
122560
|
return null;
|
|
@@ -122430,14 +122562,14 @@ ${marker}`,
|
|
|
122430
122562
|
}
|
|
122431
122563
|
function safeMtime(p) {
|
|
122432
122564
|
try {
|
|
122433
|
-
return Math.floor(
|
|
122565
|
+
return Math.floor(fs39.statSync(p).mtimeMs);
|
|
122434
122566
|
} catch {
|
|
122435
122567
|
return 0;
|
|
122436
122568
|
}
|
|
122437
122569
|
}
|
|
122438
122570
|
function safeBirthtime(p) {
|
|
122439
122571
|
try {
|
|
122440
|
-
const st =
|
|
122572
|
+
const st = fs39.statSync(p);
|
|
122441
122573
|
const birth = Math.floor(st.birthtimeMs);
|
|
122442
122574
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
122443
122575
|
} catch {
|
|
@@ -122446,7 +122578,7 @@ ${marker}`,
|
|
|
122446
122578
|
}
|
|
122447
122579
|
function safeSize(p) {
|
|
122448
122580
|
try {
|
|
122449
|
-
return
|
|
122581
|
+
return fs39.statSync(p).size;
|
|
122450
122582
|
} catch {
|
|
122451
122583
|
return 0;
|
|
122452
122584
|
}
|
|
@@ -122742,19 +122874,19 @@ ${marker}`,
|
|
|
122742
122874
|
return attrs;
|
|
122743
122875
|
}
|
|
122744
122876
|
function readTailJsonlLines(filePath, maxBytes) {
|
|
122745
|
-
const stat2 =
|
|
122877
|
+
const stat2 = fs40.statSync(filePath);
|
|
122746
122878
|
const size = stat2.size;
|
|
122747
122879
|
const start = size > maxBytes ? size - maxBytes : 0;
|
|
122748
122880
|
const length = size - start;
|
|
122749
122881
|
if (length <= 0) return [];
|
|
122750
|
-
const fd =
|
|
122882
|
+
const fd = fs40.openSync(filePath, "r");
|
|
122751
122883
|
let text;
|
|
122752
122884
|
try {
|
|
122753
122885
|
const buf = Buffer.alloc(length);
|
|
122754
|
-
const bytes =
|
|
122886
|
+
const bytes = fs40.readSync(fd, buf, 0, length, start);
|
|
122755
122887
|
text = buf.subarray(0, bytes).toString("utf8");
|
|
122756
122888
|
} finally {
|
|
122757
|
-
|
|
122889
|
+
fs40.closeSync(fd);
|
|
122758
122890
|
}
|
|
122759
122891
|
const rawLines = text.split("\n");
|
|
122760
122892
|
if (start > 0 && rawLines.length > 0) rawLines.shift();
|
|
@@ -122863,7 +122995,7 @@ ${text}` : text;
|
|
|
122863
122995
|
}
|
|
122864
122996
|
return messages.filter((m) => typeof m.content === "string" && m.content.trim().length > 0);
|
|
122865
122997
|
}
|
|
122866
|
-
var
|
|
122998
|
+
var fs41 = __toESM2(require("fs"));
|
|
122867
122999
|
var import_node_crypto6 = require("crypto");
|
|
122868
123000
|
init_provider_cli_shared();
|
|
122869
123001
|
init_logger();
|
|
@@ -123220,7 +123352,7 @@ ${text}` : text;
|
|
|
123220
123352
|
* (claude-cli specs/4.0.json), which previously stubbed the method to false. */
|
|
123221
123353
|
lastApprovalResolvedAt = 0;
|
|
123222
123354
|
constructor(specPath, workingDir, cliArgs, extraEnv, transportFactory, sessionId, manifestTuning) {
|
|
123223
|
-
const raw = JSON.parse(
|
|
123355
|
+
const raw = JSON.parse(fs41.readFileSync(specPath, "utf8"));
|
|
123224
123356
|
this.spec = {
|
|
123225
123357
|
id: raw.id,
|
|
123226
123358
|
name: raw.name,
|
|
@@ -124586,10 +124718,10 @@ ${text}` : text;
|
|
|
124586
124718
|
function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory, sessionId, removeArgs) {
|
|
124587
124719
|
const resolvedSpecPath = provider._resolvedSpecPath;
|
|
124588
124720
|
const dir = provider._resolvedProviderDir;
|
|
124589
|
-
let specPath = resolvedSpecPath &&
|
|
124721
|
+
let specPath = resolvedSpecPath && fs422.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
|
|
124590
124722
|
if (!specPath && dir) {
|
|
124591
124723
|
const legacy = path46.join(dir, "spec.json");
|
|
124592
|
-
if (
|
|
124724
|
+
if (fs422.existsSync(legacy)) specPath = legacy;
|
|
124593
124725
|
}
|
|
124594
124726
|
if (!specPath) {
|
|
124595
124727
|
throw new Error(formatNoResolvableSpecError(provider.type, dir));
|
|
@@ -124691,7 +124823,7 @@ ${text}` : text;
|
|
|
124691
124823
|
init_summary_metadata();
|
|
124692
124824
|
var os30 = __toESM2(require("os"));
|
|
124693
124825
|
var crypto6 = __toESM2(require("crypto"));
|
|
124694
|
-
var
|
|
124826
|
+
var fs46 = __toESM2(require("fs"));
|
|
124695
124827
|
function shouldUseBracketedPasteForEnvelope(input) {
|
|
124696
124828
|
return input.parts.some((part) => part.type === "image");
|
|
124697
124829
|
}
|
|
@@ -124946,7 +125078,7 @@ ${text}` : text;
|
|
|
124946
125078
|
var os29 = __toESM2(require("os"));
|
|
124947
125079
|
var path47 = __toESM2(require("path"));
|
|
124948
125080
|
var crypto5 = __toESM2(require("crypto"));
|
|
124949
|
-
var
|
|
125081
|
+
var fs43 = __toESM2(require("fs"));
|
|
124950
125082
|
var IMAGE_MIME_EXTENSIONS = {
|
|
124951
125083
|
"image/png": ".png",
|
|
124952
125084
|
"image/jpeg": ".jpg",
|
|
@@ -124981,9 +125113,9 @@ ${text}` : text;
|
|
|
124981
125113
|
if (!part.data) return null;
|
|
124982
125114
|
const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
|
|
124983
125115
|
if (!rawData) return null;
|
|
124984
|
-
|
|
125116
|
+
fs43.mkdirSync(dir, { recursive: true });
|
|
124985
125117
|
const filePath = path47.join(dir, safeInputImageBasename(index, part.mimeType));
|
|
124986
|
-
|
|
125118
|
+
fs43.writeFileSync(filePath, Buffer.from(rawData, "base64"));
|
|
124987
125119
|
cleanupStaleMaterializedImages(dir);
|
|
124988
125120
|
return filePath;
|
|
124989
125121
|
}
|
|
@@ -124995,14 +125127,14 @@ ${text}` : text;
|
|
|
124995
125127
|
if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
|
|
124996
125128
|
lastMaterializedImageCleanupAt = now;
|
|
124997
125129
|
try {
|
|
124998
|
-
const entries =
|
|
125130
|
+
const entries = fs43.readdirSync(dir);
|
|
124999
125131
|
for (const entry of entries) {
|
|
125000
125132
|
if (!entry.startsWith("adhdev-input-image-")) continue;
|
|
125001
125133
|
const fullPath = path47.join(dir, entry);
|
|
125002
125134
|
try {
|
|
125003
|
-
const stat2 =
|
|
125135
|
+
const stat2 = fs43.statSync(fullPath);
|
|
125004
125136
|
if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
|
|
125005
|
-
|
|
125137
|
+
fs43.unlinkSync(fullPath);
|
|
125006
125138
|
}
|
|
125007
125139
|
} catch {
|
|
125008
125140
|
}
|
|
@@ -125458,7 +125590,7 @@ ${text}` : text;
|
|
|
125458
125590
|
if (missingEvidence) return { action: "suppress", missingEvidence };
|
|
125459
125591
|
return { action: "inline_fire", missingEvidence: false };
|
|
125460
125592
|
}
|
|
125461
|
-
var
|
|
125593
|
+
var fs44 = __toESM2(require("fs"));
|
|
125462
125594
|
function createSqliteProbeCache() {
|
|
125463
125595
|
return { db: null, dbPath: null, missingUntil: 0 };
|
|
125464
125596
|
}
|
|
@@ -125478,7 +125610,7 @@ ${text}` : text;
|
|
|
125478
125610
|
};
|
|
125479
125611
|
addDir(workingDir);
|
|
125480
125612
|
try {
|
|
125481
|
-
addDir(
|
|
125613
|
+
addDir(fs44.realpathSync.native(workingDir));
|
|
125482
125614
|
} catch {
|
|
125483
125615
|
}
|
|
125484
125616
|
return Array.from(dirs);
|
|
@@ -125892,7 +126024,7 @@ ${buttons.join("\n")}`;
|
|
|
125892
126024
|
}
|
|
125893
126025
|
return adapterStatus;
|
|
125894
126026
|
}
|
|
125895
|
-
var
|
|
126027
|
+
var fs45 = __toESM2(require("fs"));
|
|
125896
126028
|
init_contracts2();
|
|
125897
126029
|
init_chat_message_normalization();
|
|
125898
126030
|
init_chat_history();
|
|
@@ -126096,7 +126228,7 @@ ${buttons.join("\n")}`;
|
|
|
126096
126228
|
}
|
|
126097
126229
|
if (host.lastExternalCompletionProbe?.sourcePath) {
|
|
126098
126230
|
try {
|
|
126099
|
-
|
|
126231
|
+
fs45.statSync(host.lastExternalCompletionProbe.sourcePath);
|
|
126100
126232
|
} catch {
|
|
126101
126233
|
}
|
|
126102
126234
|
}
|
|
@@ -127412,7 +127544,7 @@ ${buttons.join("\n")}`;
|
|
|
127412
127544
|
const resolvedDbPath = probe.dbPath.replace(/^~/, os30.homedir());
|
|
127413
127545
|
const now = Date.now();
|
|
127414
127546
|
if (this.sqliteProbeCache.missingUntil > now) return null;
|
|
127415
|
-
if (!
|
|
127547
|
+
if (!fs46.existsSync(resolvedDbPath)) {
|
|
127416
127548
|
this.sqliteProbeCache.missingUntil = now + 1e4;
|
|
127417
127549
|
return null;
|
|
127418
127550
|
}
|
|
@@ -132816,7 +132948,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
132816
132948
|
var net3 = __toESM2(require("net"));
|
|
132817
132949
|
var os322 = __toESM2(require("os"));
|
|
132818
132950
|
var path56 = __toESM2(require("path"));
|
|
132819
|
-
var
|
|
132951
|
+
var fs51 = __toESM2(require("fs"));
|
|
132820
132952
|
var path55 = __toESM2(require("path"));
|
|
132821
132953
|
var chokidar = __toESM2(require_chokidar());
|
|
132822
132954
|
init_logger();
|
|
@@ -133317,7 +133449,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133317
133449
|
init_contract();
|
|
133318
133450
|
init_track_identity();
|
|
133319
133451
|
init_config_dir();
|
|
133320
|
-
var
|
|
133452
|
+
var fs47 = __toESM2(require("fs"));
|
|
133321
133453
|
var path51 = __toESM2(require("path"));
|
|
133322
133454
|
var crypto8 = __toESM2(require("crypto"));
|
|
133323
133455
|
init_config();
|
|
@@ -133353,13 +133485,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133353
133485
|
/** Create a fresh staging directory. Caller must clean it up (or gc will). */
|
|
133354
133486
|
createStagingDir(kind) {
|
|
133355
133487
|
const dir = path51.join(this.stagingDir, `${kind}-${process.pid}-${crypto8.randomBytes(6).toString("hex")}`);
|
|
133356
|
-
|
|
133488
|
+
fs47.mkdirSync(dir, { recursive: true });
|
|
133357
133489
|
return dir;
|
|
133358
133490
|
}
|
|
133359
133491
|
removeStagingDir(dir) {
|
|
133360
133492
|
if (!dir.startsWith(this.stagingDir + path51.sep)) return;
|
|
133361
133493
|
try {
|
|
133362
|
-
|
|
133494
|
+
fs47.rmSync(dir, { recursive: true, force: true });
|
|
133363
133495
|
} catch {
|
|
133364
133496
|
}
|
|
133365
133497
|
}
|
|
@@ -133375,7 +133507,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133375
133507
|
}
|
|
133376
133508
|
hasObject(digest) {
|
|
133377
133509
|
try {
|
|
133378
|
-
return
|
|
133510
|
+
return fs47.statSync(this.getObjectDir(digest)).isDirectory();
|
|
133379
133511
|
} catch {
|
|
133380
133512
|
return false;
|
|
133381
133513
|
}
|
|
@@ -133393,8 +133525,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133393
133525
|
this.removeStagingDir(stagedObjectDir);
|
|
133394
133526
|
return objectDir;
|
|
133395
133527
|
}
|
|
133396
|
-
|
|
133397
|
-
|
|
133528
|
+
fs47.mkdirSync(this.objectsDir, { recursive: true });
|
|
133529
|
+
fs47.renameSync(stagedObjectDir, objectDir);
|
|
133398
133530
|
return objectDir;
|
|
133399
133531
|
}
|
|
133400
133532
|
// ─── Pointers ────────────────────────────────────────────
|
|
@@ -133406,10 +133538,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133406
133538
|
*/
|
|
133407
133539
|
getPointer(channel, providerType) {
|
|
133408
133540
|
const file2 = this.pointerPath(channel, providerType);
|
|
133409
|
-
if (!
|
|
133541
|
+
if (!fs47.existsSync(file2)) return null;
|
|
133410
133542
|
let parsed;
|
|
133411
133543
|
try {
|
|
133412
|
-
parsed = JSON.parse(
|
|
133544
|
+
parsed = JSON.parse(fs47.readFileSync(file2, "utf-8"));
|
|
133413
133545
|
} catch (e) {
|
|
133414
133546
|
throw new ProviderChannelError(
|
|
133415
133547
|
"STORE_CORRUPT",
|
|
@@ -133437,7 +133569,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133437
133569
|
const dir = this.activeDir(channel);
|
|
133438
133570
|
let files = [];
|
|
133439
133571
|
try {
|
|
133440
|
-
files =
|
|
133572
|
+
files = fs47.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
133441
133573
|
} catch {
|
|
133442
133574
|
return { pointers, errors };
|
|
133443
133575
|
}
|
|
@@ -133458,7 +133590,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133458
133590
|
const activations = [];
|
|
133459
133591
|
for (const pointer of pointers.values()) {
|
|
133460
133592
|
const objectDir = this.getObjectDir(pointer.active.digest);
|
|
133461
|
-
if (!
|
|
133593
|
+
if (!fs47.existsSync(objectDir)) {
|
|
133462
133594
|
errors.push(new ProviderChannelError(
|
|
133463
133595
|
"STORE_CORRUPT",
|
|
133464
133596
|
`active object ${pointer.active.digest} for "${pointer.active.providerType}" is missing \u2014 skipping (fail closed)`,
|
|
@@ -133527,9 +133659,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133527
133659
|
/** Remove an activation pointer (e.g. provider uninstalled). */
|
|
133528
133660
|
removePointer(channel, providerType) {
|
|
133529
133661
|
const file2 = this.pointerPath(channel, providerType);
|
|
133530
|
-
if (!
|
|
133662
|
+
if (!fs47.existsSync(file2)) return false;
|
|
133531
133663
|
try {
|
|
133532
|
-
|
|
133664
|
+
fs47.rmSync(file2, { force: true });
|
|
133533
133665
|
return true;
|
|
133534
133666
|
} catch {
|
|
133535
133667
|
return false;
|
|
@@ -133537,11 +133669,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133537
133669
|
}
|
|
133538
133670
|
writePointerAtomic(channel, providerType, pointer) {
|
|
133539
133671
|
const dir = this.activeDir(channel);
|
|
133540
|
-
|
|
133672
|
+
fs47.mkdirSync(dir, { recursive: true });
|
|
133541
133673
|
const file2 = this.pointerPath(channel, providerType);
|
|
133542
133674
|
const tmp = path51.join(dir, `.${providerType}.${process.pid}.${crypto8.randomBytes(4).toString("hex")}.tmp`);
|
|
133543
|
-
|
|
133544
|
-
|
|
133675
|
+
fs47.writeFileSync(tmp, JSON.stringify(pointer, null, 2), "utf-8");
|
|
133676
|
+
fs47.renameSync(tmp, file2);
|
|
133545
133677
|
}
|
|
133546
133678
|
// ─── GC (N=2 retention) ──────────────────────────────────
|
|
133547
133679
|
/**
|
|
@@ -133557,13 +133689,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133557
133689
|
const dir = this.activeDir(channel);
|
|
133558
133690
|
let files = [];
|
|
133559
133691
|
try {
|
|
133560
|
-
files =
|
|
133692
|
+
files = fs47.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
133561
133693
|
} catch {
|
|
133562
133694
|
continue;
|
|
133563
133695
|
}
|
|
133564
133696
|
for (const file2 of files) {
|
|
133565
133697
|
try {
|
|
133566
|
-
const parsed = JSON.parse(
|
|
133698
|
+
const parsed = JSON.parse(fs47.readFileSync(path51.join(dir, file2), "utf-8"));
|
|
133567
133699
|
if (typeof parsed?.active?.digest === "string") referenced.add(parsed.active.digest);
|
|
133568
133700
|
if (typeof parsed?.previous?.digest === "string") referenced.add(parsed.previous.digest);
|
|
133569
133701
|
} catch {
|
|
@@ -133573,7 +133705,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133573
133705
|
const removedObjects = [];
|
|
133574
133706
|
let objectNames = [];
|
|
133575
133707
|
try {
|
|
133576
|
-
objectNames =
|
|
133708
|
+
objectNames = fs47.readdirSync(this.objectsDir);
|
|
133577
133709
|
} catch {
|
|
133578
133710
|
objectNames = [];
|
|
133579
133711
|
}
|
|
@@ -133581,7 +133713,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133581
133713
|
const digest = `sha256:${name}`;
|
|
133582
133714
|
if (referenced.has(digest)) continue;
|
|
133583
133715
|
try {
|
|
133584
|
-
|
|
133716
|
+
fs47.rmSync(path51.join(this.objectsDir, name), { recursive: true, force: true });
|
|
133585
133717
|
removedObjects.push(digest);
|
|
133586
133718
|
} catch {
|
|
133587
133719
|
}
|
|
@@ -133589,13 +133721,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133589
133721
|
let removedStaging = 0;
|
|
133590
133722
|
let stagingEntries = [];
|
|
133591
133723
|
try {
|
|
133592
|
-
stagingEntries =
|
|
133724
|
+
stagingEntries = fs47.readdirSync(this.stagingDir);
|
|
133593
133725
|
} catch {
|
|
133594
133726
|
stagingEntries = [];
|
|
133595
133727
|
}
|
|
133596
133728
|
for (const name of stagingEntries) {
|
|
133597
133729
|
try {
|
|
133598
|
-
|
|
133730
|
+
fs47.rmSync(path51.join(this.stagingDir, name), { recursive: true, force: true });
|
|
133599
133731
|
removedStaging++;
|
|
133600
133732
|
} catch {
|
|
133601
133733
|
}
|
|
@@ -133606,10 +133738,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133606
133738
|
return { removedObjects, removedStaging };
|
|
133607
133739
|
}
|
|
133608
133740
|
};
|
|
133609
|
-
var
|
|
133741
|
+
var fs50 = __toESM2(require("fs"));
|
|
133610
133742
|
var path53 = __toESM2(require("path"));
|
|
133611
133743
|
init_contract();
|
|
133612
|
-
var
|
|
133744
|
+
var fs48 = __toESM2(require("fs"));
|
|
133613
133745
|
var path522 = __toESM2(require("path"));
|
|
133614
133746
|
var import_crypto18 = require("crypto");
|
|
133615
133747
|
init_contract();
|
|
@@ -133628,7 +133760,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133628
133760
|
const hash2 = (0, import_crypto18.createHash)("sha256");
|
|
133629
133761
|
for (const relPath of relPaths) {
|
|
133630
133762
|
const absPath = path522.join(rootDir, ...relPath.split("/"));
|
|
133631
|
-
const bytes =
|
|
133763
|
+
const bytes = fs48.readFileSync(absPath);
|
|
133632
133764
|
hash2.update(relPath, "utf8");
|
|
133633
133765
|
hash2.update("\0");
|
|
133634
133766
|
hash2.update(String(bytes.length), "utf8");
|
|
@@ -133640,7 +133772,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133640
133772
|
function collectRegularFiles(rootDir, dir, out, providerType) {
|
|
133641
133773
|
let entries;
|
|
133642
133774
|
try {
|
|
133643
|
-
entries =
|
|
133775
|
+
entries = fs48.readdirSync(dir, { withFileTypes: true });
|
|
133644
133776
|
} catch (e) {
|
|
133645
133777
|
throw new ProviderChannelError(
|
|
133646
133778
|
"ENTRY_TREE_INVALID",
|
|
@@ -133665,12 +133797,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133665
133797
|
out.push(rel);
|
|
133666
133798
|
}
|
|
133667
133799
|
}
|
|
133668
|
-
var
|
|
133800
|
+
var fs49 = __toESM2(require("fs"));
|
|
133669
133801
|
var zlib = __toESM2(require("zlib"));
|
|
133670
133802
|
var import_promises6 = require("stream/promises");
|
|
133671
133803
|
async function extractTarballGz(tarPath, destDir) {
|
|
133672
133804
|
const tarFs = require_tar_fs();
|
|
133673
|
-
await (0, import_promises6.pipeline)(
|
|
133805
|
+
await (0, import_promises6.pipeline)(fs49.createReadStream(tarPath), zlib.createGunzip(), tarFs.extract(destDir));
|
|
133674
133806
|
}
|
|
133675
133807
|
var REGISTRY_LIST_LIMIT = 100;
|
|
133676
133808
|
var ProviderChannelRuntime = class {
|
|
@@ -133793,7 +133925,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133793
133925
|
try {
|
|
133794
133926
|
const tarPath = path53.join(stagingRoot, "providers.tar.gz");
|
|
133795
133927
|
const extractDir = path53.join(stagingRoot, "repo");
|
|
133796
|
-
|
|
133928
|
+
fs50.mkdirSync(extractDir, { recursive: true });
|
|
133797
133929
|
try {
|
|
133798
133930
|
await this.downloadFile(this.providerTarballUrl, tarPath);
|
|
133799
133931
|
await this.extractTarball(tarPath, extractDir);
|
|
@@ -133851,8 +133983,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133851
133983
|
let relDir;
|
|
133852
133984
|
try {
|
|
133853
133985
|
relDir = path53.relative(repoRoot, artifactDir).split(path53.sep).join("/");
|
|
133854
|
-
|
|
133855
|
-
|
|
133986
|
+
fs50.mkdirSync(path53.join(objStaging, entry.category), { recursive: true });
|
|
133987
|
+
fs50.renameSync(artifactDir, path53.join(objStaging, entry.category, path53.basename(artifactDir)));
|
|
133856
133988
|
} catch (e) {
|
|
133857
133989
|
this.store.removeStagingDir(objStaging);
|
|
133858
133990
|
return { code: "TRANSPORT_FAILED", message: `failed to stage artifact tree: ${e?.message || e}`, providerType: entry.providerType };
|
|
@@ -133891,7 +134023,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133891
134023
|
function findTarballRepoRoot(extractDir) {
|
|
133892
134024
|
let entries;
|
|
133893
134025
|
try {
|
|
133894
|
-
entries =
|
|
134026
|
+
entries = fs50.readdirSync(extractDir, { withFileTypes: true });
|
|
133895
134027
|
} catch {
|
|
133896
134028
|
return null;
|
|
133897
134029
|
}
|
|
@@ -133903,7 +134035,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133903
134035
|
const categoryDir = path53.join(repoRoot, entry.category);
|
|
133904
134036
|
let candidates;
|
|
133905
134037
|
try {
|
|
133906
|
-
candidates =
|
|
134038
|
+
candidates = fs50.readdirSync(categoryDir, { withFileTypes: true });
|
|
133907
134039
|
} catch {
|
|
133908
134040
|
return null;
|
|
133909
134041
|
}
|
|
@@ -133914,8 +134046,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133914
134046
|
for (const manifestName of ["provider.v1.json", "provider.json"]) {
|
|
133915
134047
|
const manifestPath = path53.join(dir, manifestName);
|
|
133916
134048
|
try {
|
|
133917
|
-
if (!
|
|
133918
|
-
const manifest = JSON.parse(
|
|
134049
|
+
if (!fs50.existsSync(manifestPath)) continue;
|
|
134050
|
+
const manifest = JSON.parse(fs50.readFileSync(manifestPath, "utf-8"));
|
|
133919
134051
|
if (manifest?.type === entry.providerType) return dir;
|
|
133920
134052
|
break;
|
|
133921
134053
|
} catch {
|
|
@@ -133932,14 +134064,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133932
134064
|
const scan = (dir) => {
|
|
133933
134065
|
let entries;
|
|
133934
134066
|
try {
|
|
133935
|
-
entries =
|
|
134067
|
+
entries = fs50.readdirSync(dir, { withFileTypes: true });
|
|
133936
134068
|
} catch {
|
|
133937
134069
|
return;
|
|
133938
134070
|
}
|
|
133939
134071
|
const manifest = entries.find((e) => e.isFile() && (e.name === "provider.v1.json" || e.name === "provider.json"));
|
|
133940
134072
|
if (manifest) {
|
|
133941
134073
|
try {
|
|
133942
|
-
const parsed = JSON.parse(
|
|
134074
|
+
const parsed = JSON.parse(fs50.readFileSync(path53.join(dir, manifest.name), "utf-8"));
|
|
133943
134075
|
if (typeof parsed?.type === "string" && parsed.type.trim()) targets.add(parsed.type);
|
|
133944
134076
|
} catch {
|
|
133945
134077
|
}
|
|
@@ -134004,7 +134136,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134004
134136
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
134005
134137
|
return;
|
|
134006
134138
|
}
|
|
134007
|
-
const ws =
|
|
134139
|
+
const ws = fs50.createWriteStream(destPath);
|
|
134008
134140
|
res.pipe(ws);
|
|
134009
134141
|
ws.on("finish", () => {
|
|
134010
134142
|
ws.close();
|
|
@@ -134165,9 +134297,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134165
134297
|
static siblingRefusalLogged = /* @__PURE__ */ new Set();
|
|
134166
134298
|
static looksLikeProviderRoot(candidate) {
|
|
134167
134299
|
try {
|
|
134168
|
-
if (!
|
|
134300
|
+
if (!fs51.existsSync(candidate) || !fs51.statSync(candidate).isDirectory()) return false;
|
|
134169
134301
|
return ["ide", "extension", "cli", "acp"].some(
|
|
134170
|
-
(category) =>
|
|
134302
|
+
(category) => fs51.existsSync(path55.join(candidate, category))
|
|
134171
134303
|
);
|
|
134172
134304
|
} catch {
|
|
134173
134305
|
return false;
|
|
@@ -134175,7 +134307,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134175
134307
|
}
|
|
134176
134308
|
static hasProviderRootMarker(candidate) {
|
|
134177
134309
|
try {
|
|
134178
|
-
return
|
|
134310
|
+
return fs51.existsSync(path55.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
134179
134311
|
} catch {
|
|
134180
134312
|
return false;
|
|
134181
134313
|
}
|
|
@@ -134262,12 +134394,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134262
134394
|
const configDir = getConfigDir2();
|
|
134263
134395
|
const oldDir = path55.join(configDir, "marketplace");
|
|
134264
134396
|
const newDir = path55.join(configDir, "external");
|
|
134265
|
-
if (!
|
|
134266
|
-
if (
|
|
134397
|
+
if (!fs51.existsSync(oldDir)) return;
|
|
134398
|
+
if (fs51.existsSync(newDir)) {
|
|
134267
134399
|
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
134268
134400
|
return;
|
|
134269
134401
|
}
|
|
134270
|
-
|
|
134402
|
+
fs51.renameSync(oldDir, newDir);
|
|
134271
134403
|
this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
|
|
134272
134404
|
} catch (e) {
|
|
134273
134405
|
this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
|
|
@@ -134387,7 +134519,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134387
134519
|
this.providers.clear();
|
|
134388
134520
|
this.providerAvailability.clear();
|
|
134389
134521
|
let upstreamCount = 0;
|
|
134390
|
-
if (!this.disableUpstream &&
|
|
134522
|
+
if (!this.disableUpstream && fs51.existsSync(this.upstreamDir)) {
|
|
134391
134523
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
134392
134524
|
if (upstreamCount > 0) {
|
|
134393
134525
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -134397,10 +134529,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134397
134529
|
}
|
|
134398
134530
|
this.loadVerifiedChannelActivations();
|
|
134399
134531
|
const externalDir = path55.join(getConfigDir2(), "external");
|
|
134400
|
-
if (
|
|
134532
|
+
if (fs51.existsSync(externalDir)) {
|
|
134401
134533
|
const rootEntries = (() => {
|
|
134402
134534
|
try {
|
|
134403
|
-
return
|
|
134535
|
+
return fs51.readdirSync(externalDir, { withFileTypes: true });
|
|
134404
134536
|
} catch {
|
|
134405
134537
|
return [];
|
|
134406
134538
|
}
|
|
@@ -134449,7 +134581,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134449
134581
|
}
|
|
134450
134582
|
}
|
|
134451
134583
|
}
|
|
134452
|
-
if (
|
|
134584
|
+
if (fs51.existsSync(this.userDir)) {
|
|
134453
134585
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
134454
134586
|
if (userCount > 0) {
|
|
134455
134587
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -134587,7 +134719,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134587
134719
|
if (this.countVerifiedChannelPointers() > 0) return null;
|
|
134588
134720
|
if (this.hasUpstream()) return this.syncVerifiedChannel();
|
|
134589
134721
|
try {
|
|
134590
|
-
|
|
134722
|
+
fs51.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
134591
134723
|
} catch {
|
|
134592
134724
|
}
|
|
134593
134725
|
return this.syncVerifiedChannel({ bootstrapAll: true });
|
|
@@ -134598,7 +134730,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134598
134730
|
}
|
|
134599
134731
|
readChannelActivationStamp() {
|
|
134600
134732
|
try {
|
|
134601
|
-
return JSON.parse(
|
|
134733
|
+
return JSON.parse(fs51.readFileSync(this.channelActivationStampPath(), "utf-8"));
|
|
134602
134734
|
} catch {
|
|
134603
134735
|
return null;
|
|
134604
134736
|
}
|
|
@@ -134646,8 +134778,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134646
134778
|
}
|
|
134647
134779
|
}
|
|
134648
134780
|
try {
|
|
134649
|
-
|
|
134650
|
-
|
|
134781
|
+
fs51.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
134782
|
+
fs51.writeFileSync(stampPath, JSON.stringify({
|
|
134651
134783
|
daemonVersion: this.daemonVersion,
|
|
134652
134784
|
channel: this.channel,
|
|
134653
134785
|
syncedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -134791,10 +134923,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134791
134923
|
* Check if upstream directory exists and has providers.
|
|
134792
134924
|
*/
|
|
134793
134925
|
hasUpstream() {
|
|
134794
|
-
if (!
|
|
134926
|
+
if (!fs51.existsSync(this.upstreamDir)) return false;
|
|
134795
134927
|
try {
|
|
134796
|
-
return
|
|
134797
|
-
(d) =>
|
|
134928
|
+
return fs51.readdirSync(this.upstreamDir).some(
|
|
134929
|
+
(d) => fs51.statSync(path55.join(this.upstreamDir, d)).isDirectory()
|
|
134798
134930
|
);
|
|
134799
134931
|
} catch {
|
|
134800
134932
|
return false;
|
|
@@ -135343,7 +135475,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135343
135475
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
135344
135476
|
if (providerDir) {
|
|
135345
135477
|
const fullDir = path55.join(providerDir, entry.scriptDir);
|
|
135346
|
-
resolved._resolvedScriptsPath =
|
|
135478
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135347
135479
|
}
|
|
135348
135480
|
matched = true;
|
|
135349
135481
|
}
|
|
@@ -135362,7 +135494,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135362
135494
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
135363
135495
|
if (providerDir) {
|
|
135364
135496
|
const fullDir = path55.join(providerDir, base.defaultScriptDir);
|
|
135365
|
-
resolved._resolvedScriptsPath =
|
|
135497
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135366
135498
|
}
|
|
135367
135499
|
}
|
|
135368
135500
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -135380,7 +135512,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135380
135512
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
135381
135513
|
if (providerDir) {
|
|
135382
135514
|
const fullDir = path55.join(providerDir, dirOverride);
|
|
135383
|
-
resolved._resolvedScriptsPath =
|
|
135515
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135384
135516
|
}
|
|
135385
135517
|
}
|
|
135386
135518
|
} else if (override.scripts) {
|
|
@@ -135397,7 +135529,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135397
135529
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
135398
135530
|
if (providerDir) {
|
|
135399
135531
|
const fullDir = path55.join(providerDir, base.defaultScriptDir);
|
|
135400
|
-
resolved._resolvedScriptsPath =
|
|
135532
|
+
resolved._resolvedScriptsPath = fs51.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135401
135533
|
}
|
|
135402
135534
|
}
|
|
135403
135535
|
}
|
|
@@ -135415,7 +135547,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135415
135547
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
135416
135548
|
if (!override || typeof override.path !== "string") continue;
|
|
135417
135549
|
const fullPath = path55.join(providerDir2, override.path);
|
|
135418
|
-
if (!
|
|
135550
|
+
if (!fs51.existsSync(fullPath)) {
|
|
135419
135551
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
135420
135552
|
continue;
|
|
135421
135553
|
}
|
|
@@ -135445,7 +135577,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135445
135577
|
}
|
|
135446
135578
|
if (providerDir) {
|
|
135447
135579
|
try {
|
|
135448
|
-
const
|
|
135580
|
+
const fs67 = require("fs");
|
|
135449
135581
|
const path64 = require("path");
|
|
135450
135582
|
const candidates = [];
|
|
135451
135583
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -135457,13 +135589,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135457
135589
|
}
|
|
135458
135590
|
candidates.push(path64.join(providerDir, "specs", "default.json"));
|
|
135459
135591
|
candidates.push(path64.join(providerDir, "spec.json"));
|
|
135460
|
-
const specPath = candidates.find((p) =>
|
|
135592
|
+
const specPath = candidates.find((p) => fs67.existsSync(p));
|
|
135461
135593
|
let nh;
|
|
135462
135594
|
if (specPath) {
|
|
135463
135595
|
resolved._resolvedSpecPath = specPath;
|
|
135464
135596
|
let specControls;
|
|
135465
135597
|
try {
|
|
135466
|
-
const rawSpec = JSON.parse(
|
|
135598
|
+
const rawSpec = JSON.parse(fs67.readFileSync(specPath, "utf8"));
|
|
135467
135599
|
specControls = rawSpec.control_bar;
|
|
135468
135600
|
nh = rawSpec.native_history;
|
|
135469
135601
|
} catch {
|
|
@@ -135506,7 +135638,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135506
135638
|
}
|
|
135507
135639
|
} else if (nh.override_path) {
|
|
135508
135640
|
const overrideFile = path64.resolve(providerDir, nh.override_path);
|
|
135509
|
-
if (
|
|
135641
|
+
if (fs67.existsSync(overrideFile)) {
|
|
135510
135642
|
try {
|
|
135511
135643
|
registerProviderScriptRootSafely(path64.dirname(path64.dirname(providerDir)));
|
|
135512
135644
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -135565,7 +135697,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135565
135697
|
return null;
|
|
135566
135698
|
}
|
|
135567
135699
|
const dir = path55.join(providerDir, scriptDir);
|
|
135568
|
-
if (!
|
|
135700
|
+
if (!fs51.existsSync(dir)) {
|
|
135569
135701
|
this.debugLog(`[loadScriptsFromDir] ${type2}: dir not found: ${dir}`);
|
|
135570
135702
|
return null;
|
|
135571
135703
|
}
|
|
@@ -135573,7 +135705,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135573
135705
|
const cached5 = this.scriptsCache.get(dir);
|
|
135574
135706
|
if (cached5) return cached5;
|
|
135575
135707
|
const scriptsJs = path55.join(dir, "scripts.js");
|
|
135576
|
-
if (
|
|
135708
|
+
if (fs51.existsSync(scriptsJs)) {
|
|
135577
135709
|
try {
|
|
135578
135710
|
delete require.cache[require.resolve(scriptsJs)];
|
|
135579
135711
|
const loaded = require(scriptsJs);
|
|
@@ -135594,9 +135726,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135594
135726
|
watch() {
|
|
135595
135727
|
this.stopWatch();
|
|
135596
135728
|
const watchDir = (dir) => {
|
|
135597
|
-
if (!
|
|
135729
|
+
if (!fs51.existsSync(dir)) {
|
|
135598
135730
|
try {
|
|
135599
|
-
|
|
135731
|
+
fs51.mkdirSync(dir, { recursive: true });
|
|
135600
135732
|
} catch {
|
|
135601
135733
|
return;
|
|
135602
135734
|
}
|
|
@@ -135659,11 +135791,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135659
135791
|
}
|
|
135660
135792
|
/** Count provider files (provider.v1.json or provider.json — at most one per dir). */
|
|
135661
135793
|
countProviders(dir) {
|
|
135662
|
-
if (!
|
|
135794
|
+
if (!fs51.existsSync(dir)) return 0;
|
|
135663
135795
|
let count = 0;
|
|
135664
135796
|
const scan = (d) => {
|
|
135665
135797
|
try {
|
|
135666
|
-
const entries =
|
|
135798
|
+
const entries = fs51.readdirSync(d, { withFileTypes: true });
|
|
135667
135799
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
135668
135800
|
if (hasManifest) count++;
|
|
135669
135801
|
for (const entry of entries) {
|
|
@@ -135893,13 +136025,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135893
136025
|
if (!provider) return null;
|
|
135894
136026
|
const cat = provider.category;
|
|
135895
136027
|
const searchRoots = this.getProviderRoots();
|
|
135896
|
-
const hasManifest = (dir) =>
|
|
136028
|
+
const hasManifest = (dir) => fs51.existsSync(path55.join(dir, "provider.v1.json")) || fs51.existsSync(path55.join(dir, "provider.json"));
|
|
135897
136029
|
const readManifestType = (dir) => {
|
|
135898
136030
|
for (const file2 of ["provider.v1.json", "provider.json"]) {
|
|
135899
136031
|
const p = path55.join(dir, file2);
|
|
135900
|
-
if (!
|
|
136032
|
+
if (!fs51.existsSync(p)) continue;
|
|
135901
136033
|
try {
|
|
135902
|
-
const data = JSON.parse(
|
|
136034
|
+
const data = JSON.parse(fs51.readFileSync(p, "utf-8"));
|
|
135903
136035
|
if (typeof data?.type === "string") return data.type;
|
|
135904
136036
|
} catch {
|
|
135905
136037
|
}
|
|
@@ -135907,13 +136039,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135907
136039
|
return null;
|
|
135908
136040
|
};
|
|
135909
136041
|
for (const root of searchRoots) {
|
|
135910
|
-
if (!
|
|
136042
|
+
if (!fs51.existsSync(root)) continue;
|
|
135911
136043
|
const candidate = this.getProviderDir(root, cat, type2);
|
|
135912
136044
|
if (hasManifest(candidate)) return candidate;
|
|
135913
136045
|
const catDir = path55.join(root, cat);
|
|
135914
|
-
if (
|
|
136046
|
+
if (fs51.existsSync(catDir)) {
|
|
135915
136047
|
try {
|
|
135916
|
-
for (const entry of
|
|
136048
|
+
for (const entry of fs51.readdirSync(catDir, { withFileTypes: true })) {
|
|
135917
136049
|
if (!entry.isDirectory()) continue;
|
|
135918
136050
|
const entryDir = path55.join(catDir, entry.name);
|
|
135919
136051
|
const manifestType = readManifestType(entryDir);
|
|
@@ -135932,7 +136064,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135932
136064
|
*/
|
|
135933
136065
|
buildScriptWrappersFromDir(dir) {
|
|
135934
136066
|
const scriptsJs = path55.join(dir, "scripts.js");
|
|
135935
|
-
if (
|
|
136067
|
+
if (fs51.existsSync(scriptsJs)) {
|
|
135936
136068
|
try {
|
|
135937
136069
|
delete require.cache[require.resolve(scriptsJs)];
|
|
135938
136070
|
return require(scriptsJs);
|
|
@@ -135942,13 +136074,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135942
136074
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
135943
136075
|
const result = {};
|
|
135944
136076
|
try {
|
|
135945
|
-
for (const file2 of
|
|
136077
|
+
for (const file2 of fs51.readdirSync(dir)) {
|
|
135946
136078
|
if (!file2.endsWith(".js")) continue;
|
|
135947
136079
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
135948
136080
|
const filePath = path55.join(dir, file2);
|
|
135949
136081
|
result[scriptName] = (...args) => {
|
|
135950
136082
|
try {
|
|
135951
|
-
let content =
|
|
136083
|
+
let content = fs51.readFileSync(filePath, "utf-8");
|
|
135952
136084
|
if (args[0] && typeof args[0] === "object") {
|
|
135953
136085
|
for (const [key2, val] of Object.entries(args[0])) {
|
|
135954
136086
|
let v = val;
|
|
@@ -135994,12 +136126,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135994
136126
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
135995
136127
|
*/
|
|
135996
136128
|
loadDir(dir, excludeDirs) {
|
|
135997
|
-
if (!
|
|
136129
|
+
if (!fs51.existsSync(dir)) return 0;
|
|
135998
136130
|
let count = 0;
|
|
135999
136131
|
const scan = (d) => {
|
|
136000
136132
|
let entries;
|
|
136001
136133
|
try {
|
|
136002
|
-
entries =
|
|
136134
|
+
entries = fs51.readdirSync(d, { withFileTypes: true });
|
|
136003
136135
|
} catch {
|
|
136004
136136
|
return;
|
|
136005
136137
|
}
|
|
@@ -136009,7 +136141,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136009
136141
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
136010
136142
|
const jsonPath = path55.join(d, manifestFile);
|
|
136011
136143
|
try {
|
|
136012
|
-
const raw =
|
|
136144
|
+
const raw = fs51.readFileSync(jsonPath, "utf-8");
|
|
136013
136145
|
const mod = JSON.parse(raw);
|
|
136014
136146
|
if (hasV1 && (mod?.category === "cli" || mod?.category === "acp")) {
|
|
136015
136147
|
try {
|
|
@@ -136048,7 +136180,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136048
136180
|
} else {
|
|
136049
136181
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
136050
136182
|
const scriptsPath = path55.join(d, "scripts.js");
|
|
136051
|
-
if (!hasCompatibility &&
|
|
136183
|
+
if (!hasCompatibility && fs51.existsSync(scriptsPath)) {
|
|
136052
136184
|
try {
|
|
136053
136185
|
registerProviderScriptRootSafely(path55.dirname(path55.dirname(d)));
|
|
136054
136186
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -136426,7 +136558,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136426
136558
|
}
|
|
136427
136559
|
} else if (plat === "win32") {
|
|
136428
136560
|
try {
|
|
136429
|
-
const
|
|
136561
|
+
const fs67 = require("fs");
|
|
136430
136562
|
const appNameMap = getMacAppIdentifiers();
|
|
136431
136563
|
const appName = appNameMap[ideId];
|
|
136432
136564
|
if (appName) {
|
|
@@ -136435,8 +136567,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136435
136567
|
appName,
|
|
136436
136568
|
"storage.json"
|
|
136437
136569
|
);
|
|
136438
|
-
if (
|
|
136439
|
-
const data = JSON.parse(
|
|
136570
|
+
if (fs67.existsSync(storagePath)) {
|
|
136571
|
+
const data = JSON.parse(fs67.readFileSync(storagePath, "utf-8"));
|
|
136440
136572
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
136441
136573
|
if (workspaces.length > 0) {
|
|
136442
136574
|
const recent = workspaces[0];
|
|
@@ -137136,7 +137268,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137136
137268
|
normalizeRepoMeshDeclarativeConfig: normalizeRepoMeshDeclarativeConfig2,
|
|
137137
137269
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
137138
137270
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
137139
|
-
const { existsSync: existsSync76, readFileSync:
|
|
137271
|
+
const { existsSync: existsSync76, readFileSync: readFileSync60, mkdirSync: mkdirSync35, writeFileSync: writeFileSync33 } = await import("fs");
|
|
137140
137272
|
const { dirname: dirname26, join: join75 } = await import("path");
|
|
137141
137273
|
const yaml6 = await Promise.resolve().then(() => (init_js_yaml(), js_yaml_exports));
|
|
137142
137274
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
@@ -137147,7 +137279,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137147
137279
|
const candidate = join75(workspace, relative8);
|
|
137148
137280
|
if (!existsSync76(candidate)) continue;
|
|
137149
137281
|
try {
|
|
137150
|
-
const text =
|
|
137282
|
+
const text = readFileSync60(candidate, "utf-8");
|
|
137151
137283
|
const parsed = /\.json$/i.test(candidate) ? JSON.parse(text) : yaml6.load(text);
|
|
137152
137284
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
137153
137285
|
baseDoc = parsed;
|
|
@@ -139241,7 +139373,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
139241
139373
|
}
|
|
139242
139374
|
};
|
|
139243
139375
|
var import_path222 = require("path");
|
|
139244
|
-
var
|
|
139376
|
+
var fs55 = __toESM2(require("fs"));
|
|
139245
139377
|
init_logger();
|
|
139246
139378
|
init_mesh_host_ownership();
|
|
139247
139379
|
init_coordinator_registry();
|
|
@@ -139546,15 +139678,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139546
139678
|
}
|
|
139547
139679
|
if (cliType === "codex-cli") {
|
|
139548
139680
|
const repoMcpConfigPath = (0, import_path222.join)(workspace, ".mcp.json");
|
|
139549
|
-
if (
|
|
139681
|
+
if (fs55.existsSync(repoMcpConfigPath)) {
|
|
139550
139682
|
try {
|
|
139551
139683
|
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
139552
|
-
|
|
139684
|
+
fs55.readFileSync(repoMcpConfigPath, "utf-8"),
|
|
139553
139685
|
"claude_mcp_json"
|
|
139554
139686
|
);
|
|
139555
139687
|
const existingServers2 = repoMcpConfig.mcpServers;
|
|
139556
139688
|
if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
|
|
139557
|
-
|
|
139689
|
+
fs55.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
139558
139690
|
...repoMcpConfig,
|
|
139559
139691
|
mcpServers: {
|
|
139560
139692
|
...existingServers2,
|
|
@@ -139718,7 +139850,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139718
139850
|
workspace
|
|
139719
139851
|
};
|
|
139720
139852
|
}
|
|
139721
|
-
const { existsSync: existsSync76, readFileSync:
|
|
139853
|
+
const { existsSync: existsSync76, readFileSync: readFileSync60, writeFileSync: writeFileSync33, copyFileSync: copyFileSync4, mkdirSync: mkdirSync35 } = await import("fs");
|
|
139722
139854
|
const { dirname: dirname26 } = await import("path");
|
|
139723
139855
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
139724
139856
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -139770,7 +139902,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139770
139902
|
}
|
|
139771
139903
|
if (hadExistingMcpConfig) {
|
|
139772
139904
|
try {
|
|
139773
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
139905
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync60(mcpConfigPath, "utf-8"), configFormat);
|
|
139774
139906
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
139775
139907
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
139776
139908
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -139925,7 +140057,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139925
140057
|
}
|
|
139926
140058
|
}
|
|
139927
140059
|
};
|
|
139928
|
-
var
|
|
140060
|
+
var fs56 = __toESM2(require("fs"));
|
|
139929
140061
|
var import_os5 = require("os");
|
|
139930
140062
|
init_config();
|
|
139931
140063
|
init_git_status();
|
|
@@ -140308,7 +140440,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140308
140440
|
}
|
|
140309
140441
|
}
|
|
140310
140442
|
if (workspace) {
|
|
140311
|
-
if (!
|
|
140443
|
+
if (!fs56.existsSync(workspace)) {
|
|
140312
140444
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
140313
140445
|
let remoteProbeApplied = false;
|
|
140314
140446
|
if (inlineTransitGit) {
|
|
@@ -140449,7 +140581,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140449
140581
|
const pendingRetentionCounters2 = { ...getPendingRetentionCounters() };
|
|
140450
140582
|
const turnPresentationCounters = getTurnPresentationMetrics();
|
|
140451
140583
|
const previewFreshness = (() => {
|
|
140452
|
-
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));
|
|
140453
140585
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
140454
140586
|
})();
|
|
140455
140587
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -140649,7 +140781,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140649
140781
|
init_logger();
|
|
140650
140782
|
init_mesh_dual_write();
|
|
140651
140783
|
init_transcript_publisher();
|
|
140652
|
-
var
|
|
140784
|
+
var fs57 = __toESM2(require("fs"));
|
|
140653
140785
|
var path57 = __toESM2(require("path"));
|
|
140654
140786
|
init_config_dir();
|
|
140655
140787
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
@@ -140698,7 +140830,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140698
140830
|
currentFile = path57.join(dir, `commands-${today}.jsonl`);
|
|
140699
140831
|
if (dirChanged) {
|
|
140700
140832
|
try {
|
|
140701
|
-
|
|
140833
|
+
fs57.mkdirSync(dir, { recursive: true });
|
|
140702
140834
|
} catch {
|
|
140703
140835
|
}
|
|
140704
140836
|
cleanOldFiles();
|
|
@@ -140706,7 +140838,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140706
140838
|
}
|
|
140707
140839
|
function cleanOldFiles() {
|
|
140708
140840
|
try {
|
|
140709
|
-
const files =
|
|
140841
|
+
const files = fs57.readdirSync(currentDir).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
140710
140842
|
const cutoff = /* @__PURE__ */ new Date();
|
|
140711
140843
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
140712
140844
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -140714,7 +140846,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140714
140846
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
140715
140847
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
140716
140848
|
try {
|
|
140717
|
-
|
|
140849
|
+
fs57.unlinkSync(path57.join(currentDir, file2));
|
|
140718
140850
|
} catch {
|
|
140719
140851
|
}
|
|
140720
140852
|
}
|
|
@@ -140724,14 +140856,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140724
140856
|
}
|
|
140725
140857
|
function checkSize() {
|
|
140726
140858
|
try {
|
|
140727
|
-
const stat2 =
|
|
140859
|
+
const stat2 = fs57.statSync(currentFile);
|
|
140728
140860
|
if (stat2.size > MAX_FILE_SIZE) {
|
|
140729
140861
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
140730
140862
|
try {
|
|
140731
|
-
|
|
140863
|
+
fs57.unlinkSync(backup);
|
|
140732
140864
|
} catch {
|
|
140733
140865
|
}
|
|
140734
|
-
|
|
140866
|
+
fs57.renameSync(currentFile, backup);
|
|
140735
140867
|
}
|
|
140736
140868
|
} catch {
|
|
140737
140869
|
}
|
|
@@ -140764,15 +140896,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140764
140896
|
...entry.error ? { err: entry.error } : {},
|
|
140765
140897
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
140766
140898
|
});
|
|
140767
|
-
|
|
140899
|
+
fs57.appendFileSync(currentFile, line + "\n");
|
|
140768
140900
|
} catch {
|
|
140769
140901
|
}
|
|
140770
140902
|
}
|
|
140771
140903
|
function getRecentCommands(count = 50) {
|
|
140772
140904
|
try {
|
|
140773
140905
|
refreshCurrentFile();
|
|
140774
|
-
if (!
|
|
140775
|
-
const content =
|
|
140906
|
+
if (!fs57.existsSync(currentFile)) return [];
|
|
140907
|
+
const content = fs57.readFileSync(currentFile, "utf-8");
|
|
140776
140908
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
140777
140909
|
return lines.slice(-count).map((line) => {
|
|
140778
140910
|
try {
|
|
@@ -140799,10 +140931,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140799
140931
|
init_mesh_host_ownership();
|
|
140800
140932
|
init_repo_mesh_types();
|
|
140801
140933
|
init_mesh_config();
|
|
140802
|
-
var
|
|
140934
|
+
var fs59 = __toESM2(require("fs"));
|
|
140803
140935
|
init_mesh_node_identity();
|
|
140804
140936
|
init_router_refine();
|
|
140805
|
-
var
|
|
140937
|
+
var fs58 = __toESM2(require("fs"));
|
|
140806
140938
|
var import_node_os22 = require("os");
|
|
140807
140939
|
var import_path23 = require("path");
|
|
140808
140940
|
init_logger();
|
|
@@ -140833,7 +140965,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140833
140965
|
return out;
|
|
140834
140966
|
}
|
|
140835
140967
|
function repoRootUsable(repoRoot) {
|
|
140836
|
-
return typeof repoRoot === "string" && repoRoot.trim().length > 0 &&
|
|
140968
|
+
return typeof repoRoot === "string" && repoRoot.trim().length > 0 && fs58.existsSync(repoRoot.trim());
|
|
140837
140969
|
}
|
|
140838
140970
|
function meshWorktreeBaseDir(mesh) {
|
|
140839
140971
|
const v = mesh?.policy?.worktreeBaseDir;
|
|
@@ -140902,14 +141034,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140902
141034
|
return false;
|
|
140903
141035
|
}
|
|
140904
141036
|
async function bestEffortRemoveWorktreeDir(self, dir) {
|
|
140905
|
-
if (!dir || !
|
|
141037
|
+
if (!dir || !fs58.existsSync(dir)) return { removed: true, residue: false };
|
|
140906
141038
|
const sleep3 = (ms) => new Promise((resolve32) => setTimeout(resolve32, ms));
|
|
140907
141039
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
140908
141040
|
let lastErr;
|
|
140909
141041
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
140910
141042
|
try {
|
|
140911
|
-
|
|
140912
|
-
if (!
|
|
141043
|
+
fs58.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
141044
|
+
if (!fs58.existsSync(dir)) return { removed: true, residue: false };
|
|
140913
141045
|
lastErr = new Error("directory still present after rmSync");
|
|
140914
141046
|
} catch (e) {
|
|
140915
141047
|
lastErr = e;
|
|
@@ -140920,7 +141052,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140920
141052
|
}
|
|
140921
141053
|
await sleep3(150 * (attempt + 1));
|
|
140922
141054
|
}
|
|
140923
|
-
return
|
|
141055
|
+
return fs58.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
140924
141056
|
}
|
|
140925
141057
|
async function precheckLocalWorktreeRemovable(self, args) {
|
|
140926
141058
|
const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
|
|
@@ -140933,10 +141065,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140933
141065
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
|
|
140934
141066
|
};
|
|
140935
141067
|
}
|
|
140936
|
-
if (!
|
|
141068
|
+
if (!fs58.existsSync(workspace)) return { ok: true };
|
|
140937
141069
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
140938
141070
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
140939
|
-
if (!repoRoot || !
|
|
141071
|
+
if (!repoRoot || !fs58.existsSync(repoRoot)) {
|
|
140940
141072
|
return {
|
|
140941
141073
|
ok: false,
|
|
140942
141074
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -140956,7 +141088,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140956
141088
|
const normalizePath2 = (value) => {
|
|
140957
141089
|
const resolved = (0, import_path23.resolve)(value);
|
|
140958
141090
|
try {
|
|
140959
|
-
return
|
|
141091
|
+
return fs58.realpathSync(resolved);
|
|
140960
141092
|
} catch {
|
|
140961
141093
|
return resolved;
|
|
140962
141094
|
}
|
|
@@ -141057,13 +141189,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141057
141189
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
141058
141190
|
};
|
|
141059
141191
|
}
|
|
141060
|
-
const worktreeExists =
|
|
141192
|
+
const worktreeExists = fs58.existsSync(workspace);
|
|
141061
141193
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
141062
141194
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
141063
141195
|
if (!worktreeExists) {
|
|
141064
141196
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
141065
141197
|
}
|
|
141066
|
-
if (!repoRoot || !
|
|
141198
|
+
if (!repoRoot || !fs58.existsSync(repoRoot)) {
|
|
141067
141199
|
return {
|
|
141068
141200
|
success: false,
|
|
141069
141201
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -141083,7 +141215,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141083
141215
|
const normalizePath2 = (value) => {
|
|
141084
141216
|
const resolved = (0, import_path23.resolve)(value);
|
|
141085
141217
|
try {
|
|
141086
|
-
return
|
|
141218
|
+
return fs58.realpathSync(resolved);
|
|
141087
141219
|
} catch {
|
|
141088
141220
|
return resolved;
|
|
141089
141221
|
}
|
|
@@ -141300,7 +141432,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141300
141432
|
});
|
|
141301
141433
|
return String(stdout || "").trim();
|
|
141302
141434
|
};
|
|
141303
|
-
const workspaceMissing = !args.workspace || !
|
|
141435
|
+
const workspaceMissing = !args.workspace || !fs58.existsSync(args.workspace);
|
|
141304
141436
|
let head = "";
|
|
141305
141437
|
const branch = typeof args.node?.worktreeBranch === "string" ? args.node.worktreeBranch.trim() : "";
|
|
141306
141438
|
if (workspaceMissing) {
|
|
@@ -142350,7 +142482,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
142350
142482
|
const tombstones = this.removedInlineMeshNodeIds.get(meshId);
|
|
142351
142483
|
if (!tombstones?.size || !tombstones.has(nodeId)) return false;
|
|
142352
142484
|
const workspace = readStringValue(node?.workspace);
|
|
142353
|
-
if (workspace &&
|
|
142485
|
+
if (workspace && fs59.existsSync(workspace)) {
|
|
142354
142486
|
tombstones.delete(nodeId);
|
|
142355
142487
|
if (tombstones.size === 0) this.removedInlineMeshNodeIds.delete(meshId);
|
|
142356
142488
|
return false;
|
|
@@ -142371,7 +142503,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
142371
142503
|
const nodeId = readInlineMeshNodeId(node);
|
|
142372
142504
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
142373
142505
|
const workspace = readStringValue(node?.workspace);
|
|
142374
|
-
if (workspace &&
|
|
142506
|
+
if (workspace && fs59.existsSync(workspace)) {
|
|
142375
142507
|
tombstones.delete(nodeId);
|
|
142376
142508
|
return true;
|
|
142377
142509
|
}
|
|
@@ -143170,7 +143302,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
143170
143302
|
markChatOutputActivity(sessionId) {
|
|
143171
143303
|
const cfg = this.opts.chatTail;
|
|
143172
143304
|
if (!sessionId || !(cfg?.isCliSession?.(sessionId) ?? false)) return;
|
|
143173
|
-
|
|
143305
|
+
markTranscriptPtyOutputActivity(sessionId);
|
|
143174
143306
|
this.chatOutputActiveAt.set(sessionId, this.now());
|
|
143175
143307
|
if (this.chatOutputFlushTimer) return;
|
|
143176
143308
|
if (cfg?.scheduleGate && !cfg.scheduleGate()) return;
|
|
@@ -145496,7 +145628,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145496
145628
|
};
|
|
145497
145629
|
init_io_contracts();
|
|
145498
145630
|
init_chat_message_normalization();
|
|
145499
|
-
var
|
|
145631
|
+
var fs60 = __toESM2(require("fs"));
|
|
145500
145632
|
var path58 = __toESM2(require("path"));
|
|
145501
145633
|
var os33 = __toESM2(require("os"));
|
|
145502
145634
|
var import_os6 = require("os");
|
|
@@ -145513,8 +145645,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145513
145645
|
}
|
|
145514
145646
|
load() {
|
|
145515
145647
|
try {
|
|
145516
|
-
if (
|
|
145517
|
-
this.history = JSON.parse(
|
|
145648
|
+
if (fs60.existsSync(getArchivePath2())) {
|
|
145649
|
+
this.history = JSON.parse(fs60.readFileSync(getArchivePath2(), "utf-8"));
|
|
145518
145650
|
}
|
|
145519
145651
|
} catch {
|
|
145520
145652
|
this.history = {};
|
|
@@ -145551,8 +145683,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145551
145683
|
}
|
|
145552
145684
|
save() {
|
|
145553
145685
|
try {
|
|
145554
|
-
|
|
145555
|
-
|
|
145686
|
+
fs60.mkdirSync(path58.dirname(getArchivePath2()), { recursive: true });
|
|
145687
|
+
fs60.writeFileSync(getArchivePath2(), JSON.stringify(this.history, null, 2));
|
|
145556
145688
|
} catch {
|
|
145557
145689
|
}
|
|
145558
145690
|
}
|
|
@@ -145577,8 +145709,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145577
145709
|
for (const ext of exes) {
|
|
145578
145710
|
const fullPath = path58.join(p, name + ext);
|
|
145579
145711
|
try {
|
|
145580
|
-
if (
|
|
145581
|
-
const stat2 =
|
|
145712
|
+
if (fs60.existsSync(fullPath)) {
|
|
145713
|
+
const stat2 = fs60.statSync(fullPath);
|
|
145582
145714
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
145583
145715
|
return fullPath;
|
|
145584
145716
|
}
|
|
@@ -145625,9 +145757,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145625
145757
|
if (p.includes("*")) {
|
|
145626
145758
|
const home = os33.homedir();
|
|
145627
145759
|
const resolved = p.replace(/\*/g, home.split(path58.sep).pop() || "");
|
|
145628
|
-
if (
|
|
145760
|
+
if (fs60.existsSync(resolved)) return resolved;
|
|
145629
145761
|
} else {
|
|
145630
|
-
if (
|
|
145762
|
+
if (fs60.existsSync(p)) return p;
|
|
145631
145763
|
}
|
|
145632
145764
|
}
|
|
145633
145765
|
return null;
|
|
@@ -145635,7 +145767,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145635
145767
|
async function getMacAppVersion(appPath) {
|
|
145636
145768
|
if ((0, import_os6.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
145637
145769
|
const plistPath = path58.join(appPath, "Contents", "Info.plist");
|
|
145638
|
-
if (!
|
|
145770
|
+
if (!fs60.existsSync(plistPath)) return null;
|
|
145639
145771
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
145640
145772
|
return raw || null;
|
|
145641
145773
|
}
|
|
@@ -145662,7 +145794,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145662
145794
|
let resolvedBin = cliBin;
|
|
145663
145795
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
145664
145796
|
const bundled = path58.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
145665
|
-
if (provider.cli &&
|
|
145797
|
+
if (provider.cli && fs60.existsSync(bundled)) resolvedBin = bundled;
|
|
145666
145798
|
}
|
|
145667
145799
|
info.installed = !!(appPath || resolvedBin);
|
|
145668
145800
|
info.path = appPath || null;
|
|
@@ -145708,7 +145840,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145708
145840
|
return results;
|
|
145709
145841
|
}
|
|
145710
145842
|
var http3 = __toESM2(require("http"));
|
|
145711
|
-
var
|
|
145843
|
+
var fs64 = __toESM2(require("fs"));
|
|
145712
145844
|
var path62 = __toESM2(require("path"));
|
|
145713
145845
|
init_config();
|
|
145714
145846
|
function generateFiles(type2, name, category, opts = {}) {
|
|
@@ -146054,7 +146186,7 @@ async (params) => {
|
|
|
146054
146186
|
}
|
|
146055
146187
|
init_logger();
|
|
146056
146188
|
init_builders();
|
|
146057
|
-
var
|
|
146189
|
+
var fs61 = __toESM2(require("fs"));
|
|
146058
146190
|
var path59 = __toESM2(require("path"));
|
|
146059
146191
|
init_logger();
|
|
146060
146192
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -146235,17 +146367,17 @@ async (params) => {
|
|
|
146235
146367
|
}
|
|
146236
146368
|
let scriptsPath = "";
|
|
146237
146369
|
const directScripts = path59.join(dir, "scripts.js");
|
|
146238
|
-
if (
|
|
146370
|
+
if (fs61.existsSync(directScripts)) {
|
|
146239
146371
|
scriptsPath = directScripts;
|
|
146240
146372
|
} else {
|
|
146241
146373
|
const scriptsDir = path59.join(dir, "scripts");
|
|
146242
|
-
if (
|
|
146243
|
-
const versions =
|
|
146244
|
-
return
|
|
146374
|
+
if (fs61.existsSync(scriptsDir)) {
|
|
146375
|
+
const versions = fs61.readdirSync(scriptsDir).filter((d) => {
|
|
146376
|
+
return fs61.statSync(path59.join(scriptsDir, d)).isDirectory();
|
|
146245
146377
|
}).sort().reverse();
|
|
146246
146378
|
for (const ver of versions) {
|
|
146247
146379
|
const p = path59.join(scriptsDir, ver, "scripts.js");
|
|
146248
|
-
if (
|
|
146380
|
+
if (fs61.existsSync(p)) {
|
|
146249
146381
|
scriptsPath = p;
|
|
146250
146382
|
break;
|
|
146251
146383
|
}
|
|
@@ -146257,7 +146389,7 @@ async (params) => {
|
|
|
146257
146389
|
return;
|
|
146258
146390
|
}
|
|
146259
146391
|
try {
|
|
146260
|
-
const source =
|
|
146392
|
+
const source = fs61.readFileSync(scriptsPath, "utf-8");
|
|
146261
146393
|
const hints = {};
|
|
146262
146394
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
146263
146395
|
let match;
|
|
@@ -147070,7 +147202,7 @@ async (params) => {
|
|
|
147070
147202
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
147071
147203
|
}
|
|
147072
147204
|
}
|
|
147073
|
-
var
|
|
147205
|
+
var fs62 = __toESM2(require("fs"));
|
|
147074
147206
|
var path60 = __toESM2(require("path"));
|
|
147075
147207
|
function slugifyFixtureName(value) {
|
|
147076
147208
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -147086,10 +147218,10 @@ async (params) => {
|
|
|
147086
147218
|
function readCliFixture(ctx, type2, name) {
|
|
147087
147219
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
147088
147220
|
const filePath = path60.join(fixtureDir, `${name}.json`);
|
|
147089
|
-
if (!
|
|
147221
|
+
if (!fs62.existsSync(filePath)) {
|
|
147090
147222
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
147091
147223
|
}
|
|
147092
|
-
return JSON.parse(
|
|
147224
|
+
return JSON.parse(fs62.readFileSync(filePath, "utf-8"));
|
|
147093
147225
|
}
|
|
147094
147226
|
function getExerciseTranscriptText(result) {
|
|
147095
147227
|
const parts = [];
|
|
@@ -147839,7 +147971,7 @@ async (params) => {
|
|
|
147839
147971
|
return;
|
|
147840
147972
|
}
|
|
147841
147973
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
147842
|
-
|
|
147974
|
+
fs62.mkdirSync(fixtureDir, { recursive: true });
|
|
147843
147975
|
const name = slugifyFixtureName(String(body?.name || `${type2}-${Date.now()}`));
|
|
147844
147976
|
const result = await runCliExerciseInternal(ctx, { ...request, type: type2 });
|
|
147845
147977
|
const fixture = {
|
|
@@ -147867,7 +147999,7 @@ async (params) => {
|
|
|
147867
147999
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
147868
148000
|
};
|
|
147869
148001
|
const filePath = path60.join(fixtureDir, `${name}.json`);
|
|
147870
|
-
|
|
148002
|
+
fs62.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
147871
148003
|
ctx.json(res, 200, {
|
|
147872
148004
|
saved: true,
|
|
147873
148005
|
name,
|
|
@@ -147885,14 +148017,14 @@ async (params) => {
|
|
|
147885
148017
|
async function handleCliFixtureList(ctx, type2, _req, res) {
|
|
147886
148018
|
try {
|
|
147887
148019
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
147888
|
-
if (!
|
|
148020
|
+
if (!fs62.existsSync(fixtureDir)) {
|
|
147889
148021
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
147890
148022
|
return;
|
|
147891
148023
|
}
|
|
147892
|
-
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) => {
|
|
147893
148025
|
const fullPath = path60.join(fixtureDir, file2);
|
|
147894
148026
|
try {
|
|
147895
|
-
const raw = JSON.parse(
|
|
148027
|
+
const raw = JSON.parse(fs62.readFileSync(fullPath, "utf-8"));
|
|
147896
148028
|
return {
|
|
147897
148029
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
147898
148030
|
path: fullPath,
|
|
@@ -148023,7 +148155,7 @@ async (params) => {
|
|
|
148023
148155
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
148024
148156
|
}
|
|
148025
148157
|
}
|
|
148026
|
-
var
|
|
148158
|
+
var fs63 = __toESM2(require("fs"));
|
|
148027
148159
|
var path61 = __toESM2(require("path"));
|
|
148028
148160
|
var os34 = __toESM2(require("os"));
|
|
148029
148161
|
var import_session_host_core10 = require_dist();
|
|
@@ -148072,10 +148204,10 @@ async (params) => {
|
|
|
148072
148204
|
return fallback?.type || null;
|
|
148073
148205
|
}
|
|
148074
148206
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
148075
|
-
if (!
|
|
148076
|
-
const versions =
|
|
148207
|
+
if (!fs63.existsSync(scriptsDir)) return null;
|
|
148208
|
+
const versions = fs63.readdirSync(scriptsDir).filter((d) => {
|
|
148077
148209
|
try {
|
|
148078
|
-
return
|
|
148210
|
+
return fs63.statSync(path61.join(scriptsDir, d)).isDirectory();
|
|
148079
148211
|
} catch {
|
|
148080
148212
|
return false;
|
|
148081
148213
|
}
|
|
@@ -148097,13 +148229,13 @@ async (params) => {
|
|
|
148097
148229
|
if (!sourceDir) {
|
|
148098
148230
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
148099
148231
|
}
|
|
148100
|
-
if (!
|
|
148101
|
-
|
|
148102
|
-
|
|
148232
|
+
if (!fs63.existsSync(desiredDir)) {
|
|
148233
|
+
fs63.mkdirSync(path61.dirname(desiredDir), { recursive: true });
|
|
148234
|
+
fs63.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
148103
148235
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
148104
148236
|
}
|
|
148105
148237
|
const providerJson = path61.join(desiredDir, "provider.json");
|
|
148106
|
-
if (!
|
|
148238
|
+
if (!fs63.existsSync(providerJson)) {
|
|
148107
148239
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
148108
148240
|
}
|
|
148109
148241
|
return { dir: desiredDir };
|
|
@@ -148111,15 +148243,15 @@ async (params) => {
|
|
|
148111
148243
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
148112
148244
|
if (!referenceType) return {};
|
|
148113
148245
|
const refDir = ctx.findProviderDir(referenceType);
|
|
148114
|
-
if (!refDir || !
|
|
148246
|
+
if (!refDir || !fs63.existsSync(refDir)) return {};
|
|
148115
148247
|
const referenceScripts = {};
|
|
148116
148248
|
const scriptsDir = path61.join(refDir, "scripts");
|
|
148117
148249
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
148118
148250
|
if (!latestDir) return referenceScripts;
|
|
148119
|
-
for (const file2 of
|
|
148251
|
+
for (const file2 of fs63.readdirSync(latestDir)) {
|
|
148120
148252
|
if (!file2.endsWith(".js")) continue;
|
|
148121
148253
|
try {
|
|
148122
|
-
referenceScripts[file2] =
|
|
148254
|
+
referenceScripts[file2] = fs63.readFileSync(path61.join(latestDir, file2), "utf-8");
|
|
148123
148255
|
} catch {
|
|
148124
148256
|
}
|
|
148125
148257
|
}
|
|
@@ -148228,15 +148360,15 @@ async (params) => {
|
|
|
148228
148360
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
148229
148361
|
const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
148230
148362
|
const tmpDir = path61.join(os34.tmpdir(), "adhdev-autoimpl");
|
|
148231
|
-
if (!
|
|
148363
|
+
if (!fs63.existsSync(tmpDir)) fs63.mkdirSync(tmpDir, { recursive: true });
|
|
148232
148364
|
const promptFile = path61.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
|
|
148233
|
-
|
|
148365
|
+
fs63.writeFileSync(promptFile, prompt, "utf-8");
|
|
148234
148366
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
148235
148367
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
148236
148368
|
const spawn7 = agentProvider?.spawn;
|
|
148237
148369
|
if (!spawn7?.command) {
|
|
148238
148370
|
try {
|
|
148239
|
-
|
|
148371
|
+
fs63.unlinkSync(promptFile);
|
|
148240
148372
|
} catch {
|
|
148241
148373
|
}
|
|
148242
148374
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -148339,7 +148471,7 @@ async (params) => {
|
|
|
148339
148471
|
} catch {
|
|
148340
148472
|
}
|
|
148341
148473
|
try {
|
|
148342
|
-
|
|
148474
|
+
fs63.unlinkSync(promptFile);
|
|
148343
148475
|
} catch {
|
|
148344
148476
|
}
|
|
148345
148477
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})`);
|
|
@@ -148563,7 +148695,7 @@ async (params) => {
|
|
|
148563
148695
|
}
|
|
148564
148696
|
});
|
|
148565
148697
|
try {
|
|
148566
|
-
|
|
148698
|
+
fs63.unlinkSync(promptFile);
|
|
148567
148699
|
} catch {
|
|
148568
148700
|
}
|
|
148569
148701
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -148668,10 +148800,10 @@ async (params) => {
|
|
|
148668
148800
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
148669
148801
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
148670
148802
|
lines.push("");
|
|
148671
|
-
for (const file2 of
|
|
148803
|
+
for (const file2 of fs63.readdirSync(latestScriptsDir)) {
|
|
148672
148804
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
148673
148805
|
try {
|
|
148674
|
-
const content =
|
|
148806
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
148675
148807
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
148676
148808
|
lines.push("```javascript");
|
|
148677
148809
|
lines.push(content);
|
|
@@ -148681,14 +148813,14 @@ async (params) => {
|
|
|
148681
148813
|
}
|
|
148682
148814
|
}
|
|
148683
148815
|
}
|
|
148684
|
-
const refFiles =
|
|
148816
|
+
const refFiles = fs63.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
148685
148817
|
if (refFiles.length > 0) {
|
|
148686
148818
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
148687
148819
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
148688
148820
|
lines.push("");
|
|
148689
148821
|
for (const file2 of refFiles) {
|
|
148690
148822
|
try {
|
|
148691
|
-
const content =
|
|
148823
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
148692
148824
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
148693
148825
|
lines.push("```javascript");
|
|
148694
148826
|
lines.push(content);
|
|
@@ -148733,7 +148865,7 @@ async (params) => {
|
|
|
148733
148865
|
const loadGuide = (name) => {
|
|
148734
148866
|
try {
|
|
148735
148867
|
const p = path61.join(docsDir, name);
|
|
148736
|
-
if (
|
|
148868
|
+
if (fs63.existsSync(p)) return fs63.readFileSync(p, "utf-8");
|
|
148737
148869
|
} catch {
|
|
148738
148870
|
}
|
|
148739
148871
|
return null;
|
|
@@ -148977,11 +149109,11 @@ async (params) => {
|
|
|
148977
149109
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
148978
149110
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
148979
149111
|
lines.push("");
|
|
148980
|
-
for (const file2 of
|
|
149112
|
+
for (const file2 of fs63.readdirSync(latestScriptsDir)) {
|
|
148981
149113
|
if (!file2.endsWith(".js")) continue;
|
|
148982
149114
|
if (!targetFileNames.has(file2)) continue;
|
|
148983
149115
|
try {
|
|
148984
|
-
const content =
|
|
149116
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
148985
149117
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
148986
149118
|
lines.push("```javascript");
|
|
148987
149119
|
lines.push(content);
|
|
@@ -148990,14 +149122,14 @@ async (params) => {
|
|
|
148990
149122
|
} catch {
|
|
148991
149123
|
}
|
|
148992
149124
|
}
|
|
148993
|
-
const refFiles =
|
|
149125
|
+
const refFiles = fs63.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
148994
149126
|
if (refFiles.length > 0) {
|
|
148995
149127
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
148996
149128
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
148997
149129
|
lines.push("");
|
|
148998
149130
|
for (const file2 of refFiles) {
|
|
148999
149131
|
try {
|
|
149000
|
-
const content =
|
|
149132
|
+
const content = fs63.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
149001
149133
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
149002
149134
|
lines.push("```javascript");
|
|
149003
149135
|
lines.push(content);
|
|
@@ -149034,7 +149166,7 @@ async (params) => {
|
|
|
149034
149166
|
const loadGuide = (name) => {
|
|
149035
149167
|
try {
|
|
149036
149168
|
const p = path61.join(docsDir, name);
|
|
149037
|
-
if (
|
|
149169
|
+
if (fs63.existsSync(p)) return fs63.readFileSync(p, "utf-8");
|
|
149038
149170
|
} catch {
|
|
149039
149171
|
}
|
|
149040
149172
|
return null;
|
|
@@ -149773,7 +149905,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149773
149905
|
path62.join(process.cwd(), "packages/web-devconsole/dist")
|
|
149774
149906
|
];
|
|
149775
149907
|
for (const dir of candidates) {
|
|
149776
|
-
if (
|
|
149908
|
+
if (fs64.existsSync(path62.join(dir, "index.html"))) return dir;
|
|
149777
149909
|
}
|
|
149778
149910
|
return null;
|
|
149779
149911
|
}
|
|
@@ -149785,7 +149917,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149785
149917
|
}
|
|
149786
149918
|
const htmlPath = path62.join(distDir, "index.html");
|
|
149787
149919
|
try {
|
|
149788
|
-
const html =
|
|
149920
|
+
const html = fs64.readFileSync(htmlPath, "utf-8");
|
|
149789
149921
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
149790
149922
|
res.end(html);
|
|
149791
149923
|
} catch (e) {
|
|
@@ -149815,7 +149947,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149815
149947
|
return;
|
|
149816
149948
|
}
|
|
149817
149949
|
try {
|
|
149818
|
-
const content =
|
|
149950
|
+
const content = fs64.readFileSync(filePath);
|
|
149819
149951
|
const ext = path62.extname(filePath);
|
|
149820
149952
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
149821
149953
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -149924,14 +150056,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149924
150056
|
const files = [];
|
|
149925
150057
|
const scan = (d, prefix) => {
|
|
149926
150058
|
try {
|
|
149927
|
-
for (const entry of
|
|
150059
|
+
for (const entry of fs64.readdirSync(d, { withFileTypes: true })) {
|
|
149928
150060
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
149929
150061
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
149930
150062
|
if (entry.isDirectory()) {
|
|
149931
150063
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
149932
150064
|
scan(path62.join(d, entry.name), rel);
|
|
149933
150065
|
} else {
|
|
149934
|
-
const stat2 =
|
|
150066
|
+
const stat2 = fs64.statSync(path62.join(d, entry.name));
|
|
149935
150067
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
149936
150068
|
}
|
|
149937
150069
|
}
|
|
@@ -149959,11 +150091,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149959
150091
|
this.json(res, 403, { error: "Forbidden" });
|
|
149960
150092
|
return;
|
|
149961
150093
|
}
|
|
149962
|
-
if (!
|
|
150094
|
+
if (!fs64.existsSync(fullPath) || fs64.statSync(fullPath).isDirectory()) {
|
|
149963
150095
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
149964
150096
|
return;
|
|
149965
150097
|
}
|
|
149966
|
-
const content =
|
|
150098
|
+
const content = fs64.readFileSync(fullPath, "utf-8");
|
|
149967
150099
|
this.json(res, 200, { type: type2, path: filePath, content, lines: content.split("\n").length });
|
|
149968
150100
|
}
|
|
149969
150101
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -149985,9 +150117,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149985
150117
|
return;
|
|
149986
150118
|
}
|
|
149987
150119
|
try {
|
|
149988
|
-
if (
|
|
149989
|
-
|
|
149990
|
-
|
|
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");
|
|
149991
150123
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
149992
150124
|
this.providerLoader.reload();
|
|
149993
150125
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -150004,8 +150136,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150004
150136
|
}
|
|
150005
150137
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
150006
150138
|
const p = path62.join(dir, name);
|
|
150007
|
-
if (
|
|
150008
|
-
const source =
|
|
150139
|
+
if (fs64.existsSync(p)) {
|
|
150140
|
+
const source = fs64.readFileSync(p, "utf-8");
|
|
150009
150141
|
this.json(res, 200, { type: type2, path: p, source, lines: source.split("\n").length });
|
|
150010
150142
|
return;
|
|
150011
150143
|
}
|
|
@@ -150024,11 +150156,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150024
150156
|
this.json(res, 404, { error: `Provider not found: ${type2}` });
|
|
150025
150157
|
return;
|
|
150026
150158
|
}
|
|
150027
|
-
const target =
|
|
150159
|
+
const target = fs64.existsSync(path62.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
150028
150160
|
const targetPath = path62.join(dir, target);
|
|
150029
150161
|
try {
|
|
150030
|
-
if (
|
|
150031
|
-
|
|
150162
|
+
if (fs64.existsSync(targetPath)) fs64.copyFileSync(targetPath, targetPath + ".bak");
|
|
150163
|
+
fs64.writeFileSync(targetPath, source, "utf-8");
|
|
150032
150164
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
150033
150165
|
this.providerLoader.reload();
|
|
150034
150166
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -150174,20 +150306,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150174
150306
|
let targetDir;
|
|
150175
150307
|
targetDir = this.providerLoader.getUserProviderDir(category, type2);
|
|
150176
150308
|
const jsonPath = path62.join(targetDir, "provider.json");
|
|
150177
|
-
if (
|
|
150309
|
+
if (fs64.existsSync(jsonPath)) {
|
|
150178
150310
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
150179
150311
|
return;
|
|
150180
150312
|
}
|
|
150181
150313
|
try {
|
|
150182
150314
|
const result = generateFiles(type2, name, category, { cdpPorts, cli, processName, installPath, binary: binary2, extensionId, version: version2, osPaths, processNames });
|
|
150183
|
-
|
|
150184
|
-
|
|
150315
|
+
fs64.mkdirSync(targetDir, { recursive: true });
|
|
150316
|
+
fs64.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
150185
150317
|
const createdFiles = ["provider.json"];
|
|
150186
150318
|
if (result.files) {
|
|
150187
150319
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
150188
150320
|
const fullPath = path62.join(targetDir, relPath);
|
|
150189
|
-
|
|
150190
|
-
|
|
150321
|
+
fs64.mkdirSync(path62.dirname(fullPath), { recursive: true });
|
|
150322
|
+
fs64.writeFileSync(fullPath, content, "utf-8");
|
|
150191
150323
|
createdFiles.push(relPath);
|
|
150192
150324
|
}
|
|
150193
150325
|
}
|
|
@@ -150236,10 +150368,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150236
150368
|
}
|
|
150237
150369
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
150238
150370
|
getLatestScriptVersionDir(scriptsDir) {
|
|
150239
|
-
if (!
|
|
150240
|
-
const versions =
|
|
150371
|
+
if (!fs64.existsSync(scriptsDir)) return null;
|
|
150372
|
+
const versions = fs64.readdirSync(scriptsDir).filter((d) => {
|
|
150241
150373
|
try {
|
|
150242
|
-
return
|
|
150374
|
+
return fs64.statSync(path62.join(scriptsDir, d)).isDirectory();
|
|
150243
150375
|
} catch {
|
|
150244
150376
|
return false;
|
|
150245
150377
|
}
|
|
@@ -150261,13 +150393,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150261
150393
|
if (!sourceDir) {
|
|
150262
150394
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
150263
150395
|
}
|
|
150264
|
-
if (!
|
|
150265
|
-
|
|
150266
|
-
|
|
150396
|
+
if (!fs64.existsSync(desiredDir)) {
|
|
150397
|
+
fs64.mkdirSync(path62.dirname(desiredDir), { recursive: true });
|
|
150398
|
+
fs64.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
150267
150399
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
150268
150400
|
}
|
|
150269
150401
|
const providerJson = path62.join(desiredDir, "provider.json");
|
|
150270
|
-
if (!
|
|
150402
|
+
if (!fs64.existsSync(providerJson)) {
|
|
150271
150403
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
150272
150404
|
}
|
|
150273
150405
|
return { dir: desiredDir };
|
|
@@ -151076,7 +151208,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151076
151208
|
}
|
|
151077
151209
|
}
|
|
151078
151210
|
var import_child_process14 = require("child_process");
|
|
151079
|
-
var
|
|
151211
|
+
var fs65 = __toESM2(require("fs"));
|
|
151080
151212
|
var os35 = __toESM2(require("os"));
|
|
151081
151213
|
var path63 = __toESM2(require("path"));
|
|
151082
151214
|
var import_session_host_core14 = require_dist();
|
|
@@ -151103,7 +151235,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151103
151235
|
path63.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
151104
151236
|
];
|
|
151105
151237
|
for (const candidate of packagedCandidates) {
|
|
151106
|
-
if (
|
|
151238
|
+
if (fs65.existsSync(candidate)) {
|
|
151107
151239
|
return candidate;
|
|
151108
151240
|
}
|
|
151109
151241
|
}
|
|
@@ -151123,8 +151255,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151123
151255
|
function getPid() {
|
|
151124
151256
|
try {
|
|
151125
151257
|
const pidFile = getPidFile();
|
|
151126
|
-
if (!
|
|
151127
|
-
const pid = Number.parseInt(
|
|
151258
|
+
if (!fs65.existsSync(pidFile)) return null;
|
|
151259
|
+
const pid = Number.parseInt(fs65.readFileSync(pidFile, "utf8").trim(), 10);
|
|
151128
151260
|
return Number.isFinite(pid) ? pid : null;
|
|
151129
151261
|
} catch {
|
|
151130
151262
|
return null;
|
|
@@ -151174,7 +151306,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151174
151306
|
if (markerIndex === -1) return;
|
|
151175
151307
|
const activePrefix = entry.slice(0, markerIndex);
|
|
151176
151308
|
const candidates = resolveConptyPrebuildCandidates(activePrefix);
|
|
151177
|
-
const found = candidates.find((candidate) =>
|
|
151309
|
+
const found = candidates.find((candidate) => fs65.existsSync(candidate));
|
|
151178
151310
|
if (!found) {
|
|
151179
151311
|
throw new Error(
|
|
151180
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.`
|
|
@@ -151191,8 +151323,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151191
151323
|
let logFd = null;
|
|
151192
151324
|
if (options.spawnStdio === "logfile") {
|
|
151193
151325
|
const logDir = path63.join(instance().configDir, "logs");
|
|
151194
|
-
|
|
151195
|
-
logFd =
|
|
151326
|
+
fs65.mkdirSync(logDir, { recursive: true });
|
|
151327
|
+
logFd = fs65.openSync(path63.join(logDir, "session-host.log"), "a");
|
|
151196
151328
|
stdio = ["ignore", logFd, logFd];
|
|
151197
151329
|
}
|
|
151198
151330
|
const child = (0, import_child_process14.spawn)(nodeExecutable, [entry], {
|
|
@@ -151217,7 +151349,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151217
151349
|
if (typeof child?.unref === "function") child.unref();
|
|
151218
151350
|
if (logFd !== null) {
|
|
151219
151351
|
try {
|
|
151220
|
-
|
|
151352
|
+
fs65.closeSync(logFd);
|
|
151221
151353
|
} catch {
|
|
151222
151354
|
}
|
|
151223
151355
|
}
|
|
@@ -151235,8 +151367,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151235
151367
|
const pidFile = getPidFile();
|
|
151236
151368
|
let keepPidFile = false;
|
|
151237
151369
|
try {
|
|
151238
|
-
if (
|
|
151239
|
-
const pid = Number.parseInt(
|
|
151370
|
+
if (fs65.existsSync(pidFile)) {
|
|
151371
|
+
const pid = Number.parseInt(fs65.readFileSync(pidFile, "utf8").trim(), 10);
|
|
151240
151372
|
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
151241
151373
|
const managed = isManagedPid(pid);
|
|
151242
151374
|
if (managed) {
|
|
@@ -151256,7 +151388,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151256
151388
|
} finally {
|
|
151257
151389
|
if (!keepPidFile) {
|
|
151258
151390
|
try {
|
|
151259
|
-
|
|
151391
|
+
fs65.unlinkSync(pidFile);
|
|
151260
151392
|
} catch {
|
|
151261
151393
|
}
|
|
151262
151394
|
}
|
|
@@ -151292,7 +151424,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151292
151424
|
}
|
|
151293
151425
|
if (!reported) return;
|
|
151294
151426
|
if (pathsEquivalent(reported, currentEntry)) return;
|
|
151295
|
-
const reportedExists =
|
|
151427
|
+
const reportedExists = fs65.existsSync(reported);
|
|
151296
151428
|
LOG2.warn(
|
|
151297
151429
|
"SessionHost",
|
|
151298
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.`
|
|
@@ -151520,8 +151652,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151520
151652
|
const res = await fetch(extension.vsixUrl);
|
|
151521
151653
|
if (res.ok) {
|
|
151522
151654
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
151523
|
-
const
|
|
151524
|
-
|
|
151655
|
+
const fs67 = await import("fs");
|
|
151656
|
+
fs67.writeFileSync(vsixPath, buffer);
|
|
151525
151657
|
return new Promise((resolve32) => {
|
|
151526
151658
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
151527
151659
|
(0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -154330,7 +154462,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
154330
154462
|
Object.values(V1_PRIMITIVE_CATALOG).flat()
|
|
154331
154463
|
);
|
|
154332
154464
|
var V1_CONTRACT_VERSION = "1.0.0";
|
|
154333
|
-
var
|
|
154465
|
+
var fs66 = __toESM2(require("fs"));
|
|
154334
154466
|
var import_chalk2 = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
154335
154467
|
init_dist();
|
|
154336
154468
|
var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
|
|
@@ -154485,7 +154617,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
154485
154617
|
console.log(import_chalk2.default.gray(` Backup: ${status.paths.backupFile}`));
|
|
154486
154618
|
let snapshotMtimeMs = null;
|
|
154487
154619
|
try {
|
|
154488
|
-
snapshotMtimeMs =
|
|
154620
|
+
snapshotMtimeMs = fs66.statSync(status.paths.snapshotFile).mtimeMs;
|
|
154489
154621
|
} catch {
|
|
154490
154622
|
}
|
|
154491
154623
|
console.log(import_chalk2.default.gray(
|