@adhdev/daemon-core 0.9.82-rc.384 → 0.9.82-rc.386
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-adapter-types.d.ts +12 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +11 -0
- package/dist/index.js +71 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -7
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-events.d.ts +1 -1
- package/dist/mesh/mesh-reconcile-loop.d.ts +56 -0
- package/dist/providers/cli-provider-instance.d.ts +8 -0
- package/dist/providers/spec/fsm-driver.d.ts +10 -0
- package/package.json +2 -2
- package/src/cli-adapter-types.ts +12 -0
- package/src/cli-adapters/provider-cli-shared.ts +11 -0
- package/src/commands/high-family/mesh-events.ts +13 -1
- package/src/mesh/mesh-events.ts +2 -0
- package/src/mesh/mesh-reconcile-loop.ts +84 -0
- package/src/providers/cli-provider-instance.ts +43 -1
- package/src/providers/spec/cli-adapter.ts +6 -1
- package/src/providers/spec/fsm-driver.ts +12 -0
package/dist/index.mjs
CHANGED
|
@@ -378,10 +378,10 @@ function readInjected(value) {
|
|
|
378
378
|
}
|
|
379
379
|
function getDaemonBuildInfo() {
|
|
380
380
|
if (cached) return cached;
|
|
381
|
-
const commit = readInjected(true ? "
|
|
382
|
-
const commitShort = readInjected(true ? "
|
|
383
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
384
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
381
|
+
const commit = readInjected(true ? "fad1d175ca84a75f52bd0c1d88125fbb783ad241" : void 0) ?? "unknown";
|
|
382
|
+
const commitShort = readInjected(true ? "fad1d175" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
383
|
+
const version = readInjected(true ? "0.9.82-rc.386" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
384
|
+
const builtAt = readInjected(true ? "2026-06-26T00:12:44.100Z" : void 0);
|
|
385
385
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
386
386
|
return cached;
|
|
387
387
|
}
|
|
@@ -14967,6 +14967,32 @@ function findLiveCoordinators(components) {
|
|
|
14967
14967
|
}
|
|
14968
14968
|
return out;
|
|
14969
14969
|
}
|
|
14970
|
+
function resolveCoordinatorDrainDeliverability(components, meshId) {
|
|
14971
|
+
const coordinators = findLiveCoordinators(components).filter((c) => c.meshId === meshId);
|
|
14972
|
+
if (coordinators.length === 0) {
|
|
14973
|
+
return { hasLiveCliCoordinator: false, deliverableNow: false, holdForReconcile: false };
|
|
14974
|
+
}
|
|
14975
|
+
const hasIdle = coordinators.some((c) => c.idle);
|
|
14976
|
+
return {
|
|
14977
|
+
hasLiveCliCoordinator: true,
|
|
14978
|
+
deliverableNow: hasIdle,
|
|
14979
|
+
// A live CLI coordinator exists but none is idle → the reconcile loop is
|
|
14980
|
+
// holding the events; the poll must not steal them.
|
|
14981
|
+
holdForReconcile: !hasIdle
|
|
14982
|
+
};
|
|
14983
|
+
}
|
|
14984
|
+
function shouldHoldPendingDrainForBusyLocalCoordinator(components, meshId, requestedCoordinatorDaemonId) {
|
|
14985
|
+
if (!meshId) return false;
|
|
14986
|
+
const deliverability = resolveCoordinatorDrainDeliverability(components, meshId);
|
|
14987
|
+
if (!deliverability.holdForReconcile) return false;
|
|
14988
|
+
const requested = readNonEmptyString2(requestedCoordinatorDaemonId);
|
|
14989
|
+
if (!requested) return true;
|
|
14990
|
+
const localIds = expandDaemonIdForms([
|
|
14991
|
+
readNonEmptyString2(components.statusInstanceId),
|
|
14992
|
+
readNonEmptyString2(loadConfig().machineId)
|
|
14993
|
+
]);
|
|
14994
|
+
return localIds.some((id) => daemonIdsEquivalent(id, requested));
|
|
14995
|
+
}
|
|
14970
14996
|
function injectPendingIntoCoordinator(coordinator, pending) {
|
|
14971
14997
|
if (!coordinator || !pending.coordinatorMessage) return;
|
|
14972
14998
|
const force = shouldForceInjectMeshEvent(pending.event);
|
|
@@ -15683,9 +15709,11 @@ __export(mesh_events_exports, {
|
|
|
15683
15709
|
isMeshCoordinatorEvent: () => isMeshCoordinatorEvent,
|
|
15684
15710
|
queuePendingMeshCoordinatorEvent: () => queuePendingMeshCoordinatorEvent,
|
|
15685
15711
|
reconcileDirectDispatchCompletionFromTranscript: () => reconcileDirectDispatchCompletionFromTranscript,
|
|
15712
|
+
resolveCoordinatorDrainDeliverability: () => resolveCoordinatorDrainDeliverability,
|
|
15686
15713
|
runMeshReconcileTick: () => runMeshReconcileTick,
|
|
15687
15714
|
setupMeshEventForwarding: () => setupMeshEventForwarding,
|
|
15688
15715
|
setupMeshReconcileLoop: () => setupMeshReconcileLoop,
|
|
15716
|
+
shouldHoldPendingDrainForBusyLocalCoordinator: () => shouldHoldPendingDrainForBusyLocalCoordinator,
|
|
15689
15717
|
triggerMeshQueue: () => triggerMeshQueue,
|
|
15690
15718
|
tryAssignQueueTask: () => tryAssignQueueTask
|
|
15691
15719
|
});
|
|
@@ -35805,6 +35833,17 @@ var FsmDriver = class {
|
|
|
35805
35833
|
hasIdleHoldPending() {
|
|
35806
35834
|
return (this.lastFsmEval?.transitions ?? []).some((t) => !t.holdSatisfied && t.condResult);
|
|
35807
35835
|
}
|
|
35836
|
+
/**
|
|
35837
|
+
* True once the machine has reached its first non-initial idle state (the
|
|
35838
|
+
* prompt is genuinely drawn — see maybeMarkReady). The cli-adapter surfaces
|
|
35839
|
+
* this on its idle status so CliProviderInstance can re-arm the queue-claim
|
|
35840
|
+
* agent:ready on the first genuine ready, independent of the boot-time
|
|
35841
|
+
* starting→idle one-shot (which is consumed too early for specs whose
|
|
35842
|
+
* initial state already reports idle).
|
|
35843
|
+
*/
|
|
35844
|
+
hasSeenReady() {
|
|
35845
|
+
return this.readySeenOnce;
|
|
35846
|
+
}
|
|
35808
35847
|
getCompletionIdleDebounceState() {
|
|
35809
35848
|
const out = outgoingTransitions(this.spec, this.currentStateId);
|
|
35810
35849
|
const toReady = this.lastFsmEval?.transitions.find((t, i) => {
|
|
@@ -37471,7 +37510,7 @@ var SpecCliAdapter = class _SpecCliAdapter {
|
|
|
37471
37510
|
if (state.status === "generating") {
|
|
37472
37511
|
return { status: "generating", messages: [], activeModal: null, activeInteractivePrompt: this.activeInteractivePrompt, ...sessionFields };
|
|
37473
37512
|
}
|
|
37474
|
-
return { status: "idle", messages: [], activeModal: null, activeInteractivePrompt: this.activeInteractivePrompt, ...sessionFields };
|
|
37513
|
+
return { status: "idle", messages: [], activeModal: null, activeInteractivePrompt: this.activeInteractivePrompt, fsmReadySeen: this.driver.hasSeenReady?.() ?? false, ...sessionFields };
|
|
37475
37514
|
}
|
|
37476
37515
|
maybeRefreshNativeHistory() {
|
|
37477
37516
|
}
|
|
@@ -38516,6 +38555,14 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
38516
38555
|
context = null;
|
|
38517
38556
|
events = [];
|
|
38518
38557
|
lastStatus = "starting";
|
|
38558
|
+
// Idempotency guard for the queue-claim agent:ready event. agent:ready is the
|
|
38559
|
+
// sole signal the mesh coordinator's tryAssignQueueTask waits on to hand a
|
|
38560
|
+
// queued task to this worker. It is emitted in two places: the boot-time
|
|
38561
|
+
// starting→idle one-shot, and the readySeen re-arm below. This flag makes the
|
|
38562
|
+
// event fire AT MOST ONCE per session so a worker is never claimed twice and a
|
|
38563
|
+
// queued task is never double-dispatched/double-injected. Whichever path fires
|
|
38564
|
+
// first sets it; the other becomes a no-op.
|
|
38565
|
+
agentReadyEmitted = false;
|
|
38519
38566
|
generatingStartedAt = 0;
|
|
38520
38567
|
settings = {};
|
|
38521
38568
|
monitor;
|
|
@@ -39596,6 +39643,17 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
39596
39643
|
} catch {
|
|
39597
39644
|
}
|
|
39598
39645
|
}
|
|
39646
|
+
/**
|
|
39647
|
+
* Emit the queue-claim agent:ready event at most once per session. Both the
|
|
39648
|
+
* boot-time starting→idle one-shot and the fsmReadySeen re-arm call this; the
|
|
39649
|
+
* agentReadyEmitted guard ensures the second caller is a no-op so a worker is
|
|
39650
|
+
* never claimed twice and a queued task is never double-dispatched.
|
|
39651
|
+
*/
|
|
39652
|
+
emitAgentReadyOnce(chatTitle, now) {
|
|
39653
|
+
if (this.agentReadyEmitted) return;
|
|
39654
|
+
this.agentReadyEmitted = true;
|
|
39655
|
+
this.pushEvent({ event: "agent:ready", chatTitle, timestamp: now });
|
|
39656
|
+
}
|
|
39599
39657
|
detectStatusTransition() {
|
|
39600
39658
|
const now = Date.now();
|
|
39601
39659
|
const adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
@@ -39748,7 +39806,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
39748
39806
|
this.scheduleCompletedDebounceFlush(flushDelay);
|
|
39749
39807
|
}
|
|
39750
39808
|
} else if (newStatus === "idle" && this.lastStatus === "starting") {
|
|
39751
|
-
this.
|
|
39809
|
+
this.emitAgentReadyOnce(chatTitle, now);
|
|
39752
39810
|
} else if (newStatus === "error") {
|
|
39753
39811
|
if (this.generatingDebounceTimer) {
|
|
39754
39812
|
clearTimeout(this.generatingDebounceTimer);
|
|
@@ -39787,6 +39845,9 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
39787
39845
|
}
|
|
39788
39846
|
this.lastStatus = newStatus;
|
|
39789
39847
|
}
|
|
39848
|
+
if (newStatus === "idle" && adapterStatus.fsmReadySeen === true && !this.agentReadyEmitted) {
|
|
39849
|
+
this.emitAgentReadyOnce(chatTitle, now);
|
|
39850
|
+
}
|
|
39790
39851
|
this.applyProviderResponse(parsedStatus, {
|
|
39791
39852
|
phase: newStatus === "idle" && (previousStatus === "generating" || previousStatus === "waiting_approval") ? "turn_completed" : "immediate"
|
|
39792
39853
|
});
|
|
@@ -48138,9 +48199,12 @@ var meshEventsHandlers = {
|
|
|
48138
48199
|
mesh_forward_event: async (ctx, args) => {
|
|
48139
48200
|
return handleMeshForwardEvent({ instanceManager: ctx.deps.instanceManager }, args);
|
|
48140
48201
|
},
|
|
48141
|
-
get_pending_mesh_events: async (
|
|
48202
|
+
get_pending_mesh_events: async (ctx, args) => {
|
|
48142
48203
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
48143
48204
|
const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : void 0;
|
|
48205
|
+
if (meshId && shouldHoldPendingDrainForBusyLocalCoordinator(ctx.deps, meshId, coordinatorDaemonId)) {
|
|
48206
|
+
return { success: true, events: [], heldForBusyLocalCoordinator: true };
|
|
48207
|
+
}
|
|
48144
48208
|
const events = drainPendingMeshCoordinatorEvents(meshId || void 0, coordinatorDaemonId);
|
|
48145
48209
|
return { success: true, events };
|
|
48146
48210
|
},
|