@adhdev/daemon-core 0.9.82-rc.463 → 0.9.82-rc.465

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.mjs CHANGED
@@ -404,10 +404,10 @@ function readInjected(value) {
404
404
  }
405
405
  function getDaemonBuildInfo() {
406
406
  if (cached) return cached;
407
- const commit = readInjected(true ? "3441855fe9c04e158a4dc94eed196b7bcba1647e" : void 0) ?? "unknown";
408
- const commitShort = readInjected(true ? "3441855f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
- const version = readInjected(true ? "0.9.82-rc.463" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
- const builtAt = readInjected(true ? "2026-07-05T02:56:26.902Z" : void 0);
407
+ const commit = readInjected(true ? "1fb9559b573b07e5386c80329057766b4822dddb" : void 0) ?? "unknown";
408
+ const commitShort = readInjected(true ? "1fb9559b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
+ const version = readInjected(true ? "0.9.82-rc.465" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
+ const builtAt = readInjected(true ? "2026-07-05T07:20:34.545Z" : void 0);
411
411
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
412
412
  return cached;
413
413
  }
@@ -484,8 +484,8 @@ function validateChangeImpactConfig(raw, source = "inline") {
484
484
  }
485
485
  return { valid: errors.length === 0, errors, config: errors.length === 0 ? config : void 0 };
486
486
  }
487
- function parseConfigText(path44, text) {
488
- if (/\.json$/i.test(path44)) return JSON.parse(text);
487
+ function parseConfigText(path45, text) {
488
+ if (/\.json$/i.test(path45)) return JSON.parse(text);
489
489
  return yaml.load(text);
490
490
  }
491
491
  function loadChangeImpactConfig(repoRoot) {
@@ -1099,14 +1099,14 @@ async function deriveSubmoduleGitlinkStatuses(repo, options) {
1099
1099
  const lastCheckedAt = Date.now();
1100
1100
  const headOidByPath = /* @__PURE__ */ new Map();
1101
1101
  const entries = await Promise.all(
1102
- paths.filter((path44) => !ignoreSet.has(path44)).map(async (path44) => {
1103
- const repoPath = repo.repoRoot + "/" + path44;
1104
- const expected = await readGitlinkExpectedSha(repo, path44, options);
1102
+ paths.filter((path45) => !ignoreSet.has(path45)).map(async (path45) => {
1103
+ const repoPath = repo.repoRoot + "/" + path45;
1104
+ const expected = await readGitlinkExpectedSha(repo, path45, options);
1105
1105
  const actual = await readSubmoduleHeadSha(repo, repoPath, options);
1106
- if (actual) headOidByPath.set(path44, actual);
1106
+ if (actual) headOidByPath.set(path45, actual);
1107
1107
  const outOfSync = actual === null ? true : expected !== null && expected !== actual;
1108
1108
  return {
1109
- path: path44,
1109
+ path: path45,
1110
1110
  // Prefer the recorded gitlink SHA (matches the legacy column); fall back
1111
1111
  // to the checked-out SHA so the field is never empty when both are known.
1112
1112
  commit: expected ?? actual ?? "",
@@ -2553,12 +2553,12 @@ function readGitSubmodules(value, parentRepoRoot) {
2553
2553
  if (!Array.isArray(value)) return void 0;
2554
2554
  const submodules = value.map((entry) => {
2555
2555
  const submodule = readRecord(entry);
2556
- const path44 = readString2(submodule.path);
2556
+ const path45 = readString2(submodule.path);
2557
2557
  const commit = readString2(submodule.commit);
2558
- const repoPath = readString2(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path44);
2559
- if (!path44 || !commit) return null;
2558
+ const repoPath = readString2(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path45);
2559
+ if (!path45 || !commit) return null;
2560
2560
  const result = {
2561
- path: path44,
2561
+ path: path45,
2562
2562
  commit,
2563
2563
  dirty: readBoolean(submodule.dirty) ?? false,
2564
2564
  outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
@@ -2892,10 +2892,10 @@ function getMeshConfigPath() {
2892
2892
  return join5(getConfigDir(), "meshes.json");
2893
2893
  }
2894
2894
  function loadMeshConfig() {
2895
- const path44 = getMeshConfigPath();
2896
- if (!existsSync5(path44)) return { meshes: [] };
2895
+ const path45 = getMeshConfigPath();
2896
+ if (!existsSync5(path45)) return { meshes: [] };
2897
2897
  try {
2898
- const raw = JSON.parse(readFileSync3(path44, "utf-8"));
2898
+ const raw = JSON.parse(readFileSync3(path45, "utf-8"));
2899
2899
  if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
2900
2900
  const config = raw;
2901
2901
  const migrated = migrateLoadedMeshConfig(config);
@@ -2944,16 +2944,16 @@ function normalizeCapabilityTags(value) {
2944
2944
  return tags.length ? tags : void 0;
2945
2945
  }
2946
2946
  function saveMeshConfig(config) {
2947
- const path44 = getMeshConfigPath();
2948
- writeFileSync2(path44, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
2947
+ const path45 = getMeshConfigPath();
2948
+ writeFileSync2(path45, JSON.stringify(config, null, 2), { encoding: "utf-8", mode: 384 });
2949
2949
  }
2950
2950
  function normalizeRepoIdentity(remoteUrl) {
2951
2951
  let identity = remoteUrl.trim();
2952
2952
  if (identity.startsWith("http://") || identity.startsWith("https://")) {
2953
2953
  try {
2954
2954
  const url = new URL(identity);
2955
- const path44 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
2956
- return `${url.hostname}/${path44}`;
2955
+ const path45 = url.pathname.replace(/^\//, "").replace(/\.git$/, "");
2956
+ return `${url.hostname}/${path45}`;
2957
2957
  } catch {
2958
2958
  }
2959
2959
  }
@@ -4196,59 +4196,59 @@ function isMeshEventScope(value) {
4196
4196
  function isNonEmptyString(value) {
4197
4197
  return typeof value === "string" && value.length > 0;
4198
4198
  }
4199
- function assertCoordinatorIdentity(raw, path44) {
4199
+ function assertCoordinatorIdentity(raw, path45) {
4200
4200
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
4201
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, path44, "must be an object");
4201
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, path45, "must be an object");
4202
4202
  }
4203
4203
  const obj = raw;
4204
4204
  if (!isNonEmptyString(obj.daemonId)) {
4205
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.daemonId`, "must be a non-empty string");
4205
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.daemonId`, "must be a non-empty string");
4206
4206
  }
4207
4207
  if (!isNonEmptyString(obj.coordinatorRunId)) {
4208
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.coordinatorRunId`, "must be a non-empty string");
4208
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.coordinatorRunId`, "must be a non-empty string");
4209
4209
  }
4210
4210
  const sessionId = obj.sessionId;
4211
4211
  if (sessionId !== void 0 && !isNonEmptyString(sessionId)) {
4212
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.sessionId`, "must be a non-empty string when provided");
4212
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.sessionId`, "must be a non-empty string when provided");
4213
4213
  }
4214
4214
  return sessionId !== void 0 ? { daemonId: obj.daemonId, coordinatorRunId: obj.coordinatorRunId, sessionId } : { daemonId: obj.daemonId, coordinatorRunId: obj.coordinatorRunId };
4215
4215
  }
4216
- function assertPendingMeshCoordinatorEventV2(raw, path44 = "$") {
4216
+ function assertPendingMeshCoordinatorEventV2(raw, path45 = "$") {
4217
4217
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
4218
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, path44, "must be an object");
4218
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, path45, "must be an object");
4219
4219
  }
4220
4220
  const obj = raw;
4221
4221
  if (!isSupportedMeshProtocolVersion(obj.protocolVersion)) {
4222
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.protocolVersion`, `must be one of ${SUPPORTED_MESH_PROTOCOL_VERSIONS.join(", ")}`);
4222
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.protocolVersion`, `must be one of ${SUPPORTED_MESH_PROTOCOL_VERSIONS.join(", ")}`);
4223
4223
  }
4224
4224
  if (!isNonEmptyString(obj.eventId)) {
4225
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.eventId`, "must be a non-empty string");
4225
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.eventId`, "must be a non-empty string");
4226
4226
  }
4227
4227
  if (!isMeshEventScope(obj.scope)) {
4228
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.scope`, `must be one of ${MESH_EVENT_SCOPES.join(", ")}`);
4228
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.scope`, `must be one of ${MESH_EVENT_SCOPES.join(", ")}`);
4229
4229
  }
4230
4230
  if (!isNonEmptyString(obj.event)) {
4231
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.event`, "must be a non-empty string");
4231
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.event`, "must be a non-empty string");
4232
4232
  }
4233
4233
  if (!isNonEmptyString(obj.meshId)) {
4234
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.meshId`, "must be a non-empty string");
4234
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.meshId`, "must be a non-empty string");
4235
4235
  }
4236
- const dispatchedBy = assertCoordinatorIdentity(obj.dispatchedBy, `${path44}.dispatchedBy`);
4236
+ const dispatchedBy = assertCoordinatorIdentity(obj.dispatchedBy, `${path45}.dispatchedBy`);
4237
4237
  if (obj.scope === "unicast") {
4238
4238
  if (!obj.intendedFor) {
4239
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.intendedFor`, "unicast scope requires intendedFor");
4239
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.intendedFor`, "unicast scope requires intendedFor");
4240
4240
  }
4241
4241
  } else if (obj.intendedFor !== void 0) {
4242
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.intendedFor`, "only unicast scope may set intendedFor");
4242
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.intendedFor`, "only unicast scope may set intendedFor");
4243
4243
  }
4244
- const intendedFor = obj.intendedFor ? assertCoordinatorIdentity(obj.intendedFor, `${path44}.intendedFor`) : void 0;
4244
+ const intendedFor = obj.intendedFor ? assertCoordinatorIdentity(obj.intendedFor, `${path45}.intendedFor`) : void 0;
4245
4245
  const metadata = obj.metadataEvent && typeof obj.metadataEvent === "object" && !Array.isArray(obj.metadataEvent) ? obj.metadataEvent : null;
4246
4246
  if (!metadata) {
4247
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.metadataEvent`, "must be an object");
4247
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.metadataEvent`, "must be an object");
4248
4248
  }
4249
4249
  const queuedAt = typeof obj.queuedAt === "number" && Number.isFinite(obj.queuedAt) ? obj.queuedAt : null;
4250
4250
  if (queuedAt === null) {
4251
- throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path44}.queuedAt`, "must be a finite number");
4251
+ throw new MeshContractViolationError(MESH_PROTOCOL_VERSION_V2, `${path45}.queuedAt`, "must be a finite number");
4252
4252
  }
4253
4253
  return {
4254
4254
  event: obj.event,
@@ -4415,10 +4415,10 @@ function rotateArchiveFile(meshId, archivePath) {
4415
4415
  }
4416
4416
  }
4417
4417
  function readArchivedCounts(meshId) {
4418
- const path44 = getArchivedCountsPath(meshId);
4419
- if (!existsSync7(path44)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
4418
+ const path45 = getArchivedCountsPath(meshId);
4419
+ if (!existsSync7(path45)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
4420
4420
  try {
4421
- return JSON.parse(readFileSync5(path44, "utf-8"));
4421
+ return JSON.parse(readFileSync5(path45, "utf-8"));
4422
4422
  } catch {
4423
4423
  return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
4424
4424
  }
@@ -5637,11 +5637,11 @@ function readNodeReporter(node, key2) {
5637
5637
  function buildMeshNodeCapabilityTags(node, providerType) {
5638
5638
  const provider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : firstProviderPriority(node?.policy);
5639
5639
  const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
5640
- const os31 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
5640
+ const os32 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
5641
5641
  const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
5642
5642
  return normalizeMeshCapabilityTags([
5643
5643
  ...Array.isArray(node?.capabilities) ? node.capabilities : [],
5644
- `os=${os31}`,
5644
+ `os=${os32}`,
5645
5645
  `arch=${arch2}`,
5646
5646
  ...provider ? [`provider=${provider}`] : [],
5647
5647
  // Worktree nodes automatically expose a "worktree=<branch>" tag so that
@@ -6594,10 +6594,10 @@ var init_mesh_runtime_store = __esm({
6594
6594
  this.migratedMeshIds.add(meshId);
6595
6595
  const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
6596
6596
  if (count.count > 0) return;
6597
- const path44 = legacyQueuePath(meshId);
6598
- if (!existsSync8(path44)) return;
6597
+ const path45 = legacyQueuePath(meshId);
6598
+ if (!existsSync8(path45)) return;
6599
6599
  try {
6600
- const entries = JSON.parse(readFileSync6(path44, "utf-8"));
6600
+ const entries = JSON.parse(readFileSync6(path45, "utf-8"));
6601
6601
  if (!Array.isArray(entries)) return;
6602
6602
  const insert = this.db.prepare(`
6603
6603
  INSERT OR REPLACE INTO mesh_queue (
@@ -8510,8 +8510,8 @@ function resolveMeshCoordinatorSetup(options) {
8510
8510
  }
8511
8511
  const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
8512
8512
  if (mcpConfig.mode === "auto_import") {
8513
- const path44 = mcpConfig.path?.trim();
8514
- if (!path44) {
8513
+ const path45 = mcpConfig.path?.trim();
8514
+ if (!path45) {
8515
8515
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
8516
8516
  }
8517
8517
  const mcpServer = resolveAdhdevMcpServerLaunch({
@@ -8531,7 +8531,7 @@ function resolveMeshCoordinatorSetup(options) {
8531
8531
  return {
8532
8532
  kind: "auto_import",
8533
8533
  serverName,
8534
- configPath: resolveMcpConfigPath(path44, workspace),
8534
+ configPath: resolveMcpConfigPath(path45, workspace),
8535
8535
  configFormat: mcpConfig.format,
8536
8536
  mcpServer
8537
8537
  };
@@ -8732,8 +8732,8 @@ function stripCoordinatorWrapperFile(filePath) {
8732
8732
  const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
8733
8733
  if (!remaining.trim()) {
8734
8734
  try {
8735
- const fs40 = __require("fs");
8736
- fs40.unlinkSync(filePath);
8735
+ const fs41 = __require("fs");
8736
+ fs41.unlinkSync(filePath);
8737
8737
  } catch {
8738
8738
  }
8739
8739
  } else {
@@ -8833,10 +8833,10 @@ function getRegistryPath() {
8833
8833
  return join11(getDaemonDataDir(), "mesh-coordinators.json");
8834
8834
  }
8835
8835
  function loadMeshCoordinatorRegistry() {
8836
- const path44 = getRegistryPath();
8837
- if (!existsSync10(path44)) return;
8836
+ const path45 = getRegistryPath();
8837
+ if (!existsSync10(path45)) return;
8838
8838
  try {
8839
- const raw = JSON.parse(readFileSync8(path44, "utf-8"));
8839
+ const raw = JSON.parse(readFileSync8(path45, "utf-8"));
8840
8840
  if (!Array.isArray(raw)) return;
8841
8841
  _registry.clear();
8842
8842
  for (const entry of raw) {
@@ -9008,8 +9008,8 @@ function validateMeshRefineConfig(config, source = "inline") {
9008
9008
  if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
9009
9009
  return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands, bootstrapMode, deprecationWarnings };
9010
9010
  }
9011
- function parseConfigText2(path44, text) {
9012
- if (/\.json$/i.test(path44)) return JSON.parse(text);
9011
+ function parseConfigText2(path45, text) {
9012
+ if (/\.json$/i.test(path45)) return JSON.parse(text);
9013
9013
  return yaml2.load(text);
9014
9014
  }
9015
9015
  function loadMeshRefineConfig(mesh, workspace) {
@@ -9419,8 +9419,8 @@ function isCleanIgnoringSubmoduleGitlinks(porcelain, submodulePaths) {
9419
9419
  const lines = porcelain.split(/\r?\n/).filter((line) => line.length > 0);
9420
9420
  for (const line of lines) {
9421
9421
  const status = line.slice(0, 2);
9422
- const path44 = line.slice(3).trim().replace(/\\/g, "/").replace(/\/+$/, "");
9423
- const isGitlinkPointerMove = (status === " M" || status === "M ") && submodulePaths.has(path44);
9422
+ const path45 = line.slice(3).trim().replace(/\\/g, "/").replace(/\/+$/, "");
9423
+ const isGitlinkPointerMove = (status === " M" || status === "M ") && submodulePaths.has(path45);
9424
9424
  if (!isGitlinkPointerMove) return false;
9425
9425
  }
9426
9426
  return true;
@@ -9455,8 +9455,8 @@ function shouldDeferDispatchForBootstrap(node, nowMs = Date.now()) {
9455
9455
  if (node?.worktreeBootstrap?.status !== "running") return false;
9456
9456
  return !isWorktreeBootstrapStaleRunning(node, nowMs);
9457
9457
  }
9458
- function parseConfigText3(path44, text) {
9459
- if (/\.json$/i.test(path44)) return JSON.parse(text);
9458
+ function parseConfigText3(path45, text) {
9459
+ if (/\.json$/i.test(path45)) return JSON.parse(text);
9460
9460
  return yaml3.load(text);
9461
9461
  }
9462
9462
  function truncateOutput(value) {
@@ -9731,8 +9731,8 @@ import * as yaml4 from "js-yaml";
9731
9731
  function isRecord3(value) {
9732
9732
  return !!value && typeof value === "object" && !Array.isArray(value);
9733
9733
  }
9734
- function parseConfigText4(path44, text) {
9735
- if (/\.json$/i.test(path44)) return JSON.parse(text);
9734
+ function parseConfigText4(path45, text) {
9735
+ if (/\.json$/i.test(path45)) return JSON.parse(text);
9736
9736
  return yaml4.load(text);
9737
9737
  }
9738
9738
  function normalizeOperatingNote(value) {
@@ -11477,9 +11477,9 @@ function normalizeCoordinatorDaemonIds(coordinatorDaemonId) {
11477
11477
  }
11478
11478
  function isMeshProtocolV2EnforceEnabled() {
11479
11479
  const raw = readNonEmptyString2(process.env.MESH_PROTOCOL_V2_ENFORCE);
11480
- if (!raw) return false;
11480
+ if (!raw) return true;
11481
11481
  const v = raw.trim().toLowerCase();
11482
- return v === "1" || v === "true" || v === "on" || v === "yes";
11482
+ return !(v === "0" || v === "false" || v === "off" || v === "no");
11483
11483
  }
11484
11484
  function ledgerRecordQuarantinedEvent(event, reason) {
11485
11485
  try {
@@ -11688,10 +11688,10 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
11688
11688
  const primaryDaemonId = daemonIds[0];
11689
11689
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
11690
11690
  const events = [];
11691
- for (const path44 of paths) {
11692
- if (!existsSync15(path44)) continue;
11691
+ for (const path45 of paths) {
11692
+ if (!existsSync15(path45)) continue;
11693
11693
  try {
11694
- const raw = readFileSync12(path44, "utf-8");
11694
+ const raw = readFileSync12(path45, "utf-8");
11695
11695
  const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
11696
11696
  try {
11697
11697
  return [JSON.parse(line)];
@@ -11699,7 +11699,7 @@ function readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId) {
11699
11699
  return [];
11700
11700
  }
11701
11701
  });
11702
- const filtered = primaryDaemonId && path44 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
11702
+ const filtered = primaryDaemonId && path45 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId)) : parsed;
11703
11703
  events.push(...filtered);
11704
11704
  } catch {
11705
11705
  }
@@ -11764,11 +11764,11 @@ function reconcilePendingMeshCoordinatorEvents(meshId, events) {
11764
11764
  const reconciled = terminalJobIds.size === 0 ? events : events.filter((event) => !(event.event === "refine:accepted" && terminalJobIds.has(readRefineJobId2(event))));
11765
11765
  return backfilled.length === 0 ? reconciled : [...reconciled, ...backfilled];
11766
11766
  }
11767
- function trimPendingEventsIfNeeded(path44) {
11767
+ function trimPendingEventsIfNeeded(path45) {
11768
11768
  try {
11769
- if (!existsSync15(path44)) return;
11770
- if (statSync6(path44).size <= MAX_PENDING_EVENTS_BYTES) return;
11771
- const lines = readFileSync12(path44, "utf-8").split("\n").filter(Boolean);
11769
+ if (!existsSync15(path45)) return;
11770
+ if (statSync6(path45).size <= MAX_PENDING_EVENTS_BYTES) return;
11771
+ const lines = readFileSync12(path45, "utf-8").split("\n").filter(Boolean);
11772
11772
  if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
11773
11773
  const dropped = lines.slice(0, lines.length - MAX_PENDING_EVENTS_KEEP);
11774
11774
  for (const line of dropped) {
@@ -11801,7 +11801,7 @@ function trimPendingEventsIfNeeded(path44) {
11801
11801
  LOG.warn("MeshEvents", `Failed to ledger-record trim-dropped ${event.event} for mesh ${event.meshId}: ${e?.message || e}`);
11802
11802
  }
11803
11803
  }
11804
- writeFileSync6(path44, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
11804
+ writeFileSync6(path45, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
11805
11805
  } catch {
11806
11806
  }
11807
11807
  }
@@ -11809,18 +11809,24 @@ function stampPendingEventV2(event, hint) {
11809
11809
  if (event.protocolVersion === MESH_PROTOCOL_VERSION_V2 && readNonEmptyString2(event.eventId)) {
11810
11810
  return event;
11811
11811
  }
11812
- const dispatchedBy = hint?.dispatchedBy ?? coordinatorIdentityFromEmitFields({
11812
+ const coordinatorIdentity = hint?.dispatchedBy ?? coordinatorIdentityFromEmitFields({
11813
11813
  daemonId: event.targetCoordinatorDaemonId,
11814
11814
  coordinatorRunId: hint?.coordinatorRunId,
11815
11815
  sessionId: event.targetCoordinatorSessionId
11816
11816
  });
11817
- const intendedFor = hint?.intendedFor ?? dispatchedBy;
11817
+ const selfFallback = !coordinatorIdentity;
11818
+ const dispatchedBy = coordinatorIdentity ?? coordinatorIdentityFromEmitFields({
11819
+ daemonId: readNonEmptyString2(loadConfig().machineId)
11820
+ });
11821
+ const intendedFor = hint?.intendedFor ?? (selfFallback ? void 0 : coordinatorIdentity);
11818
11822
  const stamp = buildPendingEventEmitStamp({
11819
11823
  eventName: event.event,
11820
11824
  eventId: randomUUID8(),
11821
11825
  dispatchedBy,
11822
11826
  intendedFor,
11823
- scope: hint?.scope
11827
+ // Force broadcast for the self-fallback so a unicast-defaulting terminal
11828
+ // event isn't addressed to this daemon alone; an explicit hint still wins.
11829
+ scope: hint?.scope ?? (selfFallback ? "broadcast" : void 0)
11824
11830
  });
11825
11831
  if (!stamp) return event;
11826
11832
  return {
@@ -11864,6 +11870,9 @@ function readV2EnvelopeFromWire(payload) {
11864
11870
  }
11865
11871
  function queuePendingMeshCoordinatorEvent(rawEvent, hint) {
11866
11872
  const event = stampPendingEventV2(rawEvent, hint);
11873
+ return persistPendingMeshCoordinatorEvent(event);
11874
+ }
11875
+ function persistPendingMeshCoordinatorEvent(event) {
11867
11876
  try {
11868
11877
  if (hasPendingRefineTerminalEventDuplicate(event)) {
11869
11878
  LOG.info("MeshEvents", `Suppressed duplicate pending ${event.event} for refine job ${readRefineJobId2(event)}`);
@@ -11898,9 +11907,9 @@ function queuePendingMeshCoordinatorEvent(rawEvent, hint) {
11898
11907
  } catch {
11899
11908
  }
11900
11909
  try {
11901
- const path44 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
11902
- trimPendingEventsIfNeeded(path44);
11903
- appendFileSync2(path44, JSON.stringify(event) + "\n", "utf-8");
11910
+ const path45 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
11911
+ trimPendingEventsIfNeeded(path45);
11912
+ appendFileSync2(path45, JSON.stringify(event) + "\n", "utf-8");
11904
11913
  } catch (e) {
11905
11914
  if (!sqliteOk) throw e;
11906
11915
  LOG.warn("MeshEvents", `JSONL append failed for mesh ${event.meshId}; SQLite holds the event: ${e?.message || e}`);
@@ -11911,10 +11920,10 @@ function queuePendingMeshCoordinatorEvent(rawEvent, hint) {
11911
11920
  return false;
11912
11921
  }
11913
11922
  }
11914
- function atomicDrainFile(path44) {
11915
- const tmpPath = `${path44}.draining`;
11923
+ function atomicDrainFile(path45) {
11924
+ const tmpPath = `${path45}.draining`;
11916
11925
  try {
11917
- renameSync4(path44, tmpPath);
11926
+ renameSync4(path45, tmpPath);
11918
11927
  } catch {
11919
11928
  return null;
11920
11929
  }
@@ -11933,10 +11942,10 @@ function atomicDrainFile(path44) {
11933
11942
  return null;
11934
11943
  }
11935
11944
  }
11936
- function selectiveDrainFile(path44, predicate) {
11937
- const tmpPath = `${path44}.draining`;
11945
+ function selectiveDrainFile(path45, predicate) {
11946
+ const tmpPath = `${path45}.draining`;
11938
11947
  try {
11939
- renameSync4(path44, tmpPath);
11948
+ renameSync4(path45, tmpPath);
11940
11949
  } catch {
11941
11950
  return [];
11942
11951
  }
@@ -11968,12 +11977,12 @@ function selectiveDrainFile(path44, predicate) {
11968
11977
  }
11969
11978
  try {
11970
11979
  if (keptLines.length > 0) {
11971
- writeFileSync6(path44, keptLines.join("\n") + "\n", "utf-8");
11980
+ writeFileSync6(path45, keptLines.join("\n") + "\n", "utf-8");
11972
11981
  }
11973
11982
  unlinkSync2(tmpPath);
11974
11983
  } catch {
11975
11984
  try {
11976
- if (existsSync15(tmpPath) && !existsSync15(path44)) renameSync4(tmpPath, path44);
11985
+ if (existsSync15(tmpPath) && !existsSync15(path45)) renameSync4(tmpPath, path45);
11977
11986
  } catch {
11978
11987
  }
11979
11988
  return [];
@@ -12014,16 +12023,16 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
12014
12023
  LOG.warn("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only: ${e?.message || e}`);
12015
12024
  }
12016
12025
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
12017
- for (const path44 of paths) {
12018
- const isSharedFile = !!primaryDaemonId && path44 === getPendingEventsPath(meshId);
12026
+ for (const path45 of paths) {
12027
+ const isSharedFile = !!primaryDaemonId && path45 === getPendingEventsPath(meshId);
12019
12028
  const targets = (e) => !isSharedFile || !e.targetCoordinatorDaemonId || daemonIds.includes(e.targetCoordinatorDaemonId);
12020
12029
  if (onlyEvents) {
12021
- for (const event of selectiveDrainFile(path44, (e) => targets(e) && matchesFilter(e.event))) {
12030
+ for (const event of selectiveDrainFile(path45, (e) => targets(e) && matchesFilter(e.event))) {
12022
12031
  pushUnique(event);
12023
12032
  }
12024
12033
  continue;
12025
12034
  }
12026
- const content = atomicDrainFile(path44);
12035
+ const content = atomicDrainFile(path45);
12027
12036
  if (!content) continue;
12028
12037
  const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
12029
12038
  try {
@@ -12064,9 +12073,9 @@ function retractPendingDispatchBlockedEvent(meshId, taskId, coordinatorDaemonId)
12064
12073
  const daemonIds = normalizeCoordinatorDaemonIds(coordinatorDaemonId);
12065
12074
  const primaryDaemonId = daemonIds[0];
12066
12075
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
12067
- for (const path44 of paths) {
12076
+ for (const path45 of paths) {
12068
12077
  try {
12069
- removed += selectiveDrainFile(path44, matchesTask).length;
12078
+ removed += selectiveDrainFile(path45, matchesTask).length;
12070
12079
  } catch {
12071
12080
  }
12072
12081
  }
@@ -12118,9 +12127,9 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
12118
12127
  } catch {
12119
12128
  }
12120
12129
  const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
12121
- for (const path44 of paths) {
12122
- if (existsSync15(path44)) try {
12123
- unlinkSync2(path44);
12130
+ for (const path45 of paths) {
12131
+ if (existsSync15(path45)) try {
12132
+ unlinkSync2(path45);
12124
12133
  } catch {
12125
12134
  }
12126
12135
  }
@@ -12130,6 +12139,7 @@ var init_mesh_events_pending = __esm({
12130
12139
  "src/mesh/mesh-events-pending.ts"() {
12131
12140
  "use strict";
12132
12141
  init_logger();
12142
+ init_config();
12133
12143
  init_mesh_ledger();
12134
12144
  init_mesh_runtime_store();
12135
12145
  init_mesh_events_utils();
@@ -12802,9 +12812,9 @@ function findBinary(name) {
12802
12812
  for (const ext of exes) {
12803
12813
  const fullPath = path11.join(p, trimmed + ext);
12804
12814
  try {
12805
- const fs40 = __require("fs");
12806
- if (fs40.existsSync(fullPath)) {
12807
- const stat2 = fs40.statSync(fullPath);
12815
+ const fs41 = __require("fs");
12816
+ if (fs41.existsSync(fullPath)) {
12817
+ const stat2 = fs41.statSync(fullPath);
12808
12818
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
12809
12819
  return fullPath;
12810
12820
  }
@@ -12818,12 +12828,12 @@ function findBinary(name) {
12818
12828
  function isScriptBinary(binaryPath) {
12819
12829
  if (!path11.isAbsolute(binaryPath)) return false;
12820
12830
  try {
12821
- const fs40 = __require("fs");
12822
- const resolved = fs40.realpathSync(binaryPath);
12831
+ const fs41 = __require("fs");
12832
+ const resolved = fs41.realpathSync(binaryPath);
12823
12833
  const head = Buffer.alloc(8);
12824
- const fd = fs40.openSync(resolved, "r");
12825
- fs40.readSync(fd, head, 0, 8, 0);
12826
- fs40.closeSync(fd);
12834
+ const fd = fs41.openSync(resolved, "r");
12835
+ fs41.readSync(fd, head, 0, 8, 0);
12836
+ fs41.closeSync(fd);
12827
12837
  let i = 0;
12828
12838
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
12829
12839
  return head[i] === 35 && head[i + 1] === 33;
@@ -12834,12 +12844,12 @@ function isScriptBinary(binaryPath) {
12834
12844
  function looksLikeMachOOrElf(filePath) {
12835
12845
  if (!path11.isAbsolute(filePath)) return false;
12836
12846
  try {
12837
- const fs40 = __require("fs");
12838
- const resolved = fs40.realpathSync(filePath);
12847
+ const fs41 = __require("fs");
12848
+ const resolved = fs41.realpathSync(filePath);
12839
12849
  const buf = Buffer.alloc(8);
12840
- const fd = fs40.openSync(resolved, "r");
12841
- fs40.readSync(fd, buf, 0, 8, 0);
12842
- fs40.closeSync(fd);
12850
+ const fd = fs41.openSync(resolved, "r");
12851
+ fs41.readSync(fd, buf, 0, 8, 0);
12852
+ fs41.closeSync(fd);
12843
12853
  let i = 0;
12844
12854
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
12845
12855
  const b = buf.subarray(i);
@@ -18332,26 +18342,80 @@ var init_mesh_events_coordinator = __esm({
18332
18342
  }
18333
18343
  });
18334
18344
 
18335
- // src/mesh/mesh-reconcile-loop.ts
18336
- function resolveAutoPruneMinAgeMs() {
18337
- const raw = readNonEmptyString2(process.env.MESH_AUTO_PRUNE_MIN_AGE_MS);
18338
- if (raw) {
18339
- const parsed = Number.parseInt(raw, 10);
18340
- if (Number.isFinite(parsed) && parsed >= 60 * 6e4 && parsed <= 30 * 24 * 60 * 6e4) return parsed;
18345
+ // src/mesh/mesh-reconcile-identity.ts
18346
+ function resolveCoordinatorDaemonIds(components) {
18347
+ const statusInstanceId = readNonEmptyString2(components.statusInstanceId);
18348
+ const machineId = readNonEmptyString2(loadConfig().machineId);
18349
+ return expandDaemonIdForms([statusInstanceId, machineId]);
18350
+ }
18351
+ function daemonHostsMesh(mesh, daemonIds) {
18352
+ const host = mesh.meshHost;
18353
+ if (!host) return true;
18354
+ if (host.role && host.role !== "host") return false;
18355
+ const hostDaemonId = readNonEmptyString2(host.hostDaemonId);
18356
+ if (!hostDaemonId) return true;
18357
+ return daemonIdListIncludes(daemonIds, hostDaemonId);
18358
+ }
18359
+ function daemonIdListIncludes(ids, id) {
18360
+ if (!id) return false;
18361
+ return ids.some((candidate) => candidate === id || daemonIdsEquivalent(candidate, id));
18362
+ }
18363
+ function resolveCoordinatorSelfIds(mesh, drainDaemonIds) {
18364
+ const ids = new Set(drainDaemonIds);
18365
+ for (const node of mesh.nodes) {
18366
+ const nodeDaemonId = readNonEmptyString2(node.daemonId);
18367
+ const nodeMachineId = readNonEmptyString2(node.machineId);
18368
+ const isSelf = nodeDaemonId && daemonIdListIncludes(drainDaemonIds, nodeDaemonId) || nodeMachineId && daemonIdListIncludes(drainDaemonIds, nodeMachineId);
18369
+ if (!isSelf) continue;
18370
+ if (nodeDaemonId) ids.add(nodeDaemonId);
18371
+ if (nodeMachineId) ids.add(nodeMachineId);
18341
18372
  }
18342
- return DEFAULT_AUTO_PRUNE_MIN_AGE_MS;
18373
+ const hostDaemonId = readNonEmptyString2(mesh.meshHost?.hostDaemonId);
18374
+ if (hostDaemonId && daemonIdListIncludes([...ids], hostDaemonId)) ids.add(hostDaemonId);
18375
+ return [...ids];
18343
18376
  }
18344
- function resolvePendingHeldDrainEscalateMs() {
18345
- return resolveTunedReconcileMs("MESH_PENDING_HELD_DRAIN_ESCALATE_MS", DEFAULT_PENDING_HELD_DRAIN_ESCALATE_MS, 4e3, 5 * 6e4);
18377
+ var init_mesh_reconcile_identity = __esm({
18378
+ "src/mesh/mesh-reconcile-identity.ts"() {
18379
+ "use strict";
18380
+ init_config();
18381
+ init_dist();
18382
+ init_mesh_events_utils();
18383
+ }
18384
+ });
18385
+
18386
+ // src/mesh/mesh-reconcile-v2-backstop.ts
18387
+ function getMeshV2BackstopCounters() {
18388
+ return { ...meshV2BackstopCounters };
18346
18389
  }
18347
- function resolveReconcileIntervalMs() {
18348
- const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
18349
- if (raw) {
18350
- const parsed = Number.parseInt(raw, 10);
18351
- if (Number.isFinite(parsed) && parsed >= 1e3 && parsed <= 6e4) return parsed;
18390
+ function meshProtocolV2EnforceOn() {
18391
+ const raw = process.env.MESH_PROTOCOL_V2_ENFORCE;
18392
+ if (typeof raw !== "string" || !raw.trim()) return true;
18393
+ const v = raw.trim().toLowerCase();
18394
+ return !(v === "0" || v === "false" || v === "off" || v === "no");
18395
+ }
18396
+ function recordBackstopFire(kind, detail) {
18397
+ meshV2BackstopCounters[kind]++;
18398
+ if (meshProtocolV2EnforceOn()) {
18399
+ LOG.warn("MeshReconcileV2", `v2 ENFORCE last-resort backstop fired (${kind}): ${detail}. Under a healthy v2 completion contract this should be 0 \u2014 a worker's real terminal emit was lost/late.`);
18352
18400
  }
18353
- return DEFAULT_RECONCILE_INTERVAL_MS;
18354
18401
  }
18402
+ var meshV2BackstopCounters;
18403
+ var init_mesh_reconcile_v2_backstop = __esm({
18404
+ "src/mesh/mesh-reconcile-v2-backstop.ts"() {
18405
+ "use strict";
18406
+ init_logger();
18407
+ meshV2BackstopCounters = {
18408
+ /** PHASE-4 transcript synthesis actually reconciled a missing completion. */
18409
+ phase4SynthesisFired: 0,
18410
+ /** Acked-hold transcript fast-track promoted a synth ahead of the death deadline. */
18411
+ ackedHoldFastTrackFired: 0,
18412
+ /** Acked-hold death-deadline backstop released a held synth (the 8-min net). */
18413
+ ackedHoldDeathDeadlineFired: 0
18414
+ };
18415
+ }
18416
+ });
18417
+
18418
+ // src/mesh/mesh-reconcile-acked-hold.ts
18355
18419
  function resolveTunedReconcileMs(envName, def, min, max) {
18356
18420
  const raw = readNonEmptyString2(process.env[envName]);
18357
18421
  if (raw) {
@@ -18366,21 +18430,6 @@ function resolveAckedDeathDeadlineMs() {
18366
18430
  function resolveAckedTranscriptFastTrackGraceMs() {
18367
18431
  return resolveTunedReconcileMs("MESH_INFLIGHT_ACKED_TRANSCRIPT_FASTTRACK_GRACE_MS", 4e4, 0, 5 * 6e4);
18368
18432
  }
18369
- function getMeshV2BackstopCounters() {
18370
- return { ...meshV2BackstopCounters };
18371
- }
18372
- function meshProtocolV2EnforceOn() {
18373
- const raw = process.env.MESH_PROTOCOL_V2_ENFORCE;
18374
- if (typeof raw !== "string") return false;
18375
- const v = raw.trim().toLowerCase();
18376
- return v === "1" || v === "true" || v === "on" || v === "yes";
18377
- }
18378
- function recordBackstopFire(kind, detail) {
18379
- meshV2BackstopCounters[kind]++;
18380
- if (meshProtocolV2EnforceOn()) {
18381
- LOG.warn("MeshReconcileV2", `v2 ENFORCE last-resort backstop fired (${kind}): ${detail}. Under a healthy v2 completion contract this should be 0 \u2014 a worker's real terminal emit was lost/late.`);
18382
- }
18383
- }
18384
18433
  function inFlightSynthKey(meshId, taskId) {
18385
18434
  return `${meshId}::${taskId}`;
18386
18435
  }
@@ -18463,36 +18512,54 @@ function rehydrateAckedHoldsForMesh(meshId) {
18463
18512
  LOG.info("MeshReconcile", `Rehydrated ${rows.length} persisted acked-hold row(s) for mesh ${meshId} after (re)start`);
18464
18513
  }
18465
18514
  }
18466
- function resolveCoordinatorDaemonIds(components) {
18467
- const statusInstanceId = readNonEmptyString2(components.statusInstanceId);
18468
- const machineId = readNonEmptyString2(loadConfig().machineId);
18469
- return expandDaemonIdForms([statusInstanceId, machineId]);
18515
+ function collectHeldSynthKeysForMesh(meshId) {
18516
+ const heldKeys = /* @__PURE__ */ new Set();
18517
+ for (const key2 of inFlightAckedHoldState.keys()) {
18518
+ if (key2.startsWith(`${meshId}::`)) heldKeys.add(key2);
18519
+ }
18520
+ const store = holdStore();
18521
+ if (store) {
18522
+ try {
18523
+ for (const row of store.listInflightHoldsByMesh(meshId)) {
18524
+ heldKeys.add(inFlightSynthKey(meshId, row.taskId));
18525
+ }
18526
+ } catch {
18527
+ }
18528
+ }
18529
+ return heldKeys;
18470
18530
  }
18471
- function daemonHostsMesh(mesh, daemonIds) {
18472
- const host = mesh.meshHost;
18473
- if (!host) return true;
18474
- if (host.role && host.role !== "host") return false;
18475
- const hostDaemonId = readNonEmptyString2(host.hostDaemonId);
18476
- if (!hostDaemonId) return true;
18477
- return daemonIdListIncludes(daemonIds, hostDaemonId);
18531
+ var ACKED_DEATH_CONSECUTIVE_READ_FAILURES, inFlightAckedHoldState, rehydratedHoldMeshes;
18532
+ var init_mesh_reconcile_acked_hold = __esm({
18533
+ "src/mesh/mesh-reconcile-acked-hold.ts"() {
18534
+ "use strict";
18535
+ init_logger();
18536
+ init_mesh_runtime_store();
18537
+ init_mesh_events_utils();
18538
+ ACKED_DEATH_CONSECUTIVE_READ_FAILURES = 3;
18539
+ inFlightAckedHoldState = /* @__PURE__ */ new Map();
18540
+ rehydratedHoldMeshes = /* @__PURE__ */ new Set();
18541
+ }
18542
+ });
18543
+
18544
+ // src/mesh/mesh-reconcile-loop.ts
18545
+ function resolveAutoPruneMinAgeMs() {
18546
+ const raw = readNonEmptyString2(process.env.MESH_AUTO_PRUNE_MIN_AGE_MS);
18547
+ if (raw) {
18548
+ const parsed = Number.parseInt(raw, 10);
18549
+ if (Number.isFinite(parsed) && parsed >= 60 * 6e4 && parsed <= 30 * 24 * 60 * 6e4) return parsed;
18550
+ }
18551
+ return DEFAULT_AUTO_PRUNE_MIN_AGE_MS;
18478
18552
  }
18479
- function daemonIdListIncludes(ids, id) {
18480
- if (!id) return false;
18481
- return ids.some((candidate) => candidate === id || daemonIdsEquivalent(candidate, id));
18553
+ function resolvePendingHeldDrainEscalateMs() {
18554
+ return resolveTunedReconcileMs("MESH_PENDING_HELD_DRAIN_ESCALATE_MS", DEFAULT_PENDING_HELD_DRAIN_ESCALATE_MS, 4e3, 5 * 6e4);
18482
18555
  }
18483
- function resolveCoordinatorSelfIds(mesh, drainDaemonIds) {
18484
- const ids = new Set(drainDaemonIds);
18485
- for (const node of mesh.nodes) {
18486
- const nodeDaemonId = readNonEmptyString2(node.daemonId);
18487
- const nodeMachineId = readNonEmptyString2(node.machineId);
18488
- const isSelf = nodeDaemonId && daemonIdListIncludes(drainDaemonIds, nodeDaemonId) || nodeMachineId && daemonIdListIncludes(drainDaemonIds, nodeMachineId);
18489
- if (!isSelf) continue;
18490
- if (nodeDaemonId) ids.add(nodeDaemonId);
18491
- if (nodeMachineId) ids.add(nodeMachineId);
18556
+ function resolveReconcileIntervalMs() {
18557
+ const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
18558
+ if (raw) {
18559
+ const parsed = Number.parseInt(raw, 10);
18560
+ if (Number.isFinite(parsed) && parsed >= 1e3 && parsed <= 6e4) return parsed;
18492
18561
  }
18493
- const hostDaemonId = readNonEmptyString2(mesh.meshHost?.hostDaemonId);
18494
- if (hostDaemonId && daemonIdListIncludes([...ids], hostDaemonId)) ids.add(hostDaemonId);
18495
- return [...ids];
18562
+ return DEFAULT_RECONCILE_INTERVAL_MS;
18496
18563
  }
18497
18564
  function findLiveCoordinators(components) {
18498
18565
  const out = [];
@@ -19258,19 +19325,7 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
19258
19325
  const activeTaskKeys = new Set(
19259
19326
  dispatches.map((d) => readNonEmptyString2(d.taskId)).filter(Boolean).map((taskId) => inFlightSynthKey(mesh.id, taskId))
19260
19327
  );
19261
- const heldKeys = /* @__PURE__ */ new Set();
19262
- for (const key2 of inFlightAckedHoldState.keys()) {
19263
- if (key2.startsWith(`${mesh.id}::`)) heldKeys.add(key2);
19264
- }
19265
- const store = holdStore();
19266
- if (store) {
19267
- try {
19268
- for (const row of store.listInflightHoldsByMesh(mesh.id)) {
19269
- heldKeys.add(inFlightSynthKey(mesh.id, row.taskId));
19270
- }
19271
- } catch {
19272
- }
19273
- }
19328
+ const heldKeys = collectHeldSynthKeysForMesh(mesh.id);
19274
19329
  for (const key2 of heldKeys) {
19275
19330
  if (!activeTaskKeys.has(key2)) deleteHoldState(key2, mesh.id);
19276
19331
  }
@@ -19546,7 +19601,7 @@ function setupMeshReconcileLoop(components) {
19546
19601
  }
19547
19602
  };
19548
19603
  }
19549
- var DEFAULT_RECONCILE_INTERVAL_MS, DEFAULT_AUTO_PRUNE_MIN_AGE_MS, DEFAULT_PENDING_HELD_DRAIN_ESCALATE_MS, ACKED_DEATH_CONSECUTIVE_READ_FAILURES, inFlightAckedHoldState, rehydratedHoldMeshes, meshV2BackstopCounters, coordinatorModalParkState, heldEventLedgerRecorded, ASSIGNED_STRANDED_DEADLINE_MS, DELIVERED_NO_TURN_DEADLINE_MS, RECLAIM_UNKNOWN_GRACE_TICKS, deliveredNoTurnUnknownStreak, STRICT_SESSION_MATCH_TTL_MS, unresolvedForwardRejectionCounts, MAX_FORWARD_REJECTIONS;
19604
+ var DEFAULT_RECONCILE_INTERVAL_MS, DEFAULT_AUTO_PRUNE_MIN_AGE_MS, DEFAULT_PENDING_HELD_DRAIN_ESCALATE_MS, coordinatorModalParkState, heldEventLedgerRecorded, ASSIGNED_STRANDED_DEADLINE_MS, DELIVERED_NO_TURN_DEADLINE_MS, RECLAIM_UNKNOWN_GRACE_TICKS, deliveredNoTurnUnknownStreak, STRICT_SESSION_MATCH_TTL_MS, unresolvedForwardRejectionCounts, MAX_FORWARD_REJECTIONS;
19550
19605
  var init_mesh_reconcile_loop = __esm({
19551
19606
  "src/mesh/mesh-reconcile-loop.ts"() {
19552
19607
  "use strict";
@@ -19568,20 +19623,14 @@ var init_mesh_reconcile_loop = __esm({
19568
19623
  init_mesh_active_work();
19569
19624
  init_mesh_events_stale();
19570
19625
  init_chat_message_normalization();
19626
+ init_mesh_reconcile_identity();
19627
+ init_mesh_reconcile_v2_backstop();
19628
+ init_mesh_reconcile_acked_hold();
19629
+ init_mesh_reconcile_v2_backstop();
19630
+ init_mesh_reconcile_acked_hold();
19571
19631
  DEFAULT_RECONCILE_INTERVAL_MS = 4e3;
19572
19632
  DEFAULT_AUTO_PRUNE_MIN_AGE_MS = 24 * 60 * 6e4;
19573
19633
  DEFAULT_PENDING_HELD_DRAIN_ESCALATE_MS = 12e3;
19574
- ACKED_DEATH_CONSECUTIVE_READ_FAILURES = 3;
19575
- inFlightAckedHoldState = /* @__PURE__ */ new Map();
19576
- rehydratedHoldMeshes = /* @__PURE__ */ new Set();
19577
- meshV2BackstopCounters = {
19578
- /** PHASE-4 transcript synthesis actually reconciled a missing completion. */
19579
- phase4SynthesisFired: 0,
19580
- /** Acked-hold transcript fast-track promoted a synth ahead of the death deadline. */
19581
- ackedHoldFastTrackFired: 0,
19582
- /** Acked-hold death-deadline backstop released a held synth (the 8-min net). */
19583
- ackedHoldDeathDeadlineFired: 0
19584
- };
19585
19634
  coordinatorModalParkState = /* @__PURE__ */ new Map();
19586
19635
  heldEventLedgerRecorded = /* @__PURE__ */ new Set();
19587
19636
  ASSIGNED_STRANDED_DEADLINE_MS = 5 * 6e4;
@@ -20278,7 +20327,7 @@ function getCliValidator() {
20278
20327
  return _cliValidator;
20279
20328
  }
20280
20329
  function formatIssue(err) {
20281
- const path44 = err.instancePath || "";
20330
+ const path45 = err.instancePath || "";
20282
20331
  const params = err.params;
20283
20332
  let message = err.message || "validation failed";
20284
20333
  let allowed;
@@ -20296,7 +20345,7 @@ function formatIssue(err) {
20296
20345
  } else if (err.keyword === "type") {
20297
20346
  message = `must be ${params.type}`;
20298
20347
  }
20299
- return { path: path44, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
20348
+ return { path: path45, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
20300
20349
  }
20301
20350
  function validateCliProviderManifest(manifest) {
20302
20351
  const validator = getCliValidator();
@@ -20591,49 +20640,49 @@ function validateFsmSpec(raw) {
20591
20640
  }
20592
20641
  return errs;
20593
20642
  }
20594
- function validateCondition(c, sectionIds, path44) {
20643
+ function validateCondition(c, sectionIds, path45) {
20595
20644
  const errs = [];
20596
20645
  const w = c;
20597
20646
  if ("all" in w) {
20598
- w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path44}.all[${i}]`)));
20647
+ w.all.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path45}.all[${i}]`)));
20599
20648
  return errs;
20600
20649
  }
20601
20650
  if ("any" in w) {
20602
- w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path44}.any[${i}]`)));
20651
+ w.any.forEach((x, i) => errs.push(...validateCondition(x, sectionIds, `${path45}.any[${i}]`)));
20603
20652
  return errs;
20604
20653
  }
20605
20654
  if ("not" in w) {
20606
- errs.push(...validateCondition(w.not, sectionIds, `${path44}.not`));
20655
+ errs.push(...validateCondition(w.not, sectionIds, `${path45}.not`));
20607
20656
  return errs;
20608
20657
  }
20609
20658
  if ("matches" in w) {
20610
- if (w.section && !sectionIds.has(w.section)) errs.push(`${path44}.section "${w.section}" unknown`);
20659
+ if (w.section && !sectionIds.has(w.section)) errs.push(`${path45}.section "${w.section}" unknown`);
20611
20660
  try {
20612
20661
  new RegExp(w.matches, w.flags ?? "i");
20613
20662
  } catch (e) {
20614
- errs.push(`${path44}.matches invalid regex: ${e.message}`);
20663
+ errs.push(`${path45}.matches invalid regex: ${e.message}`);
20615
20664
  }
20616
20665
  return errs;
20617
20666
  }
20618
20667
  if ("cursor_above" in w && "changed" in w) return errs;
20619
20668
  if ("elapsed_ms" in w) {
20620
- if (typeof w.elapsed_ms !== "number") errs.push(`${path44}.elapsed_ms must be a number`);
20669
+ if (typeof w.elapsed_ms !== "number") errs.push(`${path45}.elapsed_ms must be a number`);
20621
20670
  return errs;
20622
20671
  }
20623
20672
  if ("stable_ms" in w) {
20624
- if (typeof w.stable_ms !== "number") errs.push(`${path44}.stable_ms must be a number`);
20625
- if (w.section && !sectionIds.has(w.section)) errs.push(`${path44}.section "${w.section}" unknown`);
20673
+ if (typeof w.stable_ms !== "number") errs.push(`${path45}.stable_ms must be a number`);
20674
+ if (w.section && !sectionIds.has(w.section)) errs.push(`${path45}.section "${w.section}" unknown`);
20626
20675
  if (w.ignore_lines !== void 0) {
20627
- if (typeof w.ignore_lines !== "string") errs.push(`${path44}.ignore_lines must be a string`);
20676
+ if (typeof w.ignore_lines !== "string") errs.push(`${path45}.ignore_lines must be a string`);
20628
20677
  else try {
20629
20678
  new RegExp(w.ignore_lines, "m");
20630
20679
  } catch (e) {
20631
- errs.push(`${path44}.ignore_lines invalid regex: ${e.message}`);
20680
+ errs.push(`${path45}.ignore_lines invalid regex: ${e.message}`);
20632
20681
  }
20633
20682
  }
20634
20683
  return errs;
20635
20684
  }
20636
- errs.push(`${path44} is not a recognized condition`);
20685
+ errs.push(`${path45} is not a recognized condition`);
20637
20686
  return errs;
20638
20687
  }
20639
20688
  var init_fsm_loader = __esm({
@@ -21130,8 +21179,8 @@ var init_pty_transport = __esm({
21130
21179
  let cwd = options.cwd;
21131
21180
  if (cwd) {
21132
21181
  try {
21133
- const fs40 = __require("fs");
21134
- const stat2 = fs40.statSync(cwd);
21182
+ const fs41 = __require("fs");
21183
+ const stat2 = fs41.statSync(cwd);
21135
21184
  if (!stat2.isDirectory()) cwd = os14.homedir();
21136
21185
  } catch {
21137
21186
  cwd = os14.homedir();
@@ -24926,7 +24975,7 @@ __export(require_whitelist_exports, {
24926
24975
  registerProviderScriptRoot: () => registerProviderScriptRoot,
24927
24976
  unregisterProviderScriptRoot: () => unregisterProviderScriptRoot
24928
24977
  });
24929
- import * as path34 from "path";
24978
+ import * as path35 from "path";
24930
24979
  import { createRequire as createRequire3 } from "module";
24931
24980
  import * as nodeFs from "fs";
24932
24981
  import * as nodeChildProcess from "child_process";
@@ -25067,7 +25116,7 @@ function _getRegisteredRoots() {
25067
25116
  }
25068
25117
  function canonicalize(p) {
25069
25118
  try {
25070
- const resolved = path34.resolve(p);
25119
+ const resolved = path35.resolve(p);
25071
25120
  try {
25072
25121
  return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
25073
25122
  } catch {
@@ -25087,7 +25136,7 @@ function isCallerInsideGatedRoot(callerFilename) {
25087
25136
  }
25088
25137
  for (const root of _gatedRoots) {
25089
25138
  if (normalized === root.rootPath) return root;
25090
- if (normalized.startsWith(root.rootPath + path34.sep)) return root;
25139
+ if (normalized.startsWith(root.rootPath + path35.sep)) return root;
25091
25140
  }
25092
25141
  return null;
25093
25142
  }
@@ -25106,16 +25155,16 @@ function ensureInstalled() {
25106
25155
  };
25107
25156
  }
25108
25157
  function gatedRequire(request, parent, isMain, gated, originalLoad) {
25109
- if (request.startsWith("./") || request.startsWith("../") || path34.isAbsolute(request)) {
25158
+ if (request.startsWith("./") || request.startsWith("../") || path35.isAbsolute(request)) {
25110
25159
  let resolved;
25111
25160
  try {
25112
- const callerRequire = parent?.filename ? createRequire3(parent.filename) : createRequire3(path34.join(gated.rootPath, "__entry__.js"));
25161
+ const callerRequire = parent?.filename ? createRequire3(parent.filename) : createRequire3(path35.join(gated.rootPath, "__entry__.js"));
25113
25162
  resolved = callerRequire.resolve(request);
25114
25163
  } catch {
25115
25164
  return originalLoad.call(this, request, parent, isMain);
25116
25165
  }
25117
25166
  const resolvedCanon = canonicalize(resolved) || resolved;
25118
- if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path34.sep))) {
25167
+ if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path35.sep))) {
25119
25168
  denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
25120
25169
  }
25121
25170
  return originalLoad.call(this, request, parent, isMain);
@@ -26832,17 +26881,17 @@ function checkPathExists(paths) {
26832
26881
  return null;
26833
26882
  }
26834
26883
  async function detectIDEs(providerLoader) {
26835
- const os31 = platform5();
26884
+ const os32 = platform5();
26836
26885
  const results = [];
26837
26886
  for (const def of getMergedDefinitions()) {
26838
26887
  const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
26839
- const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os31] || []) || []);
26888
+ const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os32] || []) || []);
26840
26889
  let resolvedCli = cliPath;
26841
- if (!resolvedCli && appPath && os31 === "darwin") {
26890
+ if (!resolvedCli && appPath && os32 === "darwin") {
26842
26891
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
26843
26892
  if (existsSync20(bundledCli)) resolvedCli = bundledCli;
26844
26893
  }
26845
- if (!resolvedCli && appPath && os31 === "win32") {
26894
+ if (!resolvedCli && appPath && os32 === "win32") {
26846
26895
  const { dirname: dirname17 } = await import("path");
26847
26896
  const appDir = dirname17(appPath);
26848
26897
  const candidates = [
@@ -26859,7 +26908,7 @@ async function detectIDEs(providerLoader) {
26859
26908
  }
26860
26909
  }
26861
26910
  }
26862
- const installed = os31 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
26911
+ const installed = os32 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
26863
26912
  const version = null;
26864
26913
  results.push({
26865
26914
  id: def.id,
@@ -36289,9 +36338,9 @@ var DaemonCommandHandler = class {
36289
36338
  * point at a sibling git checkout.
36290
36339
  */
36291
36340
  getUpstreamInstallRoot() {
36292
- const os31 = __require("os");
36293
- const path44 = __require("path");
36294
- return path44.join(os31.homedir(), ".adhdev", "providers", ".upstream");
36341
+ const os32 = __require("os");
36342
+ const path45 = __require("path");
36343
+ return path45.join(os32.homedir(), ".adhdev", "providers", ".upstream");
36295
36344
  }
36296
36345
  /**
36297
36346
  * Download a single provider manifest from the registry and write it to
@@ -36315,8 +36364,8 @@ var DaemonCommandHandler = class {
36315
36364
  return { success: false, error: "invalid type" };
36316
36365
  }
36317
36366
  const https = __require("https");
36318
- const fs40 = __require("fs");
36319
- const path44 = __require("path");
36367
+ const fs41 = __require("fs");
36368
+ const path45 = __require("path");
36320
36369
  const REGISTRY = resolveRegistryBaseUrl(loadConfig().registryUrl);
36321
36370
  function fetchText(url, timeoutMs) {
36322
36371
  return new Promise((resolve25, reject) => {
@@ -36353,12 +36402,12 @@ var DaemonCommandHandler = class {
36353
36402
  return { success: false, error: `checksum mismatch: expected ${meta.checksum}, got ${actualChecksum}` };
36354
36403
  }
36355
36404
  const installRoot = this.getUpstreamInstallRoot();
36356
- const installRootResolved = path44.resolve(installRoot);
36357
- const targetDir = path44.resolve(path44.join(installRoot, category, type));
36358
- if (!targetDir.startsWith(installRootResolved + path44.sep)) {
36405
+ const installRootResolved = path45.resolve(installRoot);
36406
+ const targetDir = path45.resolve(path45.join(installRoot, category, type));
36407
+ if (!targetDir.startsWith(installRootResolved + path45.sep)) {
36359
36408
  return { success: false, error: "install path escaped upstream root" };
36360
36409
  }
36361
- fs40.mkdirSync(targetDir, { recursive: true });
36410
+ fs41.mkdirSync(targetDir, { recursive: true });
36362
36411
  let manifestProbe = {};
36363
36412
  try {
36364
36413
  manifestProbe = JSON.parse(manifestBody);
@@ -36382,8 +36431,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36382
36431
  }
36383
36432
  }
36384
36433
  const targetFile = isV1 ? "provider.v1.json" : "provider.json";
36385
- const targetPath = path44.join(targetDir, targetFile);
36386
- fs40.writeFileSync(targetPath, manifestBody, "utf-8");
36434
+ const targetPath = path45.join(targetDir, targetFile);
36435
+ fs41.writeFileSync(targetPath, manifestBody, "utf-8");
36387
36436
  const manifestJson = JSON.parse(manifestBody);
36388
36437
  const scriptFetch = await this.fetchProviderSources(
36389
36438
  manifestJson,
@@ -36453,8 +36502,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36453
36502
  const repo = source.repo;
36454
36503
  const ref = source.ref;
36455
36504
  const https = __require("https");
36456
- const fs40 = __require("fs");
36457
- const path44 = __require("path");
36505
+ const fs41 = __require("fs");
36506
+ const path45 = __require("path");
36458
36507
  function fetchJson(url, timeoutMs) {
36459
36508
  return new Promise((resolve25, reject) => {
36460
36509
  const req = https.get(url, {
@@ -36510,9 +36559,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36510
36559
  }
36511
36560
  let fetchedCount = 0;
36512
36561
  const sharedDirRel = `${category}/_shared`;
36513
- const sharedTargetDir = path44.resolve(path44.join(targetDir, "../_shared"));
36514
- const installRootResolved = path44.resolve(path44.join(targetDir, "../.."));
36515
- if (sharedTargetDir.startsWith(installRootResolved + path44.sep)) {
36562
+ const sharedTargetDir = path45.resolve(path45.join(targetDir, "../_shared"));
36563
+ const installRootResolved = path45.resolve(path45.join(targetDir, "../.."));
36564
+ if (sharedTargetDir.startsWith(installRootResolved + path45.sep)) {
36516
36565
  const sharedStack = [sharedDirRel];
36517
36566
  while (sharedStack.length) {
36518
36567
  const relDir = sharedStack.pop();
@@ -36535,10 +36584,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36535
36584
  try {
36536
36585
  const body = await fetchBinary(entry.download_url, 3e4);
36537
36586
  const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
36538
- const outPath = path44.resolve(path44.join(sharedTargetDir, relInside));
36539
- if (!outPath.startsWith(path44.resolve(sharedTargetDir) + path44.sep)) continue;
36540
- fs40.mkdirSync(path44.dirname(outPath), { recursive: true });
36541
- fs40.writeFileSync(outPath, body);
36587
+ const outPath = path45.resolve(path45.join(sharedTargetDir, relInside));
36588
+ if (!outPath.startsWith(path45.resolve(sharedTargetDir) + path45.sep)) continue;
36589
+ fs41.mkdirSync(path45.dirname(outPath), { recursive: true });
36590
+ fs41.writeFileSync(outPath, body);
36542
36591
  fetchedCount++;
36543
36592
  } catch (e) {
36544
36593
  errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
@@ -36571,13 +36620,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36571
36620
  try {
36572
36621
  const body = await fetchBinary(entry.download_url, 3e4);
36573
36622
  const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
36574
- const outPath = path44.resolve(path44.join(targetDir, relInsideProvider));
36575
- if (!outPath.startsWith(path44.resolve(targetDir) + path44.sep)) {
36623
+ const outPath = path45.resolve(path45.join(targetDir, relInsideProvider));
36624
+ if (!outPath.startsWith(path45.resolve(targetDir) + path45.sep)) {
36576
36625
  errors.push(`refusing to write outside targetDir: ${entry.path}`);
36577
36626
  continue;
36578
36627
  }
36579
- fs40.mkdirSync(path44.dirname(outPath), { recursive: true });
36580
- fs40.writeFileSync(outPath, body);
36628
+ fs41.mkdirSync(path45.dirname(outPath), { recursive: true });
36629
+ fs41.writeFileSync(outPath, body);
36581
36630
  fetchedCount++;
36582
36631
  } catch (e) {
36583
36632
  errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
@@ -36605,19 +36654,19 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36605
36654
  if (!["cli", "ide", "extension", "acp"].includes(category)) {
36606
36655
  return { success: false, error: `unknown category: ${category}` };
36607
36656
  }
36608
- const fs40 = __require("fs");
36609
- const path44 = __require("path");
36657
+ const fs41 = __require("fs");
36658
+ const path45 = __require("path");
36610
36659
  try {
36611
36660
  const installRoot = this.getUpstreamInstallRoot();
36612
- const installRootResolved = path44.resolve(installRoot);
36613
- const targetDir = path44.resolve(path44.join(installRoot, category, type));
36614
- if (!targetDir.startsWith(installRootResolved + path44.sep)) {
36661
+ const installRootResolved = path45.resolve(installRoot);
36662
+ const targetDir = path45.resolve(path45.join(installRoot, category, type));
36663
+ if (!targetDir.startsWith(installRootResolved + path45.sep)) {
36615
36664
  return { success: false, error: "refusing to delete outside upstream root" };
36616
36665
  }
36617
- if (!fs40.existsSync(targetDir)) {
36666
+ if (!fs41.existsSync(targetDir)) {
36618
36667
  return { success: false, error: "not installed" };
36619
36668
  }
36620
- fs40.rmSync(targetDir, { recursive: true, force: true });
36669
+ fs41.rmSync(targetDir, { recursive: true, force: true });
36621
36670
  if (this._ctx.providerLoader) {
36622
36671
  this._ctx.providerLoader.reload();
36623
36672
  this._ctx.providerLoader.registerToDetector();
@@ -36633,28 +36682,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36633
36682
  * the UI and by the update checker.
36634
36683
  */
36635
36684
  handleListInstalledProviders(_args) {
36636
- const fs40 = __require("fs");
36637
- const path44 = __require("path");
36685
+ const fs41 = __require("fs");
36686
+ const path45 = __require("path");
36638
36687
  const installRoot = this.getUpstreamInstallRoot();
36639
- if (!fs40.existsSync(installRoot)) return { success: true, providers: [] };
36688
+ if (!fs41.existsSync(installRoot)) return { success: true, providers: [] };
36640
36689
  const CATEGORIES = ["cli", "ide", "extension", "acp"];
36641
36690
  const items = [];
36642
36691
  for (const category of CATEGORIES) {
36643
- const categoryDir = path44.join(installRoot, category);
36644
- if (!fs40.existsSync(categoryDir)) continue;
36692
+ const categoryDir = path45.join(installRoot, category);
36693
+ if (!fs41.existsSync(categoryDir)) continue;
36645
36694
  let entries;
36646
36695
  try {
36647
- entries = fs40.readdirSync(categoryDir);
36696
+ entries = fs41.readdirSync(categoryDir);
36648
36697
  } catch {
36649
36698
  continue;
36650
36699
  }
36651
36700
  for (const type of entries) {
36652
- const v1Path = path44.join(categoryDir, type, "provider.v1.json");
36653
- const v0Path = path44.join(categoryDir, type, "provider.json");
36654
- const manifestPath = fs40.existsSync(v1Path) ? v1Path : fs40.existsSync(v0Path) ? v0Path : null;
36701
+ const v1Path = path45.join(categoryDir, type, "provider.v1.json");
36702
+ const v0Path = path45.join(categoryDir, type, "provider.json");
36703
+ const manifestPath = fs41.existsSync(v1Path) ? v1Path : fs41.existsSync(v0Path) ? v0Path : null;
36655
36704
  if (!manifestPath) continue;
36656
36705
  try {
36657
- const m = JSON.parse(fs40.readFileSync(manifestPath, "utf-8"));
36706
+ const m = JSON.parse(fs41.readFileSync(manifestPath, "utf-8"));
36658
36707
  items.push({
36659
36708
  type,
36660
36709
  category,
@@ -36765,8 +36814,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36765
36814
  if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
36766
36815
  return { success: false, error: "name must match @[a-z0-9_-]+" };
36767
36816
  }
36768
- const fs40 = __require("fs");
36769
- const path44 = __require("path");
36817
+ const fs41 = __require("fs");
36818
+ const path45 = __require("path");
36770
36819
  const { spawnSync: spawnSync2 } = __require("child_process");
36771
36820
  const file = ext.loadExternalSources();
36772
36821
  if (file.sources.some((s2) => s2.name === requestedName)) {
@@ -36775,9 +36824,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36775
36824
  if (file.sources.some((s2) => s2.url === url && s2.ref === ref)) {
36776
36825
  return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
36777
36826
  }
36778
- const sourceDir = path44.join(ext.externalRoot(), requestedName);
36779
- if (!fs40.existsSync(ext.externalRoot())) fs40.mkdirSync(ext.externalRoot(), { recursive: true });
36780
- if (fs40.existsSync(sourceDir)) {
36827
+ const sourceDir = path45.join(ext.externalRoot(), requestedName);
36828
+ if (!fs41.existsSync(ext.externalRoot())) fs41.mkdirSync(ext.externalRoot(), { recursive: true });
36829
+ if (fs41.existsSync(sourceDir)) {
36781
36830
  return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
36782
36831
  }
36783
36832
  const clone = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url, sourceDir], {
@@ -36787,7 +36836,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36787
36836
  });
36788
36837
  if (clone.status !== 0) {
36789
36838
  try {
36790
- fs40.rmSync(sourceDir, { recursive: true, force: true });
36839
+ fs41.rmSync(sourceDir, { recursive: true, force: true });
36791
36840
  } catch {
36792
36841
  }
36793
36842
  return { success: false, error: `git clone failed: ${(clone.stderr || clone.stdout || "").trim() || "unknown error"}` };
@@ -36831,15 +36880,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
36831
36880
  const name = typeof args?.name === "string" ? args.name.trim() : "";
36832
36881
  if (!name) return { success: false, error: "name is required" };
36833
36882
  const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
36834
- const fs40 = __require("fs");
36835
- const path44 = __require("path");
36883
+ const fs41 = __require("fs");
36884
+ const path45 = __require("path");
36836
36885
  const file = ext.loadExternalSources();
36837
36886
  const match = file.sources.find((s2) => s2.name === name);
36838
36887
  if (!match) return { success: false, error: `source "${name}" not registered` };
36839
- const sourceDir = path44.join(ext.externalRoot(), name);
36840
- if (fs40.existsSync(sourceDir)) {
36888
+ const sourceDir = path45.join(ext.externalRoot(), name);
36889
+ if (fs41.existsSync(sourceDir)) {
36841
36890
  try {
36842
- fs40.rmSync(sourceDir, { recursive: true, force: true });
36891
+ fs41.rmSync(sourceDir, { recursive: true, force: true });
36843
36892
  } catch (e) {
36844
36893
  return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
36845
36894
  }
@@ -37624,24 +37673,24 @@ var statusMetaHandlers = {
37624
37673
  // src/commands/low-family/coordinator-prompt.ts
37625
37674
  var coordinatorPromptHandlers = {
37626
37675
  list_coordinator_prompts: async (_ctx, _args) => {
37627
- const fs40 = await import("fs");
37628
- const path44 = await import("path");
37629
- const os31 = await import("os");
37630
- const dir = path44.join(os31.homedir(), ".adhdev", "coordinator-prompts");
37676
+ const fs41 = await import("fs");
37677
+ const path45 = await import("path");
37678
+ const os32 = await import("os");
37679
+ const dir = path45.join(os32.homedir(), ".adhdev", "coordinator-prompts");
37631
37680
  const entries = {};
37632
37681
  try {
37633
- if (fs40.existsSync(dir)) {
37634
- for (const name of fs40.readdirSync(dir)) {
37682
+ if (fs41.existsSync(dir)) {
37683
+ for (const name of fs41.readdirSync(dir)) {
37635
37684
  const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
37636
37685
  const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
37637
37686
  const m = matchAppend || matchOverride;
37638
37687
  if (!m) continue;
37639
37688
  const isAppend = !!matchAppend;
37640
37689
  const key2 = m[1];
37641
- const full = path44.join(dir, name);
37690
+ const full = path45.join(dir, name);
37642
37691
  let content = "";
37643
37692
  try {
37644
- content = fs40.readFileSync(full, "utf8");
37693
+ content = fs41.readFileSync(full, "utf8");
37645
37694
  } catch {
37646
37695
  }
37647
37696
  if (!entries[key2]) entries[key2] = { override: "", append: "" };
@@ -37655,24 +37704,24 @@ var coordinatorPromptHandlers = {
37655
37704
  return { success: true, dir, entries };
37656
37705
  },
37657
37706
  write_coordinator_prompt: async (_ctx, args) => {
37658
- const fs40 = await import("fs");
37659
- const path44 = await import("path");
37660
- const os31 = await import("os");
37707
+ const fs41 = await import("fs");
37708
+ const path45 = await import("path");
37709
+ const os32 = await import("os");
37661
37710
  const key2 = typeof args?.key === "string" ? args.key.trim() : "";
37662
37711
  const kind = args?.kind === "append" ? "append" : "override";
37663
37712
  const content = typeof args?.content === "string" ? args.content : "";
37664
37713
  if (!key2 || !/^[a-zA-Z0-9_.-]+$/.test(key2)) {
37665
37714
  return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
37666
37715
  }
37667
- const dir = path44.join(os31.homedir(), ".adhdev", "coordinator-prompts");
37716
+ const dir = path45.join(os32.homedir(), ".adhdev", "coordinator-prompts");
37668
37717
  const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
37669
- const full = path44.join(dir, filename);
37718
+ const full = path45.join(dir, filename);
37670
37719
  try {
37671
- fs40.mkdirSync(dir, { recursive: true });
37720
+ fs41.mkdirSync(dir, { recursive: true });
37672
37721
  if (content.trim()) {
37673
- fs40.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
37674
- } else if (fs40.existsSync(full)) {
37675
- fs40.unlinkSync(full);
37722
+ fs41.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
37723
+ } else if (fs41.existsSync(full)) {
37724
+ fs41.unlinkSync(full);
37676
37725
  }
37677
37726
  return { success: true, path: full, kind, key: key2 };
37678
37727
  } catch (error) {
@@ -38763,9 +38812,9 @@ init_workspaces();
38763
38812
  init_recent_activity();
38764
38813
  init_hash();
38765
38814
  init_coordinator_registry();
38766
- import * as os21 from "os";
38767
- import * as path28 from "path";
38768
- import * as crypto5 from "crypto";
38815
+ import * as os22 from "os";
38816
+ import * as path29 from "path";
38817
+ import * as crypto6 from "crypto";
38769
38818
  import { existsSync as existsSync31, mkdirSync as mkdirSync13, writeFileSync as writeFileSync16 } from "fs";
38770
38819
  import { execFileSync as execFileSync4 } from "child_process";
38771
38820
  import chalk from "chalk";
@@ -38774,11 +38823,9 @@ init_summary_metadata();
38774
38823
  // src/providers/cli-provider-instance.ts
38775
38824
  init_contracts2();
38776
38825
  init_provider_input_support();
38777
- import * as os20 from "os";
38778
- import * as path26 from "path";
38779
- import * as crypto4 from "crypto";
38780
- import * as fs19 from "fs";
38781
- import { createRequire as createRequire2 } from "module";
38826
+ import * as os21 from "os";
38827
+ import * as crypto5 from "crypto";
38828
+ import * as fs20 from "fs";
38782
38829
  init_hash();
38783
38830
 
38784
38831
  // src/providers/spec/route.ts
@@ -41982,28 +42029,11 @@ function workingDirBasename(p) {
41982
42029
  return (p || "").split(/[\\/]/).filter(Boolean).pop() || "session";
41983
42030
  }
41984
42031
 
41985
- // src/providers/cli-provider-instance.ts
41986
- var STATUS_HYDRATION_TAIL_LIMIT = 200;
41987
- function isIdleStatus(value) {
41988
- const status = typeof value === "string" ? value.trim().toLowerCase() : "";
41989
- return !status || status === "idle" || status === "ready";
41990
- }
41991
- function getMessageTime(message) {
41992
- if (!message || typeof message !== "object") return 0;
41993
- const record = message;
41994
- const value = Number(record.receivedAt ?? record.timestamp ?? 0);
41995
- return Number.isFinite(value) ? value : 0;
41996
- }
41997
- var COMPLETED_FINALIZATION_RETRY_MS = 1e3;
41998
- var COMPLETED_FINALIZATION_MAX_WAIT_MS = 3e4;
41999
- var NATIVE_HISTORY_MESH_IDLE_SETTLE_MS = 4e3;
42000
- var USER_INPUT_ACK_DEDUP_WINDOW_MS = 6e4;
42001
- var STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS = 12e3;
42002
- var TERMINAL_MESH_EVENTS = /* @__PURE__ */ new Set([
42003
- "agent:generating_completed",
42004
- "agent:stopped",
42005
- "agent:ready"
42006
- ]);
42032
+ // src/providers/cli-provider-input-prompt.ts
42033
+ import * as os20 from "os";
42034
+ import * as path26 from "path";
42035
+ import * as crypto4 from "crypto";
42036
+ import * as fs19 from "fs";
42007
42037
  var IMAGE_MIME_EXTENSIONS = {
42008
42038
  "image/png": ".png",
42009
42039
  "image/jpeg": ".jpg",
@@ -42067,19 +42097,6 @@ function cleanupStaleMaterializedImages(dir) {
42067
42097
  } catch {
42068
42098
  }
42069
42099
  }
42070
- function hasNonEmptyCliModalButtons(activeModal) {
42071
- const buttons = activeModal?.buttons;
42072
- return Array.isArray(buttons) && buttons.some((button) => String(button || "").trim().length > 0);
42073
- }
42074
- function isCliGeneratingLikeStatus(status) {
42075
- return status === "generating" || status === "streaming" || status === "no_progress" || status === "long_generating" || status === "starting";
42076
- }
42077
- function computeTurnAnchoredDurationMs(engineTurnStartedAt, generatingStartedAt, now) {
42078
- const engineStart = typeof engineTurnStartedAt === "number" && Number.isFinite(engineTurnStartedAt) ? engineTurnStartedAt : 0;
42079
- if (engineStart > 0) return { durationMs: now - engineStart, anchor: "turn-start" };
42080
- if (generatingStartedAt > 0) return { durationMs: now - generatingStartedAt, anchor: "generatingStartedAt" };
42081
- return { durationMs: 0, anchor: "none" };
42082
- }
42083
42100
  function buildCliStructuredInputPrompt(input, options = {}) {
42084
42101
  const promptParts = [];
42085
42102
  const imageRefs = [];
@@ -42117,6 +42134,9 @@ function buildCliStructuredInputPrompt(input, options = {}) {
42117
42134
  ].filter((value, index, values) => value.trim().length > 0 && values.indexOf(value) === index);
42118
42135
  return ordered.join("\n");
42119
42136
  }
42137
+
42138
+ // src/providers/cli-provider-history-dedup.ts
42139
+ init_contracts2();
42120
42140
  function normalizePersistableCliHistoryContent(content) {
42121
42141
  return flattenContent(content).replace(/\s+/g, " ").trim();
42122
42142
  }
@@ -42148,10 +42168,37 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
42148
42168
  if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
42149
42169
  return currentMessages;
42150
42170
  }
42171
+
42172
+ // src/providers/cli-provider-status-helpers.ts
42173
+ import * as path27 from "path";
42174
+ import { createRequire as createRequire2 } from "module";
42175
+ function isIdleStatus(value) {
42176
+ const status = typeof value === "string" ? value.trim().toLowerCase() : "";
42177
+ return !status || status === "idle" || status === "ready";
42178
+ }
42179
+ function getMessageTime(message) {
42180
+ if (!message || typeof message !== "object") return 0;
42181
+ const record = message;
42182
+ const value = Number(record.receivedAt ?? record.timestamp ?? 0);
42183
+ return Number.isFinite(value) ? value : 0;
42184
+ }
42185
+ function hasNonEmptyCliModalButtons(activeModal) {
42186
+ const buttons = activeModal?.buttons;
42187
+ return Array.isArray(buttons) && buttons.some((button) => String(button || "").trim().length > 0);
42188
+ }
42189
+ function isCliGeneratingLikeStatus(status) {
42190
+ return status === "generating" || status === "streaming" || status === "no_progress" || status === "long_generating" || status === "starting";
42191
+ }
42192
+ function computeTurnAnchoredDurationMs(engineTurnStartedAt, generatingStartedAt, now) {
42193
+ const engineStart = typeof engineTurnStartedAt === "number" && Number.isFinite(engineTurnStartedAt) ? engineTurnStartedAt : 0;
42194
+ if (engineStart > 0) return { durationMs: now - engineStart, anchor: "turn-start" };
42195
+ if (generatingStartedAt > 0) return { durationMs: now - generatingStartedAt, anchor: "generatingStartedAt" };
42196
+ return { durationMs: 0, anchor: "none" };
42197
+ }
42151
42198
  var CachedDatabaseSync = null;
42152
42199
  function getDatabaseSync() {
42153
42200
  if (CachedDatabaseSync) return CachedDatabaseSync;
42154
- const requireFn = typeof __require === "function" ? __require : createRequire2(path26.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
42201
+ const requireFn = typeof __require === "function" ? __require : createRequire2(path27.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
42155
42202
  const sqliteModule = requireFn(`node:${"sqlite"}`);
42156
42203
  CachedDatabaseSync = sqliteModule.DatabaseSync;
42157
42204
  if (!CachedDatabaseSync) {
@@ -42193,13 +42240,26 @@ async function waitForCliAdapterReady(adapter, options) {
42193
42240
  }
42194
42241
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
42195
42242
  }
42243
+
42244
+ // src/providers/cli-provider-instance.ts
42245
+ var STATUS_HYDRATION_TAIL_LIMIT = 200;
42246
+ var COMPLETED_FINALIZATION_RETRY_MS = 1e3;
42247
+ var COMPLETED_FINALIZATION_MAX_WAIT_MS = 3e4;
42248
+ var NATIVE_HISTORY_MESH_IDLE_SETTLE_MS = 4e3;
42249
+ var USER_INPUT_ACK_DEDUP_WINDOW_MS = 6e4;
42250
+ var STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS = 12e3;
42251
+ var TERMINAL_MESH_EVENTS = /* @__PURE__ */ new Set([
42252
+ "agent:generating_completed",
42253
+ "agent:stopped",
42254
+ "agent:ready"
42255
+ ]);
42196
42256
  var CliProviderInstance = class _CliProviderInstance {
42197
42257
  constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, options) {
42198
42258
  this.provider = provider;
42199
42259
  this.workingDir = workingDir;
42200
42260
  this.cliArgs = cliArgs;
42201
42261
  this.type = provider.type;
42202
- this.instanceId = instanceId || crypto4.randomUUID();
42262
+ this.instanceId = instanceId || crypto5.randomUUID();
42203
42263
  this.presentationMode = "chat";
42204
42264
  this.providerSessionId = options?.providerSessionId;
42205
42265
  this.launchMode = options?.launchMode || "new";
@@ -42425,10 +42485,10 @@ var CliProviderInstance = class _CliProviderInstance {
42425
42485
  * Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
42426
42486
  */
42427
42487
  probeSessionIdFromConfig(probe) {
42428
- const resolvedDbPath = probe.dbPath.replace(/^~/, os20.homedir());
42488
+ const resolvedDbPath = probe.dbPath.replace(/^~/, os21.homedir());
42429
42489
  const now = Date.now();
42430
42490
  if (this.cachedSqliteDbMissingUntil > now) return null;
42431
- if (!fs19.existsSync(resolvedDbPath)) {
42491
+ if (!fs20.existsSync(resolvedDbPath)) {
42432
42492
  this.cachedSqliteDbMissingUntil = now + 1e4;
42433
42493
  return null;
42434
42494
  }
@@ -43024,7 +43084,7 @@ var CliProviderInstance = class _CliProviderInstance {
43024
43084
  if (!isNativeSourceCanonicalHistory(this.provider.nativeHistory)) return null;
43025
43085
  if (this.lastExternalCompletionProbe?.sourcePath) {
43026
43086
  try {
43027
- fs19.statSync(this.lastExternalCompletionProbe.sourcePath);
43087
+ fs20.statSync(this.lastExternalCompletionProbe.sourcePath);
43028
43088
  } catch {
43029
43089
  }
43030
43090
  }
@@ -44557,7 +44617,7 @@ ${effect.notification.body || ""}`.trim();
44557
44617
  };
44558
44618
  addDir(this.workingDir);
44559
44619
  try {
44560
- addDir(fs19.realpathSync.native(this.workingDir));
44620
+ addDir(fs20.realpathSync.native(this.workingDir));
44561
44621
  } catch {
44562
44622
  }
44563
44623
  return Array.from(dirs);
@@ -44596,7 +44656,7 @@ ${effect.notification.body || ""}`.trim();
44596
44656
  // src/providers/acp-provider-instance.ts
44597
44657
  init_contracts2();
44598
44658
  init_provider_input_support();
44599
- import * as path27 from "path";
44659
+ import * as path28 from "path";
44600
44660
  import { Readable, Writable } from "stream";
44601
44661
  import { spawn as spawn2 } from "child_process";
44602
44662
  import {
@@ -45389,7 +45449,7 @@ var AcpProviderInstance = class {
45389
45449
  return b.uri ? {
45390
45450
  type: "resource_link",
45391
45451
  uri: b.uri,
45392
- name: path27.basename(b.uri),
45452
+ name: path28.basename(b.uri),
45393
45453
  mimeType: b.mimeType,
45394
45454
  ...b.transcript ? { description: b.transcript } : {}
45395
45455
  } : { type: "text", text: b.transcript || `[Video attachment: ${b.mimeType}]` };
@@ -45861,11 +45921,11 @@ function shouldRestoreHostedRuntime(record, managerTag) {
45861
45921
  // src/commands/cli-manager.ts
45862
45922
  function isExplicitCommand(command) {
45863
45923
  const trimmed = command.trim();
45864
- return path28.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
45924
+ return path29.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
45865
45925
  }
45866
45926
  function expandExecutable(command) {
45867
45927
  const trimmed = command.trim();
45868
- return trimmed.startsWith("~") ? path28.join(os21.homedir(), trimmed.slice(1)) : trimmed;
45928
+ return trimmed.startsWith("~") ? path29.join(os22.homedir(), trimmed.slice(1)) : trimmed;
45869
45929
  }
45870
45930
  function commandExists(command) {
45871
45931
  const trimmed = command.trim();
@@ -46010,10 +46070,10 @@ function hasConfigOverride(args, key2) {
46010
46070
  return false;
46011
46071
  }
46012
46072
  function ensureEmptyDelegatedMcpConfig(workspace) {
46013
- const baseDir = path28.join(os21.tmpdir(), "adhdev-delegated-agent-empty-mcp");
46073
+ const baseDir = path29.join(os22.tmpdir(), "adhdev-delegated-agent-empty-mcp");
46014
46074
  mkdirSync13(baseDir, { recursive: true });
46015
- const workspaceHash = shortHash(path28.resolve(workspace || os21.tmpdir()));
46016
- const filePath = path28.join(baseDir, `${workspaceHash}.json`);
46075
+ const workspaceHash = shortHash(path29.resolve(workspace || os22.tmpdir()));
46076
+ const filePath = path29.join(baseDir, `${workspaceHash}.json`);
46017
46077
  writeFileSync16(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
46018
46078
  return filePath;
46019
46079
  }
@@ -46167,7 +46227,7 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
46167
46227
  if (!supportsExplicitSessionStart(resume)) {
46168
46228
  return { cliArgs: baseArgs, launchMode: "new" };
46169
46229
  }
46170
- const providerSessionId = crypto5.randomUUID();
46230
+ const providerSessionId = crypto6.randomUUID();
46171
46231
  const newSessionArgs = expandResumeArgs(resume.newSessionArgs, providerSessionId);
46172
46232
  return {
46173
46233
  cliArgs: [...baseArgs || [], ...newSessionArgs || []],
@@ -46351,7 +46411,7 @@ var DaemonCliManager = class {
46351
46411
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
46352
46412
  const trimmed = (workingDir || "").trim();
46353
46413
  if (!trimmed) throw new Error("working directory required");
46354
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os21.homedir()) : path28.resolve(trimmed);
46414
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os22.homedir()) : path29.resolve(trimmed);
46355
46415
  const normalizedType = this.providerLoader.resolveAlias(cliType);
46356
46416
  const rawProvider = this.providerLoader.getByAlias(cliType);
46357
46417
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -46362,7 +46422,7 @@ var DaemonCliManager = class {
46362
46422
  Enable and detect this provider from the Machine Providers page before starting a runtime.`
46363
46423
  );
46364
46424
  }
46365
- const key2 = crypto5.randomUUID();
46425
+ const key2 = crypto6.randomUUID();
46366
46426
  {
46367
46427
  const coordinatorMeshId = options?.settingsOverride?.meshCoordinatorFor;
46368
46428
  if (typeof coordinatorMeshId === "string" && coordinatorMeshId.trim()) {
@@ -47203,13 +47263,13 @@ var cliAgentHandlers = {
47203
47263
  // src/launch.ts
47204
47264
  import { exec as exec4, spawn as spawn3 } from "child_process";
47205
47265
  import * as net from "net";
47206
- import * as os26 from "os";
47207
- import * as path36 from "path";
47266
+ import * as os27 from "os";
47267
+ import * as path37 from "path";
47208
47268
 
47209
47269
  // src/providers/provider-loader.ts
47210
- import * as fs25 from "fs";
47211
- import * as path35 from "path";
47212
- import * as os25 from "os";
47270
+ import * as fs26 from "fs";
47271
+ import * as path36 from "path";
47272
+ import * as os26 from "os";
47213
47273
  import * as chokidar from "chokidar";
47214
47274
  init_hash();
47215
47275
  init_logger();
@@ -47601,13 +47661,13 @@ function validateControl(control, errors) {
47601
47661
  init_external_sources();
47602
47662
 
47603
47663
  // src/providers/native-history/dispatcher.ts
47604
- import * as fs24 from "fs";
47605
- import * as os24 from "os";
47606
- import * as path33 from "path";
47664
+ import * as fs25 from "fs";
47665
+ import * as os25 from "os";
47666
+ import * as path34 from "path";
47607
47667
 
47608
47668
  // src/providers/native-history/claude-cli-transcript.ts
47609
- import * as fs20 from "fs";
47610
- import * as path29 from "path";
47669
+ import * as fs21 from "fs";
47670
+ import * as path30 from "path";
47611
47671
  function extractTimestampValue(value) {
47612
47672
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
47613
47673
  if (typeof value === "string") {
@@ -47620,7 +47680,7 @@ function extractTimestampValue(value) {
47620
47680
  }
47621
47681
  function statMtimeMs(filePath) {
47622
47682
  try {
47623
- return fs20.statSync(filePath).mtimeMs;
47683
+ return fs21.statSync(filePath).mtimeMs;
47624
47684
  } catch {
47625
47685
  return 0;
47626
47686
  }
@@ -47690,7 +47750,7 @@ function extractUserContentParts(content) {
47690
47750
  function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
47691
47751
  let raw;
47692
47752
  try {
47693
- raw = fs20.readFileSync(filePath, "utf-8");
47753
+ raw = fs21.readFileSync(filePath, "utf-8");
47694
47754
  } catch {
47695
47755
  return [];
47696
47756
  }
@@ -47763,10 +47823,10 @@ function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
47763
47823
  return records;
47764
47824
  }
47765
47825
  function readSession(sessionPath) {
47766
- if (!sessionPath || !path29.isAbsolute(sessionPath)) return null;
47767
- const basename14 = path29.basename(sessionPath, ".jsonl");
47826
+ if (!sessionPath || !path30.isAbsolute(sessionPath)) return null;
47827
+ const basename14 = path30.basename(sessionPath, ".jsonl");
47768
47828
  if (!isSafeSessionId(basename14)) return null;
47769
- if (!fs20.existsSync(sessionPath)) return null;
47829
+ if (!fs21.existsSync(sessionPath)) return null;
47770
47830
  const sourceMtimeMs = statMtimeMs(sessionPath);
47771
47831
  const messages = parseTranscriptFile(sessionPath, basename14);
47772
47832
  if (messages.length === 0) return null;
@@ -47784,8 +47844,8 @@ function readSession(sessionPath) {
47784
47844
  }
47785
47845
 
47786
47846
  // src/providers/native-history/codex-cli-transcript.ts
47787
- import * as fs21 from "fs";
47788
- import * as path30 from "path";
47847
+ import * as fs22 from "fs";
47848
+ import * as path31 from "path";
47789
47849
  function extractTimestampValue2(value) {
47790
47850
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
47791
47851
  if (typeof value === "string") {
@@ -47798,7 +47858,7 @@ function extractTimestampValue2(value) {
47798
47858
  }
47799
47859
  function statMtimeMs2(filePath) {
47800
47860
  try {
47801
- return fs21.statSync(filePath).mtimeMs;
47861
+ return fs22.statSync(filePath).mtimeMs;
47802
47862
  } catch {
47803
47863
  return 0;
47804
47864
  }
@@ -47895,7 +47955,7 @@ function pushAssistantStandardMessage(records, sessionId, receivedAt, content, w
47895
47955
  }
47896
47956
  function readSessionMeta(filePath) {
47897
47957
  try {
47898
- const firstLine = fs21.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
47958
+ const firstLine = fs22.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
47899
47959
  if (!firstLine) return null;
47900
47960
  const parsed = JSON.parse(firstLine);
47901
47961
  if (String(parsed.type ?? "") !== "session_meta") return null;
@@ -47907,7 +47967,7 @@ function readSessionMeta(filePath) {
47907
47967
  function parseSessionFile(filePath, sessionId, workspaceFallback) {
47908
47968
  let raw;
47909
47969
  try {
47910
- raw = fs21.readFileSync(filePath, "utf-8");
47970
+ raw = fs22.readFileSync(filePath, "utf-8");
47911
47971
  } catch {
47912
47972
  return [];
47913
47973
  }
@@ -48022,11 +48082,11 @@ function parseSessionFile(filePath, sessionId, workspaceFallback) {
48022
48082
  return records;
48023
48083
  }
48024
48084
  function readSession2(sessionPath) {
48025
- if (!sessionPath || !path30.isAbsolute(sessionPath)) return null;
48026
- if (!fs21.existsSync(sessionPath)) return null;
48085
+ if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
48086
+ if (!fs22.existsSync(sessionPath)) return null;
48027
48087
  const meta = readSessionMeta(sessionPath);
48028
48088
  const metaId = String(meta?.id ?? "").trim();
48029
- const basename14 = path30.basename(sessionPath, ".jsonl");
48089
+ const basename14 = path31.basename(sessionPath, ".jsonl");
48030
48090
  const uuidMatch = basename14.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
48031
48091
  const filenameUuid2 = uuidMatch ? uuidMatch[1] : "";
48032
48092
  if (metaId && filenameUuid2 && metaId !== filenameUuid2) return null;
@@ -48052,9 +48112,9 @@ function readSession2(sessionPath) {
48052
48112
  // src/providers/native-history/antigravity-cli-transcript.ts
48053
48113
  init_load_better_sqlite3();
48054
48114
  init_logger();
48055
- import * as fs22 from "fs";
48056
- import * as path31 from "path";
48057
- import * as os22 from "os";
48115
+ import * as fs23 from "fs";
48116
+ import * as path32 from "path";
48117
+ import * as os23 from "os";
48058
48118
  function extractTimestampValue3(value) {
48059
48119
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
48060
48120
  if (typeof value === "string") {
@@ -48067,7 +48127,7 @@ function extractTimestampValue3(value) {
48067
48127
  }
48068
48128
  function statMtimeMs3(filePath) {
48069
48129
  try {
48070
- return fs22.statSync(filePath).mtimeMs;
48130
+ return fs23.statSync(filePath).mtimeMs;
48071
48131
  } catch {
48072
48132
  return 0;
48073
48133
  }
@@ -48076,13 +48136,13 @@ function isUuidLike(value) {
48076
48136
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
48077
48137
  }
48078
48138
  function antigravityRoot() {
48079
- return path31.join(os22.homedir(), ".gemini", "antigravity-cli");
48139
+ return path32.join(os23.homedir(), ".gemini", "antigravity-cli");
48080
48140
  }
48081
48141
  function historyJsonlPath() {
48082
- return path31.join(antigravityRoot(), "history.jsonl");
48142
+ return path32.join(antigravityRoot(), "history.jsonl");
48083
48143
  }
48084
48144
  function brainRoot() {
48085
- return path31.join(antigravityRoot(), "brain");
48145
+ return path32.join(antigravityRoot(), "brain");
48086
48146
  }
48087
48147
  function extractUserRequestContent(content) {
48088
48148
  const raw = content.trim();
@@ -48098,7 +48158,7 @@ function antigravityRowKind(rowType) {
48098
48158
  function parseBrainTranscript(filePath, sessionId, workspace) {
48099
48159
  let raw;
48100
48160
  try {
48101
- raw = fs22.readFileSync(filePath, "utf-8");
48161
+ raw = fs23.readFileSync(filePath, "utf-8");
48102
48162
  } catch {
48103
48163
  return null;
48104
48164
  }
@@ -48158,7 +48218,7 @@ function readHistoryRows() {
48158
48218
  const sourcePath = historyJsonlPath();
48159
48219
  let lines = [];
48160
48220
  try {
48161
- lines = fs22.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
48221
+ lines = fs23.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
48162
48222
  } catch {
48163
48223
  return [];
48164
48224
  }
@@ -48206,7 +48266,7 @@ function extractStringsFromBuffer(buf) {
48206
48266
  function parsePbFile(filePath, sessionId) {
48207
48267
  let buf;
48208
48268
  try {
48209
- buf = fs22.readFileSync(filePath);
48269
+ buf = fs23.readFileSync(filePath);
48210
48270
  } catch {
48211
48271
  return null;
48212
48272
  }
@@ -48376,7 +48436,7 @@ function parseConversationDb(filePath, sessionId, workspace) {
48376
48436
  } catch (err) {
48377
48437
  LOG.warn(
48378
48438
  "NativeHistory",
48379
- `antigravity .db reader could not load better-sqlite3 for ${path31.basename(filePath)}: ${err instanceof Error ? err.message : String(err)} (native binding unavailable \u2014 assistant answers in this .db will not surface)`
48439
+ `antigravity .db reader could not load better-sqlite3 for ${path32.basename(filePath)}: ${err instanceof Error ? err.message : String(err)} (native binding unavailable \u2014 assistant answers in this .db will not surface)`
48380
48440
  );
48381
48441
  return null;
48382
48442
  }
@@ -48406,13 +48466,13 @@ function parseConversationDb(filePath, sessionId, workspace) {
48406
48466
  }
48407
48467
  LOG.warn(
48408
48468
  "NativeHistory",
48409
- `antigravity .db ${path31.basename(filePath)} stayed locked (SQLITE_BUSY) after ${AGY_DB_MAX_ATTEMPTS} attempts: ${err instanceof Error ? err.message : String(err)} (WAL write/checkpoint lock contention \u2014 assistant answers may transiently not surface this read)`
48469
+ `antigravity .db ${path32.basename(filePath)} stayed locked (SQLITE_BUSY) after ${AGY_DB_MAX_ATTEMPTS} attempts: ${err instanceof Error ? err.message : String(err)} (WAL write/checkpoint lock contention \u2014 assistant answers may transiently not surface this read)`
48410
48470
  );
48411
48471
  return null;
48412
48472
  }
48413
48473
  LOG.debug(
48414
48474
  "NativeHistory",
48415
- `antigravity .db ${path31.basename(filePath)} not readable: ${err instanceof Error ? err.message : String(err)}`
48475
+ `antigravity .db ${path32.basename(filePath)} not readable: ${err instanceof Error ? err.message : String(err)}`
48416
48476
  );
48417
48477
  return null;
48418
48478
  } finally {
@@ -48439,12 +48499,12 @@ function parseConversationDb(filePath, sessionId, workspace) {
48439
48499
  content = recovered;
48440
48500
  LOG.debug(
48441
48501
  "NativeHistory",
48442
- `antigravity .db ${path31.basename(filePath)} step ${row.idx} (type ${row.step_type}): user prompt absent at field 19; recovered ${content.length} chars via printable-run fallback \u2014 possible step_payload schema drift`
48502
+ `antigravity .db ${path32.basename(filePath)} step ${row.idx} (type ${row.step_type}): user prompt absent at field 19; recovered ${content.length} chars via printable-run fallback \u2014 possible step_payload schema drift`
48443
48503
  );
48444
48504
  } else {
48445
48505
  LOG.debug(
48446
48506
  "NativeHistory",
48447
- `antigravity .db ${path31.basename(filePath)} step ${row.idx} (type ${row.step_type}) dropped: no user prompt text (payload ${payload.length}B, top-level fields [${topLevelFieldNumbers(payload).join(",")}])`
48507
+ `antigravity .db ${path32.basename(filePath)} step ${row.idx} (type ${row.step_type}) dropped: no user prompt text (payload ${payload.length}B, top-level fields [${topLevelFieldNumbers(payload).join(",")}])`
48448
48508
  );
48449
48509
  continue;
48450
48510
  }
@@ -48469,12 +48529,12 @@ function parseConversationDb(filePath, sessionId, workspace) {
48469
48529
  content = recovered;
48470
48530
  LOG.debug(
48471
48531
  "NativeHistory",
48472
- `antigravity .db ${path31.basename(filePath)} step ${row.idx} (type ${row.step_type}): answer absent at field 20; recovered ${content.length} chars via printable-run fallback \u2014 possible step_payload schema drift`
48532
+ `antigravity .db ${path32.basename(filePath)} step ${row.idx} (type ${row.step_type}): answer absent at field 20; recovered ${content.length} chars via printable-run fallback \u2014 possible step_payload schema drift`
48473
48533
  );
48474
48534
  } else {
48475
48535
  LOG.debug(
48476
48536
  "NativeHistory",
48477
- `antigravity .db ${path31.basename(filePath)} step ${row.idx} (type ${row.step_type}) dropped: no answer text (payload ${payload.length}B, top-level fields [${topLevelFieldNumbers(payload).join(",")}], reasoningOnly=${reasoning ? "yes" : "no"})`
48537
+ `antigravity .db ${path32.basename(filePath)} step ${row.idx} (type ${row.step_type}) dropped: no answer text (payload ${payload.length}B, top-level fields [${topLevelFieldNumbers(payload).join(",")}], reasoningOnly=${reasoning ? "yes" : "no"})`
48478
48538
  );
48479
48539
  continue;
48480
48540
  }
@@ -48495,13 +48555,13 @@ function parseConversationDb(filePath, sessionId, workspace) {
48495
48555
  return messages.length > 0 ? messages : null;
48496
48556
  }
48497
48557
  function readSession3(sessionPath, sessionId, workspace) {
48498
- if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
48499
- if (!fs22.existsSync(sessionPath)) return null;
48558
+ if (!sessionPath || !path32.isAbsolute(sessionPath)) return null;
48559
+ if (!fs23.existsSync(sessionPath)) return null;
48500
48560
  const sourceMtimeMs = statMtimeMs3(sessionPath);
48501
48561
  const brainRootPath = brainRoot();
48502
- if (sessionPath.startsWith(brainRootPath + path31.sep) && sessionPath.endsWith(".jsonl")) {
48562
+ if (sessionPath.startsWith(brainRootPath + path32.sep) && sessionPath.endsWith(".jsonl")) {
48503
48563
  const relative5 = sessionPath.slice(brainRootPath.length + 1);
48504
- const uuidFromPath = relative5.split(path31.sep)[0];
48564
+ const uuidFromPath = relative5.split(path32.sep)[0];
48505
48565
  const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : "");
48506
48566
  if (!resolvedSessionId) return null;
48507
48567
  const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
@@ -48517,7 +48577,7 @@ function readSession3(sessionPath, sessionId, workspace) {
48517
48577
  };
48518
48578
  }
48519
48579
  if (sessionPath.endsWith(".db")) {
48520
- const dbSessionId = sessionId || path31.basename(sessionPath, ".db");
48580
+ const dbSessionId = sessionId || path32.basename(sessionPath, ".db");
48521
48581
  if (!isUuidLike(dbSessionId)) return null;
48522
48582
  const messages = parseConversationDb(sessionPath, dbSessionId, workspace);
48523
48583
  if (!messages || messages.length === 0) return null;
@@ -48532,7 +48592,7 @@ function readSession3(sessionPath, sessionId, workspace) {
48532
48592
  };
48533
48593
  }
48534
48594
  if (sessionPath.endsWith(".pb")) {
48535
- const pbSessionId = sessionId || path31.basename(sessionPath, ".pb");
48595
+ const pbSessionId = sessionId || path32.basename(sessionPath, ".pb");
48536
48596
  if (!isUuidLike(pbSessionId)) return null;
48537
48597
  const messages = parsePbFile(sessionPath, pbSessionId);
48538
48598
  if (!messages || messages.length === 0) return null;
@@ -48546,7 +48606,7 @@ function readSession3(sessionPath, sessionId, workspace) {
48546
48606
  partialReason: "antigravity_cli_pb_raw_text_extraction"
48547
48607
  };
48548
48608
  }
48549
- if (path31.basename(sessionPath) === "history.jsonl") {
48609
+ if (path32.basename(sessionPath) === "history.jsonl") {
48550
48610
  const resolvedSessionId = sessionId || "";
48551
48611
  if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
48552
48612
  const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
@@ -48594,20 +48654,20 @@ function readSession3(sessionPath, sessionId, workspace) {
48594
48654
 
48595
48655
  // src/providers/native-history/hermes-cli-transcript.ts
48596
48656
  init_load_better_sqlite3();
48597
- import * as fs23 from "fs";
48598
- import * as path32 from "path";
48599
- import * as os23 from "os";
48600
- var HERMES_STATE_DB = path32.join(os23.homedir(), ".hermes", "state.db");
48601
- var HERMES_LEGACY_SESSIONS_DIR = path32.join(os23.homedir(), ".hermes", "sessions");
48657
+ import * as fs24 from "fs";
48658
+ import * as path33 from "path";
48659
+ import * as os24 from "os";
48660
+ var HERMES_STATE_DB = path33.join(os24.homedir(), ".hermes", "state.db");
48661
+ var HERMES_LEGACY_SESSIONS_DIR = path33.join(os24.homedir(), ".hermes", "sessions");
48602
48662
  function statMtimeMs4(p) {
48603
48663
  try {
48604
- return Math.floor(fs23.statSync(p).mtimeMs);
48664
+ return Math.floor(fs24.statSync(p).mtimeMs);
48605
48665
  } catch {
48606
48666
  return 0;
48607
48667
  }
48608
48668
  }
48609
48669
  function openDb() {
48610
- if (!fs23.existsSync(HERMES_STATE_DB)) return null;
48670
+ if (!fs24.existsSync(HERMES_STATE_DB)) return null;
48611
48671
  try {
48612
48672
  const Database = loadBetterSqlite3();
48613
48673
  return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
@@ -48703,10 +48763,10 @@ function readSession4(sessionPath, requestedSessionId) {
48703
48763
  }
48704
48764
  }
48705
48765
  }
48706
- if (!path32.isAbsolute(sessionPath) || !fs23.existsSync(sessionPath)) return null;
48766
+ if (!path33.isAbsolute(sessionPath) || !fs24.existsSync(sessionPath)) return null;
48707
48767
  let raw;
48708
48768
  try {
48709
- raw = JSON.parse(fs23.readFileSync(sessionPath, "utf8"));
48769
+ raw = JSON.parse(fs24.readFileSync(sessionPath, "utf8"));
48710
48770
  } catch {
48711
48771
  return null;
48712
48772
  }
@@ -48729,7 +48789,7 @@ function readSession4(sessionPath, requestedSessionId) {
48729
48789
  });
48730
48790
  }
48731
48791
  if (messages.length === 0) return null;
48732
- const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path32.basename(sessionPath, ".json").replace(/^session_/, "");
48792
+ const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path33.basename(sessionPath, ".json").replace(/^session_/, "");
48733
48793
  return {
48734
48794
  messages,
48735
48795
  providerSessionId: sessionId,
@@ -48759,7 +48819,7 @@ function createNativeHistoryDispatcher(reader) {
48759
48819
  if (!sourcePath) return null;
48760
48820
  if (input.forceRefresh === true || input.args?.forceRefresh === true) {
48761
48821
  try {
48762
- fs24.statSync(sourcePath);
48822
+ fs25.statSync(sourcePath);
48763
48823
  } catch {
48764
48824
  }
48765
48825
  }
@@ -48796,11 +48856,11 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs, ins
48796
48856
  }
48797
48857
  }
48798
48858
  function resolveClaudePath(workspace, sessionId) {
48799
- const dir = path33.join(os24.homedir(), ".claude", "projects", cwdAsDashes(workspace));
48800
- if (!fs24.existsSync(dir)) return null;
48859
+ const dir = path34.join(os25.homedir(), ".claude", "projects", cwdAsDashes(workspace));
48860
+ if (!fs25.existsSync(dir)) return null;
48801
48861
  if (sessionId) {
48802
- const candidate = path33.join(dir, `${sessionId}.jsonl`);
48803
- if (fs24.existsSync(candidate)) return candidate;
48862
+ const candidate = path34.join(dir, `${sessionId}.jsonl`);
48863
+ if (fs25.existsSync(candidate)) return candidate;
48804
48864
  }
48805
48865
  return null;
48806
48866
  }
@@ -48812,7 +48872,7 @@ function resolveCodexPath(workspace, sessionId, sessionStartedAtMs) {
48812
48872
  return findCodexPathByRuntime(root, workspace, sessionStartedAtMs);
48813
48873
  }
48814
48874
  function findCodexPathBySessionId(root, sessionId) {
48815
- if (!fs24.existsSync(root)) return null;
48875
+ if (!fs25.existsSync(root)) return null;
48816
48876
  const needle = sessionId.toLowerCase();
48817
48877
  const matches = [];
48818
48878
  const stack = [root];
@@ -48820,12 +48880,12 @@ function findCodexPathBySessionId(root, sessionId) {
48820
48880
  const current = stack.pop();
48821
48881
  let entries = [];
48822
48882
  try {
48823
- entries = fs24.readdirSync(current, { withFileTypes: true });
48883
+ entries = fs25.readdirSync(current, { withFileTypes: true });
48824
48884
  } catch {
48825
48885
  continue;
48826
48886
  }
48827
48887
  for (const entry of entries) {
48828
- const entryPath = path33.join(current, entry.name);
48888
+ const entryPath = path34.join(current, entry.name);
48829
48889
  if (entry.isDirectory()) {
48830
48890
  stack.push(entryPath);
48831
48891
  continue;
@@ -48840,7 +48900,7 @@ function findCodexPathBySessionId(root, sessionId) {
48840
48900
  return matches[0]?.p ?? null;
48841
48901
  }
48842
48902
  function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
48843
- if (!fs24.existsSync(root) || !workspace) return null;
48903
+ if (!fs25.existsSync(root) || !workspace) return null;
48844
48904
  const workspaceResolved = resolveRealPath(workspace);
48845
48905
  const cutoff = Date.now() - RECENT_WINDOW_MS;
48846
48906
  const matches = [];
@@ -48849,12 +48909,12 @@ function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
48849
48909
  const current = stack.pop();
48850
48910
  let entries = [];
48851
48911
  try {
48852
- entries = fs24.readdirSync(current, { withFileTypes: true });
48912
+ entries = fs25.readdirSync(current, { withFileTypes: true });
48853
48913
  } catch {
48854
48914
  continue;
48855
48915
  }
48856
48916
  for (const entry of entries) {
48857
- const entryPath = path33.join(current, entry.name);
48917
+ const entryPath = path34.join(current, entry.name);
48858
48918
  if (entry.isDirectory()) {
48859
48919
  stack.push(entryPath);
48860
48920
  continue;
@@ -48874,10 +48934,10 @@ function findCodexPathByRuntime(root, workspace, sessionStartedAtMs) {
48874
48934
  }
48875
48935
  function readCodexSessionMeta(filePath) {
48876
48936
  try {
48877
- const fd = fs24.openSync(filePath, "r");
48937
+ const fd = fs25.openSync(filePath, "r");
48878
48938
  try {
48879
48939
  const buffer = Buffer.alloc(8192);
48880
- const bytes = fs24.readSync(fd, buffer, 0, buffer.length, 0);
48940
+ const bytes = fs25.readSync(fd, buffer, 0, buffer.length, 0);
48881
48941
  if (bytes <= 0) return null;
48882
48942
  const text = buffer.subarray(0, bytes).toString("utf8");
48883
48943
  const firstLine = text.slice(0, text.indexOf("\n") >= 0 ? text.indexOf("\n") : text.length).trim();
@@ -48892,7 +48952,7 @@ function readCodexSessionMeta(filePath) {
48892
48952
  timestampMs: Number.isFinite(timestampMs) ? timestampMs : void 0
48893
48953
  };
48894
48954
  } finally {
48895
- fs24.closeSync(fd);
48955
+ fs25.closeSync(fd);
48896
48956
  }
48897
48957
  } catch {
48898
48958
  return null;
@@ -48900,35 +48960,35 @@ function readCodexSessionMeta(filePath) {
48900
48960
  }
48901
48961
  function resolveRealPath(value) {
48902
48962
  try {
48903
- return fs24.realpathSync(value);
48963
+ return fs25.realpathSync(value);
48904
48964
  } catch {
48905
48965
  return value;
48906
48966
  }
48907
48967
  }
48908
48968
  var AGY_SPAWN_CLAIM_GRACE_MS = 2e3;
48909
48969
  function resolveAntigravityPath(workspace, sessionId, sessionStartedAtMs, instanceId) {
48910
- const agyRoot = path33.join(os24.homedir(), ".gemini", "antigravity-cli");
48970
+ const agyRoot = path34.join(os25.homedir(), ".gemini", "antigravity-cli");
48911
48971
  const owner = antigravityOwnerToken(workspace, sessionStartedAtMs, instanceId);
48912
48972
  if (sessionId && isUuidLikeSessionId2(sessionId)) {
48913
- const dbPath = path33.join(agyRoot, "conversations", `${sessionId}.db`);
48914
- if (fs24.existsSync(dbPath)) {
48973
+ const dbPath = path34.join(agyRoot, "conversations", `${sessionId}.db`);
48974
+ if (fs25.existsSync(dbPath)) {
48915
48975
  if (owner) claimAntigravityConversation(sessionId, owner);
48916
48976
  return dbPath;
48917
48977
  }
48918
48978
  }
48919
- const brainRoot2 = path33.join(agyRoot, "brain");
48920
- if (fs24.existsSync(brainRoot2)) {
48979
+ const brainRoot2 = path34.join(agyRoot, "brain");
48980
+ if (fs25.existsSync(brainRoot2)) {
48921
48981
  const cutoff = spawnAwareCutoff(sessionStartedAtMs);
48922
- const entries = fs24.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => ({ uuid: e.name, p: path33.join(brainRoot2, e.name), mtime: safeMtime(path33.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
48982
+ const entries = fs25.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory() && isUuidLikeSessionId2(e.name)).filter((e) => !isAntigravityConversationClaimedByOther(e.name, owner)).map((e) => ({ uuid: e.name, p: path34.join(brainRoot2, e.name), mtime: safeMtime(path34.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
48923
48983
  for (const e of entries) {
48924
- const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
48925
- if (fs24.existsSync(t) && safeSize(t) > 0) {
48984
+ const t = path34.join(e.p, ".system_generated", "logs", "transcript.jsonl");
48985
+ if (fs25.existsSync(t) && safeSize(t) > 0) {
48926
48986
  if (owner) claimAntigravityConversation(e.uuid, owner);
48927
48987
  return t;
48928
48988
  }
48929
48989
  }
48930
48990
  }
48931
- const convRoot = path33.join(agyRoot, "conversations");
48991
+ const convRoot = path34.join(agyRoot, "conversations");
48932
48992
  const picked = pickUnboundConversationDb(convRoot, sessionStartedAtMs, owner);
48933
48993
  if (picked) {
48934
48994
  if (owner) claimAntigravityConversation(picked.uuid, owner);
@@ -48939,7 +48999,7 @@ function resolveAntigravityPath(workspace, sessionId, sessionStartedAtMs, instan
48939
48999
  function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
48940
49000
  let entries = [];
48941
49001
  try {
48942
- entries = fs24.readdirSync(convRoot, { withFileTypes: true });
49002
+ entries = fs25.readdirSync(convRoot, { withFileTypes: true });
48943
49003
  } catch {
48944
49004
  return null;
48945
49005
  }
@@ -48951,7 +49011,7 @@ function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
48951
49011
  if (!match || !isUuidLikeSessionId2(match[1])) continue;
48952
49012
  const uuid = match[1];
48953
49013
  if (isAntigravityConversationClaimedByOther(uuid, owner)) continue;
48954
- const p = path33.join(convRoot, entry.name);
49014
+ const p = path34.join(convRoot, entry.name);
48955
49015
  const mtime = safeMtime(p);
48956
49016
  if (mtime < recencyCutoff) continue;
48957
49017
  candidates.push({ path: p, uuid, mtime, birth: safeBirthtime(p) });
@@ -48975,10 +49035,10 @@ function spawnAwareCutoff(sessionStartedAtMs) {
48975
49035
  function resolveHermesPath(workspace, sessionId) {
48976
49036
  void workspace;
48977
49037
  void sessionId;
48978
- const dbPath = path33.join(os24.homedir(), ".hermes", "state.db");
48979
- if (fs24.existsSync(dbPath)) return dbPath;
48980
- const dir = path33.join(os24.homedir(), ".hermes", "sessions");
48981
- if (!fs24.existsSync(dir)) return null;
49038
+ const dbPath = path34.join(os25.homedir(), ".hermes", "state.db");
49039
+ if (fs25.existsSync(dbPath)) return dbPath;
49040
+ const dir = path34.join(os25.homedir(), ".hermes", "sessions");
49041
+ if (!fs25.existsSync(dir)) return null;
48982
49042
  return newestRecentFile2(dir, /^session_.*\.json$/);
48983
49043
  }
48984
49044
  function readByReader(reader, sourcePath, sessionId, workspace, requestedProviderSid) {
@@ -49003,7 +49063,7 @@ function cwdAsDashes(cwd) {
49003
49063
  return cwd.replace(/\//g, "-");
49004
49064
  }
49005
49065
  function codexSessionsRoot() {
49006
- return path33.join(os24.homedir(), ".codex", "sessions");
49066
+ return path34.join(os25.homedir(), ".codex", "sessions");
49007
49067
  }
49008
49068
  function isUuidLikeSessionId2(sessionId) {
49009
49069
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId);
@@ -49015,7 +49075,7 @@ var RECENT_WINDOW_MS = 5 * 60 * 1e3;
49015
49075
  function newestRecentFile2(dir, pattern) {
49016
49076
  try {
49017
49077
  const cutoff = Date.now() - RECENT_WINDOW_MS;
49018
- const entries = fs24.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path33.join(dir, e.name), mtime: safeMtime(path33.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
49078
+ const entries = fs25.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);
49019
49079
  return entries[0]?.p ?? null;
49020
49080
  } catch {
49021
49081
  return null;
@@ -49023,14 +49083,14 @@ function newestRecentFile2(dir, pattern) {
49023
49083
  }
49024
49084
  function safeMtime(p) {
49025
49085
  try {
49026
- return Math.floor(fs24.statSync(p).mtimeMs);
49086
+ return Math.floor(fs25.statSync(p).mtimeMs);
49027
49087
  } catch {
49028
49088
  return 0;
49029
49089
  }
49030
49090
  }
49031
49091
  function safeBirthtime(p) {
49032
49092
  try {
49033
- const st = fs24.statSync(p);
49093
+ const st = fs25.statSync(p);
49034
49094
  const birth = Math.floor(st.birthtimeMs);
49035
49095
  return birth > 0 ? birth : Math.floor(st.mtimeMs);
49036
49096
  } catch {
@@ -49039,7 +49099,7 @@ function safeBirthtime(p) {
49039
49099
  }
49040
49100
  function safeSize(p) {
49041
49101
  try {
49042
- return fs24.statSync(p).size;
49102
+ return fs25.statSync(p).size;
49043
49103
  } catch {
49044
49104
  return 0;
49045
49105
  }
@@ -49133,9 +49193,9 @@ var ProviderLoader = class _ProviderLoader {
49133
49193
  static siblingStderrLogged = /* @__PURE__ */ new Set();
49134
49194
  static looksLikeProviderRoot(candidate) {
49135
49195
  try {
49136
- if (!fs25.existsSync(candidate) || !fs25.statSync(candidate).isDirectory()) return false;
49196
+ if (!fs26.existsSync(candidate) || !fs26.statSync(candidate).isDirectory()) return false;
49137
49197
  return ["ide", "extension", "cli", "acp"].some(
49138
- (category) => fs25.existsSync(path35.join(candidate, category))
49198
+ (category) => fs26.existsSync(path36.join(candidate, category))
49139
49199
  );
49140
49200
  } catch {
49141
49201
  return false;
@@ -49143,20 +49203,20 @@ var ProviderLoader = class _ProviderLoader {
49143
49203
  }
49144
49204
  static hasProviderRootMarker(candidate) {
49145
49205
  try {
49146
- return fs25.existsSync(path35.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
49206
+ return fs26.existsSync(path36.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
49147
49207
  } catch {
49148
49208
  return false;
49149
49209
  }
49150
49210
  }
49151
49211
  detectDefaultUserDir() {
49152
- const fallback = path35.join(os25.homedir(), ".adhdev", "providers");
49212
+ const fallback = path36.join(os26.homedir(), ".adhdev", "providers");
49153
49213
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
49154
49214
  const visited = /* @__PURE__ */ new Set();
49155
49215
  for (const start of this.probeStarts) {
49156
- let current = path35.resolve(start);
49216
+ let current = path36.resolve(start);
49157
49217
  while (!visited.has(current)) {
49158
49218
  visited.add(current);
49159
- const siblingCandidate = path35.join(path35.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
49219
+ const siblingCandidate = path36.join(path36.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
49160
49220
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
49161
49221
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
49162
49222
  if (envOptIn || hasMarker) {
@@ -49178,7 +49238,7 @@ var ProviderLoader = class _ProviderLoader {
49178
49238
  return { path: siblingCandidate, source };
49179
49239
  }
49180
49240
  }
49181
- const parent = path35.dirname(current);
49241
+ const parent = path36.dirname(current);
49182
49242
  if (parent === current) break;
49183
49243
  current = parent;
49184
49244
  }
@@ -49190,11 +49250,11 @@ var ProviderLoader = class _ProviderLoader {
49190
49250
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
49191
49251
  this.registryBaseUrl = resolveRegistryBaseUrl(options?.registryUrl);
49192
49252
  this.providerTarballUrl = resolveProviderTarballUrl(options?.providerTarballUrl);
49193
- this.defaultProvidersDir = path35.join(os25.homedir(), ".adhdev", "providers");
49253
+ this.defaultProvidersDir = path36.join(os26.homedir(), ".adhdev", "providers");
49194
49254
  const detected = this.detectDefaultUserDir();
49195
49255
  this.userDir = detected.path;
49196
49256
  this.userDirSource = detected.source;
49197
- this.upstreamDir = path35.join(this.defaultProvidersDir, ".upstream");
49257
+ this.upstreamDir = path36.join(this.defaultProvidersDir, ".upstream");
49198
49258
  this.disableUpstream = false;
49199
49259
  this.applySourceConfig({
49200
49260
  userDir: options?.userDir,
@@ -49205,15 +49265,15 @@ var ProviderLoader = class _ProviderLoader {
49205
49265
  }
49206
49266
  migrateMarketplaceDirToExternal() {
49207
49267
  try {
49208
- const home = os25.homedir();
49209
- const oldDir = path35.join(home, ".adhdev", "marketplace");
49210
- const newDir = path35.join(home, ".adhdev", "external");
49211
- if (!fs25.existsSync(oldDir)) return;
49212
- if (fs25.existsSync(newDir)) {
49268
+ const home = os26.homedir();
49269
+ const oldDir = path36.join(home, ".adhdev", "marketplace");
49270
+ const newDir = path36.join(home, ".adhdev", "external");
49271
+ if (!fs26.existsSync(oldDir)) return;
49272
+ if (fs26.existsSync(newDir)) {
49213
49273
  this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
49214
49274
  return;
49215
49275
  }
49216
- fs25.renameSync(oldDir, newDir);
49276
+ fs26.renameSync(oldDir, newDir);
49217
49277
  this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
49218
49278
  } catch (e) {
49219
49279
  this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
@@ -49243,7 +49303,7 @@ var ProviderLoader = class _ProviderLoader {
49243
49303
  * Highest-priority editable overrides come first.
49244
49304
  */
49245
49305
  getProviderRoots() {
49246
- const externalDir = path35.join(os25.homedir(), ".adhdev", "external");
49306
+ const externalDir = path36.join(os26.homedir(), ".adhdev", "external");
49247
49307
  return [this.userDir, externalDir, this.upstreamDir];
49248
49308
  }
49249
49309
  getSourceConfig() {
@@ -49271,7 +49331,7 @@ var ProviderLoader = class _ProviderLoader {
49271
49331
  this.userDir = detected.path;
49272
49332
  this.userDirSource = detected.source;
49273
49333
  }
49274
- this.upstreamDir = path35.join(this.defaultProvidersDir, ".upstream");
49334
+ this.upstreamDir = path36.join(this.defaultProvidersDir, ".upstream");
49275
49335
  this.disableUpstream = this.sourceMode === "no-upstream";
49276
49336
  if (this.explicitProviderDir) {
49277
49337
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -49285,7 +49345,7 @@ var ProviderLoader = class _ProviderLoader {
49285
49345
  * Canonical provider directory shape for a given root.
49286
49346
  */
49287
49347
  getProviderDir(root, category, type) {
49288
- return path35.join(root, category, type);
49348
+ return path36.join(root, category, type);
49289
49349
  }
49290
49350
  /**
49291
49351
  * Canonical user override directory for a provider.
@@ -49312,7 +49372,7 @@ var ProviderLoader = class _ProviderLoader {
49312
49372
  resolveProviderFile(type, ...segments) {
49313
49373
  const dir = this.findProviderDirInternal(type);
49314
49374
  if (!dir) return null;
49315
- return path35.join(dir, ...segments);
49375
+ return path36.join(dir, ...segments);
49316
49376
  }
49317
49377
  /**
49318
49378
  * Load all providers (3-tier priority)
@@ -49328,7 +49388,7 @@ var ProviderLoader = class _ProviderLoader {
49328
49388
  this.providers.clear();
49329
49389
  this.providerAvailability.clear();
49330
49390
  let upstreamCount = 0;
49331
- if (!this.disableUpstream && fs25.existsSync(this.upstreamDir)) {
49391
+ if (!this.disableUpstream && fs26.existsSync(this.upstreamDir)) {
49332
49392
  upstreamCount = this.loadDir(this.upstreamDir);
49333
49393
  if (upstreamCount > 0) {
49334
49394
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -49336,11 +49396,11 @@ var ProviderLoader = class _ProviderLoader {
49336
49396
  } else if (this.disableUpstream) {
49337
49397
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
49338
49398
  }
49339
- const externalDir = path35.join(os25.homedir(), ".adhdev", "external");
49340
- if (fs25.existsSync(externalDir)) {
49399
+ const externalDir = path36.join(os26.homedir(), ".adhdev", "external");
49400
+ if (fs26.existsSync(externalDir)) {
49341
49401
  const rootEntries = (() => {
49342
49402
  try {
49343
- return fs25.readdirSync(externalDir, { withFileTypes: true });
49403
+ return fs26.readdirSync(externalDir, { withFileTypes: true });
49344
49404
  } catch {
49345
49405
  return [];
49346
49406
  }
@@ -49358,7 +49418,7 @@ var ProviderLoader = class _ProviderLoader {
49358
49418
  const ambiguousTypes = [];
49359
49419
  for (const sourceEntry of rootEntries) {
49360
49420
  if (!sourceEntry.isDirectory()) continue;
49361
- const sourceDir = path35.join(externalDir, sourceEntry.name);
49421
+ const sourceDir = path36.join(externalDir, sourceEntry.name);
49362
49422
  const sourceLoaded = this.loadDir(sourceDir);
49363
49423
  if (sourceLoaded > 0) {
49364
49424
  totalLoaded += sourceLoaded;
@@ -49374,7 +49434,7 @@ var ProviderLoader = class _ProviderLoader {
49374
49434
  ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
49375
49435
  }
49376
49436
  if (resolved.source && resolved.source !== "?") {
49377
- const sourceDir = path35.join(externalDir, resolved.source);
49437
+ const sourceDir = path36.join(externalDir, resolved.source);
49378
49438
  const reloadCount = this.loadDir(sourceDir);
49379
49439
  if (reloadCount === 0) {
49380
49440
  this.log(`Active source "${resolved.source}" no longer provides ${type}`);
@@ -49389,7 +49449,7 @@ var ProviderLoader = class _ProviderLoader {
49389
49449
  }
49390
49450
  }
49391
49451
  }
49392
- if (fs25.existsSync(this.userDir)) {
49452
+ if (fs26.existsSync(this.userDir)) {
49393
49453
  const userCount = this.loadDir(this.userDir, [".upstream"]);
49394
49454
  if (userCount > 0) {
49395
49455
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -49404,10 +49464,10 @@ var ProviderLoader = class _ProviderLoader {
49404
49464
  * Check if upstream directory exists and has providers.
49405
49465
  */
49406
49466
  hasUpstream() {
49407
- if (!fs25.existsSync(this.upstreamDir)) return false;
49467
+ if (!fs26.existsSync(this.upstreamDir)) return false;
49408
49468
  try {
49409
- return fs25.readdirSync(this.upstreamDir).some(
49410
- (d) => fs25.statSync(path35.join(this.upstreamDir, d)).isDirectory()
49469
+ return fs26.readdirSync(this.upstreamDir).some(
49470
+ (d) => fs26.statSync(path36.join(this.upstreamDir, d)).isDirectory()
49411
49471
  );
49412
49472
  } catch {
49413
49473
  return false;
@@ -49905,8 +49965,8 @@ var ProviderLoader = class _ProviderLoader {
49905
49965
  resolved._resolvedScriptDir = entry.scriptDir;
49906
49966
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
49907
49967
  if (providerDir) {
49908
- const fullDir = path35.join(providerDir, entry.scriptDir);
49909
- resolved._resolvedScriptsPath = fs25.existsSync(path35.join(fullDir, "scripts.js")) ? path35.join(fullDir, "scripts.js") : fullDir;
49968
+ const fullDir = path36.join(providerDir, entry.scriptDir);
49969
+ resolved._resolvedScriptsPath = fs26.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
49910
49970
  }
49911
49971
  matched = true;
49912
49972
  }
@@ -49924,8 +49984,8 @@ var ProviderLoader = class _ProviderLoader {
49924
49984
  resolved._resolvedScriptDir = base.defaultScriptDir;
49925
49985
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
49926
49986
  if (providerDir) {
49927
- const fullDir = path35.join(providerDir, base.defaultScriptDir);
49928
- resolved._resolvedScriptsPath = fs25.existsSync(path35.join(fullDir, "scripts.js")) ? path35.join(fullDir, "scripts.js") : fullDir;
49987
+ const fullDir = path36.join(providerDir, base.defaultScriptDir);
49988
+ resolved._resolvedScriptsPath = fs26.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
49929
49989
  }
49930
49990
  }
49931
49991
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -49942,8 +50002,8 @@ var ProviderLoader = class _ProviderLoader {
49942
50002
  resolved._resolvedScriptDir = dirOverride;
49943
50003
  resolved._resolvedScriptsSource = `versions:${range}`;
49944
50004
  if (providerDir) {
49945
- const fullDir = path35.join(providerDir, dirOverride);
49946
- resolved._resolvedScriptsPath = fs25.existsSync(path35.join(fullDir, "scripts.js")) ? path35.join(fullDir, "scripts.js") : fullDir;
50005
+ const fullDir = path36.join(providerDir, dirOverride);
50006
+ resolved._resolvedScriptsPath = fs26.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
49947
50007
  }
49948
50008
  }
49949
50009
  } else if (override.scripts) {
@@ -49959,8 +50019,8 @@ var ProviderLoader = class _ProviderLoader {
49959
50019
  resolved._resolvedScriptDir = base.defaultScriptDir;
49960
50020
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
49961
50021
  if (providerDir) {
49962
- const fullDir = path35.join(providerDir, base.defaultScriptDir);
49963
- resolved._resolvedScriptsPath = fs25.existsSync(path35.join(fullDir, "scripts.js")) ? path35.join(fullDir, "scripts.js") : fullDir;
50022
+ const fullDir = path36.join(providerDir, base.defaultScriptDir);
50023
+ resolved._resolvedScriptsPath = fs26.existsSync(path36.join(fullDir, "scripts.js")) ? path36.join(fullDir, "scripts.js") : fullDir;
49964
50024
  }
49965
50025
  }
49966
50026
  }
@@ -49977,13 +50037,13 @@ var ProviderLoader = class _ProviderLoader {
49977
50037
  if (providerDir2) {
49978
50038
  for (const [scriptName, override] of Object.entries(base.overrides)) {
49979
50039
  if (!override || typeof override.path !== "string") continue;
49980
- const fullPath = path35.join(providerDir2, override.path);
49981
- if (!fs25.existsSync(fullPath)) {
50040
+ const fullPath = path36.join(providerDir2, override.path);
50041
+ if (!fs26.existsSync(fullPath)) {
49982
50042
  this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
49983
50043
  continue;
49984
50044
  }
49985
50045
  try {
49986
- registerProviderScriptRootSafely(path35.dirname(path35.dirname(providerDir2)));
50046
+ registerProviderScriptRootSafely(path36.dirname(path36.dirname(providerDir2)));
49987
50047
  delete __require.cache[__require.resolve(fullPath)];
49988
50048
  const fn = __require(fullPath);
49989
50049
  const target = typeof fn === "function" ? fn : fn && fn[scriptName];
@@ -50008,25 +50068,25 @@ var ProviderLoader = class _ProviderLoader {
50008
50068
  }
50009
50069
  if (providerDir) {
50010
50070
  try {
50011
- const fs40 = __require("fs");
50012
- const path44 = __require("path");
50071
+ const fs41 = __require("fs");
50072
+ const path45 = __require("path");
50013
50073
  const candidates = [];
50014
50074
  if (Array.isArray(base.compatibility)) {
50015
50075
  for (const entry of base.compatibility) {
50016
50076
  if (typeof entry?.spec !== "string") continue;
50017
50077
  const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
50018
- if (matches) candidates.push(path44.join(providerDir, entry.spec));
50078
+ if (matches) candidates.push(path45.join(providerDir, entry.spec));
50019
50079
  }
50020
50080
  }
50021
- candidates.push(path44.join(providerDir, "specs", "default.json"));
50022
- candidates.push(path44.join(providerDir, "spec.json"));
50023
- const specPath = candidates.find((p) => fs40.existsSync(p));
50081
+ candidates.push(path45.join(providerDir, "specs", "default.json"));
50082
+ candidates.push(path45.join(providerDir, "spec.json"));
50083
+ const specPath = candidates.find((p) => fs41.existsSync(p));
50024
50084
  if (specPath) {
50025
50085
  resolved._resolvedSpecPath = specPath;
50026
50086
  let specControls;
50027
50087
  let nh;
50028
50088
  try {
50029
- const rawSpec = JSON.parse(fs40.readFileSync(specPath, "utf8"));
50089
+ const rawSpec = JSON.parse(fs41.readFileSync(specPath, "utf8"));
50030
50090
  specControls = rawSpec.control_bar;
50031
50091
  nh = rawSpec.native_history;
50032
50092
  } catch {
@@ -50057,10 +50117,10 @@ var ProviderLoader = class _ProviderLoader {
50057
50117
  format = `spec-${nh.source.kind}`;
50058
50118
  reader = (input) => executeNativeHistory(nh, input);
50059
50119
  } else if (nh.override_path) {
50060
- const overrideFile = path44.resolve(providerDir, nh.override_path);
50061
- if (fs40.existsSync(overrideFile)) {
50120
+ const overrideFile = path45.resolve(providerDir, nh.override_path);
50121
+ if (fs41.existsSync(overrideFile)) {
50062
50122
  try {
50063
- registerProviderScriptRootSafely(path44.dirname(path44.dirname(providerDir)));
50123
+ registerProviderScriptRootSafely(path45.dirname(path45.dirname(providerDir)));
50064
50124
  delete __require.cache[__require.resolve(overrideFile)];
50065
50125
  const mod = __require(overrideFile);
50066
50126
  const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
@@ -50103,16 +50163,16 @@ var ProviderLoader = class _ProviderLoader {
50103
50163
  this.debugLog(`[loadScriptsFromDir] ${type}: providerDir not found`);
50104
50164
  return null;
50105
50165
  }
50106
- const dir = path35.join(providerDir, scriptDir);
50107
- if (!fs25.existsSync(dir)) {
50166
+ const dir = path36.join(providerDir, scriptDir);
50167
+ if (!fs26.existsSync(dir)) {
50108
50168
  this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
50109
50169
  return null;
50110
50170
  }
50111
- registerProviderScriptRootSafely(path35.dirname(path35.dirname(providerDir)));
50171
+ registerProviderScriptRootSafely(path36.dirname(path36.dirname(providerDir)));
50112
50172
  const cached3 = this.scriptsCache.get(dir);
50113
50173
  if (cached3) return cached3;
50114
- const scriptsJs = path35.join(dir, "scripts.js");
50115
- if (fs25.existsSync(scriptsJs)) {
50174
+ const scriptsJs = path36.join(dir, "scripts.js");
50175
+ if (fs26.existsSync(scriptsJs)) {
50116
50176
  try {
50117
50177
  delete __require.cache[__require.resolve(scriptsJs)];
50118
50178
  const loaded = __require(scriptsJs);
@@ -50133,9 +50193,9 @@ var ProviderLoader = class _ProviderLoader {
50133
50193
  watch() {
50134
50194
  this.stopWatch();
50135
50195
  const watchDir = (dir) => {
50136
- if (!fs25.existsSync(dir)) {
50196
+ if (!fs26.existsSync(dir)) {
50137
50197
  try {
50138
- fs25.mkdirSync(dir, { recursive: true });
50198
+ fs26.mkdirSync(dir, { recursive: true });
50139
50199
  } catch {
50140
50200
  return;
50141
50201
  }
@@ -50156,7 +50216,7 @@ var ProviderLoader = class _ProviderLoader {
50156
50216
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
50157
50217
  if (reloadTimer) clearTimeout(reloadTimer);
50158
50218
  reloadTimer = setTimeout(() => {
50159
- this.log(`File changed: ${path35.basename(filePath)}, reloading...`);
50219
+ this.log(`File changed: ${path36.basename(filePath)}, reloading...`);
50160
50220
  this.reload();
50161
50221
  }, 300);
50162
50222
  }
@@ -50224,11 +50284,11 @@ var ProviderLoader = class _ProviderLoader {
50224
50284
  }
50225
50285
  this.log(`Registry sync starting (${this.registryBaseUrl})...`);
50226
50286
  const https = __require("https");
50227
- const regMetaPath = path35.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
50287
+ const regMetaPath = path36.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
50228
50288
  let cachedChecksums = {};
50229
50289
  try {
50230
- if (fs25.existsSync(regMetaPath)) {
50231
- cachedChecksums = JSON.parse(fs25.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
50290
+ if (fs26.existsSync(regMetaPath)) {
50291
+ cachedChecksums = JSON.parse(fs26.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
50232
50292
  }
50233
50293
  } catch {
50234
50294
  }
@@ -50279,15 +50339,15 @@ var ProviderLoader = class _ProviderLoader {
50279
50339
  this.log(`\u26A0 Registry checksum mismatch for ${type}@${version} \u2014 skipping`);
50280
50340
  continue;
50281
50341
  }
50282
- const providerDir = path35.join(this.upstreamDir, category, type);
50283
- fs25.mkdirSync(providerDir, { recursive: true });
50284
- fs25.writeFileSync(path35.join(providerDir, "provider.json"), manifestBody, "utf-8");
50342
+ const providerDir = path36.join(this.upstreamDir, category, type);
50343
+ fs26.mkdirSync(providerDir, { recursive: true });
50344
+ fs26.writeFileSync(path36.join(providerDir, "provider.json"), manifestBody, "utf-8");
50285
50345
  cachedChecksums[cacheKey] = checksum;
50286
50346
  updatedCount++;
50287
50347
  this.log(`\u2713 Registry updated: ${category}/${type}@${version}`);
50288
50348
  }
50289
- fs25.mkdirSync(this.upstreamDir, { recursive: true });
50290
- fs25.writeFileSync(regMetaPath, JSON.stringify({
50349
+ fs26.mkdirSync(this.upstreamDir, { recursive: true });
50350
+ fs26.writeFileSync(regMetaPath, JSON.stringify({
50291
50351
  checksums: cachedChecksums,
50292
50352
  syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
50293
50353
  providerCount: list.providers.length
@@ -50308,12 +50368,12 @@ var ProviderLoader = class _ProviderLoader {
50308
50368
  const { exec: exec7 } = __require("child_process");
50309
50369
  const { promisify: promisify8 } = __require("util");
50310
50370
  const execAsync5 = promisify8(exec7);
50311
- const metaPath = path35.join(this.upstreamDir, _ProviderLoader.META_FILE);
50371
+ const metaPath = path36.join(this.upstreamDir, _ProviderLoader.META_FILE);
50312
50372
  let prevEtag = "";
50313
50373
  let prevTimestamp = 0;
50314
50374
  try {
50315
- if (fs25.existsSync(metaPath)) {
50316
- const meta = JSON.parse(fs25.readFileSync(metaPath, "utf-8"));
50375
+ if (fs26.existsSync(metaPath)) {
50376
+ const meta = JSON.parse(fs26.readFileSync(metaPath, "utf-8"));
50317
50377
  prevEtag = meta.etag || "";
50318
50378
  prevTimestamp = meta.timestamp || 0;
50319
50379
  }
@@ -50369,39 +50429,39 @@ var ProviderLoader = class _ProviderLoader {
50369
50429
  return { updated: false };
50370
50430
  }
50371
50431
  this.log("Downloading latest providers from GitHub...");
50372
- const tmpTar = path35.join(os25.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
50373
- const tmpExtract = path35.join(os25.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
50432
+ const tmpTar = path36.join(os26.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
50433
+ const tmpExtract = path36.join(os26.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
50374
50434
  await this.downloadFile(tarballTarget.url, tmpTar);
50375
- fs25.mkdirSync(tmpExtract, { recursive: true });
50435
+ fs26.mkdirSync(tmpExtract, { recursive: true });
50376
50436
  await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
50377
- const extracted = fs25.readdirSync(tmpExtract);
50437
+ const extracted = fs26.readdirSync(tmpExtract);
50378
50438
  const rootDir = extracted.find(
50379
- (d) => fs25.statSync(path35.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
50439
+ (d) => fs26.statSync(path36.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
50380
50440
  );
50381
50441
  if (!rootDir) throw new Error("Unexpected tarball structure");
50382
- const sourceDir = path35.join(tmpExtract, rootDir);
50442
+ const sourceDir = path36.join(tmpExtract, rootDir);
50383
50443
  const backupDir = this.upstreamDir + ".bak";
50384
- if (fs25.existsSync(this.upstreamDir)) {
50385
- if (fs25.existsSync(backupDir)) fs25.rmSync(backupDir, { recursive: true, force: true });
50386
- fs25.renameSync(this.upstreamDir, backupDir);
50444
+ if (fs26.existsSync(this.upstreamDir)) {
50445
+ if (fs26.existsSync(backupDir)) fs26.rmSync(backupDir, { recursive: true, force: true });
50446
+ fs26.renameSync(this.upstreamDir, backupDir);
50387
50447
  }
50388
50448
  try {
50389
50449
  this.copyDirRecursive(sourceDir, this.upstreamDir);
50390
50450
  this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
50391
- if (fs25.existsSync(backupDir)) fs25.rmSync(backupDir, { recursive: true, force: true });
50451
+ if (fs26.existsSync(backupDir)) fs26.rmSync(backupDir, { recursive: true, force: true });
50392
50452
  } catch (e) {
50393
- if (fs25.existsSync(backupDir)) {
50394
- if (fs25.existsSync(this.upstreamDir)) fs25.rmSync(this.upstreamDir, { recursive: true, force: true });
50395
- fs25.renameSync(backupDir, this.upstreamDir);
50453
+ if (fs26.existsSync(backupDir)) {
50454
+ if (fs26.existsSync(this.upstreamDir)) fs26.rmSync(this.upstreamDir, { recursive: true, force: true });
50455
+ fs26.renameSync(backupDir, this.upstreamDir);
50396
50456
  }
50397
50457
  throw e;
50398
50458
  }
50399
50459
  try {
50400
- fs25.rmSync(tmpTar, { force: true });
50460
+ fs26.rmSync(tmpTar, { force: true });
50401
50461
  } catch {
50402
50462
  }
50403
50463
  try {
50404
- fs25.rmSync(tmpExtract, { recursive: true, force: true });
50464
+ fs26.rmSync(tmpExtract, { recursive: true, force: true });
50405
50465
  } catch {
50406
50466
  }
50407
50467
  const upstreamCount = this.countProviders(this.upstreamDir);
@@ -50433,7 +50493,7 @@ var ProviderLoader = class _ProviderLoader {
50433
50493
  reject(new Error(`HTTP ${res.statusCode}`));
50434
50494
  return;
50435
50495
  }
50436
- const ws = fs25.createWriteStream(destPath);
50496
+ const ws = fs26.createWriteStream(destPath);
50437
50497
  res.pipe(ws);
50438
50498
  ws.on("finish", () => {
50439
50499
  ws.close();
@@ -50452,22 +50512,22 @@ var ProviderLoader = class _ProviderLoader {
50452
50512
  }
50453
50513
  /** Recursive directory copy */
50454
50514
  copyDirRecursive(src, dest) {
50455
- fs25.mkdirSync(dest, { recursive: true });
50456
- for (const entry of fs25.readdirSync(src, { withFileTypes: true })) {
50457
- const srcPath = path35.join(src, entry.name);
50458
- const destPath = path35.join(dest, entry.name);
50515
+ fs26.mkdirSync(dest, { recursive: true });
50516
+ for (const entry of fs26.readdirSync(src, { withFileTypes: true })) {
50517
+ const srcPath = path36.join(src, entry.name);
50518
+ const destPath = path36.join(dest, entry.name);
50459
50519
  if (entry.isDirectory()) {
50460
50520
  this.copyDirRecursive(srcPath, destPath);
50461
50521
  } else {
50462
- fs25.copyFileSync(srcPath, destPath);
50522
+ fs26.copyFileSync(srcPath, destPath);
50463
50523
  }
50464
50524
  }
50465
50525
  }
50466
50526
  /** .meta.json save */
50467
50527
  writeMeta(metaPath, etag, timestamp) {
50468
50528
  try {
50469
- fs25.mkdirSync(path35.dirname(metaPath), { recursive: true });
50470
- fs25.writeFileSync(metaPath, JSON.stringify({
50529
+ fs26.mkdirSync(path36.dirname(metaPath), { recursive: true });
50530
+ fs26.writeFileSync(metaPath, JSON.stringify({
50471
50531
  etag,
50472
50532
  timestamp,
50473
50533
  lastCheck: new Date(timestamp).toISOString(),
@@ -50478,15 +50538,15 @@ var ProviderLoader = class _ProviderLoader {
50478
50538
  }
50479
50539
  /** Count provider files (provider.v1.json or provider.json — at most one per dir). */
50480
50540
  countProviders(dir) {
50481
- if (!fs25.existsSync(dir)) return 0;
50541
+ if (!fs26.existsSync(dir)) return 0;
50482
50542
  let count = 0;
50483
50543
  const scan = (d) => {
50484
50544
  try {
50485
- const entries = fs25.readdirSync(d, { withFileTypes: true });
50545
+ const entries = fs26.readdirSync(d, { withFileTypes: true });
50486
50546
  const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
50487
50547
  if (hasManifest) count++;
50488
50548
  for (const entry of entries) {
50489
- if (entry.isDirectory()) scan(path35.join(d, entry.name));
50549
+ if (entry.isDirectory()) scan(path36.join(d, entry.name));
50490
50550
  }
50491
50551
  } catch {
50492
50552
  }
@@ -50712,13 +50772,13 @@ var ProviderLoader = class _ProviderLoader {
50712
50772
  if (!provider) return null;
50713
50773
  const cat = provider.category;
50714
50774
  const searchRoots = this.getProviderRoots();
50715
- const hasManifest = (dir) => fs25.existsSync(path35.join(dir, "provider.v1.json")) || fs25.existsSync(path35.join(dir, "provider.json"));
50775
+ const hasManifest = (dir) => fs26.existsSync(path36.join(dir, "provider.v1.json")) || fs26.existsSync(path36.join(dir, "provider.json"));
50716
50776
  const readManifestType = (dir) => {
50717
50777
  for (const file of ["provider.v1.json", "provider.json"]) {
50718
- const p = path35.join(dir, file);
50719
- if (!fs25.existsSync(p)) continue;
50778
+ const p = path36.join(dir, file);
50779
+ if (!fs26.existsSync(p)) continue;
50720
50780
  try {
50721
- const data = JSON.parse(fs25.readFileSync(p, "utf-8"));
50781
+ const data = JSON.parse(fs26.readFileSync(p, "utf-8"));
50722
50782
  if (typeof data?.type === "string") return data.type;
50723
50783
  } catch {
50724
50784
  }
@@ -50726,15 +50786,15 @@ var ProviderLoader = class _ProviderLoader {
50726
50786
  return null;
50727
50787
  };
50728
50788
  for (const root of searchRoots) {
50729
- if (!fs25.existsSync(root)) continue;
50789
+ if (!fs26.existsSync(root)) continue;
50730
50790
  const candidate = this.getProviderDir(root, cat, type);
50731
50791
  if (hasManifest(candidate)) return candidate;
50732
- const catDir = path35.join(root, cat);
50733
- if (fs25.existsSync(catDir)) {
50792
+ const catDir = path36.join(root, cat);
50793
+ if (fs26.existsSync(catDir)) {
50734
50794
  try {
50735
- for (const entry of fs25.readdirSync(catDir, { withFileTypes: true })) {
50795
+ for (const entry of fs26.readdirSync(catDir, { withFileTypes: true })) {
50736
50796
  if (!entry.isDirectory()) continue;
50737
- const entryDir = path35.join(catDir, entry.name);
50797
+ const entryDir = path36.join(catDir, entry.name);
50738
50798
  const manifestType = readManifestType(entryDir);
50739
50799
  if (manifestType === type) return entryDir;
50740
50800
  }
@@ -50750,8 +50810,8 @@ var ProviderLoader = class _ProviderLoader {
50750
50810
  * (template substitution is NOT applied here — scripts.js handles that)
50751
50811
  */
50752
50812
  buildScriptWrappersFromDir(dir) {
50753
- const scriptsJs = path35.join(dir, "scripts.js");
50754
- if (fs25.existsSync(scriptsJs)) {
50813
+ const scriptsJs = path36.join(dir, "scripts.js");
50814
+ if (fs26.existsSync(scriptsJs)) {
50755
50815
  try {
50756
50816
  delete __require.cache[__require.resolve(scriptsJs)];
50757
50817
  return __require(scriptsJs);
@@ -50761,13 +50821,13 @@ var ProviderLoader = class _ProviderLoader {
50761
50821
  const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
50762
50822
  const result = {};
50763
50823
  try {
50764
- for (const file of fs25.readdirSync(dir)) {
50824
+ for (const file of fs26.readdirSync(dir)) {
50765
50825
  if (!file.endsWith(".js")) continue;
50766
50826
  const scriptName = toCamel(file.replace(".js", ""));
50767
- const filePath = path35.join(dir, file);
50827
+ const filePath = path36.join(dir, file);
50768
50828
  result[scriptName] = (...args) => {
50769
50829
  try {
50770
- let content = fs25.readFileSync(filePath, "utf-8");
50830
+ let content = fs26.readFileSync(filePath, "utf-8");
50771
50831
  if (args[0] && typeof args[0] === "object") {
50772
50832
  for (const [key2, val] of Object.entries(args[0])) {
50773
50833
  let v = val;
@@ -50813,12 +50873,12 @@ var ProviderLoader = class _ProviderLoader {
50813
50873
  * Structure: dir/category/agent-name/provider.{json,js}
50814
50874
  */
50815
50875
  loadDir(dir, excludeDirs) {
50816
- if (!fs25.existsSync(dir)) return 0;
50876
+ if (!fs26.existsSync(dir)) return 0;
50817
50877
  let count = 0;
50818
50878
  const scan = (d) => {
50819
50879
  let entries;
50820
50880
  try {
50821
- entries = fs25.readdirSync(d, { withFileTypes: true });
50881
+ entries = fs26.readdirSync(d, { withFileTypes: true });
50822
50882
  } catch {
50823
50883
  return;
50824
50884
  }
@@ -50826,9 +50886,9 @@ var ProviderLoader = class _ProviderLoader {
50826
50886
  const hasJson = entries.some((e) => e.name === "provider.json");
50827
50887
  if (hasV1 || hasJson) {
50828
50888
  const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
50829
- const jsonPath = path35.join(d, manifestFile);
50889
+ const jsonPath = path36.join(d, manifestFile);
50830
50890
  try {
50831
- const raw = fs25.readFileSync(jsonPath, "utf-8");
50891
+ const raw = fs26.readFileSync(jsonPath, "utf-8");
50832
50892
  const mod = JSON.parse(raw);
50833
50893
  if (hasV1 && mod?.category === "cli") {
50834
50894
  try {
@@ -50866,10 +50926,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
50866
50926
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
50867
50927
  } else {
50868
50928
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
50869
- const scriptsPath = path35.join(d, "scripts.js");
50870
- if (!hasCompatibility && fs25.existsSync(scriptsPath)) {
50929
+ const scriptsPath = path36.join(d, "scripts.js");
50930
+ if (!hasCompatibility && fs26.existsSync(scriptsPath)) {
50871
50931
  try {
50872
- registerProviderScriptRootSafely(path35.dirname(path35.dirname(d)));
50932
+ registerProviderScriptRootSafely(path36.dirname(path36.dirname(d)));
50873
50933
  delete __require.cache[__require.resolve(scriptsPath)];
50874
50934
  const scripts = __require(scriptsPath);
50875
50935
  normalizedProvider.scripts = scripts;
@@ -50877,7 +50937,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
50877
50937
  this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
50878
50938
  }
50879
50939
  }
50880
- const externalDirAbs = path35.join(os25.homedir(), ".adhdev", "external");
50940
+ const externalDirAbs = path36.join(os26.homedir(), ".adhdev", "external");
50881
50941
  const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
50882
50942
  try {
50883
50943
  const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS(provider_trust_exports));
@@ -50887,8 +50947,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
50887
50947
  normalizedProvider._sourceTrust = trust;
50888
50948
  normalizedProvider._manifestShape = shape;
50889
50949
  if (layer === "external") {
50890
- const rel = path35.relative(externalDirAbs, d);
50891
- const firstSeg = rel.split(path35.sep)[0];
50950
+ const rel = path36.relative(externalDirAbs, d);
50951
+ const firstSeg = rel.split(path36.sep)[0];
50892
50952
  if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
50893
50953
  }
50894
50954
  } catch {
@@ -50912,7 +50972,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
50912
50972
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
50913
50973
  if (d === dir && entry.name === "examples") continue;
50914
50974
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
50915
- scan(path35.join(d, entry.name));
50975
+ scan(path36.join(d, entry.name));
50916
50976
  }
50917
50977
  }
50918
50978
  };
@@ -51110,7 +51170,7 @@ async function isCdpActive(port) {
51110
51170
  });
51111
51171
  }
51112
51172
  async function killIdeProcess(ideId) {
51113
- const plat = os26.platform();
51173
+ const plat = os27.platform();
51114
51174
  const appName = getMacAppIdentifiers()[ideId];
51115
51175
  const winProcesses = getWinProcessNames()[ideId];
51116
51176
  try {
@@ -51171,7 +51231,7 @@ async function killIdeProcess(ideId) {
51171
51231
  }
51172
51232
  }
51173
51233
  async function isIdeRunning(ideId) {
51174
- const plat = os26.platform();
51234
+ const plat = os27.platform();
51175
51235
  try {
51176
51236
  if (plat === "darwin") {
51177
51237
  const appName = getMacAppIdentifiers()[ideId];
@@ -51226,7 +51286,7 @@ async function isIdeRunning(ideId) {
51226
51286
  }
51227
51287
  }
51228
51288
  async function detectCurrentWorkspace(ideId) {
51229
- const plat = os26.platform();
51289
+ const plat = os27.platform();
51230
51290
  if (plat === "darwin") {
51231
51291
  try {
51232
51292
  const appName = getMacAppIdentifiers()[ideId];
@@ -51241,17 +51301,17 @@ async function detectCurrentWorkspace(ideId) {
51241
51301
  }
51242
51302
  } else if (plat === "win32") {
51243
51303
  try {
51244
- const fs40 = __require("fs");
51304
+ const fs41 = __require("fs");
51245
51305
  const appNameMap = getMacAppIdentifiers();
51246
51306
  const appName = appNameMap[ideId];
51247
51307
  if (appName) {
51248
- const storagePath = path36.join(
51249
- process.env.APPDATA || path36.join(os26.homedir(), "AppData", "Roaming"),
51308
+ const storagePath = path37.join(
51309
+ process.env.APPDATA || path37.join(os27.homedir(), "AppData", "Roaming"),
51250
51310
  appName,
51251
51311
  "storage.json"
51252
51312
  );
51253
- if (fs40.existsSync(storagePath)) {
51254
- const data = JSON.parse(fs40.readFileSync(storagePath, "utf-8"));
51313
+ if (fs41.existsSync(storagePath)) {
51314
+ const data = JSON.parse(fs41.readFileSync(storagePath, "utf-8"));
51255
51315
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
51256
51316
  if (workspaces.length > 0) {
51257
51317
  const recent = workspaces[0];
@@ -51268,7 +51328,7 @@ async function detectCurrentWorkspace(ideId) {
51268
51328
  return void 0;
51269
51329
  }
51270
51330
  async function launchWithCdp(options = {}) {
51271
- const platform10 = os26.platform();
51331
+ const platform10 = os27.platform();
51272
51332
  let targetIde;
51273
51333
  const ides = await detectIDEs(getProviderLoader());
51274
51334
  if (options.ideId) {
@@ -51771,11 +51831,11 @@ var meshCrudHandlers = {
51771
51831
  MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
51772
51832
  } = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
51773
51833
  const { mkdirSync: mkdirSync22, writeFileSync: writeFileSync24 } = await import("fs");
51774
- const { dirname: dirname17, join: join50 } = await import("path");
51834
+ const { dirname: dirname17, join: join51 } = await import("path");
51775
51835
  const scaffold = buildMeshJsonConfigScaffold2(mesh);
51776
51836
  const scaffoldJson = serializeMeshJsonConfigScaffold2(scaffold);
51777
51837
  const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
51778
- const absolutePath = join50(workspace, relativePath);
51838
+ const absolutePath = join51(workspace, relativePath);
51779
51839
  const validation = normalizeRepoMeshDeclarativeConfig2(scaffold);
51780
51840
  if (!validation.valid) {
51781
51841
  return { success: false, meshId, error: `invalid mesh.json scaffold: ${validation.errors.join("; ")}` };
@@ -52840,7 +52900,7 @@ init_worktree_bootstrap_config();
52840
52900
  init_change_impact_config();
52841
52901
  init_mesh_config();
52842
52902
  import { existsSync as existsSync38, mkdirSync as mkdirSync15, writeFileSync as writeFileSync18 } from "fs";
52843
- import { dirname as dirname11, join as join41 } from "path";
52903
+ import { dirname as dirname11, join as join42 } from "path";
52844
52904
  var MESH_INIT_REFINE_CONFIG_PATH = MESH_REFINE_CONFIG_LOCATIONS[0];
52845
52905
  var MESH_INIT_WORKTREE_BOOTSTRAP_CONFIG_PATH = MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS[0];
52846
52906
  var MESH_INIT_CHANGE_IMPACT_CONFIG_PATH = CHANGE_IMPACT_CONFIG_LOCATIONS[0];
@@ -52855,7 +52915,7 @@ var CANDIDATE_STALE_INPUTS = [
52855
52915
  "requirements.txt"
52856
52916
  ];
52857
52917
  function writeConfigFile(workspace, relativePath, config) {
52858
- const target = join41(workspace, relativePath);
52918
+ const target = join42(workspace, relativePath);
52859
52919
  mkdirSync15(dirname11(target), { recursive: true });
52860
52920
  writeFileSync18(target, `${JSON.stringify(config, null, 2)}
52861
52921
  `, "utf-8");
@@ -52863,14 +52923,14 @@ function writeConfigFile(workspace, relativePath, config) {
52863
52923
  }
52864
52924
  function suggestMeshWorktreeBootstrapConfig(workspace) {
52865
52925
  const commands = [];
52866
- const hasPackageJson = existsSync38(join41(workspace, "package.json"));
52867
- const hasNpmLock = existsSync38(join41(workspace, "package-lock.json"));
52926
+ const hasPackageJson = existsSync38(join42(workspace, "package.json"));
52927
+ const hasNpmLock = existsSync38(join42(workspace, "package-lock.json"));
52868
52928
  if (hasPackageJson) {
52869
52929
  commands.push(
52870
52930
  hasNpmLock ? { command: "npm", args: ["ci"] } : { command: "npm", args: ["install"] }
52871
52931
  );
52872
52932
  }
52873
- const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => existsSync38(join41(workspace, relative5)));
52933
+ const staleInputs = CANDIDATE_STALE_INPUTS.filter((relative5) => existsSync38(join42(workspace, relative5)));
52874
52934
  if (!commands.length) {
52875
52935
  return { commands, staleInputs };
52876
52936
  }
@@ -52969,7 +53029,7 @@ function runMeshInit(mesh, workspace, detected, options = {}) {
52969
53029
  }
52970
53030
  function applyConfigSuggestion(input) {
52971
53031
  const { workspace, relativePath, existing, suggestedConfig, validate, write, overwrite } = input;
52972
- const absolute = join41(workspace, relativePath);
53032
+ const absolute = join42(workspace, relativePath);
52973
53033
  if (existing !== void 0 && !overwrite) {
52974
53034
  return { path: absolute, relativePath, written: false, skippedReason: "already_exists", config: existing };
52975
53035
  }
@@ -53231,7 +53291,7 @@ init_logger();
53231
53291
  init_mesh_host_ownership();
53232
53292
  init_coordinator_registry();
53233
53293
  import { join as pathJoin } from "path";
53234
- import * as fs26 from "fs";
53294
+ import * as fs27 from "fs";
53235
53295
  init_mesh_coordinator();
53236
53296
  init_dist();
53237
53297
  var meshCoordinatorLaunchHandlers = {
@@ -53463,15 +53523,15 @@ ${ptyResult.output.slice(-2e3)}`);
53463
53523
  }
53464
53524
  if (cliType === "codex-cli") {
53465
53525
  const repoMcpConfigPath = pathJoin(workspace, ".mcp.json");
53466
- if (fs26.existsSync(repoMcpConfigPath)) {
53526
+ if (fs27.existsSync(repoMcpConfigPath)) {
53467
53527
  try {
53468
53528
  const repoMcpConfig = parseMeshCoordinatorMcpConfig(
53469
- fs26.readFileSync(repoMcpConfigPath, "utf-8"),
53529
+ fs27.readFileSync(repoMcpConfigPath, "utf-8"),
53470
53530
  "claude_mcp_json"
53471
53531
  );
53472
53532
  const existingServers2 = repoMcpConfig.mcpServers;
53473
53533
  if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
53474
- fs26.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
53534
+ fs27.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
53475
53535
  ...repoMcpConfig,
53476
53536
  mcpServers: {
53477
53537
  ...existingServers2,
@@ -53760,7 +53820,7 @@ init_dist();
53760
53820
  init_mesh_events();
53761
53821
  init_mesh_routing();
53762
53822
  init_mesh_host_ownership();
53763
- import * as fs27 from "fs";
53823
+ import * as fs28 from "fs";
53764
53824
  import { hostname as osHostname } from "os";
53765
53825
 
53766
53826
  // src/mesh/preview-freshness.ts
@@ -53801,10 +53861,10 @@ function runGit2(repoRoot, args) {
53801
53861
  }
53802
53862
  }
53803
53863
  function readRecord6(repoRoot) {
53804
- const path44 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
53805
- if (!existsSync40(path44)) return null;
53864
+ const path45 = resolve19(repoRoot, PREVIEW_DEPLOY_RECORD);
53865
+ if (!existsSync40(path45)) return null;
53806
53866
  try {
53807
- const parsed = JSON.parse(readFileSync31(path44, "utf8"));
53867
+ const parsed = JSON.parse(readFileSync31(path45, "utf8"));
53808
53868
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
53809
53869
  } catch {
53810
53870
  return null;
@@ -54115,7 +54175,7 @@ var meshStatusHandlers = {
54115
54175
  }
54116
54176
  }
54117
54177
  if (workspace) {
54118
- if (!fs27.existsSync(workspace)) {
54178
+ if (!fs28.existsSync(workspace)) {
54119
54179
  const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
54120
54180
  let remoteProbeApplied = false;
54121
54181
  if (inlineTransitGit) {
@@ -54245,7 +54305,7 @@ var meshStatusHandlers = {
54245
54305
  backstop: { ...getMeshV2BackstopCounters() }
54246
54306
  };
54247
54307
  const previewFreshness = (() => {
54248
- const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs27.existsSync(candidate));
54308
+ const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs28.existsSync(candidate));
54249
54309
  return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
54250
54310
  })();
54251
54311
  const asyncRefineJobs = buildMeshAsyncRefineJobs({
@@ -54445,15 +54505,15 @@ init_dist();
54445
54505
  init_logger();
54446
54506
 
54447
54507
  // src/logging/command-log.ts
54448
- import * as fs28 from "fs";
54449
- import * as path37 from "path";
54450
- import * as os27 from "os";
54451
- var ADHDEV_HOME2 = process.env.ADHDEV_CONFIG_DIR && process.env.ADHDEV_CONFIG_DIR.trim() ? process.env.ADHDEV_CONFIG_DIR.trim() : path37.join(os27.homedir(), ".adhdev");
54452
- var LOG_DIR2 = path37.join(ADHDEV_HOME2, "logs");
54508
+ import * as fs29 from "fs";
54509
+ import * as path38 from "path";
54510
+ import * as os28 from "os";
54511
+ 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");
54512
+ var LOG_DIR2 = path38.join(ADHDEV_HOME2, "logs");
54453
54513
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
54454
54514
  var MAX_DAYS = 7;
54455
54515
  try {
54456
- fs28.mkdirSync(LOG_DIR2, { recursive: true });
54516
+ fs29.mkdirSync(LOG_DIR2, { recursive: true });
54457
54517
  } catch {
54458
54518
  }
54459
54519
  var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
@@ -54487,19 +54547,19 @@ function getDateStr2() {
54487
54547
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
54488
54548
  }
54489
54549
  var currentDate2 = getDateStr2();
54490
- var currentFile = path37.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
54550
+ var currentFile = path38.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
54491
54551
  var writeCount2 = 0;
54492
54552
  function checkRotation() {
54493
54553
  const today = getDateStr2();
54494
54554
  if (today !== currentDate2) {
54495
54555
  currentDate2 = today;
54496
- currentFile = path37.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
54556
+ currentFile = path38.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
54497
54557
  cleanOldFiles();
54498
54558
  }
54499
54559
  }
54500
54560
  function cleanOldFiles() {
54501
54561
  try {
54502
- const files = fs28.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
54562
+ const files = fs29.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
54503
54563
  const cutoff = /* @__PURE__ */ new Date();
54504
54564
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
54505
54565
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -54507,7 +54567,7 @@ function cleanOldFiles() {
54507
54567
  const dateMatch = file.match(/commands-(\d{4}-\d{2}-\d{2})/);
54508
54568
  if (dateMatch && dateMatch[1] < cutoffStr) {
54509
54569
  try {
54510
- fs28.unlinkSync(path37.join(LOG_DIR2, file));
54570
+ fs29.unlinkSync(path38.join(LOG_DIR2, file));
54511
54571
  } catch {
54512
54572
  }
54513
54573
  }
@@ -54517,14 +54577,14 @@ function cleanOldFiles() {
54517
54577
  }
54518
54578
  function checkSize() {
54519
54579
  try {
54520
- const stat2 = fs28.statSync(currentFile);
54580
+ const stat2 = fs29.statSync(currentFile);
54521
54581
  if (stat2.size > MAX_FILE_SIZE) {
54522
54582
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
54523
54583
  try {
54524
- fs28.unlinkSync(backup);
54584
+ fs29.unlinkSync(backup);
54525
54585
  } catch {
54526
54586
  }
54527
- fs28.renameSync(currentFile, backup);
54587
+ fs29.renameSync(currentFile, backup);
54528
54588
  }
54529
54589
  } catch {
54530
54590
  }
@@ -54557,14 +54617,14 @@ function logCommand(entry) {
54557
54617
  ...entry.error ? { err: entry.error } : {},
54558
54618
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
54559
54619
  });
54560
- fs28.appendFileSync(currentFile, line + "\n");
54620
+ fs29.appendFileSync(currentFile, line + "\n");
54561
54621
  } catch {
54562
54622
  }
54563
54623
  }
54564
54624
  function getRecentCommands(count = 50) {
54565
54625
  try {
54566
- if (!fs28.existsSync(currentFile)) return [];
54567
- const content = fs28.readFileSync(currentFile, "utf-8");
54626
+ if (!fs29.existsSync(currentFile)) return [];
54627
+ const content = fs29.readFileSync(currentFile, "utf-8");
54568
54628
  const lines = content.trim().split("\n").filter(Boolean);
54569
54629
  return lines.slice(-count).map((line) => {
54570
54630
  try {
@@ -54592,7 +54652,7 @@ cleanOldFiles();
54592
54652
  // src/commands/router.ts
54593
54653
  init_debug_trace();
54594
54654
  init_mesh_host_ownership();
54595
- import * as fs33 from "fs";
54655
+ import * as fs34 from "fs";
54596
54656
 
54597
54657
  // src/mesh/mesh-node-identity.ts
54598
54658
  init_cli_detector();
@@ -54600,7 +54660,7 @@ init_git_status();
54600
54660
  init_dist();
54601
54661
  init_logger();
54602
54662
  init_mesh_warmup_deadline();
54603
- import * as fs29 from "fs";
54663
+ import * as fs30 from "fs";
54604
54664
  init_runtime_defaults();
54605
54665
  function readProviderPriorityFromPolicy(policy) {
54606
54666
  const record = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
@@ -54987,7 +55047,7 @@ function isDeadLocalWorktreeNode(node) {
54987
55047
  if (node?.isLocalWorktree !== true) return false;
54988
55048
  const workspace = readStringValue(node?.workspace);
54989
55049
  if (!workspace) return false;
54990
- return !fs29.existsSync(workspace);
55050
+ return !fs30.existsSync(workspace);
54991
55051
  }
54992
55052
  function foldMeshNodeIdentityToCanonical(node) {
54993
55053
  if (!node || typeof node !== "object" || Array.isArray(node)) return node;
@@ -55235,7 +55295,7 @@ function summarizeInlineMeshBranchConvergence(nodes) {
55235
55295
  const followUps = nodes.filter((node) => {
55236
55296
  if (readObjectRecord(node.branchConvergence).needsConvergence !== true) return false;
55237
55297
  const workspace = typeof node.workspace === "string" ? node.workspace : "";
55238
- if (workspace && !fs29.existsSync(workspace)) return false;
55298
+ if (workspace && !fs30.existsSync(workspace)) return false;
55239
55299
  return true;
55240
55300
  }).map((node) => {
55241
55301
  const convergence = readObjectRecord(node.branchConvergence);
@@ -55665,7 +55725,7 @@ async function hydrateInlineMeshDirectTruth(args) {
55665
55725
  if (!workspace) {
55666
55726
  return !isSelfNode && daemonId ? { kind: "unavailable", nodeId } : { kind: "skip" };
55667
55727
  }
55668
- if (fs29.existsSync(workspace)) {
55728
+ if (fs30.existsSync(workspace)) {
55669
55729
  try {
55670
55730
  const runLocalProbe = () => getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
55671
55731
  const localGit = args.probeCache ? await args.probeCache.probeLocal(workspace, runLocalProbe) : await runLocalProbe();
@@ -55812,7 +55872,7 @@ function readLiveMeshNodeWorkspace(args) {
55812
55872
  }
55813
55873
  function collectLiveMeshSessionRecords(args) {
55814
55874
  const nodeWorkspace = readStringValue(args.node?.workspace);
55815
- const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs29.existsSync(nodeWorkspace);
55875
+ const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs30.existsSync(nodeWorkspace);
55816
55876
  const matches = args.liveSessionRecords.filter((record) => {
55817
55877
  const recordNodeId = readStringValue(record?.meta?.meshNodeId);
55818
55878
  if (recordNodeId && !daemonIdsEquivalent(recordNodeId, args.nodeId)) return false;
@@ -55839,7 +55899,7 @@ function buildHistoricalMeshSessions(args) {
55839
55899
  const workspace = readStringValue(node?.workspace);
55840
55900
  if (nodeId) liveNodeIds.add(nodeId);
55841
55901
  if (workspace) liveWorkspaces.add(workspace);
55842
- if (nodeId && node?.isLocalWorktree === true && workspace && !fs29.existsSync(workspace)) {
55902
+ if (nodeId && node?.isLocalWorktree === true && workspace && !fs30.existsSync(workspace)) {
55843
55903
  missingLocalWorktreeNodeIds.add(nodeId);
55844
55904
  }
55845
55905
  }
@@ -55935,9 +55995,9 @@ import { promisify as promisify6 } from "util";
55935
55995
  var execFileAsync3 = promisify6(execFile4);
55936
55996
  var GIT = process.platform === "win32" ? resolveWin32Executable("git") : "git";
55937
55997
  var MAX_CHANGED_FILES2 = 500;
55938
- function topLevel(path44) {
55939
- const slash = path44.indexOf("/");
55940
- return slash === -1 ? path44 : path44.slice(0, slash);
55998
+ function topLevel(path45) {
55999
+ const slash = path45.indexOf("/");
56000
+ return slash === -1 ? path45 : path45.slice(0, slash);
55941
56001
  }
55942
56002
  async function analyzeMeshRefineNodeChangeArea(args) {
55943
56003
  const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
@@ -56026,7 +56086,7 @@ init_refine_config();
56026
56086
  init_worktree_bootstrap_config();
56027
56087
  init_resolve_executable();
56028
56088
  import { basename as pathBasename, join as pathJoin2, resolve as pathResolve2 } from "path";
56029
- import * as fs30 from "fs";
56089
+ import * as fs31 from "fs";
56030
56090
  import { execFileSync as execFileSync7 } from "child_process";
56031
56091
  var GIT2 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
56032
56092
  var REFINE_VALIDATION_TIMEOUT_MS = 12e4;
@@ -56085,7 +56145,7 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
56085
56145
  const { execFileSync: execFileSync10 } = await import("child_process");
56086
56146
  const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
56087
56147
  if (excludePaths.length > 0) {
56088
- diffArgs.push("--", ".", ...excludePaths.map((path44) => `:(exclude)${path44}`));
56148
+ diffArgs.push("--", ".", ...excludePaths.map((path45) => `:(exclude)${path45}`));
56089
56149
  }
56090
56150
  const diff = execFileSync10(GIT2, diffArgs, {
56091
56151
  cwd,
@@ -56286,9 +56346,9 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
56286
56346
  if (!trimmed) continue;
56287
56347
  if (trimmed.startsWith("+")) {
56288
56348
  const parts = trimmed.slice(1).trim().split(/\s+/);
56289
- const path44 = parts[1] || parts[0] || "(unknown)";
56349
+ const path45 = parts[1] || parts[0] || "(unknown)";
56290
56350
  submoduleHints.push({
56291
- path: path44,
56351
+ path: path45,
56292
56352
  reason: "submodule checked-out commit differs from the committed gitlink (pointer bump not committed on the root branch)"
56293
56353
  });
56294
56354
  }
@@ -56318,10 +56378,10 @@ async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
56318
56378
  }
56319
56379
  function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
56320
56380
  if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
56321
- const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path44) => ({
56322
- path: path44,
56323
- baseCommit: readTreeObject(repoRoot, baseHead, path44),
56324
- branchCommit: readTreeObject(repoRoot, branchHead, path44)
56381
+ const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path45) => ({
56382
+ path: path45,
56383
+ baseCommit: readTreeObject(repoRoot, baseHead, path45),
56384
+ branchCommit: readTreeObject(repoRoot, branchHead, path45)
56325
56385
  }));
56326
56386
  if (conflicts.length === 0) return void 0;
56327
56387
  return {
@@ -56347,11 +56407,11 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
56347
56407
  if (!line.trim()) continue;
56348
56408
  const metaAndPath = line.split(" ");
56349
56409
  const meta = metaAndPath[0] || "";
56350
- const path44 = metaAndPath[metaAndPath.length - 1]?.trim();
56351
- if (!path44) continue;
56410
+ const path45 = metaAndPath[metaAndPath.length - 1]?.trim();
56411
+ if (!path45) continue;
56352
56412
  const parts = meta.split(/\s+/);
56353
56413
  if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
56354
- paths.add(path44);
56414
+ paths.add(path45);
56355
56415
  }
56356
56416
  }
56357
56417
  return [...paths].sort();
@@ -56359,9 +56419,9 @@ function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
56359
56419
  return [];
56360
56420
  }
56361
56421
  }
56362
- function readTreeObject(repoRoot, ref, path44) {
56422
+ function readTreeObject(repoRoot, ref, path45) {
56363
56423
  try {
56364
- const output = execFileSync7(GIT2, ["ls-tree", ref, "--", path44], {
56424
+ const output = execFileSync7(GIT2, ["ls-tree", ref, "--", path45], {
56365
56425
  cwd: repoRoot,
56366
56426
  encoding: "utf8",
56367
56427
  maxBuffer: 1024 * 1024
@@ -56384,7 +56444,7 @@ function isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) {
56384
56444
  if (!baseCommit || !branchCommit) return false;
56385
56445
  if (baseCommit === branchCommit) return true;
56386
56446
  try {
56387
- if (!fs30.existsSync(submoduleRepoPath)) return false;
56447
+ if (!fs31.existsSync(submoduleRepoPath)) return false;
56388
56448
  execFileSync7(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
56389
56449
  execFileSync7(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
56390
56450
  execFileSync7(GIT2, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
@@ -56406,12 +56466,12 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
56406
56466
  if (!line.trim()) continue;
56407
56467
  const metaAndPath = line.split(" ");
56408
56468
  const meta = metaAndPath[0] || "";
56409
- const path44 = metaAndPath[metaAndPath.length - 1]?.trim();
56410
- if (!path44 || seen.has(path44)) continue;
56411
- seen.add(path44);
56469
+ const path45 = metaAndPath[metaAndPath.length - 1]?.trim();
56470
+ if (!path45 || seen.has(path45)) continue;
56471
+ seen.add(path45);
56412
56472
  const parts = meta.split(/\s+/);
56413
56473
  const isGitlink = !!(parts[0]?.includes("160000") || parts[1]?.includes("160000"));
56414
- result.push({ path: path44, isGitlink });
56474
+ result.push({ path: path45, isGitlink });
56415
56475
  }
56416
56476
  return result;
56417
56477
  } catch {
@@ -56419,20 +56479,20 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
56419
56479
  }
56420
56480
  }
56421
56481
  function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
56422
- return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path44) => {
56423
- const baseCommit = readTreeObject(repoRoot, baseHead, path44);
56424
- const branchCommit = readTreeObject(repoRoot, branchHead, path44);
56482
+ return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path45) => {
56483
+ const baseCommit = readTreeObject(repoRoot, baseHead, path45);
56484
+ const branchCommit = readTreeObject(repoRoot, branchHead, path45);
56425
56485
  if (!baseCommit || !branchCommit) return false;
56426
- return isSubmoduleFastForward(pathResolve2(repoRoot, path44), baseCommit, branchCommit);
56486
+ return isSubmoduleFastForward(pathResolve2(repoRoot, path45), baseCommit, branchCommit);
56427
56487
  });
56428
56488
  }
56429
56489
  function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
56430
- const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path44) => {
56431
- const baseCommit = readTreeObject(repoRoot, baseHead, path44);
56432
- const branchCommit = readTreeObject(repoRoot, branchHead, path44);
56433
- const submoduleRepoPath = pathResolve2(repoRoot, path44);
56490
+ const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path45) => {
56491
+ const baseCommit = readTreeObject(repoRoot, baseHead, path45);
56492
+ const branchCommit = readTreeObject(repoRoot, branchHead, path45);
56493
+ const submoduleRepoPath = pathResolve2(repoRoot, path45);
56434
56494
  const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
56435
- return { path: path44, baseCommit, branchCommit, fastForward };
56495
+ return { path: path45, baseCommit, branchCommit, fastForward };
56436
56496
  });
56437
56497
  if (changedGitlinks.length === 0) {
56438
56498
  return { trivial: false, reason: "no_changed_gitlinks", gitlinks: changedGitlinks };
@@ -56483,7 +56543,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
56483
56543
  maxBuffer: 1024 * 1024
56484
56544
  }).trim();
56485
56545
  if (!tree) return void 0;
56486
- const updates = paths.map((path44) => `160000 commit ${placeholderCommit} ${path44}`).join("\n");
56546
+ const updates = paths.map((path45) => `160000 commit ${placeholderCommit} ${path45}`).join("\n");
56487
56547
  if (!updates) return tree;
56488
56548
  const tmpIndex = pathJoin2(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
56489
56549
  const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
@@ -56501,7 +56561,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
56501
56561
  return newTree || void 0;
56502
56562
  } finally {
56503
56563
  try {
56504
- fs30.rmSync(tmpIndex, { force: true });
56564
+ fs31.rmSync(tmpIndex, { force: true });
56505
56565
  } catch {
56506
56566
  }
56507
56567
  }
@@ -56576,7 +56636,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
56576
56636
  return newTree || void 0;
56577
56637
  } finally {
56578
56638
  try {
56579
- fs30.rmSync(tmpIndex, { force: true });
56639
+ fs31.rmSync(tmpIndex, { force: true });
56580
56640
  } catch {
56581
56641
  }
56582
56642
  }
@@ -56586,7 +56646,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
56586
56646
  }
56587
56647
  async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
56588
56648
  const startedAt = Date.now();
56589
- const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path44) => !(options.submoduleIgnorePaths || []).includes(path44));
56649
+ const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path45) => !(options.submoduleIgnorePaths || []).includes(path45));
56590
56650
  const preStatus = await getGitRepoStatus(repoRoot, {
56591
56651
  includeSubmodules: true,
56592
56652
  submoduleIgnorePaths: options.submoduleIgnorePaths,
@@ -56633,7 +56693,7 @@ async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, cur
56633
56693
  changedGitlinkPaths,
56634
56694
  outOfSyncPaths,
56635
56695
  updatedPaths: updatePaths,
56636
- verifiedPaths: updatePaths.filter((path44) => !remaining.some((submodule) => submodule.path === path44)),
56696
+ verifiedPaths: updatePaths.filter((path45) => !remaining.some((submodule) => submodule.path === path45)),
56637
56697
  durationMs: Date.now() - startedAt,
56638
56698
  command: `git ${commandArgs.join(" ")}`,
56639
56699
  stdout: truncateValidationOutput(result.stdout),
@@ -56688,7 +56748,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
56688
56748
  return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
56689
56749
  };
56690
56750
  const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
56691
- if (!fs30.existsSync(worktreeSubmodulePath)) return false;
56751
+ if (!fs31.existsSync(worktreeSubmodulePath)) return false;
56692
56752
  try {
56693
56753
  await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
56694
56754
  } catch {
@@ -56712,7 +56772,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
56712
56772
  };
56713
56773
  let submoduleDefaultBranch = "main";
56714
56774
  try {
56715
- if (!fs30.existsSync(submodulePath)) {
56775
+ if (!fs31.existsSync(submodulePath)) {
56716
56776
  entry.error = `Submodule checkout missing at ${gitlink.path}`;
56717
56777
  entry.publishRequired = true;
56718
56778
  if (options.allowAutoPublishSubmoduleMainCommits === true) {
@@ -56954,9 +57014,9 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
56954
57014
  return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
56955
57015
  };
56956
57016
  const dependenciesLikelyMissing = (cwd) => {
56957
- if (!fs30.existsSync(pathJoin2(cwd, "package.json"))) return false;
56958
- if (fs30.existsSync(pathJoin2(cwd, "node_modules"))) return false;
56959
- return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs30.existsSync(pathJoin2(cwd, lock)));
57017
+ if (!fs31.existsSync(pathJoin2(cwd, "package.json"))) return false;
57018
+ if (fs31.existsSync(pathJoin2(cwd, "node_modules"))) return false;
57019
+ return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs31.existsSync(pathJoin2(cwd, lock)));
56960
57020
  };
56961
57021
  if (runLegacyBootstrapCommands) {
56962
57022
  summary.bootstrap = { stage: "legacy" };
@@ -58372,7 +58432,7 @@ async function startMeshRefineJob(self, meshId, nodeId, args) {
58372
58432
  // src/commands/router-worktree-cleanup.ts
58373
58433
  init_logger();
58374
58434
  init_dist();
58375
- import * as fs31 from "fs";
58435
+ import * as fs32 from "fs";
58376
58436
  import { resolve as pathResolve3 } from "path";
58377
58437
  init_repo_mesh_types();
58378
58438
  function sessionMatchesMeshNode(self, record, node, nodeId, sessionIds) {
@@ -58385,14 +58445,14 @@ function sessionMatchesMeshNode(self, record, node, nodeId, sessionIds) {
58385
58445
  return false;
58386
58446
  }
58387
58447
  async function bestEffortRemoveWorktreeDir(self, dir) {
58388
- if (!dir || !fs31.existsSync(dir)) return { removed: true, residue: false };
58448
+ if (!dir || !fs32.existsSync(dir)) return { removed: true, residue: false };
58389
58449
  const sleep3 = (ms) => new Promise((resolve25) => setTimeout(resolve25, ms));
58390
58450
  const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
58391
58451
  let lastErr;
58392
58452
  for (let attempt = 0; attempt < 4; attempt++) {
58393
58453
  try {
58394
- fs31.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
58395
- if (!fs31.existsSync(dir)) return { removed: true, residue: false };
58454
+ fs32.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
58455
+ if (!fs32.existsSync(dir)) return { removed: true, residue: false };
58396
58456
  lastErr = new Error("directory still present after rmSync");
58397
58457
  } catch (e) {
58398
58458
  lastErr = e;
@@ -58403,7 +58463,7 @@ async function bestEffortRemoveWorktreeDir(self, dir) {
58403
58463
  }
58404
58464
  await sleep3(150 * (attempt + 1));
58405
58465
  }
58406
- return fs31.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
58466
+ return fs32.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
58407
58467
  }
58408
58468
  async function precheckLocalWorktreeRemovable(self, args) {
58409
58469
  const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
@@ -58416,10 +58476,10 @@ async function precheckLocalWorktreeRemovable(self, args) {
58416
58476
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
58417
58477
  };
58418
58478
  }
58419
- if (!fs31.existsSync(workspace)) return { ok: true };
58479
+ if (!fs32.existsSync(workspace)) return { ok: true };
58420
58480
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
58421
58481
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
58422
- if (!repoRoot || !fs31.existsSync(repoRoot)) {
58482
+ if (!repoRoot || !fs32.existsSync(repoRoot)) {
58423
58483
  return {
58424
58484
  ok: false,
58425
58485
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -58439,7 +58499,7 @@ async function precheckLocalWorktreeRemovable(self, args) {
58439
58499
  const normalizePath = (value) => {
58440
58500
  const resolved = pathResolve3(value);
58441
58501
  try {
58442
- return fs31.realpathSync(resolved);
58502
+ return fs32.realpathSync(resolved);
58443
58503
  } catch {
58444
58504
  return resolved;
58445
58505
  }
@@ -58501,13 +58561,13 @@ async function cleanupLocalWorktreeNode(self, args) {
58501
58561
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
58502
58562
  };
58503
58563
  }
58504
- const worktreeExists = fs31.existsSync(workspace);
58564
+ const worktreeExists = fs32.existsSync(workspace);
58505
58565
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
58506
58566
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
58507
58567
  if (!worktreeExists) {
58508
58568
  return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
58509
58569
  }
58510
- if (!repoRoot || !fs31.existsSync(repoRoot)) {
58570
+ if (!repoRoot || !fs32.existsSync(repoRoot)) {
58511
58571
  return {
58512
58572
  success: false,
58513
58573
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -58527,7 +58587,7 @@ async function cleanupLocalWorktreeNode(self, args) {
58527
58587
  const normalizePath = (value) => {
58528
58588
  const resolved = pathResolve3(value);
58529
58589
  try {
58530
- return fs31.realpathSync(resolved);
58590
+ return fs32.realpathSync(resolved);
58531
58591
  } catch {
58532
58592
  return resolved;
58533
58593
  }
@@ -59161,7 +59221,7 @@ init_logger();
59161
59221
  import * as yaml5 from "js-yaml";
59162
59222
  import { homedir as homedir26 } from "os";
59163
59223
  import { join as pathJoin3, resolve as pathResolve4 } from "path";
59164
- import * as fs32 from "fs";
59224
+ import * as fs33 from "fs";
59165
59225
  function loadYamlModule() {
59166
59226
  return yaml5;
59167
59227
  }
@@ -59185,9 +59245,9 @@ function resolveHermesUserHome() {
59185
59245
  function loadHermesCoordinatorBaseConfig(targetConfigPath) {
59186
59246
  const sourceHome = resolveHermesUserHome();
59187
59247
  const sourceConfigPath = pathJoin3(sourceHome, "config.yaml");
59188
- if (!fs32.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
59248
+ if (!fs33.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
59189
59249
  if (pathResolve4(sourceConfigPath) === pathResolve4(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
59190
- const parsed = parseMeshCoordinatorMcpConfig(fs32.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
59250
+ const parsed = parseMeshCoordinatorMcpConfig(fs33.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
59191
59251
  const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
59192
59252
  return { config: baseConfig, sourceHome, sourceConfigPath };
59193
59253
  }
@@ -59224,9 +59284,9 @@ function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
59224
59284
  for (const fileName of [".env", "auth.json"]) {
59225
59285
  const sourcePath = pathJoin3(sourceHome, fileName);
59226
59286
  const targetPath = pathJoin3(targetHome, fileName);
59227
- if (!fs32.existsSync(sourcePath)) continue;
59287
+ if (!fs33.existsSync(sourcePath)) continue;
59228
59288
  try {
59229
- fs32.copyFileSync(sourcePath, targetPath);
59289
+ fs33.copyFileSync(sourcePath, targetPath);
59230
59290
  } catch (error) {
59231
59291
  LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
59232
59292
  }
@@ -59618,7 +59678,7 @@ var DaemonCommandRouter = class {
59618
59678
  const nodeId = readInlineMeshNodeId(node);
59619
59679
  if (!nodeId || !tombstones.has(nodeId)) return true;
59620
59680
  const workspace = readStringValue(node?.workspace);
59621
- if (workspace && fs33.existsSync(workspace)) {
59681
+ if (workspace && fs34.existsSync(workspace)) {
59622
59682
  tombstones.delete(nodeId);
59623
59683
  return true;
59624
59684
  }
@@ -61537,12 +61597,12 @@ init_io_contracts();
61537
61597
  init_chat_message_normalization();
61538
61598
 
61539
61599
  // src/providers/version-archive.ts
61540
- import * as fs34 from "fs";
61541
- import * as path38 from "path";
61542
- import * as os28 from "os";
61600
+ import * as fs35 from "fs";
61601
+ import * as path39 from "path";
61602
+ import * as os29 from "os";
61543
61603
  import { platform as platform8 } from "os";
61544
61604
  import { exec as exec5 } from "child_process";
61545
- var ARCHIVE_PATH = path38.join(os28.homedir(), ".adhdev", "version-history.json");
61605
+ var ARCHIVE_PATH = path39.join(os29.homedir(), ".adhdev", "version-history.json");
61546
61606
  var MAX_ENTRIES_PER_PROVIDER = 20;
61547
61607
  var VersionArchive = class {
61548
61608
  history = {};
@@ -61551,8 +61611,8 @@ var VersionArchive = class {
61551
61611
  }
61552
61612
  load() {
61553
61613
  try {
61554
- if (fs34.existsSync(ARCHIVE_PATH)) {
61555
- this.history = JSON.parse(fs34.readFileSync(ARCHIVE_PATH, "utf-8"));
61614
+ if (fs35.existsSync(ARCHIVE_PATH)) {
61615
+ this.history = JSON.parse(fs35.readFileSync(ARCHIVE_PATH, "utf-8"));
61556
61616
  }
61557
61617
  } catch {
61558
61618
  this.history = {};
@@ -61589,8 +61649,8 @@ var VersionArchive = class {
61589
61649
  }
61590
61650
  save() {
61591
61651
  try {
61592
- fs34.mkdirSync(path38.dirname(ARCHIVE_PATH), { recursive: true });
61593
- fs34.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
61652
+ fs35.mkdirSync(path39.dirname(ARCHIVE_PATH), { recursive: true });
61653
+ fs35.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
61594
61654
  } catch {
61595
61655
  }
61596
61656
  }
@@ -61613,10 +61673,10 @@ function findBinary2(name) {
61613
61673
  for (const p of paths) {
61614
61674
  if (!p) continue;
61615
61675
  for (const ext of exes) {
61616
- const fullPath = path38.join(p, name + ext);
61676
+ const fullPath = path39.join(p, name + ext);
61617
61677
  try {
61618
- if (fs34.existsSync(fullPath)) {
61619
- const stat2 = fs34.statSync(fullPath);
61678
+ if (fs35.existsSync(fullPath)) {
61679
+ const stat2 = fs35.statSync(fullPath);
61620
61680
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
61621
61681
  return fullPath;
61622
61682
  }
@@ -61661,19 +61721,19 @@ async function getVersion(binary, versionCommand) {
61661
61721
  function checkPathExists2(paths) {
61662
61722
  for (const p of paths) {
61663
61723
  if (p.includes("*")) {
61664
- const home = os28.homedir();
61665
- const resolved = p.replace(/\*/g, home.split(path38.sep).pop() || "");
61666
- if (fs34.existsSync(resolved)) return resolved;
61724
+ const home = os29.homedir();
61725
+ const resolved = p.replace(/\*/g, home.split(path39.sep).pop() || "");
61726
+ if (fs35.existsSync(resolved)) return resolved;
61667
61727
  } else {
61668
- if (fs34.existsSync(p)) return p;
61728
+ if (fs35.existsSync(p)) return p;
61669
61729
  }
61670
61730
  }
61671
61731
  return null;
61672
61732
  }
61673
61733
  async function getMacAppVersion(appPath) {
61674
61734
  if (platform8() !== "darwin" || !appPath.endsWith(".app")) return null;
61675
- const plistPath = path38.join(appPath, "Contents", "Info.plist");
61676
- if (!fs34.existsSync(plistPath)) return null;
61735
+ const plistPath = path39.join(appPath, "Contents", "Info.plist");
61736
+ if (!fs35.existsSync(plistPath)) return null;
61677
61737
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
61678
61738
  return raw || null;
61679
61739
  }
@@ -61699,8 +61759,8 @@ async function detectAllVersions(loader, archive) {
61699
61759
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
61700
61760
  let resolvedBin = cliBin;
61701
61761
  if (!resolvedBin && appPath && currentOs === "darwin") {
61702
- const bundled = path38.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
61703
- if (provider.cli && fs34.existsSync(bundled)) resolvedBin = bundled;
61762
+ const bundled = path39.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
61763
+ if (provider.cli && fs35.existsSync(bundled)) resolvedBin = bundled;
61704
61764
  }
61705
61765
  info.installed = !!(appPath || resolvedBin);
61706
61766
  info.path = appPath || null;
@@ -61748,8 +61808,8 @@ async function detectAllVersions(loader, archive) {
61748
61808
 
61749
61809
  // src/daemon/dev-server.ts
61750
61810
  import * as http2 from "http";
61751
- import * as fs38 from "fs";
61752
- import * as path42 from "path";
61811
+ import * as fs39 from "fs";
61812
+ import * as path43 from "path";
61753
61813
  init_config();
61754
61814
 
61755
61815
  // src/daemon/scaffold-template.ts
@@ -62101,8 +62161,8 @@ init_builders();
62101
62161
 
62102
62162
  // src/daemon/dev-cdp-handlers.ts
62103
62163
  init_logger();
62104
- import * as fs35 from "fs";
62105
- import * as path39 from "path";
62164
+ import * as fs36 from "fs";
62165
+ import * as path40 from "path";
62106
62166
  async function handleCdpEvaluate(ctx, req, res) {
62107
62167
  const body = await ctx.readBody(req);
62108
62168
  const { expression, timeout, ideType } = body;
@@ -62280,18 +62340,18 @@ async function handleScriptHints(ctx, type, _req, res) {
62280
62340
  return;
62281
62341
  }
62282
62342
  let scriptsPath = "";
62283
- const directScripts = path39.join(dir, "scripts.js");
62284
- if (fs35.existsSync(directScripts)) {
62343
+ const directScripts = path40.join(dir, "scripts.js");
62344
+ if (fs36.existsSync(directScripts)) {
62285
62345
  scriptsPath = directScripts;
62286
62346
  } else {
62287
- const scriptsDir = path39.join(dir, "scripts");
62288
- if (fs35.existsSync(scriptsDir)) {
62289
- const versions = fs35.readdirSync(scriptsDir).filter((d) => {
62290
- return fs35.statSync(path39.join(scriptsDir, d)).isDirectory();
62347
+ const scriptsDir = path40.join(dir, "scripts");
62348
+ if (fs36.existsSync(scriptsDir)) {
62349
+ const versions = fs36.readdirSync(scriptsDir).filter((d) => {
62350
+ return fs36.statSync(path40.join(scriptsDir, d)).isDirectory();
62291
62351
  }).sort().reverse();
62292
62352
  for (const ver of versions) {
62293
- const p = path39.join(scriptsDir, ver, "scripts.js");
62294
- if (fs35.existsSync(p)) {
62353
+ const p = path40.join(scriptsDir, ver, "scripts.js");
62354
+ if (fs36.existsSync(p)) {
62295
62355
  scriptsPath = p;
62296
62356
  break;
62297
62357
  }
@@ -62303,7 +62363,7 @@ async function handleScriptHints(ctx, type, _req, res) {
62303
62363
  return;
62304
62364
  }
62305
62365
  try {
62306
- const source = fs35.readFileSync(scriptsPath, "utf-8");
62366
+ const source = fs36.readFileSync(scriptsPath, "utf-8");
62307
62367
  const hints = {};
62308
62368
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
62309
62369
  let match;
@@ -63118,8 +63178,8 @@ async function handleDomContext(ctx, type, req, res) {
63118
63178
  }
63119
63179
 
63120
63180
  // src/daemon/dev-cli-debug.ts
63121
- import * as fs36 from "fs";
63122
- import * as path40 from "path";
63181
+ import * as fs37 from "fs";
63182
+ import * as path41 from "path";
63123
63183
  function slugifyFixtureName(value) {
63124
63184
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
63125
63185
  return normalized || `fixture-${Date.now()}`;
@@ -63129,15 +63189,15 @@ function getCliFixtureDir(ctx, type) {
63129
63189
  if (!providerDir) {
63130
63190
  throw new Error(`Provider directory not found for '${type}'`);
63131
63191
  }
63132
- return path40.join(providerDir, "fixtures");
63192
+ return path41.join(providerDir, "fixtures");
63133
63193
  }
63134
63194
  function readCliFixture(ctx, type, name) {
63135
63195
  const fixtureDir = getCliFixtureDir(ctx, type);
63136
- const filePath = path40.join(fixtureDir, `${name}.json`);
63137
- if (!fs36.existsSync(filePath)) {
63196
+ const filePath = path41.join(fixtureDir, `${name}.json`);
63197
+ if (!fs37.existsSync(filePath)) {
63138
63198
  throw new Error(`Fixture not found: ${filePath}`);
63139
63199
  }
63140
- return JSON.parse(fs36.readFileSync(filePath, "utf-8"));
63200
+ return JSON.parse(fs37.readFileSync(filePath, "utf-8"));
63141
63201
  }
63142
63202
  function getExerciseTranscriptText(result) {
63143
63203
  const parts = [];
@@ -63882,7 +63942,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
63882
63942
  return;
63883
63943
  }
63884
63944
  const fixtureDir = getCliFixtureDir(ctx, type);
63885
- fs36.mkdirSync(fixtureDir, { recursive: true });
63945
+ fs37.mkdirSync(fixtureDir, { recursive: true });
63886
63946
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
63887
63947
  const result = await runCliExerciseInternal(ctx, { ...request, type });
63888
63948
  const fixture = {
@@ -63909,8 +63969,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
63909
63969
  },
63910
63970
  notes: typeof body?.notes === "string" ? body.notes : void 0
63911
63971
  };
63912
- const filePath = path40.join(fixtureDir, `${name}.json`);
63913
- fs36.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
63972
+ const filePath = path41.join(fixtureDir, `${name}.json`);
63973
+ fs37.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
63914
63974
  ctx.json(res, 200, {
63915
63975
  saved: true,
63916
63976
  name,
@@ -63928,14 +63988,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
63928
63988
  async function handleCliFixtureList(ctx, type, _req, res) {
63929
63989
  try {
63930
63990
  const fixtureDir = getCliFixtureDir(ctx, type);
63931
- if (!fs36.existsSync(fixtureDir)) {
63991
+ if (!fs37.existsSync(fixtureDir)) {
63932
63992
  ctx.json(res, 200, { fixtures: [], count: 0 });
63933
63993
  return;
63934
63994
  }
63935
- const fixtures = fs36.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
63936
- const fullPath = path40.join(fixtureDir, file);
63995
+ const fixtures = fs37.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
63996
+ const fullPath = path41.join(fixtureDir, file);
63937
63997
  try {
63938
- const raw = JSON.parse(fs36.readFileSync(fullPath, "utf-8"));
63998
+ const raw = JSON.parse(fs37.readFileSync(fullPath, "utf-8"));
63939
63999
  return {
63940
64000
  name: raw.name || file.replace(/\.json$/i, ""),
63941
64001
  path: fullPath,
@@ -64068,9 +64128,9 @@ async function handleCliRaw(ctx, req, res) {
64068
64128
  }
64069
64129
 
64070
64130
  // src/daemon/dev-auto-implement.ts
64071
- import * as fs37 from "fs";
64072
- import * as path41 from "path";
64073
- import * as os29 from "os";
64131
+ import * as fs38 from "fs";
64132
+ import * as path42 from "path";
64133
+ import * as os30 from "os";
64074
64134
  import { DEFAULT_SESSION_HOST_COLS as DEFAULT_SESSION_HOST_COLS7, DEFAULT_SESSION_HOST_ROWS as DEFAULT_SESSION_HOST_ROWS7 } from "@adhdev/session-host-core";
64075
64135
  function getAutoImplPid(ctx) {
64076
64136
  const pid = ctx.autoImplProcess?.pid;
@@ -64117,38 +64177,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
64117
64177
  return fallback?.type || null;
64118
64178
  }
64119
64179
  function getLatestScriptVersionDir(scriptsDir) {
64120
- if (!fs37.existsSync(scriptsDir)) return null;
64121
- const versions = fs37.readdirSync(scriptsDir).filter((d) => {
64180
+ if (!fs38.existsSync(scriptsDir)) return null;
64181
+ const versions = fs38.readdirSync(scriptsDir).filter((d) => {
64122
64182
  try {
64123
- return fs37.statSync(path41.join(scriptsDir, d)).isDirectory();
64183
+ return fs38.statSync(path42.join(scriptsDir, d)).isDirectory();
64124
64184
  } catch {
64125
64185
  return false;
64126
64186
  }
64127
64187
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
64128
64188
  if (versions.length === 0) return null;
64129
- return path41.join(scriptsDir, versions[0]);
64189
+ return path42.join(scriptsDir, versions[0]);
64130
64190
  }
64131
64191
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
64132
- const canonicalUserDir = path41.resolve(ctx.providerLoader.getUserProviderDir(category, type));
64133
- const desiredDir = requestedDir ? path41.resolve(requestedDir) : canonicalUserDir;
64134
- const upstreamRoot = path41.resolve(ctx.providerLoader.getUpstreamDir());
64135
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path41.sep}`)) {
64192
+ const canonicalUserDir = path42.resolve(ctx.providerLoader.getUserProviderDir(category, type));
64193
+ const desiredDir = requestedDir ? path42.resolve(requestedDir) : canonicalUserDir;
64194
+ const upstreamRoot = path42.resolve(ctx.providerLoader.getUpstreamDir());
64195
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path42.sep}`)) {
64136
64196
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
64137
64197
  }
64138
- if (path41.basename(desiredDir) !== type) {
64198
+ if (path42.basename(desiredDir) !== type) {
64139
64199
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
64140
64200
  }
64141
64201
  const sourceDir = ctx.findProviderDir(type);
64142
64202
  if (!sourceDir) {
64143
64203
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
64144
64204
  }
64145
- if (!fs37.existsSync(desiredDir)) {
64146
- fs37.mkdirSync(path41.dirname(desiredDir), { recursive: true });
64147
- fs37.cpSync(sourceDir, desiredDir, { recursive: true });
64205
+ if (!fs38.existsSync(desiredDir)) {
64206
+ fs38.mkdirSync(path42.dirname(desiredDir), { recursive: true });
64207
+ fs38.cpSync(sourceDir, desiredDir, { recursive: true });
64148
64208
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
64149
64209
  }
64150
- const providerJson = path41.join(desiredDir, "provider.json");
64151
- if (!fs37.existsSync(providerJson)) {
64210
+ const providerJson = path42.join(desiredDir, "provider.json");
64211
+ if (!fs38.existsSync(providerJson)) {
64152
64212
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
64153
64213
  }
64154
64214
  return { dir: desiredDir };
@@ -64156,15 +64216,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
64156
64216
  function loadAutoImplReferenceScripts(ctx, referenceType) {
64157
64217
  if (!referenceType) return {};
64158
64218
  const refDir = ctx.findProviderDir(referenceType);
64159
- if (!refDir || !fs37.existsSync(refDir)) return {};
64219
+ if (!refDir || !fs38.existsSync(refDir)) return {};
64160
64220
  const referenceScripts = {};
64161
- const scriptsDir = path41.join(refDir, "scripts");
64221
+ const scriptsDir = path42.join(refDir, "scripts");
64162
64222
  const latestDir = getLatestScriptVersionDir(scriptsDir);
64163
64223
  if (!latestDir) return referenceScripts;
64164
- for (const file of fs37.readdirSync(latestDir)) {
64224
+ for (const file of fs38.readdirSync(latestDir)) {
64165
64225
  if (!file.endsWith(".js")) continue;
64166
64226
  try {
64167
- referenceScripts[file] = fs37.readFileSync(path41.join(latestDir, file), "utf-8");
64227
+ referenceScripts[file] = fs38.readFileSync(path42.join(latestDir, file), "utf-8");
64168
64228
  } catch {
64169
64229
  }
64170
64230
  }
@@ -64272,16 +64332,16 @@ async function handleAutoImplement(ctx, type, req, res) {
64272
64332
  });
64273
64333
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
64274
64334
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
64275
- const tmpDir = path41.join(os29.tmpdir(), "adhdev-autoimpl");
64276
- if (!fs37.existsSync(tmpDir)) fs37.mkdirSync(tmpDir, { recursive: true });
64277
- const promptFile = path41.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
64278
- fs37.writeFileSync(promptFile, prompt, "utf-8");
64335
+ const tmpDir = path42.join(os30.tmpdir(), "adhdev-autoimpl");
64336
+ if (!fs38.existsSync(tmpDir)) fs38.mkdirSync(tmpDir, { recursive: true });
64337
+ const promptFile = path42.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
64338
+ fs38.writeFileSync(promptFile, prompt, "utf-8");
64279
64339
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
64280
64340
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
64281
64341
  const spawn5 = agentProvider?.spawn;
64282
64342
  if (!spawn5?.command) {
64283
64343
  try {
64284
- fs37.unlinkSync(promptFile);
64344
+ fs38.unlinkSync(promptFile);
64285
64345
  } catch {
64286
64346
  }
64287
64347
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -64383,7 +64443,7 @@ async function handleAutoImplement(ctx, type, req, res) {
64383
64443
  } catch {
64384
64444
  }
64385
64445
  try {
64386
- fs37.unlinkSync(promptFile);
64446
+ fs38.unlinkSync(promptFile);
64387
64447
  } catch {
64388
64448
  }
64389
64449
  ctx.log(`Auto-implement (ACP) ${success ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -64427,7 +64487,7 @@ async function handleAutoImplement(ctx, type, req, res) {
64427
64487
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
64428
64488
  const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
64429
64489
  let shellCmd;
64430
- const isWin = os29.platform() === "win32";
64490
+ const isWin = os30.platform() === "win32";
64431
64491
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
64432
64492
  const promptMode = autoImpl?.promptMode ?? "stdin";
64433
64493
  const extraArgs = autoImpl?.extraArgs ?? [];
@@ -64466,7 +64526,7 @@ async function handleAutoImplement(ctx, type, req, res) {
64466
64526
  try {
64467
64527
  const pty = __require("node-pty");
64468
64528
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
64469
- const isWin2 = os29.platform() === "win32";
64529
+ const isWin2 = os30.platform() === "win32";
64470
64530
  child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
64471
64531
  name: "xterm-256color",
64472
64532
  cols: DEFAULT_SESSION_HOST_COLS7,
@@ -64609,7 +64669,7 @@ async function handleAutoImplement(ctx, type, req, res) {
64609
64669
  }
64610
64670
  });
64611
64671
  try {
64612
- fs37.unlinkSync(promptFile);
64672
+ fs38.unlinkSync(promptFile);
64613
64673
  } catch {
64614
64674
  }
64615
64675
  ctx.log(`Auto-implement ${success ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -64706,7 +64766,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
64706
64766
  setMode: "set_mode.js"
64707
64767
  };
64708
64768
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
64709
- const scriptsDir = path41.join(providerDir, "scripts");
64769
+ const scriptsDir = path42.join(providerDir, "scripts");
64710
64770
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
64711
64771
  if (latestScriptsDir) {
64712
64772
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -64714,10 +64774,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
64714
64774
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
64715
64775
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
64716
64776
  lines.push("");
64717
- for (const file of fs37.readdirSync(latestScriptsDir)) {
64777
+ for (const file of fs38.readdirSync(latestScriptsDir)) {
64718
64778
  if (file.endsWith(".js") && targetFileNames.has(file)) {
64719
64779
  try {
64720
- const content = fs37.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
64780
+ const content = fs38.readFileSync(path42.join(latestScriptsDir, file), "utf-8");
64721
64781
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
64722
64782
  lines.push("```javascript");
64723
64783
  lines.push(content);
@@ -64727,14 +64787,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
64727
64787
  }
64728
64788
  }
64729
64789
  }
64730
- const refFiles = fs37.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
64790
+ const refFiles = fs38.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
64731
64791
  if (refFiles.length > 0) {
64732
64792
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
64733
64793
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
64734
64794
  lines.push("");
64735
64795
  for (const file of refFiles) {
64736
64796
  try {
64737
- const content = fs37.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
64797
+ const content = fs38.readFileSync(path42.join(latestScriptsDir, file), "utf-8");
64738
64798
  lines.push(`### \`${file}\` \u{1F512}`);
64739
64799
  lines.push("```javascript");
64740
64800
  lines.push(content);
@@ -64775,11 +64835,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
64775
64835
  lines.push("");
64776
64836
  }
64777
64837
  }
64778
- const docsDir = path41.join(providerDir, "../../docs");
64838
+ const docsDir = path42.join(providerDir, "../../docs");
64779
64839
  const loadGuide = (name) => {
64780
64840
  try {
64781
- const p = path41.join(docsDir, name);
64782
- if (fs37.existsSync(p)) return fs37.readFileSync(p, "utf-8");
64841
+ const p = path42.join(docsDir, name);
64842
+ if (fs38.existsSync(p)) return fs38.readFileSync(p, "utf-8");
64783
64843
  } catch {
64784
64844
  }
64785
64845
  return null;
@@ -65015,7 +65075,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
65015
65075
  parseApproval: "parse_approval.js"
65016
65076
  };
65017
65077
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
65018
- const scriptsDir = path41.join(providerDir, "scripts");
65078
+ const scriptsDir = path42.join(providerDir, "scripts");
65019
65079
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
65020
65080
  if (latestScriptsDir) {
65021
65081
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -65023,11 +65083,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
65023
65083
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
65024
65084
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
65025
65085
  lines.push("");
65026
- for (const file of fs37.readdirSync(latestScriptsDir)) {
65086
+ for (const file of fs38.readdirSync(latestScriptsDir)) {
65027
65087
  if (!file.endsWith(".js")) continue;
65028
65088
  if (!targetFileNames.has(file)) continue;
65029
65089
  try {
65030
- const content = fs37.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
65090
+ const content = fs38.readFileSync(path42.join(latestScriptsDir, file), "utf-8");
65031
65091
  lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
65032
65092
  lines.push("```javascript");
65033
65093
  lines.push(content);
@@ -65036,14 +65096,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
65036
65096
  } catch {
65037
65097
  }
65038
65098
  }
65039
- const refFiles = fs37.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
65099
+ const refFiles = fs38.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
65040
65100
  if (refFiles.length > 0) {
65041
65101
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
65042
65102
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
65043
65103
  lines.push("");
65044
65104
  for (const file of refFiles) {
65045
65105
  try {
65046
- const content = fs37.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
65106
+ const content = fs38.readFileSync(path42.join(latestScriptsDir, file), "utf-8");
65047
65107
  lines.push(`### \`${file}\` \u{1F512}`);
65048
65108
  lines.push("```javascript");
65049
65109
  lines.push(content);
@@ -65076,11 +65136,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
65076
65136
  lines.push("");
65077
65137
  }
65078
65138
  }
65079
- const docsDir = path41.join(providerDir, "../../docs");
65139
+ const docsDir = path42.join(providerDir, "../../docs");
65080
65140
  const loadGuide = (name) => {
65081
65141
  try {
65082
- const p = path41.join(docsDir, name);
65083
- if (fs37.existsSync(p)) return fs37.readFileSync(p, "utf-8");
65142
+ const p = path42.join(docsDir, name);
65143
+ if (fs38.existsSync(p)) return fs38.readFileSync(p, "utf-8");
65084
65144
  } catch {
65085
65145
  }
65086
65146
  return null;
@@ -65526,8 +65586,8 @@ var DevServer = class _DevServer {
65526
65586
  }
65527
65587
  getEndpointList() {
65528
65588
  return this.routes.map((r) => {
65529
- const path44 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
65530
- return `${r.method.padEnd(5)} ${path44}`;
65589
+ const path45 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
65590
+ return `${r.method.padEnd(5)} ${path45}`;
65531
65591
  });
65532
65592
  }
65533
65593
  async start(port = DEV_SERVER_PORT) {
@@ -65815,12 +65875,12 @@ var DevServer = class _DevServer {
65815
65875
  // ─── DevConsole SPA ───
65816
65876
  getConsoleDistDir() {
65817
65877
  const candidates = [
65818
- path42.resolve(__dirname, "../../web-devconsole/dist"),
65819
- path42.resolve(__dirname, "../../../web-devconsole/dist"),
65820
- path42.join(process.cwd(), "packages/web-devconsole/dist")
65878
+ path43.resolve(__dirname, "../../web-devconsole/dist"),
65879
+ path43.resolve(__dirname, "../../../web-devconsole/dist"),
65880
+ path43.join(process.cwd(), "packages/web-devconsole/dist")
65821
65881
  ];
65822
65882
  for (const dir of candidates) {
65823
- if (fs38.existsSync(path42.join(dir, "index.html"))) return dir;
65883
+ if (fs39.existsSync(path43.join(dir, "index.html"))) return dir;
65824
65884
  }
65825
65885
  return null;
65826
65886
  }
@@ -65830,9 +65890,9 @@ var DevServer = class _DevServer {
65830
65890
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
65831
65891
  return;
65832
65892
  }
65833
- const htmlPath = path42.join(distDir, "index.html");
65893
+ const htmlPath = path43.join(distDir, "index.html");
65834
65894
  try {
65835
- const html = fs38.readFileSync(htmlPath, "utf-8");
65895
+ const html = fs39.readFileSync(htmlPath, "utf-8");
65836
65896
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
65837
65897
  res.end(html);
65838
65898
  } catch (e) {
@@ -65855,15 +65915,15 @@ var DevServer = class _DevServer {
65855
65915
  this.json(res, 404, { error: "Not found" });
65856
65916
  return;
65857
65917
  }
65858
- const safePath = path42.normalize(pathname).replace(/^\.\.\//, "");
65859
- const filePath = path42.join(distDir, safePath);
65918
+ const safePath = path43.normalize(pathname).replace(/^\.\.\//, "");
65919
+ const filePath = path43.join(distDir, safePath);
65860
65920
  if (!filePath.startsWith(distDir)) {
65861
65921
  this.json(res, 403, { error: "Forbidden" });
65862
65922
  return;
65863
65923
  }
65864
65924
  try {
65865
- const content = fs38.readFileSync(filePath);
65866
- const ext = path42.extname(filePath);
65925
+ const content = fs39.readFileSync(filePath);
65926
+ const ext = path43.extname(filePath);
65867
65927
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
65868
65928
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
65869
65929
  res.end(content);
@@ -65971,14 +66031,14 @@ var DevServer = class _DevServer {
65971
66031
  const files = [];
65972
66032
  const scan = (d, prefix) => {
65973
66033
  try {
65974
- for (const entry of fs38.readdirSync(d, { withFileTypes: true })) {
66034
+ for (const entry of fs39.readdirSync(d, { withFileTypes: true })) {
65975
66035
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
65976
66036
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
65977
66037
  if (entry.isDirectory()) {
65978
66038
  files.push({ path: rel, size: 0, type: "dir" });
65979
- scan(path42.join(d, entry.name), rel);
66039
+ scan(path43.join(d, entry.name), rel);
65980
66040
  } else {
65981
- const stat2 = fs38.statSync(path42.join(d, entry.name));
66041
+ const stat2 = fs39.statSync(path43.join(d, entry.name));
65982
66042
  files.push({ path: rel, size: stat2.size, type: "file" });
65983
66043
  }
65984
66044
  }
@@ -66001,16 +66061,16 @@ var DevServer = class _DevServer {
66001
66061
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
66002
66062
  return;
66003
66063
  }
66004
- const fullPath = path42.resolve(dir, path42.normalize(filePath));
66064
+ const fullPath = path43.resolve(dir, path43.normalize(filePath));
66005
66065
  if (!fullPath.startsWith(dir)) {
66006
66066
  this.json(res, 403, { error: "Forbidden" });
66007
66067
  return;
66008
66068
  }
66009
- if (!fs38.existsSync(fullPath) || fs38.statSync(fullPath).isDirectory()) {
66069
+ if (!fs39.existsSync(fullPath) || fs39.statSync(fullPath).isDirectory()) {
66010
66070
  this.json(res, 404, { error: `File not found: ${filePath}` });
66011
66071
  return;
66012
66072
  }
66013
- const content = fs38.readFileSync(fullPath, "utf-8");
66073
+ const content = fs39.readFileSync(fullPath, "utf-8");
66014
66074
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
66015
66075
  }
66016
66076
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -66026,15 +66086,15 @@ var DevServer = class _DevServer {
66026
66086
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
66027
66087
  return;
66028
66088
  }
66029
- const fullPath = path42.resolve(dir, path42.normalize(filePath));
66089
+ const fullPath = path43.resolve(dir, path43.normalize(filePath));
66030
66090
  if (!fullPath.startsWith(dir)) {
66031
66091
  this.json(res, 403, { error: "Forbidden" });
66032
66092
  return;
66033
66093
  }
66034
66094
  try {
66035
- if (fs38.existsSync(fullPath)) fs38.copyFileSync(fullPath, fullPath + ".bak");
66036
- fs38.mkdirSync(path42.dirname(fullPath), { recursive: true });
66037
- fs38.writeFileSync(fullPath, content, "utf-8");
66095
+ if (fs39.existsSync(fullPath)) fs39.copyFileSync(fullPath, fullPath + ".bak");
66096
+ fs39.mkdirSync(path43.dirname(fullPath), { recursive: true });
66097
+ fs39.writeFileSync(fullPath, content, "utf-8");
66038
66098
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
66039
66099
  this.providerLoader.reload();
66040
66100
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -66050,9 +66110,9 @@ var DevServer = class _DevServer {
66050
66110
  return;
66051
66111
  }
66052
66112
  for (const name of ["scripts.js", "provider.json"]) {
66053
- const p = path42.join(dir, name);
66054
- if (fs38.existsSync(p)) {
66055
- const source = fs38.readFileSync(p, "utf-8");
66113
+ const p = path43.join(dir, name);
66114
+ if (fs39.existsSync(p)) {
66115
+ const source = fs39.readFileSync(p, "utf-8");
66056
66116
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
66057
66117
  return;
66058
66118
  }
@@ -66071,11 +66131,11 @@ var DevServer = class _DevServer {
66071
66131
  this.json(res, 404, { error: `Provider not found: ${type}` });
66072
66132
  return;
66073
66133
  }
66074
- const target = fs38.existsSync(path42.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
66075
- const targetPath = path42.join(dir, target);
66134
+ const target = fs39.existsSync(path43.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
66135
+ const targetPath = path43.join(dir, target);
66076
66136
  try {
66077
- if (fs38.existsSync(targetPath)) fs38.copyFileSync(targetPath, targetPath + ".bak");
66078
- fs38.writeFileSync(targetPath, source, "utf-8");
66137
+ if (fs39.existsSync(targetPath)) fs39.copyFileSync(targetPath, targetPath + ".bak");
66138
+ fs39.writeFileSync(targetPath, source, "utf-8");
66079
66139
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
66080
66140
  this.providerLoader.reload();
66081
66141
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -66219,21 +66279,21 @@ var DevServer = class _DevServer {
66219
66279
  }
66220
66280
  let targetDir;
66221
66281
  targetDir = this.providerLoader.getUserProviderDir(category, type);
66222
- const jsonPath = path42.join(targetDir, "provider.json");
66223
- if (fs38.existsSync(jsonPath)) {
66282
+ const jsonPath = path43.join(targetDir, "provider.json");
66283
+ if (fs39.existsSync(jsonPath)) {
66224
66284
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
66225
66285
  return;
66226
66286
  }
66227
66287
  try {
66228
66288
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version, osPaths, processNames });
66229
- fs38.mkdirSync(targetDir, { recursive: true });
66230
- fs38.writeFileSync(jsonPath, result["provider.json"], "utf-8");
66289
+ fs39.mkdirSync(targetDir, { recursive: true });
66290
+ fs39.writeFileSync(jsonPath, result["provider.json"], "utf-8");
66231
66291
  const createdFiles = ["provider.json"];
66232
66292
  if (result.files) {
66233
66293
  for (const [relPath, content] of Object.entries(result.files)) {
66234
- const fullPath = path42.join(targetDir, relPath);
66235
- fs38.mkdirSync(path42.dirname(fullPath), { recursive: true });
66236
- fs38.writeFileSync(fullPath, content, "utf-8");
66294
+ const fullPath = path43.join(targetDir, relPath);
66295
+ fs39.mkdirSync(path43.dirname(fullPath), { recursive: true });
66296
+ fs39.writeFileSync(fullPath, content, "utf-8");
66237
66297
  createdFiles.push(relPath);
66238
66298
  }
66239
66299
  }
@@ -66282,38 +66342,38 @@ var DevServer = class _DevServer {
66282
66342
  }
66283
66343
  // ─── Phase 2: Auto-Implement Backend ───
66284
66344
  getLatestScriptVersionDir(scriptsDir) {
66285
- if (!fs38.existsSync(scriptsDir)) return null;
66286
- const versions = fs38.readdirSync(scriptsDir).filter((d) => {
66345
+ if (!fs39.existsSync(scriptsDir)) return null;
66346
+ const versions = fs39.readdirSync(scriptsDir).filter((d) => {
66287
66347
  try {
66288
- return fs38.statSync(path42.join(scriptsDir, d)).isDirectory();
66348
+ return fs39.statSync(path43.join(scriptsDir, d)).isDirectory();
66289
66349
  } catch {
66290
66350
  return false;
66291
66351
  }
66292
66352
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
66293
66353
  if (versions.length === 0) return null;
66294
- return path42.join(scriptsDir, versions[0]);
66354
+ return path43.join(scriptsDir, versions[0]);
66295
66355
  }
66296
66356
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
66297
- const canonicalUserDir = path42.resolve(this.providerLoader.getUserProviderDir(category, type));
66298
- const desiredDir = requestedDir ? path42.resolve(requestedDir) : canonicalUserDir;
66299
- const upstreamRoot = path42.resolve(this.providerLoader.getUpstreamDir());
66300
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path42.sep}`)) {
66357
+ const canonicalUserDir = path43.resolve(this.providerLoader.getUserProviderDir(category, type));
66358
+ const desiredDir = requestedDir ? path43.resolve(requestedDir) : canonicalUserDir;
66359
+ const upstreamRoot = path43.resolve(this.providerLoader.getUpstreamDir());
66360
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path43.sep}`)) {
66301
66361
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
66302
66362
  }
66303
- if (path42.basename(desiredDir) !== type) {
66363
+ if (path43.basename(desiredDir) !== type) {
66304
66364
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
66305
66365
  }
66306
66366
  const sourceDir = this.findProviderDir(type);
66307
66367
  if (!sourceDir) {
66308
66368
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
66309
66369
  }
66310
- if (!fs38.existsSync(desiredDir)) {
66311
- fs38.mkdirSync(path42.dirname(desiredDir), { recursive: true });
66312
- fs38.cpSync(sourceDir, desiredDir, { recursive: true });
66370
+ if (!fs39.existsSync(desiredDir)) {
66371
+ fs39.mkdirSync(path43.dirname(desiredDir), { recursive: true });
66372
+ fs39.cpSync(sourceDir, desiredDir, { recursive: true });
66313
66373
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
66314
66374
  }
66315
- const providerJson = path42.join(desiredDir, "provider.json");
66316
- if (!fs38.existsSync(providerJson)) {
66375
+ const providerJson = path43.join(desiredDir, "provider.json");
66376
+ if (!fs39.existsSync(providerJson)) {
66317
66377
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
66318
66378
  }
66319
66379
  return { dir: desiredDir };
@@ -67162,9 +67222,9 @@ async function listHostedCliRuntimes(endpoint) {
67162
67222
 
67163
67223
  // src/session-host/managed-host.ts
67164
67224
  import { execFileSync as execFileSync9, spawn as spawn4 } from "child_process";
67165
- import * as fs39 from "fs";
67166
- import * as os30 from "os";
67167
- import * as path43 from "path";
67225
+ import * as fs40 from "fs";
67226
+ import * as os31 from "os";
67227
+ import * as path44 from "path";
67168
67228
  import {
67169
67229
  getDefaultSessionHostEndpoint as getDefaultSessionHostEndpoint2,
67170
67230
  sanitizeSpawnEnv as sanitizeSpawnEnv2
@@ -67182,24 +67242,24 @@ function createManagedSessionHost(options) {
67182
67242
  }
67183
67243
  function resolveEntry() {
67184
67244
  const packagedCandidates = [
67185
- path43.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
67186
- path43.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
67245
+ path44.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
67246
+ path44.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
67187
67247
  ];
67188
67248
  for (const candidate of packagedCandidates) {
67189
- if (fs39.existsSync(candidate)) {
67249
+ if (fs40.existsSync(candidate)) {
67190
67250
  return candidate;
67191
67251
  }
67192
67252
  }
67193
67253
  return __require.resolve("@adhdev/session-host-daemon");
67194
67254
  }
67195
67255
  function getPidFile() {
67196
- return path43.join(os30.homedir(), ".adhdev", `${appName}-session-host.pid`);
67256
+ return path44.join(os31.homedir(), ".adhdev", `${appName}-session-host.pid`);
67197
67257
  }
67198
67258
  function getPid() {
67199
67259
  try {
67200
67260
  const pidFile = getPidFile();
67201
- if (!fs39.existsSync(pidFile)) return null;
67202
- const pid = Number.parseInt(fs39.readFileSync(pidFile, "utf8").trim(), 10);
67261
+ if (!fs40.existsSync(pidFile)) return null;
67262
+ const pid = Number.parseInt(fs40.readFileSync(pidFile, "utf8").trim(), 10);
67203
67263
  return Number.isFinite(pid) ? pid : null;
67204
67264
  } catch {
67205
67265
  return null;
@@ -67224,9 +67284,9 @@ function createManagedSessionHost(options) {
67224
67284
  let stdio = "ignore";
67225
67285
  let logFd = null;
67226
67286
  if (options.spawnStdio === "logfile") {
67227
- const logDir = path43.join(os30.homedir(), ".adhdev", "logs");
67228
- fs39.mkdirSync(logDir, { recursive: true });
67229
- logFd = fs39.openSync(path43.join(logDir, "session-host.log"), "a");
67287
+ const logDir = path44.join(os31.homedir(), ".adhdev", "logs");
67288
+ fs40.mkdirSync(logDir, { recursive: true });
67289
+ logFd = fs40.openSync(path44.join(logDir, "session-host.log"), "a");
67230
67290
  stdio = ["ignore", logFd, logFd];
67231
67291
  }
67232
67292
  const child = spawn4(process.execPath, [entry], {
@@ -67238,7 +67298,7 @@ function createManagedSessionHost(options) {
67238
67298
  child.unref();
67239
67299
  if (logFd !== null) {
67240
67300
  try {
67241
- fs39.closeSync(logFd);
67301
+ fs40.closeSync(logFd);
67242
67302
  } catch {
67243
67303
  }
67244
67304
  }
@@ -67247,8 +67307,8 @@ function createManagedSessionHost(options) {
67247
67307
  let stopped = false;
67248
67308
  const pidFile = getPidFile();
67249
67309
  try {
67250
- if (fs39.existsSync(pidFile)) {
67251
- const pid = Number.parseInt(fs39.readFileSync(pidFile, "utf8").trim(), 10);
67310
+ if (fs40.existsSync(pidFile)) {
67311
+ const pid = Number.parseInt(fs40.readFileSync(pidFile, "utf8").trim(), 10);
67252
67312
  if (Number.isFinite(pid) && pid !== process.pid && isManagedPid(pid)) {
67253
67313
  stopped = killPid2(pid) || stopped;
67254
67314
  }
@@ -67256,7 +67316,7 @@ function createManagedSessionHost(options) {
67256
67316
  } catch {
67257
67317
  } finally {
67258
67318
  try {
67259
- fs39.unlinkSync(pidFile);
67319
+ fs40.unlinkSync(pidFile);
67260
67320
  } catch {
67261
67321
  }
67262
67322
  }
@@ -67442,8 +67502,8 @@ async function installExtension(ide, extension) {
67442
67502
  const res = await fetch(extension.vsixUrl);
67443
67503
  if (res.ok) {
67444
67504
  const buffer = Buffer.from(await res.arrayBuffer());
67445
- const fs40 = await import("fs");
67446
- fs40.writeFileSync(vsixPath, buffer);
67505
+ const fs41 = await import("fs");
67506
+ fs41.writeFileSync(vsixPath, buffer);
67447
67507
  return new Promise((resolve25) => {
67448
67508
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
67449
67509
  exec6(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
@@ -68042,7 +68102,7 @@ import { dirname as dirname15, resolve as resolve23 } from "path";
68042
68102
 
68043
68103
  // src/providers/sdk/v1/validators/taint.ts
68044
68104
  import { readFileSync as readFileSync41, existsSync as existsSync54 } from "fs";
68045
- import { resolve as resolve24, dirname as dirname16, join as join49 } from "path";
68105
+ import { resolve as resolve24, dirname as dirname16, join as join50 } from "path";
68046
68106
 
68047
68107
  // src/providers/sdk/v1/validators/index.ts
68048
68108
  init_manifest();