@dikolab/kbdb 0.1.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 (308) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +270 -0
  3. package/dist/chunk-QCCN7OZH.mjs +82 -0
  4. package/dist/chunk-QCCN7OZH.mjs.map +7 -0
  5. package/dist/cli.cjs +3598 -0
  6. package/dist/cli.cjs.map +7 -0
  7. package/dist/cli.mjs +3537 -0
  8. package/dist/cli.mjs.map +7 -0
  9. package/dist/kbdb-worker.cjs +1659 -0
  10. package/dist/kbdb-worker.cjs.map +7 -0
  11. package/dist/mod.cjs +538 -0
  12. package/dist/mod.cjs.map +7 -0
  13. package/dist/mod.d.ts +3 -0
  14. package/dist/mod.mjs +507 -0
  15. package/dist/mod.mjs.map +7 -0
  16. package/dist/src/cli.d.ts +1 -0
  17. package/dist/src/shared/cli/constants/defaults.constant.d.ts +11 -0
  18. package/dist/src/shared/cli/constants/help-text.constant.d.ts +2 -0
  19. package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +37 -0
  20. package/dist/src/shared/cli/functions/ensure-db.function.d.ts +11 -0
  21. package/dist/src/shared/cli/functions/error-to-message.function.d.ts +7 -0
  22. package/dist/src/shared/cli/functions/find-db.function.d.ts +13 -0
  23. package/dist/src/shared/cli/functions/format-output.function.d.ts +15 -0
  24. package/dist/src/shared/cli/functions/generate-help.function.d.ts +31 -0
  25. package/dist/src/shared/cli/functions/is-stdin-tty.function.d.ts +7 -0
  26. package/dist/src/shared/cli/functions/parse-args.function.d.ts +25 -0
  27. package/dist/src/shared/cli/functions/prompt-user.function.d.ts +13 -0
  28. package/dist/src/shared/cli/functions/run-agent-create.function.d.ts +58 -0
  29. package/dist/src/shared/cli/functions/run-agent-delete.function.d.ts +32 -0
  30. package/dist/src/shared/cli/functions/run-agent-get.function.d.ts +46 -0
  31. package/dist/src/shared/cli/functions/run-agent-list.function.d.ts +45 -0
  32. package/dist/src/shared/cli/functions/run-check.function.d.ts +64 -0
  33. package/dist/src/shared/cli/functions/run-cli.function.d.ts +39 -0
  34. package/dist/src/shared/cli/functions/run-content.function.d.ts +40 -0
  35. package/dist/src/shared/cli/functions/run-db-init.function.d.ts +23 -0
  36. package/dist/src/shared/cli/functions/run-db-migrate.function.d.ts +32 -0
  37. package/dist/src/shared/cli/functions/run-gc.function.d.ts +38 -0
  38. package/dist/src/shared/cli/functions/run-init.function.d.ts +27 -0
  39. package/dist/src/shared/cli/functions/run-learn.function.d.ts +46 -0
  40. package/dist/src/shared/cli/functions/run-migrate.function.d.ts +57 -0
  41. package/dist/src/shared/cli/functions/run-rebuild.function.d.ts +40 -0
  42. package/dist/src/shared/cli/functions/run-search.function.d.ts +39 -0
  43. package/dist/src/shared/cli/functions/run-skill-delete.function.d.ts +30 -0
  44. package/dist/src/shared/cli/functions/run-skill-get.function.d.ts +49 -0
  45. package/dist/src/shared/cli/functions/run-skill-learn.function.d.ts +36 -0
  46. package/dist/src/shared/cli/functions/run-skill-list.function.d.ts +43 -0
  47. package/dist/src/shared/cli/functions/run-status.function.d.ts +22 -0
  48. package/dist/src/shared/cli/functions/run-unlearn.function.d.ts +45 -0
  49. package/dist/src/shared/cli/index.d.ts +35 -0
  50. package/dist/src/shared/cli/typings/cli-options.interface.d.ts +53 -0
  51. package/dist/src/shared/cli/typings/command-result.model.d.ts +15 -0
  52. package/dist/src/shared/cli/typings/learn-result.model.d.ts +11 -0
  53. package/dist/src/shared/cli/typings/search-display.model.d.ts +17 -0
  54. package/dist/src/shared/dir-resolver/functions/resolve-base-dir.function.d.ts +3 -0
  55. package/dist/src/shared/dir-resolver/functions/resolve-wasm-dir.function.d.ts +1 -0
  56. package/dist/src/shared/dir-resolver/functions/resolve-worker-script.function.d.ts +2 -0
  57. package/dist/src/shared/dir-resolver/index.d.ts +4 -0
  58. package/dist/src/shared/dir-resolver/typings/base-dir.interface.d.ts +4 -0
  59. package/dist/src/shared/hash/functions/compute-sha256.d.ts +10 -0
  60. package/dist/src/shared/hash/index.d.ts +1 -0
  61. package/dist/src/shared/mcp/classes/mcp-server.class.d.ts +55 -0
  62. package/dist/src/shared/mcp/constants/mcp-error-codes.constant.d.ts +26 -0
  63. package/dist/src/shared/mcp/functions/create-mcp-server.function.d.ts +11 -0
  64. package/dist/src/shared/mcp/functions/create-prompt-definitions.function.d.ts +41 -0
  65. package/dist/src/shared/mcp/functions/create-resource-templates.function.d.ts +7 -0
  66. package/dist/src/shared/mcp/functions/create-tool-definitions.function.d.ts +7 -0
  67. package/dist/src/shared/mcp/functions/extract-skill-arguments.function.d.ts +13 -0
  68. package/dist/src/shared/mcp/functions/handle-agent-create.function.d.ts +29 -0
  69. package/dist/src/shared/mcp/functions/handle-agent-delete.function.d.ts +28 -0
  70. package/dist/src/shared/mcp/functions/handle-agent-get.function.d.ts +29 -0
  71. package/dist/src/shared/mcp/functions/handle-agent-list.function.d.ts +31 -0
  72. package/dist/src/shared/mcp/functions/handle-completion.function.d.ts +58 -0
  73. package/dist/src/shared/mcp/functions/handle-prompt-get.function.d.ts +23 -0
  74. package/dist/src/shared/mcp/functions/handle-resource-read.function.d.ts +26 -0
  75. package/dist/src/shared/mcp/functions/handle-roots-list.function.d.ts +21 -0
  76. package/dist/src/shared/mcp/functions/handle-tool-call.function.d.ts +26 -0
  77. package/dist/src/shared/mcp/functions/parse-skill-content.function.d.ts +15 -0
  78. package/dist/src/shared/mcp/functions/serialize-skill-content.function.d.ts +9 -0
  79. package/dist/src/shared/mcp/functions/should-emit-log.function.d.ts +20 -0
  80. package/dist/src/shared/mcp/index.d.ts +9 -0
  81. package/dist/src/shared/mcp/typings/agent-types.interface.d.ts +38 -0
  82. package/dist/src/shared/mcp/typings/log-types.interface.d.ts +17 -0
  83. package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +217 -0
  84. package/dist/src/shared/mcp/typings/mcp-types.interface.d.ts +149 -0
  85. package/dist/src/shared/mcp/typings/prompt-types.interface.d.ts +37 -0
  86. package/dist/src/shared/mcp/typings/remove-section-result.model.d.ts +10 -0
  87. package/dist/src/shared/mcp/typings/sampling-types.interface.d.ts +46 -0
  88. package/dist/src/shared/mcp/typings/skill-types.interface.d.ts +28 -0
  89. package/dist/src/shared/mod.d.ts +1 -0
  90. package/dist/src/shared/platform/functions/get-ipc-path.function.d.ts +11 -0
  91. package/dist/src/shared/platform/functions/get-tmpdir.function.d.ts +4 -0
  92. package/dist/src/shared/platform/functions/is-process-alive.function.d.ts +10 -0
  93. package/dist/src/shared/platform/index.d.ts +3 -0
  94. package/dist/src/shared/runtime/functions/detect-runtime.d.ts +8 -0
  95. package/dist/src/shared/runtime/functions/get-args.d.ts +7 -0
  96. package/dist/src/shared/runtime/index.d.ts +3 -0
  97. package/dist/src/shared/runtime/typings/runtime.d.ts +2 -0
  98. package/dist/src/shared/version/constants/version.constant.d.ts +2 -0
  99. package/dist/src/shared/version/index.d.ts +1 -0
  100. package/dist/src/shared/wasm-codec/functions/decode-compose-output.function.d.ts +5 -0
  101. package/dist/src/shared/wasm-codec/functions/decode-document-manifest-list.function.d.ts +14 -0
  102. package/dist/src/shared/wasm-codec/functions/decode-document-manifest.function.d.ts +40 -0
  103. package/dist/src/shared/wasm-codec/functions/decode-f32.function.d.ts +2 -0
  104. package/dist/src/shared/wasm-codec/functions/decode-key-value-text.function.d.ts +1 -0
  105. package/dist/src/shared/wasm-codec/functions/decode-remove-flag.function.d.ts +1 -0
  106. package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +10 -0
  107. package/dist/src/shared/wasm-codec/functions/decode-section-record-list.function.d.ts +13 -0
  108. package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +50 -0
  109. package/dist/src/shared/wasm-codec/functions/decode-string.function.d.ts +5 -0
  110. package/dist/src/shared/wasm-codec/functions/decode-u32.function.d.ts +2 -0
  111. package/dist/src/shared/wasm-codec/functions/decode-u64.function.d.ts +2 -0
  112. package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +10 -0
  113. package/dist/src/shared/wasm-codec/functions/encode-group-params.function.d.ts +10 -0
  114. package/dist/src/shared/wasm-codec/functions/encode-identifier-list.function.d.ts +1 -0
  115. package/dist/src/shared/wasm-codec/functions/encode-kbid-list.function.d.ts +1 -0
  116. package/dist/src/shared/wasm-codec/functions/encode-option-string.function.d.ts +1 -0
  117. package/dist/src/shared/wasm-codec/functions/encode-search-params.function.d.ts +1 -0
  118. package/dist/src/shared/wasm-codec/functions/encode-section-type.function.d.ts +1 -0
  119. package/dist/src/shared/wasm-codec/functions/encode-string.function.d.ts +1 -0
  120. package/dist/src/shared/wasm-codec/functions/encode-type-filter-param.function.d.ts +11 -0
  121. package/dist/src/shared/wasm-codec/functions/encode-u32.function.d.ts +1 -0
  122. package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +2 -0
  123. package/dist/src/shared/wasm-codec/index.d.ts +29 -0
  124. package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +230 -0
  125. package/dist/src/shared/worker-client/functions/compute-context-id.function.d.ts +11 -0
  126. package/dist/src/shared/worker-client/functions/create-worker-client.function.d.ts +18 -0
  127. package/dist/src/shared/worker-client/functions/discover-daemon.function.d.ts +14 -0
  128. package/dist/src/shared/worker-client/functions/resolve-db-path.function.d.ts +11 -0
  129. package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +11 -0
  130. package/dist/src/shared/worker-client/functions/wait-for-daemon.function.d.ts +13 -0
  131. package/dist/src/shared/worker-client/index.d.ts +22 -0
  132. package/dist/src/shared/worker-client/typings/add-section-result.model.d.ts +22 -0
  133. package/dist/src/shared/worker-client/typings/content-result.model.d.ts +12 -0
  134. package/dist/src/shared/worker-client/typings/daemon-info.model.d.ts +7 -0
  135. package/dist/src/shared/worker-client/typings/gc-result.model.d.ts +12 -0
  136. package/dist/src/shared/worker-client/typings/integrity-check-result.model.d.ts +36 -0
  137. package/dist/src/shared/worker-client/typings/migrate-result.model.d.ts +11 -0
  138. package/dist/src/shared/worker-client/typings/rebuild-result.model.d.ts +12 -0
  139. package/dist/src/shared/worker-client/typings/remove-section-result.model.d.ts +7 -0
  140. package/dist/src/shared/worker-client/typings/search-params.model.d.ts +12 -0
  141. package/dist/src/shared/worker-client/typings/search-result.model.d.ts +14 -0
  142. package/dist/src/shared/worker-client/typings/section.model.d.ts +26 -0
  143. package/dist/src/shared/worker-client/typings/status-result.model.d.ts +14 -0
  144. package/dist/src/shared/worker-client/typings/version-status.model.d.ts +24 -0
  145. package/dist/src/shared/worker-client/typings/worker-client-error.interface.d.ts +8 -0
  146. package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +30 -0
  147. package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +147 -0
  148. package/dist/src/shared/worker-daemon/constants/daemon-defaults.constant.d.ts +24 -0
  149. package/dist/src/shared/worker-daemon/functions/create-host-imports.function.d.ts +68 -0
  150. package/dist/src/shared/worker-daemon/functions/create-ipc-server.function.d.ts +18 -0
  151. package/dist/src/shared/worker-daemon/functions/load-wasm-modules.function.d.ts +19 -0
  152. package/dist/src/shared/worker-daemon/functions/read-config.function.d.ts +12 -0
  153. package/dist/src/shared/worker-daemon/functions/run-worker.function.d.ts +26 -0
  154. package/dist/src/shared/worker-daemon/functions/start-daemon.function.d.ts +13 -0
  155. package/dist/src/shared/worker-daemon/index.d.ts +9 -0
  156. package/dist/src/shared/worker-daemon/typings/daemon-config.interface.d.ts +13 -0
  157. package/dist/src/shared/worker-daemon/typings/ipc-handler.interface.d.ts +36 -0
  158. package/dist/src/shared/worker-daemon/typings/wasm-modules.interface.d.ts +7 -0
  159. package/dist/src/worker.d.ts +1 -0
  160. package/dist/vitest.config.d.ts +2 -0
  161. package/dist/worker.mjs +1615 -0
  162. package/dist/worker.mjs.map +7 -0
  163. package/mod.ts +17 -0
  164. package/package.json +85 -0
  165. package/src/cli.ts +62 -0
  166. package/src/shared/cli/constants/defaults.constant.ts +19 -0
  167. package/src/shared/cli/constants/help-text.constant.ts +4 -0
  168. package/src/shared/cli/functions/dispatch-command.function.ts +338 -0
  169. package/src/shared/cli/functions/ensure-db.function.ts +21 -0
  170. package/src/shared/cli/functions/error-to-message.function.ts +9 -0
  171. package/src/shared/cli/functions/find-db.function.ts +20 -0
  172. package/src/shared/cli/functions/format-output.function.ts +64 -0
  173. package/src/shared/cli/functions/generate-help.function.ts +599 -0
  174. package/src/shared/cli/functions/is-stdin-tty.function.ts +12 -0
  175. package/src/shared/cli/functions/parse-args.function.ts +133 -0
  176. package/src/shared/cli/functions/prompt-user.function.ts +36 -0
  177. package/src/shared/cli/functions/run-agent-create.function.ts +114 -0
  178. package/src/shared/cli/functions/run-agent-delete.function.ts +47 -0
  179. package/src/shared/cli/functions/run-agent-get.function.ts +166 -0
  180. package/src/shared/cli/functions/run-agent-list.function.ts +58 -0
  181. package/src/shared/cli/functions/run-check.function.ts +78 -0
  182. package/src/shared/cli/functions/run-cli.function.ts +299 -0
  183. package/src/shared/cli/functions/run-content.function.ts +47 -0
  184. package/src/shared/cli/functions/run-db-init.function.ts +44 -0
  185. package/src/shared/cli/functions/run-db-migrate.function.ts +40 -0
  186. package/src/shared/cli/functions/run-gc.function.ts +45 -0
  187. package/src/shared/cli/functions/run-init.function.ts +91 -0
  188. package/src/shared/cli/functions/run-learn.function.ts +171 -0
  189. package/src/shared/cli/functions/run-migrate.function.ts +85 -0
  190. package/src/shared/cli/functions/run-rebuild.function.ts +47 -0
  191. package/src/shared/cli/functions/run-search.function.ts +62 -0
  192. package/src/shared/cli/functions/run-skill-delete.function.ts +47 -0
  193. package/src/shared/cli/functions/run-skill-get.function.ts +90 -0
  194. package/src/shared/cli/functions/run-skill-learn.function.ts +70 -0
  195. package/src/shared/cli/functions/run-skill-list.function.ts +74 -0
  196. package/src/shared/cli/functions/run-status.function.ts +29 -0
  197. package/src/shared/cli/functions/run-unlearn.function.ts +58 -0
  198. package/src/shared/cli/index.ts +48 -0
  199. package/src/shared/cli/typings/cli-options.interface.ts +55 -0
  200. package/src/shared/cli/typings/command-result.model.ts +15 -0
  201. package/src/shared/cli/typings/learn-result.model.ts +11 -0
  202. package/src/shared/cli/typings/search-display.model.ts +17 -0
  203. package/src/shared/dir-resolver/functions/resolve-base-dir.function.ts +25 -0
  204. package/src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts +5 -0
  205. package/src/shared/dir-resolver/functions/resolve-worker-script.function.ts +13 -0
  206. package/src/shared/dir-resolver/index.ts +7 -0
  207. package/src/shared/dir-resolver/typings/base-dir.interface.ts +4 -0
  208. package/src/shared/hash/functions/compute-sha256.ts +17 -0
  209. package/src/shared/hash/index.ts +1 -0
  210. package/src/shared/mcp/classes/mcp-server.class.ts +448 -0
  211. package/src/shared/mcp/constants/mcp-error-codes.constant.ts +30 -0
  212. package/src/shared/mcp/functions/create-mcp-server.function.ts +14 -0
  213. package/src/shared/mcp/functions/create-prompt-definitions.function.ts +102 -0
  214. package/src/shared/mcp/functions/create-resource-templates.function.ts +23 -0
  215. package/src/shared/mcp/functions/create-tool-definitions.function.ts +401 -0
  216. package/src/shared/mcp/functions/extract-skill-arguments.function.ts +27 -0
  217. package/src/shared/mcp/functions/handle-agent-create.function.ts +116 -0
  218. package/src/shared/mcp/functions/handle-agent-delete.function.ts +50 -0
  219. package/src/shared/mcp/functions/handle-agent-get.function.ts +160 -0
  220. package/src/shared/mcp/functions/handle-agent-list.function.ts +50 -0
  221. package/src/shared/mcp/functions/handle-completion.function.ts +114 -0
  222. package/src/shared/mcp/functions/handle-prompt-get.function.ts +214 -0
  223. package/src/shared/mcp/functions/handle-resource-read.function.ts +56 -0
  224. package/src/shared/mcp/functions/handle-roots-list.function.ts +29 -0
  225. package/src/shared/mcp/functions/handle-tool-call.function.ts +464 -0
  226. package/src/shared/mcp/functions/parse-skill-content.function.ts +38 -0
  227. package/src/shared/mcp/functions/serialize-skill-content.function.ts +12 -0
  228. package/src/shared/mcp/functions/should-emit-log.function.ts +38 -0
  229. package/src/shared/mcp/index.ts +28 -0
  230. package/src/shared/mcp/typings/agent-types.interface.ts +39 -0
  231. package/src/shared/mcp/typings/log-types.interface.ts +26 -0
  232. package/src/shared/mcp/typings/mcp-client.interface.ts +252 -0
  233. package/src/shared/mcp/typings/mcp-types.interface.ts +158 -0
  234. package/src/shared/mcp/typings/prompt-types.interface.ts +39 -0
  235. package/src/shared/mcp/typings/remove-section-result.model.ts +10 -0
  236. package/src/shared/mcp/typings/sampling-types.interface.ts +48 -0
  237. package/src/shared/mcp/typings/skill-types.interface.ts +29 -0
  238. package/src/shared/mod.ts +1 -0
  239. package/src/shared/platform/functions/get-ipc-path.function.ts +19 -0
  240. package/src/shared/platform/functions/get-tmpdir.function.ts +8 -0
  241. package/src/shared/platform/functions/is-process-alive.function.ts +17 -0
  242. package/src/shared/platform/index.ts +3 -0
  243. package/src/shared/runtime/functions/detect-runtime.ts +14 -0
  244. package/src/shared/runtime/functions/get-args.ts +16 -0
  245. package/src/shared/runtime/index.ts +3 -0
  246. package/src/shared/runtime/typings/runtime.ts +2 -0
  247. package/src/shared/version/constants/version.constant.ts +2 -0
  248. package/src/shared/version/index.ts +1 -0
  249. package/src/shared/wasm-codec/functions/decode-compose-output.function.ts +16 -0
  250. package/src/shared/wasm-codec/functions/decode-document-manifest-list.function.ts +70 -0
  251. package/src/shared/wasm-codec/functions/decode-document-manifest.function.ts +87 -0
  252. package/src/shared/wasm-codec/functions/decode-f32.function.ts +16 -0
  253. package/src/shared/wasm-codec/functions/decode-key-value-text.function.ts +15 -0
  254. package/src/shared/wasm-codec/functions/decode-remove-flag.function.ts +3 -0
  255. package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +54 -0
  256. package/src/shared/wasm-codec/functions/decode-section-record-list.function.ts +20 -0
  257. package/src/shared/wasm-codec/functions/decode-section-records.function.ts +162 -0
  258. package/src/shared/wasm-codec/functions/decode-string.function.ts +22 -0
  259. package/src/shared/wasm-codec/functions/decode-u32.function.ts +16 -0
  260. package/src/shared/wasm-codec/functions/decode-u64.function.ts +16 -0
  261. package/src/shared/wasm-codec/functions/encode-add-section-params.function.ts +34 -0
  262. package/src/shared/wasm-codec/functions/encode-group-params.function.ts +28 -0
  263. package/src/shared/wasm-codec/functions/encode-identifier-list.function.ts +17 -0
  264. package/src/shared/wasm-codec/functions/encode-kbid-list.function.ts +17 -0
  265. package/src/shared/wasm-codec/functions/encode-option-string.function.ts +14 -0
  266. package/src/shared/wasm-codec/functions/encode-search-params.function.ts +9 -0
  267. package/src/shared/wasm-codec/functions/encode-section-type.function.ts +18 -0
  268. package/src/shared/wasm-codec/functions/encode-string.function.ts +9 -0
  269. package/src/shared/wasm-codec/functions/encode-type-filter-param.function.ts +13 -0
  270. package/src/shared/wasm-codec/functions/encode-u32.function.ts +5 -0
  271. package/src/shared/wasm-codec/functions/encode-update-section-params.function.ts +16 -0
  272. package/src/shared/wasm-codec/index.ts +36 -0
  273. package/src/shared/worker-client/classes/worker-client.class.ts +427 -0
  274. package/src/shared/worker-client/functions/compute-context-id.function.ts +18 -0
  275. package/src/shared/worker-client/functions/create-worker-client.function.ts +70 -0
  276. package/src/shared/worker-client/functions/discover-daemon.function.ts +47 -0
  277. package/src/shared/worker-client/functions/resolve-db-path.function.ts +21 -0
  278. package/src/shared/worker-client/functions/spawn-daemon.function.ts +35 -0
  279. package/src/shared/worker-client/functions/wait-for-daemon.function.ts +34 -0
  280. package/src/shared/worker-client/index.ts +31 -0
  281. package/src/shared/worker-client/typings/add-section-result.model.ts +22 -0
  282. package/src/shared/worker-client/typings/content-result.model.ts +12 -0
  283. package/src/shared/worker-client/typings/daemon-info.model.ts +7 -0
  284. package/src/shared/worker-client/typings/gc-result.model.ts +12 -0
  285. package/src/shared/worker-client/typings/integrity-check-result.model.ts +43 -0
  286. package/src/shared/worker-client/typings/migrate-result.model.ts +11 -0
  287. package/src/shared/worker-client/typings/rebuild-result.model.ts +12 -0
  288. package/src/shared/worker-client/typings/remove-section-result.model.ts +7 -0
  289. package/src/shared/worker-client/typings/search-params.model.ts +12 -0
  290. package/src/shared/worker-client/typings/search-result.model.ts +14 -0
  291. package/src/shared/worker-client/typings/section.model.ts +27 -0
  292. package/src/shared/worker-client/typings/status-result.model.ts +14 -0
  293. package/src/shared/worker-client/typings/version-status.model.ts +28 -0
  294. package/src/shared/worker-client/typings/worker-client-error.interface.ts +8 -0
  295. package/src/shared/worker-client/typings/worker-client-options.interface.ts +30 -0
  296. package/src/shared/worker-daemon/classes/worker-daemon.class.ts +1001 -0
  297. package/src/shared/worker-daemon/constants/daemon-defaults.constant.ts +29 -0
  298. package/src/shared/worker-daemon/functions/create-host-imports.function.ts +312 -0
  299. package/src/shared/worker-daemon/functions/create-ipc-server.function.ts +83 -0
  300. package/src/shared/worker-daemon/functions/load-wasm-modules.function.ts +98 -0
  301. package/src/shared/worker-daemon/functions/read-config.function.ts +83 -0
  302. package/src/shared/worker-daemon/functions/run-worker.function.ts +57 -0
  303. package/src/shared/worker-daemon/functions/start-daemon.function.ts +74 -0
  304. package/src/shared/worker-daemon/index.ts +16 -0
  305. package/src/shared/worker-daemon/typings/daemon-config.interface.ts +13 -0
  306. package/src/shared/worker-daemon/typings/ipc-handler.interface.ts +39 -0
  307. package/src/shared/worker-daemon/typings/wasm-modules.interface.ts +7 -0
  308. package/src/worker.ts +34 -0
@@ -0,0 +1,41 @@
1
+ import type { McpPrompt } from '../typings/prompt-types.interface.ts';
2
+ /** Minimal skill section record shape required by this function. */
3
+ interface SkillSectionRecord {
4
+ /** Knowledge-base identifier of the section. */
5
+ readonly kbid: string;
6
+ /** Human-readable section title used as the prompt name. */
7
+ readonly title: string | null;
8
+ /** JSON-encoded skill definition content. */
9
+ readonly content: string;
10
+ /** Optional human-readable section description. */
11
+ readonly description?: string | null;
12
+ }
13
+ /** Minimal document manifest shape required by this function. */
14
+ interface AgentDocumentRecord {
15
+ /** Unique document identifier. */
16
+ readonly docid: string;
17
+ /** Human-readable document title used in the prompt name. */
18
+ readonly title: string;
19
+ /** Ordered section references belonging to the document. */
20
+ readonly sections: readonly {
21
+ readonly kbid: string;
22
+ readonly position: number;
23
+ }[];
24
+ }
25
+ /**
26
+ * Builds the list of MCP prompt definitions from skill sections and
27
+ * agent document manifests stored in the knowledge base.
28
+ *
29
+ * Skills are mapped first (in input order), followed by agents.
30
+ * Each skill becomes a prompt whose name is the section title and
31
+ * whose arguments are extracted from the JSON content. Each agent
32
+ * becomes a prompt prefixed with `"agent:"` and carries an empty
33
+ * arguments array.
34
+ *
35
+ * @param skills - skill section records from `listByType('skill')`
36
+ * @param agents - agent document manifests from
37
+ * `listDocumentsByType('agent')`
38
+ * @returns ordered list of MCP prompt definitions
39
+ */
40
+ export declare function createPromptDefinitions(skills: readonly SkillSectionRecord[], agents: readonly AgentDocumentRecord[]): McpPrompt[];
41
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { McpResourceTemplate } from '../typings/mcp-types.interface.ts';
2
+ /**
3
+ * Returns the list of MCP resource URI templates served by the
4
+ * knowledge-base server. Each template describes the URI pattern,
5
+ * human-readable metadata, and the MIME type of the resource body.
6
+ */
7
+ export declare function createResourceTemplates(): McpResourceTemplate[];
@@ -0,0 +1,7 @@
1
+ import type { McpToolDefinition } from '../typings/mcp-types.interface.ts';
2
+ /**
3
+ * Returns the full list of MCP tool definitions exposed by the
4
+ * knowledge-base server. Each definition includes the tool name,
5
+ * a human-readable description, and a JSON Schema for its inputs.
6
+ */
7
+ export declare function createToolDefinitions(): McpToolDefinition[];
@@ -0,0 +1,13 @@
1
+ import type { SkillArgument } from '../typings/skill-types.interface.ts';
2
+ /**
3
+ * Extracts `{{argName}}` placeholder names from a skill body string
4
+ * and returns them as `SkillArgument` objects marked as required.
5
+ *
6
+ * Each placeholder is included only once regardless of how many
7
+ * times it appears, and the returned array preserves the order of
8
+ * first occurrence.
9
+ *
10
+ * @param body - skill body template text to scan for placeholders
11
+ * @returns ordered, deduplicated list of argument definitions
12
+ */
13
+ export declare function extractSkillArguments(body: string): SkillArgument[];
@@ -0,0 +1,29 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ /** Shape of a content item in an MCP tool call response. */
3
+ interface ToolContent {
4
+ /** Content type identifier, typically `'text'`. */
5
+ readonly type: string;
6
+ /** The text payload. */
7
+ readonly text: string;
8
+ }
9
+ /** Result returned by the agent-create tool handler. */
10
+ interface ToolCallResult {
11
+ /** One or more content items describing the result. */
12
+ readonly content: ToolContent[];
13
+ /** Set to `true` when the tool encountered an error. */
14
+ readonly isError?: boolean;
15
+ }
16
+ /**
17
+ * Handles the `agent:create` MCP tool call.
18
+ *
19
+ * Validates required arguments, verifies that referenced skill kbids
20
+ * exist, stores agent metadata as a JSON section, groups all sections
21
+ * into a single document, and returns the resulting document
22
+ * identifier.
23
+ *
24
+ * @param client - the worker client used to execute operations
25
+ * @param args - tool arguments from the MCP request
26
+ * @returns content items with optional `isError` flag
27
+ */
28
+ export declare function handleAgentCreate(client: McpWorkerClient, args: Record<string, unknown>): Promise<ToolCallResult>;
29
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ /** Shape of a content item in an MCP tool call response. */
3
+ interface ToolContent {
4
+ /** Content type identifier, typically `'text'`. */
5
+ readonly type: string;
6
+ /** The text payload. */
7
+ readonly text: string;
8
+ }
9
+ /** Result returned by the agent-delete tool handler. */
10
+ interface ToolCallResult {
11
+ /** One or more content items describing the result. */
12
+ readonly content: ToolContent[];
13
+ /** Set to `true` when the tool encountered an error. */
14
+ readonly isError?: boolean;
15
+ }
16
+ /**
17
+ * Handles the `agent:delete` MCP tool call.
18
+ *
19
+ * Removes the document grouping identified by `docid`. The skill
20
+ * sections referenced by the agent are not deleted; only the grouping
21
+ * record is removed.
22
+ *
23
+ * @param client - the worker client used to execute operations
24
+ * @param args - tool arguments; must include a `docid` string
25
+ * @returns content items confirming removal, or an error item
26
+ */
27
+ export declare function handleAgentDelete(client: McpWorkerClient, args: Record<string, unknown>): Promise<ToolCallResult>;
28
+ export {};
@@ -0,0 +1,29 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ /** Shape of a content item in an MCP tool call response. */
3
+ interface ToolContent {
4
+ /** Content type identifier, typically `'text'`. */
5
+ readonly type: string;
6
+ /** The text payload. */
7
+ readonly text: string;
8
+ }
9
+ /** Result returned by the agent-get tool handler. */
10
+ interface ToolCallResult {
11
+ /** One or more content items describing the result. */
12
+ readonly content: ToolContent[];
13
+ /** Set to `true` when the tool encountered an error. */
14
+ readonly isError?: boolean;
15
+ }
16
+ /**
17
+ * Handles the `agent:get` MCP tool call.
18
+ *
19
+ * Retrieves an agent document by its `docid`, reads the metadata
20
+ * section and skill references, and returns a full `AgentDefinition`.
21
+ * Dangling skill references (sections that no longer exist) appear
22
+ * with `name: null` in the skills list.
23
+ *
24
+ * @param client - the worker client used to execute operations
25
+ * @param args - tool arguments; must include a `docid` string
26
+ * @returns content items containing the serialised `AgentDefinition`
27
+ */
28
+ export declare function handleAgentGet(client: McpWorkerClient, args: Record<string, unknown>): Promise<ToolCallResult>;
29
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ /** Shape of a content item in an MCP tool call response. */
3
+ interface ToolContent {
4
+ /** Content type identifier, typically `'text'`. */
5
+ readonly type: string;
6
+ /** The text payload. */
7
+ readonly text: string;
8
+ }
9
+ /** Result returned by the agent-list tool handler. */
10
+ interface ToolCallResult {
11
+ /** One or more content items describing the result. */
12
+ readonly content: ToolContent[];
13
+ /** Set to `true` when the tool encountered an error. */
14
+ readonly isError?: boolean;
15
+ }
16
+ /**
17
+ * Handles the `agent:list` MCP tool call.
18
+ *
19
+ * Retrieves all documents with `doc_type: 'agent'` and returns a
20
+ * summary list containing each agent's document identifier, name,
21
+ * and skill count.
22
+ *
23
+ * The `skillCount` is `Math.max(0, sections.length - 1)` because
24
+ * the first section of an agent document always holds the metadata
25
+ * JSON and does not count as a skill reference.
26
+ *
27
+ * @param client - the worker client used to execute operations
28
+ * @returns content items with the serialised agent list
29
+ */
30
+ export declare function handleAgentList(client: McpWorkerClient): Promise<ToolCallResult>;
31
+ export {};
@@ -0,0 +1,58 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ /**
3
+ * Discriminated reference used in MCP completion requests.
4
+ * Identifies whether the completion target is a prompt or a resource.
5
+ */
6
+ export interface McpCompletionRef {
7
+ /**
8
+ * The reference type: `'ref/prompt'` for named prompts (skills
9
+ * and agents) or `'ref/resource'` for resource URIs.
10
+ */
11
+ readonly type: 'ref/prompt' | 'ref/resource';
12
+ /** Prompt name, present when `type` is `'ref/prompt'`. */
13
+ readonly name?: string;
14
+ /** Resource URI, present when `type` is `'ref/resource'`. */
15
+ readonly uri?: string;
16
+ }
17
+ /**
18
+ * Completion argument supplied by the client, describing which
19
+ * argument is being completed and the current partial value.
20
+ */
21
+ export interface McpCompletionArgument {
22
+ /** The argument name being completed. */
23
+ readonly name: string;
24
+ /** The partial value typed so far; used for prefix filtering. */
25
+ readonly value: string;
26
+ }
27
+ /**
28
+ * Result returned by `handleCompletion`, containing the list of
29
+ * matching completion values and pagination metadata.
30
+ */
31
+ export interface McpCompletionResult {
32
+ /** Completion payload. */
33
+ readonly completion: {
34
+ /** Matching completion strings for the given prefix. */
35
+ readonly values: string[];
36
+ /**
37
+ * Whether more results are available beyond what is returned.
38
+ * Always `false` in this implementation.
39
+ */
40
+ readonly hasMore: boolean;
41
+ /** Total number of values returned. */
42
+ readonly total: number;
43
+ };
44
+ }
45
+ /**
46
+ * Handles an MCP `completion/complete` request.
47
+ *
48
+ * For `ref/prompt` references, builds a list of all skill titles and
49
+ * agent titles (prefixed with `agent:`) and filters by the supplied
50
+ * argument value prefix. For `ref/resource` references, returns an
51
+ * empty result — resource completion is not implemented.
52
+ *
53
+ * @param ref - discriminated reference identifying the completion target
54
+ * @param argument - current argument name and partial value
55
+ * @param client - worker client used to fetch skills and agents
56
+ * @returns matching completion values with pagination metadata
57
+ */
58
+ export declare function handleCompletion(ref: McpCompletionRef, argument: McpCompletionArgument, client: McpWorkerClient): Promise<McpCompletionResult>;
@@ -0,0 +1,23 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ import type { McpPromptMessage } from '../typings/prompt-types.interface.ts';
3
+ /**
4
+ * Handles an MCP `prompts/get` request.
5
+ *
6
+ * Dispatches to the agent handler when `name` starts with `"agent:"`,
7
+ * otherwise treats the name as a skill prompt.
8
+ *
9
+ * For skill prompts: looks up by title using `listByType('skill')`,
10
+ * substitutes `{{argName}}` placeholders in the body, and returns a
11
+ * single user message.
12
+ *
13
+ * For agent prompts: reads the agent document via `retrieveDocument`,
14
+ * builds an assistant message from the persona section, and (when
15
+ * skills exist) a user message listing their names and descriptions.
16
+ *
17
+ * @param name - prompt name from the MCP request
18
+ * @param promptArgs - argument key-value map from the MCP request
19
+ * @param client - worker client used to access the knowledge base
20
+ * @returns ordered list of prompt messages to return to the caller
21
+ * @throws {Error} when a skill prompt name is not found in the store
22
+ */
23
+ export declare function handlePromptGet(name: string, promptArgs: Record<string, string>, client: McpWorkerClient): Promise<McpPromptMessage[]>;
@@ -0,0 +1,26 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ /** A single content item in an MCP resource read response. */
3
+ interface ResourceContent {
4
+ /** The resource URI that was read. */
5
+ readonly uri: string;
6
+ /** MIME type of the content body. */
7
+ readonly mimeType: string;
8
+ /** Text body of the resource. */
9
+ readonly text: string;
10
+ }
11
+ /** Result returned by a resource read operation. */
12
+ interface ResourceReadResult {
13
+ /** One or more content items for the requested URI. */
14
+ readonly contents: ResourceContent[];
15
+ }
16
+ /**
17
+ * Handles an MCP `resources/read` request by dispatching to the
18
+ * appropriate knowledge-base operation based on the resource URI.
19
+ *
20
+ * @param client - the worker client used to fetch the resource
21
+ * @param uri - the resource URI from the MCP request
22
+ * @returns contents array for the MCP response
23
+ * @throws {Error} when the URI does not match any known pattern
24
+ */
25
+ export declare function handleResourceRead(client: McpWorkerClient, uri: string): Promise<ResourceReadResult>;
26
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Represents a single file-system root entry advertised to MCP
3
+ * clients via the `roots/list` response.
4
+ */
5
+ export interface McpRoot {
6
+ /** Absolute file URI for the root directory. */
7
+ readonly uri: string;
8
+ /** Human-readable label for the root. */
9
+ readonly name: string;
10
+ }
11
+ /**
12
+ * Returns the list of MCP roots for the given database context path.
13
+ *
14
+ * Produces a single root entry whose URI is `file://` concatenated
15
+ * with the supplied `contextPath`. This tells MCP clients which
16
+ * file-system directory the server is authoritative for.
17
+ *
18
+ * @param contextPath - absolute path to the kbdb database directory
19
+ * @returns array containing a single root for the context path
20
+ */
21
+ export declare function handleRootsList(contextPath: string): McpRoot[];
@@ -0,0 +1,26 @@
1
+ import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
2
+ /** Shape of a content item in an MCP tool call response. */
3
+ interface ToolContent {
4
+ /** Content type identifier, typically 'text'. */
5
+ readonly type: string;
6
+ /** The text payload. */
7
+ readonly text: string;
8
+ }
9
+ /** Result returned by a tool call handler. */
10
+ interface ToolCallResult {
11
+ /** One or more content items describing the result. */
12
+ readonly content: ToolContent[];
13
+ /** Set to `true` when the tool encountered an error. */
14
+ readonly isError?: boolean;
15
+ }
16
+ /**
17
+ * Dispatches an MCP tool call to the appropriate knowledge-base
18
+ * operation and returns the result formatted as MCP content.
19
+ *
20
+ * @param client - the worker client used to execute operations
21
+ * @param name - the tool name to invoke
22
+ * @param args - tool arguments from the MCP request
23
+ * @returns content items with optional isError flag
24
+ */
25
+ export declare function handleToolCall(client: McpWorkerClient, name: string, args: Record<string, unknown>): Promise<ToolCallResult>;
26
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { SkillDefinition } from '../typings/skill-types.interface.ts';
2
+ /**
3
+ * Parses a JSON string into a `SkillDefinition`.
4
+ *
5
+ * Validates that the required `name` and `body` fields are present
6
+ * and are non-empty strings, then returns the full definition
7
+ * including optional `description` and `arguments`.
8
+ *
9
+ * @param json - JSON string representing a serialized skill
10
+ * @returns the parsed skill definition
11
+ * @throws {SyntaxError} when `json` is not valid JSON
12
+ * @throws {Error} when `name` is missing or empty
13
+ * @throws {Error} when `body` is missing or not a string
14
+ */
15
+ export declare function parseSkillContent(json: string): SkillDefinition;
@@ -0,0 +1,9 @@
1
+ import type { SkillDefinition } from '../typings/skill-types.interface.ts';
2
+ /**
3
+ * Serializes a `SkillDefinition` to a JSON string suitable for
4
+ * storage as a knowledge-base section's `content` field.
5
+ *
6
+ * @param skill - skill definition to serialize
7
+ * @returns JSON string representation of the skill
8
+ */
9
+ export declare function serializeSkillContent(skill: SkillDefinition): string;
@@ -0,0 +1,20 @@
1
+ import type { McpLogLevel } from '../typings/log-types.interface.ts';
2
+ /**
3
+ * Ordered list of MCP log severity levels, from least severe
4
+ * (`debug`) to most severe (`emergency`). Used to compare levels
5
+ * when filtering log output.
6
+ */
7
+ export declare const LOG_LEVEL_ORDER: McpLogLevel[];
8
+ /**
9
+ * Determines whether a log message at `messageLevel` should be
10
+ * emitted when the server's log threshold is `threshold`.
11
+ *
12
+ * Returns `true` when `messageLevel` is at the same severity as
13
+ * `threshold` or higher. Returns `false` when the message level is
14
+ * below the threshold.
15
+ *
16
+ * @param messageLevel - severity of the log message to evaluate
17
+ * @param threshold - minimum severity level required to emit
18
+ * @returns `true` if the message meets or exceeds the threshold
19
+ */
20
+ export declare function shouldEmitLog(messageLevel: McpLogLevel, threshold: McpLogLevel): boolean;
@@ -0,0 +1,9 @@
1
+ export { McpServer } from './classes/mcp-server.class.ts';
2
+ export { createMcpServer } from './functions/create-mcp-server.function.ts';
3
+ export { createToolDefinitions } from './functions/create-tool-definitions.function.ts';
4
+ export { createResourceTemplates } from './functions/create-resource-templates.function.ts';
5
+ export { handleToolCall } from './functions/handle-tool-call.function.ts';
6
+ export { handleResourceRead } from './functions/handle-resource-read.function.ts';
7
+ export { PARSE_ERROR, METHOD_NOT_FOUND, INVALID_PARAMS, INTERNAL_ERROR, RESOURCE_NOT_FOUND, } from './constants/mcp-error-codes.constant.ts';
8
+ export type { McpRequest, McpResponse, McpNotification, McpToolDefinition, McpResourceTemplate, McpServerInfo, McpCapabilities, McpToolResult, McpResourceResult, } from './typings/mcp-types.interface.ts';
9
+ export type { McpWorkerClient, RemoveSectionResult, } from './typings/mcp-client.interface.ts';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A reference from an agent document to a skill section,
3
+ * carrying the skill's position within the agent's ordered
4
+ * skill list.
5
+ */
6
+ export interface AgentSkillRef {
7
+ /** Knowledge-base identifier of the referenced skill section. */
8
+ readonly kbid: string;
9
+ /**
10
+ * Human-readable name of the skill, or `null` when the
11
+ * referenced section no longer exists (dangling reference).
12
+ */
13
+ readonly name: string | null;
14
+ /** Zero-based position of this skill within the agent's list. */
15
+ readonly position: number;
16
+ }
17
+ /**
18
+ * Full definition of an agent, including its persona text and
19
+ * ordered list of skill references.
20
+ */
21
+ export interface AgentDefinition {
22
+ /** Unique document identifier for the agent. */
23
+ readonly docid: string;
24
+ /** Human-readable name of the agent. */
25
+ readonly name: string;
26
+ /**
27
+ * Short description of what the agent does, used for discovery
28
+ * and disambiguation.
29
+ */
30
+ readonly description: string;
31
+ /**
32
+ * Persona text that governs how the agent behaves when
33
+ * executing tasks.
34
+ */
35
+ readonly persona: string;
36
+ /** Ordered list of skill references the agent can delegate to. */
37
+ readonly skills: readonly AgentSkillRef[];
38
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Severity levels for MCP log messages, ordered from least severe
3
+ * (`debug`) to most severe (`emergency`).
4
+ */
5
+ export type McpLogLevel = 'debug' | 'info' | 'notice' | 'warning' | 'error' | 'critical' | 'alert' | 'emergency';
6
+ /**
7
+ * A structured log message emitted by the MCP server via the
8
+ * `notifications/message` notification method.
9
+ */
10
+ export interface McpLogMessage {
11
+ /** Severity level of the log entry. */
12
+ readonly level: McpLogLevel;
13
+ /** Optional logger name identifying the source component. */
14
+ readonly logger?: string;
15
+ /** Optional structured payload associated with the log entry. */
16
+ readonly data?: unknown;
17
+ }