@adhdev/daemon-standalone 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
@@ -40690,6 +40690,13 @@ ${effect.notification.body || ""}`.trim();
40690
40690
  runtimeMessages = [];
40691
40691
  lastPersistedHistoryMessages = [];
40692
40692
  lastCanonicalHermesSyncMtimeMs = 0;
40693
+ lastCanonicalHermesExistCheckAt = 0;
40694
+ lastCanonicalHermesWatchPath = void 0;
40695
+ lastCanonicalClaudeRebuildMtimeMs = 0;
40696
+ lastCanonicalClaudeCheckAt = 0;
40697
+ cachedSqliteDb = null;
40698
+ cachedSqliteDbPath = null;
40699
+ cachedSqliteDbMissingUntil = 0;
40693
40700
  instanceId;
40694
40701
  suppressIdleHistoryReplay = false;
40695
40702
  errorMessage = void 0;
@@ -40754,7 +40761,12 @@ ${effect.notification.body || ""}`.trim();
40754
40761
  */
40755
40762
  probeSessionIdFromConfig(probe) {
40756
40763
  const resolvedDbPath = probe.dbPath.replace(/^~/, os11.homedir());
40757
- if (!fs52.existsSync(resolvedDbPath)) return null;
40764
+ const now = Date.now();
40765
+ if (this.cachedSqliteDbMissingUntil > now) return null;
40766
+ if (!fs52.existsSync(resolvedDbPath)) {
40767
+ this.cachedSqliteDbMissingUntil = now + 1e4;
40768
+ return null;
40769
+ }
40758
40770
  const directories = this.getProbeDirectories();
40759
40771
  const minCreatedAt = Math.max(0, this.startedAt - 6e4);
40760
40772
  const tsFormat = probe.timestampFormat || "unix_ms";
@@ -40925,6 +40937,12 @@ ${effect.notification.body || ""}`.trim();
40925
40937
  this.adapter.shutdown();
40926
40938
  this.monitor.reset();
40927
40939
  this.appliedEffectKeys.clear();
40940
+ try {
40941
+ this.cachedSqliteDb?.close();
40942
+ } catch {
40943
+ }
40944
+ this.cachedSqliteDb = null;
40945
+ this.cachedSqliteDbPath = null;
40928
40946
  }
40929
40947
  completedDebounceTimer = null;
40930
40948
  completedDebouncePending = null;
@@ -41329,13 +41347,35 @@ ${effect.notification.body || ""}`.trim();
41329
41347
  let rebuilt = false;
41330
41348
  if (canonicalHistory.format === "hermes-json") {
41331
41349
  const watchPath = canonicalHistory.watchPath.replace(/^~/, os11.homedir()).replace("{{sessionId}}", this.providerSessionId);
41332
- if (!fs52.existsSync(watchPath)) return false;
41350
+ const now = Date.now();
41351
+ if (watchPath !== this.lastCanonicalHermesWatchPath || now - this.lastCanonicalHermesExistCheckAt >= 2e3) {
41352
+ this.lastCanonicalHermesWatchPath = watchPath;
41353
+ this.lastCanonicalHermesExistCheckAt = now;
41354
+ if (!fs52.existsSync(watchPath)) return false;
41355
+ } else if (this.lastCanonicalHermesSyncMtimeMs === 0) {
41356
+ if (!fs52.existsSync(watchPath)) return false;
41357
+ }
41333
41358
  const stat4 = fs52.statSync(watchPath);
41334
41359
  if (stat4.mtimeMs <= this.lastCanonicalHermesSyncMtimeMs) return true;
41335
41360
  rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
41336
41361
  if (rebuilt) this.lastCanonicalHermesSyncMtimeMs = stat4.mtimeMs;
41337
41362
  } else if (canonicalHistory.format === "claude-jsonl") {
41363
+ const now = Date.now();
41364
+ if (now - this.lastCanonicalClaudeCheckAt < 2e3 && this.lastCanonicalClaudeRebuildMtimeMs !== 0) {
41365
+ return true;
41366
+ }
41367
+ this.lastCanonicalClaudeCheckAt = now;
41368
+ const claudeProjectsDir = path11.join(os11.homedir(), ".claude", "projects");
41369
+ const workspaceSegment = typeof this.workingDir === "string" ? this.workingDir.replace(/[\\/]/g, "-").replace(/^-+/, "") : "";
41370
+ const transcriptFile = path11.join(claudeProjectsDir, workspaceSegment, `${this.providerSessionId}.jsonl`);
41371
+ let transcriptMtime = 0;
41372
+ try {
41373
+ transcriptMtime = fs52.statSync(transcriptFile).mtimeMs;
41374
+ } catch {
41375
+ }
41376
+ if (transcriptMtime > 0 && transcriptMtime <= this.lastCanonicalClaudeRebuildMtimeMs) return true;
41338
41377
  rebuilt = rebuildClaudeSavedHistoryFromNativeProject(this.providerSessionId, this.workingDir);
41378
+ if (rebuilt) this.lastCanonicalClaudeRebuildMtimeMs = transcriptMtime || Date.now();
41339
41379
  }
41340
41380
  if (!rebuilt) return false;
41341
41381
  const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
@@ -41400,20 +41440,29 @@ ${effect.notification.body || ""}`.trim();
41400
41440
  return Array.from({ length: count }, () => "?").join(", ");
41401
41441
  }
41402
41442
  querySqliteText(dbPath, query, params) {
41403
- let db = null;
41404
41443
  try {
41405
- const DatabaseSync = getDatabaseSync();
41406
- db = new DatabaseSync(dbPath, { readOnly: true });
41407
- const row = db.prepare(query).get(...params);
41444
+ if (this.cachedSqliteDb === null || this.cachedSqliteDbPath !== dbPath) {
41445
+ try {
41446
+ this.cachedSqliteDb?.close();
41447
+ } catch {
41448
+ }
41449
+ this.cachedSqliteDb = null;
41450
+ this.cachedSqliteDbPath = null;
41451
+ const DatabaseSync = getDatabaseSync();
41452
+ this.cachedSqliteDb = new DatabaseSync(dbPath, { readOnly: true });
41453
+ this.cachedSqliteDbPath = dbPath;
41454
+ }
41455
+ const row = this.cachedSqliteDb.prepare(query).get(...params);
41408
41456
  const sessionId = typeof row?.id === "string" ? row.id.trim() : "";
41409
41457
  return sessionId || null;
41410
41458
  } catch {
41411
- return null;
41412
- } finally {
41413
41459
  try {
41414
- db?.close();
41460
+ this.cachedSqliteDb?.close();
41415
41461
  } catch {
41416
41462
  }
41463
+ this.cachedSqliteDb = null;
41464
+ this.cachedSqliteDbPath = null;
41465
+ return null;
41417
41466
  }
41418
41467
  }
41419
41468
  };
@@ -43357,6 +43406,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43357
43406
  "canonicalHistory",
43358
43407
  "autoFixProfile",
43359
43408
  "ideLevelScripts",
43409
+ "allowInputDuringGeneration",
43360
43410
  "scripts",
43361
43411
  "vscodeCommands",
43362
43412
  "inputMethod",