@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,70 @@
1
+ import { decodeString } from './decode-string.function.ts';
2
+ import { decodeU32 } from './decode-u32.function.ts';
3
+ import { decodeU64 } from './decode-u64.function.ts';
4
+ import type {
5
+ DocumentManifest,
6
+ DocumentSection,
7
+ } from './decode-document-manifest.function.ts';
8
+
9
+ export type { DocumentManifest, DocumentSection };
10
+
11
+ /**
12
+ * Decodes a WASM byte slice into an array of `DocumentManifest` values.
13
+ *
14
+ * The binary format is: u32 count, followed by count × DocumentManifest
15
+ * entries. Each entry contains: docid (string), title (string),
16
+ * createdAt (u64), docType (string), section count (u32), then each
17
+ * section's kbid (string) and position (u32).
18
+ *
19
+ * @param bytes - raw bytes returned by `worker_list_docs_by_type`
20
+ * @returns decoded array of document manifests, empty when count is zero
21
+ */
22
+ export function decodeDocumentManifestList(
23
+ bytes: Uint8Array,
24
+ ): DocumentManifest[] {
25
+ let offset = 0;
26
+ const count = decodeU32(bytes, offset);
27
+ offset += count.bytesRead;
28
+
29
+ const manifests: DocumentManifest[] = [];
30
+ for (let i = 0; i < count.value; i++) {
31
+ const docid = decodeString(bytes, offset);
32
+ offset += docid.bytesRead;
33
+
34
+ const title = decodeString(bytes, offset);
35
+ offset += title.bytesRead;
36
+
37
+ const createdAt = decodeU64(bytes, offset);
38
+ offset += createdAt.bytesRead;
39
+
40
+ const docType = decodeString(bytes, offset);
41
+ offset += docType.bytesRead;
42
+
43
+ const secCount = decodeU32(bytes, offset);
44
+ offset += secCount.bytesRead;
45
+
46
+ const sections: DocumentSection[] = [];
47
+ for (let j = 0; j < secCount.value; j++) {
48
+ const kbid = decodeString(bytes, offset);
49
+ offset += kbid.bytesRead;
50
+
51
+ const position = decodeU32(bytes, offset);
52
+ offset += position.bytesRead;
53
+
54
+ sections.push({
55
+ kbid: kbid.value,
56
+ position: position.value,
57
+ });
58
+ }
59
+
60
+ manifests.push({
61
+ docid: docid.value,
62
+ title: title.value,
63
+ createdAt: createdAt.value,
64
+ docType: docType.value,
65
+ sections,
66
+ });
67
+ }
68
+
69
+ return manifests;
70
+ }
@@ -0,0 +1,87 @@
1
+ import { decodeString } from './decode-string.function.ts';
2
+ import { decodeU32 } from './decode-u32.function.ts';
3
+ import { decodeU64 } from './decode-u64.function.ts';
4
+
5
+ /**
6
+ * A single section reference within a document manifest.
7
+ *
8
+ * Associates a knowledge-base identifier with the section's
9
+ * ordinal position in the document.
10
+ */
11
+ export interface DocumentSection {
12
+ /** Knowledge-base identifier of the referenced section. */
13
+ kbid: string;
14
+ /** Zero-based position of this section within its document. */
15
+ position: number;
16
+ }
17
+
18
+ /**
19
+ * A document manifest decoded from WASM binary output.
20
+ *
21
+ * Represents a grouped document record with its ordered list of
22
+ * section references as returned by `worker_retrieve_doc`.
23
+ */
24
+ export interface DocumentManifest {
25
+ /** Unique document identifier. */
26
+ docid: string;
27
+ /** Human-readable document title. */
28
+ title: string;
29
+ /** Document creation timestamp as a Unix epoch value. */
30
+ createdAt: bigint;
31
+ /** Application-level type name assigned to this document. */
32
+ docType: string;
33
+ /** Ordered list of section references belonging to the document. */
34
+ sections: DocumentSection[];
35
+ }
36
+
37
+ /**
38
+ * Decodes a single `DocumentManifest` from WASM binary output.
39
+ *
40
+ * Reads fields in the order: docid, title, createdAt, docType,
41
+ * section count, then each section's kbid and position.
42
+ *
43
+ * @param bytes - raw bytes returned by `worker_retrieve_doc`
44
+ * @returns the decoded document manifest
45
+ */
46
+ export function decodeDocumentManifest(
47
+ bytes: Uint8Array,
48
+ ): DocumentManifest {
49
+ let offset = 0;
50
+
51
+ const docid = decodeString(bytes, offset);
52
+ offset += docid.bytesRead;
53
+
54
+ const title = decodeString(bytes, offset);
55
+ offset += title.bytesRead;
56
+
57
+ const createdAt = decodeU64(bytes, offset);
58
+ offset += createdAt.bytesRead;
59
+
60
+ const docType = decodeString(bytes, offset);
61
+ offset += docType.bytesRead;
62
+
63
+ const count = decodeU32(bytes, offset);
64
+ offset += count.bytesRead;
65
+
66
+ const sections: DocumentSection[] = [];
67
+ for (let i = 0; i < count.value; i++) {
68
+ const kbid = decodeString(bytes, offset);
69
+ offset += kbid.bytesRead;
70
+
71
+ const position = decodeU32(bytes, offset);
72
+ offset += position.bytesRead;
73
+
74
+ sections.push({
75
+ kbid: kbid.value,
76
+ position: position.value,
77
+ });
78
+ }
79
+
80
+ return {
81
+ docid: docid.value,
82
+ title: title.value,
83
+ createdAt: createdAt.value,
84
+ docType: docType.value,
85
+ sections,
86
+ };
87
+ }
@@ -0,0 +1,16 @@
1
+ import type { DecodeResult } from './decode-string.function.ts';
2
+
3
+ export function decodeF32(
4
+ bytes: Uint8Array,
5
+ offset: number,
6
+ ): DecodeResult<number> {
7
+ const view = new DataView(
8
+ bytes.buffer,
9
+ bytes.byteOffset,
10
+ bytes.byteLength,
11
+ );
12
+ return {
13
+ value: view.getFloat32(offset, true),
14
+ bytesRead: 4,
15
+ };
16
+ }
@@ -0,0 +1,15 @@
1
+ export function decodeKeyValueText(
2
+ text: string,
3
+ ): Record<string, string> {
4
+ const result: Record<string, string> = {};
5
+ for (const line of text.split('\n')) {
6
+ const idx = line.indexOf('=');
7
+ if (idx < 0) continue;
8
+ const key = line.slice(0, idx);
9
+ const value = line.slice(idx + 1);
10
+ if (key) {
11
+ result[key] = value;
12
+ }
13
+ }
14
+ return result;
15
+ }
@@ -0,0 +1,3 @@
1
+ export function decodeRemoveFlag(bytes: Uint8Array): boolean {
2
+ return bytes.length > 0 && bytes[0] === 0x01;
3
+ }
@@ -0,0 +1,54 @@
1
+ import { decodeString } from './decode-string.function.ts';
2
+ import { decodeU32 } from './decode-u32.function.ts';
3
+ import { decodeF32 } from './decode-f32.function.ts';
4
+
5
+ export interface TermMatch {
6
+ term: string;
7
+ frequency: number;
8
+ }
9
+
10
+ export interface ScoredResult {
11
+ kbid: string;
12
+ score: number;
13
+ matches: TermMatch[];
14
+ }
15
+
16
+ export function decodeScoredResults(bytes: Uint8Array): ScoredResult[] {
17
+ let offset = 0;
18
+ const count = decodeU32(bytes, offset);
19
+ offset += count.bytesRead;
20
+
21
+ const results: ScoredResult[] = [];
22
+ for (let i = 0; i < count.value; i++) {
23
+ const kbid = decodeString(bytes, offset);
24
+ offset += kbid.bytesRead;
25
+
26
+ const score = decodeF32(bytes, offset);
27
+ offset += score.bytesRead;
28
+
29
+ const matchCount = decodeU32(bytes, offset);
30
+ offset += matchCount.bytesRead;
31
+
32
+ const matches: TermMatch[] = [];
33
+ for (let j = 0; j < matchCount.value; j++) {
34
+ const term = decodeString(bytes, offset);
35
+ offset += term.bytesRead;
36
+
37
+ const freq = decodeF32(bytes, offset);
38
+ offset += freq.bytesRead;
39
+
40
+ matches.push({
41
+ term: term.value,
42
+ frequency: freq.value,
43
+ });
44
+ }
45
+
46
+ results.push({
47
+ kbid: kbid.value,
48
+ score: score.value,
49
+ matches,
50
+ });
51
+ }
52
+
53
+ return results;
54
+ }
@@ -0,0 +1,20 @@
1
+ import { decodeSectionRecords } from './decode-section-records.function.ts';
2
+ import type { SectionRecord } from './decode-section-records.function.ts';
3
+
4
+ export type { SectionRecord };
5
+
6
+ /**
7
+ * Decodes a WASM byte slice into an array of `SectionRecord` values.
8
+ *
9
+ * Thin wrapper around `decodeSectionRecords` provided as the
10
+ * canonical entry point for list-response decoding from WASM exports
11
+ * such as `worker_list_by_type`.
12
+ *
13
+ * @param bytes - raw bytes returned by a WASM section-list export
14
+ * @returns decoded array of section records
15
+ */
16
+ export function decodeSectionRecordList(
17
+ bytes: Uint8Array,
18
+ ): SectionRecord[] {
19
+ return decodeSectionRecords(bytes);
20
+ }
@@ -0,0 +1,162 @@
1
+ import { decodeString } from './decode-string.function.ts';
2
+ import { decodeU32 } from './decode-u32.function.ts';
3
+ import { decodeU64 } from './decode-u64.function.ts';
4
+
5
+ /**
6
+ * A single section record decoded from WASM binary output.
7
+ *
8
+ * Represents a stored knowledge-base section with all its metadata
9
+ * and token counts as returned by `worker_read_sections` or
10
+ * `worker_list_by_type`.
11
+ */
12
+ export interface SectionRecord {
13
+ /** Unique knowledge-base identifier for this section. */
14
+ kbid: string;
15
+ /** Document identifier this section belongs to, or `null`. */
16
+ docid: string | null;
17
+ /** Semantic type discriminant: `'text'`, `'code'`, or `'image'`. */
18
+ sectionType: string;
19
+ /** MIME type string, present only for `'code'` and `'image'` types. */
20
+ mimeType?: string;
21
+ /** Human-readable title for the section, or `null`. */
22
+ title: string | null;
23
+ /** Optional description of the section content, or `null`. */
24
+ description: string | null;
25
+ /** Raw text or base64-encoded content of the section. */
26
+ content: string;
27
+ /** Byte size of the stored content. */
28
+ size: number;
29
+ /** Section creation timestamp as a Unix epoch value. */
30
+ createdAt: bigint;
31
+ /** Integrity checksum of the stored content. */
32
+ checksum: string;
33
+ /** Total number of tokens in the section. */
34
+ tokenCount: number;
35
+ /** Number of heading tokens in the section. */
36
+ headingTokenCount: number;
37
+ /** Number of body tokens in the section. */
38
+ bodyTokenCount: number;
39
+ /** Number of code tokens in the section. */
40
+ codeTokenCount: number;
41
+ /** Application-level type name assigned to this section. */
42
+ typeName: string;
43
+ }
44
+
45
+ function decodeOptionString(
46
+ bytes: Uint8Array,
47
+ offset: number,
48
+ ): { value: string | null; bytesRead: number } {
49
+ const tag = bytes[offset];
50
+ if (tag === 0x00) {
51
+ return { value: null, bytesRead: 1 };
52
+ }
53
+ const str = decodeString(bytes, offset + 1);
54
+ return { value: str.value, bytesRead: 1 + str.bytesRead };
55
+ }
56
+
57
+ function decodeSectionType(
58
+ bytes: Uint8Array,
59
+ offset: number,
60
+ ): {
61
+ sectionType: string;
62
+ mimeType?: string;
63
+ bytesRead: number;
64
+ } {
65
+ const tag = bytes[offset];
66
+ if (tag === 0x00) {
67
+ return { sectionType: 'text', bytesRead: 1 };
68
+ }
69
+ const mime = decodeString(bytes, offset + 1);
70
+ const kind = tag === 0x01 ? 'code' : 'image';
71
+ return {
72
+ sectionType: kind,
73
+ mimeType: mime.value,
74
+ bytesRead: 1 + mime.bytesRead,
75
+ };
76
+ }
77
+
78
+ /**
79
+ * Decodes a list of `SectionRecord` values from WASM binary output.
80
+ *
81
+ * Reads a leading u32 count followed by that many encoded records.
82
+ * Each record is decoded in field order as produced by the Rust
83
+ * `SectionRecord::encode` implementation.
84
+ *
85
+ * @param bytes - raw bytes returned by a WASM section-list export
86
+ * @returns decoded array of section records, empty when count is zero
87
+ */
88
+ export function decodeSectionRecords(
89
+ bytes: Uint8Array,
90
+ ): SectionRecord[] {
91
+ let offset = 0;
92
+ const count = decodeU32(bytes, offset);
93
+ offset += count.bytesRead;
94
+
95
+ const records: SectionRecord[] = [];
96
+ for (let i = 0; i < count.value; i++) {
97
+ const kbid = decodeString(bytes, offset);
98
+ offset += kbid.bytesRead;
99
+
100
+ const docid = decodeOptionString(bytes, offset);
101
+ offset += docid.bytesRead;
102
+
103
+ const st = decodeSectionType(bytes, offset);
104
+ offset += st.bytesRead;
105
+
106
+ const title = decodeOptionString(bytes, offset);
107
+ offset += title.bytesRead;
108
+
109
+ const description = decodeOptionString(bytes, offset);
110
+ offset += description.bytesRead;
111
+
112
+ const content = decodeString(bytes, offset);
113
+ offset += content.bytesRead;
114
+
115
+ const size = decodeU32(bytes, offset);
116
+ offset += size.bytesRead;
117
+
118
+ const createdAt = decodeU64(bytes, offset);
119
+ offset += createdAt.bytesRead;
120
+
121
+ const checksum = decodeString(bytes, offset);
122
+ offset += checksum.bytesRead;
123
+
124
+ const tokenCount = decodeU32(bytes, offset);
125
+ offset += tokenCount.bytesRead;
126
+
127
+ const headingTokenCount = decodeU32(bytes, offset);
128
+ offset += headingTokenCount.bytesRead;
129
+
130
+ const bodyTokenCount = decodeU32(bytes, offset);
131
+ offset += bodyTokenCount.bytesRead;
132
+
133
+ const codeTokenCount = decodeU32(bytes, offset);
134
+ offset += codeTokenCount.bytesRead;
135
+
136
+ const typeName = decodeString(bytes, offset);
137
+ offset += typeName.bytesRead;
138
+
139
+ const record: SectionRecord = {
140
+ kbid: kbid.value,
141
+ docid: docid.value,
142
+ sectionType: st.sectionType,
143
+ title: title.value,
144
+ description: description.value,
145
+ content: content.value,
146
+ size: size.value,
147
+ createdAt: createdAt.value,
148
+ checksum: checksum.value,
149
+ tokenCount: tokenCount.value,
150
+ headingTokenCount: headingTokenCount.value,
151
+ bodyTokenCount: bodyTokenCount.value,
152
+ codeTokenCount: codeTokenCount.value,
153
+ typeName: typeName.value,
154
+ };
155
+ if (st.mimeType !== undefined) {
156
+ record.mimeType = st.mimeType;
157
+ }
158
+ records.push(record);
159
+ }
160
+
161
+ return records;
162
+ }
@@ -0,0 +1,22 @@
1
+ const decoder = new TextDecoder();
2
+
3
+ export interface DecodeResult<T> {
4
+ value: T;
5
+ bytesRead: number;
6
+ }
7
+
8
+ export function decodeString(
9
+ bytes: Uint8Array,
10
+ offset: number,
11
+ ): DecodeResult<string> {
12
+ const view = new DataView(
13
+ bytes.buffer,
14
+ bytes.byteOffset,
15
+ bytes.byteLength,
16
+ );
17
+ const len = view.getUint32(offset, true);
18
+ const value = decoder.decode(
19
+ bytes.subarray(offset + 4, offset + 4 + len),
20
+ );
21
+ return { value, bytesRead: 4 + len };
22
+ }
@@ -0,0 +1,16 @@
1
+ import type { DecodeResult } from './decode-string.function.ts';
2
+
3
+ export function decodeU32(
4
+ bytes: Uint8Array,
5
+ offset: number,
6
+ ): DecodeResult<number> {
7
+ const view = new DataView(
8
+ bytes.buffer,
9
+ bytes.byteOffset,
10
+ bytes.byteLength,
11
+ );
12
+ return {
13
+ value: view.getUint32(offset, true),
14
+ bytesRead: 4,
15
+ };
16
+ }
@@ -0,0 +1,16 @@
1
+ import type { DecodeResult } from './decode-string.function.ts';
2
+
3
+ export function decodeU64(
4
+ bytes: Uint8Array,
5
+ offset: number,
6
+ ): DecodeResult<bigint> {
7
+ const view = new DataView(
8
+ bytes.buffer,
9
+ bytes.byteOffset,
10
+ bytes.byteLength,
11
+ );
12
+ return {
13
+ value: view.getBigUint64(offset, true),
14
+ bytesRead: 8,
15
+ };
16
+ }
@@ -0,0 +1,34 @@
1
+ import { encodeSectionType } from './encode-section-type.function.ts';
2
+ import { encodeString } from './encode-string.function.ts';
3
+ import { encodeOptionString } from './encode-option-string.function.ts';
4
+
5
+ export interface AddSectionInput {
6
+ sectionType: 'text' | 'code' | 'image';
7
+ mimeType?: string;
8
+ content: string;
9
+ title?: string | null;
10
+ description?: string | null;
11
+ docid?: string | null;
12
+ typeName?: string | null;
13
+ }
14
+
15
+ export function encodeAddSectionParams(
16
+ params: AddSectionInput,
17
+ ): Uint8Array {
18
+ const parts = [
19
+ encodeSectionType(params.sectionType, params.mimeType),
20
+ encodeString(params.content),
21
+ encodeOptionString(params.title),
22
+ encodeOptionString(params.description),
23
+ encodeOptionString(params.docid),
24
+ encodeOptionString(params.typeName),
25
+ ];
26
+ const totalLen = parts.reduce((sum, p) => sum + p.length, 0);
27
+ const result = new Uint8Array(totalLen);
28
+ let offset = 0;
29
+ for (const part of parts) {
30
+ result.set(part, offset);
31
+ offset += part.length;
32
+ }
33
+ return result;
34
+ }
@@ -0,0 +1,28 @@
1
+ import { encodeString } from './encode-string.function.ts';
2
+ import { encodeKbidList } from './encode-kbid-list.function.ts';
3
+
4
+ /**
5
+ * Encodes parameters for the `worker_group_sections` WASM call into
6
+ * a single byte buffer: title, kbid list, then doc type tag.
7
+ *
8
+ * @param title - human-readable document title
9
+ * @param kbids - identifiers of the sections to group
10
+ * @param docType - application-level document type tag; defaults to
11
+ * empty string when not specified
12
+ */
13
+ export function encodeGroupParams(
14
+ title: string,
15
+ kbids: string[],
16
+ docType = '',
17
+ ): Uint8Array {
18
+ const titleBytes = encodeString(title);
19
+ const listBytes = encodeKbidList(kbids);
20
+ const docTypeBytes = encodeString(docType);
21
+ const result = new Uint8Array(
22
+ titleBytes.length + listBytes.length + docTypeBytes.length,
23
+ );
24
+ result.set(titleBytes, 0);
25
+ result.set(listBytes, titleBytes.length);
26
+ result.set(docTypeBytes, titleBytes.length + listBytes.length);
27
+ return result;
28
+ }
@@ -0,0 +1,17 @@
1
+ import { encodeU32 } from './encode-u32.function.ts';
2
+ import { encodeString } from './encode-string.function.ts';
3
+
4
+ export function encodeIdentifierList(ids: string[]): Uint8Array {
5
+ if (ids.length === 0) {
6
+ return new Uint8Array(0);
7
+ }
8
+ const parts = [encodeU32(ids.length), ...ids.map(encodeString)];
9
+ const totalLen = parts.reduce((sum, p) => sum + p.length, 0);
10
+ const result = new Uint8Array(totalLen);
11
+ let offset = 0;
12
+ for (const part of parts) {
13
+ result.set(part, offset);
14
+ offset += part.length;
15
+ }
16
+ return result;
17
+ }
@@ -0,0 +1,17 @@
1
+ import { encodeU32 } from './encode-u32.function.ts';
2
+ import { encodeString } from './encode-string.function.ts';
3
+
4
+ export function encodeKbidList(kbids: string[]): Uint8Array {
5
+ if (kbids.length === 0) {
6
+ return new Uint8Array(0);
7
+ }
8
+ const parts = [encodeU32(kbids.length), ...kbids.map(encodeString)];
9
+ const totalLen = parts.reduce((sum, p) => sum + p.length, 0);
10
+ const result = new Uint8Array(totalLen);
11
+ let offset = 0;
12
+ for (const part of parts) {
13
+ result.set(part, offset);
14
+ offset += part.length;
15
+ }
16
+ return result;
17
+ }
@@ -0,0 +1,14 @@
1
+ import { encodeString } from './encode-string.function.ts';
2
+
3
+ export function encodeOptionString(
4
+ value: string | null | undefined,
5
+ ): Uint8Array {
6
+ if (value == null) {
7
+ return new Uint8Array([0x00]);
8
+ }
9
+ const encoded = encodeString(value);
10
+ const result = new Uint8Array(1 + encoded.length);
11
+ result[0] = 0x01;
12
+ result.set(encoded, 1);
13
+ return result;
14
+ }
@@ -0,0 +1,9 @@
1
+ const encoder = new TextEncoder();
2
+
3
+ export function encodeSearchParams(
4
+ query: string,
5
+ mode = 'and',
6
+ limit = 20,
7
+ ): Uint8Array {
8
+ return encoder.encode(`${query}\n${mode}\n${String(limit)}`);
9
+ }
@@ -0,0 +1,18 @@
1
+ import { encodeString } from './encode-string.function.ts';
2
+
3
+ export function encodeSectionType(
4
+ kind: 'text' | 'code' | 'image',
5
+ mimeType?: string,
6
+ ): Uint8Array {
7
+ if (kind === 'text') {
8
+ return new Uint8Array([0x00]);
9
+ }
10
+
11
+ const tag = kind === 'code' ? 0x01 : 0x02;
12
+ const mime = mimeType ?? 'text/plain';
13
+ const encoded = encodeString(mime);
14
+ const result = new Uint8Array(1 + encoded.length);
15
+ result[0] = tag;
16
+ result.set(encoded, 1);
17
+ return result;
18
+ }
@@ -0,0 +1,9 @@
1
+ const encoder = new TextEncoder();
2
+
3
+ export function encodeString(value: string): Uint8Array {
4
+ const utf8 = encoder.encode(value);
5
+ const result = new Uint8Array(4 + utf8.length);
6
+ new DataView(result.buffer).setUint32(0, utf8.length, true);
7
+ result.set(utf8, 4);
8
+ return result;
9
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Encodes a type filter string as raw UTF-8 bytes for WASM input.
3
+ *
4
+ * Used to pass a type name to WASM exports such as
5
+ * `worker_list_by_type` and `worker_list_docs_by_type`, which accept
6
+ * a plain UTF-8 byte slice without a length prefix.
7
+ *
8
+ * @param typeStr - the type name to filter by (e.g. `'article'`)
9
+ * @returns UTF-8 encoded bytes ready to pass to the WASM export
10
+ */
11
+ export function encodeTypeFilterParam(typeStr: string): Uint8Array {
12
+ return new TextEncoder().encode(typeStr);
13
+ }
@@ -0,0 +1,5 @@
1
+ export function encodeU32(value: number): Uint8Array {
2
+ const result = new Uint8Array(4);
3
+ new DataView(result.buffer).setUint32(0, value, true);
4
+ return result;
5
+ }