@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.mjs CHANGED
@@ -21704,6 +21704,8 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
21704
21704
  }
21705
21705
 
21706
21706
  // src/commands/router.ts
21707
+ import { homedir as homedir19 } from "os";
21708
+ import { join as pathJoin, resolve as pathResolve } from "path";
21707
21709
  import * as fs10 from "fs";
21708
21710
  var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
21709
21711
  var CHANNEL_SERVER_URL = {
@@ -21770,6 +21772,32 @@ function serializeMeshCoordinatorMcpConfig(config, format) {
21770
21772
  if (format === "claude_mcp_json") return JSON.stringify(config, null, 2);
21771
21773
  return loadYamlModule().dump(config, { noRefs: true, lineWidth: 120 });
21772
21774
  }
21775
+ function resolveHermesUserHome() {
21776
+ const explicitHome = process.env.HERMES_HOME?.trim();
21777
+ return explicitHome || pathJoin(homedir19(), ".hermes");
21778
+ }
21779
+ function loadHermesCoordinatorBaseConfig(targetConfigPath) {
21780
+ const sourceHome = resolveHermesUserHome();
21781
+ const sourceConfigPath = pathJoin(sourceHome, "config.yaml");
21782
+ if (!fs10.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
21783
+ if (pathResolve(sourceConfigPath) === pathResolve(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
21784
+ const parsed = parseMeshCoordinatorMcpConfig(fs10.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
21785
+ const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
21786
+ return { config: baseConfig, sourceHome, sourceConfigPath };
21787
+ }
21788
+ function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
21789
+ if (pathResolve(sourceHome) === pathResolve(targetHome)) return;
21790
+ for (const fileName of [".env", "auth.json"]) {
21791
+ const sourcePath = pathJoin(sourceHome, fileName);
21792
+ const targetPath = pathJoin(targetHome, fileName);
21793
+ if (!fs10.existsSync(sourcePath)) continue;
21794
+ try {
21795
+ fs10.copyFileSync(sourcePath, targetPath);
21796
+ } catch (error) {
21797
+ LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
21798
+ }
21799
+ }
21800
+ }
21773
21801
  var CHAT_COMMANDS = [
21774
21802
  "send_chat",
21775
21803
  "new_chat",
@@ -22991,10 +23019,20 @@ var DaemonCommandRouter = class {
22991
23019
  workspace
22992
23020
  };
22993
23021
  }
22994
- const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync14, copyFileSync: copyFileSync3, mkdirSync: mkdirSync16 } = await import("fs");
23022
+ const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4, mkdirSync: mkdirSync16 } = await import("fs");
22995
23023
  const { dirname: dirname9 } = await import("path");
22996
23024
  const mcpConfigPath = coordinatorSetup.configPath;
22997
23025
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
23026
+ let hermesBaseConfig = null;
23027
+ if (hermesManualFallback) {
23028
+ try {
23029
+ hermesBaseConfig = loadHermesCoordinatorBaseConfig(mcpConfigPath);
23030
+ } catch (error) {
23031
+ const message = `Failed to parse Hermes base config for automatic coordinator setup: ${error?.message || error}`;
23032
+ LOG.error("MeshCoordinator", message);
23033
+ return { success: false, code: "mesh_coordinator_config_parse_failed", error: message, meshId, cliType, workspace };
23034
+ }
23035
+ }
22998
23036
  const returnManualFallback = (message) => ({
22999
23037
  success: false,
23000
23038
  code: "mesh_coordinator_manual_mcp_setup_required",
@@ -23023,11 +23061,15 @@ var DaemonCommandRouter = class {
23023
23061
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
23024
23062
  }
23025
23063
  const hadExistingMcpConfig = existsSync23(mcpConfigPath);
23026
- let existingMcpConfig = {};
23064
+ let existingMcpConfig = hermesBaseConfig?.config || {};
23065
+ if (hermesBaseConfig) {
23066
+ copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname9(mcpConfigPath));
23067
+ }
23027
23068
  if (hadExistingMcpConfig) {
23028
23069
  try {
23029
- existingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync15(mcpConfigPath, "utf-8"), configFormat);
23030
- copyFileSync3(mcpConfigPath, mcpConfigPath + ".backup");
23070
+ const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync15(mcpConfigPath, "utf-8"), configFormat);
23071
+ existingMcpConfig = { ...existingMcpConfig, ...parsedExistingMcpConfig };
23072
+ copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
23031
23073
  } catch (error) {
23032
23074
  LOG.error("MeshCoordinator", `Failed to parse existing MCP config ${mcpConfigPath}: ${error?.message || error}`);
23033
23075
  return {