@adhdev/daemon-core 0.9.82-rc.445 → 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 ? "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);
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
  }
@@ -46985,38 +47006,75 @@ function extractUserPrompt(payload) {
46985
47006
  if (!text) return "";
46986
47007
  return extractUserRequestContent(text);
46987
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
+ }
46988
47024
  function parseConversationDb(filePath, sessionId, workspace) {
46989
- let db;
47025
+ let Database;
46990
47026
  try {
46991
- const Database = loadBetterSqlite3();
46992
- db = new Database(filePath, { readonly: true, fileMustExist: true });
47027
+ Database = loadBetterSqlite3();
46993
47028
  } catch (err) {
46994
47029
  LOG.warn(
46995
47030
  "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)`
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)`
46997
47032
  );
46998
47033
  return null;
46999
47034
  }
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 {
47035
+ let rows = null;
47036
+ let lastBusyErr;
47037
+ for (let attempt = 1; attempt <= AGY_DB_MAX_ATTEMPTS; attempt++) {
47038
+ let db;
47015
47039
  try {
47016
- db.close();
47017
- } 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
+ }
47018
47075
  }
47019
47076
  }
47077
+ void lastBusyErr;
47020
47078
  if (!Array.isArray(rows) || rows.length === 0) return null;
47021
47079
  const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
47022
47080
  const baseTs = statMtimeMs3(filePath) || Date.now();