@adhdev/daemon-core 0.9.76-rc.21 → 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.
@@ -63,6 +63,17 @@ type CliStartOptions = {
63
63
  settingsOverride?: Record<string, any>;
64
64
  extraEnv?: Record<string, string>;
65
65
  };
66
+ export interface CoordinatorDelegatedCliLaunchOptionsInput {
67
+ cliType: string;
68
+ workspace: string;
69
+ cliArgs?: string[];
70
+ env?: Record<string, string>;
71
+ }
72
+ export interface CoordinatorDelegatedCliLaunchOptions {
73
+ cliArgs: string[];
74
+ env: Record<string, string>;
75
+ }
76
+ export declare function buildCoordinatorDelegatedCliLaunchOptions(input: CoordinatorDelegatedCliLaunchOptionsInput): CoordinatorDelegatedCliLaunchOptions;
66
77
  export declare function supportsExplicitSessionResume(resume?: ProviderResumeCapability): boolean;
67
78
  export declare function resolveCliSessionBinding(provider: ProviderModule | undefined, normalizedType: string, cliArgs?: string[], requestedResumeSessionId?: string): CliSessionBinding;
68
79
  export declare class DaemonCliManager {
@@ -5,7 +5,7 @@
5
5
  * transports, and web-core. Git state is daemon-owned product truth; do not
6
6
  * infer these values from agent transcripts in frontend code.
7
7
  */
8
- export type GitFailureReason = 'not_git_repo' | 'git_not_installed' | 'timeout' | 'path_outside_repo' | 'dirty_index_required' | 'conflict' | 'invalid_args' | 'git_command_failed';
8
+ export type GitFailureReason = 'not_git_repo' | 'git_not_installed' | 'timeout' | 'path_outside_repo' | 'dirty_index_required' | 'conflict' | 'invalid_args' | 'nothing_to_commit' | 'git_command_failed';
9
9
  export interface GitRepoIdentity {
10
10
  workspace: string;
11
11
  repoRoot: string | null;
package/dist/index.js CHANGED
@@ -4890,6 +4890,7 @@ var FAILURE_REASONS = /* @__PURE__ */ new Set([
4890
4890
  "dirty_index_required",
4891
4891
  "conflict",
4892
4892
  "invalid_args",
4893
+ "nothing_to_commit",
4893
4894
  "git_command_failed"
4894
4895
  ]);
4895
4896
  function failure(reason, error) {
@@ -5134,7 +5135,10 @@ async function gitCheckpoint(workspace, message, includeUntracked) {
5134
5135
  } catch (err) {
5135
5136
  const output = (err?.stdout || "") + (err?.stderr || "");
5136
5137
  if (/nothing to commit/i.test(output)) {
5137
- throw new GitCommandError("git_command_failed", "Nothing to commit");
5138
+ throw new GitCommandError("nothing_to_commit", "Nothing to commit \u2014 working tree is clean.", {
5139
+ stdout: err?.stdout,
5140
+ stderr: err?.stderr
5141
+ });
5138
5142
  }
5139
5143
  throw err;
5140
5144
  }
@@ -15665,10 +15669,26 @@ ${effect.notification.body || ""}`.trim();
15665
15669
  }
15666
15670
  mergeConversationMessages(parsedMessages) {
15667
15671
  if (this.runtimeMessages.length === 0) return normalizeChatMessages(parsedMessages);
15668
- return normalizeChatMessages([...parsedMessages, ...this.runtimeMessages.map((entry) => entry.message)].map((message, index) => ({ message, index })).sort((a, b) => {
15669
- const aTime = a.message.receivedAt || a.message.timestamp || 0;
15670
- const bTime = b.message.receivedAt || b.message.timestamp || 0;
15671
- if (aTime !== bTime) return aTime - bTime;
15672
+ const parsedEntries = parsedMessages.map((message, index) => ({
15673
+ message,
15674
+ index,
15675
+ source: "parsed"
15676
+ }));
15677
+ const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
15678
+ message: entry.message,
15679
+ index: parsedMessages.length + index,
15680
+ source: "runtime"
15681
+ }));
15682
+ const getTime = (message) => {
15683
+ const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
15684
+ return Number.isFinite(value) && value > 0 ? value : 0;
15685
+ };
15686
+ return normalizeChatMessages([...parsedEntries, ...runtimeEntries].sort((a, b) => {
15687
+ const aTime = getTime(a.message);
15688
+ const bTime = getTime(b.message);
15689
+ if (aTime && bTime && aTime !== bTime) return aTime - bTime;
15690
+ if (aTime && !bTime && a.source === "runtime" && b.source === "parsed") return -1;
15691
+ if (!aTime && bTime && a.source === "parsed" && b.source === "runtime") return 1;
15672
15692
  return a.index - b.index;
15673
15693
  }).map((entry) => entry.message));
15674
15694
  }
@@ -17020,6 +17040,35 @@ function colorize(color, text) {
17020
17040
  const fn = chalkApi?.[color];
17021
17041
  return typeof fn === "function" ? fn(text) : text;
17022
17042
  }
17043
+ var COORDINATOR_DELEGATED_ENV_UNSETS = {
17044
+ ADHDEV_INLINE_MESH: "",
17045
+ ADHDEV_MCP_TRANSPORT: "",
17046
+ ADHDEV_MESH_ID: "",
17047
+ HERMES_EPHEMERAL_SYSTEM_PROMPT: ""
17048
+ };
17049
+ function hasCliArg(args, flag) {
17050
+ return args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
17051
+ }
17052
+ function ensureEmptyDelegatedMcpConfig(workspace) {
17053
+ const baseDir = path17.join(os13.tmpdir(), "adhdev-delegated-agent-empty-mcp");
17054
+ (0, import_fs6.mkdirSync)(baseDir, { recursive: true });
17055
+ const workspaceHash = crypto4.createHash("sha256").update(path17.resolve(workspace || os13.tmpdir())).digest("hex").slice(0, 16);
17056
+ const filePath = path17.join(baseDir, `${workspaceHash}.json`);
17057
+ (0, import_fs6.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
17058
+ return filePath;
17059
+ }
17060
+ function buildCoordinatorDelegatedCliLaunchOptions(input) {
17061
+ const cliType = String(input.cliType || "").trim();
17062
+ const cliArgs = Array.isArray(input.cliArgs) ? [...input.cliArgs] : [];
17063
+ const env = { ...input.env || {}, ...COORDINATOR_DELEGATED_ENV_UNSETS };
17064
+ if (cliType === "hermes-cli" && !hasCliArg(cliArgs, "--ignore-user-config")) {
17065
+ cliArgs.unshift("--ignore-user-config");
17066
+ }
17067
+ if (cliType === "claude-cli" && !hasCliArg(cliArgs, "--mcp-config")) {
17068
+ cliArgs.unshift("--mcp-config", ensureEmptyDelegatedMcpConfig(input.workspace));
17069
+ }
17070
+ return { cliArgs, env };
17071
+ }
17023
17072
  function isUuid(value) {
17024
17073
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
17025
17074
  }
@@ -17653,12 +17702,23 @@ Run 'adhdev doctor' for detailed diagnostics.`
17653
17702
  const dir = resolved.path;
17654
17703
  const launchSource = resolved.source;
17655
17704
  if (!cliType) throw new Error("cliType required");
17705
+ const settingsOverride = args?.settings && typeof args.settings === "object" ? args.settings : void 0;
17706
+ const delegatedLaunch = settingsOverride?.launchedByCoordinator === true ? buildCoordinatorDelegatedCliLaunchOptions({
17707
+ cliType,
17708
+ workspace: dir,
17709
+ cliArgs: args?.cliArgs,
17710
+ env: args?.env
17711
+ }) : null;
17656
17712
  const started = await this.startSession(
17657
17713
  cliType,
17658
17714
  dir,
17659
- args?.cliArgs,
17715
+ delegatedLaunch ? delegatedLaunch.cliArgs : args?.cliArgs,
17660
17716
  args?.initialModel,
17661
- { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings, extraEnv: args?.env }
17717
+ {
17718
+ resumeSessionId: args?.resumeSessionId,
17719
+ settingsOverride,
17720
+ extraEnv: delegatedLaunch ? delegatedLaunch.env : args?.env
17721
+ }
17662
17722
  );
17663
17723
  return {
17664
17724
  success: true,
@@ -22139,7 +22199,7 @@ var DaemonCommandRouter = class {
22139
22199
  workspace
22140
22200
  };
22141
22201
  }
22142
- const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3, mkdirSync: mkdirSync14 } = await import("fs");
22202
+ const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync13, copyFileSync: copyFileSync3, mkdirSync: mkdirSync15 } = await import("fs");
22143
22203
  const { dirname: dirname9 } = await import("path");
22144
22204
  const mcpConfigPath = coordinatorSetup.configPath;
22145
22205
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -22163,7 +22223,7 @@ var DaemonCommandRouter = class {
22163
22223
  };
22164
22224
  }
22165
22225
  try {
22166
- mkdirSync14(dirname9(mcpConfigPath), { recursive: true });
22226
+ mkdirSync15(dirname9(mcpConfigPath), { recursive: true });
22167
22227
  } catch (error) {
22168
22228
  const message = `Could not prepare MCP config path for automatic setup: ${error?.message || error}`;
22169
22229
  LOG.error("MeshCoordinator", message);
@@ -22195,7 +22255,7 @@ var DaemonCommandRouter = class {
22195
22255
  }
22196
22256
  };
22197
22257
  try {
22198
- writeFileSync12(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
22258
+ writeFileSync13(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
22199
22259
  } catch (error) {
22200
22260
  const message = `Could not write MCP config for automatic setup: ${error?.message || error}`;
22201
22261
  LOG.error("MeshCoordinator", message);