@adhdev/daemon-standalone 0.9.77-rc.30 → 0.9.77-rc.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "0.9.77-rc.30",
3
+ "version": "0.9.77-rc.32",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -26029,6 +26029,7 @@ function enqueueTask(meshId, message, opts) {
26029
26029
  message,
26030
26030
  status: "pending",
26031
26031
  targetNodeId: opts?.targetNodeId,
26032
+ targetSessionId: opts?.targetSessionId,
26032
26033
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
26033
26034
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
26034
26035
  };
@@ -26046,9 +26047,14 @@ function getQueue(meshId, opts) {
26046
26047
  }
26047
26048
  function claimNextTask(meshId, nodeId, sessionId) {
26048
26049
  const queue = readQueue(meshId);
26049
- let targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetNodeId === nodeId);
26050
+ const hasActiveAssignment = queue.some((q) => q.status === "assigned" && (q.assignedSessionId === sessionId || q.assignedNodeId === nodeId));
26051
+ if (hasActiveAssignment) return null;
26052
+ let targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetSessionId === sessionId);
26050
26053
  if (targetIdx === -1) {
26051
- targetIdx = queue.findIndex((q) => q.status === "pending" && !q.targetNodeId);
26054
+ targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetNodeId === nodeId && !q.targetSessionId);
26055
+ }
26056
+ if (targetIdx === -1) {
26057
+ targetIdx = queue.findIndex((q) => q.status === "pending" && !q.targetNodeId && !q.targetSessionId);
26052
26058
  }
26053
26059
  if (targetIdx === -1) return null;
26054
26060
  const entry = queue[targetIdx];
@@ -26245,6 +26251,9 @@ function drainPendingMeshCoordinatorEvents() {
26245
26251
  function readNonEmptyString(value) {
26246
26252
  return typeof value === "string" && value.trim() ? value.trim() : "";
26247
26253
  }
26254
+ function resolveEventSessionId(event, fallback) {
26255
+ return readNonEmptyString(event.targetSessionId) || readNonEmptyString(event.sessionId) || readNonEmptyString(event.instanceId) || readNonEmptyString(fallback);
26256
+ }
26248
26257
  function isMeshCoordinatorEvent(eventName) {
26249
26258
  return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
26250
26259
  }
@@ -26369,7 +26378,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
26369
26378
  }
26370
26379
  function injectMeshSystemMessage(components, args) {
26371
26380
  if (args.event === "agent:generating_completed") {
26372
- const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
26381
+ const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
26373
26382
  const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
26374
26383
  const providerType = readNonEmptyString(args.metadataEvent.providerType);
26375
26384
  if (sessionId) {
@@ -26381,9 +26390,29 @@ function injectMeshSystemMessage(components, args) {
26381
26390
  }
26382
26391
  }
26383
26392
  } else if (args.event === "agent:ready") {
26384
- const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
26393
+ const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
26385
26394
  const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
26386
26395
  const providerType = readNonEmptyString(args.metadataEvent.providerType);
26396
+ const completedTask = sessionId ? updateSessionTaskStatus(args.meshId, sessionId, "completed") : null;
26397
+ if (completedTask) {
26398
+ try {
26399
+ appendLedgerEntry(args.meshId, {
26400
+ kind: "task_completed",
26401
+ nodeId: nodeId || void 0,
26402
+ sessionId,
26403
+ providerType: providerType || void 0,
26404
+ payload: {
26405
+ event: args.event,
26406
+ nodeLabel: args.nodeLabel,
26407
+ taskId: completedTask.id,
26408
+ completedViaReady: true,
26409
+ providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0
26410
+ }
26411
+ });
26412
+ } catch (e) {
26413
+ LOG.warn("MeshLedger", `Failed to record task_completed from ready: ${e?.message || e}`);
26414
+ }
26415
+ }
26387
26416
  if (sessionId && nodeId && providerType) {
26388
26417
  remoteIdleSessions.set(`${nodeId}:${sessionId}`, { nodeId, sessionId, providerType });
26389
26418
  setTimeout(() => {
@@ -26394,13 +26423,13 @@ function injectMeshSystemMessage(components, args) {
26394
26423
  }, 500);
26395
26424
  }
26396
26425
  } else if (args.event === "agent:generating_started") {
26397
- const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
26426
+ const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
26398
26427
  const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
26399
26428
  if (sessionId && nodeId) {
26400
26429
  remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
26401
26430
  }
26402
26431
  } else if (args.event === "agent:stopped") {
26403
- const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
26432
+ const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
26404
26433
  const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
26405
26434
  if (sessionId && nodeId) {
26406
26435
  remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
@@ -26415,7 +26444,7 @@ function injectMeshSystemMessage(components, args) {
26415
26444
  appendLedgerEntry(args.meshId, {
26416
26445
  kind: ledgerKind,
26417
26446
  nodeId: readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId) || void 0,
26418
- sessionId: readNonEmptyString(args.metadataEvent.targetSessionId) || void 0,
26447
+ sessionId: resolveEventSessionId(args.metadataEvent, args.sourceInstanceId) || void 0,
26419
26448
  providerType: readNonEmptyString(args.metadataEvent.providerType) || void 0,
26420
26449
  payload: {
26421
26450
  event: args.event,
@@ -26433,7 +26462,7 @@ function injectMeshSystemMessage(components, args) {
26433
26462
  const mesh = getMesh(args.meshId);
26434
26463
  const maxRetries = mesh?.policy?.maxTaskRetries ?? 1;
26435
26464
  recoveryContext = getSessionRecoveryContext(args.meshId, {
26436
- sessionId: readNonEmptyString(args.metadataEvent.targetSessionId) || void 0,
26465
+ sessionId: resolveEventSessionId(args.metadataEvent, args.sourceInstanceId) || void 0,
26437
26466
  nodeId: readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId) || void 0,
26438
26467
  maxRetries
26439
26468
  });
@@ -26533,7 +26562,7 @@ function handleMeshForwardEvent(components, payload) {
26533
26562
  nodeLabel,
26534
26563
  event: eventName,
26535
26564
  metadataEvent: {
26536
- targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId),
26565
+ targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId),
26537
26566
  providerType: readNonEmptyString(payload.providerType),
26538
26567
  providerSessionId: readNonEmptyString(payload.providerSessionId)
26539
26568
  }
@@ -40984,7 +41013,7 @@ async function shutdownDaemonComponents(components) {
40984
41013
  }
40985
41014
  cdpManagers.clear();
40986
41015
  }
40987
- var path4, import_promises4, import_fs3, import_child_process, import_util3, import_os2, import_path, import_fs4, import_crypto2, import_fs5, import_path2, import_crypto3, import_fs6, import_path3, import_crypto4, import_events2, import_fs7, import_path4, import_crypto5, fs2, path8, os22, os8, os9, path14, import_child_process2, os10, path15, os11, import_child_process3, import_fs8, import_promises5, path, import_util4, import_promises6, path22, path32, fs, os4, path5, import_crypto6, path6, path7, import_fs9, import_path5, import_child_process4, import_fs10, import_os3, path9, import_child_process5, os32, path10, import_fs11, os42, import_child_process6, http, crypto2, fs3, path11, os5, fs4, os6, path12, import_crypto7, fs5, path13, os7, os13, path18, crypto4, import_fs12, import_child_process7, os12, path16, crypto3, fs6, import_module, path17, import_stream2, import_child_process8, import_child_process9, net2, os15, path20, fs7, path19, os14, fs8, path21, os16, import_child_process10, import_crypto8, import_fs13, import_module2, os17, import_path6, os18, import_child_process11, import_child_process12, fs9, os19, path222, import_os4, import_path7, fs10, fs11, path23, os20, import_child_process13, import_os5, http2, fs15, path27, fs12, path24, fs13, path25, fs14, path26, os21, import_child_process14, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __require2, __esm2, __export2, __copyProps2, __toCommonJS2, DEFAULT_MESH_POLICY, init_repo_mesh_types, git_worktree_exports, execFileAsync2, WORKTREE_DIR_NAME, GIT_TIMEOUT_MS, GIT_MAX_BUFFER, init_git_worktree, config_exports, DEFAULT_CONFIG, MACHINE_ID_PREFIX, init_config, mesh_config_exports, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES, init_mesh_config, coordinator_prompt_exports, TOOLS_SECTION, TOOL_EXPOSURE_PREFLIGHT_SECTION, WORKFLOW_SECTION, init_coordinator_prompt, mesh_ledger_exports, LEDGER_DIR_NAME, MAX_FILE_SIZE_BYTES, RECENT_FAILURE_WINDOW_MS, meshLedgerEvents, init_mesh_ledger, init_mesh_work_queue, 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, mesh_events_exports, remoteIdleSessions, MAX_PENDING_EVENTS, pendingMeshCoordinatorEvents, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, init_mesh_events, 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, TerminalTranscriptAccumulator, 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, CHAT_MESSAGE_VISIBILITIES, CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES, CHAT_MESSAGE_AUDIENCES, CHAT_MESSAGE_SOURCES, CHAT_MESSAGE_ACTIVITY_SOURCES, CHAT_MESSAGE_INTERNAL_SOURCES, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, EXPLICIT_HIDDEN_VISIBILITIES, EXPLICIT_VISIBLE_VISIBILITIES, HIDDEN_AUDIENCES, ACTIVITY_SOURCE_SET, INTERNAL_SOURCE_SET, 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, VALID_INPUT_MEDIA_TYPES, VALID_INPUT_STRATEGIES, TEXT_ONLY_MESSAGE_INPUT_SUPPORT, IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, CLI_CHAT_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES, globalStore, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, HERMES_CLI_STARTING_SEND_SETTLE_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN, KEY_TO_VK, COMMAND_DEBUG_LEVELS, DaemonCommandHandler, IMAGE_MIME_EXTENSIONS, MATERIALIZED_IMAGE_MAX_AGE_MS, MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS, lastMaterializedImageCleanupAt, CachedDatabaseSync, CliProviderInstance, AcpProviderInstance, chalkModule, chalkApi, COORDINATOR_DELEGATED_ENV_UNSETS, DaemonCliManager, VALID_CAPABILITY_MEDIA_TYPES, VALID_INPUT_STRATEGIES2, 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, HERMES_CLI_TYPE, HERMES_MCP_CONFIG_PATH, 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, SessionHostCompatibilityError, EXTENSION_CATALOG, SessionRegistry;
41016
+ var path4, import_promises4, import_fs3, import_child_process, import_util3, import_os2, import_path, import_fs4, import_crypto2, import_fs5, import_path2, import_crypto3, import_fs6, import_path3, import_crypto4, import_events2, import_fs7, import_path4, import_crypto5, fs2, path8, os22, os8, os9, path14, import_child_process2, os10, path15, os11, import_child_process3, import_fs8, import_promises5, path, import_util4, import_promises6, path22, path32, fs, os4, path5, import_crypto6, path6, path7, import_fs9, import_path5, import_child_process4, import_fs10, import_os3, path9, import_child_process5, os32, path10, import_fs11, os42, import_child_process6, http, crypto2, fs3, path11, os5, fs4, os6, path12, import_crypto7, fs5, path13, os7, os13, path18, crypto4, import_fs12, import_child_process7, os12, path16, crypto3, fs6, import_module, path17, import_stream2, import_child_process8, import_child_process9, net2, os15, path20, fs7, path19, os14, fs8, path21, os16, import_child_process10, import_crypto8, import_fs13, import_module2, os17, import_path6, os18, import_child_process11, import_child_process12, fs9, os19, path222, import_os4, import_path7, fs10, fs11, path23, os20, import_child_process13, import_os5, http2, fs15, path27, fs12, path24, fs13, path25, fs14, path26, os21, import_child_process14, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __require2, __esm2, __export2, __copyProps2, __toCommonJS2, DEFAULT_MESH_POLICY, init_repo_mesh_types, git_worktree_exports, execFileAsync2, WORKTREE_DIR_NAME, GIT_TIMEOUT_MS, GIT_MAX_BUFFER, init_git_worktree, config_exports, DEFAULT_CONFIG, MACHINE_ID_PREFIX, init_config, mesh_config_exports, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES, init_mesh_config, coordinator_prompt_exports, TOOLS_SECTION, TOOL_EXPOSURE_PREFLIGHT_SECTION, WORKFLOW_SECTION, init_coordinator_prompt, mesh_ledger_exports, LEDGER_DIR_NAME, MAX_FILE_SIZE_BYTES, RECENT_FAILURE_WINDOW_MS, meshLedgerEvents, init_mesh_ledger, mesh_work_queue_exports, init_mesh_work_queue, 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, mesh_events_exports, remoteIdleSessions, MAX_PENDING_EVENTS, pendingMeshCoordinatorEvents, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, init_mesh_events, 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, TerminalTranscriptAccumulator, 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, CHAT_MESSAGE_VISIBILITIES, CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES, CHAT_MESSAGE_AUDIENCES, CHAT_MESSAGE_SOURCES, CHAT_MESSAGE_ACTIVITY_SOURCES, CHAT_MESSAGE_INTERNAL_SOURCES, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, EXPLICIT_HIDDEN_VISIBILITIES, EXPLICIT_VISIBLE_VISIBILITIES, HIDDEN_AUDIENCES, ACTIVITY_SOURCE_SET, INTERNAL_SOURCE_SET, 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, VALID_INPUT_MEDIA_TYPES, VALID_INPUT_STRATEGIES, TEXT_ONLY_MESSAGE_INPUT_SUPPORT, IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, CLI_CHAT_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES, globalStore, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, HERMES_CLI_STARTING_SEND_SETTLE_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN, KEY_TO_VK, COMMAND_DEBUG_LEVELS, DaemonCommandHandler, IMAGE_MIME_EXTENSIONS, MATERIALIZED_IMAGE_MAX_AGE_MS, MATERIALIZED_IMAGE_CLEANUP_INTERVAL_MS, lastMaterializedImageCleanupAt, CachedDatabaseSync, CliProviderInstance, AcpProviderInstance, chalkModule, chalkApi, COORDINATOR_DELEGATED_ENV_UNSETS, DaemonCliManager, VALID_CAPABILITY_MEDIA_TYPES, VALID_INPUT_STRATEGIES2, 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, HERMES_CLI_TYPE, HERMES_MCP_CONFIG_PATH, 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, SessionHostCompatibilityError, EXTENSION_CATALOG, SessionRegistry;
40988
41017
  var init_dist2 = __esm({
40989
41018
  "../daemon-core/dist/index.mjs"() {
40990
41019
  "use strict";
@@ -41317,6 +41346,15 @@ Follow these recovery rules:
41317
41346
  meshLedgerEvents = new import_events2.EventEmitter();
41318
41347
  }
41319
41348
  });
41349
+ mesh_work_queue_exports = {};
41350
+ __export2(mesh_work_queue_exports, {
41351
+ claimNextTask: () => claimNextTask,
41352
+ enqueueTask: () => enqueueTask,
41353
+ getMeshQueueStats: () => getMeshQueueStats,
41354
+ getQueue: () => getQueue,
41355
+ updateSessionTaskStatus: () => updateSessionTaskStatus,
41356
+ updateTaskStatus: () => updateTaskStatus
41357
+ });
41320
41358
  init_mesh_work_queue = __esm2({
41321
41359
  "src/mesh/mesh-work-queue.ts"() {
41322
41360
  "use strict";
@@ -41400,6 +41438,7 @@ Follow these recovery rules:
41400
41438
  MAX_PENDING_EVENTS = 50;
41401
41439
  pendingMeshCoordinatorEvents = [];
41402
41440
  MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
41441
+ "agent:generating_started",
41403
41442
  "agent:generating_completed",
41404
41443
  "agent:waiting_approval",
41405
41444
  "agent:stopped",
@@ -53093,6 +53132,18 @@ Run 'adhdev doctor' for detailed diagnostics.`
53093
53132
  return { success: false, error: e.message };
53094
53133
  }
53095
53134
  }
53135
+ case "get_mesh_queue": {
53136
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
53137
+ if (!meshId) return { success: false, error: "meshId required" };
53138
+ try {
53139
+ const { getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
53140
+ const status = Array.isArray(args?.status) ? args.status.map((s) => typeof s === "string" ? s.trim() : "").filter(Boolean) : void 0;
53141
+ const queue = getQueue2(meshId, { status });
53142
+ return { success: true, queue };
53143
+ } catch (e) {
53144
+ return { success: false, error: e.message };
53145
+ }
53146
+ }
53096
53147
  case "add_mesh_node": {
53097
53148
  const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
53098
53149
  const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
@@ -57620,7 +57671,7 @@ async function commandForNode(ctx, node, command, args = {}) {
57620
57671
  }
57621
57672
  var MESH_STATUS_TOOL = {
57622
57673
  name: "mesh_status",
57623
- 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.",
57674
+ description: "Get the current status of all nodes in the repo mesh \u2014 health, git state, active sessions, recovery hints, and recommended next steps. Use this to decide which node to send work to or how to recover from failures.",
57624
57675
  inputSchema: {
57625
57676
  type: "object",
57626
57677
  properties: {
@@ -57849,6 +57900,7 @@ async function meshStatus(ctx) {
57849
57900
  await refreshMeshFromDaemon(ctx);
57850
57901
  const { mesh, transport } = ctx;
57851
57902
  const results = [];
57903
+ const ledgerSummary = getLedgerSummary(mesh.id);
57852
57904
  for (const node of mesh.nodes) {
57853
57905
  const entry = {
57854
57906
  nodeId: node.id,
@@ -57882,6 +57934,33 @@ async function meshStatus(ctx) {
57882
57934
  entry.health = "degraded";
57883
57935
  entry.error = e.message;
57884
57936
  }
57937
+ const recoveryContext = getSessionRecoveryContext(mesh.id, { nodeId: node.id });
57938
+ if (recoveryContext.consecutiveNodeFailures > 0) {
57939
+ entry.recoveryHints = {
57940
+ consecutiveFailures: recoveryContext.consecutiveNodeFailures,
57941
+ lastTaskMessage: recoveryContext.lastTaskMessage,
57942
+ advice: recoveryContext.advice,
57943
+ retryRecommended: recoveryContext.retryRecommended
57944
+ };
57945
+ }
57946
+ const nextStepHints = [];
57947
+ if (entry.health === "online" && node.isLocalWorktree) {
57948
+ nextStepHints.push(`Merge worktree to base via mesh_refine_node(node_id: "${node.id}")`);
57949
+ } else if (entry.health === "dirty") {
57950
+ nextStepHints.push(`Commit changes via mesh_checkpoint(node_id: "${node.id}", message: "...")`);
57951
+ } else if (entry.health === "degraded" && entry.error?.includes("git")) {
57952
+ nextStepHints.push("Initialize git repository or check workspace path.");
57953
+ }
57954
+ if (recoveryContext.consecutiveNodeFailures > 0) {
57955
+ if (recoveryContext.retryRecommended) {
57956
+ nextStepHints.push(`Retry task on this node or launch a fresh session.`);
57957
+ } else {
57958
+ nextStepHints.push(`Consider reassigning work to a different node.`);
57959
+ }
57960
+ }
57961
+ if (nextStepHints.length > 0) {
57962
+ entry.nextStepHints = nextStepHints;
57963
+ }
57885
57964
  const relatedRepos = await collectRelatedRepoStatuses(ctx, node);
57886
57965
  if (relatedRepos.length) entry.relatedRepos = relatedRepos;
57887
57966
  results.push(entry);
@@ -57895,7 +57974,7 @@ async function meshStatus(ctx) {
57895
57974
  nodes: results
57896
57975
  };
57897
57976
  try {
57898
- response.ledgerSummary = getLedgerSummary(mesh.id);
57977
+ response.ledgerSummary = ledgerSummary;
57899
57978
  } catch {
57900
57979
  }
57901
57980
  if (ctx.transport instanceof IpcTransport) {
@@ -58020,8 +58099,11 @@ async function meshSendTask(ctx, args) {
58020
58099
  }
58021
58100
  return JSON.stringify({ ...result, nodeId: args.node_id });
58022
58101
  }
58023
- const task = enqueueTask(ctx.mesh.id, args.message, { targetNodeId: args.node_id });
58024
- if (isLocalTransport(ctx.transport)) {
58102
+ const task = enqueueTask(ctx.mesh.id, args.message, {
58103
+ targetNodeId: args.node_id,
58104
+ targetSessionId: args.session_id
58105
+ });
58106
+ if (isLocalTransport(ctx.transport) || ctx.transport instanceof IpcTransport) {
58025
58107
  ctx.transport.command("trigger_mesh_queue", { meshId: ctx.mesh.id }).catch(() => {
58026
58108
  });
58027
58109
  }