@adhdev/daemon-standalone 1.0.28-rc.25 → 1.0.28-rc.26
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 +348 -31
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33311,10 +33311,10 @@ var require_dist3 = __commonJS({
|
|
|
33311
33311
|
}
|
|
33312
33312
|
function getDaemonBuildInfo() {
|
|
33313
33313
|
if (cached2) return cached2;
|
|
33314
|
-
const commit = readInjected(true ? "
|
|
33315
|
-
const commitShort = readInjected(true ? "
|
|
33316
|
-
const version2 = readInjected(true ? "1.0.28-rc.
|
|
33317
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
33314
|
+
const commit = readInjected(true ? "6eb8c9b32842573a3be53f868c84feb02358ac43" : void 0) ?? "unknown";
|
|
33315
|
+
const commitShort = readInjected(true ? "6eb8c9b3" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
33316
|
+
const version2 = readInjected(true ? "1.0.28-rc.26" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
33317
|
+
const builtAt = readInjected(true ? "2026-07-29T13:55:59.471Z" : void 0);
|
|
33318
33318
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
33319
33319
|
return cached2;
|
|
33320
33320
|
}
|
|
@@ -43586,8 +43586,8 @@ Next step: ${nextStep}`;
|
|
|
43586
43586
|
}
|
|
43587
43587
|
this.maybeCheckpointWal();
|
|
43588
43588
|
}
|
|
43589
|
-
countTurnOutboxByStatus() {
|
|
43590
|
-
const rows = this.db.prepare("SELECT status, COUNT(*) AS n FROM mesh_turn_outbox GROUP BY status").all();
|
|
43589
|
+
countTurnOutboxByStatus(meshId) {
|
|
43590
|
+
const rows = meshId ? this.db.prepare("SELECT status, COUNT(*) AS n FROM mesh_turn_outbox WHERE mesh_id = ? GROUP BY status").all(meshId) : this.db.prepare("SELECT status, COUNT(*) AS n FROM mesh_turn_outbox GROUP BY status").all();
|
|
43591
43591
|
const out = {};
|
|
43592
43592
|
for (const r of rows) out[r.status] = r.n;
|
|
43593
43593
|
return out;
|
|
@@ -57271,6 +57271,126 @@ ${cleanBody}`;
|
|
|
57271
57271
|
recentReadDebugSignatureBySession = /* @__PURE__ */ new Map();
|
|
57272
57272
|
}
|
|
57273
57273
|
});
|
|
57274
|
+
function readRecord6(value) {
|
|
57275
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
57276
|
+
}
|
|
57277
|
+
function readFiniteNumber(value) {
|
|
57278
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
57279
|
+
}
|
|
57280
|
+
function identitiesMatch(metadataEvent, evidence, attempt, eventSessionId) {
|
|
57281
|
+
const taskId = readNonEmptyString(metadataEvent.taskId);
|
|
57282
|
+
const attemptId = readNonEmptyString(metadataEvent.attemptId);
|
|
57283
|
+
const evidenceTaskId = readNonEmptyString(evidence.taskId);
|
|
57284
|
+
const evidenceAttemptId = readNonEmptyString(evidence.attemptId);
|
|
57285
|
+
const evidenceSessionId = readNonEmptyString(evidence.sessionId);
|
|
57286
|
+
const eventNonce = readFiniteNumber(metadataEvent.dispatchNonce);
|
|
57287
|
+
const evidenceNonce = readFiniteNumber(evidence.dispatchNonce);
|
|
57288
|
+
if (!taskId || !attemptId || !eventSessionId) return false;
|
|
57289
|
+
if (taskId !== attempt.taskId || attemptId !== attempt.attemptId) return false;
|
|
57290
|
+
if (evidenceTaskId !== taskId || evidenceAttemptId !== attemptId) return false;
|
|
57291
|
+
if (!evidenceSessionId || !sessionIdsEquivalent(evidenceSessionId, eventSessionId)) return false;
|
|
57292
|
+
if (!attempt.sessionId || !sessionIdsEquivalent(attempt.sessionId, eventSessionId)) return false;
|
|
57293
|
+
if (typeof attempt.dispatchNonce !== "number" || eventNonce !== attempt.dispatchNonce || evidenceNonce !== attempt.dispatchNonce) return false;
|
|
57294
|
+
return true;
|
|
57295
|
+
}
|
|
57296
|
+
function evaluateAuthoritativeTranscriptCompletion(args) {
|
|
57297
|
+
const { metadataEvent, eventSessionId, attempt } = args;
|
|
57298
|
+
const nowMs = args.nowMs ?? Date.now();
|
|
57299
|
+
if (!attempt || attempt.terminalOutcome || isTerminalTurnStage(attempt.stage)) {
|
|
57300
|
+
return { authoritative: false, reason: "attempt_missing_or_terminal" };
|
|
57301
|
+
}
|
|
57302
|
+
if (isWeakCompletionEvidence(metadataEvent)) {
|
|
57303
|
+
return { authoritative: false, reason: "weak_evidence" };
|
|
57304
|
+
}
|
|
57305
|
+
const diagnostic = readRecord6(metadataEvent.completionDiagnostic);
|
|
57306
|
+
const evidence = readRecord6(diagnostic?.transcriptEvidence);
|
|
57307
|
+
if (diagnostic?.finalAssistantPresent !== true || diagnostic?.cleanPath !== true || diagnostic?.evidenceWeak !== false || !evidence) {
|
|
57308
|
+
return { authoritative: false, reason: "not_clean_strong_evidence" };
|
|
57309
|
+
}
|
|
57310
|
+
if (evidence.version !== 1 || evidence.kind !== "final_assistant" || evidence.cleanPath !== true || evidence.weak !== false) {
|
|
57311
|
+
return { authoritative: false, reason: "invalid_evidence_contract" };
|
|
57312
|
+
}
|
|
57313
|
+
const authorityClass = readNonEmptyString(evidence.authorityClass);
|
|
57314
|
+
const timing = readNonEmptyString(evidence.timing);
|
|
57315
|
+
if (authorityClass !== "native-source" && authorityClass !== "pure-pty" || timing !== "floor" && timing !== "hold" && timing !== "immediate") {
|
|
57316
|
+
return { authoritative: false, reason: "non_transcript_authority_profile" };
|
|
57317
|
+
}
|
|
57318
|
+
const evidenceSource = readNonEmptyString(diagnostic.finalAssistantEvidenceSource);
|
|
57319
|
+
if (authorityClass === "native-source" && evidenceSource !== "external-native" || authorityClass === "pure-pty" && evidenceSource !== "parsed") {
|
|
57320
|
+
return { authoritative: false, reason: "evidence_source_profile_mismatch" };
|
|
57321
|
+
}
|
|
57322
|
+
const finalSummary = readNonEmptyString(metadataEvent.finalSummary);
|
|
57323
|
+
const finalContentLength = readFiniteNumber(evidence.finalContentLength) ?? 0;
|
|
57324
|
+
if (!finalSummary || finalContentLength <= 0) {
|
|
57325
|
+
return { authoritative: false, reason: "empty_final_content" };
|
|
57326
|
+
}
|
|
57327
|
+
if (!identitiesMatch(metadataEvent, evidence, attempt, eventSessionId)) {
|
|
57328
|
+
return { authoritative: false, reason: "causal_identity_mismatch" };
|
|
57329
|
+
}
|
|
57330
|
+
const observedAt = readFiniteNumber(evidence.observedAt);
|
|
57331
|
+
const eventTimestamp = readFiniteNumber(metadataEvent.timestamp);
|
|
57332
|
+
const turnStartedAt = readFiniteNumber(evidence.turnStartedAt);
|
|
57333
|
+
const acceptedAt = Date.parse(attempt.acceptedAt || attempt.createdAt);
|
|
57334
|
+
if (!observedAt || !eventTimestamp || !turnStartedAt) {
|
|
57335
|
+
return { authoritative: false, reason: "missing_evidence_timestamp" };
|
|
57336
|
+
}
|
|
57337
|
+
if (observedAt < turnStartedAt || eventTimestamp < turnStartedAt) {
|
|
57338
|
+
return { authoritative: false, reason: "pre_turn_evidence" };
|
|
57339
|
+
}
|
|
57340
|
+
if (Number.isFinite(acceptedAt) && (observedAt < acceptedAt - 2e3 || eventTimestamp < acceptedAt - 2e3)) {
|
|
57341
|
+
return { authoritative: false, reason: "pre_dispatch_evidence" };
|
|
57342
|
+
}
|
|
57343
|
+
if (observedAt > nowMs + 2e3 || eventTimestamp > nowMs + 2e3 || nowMs - observedAt > AUTHORITATIVE_COMPLETION_MAX_AGE_MS || nowMs - eventTimestamp > AUTHORITATIVE_COMPLETION_MAX_AGE_MS) {
|
|
57344
|
+
return { authoritative: false, reason: "stale_evidence_timestamp" };
|
|
57345
|
+
}
|
|
57346
|
+
const attemptUpdatedAt = Date.parse(attempt.updatedAt);
|
|
57347
|
+
return {
|
|
57348
|
+
authoritative: true,
|
|
57349
|
+
evidenceObservedAt: observedAt,
|
|
57350
|
+
attemptStage: attempt.stage,
|
|
57351
|
+
attemptUpdatedAt: Number.isFinite(attemptUpdatedAt) ? attemptUpdatedAt : null
|
|
57352
|
+
};
|
|
57353
|
+
}
|
|
57354
|
+
function authoritativeEvidenceOutranksLivePending(authority, live) {
|
|
57355
|
+
if (!authority.authoritative || live.pending !== true) return false;
|
|
57356
|
+
if (live.kind !== "modal" && live.kind !== "adapter") return false;
|
|
57357
|
+
if (live.kind === "modal" && (authority.attemptStage === "waiting_approval" || authority.attemptStage === "waiting_choice") && authority.attemptUpdatedAt !== null && authority.attemptUpdatedAt <= authority.evidenceObservedAt) {
|
|
57358
|
+
return true;
|
|
57359
|
+
}
|
|
57360
|
+
return typeof live.observedAt === "number" && Number.isFinite(live.observedAt) && live.observedAt <= authority.evidenceObservedAt;
|
|
57361
|
+
}
|
|
57362
|
+
function completionEligibleForLiveStateRetry(args) {
|
|
57363
|
+
const { metadataEvent, eventSessionId, attempt } = args;
|
|
57364
|
+
const nowMs = args.nowMs ?? Date.now();
|
|
57365
|
+
if (!evaluateAuthoritativeTranscriptCompletion({
|
|
57366
|
+
metadataEvent,
|
|
57367
|
+
eventSessionId,
|
|
57368
|
+
attempt,
|
|
57369
|
+
nowMs
|
|
57370
|
+
}).authoritative) return false;
|
|
57371
|
+
if (!attempt || attempt.terminalOutcome || isTerminalTurnStage(attempt.stage)) return false;
|
|
57372
|
+
const taskId = readNonEmptyString(metadataEvent.taskId);
|
|
57373
|
+
const attemptId = readNonEmptyString(metadataEvent.attemptId);
|
|
57374
|
+
const nonce = readFiniteNumber(metadataEvent.dispatchNonce);
|
|
57375
|
+
if (!taskId || taskId !== attempt.taskId || attemptId !== attempt.attemptId) return false;
|
|
57376
|
+
if (!attempt.sessionId || !sessionIdsEquivalent(attempt.sessionId, eventSessionId)) return false;
|
|
57377
|
+
if (typeof attempt.dispatchNonce !== "number" || nonce !== attempt.dispatchNonce) return false;
|
|
57378
|
+
const eventTimestamp = readFiniteNumber(metadataEvent.timestamp);
|
|
57379
|
+
const acceptedAt = Date.parse(attempt.acceptedAt || attempt.createdAt);
|
|
57380
|
+
if (!eventTimestamp || eventTimestamp > nowMs + 2e3 || nowMs - eventTimestamp > AUTHORITATIVE_COMPLETION_MAX_AGE_MS) return false;
|
|
57381
|
+
if (Number.isFinite(acceptedAt) && eventTimestamp < acceptedAt - 2e3) return false;
|
|
57382
|
+
return true;
|
|
57383
|
+
}
|
|
57384
|
+
var AUTHORITATIVE_COMPLETION_MAX_AGE_MS;
|
|
57385
|
+
var init_mesh_completion_live_gate = __esm2({
|
|
57386
|
+
"src/mesh/mesh-completion-live-gate.ts"() {
|
|
57387
|
+
"use strict";
|
|
57388
|
+
init_dist();
|
|
57389
|
+
init_mesh_turn_ledger();
|
|
57390
|
+
init_mesh_events_utils();
|
|
57391
|
+
AUTHORITATIVE_COMPLETION_MAX_AGE_MS = 6e4;
|
|
57392
|
+
}
|
|
57393
|
+
});
|
|
57274
57394
|
function bootstrapQueueTaskCountsAsHandled(task, bootstrapNodeId, nowMs) {
|
|
57275
57395
|
if (!meshNodeIdMatches({ id: task.targetNodeId }, bootstrapNodeId)) return false;
|
|
57276
57396
|
if (task.status === "assigned") return true;
|
|
@@ -57287,6 +57407,111 @@ ${cleanBody}`;
|
|
|
57287
57407
|
const machineId = readNonEmptyString(loadConfig2().machineId);
|
|
57288
57408
|
return expandDaemonIdForms([statusInstanceId, machineId]);
|
|
57289
57409
|
}
|
|
57410
|
+
function heldCompletionKey(meshId, taskId, attemptId, sessionId, nonce) {
|
|
57411
|
+
return `${meshId}${taskId}${attemptId}${sessionId}${nonce}`;
|
|
57412
|
+
}
|
|
57413
|
+
function readLivePendingEvidence(instance) {
|
|
57414
|
+
try {
|
|
57415
|
+
if (typeof instance?.getLiveTurnPendingEvidence === "function") {
|
|
57416
|
+
const evidence = instance.getLiveTurnPendingEvidence();
|
|
57417
|
+
if (evidence && typeof evidence === "object") {
|
|
57418
|
+
return {
|
|
57419
|
+
pending: evidence.pending === true,
|
|
57420
|
+
...evidence.kind === "adapter" || evidence.kind === "modal" || evidence.kind === "transcript_tool" ? { kind: evidence.kind } : {},
|
|
57421
|
+
...typeof evidence.observedAt === "number" && Number.isFinite(evidence.observedAt) ? { observedAt: evidence.observedAt } : {}
|
|
57422
|
+
};
|
|
57423
|
+
}
|
|
57424
|
+
}
|
|
57425
|
+
if (typeof instance?.hasLiveTurnPendingEvidence === "function") {
|
|
57426
|
+
return { pending: instance.hasLiveTurnPendingEvidence() === true };
|
|
57427
|
+
}
|
|
57428
|
+
} catch {
|
|
57429
|
+
}
|
|
57430
|
+
return { pending: false };
|
|
57431
|
+
}
|
|
57432
|
+
function scheduleHeldLiveStateCompletionDrain() {
|
|
57433
|
+
if (heldLiveStateCompletionTimer || heldLiveStateCompletions.size === 0) return;
|
|
57434
|
+
heldLiveStateCompletionTimer = setTimeout(() => {
|
|
57435
|
+
heldLiveStateCompletionTimer = null;
|
|
57436
|
+
drainHeldLiveStateCompletions();
|
|
57437
|
+
}, MID_TURN_COMPLETION_HOLD_RETRY_MS);
|
|
57438
|
+
heldLiveStateCompletionTimer.unref?.();
|
|
57439
|
+
}
|
|
57440
|
+
function drainHeldLiveStateCompletions(nowMs = Date.now()) {
|
|
57441
|
+
for (const [key2, held] of heldLiveStateCompletions) {
|
|
57442
|
+
if (nowMs < held.nextCheckAt) continue;
|
|
57443
|
+
if (nowMs >= held.expiresAt) {
|
|
57444
|
+
heldLiveStateCompletions.delete(key2);
|
|
57445
|
+
continue;
|
|
57446
|
+
}
|
|
57447
|
+
const attempt = MeshRuntimeStore.getInstance().getCurrentTurnAttempt(held.meshId, held.taskId);
|
|
57448
|
+
const identityStillCurrent = !!attempt && !attempt.terminalOutcome && attempt.attemptId === held.attemptId && sessionIdsEquivalent(attempt.sessionId, held.sessionId) && attempt.dispatchNonce === held.dispatchNonce;
|
|
57449
|
+
if (!identityStillCurrent) {
|
|
57450
|
+
heldLiveStateCompletions.delete(key2);
|
|
57451
|
+
continue;
|
|
57452
|
+
}
|
|
57453
|
+
const liveInstance = held.components.instanceManager?.getInstance?.(held.sessionId);
|
|
57454
|
+
if (!liveInstance) {
|
|
57455
|
+
heldLiveStateCompletions.delete(key2);
|
|
57456
|
+
continue;
|
|
57457
|
+
}
|
|
57458
|
+
const live = readLivePendingEvidence(liveInstance);
|
|
57459
|
+
if (live.pending) {
|
|
57460
|
+
held.nextCheckAt = nowMs + MID_TURN_COMPLETION_HOLD_RETRY_MS;
|
|
57461
|
+
continue;
|
|
57462
|
+
}
|
|
57463
|
+
heldLiveStateCompletions.delete(key2);
|
|
57464
|
+
injectMeshSystemMessage(held.components, {
|
|
57465
|
+
meshId: held.meshId,
|
|
57466
|
+
sourceInstanceId: held.sourceInstanceId,
|
|
57467
|
+
nodeId: held.nodeId,
|
|
57468
|
+
nodeLabel: held.nodeLabel,
|
|
57469
|
+
event: "agent:generating_completed",
|
|
57470
|
+
metadataEvent: {
|
|
57471
|
+
event: "agent:generating_completed",
|
|
57472
|
+
instanceId: held.sessionId,
|
|
57473
|
+
targetSessionId: held.sessionId,
|
|
57474
|
+
taskId: held.taskId,
|
|
57475
|
+
attemptId: held.attemptId,
|
|
57476
|
+
dispatchNonce: held.dispatchNonce,
|
|
57477
|
+
timestamp: held.eventTimestamp,
|
|
57478
|
+
...held.providerType ? { providerType: held.providerType } : {},
|
|
57479
|
+
completionDiagnostic: {
|
|
57480
|
+
source: "mid_turn_live_state_retry",
|
|
57481
|
+
contentFreeRetry: true
|
|
57482
|
+
}
|
|
57483
|
+
}
|
|
57484
|
+
});
|
|
57485
|
+
}
|
|
57486
|
+
scheduleHeldLiveStateCompletionDrain();
|
|
57487
|
+
}
|
|
57488
|
+
function holdCompletionForLiveStateRetry(components, args, eventSessionId, nowMs) {
|
|
57489
|
+
const taskId = readNonEmptyString(args.metadataEvent.taskId);
|
|
57490
|
+
const attemptId = readNonEmptyString(args.metadataEvent.attemptId);
|
|
57491
|
+
const dispatchNonce = typeof args.metadataEvent.dispatchNonce === "number" ? args.metadataEvent.dispatchNonce : NaN;
|
|
57492
|
+
const eventTimestamp = typeof args.metadataEvent.timestamp === "number" ? args.metadataEvent.timestamp : NaN;
|
|
57493
|
+
if (!taskId || !attemptId || !Number.isFinite(dispatchNonce) || !Number.isFinite(eventTimestamp)) return false;
|
|
57494
|
+
const key2 = heldCompletionKey(args.meshId, taskId, attemptId, eventSessionId, dispatchNonce);
|
|
57495
|
+
if (!heldLiveStateCompletions.has(key2)) {
|
|
57496
|
+
heldLiveStateCompletions.set(key2, {
|
|
57497
|
+
components,
|
|
57498
|
+
meshId: args.meshId,
|
|
57499
|
+
sourceInstanceId: args.sourceInstanceId,
|
|
57500
|
+
nodeId: args.nodeId,
|
|
57501
|
+
nodeLabel: args.nodeLabel,
|
|
57502
|
+
sessionId: eventSessionId,
|
|
57503
|
+
taskId,
|
|
57504
|
+
attemptId,
|
|
57505
|
+
dispatchNonce,
|
|
57506
|
+
providerType: readNonEmptyString(args.metadataEvent.providerType) || void 0,
|
|
57507
|
+
eventTimestamp,
|
|
57508
|
+
expiresAt: nowMs + MID_TURN_COMPLETION_HOLD_TTL_MS,
|
|
57509
|
+
nextCheckAt: nowMs + MID_TURN_COMPLETION_HOLD_RETRY_MS
|
|
57510
|
+
});
|
|
57511
|
+
}
|
|
57512
|
+
scheduleHeldLiveStateCompletionDrain();
|
|
57513
|
+
return true;
|
|
57514
|
+
}
|
|
57290
57515
|
function getCachedMeshByWorkspace(workspace) {
|
|
57291
57516
|
const now = Date.now();
|
|
57292
57517
|
const cached4 = meshByWorkspaceCache.get(workspace);
|
|
@@ -57576,19 +57801,38 @@ ${cleanBody}`;
|
|
|
57576
57801
|
}
|
|
57577
57802
|
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
57578
57803
|
const liveInstance = components.instanceManager?.getInstance?.(eventSessionId);
|
|
57579
|
-
if (typeof liveInstance?.hasLiveTurnPendingEvidence === "function") {
|
|
57580
|
-
|
|
57581
|
-
|
|
57582
|
-
|
|
57583
|
-
|
|
57584
|
-
|
|
57585
|
-
|
|
57586
|
-
|
|
57587
|
-
|
|
57588
|
-
|
|
57589
|
-
|
|
57590
|
-
|
|
57591
|
-
}
|
|
57804
|
+
if (typeof liveInstance?.getLiveTurnPendingEvidence === "function" || typeof liveInstance?.hasLiveTurnPendingEvidence === "function") {
|
|
57805
|
+
const live = readLivePendingEvidence(liveInstance);
|
|
57806
|
+
if (live.pending) {
|
|
57807
|
+
const taskId = readNonEmptyString(args.metadataEvent.taskId);
|
|
57808
|
+
const attempt = taskId ? MeshRuntimeStore.getInstance().getCurrentTurnAttempt(args.meshId, taskId) : null;
|
|
57809
|
+
const authority = evaluateAuthoritativeTranscriptCompletion({
|
|
57810
|
+
metadataEvent: args.metadataEvent,
|
|
57811
|
+
eventSessionId,
|
|
57812
|
+
attempt
|
|
57813
|
+
});
|
|
57814
|
+
if (authoritativeEvidenceOutranksLivePending(authority, live)) {
|
|
57815
|
+
LOG2.info("MeshEvents", `Accepted agent:generating_completed for session ${eventSessionId} (mesh ${args.meshId}): fresh clean-path transcript evidence for the current attempt is newer than the stale ${live.kind ?? "live"} snapshot`);
|
|
57816
|
+
} else {
|
|
57817
|
+
const retryEligible = completionEligibleForLiveStateRetry({
|
|
57818
|
+
metadataEvent: args.metadataEvent,
|
|
57819
|
+
eventSessionId,
|
|
57820
|
+
attempt
|
|
57821
|
+
});
|
|
57822
|
+
const heldForRetry = retryEligible && holdCompletionForLiveStateRetry(components, args, eventSessionId, Date.now());
|
|
57823
|
+
LOG2.info("MeshEvents", `Suppressed agent:generating_completed for session ${eventSessionId} (mesh ${args.meshId}): current live evidence remains pending (${live.kind ?? "unknown"}); transcript authority=${authority.authoritative ? "fresh_but_not_newer" : authority.reason}${heldForRetry ? " \u2014 bounded content-free retry armed" : ""}`);
|
|
57824
|
+
traceMeshEventDrop("mid_turn_live_state_pending", traceCtx, heldForRetry ? "retry_held" : void 0);
|
|
57825
|
+
return {
|
|
57826
|
+
kind: "suppress",
|
|
57827
|
+
result: {
|
|
57828
|
+
success: true,
|
|
57829
|
+
forwarded: 0,
|
|
57830
|
+
suppressed: true,
|
|
57831
|
+
midTurnLiveStatePending: true,
|
|
57832
|
+
...heldForRetry ? { completionRetryHeld: true } : {}
|
|
57833
|
+
}
|
|
57834
|
+
};
|
|
57835
|
+
}
|
|
57592
57836
|
}
|
|
57593
57837
|
}
|
|
57594
57838
|
if (!readNonEmptyString(args.metadataEvent.taskId) && !sessionHasActiveAssignment(args.meshId, eventSessionId) && !findRecentTerminalLedgerEvidence({ meshId: args.meshId, sessionId: eventSessionId, nodeId: eventNodeId || void 0 }) && isWeakCompletionEvidence(args.metadataEvent)) {
|
|
@@ -58490,6 +58734,8 @@ ${cleanBody}`;
|
|
|
58490
58734
|
// keeps event.taskId/meshActiveTaskId for free; this mirrors it for the remote relay.
|
|
58491
58735
|
// Same taskId/meshActiveTaskId ordering the local unroutable trace uses.
|
|
58492
58736
|
taskId: readNonEmptyString(payload.taskId) || readNonEmptyString(payload.meshActiveTaskId),
|
|
58737
|
+
attemptId: readNonEmptyString(payload.attemptId) || readNonEmptyString(payload.meshActiveAttemptId),
|
|
58738
|
+
...typeof payload.dispatchNonce === "number" ? { dispatchNonce: payload.dispatchNonce } : typeof payload.meshActiveDispatchNonce === "number" ? { dispatchNonce: payload.meshActiveDispatchNonce } : {},
|
|
58493
58739
|
targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId),
|
|
58494
58740
|
providerType: readNonEmptyString(payload.providerType),
|
|
58495
58741
|
providerSessionId: readNonEmptyString(payload.providerSessionId),
|
|
@@ -58516,6 +58762,7 @@ ${cleanBody}`;
|
|
|
58516
58762
|
providerName: readNonEmptyString(payload.providerName),
|
|
58517
58763
|
...payload.sessionSettings && typeof payload.sessionSettings === "object" && !Array.isArray(payload.sessionSettings) ? { sessionSettings: payload.sessionSettings } : {},
|
|
58518
58764
|
finalSummary: readNonEmptyString(payload.finalSummary) || readNonEmptyString(payload.summary),
|
|
58765
|
+
evidenceLevel: readNonEmptyString(payload.evidenceLevel),
|
|
58519
58766
|
// T2: carry the worker's status-snapshot last-message preview across the machine
|
|
58520
58767
|
// boundary so a summary-less completion still surfaces the assistant reply in the
|
|
58521
58768
|
// coordinator's inbox mirror. resolveMeshSurfacedSessionPreview reads these
|
|
@@ -58782,6 +59029,10 @@ ${cleanBody}`;
|
|
|
58782
59029
|
var REMOTE_IDLE_SESSION_TTL_MS;
|
|
58783
59030
|
var meshByWorkspaceCache;
|
|
58784
59031
|
var MESH_WORKSPACE_CACHE_TTL_MS;
|
|
59032
|
+
var MID_TURN_COMPLETION_HOLD_RETRY_MS;
|
|
59033
|
+
var MID_TURN_COMPLETION_HOLD_TTL_MS;
|
|
59034
|
+
var heldLiveStateCompletions;
|
|
59035
|
+
var heldLiveStateCompletionTimer;
|
|
58785
59036
|
var lastPendingEventsPruneAt;
|
|
58786
59037
|
var PENDING_EVENTS_PRUNE_INTERVAL_MS;
|
|
58787
59038
|
var INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS;
|
|
@@ -58816,9 +59067,14 @@ ${cleanBody}`;
|
|
|
58816
59067
|
init_mesh_turn_ledger();
|
|
58817
59068
|
init_mesh_turn_presentation();
|
|
58818
59069
|
init_mesh_queue_assignment();
|
|
59070
|
+
init_mesh_completion_live_gate();
|
|
58819
59071
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
58820
59072
|
meshByWorkspaceCache = /* @__PURE__ */ new Map();
|
|
58821
59073
|
MESH_WORKSPACE_CACHE_TTL_MS = 5e3;
|
|
59074
|
+
MID_TURN_COMPLETION_HOLD_RETRY_MS = 250;
|
|
59075
|
+
MID_TURN_COMPLETION_HOLD_TTL_MS = 5e3;
|
|
59076
|
+
heldLiveStateCompletions = /* @__PURE__ */ new Map();
|
|
59077
|
+
heldLiveStateCompletionTimer = null;
|
|
58822
59078
|
lastPendingEventsPruneAt = 0;
|
|
58823
59079
|
PENDING_EVENTS_PRUNE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
58824
59080
|
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
@@ -86891,6 +87147,43 @@ ${body}
|
|
|
86891
87147
|
isModalParked() {
|
|
86892
87148
|
return this.resolveModalParkStatus() !== null;
|
|
86893
87149
|
}
|
|
87150
|
+
/**
|
|
87151
|
+
* Provider-agnostic live-state observation for the mesh completion gate.
|
|
87152
|
+
* `observedAt` is the PTY snapshot clock, not the time this accessor ran:
|
|
87153
|
+
* after restart/rebind an old waiting_* frame must remain recognizably
|
|
87154
|
+
* older than a newly-written authoritative transcript final.
|
|
87155
|
+
*/
|
|
87156
|
+
getLiveTurnPendingEvidence() {
|
|
87157
|
+
const adapterPending = this.hasAdapterPendingResponse();
|
|
87158
|
+
const modalParked = this.isModalParked();
|
|
87159
|
+
if (adapterPending || modalParked) {
|
|
87160
|
+
let observedAt;
|
|
87161
|
+
try {
|
|
87162
|
+
const raw = this.adapter.getStatus({ allowParse: false });
|
|
87163
|
+
if (typeof raw?.lastOutputAt === "number" && Number.isFinite(raw.lastOutputAt)) {
|
|
87164
|
+
observedAt = raw.lastOutputAt;
|
|
87165
|
+
}
|
|
87166
|
+
} catch {
|
|
87167
|
+
}
|
|
87168
|
+
return {
|
|
87169
|
+
pending: true,
|
|
87170
|
+
kind: modalParked ? "modal" : "adapter",
|
|
87171
|
+
...observedAt !== void 0 ? { observedAt } : {}
|
|
87172
|
+
};
|
|
87173
|
+
}
|
|
87174
|
+
try {
|
|
87175
|
+
const probe = this.probeNativeTranscriptSignals();
|
|
87176
|
+
if (probe?.snapshot?.available === true && Array.isArray(probe.messages) && hasTrailingToolActivityAfterFinalAssistant(probe.messages)) {
|
|
87177
|
+
return {
|
|
87178
|
+
pending: true,
|
|
87179
|
+
kind: "transcript_tool",
|
|
87180
|
+
observedAt: probe.snapshot.sampledAt
|
|
87181
|
+
};
|
|
87182
|
+
}
|
|
87183
|
+
} catch {
|
|
87184
|
+
}
|
|
87185
|
+
return { pending: false };
|
|
87186
|
+
}
|
|
86894
87187
|
/**
|
|
86895
87188
|
* MID-TURN-LIVE-STATE-GATE (broader false-idle RCA, mid-turn follow-up): a live,
|
|
86896
87189
|
* synchronous re-check of whether this session's CURRENT turn genuinely still has
|
|
@@ -86925,15 +87218,7 @@ ${body}
|
|
|
86925
87218
|
* can never wedge a session as "pending" forever.
|
|
86926
87219
|
*/
|
|
86927
87220
|
hasLiveTurnPendingEvidence() {
|
|
86928
|
-
|
|
86929
|
-
try {
|
|
86930
|
-
const probe = this.probeNativeTranscriptSignals();
|
|
86931
|
-
if (probe?.snapshot?.available === true && Array.isArray(probe.messages)) {
|
|
86932
|
-
if (hasTrailingToolActivityAfterFinalAssistant(probe.messages)) return true;
|
|
86933
|
-
}
|
|
86934
|
-
} catch {
|
|
86935
|
-
}
|
|
86936
|
-
return false;
|
|
87221
|
+
return this.getLiveTurnPendingEvidence().pending;
|
|
86937
87222
|
}
|
|
86938
87223
|
/**
|
|
86939
87224
|
* PTY-OVERTRUST-DRAIN (Defect B). The deliverability/drain status the mesh
|
|
@@ -87622,8 +87907,12 @@ ${body}
|
|
|
87622
87907
|
LOG2.debug("CLI", `[${this.type}] finalAssistantEvidence: present=${finalAssistantEvidence.present} source=${finalAssistantEvidence.source} adapterOwnsMessagesElsewhere=${adapterOwnsMessagesElsewhere} parsedStatus=${parsedStatus}`);
|
|
87623
87908
|
if (finalAssistantEvidence.present && finalAssistantEvidence.source !== "unavailable") {
|
|
87624
87909
|
pending.resolvedFinalMessages = Array.isArray(finalAssistantEvidence.messages) ? finalAssistantEvidence.messages : void 0;
|
|
87910
|
+
pending.resolvedFinalEvidenceSource = finalAssistantEvidence.source;
|
|
87911
|
+
pending.resolvedFinalEvidenceObservedAt = Date.now();
|
|
87625
87912
|
} else {
|
|
87626
87913
|
pending.resolvedFinalMessages = void 0;
|
|
87914
|
+
pending.resolvedFinalEvidenceSource = void 0;
|
|
87915
|
+
pending.resolvedFinalEvidenceObservedAt = void 0;
|
|
87627
87916
|
}
|
|
87628
87917
|
if (!finalAssistantEvidence.present) {
|
|
87629
87918
|
if (adapterOwnsMessagesElsewhere) {
|
|
@@ -88579,12 +88868,40 @@ ${body}
|
|
|
88579
88868
|
duration: pending.duration,
|
|
88580
88869
|
busyEpoch: this.busyEpoch
|
|
88581
88870
|
});
|
|
88871
|
+
const finalSummary = this.cleanCompletionFinalSummary(pending);
|
|
88872
|
+
const transcriptProfile = resolveTranscriptAuthorityProfile(this.provider);
|
|
88873
|
+
const finalContentLength = typeof finalSummary === "string" ? finalSummary.trim().length : 0;
|
|
88582
88874
|
this.emitGeneratingCompleted({
|
|
88583
88875
|
chatTitle: pending.chatTitle,
|
|
88584
88876
|
duration: pending.duration,
|
|
88585
88877
|
timestamp: pending.timestamp,
|
|
88586
88878
|
taskId: pending.taskId,
|
|
88587
|
-
finalSummary
|
|
88879
|
+
finalSummary,
|
|
88880
|
+
evidenceLevel: "transcript",
|
|
88881
|
+
completionDiagnostic: {
|
|
88882
|
+
source: "clean_final_assistant",
|
|
88883
|
+
cleanPath: true,
|
|
88884
|
+
evidenceWeak: false,
|
|
88885
|
+
finalAssistantPresent: true,
|
|
88886
|
+
finalAssistantEvidenceSource: pending.resolvedFinalEvidenceSource ?? "parsed",
|
|
88887
|
+
finalAssistantContentLength: finalContentLength,
|
|
88888
|
+
transcriptEvidence: {
|
|
88889
|
+
version: 1,
|
|
88890
|
+
kind: "final_assistant",
|
|
88891
|
+
cleanPath: true,
|
|
88892
|
+
weak: false,
|
|
88893
|
+
authorityClass: transcriptProfile.class,
|
|
88894
|
+
timing: transcriptProfile.timing,
|
|
88895
|
+
providerOwnsTranscript: transcriptProfile.providerOwnsTranscript,
|
|
88896
|
+
observedAt: pending.resolvedFinalEvidenceObservedAt ?? Date.now(),
|
|
88897
|
+
turnStartedAt: pending.turnStartedAt ?? null,
|
|
88898
|
+
finalContentLength,
|
|
88899
|
+
taskId: pending.taskId ?? null,
|
|
88900
|
+
attemptId: typeof this.settings.meshActiveAttemptId === "string" ? this.settings.meshActiveAttemptId : null,
|
|
88901
|
+
dispatchNonce: typeof this.settings.meshActiveDispatchNonce === "number" ? this.settings.meshActiveDispatchNonce : null,
|
|
88902
|
+
sessionId: this.instanceId
|
|
88903
|
+
}
|
|
88904
|
+
}
|
|
88588
88905
|
});
|
|
88589
88906
|
this.completedDebouncePending = null;
|
|
88590
88907
|
this.completedDebounceTimer = null;
|
|
@@ -100783,7 +101100,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
100783
101100
|
return "";
|
|
100784
101101
|
}
|
|
100785
101102
|
}
|
|
100786
|
-
function
|
|
101103
|
+
function readRecord7(repoRoot) {
|
|
100787
101104
|
const path50 = (0, import_node_path3.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
100788
101105
|
if (!(0, import_node_fs4.existsSync)(path50)) return null;
|
|
100789
101106
|
try {
|
|
@@ -100824,7 +101141,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
100824
101141
|
function buildPreviewFreshness(repoRoot) {
|
|
100825
101142
|
if (!isPreviewPipelineConfigured(repoRoot)) return null;
|
|
100826
101143
|
const current = readCurrentMainCommit(repoRoot);
|
|
100827
|
-
const record2 =
|
|
101144
|
+
const record2 = readRecord7(repoRoot);
|
|
100828
101145
|
const lastPreviewCommit = normalizeCommit(record2?.lastPreviewCommit);
|
|
100829
101146
|
const targets = readTargetFreshness(record2, current.currentMainCommit);
|
|
100830
101147
|
let status = "unknown";
|