@adhdev/daemon-core 0.9.82-rc.443 → 0.9.82-rc.445
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 +350 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +342 -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 +367 -25
- package/src/providers/native-history/dispatcher.ts +42 -14
package/dist/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export { MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS, MESH_WORKTREE_BOOTSTRAP_CONFI
|
|
|
49
49
|
export type { MeshRefineValidationCategory, MeshRefineValidationCommandPlan, MeshRefineValidationPlan, RepoMeshRefineConfig, RepoMeshRefineValidationCommandConfig, } from './mesh/refine-config.js';
|
|
50
50
|
export { loadRepoSettings } from './config/repo-settings.js';
|
|
51
51
|
export type { RepoSettings, LoadRepoSettingsOptions } from './config/repo-settings.js';
|
|
52
|
-
export { appendLedgerEntry, appendRemoteLedgerEntries, buildTaskCompletionEvidence, normalizeMeshWorkerResult, readLedgerEntries, readLedgerSlice, readLedgerSliceFromStore, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
|
|
52
|
+
export { appendLedgerEntry, appendRemoteLedgerEntries, buildTaskCompletionEvidence, normalizeMeshWorkerResult, readLedgerEntries, readLedgerSlice, readLedgerSliceFromStore, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT, tombstoneOperatingNote, readOperatingNotes, pruneOperatingNotes, isOperatingNoteTombstoned, OPERATING_NOTE_KIND, OPERATING_NOTE_TOMBSTONE_KIND, OPERATING_NOTE_DEDUPE_WINDOW, OPERATING_NOTE_KEEP_LATEST } from './mesh/mesh-ledger.js';
|
|
53
53
|
export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext, MeshTaskCompletionEvidence, MeshWorkerResultArtifact, MeshProcessArtifact, MeshValidationResultArtifact } from './mesh/mesh-ledger.js';
|
|
54
54
|
export { fastForwardMeshNode } from './mesh/mesh-fast-forward.js';
|
|
55
55
|
export type { MeshFastForwardNodeArgs, MeshFastForwardPlannedStep, MeshFastForwardResult } from './mesh/mesh-fast-forward.js';
|
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 ? "92b0714a88a4e1e253a40fa5a8c49602d087a5b3" : void 0) ?? "unknown";
|
|
413
|
+
const commitShort = readInjected(true ? "92b0714a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
414
|
+
const version = readInjected(true ? "0.9.82-rc.445" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
415
|
+
const builtAt = readInjected(true ? "2026-07-01T12:57:54.212Z" : 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;
|
|
@@ -23812,6 +23926,10 @@ __export(index_exports, {
|
|
|
23812
23926
|
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS: () => MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
23813
23927
|
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS: () => MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
23814
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,
|
|
23815
23933
|
P2pRelayFailureError: () => P2pRelayFailureError,
|
|
23816
23934
|
PRUNABLE_ORPHAN_STALE_REASONS: () => PRUNABLE_ORPHAN_STALE_REASONS,
|
|
23817
23935
|
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
@@ -23981,6 +24099,7 @@ __export(index_exports, {
|
|
|
23981
24099
|
isManagedStatusWaiting: () => isManagedStatusWaiting,
|
|
23982
24100
|
isManagedStatusWorking: () => isManagedStatusWorking,
|
|
23983
24101
|
isMeshHostOwner: () => isMeshHostOwner,
|
|
24102
|
+
isOperatingNoteTombstoned: () => isOperatingNoteTombstoned,
|
|
23984
24103
|
isP2pRelayTransportFailure: () => isP2pRelayTransportFailure,
|
|
23985
24104
|
isPathInside: () => isPathInside,
|
|
23986
24105
|
isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
|
|
@@ -24049,6 +24168,7 @@ __export(index_exports, {
|
|
|
24049
24168
|
prepareSessionChatTailUpdate: () => prepareSessionChatTailUpdate,
|
|
24050
24169
|
prepareSessionModalUpdate: () => prepareSessionModalUpdate,
|
|
24051
24170
|
probeCdpPort: () => probeCdpPort,
|
|
24171
|
+
pruneOperatingNotes: () => pruneOperatingNotes,
|
|
24052
24172
|
pruneStaleDirectDispatches: () => pruneStaleDirectDispatches,
|
|
24053
24173
|
queuePendingMeshCoordinatorEvent: () => queuePendingMeshCoordinatorEvent,
|
|
24054
24174
|
readAntigravityCliSession: () => readSession3,
|
|
@@ -24061,6 +24181,7 @@ __export(index_exports, {
|
|
|
24061
24181
|
readLedgerSlice: () => readLedgerSlice,
|
|
24062
24182
|
readLedgerSliceFromStore: () => readLedgerSliceFromStore,
|
|
24063
24183
|
readMeshCompletionSummary: () => readMeshCompletionSummary,
|
|
24184
|
+
readOperatingNotes: () => readOperatingNotes,
|
|
24064
24185
|
reconcileDirectDispatchCompletionFromTranscript: () => reconcileDirectDispatchCompletionFromTranscript,
|
|
24065
24186
|
recordCompletionConflict: () => recordCompletionConflict,
|
|
24066
24187
|
recordDebugTrace: () => recordDebugTrace,
|
|
@@ -24118,6 +24239,7 @@ __export(index_exports, {
|
|
|
24118
24239
|
summarizeMeshMagiActivity: () => summarizeMeshMagiActivity,
|
|
24119
24240
|
summarizeMeshMission: () => summarizeMeshMission,
|
|
24120
24241
|
summarizeMissionTasks: () => summarizeMissionTasks,
|
|
24242
|
+
tombstoneOperatingNote: () => tombstoneOperatingNote,
|
|
24121
24243
|
triggerMeshQueue: () => triggerMeshQueue,
|
|
24122
24244
|
unregisterMeshCoordinator: () => unregisterMeshCoordinator,
|
|
24123
24245
|
updateConfig: () => updateConfig,
|
|
@@ -41558,8 +41680,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
41558
41680
|
* to the genuine-modal classification.
|
|
41559
41681
|
*/
|
|
41560
41682
|
isTransientToolConsent(now = Date.now()) {
|
|
41561
|
-
|
|
41562
|
-
return isAutonomousMeshSession && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
|
|
41683
|
+
return this.isAutonomousMeshSession() && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
|
|
41563
41684
|
}
|
|
41564
41685
|
/** True when this session is parked on a modal awaiting a human answer. */
|
|
41565
41686
|
isModalParked() {
|
|
@@ -42042,6 +42163,19 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42042
42163
|
isMeshWorkerSession() {
|
|
42043
42164
|
return !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.meshNodeId || this.settings.launchedByCoordinator);
|
|
42044
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
|
+
}
|
|
42045
42179
|
/**
|
|
42046
42180
|
* ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
|
|
42047
42181
|
* Prefers the per-turn binding (engine.currentTurnTaskId, set when the turn was
|
|
@@ -42535,9 +42669,9 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
42535
42669
|
...typeof adapterStatus?.lastOutputAt === "number" && Number.isFinite(adapterStatus.lastOutputAt) ? { lastOutputAtArm: adapterStatus.lastOutputAt } : {}
|
|
42536
42670
|
};
|
|
42537
42671
|
const ownsExternalHistory = !!this.adapter?.chatMessagesOwnedExternally;
|
|
42538
|
-
const
|
|
42539
|
-
const flushDelay = ownsExternalHistory ?
|
|
42540
|
-
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}`);
|
|
42541
42675
|
this.scheduleCompletedDebounceFlush(flushDelay);
|
|
42542
42676
|
}
|
|
42543
42677
|
} else if (newStatus === "idle" && this.lastStatus === "starting") {
|
|
@@ -46595,6 +46729,8 @@ function readSession2(sessionPath) {
|
|
|
46595
46729
|
var fs22 = __toESM(require("fs"));
|
|
46596
46730
|
var path31 = __toESM(require("path"));
|
|
46597
46731
|
var os22 = __toESM(require("os"));
|
|
46732
|
+
init_load_better_sqlite3();
|
|
46733
|
+
init_logger();
|
|
46598
46734
|
function extractTimestampValue3(value) {
|
|
46599
46735
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
46600
46736
|
if (typeof value === "string") {
|
|
@@ -46768,6 +46904,159 @@ function parsePbFile(filePath, sessionId) {
|
|
|
46768
46904
|
}
|
|
46769
46905
|
];
|
|
46770
46906
|
}
|
|
46907
|
+
var AGY_STEP_TYPE_USER = 14;
|
|
46908
|
+
var AGY_STEP_TYPE_MODEL = 15;
|
|
46909
|
+
function readVarint(buf, offset) {
|
|
46910
|
+
let result = 0;
|
|
46911
|
+
let shift = 0;
|
|
46912
|
+
let i = offset;
|
|
46913
|
+
while (i < buf.length) {
|
|
46914
|
+
const byte = buf[i];
|
|
46915
|
+
i += 1;
|
|
46916
|
+
result += (byte & 127) * Math.pow(2, shift);
|
|
46917
|
+
if ((byte & 128) === 0) return [result, i];
|
|
46918
|
+
shift += 7;
|
|
46919
|
+
if (shift > 63) break;
|
|
46920
|
+
}
|
|
46921
|
+
return [result, i];
|
|
46922
|
+
}
|
|
46923
|
+
function decodeProtoFields(buf) {
|
|
46924
|
+
const fields = [];
|
|
46925
|
+
let i = 0;
|
|
46926
|
+
while (i < buf.length) {
|
|
46927
|
+
const [key2, afterKey] = readVarint(buf, i);
|
|
46928
|
+
if (afterKey === i) break;
|
|
46929
|
+
i = afterKey;
|
|
46930
|
+
const field = Math.floor(key2 / 8);
|
|
46931
|
+
const wireType = key2 & 7;
|
|
46932
|
+
if (field <= 0) break;
|
|
46933
|
+
if (wireType === 0) {
|
|
46934
|
+
const [value, next] = readVarint(buf, i);
|
|
46935
|
+
if (next === i) break;
|
|
46936
|
+
i = next;
|
|
46937
|
+
fields.push({ field, wireType, varint: value });
|
|
46938
|
+
} else if (wireType === 2) {
|
|
46939
|
+
const [len, afterLen] = readVarint(buf, i);
|
|
46940
|
+
i = afterLen;
|
|
46941
|
+
if (len < 0 || i + len > buf.length) break;
|
|
46942
|
+
fields.push({ field, wireType, bytes: buf.subarray(i, i + len) });
|
|
46943
|
+
i += len;
|
|
46944
|
+
} else if (wireType === 5) {
|
|
46945
|
+
i += 4;
|
|
46946
|
+
} else if (wireType === 1) {
|
|
46947
|
+
i += 8;
|
|
46948
|
+
} else {
|
|
46949
|
+
break;
|
|
46950
|
+
}
|
|
46951
|
+
}
|
|
46952
|
+
return fields;
|
|
46953
|
+
}
|
|
46954
|
+
function firstLenField(buf, field) {
|
|
46955
|
+
for (const f of decodeProtoFields(buf)) {
|
|
46956
|
+
if (f.field === field && f.wireType === 2 && f.bytes) return f.bytes;
|
|
46957
|
+
}
|
|
46958
|
+
return null;
|
|
46959
|
+
}
|
|
46960
|
+
function looksLikeText(buf) {
|
|
46961
|
+
if (buf.length === 0) return false;
|
|
46962
|
+
let printable = 0;
|
|
46963
|
+
for (let i = 0; i < buf.length; i++) {
|
|
46964
|
+
const b = buf[i];
|
|
46965
|
+
if (b >= 32 && b <= 126 || b === 9 || b === 10 || b === 13 || b >= 128) printable += 1;
|
|
46966
|
+
}
|
|
46967
|
+
return printable / buf.length >= 0.9;
|
|
46968
|
+
}
|
|
46969
|
+
function stripAnswerMarker(text) {
|
|
46970
|
+
return text.replace(/^\s*MARKER_V1\s*/, "");
|
|
46971
|
+
}
|
|
46972
|
+
function extractModelAnswer(payload) {
|
|
46973
|
+
const inner = firstLenField(payload, 20);
|
|
46974
|
+
if (!inner) return "";
|
|
46975
|
+
const answer = firstLenField(inner, 1) ?? firstLenField(inner, 8);
|
|
46976
|
+
if (!answer || !looksLikeText(answer)) return "";
|
|
46977
|
+
return stripAnswerMarker(answer.toString("utf-8")).trim();
|
|
46978
|
+
}
|
|
46979
|
+
function extractUserPrompt(payload) {
|
|
46980
|
+
const inner = firstLenField(payload, 19);
|
|
46981
|
+
if (!inner) return "";
|
|
46982
|
+
const raw = firstLenField(inner, 2) ?? firstLenField(inner, 3);
|
|
46983
|
+
if (!raw || !looksLikeText(raw)) return "";
|
|
46984
|
+
const text = raw.toString("utf-8").trim();
|
|
46985
|
+
if (!text) return "";
|
|
46986
|
+
return extractUserRequestContent(text);
|
|
46987
|
+
}
|
|
46988
|
+
function parseConversationDb(filePath, sessionId, workspace) {
|
|
46989
|
+
let db;
|
|
46990
|
+
try {
|
|
46991
|
+
const Database = loadBetterSqlite3();
|
|
46992
|
+
db = new Database(filePath, { readonly: true, fileMustExist: true });
|
|
46993
|
+
} catch (err) {
|
|
46994
|
+
LOG.warn(
|
|
46995
|
+
"NativeHistory",
|
|
46996
|
+
`antigravity .db reader could not open ${path31.basename(filePath)}: ${err instanceof Error ? err.message : String(err)} (better-sqlite3 load/open failed \u2014 assistant answers in this .db will not surface)`
|
|
46997
|
+
);
|
|
46998
|
+
return null;
|
|
46999
|
+
}
|
|
47000
|
+
let rows;
|
|
47001
|
+
try {
|
|
47002
|
+
rows = db.prepare(
|
|
47003
|
+
`SELECT idx, step_type, step_payload
|
|
47004
|
+
FROM steps
|
|
47005
|
+
WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
|
|
47006
|
+
ORDER BY idx ASC`
|
|
47007
|
+
).all();
|
|
47008
|
+
} catch (err) {
|
|
47009
|
+
LOG.debug(
|
|
47010
|
+
"NativeHistory",
|
|
47011
|
+
`antigravity .db ${path31.basename(filePath)} has no readable steps table: ${err instanceof Error ? err.message : String(err)}`
|
|
47012
|
+
);
|
|
47013
|
+
return null;
|
|
47014
|
+
} finally {
|
|
47015
|
+
try {
|
|
47016
|
+
db.close();
|
|
47017
|
+
} catch {
|
|
47018
|
+
}
|
|
47019
|
+
}
|
|
47020
|
+
if (!Array.isArray(rows) || rows.length === 0) return null;
|
|
47021
|
+
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
47022
|
+
const baseTs = statMtimeMs3(filePath) || Date.now();
|
|
47023
|
+
const messages = [];
|
|
47024
|
+
for (const row of rows) {
|
|
47025
|
+
const payload = row.step_payload;
|
|
47026
|
+
if (!payload || !Buffer.isBuffer(payload) || payload.length === 0) continue;
|
|
47027
|
+
const receivedAt = baseTs + messages.length;
|
|
47028
|
+
if (row.step_type === AGY_STEP_TYPE_USER) {
|
|
47029
|
+
const content = extractUserPrompt(payload);
|
|
47030
|
+
if (!content) continue;
|
|
47031
|
+
const msg = {
|
|
47032
|
+
ts: new Date(receivedAt).toISOString(),
|
|
47033
|
+
receivedAt,
|
|
47034
|
+
role: "user",
|
|
47035
|
+
content,
|
|
47036
|
+
kind: "standard",
|
|
47037
|
+
agent: "antigravity-cli",
|
|
47038
|
+
historySessionId: sessionId
|
|
47039
|
+
};
|
|
47040
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
47041
|
+
messages.push(msg);
|
|
47042
|
+
} else if (row.step_type === AGY_STEP_TYPE_MODEL) {
|
|
47043
|
+
const content = extractModelAnswer(payload);
|
|
47044
|
+
if (!content) continue;
|
|
47045
|
+
const msg = {
|
|
47046
|
+
ts: new Date(receivedAt).toISOString(),
|
|
47047
|
+
receivedAt,
|
|
47048
|
+
role: "assistant",
|
|
47049
|
+
content,
|
|
47050
|
+
kind: "standard",
|
|
47051
|
+
agent: "antigravity-cli",
|
|
47052
|
+
historySessionId: sessionId
|
|
47053
|
+
};
|
|
47054
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
47055
|
+
messages.push(msg);
|
|
47056
|
+
}
|
|
47057
|
+
}
|
|
47058
|
+
return messages.length > 0 ? messages : null;
|
|
47059
|
+
}
|
|
46771
47060
|
function readSession3(sessionPath, sessionId, workspace) {
|
|
46772
47061
|
if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
|
|
46773
47062
|
if (!fs22.existsSync(sessionPath)) return null;
|
|
@@ -46790,6 +47079,21 @@ function readSession3(sessionPath, sessionId, workspace) {
|
|
|
46790
47079
|
workspace
|
|
46791
47080
|
};
|
|
46792
47081
|
}
|
|
47082
|
+
if (sessionPath.endsWith(".db")) {
|
|
47083
|
+
const dbSessionId = sessionId || path31.basename(sessionPath, ".db");
|
|
47084
|
+
if (!isUuidLike(dbSessionId)) return null;
|
|
47085
|
+
const messages = parseConversationDb(sessionPath, dbSessionId, workspace);
|
|
47086
|
+
if (!messages || messages.length === 0) return null;
|
|
47087
|
+
return {
|
|
47088
|
+
messages,
|
|
47089
|
+
providerSessionId: dbSessionId,
|
|
47090
|
+
source: "provider-native",
|
|
47091
|
+
sourcePath: sessionPath,
|
|
47092
|
+
sourceMtimeMs,
|
|
47093
|
+
nativeHistoryCoverage: "full",
|
|
47094
|
+
workspace
|
|
47095
|
+
};
|
|
47096
|
+
}
|
|
46793
47097
|
if (sessionPath.endsWith(".pb")) {
|
|
46794
47098
|
const pbSessionId = sessionId || path31.basename(sessionPath, ".pb");
|
|
46795
47099
|
if (!isUuidLike(pbSessionId)) return null;
|
|
@@ -47018,7 +47322,7 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
|
|
|
47018
47322
|
case "codex-cli":
|
|
47019
47323
|
return resolveCodexPath(workspace, sessionId, sessionStartedAtMs);
|
|
47020
47324
|
case "antigravity-cli":
|
|
47021
|
-
return resolveAntigravityPath(workspace);
|
|
47325
|
+
return resolveAntigravityPath(workspace, sessionId);
|
|
47022
47326
|
case "hermes-cli":
|
|
47023
47327
|
return resolveHermesPath(workspace, sessionId);
|
|
47024
47328
|
}
|
|
@@ -47133,16 +47437,25 @@ function resolveRealPath(value) {
|
|
|
47133
47437
|
return value;
|
|
47134
47438
|
}
|
|
47135
47439
|
}
|
|
47136
|
-
function resolveAntigravityPath(workspace) {
|
|
47440
|
+
function resolveAntigravityPath(workspace, sessionId) {
|
|
47137
47441
|
void workspace;
|
|
47138
|
-
const
|
|
47139
|
-
if (
|
|
47140
|
-
|
|
47141
|
-
|
|
47142
|
-
|
|
47143
|
-
|
|
47144
|
-
|
|
47442
|
+
const agyRoot = path33.join(os24.homedir(), ".gemini", "antigravity-cli");
|
|
47443
|
+
if (sessionId && isUuidLikeSessionId2(sessionId)) {
|
|
47444
|
+
const dbPath = path33.join(agyRoot, "conversations", `${sessionId}.db`);
|
|
47445
|
+
if (fs24.existsSync(dbPath)) return dbPath;
|
|
47446
|
+
}
|
|
47447
|
+
const brainRoot2 = path33.join(agyRoot, "brain");
|
|
47448
|
+
if (fs24.existsSync(brainRoot2)) {
|
|
47449
|
+
const cutoff = Date.now() - RECENT_WINDOW_MS;
|
|
47450
|
+
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);
|
|
47451
|
+
for (const e of entries) {
|
|
47452
|
+
const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
|
|
47453
|
+
if (fs24.existsSync(t) && safeSize(t) > 0) return t;
|
|
47454
|
+
}
|
|
47145
47455
|
}
|
|
47456
|
+
const convRoot = path33.join(agyRoot, "conversations");
|
|
47457
|
+
const newestDb = newestRecentFile2(convRoot, /^[0-9a-f-]+\.db$/i);
|
|
47458
|
+
if (newestDb) return newestDb;
|
|
47146
47459
|
return null;
|
|
47147
47460
|
}
|
|
47148
47461
|
function resolveHermesPath(workspace, sessionId) {
|
|
@@ -47201,6 +47514,13 @@ function safeMtime(p) {
|
|
|
47201
47514
|
return 0;
|
|
47202
47515
|
}
|
|
47203
47516
|
}
|
|
47517
|
+
function safeSize(p) {
|
|
47518
|
+
try {
|
|
47519
|
+
return fs24.statSync(p).size;
|
|
47520
|
+
} catch {
|
|
47521
|
+
return 0;
|
|
47522
|
+
}
|
|
47523
|
+
}
|
|
47204
47524
|
function normalizeRole2(r) {
|
|
47205
47525
|
const s2 = String(r ?? "").toLowerCase();
|
|
47206
47526
|
if (s2 === "user" || s2 === "human") return "user";
|
|
@@ -51414,8 +51734,8 @@ var meshCoordinatorLaunchHandlers = {
|
|
|
51414
51734
|
};
|
|
51415
51735
|
const buildOperatingNotesBestEffort = async (id) => {
|
|
51416
51736
|
try {
|
|
51417
|
-
const {
|
|
51418
|
-
const noteEntries =
|
|
51737
|
+
const { readOperatingNotes: readOperatingNotes2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
51738
|
+
const noteEntries = readOperatingNotes2(id, { tail: 20 });
|
|
51419
51739
|
const notes = noteEntries.map((e) => {
|
|
51420
51740
|
const p = e.payload || {};
|
|
51421
51741
|
const text = typeof p.text === "string" ? p.text.trim() : "";
|
|
@@ -66110,6 +66430,10 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66110
66430
|
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
66111
66431
|
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
66112
66432
|
NodePtyTransportFactory,
|
|
66433
|
+
OPERATING_NOTE_DEDUPE_WINDOW,
|
|
66434
|
+
OPERATING_NOTE_KEEP_LATEST,
|
|
66435
|
+
OPERATING_NOTE_KIND,
|
|
66436
|
+
OPERATING_NOTE_TOMBSTONE_KIND,
|
|
66113
66437
|
P2pRelayFailureError,
|
|
66114
66438
|
PRUNABLE_ORPHAN_STALE_REASONS,
|
|
66115
66439
|
ProviderCliAdapter,
|
|
@@ -66279,6 +66603,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66279
66603
|
isManagedStatusWaiting,
|
|
66280
66604
|
isManagedStatusWorking,
|
|
66281
66605
|
isMeshHostOwner,
|
|
66606
|
+
isOperatingNoteTombstoned,
|
|
66282
66607
|
isP2pRelayTransportFailure,
|
|
66283
66608
|
isPathInside,
|
|
66284
66609
|
isSessionHostLiveRuntime,
|
|
@@ -66347,6 +66672,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66347
66672
|
prepareSessionChatTailUpdate,
|
|
66348
66673
|
prepareSessionModalUpdate,
|
|
66349
66674
|
probeCdpPort,
|
|
66675
|
+
pruneOperatingNotes,
|
|
66350
66676
|
pruneStaleDirectDispatches,
|
|
66351
66677
|
queuePendingMeshCoordinatorEvent,
|
|
66352
66678
|
readAntigravityCliSession,
|
|
@@ -66359,6 +66685,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66359
66685
|
readLedgerSlice,
|
|
66360
66686
|
readLedgerSliceFromStore,
|
|
66361
66687
|
readMeshCompletionSummary,
|
|
66688
|
+
readOperatingNotes,
|
|
66362
66689
|
reconcileDirectDispatchCompletionFromTranscript,
|
|
66363
66690
|
recordCompletionConflict,
|
|
66364
66691
|
recordDebugTrace,
|
|
@@ -66416,6 +66743,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
66416
66743
|
summarizeMeshMagiActivity,
|
|
66417
66744
|
summarizeMeshMission,
|
|
66418
66745
|
summarizeMissionTasks,
|
|
66746
|
+
tombstoneOperatingNote,
|
|
66419
66747
|
triggerMeshQueue,
|
|
66420
66748
|
unregisterMeshCoordinator,
|
|
66421
66749
|
updateConfig,
|