adhdev 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/cli/index.js CHANGED
@@ -8984,7 +8984,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
8984
8984
  },
8985
8985
  errorMessage: state.errorMessage,
8986
8986
  errorReason: state.errorReason,
8987
- lastUpdated: state.lastUpdated
8987
+ lastUpdated: state.lastUpdated,
8988
+ settings: state.settings
8988
8989
  };
8989
8990
  }
8990
8991
  function buildExtensionAgentSession(parent, ext, options) {
@@ -9019,7 +9020,8 @@ function buildExtensionAgentSession(parent, ext, options) {
9019
9020
  },
9020
9021
  errorMessage: ext.errorMessage,
9021
9022
  errorReason: ext.errorReason,
9022
- lastUpdated: ext.lastUpdated
9023
+ lastUpdated: ext.lastUpdated,
9024
+ settings: ext.settings
9023
9025
  };
9024
9026
  }
9025
9027
  function shouldIncludeExtensionSession(ext) {
@@ -9085,7 +9087,8 @@ function buildCliSession(state, options) {
9085
9087
  },
9086
9088
  errorMessage: state.errorMessage,
9087
9089
  errorReason: state.errorReason,
9088
- lastUpdated: state.lastUpdated
9090
+ lastUpdated: state.lastUpdated,
9091
+ settings: state.settings
9089
9092
  };
9090
9093
  }
9091
9094
  function buildAcpSession(state, options) {
@@ -9119,7 +9122,8 @@ function buildAcpSession(state, options) {
9119
9122
  },
9120
9123
  errorMessage: state.errorMessage,
9121
9124
  errorReason: state.errorReason,
9122
- lastUpdated: state.lastUpdated
9125
+ lastUpdated: state.lastUpdated,
9126
+ settings: state.settings
9123
9127
  };
9124
9128
  }
9125
9129
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -9583,6 +9587,8 @@ function getSendChatInputEnvelope(args) {
9583
9587
  function getHistorySessionId(h, args) {
9584
9588
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
9585
9589
  if (explicit) return explicit;
9590
+ const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
9591
+ if (explicitProviderSessionId) return explicitProviderSessionId;
9586
9592
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
9587
9593
  if (!targetSessionId) return void 0;
9588
9594
  const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
@@ -10139,7 +10145,32 @@ async function handleReadChat(h, args) {
10139
10145
  ...coverage ? { coverage } : {}
10140
10146
  }, args);
10141
10147
  }
10142
- return { success: false, error: `${transport} adapter not found` };
10148
+ const historyLimit = normalizeReadChatTailLimit(args);
10149
+ try {
10150
+ const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
10151
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
10152
+ const history = readProviderChatHistory(agentStr, {
10153
+ canonicalHistory: provider?.canonicalHistory,
10154
+ historySessionId,
10155
+ workspace,
10156
+ offset: 0,
10157
+ limit: historyLimit,
10158
+ excludeRecentCount: 0,
10159
+ historyBehavior: provider?.historyBehavior,
10160
+ scripts: provider?.scripts
10161
+ });
10162
+ const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
10163
+ return buildReadChatCommandResult({
10164
+ messages: Array.isArray(history?.messages) ? history.messages : [],
10165
+ status: "idle",
10166
+ ...typeof history?.title === "string" ? { title: history.title } : {},
10167
+ ...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
10168
+ ...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
10169
+ coverage: "tail"
10170
+ }, args);
10171
+ } catch (error48) {
10172
+ return { success: false, error: error48?.message || `${transport} adapter not found` };
10173
+ }
10143
10174
  }
10144
10175
  if (isExtensionTransport(transport)) {
10145
10176
  let extensionReadChatError = "";
@@ -16367,11 +16398,22 @@ var init_provider_cli_adapter = __esm({
16367
16398
  }
16368
16399
  }
16369
16400
  }
16401
+ getParsedDebugState() {
16402
+ if (this.startupParseGate || typeof this.cliScripts?.parseSession !== "function") return null;
16403
+ try {
16404
+ const parsed = this.getScriptParsedStatus();
16405
+ return parsed && typeof parsed === "object" ? parsed : null;
16406
+ } catch {
16407
+ return null;
16408
+ }
16409
+ }
16370
16410
  getDebugState() {
16371
16411
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
16372
16412
  const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
16373
16413
  const effectiveStatus = this.projectEffectiveStatus(startupModal);
16374
16414
  const effectiveReady = this.ready || !!startupModal;
16415
+ const parsedDebugState = this.getParsedDebugState();
16416
+ const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
16375
16417
  return {
16376
16418
  type: this.cliType,
16377
16419
  name: this.cliName,
@@ -16384,8 +16426,18 @@ var init_provider_cli_adapter = __esm({
16384
16426
  startupParseGate: this.startupParseGate,
16385
16427
  spawnAt: this.spawnAt,
16386
16428
  workingDir: this.workingDir,
16387
- messages: [],
16388
- messageCount: 0,
16429
+ messages: parsedMessages,
16430
+ messageCount: parsedMessages.length,
16431
+ parsedStatus: parsedDebugState ? {
16432
+ id: parsedDebugState.id,
16433
+ status: parsedDebugState.status,
16434
+ title: parsedDebugState.title,
16435
+ providerSessionId: parsedDebugState.providerSessionId,
16436
+ transcriptAuthority: parsedDebugState.transcriptAuthority,
16437
+ coverage: parsedDebugState.coverage,
16438
+ activeModal: parsedDebugState.activeModal,
16439
+ messageCount: parsedMessages.length
16440
+ } : null,
16389
16441
  screenText: screenText.slice(-4e3),
16390
16442
  currentTurnScope: this.currentTurnScope,
16391
16443
  startupBuffer: this.startupBuffer.slice(-4e3),
@@ -16719,7 +16771,7 @@ var init_cli_provider_instance = __esm({
16719
16771
  this.errorMessage = void 0;
16720
16772
  this.errorReason = void 0;
16721
16773
  }
16722
- const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
16774
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
16723
16775
  const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
16724
16776
  const parsedProviderSessionId = normalizeProviderSessionId(
16725
16777
  this.provider,
@@ -16912,12 +16964,8 @@ var init_cli_provider_instance = __esm({
16912
16964
  }
16913
16965
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
16914
16966
  }
16915
- detectStatusTransition() {
16916
- const now = Date.now();
16917
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
16918
- const parsedStatus = null;
16919
- const rawStatus = adapterStatus.status;
16920
- const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
16967
+ maybeAutoApproveStatus(adapterStatus, now = Date.now()) {
16968
+ const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
16921
16969
  if (autoApproveActive && !this.autoApproveBusy) {
16922
16970
  this.autoApproveBusy = true;
16923
16971
  if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
@@ -16925,12 +16973,21 @@ var init_cli_provider_instance = __esm({
16925
16973
  this.autoApproveBusy = false;
16926
16974
  this.autoApproveBusyTimer = null;
16927
16975
  }, 2e3);
16928
- const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
16929
- this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
16976
+ const modal = adapterStatus.activeModal;
16977
+ const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(modal?.buttons, this.provider);
16978
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
16930
16979
  setTimeout(() => {
16931
16980
  this.adapter.resolveModal(buttonIndex);
16932
16981
  }, 0);
16933
16982
  }
16983
+ return autoApproveActive;
16984
+ }
16985
+ detectStatusTransition() {
16986
+ const now = Date.now();
16987
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
16988
+ const parsedStatus = null;
16989
+ const rawStatus = adapterStatus.status;
16990
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
16934
16991
  const newStatus = autoApproveActive ? "generating" : rawStatus;
16935
16992
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
16936
16993
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
@@ -35336,7 +35393,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
35336
35393
  resolvedDir,
35337
35394
  resolvedCliArgs,
35338
35395
  resolvedProvider,
35339
- this.providerLoader.getSettings(normalizedType),
35396
+ { ...this.providerLoader.getSettings(normalizedType), ...options?.settingsOverride || {} },
35340
35397
  false,
35341
35398
  {
35342
35399
  providerSessionId: sessionBinding.providerSessionId,
@@ -35590,7 +35647,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
35590
35647
  dir,
35591
35648
  args?.cliArgs,
35592
35649
  args?.initialModel,
35593
- { resumeSessionId: args?.resumeSessionId }
35650
+ { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
35594
35651
  );
35595
35652
  return {
35596
35653
  success: true,
@@ -41475,11 +41532,16 @@ var init_router = __esm({
41475
41532
  const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
41476
41533
  if (!meshId) return { success: false, error: "meshId required" };
41477
41534
  try {
41478
- const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41479
41535
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
41480
- const mesh = getMesh3(meshId);
41536
+ let mesh;
41537
+ if (args?.inlineMesh && typeof args.inlineMesh === "object") {
41538
+ mesh = args.inlineMesh;
41539
+ } else {
41540
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41541
+ mesh = getMesh3(meshId);
41542
+ }
41481
41543
  if (!mesh) return { success: false, error: "Mesh not found" };
41482
- if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
41544
+ if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
41483
41545
  const workspace = mesh.nodes[0].workspace;
41484
41546
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
41485
41547
  const coordinatorSetup = resolveMeshCoordinatorSetup({
@@ -41547,10 +41609,20 @@ var init_router = __esm({
41547
41609
  } catch {
41548
41610
  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).`;
41549
41611
  }
41612
+ const cliArgs = [];
41613
+ if (systemPrompt) {
41614
+ cliArgs.push("--append-system-prompt", systemPrompt);
41615
+ }
41616
+ if (cliType === "claude-cli") {
41617
+ cliArgs.push("--mcp-config", coordinatorSetup.configPath);
41618
+ }
41550
41619
  const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
41551
41620
  cliType,
41552
41621
  dir: workspace,
41553
- initialPrompt: systemPrompt
41622
+ cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
41623
+ settings: {
41624
+ meshCoordinatorFor: meshId
41625
+ }
41554
41626
  });
41555
41627
  if (!launchResult?.success) {
41556
41628
  return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
@@ -41861,7 +41933,8 @@ var init_reporter = __esm({
41861
41933
  workspace: session.workspace ?? null,
41862
41934
  title: session.title,
41863
41935
  cdpConnected: session.cdpConnected,
41864
- summaryMetadata: session.summaryMetadata
41936
+ summaryMetadata: session.summaryMetadata,
41937
+ settings: session.settings
41865
41938
  })),
41866
41939
  p2p: payload.p2p,
41867
41940
  timestamp: now
@@ -49441,6 +49514,51 @@ var init_registry = __esm({
49441
49514
  }
49442
49515
  });
49443
49516
 
49517
+ // ../../oss/packages/daemon-core/src/mesh/mesh-events.ts
49518
+ function setupMeshEventForwarding(components) {
49519
+ components.instanceManager.onEvent((event) => {
49520
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
49521
+ const instanceId = event.instanceId;
49522
+ if (!instanceId) return;
49523
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
49524
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
49525
+ const state = sourceInstance.getState();
49526
+ const workspace = state.workspace;
49527
+ if (!workspace) return;
49528
+ const mesh = getMeshByRepo(workspace);
49529
+ if (!mesh) return;
49530
+ const allInstances = components.instanceManager.getByCategory("cli");
49531
+ const coordinatorInstances = allInstances.filter((inst) => {
49532
+ const instState = inst.getState();
49533
+ if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
49534
+ if (instState.instanceId === instanceId) return false;
49535
+ return true;
49536
+ });
49537
+ if (coordinatorInstances.length === 0) return;
49538
+ const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
49539
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
49540
+ let messageText = "";
49541
+ if (event.event === "agent:generating_completed") {
49542
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
49543
+ } else if (event.event === "agent:waiting_approval") {
49544
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
49545
+ }
49546
+ if (!messageText) return;
49547
+ for (const coord of coordinatorInstances) {
49548
+ const coordState = coord.getState();
49549
+ LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
49550
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
49551
+ }
49552
+ });
49553
+ }
49554
+ var init_mesh_events = __esm({
49555
+ "../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
49556
+ "use strict";
49557
+ init_mesh_config();
49558
+ init_logger();
49559
+ }
49560
+ });
49561
+
49444
49562
  // ../../oss/packages/daemon-core/src/boot/daemon-lifecycle.ts
49445
49563
  async function initDaemonComponents(config2) {
49446
49564
  installGlobalInterceptor();
@@ -49599,7 +49717,7 @@ async function initDaemonComponents(config2) {
49599
49717
  });
49600
49718
  poller.start();
49601
49719
  instanceManager.startTicking(config2.tickIntervalMs ?? 5e3);
49602
- return {
49720
+ const components = {
49603
49721
  providerLoader,
49604
49722
  instanceManager,
49605
49723
  cliManager,
@@ -49613,6 +49731,8 @@ async function initDaemonComponents(config2) {
49613
49731
  detectedIdes: detectedIdesRef,
49614
49732
  refreshProviderAvailability
49615
49733
  };
49734
+ setupMeshEventForwarding(components);
49735
+ return components;
49616
49736
  }
49617
49737
  async function startDaemonDevSupport(options) {
49618
49738
  const devServer = new DevServer({
@@ -49688,6 +49808,7 @@ var init_daemon_lifecycle = __esm({
49688
49808
  init_runtime_defaults();
49689
49809
  init_config();
49690
49810
  init_git_commands();
49811
+ init_mesh_events();
49691
49812
  }
49692
49813
  });
49693
49814
 
@@ -90057,7 +90178,7 @@ var init_adhdev_daemon = __esm({
90057
90178
  init_version();
90058
90179
  init_src();
90059
90180
  init_runtime_defaults();
90060
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.69" });
90181
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.71" });
90061
90182
  AdhdevDaemon = class _AdhdevDaemon {
90062
90183
  localHttpServer = null;
90063
90184
  localWss = null;