@adhdev/daemon-standalone 0.9.82-rc.165 → 0.9.82-rc.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -34851,8 +34851,8 @@ var require_dist3 = __commonJS({
34851
34851
  return String(value).replace(/\r\n/g, "\n");
34852
34852
  }
34853
34853
  function isPathInside(parent, child) {
34854
- const relative4 = path5.relative(path5.resolve(parent), path5.resolve(child));
34855
- return relative4 === "" || !relative4.startsWith("..") && !path5.isAbsolute(relative4);
34854
+ const relative5 = path5.relative(path5.resolve(parent), path5.resolve(child));
34855
+ return relative5 === "" || !relative5.startsWith("..") && !path5.isAbsolute(relative5);
34856
34856
  }
34857
34857
  async function validateWorkspace(workspace) {
34858
34858
  if (typeof workspace !== "string" || workspace.length === 0 || workspace.includes("\0")) {
@@ -35529,10 +35529,10 @@ ${error48.message || ""}`;
35529
35529
  return (0, import_path22.join)(getConfigDir(), "meshes.json");
35530
35530
  }
35531
35531
  function loadMeshConfig() {
35532
- const path39 = getMeshConfigPath();
35533
- if (!(0, import_fs2.existsSync)(path39)) return { meshes: [] };
35532
+ const path40 = getMeshConfigPath();
35533
+ if (!(0, import_fs2.existsSync)(path40)) return { meshes: [] };
35534
35534
  try {
35535
- const raw = JSON.parse((0, import_fs2.readFileSync)(path39, "utf-8"));
35535
+ const raw = JSON.parse((0, import_fs2.readFileSync)(path40, "utf-8"));
35536
35536
  if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
35537
35537
  return raw;
35538
35538
  } catch {
@@ -35540,16 +35540,16 @@ ${error48.message || ""}`;
35540
35540
  }
35541
35541
  }
35542
35542
  function saveMeshConfig(config2) {
35543
- const path39 = getMeshConfigPath();
35544
- (0, import_fs2.writeFileSync)(path39, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
35543
+ const path40 = getMeshConfigPath();
35544
+ (0, import_fs2.writeFileSync)(path40, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
35545
35545
  }
35546
35546
  function normalizeRepoIdentity(remoteUrl) {
35547
35547
  let identity = remoteUrl.trim();
35548
35548
  if (identity.startsWith("http://") || identity.startsWith("https://")) {
35549
35549
  try {
35550
35550
  const url2 = new URL(identity);
35551
- const path39 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
35552
- return `${url2.hostname}/${path39}`;
35551
+ const path40 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
35552
+ return `${url2.hostname}/${path40}`;
35553
35553
  } catch {
35554
35554
  }
35555
35555
  }
@@ -36498,8 +36498,8 @@ Follow these recovery rules:
36498
36498
  }
36499
36499
  const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
36500
36500
  if (mcpConfig.mode === "auto_import") {
36501
- const path39 = mcpConfig.path?.trim();
36502
- if (!path39) {
36501
+ const path40 = mcpConfig.path?.trim();
36502
+ if (!path40) {
36503
36503
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
36504
36504
  }
36505
36505
  const mcpServer = resolveAdhdevMcpServerLaunch({
@@ -36517,7 +36517,7 @@ Follow these recovery rules:
36517
36517
  return {
36518
36518
  kind: "auto_import",
36519
36519
  serverName,
36520
- configPath: resolveMcpConfigPath(path39, workspace),
36520
+ configPath: resolveMcpConfigPath(path40, workspace),
36521
36521
  configFormat: mcpConfig.format,
36522
36522
  mcpServer
36523
36523
  };
@@ -36674,8 +36674,8 @@ ${rendered}`, "utf-8");
36674
36674
  const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
36675
36675
  if (!remaining.trim()) {
36676
36676
  try {
36677
- const fs27 = require("fs");
36678
- fs27.unlinkSync(filePath);
36677
+ const fs28 = require("fs");
36678
+ fs28.unlinkSync(filePath);
36679
36679
  } catch {
36680
36680
  }
36681
36681
  } else {
@@ -36818,10 +36818,10 @@ ${rendered}`, "utf-8");
36818
36818
  }
36819
36819
  }
36820
36820
  function readArchivedCounts(meshId) {
36821
- const path39 = getArchivedCountsPath(meshId);
36822
- if (!(0, import_fs6.existsSync)(path39)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
36821
+ const path40 = getArchivedCountsPath(meshId);
36822
+ if (!(0, import_fs6.existsSync)(path40)) return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
36823
36823
  try {
36824
- return JSON.parse((0, import_fs6.readFileSync)(path39, "utf-8"));
36824
+ return JSON.parse((0, import_fs6.readFileSync)(path40, "utf-8"));
36825
36825
  } catch {
36826
36826
  return { taskCompleted: 0, taskFailed: 0, taskStalled: 0, recoveryAttempted: 0, totalArchived: 0, lastArchivedAt: "" };
36827
36827
  }
@@ -37493,10 +37493,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
37493
37493
  this.migratedMeshIds.add(meshId);
37494
37494
  const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
37495
37495
  if (count.count > 0) return;
37496
- const path39 = legacyQueuePath(meshId);
37497
- if (!(0, import_fs7.existsSync)(path39)) return;
37496
+ const path40 = legacyQueuePath(meshId);
37497
+ if (!(0, import_fs7.existsSync)(path40)) return;
37498
37498
  try {
37499
- const entries = JSON.parse((0, import_fs7.readFileSync)(path39, "utf-8"));
37499
+ const entries = JSON.parse((0, import_fs7.readFileSync)(path40, "utf-8"));
37500
37500
  if (!Array.isArray(entries)) return;
37501
37501
  const insert = this.db.prepare(`
37502
37502
  INSERT OR REPLACE INTO mesh_queue (
@@ -38207,10 +38207,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
38207
38207
  if (!meshId) return [];
38208
38208
  const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
38209
38209
  const events = [];
38210
- for (const path39 of paths) {
38211
- if (!(0, import_fs9.existsSync)(path39)) continue;
38210
+ for (const path40 of paths) {
38211
+ if (!(0, import_fs9.existsSync)(path40)) continue;
38212
38212
  try {
38213
- const raw = (0, import_fs9.readFileSync)(path39, "utf-8");
38213
+ const raw = (0, import_fs9.readFileSync)(path40, "utf-8");
38214
38214
  const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
38215
38215
  try {
38216
38216
  return [JSON.parse(line)];
@@ -38218,7 +38218,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
38218
38218
  return [];
38219
38219
  }
38220
38220
  });
38221
- const filtered = coordinatorDaemonId && path39 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || e.targetCoordinatorDaemonId === coordinatorDaemonId) : parsed;
38221
+ const filtered = coordinatorDaemonId && path40 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || e.targetCoordinatorDaemonId === coordinatorDaemonId) : parsed;
38222
38222
  events.push(...filtered);
38223
38223
  } catch {
38224
38224
  }
@@ -38287,13 +38287,13 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
38287
38287
  ...backfilled
38288
38288
  ];
38289
38289
  }
38290
- function trimPendingEventsIfNeeded(path39) {
38290
+ function trimPendingEventsIfNeeded(path40) {
38291
38291
  try {
38292
- if (!(0, import_fs9.existsSync)(path39)) return;
38293
- if ((0, import_fs9.statSync)(path39).size <= MAX_PENDING_EVENTS_BYTES) return;
38294
- const lines = (0, import_fs9.readFileSync)(path39, "utf-8").split("\n").filter(Boolean);
38292
+ if (!(0, import_fs9.existsSync)(path40)) return;
38293
+ if ((0, import_fs9.statSync)(path40).size <= MAX_PENDING_EVENTS_BYTES) return;
38294
+ const lines = (0, import_fs9.readFileSync)(path40, "utf-8").split("\n").filter(Boolean);
38295
38295
  if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
38296
- (0, import_fs9.writeFileSync)(path39, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
38296
+ (0, import_fs9.writeFileSync)(path40, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
38297
38297
  } catch {
38298
38298
  }
38299
38299
  }
@@ -38307,19 +38307,19 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
38307
38307
  LOG2.info("MeshEvents", `Suppressed duplicate pending ${event.event} for mesh ${event.meshId}`);
38308
38308
  return true;
38309
38309
  }
38310
- const path39 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
38311
- trimPendingEventsIfNeeded(path39);
38312
- (0, import_fs9.appendFileSync)(path39, JSON.stringify(event) + "\n", "utf-8");
38310
+ const path40 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
38311
+ trimPendingEventsIfNeeded(path40);
38312
+ (0, import_fs9.appendFileSync)(path40, JSON.stringify(event) + "\n", "utf-8");
38313
38313
  return true;
38314
38314
  } catch (e) {
38315
38315
  LOG2.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
38316
38316
  return false;
38317
38317
  }
38318
38318
  }
38319
- function atomicDrainFile(path39) {
38320
- const tmpPath = `${path39}.draining`;
38319
+ function atomicDrainFile(path40) {
38320
+ const tmpPath = `${path40}.draining`;
38321
38321
  try {
38322
- (0, import_fs9.renameSync)(path39, tmpPath);
38322
+ (0, import_fs9.renameSync)(path40, tmpPath);
38323
38323
  } catch {
38324
38324
  return null;
38325
38325
  }
@@ -38342,8 +38342,8 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
38342
38342
  if (!meshId) return [];
38343
38343
  const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
38344
38344
  const all = [];
38345
- for (const path39 of paths) {
38346
- const content = atomicDrainFile(path39);
38345
+ for (const path40 of paths) {
38346
+ const content = atomicDrainFile(path40);
38347
38347
  if (!content) continue;
38348
38348
  const parsed = content.split("\n").filter(Boolean).flatMap((line) => {
38349
38349
  try {
@@ -38352,7 +38352,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
38352
38352
  return [];
38353
38353
  }
38354
38354
  });
38355
- const filtered = coordinatorDaemonId && path39 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || e.targetCoordinatorDaemonId === coordinatorDaemonId) : parsed;
38355
+ const filtered = coordinatorDaemonId && path40 === getPendingEventsPath(meshId) ? parsed.filter((e) => !e.targetCoordinatorDaemonId || e.targetCoordinatorDaemonId === coordinatorDaemonId) : parsed;
38356
38356
  all.push(...filtered);
38357
38357
  }
38358
38358
  if (all.length === 0) return [];
@@ -38365,9 +38365,9 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
38365
38365
  function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
38366
38366
  if (!meshId) return;
38367
38367
  const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
38368
- for (const path39 of paths) {
38369
- if ((0, import_fs9.existsSync)(path39)) try {
38370
- (0, import_fs9.unlinkSync)(path39);
38368
+ for (const path40 of paths) {
38369
+ if ((0, import_fs9.existsSync)(path40)) try {
38370
+ (0, import_fs9.unlinkSync)(path40);
38371
38371
  } catch {
38372
38372
  }
38373
38373
  }
@@ -39508,6 +39508,54 @@ Next step: ${nextStep}`;
39508
39508
  currentConfig = { ...DEFAULT_CONFIG2 };
39509
39509
  }
39510
39510
  });
39511
+ var provider_trust_exports = {};
39512
+ __export2(provider_trust_exports, {
39513
+ classifyTrust: () => classifyTrust,
39514
+ describeTrust: () => describeTrust,
39515
+ inspectManifestShape: () => inspectManifestShape,
39516
+ requiresConfirmation: () => requiresConfirmation
39517
+ });
39518
+ function inspectManifestShape(manifest) {
39519
+ const hasTui = !!manifest.tui && typeof manifest.tui === "object" && Object.keys(manifest.tui).length > 0;
39520
+ const hasOverrides = !!manifest.overrides && typeof manifest.overrides === "object" && !Array.isArray(manifest.overrides) && Object.keys(manifest.overrides).length > 0;
39521
+ const compat = Array.isArray(manifest.compatibility) ? manifest.compatibility : [];
39522
+ const compatHasScriptDir = compat.some((entry) => typeof entry?.scriptDir === "string");
39523
+ const hasScriptDir = compatHasScriptDir || typeof manifest.defaultScriptDir === "string";
39524
+ return { hasTui, hasOverrides, hasScriptDir };
39525
+ }
39526
+ function classifyTrust(layer, shape) {
39527
+ const isSpecOnly = !shape.hasTui && !shape.hasOverrides && !shape.hasScriptDir;
39528
+ switch (layer) {
39529
+ case "user":
39530
+ return "user-custom";
39531
+ case "upstream":
39532
+ return isSpecOnly ? "trusted" : "trusted-with-scripts";
39533
+ case "external":
39534
+ return isSpecOnly ? "external-safe" : "external-untrusted";
39535
+ }
39536
+ }
39537
+ function requiresConfirmation(trust) {
39538
+ return trust === "external-untrusted";
39539
+ }
39540
+ function describeTrust(trust) {
39541
+ switch (trust) {
39542
+ case "user-custom":
39543
+ return "Hand-authored in ~/.adhdev/providers/. Runs your own code.";
39544
+ case "trusted":
39545
+ return "Official, declarative-only manifest from the ADHDev registry.";
39546
+ case "trusted-with-scripts":
39547
+ return "Official manifest from the ADHDev registry. Ships JavaScript hooks executed by the daemon.";
39548
+ case "external-safe":
39549
+ return "Manifest from a 3rd-party git source you added. Declarative-only \u2014 the daemon never runs JS from this source.";
39550
+ case "external-untrusted":
39551
+ return "Manifest from a 3rd-party git source you added. Ships JavaScript that the daemon will execute. Treat as untrusted code \u2014 review the source before enabling.";
39552
+ }
39553
+ }
39554
+ var init_provider_trust = __esm2({
39555
+ "src/providers/provider-trust.ts"() {
39556
+ "use strict";
39557
+ }
39558
+ });
39511
39559
  var provider_schema_default;
39512
39560
  var init_provider_schema = __esm2({
39513
39561
  "src/providers/sdk/v1/schemas/cli/provider.schema.json"() {
@@ -40008,7 +40056,7 @@ Next step: ${nextStep}`;
40008
40056
  return _cliValidator;
40009
40057
  }
40010
40058
  function formatIssue(err) {
40011
- const path39 = err.instancePath || "";
40059
+ const path40 = err.instancePath || "";
40012
40060
  const params = err.params;
40013
40061
  let message = err.message || "validation failed";
40014
40062
  let allowed;
@@ -40026,7 +40074,7 @@ Next step: ${nextStep}`;
40026
40074
  } else if (err.keyword === "type") {
40027
40075
  message = `must be ${params.type}`;
40028
40076
  }
40029
- return { path: path39, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
40077
+ return { path: path40, keyword: err.keyword, message, ...allowed !== void 0 ? { allowed } : {} };
40030
40078
  }
40031
40079
  function validateCliProviderManifest(manifest) {
40032
40080
  const validator = getCliValidator();
@@ -40055,6 +40103,158 @@ Next step: ${nextStep}`;
40055
40103
  _cliValidator = null;
40056
40104
  }
40057
40105
  });
40106
+ var external_sources_exports = {};
40107
+ __export2(external_sources_exports, {
40108
+ activeFilePath: () => activeFilePath,
40109
+ deriveSourceName: () => deriveSourceName,
40110
+ externalRoot: () => externalRoot,
40111
+ inventoryExternalSources: () => inventoryExternalSources,
40112
+ loadExternalSources: () => loadExternalSources,
40113
+ loadProvidersActive: () => loadProvidersActive,
40114
+ resolveActiveSource: () => resolveActiveSource,
40115
+ saveExternalSources: () => saveExternalSources,
40116
+ saveProvidersActive: () => saveProvidersActive,
40117
+ sourcesFilePath: () => sourcesFilePath,
40118
+ sourcesProviding: () => sourcesProviding
40119
+ });
40120
+ function adhdevDir() {
40121
+ return path15.join(os10.homedir(), ".adhdev");
40122
+ }
40123
+ function externalRoot() {
40124
+ return path15.join(adhdevDir(), "external");
40125
+ }
40126
+ function sourcesFilePath() {
40127
+ return path15.join(adhdevDir(), SOURCES_FILENAME);
40128
+ }
40129
+ function activeFilePath() {
40130
+ return path15.join(adhdevDir(), ACTIVE_FILENAME);
40131
+ }
40132
+ function ensureAdhdevDir() {
40133
+ const d = adhdevDir();
40134
+ if (!fs8.existsSync(d)) fs8.mkdirSync(d, { recursive: true });
40135
+ }
40136
+ function loadExternalSources() {
40137
+ const p = sourcesFilePath();
40138
+ if (!fs8.existsSync(p)) return { schema: 1, sources: [] };
40139
+ try {
40140
+ const raw = JSON.parse(fs8.readFileSync(p, "utf-8"));
40141
+ if (!raw || typeof raw !== "object") return { schema: 1, sources: [] };
40142
+ const sources = Array.isArray(raw.sources) ? raw.sources.filter(isValidSource) : [];
40143
+ return { schema: 1, sources };
40144
+ } catch {
40145
+ return { schema: 1, sources: [] };
40146
+ }
40147
+ }
40148
+ function saveExternalSources(file2) {
40149
+ ensureAdhdevDir();
40150
+ const tmp = sourcesFilePath() + ".tmp";
40151
+ fs8.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
40152
+ fs8.renameSync(tmp, sourcesFilePath());
40153
+ }
40154
+ function loadProvidersActive() {
40155
+ const p = activeFilePath();
40156
+ if (!fs8.existsSync(p)) return { schema: 1, active: {} };
40157
+ try {
40158
+ const raw = JSON.parse(fs8.readFileSync(p, "utf-8"));
40159
+ if (!raw || typeof raw !== "object") return { schema: 1, active: {} };
40160
+ const active = raw.active && typeof raw.active === "object" ? raw.active : {};
40161
+ return { schema: 1, active };
40162
+ } catch {
40163
+ return { schema: 1, active: {} };
40164
+ }
40165
+ }
40166
+ function saveProvidersActive(file2) {
40167
+ ensureAdhdevDir();
40168
+ const tmp = activeFilePath() + ".tmp";
40169
+ fs8.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n", "utf-8");
40170
+ fs8.renameSync(tmp, activeFilePath());
40171
+ }
40172
+ function isValidSource(x) {
40173
+ if (!x || typeof x !== "object") return false;
40174
+ const s = x;
40175
+ return typeof s.name === "string" && s.name.length > 0 && typeof s.url === "string" && s.url.length > 0 && typeof s.ref === "string" && s.ref.length > 0 && typeof s.addedAt === "string";
40176
+ }
40177
+ function deriveSourceName(url2) {
40178
+ const m = url2.match(/[/:]([^/:]+)\/([^/]+?)(?:\.git)?$/);
40179
+ if (!m) return "@source";
40180
+ const owner = m[1].toLowerCase().replace(/[^a-z0-9_-]/g, "-");
40181
+ const repo = m[2].toLowerCase().replace(/[^a-z0-9_-]/g, "-");
40182
+ return `@${owner}-${repo}`;
40183
+ }
40184
+ function inventoryExternalSources() {
40185
+ const root = externalRoot();
40186
+ if (!fs8.existsSync(root)) return [];
40187
+ const out = [];
40188
+ let entries;
40189
+ try {
40190
+ entries = fs8.readdirSync(root, { withFileTypes: true });
40191
+ } catch {
40192
+ return [];
40193
+ }
40194
+ for (const sourceEntry of entries) {
40195
+ if (!sourceEntry.isDirectory()) continue;
40196
+ const sourceName = sourceEntry.name;
40197
+ const sourceDir = path15.join(root, sourceName);
40198
+ const providers = {};
40199
+ let categoryEntries;
40200
+ try {
40201
+ categoryEntries = fs8.readdirSync(sourceDir, { withFileTypes: true });
40202
+ } catch {
40203
+ continue;
40204
+ }
40205
+ for (const categoryEntry of categoryEntries) {
40206
+ if (!categoryEntry.isDirectory()) continue;
40207
+ const category = categoryEntry.name;
40208
+ const categoryDir = path15.join(sourceDir, category);
40209
+ let typeEntries;
40210
+ try {
40211
+ typeEntries = fs8.readdirSync(categoryDir, { withFileTypes: true });
40212
+ } catch {
40213
+ continue;
40214
+ }
40215
+ const types = [];
40216
+ for (const typeEntry of typeEntries) {
40217
+ if (!typeEntry.isDirectory()) continue;
40218
+ const typeDir = path15.join(categoryDir, typeEntry.name);
40219
+ const hasV1 = fs8.existsSync(path15.join(typeDir, "provider.v1.json"));
40220
+ const hasV0 = fs8.existsSync(path15.join(typeDir, "provider.json"));
40221
+ if (hasV1 || hasV0) types.push(typeEntry.name);
40222
+ }
40223
+ if (types.length > 0) providers[category] = types;
40224
+ }
40225
+ out.push({ sourceName, providers });
40226
+ }
40227
+ return out;
40228
+ }
40229
+ function sourcesProviding(category, type) {
40230
+ const inventory = inventoryExternalSources();
40231
+ return inventory.filter((s) => (s.providers[category] || []).includes(type)).map((s) => s.sourceName);
40232
+ }
40233
+ function resolveActiveSource(category, type, activeFile) {
40234
+ const candidates = sourcesProviding(category, type);
40235
+ if (candidates.length === 0) return { source: null, ambiguous: false, candidates };
40236
+ if (candidates.length === 1) return { source: candidates[0], ambiguous: false, candidates };
40237
+ const explicit = (activeFile ?? loadProvidersActive()).active[type];
40238
+ if (explicit && candidates.includes(explicit)) {
40239
+ return { source: explicit, ambiguous: false, candidates };
40240
+ }
40241
+ return { source: candidates[0], ambiguous: true, candidates };
40242
+ }
40243
+ var fs8;
40244
+ var os10;
40245
+ var path15;
40246
+ var SOURCES_FILENAME;
40247
+ var ACTIVE_FILENAME;
40248
+ var init_external_sources = __esm2({
40249
+ "src/providers/external-sources.ts"() {
40250
+ "use strict";
40251
+ fs8 = __toESM2(require("fs"));
40252
+ os10 = __toESM2(require("os"));
40253
+ path15 = __toESM2(require("path"));
40254
+ SOURCES_FILENAME = "providers-sources.json";
40255
+ ACTIVE_FILENAME = "providers-active.json";
40256
+ }
40257
+ });
40058
40258
  function isModuleNotFoundError(error48, ref) {
40059
40259
  if (!(error48 instanceof Error)) return false;
40060
40260
  const message = error48.message || "";
@@ -40347,14 +40547,14 @@ Next step: ${nextStep}`;
40347
40547
  }
40348
40548
  return cachedPty;
40349
40549
  }
40350
- var os10;
40550
+ var os11;
40351
40551
  var cachedPty;
40352
40552
  var NodePtyRuntimeTransport;
40353
40553
  var NodePtyTransportFactory;
40354
40554
  var init_pty_transport = __esm2({
40355
40555
  "src/cli-adapters/pty-transport.ts"() {
40356
40556
  "use strict";
40357
- os10 = __toESM2(require("os"));
40557
+ os11 = __toESM2(require("os"));
40358
40558
  init_spawn_env();
40359
40559
  NodePtyRuntimeTransport = class {
40360
40560
  constructor(handle) {
@@ -40391,11 +40591,11 @@ Next step: ${nextStep}`;
40391
40591
  let cwd = options.cwd;
40392
40592
  if (cwd) {
40393
40593
  try {
40394
- const fs27 = require("fs");
40395
- const stat2 = fs27.statSync(cwd);
40396
- if (!stat2.isDirectory()) cwd = os10.homedir();
40594
+ const fs28 = require("fs");
40595
+ const stat2 = fs28.statSync(cwd);
40596
+ if (!stat2.isDirectory()) cwd = os11.homedir();
40397
40597
  } catch {
40398
- cwd = os10.homedir();
40598
+ cwd = os11.homedir();
40399
40599
  }
40400
40600
  }
40401
40601
  const handle = pty.spawn(command, args, {
@@ -40485,21 +40685,21 @@ Next step: ${nextStep}`;
40485
40685
  function findBinary(name) {
40486
40686
  const trimmed = String(name || "").trim();
40487
40687
  if (!trimmed) return trimmed;
40488
- const expanded = trimmed.startsWith("~") ? path15.join(os11.homedir(), trimmed.slice(1)) : trimmed;
40489
- if (path15.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
40490
- return path15.isAbsolute(expanded) ? expanded : path15.resolve(expanded);
40688
+ const expanded = trimmed.startsWith("~") ? path16.join(os12.homedir(), trimmed.slice(1)) : trimmed;
40689
+ if (path16.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
40690
+ return path16.isAbsolute(expanded) ? expanded : path16.resolve(expanded);
40491
40691
  }
40492
- const isWin = os11.platform() === "win32";
40493
- const paths = (process.env.PATH || "").split(path15.delimiter);
40692
+ const isWin = os12.platform() === "win32";
40693
+ const paths = (process.env.PATH || "").split(path16.delimiter);
40494
40694
  const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
40495
40695
  for (const p of paths) {
40496
40696
  if (!p) continue;
40497
40697
  for (const ext of exes) {
40498
- const fullPath = path15.join(p, trimmed + ext);
40698
+ const fullPath = path16.join(p, trimmed + ext);
40499
40699
  try {
40500
- const fs27 = require("fs");
40501
- if (fs27.existsSync(fullPath)) {
40502
- const stat2 = fs27.statSync(fullPath);
40700
+ const fs28 = require("fs");
40701
+ if (fs28.existsSync(fullPath)) {
40702
+ const stat2 = fs28.statSync(fullPath);
40503
40703
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
40504
40704
  return fullPath;
40505
40705
  }
@@ -40511,14 +40711,14 @@ Next step: ${nextStep}`;
40511
40711
  return isWin ? `${trimmed}.cmd` : trimmed;
40512
40712
  }
40513
40713
  function isScriptBinary(binaryPath) {
40514
- if (!path15.isAbsolute(binaryPath)) return false;
40714
+ if (!path16.isAbsolute(binaryPath)) return false;
40515
40715
  try {
40516
- const fs27 = require("fs");
40517
- const resolved = fs27.realpathSync(binaryPath);
40716
+ const fs28 = require("fs");
40717
+ const resolved = fs28.realpathSync(binaryPath);
40518
40718
  const head = Buffer.alloc(8);
40519
- const fd = fs27.openSync(resolved, "r");
40520
- fs27.readSync(fd, head, 0, 8, 0);
40521
- fs27.closeSync(fd);
40719
+ const fd = fs28.openSync(resolved, "r");
40720
+ fs28.readSync(fd, head, 0, 8, 0);
40721
+ fs28.closeSync(fd);
40522
40722
  let i = 0;
40523
40723
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
40524
40724
  return head[i] === 35 && head[i + 1] === 33;
@@ -40527,14 +40727,14 @@ Next step: ${nextStep}`;
40527
40727
  }
40528
40728
  }
40529
40729
  function looksLikeMachOOrElf(filePath) {
40530
- if (!path15.isAbsolute(filePath)) return false;
40730
+ if (!path16.isAbsolute(filePath)) return false;
40531
40731
  try {
40532
- const fs27 = require("fs");
40533
- const resolved = fs27.realpathSync(filePath);
40732
+ const fs28 = require("fs");
40733
+ const resolved = fs28.realpathSync(filePath);
40534
40734
  const buf = Buffer.alloc(8);
40535
- const fd = fs27.openSync(resolved, "r");
40536
- fs27.readSync(fd, buf, 0, 8, 0);
40537
- fs27.closeSync(fd);
40735
+ const fd = fs28.openSync(resolved, "r");
40736
+ fs28.readSync(fd, buf, 0, 8, 0);
40737
+ fs28.closeSync(fd);
40538
40738
  let i = 0;
40539
40739
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
40540
40740
  const b = buf.subarray(i);
@@ -40550,7 +40750,7 @@ Next step: ${nextStep}`;
40550
40750
  }
40551
40751
  function shSingleQuote(arg) {
40552
40752
  if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
40553
- if (os11.platform() === "win32") {
40753
+ if (os12.platform() === "win32") {
40554
40754
  return `"${arg.replace(/"/g, '""')}"`;
40555
40755
  }
40556
40756
  return `'${arg.replace(/'/g, `'\\''`)}'`;
@@ -40616,15 +40816,15 @@ Next step: ${nextStep}`;
40616
40816
  }
40617
40817
  };
40618
40818
  }
40619
- var os11;
40620
- var path15;
40819
+ var os12;
40820
+ var path16;
40621
40821
  var TerminalTranscriptAccumulator;
40622
40822
  var buildCliSpawnEnv;
40623
40823
  var init_provider_cli_shared = __esm2({
40624
40824
  "src/cli-adapters/provider-cli-shared.ts"() {
40625
40825
  "use strict";
40626
- os11 = __toESM2(require("os"));
40627
- path15 = __toESM2(require("path"));
40826
+ os12 = __toESM2(require("os"));
40827
+ path16 = __toESM2(require("path"));
40628
40828
  init_spawn_env();
40629
40829
  TerminalTranscriptAccumulator = class {
40630
40830
  lines = [[]];
@@ -42506,15 +42706,15 @@ ${cont}` : cont;
42506
42706
  const { spawn: spawnConfig } = provider;
42507
42707
  const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
42508
42708
  const binaryPath = findBinary(configuredCommand);
42509
- const isWin = os12.platform() === "win32";
42709
+ const isWin = os13.platform() === "win32";
42510
42710
  const allArgs = [...spawnConfig.args, ...extraArgs].map(
42511
42711
  (arg) => typeof arg === "string" ? arg.replace(/\{\{workingDir\}\}/g, workingDir) : arg
42512
42712
  );
42513
42713
  let shellCmd;
42514
42714
  let shellArgs;
42515
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path16.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
42715
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
42516
42716
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
42517
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path16.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
42717
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path17.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
42518
42718
  const useShell = isWin ? useShellWin : useShellUnix;
42519
42719
  if (useShell) {
42520
42720
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -42590,14 +42790,14 @@ ${cont}` : cont;
42590
42790
  }
42591
42791
  return "";
42592
42792
  }
42593
- var os12;
42594
- var path16;
42793
+ var os13;
42794
+ var path17;
42595
42795
  var import_session_host_core22;
42596
42796
  var init_provider_cli_runtime = __esm2({
42597
42797
  "src/cli-adapters/provider-cli-runtime.ts"() {
42598
42798
  "use strict";
42599
- os12 = __toESM2(require("os"));
42600
- path16 = __toESM2(require("path"));
42799
+ os13 = __toESM2(require("os"));
42800
+ path17 = __toESM2(require("path"));
42601
42801
  import_session_host_core22 = require_dist2();
42602
42802
  init_provider_cli_shared();
42603
42803
  }
@@ -42616,12 +42816,12 @@ ${cont}` : cont;
42616
42816
  if (current.length <= keepFromCurrent) return current + chunk;
42617
42817
  return current.slice(-keepFromCurrent) + chunk;
42618
42818
  }
42619
- var os13;
42819
+ var os14;
42620
42820
  var ProviderCliAdapter;
42621
42821
  var init_provider_cli_adapter = __esm2({
42622
42822
  "src/cli-adapters/provider-cli-adapter.ts"() {
42623
42823
  "use strict";
42624
- os13 = __toESM2(require("os"));
42824
+ os14 = __toESM2(require("os"));
42625
42825
  init_logger();
42626
42826
  init_debug_config();
42627
42827
  init_terminal_screen();
@@ -42642,7 +42842,7 @@ ${cont}` : cont;
42642
42842
  this.transportFactory = transportFactory;
42643
42843
  this.cliType = provider.type;
42644
42844
  this.cliName = provider.name;
42645
- this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os13.homedir()) : workingDir;
42845
+ this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os14.homedir()) : workingDir;
42646
42846
  const resolvedConfig = resolveCliAdapterConfig(provider);
42647
42847
  this.timeouts = resolvedConfig.timeouts;
42648
42848
  this.approvalKeys = resolvedConfig.approvalKeys;
@@ -44785,7 +44985,7 @@ ${lastSnapshot}`;
44785
44985
  function loadSpec(sourcePath) {
44786
44986
  let raw;
44787
44987
  try {
44788
- const text = fs8.readFileSync(sourcePath, "utf8");
44988
+ const text = fs9.readFileSync(sourcePath, "utf8");
44789
44989
  raw = JSON.parse(text);
44790
44990
  } catch (err) {
44791
44991
  return { ok: false, errors: [`Failed to read spec: ${err.message}`], sourcePath };
@@ -44861,18 +45061,18 @@ ${lastSnapshot}`;
44861
45061
  }
44862
45062
  }
44863
45063
  function resolveSpecPath(providerDir) {
44864
- return path17.join(providerDir, "spec.json");
45064
+ return path18.join(providerDir, "spec.json");
44865
45065
  }
44866
- var fs8;
44867
- var path17;
45066
+ var fs9;
45067
+ var path18;
44868
45068
  var import_ajv;
44869
45069
  var ajv;
44870
45070
  var validate;
44871
45071
  var init_loader = __esm2({
44872
45072
  "src/providers/spec/loader.ts"() {
44873
45073
  "use strict";
44874
- fs8 = __toESM2(require("fs"));
44875
- path17 = __toESM2(require("path"));
45074
+ fs9 = __toESM2(require("fs"));
45075
+ path18 = __toESM2(require("path"));
44876
45076
  import_ajv = __toESM2(require_ajv());
44877
45077
  init_schema_gen();
44878
45078
  ajv = new import_ajv.default({ allErrors: true, strict: false });
@@ -45026,7 +45226,7 @@ ${lastSnapshot}`;
45026
45226
  }
45027
45227
  function canonicalize(p) {
45028
45228
  try {
45029
- const resolved = path23.resolve(p);
45229
+ const resolved = path24.resolve(p);
45030
45230
  try {
45031
45231
  return nodeFs.realpathSync.native ? nodeFs.realpathSync.native(resolved) : nodeFs.realpathSync(resolved);
45032
45232
  } catch {
@@ -45046,7 +45246,7 @@ ${lastSnapshot}`;
45046
45246
  }
45047
45247
  for (const root of _gatedRoots) {
45048
45248
  if (normalized === root.rootPath) return root;
45049
- if (normalized.startsWith(root.rootPath + path23.sep)) return root;
45249
+ if (normalized.startsWith(root.rootPath + path24.sep)) return root;
45050
45250
  }
45051
45251
  return null;
45052
45252
  }
@@ -45065,16 +45265,16 @@ ${lastSnapshot}`;
45065
45265
  };
45066
45266
  }
45067
45267
  function gatedRequire(request, parent, isMain, gated, originalLoad) {
45068
- if (request.startsWith("./") || request.startsWith("../") || path23.isAbsolute(request)) {
45268
+ if (request.startsWith("./") || request.startsWith("../") || path24.isAbsolute(request)) {
45069
45269
  let resolved;
45070
45270
  try {
45071
- const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path23.join(gated.rootPath, "__entry__.js"));
45271
+ const callerRequire = parent?.filename ? (0, import_node_module2.createRequire)(parent.filename) : (0, import_node_module2.createRequire)(path24.join(gated.rootPath, "__entry__.js"));
45072
45272
  resolved = callerRequire.resolve(request);
45073
45273
  } catch {
45074
45274
  return originalLoad.call(this, request, parent, isMain);
45075
45275
  }
45076
45276
  const resolvedCanon = canonicalize(resolved) || resolved;
45077
- if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path23.sep))) {
45277
+ if (!(resolvedCanon === gated.rootPath || resolvedCanon.startsWith(gated.rootPath + path24.sep))) {
45078
45278
  denyRequire(request, parent, `relative path escapes provider root (resolved to ${resolvedCanon})`);
45079
45279
  }
45080
45280
  return originalLoad.call(this, request, parent, isMain);
@@ -45098,7 +45298,7 @@ ${lastSnapshot}`;
45098
45298
  err.callerFilename = caller;
45099
45299
  throw err;
45100
45300
  }
45101
- var path23;
45301
+ var path24;
45102
45302
  var import_node_module2;
45103
45303
  var nodeFs;
45104
45304
  var nodeChildProcess;
@@ -45119,7 +45319,7 @@ ${lastSnapshot}`;
45119
45319
  var init_require_whitelist = __esm2({
45120
45320
  "src/providers/sdk/v1/sandbox/require-whitelist.ts"() {
45121
45321
  "use strict";
45122
- path23 = __toESM2(require("path"));
45322
+ path24 = __toESM2(require("path"));
45123
45323
  import_node_module2 = require("module");
45124
45324
  nodeFs = __toESM2(require("fs"));
45125
45325
  nodeChildProcess = __toESM2(require("child_process"));
@@ -45227,7 +45427,7 @@ ${lastSnapshot}`;
45227
45427
  } else {
45228
45428
  let stat2 = null;
45229
45429
  try {
45230
- stat2 = fs12.statSync(resolved);
45430
+ stat2 = fs13.statSync(resolved);
45231
45431
  } catch {
45232
45432
  return null;
45233
45433
  }
@@ -45246,7 +45446,7 @@ ${lastSnapshot}`;
45246
45446
  const v = jsonPathGet(lines[0], src.session_id_path);
45247
45447
  if (typeof v === "string" && v) providerSessionId = v;
45248
45448
  } else if (src.session_id_from === "filename_uuid" || !src.session_id_from) {
45249
- const m = path24.basename(sourcePath).match(UUID_RE);
45449
+ const m = path25.basename(sourcePath).match(UUID_RE);
45250
45450
  if (m) providerSessionId = m[1];
45251
45451
  }
45252
45452
  const requested = input.providerSessionId || "";
@@ -45271,7 +45471,7 @@ ${lastSnapshot}`;
45271
45471
  function readJsonlLines(p) {
45272
45472
  let text;
45273
45473
  try {
45274
- text = fs12.readFileSync(p, "utf8");
45474
+ text = fs13.readFileSync(p, "utf8");
45275
45475
  } catch {
45276
45476
  return [];
45277
45477
  }
@@ -45288,7 +45488,7 @@ ${lastSnapshot}`;
45288
45488
  }
45289
45489
  function executeSqlite(src, input) {
45290
45490
  const resolved = expandPath2(src.path, input);
45291
- if (!resolved || !fs12.existsSync(resolved)) return null;
45491
+ if (!resolved || !fs13.existsSync(resolved)) return null;
45292
45492
  let Database;
45293
45493
  try {
45294
45494
  Database = require("better-sqlite3");
@@ -45347,19 +45547,19 @@ ${lastSnapshot}`;
45347
45547
  if (!template) return null;
45348
45548
  let out = template;
45349
45549
  if (out.startsWith("~/") || out === "~") {
45350
- out = path24.join(os17.homedir(), out.slice(2));
45550
+ out = path25.join(os18.homedir(), out.slice(2));
45351
45551
  }
45352
45552
  out = out.replace(/\$\{([A-Z_][A-Z0-9_]*)(?::-(.*?))?\}/g, (_m, name, fallback) => {
45353
45553
  const v = input.envOverrides?.[name] ?? process.env[name];
45354
45554
  return v != null && v !== "" ? v : fallback ?? "";
45355
45555
  });
45356
- if (out.startsWith("~/")) out = path24.join(os17.homedir(), out.slice(2));
45556
+ if (out.startsWith("~/")) out = path25.join(os18.homedir(), out.slice(2));
45357
45557
  const now = /* @__PURE__ */ new Date();
45358
45558
  const workspaceRaw = input.workspace ?? "";
45359
45559
  let workspaceResolved = workspaceRaw;
45360
45560
  if (workspaceRaw) {
45361
45561
  try {
45362
- workspaceResolved = fs12.realpathSync(workspaceRaw);
45562
+ workspaceResolved = fs13.realpathSync(workspaceRaw);
45363
45563
  } catch {
45364
45564
  }
45365
45565
  }
@@ -45401,20 +45601,20 @@ ${lastSnapshot}`;
45401
45601
  for (const d of dirs) {
45402
45602
  let entries;
45403
45603
  try {
45404
- entries = fs12.readdirSync(d, { withFileTypes: true });
45604
+ entries = fs13.readdirSync(d, { withFileTypes: true });
45405
45605
  } catch {
45406
45606
  continue;
45407
45607
  }
45408
45608
  for (const e of entries) {
45409
- if (e.isDirectory() && re.test(e.name)) next.push(path24.join(d, e.name));
45609
+ if (e.isDirectory() && re.test(e.name)) next.push(path25.join(d, e.name));
45410
45610
  }
45411
45611
  }
45412
45612
  } else {
45413
45613
  for (const d of dirs) {
45414
- const candidate = path24.join(d, seg);
45614
+ const candidate = path25.join(d, seg);
45415
45615
  let stat2 = null;
45416
45616
  try {
45417
- stat2 = fs12.statSync(candidate);
45617
+ stat2 = fs13.statSync(candidate);
45418
45618
  } catch {
45419
45619
  continue;
45420
45620
  }
@@ -45428,13 +45628,13 @@ ${lastSnapshot}`;
45428
45628
  function walkAllDirs(root, out) {
45429
45629
  let entries;
45430
45630
  try {
45431
- entries = fs12.readdirSync(root, { withFileTypes: true });
45631
+ entries = fs13.readdirSync(root, { withFileTypes: true });
45432
45632
  } catch {
45433
45633
  return;
45434
45634
  }
45435
45635
  out.push(root);
45436
45636
  for (const e of entries) {
45437
- if (e.isDirectory()) walkAllDirs(path24.join(root, e.name), out);
45637
+ if (e.isDirectory()) walkAllDirs(path25.join(root, e.name), out);
45438
45638
  }
45439
45639
  }
45440
45640
  function newestRecentFileAcrossGlob(template, pattern, windowMs, sessionFloorMs = 0) {
@@ -45444,13 +45644,13 @@ ${lastSnapshot}`;
45444
45644
  for (const d of dirs) {
45445
45645
  let entries;
45446
45646
  try {
45447
- entries = fs12.readdirSync(d, { withFileTypes: true });
45647
+ entries = fs13.readdirSync(d, { withFileTypes: true });
45448
45648
  } catch {
45449
45649
  continue;
45450
45650
  }
45451
45651
  for (const e of entries) {
45452
45652
  if (!e.isFile() || !pattern.test(e.name)) continue;
45453
- const p = path24.join(d, e.name);
45653
+ const p = path25.join(d, e.name);
45454
45654
  const mtime = safeMtimeMs(p);
45455
45655
  if (mtime < cutoff) continue;
45456
45656
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -45461,7 +45661,7 @@ ${lastSnapshot}`;
45461
45661
  function newestRecentFile(dir, pattern, windowMs, sessionFloorMs = 0) {
45462
45662
  let entries;
45463
45663
  try {
45464
- entries = fs12.readdirSync(dir, { withFileTypes: true });
45664
+ entries = fs13.readdirSync(dir, { withFileTypes: true });
45465
45665
  } catch {
45466
45666
  return null;
45467
45667
  }
@@ -45469,7 +45669,7 @@ ${lastSnapshot}`;
45469
45669
  let best = null;
45470
45670
  for (const e of entries) {
45471
45671
  if (!e.isFile() || !pattern.test(e.name)) continue;
45472
- const p = path24.join(dir, e.name);
45672
+ const p = path25.join(dir, e.name);
45473
45673
  const mtime = safeMtimeMs(p);
45474
45674
  if (mtime < cutoff) continue;
45475
45675
  if (!best || mtime > best.mtime) best = { p, mtime };
@@ -45478,7 +45678,7 @@ ${lastSnapshot}`;
45478
45678
  }
45479
45679
  function safeMtimeMs(p) {
45480
45680
  try {
45481
- return Math.floor(fs12.statSync(p).mtimeMs);
45681
+ return Math.floor(fs13.statSync(p).mtimeMs);
45482
45682
  } catch {
45483
45683
  return 0;
45484
45684
  }
@@ -45682,16 +45882,16 @@ ${lastSnapshot}`;
45682
45882
  }
45683
45883
  return t.negate ? !result : result;
45684
45884
  }
45685
- var fs12;
45686
- var os17;
45687
- var path24;
45885
+ var fs13;
45886
+ var os18;
45887
+ var path25;
45688
45888
  var UUID_RE;
45689
45889
  var init_native_history_executor = __esm2({
45690
45890
  "src/providers/spec/native-history-executor.ts"() {
45691
45891
  "use strict";
45692
- fs12 = __toESM2(require("fs"));
45693
- os17 = __toESM2(require("os"));
45694
- path24 = __toESM2(require("path"));
45892
+ fs13 = __toESM2(require("fs"));
45893
+ os18 = __toESM2(require("os"));
45894
+ path25 = __toESM2(require("path"));
45695
45895
  UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
45696
45896
  }
45697
45897
  });
@@ -45707,7 +45907,7 @@ ${lastSnapshot}`;
45707
45907
  }
45708
45908
  function statMtimeMs(filePath) {
45709
45909
  try {
45710
- return fs13.statSync(filePath).mtimeMs;
45910
+ return fs14.statSync(filePath).mtimeMs;
45711
45911
  } catch {
45712
45912
  return 0;
45713
45913
  }
@@ -45777,7 +45977,7 @@ ${lastSnapshot}`;
45777
45977
  function parseTranscriptFile(filePath, sessionId, workspaceFallback) {
45778
45978
  let raw;
45779
45979
  try {
45780
- raw = fs13.readFileSync(filePath, "utf-8");
45980
+ raw = fs14.readFileSync(filePath, "utf-8");
45781
45981
  } catch {
45782
45982
  return [];
45783
45983
  }
@@ -45850,10 +46050,10 @@ ${lastSnapshot}`;
45850
46050
  return records;
45851
46051
  }
45852
46052
  function readSession(sessionPath) {
45853
- if (!sessionPath || !path25.isAbsolute(sessionPath)) return null;
45854
- const basename12 = path25.basename(sessionPath, ".jsonl");
46053
+ if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
46054
+ const basename12 = path26.basename(sessionPath, ".jsonl");
45855
46055
  if (!isSafeSessionId(basename12)) return null;
45856
- if (!fs13.existsSync(sessionPath)) return null;
46056
+ if (!fs14.existsSync(sessionPath)) return null;
45857
46057
  const sourceMtimeMs = statMtimeMs(sessionPath);
45858
46058
  const messages = parseTranscriptFile(sessionPath, basename12);
45859
46059
  if (messages.length === 0) return null;
@@ -45869,13 +46069,13 @@ ${lastSnapshot}`;
45869
46069
  workspace
45870
46070
  };
45871
46071
  }
45872
- var fs13;
45873
- var path25;
46072
+ var fs14;
46073
+ var path26;
45874
46074
  var init_claude_cli_transcript = __esm2({
45875
46075
  "src/providers/native-history/claude-cli-transcript.ts"() {
45876
46076
  "use strict";
45877
- fs13 = __toESM2(require("fs"));
45878
- path25 = __toESM2(require("path"));
46077
+ fs14 = __toESM2(require("fs"));
46078
+ path26 = __toESM2(require("path"));
45879
46079
  }
45880
46080
  });
45881
46081
  function extractTimestampValue2(value) {
@@ -45890,7 +46090,7 @@ ${lastSnapshot}`;
45890
46090
  }
45891
46091
  function statMtimeMs2(filePath) {
45892
46092
  try {
45893
- return fs14.statSync(filePath).mtimeMs;
46093
+ return fs15.statSync(filePath).mtimeMs;
45894
46094
  } catch {
45895
46095
  return 0;
45896
46096
  }
@@ -45958,7 +46158,7 @@ ${lastSnapshot}`;
45958
46158
  }
45959
46159
  function readSessionMeta(filePath) {
45960
46160
  try {
45961
- const firstLine = fs14.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
46161
+ const firstLine = fs15.readFileSync(filePath, "utf-8").split("\n").find(Boolean);
45962
46162
  if (!firstLine) return null;
45963
46163
  const parsed = JSON.parse(firstLine);
45964
46164
  if (String(parsed.type ?? "") !== "session_meta") return null;
@@ -45970,7 +46170,7 @@ ${lastSnapshot}`;
45970
46170
  function parseSessionFile(filePath, sessionId, workspaceFallback) {
45971
46171
  let raw;
45972
46172
  try {
45973
- raw = fs14.readFileSync(filePath, "utf-8");
46173
+ raw = fs15.readFileSync(filePath, "utf-8");
45974
46174
  } catch {
45975
46175
  return [];
45976
46176
  }
@@ -46064,11 +46264,11 @@ ${lastSnapshot}`;
46064
46264
  return records;
46065
46265
  }
46066
46266
  function readSession2(sessionPath) {
46067
- if (!sessionPath || !path26.isAbsolute(sessionPath)) return null;
46068
- if (!fs14.existsSync(sessionPath)) return null;
46267
+ if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
46268
+ if (!fs15.existsSync(sessionPath)) return null;
46069
46269
  const meta3 = readSessionMeta(sessionPath);
46070
46270
  const metaId = String(meta3?.id ?? "").trim();
46071
- const basename12 = path26.basename(sessionPath, ".jsonl");
46271
+ const basename12 = path27.basename(sessionPath, ".jsonl");
46072
46272
  const uuidMatch = basename12.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
46073
46273
  const filenameUuid = uuidMatch ? uuidMatch[1] : "";
46074
46274
  if (metaId && filenameUuid && metaId !== filenameUuid) return null;
@@ -46090,13 +46290,13 @@ ${lastSnapshot}`;
46090
46290
  workspace
46091
46291
  };
46092
46292
  }
46093
- var fs14;
46094
- var path26;
46293
+ var fs15;
46294
+ var path27;
46095
46295
  var init_codex_cli_transcript = __esm2({
46096
46296
  "src/providers/native-history/codex-cli-transcript.ts"() {
46097
46297
  "use strict";
46098
- fs14 = __toESM2(require("fs"));
46099
- path26 = __toESM2(require("path"));
46298
+ fs15 = __toESM2(require("fs"));
46299
+ path27 = __toESM2(require("path"));
46100
46300
  }
46101
46301
  });
46102
46302
  function extractTimestampValue3(value) {
@@ -46111,7 +46311,7 @@ ${lastSnapshot}`;
46111
46311
  }
46112
46312
  function statMtimeMs3(filePath) {
46113
46313
  try {
46114
- return fs15.statSync(filePath).mtimeMs;
46314
+ return fs16.statSync(filePath).mtimeMs;
46115
46315
  } catch {
46116
46316
  return 0;
46117
46317
  }
@@ -46120,13 +46320,13 @@ ${lastSnapshot}`;
46120
46320
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
46121
46321
  }
46122
46322
  function antigravityRoot() {
46123
- return path27.join(os18.homedir(), ".gemini", "antigravity-cli");
46323
+ return path28.join(os19.homedir(), ".gemini", "antigravity-cli");
46124
46324
  }
46125
46325
  function historyJsonlPath() {
46126
- return path27.join(antigravityRoot(), "history.jsonl");
46326
+ return path28.join(antigravityRoot(), "history.jsonl");
46127
46327
  }
46128
46328
  function brainRoot() {
46129
- return path27.join(antigravityRoot(), "brain");
46329
+ return path28.join(antigravityRoot(), "brain");
46130
46330
  }
46131
46331
  function extractUserRequestContent(content) {
46132
46332
  const raw = content.trim();
@@ -46142,7 +46342,7 @@ ${lastSnapshot}`;
46142
46342
  function parseBrainTranscript(filePath, sessionId, workspace) {
46143
46343
  let raw;
46144
46344
  try {
46145
- raw = fs15.readFileSync(filePath, "utf-8");
46345
+ raw = fs16.readFileSync(filePath, "utf-8");
46146
46346
  } catch {
46147
46347
  return null;
46148
46348
  }
@@ -46202,7 +46402,7 @@ ${lastSnapshot}`;
46202
46402
  const sourcePath = historyJsonlPath();
46203
46403
  let lines = [];
46204
46404
  try {
46205
- lines = fs15.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
46405
+ lines = fs16.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
46206
46406
  } catch {
46207
46407
  return [];
46208
46408
  }
@@ -46249,7 +46449,7 @@ ${lastSnapshot}`;
46249
46449
  function parsePbFile(filePath, sessionId) {
46250
46450
  let buf;
46251
46451
  try {
46252
- buf = fs15.readFileSync(filePath);
46452
+ buf = fs16.readFileSync(filePath);
46253
46453
  } catch {
46254
46454
  return null;
46255
46455
  }
@@ -46272,13 +46472,13 @@ ${lastSnapshot}`;
46272
46472
  ];
46273
46473
  }
46274
46474
  function readSession3(sessionPath, sessionId, workspace) {
46275
- if (!sessionPath || !path27.isAbsolute(sessionPath)) return null;
46276
- if (!fs15.existsSync(sessionPath)) return null;
46475
+ if (!sessionPath || !path28.isAbsolute(sessionPath)) return null;
46476
+ if (!fs16.existsSync(sessionPath)) return null;
46277
46477
  const sourceMtimeMs = statMtimeMs3(sessionPath);
46278
46478
  const brainRootPath = brainRoot();
46279
- if (sessionPath.startsWith(brainRootPath + path27.sep) && sessionPath.endsWith(".jsonl")) {
46280
- const relative4 = sessionPath.slice(brainRootPath.length + 1);
46281
- const uuidFromPath = relative4.split(path27.sep)[0];
46479
+ if (sessionPath.startsWith(brainRootPath + path28.sep) && sessionPath.endsWith(".jsonl")) {
46480
+ const relative5 = sessionPath.slice(brainRootPath.length + 1);
46481
+ const uuidFromPath = relative5.split(path28.sep)[0];
46282
46482
  const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : "");
46283
46483
  if (!resolvedSessionId) return null;
46284
46484
  const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
@@ -46294,7 +46494,7 @@ ${lastSnapshot}`;
46294
46494
  };
46295
46495
  }
46296
46496
  if (sessionPath.endsWith(".pb")) {
46297
- const pbSessionId = sessionId || path27.basename(sessionPath, ".pb");
46497
+ const pbSessionId = sessionId || path28.basename(sessionPath, ".pb");
46298
46498
  if (!isUuidLike(pbSessionId)) return null;
46299
46499
  const messages = parsePbFile(sessionPath, pbSessionId);
46300
46500
  if (!messages || messages.length === 0) return null;
@@ -46308,7 +46508,7 @@ ${lastSnapshot}`;
46308
46508
  partialReason: "antigravity_cli_pb_raw_text_extraction"
46309
46509
  };
46310
46510
  }
46311
- if (path27.basename(sessionPath) === "history.jsonl") {
46511
+ if (path28.basename(sessionPath) === "history.jsonl") {
46312
46512
  const resolvedSessionId = sessionId || "";
46313
46513
  if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
46314
46514
  const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
@@ -46353,28 +46553,28 @@ ${lastSnapshot}`;
46353
46553
  }
46354
46554
  return null;
46355
46555
  }
46356
- var fs15;
46357
- var path27;
46358
- var os18;
46556
+ var fs16;
46557
+ var path28;
46558
+ var os19;
46359
46559
  var MIN_PRINTABLE_RUN;
46360
46560
  var init_antigravity_cli_transcript = __esm2({
46361
46561
  "src/providers/native-history/antigravity-cli-transcript.ts"() {
46362
46562
  "use strict";
46363
- fs15 = __toESM2(require("fs"));
46364
- path27 = __toESM2(require("path"));
46365
- os18 = __toESM2(require("os"));
46563
+ fs16 = __toESM2(require("fs"));
46564
+ path28 = __toESM2(require("path"));
46565
+ os19 = __toESM2(require("os"));
46366
46566
  MIN_PRINTABLE_RUN = 8;
46367
46567
  }
46368
46568
  });
46369
46569
  function statMtimeMs4(p) {
46370
46570
  try {
46371
- return Math.floor(fs16.statSync(p).mtimeMs);
46571
+ return Math.floor(fs17.statSync(p).mtimeMs);
46372
46572
  } catch {
46373
46573
  return 0;
46374
46574
  }
46375
46575
  }
46376
46576
  function openDb() {
46377
- if (!fs16.existsSync(HERMES_STATE_DB)) return null;
46577
+ if (!fs17.existsSync(HERMES_STATE_DB)) return null;
46378
46578
  try {
46379
46579
  const Database = require("better-sqlite3");
46380
46580
  return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
@@ -46431,10 +46631,10 @@ ${lastSnapshot}`;
46431
46631
  }
46432
46632
  }
46433
46633
  }
46434
- if (!path28.isAbsolute(sessionPath) || !fs16.existsSync(sessionPath)) return null;
46634
+ if (!path29.isAbsolute(sessionPath) || !fs17.existsSync(sessionPath)) return null;
46435
46635
  let raw;
46436
46636
  try {
46437
- raw = JSON.parse(fs16.readFileSync(sessionPath, "utf8"));
46637
+ raw = JSON.parse(fs17.readFileSync(sessionPath, "utf8"));
46438
46638
  } catch {
46439
46639
  return null;
46440
46640
  }
@@ -46457,7 +46657,7 @@ ${lastSnapshot}`;
46457
46657
  });
46458
46658
  }
46459
46659
  if (messages.length === 0) return null;
46460
- const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path28.basename(sessionPath, ".json").replace(/^session_/, "");
46660
+ const sessionId = typeof raw.session_id === "string" && raw.session_id ? raw.session_id : path29.basename(sessionPath, ".json").replace(/^session_/, "");
46461
46661
  return {
46462
46662
  messages,
46463
46663
  providerSessionId: sessionId,
@@ -46474,19 +46674,19 @@ ${lastSnapshot}`;
46474
46674
  if (s === "tool" || s === "tool_result" || s === "function") return "assistant";
46475
46675
  return "system";
46476
46676
  }
46477
- var fs16;
46478
- var path28;
46479
- var os19;
46677
+ var fs17;
46678
+ var path29;
46679
+ var os20;
46480
46680
  var HERMES_STATE_DB;
46481
46681
  var HERMES_LEGACY_SESSIONS_DIR;
46482
46682
  var init_hermes_cli_transcript = __esm2({
46483
46683
  "src/providers/native-history/hermes-cli-transcript.ts"() {
46484
46684
  "use strict";
46485
- fs16 = __toESM2(require("fs"));
46486
- path28 = __toESM2(require("path"));
46487
- os19 = __toESM2(require("os"));
46488
- HERMES_STATE_DB = path28.join(os19.homedir(), ".hermes", "state.db");
46489
- HERMES_LEGACY_SESSIONS_DIR = path28.join(os19.homedir(), ".hermes", "sessions");
46685
+ fs17 = __toESM2(require("fs"));
46686
+ path29 = __toESM2(require("path"));
46687
+ os20 = __toESM2(require("os"));
46688
+ HERMES_STATE_DB = path29.join(os20.homedir(), ".hermes", "state.db");
46689
+ HERMES_LEGACY_SESSIONS_DIR = path29.join(os20.homedir(), ".hermes", "sessions");
46490
46690
  }
46491
46691
  });
46492
46692
  var dispatcher_exports = {};
@@ -46532,26 +46732,26 @@ ${lastSnapshot}`;
46532
46732
  }
46533
46733
  }
46534
46734
  function resolveClaudePath(workspace, sessionId) {
46535
- const dir = path29.join(os20.homedir(), ".claude", "projects", cwdAsDashes(workspace));
46536
- if (!fs17.existsSync(dir)) return null;
46735
+ const dir = path30.join(os21.homedir(), ".claude", "projects", cwdAsDashes(workspace));
46736
+ if (!fs18.existsSync(dir)) return null;
46537
46737
  if (sessionId) {
46538
- const candidate = path29.join(dir, `${sessionId}.jsonl`);
46539
- if (fs17.existsSync(candidate)) return candidate;
46738
+ const candidate = path30.join(dir, `${sessionId}.jsonl`);
46739
+ if (fs18.existsSync(candidate)) return candidate;
46540
46740
  }
46541
46741
  return null;
46542
46742
  }
46543
46743
  function resolveCodexPath(workspace) {
46544
46744
  void workspace;
46545
46745
  const now = /* @__PURE__ */ new Date();
46546
- const dir = path29.join(
46547
- os20.homedir(),
46746
+ const dir = path30.join(
46747
+ os21.homedir(),
46548
46748
  ".codex",
46549
46749
  "sessions",
46550
46750
  String(now.getUTCFullYear()),
46551
46751
  String(now.getUTCMonth() + 1).padStart(2, "0"),
46552
46752
  String(now.getUTCDate()).padStart(2, "0")
46553
46753
  );
46554
- if (fs17.existsSync(dir)) {
46754
+ if (fs18.existsSync(dir)) {
46555
46755
  const f = newestRecentFile2(dir, /\.jsonl$/);
46556
46756
  if (f) return f;
46557
46757
  }
@@ -46559,23 +46759,23 @@ ${lastSnapshot}`;
46559
46759
  }
46560
46760
  function resolveAntigravityPath(workspace) {
46561
46761
  void workspace;
46562
- const brainRoot2 = path29.join(os20.homedir(), ".gemini", "antigravity-cli", "brain");
46563
- if (!fs17.existsSync(brainRoot2)) return null;
46762
+ const brainRoot2 = path30.join(os21.homedir(), ".gemini", "antigravity-cli", "brain");
46763
+ if (!fs18.existsSync(brainRoot2)) return null;
46564
46764
  const cutoff = Date.now() - RECENT_WINDOW_MS;
46565
- const entries = fs17.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path29.join(brainRoot2, e.name), mtime: safeMtime(path29.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
46765
+ const entries = fs18.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path30.join(brainRoot2, e.name), mtime: safeMtime(path30.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
46566
46766
  for (const e of entries) {
46567
- const t = path29.join(e.p, ".system_generated", "logs", "transcript.jsonl");
46568
- if (fs17.existsSync(t)) return t;
46767
+ const t = path30.join(e.p, ".system_generated", "logs", "transcript.jsonl");
46768
+ if (fs18.existsSync(t)) return t;
46569
46769
  }
46570
46770
  return null;
46571
46771
  }
46572
46772
  function resolveHermesPath(workspace, sessionId) {
46573
46773
  void workspace;
46574
46774
  void sessionId;
46575
- const dbPath = path29.join(os20.homedir(), ".hermes", "state.db");
46576
- if (fs17.existsSync(dbPath)) return dbPath;
46577
- const dir = path29.join(os20.homedir(), ".hermes", "sessions");
46578
- if (!fs17.existsSync(dir)) return null;
46775
+ const dbPath = path30.join(os21.homedir(), ".hermes", "state.db");
46776
+ if (fs18.existsSync(dbPath)) return dbPath;
46777
+ const dir = path30.join(os21.homedir(), ".hermes", "sessions");
46778
+ if (!fs18.existsSync(dir)) return null;
46579
46779
  return newestRecentFile2(dir, /^session_.*\.json$/);
46580
46780
  }
46581
46781
  function readByReader(reader, sourcePath, sessionId, workspace) {
@@ -46597,7 +46797,7 @@ ${lastSnapshot}`;
46597
46797
  function newestRecentFile2(dir, pattern) {
46598
46798
  try {
46599
46799
  const cutoff = Date.now() - RECENT_WINDOW_MS;
46600
- const entries = fs17.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path29.join(dir, e.name), mtime: safeMtime(path29.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
46800
+ const entries = fs18.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && pattern.test(e.name)).map((e) => ({ p: path30.join(dir, e.name), mtime: safeMtime(path30.join(dir, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
46601
46801
  return entries[0]?.p ?? null;
46602
46802
  } catch {
46603
46803
  return null;
@@ -46605,7 +46805,7 @@ ${lastSnapshot}`;
46605
46805
  }
46606
46806
  function safeMtime(p) {
46607
46807
  try {
46608
- return Math.floor(fs17.statSync(p).mtimeMs);
46808
+ return Math.floor(fs18.statSync(p).mtimeMs);
46609
46809
  } catch {
46610
46810
  return 0;
46611
46811
  }
@@ -46617,16 +46817,16 @@ ${lastSnapshot}`;
46617
46817
  if (s === "tool" || s === "tool_result" || s === "function") return "assistant";
46618
46818
  return "system";
46619
46819
  }
46620
- var fs17;
46621
- var os20;
46622
- var path29;
46820
+ var fs18;
46821
+ var os21;
46822
+ var path30;
46623
46823
  var RECENT_WINDOW_MS;
46624
46824
  var init_dispatcher = __esm2({
46625
46825
  "src/providers/native-history/dispatcher.ts"() {
46626
46826
  "use strict";
46627
- fs17 = __toESM2(require("fs"));
46628
- os20 = __toESM2(require("os"));
46629
- path29 = __toESM2(require("path"));
46827
+ fs18 = __toESM2(require("fs"));
46828
+ os21 = __toESM2(require("os"));
46829
+ path30 = __toESM2(require("path"));
46630
46830
  init_claude_cli_transcript();
46631
46831
  init_codex_cli_transcript();
46632
46832
  init_antigravity_cli_transcript();
@@ -47163,12 +47363,12 @@ ${lastSnapshot}`;
47163
47363
  if (!match) continue;
47164
47364
  const prefix = match[1];
47165
47365
  const commit = match[2];
47166
- const path39 = match[3];
47167
- if (ignoreSet.has(path39)) continue;
47366
+ const path40 = match[3];
47367
+ if (ignoreSet.has(path40)) continue;
47168
47368
  submodules.push({
47169
- path: path39,
47369
+ path: path40,
47170
47370
  commit,
47171
- repoPath: repoRoot + "/" + path39,
47371
+ repoPath: repoRoot + "/" + path40,
47172
47372
  dirty: prefix === "+",
47173
47373
  outOfSync: prefix === "-",
47174
47374
  lastCheckedAt: Date.now()
@@ -47177,7 +47377,7 @@ ${lastSnapshot}`;
47177
47377
  return submodules;
47178
47378
  }
47179
47379
  var import_promises2 = require("fs/promises");
47180
- var path210 = __toESM2(require("path"));
47380
+ var path23 = __toESM2(require("path"));
47181
47381
  init_git_executor();
47182
47382
  var DEFAULT_MAX_FILES = 200;
47183
47383
  var DEFAULT_MAX_BYTES = 2e5;
@@ -47349,17 +47549,17 @@ ${lastSnapshot}`;
47349
47549
  if (typeof filePath !== "string" || filePath.length === 0 || filePath.includes("\0")) {
47350
47550
  throw new GitCommandError("invalid_args", "File path must be a non-empty path");
47351
47551
  }
47352
- const canonicalRepoRoot = await (0, import_promises2.realpath)(repoRoot).catch(() => path210.resolve(repoRoot));
47353
- const absolutePath = path210.isAbsolute(filePath) ? path210.resolve(filePath) : path210.resolve(repoRoot, filePath);
47552
+ const canonicalRepoRoot = await (0, import_promises2.realpath)(repoRoot).catch(() => path23.resolve(repoRoot));
47553
+ const absolutePath = path23.isAbsolute(filePath) ? path23.resolve(filePath) : path23.resolve(repoRoot, filePath);
47354
47554
  const checkPath = await (0, import_promises2.realpath)(absolutePath).catch(() => absolutePath);
47355
- const relativeBase = isPathInside(canonicalRepoRoot, checkPath) ? canonicalRepoRoot : path210.resolve(repoRoot);
47555
+ const relativeBase = isPathInside(canonicalRepoRoot, checkPath) ? canonicalRepoRoot : path23.resolve(repoRoot);
47356
47556
  if (!isPathInside(canonicalRepoRoot, checkPath) && !isPathInside(repoRoot, absolutePath)) {
47357
47557
  throw new GitCommandError("path_outside_repo", "Selected file path is outside the repository root", {
47358
47558
  cwd: repoRoot
47359
47559
  });
47360
47560
  }
47361
- const relativePath = path210.relative(relativeBase, checkPath).split(path210.sep).join("/");
47362
- if (!relativePath || relativePath.startsWith("..") || path210.isAbsolute(relativePath)) {
47561
+ const relativePath = path23.relative(relativeBase, checkPath).split(path23.sep).join("/");
47562
+ if (!relativePath || relativePath.startsWith("..") || path23.isAbsolute(relativePath)) {
47363
47563
  throw new GitCommandError("path_outside_repo", "Selected file path is outside the repository root", {
47364
47564
  cwd: repoRoot
47365
47565
  });
@@ -48642,10 +48842,10 @@ ${lastSnapshot}`;
48642
48842
  return (0, import_path3.join)(getDaemonDataDir(), "mesh-coordinators.json");
48643
48843
  }
48644
48844
  function loadMeshCoordinatorRegistry() {
48645
- const path39 = getRegistryPath();
48646
- if (!(0, import_fs3.existsSync)(path39)) return;
48845
+ const path40 = getRegistryPath();
48846
+ if (!(0, import_fs3.existsSync)(path40)) return;
48647
48847
  try {
48648
- const raw = JSON.parse((0, import_fs3.readFileSync)(path39, "utf-8"));
48848
+ const raw = JSON.parse((0, import_fs3.readFileSync)(path40, "utf-8"));
48649
48849
  if (!Array.isArray(raw)) return;
48650
48850
  _registry.clear();
48651
48851
  for (const entry of raw) {
@@ -48862,8 +49062,8 @@ ${lastSnapshot}`;
48862
49062
  if (rejectedCommands.length) errors.push("one or more validation commands are invalid");
48863
49063
  return { valid: errors.length === 0, errors, bootstrapCommands, commands, rejectedCommands };
48864
49064
  }
48865
- function parseConfigText(path39, text) {
48866
- if (/\.json$/i.test(path39)) return JSON.parse(text);
49065
+ function parseConfigText(path40, text) {
49066
+ if (/\.json$/i.test(path40)) return JSON.parse(text);
48867
49067
  return yaml.load(text);
48868
49068
  }
48869
49069
  function loadMeshRefineConfig(mesh, workspace) {
@@ -48874,16 +49074,16 @@ ${lastSnapshot}`;
48874
49074
  if (!validation.valid) return { source: "mesh.policy.refineConfig", sourceType: "invalid", error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
48875
49075
  return { config: inline, source: "mesh.policy.refineConfig", sourceType: "mesh_policy" };
48876
49076
  }
48877
- for (const relative4 of MESH_REFINE_CONFIG_LOCATIONS) {
48878
- const configPath = (0, import_path4.join)(workspace, relative4);
49077
+ for (const relative5 of MESH_REFINE_CONFIG_LOCATIONS) {
49078
+ const configPath = (0, import_path4.join)(workspace, relative5);
48879
49079
  if (!(0, import_fs4.existsSync)(configPath)) continue;
48880
49080
  try {
48881
49081
  const parsed = parseConfigText(configPath, (0, import_fs4.readFileSync)(configPath, "utf-8"));
48882
- const validation = validateMeshRefineConfig(parsed, relative4);
48883
- if (!validation.valid) return { source: relative4, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
48884
- return { config: parsed, source: relative4, sourceType: "repo_file", path: configPath };
49082
+ const validation = validateMeshRefineConfig(parsed, relative5);
49083
+ if (!validation.valid) return { source: relative5, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
49084
+ return { config: parsed, source: relative5, sourceType: "repo_file", path: configPath };
48885
49085
  } catch (error48) {
48886
- return { source: relative4, sourceType: "invalid", path: configPath, error: error48?.message || String(error48) };
49086
+ return { source: relative5, sourceType: "invalid", path: configPath, error: error48?.message || String(error48) };
48887
49087
  }
48888
49088
  }
48889
49089
  return {
@@ -49014,8 +49214,8 @@ ${lastSnapshot}`;
49014
49214
  var DEFAULT_TIMEOUT_MS2 = 12e4;
49015
49215
  var DEFAULT_OUTPUT_LIMIT_BYTES = 128 * 1024;
49016
49216
  var OUTPUT_SUMMARY_CHARS = 2e3;
49017
- function parseConfigText2(path39, text) {
49018
- if (/\.json$/i.test(path39)) return JSON.parse(text);
49217
+ function parseConfigText2(path40, text) {
49218
+ if (/\.json$/i.test(path40)) return JSON.parse(text);
49019
49219
  return yaml2.load(text);
49020
49220
  }
49021
49221
  function truncateOutput(value) {
@@ -49055,16 +49255,16 @@ ${lastSnapshot}`;
49055
49255
  if (!validation.valid) return { source: "mesh.policy.worktreeBootstrapConfig", sourceType: "invalid", error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
49056
49256
  return { config: inline, source: "mesh.policy.worktreeBootstrapConfig", sourceType: "mesh_policy" };
49057
49257
  }
49058
- for (const relative4 of MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS) {
49059
- const configPath = (0, import_path5.join)(workspace, relative4);
49258
+ for (const relative5 of MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS) {
49259
+ const configPath = (0, import_path5.join)(workspace, relative5);
49060
49260
  if (!(0, import_fs5.existsSync)(configPath)) continue;
49061
49261
  try {
49062
49262
  const parsed = parseConfigText2(configPath, (0, import_fs5.readFileSync)(configPath, "utf-8"));
49063
- const validation = validateMeshWorktreeBootstrapConfig(parsed, relative4);
49064
- if (!validation.valid) return { source: relative4, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
49065
- return { config: parsed, source: relative4, sourceType: "repo_file", path: configPath };
49263
+ const validation = validateMeshWorktreeBootstrapConfig(parsed, relative5);
49264
+ if (!validation.valid) return { source: relative5, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
49265
+ return { config: parsed, source: relative5, sourceType: "repo_file", path: configPath };
49066
49266
  } catch (error48) {
49067
- return { source: relative4, sourceType: "invalid", path: configPath, error: error48?.message || String(error48) };
49267
+ return { source: relative5, sourceType: "invalid", path: configPath, error: error48?.message || String(error48) };
49068
49268
  }
49069
49269
  }
49070
49270
  return { source: "unavailable", sourceType: "unavailable", error: `No worktree bootstrap config found. Checked: ${MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS.join(", ")}` };
@@ -50283,17 +50483,17 @@ ${lastSnapshot}`;
50283
50483
  return null;
50284
50484
  }
50285
50485
  async function detectIDEs(providerLoader) {
50286
- const os28 = (0, import_os22.platform)();
50486
+ const os29 = (0, import_os22.platform)();
50287
50487
  const results = [];
50288
50488
  for (const def of getMergedDefinitions()) {
50289
50489
  const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
50290
- const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os28] || []) || []);
50490
+ const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os29] || []) || []);
50291
50491
  let resolvedCli = cliPath;
50292
- if (!resolvedCli && appPath && os28 === "darwin") {
50492
+ if (!resolvedCli && appPath && os29 === "darwin") {
50293
50493
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
50294
50494
  if ((0, import_fs11.existsSync)(bundledCli)) resolvedCli = bundledCli;
50295
50495
  }
50296
- if (!resolvedCli && appPath && os28 === "win32") {
50496
+ if (!resolvedCli && appPath && os29 === "win32") {
50297
50497
  const { dirname: dirname11 } = await import("path");
50298
50498
  const appDir = dirname11(appPath);
50299
50499
  const candidates = [
@@ -50310,7 +50510,7 @@ ${lastSnapshot}`;
50310
50510
  }
50311
50511
  }
50312
50512
  }
50313
- const installed = os28 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
50513
+ const installed = os29 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
50314
50514
  const version2 = resolvedCli ? await getIdeVersion(resolvedCli) : null;
50315
50515
  results.push({
50316
50516
  id: def.id,
@@ -60600,6 +60800,14 @@ ${effect.notification.body || ""}`.trim();
60600
60800
  return this.handleCheckProviderUpdates(args);
60601
60801
  case "list_installed_providers":
60602
60802
  return this.handleListInstalledProviders(args);
60803
+ case "add_provider_source":
60804
+ return this.handleAddProviderSource(args);
60805
+ case "remove_provider_source":
60806
+ return this.handleRemoveProviderSource(args);
60807
+ case "list_provider_sources":
60808
+ return this.handleListProviderSources(args);
60809
+ case "set_active_provider_source":
60810
+ return this.handleSetActiveProviderSource(args);
60603
60811
  // ─── Stream commands (stream-commands.ts) ───────────
60604
60812
  case "select_session":
60605
60813
  return handleSelectSession(this, args);
@@ -60663,49 +60871,62 @@ ${effect.notification.body || ""}`.trim();
60663
60871
  return { success: false, error: "ProviderLoader not initialized" };
60664
60872
  }
60665
60873
  /**
60666
- * Return per-provider availability so a Marketplace UI can show
60667
- * "Installed" badges. Reuses the existing detection state from
60874
+ * Return per-provider availability so the dashboard's provider catalog
60875
+ * can show "Installed" badges. Reuses the existing detection state from
60668
60876
  * ProviderLoader.getMachineProviderStatus() — no probing is triggered.
60669
60877
  */
60670
60878
  handleListProviderAvailability(_args) {
60671
60879
  if (!this._ctx.providerLoader) {
60672
60880
  return { success: false, error: "ProviderLoader not initialized" };
60673
60881
  }
60882
+ const { describeTrust: describeTrust2, requiresConfirmation: requiresConfirmation2 } = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
60674
60883
  const loader = this._ctx.providerLoader;
60675
60884
  const items = loader.getAll().map((provider) => {
60676
60885
  const machineConfig = loader.getMachineProviderConfig(provider.type);
60677
60886
  const lastDetection = machineConfig.lastDetection;
60887
+ const trust = provider._sourceTrust ?? "trusted";
60888
+ const layer = provider._sourceLayer ?? "upstream";
60889
+ const sourceName = provider._sourceName ?? null;
60678
60890
  return {
60679
60891
  type: provider.type,
60680
60892
  category: provider.category,
60681
60893
  status: loader.getMachineProviderStatus(provider.type),
60682
60894
  installed: lastDetection?.ok === true,
60683
60895
  detectedPath: lastDetection?.path ?? null,
60684
- checkedAt: lastDetection?.checkedAt ?? null
60896
+ checkedAt: lastDetection?.checkedAt ?? null,
60897
+ trust,
60898
+ trustDescription: describeTrust2(trust),
60899
+ requiresConfirmation: requiresConfirmation2(trust),
60900
+ sourceLayer: layer,
60901
+ sourceName
60685
60902
  };
60686
60903
  });
60687
60904
  return { success: true, providers: items };
60688
60905
  }
60689
60906
  /**
60690
- * Compute the *Marketplace install root*. This is always
60691
- * `~/.adhdev/marketplace/` regardless of how ProviderLoader resolved its
60692
- * userDir (which can point to a sibling adhdev-providers git checkout in
60693
- * dev). Marketplace-installed manifests must never overwrite files in a
60694
- * developer checkout, and they should be isolated from upstream/registry
60695
- * sync so they survive `refresh_scripts`.
60907
+ * Compute the *upstream cache root*. install_provider_manifest writes
60908
+ * official-registry manifests here so the daemon's standard upstream
60909
+ * layer picks them up no special handling needed at load time, and
60910
+ * the manifests inherit the official-trust badge instead of the
60911
+ * untrusted-external one.
60912
+ *
60913
+ * Path matches ProviderLoader.upstreamDir but we recompute it from
60914
+ * homedir() so this method stays usable in dev where userDir can
60915
+ * point at a sibling git checkout.
60696
60916
  */
60697
- getMarketplaceInstallRoot() {
60698
- const os28 = require("os");
60699
- const path39 = require("path");
60700
- return path39.join(os28.homedir(), ".adhdev", "marketplace");
60917
+ getUpstreamInstallRoot() {
60918
+ const os29 = require("os");
60919
+ const path40 = require("path");
60920
+ return path40.join(os29.homedir(), ".adhdev", "providers", ".upstream");
60701
60921
  }
60702
60922
  /**
60703
60923
  * Download a single provider manifest from the registry and write it to
60704
- * ~/.adhdev/marketplace/{category}/{type}/provider.json.
60924
+ * ~/.adhdev/providers/.upstream/{category}/{type}/provider.json.
60705
60925
  *
60706
- * Used by the Marketplace UI's Install button. Verifies SHA-256 checksum
60707
- * against the registry meta before persisting. Refuses to write outside
60708
- * the marketplace root.
60926
+ * Used by standalone onboarding to seed the upstream cache with the
60927
+ * default provider set on first launch. Verifies SHA-256 checksum
60928
+ * against the registry meta before persisting. Refuses to write
60929
+ * outside the upstream root.
60709
60930
  *
60710
60931
  * Args: { type: string, category?: string, version?: string }
60711
60932
  * If category/version are omitted, looks up the latest from the registry.
@@ -60720,8 +60941,8 @@ ${effect.notification.body || ""}`.trim();
60720
60941
  return { success: false, error: "invalid type" };
60721
60942
  }
60722
60943
  const https = require("https");
60723
- const fs27 = require("fs");
60724
- const path39 = require("path");
60944
+ const fs28 = require("fs");
60945
+ const path40 = require("path");
60725
60946
  const crypto6 = require("crypto");
60726
60947
  const REGISTRY = "https://api.adhf.dev/api/v1/registry";
60727
60948
  function fetchText(url2, timeoutMs) {
@@ -60758,13 +60979,13 @@ ${effect.notification.body || ""}`.trim();
60758
60979
  if (actualChecksum !== meta3.checksum) {
60759
60980
  return { success: false, error: `checksum mismatch: expected ${meta3.checksum}, got ${actualChecksum}` };
60760
60981
  }
60761
- const installRoot = this.getMarketplaceInstallRoot();
60762
- const installRootResolved = path39.resolve(installRoot);
60763
- const targetDir = path39.resolve(path39.join(installRoot, category, type));
60764
- if (!targetDir.startsWith(installRootResolved + path39.sep)) {
60765
- return { success: false, error: "install path escaped marketplace root" };
60982
+ const installRoot = this.getUpstreamInstallRoot();
60983
+ const installRootResolved = path40.resolve(installRoot);
60984
+ const targetDir = path40.resolve(path40.join(installRoot, category, type));
60985
+ if (!targetDir.startsWith(installRootResolved + path40.sep)) {
60986
+ return { success: false, error: "install path escaped upstream root" };
60766
60987
  }
60767
- fs27.mkdirSync(targetDir, { recursive: true });
60988
+ fs28.mkdirSync(targetDir, { recursive: true });
60768
60989
  let manifestProbe = {};
60769
60990
  try {
60770
60991
  manifestProbe = JSON.parse(manifestBody);
@@ -60788,8 +61009,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60788
61009
  }
60789
61010
  }
60790
61011
  const targetFile = isV1 ? "provider.v1.json" : "provider.json";
60791
- const targetPath = path39.join(targetDir, targetFile);
60792
- fs27.writeFileSync(targetPath, manifestBody, "utf-8");
61012
+ const targetPath = path40.join(targetDir, targetFile);
61013
+ fs28.writeFileSync(targetPath, manifestBody, "utf-8");
60793
61014
  const manifestJson = JSON.parse(manifestBody);
60794
61015
  const scriptFetch = await this.fetchProviderSources(
60795
61016
  manifestJson,
@@ -60837,6 +61058,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60837
61058
  if (Array.isArray(manifest.compatibility)) {
60838
61059
  for (const c of manifest.compatibility) {
60839
61060
  if (typeof c?.scriptDir === "string") scriptDirs.add(c.scriptDir);
61061
+ if (typeof c?.spec === "string" && c.spec.includes("/")) {
61062
+ const dir = c.spec.substring(0, c.spec.lastIndexOf("/"));
61063
+ if (dir) scriptDirs.add(dir);
61064
+ }
60840
61065
  }
60841
61066
  }
60842
61067
  if (manifest.overrides && typeof manifest.overrides === "object" && !Array.isArray(manifest.overrides)) {
@@ -60855,8 +61080,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60855
61080
  const repo = source.repo;
60856
61081
  const ref = source.ref;
60857
61082
  const https = require("https");
60858
- const fs27 = require("fs");
60859
- const path39 = require("path");
61083
+ const fs28 = require("fs");
61084
+ const path40 = require("path");
60860
61085
  function fetchJson(url2, timeoutMs) {
60861
61086
  return new Promise((resolve23, reject) => {
60862
61087
  const req = https.get(url2, {
@@ -60912,9 +61137,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60912
61137
  }
60913
61138
  let fetchedCount = 0;
60914
61139
  const sharedDirRel = `${category}/_shared`;
60915
- const sharedTargetDir = path39.resolve(path39.join(targetDir, "../_shared"));
60916
- const installRootResolved = path39.resolve(path39.join(targetDir, "../.."));
60917
- if (sharedTargetDir.startsWith(installRootResolved + path39.sep)) {
61140
+ const sharedTargetDir = path40.resolve(path40.join(targetDir, "../_shared"));
61141
+ const installRootResolved = path40.resolve(path40.join(targetDir, "../.."));
61142
+ if (sharedTargetDir.startsWith(installRootResolved + path40.sep)) {
60918
61143
  const sharedStack = [sharedDirRel];
60919
61144
  while (sharedStack.length) {
60920
61145
  const relDir = sharedStack.pop();
@@ -60937,10 +61162,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60937
61162
  try {
60938
61163
  const body = await fetchBinary(entry.download_url, 3e4);
60939
61164
  const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
60940
- const outPath = path39.resolve(path39.join(sharedTargetDir, relInside));
60941
- if (!outPath.startsWith(path39.resolve(sharedTargetDir) + path39.sep)) continue;
60942
- fs27.mkdirSync(path39.dirname(outPath), { recursive: true });
60943
- fs27.writeFileSync(outPath, body);
61165
+ const outPath = path40.resolve(path40.join(sharedTargetDir, relInside));
61166
+ if (!outPath.startsWith(path40.resolve(sharedTargetDir) + path40.sep)) continue;
61167
+ fs28.mkdirSync(path40.dirname(outPath), { recursive: true });
61168
+ fs28.writeFileSync(outPath, body);
60944
61169
  fetchedCount++;
60945
61170
  } catch (e) {
60946
61171
  errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
@@ -60973,13 +61198,13 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60973
61198
  try {
60974
61199
  const body = await fetchBinary(entry.download_url, 3e4);
60975
61200
  const relInsideProvider = entry.path.startsWith(subdir + "/") ? entry.path.slice(subdir.length + 1) : entry.path;
60976
- const outPath = path39.resolve(path39.join(targetDir, relInsideProvider));
60977
- if (!outPath.startsWith(path39.resolve(targetDir) + path39.sep)) {
61201
+ const outPath = path40.resolve(path40.join(targetDir, relInsideProvider));
61202
+ if (!outPath.startsWith(path40.resolve(targetDir) + path40.sep)) {
60978
61203
  errors.push(`refusing to write outside targetDir: ${entry.path}`);
60979
61204
  continue;
60980
61205
  }
60981
- fs27.mkdirSync(path39.dirname(outPath), { recursive: true });
60982
- fs27.writeFileSync(outPath, body);
61206
+ fs28.mkdirSync(path40.dirname(outPath), { recursive: true });
61207
+ fs28.writeFileSync(outPath, body);
60983
61208
  fetchedCount++;
60984
61209
  } catch (e) {
60985
61210
  errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
@@ -60990,9 +61215,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60990
61215
  return { fetchedCount, source: `${repo}@${ref}`, errors };
60991
61216
  }
60992
61217
  /**
60993
- * Remove a provider manifest from the marketplace install root
60994
- * (~/.adhdev/marketplace/{category}/{type}/). Refuses to touch anything
60995
- * outside that root.
61218
+ * Remove a provider manifest from the upstream cache root
61219
+ * (~/.adhdev/providers/.upstream/{category}/{type}/). Refuses to touch
61220
+ * anything outside that root. Used by onboarding to opt out of a
61221
+ * provider the user doesn't want; the dashboard no longer exposes a
61222
+ * per-provider uninstall button (external sources are removed as a
61223
+ * whole via remove_provider_source).
60996
61224
  */
60997
61225
  async handleUninstallProviderManifest(args) {
60998
61226
  const type = typeof args?.type === "string" ? args.type : "";
@@ -61004,19 +61232,19 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61004
61232
  if (!["cli", "ide", "extension", "acp"].includes(category)) {
61005
61233
  return { success: false, error: `unknown category: ${category}` };
61006
61234
  }
61007
- const fs27 = require("fs");
61008
- const path39 = require("path");
61235
+ const fs28 = require("fs");
61236
+ const path40 = require("path");
61009
61237
  try {
61010
- const installRoot = this.getMarketplaceInstallRoot();
61011
- const installRootResolved = path39.resolve(installRoot);
61012
- const targetDir = path39.resolve(path39.join(installRoot, category, type));
61013
- if (!targetDir.startsWith(installRootResolved + path39.sep)) {
61014
- return { success: false, error: "refusing to delete outside marketplace root" };
61238
+ const installRoot = this.getUpstreamInstallRoot();
61239
+ const installRootResolved = path40.resolve(installRoot);
61240
+ const targetDir = path40.resolve(path40.join(installRoot, category, type));
61241
+ if (!targetDir.startsWith(installRootResolved + path40.sep)) {
61242
+ return { success: false, error: "refusing to delete outside upstream root" };
61015
61243
  }
61016
- if (!fs27.existsSync(targetDir)) {
61244
+ if (!fs28.existsSync(targetDir)) {
61017
61245
  return { success: false, error: "not installed" };
61018
61246
  }
61019
- fs27.rmSync(targetDir, { recursive: true, force: true });
61247
+ fs28.rmSync(targetDir, { recursive: true, force: true });
61020
61248
  if (this._ctx.providerLoader) {
61021
61249
  this._ctx.providerLoader.reload();
61022
61250
  this._ctx.providerLoader.registerToDetector();
@@ -61027,33 +61255,33 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61027
61255
  }
61028
61256
  }
61029
61257
  /**
61030
- * Return everything currently installed in ~/.adhdev/marketplace/ with its
61258
+ * Return everything currently installed in the upstream cache with its
61031
61259
  * version. This is the "what does this daemon have" answer used both by
61032
61260
  * the UI and by the update checker.
61033
61261
  */
61034
61262
  handleListInstalledProviders(_args) {
61035
- const fs27 = require("fs");
61036
- const path39 = require("path");
61037
- const installRoot = this.getMarketplaceInstallRoot();
61038
- if (!fs27.existsSync(installRoot)) return { success: true, providers: [] };
61263
+ const fs28 = require("fs");
61264
+ const path40 = require("path");
61265
+ const installRoot = this.getUpstreamInstallRoot();
61266
+ if (!fs28.existsSync(installRoot)) return { success: true, providers: [] };
61039
61267
  const CATEGORIES = ["cli", "ide", "extension", "acp"];
61040
61268
  const items = [];
61041
61269
  for (const category of CATEGORIES) {
61042
- const categoryDir = path39.join(installRoot, category);
61043
- if (!fs27.existsSync(categoryDir)) continue;
61270
+ const categoryDir = path40.join(installRoot, category);
61271
+ if (!fs28.existsSync(categoryDir)) continue;
61044
61272
  let entries;
61045
61273
  try {
61046
- entries = fs27.readdirSync(categoryDir);
61274
+ entries = fs28.readdirSync(categoryDir);
61047
61275
  } catch {
61048
61276
  continue;
61049
61277
  }
61050
61278
  for (const type of entries) {
61051
- const v1Path = path39.join(categoryDir, type, "provider.v1.json");
61052
- const v0Path = path39.join(categoryDir, type, "provider.json");
61053
- const manifestPath = fs27.existsSync(v1Path) ? v1Path : fs27.existsSync(v0Path) ? v0Path : null;
61279
+ const v1Path = path40.join(categoryDir, type, "provider.v1.json");
61280
+ const v0Path = path40.join(categoryDir, type, "provider.json");
61281
+ const manifestPath = fs28.existsSync(v1Path) ? v1Path : fs28.existsSync(v0Path) ? v0Path : null;
61054
61282
  if (!manifestPath) continue;
61055
61283
  try {
61056
- const m = JSON.parse(fs27.readFileSync(manifestPath, "utf-8"));
61284
+ const m = JSON.parse(fs28.readFileSync(manifestPath, "utf-8"));
61057
61285
  items.push({
61058
61286
  type,
61059
61287
  category,
@@ -61130,6 +61358,196 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61130
61358
  );
61131
61359
  return { success: true, providers: checks };
61132
61360
  }
61361
+ // ─── External provider sources (3rd-party git URLs) ──────────────
61362
+ /**
61363
+ * Register a new external provider source. The daemon clones the repo
61364
+ * to ~/.adhdev/external/<name>/, walks it once to detect provided
61365
+ * types, and surfaces any conflicts with already-installed types so
61366
+ * the dashboard can ask the user how to resolve them.
61367
+ *
61368
+ * Args: { url: string, ref?: string, name?: string }
61369
+ * - url: https://, git@, or any git-cloneable URL
61370
+ * - ref: branch/tag/commit (default "main")
61371
+ * - name: short identifier (default derived from URL)
61372
+ *
61373
+ * Returns: { source, providers, conflicts }
61374
+ * - conflicts: list of types this new source provides that another
61375
+ * source already exposes. UI uses this to prompt for active-source
61376
+ * selection before the load takes effect.
61377
+ */
61378
+ async handleAddProviderSource(args) {
61379
+ const url2 = typeof args?.url === "string" ? args.url.trim() : "";
61380
+ if (!url2) return { success: false, error: "url is required" };
61381
+ const ref = typeof args?.ref === "string" && args.ref.trim() ? args.ref.trim() : "main";
61382
+ if (url2.startsWith("-")) return { success: false, error: 'url must not start with "-"' };
61383
+ if (ref.startsWith("-")) return { success: false, error: 'ref must not start with "-"' };
61384
+ if (!/^(https?:\/\/|git@[a-z0-9._-]+:)[a-z0-9._@:/~\-]+$/i.test(url2)) {
61385
+ return { success: false, error: "url must be https://\u2026 or git@host:\u2026 and contain only URL-safe characters" };
61386
+ }
61387
+ if (!/^[A-Za-z0-9._/-]+$/.test(ref)) {
61388
+ return { success: false, error: "ref must contain only [A-Za-z0-9._/-]" };
61389
+ }
61390
+ const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
61391
+ const requestedName = typeof args?.name === "string" && args.name.trim() ? args.name.trim() : ext.deriveSourceName(url2);
61392
+ if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
61393
+ return { success: false, error: "name must match @[a-z0-9_-]+" };
61394
+ }
61395
+ const fs28 = require("fs");
61396
+ const path40 = require("path");
61397
+ const { spawnSync: spawnSync2 } = require("child_process");
61398
+ const file2 = ext.loadExternalSources();
61399
+ if (file2.sources.some((s) => s.name === requestedName)) {
61400
+ return { success: false, error: `source name "${requestedName}" is already registered` };
61401
+ }
61402
+ if (file2.sources.some((s) => s.url === url2 && s.ref === ref)) {
61403
+ return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
61404
+ }
61405
+ const sourceDir = path40.join(ext.externalRoot(), requestedName);
61406
+ if (!fs28.existsSync(ext.externalRoot())) fs28.mkdirSync(ext.externalRoot(), { recursive: true });
61407
+ if (fs28.existsSync(sourceDir)) {
61408
+ return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
61409
+ }
61410
+ const clone2 = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
61411
+ encoding: "utf-8",
61412
+ stdio: ["ignore", "pipe", "pipe"],
61413
+ timeout: 6e4
61414
+ });
61415
+ if (clone2.status !== 0) {
61416
+ try {
61417
+ fs28.rmSync(sourceDir, { recursive: true, force: true });
61418
+ } catch {
61419
+ }
61420
+ return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
61421
+ }
61422
+ const source = {
61423
+ name: requestedName,
61424
+ url: url2,
61425
+ ref,
61426
+ addedAt: (/* @__PURE__ */ new Date()).toISOString()
61427
+ };
61428
+ ext.saveExternalSources({ schema: 1, sources: [...file2.sources, source] });
61429
+ const inventory = ext.inventoryExternalSources();
61430
+ const conflicts = [];
61431
+ const newEntry = inventory.find((e) => e.sourceName === requestedName);
61432
+ if (newEntry) {
61433
+ for (const [category, types] of Object.entries(newEntry.providers)) {
61434
+ for (const type of types) {
61435
+ const sources = ext.sourcesProviding(category, type);
61436
+ if (sources.length > 1) conflicts.push({ category, type, sources });
61437
+ }
61438
+ }
61439
+ }
61440
+ if (this._ctx.providerLoader) {
61441
+ this._ctx.providerLoader.reload();
61442
+ this._ctx.providerLoader.registerToDetector();
61443
+ }
61444
+ return {
61445
+ success: true,
61446
+ source,
61447
+ providers: newEntry?.providers ?? {},
61448
+ conflicts
61449
+ };
61450
+ }
61451
+ /**
61452
+ * Remove a registered external source. Deletes the clone directory and
61453
+ * any active-source entry pointing to it.
61454
+ *
61455
+ * Args: { name: string }
61456
+ */
61457
+ async handleRemoveProviderSource(args) {
61458
+ const name = typeof args?.name === "string" ? args.name.trim() : "";
61459
+ if (!name) return { success: false, error: "name is required" };
61460
+ const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
61461
+ const fs28 = require("fs");
61462
+ const path40 = require("path");
61463
+ const file2 = ext.loadExternalSources();
61464
+ const match = file2.sources.find((s) => s.name === name);
61465
+ if (!match) return { success: false, error: `source "${name}" not registered` };
61466
+ const sourceDir = path40.join(ext.externalRoot(), name);
61467
+ if (fs28.existsSync(sourceDir)) {
61468
+ try {
61469
+ fs28.rmSync(sourceDir, { recursive: true, force: true });
61470
+ } catch (e) {
61471
+ return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
61472
+ }
61473
+ }
61474
+ ext.saveExternalSources({
61475
+ schema: 1,
61476
+ sources: file2.sources.filter((s) => s.name !== name)
61477
+ });
61478
+ const active = ext.loadProvidersActive();
61479
+ const filteredActive = {};
61480
+ for (const [type, src] of Object.entries(active.active)) {
61481
+ if (src !== name) filteredActive[type] = src;
61482
+ }
61483
+ ext.saveProvidersActive({ schema: 1, active: filteredActive });
61484
+ if (this._ctx.providerLoader) {
61485
+ this._ctx.providerLoader.reload();
61486
+ this._ctx.providerLoader.registerToDetector();
61487
+ }
61488
+ return { success: true, removed: { name } };
61489
+ }
61490
+ /**
61491
+ * List registered external sources + each source's currently installed
61492
+ * providers + the active selection for any conflicting types. Used by
61493
+ * the dashboard's "Sources" tab.
61494
+ */
61495
+ handleListProviderSources(_args) {
61496
+ const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
61497
+ const file2 = ext.loadExternalSources();
61498
+ const inventory = ext.inventoryExternalSources();
61499
+ const active = ext.loadProvidersActive();
61500
+ const sources = file2.sources.map((s) => {
61501
+ const inv = inventory.find((e) => e.sourceName === s.name);
61502
+ return {
61503
+ ...s,
61504
+ providers: inv?.providers ?? {}
61505
+ };
61506
+ });
61507
+ const conflictMap = /* @__PURE__ */ new Map();
61508
+ for (const inv of inventory) {
61509
+ for (const [category, types] of Object.entries(inv.providers)) {
61510
+ for (const type of types) {
61511
+ const candidates = ext.sourcesProviding(category, type);
61512
+ if (candidates.length > 1 && !conflictMap.has(type)) {
61513
+ conflictMap.set(type, { category, sources: candidates });
61514
+ }
61515
+ }
61516
+ }
61517
+ }
61518
+ const conflicts = [...conflictMap.entries()].map(([type, info]) => ({
61519
+ type,
61520
+ category: info.category,
61521
+ candidates: info.sources,
61522
+ active: active.active[type] ?? null
61523
+ }));
61524
+ return { success: true, sources, conflicts };
61525
+ }
61526
+ /**
61527
+ * Pick which source's copy of a conflicting provider type is active.
61528
+ * Other sources' copies stay on disk but the loader ignores them.
61529
+ *
61530
+ * Args: { type: string, sourceName: string }
61531
+ */
61532
+ handleSetActiveProviderSource(args) {
61533
+ const type = typeof args?.type === "string" ? args.type.trim() : "";
61534
+ const sourceName = typeof args?.sourceName === "string" ? args.sourceName.trim() : "";
61535
+ if (!type || !sourceName) return { success: false, error: "type and sourceName are required" };
61536
+ const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
61537
+ const inventory = ext.inventoryExternalSources();
61538
+ const entry = inventory.find((e) => e.sourceName === sourceName);
61539
+ if (!entry) return { success: false, error: `source "${sourceName}" not found` };
61540
+ const provided = Object.values(entry.providers).some((types) => types.includes(type));
61541
+ if (!provided) return { success: false, error: `source "${sourceName}" does not provide type "${type}"` };
61542
+ const active = ext.loadProvidersActive();
61543
+ active.active[type] = sourceName;
61544
+ ext.saveProvidersActive(active);
61545
+ if (this._ctx.providerLoader) {
61546
+ this._ctx.providerLoader.reload();
61547
+ this._ctx.providerLoader.registerToDetector();
61548
+ }
61549
+ return { success: true, type, sourceName };
61550
+ }
61133
61551
  // ─── DevServer HTTP proxy helpers ─────────────────
61134
61552
  // These bridge WS commands to the DevServer REST API (localhost:19280)
61135
61553
  async proxyDevServerPost(args, endpoint) {
@@ -61220,8 +61638,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61220
61638
  }
61221
61639
  }
61222
61640
  };
61223
- var os16 = __toESM2(require("os"));
61224
- var path222 = __toESM2(require("path"));
61641
+ var os17 = __toESM2(require("os"));
61642
+ var path232 = __toESM2(require("path"));
61225
61643
  var crypto5 = __toESM2(require("crypto"));
61226
61644
  var import_fs12 = require("fs");
61227
61645
  var import_child_process5 = require("child_process");
@@ -61229,17 +61647,17 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61229
61647
  init_provider_cli_adapter();
61230
61648
  init_cli_detector();
61231
61649
  init_config();
61232
- var os15 = __toESM2(require("os"));
61233
- var path20 = __toESM2(require("path"));
61650
+ var os16 = __toESM2(require("os"));
61651
+ var path21 = __toESM2(require("path"));
61234
61652
  var crypto4 = __toESM2(require("crypto"));
61235
- var fs11 = __toESM2(require("fs"));
61653
+ var fs12 = __toESM2(require("fs"));
61236
61654
  var import_node_module = require("module");
61655
+ var fs11 = __toESM2(require("fs"));
61656
+ var path20 = __toESM2(require("path"));
61657
+ init_provider_cli_adapter();
61237
61658
  var fs10 = __toESM2(require("fs"));
61659
+ var os15 = __toESM2(require("os"));
61238
61660
  var path19 = __toESM2(require("path"));
61239
- init_provider_cli_adapter();
61240
- var fs9 = __toESM2(require("fs"));
61241
- var os14 = __toESM2(require("os"));
61242
- var path18 = __toESM2(require("path"));
61243
61661
  var xtermHeadlessNs = __toESM2(require_xterm_headless());
61244
61662
  init_pty_transport();
61245
61663
  var TerminalCtor2 = xtermHeadlessNs.Terminal ?? xtermHeadlessNs.default?.Terminal;
@@ -61610,7 +62028,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61610
62028
  }
61611
62029
  armSpecWatcher() {
61612
62030
  try {
61613
- this.specWatcher = fs9.watch(this.opts.specPath, { persistent: false }, () => {
62031
+ this.specWatcher = fs10.watch(this.opts.specPath, { persistent: false }, () => {
61614
62032
  const res = loadSpec(this.opts.specPath);
61615
62033
  if (!res.ok) {
61616
62034
  this.emit({ kind: "spec_error", errors: res.errors });
@@ -61703,7 +62121,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61703
62121
  }
61704
62122
  fireDelegate(d) {
61705
62123
  const ev = this.currentEval;
61706
- const task = d.task_template.replace(/\{node\}/g, os14.hostname()).replace(/\{state\.label\}/g, ev?.state.label ?? "").replace(/\{state\.title\}/g, ev?.state.title ?? "").replace(/\{duration_ms\}/g, String(d.after_duration_ms ?? 0));
62124
+ const task = d.task_template.replace(/\{node\}/g, os15.hostname()).replace(/\{state\.label\}/g, ev?.state.label ?? "").replace(/\{state\.title\}/g, ev?.state.title ?? "").replace(/\{duration_ms\}/g, String(d.after_duration_ms ?? 0));
61707
62125
  this.emit({ kind: "delegate", id: d.id, task });
61708
62126
  }
61709
62127
  // ────────────────────────────────────────────────────────────────────
@@ -61772,9 +62190,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61772
62190
  const ctl = (this.spec.control_bar ?? []).find((c) => c.action.type === "attach_image");
61773
62191
  if (!ctl || ctl.action.type !== "attach_image") return;
61774
62192
  const ext = guessExt(mime);
61775
- const tmp = path18.join(os14.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
62193
+ const tmp = path19.join(os15.tmpdir(), `adhdev-attach-${Date.now()}${ext}`);
61776
62194
  try {
61777
- fs9.writeFileSync(tmp, Buffer.from(blob, "base64"));
62195
+ fs10.writeFileSync(tmp, Buffer.from(blob, "base64"));
61778
62196
  } catch {
61779
62197
  return;
61780
62198
  }
@@ -62098,14 +62516,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
62098
62516
  function createCliAdapter(provider, workingDir, cliArgs, extraEnv, transportFactory) {
62099
62517
  const resolvedSpecPath = provider._resolvedSpecPath;
62100
62518
  const dir = provider._resolvedProviderDir;
62101
- let specPath = resolvedSpecPath && fs10.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
62519
+ let specPath = resolvedSpecPath && fs11.existsSync(resolvedSpecPath) ? resolvedSpecPath : void 0;
62102
62520
  if (!specPath && dir) {
62103
- const legacy = path19.join(dir, "spec.json");
62104
- if (fs10.existsSync(legacy)) specPath = legacy;
62521
+ const legacy = path20.join(dir, "spec.json");
62522
+ if (fs11.existsSync(legacy)) specPath = legacy;
62105
62523
  }
62106
62524
  if (specPath) {
62107
62525
  try {
62108
- LOG2.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path19.relative(dir || "", specPath) || specPath})`);
62526
+ LOG2.info("spec-route", `[${provider.type}] routing through SpecCliAdapter (${path20.relative(dir || "", specPath) || specPath})`);
62109
62527
  return new SpecCliAdapter(specPath, workingDir, cliArgs, extraEnv, transportFactory);
62110
62528
  } catch (err) {
62111
62529
  LOG2.warn("spec-route", `[${provider.type}] spec invalid, falling back to ProviderCliAdapter: ${err.message}`);
@@ -62160,7 +62578,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
62160
62578
  return uri.slice("file://".length);
62161
62579
  }
62162
62580
  }
62163
- if (path20.isAbsolute(uri)) return uri;
62581
+ if (path21.isAbsolute(uri)) return uri;
62164
62582
  return null;
62165
62583
  }
62166
62584
  function extensionForImageMime(mimeType) {
@@ -62175,9 +62593,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
62175
62593
  if (!part.data) return null;
62176
62594
  const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
62177
62595
  if (!rawData) return null;
62178
- fs11.mkdirSync(dir, { recursive: true });
62179
- const filePath = path20.join(dir, safeInputImageBasename(index, part.mimeType));
62180
- fs11.writeFileSync(filePath, Buffer.from(rawData, "base64"));
62596
+ fs12.mkdirSync(dir, { recursive: true });
62597
+ const filePath = path21.join(dir, safeInputImageBasename(index, part.mimeType));
62598
+ fs12.writeFileSync(filePath, Buffer.from(rawData, "base64"));
62181
62599
  cleanupStaleMaterializedImages(dir);
62182
62600
  return filePath;
62183
62601
  }
@@ -62189,14 +62607,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
62189
62607
  if (now - lastMaterializedImageCleanupAt < MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS) return;
62190
62608
  lastMaterializedImageCleanupAt = now;
62191
62609
  try {
62192
- const entries = fs11.readdirSync(dir);
62610
+ const entries = fs12.readdirSync(dir);
62193
62611
  for (const entry of entries) {
62194
62612
  if (!entry.startsWith("adhdev-input-image-")) continue;
62195
- const fullPath = path20.join(dir, entry);
62613
+ const fullPath = path21.join(dir, entry);
62196
62614
  try {
62197
- const stat2 = fs11.statSync(fullPath);
62615
+ const stat2 = fs12.statSync(fullPath);
62198
62616
  if (now - stat2.mtimeMs > MATERIALIZED_IMAGE_MAX_AGE_MS) {
62199
- fs11.unlinkSync(fullPath);
62617
+ fs12.unlinkSync(fullPath);
62200
62618
  }
62201
62619
  } catch {
62202
62620
  }
@@ -62215,7 +62633,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
62215
62633
  const promptParts = [];
62216
62634
  const imageRefs = [];
62217
62635
  const resourceRefs = [];
62218
- const materializeDir = options.materializeDir || path20.join(os15.tmpdir(), "adhdev-input-media");
62636
+ const materializeDir = options.materializeDir || path21.join(os16.tmpdir(), "adhdev-input-media");
62219
62637
  input.parts.forEach((part, index) => {
62220
62638
  if (part.type === "text" && part.text.trim()) {
62221
62639
  promptParts.push(part.text.trim());
@@ -62282,7 +62700,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
62282
62700
  var CachedDatabaseSync = null;
62283
62701
  function getDatabaseSync() {
62284
62702
  if (CachedDatabaseSync) return CachedDatabaseSync;
62285
- const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path20.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
62703
+ const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path21.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
62286
62704
  const sqliteModule = requireFn(`node:${"sqlite"}`);
62287
62705
  CachedDatabaseSync = sqliteModule.DatabaseSync;
62288
62706
  if (!CachedDatabaseSync) {
@@ -62436,10 +62854,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
62436
62854
  * Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
62437
62855
  */
62438
62856
  probeSessionIdFromConfig(probe) {
62439
- const resolvedDbPath = probe.dbPath.replace(/^~/, os15.homedir());
62857
+ const resolvedDbPath = probe.dbPath.replace(/^~/, os16.homedir());
62440
62858
  const now = Date.now();
62441
62859
  if (this.cachedSqliteDbMissingUntil > now) return null;
62442
- if (!fs11.existsSync(resolvedDbPath)) {
62860
+ if (!fs12.existsSync(resolvedDbPath)) {
62443
62861
  this.cachedSqliteDbMissingUntil = now + 1e4;
62444
62862
  return null;
62445
62863
  }
@@ -63541,7 +63959,7 @@ ${effect.notification.body || ""}`.trim();
63541
63959
  };
63542
63960
  addDir(this.workingDir);
63543
63961
  try {
63544
- addDir(fs11.realpathSync.native(this.workingDir));
63962
+ addDir(fs12.realpathSync.native(this.workingDir));
63545
63963
  } catch {
63546
63964
  }
63547
63965
  return Array.from(dirs);
@@ -63576,7 +63994,7 @@ ${effect.notification.body || ""}`.trim();
63576
63994
  }
63577
63995
  }
63578
63996
  };
63579
- var path21 = __toESM2(require("path"));
63997
+ var path222 = __toESM2(require("path"));
63580
63998
  var import_stream = require("stream");
63581
63999
  var import_child_process4 = require("child_process");
63582
64000
  var import_sdk = (init_acp(), __toCommonJS(acp_exports));
@@ -64351,7 +64769,7 @@ ${effect.notification.body || ""}`.trim();
64351
64769
  return b.uri ? {
64352
64770
  type: "resource_link",
64353
64771
  uri: b.uri,
64354
- name: path21.basename(b.uri),
64772
+ name: path222.basename(b.uri),
64355
64773
  mimeType: b.mimeType,
64356
64774
  ...b.transcript ? { description: b.transcript } : {}
64357
64775
  } : { type: "text", text: b.transcript || `[Video attachment: ${b.mimeType}]` };
@@ -64803,11 +65221,11 @@ ${rawInput}` : rawInput;
64803
65221
  }
64804
65222
  function isExplicitCommand(command) {
64805
65223
  const trimmed = command.trim();
64806
- return path222.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
65224
+ return path232.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
64807
65225
  }
64808
65226
  function expandExecutable(command) {
64809
65227
  const trimmed = command.trim();
64810
- return trimmed.startsWith("~") ? path222.join(os16.homedir(), trimmed.slice(1)) : trimmed;
65228
+ return trimmed.startsWith("~") ? path232.join(os17.homedir(), trimmed.slice(1)) : trimmed;
64811
65229
  }
64812
65230
  function commandExists(command) {
64813
65231
  const trimmed = command.trim();
@@ -64934,10 +65352,10 @@ ${rawInput}` : rawInput;
64934
65352
  return args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
64935
65353
  }
64936
65354
  function ensureEmptyDelegatedMcpConfig(workspace) {
64937
- const baseDir = path222.join(os16.tmpdir(), "adhdev-delegated-agent-empty-mcp");
65355
+ const baseDir = path232.join(os17.tmpdir(), "adhdev-delegated-agent-empty-mcp");
64938
65356
  (0, import_fs12.mkdirSync)(baseDir, { recursive: true });
64939
- const workspaceHash = crypto5.createHash("sha256").update(path222.resolve(workspace || os16.tmpdir())).digest("hex").slice(0, 16);
64940
- const filePath = path222.join(baseDir, `${workspaceHash}.json`);
65357
+ const workspaceHash = crypto5.createHash("sha256").update(path232.resolve(workspace || os17.tmpdir())).digest("hex").slice(0, 16);
65358
+ const filePath = path232.join(baseDir, `${workspaceHash}.json`);
64941
65359
  (0, import_fs12.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
64942
65360
  return filePath;
64943
65361
  }
@@ -65231,7 +65649,7 @@ ${rawInput}` : rawInput;
65231
65649
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
65232
65650
  const trimmed = (workingDir || "").trim();
65233
65651
  if (!trimmed) throw new Error("working directory required");
65234
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os16.homedir()) : path222.resolve(trimmed);
65652
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os17.homedir()) : path232.resolve(trimmed);
65235
65653
  const normalizedType = this.providerLoader.resolveAlias(cliType);
65236
65654
  const rawProvider = this.providerLoader.getByAlias(cliType);
65237
65655
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -65616,6 +66034,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
65616
66034
  cliArgs: args?.cliArgs,
65617
66035
  env: args?.env
65618
66036
  }) : null;
66037
+ const provLookup = this.providerLoader.getMeta(this.providerLoader.resolveAlias(cliType));
66038
+ const provTrust = provLookup?._sourceTrust;
66039
+ if (provTrust === "external-untrusted" && args?.confirmExternalUntrusted !== true) {
66040
+ return {
66041
+ success: false,
66042
+ error: "untrusted_external_provider",
66043
+ provider: {
66044
+ type: provLookup?.type ?? cliType,
66045
+ sourceName: provLookup?._sourceName ?? null,
66046
+ trust: provTrust
66047
+ },
66048
+ hint: "Resend launch_cli with confirmExternalUntrusted=true after the user explicitly approves running JavaScript from this 3rd-party source."
66049
+ };
66050
+ }
65619
66051
  const started = await this.startSession(
65620
66052
  cliType,
65621
66053
  dir,
@@ -65800,11 +66232,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
65800
66232
  };
65801
66233
  var import_child_process6 = require("child_process");
65802
66234
  var net3 = __toESM2(require("net"));
65803
- var os222 = __toESM2(require("os"));
66235
+ var os23 = __toESM2(require("os"));
66236
+ var path322 = __toESM2(require("path"));
66237
+ var fs19 = __toESM2(require("fs"));
65804
66238
  var path31 = __toESM2(require("path"));
65805
- var fs18 = __toESM2(require("fs"));
65806
- var path30 = __toESM2(require("path"));
65807
- var os21 = __toESM2(require("os"));
66239
+ var os222 = __toESM2(require("os"));
65808
66240
  var chokidar = __toESM2(require_chokidar());
65809
66241
  init_logger();
65810
66242
  var VALID_CAPABILITY_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
@@ -66173,9 +66605,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
66173
66605
  static siblingStderrLogged = /* @__PURE__ */ new Set();
66174
66606
  static looksLikeProviderRoot(candidate) {
66175
66607
  try {
66176
- if (!fs18.existsSync(candidate) || !fs18.statSync(candidate).isDirectory()) return false;
66608
+ if (!fs19.existsSync(candidate) || !fs19.statSync(candidate).isDirectory()) return false;
66177
66609
  return ["ide", "extension", "cli", "acp"].some(
66178
- (category) => fs18.existsSync(path30.join(candidate, category))
66610
+ (category) => fs19.existsSync(path31.join(candidate, category))
66179
66611
  );
66180
66612
  } catch {
66181
66613
  return false;
@@ -66183,20 +66615,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
66183
66615
  }
66184
66616
  static hasProviderRootMarker(candidate) {
66185
66617
  try {
66186
- return fs18.existsSync(path30.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
66618
+ return fs19.existsSync(path31.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
66187
66619
  } catch {
66188
66620
  return false;
66189
66621
  }
66190
66622
  }
66191
66623
  detectDefaultUserDir() {
66192
- const fallback = path30.join(os21.homedir(), ".adhdev", "providers");
66624
+ const fallback = path31.join(os222.homedir(), ".adhdev", "providers");
66193
66625
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
66194
66626
  const visited = /* @__PURE__ */ new Set();
66195
66627
  for (const start of this.probeStarts) {
66196
- let current = path30.resolve(start);
66628
+ let current = path31.resolve(start);
66197
66629
  while (!visited.has(current)) {
66198
66630
  visited.add(current);
66199
- const siblingCandidate = path30.join(path30.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
66631
+ const siblingCandidate = path31.join(path31.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
66200
66632
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
66201
66633
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
66202
66634
  if (envOptIn || hasMarker) {
@@ -66218,7 +66650,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
66218
66650
  return { path: siblingCandidate, source };
66219
66651
  }
66220
66652
  }
66221
- const parent = path30.dirname(current);
66653
+ const parent = path31.dirname(current);
66222
66654
  if (parent === current) break;
66223
66655
  current = parent;
66224
66656
  }
@@ -66228,17 +66660,34 @@ Run 'adhdev doctor' for detailed diagnostics.`
66228
66660
  constructor(options) {
66229
66661
  this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
66230
66662
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
66231
- this.defaultProvidersDir = path30.join(os21.homedir(), ".adhdev", "providers");
66663
+ this.defaultProvidersDir = path31.join(os222.homedir(), ".adhdev", "providers");
66232
66664
  const detected = this.detectDefaultUserDir();
66233
66665
  this.userDir = detected.path;
66234
66666
  this.userDirSource = detected.source;
66235
- this.upstreamDir = path30.join(this.defaultProvidersDir, ".upstream");
66667
+ this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
66236
66668
  this.disableUpstream = false;
66237
66669
  this.applySourceConfig({
66238
66670
  userDir: options?.userDir,
66239
66671
  sourceMode: options?.sourceMode,
66240
66672
  disableUpstream: options?.disableUpstream
66241
66673
  });
66674
+ this.migrateMarketplaceDirToExternal();
66675
+ }
66676
+ migrateMarketplaceDirToExternal() {
66677
+ try {
66678
+ const home = os222.homedir();
66679
+ const oldDir = path31.join(home, ".adhdev", "marketplace");
66680
+ const newDir = path31.join(home, ".adhdev", "external");
66681
+ if (!fs19.existsSync(oldDir)) return;
66682
+ if (fs19.existsSync(newDir)) {
66683
+ this.log(`Migration skipped: both ~/.adhdev/marketplace and ~/.adhdev/external exist (marketplace dir is now inert and can be removed manually).`);
66684
+ return;
66685
+ }
66686
+ fs19.renameSync(oldDir, newDir);
66687
+ this.log(`Migrated ~/.adhdev/marketplace \u2192 ~/.adhdev/external (one-time rename after provider source-layer cleanup).`);
66688
+ } catch (e) {
66689
+ this.log(`Marketplace\u2192external migration failed: ${e?.message || e}`);
66690
+ }
66242
66691
  }
66243
66692
  log(msg) {
66244
66693
  this.logFn(`[ProviderLoader] ${msg}`);
@@ -66264,8 +66713,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
66264
66713
  * Highest-priority editable overrides come first.
66265
66714
  */
66266
66715
  getProviderRoots() {
66267
- const marketplaceDir = path30.join(os21.homedir(), ".adhdev", "marketplace");
66268
- return [this.userDir, marketplaceDir, this.upstreamDir];
66716
+ const externalDir = path31.join(os222.homedir(), ".adhdev", "external");
66717
+ return [this.userDir, externalDir, this.upstreamDir];
66269
66718
  }
66270
66719
  getSourceConfig() {
66271
66720
  return {
@@ -66292,7 +66741,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
66292
66741
  this.userDir = detected.path;
66293
66742
  this.userDirSource = detected.source;
66294
66743
  }
66295
- this.upstreamDir = path30.join(this.defaultProvidersDir, ".upstream");
66744
+ this.upstreamDir = path31.join(this.defaultProvidersDir, ".upstream");
66296
66745
  this.disableUpstream = this.sourceMode === "no-upstream";
66297
66746
  if (this.explicitProviderDir) {
66298
66747
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -66306,7 +66755,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
66306
66755
  * Canonical provider directory shape for a given root.
66307
66756
  */
66308
66757
  getProviderDir(root, category, type) {
66309
- return path30.join(root, category, type);
66758
+ return path31.join(root, category, type);
66310
66759
  }
66311
66760
  /**
66312
66761
  * Canonical user override directory for a provider.
@@ -66333,20 +66782,23 @@ Run 'adhdev doctor' for detailed diagnostics.`
66333
66782
  resolveProviderFile(type, ...segments) {
66334
66783
  const dir = this.findProviderDirInternal(type);
66335
66784
  if (!dir) return null;
66336
- return path30.join(dir, ...segments);
66785
+ return path31.join(dir, ...segments);
66337
66786
  }
66338
66787
  /**
66339
66788
  * Load all providers (3-tier priority)
66340
- * 1. .upstream/ (GitHub auto-download — primary source)
66341
- * 2. User custom (~/.adhdev/providers/ excluding .upstream)
66342
- * User custom always wins (highest priority).
66789
+ * 1. ~/.adhdev/providers/.upstream/ official git, auto-synced
66790
+ * 2. ~/.adhdev/external/ 3rd-party git sources, user-added,
66791
+ * bundled providers may include arbitrary JS (untrusted by default)
66792
+ * 3. ~/.adhdev/providers/ (excluding .upstream) — user-authored customs,
66793
+ * always wins
66794
+ * Highest priority listed last (overwrites earlier loads).
66343
66795
  * If .upstream/ is empty, call fetchLatest() before loadAll().
66344
66796
  */
66345
66797
  loadAll() {
66346
66798
  this.providers.clear();
66347
66799
  this.providerAvailability.clear();
66348
66800
  let upstreamCount = 0;
66349
- if (!this.disableUpstream && fs18.existsSync(this.upstreamDir)) {
66801
+ if (!this.disableUpstream && fs19.existsSync(this.upstreamDir)) {
66350
66802
  upstreamCount = this.loadDir(this.upstreamDir);
66351
66803
  if (upstreamCount > 0) {
66352
66804
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -66354,14 +66806,64 @@ Run 'adhdev doctor' for detailed diagnostics.`
66354
66806
  } else if (this.disableUpstream) {
66355
66807
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
66356
66808
  }
66357
- const marketplaceDir = path30.join(os21.homedir(), ".adhdev", "marketplace");
66358
- if (fs18.existsSync(marketplaceDir)) {
66359
- const marketplaceCount = this.loadDir(marketplaceDir);
66360
- if (marketplaceCount > 0) {
66361
- this.log(`Loaded ${marketplaceCount} marketplace-installed providers`);
66809
+ const externalDir = path31.join(os222.homedir(), ".adhdev", "external");
66810
+ if (fs19.existsSync(externalDir)) {
66811
+ const rootEntries = (() => {
66812
+ try {
66813
+ return fs19.readdirSync(externalDir, { withFileTypes: true });
66814
+ } catch {
66815
+ return [];
66816
+ }
66817
+ })();
66818
+ const KNOWN_CATEGORIES = /* @__PURE__ */ new Set(["cli", "ide", "extension", "acp"]);
66819
+ const looksLegacy = rootEntries.some((e) => e.isDirectory() && KNOWN_CATEGORIES.has(e.name));
66820
+ if (looksLegacy) {
66821
+ const externalCount = this.loadDir(externalDir);
66822
+ if (externalCount > 0) {
66823
+ this.log(`Loaded ${externalCount} external providers (legacy unnamed source)`);
66824
+ }
66825
+ } else {
66826
+ const {
66827
+ loadProvidersActive: loadProvidersActive2,
66828
+ resolveActiveSource: resolveActiveSource2
66829
+ } = (init_external_sources(), __toCommonJS2(external_sources_exports));
66830
+ const activeFile = loadProvidersActive2();
66831
+ let totalLoaded = 0;
66832
+ const ambiguousTypes = [];
66833
+ for (const sourceEntry of rootEntries) {
66834
+ if (!sourceEntry.isDirectory()) continue;
66835
+ const sourceDir = path31.join(externalDir, sourceEntry.name);
66836
+ const sourceLoaded = this.loadDir(sourceDir);
66837
+ if (sourceLoaded > 0) {
66838
+ totalLoaded += sourceLoaded;
66839
+ this.log(`Loaded ${sourceLoaded} providers from external source "${sourceEntry.name}"`);
66840
+ }
66841
+ }
66842
+ for (const [type] of this.providers) {
66843
+ const prov = this.providers.get(type);
66844
+ if (!prov) continue;
66845
+ const resolved = resolveActiveSource2(prov.category, type, activeFile);
66846
+ if (resolved.candidates.length <= 1) continue;
66847
+ if (resolved.ambiguous) {
66848
+ ambiguousTypes.push({ type, chosen: resolved.source ?? "?", candidates: resolved.candidates });
66849
+ }
66850
+ if (resolved.source && resolved.source !== "?") {
66851
+ const sourceDir = path31.join(externalDir, resolved.source);
66852
+ const reloadCount = this.loadDir(sourceDir);
66853
+ if (reloadCount === 0) {
66854
+ this.log(`Active source "${resolved.source}" no longer provides ${type}`);
66855
+ }
66856
+ }
66857
+ }
66858
+ if (totalLoaded > 0) {
66859
+ this.log(`Loaded ${totalLoaded} external providers (3rd-party sources)`);
66860
+ }
66861
+ for (const a of ambiguousTypes) {
66862
+ this.log(`Ambiguous provider "${a.type}" \u2014 provided by [${a.candidates.join(", ")}], defaulted to "${a.chosen}". Set the active source from the dashboard to silence this warning.`);
66863
+ }
66362
66864
  }
66363
66865
  }
66364
- if (fs18.existsSync(this.userDir)) {
66866
+ if (fs19.existsSync(this.userDir)) {
66365
66867
  const userCount = this.loadDir(this.userDir, [".upstream"]);
66366
66868
  if (userCount > 0) {
66367
66869
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -66376,10 +66878,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
66376
66878
  * Check if upstream directory exists and has providers.
66377
66879
  */
66378
66880
  hasUpstream() {
66379
- if (!fs18.existsSync(this.upstreamDir)) return false;
66881
+ if (!fs19.existsSync(this.upstreamDir)) return false;
66380
66882
  try {
66381
- return fs18.readdirSync(this.upstreamDir).some(
66382
- (d) => fs18.statSync(path30.join(this.upstreamDir, d)).isDirectory()
66883
+ return fs19.readdirSync(this.upstreamDir).some(
66884
+ (d) => fs19.statSync(path31.join(this.upstreamDir, d)).isDirectory()
66383
66885
  );
66384
66886
  } catch {
66385
66887
  return false;
@@ -66877,8 +67379,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
66877
67379
  resolved._resolvedScriptDir = entry.scriptDir;
66878
67380
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
66879
67381
  if (providerDir) {
66880
- const fullDir = path30.join(providerDir, entry.scriptDir);
66881
- resolved._resolvedScriptsPath = fs18.existsSync(path30.join(fullDir, "scripts.js")) ? path30.join(fullDir, "scripts.js") : fullDir;
67382
+ const fullDir = path31.join(providerDir, entry.scriptDir);
67383
+ resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
66882
67384
  }
66883
67385
  matched = true;
66884
67386
  }
@@ -66896,8 +67398,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
66896
67398
  resolved._resolvedScriptDir = base.defaultScriptDir;
66897
67399
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
66898
67400
  if (providerDir) {
66899
- const fullDir = path30.join(providerDir, base.defaultScriptDir);
66900
- resolved._resolvedScriptsPath = fs18.existsSync(path30.join(fullDir, "scripts.js")) ? path30.join(fullDir, "scripts.js") : fullDir;
67401
+ const fullDir = path31.join(providerDir, base.defaultScriptDir);
67402
+ resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
66901
67403
  }
66902
67404
  }
66903
67405
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -66914,8 +67416,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
66914
67416
  resolved._resolvedScriptDir = dirOverride;
66915
67417
  resolved._resolvedScriptsSource = `versions:${range}`;
66916
67418
  if (providerDir) {
66917
- const fullDir = path30.join(providerDir, dirOverride);
66918
- resolved._resolvedScriptsPath = fs18.existsSync(path30.join(fullDir, "scripts.js")) ? path30.join(fullDir, "scripts.js") : fullDir;
67419
+ const fullDir = path31.join(providerDir, dirOverride);
67420
+ resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
66919
67421
  }
66920
67422
  }
66921
67423
  } else if (override.scripts) {
@@ -66931,8 +67433,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
66931
67433
  resolved._resolvedScriptDir = base.defaultScriptDir;
66932
67434
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
66933
67435
  if (providerDir) {
66934
- const fullDir = path30.join(providerDir, base.defaultScriptDir);
66935
- resolved._resolvedScriptsPath = fs18.existsSync(path30.join(fullDir, "scripts.js")) ? path30.join(fullDir, "scripts.js") : fullDir;
67436
+ const fullDir = path31.join(providerDir, base.defaultScriptDir);
67437
+ resolved._resolvedScriptsPath = fs19.existsSync(path31.join(fullDir, "scripts.js")) ? path31.join(fullDir, "scripts.js") : fullDir;
66936
67438
  }
66937
67439
  }
66938
67440
  }
@@ -66949,13 +67451,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
66949
67451
  if (providerDir2) {
66950
67452
  for (const [scriptName, override] of Object.entries(base.overrides)) {
66951
67453
  if (!override || typeof override.path !== "string") continue;
66952
- const fullPath = path30.join(providerDir2, override.path);
66953
- if (!fs18.existsSync(fullPath)) {
67454
+ const fullPath = path31.join(providerDir2, override.path);
67455
+ if (!fs19.existsSync(fullPath)) {
66954
67456
  this.log(` [overrides] ${base.type}: ${scriptName} path not found: ${fullPath}`);
66955
67457
  continue;
66956
67458
  }
66957
67459
  try {
66958
- registerProviderScriptRootSafely(path30.dirname(path30.dirname(providerDir2)));
67460
+ registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir2)));
66959
67461
  delete require.cache[require.resolve(fullPath)];
66960
67462
  const fn = require(fullPath);
66961
67463
  const target = typeof fn === "function" ? fn : fn && fn[scriptName];
@@ -66980,19 +67482,19 @@ Run 'adhdev doctor' for detailed diagnostics.`
66980
67482
  }
66981
67483
  if (providerDir) {
66982
67484
  try {
66983
- const fs27 = require("fs");
66984
- const path39 = require("path");
67485
+ const fs28 = require("fs");
67486
+ const path40 = require("path");
66985
67487
  const candidates = [];
66986
67488
  if (Array.isArray(base.compatibility)) {
66987
67489
  for (const entry of base.compatibility) {
66988
67490
  if (typeof entry?.spec !== "string") continue;
66989
67491
  const matches = !entry.ideVersion || currentVersion && this.matchesVersion(currentVersion, entry.ideVersion) || !currentVersion;
66990
- if (matches) candidates.push(path39.join(providerDir, entry.spec));
67492
+ if (matches) candidates.push(path40.join(providerDir, entry.spec));
66991
67493
  }
66992
67494
  }
66993
- candidates.push(path39.join(providerDir, "specs", "default.json"));
66994
- candidates.push(path39.join(providerDir, "spec.json"));
66995
- const specPath = candidates.find((p) => fs27.existsSync(p));
67495
+ candidates.push(path40.join(providerDir, "specs", "default.json"));
67496
+ candidates.push(path40.join(providerDir, "spec.json"));
67497
+ const specPath = candidates.find((p) => fs28.existsSync(p));
66996
67498
  if (specPath) {
66997
67499
  resolved._resolvedSpecPath = specPath;
66998
67500
  const { loadSpec: loadSpec2 } = (init_loader(), __toCommonJS2(loader_exports));
@@ -67021,10 +67523,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
67021
67523
  format = `spec-${nh.source.kind}`;
67022
67524
  reader = (input) => executeNativeHistory2(nh, input);
67023
67525
  } else if (nh.override_path) {
67024
- const overrideFile = path39.resolve(providerDir, nh.override_path);
67025
- if (fs27.existsSync(overrideFile)) {
67526
+ const overrideFile = path40.resolve(providerDir, nh.override_path);
67527
+ if (fs28.existsSync(overrideFile)) {
67026
67528
  try {
67027
- registerProviderScriptRootSafely(path39.dirname(path39.dirname(providerDir)));
67529
+ registerProviderScriptRootSafely(path40.dirname(path40.dirname(providerDir)));
67028
67530
  delete require.cache[require.resolve(overrideFile)];
67029
67531
  const mod = require(overrideFile);
67030
67532
  const fn = typeof mod === "function" ? mod : mod && typeof mod.default === "function" ? mod.default : null;
@@ -67068,16 +67570,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
67068
67570
  this.debugLog(`[loadScriptsFromDir] ${type}: providerDir not found`);
67069
67571
  return null;
67070
67572
  }
67071
- const dir = path30.join(providerDir, scriptDir);
67072
- if (!fs18.existsSync(dir)) {
67573
+ const dir = path31.join(providerDir, scriptDir);
67574
+ if (!fs19.existsSync(dir)) {
67073
67575
  this.debugLog(`[loadScriptsFromDir] ${type}: dir not found: ${dir}`);
67074
67576
  return null;
67075
67577
  }
67076
- registerProviderScriptRootSafely(path30.dirname(path30.dirname(providerDir)));
67578
+ registerProviderScriptRootSafely(path31.dirname(path31.dirname(providerDir)));
67077
67579
  const cached2 = this.scriptsCache.get(dir);
67078
67580
  if (cached2) return cached2;
67079
- const scriptsJs = path30.join(dir, "scripts.js");
67080
- if (fs18.existsSync(scriptsJs)) {
67581
+ const scriptsJs = path31.join(dir, "scripts.js");
67582
+ if (fs19.existsSync(scriptsJs)) {
67081
67583
  try {
67082
67584
  delete require.cache[require.resolve(scriptsJs)];
67083
67585
  const loaded = require(scriptsJs);
@@ -67098,9 +67600,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
67098
67600
  watch() {
67099
67601
  this.stopWatch();
67100
67602
  const watchDir = (dir) => {
67101
- if (!fs18.existsSync(dir)) {
67603
+ if (!fs19.existsSync(dir)) {
67102
67604
  try {
67103
- fs18.mkdirSync(dir, { recursive: true });
67605
+ fs19.mkdirSync(dir, { recursive: true });
67104
67606
  } catch {
67105
67607
  return;
67106
67608
  }
@@ -67121,7 +67623,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
67121
67623
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
67122
67624
  if (reloadTimer) clearTimeout(reloadTimer);
67123
67625
  reloadTimer = setTimeout(() => {
67124
- this.log(`File changed: ${path30.basename(filePath)}, reloading...`);
67626
+ this.log(`File changed: ${path31.basename(filePath)}, reloading...`);
67125
67627
  this.reload();
67126
67628
  }, 300);
67127
67629
  }
@@ -67189,11 +67691,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
67189
67691
  }
67190
67692
  this.log(`Registry sync starting (${_ProviderLoader.REGISTRY_BASE_URL})...`);
67191
67693
  const https = require("https");
67192
- const regMetaPath = path30.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
67694
+ const regMetaPath = path31.join(this.upstreamDir, _ProviderLoader.REGISTRY_META_FILE);
67193
67695
  let cachedChecksums = {};
67194
67696
  try {
67195
- if (fs18.existsSync(regMetaPath)) {
67196
- cachedChecksums = JSON.parse(fs18.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
67697
+ if (fs19.existsSync(regMetaPath)) {
67698
+ cachedChecksums = JSON.parse(fs19.readFileSync(regMetaPath, "utf-8")).checksums ?? {};
67197
67699
  }
67198
67700
  } catch {
67199
67701
  }
@@ -67247,15 +67749,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
67247
67749
  this.log(`\u26A0 Registry checksum mismatch for ${type}@${version2} \u2014 skipping`);
67248
67750
  continue;
67249
67751
  }
67250
- const providerDir = path30.join(this.upstreamDir, category, type);
67251
- fs18.mkdirSync(providerDir, { recursive: true });
67252
- fs18.writeFileSync(path30.join(providerDir, "provider.json"), manifestBody, "utf-8");
67752
+ const providerDir = path31.join(this.upstreamDir, category, type);
67753
+ fs19.mkdirSync(providerDir, { recursive: true });
67754
+ fs19.writeFileSync(path31.join(providerDir, "provider.json"), manifestBody, "utf-8");
67253
67755
  cachedChecksums[cacheKey] = checksum;
67254
67756
  updatedCount++;
67255
67757
  this.log(`\u2713 Registry updated: ${category}/${type}@${version2}`);
67256
67758
  }
67257
- fs18.mkdirSync(this.upstreamDir, { recursive: true });
67258
- fs18.writeFileSync(regMetaPath, JSON.stringify({
67759
+ fs19.mkdirSync(this.upstreamDir, { recursive: true });
67760
+ fs19.writeFileSync(regMetaPath, JSON.stringify({
67259
67761
  checksums: cachedChecksums,
67260
67762
  syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
67261
67763
  providerCount: list.providers.length
@@ -67276,12 +67778,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
67276
67778
  const { exec: exec7 } = require("child_process");
67277
67779
  const { promisify: promisify7 } = require("util");
67278
67780
  const execAsync5 = promisify7(exec7);
67279
- const metaPath = path30.join(this.upstreamDir, _ProviderLoader.META_FILE);
67781
+ const metaPath = path31.join(this.upstreamDir, _ProviderLoader.META_FILE);
67280
67782
  let prevEtag = "";
67281
67783
  let prevTimestamp = 0;
67282
67784
  try {
67283
- if (fs18.existsSync(metaPath)) {
67284
- const meta3 = JSON.parse(fs18.readFileSync(metaPath, "utf-8"));
67785
+ if (fs19.existsSync(metaPath)) {
67786
+ const meta3 = JSON.parse(fs19.readFileSync(metaPath, "utf-8"));
67285
67787
  prevEtag = meta3.etag || "";
67286
67788
  prevTimestamp = meta3.timestamp || 0;
67287
67789
  }
@@ -67336,39 +67838,39 @@ Run 'adhdev doctor' for detailed diagnostics.`
67336
67838
  return { updated: false };
67337
67839
  }
67338
67840
  this.log("Downloading latest providers from GitHub...");
67339
- const tmpTar = path30.join(os21.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
67340
- const tmpExtract = path30.join(os21.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
67841
+ const tmpTar = path31.join(os222.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
67842
+ const tmpExtract = path31.join(os222.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
67341
67843
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
67342
- fs18.mkdirSync(tmpExtract, { recursive: true });
67844
+ fs19.mkdirSync(tmpExtract, { recursive: true });
67343
67845
  await execAsync5(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
67344
- const extracted = fs18.readdirSync(tmpExtract);
67846
+ const extracted = fs19.readdirSync(tmpExtract);
67345
67847
  const rootDir = extracted.find(
67346
- (d) => fs18.statSync(path30.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
67848
+ (d) => fs19.statSync(path31.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
67347
67849
  );
67348
67850
  if (!rootDir) throw new Error("Unexpected tarball structure");
67349
- const sourceDir = path30.join(tmpExtract, rootDir);
67851
+ const sourceDir = path31.join(tmpExtract, rootDir);
67350
67852
  const backupDir = this.upstreamDir + ".bak";
67351
- if (fs18.existsSync(this.upstreamDir)) {
67352
- if (fs18.existsSync(backupDir)) fs18.rmSync(backupDir, { recursive: true, force: true });
67353
- fs18.renameSync(this.upstreamDir, backupDir);
67853
+ if (fs19.existsSync(this.upstreamDir)) {
67854
+ if (fs19.existsSync(backupDir)) fs19.rmSync(backupDir, { recursive: true, force: true });
67855
+ fs19.renameSync(this.upstreamDir, backupDir);
67354
67856
  }
67355
67857
  try {
67356
67858
  this.copyDirRecursive(sourceDir, this.upstreamDir);
67357
67859
  this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
67358
- if (fs18.existsSync(backupDir)) fs18.rmSync(backupDir, { recursive: true, force: true });
67860
+ if (fs19.existsSync(backupDir)) fs19.rmSync(backupDir, { recursive: true, force: true });
67359
67861
  } catch (e) {
67360
- if (fs18.existsSync(backupDir)) {
67361
- if (fs18.existsSync(this.upstreamDir)) fs18.rmSync(this.upstreamDir, { recursive: true, force: true });
67362
- fs18.renameSync(backupDir, this.upstreamDir);
67862
+ if (fs19.existsSync(backupDir)) {
67863
+ if (fs19.existsSync(this.upstreamDir)) fs19.rmSync(this.upstreamDir, { recursive: true, force: true });
67864
+ fs19.renameSync(backupDir, this.upstreamDir);
67363
67865
  }
67364
67866
  throw e;
67365
67867
  }
67366
67868
  try {
67367
- fs18.rmSync(tmpTar, { force: true });
67869
+ fs19.rmSync(tmpTar, { force: true });
67368
67870
  } catch {
67369
67871
  }
67370
67872
  try {
67371
- fs18.rmSync(tmpExtract, { recursive: true, force: true });
67873
+ fs19.rmSync(tmpExtract, { recursive: true, force: true });
67372
67874
  } catch {
67373
67875
  }
67374
67876
  const upstreamCount = this.countProviders(this.upstreamDir);
@@ -67400,7 +67902,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
67400
67902
  reject(new Error(`HTTP ${res.statusCode}`));
67401
67903
  return;
67402
67904
  }
67403
- const ws = fs18.createWriteStream(destPath);
67905
+ const ws = fs19.createWriteStream(destPath);
67404
67906
  res.pipe(ws);
67405
67907
  ws.on("finish", () => {
67406
67908
  ws.close();
@@ -67419,22 +67921,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
67419
67921
  }
67420
67922
  /** Recursive directory copy */
67421
67923
  copyDirRecursive(src, dest) {
67422
- fs18.mkdirSync(dest, { recursive: true });
67423
- for (const entry of fs18.readdirSync(src, { withFileTypes: true })) {
67424
- const srcPath = path30.join(src, entry.name);
67425
- const destPath = path30.join(dest, entry.name);
67924
+ fs19.mkdirSync(dest, { recursive: true });
67925
+ for (const entry of fs19.readdirSync(src, { withFileTypes: true })) {
67926
+ const srcPath = path31.join(src, entry.name);
67927
+ const destPath = path31.join(dest, entry.name);
67426
67928
  if (entry.isDirectory()) {
67427
67929
  this.copyDirRecursive(srcPath, destPath);
67428
67930
  } else {
67429
- fs18.copyFileSync(srcPath, destPath);
67931
+ fs19.copyFileSync(srcPath, destPath);
67430
67932
  }
67431
67933
  }
67432
67934
  }
67433
67935
  /** .meta.json save */
67434
67936
  writeMeta(metaPath, etag, timestamp) {
67435
67937
  try {
67436
- fs18.mkdirSync(path30.dirname(metaPath), { recursive: true });
67437
- fs18.writeFileSync(metaPath, JSON.stringify({
67938
+ fs19.mkdirSync(path31.dirname(metaPath), { recursive: true });
67939
+ fs19.writeFileSync(metaPath, JSON.stringify({
67438
67940
  etag,
67439
67941
  timestamp,
67440
67942
  lastCheck: new Date(timestamp).toISOString(),
@@ -67445,15 +67947,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
67445
67947
  }
67446
67948
  /** Count provider files (provider.v1.json or provider.json — at most one per dir). */
67447
67949
  countProviders(dir) {
67448
- if (!fs18.existsSync(dir)) return 0;
67950
+ if (!fs19.existsSync(dir)) return 0;
67449
67951
  let count = 0;
67450
67952
  const scan = (d) => {
67451
67953
  try {
67452
- const entries = fs18.readdirSync(d, { withFileTypes: true });
67954
+ const entries = fs19.readdirSync(d, { withFileTypes: true });
67453
67955
  const hasManifest = entries.some((e) => e.name === "provider.v1.json" || e.name === "provider.json");
67454
67956
  if (hasManifest) count++;
67455
67957
  for (const entry of entries) {
67456
- if (entry.isDirectory()) scan(path30.join(d, entry.name));
67958
+ if (entry.isDirectory()) scan(path31.join(d, entry.name));
67457
67959
  }
67458
67960
  } catch {
67459
67961
  }
@@ -67679,13 +68181,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
67679
68181
  if (!provider) return null;
67680
68182
  const cat = provider.category;
67681
68183
  const searchRoots = this.getProviderRoots();
67682
- const hasManifest = (dir) => fs18.existsSync(path30.join(dir, "provider.v1.json")) || fs18.existsSync(path30.join(dir, "provider.json"));
68184
+ const hasManifest = (dir) => fs19.existsSync(path31.join(dir, "provider.v1.json")) || fs19.existsSync(path31.join(dir, "provider.json"));
67683
68185
  const readManifestType = (dir) => {
67684
68186
  for (const file2 of ["provider.v1.json", "provider.json"]) {
67685
- const p = path30.join(dir, file2);
67686
- if (!fs18.existsSync(p)) continue;
68187
+ const p = path31.join(dir, file2);
68188
+ if (!fs19.existsSync(p)) continue;
67687
68189
  try {
67688
- const data = JSON.parse(fs18.readFileSync(p, "utf-8"));
68190
+ const data = JSON.parse(fs19.readFileSync(p, "utf-8"));
67689
68191
  if (typeof data?.type === "string") return data.type;
67690
68192
  } catch {
67691
68193
  }
@@ -67693,15 +68195,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
67693
68195
  return null;
67694
68196
  };
67695
68197
  for (const root of searchRoots) {
67696
- if (!fs18.existsSync(root)) continue;
68198
+ if (!fs19.existsSync(root)) continue;
67697
68199
  const candidate = this.getProviderDir(root, cat, type);
67698
68200
  if (hasManifest(candidate)) return candidate;
67699
- const catDir = path30.join(root, cat);
67700
- if (fs18.existsSync(catDir)) {
68201
+ const catDir = path31.join(root, cat);
68202
+ if (fs19.existsSync(catDir)) {
67701
68203
  try {
67702
- for (const entry of fs18.readdirSync(catDir, { withFileTypes: true })) {
68204
+ for (const entry of fs19.readdirSync(catDir, { withFileTypes: true })) {
67703
68205
  if (!entry.isDirectory()) continue;
67704
- const entryDir = path30.join(catDir, entry.name);
68206
+ const entryDir = path31.join(catDir, entry.name);
67705
68207
  const manifestType = readManifestType(entryDir);
67706
68208
  if (manifestType === type) return entryDir;
67707
68209
  }
@@ -67717,8 +68219,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
67717
68219
  * (template substitution is NOT applied here — scripts.js handles that)
67718
68220
  */
67719
68221
  buildScriptWrappersFromDir(dir) {
67720
- const scriptsJs = path30.join(dir, "scripts.js");
67721
- if (fs18.existsSync(scriptsJs)) {
68222
+ const scriptsJs = path31.join(dir, "scripts.js");
68223
+ if (fs19.existsSync(scriptsJs)) {
67722
68224
  try {
67723
68225
  delete require.cache[require.resolve(scriptsJs)];
67724
68226
  return require(scriptsJs);
@@ -67728,13 +68230,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
67728
68230
  const toCamel = (name) => name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
67729
68231
  const result = {};
67730
68232
  try {
67731
- for (const file2 of fs18.readdirSync(dir)) {
68233
+ for (const file2 of fs19.readdirSync(dir)) {
67732
68234
  if (!file2.endsWith(".js")) continue;
67733
68235
  const scriptName = toCamel(file2.replace(".js", ""));
67734
- const filePath = path30.join(dir, file2);
68236
+ const filePath = path31.join(dir, file2);
67735
68237
  result[scriptName] = (...args) => {
67736
68238
  try {
67737
- let content = fs18.readFileSync(filePath, "utf-8");
68239
+ let content = fs19.readFileSync(filePath, "utf-8");
67738
68240
  if (args[0] && typeof args[0] === "object") {
67739
68241
  for (const [key, val] of Object.entries(args[0])) {
67740
68242
  let v = val;
@@ -67780,12 +68282,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
67780
68282
  * Structure: dir/category/agent-name/provider.{json,js}
67781
68283
  */
67782
68284
  loadDir(dir, excludeDirs) {
67783
- if (!fs18.existsSync(dir)) return 0;
68285
+ if (!fs19.existsSync(dir)) return 0;
67784
68286
  let count = 0;
67785
68287
  const scan = (d) => {
67786
68288
  let entries;
67787
68289
  try {
67788
- entries = fs18.readdirSync(d, { withFileTypes: true });
68290
+ entries = fs19.readdirSync(d, { withFileTypes: true });
67789
68291
  } catch {
67790
68292
  return;
67791
68293
  }
@@ -67793,9 +68295,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
67793
68295
  const hasJson = entries.some((e) => e.name === "provider.json");
67794
68296
  if (hasV1 || hasJson) {
67795
68297
  const manifestFile = hasV1 ? "provider.v1.json" : "provider.json";
67796
- const jsonPath = path30.join(d, manifestFile);
68298
+ const jsonPath = path31.join(d, manifestFile);
67797
68299
  try {
67798
- const raw = fs18.readFileSync(jsonPath, "utf-8");
68300
+ const raw = fs19.readFileSync(jsonPath, "utf-8");
67799
68301
  const mod = JSON.parse(raw);
67800
68302
  if (hasV1 && mod?.category === "cli") {
67801
68303
  try {
@@ -67833,10 +68335,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
67833
68335
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
67834
68336
  } else {
67835
68337
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
67836
- const scriptsPath = path30.join(d, "scripts.js");
67837
- if (!hasCompatibility && fs18.existsSync(scriptsPath)) {
68338
+ const scriptsPath = path31.join(d, "scripts.js");
68339
+ if (!hasCompatibility && fs19.existsSync(scriptsPath)) {
67838
68340
  try {
67839
- registerProviderScriptRootSafely(path30.dirname(path30.dirname(d)));
68341
+ registerProviderScriptRootSafely(path31.dirname(path31.dirname(d)));
67840
68342
  delete require.cache[require.resolve(scriptsPath)];
67841
68343
  const scripts = require(scriptsPath);
67842
68344
  normalizedProvider.scripts = scripts;
@@ -67844,12 +68346,30 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
67844
68346
  this.log(`\u26A0 Failed to load scripts: ${scriptsPath}: ${e.message}`);
67845
68347
  }
67846
68348
  }
68349
+ const externalDirAbs = path31.join(os222.homedir(), ".adhdev", "external");
68350
+ const layer = d.startsWith(externalDirAbs) ? "external" : d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
68351
+ try {
68352
+ const { inspectManifestShape: inspectManifestShape2, classifyTrust: classifyTrust2 } = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
68353
+ const shape = inspectManifestShape2(mod);
68354
+ const trust = classifyTrust2(layer, shape);
68355
+ normalizedProvider._sourceLayer = layer;
68356
+ normalizedProvider._sourceTrust = trust;
68357
+ normalizedProvider._manifestShape = shape;
68358
+ if (layer === "external") {
68359
+ const rel = path31.relative(externalDirAbs, d);
68360
+ const firstSeg = rel.split(path31.sep)[0];
68361
+ if (firstSeg && firstSeg !== "..") normalizedProvider._sourceName = firstSeg;
68362
+ }
68363
+ } catch {
68364
+ }
67847
68365
  const existed = this.providers.has(normalizedProvider.type);
67848
68366
  this.providers.set(normalizedProvider.type, normalizedProvider);
67849
68367
  count++;
67850
- const source = d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
68368
+ const source = normalizedProvider._sourceLayer ?? "upstream";
67851
68369
  const overrideWarning = existed && source === "user" ? " \u26A0 OVERRIDES upstream" : "";
67852
- this.log(` ${existed ? "\u{1F504}" : "\u2705"} ${normalizedProvider.type} (${normalizedProvider.category}) \u2014 ${normalizedProvider.name} [${source}]${overrideWarning}`);
68370
+ const sourceName = normalizedProvider._sourceName;
68371
+ const sourceLabel = sourceName ? `${source}/${sourceName}` : source;
68372
+ this.log(` ${existed ? "\u{1F504}" : "\u2705"} ${normalizedProvider.type} (${normalizedProvider.category}) \u2014 ${normalizedProvider.name} [${sourceLabel}]${overrideWarning}`);
67853
68373
  }
67854
68374
  } catch (e) {
67855
68375
  this.log(`\u26A0 Failed to load ${jsonPath}: ${e.message}`);
@@ -67859,8 +68379,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
67859
68379
  for (const entry of entries) {
67860
68380
  if (!entry.isDirectory()) continue;
67861
68381
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
68382
+ if (d === dir && entry.name === "examples") continue;
67862
68383
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
67863
- scan(path30.join(d, entry.name));
68384
+ scan(path31.join(d, entry.name));
67864
68385
  }
67865
68386
  }
67866
68387
  };
@@ -68054,7 +68575,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68054
68575
  });
68055
68576
  }
68056
68577
  async function killIdeProcess(ideId) {
68057
- const plat = os222.platform();
68578
+ const plat = os23.platform();
68058
68579
  const appName = getMacAppIdentifiers()[ideId];
68059
68580
  const winProcesses = getWinProcessNames()[ideId];
68060
68581
  try {
@@ -68115,7 +68636,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68115
68636
  }
68116
68637
  }
68117
68638
  async function isIdeRunning(ideId) {
68118
- const plat = os222.platform();
68639
+ const plat = os23.platform();
68119
68640
  try {
68120
68641
  if (plat === "darwin") {
68121
68642
  const appName = getMacAppIdentifiers()[ideId];
@@ -68170,7 +68691,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68170
68691
  }
68171
68692
  }
68172
68693
  async function detectCurrentWorkspace(ideId) {
68173
- const plat = os222.platform();
68694
+ const plat = os23.platform();
68174
68695
  if (plat === "darwin") {
68175
68696
  try {
68176
68697
  const appName = getMacAppIdentifiers()[ideId];
@@ -68185,17 +68706,17 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68185
68706
  }
68186
68707
  } else if (plat === "win32") {
68187
68708
  try {
68188
- const fs27 = require("fs");
68709
+ const fs28 = require("fs");
68189
68710
  const appNameMap = getMacAppIdentifiers();
68190
68711
  const appName = appNameMap[ideId];
68191
68712
  if (appName) {
68192
- const storagePath = path31.join(
68193
- process.env.APPDATA || path31.join(os222.homedir(), "AppData", "Roaming"),
68713
+ const storagePath = path322.join(
68714
+ process.env.APPDATA || path322.join(os23.homedir(), "AppData", "Roaming"),
68194
68715
  appName,
68195
68716
  "storage.json"
68196
68717
  );
68197
- if (fs27.existsSync(storagePath)) {
68198
- const data = JSON.parse(fs27.readFileSync(storagePath, "utf-8"));
68718
+ if (fs28.existsSync(storagePath)) {
68719
+ const data = JSON.parse(fs28.readFileSync(storagePath, "utf-8"));
68199
68720
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
68200
68721
  if (workspaces.length > 0) {
68201
68722
  const recent = workspaces[0];
@@ -68212,7 +68733,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68212
68733
  return void 0;
68213
68734
  }
68214
68735
  async function launchWithCdp(options = {}) {
68215
- const platform10 = os222.platform();
68736
+ const platform10 = os23.platform();
68216
68737
  let targetIde;
68217
68738
  const ides = await detectIDEs(getProviderLoader());
68218
68739
  if (options.ideId) {
@@ -68375,14 +68896,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68375
68896
  init_config();
68376
68897
  init_cli_detector();
68377
68898
  init_logger();
68378
- var fs19 = __toESM2(require("fs"));
68379
- var path322 = __toESM2(require("path"));
68380
- var os23 = __toESM2(require("os"));
68381
- var LOG_DIR2 = process.platform === "win32" ? path322.join(process.env.LOCALAPPDATA || process.env.APPDATA || path322.join(os23.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path322.join(os23.homedir(), "Library", "Logs", "adhdev") : path322.join(os23.homedir(), ".local", "share", "adhdev", "logs");
68899
+ var fs20 = __toESM2(require("fs"));
68900
+ var path33 = __toESM2(require("path"));
68901
+ var os24 = __toESM2(require("os"));
68902
+ var LOG_DIR2 = process.platform === "win32" ? path33.join(process.env.LOCALAPPDATA || process.env.APPDATA || path33.join(os24.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path33.join(os24.homedir(), "Library", "Logs", "adhdev") : path33.join(os24.homedir(), ".local", "share", "adhdev", "logs");
68382
68903
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
68383
68904
  var MAX_DAYS = 7;
68384
68905
  try {
68385
- fs19.mkdirSync(LOG_DIR2, { recursive: true });
68906
+ fs20.mkdirSync(LOG_DIR2, { recursive: true });
68386
68907
  } catch {
68387
68908
  }
68388
68909
  var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
@@ -68416,19 +68937,19 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68416
68937
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
68417
68938
  }
68418
68939
  var currentDate2 = getDateStr2();
68419
- var currentFile = path322.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
68940
+ var currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
68420
68941
  var writeCount2 = 0;
68421
68942
  function checkRotation() {
68422
68943
  const today = getDateStr2();
68423
68944
  if (today !== currentDate2) {
68424
68945
  currentDate2 = today;
68425
- currentFile = path322.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
68946
+ currentFile = path33.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
68426
68947
  cleanOldFiles();
68427
68948
  }
68428
68949
  }
68429
68950
  function cleanOldFiles() {
68430
68951
  try {
68431
- const files = fs19.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
68952
+ const files = fs20.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
68432
68953
  const cutoff = /* @__PURE__ */ new Date();
68433
68954
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
68434
68955
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -68436,7 +68957,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68436
68957
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
68437
68958
  if (dateMatch && dateMatch[1] < cutoffStr) {
68438
68959
  try {
68439
- fs19.unlinkSync(path322.join(LOG_DIR2, file2));
68960
+ fs20.unlinkSync(path33.join(LOG_DIR2, file2));
68440
68961
  } catch {
68441
68962
  }
68442
68963
  }
@@ -68446,14 +68967,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68446
68967
  }
68447
68968
  function checkSize() {
68448
68969
  try {
68449
- const stat2 = fs19.statSync(currentFile);
68970
+ const stat2 = fs20.statSync(currentFile);
68450
68971
  if (stat2.size > MAX_FILE_SIZE) {
68451
68972
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
68452
68973
  try {
68453
- fs19.unlinkSync(backup);
68974
+ fs20.unlinkSync(backup);
68454
68975
  } catch {
68455
68976
  }
68456
- fs19.renameSync(currentFile, backup);
68977
+ fs20.renameSync(currentFile, backup);
68457
68978
  }
68458
68979
  } catch {
68459
68980
  }
@@ -68486,14 +69007,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68486
69007
  ...entry.error ? { err: entry.error } : {},
68487
69008
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
68488
69009
  });
68489
- fs19.appendFileSync(currentFile, line + "\n");
69010
+ fs20.appendFileSync(currentFile, line + "\n");
68490
69011
  } catch {
68491
69012
  }
68492
69013
  }
68493
69014
  function getRecentCommands(count = 50) {
68494
69015
  try {
68495
- if (!fs19.existsSync(currentFile)) return [];
68496
- const content = fs19.readFileSync(currentFile, "utf-8");
69016
+ if (!fs20.existsSync(currentFile)) return [];
69017
+ const content = fs20.readFileSync(currentFile, "utf-8");
68497
69018
  const lines = content.trim().split("\n").filter(Boolean);
68498
69019
  return lines.slice(-count).map((line) => {
68499
69020
  try {
@@ -68539,10 +69060,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68539
69060
  }
68540
69061
  }
68541
69062
  function readRecord3(repoRoot) {
68542
- const path39 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
68543
- if (!(0, import_node_fs4.existsSync)(path39)) return null;
69063
+ const path40 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
69064
+ if (!(0, import_node_fs4.existsSync)(path40)) return null;
68544
69065
  try {
68545
- const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path39, "utf8"));
69066
+ const parsed = JSON.parse((0, import_node_fs4.readFileSync)(path40, "utf8"));
68546
69067
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
68547
69068
  } catch {
68548
69069
  return null;
@@ -68602,7 +69123,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68602
69123
  nextAction
68603
69124
  };
68604
69125
  }
68605
- var os24 = __toESM2(require("os"));
69126
+ var os25 = __toESM2(require("os"));
68606
69127
  init_config();
68607
69128
  init_terminal_screen();
68608
69129
  init_logger();
@@ -68641,25 +69162,50 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68641
69162
  }
68642
69163
  function buildAvailableProviders(providerLoader) {
68643
69164
  const providers = providerLoader.getAvailableProviderInfos?.() || providerLoader.getAll();
68644
- return providers.map((provider) => ({
68645
- type: provider.type,
68646
- name: provider.displayName || provider.type,
68647
- displayName: provider.displayName || provider.type,
68648
- icon: provider.icon || "\u{1F4BB}",
68649
- category: provider.category,
68650
- ...provider.installed !== void 0 ? { installed: provider.installed } : {},
68651
- ...provider.detectedPath !== void 0 ? { detectedPath: provider.detectedPath } : {},
68652
- ...provider.enabled !== void 0 ? { enabled: provider.enabled } : {},
68653
- ...provider.machineStatus !== void 0 ? { machineStatus: provider.machineStatus } : {},
68654
- ...provider.lastDetection !== void 0 ? { lastDetection: provider.lastDetection } : {},
68655
- ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {},
68656
- ...provider.meshCoordinator !== void 0 ? { meshCoordinator: provider.meshCoordinator } : {}
68657
- }));
69165
+ let describeTrust2 = () => "";
69166
+ let requiresConfirmation2 = () => false;
69167
+ try {
69168
+ const mod = (init_provider_trust(), __toCommonJS2(provider_trust_exports));
69169
+ describeTrust2 = mod.describeTrust;
69170
+ requiresConfirmation2 = mod.requiresConfirmation;
69171
+ } catch {
69172
+ }
69173
+ return providers.map((provider) => {
69174
+ const trust = provider._sourceTrust;
69175
+ const sourceLayer = provider._sourceLayer;
69176
+ const sourceName = provider._sourceName;
69177
+ return {
69178
+ type: provider.type,
69179
+ name: provider.displayName || provider.type,
69180
+ displayName: provider.displayName || provider.type,
69181
+ icon: provider.icon || "\u{1F4BB}",
69182
+ category: provider.category,
69183
+ ...provider.installed !== void 0 ? { installed: provider.installed } : {},
69184
+ ...provider.detectedPath !== void 0 ? { detectedPath: provider.detectedPath } : {},
69185
+ ...provider.enabled !== void 0 ? { enabled: provider.enabled } : {},
69186
+ ...provider.machineStatus !== void 0 ? { machineStatus: provider.machineStatus } : {},
69187
+ ...provider.lastDetection !== void 0 ? { lastDetection: provider.lastDetection } : {},
69188
+ ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {},
69189
+ ...provider.meshCoordinator !== void 0 ? { meshCoordinator: provider.meshCoordinator } : {},
69190
+ ...trust ? {
69191
+ trust,
69192
+ trustDescription: describeTrust2(trust),
69193
+ requiresConfirmation: requiresConfirmation2(trust)
69194
+ } : {},
69195
+ ...sourceLayer ? { sourceLayer } : {},
69196
+ ...sourceName ? { sourceName } : {},
69197
+ ...provider.providerVersion ? { providerVersion: provider.providerVersion } : {},
69198
+ ...provider.binary ? { binary: provider.binary } : {},
69199
+ ...provider.status ? { status: provider.status } : {},
69200
+ ...provider.details ? { details: provider.details } : {},
69201
+ ...provider.links ? { links: provider.links } : {}
69202
+ };
69203
+ });
68658
69204
  }
68659
69205
  function buildMachineInfo2(profile = "full") {
68660
69206
  const base = {
68661
- hostname: os24.hostname(),
68662
- platform: os24.platform()
69207
+ hostname: os25.hostname(),
69208
+ platform: os25.platform()
68663
69209
  };
68664
69210
  if (profile === "live") {
68665
69211
  return base;
@@ -68668,23 +69214,23 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68668
69214
  const memSnap2 = getHostMemorySnapshot();
68669
69215
  return {
68670
69216
  ...base,
68671
- arch: os24.arch(),
68672
- cpus: os24.cpus().length,
69217
+ arch: os25.arch(),
69218
+ cpus: os25.cpus().length,
68673
69219
  totalMem: memSnap2.totalMem,
68674
- release: os24.release()
69220
+ release: os25.release()
68675
69221
  };
68676
69222
  }
68677
69223
  const memSnap = getHostMemorySnapshot();
68678
69224
  return {
68679
69225
  ...base,
68680
- arch: os24.arch(),
68681
- cpus: os24.cpus().length,
69226
+ arch: os25.arch(),
69227
+ cpus: os25.cpus().length,
68682
69228
  totalMem: memSnap.totalMem,
68683
69229
  freeMem: memSnap.freeMem,
68684
69230
  availableMem: memSnap.availableMem,
68685
- loadavg: os24.loadavg(),
68686
- uptime: os24.uptime(),
68687
- release: os24.release()
69231
+ loadavg: os25.loadavg(),
69232
+ uptime: os25.uptime(),
69233
+ release: os25.release()
68688
69234
  };
68689
69235
  }
68690
69236
  function parseMessageTime(value) {
@@ -68923,42 +69469,42 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68923
69469
  }
68924
69470
  var import_child_process7 = require("child_process");
68925
69471
  var import_child_process8 = require("child_process");
68926
- var fs20 = __toESM2(require("fs"));
68927
- var os25 = __toESM2(require("os"));
68928
- var path33 = __toESM2(require("path"));
69472
+ var fs21 = __toESM2(require("fs"));
69473
+ var os26 = __toESM2(require("os"));
69474
+ var path34 = __toESM2(require("path"));
68929
69475
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
68930
69476
  function getUpgradeLogPath() {
68931
- const home = os25.homedir();
68932
- const dir = path33.join(home, ".adhdev");
68933
- fs20.mkdirSync(dir, { recursive: true });
68934
- return path33.join(dir, "daemon-upgrade.log");
69477
+ const home = os26.homedir();
69478
+ const dir = path34.join(home, ".adhdev");
69479
+ fs21.mkdirSync(dir, { recursive: true });
69480
+ return path34.join(dir, "daemon-upgrade.log");
68935
69481
  }
68936
69482
  function appendUpgradeLog(message) {
68937
69483
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
68938
69484
  `;
68939
69485
  try {
68940
- fs20.appendFileSync(getUpgradeLogPath(), line, "utf8");
69486
+ fs21.appendFileSync(getUpgradeLogPath(), line, "utf8");
68941
69487
  } catch {
68942
69488
  }
68943
69489
  }
68944
69490
  function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
68945
- const binDir = path33.dirname(nodeExecutable);
69491
+ const binDir = path34.dirname(nodeExecutable);
68946
69492
  if (platform10 === "win32") {
68947
- const npmCliPath = path33.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
68948
- if (fs20.existsSync(npmCliPath)) {
69493
+ const npmCliPath = path34.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
69494
+ if (fs21.existsSync(npmCliPath)) {
68949
69495
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
68950
69496
  }
68951
69497
  for (const candidate of ["npm.exe", "npm"]) {
68952
- const candidatePath = path33.join(binDir, candidate);
68953
- if (fs20.existsSync(candidatePath)) {
69498
+ const candidatePath = path34.join(binDir, candidate);
69499
+ if (fs21.existsSync(candidatePath)) {
68954
69500
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
68955
69501
  }
68956
69502
  }
68957
69503
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
68958
69504
  }
68959
69505
  for (const candidate of ["npm"]) {
68960
- const candidatePath = path33.join(binDir, candidate);
68961
- if (fs20.existsSync(candidatePath)) {
69506
+ const candidatePath = path34.join(binDir, candidate);
69507
+ if (fs21.existsSync(candidatePath)) {
68962
69508
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
68963
69509
  }
68964
69510
  }
@@ -68968,22 +69514,22 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68968
69514
  if (!currentCliPath) return null;
68969
69515
  let resolvedPath = currentCliPath;
68970
69516
  try {
68971
- resolvedPath = fs20.realpathSync.native(currentCliPath);
69517
+ resolvedPath = fs21.realpathSync.native(currentCliPath);
68972
69518
  } catch {
68973
69519
  }
68974
69520
  let currentDir = resolvedPath;
68975
69521
  try {
68976
- if (fs20.statSync(resolvedPath).isFile()) {
68977
- currentDir = path33.dirname(resolvedPath);
69522
+ if (fs21.statSync(resolvedPath).isFile()) {
69523
+ currentDir = path34.dirname(resolvedPath);
68978
69524
  }
68979
69525
  } catch {
68980
- currentDir = path33.dirname(resolvedPath);
69526
+ currentDir = path34.dirname(resolvedPath);
68981
69527
  }
68982
69528
  while (true) {
68983
- const packageJsonPath = path33.join(currentDir, "package.json");
69529
+ const packageJsonPath = path34.join(currentDir, "package.json");
68984
69530
  try {
68985
- if (fs20.existsSync(packageJsonPath)) {
68986
- const parsed = JSON.parse(fs20.readFileSync(packageJsonPath, "utf8"));
69531
+ if (fs21.existsSync(packageJsonPath)) {
69532
+ const parsed = JSON.parse(fs21.readFileSync(packageJsonPath, "utf8"));
68987
69533
  if (parsed?.name === packageName) {
68988
69534
  const normalized = currentDir.replace(/\\/g, "/");
68989
69535
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -68991,7 +69537,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68991
69537
  }
68992
69538
  } catch {
68993
69539
  }
68994
- const parentDir = path33.dirname(currentDir);
69540
+ const parentDir = path34.dirname(currentDir);
68995
69541
  if (parentDir === currentDir) {
68996
69542
  return null;
68997
69543
  }
@@ -68999,13 +69545,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
68999
69545
  }
69000
69546
  }
69001
69547
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
69002
- const nodeModulesDir = packageName.startsWith("@") ? path33.dirname(path33.dirname(packageRoot)) : path33.dirname(packageRoot);
69003
- if (path33.basename(nodeModulesDir) !== "node_modules") {
69548
+ const nodeModulesDir = packageName.startsWith("@") ? path34.dirname(path34.dirname(packageRoot)) : path34.dirname(packageRoot);
69549
+ if (path34.basename(nodeModulesDir) !== "node_modules") {
69004
69550
  return null;
69005
69551
  }
69006
- const maybeLibDir = path33.dirname(nodeModulesDir);
69007
- if (path33.basename(maybeLibDir) === "lib") {
69008
- return path33.dirname(maybeLibDir);
69552
+ const maybeLibDir = path34.dirname(nodeModulesDir);
69553
+ if (path34.basename(maybeLibDir) === "lib") {
69554
+ return path34.dirname(maybeLibDir);
69009
69555
  }
69010
69556
  return maybeLibDir;
69011
69557
  }
@@ -69120,10 +69666,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69120
69666
  }
69121
69667
  }
69122
69668
  function stopSessionHostProcesses(appName) {
69123
- const pidFile = path33.join(os25.homedir(), ".adhdev", `${appName}-session-host.pid`);
69669
+ const pidFile = path34.join(os26.homedir(), ".adhdev", `${appName}-session-host.pid`);
69124
69670
  try {
69125
- if (fs20.existsSync(pidFile)) {
69126
- const pid = Number.parseInt(fs20.readFileSync(pidFile, "utf8").trim(), 10);
69671
+ if (fs21.existsSync(pidFile)) {
69672
+ const pid = Number.parseInt(fs21.readFileSync(pidFile, "utf8").trim(), 10);
69127
69673
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
69128
69674
  killPid2(pid);
69129
69675
  }
@@ -69131,15 +69677,15 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69131
69677
  } catch {
69132
69678
  } finally {
69133
69679
  try {
69134
- fs20.unlinkSync(pidFile);
69680
+ fs21.unlinkSync(pidFile);
69135
69681
  } catch {
69136
69682
  }
69137
69683
  }
69138
69684
  }
69139
69685
  function removeDaemonPidFile() {
69140
- const pidFile = path33.join(os25.homedir(), ".adhdev", "daemon.pid");
69686
+ const pidFile = path34.join(os26.homedir(), ".adhdev", "daemon.pid");
69141
69687
  try {
69142
- fs20.unlinkSync(pidFile);
69688
+ fs21.unlinkSync(pidFile);
69143
69689
  } catch {
69144
69690
  }
69145
69691
  }
@@ -69148,7 +69694,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69148
69694
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
69149
69695
  if (!npmRoot) return;
69150
69696
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
69151
- const binDir = process.platform === "win32" ? npmPrefix : path33.join(npmPrefix, "bin");
69697
+ const binDir = process.platform === "win32" ? npmPrefix : path34.join(npmPrefix, "bin");
69152
69698
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
69153
69699
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
69154
69700
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -69156,25 +69702,25 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69156
69702
  }
69157
69703
  if (pkgName.startsWith("@")) {
69158
69704
  const [scope, name] = pkgName.split("/");
69159
- const scopeDir = path33.join(npmRoot, scope);
69160
- if (!fs20.existsSync(scopeDir)) return;
69161
- for (const entry of fs20.readdirSync(scopeDir)) {
69705
+ const scopeDir = path34.join(npmRoot, scope);
69706
+ if (!fs21.existsSync(scopeDir)) return;
69707
+ for (const entry of fs21.readdirSync(scopeDir)) {
69162
69708
  if (!entry.startsWith(`.${name}-`)) continue;
69163
- fs20.rmSync(path33.join(scopeDir, entry), { recursive: true, force: true });
69164
- appendUpgradeLog(`Removed stale scoped staging dir: ${path33.join(scopeDir, entry)}`);
69709
+ fs21.rmSync(path34.join(scopeDir, entry), { recursive: true, force: true });
69710
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path34.join(scopeDir, entry)}`);
69165
69711
  }
69166
69712
  } else {
69167
- for (const entry of fs20.readdirSync(npmRoot)) {
69713
+ for (const entry of fs21.readdirSync(npmRoot)) {
69168
69714
  if (!entry.startsWith(`.${pkgName}-`)) continue;
69169
- fs20.rmSync(path33.join(npmRoot, entry), { recursive: true, force: true });
69170
- appendUpgradeLog(`Removed stale staging dir: ${path33.join(npmRoot, entry)}`);
69715
+ fs21.rmSync(path34.join(npmRoot, entry), { recursive: true, force: true });
69716
+ appendUpgradeLog(`Removed stale staging dir: ${path34.join(npmRoot, entry)}`);
69171
69717
  }
69172
69718
  }
69173
- if (fs20.existsSync(binDir)) {
69174
- for (const entry of fs20.readdirSync(binDir)) {
69719
+ if (fs21.existsSync(binDir)) {
69720
+ for (const entry of fs21.readdirSync(binDir)) {
69175
69721
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
69176
- fs20.rmSync(path33.join(binDir, entry), { recursive: true, force: true });
69177
- appendUpgradeLog(`Removed stale bin staging entry: ${path33.join(binDir, entry)}`);
69722
+ fs21.rmSync(path34.join(binDir, entry), { recursive: true, force: true });
69723
+ appendUpgradeLog(`Removed stale bin staging entry: ${path34.join(binDir, entry)}`);
69178
69724
  }
69179
69725
  }
69180
69726
  }
@@ -69260,7 +69806,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69260
69806
  init_mesh_work_queue();
69261
69807
  var import_os3 = require("os");
69262
69808
  var import_path10 = require("path");
69263
- var fs21 = __toESM2(require("fs"));
69809
+ var fs222 = __toESM2(require("fs"));
69264
69810
  var import_node_child_process5 = require("child_process");
69265
69811
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
69266
69812
  var CHANNEL_SERVER_URL = {
@@ -69387,12 +69933,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69387
69933
  if (!Array.isArray(value)) return void 0;
69388
69934
  const submodules = value.map((entry) => {
69389
69935
  const submodule = readObjectRecord(entry);
69390
- const path39 = readStringValue(submodule.path);
69936
+ const path40 = readStringValue(submodule.path);
69391
69937
  const commit = readStringValue(submodule.commit);
69392
- const repoPath = readStringValue(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path39);
69393
- if (!path39 || !commit || !repoPath) return null;
69938
+ const repoPath = readStringValue(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
69939
+ if (!path40 || !commit || !repoPath) return null;
69394
69940
  return {
69395
- path: path39,
69941
+ path: path40,
69396
69942
  commit,
69397
69943
  repoPath,
69398
69944
  dirty: readBooleanValue(submodule.dirty) ?? false,
@@ -70034,7 +70580,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
70034
70580
  if (!isSelfNode && daemonId) unavailableNodeIds.push(nodeId);
70035
70581
  continue;
70036
70582
  }
70037
- if (fs21.existsSync(workspace)) {
70583
+ if (fs222.existsSync(workspace)) {
70038
70584
  try {
70039
70585
  const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
70040
70586
  if (localGit?.isGitRepo) {
@@ -70119,7 +70665,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
70119
70665
  }
70120
70666
  function collectLiveMeshSessionRecords(args) {
70121
70667
  const nodeWorkspace = readStringValue(args.node?.workspace);
70122
- const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs21.existsSync(nodeWorkspace);
70668
+ const nodeIsMissingLocalWorktree = args.node?.isLocalWorktree === true && !!nodeWorkspace && !fs222.existsSync(nodeWorkspace);
70123
70669
  const matches = args.liveSessionRecords.filter((record2) => {
70124
70670
  const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
70125
70671
  if (recordNodeId && recordNodeId !== args.nodeId) return false;
@@ -70146,7 +70692,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
70146
70692
  const workspace = readStringValue(node?.workspace);
70147
70693
  if (nodeId) liveNodeIds.add(nodeId);
70148
70694
  if (workspace) liveWorkspaces.add(workspace);
70149
- if (nodeId && node?.isLocalWorktree === true && workspace && !fs21.existsSync(workspace)) {
70695
+ if (nodeId && node?.isLocalWorktree === true && workspace && !fs222.existsSync(workspace)) {
70150
70696
  missingLocalWorktreeNodeIds.add(nodeId);
70151
70697
  }
70152
70698
  }
@@ -70345,10 +70891,10 @@ ${e?.stderr || ""}`
70345
70891
  }
70346
70892
  function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
70347
70893
  if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
70348
- const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path39) => ({
70349
- path: path39,
70350
- baseCommit: readTreeObject(repoRoot, baseHead, path39),
70351
- branchCommit: readTreeObject(repoRoot, branchHead, path39)
70894
+ const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => ({
70895
+ path: path40,
70896
+ baseCommit: readTreeObject(repoRoot, baseHead, path40),
70897
+ branchCommit: readTreeObject(repoRoot, branchHead, path40)
70352
70898
  }));
70353
70899
  if (conflicts.length === 0) return void 0;
70354
70900
  return {
@@ -70374,11 +70920,11 @@ ${e?.stderr || ""}`
70374
70920
  if (!line.trim()) continue;
70375
70921
  const metaAndPath = line.split(" ");
70376
70922
  const meta3 = metaAndPath[0] || "";
70377
- const path39 = metaAndPath[metaAndPath.length - 1]?.trim();
70378
- if (!path39) continue;
70923
+ const path40 = metaAndPath[metaAndPath.length - 1]?.trim();
70924
+ if (!path40) continue;
70379
70925
  const parts = meta3.split(/\s+/);
70380
70926
  if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
70381
- paths.add(path39);
70927
+ paths.add(path40);
70382
70928
  }
70383
70929
  }
70384
70930
  return [...paths].sort();
@@ -70386,9 +70932,9 @@ ${e?.stderr || ""}`
70386
70932
  return [];
70387
70933
  }
70388
70934
  }
70389
- function readTreeObject(repoRoot, ref, path39) {
70935
+ function readTreeObject(repoRoot, ref, path40) {
70390
70936
  try {
70391
- const output = (0, import_node_child_process5.execFileSync)("git", ["ls-tree", ref, "--", path39], {
70937
+ const output = (0, import_node_child_process5.execFileSync)("git", ["ls-tree", ref, "--", path40], {
70392
70938
  cwd: repoRoot,
70393
70939
  encoding: "utf8",
70394
70940
  maxBuffer: 1024 * 1024
@@ -70401,7 +70947,7 @@ ${e?.stderr || ""}`
70401
70947
  }
70402
70948
  async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
70403
70949
  const startedAt = Date.now();
70404
- const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path39) => !(options.submoduleIgnorePaths || []).includes(path39));
70950
+ const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path40) => !(options.submoduleIgnorePaths || []).includes(path40));
70405
70951
  const preStatus = await getGitRepoStatus(repoRoot, {
70406
70952
  includeSubmodules: true,
70407
70953
  submoduleIgnorePaths: options.submoduleIgnorePaths,
@@ -70442,7 +70988,7 @@ ${e?.stderr || ""}`
70442
70988
  changedGitlinkPaths,
70443
70989
  outOfSyncPaths,
70444
70990
  updatedPaths: updatePaths,
70445
- verifiedPaths: updatePaths.filter((path39) => !remaining.some((submodule) => submodule.path === path39)),
70991
+ verifiedPaths: updatePaths.filter((path40) => !remaining.some((submodule) => submodule.path === path40)),
70446
70992
  durationMs: Date.now() - startedAt,
70447
70993
  command: `git ${commandArgs.join(" ")}`,
70448
70994
  stdout: truncateValidationOutput(result.stdout),
@@ -70497,7 +71043,7 @@ ${e?.stderr || ""}`
70497
71043
  return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
70498
71044
  };
70499
71045
  const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
70500
- if (!fs21.existsSync(worktreeSubmodulePath)) return false;
71046
+ if (!fs222.existsSync(worktreeSubmodulePath)) return false;
70501
71047
  try {
70502
71048
  await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
70503
71049
  } catch {
@@ -70520,7 +71066,7 @@ ${e?.stderr || ""}`
70520
71066
  reachable: false
70521
71067
  };
70522
71068
  try {
70523
- if (!fs21.existsSync(submodulePath)) {
71069
+ if (!fs222.existsSync(submodulePath)) {
70524
71070
  entry.error = `Submodule checkout missing at ${gitlink.path}`;
70525
71071
  entry.publishRequired = true;
70526
71072
  if (options.allowAutoPublishSubmoduleMainCommits === true) {
@@ -70712,9 +71258,9 @@ ${e?.stderr || ""}`
70712
71258
  return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
70713
71259
  };
70714
71260
  const dependenciesLikelyMissing = (cwd) => {
70715
- if (!fs21.existsSync((0, import_path10.join)(cwd, "package.json"))) return false;
70716
- if (fs21.existsSync((0, import_path10.join)(cwd, "node_modules"))) return false;
70717
- return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs21.existsSync((0, import_path10.join)(cwd, lock)));
71261
+ if (!fs222.existsSync((0, import_path10.join)(cwd, "package.json"))) return false;
71262
+ if (fs222.existsSync((0, import_path10.join)(cwd, "node_modules"))) return false;
71263
+ return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs222.existsSync((0, import_path10.join)(cwd, lock)));
70718
71264
  };
70719
71265
  for (const candidate of selection.bootstrapCommands) {
70720
71266
  const startedAt = Date.now();
@@ -70811,9 +71357,9 @@ ${e?.stderr || ""}`
70811
71357
  function loadHermesCoordinatorBaseConfig(targetConfigPath) {
70812
71358
  const sourceHome = resolveHermesUserHome();
70813
71359
  const sourceConfigPath = (0, import_path10.join)(sourceHome, "config.yaml");
70814
- if (!fs21.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
71360
+ if (!fs222.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
70815
71361
  if ((0, import_path10.resolve)(sourceConfigPath) === (0, import_path10.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
70816
- const parsed = parseMeshCoordinatorMcpConfig(fs21.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
71362
+ const parsed = parseMeshCoordinatorMcpConfig(fs222.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
70817
71363
  const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
70818
71364
  return { config: baseConfig, sourceHome, sourceConfigPath };
70819
71365
  }
@@ -70850,9 +71396,9 @@ ${e?.stderr || ""}`
70850
71396
  for (const fileName of [".env", "auth.json"]) {
70851
71397
  const sourcePath = (0, import_path10.join)(sourceHome, fileName);
70852
71398
  const targetPath = (0, import_path10.join)(targetHome, fileName);
70853
- if (!fs21.existsSync(sourcePath)) continue;
71399
+ if (!fs222.existsSync(sourcePath)) continue;
70854
71400
  try {
70855
- fs21.copyFileSync(sourcePath, targetPath);
71401
+ fs222.copyFileSync(sourcePath, targetPath);
70856
71402
  } catch (error48) {
70857
71403
  LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
70858
71404
  }
@@ -71207,13 +71753,13 @@ ${e?.stderr || ""}`
71207
71753
  recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
71208
71754
  };
71209
71755
  }
71210
- const worktreeExists = fs21.existsSync(workspace);
71756
+ const worktreeExists = fs222.existsSync(workspace);
71211
71757
  const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => n.id === args.node.clonedFromNodeId || n.nodeId === args.node.clonedFromNodeId) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
71212
71758
  const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
71213
71759
  if (!worktreeExists) {
71214
71760
  return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
71215
71761
  }
71216
- if (!repoRoot || !fs21.existsSync(repoRoot)) {
71762
+ if (!repoRoot || !fs222.existsSync(repoRoot)) {
71217
71763
  return {
71218
71764
  success: false,
71219
71765
  code: "mesh_worktree_cleanup_missing_source_repo",
@@ -71233,7 +71779,7 @@ ${e?.stderr || ""}`
71233
71779
  const normalizePath = (value) => {
71234
71780
  const resolved = (0, import_path10.resolve)(value);
71235
71781
  try {
71236
- return fs21.realpathSync(resolved);
71782
+ return fs222.realpathSync(resolved);
71237
71783
  } catch {
71238
71784
  return resolved;
71239
71785
  }
@@ -72172,8 +72718,8 @@ ${e?.stderr || ""}`
72172
72718
  if (sinceTs > 0) {
72173
72719
  return { success: true, logs: [], totalBuffered: 0 };
72174
72720
  }
72175
- if (fs21.existsSync(LOG_PATH)) {
72176
- const content = fs21.readFileSync(LOG_PATH, "utf-8");
72721
+ if (fs222.existsSync(LOG_PATH)) {
72722
+ const content = fs222.readFileSync(LOG_PATH, "utf-8");
72177
72723
  const allLines = content.split("\n");
72178
72724
  const recent = allLines.slice(-count).join("\n");
72179
72725
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -72563,24 +73109,24 @@ ${e?.stderr || ""}`
72563
73109
  // Settings page in the dashboard reads/writes via these two
72564
73110
  // commands instead of going through fs from the browser.
72565
73111
  case "list_coordinator_prompts": {
72566
- const fs27 = await import("fs");
72567
- const path39 = await import("path");
72568
- const os28 = await import("os");
72569
- const dir = path39.join(os28.homedir(), ".adhdev", "coordinator-prompts");
73112
+ const fs28 = await import("fs");
73113
+ const path40 = await import("path");
73114
+ const os29 = await import("os");
73115
+ const dir = path40.join(os29.homedir(), ".adhdev", "coordinator-prompts");
72570
73116
  const entries = {};
72571
73117
  try {
72572
- if (fs27.existsSync(dir)) {
72573
- for (const name of fs27.readdirSync(dir)) {
73118
+ if (fs28.existsSync(dir)) {
73119
+ for (const name of fs28.readdirSync(dir)) {
72574
73120
  const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
72575
73121
  const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
72576
73122
  const m = matchAppend || matchOverride;
72577
73123
  if (!m) continue;
72578
73124
  const isAppend = !!matchAppend;
72579
73125
  const key = m[1];
72580
- const full = path39.join(dir, name);
73126
+ const full = path40.join(dir, name);
72581
73127
  let content = "";
72582
73128
  try {
72583
- content = fs27.readFileSync(full, "utf8");
73129
+ content = fs28.readFileSync(full, "utf8");
72584
73130
  } catch {
72585
73131
  }
72586
73132
  if (!entries[key]) entries[key] = { override: "", append: "" };
@@ -72594,24 +73140,24 @@ ${e?.stderr || ""}`
72594
73140
  return { success: true, dir, entries };
72595
73141
  }
72596
73142
  case "write_coordinator_prompt": {
72597
- const fs27 = await import("fs");
72598
- const path39 = await import("path");
72599
- const os28 = await import("os");
73143
+ const fs28 = await import("fs");
73144
+ const path40 = await import("path");
73145
+ const os29 = await import("os");
72600
73146
  const key = typeof args?.key === "string" ? args.key.trim() : "";
72601
73147
  const kind = args?.kind === "append" ? "append" : "override";
72602
73148
  const content = typeof args?.content === "string" ? args.content : "";
72603
73149
  if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
72604
73150
  return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
72605
73151
  }
72606
- const dir = path39.join(os28.homedir(), ".adhdev", "coordinator-prompts");
73152
+ const dir = path40.join(os29.homedir(), ".adhdev", "coordinator-prompts");
72607
73153
  const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
72608
- const full = path39.join(dir, filename);
73154
+ const full = path40.join(dir, filename);
72609
73155
  try {
72610
- fs27.mkdirSync(dir, { recursive: true });
73156
+ fs28.mkdirSync(dir, { recursive: true });
72611
73157
  if (content.trim()) {
72612
- fs27.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
72613
- } else if (fs27.existsSync(full)) {
72614
- fs27.unlinkSync(full);
73158
+ fs28.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
73159
+ } else if (fs28.existsSync(full)) {
73160
+ fs28.unlinkSync(full);
72615
73161
  }
72616
73162
  return { success: true, path: full, kind, key };
72617
73163
  } catch (error48) {
@@ -73820,7 +74366,7 @@ ${ptyResult.output.slice(-2e3)}`);
73820
74366
  workspace
73821
74367
  };
73822
74368
  }
73823
- const { existsSync: existsSync38, readFileSync: readFileSync32, writeFileSync: writeFileSync19, copyFileSync: copyFileSync4, mkdirSync: mkdirSync18 } = await import("fs");
74369
+ const { existsSync: existsSync39, readFileSync: readFileSync33, writeFileSync: writeFileSync20, copyFileSync: copyFileSync4, mkdirSync: mkdirSync19 } = await import("fs");
73824
74370
  const { dirname: dirname11 } = await import("path");
73825
74371
  const mcpConfigPath = coordinatorSetup.configPath;
73826
74372
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -73856,21 +74402,21 @@ ${ptyResult.output.slice(-2e3)}`);
73856
74402
  };
73857
74403
  }
73858
74404
  try {
73859
- mkdirSync18(dirname11(mcpConfigPath), { recursive: true });
74405
+ mkdirSync19(dirname11(mcpConfigPath), { recursive: true });
73860
74406
  } catch (error48) {
73861
74407
  const message = `Could not prepare MCP config path for automatic setup: ${error48?.message || error48}`;
73862
74408
  LOG2.error("MeshCoordinator", message);
73863
74409
  if (hermesManualFallback) return returnManualFallback(message);
73864
74410
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
73865
74411
  }
73866
- const hadExistingMcpConfig = existsSync38(mcpConfigPath);
74412
+ const hadExistingMcpConfig = existsSync39(mcpConfigPath);
73867
74413
  let existingMcpConfig = hermesBaseConfig?.config || {};
73868
74414
  if (hermesBaseConfig) {
73869
74415
  copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname11(mcpConfigPath));
73870
74416
  }
73871
74417
  if (hadExistingMcpConfig) {
73872
74418
  try {
73873
- const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync32(mcpConfigPath, "utf-8"), configFormat);
74419
+ const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync33(mcpConfigPath, "utf-8"), configFormat);
73874
74420
  const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
73875
74421
  existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
73876
74422
  copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
@@ -73893,7 +74439,7 @@ ${ptyResult.output.slice(-2e3)}`);
73893
74439
  }
73894
74440
  };
73895
74441
  try {
73896
- writeFileSync19(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
74442
+ writeFileSync20(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
73897
74443
  } catch (error48) {
73898
74444
  const message = `Could not write MCP config for automatic setup: ${error48?.message || error48}`;
73899
74445
  LOG2.error("MeshCoordinator", message);
@@ -74172,7 +74718,7 @@ ${ptyResult.output.slice(-2e3)}`);
74172
74718
  }
74173
74719
  }
74174
74720
  if (workspace) {
74175
- if (!fs21.existsSync(workspace)) {
74721
+ if (!fs222.existsSync(workspace)) {
74176
74722
  const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
74177
74723
  let remoteProbeApplied = false;
74178
74724
  if (inlineTransitGit) {
@@ -74285,7 +74831,7 @@ ${ptyResult.output.slice(-2e3)}`);
74285
74831
  const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
74286
74832
  const pendingCoordinatorEvents = drainPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
74287
74833
  const previewFreshness = (() => {
74288
- const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs21.existsSync(candidate));
74834
+ const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs222.existsSync(candidate));
74289
74835
  return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
74290
74836
  })();
74291
74837
  const asyncRefineJobs = buildMeshAsyncRefineJobs({
@@ -76010,12 +76556,12 @@ ${ptyResult.output.slice(-2e3)}`);
76010
76556
  this.eventListeners = [];
76011
76557
  }
76012
76558
  };
76013
- var fs222 = __toESM2(require("fs"));
76014
- var path34 = __toESM2(require("path"));
76015
- var os26 = __toESM2(require("os"));
76559
+ var fs23 = __toESM2(require("fs"));
76560
+ var path35 = __toESM2(require("path"));
76561
+ var os27 = __toESM2(require("os"));
76016
76562
  var import_os4 = require("os");
76017
76563
  var import_child_process9 = require("child_process");
76018
- var ARCHIVE_PATH = path34.join(os26.homedir(), ".adhdev", "version-history.json");
76564
+ var ARCHIVE_PATH = path35.join(os27.homedir(), ".adhdev", "version-history.json");
76019
76565
  var MAX_ENTRIES_PER_PROVIDER = 20;
76020
76566
  var VersionArchive = class {
76021
76567
  history = {};
@@ -76024,8 +76570,8 @@ ${ptyResult.output.slice(-2e3)}`);
76024
76570
  }
76025
76571
  load() {
76026
76572
  try {
76027
- if (fs222.existsSync(ARCHIVE_PATH)) {
76028
- this.history = JSON.parse(fs222.readFileSync(ARCHIVE_PATH, "utf-8"));
76573
+ if (fs23.existsSync(ARCHIVE_PATH)) {
76574
+ this.history = JSON.parse(fs23.readFileSync(ARCHIVE_PATH, "utf-8"));
76029
76575
  }
76030
76576
  } catch {
76031
76577
  this.history = {};
@@ -76062,8 +76608,8 @@ ${ptyResult.output.slice(-2e3)}`);
76062
76608
  }
76063
76609
  save() {
76064
76610
  try {
76065
- fs222.mkdirSync(path34.dirname(ARCHIVE_PATH), { recursive: true });
76066
- fs222.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
76611
+ fs23.mkdirSync(path35.dirname(ARCHIVE_PATH), { recursive: true });
76612
+ fs23.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
76067
76613
  } catch {
76068
76614
  }
76069
76615
  }
@@ -76086,10 +76632,10 @@ ${ptyResult.output.slice(-2e3)}`);
76086
76632
  for (const p of paths) {
76087
76633
  if (!p) continue;
76088
76634
  for (const ext of exes) {
76089
- const fullPath = path34.join(p, name + ext);
76635
+ const fullPath = path35.join(p, name + ext);
76090
76636
  try {
76091
- if (fs222.existsSync(fullPath)) {
76092
- const stat2 = fs222.statSync(fullPath);
76637
+ if (fs23.existsSync(fullPath)) {
76638
+ const stat2 = fs23.statSync(fullPath);
76093
76639
  if (stat2.isFile() && (isWin || stat2.mode & 73)) {
76094
76640
  return fullPath;
76095
76641
  }
@@ -76134,19 +76680,19 @@ ${ptyResult.output.slice(-2e3)}`);
76134
76680
  function checkPathExists2(paths) {
76135
76681
  for (const p of paths) {
76136
76682
  if (p.includes("*")) {
76137
- const home = os26.homedir();
76138
- const resolved = p.replace(/\*/g, home.split(path34.sep).pop() || "");
76139
- if (fs222.existsSync(resolved)) return resolved;
76683
+ const home = os27.homedir();
76684
+ const resolved = p.replace(/\*/g, home.split(path35.sep).pop() || "");
76685
+ if (fs23.existsSync(resolved)) return resolved;
76140
76686
  } else {
76141
- if (fs222.existsSync(p)) return p;
76687
+ if (fs23.existsSync(p)) return p;
76142
76688
  }
76143
76689
  }
76144
76690
  return null;
76145
76691
  }
76146
76692
  async function getMacAppVersion(appPath) {
76147
76693
  if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
76148
- const plistPath = path34.join(appPath, "Contents", "Info.plist");
76149
- if (!fs222.existsSync(plistPath)) return null;
76694
+ const plistPath = path35.join(appPath, "Contents", "Info.plist");
76695
+ if (!fs23.existsSync(plistPath)) return null;
76150
76696
  const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
76151
76697
  return raw || null;
76152
76698
  }
@@ -76171,8 +76717,8 @@ ${ptyResult.output.slice(-2e3)}`);
76171
76717
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
76172
76718
  let resolvedBin = cliBin;
76173
76719
  if (!resolvedBin && appPath && currentOs === "darwin") {
76174
- const bundled = path34.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
76175
- if (provider.cli && fs222.existsSync(bundled)) resolvedBin = bundled;
76720
+ const bundled = path35.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
76721
+ if (provider.cli && fs23.existsSync(bundled)) resolvedBin = bundled;
76176
76722
  }
76177
76723
  info.installed = !!(appPath || resolvedBin);
76178
76724
  info.path = appPath || null;
@@ -76209,8 +76755,8 @@ ${ptyResult.output.slice(-2e3)}`);
76209
76755
  return results;
76210
76756
  }
76211
76757
  var http2 = __toESM2(require("http"));
76212
- var fs26 = __toESM2(require("fs"));
76213
- var path38 = __toESM2(require("path"));
76758
+ var fs27 = __toESM2(require("fs"));
76759
+ var path39 = __toESM2(require("path"));
76214
76760
  init_config();
76215
76761
  function generateFiles(type, name, category, opts = {}) {
76216
76762
  const { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2 = "0.1" } = opts;
@@ -76554,8 +77100,8 @@ async (params) => {
76554
77100
  };
76555
77101
  }
76556
77102
  init_logger();
76557
- var fs23 = __toESM2(require("fs"));
76558
- var path35 = __toESM2(require("path"));
77103
+ var fs24 = __toESM2(require("fs"));
77104
+ var path36 = __toESM2(require("path"));
76559
77105
  init_logger();
76560
77106
  async function handleCdpEvaluate(ctx, req, res) {
76561
77107
  const body = await ctx.readBody(req);
@@ -76734,18 +77280,18 @@ async (params) => {
76734
77280
  return;
76735
77281
  }
76736
77282
  let scriptsPath = "";
76737
- const directScripts = path35.join(dir, "scripts.js");
76738
- if (fs23.existsSync(directScripts)) {
77283
+ const directScripts = path36.join(dir, "scripts.js");
77284
+ if (fs24.existsSync(directScripts)) {
76739
77285
  scriptsPath = directScripts;
76740
77286
  } else {
76741
- const scriptsDir = path35.join(dir, "scripts");
76742
- if (fs23.existsSync(scriptsDir)) {
76743
- const versions = fs23.readdirSync(scriptsDir).filter((d) => {
76744
- return fs23.statSync(path35.join(scriptsDir, d)).isDirectory();
77287
+ const scriptsDir = path36.join(dir, "scripts");
77288
+ if (fs24.existsSync(scriptsDir)) {
77289
+ const versions = fs24.readdirSync(scriptsDir).filter((d) => {
77290
+ return fs24.statSync(path36.join(scriptsDir, d)).isDirectory();
76745
77291
  }).sort().reverse();
76746
77292
  for (const ver of versions) {
76747
- const p = path35.join(scriptsDir, ver, "scripts.js");
76748
- if (fs23.existsSync(p)) {
77293
+ const p = path36.join(scriptsDir, ver, "scripts.js");
77294
+ if (fs24.existsSync(p)) {
76749
77295
  scriptsPath = p;
76750
77296
  break;
76751
77297
  }
@@ -76757,7 +77303,7 @@ async (params) => {
76757
77303
  return;
76758
77304
  }
76759
77305
  try {
76760
- const source = fs23.readFileSync(scriptsPath, "utf-8");
77306
+ const source = fs24.readFileSync(scriptsPath, "utf-8");
76761
77307
  const hints = {};
76762
77308
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
76763
77309
  let match;
@@ -77570,8 +78116,8 @@ async (params) => {
77570
78116
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
77571
78117
  }
77572
78118
  }
77573
- var fs24 = __toESM2(require("fs"));
77574
- var path36 = __toESM2(require("path"));
78119
+ var fs25 = __toESM2(require("fs"));
78120
+ var path37 = __toESM2(require("path"));
77575
78121
  function slugifyFixtureName(value) {
77576
78122
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
77577
78123
  return normalized || `fixture-${Date.now()}`;
@@ -77581,15 +78127,15 @@ async (params) => {
77581
78127
  if (!providerDir) {
77582
78128
  throw new Error(`Provider directory not found for '${type}'`);
77583
78129
  }
77584
- return path36.join(providerDir, "fixtures");
78130
+ return path37.join(providerDir, "fixtures");
77585
78131
  }
77586
78132
  function readCliFixture(ctx, type, name) {
77587
78133
  const fixtureDir = getCliFixtureDir(ctx, type);
77588
- const filePath = path36.join(fixtureDir, `${name}.json`);
77589
- if (!fs24.existsSync(filePath)) {
78134
+ const filePath = path37.join(fixtureDir, `${name}.json`);
78135
+ if (!fs25.existsSync(filePath)) {
77590
78136
  throw new Error(`Fixture not found: ${filePath}`);
77591
78137
  }
77592
- return JSON.parse(fs24.readFileSync(filePath, "utf-8"));
78138
+ return JSON.parse(fs25.readFileSync(filePath, "utf-8"));
77593
78139
  }
77594
78140
  function getExerciseTranscriptText(result) {
77595
78141
  const parts = [];
@@ -78334,7 +78880,7 @@ async (params) => {
78334
78880
  return;
78335
78881
  }
78336
78882
  const fixtureDir = getCliFixtureDir(ctx, type);
78337
- fs24.mkdirSync(fixtureDir, { recursive: true });
78883
+ fs25.mkdirSync(fixtureDir, { recursive: true });
78338
78884
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
78339
78885
  const result = await runCliExerciseInternal(ctx, { ...request, type });
78340
78886
  const fixture = {
@@ -78361,8 +78907,8 @@ async (params) => {
78361
78907
  },
78362
78908
  notes: typeof body?.notes === "string" ? body.notes : void 0
78363
78909
  };
78364
- const filePath = path36.join(fixtureDir, `${name}.json`);
78365
- fs24.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
78910
+ const filePath = path37.join(fixtureDir, `${name}.json`);
78911
+ fs25.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
78366
78912
  ctx.json(res, 200, {
78367
78913
  saved: true,
78368
78914
  name,
@@ -78380,14 +78926,14 @@ async (params) => {
78380
78926
  async function handleCliFixtureList(ctx, type, _req, res) {
78381
78927
  try {
78382
78928
  const fixtureDir = getCliFixtureDir(ctx, type);
78383
- if (!fs24.existsSync(fixtureDir)) {
78929
+ if (!fs25.existsSync(fixtureDir)) {
78384
78930
  ctx.json(res, 200, { fixtures: [], count: 0 });
78385
78931
  return;
78386
78932
  }
78387
- const fixtures = fs24.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
78388
- const fullPath = path36.join(fixtureDir, file2);
78933
+ const fixtures = fs25.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
78934
+ const fullPath = path37.join(fixtureDir, file2);
78389
78935
  try {
78390
- const raw = JSON.parse(fs24.readFileSync(fullPath, "utf-8"));
78936
+ const raw = JSON.parse(fs25.readFileSync(fullPath, "utf-8"));
78391
78937
  return {
78392
78938
  name: raw.name || file2.replace(/\.json$/i, ""),
78393
78939
  path: fullPath,
@@ -78518,9 +79064,9 @@ async (params) => {
78518
79064
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
78519
79065
  }
78520
79066
  }
78521
- var fs25 = __toESM2(require("fs"));
78522
- var path37 = __toESM2(require("path"));
78523
- var os27 = __toESM2(require("os"));
79067
+ var fs26 = __toESM2(require("fs"));
79068
+ var path38 = __toESM2(require("path"));
79069
+ var os28 = __toESM2(require("os"));
78524
79070
  function getAutoImplPid(ctx) {
78525
79071
  const pid = ctx.autoImplProcess?.pid;
78526
79072
  return typeof pid === "number" && pid > 0 ? pid : null;
@@ -78566,38 +79112,38 @@ async (params) => {
78566
79112
  return fallback?.type || null;
78567
79113
  }
78568
79114
  function getLatestScriptVersionDir(scriptsDir) {
78569
- if (!fs25.existsSync(scriptsDir)) return null;
78570
- const versions = fs25.readdirSync(scriptsDir).filter((d) => {
79115
+ if (!fs26.existsSync(scriptsDir)) return null;
79116
+ const versions = fs26.readdirSync(scriptsDir).filter((d) => {
78571
79117
  try {
78572
- return fs25.statSync(path37.join(scriptsDir, d)).isDirectory();
79118
+ return fs26.statSync(path38.join(scriptsDir, d)).isDirectory();
78573
79119
  } catch {
78574
79120
  return false;
78575
79121
  }
78576
79122
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
78577
79123
  if (versions.length === 0) return null;
78578
- return path37.join(scriptsDir, versions[0]);
79124
+ return path38.join(scriptsDir, versions[0]);
78579
79125
  }
78580
79126
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
78581
- const canonicalUserDir = path37.resolve(ctx.providerLoader.getUserProviderDir(category, type));
78582
- const desiredDir = requestedDir ? path37.resolve(requestedDir) : canonicalUserDir;
78583
- const upstreamRoot = path37.resolve(ctx.providerLoader.getUpstreamDir());
78584
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path37.sep}`)) {
79127
+ const canonicalUserDir = path38.resolve(ctx.providerLoader.getUserProviderDir(category, type));
79128
+ const desiredDir = requestedDir ? path38.resolve(requestedDir) : canonicalUserDir;
79129
+ const upstreamRoot = path38.resolve(ctx.providerLoader.getUpstreamDir());
79130
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path38.sep}`)) {
78585
79131
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
78586
79132
  }
78587
- if (path37.basename(desiredDir) !== type) {
79133
+ if (path38.basename(desiredDir) !== type) {
78588
79134
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
78589
79135
  }
78590
79136
  const sourceDir = ctx.findProviderDir(type);
78591
79137
  if (!sourceDir) {
78592
79138
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
78593
79139
  }
78594
- if (!fs25.existsSync(desiredDir)) {
78595
- fs25.mkdirSync(path37.dirname(desiredDir), { recursive: true });
78596
- fs25.cpSync(sourceDir, desiredDir, { recursive: true });
79140
+ if (!fs26.existsSync(desiredDir)) {
79141
+ fs26.mkdirSync(path38.dirname(desiredDir), { recursive: true });
79142
+ fs26.cpSync(sourceDir, desiredDir, { recursive: true });
78597
79143
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
78598
79144
  }
78599
- const providerJson = path37.join(desiredDir, "provider.json");
78600
- if (!fs25.existsSync(providerJson)) {
79145
+ const providerJson = path38.join(desiredDir, "provider.json");
79146
+ if (!fs26.existsSync(providerJson)) {
78601
79147
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
78602
79148
  }
78603
79149
  return { dir: desiredDir };
@@ -78605,15 +79151,15 @@ async (params) => {
78605
79151
  function loadAutoImplReferenceScripts(ctx, referenceType) {
78606
79152
  if (!referenceType) return {};
78607
79153
  const refDir = ctx.findProviderDir(referenceType);
78608
- if (!refDir || !fs25.existsSync(refDir)) return {};
79154
+ if (!refDir || !fs26.existsSync(refDir)) return {};
78609
79155
  const referenceScripts = {};
78610
- const scriptsDir = path37.join(refDir, "scripts");
79156
+ const scriptsDir = path38.join(refDir, "scripts");
78611
79157
  const latestDir = getLatestScriptVersionDir(scriptsDir);
78612
79158
  if (!latestDir) return referenceScripts;
78613
- for (const file2 of fs25.readdirSync(latestDir)) {
79159
+ for (const file2 of fs26.readdirSync(latestDir)) {
78614
79160
  if (!file2.endsWith(".js")) continue;
78615
79161
  try {
78616
- referenceScripts[file2] = fs25.readFileSync(path37.join(latestDir, file2), "utf-8");
79162
+ referenceScripts[file2] = fs26.readFileSync(path38.join(latestDir, file2), "utf-8");
78617
79163
  } catch {
78618
79164
  }
78619
79165
  }
@@ -78721,16 +79267,16 @@ async (params) => {
78721
79267
  });
78722
79268
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
78723
79269
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
78724
- const tmpDir = path37.join(os27.tmpdir(), "adhdev-autoimpl");
78725
- if (!fs25.existsSync(tmpDir)) fs25.mkdirSync(tmpDir, { recursive: true });
78726
- const promptFile = path37.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
78727
- fs25.writeFileSync(promptFile, prompt, "utf-8");
79270
+ const tmpDir = path38.join(os28.tmpdir(), "adhdev-autoimpl");
79271
+ if (!fs26.existsSync(tmpDir)) fs26.mkdirSync(tmpDir, { recursive: true });
79272
+ const promptFile = path38.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
79273
+ fs26.writeFileSync(promptFile, prompt, "utf-8");
78728
79274
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
78729
79275
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
78730
79276
  const spawn4 = agentProvider?.spawn;
78731
79277
  if (!spawn4?.command) {
78732
79278
  try {
78733
- fs25.unlinkSync(promptFile);
79279
+ fs26.unlinkSync(promptFile);
78734
79280
  } catch {
78735
79281
  }
78736
79282
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -78832,7 +79378,7 @@ async (params) => {
78832
79378
  } catch {
78833
79379
  }
78834
79380
  try {
78835
- fs25.unlinkSync(promptFile);
79381
+ fs26.unlinkSync(promptFile);
78836
79382
  } catch {
78837
79383
  }
78838
79384
  ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -78876,7 +79422,7 @@ async (params) => {
78876
79422
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
78877
79423
  const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
78878
79424
  let shellCmd;
78879
- const isWin = os27.platform() === "win32";
79425
+ const isWin = os28.platform() === "win32";
78880
79426
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
78881
79427
  const promptMode = autoImpl?.promptMode ?? "stdin";
78882
79428
  const extraArgs = autoImpl?.extraArgs ?? [];
@@ -78915,7 +79461,7 @@ async (params) => {
78915
79461
  try {
78916
79462
  const pty = require("node-pty");
78917
79463
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
78918
- const isWin2 = os27.platform() === "win32";
79464
+ const isWin2 = os28.platform() === "win32";
78919
79465
  child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
78920
79466
  name: "xterm-256color",
78921
79467
  cols: 120,
@@ -79058,7 +79604,7 @@ async (params) => {
79058
79604
  }
79059
79605
  });
79060
79606
  try {
79061
- fs25.unlinkSync(promptFile);
79607
+ fs26.unlinkSync(promptFile);
79062
79608
  } catch {
79063
79609
  }
79064
79610
  ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -79155,7 +79701,7 @@ async (params) => {
79155
79701
  setMode: "set_mode.js"
79156
79702
  };
79157
79703
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
79158
- const scriptsDir = path37.join(providerDir, "scripts");
79704
+ const scriptsDir = path38.join(providerDir, "scripts");
79159
79705
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
79160
79706
  if (latestScriptsDir) {
79161
79707
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -79163,10 +79709,10 @@ async (params) => {
79163
79709
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
79164
79710
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
79165
79711
  lines.push("");
79166
- for (const file2 of fs25.readdirSync(latestScriptsDir)) {
79712
+ for (const file2 of fs26.readdirSync(latestScriptsDir)) {
79167
79713
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
79168
79714
  try {
79169
- const content = fs25.readFileSync(path37.join(latestScriptsDir, file2), "utf-8");
79715
+ const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
79170
79716
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
79171
79717
  lines.push("```javascript");
79172
79718
  lines.push(content);
@@ -79176,14 +79722,14 @@ async (params) => {
79176
79722
  }
79177
79723
  }
79178
79724
  }
79179
- const refFiles = fs25.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
79725
+ const refFiles = fs26.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
79180
79726
  if (refFiles.length > 0) {
79181
79727
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
79182
79728
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
79183
79729
  lines.push("");
79184
79730
  for (const file2 of refFiles) {
79185
79731
  try {
79186
- const content = fs25.readFileSync(path37.join(latestScriptsDir, file2), "utf-8");
79732
+ const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
79187
79733
  lines.push(`### \`${file2}\` \u{1F512}`);
79188
79734
  lines.push("```javascript");
79189
79735
  lines.push(content);
@@ -79224,11 +79770,11 @@ async (params) => {
79224
79770
  lines.push("");
79225
79771
  }
79226
79772
  }
79227
- const docsDir = path37.join(providerDir, "../../docs");
79773
+ const docsDir = path38.join(providerDir, "../../docs");
79228
79774
  const loadGuide = (name) => {
79229
79775
  try {
79230
- const p = path37.join(docsDir, name);
79231
- if (fs25.existsSync(p)) return fs25.readFileSync(p, "utf-8");
79776
+ const p = path38.join(docsDir, name);
79777
+ if (fs26.existsSync(p)) return fs26.readFileSync(p, "utf-8");
79232
79778
  } catch {
79233
79779
  }
79234
79780
  return null;
@@ -79464,7 +80010,7 @@ async (params) => {
79464
80010
  parseApproval: "parse_approval.js"
79465
80011
  };
79466
80012
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
79467
- const scriptsDir = path37.join(providerDir, "scripts");
80013
+ const scriptsDir = path38.join(providerDir, "scripts");
79468
80014
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
79469
80015
  if (latestScriptsDir) {
79470
80016
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -79472,11 +80018,11 @@ async (params) => {
79472
80018
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
79473
80019
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
79474
80020
  lines.push("");
79475
- for (const file2 of fs25.readdirSync(latestScriptsDir)) {
80021
+ for (const file2 of fs26.readdirSync(latestScriptsDir)) {
79476
80022
  if (!file2.endsWith(".js")) continue;
79477
80023
  if (!targetFileNames.has(file2)) continue;
79478
80024
  try {
79479
- const content = fs25.readFileSync(path37.join(latestScriptsDir, file2), "utf-8");
80025
+ const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
79480
80026
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
79481
80027
  lines.push("```javascript");
79482
80028
  lines.push(content);
@@ -79485,14 +80031,14 @@ async (params) => {
79485
80031
  } catch {
79486
80032
  }
79487
80033
  }
79488
- const refFiles = fs25.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
80034
+ const refFiles = fs26.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
79489
80035
  if (refFiles.length > 0) {
79490
80036
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
79491
80037
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
79492
80038
  lines.push("");
79493
80039
  for (const file2 of refFiles) {
79494
80040
  try {
79495
- const content = fs25.readFileSync(path37.join(latestScriptsDir, file2), "utf-8");
80041
+ const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
79496
80042
  lines.push(`### \`${file2}\` \u{1F512}`);
79497
80043
  lines.push("```javascript");
79498
80044
  lines.push(content);
@@ -79525,11 +80071,11 @@ async (params) => {
79525
80071
  lines.push("");
79526
80072
  }
79527
80073
  }
79528
- const docsDir = path37.join(providerDir, "../../docs");
80074
+ const docsDir = path38.join(providerDir, "../../docs");
79529
80075
  const loadGuide = (name) => {
79530
80076
  try {
79531
- const p = path37.join(docsDir, name);
79532
- if (fs25.existsSync(p)) return fs25.readFileSync(p, "utf-8");
80077
+ const p = path38.join(docsDir, name);
80078
+ if (fs26.existsSync(p)) return fs26.readFileSync(p, "utf-8");
79533
80079
  } catch {
79534
80080
  }
79535
80081
  return null;
@@ -79973,8 +80519,8 @@ data: ${JSON.stringify(msg.data)}
79973
80519
  }
79974
80520
  getEndpointList() {
79975
80521
  return this.routes.map((r) => {
79976
- const path39 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
79977
- return `${r.method.padEnd(5)} ${path39}`;
80522
+ const path40 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
80523
+ return `${r.method.padEnd(5)} ${path40}`;
79978
80524
  });
79979
80525
  }
79980
80526
  async start(port = DEV_SERVER_PORT) {
@@ -80262,12 +80808,12 @@ data: ${JSON.stringify(msg.data)}
80262
80808
  // ─── DevConsole SPA ───
80263
80809
  getConsoleDistDir() {
80264
80810
  const candidates = [
80265
- path38.resolve(__dirname, "../../web-devconsole/dist"),
80266
- path38.resolve(__dirname, "../../../web-devconsole/dist"),
80267
- path38.join(process.cwd(), "packages/web-devconsole/dist")
80811
+ path39.resolve(__dirname, "../../web-devconsole/dist"),
80812
+ path39.resolve(__dirname, "../../../web-devconsole/dist"),
80813
+ path39.join(process.cwd(), "packages/web-devconsole/dist")
80268
80814
  ];
80269
80815
  for (const dir of candidates) {
80270
- if (fs26.existsSync(path38.join(dir, "index.html"))) return dir;
80816
+ if (fs27.existsSync(path39.join(dir, "index.html"))) return dir;
80271
80817
  }
80272
80818
  return null;
80273
80819
  }
@@ -80277,9 +80823,9 @@ data: ${JSON.stringify(msg.data)}
80277
80823
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
80278
80824
  return;
80279
80825
  }
80280
- const htmlPath = path38.join(distDir, "index.html");
80826
+ const htmlPath = path39.join(distDir, "index.html");
80281
80827
  try {
80282
- const html = fs26.readFileSync(htmlPath, "utf-8");
80828
+ const html = fs27.readFileSync(htmlPath, "utf-8");
80283
80829
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
80284
80830
  res.end(html);
80285
80831
  } catch (e) {
@@ -80302,15 +80848,15 @@ data: ${JSON.stringify(msg.data)}
80302
80848
  this.json(res, 404, { error: "Not found" });
80303
80849
  return;
80304
80850
  }
80305
- const safePath = path38.normalize(pathname).replace(/^\.\.\//, "");
80306
- const filePath = path38.join(distDir, safePath);
80851
+ const safePath = path39.normalize(pathname).replace(/^\.\.\//, "");
80852
+ const filePath = path39.join(distDir, safePath);
80307
80853
  if (!filePath.startsWith(distDir)) {
80308
80854
  this.json(res, 403, { error: "Forbidden" });
80309
80855
  return;
80310
80856
  }
80311
80857
  try {
80312
- const content = fs26.readFileSync(filePath);
80313
- const ext = path38.extname(filePath);
80858
+ const content = fs27.readFileSync(filePath);
80859
+ const ext = path39.extname(filePath);
80314
80860
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
80315
80861
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
80316
80862
  res.end(content);
@@ -80418,14 +80964,14 @@ data: ${JSON.stringify(msg.data)}
80418
80964
  const files = [];
80419
80965
  const scan = (d, prefix) => {
80420
80966
  try {
80421
- for (const entry of fs26.readdirSync(d, { withFileTypes: true })) {
80967
+ for (const entry of fs27.readdirSync(d, { withFileTypes: true })) {
80422
80968
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
80423
80969
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
80424
80970
  if (entry.isDirectory()) {
80425
80971
  files.push({ path: rel, size: 0, type: "dir" });
80426
- scan(path38.join(d, entry.name), rel);
80972
+ scan(path39.join(d, entry.name), rel);
80427
80973
  } else {
80428
- const stat2 = fs26.statSync(path38.join(d, entry.name));
80974
+ const stat2 = fs27.statSync(path39.join(d, entry.name));
80429
80975
  files.push({ path: rel, size: stat2.size, type: "file" });
80430
80976
  }
80431
80977
  }
@@ -80448,16 +80994,16 @@ data: ${JSON.stringify(msg.data)}
80448
80994
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
80449
80995
  return;
80450
80996
  }
80451
- const fullPath = path38.resolve(dir, path38.normalize(filePath));
80997
+ const fullPath = path39.resolve(dir, path39.normalize(filePath));
80452
80998
  if (!fullPath.startsWith(dir)) {
80453
80999
  this.json(res, 403, { error: "Forbidden" });
80454
81000
  return;
80455
81001
  }
80456
- if (!fs26.existsSync(fullPath) || fs26.statSync(fullPath).isDirectory()) {
81002
+ if (!fs27.existsSync(fullPath) || fs27.statSync(fullPath).isDirectory()) {
80457
81003
  this.json(res, 404, { error: `File not found: ${filePath}` });
80458
81004
  return;
80459
81005
  }
80460
- const content = fs26.readFileSync(fullPath, "utf-8");
81006
+ const content = fs27.readFileSync(fullPath, "utf-8");
80461
81007
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
80462
81008
  }
80463
81009
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -80473,15 +81019,15 @@ data: ${JSON.stringify(msg.data)}
80473
81019
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
80474
81020
  return;
80475
81021
  }
80476
- const fullPath = path38.resolve(dir, path38.normalize(filePath));
81022
+ const fullPath = path39.resolve(dir, path39.normalize(filePath));
80477
81023
  if (!fullPath.startsWith(dir)) {
80478
81024
  this.json(res, 403, { error: "Forbidden" });
80479
81025
  return;
80480
81026
  }
80481
81027
  try {
80482
- if (fs26.existsSync(fullPath)) fs26.copyFileSync(fullPath, fullPath + ".bak");
80483
- fs26.mkdirSync(path38.dirname(fullPath), { recursive: true });
80484
- fs26.writeFileSync(fullPath, content, "utf-8");
81028
+ if (fs27.existsSync(fullPath)) fs27.copyFileSync(fullPath, fullPath + ".bak");
81029
+ fs27.mkdirSync(path39.dirname(fullPath), { recursive: true });
81030
+ fs27.writeFileSync(fullPath, content, "utf-8");
80485
81031
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
80486
81032
  this.providerLoader.reload();
80487
81033
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -80497,9 +81043,9 @@ data: ${JSON.stringify(msg.data)}
80497
81043
  return;
80498
81044
  }
80499
81045
  for (const name of ["scripts.js", "provider.json"]) {
80500
- const p = path38.join(dir, name);
80501
- if (fs26.existsSync(p)) {
80502
- const source = fs26.readFileSync(p, "utf-8");
81046
+ const p = path39.join(dir, name);
81047
+ if (fs27.existsSync(p)) {
81048
+ const source = fs27.readFileSync(p, "utf-8");
80503
81049
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
80504
81050
  return;
80505
81051
  }
@@ -80518,11 +81064,11 @@ data: ${JSON.stringify(msg.data)}
80518
81064
  this.json(res, 404, { error: `Provider not found: ${type}` });
80519
81065
  return;
80520
81066
  }
80521
- const target = fs26.existsSync(path38.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
80522
- const targetPath = path38.join(dir, target);
81067
+ const target = fs27.existsSync(path39.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
81068
+ const targetPath = path39.join(dir, target);
80523
81069
  try {
80524
- if (fs26.existsSync(targetPath)) fs26.copyFileSync(targetPath, targetPath + ".bak");
80525
- fs26.writeFileSync(targetPath, source, "utf-8");
81070
+ if (fs27.existsSync(targetPath)) fs27.copyFileSync(targetPath, targetPath + ".bak");
81071
+ fs27.writeFileSync(targetPath, source, "utf-8");
80526
81072
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
80527
81073
  this.providerLoader.reload();
80528
81074
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -80666,21 +81212,21 @@ data: ${JSON.stringify(msg.data)}
80666
81212
  }
80667
81213
  let targetDir;
80668
81214
  targetDir = this.providerLoader.getUserProviderDir(category, type);
80669
- const jsonPath = path38.join(targetDir, "provider.json");
80670
- if (fs26.existsSync(jsonPath)) {
81215
+ const jsonPath = path39.join(targetDir, "provider.json");
81216
+ if (fs27.existsSync(jsonPath)) {
80671
81217
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
80672
81218
  return;
80673
81219
  }
80674
81220
  try {
80675
81221
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
80676
- fs26.mkdirSync(targetDir, { recursive: true });
80677
- fs26.writeFileSync(jsonPath, result["provider.json"], "utf-8");
81222
+ fs27.mkdirSync(targetDir, { recursive: true });
81223
+ fs27.writeFileSync(jsonPath, result["provider.json"], "utf-8");
80678
81224
  const createdFiles = ["provider.json"];
80679
81225
  if (result.files) {
80680
81226
  for (const [relPath, content] of Object.entries(result.files)) {
80681
- const fullPath = path38.join(targetDir, relPath);
80682
- fs26.mkdirSync(path38.dirname(fullPath), { recursive: true });
80683
- fs26.writeFileSync(fullPath, content, "utf-8");
81227
+ const fullPath = path39.join(targetDir, relPath);
81228
+ fs27.mkdirSync(path39.dirname(fullPath), { recursive: true });
81229
+ fs27.writeFileSync(fullPath, content, "utf-8");
80684
81230
  createdFiles.push(relPath);
80685
81231
  }
80686
81232
  }
@@ -80729,38 +81275,38 @@ data: ${JSON.stringify(msg.data)}
80729
81275
  }
80730
81276
  // ─── Phase 2: Auto-Implement Backend ───
80731
81277
  getLatestScriptVersionDir(scriptsDir) {
80732
- if (!fs26.existsSync(scriptsDir)) return null;
80733
- const versions = fs26.readdirSync(scriptsDir).filter((d) => {
81278
+ if (!fs27.existsSync(scriptsDir)) return null;
81279
+ const versions = fs27.readdirSync(scriptsDir).filter((d) => {
80734
81280
  try {
80735
- return fs26.statSync(path38.join(scriptsDir, d)).isDirectory();
81281
+ return fs27.statSync(path39.join(scriptsDir, d)).isDirectory();
80736
81282
  } catch {
80737
81283
  return false;
80738
81284
  }
80739
81285
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
80740
81286
  if (versions.length === 0) return null;
80741
- return path38.join(scriptsDir, versions[0]);
81287
+ return path39.join(scriptsDir, versions[0]);
80742
81288
  }
80743
81289
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
80744
- const canonicalUserDir = path38.resolve(this.providerLoader.getUserProviderDir(category, type));
80745
- const desiredDir = requestedDir ? path38.resolve(requestedDir) : canonicalUserDir;
80746
- const upstreamRoot = path38.resolve(this.providerLoader.getUpstreamDir());
80747
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path38.sep}`)) {
81290
+ const canonicalUserDir = path39.resolve(this.providerLoader.getUserProviderDir(category, type));
81291
+ const desiredDir = requestedDir ? path39.resolve(requestedDir) : canonicalUserDir;
81292
+ const upstreamRoot = path39.resolve(this.providerLoader.getUpstreamDir());
81293
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path39.sep}`)) {
80748
81294
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
80749
81295
  }
80750
- if (path38.basename(desiredDir) !== type) {
81296
+ if (path39.basename(desiredDir) !== type) {
80751
81297
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
80752
81298
  }
80753
81299
  const sourceDir = this.findProviderDir(type);
80754
81300
  if (!sourceDir) {
80755
81301
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
80756
81302
  }
80757
- if (!fs26.existsSync(desiredDir)) {
80758
- fs26.mkdirSync(path38.dirname(desiredDir), { recursive: true });
80759
- fs26.cpSync(sourceDir, desiredDir, { recursive: true });
81303
+ if (!fs27.existsSync(desiredDir)) {
81304
+ fs27.mkdirSync(path39.dirname(desiredDir), { recursive: true });
81305
+ fs27.cpSync(sourceDir, desiredDir, { recursive: true });
80760
81306
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
80761
81307
  }
80762
- const providerJson = path38.join(desiredDir, "provider.json");
80763
- if (!fs26.existsSync(providerJson)) {
81308
+ const providerJson = path39.join(desiredDir, "provider.json");
81309
+ if (!fs27.existsSync(providerJson)) {
80764
81310
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
80765
81311
  }
80766
81312
  return { dir: desiredDir };
@@ -80795,7 +81341,7 @@ data: ${JSON.stringify(msg.data)}
80795
81341
  setMode: "set_mode.js"
80796
81342
  };
80797
81343
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
80798
- const scriptsDir = path38.join(providerDir, "scripts");
81344
+ const scriptsDir = path39.join(providerDir, "scripts");
80799
81345
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
80800
81346
  if (latestScriptsDir) {
80801
81347
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -80803,10 +81349,10 @@ data: ${JSON.stringify(msg.data)}
80803
81349
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
80804
81350
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
80805
81351
  lines.push("");
80806
- for (const file2 of fs26.readdirSync(latestScriptsDir)) {
81352
+ for (const file2 of fs27.readdirSync(latestScriptsDir)) {
80807
81353
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
80808
81354
  try {
80809
- const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
81355
+ const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
80810
81356
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
80811
81357
  lines.push("```javascript");
80812
81358
  lines.push(content);
@@ -80816,14 +81362,14 @@ data: ${JSON.stringify(msg.data)}
80816
81362
  }
80817
81363
  }
80818
81364
  }
80819
- const refFiles = fs26.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
81365
+ const refFiles = fs27.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
80820
81366
  if (refFiles.length > 0) {
80821
81367
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
80822
81368
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
80823
81369
  lines.push("");
80824
81370
  for (const file2 of refFiles) {
80825
81371
  try {
80826
- const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
81372
+ const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
80827
81373
  lines.push(`### \`${file2}\` \u{1F512}`);
80828
81374
  lines.push("```javascript");
80829
81375
  lines.push(content);
@@ -80864,11 +81410,11 @@ data: ${JSON.stringify(msg.data)}
80864
81410
  lines.push("");
80865
81411
  }
80866
81412
  }
80867
- const docsDir = path38.join(providerDir, "../../docs");
81413
+ const docsDir = path39.join(providerDir, "../../docs");
80868
81414
  const loadGuide = (name) => {
80869
81415
  try {
80870
- const p = path38.join(docsDir, name);
80871
- if (fs26.existsSync(p)) return fs26.readFileSync(p, "utf-8");
81416
+ const p = path39.join(docsDir, name);
81417
+ if (fs27.existsSync(p)) return fs27.readFileSync(p, "utf-8");
80872
81418
  } catch {
80873
81419
  }
80874
81420
  return null;
@@ -81041,7 +81587,7 @@ data: ${JSON.stringify(msg.data)}
81041
81587
  parseApproval: "parse_approval.js"
81042
81588
  };
81043
81589
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
81044
- const scriptsDir = path38.join(providerDir, "scripts");
81590
+ const scriptsDir = path39.join(providerDir, "scripts");
81045
81591
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
81046
81592
  if (latestScriptsDir) {
81047
81593
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -81049,11 +81595,11 @@ data: ${JSON.stringify(msg.data)}
81049
81595
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
81050
81596
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
81051
81597
  lines.push("");
81052
- for (const file2 of fs26.readdirSync(latestScriptsDir)) {
81598
+ for (const file2 of fs27.readdirSync(latestScriptsDir)) {
81053
81599
  if (!file2.endsWith(".js")) continue;
81054
81600
  if (!targetFileNames.has(file2)) continue;
81055
81601
  try {
81056
- const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
81602
+ const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
81057
81603
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
81058
81604
  lines.push("```javascript");
81059
81605
  lines.push(content);
@@ -81062,14 +81608,14 @@ data: ${JSON.stringify(msg.data)}
81062
81608
  } catch {
81063
81609
  }
81064
81610
  }
81065
- const refFiles = fs26.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
81611
+ const refFiles = fs27.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
81066
81612
  if (refFiles.length > 0) {
81067
81613
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
81068
81614
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
81069
81615
  lines.push("");
81070
81616
  for (const file2 of refFiles) {
81071
81617
  try {
81072
- const content = fs26.readFileSync(path38.join(latestScriptsDir, file2), "utf-8");
81618
+ const content = fs27.readFileSync(path39.join(latestScriptsDir, file2), "utf-8");
81073
81619
  lines.push(`### \`${file2}\` \u{1F512}`);
81074
81620
  lines.push("```javascript");
81075
81621
  lines.push(content);
@@ -81102,11 +81648,11 @@ data: ${JSON.stringify(msg.data)}
81102
81648
  lines.push("");
81103
81649
  }
81104
81650
  }
81105
- const docsDir = path38.join(providerDir, "../../docs");
81651
+ const docsDir = path39.join(providerDir, "../../docs");
81106
81652
  const loadGuide = (name) => {
81107
81653
  try {
81108
- const p = path38.join(docsDir, name);
81109
- if (fs26.existsSync(p)) return fs26.readFileSync(p, "utf-8");
81654
+ const p = path39.join(docsDir, name);
81655
+ if (fs27.existsSync(p)) return fs27.readFileSync(p, "utf-8");
81110
81656
  } catch {
81111
81657
  }
81112
81658
  return null;
@@ -81999,8 +82545,8 @@ data: ${JSON.stringify(msg.data)}
81999
82545
  const res = await fetch(extension.vsixUrl);
82000
82546
  if (res.ok) {
82001
82547
  const buffer = Buffer.from(await res.arrayBuffer());
82002
- const fs27 = await import("fs");
82003
- fs27.writeFileSync(vsixPath, buffer);
82548
+ const fs28 = await import("fs");
82549
+ fs28.writeFileSync(vsixPath, buffer);
82004
82550
  return new Promise((resolve23) => {
82005
82551
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
82006
82552
  (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {