@adhdev/daemon-core 0.9.76-rc.62 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.76-rc.62",
3
+ "version": "0.9.76-rc.64",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,6 +41,8 @@ import { buildMachineInfo, buildStatusSnapshot } from '../status/snapshot.js';
41
41
  import { getSessionCompletionMarker } from '../status/snapshot.js';
42
42
  import { execNpmCommandSync, resolveCurrentGlobalInstallSurface, spawnDetachedDaemonUpgradeHelper } from './upgrade-helper.js';
43
43
  import type { RepoMeshSessionCleanupMode } from '../repo-mesh-types.js';
44
+ import { homedir } from 'os';
45
+ import { join as pathJoin, resolve as pathResolve } from 'path';
44
46
 
45
47
  type ReleaseChannel = 'stable' | 'preview';
46
48
  const CHANNEL_NPM_TAG: Record<ReleaseChannel, 'latest' | 'next'> = { stable: 'latest', preview: 'next' };
@@ -136,6 +138,36 @@ function serializeMeshCoordinatorMcpConfig(config: Record<string, any>, format:
136
138
  return loadYamlModule().dump(config, { noRefs: true, lineWidth: 120 });
137
139
  }
138
140
 
141
+ function resolveHermesUserHome(): string {
142
+ const explicitHome = process.env.HERMES_HOME?.trim();
143
+ return explicitHome || pathJoin(homedir(), '.hermes');
144
+ }
145
+
146
+ function loadHermesCoordinatorBaseConfig(targetConfigPath: string): { config: Record<string, any>; sourceHome: string; sourceConfigPath: string } {
147
+ const sourceHome = resolveHermesUserHome();
148
+ const sourceConfigPath = pathJoin(sourceHome, 'config.yaml');
149
+ if (!fs.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
150
+ if (pathResolve(sourceConfigPath) === pathResolve(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
151
+
152
+ const parsed = parseMeshCoordinatorMcpConfig(fs.readFileSync(sourceConfigPath, 'utf-8'), 'hermes_config_yaml');
153
+ const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
154
+ return { config: baseConfig, sourceHome, sourceConfigPath };
155
+ }
156
+
157
+ function copyHermesCoordinatorCredentialFiles(sourceHome: string, targetHome: string) {
158
+ if (pathResolve(sourceHome) === pathResolve(targetHome)) return;
159
+ for (const fileName of ['.env', 'auth.json']) {
160
+ const sourcePath = pathJoin(sourceHome, fileName);
161
+ const targetPath = pathJoin(targetHome, fileName);
162
+ if (!fs.existsSync(sourcePath)) continue;
163
+ try {
164
+ fs.copyFileSync(sourcePath, targetPath);
165
+ } catch (error: any) {
166
+ LOG.warn('MeshCoordinator', `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
167
+ }
168
+ }
169
+ }
170
+
139
171
  // ─── Types ───
140
172
 
141
173
  export interface SessionHostControlPlane {
@@ -1601,6 +1633,16 @@ export class DaemonCommandRouter {
1601
1633
  const hermesManualFallback = cliType === 'hermes-cli' && configFormat === 'hermes_config_yaml'
1602
1634
  ? createHermesManualMeshCoordinatorSetup(meshId, workspace)
1603
1635
  : null;
1636
+ let hermesBaseConfig: { config: Record<string, any>; sourceHome: string; sourceConfigPath: string } | null = null;
1637
+ if (hermesManualFallback) {
1638
+ try {
1639
+ hermesBaseConfig = loadHermesCoordinatorBaseConfig(mcpConfigPath);
1640
+ } catch (error: any) {
1641
+ const message = `Failed to parse Hermes base config for automatic coordinator setup: ${error?.message || error}`;
1642
+ LOG.error('MeshCoordinator', message);
1643
+ return { success: false, code: 'mesh_coordinator_config_parse_failed', error: message, meshId, cliType, workspace };
1644
+ }
1645
+ }
1604
1646
  const returnManualFallback = (message: string) => ({
1605
1647
  success: false,
1606
1648
  code: 'mesh_coordinator_manual_mcp_setup_required',
@@ -1636,10 +1678,14 @@ export class DaemonCommandRouter {
1636
1678
 
1637
1679
  // Backup existing MCP config if present.
1638
1680
  const hadExistingMcpConfig = existsSync(mcpConfigPath);
1639
- let existingMcpConfig: Record<string, any> = {};
1681
+ let existingMcpConfig: Record<string, any> = hermesBaseConfig?.config || {};
1682
+ if (hermesBaseConfig) {
1683
+ copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname(mcpConfigPath));
1684
+ }
1640
1685
  if (hadExistingMcpConfig) {
1641
1686
  try {
1642
- existingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync(mcpConfigPath, 'utf-8'), configFormat);
1687
+ const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync(mcpConfigPath, 'utf-8'), configFormat);
1688
+ existingMcpConfig = { ...existingMcpConfig, ...parsedExistingMcpConfig };
1643
1689
  copyFileSync(mcpConfigPath, mcpConfigPath + '.backup');
1644
1690
  } catch (error: any) {
1645
1691
  LOG.error('MeshCoordinator', `Failed to parse existing MCP config ${mcpConfigPath}: ${error?.message || error}`);