@dikolab/kbdb 0.5.0 → 0.6.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.
Files changed (224) hide show
  1. package/CLA.md +68 -0
  2. package/LICENSE +676 -12
  3. package/LICENSING.md +58 -0
  4. package/README.md +47 -24
  5. package/README.md.bak +320 -0
  6. package/dist/README.md +320 -0
  7. package/dist/{chunk-BJXEVALU.mjs → chunk-QLJ33C74.mjs} +44 -44
  8. package/dist/chunk-QLJ33C74.mjs.map +7 -0
  9. package/dist/cli.cjs +550 -232
  10. package/dist/cli.cjs.map +4 -4
  11. package/dist/cli.d.ts +0 -8
  12. package/dist/cli.mjs +483 -154
  13. package/dist/cli.mjs.map +4 -4
  14. package/dist/kbdb-worker.cjs +36 -5
  15. package/dist/kbdb-worker.cjs.map +3 -3
  16. package/dist/mod.cjs +89 -30
  17. package/dist/mod.cjs.map +4 -4
  18. package/dist/mod.mjs +88 -30
  19. package/dist/mod.mjs.map +4 -4
  20. package/dist/src/cli.d.ts +0 -8
  21. package/dist/src/shared/cli/constants/defaults.constant.d.ts +1 -1
  22. package/dist/src/shared/cli/constants/recfile-command-field-map.constant.d.ts +8 -0
  23. package/dist/src/shared/cli/constants/recfile-field-maps.constant.d.ts +21 -0
  24. package/dist/src/shared/cli/functions/compute-directory-level.function.d.ts +14 -0
  25. package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -28
  26. package/dist/src/shared/cli/functions/format-command-output.function.d.ts +14 -0
  27. package/dist/src/shared/cli/functions/format-db-not-found.function.d.ts +20 -0
  28. package/dist/src/shared/cli/functions/format-output.function.d.ts +1 -0
  29. package/dist/src/shared/cli/functions/format-recfile-output.function.d.ts +11 -0
  30. package/dist/src/shared/cli/functions/render-recfile-value.function.d.ts +11 -0
  31. package/dist/src/shared/cli/functions/resolve-db-dir.function.d.ts +24 -0
  32. package/dist/src/shared/cli/functions/resolve-recfile-key.function.d.ts +9 -0
  33. package/dist/src/shared/cli/functions/run-db-path.function.d.ts +10 -0
  34. package/dist/src/shared/cli/functions/run-export.function.d.ts +8 -4
  35. package/dist/src/shared/cli/functions/run-import.function.d.ts +4 -0
  36. package/dist/src/shared/cli/functions/run-learn.function.d.ts +12 -0
  37. package/dist/src/shared/cli/index.d.ts +4 -1
  38. package/dist/src/shared/cli/typings/cli-options.interface.d.ts +9 -2
  39. package/dist/src/shared/cli/typings/db-resolution.interface.d.ts +9 -0
  40. package/dist/src/shared/cli/typings/recfile-field-map.type.d.ts +10 -0
  41. package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
  42. package/dist/src/shared/wasm-codec/functions/decode-option-u8.function.d.ts +9 -0
  43. package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +4 -0
  44. package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +2 -45
  45. package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +10 -1
  46. package/dist/src/shared/wasm-codec/index.d.ts +1 -1
  47. package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +6 -0
  48. package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +5 -0
  49. package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +5 -0
  50. package/dist/src/shared/worker-client/functions/build-deno-permissions.function.d.ts +11 -0
  51. package/dist/src/shared/worker-client/functions/read-crash-reason.function.d.ts +9 -0
  52. package/dist/src/shared/worker-client/functions/resolve-spawn-script.function.d.ts +6 -0
  53. package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +1 -1
  54. package/dist/src/shared/worker-client/typings/section.model.d.ts +5 -0
  55. package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +0 -6
  56. package/dist/src/shared/worker-daemon/functions/count-files.function.d.ts +12 -0
  57. package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +2 -0
  58. package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +8 -0
  59. package/dist/src/shared/worker-daemon/functions/validate-daemon-path.function.d.ts +15 -0
  60. package/dist/src/worker.d.ts +0 -7
  61. package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm +0 -0
  62. package/dist/wasm/default-embedding/package.json +1 -1
  63. package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
  64. package/dist/wasm/fs-database/package.json +1 -1
  65. package/dist/wasm/fs-migration/package.json +1 -1
  66. package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
  67. package/dist/wasm/kb-worker/package.json +1 -1
  68. package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
  69. package/dist/wasm/query-parser/package.json +1 -1
  70. package/dist/worker.d.ts +0 -7
  71. package/dist/worker.mjs +37 -6
  72. package/dist/worker.mjs.map +3 -3
  73. package/package.json +10 -9
  74. package/dist/chunk-BJXEVALU.mjs.map +0 -7
  75. package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +0 -10
  76. package/docs/details/README.md +0 -30
  77. package/docs/details/agent-tooling.md +0 -132
  78. package/docs/details/cli.md +0 -777
  79. package/docs/details/knowledge-base.md +0 -180
  80. package/docs/details/library-api.md +0 -495
  81. package/docs/details/mcp-server.md +0 -482
  82. package/docs/details/search-and-ranking.md +0 -575
  83. package/docs/details/storage.md +0 -531
  84. package/docs/goals/agents.md +0 -751
  85. package/docs/goals/architecture.svg +0 -198
  86. package/docs/goals/auto-capture.md +0 -378
  87. package/docs/goals/benchmarking.md +0 -296
  88. package/docs/goals/cli.md +0 -2654
  89. package/docs/goals/concurrency.md +0 -259
  90. package/docs/goals/content-composer.md +0 -609
  91. package/docs/goals/content-parser.md +0 -279
  92. package/docs/goals/database.md +0 -1679
  93. package/docs/goals/document.md +0 -368
  94. package/docs/goals/hybrid-search.md +0 -465
  95. package/docs/goals/mcp.md +0 -1541
  96. package/docs/goals/overview.md +0 -124
  97. package/docs/goals/query-parser.md +0 -373
  98. package/docs/goals/query-result.md +0 -860
  99. package/docs/goals/semantic-dedup.md +0 -233
  100. package/docs/goals/skills.md +0 -810
  101. package/docs/goals/sync.md +0 -217
  102. package/docs/goals/worker-client.md +0 -1005
  103. package/docs/goals/worker-daemon.md +0 -1547
  104. package/docs/modules/overview.md +0 -319
  105. package/docs/modules/rust/embedding/module.md +0 -91
  106. package/docs/modules/rust/fs-database/functions/document.md +0 -48
  107. package/docs/modules/rust/fs-database/functions/integrity.md +0 -79
  108. package/docs/modules/rust/fs-database/functions/io.md +0 -87
  109. package/docs/modules/rust/fs-database/functions/module.md +0 -22
  110. package/docs/modules/rust/fs-database/functions/query-exec.md +0 -44
  111. package/docs/modules/rust/fs-database/functions/section.md +0 -76
  112. package/docs/modules/rust/fs-database/indexes/btree.md +0 -35
  113. package/docs/modules/rust/fs-database/indexes/corpus.md +0 -61
  114. package/docs/modules/rust/fs-database/indexes/inverted.md +0 -60
  115. package/docs/modules/rust/fs-database/indexes/module.md +0 -64
  116. package/docs/modules/rust/fs-database/indexes/positional.md +0 -39
  117. package/docs/modules/rust/fs-database/indexes/vectors.md +0 -110
  118. package/docs/modules/rust/fs-database/module.md +0 -150
  119. package/docs/modules/rust/fs-database/types/catalog.md +0 -53
  120. package/docs/modules/rust/fs-database/types/module.md +0 -12
  121. package/docs/modules/rust/fs-database/types/section.md +0 -127
  122. package/docs/modules/rust/kb-worker/functions/compose.md +0 -57
  123. package/docs/modules/rust/kb-worker/functions/module.md +0 -20
  124. package/docs/modules/rust/kb-worker/functions/retrieve.md +0 -194
  125. package/docs/modules/rust/kb-worker/functions/search.md +0 -173
  126. package/docs/modules/rust/kb-worker/functions/write.md +0 -172
  127. package/docs/modules/rust/kb-worker/module.md +0 -171
  128. package/docs/modules/rust/kb-worker/types/cache.md +0 -90
  129. package/docs/modules/rust/kb-worker/types/context.md +0 -26
  130. package/docs/modules/rust/kb-worker/types/module.md +0 -16
  131. package/docs/modules/rust/kb-worker/types/status.md +0 -29
  132. package/docs/modules/rust/kb-worker/types/token.md +0 -50
  133. package/docs/modules/rust/overview.md +0 -531
  134. package/docs/modules/rust/query-parser/functions/extract.md +0 -56
  135. package/docs/modules/rust/query-parser/functions/module.md +0 -18
  136. package/docs/modules/rust/query-parser/functions/parse.md +0 -33
  137. package/docs/modules/rust/query-parser/functions/pipeline.md +0 -9
  138. package/docs/modules/rust/query-parser/functions/rank.md +0 -85
  139. package/docs/modules/rust/query-parser/module.md +0 -131
  140. package/docs/modules/rust/query-parser/types/cache.md +0 -39
  141. package/docs/modules/rust/query-parser/types/keyphrase.md +0 -71
  142. package/docs/modules/rust/query-parser/types/module.md +0 -18
  143. package/docs/modules/rust/query-parser/types/token.md +0 -46
  144. package/docs/modules/rust/shared/content-composer/functions.md +0 -114
  145. package/docs/modules/rust/shared/content-composer/module.md +0 -147
  146. package/docs/modules/rust/shared/content-composer/types.md +0 -93
  147. package/docs/modules/rust/shared/content-parser/functions.md +0 -72
  148. package/docs/modules/rust/shared/content-parser/module.md +0 -99
  149. package/docs/modules/rust/shared/content-parser/types.md +0 -71
  150. package/docs/modules/rust/shared/corpus/module.md +0 -24
  151. package/docs/modules/rust/shared/corpus/types.md +0 -141
  152. package/docs/modules/rust/shared/document/module.md +0 -25
  153. package/docs/modules/rust/shared/document/types.md +0 -154
  154. package/docs/modules/rust/shared/encode/module.md +0 -22
  155. package/docs/modules/rust/shared/encode/traits.md +0 -304
  156. package/docs/modules/rust/shared/error/module.md +0 -28
  157. package/docs/modules/rust/shared/error/types.md +0 -302
  158. package/docs/modules/rust/shared/kbid/module.md +0 -24
  159. package/docs/modules/rust/shared/kbid/types.md +0 -147
  160. package/docs/modules/rust/shared/memory/functions.md +0 -209
  161. package/docs/modules/rust/shared/memory/module.md +0 -24
  162. package/docs/modules/rust/shared/module.md +0 -196
  163. package/docs/modules/rust/shared/pipeline/functions.md +0 -141
  164. package/docs/modules/rust/shared/pipeline/module.md +0 -62
  165. package/docs/modules/rust/shared/pipeline/types.md +0 -43
  166. package/docs/modules/rust/shared/query/module.md +0 -27
  167. package/docs/modules/rust/shared/query/types.md +0 -236
  168. package/docs/modules/rust/shared/section/module.md +0 -25
  169. package/docs/modules/rust/shared/section/types.md +0 -294
  170. package/docs/modules/rust/shared/term/module.md +0 -25
  171. package/docs/modules/rust/shared/term/types.md +0 -139
  172. package/docs/modules/typescript/cli.md +0 -131
  173. package/docs/modules/typescript/kbdb-worker.md +0 -150
  174. package/docs/modules/typescript/overview.md +0 -400
  175. package/docs/modules/typescript/shared/auto-capture/module.md +0 -73
  176. package/docs/modules/typescript/shared/cli/constants.md +0 -23
  177. package/docs/modules/typescript/shared/cli/functions.md +0 -809
  178. package/docs/modules/typescript/shared/cli/module.md +0 -138
  179. package/docs/modules/typescript/shared/cli/typings.md +0 -197
  180. package/docs/modules/typescript/shared/embedding/functions.md +0 -200
  181. package/docs/modules/typescript/shared/embedding/module.md +0 -77
  182. package/docs/modules/typescript/shared/embedding/typings.md +0 -124
  183. package/docs/modules/typescript/shared/hash/functions.md +0 -20
  184. package/docs/modules/typescript/shared/hash/module.md +0 -21
  185. package/docs/modules/typescript/shared/log/constants.md +0 -82
  186. package/docs/modules/typescript/shared/log/functions.md +0 -131
  187. package/docs/modules/typescript/shared/log/module.md +0 -153
  188. package/docs/modules/typescript/shared/log/typings.md +0 -82
  189. package/docs/modules/typescript/shared/mcp/classes.md +0 -179
  190. package/docs/modules/typescript/shared/mcp/functions.md +0 -386
  191. package/docs/modules/typescript/shared/mcp/module.md +0 -160
  192. package/docs/modules/typescript/shared/mcp/typings.md +0 -529
  193. package/docs/modules/typescript/shared/module.md +0 -110
  194. package/docs/modules/typescript/shared/platform/functions.md +0 -42
  195. package/docs/modules/typescript/shared/platform/module.md +0 -25
  196. package/docs/modules/typescript/shared/runtime/functions.md +0 -26
  197. package/docs/modules/typescript/shared/runtime/module.md +0 -27
  198. package/docs/modules/typescript/shared/runtime/typings.md +0 -13
  199. package/docs/modules/typescript/shared/version/module.md +0 -27
  200. package/docs/modules/typescript/shared/wasm-codec/functions.md +0 -391
  201. package/docs/modules/typescript/shared/wasm-codec/module.md +0 -98
  202. package/docs/modules/typescript/shared/worker-client/classes.md +0 -264
  203. package/docs/modules/typescript/shared/worker-client/functions.md +0 -175
  204. package/docs/modules/typescript/shared/worker-client/module.md +0 -92
  205. package/docs/modules/typescript/shared/worker-client/typings.md +0 -511
  206. package/docs/modules/typescript/shared/worker-daemon/classes.md +0 -239
  207. package/docs/modules/typescript/shared/worker-daemon/constants.md +0 -37
  208. package/docs/modules/typescript/shared/worker-daemon/functions.md +0 -234
  209. package/docs/modules/typescript/shared/worker-daemon/module.md +0 -118
  210. package/docs/modules/typescript/shared/worker-daemon/typings.md +0 -132
  211. package/docs/overview.md +0 -191
  212. package/docs/release-notes/0.1.0.md +0 -189
  213. package/docs/release-notes/0.1.1.md +0 -46
  214. package/docs/release-notes/0.1.2.md +0 -38
  215. package/docs/release-notes/0.1.3.md +0 -42
  216. package/docs/release-notes/0.2.0.md +0 -147
  217. package/docs/release-notes/0.3.0.md +0 -89
  218. package/docs/release-notes/0.3.1.md +0 -121
  219. package/docs/release-notes/0.3.2.md +0 -64
  220. package/docs/release-notes/0.4.0.md +0 -80
  221. package/docs/release-notes/0.4.1.md +0 -149
  222. package/docs/release-notes/0.4.3.md +0 -60
  223. package/docs/release-notes/0.5.0.md +0 -41
  224. package/docs/release-notes/README.md +0 -16
package/dist/mod.cjs CHANGED
@@ -30,7 +30,7 @@ __export(mod_exports, {
30
30
  module.exports = __toCommonJS(mod_exports);
31
31
 
32
32
  // src/shared/version/constants/version.constant.ts
33
- var VERSION = "0.5.0";
33
+ var VERSION = "0.6.0";
34
34
 
35
35
  // src/shared/worker-client/classes/worker-client.class.ts
36
36
  var import_node_net = require("node:net");
@@ -237,7 +237,7 @@ var WorkerClient = class {
237
237
  * post-connect failure handlers.
238
238
  */
239
239
  async tryConnect() {
240
- return new Promise((resolve2, reject) => {
240
+ return new Promise((resolve3, reject) => {
241
241
  const sock = (0, import_node_net.connect)(this.socketPath, () => {
242
242
  sock.removeListener("error", reject);
243
243
  sock.setKeepAlive(true, 3e4);
@@ -258,7 +258,7 @@ var WorkerClient = class {
258
258
  this.socket = null;
259
259
  });
260
260
  this.socket = sock;
261
- resolve2();
261
+ resolve3();
262
262
  });
263
263
  sock.on("error", reject);
264
264
  sock.on("data", (chunk) => {
@@ -586,8 +586,8 @@ var WorkerClient = class {
586
586
  params: { ctx: this.contextId, ...params }
587
587
  };
588
588
  const timeoutMs = this.requestTimeoutMs;
589
- return new Promise((resolve2, reject) => {
590
- const call = { resolve: resolve2, reject };
589
+ return new Promise((resolve3, reject) => {
590
+ const call = { resolve: resolve3, reject };
591
591
  if (timeoutMs) {
592
592
  call.timer = setTimeout(() => {
593
593
  if (!this.pending.has(id)) return;
@@ -656,11 +656,6 @@ var WorkerClient = class {
656
656
  }
657
657
  };
658
658
 
659
- // src/shared/worker-client/functions/create-worker-client.function.ts
660
- var import_node_fs4 = require("node:fs");
661
- var import_node_path5 = require("node:path");
662
- var import_node_os4 = require("node:os");
663
-
664
659
  // src/shared/worker-client/functions/resolve-db-path.function.ts
665
660
  var import_node_fs2 = require("node:fs");
666
661
  var import_node_path2 = require("node:path");
@@ -691,6 +686,19 @@ async function computeContextId(absolutePath) {
691
686
 
692
687
  // src/shared/worker-client/functions/spawn-daemon.function.ts
693
688
  var import_node_child_process = require("node:child_process");
689
+
690
+ // src/shared/worker-client/functions/build-deno-permissions.function.ts
691
+ function buildDenoPermissions() {
692
+ return [
693
+ "--allow-read",
694
+ "--allow-write",
695
+ "--allow-env",
696
+ "--allow-run",
697
+ "--allow-sys"
698
+ ];
699
+ }
700
+
701
+ // src/shared/worker-client/functions/spawn-daemon.function.ts
694
702
  function spawnDaemon(contextPath, runtime, workerScript) {
695
703
  if (!workerScript) {
696
704
  const msg = "workerScript must be provided (resolve at entry point)";
@@ -700,7 +708,13 @@ function spawnDaemon(contextPath, runtime, workerScript) {
700
708
  const execPath = runtime === "deno" ? "deno" : process.execPath;
701
709
  const logLevelEnv = process.env["KBDB_LOG_LEVEL"];
702
710
  const logArgs = logLevelEnv ? ["--log-level", logLevelEnv] : [];
703
- const args = runtime === "deno" ? ["run", "--allow-all", workerScript, contextPath, ...logArgs] : [workerScript, contextPath, ...logArgs];
711
+ const args = runtime === "deno" ? [
712
+ "run",
713
+ ...buildDenoPermissions(),
714
+ workerScript,
715
+ contextPath,
716
+ ...logArgs
717
+ ] : [workerScript, contextPath, ...logArgs];
704
718
  log(
705
719
  "spawning daemon: " + execPath + " " + args.join(" "),
706
720
  0 /* DEBUG */
@@ -746,6 +760,25 @@ async function waitForDaemon(contextId, timeoutMs = DEFAULT_TIMEOUT_MS) {
746
760
  return false;
747
761
  }
748
762
 
763
+ // src/shared/worker-client/functions/read-crash-reason.function.ts
764
+ var import_node_fs4 = require("node:fs");
765
+ var import_node_path4 = require("node:path");
766
+ var import_node_os3 = require("node:os");
767
+ function readCrashReason(contextId) {
768
+ const crashPath = (0, import_node_path4.join)((0, import_node_os3.tmpdir)(), `kbdb-${contextId}.crash`);
769
+ if (!(0, import_node_fs4.existsSync)(crashPath)) {
770
+ return "daemon failed to start (no details available)";
771
+ }
772
+ try {
773
+ const raw = (0, import_node_fs4.readFileSync)(crashPath, "utf-8");
774
+ const crash = JSON.parse(raw);
775
+ (0, import_node_fs4.unlinkSync)(crashPath);
776
+ return crash.error ?? "unknown error (crash log empty)";
777
+ } catch {
778
+ return "daemon failed to start (crash log unreadable)";
779
+ }
780
+ }
781
+
749
782
  // src/shared/runtime/functions/detect-runtime.ts
750
783
  function detectRuntime() {
751
784
  if (typeof globalThis !== "undefined" && "Deno" in globalThis) {
@@ -754,13 +787,52 @@ function detectRuntime() {
754
787
  return "node";
755
788
  }
756
789
 
790
+ // src/shared/worker-client/functions/resolve-spawn-script.function.ts
791
+ var import_node_path6 = require("node:path");
792
+ var import_node_url = require("node:url");
793
+
794
+ // src/shared/dir-resolver/functions/join-path.function.ts
795
+ var import_node_path5 = require("node:path");
796
+ function isRemoteUrl(path) {
797
+ return path.startsWith("http://") || path.startsWith("https://");
798
+ }
799
+ function joinPath(base, ...segments) {
800
+ if (isRemoteUrl(base)) {
801
+ const trailing = base.endsWith("/") ? "" : "/";
802
+ return base + trailing + segments.join("/");
803
+ }
804
+ return (0, import_node_path5.join)(base, ...segments);
805
+ }
806
+
807
+ // src/shared/dir-resolver/functions/resolve-worker-script.function.ts
808
+ function resolveWorkerScript(scriptDir, runtime) {
809
+ if (runtime === "deno") {
810
+ return joinPath(scriptDir, "worker.ts");
811
+ }
812
+ return joinPath(scriptDir, "kbdb-worker.cjs");
813
+ }
814
+
815
+ // src/shared/worker-client/functions/resolve-spawn-script.function.ts
816
+ var import_meta = {};
817
+ function resolveSpawnScript(runtime) {
818
+ return resolveWorkerScript(resolveScriptDir2(runtime), runtime);
819
+ }
820
+ function resolveScriptDir2(runtime) {
821
+ if (typeof __dirname !== "undefined") return __dirname;
822
+ const thisDir = (0, import_node_path6.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
823
+ if (runtime === "deno") {
824
+ return (0, import_node_path6.resolve)(thisDir, "..", "..", "..");
825
+ }
826
+ return thisDir;
827
+ }
828
+
757
829
  // src/shared/platform/functions/get-ipc-path.function.ts
758
- var import_node_path4 = require("node:path");
830
+ var import_node_path7 = require("node:path");
759
831
 
760
832
  // src/shared/platform/functions/get-tmpdir.function.ts
761
- var import_node_os3 = require("node:os");
833
+ var import_node_os4 = require("node:os");
762
834
  function getTmpdir() {
763
- return (0, import_node_os3.tmpdir)();
835
+ return (0, import_node_os4.tmpdir)();
764
836
  }
765
837
 
766
838
  // src/shared/platform/functions/get-ipc-path.function.ts
@@ -768,7 +840,7 @@ function getIpcPath(ctx) {
768
840
  if (process.platform === "win32") {
769
841
  return `\\\\.\\pipe\\kbdb-${ctx}`;
770
842
  }
771
- return (0, import_node_path4.join)(getTmpdir(), `kbdb-${ctx}.sock`);
843
+ return (0, import_node_path7.join)(getTmpdir(), `kbdb-${ctx}.sock`);
772
844
  }
773
845
 
774
846
  // src/shared/worker-client/functions/create-worker-client.function.ts
@@ -786,7 +858,8 @@ async function createWorkerClient(options) {
786
858
  if (!daemon && options?.autoSpawn !== false) {
787
859
  const runtime = detectRuntime();
788
860
  log("auto-spawning daemon", 0 /* DEBUG */);
789
- spawnDaemon(dbPath, runtime, options?.workerScript);
861
+ const workerScript = resolveSpawnScript(runtime);
862
+ spawnDaemon(dbPath, runtime, workerScript);
790
863
  log("waiting for daemon after spawn", 0 /* DEBUG */);
791
864
  await waitForDaemon(contextId, options?.connectTimeoutMs);
792
865
  daemon = discoverDaemon(contextId);
@@ -805,20 +878,6 @@ async function createWorkerClient(options) {
805
878
  await client.connect();
806
879
  return client;
807
880
  }
808
- function readCrashReason(contextId) {
809
- const crashPath = (0, import_node_path5.join)((0, import_node_os4.tmpdir)(), `kbdb-${contextId}.crash`);
810
- if (!(0, import_node_fs4.existsSync)(crashPath)) {
811
- return "daemon failed to start (no details available)";
812
- }
813
- try {
814
- const raw = (0, import_node_fs4.readFileSync)(crashPath, "utf-8");
815
- const crash = JSON.parse(raw);
816
- (0, import_node_fs4.unlinkSync)(crashPath);
817
- return crash.error ?? "unknown error (crash log empty)";
818
- } catch {
819
- return "daemon failed to start (crash log unreadable)";
820
- }
821
- }
822
881
 
823
882
  // src/shared/worker-client/functions/get-or-create-client.function.ts
824
883
  var cache = /* @__PURE__ */ new Map();
package/dist/mod.cjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../mod.ts", "../src/shared/version/constants/version.constant.ts", "../src/shared/worker-client/classes/worker-client.class.ts", "../src/shared/worker-client/functions/discover-daemon.function.ts", "../src/shared/platform/functions/is-process-alive.function.ts", "../src/shared/log/typings/log-level.type.ts", "../src/shared/log/constants/log-colors.constant.ts", "../src/shared/log/constants/log-icons.constant.ts", "../src/shared/log/constants/log-defaults.constant.ts", "../src/shared/log/functions/write-stderr.function.ts", "../src/shared/log/functions/log.function.ts", "../src/shared/worker-client/functions/create-worker-client.function.ts", "../src/shared/worker-client/functions/resolve-db-path.function.ts", "../src/shared/hash/functions/compute-sha256.ts", "../src/shared/worker-client/functions/compute-context-id.function.ts", "../src/shared/worker-client/functions/spawn-daemon.function.ts", "../src/shared/worker-client/functions/wait-for-daemon.function.ts", "../src/shared/runtime/functions/detect-runtime.ts", "../src/shared/platform/functions/get-ipc-path.function.ts", "../src/shared/platform/functions/get-tmpdir.function.ts", "../src/shared/worker-client/functions/get-or-create-client.function.ts"],
4
- "sourcesContent": ["/**\n * @module\n *\n * File-based knowledge base database for AI agents.\n * Provides a programmatic API for indexing documents,\n * searching with ranked results, and recalling section\n * context at progressive depths.\n *\n * @example\n * ```ts\n * import { createWorkerClient } from '@dikolab/kbdb';\n *\n * const client = await createWorkerClient({\n * contextPath: '/path/to/.kbdb',\n * });\n *\n * const results = await client.search({\n * query: 'authentication',\n * limit: 10,\n * });\n *\n * console.log(results.items);\n * client.disconnect();\n * ```\n */\n\n/** Semantic version string matching `package.json`. */\nexport { version } from './src/shared/mod.ts';\n\n/** Creates a connected worker client for the given database. */\nexport { createWorkerClient } from './src/shared/worker-client/index.ts';\n\n/** Persistent client wrapping JSON-RPC calls to the daemon. */\nexport { WorkerClient } from './src/shared/worker-client/index.ts';\n\n/** Resolves a parent directory to the `.kbdb` path inside it. */\nexport { resolveDbPath } from './src/shared/worker-client/index.ts';\n\n/** Derives the 16-char hex context ID from an absolute path. */\nexport { computeContextId } from './src/shared/worker-client/index.ts';\n\n/** Returns a cached client or creates a new one for the given path. */\nexport { getOrCreateClient } from './src/shared/worker-client/index.ts';\n\n/** Options accepted by {@linkcode createWorkerClient}. */\nexport type { WorkerClientOptions } from './src/shared/worker-client/index.ts';\n\n/** Parameters for a search query. */\nexport type { SearchParams } from './src/shared/worker-client/index.ts';\n\n/** A single ranked result returned by search. */\nexport type { SearchResult } from './src/shared/worker-client/index.ts';\n\n/** Raw section record stored on disk. */\nexport type { Section } from './src/shared/worker-client/index.ts';\n\n/** Parameters for adding a new section. */\nexport type { AddSectionParams } from './src/shared/worker-client/index.ts';\n\n/** Database status snapshot returned by `client.status()`. */\nexport type { StatusResult } from './src/shared/worker-client/index.ts';\n", "/** Current package version, kept in sync with package.json. */\nexport const VERSION = '0.5.0';\n", "import { connect } from 'node:net';\nimport type { Socket } from 'node:net';\nimport { discoverDaemon } from '../functions/discover-daemon.function.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\nimport type { SearchParams } from '../typings/search-params.model.ts';\nimport type { PagedSearchResult } from '../typings/search-result.model.ts';\nimport type {\n AddSectionParams,\n Section,\n} from '../typings/section.model.ts';\nimport type { StatusResult } from '../typings/status-result.model.ts';\nimport type { AddSectionResult } from '../typings/add-section-result.model.ts';\nimport type { RemoveSectionResult } from '../typings/remove-section-result.model.ts';\nimport type { ContentResult } from '../typings/content-result.model.ts';\nimport type { IntegrityCheckResult } from '../typings/integrity-check-result.model.ts';\nimport type { GcResult } from '../typings/gc-result.model.ts';\nimport type { RebuildResult } from '../typings/rebuild-result.model.ts';\nimport type { MigrateResult } from '../typings/migrate-result.model.ts';\nimport type { VersionStatus } from '../typings/version-status.model.ts';\nimport type { SectionRecord } from '../../wasm-codec/functions/decode-section-records.function.ts';\nimport type { DocumentManifest } from '../../wasm-codec/functions/decode-document-manifest.function.ts';\nimport type {\n RecallParams,\n RecallResult,\n} from '../typings/recall-result.model.ts';\nimport type { ExportResult } from '../typings/export-result.model.ts';\nimport type { ImportResult } from '../typings/import-result.model.ts';\n\n/** Pending JSON-RPC call awaiting a response from the daemon. */\ninterface PendingCall {\n resolve: (v: unknown) => void;\n reject: (e: Error) => void;\n timer?: ReturnType<typeof setTimeout>;\n}\n\n/** Shape of a JSON-RPC 2.0 error object from the daemon. */\ninterface JsonRpcError {\n readonly code: number;\n readonly message: string;\n}\n\n/** Shape of a JSON-RPC 2.0 response from the daemon. */\ninterface JsonRpcResponse {\n readonly id: number;\n readonly result?: unknown;\n readonly error?: JsonRpcError;\n}\n\n/**\n * IPC client that communicates with the worker daemon over a Unix\n * domain socket (or Windows named pipe) using JSON-RPC 2.0 with\n * newline-delimited message framing.\n *\n * Call `connect()` before any other method and `disconnect()` when\n * done to release the underlying socket.\n */\nexport class WorkerClient {\n /** Underlying socket; `null` when not connected. */\n private socket: Socket | null = null;\n\n /** Monotonically increasing request ID counter. */\n private nextId = 1;\n\n /** Map of outstanding request IDs to their resolve/reject pairs. */\n private readonly pending = new Map<number, PendingCall>();\n\n /** Partial line buffer for split TCP/IPC frames. */\n private buffer = '';\n\n /**\n * @param socketPath - absolute path to the daemon's IPC socket\n * (or Windows named pipe path)\n * @param contextId - 16-character context identifier sent as\n * `ctx` in every JSON-RPC request\n * @param requestTimeoutMs - per-request timeout in ms\n * (0 or undefined disables the timeout)\n */\n constructor(\n private readonly socketPath: string,\n private readonly contextId: string,\n private readonly requestTimeoutMs?: number,\n ) {}\n\n /** Whether the underlying socket is connected. */\n get isConnected(): boolean {\n return this.socket !== null;\n }\n\n /**\n * Establishes the IPC connection to the worker daemon.\n *\n * Retries up to 5 times with exponential backoff on\n * transient errors (`ENOENT`, `ECONNREFUSED`).\n *\n * @throws {Error} if the connection cannot be established\n */\n async connect(): Promise<void> {\n log('connecting to ' + this.socketPath, LogLevel.DEBUG);\n const maxRetries = 5;\n let delay = 50;\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n await this.tryConnect();\n log('connected', LogLevel.DEBUG);\n return;\n } catch (err: unknown) {\n const code = (err as NodeJS.ErrnoException).code;\n const retriable =\n code === 'ENOENT' || code === 'ECONNREFUSED';\n if (!retriable || attempt === maxRetries) {\n throw err;\n }\n log(\n 'connect retry: attempt=' +\n attempt.toString() +\n ' code=' +\n code +\n ' delay=' +\n delay.toString() +\n 'ms',\n LogLevel.DEBUG,\n );\n await new Promise<void>((r) => setTimeout(r, delay));\n delay = Math.min(delay * 2, 1000);\n }\n }\n }\n\n /** Destroys the IPC socket and clears the connection state. */\n disconnect(): void {\n log('disconnecting client', LogLevel.DEBUG);\n if (this.socket) {\n this.socket.destroy();\n this.socket = null;\n }\n }\n\n /**\n * Kills the daemon process and disconnects the client.\n *\n * Discovers the daemon via PID file and sends `SIGTERM`.\n * Always disconnects the socket regardless of kill outcome.\n */\n killDaemon(): void {\n const info = discoverDaemon(this.contextId);\n log(\n 'killing daemon: pid=' +\n (info ? info.pid.toString() : 'unknown'),\n LogLevel.DEBUG,\n );\n if (info) {\n try {\n process.kill(info.pid, 'SIGTERM');\n } catch {\n // already dead\n }\n }\n this.disconnect();\n }\n\n /**\n * Single connection attempt with keepalive and\n * post-connect failure handlers.\n */\n private async tryConnect(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const sock = connect(this.socketPath, () => {\n sock.removeListener('error', reject);\n sock.setKeepAlive(true, 30_000);\n sock.on('error', (err: Error) => {\n log(\n 'socket error: code=' +\n ((err as NodeJS.ErrnoException).code ??\n err.message),\n LogLevel.DEBUG,\n );\n this.handleSocketFailure(err);\n });\n sock.on('close', () => {\n log('socket closed', LogLevel.DEBUG);\n if (this.pending.size > 0) {\n this.handleSocketFailure(\n new Error('connection closed'),\n );\n }\n this.socket = null;\n });\n this.socket = sock;\n resolve();\n });\n sock.on('error', reject);\n sock.on('data', (chunk: Buffer) => {\n this.handleData(chunk.toString());\n });\n });\n }\n\n /**\n * Rejects all pending calls and marks the client as\n * disconnected.\n */\n private handleSocketFailure(err: Error): void {\n log(\n 'socket failure: pending=' +\n this.pending.size.toString() +\n ' err=' +\n err.message,\n LogLevel.DEBUG,\n );\n const sock = this.socket;\n this.socket = null;\n for (const [id, call] of this.pending) {\n this.pending.delete(id);\n if (call.timer) clearTimeout(call.timer);\n call.reject(err);\n }\n if (sock) sock.destroy();\n }\n\n /**\n * Searches the knowledge base.\n *\n * @param params - query parameters including the search string\n * @returns paginated search results with metadata\n */\n async search(params: SearchParams): Promise<PagedSearchResult> {\n return this.call('search', {\n ...params,\n algo: params.algo,\n }) as Promise<PagedSearchResult>;\n }\n\n /**\n * Retrieves full content and context for one or more sections by\n * their knowledge-base identifiers.\n *\n * @param params - section identifier(s) and optional expansion depth\n * @returns a single `RecallResult` when `kbid` is provided without\n * `kbids`, or a `RecallResult[]` when `kbids` is provided\n */\n async recall(\n params: RecallParams,\n ): Promise<RecallResult | RecallResult[]> {\n return this.call('recall', params) as Promise<\n RecallResult | RecallResult[]\n >;\n }\n\n /**\n * Adds a new section to the knowledge base.\n *\n * @param params - section content and metadata\n * @returns the result including the assigned knowledge-base\n * identifier and indexing statistics\n */\n async addSection(\n params: AddSectionParams,\n ): Promise<AddSectionResult> {\n return this.call(\n 'addSection',\n params,\n ) as Promise<AddSectionResult>;\n }\n\n /**\n * Replaces an existing section's content and metadata.\n *\n * @param kbid - identifier of the section to update\n * @param params - new content and metadata\n * @returns the knowledge-base identifier of the updated section\n */\n async updateSection(\n kbid: string,\n params: AddSectionParams,\n ): Promise<string> {\n return this.call('updateSection', {\n kbid,\n ...params,\n }) as Promise<string>;\n }\n\n /**\n * Removes a section from the knowledge base.\n *\n * @param kbid - identifier of the section to remove\n * @returns removal result with `removed` flag and elapsed time\n */\n async removeSection(kbid: string): Promise<RemoveSectionResult> {\n return this.call('removeSection', {\n kbid,\n }) as Promise<RemoveSectionResult>;\n }\n\n /**\n * Retrieves multiple sections by their identifiers.\n *\n * @param kbids - list of knowledge-base identifiers to fetch\n * @returns sections in the order their IDs were requested\n */\n async readSections(kbids: string[]): Promise<Section[]> {\n return this.call('readSections', {\n kbids,\n }) as Promise<Section[]>;\n }\n\n /**\n * Groups a set of sections under a named document.\n *\n * @param title - human-readable document title\n * @param kbids - identifiers of the sections to group\n * @param docType - application-level document type tag; omit or\n * pass an empty string for untagged documents\n * @returns the assigned document identifier\n */\n async groupSections(\n title: string,\n kbids: string[],\n docType?: string,\n ): Promise<string> {\n const result = (await this.call('groupSections', {\n title,\n kbids,\n docType: docType ?? '',\n })) as { docid: string } | string;\n return typeof result === 'string' ? result : result.docid;\n }\n\n /**\n * Removes the document grouping for the given document.\n *\n * The sections themselves are not deleted; only the grouping\n * record is removed.\n *\n * @param docid - identifier of the document grouping to remove\n */\n async removeGrouping(docid: string): Promise<void> {\n await this.call('removeGrouping', { docid });\n }\n\n /**\n * Retrieves a full document record including its sections.\n *\n * @param docid - identifier of the document to retrieve\n * @returns the document record as returned by the daemon\n */\n async retrieveDocument(docid: string): Promise<unknown> {\n return this.call('retrieveDocument', { docid });\n }\n\n /**\n * Composes a rendered Markdown document from one or more kbid\n * or docid identifiers.\n *\n * @param ids - list of kbid or docid identifiers (may be mixed)\n * @returns composed Markdown result with character count\n */\n async content(ids: string[]): Promise<ContentResult> {\n return this.call('content', { ids }) as Promise<ContentResult>;\n }\n\n /**\n * Runs an integrity check on the knowledge-base database.\n *\n * @returns a report of all issues found; `ok` is `true` when\n * no errors were detected\n */\n async integrityCheck(): Promise<IntegrityCheckResult> {\n return this.call(\n 'integrityCheck',\n {},\n ) as Promise<IntegrityCheckResult>;\n }\n\n /**\n * Removes unreferenced sections from the database.\n *\n * @returns a report of sections removed and bytes freed\n */\n async gc(): Promise<GcResult> {\n return this.call('gc', {}) as Promise<GcResult>;\n }\n\n /**\n * Reconstructs all index files from section files and document\n * manifests on disk. Text and code sections are re-tokenized;\n * image sections are skipped.\n *\n * @returns a report of sections and terms re-indexed\n */\n async rebuildIndexes(): Promise<RebuildResult> {\n return this.call('rebuildIndexes', {}) as Promise<RebuildResult>;\n }\n\n /**\n * Invalidates the in-memory cache entry for a single section.\n *\n * @param kbid - identifier of the section to evict from cache\n */\n async invalidate(kbid: string): Promise<void> {\n await this.call('invalidate', { kbid });\n }\n\n /** Clears all entries from the daemon's in-memory cache. */\n async invalidateAll(): Promise<void> {\n await this.call('invalidateAll', {});\n }\n\n /**\n * Retrieves diagnostic status information from the daemon.\n *\n * @returns current initialization state and cache statistics\n */\n async status(): Promise<StatusResult> {\n return this.call('status', {}) as Promise<StatusResult>;\n }\n\n /**\n * Returns database metadata and status from the daemon,\n * including document count, section count, index size, and\n * cache statistics.\n *\n * @returns database metadata from the daemon's cached state\n */\n async dbStatus(): Promise<StatusResult> {\n return this.call('dbStatus', {}) as Promise<StatusResult>;\n }\n\n /**\n * Initialises a new `.kbdb` database directory at the given path\n * by sending an init request to the worker daemon.\n *\n * The daemon creates all required subdirectories and seed files via\n * the `worker_init_directory` WASM export.\n *\n * @param targetPath - absolute path to the directory that will\n * contain the new `.kbdb` database\n * @throws {Error} if the `.kbdb` directory already exists or the\n * daemon cannot create the layout\n */\n async initDirectory(targetPath: string): Promise<void> {\n await this.call('initDirectory', { targetPath });\n }\n\n /**\n * Runs all pending database migrations for the `.kbdb` directory\n * at the given path.\n *\n * Delegates to the `worker_migrate` WASM export on the daemon.\n * Each migration step updates `catalog.toml` on success, so\n * retrying after a partial failure is safe.\n *\n * @param targetPath - absolute path to the `.kbdb` database root\n * @returns migration report with old version, new version, and\n * number of migration steps applied\n */\n async migrateDatabase(targetPath: string): Promise<MigrateResult> {\n return this.call('migrateDatabase', {\n targetPath,\n }) as Promise<MigrateResult>;\n }\n\n /**\n * Checks the format version of the `.kbdb` database at the given\n * path against the version required by the current WASM engine.\n *\n * This is a read-only operation: it reads `catalog.toml` and\n * returns the compatibility status without making any changes.\n *\n * @param targetPath - absolute path to the `.kbdb` database root\n * @returns version compatibility report\n */\n async checkVersion(targetPath: string): Promise<VersionStatus> {\n return this.call('checkVersion', {\n targetPath,\n }) as Promise<VersionStatus>;\n }\n\n /**\n * Retrieves all sections whose type name matches the given string.\n *\n * @param sectionType - the application-level type name to filter by\n * @returns all section records with a matching type name\n */\n async listByType(sectionType: string): Promise<SectionRecord[]> {\n return this.call('listByType', {\n sectionType,\n }) as Promise<SectionRecord[]>;\n }\n\n /**\n * Retrieves all documents whose type name matches the given string.\n *\n * @param docType - the application-level document type to filter by\n * @returns all document manifests with a matching type name\n */\n async listDocumentsByType(\n docType: string,\n ): Promise<DocumentManifest[]> {\n return this.call('listDocumentsByType', {\n docType,\n }) as Promise<DocumentManifest[]>;\n }\n\n /**\n * Exports the database to a target directory on disk.\n *\n * Copies section files, document manifests, and `catalog.toml`\n * to `params.path`. Index files are not exported because they\n * are derivable from the section and document data.\n *\n * @param params - optional export parameters\n * @param params.path - target directory path; defaults to\n * `./kbdb-export/` when not provided\n * @returns export report with the resolved path and file counts\n */\n async export(params?: {\n path?: string;\n format?: string;\n }): Promise<ExportResult> {\n return this.call('export', {\n targetPath: params?.path || undefined,\n format: params?.format,\n }) as Promise<ExportResult>;\n }\n\n /**\n * Imports an exported database from the given path.\n *\n * @param params - source path and dry-run flag\n * @returns import report with counts and timing\n */\n async import(params: {\n from: string;\n dryRun: boolean;\n }): Promise<ImportResult> {\n return this.call('importDb', {\n sourcePath: params.from,\n dryRun: params.dryRun,\n }) as Promise<ImportResult>;\n }\n\n /**\n * Sends a JSON-RPC 2.0 request and awaits the response.\n *\n * @param method - the RPC method name\n * @param params - parameters to include in the request\n * @throws {Error} if not connected\n * @throws {Error} when the daemon returns an error response\n */\n private async call(\n method: string,\n params: unknown,\n ): Promise<unknown> {\n const socket = this.socket;\n if (!socket) {\n throw new Error('not connected');\n }\n\n const id = this.nextId++;\n log(\n 'call: method=' + method + ' id=' + id.toString(),\n LogLevel.DEBUG,\n );\n const request = {\n jsonrpc: '2.0',\n id,\n method,\n params: { ctx: this.contextId, ...(params as object) },\n };\n\n const timeoutMs = this.requestTimeoutMs;\n return new Promise<unknown>((resolve, reject) => {\n const call: PendingCall = { resolve, reject };\n if (timeoutMs) {\n call.timer = setTimeout(() => {\n if (!this.pending.has(id)) return;\n this.pending.delete(id);\n log(\n 'request timeout after ' + String(timeoutMs) + 'ms',\n LogLevel.WARNING,\n );\n const err = new Error(\n `request timeout after ${String(timeoutMs)}ms`,\n );\n (err as unknown as Record<string, unknown>).code =\n 'REQUEST_TIMEOUT';\n reject(err);\n }, timeoutMs);\n }\n this.pending.set(id, call);\n socket.write(JSON.stringify(request) + '\\n');\n });\n }\n\n /**\n * Processes incoming data from the socket, splitting on newlines\n * and dispatching complete JSON-RPC response objects.\n *\n * @param data - raw string chunk received from the socket\n */\n private handleData(data: string): void {\n this.buffer += data;\n const lines = this.buffer.split('\\n');\n this.buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n if (!line.trim()) continue;\n try {\n const response = JSON.parse(line) as JsonRpcResponse;\n const pending = this.pending.get(response.id);\n if (pending) {\n this.pending.delete(response.id);\n if (pending.timer) clearTimeout(pending.timer);\n if (response.error) {\n log(\n 'response error: id=' +\n response.id.toString() +\n ' code=' +\n response.error.code.toString(),\n LogLevel.DEBUG,\n );\n const err = new Error(response.error.message);\n (err as unknown as Record<string, unknown>).code =\n response.error.code;\n pending.reject(err);\n } else {\n log(\n 'response ok: id=' + response.id.toString(),\n LogLevel.DEBUG,\n );\n pending.resolve(response.result);\n }\n } else {\n log(\n 'unmatched response id=' + response.id.toString(),\n LogLevel.DEBUG,\n );\n }\n } catch (parseErr: unknown) {\n log(\n 'json parse error: ' + (parseErr as Error).message,\n LogLevel.DEBUG,\n );\n }\n }\n }\n}\n", "import { existsSync, readFileSync, unlinkSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { isProcessAlive } from '../../platform/functions/is-process-alive.function.ts';\nimport type { DaemonInfo } from '../typings/daemon-info.model.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\nexport type { DaemonInfo };\n\n/**\n * Discovers a running worker daemon for the given context.\n *\n * Reads the PID file at `<tmpdir>/kbdb-<contextId>.pid`. If the\n * file exists and the process is alive, returns its PID and the\n * expected socket path. If the file is stale (process dead or PID\n * unparseable), removes the PID file and returns `null`.\n *\n * @param contextId - the 16-character context identifier\n * @returns daemon location info, or `null` if no live daemon found\n */\nexport function discoverDaemon(contextId: string): DaemonInfo | null {\n log('discovering daemon for context: ' + contextId, LogLevel.DEBUG);\n const pidPath = join(tmpdir(), `kbdb-${contextId}.pid`);\n\n if (!existsSync(pidPath)) {\n log(\n 'no daemon PID file found for context: ' + contextId,\n LogLevel.DEBUG,\n );\n return null;\n }\n\n const pidStr = readFileSync(pidPath, 'utf-8').trim();\n const pid = parseInt(pidStr, 10);\n\n if (isNaN(pid) || !isProcessAlive(pid)) {\n log(\n 'daemon process not alive for context: ' + contextId,\n LogLevel.DEBUG,\n );\n try {\n unlinkSync(pidPath);\n } catch {\n // Stale PID file removal is best-effort\n }\n return null;\n }\n\n log('daemon found: pid=' + pid.toString(), LogLevel.DEBUG);\n const socketPath = join(tmpdir(), `kbdb-${contextId}.sock`);\n\n const crashPath = join(tmpdir(), `kbdb-${contextId}.crash`);\n try {\n unlinkSync(crashPath);\n } catch {\n // stale crash file removal is best-effort\n }\n\n return { pid, socketPath };\n}\n", "/**\n * Checks whether a process with the given PID is alive.\n *\n * Sends signal `0` to the process, which performs a permission\n * check without sending an actual signal. Returns `true` if the\n * process exists and is reachable, `false` otherwise.\n *\n * @param pid - the process identifier to probe\n */\nexport function isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n}\n", "/** Verbosity levels, ordered from most to least verbose. */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARNING = 2,\n ERROR = 3,\n}\n", "import { LogLevel } from '../typings/log-level.type.ts';\n\n/** ANSI escape sequence that resets all text formatting. */\nexport const ANSI_RESET = '\\x1b[0m';\n\n/** ANSI foreground color code applied to each log level's output. */\nexport const LOG_COLORS: Record<LogLevel, string> = {\n [LogLevel.DEBUG]: '\\x1b[37m',\n [LogLevel.INFO]: '\\x1b[36m',\n [LogLevel.WARNING]: '\\x1b[33m',\n [LogLevel.ERROR]: '\\x1b[91m',\n};\n", "import { LogLevel } from '../typings/log-level.type.ts';\n\n/** Single-character icon used as visual prefix for each log level. */\nexport const LOG_ICONS: Record<LogLevel, string> = {\n [LogLevel.DEBUG]: '\u25B8',\n [LogLevel.INFO]: '\u2139',\n [LogLevel.WARNING]: '\u26A0',\n [LogLevel.ERROR]: '\u2716',\n};\n", "import { LogLevel } from '../typings/log-level.type.ts';\n\n/** Default log level used when no CLI flag or env var is set. */\nexport const DEFAULT_LOG_LEVEL = LogLevel.ERROR;\n", "/**\n * Writes a string to the process standard error stream.\n *\n * Works on both Node.js (via `process.stderr.write`) and Deno\n * (via `Deno.stderr.writeSync`). Silently does nothing when\n * neither runtime API is available.\n *\n * @param message - the string to write to stderr\n */\nexport function writeStderr(message: string): void {\n const g = globalThis as Record<string, unknown>;\n const proc = g['process'] as\n | { stderr: { write: (s: string) => void } }\n | undefined;\n if (proc?.stderr) {\n proc.stderr.write(message);\n return;\n }\n const deno = g['Deno'] as\n | { stderr: { writeSync: (b: Uint8Array) => void } }\n | undefined;\n deno?.stderr.writeSync(new TextEncoder().encode(message));\n}\n", "import {\n ANSI_RESET,\n LOG_COLORS,\n} from '../constants/log-colors.constant.ts';\nimport { LOG_ICONS } from '../constants/log-icons.constant.ts';\nimport { DEFAULT_LOG_LEVEL } from '../constants/log-defaults.constant.ts';\nimport { LogLevel } from '../typings/log-level.type.ts';\nimport { writeStderr } from './write-stderr.function.ts';\n\n/** A function that receives a formatted log line. */\ntype OutputFn = (message: string) => void;\n\nlet currentLevel: LogLevel = DEFAULT_LOG_LEVEL;\n\nconst outputs: Record<LogLevel, OutputFn> = {\n [LogLevel.DEBUG]: writeStderr,\n [LogLevel.INFO]: writeStderr,\n [LogLevel.WARNING]: writeStderr,\n [LogLevel.ERROR]: writeStderr,\n};\n\n/**\n * Sets the minimum log level. Messages below this level are\n * suppressed. Used internally by `configureLog`.\n */\nexport function setLogLevel(level: LogLevel): void {\n currentLevel = level;\n}\n\n/**\n * Overrides the output function for a specific log level.\n * Used internally by `configureLog`.\n *\n * @param level - the log level whose output to replace\n * @param output - function that receives the formatted message\n */\nexport function setLogOutput(level: LogLevel, output: OutputFn): void {\n outputs[level] = output;\n}\n\n/**\n * Writes a formatted, colorized log message to the configured\n * output for the given level. Messages below the current level\n * are silently discarded.\n *\n * Format: `\\x1b[COLORm ICON [LEVEL_NAME] message\\x1b[0m\\n`\n *\n * @param message - the text to log\n * @param level - severity level; defaults to `LogLevel.ERROR`\n */\nexport function log(\n message: string,\n level: LogLevel = LogLevel.ERROR,\n): void {\n if (level < currentLevel) {\n return;\n }\n const color = LOG_COLORS[level];\n const icon = LOG_ICONS[level];\n const name = LogLevel[level];\n const line = `${color}${icon} [${name}] ${message}${ANSI_RESET}\\n`;\n outputs[level](line);\n}\n", "import { existsSync, readFileSync, unlinkSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { WorkerClient } from '../classes/worker-client.class.ts';\nimport { resolveDbPath } from './resolve-db-path.function.ts';\nimport { computeContextId } from './compute-context-id.function.ts';\nimport { discoverDaemon } from './discover-daemon.function.ts';\nimport { spawnDaemon } from './spawn-daemon.function.ts';\nimport { waitForDaemon } from './wait-for-daemon.function.ts';\nimport { detectRuntime } from '../../runtime/functions/detect-runtime.ts';\nimport { getIpcPath } from '../../platform/functions/get-ipc-path.function.ts';\nimport type { WorkerClientOptions } from '../typings/worker-client-options.interface.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/**\n * Creates and connects a `WorkerClient` to the worker daemon.\n *\n * Resolves the context path, derives a stable context identifier,\n * and checks whether a daemon is already running. If no daemon is\n * found and `autoSpawn` is not `false`, a new daemon process is\n * spawned and the factory waits for its PID file to appear before\n * connecting.\n *\n * @param options - optional configuration for path resolution,\n * auto-spawn behaviour, and connection timeout\n * @returns a connected `WorkerClient` ready to send requests\n * @throws {Error} if the `.kbdb` directory cannot be found\n * @throws {Error} if the socket connection cannot be established\n */\nexport async function createWorkerClient(\n options?: WorkerClientOptions,\n): Promise<WorkerClient> {\n const dbPath =\n options?.contextPath ?? resolveDbPath(options?.dbPath);\n const contextId = await computeContextId(dbPath);\n log('create-worker-client: contextId=' + contextId, LogLevel.DEBUG);\n const socketPath = getIpcPath(contextId);\n\n let daemon = discoverDaemon(contextId);\n\n if (daemon) {\n log('daemon found: pid=' + daemon.pid.toString(), LogLevel.DEBUG);\n } else {\n log('no daemon found', LogLevel.DEBUG);\n }\n\n if (!daemon && options?.autoSpawn !== false) {\n const runtime = detectRuntime();\n log('auto-spawning daemon', LogLevel.DEBUG);\n spawnDaemon(dbPath, runtime, options?.workerScript);\n log('waiting for daemon after spawn', LogLevel.DEBUG);\n await waitForDaemon(contextId, options?.connectTimeoutMs);\n daemon = discoverDaemon(contextId);\n }\n\n if (!daemon) {\n const msg = `kbdb worker daemon did not start: ${readCrashReason(contextId)}`;\n log(msg, LogLevel.ERROR);\n throw new Error(msg);\n }\n\n log('connecting to daemon', LogLevel.DEBUG);\n const client = new WorkerClient(\n socketPath,\n contextId,\n options?.requestTimeoutMs,\n );\n await client.connect();\n return client;\n}\n\nfunction readCrashReason(contextId: string): string {\n const crashPath = join(tmpdir(), `kbdb-${contextId}.crash`);\n if (!existsSync(crashPath)) {\n return 'daemon failed to start (no details available)';\n }\n try {\n const raw = readFileSync(crashPath, 'utf-8');\n const crash = JSON.parse(raw) as { error?: string };\n unlinkSync(crashPath);\n return crash.error ?? 'unknown error (crash log empty)';\n } catch {\n return 'daemon failed to start (crash log unreadable)';\n }\n}\n", "import { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/**\n * Resolves the absolute path to the `.kbdb` database directory.\n *\n * Searches for a `.kbdb` sub-directory inside `targetDir`. When\n * `targetDir` is omitted, `process.cwd()` is used as the base.\n *\n * @param targetDir - directory to search in; defaults to cwd\n * @throws {Error} if no `.kbdb` directory exists at the resolved\n * path\n */\nexport function resolveDbPath(targetDir?: string): string {\n const base = targetDir ? resolve(targetDir) : process.cwd();\n const dbPath = join(base, '.kbdb');\n if (!existsSync(dbPath)) {\n const msg = `database not found: ${dbPath}`;\n log(msg, LogLevel.ERROR);\n throw new Error(msg);\n }\n return dbPath;\n}\n", "/**\n * Computes the SHA-256 hash of a UTF-8 string.\n *\n * Uses the Web Crypto API (`crypto.subtle`), which is available\n * in both Deno and Node.js >= 20 without additional imports.\n *\n * @param input - the string to hash\n * @returns lowercase hex-encoded SHA-256 digest (64 characters)\n */\nexport async function computeSha256(input: string): Promise<string> {\n const data = new TextEncoder().encode(input);\n const hash = await crypto.subtle.digest('SHA-256', data);\n const bytes = new Uint8Array(hash);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n", "import { computeSha256 } from '../../hash/functions/compute-sha256.ts';\n\n/**\n * Computes a short context identifier for an absolute path.\n *\n * Hashes the path with SHA-256 and returns the first 16 hex\n * characters. The result is stable for the same input and unique\n * enough to avoid accidental collisions across typical path sets.\n *\n * @param absolutePath - the absolute filesystem path to identify\n * @returns a 16-character lowercase hex string\n */\nexport async function computeContextId(\n absolutePath: string,\n): Promise<string> {\n const hash = await computeSha256(absolutePath);\n return hash.slice(0, 16);\n}\n", "import { spawn } from 'node:child_process';\nimport type { Runtime } from '../../runtime/typings/runtime.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/**\n * Spawns a detached worker daemon process for the given context.\n *\n * @param contextPath - absolute path to the context directory the\n * daemon should serve\n * @param runtime - the current JavaScript runtime environment\n * @param workerScript - absolute path to the worker daemon script,\n * resolved at the entry point by `resolveWorkerScript`\n */\nexport function spawnDaemon(\n contextPath: string,\n runtime: Runtime,\n workerScript?: string,\n): void {\n if (!workerScript) {\n const msg =\n 'workerScript must be provided' + ' (resolve at entry point)';\n log(msg, LogLevel.ERROR);\n throw new Error(msg);\n }\n const execPath = runtime === 'deno' ? 'deno' : process.execPath;\n\n const logLevelEnv = process.env['KBDB_LOG_LEVEL'];\n const logArgs = logLevelEnv ? ['--log-level', logLevelEnv] : [];\n\n const args =\n runtime === 'deno'\n ? ['run', '--allow-all', workerScript, contextPath, ...logArgs]\n : [workerScript, contextPath, ...logArgs];\n\n log(\n 'spawning daemon: ' + execPath + ' ' + args.join(' '),\n LogLevel.DEBUG,\n );\n const child = spawn(execPath, args, {\n detached: true,\n stdio: 'ignore',\n });\n child.unref();\n}\n", "import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/** Default maximum wait time for the daemon PID file to appear. */\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\n/** Polling interval in milliseconds between existence checks. */\nconst POLL_INTERVAL_MS = 100;\n\n/**\n * Waits for the worker daemon's PID file to appear on disk.\n *\n * Polls every 100 ms until the PID file at\n * `<tmpdir>/kbdb-<contextId>.pid` exists or the timeout elapses.\n *\n * @param contextId - the 16-character context identifier\n * @param timeoutMs - maximum wait time in milliseconds; defaults\n * to 10 000 ms\n * @returns `true` if the PID file appeared before the timeout,\n * `false` otherwise\n */\nexport async function waitForDaemon(\n contextId: string,\n timeoutMs: number = DEFAULT_TIMEOUT_MS,\n): Promise<boolean> {\n log('waiting for daemon: contextId=' + contextId, LogLevel.DEBUG);\n const pidPath = join(tmpdir(), `kbdb-${contextId}.pid`);\n const start = Date.now();\n let iteration = 0;\n while (Date.now() - start < timeoutMs) {\n if (existsSync(pidPath)) {\n log('daemon PID file appeared', LogLevel.DEBUG);\n return true;\n }\n iteration++;\n if (iteration % 10 === 0) {\n const elapsed = Date.now() - start;\n log(\n 'still waiting for daemon: elapsed=' +\n elapsed.toString() +\n 'ms',\n LogLevel.DEBUG,\n );\n }\n await new Promise<void>((r) => setTimeout(r, POLL_INTERVAL_MS));\n }\n const elapsed = Date.now() - start;\n log(\n 'timed out waiting for daemon: elapsed=' +\n elapsed.toString() +\n 'ms',\n LogLevel.DEBUG,\n );\n return false;\n}\n", "import type { Runtime } from '../typings/runtime.ts';\n\n/**\n * Detects the current JavaScript runtime environment.\n *\n * Returns `'deno'` when the global `Deno` object is present,\n * otherwise returns `'node'`.\n */\nexport function detectRuntime(): Runtime {\n if (typeof globalThis !== 'undefined' && 'Deno' in globalThis) {\n return 'deno';\n }\n return 'node';\n}\n", "import { join } from 'node:path';\nimport { getTmpdir } from './get-tmpdir.function.ts';\n\n/**\n * Returns the platform-appropriate IPC socket path for a given\n * context identifier.\n *\n * On Windows, returns a named pipe path (`\\\\.\\pipe\\kbdb-<ctx>`).\n * On POSIX systems, returns a Unix domain socket path under the\n * system temp directory (`<tmpdir>/kbdb-<ctx>.sock`).\n *\n * @param ctx - unique context identifier embedded in the path\n */\nexport function getIpcPath(ctx: string): string {\n if (process.platform === 'win32') {\n return `\\\\\\\\.\\\\pipe\\\\kbdb-${ctx}`;\n }\n return join(getTmpdir(), `kbdb-${ctx}.sock`);\n}\n", "import { tmpdir } from 'node:os';\n\n/**\n * Returns the operating system's default temporary directory path.\n */\nexport function getTmpdir(): string {\n return tmpdir();\n}\n", "import { createWorkerClient } from './create-worker-client.function.ts';\nimport type { WorkerClient } from '../classes/worker-client.class.ts';\nimport type { WorkerClientOptions } from '../typings/worker-client-options.interface.ts';\nimport { resolveDbPath } from './resolve-db-path.function.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/** Cache of connected clients keyed by database path. */\nconst cache = new Map<string, WorkerClient>();\n\n/**\n * Returns a cached `WorkerClient` for the given context\n * path, or creates and caches a new one if the cached\n * client is disconnected or absent.\n *\n * Intended for library consumers and the MCP server. CLI\n * one-shots should use `createWorkerClient()` directly.\n *\n * @param options - optional configuration forwarded to\n * `createWorkerClient`\n * @returns a connected `WorkerClient`\n */\nexport async function getOrCreateClient(\n options?: WorkerClientOptions,\n): Promise<WorkerClient> {\n log('getOrCreateClient called', LogLevel.DEBUG);\n const dbPath =\n options?.contextPath ?? resolveDbPath(options?.dbPath);\n const cached = cache.get(dbPath);\n if (cached?.isConnected) {\n log('returning cached client for: ' + dbPath, LogLevel.DEBUG);\n return cached;\n }\n cache.delete(dbPath);\n log('creating new client for: ' + dbPath, LogLevel.DEBUG);\n const client = await createWorkerClient(options);\n cache.set(dbPath, client);\n return client;\n}\n\n/**\n * Clears the internal client cache. Intended for tests\n * that need isolation between runs.\n */\nexport function clearClientCache(): void {\n for (const [key, client] of cache) {\n client.disconnect();\n cache.delete(key);\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,UAAU;;;ACDvB,sBAAwB;;;ACAxB,qBAAqD;AACrD,uBAAqB;AACrB,qBAAuB;;;ACOhB,SAAS,eAAe,KAAsB;AAClD,MAAI;AACD,YAAQ,KAAK,KAAK,CAAC;AACnB,WAAO;AAAA,EACV,QAAQ;AACL,WAAO;AAAA,EACV;AACH;;;ACfO,IAAK,WAAL,kBAAKA,cAAL;AACJ,EAAAA,oBAAA,WAAQ,KAAR;AACA,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,aAAU,KAAV;AACA,EAAAA,oBAAA,WAAQ,KAAR;AAJS,SAAAA;AAAA,GAAA;;;ACEL,IAAM,aAAa;AAGnB,IAAM,aAAuC;AAAA,EACjD,cAAe,GAAG;AAAA,EAClB,aAAc,GAAG;AAAA,EACjB,gBAAiB,GAAG;AAAA,EACpB,cAAe,GAAG;AACrB;;;ACRO,IAAM,YAAsC;AAAA,EAChD,cAAe,GAAG;AAAA,EAClB,aAAc,GAAG;AAAA,EACjB,gBAAiB,GAAG;AAAA,EACpB,cAAe,GAAG;AACrB;;;ACLO,IAAM;;;ACMN,SAAS,YAAY,SAAuB;AAChD,QAAM,IAAI;AACV,QAAM,OAAO,EAAE,SAAS;AAGxB,MAAI,MAAM,QAAQ;AACf,SAAK,OAAO,MAAM,OAAO;AACzB;AAAA,EACH;AACA,QAAM,OAAO,EAAE,MAAM;AAGrB,QAAM,OAAO,UAAU,IAAI,YAAY,EAAE,OAAO,OAAO,CAAC;AAC3D;;;ACVA,IAAI,eAAyB;AAE7B,IAAM,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M,SAAS,IAAI;AAAA,IAChB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACZ;AACA,QAAM,OAAO,QAAQ;AACrB,SAAO;AACV;AAEA,SAAS,gBAAgB,WAA2B;AACjD,QAAM,gBAAY,4BAAK,wBAAO,GAAG,QAAQ,SAAS,QAAQ;AAC1D,MAAI,KAAC,4BAAW,SAAS,GAAG;AACzB,WAAO;AAAA,EACV;AACA,MAAI;AACD,UAAM,UAAM,8BAAa,WAAW,OAAO;AAC3C,UAAM,QAAQ,KAAK,MAAM,GAAG;AAC5B,oCAAW,SAAS;AACpB,WAAO,MAAM,SAAS;AAAA,EACzB,QAAQ;AACL,WAAO;AAAA,EACV;AACH;;;AS7EA,IAAM,QAAQ,oBAAI,IAA0B;AAc5C,eAAsB,kBACnB,SACsB;AACtB,MAAI,yCAA0C;AAC9C,QAAM,SACH,SAAS,eAAe,cAAc,SAAS,MAAM;AACxD,QAAM,SAAS,MAAM,IAAI,MAAM;AAC/B,MAAI,QAAQ,aAAa;AACtB,QAAI,kCAAkC,qBAAsB;AAC5D,WAAO;AAAA,EACV;AACA,QAAM,OAAO,MAAM;AACnB,MAAI,8BAA8B,qBAAsB;AACxD,QAAM,SAAS,MAAM,mBAAmB,OAAO;AAC/C,QAAM,IAAI,QAAQ,MAAM;AACxB,SAAO;AACV;",
6
- "names": ["LogLevel", "resolve", "import_node_fs", "import_node_path", "import_node_os", "import_node_fs", "import_node_path", "import_node_fs", "import_node_path", "import_node_os", "elapsed", "import_node_path", "import_node_os"]
3
+ "sources": ["../mod.ts", "../src/shared/version/constants/version.constant.ts", "../src/shared/worker-client/classes/worker-client.class.ts", "../src/shared/worker-client/functions/discover-daemon.function.ts", "../src/shared/platform/functions/is-process-alive.function.ts", "../src/shared/log/typings/log-level.type.ts", "../src/shared/log/constants/log-colors.constant.ts", "../src/shared/log/constants/log-icons.constant.ts", "../src/shared/log/constants/log-defaults.constant.ts", "../src/shared/log/functions/write-stderr.function.ts", "../src/shared/log/functions/log.function.ts", "../src/shared/worker-client/functions/resolve-db-path.function.ts", "../src/shared/hash/functions/compute-sha256.ts", "../src/shared/worker-client/functions/compute-context-id.function.ts", "../src/shared/worker-client/functions/spawn-daemon.function.ts", "../src/shared/worker-client/functions/build-deno-permissions.function.ts", "../src/shared/worker-client/functions/wait-for-daemon.function.ts", "../src/shared/worker-client/functions/read-crash-reason.function.ts", "../src/shared/runtime/functions/detect-runtime.ts", "../src/shared/worker-client/functions/resolve-spawn-script.function.ts", "../src/shared/dir-resolver/functions/join-path.function.ts", "../src/shared/dir-resolver/functions/resolve-worker-script.function.ts", "../src/shared/platform/functions/get-ipc-path.function.ts", "../src/shared/platform/functions/get-tmpdir.function.ts", "../src/shared/worker-client/functions/create-worker-client.function.ts", "../src/shared/worker-client/functions/get-or-create-client.function.ts"],
4
+ "sourcesContent": ["/**\n * @module\n *\n * File-based knowledge base database for AI agents.\n * Provides a programmatic API for indexing documents,\n * searching with ranked results, and recalling section\n * context at progressive depths.\n *\n * @example\n * ```ts\n * import { createWorkerClient } from '@dikolab/kbdb';\n *\n * const client = await createWorkerClient({\n * contextPath: '/path/to/.kbdb',\n * });\n *\n * const results = await client.search({\n * query: 'authentication',\n * limit: 10,\n * });\n *\n * console.log(results.items);\n * client.disconnect();\n * ```\n */\n\n/** Semantic version string matching `package.json`. */\nexport { version } from './src/shared/mod.ts';\n\n/** Creates a connected worker client for the given database. */\nexport { createWorkerClient } from './src/shared/worker-client/index.ts';\n\n/** Persistent client wrapping JSON-RPC calls to the daemon. */\nexport { WorkerClient } from './src/shared/worker-client/index.ts';\n\n/** Resolves a parent directory to the `.kbdb` path inside it. */\nexport { resolveDbPath } from './src/shared/worker-client/index.ts';\n\n/** Derives the 16-char hex context ID from an absolute path. */\nexport { computeContextId } from './src/shared/worker-client/index.ts';\n\n/** Returns a cached client or creates a new one for the given path. */\nexport { getOrCreateClient } from './src/shared/worker-client/index.ts';\n\n/** Options accepted by {@linkcode createWorkerClient}. */\nexport type { WorkerClientOptions } from './src/shared/worker-client/index.ts';\n\n/** Parameters for a search query. */\nexport type { SearchParams } from './src/shared/worker-client/index.ts';\n\n/** A single ranked result returned by search. */\nexport type { SearchResult } from './src/shared/worker-client/index.ts';\n\n/** Raw section record stored on disk. */\nexport type { Section } from './src/shared/worker-client/index.ts';\n\n/** Parameters for adding a new section. */\nexport type { AddSectionParams } from './src/shared/worker-client/index.ts';\n\n/** Database status snapshot returned by `client.status()`. */\nexport type { StatusResult } from './src/shared/worker-client/index.ts';\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\n/** Current package version, kept in sync with package.json. */\nexport const VERSION = '0.6.0';\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { connect } from 'node:net';\nimport type { Socket } from 'node:net';\nimport { discoverDaemon } from '../functions/discover-daemon.function.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\nimport type { SearchParams } from '../typings/search-params.model.ts';\nimport type { PagedSearchResult } from '../typings/search-result.model.ts';\nimport type {\n AddSectionParams,\n Section,\n} from '../typings/section.model.ts';\nimport type { StatusResult } from '../typings/status-result.model.ts';\nimport type { AddSectionResult } from '../typings/add-section-result.model.ts';\nimport type { RemoveSectionResult } from '../typings/remove-section-result.model.ts';\nimport type { ContentResult } from '../typings/content-result.model.ts';\nimport type { IntegrityCheckResult } from '../typings/integrity-check-result.model.ts';\nimport type { GcResult } from '../typings/gc-result.model.ts';\nimport type { RebuildResult } from '../typings/rebuild-result.model.ts';\nimport type { MigrateResult } from '../typings/migrate-result.model.ts';\nimport type { VersionStatus } from '../typings/version-status.model.ts';\nimport type { SectionRecord } from '../../wasm-codec/functions/decode-section-records.function.ts';\nimport type { DocumentManifest } from '../../wasm-codec/functions/decode-document-manifest.function.ts';\nimport type {\n RecallParams,\n RecallResult,\n} from '../typings/recall-result.model.ts';\nimport type { ExportResult } from '../typings/export-result.model.ts';\nimport type { ImportResult } from '../typings/import-result.model.ts';\n\n/** Pending JSON-RPC call awaiting a response from the daemon. */\ninterface PendingCall {\n resolve: (v: unknown) => void;\n reject: (e: Error) => void;\n timer?: ReturnType<typeof setTimeout>;\n}\n\n/** Shape of a JSON-RPC 2.0 error object from the daemon. */\ninterface JsonRpcError {\n readonly code: number;\n readonly message: string;\n}\n\n/** Shape of a JSON-RPC 2.0 response from the daemon. */\ninterface JsonRpcResponse {\n readonly id: number;\n readonly result?: unknown;\n readonly error?: JsonRpcError;\n}\n\n/**\n * IPC client that communicates with the worker daemon over a Unix\n * domain socket (or Windows named pipe) using JSON-RPC 2.0 with\n * newline-delimited message framing.\n *\n * Call `connect()` before any other method and `disconnect()` when\n * done to release the underlying socket.\n */\nexport class WorkerClient {\n /** Underlying socket; `null` when not connected. */\n private socket: Socket | null = null;\n\n /** Monotonically increasing request ID counter. */\n private nextId = 1;\n\n /** Map of outstanding request IDs to their resolve/reject pairs. */\n private readonly pending = new Map<number, PendingCall>();\n\n /** Partial line buffer for split TCP/IPC frames. */\n private buffer = '';\n\n /**\n * @param socketPath - absolute path to the daemon's IPC socket\n * (or Windows named pipe path)\n * @param contextId - 16-character context identifier sent as\n * `ctx` in every JSON-RPC request\n * @param requestTimeoutMs - per-request timeout in ms\n * (0 or undefined disables the timeout)\n */\n constructor(\n private readonly socketPath: string,\n private readonly contextId: string,\n private readonly requestTimeoutMs?: number,\n ) {}\n\n /** Whether the underlying socket is connected. */\n get isConnected(): boolean {\n return this.socket !== null;\n }\n\n /**\n * Establishes the IPC connection to the worker daemon.\n *\n * Retries up to 5 times with exponential backoff on\n * transient errors (`ENOENT`, `ECONNREFUSED`).\n *\n * @throws {Error} if the connection cannot be established\n */\n async connect(): Promise<void> {\n log('connecting to ' + this.socketPath, LogLevel.DEBUG);\n const maxRetries = 5;\n let delay = 50;\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n await this.tryConnect();\n log('connected', LogLevel.DEBUG);\n return;\n } catch (err: unknown) {\n const code = (err as NodeJS.ErrnoException).code;\n const retriable =\n code === 'ENOENT' || code === 'ECONNREFUSED';\n if (!retriable || attempt === maxRetries) {\n throw err;\n }\n log(\n 'connect retry: attempt=' +\n attempt.toString() +\n ' code=' +\n code +\n ' delay=' +\n delay.toString() +\n 'ms',\n LogLevel.DEBUG,\n );\n await new Promise<void>((r) => setTimeout(r, delay));\n delay = Math.min(delay * 2, 1000);\n }\n }\n }\n\n /** Destroys the IPC socket and clears the connection state. */\n disconnect(): void {\n log('disconnecting client', LogLevel.DEBUG);\n if (this.socket) {\n this.socket.destroy();\n this.socket = null;\n }\n }\n\n /**\n * Kills the daemon process and disconnects the client.\n *\n * Discovers the daemon via PID file and sends `SIGTERM`.\n * Always disconnects the socket regardless of kill outcome.\n */\n killDaemon(): void {\n const info = discoverDaemon(this.contextId);\n log(\n 'killing daemon: pid=' +\n (info ? info.pid.toString() : 'unknown'),\n LogLevel.DEBUG,\n );\n if (info) {\n try {\n process.kill(info.pid, 'SIGTERM');\n } catch {\n // already dead\n }\n }\n this.disconnect();\n }\n\n /**\n * Single connection attempt with keepalive and\n * post-connect failure handlers.\n */\n private async tryConnect(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const sock = connect(this.socketPath, () => {\n sock.removeListener('error', reject);\n sock.setKeepAlive(true, 30_000);\n sock.on('error', (err: Error) => {\n log(\n 'socket error: code=' +\n ((err as NodeJS.ErrnoException).code ??\n err.message),\n LogLevel.DEBUG,\n );\n this.handleSocketFailure(err);\n });\n sock.on('close', () => {\n log('socket closed', LogLevel.DEBUG);\n if (this.pending.size > 0) {\n this.handleSocketFailure(\n new Error('connection closed'),\n );\n }\n this.socket = null;\n });\n this.socket = sock;\n resolve();\n });\n sock.on('error', reject);\n sock.on('data', (chunk: Buffer) => {\n this.handleData(chunk.toString());\n });\n });\n }\n\n /**\n * Rejects all pending calls and marks the client as\n * disconnected.\n */\n private handleSocketFailure(err: Error): void {\n log(\n 'socket failure: pending=' +\n this.pending.size.toString() +\n ' err=' +\n err.message,\n LogLevel.DEBUG,\n );\n const sock = this.socket;\n this.socket = null;\n for (const [id, call] of this.pending) {\n this.pending.delete(id);\n if (call.timer) clearTimeout(call.timer);\n call.reject(err);\n }\n if (sock) sock.destroy();\n }\n\n /**\n * Searches the knowledge base.\n *\n * @param params - query parameters including the search string\n * @returns paginated search results with metadata\n */\n async search(params: SearchParams): Promise<PagedSearchResult> {\n return this.call('search', {\n ...params,\n algo: params.algo,\n }) as Promise<PagedSearchResult>;\n }\n\n /**\n * Retrieves full content and context for one or more sections by\n * their knowledge-base identifiers.\n *\n * @param params - section identifier(s) and optional expansion depth\n * @returns a single `RecallResult` when `kbid` is provided without\n * `kbids`, or a `RecallResult[]` when `kbids` is provided\n */\n async recall(\n params: RecallParams,\n ): Promise<RecallResult | RecallResult[]> {\n return this.call('recall', params) as Promise<\n RecallResult | RecallResult[]\n >;\n }\n\n /**\n * Adds a new section to the knowledge base.\n *\n * @param params - section content and metadata\n * @returns the result including the assigned knowledge-base\n * identifier and indexing statistics\n */\n async addSection(\n params: AddSectionParams,\n ): Promise<AddSectionResult> {\n return this.call(\n 'addSection',\n params,\n ) as Promise<AddSectionResult>;\n }\n\n /**\n * Replaces an existing section's content and metadata.\n *\n * @param kbid - identifier of the section to update\n * @param params - new content and metadata\n * @returns the knowledge-base identifier of the updated section\n */\n async updateSection(\n kbid: string,\n params: AddSectionParams,\n ): Promise<string> {\n return this.call('updateSection', {\n kbid,\n ...params,\n }) as Promise<string>;\n }\n\n /**\n * Removes a section from the knowledge base.\n *\n * @param kbid - identifier of the section to remove\n * @returns removal result with `removed` flag and elapsed time\n */\n async removeSection(kbid: string): Promise<RemoveSectionResult> {\n return this.call('removeSection', {\n kbid,\n }) as Promise<RemoveSectionResult>;\n }\n\n /**\n * Retrieves multiple sections by their identifiers.\n *\n * @param kbids - list of knowledge-base identifiers to fetch\n * @returns sections in the order their IDs were requested\n */\n async readSections(kbids: string[]): Promise<Section[]> {\n return this.call('readSections', {\n kbids,\n }) as Promise<Section[]>;\n }\n\n /**\n * Groups a set of sections under a named document.\n *\n * @param title - human-readable document title\n * @param kbids - identifiers of the sections to group\n * @param docType - application-level document type tag; omit or\n * pass an empty string for untagged documents\n * @returns the assigned document identifier\n */\n async groupSections(\n title: string,\n kbids: string[],\n docType?: string,\n ): Promise<string> {\n const result = (await this.call('groupSections', {\n title,\n kbids,\n docType: docType ?? '',\n })) as { docid: string } | string;\n return typeof result === 'string' ? result : result.docid;\n }\n\n /**\n * Removes the document grouping for the given document.\n *\n * The sections themselves are not deleted; only the grouping\n * record is removed.\n *\n * @param docid - identifier of the document grouping to remove\n */\n async removeGrouping(docid: string): Promise<void> {\n await this.call('removeGrouping', { docid });\n }\n\n /**\n * Retrieves a full document record including its sections.\n *\n * @param docid - identifier of the document to retrieve\n * @returns the document record as returned by the daemon\n */\n async retrieveDocument(docid: string): Promise<unknown> {\n return this.call('retrieveDocument', { docid });\n }\n\n /**\n * Composes a rendered Markdown document from one or more kbid\n * or docid identifiers.\n *\n * @param ids - list of kbid or docid identifiers (may be mixed)\n * @returns composed Markdown result with character count\n */\n async content(ids: string[]): Promise<ContentResult> {\n return this.call('content', { ids }) as Promise<ContentResult>;\n }\n\n /**\n * Runs an integrity check on the knowledge-base database.\n *\n * @returns a report of all issues found; `ok` is `true` when\n * no errors were detected\n */\n async integrityCheck(): Promise<IntegrityCheckResult> {\n return this.call(\n 'integrityCheck',\n {},\n ) as Promise<IntegrityCheckResult>;\n }\n\n /**\n * Removes unreferenced sections from the database.\n *\n * @returns a report of sections removed and bytes freed\n */\n async gc(): Promise<GcResult> {\n return this.call('gc', {}) as Promise<GcResult>;\n }\n\n /**\n * Reconstructs all index files from section files and document\n * manifests on disk. Text and code sections are re-tokenized;\n * image sections are skipped.\n *\n * @returns a report of sections and terms re-indexed\n */\n async rebuildIndexes(): Promise<RebuildResult> {\n return this.call('rebuildIndexes', {}) as Promise<RebuildResult>;\n }\n\n /**\n * Invalidates the in-memory cache entry for a single section.\n *\n * @param kbid - identifier of the section to evict from cache\n */\n async invalidate(kbid: string): Promise<void> {\n await this.call('invalidate', { kbid });\n }\n\n /** Clears all entries from the daemon's in-memory cache. */\n async invalidateAll(): Promise<void> {\n await this.call('invalidateAll', {});\n }\n\n /**\n * Retrieves diagnostic status information from the daemon.\n *\n * @returns current initialization state and cache statistics\n */\n async status(): Promise<StatusResult> {\n return this.call('status', {}) as Promise<StatusResult>;\n }\n\n /**\n * Returns database metadata and status from the daemon,\n * including document count, section count, index size, and\n * cache statistics.\n *\n * @returns database metadata from the daemon's cached state\n */\n async dbStatus(): Promise<StatusResult> {\n return this.call('dbStatus', {}) as Promise<StatusResult>;\n }\n\n /**\n * Initialises a new `.kbdb` database directory at the given path\n * by sending an init request to the worker daemon.\n *\n * The daemon creates all required subdirectories and seed files via\n * the `worker_init_directory` WASM export.\n *\n * @param targetPath - absolute path to the directory that will\n * contain the new `.kbdb` database\n * @throws {Error} if the `.kbdb` directory already exists or the\n * daemon cannot create the layout\n */\n async initDirectory(targetPath: string): Promise<void> {\n await this.call('initDirectory', { targetPath });\n }\n\n /**\n * Runs all pending database migrations for the `.kbdb` directory\n * at the given path.\n *\n * Delegates to the `worker_migrate` WASM export on the daemon.\n * Each migration step updates `catalog.toml` on success, so\n * retrying after a partial failure is safe.\n *\n * @param targetPath - absolute path to the `.kbdb` database root\n * @returns migration report with old version, new version, and\n * number of migration steps applied\n */\n async migrateDatabase(targetPath: string): Promise<MigrateResult> {\n return this.call('migrateDatabase', {\n targetPath,\n }) as Promise<MigrateResult>;\n }\n\n /**\n * Checks the format version of the `.kbdb` database at the given\n * path against the version required by the current WASM engine.\n *\n * This is a read-only operation: it reads `catalog.toml` and\n * returns the compatibility status without making any changes.\n *\n * @param targetPath - absolute path to the `.kbdb` database root\n * @returns version compatibility report\n */\n async checkVersion(targetPath: string): Promise<VersionStatus> {\n return this.call('checkVersion', {\n targetPath,\n }) as Promise<VersionStatus>;\n }\n\n /**\n * Retrieves all sections whose type name matches the given string.\n *\n * @param sectionType - the application-level type name to filter by\n * @returns all section records with a matching type name\n */\n async listByType(sectionType: string): Promise<SectionRecord[]> {\n return this.call('listByType', {\n sectionType,\n }) as Promise<SectionRecord[]>;\n }\n\n /**\n * Retrieves all documents whose type name matches the given string.\n *\n * @param docType - the application-level document type to filter by\n * @returns all document manifests with a matching type name\n */\n async listDocumentsByType(\n docType: string,\n ): Promise<DocumentManifest[]> {\n return this.call('listDocumentsByType', {\n docType,\n }) as Promise<DocumentManifest[]>;\n }\n\n /**\n * Exports the database to a target directory on disk.\n *\n * Copies section files, document manifests, and `catalog.toml`\n * to `params.path`. Index files are not exported because they\n * are derivable from the section and document data.\n *\n * @param params - optional export parameters\n * @param params.path - target directory path; defaults to\n * `./kbdb-export/` when not provided\n * @returns export report with the resolved path and file counts\n */\n async export(params?: {\n path?: string;\n format?: string;\n }): Promise<ExportResult> {\n return this.call('export', {\n targetPath: params?.path || undefined,\n format: params?.format,\n }) as Promise<ExportResult>;\n }\n\n /**\n * Imports an exported database from the given path.\n *\n * @param params - source path and dry-run flag\n * @returns import report with counts and timing\n */\n async import(params: {\n from: string;\n dryRun: boolean;\n }): Promise<ImportResult> {\n return this.call('importDb', {\n sourcePath: params.from,\n dryRun: params.dryRun,\n }) as Promise<ImportResult>;\n }\n\n /**\n * Sends a JSON-RPC 2.0 request and awaits the response.\n *\n * @param method - the RPC method name\n * @param params - parameters to include in the request\n * @throws {Error} if not connected\n * @throws {Error} when the daemon returns an error response\n */\n private async call(\n method: string,\n params: unknown,\n ): Promise<unknown> {\n const socket = this.socket;\n if (!socket) {\n throw new Error('not connected');\n }\n\n const id = this.nextId++;\n log(\n 'call: method=' + method + ' id=' + id.toString(),\n LogLevel.DEBUG,\n );\n const request = {\n jsonrpc: '2.0',\n id,\n method,\n params: { ctx: this.contextId, ...(params as object) },\n };\n\n const timeoutMs = this.requestTimeoutMs;\n return new Promise<unknown>((resolve, reject) => {\n const call: PendingCall = { resolve, reject };\n if (timeoutMs) {\n call.timer = setTimeout(() => {\n if (!this.pending.has(id)) return;\n this.pending.delete(id);\n log(\n 'request timeout after ' + String(timeoutMs) + 'ms',\n LogLevel.WARNING,\n );\n const err = new Error(\n `request timeout after ${String(timeoutMs)}ms`,\n );\n (err as unknown as Record<string, unknown>).code =\n 'REQUEST_TIMEOUT';\n reject(err);\n }, timeoutMs);\n }\n this.pending.set(id, call);\n socket.write(JSON.stringify(request) + '\\n');\n });\n }\n\n /**\n * Processes incoming data from the socket, splitting on newlines\n * and dispatching complete JSON-RPC response objects.\n *\n * @param data - raw string chunk received from the socket\n */\n private handleData(data: string): void {\n this.buffer += data;\n const lines = this.buffer.split('\\n');\n this.buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n if (!line.trim()) continue;\n try {\n const response = JSON.parse(line) as JsonRpcResponse;\n const pending = this.pending.get(response.id);\n if (pending) {\n this.pending.delete(response.id);\n if (pending.timer) clearTimeout(pending.timer);\n if (response.error) {\n log(\n 'response error: id=' +\n response.id.toString() +\n ' code=' +\n response.error.code.toString(),\n LogLevel.DEBUG,\n );\n const err = new Error(response.error.message);\n (err as unknown as Record<string, unknown>).code =\n response.error.code;\n pending.reject(err);\n } else {\n log(\n 'response ok: id=' + response.id.toString(),\n LogLevel.DEBUG,\n );\n pending.resolve(response.result);\n }\n } else {\n log(\n 'unmatched response id=' + response.id.toString(),\n LogLevel.DEBUG,\n );\n }\n } catch (parseErr: unknown) {\n log(\n 'json parse error: ' + (parseErr as Error).message,\n LogLevel.DEBUG,\n );\n }\n }\n }\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { existsSync, readFileSync, unlinkSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { isProcessAlive } from '../../platform/functions/is-process-alive.function.ts';\nimport type { DaemonInfo } from '../typings/daemon-info.model.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\nexport type { DaemonInfo };\n\n/**\n * Discovers a running worker daemon for the given context.\n *\n * Reads the PID file at `<tmpdir>/kbdb-<contextId>.pid`. If the\n * file exists and the process is alive, returns its PID and the\n * expected socket path. If the file is stale (process dead or PID\n * unparseable), removes the PID file and returns `null`.\n *\n * @param contextId - the 16-character context identifier\n * @returns daemon location info, or `null` if no live daemon found\n */\nexport function discoverDaemon(contextId: string): DaemonInfo | null {\n log('discovering daemon for context: ' + contextId, LogLevel.DEBUG);\n const pidPath = join(tmpdir(), `kbdb-${contextId}.pid`);\n\n if (!existsSync(pidPath)) {\n log(\n 'no daemon PID file found for context: ' + contextId,\n LogLevel.DEBUG,\n );\n return null;\n }\n\n const pidStr = readFileSync(pidPath, 'utf-8').trim();\n const pid = parseInt(pidStr, 10);\n\n if (isNaN(pid) || !isProcessAlive(pid)) {\n log(\n 'daemon process not alive for context: ' + contextId,\n LogLevel.DEBUG,\n );\n try {\n unlinkSync(pidPath);\n } catch {\n // Stale PID file removal is best-effort\n }\n return null;\n }\n\n log('daemon found: pid=' + pid.toString(), LogLevel.DEBUG);\n const socketPath = join(tmpdir(), `kbdb-${contextId}.sock`);\n\n const crashPath = join(tmpdir(), `kbdb-${contextId}.crash`);\n try {\n unlinkSync(crashPath);\n } catch {\n // stale crash file removal is best-effort\n }\n\n return { pid, socketPath };\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\n/**\n * Checks whether a process with the given PID is alive.\n *\n * Sends signal `0` to the process, which performs a permission\n * check without sending an actual signal. Returns `true` if the\n * process exists and is reachable, `false` otherwise.\n *\n * @param pid - the process identifier to probe\n */\nexport function isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\n/** Verbosity levels, ordered from most to least verbose. */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARNING = 2,\n ERROR = 3,\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { LogLevel } from '../typings/log-level.type.ts';\n\n/** ANSI escape sequence that resets all text formatting. */\nexport const ANSI_RESET = '\\x1b[0m';\n\n/** ANSI foreground color code applied to each log level's output. */\nexport const LOG_COLORS: Record<LogLevel, string> = {\n [LogLevel.DEBUG]: '\\x1b[37m',\n [LogLevel.INFO]: '\\x1b[36m',\n [LogLevel.WARNING]: '\\x1b[33m',\n [LogLevel.ERROR]: '\\x1b[91m',\n};\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { LogLevel } from '../typings/log-level.type.ts';\n\n/** Single-character icon used as visual prefix for each log level. */\nexport const LOG_ICONS: Record<LogLevel, string> = {\n [LogLevel.DEBUG]: '\u25B8',\n [LogLevel.INFO]: '\u2139',\n [LogLevel.WARNING]: '\u26A0',\n [LogLevel.ERROR]: '\u2716',\n};\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { LogLevel } from '../typings/log-level.type.ts';\n\n/** Default log level used when no CLI flag or env var is set. */\nexport const DEFAULT_LOG_LEVEL = LogLevel.ERROR;\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\n/**\n * Writes a string to the process standard error stream.\n *\n * Works on both Node.js (via `process.stderr.write`) and Deno\n * (via `Deno.stderr.writeSync`). Silently does nothing when\n * neither runtime API is available.\n *\n * @param message - the string to write to stderr\n */\nexport function writeStderr(message: string): void {\n const g = globalThis as Record<string, unknown>;\n const proc = g['process'] as\n | { stderr: { write: (s: string) => void } }\n | undefined;\n if (proc?.stderr) {\n proc.stderr.write(message);\n return;\n }\n const deno = g['Deno'] as\n | { stderr: { writeSync: (b: Uint8Array) => void } }\n | undefined;\n deno?.stderr.writeSync(new TextEncoder().encode(message));\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport {\n ANSI_RESET,\n LOG_COLORS,\n} from '../constants/log-colors.constant.ts';\nimport { LOG_ICONS } from '../constants/log-icons.constant.ts';\nimport { DEFAULT_LOG_LEVEL } from '../constants/log-defaults.constant.ts';\nimport { LogLevel } from '../typings/log-level.type.ts';\nimport { writeStderr } from './write-stderr.function.ts';\n\n/** A function that receives a formatted log line. */\ntype OutputFn = (message: string) => void;\n\nlet currentLevel: LogLevel = DEFAULT_LOG_LEVEL;\n\nconst outputs: Record<LogLevel, OutputFn> = {\n [LogLevel.DEBUG]: writeStderr,\n [LogLevel.INFO]: writeStderr,\n [LogLevel.WARNING]: writeStderr,\n [LogLevel.ERROR]: writeStderr,\n};\n\n/**\n * Sets the minimum log level. Messages below this level are\n * suppressed. Used internally by `configureLog`.\n */\nexport function setLogLevel(level: LogLevel): void {\n currentLevel = level;\n}\n\n/**\n * Overrides the output function for a specific log level.\n * Used internally by `configureLog`.\n *\n * @param level - the log level whose output to replace\n * @param output - function that receives the formatted message\n */\nexport function setLogOutput(level: LogLevel, output: OutputFn): void {\n outputs[level] = output;\n}\n\n/**\n * Writes a formatted, colorized log message to the configured\n * output for the given level. Messages below the current level\n * are silently discarded.\n *\n * Format: `\\x1b[COLORm ICON [LEVEL_NAME] message\\x1b[0m\\n`\n *\n * @param message - the text to log\n * @param level - severity level; defaults to `LogLevel.ERROR`\n */\nexport function log(\n message: string,\n level: LogLevel = LogLevel.ERROR,\n): void {\n if (level < currentLevel) {\n return;\n }\n const color = LOG_COLORS[level];\n const icon = LOG_ICONS[level];\n const name = LogLevel[level];\n const line = `${color}${icon} [${name}] ${message}${ANSI_RESET}\\n`;\n outputs[level](line);\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/**\n * Resolves the absolute path to the `.kbdb` database directory.\n *\n * Searches for a `.kbdb` sub-directory inside `targetDir`. When\n * `targetDir` is omitted, `process.cwd()` is used as the base.\n *\n * @param targetDir - directory to search in; defaults to cwd\n * @throws {Error} if no `.kbdb` directory exists at the resolved\n * path\n */\nexport function resolveDbPath(targetDir?: string): string {\n const base = targetDir ? resolve(targetDir) : process.cwd();\n const dbPath = join(base, '.kbdb');\n if (!existsSync(dbPath)) {\n const msg = `database not found: ${dbPath}`;\n log(msg, LogLevel.ERROR);\n throw new Error(msg);\n }\n return dbPath;\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\n/**\n * Computes the SHA-256 hash of a UTF-8 string.\n *\n * Uses the Web Crypto API (`crypto.subtle`), which is available\n * in both Deno and Node.js >= 20 without additional imports.\n *\n * @param input - the string to hash\n * @returns lowercase hex-encoded SHA-256 digest (64 characters)\n */\nexport async function computeSha256(input: string): Promise<string> {\n const data = new TextEncoder().encode(input);\n const hash = await crypto.subtle.digest('SHA-256', data);\n const bytes = new Uint8Array(hash);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { computeSha256 } from '../../hash/functions/compute-sha256.ts';\n\n/**\n * Computes a short context identifier for an absolute path.\n *\n * Hashes the path with SHA-256 and returns the first 16 hex\n * characters. The result is stable for the same input and unique\n * enough to avoid accidental collisions across typical path sets.\n *\n * @param absolutePath - the absolute filesystem path to identify\n * @returns a 16-character lowercase hex string\n */\nexport async function computeContextId(\n absolutePath: string,\n): Promise<string> {\n const hash = await computeSha256(absolutePath);\n return hash.slice(0, 16);\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { spawn } from 'node:child_process';\nimport type { Runtime } from '../../runtime/typings/runtime.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\nimport { buildDenoPermissions } from './build-deno-permissions.function.ts';\n\n/**\n * Spawns a detached worker daemon process for the given context.\n *\n * @param contextPath - absolute path to the context directory the\n * daemon should serve\n * @param runtime - the current JavaScript runtime environment\n * @param workerScript - absolute path to the worker daemon script,\n * resolved by `resolveSpawnScript`\n */\nexport function spawnDaemon(\n contextPath: string,\n runtime: Runtime,\n workerScript?: string,\n): void {\n if (!workerScript) {\n const msg =\n 'workerScript must be provided' + ' (resolve at entry point)';\n log(msg, LogLevel.ERROR);\n throw new Error(msg);\n }\n const execPath = runtime === 'deno' ? 'deno' : process.execPath;\n\n const logLevelEnv = process.env['KBDB_LOG_LEVEL'];\n const logArgs = logLevelEnv ? ['--log-level', logLevelEnv] : [];\n\n const args =\n runtime === 'deno'\n ? [\n 'run',\n ...buildDenoPermissions(),\n workerScript,\n contextPath,\n ...logArgs,\n ]\n : [workerScript, contextPath, ...logArgs];\n\n log(\n 'spawning daemon: ' + execPath + ' ' + args.join(' '),\n LogLevel.DEBUG,\n );\n const child = spawn(execPath, args, {\n detached: true,\n stdio: 'ignore',\n });\n child.unref();\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\n/**\n * Deno permission flags for the worker daemon.\n *\n * - read: WASM modules, DB files, config\n * - write: DB files, IPC socket, crash logs, exports\n * - env: KBDB_LOG_LEVEL, HOME, TMPDIR, XDG_RUNTIME_DIR\n * - run: not used by daemon itself (CLI needs it to\n * spawn the daemon, included for symmetry)\n * - sys: os.tmpdir(), os.hostname() via node:os compat\n */\nexport function buildDenoPermissions(): string[] {\n return [\n '--allow-read',\n '--allow-write',\n '--allow-env',\n '--allow-run',\n '--allow-sys',\n ];\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/** Default maximum wait time for the daemon PID file to appear. */\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\n/** Polling interval in milliseconds between existence checks. */\nconst POLL_INTERVAL_MS = 100;\n\n/**\n * Waits for the worker daemon's PID file to appear on disk.\n *\n * Polls every 100 ms until the PID file at\n * `<tmpdir>/kbdb-<contextId>.pid` exists or the timeout elapses.\n *\n * @param contextId - the 16-character context identifier\n * @param timeoutMs - maximum wait time in milliseconds; defaults\n * to 10 000 ms\n * @returns `true` if the PID file appeared before the timeout,\n * `false` otherwise\n */\nexport async function waitForDaemon(\n contextId: string,\n timeoutMs: number = DEFAULT_TIMEOUT_MS,\n): Promise<boolean> {\n log('waiting for daemon: contextId=' + contextId, LogLevel.DEBUG);\n const pidPath = join(tmpdir(), `kbdb-${contextId}.pid`);\n const start = Date.now();\n let iteration = 0;\n while (Date.now() - start < timeoutMs) {\n if (existsSync(pidPath)) {\n log('daemon PID file appeared', LogLevel.DEBUG);\n return true;\n }\n iteration++;\n if (iteration % 10 === 0) {\n const elapsed = Date.now() - start;\n log(\n 'still waiting for daemon: elapsed=' +\n elapsed.toString() +\n 'ms',\n LogLevel.DEBUG,\n );\n }\n await new Promise<void>((r) => setTimeout(r, POLL_INTERVAL_MS));\n }\n const elapsed = Date.now() - start;\n log(\n 'timed out waiting for daemon: elapsed=' +\n elapsed.toString() +\n 'ms',\n LogLevel.DEBUG,\n );\n return false;\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { existsSync, readFileSync, unlinkSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\n\n/**\n * Reads and clears the crash log written by a worker daemon that\n * failed to start, returning a human-readable reason.\n *\n * @param contextId - the 16-char hex context ID for the daemon\n * @returns the recorded crash error, or a fallback message when no\n * usable crash log is found\n */\nexport function readCrashReason(contextId: string): string {\n const crashPath = join(tmpdir(), `kbdb-${contextId}.crash`);\n if (!existsSync(crashPath)) {\n return 'daemon failed to start (no details available)';\n }\n try {\n const raw = readFileSync(crashPath, 'utf-8');\n const crash = JSON.parse(raw) as { error?: string };\n unlinkSync(crashPath);\n return crash.error ?? 'unknown error (crash log empty)';\n } catch {\n return 'daemon failed to start (crash log unreadable)';\n }\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport type { Runtime } from '../typings/runtime.ts';\n\n/**\n * Detects the current JavaScript runtime environment.\n *\n * Returns `'deno'` when the global `Deno` object is present,\n * otherwise returns `'node'`.\n */\nexport function detectRuntime(): Runtime {\n if (typeof globalThis !== 'undefined' && 'Deno' in globalThis) {\n return 'deno';\n }\n return 'node';\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { resolveWorkerScript } from '../../dir-resolver/index.ts';\n\nimport type { Runtime } from '../../runtime/typings/runtime.ts';\n\n/**\n * Resolves the worker daemon script path from within\n * the worker-client module.\n */\nexport function resolveSpawnScript(runtime: Runtime): string {\n return resolveWorkerScript(resolveScriptDir(runtime), runtime);\n}\n\nfunction resolveScriptDir(runtime: Runtime): string {\n if (typeof __dirname !== 'undefined') return __dirname;\n const thisDir = dirname(fileURLToPath(import.meta.url));\n if (runtime === 'deno') {\n return resolve(thisDir, '..', '..', '..');\n }\n return thisDir;\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { join } from 'node:path';\n\nexport function isRemoteUrl(path: string): boolean {\n return path.startsWith('http://') || path.startsWith('https://');\n}\n\nexport function joinPath(base: string, ...segments: string[]): string {\n if (isRemoteUrl(base)) {\n const trailing = base.endsWith('/') ? '' : '/';\n return base + trailing + segments.join('/');\n }\n return join(base, ...segments);\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { joinPath } from './join-path.function.ts';\n\nimport type { Runtime } from '../../runtime/typings/runtime.ts';\n\nexport function resolveWorkerScript(\n scriptDir: string,\n runtime: Runtime,\n): string {\n if (runtime === 'deno') {\n return joinPath(scriptDir, 'worker.ts');\n }\n return joinPath(scriptDir, 'kbdb-worker.cjs');\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { join } from 'node:path';\nimport { getTmpdir } from './get-tmpdir.function.ts';\n\n/**\n * Returns the platform-appropriate IPC socket path for a given\n * context identifier.\n *\n * On Windows, returns a named pipe path (`\\\\.\\pipe\\kbdb-<ctx>`).\n * On POSIX systems, returns a Unix domain socket path under the\n * system temp directory (`<tmpdir>/kbdb-<ctx>.sock`).\n *\n * @param ctx - unique context identifier embedded in the path\n */\nexport function getIpcPath(ctx: string): string {\n if (process.platform === 'win32') {\n return `\\\\\\\\.\\\\pipe\\\\kbdb-${ctx}`;\n }\n return join(getTmpdir(), `kbdb-${ctx}.sock`);\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { tmpdir } from 'node:os';\n\n/**\n * Returns the operating system's default temporary directory path.\n */\nexport function getTmpdir(): string {\n return tmpdir();\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { WorkerClient } from '../classes/worker-client.class.ts';\nimport { resolveDbPath } from './resolve-db-path.function.ts';\nimport { computeContextId } from './compute-context-id.function.ts';\nimport { discoverDaemon } from './discover-daemon.function.ts';\nimport { spawnDaemon } from './spawn-daemon.function.ts';\nimport { waitForDaemon } from './wait-for-daemon.function.ts';\nimport { readCrashReason } from './read-crash-reason.function.ts';\nimport { detectRuntime } from '../../runtime/functions/detect-runtime.ts';\nimport { resolveSpawnScript } from './resolve-spawn-script.function.ts';\nimport { getIpcPath } from '../../platform/functions/get-ipc-path.function.ts';\nimport type { WorkerClientOptions } from '../typings/worker-client-options.interface.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/**\n * Creates and connects a `WorkerClient` to the worker daemon.\n *\n * Resolves the context path, derives a stable context identifier,\n * and checks whether a daemon is already running. If no daemon is\n * found and `autoSpawn` is not `false`, a new daemon process is\n * spawned and the factory waits for its PID file to appear before\n * connecting.\n *\n * @param options - optional configuration for path resolution,\n * auto-spawn behaviour, and connection timeout\n * @returns a connected `WorkerClient` ready to send requests\n * @throws {Error} if the `.kbdb` directory cannot be found\n * @throws {Error} if the socket connection cannot be established\n */\nexport async function createWorkerClient(\n options?: WorkerClientOptions,\n): Promise<WorkerClient> {\n const dbPath =\n options?.contextPath ?? resolveDbPath(options?.dbPath);\n const contextId = await computeContextId(dbPath);\n log('create-worker-client: contextId=' + contextId, LogLevel.DEBUG);\n const socketPath = getIpcPath(contextId);\n\n let daemon = discoverDaemon(contextId);\n\n if (daemon) {\n log('daemon found: pid=' + daemon.pid.toString(), LogLevel.DEBUG);\n } else {\n log('no daemon found', LogLevel.DEBUG);\n }\n\n if (!daemon && options?.autoSpawn !== false) {\n const runtime = detectRuntime();\n log('auto-spawning daemon', LogLevel.DEBUG);\n const workerScript = resolveSpawnScript(runtime);\n spawnDaemon(dbPath, runtime, workerScript);\n log('waiting for daemon after spawn', LogLevel.DEBUG);\n await waitForDaemon(contextId, options?.connectTimeoutMs);\n daemon = discoverDaemon(contextId);\n }\n\n if (!daemon) {\n const msg = `kbdb worker daemon did not start: ${readCrashReason(contextId)}`;\n log(msg, LogLevel.ERROR);\n throw new Error(msg);\n }\n\n log('connecting to daemon', LogLevel.DEBUG);\n const client = new WorkerClient(\n socketPath,\n contextId,\n options?.requestTimeoutMs,\n );\n await client.connect();\n return client;\n}\n", "// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright (C) 2026 Diko Tech Slave\n\nimport { createWorkerClient } from './create-worker-client.function.ts';\nimport type { WorkerClient } from '../classes/worker-client.class.ts';\nimport type { WorkerClientOptions } from '../typings/worker-client-options.interface.ts';\nimport { resolveDbPath } from './resolve-db-path.function.ts';\nimport { log } from '../../log/functions/log.function.ts';\nimport { LogLevel } from '../../log/typings/log-level.type.ts';\n\n/** Cache of connected clients keyed by database path. */\nconst cache = new Map<string, WorkerClient>();\n\n/**\n * Returns a cached `WorkerClient` for the given context\n * path, or creates and caches a new one if the cached\n * client is disconnected or absent.\n *\n * Intended for library consumers and the MCP server. CLI\n * one-shots should use `createWorkerClient()` directly.\n *\n * @param options - optional configuration forwarded to\n * `createWorkerClient`\n * @returns a connected `WorkerClient`\n */\nexport async function getOrCreateClient(\n options?: WorkerClientOptions,\n): Promise<WorkerClient> {\n log('getOrCreateClient called', LogLevel.DEBUG);\n const dbPath =\n options?.contextPath ?? resolveDbPath(options?.dbPath);\n const cached = cache.get(dbPath);\n if (cached?.isConnected) {\n log('returning cached client for: ' + dbPath, LogLevel.DEBUG);\n return cached;\n }\n cache.delete(dbPath);\n log('creating new client for: ' + dbPath, LogLevel.DEBUG);\n const client = await createWorkerClient(options);\n cache.set(dbPath, client);\n return client;\n}\n\n/**\n * Clears the internal client cache. Intended for tests\n * that need isolation between runs.\n */\nexport function clearClientCache(): void {\n for (const [key, client] of cache) {\n client.disconnect();\n cache.delete(key);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,UAAU;;;ACDvB,sBAAwB;;;ACAxB,qBAAqD;AACrD,uBAAqB;AACrB,qBAAuB;;;ACOhB,SAAS,eAAe,KAAsB;AAClD,MAAI;AACD,YAAQ,KAAK,KAAK,CAAC;AACnB,WAAO;AAAA,EACV,QAAQ;AACL,WAAO;AAAA,EACV;AACH;;;ACfO,IAAK,WAAL,kBAAKA,cAAL;AACJ,EAAAA,oBAAA,W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M,IAAI,QAAQ,MAAM;AACxB,SAAO;AACV;",
6
+ "names": ["LogLevel", "resolve", "import_node_fs", "import_node_path", "import_node_fs", "import_node_path", "import_node_os", "elapsed", "import_node_fs", "import_node_path", "import_node_os", "import_node_path", "import_node_path", "resolveScriptDir", "import_node_path", "import_node_os"]
7
7
  }