@adhdev/daemon-standalone 0.9.82-rc.540 → 0.9.82-rc.542
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 +750 -591
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -30208,10 +30208,10 @@ var require_dist3 = __commonJS({
|
|
|
30208
30208
|
}
|
|
30209
30209
|
function getDaemonBuildInfo() {
|
|
30210
30210
|
if (cached2) return cached2;
|
|
30211
|
-
const commit = readInjected(true ? "
|
|
30212
|
-
const commitShort = readInjected(true ? "
|
|
30213
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30214
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
30211
|
+
const commit = readInjected(true ? "eb1fb961d4f22983420fad4c65b982d3ab42b5cf" : void 0) ?? "unknown";
|
|
30212
|
+
const commitShort = readInjected(true ? "eb1fb961" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30213
|
+
const version2 = readInjected(true ? "0.9.82-rc.542" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30214
|
+
const builtAt = readInjected(true ? "2026-07-16T06:30:45.651Z" : void 0);
|
|
30215
30215
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30216
30216
|
return cached2;
|
|
30217
30217
|
}
|
|
@@ -33881,7 +33881,8 @@ ${rules.join("\n")}`;
|
|
|
33881
33881
|
- **Coordinator runtime is not a delegation default.** This coordinator is running as \`${coordinatorCliType}\`, but delegated node sessions must follow the user's requested provider, not the coordinator's own runtime.` : "";
|
|
33882
33882
|
return `## Rules
|
|
33883
33883
|
|
|
33884
|
-
- **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean.
|
|
33884
|
+
- **Route, don't implement.** Delegate all code reading, analysis, and execution to node agents. Never read source files or run commands in the coordinator \u2014 keep context lean. See also: **Never use local sub-agents** below.
|
|
33885
|
+
- **Never use local sub-agents.** Do NOT spawn your runtime's own sub-agents (e.g. Claude Code's Task/Explore/Agent tools, or any equivalent in-process agent-spawning tool) to read code, investigate, run RCA, or implement. Such sub-agents execute on the coordinator's machine, outside the mesh \u2014 they escape mesh parallelism, the ledger/audit trail, node capability profiles, and worktree isolation, and leave no \`mesh_task_history\` record. ALL code reading, analysis, RCA, and implementation must be delegated to mesh nodes via \`mesh_enqueue_task\` / \`mesh_send_task\` (use \`task_mode: "live_debug_readonly"\` for read-only investigation), or cross-verified via \`mesh_magi_review\` for read-only fan-out. The coordinator's own actions are limited to \`mesh_*\` tool orchestration and synthesizing results.
|
|
33885
33886
|
- **Front-load task messages.** Include everything the agent needs (files, problem, expected fix) in \`mesh_enqueue_task\` / \`mesh_send_task\`. Append a structured result request at the end: ask the worker to conclude with a JSON block containing \`status\`, \`changedFiles\`, \`gitStatus\`, \`validationResults\`, \`errors\`, \`nextAction\`. The daemon parses this automatically; you can read it from \`mesh_task_history\`.
|
|
33886
33887
|
- **Reuse idle sessions.** For follow-up, retry, commit/push, or cleanup on the same issue, send only the delta to the existing idle session. Start a fresh session only when: (a) branch/worktree isolation is required, (b) the existing session had a dispatch failure or provider mismatch, (c) the transcript/runtime is contaminated or interrupted, or (d) the user explicitly asks for a different provider/session. Continuation of the same issue in an already-idle session is allowed and preferred \u2014 this rule blocks concurrent unrelated work interleaved into a live (still-generating) session, not sequential same-issue follow-ups.
|
|
33887
33888
|
- **Worktree affinity.** A worktree is a durable per-branch workspace; keep all of a branch's code_change/fix/review work on its worktree node by targeting \`required_tags: ["worktree=<branch>"]\` or \`target_node_id\`. Get the id/branch from the \`mesh_clone_node\` result or a live \`mesh_status\` \u2014 the Configured Nodes snapshot won't list a worktree cloned after launch. Untargeted same-branch follow-ups drift to the base node. Only \`convergence\` (merge/push) runs on the base, never pinned to the worktree.
|
|
@@ -40527,8 +40528,8 @@ ${rendered}`, "utf-8");
|
|
|
40527
40528
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
40528
40529
|
if (!remaining.trim()) {
|
|
40529
40530
|
try {
|
|
40530
|
-
const
|
|
40531
|
-
|
|
40531
|
+
const fs43 = require("fs");
|
|
40532
|
+
fs43.unlinkSync(filePath);
|
|
40532
40533
|
} catch {
|
|
40533
40534
|
}
|
|
40534
40535
|
} else {
|
|
@@ -42548,9 +42549,9 @@ ${rendered}`, "utf-8");
|
|
|
42548
42549
|
for (const ext of exes) {
|
|
42549
42550
|
const fullPath = path11.join(p, trimmed + ext);
|
|
42550
42551
|
try {
|
|
42551
|
-
const
|
|
42552
|
-
if (
|
|
42553
|
-
const stat2 =
|
|
42552
|
+
const fs43 = require("fs");
|
|
42553
|
+
if (fs43.existsSync(fullPath)) {
|
|
42554
|
+
const stat2 = fs43.statSync(fullPath);
|
|
42554
42555
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
42555
42556
|
return fullPath;
|
|
42556
42557
|
}
|
|
@@ -42564,12 +42565,12 @@ ${rendered}`, "utf-8");
|
|
|
42564
42565
|
function isScriptBinary(binaryPath) {
|
|
42565
42566
|
if (!path11.isAbsolute(binaryPath)) return false;
|
|
42566
42567
|
try {
|
|
42567
|
-
const
|
|
42568
|
-
const resolved =
|
|
42568
|
+
const fs43 = require("fs");
|
|
42569
|
+
const resolved = fs43.realpathSync(binaryPath);
|
|
42569
42570
|
const head = Buffer.alloc(8);
|
|
42570
|
-
const fd =
|
|
42571
|
-
|
|
42572
|
-
|
|
42571
|
+
const fd = fs43.openSync(resolved, "r");
|
|
42572
|
+
fs43.readSync(fd, head, 0, 8, 0);
|
|
42573
|
+
fs43.closeSync(fd);
|
|
42573
42574
|
let i = 0;
|
|
42574
42575
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
42575
42576
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -42580,12 +42581,12 @@ ${rendered}`, "utf-8");
|
|
|
42580
42581
|
function looksLikeMachOOrElf(filePath) {
|
|
42581
42582
|
if (!path11.isAbsolute(filePath)) return false;
|
|
42582
42583
|
try {
|
|
42583
|
-
const
|
|
42584
|
-
const resolved =
|
|
42584
|
+
const fs43 = require("fs");
|
|
42585
|
+
const resolved = fs43.realpathSync(filePath);
|
|
42585
42586
|
const buf = Buffer.alloc(8);
|
|
42586
|
-
const fd =
|
|
42587
|
-
|
|
42588
|
-
|
|
42587
|
+
const fd = fs43.openSync(resolved, "r");
|
|
42588
|
+
fs43.readSync(fd, buf, 0, 8, 0);
|
|
42589
|
+
fs43.closeSync(fd);
|
|
42589
42590
|
let i = 0;
|
|
42590
42591
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
42591
42592
|
const b = buf.subarray(i);
|
|
@@ -42873,19 +42874,19 @@ ${rendered}`, "utf-8");
|
|
|
42873
42874
|
return null;
|
|
42874
42875
|
}
|
|
42875
42876
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
42876
|
-
return new Promise((
|
|
42877
|
+
return new Promise((resolve26) => {
|
|
42877
42878
|
const child = (0, import_child_process2.exec)(cmd, {
|
|
42878
42879
|
encoding: "utf-8",
|
|
42879
42880
|
timeout: timeoutMs,
|
|
42880
42881
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
42881
42882
|
}, (err, stdout) => {
|
|
42882
42883
|
if (err || !stdout?.trim()) {
|
|
42883
|
-
|
|
42884
|
+
resolve26(null);
|
|
42884
42885
|
} else {
|
|
42885
|
-
|
|
42886
|
+
resolve26(stdout.trim());
|
|
42886
42887
|
}
|
|
42887
42888
|
});
|
|
42888
|
-
child.on("error", () =>
|
|
42889
|
+
child.on("error", () => resolve26(null));
|
|
42889
42890
|
});
|
|
42890
42891
|
}
|
|
42891
42892
|
async function detectCLIs(providerLoader, options) {
|
|
@@ -43031,7 +43032,7 @@ ${rendered}`, "utf-8");
|
|
|
43031
43032
|
});
|
|
43032
43033
|
function awaitWithWarmupDeadline(work, opts) {
|
|
43033
43034
|
const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
|
|
43034
|
-
return new Promise((
|
|
43035
|
+
return new Promise((resolve26, reject) => {
|
|
43035
43036
|
let done = false;
|
|
43036
43037
|
let poll;
|
|
43037
43038
|
let responseTimer;
|
|
@@ -43081,7 +43082,7 @@ ${rendered}`, "utf-8");
|
|
|
43081
43082
|
if (typeof poll.unref === "function") poll.unref();
|
|
43082
43083
|
}
|
|
43083
43084
|
work.then(
|
|
43084
|
-
(val) => settle(() =>
|
|
43085
|
+
(val) => settle(() => resolve26(val)),
|
|
43085
43086
|
(err) => settle(() => reject(err))
|
|
43086
43087
|
);
|
|
43087
43088
|
});
|
|
@@ -44171,7 +44172,7 @@ ${rendered}`, "utf-8");
|
|
|
44171
44172
|
const connection = args.getConnection?.(args.daemonId);
|
|
44172
44173
|
if (args.getConnection && readMeshConnectionState(connection) !== "connected") break;
|
|
44173
44174
|
if (connection) args.onConnection?.(connection);
|
|
44174
|
-
await new Promise((
|
|
44175
|
+
await new Promise((resolve26) => setTimeout(resolve26, 250 * 2 ** (attempt - 1)));
|
|
44175
44176
|
}
|
|
44176
44177
|
try {
|
|
44177
44178
|
const remoteGit = await probeRemoteMeshGitStatus({
|
|
@@ -45957,7 +45958,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
45957
45958
|
const deadline = Date.now() + LOCAL_LAUNCH_READY_TIMEOUT_MS;
|
|
45958
45959
|
while (Date.now() < deadline) {
|
|
45959
45960
|
if (adapter.isReady() || adapter.currentStatus === "idle") return;
|
|
45960
|
-
await new Promise((
|
|
45961
|
+
await new Promise((resolve26) => setTimeout(resolve26, LOCAL_LAUNCH_READY_POLL_MS));
|
|
45961
45962
|
}
|
|
45962
45963
|
LOG2.warn("MeshQueue", `Auto-launched session ${sessionId} not interactive after ${LOCAL_LAUNCH_READY_TIMEOUT_MS}ms; dispatching anyway (adapter queue-until-ready will buffer)`);
|
|
45963
45964
|
}
|
|
@@ -49473,8 +49474,12 @@ ${cleanBody}`;
|
|
|
49473
49474
|
settings: state.settings,
|
|
49474
49475
|
...coordinator && { coordinator },
|
|
49475
49476
|
...meshQueueStats && { meshQueueStats },
|
|
49476
|
-
|
|
49477
|
-
|
|
49477
|
+
// Emit these booleans explicitly (including false) so an un-hide/un-mute clears a
|
|
49478
|
+
// previously-true value downstream. Consumers merge with `?? existing` and copy only
|
|
49479
|
+
// `!== undefined` fields, so an absent field on false never overwrote a prior true —
|
|
49480
|
+
// the toggle-off direction silently stuck. See session-entry-merge.ts.
|
|
49481
|
+
surfaceHidden: resolveSurfaceHidden(state.settings),
|
|
49482
|
+
muted: resolveMuted(state.settings)
|
|
49478
49483
|
};
|
|
49479
49484
|
}
|
|
49480
49485
|
function buildAcpSession(state, options) {
|
|
@@ -49515,8 +49520,10 @@ ${cleanBody}`;
|
|
|
49515
49520
|
settings: state.settings,
|
|
49516
49521
|
...coordinator && { coordinator },
|
|
49517
49522
|
...meshQueueStats && { meshQueueStats },
|
|
49518
|
-
|
|
49519
|
-
|
|
49523
|
+
// Emit explicitly (including false) so un-hide/un-mute clears a prior true downstream —
|
|
49524
|
+
// see buildCliSession above and session-entry-merge.ts.
|
|
49525
|
+
surfaceHidden: resolveSurfaceHidden(state.settings),
|
|
49526
|
+
muted: resolveMuted(state.settings)
|
|
49520
49527
|
};
|
|
49521
49528
|
}
|
|
49522
49529
|
function buildSessionEntries(allStates, cdpManagers, options = {}) {
|
|
@@ -53673,13 +53680,13 @@ ${cleanBody}`;
|
|
|
53673
53680
|
}
|
|
53674
53681
|
function ensureAdhdevDir() {
|
|
53675
53682
|
const d = adhdevDir();
|
|
53676
|
-
if (!
|
|
53683
|
+
if (!fs11.existsSync(d)) fs11.mkdirSync(d, { recursive: true });
|
|
53677
53684
|
}
|
|
53678
53685
|
function loadExternalSources() {
|
|
53679
53686
|
const p = sourcesFilePath();
|
|
53680
|
-
if (!
|
|
53687
|
+
if (!fs11.existsSync(p)) return { schema: 1, sources: [] };
|
|
53681
53688
|
try {
|
|
53682
|
-
const raw = JSON.parse(
|
|
53689
|
+
const raw = JSON.parse(fs11.readFileSync(p, "utf-8"));
|
|
53683
53690
|
if (!raw || typeof raw !== "object") return { schema: 1, sources: [] };
|
|
53684
53691
|
const sources = Array.isArray(raw.sources) ? raw.sources.filter(isValidSource) : [];
|
|
53685
53692
|
return { schema: 1, sources };
|
|
@@ -53690,14 +53697,14 @@ ${cleanBody}`;
|
|
|
53690
53697
|
function saveExternalSources(file2) {
|
|
53691
53698
|
ensureAdhdevDir();
|
|
53692
53699
|
const tmp = sourcesFilePath() + ".tmp";
|
|
53693
|
-
|
|
53694
|
-
|
|
53700
|
+
fs11.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
|
|
53701
|
+
fs11.renameSync(tmp, sourcesFilePath());
|
|
53695
53702
|
}
|
|
53696
53703
|
function loadProvidersActive() {
|
|
53697
53704
|
const p = activeFilePath();
|
|
53698
|
-
if (!
|
|
53705
|
+
if (!fs11.existsSync(p)) return { schema: 1, active: {} };
|
|
53699
53706
|
try {
|
|
53700
|
-
const raw = JSON.parse(
|
|
53707
|
+
const raw = JSON.parse(fs11.readFileSync(p, "utf-8"));
|
|
53701
53708
|
if (!raw || typeof raw !== "object") return { schema: 1, active: {} };
|
|
53702
53709
|
const active = raw.active && typeof raw.active === "object" ? raw.active : {};
|
|
53703
53710
|
return { schema: 1, active };
|
|
@@ -53708,8 +53715,8 @@ ${cleanBody}`;
|
|
|
53708
53715
|
function saveProvidersActive(file2) {
|
|
53709
53716
|
ensureAdhdevDir();
|
|
53710
53717
|
const tmp = activeFilePath() + ".tmp";
|
|
53711
|
-
|
|
53712
|
-
|
|
53718
|
+
fs11.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
|
|
53719
|
+
fs11.renameSync(tmp, activeFilePath());
|
|
53713
53720
|
}
|
|
53714
53721
|
function isValidSource(x) {
|
|
53715
53722
|
if (!x || typeof x !== "object") return false;
|
|
@@ -53725,11 +53732,11 @@ ${cleanBody}`;
|
|
|
53725
53732
|
}
|
|
53726
53733
|
function inventoryExternalSources() {
|
|
53727
53734
|
const root = externalRoot();
|
|
53728
|
-
if (!
|
|
53735
|
+
if (!fs11.existsSync(root)) return [];
|
|
53729
53736
|
const out = [];
|
|
53730
53737
|
let entries;
|
|
53731
53738
|
try {
|
|
53732
|
-
entries =
|
|
53739
|
+
entries = fs11.readdirSync(root, { withFileTypes: true });
|
|
53733
53740
|
} catch {
|
|
53734
53741
|
return [];
|
|
53735
53742
|
}
|
|
@@ -53740,7 +53747,7 @@ ${cleanBody}`;
|
|
|
53740
53747
|
const providers = {};
|
|
53741
53748
|
let categoryEntries;
|
|
53742
53749
|
try {
|
|
53743
|
-
categoryEntries =
|
|
53750
|
+
categoryEntries = fs11.readdirSync(sourceDir, { withFileTypes: true });
|
|
53744
53751
|
} catch {
|
|
53745
53752
|
continue;
|
|
53746
53753
|
}
|
|
@@ -53750,7 +53757,7 @@ ${cleanBody}`;
|
|
|
53750
53757
|
const categoryDir = path19.join(sourceDir, category);
|
|
53751
53758
|
let typeEntries;
|
|
53752
53759
|
try {
|
|
53753
|
-
typeEntries =
|
|
53760
|
+
typeEntries = fs11.readdirSync(categoryDir, { withFileTypes: true });
|
|
53754
53761
|
} catch {
|
|
53755
53762
|
continue;
|
|
53756
53763
|
}
|
|
@@ -53758,8 +53765,8 @@ ${cleanBody}`;
|
|
|
53758
53765
|
for (const typeEntry of typeEntries) {
|
|
53759
53766
|
if (!typeEntry.isDirectory()) continue;
|
|
53760
53767
|
const typeDir = path19.join(categoryDir, typeEntry.name);
|
|
53761
|
-
const hasV1 =
|
|
53762
|
-
const hasV0 =
|
|
53768
|
+
const hasV1 = fs11.existsSync(path19.join(typeDir, "provider.v1.json"));
|
|
53769
|
+
const hasV0 = fs11.existsSync(path19.join(typeDir, "provider.json"));
|
|
53763
53770
|
if (hasV1 || hasV0) types.push(typeEntry.name);
|
|
53764
53771
|
}
|
|
53765
53772
|
if (types.length > 0) providers[category] = types;
|
|
@@ -53782,7 +53789,7 @@ ${cleanBody}`;
|
|
|
53782
53789
|
}
|
|
53783
53790
|
return { source: candidates[0], ambiguous: true, candidates };
|
|
53784
53791
|
}
|
|
53785
|
-
var
|
|
53792
|
+
var fs11;
|
|
53786
53793
|
var os12;
|
|
53787
53794
|
var path19;
|
|
53788
53795
|
var SOURCES_FILENAME;
|
|
@@ -53790,7 +53797,7 @@ ${cleanBody}`;
|
|
|
53790
53797
|
var init_external_sources = __esm2({
|
|
53791
53798
|
"src/providers/external-sources.ts"() {
|
|
53792
53799
|
"use strict";
|
|
53793
|
-
|
|
53800
|
+
fs11 = __toESM2(require("fs"));
|
|
53794
53801
|
os12 = __toESM2(require("os"));
|
|
53795
53802
|
path19 = __toESM2(require("path"));
|
|
53796
53803
|
SOURCES_FILENAME = "providers-sources.json";
|
|
@@ -53838,7 +53845,7 @@ ${cleanBody}`;
|
|
|
53838
53845
|
function loadFsmSpec(sourcePath) {
|
|
53839
53846
|
let raw;
|
|
53840
53847
|
try {
|
|
53841
|
-
raw = JSON.parse(
|
|
53848
|
+
raw = JSON.parse(fs12.readFileSync(sourcePath, "utf8"));
|
|
53842
53849
|
} catch (err) {
|
|
53843
53850
|
return { ok: false, errors: [`Failed to read/parse spec: ${err.message}`], sourcePath };
|
|
53844
53851
|
}
|
|
@@ -53958,11 +53965,11 @@ ${cleanBody}`;
|
|
|
53958
53965
|
errs.push(`${path45} is not a recognized condition`);
|
|
53959
53966
|
return errs;
|
|
53960
53967
|
}
|
|
53961
|
-
var
|
|
53968
|
+
var fs12;
|
|
53962
53969
|
var init_fsm_loader = __esm2({
|
|
53963
53970
|
"src/providers/spec/fsm-loader.ts"() {
|
|
53964
53971
|
"use strict";
|
|
53965
|
-
|
|
53972
|
+
fs12 = __toESM2(require("fs"));
|
|
53966
53973
|
init_fsm_types();
|
|
53967
53974
|
}
|
|
53968
53975
|
});
|
|
@@ -54451,8 +54458,8 @@ ${cleanBody}`;
|
|
|
54451
54458
|
let cwd = options.cwd;
|
|
54452
54459
|
if (cwd) {
|
|
54453
54460
|
try {
|
|
54454
|
-
const
|
|
54455
|
-
const stat2 =
|
|
54461
|
+
const fs43 = require("fs");
|
|
54462
|
+
const stat2 = fs43.statSync(cwd);
|
|
54456
54463
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
54457
54464
|
} catch {
|
|
54458
54465
|
cwd = os14.homedir();
|
|
@@ -55437,6 +55444,7 @@ ${cont}` : cont;
|
|
|
55437
55444
|
var APPROVAL_EXIT_TIMEOUT_MS;
|
|
55438
55445
|
var IDLE_CONFIRMATION_GRACE_MS;
|
|
55439
55446
|
var APPROVAL_RESUME_IDLE_DEFER_CAP_MS;
|
|
55447
|
+
var SCREEN_QUIET_IDLE_MS;
|
|
55440
55448
|
var CliStateEngine;
|
|
55441
55449
|
var init_cli_state_engine = __esm2({
|
|
55442
55450
|
"src/cli-adapters/cli-state-engine.ts"() {
|
|
@@ -55451,6 +55459,7 @@ ${cont}` : cont;
|
|
|
55451
55459
|
APPROVAL_EXIT_TIMEOUT_MS = 6e4;
|
|
55452
55460
|
IDLE_CONFIRMATION_GRACE_MS = 2e3;
|
|
55453
55461
|
APPROVAL_RESUME_IDLE_DEFER_CAP_MS = 18e3;
|
|
55462
|
+
SCREEN_QUIET_IDLE_MS = 5e3;
|
|
55454
55463
|
CliStateEngine = class {
|
|
55455
55464
|
constructor(provider, runner, transport, callbacks, timeouts) {
|
|
55456
55465
|
this.provider = provider;
|
|
@@ -56015,6 +56024,10 @@ ${cont}` : cont;
|
|
|
56015
56024
|
this.idleTimeout = setTimeout(() => {
|
|
56016
56025
|
if (this.isWaitingForResponse && !this.hasActionableApproval()) {
|
|
56017
56026
|
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
56027
|
+
if (!this.hasScreenBeenQuietForIdle(Date.now())) {
|
|
56028
|
+
this.evaluateSettled(this.transport.getSnapshot());
|
|
56029
|
+
return;
|
|
56030
|
+
}
|
|
56018
56031
|
this.finishResponse();
|
|
56019
56032
|
}
|
|
56020
56033
|
}, this.timeouts.generatingIdle);
|
|
@@ -56037,6 +56050,10 @@ ${cont}` : cont;
|
|
|
56037
56050
|
this.idleTimeout = setTimeout(() => {
|
|
56038
56051
|
if (this.isWaitingForResponse && !this.hasActionableApproval()) {
|
|
56039
56052
|
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
56053
|
+
if (!this.hasScreenBeenQuietForIdle(Date.now())) {
|
|
56054
|
+
this.evaluateSettled(this.transport.getSnapshot());
|
|
56055
|
+
return;
|
|
56056
|
+
}
|
|
56040
56057
|
this.finishResponse();
|
|
56041
56058
|
}
|
|
56042
56059
|
}, this.timeouts.generatingIdle);
|
|
@@ -56105,6 +56122,10 @@ ${cont}` : cont;
|
|
|
56105
56122
|
this.idleTimeout = setTimeout(() => {
|
|
56106
56123
|
if (this.isWaitingForResponse) {
|
|
56107
56124
|
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
56125
|
+
if (!this.hasScreenBeenQuietForIdle(Date.now())) {
|
|
56126
|
+
this.evaluateSettled(this.transport.getSnapshot());
|
|
56127
|
+
return;
|
|
56128
|
+
}
|
|
56108
56129
|
this.finishResponse();
|
|
56109
56130
|
}
|
|
56110
56131
|
}, this.timeouts.generatingIdle);
|
|
@@ -56190,7 +56211,8 @@ ${cont}` : cont;
|
|
|
56190
56211
|
const assistantLength = lastParsedAssistant?.content?.length || 0;
|
|
56191
56212
|
const idleFinishConfirmMs = this.timeouts.idleFinishConfirm;
|
|
56192
56213
|
const idleQuietThresholdMs = Math.max(idleFinishConfirmMs, this.timeouts.outputSettle);
|
|
56193
|
-
const
|
|
56214
|
+
const screenQuietForIdle = screenStableMs >= SCREEN_QUIET_IDLE_MS;
|
|
56215
|
+
const idleReady = !modal && hasAssistantTurn && quietForMs >= idleQuietThresholdMs && screenStableMs >= idleFinishConfirmMs && screenQuietForIdle;
|
|
56194
56216
|
const candidate = this.idleFinishCandidate;
|
|
56195
56217
|
const candidateQuiet = !!candidate && candidate.responseEpoch === this.responseEpoch && candidate.lastOutputAt === snap.lastOutputAt && candidate.lastScreenChangeAt === snap.lastScreenChangeAt && assistantLength >= candidate.assistantLength && now - candidate.armedAt >= idleFinishConfirmMs;
|
|
56196
56218
|
if (this.shouldDeferIdleForApprovalResume(now)) {
|
|
@@ -56225,6 +56247,13 @@ ${cont}` : cont;
|
|
|
56225
56247
|
return;
|
|
56226
56248
|
}
|
|
56227
56249
|
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
56250
|
+
if (!this.hasScreenBeenQuietForIdle(Date.now())) {
|
|
56251
|
+
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
56252
|
+
this.idleTimeout = setTimeout(() => {
|
|
56253
|
+
if (this.isWaitingForResponse) this.evaluateSettled(this.transport.getSnapshot());
|
|
56254
|
+
}, this.timeouts.idleFinish);
|
|
56255
|
+
return;
|
|
56256
|
+
}
|
|
56228
56257
|
const parsed = this.runParseSession(this.transport.getSnapshot());
|
|
56229
56258
|
if (this.shouldDeferFinishForTranscript(parsed)) {
|
|
56230
56259
|
this.rescheduleTranscriptFinishCheck("transcript_idle_timeout_not_final");
|
|
@@ -56235,6 +56264,22 @@ ${cont}` : cont;
|
|
|
56235
56264
|
}
|
|
56236
56265
|
}, this.timeouts.idleFinish);
|
|
56237
56266
|
}
|
|
56267
|
+
/**
|
|
56268
|
+
* FALSE-IDLE (screen-quiet gate): has the visible terminal screen content been
|
|
56269
|
+
* byte-identical for at least SCREEN_QUIET_IDLE_MS continuously?
|
|
56270
|
+
*
|
|
56271
|
+
* `lastScreenChangeAt` is bumped by the adapter every time the normalized screen
|
|
56272
|
+
* snapshot changes (spinner frame, streaming command output, etc.), so
|
|
56273
|
+
* `now - lastScreenChangeAt` is the real screen-diff quiet age. Reads the LIVE
|
|
56274
|
+
* transport snapshot so the deferred idleFinish timeout re-checks current screen
|
|
56275
|
+
* state, not the stale snapshot from when the timer was armed. A never-changed
|
|
56276
|
+
* screen (lastScreenChangeAt === 0) is treated as quiet.
|
|
56277
|
+
*/
|
|
56278
|
+
hasScreenBeenQuietForIdle(now) {
|
|
56279
|
+
const lastChange = this.transport.getSnapshot().lastScreenChangeAt;
|
|
56280
|
+
if (!lastChange) return true;
|
|
56281
|
+
return now - lastChange >= SCREEN_QUIET_IDLE_MS;
|
|
56282
|
+
}
|
|
56238
56283
|
/**
|
|
56239
56284
|
* FALSE-IDLE (Fix 2): should applyIdle suppress the idle/finish for the current
|
|
56240
56285
|
* turn because we are inside the post-approval resume grace?
|
|
@@ -57314,7 +57359,7 @@ ${lastSnapshot}`;
|
|
|
57314
57359
|
`[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
|
|
57315
57360
|
);
|
|
57316
57361
|
}
|
|
57317
|
-
await new Promise((
|
|
57362
|
+
await new Promise((resolve26) => setTimeout(resolve26, 50));
|
|
57318
57363
|
}
|
|
57319
57364
|
const finalScreenText = this.terminalScreen.getText() || "";
|
|
57320
57365
|
LOG2.warn(
|
|
@@ -57681,7 +57726,7 @@ ${lastSnapshot}`;
|
|
|
57681
57726
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
57682
57727
|
await this.ptyProcess.write(chunks[i]);
|
|
57683
57728
|
if (i + 1 < chunks.length) {
|
|
57684
|
-
await new Promise((
|
|
57729
|
+
await new Promise((resolve26) => setTimeout(resolve26, WIN32_PTY_WRITE_CHUNK_GAP_MS));
|
|
57685
57730
|
}
|
|
57686
57731
|
}
|
|
57687
57732
|
}
|
|
@@ -57849,7 +57894,7 @@ ${lastSnapshot}`;
|
|
|
57849
57894
|
this.onStatusChange?.();
|
|
57850
57895
|
}
|
|
57851
57896
|
async waitForForceSubmitSettle() {
|
|
57852
|
-
await new Promise((
|
|
57897
|
+
await new Promise((resolve26) => setTimeout(resolve26, FORCE_SUBMIT_SETTLE_MS));
|
|
57853
57898
|
}
|
|
57854
57899
|
enqueuePendingOutboundMessage(text, reason, meshTaskId) {
|
|
57855
57900
|
const content = String(text || "");
|
|
@@ -57928,7 +57973,7 @@ ${lastSnapshot}`;
|
|
|
57928
57973
|
const deadline = Date.now() + 1e4;
|
|
57929
57974
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
57930
57975
|
this.resolveStartupState("send_wait");
|
|
57931
|
-
await new Promise((
|
|
57976
|
+
await new Promise((resolve26) => setTimeout(resolve26, 50));
|
|
57932
57977
|
}
|
|
57933
57978
|
}
|
|
57934
57979
|
const parsedStatusBeforeSend = !allowInputDuringGeneration ? (() => {
|
|
@@ -58021,13 +58066,13 @@ ${lastSnapshot}`;
|
|
|
58021
58066
|
isFirstTurn: !this.firstTurnSent
|
|
58022
58067
|
};
|
|
58023
58068
|
this.engine.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
|
|
58024
|
-
await new Promise((
|
|
58069
|
+
await new Promise((resolve26, reject) => {
|
|
58025
58070
|
let resolved = false;
|
|
58026
58071
|
const completion = {
|
|
58027
58072
|
resolveOnce: () => {
|
|
58028
58073
|
if (resolved) return;
|
|
58029
58074
|
resolved = true;
|
|
58030
|
-
|
|
58075
|
+
resolve26();
|
|
58031
58076
|
},
|
|
58032
58077
|
rejectOnce: (error48) => {
|
|
58033
58078
|
if (resolved) return;
|
|
@@ -58215,17 +58260,17 @@ ${lastSnapshot}`;
|
|
|
58215
58260
|
}
|
|
58216
58261
|
}
|
|
58217
58262
|
waitForStopped(timeoutMs) {
|
|
58218
|
-
return new Promise((
|
|
58263
|
+
return new Promise((resolve26) => {
|
|
58219
58264
|
const startedAt = Date.now();
|
|
58220
58265
|
const timer = setInterval(() => {
|
|
58221
58266
|
if (!this.ptyProcess || this.engine.currentStatus === "stopped") {
|
|
58222
58267
|
clearInterval(timer);
|
|
58223
|
-
|
|
58268
|
+
resolve26(true);
|
|
58224
58269
|
return;
|
|
58225
58270
|
}
|
|
58226
58271
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
58227
58272
|
clearInterval(timer);
|
|
58228
|
-
|
|
58273
|
+
resolve26(false);
|
|
58229
58274
|
}
|
|
58230
58275
|
}, 100);
|
|
58231
58276
|
});
|
|
@@ -60960,8 +61005,8 @@ ${lastSnapshot}`;
|
|
|
60960
61005
|
if ((0, import_fs15.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
60961
61006
|
}
|
|
60962
61007
|
if (!resolvedCli && appPath && os322 === "win32") {
|
|
60963
|
-
const { dirname:
|
|
60964
|
-
const appDir =
|
|
61008
|
+
const { dirname: dirname18 } = await import("path");
|
|
61009
|
+
const appDir = dirname18(appPath);
|
|
60965
61010
|
const candidates = [
|
|
60966
61011
|
`${appDir}\\\\bin\\\\${def.cli}.cmd`,
|
|
60967
61012
|
`${appDir}\\\\bin\\\\${def.cli}`,
|
|
@@ -61213,7 +61258,7 @@ ${lastSnapshot}`;
|
|
|
61213
61258
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
61214
61259
|
*/
|
|
61215
61260
|
static listAllTargets(port) {
|
|
61216
|
-
return new Promise((
|
|
61261
|
+
return new Promise((resolve26) => {
|
|
61217
61262
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
61218
61263
|
let data = "";
|
|
61219
61264
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -61229,16 +61274,16 @@ ${lastSnapshot}`;
|
|
|
61229
61274
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
61230
61275
|
);
|
|
61231
61276
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
61232
|
-
|
|
61277
|
+
resolve26(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
61233
61278
|
} catch {
|
|
61234
|
-
|
|
61279
|
+
resolve26([]);
|
|
61235
61280
|
}
|
|
61236
61281
|
});
|
|
61237
61282
|
});
|
|
61238
|
-
req.on("error", () =>
|
|
61283
|
+
req.on("error", () => resolve26([]));
|
|
61239
61284
|
req.setTimeout(2e3, () => {
|
|
61240
61285
|
req.destroy();
|
|
61241
|
-
|
|
61286
|
+
resolve26([]);
|
|
61242
61287
|
});
|
|
61243
61288
|
});
|
|
61244
61289
|
}
|
|
@@ -61278,7 +61323,7 @@ ${lastSnapshot}`;
|
|
|
61278
61323
|
}
|
|
61279
61324
|
}
|
|
61280
61325
|
findTargetOnPort(port) {
|
|
61281
|
-
return new Promise((
|
|
61326
|
+
return new Promise((resolve26) => {
|
|
61282
61327
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
61283
61328
|
let data = "";
|
|
61284
61329
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -61289,7 +61334,7 @@ ${lastSnapshot}`;
|
|
|
61289
61334
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
61290
61335
|
);
|
|
61291
61336
|
if (pages.length === 0) {
|
|
61292
|
-
|
|
61337
|
+
resolve26(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
61293
61338
|
return;
|
|
61294
61339
|
}
|
|
61295
61340
|
const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -61308,25 +61353,25 @@ ${lastSnapshot}`;
|
|
|
61308
61353
|
this._targetId = selected.target.id;
|
|
61309
61354
|
}
|
|
61310
61355
|
this._pageTitle = selected.target.title || "";
|
|
61311
|
-
|
|
61356
|
+
resolve26(selected.target);
|
|
61312
61357
|
return;
|
|
61313
61358
|
}
|
|
61314
61359
|
if (previousTargetId) {
|
|
61315
61360
|
this.log(`[CDP] Target ${previousTargetId} not found in page list`);
|
|
61316
|
-
|
|
61361
|
+
resolve26(null);
|
|
61317
61362
|
return;
|
|
61318
61363
|
}
|
|
61319
61364
|
this._pageTitle = list[0]?.title || "";
|
|
61320
|
-
|
|
61365
|
+
resolve26(list[0]);
|
|
61321
61366
|
} catch {
|
|
61322
|
-
|
|
61367
|
+
resolve26(null);
|
|
61323
61368
|
}
|
|
61324
61369
|
});
|
|
61325
61370
|
});
|
|
61326
|
-
req.on("error", () =>
|
|
61371
|
+
req.on("error", () => resolve26(null));
|
|
61327
61372
|
req.setTimeout(2e3, () => {
|
|
61328
61373
|
req.destroy();
|
|
61329
|
-
|
|
61374
|
+
resolve26(null);
|
|
61330
61375
|
});
|
|
61331
61376
|
});
|
|
61332
61377
|
}
|
|
@@ -61337,7 +61382,7 @@ ${lastSnapshot}`;
|
|
|
61337
61382
|
this.extensionProviders = providers;
|
|
61338
61383
|
}
|
|
61339
61384
|
connectToTarget(wsUrl) {
|
|
61340
|
-
return new Promise((
|
|
61385
|
+
return new Promise((resolve26) => {
|
|
61341
61386
|
this.ws = new import_ws2.default(wsUrl);
|
|
61342
61387
|
this.ws.on("open", async () => {
|
|
61343
61388
|
this._connected = true;
|
|
@@ -61347,17 +61392,17 @@ ${lastSnapshot}`;
|
|
|
61347
61392
|
}
|
|
61348
61393
|
this.connectBrowserWs().catch(() => {
|
|
61349
61394
|
});
|
|
61350
|
-
|
|
61395
|
+
resolve26(true);
|
|
61351
61396
|
});
|
|
61352
61397
|
this.ws.on("message", (data) => {
|
|
61353
61398
|
try {
|
|
61354
61399
|
const msg = JSON.parse(data.toString());
|
|
61355
61400
|
if (msg.id && this.pending.has(msg.id)) {
|
|
61356
|
-
const { resolve:
|
|
61401
|
+
const { resolve: resolve27, reject } = this.pending.get(msg.id);
|
|
61357
61402
|
this.pending.delete(msg.id);
|
|
61358
61403
|
this.failureCount = 0;
|
|
61359
61404
|
if (msg.error) reject(new Error(msg.error.message));
|
|
61360
|
-
else
|
|
61405
|
+
else resolve27(msg.result);
|
|
61361
61406
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
61362
61407
|
this.contexts.add(msg.params.context.id);
|
|
61363
61408
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -61380,7 +61425,7 @@ ${lastSnapshot}`;
|
|
|
61380
61425
|
this.ws.on("error", (err) => {
|
|
61381
61426
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
61382
61427
|
this._connected = false;
|
|
61383
|
-
|
|
61428
|
+
resolve26(false);
|
|
61384
61429
|
});
|
|
61385
61430
|
});
|
|
61386
61431
|
}
|
|
@@ -61394,7 +61439,7 @@ ${lastSnapshot}`;
|
|
|
61394
61439
|
return;
|
|
61395
61440
|
}
|
|
61396
61441
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
61397
|
-
await new Promise((
|
|
61442
|
+
await new Promise((resolve26, reject) => {
|
|
61398
61443
|
this.browserWs = new import_ws2.default(browserWsUrl);
|
|
61399
61444
|
this.browserWs.on("open", async () => {
|
|
61400
61445
|
this._browserConnected = true;
|
|
@@ -61404,16 +61449,16 @@ ${lastSnapshot}`;
|
|
|
61404
61449
|
} catch (e) {
|
|
61405
61450
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
61406
61451
|
}
|
|
61407
|
-
|
|
61452
|
+
resolve26();
|
|
61408
61453
|
});
|
|
61409
61454
|
this.browserWs.on("message", (data) => {
|
|
61410
61455
|
try {
|
|
61411
61456
|
const msg = JSON.parse(data.toString());
|
|
61412
61457
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
61413
|
-
const { resolve:
|
|
61458
|
+
const { resolve: resolve27, reject: reject2 } = this.browserPending.get(msg.id);
|
|
61414
61459
|
this.browserPending.delete(msg.id);
|
|
61415
61460
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
61416
|
-
else
|
|
61461
|
+
else resolve27(msg.result);
|
|
61417
61462
|
}
|
|
61418
61463
|
} catch {
|
|
61419
61464
|
}
|
|
@@ -61433,31 +61478,31 @@ ${lastSnapshot}`;
|
|
|
61433
61478
|
}
|
|
61434
61479
|
}
|
|
61435
61480
|
getBrowserWsUrl() {
|
|
61436
|
-
return new Promise((
|
|
61481
|
+
return new Promise((resolve26) => {
|
|
61437
61482
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
61438
61483
|
let data = "";
|
|
61439
61484
|
res.on("data", (chunk) => data += chunk.toString());
|
|
61440
61485
|
res.on("end", () => {
|
|
61441
61486
|
try {
|
|
61442
61487
|
const info = JSON.parse(data);
|
|
61443
|
-
|
|
61488
|
+
resolve26(info.webSocketDebuggerUrl || null);
|
|
61444
61489
|
} catch {
|
|
61445
|
-
|
|
61490
|
+
resolve26(null);
|
|
61446
61491
|
}
|
|
61447
61492
|
});
|
|
61448
61493
|
});
|
|
61449
|
-
req.on("error", () =>
|
|
61494
|
+
req.on("error", () => resolve26(null));
|
|
61450
61495
|
req.setTimeout(3e3, () => {
|
|
61451
61496
|
req.destroy();
|
|
61452
|
-
|
|
61497
|
+
resolve26(null);
|
|
61453
61498
|
});
|
|
61454
61499
|
});
|
|
61455
61500
|
}
|
|
61456
61501
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
61457
|
-
return new Promise((
|
|
61502
|
+
return new Promise((resolve26, reject) => {
|
|
61458
61503
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
61459
61504
|
const id = this.browserMsgId++;
|
|
61460
|
-
this.browserPending.set(id, { resolve:
|
|
61505
|
+
this.browserPending.set(id, { resolve: resolve26, reject });
|
|
61461
61506
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
61462
61507
|
setTimeout(() => {
|
|
61463
61508
|
if (this.browserPending.has(id)) {
|
|
@@ -61497,11 +61542,11 @@ ${lastSnapshot}`;
|
|
|
61497
61542
|
}
|
|
61498
61543
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
61499
61544
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
61500
|
-
return new Promise((
|
|
61545
|
+
return new Promise((resolve26, reject) => {
|
|
61501
61546
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
61502
61547
|
if (this.ws.readyState !== import_ws2.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
61503
61548
|
const id = this.msgId++;
|
|
61504
|
-
this.pending.set(id, { resolve:
|
|
61549
|
+
this.pending.set(id, { resolve: resolve26, reject });
|
|
61505
61550
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
61506
61551
|
setTimeout(() => {
|
|
61507
61552
|
if (this.pending.has(id)) {
|
|
@@ -61750,7 +61795,7 @@ ${lastSnapshot}`;
|
|
|
61750
61795
|
const browserWs = this.browserWs;
|
|
61751
61796
|
let msgId = this.browserMsgId;
|
|
61752
61797
|
const sendWs = (method, params = {}, sessionId) => {
|
|
61753
|
-
return new Promise((
|
|
61798
|
+
return new Promise((resolve26, reject) => {
|
|
61754
61799
|
const mid = msgId++;
|
|
61755
61800
|
this.browserMsgId = msgId;
|
|
61756
61801
|
const handler = (raw) => {
|
|
@@ -61759,7 +61804,7 @@ ${lastSnapshot}`;
|
|
|
61759
61804
|
if (msg.id === mid) {
|
|
61760
61805
|
browserWs.removeListener("message", handler);
|
|
61761
61806
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
61762
|
-
else
|
|
61807
|
+
else resolve26(msg.result);
|
|
61763
61808
|
}
|
|
61764
61809
|
} catch {
|
|
61765
61810
|
}
|
|
@@ -61960,14 +62005,14 @@ ${lastSnapshot}`;
|
|
|
61960
62005
|
if (!ws || ws.readyState !== import_ws2.default.OPEN) {
|
|
61961
62006
|
throw new Error("CDP not connected");
|
|
61962
62007
|
}
|
|
61963
|
-
return new Promise((
|
|
62008
|
+
return new Promise((resolve26, reject) => {
|
|
61964
62009
|
const id = getNextId();
|
|
61965
62010
|
pendingMap.set(id, {
|
|
61966
62011
|
resolve: (result) => {
|
|
61967
62012
|
if (result?.result?.subtype === "error") {
|
|
61968
62013
|
reject(new Error(result.result.description));
|
|
61969
62014
|
} else {
|
|
61970
|
-
|
|
62015
|
+
resolve26(result?.result?.value);
|
|
61971
62016
|
}
|
|
61972
62017
|
},
|
|
61973
62018
|
reject
|
|
@@ -61999,10 +62044,10 @@ ${lastSnapshot}`;
|
|
|
61999
62044
|
throw new Error("CDP not connected");
|
|
62000
62045
|
}
|
|
62001
62046
|
const sendViaSession = (method, params = {}) => {
|
|
62002
|
-
return new Promise((
|
|
62047
|
+
return new Promise((resolve26, reject) => {
|
|
62003
62048
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
62004
62049
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
62005
|
-
pendingMap.set(id, { resolve:
|
|
62050
|
+
pendingMap.set(id, { resolve: resolve26, reject });
|
|
62006
62051
|
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
62007
62052
|
setTimeout(() => {
|
|
62008
62053
|
if (pendingMap.has(id)) {
|
|
@@ -65863,12 +65908,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
65863
65908
|
if (typeof instanceWorkspace === "string" && instanceWorkspace.trim()) return instanceWorkspace;
|
|
65864
65909
|
return "";
|
|
65865
65910
|
}
|
|
65866
|
-
var
|
|
65911
|
+
var fs9 = __toESM2(require("fs"));
|
|
65867
65912
|
var os10 = __toESM2(require("os"));
|
|
65868
65913
|
var path17 = __toESM2(require("path"));
|
|
65869
65914
|
var import_node_crypto3 = require("crypto");
|
|
65870
65915
|
init_logger();
|
|
65871
65916
|
init_debug_trace();
|
|
65917
|
+
var fs8 = __toESM2(require("fs"));
|
|
65872
65918
|
var path16 = __toESM2(require("path"));
|
|
65873
65919
|
init_contracts2();
|
|
65874
65920
|
init_state_store();
|
|
@@ -66816,7 +66862,16 @@ ${effect.notification.body || ""}`.trim();
|
|
|
66816
66862
|
function normalizeComparableWorkspace(value) {
|
|
66817
66863
|
const text = typeof value === "string" ? value.trim() : "";
|
|
66818
66864
|
if (!text) return "";
|
|
66819
|
-
|
|
66865
|
+
const lexical = path16.resolve(text);
|
|
66866
|
+
try {
|
|
66867
|
+
return fs8.realpathSync.native(lexical);
|
|
66868
|
+
} catch {
|
|
66869
|
+
try {
|
|
66870
|
+
return fs8.realpathSync(lexical);
|
|
66871
|
+
} catch {
|
|
66872
|
+
return lexical;
|
|
66873
|
+
}
|
|
66874
|
+
}
|
|
66820
66875
|
}
|
|
66821
66876
|
function isCurrentRuntimePtySafelyAttributed(args) {
|
|
66822
66877
|
if (args.adapter.cliType !== "codex-cli") return false;
|
|
@@ -68132,11 +68187,11 @@ ${effect.notification.body || ""}`.trim();
|
|
|
68132
68187
|
function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
|
|
68133
68188
|
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
68134
68189
|
const dir = getChatDebugBundleDir();
|
|
68135
|
-
|
|
68190
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
68136
68191
|
const savedPath = path17.join(dir, `${bundleId}.json`);
|
|
68137
68192
|
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
68138
68193
|
`;
|
|
68139
|
-
|
|
68194
|
+
fs9.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
68140
68195
|
return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json2, "utf8") };
|
|
68141
68196
|
}
|
|
68142
68197
|
function isDaemonFileDebugDelivery(args) {
|
|
@@ -68295,7 +68350,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
68295
68350
|
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
68296
68351
|
}
|
|
68297
68352
|
function sleep(ms) {
|
|
68298
|
-
return new Promise((
|
|
68353
|
+
return new Promise((resolve26) => setTimeout(resolve26, ms));
|
|
68299
68354
|
}
|
|
68300
68355
|
async function waitOnceForFreshHermesCliStart(adapter, log) {
|
|
68301
68356
|
if (adapter.cliType !== "hermes-cli") return;
|
|
@@ -68350,7 +68405,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
68350
68405
|
async function getStableExtensionBaseline(h) {
|
|
68351
68406
|
const first = await readExtensionChatState(h);
|
|
68352
68407
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
68353
|
-
await new Promise((
|
|
68408
|
+
await new Promise((resolve26) => setTimeout(resolve26, 150));
|
|
68354
68409
|
const second = await readExtensionChatState(h);
|
|
68355
68410
|
return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
|
|
68356
68411
|
}
|
|
@@ -68358,7 +68413,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
68358
68413
|
const beforeCount = getStateMessageCount(before);
|
|
68359
68414
|
const beforeSignature = getStateLastSignature(before);
|
|
68360
68415
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
68361
|
-
await new Promise((
|
|
68416
|
+
await new Promise((resolve26) => setTimeout(resolve26, 250));
|
|
68362
68417
|
const state = await readExtensionChatState(h);
|
|
68363
68418
|
if (state?.status === "waiting_approval") return true;
|
|
68364
68419
|
const afterCount = getStateMessageCount(state);
|
|
@@ -69073,7 +69128,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
69073
69128
|
}
|
|
69074
69129
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
69075
69130
|
}
|
|
69076
|
-
var
|
|
69131
|
+
var fs10 = __toESM2(require("fs"));
|
|
69077
69132
|
var path18 = __toESM2(require("path"));
|
|
69078
69133
|
var os11 = __toESM2(require("os"));
|
|
69079
69134
|
var KEY_TO_VK = {
|
|
@@ -69346,7 +69401,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
69346
69401
|
return path18.resolve(inputPath);
|
|
69347
69402
|
}
|
|
69348
69403
|
function listDirectoryEntriesSafe(dirPath) {
|
|
69349
|
-
const entries =
|
|
69404
|
+
const entries = fs10.readdirSync(dirPath, { withFileTypes: true });
|
|
69350
69405
|
const files = [];
|
|
69351
69406
|
for (const entry of entries) {
|
|
69352
69407
|
const entryPath = path18.join(dirPath, entry.name);
|
|
@@ -69358,14 +69413,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
69358
69413
|
if (entry.isFile()) {
|
|
69359
69414
|
let size;
|
|
69360
69415
|
try {
|
|
69361
|
-
size =
|
|
69416
|
+
size = fs10.statSync(entryPath).size;
|
|
69362
69417
|
} catch {
|
|
69363
69418
|
size = void 0;
|
|
69364
69419
|
}
|
|
69365
69420
|
files.push({ name: entry.name, type: "file", size });
|
|
69366
69421
|
continue;
|
|
69367
69422
|
}
|
|
69368
|
-
const stat2 =
|
|
69423
|
+
const stat2 = fs10.statSync(entryPath);
|
|
69369
69424
|
files.push({
|
|
69370
69425
|
name: entry.name,
|
|
69371
69426
|
type: stat2.isDirectory() ? "directory" : "file",
|
|
@@ -69383,7 +69438,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
69383
69438
|
const letter = String.fromCharCode(code);
|
|
69384
69439
|
const root = `${letter}:\\`;
|
|
69385
69440
|
try {
|
|
69386
|
-
if (!
|
|
69441
|
+
if (!fs10.existsSync(root)) continue;
|
|
69387
69442
|
if (excluded && root.toLowerCase() === excluded) continue;
|
|
69388
69443
|
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
69389
69444
|
} catch {
|
|
@@ -69394,7 +69449,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
69394
69449
|
async function handleFileRead(h, args) {
|
|
69395
69450
|
try {
|
|
69396
69451
|
const filePath = resolveSafePath(args?.path);
|
|
69397
|
-
const content =
|
|
69452
|
+
const content = fs10.readFileSync(filePath, "utf-8");
|
|
69398
69453
|
return { success: true, content, path: filePath };
|
|
69399
69454
|
} catch (e) {
|
|
69400
69455
|
return { success: false, error: e.message };
|
|
@@ -69403,8 +69458,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
69403
69458
|
async function handleFileWrite(h, args) {
|
|
69404
69459
|
try {
|
|
69405
69460
|
const filePath = resolveSafePath(args?.path);
|
|
69406
|
-
|
|
69407
|
-
|
|
69461
|
+
fs10.mkdirSync(path18.dirname(filePath), { recursive: true });
|
|
69462
|
+
fs10.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
69408
69463
|
return { success: true, path: filePath };
|
|
69409
69464
|
} catch (e) {
|
|
69410
69465
|
return { success: false, error: e.message };
|
|
@@ -69750,7 +69805,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
69750
69805
|
const enterCount = cliCommand.enterCount || 1;
|
|
69751
69806
|
await adapter.writeRaw(cliCommand.text + "\r");
|
|
69752
69807
|
for (let i = 1; i < enterCount; i += 1) {
|
|
69753
|
-
await new Promise((
|
|
69808
|
+
await new Promise((resolve26) => setTimeout(resolve26, 50));
|
|
69754
69809
|
await adapter.writeRaw("\r");
|
|
69755
69810
|
}
|
|
69756
69811
|
}
|
|
@@ -70550,11 +70605,11 @@ ${effect.notification.body || ""}`.trim();
|
|
|
70550
70605
|
return { success: false, error: "invalid type" };
|
|
70551
70606
|
}
|
|
70552
70607
|
const https = require("https");
|
|
70553
|
-
const
|
|
70608
|
+
const fs43 = require("fs");
|
|
70554
70609
|
const path45 = require("path");
|
|
70555
70610
|
const REGISTRY = resolveRegistryBaseUrl(loadConfig2().registryUrl);
|
|
70556
70611
|
function fetchText(url2, timeoutMs) {
|
|
70557
|
-
return new Promise((
|
|
70612
|
+
return new Promise((resolve26, reject) => {
|
|
70558
70613
|
const req = https.get(url2, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: timeoutMs }, (res) => {
|
|
70559
70614
|
if (res.statusCode !== 200) {
|
|
70560
70615
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
@@ -70562,7 +70617,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
70562
70617
|
}
|
|
70563
70618
|
const chunks = [];
|
|
70564
70619
|
res.on("data", (c) => chunks.push(c));
|
|
70565
|
-
res.on("end", () =>
|
|
70620
|
+
res.on("end", () => resolve26(Buffer.concat(chunks).toString("utf-8")));
|
|
70566
70621
|
});
|
|
70567
70622
|
req.on("error", reject);
|
|
70568
70623
|
req.on("timeout", () => {
|
|
@@ -70593,7 +70648,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
70593
70648
|
if (!targetDir.startsWith(installRootResolved + path45.sep)) {
|
|
70594
70649
|
return { success: false, error: "install path escaped upstream root" };
|
|
70595
70650
|
}
|
|
70596
|
-
|
|
70651
|
+
fs43.mkdirSync(targetDir, { recursive: true });
|
|
70597
70652
|
let manifestProbe = {};
|
|
70598
70653
|
try {
|
|
70599
70654
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -70618,7 +70673,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70618
70673
|
}
|
|
70619
70674
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
70620
70675
|
const targetPath = path45.join(targetDir, targetFile);
|
|
70621
|
-
|
|
70676
|
+
fs43.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
70622
70677
|
const manifestJson = JSON.parse(manifestBody);
|
|
70623
70678
|
const scriptFetch = await this.fetchProviderSources(
|
|
70624
70679
|
manifestJson,
|
|
@@ -70688,10 +70743,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70688
70743
|
const repo = source.repo;
|
|
70689
70744
|
const ref = source.ref;
|
|
70690
70745
|
const https = require("https");
|
|
70691
|
-
const
|
|
70746
|
+
const fs43 = require("fs");
|
|
70692
70747
|
const path45 = require("path");
|
|
70693
70748
|
function fetchJson(url2, timeoutMs) {
|
|
70694
|
-
return new Promise((
|
|
70749
|
+
return new Promise((resolve26, reject) => {
|
|
70695
70750
|
const req = https.get(url2, {
|
|
70696
70751
|
headers: { "User-Agent": "adhdev-daemon", "Accept": "application/vnd.github+json" },
|
|
70697
70752
|
timeout: timeoutMs
|
|
@@ -70704,7 +70759,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70704
70759
|
res.on("data", (c) => chunks.push(c));
|
|
70705
70760
|
res.on("end", () => {
|
|
70706
70761
|
try {
|
|
70707
|
-
|
|
70762
|
+
resolve26(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
70708
70763
|
} catch (e) {
|
|
70709
70764
|
reject(e);
|
|
70710
70765
|
}
|
|
@@ -70718,14 +70773,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70718
70773
|
});
|
|
70719
70774
|
}
|
|
70720
70775
|
function fetchBinary(url2, timeoutMs) {
|
|
70721
|
-
return new Promise((
|
|
70776
|
+
return new Promise((resolve26, reject) => {
|
|
70722
70777
|
const req = https.get(url2, {
|
|
70723
70778
|
headers: { "User-Agent": "adhdev-daemon" },
|
|
70724
70779
|
timeout: timeoutMs
|
|
70725
70780
|
}, (res) => {
|
|
70726
70781
|
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
70727
70782
|
if (res.headers.location) {
|
|
70728
|
-
return fetchBinary(res.headers.location, timeoutMs).then(
|
|
70783
|
+
return fetchBinary(res.headers.location, timeoutMs).then(resolve26, reject);
|
|
70729
70784
|
}
|
|
70730
70785
|
}
|
|
70731
70786
|
if (res.statusCode !== 200) {
|
|
@@ -70734,7 +70789,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70734
70789
|
}
|
|
70735
70790
|
const chunks = [];
|
|
70736
70791
|
res.on("data", (c) => chunks.push(c));
|
|
70737
|
-
res.on("end", () =>
|
|
70792
|
+
res.on("end", () => resolve26(Buffer.concat(chunks)));
|
|
70738
70793
|
});
|
|
70739
70794
|
req.on("error", reject);
|
|
70740
70795
|
req.on("timeout", () => {
|
|
@@ -70772,8 +70827,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70772
70827
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
70773
70828
|
const outPath = path45.resolve(path45.join(sharedTargetDir, relInside));
|
|
70774
70829
|
if (!outPath.startsWith(path45.resolve(sharedTargetDir) + path45.sep)) continue;
|
|
70775
|
-
|
|
70776
|
-
|
|
70830
|
+
fs43.mkdirSync(path45.dirname(outPath), { recursive: true });
|
|
70831
|
+
fs43.writeFileSync(outPath, body);
|
|
70777
70832
|
fetchedCount++;
|
|
70778
70833
|
} catch (e) {
|
|
70779
70834
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -70811,8 +70866,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70811
70866
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
70812
70867
|
continue;
|
|
70813
70868
|
}
|
|
70814
|
-
|
|
70815
|
-
|
|
70869
|
+
fs43.mkdirSync(path45.dirname(outPath), { recursive: true });
|
|
70870
|
+
fs43.writeFileSync(outPath, body);
|
|
70816
70871
|
fetchedCount++;
|
|
70817
70872
|
} catch (e) {
|
|
70818
70873
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -70840,7 +70895,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70840
70895
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
70841
70896
|
return { success: false, error: `unknown category: ${category}` };
|
|
70842
70897
|
}
|
|
70843
|
-
const
|
|
70898
|
+
const fs43 = require("fs");
|
|
70844
70899
|
const path45 = require("path");
|
|
70845
70900
|
try {
|
|
70846
70901
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -70849,10 +70904,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70849
70904
|
if (!targetDir.startsWith(installRootResolved + path45.sep)) {
|
|
70850
70905
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
70851
70906
|
}
|
|
70852
|
-
if (!
|
|
70907
|
+
if (!fs43.existsSync(targetDir)) {
|
|
70853
70908
|
return { success: false, error: "not installed" };
|
|
70854
70909
|
}
|
|
70855
|
-
|
|
70910
|
+
fs43.rmSync(targetDir, { recursive: true, force: true });
|
|
70856
70911
|
if (this._ctx.providerLoader) {
|
|
70857
70912
|
this._ctx.providerLoader.reload();
|
|
70858
70913
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -70868,28 +70923,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70868
70923
|
* the UI and by the update checker.
|
|
70869
70924
|
*/
|
|
70870
70925
|
handleListInstalledProviders(_args) {
|
|
70871
|
-
const
|
|
70926
|
+
const fs43 = require("fs");
|
|
70872
70927
|
const path45 = require("path");
|
|
70873
70928
|
const installRoot = this.getUpstreamInstallRoot();
|
|
70874
|
-
if (!
|
|
70929
|
+
if (!fs43.existsSync(installRoot)) return { success: true, providers: [] };
|
|
70875
70930
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
70876
70931
|
const items = [];
|
|
70877
70932
|
for (const category of CATEGORIES) {
|
|
70878
70933
|
const categoryDir = path45.join(installRoot, category);
|
|
70879
|
-
if (!
|
|
70934
|
+
if (!fs43.existsSync(categoryDir)) continue;
|
|
70880
70935
|
let entries;
|
|
70881
70936
|
try {
|
|
70882
|
-
entries =
|
|
70937
|
+
entries = fs43.readdirSync(categoryDir);
|
|
70883
70938
|
} catch {
|
|
70884
70939
|
continue;
|
|
70885
70940
|
}
|
|
70886
70941
|
for (const type of entries) {
|
|
70887
70942
|
const v1Path = path45.join(categoryDir, type, "provider.v1.json");
|
|
70888
70943
|
const v0Path = path45.join(categoryDir, type, "provider.json");
|
|
70889
|
-
const manifestPath =
|
|
70944
|
+
const manifestPath = fs43.existsSync(v1Path) ? v1Path : fs43.existsSync(v0Path) ? v0Path : null;
|
|
70890
70945
|
if (!manifestPath) continue;
|
|
70891
70946
|
try {
|
|
70892
|
-
const m = JSON.parse(
|
|
70947
|
+
const m = JSON.parse(fs43.readFileSync(manifestPath, "utf-8"));
|
|
70893
70948
|
const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
70894
70949
|
const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
70895
70950
|
items.push({
|
|
@@ -70920,7 +70975,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70920
70975
|
const https = require("https");
|
|
70921
70976
|
const REGISTRY = resolveRegistryBaseUrl(loadConfig2().registryUrl);
|
|
70922
70977
|
function fetchJson(url2) {
|
|
70923
|
-
return new Promise((
|
|
70978
|
+
return new Promise((resolve26, reject) => {
|
|
70924
70979
|
const req = https.get(url2, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
|
|
70925
70980
|
if (res.statusCode !== 200) {
|
|
70926
70981
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
@@ -70930,7 +70985,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
70930
70985
|
res.on("data", (c) => chunks.push(c));
|
|
70931
70986
|
res.on("end", () => {
|
|
70932
70987
|
try {
|
|
70933
|
-
|
|
70988
|
+
resolve26(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
70934
70989
|
} catch (e) {
|
|
70935
70990
|
reject(e);
|
|
70936
70991
|
}
|
|
@@ -71004,7 +71059,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71004
71059
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
71005
71060
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
71006
71061
|
}
|
|
71007
|
-
const
|
|
71062
|
+
const fs43 = require("fs");
|
|
71008
71063
|
const path45 = require("path");
|
|
71009
71064
|
const { spawnSync: spawnSync2 } = require("child_process");
|
|
71010
71065
|
const file2 = ext.loadExternalSources();
|
|
@@ -71015,8 +71070,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71015
71070
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
71016
71071
|
}
|
|
71017
71072
|
const sourceDir = path45.join(ext.externalRoot(), requestedName);
|
|
71018
|
-
if (!
|
|
71019
|
-
if (
|
|
71073
|
+
if (!fs43.existsSync(ext.externalRoot())) fs43.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
71074
|
+
if (fs43.existsSync(sourceDir)) {
|
|
71020
71075
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
71021
71076
|
}
|
|
71022
71077
|
const clone2 = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -71026,7 +71081,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71026
71081
|
});
|
|
71027
71082
|
if (clone2.status !== 0) {
|
|
71028
71083
|
try {
|
|
71029
|
-
|
|
71084
|
+
fs43.rmSync(sourceDir, { recursive: true, force: true });
|
|
71030
71085
|
} catch {
|
|
71031
71086
|
}
|
|
71032
71087
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -71070,15 +71125,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71070
71125
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
71071
71126
|
if (!name) return { success: false, error: "name is required" };
|
|
71072
71127
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
71073
|
-
const
|
|
71128
|
+
const fs43 = require("fs");
|
|
71074
71129
|
const path45 = require("path");
|
|
71075
71130
|
const file2 = ext.loadExternalSources();
|
|
71076
71131
|
const match = file2.sources.find((s2) => s2.name === name);
|
|
71077
71132
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
71078
71133
|
const sourceDir = path45.join(ext.externalRoot(), name);
|
|
71079
|
-
if (
|
|
71134
|
+
if (fs43.existsSync(sourceDir)) {
|
|
71080
71135
|
try {
|
|
71081
|
-
|
|
71136
|
+
fs43.rmSync(sourceDir, { recursive: true, force: true });
|
|
71082
71137
|
} catch (e) {
|
|
71083
71138
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
71084
71139
|
}
|
|
@@ -71168,7 +71223,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71168
71223
|
try {
|
|
71169
71224
|
const http3 = await import("http");
|
|
71170
71225
|
const postData = JSON.stringify(body);
|
|
71171
|
-
const result = await new Promise((
|
|
71226
|
+
const result = await new Promise((resolve26, reject) => {
|
|
71172
71227
|
const req = http3.request({
|
|
71173
71228
|
hostname: "127.0.0.1",
|
|
71174
71229
|
port: 19280,
|
|
@@ -71180,9 +71235,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71180
71235
|
res.on("data", (chunk) => data += chunk);
|
|
71181
71236
|
res.on("end", () => {
|
|
71182
71237
|
try {
|
|
71183
|
-
|
|
71238
|
+
resolve26(JSON.parse(data));
|
|
71184
71239
|
} catch {
|
|
71185
|
-
|
|
71240
|
+
resolve26({ raw: data });
|
|
71186
71241
|
}
|
|
71187
71242
|
});
|
|
71188
71243
|
});
|
|
@@ -71200,15 +71255,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71200
71255
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
71201
71256
|
try {
|
|
71202
71257
|
const http3 = await import("http");
|
|
71203
|
-
const result = await new Promise((
|
|
71258
|
+
const result = await new Promise((resolve26, reject) => {
|
|
71204
71259
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
71205
71260
|
let data = "";
|
|
71206
71261
|
res.on("data", (chunk) => data += chunk);
|
|
71207
71262
|
res.on("end", () => {
|
|
71208
71263
|
try {
|
|
71209
|
-
|
|
71264
|
+
resolve26(JSON.parse(data));
|
|
71210
71265
|
} catch {
|
|
71211
|
-
|
|
71266
|
+
resolve26({ raw: data });
|
|
71212
71267
|
}
|
|
71213
71268
|
});
|
|
71214
71269
|
}).on("error", reject);
|
|
@@ -71222,7 +71277,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71222
71277
|
try {
|
|
71223
71278
|
const http3 = await import("http");
|
|
71224
71279
|
const postData = JSON.stringify(args || {});
|
|
71225
|
-
const result = await new Promise((
|
|
71280
|
+
const result = await new Promise((resolve26, reject) => {
|
|
71226
71281
|
const req = http3.request({
|
|
71227
71282
|
hostname: "127.0.0.1",
|
|
71228
71283
|
port: 19280,
|
|
@@ -71234,9 +71289,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71234
71289
|
res.on("data", (chunk) => data += chunk);
|
|
71235
71290
|
res.on("end", () => {
|
|
71236
71291
|
try {
|
|
71237
|
-
|
|
71292
|
+
resolve26(JSON.parse(data));
|
|
71238
71293
|
} catch {
|
|
71239
|
-
|
|
71294
|
+
resolve26({ raw: data });
|
|
71240
71295
|
}
|
|
71241
71296
|
});
|
|
71242
71297
|
});
|
|
@@ -71742,7 +71797,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71742
71797
|
};
|
|
71743
71798
|
}
|
|
71744
71799
|
};
|
|
71745
|
-
var
|
|
71800
|
+
var fs13 = __toESM2(require("fs"));
|
|
71746
71801
|
init_logger();
|
|
71747
71802
|
init_debug_trace();
|
|
71748
71803
|
var diagnosticsHandlers = {
|
|
@@ -71761,8 +71816,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71761
71816
|
if (sinceTs > 0) {
|
|
71762
71817
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
71763
71818
|
}
|
|
71764
|
-
if (
|
|
71765
|
-
const content =
|
|
71819
|
+
if (fs13.existsSync(LOG_PATH)) {
|
|
71820
|
+
const content = fs13.readFileSync(LOG_PATH, "utf-8");
|
|
71766
71821
|
const allLines = content.split("\n");
|
|
71767
71822
|
const recent = allLines.slice(-count).join("\n");
|
|
71768
71823
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -71905,14 +71960,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71905
71960
|
}
|
|
71906
71961
|
},
|
|
71907
71962
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
71908
|
-
const
|
|
71963
|
+
const fs43 = await import("fs");
|
|
71909
71964
|
const path45 = await import("path");
|
|
71910
71965
|
const os322 = await import("os");
|
|
71911
71966
|
const dir = path45.join(os322.homedir(), ".adhdev", "coordinator-prompts");
|
|
71912
71967
|
const entries = {};
|
|
71913
71968
|
try {
|
|
71914
|
-
if (
|
|
71915
|
-
for (const name of
|
|
71969
|
+
if (fs43.existsSync(dir)) {
|
|
71970
|
+
for (const name of fs43.readdirSync(dir)) {
|
|
71916
71971
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
71917
71972
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
71918
71973
|
const m = matchAppend || matchOverride;
|
|
@@ -71922,7 +71977,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71922
71977
|
const full = path45.join(dir, name);
|
|
71923
71978
|
let content = "";
|
|
71924
71979
|
try {
|
|
71925
|
-
content =
|
|
71980
|
+
content = fs43.readFileSync(full, "utf8");
|
|
71926
71981
|
} catch {
|
|
71927
71982
|
}
|
|
71928
71983
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -71936,7 +71991,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71936
71991
|
return { success: true, dir, entries };
|
|
71937
71992
|
},
|
|
71938
71993
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
71939
|
-
const
|
|
71994
|
+
const fs43 = await import("fs");
|
|
71940
71995
|
const path45 = await import("path");
|
|
71941
71996
|
const os322 = await import("os");
|
|
71942
71997
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -71949,11 +72004,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
71949
72004
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
71950
72005
|
const full = path45.join(dir, filename);
|
|
71951
72006
|
try {
|
|
71952
|
-
|
|
72007
|
+
fs43.mkdirSync(dir, { recursive: true });
|
|
71953
72008
|
if (content.trim()) {
|
|
71954
|
-
|
|
71955
|
-
} else if (
|
|
71956
|
-
|
|
72009
|
+
fs43.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
72010
|
+
} else if (fs43.existsSync(full)) {
|
|
72011
|
+
fs43.unlinkSync(full);
|
|
71957
72012
|
}
|
|
71958
72013
|
return { success: true, path: full, kind, key: key2 };
|
|
71959
72014
|
} catch (error48) {
|
|
@@ -72063,21 +72118,21 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72063
72118
|
init_config();
|
|
72064
72119
|
var import_child_process5 = require("child_process");
|
|
72065
72120
|
var import_child_process6 = require("child_process");
|
|
72066
|
-
var
|
|
72121
|
+
var fs14 = __toESM2(require("fs"));
|
|
72067
72122
|
var os13 = __toESM2(require("os"));
|
|
72068
72123
|
var path20 = __toESM2(require("path"));
|
|
72069
72124
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
72070
72125
|
function getUpgradeLogPath() {
|
|
72071
72126
|
const home = os13.homedir();
|
|
72072
72127
|
const dir = path20.join(home, ".adhdev");
|
|
72073
|
-
|
|
72128
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
72074
72129
|
return path20.join(dir, "daemon-upgrade.log");
|
|
72075
72130
|
}
|
|
72076
72131
|
function appendUpgradeLog(message) {
|
|
72077
72132
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
72078
72133
|
`;
|
|
72079
72134
|
try {
|
|
72080
|
-
|
|
72135
|
+
fs14.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
72081
72136
|
} catch {
|
|
72082
72137
|
}
|
|
72083
72138
|
}
|
|
@@ -72085,12 +72140,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72085
72140
|
const binDir = path20.dirname(nodeExecutable);
|
|
72086
72141
|
if (platform10 === "win32") {
|
|
72087
72142
|
const npmCliPath = path20.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
72088
|
-
if (
|
|
72143
|
+
if (fs14.existsSync(npmCliPath)) {
|
|
72089
72144
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
72090
72145
|
}
|
|
72091
72146
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
72092
72147
|
const candidatePath = path20.join(binDir, candidate);
|
|
72093
|
-
if (
|
|
72148
|
+
if (fs14.existsSync(candidatePath)) {
|
|
72094
72149
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
72095
72150
|
}
|
|
72096
72151
|
}
|
|
@@ -72098,7 +72153,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72098
72153
|
}
|
|
72099
72154
|
for (const candidate of ["npm"]) {
|
|
72100
72155
|
const candidatePath = path20.join(binDir, candidate);
|
|
72101
|
-
if (
|
|
72156
|
+
if (fs14.existsSync(candidatePath)) {
|
|
72102
72157
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
72103
72158
|
}
|
|
72104
72159
|
}
|
|
@@ -72108,12 +72163,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72108
72163
|
if (!currentCliPath) return null;
|
|
72109
72164
|
let resolvedPath = currentCliPath;
|
|
72110
72165
|
try {
|
|
72111
|
-
resolvedPath =
|
|
72166
|
+
resolvedPath = fs14.realpathSync.native(currentCliPath);
|
|
72112
72167
|
} catch {
|
|
72113
72168
|
}
|
|
72114
72169
|
let currentDir = resolvedPath;
|
|
72115
72170
|
try {
|
|
72116
|
-
if (
|
|
72171
|
+
if (fs14.statSync(resolvedPath).isFile()) {
|
|
72117
72172
|
currentDir = path20.dirname(resolvedPath);
|
|
72118
72173
|
}
|
|
72119
72174
|
} catch {
|
|
@@ -72122,8 +72177,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72122
72177
|
while (true) {
|
|
72123
72178
|
const packageJsonPath = path20.join(currentDir, "package.json");
|
|
72124
72179
|
try {
|
|
72125
|
-
if (
|
|
72126
|
-
const parsed = JSON.parse(
|
|
72180
|
+
if (fs14.existsSync(packageJsonPath)) {
|
|
72181
|
+
const parsed = JSON.parse(fs14.readFileSync(packageJsonPath, "utf8"));
|
|
72127
72182
|
if (parsed?.name === packageName) {
|
|
72128
72183
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
72129
72184
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -72264,7 +72319,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72264
72319
|
while (Date.now() - start < timeoutMs) {
|
|
72265
72320
|
try {
|
|
72266
72321
|
process.kill(pid, 0);
|
|
72267
|
-
await new Promise((
|
|
72322
|
+
await new Promise((resolve26) => setTimeout(resolve26, 250));
|
|
72268
72323
|
} catch {
|
|
72269
72324
|
return;
|
|
72270
72325
|
}
|
|
@@ -72274,8 +72329,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72274
72329
|
const pidFile = path20.join(os13.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
72275
72330
|
let killedPid = null;
|
|
72276
72331
|
try {
|
|
72277
|
-
if (
|
|
72278
|
-
const pid = Number.parseInt(
|
|
72332
|
+
if (fs14.existsSync(pidFile)) {
|
|
72333
|
+
const pid = Number.parseInt(fs14.readFileSync(pidFile, "utf8").trim(), 10);
|
|
72279
72334
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
72280
72335
|
if (killPid(pid)) killedPid = pid;
|
|
72281
72336
|
}
|
|
@@ -72283,7 +72338,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72283
72338
|
} catch {
|
|
72284
72339
|
} finally {
|
|
72285
72340
|
try {
|
|
72286
|
-
|
|
72341
|
+
fs14.unlinkSync(pidFile);
|
|
72287
72342
|
} catch {
|
|
72288
72343
|
}
|
|
72289
72344
|
}
|
|
@@ -72360,7 +72415,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72360
72415
|
const home = os13.homedir();
|
|
72361
72416
|
const dir = path20.join(home, ".adhdev");
|
|
72362
72417
|
try {
|
|
72363
|
-
|
|
72418
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
72364
72419
|
} catch {
|
|
72365
72420
|
}
|
|
72366
72421
|
return path20.join(dir, "daemon-upgrade-last-error.txt");
|
|
@@ -72373,7 +72428,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
72373
72428
|
appendUpgradeLog(`Upgrade blocked \u2014 user action required:
|
|
72374
72429
|
${body}`);
|
|
72375
72430
|
try {
|
|
72376
|
-
|
|
72431
|
+
fs14.writeFileSync(getUpgradeFailureNoticePath(), `[${(/* @__PURE__ */ new Date()).toISOString()}]
|
|
72377
72432
|
${body}
|
|
72378
72433
|
`, "utf8");
|
|
72379
72434
|
} catch {
|
|
@@ -72388,13 +72443,13 @@ ${body}
|
|
|
72388
72443
|
function removeDaemonPidFile() {
|
|
72389
72444
|
const pidFile = path20.join(os13.homedir(), ".adhdev", "daemon.pid");
|
|
72390
72445
|
try {
|
|
72391
|
-
|
|
72446
|
+
fs14.unlinkSync(pidFile);
|
|
72392
72447
|
} catch {
|
|
72393
72448
|
}
|
|
72394
72449
|
}
|
|
72395
72450
|
function safeRemoveStaleEntry(target, label) {
|
|
72396
72451
|
try {
|
|
72397
|
-
|
|
72452
|
+
fs14.rmSync(target, { recursive: true, force: true });
|
|
72398
72453
|
appendUpgradeLog(`${label}: ${target}`);
|
|
72399
72454
|
} catch (error48) {
|
|
72400
72455
|
appendUpgradeLog(`Skipped locked stale entry (${error48?.code || "error"}): ${target} \u2014 ${error48?.message || String(error48)}`);
|
|
@@ -72415,19 +72470,19 @@ ${body}
|
|
|
72415
72470
|
if (pkgName.startsWith("@")) {
|
|
72416
72471
|
const [scope, name] = pkgName.split("/");
|
|
72417
72472
|
const scopeDir = path20.join(npmRoot, scope);
|
|
72418
|
-
if (!
|
|
72419
|
-
for (const entry of
|
|
72473
|
+
if (!fs14.existsSync(scopeDir)) return;
|
|
72474
|
+
for (const entry of fs14.readdirSync(scopeDir)) {
|
|
72420
72475
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
72421
72476
|
safeRemoveStaleEntry(path20.join(scopeDir, entry), "Removed stale scoped staging dir");
|
|
72422
72477
|
}
|
|
72423
72478
|
} else {
|
|
72424
|
-
for (const entry of
|
|
72479
|
+
for (const entry of fs14.readdirSync(npmRoot)) {
|
|
72425
72480
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
72426
72481
|
safeRemoveStaleEntry(path20.join(npmRoot, entry), "Removed stale staging dir");
|
|
72427
72482
|
}
|
|
72428
72483
|
}
|
|
72429
|
-
if (
|
|
72430
|
-
for (const entry of
|
|
72484
|
+
if (fs14.existsSync(binDir)) {
|
|
72485
|
+
for (const entry of fs14.readdirSync(binDir)) {
|
|
72431
72486
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
72432
72487
|
safeRemoveStaleEntry(path20.join(binDir, entry), "Removed stale bin staging entry");
|
|
72433
72488
|
}
|
|
@@ -72490,7 +72545,7 @@ ${body}
|
|
|
72490
72545
|
appendUpgradeLog(`Install attempt ${attempt} hit a file lock (${error48?.code || "lock"}); clearing holders + staging and retrying after backoff`);
|
|
72491
72546
|
await stopForeignNativeAddonHolders(installCommand.surface.packageRoot, { parentPid: payload.parentPid });
|
|
72492
72547
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
72493
|
-
await new Promise((
|
|
72548
|
+
await new Promise((resolve26) => setTimeout(resolve26, attempt * 1500));
|
|
72494
72549
|
continue;
|
|
72495
72550
|
}
|
|
72496
72551
|
if (isRetriableInstallLockError(error48)) {
|
|
@@ -72518,7 +72573,7 @@ ${body}
|
|
|
72518
72573
|
appendUpgradeLog(installOutput.trim());
|
|
72519
72574
|
}
|
|
72520
72575
|
if (process.platform === "win32") {
|
|
72521
|
-
await new Promise((
|
|
72576
|
+
await new Promise((resolve26) => setTimeout(resolve26, 500));
|
|
72522
72577
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
72523
72578
|
appendUpgradeLog("Post-install staging cleanup complete");
|
|
72524
72579
|
}
|
|
@@ -72675,7 +72730,7 @@ ${body}
|
|
|
72675
72730
|
}
|
|
72676
72731
|
};
|
|
72677
72732
|
init_dist();
|
|
72678
|
-
var
|
|
72733
|
+
var fs15 = __toESM2(require("fs"));
|
|
72679
72734
|
init_logger();
|
|
72680
72735
|
var DEFAULT_TAIL_BYTES = 64 * 1024;
|
|
72681
72736
|
var MAX_TAIL_BYTES = 128 * 1024;
|
|
@@ -72693,9 +72748,9 @@ ${body}
|
|
|
72693
72748
|
return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES);
|
|
72694
72749
|
}
|
|
72695
72750
|
function readByteBoundedTail(filePath, limitBytes) {
|
|
72696
|
-
const fd =
|
|
72751
|
+
const fd = fs15.openSync(filePath, "r");
|
|
72697
72752
|
try {
|
|
72698
|
-
const stat2 =
|
|
72753
|
+
const stat2 = fs15.fstatSync(fd);
|
|
72699
72754
|
const size = stat2.size;
|
|
72700
72755
|
if (size === 0) return { text: "", truncated: false, bytesReturned: 0 };
|
|
72701
72756
|
const want = Math.min(limitBytes, size);
|
|
@@ -72706,7 +72761,7 @@ ${body}
|
|
|
72706
72761
|
while (position < size) {
|
|
72707
72762
|
const chunkSize = Math.min(READ_CHUNK_BYTES, size - position);
|
|
72708
72763
|
const chunk = Buffer.alloc(chunkSize);
|
|
72709
|
-
|
|
72764
|
+
fs15.readSync(fd, chunk, 0, chunkSize, position);
|
|
72710
72765
|
buffers.push(chunk);
|
|
72711
72766
|
position += chunkSize;
|
|
72712
72767
|
}
|
|
@@ -72719,7 +72774,7 @@ ${body}
|
|
|
72719
72774
|
}
|
|
72720
72775
|
return { text: buf.toString("utf-8"), truncated, bytesReturned: buf.length };
|
|
72721
72776
|
} finally {
|
|
72722
|
-
|
|
72777
|
+
fs15.closeSync(fd);
|
|
72723
72778
|
}
|
|
72724
72779
|
}
|
|
72725
72780
|
function splitLogLines(text) {
|
|
@@ -72797,8 +72852,8 @@ ${body}
|
|
|
72797
72852
|
const limitBytes = clampTailBytes(args.tailBytes);
|
|
72798
72853
|
const primaryPath = resolveLogPath(args.date);
|
|
72799
72854
|
const backupPath = primaryPath.replace(/\.log$/, ".1.log");
|
|
72800
|
-
const primaryExists =
|
|
72801
|
-
const backupExists =
|
|
72855
|
+
const primaryExists = fs15.existsSync(primaryPath);
|
|
72856
|
+
const backupExists = fs15.existsSync(backupPath);
|
|
72802
72857
|
if (!primaryExists && !backupExists) {
|
|
72803
72858
|
return errorResult(
|
|
72804
72859
|
`No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
|
|
@@ -72837,7 +72892,7 @@ ${body}
|
|
|
72837
72892
|
try {
|
|
72838
72893
|
for (const p of [backupExists ? backupPath : null, primaryExists ? primaryPath : null]) {
|
|
72839
72894
|
if (!p) continue;
|
|
72840
|
-
const buf =
|
|
72895
|
+
const buf = fs15.readFileSync(p);
|
|
72841
72896
|
scannedBytes += buf.length;
|
|
72842
72897
|
allLines = allLines.concat(splitLogLines(buf.toString("utf-8")));
|
|
72843
72898
|
}
|
|
@@ -73029,14 +73084,14 @@ ${body}
|
|
|
73029
73084
|
init_summary_metadata();
|
|
73030
73085
|
var os21 = __toESM2(require("os"));
|
|
73031
73086
|
var crypto5 = __toESM2(require("crypto"));
|
|
73032
|
-
var
|
|
73087
|
+
var fs23 = __toESM2(require("fs"));
|
|
73033
73088
|
init_contracts2();
|
|
73034
73089
|
init_provider_input_support();
|
|
73035
73090
|
init_hash();
|
|
73036
|
-
var
|
|
73091
|
+
var fs21 = __toESM2(require("fs"));
|
|
73037
73092
|
var path25 = __toESM2(require("path"));
|
|
73038
73093
|
init_provider_cli_adapter();
|
|
73039
|
-
var
|
|
73094
|
+
var fs17 = __toESM2(require("fs"));
|
|
73040
73095
|
var os18 = __toESM2(require("os"));
|
|
73041
73096
|
var path23 = __toESM2(require("path"));
|
|
73042
73097
|
init_terminal_screen();
|
|
@@ -73209,7 +73264,7 @@ ${body}
|
|
|
73209
73264
|
init_fsm_evaluator();
|
|
73210
73265
|
init_fsm_types();
|
|
73211
73266
|
init_fsm_loader();
|
|
73212
|
-
var
|
|
73267
|
+
var fs16 = __toESM2(require("fs"));
|
|
73213
73268
|
var os17 = __toESM2(require("os"));
|
|
73214
73269
|
var path222 = __toESM2(require("path"));
|
|
73215
73270
|
init_logger();
|
|
@@ -73220,7 +73275,7 @@ ${body}
|
|
|
73220
73275
|
}
|
|
73221
73276
|
function realWorkspacePath(workingDir) {
|
|
73222
73277
|
try {
|
|
73223
|
-
return
|
|
73278
|
+
return fs16.realpathSync(workingDir);
|
|
73224
73279
|
} catch {
|
|
73225
73280
|
return path222.resolve(workingDir);
|
|
73226
73281
|
}
|
|
@@ -73231,8 +73286,8 @@ ${body}
|
|
|
73231
73286
|
const real = realWorkspacePath(workingDir);
|
|
73232
73287
|
try {
|
|
73233
73288
|
let parsed = {};
|
|
73234
|
-
if (
|
|
73235
|
-
const text =
|
|
73289
|
+
if (fs16.existsSync(settingsPath)) {
|
|
73290
|
+
const text = fs16.readFileSync(settingsPath, "utf8");
|
|
73236
73291
|
if (text.trim().length > 0) {
|
|
73237
73292
|
const json2 = JSON.parse(text);
|
|
73238
73293
|
if (json2 && typeof json2 === "object" && !Array.isArray(json2)) {
|
|
@@ -73248,8 +73303,8 @@ ${body}
|
|
|
73248
73303
|
}
|
|
73249
73304
|
list.push(real);
|
|
73250
73305
|
parsed[key2] = list;
|
|
73251
|
-
|
|
73252
|
-
|
|
73306
|
+
fs16.mkdirSync(path222.dirname(settingsPath), { recursive: true });
|
|
73307
|
+
fs16.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
|
|
73253
73308
|
`, "utf8");
|
|
73254
73309
|
LOG2.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key2}")`);
|
|
73255
73310
|
return real;
|
|
@@ -73610,7 +73665,7 @@ ${body}
|
|
|
73610
73665
|
try {
|
|
73611
73666
|
const dir = path23.dirname(this.opts.specPath);
|
|
73612
73667
|
const base = path23.basename(this.opts.specPath);
|
|
73613
|
-
this.specWatcher =
|
|
73668
|
+
this.specWatcher = fs17.watch(dir, { persistent: false }, (_event, filename) => {
|
|
73614
73669
|
if (filename && filename !== base) return;
|
|
73615
73670
|
const res = loadFsmSpec(this.opts.specPath);
|
|
73616
73671
|
if (!res.ok) {
|
|
@@ -74246,7 +74301,7 @@ ${body}
|
|
|
74246
74301
|
const ext = guessExt(mime);
|
|
74247
74302
|
const tmp = path23.join(os18.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
|
|
74248
74303
|
try {
|
|
74249
|
-
|
|
74304
|
+
fs17.writeFileSync(tmp, Buffer.from(blob, "base64"));
|
|
74250
74305
|
} catch {
|
|
74251
74306
|
return;
|
|
74252
74307
|
}
|
|
@@ -74374,7 +74429,7 @@ ${body}
|
|
|
74374
74429
|
return lines.filter((l) => !ignoreRe.test(l));
|
|
74375
74430
|
}
|
|
74376
74431
|
init_evaluator();
|
|
74377
|
-
var
|
|
74432
|
+
var fs18 = __toESM2(require("fs"));
|
|
74378
74433
|
var os19 = __toESM2(require("os"));
|
|
74379
74434
|
var path24 = __toESM2(require("path"));
|
|
74380
74435
|
init_logger();
|
|
@@ -74395,7 +74450,7 @@ ${body}
|
|
|
74395
74450
|
const wsRaw = typeof input.workspace === "string" ? input.workspace : "";
|
|
74396
74451
|
let wsReal = wsRaw;
|
|
74397
74452
|
try {
|
|
74398
|
-
if (wsRaw) wsReal =
|
|
74453
|
+
if (wsRaw) wsReal = fs18.realpathSync(wsRaw);
|
|
74399
74454
|
} catch {
|
|
74400
74455
|
}
|
|
74401
74456
|
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)`);
|
|
@@ -74404,23 +74459,26 @@ ${body}
|
|
|
74404
74459
|
const mtime = safeMtimeMs(sourcePath);
|
|
74405
74460
|
const lines = readJsonlLines(sourcePath);
|
|
74406
74461
|
if (lines.length === 0) return null;
|
|
74407
|
-
const transcriptWorkspace = readSessionMetaWorkspace(lines) ?? (src.workspace_from_input ? workspaceFromInputIfSlugMatches(sourcePath, input) : void 0);
|
|
74462
|
+
const transcriptWorkspace = readSessionMetaWorkspace(lines) ?? (src.workspace_from_sidecar ? readSidecarWorkspace(sourcePath, src.workspace_from_sidecar) : void 0) ?? (src.workspace_from_input ? workspaceFromInputIfSlugMatches(sourcePath, input) : void 0);
|
|
74408
74463
|
let providerSessionId;
|
|
74409
74464
|
if (src.session_id_from === "first_record" && src.session_id_path) {
|
|
74410
74465
|
const v = jsonPathGet(lines[0], src.session_id_path);
|
|
74411
74466
|
if (typeof v === "string" && v) providerSessionId = v;
|
|
74467
|
+
} else if (src.session_id_from === "dir_uuid") {
|
|
74468
|
+
providerSessionId = dirUuid(sourcePath) || void 0;
|
|
74412
74469
|
} else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
|
|
74413
74470
|
const m = path24.basename(sourcePath).match(UUID_RE);
|
|
74414
74471
|
if (m) providerSessionId = m[1];
|
|
74415
74472
|
}
|
|
74416
74473
|
const requested = readRequestedSessionId(input) || "";
|
|
74417
|
-
if (requested && providerSessionId && providerSessionId
|
|
74418
|
-
const
|
|
74474
|
+
if (requested && providerSessionId && !sameSessionUuid(providerSessionId, requested)) return null;
|
|
74475
|
+
const shapes = compileRecordShapes(src);
|
|
74419
74476
|
const messages = [];
|
|
74420
74477
|
for (let i = 0; i < lines.length; i += 1) {
|
|
74421
74478
|
const rec = lines[i];
|
|
74422
|
-
|
|
74423
|
-
|
|
74479
|
+
const shape = shapes.pick(rec);
|
|
74480
|
+
if (!shape) continue;
|
|
74481
|
+
for (const msg of projectMessages(rec, shape.map, i, lines.length, mtime)) {
|
|
74424
74482
|
if (transcriptWorkspace) msg.workspace = transcriptWorkspace;
|
|
74425
74483
|
messages.push(msg);
|
|
74426
74484
|
}
|
|
@@ -74445,11 +74503,22 @@ ${body}
|
|
|
74445
74503
|
const workspaceHint = typeof input.workspace === "string" && input.workspace.trim() ? input.workspace.trim() : "";
|
|
74446
74504
|
let sourcePath = null;
|
|
74447
74505
|
if (resolved.includes("*")) {
|
|
74448
|
-
|
|
74506
|
+
if (src.session_id_from === "dir_uuid" || src.workspace_from_sidecar) {
|
|
74507
|
+
sourcePath = pickDirUuidFileAcrossGlob(resolved, filePat, requestedSessionId);
|
|
74508
|
+
if (!sourcePath && !requestedSessionId) {
|
|
74509
|
+
if (src.workspace_from_sidecar && workspaceHint) {
|
|
74510
|
+
sourcePath = pickSidecarWorkspaceFileAcrossGlob(resolved, filePat, windowMs, sessionFloor, workspaceHint, src.workspace_from_sidecar);
|
|
74511
|
+
} else {
|
|
74512
|
+
sourcePath = newestRecentFileAcrossGlob(resolved, filePat, windowMs, sessionFloor);
|
|
74513
|
+
}
|
|
74514
|
+
}
|
|
74515
|
+
} else {
|
|
74516
|
+
sourcePath = pickExactSessionFileAcrossGlob(resolved, filePat, requestedSessionId) || pickSessionBoundFileAcrossGlob(resolved, filePat, windowMs, sessionFloor, workspaceHint) || newestRecentFileAcrossGlob(resolved, filePat, windowMs, sessionFloor);
|
|
74517
|
+
}
|
|
74449
74518
|
} else {
|
|
74450
74519
|
let stat2 = null;
|
|
74451
74520
|
try {
|
|
74452
|
-
stat2 =
|
|
74521
|
+
stat2 = fs18.statSync(resolved);
|
|
74453
74522
|
} catch {
|
|
74454
74523
|
}
|
|
74455
74524
|
if (stat2 && stat2.isFile()) {
|
|
@@ -74464,7 +74533,7 @@ ${body}
|
|
|
74464
74533
|
const resolvedRaw = expandPath2(src.path, input, { skipWorkspaceRealpath: true });
|
|
74465
74534
|
if (resolvedRaw && resolvedRaw !== resolved) {
|
|
74466
74535
|
try {
|
|
74467
|
-
const rawStat =
|
|
74536
|
+
const rawStat = fs18.statSync(resolvedRaw);
|
|
74468
74537
|
if (rawStat.isFile()) sourcePath = resolvedRaw;
|
|
74469
74538
|
else if (rawStat.isDirectory()) {
|
|
74470
74539
|
sourcePath = pickExactSessionFile(resolvedRaw, filePat, requestedSessionId) || (requestedSessionId ? null : newestRecentFile(resolvedRaw, filePat, windowMs, sessionFloor));
|
|
@@ -74487,12 +74556,61 @@ ${body}
|
|
|
74487
74556
|
}
|
|
74488
74557
|
return void 0;
|
|
74489
74558
|
}
|
|
74559
|
+
function readSidecarWorkspace(sourcePath, cfg) {
|
|
74560
|
+
try {
|
|
74561
|
+
const sidecar = path24.resolve(path24.dirname(sourcePath), cfg.rel_path);
|
|
74562
|
+
const parsed = JSON.parse(fs18.readFileSync(sidecar, "utf8"));
|
|
74563
|
+
const v = jsonPathGet(parsed, cfg.workspace_path);
|
|
74564
|
+
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
74565
|
+
} catch {
|
|
74566
|
+
return void 0;
|
|
74567
|
+
}
|
|
74568
|
+
}
|
|
74569
|
+
function dirUuid(filePath) {
|
|
74570
|
+
const segs = path24.dirname(filePath).split(path24.sep);
|
|
74571
|
+
for (let i = segs.length - 1; i >= 0; i -= 1) {
|
|
74572
|
+
const m = segs[i].match(UUID_RE);
|
|
74573
|
+
if (m) return m[1];
|
|
74574
|
+
}
|
|
74575
|
+
return "";
|
|
74576
|
+
}
|
|
74577
|
+
function sameSessionUuid(a, b) {
|
|
74578
|
+
if (a === b) return true;
|
|
74579
|
+
const ua = a.match(UUID_RE)?.[1]?.toLowerCase();
|
|
74580
|
+
const ub = b.match(UUID_RE)?.[1]?.toLowerCase();
|
|
74581
|
+
return !!ua && !!ub && ua === ub;
|
|
74582
|
+
}
|
|
74583
|
+
function compileRecordShapes(src) {
|
|
74584
|
+
if (Array.isArray(src.records) && src.records.length > 0) {
|
|
74585
|
+
const compiled = src.records.map((r) => ({
|
|
74586
|
+
where: r.where ? compileWhere(r.where) : null,
|
|
74587
|
+
map: r.message_map
|
|
74588
|
+
}));
|
|
74589
|
+
return {
|
|
74590
|
+
pick: (record2) => {
|
|
74591
|
+
for (const shape of compiled) {
|
|
74592
|
+
if (!shape.where || shape.where(record2)) return { map: shape.map };
|
|
74593
|
+
}
|
|
74594
|
+
return null;
|
|
74595
|
+
}
|
|
74596
|
+
};
|
|
74597
|
+
}
|
|
74598
|
+
const filter = src.message_filter ? compileWhere(src.message_filter.where) : null;
|
|
74599
|
+
const map2 = src.message_map;
|
|
74600
|
+
return {
|
|
74601
|
+
pick: (record2) => {
|
|
74602
|
+
if (!map2) return null;
|
|
74603
|
+
if (filter && !filter(record2)) return null;
|
|
74604
|
+
return { map: map2 };
|
|
74605
|
+
}
|
|
74606
|
+
};
|
|
74607
|
+
}
|
|
74490
74608
|
function workspaceFromInputIfSlugMatches(sourcePath, input) {
|
|
74491
74609
|
const wsRaw = typeof input.workspace === "string" ? input.workspace.trim() : "";
|
|
74492
74610
|
if (!wsRaw) return void 0;
|
|
74493
74611
|
let wsReal = wsRaw;
|
|
74494
74612
|
try {
|
|
74495
|
-
wsReal =
|
|
74613
|
+
wsReal = fs18.realpathSync(wsRaw);
|
|
74496
74614
|
} catch {
|
|
74497
74615
|
}
|
|
74498
74616
|
const slugs = /* @__PURE__ */ new Set();
|
|
@@ -74516,7 +74634,7 @@ ${body}
|
|
|
74516
74634
|
function readJsonlLines(p) {
|
|
74517
74635
|
let text;
|
|
74518
74636
|
try {
|
|
74519
|
-
text =
|
|
74637
|
+
text = fs18.readFileSync(p, "utf8");
|
|
74520
74638
|
} catch {
|
|
74521
74639
|
return [];
|
|
74522
74640
|
}
|
|
@@ -74533,7 +74651,7 @@ ${body}
|
|
|
74533
74651
|
}
|
|
74534
74652
|
function executeSqlite(src, input) {
|
|
74535
74653
|
const resolved = expandPath2(src.path, input);
|
|
74536
|
-
if (!resolved || !
|
|
74654
|
+
if (!resolved || !fs18.existsSync(resolved)) return null;
|
|
74537
74655
|
let Database;
|
|
74538
74656
|
try {
|
|
74539
74657
|
Database = loadBetterSqlite3();
|
|
@@ -74672,7 +74790,7 @@ ${body}
|
|
|
74672
74790
|
let workspaceResolved = workspaceRaw;
|
|
74673
74791
|
if (workspaceRaw && !opts?.skipWorkspaceRealpath) {
|
|
74674
74792
|
try {
|
|
74675
|
-
workspaceResolved =
|
|
74793
|
+
workspaceResolved = fs18.realpathSync(workspaceRaw);
|
|
74676
74794
|
} catch {
|
|
74677
74795
|
}
|
|
74678
74796
|
}
|
|
@@ -74711,7 +74829,7 @@ ${body}
|
|
|
74711
74829
|
if (!base) return null;
|
|
74712
74830
|
let baseStat = null;
|
|
74713
74831
|
try {
|
|
74714
|
-
baseStat =
|
|
74832
|
+
baseStat = fs18.statSync(base);
|
|
74715
74833
|
} catch {
|
|
74716
74834
|
return null;
|
|
74717
74835
|
}
|
|
@@ -74719,7 +74837,7 @@ ${body}
|
|
|
74719
74837
|
const needle = `${requestedSessionId.toLowerCase()}.jsonl`;
|
|
74720
74838
|
const dirsToScan = [base];
|
|
74721
74839
|
try {
|
|
74722
|
-
for (const entry of
|
|
74840
|
+
for (const entry of fs18.readdirSync(base, { withFileTypes: true })) {
|
|
74723
74841
|
if (entry.isDirectory()) dirsToScan.push(path24.join(base, entry.name));
|
|
74724
74842
|
}
|
|
74725
74843
|
} catch {
|
|
@@ -74727,7 +74845,7 @@ ${body}
|
|
|
74727
74845
|
for (const dir of dirsToScan) {
|
|
74728
74846
|
let entries;
|
|
74729
74847
|
try {
|
|
74730
|
-
entries =
|
|
74848
|
+
entries = fs18.readdirSync(dir, { withFileTypes: true });
|
|
74731
74849
|
} catch {
|
|
74732
74850
|
continue;
|
|
74733
74851
|
}
|
|
@@ -74762,7 +74880,7 @@ ${body}
|
|
|
74762
74880
|
for (const d of dirs) {
|
|
74763
74881
|
let entries;
|
|
74764
74882
|
try {
|
|
74765
|
-
entries =
|
|
74883
|
+
entries = fs18.readdirSync(d, { withFileTypes: true });
|
|
74766
74884
|
} catch {
|
|
74767
74885
|
continue;
|
|
74768
74886
|
}
|
|
@@ -74775,7 +74893,7 @@ ${body}
|
|
|
74775
74893
|
const candidate = path24.join(d, seg);
|
|
74776
74894
|
let stat2 = null;
|
|
74777
74895
|
try {
|
|
74778
|
-
stat2 =
|
|
74896
|
+
stat2 = fs18.statSync(candidate);
|
|
74779
74897
|
} catch {
|
|
74780
74898
|
continue;
|
|
74781
74899
|
}
|
|
@@ -74789,7 +74907,7 @@ ${body}
|
|
|
74789
74907
|
function walkAllDirs(root, out) {
|
|
74790
74908
|
let entries;
|
|
74791
74909
|
try {
|
|
74792
|
-
entries =
|
|
74910
|
+
entries = fs18.readdirSync(root, { withFileTypes: true });
|
|
74793
74911
|
} catch {
|
|
74794
74912
|
return;
|
|
74795
74913
|
}
|
|
@@ -74805,7 +74923,7 @@ ${body}
|
|
|
74805
74923
|
for (const d of dirs) {
|
|
74806
74924
|
let entries;
|
|
74807
74925
|
try {
|
|
74808
|
-
entries =
|
|
74926
|
+
entries = fs18.readdirSync(d, { withFileTypes: true });
|
|
74809
74927
|
} catch {
|
|
74810
74928
|
continue;
|
|
74811
74929
|
}
|
|
@@ -74832,7 +74950,7 @@ ${body}
|
|
|
74832
74950
|
if (!resolved) continue;
|
|
74833
74951
|
let entries;
|
|
74834
74952
|
try {
|
|
74835
|
-
entries =
|
|
74953
|
+
entries = fs18.readdirSync(resolved, { withFileTypes: true });
|
|
74836
74954
|
} catch {
|
|
74837
74955
|
continue;
|
|
74838
74956
|
}
|
|
@@ -74861,7 +74979,7 @@ ${body}
|
|
|
74861
74979
|
let workspaceResolved = workspaceRaw;
|
|
74862
74980
|
if (workspaceRaw) {
|
|
74863
74981
|
try {
|
|
74864
|
-
workspaceResolved =
|
|
74982
|
+
workspaceResolved = fs18.realpathSync(workspaceRaw);
|
|
74865
74983
|
} catch {
|
|
74866
74984
|
}
|
|
74867
74985
|
}
|
|
@@ -74886,7 +75004,7 @@ ${body}
|
|
|
74886
75004
|
function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
|
|
74887
75005
|
let entries;
|
|
74888
75006
|
try {
|
|
74889
|
-
entries =
|
|
75007
|
+
entries = fs18.readdirSync(dir, { withFileTypes: true });
|
|
74890
75008
|
} catch {
|
|
74891
75009
|
return null;
|
|
74892
75010
|
}
|
|
@@ -74903,7 +75021,7 @@ ${body}
|
|
|
74903
75021
|
}
|
|
74904
75022
|
function safeMtimeMs(p) {
|
|
74905
75023
|
try {
|
|
74906
|
-
return Math.floor(
|
|
75024
|
+
return Math.floor(fs18.statSync(p).mtimeMs);
|
|
74907
75025
|
} catch {
|
|
74908
75026
|
return 0;
|
|
74909
75027
|
}
|
|
@@ -74933,6 +75051,47 @@ ${body}
|
|
|
74933
75051
|
matches.sort((a, b) => safeMtimeMs(b) - safeMtimeMs(a));
|
|
74934
75052
|
return matches[0] || null;
|
|
74935
75053
|
}
|
|
75054
|
+
function pickDirUuidFileAcrossGlob(template, pattern, requestedSessionId) {
|
|
75055
|
+
if (!requestedSessionId) return null;
|
|
75056
|
+
const wantUuid = requestedSessionId.match(UUID_RE)?.[1]?.toLowerCase();
|
|
75057
|
+
if (!wantUuid) return null;
|
|
75058
|
+
const dirs = expandDirGlob(template);
|
|
75059
|
+
const matches = [];
|
|
75060
|
+
for (const d of dirs) {
|
|
75061
|
+
for (const p of listMatchingFiles(d, pattern)) {
|
|
75062
|
+
if (dirUuid(p).toLowerCase() === wantUuid) matches.push(p);
|
|
75063
|
+
}
|
|
75064
|
+
}
|
|
75065
|
+
matches.sort((a, b) => safeMtimeMs(b) - safeMtimeMs(a));
|
|
75066
|
+
return matches[0] || null;
|
|
75067
|
+
}
|
|
75068
|
+
function pickSidecarWorkspaceFileAcrossGlob(template, pattern, windowMs, sessionFloorMs, workspaceHint, sidecar) {
|
|
75069
|
+
if (!sidecar || !workspaceHint) return null;
|
|
75070
|
+
let wsResolved = workspaceHint;
|
|
75071
|
+
try {
|
|
75072
|
+
wsResolved = fs18.realpathSync(workspaceHint);
|
|
75073
|
+
} catch {
|
|
75074
|
+
}
|
|
75075
|
+
const dirs = expandDirGlob(template);
|
|
75076
|
+
const cutoff = Math.max(Date.now() - windowMs, sessionFloorMs);
|
|
75077
|
+
let best = null;
|
|
75078
|
+
for (const d of dirs) {
|
|
75079
|
+
for (const p of listMatchingFiles(d, pattern)) {
|
|
75080
|
+
const mtime = safeMtimeMs(p);
|
|
75081
|
+
if (mtime < cutoff) continue;
|
|
75082
|
+
const ws = readSidecarWorkspace(p, sidecar);
|
|
75083
|
+
if (!ws) continue;
|
|
75084
|
+
let wsReal = ws;
|
|
75085
|
+
try {
|
|
75086
|
+
wsReal = fs18.realpathSync(ws);
|
|
75087
|
+
} catch {
|
|
75088
|
+
}
|
|
75089
|
+
if (ws !== workspaceHint && wsReal !== wsResolved) continue;
|
|
75090
|
+
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
75091
|
+
}
|
|
75092
|
+
}
|
|
75093
|
+
return best ? best.p : null;
|
|
75094
|
+
}
|
|
74936
75095
|
function pickExactSessionFileAcrossDateWindow(template, input, pattern, requestedSessionId) {
|
|
74937
75096
|
if (!requestedSessionId) return null;
|
|
74938
75097
|
const matches = [];
|
|
@@ -74948,10 +75107,10 @@ ${body}
|
|
|
74948
75107
|
}
|
|
74949
75108
|
function readCandidateSessionMeta(filePath) {
|
|
74950
75109
|
try {
|
|
74951
|
-
const fd =
|
|
75110
|
+
const fd = fs18.openSync(filePath, "r");
|
|
74952
75111
|
try {
|
|
74953
75112
|
const buf = Buffer.alloc(8192);
|
|
74954
|
-
const bytes =
|
|
75113
|
+
const bytes = fs18.readSync(fd, buf, 0, buf.length, 0);
|
|
74955
75114
|
if (bytes <= 0) return null;
|
|
74956
75115
|
const text = buf.subarray(0, bytes).toString("utf8");
|
|
74957
75116
|
const nl = text.indexOf("\n");
|
|
@@ -74969,7 +75128,7 @@ ${body}
|
|
|
74969
75128
|
sessionTimestampMs: Number.isFinite(tsMs) ? tsMs : void 0
|
|
74970
75129
|
};
|
|
74971
75130
|
} finally {
|
|
74972
|
-
|
|
75131
|
+
fs18.closeSync(fd);
|
|
74973
75132
|
}
|
|
74974
75133
|
} catch {
|
|
74975
75134
|
return null;
|
|
@@ -74979,7 +75138,7 @@ ${body}
|
|
|
74979
75138
|
if (!sessionFloorMs || !workspaceHint || candidatePaths.length === 0) return null;
|
|
74980
75139
|
let workspaceResolved = workspaceHint;
|
|
74981
75140
|
try {
|
|
74982
|
-
workspaceResolved =
|
|
75141
|
+
workspaceResolved = fs18.realpathSync(workspaceHint);
|
|
74983
75142
|
} catch {
|
|
74984
75143
|
}
|
|
74985
75144
|
let best = null;
|
|
@@ -74988,7 +75147,7 @@ ${body}
|
|
|
74988
75147
|
if (!meta3 || !meta3.cwd || meta3.sessionTimestampMs == null) continue;
|
|
74989
75148
|
let candidateCwd = meta3.cwd;
|
|
74990
75149
|
try {
|
|
74991
|
-
candidateCwd =
|
|
75150
|
+
candidateCwd = fs18.realpathSync(meta3.cwd);
|
|
74992
75151
|
} catch {
|
|
74993
75152
|
}
|
|
74994
75153
|
if (candidateCwd !== workspaceResolved && meta3.cwd !== workspaceHint) continue;
|
|
@@ -75001,7 +75160,7 @@ ${body}
|
|
|
75001
75160
|
function listMatchingFiles(dir, pattern) {
|
|
75002
75161
|
let entries;
|
|
75003
75162
|
try {
|
|
75004
|
-
entries =
|
|
75163
|
+
entries = fs18.readdirSync(dir, { withFileTypes: true });
|
|
75005
75164
|
} catch {
|
|
75006
75165
|
return [];
|
|
75007
75166
|
}
|
|
@@ -75293,7 +75452,7 @@ ${body}
|
|
|
75293
75452
|
}
|
|
75294
75453
|
return t.negate ? !result : result;
|
|
75295
75454
|
}
|
|
75296
|
-
var
|
|
75455
|
+
var fs19 = __toESM2(require("fs"));
|
|
75297
75456
|
init_logger();
|
|
75298
75457
|
var EMPTY = { active: false, count: 0, ids: [] };
|
|
75299
75458
|
var TAIL_BYTES = 512 * 1024;
|
|
@@ -75355,19 +75514,19 @@ ${body}
|
|
|
75355
75514
|
return { active: true, count: unresolved.length, ids: unresolved };
|
|
75356
75515
|
}
|
|
75357
75516
|
function readTailJsonlLines(filePath, maxBytes) {
|
|
75358
|
-
const stat2 =
|
|
75517
|
+
const stat2 = fs19.statSync(filePath);
|
|
75359
75518
|
const size = stat2.size;
|
|
75360
75519
|
const start = size > maxBytes ? size - maxBytes : 0;
|
|
75361
75520
|
const length = size - start;
|
|
75362
75521
|
if (length <= 0) return [];
|
|
75363
|
-
const fd =
|
|
75522
|
+
const fd = fs19.openSync(filePath, "r");
|
|
75364
75523
|
let text;
|
|
75365
75524
|
try {
|
|
75366
75525
|
const buf = Buffer.alloc(length);
|
|
75367
|
-
const bytes =
|
|
75526
|
+
const bytes = fs19.readSync(fd, buf, 0, length, start);
|
|
75368
75527
|
text = buf.subarray(0, bytes).toString("utf8");
|
|
75369
75528
|
} finally {
|
|
75370
|
-
|
|
75529
|
+
fs19.closeSync(fd);
|
|
75371
75530
|
}
|
|
75372
75531
|
const rawLines = text.split("\n");
|
|
75373
75532
|
if (start > 0 && rawLines.length > 0) rawLines.shift();
|
|
@@ -75382,13 +75541,13 @@ ${body}
|
|
|
75382
75541
|
}
|
|
75383
75542
|
return out;
|
|
75384
75543
|
}
|
|
75385
|
-
var
|
|
75544
|
+
var fs20 = __toESM2(require("fs"));
|
|
75386
75545
|
init_logger();
|
|
75387
75546
|
function stripAnsi3(text) {
|
|
75388
75547
|
return String(text || "").replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
75389
75548
|
}
|
|
75390
75549
|
function delay(ms) {
|
|
75391
|
-
return new Promise((
|
|
75550
|
+
return new Promise((resolve26) => setTimeout(resolve26, ms));
|
|
75392
75551
|
}
|
|
75393
75552
|
var SpecCliAdapter = class _SpecCliAdapter {
|
|
75394
75553
|
cliType;
|
|
@@ -75452,7 +75611,7 @@ ${body}
|
|
|
75452
75611
|
* hermes ships a runtime MCP override. */
|
|
75453
75612
|
spawnedEnv = {};
|
|
75454
75613
|
constructor(specPath, workingDir, cliArgs, extraEnv, transportFactory) {
|
|
75455
|
-
const raw = JSON.parse(
|
|
75614
|
+
const raw = JSON.parse(fs20.readFileSync(specPath, "utf8"));
|
|
75456
75615
|
this.spec = {
|
|
75457
75616
|
id: raw.id,
|
|
75458
75617
|
name: raw.name,
|
|
@@ -75604,7 +75763,7 @@ ${body}
|
|
|
75604
75763
|
const steps = buildClaudeInteractiveTuiAnswerSteps(prompt, response);
|
|
75605
75764
|
for (const step of steps) {
|
|
75606
75765
|
this.driver.dispatch({ kind: "pty_write", data: step });
|
|
75607
|
-
await new Promise((
|
|
75766
|
+
await new Promise((resolve26) => setTimeout(resolve26, 180));
|
|
75608
75767
|
}
|
|
75609
75768
|
} else {
|
|
75610
75769
|
this.driver.dispatch({ kind: "pty_write", data: `${buildClaudeInteractiveToolResult(response)}
|
|
@@ -76160,7 +76319,7 @@ ${body}
|
|
|
76160
76319
|
let screenText = this.driver.snapshot();
|
|
76161
76320
|
const deadline = Date.now() + _SpecCliAdapter.CLAUDE_TUI_PAGE_SETTLE_TIMEOUT_MS;
|
|
76162
76321
|
while (!detectClaudeTuiMultiSelect(screenText) && Date.now() < deadline) {
|
|
76163
|
-
await new Promise((
|
|
76322
|
+
await new Promise((resolve26) => setTimeout(resolve26, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
76164
76323
|
screenText = this.driver.snapshot();
|
|
76165
76324
|
}
|
|
76166
76325
|
return screenText;
|
|
@@ -76169,12 +76328,12 @@ ${body}
|
|
|
76169
76328
|
const pages = [{ screenText: firstScreen, header: headers[0] }];
|
|
76170
76329
|
for (let index = 1; index < headers.length; index += 1) {
|
|
76171
76330
|
this.driver.dispatch({ kind: "pty_write", data: " " });
|
|
76172
|
-
await new Promise((
|
|
76331
|
+
await new Promise((resolve26) => setTimeout(resolve26, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
76173
76332
|
pages.push({ screenText: await this.snapshotSettledClaudeTuiPage(), header: headers[index] });
|
|
76174
76333
|
}
|
|
76175
76334
|
for (let index = headers.length - 1; index > 0; index -= 1) {
|
|
76176
76335
|
this.driver.dispatch({ kind: "pty_write", data: "\x1B[Z" });
|
|
76177
|
-
await new Promise((
|
|
76336
|
+
await new Promise((resolve26) => setTimeout(resolve26, _SpecCliAdapter.CLAUDE_TUI_PAGE_POLL_INTERVAL_MS));
|
|
76178
76337
|
const reread = await this.snapshotSettledClaudeTuiPage();
|
|
76179
76338
|
const landed = pages[index - 1];
|
|
76180
76339
|
if (landed && !detectClaudeTuiMultiSelect(landed.screenText) && detectClaudeTuiMultiSelect(reread)) {
|
|
@@ -76272,10 +76431,10 @@ ${body}
|
|
|
76272
76431
|
function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory) {
|
|
76273
76432
|
const resolvedSpecPath = provider._resolvedSpecPath;
|
|
76274
76433
|
const dir = provider._resolvedProviderDir;
|
|
76275
|
-
let specPath = resolvedSpecPath &&
|
|
76434
|
+
let specPath = resolvedSpecPath && fs21.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
|
|
76276
76435
|
if (!specPath && dir) {
|
|
76277
76436
|
const legacy = path25.join(dir, "spec.json");
|
|
76278
|
-
if (
|
|
76437
|
+
if (fs21.existsSync(legacy)) specPath = legacy;
|
|
76279
76438
|
}
|
|
76280
76439
|
if (specPath) {
|
|
76281
76440
|
try {
|
|
@@ -76350,7 +76509,7 @@ ${body}
|
|
|
76350
76509
|
var os20 = __toESM2(require("os"));
|
|
76351
76510
|
var path26 = __toESM2(require("path"));
|
|
76352
76511
|
var crypto4 = __toESM2(require("crypto"));
|
|
76353
|
-
var
|
|
76512
|
+
var fs222 = __toESM2(require("fs"));
|
|
76354
76513
|
var IMAGE_MIME_EXTENSIONS = {
|
|
76355
76514
|
"image/png": ".png",
|
|
76356
76515
|
"image/jpeg": ".jpg",
|
|
@@ -76385,9 +76544,9 @@ ${body}
|
|
|
76385
76544
|
if (!part.data) return null;
|
|
76386
76545
|
const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
|
|
76387
76546
|
if (!rawData) return null;
|
|
76388
|
-
|
|
76547
|
+
fs222.mkdirSync(dir, { recursive: true });
|
|
76389
76548
|
const filePath = path26.join(dir, safeInputImageBasename(index, part.mimeType));
|
|
76390
|
-
|
|
76549
|
+
fs222.writeFileSync(filePath, Buffer.from(rawData, "base64"));
|
|
76391
76550
|
cleanupStaleMaterializedImages(dir);
|
|
76392
76551
|
return filePath;
|
|
76393
76552
|
}
|
|
@@ -76399,14 +76558,14 @@ ${body}
|
|
|
76399
76558
|
if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
|
|
76400
76559
|
lastMaterializedImageCleanupAt = now;
|
|
76401
76560
|
try {
|
|
76402
|
-
const entries =
|
|
76561
|
+
const entries = fs222.readdirSync(dir);
|
|
76403
76562
|
for (const entry of entries) {
|
|
76404
76563
|
if (!entry.startsWith("adhdev-input-image-")) continue;
|
|
76405
76564
|
const fullPath = path26.join(dir, entry);
|
|
76406
76565
|
try {
|
|
76407
|
-
const stat2 =
|
|
76566
|
+
const stat2 = fs222.statSync(fullPath);
|
|
76408
76567
|
if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
|
|
76409
|
-
|
|
76568
|
+
fs222.unlinkSync(fullPath);
|
|
76410
76569
|
}
|
|
76411
76570
|
} catch {
|
|
76412
76571
|
}
|
|
@@ -76549,7 +76708,7 @@ ${body}
|
|
|
76549
76708
|
if (status === "stopped") {
|
|
76550
76709
|
throw new Error("CLI runtime stopped before it became ready");
|
|
76551
76710
|
}
|
|
76552
|
-
await new Promise((
|
|
76711
|
+
await new Promise((resolve26) => setTimeout(resolve26, pollMs));
|
|
76553
76712
|
}
|
|
76554
76713
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
76555
76714
|
}
|
|
@@ -77055,7 +77214,7 @@ ${body}
|
|
|
77055
77214
|
const resolvedDbPath = probe.dbPath.replace(/^~/, os21.homedir());
|
|
77056
77215
|
const now = Date.now();
|
|
77057
77216
|
if (this.cachedSqliteDbMissingUntil > now) return null;
|
|
77058
|
-
if (!
|
|
77217
|
+
if (!fs23.existsSync(resolvedDbPath)) {
|
|
77059
77218
|
this.cachedSqliteDbMissingUntil = now + 1e4;
|
|
77060
77219
|
return null;
|
|
77061
77220
|
}
|
|
@@ -77639,7 +77798,7 @@ ${body}
|
|
|
77639
77798
|
const enterCount = cliCommand.enterCount || 1;
|
|
77640
77799
|
await this.adapter.writeRaw(cliCommand.text + "\r");
|
|
77641
77800
|
for (let i = 1; i < enterCount; i += 1) {
|
|
77642
|
-
await new Promise((
|
|
77801
|
+
await new Promise((resolve26) => setTimeout(resolve26, 50));
|
|
77643
77802
|
await this.adapter.writeRaw("\r");
|
|
77644
77803
|
}
|
|
77645
77804
|
}
|
|
@@ -77733,7 +77892,7 @@ ${body}
|
|
|
77733
77892
|
}
|
|
77734
77893
|
if (this.lastExternalCompletionProbe?.sourcePath) {
|
|
77735
77894
|
try {
|
|
77736
|
-
|
|
77895
|
+
fs23.statSync(this.lastExternalCompletionProbe.sourcePath);
|
|
77737
77896
|
} catch {
|
|
77738
77897
|
}
|
|
77739
77898
|
}
|
|
@@ -79429,7 +79588,7 @@ ${buttons.join("\n")}`;
|
|
|
79429
79588
|
};
|
|
79430
79589
|
addDir(this.workingDir);
|
|
79431
79590
|
try {
|
|
79432
|
-
addDir(
|
|
79591
|
+
addDir(fs23.realpathSync.native(this.workingDir));
|
|
79433
79592
|
} catch {
|
|
79434
79593
|
}
|
|
79435
79594
|
return Array.from(dirs);
|
|
@@ -80097,13 +80256,13 @@ ${buttons.join("\n")}`;
|
|
|
80097
80256
|
}
|
|
80098
80257
|
this.currentStatus = "waiting_approval";
|
|
80099
80258
|
this.detectStatusTransition();
|
|
80100
|
-
const approved = await new Promise((
|
|
80101
|
-
this.permissionResolvers.push(
|
|
80259
|
+
const approved = await new Promise((resolve26) => {
|
|
80260
|
+
this.permissionResolvers.push(resolve26);
|
|
80102
80261
|
setTimeout(() => {
|
|
80103
|
-
const idx = this.permissionResolvers.indexOf(
|
|
80262
|
+
const idx = this.permissionResolvers.indexOf(resolve26);
|
|
80104
80263
|
if (idx >= 0) {
|
|
80105
80264
|
this.permissionResolvers.splice(idx, 1);
|
|
80106
|
-
|
|
80265
|
+
resolve26(false);
|
|
80107
80266
|
}
|
|
80108
80267
|
}, 3e5);
|
|
80109
80268
|
});
|
|
@@ -80833,7 +80992,7 @@ ${rawInput}` : rawInput;
|
|
|
80833
80992
|
} catch {
|
|
80834
80993
|
return false;
|
|
80835
80994
|
}
|
|
80836
|
-
await new Promise((
|
|
80995
|
+
await new Promise((resolve26) => setTimeout(resolve26, ZERO_MESSAGE_STARTING_SEND_WAIT_MS));
|
|
80837
80996
|
try {
|
|
80838
80997
|
return hasZeroMessageStartingLaunch(adapter);
|
|
80839
80998
|
} catch {
|
|
@@ -82142,7 +82301,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82142
82301
|
var net3 = __toESM2(require("net"));
|
|
82143
82302
|
var os27 = __toESM2(require("os"));
|
|
82144
82303
|
var path37 = __toESM2(require("path"));
|
|
82145
|
-
var
|
|
82304
|
+
var fs29 = __toESM2(require("fs"));
|
|
82146
82305
|
var path36 = __toESM2(require("path"));
|
|
82147
82306
|
var os26 = __toESM2(require("os"));
|
|
82148
82307
|
var chokidar = __toESM2(require_chokidar());
|
|
@@ -82536,10 +82695,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82536
82695
|
}
|
|
82537
82696
|
}
|
|
82538
82697
|
init_external_sources();
|
|
82539
|
-
var
|
|
82698
|
+
var fs28 = __toESM2(require("fs"));
|
|
82540
82699
|
var os25 = __toESM2(require("os"));
|
|
82541
82700
|
var path34 = __toESM2(require("path"));
|
|
82542
|
-
var
|
|
82701
|
+
var fs24 = __toESM2(require("fs"));
|
|
82543
82702
|
var path30 = __toESM2(require("path"));
|
|
82544
82703
|
function extractTimestampValue(value) {
|
|
82545
82704
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
@@ -82553,7 +82712,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82553
82712
|
}
|
|
82554
82713
|
function statMtimeMs(filePath) {
|
|
82555
82714
|
try {
|
|
82556
|
-
return
|
|
82715
|
+
return fs24.statSync(filePath).mtimeMs;
|
|
82557
82716
|
} catch {
|
|
82558
82717
|
return 0;
|
|
82559
82718
|
}
|
|
@@ -82623,7 +82782,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82623
82782
|
function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
|
|
82624
82783
|
let raw;
|
|
82625
82784
|
try {
|
|
82626
|
-
raw =
|
|
82785
|
+
raw = fs24.readFileSync(filePath, "utf-8");
|
|
82627
82786
|
} catch {
|
|
82628
82787
|
return [];
|
|
82629
82788
|
}
|
|
@@ -82699,7 +82858,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82699
82858
|
if (!sessionPath || !path30.isAbsolute(sessionPath)) return null;
|
|
82700
82859
|
const basename14 = path30.basename(sessionPath, ".jsonl");
|
|
82701
82860
|
if (!isSafeSessionId(basename14)) return null;
|
|
82702
|
-
if (!
|
|
82861
|
+
if (!fs24.existsSync(sessionPath)) return null;
|
|
82703
82862
|
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
82704
82863
|
const messages = parseTranscriptFile(sessionPath, basename14);
|
|
82705
82864
|
if (messages.length === 0) return null;
|
|
@@ -82715,7 +82874,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82715
82874
|
workspace
|
|
82716
82875
|
};
|
|
82717
82876
|
}
|
|
82718
|
-
var
|
|
82877
|
+
var fs25 = __toESM2(require("fs"));
|
|
82719
82878
|
var path31 = __toESM2(require("path"));
|
|
82720
82879
|
function extractTimestampValue2(value) {
|
|
82721
82880
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
@@ -82729,7 +82888,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82729
82888
|
}
|
|
82730
82889
|
function statMtimeMs2(filePath) {
|
|
82731
82890
|
try {
|
|
82732
|
-
return
|
|
82891
|
+
return fs25.statSync(filePath).mtimeMs;
|
|
82733
82892
|
} catch {
|
|
82734
82893
|
return 0;
|
|
82735
82894
|
}
|
|
@@ -82826,7 +82985,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82826
82985
|
}
|
|
82827
82986
|
function readSessionMeta(filePath) {
|
|
82828
82987
|
try {
|
|
82829
|
-
const firstLine =
|
|
82988
|
+
const firstLine = fs25.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
|
|
82830
82989
|
if (!firstLine) return null;
|
|
82831
82990
|
const parsed = JSON.parse(firstLine);
|
|
82832
82991
|
if (String(parsed.type ?? "") !== "session_meta") return null;
|
|
@@ -82838,7 +82997,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82838
82997
|
function parseSessionFile(filePath, sessionId, workspaceFallback) {
|
|
82839
82998
|
let raw;
|
|
82840
82999
|
try {
|
|
82841
|
-
raw =
|
|
83000
|
+
raw = fs25.readFileSync(filePath, "utf-8");
|
|
82842
83001
|
} catch {
|
|
82843
83002
|
return [];
|
|
82844
83003
|
}
|
|
@@ -82954,7 +83113,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82954
83113
|
}
|
|
82955
83114
|
function readSession2(sessionPath) {
|
|
82956
83115
|
if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
|
|
82957
|
-
if (!
|
|
83116
|
+
if (!fs25.existsSync(sessionPath)) return null;
|
|
82958
83117
|
const meta3 = readSessionMeta(sessionPath);
|
|
82959
83118
|
const metaId = String(meta3?.id ?? "").trim();
|
|
82960
83119
|
const basename14 = path31.basename(sessionPath, ".jsonl");
|
|
@@ -82979,7 +83138,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82979
83138
|
workspace
|
|
82980
83139
|
};
|
|
82981
83140
|
}
|
|
82982
|
-
var
|
|
83141
|
+
var fs26 = __toESM2(require("fs"));
|
|
82983
83142
|
var path322 = __toESM2(require("path"));
|
|
82984
83143
|
var os23 = __toESM2(require("os"));
|
|
82985
83144
|
init_load_better_sqlite3();
|
|
@@ -82996,7 +83155,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
82996
83155
|
}
|
|
82997
83156
|
function statMtimeMs3(filePath) {
|
|
82998
83157
|
try {
|
|
82999
|
-
return
|
|
83158
|
+
return fs26.statSync(filePath).mtimeMs;
|
|
83000
83159
|
} catch {
|
|
83001
83160
|
return 0;
|
|
83002
83161
|
}
|
|
@@ -83025,12 +83184,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83025
83184
|
function findBrainTranscriptPath(sessionId) {
|
|
83026
83185
|
if (!isUuidLike(sessionId)) return null;
|
|
83027
83186
|
const logsRoot = resolvePathInside(brainRoot(), sessionId, ".system_generated", "logs");
|
|
83028
|
-
if (!logsRoot || !
|
|
83029
|
-
const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null &&
|
|
83187
|
+
if (!logsRoot || !fs26.existsSync(logsRoot)) return null;
|
|
83188
|
+
const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file2) => resolvePathInside(logsRoot, file2)).filter((p) => p !== null && fs26.existsSync(p));
|
|
83030
83189
|
if (candidates.length === 0) {
|
|
83031
83190
|
let entries = [];
|
|
83032
83191
|
try {
|
|
83033
|
-
entries =
|
|
83192
|
+
entries = fs26.readdirSync(logsRoot, { withFileTypes: true });
|
|
83034
83193
|
} catch {
|
|
83035
83194
|
return null;
|
|
83036
83195
|
}
|
|
@@ -83056,7 +83215,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83056
83215
|
function parseBrainTranscript(filePath, sessionId, workspace) {
|
|
83057
83216
|
let raw;
|
|
83058
83217
|
try {
|
|
83059
|
-
raw =
|
|
83218
|
+
raw = fs26.readFileSync(filePath, "utf-8");
|
|
83060
83219
|
} catch {
|
|
83061
83220
|
return null;
|
|
83062
83221
|
}
|
|
@@ -83116,7 +83275,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83116
83275
|
const sourcePath = historyJsonlPath();
|
|
83117
83276
|
let lines = [];
|
|
83118
83277
|
try {
|
|
83119
|
-
lines =
|
|
83278
|
+
lines = fs26.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
83120
83279
|
} catch {
|
|
83121
83280
|
return [];
|
|
83122
83281
|
}
|
|
@@ -83164,7 +83323,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83164
83323
|
function parsePbFile(filePath, sessionId) {
|
|
83165
83324
|
let buf;
|
|
83166
83325
|
try {
|
|
83167
|
-
buf =
|
|
83326
|
+
buf = fs26.readFileSync(filePath);
|
|
83168
83327
|
} catch {
|
|
83169
83328
|
return null;
|
|
83170
83329
|
}
|
|
@@ -83512,7 +83671,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83512
83671
|
}
|
|
83513
83672
|
}
|
|
83514
83673
|
const pbPath = resolvePathInside(conversationsRoot(), `${sessionId}.pb`);
|
|
83515
|
-
if (pbPath &&
|
|
83674
|
+
if (pbPath && fs26.existsSync(pbPath)) {
|
|
83516
83675
|
const pbMessages = parsePbFile(pbPath, sessionId);
|
|
83517
83676
|
if (pbMessages && pbMessages.length > 0) {
|
|
83518
83677
|
return {
|
|
@@ -83531,7 +83690,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83531
83690
|
}
|
|
83532
83691
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
83533
83692
|
if (!sessionPath || !path322.isAbsolute(sessionPath)) return null;
|
|
83534
|
-
if (!
|
|
83693
|
+
if (!fs26.existsSync(sessionPath)) return null;
|
|
83535
83694
|
const sourceMtimeMs = statMtimeMs3(sessionPath);
|
|
83536
83695
|
const brainRootPath = brainRoot();
|
|
83537
83696
|
if (sessionPath.startsWith(brainRootPath + path322.sep) && sessionPath.endsWith(".jsonl")) {
|
|
@@ -83590,7 +83749,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83590
83749
|
}
|
|
83591
83750
|
return null;
|
|
83592
83751
|
}
|
|
83593
|
-
var
|
|
83752
|
+
var fs27 = __toESM2(require("fs"));
|
|
83594
83753
|
var path33 = __toESM2(require("path"));
|
|
83595
83754
|
var os24 = __toESM2(require("os"));
|
|
83596
83755
|
init_load_better_sqlite3();
|
|
@@ -83598,13 +83757,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83598
83757
|
var HERMES_LEGACY_SESSIONS_DIR = path33.join(os24.homedir(), ".hermes", "sessions");
|
|
83599
83758
|
function statMtimeMs4(p) {
|
|
83600
83759
|
try {
|
|
83601
|
-
return Math.floor(
|
|
83760
|
+
return Math.floor(fs27.statSync(p).mtimeMs);
|
|
83602
83761
|
} catch {
|
|
83603
83762
|
return 0;
|
|
83604
83763
|
}
|
|
83605
83764
|
}
|
|
83606
83765
|
function openDb() {
|
|
83607
|
-
if (!
|
|
83766
|
+
if (!fs27.existsSync(HERMES_STATE_DB)) return null;
|
|
83608
83767
|
try {
|
|
83609
83768
|
const Database = loadBetterSqlite3();
|
|
83610
83769
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
@@ -83700,10 +83859,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83700
83859
|
}
|
|
83701
83860
|
}
|
|
83702
83861
|
}
|
|
83703
|
-
if (!path33.isAbsolute(sessionPath) || !
|
|
83862
|
+
if (!path33.isAbsolute(sessionPath) || !fs27.existsSync(sessionPath)) return null;
|
|
83704
83863
|
let raw;
|
|
83705
83864
|
try {
|
|
83706
|
-
raw = JSON.parse(
|
|
83865
|
+
raw = JSON.parse(fs27.readFileSync(sessionPath, "utf8"));
|
|
83707
83866
|
} catch {
|
|
83708
83867
|
return null;
|
|
83709
83868
|
}
|
|
@@ -83756,7 +83915,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83756
83915
|
const ownerConfirmed = reader === "antigravity-cli" ? resolved?.ownerConfirmed === true : void 0;
|
|
83757
83916
|
if (input.forceRefresh === true || input.args?.forceRefresh === true) {
|
|
83758
83917
|
try {
|
|
83759
|
-
|
|
83918
|
+
fs28.statSync(sourcePath);
|
|
83760
83919
|
} catch {
|
|
83761
83920
|
}
|
|
83762
83921
|
}
|
|
@@ -83808,10 +83967,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83808
83967
|
}
|
|
83809
83968
|
function resolveClaudePath(workspace, sessionId) {
|
|
83810
83969
|
const dir = path34.join(os25.homedir(), ".claude", "projects", cwdAsDashes(workspace));
|
|
83811
|
-
if (!
|
|
83970
|
+
if (!fs28.existsSync(dir)) return null;
|
|
83812
83971
|
if (sessionId) {
|
|
83813
83972
|
const candidate = path34.join(dir, `${sessionId}.jsonl`);
|
|
83814
|
-
if (
|
|
83973
|
+
if (fs28.existsSync(candidate)) return candidate;
|
|
83815
83974
|
}
|
|
83816
83975
|
return null;
|
|
83817
83976
|
}
|
|
@@ -83823,7 +83982,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83823
83982
|
return findCodexPathByRuntime(root, workspace, sessionStartedAtMs);
|
|
83824
83983
|
}
|
|
83825
83984
|
function findCodexPathBySessionId(root, sessionId) {
|
|
83826
|
-
if (!
|
|
83985
|
+
if (!fs28.existsSync(root)) return null;
|
|
83827
83986
|
const needle = sessionId.toLowerCase();
|
|
83828
83987
|
const matches = [];
|
|
83829
83988
|
const stack = [root];
|
|
@@ -83831,7 +83990,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83831
83990
|
const current = stack.pop();
|
|
83832
83991
|
let entries = [];
|
|
83833
83992
|
try {
|
|
83834
|
-
entries =
|
|
83993
|
+
entries = fs28.readdirSync(current, { withFileTypes: true });
|
|
83835
83994
|
} catch {
|
|
83836
83995
|
continue;
|
|
83837
83996
|
}
|
|
@@ -83851,7 +84010,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83851
84010
|
return matches[0]?.p ?? null;
|
|
83852
84011
|
}
|
|
83853
84012
|
function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
|
|
83854
|
-
if (!
|
|
84013
|
+
if (!fs28.existsSync(root) || !workspace) return null;
|
|
83855
84014
|
const workspaceResolved = resolveRealPath(workspace);
|
|
83856
84015
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
83857
84016
|
const matches = [];
|
|
@@ -83860,7 +84019,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83860
84019
|
const current = stack.pop();
|
|
83861
84020
|
let entries = [];
|
|
83862
84021
|
try {
|
|
83863
|
-
entries =
|
|
84022
|
+
entries = fs28.readdirSync(current, { withFileTypes: true });
|
|
83864
84023
|
} catch {
|
|
83865
84024
|
continue;
|
|
83866
84025
|
}
|
|
@@ -83885,10 +84044,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83885
84044
|
}
|
|
83886
84045
|
function readCodexSessionMeta(filePath) {
|
|
83887
84046
|
try {
|
|
83888
|
-
const fd =
|
|
84047
|
+
const fd = fs28.openSync(filePath, "r");
|
|
83889
84048
|
try {
|
|
83890
84049
|
const buffer = Buffer.alloc(8192);
|
|
83891
|
-
const bytes =
|
|
84050
|
+
const bytes = fs28.readSync(fd, buffer, 0, buffer.length, 0);
|
|
83892
84051
|
if (bytes <= 0) return null;
|
|
83893
84052
|
const text = buffer.subarray(0, bytes).toString("utf8");
|
|
83894
84053
|
const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
|
|
@@ -83903,7 +84062,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83903
84062
|
timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
|
|
83904
84063
|
};
|
|
83905
84064
|
} finally {
|
|
83906
|
-
|
|
84065
|
+
fs28.closeSync(fd);
|
|
83907
84066
|
}
|
|
83908
84067
|
} catch {
|
|
83909
84068
|
return null;
|
|
@@ -83911,7 +84070,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83911
84070
|
}
|
|
83912
84071
|
function resolveRealPath(value) {
|
|
83913
84072
|
try {
|
|
83914
|
-
return
|
|
84073
|
+
return fs28.realpathSync(value);
|
|
83915
84074
|
} catch {
|
|
83916
84075
|
return value;
|
|
83917
84076
|
}
|
|
@@ -83933,19 +84092,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83933
84092
|
const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
|
|
83934
84093
|
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
83935
84094
|
const dbPath = path34.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
83936
|
-
if (
|
|
84095
|
+
if (fs28.existsSync(dbPath)) {
|
|
83937
84096
|
if (owner) claimAntigravityConversation(sessionId, owner);
|
|
83938
84097
|
return { path: dbPath, ownerConfirmed: true };
|
|
83939
84098
|
}
|
|
83940
84099
|
}
|
|
83941
84100
|
const brainRoot2 = path34.join(agyRoot, "brain");
|
|
83942
|
-
if (
|
|
84101
|
+
if (fs28.existsSync(brainRoot2)) {
|
|
83943
84102
|
const cutoff = spawnAwareCutoff(sessionStartedAtMs);
|
|
83944
84103
|
const nonEmptyBrain = (uuid3, p) => {
|
|
83945
84104
|
const t = path34.join(p, ".system_generated", "logs", "transcript.jsonl");
|
|
83946
|
-
return
|
|
84105
|
+
return fs28.existsSync(t) && safeSize(t) > 0 ? t : null;
|
|
83947
84106
|
};
|
|
83948
|
-
const all =
|
|
84107
|
+
const all = fs28.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => {
|
|
83949
84108
|
const p = path34.join(brainRoot2, e.name);
|
|
83950
84109
|
return { uuid: e.name, p, mtime: safeMtime(p), birth: safeBirthtime(p) };
|
|
83951
84110
|
}).filter((e) => e.mtime >= cutoff);
|
|
@@ -83976,7 +84135,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
83976
84135
|
function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
|
|
83977
84136
|
let entries = [];
|
|
83978
84137
|
try {
|
|
83979
|
-
entries =
|
|
84138
|
+
entries = fs28.readdirSync(convRoot, { withFileTypes: true });
|
|
83980
84139
|
} catch {
|
|
83981
84140
|
return null;
|
|
83982
84141
|
}
|
|
@@ -84014,9 +84173,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84014
84173
|
void workspace;
|
|
84015
84174
|
void sessionId;
|
|
84016
84175
|
const dbPath = path34.join(os25.homedir(), ".hermes", "state.db");
|
|
84017
|
-
if (
|
|
84176
|
+
if (fs28.existsSync(dbPath)) return dbPath;
|
|
84018
84177
|
const dir = path34.join(os25.homedir(), ".hermes", "sessions");
|
|
84019
|
-
if (!
|
|
84178
|
+
if (!fs28.existsSync(dir)) return null;
|
|
84020
84179
|
return newestRecentFile2(dir, /^session_.*\.json$/);
|
|
84021
84180
|
}
|
|
84022
84181
|
function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
|
|
@@ -84053,7 +84212,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84053
84212
|
function newestRecentFile2(dir, pattern) {
|
|
84054
84213
|
try {
|
|
84055
84214
|
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
84056
|
-
const entries =
|
|
84215
|
+
const entries = fs28.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path34.join(dir, e.name), mtime: safeMtime(path34.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
84057
84216
|
return entries[0]?.p ?? null;
|
|
84058
84217
|
} catch {
|
|
84059
84218
|
return null;
|
|
@@ -84061,14 +84220,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84061
84220
|
}
|
|
84062
84221
|
function safeMtime(p) {
|
|
84063
84222
|
try {
|
|
84064
|
-
return Math.floor(
|
|
84223
|
+
return Math.floor(fs28.statSync(p).mtimeMs);
|
|
84065
84224
|
} catch {
|
|
84066
84225
|
return 0;
|
|
84067
84226
|
}
|
|
84068
84227
|
}
|
|
84069
84228
|
function safeBirthtime(p) {
|
|
84070
84229
|
try {
|
|
84071
|
-
const st =
|
|
84230
|
+
const st = fs28.statSync(p);
|
|
84072
84231
|
const birth = Math.floor(st.birthtimeMs);
|
|
84073
84232
|
return birth > 0 ? birth : Math.floor(st.mtimeMs);
|
|
84074
84233
|
} catch {
|
|
@@ -84077,7 +84236,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84077
84236
|
}
|
|
84078
84237
|
function safeSize(p) {
|
|
84079
84238
|
try {
|
|
84080
|
-
return
|
|
84239
|
+
return fs28.statSync(p).size;
|
|
84081
84240
|
} catch {
|
|
84082
84241
|
return 0;
|
|
84083
84242
|
}
|
|
@@ -84169,9 +84328,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84169
84328
|
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
84170
84329
|
static looksLikeProviderRoot(candidate) {
|
|
84171
84330
|
try {
|
|
84172
|
-
if (!
|
|
84331
|
+
if (!fs29.existsSync(candidate) || !fs29.statSync(candidate).isDirectory()) return false;
|
|
84173
84332
|
return ["ide", "extension", "cli", "acp"].some(
|
|
84174
|
-
(category) =>
|
|
84333
|
+
(category) => fs29.existsSync(path36.join(candidate, category))
|
|
84175
84334
|
);
|
|
84176
84335
|
} catch {
|
|
84177
84336
|
return false;
|
|
@@ -84179,7 +84338,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84179
84338
|
}
|
|
84180
84339
|
static hasProviderRootMarker(candidate) {
|
|
84181
84340
|
try {
|
|
84182
|
-
return
|
|
84341
|
+
return fs29.existsSync(path36.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
84183
84342
|
} catch {
|
|
84184
84343
|
return false;
|
|
84185
84344
|
}
|
|
@@ -84244,12 +84403,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84244
84403
|
const home = os26.homedir();
|
|
84245
84404
|
const oldDir = path36.join(home, ".adhdev", "marketplace");
|
|
84246
84405
|
const newDir = path36.join(home, ".adhdev", "external");
|
|
84247
|
-
if (!
|
|
84248
|
-
if (
|
|
84406
|
+
if (!fs29.existsSync(oldDir)) return;
|
|
84407
|
+
if (fs29.existsSync(newDir)) {
|
|
84249
84408
|
this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
|
|
84250
84409
|
return;
|
|
84251
84410
|
}
|
|
84252
|
-
|
|
84411
|
+
fs29.renameSync(oldDir, newDir);
|
|
84253
84412
|
this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
|
|
84254
84413
|
} catch (e) {
|
|
84255
84414
|
this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
|
|
@@ -84364,7 +84523,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84364
84523
|
this.providers.clear();
|
|
84365
84524
|
this.providerAvailability.clear();
|
|
84366
84525
|
let upstreamCount = 0;
|
|
84367
|
-
if (!this.disableUpstream &&
|
|
84526
|
+
if (!this.disableUpstream && fs29.existsSync(this.upstreamDir)) {
|
|
84368
84527
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
84369
84528
|
if (upstreamCount > 0) {
|
|
84370
84529
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -84373,10 +84532,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84373
84532
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
84374
84533
|
}
|
|
84375
84534
|
const externalDir = path36.join(os26.homedir(), ".adhdev", "external");
|
|
84376
|
-
if (
|
|
84535
|
+
if (fs29.existsSync(externalDir)) {
|
|
84377
84536
|
const rootEntries = (() => {
|
|
84378
84537
|
try {
|
|
84379
|
-
return
|
|
84538
|
+
return fs29.readdirSync(externalDir, { withFileTypes: true });
|
|
84380
84539
|
} catch {
|
|
84381
84540
|
return [];
|
|
84382
84541
|
}
|
|
@@ -84425,7 +84584,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84425
84584
|
}
|
|
84426
84585
|
}
|
|
84427
84586
|
}
|
|
84428
|
-
if (
|
|
84587
|
+
if (fs29.existsSync(this.userDir)) {
|
|
84429
84588
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
84430
84589
|
if (userCount > 0) {
|
|
84431
84590
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -84440,10 +84599,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84440
84599
|
* Check if upstream directory exists and has providers.
|
|
84441
84600
|
*/
|
|
84442
84601
|
hasUpstream() {
|
|
84443
|
-
if (!
|
|
84602
|
+
if (!fs29.existsSync(this.upstreamDir)) return false;
|
|
84444
84603
|
try {
|
|
84445
|
-
return
|
|
84446
|
-
(d) =>
|
|
84604
|
+
return fs29.readdirSync(this.upstreamDir).some(
|
|
84605
|
+
(d) => fs29.statSync(path36.join(this.upstreamDir, d)).isDirectory()
|
|
84447
84606
|
);
|
|
84448
84607
|
} catch {
|
|
84449
84608
|
return false;
|
|
@@ -84942,7 +85101,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84942
85101
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
84943
85102
|
if (providerDir) {
|
|
84944
85103
|
const fullDir = path36.join(providerDir, entry.scriptDir);
|
|
84945
|
-
resolved._resolvedScriptsPath =
|
|
85104
|
+
resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
|
|
84946
85105
|
}
|
|
84947
85106
|
matched = true;
|
|
84948
85107
|
}
|
|
@@ -84961,7 +85120,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84961
85120
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
84962
85121
|
if (providerDir) {
|
|
84963
85122
|
const fullDir = path36.join(providerDir, base.defaultScriptDir);
|
|
84964
|
-
resolved._resolvedScriptsPath =
|
|
85123
|
+
resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
|
|
84965
85124
|
}
|
|
84966
85125
|
}
|
|
84967
85126
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -84979,7 +85138,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84979
85138
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
84980
85139
|
if (providerDir) {
|
|
84981
85140
|
const fullDir = path36.join(providerDir, dirOverride);
|
|
84982
|
-
resolved._resolvedScriptsPath =
|
|
85141
|
+
resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
|
|
84983
85142
|
}
|
|
84984
85143
|
}
|
|
84985
85144
|
} else if (override.scripts) {
|
|
@@ -84996,7 +85155,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
84996
85155
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
84997
85156
|
if (providerDir) {
|
|
84998
85157
|
const fullDir = path36.join(providerDir, base.defaultScriptDir);
|
|
84999
|
-
resolved._resolvedScriptsPath =
|
|
85158
|
+
resolved._resolvedScriptsPath = fs29.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
|
|
85000
85159
|
}
|
|
85001
85160
|
}
|
|
85002
85161
|
}
|
|
@@ -85014,7 +85173,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85014
85173
|
for (const [scriptName, override] of Object.entries(base.overrides)) {
|
|
85015
85174
|
if (!override || typeof override.path !== "string") continue;
|
|
85016
85175
|
const fullPath = path36.join(providerDir2, override.path);
|
|
85017
|
-
if (!
|
|
85176
|
+
if (!fs29.existsSync(fullPath)) {
|
|
85018
85177
|
this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
|
|
85019
85178
|
continue;
|
|
85020
85179
|
}
|
|
@@ -85044,7 +85203,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85044
85203
|
}
|
|
85045
85204
|
if (providerDir) {
|
|
85046
85205
|
try {
|
|
85047
|
-
const
|
|
85206
|
+
const fs43 = require("fs");
|
|
85048
85207
|
const path45 = require("path");
|
|
85049
85208
|
const candidates = [];
|
|
85050
85209
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -85056,13 +85215,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85056
85215
|
}
|
|
85057
85216
|
candidates.push(path45.join(providerDir, "specs", "default.json"));
|
|
85058
85217
|
candidates.push(path45.join(providerDir, "spec.json"));
|
|
85059
|
-
const specPath = candidates.find((p) =>
|
|
85218
|
+
const specPath = candidates.find((p) => fs43.existsSync(p));
|
|
85060
85219
|
let nh;
|
|
85061
85220
|
if (specPath) {
|
|
85062
85221
|
resolved._resolvedSpecPath = specPath;
|
|
85063
85222
|
let specControls;
|
|
85064
85223
|
try {
|
|
85065
|
-
const rawSpec = JSON.parse(
|
|
85224
|
+
const rawSpec = JSON.parse(fs43.readFileSync(specPath, "utf8"));
|
|
85066
85225
|
specControls = rawSpec.control_bar;
|
|
85067
85226
|
nh = rawSpec.native_history;
|
|
85068
85227
|
} catch {
|
|
@@ -85101,7 +85260,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85101
85260
|
reader = (input) => executeNativeHistory(nh, input);
|
|
85102
85261
|
} else if (nh.override_path) {
|
|
85103
85262
|
const overrideFile = path45.resolve(providerDir, nh.override_path);
|
|
85104
|
-
if (
|
|
85263
|
+
if (fs43.existsSync(overrideFile)) {
|
|
85105
85264
|
try {
|
|
85106
85265
|
registerProviderScriptRootSafely(path45.dirname(path45.dirname(providerDir)));
|
|
85107
85266
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -85146,7 +85305,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85146
85305
|
return null;
|
|
85147
85306
|
}
|
|
85148
85307
|
const dir = path36.join(providerDir, scriptDir);
|
|
85149
|
-
if (!
|
|
85308
|
+
if (!fs29.existsSync(dir)) {
|
|
85150
85309
|
this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
85151
85310
|
return null;
|
|
85152
85311
|
}
|
|
@@ -85154,7 +85313,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85154
85313
|
const cached3 = this.scriptsCache.get(dir);
|
|
85155
85314
|
if (cached3) return cached3;
|
|
85156
85315
|
const scriptsJs = path36.join(dir, "scripts.js");
|
|
85157
|
-
if (
|
|
85316
|
+
if (fs29.existsSync(scriptsJs)) {
|
|
85158
85317
|
try {
|
|
85159
85318
|
delete require.cache[require.resolve(scriptsJs)];
|
|
85160
85319
|
const loaded = require(scriptsJs);
|
|
@@ -85175,9 +85334,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85175
85334
|
watch() {
|
|
85176
85335
|
this.stopWatch();
|
|
85177
85336
|
const watchDir = (dir) => {
|
|
85178
|
-
if (!
|
|
85337
|
+
if (!fs29.existsSync(dir)) {
|
|
85179
85338
|
try {
|
|
85180
|
-
|
|
85339
|
+
fs29.mkdirSync(dir, { recursive: true });
|
|
85181
85340
|
} catch {
|
|
85182
85341
|
return;
|
|
85183
85342
|
}
|
|
@@ -85269,14 +85428,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85269
85428
|
const regMetaPath = path36.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
|
|
85270
85429
|
let cachedChecksums = {};
|
|
85271
85430
|
try {
|
|
85272
|
-
if (
|
|
85273
|
-
cachedChecksums = JSON.parse(
|
|
85431
|
+
if (fs29.existsSync(regMetaPath)) {
|
|
85432
|
+
cachedChecksums = JSON.parse(fs29.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
|
|
85274
85433
|
}
|
|
85275
85434
|
} catch {
|
|
85276
85435
|
}
|
|
85277
85436
|
try {
|
|
85278
85437
|
const listUrl = `${this.registryBaseUrl}/providers`;
|
|
85279
|
-
const listBody = await new Promise((
|
|
85438
|
+
const listBody = await new Promise((resolve26, reject) => {
|
|
85280
85439
|
const req = https.get(listUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 1e4 }, (res) => {
|
|
85281
85440
|
if (res.statusCode !== 200) {
|
|
85282
85441
|
reject(new Error(`registry list HTTP ${res.statusCode}`));
|
|
@@ -85284,7 +85443,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85284
85443
|
}
|
|
85285
85444
|
const chunks = [];
|
|
85286
85445
|
res.on("data", (c) => chunks.push(c));
|
|
85287
|
-
res.on("end", () =>
|
|
85446
|
+
res.on("end", () => resolve26(Buffer.concat(chunks).toString("utf-8")));
|
|
85288
85447
|
});
|
|
85289
85448
|
req.on("error", reject);
|
|
85290
85449
|
req.on("timeout", () => {
|
|
@@ -85300,7 +85459,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85300
85459
|
const cacheKey = `${category}/${type}`;
|
|
85301
85460
|
if (cachedChecksums[cacheKey] === checksum) continue;
|
|
85302
85461
|
const dlUrl = `${this.registryBaseUrl}/providers/${type}/${version2}/download`;
|
|
85303
|
-
const manifestBody = await new Promise((
|
|
85462
|
+
const manifestBody = await new Promise((resolve26, reject) => {
|
|
85304
85463
|
const req = https.get(dlUrl, { headers: { "User-Agent": "adhdev-daemon", "Accept": "application/json" }, timeout: 3e4 }, (res) => {
|
|
85305
85464
|
if (res.statusCode !== 200) {
|
|
85306
85465
|
reject(new Error(`registry download HTTP ${res.statusCode} for ${type}@${version2}`));
|
|
@@ -85308,7 +85467,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85308
85467
|
}
|
|
85309
85468
|
const chunks = [];
|
|
85310
85469
|
res.on("data", (c) => chunks.push(c));
|
|
85311
|
-
res.on("end", () =>
|
|
85470
|
+
res.on("end", () => resolve26(Buffer.concat(chunks).toString("utf-8")));
|
|
85312
85471
|
});
|
|
85313
85472
|
req.on("error", reject);
|
|
85314
85473
|
req.on("timeout", () => {
|
|
@@ -85322,14 +85481,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85322
85481
|
continue;
|
|
85323
85482
|
}
|
|
85324
85483
|
const providerDir = path36.join(this.upstreamDir, category, type);
|
|
85325
|
-
|
|
85326
|
-
|
|
85484
|
+
fs29.mkdirSync(providerDir, { recursive: true });
|
|
85485
|
+
fs29.writeFileSync(path36.join(providerDir, "provider.json"), manifestBody, "utf-8");
|
|
85327
85486
|
cachedChecksums[cacheKey] = checksum;
|
|
85328
85487
|
updatedCount++;
|
|
85329
85488
|
this.log(`\u2713 Registry updated: ${category}/${type}@${version2}`);
|
|
85330
85489
|
}
|
|
85331
|
-
|
|
85332
|
-
|
|
85490
|
+
fs29.mkdirSync(this.upstreamDir, { recursive: true });
|
|
85491
|
+
fs29.writeFileSync(regMetaPath, JSON.stringify({
|
|
85333
85492
|
checksums: cachedChecksums,
|
|
85334
85493
|
syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
85335
85494
|
providerCount: list.providers.length
|
|
@@ -85354,8 +85513,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85354
85513
|
let prevEtag = "";
|
|
85355
85514
|
let prevTimestamp = 0;
|
|
85356
85515
|
try {
|
|
85357
|
-
if (
|
|
85358
|
-
const meta3 = JSON.parse(
|
|
85516
|
+
if (fs29.existsSync(metaPath)) {
|
|
85517
|
+
const meta3 = JSON.parse(fs29.readFileSync(metaPath, "utf-8"));
|
|
85359
85518
|
prevEtag = meta3.etag || "";
|
|
85360
85519
|
prevTimestamp = meta3.timestamp || 0;
|
|
85361
85520
|
}
|
|
@@ -85368,7 +85527,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85368
85527
|
}
|
|
85369
85528
|
const tarballTarget = resolveProviderTarballTarget(this.providerTarballUrl);
|
|
85370
85529
|
try {
|
|
85371
|
-
const etag = await new Promise((
|
|
85530
|
+
const etag = await new Promise((resolve26, reject) => {
|
|
85372
85531
|
const options = {
|
|
85373
85532
|
method: "HEAD",
|
|
85374
85533
|
hostname: tarballTarget.hostname,
|
|
@@ -85386,7 +85545,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85386
85545
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
85387
85546
|
timeout: 1e4
|
|
85388
85547
|
}, (res2) => {
|
|
85389
|
-
|
|
85548
|
+
resolve26(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
85390
85549
|
});
|
|
85391
85550
|
req2.on("error", reject);
|
|
85392
85551
|
req2.on("timeout", () => {
|
|
@@ -85395,7 +85554,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85395
85554
|
});
|
|
85396
85555
|
req2.end();
|
|
85397
85556
|
} else {
|
|
85398
|
-
|
|
85557
|
+
resolve26(res.headers.etag || res.headers["last-modified"] || "");
|
|
85399
85558
|
}
|
|
85400
85559
|
});
|
|
85401
85560
|
req.on("error", reject);
|
|
@@ -85414,36 +85573,36 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85414
85573
|
const tmpTar = path36.join(os26.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
85415
85574
|
const tmpExtract = path36.join(os26.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
85416
85575
|
await this.downloadFile(tarballTarget.url, tmpTar);
|
|
85417
|
-
|
|
85576
|
+
fs29.mkdirSync(tmpExtract, { recursive: true });
|
|
85418
85577
|
await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
85419
|
-
const extracted =
|
|
85578
|
+
const extracted = fs29.readdirSync(tmpExtract);
|
|
85420
85579
|
const rootDir = extracted.find(
|
|
85421
|
-
(d) =>
|
|
85580
|
+
(d) => fs29.statSync(path36.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
85422
85581
|
);
|
|
85423
85582
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
85424
85583
|
const sourceDir = path36.join(tmpExtract, rootDir);
|
|
85425
85584
|
const backupDir = this.upstreamDir + ".bak";
|
|
85426
|
-
if (
|
|
85427
|
-
if (
|
|
85428
|
-
|
|
85585
|
+
if (fs29.existsSync(this.upstreamDir)) {
|
|
85586
|
+
if (fs29.existsSync(backupDir)) fs29.rmSync(backupDir, { recursive: true, force: true });
|
|
85587
|
+
fs29.renameSync(this.upstreamDir, backupDir);
|
|
85429
85588
|
}
|
|
85430
85589
|
try {
|
|
85431
85590
|
this.copyDirRecursive(sourceDir, this.upstreamDir);
|
|
85432
85591
|
this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
|
|
85433
|
-
if (
|
|
85592
|
+
if (fs29.existsSync(backupDir)) fs29.rmSync(backupDir, { recursive: true, force: true });
|
|
85434
85593
|
} catch (e) {
|
|
85435
|
-
if (
|
|
85436
|
-
if (
|
|
85437
|
-
|
|
85594
|
+
if (fs29.existsSync(backupDir)) {
|
|
85595
|
+
if (fs29.existsSync(this.upstreamDir)) fs29.rmSync(this.upstreamDir, { recursive: true, force: true });
|
|
85596
|
+
fs29.renameSync(backupDir, this.upstreamDir);
|
|
85438
85597
|
}
|
|
85439
85598
|
throw e;
|
|
85440
85599
|
}
|
|
85441
85600
|
try {
|
|
85442
|
-
|
|
85601
|
+
fs29.rmSync(tmpTar, { force: true });
|
|
85443
85602
|
} catch {
|
|
85444
85603
|
}
|
|
85445
85604
|
try {
|
|
85446
|
-
|
|
85605
|
+
fs29.rmSync(tmpExtract, { recursive: true, force: true });
|
|
85447
85606
|
} catch {
|
|
85448
85607
|
}
|
|
85449
85608
|
const upstreamCount = this.countProviders(this.upstreamDir);
|
|
@@ -85459,7 +85618,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85459
85618
|
downloadFile(url2, destPath) {
|
|
85460
85619
|
const https = require("https");
|
|
85461
85620
|
const http3 = require("http");
|
|
85462
|
-
return new Promise((
|
|
85621
|
+
return new Promise((resolve26, reject) => {
|
|
85463
85622
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
85464
85623
|
if (redirectCount > 5) {
|
|
85465
85624
|
reject(new Error("Too many redirects"));
|
|
@@ -85475,11 +85634,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85475
85634
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
85476
85635
|
return;
|
|
85477
85636
|
}
|
|
85478
|
-
const ws =
|
|
85637
|
+
const ws = fs29.createWriteStream(destPath);
|
|
85479
85638
|
res.pipe(ws);
|
|
85480
85639
|
ws.on("finish", () => {
|
|
85481
85640
|
ws.close();
|
|
85482
|
-
|
|
85641
|
+
resolve26();
|
|
85483
85642
|
});
|
|
85484
85643
|
ws.on("error", reject);
|
|
85485
85644
|
});
|
|
@@ -85494,22 +85653,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85494
85653
|
}
|
|
85495
85654
|
/** Recursive directory copy */
|
|
85496
85655
|
copyDirRecursive(src, dest) {
|
|
85497
|
-
|
|
85498
|
-
for (const entry of
|
|
85656
|
+
fs29.mkdirSync(dest, { recursive: true });
|
|
85657
|
+
for (const entry of fs29.readdirSync(src, { withFileTypes: true })) {
|
|
85499
85658
|
const srcPath = path36.join(src, entry.name);
|
|
85500
85659
|
const destPath = path36.join(dest, entry.name);
|
|
85501
85660
|
if (entry.isDirectory()) {
|
|
85502
85661
|
this.copyDirRecursive(srcPath, destPath);
|
|
85503
85662
|
} else {
|
|
85504
|
-
|
|
85663
|
+
fs29.copyFileSync(srcPath, destPath);
|
|
85505
85664
|
}
|
|
85506
85665
|
}
|
|
85507
85666
|
}
|
|
85508
85667
|
/** .meta.json save */
|
|
85509
85668
|
writeMeta(metaPath, etag, timestamp) {
|
|
85510
85669
|
try {
|
|
85511
|
-
|
|
85512
|
-
|
|
85670
|
+
fs29.mkdirSync(path36.dirname(metaPath), { recursive: true });
|
|
85671
|
+
fs29.writeFileSync(metaPath, JSON.stringify({
|
|
85513
85672
|
etag,
|
|
85514
85673
|
timestamp,
|
|
85515
85674
|
lastCheck: new Date(timestamp).toISOString(),
|
|
@@ -85520,11 +85679,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85520
85679
|
}
|
|
85521
85680
|
/** Count provider files (provider.v1.json or provider.json — at most one per dir). */
|
|
85522
85681
|
countProviders(dir) {
|
|
85523
|
-
if (!
|
|
85682
|
+
if (!fs29.existsSync(dir)) return 0;
|
|
85524
85683
|
let count = 0;
|
|
85525
85684
|
const scan = (d) => {
|
|
85526
85685
|
try {
|
|
85527
|
-
const entries =
|
|
85686
|
+
const entries = fs29.readdirSync(d, { withFileTypes: true });
|
|
85528
85687
|
const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
|
|
85529
85688
|
if (hasManifest) count++;
|
|
85530
85689
|
for (const entry of entries) {
|
|
@@ -85754,13 +85913,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85754
85913
|
if (!provider) return null;
|
|
85755
85914
|
const cat = provider.category;
|
|
85756
85915
|
const searchRoots = this.getProviderRoots();
|
|
85757
|
-
const hasManifest = (dir) =>
|
|
85916
|
+
const hasManifest = (dir) => fs29.existsSync(path36.join(dir, "provider.v1.json")) || fs29.existsSync(path36.join(dir, "provider.json"));
|
|
85758
85917
|
const readManifestType = (dir) => {
|
|
85759
85918
|
for (const file2 of ["provider.v1.json", "provider.json"]) {
|
|
85760
85919
|
const p = path36.join(dir, file2);
|
|
85761
|
-
if (!
|
|
85920
|
+
if (!fs29.existsSync(p)) continue;
|
|
85762
85921
|
try {
|
|
85763
|
-
const data = JSON.parse(
|
|
85922
|
+
const data = JSON.parse(fs29.readFileSync(p, "utf-8"));
|
|
85764
85923
|
if (typeof data?.type === "string") return data.type;
|
|
85765
85924
|
} catch {
|
|
85766
85925
|
}
|
|
@@ -85768,13 +85927,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85768
85927
|
return null;
|
|
85769
85928
|
};
|
|
85770
85929
|
for (const root of searchRoots) {
|
|
85771
|
-
if (!
|
|
85930
|
+
if (!fs29.existsSync(root)) continue;
|
|
85772
85931
|
const candidate = this.getProviderDir(root, cat, type);
|
|
85773
85932
|
if (hasManifest(candidate)) return candidate;
|
|
85774
85933
|
const catDir = path36.join(root, cat);
|
|
85775
|
-
if (
|
|
85934
|
+
if (fs29.existsSync(catDir)) {
|
|
85776
85935
|
try {
|
|
85777
|
-
for (const entry of
|
|
85936
|
+
for (const entry of fs29.readdirSync(catDir, { withFileTypes: true })) {
|
|
85778
85937
|
if (!entry.isDirectory()) continue;
|
|
85779
85938
|
const entryDir = path36.join(catDir, entry.name);
|
|
85780
85939
|
const manifestType = readManifestType(entryDir);
|
|
@@ -85793,7 +85952,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85793
85952
|
*/
|
|
85794
85953
|
buildScriptWrappersFromDir(dir) {
|
|
85795
85954
|
const scriptsJs = path36.join(dir, "scripts.js");
|
|
85796
|
-
if (
|
|
85955
|
+
if (fs29.existsSync(scriptsJs)) {
|
|
85797
85956
|
try {
|
|
85798
85957
|
delete require.cache[require.resolve(scriptsJs)];
|
|
85799
85958
|
return require(scriptsJs);
|
|
@@ -85803,13 +85962,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85803
85962
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
85804
85963
|
const result = {};
|
|
85805
85964
|
try {
|
|
85806
|
-
for (const file2 of
|
|
85965
|
+
for (const file2 of fs29.readdirSync(dir)) {
|
|
85807
85966
|
if (!file2.endsWith(".js")) continue;
|
|
85808
85967
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
85809
85968
|
const filePath = path36.join(dir, file2);
|
|
85810
85969
|
result[scriptName] = (...args) => {
|
|
85811
85970
|
try {
|
|
85812
|
-
let content =
|
|
85971
|
+
let content = fs29.readFileSync(filePath, "utf-8");
|
|
85813
85972
|
if (args[0] && typeof args[0] === "object") {
|
|
85814
85973
|
for (const [key2, val] of Object.entries(args[0])) {
|
|
85815
85974
|
let v = val;
|
|
@@ -85855,12 +86014,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85855
86014
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
85856
86015
|
*/
|
|
85857
86016
|
loadDir(dir, excludeDirs) {
|
|
85858
|
-
if (!
|
|
86017
|
+
if (!fs29.existsSync(dir)) return 0;
|
|
85859
86018
|
let count = 0;
|
|
85860
86019
|
const scan = (d) => {
|
|
85861
86020
|
let entries;
|
|
85862
86021
|
try {
|
|
85863
|
-
entries =
|
|
86022
|
+
entries = fs29.readdirSync(d, { withFileTypes: true });
|
|
85864
86023
|
} catch {
|
|
85865
86024
|
return;
|
|
85866
86025
|
}
|
|
@@ -85870,7 +86029,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
85870
86029
|
const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
|
|
85871
86030
|
const jsonPath = path36.join(d, manifestFile);
|
|
85872
86031
|
try {
|
|
85873
|
-
const raw =
|
|
86032
|
+
const raw = fs29.readFileSync(jsonPath, "utf-8");
|
|
85874
86033
|
const mod = JSON.parse(raw);
|
|
85875
86034
|
if (hasV1 && mod?.category === "cli") {
|
|
85876
86035
|
try {
|
|
@@ -85909,7 +86068,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
85909
86068
|
} else {
|
|
85910
86069
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
85911
86070
|
const scriptsPath = path36.join(d, "scripts.js");
|
|
85912
|
-
if (!hasCompatibility &&
|
|
86071
|
+
if (!hasCompatibility && fs29.existsSync(scriptsPath)) {
|
|
85913
86072
|
try {
|
|
85914
86073
|
registerProviderScriptRootSafely(path36.dirname(path36.dirname(d)));
|
|
85915
86074
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -86031,10 +86190,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
86031
86190
|
return pids;
|
|
86032
86191
|
}
|
|
86033
86192
|
async function execQuiet(command, options = {}) {
|
|
86034
|
-
return new Promise((
|
|
86193
|
+
return new Promise((resolve26) => {
|
|
86035
86194
|
(0, import_child_process9.exec)(command, options, (error48, stdout) => {
|
|
86036
|
-
if (error48) return
|
|
86037
|
-
|
|
86195
|
+
if (error48) return resolve26("");
|
|
86196
|
+
resolve26(stdout.toString());
|
|
86038
86197
|
});
|
|
86039
86198
|
});
|
|
86040
86199
|
}
|
|
@@ -86115,17 +86274,17 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
86115
86274
|
throw new Error("No free port found");
|
|
86116
86275
|
}
|
|
86117
86276
|
function checkPortFree(port) {
|
|
86118
|
-
return new Promise((
|
|
86277
|
+
return new Promise((resolve26) => {
|
|
86119
86278
|
const server = net3.createServer();
|
|
86120
86279
|
server.unref();
|
|
86121
|
-
server.on("error", () =>
|
|
86280
|
+
server.on("error", () => resolve26(false));
|
|
86122
86281
|
server.listen(port, "127.0.0.1", () => {
|
|
86123
|
-
server.close(() =>
|
|
86282
|
+
server.close(() => resolve26(true));
|
|
86124
86283
|
});
|
|
86125
86284
|
});
|
|
86126
86285
|
}
|
|
86127
86286
|
async function isCdpActive(port) {
|
|
86128
|
-
return new Promise((
|
|
86287
|
+
return new Promise((resolve26) => {
|
|
86129
86288
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
86130
86289
|
timeout: 2e3
|
|
86131
86290
|
}, (res) => {
|
|
@@ -86134,16 +86293,16 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
86134
86293
|
res.on("end", () => {
|
|
86135
86294
|
try {
|
|
86136
86295
|
const info = JSON.parse(data);
|
|
86137
|
-
|
|
86296
|
+
resolve26(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
86138
86297
|
} catch {
|
|
86139
|
-
|
|
86298
|
+
resolve26(false);
|
|
86140
86299
|
}
|
|
86141
86300
|
});
|
|
86142
86301
|
});
|
|
86143
|
-
req.on("error", () =>
|
|
86302
|
+
req.on("error", () => resolve26(false));
|
|
86144
86303
|
req.on("timeout", () => {
|
|
86145
86304
|
req.destroy();
|
|
86146
|
-
|
|
86305
|
+
resolve26(false);
|
|
86147
86306
|
});
|
|
86148
86307
|
});
|
|
86149
86308
|
}
|
|
@@ -86279,7 +86438,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
86279
86438
|
}
|
|
86280
86439
|
} else if (plat === "win32") {
|
|
86281
86440
|
try {
|
|
86282
|
-
const
|
|
86441
|
+
const fs43 = require("fs");
|
|
86283
86442
|
const appNameMap = getMacAppIdentifiers();
|
|
86284
86443
|
const appName = appNameMap[ideId];
|
|
86285
86444
|
if (appName) {
|
|
@@ -86288,8 +86447,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
86288
86447
|
appName,
|
|
86289
86448
|
"storage.json"
|
|
86290
86449
|
);
|
|
86291
|
-
if (
|
|
86292
|
-
const data = JSON.parse(
|
|
86450
|
+
if (fs43.existsSync(storagePath)) {
|
|
86451
|
+
const data = JSON.parse(fs43.readFileSync(storagePath, "utf-8"));
|
|
86293
86452
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
86294
86453
|
if (workspaces.length > 0) {
|
|
86295
86454
|
const recent = workspaces[0];
|
|
@@ -86805,7 +86964,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
86805
86964
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
86806
86965
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
86807
86966
|
const { mkdirSync: mkdirSync22, writeFileSync: writeFileSync24 } = await import("fs");
|
|
86808
|
-
const { dirname:
|
|
86967
|
+
const { dirname: dirname18, join: join52 } = await import("path");
|
|
86809
86968
|
const scaffold = buildMeshJsonConfigScaffold2(mesh);
|
|
86810
86969
|
const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
|
|
86811
86970
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
@@ -86845,7 +87004,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
86845
87004
|
note: "Dry-run: nothing written. Re-run with write=true to persist to the repo (commit target). meshes.json is untouched."
|
|
86846
87005
|
};
|
|
86847
87006
|
}
|
|
86848
|
-
mkdirSync22(
|
|
87007
|
+
mkdirSync22(dirname18(absolutePath), { recursive: true });
|
|
86849
87008
|
writeFileSync24(absolutePath, `${scaffoldJson}
|
|
86850
87009
|
`, "utf-8");
|
|
86851
87010
|
return {
|
|
@@ -87384,7 +87543,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
87384
87543
|
const setupPromise = finishWorktreeSetup();
|
|
87385
87544
|
const setupResult = await Promise.race([
|
|
87386
87545
|
setupPromise.then((value) => ({ completed: true, value })),
|
|
87387
|
-
new Promise((
|
|
87546
|
+
new Promise((resolve26) => setTimeout(() => resolve26({ completed: false }), setupWaitMs))
|
|
87388
87547
|
]);
|
|
87389
87548
|
const emitBootstrapEvent = (eventStatus2, bootstrapState2, startedAtMs, extraPayload) => {
|
|
87390
87549
|
try {
|
|
@@ -88249,7 +88408,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
88249
88408
|
}
|
|
88250
88409
|
};
|
|
88251
88410
|
var import_path13 = require("path");
|
|
88252
|
-
var
|
|
88411
|
+
var fs30 = __toESM2(require("fs"));
|
|
88253
88412
|
init_logger();
|
|
88254
88413
|
init_mesh_host_ownership();
|
|
88255
88414
|
init_coordinator_registry();
|
|
@@ -88495,15 +88654,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
88495
88654
|
}
|
|
88496
88655
|
if (cliType === "codex-cli") {
|
|
88497
88656
|
const repoMcpConfigPath = (0, import_path13.join)(workspace, ".mcp.json");
|
|
88498
|
-
if (
|
|
88657
|
+
if (fs30.existsSync(repoMcpConfigPath)) {
|
|
88499
88658
|
try {
|
|
88500
88659
|
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
88501
|
-
|
|
88660
|
+
fs30.readFileSync(repoMcpConfigPath, "utf-8"),
|
|
88502
88661
|
"claude_mcp_json"
|
|
88503
88662
|
);
|
|
88504
88663
|
const existingServers2 = repoMcpConfig.mcpServers;
|
|
88505
88664
|
if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
|
|
88506
|
-
|
|
88665
|
+
fs30.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
88507
88666
|
...repoMcpConfig,
|
|
88508
88667
|
mcpServers: {
|
|
88509
88668
|
...existingServers2,
|
|
@@ -88622,7 +88781,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
88622
88781
|
};
|
|
88623
88782
|
}
|
|
88624
88783
|
const { existsSync: existsSync55, readFileSync: readFileSync42, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync22 } = await import("fs");
|
|
88625
|
-
const { dirname:
|
|
88784
|
+
const { dirname: dirname18 } = await import("path");
|
|
88626
88785
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
88627
88786
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
88628
88787
|
let hermesBaseConfig = null;
|
|
@@ -88657,7 +88816,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
88657
88816
|
};
|
|
88658
88817
|
}
|
|
88659
88818
|
try {
|
|
88660
|
-
mkdirSync22(
|
|
88819
|
+
mkdirSync22(dirname18(mcpConfigPath), { recursive: true });
|
|
88661
88820
|
} catch (error48) {
|
|
88662
88821
|
const message = `Could not prepare MCP config path for automatic setup: ${error48?.message || error48}`;
|
|
88663
88822
|
LOG2.error("MeshCoordinator", message);
|
|
@@ -88667,7 +88826,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
88667
88826
|
const hadExistingMcpConfig = existsSync55(mcpConfigPath);
|
|
88668
88827
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
88669
88828
|
if (hermesBaseConfig) {
|
|
88670
|
-
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome,
|
|
88829
|
+
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname18(mcpConfigPath));
|
|
88671
88830
|
}
|
|
88672
88831
|
if (hadExistingMcpConfig) {
|
|
88673
88832
|
try {
|
|
@@ -88705,7 +88864,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
88705
88864
|
const cliArgs = [];
|
|
88706
88865
|
const launchEnv = {};
|
|
88707
88866
|
if (configFormat === "hermes_config_yaml") {
|
|
88708
|
-
launchEnv.HERMES_HOME =
|
|
88867
|
+
launchEnv.HERMES_HOME = dirname18(mcpConfigPath);
|
|
88709
88868
|
launchEnv.HERMES_IGNORE_USER_CONFIG = "";
|
|
88710
88869
|
}
|
|
88711
88870
|
let autoImportContextFilePath;
|
|
@@ -88788,7 +88947,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
88788
88947
|
}
|
|
88789
88948
|
}
|
|
88790
88949
|
};
|
|
88791
|
-
var
|
|
88950
|
+
var fs31 = __toESM2(require("fs"));
|
|
88792
88951
|
var import_os3 = require("os");
|
|
88793
88952
|
init_config();
|
|
88794
88953
|
init_git_status();
|
|
@@ -89151,7 +89310,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89151
89310
|
}
|
|
89152
89311
|
}
|
|
89153
89312
|
if (workspace) {
|
|
89154
|
-
if (!
|
|
89313
|
+
if (!fs31.existsSync(workspace)) {
|
|
89155
89314
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
89156
89315
|
let remoteProbeApplied = false;
|
|
89157
89316
|
if (inlineTransitGit) {
|
|
@@ -89287,7 +89446,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89287
89446
|
backstop: { ...getMeshV2BackstopCounters() }
|
|
89288
89447
|
};
|
|
89289
89448
|
const previewFreshness = (() => {
|
|
89290
|
-
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate &&
|
|
89449
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs31.existsSync(candidate));
|
|
89291
89450
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
89292
89451
|
})();
|
|
89293
89452
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -89481,7 +89640,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89481
89640
|
);
|
|
89482
89641
|
init_dist();
|
|
89483
89642
|
init_logger();
|
|
89484
|
-
var
|
|
89643
|
+
var fs322 = __toESM2(require("fs"));
|
|
89485
89644
|
var path38 = __toESM2(require("path"));
|
|
89486
89645
|
var os28 = __toESM2(require("os"));
|
|
89487
89646
|
var ADHDEV_HOME2 = process.env.ADHDEV_CONFIG_DIR && process.env.ADHDEV_CONFIG_DIR.trim() ? process.env.ADHDEV_CONFIG_DIR.trim() : path38.join(os28.homedir(), ".adhdev");
|
|
@@ -89489,7 +89648,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89489
89648
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
89490
89649
|
var MAX_DAYS = 7;
|
|
89491
89650
|
try {
|
|
89492
|
-
|
|
89651
|
+
fs322.mkdirSync(LOG_DIR2, { recursive: true });
|
|
89493
89652
|
} catch {
|
|
89494
89653
|
}
|
|
89495
89654
|
var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -89535,7 +89694,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89535
89694
|
}
|
|
89536
89695
|
function cleanOldFiles() {
|
|
89537
89696
|
try {
|
|
89538
|
-
const files =
|
|
89697
|
+
const files = fs322.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
89539
89698
|
const cutoff = /* @__PURE__ */ new Date();
|
|
89540
89699
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
89541
89700
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -89543,7 +89702,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89543
89702
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
89544
89703
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
89545
89704
|
try {
|
|
89546
|
-
|
|
89705
|
+
fs322.unlinkSync(path38.join(LOG_DIR2, file2));
|
|
89547
89706
|
} catch {
|
|
89548
89707
|
}
|
|
89549
89708
|
}
|
|
@@ -89553,14 +89712,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89553
89712
|
}
|
|
89554
89713
|
function checkSize() {
|
|
89555
89714
|
try {
|
|
89556
|
-
const stat2 =
|
|
89715
|
+
const stat2 = fs322.statSync(currentFile);
|
|
89557
89716
|
if (stat2.size > MAX_FILE_SIZE) {
|
|
89558
89717
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
89559
89718
|
try {
|
|
89560
|
-
|
|
89719
|
+
fs322.unlinkSync(backup);
|
|
89561
89720
|
} catch {
|
|
89562
89721
|
}
|
|
89563
|
-
|
|
89722
|
+
fs322.renameSync(currentFile, backup);
|
|
89564
89723
|
}
|
|
89565
89724
|
} catch {
|
|
89566
89725
|
}
|
|
@@ -89593,14 +89752,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89593
89752
|
...entry.error ? { err: entry.error } : {},
|
|
89594
89753
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
89595
89754
|
});
|
|
89596
|
-
|
|
89755
|
+
fs322.appendFileSync(currentFile, line + "\n");
|
|
89597
89756
|
} catch {
|
|
89598
89757
|
}
|
|
89599
89758
|
}
|
|
89600
89759
|
function getRecentCommands(count = 50) {
|
|
89601
89760
|
try {
|
|
89602
|
-
if (!
|
|
89603
|
-
const content =
|
|
89761
|
+
if (!fs322.existsSync(currentFile)) return [];
|
|
89762
|
+
const content = fs322.readFileSync(currentFile, "utf-8");
|
|
89604
89763
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
89605
89764
|
return lines.slice(-count).map((line) => {
|
|
89606
89765
|
try {
|
|
@@ -89626,7 +89785,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89626
89785
|
cleanOldFiles();
|
|
89627
89786
|
init_debug_trace();
|
|
89628
89787
|
init_mesh_host_ownership();
|
|
89629
|
-
var
|
|
89788
|
+
var fs36 = __toESM2(require("fs"));
|
|
89630
89789
|
init_mesh_node_identity();
|
|
89631
89790
|
var import_node_child_process7 = require("child_process");
|
|
89632
89791
|
init_logger();
|
|
@@ -89729,7 +89888,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
89729
89888
|
init_refine_config();
|
|
89730
89889
|
init_worktree_bootstrap_config();
|
|
89731
89890
|
var import_path14 = require("path");
|
|
89732
|
-
var
|
|
89891
|
+
var fs33 = __toESM2(require("fs"));
|
|
89733
89892
|
var import_node_child_process6 = require("child_process");
|
|
89734
89893
|
init_resolve_executable();
|
|
89735
89894
|
var GIT2 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
@@ -90088,7 +90247,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
90088
90247
|
if (!baseCommit || !branchCommit) return false;
|
|
90089
90248
|
if (baseCommit === branchCommit) return true;
|
|
90090
90249
|
try {
|
|
90091
|
-
if (!
|
|
90250
|
+
if (!fs33.existsSync(submoduleRepoPath)) return false;
|
|
90092
90251
|
(0, import_node_child_process6.execFileSync)(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
90093
90252
|
(0, import_node_child_process6.execFileSync)(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
90094
90253
|
(0, import_node_child_process6.execFileSync)(GIT2, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
@@ -90205,7 +90364,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
90205
90364
|
return newTree || void 0;
|
|
90206
90365
|
} finally {
|
|
90207
90366
|
try {
|
|
90208
|
-
|
|
90367
|
+
fs33.rmSync(tmpIndex, { force: true });
|
|
90209
90368
|
} catch {
|
|
90210
90369
|
}
|
|
90211
90370
|
}
|
|
@@ -90280,7 +90439,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
90280
90439
|
return newTree || void 0;
|
|
90281
90440
|
} finally {
|
|
90282
90441
|
try {
|
|
90283
|
-
|
|
90442
|
+
fs33.rmSync(tmpIndex, { force: true });
|
|
90284
90443
|
} catch {
|
|
90285
90444
|
}
|
|
90286
90445
|
}
|
|
@@ -90392,7 +90551,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
90392
90551
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
90393
90552
|
};
|
|
90394
90553
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
90395
|
-
if (!
|
|
90554
|
+
if (!fs33.existsSync(worktreeSubmodulePath)) return false;
|
|
90396
90555
|
try {
|
|
90397
90556
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
90398
90557
|
} catch {
|
|
@@ -90416,7 +90575,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
90416
90575
|
};
|
|
90417
90576
|
let submoduleDefaultBranch = "main";
|
|
90418
90577
|
try {
|
|
90419
|
-
if (!
|
|
90578
|
+
if (!fs33.existsSync(submodulePath)) {
|
|
90420
90579
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
90421
90580
|
entry.publishRequired = true;
|
|
90422
90581
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -90661,9 +90820,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
90661
90820
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
90662
90821
|
};
|
|
90663
90822
|
const dependenciesLikelyMissing = (cwd) => {
|
|
90664
|
-
if (!
|
|
90665
|
-
if (
|
|
90666
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
90823
|
+
if (!fs33.existsSync((0, import_path14.join)(cwd, "package.json"))) return false;
|
|
90824
|
+
if (fs33.existsSync((0, import_path14.join)(cwd, "node_modules"))) return false;
|
|
90825
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs33.existsSync((0, import_path14.join)(cwd, lock)));
|
|
90667
90826
|
};
|
|
90668
90827
|
const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
|
|
90669
90828
|
const isDaemonScopedCommand = (candidate) => {
|
|
@@ -92555,7 +92714,7 @@ ${e?.stderr || ""}`;
|
|
|
92555
92714
|
});
|
|
92556
92715
|
return handle;
|
|
92557
92716
|
}
|
|
92558
|
-
var
|
|
92717
|
+
var fs34 = __toESM2(require("fs"));
|
|
92559
92718
|
var import_path15 = require("path");
|
|
92560
92719
|
init_logger();
|
|
92561
92720
|
init_dist();
|
|
@@ -92572,14 +92731,14 @@ ${e?.stderr || ""}`;
|
|
|
92572
92731
|
return false;
|
|
92573
92732
|
}
|
|
92574
92733
|
async function bestEffortRemoveWorktreeDir(self, dir) {
|
|
92575
|
-
if (!dir || !
|
|
92576
|
-
const sleep3 = (ms) => new Promise((
|
|
92734
|
+
if (!dir || !fs34.existsSync(dir)) return { removed: true, residue: false };
|
|
92735
|
+
const sleep3 = (ms) => new Promise((resolve26) => setTimeout(resolve26, ms));
|
|
92577
92736
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
92578
92737
|
let lastErr;
|
|
92579
92738
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
92580
92739
|
try {
|
|
92581
|
-
|
|
92582
|
-
if (!
|
|
92740
|
+
fs34.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
92741
|
+
if (!fs34.existsSync(dir)) return { removed: true, residue: false };
|
|
92583
92742
|
lastErr = new Error("directory still present after rmSync");
|
|
92584
92743
|
} catch (e) {
|
|
92585
92744
|
lastErr = e;
|
|
@@ -92590,7 +92749,7 @@ ${e?.stderr || ""}`;
|
|
|
92590
92749
|
}
|
|
92591
92750
|
await sleep3(150 * (attempt + 1));
|
|
92592
92751
|
}
|
|
92593
|
-
return
|
|
92752
|
+
return fs34.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
92594
92753
|
}
|
|
92595
92754
|
async function precheckLocalWorktreeRemovable(self, args) {
|
|
92596
92755
|
const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
|
|
@@ -92603,10 +92762,10 @@ ${e?.stderr || ""}`;
|
|
|
92603
92762
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
|
|
92604
92763
|
};
|
|
92605
92764
|
}
|
|
92606
|
-
if (!
|
|
92765
|
+
if (!fs34.existsSync(workspace)) return { ok: true };
|
|
92607
92766
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
92608
92767
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
92609
|
-
if (!repoRoot || !
|
|
92768
|
+
if (!repoRoot || !fs34.existsSync(repoRoot)) {
|
|
92610
92769
|
return {
|
|
92611
92770
|
ok: false,
|
|
92612
92771
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -92626,7 +92785,7 @@ ${e?.stderr || ""}`;
|
|
|
92626
92785
|
const normalizePath = (value) => {
|
|
92627
92786
|
const resolved = (0, import_path15.resolve)(value);
|
|
92628
92787
|
try {
|
|
92629
|
-
return
|
|
92788
|
+
return fs34.realpathSync(resolved);
|
|
92630
92789
|
} catch {
|
|
92631
92790
|
return resolved;
|
|
92632
92791
|
}
|
|
@@ -92688,13 +92847,13 @@ ${e?.stderr || ""}`;
|
|
|
92688
92847
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
92689
92848
|
};
|
|
92690
92849
|
}
|
|
92691
|
-
const worktreeExists =
|
|
92850
|
+
const worktreeExists = fs34.existsSync(workspace);
|
|
92692
92851
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
92693
92852
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
92694
92853
|
if (!worktreeExists) {
|
|
92695
92854
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
92696
92855
|
}
|
|
92697
|
-
if (!repoRoot || !
|
|
92856
|
+
if (!repoRoot || !fs34.existsSync(repoRoot)) {
|
|
92698
92857
|
return {
|
|
92699
92858
|
success: false,
|
|
92700
92859
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -92714,7 +92873,7 @@ ${e?.stderr || ""}`;
|
|
|
92714
92873
|
const normalizePath = (value) => {
|
|
92715
92874
|
const resolved = (0, import_path15.resolve)(value);
|
|
92716
92875
|
try {
|
|
92717
|
-
return
|
|
92876
|
+
return fs34.realpathSync(resolved);
|
|
92718
92877
|
} catch {
|
|
92719
92878
|
return resolved;
|
|
92720
92879
|
}
|
|
@@ -93345,7 +93504,7 @@ ${e?.stderr || ""}`;
|
|
|
93345
93504
|
var yaml5 = __toESM2(require_js_yaml());
|
|
93346
93505
|
var import_os4 = require("os");
|
|
93347
93506
|
var import_path16 = require("path");
|
|
93348
|
-
var
|
|
93507
|
+
var fs35 = __toESM2(require("fs"));
|
|
93349
93508
|
function loadYamlModule() {
|
|
93350
93509
|
return yaml5;
|
|
93351
93510
|
}
|
|
@@ -93369,9 +93528,9 @@ ${e?.stderr || ""}`;
|
|
|
93369
93528
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
93370
93529
|
const sourceHome = resolveHermesUserHome();
|
|
93371
93530
|
const sourceConfigPath = (0, import_path16.join)(sourceHome, "config.yaml");
|
|
93372
|
-
if (!
|
|
93531
|
+
if (!fs35.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
93373
93532
|
if ((0, import_path16.resolve)(sourceConfigPath) === (0, import_path16.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
93374
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
93533
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs35.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
93375
93534
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
93376
93535
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
93377
93536
|
}
|
|
@@ -93408,9 +93567,9 @@ ${e?.stderr || ""}`;
|
|
|
93408
93567
|
for (const fileName of [".env", "auth.json"]) {
|
|
93409
93568
|
const sourcePath = (0, import_path16.join)(sourceHome, fileName);
|
|
93410
93569
|
const targetPath = (0, import_path16.join)(targetHome, fileName);
|
|
93411
|
-
if (!
|
|
93570
|
+
if (!fs35.existsSync(sourcePath)) continue;
|
|
93412
93571
|
try {
|
|
93413
|
-
|
|
93572
|
+
fs35.copyFileSync(sourcePath, targetPath);
|
|
93414
93573
|
} catch (error48) {
|
|
93415
93574
|
LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
|
|
93416
93575
|
}
|
|
@@ -93809,7 +93968,7 @@ ${e?.stderr || ""}`;
|
|
|
93809
93968
|
const nodeId = readInlineMeshNodeId(node);
|
|
93810
93969
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
93811
93970
|
const workspace = readStringValue(node?.workspace);
|
|
93812
|
-
if (workspace &&
|
|
93971
|
+
if (workspace && fs36.existsSync(workspace)) {
|
|
93813
93972
|
tombstones.delete(nodeId);
|
|
93814
93973
|
return true;
|
|
93815
93974
|
}
|
|
@@ -94608,7 +94767,7 @@ ${e?.stderr || ""}`;
|
|
|
94608
94767
|
const beforeCount = this.messageCount(before);
|
|
94609
94768
|
const beforeSignature = this.lastMessageSignature(before);
|
|
94610
94769
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
94611
|
-
await new Promise((
|
|
94770
|
+
await new Promise((resolve26) => setTimeout(resolve26, 250));
|
|
94612
94771
|
let state;
|
|
94613
94772
|
try {
|
|
94614
94773
|
state = await this.readChat(evaluate);
|
|
@@ -94630,7 +94789,7 @@ ${e?.stderr || ""}`;
|
|
|
94630
94789
|
if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
|
|
94631
94790
|
return first;
|
|
94632
94791
|
}
|
|
94633
|
-
await new Promise((
|
|
94792
|
+
await new Promise((resolve26) => setTimeout(resolve26, 150));
|
|
94634
94793
|
const second = await this.readChat(evaluate);
|
|
94635
94794
|
return this.messageCount(second) >= this.messageCount(first) ? second : first;
|
|
94636
94795
|
}
|
|
@@ -94781,7 +94940,7 @@ ${e?.stderr || ""}`;
|
|
|
94781
94940
|
if (typeof data.error === "string" && data.error.trim()) return false;
|
|
94782
94941
|
}
|
|
94783
94942
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
94784
|
-
await new Promise((
|
|
94943
|
+
await new Promise((resolve26) => setTimeout(resolve26, 250));
|
|
94785
94944
|
const state = await this.readChat(evaluate);
|
|
94786
94945
|
const title = this.getStateTitle(state);
|
|
94787
94946
|
if (this.titlesMatch(title, sessionId)) return true;
|
|
@@ -95702,7 +95861,7 @@ ${e?.stderr || ""}`;
|
|
|
95702
95861
|
};
|
|
95703
95862
|
init_io_contracts();
|
|
95704
95863
|
init_chat_message_normalization();
|
|
95705
|
-
var
|
|
95864
|
+
var fs37 = __toESM2(require("fs"));
|
|
95706
95865
|
var path39 = __toESM2(require("path"));
|
|
95707
95866
|
var os29 = __toESM2(require("os"));
|
|
95708
95867
|
var import_os5 = require("os");
|
|
@@ -95716,8 +95875,8 @@ ${e?.stderr || ""}`;
|
|
|
95716
95875
|
}
|
|
95717
95876
|
load() {
|
|
95718
95877
|
try {
|
|
95719
|
-
if (
|
|
95720
|
-
this.history = JSON.parse(
|
|
95878
|
+
if (fs37.existsSync(ARCHIVE_PATH)) {
|
|
95879
|
+
this.history = JSON.parse(fs37.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
95721
95880
|
}
|
|
95722
95881
|
} catch {
|
|
95723
95882
|
this.history = {};
|
|
@@ -95754,20 +95913,20 @@ ${e?.stderr || ""}`;
|
|
|
95754
95913
|
}
|
|
95755
95914
|
save() {
|
|
95756
95915
|
try {
|
|
95757
|
-
|
|
95758
|
-
|
|
95916
|
+
fs37.mkdirSync(path39.dirname(ARCHIVE_PATH), { recursive: true });
|
|
95917
|
+
fs37.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
95759
95918
|
} catch {
|
|
95760
95919
|
}
|
|
95761
95920
|
}
|
|
95762
95921
|
};
|
|
95763
95922
|
async function runCommand(cmd, timeout = 1e4) {
|
|
95764
|
-
return new Promise((
|
|
95923
|
+
return new Promise((resolve26) => {
|
|
95765
95924
|
(0, import_child_process10.exec)(cmd, {
|
|
95766
95925
|
encoding: "utf-8",
|
|
95767
95926
|
timeout
|
|
95768
95927
|
}, (error48, stdout) => {
|
|
95769
|
-
if (error48) return
|
|
95770
|
-
|
|
95928
|
+
if (error48) return resolve26(null);
|
|
95929
|
+
resolve26(stdout.trim());
|
|
95771
95930
|
});
|
|
95772
95931
|
});
|
|
95773
95932
|
}
|
|
@@ -95780,8 +95939,8 @@ ${e?.stderr || ""}`;
|
|
|
95780
95939
|
for (const ext of exes) {
|
|
95781
95940
|
const fullPath = path39.join(p, name + ext);
|
|
95782
95941
|
try {
|
|
95783
|
-
if (
|
|
95784
|
-
const stat2 =
|
|
95942
|
+
if (fs37.existsSync(fullPath)) {
|
|
95943
|
+
const stat2 = fs37.statSync(fullPath);
|
|
95785
95944
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
95786
95945
|
return fullPath;
|
|
95787
95946
|
}
|
|
@@ -95828,9 +95987,9 @@ ${e?.stderr || ""}`;
|
|
|
95828
95987
|
if (p.includes("*")) {
|
|
95829
95988
|
const home = os29.homedir();
|
|
95830
95989
|
const resolved = p.replace(/\*/g, home.split(path39.sep).pop() || "");
|
|
95831
|
-
if (
|
|
95990
|
+
if (fs37.existsSync(resolved)) return resolved;
|
|
95832
95991
|
} else {
|
|
95833
|
-
if (
|
|
95992
|
+
if (fs37.existsSync(p)) return p;
|
|
95834
95993
|
}
|
|
95835
95994
|
}
|
|
95836
95995
|
return null;
|
|
@@ -95838,7 +95997,7 @@ ${e?.stderr || ""}`;
|
|
|
95838
95997
|
async function getMacAppVersion(appPath) {
|
|
95839
95998
|
if ((0, import_os5.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
95840
95999
|
const plistPath = path39.join(appPath, "Contents", "Info.plist");
|
|
95841
|
-
if (!
|
|
96000
|
+
if (!fs37.existsSync(plistPath)) return null;
|
|
95842
96001
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
95843
96002
|
return raw || null;
|
|
95844
96003
|
}
|
|
@@ -95865,7 +96024,7 @@ ${e?.stderr || ""}`;
|
|
|
95865
96024
|
let resolvedBin = cliBin;
|
|
95866
96025
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
95867
96026
|
const bundled = path39.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
95868
|
-
if (provider.cli &&
|
|
96027
|
+
if (provider.cli && fs37.existsSync(bundled)) resolvedBin = bundled;
|
|
95869
96028
|
}
|
|
95870
96029
|
info.installed = !!(appPath || resolvedBin);
|
|
95871
96030
|
info.path = appPath || null;
|
|
@@ -95911,7 +96070,7 @@ ${e?.stderr || ""}`;
|
|
|
95911
96070
|
return results;
|
|
95912
96071
|
}
|
|
95913
96072
|
var http2 = __toESM2(require("http"));
|
|
95914
|
-
var
|
|
96073
|
+
var fs41 = __toESM2(require("fs"));
|
|
95915
96074
|
var path43 = __toESM2(require("path"));
|
|
95916
96075
|
init_config();
|
|
95917
96076
|
function generateFiles(type, name, category, opts = {}) {
|
|
@@ -96257,7 +96416,7 @@ async (params) => {
|
|
|
96257
96416
|
}
|
|
96258
96417
|
init_logger();
|
|
96259
96418
|
init_builders();
|
|
96260
|
-
var
|
|
96419
|
+
var fs38 = __toESM2(require("fs"));
|
|
96261
96420
|
var path40 = __toESM2(require("path"));
|
|
96262
96421
|
init_logger();
|
|
96263
96422
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -96438,17 +96597,17 @@ async (params) => {
|
|
|
96438
96597
|
}
|
|
96439
96598
|
let scriptsPath = "";
|
|
96440
96599
|
const directScripts = path40.join(dir, "scripts.js");
|
|
96441
|
-
if (
|
|
96600
|
+
if (fs38.existsSync(directScripts)) {
|
|
96442
96601
|
scriptsPath = directScripts;
|
|
96443
96602
|
} else {
|
|
96444
96603
|
const scriptsDir = path40.join(dir, "scripts");
|
|
96445
|
-
if (
|
|
96446
|
-
const versions =
|
|
96447
|
-
return
|
|
96604
|
+
if (fs38.existsSync(scriptsDir)) {
|
|
96605
|
+
const versions = fs38.readdirSync(scriptsDir).filter((d) => {
|
|
96606
|
+
return fs38.statSync(path40.join(scriptsDir, d)).isDirectory();
|
|
96448
96607
|
}).sort().reverse();
|
|
96449
96608
|
for (const ver of versions) {
|
|
96450
96609
|
const p = path40.join(scriptsDir, ver, "scripts.js");
|
|
96451
|
-
if (
|
|
96610
|
+
if (fs38.existsSync(p)) {
|
|
96452
96611
|
scriptsPath = p;
|
|
96453
96612
|
break;
|
|
96454
96613
|
}
|
|
@@ -96460,7 +96619,7 @@ async (params) => {
|
|
|
96460
96619
|
return;
|
|
96461
96620
|
}
|
|
96462
96621
|
try {
|
|
96463
|
-
const source =
|
|
96622
|
+
const source = fs38.readFileSync(scriptsPath, "utf-8");
|
|
96464
96623
|
const hints = {};
|
|
96465
96624
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
96466
96625
|
let match;
|
|
@@ -97273,7 +97432,7 @@ async (params) => {
|
|
|
97273
97432
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
97274
97433
|
}
|
|
97275
97434
|
}
|
|
97276
|
-
var
|
|
97435
|
+
var fs39 = __toESM2(require("fs"));
|
|
97277
97436
|
var path41 = __toESM2(require("path"));
|
|
97278
97437
|
function slugifyFixtureName(value) {
|
|
97279
97438
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -97289,10 +97448,10 @@ async (params) => {
|
|
|
97289
97448
|
function readCliFixture(ctx, type, name) {
|
|
97290
97449
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
97291
97450
|
const filePath = path41.join(fixtureDir, `${name}.json`);
|
|
97292
|
-
if (!
|
|
97451
|
+
if (!fs39.existsSync(filePath)) {
|
|
97293
97452
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
97294
97453
|
}
|
|
97295
|
-
return JSON.parse(
|
|
97454
|
+
return JSON.parse(fs39.readFileSync(filePath, "utf-8"));
|
|
97296
97455
|
}
|
|
97297
97456
|
function getExerciseTranscriptText(result) {
|
|
97298
97457
|
const parts = [];
|
|
@@ -97457,7 +97616,7 @@ async (params) => {
|
|
|
97457
97616
|
return { target, instance, adapter };
|
|
97458
97617
|
}
|
|
97459
97618
|
function sleep2(ms) {
|
|
97460
|
-
return new Promise((
|
|
97619
|
+
return new Promise((resolve26) => setTimeout(resolve26, ms));
|
|
97461
97620
|
}
|
|
97462
97621
|
async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
|
|
97463
97622
|
const startedAt = Date.now();
|
|
@@ -98037,7 +98196,7 @@ async (params) => {
|
|
|
98037
98196
|
return;
|
|
98038
98197
|
}
|
|
98039
98198
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
98040
|
-
|
|
98199
|
+
fs39.mkdirSync(fixtureDir, { recursive: true });
|
|
98041
98200
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
98042
98201
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
98043
98202
|
const fixture = {
|
|
@@ -98065,7 +98224,7 @@ async (params) => {
|
|
|
98065
98224
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
98066
98225
|
};
|
|
98067
98226
|
const filePath = path41.join(fixtureDir, `${name}.json`);
|
|
98068
|
-
|
|
98227
|
+
fs39.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
98069
98228
|
ctx.json(res, 200, {
|
|
98070
98229
|
saved: true,
|
|
98071
98230
|
name,
|
|
@@ -98083,14 +98242,14 @@ async (params) => {
|
|
|
98083
98242
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
98084
98243
|
try {
|
|
98085
98244
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
98086
|
-
if (!
|
|
98245
|
+
if (!fs39.existsSync(fixtureDir)) {
|
|
98087
98246
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
98088
98247
|
return;
|
|
98089
98248
|
}
|
|
98090
|
-
const fixtures =
|
|
98249
|
+
const fixtures = fs39.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
98091
98250
|
const fullPath = path41.join(fixtureDir, file2);
|
|
98092
98251
|
try {
|
|
98093
|
-
const raw = JSON.parse(
|
|
98252
|
+
const raw = JSON.parse(fs39.readFileSync(fullPath, "utf-8"));
|
|
98094
98253
|
return {
|
|
98095
98254
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
98096
98255
|
path: fullPath,
|
|
@@ -98221,7 +98380,7 @@ async (params) => {
|
|
|
98221
98380
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
98222
98381
|
}
|
|
98223
98382
|
}
|
|
98224
|
-
var
|
|
98383
|
+
var fs40 = __toESM2(require("fs"));
|
|
98225
98384
|
var path422 = __toESM2(require("path"));
|
|
98226
98385
|
var os30 = __toESM2(require("os"));
|
|
98227
98386
|
var import_session_host_core9 = require_dist();
|
|
@@ -98270,10 +98429,10 @@ async (params) => {
|
|
|
98270
98429
|
return fallback?.type || null;
|
|
98271
98430
|
}
|
|
98272
98431
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
98273
|
-
if (!
|
|
98274
|
-
const versions =
|
|
98432
|
+
if (!fs40.existsSync(scriptsDir)) return null;
|
|
98433
|
+
const versions = fs40.readdirSync(scriptsDir).filter((d) => {
|
|
98275
98434
|
try {
|
|
98276
|
-
return
|
|
98435
|
+
return fs40.statSync(path422.join(scriptsDir, d)).isDirectory();
|
|
98277
98436
|
} catch {
|
|
98278
98437
|
return false;
|
|
98279
98438
|
}
|
|
@@ -98295,13 +98454,13 @@ async (params) => {
|
|
|
98295
98454
|
if (!sourceDir) {
|
|
98296
98455
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
98297
98456
|
}
|
|
98298
|
-
if (!
|
|
98299
|
-
|
|
98300
|
-
|
|
98457
|
+
if (!fs40.existsSync(desiredDir)) {
|
|
98458
|
+
fs40.mkdirSync(path422.dirname(desiredDir), { recursive: true });
|
|
98459
|
+
fs40.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
98301
98460
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
98302
98461
|
}
|
|
98303
98462
|
const providerJson = path422.join(desiredDir, "provider.json");
|
|
98304
|
-
if (!
|
|
98463
|
+
if (!fs40.existsSync(providerJson)) {
|
|
98305
98464
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
98306
98465
|
}
|
|
98307
98466
|
return { dir: desiredDir };
|
|
@@ -98309,15 +98468,15 @@ async (params) => {
|
|
|
98309
98468
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
98310
98469
|
if (!referenceType) return {};
|
|
98311
98470
|
const refDir = ctx.findProviderDir(referenceType);
|
|
98312
|
-
if (!refDir || !
|
|
98471
|
+
if (!refDir || !fs40.existsSync(refDir)) return {};
|
|
98313
98472
|
const referenceScripts = {};
|
|
98314
98473
|
const scriptsDir = path422.join(refDir, "scripts");
|
|
98315
98474
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
98316
98475
|
if (!latestDir) return referenceScripts;
|
|
98317
|
-
for (const file2 of
|
|
98476
|
+
for (const file2 of fs40.readdirSync(latestDir)) {
|
|
98318
98477
|
if (!file2.endsWith(".js")) continue;
|
|
98319
98478
|
try {
|
|
98320
|
-
referenceScripts[file2] =
|
|
98479
|
+
referenceScripts[file2] = fs40.readFileSync(path422.join(latestDir, file2), "utf-8");
|
|
98321
98480
|
} catch {
|
|
98322
98481
|
}
|
|
98323
98482
|
}
|
|
@@ -98426,15 +98585,15 @@ async (params) => {
|
|
|
98426
98585
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
98427
98586
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
98428
98587
|
const tmpDir = path422.join(os30.tmpdir(), "adhdev-autoimpl");
|
|
98429
|
-
if (!
|
|
98588
|
+
if (!fs40.existsSync(tmpDir)) fs40.mkdirSync(tmpDir, { recursive: true });
|
|
98430
98589
|
const promptFile = path422.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
98431
|
-
|
|
98590
|
+
fs40.writeFileSync(promptFile, prompt, "utf-8");
|
|
98432
98591
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
98433
98592
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
98434
98593
|
const spawn5 = agentProvider?.spawn;
|
|
98435
98594
|
if (!spawn5?.command) {
|
|
98436
98595
|
try {
|
|
98437
|
-
|
|
98596
|
+
fs40.unlinkSync(promptFile);
|
|
98438
98597
|
} catch {
|
|
98439
98598
|
}
|
|
98440
98599
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -98536,7 +98695,7 @@ async (params) => {
|
|
|
98536
98695
|
} catch {
|
|
98537
98696
|
}
|
|
98538
98697
|
try {
|
|
98539
|
-
|
|
98698
|
+
fs40.unlinkSync(promptFile);
|
|
98540
98699
|
} catch {
|
|
98541
98700
|
}
|
|
98542
98701
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -98762,7 +98921,7 @@ async (params) => {
|
|
|
98762
98921
|
}
|
|
98763
98922
|
});
|
|
98764
98923
|
try {
|
|
98765
|
-
|
|
98924
|
+
fs40.unlinkSync(promptFile);
|
|
98766
98925
|
} catch {
|
|
98767
98926
|
}
|
|
98768
98927
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -98867,10 +99026,10 @@ async (params) => {
|
|
|
98867
99026
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
98868
99027
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
98869
99028
|
lines.push("");
|
|
98870
|
-
for (const file2 of
|
|
99029
|
+
for (const file2 of fs40.readdirSync(latestScriptsDir)) {
|
|
98871
99030
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
98872
99031
|
try {
|
|
98873
|
-
const content =
|
|
99032
|
+
const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
|
|
98874
99033
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
98875
99034
|
lines.push("```javascript");
|
|
98876
99035
|
lines.push(content);
|
|
@@ -98880,14 +99039,14 @@ async (params) => {
|
|
|
98880
99039
|
}
|
|
98881
99040
|
}
|
|
98882
99041
|
}
|
|
98883
|
-
const refFiles =
|
|
99042
|
+
const refFiles = fs40.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
98884
99043
|
if (refFiles.length > 0) {
|
|
98885
99044
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
98886
99045
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
98887
99046
|
lines.push("");
|
|
98888
99047
|
for (const file2 of refFiles) {
|
|
98889
99048
|
try {
|
|
98890
|
-
const content =
|
|
99049
|
+
const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
|
|
98891
99050
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
98892
99051
|
lines.push("```javascript");
|
|
98893
99052
|
lines.push(content);
|
|
@@ -98932,7 +99091,7 @@ async (params) => {
|
|
|
98932
99091
|
const loadGuide = (name) => {
|
|
98933
99092
|
try {
|
|
98934
99093
|
const p = path422.join(docsDir, name);
|
|
98935
|
-
if (
|
|
99094
|
+
if (fs40.existsSync(p)) return fs40.readFileSync(p, "utf-8");
|
|
98936
99095
|
} catch {
|
|
98937
99096
|
}
|
|
98938
99097
|
return null;
|
|
@@ -99176,11 +99335,11 @@ async (params) => {
|
|
|
99176
99335
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
99177
99336
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
99178
99337
|
lines.push("");
|
|
99179
|
-
for (const file2 of
|
|
99338
|
+
for (const file2 of fs40.readdirSync(latestScriptsDir)) {
|
|
99180
99339
|
if (!file2.endsWith(".js")) continue;
|
|
99181
99340
|
if (!targetFileNames.has(file2)) continue;
|
|
99182
99341
|
try {
|
|
99183
|
-
const content =
|
|
99342
|
+
const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
|
|
99184
99343
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
99185
99344
|
lines.push("```javascript");
|
|
99186
99345
|
lines.push(content);
|
|
@@ -99189,14 +99348,14 @@ async (params) => {
|
|
|
99189
99348
|
} catch {
|
|
99190
99349
|
}
|
|
99191
99350
|
}
|
|
99192
|
-
const refFiles =
|
|
99351
|
+
const refFiles = fs40.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
99193
99352
|
if (refFiles.length > 0) {
|
|
99194
99353
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
99195
99354
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
99196
99355
|
lines.push("");
|
|
99197
99356
|
for (const file2 of refFiles) {
|
|
99198
99357
|
try {
|
|
99199
|
-
const content =
|
|
99358
|
+
const content = fs40.readFileSync(path422.join(latestScriptsDir, file2), "utf-8");
|
|
99200
99359
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
99201
99360
|
lines.push("```javascript");
|
|
99202
99361
|
lines.push(content);
|
|
@@ -99233,7 +99392,7 @@ async (params) => {
|
|
|
99233
99392
|
const loadGuide = (name) => {
|
|
99234
99393
|
try {
|
|
99235
99394
|
const p = path422.join(docsDir, name);
|
|
99236
|
-
if (
|
|
99395
|
+
if (fs40.existsSync(p)) return fs40.readFileSync(p, "utf-8");
|
|
99237
99396
|
} catch {
|
|
99238
99397
|
}
|
|
99239
99398
|
return null;
|
|
@@ -99709,15 +99868,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
99709
99868
|
this.json(res, 500, { error: e.message });
|
|
99710
99869
|
}
|
|
99711
99870
|
});
|
|
99712
|
-
return new Promise((
|
|
99871
|
+
return new Promise((resolve26, reject) => {
|
|
99713
99872
|
this.server.listen(port, "127.0.0.1", () => {
|
|
99714
99873
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
99715
|
-
|
|
99874
|
+
resolve26();
|
|
99716
99875
|
});
|
|
99717
99876
|
this.server.on("error", (e) => {
|
|
99718
99877
|
if (e.code === "EADDRINUSE") {
|
|
99719
99878
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
99720
|
-
|
|
99879
|
+
resolve26();
|
|
99721
99880
|
} else {
|
|
99722
99881
|
reject(e);
|
|
99723
99882
|
}
|
|
@@ -99799,20 +99958,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
99799
99958
|
child.stderr?.on("data", (d) => {
|
|
99800
99959
|
stderr += d.toString().slice(0, 2e3);
|
|
99801
99960
|
});
|
|
99802
|
-
await new Promise((
|
|
99961
|
+
await new Promise((resolve26) => {
|
|
99803
99962
|
const timer = setTimeout(() => {
|
|
99804
99963
|
child.kill();
|
|
99805
|
-
|
|
99964
|
+
resolve26();
|
|
99806
99965
|
}, 3e3);
|
|
99807
99966
|
child.on("exit", () => {
|
|
99808
99967
|
clearTimeout(timer);
|
|
99809
|
-
|
|
99968
|
+
resolve26();
|
|
99810
99969
|
});
|
|
99811
99970
|
child.stdout?.once("data", () => {
|
|
99812
99971
|
setTimeout(() => {
|
|
99813
99972
|
child.kill();
|
|
99814
99973
|
clearTimeout(timer);
|
|
99815
|
-
|
|
99974
|
+
resolve26();
|
|
99816
99975
|
}, 500);
|
|
99817
99976
|
});
|
|
99818
99977
|
});
|
|
@@ -99971,7 +100130,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
99971
100130
|
path43.join(process.cwd(), "packages/web-devconsole/dist")
|
|
99972
100131
|
];
|
|
99973
100132
|
for (const dir of candidates) {
|
|
99974
|
-
if (
|
|
100133
|
+
if (fs41.existsSync(path43.join(dir, "index.html"))) return dir;
|
|
99975
100134
|
}
|
|
99976
100135
|
return null;
|
|
99977
100136
|
}
|
|
@@ -99983,7 +100142,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
99983
100142
|
}
|
|
99984
100143
|
const htmlPath = path43.join(distDir, "index.html");
|
|
99985
100144
|
try {
|
|
99986
|
-
const html =
|
|
100145
|
+
const html = fs41.readFileSync(htmlPath, "utf-8");
|
|
99987
100146
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
99988
100147
|
res.end(html);
|
|
99989
100148
|
} catch (e) {
|
|
@@ -100013,7 +100172,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100013
100172
|
return;
|
|
100014
100173
|
}
|
|
100015
100174
|
try {
|
|
100016
|
-
const content =
|
|
100175
|
+
const content = fs41.readFileSync(filePath);
|
|
100017
100176
|
const ext = path43.extname(filePath);
|
|
100018
100177
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
100019
100178
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -100122,14 +100281,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100122
100281
|
const files = [];
|
|
100123
100282
|
const scan = (d, prefix) => {
|
|
100124
100283
|
try {
|
|
100125
|
-
for (const entry of
|
|
100284
|
+
for (const entry of fs41.readdirSync(d, { withFileTypes: true })) {
|
|
100126
100285
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
100127
100286
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
100128
100287
|
if (entry.isDirectory()) {
|
|
100129
100288
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
100130
100289
|
scan(path43.join(d, entry.name), rel);
|
|
100131
100290
|
} else {
|
|
100132
|
-
const stat2 =
|
|
100291
|
+
const stat2 = fs41.statSync(path43.join(d, entry.name));
|
|
100133
100292
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
100134
100293
|
}
|
|
100135
100294
|
}
|
|
@@ -100157,11 +100316,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100157
100316
|
this.json(res, 403, { error: "Forbidden" });
|
|
100158
100317
|
return;
|
|
100159
100318
|
}
|
|
100160
|
-
if (!
|
|
100319
|
+
if (!fs41.existsSync(fullPath) || fs41.statSync(fullPath).isDirectory()) {
|
|
100161
100320
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
100162
100321
|
return;
|
|
100163
100322
|
}
|
|
100164
|
-
const content =
|
|
100323
|
+
const content = fs41.readFileSync(fullPath, "utf-8");
|
|
100165
100324
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
100166
100325
|
}
|
|
100167
100326
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -100183,9 +100342,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100183
100342
|
return;
|
|
100184
100343
|
}
|
|
100185
100344
|
try {
|
|
100186
|
-
if (
|
|
100187
|
-
|
|
100188
|
-
|
|
100345
|
+
if (fs41.existsSync(fullPath)) fs41.copyFileSync(fullPath, fullPath + ".bak");
|
|
100346
|
+
fs41.mkdirSync(path43.dirname(fullPath), { recursive: true });
|
|
100347
|
+
fs41.writeFileSync(fullPath, content, "utf-8");
|
|
100189
100348
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
100190
100349
|
this.providerLoader.reload();
|
|
100191
100350
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -100202,8 +100361,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100202
100361
|
}
|
|
100203
100362
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
100204
100363
|
const p = path43.join(dir, name);
|
|
100205
|
-
if (
|
|
100206
|
-
const source =
|
|
100364
|
+
if (fs41.existsSync(p)) {
|
|
100365
|
+
const source = fs41.readFileSync(p, "utf-8");
|
|
100207
100366
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
100208
100367
|
return;
|
|
100209
100368
|
}
|
|
@@ -100222,11 +100381,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100222
100381
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
100223
100382
|
return;
|
|
100224
100383
|
}
|
|
100225
|
-
const target =
|
|
100384
|
+
const target = fs41.existsSync(path43.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
100226
100385
|
const targetPath = path43.join(dir, target);
|
|
100227
100386
|
try {
|
|
100228
|
-
if (
|
|
100229
|
-
|
|
100387
|
+
if (fs41.existsSync(targetPath)) fs41.copyFileSync(targetPath, targetPath + ".bak");
|
|
100388
|
+
fs41.writeFileSync(targetPath, source, "utf-8");
|
|
100230
100389
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
100231
100390
|
this.providerLoader.reload();
|
|
100232
100391
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -100315,14 +100474,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100315
100474
|
child.stderr?.on("data", (d) => {
|
|
100316
100475
|
stderr += d.toString();
|
|
100317
100476
|
});
|
|
100318
|
-
await new Promise((
|
|
100477
|
+
await new Promise((resolve26) => {
|
|
100319
100478
|
const timer = setTimeout(() => {
|
|
100320
100479
|
child.kill();
|
|
100321
|
-
|
|
100480
|
+
resolve26();
|
|
100322
100481
|
}, timeout);
|
|
100323
100482
|
child.on("exit", () => {
|
|
100324
100483
|
clearTimeout(timer);
|
|
100325
|
-
|
|
100484
|
+
resolve26();
|
|
100326
100485
|
});
|
|
100327
100486
|
});
|
|
100328
100487
|
const elapsed = Date.now() - start;
|
|
@@ -100371,20 +100530,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100371
100530
|
let targetDir;
|
|
100372
100531
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
100373
100532
|
const jsonPath = path43.join(targetDir, "provider.json");
|
|
100374
|
-
if (
|
|
100533
|
+
if (fs41.existsSync(jsonPath)) {
|
|
100375
100534
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
100376
100535
|
return;
|
|
100377
100536
|
}
|
|
100378
100537
|
try {
|
|
100379
100538
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
100380
|
-
|
|
100381
|
-
|
|
100539
|
+
fs41.mkdirSync(targetDir, { recursive: true });
|
|
100540
|
+
fs41.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
100382
100541
|
const createdFiles = ["provider.json"];
|
|
100383
100542
|
if (result.files) {
|
|
100384
100543
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
100385
100544
|
const fullPath = path43.join(targetDir, relPath);
|
|
100386
|
-
|
|
100387
|
-
|
|
100545
|
+
fs41.mkdirSync(path43.dirname(fullPath), { recursive: true });
|
|
100546
|
+
fs41.writeFileSync(fullPath, content, "utf-8");
|
|
100388
100547
|
createdFiles.push(relPath);
|
|
100389
100548
|
}
|
|
100390
100549
|
}
|
|
@@ -100433,10 +100592,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100433
100592
|
}
|
|
100434
100593
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
100435
100594
|
getLatestScriptVersionDir(scriptsDir) {
|
|
100436
|
-
if (!
|
|
100437
|
-
const versions =
|
|
100595
|
+
if (!fs41.existsSync(scriptsDir)) return null;
|
|
100596
|
+
const versions = fs41.readdirSync(scriptsDir).filter((d) => {
|
|
100438
100597
|
try {
|
|
100439
|
-
return
|
|
100598
|
+
return fs41.statSync(path43.join(scriptsDir, d)).isDirectory();
|
|
100440
100599
|
} catch {
|
|
100441
100600
|
return false;
|
|
100442
100601
|
}
|
|
@@ -100458,13 +100617,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100458
100617
|
if (!sourceDir) {
|
|
100459
100618
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
100460
100619
|
}
|
|
100461
|
-
if (!
|
|
100462
|
-
|
|
100463
|
-
|
|
100620
|
+
if (!fs41.existsSync(desiredDir)) {
|
|
100621
|
+
fs41.mkdirSync(path43.dirname(desiredDir), { recursive: true });
|
|
100622
|
+
fs41.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
100464
100623
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
100465
100624
|
}
|
|
100466
100625
|
const providerJson = path43.join(desiredDir, "provider.json");
|
|
100467
|
-
if (!
|
|
100626
|
+
if (!fs41.existsSync(providerJson)) {
|
|
100468
100627
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
100469
100628
|
}
|
|
100470
100629
|
return { dir: desiredDir };
|
|
@@ -100521,14 +100680,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
100521
100680
|
res.end(JSON.stringify(data, null, 2));
|
|
100522
100681
|
}
|
|
100523
100682
|
async readBody(req) {
|
|
100524
|
-
return new Promise((
|
|
100683
|
+
return new Promise((resolve26) => {
|
|
100525
100684
|
let body = "";
|
|
100526
100685
|
req.on("data", (chunk) => body += chunk);
|
|
100527
100686
|
req.on("end", () => {
|
|
100528
100687
|
try {
|
|
100529
|
-
|
|
100688
|
+
resolve26(JSON.parse(body));
|
|
100530
100689
|
} catch {
|
|
100531
|
-
|
|
100690
|
+
resolve26({});
|
|
100532
100691
|
}
|
|
100533
100692
|
});
|
|
100534
100693
|
});
|
|
@@ -101253,7 +101412,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101253
101412
|
const deadline = Date.now() + timeoutMs;
|
|
101254
101413
|
while (Date.now() < deadline) {
|
|
101255
101414
|
if (await canConnect(endpoint, requiredRequestTypes)) return;
|
|
101256
|
-
await new Promise((
|
|
101415
|
+
await new Promise((resolve26) => setTimeout(resolve26, STARTUP_POLL_MS));
|
|
101257
101416
|
}
|
|
101258
101417
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
101259
101418
|
}
|
|
@@ -101294,7 +101453,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101294
101453
|
}
|
|
101295
101454
|
}
|
|
101296
101455
|
var import_child_process11 = require("child_process");
|
|
101297
|
-
var
|
|
101456
|
+
var fs42 = __toESM2(require("fs"));
|
|
101298
101457
|
var os31 = __toESM2(require("os"));
|
|
101299
101458
|
var path44 = __toESM2(require("path"));
|
|
101300
101459
|
var import_session_host_core13 = require_dist();
|
|
@@ -101315,7 +101474,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101315
101474
|
path44.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
101316
101475
|
];
|
|
101317
101476
|
for (const candidate of packagedCandidates) {
|
|
101318
|
-
if (
|
|
101477
|
+
if (fs42.existsSync(candidate)) {
|
|
101319
101478
|
return candidate;
|
|
101320
101479
|
}
|
|
101321
101480
|
}
|
|
@@ -101327,8 +101486,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101327
101486
|
function getPid() {
|
|
101328
101487
|
try {
|
|
101329
101488
|
const pidFile = getPidFile();
|
|
101330
|
-
if (!
|
|
101331
|
-
const pid = Number.parseInt(
|
|
101489
|
+
if (!fs42.existsSync(pidFile)) return null;
|
|
101490
|
+
const pid = Number.parseInt(fs42.readFileSync(pidFile, "utf8").trim(), 10);
|
|
101332
101491
|
return Number.isFinite(pid) ? pid : null;
|
|
101333
101492
|
} catch {
|
|
101334
101493
|
return null;
|
|
@@ -101354,8 +101513,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101354
101513
|
let logFd = null;
|
|
101355
101514
|
if (options.spawnStdio === "logfile") {
|
|
101356
101515
|
const logDir = path44.join(os31.homedir(), ".adhdev", "logs");
|
|
101357
|
-
|
|
101358
|
-
logFd =
|
|
101516
|
+
fs42.mkdirSync(logDir, { recursive: true });
|
|
101517
|
+
logFd = fs42.openSync(path44.join(logDir, "session-host.log"), "a");
|
|
101359
101518
|
stdio = ["ignore", logFd, logFd];
|
|
101360
101519
|
}
|
|
101361
101520
|
const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
|
|
@@ -101367,7 +101526,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101367
101526
|
child.unref();
|
|
101368
101527
|
if (logFd !== null) {
|
|
101369
101528
|
try {
|
|
101370
|
-
|
|
101529
|
+
fs42.closeSync(logFd);
|
|
101371
101530
|
} catch {
|
|
101372
101531
|
}
|
|
101373
101532
|
}
|
|
@@ -101376,8 +101535,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101376
101535
|
let stopped = false;
|
|
101377
101536
|
const pidFile = getPidFile();
|
|
101378
101537
|
try {
|
|
101379
|
-
if (
|
|
101380
|
-
const pid = Number.parseInt(
|
|
101538
|
+
if (fs42.existsSync(pidFile)) {
|
|
101539
|
+
const pid = Number.parseInt(fs42.readFileSync(pidFile, "utf8").trim(), 10);
|
|
101381
101540
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedPid(pid)) {
|
|
101382
101541
|
stopped = killPid2(pid) || stopped;
|
|
101383
101542
|
}
|
|
@@ -101385,7 +101544,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101385
101544
|
} catch {
|
|
101386
101545
|
} finally {
|
|
101387
101546
|
try {
|
|
101388
|
-
|
|
101547
|
+
fs42.unlinkSync(pidFile);
|
|
101389
101548
|
} catch {
|
|
101390
101549
|
}
|
|
101391
101550
|
}
|
|
@@ -101568,12 +101727,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101568
101727
|
const res = await fetch(extension.vsixUrl);
|
|
101569
101728
|
if (res.ok) {
|
|
101570
101729
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
101571
|
-
const
|
|
101572
|
-
|
|
101573
|
-
return new Promise((
|
|
101730
|
+
const fs43 = await import("fs");
|
|
101731
|
+
fs43.writeFileSync(vsixPath, buffer);
|
|
101732
|
+
return new Promise((resolve26) => {
|
|
101574
101733
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
101575
101734
|
(0, import_child_process12.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
101576
|
-
|
|
101735
|
+
resolve26({
|
|
101577
101736
|
extensionId: extension.id,
|
|
101578
101737
|
marketplaceId: extension.marketplaceId,
|
|
101579
101738
|
success: !error48,
|
|
@@ -101586,11 +101745,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101586
101745
|
} catch (e) {
|
|
101587
101746
|
}
|
|
101588
101747
|
}
|
|
101589
|
-
return new Promise((
|
|
101748
|
+
return new Promise((resolve26) => {
|
|
101590
101749
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
101591
101750
|
(0, import_child_process12.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
101592
101751
|
if (error48) {
|
|
101593
|
-
|
|
101752
|
+
resolve26({
|
|
101594
101753
|
extensionId: extension.id,
|
|
101595
101754
|
marketplaceId: extension.marketplaceId,
|
|
101596
101755
|
success: false,
|
|
@@ -101598,7 +101757,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
101598
101757
|
error: stderr || error48.message
|
|
101599
101758
|
});
|
|
101600
101759
|
} else {
|
|
101601
|
-
|
|
101760
|
+
resolve26({
|
|
101602
101761
|
extensionId: extension.id,
|
|
101603
101762
|
marketplaceId: extension.marketplaceId,
|
|
101604
101763
|
success: true,
|
|
@@ -102122,7 +102281,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
102122
102281
|
}));
|
|
102123
102282
|
}
|
|
102124
102283
|
}
|
|
102125
|
-
await new Promise((
|
|
102284
|
+
await new Promise((resolve26, reject) => {
|
|
102126
102285
|
const onError = (error48) => {
|
|
102127
102286
|
httpServer?.off("listening", onListening);
|
|
102128
102287
|
reject(error48);
|
|
@@ -102130,7 +102289,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
102130
102289
|
const onListening = () => {
|
|
102131
102290
|
httpServer?.off("error", onError);
|
|
102132
102291
|
listening = true;
|
|
102133
|
-
|
|
102292
|
+
resolve26();
|
|
102134
102293
|
};
|
|
102135
102294
|
httpServer.once("error", onError);
|
|
102136
102295
|
httpServer.once("listening", onListening);
|
|
@@ -102157,12 +102316,12 @@ data: ${JSON.stringify(msg.data)}
|
|
|
102157
102316
|
}
|
|
102158
102317
|
}
|
|
102159
102318
|
clients.clear();
|
|
102160
|
-
await new Promise((
|
|
102319
|
+
await new Promise((resolve26) => {
|
|
102161
102320
|
if (!httpServer) {
|
|
102162
|
-
|
|
102321
|
+
resolve26();
|
|
102163
102322
|
return;
|
|
102164
102323
|
}
|
|
102165
|
-
httpServer.close(() =>
|
|
102324
|
+
httpServer.close(() => resolve26());
|
|
102166
102325
|
});
|
|
102167
102326
|
httpServer = null;
|
|
102168
102327
|
wss = null;
|