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/cli/index.js +342 -206
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +342 -206
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/vendor/mcp-server/index.js +5 -5
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3810,6 +3810,36 @@ function getQueuePath(meshId) {
|
|
|
3810
3810
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3811
3811
|
return (0, import_path4.join)(getLedgerDir(), `${safe}.queue.json`);
|
|
3812
3812
|
}
|
|
3813
|
+
function getLockPath(meshId) {
|
|
3814
|
+
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3815
|
+
return (0, import_path4.join)(getLedgerDir(), `${safe}.queue.lock`);
|
|
3816
|
+
}
|
|
3817
|
+
function withQueueLock(meshId, fn) {
|
|
3818
|
+
const lockPath = getLockPath(meshId);
|
|
3819
|
+
let fd = -1;
|
|
3820
|
+
for (let i = 0; i < 10; i++) {
|
|
3821
|
+
try {
|
|
3822
|
+
fd = (0, import_fs4.openSync)(lockPath, "wx");
|
|
3823
|
+
break;
|
|
3824
|
+
} catch {
|
|
3825
|
+
const deadline = Date.now() + 30;
|
|
3826
|
+
while (Date.now() < deadline) {
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
try {
|
|
3831
|
+
return fn();
|
|
3832
|
+
} finally {
|
|
3833
|
+
if (fd !== -1) try {
|
|
3834
|
+
(0, import_fs4.closeSync)(fd);
|
|
3835
|
+
} catch {
|
|
3836
|
+
}
|
|
3837
|
+
try {
|
|
3838
|
+
(0, import_fs4.unlinkSync)(lockPath);
|
|
3839
|
+
} catch {
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3813
3843
|
function readQueue(meshId) {
|
|
3814
3844
|
const path42 = getQueuePath(meshId);
|
|
3815
3845
|
if (!(0, import_fs4.existsSync)(path42)) return [];
|
|
@@ -3825,20 +3855,22 @@ function writeQueue(meshId, queue) {
|
|
|
3825
3855
|
(0, import_fs4.writeFileSync)(path42, JSON.stringify(queue, null, 2), "utf-8");
|
|
3826
3856
|
}
|
|
3827
3857
|
function enqueueTask(meshId, message, opts) {
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3858
|
+
return withQueueLock(meshId, () => {
|
|
3859
|
+
const queue = readQueue(meshId);
|
|
3860
|
+
const entry = {
|
|
3861
|
+
id: (0, import_crypto5.randomUUID)(),
|
|
3862
|
+
meshId,
|
|
3863
|
+
message,
|
|
3864
|
+
status: "pending",
|
|
3865
|
+
targetNodeId: opts?.targetNodeId,
|
|
3866
|
+
targetSessionId: opts?.targetSessionId,
|
|
3867
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3868
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3869
|
+
};
|
|
3870
|
+
queue.push(entry);
|
|
3871
|
+
writeQueue(meshId, queue);
|
|
3872
|
+
return entry;
|
|
3873
|
+
});
|
|
3842
3874
|
}
|
|
3843
3875
|
function getQueue(meshId, opts) {
|
|
3844
3876
|
let queue = readQueue(meshId);
|
|
@@ -3849,100 +3881,109 @@ function getQueue(meshId, opts) {
|
|
|
3849
3881
|
return queue;
|
|
3850
3882
|
}
|
|
3851
3883
|
function claimNextTask(meshId, nodeId, sessionId) {
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3884
|
+
return withQueueLock(meshId, () => {
|
|
3885
|
+
const queue = readQueue(meshId);
|
|
3886
|
+
const hasActiveAssignment = queue.some((q) => q.status === "assigned" && (q.assignedSessionId === sessionId || q.assignedNodeId === nodeId));
|
|
3887
|
+
if (hasActiveAssignment) return null;
|
|
3888
|
+
let targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetSessionId === sessionId);
|
|
3889
|
+
if (targetIdx === -1) {
|
|
3890
|
+
targetIdx = queue.findIndex((q) => q.status === "pending" && q.targetNodeId === nodeId && !q.targetSessionId);
|
|
3891
|
+
}
|
|
3892
|
+
if (targetIdx === -1) {
|
|
3893
|
+
targetIdx = queue.findIndex((q) => q.status === "pending" && !q.targetNodeId && !q.targetSessionId);
|
|
3894
|
+
}
|
|
3895
|
+
if (targetIdx === -1) return null;
|
|
3896
|
+
const entry = queue[targetIdx];
|
|
3897
|
+
entry.status = "assigned";
|
|
3898
|
+
entry.assignedNodeId = nodeId;
|
|
3899
|
+
entry.assignedSessionId = sessionId;
|
|
3900
|
+
entry.dispatchTimestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3901
|
+
entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3902
|
+
writeQueue(meshId, queue);
|
|
3903
|
+
return entry;
|
|
3904
|
+
});
|
|
3871
3905
|
}
|
|
3872
3906
|
function updateTaskStatus(meshId, taskId, status) {
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3907
|
+
return withQueueLock(meshId, () => {
|
|
3908
|
+
const queue = readQueue(meshId);
|
|
3909
|
+
const idx = queue.findIndex((q) => q.id === taskId);
|
|
3910
|
+
if (idx === -1) return null;
|
|
3911
|
+
queue[idx].status = status;
|
|
3912
|
+
queue[idx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3913
|
+
writeQueue(meshId, queue);
|
|
3914
|
+
return queue[idx];
|
|
3915
|
+
});
|
|
3880
3916
|
}
|
|
3881
3917
|
function recordTaskAutoLaunch(meshId, taskId, autoLaunch) {
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
...autoLaunch,
|
|
3888
|
-
updatedAt
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
return queue[idx];
|
|
3918
|
+
return withQueueLock(meshId, () => {
|
|
3919
|
+
const queue = readQueue(meshId);
|
|
3920
|
+
const idx = queue.findIndex((q) => q.id === taskId);
|
|
3921
|
+
if (idx === -1) return null;
|
|
3922
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3923
|
+
queue[idx].autoLaunch = { ...autoLaunch, updatedAt: now };
|
|
3924
|
+
queue[idx].updatedAt = now;
|
|
3925
|
+
writeQueue(meshId, queue);
|
|
3926
|
+
return queue[idx];
|
|
3927
|
+
});
|
|
3893
3928
|
}
|
|
3894
3929
|
function cancelTask(meshId, taskId, opts) {
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3930
|
+
return withQueueLock(meshId, () => {
|
|
3931
|
+
const queue = readQueue(meshId);
|
|
3932
|
+
const idx = queue.findIndex((q) => q.id === taskId);
|
|
3933
|
+
if (idx === -1) return null;
|
|
3934
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3935
|
+
queue[idx].status = "cancelled";
|
|
3936
|
+
queue[idx].updatedAt = now;
|
|
3937
|
+
queue[idx].cancelledAt = now;
|
|
3938
|
+
if (opts?.reason) queue[idx].cancelReason = opts.reason;
|
|
3939
|
+
writeQueue(meshId, queue);
|
|
3940
|
+
return queue[idx];
|
|
3941
|
+
});
|
|
3905
3942
|
}
|
|
3906
3943
|
function requeueTask(meshId, taskId, opts) {
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3944
|
+
return withQueueLock(meshId, () => {
|
|
3945
|
+
const queue = readQueue(meshId);
|
|
3946
|
+
const idx = queue.findIndex((q) => q.id === taskId);
|
|
3947
|
+
if (idx === -1) return null;
|
|
3948
|
+
const entry = queue[idx];
|
|
3949
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3950
|
+
entry.status = "pending";
|
|
3951
|
+
delete entry.assignedNodeId;
|
|
3952
|
+
delete entry.assignedSessionId;
|
|
3953
|
+
delete entry.cancelledAt;
|
|
3954
|
+
delete entry.cancelReason;
|
|
3955
|
+
if (opts?.clearTargetNode) delete entry.targetNodeId;
|
|
3956
|
+
if (typeof opts?.targetNodeId === "string") entry.targetNodeId = opts.targetNodeId;
|
|
3957
|
+
if (opts?.clearTargetSession !== false) delete entry.targetSessionId;
|
|
3958
|
+
if (typeof opts?.targetSessionId === "string") entry.targetSessionId = opts.targetSessionId;
|
|
3959
|
+
entry.updatedAt = now;
|
|
3960
|
+
entry.requeuedAt = now;
|
|
3961
|
+
entry.requeueCount = (entry.requeueCount || 0) + 1;
|
|
3962
|
+
if (opts?.reason) entry.requeueReason = opts.reason;
|
|
3963
|
+
writeQueue(meshId, queue);
|
|
3964
|
+
return entry;
|
|
3965
|
+
});
|
|
3927
3966
|
}
|
|
3928
3967
|
function updateSessionTaskStatus(meshId, sessionId, status) {
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
bestTime
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3968
|
+
return withQueueLock(meshId, () => {
|
|
3969
|
+
const queue = readQueue(meshId);
|
|
3970
|
+
let bestIdx = -1;
|
|
3971
|
+
let bestTime = 0;
|
|
3972
|
+
for (let i = queue.length - 1; i >= 0; i--) {
|
|
3973
|
+
if (queue[i].assignedSessionId === sessionId && queue[i].status === "assigned") {
|
|
3974
|
+
const time3 = new Date(queue[i].dispatchTimestamp || queue[i].updatedAt).getTime();
|
|
3975
|
+
if (time3 > bestTime) {
|
|
3976
|
+
bestTime = time3;
|
|
3977
|
+
bestIdx = i;
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
if (bestIdx === -1) return null;
|
|
3982
|
+
queue[bestIdx].status = status;
|
|
3983
|
+
queue[bestIdx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3984
|
+
writeQueue(meshId, queue);
|
|
3985
|
+
return queue[bestIdx];
|
|
3986
|
+
});
|
|
3946
3987
|
}
|
|
3947
3988
|
function getMeshQueueStats(meshId) {
|
|
3948
3989
|
const queue = readQueue(meshId);
|
|
@@ -4351,21 +4392,70 @@ __export(mesh_events_exports, {
|
|
|
4351
4392
|
triggerMeshQueue: () => triggerMeshQueue,
|
|
4352
4393
|
tryAssignQueueTask: () => tryAssignQueueTask
|
|
4353
4394
|
});
|
|
4395
|
+
function sweepExpiredRemoteIdleSessions() {
|
|
4396
|
+
const now = Date.now();
|
|
4397
|
+
for (const [key, session] of remoteIdleSessions) {
|
|
4398
|
+
if (session.expiresAt <= now) remoteIdleSessions.delete(key);
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4401
|
+
function getPendingEventsPath(meshId) {
|
|
4402
|
+
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
4403
|
+
return (0, import_path5.join)(getLedgerDir(), `${safe}.pending-events.jsonl`);
|
|
4404
|
+
}
|
|
4354
4405
|
function queuePendingMeshCoordinatorEvent(event) {
|
|
4355
|
-
|
|
4406
|
+
try {
|
|
4407
|
+
(0, import_fs6.appendFileSync)(getPendingEventsPath(event.meshId), JSON.stringify(event) + "\n", "utf-8");
|
|
4408
|
+
return true;
|
|
4409
|
+
} catch (e) {
|
|
4410
|
+
LOG.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
|
|
4356
4411
|
return false;
|
|
4357
4412
|
}
|
|
4358
|
-
pendingMeshCoordinatorEvents.push(event);
|
|
4359
|
-
return true;
|
|
4360
4413
|
}
|
|
4361
|
-
function drainPendingMeshCoordinatorEvents() {
|
|
4362
|
-
|
|
4414
|
+
function drainPendingMeshCoordinatorEvents(meshId) {
|
|
4415
|
+
if (!meshId) return [];
|
|
4416
|
+
const path42 = getPendingEventsPath(meshId);
|
|
4417
|
+
if (!(0, import_fs6.existsSync)(path42)) return [];
|
|
4418
|
+
try {
|
|
4419
|
+
const raw = (0, import_fs6.readFileSync)(path42, "utf-8");
|
|
4420
|
+
try {
|
|
4421
|
+
(0, import_fs6.unlinkSync)(path42);
|
|
4422
|
+
} catch {
|
|
4423
|
+
}
|
|
4424
|
+
return raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
4425
|
+
try {
|
|
4426
|
+
return [JSON.parse(line)];
|
|
4427
|
+
} catch {
|
|
4428
|
+
return [];
|
|
4429
|
+
}
|
|
4430
|
+
});
|
|
4431
|
+
} catch {
|
|
4432
|
+
return [];
|
|
4433
|
+
}
|
|
4363
4434
|
}
|
|
4364
|
-
function getPendingMeshCoordinatorEvents() {
|
|
4365
|
-
|
|
4435
|
+
function getPendingMeshCoordinatorEvents(meshId) {
|
|
4436
|
+
if (!meshId) return [];
|
|
4437
|
+
const path42 = getPendingEventsPath(meshId);
|
|
4438
|
+
if (!(0, import_fs6.existsSync)(path42)) return [];
|
|
4439
|
+
try {
|
|
4440
|
+
const raw = (0, import_fs6.readFileSync)(path42, "utf-8");
|
|
4441
|
+
return raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
4442
|
+
try {
|
|
4443
|
+
return [JSON.parse(line)];
|
|
4444
|
+
} catch {
|
|
4445
|
+
return [];
|
|
4446
|
+
}
|
|
4447
|
+
});
|
|
4448
|
+
} catch {
|
|
4449
|
+
return [];
|
|
4450
|
+
}
|
|
4366
4451
|
}
|
|
4367
|
-
function clearPendingMeshCoordinatorEvents() {
|
|
4368
|
-
|
|
4452
|
+
function clearPendingMeshCoordinatorEvents(meshId) {
|
|
4453
|
+
if (!meshId) return;
|
|
4454
|
+
const path42 = getPendingEventsPath(meshId);
|
|
4455
|
+
if ((0, import_fs6.existsSync)(path42)) try {
|
|
4456
|
+
(0, import_fs6.unlinkSync)(path42);
|
|
4457
|
+
} catch {
|
|
4458
|
+
}
|
|
4369
4459
|
}
|
|
4370
4460
|
function readNonEmptyString(value) {
|
|
4371
4461
|
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
@@ -4429,7 +4519,16 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
|
|
|
4429
4519
|
message: task.message
|
|
4430
4520
|
}).catch((e) => {
|
|
4431
4521
|
LOG.error("MeshQueue", `Failed to dispatch task via P2P to remote node ${nodeId}: ${e?.message}`);
|
|
4432
|
-
updateTaskStatus(meshId, task.id, "
|
|
4522
|
+
updateTaskStatus(meshId, task.id, "pending");
|
|
4523
|
+
try {
|
|
4524
|
+
appendLedgerEntry(meshId, {
|
|
4525
|
+
kind: "dispatch_failed",
|
|
4526
|
+
nodeId,
|
|
4527
|
+
sessionId,
|
|
4528
|
+
payload: { taskId: task.id, error: e?.message, retryable: true }
|
|
4529
|
+
});
|
|
4530
|
+
} catch {
|
|
4531
|
+
}
|
|
4433
4532
|
});
|
|
4434
4533
|
return true;
|
|
4435
4534
|
}
|
|
@@ -4772,9 +4871,9 @@ function injectMeshSystemMessage(components, args) {
|
|
|
4772
4871
|
const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed");
|
|
4773
4872
|
completedTaskForLedger = completedTask ? { id: completedTask.id } : null;
|
|
4774
4873
|
if (nodeId && providerType) {
|
|
4775
|
-
|
|
4874
|
+
setImmediate(() => {
|
|
4776
4875
|
tryAssignQueueTask(components, args.meshId, nodeId, sessionId, providerType);
|
|
4777
|
-
}
|
|
4876
|
+
});
|
|
4778
4877
|
}
|
|
4779
4878
|
}
|
|
4780
4879
|
} else if (args.event === "agent:ready") {
|
|
@@ -4812,13 +4911,17 @@ function injectMeshSystemMessage(components, args) {
|
|
|
4812
4911
|
}
|
|
4813
4912
|
}
|
|
4814
4913
|
if (sessionId && nodeId && providerType) {
|
|
4815
|
-
|
|
4816
|
-
|
|
4914
|
+
sweepExpiredRemoteIdleSessions();
|
|
4915
|
+
remoteIdleSessions.set(`${nodeId}:${sessionId}`, {
|
|
4916
|
+
nodeId,
|
|
4917
|
+
sessionId,
|
|
4918
|
+
providerType,
|
|
4919
|
+
expiresAt: Date.now() + REMOTE_IDLE_SESSION_TTL_MS
|
|
4920
|
+
});
|
|
4921
|
+
setImmediate(() => {
|
|
4817
4922
|
const assigned = tryAssignQueueTask(components, args.meshId, nodeId, sessionId, providerType);
|
|
4818
|
-
if (assigned) {
|
|
4819
|
-
|
|
4820
|
-
}
|
|
4821
|
-
}, 500);
|
|
4923
|
+
if (assigned) remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
|
|
4924
|
+
});
|
|
4822
4925
|
}
|
|
4823
4926
|
} else if (args.event === "agent:generating_started") {
|
|
4824
4927
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
@@ -5021,19 +5124,20 @@ function setupMeshEventForwarding(components) {
|
|
|
5021
5124
|
});
|
|
5022
5125
|
});
|
|
5023
5126
|
}
|
|
5024
|
-
var
|
|
5127
|
+
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;
|
|
5025
5128
|
var init_mesh_events = __esm({
|
|
5026
5129
|
"../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
|
|
5027
5130
|
"use strict";
|
|
5131
|
+
import_fs6 = require("fs");
|
|
5132
|
+
import_path5 = require("path");
|
|
5028
5133
|
init_config();
|
|
5029
5134
|
init_mesh_config();
|
|
5030
5135
|
init_cli_detector();
|
|
5031
5136
|
init_logger();
|
|
5032
5137
|
init_mesh_ledger();
|
|
5033
5138
|
init_mesh_work_queue();
|
|
5139
|
+
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
5034
5140
|
remoteIdleSessions = /* @__PURE__ */ new Map();
|
|
5035
|
-
MAX_PENDING_EVENTS = 50;
|
|
5036
|
-
pendingMeshCoordinatorEvents = [];
|
|
5037
5141
|
MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
|
|
5038
5142
|
"agent:generating_started",
|
|
5039
5143
|
"agent:generating_completed",
|
|
@@ -5176,7 +5280,7 @@ function isPlainObject2(value) {
|
|
|
5176
5280
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
5177
5281
|
}
|
|
5178
5282
|
function getStatePath() {
|
|
5179
|
-
return (0,
|
|
5283
|
+
return (0, import_path6.join)(getConfigDir(), "state.json");
|
|
5180
5284
|
}
|
|
5181
5285
|
function normalizeState(raw) {
|
|
5182
5286
|
const parsed = isPlainObject2(raw) ? raw : {};
|
|
@@ -5212,11 +5316,11 @@ function normalizeState(raw) {
|
|
|
5212
5316
|
}
|
|
5213
5317
|
function loadState() {
|
|
5214
5318
|
const statePath = getStatePath();
|
|
5215
|
-
if (!(0,
|
|
5319
|
+
if (!(0, import_fs7.existsSync)(statePath)) {
|
|
5216
5320
|
return { ...DEFAULT_STATE };
|
|
5217
5321
|
}
|
|
5218
5322
|
try {
|
|
5219
|
-
const raw = (0,
|
|
5323
|
+
const raw = (0, import_fs7.readFileSync)(statePath, "utf-8");
|
|
5220
5324
|
return normalizeState(JSON.parse(raw));
|
|
5221
5325
|
} catch {
|
|
5222
5326
|
return { ...DEFAULT_STATE };
|
|
@@ -5225,17 +5329,17 @@ function loadState() {
|
|
|
5225
5329
|
function saveState(state) {
|
|
5226
5330
|
const statePath = getStatePath();
|
|
5227
5331
|
const normalized = normalizeState(state);
|
|
5228
|
-
(0,
|
|
5332
|
+
(0, import_fs7.writeFileSync)(statePath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
5229
5333
|
}
|
|
5230
5334
|
function resetState() {
|
|
5231
5335
|
saveState({ ...DEFAULT_STATE });
|
|
5232
5336
|
}
|
|
5233
|
-
var
|
|
5337
|
+
var import_fs7, import_path6, DEFAULT_STATE;
|
|
5234
5338
|
var init_state_store = __esm({
|
|
5235
5339
|
"../../oss/packages/daemon-core/src/config/state-store.ts"() {
|
|
5236
5340
|
"use strict";
|
|
5237
|
-
|
|
5238
|
-
|
|
5341
|
+
import_fs7 = require("fs");
|
|
5342
|
+
import_path6 = require("path");
|
|
5239
5343
|
init_config();
|
|
5240
5344
|
DEFAULT_STATE = {
|
|
5241
5345
|
recentActivity: [],
|
|
@@ -5268,7 +5372,7 @@ function findCliCommand(command) {
|
|
|
5268
5372
|
if (path10.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
|
|
5269
5373
|
const candidate = trimmed.startsWith("~") ? path10.join((0, import_os2.homedir)(), trimmed.slice(1)) : trimmed;
|
|
5270
5374
|
const resolved = path10.isAbsolute(candidate) ? candidate : path10.resolve(candidate);
|
|
5271
|
-
return (0,
|
|
5375
|
+
return (0, import_fs8.existsSync)(resolved) ? resolved : null;
|
|
5272
5376
|
}
|
|
5273
5377
|
try {
|
|
5274
5378
|
const result = (0, import_child_process2.execSync)(
|
|
@@ -5299,9 +5403,9 @@ function checkPathExists(paths) {
|
|
|
5299
5403
|
if (normalized.includes("*")) {
|
|
5300
5404
|
const username = home.split(/[\\/]/).pop() || "";
|
|
5301
5405
|
const resolved = normalized.replace("*", username);
|
|
5302
|
-
if ((0,
|
|
5406
|
+
if ((0, import_fs8.existsSync)(resolved)) return resolved;
|
|
5303
5407
|
} else {
|
|
5304
|
-
if ((0,
|
|
5408
|
+
if ((0, import_fs8.existsSync)(normalized)) return normalized;
|
|
5305
5409
|
}
|
|
5306
5410
|
}
|
|
5307
5411
|
return null;
|
|
@@ -5315,7 +5419,7 @@ async function detectIDEs(providerLoader) {
|
|
|
5315
5419
|
let resolvedCli = cliPath;
|
|
5316
5420
|
if (!resolvedCli && appPath && os32 === "darwin") {
|
|
5317
5421
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
5318
|
-
if ((0,
|
|
5422
|
+
if ((0, import_fs8.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
5319
5423
|
}
|
|
5320
5424
|
if (!resolvedCli && appPath && os32 === "win32") {
|
|
5321
5425
|
const { dirname: dirname13 } = await import("path");
|
|
@@ -5328,7 +5432,7 @@ async function detectIDEs(providerLoader) {
|
|
|
5328
5432
|
`${appDir}\\\\resources\\\\app\\\\bin\\\\${def.cli}.cmd`
|
|
5329
5433
|
];
|
|
5330
5434
|
for (const c of candidates) {
|
|
5331
|
-
if ((0,
|
|
5435
|
+
if ((0, import_fs8.existsSync)(c)) {
|
|
5332
5436
|
resolvedCli = c;
|
|
5333
5437
|
break;
|
|
5334
5438
|
}
|
|
@@ -5349,12 +5453,12 @@ async function detectIDEs(providerLoader) {
|
|
|
5349
5453
|
}
|
|
5350
5454
|
return results;
|
|
5351
5455
|
}
|
|
5352
|
-
var import_child_process2,
|
|
5456
|
+
var import_child_process2, import_fs8, import_os2, path10, BUILTIN_IDE_DEFINITIONS, registeredIDEs;
|
|
5353
5457
|
var init_ide_detector = __esm({
|
|
5354
5458
|
"../../oss/packages/daemon-core/src/detection/ide-detector.ts"() {
|
|
5355
5459
|
"use strict";
|
|
5356
5460
|
import_child_process2 = require("child_process");
|
|
5357
|
-
|
|
5461
|
+
import_fs8 = require("fs");
|
|
5358
5462
|
import_os2 = require("os");
|
|
5359
5463
|
path10 = __toESM(require("path"));
|
|
5360
5464
|
BUILTIN_IDE_DEFINITIONS = [];
|
|
@@ -37802,7 +37906,7 @@ function commandExists(command) {
|
|
|
37802
37906
|
const trimmed = command.trim();
|
|
37803
37907
|
if (!trimmed) return false;
|
|
37804
37908
|
if (isExplicitCommand(trimmed)) {
|
|
37805
|
-
return (0,
|
|
37909
|
+
return (0, import_fs9.existsSync)(expandExecutable(trimmed));
|
|
37806
37910
|
}
|
|
37807
37911
|
try {
|
|
37808
37912
|
(0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
@@ -37823,10 +37927,10 @@ function hasCliArg(args, flag) {
|
|
|
37823
37927
|
}
|
|
37824
37928
|
function ensureEmptyDelegatedMcpConfig(workspace) {
|
|
37825
37929
|
const baseDir = path19.join(os16.tmpdir(), "adhdev-delegated-agent-empty-mcp");
|
|
37826
|
-
(0,
|
|
37930
|
+
(0, import_fs9.mkdirSync)(baseDir, { recursive: true });
|
|
37827
37931
|
const workspaceHash = crypto4.createHash("sha256").update(path19.resolve(workspace || os16.tmpdir())).digest("hex").slice(0, 16);
|
|
37828
37932
|
const filePath = path19.join(baseDir, `${workspaceHash}.json`);
|
|
37829
|
-
(0,
|
|
37933
|
+
(0, import_fs9.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
|
|
37830
37934
|
return filePath;
|
|
37831
37935
|
}
|
|
37832
37936
|
function buildCoordinatorDelegatedCliLaunchOptions(input) {
|
|
@@ -37953,14 +38057,14 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
37953
38057
|
launchMode: "new"
|
|
37954
38058
|
};
|
|
37955
38059
|
}
|
|
37956
|
-
var os16, path19, crypto4,
|
|
38060
|
+
var os16, path19, crypto4, import_fs9, import_child_process6, chalkModule, chalkApi, COORDINATOR_DELEGATED_ENV_UNSETS, DaemonCliManager;
|
|
37957
38061
|
var init_cli_manager = __esm({
|
|
37958
38062
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
37959
38063
|
"use strict";
|
|
37960
38064
|
os16 = __toESM(require("os"));
|
|
37961
38065
|
path19 = __toESM(require("path"));
|
|
37962
38066
|
crypto4 = __toESM(require("crypto"));
|
|
37963
|
-
|
|
38067
|
+
import_fs9 = require("fs");
|
|
37964
38068
|
import_child_process6 = require("child_process");
|
|
37965
38069
|
init_source2();
|
|
37966
38070
|
init_provider_cli_adapter();
|
|
@@ -38874,7 +38978,7 @@ function createFsWatchInstance(path42, options, listener, errHandler, emitRaw) {
|
|
|
38874
38978
|
}
|
|
38875
38979
|
};
|
|
38876
38980
|
try {
|
|
38877
|
-
return (0,
|
|
38981
|
+
return (0, import_fs10.watch)(path42, {
|
|
38878
38982
|
persistent: options.persistent
|
|
38879
38983
|
}, handleEvent);
|
|
38880
38984
|
} catch (error48) {
|
|
@@ -38882,11 +38986,11 @@ function createFsWatchInstance(path42, options, listener, errHandler, emitRaw) {
|
|
|
38882
38986
|
return void 0;
|
|
38883
38987
|
}
|
|
38884
38988
|
}
|
|
38885
|
-
var
|
|
38989
|
+
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;
|
|
38886
38990
|
var init_handler2 = __esm({
|
|
38887
38991
|
"../../oss/node_modules/chokidar/esm/handler.js"() {
|
|
38888
38992
|
"use strict";
|
|
38889
|
-
|
|
38993
|
+
import_fs10 = require("fs");
|
|
38890
38994
|
import_promises5 = require("fs/promises");
|
|
38891
38995
|
sysPath = __toESM(require("path"), 1);
|
|
38892
38996
|
import_os3 = require("os");
|
|
@@ -39290,7 +39394,7 @@ var init_handler2 = __esm({
|
|
|
39290
39394
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
39291
39395
|
const copts = cont && cont.options;
|
|
39292
39396
|
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
|
39293
|
-
(0,
|
|
39397
|
+
(0, import_fs10.unwatchFile)(fullPath);
|
|
39294
39398
|
cont = void 0;
|
|
39295
39399
|
}
|
|
39296
39400
|
if (cont) {
|
|
@@ -39301,7 +39405,7 @@ var init_handler2 = __esm({
|
|
|
39301
39405
|
listeners: listener,
|
|
39302
39406
|
rawEmitters: rawEmitter,
|
|
39303
39407
|
options,
|
|
39304
|
-
watcher: (0,
|
|
39408
|
+
watcher: (0, import_fs10.watchFile)(fullPath, options, (curr, prev) => {
|
|
39305
39409
|
foreach(cont.rawEmitters, (rawEmitter2) => {
|
|
39306
39410
|
rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
|
|
39307
39411
|
});
|
|
@@ -39318,7 +39422,7 @@ var init_handler2 = __esm({
|
|
|
39318
39422
|
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
39319
39423
|
if (isEmptySet(cont.listeners)) {
|
|
39320
39424
|
FsWatchFileInstances.delete(fullPath);
|
|
39321
|
-
(0,
|
|
39425
|
+
(0, import_fs10.unwatchFile)(fullPath);
|
|
39322
39426
|
cont.options = cont.watcher = void 0;
|
|
39323
39427
|
Object.freeze(cont);
|
|
39324
39428
|
}
|
|
@@ -39696,11 +39800,11 @@ function watch(paths, options = {}) {
|
|
|
39696
39800
|
watcher.add(paths);
|
|
39697
39801
|
return watcher;
|
|
39698
39802
|
}
|
|
39699
|
-
var
|
|
39803
|
+
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;
|
|
39700
39804
|
var init_esm2 = __esm({
|
|
39701
39805
|
"../../oss/node_modules/chokidar/esm/index.js"() {
|
|
39702
39806
|
"use strict";
|
|
39703
|
-
|
|
39807
|
+
import_fs11 = require("fs");
|
|
39704
39808
|
import_promises6 = require("fs/promises");
|
|
39705
39809
|
import_events2 = require("events");
|
|
39706
39810
|
sysPath2 = __toESM(require("path"), 1);
|
|
@@ -40178,7 +40282,7 @@ var init_esm2 = __esm({
|
|
|
40178
40282
|
const now = /* @__PURE__ */ new Date();
|
|
40179
40283
|
const writes = this._pendingWrites;
|
|
40180
40284
|
function awaitWriteFinishFn(prevStat) {
|
|
40181
|
-
(0,
|
|
40285
|
+
(0, import_fs11.stat)(fullPath, (err, curStat) => {
|
|
40182
40286
|
if (err || !writes.has(path42)) {
|
|
40183
40287
|
if (err && err.code !== "ENOENT")
|
|
40184
40288
|
awfEmit(err);
|
|
@@ -46754,8 +46858,21 @@ function summarizeMeshSessionRecord(record2) {
|
|
|
46754
46858
|
isCached: false
|
|
46755
46859
|
};
|
|
46756
46860
|
}
|
|
46861
|
+
function liveSessionRecordMatchesMeshNode(record2, meshId, nodeId) {
|
|
46862
|
+
const recordNodeId = readStringValue(record2?.meta?.meshNodeId);
|
|
46863
|
+
if (!recordNodeId || recordNodeId !== nodeId) return false;
|
|
46864
|
+
const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
|
|
46865
|
+
return !recordMeshId || recordMeshId === meshId;
|
|
46866
|
+
}
|
|
46867
|
+
function liveSessionRecordMatchesMeshWorkspace(record2, meshId, workspace) {
|
|
46868
|
+
const recordWorkspace = readStringValue(record2?.workspace);
|
|
46869
|
+
if (!recordWorkspace || !workspace || recordWorkspace !== workspace) return false;
|
|
46870
|
+
const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
|
|
46871
|
+
if (recordMeshId) return recordMeshId === meshId;
|
|
46872
|
+
return record2?.meta?.launchedByCoordinator === true || !!readStringValue(record2?.meta?.meshNodeId);
|
|
46873
|
+
}
|
|
46757
46874
|
function readLiveMeshNodeWorkspace(args) {
|
|
46758
|
-
const directNodeWorkspace = args.liveSessionRecords.find((record2) =>
|
|
46875
|
+
const directNodeWorkspace = args.liveSessionRecords.find((record2) => liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId) && readStringValue(record2?.workspace));
|
|
46759
46876
|
if (directNodeWorkspace) {
|
|
46760
46877
|
return readStringValue(directNodeWorkspace.workspace) || "";
|
|
46761
46878
|
}
|
|
@@ -46769,10 +46886,9 @@ function readLiveMeshNodeWorkspace(args) {
|
|
|
46769
46886
|
}
|
|
46770
46887
|
function collectLiveMeshSessionRecords(args) {
|
|
46771
46888
|
const matches = args.liveSessionRecords.filter((record2) => {
|
|
46772
|
-
if (readStringValue(record2?.meta?.meshNodeId) === args.nodeId) return true;
|
|
46773
|
-
const recordWorkspace = readStringValue(record2?.workspace);
|
|
46774
46889
|
const nodeWorkspace = readStringValue(args.node?.workspace);
|
|
46775
|
-
|
|
46890
|
+
if (liveSessionRecordMatchesMeshNode(record2, args.meshId, args.nodeId)) return true;
|
|
46891
|
+
return !!nodeWorkspace && liveSessionRecordMatchesMeshWorkspace(record2, args.meshId, nodeWorkspace);
|
|
46776
46892
|
});
|
|
46777
46893
|
if (args.allowCoordinatorSession) {
|
|
46778
46894
|
for (const record2 of args.liveSessionRecords) {
|
|
@@ -46843,7 +46959,7 @@ function truncateValidationOutput(value) {
|
|
|
46843
46959
|
}
|
|
46844
46960
|
function readPackageScripts(workspace) {
|
|
46845
46961
|
try {
|
|
46846
|
-
const packageJsonPath = (0,
|
|
46962
|
+
const packageJsonPath = (0, import_path7.join)(workspace, "package.json");
|
|
46847
46963
|
const parsed = JSON.parse(fs10.readFileSync(packageJsonPath, "utf-8"));
|
|
46848
46964
|
return parsed?.scripts && typeof parsed.scripts === "object" && !Array.isArray(parsed.scripts) ? parsed.scripts : {};
|
|
46849
46965
|
} catch {
|
|
@@ -47051,13 +47167,13 @@ function serializeMeshCoordinatorMcpConfig(config2, format) {
|
|
|
47051
47167
|
}
|
|
47052
47168
|
function resolveHermesUserHome() {
|
|
47053
47169
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
47054
|
-
return explicitHome || (0,
|
|
47170
|
+
return explicitHome || (0, import_path7.join)((0, import_os4.homedir)(), ".hermes");
|
|
47055
47171
|
}
|
|
47056
47172
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
47057
47173
|
const sourceHome = resolveHermesUserHome();
|
|
47058
|
-
const sourceConfigPath = (0,
|
|
47174
|
+
const sourceConfigPath = (0, import_path7.join)(sourceHome, "config.yaml");
|
|
47059
47175
|
if (!fs10.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
47060
|
-
if ((0,
|
|
47176
|
+
if ((0, import_path7.resolve)(sourceConfigPath) === (0, import_path7.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
47061
47177
|
const parsed = parseMeshCoordinatorMcpConfig(fs10.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
47062
47178
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
47063
47179
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
@@ -47091,10 +47207,10 @@ function stripHermesCoordinatorTempModelProviderOverrides(config2) {
|
|
|
47091
47207
|
return sanitized;
|
|
47092
47208
|
}
|
|
47093
47209
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
47094
|
-
if ((0,
|
|
47210
|
+
if ((0, import_path7.resolve)(sourceHome) === (0, import_path7.resolve)(targetHome)) return;
|
|
47095
47211
|
for (const fileName of [".env", "auth.json"]) {
|
|
47096
|
-
const sourcePath = (0,
|
|
47097
|
-
const targetPath = (0,
|
|
47212
|
+
const sourcePath = (0, import_path7.join)(sourceHome, fileName);
|
|
47213
|
+
const targetPath = (0, import_path7.join)(targetHome, fileName);
|
|
47098
47214
|
if (!fs10.existsSync(sourcePath)) continue;
|
|
47099
47215
|
try {
|
|
47100
47216
|
fs10.copyFileSync(sourcePath, targetPath);
|
|
@@ -47184,7 +47300,7 @@ function summarizeSessionHostPruneResult(result) {
|
|
|
47184
47300
|
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
|
|
47185
47301
|
};
|
|
47186
47302
|
}
|
|
47187
|
-
var import_os4,
|
|
47303
|
+
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;
|
|
47188
47304
|
var init_router = __esm({
|
|
47189
47305
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
47190
47306
|
"use strict";
|
|
@@ -47214,7 +47330,7 @@ var init_router = __esm({
|
|
|
47214
47330
|
init_snapshot();
|
|
47215
47331
|
init_upgrade_helper();
|
|
47216
47332
|
import_os4 = require("os");
|
|
47217
|
-
|
|
47333
|
+
import_path7 = require("path");
|
|
47218
47334
|
fs10 = __toESM(require("fs"));
|
|
47219
47335
|
CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
47220
47336
|
CHANNEL_SERVER_URL = {
|
|
@@ -47343,7 +47459,7 @@ var init_router = __esm({
|
|
|
47343
47459
|
}
|
|
47344
47460
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
47345
47461
|
const normalizePath3 = (value) => {
|
|
47346
|
-
const resolved = (0,
|
|
47462
|
+
const resolved = (0, import_path7.resolve)(value);
|
|
47347
47463
|
try {
|
|
47348
47464
|
return fs10.realpathSync(resolved);
|
|
47349
47465
|
} catch {
|
|
@@ -47744,7 +47860,8 @@ var init_router = __esm({
|
|
|
47744
47860
|
return handleMeshForwardEvent({ instanceManager: this.deps.instanceManager }, args);
|
|
47745
47861
|
}
|
|
47746
47862
|
case "get_pending_mesh_events": {
|
|
47747
|
-
const
|
|
47863
|
+
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
47864
|
+
const events = drainPendingMeshCoordinatorEvents(meshId || void 0);
|
|
47748
47865
|
return { success: true, events };
|
|
47749
47866
|
}
|
|
47750
47867
|
case "launch_cli":
|
|
@@ -48965,7 +49082,7 @@ ${block}`);
|
|
|
48965
49082
|
workspace
|
|
48966
49083
|
};
|
|
48967
49084
|
}
|
|
48968
|
-
const { existsSync:
|
|
49085
|
+
const { existsSync: existsSync33, readFileSync: readFileSync24, writeFileSync: writeFileSync18, copyFileSync: copyFileSync5, mkdirSync: mkdirSync22 } = await import("fs");
|
|
48969
49086
|
const { dirname: dirname13 } = await import("path");
|
|
48970
49087
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
48971
49088
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -49008,14 +49125,14 @@ ${block}`);
|
|
|
49008
49125
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
49009
49126
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
49010
49127
|
}
|
|
49011
|
-
const hadExistingMcpConfig =
|
|
49128
|
+
const hadExistingMcpConfig = existsSync33(mcpConfigPath);
|
|
49012
49129
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
49013
49130
|
if (hermesBaseConfig) {
|
|
49014
49131
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname13(mcpConfigPath));
|
|
49015
49132
|
}
|
|
49016
49133
|
if (hadExistingMcpConfig) {
|
|
49017
49134
|
try {
|
|
49018
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
49135
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync24(mcpConfigPath, "utf-8"), configFormat);
|
|
49019
49136
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
49020
49137
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
49021
49138
|
copyFileSync5(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -49203,29 +49320,48 @@ ${block}`);
|
|
|
49203
49320
|
}
|
|
49204
49321
|
if (workspace) {
|
|
49205
49322
|
if (!fs10.existsSync(workspace)) {
|
|
49206
|
-
|
|
49207
|
-
|
|
49208
|
-
|
|
49209
|
-
|
|
49210
|
-
|
|
49211
|
-
|
|
49212
|
-
|
|
49213
|
-
|
|
49214
|
-
|
|
49323
|
+
let remoteProbeApplied = false;
|
|
49324
|
+
if (!isSelfNode && daemonId && this.deps.dispatchMeshCommand) {
|
|
49325
|
+
try {
|
|
49326
|
+
const remoteResult = await Promise.race([
|
|
49327
|
+
this.deps.dispatchMeshCommand(daemonId, "git_status", { workspace }),
|
|
49328
|
+
new Promise((_2, reject) => setTimeout(() => reject(new Error("timeout")), 8e3))
|
|
49329
|
+
]);
|
|
49330
|
+
const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
|
|
49331
|
+
if (remoteGit && typeof remoteGit === "object" && typeof remoteGit.isGitRepo === "boolean") {
|
|
49332
|
+
status.git = remoteGit;
|
|
49333
|
+
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
49334
|
+
remoteProbeApplied = true;
|
|
49335
|
+
}
|
|
49336
|
+
} catch {
|
|
49337
|
+
}
|
|
49215
49338
|
}
|
|
49216
|
-
|
|
49217
|
-
|
|
49218
|
-
|
|
49219
|
-
|
|
49220
|
-
|
|
49221
|
-
|
|
49222
|
-
|
|
49223
|
-
|
|
49224
|
-
|
|
49339
|
+
if (!remoteProbeApplied) {
|
|
49340
|
+
if (applyCachedInlineMeshNodeStatus(status, node)) {
|
|
49341
|
+
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
|
|
49342
|
+
nodeStatuses.push(status);
|
|
49343
|
+
continue;
|
|
49344
|
+
}
|
|
49345
|
+
if (meshRecord?.source === "inline_cache" && !isSelfNode) {
|
|
49346
|
+
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
|
|
49347
|
+
nodeStatuses.push(status);
|
|
49348
|
+
continue;
|
|
49349
|
+
}
|
|
49225
49350
|
}
|
|
49226
|
-
}
|
|
49227
|
-
|
|
49228
|
-
|
|
49351
|
+
} else {
|
|
49352
|
+
try {
|
|
49353
|
+
const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
49354
|
+
status.git = gitStatus;
|
|
49355
|
+
if (gitStatus.isGitRepo) {
|
|
49356
|
+
status.health = deriveMeshNodeHealthFromGit(gitStatus);
|
|
49357
|
+
} else {
|
|
49358
|
+
status.health = "degraded";
|
|
49359
|
+
if (gitStatus.error && !status.error) status.error = gitStatus.error;
|
|
49360
|
+
}
|
|
49361
|
+
} catch {
|
|
49362
|
+
if (!applyCachedInlineMeshNodeStatus(status, node)) {
|
|
49363
|
+
status.health = "degraded";
|
|
49364
|
+
}
|
|
49229
49365
|
}
|
|
49230
49366
|
}
|
|
49231
49367
|
} else {
|
|
@@ -72529,7 +72665,7 @@ var require_buffer_list = __commonJS({
|
|
|
72529
72665
|
}
|
|
72530
72666
|
}, {
|
|
72531
72667
|
key: "join",
|
|
72532
|
-
value: function
|
|
72668
|
+
value: function join40(s) {
|
|
72533
72669
|
if (this.length === 0) return "";
|
|
72534
72670
|
var p = this.head;
|
|
72535
72671
|
var ret = "" + p.data;
|
|
@@ -86588,13 +86724,13 @@ function splitStringBySpace(str2) {
|
|
|
86588
86724
|
}
|
|
86589
86725
|
return pieces;
|
|
86590
86726
|
}
|
|
86591
|
-
var import_chardet, import_child_process12,
|
|
86727
|
+
var import_chardet, import_child_process12, import_fs12, import_node_path3, import_node_os3, import_node_crypto3, import_iconv_lite, ExternalEditor;
|
|
86592
86728
|
var init_esm4 = __esm({
|
|
86593
86729
|
"../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
|
|
86594
86730
|
"use strict";
|
|
86595
86731
|
import_chardet = __toESM(require_lib(), 1);
|
|
86596
86732
|
import_child_process12 = require("child_process");
|
|
86597
|
-
|
|
86733
|
+
import_fs12 = require("fs");
|
|
86598
86734
|
import_node_path3 = __toESM(require("path"), 1);
|
|
86599
86735
|
import_node_os3 = __toESM(require("os"), 1);
|
|
86600
86736
|
import_node_crypto3 = require("crypto");
|
|
@@ -86670,14 +86806,14 @@ var init_esm4 = __esm({
|
|
|
86670
86806
|
if (Object.prototype.hasOwnProperty.call(this.fileOptions, "mode")) {
|
|
86671
86807
|
opt.mode = this.fileOptions.mode;
|
|
86672
86808
|
}
|
|
86673
|
-
(0,
|
|
86809
|
+
(0, import_fs12.writeFileSync)(this.tempFile, this.text, opt);
|
|
86674
86810
|
} catch (createFileError) {
|
|
86675
86811
|
throw new CreateFileError(createFileError);
|
|
86676
86812
|
}
|
|
86677
86813
|
}
|
|
86678
86814
|
readTemporaryFile() {
|
|
86679
86815
|
try {
|
|
86680
|
-
const tempFileBuffer = (0,
|
|
86816
|
+
const tempFileBuffer = (0, import_fs12.readFileSync)(this.tempFile);
|
|
86681
86817
|
if (tempFileBuffer.length === 0) {
|
|
86682
86818
|
this.text = "";
|
|
86683
86819
|
} else {
|
|
@@ -86693,7 +86829,7 @@ var init_esm4 = __esm({
|
|
|
86693
86829
|
}
|
|
86694
86830
|
removeTemporaryFile() {
|
|
86695
86831
|
try {
|
|
86696
|
-
(0,
|
|
86832
|
+
(0, import_fs12.unlinkSync)(this.tempFile);
|
|
86697
86833
|
} catch (removeFileError) {
|
|
86698
86834
|
throw new RemoveFileError(removeFileError);
|
|
86699
86835
|
}
|
|
@@ -88395,25 +88531,25 @@ function resolvePackageVersion(options) {
|
|
|
88395
88531
|
const injectedVersion = options?.injectedVersion || "unknown";
|
|
88396
88532
|
const dir = options?.dirname || __dirname;
|
|
88397
88533
|
const possiblePaths = [
|
|
88398
|
-
(0,
|
|
88399
|
-
(0,
|
|
88400
|
-
(0,
|
|
88534
|
+
(0, import_path8.join)(dir, "..", "..", "package.json"),
|
|
88535
|
+
(0, import_path8.join)(dir, "..", "package.json"),
|
|
88536
|
+
(0, import_path8.join)(dir, "package.json")
|
|
88401
88537
|
];
|
|
88402
88538
|
for (const p of possiblePaths) {
|
|
88403
88539
|
try {
|
|
88404
|
-
const data = JSON.parse((0,
|
|
88540
|
+
const data = JSON.parse((0, import_fs13.readFileSync)(p, "utf-8"));
|
|
88405
88541
|
if (data.version) return data.version;
|
|
88406
88542
|
} catch {
|
|
88407
88543
|
}
|
|
88408
88544
|
}
|
|
88409
88545
|
return injectedVersion;
|
|
88410
88546
|
}
|
|
88411
|
-
var
|
|
88547
|
+
var import_fs13, import_path8;
|
|
88412
88548
|
var init_version = __esm({
|
|
88413
88549
|
"src/version.ts"() {
|
|
88414
88550
|
"use strict";
|
|
88415
|
-
|
|
88416
|
-
|
|
88551
|
+
import_fs13 = require("fs");
|
|
88552
|
+
import_path8 = require("path");
|
|
88417
88553
|
}
|
|
88418
88554
|
});
|
|
88419
88555
|
|
|
@@ -90349,7 +90485,7 @@ var require_filesystem = __commonJS({
|
|
|
90349
90485
|
var LDD_PATH = "/usr/bin/ldd";
|
|
90350
90486
|
var SELF_PATH = "/proc/self/exe";
|
|
90351
90487
|
var MAX_LENGTH = 2048;
|
|
90352
|
-
var
|
|
90488
|
+
var readFileSync24 = (path42) => {
|
|
90353
90489
|
const fd = fs24.openSync(path42, "r");
|
|
90354
90490
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
90355
90491
|
const bytesRead = fs24.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
@@ -90374,7 +90510,7 @@ var require_filesystem = __commonJS({
|
|
|
90374
90510
|
module2.exports = {
|
|
90375
90511
|
LDD_PATH,
|
|
90376
90512
|
SELF_PATH,
|
|
90377
|
-
readFileSync:
|
|
90513
|
+
readFileSync: readFileSync24,
|
|
90378
90514
|
readFile: readFile2
|
|
90379
90515
|
};
|
|
90380
90516
|
}
|
|
@@ -90423,7 +90559,7 @@ var require_detect_libc = __commonJS({
|
|
|
90423
90559
|
"use strict";
|
|
90424
90560
|
var childProcess = require("child_process");
|
|
90425
90561
|
var { isLinux: isLinux2, getReport } = require_process();
|
|
90426
|
-
var { LDD_PATH, SELF_PATH, readFile: readFile2, readFileSync:
|
|
90562
|
+
var { LDD_PATH, SELF_PATH, readFile: readFile2, readFileSync: readFileSync24 } = require_filesystem();
|
|
90427
90563
|
var { interpreterPath } = require_elf();
|
|
90428
90564
|
var cachedFamilyInterpreter;
|
|
90429
90565
|
var cachedFamilyFilesystem;
|
|
@@ -90515,7 +90651,7 @@ var require_detect_libc = __commonJS({
|
|
|
90515
90651
|
}
|
|
90516
90652
|
cachedFamilyFilesystem = null;
|
|
90517
90653
|
try {
|
|
90518
|
-
const lddContent =
|
|
90654
|
+
const lddContent = readFileSync24(LDD_PATH);
|
|
90519
90655
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
90520
90656
|
} catch (e) {
|
|
90521
90657
|
}
|
|
@@ -90540,7 +90676,7 @@ var require_detect_libc = __commonJS({
|
|
|
90540
90676
|
}
|
|
90541
90677
|
cachedFamilyInterpreter = null;
|
|
90542
90678
|
try {
|
|
90543
|
-
const selfContent =
|
|
90679
|
+
const selfContent = readFileSync24(SELF_PATH);
|
|
90544
90680
|
const path42 = interpreterPath(selfContent);
|
|
90545
90681
|
cachedFamilyInterpreter = familyFromInterpreterPath(path42);
|
|
90546
90682
|
} catch (e) {
|
|
@@ -90604,7 +90740,7 @@ var require_detect_libc = __commonJS({
|
|
|
90604
90740
|
}
|
|
90605
90741
|
cachedVersionFilesystem = null;
|
|
90606
90742
|
try {
|
|
90607
|
-
const lddContent =
|
|
90743
|
+
const lddContent = readFileSync24(LDD_PATH);
|
|
90608
90744
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
90609
90745
|
if (versionMatch) {
|
|
90610
90746
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -98274,7 +98410,7 @@ var init_adhdev_daemon = __esm({
|
|
|
98274
98410
|
init_version();
|
|
98275
98411
|
init_src();
|
|
98276
98412
|
init_runtime_defaults();
|
|
98277
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
98413
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.24" });
|
|
98278
98414
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
98279
98415
|
localHttpServer = null;
|
|
98280
98416
|
localWss = null;
|