@adhdev/daemon-core 0.9.82-rc.444 → 0.9.82-rc.446

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.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 ? "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);
412
+ const commit = readInjected(true ? "c70a1cf556d27bbee6f81e64ea13699887f50ecc" : void 0) ?? "unknown";
413
+ const commitShort = readInjected(true ? "c70a1cf5" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
414
+ const version = readInjected(true ? "0.9.82-rc.446" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
415
+ const builtAt = readInjected(true ? "2026-07-01T15:09:11.778Z" : void 0);
416
416
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
417
417
  return cached;
418
418
  }
@@ -42614,19 +42614,41 @@ var CliProviderInstance = class _CliProviderInstance {
42614
42614
  if (shortFinalSummary) {
42615
42615
  this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now - shortDurationMs });
42616
42616
  }
42617
+ const shortEngineTurnStart = typeof this.adapter?.currentTurnStartedAt === "number" && Number.isFinite(this.adapter.currentTurnStartedAt) ? this.adapter.currentTurnStartedAt : 0;
42618
+ const shortTurnStartedAt = shortEngineTurnStart || this.generatingStartedAt || 0;
42619
+ const shortTaskId = this.completingTurnTaskId();
42617
42620
  this.generatingDebouncePending = null;
42618
42621
  this.generatingStartedAt = 0;
42619
- const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || shortEvidenceSource === "external-native") && !shortFinalSummary;
42622
+ const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || shortEvidenceSource === "external-native" || shortEvidenceSource === "unavailable") && !shortFinalSummary;
42620
42623
  if (missingEvidence) {
42621
42624
  LOG.warn("CLI", `[${this.type}] short completion missing final assistant evidence (source=${shortEvidenceSource})`);
42622
42625
  }
42623
- const hasMeshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
42624
- if (missingEvidence && !hasMeshContext) {
42625
- LOG.info("CLI", `[${this.type}] short completion suppressed: missing final assistant evidence, no mesh context (source=${shortEvidenceSource})`);
42626
- } else {
42626
+ if (this.isAutonomousMeshSession()) {
42627
+ this.completedDebouncePending = {
42628
+ chatTitle,
42629
+ duration: Math.round(shortDurationMs / 1e3),
42630
+ timestamp: now,
42631
+ firstObservedAt: now,
42632
+ // Short-gen enters from generating→idle (or waiting_approval→idle); the
42633
+ // completedDebounce finalization gate treats previousStatus for its
42634
+ // approval-resolution / inter-approval-valley handling. lastStatus is the
42635
+ // status we transitioned FROM here.
42636
+ previousStatus: this.lastStatus,
42637
+ ...shortTaskId ? { taskId: shortTaskId } : {},
42638
+ ...shortTurnStartedAt ? { turnStartedAt: shortTurnStartedAt } : {},
42639
+ // FALSE-IDLE continuity: same arm-time snapshots as the normal branch so the
42640
+ // flush guard can prove continuous idle across the settle window.
42641
+ busyEpochAtArm: this.busyEpoch,
42642
+ ...typeof adapterStatus?.lastOutputAt === "number" && Number.isFinite(adapterStatus.lastOutputAt) ? { lastOutputAtArm: adapterStatus.lastOutputAt } : {}
42643
+ };
42644
+ LOG.info("CLI", `[${this.type}] short-generating routed through settle window (${shortDurationMs}ms, source=${shortEvidenceSource}, missingEvidence=${missingEvidence}) \u2014 arming completedDebouncePending instead of inline fire`);
42627
42645
  if (this.isMeshWorkerSession()) {
42628
- traceMeshEventStage("fired", this.meshTraceCtx(), `short-generating idle (source=${shortEvidenceSource})`);
42646
+ traceMeshEventStage("arm", this.meshTraceCtx(), `short-generating settle-arm (source=${shortEvidenceSource}, missingEvidence=${missingEvidence})`);
42629
42647
  }
42648
+ this.scheduleCompletedDebounceFlush(NATIVE_HISTORY_MESH_IDLE_SETTLE_MS);
42649
+ } else if (missingEvidence) {
42650
+ LOG.info("CLI", `[${this.type}] short completion suppressed: missing final assistant evidence, non-mesh session (source=${shortEvidenceSource})`);
42651
+ } else {
42630
42652
  this.pushEvent({
42631
42653
  event: "agent:generating_completed",
42632
42654
  chatTitle,
@@ -42636,8 +42658,7 @@ var CliProviderInstance = class _CliProviderInstance {
42636
42658
  completionDiagnostic: {
42637
42659
  reason: "short_generating_suppressed",
42638
42660
  shortDurationMs,
42639
- finalAssistantEvidenceSource: shortEvidenceSource,
42640
- ...missingEvidence ? { blockReason: "missing_final_assistant" } : {}
42661
+ finalAssistantEvidenceSource: shortEvidenceSource
42641
42662
  }
42642
42663
  });
42643
42664
  }
@@ -46730,6 +46751,7 @@ var fs22 = __toESM(require("fs"));
46730
46751
  var path31 = __toESM(require("path"));
46731
46752
  var os22 = __toESM(require("os"));
46732
46753
  init_load_better_sqlite3();
46754
+ init_logger();
46733
46755
  function extractTimestampValue3(value) {
46734
46756
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
46735
46757
  if (typeof value === "string") {
@@ -46984,30 +47006,75 @@ function extractUserPrompt(payload) {
46984
47006
  if (!text) return "";
46985
47007
  return extractUserRequestContent(text);
46986
47008
  }
47009
+ function isSqliteBusyError(err) {
47010
+ if (!err) return false;
47011
+ const code = err.code;
47012
+ if (typeof code === "string" && code.includes("SQLITE_BUSY")) return true;
47013
+ const msg = err instanceof Error ? err.message : String(err);
47014
+ return /SQLITE_BUSY|database is locked|database table is locked/i.test(msg);
47015
+ }
47016
+ var AGY_DB_BUSY_TIMEOUT_MS = 3e3;
47017
+ var AGY_DB_MAX_ATTEMPTS = 4;
47018
+ var AGY_DB_RETRY_BACKOFF_MS = [50, 100, 150];
47019
+ function sleepBusy(ms) {
47020
+ const end = Date.now() + ms;
47021
+ while (Date.now() < end) {
47022
+ }
47023
+ }
46987
47024
  function parseConversationDb(filePath, sessionId, workspace) {
46988
- let db;
47025
+ let Database;
46989
47026
  try {
46990
- const Database = loadBetterSqlite3();
46991
- db = new Database(filePath, { readonly: true, fileMustExist: true });
46992
- } catch {
47027
+ Database = loadBetterSqlite3();
47028
+ } catch (err) {
47029
+ LOG.warn(
47030
+ "NativeHistory",
47031
+ `antigravity .db reader could not load better-sqlite3 for ${path31.basename(filePath)}: ${err instanceof Error ? err.message : String(err)} (native binding unavailable \u2014 assistant answers in this .db will not surface)`
47032
+ );
46993
47033
  return null;
46994
47034
  }
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 {
47035
+ let rows = null;
47036
+ let lastBusyErr;
47037
+ for (let attempt = 1; attempt <= AGY_DB_MAX_ATTEMPTS; attempt++) {
47038
+ let db;
47006
47039
  try {
47007
- db.close();
47008
- } catch {
47040
+ db = new Database(filePath, { readonly: true, fileMustExist: true });
47041
+ try {
47042
+ db.pragma(`busy_timeout = ${AGY_DB_BUSY_TIMEOUT_MS}`);
47043
+ } catch {
47044
+ }
47045
+ rows = db.prepare(
47046
+ `SELECT idx, step_type, step_payload
47047
+ FROM steps
47048
+ WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
47049
+ ORDER BY idx ASC`
47050
+ ).all();
47051
+ break;
47052
+ } catch (err) {
47053
+ if (isSqliteBusyError(err)) {
47054
+ lastBusyErr = err;
47055
+ if (attempt < AGY_DB_MAX_ATTEMPTS) {
47056
+ sleepBusy(AGY_DB_RETRY_BACKOFF_MS[attempt - 1] ?? 150);
47057
+ continue;
47058
+ }
47059
+ LOG.warn(
47060
+ "NativeHistory",
47061
+ `antigravity .db ${path31.basename(filePath)} stayed locked (SQLITE_BUSY) after ${AGY_DB_MAX_ATTEMPTS} attempts: ${err instanceof Error ? err.message : String(err)} (WAL write/checkpoint lock contention \u2014 assistant answers may transiently not surface this read)`
47062
+ );
47063
+ return null;
47064
+ }
47065
+ LOG.debug(
47066
+ "NativeHistory",
47067
+ `antigravity .db ${path31.basename(filePath)} not readable: ${err instanceof Error ? err.message : String(err)}`
47068
+ );
47069
+ return null;
47070
+ } finally {
47071
+ try {
47072
+ db?.close();
47073
+ } catch {
47074
+ }
47009
47075
  }
47010
47076
  }
47077
+ void lastBusyErr;
47011
47078
  if (!Array.isArray(rows) || rows.length === 0) return null;
47012
47079
  const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
47013
47080
  const baseTs = statMtimeMs3(filePath) || Date.now();
@@ -47441,7 +47508,7 @@ function resolveAntigravityPath(workspace, sessionId) {
47441
47508
  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
47509
  for (const e of entries) {
47443
47510
  const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
47444
- if (fs24.existsSync(t)) return t;
47511
+ if (fs24.existsSync(t) && safeSize(t) > 0) return t;
47445
47512
  }
47446
47513
  }
47447
47514
  const convRoot = path33.join(agyRoot, "conversations");
@@ -47505,6 +47572,13 @@ function safeMtime(p) {
47505
47572
  return 0;
47506
47573
  }
47507
47574
  }
47575
+ function safeSize(p) {
47576
+ try {
47577
+ return fs24.statSync(p).size;
47578
+ } catch {
47579
+ return 0;
47580
+ }
47581
+ }
47508
47582
  function normalizeRole2(r) {
47509
47583
  const s2 = String(r ?? "").toLowerCase();
47510
47584
  if (s2 === "user" || s2 === "human") return "user";