@adhdev/daemon-core 1.0.21-rc.3 → 1.0.21-rc.5
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-adapters/provider-cli-shared.d.ts +11 -1
- package/dist/index.js +83 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -25
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-completion-synthesis.d.ts +10 -1
- package/dist/mesh/mesh-events-stale.d.ts +21 -0
- package/dist/providers/spec/fsm-types.d.ts +3 -0
- package/package.json +3 -3
- package/src/cli-adapters/provider-cli-shared.ts +11 -1
- package/src/mesh/mesh-completion-synthesis.ts +31 -2
- package/src/mesh/mesh-events-stale.ts +28 -3
- package/src/mesh/mesh-reconcile-loop.ts +84 -13
- package/src/providers/cli-provider-instance.ts +60 -6
- package/src/providers/provider-schema.ts +1 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +6 -1
- package/src/providers/spec/fsm-types.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -786,10 +786,10 @@ function readInjected(value) {
|
|
|
786
786
|
}
|
|
787
787
|
function getDaemonBuildInfo() {
|
|
788
788
|
if (cached) return cached;
|
|
789
|
-
const commit = readInjected(true ? "
|
|
790
|
-
const commitShort = readInjected(true ? "
|
|
791
|
-
const version = readInjected(true ? "1.0.21-rc.
|
|
792
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
789
|
+
const commit = readInjected(true ? "57d6b342db3f9f235038696295dbc4761e227e3c" : void 0) ?? "unknown";
|
|
790
|
+
const commitShort = readInjected(true ? "57d6b342" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
791
|
+
const version = readInjected(true ? "1.0.21-rc.5" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
792
|
+
const builtAt = readInjected(true ? "2026-07-24T01:20:44.122Z" : void 0);
|
|
793
793
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
794
794
|
return cached;
|
|
795
795
|
}
|
|
@@ -16375,13 +16375,13 @@ function reconcileDirectDispatchCompletionFromTranscript(args) {
|
|
|
16375
16375
|
});
|
|
16376
16376
|
const workerResult = evidence.workerResult;
|
|
16377
16377
|
const selfAttributing = workerResult.source === "final_summary_json";
|
|
16378
|
-
const dispatchTime = dispatch?.timestamp ? new Date(dispatch.timestamp).getTime() : Number.NaN;
|
|
16378
|
+
const dispatchTime = dispatch?.timestamp ? new Date(dispatch.timestamp).getTime() : args.dispatchTimestamp ? new Date(args.dispatchTimestamp).getTime() : Number.NaN;
|
|
16379
16379
|
const transcriptTime = args.transcriptMessageAt ? new Date(args.transcriptMessageAt).getTime() : Number.NaN;
|
|
16380
16380
|
const transcriptAfterDispatch = Number.isFinite(dispatchTime) && Number.isFinite(transcriptTime) && transcriptTime >= dispatchTime;
|
|
16381
|
-
if (workerResult.source !== "final_summary_json" && !transcriptAfterDispatch) {
|
|
16381
|
+
if (!args.preValidatedTranscriptEvidence && workerResult.source !== "final_summary_json" && !transcriptAfterDispatch) {
|
|
16382
16382
|
return { reconciled: false, reason: "transcript_not_proven_after_dispatch" };
|
|
16383
16383
|
}
|
|
16384
|
-
if (Number.isFinite(dispatchTime) && workerResult.source !== "final_summary_json") {
|
|
16384
|
+
if (!args.preValidatedTranscriptEvidence && Number.isFinite(dispatchTime) && workerResult.source !== "final_summary_json") {
|
|
16385
16385
|
const dispatchedToIdleSession = dispatch?.payload?.dispatchedToIdleSession === true;
|
|
16386
16386
|
const graceMs = dispatchedToIdleSession ? DIRECT_DISPATCH_IDLE_SESSION_RECONCILE_GRACE_MS : DIRECT_DISPATCH_RECONCILE_GRACE_MS;
|
|
16387
16387
|
if (Date.now() - dispatchTime < graceMs) {
|
|
@@ -24610,7 +24610,15 @@ async function pollAssignedTaskTerminalEvidence(components, mesh, row) {
|
|
|
24610
24610
|
if (!(Number.isFinite(dispatchedAtMs) && Number.isFinite(transcriptAtMs) && transcriptAtMs >= dispatchedAtMs)) {
|
|
24611
24611
|
return null;
|
|
24612
24612
|
}
|
|
24613
|
-
return
|
|
24613
|
+
return {
|
|
24614
|
+
outcome: "completed",
|
|
24615
|
+
finalSummary: evidence.finalSummary,
|
|
24616
|
+
...evidence.transcriptMessageAt ? { transcriptMessageAt: evidence.transcriptMessageAt } : {},
|
|
24617
|
+
...readNonEmptyString(payload.providerSessionId) ? { providerSessionId: readNonEmptyString(payload.providerSessionId) } : {},
|
|
24618
|
+
...providerType ? { providerType } : {},
|
|
24619
|
+
...nodeId ? { nodeId } : {},
|
|
24620
|
+
sessionId
|
|
24621
|
+
};
|
|
24614
24622
|
}
|
|
24615
24623
|
var init_mesh_completion_synthesis = __esm({
|
|
24616
24624
|
"src/mesh/mesh-completion-synthesis.ts"() {
|
|
@@ -24962,6 +24970,32 @@ async function evaluateEarlyIdleTranscriptArm(components, mesh, store, row, loca
|
|
|
24962
24970
|
}
|
|
24963
24971
|
return verdict === "UNKNOWN";
|
|
24964
24972
|
}
|
|
24973
|
+
function propagateWatchdogTranscriptCompletion(meshId, row, evidence, source) {
|
|
24974
|
+
const sessionId = readNonEmptyString(row.assignedSessionId) || evidence.sessionId;
|
|
24975
|
+
if (!sessionId || !readNonEmptyString(evidence.finalSummary)) {
|
|
24976
|
+
return false;
|
|
24977
|
+
}
|
|
24978
|
+
try {
|
|
24979
|
+
const result = reconcileDirectDispatchCompletionFromTranscript({
|
|
24980
|
+
meshId,
|
|
24981
|
+
nodeId: readNonEmptyString(row.assignedNodeId) || evidence.nodeId,
|
|
24982
|
+
sessionId,
|
|
24983
|
+
providerType: readNonEmptyString(row.assignedProviderType) || evidence.providerType,
|
|
24984
|
+
providerSessionId: evidence.providerSessionId,
|
|
24985
|
+
taskId: row.id,
|
|
24986
|
+
finalSummary: evidence.finalSummary,
|
|
24987
|
+
...evidence.transcriptMessageAt ? { transcriptMessageAt: evidence.transcriptMessageAt } : {},
|
|
24988
|
+
...readNonEmptyString(row.dispatchTimestamp) ? { dispatchTimestamp: readNonEmptyString(row.dispatchTimestamp) } : {},
|
|
24989
|
+
// The watchdog poll already enforced idle + post-dispatch + no-trailing-tool + streak;
|
|
24990
|
+
// skip the reconcile's own grace/transcript_not_proven gates (dedup backstops remain).
|
|
24991
|
+
preValidatedTranscriptEvidence: true,
|
|
24992
|
+
source
|
|
24993
|
+
});
|
|
24994
|
+
return result.reconciled || result.alreadyTerminal === true;
|
|
24995
|
+
} catch {
|
|
24996
|
+
return false;
|
|
24997
|
+
}
|
|
24998
|
+
}
|
|
24965
24999
|
async function recoverStrandedAssignedDispatches(components, mesh, store, localDaemonId, selfIds = []) {
|
|
24966
25000
|
const meshId = mesh.id;
|
|
24967
25001
|
const assigned = getQueue(meshId, { status: ["assigned"] });
|
|
@@ -24992,11 +25026,17 @@ async function recoverStrandedAssignedDispatches(components, mesh, store, localD
|
|
|
24992
25026
|
const terminalEvidence = await pollAssignedTaskTerminalEvidence(components, mesh, row);
|
|
24993
25027
|
if (terminalEvidence) {
|
|
24994
25028
|
assignedIdleFinalAssistantSince.delete(idleTranscriptStreakKey);
|
|
24995
|
-
updateTaskStatus(meshId, row.id, terminalEvidence);
|
|
24996
|
-
|
|
25029
|
+
updateTaskStatus(meshId, row.id, terminalEvidence.outcome);
|
|
25030
|
+
const propagated = propagateWatchdogTranscriptCompletion(
|
|
25031
|
+
meshId,
|
|
25032
|
+
row,
|
|
25033
|
+
terminalEvidence,
|
|
25034
|
+
"early_idle_transcript_evidence"
|
|
25035
|
+
);
|
|
25036
|
+
if (!propagated && !findTerminalLedgerEvidenceForTask({ meshId, taskId: row.id })) {
|
|
24997
25037
|
try {
|
|
24998
25038
|
appendLedgerEntry(meshId, {
|
|
24999
|
-
kind: terminalEvidence === "completed" ? "task_completed" : "task_failed",
|
|
25039
|
+
kind: terminalEvidence.outcome === "completed" ? "task_completed" : "task_failed",
|
|
25000
25040
|
nodeId: row.assignedNodeId,
|
|
25001
25041
|
sessionId: row.assignedSessionId,
|
|
25002
25042
|
providerType: row.assignedProviderType,
|
|
@@ -25009,14 +25049,14 @@ async function recoverStrandedAssignedDispatches(components, mesh, store, localD
|
|
|
25009
25049
|
} catch {
|
|
25010
25050
|
}
|
|
25011
25051
|
}
|
|
25012
|
-
LOG.warn("MeshReconcile", `Early-completed assigned task ${row.id} on mesh ${meshId} (node=${row.assignedNodeId ?? "?"} session=${row.assignedSessionId ?? "?"}): worker idle with a final assistant message after dispatch for \u2265${Math.round(ASSIGNED_IDLE_TRANSCRIPT_COMPLETE_MS / 1e3)}s \u2014 the completion event was lost/late (pure-PTY provider), task is ${terminalEvidence} without waiting the 15-min deadline`);
|
|
25013
|
-
|
|
25052
|
+
LOG.warn("MeshReconcile", `Early-completed assigned task ${row.id} on mesh ${meshId} (node=${row.assignedNodeId ?? "?"} session=${row.assignedSessionId ?? "?"}): worker idle with a final assistant message after dispatch for \u2265${Math.round(ASSIGNED_IDLE_TRANSCRIPT_COMPLETE_MS / 1e3)}s \u2014 the completion event was lost/late (pure-PTY provider), task is ${terminalEvidence.outcome} without waiting the 15-min deadline${propagated ? " (finalSummary propagated to coordinator)" : ""}`);
|
|
25053
|
+
traceMeshEventStage("assigned_early_transcript_completed", {
|
|
25014
25054
|
taskId: row.id,
|
|
25015
25055
|
sessionId: row.assignedSessionId,
|
|
25016
25056
|
nodeId: row.assignedNodeId,
|
|
25017
25057
|
meshId,
|
|
25018
25058
|
event: "agent:generating_completed"
|
|
25019
|
-
}, terminalEvidence);
|
|
25059
|
+
}, propagated ? "propagated" : terminalEvidence.outcome);
|
|
25020
25060
|
continue;
|
|
25021
25061
|
}
|
|
25022
25062
|
assignedIdleFinalAssistantSince.delete(idleTranscriptStreakKey);
|
|
@@ -25154,11 +25194,17 @@ async function recoverStrandedAssignedDispatches(components, mesh, store, localD
|
|
|
25154
25194
|
const terminalEvidence = await pollAssignedTaskTerminalEvidence(components, mesh, row);
|
|
25155
25195
|
if (terminalEvidence) {
|
|
25156
25196
|
deliveredNoTurnUnknownStreak.delete(streakKey);
|
|
25157
|
-
updateTaskStatus(meshId, row.id, terminalEvidence);
|
|
25158
|
-
|
|
25197
|
+
updateTaskStatus(meshId, row.id, terminalEvidence.outcome);
|
|
25198
|
+
const propagated = propagateWatchdogTranscriptCompletion(
|
|
25199
|
+
meshId,
|
|
25200
|
+
row,
|
|
25201
|
+
terminalEvidence,
|
|
25202
|
+
"redrive_deadline_transcript_evidence"
|
|
25203
|
+
);
|
|
25204
|
+
if (!propagated && !findTerminalLedgerEvidenceForTask({ meshId, taskId: row.id })) {
|
|
25159
25205
|
try {
|
|
25160
25206
|
appendLedgerEntry(meshId, {
|
|
25161
|
-
kind: terminalEvidence === "completed" ? "task_completed" : "task_failed",
|
|
25207
|
+
kind: terminalEvidence.outcome === "completed" ? "task_completed" : "task_failed",
|
|
25162
25208
|
nodeId: row.assignedNodeId,
|
|
25163
25209
|
sessionId: row.assignedSessionId,
|
|
25164
25210
|
providerType: row.assignedProviderType,
|
|
@@ -25171,14 +25217,14 @@ async function recoverStrandedAssignedDispatches(components, mesh, store, localD
|
|
|
25171
25217
|
} catch {
|
|
25172
25218
|
}
|
|
25173
25219
|
}
|
|
25174
|
-
LOG.warn("MeshReconcile", `Skipped delivered-no-turn re-drive for task ${row.id} on mesh ${meshId} (node=${row.assignedNodeId ?? "?"} session=${row.assignedSessionId ?? "?"}): worker transcript is idle with a final assistant message after dispatch \u2014 the completion event was lost/late, task is ${terminalEvidence}, NOT re-driving`);
|
|
25175
|
-
|
|
25220
|
+
LOG.warn("MeshReconcile", `Skipped delivered-no-turn re-drive for task ${row.id} on mesh ${meshId} (node=${row.assignedNodeId ?? "?"} session=${row.assignedSessionId ?? "?"}): worker transcript is idle with a final assistant message after dispatch \u2014 the completion event was lost/late, task is ${terminalEvidence.outcome}, NOT re-driving${propagated ? " (finalSummary propagated to coordinator)" : ""}`);
|
|
25221
|
+
traceMeshEventStage("redrive_deadline_transcript_completed", {
|
|
25176
25222
|
taskId: row.id,
|
|
25177
25223
|
sessionId: row.assignedSessionId,
|
|
25178
25224
|
nodeId: row.assignedNodeId,
|
|
25179
25225
|
meshId,
|
|
25180
25226
|
event: "agent:generating_completed"
|
|
25181
|
-
}, `${reclaimReason} \u2192 transcript ${terminalEvidence}`);
|
|
25227
|
+
}, `${reclaimReason} \u2192 transcript ${terminalEvidence.outcome}${propagated ? " propagated" : ""}`);
|
|
25182
25228
|
continue;
|
|
25183
25229
|
}
|
|
25184
25230
|
const reclaimedLost = reclaimStrandedAssignedTask(meshId, row.id, {
|
|
@@ -26092,7 +26138,12 @@ var init_provider_schema = __esm({
|
|
|
26092
26138
|
requiresFinalAssistantBeforeIdle: {
|
|
26093
26139
|
type: "boolean",
|
|
26094
26140
|
default: false,
|
|
26095
|
-
description: "When true, daemon defers generating\u2192idle until parseSession includes a final standard assistant message."
|
|
26141
|
+
description: "When true, daemon defers generating\u2192idle until parseSession includes a final standard assistant message. Also selects the completion-timing floor for a native-source provider: an idle without a final assistant reply is treated as a possible mid-tool-call quiet valley, so the decoupled CANON-C completion is held under the min-elapsed floor (noExternalTranscriptSource) rather than emitted immediately. A provider that leaves this false is a write-lag native source (e.g. claude-cli) whose transcript merely trails the finished idle by a write, so it emits immediately."
|
|
26142
|
+
},
|
|
26143
|
+
holdCompletionForTranscript: {
|
|
26144
|
+
type: "boolean",
|
|
26145
|
+
default: false,
|
|
26146
|
+
description: "Completion-timing authority for a native-history provider whose live idle verdict is PTY-derived but whose authoritative answer lands in native history (e.g. antigravity-cli). When true, an idle-without-final-assistant HOLDS for the native transcript to land (holdForTranscript) instead of emitting or applying the min-elapsed floor, and the hold persists past the 30s finalization cap while the PTY is still active (bounded by the hard cap). This is the third completion-timing class alongside immediate (requiresFinalAssistantBeforeIdle=false) and floor (requiresFinalAssistantBeforeIdle=true)."
|
|
26096
26147
|
},
|
|
26097
26148
|
augmentStaleSnapshot: {
|
|
26098
26149
|
type: "boolean",
|
|
@@ -50869,7 +50920,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
50869
50920
|
if (probe?.lastRole === "assistant" && (probe.contentLen ?? 0) > 0) {
|
|
50870
50921
|
return null;
|
|
50871
50922
|
}
|
|
50872
|
-
if (this.
|
|
50923
|
+
if (this.provider?.holdCompletionForTranscript === true) {
|
|
50873
50924
|
if (allowMissingAssistantTimeout) {
|
|
50874
50925
|
return { reason: "missing_final_assistant", terminal: false, holdForTranscript: true };
|
|
50875
50926
|
}
|
|
@@ -50878,10 +50929,16 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
50878
50929
|
if (allowMissingAssistantTimeout && pending.previousStatus === "waiting_approval") {
|
|
50879
50930
|
return { reason: "missing_final_assistant", terminal: false, holdForTranscript: true };
|
|
50880
50931
|
}
|
|
50881
|
-
|
|
50932
|
+
const isWriteLagNativeSource = this.provider.requiresFinalAssistantBeforeIdle !== true;
|
|
50933
|
+
return {
|
|
50934
|
+
reason: "missing_final_assistant",
|
|
50935
|
+
terminal: true,
|
|
50936
|
+
allowTimeout: allowMissingAssistantTimeout,
|
|
50937
|
+
...isWriteLagNativeSource ? {} : { noExternalTranscriptSource: true }
|
|
50938
|
+
};
|
|
50882
50939
|
}
|
|
50883
50940
|
if (this.provider.requiresFinalAssistantBeforeIdle === true) {
|
|
50884
|
-
return { reason: "missing_final_assistant", terminal: true, allowTimeout: allowMissingAssistantTimeout };
|
|
50941
|
+
return { reason: "missing_final_assistant", terminal: true, allowTimeout: allowMissingAssistantTimeout, noExternalTranscriptSource: true };
|
|
50885
50942
|
}
|
|
50886
50943
|
} else {
|
|
50887
50944
|
LOG.debug("CLI", `[${this.type}] missing_final_assistant (not ownsExternal) requiresFinalAssistant=${!!this.provider.requiresFinalAssistantBeforeIdle}`);
|
|
@@ -51657,7 +51714,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
51657
51714
|
this.scheduleCompletedDebounceFlush(COMPLETED_FINALIZATION_RETRY_MS);
|
|
51658
51715
|
return;
|
|
51659
51716
|
}
|
|
51660
|
-
if (this.
|
|
51717
|
+
if (this.provider?.holdCompletionForTranscript === true && block2.holdForTranscript === true && waitedMs < ANTIGRAVITY_HOLD_HARD_CAP_MS && this.antigravityHoldPtyStillActive()) {
|
|
51661
51718
|
if (pending.loggedBlockReason !== "antigravity_hold_pty_active") {
|
|
51662
51719
|
LOG.info("CLI", `[${this.type}] 30s cap reached but PTY still generating; holding antigravity completion past cap (waitedMs=${waitedMs} hardCap=${ANTIGRAVITY_HOLD_HARD_CAP_MS}) (${blockReason})`);
|
|
51663
51720
|
if (this.isMeshWorkerSession()) {
|
|
@@ -55800,6 +55857,7 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
|
|
|
55800
55857
|
"submitStrategy",
|
|
55801
55858
|
"requirePromptEchoBeforeSubmit",
|
|
55802
55859
|
"requiresFinalAssistantBeforeIdle",
|
|
55860
|
+
"holdCompletionForTranscript",
|
|
55803
55861
|
"augmentStaleSnapshot",
|
|
55804
55862
|
"timeouts",
|
|
55805
55863
|
"disableUpstream"
|