@adhdev/daemon-core 0.9.76-rc.63 → 0.9.76-rc.64

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
@@ -21909,6 +21909,8 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
21909
21909
  }
21910
21910
 
21911
21911
  // src/commands/router.ts
21912
+ var import_os3 = require("os");
21913
+ var import_path4 = require("path");
21912
21914
  var fs10 = __toESM(require("fs"));
21913
21915
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
21914
21916
  var CHANNEL_SERVER_URL = {
@@ -21975,6 +21977,32 @@ function serializeMeshCoordinatorMcpConfig(config, format) {
21975
21977
  if (format === "claude_mcp_json") return JSON.stringify(config, null, 2);
21976
21978
  return loadYamlModule().dump(config, { noRefs: true, lineWidth: 120 });
21977
21979
  }
21980
+ function resolveHermesUserHome() {
21981
+ const explicitHome = process.env.HERMES_HOME?.trim();
21982
+ return explicitHome || (0, import_path4.join)((0, import_os3.homedir)(), ".hermes");
21983
+ }
21984
+ function loadHermesCoordinatorBaseConfig(targetConfigPath) {
21985
+ const sourceHome = resolveHermesUserHome();
21986
+ const sourceConfigPath = (0, import_path4.join)(sourceHome, "config.yaml");
21987
+ if (!fs10.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
21988
+ if ((0, import_path4.resolve)(sourceConfigPath) === (0, import_path4.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
21989
+ const parsed = parseMeshCoordinatorMcpConfig(fs10.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
21990
+ const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
21991
+ return { config: baseConfig, sourceHome, sourceConfigPath };
21992
+ }
21993
+ function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
21994
+ if ((0, import_path4.resolve)(sourceHome) === (0, import_path4.resolve)(targetHome)) return;
21995
+ for (const fileName of [".env", "auth.json"]) {
21996
+ const sourcePath = (0, import_path4.join)(sourceHome, fileName);
21997
+ const targetPath = (0, import_path4.join)(targetHome, fileName);
21998
+ if (!fs10.existsSync(sourcePath)) continue;
21999
+ try {
22000
+ fs10.copyFileSync(sourcePath, targetPath);
22001
+ } catch (error) {
22002
+ LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
22003
+ }
22004
+ }
22005
+ }
21978
22006
  var CHAT_COMMANDS = [
21979
22007
  "send_chat",
21980
22008
  "new_chat",
@@ -23196,10 +23224,20 @@ var DaemonCommandRouter = class {
23196
23224
  workspace
23197
23225
  };
23198
23226
  }
23199
- const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync14, copyFileSync: copyFileSync3, mkdirSync: mkdirSync16 } = await import("fs");
23227
+ const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4, mkdirSync: mkdirSync16 } = await import("fs");
23200
23228
  const { dirname: dirname9 } = await import("path");
23201
23229
  const mcpConfigPath = coordinatorSetup.configPath;
23202
23230
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
23231
+ let hermesBaseConfig = null;
23232
+ if (hermesManualFallback) {
23233
+ try {
23234
+ hermesBaseConfig = loadHermesCoordinatorBaseConfig(mcpConfigPath);
23235
+ } catch (error) {
23236
+ const message = `Failed to parse Hermes base config for automatic coordinator setup: ${error?.message || error}`;
23237
+ LOG.error("MeshCoordinator", message);
23238
+ return { success: false, code: "mesh_coordinator_config_parse_failed", error: message, meshId, cliType, workspace };
23239
+ }
23240
+ }
23203
23241
  const returnManualFallback = (message) => ({
23204
23242
  success: false,
23205
23243
  code: "mesh_coordinator_manual_mcp_setup_required",
@@ -23228,11 +23266,15 @@ var DaemonCommandRouter = class {
23228
23266
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
23229
23267
  }
23230
23268
  const hadExistingMcpConfig = existsSync23(mcpConfigPath);
23231
- let existingMcpConfig = {};
23269
+ let existingMcpConfig = hermesBaseConfig?.config || {};
23270
+ if (hermesBaseConfig) {
23271
+ copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname9(mcpConfigPath));
23272
+ }
23232
23273
  if (hadExistingMcpConfig) {
23233
23274
  try {
23234
- existingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync15(mcpConfigPath, "utf-8"), configFormat);
23235
- copyFileSync3(mcpConfigPath, mcpConfigPath + ".backup");
23275
+ const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync15(mcpConfigPath, "utf-8"), configFormat);
23276
+ existingMcpConfig = { ...existingMcpConfig, ...parsedExistingMcpConfig };
23277
+ copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
23236
23278
  } catch (error) {
23237
23279
  LOG.error("MeshCoordinator", `Failed to parse existing MCP config ${mcpConfigPath}: ${error?.message || error}`);
23238
23280
  return {
@@ -24965,7 +25007,7 @@ var fs11 = __toESM(require("fs"));
24965
25007
  var path23 = __toESM(require("path"));
24966
25008
  var os20 = __toESM(require("os"));
24967
25009
  var import_child_process10 = require("child_process");
24968
- var import_os3 = require("os");
25010
+ var import_os4 = require("os");
24969
25011
  var ARCHIVE_PATH = path23.join(os20.homedir(), ".adhdev", "version-history.json");
24970
25012
  var MAX_ENTRIES_PER_PROVIDER = 20;
24971
25013
  var VersionArchive = class {
@@ -24991,7 +25033,7 @@ var VersionArchive = class {
24991
25033
  entries.push({
24992
25034
  version,
24993
25035
  detectedAt: (/* @__PURE__ */ new Date()).toISOString(),
24994
- os: (0, import_os3.platform)()
25036
+ os: (0, import_os4.platform)()
24995
25037
  });
24996
25038
  if (entries.length > MAX_ENTRIES_PER_PROVIDER) {
24997
25039
  this.history[type] = entries.slice(-MAX_ENTRIES_PER_PROVIDER);
@@ -25031,7 +25073,7 @@ function runCommand(cmd, timeout = 1e4) {
25031
25073
  }
25032
25074
  }
25033
25075
  function findBinary2(name) {
25034
- const cmd = (0, import_os3.platform)() === "win32" ? `where ${name}` : `which ${name}`;
25076
+ const cmd = (0, import_os4.platform)() === "win32" ? `where ${name}` : `which ${name}`;
25035
25077
  const result = runCommand(cmd, 5e3);
25036
25078
  return result ? result.split("\n")[0] : null;
25037
25079
  }
@@ -25079,7 +25121,7 @@ function checkPathExists2(paths) {
25079
25121
  return null;
25080
25122
  }
25081
25123
  function getMacAppVersion(appPath) {
25082
- if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
25124
+ if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
25083
25125
  const plistPath = path23.join(appPath, "Contents", "Info.plist");
25084
25126
  if (!fs11.existsSync(plistPath)) return null;
25085
25127
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
@@ -25087,7 +25129,7 @@ function getMacAppVersion(appPath) {
25087
25129
  }
25088
25130
  async function detectAllVersions(loader, archive) {
25089
25131
  const results = [];
25090
- const currentOs = (0, import_os3.platform)();
25132
+ const currentOs = (0, import_os4.platform)();
25091
25133
  for (const provider of loader.getAll()) {
25092
25134
  const info = {
25093
25135
  type: provider.type,