@adhdev/daemon-core 0.9.82-rc.68 → 0.9.82-rc.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.68",
3
+ "version": "0.9.82-rc.69",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3933,7 +3933,17 @@ export class DaemonCommandRouter {
3933
3933
  ...(providerPriority.length ? { providerPriority } : {}),
3934
3934
  };
3935
3935
  const role = normalizeMeshDaemonRole(args?.role);
3936
- const node = addNode(meshId, { workspace, ...(policy ? { policy } : {}), ...(role ? { role } : {}) });
3936
+ const daemonId = typeof args?.daemonId === 'string' && args.daemonId.trim() ? args.daemonId.trim() : undefined;
3937
+ const machineId = typeof args?.machineId === 'string' && args.machineId.trim() ? args.machineId.trim() : undefined;
3938
+ const repoRoot = typeof args?.repoRoot === 'string' && args.repoRoot.trim() ? args.repoRoot.trim() : undefined;
3939
+ const node = addNode(meshId, {
3940
+ workspace,
3941
+ ...(repoRoot ? { repoRoot } : {}),
3942
+ ...(daemonId ? { daemonId } : {}),
3943
+ ...(machineId ? { machineId } : {}),
3944
+ ...(policy ? { policy } : {}),
3945
+ ...(role ? { role } : {}),
3946
+ });
3937
3947
  if (!node) return { success: false, error: 'Mesh not found' };
3938
3948
  return { success: true, node };
3939
3949
  } catch (e: any) {
@@ -1,8 +1,21 @@
1
- import Database from 'better-sqlite3';
2
1
  import { existsSync, mkdirSync, readFileSync } from 'fs';
3
2
  import { dirname, join } from 'path';
3
+ import { createRequire } from 'module';
4
4
  import { getLedgerDir } from './mesh-ledger.js';
5
5
  import type { MeshTaskStatus, MeshWorkQueueEntry } from './mesh-work-queue.js';
6
+ import type BetterSqlite3 from 'better-sqlite3';
7
+ import type { Database as DatabaseHandle } from 'better-sqlite3';
8
+
9
+ let DatabaseCtor: typeof BetterSqlite3 | undefined;
10
+
11
+ function loadDatabaseCtor(): typeof BetterSqlite3 {
12
+ if (DatabaseCtor) return DatabaseCtor;
13
+ const runtimeRequire = typeof require === 'function'
14
+ ? require
15
+ : createRequire(import.meta.url);
16
+ DatabaseCtor = runtimeRequire('better-sqlite3') as typeof BetterSqlite3;
17
+ return DatabaseCtor;
18
+ }
6
19
 
7
20
  function safeMeshId(meshId: string): string {
8
21
  return meshId.replace(/[^a-zA-Z0-9_-]/g, '_');
@@ -14,14 +27,14 @@ function legacyQueuePath(meshId: string): string {
14
27
 
15
28
  export class BeadsDB {
16
29
  private static instance: BeadsDB | undefined;
17
- private readonly db: Database.Database;
30
+ private readonly db: DatabaseHandle;
18
31
  private readonly migratedMeshIds = new Set<string>();
19
32
 
20
33
  private constructor(dbPath: string) {
21
34
  const dir = dirname(dbPath);
22
35
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
23
36
 
24
- this.db = new Database(dbPath);
37
+ this.db = new (loadDatabaseCtor())(dbPath);
25
38
  this.db.pragma('journal_mode = WAL');
26
39
  this.db.pragma('synchronous = NORMAL');
27
40
  this.db.pragma('foreign_keys = ON');