@adhdev/daemon-standalone 1.0.58-rc.50 → 1.0.58-rc.51
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 +610 -573
- 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 ? "8ae4b622b6ab59e300631f175785f024b2cbecb2" : void 0) ?? "unknown";
|
|
36915
|
+
const commitShort = readInjected(true ? "8ae4b622" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36916
|
+
const version2 = readInjected(true ? "1.0.58-rc.51" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36917
|
+
const builtAt = readInjected(true ? "2026-08-30T15:26:29.414Z" : 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 fs68 = require("fs");
|
|
42683
42683
|
const push = (dir) => {
|
|
42684
42684
|
if (!dir) return;
|
|
42685
42685
|
try {
|
|
42686
|
-
if (
|
|
42686
|
+
if (fs68.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 fs68 = 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 (fs68.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 fs68 = require("fs");
|
|
42747
|
+
if (fs68.existsSync(fullPath)) {
|
|
42748
|
+
const stat2 = fs68.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 fs68 = require("fs");
|
|
42763
|
+
const resolved = fs68.realpathSync(binaryPath);
|
|
42764
42764
|
const head = Buffer.alloc(8);
|
|
42765
|
-
const fd =
|
|
42766
|
-
|
|
42767
|
-
|
|
42765
|
+
const fd = fs68.openSync(resolved, "r");
|
|
42766
|
+
fs68.readSync(fd, head, 0, 8, 0);
|
|
42767
|
+
fs68.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 fs68 = require("fs");
|
|
42779
|
+
const resolved = fs68.realpathSync(filePath);
|
|
42780
42780
|
const buf = Buffer.alloc(8);
|
|
42781
|
-
const fd =
|
|
42782
|
-
|
|
42783
|
-
|
|
42781
|
+
const fd = fs68.openSync(resolved, "r");
|
|
42782
|
+
fs68.readSync(fd, buf, 0, 8, 0);
|
|
42783
|
+
fs68.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);
|
|
@@ -71315,8 +71315,8 @@ ${rendered}`, "utf-8");
|
|
|
71315
71315
|
if (!(0, import_node_fs3.existsSync)(filePath)) return;
|
|
71316
71316
|
if (owned) {
|
|
71317
71317
|
try {
|
|
71318
|
-
const
|
|
71319
|
-
|
|
71318
|
+
const fs68 = require("fs");
|
|
71319
|
+
fs68.unlinkSync(filePath);
|
|
71320
71320
|
} catch {
|
|
71321
71321
|
}
|
|
71322
71322
|
return;
|
|
@@ -71329,8 +71329,8 @@ ${rendered}`, "utf-8");
|
|
|
71329
71329
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
71330
71330
|
if (!remaining.trim()) {
|
|
71331
71331
|
try {
|
|
71332
|
-
const
|
|
71333
|
-
|
|
71332
|
+
const fs68 = require("fs");
|
|
71333
|
+
fs68.unlinkSync(filePath);
|
|
71334
71334
|
} catch {
|
|
71335
71335
|
}
|
|
71336
71336
|
} else {
|
|
@@ -89179,8 +89179,7 @@ ${cleanBody}`;
|
|
|
89179
89179
|
oversized: 0,
|
|
89180
89180
|
dropped: 0,
|
|
89181
89181
|
collectorUnavailable: 0,
|
|
89182
|
-
sourcePending: 0
|
|
89183
|
-
ptyDirtyCoalesced: 0
|
|
89182
|
+
sourcePending: 0
|
|
89184
89183
|
};
|
|
89185
89184
|
}
|
|
89186
89185
|
function redactSessionId(id) {
|
|
@@ -89197,17 +89196,22 @@ ${cleanBody}`;
|
|
|
89197
89196
|
function markTranscriptSessionDirty(sessionId) {
|
|
89198
89197
|
activeService?.markDirty(sessionId);
|
|
89199
89198
|
}
|
|
89200
|
-
function
|
|
89201
|
-
activeService?.
|
|
89199
|
+
function startTranscriptStatPolling(sessionId) {
|
|
89200
|
+
activeService?.startPolling(sessionId);
|
|
89202
89201
|
}
|
|
89202
|
+
function stopTranscriptStatPolling(sessionId) {
|
|
89203
|
+
activeService?.stopPolling(sessionId);
|
|
89204
|
+
}
|
|
89205
|
+
var fs19;
|
|
89203
89206
|
var import_node_crypto4;
|
|
89204
89207
|
var MAX_TRACKED_SESSIONS;
|
|
89205
|
-
var
|
|
89208
|
+
var TRANSCRIPT_STAT_POLL_INTERVAL_MS;
|
|
89206
89209
|
var TranscriptProjectionService;
|
|
89207
89210
|
var activeService;
|
|
89208
89211
|
var init_transcript_publisher = __esm2({
|
|
89209
89212
|
"src/seqscribe/transcript-publisher.ts"() {
|
|
89210
89213
|
"use strict";
|
|
89214
|
+
fs19 = __toESM2(require("fs"));
|
|
89211
89215
|
import_node_crypto4 = require("crypto");
|
|
89212
89216
|
init_logger();
|
|
89213
89217
|
init_transcript_revision_codec();
|
|
@@ -89215,7 +89219,7 @@ ${cleanBody}`;
|
|
|
89215
89219
|
init_transcript_observation();
|
|
89216
89220
|
init_transcript_mode();
|
|
89217
89221
|
MAX_TRACKED_SESSIONS = 512;
|
|
89218
|
-
|
|
89222
|
+
TRANSCRIPT_STAT_POLL_INTERVAL_MS = 3e3;
|
|
89219
89223
|
TranscriptProjectionService = class {
|
|
89220
89224
|
deps;
|
|
89221
89225
|
epoch;
|
|
@@ -89227,9 +89231,10 @@ ${cleanBody}`;
|
|
|
89227
89231
|
inFlight = /* @__PURE__ */ new Set();
|
|
89228
89232
|
pendingObservation = /* @__PURE__ */ new Map();
|
|
89229
89233
|
pendingPull = /* @__PURE__ */ new Set();
|
|
89230
|
-
|
|
89231
|
-
|
|
89232
|
-
|
|
89234
|
+
pollingSessions = /* @__PURE__ */ new Set();
|
|
89235
|
+
knownPaths = /* @__PURE__ */ new Map();
|
|
89236
|
+
lastSignatures = /* @__PURE__ */ new Map();
|
|
89237
|
+
statPollTimer = null;
|
|
89233
89238
|
constructor(deps) {
|
|
89234
89239
|
this.deps = deps;
|
|
89235
89240
|
this.epoch = deps.epoch ?? (0, import_node_crypto4.randomUUID)();
|
|
@@ -89246,6 +89251,10 @@ ${cleanBody}`;
|
|
|
89246
89251
|
return;
|
|
89247
89252
|
}
|
|
89248
89253
|
if (!this.admitSession(sessionId)) return;
|
|
89254
|
+
const sourcePath = observation.provenance?.transcriptProvenance?.sourcePath;
|
|
89255
|
+
if (typeof sourcePath === "string" && sourcePath) {
|
|
89256
|
+
this.knownPaths.set(sessionId, sourcePath);
|
|
89257
|
+
}
|
|
89249
89258
|
void this.runObserve(sessionId, observation);
|
|
89250
89259
|
}
|
|
89251
89260
|
/** PULL trigger — output-activity/status-change hooks that lack a fresh observation. */
|
|
@@ -89263,40 +89272,53 @@ ${cleanBody}`;
|
|
|
89263
89272
|
if (!this.admitSession(sessionId)) return;
|
|
89264
89273
|
void this.runPull(sessionId);
|
|
89265
89274
|
}
|
|
89266
|
-
|
|
89267
|
-
* PTY-output trigger. Pull the leading edge immediately, then collapse all
|
|
89268
|
-
* repaint chunks in the window into one trailing pull. The trailing pull is
|
|
89269
|
-
* mandatory even for a single byte because providers may append their JSONL
|
|
89270
|
-
* record just after writing the corresponding terminal output.
|
|
89271
|
-
*/
|
|
89272
|
-
markPtyOutputActivity(sessionId) {
|
|
89275
|
+
startPolling(sessionId) {
|
|
89273
89276
|
if (!sessionId) return;
|
|
89274
89277
|
if (this.mode() === "off") return;
|
|
89275
|
-
|
|
89276
|
-
|
|
89277
|
-
|
|
89278
|
-
|
|
89279
|
-
if (this.ptyDirtyTimers.has(sessionId)) {
|
|
89280
|
-
this.ptyDirtyTrailing.add(sessionId);
|
|
89281
|
-
this.counters.ptyDirtyCoalesced++;
|
|
89282
|
-
return;
|
|
89278
|
+
this.pollingSessions.add(sessionId);
|
|
89279
|
+
if (!this.statPollTimer) {
|
|
89280
|
+
this.statPollTimer = setInterval(() => this.runStatPoll(), TRANSCRIPT_STAT_POLL_INTERVAL_MS);
|
|
89281
|
+
this.statPollTimer.unref?.();
|
|
89283
89282
|
}
|
|
89284
|
-
this.markDirty(sessionId);
|
|
89285
|
-
this.ptyDirtyTrailing.add(sessionId);
|
|
89286
|
-
this.armPtyDirtyTimer(sessionId);
|
|
89287
89283
|
}
|
|
89288
|
-
|
|
89289
|
-
|
|
89290
|
-
|
|
89291
|
-
|
|
89292
|
-
|
|
89284
|
+
stopPolling(sessionId) {
|
|
89285
|
+
if (!sessionId) return;
|
|
89286
|
+
this.pollingSessions.delete(sessionId);
|
|
89287
|
+
this.knownPaths.delete(sessionId);
|
|
89288
|
+
this.lastSignatures.delete(sessionId);
|
|
89289
|
+
if (this.pollingSessions.size === 0 && this.statPollTimer) {
|
|
89290
|
+
clearInterval(this.statPollTimer);
|
|
89291
|
+
this.statPollTimer = null;
|
|
89292
|
+
}
|
|
89293
|
+
}
|
|
89294
|
+
runStatPoll() {
|
|
89295
|
+
for (const sessionId of this.pollingSessions) {
|
|
89296
|
+
let path64 = this.knownPaths.get(sessionId);
|
|
89297
|
+
if (!path64 && this.deps.resolveSourcePath) {
|
|
89298
|
+
path64 = this.deps.resolveSourcePath(sessionId) ?? void 0;
|
|
89299
|
+
if (path64) this.knownPaths.set(sessionId, path64);
|
|
89300
|
+
}
|
|
89301
|
+
if (!path64) continue;
|
|
89302
|
+
try {
|
|
89303
|
+
const st = fs19.statSync(path64);
|
|
89304
|
+
const sig = `${st.dev}:${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`;
|
|
89305
|
+
const lastSig = this.lastSignatures.get(sessionId);
|
|
89306
|
+
if (sig !== lastSig) {
|
|
89307
|
+
this.lastSignatures.set(sessionId, sig);
|
|
89308
|
+
if (lastSig !== void 0) {
|
|
89309
|
+
this.markDirty(sessionId);
|
|
89310
|
+
}
|
|
89311
|
+
}
|
|
89312
|
+
} catch {
|
|
89313
|
+
const lastSig = this.lastSignatures.get(sessionId);
|
|
89314
|
+
if (lastSig !== "missing") {
|
|
89315
|
+
this.lastSignatures.set(sessionId, "missing");
|
|
89316
|
+
if (lastSig !== void 0) {
|
|
89317
|
+
this.markDirty(sessionId);
|
|
89318
|
+
}
|
|
89319
|
+
}
|
|
89293
89320
|
}
|
|
89294
|
-
|
|
89295
|
-
this.armPtyDirtyTimer(sessionId);
|
|
89296
|
-
this.markDirty(sessionId);
|
|
89297
|
-
}, TRANSCRIPT_PTY_DIRTY_THROTTLE_MS);
|
|
89298
|
-
timer.unref?.();
|
|
89299
|
-
this.ptyDirtyTimers.set(sessionId, timer);
|
|
89321
|
+
}
|
|
89300
89322
|
}
|
|
89301
89323
|
/**
|
|
89302
89324
|
* Explicit alias for the restart/activation seed-read entry point (design
|
|
@@ -89407,9 +89429,11 @@ ${cleanBody}`;
|
|
|
89407
89429
|
}
|
|
89408
89430
|
/** Stop deferred PTY work when the singleton is replaced or disarmed. */
|
|
89409
89431
|
dispose() {
|
|
89410
|
-
|
|
89411
|
-
this.
|
|
89412
|
-
this.
|
|
89432
|
+
if (this.statPollTimer) clearInterval(this.statPollTimer);
|
|
89433
|
+
this.statPollTimer = null;
|
|
89434
|
+
this.pollingSessions.clear();
|
|
89435
|
+
this.knownPaths.clear();
|
|
89436
|
+
this.lastSignatures.clear();
|
|
89413
89437
|
}
|
|
89414
89438
|
};
|
|
89415
89439
|
activeService = null;
|
|
@@ -92453,13 +92477,13 @@ ${cleanBody}`;
|
|
|
92453
92477
|
}
|
|
92454
92478
|
function ensureAdhdevDir() {
|
|
92455
92479
|
const d = adhdevDir();
|
|
92456
|
-
if (!
|
|
92480
|
+
if (!fs24.existsSync(d)) fs24.mkdirSync(d, { recursive: true });
|
|
92457
92481
|
}
|
|
92458
92482
|
function loadExternalSources() {
|
|
92459
92483
|
const p = sourcesFilePath();
|
|
92460
|
-
if (!
|
|
92484
|
+
if (!fs24.existsSync(p)) return { schema: 1, sources: [] };
|
|
92461
92485
|
try {
|
|
92462
|
-
const raw = JSON.parse(
|
|
92486
|
+
const raw = JSON.parse(fs24.readFileSync(p, "utf-8"));
|
|
92463
92487
|
if (!raw || typeof raw !== "object") return { schema: 1, sources: [] };
|
|
92464
92488
|
const sources = Array.isArray(raw.sources) ? raw.sources.filter(isValidSource) : [];
|
|
92465
92489
|
return { schema: 1, sources };
|
|
@@ -92470,14 +92494,14 @@ ${cleanBody}`;
|
|
|
92470
92494
|
function saveExternalSources(file2) {
|
|
92471
92495
|
ensureAdhdevDir();
|
|
92472
92496
|
const tmp = sourcesFilePath() + ".tmp";
|
|
92473
|
-
|
|
92474
|
-
|
|
92497
|
+
fs24.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
|
|
92498
|
+
fs24.renameSync(tmp, sourcesFilePath());
|
|
92475
92499
|
}
|
|
92476
92500
|
function loadProvidersActive() {
|
|
92477
92501
|
const p = activeFilePath();
|
|
92478
|
-
if (!
|
|
92502
|
+
if (!fs24.existsSync(p)) return { schema: 1, active: {} };
|
|
92479
92503
|
try {
|
|
92480
|
-
const raw = JSON.parse(
|
|
92504
|
+
const raw = JSON.parse(fs24.readFileSync(p, "utf-8"));
|
|
92481
92505
|
if (!raw || typeof raw !== "object") return { schema: 1, active: {} };
|
|
92482
92506
|
const active = raw.active && typeof raw.active === "object" ? raw.active : {};
|
|
92483
92507
|
return { schema: 1, active };
|
|
@@ -92488,8 +92512,8 @@ ${cleanBody}`;
|
|
|
92488
92512
|
function saveProvidersActive(file2) {
|
|
92489
92513
|
ensureAdhdevDir();
|
|
92490
92514
|
const tmp = activeFilePath() + ".tmp";
|
|
92491
|
-
|
|
92492
|
-
|
|
92515
|
+
fs24.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
|
|
92516
|
+
fs24.renameSync(tmp, activeFilePath());
|
|
92493
92517
|
}
|
|
92494
92518
|
function isValidSource(x) {
|
|
92495
92519
|
if (!x || typeof x !== "object") return false;
|
|
@@ -92505,11 +92529,11 @@ ${cleanBody}`;
|
|
|
92505
92529
|
}
|
|
92506
92530
|
function inventoryExternalSources() {
|
|
92507
92531
|
const root = externalRoot();
|
|
92508
|
-
if (!
|
|
92532
|
+
if (!fs24.existsSync(root)) return [];
|
|
92509
92533
|
const out = [];
|
|
92510
92534
|
let entries;
|
|
92511
92535
|
try {
|
|
92512
|
-
entries =
|
|
92536
|
+
entries = fs24.readdirSync(root, { withFileTypes: true });
|
|
92513
92537
|
} catch {
|
|
92514
92538
|
return [];
|
|
92515
92539
|
}
|
|
@@ -92520,7 +92544,7 @@ ${cleanBody}`;
|
|
|
92520
92544
|
const providers = {};
|
|
92521
92545
|
let categoryEntries;
|
|
92522
92546
|
try {
|
|
92523
|
-
categoryEntries =
|
|
92547
|
+
categoryEntries = fs24.readdirSync(sourceDir, { withFileTypes: true });
|
|
92524
92548
|
} catch {
|
|
92525
92549
|
continue;
|
|
92526
92550
|
}
|
|
@@ -92530,7 +92554,7 @@ ${cleanBody}`;
|
|
|
92530
92554
|
const categoryDir = path322.join(sourceDir, category);
|
|
92531
92555
|
let typeEntries;
|
|
92532
92556
|
try {
|
|
92533
|
-
typeEntries =
|
|
92557
|
+
typeEntries = fs24.readdirSync(categoryDir, { withFileTypes: true });
|
|
92534
92558
|
} catch {
|
|
92535
92559
|
continue;
|
|
92536
92560
|
}
|
|
@@ -92538,8 +92562,8 @@ ${cleanBody}`;
|
|
|
92538
92562
|
for (const typeEntry of typeEntries) {
|
|
92539
92563
|
if (!typeEntry.isDirectory()) continue;
|
|
92540
92564
|
const typeDir = path322.join(categoryDir, typeEntry.name);
|
|
92541
|
-
const hasV1 =
|
|
92542
|
-
const hasV0 =
|
|
92565
|
+
const hasV1 = fs24.existsSync(path322.join(typeDir, "provider.v1.json"));
|
|
92566
|
+
const hasV0 = fs24.existsSync(path322.join(typeDir, "provider.json"));
|
|
92543
92567
|
if (hasV1 || hasV0) types2.push(typeEntry.name);
|
|
92544
92568
|
}
|
|
92545
92569
|
if (types2.length > 0) providers[category] = types2;
|
|
@@ -92562,14 +92586,14 @@ ${cleanBody}`;
|
|
|
92562
92586
|
}
|
|
92563
92587
|
return { source: candidates[0], ambiguous: true, candidates };
|
|
92564
92588
|
}
|
|
92565
|
-
var
|
|
92589
|
+
var fs24;
|
|
92566
92590
|
var path322;
|
|
92567
92591
|
var SOURCES_FILENAME;
|
|
92568
92592
|
var ACTIVE_FILENAME;
|
|
92569
92593
|
var init_external_sources = __esm2({
|
|
92570
92594
|
"src/providers/external-sources.ts"() {
|
|
92571
92595
|
"use strict";
|
|
92572
|
-
|
|
92596
|
+
fs24 = __toESM2(require("fs"));
|
|
92573
92597
|
path322 = __toESM2(require("path"));
|
|
92574
92598
|
init_config();
|
|
92575
92599
|
SOURCES_FILENAME = "providers-sources.json";
|
|
@@ -92617,7 +92641,7 @@ ${cleanBody}`;
|
|
|
92617
92641
|
function loadFsmSpec(sourcePath) {
|
|
92618
92642
|
let raw;
|
|
92619
92643
|
try {
|
|
92620
|
-
raw = JSON.parse(
|
|
92644
|
+
raw = JSON.parse(fs25.readFileSync(sourcePath, "utf8"));
|
|
92621
92645
|
} catch (err) {
|
|
92622
92646
|
return { ok: false, errors: [`Failed to read/parse spec: ${err.message}`], sourcePath };
|
|
92623
92647
|
}
|
|
@@ -92777,11 +92801,11 @@ ${cleanBody}`;
|
|
|
92777
92801
|
errs.push(`${path64} is not a recognized condition`);
|
|
92778
92802
|
return errs;
|
|
92779
92803
|
}
|
|
92780
|
-
var
|
|
92804
|
+
var fs25;
|
|
92781
92805
|
var init_fsm_loader = __esm2({
|
|
92782
92806
|
"src/providers/spec/fsm-loader.ts"() {
|
|
92783
92807
|
"use strict";
|
|
92784
|
-
|
|
92808
|
+
fs25 = __toESM2(require("fs"));
|
|
92785
92809
|
init_fsm_types();
|
|
92786
92810
|
}
|
|
92787
92811
|
});
|
|
@@ -93504,8 +93528,8 @@ ${cleanBody}`;
|
|
|
93504
93528
|
let cwd = options.cwd;
|
|
93505
93529
|
if (cwd) {
|
|
93506
93530
|
try {
|
|
93507
|
-
const
|
|
93508
|
-
const stat2 =
|
|
93531
|
+
const fs68 = require("fs");
|
|
93532
|
+
const stat2 = fs68.statSync(cwd);
|
|
93509
93533
|
if (!stat2.isDirectory()) cwd = os19.homedir();
|
|
93510
93534
|
} catch {
|
|
93511
93535
|
cwd = os19.homedir();
|
|
@@ -95626,7 +95650,7 @@ ${tail}`;
|
|
|
95626
95650
|
}
|
|
95627
95651
|
function probeGitAncestry(cwd, ancestor, descendant) {
|
|
95628
95652
|
try {
|
|
95629
|
-
if (!
|
|
95653
|
+
if (!fs53.existsSync(cwd)) return "undeterminable";
|
|
95630
95654
|
} catch {
|
|
95631
95655
|
return "undeterminable";
|
|
95632
95656
|
}
|
|
@@ -95697,7 +95721,7 @@ ${tail}`;
|
|
|
95697
95721
|
};
|
|
95698
95722
|
if (present()) return true;
|
|
95699
95723
|
try {
|
|
95700
|
-
if (!
|
|
95724
|
+
if (!fs53.existsSync(submoduleRepoPath) || !fs53.existsSync(baseSubmoduleRepoPath)) return false;
|
|
95701
95725
|
} catch {
|
|
95702
95726
|
return false;
|
|
95703
95727
|
}
|
|
@@ -95839,7 +95863,7 @@ ${tail}`;
|
|
|
95839
95863
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
95840
95864
|
};
|
|
95841
95865
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
95842
|
-
if (!
|
|
95866
|
+
if (!fs53.existsSync(worktreeSubmodulePath)) return false;
|
|
95843
95867
|
try {
|
|
95844
95868
|
await runGit4(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
95845
95869
|
} catch {
|
|
@@ -95881,7 +95905,7 @@ ${tail}`;
|
|
|
95881
95905
|
};
|
|
95882
95906
|
let submoduleDefaultBranch = "main";
|
|
95883
95907
|
try {
|
|
95884
|
-
if (!
|
|
95908
|
+
if (!fs53.existsSync(submodulePath)) {
|
|
95885
95909
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
95886
95910
|
entry.publishRequired = true;
|
|
95887
95911
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -96046,7 +96070,7 @@ ${tail}`;
|
|
|
96046
96070
|
};
|
|
96047
96071
|
}
|
|
96048
96072
|
}
|
|
96049
|
-
var
|
|
96073
|
+
var fs53;
|
|
96050
96074
|
var import_node_child_process9;
|
|
96051
96075
|
var import_path18;
|
|
96052
96076
|
var GIT2;
|
|
@@ -96057,7 +96081,7 @@ ${tail}`;
|
|
|
96057
96081
|
var init_mesh_refine_gitlink_utils = __esm2({
|
|
96058
96082
|
"src/mesh/mesh-refine-gitlink-utils.ts"() {
|
|
96059
96083
|
"use strict";
|
|
96060
|
-
|
|
96084
|
+
fs53 = __toESM2(require("fs"));
|
|
96061
96085
|
import_node_child_process9 = require("child_process");
|
|
96062
96086
|
import_path18 = require("path");
|
|
96063
96087
|
init_logger();
|
|
@@ -96114,7 +96138,7 @@ ${tail}`;
|
|
|
96114
96138
|
if (!baseCommit || !branchCommit) return "undeterminable";
|
|
96115
96139
|
if (baseCommit === branchCommit) return "not_diverged";
|
|
96116
96140
|
try {
|
|
96117
|
-
if (!
|
|
96141
|
+
if (!fs54.existsSync(submoduleRepoPath)) return "undeterminable";
|
|
96118
96142
|
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
96119
96143
|
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
96120
96144
|
} catch {
|
|
@@ -96449,7 +96473,7 @@ ${tail}`;
|
|
|
96449
96473
|
}
|
|
96450
96474
|
return { ok: true, branchHead };
|
|
96451
96475
|
}
|
|
96452
|
-
var
|
|
96476
|
+
var fs54;
|
|
96453
96477
|
var import_path19;
|
|
96454
96478
|
var import_node_child_process10;
|
|
96455
96479
|
var SUBMODULE_PUBLISH_REQUIRED_RECOMMENDED_ACTION;
|
|
@@ -96457,7 +96481,7 @@ ${tail}`;
|
|
|
96457
96481
|
var init_mesh_refine_submodule_converge = __esm2({
|
|
96458
96482
|
"src/mesh/mesh-refine-submodule-converge.ts"() {
|
|
96459
96483
|
"use strict";
|
|
96460
|
-
|
|
96484
|
+
fs54 = __toESM2(require("fs"));
|
|
96461
96485
|
import_path19 = require("path");
|
|
96462
96486
|
import_node_child_process10 = require("child_process");
|
|
96463
96487
|
init_mesh_refine_gitlink_utils();
|
|
@@ -96473,12 +96497,12 @@ ${tail}`;
|
|
|
96473
96497
|
function writeValidationFailureLog(workspace, index, candidate, streams, now = () => /* @__PURE__ */ new Date()) {
|
|
96474
96498
|
try {
|
|
96475
96499
|
const dir = (0, import_path20.join)(workspace, REFINE_VALIDATION_LOG_DIR);
|
|
96476
|
-
|
|
96500
|
+
fs55.mkdirSync(dir, { recursive: true });
|
|
96477
96501
|
const stamp2 = now().toISOString().replace(/[:.]/g, "-");
|
|
96478
96502
|
const file2 = (0, import_path20.join)(dir, `refine-${stamp2}-${index}.log`);
|
|
96479
96503
|
const asText = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
96480
96504
|
const shown = candidate.displayCommand || [candidate.command, ...candidate.args || []].join(" ");
|
|
96481
|
-
|
|
96505
|
+
fs55.writeFileSync(
|
|
96482
96506
|
file2,
|
|
96483
96507
|
`# refine validation failure
|
|
96484
96508
|
# command: ${shown}
|
|
@@ -97075,7 +97099,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97075
97099
|
return newTree || void 0;
|
|
97076
97100
|
} finally {
|
|
97077
97101
|
try {
|
|
97078
|
-
|
|
97102
|
+
fs55.rmSync(tmpIndex, { force: true });
|
|
97079
97103
|
} catch {
|
|
97080
97104
|
}
|
|
97081
97105
|
}
|
|
@@ -97150,7 +97174,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97150
97174
|
return newTree || void 0;
|
|
97151
97175
|
} finally {
|
|
97152
97176
|
try {
|
|
97153
|
-
|
|
97177
|
+
fs55.rmSync(tmpIndex, { force: true });
|
|
97154
97178
|
} catch {
|
|
97155
97179
|
}
|
|
97156
97180
|
}
|
|
@@ -97339,9 +97363,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97339
97363
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
97340
97364
|
};
|
|
97341
97365
|
const dependenciesLikelyMissing = (cwd) => {
|
|
97342
|
-
if (!
|
|
97343
|
-
if (
|
|
97344
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
97366
|
+
if (!fs55.existsSync((0, import_path20.join)(cwd, "package.json"))) return false;
|
|
97367
|
+
if (fs55.existsSync((0, import_path20.join)(cwd, "node_modules"))) return false;
|
|
97368
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs55.existsSync((0, import_path20.join)(cwd, lock)));
|
|
97345
97369
|
};
|
|
97346
97370
|
const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
|
|
97347
97371
|
const isDaemonScopedCommand = (candidate) => {
|
|
@@ -97511,7 +97535,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97511
97535
|
return summary;
|
|
97512
97536
|
}
|
|
97513
97537
|
var import_path20;
|
|
97514
|
-
var
|
|
97538
|
+
var fs55;
|
|
97515
97539
|
var import_node_child_process11;
|
|
97516
97540
|
var REFINE_VALIDATION_TIMEOUT_MS;
|
|
97517
97541
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES;
|
|
@@ -97523,7 +97547,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
97523
97547
|
init_refine_config();
|
|
97524
97548
|
init_worktree_bootstrap_config();
|
|
97525
97549
|
import_path20 = require("path");
|
|
97526
|
-
|
|
97550
|
+
fs55 = __toESM2(require("fs"));
|
|
97527
97551
|
import_node_child_process11 = require("child_process");
|
|
97528
97552
|
init_resolve_executable();
|
|
97529
97553
|
init_mesh_refine_worker_cap();
|
|
@@ -104791,7 +104815,7 @@ The pin is NOT cleared automatically: a pin often encodes required context conti
|
|
|
104791
104815
|
var import_fs21 = require("fs");
|
|
104792
104816
|
var import_os4 = require("os");
|
|
104793
104817
|
var path28 = __toESM2(require("path"));
|
|
104794
|
-
var
|
|
104818
|
+
var fs20 = __toESM2(require("fs"));
|
|
104795
104819
|
var path27 = __toESM2(require("path"));
|
|
104796
104820
|
function manifestCandidates(exeDir) {
|
|
104797
104821
|
return [
|
|
@@ -104816,14 +104840,14 @@ The pin is NOT cleared automatically: a pin often encodes required context conti
|
|
|
104816
104840
|
if (!exePath) return null;
|
|
104817
104841
|
let exeDir;
|
|
104818
104842
|
try {
|
|
104819
|
-
exeDir =
|
|
104843
|
+
exeDir = fs20.statSync(exePath).isDirectory() ? exePath : path27.dirname(exePath);
|
|
104820
104844
|
} catch {
|
|
104821
104845
|
exeDir = path27.dirname(exePath);
|
|
104822
104846
|
}
|
|
104823
104847
|
for (const candidate of manifestCandidates(exeDir)) {
|
|
104824
104848
|
try {
|
|
104825
|
-
if (!
|
|
104826
|
-
const version2 = parseVersionFromManifest(
|
|
104849
|
+
if (!fs20.existsSync(candidate)) continue;
|
|
104850
|
+
const version2 = parseVersionFromManifest(fs20.readFileSync(candidate, "utf-8"));
|
|
104827
104851
|
if (version2) return version2;
|
|
104828
104852
|
} catch {
|
|
104829
104853
|
}
|
|
@@ -108263,13 +108287,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
108263
108287
|
if (typeof instanceWorkspace === "string" && instanceWorkspace.trim()) return instanceWorkspace;
|
|
108264
108288
|
return "";
|
|
108265
108289
|
}
|
|
108266
|
-
var
|
|
108290
|
+
var fs222 = __toESM2(require("fs"));
|
|
108267
108291
|
var path30 = __toESM2(require("path"));
|
|
108268
108292
|
var import_node_crypto5 = require("crypto");
|
|
108269
108293
|
init_config();
|
|
108270
108294
|
init_logger();
|
|
108271
108295
|
init_debug_trace();
|
|
108272
|
-
var
|
|
108296
|
+
var fs21 = __toESM2(require("fs"));
|
|
108273
108297
|
var path29 = __toESM2(require("path"));
|
|
108274
108298
|
init_contracts2();
|
|
108275
108299
|
init_read_chat_contract();
|
|
@@ -109225,10 +109249,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
109225
109249
|
if (!text) return "";
|
|
109226
109250
|
const lexical = path29.resolve(text);
|
|
109227
109251
|
try {
|
|
109228
|
-
return
|
|
109252
|
+
return fs21.realpathSync.native(lexical);
|
|
109229
109253
|
} catch {
|
|
109230
109254
|
try {
|
|
109231
|
-
return
|
|
109255
|
+
return fs21.realpathSync(lexical);
|
|
109232
109256
|
} catch {
|
|
109233
109257
|
return lexical;
|
|
109234
109258
|
}
|
|
@@ -110455,11 +110479,11 @@ ${effect.notification.body || ""}`.trim();
|
|
|
110455
110479
|
function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
|
|
110456
110480
|
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
110457
110481
|
const dir = getChatDebugBundleDir();
|
|
110458
|
-
|
|
110482
|
+
fs222.mkdirSync(dir, { recursive: true });
|
|
110459
110483
|
const savedPath = path30.join(dir, `${bundleId}.json`);
|
|
110460
110484
|
const json3 = `${JSON.stringify(bundle, null, 2)}
|
|
110461
110485
|
`;
|
|
110462
|
-
|
|
110486
|
+
fs222.writeFileSync(savedPath, json3, { encoding: "utf8", mode: 384 });
|
|
110463
110487
|
return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json3, "utf8") };
|
|
110464
110488
|
}
|
|
110465
110489
|
function isDaemonFileDebugDelivery(args) {
|
|
@@ -111411,7 +111435,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
111411
111435
|
}
|
|
111412
111436
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
111413
111437
|
}
|
|
111414
|
-
var
|
|
111438
|
+
var fs23 = __toESM2(require("fs"));
|
|
111415
111439
|
var path31 = __toESM2(require("path"));
|
|
111416
111440
|
var os17 = __toESM2(require("os"));
|
|
111417
111441
|
var KEY_TO_VK = {
|
|
@@ -111684,7 +111708,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
111684
111708
|
return path31.resolve(inputPath);
|
|
111685
111709
|
}
|
|
111686
111710
|
function listDirectoryEntriesSafe(dirPath) {
|
|
111687
|
-
const entries =
|
|
111711
|
+
const entries = fs23.readdirSync(dirPath, { withFileTypes: true });
|
|
111688
111712
|
const files = [];
|
|
111689
111713
|
for (const entry of entries) {
|
|
111690
111714
|
const entryPath = path31.join(dirPath, entry.name);
|
|
@@ -111696,14 +111720,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
111696
111720
|
if (entry.isFile()) {
|
|
111697
111721
|
let size;
|
|
111698
111722
|
try {
|
|
111699
|
-
size =
|
|
111723
|
+
size = fs23.statSync(entryPath).size;
|
|
111700
111724
|
} catch {
|
|
111701
111725
|
size = void 0;
|
|
111702
111726
|
}
|
|
111703
111727
|
files.push({ name: entry.name, type: "file", size });
|
|
111704
111728
|
continue;
|
|
111705
111729
|
}
|
|
111706
|
-
const stat2 =
|
|
111730
|
+
const stat2 = fs23.statSync(entryPath);
|
|
111707
111731
|
files.push({
|
|
111708
111732
|
name: entry.name,
|
|
111709
111733
|
type: stat2.isDirectory() ? "directory" : "file",
|
|
@@ -111721,7 +111745,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
111721
111745
|
const letter = String.fromCharCode(code);
|
|
111722
111746
|
const root = `${letter}:\\`;
|
|
111723
111747
|
try {
|
|
111724
|
-
if (!
|
|
111748
|
+
if (!fs23.existsSync(root)) continue;
|
|
111725
111749
|
if (excluded && root.toLowerCase() === excluded) continue;
|
|
111726
111750
|
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
111727
111751
|
} catch {
|
|
@@ -111732,7 +111756,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
111732
111756
|
async function handleFileRead(h, args) {
|
|
111733
111757
|
try {
|
|
111734
111758
|
const filePath = resolveSafePath(args?.path);
|
|
111735
|
-
const content =
|
|
111759
|
+
const content = fs23.readFileSync(filePath, "utf-8");
|
|
111736
111760
|
return { success: true, content, path: filePath };
|
|
111737
111761
|
} catch (e) {
|
|
111738
111762
|
return { success: false, error: e.message };
|
|
@@ -111741,8 +111765,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
111741
111765
|
async function handleFileWrite(h, args) {
|
|
111742
111766
|
try {
|
|
111743
111767
|
const filePath = resolveSafePath(args?.path);
|
|
111744
|
-
|
|
111745
|
-
|
|
111768
|
+
fs23.mkdirSync(path31.dirname(filePath), { recursive: true });
|
|
111769
|
+
fs23.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
111746
111770
|
return { success: true, path: filePath };
|
|
111747
111771
|
} catch (e) {
|
|
111748
111772
|
return { success: false, error: e.message };
|
|
@@ -113020,7 +113044,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113020
113044
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
113021
113045
|
return { success: false, error: `unknown category: ${category}` };
|
|
113022
113046
|
}
|
|
113023
|
-
const
|
|
113047
|
+
const fs68 = require("fs");
|
|
113024
113048
|
const path64 = require("path");
|
|
113025
113049
|
try {
|
|
113026
113050
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -113029,9 +113053,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113029
113053
|
if (!targetDir.startsWith(installRootResolved + path64.sep)) {
|
|
113030
113054
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
113031
113055
|
}
|
|
113032
|
-
const hadUpstreamDir =
|
|
113056
|
+
const hadUpstreamDir = fs68.existsSync(targetDir);
|
|
113033
113057
|
if (hadUpstreamDir) {
|
|
113034
|
-
|
|
113058
|
+
fs68.rmSync(targetDir, { recursive: true, force: true });
|
|
113035
113059
|
}
|
|
113036
113060
|
let channelDeactivated = false;
|
|
113037
113061
|
try {
|
|
@@ -113060,28 +113084,28 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113060
113084
|
* the UI and by the update checker.
|
|
113061
113085
|
*/
|
|
113062
113086
|
handleListInstalledProviders(_args) {
|
|
113063
|
-
const
|
|
113087
|
+
const fs68 = require("fs");
|
|
113064
113088
|
const path64 = require("path");
|
|
113065
113089
|
const installRoot = this.getUpstreamInstallRoot();
|
|
113066
|
-
if (!
|
|
113090
|
+
if (!fs68.existsSync(installRoot)) return { success: true, providers: [] };
|
|
113067
113091
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
113068
113092
|
const items = [];
|
|
113069
113093
|
for (const category of CATEGORIES) {
|
|
113070
113094
|
const categoryDir = path64.join(installRoot, category);
|
|
113071
|
-
if (!
|
|
113095
|
+
if (!fs68.existsSync(categoryDir)) continue;
|
|
113072
113096
|
let entries;
|
|
113073
113097
|
try {
|
|
113074
|
-
entries =
|
|
113098
|
+
entries = fs68.readdirSync(categoryDir);
|
|
113075
113099
|
} catch {
|
|
113076
113100
|
continue;
|
|
113077
113101
|
}
|
|
113078
113102
|
for (const type2 of entries) {
|
|
113079
113103
|
const v1Path = path64.join(categoryDir, type2, "provider.v1.json");
|
|
113080
113104
|
const v0Path = path64.join(categoryDir, type2, "provider.json");
|
|
113081
|
-
const manifestPath =
|
|
113105
|
+
const manifestPath = fs68.existsSync(v1Path) ? v1Path : fs68.existsSync(v0Path) ? v0Path : null;
|
|
113082
113106
|
if (!manifestPath) continue;
|
|
113083
113107
|
try {
|
|
113084
|
-
const m = JSON.parse(
|
|
113108
|
+
const m = JSON.parse(fs68.readFileSync(manifestPath, "utf-8"));
|
|
113085
113109
|
const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
113086
113110
|
const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
113087
113111
|
items.push({
|
|
@@ -113347,7 +113371,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113347
113371
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
113348
113372
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
113349
113373
|
}
|
|
113350
|
-
const
|
|
113374
|
+
const fs68 = require("fs");
|
|
113351
113375
|
const path64 = require("path");
|
|
113352
113376
|
const { spawnSync: spawnSync3 } = require("child_process");
|
|
113353
113377
|
const file2 = ext.loadExternalSources();
|
|
@@ -113358,8 +113382,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113358
113382
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
113359
113383
|
}
|
|
113360
113384
|
const sourceDir = path64.join(ext.externalRoot(), requestedName);
|
|
113361
|
-
if (!
|
|
113362
|
-
if (
|
|
113385
|
+
if (!fs68.existsSync(ext.externalRoot())) fs68.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
113386
|
+
if (fs68.existsSync(sourceDir)) {
|
|
113363
113387
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
113364
113388
|
}
|
|
113365
113389
|
const clone2 = spawnSync3("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -113369,7 +113393,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113369
113393
|
});
|
|
113370
113394
|
if (clone2.status !== 0) {
|
|
113371
113395
|
try {
|
|
113372
|
-
|
|
113396
|
+
fs68.rmSync(sourceDir, { recursive: true, force: true });
|
|
113373
113397
|
} catch {
|
|
113374
113398
|
}
|
|
113375
113399
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -113413,15 +113437,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
113413
113437
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
113414
113438
|
if (!name) return { success: false, error: "name is required" };
|
|
113415
113439
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
113416
|
-
const
|
|
113440
|
+
const fs68 = require("fs");
|
|
113417
113441
|
const path64 = require("path");
|
|
113418
113442
|
const file2 = ext.loadExternalSources();
|
|
113419
113443
|
const match = file2.sources.find((s2) => s2.name === name);
|
|
113420
113444
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
113421
113445
|
const sourceDir = path64.join(ext.externalRoot(), name);
|
|
113422
|
-
if (
|
|
113446
|
+
if (fs68.existsSync(sourceDir)) {
|
|
113423
113447
|
try {
|
|
113424
|
-
|
|
113448
|
+
fs68.rmSync(sourceDir, { recursive: true, force: true });
|
|
113425
113449
|
} catch (e) {
|
|
113426
113450
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
113427
113451
|
}
|
|
@@ -114085,7 +114109,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
114085
114109
|
};
|
|
114086
114110
|
}
|
|
114087
114111
|
};
|
|
114088
|
-
var
|
|
114112
|
+
var fs26 = __toESM2(require("fs"));
|
|
114089
114113
|
init_logger();
|
|
114090
114114
|
init_debug_trace();
|
|
114091
114115
|
var diagnosticsHandlers = {
|
|
@@ -114105,8 +114129,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
114105
114129
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
114106
114130
|
}
|
|
114107
114131
|
const logPath = getCurrentDaemonLogPath();
|
|
114108
|
-
if (
|
|
114109
|
-
const content =
|
|
114132
|
+
if (fs26.existsSync(logPath)) {
|
|
114133
|
+
const content = fs26.readFileSync(logPath, "utf-8");
|
|
114110
114134
|
const allLines = content.split("\n");
|
|
114111
114135
|
const recent = allLines.slice(-count).join("\n");
|
|
114112
114136
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -114128,11 +114152,11 @@ ${effect.notification.body || ""}`.trim();
|
|
|
114128
114152
|
init_config();
|
|
114129
114153
|
var import_child_process8 = require("child_process");
|
|
114130
114154
|
var import_child_process9 = require("child_process");
|
|
114131
|
-
var
|
|
114155
|
+
var fs28 = __toESM2(require("fs"));
|
|
114132
114156
|
var os18 = __toESM2(require("os"));
|
|
114133
114157
|
var path34 = __toESM2(require("path"));
|
|
114134
114158
|
var import_child_process7 = require("child_process");
|
|
114135
|
-
var
|
|
114159
|
+
var fs27 = __toESM2(require("fs"));
|
|
114136
114160
|
var http2 = __toESM2(require("http"));
|
|
114137
114161
|
var path33 = __toESM2(require("path"));
|
|
114138
114162
|
init_track_identity();
|
|
@@ -114439,12 +114463,12 @@ ${effect.notification.body || ""}`.trim();
|
|
|
114439
114463
|
const candidates = [currentNode];
|
|
114440
114464
|
const portableRoot = path33.join(homeDir2, normalizeInstanceDir(instanceDir), "tools", "node22");
|
|
114441
114465
|
try {
|
|
114442
|
-
const dirs =
|
|
114466
|
+
const dirs = fs27.readdirSync(portableRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path33.join(portableRoot, entry.name, "node.exe"));
|
|
114443
114467
|
candidates.push(...dirs);
|
|
114444
114468
|
} catch {
|
|
114445
114469
|
}
|
|
114446
114470
|
for (const candidate of candidates) {
|
|
114447
|
-
if (candidate &&
|
|
114471
|
+
if (candidate && fs27.existsSync(candidate) && nodeMajor(candidate) === 22) return candidate;
|
|
114448
114472
|
}
|
|
114449
114473
|
return null;
|
|
114450
114474
|
}
|
|
@@ -114475,7 +114499,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
114475
114499
|
}
|
|
114476
114500
|
function verifyStagedConptyPrebuild(stagedPrefix, log) {
|
|
114477
114501
|
const candidates = resolveConptyPrebuildCandidates(stagedPrefix);
|
|
114478
|
-
const found = candidates.find((candidate) =>
|
|
114502
|
+
const found = candidates.find((candidate) => fs27.existsSync(candidate));
|
|
114479
114503
|
if (!found) {
|
|
114480
114504
|
throw new Error(
|
|
114481
114505
|
`Staged install is missing required native addon: node-pty's conpty.node prebuild (checked: ${candidates.join(", ")}). Aborting activation to prevent a daemon boot crash.`
|
|
@@ -114486,13 +114510,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
114486
114510
|
function readPackageCliEntry(prefix, packageName, targetVersion) {
|
|
114487
114511
|
const packageRoot = packageRootForPrefix(prefix, packageName);
|
|
114488
114512
|
const packageJsonPath = path33.join(packageRoot, "package.json");
|
|
114489
|
-
const pkg = JSON.parse(
|
|
114513
|
+
const pkg = JSON.parse(fs27.readFileSync(packageJsonPath, "utf8"));
|
|
114490
114514
|
if (pkg.name !== packageName) throw new Error(`staged package name mismatch: ${pkg.name || "missing"}`);
|
|
114491
114515
|
if (pkg.version !== targetVersion) throw new Error(`staged package version mismatch: ${pkg.version || "missing"}`);
|
|
114492
114516
|
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.adhdev || (pkg.bin ? Object.values(pkg.bin)[0] : void 0);
|
|
114493
114517
|
if (!bin) throw new Error("staged package has no CLI entry");
|
|
114494
114518
|
const cliEntry = path33.resolve(packageRoot, bin);
|
|
114495
|
-
if (!
|
|
114519
|
+
if (!fs27.existsSync(cliEntry)) throw new Error(`staged CLI entry is missing: ${cliEntry}`);
|
|
114496
114520
|
return cliEntry;
|
|
114497
114521
|
}
|
|
114498
114522
|
function quotePowerShellLiteral(value) {
|
|
@@ -114512,12 +114536,12 @@ exit $LASTEXITCODE\r
|
|
|
114512
114536
|
const noExt = `#!/bin/sh
|
|
114513
114537
|
exec "${portableNode}" "${cliEntry}" "$@"
|
|
114514
114538
|
`;
|
|
114515
|
-
|
|
114516
|
-
|
|
114517
|
-
|
|
114518
|
-
const cmdReadback =
|
|
114519
|
-
const ps1Readback =
|
|
114520
|
-
const noExtReadback =
|
|
114539
|
+
fs27.writeFileSync(cmdPath, cmd, "ascii");
|
|
114540
|
+
fs27.writeFileSync(ps1Path, ps1, "utf8");
|
|
114541
|
+
fs27.writeFileSync(noExtPath, noExt, "ascii");
|
|
114542
|
+
const cmdReadback = fs27.readFileSync(cmdPath, "utf8");
|
|
114543
|
+
const ps1Readback = fs27.readFileSync(ps1Path, "utf8");
|
|
114544
|
+
const noExtReadback = fs27.readFileSync(noExtPath, "utf8");
|
|
114521
114545
|
if (!cmdReadback.includes(portableNode) || !ps1Readback.includes(portableNode) || !noExtReadback.includes(portableNode) || /(^|\s)exec\s+node(\s|$)/m.test(noExtReadback)) {
|
|
114522
114546
|
throw new Error("portable Node 22 pin validation failed");
|
|
114523
114547
|
}
|
|
@@ -114534,7 +114558,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114534
114558
|
}
|
|
114535
114559
|
}
|
|
114536
114560
|
function atomicWrite(destination, content, encoding) {
|
|
114537
|
-
|
|
114561
|
+
fs27.mkdirSync(path33.dirname(destination), { recursive: true });
|
|
114538
114562
|
if (process.platform === "win32") {
|
|
114539
114563
|
const bytes = Buffer.from(content, encoding);
|
|
114540
114564
|
const payload = Buffer.from(JSON.stringify({ destination, bytes: bytes.toString("base64") }), "utf8").toString("base64");
|
|
@@ -114567,12 +114591,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114567
114591
|
return;
|
|
114568
114592
|
}
|
|
114569
114593
|
const temporary = `${destination}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
114570
|
-
|
|
114594
|
+
fs27.writeFileSync(temporary, content, encoding);
|
|
114571
114595
|
try {
|
|
114572
|
-
|
|
114596
|
+
fs27.renameSync(temporary, destination);
|
|
114573
114597
|
} catch (error48) {
|
|
114574
114598
|
try {
|
|
114575
|
-
|
|
114599
|
+
fs27.unlinkSync(temporary);
|
|
114576
114600
|
} catch {
|
|
114577
114601
|
}
|
|
114578
114602
|
throw error48;
|
|
@@ -114599,7 +114623,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114599
114623
|
for (const name of STABLE_FILES) {
|
|
114600
114624
|
const target = path33.join(stablePrefix, name);
|
|
114601
114625
|
try {
|
|
114602
|
-
snapshots.set(target, { exists: true, data:
|
|
114626
|
+
snapshots.set(target, { exists: true, data: fs27.readFileSync(target) });
|
|
114603
114627
|
} catch {
|
|
114604
114628
|
snapshots.set(target, { exists: false });
|
|
114605
114629
|
}
|
|
@@ -114619,12 +114643,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114619
114643
|
} else if (name === POINTER_NAME) {
|
|
114620
114644
|
if (layout.activeVersionName) writePointerVerified(target, layout.activeVersionName);
|
|
114621
114645
|
else try {
|
|
114622
|
-
|
|
114646
|
+
fs27.unlinkSync(target);
|
|
114623
114647
|
} catch {
|
|
114624
114648
|
}
|
|
114625
114649
|
} else {
|
|
114626
114650
|
try {
|
|
114627
|
-
|
|
114651
|
+
fs27.unlinkSync(target);
|
|
114628
114652
|
} catch {
|
|
114629
114653
|
}
|
|
114630
114654
|
}
|
|
@@ -114638,7 +114662,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114638
114662
|
if (REAL_PLATFORM !== "win32") return;
|
|
114639
114663
|
let readback = "";
|
|
114640
114664
|
try {
|
|
114641
|
-
readback =
|
|
114665
|
+
readback = fs27.readFileSync(pointerPath, "utf8").trim();
|
|
114642
114666
|
} catch (error48) {
|
|
114643
114667
|
throw new Error(`version pointer readback failed for ${pointerPath}: ${error48?.message || String(error48)}`);
|
|
114644
114668
|
}
|
|
@@ -114667,9 +114691,9 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114667
114691
|
log(`Refusing to clean up ${stagedPrefix}: not a version-* prefix under ${layout.installRoot}`);
|
|
114668
114692
|
return;
|
|
114669
114693
|
}
|
|
114670
|
-
if (!
|
|
114694
|
+
if (!fs27.existsSync(stagedPrefix)) return;
|
|
114671
114695
|
removeInactivePrefix(stagedPrefix, log);
|
|
114672
|
-
if (
|
|
114696
|
+
if (fs27.existsSync(stagedPrefix)) {
|
|
114673
114697
|
log(`Failed staged prefix ${stagedPrefix} could not be fully removed; a future update will retry`);
|
|
114674
114698
|
} else {
|
|
114675
114699
|
log(`Cleaned up failed staged prefix ${stagedPrefix}`);
|
|
@@ -114685,7 +114709,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114685
114709
|
const snapshots = snapshotStableFiles(layout.stablePrefix);
|
|
114686
114710
|
let activated = false;
|
|
114687
114711
|
let restarted = null;
|
|
114688
|
-
|
|
114712
|
+
fs27.mkdirSync(stagedPrefix, { recursive: false });
|
|
114689
114713
|
try {
|
|
114690
114714
|
hooks.log(`Installing ${packageName}@${targetVersion} into inactive prefix ${stagedPrefix}`);
|
|
114691
114715
|
await hooks.install(stagedPrefix, portableNode);
|
|
@@ -114854,7 +114878,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114854
114878
|
const { layout, activePrefix, log } = options;
|
|
114855
114879
|
let candidates = [];
|
|
114856
114880
|
try {
|
|
114857
|
-
candidates =
|
|
114881
|
+
candidates = fs27.readdirSync(layout.installRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("version-")).map((entry) => path33.join(layout.installRoot, entry.name)).filter((entry) => normalizeForCompare(entry) !== normalizeForCompare(activePrefix)).sort().slice(0, 8);
|
|
114858
114882
|
} catch {
|
|
114859
114883
|
return;
|
|
114860
114884
|
}
|
|
@@ -114882,7 +114906,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114882
114906
|
}
|
|
114883
114907
|
function removeInactivePrefix(target, log) {
|
|
114884
114908
|
try {
|
|
114885
|
-
|
|
114909
|
+
fs27.rmSync(target, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
|
|
114886
114910
|
} catch (error48) {
|
|
114887
114911
|
log?.(`Failed to remove inactive prefix ${target}: ${error48?.message || String(error48)}`);
|
|
114888
114912
|
}
|
|
@@ -114896,14 +114920,14 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114896
114920
|
return base || ".adhdev";
|
|
114897
114921
|
}
|
|
114898
114922
|
function getUpgradeLogPath(configDir = getConfigDir2()) {
|
|
114899
|
-
|
|
114923
|
+
fs28.mkdirSync(configDir, { recursive: true });
|
|
114900
114924
|
return path34.join(configDir, "daemon-upgrade.log");
|
|
114901
114925
|
}
|
|
114902
114926
|
function appendUpgradeLog(message, configDir = getConfigDir2()) {
|
|
114903
114927
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
114904
114928
|
`;
|
|
114905
114929
|
try {
|
|
114906
|
-
|
|
114930
|
+
fs28.appendFileSync(getUpgradeLogPath(configDir), line, "utf8");
|
|
114907
114931
|
} catch {
|
|
114908
114932
|
}
|
|
114909
114933
|
}
|
|
@@ -114911,12 +114935,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114911
114935
|
const binDir = path34.dirname(nodeExecutable);
|
|
114912
114936
|
if (platform11 === "win32") {
|
|
114913
114937
|
const npmCliPath = path34.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
114914
|
-
if (
|
|
114938
|
+
if (fs28.existsSync(npmCliPath)) {
|
|
114915
114939
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform11) };
|
|
114916
114940
|
}
|
|
114917
114941
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
114918
114942
|
const candidatePath = path34.join(binDir, candidate);
|
|
114919
|
-
if (
|
|
114943
|
+
if (fs28.existsSync(candidatePath)) {
|
|
114920
114944
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform11) };
|
|
114921
114945
|
}
|
|
114922
114946
|
}
|
|
@@ -114924,7 +114948,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114924
114948
|
}
|
|
114925
114949
|
for (const candidate of ["npm"]) {
|
|
114926
114950
|
const candidatePath = path34.join(binDir, candidate);
|
|
114927
|
-
if (
|
|
114951
|
+
if (fs28.existsSync(candidatePath)) {
|
|
114928
114952
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform11) };
|
|
114929
114953
|
}
|
|
114930
114954
|
}
|
|
@@ -114934,12 +114958,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114934
114958
|
if (!currentCliPath) return null;
|
|
114935
114959
|
let resolvedPath = currentCliPath;
|
|
114936
114960
|
try {
|
|
114937
|
-
resolvedPath =
|
|
114961
|
+
resolvedPath = fs28.realpathSync.native(currentCliPath);
|
|
114938
114962
|
} catch {
|
|
114939
114963
|
}
|
|
114940
114964
|
let currentDir2 = resolvedPath;
|
|
114941
114965
|
try {
|
|
114942
|
-
if (
|
|
114966
|
+
if (fs28.statSync(resolvedPath).isFile()) {
|
|
114943
114967
|
currentDir2 = path34.dirname(resolvedPath);
|
|
114944
114968
|
}
|
|
114945
114969
|
} catch {
|
|
@@ -114948,8 +114972,8 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114948
114972
|
while (true) {
|
|
114949
114973
|
const packageJsonPath = path34.join(currentDir2, "package.json");
|
|
114950
114974
|
try {
|
|
114951
|
-
if (
|
|
114952
|
-
const parsed = JSON.parse(
|
|
114975
|
+
if (fs28.existsSync(packageJsonPath)) {
|
|
114976
|
+
const parsed = JSON.parse(fs28.readFileSync(packageJsonPath, "utf8"));
|
|
114953
114977
|
if (parsed?.name === packageName) {
|
|
114954
114978
|
const normalized = currentDir2.replace(/\\/g, "/");
|
|
114955
114979
|
return normalized.includes("/node_modules/") ? currentDir2 : null;
|
|
@@ -114986,7 +115010,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
114986
115010
|
const installRoot = path34.join(homeDir2, instanceDir, "npm-installs");
|
|
114987
115011
|
const pointerPath = path34.join(homeDir2, instanceDir, "npm-global", ".adhdev-current");
|
|
114988
115012
|
try {
|
|
114989
|
-
const activeVersion =
|
|
115013
|
+
const activeVersion = fs28.readFileSync(pointerPath, "utf8").trim();
|
|
114990
115014
|
if (activeVersion.startsWith("version-")) return path34.join(installRoot, activeVersion);
|
|
114991
115015
|
} catch {
|
|
114992
115016
|
}
|
|
@@ -115114,8 +115138,8 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
115114
115138
|
let killedPid = null;
|
|
115115
115139
|
let keepPidFile = false;
|
|
115116
115140
|
try {
|
|
115117
|
-
if (
|
|
115118
|
-
const pid = Number.parseInt(
|
|
115141
|
+
if (fs28.existsSync(pidFile)) {
|
|
115142
|
+
const pid = Number.parseInt(fs28.readFileSync(pidFile, "utf8").trim(), 10);
|
|
115119
115143
|
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
115120
115144
|
outcome.pid = pid;
|
|
115121
115145
|
const identity = classifySessionHostPid(pid);
|
|
@@ -115153,7 +115177,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
115153
115177
|
keepPidFile = outcome.survived;
|
|
115154
115178
|
if (!keepPidFile) {
|
|
115155
115179
|
try {
|
|
115156
|
-
|
|
115180
|
+
fs28.unlinkSync(pidFile);
|
|
115157
115181
|
} catch {
|
|
115158
115182
|
}
|
|
115159
115183
|
} else {
|
|
@@ -115239,7 +115263,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
|
|
|
115239
115263
|
}
|
|
115240
115264
|
function getUpgradeFailureNoticePath(configDir = getConfigDir2()) {
|
|
115241
115265
|
try {
|
|
115242
|
-
|
|
115266
|
+
fs28.mkdirSync(configDir, { recursive: true });
|
|
115243
115267
|
} catch {
|
|
115244
115268
|
}
|
|
115245
115269
|
return path34.join(configDir, "daemon-upgrade-last-error.txt");
|
|
@@ -115256,7 +115280,7 @@ ${body}`, configDir);
|
|
|
115256
115280
|
const marker = target ? `${UPGRADE_FAILURE_TARGET_MARKER} ${target}
|
|
115257
115281
|
` : "";
|
|
115258
115282
|
try {
|
|
115259
|
-
|
|
115283
|
+
fs28.writeFileSync(
|
|
115260
115284
|
getUpgradeFailureNoticePath(configDir),
|
|
115261
115285
|
`[${(/* @__PURE__ */ new Date()).toISOString()}]
|
|
115262
115286
|
${body}
|
|
@@ -115269,7 +115293,7 @@ ${marker}`,
|
|
|
115269
115293
|
function clearUpgradeFailureNotice(configDir = getConfigDir2()) {
|
|
115270
115294
|
const noticePath = getUpgradeFailureNoticePath(configDir);
|
|
115271
115295
|
try {
|
|
115272
|
-
|
|
115296
|
+
fs28.unlinkSync(noticePath);
|
|
115273
115297
|
} catch (error48) {
|
|
115274
115298
|
if (error48?.code === "ENOENT") return;
|
|
115275
115299
|
appendUpgradeLog(
|
|
@@ -115302,8 +115326,8 @@ ${marker}`,
|
|
|
115302
115326
|
function readUpgradeFailureNotice(configDir = getConfigDir2()) {
|
|
115303
115327
|
try {
|
|
115304
115328
|
const noticePath = getUpgradeFailureNoticePath(configDir);
|
|
115305
|
-
if (!
|
|
115306
|
-
const notice =
|
|
115329
|
+
if (!fs28.existsSync(noticePath)) return null;
|
|
115330
|
+
const notice = fs28.readFileSync(noticePath, "utf8").trim();
|
|
115307
115331
|
if (!notice) return null;
|
|
115308
115332
|
const recordedAt = parseUpgradeNoticeTimestamp(notice);
|
|
115309
115333
|
const ageMs2 = recordedAt ? Date.now() - Date.parse(recordedAt) : null;
|
|
@@ -115329,13 +115353,13 @@ ${marker}`,
|
|
|
115329
115353
|
function removeDaemonPidFile(configDir = getConfigDir2()) {
|
|
115330
115354
|
const pidFile = path34.join(configDir, "daemon.pid");
|
|
115331
115355
|
try {
|
|
115332
|
-
|
|
115356
|
+
fs28.unlinkSync(pidFile);
|
|
115333
115357
|
} catch {
|
|
115334
115358
|
}
|
|
115335
115359
|
}
|
|
115336
115360
|
function safeRemoveStaleEntry(target, label) {
|
|
115337
115361
|
try {
|
|
115338
|
-
|
|
115362
|
+
fs28.rmSync(target, { recursive: true, force: true });
|
|
115339
115363
|
appendUpgradeLog(`${label}: ${target}`);
|
|
115340
115364
|
} catch (error48) {
|
|
115341
115365
|
appendUpgradeLog(`Skipped locked stale entry (${error48?.code || "error"}): ${target} \u2014 ${error48?.message || String(error48)}`);
|
|
@@ -115356,19 +115380,19 @@ ${marker}`,
|
|
|
115356
115380
|
if (pkgName.startsWith("@")) {
|
|
115357
115381
|
const [scope, name] = pkgName.split("/");
|
|
115358
115382
|
const scopeDir = path34.join(npmRoot, scope);
|
|
115359
|
-
if (!
|
|
115360
|
-
for (const entry of
|
|
115383
|
+
if (!fs28.existsSync(scopeDir)) return;
|
|
115384
|
+
for (const entry of fs28.readdirSync(scopeDir)) {
|
|
115361
115385
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
115362
115386
|
safeRemoveStaleEntry(path34.join(scopeDir, entry), "Removed stale scoped staging dir");
|
|
115363
115387
|
}
|
|
115364
115388
|
} else {
|
|
115365
|
-
for (const entry of
|
|
115389
|
+
for (const entry of fs28.readdirSync(npmRoot)) {
|
|
115366
115390
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
115367
115391
|
safeRemoveStaleEntry(path34.join(npmRoot, entry), "Removed stale staging dir");
|
|
115368
115392
|
}
|
|
115369
115393
|
}
|
|
115370
|
-
if (
|
|
115371
|
-
for (const entry of
|
|
115394
|
+
if (fs28.existsSync(binDir)) {
|
|
115395
|
+
for (const entry of fs28.readdirSync(binDir)) {
|
|
115372
115396
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
115373
115397
|
safeRemoveStaleEntry(path34.join(binDir, entry), "Removed stale bin staging entry");
|
|
115374
115398
|
}
|
|
@@ -115389,12 +115413,12 @@ ${marker}`,
|
|
|
115389
115413
|
const binDir = path34.join(prefix, "bin");
|
|
115390
115414
|
const names = resolvePosixBinNames(packageName);
|
|
115391
115415
|
const baseShim = path34.join(binDir, names[0]);
|
|
115392
|
-
if (!
|
|
115416
|
+
if (!fs28.existsSync(baseShim)) {
|
|
115393
115417
|
throw new Error(`installed CLI shim is missing: ${baseShim}`);
|
|
115394
115418
|
}
|
|
115395
115419
|
for (const name of names) {
|
|
115396
115420
|
const shimPath = path34.join(binDir, name);
|
|
115397
|
-
if (!
|
|
115421
|
+
if (!fs28.existsSync(shimPath)) continue;
|
|
115398
115422
|
(0, import_child_process8.execFileSync)(shimPath, ["--version"], {
|
|
115399
115423
|
encoding: "utf8",
|
|
115400
115424
|
stdio: "pipe",
|
|
@@ -115405,15 +115429,15 @@ ${marker}`,
|
|
|
115405
115429
|
}
|
|
115406
115430
|
function backupPosixInstall(options) {
|
|
115407
115431
|
try {
|
|
115408
|
-
|
|
115409
|
-
const backupDir =
|
|
115410
|
-
|
|
115432
|
+
fs28.mkdirSync(options.configDir, { recursive: true });
|
|
115433
|
+
const backupDir = fs28.mkdtempSync(path34.join(options.configDir, "upgrade-backup-"));
|
|
115434
|
+
fs28.cpSync(options.packageRoot, path34.join(backupDir, "package"), { recursive: true });
|
|
115411
115435
|
const binShims = [];
|
|
115412
115436
|
const binDir = path34.join(options.installPrefix, "bin");
|
|
115413
115437
|
for (const name of resolvePosixBinNames(options.packageName)) {
|
|
115414
115438
|
const shim = path34.join(binDir, name);
|
|
115415
|
-
if (
|
|
115416
|
-
|
|
115439
|
+
if (fs28.existsSync(shim)) {
|
|
115440
|
+
fs28.cpSync(shim, path34.join(backupDir, `bin-${name}`), { recursive: true });
|
|
115417
115441
|
binShims.push(shim);
|
|
115418
115442
|
}
|
|
115419
115443
|
}
|
|
@@ -115424,10 +115448,10 @@ ${marker}`,
|
|
|
115424
115448
|
}
|
|
115425
115449
|
}
|
|
115426
115450
|
function restorePosixInstall(backup) {
|
|
115427
|
-
|
|
115428
|
-
|
|
115451
|
+
fs28.rmSync(backup.packageRoot, { recursive: true, force: true });
|
|
115452
|
+
fs28.cpSync(path34.join(backup.backupDir, "package"), backup.packageRoot, { recursive: true });
|
|
115429
115453
|
for (const shim of backup.binShims) {
|
|
115430
|
-
|
|
115454
|
+
fs28.cpSync(path34.join(backup.backupDir, `bin-${path34.basename(shim)}`), shim, { recursive: true });
|
|
115431
115455
|
}
|
|
115432
115456
|
}
|
|
115433
115457
|
function runPosixInPlaceUpgrade(options) {
|
|
@@ -115436,7 +115460,7 @@ ${marker}`,
|
|
|
115436
115460
|
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
115437
115461
|
const { packageRoot, installPrefix } = installCommand.surface;
|
|
115438
115462
|
try {
|
|
115439
|
-
for (const entry of
|
|
115463
|
+
for (const entry of fs28.readdirSync(configDir)) {
|
|
115440
115464
|
if (entry.startsWith("upgrade-preflight-")) {
|
|
115441
115465
|
safeRemoveStaleEntry(path34.join(configDir, entry), "Removed stale pre-flight staging prefix");
|
|
115442
115466
|
}
|
|
@@ -115444,8 +115468,8 @@ ${marker}`,
|
|
|
115444
115468
|
} catch {
|
|
115445
115469
|
}
|
|
115446
115470
|
const preflightPrefix = (() => {
|
|
115447
|
-
|
|
115448
|
-
return
|
|
115471
|
+
fs28.mkdirSync(configDir, { recursive: true });
|
|
115472
|
+
return fs28.mkdtempSync(path34.join(configDir, "upgrade-preflight-"));
|
|
115449
115473
|
})();
|
|
115450
115474
|
try {
|
|
115451
115475
|
appendUpgradeLog(`Pre-flight: installing ${spec} into throwaway prefix ${preflightPrefix}`);
|
|
@@ -115610,7 +115634,7 @@ ${marker}`,
|
|
|
115610
115634
|
throw new Error("installer-managed Windows update requires the portable Node.js 22 runtime");
|
|
115611
115635
|
}
|
|
115612
115636
|
const npmCliPath = path34.join(path34.dirname(portableNode), "node_modules", "npm", "bin", "npm-cli.js");
|
|
115613
|
-
if (!
|
|
115637
|
+
if (!fs28.existsSync(npmCliPath)) {
|
|
115614
115638
|
throw new Error(`portable Node.js 22 npm CLI is missing: ${npmCliPath}`);
|
|
115615
115639
|
}
|
|
115616
115640
|
appendUpgradeLog(`Installer-managed pointer layout detected; active prefix will remain untouched: ${windowsInstallerLayout.activePrefix}`);
|
|
@@ -116066,14 +116090,14 @@ ${marker}`,
|
|
|
116066
116090
|
}
|
|
116067
116091
|
},
|
|
116068
116092
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
116069
|
-
const
|
|
116093
|
+
const fs68 = await import("fs");
|
|
116070
116094
|
const path64 = await import("path");
|
|
116071
116095
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
116072
116096
|
const dir = path64.join(getConfigDir22(), "coordinator-prompts");
|
|
116073
116097
|
const entries = {};
|
|
116074
116098
|
try {
|
|
116075
|
-
if (
|
|
116076
|
-
for (const name of
|
|
116099
|
+
if (fs68.existsSync(dir)) {
|
|
116100
|
+
for (const name of fs68.readdirSync(dir)) {
|
|
116077
116101
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
116078
116102
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
116079
116103
|
const m = matchAppend || matchOverride;
|
|
@@ -116083,7 +116107,7 @@ ${marker}`,
|
|
|
116083
116107
|
const full = path64.join(dir, name);
|
|
116084
116108
|
let content = "";
|
|
116085
116109
|
try {
|
|
116086
|
-
content =
|
|
116110
|
+
content = fs68.readFileSync(full, "utf8");
|
|
116087
116111
|
} catch {
|
|
116088
116112
|
}
|
|
116089
116113
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -116097,7 +116121,7 @@ ${marker}`,
|
|
|
116097
116121
|
return { success: true, dir, entries };
|
|
116098
116122
|
},
|
|
116099
116123
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
116100
|
-
const
|
|
116124
|
+
const fs68 = await import("fs");
|
|
116101
116125
|
const path64 = await import("path");
|
|
116102
116126
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
116103
116127
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -116110,11 +116134,11 @@ ${marker}`,
|
|
|
116110
116134
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
116111
116135
|
const full = path64.join(dir, filename);
|
|
116112
116136
|
try {
|
|
116113
|
-
|
|
116137
|
+
fs68.mkdirSync(dir, { recursive: true });
|
|
116114
116138
|
if (content.trim()) {
|
|
116115
|
-
|
|
116116
|
-
} else if (
|
|
116117
|
-
|
|
116139
|
+
fs68.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
116140
|
+
} else if (fs68.existsSync(full)) {
|
|
116141
|
+
fs68.unlinkSync(full);
|
|
116118
116142
|
}
|
|
116119
116143
|
return { success: true, path: full, kind, key: key2 };
|
|
116120
116144
|
} catch (error48) {
|
|
@@ -116586,7 +116610,7 @@ ${marker}`,
|
|
|
116586
116610
|
}
|
|
116587
116611
|
};
|
|
116588
116612
|
init_dist();
|
|
116589
|
-
var
|
|
116613
|
+
var fs29 = __toESM2(require("fs"));
|
|
116590
116614
|
init_logger();
|
|
116591
116615
|
var DEFAULT_TAIL_BYTES = 64 * 1024;
|
|
116592
116616
|
var MAX_TAIL_BYTES2 = 128 * 1024;
|
|
@@ -116610,9 +116634,9 @@ ${marker}`,
|
|
|
116610
116634
|
return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES2);
|
|
116611
116635
|
}
|
|
116612
116636
|
function readByteBoundedTail(filePath, limitBytes) {
|
|
116613
|
-
const fd =
|
|
116637
|
+
const fd = fs29.openSync(filePath, "r");
|
|
116614
116638
|
try {
|
|
116615
|
-
const stat2 =
|
|
116639
|
+
const stat2 = fs29.fstatSync(fd);
|
|
116616
116640
|
const size = stat2.size;
|
|
116617
116641
|
if (size === 0) return { text: "", truncated: false, bytesReturned: 0 };
|
|
116618
116642
|
const want = Math.min(limitBytes, size);
|
|
@@ -116623,7 +116647,7 @@ ${marker}`,
|
|
|
116623
116647
|
while (position < size) {
|
|
116624
116648
|
const chunkSize = Math.min(READ_CHUNK_BYTES, size - position);
|
|
116625
116649
|
const chunk = Buffer.alloc(chunkSize);
|
|
116626
|
-
|
|
116650
|
+
fs29.readSync(fd, chunk, 0, chunkSize, position);
|
|
116627
116651
|
buffers.push(chunk);
|
|
116628
116652
|
position += chunkSize;
|
|
116629
116653
|
}
|
|
@@ -116636,7 +116660,7 @@ ${marker}`,
|
|
|
116636
116660
|
}
|
|
116637
116661
|
return { text: buf.toString("utf-8"), truncated, bytesReturned: buf.length };
|
|
116638
116662
|
} finally {
|
|
116639
|
-
|
|
116663
|
+
fs29.closeSync(fd);
|
|
116640
116664
|
}
|
|
116641
116665
|
}
|
|
116642
116666
|
function splitLogLines(text) {
|
|
@@ -116714,8 +116738,8 @@ ${marker}`,
|
|
|
116714
116738
|
const limitBytes = clampTailBytes(args.tailBytes);
|
|
116715
116739
|
const primaryPath = resolveLogPath(args.date);
|
|
116716
116740
|
const backupPaths = sizeRotationPaths(primaryPath);
|
|
116717
|
-
const primaryExists =
|
|
116718
|
-
const existingBackupPaths = backupPaths.filter((backupPath2) =>
|
|
116741
|
+
const primaryExists = fs29.existsSync(primaryPath);
|
|
116742
|
+
const existingBackupPaths = backupPaths.filter((backupPath2) => fs29.existsSync(backupPath2));
|
|
116719
116743
|
if (!primaryExists && existingBackupPaths.length === 0) {
|
|
116720
116744
|
return errorResult(
|
|
116721
116745
|
`No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
|
|
@@ -116754,7 +116778,7 @@ ${marker}`,
|
|
|
116754
116778
|
try {
|
|
116755
116779
|
for (const p of [...existingBackupPaths].reverse().concat(primaryExists ? [primaryPath] : [])) {
|
|
116756
116780
|
if (!p) continue;
|
|
116757
|
-
const buf =
|
|
116781
|
+
const buf = fs29.readFileSync(p);
|
|
116758
116782
|
scannedBytes += buf.length;
|
|
116759
116783
|
allLines = allLines.concat(splitLogLines(buf.toString("utf-8")));
|
|
116760
116784
|
}
|
|
@@ -117161,9 +117185,9 @@ ${marker}`,
|
|
|
117161
117185
|
var import_fs22 = require("fs");
|
|
117162
117186
|
var import_child_process11 = require("child_process");
|
|
117163
117187
|
var import_chalk = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
117164
|
-
var
|
|
117188
|
+
var fs43 = __toESM2(require("fs"));
|
|
117165
117189
|
var path46 = __toESM2(require("path"));
|
|
117166
|
-
var
|
|
117190
|
+
var fs322 = __toESM2(require("fs"));
|
|
117167
117191
|
var os23 = __toESM2(require("os"));
|
|
117168
117192
|
var path38 = __toESM2(require("path"));
|
|
117169
117193
|
init_terminal_screen();
|
|
@@ -117441,10 +117465,10 @@ ${marker}`,
|
|
|
117441
117465
|
init_fsm_evaluator();
|
|
117442
117466
|
init_fsm_types();
|
|
117443
117467
|
init_fsm_loader();
|
|
117444
|
-
var
|
|
117468
|
+
var fs31 = __toESM2(require("fs"));
|
|
117445
117469
|
var os222 = __toESM2(require("os"));
|
|
117446
117470
|
var path37 = __toESM2(require("path"));
|
|
117447
|
-
var
|
|
117471
|
+
var fs30 = __toESM2(require("fs"));
|
|
117448
117472
|
var os21 = __toESM2(require("os"));
|
|
117449
117473
|
var path36 = __toESM2(require("path"));
|
|
117450
117474
|
var crypto4 = __toESM2(require("crypto"));
|
|
@@ -117456,7 +117480,7 @@ ${marker}`,
|
|
|
117456
117480
|
}
|
|
117457
117481
|
function realWorkspacePath(workingDir) {
|
|
117458
117482
|
try {
|
|
117459
|
-
return
|
|
117483
|
+
return fs30.realpathSync(workingDir);
|
|
117460
117484
|
} catch {
|
|
117461
117485
|
return path36.resolve(workingDir);
|
|
117462
117486
|
}
|
|
@@ -117479,12 +117503,12 @@ ${marker}`,
|
|
|
117479
117503
|
const trustDir = path36.join(kimiHome2(env2), "workspace-trust");
|
|
117480
117504
|
const trustFile = path36.join(trustDir, key2);
|
|
117481
117505
|
try {
|
|
117482
|
-
if (
|
|
117506
|
+
if (fs30.existsSync(trustFile)) {
|
|
117483
117507
|
LOG2.debug("kimi-workspace-trust", `${real} already trusted (${key2}) \u2014 no change`);
|
|
117484
117508
|
return null;
|
|
117485
117509
|
}
|
|
117486
|
-
|
|
117487
|
-
|
|
117510
|
+
fs30.mkdirSync(trustDir, { recursive: true });
|
|
117511
|
+
fs30.writeFileSync(trustFile, JSON.stringify({ root: real, trustedAt: Date.now() }), "utf8");
|
|
117488
117512
|
LOG2.info("kimi-workspace-trust", `pre-trusted workspace ${real} (${key2})`);
|
|
117489
117513
|
return real;
|
|
117490
117514
|
} catch (err) {
|
|
@@ -117500,7 +117524,7 @@ ${marker}`,
|
|
|
117500
117524
|
}
|
|
117501
117525
|
function realWorkspacePath2(workingDir) {
|
|
117502
117526
|
try {
|
|
117503
|
-
return
|
|
117527
|
+
return fs31.realpathSync(workingDir);
|
|
117504
117528
|
} catch {
|
|
117505
117529
|
return path37.resolve(workingDir);
|
|
117506
117530
|
}
|
|
@@ -117515,8 +117539,8 @@ ${marker}`,
|
|
|
117515
117539
|
const real = realWorkspacePath2(workingDir);
|
|
117516
117540
|
try {
|
|
117517
117541
|
let parsed = {};
|
|
117518
|
-
if (
|
|
117519
|
-
const text =
|
|
117542
|
+
if (fs31.existsSync(settingsPath)) {
|
|
117543
|
+
const text = fs31.readFileSync(settingsPath, "utf8");
|
|
117520
117544
|
if (text.trim().length > 0) {
|
|
117521
117545
|
const json3 = JSON.parse(text);
|
|
117522
117546
|
if (json3 && typeof json3 === "object" && !Array.isArray(json3)) {
|
|
@@ -117532,8 +117556,8 @@ ${marker}`,
|
|
|
117532
117556
|
}
|
|
117533
117557
|
list.push(real);
|
|
117534
117558
|
parsed[key2] = list;
|
|
117535
|
-
|
|
117536
|
-
|
|
117559
|
+
fs31.mkdirSync(path37.dirname(settingsPath), { recursive: true });
|
|
117560
|
+
fs31.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
|
|
117537
117561
|
`, "utf8");
|
|
117538
117562
|
LOG2.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key2}")`);
|
|
117539
117563
|
return real;
|
|
@@ -118063,7 +118087,7 @@ ${marker}`,
|
|
|
118063
118087
|
try {
|
|
118064
118088
|
const dir = path38.dirname(this.opts.specPath);
|
|
118065
118089
|
const base = path38.basename(this.opts.specPath);
|
|
118066
|
-
this.specWatcher =
|
|
118090
|
+
this.specWatcher = fs322.watch(dir, { persistent: false }, (_event, filename) => {
|
|
118067
118091
|
if (filename && filename !== base) return;
|
|
118068
118092
|
const res = loadFsmSpec(this.opts.specPath);
|
|
118069
118093
|
if (!res.ok) {
|
|
@@ -118879,7 +118903,7 @@ ${marker}`,
|
|
|
118879
118903
|
const ext = guessExt(mime);
|
|
118880
118904
|
const tmp = path38.join(os23.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
|
|
118881
118905
|
try {
|
|
118882
|
-
|
|
118906
|
+
fs322.writeFileSync(tmp, Buffer.from(blob, "base64"));
|
|
118883
118907
|
} catch {
|
|
118884
118908
|
return;
|
|
118885
118909
|
}
|
|
@@ -119021,7 +119045,7 @@ ${marker}`,
|
|
|
119021
119045
|
return { start, end };
|
|
119022
119046
|
}
|
|
119023
119047
|
init_evaluator();
|
|
119024
|
-
var
|
|
119048
|
+
var fs34 = __toESM2(require("fs"));
|
|
119025
119049
|
var os24 = __toESM2(require("os"));
|
|
119026
119050
|
var path39 = __toESM2(require("path"));
|
|
119027
119051
|
init_logger();
|
|
@@ -119087,7 +119111,7 @@ ${marker}`,
|
|
|
119087
119111
|
}
|
|
119088
119112
|
}
|
|
119089
119113
|
}
|
|
119090
|
-
var
|
|
119114
|
+
var fs33 = __toESM2(require("fs"));
|
|
119091
119115
|
var PARSED_JSONL_CACHE_MAX_ENTRIES = 8;
|
|
119092
119116
|
var PARSED_JSONL_CACHE_MAX_SOURCE_BYTES = 16 * 1024 * 1024;
|
|
119093
119117
|
var parsedJsonlCache = /* @__PURE__ */ new Map();
|
|
@@ -119114,7 +119138,7 @@ ${marker}`,
|
|
|
119114
119138
|
function readJsonlLines(p, forceRefresh = false) {
|
|
119115
119139
|
let stat2;
|
|
119116
119140
|
try {
|
|
119117
|
-
stat2 =
|
|
119141
|
+
stat2 = fs33.statSync(p);
|
|
119118
119142
|
} catch {
|
|
119119
119143
|
return [];
|
|
119120
119144
|
}
|
|
@@ -119129,7 +119153,7 @@ ${marker}`,
|
|
|
119129
119153
|
parsedJsonlCacheStats.misses++;
|
|
119130
119154
|
let text;
|
|
119131
119155
|
try {
|
|
119132
|
-
text =
|
|
119156
|
+
text = fs33.readFileSync(p, "utf8");
|
|
119133
119157
|
parsedJsonlCacheStats.fileReads++;
|
|
119134
119158
|
} catch {
|
|
119135
119159
|
return [];
|
|
@@ -119296,7 +119320,7 @@ ${marker}`,
|
|
|
119296
119320
|
const wsRaw = typeof input.workspace === "string" ? input.workspace : "";
|
|
119297
119321
|
let wsReal = wsRaw;
|
|
119298
119322
|
try {
|
|
119299
|
-
if (wsRaw) wsReal =
|
|
119323
|
+
if (wsRaw) wsReal = fs34.realpathSync(wsRaw);
|
|
119300
119324
|
} catch {
|
|
119301
119325
|
}
|
|
119302
119326
|
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)`);
|
|
@@ -119439,7 +119463,7 @@ ${marker}`,
|
|
|
119439
119463
|
} else {
|
|
119440
119464
|
let stat2 = null;
|
|
119441
119465
|
try {
|
|
119442
|
-
stat2 =
|
|
119466
|
+
stat2 = fs34.statSync(resolved);
|
|
119443
119467
|
} catch {
|
|
119444
119468
|
}
|
|
119445
119469
|
if (stat2 && stat2.isFile()) {
|
|
@@ -119454,7 +119478,7 @@ ${marker}`,
|
|
|
119454
119478
|
const resolvedRaw = expandPath2(src.path, input, { skipWorkspaceRealpath: true });
|
|
119455
119479
|
if (resolvedRaw && resolvedRaw !== resolved) {
|
|
119456
119480
|
try {
|
|
119457
|
-
const rawStat =
|
|
119481
|
+
const rawStat = fs34.statSync(resolvedRaw);
|
|
119458
119482
|
if (rawStat.isFile()) sourcePath = resolvedRaw;
|
|
119459
119483
|
else if (rawStat.isDirectory()) {
|
|
119460
119484
|
sourcePath = pickExactSessionFile(resolvedRaw, filePat, requestedSessionId) || (requestedSessionId ? null : newestRecentFile(resolvedRaw, filePat, windowMs, sessionFloor));
|
|
@@ -119471,7 +119495,7 @@ ${marker}`,
|
|
|
119471
119495
|
}
|
|
119472
119496
|
function claimKeyForPath(p) {
|
|
119473
119497
|
try {
|
|
119474
|
-
return
|
|
119498
|
+
return fs34.realpathSync(p);
|
|
119475
119499
|
} catch {
|
|
119476
119500
|
return p;
|
|
119477
119501
|
}
|
|
@@ -119533,7 +119557,7 @@ ${marker}`,
|
|
|
119533
119557
|
function listSidecarWorkspaceCandidates(template, pattern, windowMs, sessionFloorMs, workspaceHint, sidecar) {
|
|
119534
119558
|
let wsResolved = workspaceHint;
|
|
119535
119559
|
try {
|
|
119536
|
-
wsResolved =
|
|
119560
|
+
wsResolved = fs34.realpathSync(workspaceHint);
|
|
119537
119561
|
} catch {
|
|
119538
119562
|
}
|
|
119539
119563
|
const dirs = expandDirGlob(template);
|
|
@@ -119547,7 +119571,7 @@ ${marker}`,
|
|
|
119547
119571
|
if (!ws) continue;
|
|
119548
119572
|
let wsReal = ws;
|
|
119549
119573
|
try {
|
|
119550
|
-
wsReal =
|
|
119574
|
+
wsReal = fs34.realpathSync(ws);
|
|
119551
119575
|
} catch {
|
|
119552
119576
|
}
|
|
119553
119577
|
if (ws !== workspaceHint && wsReal !== wsResolved) continue;
|
|
@@ -119568,7 +119592,7 @@ ${marker}`,
|
|
|
119568
119592
|
function readSidecarWorkspace(sourcePath, cfg) {
|
|
119569
119593
|
try {
|
|
119570
119594
|
const sidecar = path39.resolve(path39.dirname(sourcePath), cfg.rel_path);
|
|
119571
|
-
const parsed = JSON.parse(
|
|
119595
|
+
const parsed = JSON.parse(fs34.readFileSync(sidecar, "utf8"));
|
|
119572
119596
|
const v = jsonPathGet(parsed, cfg.workspace_path);
|
|
119573
119597
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
119574
119598
|
} catch {
|
|
@@ -119656,7 +119680,7 @@ ${marker}`,
|
|
|
119656
119680
|
if (!wsRaw) return void 0;
|
|
119657
119681
|
let wsReal = wsRaw;
|
|
119658
119682
|
try {
|
|
119659
|
-
wsReal =
|
|
119683
|
+
wsReal = fs34.realpathSync(wsRaw);
|
|
119660
119684
|
} catch {
|
|
119661
119685
|
}
|
|
119662
119686
|
const slugs = /* @__PURE__ */ new Set();
|
|
@@ -119686,7 +119710,7 @@ ${marker}`,
|
|
|
119686
119710
|
}
|
|
119687
119711
|
function executeSqlite(src, input) {
|
|
119688
119712
|
const resolved = expandPath2(src.path, input);
|
|
119689
|
-
if (!resolved || !
|
|
119713
|
+
if (!resolved || !fs34.existsSync(resolved)) return null;
|
|
119690
119714
|
let Database;
|
|
119691
119715
|
try {
|
|
119692
119716
|
Database = loadBetterSqlite3();
|
|
@@ -119825,7 +119849,7 @@ ${marker}`,
|
|
|
119825
119849
|
let workspaceResolved = workspaceRaw;
|
|
119826
119850
|
if (workspaceRaw && !opts?.skipWorkspaceRealpath) {
|
|
119827
119851
|
try {
|
|
119828
|
-
workspaceResolved =
|
|
119852
|
+
workspaceResolved = fs34.realpathSync(workspaceRaw);
|
|
119829
119853
|
} catch {
|
|
119830
119854
|
}
|
|
119831
119855
|
}
|
|
@@ -119867,7 +119891,7 @@ ${marker}`,
|
|
|
119867
119891
|
if (!base) return null;
|
|
119868
119892
|
let baseStat = null;
|
|
119869
119893
|
try {
|
|
119870
|
-
baseStat =
|
|
119894
|
+
baseStat = fs34.statSync(base);
|
|
119871
119895
|
} catch {
|
|
119872
119896
|
return null;
|
|
119873
119897
|
}
|
|
@@ -119875,7 +119899,7 @@ ${marker}`,
|
|
|
119875
119899
|
const needle = `${requestedSessionId.toLowerCase()}.jsonl`;
|
|
119876
119900
|
const dirsToScan = [base];
|
|
119877
119901
|
try {
|
|
119878
|
-
for (const entry of
|
|
119902
|
+
for (const entry of fs34.readdirSync(base, { withFileTypes: true })) {
|
|
119879
119903
|
if (entry.isDirectory()) dirsToScan.push(path39.join(base, entry.name));
|
|
119880
119904
|
}
|
|
119881
119905
|
} catch {
|
|
@@ -119883,7 +119907,7 @@ ${marker}`,
|
|
|
119883
119907
|
for (const dir of dirsToScan) {
|
|
119884
119908
|
let entries;
|
|
119885
119909
|
try {
|
|
119886
|
-
entries =
|
|
119910
|
+
entries = fs34.readdirSync(dir, { withFileTypes: true });
|
|
119887
119911
|
} catch {
|
|
119888
119912
|
continue;
|
|
119889
119913
|
}
|
|
@@ -119923,7 +119947,7 @@ ${marker}`,
|
|
|
119923
119947
|
for (const d of dirs) {
|
|
119924
119948
|
let entries;
|
|
119925
119949
|
try {
|
|
119926
|
-
entries =
|
|
119950
|
+
entries = fs34.readdirSync(d, { withFileTypes: true });
|
|
119927
119951
|
} catch {
|
|
119928
119952
|
continue;
|
|
119929
119953
|
}
|
|
@@ -119936,7 +119960,7 @@ ${marker}`,
|
|
|
119936
119960
|
const candidate = path39.join(d, seg);
|
|
119937
119961
|
let stat2 = null;
|
|
119938
119962
|
try {
|
|
119939
|
-
stat2 =
|
|
119963
|
+
stat2 = fs34.statSync(candidate);
|
|
119940
119964
|
} catch {
|
|
119941
119965
|
continue;
|
|
119942
119966
|
}
|
|
@@ -119980,7 +120004,7 @@ ${marker}`,
|
|
|
119980
120004
|
function walkAllDirs(root, out) {
|
|
119981
120005
|
let entries;
|
|
119982
120006
|
try {
|
|
119983
|
-
entries =
|
|
120007
|
+
entries = fs34.readdirSync(root, { withFileTypes: true });
|
|
119984
120008
|
} catch {
|
|
119985
120009
|
return;
|
|
119986
120010
|
}
|
|
@@ -119996,7 +120020,7 @@ ${marker}`,
|
|
|
119996
120020
|
for (const d of dirs) {
|
|
119997
120021
|
let entries;
|
|
119998
120022
|
try {
|
|
119999
|
-
entries =
|
|
120023
|
+
entries = fs34.readdirSync(d, { withFileTypes: true });
|
|
120000
120024
|
} catch {
|
|
120001
120025
|
continue;
|
|
120002
120026
|
}
|
|
@@ -120023,7 +120047,7 @@ ${marker}`,
|
|
|
120023
120047
|
if (!resolved) continue;
|
|
120024
120048
|
let entries;
|
|
120025
120049
|
try {
|
|
120026
|
-
entries =
|
|
120050
|
+
entries = fs34.readdirSync(resolved, { withFileTypes: true });
|
|
120027
120051
|
} catch {
|
|
120028
120052
|
continue;
|
|
120029
120053
|
}
|
|
@@ -120052,7 +120076,7 @@ ${marker}`,
|
|
|
120052
120076
|
let workspaceResolved = workspaceRaw;
|
|
120053
120077
|
if (workspaceRaw) {
|
|
120054
120078
|
try {
|
|
120055
|
-
workspaceResolved =
|
|
120079
|
+
workspaceResolved = fs34.realpathSync(workspaceRaw);
|
|
120056
120080
|
} catch {
|
|
120057
120081
|
}
|
|
120058
120082
|
}
|
|
@@ -120077,7 +120101,7 @@ ${marker}`,
|
|
|
120077
120101
|
function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
|
|
120078
120102
|
let entries;
|
|
120079
120103
|
try {
|
|
120080
|
-
entries =
|
|
120104
|
+
entries = fs34.readdirSync(dir, { withFileTypes: true });
|
|
120081
120105
|
} catch {
|
|
120082
120106
|
return null;
|
|
120083
120107
|
}
|
|
@@ -120094,14 +120118,14 @@ ${marker}`,
|
|
|
120094
120118
|
}
|
|
120095
120119
|
function safeMtimeMs(p) {
|
|
120096
120120
|
try {
|
|
120097
|
-
return Math.floor(
|
|
120121
|
+
return Math.floor(fs34.statSync(p).mtimeMs);
|
|
120098
120122
|
} catch {
|
|
120099
120123
|
return 0;
|
|
120100
120124
|
}
|
|
120101
120125
|
}
|
|
120102
120126
|
function safeBirthtimeMs(p) {
|
|
120103
120127
|
try {
|
|
120104
|
-
const st =
|
|
120128
|
+
const st = fs34.statSync(p);
|
|
120105
120129
|
const birth = Math.floor(st.birthtimeMs);
|
|
120106
120130
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
120107
120131
|
} catch {
|
|
@@ -120162,10 +120186,10 @@ ${marker}`,
|
|
|
120162
120186
|
}
|
|
120163
120187
|
function readCandidateSessionMeta(filePath) {
|
|
120164
120188
|
try {
|
|
120165
|
-
const fd =
|
|
120189
|
+
const fd = fs34.openSync(filePath, "r");
|
|
120166
120190
|
try {
|
|
120167
120191
|
const buf = Buffer.alloc(8192);
|
|
120168
|
-
const bytes =
|
|
120192
|
+
const bytes = fs34.readSync(fd, buf, 0, buf.length, 0);
|
|
120169
120193
|
if (bytes <= 0) return null;
|
|
120170
120194
|
const text = buf.subarray(0, bytes).toString("utf8");
|
|
120171
120195
|
const nl = text.indexOf("\n");
|
|
@@ -120183,7 +120207,7 @@ ${marker}`,
|
|
|
120183
120207
|
sessionTimestampMs: Number.isFinite(tsMs) ? tsMs : void 0
|
|
120184
120208
|
};
|
|
120185
120209
|
} finally {
|
|
120186
|
-
|
|
120210
|
+
fs34.closeSync(fd);
|
|
120187
120211
|
}
|
|
120188
120212
|
} catch {
|
|
120189
120213
|
return null;
|
|
@@ -120193,7 +120217,7 @@ ${marker}`,
|
|
|
120193
120217
|
if (!sessionFloorMs || !workspaceHint || candidatePaths.length === 0) return null;
|
|
120194
120218
|
let workspaceResolved = workspaceHint;
|
|
120195
120219
|
try {
|
|
120196
|
-
workspaceResolved =
|
|
120220
|
+
workspaceResolved = fs34.realpathSync(workspaceHint);
|
|
120197
120221
|
} catch {
|
|
120198
120222
|
}
|
|
120199
120223
|
let best = null;
|
|
@@ -120202,7 +120226,7 @@ ${marker}`,
|
|
|
120202
120226
|
if (!meta3 || !meta3.cwd || meta3.sessionTimestampMs == null) continue;
|
|
120203
120227
|
let candidateCwd = meta3.cwd;
|
|
120204
120228
|
try {
|
|
120205
|
-
candidateCwd =
|
|
120229
|
+
candidateCwd = fs34.realpathSync(meta3.cwd);
|
|
120206
120230
|
} catch {
|
|
120207
120231
|
}
|
|
120208
120232
|
if (candidateCwd !== workspaceResolved && meta3.cwd !== workspaceHint) continue;
|
|
@@ -120215,7 +120239,7 @@ ${marker}`,
|
|
|
120215
120239
|
function listMatchingFiles(dir, pattern) {
|
|
120216
120240
|
let entries;
|
|
120217
120241
|
try {
|
|
120218
|
-
entries =
|
|
120242
|
+
entries = fs34.readdirSync(dir, { withFileTypes: true });
|
|
120219
120243
|
} catch {
|
|
120220
120244
|
return [];
|
|
120221
120245
|
}
|
|
@@ -120507,12 +120531,12 @@ ${marker}`,
|
|
|
120507
120531
|
}
|
|
120508
120532
|
return t.negate ? !result : result;
|
|
120509
120533
|
}
|
|
120510
|
-
var
|
|
120534
|
+
var fs41 = __toESM2(require("fs"));
|
|
120511
120535
|
init_logger();
|
|
120512
|
-
var
|
|
120536
|
+
var fs40 = __toESM2(require("fs"));
|
|
120513
120537
|
var os28 = __toESM2(require("os"));
|
|
120514
120538
|
var path45 = __toESM2(require("path"));
|
|
120515
|
-
var
|
|
120539
|
+
var fs35 = __toESM2(require("fs"));
|
|
120516
120540
|
var path40 = __toESM2(require("path"));
|
|
120517
120541
|
function extractTimestampValue(value) {
|
|
120518
120542
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
@@ -120526,7 +120550,7 @@ ${marker}`,
|
|
|
120526
120550
|
}
|
|
120527
120551
|
function statMtimeMs(filePath) {
|
|
120528
120552
|
try {
|
|
120529
|
-
return
|
|
120553
|
+
return fs35.statSync(filePath).mtimeMs;
|
|
120530
120554
|
} catch {
|
|
120531
120555
|
return 0;
|
|
120532
120556
|
}
|
|
@@ -120609,7 +120633,7 @@ ${marker}`,
|
|
|
120609
120633
|
function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
|
|
120610
120634
|
let raw;
|
|
120611
120635
|
try {
|
|
120612
|
-
raw =
|
|
120636
|
+
raw = fs35.readFileSync(filePath, "utf-8");
|
|
120613
120637
|
} catch {
|
|
120614
120638
|
return { messages: [], usageRecords: [] };
|
|
120615
120639
|
}
|
|
@@ -120695,7 +120719,7 @@ ${marker}`,
|
|
|
120695
120719
|
if (!sessionPath || !path40.isAbsolute(sessionPath)) return null;
|
|
120696
120720
|
const basename22 = path40.basename(sessionPath, ".jsonl");
|
|
120697
120721
|
if (!isSafeSessionId(basename22)) return null;
|
|
120698
|
-
if (!
|
|
120722
|
+
if (!fs35.existsSync(sessionPath)) return null;
|
|
120699
120723
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
120700
120724
|
const { messages, usageRecords } = parseTranscriptFile(sessionPath, basename22);
|
|
120701
120725
|
if (messages.length === 0) return null;
|
|
@@ -120718,7 +120742,7 @@ ${marker}`,
|
|
|
120718
120742
|
}
|
|
120719
120743
|
return session;
|
|
120720
120744
|
}
|
|
120721
|
-
var
|
|
120745
|
+
var fs36 = __toESM2(require("fs"));
|
|
120722
120746
|
var path41 = __toESM2(require("path"));
|
|
120723
120747
|
init_native_turn_signal();
|
|
120724
120748
|
var CODEX_DEFAULT_COMPLETION_SIGNAL = {
|
|
@@ -120739,7 +120763,7 @@ ${marker}`,
|
|
|
120739
120763
|
}
|
|
120740
120764
|
function statMtimeMs2(filePath) {
|
|
120741
120765
|
try {
|
|
120742
|
-
return
|
|
120766
|
+
return fs36.statSync(filePath).mtimeMs;
|
|
120743
120767
|
} catch {
|
|
120744
120768
|
return 0;
|
|
120745
120769
|
}
|
|
@@ -120855,7 +120879,7 @@ ${marker}`,
|
|
|
120855
120879
|
}
|
|
120856
120880
|
function readSessionMeta(filePath) {
|
|
120857
120881
|
try {
|
|
120858
|
-
const firstLine =
|
|
120882
|
+
const firstLine = fs36.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
|
|
120859
120883
|
if (!firstLine) return null;
|
|
120860
120884
|
const parsed = JSON.parse(firstLine);
|
|
120861
120885
|
if (String(parsed.type ?? "") !== "session_meta") return null;
|
|
@@ -120867,7 +120891,7 @@ ${marker}`,
|
|
|
120867
120891
|
function parseSessionFile(filePath, sessionId, workspaceFallback, completionSignal = CODEX_DEFAULT_COMPLETION_SIGNAL) {
|
|
120868
120892
|
let raw;
|
|
120869
120893
|
try {
|
|
120870
|
-
raw =
|
|
120894
|
+
raw = fs36.readFileSync(filePath, "utf-8");
|
|
120871
120895
|
} catch {
|
|
120872
120896
|
return { messages: [], usageRecords: [], turnTerminalMarkers: [] };
|
|
120873
120897
|
}
|
|
@@ -121003,7 +121027,7 @@ ${marker}`,
|
|
|
121003
121027
|
}
|
|
121004
121028
|
function readSession2(sessionPath, nativeHistory) {
|
|
121005
121029
|
if (!sessionPath || !path41.isAbsolute(sessionPath)) return null;
|
|
121006
|
-
if (!
|
|
121030
|
+
if (!fs36.existsSync(sessionPath)) return null;
|
|
121007
121031
|
const meta3 = readSessionMeta(sessionPath);
|
|
121008
121032
|
const metaId = String(meta3?.id ?? "").trim();
|
|
121009
121033
|
const basename22 = path41.basename(sessionPath, ".jsonl");
|
|
@@ -121042,7 +121066,7 @@ ${marker}`,
|
|
|
121042
121066
|
if (turnTerminalMarkers.length > 0) session.turnTerminalMarkers = turnTerminalMarkers;
|
|
121043
121067
|
return session;
|
|
121044
121068
|
}
|
|
121045
|
-
var
|
|
121069
|
+
var fs37 = __toESM2(require("fs"));
|
|
121046
121070
|
var path422 = __toESM2(require("path"));
|
|
121047
121071
|
var os25 = __toESM2(require("os"));
|
|
121048
121072
|
init_load_better_sqlite3();
|
|
@@ -121059,7 +121083,7 @@ ${marker}`,
|
|
|
121059
121083
|
}
|
|
121060
121084
|
function statMtimeMs3(filePath) {
|
|
121061
121085
|
try {
|
|
121062
|
-
return
|
|
121086
|
+
return fs37.statSync(filePath).mtimeMs;
|
|
121063
121087
|
} catch {
|
|
121064
121088
|
return 0;
|
|
121065
121089
|
}
|
|
@@ -121088,12 +121112,12 @@ ${marker}`,
|
|
|
121088
121112
|
function findBrainTranscriptPath(sessionId) {
|
|
121089
121113
|
if (!isUuidLike(sessionId)) return null;
|
|
121090
121114
|
const logsRoot = resolvePathInside(brainRoot(), sessionId, ".system_generated", "logs");
|
|
121091
|
-
if (!logsRoot || !
|
|
121092
|
-
const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null &&
|
|
121115
|
+
if (!logsRoot || !fs37.existsSync(logsRoot)) return null;
|
|
121116
|
+
const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null && fs37.existsSync(p));
|
|
121093
121117
|
if (candidates.length === 0) {
|
|
121094
121118
|
let entries = [];
|
|
121095
121119
|
try {
|
|
121096
|
-
entries =
|
|
121120
|
+
entries = fs37.readdirSync(logsRoot, { withFileTypes: true });
|
|
121097
121121
|
} catch {
|
|
121098
121122
|
return null;
|
|
121099
121123
|
}
|
|
@@ -121119,7 +121143,7 @@ ${marker}`,
|
|
|
121119
121143
|
function parseBrainTranscript(filePath, sessionId, workspace) {
|
|
121120
121144
|
let raw;
|
|
121121
121145
|
try {
|
|
121122
|
-
raw =
|
|
121146
|
+
raw = fs37.readFileSync(filePath, "utf-8");
|
|
121123
121147
|
} catch {
|
|
121124
121148
|
return null;
|
|
121125
121149
|
}
|
|
@@ -121179,7 +121203,7 @@ ${marker}`,
|
|
|
121179
121203
|
const sourcePath = historyJsonlPath();
|
|
121180
121204
|
let lines = [];
|
|
121181
121205
|
try {
|
|
121182
|
-
lines =
|
|
121206
|
+
lines = fs37.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
121183
121207
|
} catch {
|
|
121184
121208
|
return [];
|
|
121185
121209
|
}
|
|
@@ -121227,7 +121251,7 @@ ${marker}`,
|
|
|
121227
121251
|
function parsePbFile(filePath, sessionId) {
|
|
121228
121252
|
let buf;
|
|
121229
121253
|
try {
|
|
121230
|
-
buf =
|
|
121254
|
+
buf = fs37.readFileSync(filePath);
|
|
121231
121255
|
} catch {
|
|
121232
121256
|
return null;
|
|
121233
121257
|
}
|
|
@@ -121692,7 +121716,7 @@ ${marker}`,
|
|
|
121692
121716
|
}
|
|
121693
121717
|
}
|
|
121694
121718
|
const pbPath = resolvePathInside(conversationsRoot(), `${sessionId}.pb`);
|
|
121695
|
-
if (pbPath &&
|
|
121719
|
+
if (pbPath && fs37.existsSync(pbPath)) {
|
|
121696
121720
|
const pbMessages = parsePbFile(pbPath, sessionId);
|
|
121697
121721
|
if (pbMessages && pbMessages.length > 0) {
|
|
121698
121722
|
return {
|
|
@@ -121711,7 +121735,7 @@ ${marker}`,
|
|
|
121711
121735
|
}
|
|
121712
121736
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
121713
121737
|
if (!sessionPath || !path422.isAbsolute(sessionPath)) return null;
|
|
121714
|
-
if (!
|
|
121738
|
+
if (!fs37.existsSync(sessionPath)) return null;
|
|
121715
121739
|
const sourceMtimeMs = statMtimeMs3(sessionPath);
|
|
121716
121740
|
const brainRootPath = brainRoot();
|
|
121717
121741
|
if (sessionPath.startsWith(brainRootPath + path422.sep) && sessionPath.endsWith(".jsonl")) {
|
|
@@ -121770,7 +121794,7 @@ ${marker}`,
|
|
|
121770
121794
|
}
|
|
121771
121795
|
return null;
|
|
121772
121796
|
}
|
|
121773
|
-
var
|
|
121797
|
+
var fs38 = __toESM2(require("fs"));
|
|
121774
121798
|
var path43 = __toESM2(require("path"));
|
|
121775
121799
|
var os26 = __toESM2(require("os"));
|
|
121776
121800
|
init_load_better_sqlite3();
|
|
@@ -121778,13 +121802,13 @@ ${marker}`,
|
|
|
121778
121802
|
var HERMES_LEGACY_SESSIONS_DIR = path43.join(os26.homedir(), ".hermes", "sessions");
|
|
121779
121803
|
function statMtimeMs4(p) {
|
|
121780
121804
|
try {
|
|
121781
|
-
return Math.floor(
|
|
121805
|
+
return Math.floor(fs38.statSync(p).mtimeMs);
|
|
121782
121806
|
} catch {
|
|
121783
121807
|
return 0;
|
|
121784
121808
|
}
|
|
121785
121809
|
}
|
|
121786
121810
|
function openDb() {
|
|
121787
|
-
if (!
|
|
121811
|
+
if (!fs38.existsSync(HERMES_STATE_DB)) return null;
|
|
121788
121812
|
try {
|
|
121789
121813
|
const Database = loadBetterSqlite3();
|
|
121790
121814
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
@@ -121952,10 +121976,10 @@ ${marker}`,
|
|
|
121952
121976
|
}
|
|
121953
121977
|
}
|
|
121954
121978
|
}
|
|
121955
|
-
if (!path43.isAbsolute(sessionPath) || !
|
|
121979
|
+
if (!path43.isAbsolute(sessionPath) || !fs38.existsSync(sessionPath)) return null;
|
|
121956
121980
|
let raw;
|
|
121957
121981
|
try {
|
|
121958
|
-
raw = JSON.parse(
|
|
121982
|
+
raw = JSON.parse(fs38.readFileSync(sessionPath, "utf8"));
|
|
121959
121983
|
} catch {
|
|
121960
121984
|
return null;
|
|
121961
121985
|
}
|
|
@@ -121995,7 +122019,7 @@ ${marker}`,
|
|
|
121995
122019
|
if (s2 === "tool" || s2 === "tool_result" || s2 === "function") return "assistant";
|
|
121996
122020
|
return "system";
|
|
121997
122021
|
}
|
|
121998
|
-
var
|
|
122022
|
+
var fs39 = __toESM2(require("fs"));
|
|
121999
122023
|
var path44 = __toESM2(require("path"));
|
|
122000
122024
|
var os27 = __toESM2(require("os"));
|
|
122001
122025
|
function grokSessionsRoot() {
|
|
@@ -122007,7 +122031,7 @@ ${marker}`,
|
|
|
122007
122031
|
}
|
|
122008
122032
|
function statMtimeMs5(filePath) {
|
|
122009
122033
|
try {
|
|
122010
|
-
return
|
|
122034
|
+
return fs39.statSync(filePath).mtimeMs;
|
|
122011
122035
|
} catch {
|
|
122012
122036
|
return 0;
|
|
122013
122037
|
}
|
|
@@ -122018,7 +122042,7 @@ ${marker}`,
|
|
|
122018
122042
|
function workspaceCandidates(workspace) {
|
|
122019
122043
|
const out = [workspace];
|
|
122020
122044
|
try {
|
|
122021
|
-
const real =
|
|
122045
|
+
const real = fs39.realpathSync(workspace);
|
|
122022
122046
|
if (real && real !== workspace) out.push(real);
|
|
122023
122047
|
} catch {
|
|
122024
122048
|
}
|
|
@@ -122027,22 +122051,22 @@ ${marker}`,
|
|
|
122027
122051
|
function resolveGrokPath(workspace, sessionId) {
|
|
122028
122052
|
if (!sessionId || !isUuidLike2(sessionId)) return null;
|
|
122029
122053
|
const root = grokSessionsRoot();
|
|
122030
|
-
if (!
|
|
122054
|
+
if (!fs39.existsSync(root)) return null;
|
|
122031
122055
|
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
122032
122056
|
if (!candidate) continue;
|
|
122033
122057
|
const file2 = path44.join(root, encodeWorkspaceDir(candidate), sessionId, "chat_history.jsonl");
|
|
122034
|
-
if (
|
|
122058
|
+
if (fs39.existsSync(file2)) return file2;
|
|
122035
122059
|
}
|
|
122036
122060
|
let entries = [];
|
|
122037
122061
|
try {
|
|
122038
|
-
entries =
|
|
122062
|
+
entries = fs39.readdirSync(root, { withFileTypes: true });
|
|
122039
122063
|
} catch {
|
|
122040
122064
|
return null;
|
|
122041
122065
|
}
|
|
122042
122066
|
for (const entry of entries) {
|
|
122043
122067
|
if (!entry.isDirectory()) continue;
|
|
122044
122068
|
const file2 = path44.join(root, entry.name, sessionId, "chat_history.jsonl");
|
|
122045
|
-
if (
|
|
122069
|
+
if (fs39.existsSync(file2)) return file2;
|
|
122046
122070
|
}
|
|
122047
122071
|
return null;
|
|
122048
122072
|
}
|
|
@@ -122096,7 +122120,7 @@ ${marker}`,
|
|
|
122096
122120
|
}
|
|
122097
122121
|
function readSessionCreatedAtMs(sessionDir) {
|
|
122098
122122
|
try {
|
|
122099
|
-
const summary = JSON.parse(
|
|
122123
|
+
const summary = JSON.parse(fs39.readFileSync(path44.join(sessionDir, "summary.json"), "utf8"));
|
|
122100
122124
|
const created = summary?.created_at;
|
|
122101
122125
|
if (typeof created === "string") {
|
|
122102
122126
|
const parsed = Date.parse(created);
|
|
@@ -122109,7 +122133,7 @@ ${marker}`,
|
|
|
122109
122133
|
function readSession5(sourcePath, sessionId, workspace) {
|
|
122110
122134
|
let text;
|
|
122111
122135
|
try {
|
|
122112
|
-
text =
|
|
122136
|
+
text = fs39.readFileSync(sourcePath, "utf8");
|
|
122113
122137
|
} catch {
|
|
122114
122138
|
return null;
|
|
122115
122139
|
}
|
|
@@ -122159,26 +122183,26 @@ ${marker}`,
|
|
|
122159
122183
|
}
|
|
122160
122184
|
function listSessions(workspace, limit = 50) {
|
|
122161
122185
|
const root = grokSessionsRoot();
|
|
122162
|
-
if (!
|
|
122186
|
+
if (!fs39.existsSync(root)) return [];
|
|
122163
122187
|
const dirs = [];
|
|
122164
122188
|
for (const candidate of workspaceCandidates(workspace || "")) {
|
|
122165
122189
|
if (!candidate) continue;
|
|
122166
122190
|
const dir = path44.join(root, encodeWorkspaceDir(candidate));
|
|
122167
|
-
if (
|
|
122191
|
+
if (fs39.existsSync(dir)) dirs.push(dir);
|
|
122168
122192
|
}
|
|
122169
122193
|
if (dirs.length === 0) return [];
|
|
122170
122194
|
const out = [];
|
|
122171
122195
|
for (const dir of dirs) {
|
|
122172
122196
|
let entries = [];
|
|
122173
122197
|
try {
|
|
122174
|
-
entries =
|
|
122198
|
+
entries = fs39.readdirSync(dir, { withFileTypes: true });
|
|
122175
122199
|
} catch {
|
|
122176
122200
|
continue;
|
|
122177
122201
|
}
|
|
122178
122202
|
for (const entry of entries) {
|
|
122179
122203
|
if (!entry.isDirectory() || !isUuidLike2(entry.name)) continue;
|
|
122180
122204
|
const sourcePath = path44.join(dir, entry.name, "chat_history.jsonl");
|
|
122181
|
-
if (!
|
|
122205
|
+
if (!fs39.existsSync(sourcePath)) continue;
|
|
122182
122206
|
const session = readSession5(sourcePath, entry.name, workspace);
|
|
122183
122207
|
if (!session || session.messages.length === 0) continue;
|
|
122184
122208
|
const first = session.messages[0];
|
|
@@ -122208,10 +122232,10 @@ ${marker}`,
|
|
|
122208
122232
|
}
|
|
122209
122233
|
function listSessionsAllWorkspaces(limit = 50) {
|
|
122210
122234
|
const root = grokSessionsRoot();
|
|
122211
|
-
if (!
|
|
122235
|
+
if (!fs39.existsSync(root)) return [];
|
|
122212
122236
|
let dirs = [];
|
|
122213
122237
|
try {
|
|
122214
|
-
dirs =
|
|
122238
|
+
dirs = fs39.readdirSync(root, { withFileTypes: true });
|
|
122215
122239
|
} catch {
|
|
122216
122240
|
return [];
|
|
122217
122241
|
}
|
|
@@ -122259,7 +122283,7 @@ ${marker}`,
|
|
|
122259
122283
|
const ownerConfirmed = reader === "antigravity-cli" ? resolved?.ownerConfirmed === true : void 0;
|
|
122260
122284
|
if (input.forceRefresh === true || input.args?.forceRefresh === true) {
|
|
122261
122285
|
try {
|
|
122262
|
-
|
|
122286
|
+
fs40.statSync(sourcePath);
|
|
122263
122287
|
} catch {
|
|
122264
122288
|
}
|
|
122265
122289
|
}
|
|
@@ -122324,10 +122348,10 @@ ${marker}`,
|
|
|
122324
122348
|
}
|
|
122325
122349
|
function resolveClaudePath(workspace, sessionId) {
|
|
122326
122350
|
const dir = path45.join(os28.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
122327
|
-
if (!
|
|
122351
|
+
if (!fs40.existsSync(dir)) return null;
|
|
122328
122352
|
if (sessionId) {
|
|
122329
122353
|
const candidate = path45.join(dir, `${sessionId}.jsonl`);
|
|
122330
|
-
if (
|
|
122354
|
+
if (fs40.existsSync(candidate)) return candidate;
|
|
122331
122355
|
}
|
|
122332
122356
|
return null;
|
|
122333
122357
|
}
|
|
@@ -122345,7 +122369,7 @@ ${marker}`,
|
|
|
122345
122369
|
if (key2) {
|
|
122346
122370
|
const pinned = codexRuntimeBindings.get(key2);
|
|
122347
122371
|
if (pinned) {
|
|
122348
|
-
if (
|
|
122372
|
+
if (fs40.existsSync(pinned)) return pinned;
|
|
122349
122373
|
codexRuntimeBindings.delete(key2);
|
|
122350
122374
|
}
|
|
122351
122375
|
}
|
|
@@ -122354,7 +122378,7 @@ ${marker}`,
|
|
|
122354
122378
|
return resolved;
|
|
122355
122379
|
}
|
|
122356
122380
|
function findCodexPathBySessionId(root, sessionId) {
|
|
122357
|
-
if (!
|
|
122381
|
+
if (!fs40.existsSync(root)) return null;
|
|
122358
122382
|
const needle = sessionId.toLowerCase();
|
|
122359
122383
|
const matches = [];
|
|
122360
122384
|
const stack = [root];
|
|
@@ -122362,7 +122386,7 @@ ${marker}`,
|
|
|
122362
122386
|
const current = stack.pop();
|
|
122363
122387
|
let entries = [];
|
|
122364
122388
|
try {
|
|
122365
|
-
entries =
|
|
122389
|
+
entries = fs40.readdirSync(current, { withFileTypes: true });
|
|
122366
122390
|
} catch {
|
|
122367
122391
|
continue;
|
|
122368
122392
|
}
|
|
@@ -122382,7 +122406,7 @@ ${marker}`,
|
|
|
122382
122406
|
return matches[0]?.p ?? null;
|
|
122383
122407
|
}
|
|
122384
122408
|
function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
|
|
122385
|
-
if (!
|
|
122409
|
+
if (!fs40.existsSync(root) || !workspace) return null;
|
|
122386
122410
|
const workspaceResolved = resolveRealPath(workspace);
|
|
122387
122411
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
122388
122412
|
const matches = [];
|
|
@@ -122391,7 +122415,7 @@ ${marker}`,
|
|
|
122391
122415
|
const current = stack.pop();
|
|
122392
122416
|
let entries = [];
|
|
122393
122417
|
try {
|
|
122394
|
-
entries =
|
|
122418
|
+
entries = fs40.readdirSync(current, { withFileTypes: true });
|
|
122395
122419
|
} catch {
|
|
122396
122420
|
continue;
|
|
122397
122421
|
}
|
|
@@ -122416,10 +122440,10 @@ ${marker}`,
|
|
|
122416
122440
|
}
|
|
122417
122441
|
function readCodexSessionMeta(filePath) {
|
|
122418
122442
|
try {
|
|
122419
|
-
const fd =
|
|
122443
|
+
const fd = fs40.openSync(filePath, "r");
|
|
122420
122444
|
try {
|
|
122421
122445
|
const buffer = Buffer.alloc(8192);
|
|
122422
|
-
const bytes =
|
|
122446
|
+
const bytes = fs40.readSync(fd, buffer, 0, buffer.length, 0);
|
|
122423
122447
|
if (bytes <= 0) return null;
|
|
122424
122448
|
const text = buffer.subarray(0, bytes).toString("utf8");
|
|
122425
122449
|
const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
|
|
@@ -122434,7 +122458,7 @@ ${marker}`,
|
|
|
122434
122458
|
timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
|
|
122435
122459
|
};
|
|
122436
122460
|
} finally {
|
|
122437
|
-
|
|
122461
|
+
fs40.closeSync(fd);
|
|
122438
122462
|
}
|
|
122439
122463
|
} catch {
|
|
122440
122464
|
return null;
|
|
@@ -122442,7 +122466,7 @@ ${marker}`,
|
|
|
122442
122466
|
}
|
|
122443
122467
|
function resolveRealPath(value) {
|
|
122444
122468
|
try {
|
|
122445
|
-
return
|
|
122469
|
+
return fs40.realpathSync(value);
|
|
122446
122470
|
} catch {
|
|
122447
122471
|
return value;
|
|
122448
122472
|
}
|
|
@@ -122464,19 +122488,19 @@ ${marker}`,
|
|
|
122464
122488
|
const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
|
|
122465
122489
|
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
122466
122490
|
const dbPath = path45.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
122467
|
-
if (
|
|
122491
|
+
if (fs40.existsSync(dbPath)) {
|
|
122468
122492
|
if (owner) claimAntigravityConversation(sessionId, owner);
|
|
122469
122493
|
return { path: dbPath, ownerConfirmed: true };
|
|
122470
122494
|
}
|
|
122471
122495
|
}
|
|
122472
122496
|
const brainRoot2 = path45.join(agyRoot, "brain");
|
|
122473
|
-
if (
|
|
122497
|
+
if (fs40.existsSync(brainRoot2)) {
|
|
122474
122498
|
const cutoff = spawnAwareCutoff(sessionStartedAtMs);
|
|
122475
122499
|
const nonEmptyBrain = (uuid3, p) => {
|
|
122476
122500
|
const t = path45.join(p, ".system_generated", "logs", "transcript.jsonl");
|
|
122477
|
-
return
|
|
122501
|
+
return fs40.existsSync(t) && safeSize(t) > 0 ? t : null;
|
|
122478
122502
|
};
|
|
122479
|
-
const all =
|
|
122503
|
+
const all = fs40.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
|
|
122480
122504
|
const p = path45.join(brainRoot2, e.name);
|
|
122481
122505
|
return { uuid: e.name, p, mtime: safeMtime(p), birth: safeBirthtime(p) };
|
|
122482
122506
|
}).filter((e) => e.mtime >= cutoff);
|
|
@@ -122507,7 +122531,7 @@ ${marker}`,
|
|
|
122507
122531
|
function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
|
|
122508
122532
|
let entries = [];
|
|
122509
122533
|
try {
|
|
122510
|
-
entries =
|
|
122534
|
+
entries = fs40.readdirSync(convRoot, { withFileTypes: true });
|
|
122511
122535
|
} catch {
|
|
122512
122536
|
return null;
|
|
122513
122537
|
}
|
|
@@ -122545,9 +122569,9 @@ ${marker}`,
|
|
|
122545
122569
|
void workspace;
|
|
122546
122570
|
void sessionId;
|
|
122547
122571
|
const dbPath = path45.join(os28.homedir(), ".hermes", "state.db");
|
|
122548
|
-
if (
|
|
122572
|
+
if (fs40.existsSync(dbPath)) return dbPath;
|
|
122549
122573
|
const dir = path45.join(os28.homedir(), ".hermes", "sessions");
|
|
122550
|
-
if (!
|
|
122574
|
+
if (!fs40.existsSync(dir)) return null;
|
|
122551
122575
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
122552
122576
|
}
|
|
122553
122577
|
function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
|
|
@@ -122586,7 +122610,7 @@ ${marker}`,
|
|
|
122586
122610
|
function newestRecentFile2(dir, pattern) {
|
|
122587
122611
|
try {
|
|
122588
122612
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
122589
|
-
const entries =
|
|
122613
|
+
const entries = fs40.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);
|
|
122590
122614
|
return entries[0]?.p ?? null;
|
|
122591
122615
|
} catch {
|
|
122592
122616
|
return null;
|
|
@@ -122594,14 +122618,14 @@ ${marker}`,
|
|
|
122594
122618
|
}
|
|
122595
122619
|
function safeMtime(p) {
|
|
122596
122620
|
try {
|
|
122597
|
-
return Math.floor(
|
|
122621
|
+
return Math.floor(fs40.statSync(p).mtimeMs);
|
|
122598
122622
|
} catch {
|
|
122599
122623
|
return 0;
|
|
122600
122624
|
}
|
|
122601
122625
|
}
|
|
122602
122626
|
function safeBirthtime(p) {
|
|
122603
122627
|
try {
|
|
122604
|
-
const st =
|
|
122628
|
+
const st = fs40.statSync(p);
|
|
122605
122629
|
const birth = Math.floor(st.birthtimeMs);
|
|
122606
122630
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
122607
122631
|
} catch {
|
|
@@ -122610,7 +122634,7 @@ ${marker}`,
|
|
|
122610
122634
|
}
|
|
122611
122635
|
function safeSize(p) {
|
|
122612
122636
|
try {
|
|
122613
|
-
return
|
|
122637
|
+
return fs40.statSync(p).size;
|
|
122614
122638
|
} catch {
|
|
122615
122639
|
return 0;
|
|
122616
122640
|
}
|
|
@@ -122906,19 +122930,19 @@ ${marker}`,
|
|
|
122906
122930
|
return attrs;
|
|
122907
122931
|
}
|
|
122908
122932
|
function readTailJsonlLines(filePath, maxBytes) {
|
|
122909
|
-
const stat2 =
|
|
122933
|
+
const stat2 = fs41.statSync(filePath);
|
|
122910
122934
|
const size = stat2.size;
|
|
122911
122935
|
const start = size > maxBytes ? size - maxBytes : 0;
|
|
122912
122936
|
const length = size - start;
|
|
122913
122937
|
if (length <= 0) return [];
|
|
122914
|
-
const fd =
|
|
122938
|
+
const fd = fs41.openSync(filePath, "r");
|
|
122915
122939
|
let text;
|
|
122916
122940
|
try {
|
|
122917
122941
|
const buf = Buffer.alloc(length);
|
|
122918
|
-
const bytes =
|
|
122942
|
+
const bytes = fs41.readSync(fd, buf, 0, length, start);
|
|
122919
122943
|
text = buf.subarray(0, bytes).toString("utf8");
|
|
122920
122944
|
} finally {
|
|
122921
|
-
|
|
122945
|
+
fs41.closeSync(fd);
|
|
122922
122946
|
}
|
|
122923
122947
|
const rawLines = text.split("\n");
|
|
122924
122948
|
if (start > 0 && rawLines.length > 0) rawLines.shift();
|
|
@@ -123027,7 +123051,7 @@ ${text}` : text;
|
|
|
123027
123051
|
}
|
|
123028
123052
|
return messages.filter((m) => typeof m.content === "string" && m.content.trim().length > 0);
|
|
123029
123053
|
}
|
|
123030
|
-
var
|
|
123054
|
+
var fs422 = __toESM2(require("fs"));
|
|
123031
123055
|
var import_node_crypto6 = require("crypto");
|
|
123032
123056
|
init_provider_cli_shared();
|
|
123033
123057
|
init_logger();
|
|
@@ -123385,7 +123409,7 @@ ${text}` : text;
|
|
|
123385
123409
|
* (claude-cli specs/4.0.json), which previously stubbed the method to false. */
|
|
123386
123410
|
lastApprovalResolvedAt = 0;
|
|
123387
123411
|
constructor(specPath, workingDir, cliArgs, extraEnv, transportFactory, sessionId, manifestTuning) {
|
|
123388
|
-
const raw = JSON.parse(
|
|
123412
|
+
const raw = JSON.parse(fs422.readFileSync(specPath, "utf8"));
|
|
123389
123413
|
this.spec = {
|
|
123390
123414
|
id: raw.id,
|
|
123391
123415
|
name: raw.name,
|
|
@@ -124750,10 +124774,10 @@ ${text}` : text;
|
|
|
124750
124774
|
function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory, sessionId, removeArgs) {
|
|
124751
124775
|
const resolvedSpecPath = provider._resolvedSpecPath;
|
|
124752
124776
|
const dir = provider._resolvedProviderDir;
|
|
124753
|
-
let specPath = resolvedSpecPath &&
|
|
124777
|
+
let specPath = resolvedSpecPath && fs43.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
|
|
124754
124778
|
if (!specPath && dir) {
|
|
124755
124779
|
const legacy = path46.join(dir, "spec.json");
|
|
124756
|
-
if (
|
|
124780
|
+
if (fs43.existsSync(legacy)) specPath = legacy;
|
|
124757
124781
|
}
|
|
124758
124782
|
if (!specPath) {
|
|
124759
124783
|
throw new Error(formatNoResolvableSpecError(provider.type, dir));
|
|
@@ -124855,7 +124879,7 @@ ${text}` : text;
|
|
|
124855
124879
|
init_summary_metadata();
|
|
124856
124880
|
var os30 = __toESM2(require("os"));
|
|
124857
124881
|
var crypto6 = __toESM2(require("crypto"));
|
|
124858
|
-
var
|
|
124882
|
+
var fs47 = __toESM2(require("fs"));
|
|
124859
124883
|
function shouldUseBracketedPasteForEnvelope(input) {
|
|
124860
124884
|
return input.parts.some((part) => part.type === "image");
|
|
124861
124885
|
}
|
|
@@ -125110,7 +125134,7 @@ ${text}` : text;
|
|
|
125110
125134
|
var os29 = __toESM2(require("os"));
|
|
125111
125135
|
var path47 = __toESM2(require("path"));
|
|
125112
125136
|
var crypto5 = __toESM2(require("crypto"));
|
|
125113
|
-
var
|
|
125137
|
+
var fs44 = __toESM2(require("fs"));
|
|
125114
125138
|
var IMAGE_MIME_EXTENSIONS = {
|
|
125115
125139
|
"image/png": ".png",
|
|
125116
125140
|
"image/jpeg": ".jpg",
|
|
@@ -125145,9 +125169,9 @@ ${text}` : text;
|
|
|
125145
125169
|
if (!part.data) return null;
|
|
125146
125170
|
const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
|
|
125147
125171
|
if (!rawData) return null;
|
|
125148
|
-
|
|
125172
|
+
fs44.mkdirSync(dir, { recursive: true });
|
|
125149
125173
|
const filePath = path47.join(dir, safeInputImageBasename(index, part.mimeType));
|
|
125150
|
-
|
|
125174
|
+
fs44.writeFileSync(filePath, Buffer.from(rawData, "base64"));
|
|
125151
125175
|
cleanupStaleMaterializedImages(dir);
|
|
125152
125176
|
return filePath;
|
|
125153
125177
|
}
|
|
@@ -125159,14 +125183,14 @@ ${text}` : text;
|
|
|
125159
125183
|
if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
|
|
125160
125184
|
lastMaterializedImageCleanupAt = now;
|
|
125161
125185
|
try {
|
|
125162
|
-
const entries =
|
|
125186
|
+
const entries = fs44.readdirSync(dir);
|
|
125163
125187
|
for (const entry of entries) {
|
|
125164
125188
|
if (!entry.startsWith("adhdev-input-image-")) continue;
|
|
125165
125189
|
const fullPath = path47.join(dir, entry);
|
|
125166
125190
|
try {
|
|
125167
|
-
const stat2 =
|
|
125191
|
+
const stat2 = fs44.statSync(fullPath);
|
|
125168
125192
|
if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
|
|
125169
|
-
|
|
125193
|
+
fs44.unlinkSync(fullPath);
|
|
125170
125194
|
}
|
|
125171
125195
|
} catch {
|
|
125172
125196
|
}
|
|
@@ -125622,7 +125646,7 @@ ${text}` : text;
|
|
|
125622
125646
|
if (missingEvidence) return { action: "suppress", missingEvidence };
|
|
125623
125647
|
return { action: "inline_fire", missingEvidence: false };
|
|
125624
125648
|
}
|
|
125625
|
-
var
|
|
125649
|
+
var fs45 = __toESM2(require("fs"));
|
|
125626
125650
|
function createSqliteProbeCache() {
|
|
125627
125651
|
return { db: null, dbPath: null, missingUntil: 0 };
|
|
125628
125652
|
}
|
|
@@ -125642,7 +125666,7 @@ ${text}` : text;
|
|
|
125642
125666
|
};
|
|
125643
125667
|
addDir(workingDir);
|
|
125644
125668
|
try {
|
|
125645
|
-
addDir(
|
|
125669
|
+
addDir(fs45.realpathSync.native(workingDir));
|
|
125646
125670
|
} catch {
|
|
125647
125671
|
}
|
|
125648
125672
|
return Array.from(dirs);
|
|
@@ -126056,7 +126080,7 @@ ${buttons.join("\n")}`;
|
|
|
126056
126080
|
}
|
|
126057
126081
|
return adapterStatus;
|
|
126058
126082
|
}
|
|
126059
|
-
var
|
|
126083
|
+
var fs46 = __toESM2(require("fs"));
|
|
126060
126084
|
init_contracts2();
|
|
126061
126085
|
init_chat_message_normalization();
|
|
126062
126086
|
init_chat_history();
|
|
@@ -126260,7 +126284,7 @@ ${buttons.join("\n")}`;
|
|
|
126260
126284
|
}
|
|
126261
126285
|
if (host.lastExternalCompletionProbe?.sourcePath) {
|
|
126262
126286
|
try {
|
|
126263
|
-
|
|
126287
|
+
fs46.statSync(host.lastExternalCompletionProbe.sourcePath);
|
|
126264
126288
|
} catch {
|
|
126265
126289
|
}
|
|
126266
126290
|
}
|
|
@@ -127576,7 +127600,7 @@ ${buttons.join("\n")}`;
|
|
|
127576
127600
|
const resolvedDbPath = probe.dbPath.replace(/^~/, os30.homedir());
|
|
127577
127601
|
const now = Date.now();
|
|
127578
127602
|
if (this.sqliteProbeCache.missingUntil > now) return null;
|
|
127579
|
-
if (!
|
|
127603
|
+
if (!fs47.existsSync(resolvedDbPath)) {
|
|
127580
127604
|
this.sqliteProbeCache.missingUntil = now + 1e4;
|
|
127581
127605
|
return null;
|
|
127582
127606
|
}
|
|
@@ -132980,7 +133004,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
132980
133004
|
var net3 = __toESM2(require("net"));
|
|
132981
133005
|
var os322 = __toESM2(require("os"));
|
|
132982
133006
|
var path56 = __toESM2(require("path"));
|
|
132983
|
-
var
|
|
133007
|
+
var fs52 = __toESM2(require("fs"));
|
|
132984
133008
|
var path55 = __toESM2(require("path"));
|
|
132985
133009
|
var chokidar = __toESM2(require_chokidar());
|
|
132986
133010
|
init_logger();
|
|
@@ -133481,7 +133505,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133481
133505
|
init_contract();
|
|
133482
133506
|
init_track_identity();
|
|
133483
133507
|
init_config_dir();
|
|
133484
|
-
var
|
|
133508
|
+
var fs48 = __toESM2(require("fs"));
|
|
133485
133509
|
var path51 = __toESM2(require("path"));
|
|
133486
133510
|
var crypto8 = __toESM2(require("crypto"));
|
|
133487
133511
|
init_config();
|
|
@@ -133517,13 +133541,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133517
133541
|
/** Create a fresh staging directory. Caller must clean it up (or gc will). */
|
|
133518
133542
|
createStagingDir(kind) {
|
|
133519
133543
|
const dir = path51.join(this.stagingDir, `${kind}-${process.pid}-${crypto8.randomBytes(6).toString("hex")}`);
|
|
133520
|
-
|
|
133544
|
+
fs48.mkdirSync(dir, { recursive: true });
|
|
133521
133545
|
return dir;
|
|
133522
133546
|
}
|
|
133523
133547
|
removeStagingDir(dir) {
|
|
133524
133548
|
if (!dir.startsWith(this.stagingDir + path51.sep)) return;
|
|
133525
133549
|
try {
|
|
133526
|
-
|
|
133550
|
+
fs48.rmSync(dir, { recursive: true, force: true });
|
|
133527
133551
|
} catch {
|
|
133528
133552
|
}
|
|
133529
133553
|
}
|
|
@@ -133539,7 +133563,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133539
133563
|
}
|
|
133540
133564
|
hasObject(digest) {
|
|
133541
133565
|
try {
|
|
133542
|
-
return
|
|
133566
|
+
return fs48.statSync(this.getObjectDir(digest)).isDirectory();
|
|
133543
133567
|
} catch {
|
|
133544
133568
|
return false;
|
|
133545
133569
|
}
|
|
@@ -133557,8 +133581,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133557
133581
|
this.removeStagingDir(stagedObjectDir);
|
|
133558
133582
|
return objectDir;
|
|
133559
133583
|
}
|
|
133560
|
-
|
|
133561
|
-
|
|
133584
|
+
fs48.mkdirSync(this.objectsDir, { recursive: true });
|
|
133585
|
+
fs48.renameSync(stagedObjectDir, objectDir);
|
|
133562
133586
|
return objectDir;
|
|
133563
133587
|
}
|
|
133564
133588
|
// ─── Pointers ────────────────────────────────────────────
|
|
@@ -133570,10 +133594,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133570
133594
|
*/
|
|
133571
133595
|
getPointer(channel, providerType) {
|
|
133572
133596
|
const file2 = this.pointerPath(channel, providerType);
|
|
133573
|
-
if (!
|
|
133597
|
+
if (!fs48.existsSync(file2)) return null;
|
|
133574
133598
|
let parsed;
|
|
133575
133599
|
try {
|
|
133576
|
-
parsed = JSON.parse(
|
|
133600
|
+
parsed = JSON.parse(fs48.readFileSync(file2, "utf-8"));
|
|
133577
133601
|
} catch (e) {
|
|
133578
133602
|
throw new ProviderChannelError(
|
|
133579
133603
|
"STORE_CORRUPT",
|
|
@@ -133601,7 +133625,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133601
133625
|
const dir = this.activeDir(channel);
|
|
133602
133626
|
let files = [];
|
|
133603
133627
|
try {
|
|
133604
|
-
files =
|
|
133628
|
+
files = fs48.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
133605
133629
|
} catch {
|
|
133606
133630
|
return { pointers, errors };
|
|
133607
133631
|
}
|
|
@@ -133622,7 +133646,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133622
133646
|
const activations = [];
|
|
133623
133647
|
for (const pointer of pointers.values()) {
|
|
133624
133648
|
const objectDir = this.getObjectDir(pointer.active.digest);
|
|
133625
|
-
if (!
|
|
133649
|
+
if (!fs48.existsSync(objectDir)) {
|
|
133626
133650
|
errors.push(new ProviderChannelError(
|
|
133627
133651
|
"STORE_CORRUPT",
|
|
133628
133652
|
`active object ${pointer.active.digest} for "${pointer.active.providerType}" is missing \u2014 skipping (fail closed)`,
|
|
@@ -133691,9 +133715,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133691
133715
|
/** Remove an activation pointer (e.g. provider uninstalled). */
|
|
133692
133716
|
removePointer(channel, providerType) {
|
|
133693
133717
|
const file2 = this.pointerPath(channel, providerType);
|
|
133694
|
-
if (!
|
|
133718
|
+
if (!fs48.existsSync(file2)) return false;
|
|
133695
133719
|
try {
|
|
133696
|
-
|
|
133720
|
+
fs48.rmSync(file2, { force: true });
|
|
133697
133721
|
return true;
|
|
133698
133722
|
} catch {
|
|
133699
133723
|
return false;
|
|
@@ -133701,11 +133725,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133701
133725
|
}
|
|
133702
133726
|
writePointerAtomic(channel, providerType, pointer) {
|
|
133703
133727
|
const dir = this.activeDir(channel);
|
|
133704
|
-
|
|
133728
|
+
fs48.mkdirSync(dir, { recursive: true });
|
|
133705
133729
|
const file2 = this.pointerPath(channel, providerType);
|
|
133706
133730
|
const tmp = path51.join(dir, `.${providerType}.${process.pid}.${crypto8.randomBytes(4).toString("hex")}.tmp`);
|
|
133707
|
-
|
|
133708
|
-
|
|
133731
|
+
fs48.writeFileSync(tmp, JSON.stringify(pointer, null, 2), "utf-8");
|
|
133732
|
+
fs48.renameSync(tmp, file2);
|
|
133709
133733
|
}
|
|
133710
133734
|
// ─── GC (N=2 retention) ──────────────────────────────────
|
|
133711
133735
|
/**
|
|
@@ -133721,13 +133745,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133721
133745
|
const dir = this.activeDir(channel);
|
|
133722
133746
|
let files = [];
|
|
133723
133747
|
try {
|
|
133724
|
-
files =
|
|
133748
|
+
files = fs48.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
133725
133749
|
} catch {
|
|
133726
133750
|
continue;
|
|
133727
133751
|
}
|
|
133728
133752
|
for (const file2 of files) {
|
|
133729
133753
|
try {
|
|
133730
|
-
const parsed = JSON.parse(
|
|
133754
|
+
const parsed = JSON.parse(fs48.readFileSync(path51.join(dir, file2), "utf-8"));
|
|
133731
133755
|
if (typeof parsed?.active?.digest === "string") referenced.add(parsed.active.digest);
|
|
133732
133756
|
if (typeof parsed?.previous?.digest === "string") referenced.add(parsed.previous.digest);
|
|
133733
133757
|
} catch {
|
|
@@ -133737,7 +133761,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133737
133761
|
const removedObjects = [];
|
|
133738
133762
|
let objectNames = [];
|
|
133739
133763
|
try {
|
|
133740
|
-
objectNames =
|
|
133764
|
+
objectNames = fs48.readdirSync(this.objectsDir);
|
|
133741
133765
|
} catch {
|
|
133742
133766
|
objectNames = [];
|
|
133743
133767
|
}
|
|
@@ -133745,7 +133769,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133745
133769
|
const digest = `sha256:${name}`;
|
|
133746
133770
|
if (referenced.has(digest)) continue;
|
|
133747
133771
|
try {
|
|
133748
|
-
|
|
133772
|
+
fs48.rmSync(path51.join(this.objectsDir, name), { recursive: true, force: true });
|
|
133749
133773
|
removedObjects.push(digest);
|
|
133750
133774
|
} catch {
|
|
133751
133775
|
}
|
|
@@ -133753,13 +133777,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133753
133777
|
let removedStaging = 0;
|
|
133754
133778
|
let stagingEntries = [];
|
|
133755
133779
|
try {
|
|
133756
|
-
stagingEntries =
|
|
133780
|
+
stagingEntries = fs48.readdirSync(this.stagingDir);
|
|
133757
133781
|
} catch {
|
|
133758
133782
|
stagingEntries = [];
|
|
133759
133783
|
}
|
|
133760
133784
|
for (const name of stagingEntries) {
|
|
133761
133785
|
try {
|
|
133762
|
-
|
|
133786
|
+
fs48.rmSync(path51.join(this.stagingDir, name), { recursive: true, force: true });
|
|
133763
133787
|
removedStaging++;
|
|
133764
133788
|
} catch {
|
|
133765
133789
|
}
|
|
@@ -133770,10 +133794,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133770
133794
|
return { removedObjects, removedStaging };
|
|
133771
133795
|
}
|
|
133772
133796
|
};
|
|
133773
|
-
var
|
|
133797
|
+
var fs51 = __toESM2(require("fs"));
|
|
133774
133798
|
var path53 = __toESM2(require("path"));
|
|
133775
133799
|
init_contract();
|
|
133776
|
-
var
|
|
133800
|
+
var fs49 = __toESM2(require("fs"));
|
|
133777
133801
|
var path522 = __toESM2(require("path"));
|
|
133778
133802
|
var import_crypto18 = require("crypto");
|
|
133779
133803
|
init_contract();
|
|
@@ -133792,7 +133816,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133792
133816
|
const hash2 = (0, import_crypto18.createHash)("sha256");
|
|
133793
133817
|
for (const relPath of relPaths) {
|
|
133794
133818
|
const absPath = path522.join(rootDir, ...relPath.split("/"));
|
|
133795
|
-
const bytes =
|
|
133819
|
+
const bytes = fs49.readFileSync(absPath);
|
|
133796
133820
|
hash2.update(relPath, "utf8");
|
|
133797
133821
|
hash2.update("\0");
|
|
133798
133822
|
hash2.update(String(bytes.length), "utf8");
|
|
@@ -133804,7 +133828,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133804
133828
|
function collectRegularFiles(rootDir, dir, out, providerType) {
|
|
133805
133829
|
let entries;
|
|
133806
133830
|
try {
|
|
133807
|
-
entries =
|
|
133831
|
+
entries = fs49.readdirSync(dir, { withFileTypes: true });
|
|
133808
133832
|
} catch (e) {
|
|
133809
133833
|
throw new ProviderChannelError(
|
|
133810
133834
|
"ENTRY_TREE_INVALID",
|
|
@@ -133829,12 +133853,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133829
133853
|
out.push(rel);
|
|
133830
133854
|
}
|
|
133831
133855
|
}
|
|
133832
|
-
var
|
|
133856
|
+
var fs50 = __toESM2(require("fs"));
|
|
133833
133857
|
var zlib = __toESM2(require("zlib"));
|
|
133834
133858
|
var import_promises6 = require("stream/promises");
|
|
133835
133859
|
async function extractTarballGz(tarPath, destDir) {
|
|
133836
133860
|
const tarFs = require_tar_fs();
|
|
133837
|
-
await (0, import_promises6.pipeline)(
|
|
133861
|
+
await (0, import_promises6.pipeline)(fs50.createReadStream(tarPath), zlib.createGunzip(), tarFs.extract(destDir));
|
|
133838
133862
|
}
|
|
133839
133863
|
var REGISTRY_LIST_LIMIT = 100;
|
|
133840
133864
|
var ProviderChannelRuntime = class {
|
|
@@ -133957,7 +133981,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
133957
133981
|
try {
|
|
133958
133982
|
const tarPath = path53.join(stagingRoot, "providers.tar.gz");
|
|
133959
133983
|
const extractDir = path53.join(stagingRoot, "repo");
|
|
133960
|
-
|
|
133984
|
+
fs51.mkdirSync(extractDir, { recursive: true });
|
|
133961
133985
|
try {
|
|
133962
133986
|
await this.downloadFile(this.providerTarballUrl, tarPath);
|
|
133963
133987
|
await this.extractTarball(tarPath, extractDir);
|
|
@@ -134015,8 +134039,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134015
134039
|
let relDir;
|
|
134016
134040
|
try {
|
|
134017
134041
|
relDir = path53.relative(repoRoot, artifactDir).split(path53.sep).join("/");
|
|
134018
|
-
|
|
134019
|
-
|
|
134042
|
+
fs51.mkdirSync(path53.join(objStaging, entry.category), { recursive: true });
|
|
134043
|
+
fs51.renameSync(artifactDir, path53.join(objStaging, entry.category, path53.basename(artifactDir)));
|
|
134020
134044
|
} catch (e) {
|
|
134021
134045
|
this.store.removeStagingDir(objStaging);
|
|
134022
134046
|
return { code: "TRANSPORT_FAILED", message: `failed to stage artifact tree: ${e?.message || e}`, providerType: entry.providerType };
|
|
@@ -134055,7 +134079,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134055
134079
|
function findTarballRepoRoot(extractDir) {
|
|
134056
134080
|
let entries;
|
|
134057
134081
|
try {
|
|
134058
|
-
entries =
|
|
134082
|
+
entries = fs51.readdirSync(extractDir, { withFileTypes: true });
|
|
134059
134083
|
} catch {
|
|
134060
134084
|
return null;
|
|
134061
134085
|
}
|
|
@@ -134067,7 +134091,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134067
134091
|
const categoryDir = path53.join(repoRoot, entry.category);
|
|
134068
134092
|
let candidates;
|
|
134069
134093
|
try {
|
|
134070
|
-
candidates =
|
|
134094
|
+
candidates = fs51.readdirSync(categoryDir, { withFileTypes: true });
|
|
134071
134095
|
} catch {
|
|
134072
134096
|
return null;
|
|
134073
134097
|
}
|
|
@@ -134078,8 +134102,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134078
134102
|
for (const manifestName of ["provider.v1.json", "provider.json"]) {
|
|
134079
134103
|
const manifestPath = path53.join(dir, manifestName);
|
|
134080
134104
|
try {
|
|
134081
|
-
if (!
|
|
134082
|
-
const manifest = JSON.parse(
|
|
134105
|
+
if (!fs51.existsSync(manifestPath)) continue;
|
|
134106
|
+
const manifest = JSON.parse(fs51.readFileSync(manifestPath, "utf-8"));
|
|
134083
134107
|
if (manifest?.type === entry.providerType) return dir;
|
|
134084
134108
|
break;
|
|
134085
134109
|
} catch {
|
|
@@ -134096,14 +134120,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134096
134120
|
const scan = (dir) => {
|
|
134097
134121
|
let entries;
|
|
134098
134122
|
try {
|
|
134099
|
-
entries =
|
|
134123
|
+
entries = fs51.readdirSync(dir, { withFileTypes: true });
|
|
134100
134124
|
} catch {
|
|
134101
134125
|
return;
|
|
134102
134126
|
}
|
|
134103
134127
|
const manifest = entries.find((e) => e.isFile() && (e.name === "provider.v1.json" || e.name === "provider.json"));
|
|
134104
134128
|
if (manifest) {
|
|
134105
134129
|
try {
|
|
134106
|
-
const parsed = JSON.parse(
|
|
134130
|
+
const parsed = JSON.parse(fs51.readFileSync(path53.join(dir, manifest.name), "utf-8"));
|
|
134107
134131
|
if (typeof parsed?.type === "string" && parsed.type.trim()) targets.add(parsed.type);
|
|
134108
134132
|
} catch {
|
|
134109
134133
|
}
|
|
@@ -134168,7 +134192,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134168
134192
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
134169
134193
|
return;
|
|
134170
134194
|
}
|
|
134171
|
-
const ws =
|
|
134195
|
+
const ws = fs51.createWriteStream(destPath);
|
|
134172
134196
|
res.pipe(ws);
|
|
134173
134197
|
ws.on("finish", () => {
|
|
134174
134198
|
ws.close();
|
|
@@ -134329,9 +134353,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134329
134353
|
static siblingRefusalLogged = /* @__PURE__ */ new Set();
|
|
134330
134354
|
static looksLikeProviderRoot(candidate) {
|
|
134331
134355
|
try {
|
|
134332
|
-
if (!
|
|
134356
|
+
if (!fs52.existsSync(candidate) || !fs52.statSync(candidate).isDirectory()) return false;
|
|
134333
134357
|
return ["ide", "extension", "cli", "acp"].some(
|
|
134334
|
-
(category) =>
|
|
134358
|
+
(category) => fs52.existsSync(path55.join(candidate, category))
|
|
134335
134359
|
);
|
|
134336
134360
|
} catch {
|
|
134337
134361
|
return false;
|
|
@@ -134339,7 +134363,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134339
134363
|
}
|
|
134340
134364
|
static hasProviderRootMarker(candidate) {
|
|
134341
134365
|
try {
|
|
134342
|
-
return
|
|
134366
|
+
return fs52.existsSync(path55.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
134343
134367
|
} catch {
|
|
134344
134368
|
return false;
|
|
134345
134369
|
}
|
|
@@ -134426,12 +134450,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134426
134450
|
const configDir = getConfigDir2();
|
|
134427
134451
|
const oldDir = path55.join(configDir, "marketplace");
|
|
134428
134452
|
const newDir = path55.join(configDir, "external");
|
|
134429
|
-
if (!
|
|
134430
|
-
if (
|
|
134453
|
+
if (!fs52.existsSync(oldDir)) return;
|
|
134454
|
+
if (fs52.existsSync(newDir)) {
|
|
134431
134455
|
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
134432
134456
|
return;
|
|
134433
134457
|
}
|
|
134434
|
-
|
|
134458
|
+
fs52.renameSync(oldDir, newDir);
|
|
134435
134459
|
this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
|
|
134436
134460
|
} catch (e) {
|
|
134437
134461
|
this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
|
|
@@ -134551,7 +134575,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134551
134575
|
this.providers.clear();
|
|
134552
134576
|
this.providerAvailability.clear();
|
|
134553
134577
|
let upstreamCount = 0;
|
|
134554
|
-
if (!this.disableUpstream &&
|
|
134578
|
+
if (!this.disableUpstream && fs52.existsSync(this.upstreamDir)) {
|
|
134555
134579
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
134556
134580
|
if (upstreamCount > 0) {
|
|
134557
134581
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -134561,10 +134585,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134561
134585
|
}
|
|
134562
134586
|
this.loadVerifiedChannelActivations();
|
|
134563
134587
|
const externalDir = path55.join(getConfigDir2(), "external");
|
|
134564
|
-
if (
|
|
134588
|
+
if (fs52.existsSync(externalDir)) {
|
|
134565
134589
|
const rootEntries = (() => {
|
|
134566
134590
|
try {
|
|
134567
|
-
return
|
|
134591
|
+
return fs52.readdirSync(externalDir, { withFileTypes: true });
|
|
134568
134592
|
} catch {
|
|
134569
134593
|
return [];
|
|
134570
134594
|
}
|
|
@@ -134613,7 +134637,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134613
134637
|
}
|
|
134614
134638
|
}
|
|
134615
134639
|
}
|
|
134616
|
-
if (
|
|
134640
|
+
if (fs52.existsSync(this.userDir)) {
|
|
134617
134641
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
134618
134642
|
if (userCount > 0) {
|
|
134619
134643
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -134751,7 +134775,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134751
134775
|
if (this.countVerifiedChannelPointers() > 0) return null;
|
|
134752
134776
|
if (this.hasUpstream()) return this.syncVerifiedChannel();
|
|
134753
134777
|
try {
|
|
134754
|
-
|
|
134778
|
+
fs52.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
134755
134779
|
} catch {
|
|
134756
134780
|
}
|
|
134757
134781
|
return this.syncVerifiedChannel({ bootstrapAll: true });
|
|
@@ -134762,7 +134786,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134762
134786
|
}
|
|
134763
134787
|
readChannelActivationStamp() {
|
|
134764
134788
|
try {
|
|
134765
|
-
return JSON.parse(
|
|
134789
|
+
return JSON.parse(fs52.readFileSync(this.channelActivationStampPath(), "utf-8"));
|
|
134766
134790
|
} catch {
|
|
134767
134791
|
return null;
|
|
134768
134792
|
}
|
|
@@ -134810,8 +134834,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134810
134834
|
}
|
|
134811
134835
|
}
|
|
134812
134836
|
try {
|
|
134813
|
-
|
|
134814
|
-
|
|
134837
|
+
fs52.mkdirSync(this.defaultProvidersDir, { recursive: true });
|
|
134838
|
+
fs52.writeFileSync(stampPath, JSON.stringify({
|
|
134815
134839
|
daemonVersion: this.daemonVersion,
|
|
134816
134840
|
channel: this.channel,
|
|
134817
134841
|
syncedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -134955,10 +134979,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
134955
134979
|
* Check if upstream directory exists and has providers.
|
|
134956
134980
|
*/
|
|
134957
134981
|
hasUpstream() {
|
|
134958
|
-
if (!
|
|
134982
|
+
if (!fs52.existsSync(this.upstreamDir)) return false;
|
|
134959
134983
|
try {
|
|
134960
|
-
return
|
|
134961
|
-
(d) =>
|
|
134984
|
+
return fs52.readdirSync(this.upstreamDir).some(
|
|
134985
|
+
(d) => fs52.statSync(path55.join(this.upstreamDir, d)).isDirectory()
|
|
134962
134986
|
);
|
|
134963
134987
|
} catch {
|
|
134964
134988
|
return false;
|
|
@@ -135507,7 +135531,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135507
135531
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
135508
135532
|
if (providerDir) {
|
|
135509
135533
|
const fullDir = path55.join(providerDir, entry.scriptDir);
|
|
135510
|
-
resolved._resolvedScriptsPath =
|
|
135534
|
+
resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135511
135535
|
}
|
|
135512
135536
|
matched = true;
|
|
135513
135537
|
}
|
|
@@ -135526,7 +135550,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135526
135550
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
135527
135551
|
if (providerDir) {
|
|
135528
135552
|
const fullDir = path55.join(providerDir, base.defaultScriptDir);
|
|
135529
|
-
resolved._resolvedScriptsPath =
|
|
135553
|
+
resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135530
135554
|
}
|
|
135531
135555
|
}
|
|
135532
135556
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -135544,7 +135568,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135544
135568
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
135545
135569
|
if (providerDir) {
|
|
135546
135570
|
const fullDir = path55.join(providerDir, dirOverride);
|
|
135547
|
-
resolved._resolvedScriptsPath =
|
|
135571
|
+
resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135548
135572
|
}
|
|
135549
135573
|
}
|
|
135550
135574
|
} else if (override.scripts) {
|
|
@@ -135561,7 +135585,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135561
135585
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
135562
135586
|
if (providerDir) {
|
|
135563
135587
|
const fullDir = path55.join(providerDir, base.defaultScriptDir);
|
|
135564
|
-
resolved._resolvedScriptsPath =
|
|
135588
|
+
resolved._resolvedScriptsPath = fs52.existsSync(path55.join(fullDir, "scripts.js")) ? path55.join(fullDir, "scripts.js") : fullDir;
|
|
135565
135589
|
}
|
|
135566
135590
|
}
|
|
135567
135591
|
}
|
|
@@ -135579,7 +135603,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135579
135603
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
135580
135604
|
if (!override || typeof override.path !== "string") continue;
|
|
135581
135605
|
const fullPath = path55.join(providerDir2, override.path);
|
|
135582
|
-
if (!
|
|
135606
|
+
if (!fs52.existsSync(fullPath)) {
|
|
135583
135607
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
135584
135608
|
continue;
|
|
135585
135609
|
}
|
|
@@ -135609,7 +135633,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135609
135633
|
}
|
|
135610
135634
|
if (providerDir) {
|
|
135611
135635
|
try {
|
|
135612
|
-
const
|
|
135636
|
+
const fs68 = require("fs");
|
|
135613
135637
|
const path64 = require("path");
|
|
135614
135638
|
const candidates = [];
|
|
135615
135639
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -135621,13 +135645,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135621
135645
|
}
|
|
135622
135646
|
candidates.push(path64.join(providerDir, "specs", "default.json"));
|
|
135623
135647
|
candidates.push(path64.join(providerDir, "spec.json"));
|
|
135624
|
-
const specPath = candidates.find((p) =>
|
|
135648
|
+
const specPath = candidates.find((p) => fs68.existsSync(p));
|
|
135625
135649
|
let nh;
|
|
135626
135650
|
if (specPath) {
|
|
135627
135651
|
resolved._resolvedSpecPath = specPath;
|
|
135628
135652
|
let specControls;
|
|
135629
135653
|
try {
|
|
135630
|
-
const rawSpec = JSON.parse(
|
|
135654
|
+
const rawSpec = JSON.parse(fs68.readFileSync(specPath, "utf8"));
|
|
135631
135655
|
specControls = rawSpec.control_bar;
|
|
135632
135656
|
nh = rawSpec.native_history;
|
|
135633
135657
|
} catch {
|
|
@@ -135670,7 +135694,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135670
135694
|
}
|
|
135671
135695
|
} else if (nh.override_path) {
|
|
135672
135696
|
const overrideFile = path64.resolve(providerDir, nh.override_path);
|
|
135673
|
-
if (
|
|
135697
|
+
if (fs68.existsSync(overrideFile)) {
|
|
135674
135698
|
try {
|
|
135675
135699
|
registerProviderScriptRootSafely(path64.dirname(path64.dirname(providerDir)));
|
|
135676
135700
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -135729,7 +135753,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135729
135753
|
return null;
|
|
135730
135754
|
}
|
|
135731
135755
|
const dir = path55.join(providerDir, scriptDir);
|
|
135732
|
-
if (!
|
|
135756
|
+
if (!fs52.existsSync(dir)) {
|
|
135733
135757
|
this.debugLog(`[loadScriptsFromDir] ${type2}: dir not found: ${dir}`);
|
|
135734
135758
|
return null;
|
|
135735
135759
|
}
|
|
@@ -135737,7 +135761,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135737
135761
|
const cached5 = this.scriptsCache.get(dir);
|
|
135738
135762
|
if (cached5) return cached5;
|
|
135739
135763
|
const scriptsJs = path55.join(dir, "scripts.js");
|
|
135740
|
-
if (
|
|
135764
|
+
if (fs52.existsSync(scriptsJs)) {
|
|
135741
135765
|
try {
|
|
135742
135766
|
delete require.cache[require.resolve(scriptsJs)];
|
|
135743
135767
|
const loaded = require(scriptsJs);
|
|
@@ -135758,9 +135782,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135758
135782
|
watch() {
|
|
135759
135783
|
this.stopWatch();
|
|
135760
135784
|
const watchDir = (dir) => {
|
|
135761
|
-
if (!
|
|
135785
|
+
if (!fs52.existsSync(dir)) {
|
|
135762
135786
|
try {
|
|
135763
|
-
|
|
135787
|
+
fs52.mkdirSync(dir, { recursive: true });
|
|
135764
135788
|
} catch {
|
|
135765
135789
|
return;
|
|
135766
135790
|
}
|
|
@@ -135823,11 +135847,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
135823
135847
|
}
|
|
135824
135848
|
/** Count provider files (provider.v1.json or provider.json — at most one per dir). */
|
|
135825
135849
|
countProviders(dir) {
|
|
135826
|
-
if (!
|
|
135850
|
+
if (!fs52.existsSync(dir)) return 0;
|
|
135827
135851
|
let count = 0;
|
|
135828
135852
|
const scan = (d) => {
|
|
135829
135853
|
try {
|
|
135830
|
-
const entries =
|
|
135854
|
+
const entries = fs52.readdirSync(d, { withFileTypes: true });
|
|
135831
135855
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
135832
135856
|
if (hasManifest) count++;
|
|
135833
135857
|
for (const entry of entries) {
|
|
@@ -136057,13 +136081,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136057
136081
|
if (!provider) return null;
|
|
136058
136082
|
const cat = provider.category;
|
|
136059
136083
|
const searchRoots = this.getProviderRoots();
|
|
136060
|
-
const hasManifest = (dir) =>
|
|
136084
|
+
const hasManifest = (dir) => fs52.existsSync(path55.join(dir, "provider.v1.json")) || fs52.existsSync(path55.join(dir, "provider.json"));
|
|
136061
136085
|
const readManifestType = (dir) => {
|
|
136062
136086
|
for (const file2 of ["provider.v1.json", "provider.json"]) {
|
|
136063
136087
|
const p = path55.join(dir, file2);
|
|
136064
|
-
if (!
|
|
136088
|
+
if (!fs52.existsSync(p)) continue;
|
|
136065
136089
|
try {
|
|
136066
|
-
const data = JSON.parse(
|
|
136090
|
+
const data = JSON.parse(fs52.readFileSync(p, "utf-8"));
|
|
136067
136091
|
if (typeof data?.type === "string") return data.type;
|
|
136068
136092
|
} catch {
|
|
136069
136093
|
}
|
|
@@ -136071,13 +136095,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136071
136095
|
return null;
|
|
136072
136096
|
};
|
|
136073
136097
|
for (const root of searchRoots) {
|
|
136074
|
-
if (!
|
|
136098
|
+
if (!fs52.existsSync(root)) continue;
|
|
136075
136099
|
const candidate = this.getProviderDir(root, cat, type2);
|
|
136076
136100
|
if (hasManifest(candidate)) return candidate;
|
|
136077
136101
|
const catDir = path55.join(root, cat);
|
|
136078
|
-
if (
|
|
136102
|
+
if (fs52.existsSync(catDir)) {
|
|
136079
136103
|
try {
|
|
136080
|
-
for (const entry of
|
|
136104
|
+
for (const entry of fs52.readdirSync(catDir, { withFileTypes: true })) {
|
|
136081
136105
|
if (!entry.isDirectory()) continue;
|
|
136082
136106
|
const entryDir = path55.join(catDir, entry.name);
|
|
136083
136107
|
const manifestType = readManifestType(entryDir);
|
|
@@ -136096,7 +136120,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136096
136120
|
*/
|
|
136097
136121
|
buildScriptWrappersFromDir(dir) {
|
|
136098
136122
|
const scriptsJs = path55.join(dir, "scripts.js");
|
|
136099
|
-
if (
|
|
136123
|
+
if (fs52.existsSync(scriptsJs)) {
|
|
136100
136124
|
try {
|
|
136101
136125
|
delete require.cache[require.resolve(scriptsJs)];
|
|
136102
136126
|
return require(scriptsJs);
|
|
@@ -136106,13 +136130,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136106
136130
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
136107
136131
|
const result = {};
|
|
136108
136132
|
try {
|
|
136109
|
-
for (const file2 of
|
|
136133
|
+
for (const file2 of fs52.readdirSync(dir)) {
|
|
136110
136134
|
if (!file2.endsWith(".js")) continue;
|
|
136111
136135
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
136112
136136
|
const filePath = path55.join(dir, file2);
|
|
136113
136137
|
result[scriptName] = (...args) => {
|
|
136114
136138
|
try {
|
|
136115
|
-
let content =
|
|
136139
|
+
let content = fs52.readFileSync(filePath, "utf-8");
|
|
136116
136140
|
if (args[0] && typeof args[0] === "object") {
|
|
136117
136141
|
for (const [key2, val] of Object.entries(args[0])) {
|
|
136118
136142
|
let v = val;
|
|
@@ -136158,12 +136182,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136158
136182
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
136159
136183
|
*/
|
|
136160
136184
|
loadDir(dir, excludeDirs) {
|
|
136161
|
-
if (!
|
|
136185
|
+
if (!fs52.existsSync(dir)) return 0;
|
|
136162
136186
|
let count = 0;
|
|
136163
136187
|
const scan = (d) => {
|
|
136164
136188
|
let entries;
|
|
136165
136189
|
try {
|
|
136166
|
-
entries =
|
|
136190
|
+
entries = fs52.readdirSync(d, { withFileTypes: true });
|
|
136167
136191
|
} catch {
|
|
136168
136192
|
return;
|
|
136169
136193
|
}
|
|
@@ -136173,7 +136197,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
136173
136197
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
136174
136198
|
const jsonPath = path55.join(d, manifestFile);
|
|
136175
136199
|
try {
|
|
136176
|
-
const raw =
|
|
136200
|
+
const raw = fs52.readFileSync(jsonPath, "utf-8");
|
|
136177
136201
|
const mod = JSON.parse(raw);
|
|
136178
136202
|
if (hasV1 && (mod?.category === "cli" || mod?.category === "acp")) {
|
|
136179
136203
|
try {
|
|
@@ -136212,7 +136236,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136212
136236
|
} else {
|
|
136213
136237
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
136214
136238
|
const scriptsPath = path55.join(d, "scripts.js");
|
|
136215
|
-
if (!hasCompatibility &&
|
|
136239
|
+
if (!hasCompatibility && fs52.existsSync(scriptsPath)) {
|
|
136216
136240
|
try {
|
|
136217
136241
|
registerProviderScriptRootSafely(path55.dirname(path55.dirname(d)));
|
|
136218
136242
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -136590,7 +136614,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136590
136614
|
}
|
|
136591
136615
|
} else if (plat === "win32") {
|
|
136592
136616
|
try {
|
|
136593
|
-
const
|
|
136617
|
+
const fs68 = require("fs");
|
|
136594
136618
|
const appNameMap = getMacAppIdentifiers();
|
|
136595
136619
|
const appName = appNameMap[ideId];
|
|
136596
136620
|
if (appName) {
|
|
@@ -136599,8 +136623,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
136599
136623
|
appName,
|
|
136600
136624
|
"storage.json"
|
|
136601
136625
|
);
|
|
136602
|
-
if (
|
|
136603
|
-
const data = JSON.parse(
|
|
136626
|
+
if (fs68.existsSync(storagePath)) {
|
|
136627
|
+
const data = JSON.parse(fs68.readFileSync(storagePath, "utf-8"));
|
|
136604
136628
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
136605
136629
|
if (workspaces.length > 0) {
|
|
136606
136630
|
const recent = workspaces[0];
|
|
@@ -139405,7 +139429,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
139405
139429
|
}
|
|
139406
139430
|
};
|
|
139407
139431
|
var import_path222 = require("path");
|
|
139408
|
-
var
|
|
139432
|
+
var fs56 = __toESM2(require("fs"));
|
|
139409
139433
|
init_logger();
|
|
139410
139434
|
init_mesh_host_ownership();
|
|
139411
139435
|
init_coordinator_registry();
|
|
@@ -139710,15 +139734,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
139710
139734
|
}
|
|
139711
139735
|
if (cliType === "codex-cli") {
|
|
139712
139736
|
const repoMcpConfigPath = (0, import_path222.join)(workspace, ".mcp.json");
|
|
139713
|
-
if (
|
|
139737
|
+
if (fs56.existsSync(repoMcpConfigPath)) {
|
|
139714
139738
|
try {
|
|
139715
139739
|
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
139716
|
-
|
|
139740
|
+
fs56.readFileSync(repoMcpConfigPath, "utf-8"),
|
|
139717
139741
|
"claude_mcp_json"
|
|
139718
139742
|
);
|
|
139719
139743
|
const existingServers2 = repoMcpConfig.mcpServers;
|
|
139720
139744
|
if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
|
|
139721
|
-
|
|
139745
|
+
fs56.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
139722
139746
|
...repoMcpConfig,
|
|
139723
139747
|
mcpServers: {
|
|
139724
139748
|
...existingServers2,
|
|
@@ -140089,7 +140113,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140089
140113
|
}
|
|
140090
140114
|
}
|
|
140091
140115
|
};
|
|
140092
|
-
var
|
|
140116
|
+
var fs57 = __toESM2(require("fs"));
|
|
140093
140117
|
var import_os5 = require("os");
|
|
140094
140118
|
init_config();
|
|
140095
140119
|
init_git_status();
|
|
@@ -140472,7 +140496,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140472
140496
|
}
|
|
140473
140497
|
}
|
|
140474
140498
|
if (workspace) {
|
|
140475
|
-
if (!
|
|
140499
|
+
if (!fs57.existsSync(workspace)) {
|
|
140476
140500
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
140477
140501
|
let remoteProbeApplied = false;
|
|
140478
140502
|
if (inlineTransitGit) {
|
|
@@ -140613,7 +140637,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140613
140637
|
const pendingRetentionCounters2 = { ...getPendingRetentionCounters() };
|
|
140614
140638
|
const turnPresentationCounters = getTurnPresentationMetrics();
|
|
140615
140639
|
const previewFreshness = (() => {
|
|
140616
|
-
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate &&
|
|
140640
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs57.existsSync(candidate));
|
|
140617
140641
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
140618
140642
|
})();
|
|
140619
140643
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -140813,7 +140837,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140813
140837
|
init_logger();
|
|
140814
140838
|
init_mesh_dual_write();
|
|
140815
140839
|
init_transcript_publisher();
|
|
140816
|
-
var
|
|
140840
|
+
var fs58 = __toESM2(require("fs"));
|
|
140817
140841
|
var path57 = __toESM2(require("path"));
|
|
140818
140842
|
init_config_dir();
|
|
140819
140843
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
@@ -140862,7 +140886,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140862
140886
|
currentFile = path57.join(dir, `commands-${today}.jsonl`);
|
|
140863
140887
|
if (dirChanged) {
|
|
140864
140888
|
try {
|
|
140865
|
-
|
|
140889
|
+
fs58.mkdirSync(dir, { recursive: true });
|
|
140866
140890
|
} catch {
|
|
140867
140891
|
}
|
|
140868
140892
|
cleanOldFiles();
|
|
@@ -140870,7 +140894,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140870
140894
|
}
|
|
140871
140895
|
function cleanOldFiles() {
|
|
140872
140896
|
try {
|
|
140873
|
-
const files =
|
|
140897
|
+
const files = fs58.readdirSync(currentDir).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
140874
140898
|
const cutoff = /* @__PURE__ */ new Date();
|
|
140875
140899
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
140876
140900
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -140878,7 +140902,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140878
140902
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
140879
140903
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
140880
140904
|
try {
|
|
140881
|
-
|
|
140905
|
+
fs58.unlinkSync(path57.join(currentDir, file2));
|
|
140882
140906
|
} catch {
|
|
140883
140907
|
}
|
|
140884
140908
|
}
|
|
@@ -140888,14 +140912,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140888
140912
|
}
|
|
140889
140913
|
function checkSize() {
|
|
140890
140914
|
try {
|
|
140891
|
-
const stat2 =
|
|
140915
|
+
const stat2 = fs58.statSync(currentFile);
|
|
140892
140916
|
if (stat2.size > MAX_FILE_SIZE) {
|
|
140893
140917
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
140894
140918
|
try {
|
|
140895
|
-
|
|
140919
|
+
fs58.unlinkSync(backup);
|
|
140896
140920
|
} catch {
|
|
140897
140921
|
}
|
|
140898
|
-
|
|
140922
|
+
fs58.renameSync(currentFile, backup);
|
|
140899
140923
|
}
|
|
140900
140924
|
} catch {
|
|
140901
140925
|
}
|
|
@@ -140928,15 +140952,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140928
140952
|
...entry.error ? { err: entry.error } : {},
|
|
140929
140953
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
140930
140954
|
});
|
|
140931
|
-
|
|
140955
|
+
fs58.appendFileSync(currentFile, line + "\n");
|
|
140932
140956
|
} catch {
|
|
140933
140957
|
}
|
|
140934
140958
|
}
|
|
140935
140959
|
function getRecentCommands(count = 50) {
|
|
140936
140960
|
try {
|
|
140937
140961
|
refreshCurrentFile();
|
|
140938
|
-
if (!
|
|
140939
|
-
const content =
|
|
140962
|
+
if (!fs58.existsSync(currentFile)) return [];
|
|
140963
|
+
const content = fs58.readFileSync(currentFile, "utf-8");
|
|
140940
140964
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
140941
140965
|
return lines.slice(-count).map((line) => {
|
|
140942
140966
|
try {
|
|
@@ -140963,10 +140987,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140963
140987
|
init_mesh_host_ownership();
|
|
140964
140988
|
init_repo_mesh_types();
|
|
140965
140989
|
init_mesh_config();
|
|
140966
|
-
var
|
|
140990
|
+
var fs60 = __toESM2(require("fs"));
|
|
140967
140991
|
init_mesh_node_identity();
|
|
140968
140992
|
init_router_refine();
|
|
140969
|
-
var
|
|
140993
|
+
var fs59 = __toESM2(require("fs"));
|
|
140970
140994
|
var import_node_os22 = require("os");
|
|
140971
140995
|
var import_path23 = require("path");
|
|
140972
140996
|
init_logger();
|
|
@@ -140997,7 +141021,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
140997
141021
|
return out;
|
|
140998
141022
|
}
|
|
140999
141023
|
function repoRootUsable(repoRoot) {
|
|
141000
|
-
return typeof repoRoot === "string" && repoRoot.trim().length > 0 &&
|
|
141024
|
+
return typeof repoRoot === "string" && repoRoot.trim().length > 0 && fs59.existsSync(repoRoot.trim());
|
|
141001
141025
|
}
|
|
141002
141026
|
function meshWorktreeBaseDir(mesh) {
|
|
141003
141027
|
const v = mesh?.policy?.worktreeBaseDir;
|
|
@@ -141066,14 +141090,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141066
141090
|
return false;
|
|
141067
141091
|
}
|
|
141068
141092
|
async function bestEffortRemoveWorktreeDir(self, dir) {
|
|
141069
|
-
if (!dir || !
|
|
141093
|
+
if (!dir || !fs59.existsSync(dir)) return { removed: true, residue: false };
|
|
141070
141094
|
const sleep3 = (ms) => new Promise((resolve32) => setTimeout(resolve32, ms));
|
|
141071
141095
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
141072
141096
|
let lastErr;
|
|
141073
141097
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
141074
141098
|
try {
|
|
141075
|
-
|
|
141076
|
-
if (!
|
|
141099
|
+
fs59.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
141100
|
+
if (!fs59.existsSync(dir)) return { removed: true, residue: false };
|
|
141077
141101
|
lastErr = new Error("directory still present after rmSync");
|
|
141078
141102
|
} catch (e) {
|
|
141079
141103
|
lastErr = e;
|
|
@@ -141084,7 +141108,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141084
141108
|
}
|
|
141085
141109
|
await sleep3(150 * (attempt + 1));
|
|
141086
141110
|
}
|
|
141087
|
-
return
|
|
141111
|
+
return fs59.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
141088
141112
|
}
|
|
141089
141113
|
async function precheckLocalWorktreeRemovable(self, args) {
|
|
141090
141114
|
const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
|
|
@@ -141097,10 +141121,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141097
141121
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
|
|
141098
141122
|
};
|
|
141099
141123
|
}
|
|
141100
|
-
if (!
|
|
141124
|
+
if (!fs59.existsSync(workspace)) return { ok: true };
|
|
141101
141125
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
141102
141126
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
141103
|
-
if (!repoRoot || !
|
|
141127
|
+
if (!repoRoot || !fs59.existsSync(repoRoot)) {
|
|
141104
141128
|
return {
|
|
141105
141129
|
ok: false,
|
|
141106
141130
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -141120,7 +141144,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141120
141144
|
const normalizePath2 = (value) => {
|
|
141121
141145
|
const resolved = (0, import_path23.resolve)(value);
|
|
141122
141146
|
try {
|
|
141123
|
-
return
|
|
141147
|
+
return fs59.realpathSync(resolved);
|
|
141124
141148
|
} catch {
|
|
141125
141149
|
return resolved;
|
|
141126
141150
|
}
|
|
@@ -141221,13 +141245,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141221
141245
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
141222
141246
|
};
|
|
141223
141247
|
}
|
|
141224
|
-
const worktreeExists =
|
|
141248
|
+
const worktreeExists = fs59.existsSync(workspace);
|
|
141225
141249
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
141226
141250
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
141227
141251
|
if (!worktreeExists) {
|
|
141228
141252
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
141229
141253
|
}
|
|
141230
|
-
if (!repoRoot || !
|
|
141254
|
+
if (!repoRoot || !fs59.existsSync(repoRoot)) {
|
|
141231
141255
|
return {
|
|
141232
141256
|
success: false,
|
|
141233
141257
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -141247,7 +141271,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141247
141271
|
const normalizePath2 = (value) => {
|
|
141248
141272
|
const resolved = (0, import_path23.resolve)(value);
|
|
141249
141273
|
try {
|
|
141250
|
-
return
|
|
141274
|
+
return fs59.realpathSync(resolved);
|
|
141251
141275
|
} catch {
|
|
141252
141276
|
return resolved;
|
|
141253
141277
|
}
|
|
@@ -141464,7 +141488,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141464
141488
|
});
|
|
141465
141489
|
return String(stdout || "").trim();
|
|
141466
141490
|
};
|
|
141467
|
-
const workspaceMissing = !args.workspace || !
|
|
141491
|
+
const workspaceMissing = !args.workspace || !fs59.existsSync(args.workspace);
|
|
141468
141492
|
let head = "";
|
|
141469
141493
|
const branch = typeof args.node?.worktreeBranch === "string" ? args.node.worktreeBranch.trim() : "";
|
|
141470
141494
|
if (workspaceMissing) {
|
|
@@ -142514,7 +142538,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
142514
142538
|
const tombstones = this.removedInlineMeshNodeIds.get(meshId);
|
|
142515
142539
|
if (!tombstones?.size || !tombstones.has(nodeId)) return false;
|
|
142516
142540
|
const workspace = readStringValue(node?.workspace);
|
|
142517
|
-
if (workspace &&
|
|
142541
|
+
if (workspace && fs60.existsSync(workspace)) {
|
|
142518
142542
|
tombstones.delete(nodeId);
|
|
142519
142543
|
if (tombstones.size === 0) this.removedInlineMeshNodeIds.delete(meshId);
|
|
142520
142544
|
return false;
|
|
@@ -142535,7 +142559,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
142535
142559
|
const nodeId = readInlineMeshNodeId(node);
|
|
142536
142560
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
142537
142561
|
const workspace = readStringValue(node?.workspace);
|
|
142538
|
-
if (workspace &&
|
|
142562
|
+
if (workspace && fs60.existsSync(workspace)) {
|
|
142539
142563
|
tombstones.delete(nodeId);
|
|
142540
142564
|
return true;
|
|
142541
142565
|
}
|
|
@@ -142980,7 +143004,6 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
142980
143004
|
}
|
|
142981
143005
|
init_snapshot3();
|
|
142982
143006
|
init_runtime_defaults();
|
|
142983
|
-
init_transcript_publisher();
|
|
142984
143007
|
var DEFAULT_GIT_REFRESH_CONCURRENCY = 2;
|
|
142985
143008
|
var DEFAULT_CHAT_TAIL_FLUSH_DEBOUNCE_MS = 700;
|
|
142986
143009
|
var PUSH_TOPICS = ["machine.runtime", "session_host.diagnostics", "session.modal", "daemon.metadata"];
|
|
@@ -143334,7 +143357,6 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
143334
143357
|
markChatOutputActivity(sessionId) {
|
|
143335
143358
|
const cfg = this.opts.chatTail;
|
|
143336
143359
|
if (!sessionId || !(cfg?.isCliSession?.(sessionId) ?? false)) return;
|
|
143337
|
-
markTranscriptPtyOutputActivity(sessionId);
|
|
143338
143360
|
this.chatOutputActiveAt.set(sessionId, this.now());
|
|
143339
143361
|
if (this.chatOutputFlushTimer) return;
|
|
143340
143362
|
if (cfg?.scheduleGate && !cfg.scheduleGate()) return;
|
|
@@ -145660,7 +145682,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145660
145682
|
};
|
|
145661
145683
|
init_io_contracts();
|
|
145662
145684
|
init_chat_message_normalization();
|
|
145663
|
-
var
|
|
145685
|
+
var fs61 = __toESM2(require("fs"));
|
|
145664
145686
|
var path58 = __toESM2(require("path"));
|
|
145665
145687
|
var os33 = __toESM2(require("os"));
|
|
145666
145688
|
var import_os6 = require("os");
|
|
@@ -145677,8 +145699,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145677
145699
|
}
|
|
145678
145700
|
load() {
|
|
145679
145701
|
try {
|
|
145680
|
-
if (
|
|
145681
|
-
this.history = JSON.parse(
|
|
145702
|
+
if (fs61.existsSync(getArchivePath2())) {
|
|
145703
|
+
this.history = JSON.parse(fs61.readFileSync(getArchivePath2(), "utf-8"));
|
|
145682
145704
|
}
|
|
145683
145705
|
} catch {
|
|
145684
145706
|
this.history = {};
|
|
@@ -145715,8 +145737,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145715
145737
|
}
|
|
145716
145738
|
save() {
|
|
145717
145739
|
try {
|
|
145718
|
-
|
|
145719
|
-
|
|
145740
|
+
fs61.mkdirSync(path58.dirname(getArchivePath2()), { recursive: true });
|
|
145741
|
+
fs61.writeFileSync(getArchivePath2(), JSON.stringify(this.history, null, 2));
|
|
145720
145742
|
} catch {
|
|
145721
145743
|
}
|
|
145722
145744
|
}
|
|
@@ -145741,8 +145763,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145741
145763
|
for (const ext of exes) {
|
|
145742
145764
|
const fullPath = path58.join(p, name + ext);
|
|
145743
145765
|
try {
|
|
145744
|
-
if (
|
|
145745
|
-
const stat2 =
|
|
145766
|
+
if (fs61.existsSync(fullPath)) {
|
|
145767
|
+
const stat2 = fs61.statSync(fullPath);
|
|
145746
145768
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
145747
145769
|
return fullPath;
|
|
145748
145770
|
}
|
|
@@ -145789,9 +145811,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145789
145811
|
if (p.includes("*")) {
|
|
145790
145812
|
const home = os33.homedir();
|
|
145791
145813
|
const resolved = p.replace(/\*/g, home.split(path58.sep).pop() || "");
|
|
145792
|
-
if (
|
|
145814
|
+
if (fs61.existsSync(resolved)) return resolved;
|
|
145793
145815
|
} else {
|
|
145794
|
-
if (
|
|
145816
|
+
if (fs61.existsSync(p)) return p;
|
|
145795
145817
|
}
|
|
145796
145818
|
}
|
|
145797
145819
|
return null;
|
|
@@ -145799,7 +145821,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145799
145821
|
async function getMacAppVersion(appPath) {
|
|
145800
145822
|
if ((0, import_os6.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
145801
145823
|
const plistPath = path58.join(appPath, "Contents", "Info.plist");
|
|
145802
|
-
if (!
|
|
145824
|
+
if (!fs61.existsSync(plistPath)) return null;
|
|
145803
145825
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
145804
145826
|
return raw || null;
|
|
145805
145827
|
}
|
|
@@ -145826,7 +145848,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145826
145848
|
let resolvedBin = cliBin;
|
|
145827
145849
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
145828
145850
|
const bundled = path58.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
145829
|
-
if (provider.cli &&
|
|
145851
|
+
if (provider.cli && fs61.existsSync(bundled)) resolvedBin = bundled;
|
|
145830
145852
|
}
|
|
145831
145853
|
info.installed = !!(appPath || resolvedBin);
|
|
145832
145854
|
info.path = appPath || null;
|
|
@@ -145872,7 +145894,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
145872
145894
|
return results;
|
|
145873
145895
|
}
|
|
145874
145896
|
var http3 = __toESM2(require("http"));
|
|
145875
|
-
var
|
|
145897
|
+
var fs65 = __toESM2(require("fs"));
|
|
145876
145898
|
var path62 = __toESM2(require("path"));
|
|
145877
145899
|
init_config();
|
|
145878
145900
|
function generateFiles(type2, name, category, opts = {}) {
|
|
@@ -146218,7 +146240,7 @@ async (params) => {
|
|
|
146218
146240
|
}
|
|
146219
146241
|
init_logger();
|
|
146220
146242
|
init_builders();
|
|
146221
|
-
var
|
|
146243
|
+
var fs62 = __toESM2(require("fs"));
|
|
146222
146244
|
var path59 = __toESM2(require("path"));
|
|
146223
146245
|
init_logger();
|
|
146224
146246
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -146399,17 +146421,17 @@ async (params) => {
|
|
|
146399
146421
|
}
|
|
146400
146422
|
let scriptsPath = "";
|
|
146401
146423
|
const directScripts = path59.join(dir, "scripts.js");
|
|
146402
|
-
if (
|
|
146424
|
+
if (fs62.existsSync(directScripts)) {
|
|
146403
146425
|
scriptsPath = directScripts;
|
|
146404
146426
|
} else {
|
|
146405
146427
|
const scriptsDir = path59.join(dir, "scripts");
|
|
146406
|
-
if (
|
|
146407
|
-
const versions =
|
|
146408
|
-
return
|
|
146428
|
+
if (fs62.existsSync(scriptsDir)) {
|
|
146429
|
+
const versions = fs62.readdirSync(scriptsDir).filter((d) => {
|
|
146430
|
+
return fs62.statSync(path59.join(scriptsDir, d)).isDirectory();
|
|
146409
146431
|
}).sort().reverse();
|
|
146410
146432
|
for (const ver of versions) {
|
|
146411
146433
|
const p = path59.join(scriptsDir, ver, "scripts.js");
|
|
146412
|
-
if (
|
|
146434
|
+
if (fs62.existsSync(p)) {
|
|
146413
146435
|
scriptsPath = p;
|
|
146414
146436
|
break;
|
|
146415
146437
|
}
|
|
@@ -146421,7 +146443,7 @@ async (params) => {
|
|
|
146421
146443
|
return;
|
|
146422
146444
|
}
|
|
146423
146445
|
try {
|
|
146424
|
-
const source =
|
|
146446
|
+
const source = fs62.readFileSync(scriptsPath, "utf-8");
|
|
146425
146447
|
const hints = {};
|
|
146426
146448
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
146427
146449
|
let match;
|
|
@@ -147234,7 +147256,7 @@ async (params) => {
|
|
|
147234
147256
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
147235
147257
|
}
|
|
147236
147258
|
}
|
|
147237
|
-
var
|
|
147259
|
+
var fs63 = __toESM2(require("fs"));
|
|
147238
147260
|
var path60 = __toESM2(require("path"));
|
|
147239
147261
|
function slugifyFixtureName(value) {
|
|
147240
147262
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -147250,10 +147272,10 @@ async (params) => {
|
|
|
147250
147272
|
function readCliFixture(ctx, type2, name) {
|
|
147251
147273
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
147252
147274
|
const filePath = path60.join(fixtureDir, `${name}.json`);
|
|
147253
|
-
if (!
|
|
147275
|
+
if (!fs63.existsSync(filePath)) {
|
|
147254
147276
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
147255
147277
|
}
|
|
147256
|
-
return JSON.parse(
|
|
147278
|
+
return JSON.parse(fs63.readFileSync(filePath, "utf-8"));
|
|
147257
147279
|
}
|
|
147258
147280
|
function getExerciseTranscriptText(result) {
|
|
147259
147281
|
const parts = [];
|
|
@@ -148003,7 +148025,7 @@ async (params) => {
|
|
|
148003
148025
|
return;
|
|
148004
148026
|
}
|
|
148005
148027
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
148006
|
-
|
|
148028
|
+
fs63.mkdirSync(fixtureDir, { recursive: true });
|
|
148007
148029
|
const name = slugifyFixtureName(String(body?.name || `${type2}-${Date.now()}`));
|
|
148008
148030
|
const result = await runCliExerciseInternal(ctx, { ...request, type: type2 });
|
|
148009
148031
|
const fixture = {
|
|
@@ -148031,7 +148053,7 @@ async (params) => {
|
|
|
148031
148053
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
148032
148054
|
};
|
|
148033
148055
|
const filePath = path60.join(fixtureDir, `${name}.json`);
|
|
148034
|
-
|
|
148056
|
+
fs63.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
148035
148057
|
ctx.json(res, 200, {
|
|
148036
148058
|
saved: true,
|
|
148037
148059
|
name,
|
|
@@ -148049,14 +148071,14 @@ async (params) => {
|
|
|
148049
148071
|
async function handleCliFixtureList(ctx, type2, _req, res) {
|
|
148050
148072
|
try {
|
|
148051
148073
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
148052
|
-
if (!
|
|
148074
|
+
if (!fs63.existsSync(fixtureDir)) {
|
|
148053
148075
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
148054
148076
|
return;
|
|
148055
148077
|
}
|
|
148056
|
-
const fixtures =
|
|
148078
|
+
const fixtures = fs63.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
148057
148079
|
const fullPath = path60.join(fixtureDir, file2);
|
|
148058
148080
|
try {
|
|
148059
|
-
const raw = JSON.parse(
|
|
148081
|
+
const raw = JSON.parse(fs63.readFileSync(fullPath, "utf-8"));
|
|
148060
148082
|
return {
|
|
148061
148083
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
148062
148084
|
path: fullPath,
|
|
@@ -148187,7 +148209,7 @@ async (params) => {
|
|
|
148187
148209
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
148188
148210
|
}
|
|
148189
148211
|
}
|
|
148190
|
-
var
|
|
148212
|
+
var fs64 = __toESM2(require("fs"));
|
|
148191
148213
|
var path61 = __toESM2(require("path"));
|
|
148192
148214
|
var os34 = __toESM2(require("os"));
|
|
148193
148215
|
var import_session_host_core10 = require_dist();
|
|
@@ -148236,10 +148258,10 @@ async (params) => {
|
|
|
148236
148258
|
return fallback?.type || null;
|
|
148237
148259
|
}
|
|
148238
148260
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
148239
|
-
if (!
|
|
148240
|
-
const versions =
|
|
148261
|
+
if (!fs64.existsSync(scriptsDir)) return null;
|
|
148262
|
+
const versions = fs64.readdirSync(scriptsDir).filter((d) => {
|
|
148241
148263
|
try {
|
|
148242
|
-
return
|
|
148264
|
+
return fs64.statSync(path61.join(scriptsDir, d)).isDirectory();
|
|
148243
148265
|
} catch {
|
|
148244
148266
|
return false;
|
|
148245
148267
|
}
|
|
@@ -148261,13 +148283,13 @@ async (params) => {
|
|
|
148261
148283
|
if (!sourceDir) {
|
|
148262
148284
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
148263
148285
|
}
|
|
148264
|
-
if (!
|
|
148265
|
-
|
|
148266
|
-
|
|
148286
|
+
if (!fs64.existsSync(desiredDir)) {
|
|
148287
|
+
fs64.mkdirSync(path61.dirname(desiredDir), { recursive: true });
|
|
148288
|
+
fs64.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
148267
148289
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
148268
148290
|
}
|
|
148269
148291
|
const providerJson = path61.join(desiredDir, "provider.json");
|
|
148270
|
-
if (!
|
|
148292
|
+
if (!fs64.existsSync(providerJson)) {
|
|
148271
148293
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
148272
148294
|
}
|
|
148273
148295
|
return { dir: desiredDir };
|
|
@@ -148275,15 +148297,15 @@ async (params) => {
|
|
|
148275
148297
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
148276
148298
|
if (!referenceType) return {};
|
|
148277
148299
|
const refDir = ctx.findProviderDir(referenceType);
|
|
148278
|
-
if (!refDir || !
|
|
148300
|
+
if (!refDir || !fs64.existsSync(refDir)) return {};
|
|
148279
148301
|
const referenceScripts = {};
|
|
148280
148302
|
const scriptsDir = path61.join(refDir, "scripts");
|
|
148281
148303
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
148282
148304
|
if (!latestDir) return referenceScripts;
|
|
148283
|
-
for (const file2 of
|
|
148305
|
+
for (const file2 of fs64.readdirSync(latestDir)) {
|
|
148284
148306
|
if (!file2.endsWith(".js")) continue;
|
|
148285
148307
|
try {
|
|
148286
|
-
referenceScripts[file2] =
|
|
148308
|
+
referenceScripts[file2] = fs64.readFileSync(path61.join(latestDir, file2), "utf-8");
|
|
148287
148309
|
} catch {
|
|
148288
148310
|
}
|
|
148289
148311
|
}
|
|
@@ -148392,15 +148414,15 @@ async (params) => {
|
|
|
148392
148414
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
148393
148415
|
const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
148394
148416
|
const tmpDir = path61.join(os34.tmpdir(), "adhdev-autoimpl");
|
|
148395
|
-
if (!
|
|
148417
|
+
if (!fs64.existsSync(tmpDir)) fs64.mkdirSync(tmpDir, { recursive: true });
|
|
148396
148418
|
const promptFile = path61.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
|
|
148397
|
-
|
|
148419
|
+
fs64.writeFileSync(promptFile, prompt, "utf-8");
|
|
148398
148420
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
148399
148421
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
148400
148422
|
const spawn7 = agentProvider?.spawn;
|
|
148401
148423
|
if (!spawn7?.command) {
|
|
148402
148424
|
try {
|
|
148403
|
-
|
|
148425
|
+
fs64.unlinkSync(promptFile);
|
|
148404
148426
|
} catch {
|
|
148405
148427
|
}
|
|
148406
148428
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -148503,7 +148525,7 @@ async (params) => {
|
|
|
148503
148525
|
} catch {
|
|
148504
148526
|
}
|
|
148505
148527
|
try {
|
|
148506
|
-
|
|
148528
|
+
fs64.unlinkSync(promptFile);
|
|
148507
148529
|
} catch {
|
|
148508
148530
|
}
|
|
148509
148531
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})`);
|
|
@@ -148727,7 +148749,7 @@ async (params) => {
|
|
|
148727
148749
|
}
|
|
148728
148750
|
});
|
|
148729
148751
|
try {
|
|
148730
|
-
|
|
148752
|
+
fs64.unlinkSync(promptFile);
|
|
148731
148753
|
} catch {
|
|
148732
148754
|
}
|
|
148733
148755
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -148832,10 +148854,10 @@ async (params) => {
|
|
|
148832
148854
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
148833
148855
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
148834
148856
|
lines.push("");
|
|
148835
|
-
for (const file2 of
|
|
148857
|
+
for (const file2 of fs64.readdirSync(latestScriptsDir)) {
|
|
148836
148858
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
148837
148859
|
try {
|
|
148838
|
-
const content =
|
|
148860
|
+
const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
148839
148861
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
148840
148862
|
lines.push("```javascript");
|
|
148841
148863
|
lines.push(content);
|
|
@@ -148845,14 +148867,14 @@ async (params) => {
|
|
|
148845
148867
|
}
|
|
148846
148868
|
}
|
|
148847
148869
|
}
|
|
148848
|
-
const refFiles =
|
|
148870
|
+
const refFiles = fs64.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
148849
148871
|
if (refFiles.length > 0) {
|
|
148850
148872
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
148851
148873
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
148852
148874
|
lines.push("");
|
|
148853
148875
|
for (const file2 of refFiles) {
|
|
148854
148876
|
try {
|
|
148855
|
-
const content =
|
|
148877
|
+
const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
148856
148878
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
148857
148879
|
lines.push("```javascript");
|
|
148858
148880
|
lines.push(content);
|
|
@@ -148897,7 +148919,7 @@ async (params) => {
|
|
|
148897
148919
|
const loadGuide = (name) => {
|
|
148898
148920
|
try {
|
|
148899
148921
|
const p = path61.join(docsDir, name);
|
|
148900
|
-
if (
|
|
148922
|
+
if (fs64.existsSync(p)) return fs64.readFileSync(p, "utf-8");
|
|
148901
148923
|
} catch {
|
|
148902
148924
|
}
|
|
148903
148925
|
return null;
|
|
@@ -149141,11 +149163,11 @@ async (params) => {
|
|
|
149141
149163
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
149142
149164
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
149143
149165
|
lines.push("");
|
|
149144
|
-
for (const file2 of
|
|
149166
|
+
for (const file2 of fs64.readdirSync(latestScriptsDir)) {
|
|
149145
149167
|
if (!file2.endsWith(".js")) continue;
|
|
149146
149168
|
if (!targetFileNames.has(file2)) continue;
|
|
149147
149169
|
try {
|
|
149148
|
-
const content =
|
|
149170
|
+
const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
149149
149171
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
149150
149172
|
lines.push("```javascript");
|
|
149151
149173
|
lines.push(content);
|
|
@@ -149154,14 +149176,14 @@ async (params) => {
|
|
|
149154
149176
|
} catch {
|
|
149155
149177
|
}
|
|
149156
149178
|
}
|
|
149157
|
-
const refFiles =
|
|
149179
|
+
const refFiles = fs64.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
149158
149180
|
if (refFiles.length > 0) {
|
|
149159
149181
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
149160
149182
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
149161
149183
|
lines.push("");
|
|
149162
149184
|
for (const file2 of refFiles) {
|
|
149163
149185
|
try {
|
|
149164
|
-
const content =
|
|
149186
|
+
const content = fs64.readFileSync(path61.join(latestScriptsDir, file2), "utf-8");
|
|
149165
149187
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
149166
149188
|
lines.push("```javascript");
|
|
149167
149189
|
lines.push(content);
|
|
@@ -149198,7 +149220,7 @@ async (params) => {
|
|
|
149198
149220
|
const loadGuide = (name) => {
|
|
149199
149221
|
try {
|
|
149200
149222
|
const p = path61.join(docsDir, name);
|
|
149201
|
-
if (
|
|
149223
|
+
if (fs64.existsSync(p)) return fs64.readFileSync(p, "utf-8");
|
|
149202
149224
|
} catch {
|
|
149203
149225
|
}
|
|
149204
149226
|
return null;
|
|
@@ -149937,7 +149959,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149937
149959
|
path62.join(process.cwd(), "packages/web-devconsole/dist")
|
|
149938
149960
|
];
|
|
149939
149961
|
for (const dir of candidates) {
|
|
149940
|
-
if (
|
|
149962
|
+
if (fs65.existsSync(path62.join(dir, "index.html"))) return dir;
|
|
149941
149963
|
}
|
|
149942
149964
|
return null;
|
|
149943
149965
|
}
|
|
@@ -149949,7 +149971,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149949
149971
|
}
|
|
149950
149972
|
const htmlPath = path62.join(distDir, "index.html");
|
|
149951
149973
|
try {
|
|
149952
|
-
const html =
|
|
149974
|
+
const html = fs65.readFileSync(htmlPath, "utf-8");
|
|
149953
149975
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
149954
149976
|
res.end(html);
|
|
149955
149977
|
} catch (e) {
|
|
@@ -149979,7 +150001,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
149979
150001
|
return;
|
|
149980
150002
|
}
|
|
149981
150003
|
try {
|
|
149982
|
-
const content =
|
|
150004
|
+
const content = fs65.readFileSync(filePath);
|
|
149983
150005
|
const ext = path62.extname(filePath);
|
|
149984
150006
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
149985
150007
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -150088,14 +150110,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150088
150110
|
const files = [];
|
|
150089
150111
|
const scan = (d, prefix) => {
|
|
150090
150112
|
try {
|
|
150091
|
-
for (const entry of
|
|
150113
|
+
for (const entry of fs65.readdirSync(d, { withFileTypes: true })) {
|
|
150092
150114
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
150093
150115
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
150094
150116
|
if (entry.isDirectory()) {
|
|
150095
150117
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
150096
150118
|
scan(path62.join(d, entry.name), rel);
|
|
150097
150119
|
} else {
|
|
150098
|
-
const stat2 =
|
|
150120
|
+
const stat2 = fs65.statSync(path62.join(d, entry.name));
|
|
150099
150121
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
150100
150122
|
}
|
|
150101
150123
|
}
|
|
@@ -150123,11 +150145,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150123
150145
|
this.json(res, 403, { error: "Forbidden" });
|
|
150124
150146
|
return;
|
|
150125
150147
|
}
|
|
150126
|
-
if (!
|
|
150148
|
+
if (!fs65.existsSync(fullPath) || fs65.statSync(fullPath).isDirectory()) {
|
|
150127
150149
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
150128
150150
|
return;
|
|
150129
150151
|
}
|
|
150130
|
-
const content =
|
|
150152
|
+
const content = fs65.readFileSync(fullPath, "utf-8");
|
|
150131
150153
|
this.json(res, 200, { type: type2, path: filePath, content, lines: content.split("\n").length });
|
|
150132
150154
|
}
|
|
150133
150155
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -150149,9 +150171,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150149
150171
|
return;
|
|
150150
150172
|
}
|
|
150151
150173
|
try {
|
|
150152
|
-
if (
|
|
150153
|
-
|
|
150154
|
-
|
|
150174
|
+
if (fs65.existsSync(fullPath)) fs65.copyFileSync(fullPath, fullPath + ".bak");
|
|
150175
|
+
fs65.mkdirSync(path62.dirname(fullPath), { recursive: true });
|
|
150176
|
+
fs65.writeFileSync(fullPath, content, "utf-8");
|
|
150155
150177
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
150156
150178
|
this.providerLoader.reload();
|
|
150157
150179
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -150168,8 +150190,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150168
150190
|
}
|
|
150169
150191
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
150170
150192
|
const p = path62.join(dir, name);
|
|
150171
|
-
if (
|
|
150172
|
-
const source =
|
|
150193
|
+
if (fs65.existsSync(p)) {
|
|
150194
|
+
const source = fs65.readFileSync(p, "utf-8");
|
|
150173
150195
|
this.json(res, 200, { type: type2, path: p, source, lines: source.split("\n").length });
|
|
150174
150196
|
return;
|
|
150175
150197
|
}
|
|
@@ -150188,11 +150210,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150188
150210
|
this.json(res, 404, { error: `Provider not found: ${type2}` });
|
|
150189
150211
|
return;
|
|
150190
150212
|
}
|
|
150191
|
-
const target =
|
|
150213
|
+
const target = fs65.existsSync(path62.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
150192
150214
|
const targetPath = path62.join(dir, target);
|
|
150193
150215
|
try {
|
|
150194
|
-
if (
|
|
150195
|
-
|
|
150216
|
+
if (fs65.existsSync(targetPath)) fs65.copyFileSync(targetPath, targetPath + ".bak");
|
|
150217
|
+
fs65.writeFileSync(targetPath, source, "utf-8");
|
|
150196
150218
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
150197
150219
|
this.providerLoader.reload();
|
|
150198
150220
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -150338,20 +150360,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150338
150360
|
let targetDir;
|
|
150339
150361
|
targetDir = this.providerLoader.getUserProviderDir(category, type2);
|
|
150340
150362
|
const jsonPath = path62.join(targetDir, "provider.json");
|
|
150341
|
-
if (
|
|
150363
|
+
if (fs65.existsSync(jsonPath)) {
|
|
150342
150364
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
150343
150365
|
return;
|
|
150344
150366
|
}
|
|
150345
150367
|
try {
|
|
150346
150368
|
const result = generateFiles(type2, name, category, { cdpPorts, cli, processName, installPath, binary: binary2, extensionId, version: version2, osPaths, processNames });
|
|
150347
|
-
|
|
150348
|
-
|
|
150369
|
+
fs65.mkdirSync(targetDir, { recursive: true });
|
|
150370
|
+
fs65.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
150349
150371
|
const createdFiles = ["provider.json"];
|
|
150350
150372
|
if (result.files) {
|
|
150351
150373
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
150352
150374
|
const fullPath = path62.join(targetDir, relPath);
|
|
150353
|
-
|
|
150354
|
-
|
|
150375
|
+
fs65.mkdirSync(path62.dirname(fullPath), { recursive: true });
|
|
150376
|
+
fs65.writeFileSync(fullPath, content, "utf-8");
|
|
150355
150377
|
createdFiles.push(relPath);
|
|
150356
150378
|
}
|
|
150357
150379
|
}
|
|
@@ -150400,10 +150422,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150400
150422
|
}
|
|
150401
150423
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
150402
150424
|
getLatestScriptVersionDir(scriptsDir) {
|
|
150403
|
-
if (!
|
|
150404
|
-
const versions =
|
|
150425
|
+
if (!fs65.existsSync(scriptsDir)) return null;
|
|
150426
|
+
const versions = fs65.readdirSync(scriptsDir).filter((d) => {
|
|
150405
150427
|
try {
|
|
150406
|
-
return
|
|
150428
|
+
return fs65.statSync(path62.join(scriptsDir, d)).isDirectory();
|
|
150407
150429
|
} catch {
|
|
150408
150430
|
return false;
|
|
150409
150431
|
}
|
|
@@ -150425,13 +150447,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
150425
150447
|
if (!sourceDir) {
|
|
150426
150448
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
150427
150449
|
}
|
|
150428
|
-
if (!
|
|
150429
|
-
|
|
150430
|
-
|
|
150450
|
+
if (!fs65.existsSync(desiredDir)) {
|
|
150451
|
+
fs65.mkdirSync(path62.dirname(desiredDir), { recursive: true });
|
|
150452
|
+
fs65.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
150431
150453
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
150432
150454
|
}
|
|
150433
150455
|
const providerJson = path62.join(desiredDir, "provider.json");
|
|
150434
|
-
if (!
|
|
150456
|
+
if (!fs65.existsSync(providerJson)) {
|
|
150435
150457
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
150436
150458
|
}
|
|
150437
150459
|
return { dir: desiredDir };
|
|
@@ -151240,7 +151262,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151240
151262
|
}
|
|
151241
151263
|
}
|
|
151242
151264
|
var import_child_process14 = require("child_process");
|
|
151243
|
-
var
|
|
151265
|
+
var fs66 = __toESM2(require("fs"));
|
|
151244
151266
|
var os35 = __toESM2(require("os"));
|
|
151245
151267
|
var path63 = __toESM2(require("path"));
|
|
151246
151268
|
var import_session_host_core14 = require_dist();
|
|
@@ -151267,7 +151289,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151267
151289
|
path63.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
151268
151290
|
];
|
|
151269
151291
|
for (const candidate of packagedCandidates) {
|
|
151270
|
-
if (
|
|
151292
|
+
if (fs66.existsSync(candidate)) {
|
|
151271
151293
|
return candidate;
|
|
151272
151294
|
}
|
|
151273
151295
|
}
|
|
@@ -151287,8 +151309,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151287
151309
|
function getPid() {
|
|
151288
151310
|
try {
|
|
151289
151311
|
const pidFile = getPidFile();
|
|
151290
|
-
if (!
|
|
151291
|
-
const pid = Number.parseInt(
|
|
151312
|
+
if (!fs66.existsSync(pidFile)) return null;
|
|
151313
|
+
const pid = Number.parseInt(fs66.readFileSync(pidFile, "utf8").trim(), 10);
|
|
151292
151314
|
return Number.isFinite(pid) ? pid : null;
|
|
151293
151315
|
} catch {
|
|
151294
151316
|
return null;
|
|
@@ -151338,7 +151360,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151338
151360
|
if (markerIndex === -1) return;
|
|
151339
151361
|
const activePrefix = entry.slice(0, markerIndex);
|
|
151340
151362
|
const candidates = resolveConptyPrebuildCandidates(activePrefix);
|
|
151341
|
-
const found = candidates.find((candidate) =>
|
|
151363
|
+
const found = candidates.find((candidate) => fs66.existsSync(candidate));
|
|
151342
151364
|
if (!found) {
|
|
151343
151365
|
throw new Error(
|
|
151344
151366
|
`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.`
|
|
@@ -151355,8 +151377,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151355
151377
|
let logFd = null;
|
|
151356
151378
|
if (options.spawnStdio === "logfile") {
|
|
151357
151379
|
const logDir = path63.join(instance().configDir, "logs");
|
|
151358
|
-
|
|
151359
|
-
logFd =
|
|
151380
|
+
fs66.mkdirSync(logDir, { recursive: true });
|
|
151381
|
+
logFd = fs66.openSync(path63.join(logDir, "session-host.log"), "a");
|
|
151360
151382
|
stdio = ["ignore", logFd, logFd];
|
|
151361
151383
|
}
|
|
151362
151384
|
const child = (0, import_child_process14.spawn)(nodeExecutable, [entry], {
|
|
@@ -151381,7 +151403,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151381
151403
|
if (typeof child?.unref === "function") child.unref();
|
|
151382
151404
|
if (logFd !== null) {
|
|
151383
151405
|
try {
|
|
151384
|
-
|
|
151406
|
+
fs66.closeSync(logFd);
|
|
151385
151407
|
} catch {
|
|
151386
151408
|
}
|
|
151387
151409
|
}
|
|
@@ -151399,8 +151421,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151399
151421
|
const pidFile = getPidFile();
|
|
151400
151422
|
let keepPidFile = false;
|
|
151401
151423
|
try {
|
|
151402
|
-
if (
|
|
151403
|
-
const pid = Number.parseInt(
|
|
151424
|
+
if (fs66.existsSync(pidFile)) {
|
|
151425
|
+
const pid = Number.parseInt(fs66.readFileSync(pidFile, "utf8").trim(), 10);
|
|
151404
151426
|
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
151405
151427
|
const managed = isManagedPid(pid);
|
|
151406
151428
|
if (managed) {
|
|
@@ -151420,7 +151442,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151420
151442
|
} finally {
|
|
151421
151443
|
if (!keepPidFile) {
|
|
151422
151444
|
try {
|
|
151423
|
-
|
|
151445
|
+
fs66.unlinkSync(pidFile);
|
|
151424
151446
|
} catch {
|
|
151425
151447
|
}
|
|
151426
151448
|
}
|
|
@@ -151456,7 +151478,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151456
151478
|
}
|
|
151457
151479
|
if (!reported) return;
|
|
151458
151480
|
if (pathsEquivalent(reported, currentEntry)) return;
|
|
151459
|
-
const reportedExists =
|
|
151481
|
+
const reportedExists = fs66.existsSync(reported);
|
|
151460
151482
|
LOG2.warn(
|
|
151461
151483
|
"SessionHost",
|
|
151462
151484
|
`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.`
|
|
@@ -151684,8 +151706,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151684
151706
|
const res = await fetch(extension.vsixUrl);
|
|
151685
151707
|
if (res.ok) {
|
|
151686
151708
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
151687
|
-
const
|
|
151688
|
-
|
|
151709
|
+
const fs68 = await import("fs");
|
|
151710
|
+
fs68.writeFileSync(vsixPath, buffer);
|
|
151689
151711
|
return new Promise((resolve32) => {
|
|
151690
151712
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
151691
151713
|
(0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -151749,6 +151771,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151749
151771
|
}
|
|
151750
151772
|
init_cli_detector();
|
|
151751
151773
|
init_build_info();
|
|
151774
|
+
init_transcript_publisher();
|
|
151752
151775
|
var SessionRegistry = class {
|
|
151753
151776
|
bySessionId = /* @__PURE__ */ new Map();
|
|
151754
151777
|
byManagerKey = /* @__PURE__ */ new Map();
|
|
@@ -151761,6 +151784,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151761
151784
|
target = { ...target, providerSessionId: priorProviderSessionId };
|
|
151762
151785
|
}
|
|
151763
151786
|
this.bySessionId.set(target.sessionId, target);
|
|
151787
|
+
startTranscriptStatPolling(target.sessionId);
|
|
151764
151788
|
if (target.cdpManagerKey) this.addIndex(this.byManagerKey, target.cdpManagerKey, target.sessionId);
|
|
151765
151789
|
if (target.instanceKey) this.addIndex(this.byInstanceKey, target.instanceKey, target.sessionId);
|
|
151766
151790
|
if (target.parentSessionId) this.addIndex(this.byParentSessionId, target.parentSessionId, target.sessionId);
|
|
@@ -151790,6 +151814,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
151790
151814
|
const target = this.bySessionId.get(sessionId);
|
|
151791
151815
|
if (!target) return;
|
|
151792
151816
|
this.bySessionId.delete(sessionId);
|
|
151817
|
+
stopTranscriptStatPolling(sessionId);
|
|
151793
151818
|
if (target.cdpManagerKey) this.removeIndex(this.byManagerKey, target.cdpManagerKey, sessionId);
|
|
151794
151819
|
if (target.instanceKey) this.removeIndex(this.byInstanceKey, target.instanceKey, sessionId);
|
|
151795
151820
|
if (target.parentSessionId) this.removeIndex(this.byParentSessionId, target.parentSessionId, sessionId);
|
|
@@ -154034,6 +154059,18 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
154034
154059
|
// `settle()` publishes it right after this pull returns.
|
|
154035
154060
|
// Returning null here is therefore correct, not "nothing to
|
|
154036
154061
|
// do" — see transcript-publisher.ts's `settle()`.
|
|
154062
|
+
resolveSourcePath: (sessionId) => {
|
|
154063
|
+
const session = sessionRegistry.get(sessionId);
|
|
154064
|
+
if (!session) return null;
|
|
154065
|
+
const provider = providerLoader.getMeta(session.providerType);
|
|
154066
|
+
const nh = provider?.nativeHistory;
|
|
154067
|
+
if (!nh?.source) return null;
|
|
154068
|
+
return resolveJsonlSourcePath(nh.source, {
|
|
154069
|
+
workspace: session.workspace,
|
|
154070
|
+
providerSessionId: session.providerSessionId,
|
|
154071
|
+
sessionStartedAtMs: session.spawnedAtMs
|
|
154072
|
+
});
|
|
154073
|
+
},
|
|
154037
154074
|
collectObservation: async (sessionId) => {
|
|
154038
154075
|
try {
|
|
154039
154076
|
await commandHandler.handle("read_chat", { targetSessionId: sessionId });
|
|
@@ -154494,7 +154531,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
154494
154531
|
Object.values(V1_PRIMITIVE_CATALOG).flat()
|
|
154495
154532
|
);
|
|
154496
154533
|
var V1_CONTRACT_VERSION = "1.0.0";
|
|
154497
|
-
var
|
|
154534
|
+
var fs67 = __toESM2(require("fs"));
|
|
154498
154535
|
var import_chalk2 = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
154499
154536
|
init_dist();
|
|
154500
154537
|
var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
|
|
@@ -154649,7 +154686,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
154649
154686
|
console.log(import_chalk2.default.gray(` Backup: ${status.paths.backupFile}`));
|
|
154650
154687
|
let snapshotMtimeMs = null;
|
|
154651
154688
|
try {
|
|
154652
|
-
snapshotMtimeMs =
|
|
154689
|
+
snapshotMtimeMs = fs67.statSync(status.paths.snapshotFile).mtimeMs;
|
|
154653
154690
|
} catch {
|
|
154654
154691
|
}
|
|
154655
154692
|
console.log(import_chalk2.default.gray(
|