@adhdev/daemon-core 0.9.82-rc.442 → 0.9.82-rc.444
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/commands/high-family/types.d.ts +4 -0
- package/dist/commands/router.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +551 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +543 -63
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-ledger.d.ts +39 -1
- package/dist/mesh/mesh-node-identity.d.ts +15 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +15 -1
- package/dist/providers/chat-message-normalization.d.ts +1 -0
- package/dist/providers/cli-provider-instance.d.ts +2 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +28 -2
- package/package.json +2 -2
- package/src/commands/chat-commands-read.ts +41 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +4 -2
- package/src/commands/high-family/mesh-events.ts +11 -2
- package/src/commands/high-family/mesh-status.ts +102 -9
- package/src/commands/high-family/types.ts +5 -1
- package/src/commands/router.ts +19 -2
- package/src/index.ts +1 -1
- package/src/mesh/coordinator-prompt.ts +1 -0
- package/src/mesh/mesh-ledger.ts +185 -0
- package/src/mesh/mesh-node-identity.ts +106 -18
- package/src/mesh/mesh-reconcile-loop.ts +22 -1
- package/src/providers/chat-message-normalization.ts +1 -1
- package/src/providers/cli-provider-instance.ts +130 -17
- package/src/providers/native-history/antigravity-cli-transcript.ts +348 -25
- package/src/providers/native-history/dispatcher.ts +33 -14
package/dist/index.js
CHANGED
|
@@ -409,10 +409,10 @@ function readInjected(value) {
|
|
|
409
409
|
}
|
|
410
410
|
function getDaemonBuildInfo() {
|
|
411
411
|
if (cached) return cached;
|
|
412
|
-
const commit = readInjected(true ? "
|
|
413
|
-
const commitShort = readInjected(true ? "
|
|
414
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
415
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
412
|
+
const commit = readInjected(true ? "fafdde138250b2edcbf2e42c643e3cabd1b8bda0" : void 0) ?? "unknown";
|
|
413
|
+
const commitShort = readInjected(true ? "fafdde13" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
414
|
+
const version = readInjected(true ? "0.9.82-rc.444" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
415
|
+
const builtAt = readInjected(true ? "2026-07-01T12:06:17.132Z" : void 0);
|
|
416
416
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
417
417
|
return cached;
|
|
418
418
|
}
|
|
@@ -3717,6 +3717,7 @@ var init_coordinator_prompt = __esm({
|
|
|
3717
3717
|
| \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
|
|
3718
3718
|
| \`mesh_task_history\` | Read the task ledger \u2014 dispatches, completions, failures. Use to understand what has been done before deciding next steps |
|
|
3719
3719
|
| \`mesh_record_note\` | Record a durable, provider-neutral operating note (provider quirk / pattern to avoid / recovery lesson). Future coordinators see it under "## Operating Notes" at launch |
|
|
3720
|
+
| \`mesh_forget_note\` | Retract a stale/wrong operating note by note_id or exact text so it stops riding into future coordinators' prompts (append-only tombstone; history preserved) |
|
|
3720
3721
|
| \`mesh_git_status\` | Check git status on a specific node |
|
|
3721
3722
|
| \`mesh_read_node_logs\` | Fetch a remote node's daemon log tail directly over P2P (grep/since/byte-bounded, secrets redacted) \u2014 no session/PowerShell needed to debug a node's daemon |
|
|
3722
3723
|
| \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
|
|
@@ -4103,6 +4104,10 @@ var init_load_better_sqlite3 = __esm({
|
|
|
4103
4104
|
var mesh_ledger_exports = {};
|
|
4104
4105
|
__export(mesh_ledger_exports, {
|
|
4105
4106
|
MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
|
|
4107
|
+
OPERATING_NOTE_DEDUPE_WINDOW: () => OPERATING_NOTE_DEDUPE_WINDOW,
|
|
4108
|
+
OPERATING_NOTE_KEEP_LATEST: () => OPERATING_NOTE_KEEP_LATEST,
|
|
4109
|
+
OPERATING_NOTE_KIND: () => OPERATING_NOTE_KIND,
|
|
4110
|
+
OPERATING_NOTE_TOMBSTONE_KIND: () => OPERATING_NOTE_TOMBSTONE_KIND,
|
|
4106
4111
|
__clearMeshLedgerForTests: () => __clearMeshLedgerForTests,
|
|
4107
4112
|
appendLedgerEntry: () => appendLedgerEntry,
|
|
4108
4113
|
appendRemoteLedgerEntries: () => appendRemoteLedgerEntries,
|
|
@@ -4113,11 +4118,15 @@ __export(mesh_ledger_exports, {
|
|
|
4113
4118
|
getLedgerSummary: () => getLedgerSummary,
|
|
4114
4119
|
getSessionRecoveryContext: () => getSessionRecoveryContext,
|
|
4115
4120
|
isIntentionalCleanupStopEntry: () => isIntentionalCleanupStopEntry,
|
|
4121
|
+
isOperatingNoteTombstoned: () => isOperatingNoteTombstoned,
|
|
4116
4122
|
meshLedgerEvents: () => meshLedgerEvents,
|
|
4117
4123
|
normalizeMeshWorkerResult: () => normalizeMeshWorkerResult,
|
|
4124
|
+
pruneOperatingNotes: () => pruneOperatingNotes,
|
|
4118
4125
|
readLedgerEntries: () => readLedgerEntries,
|
|
4119
4126
|
readLedgerSlice: () => readLedgerSlice,
|
|
4120
|
-
readLedgerSliceFromStore: () => readLedgerSliceFromStore
|
|
4127
|
+
readLedgerSliceFromStore: () => readLedgerSliceFromStore,
|
|
4128
|
+
readOperatingNotes: () => readOperatingNotes,
|
|
4129
|
+
tombstoneOperatingNote: () => tombstoneOperatingNote
|
|
4121
4130
|
});
|
|
4122
4131
|
function isIntentionalCleanupStopEntry(entry) {
|
|
4123
4132
|
if (entry.kind !== "session_stopped" && entry.kind !== "task_failed" && entry.kind !== "task_stalled") return false;
|
|
@@ -4387,6 +4396,17 @@ function buildTaskCompletionEvidence(opts) {
|
|
|
4387
4396
|
};
|
|
4388
4397
|
}
|
|
4389
4398
|
function appendLedgerEntry(meshId, partial) {
|
|
4399
|
+
if (partial.kind === OPERATING_NOTE_KIND) {
|
|
4400
|
+
const text = operatingNoteText(partial.payload);
|
|
4401
|
+
if (text) {
|
|
4402
|
+
const recentNotes = readLedgerEntries(meshId, {
|
|
4403
|
+
kind: [OPERATING_NOTE_KIND],
|
|
4404
|
+
tail: OPERATING_NOTE_DEDUPE_WINDOW
|
|
4405
|
+
});
|
|
4406
|
+
const existing = recentNotes.find((e) => operatingNoteText(e.payload) === text);
|
|
4407
|
+
if (existing) return existing;
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4390
4410
|
const entry = {
|
|
4391
4411
|
id: (0, import_crypto4.randomUUID)(),
|
|
4392
4412
|
meshId,
|
|
@@ -4424,11 +4444,101 @@ function appendLedgerEntry(meshId, partial) {
|
|
|
4424
4444
|
(0, import_fs4.appendFileSync)(filePath, line, { encoding: "utf-8", mode: 384 });
|
|
4425
4445
|
invalidateLedgerCache(meshId);
|
|
4426
4446
|
meshLedgerEvents.emit("append", meshId, entry);
|
|
4447
|
+
if (entry.kind === OPERATING_NOTE_KIND || entry.kind === OPERATING_NOTE_TOMBSTONE_KIND) {
|
|
4448
|
+
try {
|
|
4449
|
+
pruneOperatingNotes(meshId);
|
|
4450
|
+
} catch {
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4427
4453
|
return entry;
|
|
4428
4454
|
} catch (e) {
|
|
4429
4455
|
throw new Error(`Failed to append to ledger for mesh ${meshId}: ${e.message}`);
|
|
4430
4456
|
}
|
|
4431
4457
|
}
|
|
4458
|
+
function operatingNoteText(payload) {
|
|
4459
|
+
const text = payload && typeof payload.text === "string" ? payload.text.trim() : "";
|
|
4460
|
+
return text || void 0;
|
|
4461
|
+
}
|
|
4462
|
+
function collectOperatingNoteTombstones(entries) {
|
|
4463
|
+
const ids = /* @__PURE__ */ new Set();
|
|
4464
|
+
const fingerprints = /* @__PURE__ */ new Set();
|
|
4465
|
+
for (const e of entries) {
|
|
4466
|
+
if (e.kind !== OPERATING_NOTE_TOMBSTONE_KIND) continue;
|
|
4467
|
+
const p = e.payload || {};
|
|
4468
|
+
const targetId = typeof p.targetNoteId === "string" ? p.targetNoteId.trim() : "";
|
|
4469
|
+
const targetFp = typeof p.targetFingerprint === "string" ? p.targetFingerprint.trim() : "";
|
|
4470
|
+
if (targetId) ids.add(targetId);
|
|
4471
|
+
if (targetFp) fingerprints.add(targetFp);
|
|
4472
|
+
}
|
|
4473
|
+
return { ids, fingerprints };
|
|
4474
|
+
}
|
|
4475
|
+
function isOperatingNoteTombstoned(entry, tombstones) {
|
|
4476
|
+
if (tombstones.ids.has(entry.id)) return true;
|
|
4477
|
+
const text = operatingNoteText(entry.payload);
|
|
4478
|
+
return text ? tombstones.fingerprints.has(text) : false;
|
|
4479
|
+
}
|
|
4480
|
+
function tombstoneOperatingNote(meshId, target) {
|
|
4481
|
+
const noteId = typeof target.noteId === "string" ? target.noteId.trim() : "";
|
|
4482
|
+
const fingerprint = typeof target.text === "string" ? target.text.trim() : "";
|
|
4483
|
+
if (!noteId && !fingerprint) {
|
|
4484
|
+
throw new Error("tombstoneOperatingNote requires a noteId or text target");
|
|
4485
|
+
}
|
|
4486
|
+
const notes = readOperatingNotes(meshId);
|
|
4487
|
+
const matched = notes.filter(
|
|
4488
|
+
(n) => noteId && n.id === noteId || fingerprint && operatingNoteText(n.payload) === fingerprint
|
|
4489
|
+
).length;
|
|
4490
|
+
const tombstone = appendLedgerEntry(meshId, {
|
|
4491
|
+
kind: OPERATING_NOTE_TOMBSTONE_KIND,
|
|
4492
|
+
payload: {
|
|
4493
|
+
...noteId ? { targetNoteId: noteId } : {},
|
|
4494
|
+
...fingerprint ? { targetFingerprint: fingerprint } : {},
|
|
4495
|
+
...target.reason && target.reason.trim() ? { reason: target.reason.trim() } : {},
|
|
4496
|
+
forgottenAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4497
|
+
}
|
|
4498
|
+
});
|
|
4499
|
+
return { tombstone, matched };
|
|
4500
|
+
}
|
|
4501
|
+
function readOperatingNotes(meshId, opts) {
|
|
4502
|
+
const raw = getCachedRawEntries(meshId);
|
|
4503
|
+
const tombstones = collectOperatingNoteTombstones(raw);
|
|
4504
|
+
let notes = raw.filter((e) => e.kind === OPERATING_NOTE_KIND && !isOperatingNoteTombstoned(e, tombstones));
|
|
4505
|
+
if (opts?.tail && opts.tail > 0 && notes.length > opts.tail) {
|
|
4506
|
+
notes = notes.slice(-opts.tail);
|
|
4507
|
+
}
|
|
4508
|
+
return notes;
|
|
4509
|
+
}
|
|
4510
|
+
function pruneOperatingNotes(meshId, keepLatest = OPERATING_NOTE_KEEP_LATEST) {
|
|
4511
|
+
const raw = getCachedRawEntries(meshId);
|
|
4512
|
+
const tombstones = collectOperatingNoteTombstones(raw);
|
|
4513
|
+
const removeIds = [];
|
|
4514
|
+
const liveNotes = [];
|
|
4515
|
+
for (const e of raw) {
|
|
4516
|
+
if (e.kind !== OPERATING_NOTE_KIND) continue;
|
|
4517
|
+
if (isOperatingNoteTombstoned(e, tombstones)) {
|
|
4518
|
+
removeIds.push(e.id);
|
|
4519
|
+
} else {
|
|
4520
|
+
liveNotes.push(e);
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
const bound = Math.max(0, Math.floor(keepLatest));
|
|
4524
|
+
if (liveNotes.length > bound) {
|
|
4525
|
+
for (const e of liveNotes.slice(0, liveNotes.length - bound)) removeIds.push(e.id);
|
|
4526
|
+
}
|
|
4527
|
+
if (removeIds.length === 0) return 0;
|
|
4528
|
+
try {
|
|
4529
|
+
MeshRuntimeStore.getInstance().deleteLedgerEntries(meshId, removeIds);
|
|
4530
|
+
} catch {
|
|
4531
|
+
}
|
|
4532
|
+
try {
|
|
4533
|
+
const remaining = readLedgerFile(meshId).filter((e) => !removeIds.includes(e.id));
|
|
4534
|
+
const filePath = getLedgerPath(meshId);
|
|
4535
|
+
const lines = remaining.length ? remaining.map((e) => JSON.stringify(e)).join("\n") + "\n" : "";
|
|
4536
|
+
(0, import_fs4.writeFileSync)(filePath, lines, { encoding: "utf-8", mode: 384 });
|
|
4537
|
+
} catch {
|
|
4538
|
+
}
|
|
4539
|
+
invalidateLedgerCache(meshId);
|
|
4540
|
+
return removeIds.length;
|
|
4541
|
+
}
|
|
4432
4542
|
function clampLedgerSliceLimit(limit) {
|
|
4433
4543
|
if (typeof limit !== "number" || !Number.isFinite(limit)) return DEFAULT_LEDGER_SLICE_LIMIT;
|
|
4434
4544
|
return Math.max(1, Math.min(MAX_LEDGER_SLICE_LIMIT, Math.floor(limit)));
|
|
@@ -4768,7 +4878,7 @@ function rotateLedgerFile(meshId, currentPath) {
|
|
|
4768
4878
|
`);
|
|
4769
4879
|
}
|
|
4770
4880
|
}
|
|
4771
|
-
var import_fs4, import_path4, import_crypto4, import_events, LEDGER_DIR_NAME, MAX_FILE_SIZE_BYTES, COMPACT_THRESHOLD_BYTES, ARCHIVE_TERMINAL_OLDER_THAN_MS, RECENT_FAILURE_WINDOW_MS, ARCHIVABLE_KINDS, DEFAULT_LEDGER_SLICE_LIMIT, MAX_LEDGER_SLICE_LIMIT, meshLedgerEvents, ledgerReadCache, LEDGER_CACHE_TTL_MS, ledgerImportStoreRef, ledgerImportDone;
|
|
4881
|
+
var import_fs4, import_path4, import_crypto4, import_events, LEDGER_DIR_NAME, MAX_FILE_SIZE_BYTES, COMPACT_THRESHOLD_BYTES, ARCHIVE_TERMINAL_OLDER_THAN_MS, RECENT_FAILURE_WINDOW_MS, ARCHIVABLE_KINDS, DEFAULT_LEDGER_SLICE_LIMIT, MAX_LEDGER_SLICE_LIMIT, OPERATING_NOTE_KIND, OPERATING_NOTE_TOMBSTONE_KIND, OPERATING_NOTE_DEDUPE_WINDOW, OPERATING_NOTE_KEEP_LATEST, meshLedgerEvents, ledgerReadCache, LEDGER_CACHE_TTL_MS, ledgerImportStoreRef, ledgerImportDone;
|
|
4772
4882
|
var init_mesh_ledger = __esm({
|
|
4773
4883
|
"src/mesh/mesh-ledger.ts"() {
|
|
4774
4884
|
"use strict";
|
|
@@ -4791,6 +4901,10 @@ var init_mesh_ledger = __esm({
|
|
|
4791
4901
|
]);
|
|
4792
4902
|
DEFAULT_LEDGER_SLICE_LIMIT = 100;
|
|
4793
4903
|
MAX_LEDGER_SLICE_LIMIT = 500;
|
|
4904
|
+
OPERATING_NOTE_KIND = "coordinator_operating_note";
|
|
4905
|
+
OPERATING_NOTE_TOMBSTONE_KIND = "coordinator_operating_note_tombstone";
|
|
4906
|
+
OPERATING_NOTE_DEDUPE_WINDOW = 40;
|
|
4907
|
+
OPERATING_NOTE_KEEP_LATEST = 100;
|
|
4794
4908
|
meshLedgerEvents = new import_events.EventEmitter();
|
|
4795
4909
|
ledgerReadCache = /* @__PURE__ */ new Map();
|
|
4796
4910
|
LEDGER_CACHE_TTL_MS = 100;
|
|
@@ -17200,7 +17314,7 @@ function resolveCoordinatorDrainDeliverability(components, meshId) {
|
|
|
17200
17314
|
holdForReconcile: !hasIdle
|
|
17201
17315
|
};
|
|
17202
17316
|
}
|
|
17203
|
-
function shouldHoldPendingDrainForBusyLocalCoordinator(components, meshId, requestedCoordinatorDaemonId) {
|
|
17317
|
+
function shouldHoldPendingDrainForBusyLocalCoordinator(components, meshId, requestedCoordinatorDaemonId, callerIsSelfCoordinatorInboxRead) {
|
|
17204
17318
|
if (!meshId) return false;
|
|
17205
17319
|
const deliverability = resolveCoordinatorDrainDeliverability(components, meshId);
|
|
17206
17320
|
if (!deliverability.holdForReconcile) return false;
|
|
@@ -17210,7 +17324,10 @@ function shouldHoldPendingDrainForBusyLocalCoordinator(components, meshId, reque
|
|
|
17210
17324
|
readNonEmptyString2(components.statusInstanceId),
|
|
17211
17325
|
readNonEmptyString2(loadConfig().machineId)
|
|
17212
17326
|
]);
|
|
17213
|
-
|
|
17327
|
+
const targetsLocalCoordinator = localIds.some((id) => daemonIdsEquivalent(id, requested));
|
|
17328
|
+
if (!targetsLocalCoordinator) return false;
|
|
17329
|
+
if (callerIsSelfCoordinatorInboxRead) return false;
|
|
17330
|
+
return true;
|
|
17214
17331
|
}
|
|
17215
17332
|
function injectPendingIntoCoordinator(coordinator, pending) {
|
|
17216
17333
|
if (!coordinator) return;
|
|
@@ -23809,6 +23926,10 @@ __export(index_exports, {
|
|
|
23809
23926
|
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS: () => MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
23810
23927
|
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS: () => MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
23811
23928
|
NodePtyTransportFactory: () => NodePtyTransportFactory,
|
|
23929
|
+
OPERATING_NOTE_DEDUPE_WINDOW: () => OPERATING_NOTE_DEDUPE_WINDOW,
|
|
23930
|
+
OPERATING_NOTE_KEEP_LATEST: () => OPERATING_NOTE_KEEP_LATEST,
|
|
23931
|
+
OPERATING_NOTE_KIND: () => OPERATING_NOTE_KIND,
|
|
23932
|
+
OPERATING_NOTE_TOMBSTONE_KIND: () => OPERATING_NOTE_TOMBSTONE_KIND,
|
|
23812
23933
|
P2pRelayFailureError: () => P2pRelayFailureError,
|
|
23813
23934
|
PRUNABLE_ORPHAN_STALE_REASONS: () => PRUNABLE_ORPHAN_STALE_REASONS,
|
|
23814
23935
|
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
@@ -23978,6 +24099,7 @@ __export(index_exports, {
|
|
|
23978
24099
|
isManagedStatusWaiting: () => isManagedStatusWaiting,
|
|
23979
24100
|
isManagedStatusWorking: () => isManagedStatusWorking,
|
|
23980
24101
|
isMeshHostOwner: () => isMeshHostOwner,
|
|
24102
|
+
isOperatingNoteTombstoned: () => isOperatingNoteTombstoned,
|
|
23981
24103
|
isP2pRelayTransportFailure: () => isP2pRelayTransportFailure,
|
|
23982
24104
|
isPathInside: () => isPathInside,
|
|
23983
24105
|
isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
|
|
@@ -24046,6 +24168,7 @@ __export(index_exports, {
|
|
|
24046
24168
|
prepareSessionChatTailUpdate: () => prepareSessionChatTailUpdate,
|
|
24047
24169
|
prepareSessionModalUpdate: () => prepareSessionModalUpdate,
|
|
24048
24170
|
probeCdpPort: () => probeCdpPort,
|
|
24171
|
+
pruneOperatingNotes: () => pruneOperatingNotes,
|
|
24049
24172
|
pruneStaleDirectDispatches: () => pruneStaleDirectDispatches,
|
|
24050
24173
|
queuePendingMeshCoordinatorEvent: () => queuePendingMeshCoordinatorEvent,
|
|
24051
24174
|
readAntigravityCliSession: () => readSession3,
|
|
@@ -24058,6 +24181,7 @@ __export(index_exports, {
|
|
|
24058
24181
|
readLedgerSlice: () => readLedgerSlice,
|
|
24059
24182
|
readLedgerSliceFromStore: () => readLedgerSliceFromStore,
|
|
24060
24183
|
readMeshCompletionSummary: () => readMeshCompletionSummary,
|
|
24184
|
+
readOperatingNotes: () => readOperatingNotes,
|
|
24061
24185
|
reconcileDirectDispatchCompletionFromTranscript: () => reconcileDirectDispatchCompletionFromTranscript,
|
|
24062
24186
|
recordCompletionConflict: () => recordCompletionConflict,
|
|
24063
24187
|
recordDebugTrace: () => recordDebugTrace,
|
|
@@ -24115,6 +24239,7 @@ __export(index_exports, {
|
|
|
24115
24239
|
summarizeMeshMagiActivity: () => summarizeMeshMagiActivity,
|
|
24116
24240
|
summarizeMeshMission: () => summarizeMeshMission,
|
|
24117
24241
|
summarizeMissionTasks: () => summarizeMissionTasks,
|
|
24242
|
+
tombstoneOperatingNote: () => tombstoneOperatingNote,
|
|
24118
24243
|
triggerMeshQueue: () => triggerMeshQueue,
|
|
24119
24244
|
unregisterMeshCoordinator: () => unregisterMeshCoordinator,
|
|
24120
24245
|
updateConfig: () => updateConfig,
|
|
@@ -32442,6 +32567,26 @@ async function handleReadChat(h, args) {
|
|
|
32442
32567
|
ptyStatusApprovalOnly: false
|
|
32443
32568
|
});
|
|
32444
32569
|
if (supportsNative && !decision.nativeSelected) {
|
|
32570
|
+
if (safeMapping && historyMessages.length > 0) {
|
|
32571
|
+
LOG.debug("Command", `[read_chat] native-only content preserved despite pty-parser selection target=${String(args?.targetSessionId || "")} provider=${agentStr} rows=${historyMessages.length} cause=${decision.decision.transition.cause}`);
|
|
32572
|
+
return buildReadChatCommandResult({
|
|
32573
|
+
messages: historyMessages,
|
|
32574
|
+
status: "idle",
|
|
32575
|
+
messageSource: {
|
|
32576
|
+
...decision.messageSource,
|
|
32577
|
+
nativeOnlyContentPreserved: true,
|
|
32578
|
+
returnedMessageCount: historyMessages.length
|
|
32579
|
+
},
|
|
32580
|
+
transcriptProvenance: {
|
|
32581
|
+
...decision.messageSource,
|
|
32582
|
+
nativeOnlyContentPreserved: true
|
|
32583
|
+
},
|
|
32584
|
+
...typeof history?.title === "string" ? { title: history.title } : {},
|
|
32585
|
+
...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
|
|
32586
|
+
...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
|
|
32587
|
+
coverage: "tail"
|
|
32588
|
+
}, args, h);
|
|
32589
|
+
}
|
|
32445
32590
|
LOG.debug("Command", `[read_chat] soft pending: no live adapter and native history not safely mappable target=${String(args?.targetSessionId || "")} provider=${agentStr} reason=native_history_not_safely_available`);
|
|
32446
32591
|
return {
|
|
32447
32592
|
success: true,
|
|
@@ -41043,6 +41188,15 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41043
41188
|
// first sets it; the other becomes a no-op.
|
|
41044
41189
|
agentReadyEmitted = false;
|
|
41045
41190
|
generatingStartedAt = 0;
|
|
41191
|
+
// FALSE-IDLE continuity epoch: monotonically bumped on EVERY entry into a busy
|
|
41192
|
+
// phase (→generating or →waiting_approval). The completedDebouncePending snapshots
|
|
41193
|
+
// this value at arm time (busyEpochAtArm); the flush guard requires it UNCHANGED
|
|
41194
|
+
// — proving the session did not re-enter a busy phase (a momentary busy→idle blip
|
|
41195
|
+
// in an inter-approval valley) between arming the debounce and flushing it. A
|
|
41196
|
+
// single point-sample of status at flush time cannot see a generating phase that
|
|
41197
|
+
// opened AND closed within the settle window; the epoch can. See
|
|
41198
|
+
// flushCompletedDebounceIfFinalized.
|
|
41199
|
+
busyEpoch = 0;
|
|
41046
41200
|
// GENERATING-BOUNDARY (R4b): the per-turn taskId for which a startup-grace
|
|
41047
41201
|
// started+completed pair was already synthesized. Both fast-collapse callers
|
|
41048
41202
|
// (starting→idle transition AND the idle-stayed no-status-change poll) route
|
|
@@ -41526,8 +41680,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41526
41680
|
* to the genuine-modal classification.
|
|
41527
41681
|
*/
|
|
41528
41682
|
isTransientToolConsent(now = Date.now()) {
|
|
41529
|
-
|
|
41530
|
-
return isAutonomousMeshSession && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
|
|
41683
|
+
return this.isAutonomousMeshSession() && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
|
|
41531
41684
|
}
|
|
41532
41685
|
/** True when this session is parked on a modal awaiting a human answer. */
|
|
41533
41686
|
isModalParked() {
|
|
@@ -41709,13 +41862,17 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41709
41862
|
}
|
|
41710
41863
|
this.applyProviderResponse(parsed.payload, { phase: "immediate" });
|
|
41711
41864
|
}
|
|
41712
|
-
completionHasFinalAssistantMessage(messages) {
|
|
41865
|
+
completionHasFinalAssistantMessage(messages, turnStartedAt) {
|
|
41713
41866
|
const visibleMessages = (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
|
|
41714
41867
|
const lastVisible = visibleMessages[visibleMessages.length - 1];
|
|
41715
41868
|
const role = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : "";
|
|
41716
41869
|
const content = lastVisible ? flattenContent(lastVisible.content).trim() : "";
|
|
41717
41870
|
if (role !== "assistant" || !content) return false;
|
|
41718
41871
|
if (looksLikeActiveApprovalPromptText(content)) return false;
|
|
41872
|
+
if (typeof turnStartedAt === "number" && Number.isFinite(turnStartedAt) && turnStartedAt > 0) {
|
|
41873
|
+
const ts2 = readChatMessageTimestampMs(lastVisible);
|
|
41874
|
+
if (typeof ts2 === "number" && ts2 < turnStartedAt) return false;
|
|
41875
|
+
}
|
|
41719
41876
|
return true;
|
|
41720
41877
|
}
|
|
41721
41878
|
buildExternalTranscriptProbe(messages, sourcePath, sourceMtimeMs) {
|
|
@@ -41778,8 +41935,8 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41778
41935
|
);
|
|
41779
41936
|
return restoredHistory.messages;
|
|
41780
41937
|
}
|
|
41781
|
-
completionFinalAssistantEvidence(parsedMessages) {
|
|
41782
|
-
if (this.completionHasFinalAssistantMessage(parsedMessages)) {
|
|
41938
|
+
completionFinalAssistantEvidence(parsedMessages, turnStartedAt) {
|
|
41939
|
+
if (this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt)) {
|
|
41783
41940
|
return {
|
|
41784
41941
|
present: true,
|
|
41785
41942
|
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
@@ -41789,7 +41946,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41789
41946
|
const externalMessages = this.readExternalCompletionMessages();
|
|
41790
41947
|
if (externalMessages) {
|
|
41791
41948
|
return {
|
|
41792
|
-
present: this.completionHasFinalAssistantMessage(externalMessages),
|
|
41949
|
+
present: this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt),
|
|
41793
41950
|
messages: externalMessages,
|
|
41794
41951
|
source: "external-native"
|
|
41795
41952
|
};
|
|
@@ -41802,8 +41959,9 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41802
41959
|
}
|
|
41803
41960
|
completionFinalSummary(parsedMessages, turnStartedAt) {
|
|
41804
41961
|
const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
|
|
41805
|
-
const parsedSummary =
|
|
41806
|
-
this.completionHasFinalAssistantMessage(parsedMessages) ? Array.isArray(parsedMessages) ? parsedMessages : [] : []
|
|
41962
|
+
const parsedSummary = extractFinalSummaryFromMessagesAfter(
|
|
41963
|
+
this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt) ? Array.isArray(parsedMessages) ? parsedMessages : [] : [],
|
|
41964
|
+
turnStartedAt
|
|
41807
41965
|
);
|
|
41808
41966
|
if (adapterOwnsMessagesElsewhere) {
|
|
41809
41967
|
const externalMessages = this.readExternalCompletionMessages();
|
|
@@ -41908,7 +42066,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41908
42066
|
}
|
|
41909
42067
|
if (parsed?.activeModal || parsed?.modal) return { reason: "parsed_modal_active", terminal: true };
|
|
41910
42068
|
const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
|
|
41911
|
-
const finalAssistantEvidence = this.completionFinalAssistantEvidence(parsed?.messages);
|
|
42069
|
+
const finalAssistantEvidence = this.completionFinalAssistantEvidence(parsed?.messages, pending.turnStartedAt);
|
|
41912
42070
|
const allowMissingAssistantTimeout = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
|
|
41913
42071
|
LOG.debug("CLI", `[${this.type}] finalAssistantEvidence: present=${finalAssistantEvidence.present} source=${finalAssistantEvidence.source} adapterOwnsMessagesElsewhere=${adapterOwnsMessagesElsewhere} parsedStatus=${parsedStatus}`);
|
|
41914
42072
|
if (!finalAssistantEvidence.present) {
|
|
@@ -42005,6 +42163,19 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42005
42163
|
isMeshWorkerSession() {
|
|
42006
42164
|
return !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.meshNodeId || this.settings.launchedByCoordinator);
|
|
42007
42165
|
}
|
|
42166
|
+
// FALSE-IDLE (self-coordinator settle): an autonomously-progressing mesh session
|
|
42167
|
+
// is either a delegated worker (isMeshWorkerSession) OR the coordinator's OWN
|
|
42168
|
+
// claude-cli session (meshCoordinatorFor). Both run auto-approved tool turns whose
|
|
42169
|
+
// inter-approval valley (busy→idle blip→generating re-entry ~0.5s later) must be
|
|
42170
|
+
// absorbed by the completedDebounce settle window, not flushed on the first idle
|
|
42171
|
+
// sample. The worker branch already gets NATIVE_HISTORY_MESH_IDLE_SETTLE_MS; the
|
|
42172
|
+
// self-coordinator session (worker markers absent, meshCoordinatorFor present) was
|
|
42173
|
+
// taking flushDelay=0 — no settle window — so its busyEpoch/lastOutputAt continuity
|
|
42174
|
+
// guard had no window to observe the valley and fired mid-turn "next-step" previews
|
|
42175
|
+
// as a finalSummary. Mirrors the isAutonomousMeshSession notion in isTransientToolConsent.
|
|
42176
|
+
isAutonomousMeshSession() {
|
|
42177
|
+
return this.isMeshWorkerSession() || !!this.settings.meshCoordinatorFor;
|
|
42178
|
+
}
|
|
42008
42179
|
/**
|
|
42009
42180
|
* ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
|
|
42010
42181
|
* Prefers the per-turn binding (engine.currentTurnTaskId, set when the turn was
|
|
@@ -42049,6 +42220,19 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42049
42220
|
this.completedDebounceTimer = null;
|
|
42050
42221
|
return;
|
|
42051
42222
|
}
|
|
42223
|
+
if (typeof pending.busyEpochAtArm === "number" && this.busyEpoch !== pending.busyEpochAtArm) {
|
|
42224
|
+
LOG.info("CLI", `[${this.type}] cancelled pending completed (busy re-entry during settle: epoch ${pending.busyEpochAtArm}\u2192${this.busyEpoch})`);
|
|
42225
|
+
this.completedDebouncePending = null;
|
|
42226
|
+
this.completedDebounceTimer = null;
|
|
42227
|
+
return;
|
|
42228
|
+
}
|
|
42229
|
+
const latestOutputAt = typeof latestStatus?.lastOutputAt === "number" ? latestStatus.lastOutputAt : void 0;
|
|
42230
|
+
if (typeof pending.lastOutputAtArm === "number" && typeof latestOutputAt === "number" && latestOutputAt > pending.lastOutputAtArm) {
|
|
42231
|
+
LOG.info("CLI", `[${this.type}] cancelled pending completed (new PTY output during settle: ${pending.lastOutputAtArm}\u2192${latestOutputAt})`);
|
|
42232
|
+
this.completedDebouncePending = null;
|
|
42233
|
+
this.completedDebounceTimer = null;
|
|
42234
|
+
return;
|
|
42235
|
+
}
|
|
42052
42236
|
const block2 = this.getCompletedFinalizationBlock(latestVisibleStatus, pending);
|
|
42053
42237
|
if (block2) {
|
|
42054
42238
|
const blockReason = block2.reason;
|
|
@@ -42351,6 +42535,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42351
42535
|
this.completedDebouncePending = null;
|
|
42352
42536
|
}
|
|
42353
42537
|
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
42538
|
+
this.busyEpoch++;
|
|
42354
42539
|
if (this.generatingDebounceTimer) clearTimeout(this.generatingDebounceTimer);
|
|
42355
42540
|
this.generatingDebouncePending = { chatTitle, timestamp: now };
|
|
42356
42541
|
this.generatingDebounceTimer = setTimeout(() => {
|
|
@@ -42376,6 +42561,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42376
42561
|
}
|
|
42377
42562
|
this.completedDebouncePending = null;
|
|
42378
42563
|
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
42564
|
+
this.busyEpoch++;
|
|
42379
42565
|
const modal = adapterStatus.activeModal;
|
|
42380
42566
|
LOG.info("CLI", `[${this.type}] approval modal: "${modal?.message?.slice(0, 80) ?? "none"}"`);
|
|
42381
42567
|
const approvalEntrySeq = typeof adapterStatus?.approvalEntrySeq === "number" ? adapterStatus.approvalEntrySeq : 0;
|
|
@@ -42474,12 +42660,18 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42474
42660
|
const engineTurnStart = typeof this.adapter?.currentTurnStartedAt === "number" && Number.isFinite(this.adapter.currentTurnStartedAt) ? this.adapter.currentTurnStartedAt : 0;
|
|
42475
42661
|
const turnStartedAt = engineTurnStart || this.generatingStartedAt || 0;
|
|
42476
42662
|
return turnStartedAt ? { turnStartedAt } : {};
|
|
42477
|
-
})()
|
|
42663
|
+
})(),
|
|
42664
|
+
// FALSE-IDLE continuity: snapshot the busy epoch + raw PTY output
|
|
42665
|
+
// clock at arm time so the flush guard can prove the session stayed
|
|
42666
|
+
// continuously idle (no busy re-entry, no new PTY output) through the
|
|
42667
|
+
// settle window rather than merely reading 'idle' once at flush.
|
|
42668
|
+
busyEpochAtArm: this.busyEpoch,
|
|
42669
|
+
...typeof adapterStatus?.lastOutputAt === "number" && Number.isFinite(adapterStatus.lastOutputAt) ? { lastOutputAtArm: adapterStatus.lastOutputAt } : {}
|
|
42478
42670
|
};
|
|
42479
42671
|
const ownsExternalHistory = !!this.adapter?.chatMessagesOwnedExternally;
|
|
42480
|
-
const
|
|
42481
|
-
const flushDelay = ownsExternalHistory ?
|
|
42482
|
-
LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory}
|
|
42672
|
+
const meshSettleSession = this.isAutonomousMeshSession();
|
|
42673
|
+
const flushDelay = ownsExternalHistory ? meshSettleSession ? NATIVE_HISTORY_MESH_IDLE_SETTLE_MS : 0 : 3e3;
|
|
42674
|
+
LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory} meshSettle=${meshSettleSession} flushDelay=${flushDelay}ms generatingStartedAt=${this.generatingStartedAt}`);
|
|
42483
42675
|
this.scheduleCompletedDebounceFlush(flushDelay);
|
|
42484
42676
|
}
|
|
42485
42677
|
} else if (newStatus === "idle" && this.lastStatus === "starting") {
|
|
@@ -46537,6 +46729,7 @@ function readSession2(sessionPath) {
|
|
|
46537
46729
|
var fs22 = __toESM(require("fs"));
|
|
46538
46730
|
var path31 = __toESM(require("path"));
|
|
46539
46731
|
var os22 = __toESM(require("os"));
|
|
46732
|
+
init_load_better_sqlite3();
|
|
46540
46733
|
function extractTimestampValue3(value) {
|
|
46541
46734
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
46542
46735
|
if (typeof value === "string") {
|
|
@@ -46710,6 +46903,151 @@ function parsePbFile(filePath, sessionId) {
|
|
|
46710
46903
|
}
|
|
46711
46904
|
];
|
|
46712
46905
|
}
|
|
46906
|
+
var AGY_STEP_TYPE_USER = 14;
|
|
46907
|
+
var AGY_STEP_TYPE_MODEL = 15;
|
|
46908
|
+
function readVarint(buf, offset) {
|
|
46909
|
+
let result = 0;
|
|
46910
|
+
let shift = 0;
|
|
46911
|
+
let i = offset;
|
|
46912
|
+
while (i < buf.length) {
|
|
46913
|
+
const byte = buf[i];
|
|
46914
|
+
i += 1;
|
|
46915
|
+
result += (byte & 127) * Math.pow(2, shift);
|
|
46916
|
+
if ((byte & 128) === 0) return [result, i];
|
|
46917
|
+
shift += 7;
|
|
46918
|
+
if (shift > 63) break;
|
|
46919
|
+
}
|
|
46920
|
+
return [result, i];
|
|
46921
|
+
}
|
|
46922
|
+
function decodeProtoFields(buf) {
|
|
46923
|
+
const fields = [];
|
|
46924
|
+
let i = 0;
|
|
46925
|
+
while (i < buf.length) {
|
|
46926
|
+
const [key2, afterKey] = readVarint(buf, i);
|
|
46927
|
+
if (afterKey === i) break;
|
|
46928
|
+
i = afterKey;
|
|
46929
|
+
const field = Math.floor(key2 / 8);
|
|
46930
|
+
const wireType = key2 & 7;
|
|
46931
|
+
if (field <= 0) break;
|
|
46932
|
+
if (wireType === 0) {
|
|
46933
|
+
const [value, next] = readVarint(buf, i);
|
|
46934
|
+
if (next === i) break;
|
|
46935
|
+
i = next;
|
|
46936
|
+
fields.push({ field, wireType, varint: value });
|
|
46937
|
+
} else if (wireType === 2) {
|
|
46938
|
+
const [len, afterLen] = readVarint(buf, i);
|
|
46939
|
+
i = afterLen;
|
|
46940
|
+
if (len < 0 || i + len > buf.length) break;
|
|
46941
|
+
fields.push({ field, wireType, bytes: buf.subarray(i, i + len) });
|
|
46942
|
+
i += len;
|
|
46943
|
+
} else if (wireType === 5) {
|
|
46944
|
+
i += 4;
|
|
46945
|
+
} else if (wireType === 1) {
|
|
46946
|
+
i += 8;
|
|
46947
|
+
} else {
|
|
46948
|
+
break;
|
|
46949
|
+
}
|
|
46950
|
+
}
|
|
46951
|
+
return fields;
|
|
46952
|
+
}
|
|
46953
|
+
function firstLenField(buf, field) {
|
|
46954
|
+
for (const f of decodeProtoFields(buf)) {
|
|
46955
|
+
if (f.field === field && f.wireType === 2 && f.bytes) return f.bytes;
|
|
46956
|
+
}
|
|
46957
|
+
return null;
|
|
46958
|
+
}
|
|
46959
|
+
function looksLikeText(buf) {
|
|
46960
|
+
if (buf.length === 0) return false;
|
|
46961
|
+
let printable = 0;
|
|
46962
|
+
for (let i = 0; i < buf.length; i++) {
|
|
46963
|
+
const b = buf[i];
|
|
46964
|
+
if (b >= 32 && b <= 126 || b === 9 || b === 10 || b === 13 || b >= 128) printable += 1;
|
|
46965
|
+
}
|
|
46966
|
+
return printable / buf.length >= 0.9;
|
|
46967
|
+
}
|
|
46968
|
+
function stripAnswerMarker(text) {
|
|
46969
|
+
return text.replace(/^\s*MARKER_V1\s*/, "");
|
|
46970
|
+
}
|
|
46971
|
+
function extractModelAnswer(payload) {
|
|
46972
|
+
const inner = firstLenField(payload, 20);
|
|
46973
|
+
if (!inner) return "";
|
|
46974
|
+
const answer = firstLenField(inner, 1) ?? firstLenField(inner, 8);
|
|
46975
|
+
if (!answer || !looksLikeText(answer)) return "";
|
|
46976
|
+
return stripAnswerMarker(answer.toString("utf-8")).trim();
|
|
46977
|
+
}
|
|
46978
|
+
function extractUserPrompt(payload) {
|
|
46979
|
+
const inner = firstLenField(payload, 19);
|
|
46980
|
+
if (!inner) return "";
|
|
46981
|
+
const raw = firstLenField(inner, 2) ?? firstLenField(inner, 3);
|
|
46982
|
+
if (!raw || !looksLikeText(raw)) return "";
|
|
46983
|
+
const text = raw.toString("utf-8").trim();
|
|
46984
|
+
if (!text) return "";
|
|
46985
|
+
return extractUserRequestContent(text);
|
|
46986
|
+
}
|
|
46987
|
+
function parseConversationDb(filePath, sessionId, workspace) {
|
|
46988
|
+
let db;
|
|
46989
|
+
try {
|
|
46990
|
+
const Database = loadBetterSqlite3();
|
|
46991
|
+
db = new Database(filePath, { readonly: true, fileMustExist: true });
|
|
46992
|
+
} catch {
|
|
46993
|
+
return null;
|
|
46994
|
+
}
|
|
46995
|
+
let rows;
|
|
46996
|
+
try {
|
|
46997
|
+
rows = db.prepare(
|
|
46998
|
+
`SELECT idx, step_type, step_payload
|
|
46999
|
+
FROM steps
|
|
47000
|
+
WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
|
|
47001
|
+
ORDER BY idx ASC`
|
|
47002
|
+
).all();
|
|
47003
|
+
} catch {
|
|
47004
|
+
return null;
|
|
47005
|
+
} finally {
|
|
47006
|
+
try {
|
|
47007
|
+
db.close();
|
|
47008
|
+
} catch {
|
|
47009
|
+
}
|
|
47010
|
+
}
|
|
47011
|
+
if (!Array.isArray(rows) || rows.length === 0) return null;
|
|
47012
|
+
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
47013
|
+
const baseTs = statMtimeMs3(filePath) || Date.now();
|
|
47014
|
+
const messages = [];
|
|
47015
|
+
for (const row of rows) {
|
|
47016
|
+
const payload = row.step_payload;
|
|
47017
|
+
if (!payload || !Buffer.isBuffer(payload) || payload.length === 0) continue;
|
|
47018
|
+
const receivedAt = baseTs + messages.length;
|
|
47019
|
+
if (row.step_type === AGY_STEP_TYPE_USER) {
|
|
47020
|
+
const content = extractUserPrompt(payload);
|
|
47021
|
+
if (!content) continue;
|
|
47022
|
+
const msg = {
|
|
47023
|
+
ts: new Date(receivedAt).toISOString(),
|
|
47024
|
+
receivedAt,
|
|
47025
|
+
role: "user",
|
|
47026
|
+
content,
|
|
47027
|
+
kind: "standard",
|
|
47028
|
+
agent: "antigravity-cli",
|
|
47029
|
+
historySessionId: sessionId
|
|
47030
|
+
};
|
|
47031
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
47032
|
+
messages.push(msg);
|
|
47033
|
+
} else if (row.step_type === AGY_STEP_TYPE_MODEL) {
|
|
47034
|
+
const content = extractModelAnswer(payload);
|
|
47035
|
+
if (!content) continue;
|
|
47036
|
+
const msg = {
|
|
47037
|
+
ts: new Date(receivedAt).toISOString(),
|
|
47038
|
+
receivedAt,
|
|
47039
|
+
role: "assistant",
|
|
47040
|
+
content,
|
|
47041
|
+
kind: "standard",
|
|
47042
|
+
agent: "antigravity-cli",
|
|
47043
|
+
historySessionId: sessionId
|
|
47044
|
+
};
|
|
47045
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
47046
|
+
messages.push(msg);
|
|
47047
|
+
}
|
|
47048
|
+
}
|
|
47049
|
+
return messages.length > 0 ? messages : null;
|
|
47050
|
+
}
|
|
46713
47051
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
46714
47052
|
if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
|
|
46715
47053
|
if (!fs22.existsSync(sessionPath)) return null;
|
|
@@ -46732,6 +47070,21 @@ function readSession3(sessionPath, sessionId, workspace) {
|
|
|
46732
47070
|
workspace
|
|
46733
47071
|
};
|
|
46734
47072
|
}
|
|
47073
|
+
if (sessionPath.endsWith(".db")) {
|
|
47074
|
+
const dbSessionId = sessionId || path31.basename(sessionPath, ".db");
|
|
47075
|
+
if (!isUuidLike(dbSessionId)) return null;
|
|
47076
|
+
const messages = parseConversationDb(sessionPath, dbSessionId, workspace);
|
|
47077
|
+
if (!messages || messages.length === 0) return null;
|
|
47078
|
+
return {
|
|
47079
|
+
messages,
|
|
47080
|
+
providerSessionId: dbSessionId,
|
|
47081
|
+
source: "provider-native",
|
|
47082
|
+
sourcePath: sessionPath,
|
|
47083
|
+
sourceMtimeMs,
|
|
47084
|
+
nativeHistoryCoverage: "full",
|
|
47085
|
+
workspace
|
|
47086
|
+
};
|
|
47087
|
+
}
|
|
46735
47088
|
if (sessionPath.endsWith(".pb")) {
|
|
46736
47089
|
const pbSessionId = sessionId || path31.basename(sessionPath, ".pb");
|
|
46737
47090
|
if (!isUuidLike(pbSessionId)) return null;
|
|
@@ -46960,7 +47313,7 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
|
|
|
46960
47313
|
case "codex-cli":
|
|
46961
47314
|
return resolveCodexPath(workspace, sessionId, sessionStartedAtMs);
|
|
46962
47315
|
case "antigravity-cli":
|
|
46963
|
-
return resolveAntigravityPath(workspace);
|
|
47316
|
+
return resolveAntigravityPath(workspace, sessionId);
|
|
46964
47317
|
case "hermes-cli":
|
|
46965
47318
|
return resolveHermesPath(workspace, sessionId);
|
|
46966
47319
|
}
|
|
@@ -47075,16 +47428,25 @@ function resolveRealPath(value) {
|
|
|
47075
47428
|
return value;
|
|
47076
47429
|
}
|
|
47077
47430
|
}
|
|
47078
|
-
function resolveAntigravityPath(workspace) {
|
|
47431
|
+
function resolveAntigravityPath(workspace, sessionId) {
|
|
47079
47432
|
void workspace;
|
|
47080
|
-
const
|
|
47081
|
-
if (
|
|
47082
|
-
|
|
47083
|
-
|
|
47084
|
-
for (const e of entries) {
|
|
47085
|
-
const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
|
|
47086
|
-
if (fs24.existsSync(t)) return t;
|
|
47433
|
+
const agyRoot = path33.join(os24.homedir(), ".gemini", "antigravity-cli");
|
|
47434
|
+
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
47435
|
+
const dbPath = path33.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
47436
|
+
if (fs24.existsSync(dbPath)) return dbPath;
|
|
47087
47437
|
}
|
|
47438
|
+
const brainRoot2 = path33.join(agyRoot, "brain");
|
|
47439
|
+
if (fs24.existsSync(brainRoot2)) {
|
|
47440
|
+
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
47441
|
+
const entries = fs24.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path33.join(brainRoot2, e.name), mtime: safeMtime(path33.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
47442
|
+
for (const e of entries) {
|
|
47443
|
+
const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
|
|
47444
|
+
if (fs24.existsSync(t)) return t;
|
|
47445
|
+
}
|
|
47446
|
+
}
|
|
47447
|
+
const convRoot = path33.join(agyRoot, "conversations");
|
|
47448
|
+
const newestDb = newestRecentFile2(convRoot, /^[0-9a-f-]+\.db$/i);
|
|
47449
|
+
if (newestDb) return newestDb;
|
|
47088
47450
|
return null;
|
|
47089
47451
|
}
|
|
47090
47452
|
function resolveHermesPath(workspace, sessionId) {
|
|
@@ -51282,12 +51644,13 @@ var meshEventsHandlers = {
|
|
|
51282
51644
|
get_pending_mesh_events: async (ctx, args) => {
|
|
51283
51645
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
51284
51646
|
const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : void 0;
|
|
51647
|
+
const selfCoordinatorInboxRead = args?.selfCoordinatorInboxRead === true;
|
|
51285
51648
|
const hasLiveCliCoordinator = meshId ? resolveCoordinatorDrainDeliverability(ctx.deps, meshId).hasLiveCliCoordinator : false;
|
|
51286
|
-
if (meshId && shouldHoldPendingDrainForBusyLocalCoordinator(ctx.deps, meshId, coordinatorDaemonId)) {
|
|
51649
|
+
if (meshId && shouldHoldPendingDrainForBusyLocalCoordinator(ctx.deps, meshId, coordinatorDaemonId, selfCoordinatorInboxRead)) {
|
|
51287
51650
|
return { success: true, events: [], heldForBusyLocalCoordinator: true, hasLiveCliCoordinator };
|
|
51288
51651
|
}
|
|
51289
51652
|
const events = drainPendingMeshCoordinatorEvents(meshId || void 0, coordinatorDaemonId);
|
|
51290
|
-
return { success: true, events, hasLiveCliCoordinator };
|
|
51653
|
+
return { success: true, events, hasLiveCliCoordinator, ...selfCoordinatorInboxRead ? { surfacedForSelfCoordinator: true } : {} };
|
|
51291
51654
|
},
|
|
51292
51655
|
interactive_prompt_response: async (ctx, args) => {
|
|
51293
51656
|
const sessionId = typeof args?.targetSessionId === "string" && args.targetSessionId.trim() ? args.targetSessionId.trim() : typeof args?.sessionId === "string" && args.sessionId.trim() ? args.sessionId.trim() : "";
|
|
@@ -51355,8 +51718,8 @@ var meshCoordinatorLaunchHandlers = {
|
|
|
51355
51718
|
};
|
|
51356
51719
|
const buildOperatingNotesBestEffort = async (id) => {
|
|
51357
51720
|
try {
|
|
51358
|
-
const {
|
|
51359
|
-
const noteEntries =
|
|
51721
|
+
const { readOperatingNotes: readOperatingNotes2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
51722
|
+
const noteEntries = readOperatingNotes2(id, { tail: 20 });
|
|
51360
51723
|
const notes = noteEntries.map((e) => {
|
|
51361
51724
|
const p = e.payload || {};
|
|
51362
51725
|
const text = typeof p.text === "string" ? p.text.trim() : "";
|
|
@@ -51925,6 +52288,7 @@ var meshStatusHandlers = {
|
|
|
51925
52288
|
mesh_status: async (ctx, args) => {
|
|
51926
52289
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
51927
52290
|
if (!meshId) return { success: false, error: "meshId required" };
|
|
52291
|
+
const startedAtMs = Date.now();
|
|
51928
52292
|
try {
|
|
51929
52293
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
51930
52294
|
const mesh = meshRecord?.mesh;
|
|
@@ -51942,10 +52306,38 @@ var meshStatusHandlers = {
|
|
|
51942
52306
|
meshId,
|
|
51943
52307
|
command: "mesh_status",
|
|
51944
52308
|
refreshRequested,
|
|
52309
|
+
durationMs: Date.now() - startedAtMs,
|
|
51945
52310
|
summary: summarizeRepoMeshStatusDebug(cachedStatus)
|
|
51946
52311
|
});
|
|
51947
52312
|
return cachedStatus;
|
|
51948
52313
|
}
|
|
52314
|
+
const staleStatus = ctx.getCachedAggregateMeshStatus(meshId, mesh, {
|
|
52315
|
+
requireDirectPeerTruth: args?.requireDirectPeerTruth === true,
|
|
52316
|
+
allowStalePending: true
|
|
52317
|
+
});
|
|
52318
|
+
if (staleStatus) {
|
|
52319
|
+
if (!ctx.swrRefreshInFlight.has(meshId)) {
|
|
52320
|
+
ctx.swrRefreshInFlight.add(meshId);
|
|
52321
|
+
void Promise.resolve().then(() => ctx.execute("mesh_status", {
|
|
52322
|
+
meshId,
|
|
52323
|
+
inlineMesh: args?.inlineMesh,
|
|
52324
|
+
coordinatorDaemonId: args?.coordinatorDaemonId,
|
|
52325
|
+
requireDirectPeerTruth: args?.requireDirectPeerTruth === true,
|
|
52326
|
+
refresh: true
|
|
52327
|
+
}, "mesh_status_swr_freshen")).catch(() => {
|
|
52328
|
+
}).finally(() => {
|
|
52329
|
+
ctx.swrRefreshInFlight.delete(meshId);
|
|
52330
|
+
});
|
|
52331
|
+
}
|
|
52332
|
+
logRepoMeshStatusDebug("return_stale_swr", {
|
|
52333
|
+
meshId,
|
|
52334
|
+
command: "mesh_status",
|
|
52335
|
+
refreshRequested,
|
|
52336
|
+
durationMs: Date.now() - startedAtMs,
|
|
52337
|
+
summary: summarizeRepoMeshStatusDebug(staleStatus)
|
|
52338
|
+
});
|
|
52339
|
+
return staleStatus;
|
|
52340
|
+
}
|
|
51949
52341
|
}
|
|
51950
52342
|
const refreshReason = refreshRequested ? "explicit_refresh" : pendingCoordinatorEventCount > 0 ? "pending_coordinator_events" : hadAggregateCache ? "stale_pending_cache_refresh" : "cold_cache_miss";
|
|
51951
52343
|
const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
@@ -52026,8 +52418,7 @@ var meshStatusHandlers = {
|
|
|
52026
52418
|
);
|
|
52027
52419
|
const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? selectedCoordinatorNodeId : void 0;
|
|
52028
52420
|
const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52029
|
-
const
|
|
52030
|
-
for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
|
|
52421
|
+
const renderMeshNode = async (nodeIndex, node) => {
|
|
52031
52422
|
const nodeId = normalizeMeshNodeId(node) ?? "";
|
|
52032
52423
|
const daemonId = readStringValue(node.daemonId);
|
|
52033
52424
|
const nodeMachineId = readMeshNodeMachineId(node);
|
|
@@ -52182,19 +52573,19 @@ var meshStatusHandlers = {
|
|
|
52182
52573
|
)) {
|
|
52183
52574
|
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
52184
52575
|
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
52185
|
-
|
|
52186
|
-
continue;
|
|
52576
|
+
return status;
|
|
52187
52577
|
}
|
|
52188
52578
|
if (meshRecord?.source === "inline_cache" && !isSelfNode) {
|
|
52189
52579
|
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
52190
52580
|
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
52191
|
-
|
|
52192
|
-
continue;
|
|
52581
|
+
return status;
|
|
52193
52582
|
}
|
|
52194
52583
|
}
|
|
52195
52584
|
} else {
|
|
52196
52585
|
try {
|
|
52197
|
-
const
|
|
52586
|
+
const runLocalProbe = () => getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
52587
|
+
const gitStatus = await meshGitProbeCache.probeLocal(workspace, runLocalProbe);
|
|
52588
|
+
if (!gitStatus) throw new Error("local_git_probe_unavailable");
|
|
52198
52589
|
status.git = gitStatus;
|
|
52199
52590
|
status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
|
|
52200
52591
|
const reporter = recordInlineMeshDirectGitTruth(node, gitStatus, "selected_coordinator_local_git");
|
|
@@ -52216,8 +52607,38 @@ var meshStatusHandlers = {
|
|
|
52216
52607
|
}
|
|
52217
52608
|
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
52218
52609
|
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
52219
|
-
|
|
52220
|
-
}
|
|
52610
|
+
return status;
|
|
52611
|
+
};
|
|
52612
|
+
const meshNodeEntries = [...(mesh.nodes || []).entries()];
|
|
52613
|
+
const settledNodeStatuses = await Promise.allSettled(
|
|
52614
|
+
meshNodeEntries.map(([nodeIndex, node]) => renderMeshNode(nodeIndex, node))
|
|
52615
|
+
);
|
|
52616
|
+
const nodeStatuses = settledNodeStatuses.map((settled, i) => {
|
|
52617
|
+
if (settled.status === "fulfilled") return settled.value;
|
|
52618
|
+
const [nodeIndex, node] = meshNodeEntries[i];
|
|
52619
|
+
const nodeId = normalizeMeshNodeId(node) ?? "";
|
|
52620
|
+
const daemonId = readStringValue(node.daemonId);
|
|
52621
|
+
const fallback = {
|
|
52622
|
+
nodeId,
|
|
52623
|
+
machineLabel: buildMeshNodeDisplayLabel(node, nodeId, readProviderPriorityFromPolicy(node.policy)),
|
|
52624
|
+
workspace: node.workspace,
|
|
52625
|
+
repoRoot: node.repoRoot,
|
|
52626
|
+
isLocalWorktree: node.isLocalWorktree,
|
|
52627
|
+
worktreeBranch: node.worktreeBranch,
|
|
52628
|
+
daemonId,
|
|
52629
|
+
machineId: readMeshNodeMachineId(node) || node.machineId,
|
|
52630
|
+
health: "unknown",
|
|
52631
|
+
providers: node.providers || [],
|
|
52632
|
+
activeSessions: [],
|
|
52633
|
+
activeSessionDetails: [],
|
|
52634
|
+
launchReady: false,
|
|
52635
|
+
error: settled.reason instanceof Error ? settled.reason.message : "node render failed"
|
|
52636
|
+
};
|
|
52637
|
+
applyCachedInlineMeshNodeStatus(fallback, node);
|
|
52638
|
+
applyInlineMeshBranchConvergence(mesh, node, fallback);
|
|
52639
|
+
finalizeMeshNodeStatus({ status: fallback, node, daemonId, isSelfNode: false, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
52640
|
+
return fallback;
|
|
52641
|
+
});
|
|
52221
52642
|
const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : ctx.deps.statusInstanceId || void 0;
|
|
52222
52643
|
const pendingCoordinatorEvents = getPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
|
|
52223
52644
|
const unroutableDeliveries = getRecentUnroutableDeliveries();
|
|
@@ -52333,6 +52754,7 @@ var meshStatusHandlers = {
|
|
|
52333
52754
|
refreshReason,
|
|
52334
52755
|
meshSource: meshRecord.source,
|
|
52335
52756
|
directTruth,
|
|
52757
|
+
durationMs: Date.now() - startedAtMs,
|
|
52336
52758
|
summary: summarizeRepoMeshStatusDebug(returnedStatus)
|
|
52337
52759
|
});
|
|
52338
52760
|
return returnedStatus;
|
|
@@ -53533,7 +53955,7 @@ var MESH_DIRECT_PROBE_TIMEOUT_MS = readMeshTimeoutEnvMs("MESH_DIRECT_PROBE_TIMEO
|
|
|
53533
53955
|
var MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS = readMeshTimeoutEnvMs("MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS", 25e3);
|
|
53534
53956
|
var MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS = MESH_CONNECT_TIMEOUT_MS;
|
|
53535
53957
|
var MESH_DIRECT_PROBE_REUSE_MS = readMeshTimeoutEnvMs("MESH_DIRECT_PROBE_REUSE_MS", 12e3);
|
|
53536
|
-
var MeshGitProbeCache = class {
|
|
53958
|
+
var MeshGitProbeCache = class _MeshGitProbeCache {
|
|
53537
53959
|
constructor(reuseMs, now = Date.now) {
|
|
53538
53960
|
this.reuseMs = reuseMs;
|
|
53539
53961
|
this.now = now;
|
|
@@ -53543,6 +53965,23 @@ var MeshGitProbeCache = class {
|
|
|
53543
53965
|
key(daemonId, workspace) {
|
|
53544
53966
|
return `${daemonId}::${workspace}`;
|
|
53545
53967
|
}
|
|
53968
|
+
/**
|
|
53969
|
+
* Local (same-machine) git_status dedup. The bootstrap direct-truth hydrate
|
|
53970
|
+
* and the per-node render loop both call getGitRepoStatus(refreshUpstream:true)
|
|
53971
|
+
* for the same local workspace within one mesh_status call. Each such probe
|
|
53972
|
+
* fans out ~13-15 git subprocesses, and because the two passes are separated by
|
|
53973
|
+
* the render/hydrate work of every OTHER node they routinely straddle the
|
|
53974
|
+
* getGitRepoStatus 1.5s TTL, so the second pass re-shells the whole ~14-process
|
|
53975
|
+
* collection. Routing both through this cache (namespaced under a reserved
|
|
53976
|
+
* daemon id so it never collides with a remote-peer key) collapses them to one
|
|
53977
|
+
* collection per workspace per request, and reuses it across the reuse window
|
|
53978
|
+
* so the dashboard auto-retry loop can't restart a fresh local probe seconds
|
|
53979
|
+
* apart either.
|
|
53980
|
+
*/
|
|
53981
|
+
static LOCAL_PROBE_DAEMON_ID = "__local_git__";
|
|
53982
|
+
async probeLocal(workspace, probe) {
|
|
53983
|
+
return this.probe(_MeshGitProbeCache.LOCAL_PROBE_DAEMON_ID, workspace, probe);
|
|
53984
|
+
}
|
|
53546
53985
|
/**
|
|
53547
53986
|
* Run `probe` for this peer, but reuse a fresh recent result or an in-flight
|
|
53548
53987
|
* probe for the same key when one is available. `probe` is only invoked when
|
|
@@ -53653,7 +54092,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
53653
54092
|
let standingEvidenceCount = 0;
|
|
53654
54093
|
const unavailableNodeIds = [];
|
|
53655
54094
|
const deadNodeIds = [];
|
|
53656
|
-
|
|
54095
|
+
const classifyNode = async (nodeIndex, node) => {
|
|
53657
54096
|
const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
|
|
53658
54097
|
const workspace = readStringValue(node?.workspace);
|
|
53659
54098
|
const daemonId = readStringValue(node?.daemonId);
|
|
@@ -53666,38 +54105,33 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
53666
54105
|
daemonId && (daemonIdsEquivalent(daemonId, args.localMachineId) || daemonIdsEquivalent(daemonId, args.statusInstanceId))
|
|
53667
54106
|
);
|
|
53668
54107
|
if ((isSelfNode || isSelfDaemonNode) && isDeadLocalWorktreeNode(node)) {
|
|
53669
|
-
|
|
53670
|
-
continue;
|
|
54108
|
+
return { kind: "dead", nodeId };
|
|
53671
54109
|
}
|
|
53672
54110
|
if (!workspace) {
|
|
53673
|
-
|
|
53674
|
-
continue;
|
|
54111
|
+
return !isSelfNode && daemonId ? { kind: "unavailable", nodeId } : { kind: "skip" };
|
|
53675
54112
|
}
|
|
53676
54113
|
if (fs29.existsSync(workspace)) {
|
|
53677
54114
|
try {
|
|
53678
|
-
const
|
|
54115
|
+
const runLocalProbe = () => getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
54116
|
+
const localGit = args.probeCache ? await args.probeCache.probeLocal(workspace, runLocalProbe) : await runLocalProbe();
|
|
53679
54117
|
if (localGit?.isGitRepo) {
|
|
53680
54118
|
const reporter = recordInlineMeshDirectGitTruth(node, localGit, "selected_coordinator_local_git");
|
|
53681
54119
|
persistNodeReporterPlatform(args.meshSource, args.mesh, nodeId, reporter);
|
|
53682
|
-
|
|
53683
|
-
continue;
|
|
54120
|
+
return { kind: "local" };
|
|
53684
54121
|
}
|
|
53685
54122
|
} catch {
|
|
53686
54123
|
}
|
|
53687
54124
|
}
|
|
53688
54125
|
const standingGit = buildInlineMeshTransitGitStatus(node);
|
|
53689
54126
|
if (standingGit) {
|
|
53690
|
-
|
|
53691
|
-
continue;
|
|
54127
|
+
return { kind: "standing" };
|
|
53692
54128
|
}
|
|
53693
54129
|
if (!args.probeRemotePeers) {
|
|
53694
|
-
|
|
54130
|
+
return { kind: "skip" };
|
|
53695
54131
|
}
|
|
53696
54132
|
if (!daemonId || !args.dispatchMeshCommand) {
|
|
53697
|
-
|
|
53698
|
-
continue;
|
|
54133
|
+
return !isSelfNode ? { kind: "unavailable", nodeId } : { kind: "skip" };
|
|
53699
54134
|
}
|
|
53700
|
-
peerAttemptedCount += 1;
|
|
53701
54135
|
const runProbe = () => probeRemoteMeshGitStatusWithRetry({
|
|
53702
54136
|
dispatchMeshCommand: args.dispatchMeshCommand,
|
|
53703
54137
|
daemonId,
|
|
@@ -53711,11 +54145,52 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
53711
54145
|
if (remoteGit) {
|
|
53712
54146
|
const reporter = recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
53713
54147
|
persistNodeReporterPlatform(args.meshSource, args.mesh, nodeId, reporter);
|
|
53714
|
-
|
|
53715
|
-
continue;
|
|
54148
|
+
return { kind: "peerConfirmed" };
|
|
53716
54149
|
}
|
|
53717
|
-
|
|
53718
|
-
}
|
|
54150
|
+
return { kind: "peerUnavailable", nodeId };
|
|
54151
|
+
};
|
|
54152
|
+
const nodeEntries = [...nodes.entries()];
|
|
54153
|
+
const settledResults = await Promise.allSettled(
|
|
54154
|
+
nodeEntries.map(([nodeIndex, node]) => classifyNode(nodeIndex, node))
|
|
54155
|
+
);
|
|
54156
|
+
settledResults.forEach((settled, i) => {
|
|
54157
|
+
const [nodeIndex, node] = nodeEntries[i];
|
|
54158
|
+
const result = settled.status === "fulfilled" ? settled.value : (() => {
|
|
54159
|
+
const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
|
|
54160
|
+
const daemonId = readStringValue(node?.daemonId);
|
|
54161
|
+
const isSelfNode = Boolean(
|
|
54162
|
+
nodeId && selectedCoordinatorNodeId && nodeId === selectedCoordinatorNodeId
|
|
54163
|
+
) || Boolean(
|
|
54164
|
+
daemonId && (daemonIdsEquivalent(daemonId, args.localMachineId) || daemonIdsEquivalent(daemonId, args.statusInstanceId))
|
|
54165
|
+
);
|
|
54166
|
+
return !isSelfNode && daemonId ? { kind: "unavailable", nodeId } : { kind: "skip" };
|
|
54167
|
+
})();
|
|
54168
|
+
switch (result.kind) {
|
|
54169
|
+
case "dead":
|
|
54170
|
+
deadNodeIds.push(result.nodeId);
|
|
54171
|
+
break;
|
|
54172
|
+
case "unavailable":
|
|
54173
|
+
unavailableNodeIds.push(result.nodeId);
|
|
54174
|
+
break;
|
|
54175
|
+
case "local":
|
|
54176
|
+
localConfirmedCount += 1;
|
|
54177
|
+
break;
|
|
54178
|
+
case "standing":
|
|
54179
|
+
standingEvidenceCount += 1;
|
|
54180
|
+
break;
|
|
54181
|
+
case "peerConfirmed":
|
|
54182
|
+
peerAttemptedCount += 1;
|
|
54183
|
+
peerConfirmedCount += 1;
|
|
54184
|
+
break;
|
|
54185
|
+
case "peerUnavailable":
|
|
54186
|
+
peerAttemptedCount += 1;
|
|
54187
|
+
unavailableNodeIds.push(result.nodeId);
|
|
54188
|
+
break;
|
|
54189
|
+
case "skip":
|
|
54190
|
+
default:
|
|
54191
|
+
break;
|
|
54192
|
+
}
|
|
54193
|
+
});
|
|
53719
54194
|
return {
|
|
53720
54195
|
directEvidenceCount: localConfirmedCount + peerConfirmedCount + standingEvidenceCount,
|
|
53721
54196
|
localConfirmedCount,
|
|
@@ -55086,6 +55561,10 @@ var DaemonCommandRouter = class {
|
|
|
55086
55561
|
* Spans separate mesh_status/get_mesh calls so the dashboard auto-retry
|
|
55087
55562
|
* loop cannot storm a slow peer with back-to-back refreshUpstream probes. */
|
|
55088
55563
|
meshGitProbeCache = new MeshGitProbeCache(MESH_DIRECT_PROBE_REUSE_MS);
|
|
55564
|
+
/** Meshes with a background SWR freshen (async mesh_status refresh) already in
|
|
55565
|
+
* flight — so a burst of interactive detail-opens serves the cached snapshot
|
|
55566
|
+
* and coalesces onto ONE background refresh instead of storming the peers. */
|
|
55567
|
+
swrRefreshInFlight = /* @__PURE__ */ new Set();
|
|
55089
55568
|
/** In-memory async Refinery jobs keyed by meshId:nodeId to reject/return duplicate in-flight requests. */
|
|
55090
55569
|
runningRefineJobs = /* @__PURE__ */ new Map();
|
|
55091
55570
|
/** Terminal async Refinery jobs preserve a clear answer after the worktree node has been removed. */
|
|
@@ -55189,7 +55668,7 @@ var DaemonCommandRouter = class {
|
|
|
55189
55668
|
if (cached3.queueRevision !== getMeshQueueRevision(meshId)) return null;
|
|
55190
55669
|
let snapshot = this.cloneJsonValue(cached3.snapshot);
|
|
55191
55670
|
snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
|
|
55192
|
-
if (shouldRefreshStalePendingAggregate(snapshot, options)) return null;
|
|
55671
|
+
if (!options?.allowStalePending && shouldRefreshStalePendingAggregate(snapshot, options)) return null;
|
|
55193
55672
|
const ageMs = Math.max(0, Date.now() - cached3.builtAt);
|
|
55194
55673
|
const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
|
|
55195
55674
|
snapshot.sourceOfTruth = {
|
|
@@ -55419,6 +55898,7 @@ var DaemonCommandRouter = class {
|
|
|
55419
55898
|
rememberAggregateMeshStatus: this.rememberAggregateMeshStatus.bind(this),
|
|
55420
55899
|
execute: this.execute.bind(this),
|
|
55421
55900
|
aggregateMeshStatusCache: this.aggregateMeshStatusCache,
|
|
55901
|
+
swrRefreshInFlight: this.swrRefreshInFlight,
|
|
55422
55902
|
runningRefineJobs: this.runningRefineJobs,
|
|
55423
55903
|
inlineMeshCache: this.inlineMeshCache,
|
|
55424
55904
|
meshGitProbeCache: this.meshGitProbeCache
|
|
@@ -65934,6 +66414,10 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
65934
66414
|
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
65935
66415
|
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
65936
66416
|
NodePtyTransportFactory,
|
|
66417
|
+
OPERATING_NOTE_DEDUPE_WINDOW,
|
|
66418
|
+
OPERATING_NOTE_KEEP_LATEST,
|
|
66419
|
+
OPERATING_NOTE_KIND,
|
|
66420
|
+
OPERATING_NOTE_TOMBSTONE_KIND,
|
|
65937
66421
|
P2pRelayFailureError,
|
|
65938
66422
|
PRUNABLE_ORPHAN_STALE_REASONS,
|
|
65939
66423
|
ProviderCliAdapter,
|
|
@@ -66103,6 +66587,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66103
66587
|
isManagedStatusWaiting,
|
|
66104
66588
|
isManagedStatusWorking,
|
|
66105
66589
|
isMeshHostOwner,
|
|
66590
|
+
isOperatingNoteTombstoned,
|
|
66106
66591
|
isP2pRelayTransportFailure,
|
|
66107
66592
|
isPathInside,
|
|
66108
66593
|
isSessionHostLiveRuntime,
|
|
@@ -66171,6 +66656,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66171
66656
|
prepareSessionChatTailUpdate,
|
|
66172
66657
|
prepareSessionModalUpdate,
|
|
66173
66658
|
probeCdpPort,
|
|
66659
|
+
pruneOperatingNotes,
|
|
66174
66660
|
pruneStaleDirectDispatches,
|
|
66175
66661
|
queuePendingMeshCoordinatorEvent,
|
|
66176
66662
|
readAntigravityCliSession,
|
|
@@ -66183,6 +66669,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66183
66669
|
readLedgerSlice,
|
|
66184
66670
|
readLedgerSliceFromStore,
|
|
66185
66671
|
readMeshCompletionSummary,
|
|
66672
|
+
readOperatingNotes,
|
|
66186
66673
|
reconcileDirectDispatchCompletionFromTranscript,
|
|
66187
66674
|
recordCompletionConflict,
|
|
66188
66675
|
recordDebugTrace,
|
|
@@ -66240,6 +66727,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66240
66727
|
summarizeMeshMagiActivity,
|
|
66241
66728
|
summarizeMeshMission,
|
|
66242
66729
|
summarizeMissionTasks,
|
|
66730
|
+
tombstoneOperatingNote,
|
|
66243
66731
|
triggerMeshQueue,
|
|
66244
66732
|
unregisterMeshCoordinator,
|
|
66245
66733
|
updateConfig,
|