@adhdev/daemon-core 0.9.82-rc.443 → 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/index.d.ts +1 -1
- package/dist/index.js +334 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +326 -22
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-ledger.d.ts +39 -1
- package/dist/providers/cli-provider-instance.d.ts +1 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +28 -2
- package/package.json +2 -2
- package/src/commands/high-family/mesh-coordinator-launch.ts +4 -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/providers/cli-provider-instance.ts +35 -9
- package/src/providers/native-history/antigravity-cli-transcript.ts +348 -25
- package/src/providers/native-history/dispatcher.ts +33 -14
package/dist/index.mjs
CHANGED
|
@@ -404,10 +404,10 @@ function readInjected(value) {
|
|
|
404
404
|
}
|
|
405
405
|
function getDaemonBuildInfo() {
|
|
406
406
|
if (cached) return cached;
|
|
407
|
-
const commit = readInjected(true ? "
|
|
408
|
-
const commitShort = readInjected(true ? "
|
|
409
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
410
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
407
|
+
const commit = readInjected(true ? "fafdde138250b2edcbf2e42c643e3cabd1b8bda0" : void 0) ?? "unknown";
|
|
408
|
+
const commitShort = readInjected(true ? "fafdde13" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
409
|
+
const version = readInjected(true ? "0.9.82-rc.444" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
410
|
+
const builtAt = readInjected(true ? "2026-07-01T12:06:17.132Z" : void 0);
|
|
411
411
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
412
412
|
return cached;
|
|
413
413
|
}
|
|
@@ -3711,6 +3711,7 @@ var init_coordinator_prompt = __esm({
|
|
|
3711
3711
|
| \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
|
|
3712
3712
|
| \`mesh_task_history\` | Read the task ledger \u2014 dispatches, completions, failures. Use to understand what has been done before deciding next steps |
|
|
3713
3713
|
| \`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 |
|
|
3714
|
+
| \`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) |
|
|
3714
3715
|
| \`mesh_git_status\` | Check git status on a specific node |
|
|
3715
3716
|
| \`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 |
|
|
3716
3717
|
| \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
|
|
@@ -4096,6 +4097,10 @@ var init_load_better_sqlite3 = __esm({
|
|
|
4096
4097
|
var mesh_ledger_exports = {};
|
|
4097
4098
|
__export(mesh_ledger_exports, {
|
|
4098
4099
|
MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
|
|
4100
|
+
OPERATING_NOTE_DEDUPE_WINDOW: () => OPERATING_NOTE_DEDUPE_WINDOW,
|
|
4101
|
+
OPERATING_NOTE_KEEP_LATEST: () => OPERATING_NOTE_KEEP_LATEST,
|
|
4102
|
+
OPERATING_NOTE_KIND: () => OPERATING_NOTE_KIND,
|
|
4103
|
+
OPERATING_NOTE_TOMBSTONE_KIND: () => OPERATING_NOTE_TOMBSTONE_KIND,
|
|
4099
4104
|
__clearMeshLedgerForTests: () => __clearMeshLedgerForTests,
|
|
4100
4105
|
appendLedgerEntry: () => appendLedgerEntry,
|
|
4101
4106
|
appendRemoteLedgerEntries: () => appendRemoteLedgerEntries,
|
|
@@ -4106,11 +4111,15 @@ __export(mesh_ledger_exports, {
|
|
|
4106
4111
|
getLedgerSummary: () => getLedgerSummary,
|
|
4107
4112
|
getSessionRecoveryContext: () => getSessionRecoveryContext,
|
|
4108
4113
|
isIntentionalCleanupStopEntry: () => isIntentionalCleanupStopEntry,
|
|
4114
|
+
isOperatingNoteTombstoned: () => isOperatingNoteTombstoned,
|
|
4109
4115
|
meshLedgerEvents: () => meshLedgerEvents,
|
|
4110
4116
|
normalizeMeshWorkerResult: () => normalizeMeshWorkerResult,
|
|
4117
|
+
pruneOperatingNotes: () => pruneOperatingNotes,
|
|
4111
4118
|
readLedgerEntries: () => readLedgerEntries,
|
|
4112
4119
|
readLedgerSlice: () => readLedgerSlice,
|
|
4113
|
-
readLedgerSliceFromStore: () => readLedgerSliceFromStore
|
|
4120
|
+
readLedgerSliceFromStore: () => readLedgerSliceFromStore,
|
|
4121
|
+
readOperatingNotes: () => readOperatingNotes,
|
|
4122
|
+
tombstoneOperatingNote: () => tombstoneOperatingNote
|
|
4114
4123
|
});
|
|
4115
4124
|
import { appendFileSync, existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync5, statSync as statSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
4116
4125
|
import { join as join8 } from "path";
|
|
@@ -4384,6 +4393,17 @@ function buildTaskCompletionEvidence(opts) {
|
|
|
4384
4393
|
};
|
|
4385
4394
|
}
|
|
4386
4395
|
function appendLedgerEntry(meshId, partial) {
|
|
4396
|
+
if (partial.kind === OPERATING_NOTE_KIND) {
|
|
4397
|
+
const text = operatingNoteText(partial.payload);
|
|
4398
|
+
if (text) {
|
|
4399
|
+
const recentNotes = readLedgerEntries(meshId, {
|
|
4400
|
+
kind: [OPERATING_NOTE_KIND],
|
|
4401
|
+
tail: OPERATING_NOTE_DEDUPE_WINDOW
|
|
4402
|
+
});
|
|
4403
|
+
const existing = recentNotes.find((e) => operatingNoteText(e.payload) === text);
|
|
4404
|
+
if (existing) return existing;
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4387
4407
|
const entry = {
|
|
4388
4408
|
id: randomUUID4(),
|
|
4389
4409
|
meshId,
|
|
@@ -4421,11 +4441,101 @@ function appendLedgerEntry(meshId, partial) {
|
|
|
4421
4441
|
appendFileSync(filePath, line, { encoding: "utf-8", mode: 384 });
|
|
4422
4442
|
invalidateLedgerCache(meshId);
|
|
4423
4443
|
meshLedgerEvents.emit("append", meshId, entry);
|
|
4444
|
+
if (entry.kind === OPERATING_NOTE_KIND || entry.kind === OPERATING_NOTE_TOMBSTONE_KIND) {
|
|
4445
|
+
try {
|
|
4446
|
+
pruneOperatingNotes(meshId);
|
|
4447
|
+
} catch {
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4424
4450
|
return entry;
|
|
4425
4451
|
} catch (e) {
|
|
4426
4452
|
throw new Error(`Failed to append to ledger for mesh ${meshId}: ${e.message}`);
|
|
4427
4453
|
}
|
|
4428
4454
|
}
|
|
4455
|
+
function operatingNoteText(payload) {
|
|
4456
|
+
const text = payload && typeof payload.text === "string" ? payload.text.trim() : "";
|
|
4457
|
+
return text || void 0;
|
|
4458
|
+
}
|
|
4459
|
+
function collectOperatingNoteTombstones(entries) {
|
|
4460
|
+
const ids = /* @__PURE__ */ new Set();
|
|
4461
|
+
const fingerprints = /* @__PURE__ */ new Set();
|
|
4462
|
+
for (const e of entries) {
|
|
4463
|
+
if (e.kind !== OPERATING_NOTE_TOMBSTONE_KIND) continue;
|
|
4464
|
+
const p = e.payload || {};
|
|
4465
|
+
const targetId = typeof p.targetNoteId === "string" ? p.targetNoteId.trim() : "";
|
|
4466
|
+
const targetFp = typeof p.targetFingerprint === "string" ? p.targetFingerprint.trim() : "";
|
|
4467
|
+
if (targetId) ids.add(targetId);
|
|
4468
|
+
if (targetFp) fingerprints.add(targetFp);
|
|
4469
|
+
}
|
|
4470
|
+
return { ids, fingerprints };
|
|
4471
|
+
}
|
|
4472
|
+
function isOperatingNoteTombstoned(entry, tombstones) {
|
|
4473
|
+
if (tombstones.ids.has(entry.id)) return true;
|
|
4474
|
+
const text = operatingNoteText(entry.payload);
|
|
4475
|
+
return text ? tombstones.fingerprints.has(text) : false;
|
|
4476
|
+
}
|
|
4477
|
+
function tombstoneOperatingNote(meshId, target) {
|
|
4478
|
+
const noteId = typeof target.noteId === "string" ? target.noteId.trim() : "";
|
|
4479
|
+
const fingerprint = typeof target.text === "string" ? target.text.trim() : "";
|
|
4480
|
+
if (!noteId && !fingerprint) {
|
|
4481
|
+
throw new Error("tombstoneOperatingNote requires a noteId or text target");
|
|
4482
|
+
}
|
|
4483
|
+
const notes = readOperatingNotes(meshId);
|
|
4484
|
+
const matched = notes.filter(
|
|
4485
|
+
(n) => noteId && n.id === noteId || fingerprint && operatingNoteText(n.payload) === fingerprint
|
|
4486
|
+
).length;
|
|
4487
|
+
const tombstone = appendLedgerEntry(meshId, {
|
|
4488
|
+
kind: OPERATING_NOTE_TOMBSTONE_KIND,
|
|
4489
|
+
payload: {
|
|
4490
|
+
...noteId ? { targetNoteId: noteId } : {},
|
|
4491
|
+
...fingerprint ? { targetFingerprint: fingerprint } : {},
|
|
4492
|
+
...target.reason && target.reason.trim() ? { reason: target.reason.trim() } : {},
|
|
4493
|
+
forgottenAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4494
|
+
}
|
|
4495
|
+
});
|
|
4496
|
+
return { tombstone, matched };
|
|
4497
|
+
}
|
|
4498
|
+
function readOperatingNotes(meshId, opts) {
|
|
4499
|
+
const raw = getCachedRawEntries(meshId);
|
|
4500
|
+
const tombstones = collectOperatingNoteTombstones(raw);
|
|
4501
|
+
let notes = raw.filter((e) => e.kind === OPERATING_NOTE_KIND && !isOperatingNoteTombstoned(e, tombstones));
|
|
4502
|
+
if (opts?.tail && opts.tail > 0 && notes.length > opts.tail) {
|
|
4503
|
+
notes = notes.slice(-opts.tail);
|
|
4504
|
+
}
|
|
4505
|
+
return notes;
|
|
4506
|
+
}
|
|
4507
|
+
function pruneOperatingNotes(meshId, keepLatest = OPERATING_NOTE_KEEP_LATEST) {
|
|
4508
|
+
const raw = getCachedRawEntries(meshId);
|
|
4509
|
+
const tombstones = collectOperatingNoteTombstones(raw);
|
|
4510
|
+
const removeIds = [];
|
|
4511
|
+
const liveNotes = [];
|
|
4512
|
+
for (const e of raw) {
|
|
4513
|
+
if (e.kind !== OPERATING_NOTE_KIND) continue;
|
|
4514
|
+
if (isOperatingNoteTombstoned(e, tombstones)) {
|
|
4515
|
+
removeIds.push(e.id);
|
|
4516
|
+
} else {
|
|
4517
|
+
liveNotes.push(e);
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
const bound = Math.max(0, Math.floor(keepLatest));
|
|
4521
|
+
if (liveNotes.length > bound) {
|
|
4522
|
+
for (const e of liveNotes.slice(0, liveNotes.length - bound)) removeIds.push(e.id);
|
|
4523
|
+
}
|
|
4524
|
+
if (removeIds.length === 0) return 0;
|
|
4525
|
+
try {
|
|
4526
|
+
MeshRuntimeStore.getInstance().deleteLedgerEntries(meshId, removeIds);
|
|
4527
|
+
} catch {
|
|
4528
|
+
}
|
|
4529
|
+
try {
|
|
4530
|
+
const remaining = readLedgerFile(meshId).filter((e) => !removeIds.includes(e.id));
|
|
4531
|
+
const filePath = getLedgerPath(meshId);
|
|
4532
|
+
const lines = remaining.length ? remaining.map((e) => JSON.stringify(e)).join("\n") + "\n" : "";
|
|
4533
|
+
writeFileSync3(filePath, lines, { encoding: "utf-8", mode: 384 });
|
|
4534
|
+
} catch {
|
|
4535
|
+
}
|
|
4536
|
+
invalidateLedgerCache(meshId);
|
|
4537
|
+
return removeIds.length;
|
|
4538
|
+
}
|
|
4429
4539
|
function clampLedgerSliceLimit(limit) {
|
|
4430
4540
|
if (typeof limit !== "number" || !Number.isFinite(limit)) return DEFAULT_LEDGER_SLICE_LIMIT;
|
|
4431
4541
|
return Math.max(1, Math.min(MAX_LEDGER_SLICE_LIMIT, Math.floor(limit)));
|
|
@@ -4765,7 +4875,7 @@ function rotateLedgerFile(meshId, currentPath) {
|
|
|
4765
4875
|
`);
|
|
4766
4876
|
}
|
|
4767
4877
|
}
|
|
4768
|
-
var 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;
|
|
4878
|
+
var 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;
|
|
4769
4879
|
var init_mesh_ledger = __esm({
|
|
4770
4880
|
"src/mesh/mesh-ledger.ts"() {
|
|
4771
4881
|
"use strict";
|
|
@@ -4784,6 +4894,10 @@ var init_mesh_ledger = __esm({
|
|
|
4784
4894
|
]);
|
|
4785
4895
|
DEFAULT_LEDGER_SLICE_LIMIT = 100;
|
|
4786
4896
|
MAX_LEDGER_SLICE_LIMIT = 500;
|
|
4897
|
+
OPERATING_NOTE_KIND = "coordinator_operating_note";
|
|
4898
|
+
OPERATING_NOTE_TOMBSTONE_KIND = "coordinator_operating_note_tombstone";
|
|
4899
|
+
OPERATING_NOTE_DEDUPE_WINDOW = 40;
|
|
4900
|
+
OPERATING_NOTE_KEEP_LATEST = 100;
|
|
4787
4901
|
meshLedgerEvents = new EventEmitter();
|
|
4788
4902
|
ledgerReadCache = /* @__PURE__ */ new Map();
|
|
4789
4903
|
LEDGER_CACHE_TTL_MS = 100;
|
|
@@ -41154,8 +41268,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41154
41268
|
* to the genuine-modal classification.
|
|
41155
41269
|
*/
|
|
41156
41270
|
isTransientToolConsent(now = Date.now()) {
|
|
41157
|
-
|
|
41158
|
-
return isAutonomousMeshSession && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
|
|
41271
|
+
return this.isAutonomousMeshSession() && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
|
|
41159
41272
|
}
|
|
41160
41273
|
/** True when this session is parked on a modal awaiting a human answer. */
|
|
41161
41274
|
isModalParked() {
|
|
@@ -41638,6 +41751,19 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41638
41751
|
isMeshWorkerSession() {
|
|
41639
41752
|
return !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.meshNodeId || this.settings.launchedByCoordinator);
|
|
41640
41753
|
}
|
|
41754
|
+
// FALSE-IDLE (self-coordinator settle): an autonomously-progressing mesh session
|
|
41755
|
+
// is either a delegated worker (isMeshWorkerSession) OR the coordinator's OWN
|
|
41756
|
+
// claude-cli session (meshCoordinatorFor). Both run auto-approved tool turns whose
|
|
41757
|
+
// inter-approval valley (busy→idle blip→generating re-entry ~0.5s later) must be
|
|
41758
|
+
// absorbed by the completedDebounce settle window, not flushed on the first idle
|
|
41759
|
+
// sample. The worker branch already gets NATIVE_HISTORY_MESH_IDLE_SETTLE_MS; the
|
|
41760
|
+
// self-coordinator session (worker markers absent, meshCoordinatorFor present) was
|
|
41761
|
+
// taking flushDelay=0 — no settle window — so its busyEpoch/lastOutputAt continuity
|
|
41762
|
+
// guard had no window to observe the valley and fired mid-turn "next-step" previews
|
|
41763
|
+
// as a finalSummary. Mirrors the isAutonomousMeshSession notion in isTransientToolConsent.
|
|
41764
|
+
isAutonomousMeshSession() {
|
|
41765
|
+
return this.isMeshWorkerSession() || !!this.settings.meshCoordinatorFor;
|
|
41766
|
+
}
|
|
41641
41767
|
/**
|
|
41642
41768
|
* ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
|
|
41643
41769
|
* Prefers the per-turn binding (engine.currentTurnTaskId, set when the turn was
|
|
@@ -42131,9 +42257,9 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42131
42257
|
...typeof adapterStatus?.lastOutputAt === "number" && Number.isFinite(adapterStatus.lastOutputAt) ? { lastOutputAtArm: adapterStatus.lastOutputAt } : {}
|
|
42132
42258
|
};
|
|
42133
42259
|
const ownsExternalHistory = !!this.adapter?.chatMessagesOwnedExternally;
|
|
42134
|
-
const
|
|
42135
|
-
const flushDelay = ownsExternalHistory ?
|
|
42136
|
-
LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory}
|
|
42260
|
+
const meshSettleSession = this.isAutonomousMeshSession();
|
|
42261
|
+
const flushDelay = ownsExternalHistory ? meshSettleSession ? NATIVE_HISTORY_MESH_IDLE_SETTLE_MS : 0 : 3e3;
|
|
42262
|
+
LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory} meshSettle=${meshSettleSession} flushDelay=${flushDelay}ms generatingStartedAt=${this.generatingStartedAt}`);
|
|
42137
42263
|
this.scheduleCompletedDebounceFlush(flushDelay);
|
|
42138
42264
|
}
|
|
42139
42265
|
} else if (newStatus === "idle" && this.lastStatus === "starting") {
|
|
@@ -46193,6 +46319,7 @@ function readSession2(sessionPath) {
|
|
|
46193
46319
|
}
|
|
46194
46320
|
|
|
46195
46321
|
// src/providers/native-history/antigravity-cli-transcript.ts
|
|
46322
|
+
init_load_better_sqlite3();
|
|
46196
46323
|
import * as fs22 from "fs";
|
|
46197
46324
|
import * as path31 from "path";
|
|
46198
46325
|
import * as os22 from "os";
|
|
@@ -46369,6 +46496,151 @@ function parsePbFile(filePath, sessionId) {
|
|
|
46369
46496
|
}
|
|
46370
46497
|
];
|
|
46371
46498
|
}
|
|
46499
|
+
var AGY_STEP_TYPE_USER = 14;
|
|
46500
|
+
var AGY_STEP_TYPE_MODEL = 15;
|
|
46501
|
+
function readVarint(buf, offset) {
|
|
46502
|
+
let result = 0;
|
|
46503
|
+
let shift = 0;
|
|
46504
|
+
let i = offset;
|
|
46505
|
+
while (i < buf.length) {
|
|
46506
|
+
const byte = buf[i];
|
|
46507
|
+
i += 1;
|
|
46508
|
+
result += (byte & 127) * Math.pow(2, shift);
|
|
46509
|
+
if ((byte & 128) === 0) return [result, i];
|
|
46510
|
+
shift += 7;
|
|
46511
|
+
if (shift > 63) break;
|
|
46512
|
+
}
|
|
46513
|
+
return [result, i];
|
|
46514
|
+
}
|
|
46515
|
+
function decodeProtoFields(buf) {
|
|
46516
|
+
const fields = [];
|
|
46517
|
+
let i = 0;
|
|
46518
|
+
while (i < buf.length) {
|
|
46519
|
+
const [key2, afterKey] = readVarint(buf, i);
|
|
46520
|
+
if (afterKey === i) break;
|
|
46521
|
+
i = afterKey;
|
|
46522
|
+
const field = Math.floor(key2 / 8);
|
|
46523
|
+
const wireType = key2 & 7;
|
|
46524
|
+
if (field <= 0) break;
|
|
46525
|
+
if (wireType === 0) {
|
|
46526
|
+
const [value, next] = readVarint(buf, i);
|
|
46527
|
+
if (next === i) break;
|
|
46528
|
+
i = next;
|
|
46529
|
+
fields.push({ field, wireType, varint: value });
|
|
46530
|
+
} else if (wireType === 2) {
|
|
46531
|
+
const [len, afterLen] = readVarint(buf, i);
|
|
46532
|
+
i = afterLen;
|
|
46533
|
+
if (len < 0 || i + len > buf.length) break;
|
|
46534
|
+
fields.push({ field, wireType, bytes: buf.subarray(i, i + len) });
|
|
46535
|
+
i += len;
|
|
46536
|
+
} else if (wireType === 5) {
|
|
46537
|
+
i += 4;
|
|
46538
|
+
} else if (wireType === 1) {
|
|
46539
|
+
i += 8;
|
|
46540
|
+
} else {
|
|
46541
|
+
break;
|
|
46542
|
+
}
|
|
46543
|
+
}
|
|
46544
|
+
return fields;
|
|
46545
|
+
}
|
|
46546
|
+
function firstLenField(buf, field) {
|
|
46547
|
+
for (const f of decodeProtoFields(buf)) {
|
|
46548
|
+
if (f.field === field && f.wireType === 2 && f.bytes) return f.bytes;
|
|
46549
|
+
}
|
|
46550
|
+
return null;
|
|
46551
|
+
}
|
|
46552
|
+
function looksLikeText(buf) {
|
|
46553
|
+
if (buf.length === 0) return false;
|
|
46554
|
+
let printable = 0;
|
|
46555
|
+
for (let i = 0; i < buf.length; i++) {
|
|
46556
|
+
const b = buf[i];
|
|
46557
|
+
if (b >= 32 && b <= 126 || b === 9 || b === 10 || b === 13 || b >= 128) printable += 1;
|
|
46558
|
+
}
|
|
46559
|
+
return printable / buf.length >= 0.9;
|
|
46560
|
+
}
|
|
46561
|
+
function stripAnswerMarker(text) {
|
|
46562
|
+
return text.replace(/^\s*MARKER_V1\s*/, "");
|
|
46563
|
+
}
|
|
46564
|
+
function extractModelAnswer(payload) {
|
|
46565
|
+
const inner = firstLenField(payload, 20);
|
|
46566
|
+
if (!inner) return "";
|
|
46567
|
+
const answer = firstLenField(inner, 1) ?? firstLenField(inner, 8);
|
|
46568
|
+
if (!answer || !looksLikeText(answer)) return "";
|
|
46569
|
+
return stripAnswerMarker(answer.toString("utf-8")).trim();
|
|
46570
|
+
}
|
|
46571
|
+
function extractUserPrompt(payload) {
|
|
46572
|
+
const inner = firstLenField(payload, 19);
|
|
46573
|
+
if (!inner) return "";
|
|
46574
|
+
const raw = firstLenField(inner, 2) ?? firstLenField(inner, 3);
|
|
46575
|
+
if (!raw || !looksLikeText(raw)) return "";
|
|
46576
|
+
const text = raw.toString("utf-8").trim();
|
|
46577
|
+
if (!text) return "";
|
|
46578
|
+
return extractUserRequestContent(text);
|
|
46579
|
+
}
|
|
46580
|
+
function parseConversationDb(filePath, sessionId, workspace) {
|
|
46581
|
+
let db;
|
|
46582
|
+
try {
|
|
46583
|
+
const Database = loadBetterSqlite3();
|
|
46584
|
+
db = new Database(filePath, { readonly: true, fileMustExist: true });
|
|
46585
|
+
} catch {
|
|
46586
|
+
return null;
|
|
46587
|
+
}
|
|
46588
|
+
let rows;
|
|
46589
|
+
try {
|
|
46590
|
+
rows = db.prepare(
|
|
46591
|
+
`SELECT idx, step_type, step_payload
|
|
46592
|
+
FROM steps
|
|
46593
|
+
WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
|
|
46594
|
+
ORDER BY idx ASC`
|
|
46595
|
+
).all();
|
|
46596
|
+
} catch {
|
|
46597
|
+
return null;
|
|
46598
|
+
} finally {
|
|
46599
|
+
try {
|
|
46600
|
+
db.close();
|
|
46601
|
+
} catch {
|
|
46602
|
+
}
|
|
46603
|
+
}
|
|
46604
|
+
if (!Array.isArray(rows) || rows.length === 0) return null;
|
|
46605
|
+
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
46606
|
+
const baseTs = statMtimeMs3(filePath) || Date.now();
|
|
46607
|
+
const messages = [];
|
|
46608
|
+
for (const row of rows) {
|
|
46609
|
+
const payload = row.step_payload;
|
|
46610
|
+
if (!payload || !Buffer.isBuffer(payload) || payload.length === 0) continue;
|
|
46611
|
+
const receivedAt = baseTs + messages.length;
|
|
46612
|
+
if (row.step_type === AGY_STEP_TYPE_USER) {
|
|
46613
|
+
const content = extractUserPrompt(payload);
|
|
46614
|
+
if (!content) continue;
|
|
46615
|
+
const msg = {
|
|
46616
|
+
ts: new Date(receivedAt).toISOString(),
|
|
46617
|
+
receivedAt,
|
|
46618
|
+
role: "user",
|
|
46619
|
+
content,
|
|
46620
|
+
kind: "standard",
|
|
46621
|
+
agent: "antigravity-cli",
|
|
46622
|
+
historySessionId: sessionId
|
|
46623
|
+
};
|
|
46624
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
46625
|
+
messages.push(msg);
|
|
46626
|
+
} else if (row.step_type === AGY_STEP_TYPE_MODEL) {
|
|
46627
|
+
const content = extractModelAnswer(payload);
|
|
46628
|
+
if (!content) continue;
|
|
46629
|
+
const msg = {
|
|
46630
|
+
ts: new Date(receivedAt).toISOString(),
|
|
46631
|
+
receivedAt,
|
|
46632
|
+
role: "assistant",
|
|
46633
|
+
content,
|
|
46634
|
+
kind: "standard",
|
|
46635
|
+
agent: "antigravity-cli",
|
|
46636
|
+
historySessionId: sessionId
|
|
46637
|
+
};
|
|
46638
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
46639
|
+
messages.push(msg);
|
|
46640
|
+
}
|
|
46641
|
+
}
|
|
46642
|
+
return messages.length > 0 ? messages : null;
|
|
46643
|
+
}
|
|
46372
46644
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
46373
46645
|
if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
|
|
46374
46646
|
if (!fs22.existsSync(sessionPath)) return null;
|
|
@@ -46391,6 +46663,21 @@ function readSession3(sessionPath, sessionId, workspace) {
|
|
|
46391
46663
|
workspace
|
|
46392
46664
|
};
|
|
46393
46665
|
}
|
|
46666
|
+
if (sessionPath.endsWith(".db")) {
|
|
46667
|
+
const dbSessionId = sessionId || path31.basename(sessionPath, ".db");
|
|
46668
|
+
if (!isUuidLike(dbSessionId)) return null;
|
|
46669
|
+
const messages = parseConversationDb(sessionPath, dbSessionId, workspace);
|
|
46670
|
+
if (!messages || messages.length === 0) return null;
|
|
46671
|
+
return {
|
|
46672
|
+
messages,
|
|
46673
|
+
providerSessionId: dbSessionId,
|
|
46674
|
+
source: "provider-native",
|
|
46675
|
+
sourcePath: sessionPath,
|
|
46676
|
+
sourceMtimeMs,
|
|
46677
|
+
nativeHistoryCoverage: "full",
|
|
46678
|
+
workspace
|
|
46679
|
+
};
|
|
46680
|
+
}
|
|
46394
46681
|
if (sessionPath.endsWith(".pb")) {
|
|
46395
46682
|
const pbSessionId = sessionId || path31.basename(sessionPath, ".pb");
|
|
46396
46683
|
if (!isUuidLike(pbSessionId)) return null;
|
|
@@ -46619,7 +46906,7 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
|
|
|
46619
46906
|
case "codex-cli":
|
|
46620
46907
|
return resolveCodexPath(workspace, sessionId, sessionStartedAtMs);
|
|
46621
46908
|
case "antigravity-cli":
|
|
46622
|
-
return resolveAntigravityPath(workspace);
|
|
46909
|
+
return resolveAntigravityPath(workspace, sessionId);
|
|
46623
46910
|
case "hermes-cli":
|
|
46624
46911
|
return resolveHermesPath(workspace, sessionId);
|
|
46625
46912
|
}
|
|
@@ -46734,16 +47021,25 @@ function resolveRealPath(value) {
|
|
|
46734
47021
|
return value;
|
|
46735
47022
|
}
|
|
46736
47023
|
}
|
|
46737
|
-
function resolveAntigravityPath(workspace) {
|
|
47024
|
+
function resolveAntigravityPath(workspace, sessionId) {
|
|
46738
47025
|
void workspace;
|
|
46739
|
-
const
|
|
46740
|
-
if (
|
|
46741
|
-
|
|
46742
|
-
|
|
46743
|
-
|
|
46744
|
-
|
|
46745
|
-
|
|
47026
|
+
const agyRoot = path33.join(os24.homedir(), ".gemini", "antigravity-cli");
|
|
47027
|
+
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
47028
|
+
const dbPath = path33.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
47029
|
+
if (fs24.existsSync(dbPath)) return dbPath;
|
|
47030
|
+
}
|
|
47031
|
+
const brainRoot2 = path33.join(agyRoot, "brain");
|
|
47032
|
+
if (fs24.existsSync(brainRoot2)) {
|
|
47033
|
+
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
47034
|
+
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);
|
|
47035
|
+
for (const e of entries) {
|
|
47036
|
+
const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
|
|
47037
|
+
if (fs24.existsSync(t)) return t;
|
|
47038
|
+
}
|
|
46746
47039
|
}
|
|
47040
|
+
const convRoot = path33.join(agyRoot, "conversations");
|
|
47041
|
+
const newestDb = newestRecentFile2(convRoot, /^[0-9a-f-]+\.db$/i);
|
|
47042
|
+
if (newestDb) return newestDb;
|
|
46747
47043
|
return null;
|
|
46748
47044
|
}
|
|
46749
47045
|
function resolveHermesPath(workspace, sessionId) {
|
|
@@ -51015,8 +51311,8 @@ var meshCoordinatorLaunchHandlers = {
|
|
|
51015
51311
|
};
|
|
51016
51312
|
const buildOperatingNotesBestEffort = async (id) => {
|
|
51017
51313
|
try {
|
|
51018
|
-
const {
|
|
51019
|
-
const noteEntries =
|
|
51314
|
+
const { readOperatingNotes: readOperatingNotes2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
51315
|
+
const noteEntries = readOperatingNotes2(id, { tail: 20 });
|
|
51020
51316
|
const notes = noteEntries.map((e) => {
|
|
51021
51317
|
const p = e.payload || {};
|
|
51022
51318
|
const text = typeof p.text === "string" ? p.text.trim() : "";
|
|
@@ -65717,6 +66013,10 @@ export {
|
|
|
65717
66013
|
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
65718
66014
|
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
65719
66015
|
NodePtyTransportFactory,
|
|
66016
|
+
OPERATING_NOTE_DEDUPE_WINDOW,
|
|
66017
|
+
OPERATING_NOTE_KEEP_LATEST,
|
|
66018
|
+
OPERATING_NOTE_KIND,
|
|
66019
|
+
OPERATING_NOTE_TOMBSTONE_KIND,
|
|
65720
66020
|
P2pRelayFailureError,
|
|
65721
66021
|
PRUNABLE_ORPHAN_STALE_REASONS,
|
|
65722
66022
|
ProviderCliAdapter,
|
|
@@ -65886,6 +66186,7 @@ export {
|
|
|
65886
66186
|
isManagedStatusWaiting,
|
|
65887
66187
|
isManagedStatusWorking,
|
|
65888
66188
|
isMeshHostOwner,
|
|
66189
|
+
isOperatingNoteTombstoned,
|
|
65889
66190
|
isP2pRelayTransportFailure,
|
|
65890
66191
|
isPathInside,
|
|
65891
66192
|
isSessionHostLiveRuntime,
|
|
@@ -65954,6 +66255,7 @@ export {
|
|
|
65954
66255
|
prepareSessionChatTailUpdate,
|
|
65955
66256
|
prepareSessionModalUpdate,
|
|
65956
66257
|
probeCdpPort,
|
|
66258
|
+
pruneOperatingNotes,
|
|
65957
66259
|
pruneStaleDirectDispatches,
|
|
65958
66260
|
queuePendingMeshCoordinatorEvent,
|
|
65959
66261
|
readSession3 as readAntigravityCliSession,
|
|
@@ -65966,6 +66268,7 @@ export {
|
|
|
65966
66268
|
readLedgerSlice,
|
|
65967
66269
|
readLedgerSliceFromStore,
|
|
65968
66270
|
readMeshCompletionSummary,
|
|
66271
|
+
readOperatingNotes,
|
|
65969
66272
|
reconcileDirectDispatchCompletionFromTranscript,
|
|
65970
66273
|
recordCompletionConflict,
|
|
65971
66274
|
recordDebugTrace,
|
|
@@ -66023,6 +66326,7 @@ export {
|
|
|
66023
66326
|
summarizeMeshMagiActivity,
|
|
66024
66327
|
summarizeMeshMission,
|
|
66025
66328
|
summarizeMissionTasks,
|
|
66329
|
+
tombstoneOperatingNote,
|
|
66026
66330
|
triggerMeshQueue,
|
|
66027
66331
|
unregisterMeshCoordinator,
|
|
66028
66332
|
updateConfig,
|