wiki-graph-core 0.3.1 → 0.4.1

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 (1700) hide show
  1. package/README.md +15 -0
  2. package/data/editor/text_compressor.jinja +17 -13
  3. package/data/help/commands/archive/next.jinja +7 -2
  4. package/data/help/commands/gc.jinja +2 -1
  5. package/data/help/commands/legacy/migrate.jinja +6 -1
  6. package/data/help/commands/legacy.jinja +3 -2
  7. package/data/help/commands/library-predicate.jinja +296 -0
  8. package/data/help/commands/library.jinja +237 -0
  9. package/data/help/commands/maintenance/chapter/add.jinja +3 -3
  10. package/data/help/commands/maintenance/chapter/list.jinja +4 -4
  11. package/data/help/commands/maintenance/chapter/move.jinja +4 -4
  12. package/data/help/commands/maintenance/chapter/remove.jinja +1 -1
  13. package/data/help/commands/maintenance/chapter/reset.jinja +1 -1
  14. package/data/help/commands/maintenance/chapter/set-source.jinja +2 -2
  15. package/data/help/commands/maintenance/chapter/set-summary.jinja +1 -1
  16. package/data/help/commands/maintenance/chapter/set-title.jinja +3 -3
  17. package/data/help/commands/maintenance/chapter/tree.jinja +6 -6
  18. package/data/help/commands/maintenance/chapter.jinja +10 -10
  19. package/data/help/commands/maintenance/meta.jinja +7 -7
  20. package/data/help/commands/maintenance/upgrade.jinja +35 -0
  21. package/data/help/commands/maintenance.jinja +23 -0
  22. package/data/help/commands/predicate.jinja +204 -28
  23. package/data/help/commands/root.jinja +10 -3
  24. package/data/help/commands/uri.jinja +165 -6
  25. package/data/help/topics/config.jinja +10 -3
  26. package/data/help/topics/library.jinja +90 -0
  27. package/data/help/topics/readiness.jinja +32 -2
  28. package/data/help/topics/recipe.jinja +42 -17
  29. package/data/help/topics/runtime.jinja +20 -3
  30. package/data/help/topics/uri.jinja +53 -25
  31. package/dist/api/app.d.ts +87 -0
  32. package/dist/api/app.js +137 -0
  33. package/dist/api/app.js.map +1 -0
  34. package/dist/api/chapter/advance.d.ts +36 -0
  35. package/dist/api/chapter/advance.js +171 -0
  36. package/dist/api/chapter/advance.js.map +1 -0
  37. package/dist/api/chapter/details.d.ts +25 -0
  38. package/dist/api/chapter/details.js +17 -0
  39. package/dist/api/chapter/details.js.map +1 -0
  40. package/dist/api/chapter/entries.d.ts +41 -0
  41. package/dist/api/chapter/entries.js +216 -0
  42. package/dist/api/chapter/entries.js.map +1 -0
  43. package/dist/api/chapter/generate.d.ts +42 -0
  44. package/dist/api/chapter/generate.js +61 -0
  45. package/dist/api/chapter/generate.js.map +1 -0
  46. package/dist/api/chapter/index.d.ts +43 -0
  47. package/dist/api/chapter/index.js +11 -0
  48. package/dist/api/chapter/index.js.map +1 -0
  49. package/dist/api/chapter/manage.d.ts +53 -0
  50. package/dist/api/chapter/manage.js +185 -0
  51. package/dist/api/chapter/manage.js.map +1 -0
  52. package/dist/api/chapter/options.d.ts +51 -0
  53. package/dist/api/chapter/options.js +11 -0
  54. package/dist/api/chapter/options.js.map +1 -0
  55. package/dist/api/chapter/parse.d.ts +13 -0
  56. package/dist/api/chapter/parse.js +16 -0
  57. package/dist/api/chapter/parse.js.map +1 -0
  58. package/dist/api/chapter/tree.d.ts +61 -0
  59. package/dist/api/chapter/tree.js +387 -0
  60. package/dist/api/chapter/tree.js.map +1 -0
  61. package/dist/api/chapter/types.d.ts +104 -0
  62. package/dist/api/chapter/types.js +5 -0
  63. package/dist/api/chapter/types.js.map +1 -0
  64. package/dist/api/chapter-build/index.d.ts +42 -0
  65. package/dist/api/chapter-build/index.js +3 -0
  66. package/dist/api/chapter-build/index.js.map +1 -0
  67. package/dist/api/chapter-build/types.d.ts +37 -0
  68. package/dist/api/digest.d.ts +67 -0
  69. package/dist/api/digest.js +171 -0
  70. package/dist/api/digest.js.map +1 -0
  71. package/dist/api/graph.d.ts +24 -0
  72. package/dist/api/graph.js +2 -0
  73. package/dist/api/graph.js.map +1 -0
  74. package/dist/api/import.d.ts +62 -0
  75. package/dist/api/import.js +269 -0
  76. package/dist/api/import.js.map +1 -0
  77. package/dist/api/index.d.ts +91 -0
  78. package/dist/api/index.js +189 -0
  79. package/dist/api/index.js.map +1 -0
  80. package/dist/api/knowledge-graph-build/index.d.ts +40 -0
  81. package/dist/api/knowledge-graph-build/index.js +2 -0
  82. package/dist/api/knowledge-graph-build/index.js.map +1 -0
  83. package/dist/api/knowledge-graph-build/types.d.ts +13 -0
  84. package/dist/api/llm-sampling.d.ts +11 -0
  85. package/dist/api/llm-sampling.js +58 -0
  86. package/dist/api/llm-sampling.js.map +1 -0
  87. package/dist/api/prompts.d.ts +1 -0
  88. package/dist/api/prompts.js +2 -0
  89. package/dist/api/prompts.js.map +1 -0
  90. package/dist/api/wiki-graph-archive.d.ts +42 -0
  91. package/dist/api/wiki-graph-archive.js +130 -0
  92. package/dist/api/wiki-graph-archive.js.map +1 -0
  93. package/dist/core-Cv8a8viI.d.ts +85 -0
  94. package/dist/document/chapter/index.d.ts +26 -0
  95. package/dist/document/chapter/index.js +23 -0
  96. package/dist/document/chapter/index.js.map +1 -0
  97. package/dist/document/chapter/path.d.ts +14 -0
  98. package/dist/document/chapter/path.js +133 -0
  99. package/dist/document/chapter/path.js.map +1 -0
  100. package/dist/document/chapter/query.d.ts +33 -0
  101. package/dist/document/chapter/query.js +83 -0
  102. package/dist/document/chapter/query.js.map +1 -0
  103. package/dist/document/chapter/stage.d.ts +28 -0
  104. package/dist/document/chapter/stage.js +13 -0
  105. package/dist/document/chapter/stage.js.map +1 -0
  106. package/dist/document/chapter/toc.d.ts +33 -0
  107. package/dist/document/chapter/toc.js +213 -0
  108. package/dist/document/chapter/toc.js.map +1 -0
  109. package/dist/document/chapter/tree.d.ts +20 -0
  110. package/dist/document/chapter/tree.js +48 -0
  111. package/dist/document/chapter/tree.js.map +1 -0
  112. package/dist/document/chapter/types.d.ts +31 -0
  113. package/dist/document/chapter/types.js +10 -0
  114. package/dist/document/chapter/types.js.map +1 -0
  115. package/dist/document/directory/context.d.ts +25 -0
  116. package/dist/document/directory/context.js +54 -0
  117. package/dist/document/directory/context.js.map +1 -0
  118. package/dist/document/directory/core.d.ts +25 -0
  119. package/dist/document/directory/core.js +382 -0
  120. package/dist/document/directory/core.js.map +1 -0
  121. package/dist/document/directory/file-store.d.ts +27 -0
  122. package/dist/document/directory/file-store.js +48 -0
  123. package/dist/document/directory/file-store.js.map +1 -0
  124. package/dist/document/directory/files.d.ts +53 -0
  125. package/dist/document/directory/files.js +71 -0
  126. package/dist/document/directory/files.js.map +1 -0
  127. package/dist/document/directory/index.d.ts +26 -0
  128. package/dist/document/directory/index.js +4 -0
  129. package/dist/document/directory/index.js.map +1 -0
  130. package/dist/document/directory/search-index.d.ts +32 -0
  131. package/dist/document/directory/search-index.js +154 -0
  132. package/dist/document/directory/search-index.js.map +1 -0
  133. package/dist/document/directory/serial-cleanup.d.ts +47 -0
  134. package/dist/document/directory/serial-cleanup.js +178 -0
  135. package/dist/document/directory/serial-cleanup.js.map +1 -0
  136. package/dist/document/directory/toc.d.ts +6 -0
  137. package/dist/document/directory/toc.js +14 -0
  138. package/dist/document/directory/toc.js.map +1 -0
  139. package/dist/document/directory/types.d.ts +105 -0
  140. package/dist/document/fragment-backed.d.ts +27 -0
  141. package/dist/document/fragment-backed.js +26 -0
  142. package/dist/document/fragment-backed.js.map +1 -0
  143. package/dist/document/fragments/core.d.ts +18 -0
  144. package/dist/document/fragments/core.js +68 -0
  145. package/dist/document/fragments/core.js.map +1 -0
  146. package/dist/document/fragments/draft.d.ts +16 -0
  147. package/dist/document/fragments/draft.js +57 -0
  148. package/dist/document/fragments/draft.js.map +1 -0
  149. package/dist/document/fragments/file-access.d.ts +7 -0
  150. package/dist/document/fragments/file-access.js +28 -0
  151. package/dist/document/fragments/file-access.js.map +1 -0
  152. package/dist/document/fragments/file.d.ts +7 -0
  153. package/dist/document/fragments/file.js +55 -0
  154. package/dist/document/fragments/file.js.map +1 -0
  155. package/dist/document/fragments/index.d.ts +5 -0
  156. package/dist/document/fragments/index.js +5 -0
  157. package/dist/document/fragments/index.js.map +1 -0
  158. package/dist/document/fragments/sentence.d.ts +5 -0
  159. package/dist/document/fragments/sentence.js +14 -0
  160. package/dist/document/fragments/sentence.js.map +1 -0
  161. package/dist/document/fragments/serial.d.ts +16 -0
  162. package/dist/document/fragments/serial.js +187 -0
  163. package/dist/document/fragments/serial.js.map +1 -0
  164. package/dist/document/fragments/types.d.ts +37 -0
  165. package/dist/document/fragments/types.js +9 -0
  166. package/dist/document/fragments/types.js.map +1 -0
  167. package/dist/document/home-schema-upgrade.d.ts +5 -0
  168. package/dist/document/home-schema-upgrade.js +529 -0
  169. package/dist/document/home-schema-upgrade.js.map +1 -0
  170. package/dist/document/index.d.ts +27 -8
  171. package/dist/document/index.js +10 -4
  172. package/dist/document/index.js.map +1 -1
  173. package/dist/document/schema.d.ts +3 -2
  174. package/dist/document/schema.js +24 -11
  175. package/dist/document/schema.js.map +1 -1
  176. package/dist/document/shared-state-database.js +27 -3
  177. package/dist/document/shared-state-database.js.map +1 -1
  178. package/dist/document/stores/chunk.d.ts +21 -0
  179. package/dist/document/stores/chunk.js +299 -0
  180. package/dist/document/stores/chunk.js.map +1 -0
  181. package/dist/document/stores/fragment-group.d.ts +16 -0
  182. package/dist/document/stores/fragment-group.js +77 -0
  183. package/dist/document/stores/fragment-group.js.map +1 -0
  184. package/dist/document/stores/graph-build-parameter.d.ts +17 -0
  185. package/dist/document/stores/graph-build-parameter.js +62 -0
  186. package/dist/document/stores/graph-build-parameter.js.map +1 -0
  187. package/dist/document/stores/helpers.d.ts +22 -0
  188. package/dist/document/stores/helpers.js +115 -0
  189. package/dist/document/stores/helpers.js.map +1 -0
  190. package/dist/document/stores/index.d.ts +15 -0
  191. package/dist/document/stores/index.js +23 -0
  192. package/dist/document/stores/index.js.map +1 -0
  193. package/dist/document/stores/mention-link.d.ts +32 -0
  194. package/dist/document/stores/mention-link.js +287 -0
  195. package/dist/document/stores/mention-link.js.map +1 -0
  196. package/dist/document/stores/mention.d.ts +31 -0
  197. package/dist/document/stores/mention.js +238 -0
  198. package/dist/document/stores/mention.js.map +1 -0
  199. package/dist/document/stores/object-metadata.d.ts +19 -0
  200. package/dist/document/stores/object-metadata.js +148 -0
  201. package/dist/document/stores/object-metadata.js.map +1 -0
  202. package/dist/document/stores/reading-edge.d.ts +17 -0
  203. package/dist/document/stores/reading-edge.js +80 -0
  204. package/dist/document/stores/reading-edge.js.map +1 -0
  205. package/dist/document/stores/serial.d.ts +29 -0
  206. package/dist/document/stores/serial.js +296 -0
  207. package/dist/document/stores/serial.js.map +1 -0
  208. package/dist/document/stores/snake/chunk.d.ts +14 -0
  209. package/dist/document/stores/snake/chunk.js +48 -0
  210. package/dist/document/stores/snake/chunk.js.map +1 -0
  211. package/dist/document/stores/snake/core.d.ts +15 -0
  212. package/dist/document/stores/snake/core.js +112 -0
  213. package/dist/document/stores/snake/core.js.map +1 -0
  214. package/dist/document/stores/snake/edge.d.ts +16 -0
  215. package/dist/document/stores/snake/edge.js +86 -0
  216. package/dist/document/stores/snake/edge.js.map +1 -0
  217. package/dist/document/stores/snake/index.d.ts +7 -0
  218. package/dist/document/stores/snake/index.js +4 -0
  219. package/dist/document/stores/snake/index.js.map +1 -0
  220. package/dist/document/stores/types.d.ts +95 -0
  221. package/dist/document/text-streams/core.d.ts +17 -0
  222. package/dist/document/text-streams/core.js +45 -0
  223. package/dist/document/text-streams/core.js.map +1 -0
  224. package/dist/document/text-streams/draft.d.ts +20 -0
  225. package/dist/document/text-streams/draft.js +70 -0
  226. package/dist/document/text-streams/draft.js.map +1 -0
  227. package/dist/document/text-streams/file-access.d.ts +6 -0
  228. package/dist/document/text-streams/file-access.js +31 -0
  229. package/dist/document/text-streams/file-access.js.map +1 -0
  230. package/dist/document/text-streams/index.d.ts +7 -0
  231. package/dist/document/text-streams/index.js +5 -0
  232. package/dist/document/text-streams/index.js.map +1 -0
  233. package/dist/document/text-streams/sentence.d.ts +13 -0
  234. package/dist/document/text-streams/sentence.js +77 -0
  235. package/dist/document/text-streams/sentence.js.map +1 -0
  236. package/dist/document/text-streams/serial.d.ts +24 -0
  237. package/dist/document/text-streams/serial.js +324 -0
  238. package/dist/document/text-streams/serial.js.map +1 -0
  239. package/dist/document/text-streams/types.d.ts +55 -0
  240. package/dist/document/text-streams/types.js +10 -0
  241. package/dist/document/text-streams/types.js.map +1 -0
  242. package/dist/external/guaranteed/classifier.js.map +1 -0
  243. package/dist/external/guaranteed/errors.js.map +1 -0
  244. package/dist/external/guaranteed/index.js.map +1 -0
  245. package/dist/external/guaranteed/request.js.map +1 -0
  246. package/dist/external/guaranteed/response.js.map +1 -0
  247. package/dist/external/llm/cache.js +35 -0
  248. package/dist/external/llm/cache.js.map +1 -0
  249. package/dist/external/llm/client/core.d.ts +26 -0
  250. package/dist/external/llm/client/core.js +321 -0
  251. package/dist/external/llm/client/core.js.map +1 -0
  252. package/dist/external/llm/client/files.d.ts +6 -0
  253. package/dist/external/llm/client/files.js +29 -0
  254. package/dist/external/llm/client/files.js.map +1 -0
  255. package/dist/external/llm/client/generation.d.ts +16 -0
  256. package/dist/external/llm/client/generation.js +35 -0
  257. package/dist/external/llm/client/generation.js.map +1 -0
  258. package/dist/external/llm/client/index.d.ts +5 -0
  259. package/dist/external/llm/client/index.js +5 -0
  260. package/dist/external/llm/client/index.js.map +1 -0
  261. package/dist/external/llm/client/log.d.ts +22 -0
  262. package/dist/external/llm/client/log.js +106 -0
  263. package/dist/external/llm/client/log.js.map +1 -0
  264. package/dist/external/llm/client/model.d.ts +10 -0
  265. package/dist/external/llm/client/model.js +26 -0
  266. package/dist/external/llm/client/model.js.map +1 -0
  267. package/dist/external/llm/client/retry.d.ts +4 -0
  268. package/dist/external/llm/client/retry.js +91 -0
  269. package/dist/external/llm/client/retry.js.map +1 -0
  270. package/dist/external/llm/context.js +78 -0
  271. package/dist/external/llm/context.js.map +1 -0
  272. package/dist/external/llm/errors.js.map +1 -0
  273. package/dist/external/llm/index.d.ts +7 -0
  274. package/dist/external/llm/index.js +17 -0
  275. package/dist/external/llm/index.js.map +1 -0
  276. package/dist/external/llm/request-log.js +35 -0
  277. package/dist/external/llm/request-log.js.map +1 -0
  278. package/dist/external/llm/sampling.js.map +1 -0
  279. package/dist/external/wikimatch/enrichment.d.ts +15 -0
  280. package/dist/external/wikimatch/enrichment.js +61 -0
  281. package/dist/external/wikimatch/enrichment.js.map +1 -0
  282. package/dist/external/wikimatch/index.d.ts +19 -0
  283. package/dist/external/wikimatch/index.js +66 -0
  284. package/dist/external/wikimatch/index.js.map +1 -0
  285. package/dist/external/wikimatch/option-narrowing.d.ts +19 -0
  286. package/dist/external/wikimatch/option-narrowing.js.map +1 -0
  287. package/dist/external/wikimatch/options.d.ts +16 -0
  288. package/dist/external/wikimatch/options.js +154 -0
  289. package/dist/external/wikimatch/options.js.map +1 -0
  290. package/dist/external/wikimatch/policy-judge.d.ts +19 -0
  291. package/dist/external/wikimatch/policy-judge.js +431 -0
  292. package/dist/external/wikimatch/policy-judge.js.map +1 -0
  293. package/dist/external/wikimatch/range-suppression.js.map +1 -0
  294. package/dist/external/wikimatch/surface/index.d.ts +10 -0
  295. package/dist/external/wikimatch/surface/index.js +3 -0
  296. package/dist/external/wikimatch/surface/index.js.map +1 -0
  297. package/dist/external/wikimatch/surface/screening.d.ts +18 -0
  298. package/dist/external/wikimatch/surface/screening.js +168 -0
  299. package/dist/external/wikimatch/surface/screening.js.map +1 -0
  300. package/dist/external/wikimatch/surface/window.d.ts +8 -0
  301. package/dist/external/wikimatch/surface/window.js +44 -0
  302. package/dist/external/wikimatch/surface/window.js.map +1 -0
  303. package/dist/external/wikimatch/types.d.ts +153 -0
  304. package/dist/external/wikimatch/wikispine.d.ts +45 -0
  305. package/dist/external/wikimatch/wikispine.js.map +1 -0
  306. package/dist/external/wikimatch/window.d.ts +8 -0
  307. package/dist/external/wikimatch/window.js.map +1 -0
  308. package/dist/external/wikimatch/words.js.map +1 -0
  309. package/dist/external/wikipage/cache.d.ts +20 -0
  310. package/dist/external/wikipage/cache.js +442 -0
  311. package/dist/external/wikipage/cache.js.map +1 -0
  312. package/dist/external/wikipage/fetch-log.js +146 -0
  313. package/dist/external/wikipage/fetch-log.js.map +1 -0
  314. package/dist/external/wikipage/index.d.ts +15 -0
  315. package/dist/external/wikipage/index.js +17 -0
  316. package/dist/external/wikipage/index.js.map +1 -0
  317. package/dist/external/wikipage/normalizer.d.ts +16 -0
  318. package/dist/external/wikipage/normalizer.js +188 -0
  319. package/dist/external/wikipage/normalizer.js.map +1 -0
  320. package/dist/external/wikipage/rate-limiter.js.map +1 -0
  321. package/dist/external/wikipage/resolver.d.ts +22 -0
  322. package/dist/external/wikipage/resolver.js +359 -0
  323. package/dist/external/wikipage/resolver.js.map +1 -0
  324. package/dist/external/wikipage/types.d.ts +118 -0
  325. package/dist/external/wikipage/wikimedia-client/core.d.ts +13 -0
  326. package/dist/external/wikipage/wikimedia-client/core.js +207 -0
  327. package/dist/external/wikipage/wikimedia-client/core.js.map +1 -0
  328. package/dist/external/wikipage/wikimedia-client/html.d.ts +7 -0
  329. package/dist/external/wikipage/wikimedia-client/html.js +136 -0
  330. package/dist/external/wikipage/wikimedia-client/html.js.map +1 -0
  331. package/dist/external/wikipage/wikimedia-client/index.d.ts +5 -0
  332. package/dist/external/wikipage/wikimedia-client/index.js +4 -0
  333. package/dist/external/wikipage/wikimedia-client/index.js.map +1 -0
  334. package/dist/external/wikipage/wikimedia-client/json.d.ts +7 -0
  335. package/dist/external/wikipage/wikimedia-client/json.js +27 -0
  336. package/dist/external/wikipage/wikimedia-client/json.js.map +1 -0
  337. package/dist/external/wikipage/wikimedia-client/request.d.ts +12 -0
  338. package/dist/external/wikipage/wikimedia-client/request.js +51 -0
  339. package/dist/external/wikipage/wikimedia-client/request.js.map +1 -0
  340. package/dist/external/wikipage/wikimedia-client/wiki.d.ts +54 -0
  341. package/dist/external/wikipage/wikimedia-client/wiki.js +28 -0
  342. package/dist/external/wikipage/wikimedia-client/wiki.js.map +1 -0
  343. package/dist/gc.cjs +8188 -8373
  344. package/dist/gc.cjs.map +1 -1
  345. package/dist/gc.d.cts +23 -3
  346. package/dist/gc.d.ts +2 -2
  347. package/dist/gc.js +1 -1
  348. package/dist/gc.js.map +1 -1
  349. package/dist/graph/evidence-selection/anchor/index.d.ts +4 -0
  350. package/dist/graph/evidence-selection/anchor/index.js +3 -0
  351. package/dist/graph/evidence-selection/anchor/index.js.map +1 -0
  352. package/dist/graph/evidence-selection/anchor/resolver/index.d.ts +38 -0
  353. package/dist/graph/evidence-selection/anchor/resolver/index.js +418 -0
  354. package/dist/graph/evidence-selection/anchor/resolver/index.js.map +1 -0
  355. package/dist/graph/evidence-selection/anchor/resolver/matcher.d.ts +8 -0
  356. package/dist/graph/evidence-selection/anchor/resolver/matcher.js +178 -0
  357. package/dist/graph/evidence-selection/anchor/resolver/matcher.js.map +1 -0
  358. package/dist/graph/evidence-selection/anchor/resolver/parser.d.ts +7 -0
  359. package/dist/graph/evidence-selection/anchor/resolver/parser.js +91 -0
  360. package/dist/graph/evidence-selection/anchor/resolver/parser.js.map +1 -0
  361. package/dist/graph/evidence-selection/anchor/resolver/scoring.d.ts +20 -0
  362. package/dist/graph/evidence-selection/anchor/resolver/scoring.js +119 -0
  363. package/dist/graph/evidence-selection/anchor/resolver/scoring.js.map +1 -0
  364. package/dist/graph/evidence-selection/anchor/resolver/types.d.ts +15 -0
  365. package/dist/graph/evidence-selection/anchor/resolver/types.js +17 -0
  366. package/dist/graph/evidence-selection/anchor/resolver/types.js.map +1 -0
  367. package/dist/graph/evidence-selection/anchor/types.d.ts +27 -0
  368. package/dist/graph/evidence-selection/index.d.ts +9 -0
  369. package/dist/graph/evidence-selection/index.js +32 -0
  370. package/dist/graph/evidence-selection/index.js.map +1 -0
  371. package/dist/graph/evidence-selection/prompt.js.map +1 -0
  372. package/dist/graph/evidence-selection/quote-score.js.map +1 -0
  373. package/dist/graph/evidence-selection/resolver.js +303 -0
  374. package/dist/graph/evidence-selection/resolver.js.map +1 -0
  375. package/dist/graph/evidence-selection/text.js.map +1 -0
  376. package/dist/graph/knowledge-build/artifact-io.d.ts +12 -0
  377. package/dist/graph/knowledge-build/artifact-io.js +151 -0
  378. package/dist/graph/knowledge-build/artifact-io.js.map +1 -0
  379. package/dist/graph/knowledge-build/artifact.d.ts +17 -0
  380. package/dist/graph/knowledge-build/artifact.js +66 -0
  381. package/dist/graph/knowledge-build/artifact.js.map +1 -0
  382. package/dist/graph/knowledge-build/candidates.d.ts +24 -0
  383. package/dist/graph/knowledge-build/candidates.js +60 -0
  384. package/dist/graph/knowledge-build/candidates.js.map +1 -0
  385. package/dist/graph/knowledge-build/commit.d.ts +39 -0
  386. package/dist/graph/knowledge-build/commit.js +52 -0
  387. package/dist/graph/knowledge-build/commit.js.map +1 -0
  388. package/dist/graph/knowledge-build/constants.d.ts +6 -0
  389. package/dist/graph/knowledge-build/constants.js +11 -0
  390. package/dist/graph/knowledge-build/constants.js.map +1 -0
  391. package/dist/graph/knowledge-build/fragments.d.ts +33 -0
  392. package/dist/graph/knowledge-build/fragments.js +36 -0
  393. package/dist/graph/knowledge-build/fragments.js.map +1 -0
  394. package/dist/graph/knowledge-build/generate.d.ts +39 -0
  395. package/dist/graph/knowledge-build/generate.js +128 -0
  396. package/dist/graph/knowledge-build/generate.js.map +1 -0
  397. package/dist/graph/knowledge-build/grounding-runner.d.ts +23 -0
  398. package/dist/graph/knowledge-build/grounding-runner.js +90 -0
  399. package/dist/graph/knowledge-build/grounding-runner.js.map +1 -0
  400. package/dist/graph/knowledge-build/grounding.d.ts +19 -0
  401. package/dist/graph/knowledge-build/grounding.js +158 -0
  402. package/dist/graph/knowledge-build/grounding.js.map +1 -0
  403. package/dist/graph/knowledge-build/index.d.ts +40 -0
  404. package/dist/graph/knowledge-build/index.js +8 -0
  405. package/dist/graph/knowledge-build/index.js.map +1 -0
  406. package/dist/graph/knowledge-build/mentions.d.ts +25 -0
  407. package/dist/graph/knowledge-build/mentions.js +66 -0
  408. package/dist/graph/knowledge-build/mentions.js.map +1 -0
  409. package/dist/graph/knowledge-build/parameter.d.ts +19 -0
  410. package/dist/graph/knowledge-build/parameter.js +14 -0
  411. package/dist/graph/knowledge-build/parameter.js.map +1 -0
  412. package/dist/graph/knowledge-build/progress.d.ts +8 -0
  413. package/dist/graph/knowledge-build/progress.js +45 -0
  414. package/dist/graph/knowledge-build/progress.js.map +1 -0
  415. package/dist/graph/knowledge-build/relations.d.ts +22 -0
  416. package/dist/graph/knowledge-build/relations.js +118 -0
  417. package/dist/graph/knowledge-build/relations.js.map +1 -0
  418. package/dist/graph/knowledge-build/request.d.ts +8 -0
  419. package/dist/graph/knowledge-build/request.js +19 -0
  420. package/dist/graph/knowledge-build/request.js.map +1 -0
  421. package/dist/graph/knowledge-build/snapshot.d.ts +38 -0
  422. package/dist/graph/knowledge-build/snapshot.js +18 -0
  423. package/dist/graph/knowledge-build/snapshot.js.map +1 -0
  424. package/dist/graph/knowledge-build/types.d.ts +46 -0
  425. package/dist/graph/reading-build/artifact.d.ts +42 -0
  426. package/dist/graph/reading-build/artifact.js +162 -0
  427. package/dist/graph/reading-build/artifact.js.map +1 -0
  428. package/dist/graph/reading-build/copy.d.ts +28 -0
  429. package/dist/graph/reading-build/copy.js +65 -0
  430. package/dist/graph/reading-build/copy.js.map +1 -0
  431. package/dist/graph/reading-build/index.d.ts +39 -0
  432. package/dist/graph/reading-build/index.js +4 -0
  433. package/dist/graph/reading-build/index.js.map +1 -0
  434. package/dist/graph/reading-build/input.d.ts +32 -0
  435. package/dist/graph/reading-build/input.js +19 -0
  436. package/dist/graph/reading-build/input.js.map +1 -0
  437. package/dist/graph/reading-build/options.d.ts +47 -0
  438. package/dist/graph/reading-build/options.js +20 -0
  439. package/dist/graph/reading-build/options.js.map +1 -0
  440. package/dist/graph/reading-build/source-fragments.d.ts +15 -0
  441. package/dist/graph/reading-build/source-fragments.js +36 -0
  442. package/dist/graph/reading-build/source-fragments.js.map +1 -0
  443. package/dist/graph/reading-build/types.d.ts +57 -0
  444. package/dist/graph/reading.d.ts +73 -0
  445. package/dist/graph/reading.js +203 -0
  446. package/dist/graph/reading.js.map +1 -0
  447. package/dist/graph/topology/core.d.ts +42 -0
  448. package/dist/graph/topology/core.js +348 -0
  449. package/dist/graph/topology/core.js.map +1 -0
  450. package/dist/graph/topology/grouping.d.ts +13 -0
  451. package/dist/graph/topology/grouping.js.map +1 -0
  452. package/dist/graph/topology/index.d.ts +34 -0
  453. package/dist/graph/topology/index.js +5 -0
  454. package/dist/graph/topology/index.js.map +1 -0
  455. package/dist/graph/topology/resource-segmentation.d.ts +11 -0
  456. package/dist/graph/topology/resource-segmentation.js.map +1 -0
  457. package/dist/graph/topology/segment-incision.d.ts +16 -0
  458. package/dist/graph/topology/segment-incision.js.map +1 -0
  459. package/dist/graph/topology/snake/compare.d.ts +8 -0
  460. package/dist/graph/topology/snake/compare.js +29 -0
  461. package/dist/graph/topology/snake/compare.js.map +1 -0
  462. package/dist/graph/topology/snake/components.d.ts +12 -0
  463. package/dist/graph/topology/snake/components.js +80 -0
  464. package/dist/graph/topology/snake/components.js.map +1 -0
  465. package/dist/graph/topology/snake/constants.d.ts +7 -0
  466. package/dist/graph/topology/snake/constants.js +13 -0
  467. package/dist/graph/topology/snake/constants.js.map +1 -0
  468. package/dist/graph/topology/snake/detect.d.ts +9 -0
  469. package/dist/graph/topology/snake/detect.js +63 -0
  470. package/dist/graph/topology/snake/detect.js.map +1 -0
  471. package/dist/graph/topology/snake/detector.d.ts +3 -0
  472. package/dist/graph/topology/snake/detector.js +7 -0
  473. package/dist/graph/topology/snake/detector.js.map +1 -0
  474. package/dist/graph/topology/snake/fingerprints.d.ts +7 -0
  475. package/dist/graph/topology/snake/fingerprints.js +86 -0
  476. package/dist/graph/topology/snake/fingerprints.js.map +1 -0
  477. package/dist/graph/topology/snake/graph-builder.d.ts +14 -0
  478. package/dist/graph/topology/snake/graph-builder.js +76 -0
  479. package/dist/graph/topology/snake/graph-builder.js.map +1 -0
  480. package/dist/graph/topology/snake/graph.d.ts +7 -0
  481. package/dist/graph/topology/snake/graph.js +105 -0
  482. package/dist/graph/topology/snake/graph.js.map +1 -0
  483. package/dist/graph/topology/snake/index.d.ts +4 -0
  484. package/dist/graph/topology/snake/index.js +3 -0
  485. package/dist/graph/topology/snake/index.js.map +1 -0
  486. package/dist/graph/topology/snake/merge.d.ts +6 -0
  487. package/dist/graph/topology/snake/merge.js +174 -0
  488. package/dist/graph/topology/snake/merge.js.map +1 -0
  489. package/dist/graph/topology/snake/records.d.ts +12 -0
  490. package/dist/graph/topology/snake/records.js +35 -0
  491. package/dist/graph/topology/snake/records.js.map +1 -0
  492. package/dist/graph/topology/snake/types.d.ts +23 -0
  493. package/dist/graph/topology/snake/types.js +1 -0
  494. package/dist/graph/topology/snake/weights.d.ts +3 -0
  495. package/dist/graph/topology/snake/weights.js +17 -0
  496. package/dist/graph/topology/snake/weights.js.map +1 -0
  497. package/dist/graph/topology/weights.d.ts +10 -0
  498. package/dist/graph/topology/weights.js +84 -0
  499. package/dist/graph/topology/weights.js.map +1 -0
  500. package/dist/graph/wikilink/index.d.ts +12 -0
  501. package/dist/graph/wikilink/index.js.map +1 -0
  502. package/dist/graph/wikilink/relation-discovery.d.ts +33 -0
  503. package/dist/graph/wikilink/relation-discovery.js +477 -0
  504. package/dist/graph/wikilink/relation-discovery.js.map +1 -0
  505. package/dist/graph/wikilink/types.d.ts +25 -0
  506. package/dist/graph/wikilink/types.js +1 -0
  507. package/dist/graph/wikilink/window.d.ts +9 -0
  508. package/dist/graph/wikilink/window.js.map +1 -0
  509. package/dist/index.cjs +37928 -29156
  510. package/dist/index.cjs.map +1 -1
  511. package/dist/index.d.cts +1649 -1406
  512. package/dist/index.d.ts +127 -72
  513. package/dist/index.js +337 -27
  514. package/dist/index.js.map +1 -1
  515. package/dist/library/index.d.ts +38 -0
  516. package/dist/library/index.js +6 -0
  517. package/dist/library/index.js.map +1 -0
  518. package/dist/library/lock.d.ts +9 -0
  519. package/dist/library/lock.js +121 -0
  520. package/dist/library/lock.js.map +1 -0
  521. package/dist/library/membership.d.ts +51 -0
  522. package/dist/library/membership.js +812 -0
  523. package/dist/library/membership.js.map +1 -0
  524. package/dist/library/query-helpers.d.ts +45 -0
  525. package/dist/library/query-helpers.js +45 -0
  526. package/dist/library/query-helpers.js.map +1 -0
  527. package/dist/library/query.d.ts +47 -0
  528. package/dist/library/query.js +466 -0
  529. package/dist/library/query.js.map +1 -0
  530. package/dist/library/registry.d.ts +40 -0
  531. package/dist/library/registry.js +601 -0
  532. package/dist/library/registry.js.map +1 -0
  533. package/dist/library/search-index.d.ts +87 -0
  534. package/dist/library/search-index.js +473 -0
  535. package/dist/library/search-index.js.map +1 -0
  536. package/dist/library/search-query.d.ts +32 -0
  537. package/dist/library/search-query.js +418 -0
  538. package/dist/library/search-query.js.map +1 -0
  539. package/dist/library/segments.d.ts +3 -0
  540. package/dist/library/segments.js +16 -0
  541. package/dist/library/segments.js.map +1 -0
  542. package/dist/maintenance/upgrade.d.ts +54 -0
  543. package/dist/maintenance/upgrade.js +195 -0
  544. package/dist/maintenance/upgrade.js.map +1 -0
  545. package/dist/object-stream.d.ts +170 -0
  546. package/dist/object-stream.js +732 -0
  547. package/dist/object-stream.js.map +1 -0
  548. package/dist/retrieval/query/archive-view/backlinks.d.ts +38 -0
  549. package/dist/retrieval/query/archive-view/backlinks.js +200 -0
  550. package/dist/retrieval/query/archive-view/backlinks.js.map +1 -0
  551. package/dist/retrieval/query/archive-view/collection.d.ts +33 -0
  552. package/dist/retrieval/query/archive-view/collection.js +327 -0
  553. package/dist/retrieval/query/archive-view/collection.js.map +1 -0
  554. package/dist/retrieval/query/archive-view/core.d.ts +44 -0
  555. package/dist/retrieval/query/archive-view/core.js +165 -0
  556. package/dist/retrieval/query/archive-view/core.js.map +1 -0
  557. package/dist/retrieval/query/archive-view/evidence-hydration.d.ts +41 -0
  558. package/dist/retrieval/query/archive-view/evidence-hydration.js +311 -0
  559. package/dist/retrieval/query/archive-view/evidence-hydration.js.map +1 -0
  560. package/dist/retrieval/query/archive-view/evidence.d.ts +31 -0
  561. package/dist/retrieval/query/archive-view/evidence.js +166 -0
  562. package/dist/retrieval/query/archive-view/evidence.js.map +1 -0
  563. package/dist/retrieval/query/archive-view/find.d.ts +41 -0
  564. package/dist/retrieval/query/archive-view/find.js +289 -0
  565. package/dist/retrieval/query/archive-view/find.js.map +1 -0
  566. package/dist/retrieval/query/archive-view/helper/constants.d.ts +15 -0
  567. package/dist/retrieval/query/archive-view/helper/constants.js +20 -0
  568. package/dist/retrieval/query/archive-view/helper/constants.js.map +1 -0
  569. package/dist/retrieval/query/archive-view/helper/index.d.ts +34 -0
  570. package/dist/retrieval/query/archive-view/helper/index.js +9 -0
  571. package/dist/retrieval/query/archive-view/helper/index.js.map +1 -0
  572. package/dist/retrieval/query/archive-view/helper/meta.d.ts +17 -0
  573. package/dist/retrieval/query/archive-view/helper/meta.js +57 -0
  574. package/dist/retrieval/query/archive-view/helper/meta.js.map +1 -0
  575. package/dist/retrieval/query/archive-view/helper/parse.d.ts +38 -0
  576. package/dist/retrieval/query/archive-view/helper/parse.js +71 -0
  577. package/dist/retrieval/query/archive-view/helper/parse.js.map +1 -0
  578. package/dist/retrieval/query/archive-view/helper/position.d.ts +39 -0
  579. package/dist/retrieval/query/archive-view/helper/position.js +75 -0
  580. package/dist/retrieval/query/archive-view/helper/position.js.map +1 -0
  581. package/dist/retrieval/query/archive-view/helper/results.d.ts +45 -0
  582. package/dist/retrieval/query/archive-view/helper/results.js +153 -0
  583. package/dist/retrieval/query/archive-view/helper/results.js.map +1 -0
  584. package/dist/retrieval/query/archive-view/helper/sort.d.ts +35 -0
  585. package/dist/retrieval/query/archive-view/helper/sort.js +88 -0
  586. package/dist/retrieval/query/archive-view/helper/sort.js.map +1 -0
  587. package/dist/retrieval/query/archive-view/helper/text.d.ts +46 -0
  588. package/dist/retrieval/query/archive-view/helper/text.js +91 -0
  589. package/dist/retrieval/query/archive-view/helper/text.js.map +1 -0
  590. package/dist/retrieval/query/archive-view/helper/uri.d.ts +4 -0
  591. package/dist/retrieval/query/archive-view/helper/uri.js +12 -0
  592. package/dist/retrieval/query/archive-view/helper/uri.js.map +1 -0
  593. package/dist/retrieval/query/archive-view/helpers.d.ts +34 -0
  594. package/dist/retrieval/query/archive-view/helpers.js +2 -0
  595. package/dist/retrieval/query/archive-view/helpers.js.map +1 -0
  596. package/dist/retrieval/query/archive-view/index-state.d.ts +35 -0
  597. package/dist/retrieval/query/archive-view/index-state.js +191 -0
  598. package/dist/retrieval/query/archive-view/index-state.js.map +1 -0
  599. package/dist/retrieval/query/archive-view/index.d.ts +41 -0
  600. package/dist/retrieval/query/archive-view/index.js +51 -0
  601. package/dist/retrieval/query/archive-view/index.js.map +1 -0
  602. package/dist/retrieval/query/archive-view/knowledge.d.ts +45 -0
  603. package/dist/retrieval/query/archive-view/knowledge.js +99 -0
  604. package/dist/retrieval/query/archive-view/knowledge.js.map +1 -0
  605. package/dist/retrieval/query/archive-view/pack.d.ts +30 -0
  606. package/dist/retrieval/query/archive-view/pack.js +49 -0
  607. package/dist/retrieval/query/archive-view/pack.js.map +1 -0
  608. package/dist/retrieval/query/archive-view/pages.d.ts +41 -0
  609. package/dist/retrieval/query/archive-view/pages.js +341 -0
  610. package/dist/retrieval/query/archive-view/pages.js.map +1 -0
  611. package/dist/retrieval/query/archive-view/references.d.ts +88 -0
  612. package/dist/retrieval/query/archive-view/references.js +287 -0
  613. package/dist/retrieval/query/archive-view/references.js.map +1 -0
  614. package/dist/retrieval/query/archive-view/related/core.d.ts +37 -0
  615. package/dist/retrieval/query/archive-view/related/core.js +163 -0
  616. package/dist/retrieval/query/archive-view/related/core.js.map +1 -0
  617. package/dist/retrieval/query/archive-view/related/entity.d.ts +33 -0
  618. package/dist/retrieval/query/archive-view/related/entity.js +93 -0
  619. package/dist/retrieval/query/archive-view/related/entity.js.map +1 -0
  620. package/dist/retrieval/query/archive-view/related/index.d.ts +37 -0
  621. package/dist/retrieval/query/archive-view/related/index.js +7 -0
  622. package/dist/retrieval/query/archive-view/related/index.js.map +1 -0
  623. package/dist/retrieval/query/archive-view/related/pagination.d.ts +31 -0
  624. package/dist/retrieval/query/archive-view/related/pagination.js +90 -0
  625. package/dist/retrieval/query/archive-view/related/pagination.js.map +1 -0
  626. package/dist/retrieval/query/archive-view/related/query.d.ts +31 -0
  627. package/dist/retrieval/query/archive-view/related/query.js +145 -0
  628. package/dist/retrieval/query/archive-view/related/query.js.map +1 -0
  629. package/dist/retrieval/query/archive-view/related/sort.d.ts +32 -0
  630. package/dist/retrieval/query/archive-view/related/sort.js +85 -0
  631. package/dist/retrieval/query/archive-view/related/sort.js.map +1 -0
  632. package/dist/retrieval/query/archive-view/related/wikipage.d.ts +37 -0
  633. package/dist/retrieval/query/archive-view/related/wikipage.js +43 -0
  634. package/dist/retrieval/query/archive-view/related/wikipage.js.map +1 -0
  635. package/dist/retrieval/query/archive-view/search/bucket-hydration.d.ts +31 -0
  636. package/dist/retrieval/query/archive-view/search/bucket-hydration.js +58 -0
  637. package/dist/retrieval/query/archive-view/search/bucket-hydration.js.map +1 -0
  638. package/dist/retrieval/query/archive-view/search/bucket-order.d.ts +36 -0
  639. package/dist/retrieval/query/archive-view/search/bucket-order.js +64 -0
  640. package/dist/retrieval/query/archive-view/search/bucket-order.js.map +1 -0
  641. package/dist/retrieval/query/archive-view/search/bucket.d.ts +30 -0
  642. package/dist/retrieval/query/archive-view/search/bucket.js +3 -0
  643. package/dist/retrieval/query/archive-view/search/bucket.js.map +1 -0
  644. package/dist/retrieval/query/archive-view/search/buckets.d.ts +42 -0
  645. package/dist/retrieval/query/archive-view/search/buckets.js +302 -0
  646. package/dist/retrieval/query/archive-view/search/buckets.js.map +1 -0
  647. package/dist/retrieval/query/archive-view/search/cache-input.d.ts +45 -0
  648. package/dist/retrieval/query/archive-view/search/cache-input.js +255 -0
  649. package/dist/retrieval/query/archive-view/search/cache-input.js.map +1 -0
  650. package/dist/retrieval/query/archive-view/search/core.d.ts +31 -0
  651. package/dist/retrieval/query/archive-view/search/core.js +388 -0
  652. package/dist/retrieval/query/archive-view/search/core.js.map +1 -0
  653. package/dist/retrieval/query/archive-view/search/hydration.d.ts +51 -0
  654. package/dist/retrieval/query/archive-view/search/hydration.js +234 -0
  655. package/dist/retrieval/query/archive-view/search/hydration.js.map +1 -0
  656. package/dist/retrieval/query/archive-view/search/index.d.ts +35 -0
  657. package/dist/retrieval/query/archive-view/search/index.js +7 -0
  658. package/dist/retrieval/query/archive-view/search/index.js.map +1 -0
  659. package/dist/retrieval/query/archive-view/source-evidence/core.d.ts +60 -0
  660. package/dist/retrieval/query/archive-view/source-evidence/core.js +330 -0
  661. package/dist/retrieval/query/archive-view/source-evidence/core.js.map +1 -0
  662. package/dist/retrieval/query/archive-view/source-evidence/index.d.ts +30 -0
  663. package/dist/retrieval/query/archive-view/source-evidence/index.js +5 -0
  664. package/dist/retrieval/query/archive-view/source-evidence/index.js.map +1 -0
  665. package/dist/retrieval/query/archive-view/source-evidence/pagination.d.ts +46 -0
  666. package/dist/retrieval/query/archive-view/source-evidence/pagination.js +82 -0
  667. package/dist/retrieval/query/archive-view/source-evidence/pagination.js.map +1 -0
  668. package/dist/retrieval/query/archive-view/source-evidence/ranges.d.ts +47 -0
  669. package/dist/retrieval/query/archive-view/source-evidence/ranges.js +209 -0
  670. package/dist/retrieval/query/archive-view/source-evidence/ranges.js.map +1 -0
  671. package/dist/retrieval/query/archive-view/source-evidence/read.d.ts +31 -0
  672. package/dist/retrieval/query/archive-view/source-evidence/read.js +49 -0
  673. package/dist/retrieval/query/archive-view/source-evidence/read.js.map +1 -0
  674. package/dist/retrieval/query/archive-view/source.d.ts +30 -0
  675. package/dist/retrieval/query/archive-view/source.js +2 -0
  676. package/dist/retrieval/query/archive-view/source.js.map +1 -0
  677. package/dist/retrieval/query/archive-view/text-streams.d.ts +44 -0
  678. package/dist/retrieval/query/archive-view/text-streams.js +160 -0
  679. package/dist/retrieval/query/archive-view/text-streams.js.map +1 -0
  680. package/dist/retrieval/query/archive-view/types.d.ts +363 -0
  681. package/dist/retrieval/query/archive-view/types.js +1 -0
  682. package/dist/retrieval/query/continuation-cursor/core.d.ts +6 -0
  683. package/dist/retrieval/query/continuation-cursor/core.js +82 -0
  684. package/dist/retrieval/query/continuation-cursor/core.js.map +1 -0
  685. package/dist/retrieval/query/continuation-cursor/index.d.ts +2 -0
  686. package/dist/retrieval/query/continuation-cursor/index.js +3 -0
  687. package/dist/retrieval/query/continuation-cursor/index.js.map +1 -0
  688. package/dist/retrieval/query/continuation-cursor/payload.d.ts +12 -0
  689. package/dist/retrieval/query/continuation-cursor/payload.js +285 -0
  690. package/dist/retrieval/query/continuation-cursor/payload.js.map +1 -0
  691. package/dist/retrieval/query/continuation-cursor/store.d.ts +10 -0
  692. package/dist/retrieval/query/continuation-cursor/store.js +65 -0
  693. package/dist/retrieval/query/continuation-cursor/store.js.map +1 -0
  694. package/dist/retrieval/query/continuation-cursor/types.d.ts +72 -0
  695. package/dist/retrieval/query/continuation-cursor/types.js +1 -0
  696. package/dist/retrieval/query/continuation-cursor/types.js.map +1 -0
  697. package/dist/retrieval/query/index.d.ts +47 -0
  698. package/dist/retrieval/query/index.js +63 -0
  699. package/dist/retrieval/query/index.js.map +1 -0
  700. package/dist/retrieval/query/lexical-search.js.map +1 -0
  701. package/dist/retrieval/query/search-cache/buckets.d.ts +32 -0
  702. package/dist/retrieval/query/search-cache/buckets.js +87 -0
  703. package/dist/retrieval/query/search-cache/buckets.js.map +1 -0
  704. package/dist/retrieval/query/search-cache/cursor.d.ts +42 -0
  705. package/dist/retrieval/query/search-cache/cursor.js +84 -0
  706. package/dist/retrieval/query/search-cache/cursor.js.map +1 -0
  707. package/dist/retrieval/query/search-cache/database.d.ts +7 -0
  708. package/dist/retrieval/query/search-cache/database.js +47 -0
  709. package/dist/retrieval/query/search-cache/database.js.map +1 -0
  710. package/dist/retrieval/query/search-cache/gc.d.ts +6 -0
  711. package/dist/retrieval/query/search-cache/gc.js +110 -0
  712. package/dist/retrieval/query/search-cache/gc.js.map +1 -0
  713. package/dist/retrieval/query/search-cache/hits.d.ts +42 -0
  714. package/dist/retrieval/query/search-cache/hits.js +446 -0
  715. package/dist/retrieval/query/search-cache/hits.js.map +1 -0
  716. package/dist/retrieval/query/search-cache/ids.d.ts +32 -0
  717. package/dist/retrieval/query/search-cache/ids.js +48 -0
  718. package/dist/retrieval/query/search-cache/ids.js.map +1 -0
  719. package/dist/retrieval/query/search-cache/index.d.ts +33 -0
  720. package/dist/retrieval/query/search-cache/index.js +46 -0
  721. package/dist/retrieval/query/search-cache/index.js.map +1 -0
  722. package/dist/retrieval/query/search-cache/parsing.d.ts +36 -0
  723. package/dist/retrieval/query/search-cache/parsing.js +38 -0
  724. package/dist/retrieval/query/search-cache/parsing.js.map +1 -0
  725. package/dist/retrieval/query/search-cache/schema.d.ts +7 -0
  726. package/dist/retrieval/query/search-cache/schema.js +117 -0
  727. package/dist/retrieval/query/search-cache/schema.js.map +1 -0
  728. package/dist/retrieval/query/search-cache/scores.d.ts +4 -0
  729. package/dist/retrieval/query/search-cache/scores.js +12 -0
  730. package/dist/retrieval/query/search-cache/scores.js.map +1 -0
  731. package/dist/retrieval/query/search-cache/sessions.d.ts +45 -0
  732. package/dist/retrieval/query/search-cache/sessions.js +330 -0
  733. package/dist/retrieval/query/search-cache/sessions.js.map +1 -0
  734. package/dist/retrieval/query/search-cache/store.d.ts +23 -0
  735. package/dist/retrieval/query/search-cache/store.js +111 -0
  736. package/dist/retrieval/query/search-cache/store.js.map +1 -0
  737. package/dist/retrieval/query/search-cache/types.d.ts +164 -0
  738. package/dist/retrieval/query/search-cache/types.js +9 -0
  739. package/dist/retrieval/query/search-cache/types.js.map +1 -0
  740. package/dist/retrieval/query/view.d.ts +41 -0
  741. package/dist/retrieval/query/view.js +2 -0
  742. package/dist/retrieval/query/view.js.map +1 -0
  743. package/dist/retrieval/search-index/index.d.ts +33 -0
  744. package/dist/retrieval/search-index/index.js +41 -0
  745. package/dist/retrieval/search-index/index.js.map +1 -0
  746. package/dist/retrieval/search-index/search/build.d.ts +39 -0
  747. package/dist/retrieval/search-index/search/build.js +212 -0
  748. package/dist/retrieval/search-index/search/build.js.map +1 -0
  749. package/dist/retrieval/search-index/search/core.d.ts +33 -0
  750. package/dist/retrieval/search-index/search/core.js +8 -0
  751. package/dist/retrieval/search-index/search/core.js.map +1 -0
  752. package/dist/retrieval/search-index/search/dirty.d.ts +30 -0
  753. package/dist/retrieval/search-index/search/dirty.js +28 -0
  754. package/dist/retrieval/search-index/search/dirty.js.map +1 -0
  755. package/dist/retrieval/search-index/search/errors.d.ts +3 -0
  756. package/dist/retrieval/search-index/search/errors.js +8 -0
  757. package/dist/retrieval/search-index/search/errors.js.map +1 -0
  758. package/dist/retrieval/search-index/search/fingerprint.d.ts +8 -0
  759. package/dist/retrieval/search-index/search/fingerprint.js +51 -0
  760. package/dist/retrieval/search-index/search/fingerprint.js.map +1 -0
  761. package/dist/retrieval/search-index/search/helpers.d.ts +44 -0
  762. package/dist/retrieval/search-index/search/helpers.js +109 -0
  763. package/dist/retrieval/search-index/search/helpers.js.map +1 -0
  764. package/dist/retrieval/search-index/search/index.d.ts +34 -0
  765. package/dist/retrieval/search-index/search/index.js +3 -0
  766. package/dist/retrieval/search-index/search/index.js.map +1 -0
  767. package/dist/retrieval/search-index/search/match.d.ts +34 -0
  768. package/dist/retrieval/search-index/search/match.js +82 -0
  769. package/dist/retrieval/search-index/search/match.js.map +1 -0
  770. package/dist/retrieval/search-index/search/query.d.ts +44 -0
  771. package/dist/retrieval/search-index/search/query.js +219 -0
  772. package/dist/retrieval/search-index/search/query.js.map +1 -0
  773. package/dist/retrieval/search-index/search/settings.d.ts +29 -0
  774. package/dist/retrieval/search-index/search/settings.js +35 -0
  775. package/dist/retrieval/search-index/search/settings.js.map +1 -0
  776. package/dist/retrieval/search-index/search/status.d.ts +31 -0
  777. package/dist/retrieval/search-index/search/status.js +70 -0
  778. package/dist/retrieval/search-index/search/status.js.map +1 -0
  779. package/dist/retrieval/search-index/search/tokenizer.js +225 -0
  780. package/dist/retrieval/search-index/search/tokenizer.js.map +1 -0
  781. package/dist/retrieval/search-index/search/types.d.ts +79 -0
  782. package/dist/retrieval/search-index/search/types.js +31 -0
  783. package/dist/retrieval/search-index/search/types.js.map +1 -0
  784. package/dist/retrieval/search-index/search/write.d.ts +10 -0
  785. package/dist/retrieval/search-index/search/write.js +70 -0
  786. package/dist/retrieval/search-index/search/write.js.map +1 -0
  787. package/dist/runtime/common/cli-command.js.map +1 -0
  788. package/dist/runtime/common/data-dir.js +49 -0
  789. package/dist/runtime/common/data-dir.js.map +1 -0
  790. package/dist/runtime/common/language.js.map +1 -0
  791. package/dist/runtime/common/llm-scope.js.map +1 -0
  792. package/dist/runtime/common/logging.js.map +1 -0
  793. package/dist/runtime/common/prompts.d.ts +6 -0
  794. package/dist/runtime/common/prompts.js +25 -0
  795. package/dist/runtime/common/prompts.js.map +1 -0
  796. package/dist/runtime/common/template.js.map +1 -0
  797. package/dist/runtime/common/tinyld-language.js.map +1 -0
  798. package/dist/runtime/common/wiki-graph/dir.d.ts +19 -0
  799. package/dist/runtime/common/wiki-graph/dir.js +68 -0
  800. package/dist/runtime/common/wiki-graph/dir.js.map +1 -0
  801. package/dist/runtime/common/wiki-graph/index.d.ts +3 -0
  802. package/dist/runtime/common/wiki-graph/index.js +4 -0
  803. package/dist/runtime/common/wiki-graph/index.js.map +1 -0
  804. package/dist/runtime/common/wiki-graph/temp.js +21 -0
  805. package/dist/runtime/common/wiki-graph/temp.js.map +1 -0
  806. package/dist/runtime/common/wiki-graph/uri.d.ts +37 -0
  807. package/dist/runtime/common/wiki-graph/uri.js +288 -0
  808. package/dist/runtime/common/wiki-graph/uri.js.map +1 -0
  809. package/dist/runtime/context/index.d.ts +1 -0
  810. package/dist/runtime/context/index.js +13 -0
  811. package/dist/runtime/context/index.js.map +1 -0
  812. package/dist/runtime/context/task.js +111 -0
  813. package/dist/runtime/context/task.js.map +1 -0
  814. package/dist/runtime/gc/files.js +141 -0
  815. package/dist/runtime/gc/files.js.map +1 -0
  816. package/dist/runtime/gc/index.js.map +1 -0
  817. package/dist/runtime/gc/lock.js +137 -0
  818. package/dist/runtime/gc/lock.js.map +1 -0
  819. package/dist/runtime/gc/runner.js +134 -0
  820. package/dist/runtime/gc/runner.js.map +1 -0
  821. package/dist/runtime/gc/temp.js +57 -0
  822. package/dist/runtime/gc/temp.js.map +1 -0
  823. package/dist/runtime/gc/types.js +1 -0
  824. package/dist/runtime/gc/types.js.map +1 -0
  825. package/dist/runtime/jobs/conflicts.d.ts +16 -0
  826. package/dist/runtime/jobs/conflicts.js +61 -0
  827. package/dist/runtime/jobs/conflicts.js.map +1 -0
  828. package/dist/runtime/jobs/database.d.ts +12 -0
  829. package/dist/runtime/jobs/database.js +74 -0
  830. package/dist/runtime/jobs/database.js.map +1 -0
  831. package/dist/runtime/jobs/events.d.ts +6 -0
  832. package/dist/runtime/jobs/events.js +29 -0
  833. package/dist/runtime/jobs/events.js.map +1 -0
  834. package/dist/runtime/jobs/gc.d.ts +10 -0
  835. package/dist/runtime/jobs/gc.js +81 -0
  836. package/dist/runtime/jobs/gc.js.map +1 -0
  837. package/dist/runtime/jobs/helpers.d.ts +6 -0
  838. package/dist/runtime/jobs/helpers.js +35 -0
  839. package/dist/runtime/jobs/helpers.js.map +1 -0
  840. package/dist/runtime/jobs/index.d.ts +7 -0
  841. package/dist/runtime/jobs/index.js +42 -0
  842. package/dist/runtime/jobs/index.js.map +1 -0
  843. package/dist/runtime/jobs/jobs.d.ts +24 -0
  844. package/dist/runtime/jobs/jobs.js +416 -0
  845. package/dist/runtime/jobs/jobs.js.map +1 -0
  846. package/dist/runtime/jobs/paths.d.ts +9 -0
  847. package/dist/runtime/jobs/paths.js +48 -0
  848. package/dist/runtime/jobs/paths.js.map +1 -0
  849. package/dist/runtime/jobs/progress.d.ts +37 -0
  850. package/dist/runtime/jobs/progress.js +246 -0
  851. package/dist/runtime/jobs/progress.js.map +1 -0
  852. package/dist/runtime/jobs/recovery.d.ts +6 -0
  853. package/dist/runtime/jobs/recovery.js +40 -0
  854. package/dist/runtime/jobs/recovery.js.map +1 -0
  855. package/dist/runtime/jobs/row.d.ts +10 -0
  856. package/dist/runtime/jobs/row.js +92 -0
  857. package/dist/runtime/jobs/row.js.map +1 -0
  858. package/dist/runtime/jobs/schema.d.ts +3 -0
  859. package/dist/runtime/jobs/schema.js +55 -0
  860. package/dist/runtime/jobs/schema.js.map +1 -0
  861. package/dist/runtime/jobs/state.d.ts +13 -0
  862. package/dist/runtime/jobs/state.js +156 -0
  863. package/dist/runtime/jobs/state.js.map +1 -0
  864. package/dist/runtime/jobs/types.d.ts +141 -0
  865. package/dist/runtime/jobs/types.js +13 -0
  866. package/dist/runtime/jobs/types.js.map +1 -0
  867. package/dist/runtime/jobs/worker.d.ts +5 -0
  868. package/dist/runtime/jobs/worker.js +241 -0
  869. package/dist/runtime/jobs/worker.js.map +1 -0
  870. package/dist/runtime/progress/index.js.map +1 -0
  871. package/dist/runtime/progress/reporter.js.map +1 -0
  872. package/dist/runtime/progress/tracker.js.map +1 -0
  873. package/dist/runtime/progress/types.js +1 -0
  874. package/dist/runtime/progress/types.js.map +1 -0
  875. package/dist/serial.d.ts +36 -85
  876. package/dist/serial.js +1 -475
  877. package/dist/serial.js.map +1 -1
  878. package/dist/state-lock.d.ts +21 -0
  879. package/dist/state-lock.js +233 -0
  880. package/dist/state-lock.js.map +1 -0
  881. package/dist/storage/migration/legacy-sdpub/upgrade/archive.d.ts +11 -0
  882. package/dist/storage/migration/legacy-sdpub/upgrade/archive.js +94 -0
  883. package/dist/storage/migration/legacy-sdpub/upgrade/archive.js.map +1 -0
  884. package/dist/storage/migration/legacy-sdpub/upgrade/database.d.ts +7 -0
  885. package/dist/storage/migration/legacy-sdpub/upgrade/database.js +28 -0
  886. package/dist/storage/migration/legacy-sdpub/upgrade/database.js.map +1 -0
  887. package/dist/storage/migration/legacy-sdpub/upgrade/extract.d.ts +3 -0
  888. package/dist/storage/migration/legacy-sdpub/upgrade/extract.js +68 -0
  889. package/dist/storage/migration/legacy-sdpub/upgrade/extract.js.map +1 -0
  890. package/dist/storage/migration/legacy-sdpub/upgrade/index.js +47 -0
  891. package/dist/storage/migration/legacy-sdpub/upgrade/index.js.map +1 -0
  892. package/dist/storage/migration/legacy-sdpub/upgrade/schema.d.ts +3 -0
  893. package/dist/storage/migration/legacy-sdpub/upgrade/schema.js +41 -0
  894. package/dist/storage/migration/legacy-sdpub/upgrade/schema.js.map +1 -0
  895. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/core.d.ts +3 -0
  896. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/core.js +77 -0
  897. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/core.js.map +1 -0
  898. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/fragments.d.ts +10 -0
  899. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/fragments.js +123 -0
  900. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/fragments.js.map +1 -0
  901. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/index.d.ts +1 -0
  902. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/index.js +2 -0
  903. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/index.js.map +1 -0
  904. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/references.d.ts +5 -0
  905. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/references.js +305 -0
  906. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/references.js.map +1 -0
  907. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/source-text.d.ts +11 -0
  908. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/source-text.js +62 -0
  909. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/source-text.js.map +1 -0
  910. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/summaries.d.ts +3 -0
  911. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/summaries.js +45 -0
  912. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/summaries.js.map +1 -0
  913. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/types.d.ts +19 -0
  914. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/types.js +1 -0
  915. package/dist/storage/migration/legacy-sdpub/upgrade/text-storage/types.js.map +1 -0
  916. package/dist/storage/schema-upgrade/index.d.ts +13 -0
  917. package/dist/storage/schema-upgrade/index.js +320 -0
  918. package/dist/storage/schema-upgrade/index.js.map +1 -0
  919. package/dist/storage/wikg/archive/constants.d.ts +6 -0
  920. package/dist/storage/wikg/archive/constants.js +19 -0
  921. package/dist/storage/wikg/archive/constants.js.map +1 -0
  922. package/dist/storage/wikg/archive/document-files.d.ts +11 -0
  923. package/dist/storage/wikg/archive/document-files.js +70 -0
  924. package/dist/storage/wikg/archive/document-files.js.map +1 -0
  925. package/dist/storage/wikg/archive/extract.d.ts +3 -0
  926. package/dist/storage/wikg/archive/extract.js +37 -0
  927. package/dist/storage/wikg/archive/extract.js.map +1 -0
  928. package/dist/storage/wikg/archive/index.d.ts +6 -0
  929. package/dist/storage/wikg/archive/index.js +25 -0
  930. package/dist/storage/wikg/archive/index.js.map +1 -0
  931. package/dist/storage/wikg/archive/manifest.d.ts +11 -0
  932. package/dist/storage/wikg/archive/manifest.js +60 -0
  933. package/dist/storage/wikg/archive/manifest.js.map +1 -0
  934. package/dist/storage/wikg/archive/paths.d.ts +9 -0
  935. package/dist/storage/wikg/archive/paths.js +46 -0
  936. package/dist/storage/wikg/archive/paths.js.map +1 -0
  937. package/dist/storage/wikg/archive/reader.d.ts +17 -0
  938. package/dist/storage/wikg/archive/reader.js +101 -0
  939. package/dist/storage/wikg/archive/reader.js.map +1 -0
  940. package/dist/storage/wikg/archive/types.d.ts +10 -0
  941. package/dist/storage/wikg/archive/types.js +1 -0
  942. package/dist/storage/wikg/archive/types.js.map +1 -0
  943. package/dist/storage/wikg/archive/write.d.ts +8 -0
  944. package/dist/storage/wikg/archive/write.js +155 -0
  945. package/dist/storage/wikg/archive/write.js.map +1 -0
  946. package/dist/storage/wikg/archive/zip.d.ts +13 -0
  947. package/dist/storage/wikg/archive/zip.js +122 -0
  948. package/dist/storage/wikg/archive/zip.js.map +1 -0
  949. package/dist/storage/wikg/archive-uri.d.ts +1 -0
  950. package/dist/storage/wikg/archive-uri.js +39 -0
  951. package/dist/storage/wikg/archive-uri.js.map +1 -0
  952. package/dist/storage/wikg/coordinator.d.ts +29 -0
  953. package/dist/storage/wikg/coordinator.js +2 -0
  954. package/dist/storage/wikg/coordinator.js.map +1 -0
  955. package/dist/storage/wikg/index.d.ts +41 -0
  956. package/dist/storage/wikg/index.js +68 -0
  957. package/dist/storage/wikg/index.js.map +1 -0
  958. package/dist/storage/wikg/wikg-coordinator/activity.d.ts +4 -0
  959. package/dist/storage/wikg/wikg-coordinator/activity.js +48 -0
  960. package/dist/storage/wikg/wikg-coordinator/activity.js.map +1 -0
  961. package/dist/storage/wikg/wikg-coordinator/archive-key.d.ts +7 -0
  962. package/dist/storage/wikg/wikg-coordinator/archive-key.js +38 -0
  963. package/dist/storage/wikg/wikg-coordinator/archive-key.js.map +1 -0
  964. package/dist/storage/wikg/wikg-coordinator/constants.d.ts +9 -0
  965. package/dist/storage/wikg/wikg-coordinator/constants.js +19 -0
  966. package/dist/storage/wikg/wikg-coordinator/constants.js.map +1 -0
  967. package/dist/storage/wikg/wikg-coordinator/facade.d.ts +40 -0
  968. package/dist/storage/wikg/wikg-coordinator/facade.js +43 -0
  969. package/dist/storage/wikg/wikg-coordinator/facade.js.map +1 -0
  970. package/dist/storage/wikg/wikg-coordinator/file-store.d.ts +52 -0
  971. package/dist/storage/wikg/wikg-coordinator/file-store.js +369 -0
  972. package/dist/storage/wikg/wikg-coordinator/file-store.js.map +1 -0
  973. package/dist/storage/wikg/wikg-coordinator/flusher.d.ts +4 -0
  974. package/dist/storage/wikg/wikg-coordinator/flusher.js +115 -0
  975. package/dist/storage/wikg/wikg-coordinator/flusher.js.map +1 -0
  976. package/dist/storage/wikg/wikg-coordinator/gc.d.ts +5 -0
  977. package/dist/storage/wikg/wikg-coordinator/gc.js +197 -0
  978. package/dist/storage/wikg/wikg-coordinator/gc.js.map +1 -0
  979. package/dist/storage/wikg/wikg-coordinator/index.d.ts +29 -0
  980. package/dist/storage/wikg/wikg-coordinator/index.js +11 -0
  981. package/dist/storage/wikg/wikg-coordinator/index.js.map +1 -0
  982. package/dist/storage/wikg/wikg-coordinator/locks.d.ts +19 -0
  983. package/dist/storage/wikg/wikg-coordinator/locks.js +194 -0
  984. package/dist/storage/wikg/wikg-coordinator/locks.js.map +1 -0
  985. package/dist/storage/wikg/wikg-coordinator/overlays.d.ts +32 -0
  986. package/dist/storage/wikg/wikg-coordinator/overlays.js +141 -0
  987. package/dist/storage/wikg/wikg-coordinator/overlays.js.map +1 -0
  988. package/dist/storage/wikg/wikg-coordinator/owners.d.ts +15 -0
  989. package/dist/storage/wikg/wikg-coordinator/owners.js +95 -0
  990. package/dist/storage/wikg/wikg-coordinator/owners.js.map +1 -0
  991. package/dist/storage/wikg/wikg-coordinator/search-index-cache.d.ts +9 -0
  992. package/dist/storage/wikg/wikg-coordinator/search-index-cache.js +164 -0
  993. package/dist/storage/wikg/wikg-coordinator/search-index-cache.js.map +1 -0
  994. package/dist/storage/wikg/wikg-coordinator/session.d.ts +43 -0
  995. package/dist/storage/wikg/wikg-coordinator/session.js +147 -0
  996. package/dist/storage/wikg/wikg-coordinator/session.js.map +1 -0
  997. package/dist/storage/wikg/wikg-coordinator/state.d.ts +16 -0
  998. package/dist/storage/wikg/wikg-coordinator/state.js +258 -0
  999. package/dist/storage/wikg/wikg-coordinator/state.js.map +1 -0
  1000. package/dist/storage/wikg/wikg-coordinator/types.d.ts +28 -0
  1001. package/dist/storage/wikg/wikg-coordinator/types.js +1 -0
  1002. package/dist/storage/wikg/wikg-coordinator/types.js.map +1 -0
  1003. package/dist/storage/wikg/wikg-coordinator/workspace.d.ts +8 -0
  1004. package/dist/storage/wikg/wikg-coordinator/workspace.js +60 -0
  1005. package/dist/storage/wikg/wikg-coordinator/workspace.js.map +1 -0
  1006. package/dist/storage/wikg/wiki-graph-archive-file.d.ts +45 -0
  1007. package/dist/storage/wikg/wiki-graph-archive-file.js +78 -0
  1008. package/dist/storage/wikg/wiki-graph-archive-file.js.map +1 -0
  1009. package/dist/text/editor/clue.d.ts +40 -0
  1010. package/dist/text/editor/clue.js.map +1 -0
  1011. package/dist/text/editor/compression.d.ts +52 -0
  1012. package/dist/text/editor/compression.js +253 -0
  1013. package/dist/text/editor/compression.js.map +1 -0
  1014. package/dist/text/editor/compressor.d.ts +19 -0
  1015. package/dist/text/editor/compressor.js +123 -0
  1016. package/dist/text/editor/compressor.js.map +1 -0
  1017. package/dist/text/editor/feedback.d.ts +16 -0
  1018. package/dist/text/editor/feedback.js.map +1 -0
  1019. package/dist/text/editor/index.d.ts +30 -0
  1020. package/dist/text/editor/index.js +5 -0
  1021. package/dist/text/editor/index.js.map +1 -0
  1022. package/dist/text/editor/language-review.d.ts +14 -0
  1023. package/dist/text/editor/language-review.js +35 -0
  1024. package/dist/text/editor/language-review.js.map +1 -0
  1025. package/dist/text/editor/log.d.ts +50 -0
  1026. package/dist/text/editor/log.js +202 -0
  1027. package/dist/text/editor/log.js.map +1 -0
  1028. package/dist/text/editor/markup.d.ts +18 -0
  1029. package/dist/text/editor/markup.js +294 -0
  1030. package/dist/text/editor/markup.js.map +1 -0
  1031. package/dist/text/editor/prompt-templates.js.map +1 -0
  1032. package/dist/text/editor/response.js.map +1 -0
  1033. package/dist/text/editor/review.d.ts +47 -0
  1034. package/dist/text/editor/review.js +189 -0
  1035. package/dist/text/editor/review.js.map +1 -0
  1036. package/dist/text/editor/types.js +21 -0
  1037. package/dist/text/editor/types.js.map +1 -0
  1038. package/dist/text/output/epub/archive.js.map +1 -0
  1039. package/dist/text/output/epub/book.d.ts +28 -0
  1040. package/dist/text/output/epub/book.js.map +1 -0
  1041. package/dist/text/output/epub/content.js.map +1 -0
  1042. package/dist/text/output/epub/index.d.ts +33 -0
  1043. package/dist/text/output/epub/index.js.map +1 -0
  1044. package/dist/text/output/epub/model.js.map +1 -0
  1045. package/dist/text/output/epub/navigation.js.map +1 -0
  1046. package/dist/text/output/epub/package.js.map +1 -0
  1047. package/dist/text/output/epub/shared.js.map +1 -0
  1048. package/dist/text/output/epub/templates.js +26 -0
  1049. package/dist/text/output/epub/templates.js.map +1 -0
  1050. package/dist/text/output/index.d.ts +27 -0
  1051. package/dist/text/output/index.js.map +1 -0
  1052. package/dist/text/output/plain-text.d.ts +31 -0
  1053. package/dist/text/output/plain-text.js.map +1 -0
  1054. package/dist/text/reader/attention/core.d.ts +39 -0
  1055. package/dist/text/reader/attention/core.js +123 -0
  1056. package/dist/text/reader/attention/core.js.map +1 -0
  1057. package/dist/text/reader/attention/index.d.ts +9 -0
  1058. package/dist/text/reader/attention/index.js +5 -0
  1059. package/dist/text/reader/attention/index.js.map +1 -0
  1060. package/dist/text/reader/attention/wave-reflection.d.ts +21 -0
  1061. package/dist/text/reader/attention/wave-reflection.js.map +1 -0
  1062. package/dist/text/reader/attention/working-memory.d.ts +28 -0
  1063. package/dist/text/reader/attention/working-memory.js.map +1 -0
  1064. package/dist/text/reader/chunk-batch/extract.d.ts +13 -0
  1065. package/dist/text/reader/chunk-batch/extract.js.map +1 -0
  1066. package/dist/text/reader/chunk-batch/extractor.d.ts +17 -0
  1067. package/dist/text/reader/chunk-batch/extractor.js +337 -0
  1068. package/dist/text/reader/chunk-batch/extractor.js.map +1 -0
  1069. package/dist/text/reader/chunk-batch/fragment-projection.d.ts +34 -0
  1070. package/dist/text/reader/chunk-batch/fragment-projection.js.map +1 -0
  1071. package/dist/text/reader/chunk-batch/index.d.ts +13 -0
  1072. package/dist/text/reader/chunk-batch/index.js +13 -0
  1073. package/dist/text/reader/chunk-batch/index.js.map +1 -0
  1074. package/dist/text/reader/chunk-batch/language.d.ts +9 -0
  1075. package/dist/text/reader/chunk-batch/language.js +23 -0
  1076. package/dist/text/reader/chunk-batch/language.js.map +1 -0
  1077. package/dist/text/reader/chunk-batch/parser/annotations.d.ts +19 -0
  1078. package/dist/text/reader/chunk-batch/parser/annotations.js +34 -0
  1079. package/dist/text/reader/chunk-batch/parser/annotations.js.map +1 -0
  1080. package/dist/text/reader/chunk-batch/parser/core.d.ts +33 -0
  1081. package/dist/text/reader/chunk-batch/parser/core.js +171 -0
  1082. package/dist/text/reader/chunk-batch/parser/core.js.map +1 -0
  1083. package/dist/text/reader/chunk-batch/parser/evidence.d.ts +21 -0
  1084. package/dist/text/reader/chunk-batch/parser/evidence.js +40 -0
  1085. package/dist/text/reader/chunk-batch/parser/evidence.js.map +1 -0
  1086. package/dist/text/reader/chunk-batch/parser/helpers.d.ts +27 -0
  1087. package/dist/text/reader/chunk-batch/parser/helpers.js +98 -0
  1088. package/dist/text/reader/chunk-batch/parser/helpers.js.map +1 -0
  1089. package/dist/text/reader/chunk-batch/parser/index.d.ts +13 -0
  1090. package/dist/text/reader/chunk-batch/parser/index.js +3 -0
  1091. package/dist/text/reader/chunk-batch/parser/index.js.map +1 -0
  1092. package/dist/text/reader/chunk-batch/parser/links.d.ts +17 -0
  1093. package/dist/text/reader/chunk-batch/parser/links.js +44 -0
  1094. package/dist/text/reader/chunk-batch/parser/links.js.map +1 -0
  1095. package/dist/text/reader/chunk-batch/parser/resolver.d.ts +28 -0
  1096. package/dist/text/reader/chunk-batch/parser/resolver.js +267 -0
  1097. package/dist/text/reader/chunk-batch/parser/resolver.js.map +1 -0
  1098. package/dist/text/reader/chunk-batch/parser/schema.d.ts +136 -0
  1099. package/dist/text/reader/chunk-batch/parser/schema.js +71 -0
  1100. package/dist/text/reader/chunk-batch/parser/schema.js.map +1 -0
  1101. package/dist/text/reader/chunk-batch/prompt-templates.js.map +1 -0
  1102. package/dist/text/reader/chunk-batch/types.d.ts +85 -0
  1103. package/dist/text/reader/chunk-batch/types.js +1 -0
  1104. package/dist/text/reader/chunk-batch/types.js.map +1 -0
  1105. package/dist/text/reader/core.d.ts +37 -0
  1106. package/dist/text/reader/core.js +82 -0
  1107. package/dist/text/reader/core.js.map +1 -0
  1108. package/dist/text/reader/index.d.ts +13 -0
  1109. package/dist/text/reader/index.js +7 -0
  1110. package/dist/text/reader/index.js.map +1 -0
  1111. package/dist/text/reader/segment/core.js +9 -0
  1112. package/dist/text/reader/segment/core.js.map +1 -0
  1113. package/dist/text/reader/segment/index.d.ts +2 -0
  1114. package/dist/text/reader/segment/index.js +5 -0
  1115. package/dist/text/reader/segment/index.js.map +1 -0
  1116. package/dist/text/reader/segment/intl-segmenter.js.map +1 -0
  1117. package/dist/text/reader/segment/types.js +1 -0
  1118. package/dist/text/reader/segment/types.js.map +1 -0
  1119. package/dist/text/reader/types.d.ts +29 -0
  1120. package/dist/text/reader/types.js +1 -0
  1121. package/dist/text/reader/types.js.map +1 -0
  1122. package/dist/text/serial/discovery.d.ts +36 -0
  1123. package/dist/text/serial/discovery.js +5 -0
  1124. package/dist/text/serial/discovery.js.map +1 -0
  1125. package/dist/text/serial/fragments.d.ts +67 -0
  1126. package/dist/text/serial/fragments.js +121 -0
  1127. package/dist/text/serial/fragments.js.map +1 -0
  1128. package/dist/text/serial/generation.d.ts +48 -0
  1129. package/dist/text/serial/generation.js +257 -0
  1130. package/dist/text/serial/generation.js.map +1 -0
  1131. package/dist/text/serial/index.d.ts +40 -0
  1132. package/dist/text/serial/index.js +7 -0
  1133. package/dist/text/serial/index.js.map +1 -0
  1134. package/dist/text/serial/options.d.ts +77 -0
  1135. package/dist/text/serial/options.js +17 -0
  1136. package/dist/text/serial/options.js.map +1 -0
  1137. package/dist/text/serial/read.d.ts +28 -0
  1138. package/dist/text/serial/read.js +19 -0
  1139. package/dist/text/serial/read.js.map +1 -0
  1140. package/dist/text/serial/reader-graph.d.ts +39 -0
  1141. package/dist/text/serial/reader-graph.js +27 -0
  1142. package/dist/text/serial/reader-graph.js.map +1 -0
  1143. package/dist/text/serial/record.d.ts +40 -0
  1144. package/dist/text/serial/record.js +21 -0
  1145. package/dist/text/serial/record.js.map +1 -0
  1146. package/dist/text/serial/source.d.ts +39 -0
  1147. package/dist/text/serial/source.js +12 -0
  1148. package/dist/text/serial/source.js.map +1 -0
  1149. package/dist/text/serial/topology.d.ts +43 -0
  1150. package/dist/text/serial/topology.js +64 -0
  1151. package/dist/text/serial/topology.js.map +1 -0
  1152. package/dist/text/source/adapter.js.map +1 -0
  1153. package/dist/text/source/epub/archive.js.map +1 -0
  1154. package/dist/text/source/epub/content.js.map +1 -0
  1155. package/dist/text/source/epub/document.js.map +1 -0
  1156. package/dist/text/source/epub/index.js.map +1 -0
  1157. package/dist/text/source/epub/navigation.js.map +1 -0
  1158. package/dist/text/source/epub/package.js.map +1 -0
  1159. package/dist/text/source/epub/xml.js.map +1 -0
  1160. package/dist/text/source/index.js.map +1 -0
  1161. package/dist/text/source/meta.js.map +1 -0
  1162. package/dist/text/source/plain-text.js.map +1 -0
  1163. package/dist/text/source/toc.d.ts +17 -0
  1164. package/dist/text/source/toc.js +19 -0
  1165. package/dist/text/source/toc.js.map +1 -0
  1166. package/dist/text/source/types.js +1 -0
  1167. package/dist/text/source/types.js.map +1 -0
  1168. package/dist/text/summary-build/artifact.d.ts +44 -0
  1169. package/dist/text/summary-build/artifact.js +157 -0
  1170. package/dist/text/summary-build/artifact.js.map +1 -0
  1171. package/dist/text/summary-build/build.d.ts +37 -0
  1172. package/dist/text/summary-build/build.js +60 -0
  1173. package/dist/text/summary-build/build.js.map +1 -0
  1174. package/dist/text/summary-build/index.d.ts +38 -0
  1175. package/dist/text/summary-build/index.js +4 -0
  1176. package/dist/text/summary-build/index.js.map +1 -0
  1177. package/dist/text/summary-build/schema.d.ts +106 -0
  1178. package/dist/text/summary-build/schema.js +118 -0
  1179. package/dist/text/summary-build/schema.js.map +1 -0
  1180. package/dist/text/summary-build/snapshot/chunk-store.d.ts +17 -0
  1181. package/dist/text/summary-build/snapshot/chunk-store.js +68 -0
  1182. package/dist/text/summary-build/snapshot/chunk-store.js.map +1 -0
  1183. package/dist/text/summary-build/snapshot/empty-stores.d.ts +50 -0
  1184. package/dist/text/summary-build/snapshot/empty-stores.js +60 -0
  1185. package/dist/text/summary-build/snapshot/empty-stores.js.map +1 -0
  1186. package/dist/text/summary-build/snapshot/graph-stores.d.ts +42 -0
  1187. package/dist/text/summary-build/snapshot/graph-stores.js +148 -0
  1188. package/dist/text/summary-build/snapshot/graph-stores.js.map +1 -0
  1189. package/dist/text/summary-build/snapshot/helpers.d.ts +17 -0
  1190. package/dist/text/summary-build/snapshot/helpers.js +65 -0
  1191. package/dist/text/summary-build/snapshot/helpers.js.map +1 -0
  1192. package/dist/text/summary-build/snapshot/index.d.ts +63 -0
  1193. package/dist/text/summary-build/snapshot/index.js +106 -0
  1194. package/dist/text/summary-build/snapshot/index.js.map +1 -0
  1195. package/dist/text/summary-build/snapshot/serial-store.d.ts +29 -0
  1196. package/dist/text/summary-build/snapshot/serial-store.js +92 -0
  1197. package/dist/text/summary-build/snapshot/serial-store.js.map +1 -0
  1198. package/dist/text/summary-build/snapshot-io.d.ts +14 -0
  1199. package/dist/text/summary-build/snapshot-io.js +25 -0
  1200. package/dist/text/summary-build/snapshot-io.js.map +1 -0
  1201. package/dist/text/summary-build/source.d.ts +39 -0
  1202. package/dist/text/summary-build/source.js +30 -0
  1203. package/dist/text/summary-build/source.js.map +1 -0
  1204. package/dist/text/summary-build/types.d.ts +34 -0
  1205. package/dist/text/summary-build/types.js +1 -0
  1206. package/dist/text/summary-build/types.js.map +1 -0
  1207. package/dist/worker-DWasYKWW.d.cts +143 -0
  1208. package/dist/worker.cjs +5560 -2312
  1209. package/dist/worker.cjs.map +1 -1
  1210. package/dist/worker.d.cts +1 -2
  1211. package/dist/worker.d.ts +2 -2
  1212. package/dist/worker.js +1 -1
  1213. package/dist/worker.js.map +1 -1
  1214. package/package.json +3 -2
  1215. package/dist/archive/query/archive-view.d.ts +0 -26
  1216. package/dist/archive/query/archive-view.js +0 -4540
  1217. package/dist/archive/query/archive-view.js.map +0 -1
  1218. package/dist/archive/query/continuation-cursor.d.ts +0 -61
  1219. package/dist/archive/query/continuation-cursor.js +0 -363
  1220. package/dist/archive/query/continuation-cursor.js.map +0 -1
  1221. package/dist/archive/query/index.d.ts +0 -29
  1222. package/dist/archive/query/index.js +0 -63
  1223. package/dist/archive/query/index.js.map +0 -1
  1224. package/dist/archive/query/lexical-search.js.map +0 -1
  1225. package/dist/archive/query/search-cache.d.ts +0 -192
  1226. package/dist/archive/query/search-cache.js +0 -1248
  1227. package/dist/archive/query/search-cache.js.map +0 -1
  1228. package/dist/archive/search-index/index.d.ts +0 -26
  1229. package/dist/archive/search-index/index.js +0 -29
  1230. package/dist/archive/search-index/index.js.map +0 -1
  1231. package/dist/archive/search-index/search-index.d.ts +0 -26
  1232. package/dist/archive/search-index/search-index.js +0 -555
  1233. package/dist/archive/search-index/search-index.js.map +0 -1
  1234. package/dist/archive/search-index/search-tokenizer.js +0 -225
  1235. package/dist/archive/search-index/search-tokenizer.js.map +0 -1
  1236. package/dist/common/cli-command.js.map +0 -1
  1237. package/dist/common/data-dir.js +0 -48
  1238. package/dist/common/data-dir.js.map +0 -1
  1239. package/dist/common/language.js.map +0 -1
  1240. package/dist/common/llm-scope.js.map +0 -1
  1241. package/dist/common/logging.js.map +0 -1
  1242. package/dist/common/template.js.map +0 -1
  1243. package/dist/common/tinyld-language.js.map +0 -1
  1244. package/dist/common/wiki-graph-dir.d.ts +0 -10
  1245. package/dist/common/wiki-graph-dir.js +0 -41
  1246. package/dist/common/wiki-graph-dir.js.map +0 -1
  1247. package/dist/common/wiki-graph-temp.js +0 -21
  1248. package/dist/common/wiki-graph-temp.js.map +0 -1
  1249. package/dist/common/wiki-graph-uri.d.ts +0 -28
  1250. package/dist/common/wiki-graph-uri.js +0 -171
  1251. package/dist/common/wiki-graph-uri.js.map +0 -1
  1252. package/dist/context/index.d.ts +0 -1
  1253. package/dist/context/index.js +0 -13
  1254. package/dist/context/index.js.map +0 -1
  1255. package/dist/context/task-context.js +0 -111
  1256. package/dist/context/task-context.js.map +0 -1
  1257. package/dist/document/document.d.ts +0 -153
  1258. package/dist/document/document.js +0 -615
  1259. package/dist/document/document.js.map +0 -1
  1260. package/dist/document/fragments.d.ts +0 -63
  1261. package/dist/document/fragments.js +0 -371
  1262. package/dist/document/fragments.js.map +0 -1
  1263. package/dist/document/stores.d.ts +0 -203
  1264. package/dist/document/stores.js +0 -1678
  1265. package/dist/document/stores.js.map +0 -1
  1266. package/dist/document/text-streams.d.ts +0 -86
  1267. package/dist/document/text-streams.js +0 -515
  1268. package/dist/document/text-streams.js.map +0 -1
  1269. package/dist/editor/clue.d.ts +0 -27
  1270. package/dist/editor/clue.js.map +0 -1
  1271. package/dist/editor/compressor.d.ts +0 -18
  1272. package/dist/editor/compressor.js +0 -68
  1273. package/dist/editor/compressor.js.map +0 -1
  1274. package/dist/editor/editor.d.ts +0 -39
  1275. package/dist/editor/editor.js +0 -253
  1276. package/dist/editor/editor.js.map +0 -1
  1277. package/dist/editor/feedback.d.ts +0 -16
  1278. package/dist/editor/feedback.js.map +0 -1
  1279. package/dist/editor/index.d.ts +0 -17
  1280. package/dist/editor/index.js +0 -5
  1281. package/dist/editor/index.js.map +0 -1
  1282. package/dist/editor/language-review.d.ts +0 -14
  1283. package/dist/editor/language-review.js +0 -35
  1284. package/dist/editor/language-review.js.map +0 -1
  1285. package/dist/editor/log.d.ts +0 -37
  1286. package/dist/editor/log.js +0 -202
  1287. package/dist/editor/log.js.map +0 -1
  1288. package/dist/editor/markup.d.ts +0 -20
  1289. package/dist/editor/markup.js +0 -294
  1290. package/dist/editor/markup.js.map +0 -1
  1291. package/dist/editor/prompt-templates.js.map +0 -1
  1292. package/dist/editor/response.js.map +0 -1
  1293. package/dist/editor/review.d.ts +0 -34
  1294. package/dist/editor/review.js +0 -189
  1295. package/dist/editor/review.js.map +0 -1
  1296. package/dist/editor/types.js +0 -21
  1297. package/dist/editor/types.js.map +0 -1
  1298. package/dist/evidence-selection/anchor-resolver.d.ts +0 -43
  1299. package/dist/evidence-selection/anchor-resolver.js +0 -783
  1300. package/dist/evidence-selection/anchor-resolver.js.map +0 -1
  1301. package/dist/evidence-selection/anchor-types.d.ts +0 -27
  1302. package/dist/evidence-selection/anchor-types.js +0 -1
  1303. package/dist/evidence-selection/index.d.ts +0 -8
  1304. package/dist/evidence-selection/index.js +0 -32
  1305. package/dist/evidence-selection/index.js.map +0 -1
  1306. package/dist/evidence-selection/prompt.js.map +0 -1
  1307. package/dist/evidence-selection/quote-score.js.map +0 -1
  1308. package/dist/evidence-selection/selection-resolver.js +0 -303
  1309. package/dist/evidence-selection/selection-resolver.js.map +0 -1
  1310. package/dist/evidence-selection/text.js.map +0 -1
  1311. package/dist/facade/app.d.ts +0 -75
  1312. package/dist/facade/app.js +0 -141
  1313. package/dist/facade/app.js.map +0 -1
  1314. package/dist/facade/build-queue.d.ts +0 -181
  1315. package/dist/facade/build-queue.js +0 -1442
  1316. package/dist/facade/build-queue.js.map +0 -1
  1317. package/dist/facade/chapter-build.d.ts +0 -60
  1318. package/dist/facade/chapter-build.js +0 -1020
  1319. package/dist/facade/chapter-build.js.map +0 -1
  1320. package/dist/facade/chapter.d.ts +0 -168
  1321. package/dist/facade/chapter.js +0 -944
  1322. package/dist/facade/chapter.js.map +0 -1
  1323. package/dist/facade/digest.d.ts +0 -55
  1324. package/dist/facade/digest.js +0 -168
  1325. package/dist/facade/digest.js.map +0 -1
  1326. package/dist/facade/graph.d.ts +0 -60
  1327. package/dist/facade/graph.js +0 -203
  1328. package/dist/facade/graph.js.map +0 -1
  1329. package/dist/facade/import.d.ts +0 -49
  1330. package/dist/facade/import.js +0 -262
  1331. package/dist/facade/import.js.map +0 -1
  1332. package/dist/facade/index.d.ts +0 -39
  1333. package/dist/facade/index.js +0 -171
  1334. package/dist/facade/index.js.map +0 -1
  1335. package/dist/facade/knowledge-graph-build.d.ts +0 -75
  1336. package/dist/facade/knowledge-graph-build.js +0 -897
  1337. package/dist/facade/knowledge-graph-build.js.map +0 -1
  1338. package/dist/facade/llm-sampling.d.ts +0 -11
  1339. package/dist/facade/llm-sampling.js +0 -58
  1340. package/dist/facade/llm-sampling.js.map +0 -1
  1341. package/dist/facade/wiki-graph-archive.d.ts +0 -41
  1342. package/dist/facade/wiki-graph-archive.js +0 -130
  1343. package/dist/facade/wiki-graph-archive.js.map +0 -1
  1344. package/dist/gc/files.js +0 -141
  1345. package/dist/gc/files.js.map +0 -1
  1346. package/dist/gc/index.js.map +0 -1
  1347. package/dist/gc/lock.js +0 -137
  1348. package/dist/gc/lock.js.map +0 -1
  1349. package/dist/gc/runner.js +0 -129
  1350. package/dist/gc/runner.js.map +0 -1
  1351. package/dist/gc/tmp-gc.js +0 -57
  1352. package/dist/gc/tmp-gc.js.map +0 -1
  1353. package/dist/guaranteed/classifier.js.map +0 -1
  1354. package/dist/guaranteed/errors.js.map +0 -1
  1355. package/dist/guaranteed/index.js.map +0 -1
  1356. package/dist/guaranteed/request.js.map +0 -1
  1357. package/dist/guaranteed/response.js.map +0 -1
  1358. package/dist/index-B8NNnQ8P.d.ts +0 -424
  1359. package/dist/legacy-sdpub/upgrade.js +0 -795
  1360. package/dist/legacy-sdpub/upgrade.js.map +0 -1
  1361. package/dist/llm/cache.js +0 -35
  1362. package/dist/llm/cache.js.map +0 -1
  1363. package/dist/llm/client.d.ts +0 -26
  1364. package/dist/llm/client.js +0 -572
  1365. package/dist/llm/client.js.map +0 -1
  1366. package/dist/llm/context.js +0 -78
  1367. package/dist/llm/context.js.map +0 -1
  1368. package/dist/llm/errors.js.map +0 -1
  1369. package/dist/llm/index.d.ts +0 -7
  1370. package/dist/llm/index.js +0 -17
  1371. package/dist/llm/index.js.map +0 -1
  1372. package/dist/llm/request-log.js +0 -35
  1373. package/dist/llm/request-log.js.map +0 -1
  1374. package/dist/llm/sampling.js.map +0 -1
  1375. package/dist/output/epub/archive.js.map +0 -1
  1376. package/dist/output/epub/book.d.ts +0 -15
  1377. package/dist/output/epub/book.js.map +0 -1
  1378. package/dist/output/epub/content.js.map +0 -1
  1379. package/dist/output/epub/index.d.ts +0 -20
  1380. package/dist/output/epub/index.js.map +0 -1
  1381. package/dist/output/epub/navigation.js.map +0 -1
  1382. package/dist/output/epub/package.js.map +0 -1
  1383. package/dist/output/epub/shared.js.map +0 -1
  1384. package/dist/output/epub/templates.js +0 -26
  1385. package/dist/output/epub/templates.js.map +0 -1
  1386. package/dist/output/index.d.ts +0 -14
  1387. package/dist/output/index.js.map +0 -1
  1388. package/dist/output/plain-text.d.ts +0 -18
  1389. package/dist/output/plain-text.js.map +0 -1
  1390. package/dist/progress/index.js.map +0 -1
  1391. package/dist/progress/reporter.js.map +0 -1
  1392. package/dist/progress/tracker.js.map +0 -1
  1393. package/dist/reader/attention/attention.d.ts +0 -39
  1394. package/dist/reader/attention/attention.js +0 -123
  1395. package/dist/reader/attention/attention.js.map +0 -1
  1396. package/dist/reader/attention/index.d.ts +0 -9
  1397. package/dist/reader/attention/index.js +0 -5
  1398. package/dist/reader/attention/index.js.map +0 -1
  1399. package/dist/reader/attention/wave-reflection.d.ts +0 -21
  1400. package/dist/reader/attention/wave-reflection.js.map +0 -1
  1401. package/dist/reader/attention/working-memory.d.ts +0 -28
  1402. package/dist/reader/attention/working-memory.js.map +0 -1
  1403. package/dist/reader/chunk-batch/extract.d.ts +0 -13
  1404. package/dist/reader/chunk-batch/extract.js.map +0 -1
  1405. package/dist/reader/chunk-batch/extractor.d.ts +0 -17
  1406. package/dist/reader/chunk-batch/extractor.js +0 -337
  1407. package/dist/reader/chunk-batch/extractor.js.map +0 -1
  1408. package/dist/reader/chunk-batch/fragment-projection.d.ts +0 -34
  1409. package/dist/reader/chunk-batch/fragment-projection.js.map +0 -1
  1410. package/dist/reader/chunk-batch/index.d.ts +0 -12
  1411. package/dist/reader/chunk-batch/index.js +0 -13
  1412. package/dist/reader/chunk-batch/index.js.map +0 -1
  1413. package/dist/reader/chunk-batch/language.d.ts +0 -9
  1414. package/dist/reader/chunk-batch/language.js +0 -23
  1415. package/dist/reader/chunk-batch/language.js.map +0 -1
  1416. package/dist/reader/chunk-batch/parser.d.ts +0 -94
  1417. package/dist/reader/chunk-batch/parser.js +0 -640
  1418. package/dist/reader/chunk-batch/parser.js.map +0 -1
  1419. package/dist/reader/chunk-batch/prompt-templates.js.map +0 -1
  1420. package/dist/reader/chunk-batch/types.d.ts +0 -85
  1421. package/dist/reader/index.d.ts +0 -13
  1422. package/dist/reader/index.js +0 -7
  1423. package/dist/reader/index.js.map +0 -1
  1424. package/dist/reader/reader.d.ts +0 -37
  1425. package/dist/reader/reader.js +0 -82
  1426. package/dist/reader/reader.js.map +0 -1
  1427. package/dist/reader/segment/index.d.ts +0 -2
  1428. package/dist/reader/segment/index.js +0 -5
  1429. package/dist/reader/segment/index.js.map +0 -1
  1430. package/dist/reader/segment/intl-segmenter.js.map +0 -1
  1431. package/dist/reader/segment/segment.js +0 -9
  1432. package/dist/reader/segment/segment.js.map +0 -1
  1433. package/dist/reader/types.d.ts +0 -29
  1434. package/dist/source/epub/archive.js.map +0 -1
  1435. package/dist/source/epub/content.js.map +0 -1
  1436. package/dist/source/epub/document.js.map +0 -1
  1437. package/dist/source/epub/index.js.map +0 -1
  1438. package/dist/source/epub/navigation.js.map +0 -1
  1439. package/dist/source/epub/package.js.map +0 -1
  1440. package/dist/source/epub/xml.js.map +0 -1
  1441. package/dist/source/index.js.map +0 -1
  1442. package/dist/source/meta.js.map +0 -1
  1443. package/dist/source/plain-text.js.map +0 -1
  1444. package/dist/source/toc.d.ts +0 -16
  1445. package/dist/source/toc.js +0 -17
  1446. package/dist/source/toc.js.map +0 -1
  1447. package/dist/topology/grouping.d.ts +0 -15
  1448. package/dist/topology/grouping.js.map +0 -1
  1449. package/dist/topology/index.d.ts +0 -21
  1450. package/dist/topology/index.js +0 -5
  1451. package/dist/topology/index.js.map +0 -1
  1452. package/dist/topology/resource-segmentation.d.ts +0 -13
  1453. package/dist/topology/resource-segmentation.js.map +0 -1
  1454. package/dist/topology/segment-incision.d.ts +0 -18
  1455. package/dist/topology/segment-incision.js.map +0 -1
  1456. package/dist/topology/snake-detector.d.ts +0 -13
  1457. package/dist/topology/snake-detector.js +0 -520
  1458. package/dist/topology/snake-detector.js.map +0 -1
  1459. package/dist/topology/snake-graph-builder.d.ts +0 -14
  1460. package/dist/topology/snake-graph-builder.js +0 -76
  1461. package/dist/topology/snake-graph-builder.js.map +0 -1
  1462. package/dist/topology/topology.d.ts +0 -29
  1463. package/dist/topology/topology.js +0 -348
  1464. package/dist/topology/topology.js.map +0 -1
  1465. package/dist/topology/weights.d.ts +0 -10
  1466. package/dist/topology/weights.js +0 -84
  1467. package/dist/topology/weights.js.map +0 -1
  1468. package/dist/types-FVIqiLC9.d.cts +0 -24
  1469. package/dist/wikg/archive-uri.d.ts +0 -1
  1470. package/dist/wikg/archive-uri.js +0 -37
  1471. package/dist/wikg/archive-uri.js.map +0 -1
  1472. package/dist/wikg/archive.d.ts +0 -28
  1473. package/dist/wikg/archive.js +0 -496
  1474. package/dist/wikg/archive.js.map +0 -1
  1475. package/dist/wikg/index.d.ts +0 -31
  1476. package/dist/wikg/index.js +0 -60
  1477. package/dist/wikg/index.js.map +0 -1
  1478. package/dist/wikg/wikg-coordinator.d.ts +0 -45
  1479. package/dist/wikg/wikg-coordinator.js +0 -1687
  1480. package/dist/wikg/wikg-coordinator.js.map +0 -1
  1481. package/dist/wikg/wiki-graph-archive-file.d.ts +0 -42
  1482. package/dist/wikg/wiki-graph-archive-file.js +0 -78
  1483. package/dist/wikg/wiki-graph-archive-file.js.map +0 -1
  1484. package/dist/wikilink/index.d.ts +0 -10
  1485. package/dist/wikilink/index.js.map +0 -1
  1486. package/dist/wikilink/relation-discovery.d.ts +0 -31
  1487. package/dist/wikilink/relation-discovery.js +0 -477
  1488. package/dist/wikilink/relation-discovery.js.map +0 -1
  1489. package/dist/wikilink/types.d.ts +0 -23
  1490. package/dist/wikilink/window.d.ts +0 -7
  1491. package/dist/wikilink/window.js.map +0 -1
  1492. package/dist/wikimatch/enrichment.d.ts +0 -10
  1493. package/dist/wikimatch/enrichment.js +0 -55
  1494. package/dist/wikimatch/enrichment.js.map +0 -1
  1495. package/dist/wikimatch/index.d.ts +0 -16
  1496. package/dist/wikimatch/index.js +0 -66
  1497. package/dist/wikimatch/index.js.map +0 -1
  1498. package/dist/wikimatch/option-narrowing.d.ts +0 -17
  1499. package/dist/wikimatch/option-narrowing.js.map +0 -1
  1500. package/dist/wikimatch/options.d.ts +0 -14
  1501. package/dist/wikimatch/options.js +0 -155
  1502. package/dist/wikimatch/options.js.map +0 -1
  1503. package/dist/wikimatch/policy-judge.d.ts +0 -17
  1504. package/dist/wikimatch/policy-judge.js +0 -430
  1505. package/dist/wikimatch/policy-judge.js.map +0 -1
  1506. package/dist/wikimatch/range-suppression.js.map +0 -1
  1507. package/dist/wikimatch/surface-screening.d.ts +0 -16
  1508. package/dist/wikimatch/surface-screening.js +0 -168
  1509. package/dist/wikimatch/surface-screening.js.map +0 -1
  1510. package/dist/wikimatch/surface-window.d.ts +0 -6
  1511. package/dist/wikimatch/surface-window.js +0 -44
  1512. package/dist/wikimatch/surface-window.js.map +0 -1
  1513. package/dist/wikimatch/types.d.ts +0 -151
  1514. package/dist/wikimatch/wikispine.d.ts +0 -43
  1515. package/dist/wikimatch/wikispine.js.map +0 -1
  1516. package/dist/wikimatch/window.d.ts +0 -6
  1517. package/dist/wikimatch/window.js.map +0 -1
  1518. package/dist/wikimatch/words.js.map +0 -1
  1519. package/dist/wikipage/cache.d.ts +0 -18
  1520. package/dist/wikipage/cache.js +0 -404
  1521. package/dist/wikipage/cache.js.map +0 -1
  1522. package/dist/wikipage/fetch-log.js +0 -143
  1523. package/dist/wikipage/fetch-log.js.map +0 -1
  1524. package/dist/wikipage/index.d.ts +0 -14
  1525. package/dist/wikipage/index.js +0 -17
  1526. package/dist/wikipage/index.js.map +0 -1
  1527. package/dist/wikipage/normalizer.d.ts +0 -14
  1528. package/dist/wikipage/normalizer.js +0 -147
  1529. package/dist/wikipage/normalizer.js.map +0 -1
  1530. package/dist/wikipage/rate-limiter.js.map +0 -1
  1531. package/dist/wikipage/resolver.d.ts +0 -26
  1532. package/dist/wikipage/resolver.js +0 -325
  1533. package/dist/wikipage/resolver.js.map +0 -1
  1534. package/dist/wikipage/types.d.ts +0 -96
  1535. package/dist/wikipage/wikimedia-client.d.ts +0 -48
  1536. package/dist/wikipage/wikimedia-client.js +0 -397
  1537. package/dist/wikipage/wikimedia-client.js.map +0 -1
  1538. package/dist/worker-BgQ0Xl8T.d.cts +0 -181
  1539. /package/dist/{evidence-selection → api/chapter-build}/types.js +0 -0
  1540. /package/dist/{evidence-selection → api/chapter-build}/types.js.map +0 -0
  1541. /package/dist/{facade → api/knowledge-graph-build}/types.js +0 -0
  1542. /package/dist/{facade → api/knowledge-graph-build}/types.js.map +0 -0
  1543. /package/dist/{facade → api}/types.d.ts +0 -0
  1544. /package/dist/{gc → api}/types.js +0 -0
  1545. /package/dist/{gc → api}/types.js.map +0 -0
  1546. /package/dist/{guaranteed → document/directory}/types.js +0 -0
  1547. /package/dist/{guaranteed → document/directory}/types.js.map +0 -0
  1548. /package/dist/{llm → document/stores}/types.js +0 -0
  1549. /package/dist/{llm → document/stores}/types.js.map +0 -0
  1550. /package/dist/{guaranteed → external/guaranteed}/classifier.d.ts +0 -0
  1551. /package/dist/{guaranteed → external/guaranteed}/classifier.js +0 -0
  1552. /package/dist/{guaranteed → external/guaranteed}/errors.d.ts +0 -0
  1553. /package/dist/{guaranteed → external/guaranteed}/errors.js +0 -0
  1554. /package/dist/{guaranteed → external/guaranteed}/index.d.ts +0 -0
  1555. /package/dist/{guaranteed → external/guaranteed}/index.js +0 -0
  1556. /package/dist/{guaranteed → external/guaranteed}/request.d.ts +0 -0
  1557. /package/dist/{guaranteed → external/guaranteed}/request.js +0 -0
  1558. /package/dist/{guaranteed → external/guaranteed}/response.d.ts +0 -0
  1559. /package/dist/{guaranteed → external/guaranteed}/response.js +0 -0
  1560. /package/dist/{guaranteed → external/guaranteed}/types.d.ts +0 -0
  1561. /package/dist/{progress → external/guaranteed}/types.js +0 -0
  1562. /package/dist/{progress → external/guaranteed}/types.js.map +0 -0
  1563. /package/dist/{llm → external/llm}/cache.d.ts +0 -0
  1564. /package/dist/{llm → external/llm}/context.d.ts +0 -0
  1565. /package/dist/{llm → external/llm}/errors.d.ts +0 -0
  1566. /package/dist/{llm → external/llm}/errors.js +0 -0
  1567. /package/dist/{llm → external/llm}/request-log.d.ts +0 -0
  1568. /package/dist/{llm → external/llm}/sampling.d.ts +0 -0
  1569. /package/dist/{llm → external/llm}/sampling.js +0 -0
  1570. /package/dist/{llm → external/llm}/types.d.ts +0 -0
  1571. /package/dist/{reader/chunk-batch → external/llm}/types.js +0 -0
  1572. /package/dist/{reader/chunk-batch → external/llm}/types.js.map +0 -0
  1573. /package/dist/{wikimatch → external/wikimatch}/option-narrowing.js +0 -0
  1574. /package/dist/{wikimatch → external/wikimatch}/range-suppression.d.ts +0 -0
  1575. /package/dist/{wikimatch → external/wikimatch}/range-suppression.js +0 -0
  1576. /package/dist/{reader/segment → external/wikimatch}/types.js +0 -0
  1577. /package/dist/{reader/segment → external/wikimatch}/types.js.map +0 -0
  1578. /package/dist/{wikimatch → external/wikimatch}/wikispine.js +0 -0
  1579. /package/dist/{wikimatch → external/wikimatch}/window.js +0 -0
  1580. /package/dist/{wikimatch → external/wikimatch}/words.d.ts +0 -0
  1581. /package/dist/{wikimatch → external/wikimatch}/words.js +0 -0
  1582. /package/dist/{wikipage → external/wikipage}/fetch-log.d.ts +0 -0
  1583. /package/dist/{wikipage → external/wikipage}/rate-limiter.d.ts +0 -0
  1584. /package/dist/{wikipage → external/wikipage}/rate-limiter.js +0 -0
  1585. /package/dist/{reader → external/wikipage}/types.js +0 -0
  1586. /package/dist/{reader → external/wikipage}/types.js.map +0 -0
  1587. /package/dist/{source → graph/evidence-selection/anchor}/types.js +0 -0
  1588. /package/dist/{source → graph/evidence-selection/anchor}/types.js.map +0 -0
  1589. /package/dist/{evidence-selection → graph/evidence-selection}/prompt.d.ts +0 -0
  1590. /package/dist/{evidence-selection → graph/evidence-selection}/prompt.js +0 -0
  1591. /package/dist/{evidence-selection → graph/evidence-selection}/quote-score.d.ts +0 -0
  1592. /package/dist/{evidence-selection → graph/evidence-selection}/quote-score.js +0 -0
  1593. /package/dist/{evidence-selection/selection-resolver.d.ts → graph/evidence-selection/resolver.d.ts} +0 -0
  1594. /package/dist/{evidence-selection → graph/evidence-selection}/text.d.ts +0 -0
  1595. /package/dist/{evidence-selection → graph/evidence-selection}/text.js +0 -0
  1596. /package/dist/{evidence-selection → graph/evidence-selection}/types.d.ts +0 -0
  1597. /package/dist/{wikilink → graph/evidence-selection}/types.js +0 -0
  1598. /package/dist/{wikilink → graph/evidence-selection}/types.js.map +0 -0
  1599. /package/dist/{wikimatch → graph/knowledge-build}/types.js +0 -0
  1600. /package/dist/{wikimatch → graph/knowledge-build}/types.js.map +0 -0
  1601. /package/dist/{wikipage → graph/reading-build}/types.js +0 -0
  1602. /package/dist/{wikipage → graph/reading-build}/types.js.map +0 -0
  1603. /package/dist/{topology → graph/topology}/grouping.js +0 -0
  1604. /package/dist/{topology → graph/topology}/resource-segmentation.js +0 -0
  1605. /package/dist/{topology → graph/topology}/segment-incision.js +0 -0
  1606. /package/dist/{evidence-selection/anchor-types.js.map → graph/topology/snake/types.js.map} +0 -0
  1607. /package/dist/{wikilink → graph/wikilink}/index.js +0 -0
  1608. /package/dist/{output/epub/model.js.map → graph/wikilink/types.js.map} +0 -0
  1609. /package/dist/{wikilink → graph/wikilink}/window.js +0 -0
  1610. /package/dist/{source/adapter.js.map → retrieval/query/archive-view/types.js.map} +0 -0
  1611. /package/dist/{archive → retrieval}/query/lexical-search.d.ts +0 -0
  1612. /package/dist/{archive → retrieval}/query/lexical-search.js +0 -0
  1613. /package/dist/{archive/search-index/search-tokenizer.d.ts → retrieval/search-index/search/tokenizer.d.ts} +0 -0
  1614. /package/dist/{common → runtime/common}/cli-command.d.ts +0 -0
  1615. /package/dist/{common → runtime/common}/cli-command.js +0 -0
  1616. /package/dist/{common → runtime/common}/data-dir.d.ts +0 -0
  1617. /package/dist/{common → runtime/common}/language.d.ts +0 -0
  1618. /package/dist/{common → runtime/common}/language.js +0 -0
  1619. /package/dist/{common → runtime/common}/llm-scope.d.ts +0 -0
  1620. /package/dist/{common → runtime/common}/llm-scope.js +0 -0
  1621. /package/dist/{common → runtime/common}/logging.d.ts +0 -0
  1622. /package/dist/{common → runtime/common}/logging.js +0 -0
  1623. /package/dist/{common → runtime/common}/template.d.ts +0 -0
  1624. /package/dist/{common → runtime/common}/template.js +0 -0
  1625. /package/dist/{common → runtime/common}/tinyld-language.d.ts +0 -0
  1626. /package/dist/{common → runtime/common}/tinyld-language.js +0 -0
  1627. /package/dist/{common/wiki-graph-temp.d.ts → runtime/common/wiki-graph/temp.d.ts} +0 -0
  1628. /package/dist/{context/task-context.d.ts → runtime/context/task.d.ts} +0 -0
  1629. /package/dist/{gc → runtime/gc}/files.d.ts +0 -0
  1630. /package/dist/{gc → runtime/gc}/index.d.ts +0 -0
  1631. /package/dist/{gc → runtime/gc}/index.js +0 -0
  1632. /package/dist/{gc → runtime/gc}/lock.d.ts +0 -0
  1633. /package/dist/{gc → runtime/gc}/runner.d.ts +0 -0
  1634. /package/dist/{gc/tmp-gc.d.ts → runtime/gc/temp.d.ts} +0 -0
  1635. /package/dist/{gc → runtime/gc}/types.d.ts +0 -0
  1636. /package/dist/{progress → runtime/progress}/index.d.ts +0 -0
  1637. /package/dist/{progress → runtime/progress}/index.js +0 -0
  1638. /package/dist/{progress → runtime/progress}/reporter.d.ts +0 -0
  1639. /package/dist/{progress → runtime/progress}/reporter.js +0 -0
  1640. /package/dist/{progress → runtime/progress}/tracker.d.ts +0 -0
  1641. /package/dist/{progress → runtime/progress}/tracker.js +0 -0
  1642. /package/dist/{progress → runtime/progress}/types.d.ts +0 -0
  1643. /package/dist/{legacy-sdpub/upgrade.d.ts → storage/migration/legacy-sdpub/upgrade/index.d.ts} +0 -0
  1644. /package/dist/{editor → text/editor}/clue.js +0 -0
  1645. /package/dist/{editor → text/editor}/feedback.js +0 -0
  1646. /package/dist/{editor → text/editor}/prompt-templates.d.ts +0 -0
  1647. /package/dist/{editor → text/editor}/prompt-templates.js +0 -0
  1648. /package/dist/{editor → text/editor}/response.d.ts +0 -0
  1649. /package/dist/{editor → text/editor}/response.js +0 -0
  1650. /package/dist/{editor → text/editor}/types.d.ts +0 -0
  1651. /package/dist/{output → text/output}/epub/archive.d.ts +0 -0
  1652. /package/dist/{output → text/output}/epub/archive.js +0 -0
  1653. /package/dist/{output → text/output}/epub/book.js +0 -0
  1654. /package/dist/{output → text/output}/epub/content.d.ts +0 -0
  1655. /package/dist/{output → text/output}/epub/content.js +0 -0
  1656. /package/dist/{output → text/output}/epub/index.js +0 -0
  1657. /package/dist/{output → text/output}/epub/model.d.ts +0 -0
  1658. /package/dist/{output → text/output}/epub/model.js +0 -0
  1659. /package/dist/{output → text/output}/epub/navigation.d.ts +0 -0
  1660. /package/dist/{output → text/output}/epub/navigation.js +0 -0
  1661. /package/dist/{output → text/output}/epub/package.d.ts +0 -0
  1662. /package/dist/{output → text/output}/epub/package.js +0 -0
  1663. /package/dist/{output → text/output}/epub/shared.d.ts +0 -0
  1664. /package/dist/{output → text/output}/epub/shared.js +0 -0
  1665. /package/dist/{output → text/output}/epub/templates.d.ts +0 -0
  1666. /package/dist/{output → text/output}/index.js +0 -0
  1667. /package/dist/{output → text/output}/plain-text.js +0 -0
  1668. /package/dist/{reader → text/reader}/attention/wave-reflection.js +0 -0
  1669. /package/dist/{reader → text/reader}/attention/working-memory.js +0 -0
  1670. /package/dist/{reader → text/reader}/chunk-batch/extract.js +0 -0
  1671. /package/dist/{reader → text/reader}/chunk-batch/fragment-projection.js +0 -0
  1672. /package/dist/{reader → text/reader}/chunk-batch/prompt-templates.d.ts +0 -0
  1673. /package/dist/{reader → text/reader}/chunk-batch/prompt-templates.js +0 -0
  1674. /package/dist/{reader/segment/segment.d.ts → text/reader/segment/core.d.ts} +0 -0
  1675. /package/dist/{reader → text/reader}/segment/intl-segmenter.d.ts +0 -0
  1676. /package/dist/{reader → text/reader}/segment/intl-segmenter.js +0 -0
  1677. /package/dist/{reader → text/reader}/segment/types.d.ts +0 -0
  1678. /package/dist/{source → text/source}/adapter.d.ts +0 -0
  1679. /package/dist/{source → text/source}/adapter.js +0 -0
  1680. /package/dist/{source → text/source}/epub/archive.d.ts +0 -0
  1681. /package/dist/{source → text/source}/epub/archive.js +0 -0
  1682. /package/dist/{source → text/source}/epub/content.d.ts +0 -0
  1683. /package/dist/{source → text/source}/epub/content.js +0 -0
  1684. /package/dist/{source → text/source}/epub/document.d.ts +0 -0
  1685. /package/dist/{source → text/source}/epub/document.js +0 -0
  1686. /package/dist/{source → text/source}/epub/index.d.ts +0 -0
  1687. /package/dist/{source → text/source}/epub/index.js +0 -0
  1688. /package/dist/{source → text/source}/epub/navigation.d.ts +0 -0
  1689. /package/dist/{source → text/source}/epub/navigation.js +0 -0
  1690. /package/dist/{source → text/source}/epub/package.d.ts +0 -0
  1691. /package/dist/{source → text/source}/epub/package.js +0 -0
  1692. /package/dist/{source → text/source}/epub/xml.d.ts +0 -0
  1693. /package/dist/{source → text/source}/epub/xml.js +0 -0
  1694. /package/dist/{source → text/source}/index.d.ts +0 -0
  1695. /package/dist/{source → text/source}/index.js +0 -0
  1696. /package/dist/{source → text/source}/meta.d.ts +0 -0
  1697. /package/dist/{source → text/source}/meta.js +0 -0
  1698. /package/dist/{source → text/source}/plain-text.d.ts +0 -0
  1699. /package/dist/{source → text/source}/plain-text.js +0 -0
  1700. /package/dist/{source → text/source}/types.d.ts +0 -0
@@ -1,897 +0,0 @@
1
- import { createReadStream, createWriteStream } from "fs";
2
- import { mkdir, rm } from "fs/promises";
3
- import { createInterface } from "readline";
4
- import { join } from "path";
5
- import { z } from "zod";
6
- import { LanguageCode, normalizeLanguageCode } from "../common/language.js";
7
- import {
8
- buildWikimatchSurfaceProtectionInput,
9
- buildWikimatchWindows,
10
- enrichWikimatchCandidates,
11
- filterCandidateQidOptions,
12
- judgeWikimatchPolicy,
13
- judgeWikimatchSurfaceProtection,
14
- listCandidateSelectableQids,
15
- matchWikispineSentenceCandidates
16
- } from "../wikimatch/index.js";
17
- import {
18
- buildWikilinkEvidenceWindows,
19
- discoverWikilinkRelations
20
- } from "../wikilink/index.js";
21
- import { getChapterDetails } from "./chapter.js";
22
- const mentionRecordSchema = z.object({
23
- id: z.string().min(1),
24
- chapterId: z.number().int(),
25
- sentenceIndex: z.number().int().nonnegative().optional(),
26
- rangeStart: z.number().int().nonnegative(),
27
- rangeEnd: z.number().int().nonnegative(),
28
- surface: z.string().min(1),
29
- qid: z.string().regex(/^Q[1-9][0-9]*$/),
30
- confidence: z.number().min(0).max(1).optional(),
31
- note: z.string().optional()
32
- });
33
- const sentenceIdSchema = z.tuple([z.number().int().nonnegative(), z.number().int().nonnegative()]).readonly();
34
- const mentionLinkRecordSchema = z.object({
35
- id: z.string().min(1),
36
- sourceMentionId: z.string().min(1),
37
- targetMentionId: z.string().min(1),
38
- predicate: z.string().min(1),
39
- evidenceSentenceIds: z.array(sentenceIdSchema).min(1),
40
- confidence: z.number().min(0).max(1).optional(),
41
- note: z.string().optional()
42
- });
43
- const WIKIMATCH_GROUNDING_DEFAULT_OPTION_BUDGETS = [5, 10, 20, 35];
44
- const WIKIMATCH_GROUNDING_PRIOR_OPTION_BUDGETS = [3, 5, 10, 20, 35];
45
- const WIKIMATCH_GROUNDING_MAX_OPTION_BUDGET = 50;
46
- const WIKIMATCH_GROUNDING_SURFACE_PRIOR_THRESHOLD = 3;
47
- const WIKIMATCH_SURFACE_PROTECTION_PERCENTILE = 0.1;
48
- const WIKILINK_EVIDENCE_DISTANCE = 700;
49
- const WIKILINK_WINDOW_LENGTH = 1800;
50
- async function generateChapterKnowledgeGraphArtifact(document, chapterId, options) {
51
- return await generateChapterKnowledgeGraphArtifactFromSnapshot(
52
- chapterId,
53
- await snapshotChapterKnowledgeGraphInput(document, chapterId),
54
- options
55
- );
56
- }
57
- async function snapshotChapterKnowledgeGraphInput(document, chapterId) {
58
- const details = await getChapterDetails(document, chapterId);
59
- if (details.stage === "planned") {
60
- throw new Error(
61
- `Chapter ${chapterId} is planned. Set source before generating Knowledge Graph.`
62
- );
63
- }
64
- return {
65
- details,
66
- fragments: await readChapterFragments(document, chapterId)
67
- };
68
- }
69
- async function generateChapterKnowledgeGraphArtifactFromSnapshot(chapterId, snapshot, options) {
70
- if (snapshot.details.chapterId !== chapterId) {
71
- throw new Error(
72
- `Knowledge Graph snapshot belongs to chapter ${snapshot.details.chapterId}, not chapter ${chapterId}.`
73
- );
74
- }
75
- if (snapshot.details.stage === "planned") {
76
- throw new Error(
77
- `Chapter ${chapterId} is planned. Set source before generating Knowledge Graph.`
78
- );
79
- }
80
- const fragments = snapshot.fragments;
81
- const text = joinFragmentText(fragments);
82
- const sentences = createWikimatchSentences(fragments);
83
- await options.progressTracker?.updatePhase({
84
- done: 0,
85
- phase: "matching",
86
- phaseDetail: "text",
87
- total: text.length,
88
- unit: "char"
89
- });
90
- const rawCandidates = await matchWikispineSentenceCandidates({
91
- includeDisambiguation: true,
92
- onProgress: async (progress) => {
93
- await options.progressTracker?.updatePhase({
94
- done: progress.coveredRangeEnd,
95
- force: false,
96
- phase: "matching",
97
- phaseDetail: "text",
98
- total: text.length,
99
- unit: "char"
100
- });
101
- },
102
- ...options.wikispine ?? {},
103
- sentences
104
- });
105
- await options.progressTracker?.throwIfStopped();
106
- await options.progressTracker?.updatePhase({
107
- done: text.length,
108
- phase: "matching",
109
- phaseDetail: "text",
110
- total: text.length,
111
- unit: "char"
112
- });
113
- const screenedCandidates = await screenCandidates({
114
- candidates: rawCandidates,
115
- policyPrompt: options.policyPrompt,
116
- ...options.progressTracker === void 0 ? {} : { progressTracker: options.progressTracker },
117
- request: options.request,
118
- text
119
- });
120
- await options.progressTracker?.throwIfStopped();
121
- const qidCount = countUniqueQids(screenedCandidates);
122
- await options.progressTracker?.updatePhase({
123
- done: 0,
124
- phase: "enrichment",
125
- total: qidCount,
126
- unit: "qid"
127
- });
128
- const enrichedCandidates = await enrichWikimatchCandidates(
129
- screenedCandidates,
130
- {
131
- ...options.progressTracker === void 0 ? {} : {
132
- progress: createEnrichmentProgressReporter(options.progressTracker)
133
- },
134
- ...options.resolverOptions === void 0 ? {} : { resolverOptions: options.resolverOptions }
135
- }
136
- );
137
- await options.progressTracker?.throwIfStopped();
138
- await options.progressTracker?.updatePhase({
139
- done: qidCount,
140
- phase: "enrichment",
141
- total: qidCount,
142
- unit: "qid"
143
- });
144
- const mentions = await judgeCandidates({
145
- candidates: enrichedCandidates,
146
- chapterId,
147
- fragments,
148
- policyPrompt: options.policyPrompt,
149
- ...options.progressTracker === void 0 ? {} : { progressTracker: options.progressTracker },
150
- request: options.request,
151
- text
152
- });
153
- await options.progressTracker?.throwIfStopped();
154
- const mentionLinks = await discoverMentionLinks({
155
- fragments,
156
- mentions,
157
- ...options.progressTracker === void 0 ? {} : { progressTracker: options.progressTracker },
158
- request: options.request
159
- });
160
- await options.progressTracker?.throwIfStopped();
161
- const artifact = await buildChapterKnowledgeGraphArtifact(chapterId, {
162
- mentionLinks,
163
- mentions,
164
- parameter: createKnowledgeGraphParameterInput(options),
165
- workspacePath: options.workspacePath
166
- });
167
- return artifact;
168
- }
169
- async function buildChapterKnowledgeGraphArtifact(chapterId, options) {
170
- const workspacePath = join(
171
- options.workspacePath,
172
- "knowledge-graph",
173
- `chapter-${chapterId}`
174
- );
175
- const mentionsPath = join(workspacePath, "mentions.jsonl");
176
- const mentionLinksPath = join(workspacePath, "mention-links.jsonl");
177
- await rm(workspacePath, { force: true, recursive: true });
178
- await mkdir(workspacePath, { recursive: true });
179
- await writeJsonl(mentionsPath, options.mentions, parseMentionRecord);
180
- await writeJsonl(
181
- mentionLinksPath,
182
- options.mentionLinks,
183
- parseMentionLinkRecord
184
- );
185
- return {
186
- chapterId,
187
- mentionLinksPath,
188
- mentionsPath,
189
- parameter: options.parameter ?? {
190
- language: LanguageCode.Chinese,
191
- prompt: ""
192
- },
193
- workspacePath
194
- };
195
- }
196
- function createKnowledgeGraphParameterInput(options) {
197
- return {
198
- language: normalizeLanguageCode(options.resolverOptions?.language) ?? LanguageCode.Chinese,
199
- prompt: options.policyPrompt
200
- };
201
- }
202
- async function screenCandidates(input) {
203
- if (input.candidates.length === 0) {
204
- return [];
205
- }
206
- const protectionInput = buildWikimatchSurfaceProtectionInput({
207
- candidates: input.candidates,
208
- percentile: WIKIMATCH_SURFACE_PROTECTION_PERCENTILE,
209
- text: input.text
210
- });
211
- await input.progressTracker?.updatePhase({
212
- done: 0,
213
- phase: "screening",
214
- phaseDetail: `${protectionInput.suspiciousSurfaces.length} high-frequency surfaces`,
215
- total: 1,
216
- unit: "window"
217
- });
218
- await input.progressTracker?.throwIfStopped();
219
- const protection = await judgeWikimatchSurfaceProtection({
220
- policyPrompt: input.policyPrompt,
221
- request: input.request,
222
- suspiciousSurfaces: protectionInput.suspiciousSurfaces
223
- });
224
- await input.progressTracker?.throwIfStopped();
225
- const protectedSurfaces = new Set(
226
- protection.protectedSurfaces.map((surface) => surface.text)
227
- );
228
- const allowedCandidateKeys = new Set(
229
- protectionInput.candidates.map(createCandidateRangeKey)
230
- );
231
- await input.progressTracker?.updatePhase({
232
- done: 1,
233
- phase: "screening",
234
- phaseDetail: `${protectedSurfaces.size} protected surfaces`,
235
- total: 1,
236
- unit: "window"
237
- });
238
- return protectionInput.suppressedCandidates.filter(
239
- (candidate) => allowedCandidateKeys.has(createCandidateRangeKey(candidate)) || protectedSurfaces.has(candidate.surface)
240
- );
241
- }
242
- function createCandidateRangeKey(candidate) {
243
- return `${candidate.range.start}\0${candidate.range.end}\0${candidate.surface}`;
244
- }
245
- async function judgeCandidates(input) {
246
- const mentions = [];
247
- const sentenceLocations = buildSentenceLocations(input.fragments);
248
- const acceptedMentions = await groundWikimatchCandidates({
249
- candidates: input.candidates,
250
- policyPrompt: input.policyPrompt,
251
- ...input.progressTracker === void 0 ? {} : { progressTracker: input.progressTracker },
252
- request: input.request,
253
- text: input.text
254
- });
255
- let mentionIndex = 1;
256
- for (const mention of acceptedMentions) {
257
- const location = locateMention(sentenceLocations, mention.range.start);
258
- mentions.push(
259
- toMentionRecord(input.chapterId, mention, location, mentionIndex)
260
- );
261
- mentionIndex += 1;
262
- }
263
- return mentions;
264
- }
265
- async function groundWikimatchCandidates(input) {
266
- const mentions = [];
267
- const candidatePages = createGroundingCandidatePages(input.candidates);
268
- let completedWindows = 0;
269
- let totalWindows = 0;
270
- let activeCandidates = candidatePages.nextPage();
271
- while (activeCandidates.length > 0) {
272
- const windows = buildWikimatchWindows({
273
- candidates: activeCandidates,
274
- contextWords: 220,
275
- optionBudget: WIKIMATCH_GROUNDING_MAX_OPTION_BUDGET,
276
- text: input.text
277
- });
278
- totalWindows += windows.length;
279
- if (windows.length === 0) {
280
- break;
281
- }
282
- await input.progressTracker?.updatePhase({
283
- done: completedWindows,
284
- phase: "grounding",
285
- total: totalWindows,
286
- unit: "window"
287
- });
288
- const results = await mapLazyGuaranteedRequests(
289
- input.request,
290
- windows,
291
- async (window, request) => {
292
- try {
293
- await input.progressTracker?.throwIfStopped();
294
- return await judgeWikimatchPolicy({
295
- candidates: window.candidates,
296
- policyPrompt: input.policyPrompt,
297
- request,
298
- window
299
- });
300
- } finally {
301
- completedWindows += 1;
302
- await input.progressTracker?.updatePhase({
303
- done: completedWindows,
304
- phase: "grounding",
305
- total: totalWindows,
306
- unit: "window"
307
- });
308
- }
309
- }
310
- );
311
- const continuedCandidateIds = /* @__PURE__ */ new Set();
312
- for (const result of results) {
313
- for (const mention of result.mentions) {
314
- mentions.push(mention);
315
- candidatePages.accept(mention);
316
- }
317
- for (const update of result.policyUpdates) {
318
- candidatePages.close(update.candidateId, update.decision);
319
- }
320
- for (const continuation of result.continuations) {
321
- for (const candidateId of continuation.candidateIds) {
322
- continuedCandidateIds.add(candidateId);
323
- candidatePages.continue(candidateId);
324
- }
325
- }
326
- }
327
- activeCandidates = candidatePages.nextPage(continuedCandidateIds);
328
- }
329
- await input.progressTracker?.updatePhase({
330
- done: completedWindows,
331
- phase: "grounding",
332
- phaseDetail: formatGroundingEfficiency(
333
- candidatePages.getStats(),
334
- mentions.length
335
- ),
336
- total: totalWindows,
337
- unit: "window"
338
- });
339
- return mentions;
340
- }
341
- function createGroundingCandidatePages(candidates) {
342
- const candidatesById = new Map(
343
- candidates.map((candidate) => [candidate.id, candidate])
344
- );
345
- const shownQidsByCandidateId = new Map(
346
- candidates.map((candidate) => [candidate.id, /* @__PURE__ */ new Set()])
347
- );
348
- const pageIndexesByCandidateId = new Map(
349
- candidates.map((candidate) => [candidate.id, 0])
350
- );
351
- const closedCandidateIds = /* @__PURE__ */ new Set();
352
- const recallCounts = /* @__PURE__ */ new Map();
353
- const surfaceStats = /* @__PURE__ */ new Map();
354
- const stats = {
355
- candidatePageCount: 0,
356
- qidAppearanceCount: 0
357
- };
358
- return {
359
- accept(mention) {
360
- closedCandidateIds.add(mention.candidateId);
361
- getSurfaceStats(surfaceStats, mention.surface).recallCount += 1;
362
- recallCounts.set(
363
- createSurfaceQidKey(mention.surface, mention.qid),
364
- (recallCounts.get(createSurfaceQidKey(mention.surface, mention.qid)) ?? 0) + 1
365
- );
366
- },
367
- close(candidateId, decision) {
368
- closedCandidateIds.add(candidateId);
369
- const candidate = candidatesById.get(candidateId);
370
- if (candidate !== void 0 && (decision === "skip_this_time" || decision === "never_recall")) {
371
- getSurfaceStats(surfaceStats, candidate.surface).rejectCount += 1;
372
- }
373
- },
374
- continue(candidateId) {
375
- const candidate = candidatesById.get(candidateId);
376
- if (candidate !== void 0) {
377
- getSurfaceStats(surfaceStats, candidate.surface).continueCount += 1;
378
- }
379
- },
380
- getStats() {
381
- return { ...stats };
382
- },
383
- nextPage(continuedCandidateIds) {
384
- const pageCandidates = [];
385
- const candidateIds = continuedCandidateIds === void 0 ? candidates.map((candidate) => candidate.id) : [...continuedCandidateIds];
386
- for (const candidateId of candidateIds) {
387
- if (closedCandidateIds.has(candidateId)) {
388
- continue;
389
- }
390
- const candidate = candidatesById.get(candidateId);
391
- const shownQids = shownQidsByCandidateId.get(candidateId);
392
- if (candidate === void 0 || shownQids === void 0) {
393
- continue;
394
- }
395
- const sortedCandidate = sortCandidateOptionsByRecall(
396
- candidate,
397
- recallCounts
398
- );
399
- const selectableQids = listCandidateSelectableQids(sortedCandidate);
400
- const pageIndex = pageIndexesByCandidateId.get(candidateId) ?? 0;
401
- const optionBudget = getGroundingCandidateOptionBudget(
402
- getSurfaceStats(surfaceStats, candidate.surface),
403
- pageIndex
404
- );
405
- const selectedQids = selectableQids.filter((qid) => !shownQids.has(qid)).slice(0, optionBudget);
406
- if (selectedQids.length === 0) {
407
- closedCandidateIds.add(candidateId);
408
- continue;
409
- }
410
- for (const qid of selectedQids) {
411
- shownQids.add(qid);
412
- }
413
- const hasMoreOptions = selectableQids.some(
414
- (qid) => !shownQids.has(qid)
415
- );
416
- const pageCandidate = filterCandidateQidOptions(
417
- sortedCandidate,
418
- new Set(selectedQids)
419
- );
420
- if (!hasMoreOptions) {
421
- closedCandidateIds.add(candidateId);
422
- }
423
- getSurfaceStats(surfaceStats, candidate.surface).seenCount += 1;
424
- pageIndexesByCandidateId.set(candidateId, pageIndex + 1);
425
- stats.candidatePageCount += 1;
426
- stats.qidAppearanceCount += selectedQids.length;
427
- pageCandidates.push({
428
- ...pageCandidate,
429
- ...hasMoreOptions ? { hasMoreOptions: true } : {}
430
- });
431
- }
432
- return pageCandidates;
433
- }
434
- };
435
- }
436
- function getSurfaceStats(surfaceStats, surface) {
437
- const existing = surfaceStats.get(surface);
438
- if (existing !== void 0) {
439
- return existing;
440
- }
441
- const created = {
442
- continueCount: 0,
443
- recallCount: 0,
444
- rejectCount: 0,
445
- seenCount: 0
446
- };
447
- surfaceStats.set(surface, created);
448
- return created;
449
- }
450
- function getGroundingCandidateOptionBudget(stats, pageIndex) {
451
- const budgets = hasStrongGroundingSurfacePrior(stats) ? WIKIMATCH_GROUNDING_PRIOR_OPTION_BUDGETS : WIKIMATCH_GROUNDING_DEFAULT_OPTION_BUDGETS;
452
- return budgets[Math.min(pageIndex, budgets.length - 1)];
453
- }
454
- function hasStrongGroundingSurfacePrior(stats) {
455
- if (stats.seenCount < WIKIMATCH_GROUNDING_SURFACE_PRIOR_THRESHOLD) {
456
- return false;
457
- }
458
- return stats.recallCount >= 2 && stats.continueCount === 0 || stats.rejectCount >= 2 && stats.recallCount === 0 || stats.continueCount >= WIKIMATCH_GROUNDING_SURFACE_PRIOR_THRESHOLD;
459
- }
460
- function formatGroundingEfficiency(stats, mentionCount) {
461
- const qidPerMention = mentionCount === 0 ? "n/a" : (stats.qidAppearanceCount / mentionCount).toFixed(1);
462
- return `efficiency qid/mention=${qidPerMention} qids=${stats.qidAppearanceCount} mentions=${mentionCount} pages=${stats.candidatePageCount}`;
463
- }
464
- function sortCandidateOptionsByRecall(candidate, recallCounts) {
465
- return {
466
- ...candidate,
467
- qidOptions: [...candidate.qidOptions].sort((left, right) => {
468
- return getOptionRecallScore(candidate.surface, right, recallCounts) - getOptionRecallScore(candidate.surface, left, recallCounts);
469
- })
470
- };
471
- }
472
- function getOptionRecallScore(surface, option, recallCounts) {
473
- const directScore = recallCounts.get(createSurfaceQidKey(surface, option.qid)) ?? 0;
474
- const disambiguationScore = option.disambiguation?.linkedQids.reduce(
475
- (total, item) => total + (recallCounts.get(createSurfaceQidKey(surface, item.qid)) ?? 0),
476
- 0
477
- ) ?? 0;
478
- const profileScore = option.disambiguation?.profile?.meanings.reduce(
479
- (total, item) => total + (recallCounts.get(createSurfaceQidKey(surface, item.qid)) ?? 0),
480
- 0
481
- ) ?? 0;
482
- return directScore + disambiguationScore + profileScore;
483
- }
484
- function createSurfaceQidKey(surface, qid) {
485
- return `${surface}\0${qid}`;
486
- }
487
- function createEnrichmentProgressReporter(progressTracker) {
488
- return async (event) => {
489
- await progressTracker.throwIfStopped();
490
- const phase = formatEnrichmentProgressPhase(event);
491
- await progressTracker.updatePhase({
492
- done: event.done,
493
- ...phase.detail === void 0 ? {} : { phaseDetail: phase.detail },
494
- phase: "enrichment",
495
- total: event.total,
496
- unit: phase.unit
497
- });
498
- };
499
- }
500
- function formatEnrichmentProgressPhase(event) {
501
- switch (event.detail) {
502
- case "disambiguation-page":
503
- return {
504
- detail: "disambiguation",
505
- unit: "page"
506
- };
507
- case "entity":
508
- return {
509
- detail: "entity",
510
- unit: "record"
511
- };
512
- case "linked-page":
513
- return {
514
- detail: "linked",
515
- unit: "page"
516
- };
517
- case "page":
518
- return {
519
- detail: "page",
520
- unit: "page"
521
- };
522
- case "qid":
523
- return {
524
- unit: "qid"
525
- };
526
- }
527
- }
528
- async function mapLazyGuaranteedRequests(request, items, operation) {
529
- const lazy = request.lazy;
530
- if (lazy !== void 0) {
531
- return await Promise.all(
532
- items.map(
533
- async (item) => await lazy(async (request2) => await operation(item, request2))
534
- )
535
- );
536
- }
537
- const results = [];
538
- for (const item of items) {
539
- results.push(await operation(item, request));
540
- }
541
- return results;
542
- }
543
- async function discoverMentionLinks(input) {
544
- const fragmentWindows = buildMentionLinkWindows(
545
- input.fragments,
546
- input.mentions
547
- );
548
- let completedWindows = 0;
549
- await input.progressTracker?.updatePhase({
550
- done: 0,
551
- phase: "relation-discovery",
552
- total: fragmentWindows.length,
553
- unit: "window"
554
- });
555
- const discoveredLinks = (await mapLazyGuaranteedRequests(
556
- input.request,
557
- fragmentWindows,
558
- async (item, request) => {
559
- try {
560
- await input.progressTracker?.throwIfStopped();
561
- return await discoverWikilinkRelations({
562
- chapterId: item.fragment.serialId,
563
- fragmentId: item.fragment.fragmentId,
564
- request,
565
- sentences: item.fragment.sentences,
566
- window: item.window
567
- });
568
- } finally {
569
- completedWindows += 1;
570
- await input.progressTracker?.updatePhase({
571
- done: completedWindows,
572
- phase: "relation-discovery",
573
- total: fragmentWindows.length,
574
- unit: "window"
575
- });
576
- }
577
- }
578
- )).flat();
579
- return discoveredLinks.map((link, index) => ({
580
- ...link.confidence === void 0 ? {} : { confidence: link.confidence },
581
- evidenceSentenceIds: link.evidenceSentenceIds,
582
- id: `l${input.fragments[0]?.serialId ?? 0}-${index + 1}`,
583
- predicate: link.predicate,
584
- sourceMentionId: link.sourceMentionId,
585
- targetMentionId: link.targetMentionId
586
- }));
587
- }
588
- function buildMentionLinkWindows(fragments, mentions) {
589
- return fragments.flatMap((fragment) => {
590
- const startSentenceIndex = fragment.fragmentId;
591
- const endSentenceIndex = startSentenceIndex + fragment.sentences.length - 1;
592
- const fragmentMentions = toWikilinkMentions(
593
- fragment.sentences,
594
- mentions.filter(
595
- (mention) => mention.sentenceIndex !== void 0 && mention.sentenceIndex >= startSentenceIndex && mention.sentenceIndex <= endSentenceIndex
596
- ),
597
- startSentenceIndex
598
- );
599
- const windows = buildWikilinkEvidenceWindows({
600
- maxEvidenceDistance: WIKILINK_EVIDENCE_DISTANCE,
601
- mentions: fragmentMentions,
602
- text: joinSentences(fragment.sentences),
603
- windowLength: WIKILINK_WINDOW_LENGTH
604
- });
605
- return windows.map((window) => ({
606
- fragment,
607
- window
608
- }));
609
- });
610
- }
611
- function toWikilinkMentions(sentences, mentions, startSentenceIndex) {
612
- const sentenceOffsets = buildFragmentSentenceOffsets(sentences);
613
- return mentions.flatMap((mention) => {
614
- if (mention.sentenceIndex === void 0) {
615
- return [];
616
- }
617
- const sentenceOffset = sentenceOffsets[mention.sentenceIndex - startSentenceIndex];
618
- if (sentenceOffset === void 0) {
619
- return [];
620
- }
621
- return [
622
- {
623
- id: mention.id,
624
- qid: mention.qid,
625
- range: {
626
- end: sentenceOffset.start + mention.rangeEnd,
627
- start: sentenceOffset.start + mention.rangeStart
628
- },
629
- surface: mention.surface
630
- }
631
- ];
632
- });
633
- }
634
- function buildFragmentSentenceOffsets(sentences) {
635
- const offsets = [];
636
- let cursor = 0;
637
- for (const sentence of sentences) {
638
- const start = cursor;
639
- const end = start + sentence.text.length;
640
- offsets.push({ end, start });
641
- cursor = end + 1;
642
- }
643
- return offsets;
644
- }
645
- function joinSentences(sentences) {
646
- return sentences.map((sentence) => sentence.text).join(" ");
647
- }
648
- function countUniqueQids(candidates) {
649
- return new Set(
650
- candidates.flatMap(
651
- (candidate) => candidate.qidOptions.map((option) => option.qid)
652
- )
653
- ).size;
654
- }
655
- function toMentionRecord(chapterId, mention, location, index) {
656
- return {
657
- chapterId,
658
- ...mention.confidence === void 0 ? {} : { confidence: mention.confidence },
659
- id: `m${chapterId}-${index}`,
660
- ...mention.note === void 0 ? {} : { note: mention.note },
661
- qid: mention.qid,
662
- rangeEnd: location.rangeStart + mention.surface.length,
663
- rangeStart: location.rangeStart,
664
- sentenceIndex: location.sentenceIndex,
665
- surface: mention.surface
666
- };
667
- }
668
- function buildSentenceLocations(fragments) {
669
- const locations = [];
670
- let offset = 0;
671
- for (const fragment of fragments) {
672
- for (let sentenceIndex = 0; sentenceIndex < fragment.sentences.length; sentenceIndex += 1) {
673
- const length = fragment.sentences[sentenceIndex].text.length;
674
- locations.push({
675
- absoluteStart: offset,
676
- length,
677
- sentenceIndex: fragment.fragmentId + sentenceIndex
678
- });
679
- offset += length + 1;
680
- }
681
- }
682
- return locations;
683
- }
684
- function locateMention(locations, absoluteOffset) {
685
- for (const location of locations) {
686
- const rangeEnd = location.absoluteStart + location.length;
687
- if (absoluteOffset >= location.absoluteStart && absoluteOffset < rangeEnd) {
688
- return {
689
- rangeStart: absoluteOffset - location.absoluteStart,
690
- sentenceIndex: location.sentenceIndex
691
- };
692
- }
693
- }
694
- throw new Error(`Mention offset ${absoluteOffset} is outside chapter text.`);
695
- }
696
- async function readChapterFragments(document, chapterId) {
697
- const serialFragments = document.getSerialFragments(chapterId);
698
- return await Promise.all(
699
- (await serialFragments.listFragmentIds()).map(
700
- async (fragmentId) => await serialFragments.getFragment(fragmentId)
701
- )
702
- );
703
- }
704
- function joinFragmentText(fragments) {
705
- return fragments.flatMap((fragment) => fragment.sentences.map((sentence) => sentence.text)).join(" ");
706
- }
707
- function createWikimatchSentences(fragments) {
708
- const sentences = [];
709
- let offset = 0;
710
- for (const fragment of fragments) {
711
- for (let index = 0; index < fragment.sentences.length; index += 1) {
712
- const sentence = fragment.sentences[index];
713
- sentences.push({
714
- id: `${fragment.serialId}:${fragment.fragmentId + index}`,
715
- range: {
716
- end: offset + sentence.text.length,
717
- start: offset
718
- },
719
- text: sentence.text
720
- });
721
- offset += sentence.text.length + 1;
722
- }
723
- }
724
- return sentences;
725
- }
726
- async function commitChapterKnowledgeGraphArtifact(document, artifact) {
727
- const mentions = await readJsonl(artifact.mentionsPath, parseMentionRecord);
728
- const mentionLinks = await readJsonl(
729
- artifact.mentionLinksPath,
730
- parseMentionLinkRecord
731
- );
732
- validateChapterKnowledgeGraphArtifact(artifact.chapterId, {
733
- mentionLinks,
734
- mentions
735
- });
736
- await document.openSession(async (openedDocument) => {
737
- await openedDocument.serials.ensure(artifact.chapterId);
738
- const existingLinks = await openedDocument.mentionLinks.listByChapter(
739
- artifact.chapterId
740
- );
741
- if (existingLinks.length > 0 && mentionLinks.length === 0) {
742
- throw new Error(
743
- `Refusing to replace chapter ${artifact.chapterId} knowledge graph with an artifact that contains no mention links.`
744
- );
745
- }
746
- await openedDocument.mentionLinks.deleteByChapter(artifact.chapterId);
747
- await openedDocument.mentions.deleteByChapter(artifact.chapterId);
748
- await openedDocument.mentions.saveMany(mentions);
749
- await openedDocument.mentionLinks.saveMany(mentionLinks);
750
- const parameter = await openedDocument.graphBuildParameters.save(
751
- artifact.parameter
752
- );
753
- await openedDocument.serials.setKnowledgeGraphReady(
754
- artifact.chapterId,
755
- true,
756
- parameter.hash
757
- );
758
- });
759
- }
760
- async function clearChapterKnowledgeGraph(document, chapterId) {
761
- await document.openSession(async (openedDocument) => {
762
- await openedDocument.mentionLinks.deleteByChapter(chapterId);
763
- await openedDocument.mentions.deleteByChapter(chapterId);
764
- await openedDocument.serials.setKnowledgeGraphReady(chapterId, false);
765
- await openedDocument.graphBuildParameters.deleteUnreferenced();
766
- });
767
- }
768
- function validateChapterKnowledgeGraphArtifact(chapterId, records) {
769
- const mentionIds = /* @__PURE__ */ new Set();
770
- for (const mention of records.mentions) {
771
- if (mention.chapterId !== chapterId) {
772
- throw new Error(
773
- `Mention ${mention.id} belongs to chapter ${mention.chapterId}, expected chapter ${chapterId}.`
774
- );
775
- }
776
- if (mention.rangeEnd <= mention.rangeStart) {
777
- throw new Error(
778
- `Mention ${mention.id} has invalid range [${mention.rangeStart}, ${mention.rangeEnd}).`
779
- );
780
- }
781
- if (mentionIds.has(mention.id)) {
782
- throw new Error(`Duplicate mention id ${mention.id}.`);
783
- }
784
- mentionIds.add(mention.id);
785
- }
786
- const linkIds = /* @__PURE__ */ new Set();
787
- for (const link of records.mentionLinks) {
788
- if (linkIds.has(link.id)) {
789
- throw new Error(`Duplicate mention link id ${link.id}.`);
790
- }
791
- if (!mentionIds.has(link.sourceMentionId)) {
792
- throw new Error(
793
- `Mention link ${link.id} references unknown source mention ${link.sourceMentionId}.`
794
- );
795
- }
796
- if (!mentionIds.has(link.targetMentionId)) {
797
- throw new Error(
798
- `Mention link ${link.id} references unknown target mention ${link.targetMentionId}.`
799
- );
800
- }
801
- if (link.evidenceSentenceIds.length === 0) {
802
- throw new Error(`Mention link ${link.id} has no evidence sentences.`);
803
- }
804
- for (const sentenceId of link.evidenceSentenceIds) {
805
- if (sentenceId[0] !== chapterId) {
806
- throw new Error(
807
- `Mention link ${link.id} evidence sentence ${formatSentenceId(sentenceId)} is outside chapter ${chapterId}.`
808
- );
809
- }
810
- }
811
- linkIds.add(link.id);
812
- }
813
- }
814
- function formatSentenceId(sentenceId) {
815
- return sentenceId.join(":");
816
- }
817
- async function writeJsonl(path, records, parseRecord) {
818
- const stream = createWriteStream(path, { encoding: "utf8", flags: "wx" });
819
- try {
820
- for await (const record of records) {
821
- stream.write(`${JSON.stringify(parseRecord(record))}
822
- `);
823
- }
824
- } finally {
825
- await closeWritableStream(stream);
826
- }
827
- }
828
- async function readJsonl(path, parseRecord) {
829
- const records = [];
830
- const lines = createInterface({
831
- crlfDelay: Infinity,
832
- input: createReadStream(path, { encoding: "utf8" })
833
- });
834
- let lineNumber = 0;
835
- for await (const line of lines) {
836
- lineNumber += 1;
837
- if (line.trim() === "") {
838
- continue;
839
- }
840
- try {
841
- records.push(parseRecord(JSON.parse(line)));
842
- } catch (error) {
843
- throw new Error(`Invalid JSONL record at ${path}:${lineNumber}`, {
844
- cause: error
845
- });
846
- }
847
- }
848
- return records;
849
- }
850
- function parseMentionRecord(record) {
851
- const parsed = mentionRecordSchema.parse(record);
852
- return {
853
- chapterId: parsed.chapterId,
854
- ...parsed.confidence === void 0 ? {} : { confidence: parsed.confidence },
855
- id: parsed.id,
856
- ...parsed.note === void 0 ? {} : { note: parsed.note },
857
- qid: parsed.qid,
858
- rangeEnd: parsed.rangeEnd,
859
- rangeStart: parsed.rangeStart,
860
- ...parsed.sentenceIndex === void 0 ? {} : { sentenceIndex: parsed.sentenceIndex },
861
- surface: parsed.surface
862
- };
863
- }
864
- function parseMentionLinkRecord(record) {
865
- const parsed = mentionLinkRecordSchema.parse(record);
866
- return {
867
- ...parsed.confidence === void 0 ? {} : { confidence: parsed.confidence },
868
- evidenceSentenceIds: parsed.evidenceSentenceIds,
869
- id: parsed.id,
870
- ...parsed.note === void 0 ? {} : { note: parsed.note },
871
- predicate: parsed.predicate,
872
- sourceMentionId: parsed.sourceMentionId,
873
- targetMentionId: parsed.targetMentionId
874
- };
875
- }
876
- async function closeWritableStream(stream) {
877
- await new Promise((resolveClose, rejectClose) => {
878
- stream.end((error) => {
879
- if (error !== void 0 && error !== null) {
880
- rejectClose(error);
881
- return;
882
- }
883
- resolveClose();
884
- });
885
- });
886
- }
887
- export {
888
- buildChapterKnowledgeGraphArtifact,
889
- clearChapterKnowledgeGraph,
890
- commitChapterKnowledgeGraphArtifact,
891
- createEnrichmentProgressReporter,
892
- generateChapterKnowledgeGraphArtifact,
893
- generateChapterKnowledgeGraphArtifactFromSnapshot,
894
- groundWikimatchCandidates,
895
- snapshotChapterKnowledgeGraphInput
896
- };
897
- //# sourceMappingURL=knowledge-graph-build.js.map