@adhdev/daemon-core 0.9.5 → 0.9.6

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
@@ -12932,6 +12932,13 @@ var CliProviderInstance = class {
12932
12932
  runtimeMessages = [];
12933
12933
  lastPersistedHistoryMessages = [];
12934
12934
  lastCanonicalHermesSyncMtimeMs = 0;
12935
+ lastCanonicalHermesExistCheckAt = 0;
12936
+ lastCanonicalHermesWatchPath = void 0;
12937
+ lastCanonicalClaudeRebuildMtimeMs = 0;
12938
+ lastCanonicalClaudeCheckAt = 0;
12939
+ cachedSqliteDb = null;
12940
+ cachedSqliteDbPath = null;
12941
+ cachedSqliteDbMissingUntil = 0;
12935
12942
  instanceId;
12936
12943
  suppressIdleHistoryReplay = false;
12937
12944
  errorMessage = void 0;
@@ -12996,7 +13003,12 @@ var CliProviderInstance = class {
12996
13003
  */
12997
13004
  probeSessionIdFromConfig(probe) {
12998
13005
  const resolvedDbPath = probe.dbPath.replace(/^~/, os11.homedir());
12999
- if (!fs5.existsSync(resolvedDbPath)) return null;
13006
+ const now = Date.now();
13007
+ if (this.cachedSqliteDbMissingUntil > now) return null;
13008
+ if (!fs5.existsSync(resolvedDbPath)) {
13009
+ this.cachedSqliteDbMissingUntil = now + 1e4;
13010
+ return null;
13011
+ }
13000
13012
  const directories = this.getProbeDirectories();
13001
13013
  const minCreatedAt = Math.max(0, this.startedAt - 6e4);
13002
13014
  const tsFormat = probe.timestampFormat || "unix_ms";
@@ -13167,6 +13179,12 @@ var CliProviderInstance = class {
13167
13179
  this.adapter.shutdown();
13168
13180
  this.monitor.reset();
13169
13181
  this.appliedEffectKeys.clear();
13182
+ try {
13183
+ this.cachedSqliteDb?.close();
13184
+ } catch {
13185
+ }
13186
+ this.cachedSqliteDb = null;
13187
+ this.cachedSqliteDbPath = null;
13170
13188
  }
13171
13189
  completedDebounceTimer = null;
13172
13190
  completedDebouncePending = null;
@@ -13571,13 +13589,35 @@ ${effect.notification.body || ""}`.trim();
13571
13589
  let rebuilt = false;
13572
13590
  if (canonicalHistory.format === "hermes-json") {
13573
13591
  const watchPath = canonicalHistory.watchPath.replace(/^~/, os11.homedir()).replace("{{sessionId}}", this.providerSessionId);
13574
- if (!fs5.existsSync(watchPath)) return false;
13592
+ const now = Date.now();
13593
+ if (watchPath !== this.lastCanonicalHermesWatchPath || now - this.lastCanonicalHermesExistCheckAt >= 2e3) {
13594
+ this.lastCanonicalHermesWatchPath = watchPath;
13595
+ this.lastCanonicalHermesExistCheckAt = now;
13596
+ if (!fs5.existsSync(watchPath)) return false;
13597
+ } else if (this.lastCanonicalHermesSyncMtimeMs === 0) {
13598
+ if (!fs5.existsSync(watchPath)) return false;
13599
+ }
13575
13600
  const stat = fs5.statSync(watchPath);
13576
13601
  if (stat.mtimeMs <= this.lastCanonicalHermesSyncMtimeMs) return true;
13577
13602
  rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
13578
13603
  if (rebuilt) this.lastCanonicalHermesSyncMtimeMs = stat.mtimeMs;
13579
13604
  } else if (canonicalHistory.format === "claude-jsonl") {
13605
+ const now = Date.now();
13606
+ if (now - this.lastCanonicalClaudeCheckAt < 2e3 && this.lastCanonicalClaudeRebuildMtimeMs !== 0) {
13607
+ return true;
13608
+ }
13609
+ this.lastCanonicalClaudeCheckAt = now;
13610
+ const claudeProjectsDir = path11.join(os11.homedir(), ".claude", "projects");
13611
+ const workspaceSegment = typeof this.workingDir === "string" ? this.workingDir.replace(/[\\/]/g, "-").replace(/^-+/, "") : "";
13612
+ const transcriptFile = path11.join(claudeProjectsDir, workspaceSegment, `${this.providerSessionId}.jsonl`);
13613
+ let transcriptMtime = 0;
13614
+ try {
13615
+ transcriptMtime = fs5.statSync(transcriptFile).mtimeMs;
13616
+ } catch {
13617
+ }
13618
+ if (transcriptMtime > 0 && transcriptMtime <= this.lastCanonicalClaudeRebuildMtimeMs) return true;
13580
13619
  rebuilt = rebuildClaudeSavedHistoryFromNativeProject(this.providerSessionId, this.workingDir);
13620
+ if (rebuilt) this.lastCanonicalClaudeRebuildMtimeMs = transcriptMtime || Date.now();
13581
13621
  }
13582
13622
  if (!rebuilt) return false;
13583
13623
  const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
@@ -13642,20 +13682,29 @@ ${effect.notification.body || ""}`.trim();
13642
13682
  return Array.from({ length: count }, () => "?").join(", ");
13643
13683
  }
13644
13684
  querySqliteText(dbPath, query, params) {
13645
- let db = null;
13646
13685
  try {
13647
- const DatabaseSync = getDatabaseSync();
13648
- db = new DatabaseSync(dbPath, { readOnly: true });
13649
- const row = db.prepare(query).get(...params);
13686
+ if (this.cachedSqliteDb === null || this.cachedSqliteDbPath !== dbPath) {
13687
+ try {
13688
+ this.cachedSqliteDb?.close();
13689
+ } catch {
13690
+ }
13691
+ this.cachedSqliteDb = null;
13692
+ this.cachedSqliteDbPath = null;
13693
+ const DatabaseSync = getDatabaseSync();
13694
+ this.cachedSqliteDb = new DatabaseSync(dbPath, { readOnly: true });
13695
+ this.cachedSqliteDbPath = dbPath;
13696
+ }
13697
+ const row = this.cachedSqliteDb.prepare(query).get(...params);
13650
13698
  const sessionId = typeof row?.id === "string" ? row.id.trim() : "";
13651
13699
  return sessionId || null;
13652
13700
  } catch {
13653
- return null;
13654
- } finally {
13655
13701
  try {
13656
- db?.close();
13702
+ this.cachedSqliteDb?.close();
13657
13703
  } catch {
13658
13704
  }
13705
+ this.cachedSqliteDb = null;
13706
+ this.cachedSqliteDbPath = null;
13707
+ return null;
13659
13708
  }
13660
13709
  }
13661
13710
  };
@@ -15613,6 +15662,7 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
15613
15662
  "canonicalHistory",
15614
15663
  "autoFixProfile",
15615
15664
  "ideLevelScripts",
15665
+ "allowInputDuringGeneration",
15616
15666
  "scripts",
15617
15667
  "vscodeCommands",
15618
15668
  "inputMethod",