@adhdev/daemon-core 0.9.82-rc.339 → 0.9.82-rc.340

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.
@@ -310,6 +310,25 @@ export declare class DaemonCommandRouter {
310
310
  private getCachedAggregateMeshStatus;
311
311
  private rememberAggregateMeshStatus;
312
312
  getCachedInlineMeshNodes(): any[];
313
+ /**
314
+ * Resolve the REMOTE worker daemonId that owns a given session, when the session
315
+ * belongs to a mesh node hosted on a DIFFERENT daemon than this coordinator.
316
+ *
317
+ * The coordinator does not host remote-worker session instances in its own
318
+ * instanceManager/sessionRegistry — only their cached mesh-node metadata. A
319
+ * dashboard-issued session-scoped command (invoke_provider_script / resolve_action /
320
+ * set_mode / …) lands on the coordinator with a targetSessionId the coordinator can't
321
+ * find locally, and without forwarding it dies as "Live session not found". send_chat
322
+ * happens to survive (its target resolves to the worker by another route), but the
323
+ * controlbar commands do not — so the controlbar buttons appear to do nothing.
324
+ *
325
+ * Mirror the existing node-level remote-forward pattern (fast_forward_mesh_node etc.):
326
+ * scan the cached inline-mesh nodes for the one whose active session matches the
327
+ * targetSessionId, and return its daemonId when that daemonId is a remote daemon (i.e.
328
+ * not this coordinator's own statusInstanceId). Returns undefined for a locally-hosted
329
+ * session (no forward — execute locally as before) or when ownership can't be resolved.
330
+ */
331
+ resolveRemoteMeshSessionOwnerDaemonId(sessionId: string): string | undefined;
313
332
  getCachedInlineMesh(meshId: string, inlineMesh?: unknown): any | undefined;
314
333
  private warmInlineMeshCache;
315
334
  private getMeshForCommand;
package/dist/index.js CHANGED
@@ -316,10 +316,10 @@ function readInjected(value) {
316
316
  }
317
317
  function getDaemonBuildInfo() {
318
318
  if (cached) return cached;
319
- const commit = readInjected(true ? "042075899bbd2feb9c22f9ccd01990408323443d" : void 0) ?? "unknown";
320
- const commitShort = readInjected(true ? "04207589" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
321
- const version = readInjected(true ? "0.9.82-rc.339" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
322
- const builtAt = readInjected(true ? "2026-06-20T12:40:45.079Z" : void 0);
319
+ const commit = readInjected(true ? "4208ff17576c4e0d480e0773908bb522545f006f" : void 0) ?? "unknown";
320
+ const commitShort = readInjected(true ? "4208ff17" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
321
+ const version = readInjected(true ? "0.9.82-rc.340" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
322
+ const builtAt = readInjected(true ? "2026-06-20T14:30:26.030Z" : void 0);
323
323
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
324
324
  return cached;
325
325
  }
@@ -44442,6 +44442,16 @@ function readCachedInlineMeshActiveSessionDetails(node) {
44442
44442
  startedAt: readStringValue(fallbackSession.startedAt, fallbackSession.started_at) ?? null,
44443
44443
  lastActivityAt: readStringValue(fallbackSession.lastActivityAt, fallbackSession.last_activity_at) ?? null,
44444
44444
  recoveryState: readStringValue(fallbackSession.recoveryState, fallbackSession.recovery_state) ?? null,
44445
+ // [T2] Carry the worker-computed last-message preview through the cached inline-mesh
44446
+ // active-session entry. The worker's get_status_metadata slim now ships these
44447
+ // (mesh-tools.ts), and this is the surface the coordinator's inbox-preview path reads
44448
+ // (buildDaemonMetadataUpdateForSubscription → stampLocalAssistantPreviewOnCachedEntry).
44449
+ // Without carrying them here, the coordinator could only derive the preview from a live
44450
+ // in-process instance it doesn't host for a remote worker, so the inbox stuck on the
44451
+ // dispatched user task. Only present when the worker reported them.
44452
+ ...readStringValue(fallbackSession.lastMessagePreview, fallbackSession.last_message_preview) ? { lastMessagePreview: readStringValue(fallbackSession.lastMessagePreview, fallbackSession.last_message_preview) } : {},
44453
+ ...readStringValue(fallbackSession.lastMessageRole, fallbackSession.last_message_role) ? { lastMessageRole: readStringValue(fallbackSession.lastMessageRole, fallbackSession.last_message_role) } : {},
44454
+ ...readNumberValue(fallbackSession.lastMessageAt, fallbackSession.last_message_at) !== void 0 ? { lastMessageAt: readNumberValue(fallbackSession.lastMessageAt, fallbackSession.last_message_at) } : {},
44445
44455
  isCached: true
44446
44456
  }];
44447
44457
  }
@@ -45931,6 +45941,13 @@ var CHAT_COMMANDS = [
45931
45941
  "set_mode",
45932
45942
  "change_model"
45933
45943
  ];
45944
+ var MESH_FORWARDABLE_SESSION_COMMANDS = /* @__PURE__ */ new Set([
45945
+ "invoke_provider_script",
45946
+ "resolve_action",
45947
+ "set_mode",
45948
+ "change_model",
45949
+ "set_thought_level"
45950
+ ]);
45934
45951
  var READ_DEBUG_ENABLED2 = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
45935
45952
  function normalizeCommandSource(source) {
45936
45953
  switch (source) {
@@ -46247,6 +46264,38 @@ var DaemonCommandRouter = class {
46247
46264
  }
46248
46265
  return nodes;
46249
46266
  }
46267
+ /**
46268
+ * Resolve the REMOTE worker daemonId that owns a given session, when the session
46269
+ * belongs to a mesh node hosted on a DIFFERENT daemon than this coordinator.
46270
+ *
46271
+ * The coordinator does not host remote-worker session instances in its own
46272
+ * instanceManager/sessionRegistry — only their cached mesh-node metadata. A
46273
+ * dashboard-issued session-scoped command (invoke_provider_script / resolve_action /
46274
+ * set_mode / …) lands on the coordinator with a targetSessionId the coordinator can't
46275
+ * find locally, and without forwarding it dies as "Live session not found". send_chat
46276
+ * happens to survive (its target resolves to the worker by another route), but the
46277
+ * controlbar commands do not — so the controlbar buttons appear to do nothing.
46278
+ *
46279
+ * Mirror the existing node-level remote-forward pattern (fast_forward_mesh_node etc.):
46280
+ * scan the cached inline-mesh nodes for the one whose active session matches the
46281
+ * targetSessionId, and return its daemonId when that daemonId is a remote daemon (i.e.
46282
+ * not this coordinator's own statusInstanceId). Returns undefined for a locally-hosted
46283
+ * session (no forward — execute locally as before) or when ownership can't be resolved.
46284
+ */
46285
+ resolveRemoteMeshSessionOwnerDaemonId(sessionId) {
46286
+ const trimmed = typeof sessionId === "string" ? sessionId.trim() : "";
46287
+ if (!trimmed) return void 0;
46288
+ const selfDaemonId = this.deps.statusInstanceId;
46289
+ for (const node of this.getCachedInlineMeshNodes()) {
46290
+ const nodeSessions = readCachedInlineMeshActiveSessions(node);
46291
+ if (!nodeSessions.includes(trimmed)) continue;
46292
+ const nodeDaemonId = readMeshNodeDaemonId(readObjectRecord(node));
46293
+ if (!nodeDaemonId) return void 0;
46294
+ if (selfDaemonId && nodeDaemonId === selfDaemonId) return void 0;
46295
+ return nodeDaemonId;
46296
+ }
46297
+ return void 0;
46298
+ }
46250
46299
  getCachedInlineMesh(meshId, inlineMesh) {
46251
46300
  if (inlineMesh && typeof inlineMesh === "object") {
46252
46301
  return this.warmInlineMeshCache(meshId, inlineMesh);
@@ -48192,6 +48241,24 @@ ${hintLines.join("\n")}` : "",
48192
48241
  * Returns null if not handled at this level → caller delegates to CommandHandler.
48193
48242
  */
48194
48243
  async executeDaemonCommand(cmd, args) {
48244
+ if (MESH_FORWARDABLE_SESSION_COMMANDS.has(cmd) && this.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
48245
+ const targetSessionId = readStringValue(args?.targetSessionId, args?.sessionId, args?.instanceId);
48246
+ if (targetSessionId) {
48247
+ const localInstance = this.deps.instanceManager?.getInstance(targetSessionId);
48248
+ const localRegistry = this.deps.sessionRegistry?.get?.(targetSessionId);
48249
+ if (!localInstance && !localRegistry) {
48250
+ const ownerDaemonId = this.resolveRemoteMeshSessionOwnerDaemonId(targetSessionId);
48251
+ if (ownerDaemonId) {
48252
+ LOG.info("Mesh", `[Mesh] Forwarding session-scoped '${cmd}' for remote worker session ${targetSessionId.split("_")[0]} \u2192 daemon ${ownerDaemonId.slice(0, 12)}`);
48253
+ const forwarded = await this.deps.dispatchMeshCommand(ownerDaemonId, cmd, {
48254
+ ...typeof args === "object" && args !== null ? args : {},
48255
+ _meshDirectDispatch: true
48256
+ });
48257
+ return forwarded ?? { success: false, error: "no response from remote worker daemon" };
48258
+ }
48259
+ }
48260
+ }
48261
+ }
48195
48262
  switch (cmd) {
48196
48263
  // ─── CLI / ACP commands ───
48197
48264
  case "mesh_forward_event": {