@adhdev/daemon-standalone 1.0.58-rc.43 → 1.0.58-rc.45
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 +119 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -36911,10 +36911,10 @@ var require_dist3 = __commonJS({
|
|
|
36911
36911
|
}
|
|
36912
36912
|
function getDaemonBuildInfo() {
|
|
36913
36913
|
if (cached2) return cached2;
|
|
36914
|
-
const commit = readInjected(true ? "
|
|
36915
|
-
const commitShort = readInjected(true ? "
|
|
36916
|
-
const version2 = readInjected(true ? "1.0.58-rc.
|
|
36917
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
36914
|
+
const commit = readInjected(true ? "f678a3c56c08e7876a714abda968b9e6a8787841" : void 0) ?? "unknown";
|
|
36915
|
+
const commitShort = readInjected(true ? "f678a3c5" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36916
|
+
const version2 = readInjected(true ? "1.0.58-rc.45" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36917
|
+
const builtAt = readInjected(true ? "2026-08-30T01:11:37.487Z" : void 0);
|
|
36918
36918
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
36919
36919
|
return cached2;
|
|
36920
36920
|
}
|
|
@@ -51080,7 +51080,8 @@ ${lines.join("\n")}
|
|
|
51080
51080
|
});
|
|
51081
51081
|
if (!stamp2) return event;
|
|
51082
51082
|
const dispatchedBySelfFallback = selfFallback && stamp2.scope === "broadcast";
|
|
51083
|
-
const
|
|
51083
|
+
const isWorktreeBootstrapEvent = event.event === "worktree_bootstrap_complete" || event.event === "worktree_bootstrap_failed";
|
|
51084
|
+
const selfFallbackTarget = dispatchedBySelfFallback && !isWorktreeBootstrapEvent && !readNonEmptyString(event.targetCoordinatorDaemonId) && !readNonEmptyString(event.targetCoordinatorSessionId) ? readNonEmptyString(stamp2.dispatchedBy.daemonId) : void 0;
|
|
51084
51085
|
return {
|
|
51085
51086
|
...event,
|
|
51086
51087
|
protocolVersion: stamp2.protocolVersion,
|
|
@@ -79188,6 +79189,47 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
79188
79189
|
recordAutoLaunchEvent(meshId, { phase: "skipped", taskId: task.id, reason: "awaiting_launched_session_claim_backoff", nodeId, sessionId });
|
|
79189
79190
|
return "backoff";
|
|
79190
79191
|
}
|
|
79192
|
+
function remoteGeneratingKey(meshId, sessionId) {
|
|
79193
|
+
return `${meshId}::${sessionId}`;
|
|
79194
|
+
}
|
|
79195
|
+
function markRemoteSessionGenerating(meshId, sessionId) {
|
|
79196
|
+
if (!meshId || !sessionId) return;
|
|
79197
|
+
remoteGeneratingSessions.add(remoteGeneratingKey(meshId, sessionId));
|
|
79198
|
+
}
|
|
79199
|
+
function markRemoteSessionIdle(meshId, sessionId) {
|
|
79200
|
+
if (!meshId || !sessionId) return;
|
|
79201
|
+
remoteGeneratingSessions.delete(remoteGeneratingKey(meshId, sessionId));
|
|
79202
|
+
}
|
|
79203
|
+
function isRemoteSessionMarkedGenerating(meshId, sessionId) {
|
|
79204
|
+
if (!meshId || !sessionId) return false;
|
|
79205
|
+
return remoteGeneratingSessions.has(remoteGeneratingKey(meshId, sessionId));
|
|
79206
|
+
}
|
|
79207
|
+
function claimAfterRemoteAutoLaunch(components, meshId, nodeId, sessionId, providerType, assignQueueTask) {
|
|
79208
|
+
if (!sessionId) return "no_session";
|
|
79209
|
+
if (isRemoteSessionMarkedGenerating(meshId, sessionId)) {
|
|
79210
|
+
LOG2.info("MeshQueue", `Remote auto-launch claim skipped for session ${sessionId} on node ${nodeId} (mesh ${meshId}): generating_started observed \u2014 fail-closed, will not inject into a mid-turn worker`);
|
|
79211
|
+
return "skipped_generating";
|
|
79212
|
+
}
|
|
79213
|
+
try {
|
|
79214
|
+
MeshRuntimeStore.getInstance().setRemoteIdleSession(
|
|
79215
|
+
meshId,
|
|
79216
|
+
nodeId,
|
|
79217
|
+
sessionId,
|
|
79218
|
+
providerType,
|
|
79219
|
+
Date.now() + AUTO_LAUNCH_REMOTE_IDLE_TTL_MS
|
|
79220
|
+
);
|
|
79221
|
+
} catch {
|
|
79222
|
+
}
|
|
79223
|
+
const assigned = assignQueueTask(components, meshId, nodeId, sessionId, providerType);
|
|
79224
|
+
if (assigned) {
|
|
79225
|
+
try {
|
|
79226
|
+
MeshRuntimeStore.getInstance().deleteRemoteIdleSession(meshId, nodeId, sessionId);
|
|
79227
|
+
} catch {
|
|
79228
|
+
}
|
|
79229
|
+
return "claimed";
|
|
79230
|
+
}
|
|
79231
|
+
return "registered";
|
|
79232
|
+
}
|
|
79191
79233
|
var AUTO_LAUNCH_AWAIT_CLAIM_MS;
|
|
79192
79234
|
var AUTO_LAUNCH_AWAIT_CLAIM_BACKOFF_CAP_CYCLES;
|
|
79193
79235
|
var AUTO_LAUNCH_REMOTE_IDLE_TTL_MS;
|
|
@@ -79196,6 +79238,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
79196
79238
|
var autoLaunchOrphanFirstSeenAtMs;
|
|
79197
79239
|
var AUTO_LAUNCH_ORPHAN_GRACE_MS;
|
|
79198
79240
|
var autoLaunchAwaitClaimBackoff;
|
|
79241
|
+
var remoteGeneratingSessions;
|
|
79199
79242
|
var init_mesh_autolaunch_integrity = __esm2({
|
|
79200
79243
|
"src/mesh/mesh-autolaunch-integrity.ts"() {
|
|
79201
79244
|
"use strict";
|
|
@@ -79216,6 +79259,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
79216
79259
|
autoLaunchOrphanFirstSeenAtMs = /* @__PURE__ */ new Map();
|
|
79217
79260
|
AUTO_LAUNCH_ORPHAN_GRACE_MS = 3e4;
|
|
79218
79261
|
autoLaunchAwaitClaimBackoff = /* @__PURE__ */ new Map();
|
|
79262
|
+
remoteGeneratingSessions = /* @__PURE__ */ new Set();
|
|
79219
79263
|
}
|
|
79220
79264
|
});
|
|
79221
79265
|
function classifiedDifficultiesForSlot(slot) {
|
|
@@ -81035,12 +81079,18 @@ ${block2.text}`,
|
|
|
81035
81079
|
if (!localId) continue;
|
|
81036
81080
|
const inlineMatch = cachedNodes.find((cachedNode) => meshNodeIdMatches(cachedNode, localId));
|
|
81037
81081
|
if (!inlineMatch) continue;
|
|
81038
|
-
|
|
81082
|
+
const bootstrapFresher = inlineBootstrapIsFresher(inlineMatch.worktreeBootstrap, localNode.worktreeBootstrap);
|
|
81083
|
+
const inlineGit = inlineMatch.lastGit ?? inlineMatch.last_git;
|
|
81084
|
+
if (!bootstrapFresher && !inlineGit) continue;
|
|
81039
81085
|
if (!overlaid) {
|
|
81040
81086
|
overlaidLocalNodes = [...localNodes];
|
|
81041
81087
|
overlaid = true;
|
|
81042
81088
|
}
|
|
81043
|
-
overlaidLocalNodes[i] = {
|
|
81089
|
+
overlaidLocalNodes[i] = {
|
|
81090
|
+
...localNode,
|
|
81091
|
+
...bootstrapFresher ? { worktreeBootstrap: inlineMatch.worktreeBootstrap } : {},
|
|
81092
|
+
...inlineGit ? { lastGit: inlineGit, last_git: inlineGit } : {}
|
|
81093
|
+
};
|
|
81044
81094
|
}
|
|
81045
81095
|
if (!cacheOnly.length && !overlaid) return localMesh;
|
|
81046
81096
|
return { ...localMesh, nodes: [...overlaidLocalNodes, ...cacheOnly] };
|
|
@@ -81337,7 +81387,12 @@ ${block2.text}`,
|
|
|
81337
81387
|
return void 0;
|
|
81338
81388
|
}
|
|
81339
81389
|
})();
|
|
81340
|
-
const bootstrapGateNode =
|
|
81390
|
+
const bootstrapGateNode = (() => {
|
|
81391
|
+
const base = inlineBootstrapNode ?? node;
|
|
81392
|
+
if (!base) return base;
|
|
81393
|
+
const git3 = inlineBootstrapNode?.lastGit ?? inlineBootstrapNode?.last_git ?? node?.lastGit ?? node?.last_git;
|
|
81394
|
+
return git3 ? { ...base, lastGit: git3, last_git: git3 } : base;
|
|
81395
|
+
})();
|
|
81341
81396
|
if (bootstrapGateNode?.worktreeBootstrap?.status === "running") {
|
|
81342
81397
|
if (!shouldDeferDispatchForBootstrap(bootstrapGateNode)) {
|
|
81343
81398
|
logWorktreeBootstrapStaleBypass(meshId, nodeId, sessionId);
|
|
@@ -82130,6 +82185,7 @@ ${block2.text}`,
|
|
|
82130
82185
|
await waitForRemoteSessionReady(meshId, nodeId, remoteSessionId, {
|
|
82131
82186
|
isReady: remoteSessionReadyProbe(meshId, nodeId, remoteSessionId)
|
|
82132
82187
|
}).catch(() => false);
|
|
82188
|
+
claimAfterRemoteAutoLaunch(components, meshId, nodeId, remoteSessionId, effectiveProviderType, tryAssignQueueTask);
|
|
82133
82189
|
}
|
|
82134
82190
|
return true;
|
|
82135
82191
|
}
|
|
@@ -85973,6 +86029,7 @@ ${cleanBody}`;
|
|
|
85973
86029
|
}
|
|
85974
86030
|
if (nodeId && providerType) {
|
|
85975
86031
|
if (!isFalseIdle) {
|
|
86032
|
+
markRemoteSessionIdle(args.meshId, sessionId);
|
|
85976
86033
|
sweepExpiredRemoteIdleSessions();
|
|
85977
86034
|
try {
|
|
85978
86035
|
MeshRuntimeStore.getInstance().setRemoteIdleSession(args.meshId, nodeId, sessionId, providerType, Date.now() + REMOTE_IDLE_SESSION_TTL_MS);
|
|
@@ -86050,6 +86107,7 @@ ${cleanBody}`;
|
|
|
86050
86107
|
worktreeBootstrapPending = node?.worktreeBootstrap?.status === "running";
|
|
86051
86108
|
} catch {
|
|
86052
86109
|
}
|
|
86110
|
+
markRemoteSessionIdle(args.meshId, sessionId);
|
|
86053
86111
|
sweepExpiredRemoteIdleSessions();
|
|
86054
86112
|
try {
|
|
86055
86113
|
MeshRuntimeStore.getInstance().setRemoteIdleSession(args.meshId, nodeId, sessionId, providerType, Date.now() + REMOTE_IDLE_SESSION_TTL_MS);
|
|
@@ -86080,6 +86138,7 @@ ${cleanBody}`;
|
|
|
86080
86138
|
}
|
|
86081
86139
|
}
|
|
86082
86140
|
if (sessionId) {
|
|
86141
|
+
markRemoteSessionGenerating(args.meshId, sessionId);
|
|
86083
86142
|
const startedTaskId = readNonEmptyString(args.metadataEvent.taskId) || void 0;
|
|
86084
86143
|
const startedNonce = typeof args.metadataEvent.dispatchNonce === "number" ? args.metadataEvent.dispatchNonce : void 0;
|
|
86085
86144
|
if (startedTaskId && startedNonce !== void 0) {
|
|
@@ -86187,6 +86246,7 @@ ${cleanBody}`;
|
|
|
86187
86246
|
}
|
|
86188
86247
|
}
|
|
86189
86248
|
if (sessionId) {
|
|
86249
|
+
markRemoteSessionIdle(args.meshId, sessionId);
|
|
86190
86250
|
directDispatchTaskIdForLedger = readNonEmptyString(args.metadataEvent.taskId) || resolveActiveDirectDispatchTaskId(args.meshId, sessionId);
|
|
86191
86251
|
completedTaskForLedger = markSessionTerminal(sessionId, "failed");
|
|
86192
86252
|
}
|
|
@@ -86195,11 +86255,17 @@ ${cleanBody}`;
|
|
|
86195
86255
|
if (bootstrapNodeId) {
|
|
86196
86256
|
try {
|
|
86197
86257
|
const bootstrapWorkspace = readNonEmptyString(args.metadataEvent.worktreePath) || readNonEmptyString(args.metadataEvent.workspace);
|
|
86258
|
+
const originDaemonId = readNonEmptyString(args.metadataEvent.originDaemonId) || readNonEmptyString(args.metadataEvent.daemonId);
|
|
86259
|
+
const originMachineId = readNonEmptyString(args.metadataEvent.originMachineId) || readNonEmptyString(args.metadataEvent.machineId);
|
|
86198
86260
|
components.router.markWorktreeBootstrapTerminalState(
|
|
86199
86261
|
args.meshId,
|
|
86200
86262
|
bootstrapNodeId,
|
|
86201
86263
|
args.event === "worktree_bootstrap_failed" ? "failed" : "complete",
|
|
86202
|
-
bootstrapWorkspace
|
|
86264
|
+
bootstrapWorkspace || originDaemonId || originMachineId ? {
|
|
86265
|
+
...bootstrapWorkspace ? { workspace: bootstrapWorkspace } : {},
|
|
86266
|
+
...originDaemonId ? { daemonId: originDaemonId } : {},
|
|
86267
|
+
...originMachineId ? { machineId: originMachineId } : {}
|
|
86268
|
+
} : void 0
|
|
86203
86269
|
);
|
|
86204
86270
|
} catch (e) {
|
|
86205
86271
|
LOG2.error("MeshQueue", `Failed to stamp terminal bootstrap state for ${bootstrapNodeId} (mesh ${args.meshId}): ${e?.message || e}`);
|
|
@@ -86528,6 +86594,10 @@ ${cleanBody}`;
|
|
|
86528
86594
|
interactionId: readNonEmptyString(payload.interactionId),
|
|
86529
86595
|
status: readNonEmptyString(payload.status),
|
|
86530
86596
|
targetDaemonId: readNonEmptyString(payload.targetDaemonId),
|
|
86597
|
+
// Worker origin identity for a remotely cloned worktree's bootstrap event
|
|
86598
|
+
// so the coordinator's hydrate-on-miss upsert is P2P-addressable.
|
|
86599
|
+
originDaemonId: readNonEmptyString(payload.originDaemonId) || readNonEmptyString(payload.daemonId) || readNonEmptyString(payload.metadataEvent?.originDaemonId),
|
|
86600
|
+
originMachineId: readNonEmptyString(payload.originMachineId) || readNonEmptyString(payload.machineId) || readNonEmptyString(payload.metadataEvent?.originMachineId),
|
|
86531
86601
|
startedAt: readNonEmptyString(payload.startedAt),
|
|
86532
86602
|
completedAt: readNonEmptyString(payload.completedAt),
|
|
86533
86603
|
retryOfJobId: readNonEmptyString(payload.retryOfJobId),
|
|
@@ -86850,6 +86920,7 @@ ${cleanBody}`;
|
|
|
86850
86920
|
init_mesh_event_classify();
|
|
86851
86921
|
init_mesh_turn_ledger();
|
|
86852
86922
|
init_mesh_queue_assignment();
|
|
86923
|
+
init_mesh_autolaunch_integrity();
|
|
86853
86924
|
init_mesh_event_suppression();
|
|
86854
86925
|
init_mesh_event_suppression();
|
|
86855
86926
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
@@ -87080,10 +87151,24 @@ ${cleanBody}`;
|
|
|
87080
87151
|
return [];
|
|
87081
87152
|
}
|
|
87082
87153
|
function extractPendingEvents(raw) {
|
|
87083
|
-
|
|
87084
|
-
|
|
87085
|
-
|
|
87086
|
-
|
|
87154
|
+
let cursor = raw;
|
|
87155
|
+
for (let depth = 0; depth < 4 && cursor && typeof cursor === "object"; depth++) {
|
|
87156
|
+
if (Array.isArray(cursor)) return cursor;
|
|
87157
|
+
const record2 = cursor;
|
|
87158
|
+
if (Array.isArray(record2.events)) return record2.events;
|
|
87159
|
+
if (record2.payload && typeof record2.payload === "object") {
|
|
87160
|
+
cursor = record2.payload;
|
|
87161
|
+
continue;
|
|
87162
|
+
}
|
|
87163
|
+
if (record2.result && typeof record2.result === "object") {
|
|
87164
|
+
cursor = record2.result;
|
|
87165
|
+
continue;
|
|
87166
|
+
}
|
|
87167
|
+
if (record2.data && typeof record2.data === "object") {
|
|
87168
|
+
cursor = record2.data;
|
|
87169
|
+
continue;
|
|
87170
|
+
}
|
|
87171
|
+
break;
|
|
87087
87172
|
}
|
|
87088
87173
|
return [];
|
|
87089
87174
|
}
|
|
@@ -137541,6 +137626,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137541
137626
|
try {
|
|
137542
137627
|
const durationMs = Date.now() - startedAtMs;
|
|
137543
137628
|
const event = `worktree_${eventStatus2}`;
|
|
137629
|
+
const hostDaemonId = readNonEmptyString(mesh?.meshHost?.hostDaemonId);
|
|
137544
137630
|
const metadataEvent = {
|
|
137545
137631
|
source: "clone_mesh_node_bootstrap",
|
|
137546
137632
|
nodeId: node.id,
|
|
@@ -137548,6 +137634,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137548
137634
|
worktreePath: result.worktreePath,
|
|
137549
137635
|
durationMs,
|
|
137550
137636
|
bootstrapStatus: bootstrapState2.status,
|
|
137637
|
+
...hostDaemonId ? { targetCoordinatorDaemonId: hostDaemonId } : {},
|
|
137638
|
+
...effectiveDaemonId ? { originDaemonId: effectiveDaemonId } : {},
|
|
137639
|
+
...effectiveMachineId ? { originMachineId: effectiveMachineId } : {},
|
|
137551
137640
|
...bootstrapState2.error ? { error: bootstrapState2.error } : {},
|
|
137552
137641
|
...bootstrapState2.exitCode !== void 0 ? { exitCode: bootstrapState2.exitCode } : {},
|
|
137553
137642
|
...extraPayload || {}
|
|
@@ -137562,7 +137651,16 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137562
137651
|
getCachedInlineMesh: ctx.getCachedInlineMesh
|
|
137563
137652
|
}
|
|
137564
137653
|
},
|
|
137565
|
-
{
|
|
137654
|
+
{
|
|
137655
|
+
event,
|
|
137656
|
+
meshId,
|
|
137657
|
+
nodeId: node.id,
|
|
137658
|
+
workspace: result.worktreePath,
|
|
137659
|
+
metadataEvent,
|
|
137660
|
+
...hostDaemonId ? { targetCoordinatorDaemonId: hostDaemonId } : {},
|
|
137661
|
+
...effectiveDaemonId ? { originDaemonId: effectiveDaemonId } : {},
|
|
137662
|
+
...effectiveMachineId ? { originMachineId: effectiveMachineId } : {}
|
|
137663
|
+
}
|
|
137566
137664
|
);
|
|
137567
137665
|
if (forwarded?.success === true) return;
|
|
137568
137666
|
} catch {
|
|
@@ -137575,7 +137673,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
137575
137673
|
nodeId: node.id,
|
|
137576
137674
|
workspace: result.worktreePath,
|
|
137577
137675
|
metadataEvent,
|
|
137578
|
-
queuedAt: Date.now()
|
|
137676
|
+
queuedAt: Date.now(),
|
|
137677
|
+
...hostDaemonId ? { targetCoordinatorDaemonId: hostDaemonId } : {}
|
|
137579
137678
|
});
|
|
137580
137679
|
} catch {
|
|
137581
137680
|
}
|
|
@@ -141844,6 +141943,11 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
141844
141943
|
nodeId,
|
|
141845
141944
|
isLocalWorktree: true,
|
|
141846
141945
|
...opts?.workspace ? { workspace: opts.workspace } : {},
|
|
141946
|
+
// Origin identity from the worker's bootstrap event: without
|
|
141947
|
+
// these, isLocalAutoLaunchNode treats the shell as LOCAL and the
|
|
141948
|
+
// coordinator tries to spawn the remote worktree on itself.
|
|
141949
|
+
...opts?.daemonId ? { daemonId: opts.daemonId } : {},
|
|
141950
|
+
...opts?.machineId ? { machineId: opts.machineId } : {},
|
|
141847
141951
|
worktreeBootstrap: terminalBootstrap()
|
|
141848
141952
|
};
|
|
141849
141953
|
this.updateInlineMeshNode(meshId, shell, hydratedNode);
|