adhdev 0.9.82-rc.24 → 0.9.82-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/cli/index.js +97 -59
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +97 -59
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3444,18 +3444,20 @@ function requeueTask(meshId, taskId, opts) {
|
|
|
3444
3444
|
return entry;
|
|
3445
3445
|
});
|
|
3446
3446
|
}
|
|
3447
|
-
function updateSessionTaskStatus(meshId, sessionId, status) {
|
|
3447
|
+
function updateSessionTaskStatus(meshId, sessionId, status, opts) {
|
|
3448
3448
|
return withQueueLock(meshId, () => {
|
|
3449
3449
|
const queue = readQueue(meshId);
|
|
3450
|
+
const occurredAtTime = opts?.occurredAt ? new Date(opts.occurredAt).getTime() : Number.NaN;
|
|
3451
|
+
const hasOccurredAt = Number.isFinite(occurredAtTime);
|
|
3450
3452
|
let bestIdx = -1;
|
|
3451
3453
|
let bestTime = 0;
|
|
3452
3454
|
for (let i = queue.length - 1; i >= 0; i--) {
|
|
3453
|
-
if (queue[i].assignedSessionId
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3455
|
+
if (queue[i].assignedSessionId !== sessionId || queue[i].status !== "assigned") continue;
|
|
3456
|
+
const time3 = new Date(queue[i].dispatchTimestamp || queue[i].updatedAt).getTime();
|
|
3457
|
+
if (hasOccurredAt && Number.isFinite(time3) && time3 > occurredAtTime) continue;
|
|
3458
|
+
if (time3 > bestTime) {
|
|
3459
|
+
bestTime = time3;
|
|
3460
|
+
bestIdx = i;
|
|
3459
3461
|
}
|
|
3460
3462
|
}
|
|
3461
3463
|
if (bestIdx === -1) return null;
|
|
@@ -3981,6 +3983,38 @@ function shouldSuppressIntentionalCleanupStop(args) {
|
|
|
3981
3983
|
if (isIntentionalCleanupStopMetadata(args.metadataEvent)) return true;
|
|
3982
3984
|
return hasRecentIntentionalCleanupStop(args.meshId, args.sessionId, args.nodeId);
|
|
3983
3985
|
}
|
|
3986
|
+
function readEventTimestamp(value) {
|
|
3987
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
3988
|
+
if (typeof value === "string" && value.trim()) {
|
|
3989
|
+
const numeric = Number(value);
|
|
3990
|
+
if (Number.isFinite(numeric)) return numeric;
|
|
3991
|
+
const parsed = Date.parse(value);
|
|
3992
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
3993
|
+
}
|
|
3994
|
+
return null;
|
|
3995
|
+
}
|
|
3996
|
+
function buildMeshCompletionFingerprint(args) {
|
|
3997
|
+
const timestampPart = Number.isFinite(args.timestamp) ? String(args.timestamp) : readNonEmptyString(args.finalSummary).slice(0, 200);
|
|
3998
|
+
return [
|
|
3999
|
+
args.meshId,
|
|
4000
|
+
args.event,
|
|
4001
|
+
args.sessionId,
|
|
4002
|
+
args.providerType || "",
|
|
4003
|
+
args.providerSessionId || "",
|
|
4004
|
+
timestampPart
|
|
4005
|
+
].join("::");
|
|
4006
|
+
}
|
|
4007
|
+
function isDuplicateMeshCompletionEvent(args) {
|
|
4008
|
+
const fingerprint = buildMeshCompletionFingerprint(args);
|
|
4009
|
+
if (!fingerprint) return false;
|
|
4010
|
+
const now = Date.now();
|
|
4011
|
+
for (const [key, seenAt] of recentCompletionFingerprints.entries()) {
|
|
4012
|
+
if (now - seenAt > RECENT_COMPLETION_FINGERPRINT_TTL_MS) recentCompletionFingerprints.delete(key);
|
|
4013
|
+
}
|
|
4014
|
+
if (recentCompletionFingerprints.has(fingerprint)) return true;
|
|
4015
|
+
recentCompletionFingerprints.set(fingerprint, now);
|
|
4016
|
+
return false;
|
|
4017
|
+
}
|
|
3984
4018
|
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
|
|
3985
4019
|
const task = claimNextTask(meshId, nodeId, sessionId);
|
|
3986
4020
|
if (!task) {
|
|
@@ -4342,13 +4376,31 @@ function injectMeshSystemMessage(components, args) {
|
|
|
4342
4376
|
LOG.info("MeshEvents", `Suppressed ${args.event} for intentionally cleanup-stopped session ${eventSessionId || "(unknown session)"}`);
|
|
4343
4377
|
return { success: true, forwarded: 0, suppressed: true, intentionalCleanupStop: true };
|
|
4344
4378
|
}
|
|
4379
|
+
const eventTimestamp = readEventTimestamp(args.metadataEvent.timestamp);
|
|
4380
|
+
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
4381
|
+
const duplicateCompletion = isDuplicateMeshCompletionEvent({
|
|
4382
|
+
meshId: args.meshId,
|
|
4383
|
+
event: args.event,
|
|
4384
|
+
sessionId: eventSessionId,
|
|
4385
|
+
providerType: readNonEmptyString(args.metadataEvent.providerType) || void 0,
|
|
4386
|
+
providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0,
|
|
4387
|
+
timestamp: eventTimestamp,
|
|
4388
|
+
finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || void 0
|
|
4389
|
+
});
|
|
4390
|
+
if (duplicateCompletion) {
|
|
4391
|
+
LOG.info("MeshEvents", `Suppressed duplicate completion for mesh ${args.meshId} session ${eventSessionId}`);
|
|
4392
|
+
return { success: true, forwarded: 0, suppressed: true, duplicateCompletion: true };
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4345
4395
|
let completedTaskForLedger = null;
|
|
4346
4396
|
if (args.event === "agent:generating_completed") {
|
|
4347
4397
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
4348
4398
|
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
4349
4399
|
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
4350
4400
|
if (sessionId) {
|
|
4351
|
-
const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed"
|
|
4401
|
+
const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed", {
|
|
4402
|
+
occurredAt: eventTimestamp !== null ? new Date(eventTimestamp).toISOString() : void 0
|
|
4403
|
+
});
|
|
4352
4404
|
completedTaskForLedger = completedTask ? { id: completedTask.id } : null;
|
|
4353
4405
|
if (nodeId && providerType) {
|
|
4354
4406
|
setImmediate(() => {
|
|
@@ -4562,6 +4614,7 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
4562
4614
|
providerType: readNonEmptyString(payload.providerType),
|
|
4563
4615
|
providerSessionId: readNonEmptyString(payload.providerSessionId),
|
|
4564
4616
|
finalSummary: readNonEmptyString(payload.finalSummary) || readNonEmptyString(payload.summary),
|
|
4617
|
+
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {},
|
|
4565
4618
|
intentional: payload.intentional === true,
|
|
4566
4619
|
intentionalStop: payload.intentionalStop === true,
|
|
4567
4620
|
operatorCleanup: payload.operatorCleanup === true,
|
|
@@ -4604,7 +4657,7 @@ function setupMeshEventForwarding(components) {
|
|
|
4604
4657
|
});
|
|
4605
4658
|
});
|
|
4606
4659
|
}
|
|
4607
|
-
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;
|
|
4660
|
+
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;
|
|
4608
4661
|
var init_mesh_events = __esm({
|
|
4609
4662
|
"../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
|
|
4610
4663
|
"use strict";
|
|
@@ -4633,6 +4686,8 @@ var init_mesh_events = __esm({
|
|
|
4633
4686
|
"monitor:long_generating": "task_stalled"
|
|
4634
4687
|
};
|
|
4635
4688
|
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
4689
|
+
RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
|
|
4690
|
+
recentCompletionFingerprints = /* @__PURE__ */ new Map();
|
|
4636
4691
|
autoLaunchInProgress = /* @__PURE__ */ new Set();
|
|
4637
4692
|
autoLaunchCooldownUntil = /* @__PURE__ */ new Map();
|
|
4638
4693
|
AUTO_LAUNCH_COOLDOWN_MS = 5e3;
|
|
@@ -45615,49 +45670,7 @@ function readGitSubmodules(value) {
|
|
|
45615
45670
|
}).filter((entry) => entry !== null);
|
|
45616
45671
|
return submodules.length > 0 ? submodules : void 0;
|
|
45617
45672
|
}
|
|
45618
|
-
function
|
|
45619
|
-
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
45620
|
-
const cachedGit = readObjectRecord(cachedStatus.git);
|
|
45621
|
-
if (Object.keys(cachedGit).length) {
|
|
45622
|
-
const conflictFiles2 = Array.isArray(cachedGit.conflictFiles) ? cachedGit.conflictFiles.filter((value) => typeof value === "string") : [];
|
|
45623
|
-
const conflictCount2 = readNumberValue(cachedGit.conflicts) ?? conflictFiles2.length;
|
|
45624
|
-
const hasConflicts2 = readBooleanValue(cachedGit.hasConflicts) ?? conflictCount2 > 0;
|
|
45625
|
-
const isGitRepo2 = readBooleanValue(cachedGit.isGitRepo);
|
|
45626
|
-
if (isGitRepo2 !== void 0) {
|
|
45627
|
-
const submodules2 = readGitSubmodules(cachedGit.submodules);
|
|
45628
|
-
return {
|
|
45629
|
-
workspace: readStringValue(cachedGit.workspace, node?.workspace) || "",
|
|
45630
|
-
repoRoot: readStringValue(cachedGit.repoRoot, node?.repoRoot, node?.workspace) || null,
|
|
45631
|
-
isGitRepo: isGitRepo2,
|
|
45632
|
-
branch: readStringValue(cachedGit.branch) ?? null,
|
|
45633
|
-
headCommit: readStringValue(cachedGit.headCommit) ?? null,
|
|
45634
|
-
headMessage: readStringValue(cachedGit.headMessage) ?? null,
|
|
45635
|
-
upstream: readStringValue(cachedGit.upstream) ?? null,
|
|
45636
|
-
ahead: readNumberValue(cachedGit.ahead) ?? 0,
|
|
45637
|
-
behind: readNumberValue(cachedGit.behind) ?? 0,
|
|
45638
|
-
staged: readNumberValue(cachedGit.staged) ?? 0,
|
|
45639
|
-
modified: readNumberValue(cachedGit.modified) ?? 0,
|
|
45640
|
-
untracked: readNumberValue(cachedGit.untracked) ?? 0,
|
|
45641
|
-
deleted: readNumberValue(cachedGit.deleted) ?? 0,
|
|
45642
|
-
renamed: readNumberValue(cachedGit.renamed) ?? 0,
|
|
45643
|
-
hasConflicts: hasConflicts2,
|
|
45644
|
-
conflictFiles: conflictFiles2,
|
|
45645
|
-
stashCount: readNumberValue(cachedGit.stashCount) ?? 0,
|
|
45646
|
-
lastCheckedAt: readNumberValue(cachedGit.lastCheckedAt) ?? Date.now(),
|
|
45647
|
-
...submodules2 ? { submodules: submodules2 } : {}
|
|
45648
|
-
};
|
|
45649
|
-
}
|
|
45650
|
-
}
|
|
45651
|
-
const rawGit = readObjectRecord(node?.lastGit ?? node?.last_git);
|
|
45652
|
-
const gitResult = readObjectRecord(rawGit.result);
|
|
45653
|
-
const directStatus = readObjectRecord(rawGit.status);
|
|
45654
|
-
const nestedStatus = readObjectRecord(gitResult.status);
|
|
45655
|
-
const rawProbe = readObjectRecord(node?.lastProbe ?? node?.last_probe);
|
|
45656
|
-
const probeGit = readObjectRecord(rawProbe.git);
|
|
45657
|
-
const probeGitResult = readObjectRecord(probeGit.result);
|
|
45658
|
-
const probeDirectStatus = readObjectRecord(probeGit.status);
|
|
45659
|
-
const probeNestedStatus = readObjectRecord(probeGitResult.status);
|
|
45660
|
-
const status = Object.keys(directStatus).length ? directStatus : Object.keys(nestedStatus).length ? nestedStatus : Object.keys(probeDirectStatus).length ? probeDirectStatus : Object.keys(probeNestedStatus).length ? probeNestedStatus : {};
|
|
45673
|
+
function normalizeInlineMeshGitStatus(status, node, options) {
|
|
45661
45674
|
const isGitRepo = readBooleanValue(status.isGitRepo);
|
|
45662
45675
|
if (!Object.keys(status).length || isGitRepo === void 0) return void 0;
|
|
45663
45676
|
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((value) => typeof value === "string") : [];
|
|
@@ -45682,10 +45695,31 @@ function buildCachedInlineMeshGitStatus(node) {
|
|
|
45682
45695
|
hasConflicts,
|
|
45683
45696
|
conflictFiles,
|
|
45684
45697
|
stashCount: readNumberValue(status.stashCount) ?? 0,
|
|
45685
|
-
lastCheckedAt: Date.now(),
|
|
45698
|
+
lastCheckedAt: options?.lastCheckedAt ?? readNumberValue(status.lastCheckedAt) ?? Date.now(),
|
|
45686
45699
|
...submodules ? { submodules } : {}
|
|
45687
45700
|
};
|
|
45688
45701
|
}
|
|
45702
|
+
function buildInlineMeshTransitGitStatus(node) {
|
|
45703
|
+
const rawGit = readObjectRecord(node?.lastGit ?? node?.last_git);
|
|
45704
|
+
const gitResult = readObjectRecord(rawGit.result);
|
|
45705
|
+
const directStatus = readObjectRecord(rawGit.status);
|
|
45706
|
+
const nestedStatus = readObjectRecord(gitResult.status);
|
|
45707
|
+
const rawProbe = readObjectRecord(node?.lastProbe ?? node?.last_probe);
|
|
45708
|
+
const probeGit = readObjectRecord(rawProbe.git);
|
|
45709
|
+
const probeGitResult = readObjectRecord(probeGit.result);
|
|
45710
|
+
const probeDirectStatus = readObjectRecord(probeGit.status);
|
|
45711
|
+
const probeNestedStatus = readObjectRecord(probeGitResult.status);
|
|
45712
|
+
const status = Object.keys(directStatus).length ? directStatus : Object.keys(nestedStatus).length ? nestedStatus : Object.keys(probeDirectStatus).length ? probeDirectStatus : Object.keys(probeNestedStatus).length ? probeNestedStatus : {};
|
|
45713
|
+
return normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
|
|
45714
|
+
}
|
|
45715
|
+
function buildCachedInlineMeshGitStatus(node) {
|
|
45716
|
+
const liveGit = buildInlineMeshTransitGitStatus(node);
|
|
45717
|
+
if (liveGit) return liveGit;
|
|
45718
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
45719
|
+
const cachedGit = readObjectRecord(cachedStatus.git);
|
|
45720
|
+
if (!Object.keys(cachedGit).length) return void 0;
|
|
45721
|
+
return normalizeInlineMeshGitStatus(cachedGit, node);
|
|
45722
|
+
}
|
|
45689
45723
|
function shouldDiscardCachedInlineMeshStatus(node) {
|
|
45690
45724
|
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
45691
45725
|
if (!Object.keys(cachedStatus).length) return false;
|
|
@@ -45914,9 +45948,10 @@ function collectLiveMeshSessionRecords(args) {
|
|
|
45914
45948
|
}
|
|
45915
45949
|
function applyCachedInlineMeshNodeStatus(status, node) {
|
|
45916
45950
|
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
45917
|
-
const
|
|
45918
|
-
const
|
|
45919
|
-
const
|
|
45951
|
+
const liveGit = buildInlineMeshTransitGitStatus(node);
|
|
45952
|
+
const git = liveGit ?? buildCachedInlineMeshGitStatus(node);
|
|
45953
|
+
const error48 = liveGit ? void 0 : readStringValue(cachedStatus.error, node?.error);
|
|
45954
|
+
const health = liveGit ? void 0 : readStringValue(cachedStatus.health, node?.health);
|
|
45920
45955
|
const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
|
|
45921
45956
|
const lastSeenAt = toIsoTimestamp(cachedStatus.lastSeenAt ?? cachedStatus.last_seen_at ?? node?.lastSeenAt ?? node?.last_seen_at);
|
|
45922
45957
|
const updatedAt = toIsoTimestamp(cachedStatus.updatedAt ?? cachedStatus.updated_at ?? node?.updatedAt ?? node?.updated_at);
|
|
@@ -67237,7 +67272,7 @@ var init_adhdev_daemon = __esm({
|
|
|
67237
67272
|
init_version();
|
|
67238
67273
|
init_src();
|
|
67239
67274
|
init_runtime_defaults();
|
|
67240
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
67275
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.26" });
|
|
67241
67276
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
67242
67277
|
localHttpServer = null;
|
|
67243
67278
|
localWss = null;
|
|
@@ -68131,6 +68166,7 @@ ${err?.stack || ""}`);
|
|
|
68131
68166
|
const meshId = this.readMeshString(settings.meshNodeFor);
|
|
68132
68167
|
const coordinatorDaemonId = this.readMeshString(settings.meshCoordinatorDaemonId);
|
|
68133
68168
|
if (!meshId || !coordinatorDaemonId) return;
|
|
68169
|
+
const relayTimestamp = typeof event.timestamp === "number" && Number.isFinite(event.timestamp) ? event.timestamp : this.readMeshString(event.timestamp) || void 0;
|
|
68134
68170
|
const payload = {
|
|
68135
68171
|
event: this.readMeshString(event.event),
|
|
68136
68172
|
meshId,
|
|
@@ -68139,7 +68175,8 @@ ${err?.stack || ""}`);
|
|
|
68139
68175
|
targetSessionId: this.readMeshString(event.targetSessionId) || instanceId,
|
|
68140
68176
|
providerType: this.readMeshString(event.providerType),
|
|
68141
68177
|
providerSessionId: this.readMeshString(event.providerSessionId),
|
|
68142
|
-
finalSummary: this.readMeshString(event.finalSummary) || this.readMeshString(event.summary)
|
|
68178
|
+
finalSummary: this.readMeshString(event.finalSummary) || this.readMeshString(event.summary),
|
|
68179
|
+
...relayTimestamp !== void 0 ? { timestamp: relayTimestamp } : {}
|
|
68143
68180
|
};
|
|
68144
68181
|
if (coordinatorDaemonId === localDaemonId) {
|
|
68145
68182
|
try {
|
|
@@ -68165,7 +68202,8 @@ ${err?.stack || ""}`);
|
|
|
68165
68202
|
providerType: payload.providerType,
|
|
68166
68203
|
providerSessionId: payload.providerSessionId,
|
|
68167
68204
|
finalSummary: payload.finalSummary,
|
|
68168
|
-
workspace: payload.workspace
|
|
68205
|
+
workspace: payload.workspace,
|
|
68206
|
+
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {}
|
|
68169
68207
|
},
|
|
68170
68208
|
queuedAt: Date.now()
|
|
68171
68209
|
});
|