@ai-devkit/agent-manager 0.30.0 → 0.31.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/database/connection.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAMtC,eAAO,MAAM,8BAA8B,QAA6C,CAAC;AAEzF,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAEvB,OAAO,GAAE,eAAoB;
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/database/connection.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAMtC,eAAO,MAAM,8BAA8B,QAA6C,CAAC;AAEzF,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAEvB,OAAO,GAAE,eAAoB;IA4BzC,OAAO,CAAC,SAAS;IASjB,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAEhC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,CAAC,EAAE;IAIlD,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,CAAC,GAAG,SAAS;IAI/D,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,QAAQ,CAAC,SAAS;IAIhE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAI9B,KAAK,IAAI,IAAI;CAKhB"}
|
|
@@ -23,6 +23,7 @@ export class DatabaseConnection {
|
|
|
23
23
|
});
|
|
24
24
|
this.db = new Database(this.dbPath, {
|
|
25
25
|
readonly: this.readonly,
|
|
26
|
+
timeout: 5000,
|
|
26
27
|
verbose: typeof options.verbose === 'function' ? options.verbose : options.verbose ? console.log : undefined
|
|
27
28
|
});
|
|
28
29
|
if (this.readonly) {
|
|
@@ -39,7 +40,10 @@ export class DatabaseConnection {
|
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
configure() {
|
|
42
|
-
this.db.pragma('journal_mode
|
|
43
|
+
const journalMode = this.db.pragma('journal_mode', {
|
|
44
|
+
simple: true
|
|
45
|
+
});
|
|
46
|
+
if (journalMode.toLowerCase() !== 'wal') this.db.pragma('journal_mode = WAL');
|
|
43
47
|
this.db.pragma('foreign_keys = ON');
|
|
44
48
|
this.db.pragma('synchronous = NORMAL');
|
|
45
49
|
this.db.pragma('busy_timeout = 5000');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/database/connection.ts"],"sourcesContent":["import Database from 'better-sqlite3';\nimport { existsSync, mkdirSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { homedir } from 'os';\nimport { initializeSchema } from './schema.js';\n\nexport const DEFAULT_AGENT_REGISTRY_DB_PATH = join(homedir(), '.ai-devkit', 'agents.db');\n\nexport interface DatabaseOptions {\n dbPath?: string;\n verbose?: boolean | ((message: string) => void);\n readonly?: boolean;\n}\n\nexport function resolveAgentRegistryDbPath(filePath?: string): string {\n if (!filePath) return DEFAULT_AGENT_REGISTRY_DB_PATH;\n return filePath.endsWith('.json') ? filePath.replace(/\\.json$/, '.db') : filePath;\n}\n\nexport class DatabaseConnection {\n private db: Database.Database;\n private readonly dbPath: string;\n private readonly readonly: boolean;\n\n constructor(options: DatabaseOptions = {}) {\n this.dbPath = options.dbPath ?? DEFAULT_AGENT_REGISTRY_DB_PATH;\n this.readonly = options.readonly ?? false;\n if (this.readonly && !existsSync(this.dbPath)) {\n throw new Error(`Cannot open readonly agent database because it does not exist: ${this.dbPath}`);\n }\n if (!this.readonly) mkdirSync(dirname(this.dbPath), { recursive: true });\n\n this.db = new Database(this.dbPath, {\n readonly: this.readonly,\n verbose: typeof options.verbose === 'function'\n ? options.verbose\n : options.verbose ? console.log : undefined,\n });\n\n if (this.readonly) {\n const version = this.db.pragma('user_version', { simple: true }) as number;\n if (version < 3) {\n this.db.close();\n throw new Error(`Readonly agent database requires schema version 3 (found ${version}).`);\n }\n } else {\n this.configure();\n initializeSchema(this);\n }\n }\n\n private configure(): void {\n this.db.pragma('journal_mode = WAL');\n this.db.pragma('foreign_keys = ON');\n this.db.pragma('synchronous = NORMAL');\n this.db.pragma('busy_timeout = 5000');\n this.db.pragma('mmap_size = 268435456');\n }\n\n get instance(): Database.Database {\n return this.db;\n }\n\n get path(): string {\n return this.dbPath;\n }\n\n query<T>(sql: string, params: unknown[] = []): T[] {\n return this.db.prepare(sql).all(...params) as T[];\n }\n\n queryOne<T>(sql: string, params: unknown[] = []): T | undefined {\n return this.db.prepare(sql).get(...params) as T | undefined;\n }\n\n execute(sql: string, params: unknown[] = []): Database.RunResult {\n return this.db.prepare(sql).run(...params);\n }\n\n transaction<T>(fn: () => T): T {\n return this.db.transaction(fn)();\n }\n\n close(): void {\n if (this.db.open) {\n this.db.close();\n }\n }\n}\n"],"names":["Database","existsSync","mkdirSync","dirname","join","homedir","initializeSchema","DEFAULT_AGENT_REGISTRY_DB_PATH","resolveAgentRegistryDbPath","filePath","endsWith","replace","DatabaseConnection","db","dbPath","readonly","options","Error","recursive","verbose","console","log","undefined","version","pragma","simple","close","configure","instance","path","query","sql","params","prepare","all","queryOne","get","execute","run","transaction","fn","open"],"mappings":"AAAA,OAAOA,cAAc,iBAAiB;AACtC,SAASC,UAAU,EAAEC,SAAS,QAAQ,KAAK;AAC3C,SAASC,OAAO,EAAEC,IAAI,QAAQ,OAAO;AACrC,SAASC,OAAO,QAAQ,KAAK;AAC7B,SAASC,gBAAgB,QAAQ,cAAc;AAE/C,OAAO,MAAMC,iCAAiCH,KAAKC,WAAW,cAAc,aAAa;AAQzF,OAAO,SAASG,2BAA2BC,QAAiB;IACxD,IAAI,CAACA,UAAU,OAAOF;IACtB,OAAOE,SAASC,QAAQ,CAAC,WAAWD,SAASE,OAAO,CAAC,WAAW,SAASF;AAC7E;AAEA,OAAO,MAAMG;IACDC,GAAsB;IACbC,OAAe;IACfC,SAAkB;IAEnC,YAAYC,UAA2B,CAAC,CAAC,CAAE;QACvC,IAAI,CAACF,MAAM,GAAGE,QAAQF,MAAM,IAAIP;QAChC,IAAI,CAACQ,QAAQ,GAAGC,QAAQD,QAAQ,IAAI;QACpC,IAAI,IAAI,CAACA,QAAQ,IAAI,CAACd,WAAW,IAAI,CAACa,MAAM,GAAG;YAC3C,MAAM,IAAIG,MAAM,CAAC,+DAA+D,EAAE,IAAI,CAACH,MAAM,EAAE;QACnG;QACA,IAAI,CAAC,IAAI,CAACC,QAAQ,EAAEb,UAAUC,QAAQ,IAAI,CAACW,MAAM,GAAG;YAAEI,WAAW;QAAK;QAEtE,IAAI,CAACL,EAAE,GAAG,IAAIb,SAAS,IAAI,CAACc,MAAM,EAAE;YAChCC,UAAU,IAAI,CAACA,QAAQ;YACvBI,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../src/database/connection.ts"],"sourcesContent":["import Database from 'better-sqlite3';\nimport { existsSync, mkdirSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { homedir } from 'os';\nimport { initializeSchema } from './schema.js';\n\nexport const DEFAULT_AGENT_REGISTRY_DB_PATH = join(homedir(), '.ai-devkit', 'agents.db');\n\nexport interface DatabaseOptions {\n dbPath?: string;\n verbose?: boolean | ((message: string) => void);\n readonly?: boolean;\n}\n\nexport function resolveAgentRegistryDbPath(filePath?: string): string {\n if (!filePath) return DEFAULT_AGENT_REGISTRY_DB_PATH;\n return filePath.endsWith('.json') ? filePath.replace(/\\.json$/, '.db') : filePath;\n}\n\nexport class DatabaseConnection {\n private db: Database.Database;\n private readonly dbPath: string;\n private readonly readonly: boolean;\n\n constructor(options: DatabaseOptions = {}) {\n this.dbPath = options.dbPath ?? DEFAULT_AGENT_REGISTRY_DB_PATH;\n this.readonly = options.readonly ?? false;\n if (this.readonly && !existsSync(this.dbPath)) {\n throw new Error(`Cannot open readonly agent database because it does not exist: ${this.dbPath}`);\n }\n if (!this.readonly) mkdirSync(dirname(this.dbPath), { recursive: true });\n\n this.db = new Database(this.dbPath, {\n readonly: this.readonly,\n timeout: 5000,\n verbose: typeof options.verbose === 'function'\n ? options.verbose\n : options.verbose ? console.log : undefined,\n });\n\n if (this.readonly) {\n const version = this.db.pragma('user_version', { simple: true }) as number;\n if (version < 3) {\n this.db.close();\n throw new Error(`Readonly agent database requires schema version 3 (found ${version}).`);\n }\n } else {\n this.configure();\n initializeSchema(this);\n }\n }\n\n private configure(): void {\n const journalMode = this.db.pragma('journal_mode', { simple: true }) as string;\n if (journalMode.toLowerCase() !== 'wal') this.db.pragma('journal_mode = WAL');\n this.db.pragma('foreign_keys = ON');\n this.db.pragma('synchronous = NORMAL');\n this.db.pragma('busy_timeout = 5000');\n this.db.pragma('mmap_size = 268435456');\n }\n\n get instance(): Database.Database {\n return this.db;\n }\n\n get path(): string {\n return this.dbPath;\n }\n\n query<T>(sql: string, params: unknown[] = []): T[] {\n return this.db.prepare(sql).all(...params) as T[];\n }\n\n queryOne<T>(sql: string, params: unknown[] = []): T | undefined {\n return this.db.prepare(sql).get(...params) as T | undefined;\n }\n\n execute(sql: string, params: unknown[] = []): Database.RunResult {\n return this.db.prepare(sql).run(...params);\n }\n\n transaction<T>(fn: () => T): T {\n return this.db.transaction(fn)();\n }\n\n close(): void {\n if (this.db.open) {\n this.db.close();\n }\n }\n}\n"],"names":["Database","existsSync","mkdirSync","dirname","join","homedir","initializeSchema","DEFAULT_AGENT_REGISTRY_DB_PATH","resolveAgentRegistryDbPath","filePath","endsWith","replace","DatabaseConnection","db","dbPath","readonly","options","Error","recursive","timeout","verbose","console","log","undefined","version","pragma","simple","close","configure","journalMode","toLowerCase","instance","path","query","sql","params","prepare","all","queryOne","get","execute","run","transaction","fn","open"],"mappings":"AAAA,OAAOA,cAAc,iBAAiB;AACtC,SAASC,UAAU,EAAEC,SAAS,QAAQ,KAAK;AAC3C,SAASC,OAAO,EAAEC,IAAI,QAAQ,OAAO;AACrC,SAASC,OAAO,QAAQ,KAAK;AAC7B,SAASC,gBAAgB,QAAQ,cAAc;AAE/C,OAAO,MAAMC,iCAAiCH,KAAKC,WAAW,cAAc,aAAa;AAQzF,OAAO,SAASG,2BAA2BC,QAAiB;IACxD,IAAI,CAACA,UAAU,OAAOF;IACtB,OAAOE,SAASC,QAAQ,CAAC,WAAWD,SAASE,OAAO,CAAC,WAAW,SAASF;AAC7E;AAEA,OAAO,MAAMG;IACDC,GAAsB;IACbC,OAAe;IACfC,SAAkB;IAEnC,YAAYC,UAA2B,CAAC,CAAC,CAAE;QACvC,IAAI,CAACF,MAAM,GAAGE,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ACnB;IAEA,IAAIM,WAA8B;QAC9B,OAAO,IAAI,CAAClB,EAAE;IAClB;IAEA,IAAImB,OAAe;QACf,OAAO,IAAI,CAAClB,MAAM;IACtB;IAEAmB,MAASC,GAAW,EAAEC,SAAoB,EAAE,EAAO;QAC/C,OAAO,IAAI,CAACtB,EAAE,CAACuB,OAAO,CAACF,KAAKG,GAAG,IAAIF;IACvC;IAEAG,SAAYJ,GAAW,EAAEC,SAAoB,EAAE,EAAiB;QAC5D,OAAO,IAAI,CAACtB,EAAE,CAACuB,OAAO,CAACF,KAAKK,GAAG,IAAIJ;IACvC;IAEAK,QAAQN,GAAW,EAAEC,SAAoB,EAAE,EAAsB;QAC7D,OAAO,IAAI,CAACtB,EAAE,CAACuB,OAAO,CAACF,KAAKO,GAAG,IAAIN;IACvC;IAEAO,YAAeC,EAAW,EAAK;QAC3B,OAAO,IAAI,CAAC9B,EAAE,CAAC6B,WAAW,CAACC;IAC/B;IAEAhB,QAAc;QACV,IAAI,IAAI,CAACd,EAAE,CAAC+B,IAAI,EAAE;YACd,IAAI,CAAC/B,EAAE,CAACc,KAAK;QACjB;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -32,6 +32,7 @@ export class DatabaseConnection {
|
|
|
32
32
|
|
|
33
33
|
this.db = new Database(this.dbPath, {
|
|
34
34
|
readonly: this.readonly,
|
|
35
|
+
timeout: 5000,
|
|
35
36
|
verbose: typeof options.verbose === 'function'
|
|
36
37
|
? options.verbose
|
|
37
38
|
: options.verbose ? console.log : undefined,
|
|
@@ -50,7 +51,8 @@ export class DatabaseConnection {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
private configure(): void {
|
|
53
|
-
this.db.pragma('journal_mode
|
|
54
|
+
const journalMode = this.db.pragma('journal_mode', { simple: true }) as string;
|
|
55
|
+
if (journalMode.toLowerCase() !== 'wal') this.db.pragma('journal_mode = WAL');
|
|
54
56
|
this.db.pragma('foreign_keys = ON');
|
|
55
57
|
this.db.pragma('synchronous = NORMAL');
|
|
56
58
|
this.db.pragma('busy_timeout = 5000');
|