@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.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 ? "92b0714a88a4e1e253a40fa5a8c49602d087a5b3" : void 0) ?? "unknown";
408
- const commitShort = readInjected(true ? "92b0714a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
- const version = readInjected(true ? "0.9.82-rc.445" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
- const builtAt = readInjected(true ? "2026-07-01T12:57:54.212Z" : void 0);
407
+ const commit = readInjected(true ? "c70a1cf556d27bbee6f81e64ea13699887f50ecc" : void 0) ?? "unknown";
408
+ const commitShort = readInjected(true ? "c70a1cf5" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
+ const version = readInjected(true ? "0.9.82-rc.446" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
+ const builtAt = readInjected(true ? "2026-07-01T15:09:11.778Z" : void 0);
411
411
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
412
412
  return cached;
413
413
  }
@@ -42202,19 +42202,41 @@ var CliProviderInstance = class _CliProviderInstance {
42202
42202
  if (shortFinalSummary) {
42203
42203
  this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now - shortDurationMs });
42204
42204
  }
42205
+ const shortEngineTurnStart = typeof this.adapter?.currentTurnStartedAt === "number" && Number.isFinite(this.adapter.currentTurnStartedAt) ? this.adapter.currentTurnStartedAt : 0;
42206
+ const shortTurnStartedAt = shortEngineTurnStart || this.generatingStartedAt || 0;
42207
+ const shortTaskId = this.completingTurnTaskId();
42205
42208
  this.generatingDebouncePending = null;
42206
42209
  this.generatingStartedAt = 0;
42207
- const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || shortEvidenceSource === "external-native") && !shortFinalSummary;
42210
+ const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || shortEvidenceSource === "external-native" || shortEvidenceSource === "unavailable") && !shortFinalSummary;
42208
42211
  if (missingEvidence) {
42209
42212
  LOG.warn("CLI", `[${this.type}] short completion missing final assistant evidence (source=${shortEvidenceSource})`);
42210
42213
  }
42211
- const hasMeshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
42212
- if (missingEvidence && !hasMeshContext) {
42213
- LOG.info("CLI", `[${this.type}] short completion suppressed: missing final assistant evidence, no mesh context (source=${shortEvidenceSource})`);
42214
- } else {
42214
+ if (this.isAutonomousMeshSession()) {
42215
+ this.completedDebouncePending = {
42216
+ chatTitle,
42217
+ duration: Math.round(shortDurationMs / 1e3),
42218
+ timestamp: now,
42219
+ firstObservedAt: now,
42220
+ // Short-gen enters from generating→idle (or waiting_approval→idle); the
42221
+ // completedDebounce finalization gate treats previousStatus for its
42222
+ // approval-resolution / inter-approval-valley handling. lastStatus is the
42223
+ // status we transitioned FROM here.
42224
+ previousStatus: this.lastStatus,
42225
+ ...shortTaskId ? { taskId: shortTaskId } : {},
42226
+ ...shortTurnStartedAt ? { turnStartedAt: shortTurnStartedAt } : {},
42227
+ // FALSE-IDLE continuity: same arm-time snapshots as the normal branch so the
42228
+ // flush guard can prove continuous idle across the settle window.
42229
+ busyEpochAtArm: this.busyEpoch,
42230
+ ...typeof adapterStatus?.lastOutputAt === "number" && Number.isFinite(adapterStatus.lastOutputAt) ? { lastOutputAtArm: adapterStatus.lastOutputAt } : {}
42231
+ };
42232
+ LOG.info("CLI", `[${this.type}] short-generating routed through settle window (${shortDurationMs}ms, source=${shortEvidenceSource}, missingEvidence=${missingEvidence}) \u2014 arming completedDebouncePending instead of inline fire`);
42215
42233
  if (this.isMeshWorkerSession()) {
42216
- traceMeshEventStage("fired", this.meshTraceCtx(), `short-generating idle (source=${shortEvidenceSource})`);
42234
+ traceMeshEventStage("arm", this.meshTraceCtx(), `short-generating settle-arm (source=${shortEvidenceSource}, missingEvidence=${missingEvidence})`);
42217
42235
  }
42236
+ this.scheduleCompletedDebounceFlush(NATIVE_HISTORY_MESH_IDLE_SETTLE_MS);
42237
+ } else if (missingEvidence) {
42238
+ LOG.info("CLI", `[${this.type}] short completion suppressed: missing final assistant evidence, non-mesh session (source=${shortEvidenceSource})`);
42239
+ } else {
42218
42240
  this.pushEvent({
42219
42241
  event: "agent:generating_completed",
42220
42242
  chatTitle,
@@ -42224,8 +42246,7 @@ var CliProviderInstance = class _CliProviderInstance {
42224
42246
  completionDiagnostic: {
42225
42247
  reason: "short_generating_suppressed",
42226
42248
  shortDurationMs,
42227
- finalAssistantEvidenceSource: shortEvidenceSource,
42228
- ...missingEvidence ? { blockReason: "missing_final_assistant" } : {}
42249
+ finalAssistantEvidenceSource: shortEvidenceSource
42229
42250
  }
42230
42251
  });
42231
42252
  }
@@ -46578,38 +46599,75 @@ function extractUserPrompt(payload) {
46578
46599
  if (!text) return "";
46579
46600
  return extractUserRequestContent(text);
46580
46601
  }
46602
+ function isSqliteBusyError(err) {
46603
+ if (!err) return false;
46604
+ const code = err.code;
46605
+ if (typeof code === "string" && code.includes("SQLITE_BUSY")) return true;
46606
+ const msg = err instanceof Error ? err.message : String(err);
46607
+ return /SQLITE_BUSY|database is locked|database table is locked/i.test(msg);
46608
+ }
46609
+ var AGY_DB_BUSY_TIMEOUT_MS = 3e3;
46610
+ var AGY_DB_MAX_ATTEMPTS = 4;
46611
+ var AGY_DB_RETRY_BACKOFF_MS = [50, 100, 150];
46612
+ function sleepBusy(ms) {
46613
+ const end = Date.now() + ms;
46614
+ while (Date.now() < end) {
46615
+ }
46616
+ }
46581
46617
  function parseConversationDb(filePath, sessionId, workspace) {
46582
- let db;
46618
+ let Database;
46583
46619
  try {
46584
- const Database = loadBetterSqlite3();
46585
- db = new Database(filePath, { readonly: true, fileMustExist: true });
46620
+ Database = loadBetterSqlite3();
46586
46621
  } catch (err) {
46587
46622
  LOG.warn(
46588
46623
  "NativeHistory",
46589
- `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)`
46624
+ `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)`
46590
46625
  );
46591
46626
  return null;
46592
46627
  }
46593
- let rows;
46594
- try {
46595
- rows = db.prepare(
46596
- `SELECT idx, step_type, step_payload
46597
- FROM steps
46598
- WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
46599
- ORDER BY idx ASC`
46600
- ).all();
46601
- } catch (err) {
46602
- LOG.debug(
46603
- "NativeHistory",
46604
- `antigravity .db ${path31.basename(filePath)} has no readable steps table: ${err instanceof Error ? err.message : String(err)}`
46605
- );
46606
- return null;
46607
- } finally {
46628
+ let rows = null;
46629
+ let lastBusyErr;
46630
+ for (let attempt = 1; attempt <= AGY_DB_MAX_ATTEMPTS; attempt++) {
46631
+ let db;
46608
46632
  try {
46609
- db.close();
46610
- } catch {
46633
+ db = new Database(filePath, { readonly: true, fileMustExist: true });
46634
+ try {
46635
+ db.pragma(`busy_timeout = ${AGY_DB_BUSY_TIMEOUT_MS}`);
46636
+ } catch {
46637
+ }
46638
+ rows = db.prepare(
46639
+ `SELECT idx, step_type, step_payload
46640
+ FROM steps
46641
+ WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
46642
+ ORDER BY idx ASC`
46643
+ ).all();
46644
+ break;
46645
+ } catch (err) {
46646
+ if (isSqliteBusyError(err)) {
46647
+ lastBusyErr = err;
46648
+ if (attempt < AGY_DB_MAX_ATTEMPTS) {
46649
+ sleepBusy(AGY_DB_RETRY_BACKOFF_MS[attempt - 1] ?? 150);
46650
+ continue;
46651
+ }
46652
+ LOG.warn(
46653
+ "NativeHistory",
46654
+ `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)`
46655
+ );
46656
+ return null;
46657
+ }
46658
+ LOG.debug(
46659
+ "NativeHistory",
46660
+ `antigravity .db ${path31.basename(filePath)} not readable: ${err instanceof Error ? err.message : String(err)}`
46661
+ );
46662
+ return null;
46663
+ } finally {
46664
+ try {
46665
+ db?.close();
46666
+ } catch {
46667
+ }
46611
46668
  }
46612
46669
  }
46670
+ void lastBusyErr;
46613
46671
  if (!Array.isArray(rows) || rows.length === 0) return null;
46614
46672
  const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
46615
46673
  const baseTs = statMtimeMs3(filePath) || Date.now();