@adhdev/daemon-standalone 0.9.69 → 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.
package/dist/index.js CHANGED
@@ -31398,11 +31398,22 @@ ${rules.join("\n")}`;
31398
31398
  }
31399
31399
  }
31400
31400
  }
31401
+ getParsedDebugState() {
31402
+ if (this.startupParseGate || typeof this.cliScripts?.parseSession !== "function") return null;
31403
+ try {
31404
+ const parsed = this.getScriptParsedStatus();
31405
+ return parsed && typeof parsed === "object" ? parsed : null;
31406
+ } catch {
31407
+ return null;
31408
+ }
31409
+ }
31401
31410
  getDebugState() {
31402
31411
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
31403
31412
  const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
31404
31413
  const effectiveStatus = this.projectEffectiveStatus(startupModal);
31405
31414
  const effectiveReady = this.ready || !!startupModal;
31415
+ const parsedDebugState = this.getParsedDebugState();
31416
+ const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
31406
31417
  return {
31407
31418
  type: this.cliType,
31408
31419
  name: this.cliName,
@@ -31415,8 +31426,18 @@ ${rules.join("\n")}`;
31415
31426
  startupParseGate: this.startupParseGate,
31416
31427
  spawnAt: this.spawnAt,
31417
31428
  workingDir: this.workingDir,
31418
- messages: [],
31419
- messageCount: 0,
31429
+ messages: parsedMessages,
31430
+ messageCount: parsedMessages.length,
31431
+ parsedStatus: parsedDebugState ? {
31432
+ id: parsedDebugState.id,
31433
+ status: parsedDebugState.status,
31434
+ title: parsedDebugState.title,
31435
+ providerSessionId: parsedDebugState.providerSessionId,
31436
+ transcriptAuthority: parsedDebugState.transcriptAuthority,
31437
+ coverage: parsedDebugState.coverage,
31438
+ activeModal: parsedDebugState.activeModal,
31439
+ messageCount: parsedMessages.length
31440
+ } : null,
31420
31441
  screenText: screenText.slice(-4e3),
31421
31442
  currentTurnScope: this.currentTurnScope,
31422
31443
  startupBuffer: this.startupBuffer.slice(-4e3),
@@ -39024,7 +39045,8 @@ ${effect.notification.body || ""}`.trim();
39024
39045
  },
39025
39046
  errorMessage: state.errorMessage,
39026
39047
  errorReason: state.errorReason,
39027
- lastUpdated: state.lastUpdated
39048
+ lastUpdated: state.lastUpdated,
39049
+ settings: state.settings
39028
39050
  };
39029
39051
  }
39030
39052
  function buildExtensionAgentSession(parent, ext, options) {
@@ -39059,7 +39081,8 @@ ${effect.notification.body || ""}`.trim();
39059
39081
  },
39060
39082
  errorMessage: ext.errorMessage,
39061
39083
  errorReason: ext.errorReason,
39062
- lastUpdated: ext.lastUpdated
39084
+ lastUpdated: ext.lastUpdated,
39085
+ settings: ext.settings
39063
39086
  };
39064
39087
  }
39065
39088
  function shouldIncludeExtensionSession(ext) {
@@ -39125,7 +39148,8 @@ ${effect.notification.body || ""}`.trim();
39125
39148
  },
39126
39149
  errorMessage: state.errorMessage,
39127
39150
  errorReason: state.errorReason,
39128
- lastUpdated: state.lastUpdated
39151
+ lastUpdated: state.lastUpdated,
39152
+ settings: state.settings
39129
39153
  };
39130
39154
  }
39131
39155
  function buildAcpSession(state, options) {
@@ -39159,7 +39183,8 @@ ${effect.notification.body || ""}`.trim();
39159
39183
  },
39160
39184
  errorMessage: state.errorMessage,
39161
39185
  errorReason: state.errorReason,
39162
- lastUpdated: state.lastUpdated
39186
+ lastUpdated: state.lastUpdated,
39187
+ settings: state.settings
39163
39188
  };
39164
39189
  }
39165
39190
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -39508,6 +39533,8 @@ ${effect.notification.body || ""}`.trim();
39508
39533
  function getHistorySessionId(h, args) {
39509
39534
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
39510
39535
  if (explicit) return explicit;
39536
+ const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
39537
+ if (explicitProviderSessionId) return explicitProviderSessionId;
39511
39538
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
39512
39539
  if (!targetSessionId) return void 0;
39513
39540
  const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
@@ -40071,7 +40098,32 @@ ${effect.notification.body || ""}`.trim();
40071
40098
  ...coverage ? { coverage } : {}
40072
40099
  }, args);
40073
40100
  }
40074
- return { success: false, error: `${transport} adapter not found` };
40101
+ const historyLimit = normalizeReadChatTailLimit(args);
40102
+ try {
40103
+ const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
40104
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
40105
+ const history = readProviderChatHistory(agentStr, {
40106
+ canonicalHistory: provider?.canonicalHistory,
40107
+ historySessionId,
40108
+ workspace,
40109
+ offset: 0,
40110
+ limit: historyLimit,
40111
+ excludeRecentCount: 0,
40112
+ historyBehavior: provider?.historyBehavior,
40113
+ scripts: provider?.scripts
40114
+ });
40115
+ const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
40116
+ return buildReadChatCommandResult({
40117
+ messages: Array.isArray(history?.messages) ? history.messages : [],
40118
+ status: "idle",
40119
+ ...typeof history?.title === "string" ? { title: history.title } : {},
40120
+ ...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
40121
+ ...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
40122
+ coverage: "tail"
40123
+ }, args);
40124
+ } catch (error48) {
40125
+ return { success: false, error: error48?.message || `${transport} adapter not found` };
40126
+ }
40075
40127
  }
40076
40128
  if (isExtensionTransport(transport)) {
40077
40129
  let extensionReadChatError = "";
@@ -42600,7 +42652,7 @@ ${effect.notification.body || ""}`.trim();
42600
42652
  this.errorMessage = void 0;
42601
42653
  this.errorReason = void 0;
42602
42654
  }
42603
- const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
42655
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
42604
42656
  const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
42605
42657
  const parsedProviderSessionId = normalizeProviderSessionId(
42606
42658
  this.provider,
@@ -42793,12 +42845,8 @@ ${effect.notification.body || ""}`.trim();
42793
42845
  }
42794
42846
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
42795
42847
  }
42796
- detectStatusTransition() {
42797
- const now = Date.now();
42798
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
42799
- const parsedStatus = null;
42800
- const rawStatus = adapterStatus.status;
42801
- const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
42848
+ maybeAutoApproveStatus(adapterStatus, now = Date.now()) {
42849
+ const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
42802
42850
  if (autoApproveActive && !this.autoApproveBusy) {
42803
42851
  this.autoApproveBusy = true;
42804
42852
  if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
@@ -42806,12 +42854,21 @@ ${effect.notification.body || ""}`.trim();
42806
42854
  this.autoApproveBusy = false;
42807
42855
  this.autoApproveBusyTimer = null;
42808
42856
  }, 2e3);
42809
- const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
42810
- this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
42857
+ const modal = adapterStatus.activeModal;
42858
+ const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(modal?.buttons, this.provider);
42859
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
42811
42860
  setTimeout(() => {
42812
42861
  this.adapter.resolveModal(buttonIndex);
42813
42862
  }, 0);
42814
42863
  }
42864
+ return autoApproveActive;
42865
+ }
42866
+ detectStatusTransition() {
42867
+ const now = Date.now();
42868
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
42869
+ const parsedStatus = null;
42870
+ const rawStatus = adapterStatus.status;
42871
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
42815
42872
  const newStatus = autoApproveActive ? "generating" : rawStatus;
42816
42873
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
42817
42874
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
@@ -44869,7 +44926,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44869
44926
  resolvedDir,
44870
44927
  resolvedCliArgs,
44871
44928
  resolvedProvider,
44872
- this.providerLoader.getSettings(normalizedType),
44929
+ { ...this.providerLoader.getSettings(normalizedType), ...options?.settingsOverride || {} },
44873
44930
  false,
44874
44931
  {
44875
44932
  providerSessionId: sessionBinding.providerSessionId,
@@ -45123,7 +45180,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
45123
45180
  dir,
45124
45181
  args?.cliArgs,
45125
45182
  args?.initialModel,
45126
- { resumeSessionId: args?.resumeSessionId }
45183
+ { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
45127
45184
  );
45128
45185
  return {
45129
45186
  success: true,
@@ -49156,11 +49213,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
49156
49213
  const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
49157
49214
  if (!meshId) return { success: false, error: "meshId required" };
49158
49215
  try {
49159
- const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
49160
49216
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
49161
- const mesh = getMesh3(meshId);
49217
+ let mesh;
49218
+ if (args?.inlineMesh && typeof args.inlineMesh === "object") {
49219
+ mesh = args.inlineMesh;
49220
+ } else {
49221
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
49222
+ mesh = getMesh3(meshId);
49223
+ }
49162
49224
  if (!mesh) return { success: false, error: "Mesh not found" };
49163
- if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
49225
+ if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
49164
49226
  const workspace = mesh.nodes[0].workspace;
49165
49227
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
49166
49228
  const coordinatorSetup = resolveMeshCoordinatorSetup({
@@ -49228,10 +49290,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
49228
49290
  } catch {
49229
49291
  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).`;
49230
49292
  }
49293
+ const cliArgs = [];
49294
+ if (systemPrompt) {
49295
+ cliArgs.push("--append-system-prompt", systemPrompt);
49296
+ }
49297
+ if (cliType === "claude-cli") {
49298
+ cliArgs.push("--mcp-config", coordinatorSetup.configPath);
49299
+ }
49231
49300
  const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
49232
49301
  cliType,
49233
49302
  dir: workspace,
49234
- initialPrompt: systemPrompt
49303
+ cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
49304
+ settings: {
49305
+ meshCoordinatorFor: meshId
49306
+ }
49235
49307
  });
49236
49308
  if (!launchResult?.success) {
49237
49309
  return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
@@ -49532,7 +49604,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
49532
49604
  workspace: session.workspace ?? null,
49533
49605
  title: session.title,
49534
49606
  cdpConnected: session.cdpConnected,
49535
- summaryMetadata: session.summaryMetadata
49607
+ summaryMetadata: session.summaryMetadata,
49608
+ settings: session.settings
49536
49609
  })),
49537
49610
  p2p: payload.p2p,
49538
49611
  timestamp: now
@@ -56919,6 +56992,44 @@ data: ${JSON.stringify(msg.data)}
56919
56992
  };
56920
56993
  init_logger();
56921
56994
  init_config();
56995
+ init_mesh_config();
56996
+ init_logger();
56997
+ function setupMeshEventForwarding(components) {
56998
+ components.instanceManager.onEvent((event) => {
56999
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
57000
+ const instanceId = event.instanceId;
57001
+ if (!instanceId) return;
57002
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
57003
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
57004
+ const state = sourceInstance.getState();
57005
+ const workspace = state.workspace;
57006
+ if (!workspace) return;
57007
+ const mesh = getMeshByRepo(workspace);
57008
+ if (!mesh) return;
57009
+ const allInstances = components.instanceManager.getByCategory("cli");
57010
+ const coordinatorInstances = allInstances.filter((inst) => {
57011
+ const instState = inst.getState();
57012
+ if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
57013
+ if (instState.instanceId === instanceId) return false;
57014
+ return true;
57015
+ });
57016
+ if (coordinatorInstances.length === 0) return;
57017
+ const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
57018
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
57019
+ let messageText = "";
57020
+ if (event.event === "agent:generating_completed") {
57021
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
57022
+ } else if (event.event === "agent:waiting_approval") {
57023
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
57024
+ }
57025
+ if (!messageText) return;
57026
+ for (const coord of coordinatorInstances) {
57027
+ const coordState = coord.getState();
57028
+ LOG2.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
57029
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
57030
+ }
57031
+ });
57032
+ }
56922
57033
  async function initDaemonComponents2(config2) {
56923
57034
  installGlobalInterceptor();
56924
57035
  const appConfig = loadConfig2();
@@ -57076,7 +57187,7 @@ data: ${JSON.stringify(msg.data)}
57076
57187
  });
57077
57188
  poller.start();
57078
57189
  instanceManager.startTicking(config2.tickIntervalMs ?? 5e3);
57079
- return {
57190
+ const components = {
57080
57191
  providerLoader,
57081
57192
  instanceManager,
57082
57193
  cliManager,
@@ -57090,6 +57201,8 @@ data: ${JSON.stringify(msg.data)}
57090
57201
  detectedIdes: detectedIdesRef,
57091
57202
  refreshProviderAvailability
57092
57203
  };
57204
+ setupMeshEventForwarding(components);
57205
+ return components;
57093
57206
  }
57094
57207
  async function startDaemonDevSupport2(options) {
57095
57208
  const devServer = new DevServer({