@adhdev/daemon-standalone 0.9.70 → 0.9.71

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.
@@ -27576,7 +27576,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
27576
27576
  },
27577
27577
  errorMessage: state.errorMessage,
27578
27578
  errorReason: state.errorReason,
27579
- lastUpdated: state.lastUpdated
27579
+ lastUpdated: state.lastUpdated,
27580
+ settings: state.settings
27580
27581
  };
27581
27582
  }
27582
27583
  function buildExtensionAgentSession(parent, ext, options) {
@@ -27611,7 +27612,8 @@ function buildExtensionAgentSession(parent, ext, options) {
27611
27612
  },
27612
27613
  errorMessage: ext.errorMessage,
27613
27614
  errorReason: ext.errorReason,
27614
- lastUpdated: ext.lastUpdated
27615
+ lastUpdated: ext.lastUpdated,
27616
+ settings: ext.settings
27615
27617
  };
27616
27618
  }
27617
27619
  function shouldIncludeExtensionSession(ext) {
@@ -27677,7 +27679,8 @@ function buildCliSession(state, options) {
27677
27679
  },
27678
27680
  errorMessage: state.errorMessage,
27679
27681
  errorReason: state.errorReason,
27680
- lastUpdated: state.lastUpdated
27682
+ lastUpdated: state.lastUpdated,
27683
+ settings: state.settings
27681
27684
  };
27682
27685
  }
27683
27686
  function buildAcpSession(state, options) {
@@ -27711,7 +27714,8 @@ function buildAcpSession(state, options) {
27711
27714
  },
27712
27715
  errorMessage: state.errorMessage,
27713
27716
  errorReason: state.errorReason,
27714
- lastUpdated: state.lastUpdated
27717
+ lastUpdated: state.lastUpdated,
27718
+ settings: state.settings
27715
27719
  };
27716
27720
  }
27717
27721
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -28048,6 +28052,8 @@ function getSendChatInputEnvelope(args) {
28048
28052
  function getHistorySessionId(h, args) {
28049
28053
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
28050
28054
  if (explicit) return explicit;
28055
+ const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
28056
+ if (explicitProviderSessionId) return explicitProviderSessionId;
28051
28057
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
28052
28058
  if (!targetSessionId) return void 0;
28053
28059
  const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
@@ -28604,7 +28610,32 @@ async function handleReadChat(h, args) {
28604
28610
  ...coverage ? { coverage } : {}
28605
28611
  }, args);
28606
28612
  }
28607
- return { success: false, error: `${transport} adapter not found` };
28613
+ const historyLimit = normalizeReadChatTailLimit(args);
28614
+ try {
28615
+ const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
28616
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
28617
+ const history = readProviderChatHistory(agentStr, {
28618
+ canonicalHistory: provider?.canonicalHistory,
28619
+ historySessionId,
28620
+ workspace,
28621
+ offset: 0,
28622
+ limit: historyLimit,
28623
+ excludeRecentCount: 0,
28624
+ historyBehavior: provider?.historyBehavior,
28625
+ scripts: provider?.scripts
28626
+ });
28627
+ const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
28628
+ return buildReadChatCommandResult({
28629
+ messages: Array.isArray(history?.messages) ? history.messages : [],
28630
+ status: "idle",
28631
+ ...typeof history?.title === "string" ? { title: history.title } : {},
28632
+ ...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
28633
+ ...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
28634
+ coverage: "tail"
28635
+ }, args);
28636
+ } catch (error48) {
28637
+ return { success: false, error: error48?.message || `${transport} adapter not found` };
28638
+ }
28608
28639
  }
28609
28640
  if (isExtensionTransport(transport)) {
28610
28641
  let extensionReadChatError = "";
@@ -36390,6 +36421,42 @@ function launchIDE(ide, workspacePath) {
36390
36421
  return false;
36391
36422
  }
36392
36423
  }
36424
+ function setupMeshEventForwarding(components) {
36425
+ components.instanceManager.onEvent((event) => {
36426
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
36427
+ const instanceId = event.instanceId;
36428
+ if (!instanceId) return;
36429
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
36430
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
36431
+ const state = sourceInstance.getState();
36432
+ const workspace = state.workspace;
36433
+ if (!workspace) return;
36434
+ const mesh = getMeshByRepo(workspace);
36435
+ if (!mesh) return;
36436
+ const allInstances = components.instanceManager.getByCategory("cli");
36437
+ const coordinatorInstances = allInstances.filter((inst) => {
36438
+ const instState = inst.getState();
36439
+ if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
36440
+ if (instState.instanceId === instanceId) return false;
36441
+ return true;
36442
+ });
36443
+ if (coordinatorInstances.length === 0) return;
36444
+ const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
36445
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
36446
+ let messageText = "";
36447
+ if (event.event === "agent:generating_completed") {
36448
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
36449
+ } else if (event.event === "agent:waiting_approval") {
36450
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
36451
+ }
36452
+ if (!messageText) return;
36453
+ for (const coord of coordinatorInstances) {
36454
+ const coordState = coord.getState();
36455
+ LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
36456
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
36457
+ }
36458
+ });
36459
+ }
36393
36460
  async function initDaemonComponents(config2) {
36394
36461
  installGlobalInterceptor();
36395
36462
  const appConfig = loadConfig();
@@ -36547,7 +36614,7 @@ async function initDaemonComponents(config2) {
36547
36614
  });
36548
36615
  poller.start();
36549
36616
  instanceManager.startTicking(config2.tickIntervalMs ?? 5e3);
36550
- return {
36617
+ const components = {
36551
36618
  providerLoader,
36552
36619
  instanceManager,
36553
36620
  cliManager,
@@ -36561,6 +36628,8 @@ async function initDaemonComponents(config2) {
36561
36628
  detectedIdes: detectedIdesRef,
36562
36629
  refreshProviderAvailability
36563
36630
  };
36631
+ setupMeshEventForwarding(components);
36632
+ return components;
36564
36633
  }
36565
36634
  async function startDaemonDevSupport(options) {
36566
36635
  const devServer = new DevServer({
@@ -39122,11 +39191,22 @@ var init_dist2 = __esm({
39122
39191
  }
39123
39192
  }
39124
39193
  }
39194
+ getParsedDebugState() {
39195
+ if (this.startupParseGate || typeof this.cliScripts?.parseSession !== "function") return null;
39196
+ try {
39197
+ const parsed = this.getScriptParsedStatus();
39198
+ return parsed && typeof parsed === "object" ? parsed : null;
39199
+ } catch {
39200
+ return null;
39201
+ }
39202
+ }
39125
39203
  getDebugState() {
39126
39204
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
39127
39205
  const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
39128
39206
  const effectiveStatus = this.projectEffectiveStatus(startupModal);
39129
39207
  const effectiveReady = this.ready || !!startupModal;
39208
+ const parsedDebugState = this.getParsedDebugState();
39209
+ const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
39130
39210
  return {
39131
39211
  type: this.cliType,
39132
39212
  name: this.cliName,
@@ -39139,8 +39219,18 @@ var init_dist2 = __esm({
39139
39219
  startupParseGate: this.startupParseGate,
39140
39220
  spawnAt: this.spawnAt,
39141
39221
  workingDir: this.workingDir,
39142
- messages: [],
39143
- messageCount: 0,
39222
+ messages: parsedMessages,
39223
+ messageCount: parsedMessages.length,
39224
+ parsedStatus: parsedDebugState ? {
39225
+ id: parsedDebugState.id,
39226
+ status: parsedDebugState.status,
39227
+ title: parsedDebugState.title,
39228
+ providerSessionId: parsedDebugState.providerSessionId,
39229
+ transcriptAuthority: parsedDebugState.transcriptAuthority,
39230
+ coverage: parsedDebugState.coverage,
39231
+ activeModal: parsedDebugState.activeModal,
39232
+ messageCount: parsedMessages.length
39233
+ } : null,
39144
39234
  screenText: screenText.slice(-4e3),
39145
39235
  currentTurnScope: this.currentTurnScope,
39146
39236
  startupBuffer: this.startupBuffer.slice(-4e3),
@@ -43323,7 +43413,7 @@ ${effect.notification.body || ""}`.trim();
43323
43413
  this.errorMessage = void 0;
43324
43414
  this.errorReason = void 0;
43325
43415
  }
43326
- const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
43416
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
43327
43417
  const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
43328
43418
  const parsedProviderSessionId = normalizeProviderSessionId(
43329
43419
  this.provider,
@@ -43516,12 +43606,8 @@ ${effect.notification.body || ""}`.trim();
43516
43606
  }
43517
43607
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
43518
43608
  }
43519
- detectStatusTransition() {
43520
- const now = Date.now();
43521
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
43522
- const parsedStatus = null;
43523
- const rawStatus = adapterStatus.status;
43524
- const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
43609
+ maybeAutoApproveStatus(adapterStatus, now = Date.now()) {
43610
+ const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
43525
43611
  if (autoApproveActive && !this.autoApproveBusy) {
43526
43612
  this.autoApproveBusy = true;
43527
43613
  if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
@@ -43529,12 +43615,21 @@ ${effect.notification.body || ""}`.trim();
43529
43615
  this.autoApproveBusy = false;
43530
43616
  this.autoApproveBusyTimer = null;
43531
43617
  }, 2e3);
43532
- const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
43533
- this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
43618
+ const modal = adapterStatus.activeModal;
43619
+ const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(modal?.buttons, this.provider);
43620
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
43534
43621
  setTimeout(() => {
43535
43622
  this.adapter.resolveModal(buttonIndex);
43536
43623
  }, 0);
43537
43624
  }
43625
+ return autoApproveActive;
43626
+ }
43627
+ detectStatusTransition() {
43628
+ const now = Date.now();
43629
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
43630
+ const parsedStatus = null;
43631
+ const rawStatus = adapterStatus.status;
43632
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
43538
43633
  const newStatus = autoApproveActive ? "generating" : rawStatus;
43539
43634
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
43540
43635
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
@@ -45359,7 +45454,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
45359
45454
  resolvedDir,
45360
45455
  resolvedCliArgs,
45361
45456
  resolvedProvider,
45362
- this.providerLoader.getSettings(normalizedType),
45457
+ { ...this.providerLoader.getSettings(normalizedType), ...options?.settingsOverride || {} },
45363
45458
  false,
45364
45459
  {
45365
45460
  providerSessionId: sessionBinding.providerSessionId,
@@ -45613,7 +45708,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
45613
45708
  dir,
45614
45709
  args?.cliArgs,
45615
45710
  args?.initialModel,
45616
- { resumeSessionId: args?.resumeSessionId }
45711
+ { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
45617
45712
  );
45618
45713
  return {
45619
45714
  success: true,
@@ -48067,11 +48162,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
48067
48162
  const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
48068
48163
  if (!meshId) return { success: false, error: "meshId required" };
48069
48164
  try {
48070
- const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
48071
48165
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
48072
- const mesh = getMesh3(meshId);
48166
+ let mesh;
48167
+ if (args?.inlineMesh && typeof args.inlineMesh === "object") {
48168
+ mesh = args.inlineMesh;
48169
+ } else {
48170
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
48171
+ mesh = getMesh3(meshId);
48172
+ }
48073
48173
  if (!mesh) return { success: false, error: "Mesh not found" };
48074
- if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
48174
+ if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
48075
48175
  const workspace = mesh.nodes[0].workspace;
48076
48176
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
48077
48177
  const coordinatorSetup = resolveMeshCoordinatorSetup({
@@ -48139,10 +48239,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
48139
48239
  } catch {
48140
48240
  systemPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}". Use the adhdev-mesh MCP tools (mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, etc.) to orchestrate work across ${mesh.nodes.length} node(s).`;
48141
48241
  }
48242
+ const cliArgs = [];
48243
+ if (systemPrompt) {
48244
+ cliArgs.push("--append-system-prompt", systemPrompt);
48245
+ }
48246
+ if (cliType === "claude-cli") {
48247
+ cliArgs.push("--mcp-config", coordinatorSetup.configPath);
48248
+ }
48142
48249
  const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
48143
48250
  cliType,
48144
48251
  dir: workspace,
48145
- initialPrompt: systemPrompt
48252
+ cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
48253
+ settings: {
48254
+ meshCoordinatorFor: meshId
48255
+ }
48146
48256
  });
48147
48257
  if (!launchResult?.success) {
48148
48258
  return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
@@ -48443,7 +48553,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
48443
48553
  workspace: session.workspace ?? null,
48444
48554
  title: session.title,
48445
48555
  cdpConnected: session.cdpConnected,
48446
- summaryMetadata: session.summaryMetadata
48556
+ summaryMetadata: session.summaryMetadata,
48557
+ settings: session.settings
48447
48558
  })),
48448
48559
  p2p: payload.p2p,
48449
48560
  timestamp: now
@@ -51668,6 +51779,8 @@ data: ${JSON.stringify(msg.data)}
51668
51779
  };
51669
51780
  init_logger();
51670
51781
  init_config();
51782
+ init_mesh_config();
51783
+ init_logger();
51671
51784
  }
51672
51785
  });
51673
51786
 
@@ -53100,7 +53213,11 @@ async function meshLaunchSession(ctx, args) {
53100
53213
  if (isLocalTransport(ctx.transport)) {
53101
53214
  const result = await ctx.transport.command("launch_cli", {
53102
53215
  cliType: args.type,
53103
- dir: node.workspace
53216
+ dir: node.workspace,
53217
+ settings: {
53218
+ meshNodeFor: ctx.mesh.id,
53219
+ launchedByCoordinator: true
53220
+ }
53104
53221
  });
53105
53222
  return JSON.stringify(result, null, 2);
53106
53223
  } else {
@@ -53246,7 +53363,7 @@ async function startMcpServer(opts) {
53246
53363
  coordinatorPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}" (${mesh.repoIdentity}). Use mesh_* tools to orchestrate work.`;
53247
53364
  }
53248
53365
  const server2 = new import_server.Server(
53249
- { name: "adhdev-mcp-server", version: "0.9.70" },
53366
+ { name: "adhdev-mcp-server", version: "0.9.71" },
53250
53367
  { capabilities: { tools: {}, resources: {} } }
53251
53368
  );
53252
53369
  const { ListResourcesRequestSchema, ReadResourceRequestSchema } = await import("@modelcontextprotocol/sdk/types.js");