@adhdev/daemon-standalone 0.9.76-rc.4 → 0.9.76-rc.6

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.
@@ -32,6 +32,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
32
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
33
  mod
34
34
  ));
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
36
 
36
37
  // ../session-host-core/dist/index.mjs
37
38
  function getDefaultSessionHostEndpoint(appName = "adhdev") {
@@ -31579,7 +31580,7 @@ function resolveAdhdevMcpServerLaunch(options) {
31579
31580
  if (!entryPath) return null;
31580
31581
  return {
31581
31582
  command: options.nodeExecutable?.trim() || process.execPath,
31582
- args: [entryPath, "--repo-mesh", options.meshId]
31583
+ args: [entryPath, "--mode", "ipc", "--repo-mesh", options.meshId]
31583
31584
  };
31584
31585
  }
31585
31586
  function resolveAdhdevMcpEntryPath(explicitPath) {
@@ -36756,7 +36757,7 @@ async function shutdownDaemonComponents(components) {
36756
36757
  }
36757
36758
  cdpManagers.clear();
36758
36759
  }
36759
- var import_os, import_path, import_fs, import_crypto2, import_fs2, import_path2, import_crypto3, fs2, path9, os4, os8, os9, path13, import_child_process, os10, path14, os11, import_child_process2, import_fs3, import_promises4, path, import_util3, import_promises5, path22, path32, fs, os5, path4, import_crypto4, path5, path6, import_fs4, import_path3, import_child_process3, import_fs5, import_os2, path7, import_child_process4, os22, path8, import_fs6, os32, import_child_process5, http, crypto2, fs3, path10, os52, fs4, os6, path11, import_crypto5, fs5, path12, os7, os13, path16, crypto4, import_fs7, import_child_process6, os12, path15, crypto3, fs6, import_module, import_stream2, import_child_process7, import_child_process8, net2, os15, path18, fs7, path17, os14, fs8, path19, os16, import_fs8, import_module2, import_path4, os17, import_child_process9, import_child_process10, fs9, os18, path20, fs10, fs11, path21, os19, import_child_process11, import_os3, http2, fs15, path25, fs12, path222, fs13, path23, fs14, path24, os20, import_child_process12, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __require2, __esm2, __export2, __copyProps2, __toCommonJS, DEFAULT_MESH_POLICY, init_repo_mesh_types, config_exports, DEFAULT_CONFIG, MACHINE_ID_PREFIX, init_config, mesh_config_exports, init_mesh_config, coordinator_prompt_exports, TOOLS_SECTION, WORKFLOW_SECTION, RULES_SECTION, init_coordinator_prompt, LEVEL_NUM, LEVEL_LABEL, currentLevel, LOG_DIR, MAX_LOG_SIZE, MAX_LOG_DAYS, currentDate, currentLogFile, writeCount, RING_BUFFER_SIZE, ringBuffer, origConsoleLog, origConsoleError, origConsoleWarn, LOG, interceptorInstalled, LOG_PATH, init_logger, NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig, init_debug_config, DEFAULT_BINDING_CANDIDATES, cachedBinding, cachedBindingError, GhosttyVtTerminalBackend, init_ghostty_vt_backend, TerminalCtor, XtermTerminalBackend, init_xterm_backend, DEFAULT_SCROLLBACK, loggedTerminalBackends, TerminalScreen, init_terminal_screen, init_spawn_env, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory, init_pty_transport, buildCliSpawnEnv, init_provider_cli_shared, init_provider_cli_parse, init_provider_cli_config, init_provider_cli_runtime, provider_cli_adapter_exports, ProviderCliAdapter, init_provider_cli_adapter, execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GitCommandError, DEFAULT_MAX_FILES, DEFAULT_MAX_BYTES, summarizeGitStatus, InMemoryGitSnapshotStore, DEFAULT_GIT_WORKSPACE_POLL_INTERVAL_MS, MIN_GIT_WORKSPACE_POLL_INTERVAL_MS, GitWorkspaceMonitor, GIT_COMMAND_NAMES, SNAPSHOT_REASONS, FAILURE_REASONS, defaultSnapshotStore, defaultGitCommandServices, BUSY_STATUSES, TERMINAL_STATUSES, TurnSnapshotTracker, MAX_WORKSPACES, MAX_ACTIVITY, MAX_SAVED_SESSIONS, DEFAULT_STATE, BUILTIN_IDE_DEFINITIONS, registeredIDEs, LIVE_LIFECYCLES, DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS, LIVE_RUNTIME_LIFECYCLES, DaemonCdpManager, CdpDomHandlers, DEFAULT_MONITOR_CONFIG, StatusMonitor, BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter, IDE_PROVIDER_SESSION_CAPABILITIES_BASE, EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE, ExtensionProviderInstance, VALID_STATUSES, VALID_ROLES, VALID_BUBBLE_STATES, VALID_TURN_STATUSES, DEFAULT_APPROVAL_POSITIVE_HINTS, IdeProviderInstance, DEFAULT_CDP_SCAN_INTERVAL_MS, DEFAULT_CDP_DISCOVERY_INTERVAL_MS, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS, MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_READY_TIMEOUT_MS, STANDALONE_CDP_SCAN_INTERVAL_MS, DaemonCdpScanner, DaemonCdpInitializer, WORKING_STATUSES, FULL_STATUS_ACTIVE_CHAT_OPTIONS, LIVE_STATUS_ACTIVE_CHAT_OPTIONS, STATUS_MODAL_MESSAGE_LIMIT, STATUS_MODAL_BUTTON_LIMIT, IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, CLI_CHAT_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES, VALID_INPUT_MEDIA_TYPES, globalStore, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN, KEY_TO_VK, COMMAND_DEBUG_LEVELS, DaemonCommandHandler, CachedDatabaseSync, CliProviderInstance, AcpProviderInstance, chalkModule, chalkApi, DaemonCliManager, VALID_CAPABILITY_MEDIA_TYPES, KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES, ProviderLoader, _providerLoader, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession, UPGRADE_HELPER_ENV, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter, DaemonStatusReporter, DEFAULT_DAEMON_PORT, DAEMON_WS_PATH, ProviderStreamAdapter, DaemonAgentStreamManager, AgentStreamPoller, ProviderInstanceManager, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive, DEV_SERVER_PORT, DevServer, SessionHostRuntimeTransport, SessionHostPtyTransportFactory, DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME, STARTUP_TIMEOUT_MS, STARTUP_POLL_MS, EXTENSION_CATALOG, SessionRegistry;
36760
+ var import_os, import_path, import_fs, import_crypto2, import_fs2, import_path2, import_crypto3, fs2, path9, os4, os8, os9, path13, import_child_process, os10, path14, os11, import_child_process2, import_fs3, import_promises4, path, import_util3, import_promises5, path22, path32, fs, os5, path4, import_crypto4, path5, path6, import_fs4, import_path3, import_child_process3, import_fs5, import_os2, path7, import_child_process4, os22, path8, import_fs6, os32, import_child_process5, http, crypto2, fs3, path10, os52, fs4, os6, path11, import_crypto5, fs5, path12, os7, os13, path16, crypto4, import_fs7, import_child_process6, os12, path15, crypto3, fs6, import_module, import_stream2, import_child_process7, import_child_process8, net2, os15, path18, fs7, path17, os14, fs8, path19, os16, import_fs8, import_module2, import_path4, os17, import_child_process9, import_child_process10, fs9, os18, path20, fs10, fs11, path21, os19, import_child_process11, import_os3, http2, fs15, path25, fs12, path222, fs13, path23, fs14, path24, os20, import_child_process12, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __require2, __esm2, __export2, __copyProps2, __toCommonJS2, DEFAULT_MESH_POLICY, init_repo_mesh_types, config_exports, DEFAULT_CONFIG, MACHINE_ID_PREFIX, init_config, mesh_config_exports, init_mesh_config, coordinator_prompt_exports, TOOLS_SECTION, WORKFLOW_SECTION, RULES_SECTION, init_coordinator_prompt, LEVEL_NUM, LEVEL_LABEL, currentLevel, LOG_DIR, MAX_LOG_SIZE, MAX_LOG_DAYS, currentDate, currentLogFile, writeCount, RING_BUFFER_SIZE, ringBuffer, origConsoleLog, origConsoleError, origConsoleWarn, LOG, interceptorInstalled, LOG_PATH, init_logger, NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig, init_debug_config, DEFAULT_BINDING_CANDIDATES, cachedBinding, cachedBindingError, GhosttyVtTerminalBackend, init_ghostty_vt_backend, TerminalCtor, XtermTerminalBackend, init_xterm_backend, DEFAULT_SCROLLBACK, loggedTerminalBackends, TerminalScreen, init_terminal_screen, init_spawn_env, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory, init_pty_transport, buildCliSpawnEnv, init_provider_cli_shared, init_provider_cli_parse, init_provider_cli_config, init_provider_cli_runtime, provider_cli_adapter_exports, ProviderCliAdapter, init_provider_cli_adapter, execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GitCommandError, DEFAULT_MAX_FILES, DEFAULT_MAX_BYTES, summarizeGitStatus, InMemoryGitSnapshotStore, DEFAULT_GIT_WORKSPACE_POLL_INTERVAL_MS, MIN_GIT_WORKSPACE_POLL_INTERVAL_MS, GitWorkspaceMonitor, GIT_COMMAND_NAMES, SNAPSHOT_REASONS, FAILURE_REASONS, defaultSnapshotStore, defaultGitCommandServices, BUSY_STATUSES, TERMINAL_STATUSES, TurnSnapshotTracker, MAX_WORKSPACES, MAX_ACTIVITY, MAX_SAVED_SESSIONS, DEFAULT_STATE, BUILTIN_IDE_DEFINITIONS, registeredIDEs, LIVE_LIFECYCLES, DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS, LIVE_RUNTIME_LIFECYCLES, DaemonCdpManager, CdpDomHandlers, DEFAULT_MONITOR_CONFIG, StatusMonitor, BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter, IDE_PROVIDER_SESSION_CAPABILITIES_BASE, EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE, ExtensionProviderInstance, VALID_STATUSES, VALID_ROLES, VALID_BUBBLE_STATES, VALID_TURN_STATUSES, DEFAULT_APPROVAL_POSITIVE_HINTS, IdeProviderInstance, DEFAULT_CDP_SCAN_INTERVAL_MS, DEFAULT_CDP_DISCOVERY_INTERVAL_MS, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS, MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_READY_TIMEOUT_MS, STANDALONE_CDP_SCAN_INTERVAL_MS, DaemonCdpScanner, DaemonCdpInitializer, WORKING_STATUSES, FULL_STATUS_ACTIVE_CHAT_OPTIONS, LIVE_STATUS_ACTIVE_CHAT_OPTIONS, STATUS_MODAL_MESSAGE_LIMIT, STATUS_MODAL_BUTTON_LIMIT, IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, CLI_CHAT_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES, VALID_INPUT_MEDIA_TYPES, globalStore, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN, KEY_TO_VK, COMMAND_DEBUG_LEVELS, DaemonCommandHandler, CachedDatabaseSync, CliProviderInstance, AcpProviderInstance, chalkModule, chalkApi, DaemonCliManager, VALID_CAPABILITY_MEDIA_TYPES, KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES, ProviderLoader, _providerLoader, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession, UPGRADE_HELPER_ENV, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter, DaemonStatusReporter, DEFAULT_DAEMON_PORT, DAEMON_WS_PATH, ProviderStreamAdapter, DaemonAgentStreamManager, AgentStreamPoller, ProviderInstanceManager, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive, DEV_SERVER_PORT, DevServer, SessionHostRuntimeTransport, SessionHostPtyTransportFactory, DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME, STARTUP_TIMEOUT_MS, STARTUP_POLL_MS, EXTENSION_CATALOG, SessionRegistry;
36760
36761
  var init_dist2 = __esm({
36761
36762
  "../daemon-core/dist/index.mjs"() {
36762
36763
  "use strict";
@@ -36896,7 +36897,7 @@ var init_dist2 = __esm({
36896
36897
  }
36897
36898
  return to;
36898
36899
  };
36899
- __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
36900
+ __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
36900
36901
  init_repo_mesh_types = __esm2({
36901
36902
  "src/repo-mesh-types.ts"() {
36902
36903
  "use strict";
@@ -47178,14 +47179,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
47178
47179
  }
47179
47180
  readConfig() {
47180
47181
  try {
47181
- const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
47182
+ const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS2(config_exports));
47182
47183
  return loadConfig2();
47183
47184
  } catch {
47184
47185
  return null;
47185
47186
  }
47186
47187
  }
47187
47188
  writeConfig(config2) {
47188
- const { saveConfig: saveConfig3 } = (init_config(), __toCommonJS(config_exports));
47189
+ const { saveConfig: saveConfig3 } = (init_config(), __toCommonJS2(config_exports));
47189
47190
  saveConfig3(config2);
47190
47191
  }
47191
47192
  getPlatformVersionCommand(versionCommand) {
@@ -48344,7 +48345,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
48344
48345
  };
48345
48346
  if (args?.inlineMesh) {
48346
48347
  mcpServerEntry.env = {
48347
- ADHDEV_INLINE_MESH: JSON.stringify(mesh)
48348
+ ADHDEV_INLINE_MESH: JSON.stringify(mesh),
48349
+ ADHDEV_MCP_TRANSPORT: "ipc"
48348
48350
  };
48349
48351
  }
48350
48352
  const mcpConfig = {
@@ -51907,6 +51909,13 @@ data: ${JSON.stringify(msg.data)}
51907
51909
  }
51908
51910
  });
51909
51911
 
51912
+ // src/index.ts
51913
+ var index_exports = {};
51914
+ __export(index_exports, {
51915
+ parseArgs: () => parseArgs
51916
+ });
51917
+ module.exports = __toCommonJS(index_exports);
51918
+
51910
51919
  // src/server.ts
51911
51920
  var import_server = require("@modelcontextprotocol/sdk/server/index.js");
51912
51921
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
@@ -52118,6 +52127,104 @@ var CloudTransport = class {
52118
52127
  }
52119
52128
  };
52120
52129
 
52130
+ // src/transports/ipc.ts
52131
+ var DEFAULT_IPC_PORT = 19222;
52132
+ var DEFAULT_IPC_PATH = "/ipc";
52133
+ var IpcTransport = class {
52134
+ port;
52135
+ path;
52136
+ constructor(opts = {}) {
52137
+ this.port = opts.port ?? DEFAULT_IPC_PORT;
52138
+ this.path = opts.path || DEFAULT_IPC_PATH;
52139
+ }
52140
+ async ping() {
52141
+ try {
52142
+ const res = await fetch(`http://127.0.0.1:${this.port}/health`);
52143
+ return res.ok;
52144
+ } catch {
52145
+ return false;
52146
+ }
52147
+ }
52148
+ async getStatus() {
52149
+ return this.command("get_status_metadata");
52150
+ }
52151
+ async command(type, args = {}) {
52152
+ return this.sendIpcCommand(type, args);
52153
+ }
52154
+ async meshCommand(targetDaemonId, command, args = {}) {
52155
+ return this.sendIpcCommand("mesh_relay_command", {
52156
+ targetDaemonId,
52157
+ command,
52158
+ args
52159
+ });
52160
+ }
52161
+ async sendIpcCommand(type, args) {
52162
+ const WebSocketCtor = globalThis.WebSocket;
52163
+ if (!WebSocketCtor) {
52164
+ throw new Error("WebSocket is not available in this Node runtime; Node 20+ is required for daemon IPC mode");
52165
+ }
52166
+ return new Promise((resolve18, reject) => {
52167
+ const requestId = `mcp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
52168
+ const ws = new WebSocketCtor(`ws://127.0.0.1:${this.port}${this.path}`);
52169
+ let settled = false;
52170
+ const finish = (fn) => {
52171
+ if (settled) return;
52172
+ settled = true;
52173
+ clearTimeout(timeout);
52174
+ try {
52175
+ ws.close();
52176
+ } catch {
52177
+ }
52178
+ fn();
52179
+ };
52180
+ const timeout = setTimeout(() => {
52181
+ finish(() => reject(new Error(`Daemon IPC command '${type}' timed out after 15s`)));
52182
+ }, 15e3);
52183
+ const send = () => {
52184
+ ws.send(JSON.stringify({
52185
+ type: "ext:command",
52186
+ payload: { command: type, args, requestId }
52187
+ }));
52188
+ };
52189
+ ws.addEventListener("open", () => {
52190
+ ws.send(JSON.stringify({
52191
+ type: "ext:register",
52192
+ payload: {
52193
+ ideType: "mcp-server",
52194
+ ideVersion: "1.0.0",
52195
+ extensionVersion: "1.0.0",
52196
+ instanceId: `mcp-server-${process.pid}`,
52197
+ machineId: "mcp-server",
52198
+ workspaceFolders: []
52199
+ }
52200
+ }));
52201
+ });
52202
+ ws.addEventListener("message", (event) => {
52203
+ try {
52204
+ const raw = typeof event.data === "string" ? event.data : String(event.data);
52205
+ const msg = JSON.parse(raw);
52206
+ if (msg?.type === "daemon:welcome") {
52207
+ send();
52208
+ return;
52209
+ }
52210
+ if (msg?.type !== "ext:command_result") return;
52211
+ if (msg?.payload?.requestId !== requestId) return;
52212
+ const payload = msg.payload;
52213
+ if (payload?.success === false) {
52214
+ finish(() => reject(new Error(payload.error || `Daemon IPC command '${type}' failed`)));
52215
+ return;
52216
+ }
52217
+ finish(() => resolve18(payload?.result ?? payload));
52218
+ } catch {
52219
+ }
52220
+ });
52221
+ ws.addEventListener("error", () => {
52222
+ finish(() => reject(new Error(`Cannot connect to daemon IPC at ws://127.0.0.1:${this.port}${this.path}`)));
52223
+ });
52224
+ });
52225
+ }
52226
+ };
52227
+
52121
52228
  // src/transports/mode.ts
52122
52229
  function isLocalTransport(transport) {
52123
52230
  return typeof transport.command === "function";
@@ -53154,6 +53261,15 @@ function findNode(mesh, nodeId) {
53154
53261
  if (!node) throw new Error(`Node '${nodeId}' is not a member of mesh '${mesh.name}'`);
53155
53262
  return node;
53156
53263
  }
53264
+ async function commandForNode(ctx, node, command, args = {}) {
53265
+ if (ctx.transport instanceof IpcTransport && node.daemonId) {
53266
+ return ctx.transport.meshCommand(node.daemonId, command, args);
53267
+ }
53268
+ if (isLocalTransport(ctx.transport)) {
53269
+ return ctx.transport.command(command, args);
53270
+ }
53271
+ throw new Error(`Command '${command}' requires daemon IPC/local transport for node '${node.id}'`);
53272
+ }
53157
53273
  var MESH_STATUS_TOOL = {
53158
53274
  name: "mesh_status",
53159
53275
  description: "Get the current status of all nodes in the repo mesh \u2014 health, git state, active sessions. Use this to decide which node to send work to.",
@@ -53271,7 +53387,7 @@ async function meshStatus(ctx) {
53271
53387
  entry.isDirty = status?.isDirty;
53272
53388
  entry.uncommittedChanges = status?.uncommittedChanges ?? 0;
53273
53389
  } else if (isLocalTransport(transport)) {
53274
- const statusResult = await transport.command("git_status", { workspace: node.workspace });
53390
+ const statusResult = await commandForNode(ctx, node, "git_status", { workspace: node.workspace });
53275
53391
  const status = statusResult?.status ?? statusResult;
53276
53392
  entry.health = status?.isGitRepo ? status?.isDirty ? "dirty" : "online" : "degraded";
53277
53393
  entry.branch = status?.branch;
@@ -53317,9 +53433,10 @@ async function meshSendTask(ctx, args) {
53317
53433
  return JSON.stringify({ error: `Node '${args.node_id}' is read-only` });
53318
53434
  }
53319
53435
  if (isLocalTransport(ctx.transport)) {
53320
- await ctx.transport.command("send_chat", {
53436
+ await commandForNode(ctx, node, "send_chat", {
53321
53437
  message: args.message,
53322
- sessionId: args.session_id
53438
+ sessionId: args.session_id,
53439
+ targetSessionId: args.session_id
53323
53440
  });
53324
53441
  return JSON.stringify({ success: true, nodeId: args.node_id, sessionId: args.session_id });
53325
53442
  } else {
@@ -53327,10 +53444,11 @@ async function meshSendTask(ctx, args) {
53327
53444
  }
53328
53445
  }
53329
53446
  async function meshReadChat(ctx, args) {
53330
- findNode(ctx.mesh, args.node_id);
53447
+ const node = findNode(ctx.mesh, args.node_id);
53331
53448
  if (isLocalTransport(ctx.transport)) {
53332
- const result = await ctx.transport.command("read_chat", {
53449
+ const result = await commandForNode(ctx, node, "read_chat", {
53333
53450
  sessionId: args.session_id,
53451
+ targetSessionId: args.session_id,
53334
53452
  tailLimit: args.tail ?? 10
53335
53453
  });
53336
53454
  return JSON.stringify(result, null, 2);
@@ -53341,7 +53459,7 @@ async function meshReadChat(ctx, args) {
53341
53459
  async function meshLaunchSession(ctx, args) {
53342
53460
  const node = findNode(ctx.mesh, args.node_id);
53343
53461
  if (isLocalTransport(ctx.transport)) {
53344
- const result = await ctx.transport.command("launch_cli", {
53462
+ const result = await commandForNode(ctx, node, "launch_cli", {
53345
53463
  cliType: args.type,
53346
53464
  dir: node.workspace,
53347
53465
  settings: {
@@ -53365,10 +53483,10 @@ async function meshGitStatus(ctx, args) {
53365
53483
  diff: result?.diff ?? null
53366
53484
  }, null, 2);
53367
53485
  } else if (isLocalTransport(ctx.transport)) {
53368
- const statusResult = await ctx.transport.command("git_status", {
53486
+ const statusResult = await commandForNode(ctx, node, "git_status", {
53369
53487
  workspace: node.workspace
53370
53488
  });
53371
- const diffResult = await ctx.transport.command("git_diff_summary", {
53489
+ const diffResult = await commandForNode(ctx, node, "git_diff_summary", {
53372
53490
  workspace: node.workspace
53373
53491
  });
53374
53492
  return JSON.stringify({
@@ -53387,7 +53505,7 @@ async function meshCheckpoint(ctx, args) {
53387
53505
  return JSON.stringify({ error: `Node '${args.node_id}' is read-only \u2014 cannot checkpoint` });
53388
53506
  }
53389
53507
  if (isLocalTransport(ctx.transport)) {
53390
- const result = await ctx.transport.command("git_checkpoint", {
53508
+ const result = await commandForNode(ctx, node, "git_checkpoint", {
53391
53509
  workspace: node.workspace,
53392
53510
  message: args.message
53393
53511
  });
@@ -53397,10 +53515,11 @@ async function meshCheckpoint(ctx, args) {
53397
53515
  }
53398
53516
  }
53399
53517
  async function meshApprove(ctx, args) {
53400
- findNode(ctx.mesh, args.node_id);
53518
+ const node = findNode(ctx.mesh, args.node_id);
53401
53519
  if (isLocalTransport(ctx.transport)) {
53402
- const result = await ctx.transport.command("resolve_action", {
53520
+ const result = await commandForNode(ctx, node, "resolve_action", {
53403
53521
  sessionId: args.session_id,
53522
+ targetSessionId: args.session_id,
53404
53523
  action: args.action === "reject" ? "reject" : "approve"
53405
53524
  });
53406
53525
  return JSON.stringify(result, null, 2);
@@ -53411,10 +53530,10 @@ async function meshApprove(ctx, args) {
53411
53530
 
53412
53531
  // src/server.ts
53413
53532
  async function startMcpServer(opts) {
53414
- const transport = opts.mode === "cloud" ? new CloudTransport({ apiKey: opts.apiKey, baseUrl: opts.baseUrl }) : new LocalTransport({ port: opts.port, password: opts.password });
53533
+ const transport = opts.mode === "cloud" ? new CloudTransport({ apiKey: opts.apiKey, baseUrl: opts.baseUrl }) : opts.mode === "ipc" ? new IpcTransport({ port: opts.port }) : new LocalTransport({ port: opts.port, password: opts.password });
53415
53534
  const alive = await transport.ping();
53416
53535
  if (!alive) {
53417
- const hint = opts.mode === "local" ? `Make sure the standalone daemon is running (adhdev standalone or npx @adhdev/daemon-standalone).` : `Check your API key and network connectivity.`;
53536
+ const hint = opts.mode === "local" ? `Make sure the standalone daemon is running (adhdev standalone or npx @adhdev/daemon-standalone).` : opts.mode === "ipc" ? `Make sure the cloud daemon is running with local IPC enabled (adhdev daemon).` : `Check your API key and network connectivity.`;
53418
53537
  process.stderr.write(`[adhdev-mcp] Cannot reach ${opts.mode} daemon. ${hint}
53419
53538
  `);
53420
53539
  process.exit(1);
@@ -53497,7 +53616,7 @@ async function startMcpServer(opts) {
53497
53616
  `);
53498
53617
  }
53499
53618
  }
53500
- if (!mesh && transport instanceof LocalTransport) {
53619
+ if (!mesh && (transport instanceof LocalTransport || transport instanceof IpcTransport)) {
53501
53620
  try {
53502
53621
  const result = await transport.command("get_mesh", { meshId: opts.meshId });
53503
53622
  if (result?.success && result.mesh) {
@@ -53701,13 +53820,14 @@ async function startMcpServer(opts) {
53701
53820
  }
53702
53821
 
53703
53822
  // src/index.ts
53704
- function parseArgs(argv) {
53823
+ function parseArgs(argv, env2 = process.env) {
53705
53824
  const args = argv.slice(2);
53706
53825
  let apiKey;
53707
53826
  let baseUrl;
53708
53827
  let port;
53709
53828
  let password;
53710
53829
  let meshId;
53830
+ let explicitMode;
53711
53831
  for (let i = 0; i < args.length; i++) {
53712
53832
  const arg = args[i];
53713
53833
  if ((arg === "--api-key" || arg === "-k") && args[i + 1]) {
@@ -53716,6 +53836,12 @@ function parseArgs(argv) {
53716
53836
  apiKey = arg.slice("--api-key=".length);
53717
53837
  } else if (arg === "--base-url" && args[i + 1]) {
53718
53838
  baseUrl = args[++i];
53839
+ } else if (arg === "--mode" && args[i + 1]) {
53840
+ const value = String(args[++i]).trim();
53841
+ if (value === "local" || value === "cloud" || value === "ipc") explicitMode = value;
53842
+ } else if (arg?.startsWith("--mode=")) {
53843
+ const value = arg.slice("--mode=".length).trim();
53844
+ if (value === "local" || value === "cloud" || value === "ipc") explicitMode = value;
53719
53845
  } else if (arg === "--port" && args[i + 1]) {
53720
53846
  port = Number(args[++i]);
53721
53847
  } else if (arg?.startsWith("--port=")) {
@@ -53731,10 +53857,14 @@ function parseArgs(argv) {
53731
53857
  process.exit(0);
53732
53858
  }
53733
53859
  }
53734
- if (!apiKey && process.env.ADHDEV_API_KEY) apiKey = process.env.ADHDEV_API_KEY;
53735
- if (!password && process.env.ADHDEV_PASSWORD) password = process.env.ADHDEV_PASSWORD;
53736
- if (!meshId && process.env.ADHDEV_MESH_ID) meshId = process.env.ADHDEV_MESH_ID;
53737
- const mode = apiKey ? "cloud" : "local";
53860
+ if (!apiKey && env2.ADHDEV_API_KEY) apiKey = env2.ADHDEV_API_KEY;
53861
+ if (!password && env2.ADHDEV_PASSWORD) password = env2.ADHDEV_PASSWORD;
53862
+ if (!meshId && env2.ADHDEV_MESH_ID) meshId = env2.ADHDEV_MESH_ID;
53863
+ if (!explicitMode && env2.ADHDEV_MCP_TRANSPORT) {
53864
+ const value = env2.ADHDEV_MCP_TRANSPORT.trim();
53865
+ if (value === "local" || value === "cloud" || value === "ipc") explicitMode = value;
53866
+ }
53867
+ const mode = explicitMode || (apiKey ? "cloud" : meshId && env2.ADHDEV_INLINE_MESH ? "ipc" : "local");
53738
53868
  return { mode, port, password, apiKey, baseUrl, meshId };
53739
53869
  }
53740
53870
  function printHelp() {
@@ -53744,10 +53874,12 @@ adhdev-mcp \u2014 ADHDev MCP Server
53744
53874
  Usage:
53745
53875
  adhdev-mcp Local mode (requires standalone daemon)
53746
53876
  adhdev-mcp --api-key <key> Cloud mode (ADHDev cloud API)
53877
+ adhdev-mcp --mode ipc --repo-mesh <mesh_id> Cloud daemon IPC mesh mode
53747
53878
  adhdev-mcp --repo-mesh <mesh_id> Mesh mode (coordinator-scoped tools)
53748
53879
 
53749
53880
  Options:
53750
- --port <n> Standalone daemon port (default: 3847)
53881
+ --mode <mode> Transport: local, cloud, or ipc
53882
+ --port <n> Standalone or IPC daemon port (defaults: local 3847, ipc 19222)
53751
53883
  --password <pass> Standalone daemon password (if set)
53752
53884
  --api-key <key> ADHDev cloud API key (switches to cloud mode)
53753
53885
  --base-url <url> Override cloud API base URL
@@ -53758,6 +53890,7 @@ Environment variables:
53758
53890
  ADHDEV_API_KEY API key (cloud mode)
53759
53891
  ADHDEV_PASSWORD Daemon password (local mode)
53760
53892
  ADHDEV_MESH_ID Mesh ID (mesh mode)
53893
+ ADHDEV_MCP_TRANSPORT Transport: local, cloud, or ipc
53761
53894
 
53762
53895
  Standard tools: list_daemons, list_sessions, launch_session, stop_session, check_pending, read_chat, send_chat, approve, git_status, git_log, git_diff, git_checkpoint, git_push, screenshot
53763
53896
  Mesh tools: mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, mesh_git_status, mesh_checkpoint, mesh_approve
@@ -53768,6 +53901,10 @@ startMcpServer(parseArgs(process.argv)).catch((err) => {
53768
53901
  `);
53769
53902
  process.exit(1);
53770
53903
  });
53904
+ // Annotate the CommonJS export names for ESM import in node:
53905
+ 0 && (module.exports = {
53906
+ parseArgs
53907
+ });
53771
53908
  /*! Bundled license information:
53772
53909
 
53773
53910
  chokidar/index.js: