@adhdev/daemon-core 0.9.76-rc.22 → 0.9.76-rc.23

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.22",
3
+ "version": "0.9.76-rc.23",
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",
@@ -8,7 +8,7 @@
8
8
  import * as os from 'os';
9
9
  import * as path from 'path';
10
10
  import * as crypto from 'crypto';
11
- import { existsSync } from 'fs';
11
+ import { existsSync, mkdirSync, writeFileSync } from 'fs';
12
12
  import { execFileSync } from 'child_process';
13
13
  import chalk from 'chalk';
14
14
  import { ProviderCliAdapter } from '../cli-adapters/provider-cli-adapter.js';
@@ -138,6 +138,56 @@ type CliStartOptions = {
138
138
  extraEnv?: Record<string, string>;
139
139
  };
140
140
 
141
+ const COORDINATOR_DELEGATED_ENV_UNSETS: Record<string, string> = {
142
+ ADHDEV_INLINE_MESH: '',
143
+ ADHDEV_MCP_TRANSPORT: '',
144
+ ADHDEV_MESH_ID: '',
145
+ HERMES_EPHEMERAL_SYSTEM_PROMPT: '',
146
+ };
147
+
148
+ export interface CoordinatorDelegatedCliLaunchOptionsInput {
149
+ cliType: string;
150
+ workspace: string;
151
+ cliArgs?: string[];
152
+ env?: Record<string, string>;
153
+ }
154
+
155
+ export interface CoordinatorDelegatedCliLaunchOptions {
156
+ cliArgs: string[];
157
+ env: Record<string, string>;
158
+ }
159
+
160
+ function hasCliArg(args: string[], flag: string): boolean {
161
+ return args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
162
+ }
163
+
164
+ function ensureEmptyDelegatedMcpConfig(workspace: string): string {
165
+ const baseDir = path.join(os.tmpdir(), 'adhdev-delegated-agent-empty-mcp');
166
+ mkdirSync(baseDir, { recursive: true });
167
+ const workspaceHash = crypto.createHash('sha256').update(path.resolve(workspace || os.tmpdir())).digest('hex').slice(0, 16);
168
+ const filePath = path.join(baseDir, `${workspaceHash}.json`);
169
+ writeFileSync(filePath, JSON.stringify({ mcpServers: {} }, null, 2), 'utf-8');
170
+ return filePath;
171
+ }
172
+
173
+ export function buildCoordinatorDelegatedCliLaunchOptions(
174
+ input: CoordinatorDelegatedCliLaunchOptionsInput,
175
+ ): CoordinatorDelegatedCliLaunchOptions {
176
+ const cliType = String(input.cliType || '').trim();
177
+ const cliArgs = Array.isArray(input.cliArgs) ? [...input.cliArgs] : [];
178
+ const env: Record<string, string> = { ...(input.env || {}), ...COORDINATOR_DELEGATED_ENV_UNSETS };
179
+
180
+ if (cliType === 'hermes-cli' && !hasCliArg(cliArgs, '--ignore-user-config')) {
181
+ cliArgs.unshift('--ignore-user-config');
182
+ }
183
+
184
+ if (cliType === 'claude-cli' && !hasCliArg(cliArgs, '--mcp-config')) {
185
+ cliArgs.unshift('--mcp-config', ensureEmptyDelegatedMcpConfig(input.workspace));
186
+ }
187
+
188
+ return { cliArgs, env };
189
+ }
190
+
141
191
  function isUuid(value: string): boolean {
142
192
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
143
193
  }
@@ -909,12 +959,25 @@ export class DaemonCliManager {
909
959
  const launchSource = resolved.source;
910
960
  if (!cliType) throw new Error('cliType required');
911
961
 
962
+ const settingsOverride = args?.settings && typeof args.settings === 'object' ? args.settings : undefined;
963
+ const delegatedLaunch = settingsOverride?.launchedByCoordinator === true
964
+ ? buildCoordinatorDelegatedCliLaunchOptions({
965
+ cliType,
966
+ workspace: dir,
967
+ cliArgs: args?.cliArgs,
968
+ env: args?.env,
969
+ })
970
+ : null;
912
971
  const started = await this.startSession(
913
972
  cliType,
914
973
  dir,
915
- args?.cliArgs,
974
+ delegatedLaunch ? delegatedLaunch.cliArgs : args?.cliArgs,
916
975
  args?.initialModel,
917
- { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings, extraEnv: args?.env },
976
+ {
977
+ resumeSessionId: args?.resumeSessionId,
978
+ settingsOverride,
979
+ extraEnv: delegatedLaunch ? delegatedLaunch.env : args?.env,
980
+ },
918
981
  );
919
982
 
920
983
  return {