@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,252 @@
1
+ import type { AddSectionResult } from '../../worker-client/typings/add-section-result.model.ts';
2
+ import type { RemoveSectionResult } from './remove-section-result.model.ts';
3
+ import type { SectionRecord } from '../../wasm-codec/functions/decode-section-records.function.ts';
4
+ import type { DocumentManifest } from '../../wasm-codec/functions/decode-document-manifest.function.ts';
5
+
6
+ /** Result returned by content composition. */
7
+ export interface McpContentResult {
8
+ /** MIME type of the composed output, always `'text/markdown'`. */
9
+ readonly type: 'text/markdown';
10
+ /** The composed Markdown string. */
11
+ readonly data: string;
12
+ /** Character count of `data` (not byte count). */
13
+ readonly total: number;
14
+ }
15
+
16
+ /** A single integrity error found during a database check. */
17
+ export interface McpIntegrityError {
18
+ /** The category of integrity violation detected. */
19
+ readonly type:
20
+ | 'checksum_mismatch'
21
+ | 'orphan_section'
22
+ | 'orphan_document'
23
+ | 'broken_reference'
24
+ | 'type_mismatch'
25
+ | 'circular_reference';
26
+ /** Identifier of the entity (kbid or docid) that has the issue. */
27
+ readonly entity: string;
28
+ /** Human-readable description of the specific problem. */
29
+ readonly detail: string;
30
+ }
31
+
32
+ /** Integrity check report returned by the daemon. */
33
+ export interface McpIntegrityCheckResult {
34
+ /** `true` when all checks passed and no errors were found. */
35
+ readonly ok: boolean;
36
+ /** All integrity errors found; empty when `ok` is `true`. */
37
+ readonly errors: McpIntegrityError[];
38
+ /** Total number of sections examined. */
39
+ readonly sections_checked: number;
40
+ /** Total number of documents examined. */
41
+ readonly documents_checked: number;
42
+ /** Total number of marker references checked. */
43
+ readonly references_checked: number;
44
+ /** Time taken to complete the check, in milliseconds. */
45
+ readonly elapsed_ms: number;
46
+ }
47
+
48
+ /** Garbage collection report returned by the daemon. */
49
+ export interface McpGcResult {
50
+ /** Number of unreferenced sections removed. */
51
+ readonly removed_sections: number;
52
+ /** Total bytes freed by removing unreferenced sections. */
53
+ readonly removed_bytes: number;
54
+ /** Time taken to complete garbage collection, in milliseconds. */
55
+ readonly elapsed_ms: number;
56
+ }
57
+
58
+ /** Index rebuild report returned by the daemon. */
59
+ export interface McpRebuildResult {
60
+ /** Number of text and code sections that were re-indexed. */
61
+ readonly sections_reindexed: number;
62
+ /** Total number of unique terms written to the rebuilt indexes. */
63
+ readonly terms_indexed: number;
64
+ /** Time taken to complete the rebuild, in milliseconds. */
65
+ readonly elapsed_ms: number;
66
+ }
67
+
68
+ /**
69
+ * Interface for the worker client dependency consumed by the MCP
70
+ * server. Defines the knowledge-base operations the server exposes
71
+ * as MCP tools and resources without coupling to the concrete
72
+ * `WorkerClient` class.
73
+ */
74
+ export interface McpWorkerClient {
75
+ /**
76
+ * Searches the knowledge base using the given parameters.
77
+ *
78
+ * @param params - query string and optional search options
79
+ * @returns ranked list of matching section summaries
80
+ */
81
+ search(params: {
82
+ /** Natural language query text. */
83
+ readonly query: string;
84
+ /** Search mode: 'sections', 'documents', or 'stats'. */
85
+ readonly mode?: string;
86
+ /** Maximum number of results to return. */
87
+ readonly limit?: number;
88
+ }): Promise<
89
+ {
90
+ /** Knowledge-base identifier of the matched section. */
91
+ kbid: string;
92
+ /** Relevance score assigned by the ranking engine. */
93
+ score: number;
94
+ /** Terms that matched within this section. */
95
+ readonly matches: readonly {
96
+ /** The matched term. */
97
+ readonly term: string;
98
+ /** Number of times the term appears in the section. */
99
+ readonly frequency: number;
100
+ }[];
101
+ }[]
102
+ >;
103
+
104
+ /**
105
+ * Adds a new section to the knowledge base.
106
+ *
107
+ * @param params - content type, raw content, and optional metadata
108
+ * @returns the assigned knowledge-base identifier
109
+ */
110
+ addSection(params: {
111
+ /** Semantic type label for the section content. */
112
+ readonly sectionType: string;
113
+ /** Raw text or base64-encoded content for the section. */
114
+ readonly content: string;
115
+ /** Optional section title. Required for image/* types. */
116
+ readonly title?: string;
117
+ /** Optional section description. */
118
+ readonly description?: string;
119
+ /** Optional document ID to group this section under. */
120
+ readonly docid?: string;
121
+ }): Promise<AddSectionResult>;
122
+
123
+ /**
124
+ * Removes a section from the knowledge base.
125
+ *
126
+ * @param kbid - knowledge-base identifier of the section to remove
127
+ * @returns removal result with `removed` flag and elapsed time
128
+ */
129
+ removeSection(kbid: string): Promise<RemoveSectionResult>;
130
+
131
+ /**
132
+ * Retrieves one or more sections by their identifiers.
133
+ *
134
+ * @param kbids - list of knowledge-base identifiers to fetch
135
+ * @returns sections in the order their IDs were requested
136
+ */
137
+ readSections(kbids: string[]): Promise<
138
+ {
139
+ /** Knowledge-base identifier for this section. */
140
+ kbid: string;
141
+ /** Semantic type label assigned to the section. */
142
+ sectionType: string;
143
+ /** Raw text content of the section. */
144
+ content: string;
145
+ /** Byte size of the stored content. */
146
+ size: number;
147
+ }[]
148
+ >;
149
+
150
+ /**
151
+ * Retrieves a full document record including its ordered sections.
152
+ *
153
+ * @param docid - identifier of the document to retrieve
154
+ * @returns the document record as returned by the daemon
155
+ */
156
+ retrieveDocument(docid: string): Promise<unknown>;
157
+
158
+ /**
159
+ * Composes a rendered Markdown document from one or more kbid
160
+ * or docid identifiers.
161
+ *
162
+ * @param ids - list of kbid or docid identifiers (may be mixed)
163
+ * @returns composed Markdown result with character count
164
+ */
165
+ content(ids: string[]): Promise<McpContentResult>;
166
+
167
+ /**
168
+ * Returns database metadata and status from the daemon.
169
+ *
170
+ * @returns document count, section count, and timing statistics
171
+ */
172
+ dbStatus(): Promise<{
173
+ /** Whether the daemon has finished loading its WASM modules. */
174
+ initialized: boolean;
175
+ /** Absolute path to the context directory the daemon serves. */
176
+ contextPath: string;
177
+ /** In-memory cache statistics. */
178
+ cacheStats: {
179
+ /** Number of content entries currently cached. */
180
+ contentCount: number;
181
+ /** Number of index entries currently cached. */
182
+ indexCount: number;
183
+ };
184
+ }>;
185
+
186
+ /**
187
+ * Runs an integrity check on the knowledge-base database.
188
+ *
189
+ * @returns a report of all issues found; `ok` is `true` when
190
+ * no errors were detected
191
+ */
192
+ integrityCheck(): Promise<McpIntegrityCheckResult>;
193
+
194
+ /**
195
+ * Removes unreferenced sections from the database.
196
+ *
197
+ * @returns a report of sections removed and bytes freed
198
+ */
199
+ gc(): Promise<McpGcResult>;
200
+
201
+ /**
202
+ * Reconstructs all index files from section files and document
203
+ * manifests on disk.
204
+ *
205
+ * @returns a report of sections and terms re-indexed
206
+ */
207
+ rebuildIndexes(): Promise<McpRebuildResult>;
208
+
209
+ /**
210
+ * Retrieves all sections whose type name matches the given string.
211
+ *
212
+ * @param sectionType - the application-level type name to filter by
213
+ * @returns all section records with a matching type name
214
+ */
215
+ listByType(sectionType: string): Promise<SectionRecord[]>;
216
+
217
+ /**
218
+ * Retrieves all documents whose type name matches the given string.
219
+ *
220
+ * @param docType - the application-level document type to filter by
221
+ * @returns all document manifests with a matching type name
222
+ */
223
+ listDocumentsByType(docType: string): Promise<DocumentManifest[]>;
224
+
225
+ /**
226
+ * Groups a set of sections under a named document.
227
+ *
228
+ * @param title - human-readable document title
229
+ * @param kbids - identifiers of the sections to group
230
+ * @returns the assigned document identifier
231
+ */
232
+ groupSections(
233
+ title: string,
234
+ kbids: string[],
235
+ docType?: string,
236
+ ): Promise<string>;
237
+
238
+ /**
239
+ * Removes the document grouping for the given document.
240
+ *
241
+ * The sections themselves are not deleted; only the grouping
242
+ * record is removed.
243
+ *
244
+ * @param docid - identifier of the document grouping to remove
245
+ */
246
+ removeGrouping(docid: string): Promise<void>;
247
+
248
+ /** Destroys the IPC socket and clears the connection state. */
249
+ disconnect(): void;
250
+ }
251
+
252
+ export type { RemoveSectionResult };
@@ -0,0 +1,158 @@
1
+ /** A JSON-RPC 2.0 request message sent to the MCP server. */
2
+ export interface McpRequest {
3
+ /** JSON-RPC protocol version. Must always be '2.0'. */
4
+ readonly jsonrpc: '2.0';
5
+ /** Request identifier; absent for notifications. */
6
+ readonly id?: number | string;
7
+ /** RPC method name. */
8
+ readonly method: string;
9
+ /** Optional method parameters. */
10
+ readonly params?: Record<string, unknown>;
11
+ }
12
+
13
+ /** A JSON-RPC 2.0 response message sent from the MCP server. */
14
+ export interface McpResponse {
15
+ /** JSON-RPC protocol version. Must always be '2.0'. */
16
+ readonly jsonrpc: '2.0';
17
+ /** Echoes the request identifier. */
18
+ readonly id: number | string;
19
+ /** Successful result payload; absent when error is set. */
20
+ readonly result?: unknown;
21
+ /** Error payload; absent when result is set. */
22
+ readonly error?: {
23
+ /** Numeric error code as defined by JSON-RPC or MCP. */
24
+ readonly code: number;
25
+ /** Human-readable error message. */
26
+ readonly message: string;
27
+ /** Optional additional error data. */
28
+ readonly data?: unknown;
29
+ };
30
+ }
31
+
32
+ /** A JSON-RPC 2.0 notification with no expected response. */
33
+ export interface McpNotification {
34
+ /** JSON-RPC protocol version. Must always be '2.0'. */
35
+ readonly jsonrpc: '2.0';
36
+ /** Notification method name. */
37
+ readonly method: string;
38
+ /** Optional notification parameters. */
39
+ readonly params?: Record<string, unknown>;
40
+ }
41
+
42
+ /**
43
+ * Optional behavioral hints for an MCP tool, used by clients to
44
+ * decide how to present or invoke the tool safely.
45
+ */
46
+ export interface McpToolAnnotations {
47
+ /**
48
+ * Human-readable title for the tool, suitable for display
49
+ * in client UIs.
50
+ */
51
+ readonly title?: string;
52
+ /**
53
+ * When `true`, the tool only reads data and does not modify
54
+ * any server-side state.
55
+ */
56
+ readonly readOnlyHint?: boolean;
57
+ /**
58
+ * When `true`, the tool may cause data loss or irreversible
59
+ * changes.
60
+ */
61
+ readonly destructiveHint?: boolean;
62
+ /**
63
+ * When `true`, calling the tool multiple times with the same
64
+ * arguments produces the same result with no additional side
65
+ * effects.
66
+ */
67
+ readonly idempotentHint?: boolean;
68
+ /**
69
+ * When `true`, the tool may interact with systems or data
70
+ * outside the immediate knowledge base context.
71
+ */
72
+ readonly openWorldHint?: boolean;
73
+ }
74
+
75
+ /** Definition of a single MCP tool exposed by the server. */
76
+ export interface McpToolDefinition {
77
+ /** Unique tool name used to invoke it. */
78
+ readonly name: string;
79
+ /** Human-readable description of what the tool does. */
80
+ readonly description: string;
81
+ /** JSON Schema object describing the tool's input parameters. */
82
+ readonly inputSchema: Record<string, unknown>;
83
+ /**
84
+ * Optional behavioral hints that describe how the tool
85
+ * interacts with state.
86
+ */
87
+ readonly annotations?: McpToolAnnotations;
88
+ }
89
+
90
+ /** A URI template describing an MCP resource the server serves. */
91
+ export interface McpResourceTemplate {
92
+ /** RFC 6570 URI template for the resource. */
93
+ readonly uriTemplate: string;
94
+ /** Human-readable resource name. */
95
+ readonly name: string;
96
+ /** Human-readable description of the resource. */
97
+ readonly description: string;
98
+ /** Optional MIME type for the resource content. */
99
+ readonly mimeType?: string;
100
+ }
101
+
102
+ /** Identity information for the MCP server. */
103
+ export interface McpServerInfo {
104
+ /** Server name reported during MCP initialization. */
105
+ readonly name: string;
106
+ /** Server version string reported during MCP initialization. */
107
+ readonly version: string;
108
+ }
109
+
110
+ /** MCP capability flags advertised during initialization. */
111
+ export interface McpCapabilities {
112
+ /** Indicates the server supports the tools capability. */
113
+ readonly tools?: Record<string, unknown>;
114
+ /** Indicates the server supports the resources capability. */
115
+ readonly resources?: Record<string, unknown>;
116
+ /** Indicates the server supports the prompts capability. */
117
+ readonly prompts?: Record<string, unknown>;
118
+ /** Indicates the server supports the logging capability. */
119
+ readonly logging?: Record<string, unknown>;
120
+ /**
121
+ * Indicates the server supports the completions capability,
122
+ * providing argument auto-completion for prompts and resources.
123
+ */
124
+ readonly completions?: Record<string, unknown>;
125
+ }
126
+
127
+ /**
128
+ * Result returned by `handleToolCall`. Successful tool responses
129
+ * carry `isError: true` for application-level failures rather than
130
+ * using JSON-RPC error responses.
131
+ */
132
+ export interface McpToolResult {
133
+ /** One or more text content items describing the result. */
134
+ readonly content: readonly {
135
+ /** Content type identifier, always 'text'. */
136
+ readonly type: string;
137
+ /** Text payload of the content item. */
138
+ readonly text: string;
139
+ }[];
140
+ /**
141
+ * Set to `true` when the tool encountered an application-level
142
+ * error. Absent or `false` on success.
143
+ */
144
+ readonly isError?: boolean;
145
+ }
146
+
147
+ /** Result returned by `handleResourceRead`. */
148
+ export interface McpResourceResult {
149
+ /** One or more content items for the requested resource URI. */
150
+ readonly contents: readonly {
151
+ /** The resource URI that was read. */
152
+ readonly uri: string;
153
+ /** MIME type of the content body. */
154
+ readonly mimeType: string;
155
+ /** Text body of the resource. */
156
+ readonly text: string;
157
+ }[];
158
+ }
@@ -0,0 +1,39 @@
1
+ /** A single argument definition for an MCP prompt. */
2
+ export interface McpPromptArgument {
3
+ /** Argument name used as the placeholder key. */
4
+ readonly name: string;
5
+ /** Human-readable description of the argument. */
6
+ readonly description?: string;
7
+ /** Whether the argument must be supplied at invocation time. */
8
+ readonly required?: boolean;
9
+ }
10
+
11
+ /** An MCP prompt entry returned by `prompts/list`. */
12
+ export interface McpPrompt {
13
+ /** Unique prompt name used to invoke it via `prompts/get`. */
14
+ readonly name: string;
15
+ /** Human-readable description of what the prompt does. */
16
+ readonly description?: string;
17
+ /**
18
+ * Declared arguments the prompt accepts.
19
+ * Absent or empty when the prompt takes no arguments.
20
+ */
21
+ readonly arguments?: readonly McpPromptArgument[];
22
+ }
23
+
24
+ /** A single message in an MCP prompt response. */
25
+ export interface McpPromptMessage {
26
+ /**
27
+ * Conversation role for this message.
28
+ * `'assistant'` for persona/system context, `'user'` for
29
+ * instructions directed at the model.
30
+ */
31
+ readonly role: 'user' | 'assistant';
32
+ /** Text content of the message. */
33
+ readonly content: {
34
+ /** Content type identifier, always `'text'`. */
35
+ readonly type: 'text';
36
+ /** The text payload. */
37
+ readonly text: string;
38
+ };
39
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Result returned by `McpWorkerClient.removeSection`. Reports
3
+ * whether the section was removed and the elapsed operation time.
4
+ */
5
+ export interface RemoveSectionResult {
6
+ /** `true` when the section was found and removed. */
7
+ readonly removed: boolean;
8
+ /** Elapsed time for the remove operation in milliseconds. */
9
+ readonly elapsed_ms: number;
10
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A single message in an MCP sampling conversation, sent to or
3
+ * received from a language model.
4
+ */
5
+ export interface McpSamplingMessage {
6
+ /** Originating role for this message. */
7
+ readonly role: 'user' | 'assistant';
8
+ /** Text content of the message. */
9
+ readonly content: {
10
+ /** Content type discriminant, always `'text'`. */
11
+ readonly type: 'text';
12
+ /** The text body of the message. */
13
+ readonly text: string;
14
+ };
15
+ }
16
+
17
+ /**
18
+ * Request sent by the MCP server to the client to sample a language
19
+ * model. The client is responsible for selecting the model and
20
+ * forwarding the request.
21
+ */
22
+ export interface McpSamplingRequest {
23
+ /** Ordered list of messages forming the conversation context. */
24
+ readonly messages: readonly McpSamplingMessage[];
25
+ /**
26
+ * Maximum number of tokens the model should generate in its
27
+ * response.
28
+ */
29
+ readonly maxTokens: number;
30
+ }
31
+
32
+ /**
33
+ * Result returned by the client after sampling a language model,
34
+ * containing the assistant's generated response.
35
+ */
36
+ export interface McpSamplingResult {
37
+ /** Role of the response message, always `'assistant'`. */
38
+ readonly role: 'assistant';
39
+ /** Text content generated by the model. */
40
+ readonly content: {
41
+ /** Content type discriminant, always `'text'`. */
42
+ readonly type: 'text';
43
+ /** The generated text response. */
44
+ readonly text: string;
45
+ };
46
+ /** Identifier of the model that produced the response. */
47
+ readonly model: string;
48
+ }
@@ -0,0 +1,29 @@
1
+ /** A single argument definition for a skill. */
2
+ export interface SkillArgument {
3
+ /** Argument name, used as the placeholder key. */
4
+ readonly name: string;
5
+ /** The expected value type. Defaults to `'string'` when omitted. */
6
+ readonly type?: 'string' | 'number' | 'boolean';
7
+ /** Human-readable description of the argument. */
8
+ readonly description?: string;
9
+ /** Whether the argument must be supplied at invocation time. */
10
+ readonly required?: boolean;
11
+ }
12
+
13
+ /** A reusable AI agent capability stored in the knowledge base. */
14
+ export interface SkillDefinition {
15
+ /** Unique skill name used for lookup. */
16
+ readonly name: string;
17
+ /** Human-readable description of the skill. */
18
+ readonly description?: string;
19
+ /**
20
+ * Declared arguments for the skill body template.
21
+ * Extracted from `{{argName}}` placeholders.
22
+ */
23
+ readonly arguments?: readonly SkillArgument[];
24
+ /**
25
+ * Template body of the skill.
26
+ * May contain `{{argName}}` placeholders for variable substitution.
27
+ */
28
+ readonly body: string;
29
+ }
@@ -0,0 +1 @@
1
+ export { VERSION as version } from './version/constants/version.constant.ts';
@@ -0,0 +1,19 @@
1
+ import { join } from 'node:path';
2
+ import { getTmpdir } from './get-tmpdir.function.ts';
3
+
4
+ /**
5
+ * Returns the platform-appropriate IPC socket path for a given
6
+ * context identifier.
7
+ *
8
+ * On Windows, returns a named pipe path (`\\.\pipe\kbdb-<ctx>`).
9
+ * On POSIX systems, returns a Unix domain socket path under the
10
+ * system temp directory (`<tmpdir>/kbdb-<ctx>.sock`).
11
+ *
12
+ * @param ctx - unique context identifier embedded in the path
13
+ */
14
+ export function getIpcPath(ctx: string): string {
15
+ if (process.platform === 'win32') {
16
+ return `\\\\.\\pipe\\kbdb-${ctx}`;
17
+ }
18
+ return join(getTmpdir(), `kbdb-${ctx}.sock`);
19
+ }
@@ -0,0 +1,8 @@
1
+ import { tmpdir } from 'node:os';
2
+
3
+ /**
4
+ * Returns the operating system's default temporary directory path.
5
+ */
6
+ export function getTmpdir(): string {
7
+ return tmpdir();
8
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks whether a process with the given PID is alive.
3
+ *
4
+ * Sends signal `0` to the process, which performs a permission
5
+ * check without sending an actual signal. Returns `true` if the
6
+ * process exists and is reachable, `false` otherwise.
7
+ *
8
+ * @param pid - the process identifier to probe
9
+ */
10
+ export function isProcessAlive(pid: number): boolean {
11
+ try {
12
+ process.kill(pid, 0);
13
+ return true;
14
+ } catch {
15
+ return false;
16
+ }
17
+ }
@@ -0,0 +1,3 @@
1
+ export { getTmpdir } from './functions/get-tmpdir.function.ts';
2
+ export { isProcessAlive } from './functions/is-process-alive.function.ts';
3
+ export { getIpcPath } from './functions/get-ipc-path.function.ts';
@@ -0,0 +1,14 @@
1
+ import type { Runtime } from '../typings/runtime.ts';
2
+
3
+ /**
4
+ * Detects the current JavaScript runtime environment.
5
+ *
6
+ * Returns `'deno'` when the global `Deno` object is present,
7
+ * otherwise returns `'node'`.
8
+ */
9
+ export function detectRuntime(): Runtime {
10
+ if (typeof globalThis !== 'undefined' && 'Deno' in globalThis) {
11
+ return 'deno';
12
+ }
13
+ return 'node';
14
+ }
@@ -0,0 +1,16 @@
1
+ import { detectRuntime } from './detect-runtime.ts';
2
+
3
+ /**
4
+ * Returns the command-line arguments for the current runtime.
5
+ *
6
+ * In Deno, reads `Deno.args`; in Node.js, slices `process.argv`
7
+ * past the interpreter and script entries.
8
+ */
9
+ export function getArgs(): string[] {
10
+ if (detectRuntime() === 'deno') {
11
+ const g = globalThis as Record<string, unknown>;
12
+ const deno = g['Deno'] as { args: string[] } | undefined;
13
+ return deno?.args ?? [];
14
+ }
15
+ return process.argv.slice(2);
16
+ }
@@ -0,0 +1,3 @@
1
+ export { detectRuntime } from './functions/detect-runtime.ts';
2
+ export { getArgs } from './functions/get-args.ts';
3
+ export type { Runtime } from './typings/runtime.ts';
@@ -0,0 +1,2 @@
1
+ /** The runtime environment in which the library is executing. */
2
+ export type Runtime = 'deno' | 'node';
@@ -0,0 +1,2 @@
1
+ /** Current package version, kept in sync with package.json. */
2
+ export const VERSION = '0.1.0';
@@ -0,0 +1 @@
1
+ export { VERSION } from './constants/version.constant.ts';
@@ -0,0 +1,16 @@
1
+ import { decodeString } from './decode-string.function.ts';
2
+ import { decodeU64 } from './decode-u64.function.ts';
3
+
4
+ export interface ComposeOutput {
5
+ markdown: string;
6
+ totalChars: bigint;
7
+ }
8
+
9
+ export function decodeComposeOutput(bytes: Uint8Array): ComposeOutput {
10
+ const md = decodeString(bytes, 0);
11
+ const totalChars = decodeU64(bytes, md.bytesRead);
12
+ return {
13
+ markdown: md.value,
14
+ totalChars: totalChars.value,
15
+ };
16
+ }