adhdev 0.9.82-rc.22 → 0.9.82-rc.24

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
@@ -3290,6 +3290,36 @@ function getQueuePath(meshId) {
3290
3290
  const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
3291
3291
  return (0, import_path4.join)(getLedgerDir(), `${safe}.queue.json`);
3292
3292
  }
3293
+ function getLockPath(meshId) {
3294
+ const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
3295
+ return (0, import_path4.join)(getLedgerDir(), `${safe}.queue.lock`);
3296
+ }
3297
+ function withQueueLock(meshId, fn) {
3298
+ const lockPath = getLockPath(meshId);
3299
+ let fd = -1;
3300
+ for (let i = 0; i < 10; i++) {
3301
+ try {
3302
+ fd = (0, import_fs4.openSync)(lockPath, "wx");
3303
+ break;
3304
+ } catch {
3305
+ const deadline = Date.now() + 30;
3306
+ while (Date.now() < deadline) {
3307
+ }
3308
+ }
3309
+ }
3310
+ try {
3311
+ return fn();
3312
+ } finally {
3313
+ if (fd !== -1) try {
3314
+ (0, import_fs4.closeSync)(fd);
3315
+ } catch {
3316
+ }
3317
+ try {
3318
+ (0, import_fs4.unlinkSync)(lockPath);
3319
+ } catch {
3320
+ }
3321
+ }
3322
+ }
3293
3323
  function readQueue(meshId) {
3294
3324
  const path35 = getQueuePath(meshId);
3295
3325
  if (!(0, import_fs4.existsSync)(path35)) return [];
@@ -3305,20 +3335,22 @@ function writeQueue(meshId, queue) {
3305
3335
  (0, import_fs4.writeFileSync)(path35, JSON.stringify(queue, null, 2), "utf-8");
3306
3336
  }
3307
3337
  function enqueueTask(meshId, message, opts) {
3308
- const queue = readQueue(meshId);
3309
- const entry = {
3310
- id: (0, import_crypto5.randomUUID)(),
3311
- meshId,
3312
- message,
3313
- status: "pending",
3314
- targetNodeId: opts?.targetNodeId,
3315
- targetSessionId: opts?.targetSessionId,
3316
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3317
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3318
- };
3319
- queue.push(entry);
3320
- writeQueue(meshId, queue);
3321
- return entry;
3338
+ return withQueueLock(meshId, () => {
3339
+ const queue = readQueue(meshId);
3340
+ const entry = {
3341
+ id: (0, import_crypto5.randomUUID)(),
3342
+ meshId,
3343
+ message,
3344
+ status: "pending",
3345
+ targetNodeId: opts?.targetNodeId,
3346
+ targetSessionId: opts?.targetSessionId,
3347
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3348
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3349
+ };
3350
+ queue.push(entry);
3351
+ writeQueue(meshId, queue);
3352
+ return entry;
3353
+ });
3322
3354
  }
3323
3355
  function getQueue(meshId, opts) {
3324
3356
  let queue = readQueue(meshId);
@@ -3329,100 +3361,109 @@ function getQueue(meshId, opts) {
3329
3361
  return queue;
3330
3362
  }
3331
3363
  function claimNextTask(meshId, nodeId, sessionId) {
3332
- const queue = readQueue(meshId);
3333
- const hasActiveAssignment = queue.some((q) => q.status === "assigned" && (q.assignedSessionId === sessionId || q.assignedNodeId === nodeId));
3334
- if (hasActiveAssignment) return null;
3335
- let targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetSessionId === sessionId);
3336
- if (targetIdx === -1) {
3337
- targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetNodeId === nodeId && !q.targetSessionId);
3338
- }
3339
- if (targetIdx === -1) {
3340
- targetIdx = queue.findIndex((q) => q.status === "pending" && !q.targetNodeId && !q.targetSessionId);
3341
- }
3342
- if (targetIdx === -1) return null;
3343
- const entry = queue[targetIdx];
3344
- entry.status = "assigned";
3345
- entry.assignedNodeId = nodeId;
3346
- entry.assignedSessionId = sessionId;
3347
- entry.dispatchTimestamp = (/* @__PURE__ */ new Date()).toISOString();
3348
- entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
3349
- writeQueue(meshId, queue);
3350
- return entry;
3364
+ return withQueueLock(meshId, () => {
3365
+ const queue = readQueue(meshId);
3366
+ const hasActiveAssignment = queue.some((q) => q.status === "assigned" && (q.assignedSessionId === sessionId || q.assignedNodeId === nodeId));
3367
+ if (hasActiveAssignment) return null;
3368
+ let targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetSessionId === sessionId);
3369
+ if (targetIdx === -1) {
3370
+ targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetNodeId === nodeId && !q.targetSessionId);
3371
+ }
3372
+ if (targetIdx === -1) {
3373
+ targetIdx = queue.findIndex((q) => q.status === "pending" && !q.targetNodeId && !q.targetSessionId);
3374
+ }
3375
+ if (targetIdx === -1) return null;
3376
+ const entry = queue[targetIdx];
3377
+ entry.status = "assigned";
3378
+ entry.assignedNodeId = nodeId;
3379
+ entry.assignedSessionId = sessionId;
3380
+ entry.dispatchTimestamp = (/* @__PURE__ */ new Date()).toISOString();
3381
+ entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
3382
+ writeQueue(meshId, queue);
3383
+ return entry;
3384
+ });
3351
3385
  }
3352
3386
  function updateTaskStatus(meshId, taskId, status) {
3353
- const queue = readQueue(meshId);
3354
- const idx = queue.findIndex((q) => q.id === taskId);
3355
- if (idx === -1) return null;
3356
- queue[idx].status = status;
3357
- queue[idx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
3358
- writeQueue(meshId, queue);
3359
- return queue[idx];
3387
+ return withQueueLock(meshId, () => {
3388
+ const queue = readQueue(meshId);
3389
+ const idx = queue.findIndex((q) => q.id === taskId);
3390
+ if (idx === -1) return null;
3391
+ queue[idx].status = status;
3392
+ queue[idx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
3393
+ writeQueue(meshId, queue);
3394
+ return queue[idx];
3395
+ });
3360
3396
  }
3361
3397
  function recordTaskAutoLaunch(meshId, taskId, autoLaunch) {
3362
- const queue = readQueue(meshId);
3363
- const idx = queue.findIndex((q) => q.id === taskId);
3364
- if (idx === -1) return null;
3365
- const now = (/* @__PURE__ */ new Date()).toISOString();
3366
- queue[idx].autoLaunch = {
3367
- ...autoLaunch,
3368
- updatedAt: now
3369
- };
3370
- queue[idx].updatedAt = now;
3371
- writeQueue(meshId, queue);
3372
- return queue[idx];
3398
+ return withQueueLock(meshId, () => {
3399
+ const queue = readQueue(meshId);
3400
+ const idx = queue.findIndex((q) => q.id === taskId);
3401
+ if (idx === -1) return null;
3402
+ const now = (/* @__PURE__ */ new Date()).toISOString();
3403
+ queue[idx].autoLaunch = { ...autoLaunch, updatedAt: now };
3404
+ queue[idx].updatedAt = now;
3405
+ writeQueue(meshId, queue);
3406
+ return queue[idx];
3407
+ });
3373
3408
  }
3374
3409
  function cancelTask(meshId, taskId, opts) {
3375
- const queue = readQueue(meshId);
3376
- const idx = queue.findIndex((q) => q.id === taskId);
3377
- if (idx === -1) return null;
3378
- const now = (/* @__PURE__ */ new Date()).toISOString();
3379
- queue[idx].status = "cancelled";
3380
- queue[idx].updatedAt = now;
3381
- queue[idx].cancelledAt = now;
3382
- if (opts?.reason) queue[idx].cancelReason = opts.reason;
3383
- writeQueue(meshId, queue);
3384
- return queue[idx];
3410
+ return withQueueLock(meshId, () => {
3411
+ const queue = readQueue(meshId);
3412
+ const idx = queue.findIndex((q) => q.id === taskId);
3413
+ if (idx === -1) return null;
3414
+ const now = (/* @__PURE__ */ new Date()).toISOString();
3415
+ queue[idx].status = "cancelled";
3416
+ queue[idx].updatedAt = now;
3417
+ queue[idx].cancelledAt = now;
3418
+ if (opts?.reason) queue[idx].cancelReason = opts.reason;
3419
+ writeQueue(meshId, queue);
3420
+ return queue[idx];
3421
+ });
3385
3422
  }
3386
3423
  function requeueTask(meshId, taskId, opts) {
3387
- const queue = readQueue(meshId);
3388
- const idx = queue.findIndex((q) => q.id === taskId);
3389
- if (idx === -1) return null;
3390
- const entry = queue[idx];
3391
- const now = (/* @__PURE__ */ new Date()).toISOString();
3392
- entry.status = "pending";
3393
- delete entry.assignedNodeId;
3394
- delete entry.assignedSessionId;
3395
- delete entry.cancelledAt;
3396
- delete entry.cancelReason;
3397
- if (opts?.clearTargetNode) delete entry.targetNodeId;
3398
- if (typeof opts?.targetNodeId === "string") entry.targetNodeId = opts.targetNodeId;
3399
- if (opts?.clearTargetSession !== false) delete entry.targetSessionId;
3400
- if (typeof opts?.targetSessionId === "string") entry.targetSessionId = opts.targetSessionId;
3401
- entry.updatedAt = now;
3402
- entry.requeuedAt = now;
3403
- entry.requeueCount = (entry.requeueCount || 0) + 1;
3404
- if (opts?.reason) entry.requeueReason = opts.reason;
3405
- writeQueue(meshId, queue);
3406
- return entry;
3424
+ return withQueueLock(meshId, () => {
3425
+ const queue = readQueue(meshId);
3426
+ const idx = queue.findIndex((q) => q.id === taskId);
3427
+ if (idx === -1) return null;
3428
+ const entry = queue[idx];
3429
+ const now = (/* @__PURE__ */ new Date()).toISOString();
3430
+ entry.status = "pending";
3431
+ delete entry.assignedNodeId;
3432
+ delete entry.assignedSessionId;
3433
+ delete entry.cancelledAt;
3434
+ delete entry.cancelReason;
3435
+ if (opts?.clearTargetNode) delete entry.targetNodeId;
3436
+ if (typeof opts?.targetNodeId === "string") entry.targetNodeId = opts.targetNodeId;
3437
+ if (opts?.clearTargetSession !== false) delete entry.targetSessionId;
3438
+ if (typeof opts?.targetSessionId === "string") entry.targetSessionId = opts.targetSessionId;
3439
+ entry.updatedAt = now;
3440
+ entry.requeuedAt = now;
3441
+ entry.requeueCount = (entry.requeueCount || 0) + 1;
3442
+ if (opts?.reason) entry.requeueReason = opts.reason;
3443
+ writeQueue(meshId, queue);
3444
+ return entry;
3445
+ });
3407
3446
  }
3408
3447
  function updateSessionTaskStatus(meshId, sessionId, status) {
3409
- const queue = readQueue(meshId);
3410
- let bestIdx = -1;
3411
- let bestTime = 0;
3412
- for (let i = queue.length - 1; i >= 0; i--) {
3413
- if (queue[i].assignedSessionId === sessionId && queue[i].status === "assigned") {
3414
- const time3 = new Date(queue[i].dispatchTimestamp || queue[i].updatedAt).getTime();
3415
- if (time3 > bestTime) {
3416
- bestTime = time3;
3417
- bestIdx = i;
3418
- }
3419
- }
3420
- }
3421
- if (bestIdx === -1) return null;
3422
- queue[bestIdx].status = status;
3423
- queue[bestIdx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
3424
- writeQueue(meshId, queue);
3425
- return queue[bestIdx];
3448
+ return withQueueLock(meshId, () => {
3449
+ const queue = readQueue(meshId);
3450
+ let bestIdx = -1;
3451
+ let bestTime = 0;
3452
+ for (let i = queue.length - 1; i >= 0; i--) {
3453
+ if (queue[i].assignedSessionId === sessionId && queue[i].status === "assigned") {
3454
+ const time3 = new Date(queue[i].dispatchTimestamp || queue[i].updatedAt).getTime();
3455
+ if (time3 > bestTime) {
3456
+ bestTime = time3;
3457
+ bestIdx = i;
3458
+ }
3459
+ }
3460
+ }
3461
+ if (bestIdx === -1) return null;
3462
+ queue[bestIdx].status = status;
3463
+ queue[bestIdx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
3464
+ writeQueue(meshId, queue);
3465
+ return queue[bestIdx];
3466
+ });
3426
3467
  }
3427
3468
  function getMeshQueueStats(meshId) {
3428
3469
  const queue = readQueue(meshId);
@@ -3831,21 +3872,70 @@ __export(mesh_events_exports, {
3831
3872
  triggerMeshQueue: () => triggerMeshQueue,
3832
3873
  tryAssignQueueTask: () => tryAssignQueueTask
3833
3874
  });
3875
+ function sweepExpiredRemoteIdleSessions() {
3876
+ const now = Date.now();
3877
+ for (const [key, session] of remoteIdleSessions) {
3878
+ if (session.expiresAt <= now) remoteIdleSessions.delete(key);
3879
+ }
3880
+ }
3881
+ function getPendingEventsPath(meshId) {
3882
+ const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
3883
+ return (0, import_path5.join)(getLedgerDir(), `${safe}.pending-events.jsonl`);
3884
+ }
3834
3885
  function queuePendingMeshCoordinatorEvent(event) {
3835
- if (pendingMeshCoordinatorEvents.length >= MAX_PENDING_EVENTS) {
3886
+ try {
3887
+ (0, import_fs6.appendFileSync)(getPendingEventsPath(event.meshId), JSON.stringify(event) + "\n", "utf-8");
3888
+ return true;
3889
+ } catch (e) {
3890
+ LOG.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
3836
3891
  return false;
3837
3892
  }
3838
- pendingMeshCoordinatorEvents.push(event);
3839
- return true;
3840
3893
  }
3841
- function drainPendingMeshCoordinatorEvents() {
3842
- return pendingMeshCoordinatorEvents.splice(0);
3894
+ function drainPendingMeshCoordinatorEvents(meshId) {
3895
+ if (!meshId) return [];
3896
+ const path35 = getPendingEventsPath(meshId);
3897
+ if (!(0, import_fs6.existsSync)(path35)) return [];
3898
+ try {
3899
+ const raw = (0, import_fs6.readFileSync)(path35, "utf-8");
3900
+ try {
3901
+ (0, import_fs6.unlinkSync)(path35);
3902
+ } catch {
3903
+ }
3904
+ return raw.split("\n").filter(Boolean).flatMap((line) => {
3905
+ try {
3906
+ return [JSON.parse(line)];
3907
+ } catch {
3908
+ return [];
3909
+ }
3910
+ });
3911
+ } catch {
3912
+ return [];
3913
+ }
3843
3914
  }
3844
- function getPendingMeshCoordinatorEvents() {
3845
- return pendingMeshCoordinatorEvents.slice();
3915
+ function getPendingMeshCoordinatorEvents(meshId) {
3916
+ if (!meshId) return [];
3917
+ const path35 = getPendingEventsPath(meshId);
3918
+ if (!(0, import_fs6.existsSync)(path35)) return [];
3919
+ try {
3920
+ const raw = (0, import_fs6.readFileSync)(path35, "utf-8");
3921
+ return raw.split("\n").filter(Boolean).flatMap((line) => {
3922
+ try {
3923
+ return [JSON.parse(line)];
3924
+ } catch {
3925
+ return [];
3926
+ }
3927
+ });
3928
+ } catch {
3929
+ return [];
3930
+ }
3846
3931
  }
3847
- function clearPendingMeshCoordinatorEvents() {
3848
- pendingMeshCoordinatorEvents.splice(0);
3932
+ function clearPendingMeshCoordinatorEvents(meshId) {
3933
+ if (!meshId) return;
3934
+ const path35 = getPendingEventsPath(meshId);
3935
+ if ((0, import_fs6.existsSync)(path35)) try {
3936
+ (0, import_fs6.unlinkSync)(path35);
3937
+ } catch {
3938
+ }
3849
3939
  }
3850
3940
  function readNonEmptyString(value) {
3851
3941
  return typeof value === "string" && value.trim() ? value.trim() : "";
@@ -3909,7 +3999,16 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
3909
3999
  message: task.message
3910
4000
  }).catch((e) => {
3911
4001
  LOG.error("MeshQueue", `Failed to dispatch task via P2P to remote node ${nodeId}: ${e?.message}`);
3912
- updateTaskStatus(meshId, task.id, "failed");
4002
+ updateTaskStatus(meshId, task.id, "pending");
4003
+ try {
4004
+ appendLedgerEntry(meshId, {
4005
+ kind: "dispatch_failed",
4006
+ nodeId,
4007
+ sessionId,
4008
+ payload: { taskId: task.id, error: e?.message, retryable: true }
4009
+ });
4010
+ } catch {
4011
+ }
3913
4012
  });
3914
4013
  return true;
3915
4014
  }
@@ -4252,9 +4351,9 @@ function injectMeshSystemMessage(components, args) {
4252
4351
  const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed");
4253
4352
  completedTaskForLedger = completedTask ? { id: completedTask.id } : null;
4254
4353
  if (nodeId && providerType) {
4255
- setTimeout(() => {
4354
+ setImmediate(() => {
4256
4355
  tryAssignQueueTask(components, args.meshId, nodeId, sessionId, providerType);
4257
- }, 500);
4356
+ });
4258
4357
  }
4259
4358
  }
4260
4359
  } else if (args.event === "agent:ready") {
@@ -4292,13 +4391,17 @@ function injectMeshSystemMessage(components, args) {
4292
4391
  }
4293
4392
  }
4294
4393
  if (sessionId && nodeId && providerType) {
4295
- remoteIdleSessions.set(`${nodeId}:${sessionId}`, { nodeId, sessionId, providerType });
4296
- setTimeout(() => {
4394
+ sweepExpiredRemoteIdleSessions();
4395
+ remoteIdleSessions.set(`${nodeId}:${sessionId}`, {
4396
+ nodeId,
4397
+ sessionId,
4398
+ providerType,
4399
+ expiresAt: Date.now() + REMOTE_IDLE_SESSION_TTL_MS
4400
+ });
4401
+ setImmediate(() => {
4297
4402
  const assigned = tryAssignQueueTask(components, args.meshId, nodeId, sessionId, providerType);
4298
- if (assigned) {
4299
- remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
4300
- }
4301
- }, 500);
4403
+ if (assigned) remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
4404
+ });
4302
4405
  }
4303
4406
  } else if (args.event === "agent:generating_started") {
4304
4407
  const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
@@ -4501,19 +4604,20 @@ function setupMeshEventForwarding(components) {
4501
4604
  });
4502
4605
  });
4503
4606
  }
4504
- var remoteIdleSessions, MAX_PENDING_EVENTS, pendingMeshCoordinatorEvents, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS;
4607
+ var import_fs6, import_path5, REMOTE_IDLE_SESSION_TTL_MS, remoteIdleSessions, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS;
4505
4608
  var init_mesh_events = __esm({
4506
4609
  "../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
4507
4610
  "use strict";
4611
+ import_fs6 = require("fs");
4612
+ import_path5 = require("path");
4508
4613
  init_config();
4509
4614
  init_mesh_config();
4510
4615
  init_cli_detector();
4511
4616
  init_logger();
4512
4617
  init_mesh_ledger();
4513
4618
  init_mesh_work_queue();
4619
+ REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
4514
4620
  remoteIdleSessions = /* @__PURE__ */ new Map();
4515
- MAX_PENDING_EVENTS = 50;
4516
- pendingMeshCoordinatorEvents = [];
4517
4621
  MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
4518
4622
  "agent:generating_started",
4519
4623
  "agent:generating_completed",
@@ -4656,7 +4760,7 @@ function isPlainObject2(value) {
4656
4760
  return !!value && typeof value === "object" && !Array.isArray(value);
4657
4761
  }
4658
4762
  function getStatePath() {
4659
- return (0, import_path5.join)(getConfigDir(), "state.json");
4763
+ return (0, import_path6.join)(getConfigDir(), "state.json");
4660
4764
  }
4661
4765
  function normalizeState(raw) {
4662
4766
  const parsed = isPlainObject2(raw) ? raw : {};
@@ -4692,11 +4796,11 @@ function normalizeState(raw) {
4692
4796
  }
4693
4797
  function loadState() {
4694
4798
  const statePath = getStatePath();
4695
- if (!(0, import_fs6.existsSync)(statePath)) {
4799
+ if (!(0, import_fs7.existsSync)(statePath)) {
4696
4800
  return { ...DEFAULT_STATE };
4697
4801
  }
4698
4802
  try {
4699
- const raw = (0, import_fs6.readFileSync)(statePath, "utf-8");
4803
+ const raw = (0, import_fs7.readFileSync)(statePath, "utf-8");
4700
4804
  return normalizeState(JSON.parse(raw));
4701
4805
  } catch {
4702
4806
  return { ...DEFAULT_STATE };
@@ -4705,17 +4809,17 @@ function loadState() {
4705
4809
  function saveState(state) {
4706
4810
  const statePath = getStatePath();
4707
4811
  const normalized = normalizeState(state);
4708
- (0, import_fs6.writeFileSync)(statePath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
4812
+ (0, import_fs7.writeFileSync)(statePath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
4709
4813
  }
4710
4814
  function resetState() {
4711
4815
  saveState({ ...DEFAULT_STATE });
4712
4816
  }
4713
- var import_fs6, import_path5, DEFAULT_STATE;
4817
+ var import_fs7, import_path6, DEFAULT_STATE;
4714
4818
  var init_state_store = __esm({
4715
4819
  "../../oss/packages/daemon-core/src/config/state-store.ts"() {
4716
4820
  "use strict";
4717
- import_fs6 = require("fs");
4718
- import_path5 = require("path");
4821
+ import_fs7 = require("fs");
4822
+ import_path6 = require("path");
4719
4823
  init_config();
4720
4824
  DEFAULT_STATE = {
4721
4825
  recentActivity: [],
@@ -4748,7 +4852,7 @@ function findCliCommand(command) {
4748
4852
  if (path10.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
4749
4853
  const candidate = trimmed.startsWith("~") ? path10.join((0, import_os2.homedir)(), trimmed.slice(1)) : trimmed;
4750
4854
  const resolved = path10.isAbsolute(candidate) ? candidate : path10.resolve(candidate);
4751
- return (0, import_fs7.existsSync)(resolved) ? resolved : null;
4855
+ return (0, import_fs8.existsSync)(resolved) ? resolved : null;
4752
4856
  }
4753
4857
  try {
4754
4858
  const result = (0, import_child_process2.execSync)(
@@ -4779,9 +4883,9 @@ function checkPathExists(paths) {
4779
4883
  if (normalized.includes("*")) {
4780
4884
  const username = home.split(/[\\/]/).pop() || "";
4781
4885
  const resolved = normalized.replace("*", username);
4782
- if ((0, import_fs7.existsSync)(resolved)) return resolved;
4886
+ if ((0, import_fs8.existsSync)(resolved)) return resolved;
4783
4887
  } else {
4784
- if ((0, import_fs7.existsSync)(normalized)) return normalized;
4888
+ if ((0, import_fs8.existsSync)(normalized)) return normalized;
4785
4889
  }
4786
4890
  }
4787
4891
  return null;
@@ -4795,7 +4899,7 @@ async function detectIDEs(providerLoader) {
4795
4899
  let resolvedCli = cliPath;
4796
4900
  if (!resolvedCli && appPath && os30 === "darwin") {
4797
4901
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
4798
- if ((0, import_fs7.existsSync)(bundledCli)) resolvedCli = bundledCli;
4902
+ if ((0, import_fs8.existsSync)(bundledCli)) resolvedCli = bundledCli;
4799
4903
  }
4800
4904
  if (!resolvedCli && appPath && os30 === "win32") {
4801
4905
  const { dirname: dirname12 } = await import("path");
@@ -4808,7 +4912,7 @@ async function detectIDEs(providerLoader) {
4808
4912
  `${appDir}\\\\resources\\\\app\\\\bin\\\\${def.cli}.cmd`
4809
4913
  ];
4810
4914
  for (const c of candidates) {
4811
- if ((0, import_fs7.existsSync)(c)) {
4915
+ if ((0, import_fs8.existsSync)(c)) {
4812
4916
  resolvedCli = c;
4813
4917
  break;
4814
4918
  }
@@ -4829,12 +4933,12 @@ async function detectIDEs(providerLoader) {
4829
4933
  }
4830
4934
  return results;
4831
4935
  }
4832
- var import_child_process2, import_fs7, import_os2, path10, BUILTIN_IDE_DEFINITIONS, registeredIDEs;
4936
+ var import_child_process2, import_fs8, import_os2, path10, BUILTIN_IDE_DEFINITIONS, registeredIDEs;
4833
4937
  var init_ide_detector = __esm({
4834
4938
  "../../oss/packages/daemon-core/src/detection/ide-detector.ts"() {
4835
4939
  "use strict";
4836
4940
  import_child_process2 = require("child_process");
4837
- import_fs7 = require("fs");
4941
+ import_fs8 = require("fs");
4838
4942
  import_os2 = require("os");
4839
4943
  path10 = __toESM(require("path"));
4840
4944
  BUILTIN_IDE_DEFINITIONS = [];
@@ -36814,7 +36918,7 @@ function commandExists(command) {
36814
36918
  const trimmed = command.trim();
36815
36919
  if (!trimmed) return false;
36816
36920
  if (isExplicitCommand(trimmed)) {
36817
- return (0, import_fs8.existsSync)(expandExecutable(trimmed));
36921
+ return (0, import_fs9.existsSync)(expandExecutable(trimmed));
36818
36922
  }
36819
36923
  try {
36820
36924
  (0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
@@ -36835,10 +36939,10 @@ function hasCliArg(args, flag) {
36835
36939
  }
36836
36940
  function ensureEmptyDelegatedMcpConfig(workspace) {
36837
36941
  const baseDir = path18.join(os15.tmpdir(), "adhdev-delegated-agent-empty-mcp");
36838
- (0, import_fs8.mkdirSync)(baseDir, { recursive: true });
36942
+ (0, import_fs9.mkdirSync)(baseDir, { recursive: true });
36839
36943
  const workspaceHash = crypto4.createHash("sha256").update(path18.resolve(workspace || os15.tmpdir())).digest("hex").slice(0, 16);
36840
36944
  const filePath = path18.join(baseDir, `${workspaceHash}.json`);
36841
- (0, import_fs8.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
36945
+ (0, import_fs9.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
36842
36946
  return filePath;
36843
36947
  }
36844
36948
  function buildCoordinatorDelegatedCliLaunchOptions(input) {
@@ -36965,14 +37069,14 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
36965
37069
  launchMode: "new"
36966
37070
  };
36967
37071
  }
36968
- var os15, path18, crypto4, import_fs8, import_child_process6, chalkModule, chalkApi, COORDINATOR_DELEGATED_ENV_UNSETS, DaemonCliManager;
37072
+ var os15, path18, crypto4, import_fs9, import_child_process6, chalkModule, chalkApi, COORDINATOR_DELEGATED_ENV_UNSETS, DaemonCliManager;
36969
37073
  var init_cli_manager = __esm({
36970
37074
  "../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
36971
37075
  "use strict";
36972
37076
  os15 = __toESM(require("os"));
36973
37077
  path18 = __toESM(require("path"));
36974
37078
  crypto4 = __toESM(require("crypto"));
36975
- import_fs8 = require("fs");
37079
+ import_fs9 = require("fs");
36976
37080
  import_child_process6 = require("child_process");
36977
37081
  init_source();
36978
37082
  init_provider_cli_adapter();
@@ -37886,7 +37990,7 @@ function createFsWatchInstance(path35, options, listener, errHandler, emitRaw) {
37886
37990
  }
37887
37991
  };
37888
37992
  try {
37889
- return (0, import_fs9.watch)(path35, {
37993
+ return (0, import_fs10.watch)(path35, {
37890
37994
  persistent: options.persistent
37891
37995
  }, handleEvent);
37892
37996
  } catch (error48) {
@@ -37894,11 +37998,11 @@ function createFsWatchInstance(path35, options, listener, errHandler, emitRaw) {
37894
37998
  return void 0;
37895
37999
  }
37896
38000
  }
37897
- var import_fs9, import_promises5, sysPath, import_os3, STR_DATA, STR_END, STR_CLOSE, EMPTY_FN, pl, isWindows, isMacos, isLinux, isFreeBSD, isIBMi, EVENTS, EV, THROTTLE_MODE_WATCH, statMethods, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, binaryExtensions, isBinaryPath, foreach, addAndConvert, clearItem, delFromSet, isEmptySet, FsWatchInstances, fsWatchBroadcast, setFsWatchListener, FsWatchFileInstances, setFsWatchFileListener, NodeFsHandler;
38001
+ var import_fs10, import_promises5, sysPath, import_os3, STR_DATA, STR_END, STR_CLOSE, EMPTY_FN, pl, isWindows, isMacos, isLinux, isFreeBSD, isIBMi, EVENTS, EV, THROTTLE_MODE_WATCH, statMethods, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, binaryExtensions, isBinaryPath, foreach, addAndConvert, clearItem, delFromSet, isEmptySet, FsWatchInstances, fsWatchBroadcast, setFsWatchListener, FsWatchFileInstances, setFsWatchFileListener, NodeFsHandler;
37898
38002
  var init_handler2 = __esm({
37899
38003
  "../../oss/node_modules/chokidar/esm/handler.js"() {
37900
38004
  "use strict";
37901
- import_fs9 = require("fs");
38005
+ import_fs10 = require("fs");
37902
38006
  import_promises5 = require("fs/promises");
37903
38007
  sysPath = __toESM(require("path"), 1);
37904
38008
  import_os3 = require("os");
@@ -38302,7 +38406,7 @@ var init_handler2 = __esm({
38302
38406
  let cont = FsWatchFileInstances.get(fullPath);
38303
38407
  const copts = cont && cont.options;
38304
38408
  if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
38305
- (0, import_fs9.unwatchFile)(fullPath);
38409
+ (0, import_fs10.unwatchFile)(fullPath);
38306
38410
  cont = void 0;
38307
38411
  }
38308
38412
  if (cont) {
@@ -38313,7 +38417,7 @@ var init_handler2 = __esm({
38313
38417
  listeners: listener,
38314
38418
  rawEmitters: rawEmitter,
38315
38419
  options,
38316
- watcher: (0, import_fs9.watchFile)(fullPath, options, (curr, prev) => {
38420
+ watcher: (0, import_fs10.watchFile)(fullPath, options, (curr, prev) => {
38317
38421
  foreach(cont.rawEmitters, (rawEmitter2) => {
38318
38422
  rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
38319
38423
  });
@@ -38330,7 +38434,7 @@ var init_handler2 = __esm({
38330
38434
  delFromSet(cont, KEY_RAW, rawEmitter);
38331
38435
  if (isEmptySet(cont.listeners)) {
38332
38436
  FsWatchFileInstances.delete(fullPath);
38333
- (0, import_fs9.unwatchFile)(fullPath);
38437
+ (0, import_fs10.unwatchFile)(fullPath);
38334
38438
  cont.options = cont.watcher = void 0;
38335
38439
  Object.freeze(cont);
38336
38440
  }
@@ -38708,11 +38812,11 @@ function watch(paths, options = {}) {
38708
38812
  watcher.add(paths);
38709
38813
  return watcher;
38710
38814
  }
38711
- var import_fs10, import_promises6, import_events2, sysPath2, SLASH, SLASH_SLASH, ONE_DOT, TWO_DOTS, STRING_TYPE, BACK_SLASH_RE, DOUBLE_SLASH_RE, DOT_RE, REPLACER_RE, isMatcherObject, unifyPaths, toUnix, normalizePathToUnix, normalizeIgnored, getAbsolutePath, EMPTY_SET, DirEntry, STAT_METHOD_F, STAT_METHOD_L, WatchHelper, FSWatcher;
38815
+ var import_fs11, import_promises6, import_events2, sysPath2, SLASH, SLASH_SLASH, ONE_DOT, TWO_DOTS, STRING_TYPE, BACK_SLASH_RE, DOUBLE_SLASH_RE, DOT_RE, REPLACER_RE, isMatcherObject, unifyPaths, toUnix, normalizePathToUnix, normalizeIgnored, getAbsolutePath, EMPTY_SET, DirEntry, STAT_METHOD_F, STAT_METHOD_L, WatchHelper, FSWatcher;
38712
38816
  var init_esm2 = __esm({
38713
38817
  "../../oss/node_modules/chokidar/esm/index.js"() {
38714
38818
  "use strict";
38715
- import_fs10 = require("fs");
38819
+ import_fs11 = require("fs");
38716
38820
  import_promises6 = require("fs/promises");
38717
38821
  import_events2 = require("events");
38718
38822
  sysPath2 = __toESM(require("path"), 1);
@@ -39190,7 +39294,7 @@ var init_esm2 = __esm({
39190
39294
  const now = /* @__PURE__ */ new Date();
39191
39295
  const writes = this._pendingWrites;
39192
39296
  function awaitWriteFinishFn(prevStat) {
39193
- (0, import_fs10.stat)(fullPath, (err, curStat) => {
39297
+ (0, import_fs11.stat)(fullPath, (err, curStat) => {
39194
39298
  if (err || !writes.has(path35)) {
39195
39299
  if (err && err.code !== "ENOENT")
39196
39300
  awfEmit(err);
@@ -45766,8 +45870,21 @@ function summarizeMeshSessionRecord(record2) {
45766
45870
  isCached: false
45767
45871
  };
45768
45872
  }
45873
+ function liveSessionRecordMatchesMeshNode(record2, meshId, nodeId) {
45874
+ const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
45875
+ if (!recordNodeId || recordNodeId !== nodeId) return false;
45876
+ const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
45877
+ return !recordMeshId || recordMeshId === meshId;
45878
+ }
45879
+ function liveSessionRecordMatchesMeshWorkspace(record2, meshId, workspace) {
45880
+ const recordWorkspace = readStringValue(record2?.workspace);
45881
+ if (!recordWorkspace || !workspace || recordWorkspace !== workspace) return false;
45882
+ const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
45883
+ if (recordMeshId) return recordMeshId === meshId;
45884
+ return record2?.meta?.launchedByCoordinator === true || !!readStringValue(record2?.meta?.meshNodeId);
45885
+ }
45769
45886
  function readLiveMeshNodeWorkspace(args) {
45770
- const directNodeWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshNodeId) === args.nodeId && readStringValue(record2?.workspace));
45887
+ const directNodeWorkspace = args.liveSessionRecords.find((record2) => liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId) && readStringValue(record2?.workspace));
45771
45888
  if (directNodeWorkspace) {
45772
45889
  return readStringValue(directNodeWorkspace.workspace) || "";
45773
45890
  }
@@ -45781,10 +45898,9 @@ function readLiveMeshNodeWorkspace(args) {
45781
45898
  }
45782
45899
  function collectLiveMeshSessionRecords(args) {
45783
45900
  const matches = args.liveSessionRecords.filter((record2) => {
45784
- if (readStringValue(record2?.meta?.meshNodeId) === args.nodeId) return true;
45785
- const recordWorkspace = readStringValue(record2?.workspace);
45786
45901
  const nodeWorkspace = readStringValue(args.node?.workspace);
45787
- return !!recordWorkspace && !!nodeWorkspace && recordWorkspace === nodeWorkspace;
45902
+ if (liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId)) return true;
45903
+ return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record2, args.meshId, nodeWorkspace);
45788
45904
  });
45789
45905
  if (args.allowCoordinatorSession) {
45790
45906
  for (const record2 of args.liveSessionRecords) {
@@ -45855,7 +45971,7 @@ function truncateValidationOutput(value) {
45855
45971
  }
45856
45972
  function readPackageScripts(workspace) {
45857
45973
  try {
45858
- const packageJsonPath = (0, import_path6.join)(workspace, "package.json");
45974
+ const packageJsonPath = (0, import_path7.join)(workspace, "package.json");
45859
45975
  const parsed = JSON.parse(fs10.readFileSync(packageJsonPath, "utf-8"));
45860
45976
  return parsed?.scripts && typeof parsed.scripts === "object" && !Array.isArray(parsed.scripts) ? parsed.scripts : {};
45861
45977
  } catch {
@@ -46063,13 +46179,13 @@ function serializeMeshCoordinatorMcpConfig(config2, format) {
46063
46179
  }
46064
46180
  function resolveHermesUserHome() {
46065
46181
  const explicitHome = process.env.HERMES_HOME?.trim();
46066
- return explicitHome || (0, import_path6.join)((0, import_os4.homedir)(), ".hermes");
46182
+ return explicitHome || (0, import_path7.join)((0, import_os4.homedir)(), ".hermes");
46067
46183
  }
46068
46184
  function loadHermesCoordinatorBaseConfig(targetConfigPath) {
46069
46185
  const sourceHome = resolveHermesUserHome();
46070
- const sourceConfigPath = (0, import_path6.join)(sourceHome, "config.yaml");
46186
+ const sourceConfigPath = (0, import_path7.join)(sourceHome, "config.yaml");
46071
46187
  if (!fs10.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
46072
- if ((0, import_path6.resolve)(sourceConfigPath) === (0, import_path6.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
46188
+ if ((0, import_path7.resolve)(sourceConfigPath) === (0, import_path7.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
46073
46189
  const parsed = parseMeshCoordinatorMcpConfig(fs10.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
46074
46190
  const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
46075
46191
  return { config: baseConfig, sourceHome, sourceConfigPath };
@@ -46103,10 +46219,10 @@ function stripHermesCoordinatorTempModelProviderOverrides(config2) {
46103
46219
  return sanitized;
46104
46220
  }
46105
46221
  function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
46106
- if ((0, import_path6.resolve)(sourceHome) === (0, import_path6.resolve)(targetHome)) return;
46222
+ if ((0, import_path7.resolve)(sourceHome) === (0, import_path7.resolve)(targetHome)) return;
46107
46223
  for (const fileName of [".env", "auth.json"]) {
46108
- const sourcePath = (0, import_path6.join)(sourceHome, fileName);
46109
- const targetPath = (0, import_path6.join)(targetHome, fileName);
46224
+ const sourcePath = (0, import_path7.join)(sourceHome, fileName);
46225
+ const targetPath = (0, import_path7.join)(targetHome, fileName);
46110
46226
  if (!fs10.existsSync(sourcePath)) continue;
46111
46227
  try {
46112
46228
  fs10.copyFileSync(sourcePath, targetPath);
@@ -46196,7 +46312,7 @@ function summarizeSessionHostPruneResult(result) {
46196
46312
  keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
46197
46313
  };
46198
46314
  }
46199
- var import_os4, import_path6, fs10, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, REFINE_VALIDATION_CATEGORIES, REFINE_VALIDATION_TIMEOUT_MS, REFINE_VALIDATION_OUTPUT_LIMIT_BYTES, REFINE_VALIDATION_SUMMARY_CHARS, REFINE_VALIDATION_MAX_COMMANDS, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
46315
+ var import_os4, import_path7, fs10, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, REFINE_VALIDATION_CATEGORIES, REFINE_VALIDATION_TIMEOUT_MS, REFINE_VALIDATION_OUTPUT_LIMIT_BYTES, REFINE_VALIDATION_SUMMARY_CHARS, REFINE_VALIDATION_MAX_COMMANDS, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
46200
46316
  var init_router = __esm({
46201
46317
  "../../oss/packages/daemon-core/src/commands/router.ts"() {
46202
46318
  "use strict";
@@ -46226,7 +46342,7 @@ var init_router = __esm({
46226
46342
  init_snapshot();
46227
46343
  init_upgrade_helper();
46228
46344
  import_os4 = require("os");
46229
- import_path6 = require("path");
46345
+ import_path7 = require("path");
46230
46346
  fs10 = __toESM(require("fs"));
46231
46347
  CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
46232
46348
  CHANNEL_SERVER_URL = {
@@ -46355,7 +46471,7 @@ var init_router = __esm({
46355
46471
  }
46356
46472
  const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
46357
46473
  const normalizePath2 = (value) => {
46358
- const resolved = (0, import_path6.resolve)(value);
46474
+ const resolved = (0, import_path7.resolve)(value);
46359
46475
  try {
46360
46476
  return fs10.realpathSync(resolved);
46361
46477
  } catch {
@@ -46756,7 +46872,8 @@ var init_router = __esm({
46756
46872
  return handleMeshForwardEvent({ instanceManager: this.deps.instanceManager }, args);
46757
46873
  }
46758
46874
  case "get_pending_mesh_events": {
46759
- const events = drainPendingMeshCoordinatorEvents();
46875
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
46876
+ const events = drainPendingMeshCoordinatorEvents(meshId || void 0);
46760
46877
  return { success: true, events };
46761
46878
  }
46762
46879
  case "launch_cli":
@@ -47977,7 +48094,7 @@ ${block}`);
47977
48094
  workspace
47978
48095
  };
47979
48096
  }
47980
- const { existsSync: existsSync29, readFileSync: readFileSync22, writeFileSync: writeFileSync17, copyFileSync: copyFileSync5, mkdirSync: mkdirSync21 } = await import("fs");
48097
+ const { existsSync: existsSync30, readFileSync: readFileSync23, writeFileSync: writeFileSync17, copyFileSync: copyFileSync5, mkdirSync: mkdirSync21 } = await import("fs");
47981
48098
  const { dirname: dirname12 } = await import("path");
47982
48099
  const mcpConfigPath = coordinatorSetup.configPath;
47983
48100
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -48020,14 +48137,14 @@ ${block}`);
48020
48137
  if (hermesManualFallback) return returnManualFallback(message);
48021
48138
  return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
48022
48139
  }
48023
- const hadExistingMcpConfig = existsSync29(mcpConfigPath);
48140
+ const hadExistingMcpConfig = existsSync30(mcpConfigPath);
48024
48141
  let existingMcpConfig = hermesBaseConfig?.config || {};
48025
48142
  if (hermesBaseConfig) {
48026
48143
  copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname12(mcpConfigPath));
48027
48144
  }
48028
48145
  if (hadExistingMcpConfig) {
48029
48146
  try {
48030
- const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync22(mcpConfigPath, "utf-8"), configFormat);
48147
+ const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync23(mcpConfigPath, "utf-8"), configFormat);
48031
48148
  const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
48032
48149
  existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
48033
48150
  copyFileSync5(mcpConfigPath, mcpConfigPath + ".backup");
@@ -48215,29 +48332,48 @@ ${block}`);
48215
48332
  }
48216
48333
  if (workspace) {
48217
48334
  if (!fs10.existsSync(workspace)) {
48218
- if (applyCachedInlineMeshNodeStatus(status, node)) {
48219
- status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48220
- nodeStatuses.push(status);
48221
- continue;
48222
- }
48223
- if (meshRecord?.source === "inline_cache" && !isSelfNode) {
48224
- status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48225
- nodeStatuses.push(status);
48226
- continue;
48335
+ let remoteProbeApplied = false;
48336
+ if (!isSelfNode && daemonId && this.deps.dispatchMeshCommand) {
48337
+ try {
48338
+ const remoteResult = await Promise.race([
48339
+ this.deps.dispatchMeshCommand(daemonId, "git_status", { workspace }),
48340
+ new Promise((_2, reject) => setTimeout(() => reject(new Error("timeout")), 8e3))
48341
+ ]);
48342
+ const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
48343
+ if (remoteGit && typeof remoteGit === "object" && typeof remoteGit.isGitRepo === "boolean") {
48344
+ status.git = remoteGit;
48345
+ status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
48346
+ remoteProbeApplied = true;
48347
+ }
48348
+ } catch {
48349
+ }
48227
48350
  }
48228
- }
48229
- try {
48230
- const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
48231
- status.git = gitStatus;
48232
- if (gitStatus.isGitRepo) {
48233
- status.health = deriveMeshNodeHealthFromGit(gitStatus);
48234
- } else {
48235
- status.health = "degraded";
48236
- if (gitStatus.error && !status.error) status.error = gitStatus.error;
48351
+ if (!remoteProbeApplied) {
48352
+ if (applyCachedInlineMeshNodeStatus(status, node)) {
48353
+ status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48354
+ nodeStatuses.push(status);
48355
+ continue;
48356
+ }
48357
+ if (meshRecord?.source === "inline_cache" && !isSelfNode) {
48358
+ status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48359
+ nodeStatuses.push(status);
48360
+ continue;
48361
+ }
48237
48362
  }
48238
- } catch {
48239
- if (!applyCachedInlineMeshNodeStatus(status, node)) {
48240
- status.health = "degraded";
48363
+ } else {
48364
+ try {
48365
+ const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
48366
+ status.git = gitStatus;
48367
+ if (gitStatus.isGitRepo) {
48368
+ status.health = deriveMeshNodeHealthFromGit(gitStatus);
48369
+ } else {
48370
+ status.health = "degraded";
48371
+ if (gitStatus.error && !status.error) status.error = gitStatus.error;
48372
+ }
48373
+ } catch {
48374
+ if (!applyCachedInlineMeshNodeStatus(status, node)) {
48375
+ status.health = "degraded";
48376
+ }
48241
48377
  }
48242
48378
  }
48243
48379
  } else {
@@ -58682,7 +58818,7 @@ var require_filesystem = __commonJS({
58682
58818
  var LDD_PATH = "/usr/bin/ldd";
58683
58819
  var SELF_PATH = "/proc/self/exe";
58684
58820
  var MAX_LENGTH = 2048;
58685
- var readFileSync22 = (path35) => {
58821
+ var readFileSync23 = (path35) => {
58686
58822
  const fd = fs20.openSync(path35, "r");
58687
58823
  const buffer = Buffer.alloc(MAX_LENGTH);
58688
58824
  const bytesRead = fs20.readSync(fd, buffer, 0, MAX_LENGTH, 0);
@@ -58707,7 +58843,7 @@ var require_filesystem = __commonJS({
58707
58843
  module2.exports = {
58708
58844
  LDD_PATH,
58709
58845
  SELF_PATH,
58710
- readFileSync: readFileSync22,
58846
+ readFileSync: readFileSync23,
58711
58847
  readFile: readFile2
58712
58848
  };
58713
58849
  }
@@ -58756,7 +58892,7 @@ var require_detect_libc = __commonJS({
58756
58892
  "use strict";
58757
58893
  var childProcess = require("child_process");
58758
58894
  var { isLinux: isLinux2, getReport } = require_process();
58759
- var { LDD_PATH, SELF_PATH, readFile: readFile2, readFileSync: readFileSync22 } = require_filesystem();
58895
+ var { LDD_PATH, SELF_PATH, readFile: readFile2, readFileSync: readFileSync23 } = require_filesystem();
58760
58896
  var { interpreterPath } = require_elf();
58761
58897
  var cachedFamilyInterpreter;
58762
58898
  var cachedFamilyFilesystem;
@@ -58848,7 +58984,7 @@ var require_detect_libc = __commonJS({
58848
58984
  }
58849
58985
  cachedFamilyFilesystem = null;
58850
58986
  try {
58851
- const lddContent = readFileSync22(LDD_PATH);
58987
+ const lddContent = readFileSync23(LDD_PATH);
58852
58988
  cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
58853
58989
  } catch (e) {
58854
58990
  }
@@ -58873,7 +59009,7 @@ var require_detect_libc = __commonJS({
58873
59009
  }
58874
59010
  cachedFamilyInterpreter = null;
58875
59011
  try {
58876
- const selfContent = readFileSync22(SELF_PATH);
59012
+ const selfContent = readFileSync23(SELF_PATH);
58877
59013
  const path35 = interpreterPath(selfContent);
58878
59014
  cachedFamilyInterpreter = familyFromInterpreterPath(path35);
58879
59015
  } catch (e) {
@@ -58937,7 +59073,7 @@ var require_detect_libc = __commonJS({
58937
59073
  }
58938
59074
  cachedVersionFilesystem = null;
58939
59075
  try {
58940
- const lddContent = readFileSync22(LDD_PATH);
59076
+ const lddContent = readFileSync23(LDD_PATH);
58941
59077
  const versionMatch = lddContent.match(RE_GLIBC_VERSION);
58942
59078
  if (versionMatch) {
58943
59079
  cachedVersionFilesystem = versionMatch[1];
@@ -66379,25 +66515,25 @@ function resolvePackageVersion(options) {
66379
66515
  const injectedVersion = options?.injectedVersion || "unknown";
66380
66516
  const dir = options?.dirname || __dirname;
66381
66517
  const possiblePaths = [
66382
- (0, import_path7.join)(dir, "..", "..", "package.json"),
66383
- (0, import_path7.join)(dir, "..", "package.json"),
66384
- (0, import_path7.join)(dir, "package.json")
66518
+ (0, import_path8.join)(dir, "..", "..", "package.json"),
66519
+ (0, import_path8.join)(dir, "..", "package.json"),
66520
+ (0, import_path8.join)(dir, "package.json")
66385
66521
  ];
66386
66522
  for (const p of possiblePaths) {
66387
66523
  try {
66388
- const data = JSON.parse((0, import_fs11.readFileSync)(p, "utf-8"));
66524
+ const data = JSON.parse((0, import_fs12.readFileSync)(p, "utf-8"));
66389
66525
  if (data.version) return data.version;
66390
66526
  } catch {
66391
66527
  }
66392
66528
  }
66393
66529
  return injectedVersion;
66394
66530
  }
66395
- var import_fs11, import_path7;
66531
+ var import_fs12, import_path8;
66396
66532
  var init_version = __esm({
66397
66533
  "src/version.ts"() {
66398
66534
  "use strict";
66399
- import_fs11 = require("fs");
66400
- import_path7 = require("path");
66535
+ import_fs12 = require("fs");
66536
+ import_path8 = require("path");
66401
66537
  }
66402
66538
  });
66403
66539
 
@@ -67101,7 +67237,7 @@ var init_adhdev_daemon = __esm({
67101
67237
  init_version();
67102
67238
  init_src();
67103
67239
  init_runtime_defaults();
67104
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.22" });
67240
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.24" });
67105
67241
  AdhdevDaemon = class _AdhdevDaemon {
67106
67242
  localHttpServer = null;
67107
67243
  localWss = null;
@@ -83081,7 +83217,7 @@ var require_buffer_list = __commonJS({
83081
83217
  }
83082
83218
  }, {
83083
83219
  key: "join",
83084
- value: function join36(s) {
83220
+ value: function join37(s) {
83085
83221
  if (this.length === 0) return "";
83086
83222
  var p = this.head;
83087
83223
  var ret = "" + p.data;
@@ -97140,13 +97276,13 @@ function splitStringBySpace(str2) {
97140
97276
  }
97141
97277
  return pieces;
97142
97278
  }
97143
- var import_chardet, import_child_process14, import_fs12, import_node_path3, import_node_os3, import_node_crypto3, import_iconv_lite, ExternalEditor;
97279
+ var import_chardet, import_child_process14, import_fs13, import_node_path3, import_node_os3, import_node_crypto3, import_iconv_lite, ExternalEditor;
97144
97280
  var init_esm4 = __esm({
97145
97281
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
97146
97282
  "use strict";
97147
97283
  import_chardet = __toESM(require_lib2(), 1);
97148
97284
  import_child_process14 = require("child_process");
97149
- import_fs12 = require("fs");
97285
+ import_fs13 = require("fs");
97150
97286
  import_node_path3 = __toESM(require("path"), 1);
97151
97287
  import_node_os3 = __toESM(require("os"), 1);
97152
97288
  import_node_crypto3 = require("crypto");
@@ -97222,14 +97358,14 @@ var init_esm4 = __esm({
97222
97358
  if (Object.prototype.hasOwnProperty.call(this.fileOptions, "mode")) {
97223
97359
  opt.mode = this.fileOptions.mode;
97224
97360
  }
97225
- (0, import_fs12.writeFileSync)(this.tempFile, this.text, opt);
97361
+ (0, import_fs13.writeFileSync)(this.tempFile, this.text, opt);
97226
97362
  } catch (createFileError) {
97227
97363
  throw new CreateFileError(createFileError);
97228
97364
  }
97229
97365
  }
97230
97366
  readTemporaryFile() {
97231
97367
  try {
97232
- const tempFileBuffer = (0, import_fs12.readFileSync)(this.tempFile);
97368
+ const tempFileBuffer = (0, import_fs13.readFileSync)(this.tempFile);
97233
97369
  if (tempFileBuffer.length === 0) {
97234
97370
  this.text = "";
97235
97371
  } else {
@@ -97245,7 +97381,7 @@ var init_esm4 = __esm({
97245
97381
  }
97246
97382
  removeTemporaryFile() {
97247
97383
  try {
97248
- (0, import_fs12.unlinkSync)(this.tempFile);
97384
+ (0, import_fs13.unlinkSync)(this.tempFile);
97249
97385
  } catch (removeFileError) {
97250
97386
  throw new RemoveFileError(removeFileError);
97251
97387
  }