adhdev 0.9.82-rc.24 → 0.9.82-rc.25
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 +70 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +70 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -3964,18 +3964,20 @@ function requeueTask(meshId, taskId, opts) {
|
|
|
3964
3964
|
return entry;
|
|
3965
3965
|
});
|
|
3966
3966
|
}
|
|
3967
|
-
function updateSessionTaskStatus(meshId, sessionId, status) {
|
|
3967
|
+
function updateSessionTaskStatus(meshId, sessionId, status, opts) {
|
|
3968
3968
|
return withQueueLock(meshId, () => {
|
|
3969
3969
|
const queue = readQueue(meshId);
|
|
3970
|
+
const occurredAtTime = opts?.occurredAt ? new Date(opts.occurredAt).getTime() : Number.NaN;
|
|
3971
|
+
const hasOccurredAt = Number.isFinite(occurredAtTime);
|
|
3970
3972
|
let bestIdx = -1;
|
|
3971
3973
|
let bestTime = 0;
|
|
3972
3974
|
for (let i = queue.length - 1; i >= 0; i--) {
|
|
3973
|
-
if (queue[i].assignedSessionId
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3975
|
+
if (queue[i].assignedSessionId !== sessionId || queue[i].status !== "assigned") continue;
|
|
3976
|
+
const time3 = new Date(queue[i].dispatchTimestamp || queue[i].updatedAt).getTime();
|
|
3977
|
+
if (hasOccurredAt && Number.isFinite(time3) && time3 > occurredAtTime) continue;
|
|
3978
|
+
if (time3 > bestTime) {
|
|
3979
|
+
bestTime = time3;
|
|
3980
|
+
bestIdx = i;
|
|
3979
3981
|
}
|
|
3980
3982
|
}
|
|
3981
3983
|
if (bestIdx === -1) return null;
|
|
@@ -4501,6 +4503,38 @@ function shouldSuppressIntentionalCleanupStop(args) {
|
|
|
4501
4503
|
if (isIntentionalCleanupStopMetadata(args.metadataEvent)) return true;
|
|
4502
4504
|
return hasRecentIntentionalCleanupStop(args.meshId, args.sessionId, args.nodeId);
|
|
4503
4505
|
}
|
|
4506
|
+
function readEventTimestamp(value) {
|
|
4507
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
4508
|
+
if (typeof value === "string" && value.trim()) {
|
|
4509
|
+
const numeric = Number(value);
|
|
4510
|
+
if (Number.isFinite(numeric)) return numeric;
|
|
4511
|
+
const parsed = Date.parse(value);
|
|
4512
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
4513
|
+
}
|
|
4514
|
+
return null;
|
|
4515
|
+
}
|
|
4516
|
+
function buildMeshCompletionFingerprint(args) {
|
|
4517
|
+
const timestampPart = Number.isFinite(args.timestamp) ? String(args.timestamp) : readNonEmptyString(args.finalSummary).slice(0, 200);
|
|
4518
|
+
return [
|
|
4519
|
+
args.meshId,
|
|
4520
|
+
args.event,
|
|
4521
|
+
args.sessionId,
|
|
4522
|
+
args.providerType || "",
|
|
4523
|
+
args.providerSessionId || "",
|
|
4524
|
+
timestampPart
|
|
4525
|
+
].join("::");
|
|
4526
|
+
}
|
|
4527
|
+
function isDuplicateMeshCompletionEvent(args) {
|
|
4528
|
+
const fingerprint = buildMeshCompletionFingerprint(args);
|
|
4529
|
+
if (!fingerprint) return false;
|
|
4530
|
+
const now = Date.now();
|
|
4531
|
+
for (const [key, seenAt] of recentCompletionFingerprints.entries()) {
|
|
4532
|
+
if (now - seenAt > RECENT_COMPLETION_FINGERPRINT_TTL_MS) recentCompletionFingerprints.delete(key);
|
|
4533
|
+
}
|
|
4534
|
+
if (recentCompletionFingerprints.has(fingerprint)) return true;
|
|
4535
|
+
recentCompletionFingerprints.set(fingerprint, now);
|
|
4536
|
+
return false;
|
|
4537
|
+
}
|
|
4504
4538
|
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
|
|
4505
4539
|
const task = claimNextTask(meshId, nodeId, sessionId);
|
|
4506
4540
|
if (!task) {
|
|
@@ -4862,13 +4896,31 @@ function injectMeshSystemMessage(components, args) {
|
|
|
4862
4896
|
LOG.info("MeshEvents", `Suppressed ${args.event} for intentionally cleanup-stopped session ${eventSessionId || "(unknown session)"}`);
|
|
4863
4897
|
return { success: true, forwarded: 0, suppressed: true, intentionalCleanupStop: true };
|
|
4864
4898
|
}
|
|
4899
|
+
const eventTimestamp = readEventTimestamp(args.metadataEvent.timestamp);
|
|
4900
|
+
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
4901
|
+
const duplicateCompletion = isDuplicateMeshCompletionEvent({
|
|
4902
|
+
meshId: args.meshId,
|
|
4903
|
+
event: args.event,
|
|
4904
|
+
sessionId: eventSessionId,
|
|
4905
|
+
providerType: readNonEmptyString(args.metadataEvent.providerType) || void 0,
|
|
4906
|
+
providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0,
|
|
4907
|
+
timestamp: eventTimestamp,
|
|
4908
|
+
finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || void 0
|
|
4909
|
+
});
|
|
4910
|
+
if (duplicateCompletion) {
|
|
4911
|
+
LOG.info("MeshEvents", `Suppressed duplicate completion for mesh ${args.meshId} session ${eventSessionId}`);
|
|
4912
|
+
return { success: true, forwarded: 0, suppressed: true, duplicateCompletion: true };
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4865
4915
|
let completedTaskForLedger = null;
|
|
4866
4916
|
if (args.event === "agent:generating_completed") {
|
|
4867
4917
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
4868
4918
|
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
4869
4919
|
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
4870
4920
|
if (sessionId) {
|
|
4871
|
-
const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed"
|
|
4921
|
+
const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed", {
|
|
4922
|
+
occurredAt: eventTimestamp !== null ? new Date(eventTimestamp).toISOString() : void 0
|
|
4923
|
+
});
|
|
4872
4924
|
completedTaskForLedger = completedTask ? { id: completedTask.id } : null;
|
|
4873
4925
|
if (nodeId && providerType) {
|
|
4874
4926
|
setImmediate(() => {
|
|
@@ -5082,6 +5134,7 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
5082
5134
|
providerType: readNonEmptyString(payload.providerType),
|
|
5083
5135
|
providerSessionId: readNonEmptyString(payload.providerSessionId),
|
|
5084
5136
|
finalSummary: readNonEmptyString(payload.finalSummary) || readNonEmptyString(payload.summary),
|
|
5137
|
+
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {},
|
|
5085
5138
|
intentional: payload.intentional === true,
|
|
5086
5139
|
intentionalStop: payload.intentionalStop === true,
|
|
5087
5140
|
operatorCleanup: payload.operatorCleanup === true,
|
|
@@ -5124,7 +5177,7 @@ function setupMeshEventForwarding(components) {
|
|
|
5124
5177
|
});
|
|
5125
5178
|
});
|
|
5126
5179
|
}
|
|
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;
|
|
5180
|
+
var import_fs6, import_path5, REMOTE_IDLE_SESSION_TTL_MS, remoteIdleSessions, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, RECENT_COMPLETION_FINGERPRINT_TTL_MS, recentCompletionFingerprints, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS;
|
|
5128
5181
|
var init_mesh_events = __esm({
|
|
5129
5182
|
"../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
|
|
5130
5183
|
"use strict";
|
|
@@ -5153,6 +5206,8 @@ var init_mesh_events = __esm({
|
|
|
5153
5206
|
"monitor:long_generating": "task_stalled"
|
|
5154
5207
|
};
|
|
5155
5208
|
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
5209
|
+
RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
|
|
5210
|
+
recentCompletionFingerprints = /* @__PURE__ */ new Map();
|
|
5156
5211
|
autoLaunchInProgress = /* @__PURE__ */ new Set();
|
|
5157
5212
|
autoLaunchCooldownUntil = /* @__PURE__ */ new Map();
|
|
5158
5213
|
AUTO_LAUNCH_COOLDOWN_MS = 5e3;
|
|
@@ -98410,7 +98465,7 @@ var init_adhdev_daemon = __esm({
|
|
|
98410
98465
|
init_version();
|
|
98411
98466
|
init_src();
|
|
98412
98467
|
init_runtime_defaults();
|
|
98413
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
98468
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.25" });
|
|
98414
98469
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
98415
98470
|
localHttpServer = null;
|
|
98416
98471
|
localWss = null;
|
|
@@ -99304,6 +99359,7 @@ ${err?.stack || ""}`);
|
|
|
99304
99359
|
const meshId = this.readMeshString(settings.meshNodeFor);
|
|
99305
99360
|
const coordinatorDaemonId = this.readMeshString(settings.meshCoordinatorDaemonId);
|
|
99306
99361
|
if (!meshId || !coordinatorDaemonId) return;
|
|
99362
|
+
const relayTimestamp = typeof event.timestamp === "number" && Number.isFinite(event.timestamp) ? event.timestamp : this.readMeshString(event.timestamp) || void 0;
|
|
99307
99363
|
const payload = {
|
|
99308
99364
|
event: this.readMeshString(event.event),
|
|
99309
99365
|
meshId,
|
|
@@ -99312,7 +99368,8 @@ ${err?.stack || ""}`);
|
|
|
99312
99368
|
targetSessionId: this.readMeshString(event.targetSessionId) || instanceId,
|
|
99313
99369
|
providerType: this.readMeshString(event.providerType),
|
|
99314
99370
|
providerSessionId: this.readMeshString(event.providerSessionId),
|
|
99315
|
-
finalSummary: this.readMeshString(event.finalSummary) || this.readMeshString(event.summary)
|
|
99371
|
+
finalSummary: this.readMeshString(event.finalSummary) || this.readMeshString(event.summary),
|
|
99372
|
+
...relayTimestamp !== void 0 ? { timestamp: relayTimestamp } : {}
|
|
99316
99373
|
};
|
|
99317
99374
|
if (coordinatorDaemonId === localDaemonId) {
|
|
99318
99375
|
try {
|
|
@@ -99338,7 +99395,8 @@ ${err?.stack || ""}`);
|
|
|
99338
99395
|
providerType: payload.providerType,
|
|
99339
99396
|
providerSessionId: payload.providerSessionId,
|
|
99340
99397
|
finalSummary: payload.finalSummary,
|
|
99341
|
-
workspace: payload.workspace
|
|
99398
|
+
workspace: payload.workspace,
|
|
99399
|
+
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {}
|
|
99342
99400
|
},
|
|
99343
99401
|
queuedAt: Date.now()
|
|
99344
99402
|
});
|