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
package/dist/index.d.cts CHANGED
@@ -1,10 +1,9 @@
1
1
  import { LanguageModel, ModelMessage } from 'ai';
2
2
  import { Environment } from 'nunjucks';
3
- import * as Sqlite3Namespace from 'sqlite3';
4
3
  import { z } from 'zod';
5
- import { a as GcContext, d as GcJobResult } from './types-FVIqiLC9.cjs';
6
- import { B as BuildJobProgressReporter } from './worker-BgQ0Xl8T.cjs';
7
- export { A as AddBuildJobOptions, a as BuildJob, b as BuildJobConflictScope, c as BuildJobEvent, d as BuildJobExecutionContext, e as BuildJobListOptions, f as BuildJobProgressCounter, g as BuildJobState, h as BuildJobTarget, i as BuildJobWorkerOptions, j as addBuildJob, k as assertBuildJobInputRevision, l as assertNoActiveBuildJobConflicts, m as assertNoActiveBuildJobs, n as boostBuildJob, o as cancelBuildJob, p as cleanBuildJobs, q as getBuildJob, r as listBuildJobs, s as pauseBuildJob, t as readBuildJobEvents, u as recordBuildJobInputRevision, v as resolveBuildJobId, w as resumeBuildJob, x as runBuildJobWorker, y as runBuildQueueGc, z as updateBuildJobTarget } from './worker-BgQ0Xl8T.cjs';
4
+ import * as Sqlite3Namespace from 'sqlite3';
5
+ import { A as AddBuildJobOptions, B as BuildJob, a as BuildJobListOptions, b as BuildJobTarget, c as BuildJobConflictScope, d as BuildJobEvent, e as BuildJobState, f as BuildJobProgressReporter } from './worker-DWasYKWW.cjs';
6
+ export { g as BuildJobExecutionContext, h as BuildJobProgressCounter, i as BuildJobWorkerOptions, r as runBuildJobWorker } from './worker-DWasYKWW.cjs';
8
7
 
9
8
  declare enum Language {
10
9
  Arabic = "Arabic",
@@ -232,12 +231,90 @@ declare function createEnv(dirPath: string, options?: {
232
231
  readonly trimBlocks?: boolean;
233
232
  }): Environment;
234
233
 
235
- declare function resolveWikiGraphHomeDirectoryPath(): string;
236
- declare function resolveWikiGraphCoreDatabasePath(): string;
237
-
238
- type WikiGraphTempCategory = "archive-open" | "archive-write" | "cli-output" | "sdpub-upgrade" | "stdin-create" | "url-create";
239
- declare function resolveWikiGraphStateRootPath(): string;
240
- declare function createWikiGraphTempDirectory(category: WikiGraphTempCategory): Promise<string>;
234
+ interface WikiGraphLibraryRecord {
235
+ readonly id: number;
236
+ readonly publicId: string;
237
+ readonly uri: string;
238
+ readonly folderPath: string;
239
+ readonly isDefault: boolean;
240
+ readonly stagingPath: string;
241
+ readonly createdAt: string;
242
+ readonly updatedAt: string;
243
+ }
244
+ interface ParsedWikiGraphLibraryUri {
245
+ readonly archivePublicId?: string;
246
+ readonly kind: "archive" | "archive-collection" | "archive-path" | "archive-tree" | "metadata" | "path" | "registry" | "scope";
247
+ readonly objectUri?: string;
248
+ readonly publicId?: string;
249
+ readonly isDefault: boolean;
250
+ }
251
+ declare function isWikiGraphLibraryUri(uri: string | undefined): uri is string;
252
+ declare function parseWikiGraphLibraryUri(uri: string): ParsedWikiGraphLibraryUri | undefined;
253
+ declare function formatWikiGraphLibraryUri(publicId?: string): string;
254
+ declare function resolveDefaultWikiGraphLibraryDirectoryPath(): string;
255
+ declare function resolveWikiGraphLibraryStagingDirectoryPath(id: number): string;
256
+ declare function ensureDefaultWikiGraphLibrary(): Promise<WikiGraphLibraryRecord>;
257
+ declare function createWikiGraphLibrary(input: {
258
+ readonly folderPath: string;
259
+ }): Promise<WikiGraphLibraryRecord>;
260
+ declare function listWikiGraphLibraries(): Promise<readonly WikiGraphLibraryRecord[]>;
261
+ declare function resolveWikiGraphLibrary(target: ParsedWikiGraphLibraryUri): Promise<WikiGraphLibraryRecord>;
262
+ declare function resolveWikiGraphLibraryById(id: number): Promise<WikiGraphLibraryRecord>;
263
+ declare function listWikiGraphLibraryScope(target: ParsedWikiGraphLibraryUri): Promise<readonly []>;
264
+ declare function removeWikiGraphLibrary(target: ParsedWikiGraphLibraryUri): Promise<WikiGraphLibraryRecord>;
265
+ declare function getWikiGraphLibraryMetadata(target: ParsedWikiGraphLibraryUri): Promise<Readonly<Record<string, unknown>>>;
266
+ declare function replaceWikiGraphLibraryMetadata(target: ParsedWikiGraphLibraryUri, map: Readonly<Record<string, unknown>>): Promise<Readonly<Record<string, unknown>>>;
267
+ declare function putWikiGraphLibraryMetadata(target: ParsedWikiGraphLibraryUri, key: string, value: unknown): Promise<Readonly<Record<string, unknown>>>;
268
+ declare function deleteWikiGraphLibraryMetadataKey(target: ParsedWikiGraphLibraryUri, key: string): Promise<Readonly<Record<string, unknown>>>;
269
+ declare function clearWikiGraphLibraryMetadata(target: ParsedWikiGraphLibraryUri): Promise<Readonly<Record<string, unknown>>>;
270
+
271
+ type WikiGraphLibraryArchiveStatus = "conflict" | "missing" | "present";
272
+ interface WikiGraphLibraryArchiveRecord {
273
+ readonly id: number;
274
+ readonly publicId: string;
275
+ readonly uri: string;
276
+ readonly libraryId: number;
277
+ readonly libraryUri: string;
278
+ readonly relativePath: string;
279
+ readonly path: string;
280
+ readonly exists: boolean;
281
+ readonly status: WikiGraphLibraryArchiveStatus;
282
+ readonly lastSeenMutationToken?: string;
283
+ readonly lastSeenSize?: number;
284
+ readonly lastSeenMtimeMs?: number;
285
+ readonly lastScannedAt?: string;
286
+ readonly createdAt: string;
287
+ readonly updatedAt: string;
288
+ }
289
+ interface WikiGraphLibraryScanResult {
290
+ readonly library: WikiGraphLibraryRecord;
291
+ readonly archives: readonly WikiGraphLibraryArchiveRecord[];
292
+ }
293
+ declare function scanWikiGraphLibrary(target: ParsedWikiGraphLibraryUri): Promise<WikiGraphLibraryScanResult>;
294
+ declare function rebindWikiGraphLibrary(input: {
295
+ readonly target: ParsedWikiGraphLibraryUri;
296
+ readonly folderPath: string;
297
+ }): Promise<WikiGraphLibraryScanResult>;
298
+ declare function listWikiGraphLibraryArchives(target: ParsedWikiGraphLibraryUri): Promise<readonly WikiGraphLibraryArchiveRecord[]>;
299
+ declare function getWikiGraphLibraryArchive(target: ParsedWikiGraphLibraryUri): Promise<WikiGraphLibraryArchiveRecord>;
300
+ declare function getWikiGraphLibraryArchiveById(library: WikiGraphLibraryRecord, archiveId: number): Promise<WikiGraphLibraryArchiveRecord>;
301
+ declare function resolveWikiGraphLibraryArchivePath(archiveLocator: string): Promise<string>;
302
+ declare function addWikiGraphLibraryArchive(input: {
303
+ readonly target: ParsedWikiGraphLibraryUri;
304
+ readonly inputPath: string;
305
+ readonly to?: string;
306
+ }): Promise<WikiGraphLibraryArchiveRecord>;
307
+ declare function finalizeWikiGraphLibraryArchiveWrite(input: {
308
+ readonly target: ParsedWikiGraphLibraryUri;
309
+ }): Promise<boolean>;
310
+ declare function ensureLibraryManagedArchiveHasNoSearchIndex(archivePath: string): Promise<boolean>;
311
+ declare function removeWikiGraphLibraryArchive(input: {
312
+ readonly target: ParsedWikiGraphLibraryUri;
313
+ }): Promise<WikiGraphLibraryArchiveRecord>;
314
+ declare function moveWikiGraphLibraryArchive(input: {
315
+ readonly target: ParsedWikiGraphLibraryUri;
316
+ readonly to: string;
317
+ }): Promise<WikiGraphLibraryArchiveRecord>;
241
318
 
242
319
  type SqliteDatabase = Sqlite3Namespace.Database;
243
320
  type SqlBindValue = Buffer | Uint8Array | number | string | null;
@@ -266,7 +343,6 @@ declare class Database {
266
343
  declare function openSharedStateDatabase(databasePath: string, schemaSql: string, options?: {
267
344
  readonly readonly?: boolean;
268
345
  }): Promise<Database>;
269
- declare function ensureSharedStateDatabaseInitialized(databasePath: string, schemaSql: string): Promise<void>;
270
346
 
271
347
  declare enum ChunkRetention {
272
348
  Verbatim = "verbatim",
@@ -274,15 +350,11 @@ declare enum ChunkRetention {
274
350
  Focused = "focused",
275
351
  Relevant = "relevant"
276
352
  }
277
- declare const isChunkRetention: (value: string) => value is ChunkRetention;
278
- declare const expectChunkRetention: (value: string) => ChunkRetention;
279
353
  declare enum ChunkImportance {
280
354
  Critical = "critical",
281
355
  Important = "important",
282
356
  Helpful = "helpful"
283
357
  }
284
- declare const isChunkImportance: (value: string) => value is ChunkImportance;
285
- declare const expectChunkImportance: (value: string) => ChunkImportance;
286
358
  type SentenceId = readonly [chapterId: number, sentenceIndex: number];
287
359
  interface SentenceRecord {
288
360
  readonly text: string;
@@ -406,6 +478,23 @@ interface ObjectMetadataTarget {
406
478
  readonly tripleObjectQid?: string;
407
479
  }
408
480
 
481
+ declare class TextStreamDraft {
482
+ #private;
483
+ constructor(serialId: number, startSentenceIndex: number, callbacks: {
484
+ readonly discard: () => void;
485
+ readonly finalize: (startSentenceIndex: number, summary: string, sentences: readonly SentenceRecord[]) => Promise<FragmentRecord | undefined>;
486
+ });
487
+ addSentence(text: string, wordsCount: number, location?: {
488
+ readonly byteOffset: number;
489
+ readonly byteLength: number;
490
+ }): SentenceId;
491
+ commit(): Promise<FragmentRecord | undefined>;
492
+ commitWithText(text: string): Promise<FragmentRecord | undefined>;
493
+ discard(): void;
494
+ setSummary(summary: string): void;
495
+ get fragmentId(): number;
496
+ }
497
+
409
498
  declare const TEXT_STREAM_KIND: {
410
499
  readonly source: 1;
411
500
  readonly summary: 2;
@@ -446,14 +535,7 @@ interface ReadonlySerialTextStream {
446
535
  readonly path: string;
447
536
  readonly serialId: number;
448
537
  }
449
- declare class TextStreams implements ReadonlyTextStreams {
450
- #private;
451
- constructor(documentPath: string, database: Database, fileAccess?: TextStreamFileAccess);
452
- ensureCreated(): Promise<void>;
453
- getSentence(sentenceId: SentenceId): Promise<string>;
454
- getSerial(serialId: number): SerialTextStream;
455
- getSummarySerial(serialId: number): SerialTextStream;
456
- }
538
+
457
539
  declare class SerialTextStream implements ReadonlySerialTextStream {
458
540
  #private;
459
541
  constructor(documentPath: string, database: Database, fileAccess: TextStreamFileAccess, stream: TextStreamName, serialId: number);
@@ -470,81 +552,14 @@ declare class SerialTextStream implements ReadonlySerialTextStream {
470
552
  get path(): string;
471
553
  get serialId(): number;
472
554
  }
473
- declare class TextStreamDraft {
474
- #private;
475
- constructor(serialId: number, startSentenceIndex: number, callbacks: {
476
- readonly discard: () => void;
477
- readonly finalize: (startSentenceIndex: number, summary: string, sentences: readonly SentenceRecord[]) => Promise<FragmentRecord | undefined>;
478
- });
479
- addSentence(text: string, wordsCount: number, location?: {
480
- readonly byteOffset: number;
481
- readonly byteLength: number;
482
- }): SentenceId;
483
- commit(): Promise<FragmentRecord | undefined>;
484
- commitWithText(text: string): Promise<FragmentRecord | undefined>;
485
- discard(): void;
486
- setSummary(summary: string): void;
487
- get fragmentId(): number;
488
- }
489
555
 
490
- interface FragmentWriter {
491
- write(path: string, content: string): Promise<void>;
492
- }
493
- interface FragmentFileAccess {
494
- ensureDirectory(path: string): Promise<void>;
495
- listFileContents?(path: string): Promise<ReadonlyMap<string, Uint8Array>>;
496
- listFiles(path: string): Promise<readonly string[]>;
497
- readFile(path: string): Promise<Uint8Array | undefined>;
498
- }
499
- interface ReadonlyFragments {
500
- getSerial(serialId: number): ReadonlySerialFragments;
501
- getSummarySerial(serialId: number): ReadonlySerialFragments;
502
- getSentence(sentenceId: SentenceId): Promise<string>;
503
- getSummary(serialId: number, fragmentId: number): Promise<string>;
504
- getWordsCount(serialId: number, fragmentId: number): Promise<number>;
505
- readonly path: string;
506
- }
507
- interface TextStreamWriteOptions {
508
- readonly maxWordsCount?: number;
509
- }
510
- interface ReadonlySerialFragments {
511
- getFragment(fragmentId: number): Promise<FragmentRecord>;
512
- listFragmentIds(): Promise<readonly number[]>;
513
- readonly serialId: number;
514
- readonly path: string;
515
- }
516
- declare class Fragments implements ReadonlyFragments {
556
+ declare class TextStreams implements ReadonlyTextStreams {
517
557
  #private;
518
- constructor(documentPath: string, writer?: FragmentWriter, fileAccess?: FragmentFileAccess);
558
+ constructor(documentPath: string, database: Database, fileAccess?: TextStreamFileAccess);
519
559
  ensureCreated(): Promise<void>;
520
- getSerial(serialId: number): SerialFragments;
521
- getSummarySerial(serialId: number): SerialFragments;
522
560
  getSentence(sentenceId: SentenceId): Promise<string>;
523
- getSummary(serialId: number, fragmentId: number): Promise<string>;
524
- getWordsCount(serialId: number, fragmentId: number): Promise<number>;
525
- get path(): string;
526
- }
527
- declare class SerialFragments implements ReadonlySerialFragments {
528
- #private;
529
- constructor(documentPath: string, serialId: number, rootDirectoryName?: string, writer?: FragmentWriter, fileAccess?: FragmentFileAccess);
530
- createDraft(): Promise<FragmentDraft>;
531
- getFragment(fragmentId: number): Promise<FragmentRecord>;
532
- listFragmentIds(): Promise<readonly number[]>;
533
- writeTextStream(text: string, options?: TextStreamWriteOptions): Promise<void>;
534
- get serialId(): number;
535
- get path(): string;
536
- }
537
- declare class FragmentDraft {
538
- #private;
539
- constructor(serialId: number, fragmentId: number, startSentenceIndex: number, callbacks: {
540
- readonly discard: () => void;
541
- readonly finalize: (fragmentId: number, startSentenceIndex: number, summary: string, sentences: readonly SentenceRecord[]) => Promise<FragmentRecord | undefined>;
542
- });
543
- addSentence(text: string, wordsCount: number): SentenceId;
544
- commit(): Promise<FragmentRecord | undefined>;
545
- discard(): void;
546
- setSummary(summary: string): void;
547
- get fragmentId(): number;
561
+ getSerial(serialId: number): SerialTextStream;
562
+ getSummarySerial(serialId: number): SerialTextStream;
548
563
  }
549
564
 
550
565
  declare const bookMetaSchema: z.ZodObject<{
@@ -567,6 +582,7 @@ type BookMeta = z.infer<typeof bookMetaSchema>;
567
582
 
568
583
  declare const TOC_FILE_VERSION = 1;
569
584
  interface TocItem {
585
+ readonly key?: string | undefined;
570
586
  readonly title?: string | null | undefined;
571
587
  readonly serialId?: number | undefined;
572
588
  readonly children: readonly TocItem[];
@@ -613,16 +629,38 @@ interface ReadonlyReadingEdgeStore {
613
629
  listOutgoing(chunkId: number): Promise<ReadingEdgeRecord[]>;
614
630
  }
615
631
  interface ReadonlyMentionStore {
632
+ countByQid(qid: string, options?: {
633
+ readonly chapterId?: number;
634
+ }): Promise<number>;
616
635
  getById(mentionId: string): Promise<MentionRecord | undefined>;
617
636
  listAll(): Promise<MentionRecord[]>;
618
637
  listBySurfaceTerms(terms: readonly string[]): Promise<MentionRecord[]>;
619
638
  listBySurfaces(surfaces: readonly string[]): Promise<MentionRecord[]>;
620
- listByQid(qid: string): Promise<MentionRecord[]>;
639
+ listByQid(qid: string, options?: {
640
+ readonly chapterId?: number;
641
+ readonly limit?: number;
642
+ readonly offset?: number;
643
+ readonly order?: "asc" | "desc";
644
+ }): Promise<MentionRecord[]>;
645
+ listLabelsByQid(qid: string, options?: {
646
+ readonly chapterId?: number;
647
+ }): Promise<string[]>;
621
648
  listByChapter(chapterId: number): Promise<MentionRecord[]>;
622
649
  }
623
650
  interface ReadonlyMentionLinkStore {
651
+ countByTriple(input: {
652
+ readonly chapterId?: number;
653
+ readonly objectQid: string;
654
+ readonly predicate: string;
655
+ readonly subjectQid: string;
656
+ }): Promise<number>;
624
657
  getById(linkId: string): Promise<MentionLinkRecord | undefined>;
658
+ listAll(): Promise<MentionLinkRecord[]>;
625
659
  listByTriple(input: {
660
+ readonly chapterId?: number;
661
+ readonly limit?: number;
662
+ readonly offset?: number;
663
+ readonly order?: "asc" | "desc";
626
664
  readonly objectQid: string;
627
665
  readonly predicate: string;
628
666
  readonly subjectQid: string;
@@ -652,6 +690,94 @@ interface ReadonlyFragmentGroupStore {
652
690
  interface ReadonlyObjectMetadataStore {
653
691
  getMap(objectPath: string): Promise<Readonly<Record<string, unknown>>>;
654
692
  }
693
+
694
+ declare class ChunkStore implements ReadonlyChunkStore {
695
+ #private;
696
+ constructor(database: Database);
697
+ countAll(): Promise<number>;
698
+ create(record: CreateChunkRecord): Promise<ChunkRecord>;
699
+ save(record: ChunkRecord): Promise<void>;
700
+ getById(chunkId: number): Promise<ChunkRecord | undefined>;
701
+ listAll(): Promise<ChunkRecord[]>;
702
+ listBySentenceStartIndexes(serialId: number, sentenceStartIndexes: readonly number[]): Promise<ChunkRecord[]>;
703
+ listBySentenceRange(serialId: number, startSentenceIndex: number, endSentenceIndex: number): Promise<ChunkRecord[]>;
704
+ listBySerial(serialId: number): Promise<ChunkRecord[]>;
705
+ getMaxId(): Promise<number>;
706
+ listFragmentPairs(): Promise<ReadonlyArray<readonly [number, number]>>;
707
+ }
708
+
709
+ declare class FragmentGroupStore implements ReadonlyFragmentGroupStore {
710
+ #private;
711
+ constructor(database: Database);
712
+ save(record: SentenceGroupRecord): Promise<void>;
713
+ saveMany(records: readonly SentenceGroupRecord[]): Promise<void>;
714
+ listBySerial(serialId: number): Promise<SentenceGroupRecord[]>;
715
+ listSerialIds(): Promise<number[]>;
716
+ listGroupIdsForSerial(serialId: number): Promise<number[]>;
717
+ }
718
+
719
+ declare class GraphBuildParameterStore implements ReadonlyGraphBuildParameterStore {
720
+ #private;
721
+ constructor(database: Database);
722
+ save(input: {
723
+ readonly language?: string;
724
+ readonly prompt: string;
725
+ }): Promise<GraphBuildParameterRecord>;
726
+ getByHash(hash: string): Promise<GraphBuildParameterRecord | undefined>;
727
+ deleteUnreferenced(): Promise<void>;
728
+ }
729
+
730
+ declare class MentionLinkStore implements ReadonlyMentionLinkStore {
731
+ #private;
732
+ constructor(database: Database);
733
+ save(record: MentionLinkRecord): Promise<void>;
734
+ saveMany(records: readonly MentionLinkRecord[]): Promise<void>;
735
+ getById(linkId: string): Promise<MentionLinkRecord | undefined>;
736
+ listAll(): Promise<MentionLinkRecord[]>;
737
+ countByTriple(input: {
738
+ readonly chapterId?: number;
739
+ readonly objectQid: string;
740
+ readonly predicate: string;
741
+ readonly subjectQid: string;
742
+ }): Promise<number>;
743
+ listByTriple(input: {
744
+ readonly chapterId?: number;
745
+ readonly limit?: number;
746
+ readonly offset?: number;
747
+ readonly order?: "asc" | "desc";
748
+ readonly objectQid: string;
749
+ readonly predicate: string;
750
+ readonly subjectQid: string;
751
+ }): Promise<MentionLinkRecord[]>;
752
+ listByChapter(chapterId: number): Promise<MentionLinkRecord[]>;
753
+ deleteByChapter(chapterId: number): Promise<void>;
754
+ }
755
+
756
+ declare class MentionStore implements ReadonlyMentionStore {
757
+ #private;
758
+ constructor(database: Database);
759
+ save(record: MentionRecord): Promise<void>;
760
+ saveMany(records: readonly MentionRecord[]): Promise<void>;
761
+ getById(mentionId: string): Promise<MentionRecord | undefined>;
762
+ listAll(): Promise<MentionRecord[]>;
763
+ countByQid(qid: string, options?: {
764
+ readonly chapterId?: number;
765
+ }): Promise<number>;
766
+ listByQid(qid: string, options?: {
767
+ readonly chapterId?: number;
768
+ readonly limit?: number;
769
+ readonly offset?: number;
770
+ readonly order?: "asc" | "desc";
771
+ }): Promise<MentionRecord[]>;
772
+ listLabelsByQid(qid: string, options?: {
773
+ readonly chapterId?: number;
774
+ }): Promise<string[]>;
775
+ listBySurfaces(surfaces: readonly string[]): Promise<MentionRecord[]>;
776
+ listBySurfaceTerms(terms: readonly string[]): Promise<MentionRecord[]>;
777
+ listByChapter(chapterId: number): Promise<MentionRecord[]>;
778
+ deleteByChapter(chapterId: number): Promise<void>;
779
+ }
780
+
655
781
  declare class ObjectMetadataStore implements ReadonlyObjectMetadataStore {
656
782
  #private;
657
783
  constructor(database: Database);
@@ -664,6 +790,18 @@ declare class ObjectMetadataStore implements ReadonlyObjectMetadataStore {
664
790
  deleteDeletedChunks(): Promise<void>;
665
791
  deleteDeletedEntitiesAndTriples(): Promise<void>;
666
792
  }
793
+
794
+ declare class ReadingEdgeStore implements ReadonlyReadingEdgeStore {
795
+ #private;
796
+ constructor(database: Database);
797
+ countAll(): Promise<number>;
798
+ save(record: ReadingEdgeRecord): Promise<void>;
799
+ listAll(): Promise<ReadingEdgeRecord[]>;
800
+ listBySerial(serialId: number): Promise<ReadingEdgeRecord[]>;
801
+ listIncoming(chunkId: number): Promise<ReadingEdgeRecord[]>;
802
+ listOutgoing(chunkId: number): Promise<ReadingEdgeRecord[]>;
803
+ }
804
+
667
805
  declare class SerialStore implements ReadonlySerialStore {
668
806
  #private;
669
807
  constructor(database: Database);
@@ -686,40 +824,15 @@ declare class SerialStore implements ReadonlySerialStore {
686
824
  readonly serialId: number;
687
825
  }[]): Promise<void>;
688
826
  }
689
- declare class GraphBuildParameterStore implements ReadonlyGraphBuildParameterStore {
690
- #private;
691
- constructor(database: Database);
692
- save(input: {
693
- readonly language?: string;
694
- readonly prompt: string;
695
- }): Promise<GraphBuildParameterRecord>;
696
- getByHash(hash: string): Promise<GraphBuildParameterRecord | undefined>;
697
- deleteUnreferenced(): Promise<void>;
698
- }
699
- declare class ChunkStore implements ReadonlyChunkStore {
700
- #private;
701
- constructor(database: Database);
702
- countAll(): Promise<number>;
703
- create(record: CreateChunkRecord): Promise<ChunkRecord>;
704
- save(record: ChunkRecord): Promise<void>;
705
- getById(chunkId: number): Promise<ChunkRecord | undefined>;
706
- listAll(): Promise<ChunkRecord[]>;
707
- listBySentenceStartIndexes(serialId: number, sentenceStartIndexes: readonly number[]): Promise<ChunkRecord[]>;
708
- listBySentenceRange(serialId: number, startSentenceIndex: number, endSentenceIndex: number): Promise<ChunkRecord[]>;
709
- listBySerial(serialId: number): Promise<ChunkRecord[]>;
710
- getMaxId(): Promise<number>;
711
- listFragmentPairs(): Promise<ReadonlyArray<readonly [number, number]>>;
712
- }
713
- declare class ReadingEdgeStore implements ReadonlyReadingEdgeStore {
827
+
828
+ declare class SnakeChunkStore implements ReadonlySnakeChunkStore {
714
829
  #private;
715
830
  constructor(database: Database);
716
- countAll(): Promise<number>;
717
- save(record: ReadingEdgeRecord): Promise<void>;
718
- listAll(): Promise<ReadingEdgeRecord[]>;
719
- listBySerial(serialId: number): Promise<ReadingEdgeRecord[]>;
720
- listIncoming(chunkId: number): Promise<ReadingEdgeRecord[]>;
721
- listOutgoing(chunkId: number): Promise<ReadingEdgeRecord[]>;
831
+ save(record: SnakeChunkRecord): Promise<void>;
832
+ listChunkIds(snakeId: number): Promise<number[]>;
833
+ listBySnake(snakeId: number): Promise<SnakeChunkRecord[]>;
722
834
  }
835
+
723
836
  declare class SnakeStore implements ReadonlySnakeStore {
724
837
  #private;
725
838
  constructor(database: Database);
@@ -728,40 +841,7 @@ declare class SnakeStore implements ReadonlySnakeStore {
728
841
  listIdsByGroup(serialId: number, groupId: number): Promise<number[]>;
729
842
  listBySerial(serialId: number): Promise<SnakeRecord[]>;
730
843
  }
731
- declare class MentionStore implements ReadonlyMentionStore {
732
- #private;
733
- constructor(database: Database);
734
- save(record: MentionRecord): Promise<void>;
735
- saveMany(records: readonly MentionRecord[]): Promise<void>;
736
- getById(mentionId: string): Promise<MentionRecord | undefined>;
737
- listAll(): Promise<MentionRecord[]>;
738
- listByQid(qid: string): Promise<MentionRecord[]>;
739
- listBySurfaces(surfaces: readonly string[]): Promise<MentionRecord[]>;
740
- listBySurfaceTerms(terms: readonly string[]): Promise<MentionRecord[]>;
741
- listByChapter(chapterId: number): Promise<MentionRecord[]>;
742
- deleteByChapter(chapterId: number): Promise<void>;
743
- }
744
- declare class MentionLinkStore implements ReadonlyMentionLinkStore {
745
- #private;
746
- constructor(database: Database);
747
- save(record: MentionLinkRecord): Promise<void>;
748
- saveMany(records: readonly MentionLinkRecord[]): Promise<void>;
749
- getById(linkId: string): Promise<MentionLinkRecord | undefined>;
750
- listByTriple(input: {
751
- readonly objectQid: string;
752
- readonly predicate: string;
753
- readonly subjectQid: string;
754
- }): Promise<MentionLinkRecord[]>;
755
- listByChapter(chapterId: number): Promise<MentionLinkRecord[]>;
756
- deleteByChapter(chapterId: number): Promise<void>;
757
- }
758
- declare class SnakeChunkStore implements ReadonlySnakeChunkStore {
759
- #private;
760
- constructor(database: Database);
761
- save(record: SnakeChunkRecord): Promise<void>;
762
- listChunkIds(snakeId: number): Promise<number[]>;
763
- listBySnake(snakeId: number): Promise<SnakeChunkRecord[]>;
764
- }
844
+
765
845
  declare class SnakeEdgeStore implements ReadonlySnakeEdgeStore {
766
846
  #private;
767
847
  constructor(database: Database);
@@ -771,15 +851,6 @@ declare class SnakeEdgeStore implements ReadonlySnakeEdgeStore {
771
851
  listWithin(snakeIds: readonly number[]): Promise<SnakeEdgeRecord[]>;
772
852
  listBySerial(serialId: number): Promise<SnakeEdgeRecord[]>;
773
853
  }
774
- declare class FragmentGroupStore implements ReadonlyFragmentGroupStore {
775
- #private;
776
- constructor(database: Database);
777
- save(record: SentenceGroupRecord): Promise<void>;
778
- saveMany(records: readonly SentenceGroupRecord[]): Promise<void>;
779
- listBySerial(serialId: number): Promise<SentenceGroupRecord[]>;
780
- listSerialIds(): Promise<number[]>;
781
- listGroupIdsForSerial(serialId: number): Promise<number[]>;
782
- }
783
854
 
784
855
  interface DocumentFileStore {
785
856
  close(): Promise<void>;
@@ -861,6 +932,19 @@ interface Document extends ReadonlyDocument {
861
932
  writeToc(toc: TocFile): Promise<void>;
862
933
  writeSearchIndexDatabase<T>(operation: (database: Database) => Promise<T> | T): Promise<T>;
863
934
  }
935
+
936
+ declare class DirectoryDocumentContext implements DocumentContext {
937
+ #private;
938
+ constructor(document: DirectoryDocument);
939
+ complete(): void;
940
+ dispose(): Promise<void>;
941
+ ownSerial(serialId: number): void;
942
+ run<T>(operation: () => Promise<T> | T): Promise<T>;
943
+ listCreatedFilePaths(): readonly string[];
944
+ listOwnedSerialIds(): readonly number[];
945
+ registerCreatedFile(path: string): void;
946
+ }
947
+
864
948
  declare class DirectoryDocument implements Document {
865
949
  #private;
866
950
  readonly chunks: ChunkStore;
@@ -911,237 +995,419 @@ declare class DirectoryDocument implements Document {
911
995
  runWithContext<T>(context: DirectoryDocumentContext, operation: () => Promise<T> | T): Promise<T>;
912
996
  rollbackContext(context: DirectoryDocumentContext): Promise<void>;
913
997
  }
914
- declare class DirectoryDocumentContext implements DocumentContext {
915
- #private;
916
- constructor(document: DirectoryDocument);
917
- complete(): void;
918
- dispose(): Promise<void>;
919
- ownSerial(serialId: number): void;
920
- run<T>(operation: () => Promise<T> | T): Promise<T>;
921
- listCreatedFilePaths(): readonly string[];
922
- listOwnedSerialIds(): readonly number[];
923
- registerCreatedFile(path: string): void;
924
- }
925
-
926
- declare const SCHEMA_SQL = "\n CREATE TABLE IF NOT EXISTS serials (\n id INTEGER PRIMARY KEY,\n document_order INTEGER NOT NULL DEFAULT 0\n );\n\n CREATE TABLE IF NOT EXISTS serial_states (\n serial_id INTEGER PRIMARY KEY,\n revision INTEGER NOT NULL DEFAULT 0,\n topology_ready INTEGER NOT NULL DEFAULT 0,\n topology_parameter_hash TEXT,\n knowledge_graph_ready INTEGER NOT NULL DEFAULT 0,\n knowledge_graph_parameter_hash TEXT,\n FOREIGN KEY (serial_id) REFERENCES serials(id)\n );\n\n CREATE TABLE IF NOT EXISTS archive_revisions (\n key TEXT PRIMARY KEY,\n value INTEGER NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS archive_index_settings (\n id INTEGER PRIMARY KEY CHECK (id = 1),\n fts_embedded INTEGER NOT NULL DEFAULT 0\n );\n\n CREATE TABLE IF NOT EXISTS graph_build_parameters (\n hash TEXT PRIMARY KEY,\n prompt TEXT NOT NULL,\n language TEXT,\n created_at TEXT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS chunks (\n id INTEGER PRIMARY KEY,\n generation INTEGER NOT NULL,\n serial_id INTEGER NOT NULL,\n sentence_index INTEGER NOT NULL,\n label TEXT NOT NULL,\n content TEXT NOT NULL,\n retention TEXT,\n importance TEXT,\n wordsCount INTEGER NOT NULL DEFAULT 0,\n weight REAL NOT NULL DEFAULT 0.0\n );\n\n CREATE INDEX IF NOT EXISTS idx_chunks_sentence\n ON chunks(serial_id, sentence_index);\n\n CREATE INDEX IF NOT EXISTS idx_chunks_serial_id\n ON chunks(serial_id, id);\n\n CREATE TABLE IF NOT EXISTS chunk_sentences (\n chunk_id INTEGER NOT NULL,\n serial_id INTEGER NOT NULL,\n sentence_index INTEGER NOT NULL,\n FOREIGN KEY (chunk_id) REFERENCES chunks(id),\n PRIMARY KEY (chunk_id, serial_id, sentence_index)\n );\n\n CREATE TABLE IF NOT EXISTS reading_edges (\n from_id INTEGER NOT NULL,\n to_id INTEGER NOT NULL,\n strength TEXT,\n weight REAL NOT NULL DEFAULT 0.1,\n PRIMARY KEY (from_id, to_id),\n FOREIGN KEY (from_id) REFERENCES chunks(id),\n FOREIGN KEY (to_id) REFERENCES chunks(id)\n );\n\n CREATE TABLE IF NOT EXISTS snakes (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n serial_id INTEGER NOT NULL,\n group_id INTEGER NOT NULL,\n local_snake_id INTEGER NOT NULL,\n size INTEGER NOT NULL,\n first_label TEXT NOT NULL,\n last_label TEXT NOT NULL,\n wordsCount INTEGER NOT NULL DEFAULT 0,\n weight REAL NOT NULL DEFAULT 0.0,\n UNIQUE(serial_id, group_id, local_snake_id)\n );\n\n CREATE TABLE IF NOT EXISTS snake_chunks (\n snake_id INTEGER NOT NULL,\n chunk_id INTEGER NOT NULL,\n position INTEGER NOT NULL,\n FOREIGN KEY (snake_id) REFERENCES snakes(id),\n FOREIGN KEY (chunk_id) REFERENCES chunks(id),\n PRIMARY KEY (snake_id, chunk_id)\n );\n\n CREATE TABLE IF NOT EXISTS snake_edges (\n from_snake_id INTEGER NOT NULL,\n to_snake_id INTEGER NOT NULL,\n weight REAL NOT NULL DEFAULT 0.1,\n PRIMARY KEY (from_snake_id, to_snake_id),\n FOREIGN KEY (from_snake_id) REFERENCES snakes(id),\n FOREIGN KEY (to_snake_id) REFERENCES snakes(id)\n );\n\n CREATE TABLE IF NOT EXISTS sentence_groups (\n serial_id INTEGER NOT NULL,\n group_id INTEGER NOT NULL,\n start_sentence_index INTEGER NOT NULL,\n end_sentence_index INTEGER NOT NULL,\n PRIMARY KEY (serial_id, group_id, start_sentence_index, end_sentence_index)\n );\n\n CREATE TABLE IF NOT EXISTS mentions (\n id TEXT PRIMARY KEY,\n chapter_id INTEGER NOT NULL,\n sentence_index INTEGER,\n range_start INTEGER NOT NULL,\n range_end INTEGER NOT NULL,\n surface TEXT NOT NULL,\n qid TEXT NOT NULL,\n confidence REAL,\n note TEXT,\n FOREIGN KEY (chapter_id) REFERENCES serials(id)\n );\n\n CREATE INDEX IF NOT EXISTS idx_mentions_chapter\n ON mentions(chapter_id);\n\n CREATE INDEX IF NOT EXISTS idx_mentions_chapter_position\n ON mentions(chapter_id, sentence_index, range_start, range_end, id);\n\n CREATE INDEX IF NOT EXISTS idx_mentions_chapter_qid\n ON mentions(chapter_id, qid);\n\n CREATE INDEX IF NOT EXISTS idx_mentions_qid\n ON mentions(qid);\n\n CREATE INDEX IF NOT EXISTS idx_mentions_qid_position\n ON mentions(qid, chapter_id, sentence_index, range_start, range_end, id);\n\n CREATE INDEX IF NOT EXISTS idx_mentions_surface\n ON mentions(surface);\n\n CREATE INDEX IF NOT EXISTS idx_mentions_surface_position\n ON mentions(surface, chapter_id, sentence_index, range_start, range_end, id);\n\n CREATE INDEX IF NOT EXISTS idx_mentions_sentence\n ON mentions(chapter_id, sentence_index);\n\n CREATE TABLE IF NOT EXISTS mention_links (\n id TEXT PRIMARY KEY,\n source_mention_id TEXT NOT NULL,\n target_mention_id TEXT NOT NULL,\n predicate TEXT NOT NULL,\n confidence REAL,\n note TEXT,\n FOREIGN KEY (source_mention_id) REFERENCES mentions(id),\n FOREIGN KEY (target_mention_id) REFERENCES mentions(id)\n );\n\n CREATE TABLE IF NOT EXISTS mention_link_evidence_sentences (\n link_id TEXT NOT NULL,\n chapter_id INTEGER NOT NULL,\n sentence_index INTEGER NOT NULL,\n FOREIGN KEY (link_id) REFERENCES mention_links(id),\n PRIMARY KEY (link_id, chapter_id, sentence_index)\n );\n\n CREATE INDEX IF NOT EXISTS idx_mention_link_evidence_sentences_sentence\n ON mention_link_evidence_sentences(chapter_id, sentence_index);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_source\n ON mention_links(source_mention_id);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_target\n ON mention_links(target_mention_id);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_predicate\n ON mention_links(predicate);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_predicate_source_target\n ON mention_links(predicate, source_mention_id, target_mention_id);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_predicate_target_source\n ON mention_links(predicate, target_mention_id, source_mention_id);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_source_predicate_target\n ON mention_links(source_mention_id, predicate, target_mention_id);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_target_predicate_source\n ON mention_links(target_mention_id, predicate, source_mention_id);\n\n CREATE INDEX IF NOT EXISTS idx_mention_links_source_target_predicate\n ON mention_links(source_mention_id, target_mention_id, predicate);\n\n CREATE INDEX IF NOT EXISTS idx_reading_edges_target\n ON reading_edges(to_id, from_id);\n\n CREATE INDEX IF NOT EXISTS idx_snake_edges_target\n ON snake_edges(to_snake_id, from_snake_id);\n\n CREATE VIEW IF NOT EXISTS chapter_entities AS\n SELECT\n chapter_id,\n qid,\n COUNT(*) AS mention_count\n FROM mentions\n GROUP BY chapter_id, qid;\n\n CREATE VIEW IF NOT EXISTS book_entities AS\n SELECT\n qid,\n SUM(mention_count) AS mention_count\n FROM chapter_entities\n GROUP BY qid;\n\n CREATE VIEW IF NOT EXISTS chapter_entity_relations AS\n SELECT\n source_mentions.chapter_id AS chapter_id,\n source_mentions.qid AS subject_qid,\n mention_links.predicate AS predicate,\n target_mentions.qid AS object_qid,\n COUNT(*) AS evidence_count\n FROM mention_links\n JOIN mentions AS source_mentions\n ON source_mentions.id = mention_links.source_mention_id\n JOIN mentions AS target_mentions\n ON target_mentions.id = mention_links.target_mention_id\n WHERE source_mentions.chapter_id = target_mentions.chapter_id\n GROUP BY\n source_mentions.chapter_id,\n source_mentions.qid,\n mention_links.predicate,\n target_mentions.qid;\n\n CREATE VIEW IF NOT EXISTS book_entity_relations AS\n SELECT\n subject_qid,\n predicate,\n object_qid,\n SUM(evidence_count) AS evidence_count\n FROM chapter_entity_relations\n GROUP BY subject_qid, predicate, object_qid;\n\n CREATE TABLE IF NOT EXISTS text_sentence_records (\n id INTEGER PRIMARY KEY,\n kind INTEGER NOT NULL,\n chapter_id INTEGER NOT NULL,\n sentence_index INTEGER NOT NULL,\n words_count INTEGER NOT NULL DEFAULT 0,\n byte_offset INTEGER NOT NULL DEFAULT 0,\n byte_length INTEGER NOT NULL DEFAULT 0,\n UNIQUE(kind, chapter_id, sentence_index)\n );\n\n CREATE INDEX IF NOT EXISTS idx_text_sentence_records_chapter\n ON text_sentence_records(kind, chapter_id, sentence_index);\n\n CREATE TABLE IF NOT EXISTS object_metadata (\n id INTEGER PRIMARY KEY,\n object_kind INTEGER NOT NULL,\n object_path TEXT NOT NULL,\n key TEXT NOT NULL,\n value_json TEXT NOT NULL,\n updated_at TEXT NOT NULL,\n chapter_id INTEGER,\n chunk_id INTEGER,\n entity_qid TEXT,\n triple_subject_qid TEXT,\n triple_predicate TEXT,\n triple_object_qid TEXT,\n UNIQUE(object_path, key)\n );\n\n CREATE INDEX IF NOT EXISTS idx_object_metadata_object\n ON object_metadata(object_path);\n\n CREATE INDEX IF NOT EXISTS idx_object_metadata_chapter\n ON object_metadata(chapter_id);\n\n CREATE INDEX IF NOT EXISTS idx_object_metadata_chunk\n ON object_metadata(chunk_id);\n\n CREATE INDEX IF NOT EXISTS idx_object_metadata_entity\n ON object_metadata(entity_qid);\n\n CREATE INDEX IF NOT EXISTS idx_object_metadata_triple\n ON object_metadata(\n triple_subject_qid,\n triple_predicate,\n triple_object_qid\n );\n";
927
-
928
- declare const EVIDENCE_SELECTION_PROMPT_FRAGMENT: string;
929
- declare const EVIDENCE_SELECTION_JSON_SHAPE: readonly [{
930
- readonly quote: "exact short source quote copied from the selected sentence";
931
- readonly sentence_id: "sentence id from the source context, such as S1";
932
- }];
933
- declare function formatEvidenceSelectionChoicePrompt(input: {
934
- readonly evidenceLabel: string;
935
- readonly generatedEvidence: unknown;
936
- readonly candidates: readonly {
937
- readonly nextText: string;
938
- readonly occurrenceId: string;
939
- readonly prevText: string;
940
- readonly score: number;
941
- readonly text: string;
942
- }[];
943
- }): string;
944
998
 
945
- type EvidenceQuoteMatchStrategy = "empty" | "exact" | "normalized_exact" | "normalized_substring" | "fuzzy_window";
946
- interface EvidenceQuoteScore {
947
- readonly exactRaw: boolean;
948
- readonly exactNormalized: boolean;
949
- readonly exactSubstring: boolean;
950
- readonly matchEnd: number;
951
- readonly matchStart: number;
952
- readonly normalizedQuote: string;
953
- readonly normalizedSentence: string;
954
- readonly score: number;
955
- readonly strategy: EvidenceQuoteMatchStrategy;
999
+ interface GraphNode {
1000
+ readonly content: string;
1001
+ readonly id: number;
1002
+ readonly importance?: ChunkImportance;
1003
+ readonly label: string;
1004
+ readonly retention?: ChunkRetention;
1005
+ readonly sentenceIds: readonly SentenceId[];
1006
+ readonly weight: number;
1007
+ readonly wordsCount: number;
956
1008
  }
957
- declare function normalizeEvidenceDisplayText(text: string): string;
958
- declare function normalizeEvidenceText(text: string): string;
959
- declare function scoreEvidenceQuote(input: {
960
- readonly quote: string;
961
- readonly sentence: string;
962
- }): EvidenceQuoteScore;
963
-
964
- type EvidenceSentenceId = readonly [number, number];
965
- interface EvidenceSelectionSentence {
966
- readonly id: string;
967
- readonly sentenceId: EvidenceSentenceId;
968
- readonly text: string;
1009
+ interface GraphEdge {
1010
+ readonly fromId: number;
1011
+ readonly strength?: string;
1012
+ readonly toId: number;
1013
+ readonly weight: number;
969
1014
  }
970
- interface EvidenceSelection {
971
- readonly quote?: string;
972
- readonly sentence_id?: string;
1015
+ interface GraphNeighbor {
1016
+ readonly direction: "incoming" | "outgoing";
1017
+ readonly edge: GraphEdge;
1018
+ readonly node: GraphNode;
973
1019
  }
974
- type EvidenceSelectionList = EvidenceSelection | readonly EvidenceSelection[];
975
- interface EvidenceSelectionCandidate {
976
- readonly exactNormalized: boolean;
977
- readonly exactRaw: boolean;
978
- readonly exactSubstring: boolean;
979
- readonly index: number;
980
- readonly nextText: string;
981
- readonly occurrenceId: string;
982
- readonly prevText: string;
983
- readonly score: number;
984
- readonly sentence: EvidenceSelectionSentence;
985
- readonly strategy: string;
1020
+
1021
+ declare const CHAPTER_STAGES: readonly ["planned", "sourced", "graphed", "summarized"];
1022
+ type ChapterStage = (typeof CHAPTER_STAGES)[number];
1023
+ interface ChapterEntry {
1024
+ readonly chapterId: number;
1025
+ readonly childCount: number;
1026
+ readonly depth: number;
1027
+ readonly documentOrder: number;
1028
+ readonly fragmentCount: number;
1029
+ readonly key: string;
1030
+ readonly path: string;
1031
+ readonly stage: ChapterStage;
1032
+ readonly title: string | null;
1033
+ readonly tocPath: readonly string[];
1034
+ readonly uri: string;
1035
+ readonly words: number;
986
1036
  }
987
- interface EvidenceSelectionResolution {
988
- readonly candidate: EvidenceSelectionCandidate;
989
- readonly confidence: number;
990
- readonly sentenceIds: readonly EvidenceSentenceId[];
991
- readonly strategy: string;
1037
+ interface ChapterDetails extends ChapterEntry {
1038
+ readonly graphReady: boolean;
1039
+ readonly hasSummary: boolean;
1040
+ readonly words: number;
992
1041
  }
993
- interface EvidenceSelectionFailure {
994
- readonly candidates: readonly EvidenceSelectionCandidate[];
995
- readonly code: "ambiguous" | "invalid" | "low_confidence" | "missing_sentence" | "none";
996
- readonly message: string;
1042
+ interface ChapterTree {
1043
+ readonly chapters: readonly ChapterTreeNode[];
1044
+ }
1045
+ interface ChapterTreeNode {
1046
+ readonly children: readonly ChapterTreeNode[];
1047
+ readonly title: string | null;
1048
+ readonly uri: string;
997
1049
  }
998
1050
 
999
- declare function resolveEvidenceSelection(input: {
1000
- readonly evidence: EvidenceSelection;
1001
- readonly sentences: readonly EvidenceSelectionSentence[];
1002
- }): readonly [
1003
- resolution: EvidenceSelectionResolution | undefined,
1004
- failure: EvidenceSelectionFailure | undefined
1005
- ];
1006
- declare function resolveEvidenceSelectionList(input: {
1007
- readonly evidence: EvidenceSelectionList;
1008
- readonly sentences: readonly EvidenceSelectionSentence[];
1009
- }): readonly [
1010
- resolution: EvidenceSelectionResolution | undefined,
1011
- failure: EvidenceSelectionFailure | undefined
1012
- ];
1013
- declare function rankEvidenceQuote(quote: string, sentences: readonly EvidenceSelectionSentence[]): EvidenceSelectionCandidate[];
1051
+ declare function getChapterDetails(document: ReadonlyDocument, chapterId: number): Promise<ChapterDetails>;
1052
+ declare function listChapters(document: ReadonlyDocument): Promise<readonly ChapterEntry[]>;
1053
+ declare function getChapterTree(document: ReadonlyDocument): Promise<ChapterTree>;
1014
1054
 
1015
- interface WikipageResolverOptions {
1016
- readonly cacheDatabasePath?: string;
1017
- readonly concurrency?: number;
1018
- readonly fetch?: typeof fetch;
1019
- readonly language?: string;
1020
- readonly logDirPath?: string;
1021
- readonly maxBatchSize?: number;
1022
- readonly minRequestIntervalMs?: number;
1023
- readonly normalizer?: DisambiguationProfileNormalizer;
1024
- readonly progress?: WikipageResolveProgressReporter;
1025
- readonly retryBaseDelayMs?: number;
1026
- readonly retryTimes?: number;
1027
- readonly userAgent?: string;
1028
- readonly wiki?: string;
1055
+ type ArchiveObjectType = "chapter" | "chapter-title" | "chapter-tree" | "edge" | "entity" | "fragment" | "meta" | "node" | "source" | "state" | "summary" | "triple";
1056
+ type ChapterStateTarget = "knowledge-graph" | "reading-graph" | "reading-summary" | "source";
1057
+ type ChapterStateValue = "missing" | "ready";
1058
+ type ChapterState = Record<ChapterStateTarget, ChapterStateValue>;
1059
+ type ArchiveCollectionType = "chapter" | "chapter-title" | "entity" | "fragment" | "meta" | "node" | "source" | "summary" | "triple";
1060
+ type ArchiveFindObjectType = "chapter" | "chapter-title" | "chapter-tree" | "entity" | "fragment" | "meta" | "node" | "source" | "summary" | "triple";
1061
+ type ArchiveFindFilterType = "chapter" | "chapter-title" | "entity" | "fragment" | "meta" | "node" | "source" | "summary" | "triple";
1062
+ interface ArchiveIndex {
1063
+ readonly chapters: readonly ChapterEntry[];
1064
+ readonly edgeCount: number;
1065
+ readonly meta: BookMeta | undefined;
1066
+ readonly nodeCount: number;
1067
+ readonly summaryCount: number;
1029
1068
  }
1030
- type WikipageResolveProgressDetail = "disambiguation-page" | "entity" | "linked-page" | "page" | "qid";
1031
- interface WikipageResolveProgress {
1032
- readonly detail: WikipageResolveProgressDetail;
1033
- readonly done: number;
1034
- readonly total: number;
1069
+ interface ArchiveLibrarySourceFields {
1070
+ readonly archiveId?: number;
1071
+ readonly libraryArchiveUri?: string;
1072
+ readonly sources?: readonly ArchiveLibrarySource[];
1035
1073
  }
1036
- type WikipageResolveProgressReporter = (event: WikipageResolveProgress) => Promise<void> | void;
1037
- interface QidResolution {
1038
- readonly description?: string;
1039
- readonly disambiguation?: DisambiguationExpansion;
1040
- readonly disambiguationPages?: readonly DisambiguationPageText[];
1041
- readonly isDisambiguation: boolean;
1042
- readonly label?: string;
1043
- readonly qid: string;
1044
- readonly sitelink?: WikipageSitelink;
1045
- readonly sitelinks?: readonly WikipageSitelink[];
1074
+ interface ArchiveLibrarySource {
1075
+ readonly archiveId: number;
1076
+ readonly libraryArchiveUri: string;
1046
1077
  }
1047
- interface WikipageSitelink {
1078
+ interface ArchiveFindHit extends ArchiveLibrarySourceFields {
1079
+ readonly backlinks?: ArchiveBacklinks;
1080
+ readonly chapter?: number;
1081
+ readonly evidence?: ArchiveFindEvidencePreview;
1082
+ readonly evidenceLinks?: readonly MentionLinkRecord[];
1083
+ readonly evidenceMentions?: readonly EntityEvidenceMention[];
1084
+ readonly field: ArchiveFindField;
1085
+ readonly id: string;
1086
+ readonly matchCount?: number;
1087
+ readonly matchedTerms?: readonly string[];
1088
+ readonly missingTerms?: readonly string[];
1089
+ readonly position?: ArchiveFindPosition;
1090
+ readonly score?: number;
1091
+ readonly snippet: string;
1092
+ readonly state?: ChapterState;
1048
1093
  readonly title: string;
1049
- readonly wiki: string;
1094
+ readonly triple?: {
1095
+ readonly objectLabel: string;
1096
+ readonly predicate: string;
1097
+ readonly subjectLabel: string;
1098
+ };
1099
+ readonly type: ArchiveFindObjectType;
1050
1100
  }
1051
- interface DisambiguationExpansion {
1052
- readonly checkedAt: string;
1053
- readonly disambiguationQid: string;
1054
- readonly linkedQids: readonly DisambiguationLinkedQid[];
1055
- readonly pages: readonly DisambiguationPageText[];
1056
- readonly profile?: DisambiguationProfile;
1101
+ interface EntityEvidenceMention {
1102
+ readonly match: Pick<ArchiveFindHit, "matchCount" | "matchedTerms" | "missingTerms" | "score">;
1103
+ readonly mention: MentionRecord;
1057
1104
  }
1058
- interface DisambiguationPageText {
1059
- readonly linkedQids: readonly DisambiguationLinkedQid[];
1060
- readonly pageId?: number;
1061
- readonly text: string;
1062
- readonly title: string;
1063
- readonly wiki: "enwiki" | "zhwiki";
1105
+ interface ArchiveFindEvidencePreview {
1106
+ readonly nextCursor: string | null;
1107
+ readonly shown: number;
1108
+ readonly sources: readonly ArchiveEvidenceItem[];
1109
+ readonly total: number;
1064
1110
  }
1065
- interface DisambiguationLinkedQid {
1066
- readonly qid: string;
1067
- readonly title: string;
1111
+ type ArchiveFindField = "content" | "metadata" | "source" | "summary" | "title";
1112
+ interface ArchiveFindOptions {
1113
+ readonly archiveKey?: string;
1114
+ readonly backlinks?: boolean;
1115
+ readonly chapters?: readonly number[];
1116
+ readonly cursor?: string;
1117
+ readonly evidenceLimit?: number;
1118
+ readonly ids?: readonly string[];
1119
+ readonly limit?: number;
1120
+ readonly match?: ArchiveFindMatch;
1121
+ readonly order?: ArchiveFindOrder;
1122
+ readonly sourceContext?: number;
1123
+ readonly triplePattern?: ArchiveTriplePattern;
1124
+ readonly types?: readonly ArchiveFindFilterType[];
1068
1125
  }
1069
- interface CachedQidRecord {
1070
- readonly checkedAt: string;
1071
- readonly description?: string;
1072
- readonly label?: string;
1126
+ type ArchiveFindOrder = "doc-asc" | "doc-desc";
1127
+ type ArchiveFindMatch = "all" | "any";
1128
+ interface ArchiveFindPosition {
1129
+ readonly chapter: number;
1130
+ readonly documentOrder?: number;
1131
+ readonly fragment?: number;
1132
+ readonly sentence?: number;
1133
+ }
1134
+ interface ArchiveFindResult {
1135
+ readonly chapters: readonly number[] | null;
1136
+ readonly items: readonly ArchiveFindHit[];
1137
+ readonly lens: ArchiveFindLens;
1138
+ readonly lensHint: ArchiveFindLensHint | null;
1139
+ readonly limit: number;
1140
+ readonly match: ArchiveFindMatch;
1141
+ readonly nextCursor: string | null;
1142
+ readonly order: ArchiveFindOrder;
1143
+ readonly query: string;
1144
+ readonly terms: readonly string[];
1145
+ readonly types: readonly ArchiveFindFilterType[] | null;
1146
+ }
1147
+ type ArchiveFindLens = "broad" | "exact" | "typed";
1148
+ interface ArchiveFindLensHint {
1149
+ readonly lenses: {
1150
+ readonly chapter: string;
1151
+ readonly chunk: string;
1152
+ readonly entity: string;
1153
+ readonly node: string;
1154
+ readonly triple: string;
1155
+ };
1156
+ readonly message: string;
1157
+ }
1158
+ interface ArchiveCollectionOptions {
1159
+ readonly backlinks?: boolean;
1160
+ readonly chapters?: readonly number[];
1161
+ readonly cursor?: string;
1162
+ readonly evidenceLimit?: number;
1163
+ readonly ids?: readonly string[];
1164
+ readonly limit?: number;
1165
+ readonly order?: ArchiveFindOrder;
1166
+ readonly sourceContext?: number;
1167
+ readonly triplePattern?: ArchiveTriplePattern;
1168
+ readonly types?: readonly ArchiveCollectionType[];
1169
+ }
1170
+ interface ArchiveTriplePattern {
1171
+ readonly objectQid?: string;
1172
+ readonly predicate?: string;
1173
+ readonly subjectQid?: string;
1174
+ }
1175
+ interface ArchiveCollectionResult {
1176
+ readonly chapters: readonly number[] | null;
1177
+ readonly ids: readonly string[] | null;
1178
+ readonly items: readonly ArchiveFindHit[];
1179
+ readonly limit: number;
1180
+ readonly nextCursor: string | null;
1181
+ readonly order: ArchiveFindOrder;
1182
+ readonly types: readonly ArchiveCollectionType[] | null;
1183
+ }
1184
+ interface ArchiveBacklinks {
1185
+ readonly chunks: ArchiveBacklinkBucket;
1186
+ readonly entities: ArchiveBacklinkBucket;
1187
+ readonly triples: ArchiveBacklinkBucket;
1188
+ }
1189
+ interface ArchiveBacklinkBucket {
1190
+ readonly items: readonly ArchiveFindHit[];
1191
+ readonly limit: number;
1192
+ readonly nextCursor: string | null;
1193
+ }
1194
+ type ArchiveListKind = "chapters" | "edges" | "fragments" | "meta" | "nodes" | "summaries";
1195
+ type ArchiveListItem = ArchiveLibrarySourceFields & ({
1196
+ readonly evidence?: ArchiveFindEvidencePreview;
1197
+ readonly id: string;
1198
+ readonly label: string;
1199
+ readonly score?: number;
1200
+ readonly state?: ChapterState;
1201
+ readonly summary: string;
1202
+ readonly type: Exclude<ArchiveObjectType, "triple">;
1203
+ } | {
1204
+ readonly evidence?: ArchiveFindEvidencePreview;
1205
+ readonly id: string;
1206
+ readonly label: string;
1207
+ readonly evidenceLinks?: readonly MentionLinkRecord[];
1208
+ readonly objectLabel: string;
1209
+ readonly objectQid: string;
1210
+ readonly predicate: string;
1211
+ readonly score?: number;
1212
+ readonly subjectLabel: string;
1213
+ readonly subjectQid: string;
1214
+ readonly summary: string;
1215
+ readonly type: "triple";
1216
+ });
1217
+ type ArchivePage = ArchiveLibrarySourceFields & ({
1218
+ readonly id: string;
1219
+ readonly state: ChapterState;
1220
+ readonly title: string;
1221
+ readonly type: "chapter";
1222
+ } | {
1223
+ readonly id: string;
1224
+ readonly title: string;
1225
+ readonly type: "chapter-title";
1226
+ } | {
1227
+ readonly id: string;
1228
+ readonly title: string;
1229
+ readonly tree: ChapterTree;
1230
+ readonly type: "chapter-tree";
1231
+ } | {
1232
+ readonly generatedNodeSummary: string;
1233
+ readonly id: string;
1234
+ readonly incoming: readonly GraphNeighbor[];
1235
+ readonly neighbors: readonly GraphNeighbor[];
1236
+ readonly outgoing: readonly GraphNeighbor[];
1237
+ readonly position: ArchiveFindPosition | undefined;
1238
+ readonly sourceFragments: readonly ArchiveNodeSourceFragment[];
1239
+ readonly title: string;
1240
+ readonly type: "node";
1241
+ } | {
1242
+ readonly backlinks?: ArchiveBacklinks;
1243
+ readonly fragment: ArchiveSourceFragment;
1244
+ readonly id: string;
1245
+ readonly nextFragmentId: string | undefined;
1246
+ readonly nodes: readonly ArchiveNodeLabel[];
1247
+ readonly previousFragmentId: string | undefined;
1248
+ readonly title: string;
1249
+ readonly type: "fragment";
1250
+ } | {
1251
+ readonly content: string;
1252
+ readonly id: string;
1253
+ readonly title: string;
1254
+ readonly type: "summary";
1255
+ } | {
1256
+ readonly evidence: ArchiveFindEvidencePreview;
1257
+ readonly id: string;
1258
+ readonly label: string;
1259
+ readonly labels: readonly string[];
1260
+ readonly mentionCount: number;
1073
1261
  readonly qid: string;
1074
- readonly sitelinks: readonly CachedPageRecord[];
1075
- readonly updatedAt: string;
1262
+ readonly type: "entity";
1263
+ } | {
1264
+ readonly en: ArchiveEntityWikipageLocale | null;
1265
+ readonly id: string;
1266
+ readonly type: "entity-wikipage";
1267
+ readonly zh: ArchiveEntityWikipageLocale | null;
1268
+ } | {
1269
+ readonly evidence: ArchiveFindEvidencePreview;
1270
+ readonly id: string;
1271
+ readonly label: string;
1272
+ readonly objectQid: string;
1273
+ readonly predicate: string;
1274
+ readonly subjectQid: string;
1275
+ readonly type: "triple";
1276
+ } | {
1277
+ readonly authors?: readonly string[];
1278
+ readonly description?: string;
1279
+ readonly id: string;
1280
+ readonly publisher?: string;
1281
+ readonly title: string;
1282
+ readonly type: "meta";
1283
+ } | {
1284
+ readonly id: string;
1285
+ readonly state: ChapterState;
1286
+ readonly type: "state";
1287
+ } | {
1288
+ readonly id: string;
1289
+ readonly target: ChapterStateTarget;
1290
+ readonly type: "state";
1291
+ readonly value: ChapterStateValue;
1292
+ });
1293
+ interface ArchiveEntityWikipageLocale {
1294
+ readonly description?: string;
1295
+ readonly title: string;
1296
+ readonly url: string;
1076
1297
  }
1077
- interface CachedDisambiguationRecord {
1078
- readonly checkedAt: string;
1079
- readonly disambiguationQid: string;
1080
- readonly pages: readonly DisambiguationPageText[];
1081
- readonly profile?: DisambiguationProfile;
1298
+ interface ArchivePack {
1299
+ readonly anchor: ArchivePage;
1300
+ readonly budget: number;
1301
+ readonly related: readonly ArchiveListItem[];
1082
1302
  }
1083
- interface CachedPageRecord {
1084
- readonly isDisambiguation: boolean;
1085
- readonly pageId?: number;
1303
+ type ArchiveRelatedRole = "any" | "object" | "self" | "subject";
1304
+ interface ArchiveRelatedOptions {
1305
+ readonly cursor?: string;
1306
+ readonly evidenceLimit?: number;
1307
+ readonly limit?: number;
1308
+ readonly order?: ArchiveFindOrder;
1309
+ readonly query?: string;
1310
+ readonly role?: ArchiveRelatedRole;
1311
+ readonly sourceContext?: number;
1312
+ }
1313
+ interface ArchiveRelatedResult {
1314
+ readonly items: readonly ArchiveListItem[];
1315
+ readonly limit: number;
1316
+ readonly nextCursor: string | null;
1317
+ }
1318
+ interface ArchiveEvidence {
1319
+ readonly items: readonly ArchiveEvidenceItem[];
1320
+ readonly limit: number;
1321
+ readonly nextCursor: string | null;
1322
+ }
1323
+ interface ArchiveEvidenceItem extends ArchiveLibrarySourceFields {
1324
+ readonly chapterId: number;
1325
+ readonly endSentenceIndex: number;
1326
+ readonly fragmentId?: number;
1327
+ readonly id: string;
1328
+ readonly score?: number;
1329
+ readonly source: string;
1330
+ readonly startSentenceIndex: number;
1086
1331
  readonly title: string;
1087
- readonly wiki: "enwiki" | "zhwiki";
1332
+ readonly type: "source";
1088
1333
  }
1089
- type DisambiguationMeaningPriority = "other" | "primary" | "secondary";
1090
- interface DisambiguationProfile {
1091
- readonly meanings: readonly DisambiguationProfileMeaning[];
1092
- readonly sourceQid: string;
1093
- readonly surface?: string;
1334
+ interface ArchiveNodeLabel {
1335
+ readonly id: string;
1336
+ readonly title: string;
1094
1337
  }
1095
- interface DisambiguationProfileMeaning {
1096
- readonly category?: string;
1097
- readonly information: string;
1098
- readonly name: string;
1099
- readonly priority: DisambiguationMeaningPriority;
1100
- readonly qid: string;
1338
+ interface ArchiveSourceFragment {
1339
+ readonly fragmentId?: number;
1340
+ readonly id: string;
1341
+ readonly preview: string;
1342
+ readonly sentenceCount: number;
1343
+ readonly text: string;
1344
+ readonly wordsCount: number;
1101
1345
  }
1102
- type DisambiguationProfileNormalizer = (input: DisambiguationProfileNormalizerInput) => Promise<DisambiguationProfile>;
1103
- interface DisambiguationProfileNormalizerInput {
1104
- readonly pageQidLinks: readonly DisambiguationLinkedQid[];
1105
- readonly pages: readonly DisambiguationPageText[];
1106
- readonly sourceQid: string;
1107
- readonly surface?: string;
1346
+ interface ArchiveNodeSourceFragment {
1347
+ readonly id: string;
1348
+ readonly text: string;
1349
+ readonly truncated: boolean;
1108
1350
  }
1109
-
1110
- declare class WikipageCache {
1111
- #private;
1112
- constructor(database: Database);
1113
- static open(path?: string): Promise<WikipageCache>;
1114
- close(): Promise<void>;
1115
- getQids(qids: readonly string[], language: string): Promise<ReadonlyMap<string, CachedQidRecord>>;
1116
- putQids(records: readonly CachedQidRecord[], language: string): Promise<void>;
1117
- getDisambiguations(qids: readonly string[], wiki: string): Promise<ReadonlyMap<string, CachedDisambiguationRecord>>;
1118
- putDisambiguations(records: readonly CachedDisambiguationRecord[], wiki: string): Promise<void>;
1351
+ interface ArchiveEvidenceOptions {
1352
+ readonly cursor?: string;
1353
+ readonly limit?: number;
1354
+ readonly order?: ArchiveFindOrder;
1355
+ readonly query?: string;
1356
+ readonly sourceContext?: number;
1119
1357
  }
1120
1358
 
1121
- type GuaranteedRequest = (messages: readonly LLMessage[], index: number, maxRetries: number) => Promise<string | undefined>;
1122
- type GuaranteedLazyRequest = <T>(operation: (request: GuaranteedRequest) => Promise<T>) => Promise<T>;
1123
- type GuaranteedRequestController = GuaranteedRequest & {
1124
- lazy?: GuaranteedLazyRequest;
1125
- };
1359
+ declare function findArchiveObjects(document: ReadonlyDocument, query: string, options?: ArchiveFindOptions): Promise<ArchiveFindResult>;
1360
+ declare function grepArchiveObjects(document: ReadonlyDocument, query: string, options?: ArchiveFindOptions): Promise<ArchiveFindResult>;
1126
1361
 
1127
- interface CreateDisambiguationProfileNormalizerOptions {
1128
- readonly maxMeanings?: number;
1129
- readonly maxRetries?: number;
1130
- readonly request: GuaranteedRequest;
1362
+ declare const TEXT_SENTENCE_KIND: {
1363
+ readonly source: 1;
1364
+ readonly summary: 2;
1365
+ };
1366
+ type TextSentenceKind = (typeof TEXT_SENTENCE_KIND)[keyof typeof TEXT_SENTENCE_KIND];
1367
+ declare const SEARCH_OBJECT_PROPERTY_OWNER_KIND: {
1368
+ readonly chapter: 1;
1369
+ readonly chunk: 2;
1370
+ readonly entity: 3;
1371
+ };
1372
+ type SearchObjectPropertyOwnerKind = (typeof SEARCH_OBJECT_PROPERTY_OWNER_KIND)[keyof typeof SEARCH_OBJECT_PROPERTY_OWNER_KIND];
1373
+ declare const SEARCH_OBJECT_PROPERTY_KIND: {
1374
+ readonly title: 1;
1375
+ readonly label: 1;
1376
+ readonly content: 2;
1377
+ readonly surface: 1;
1378
+ };
1379
+ type SearchObjectPropertyKind = (typeof SEARCH_OBJECT_PROPERTY_KIND)[keyof typeof SEARCH_OBJECT_PROPERTY_KIND];
1380
+ type SearchIndexProgressPhase = "checking" | "clearing" | "collecting" | "finalizing" | "indexing-objects" | "indexing-text";
1381
+ interface SearchIndexProgressEvent {
1382
+ readonly done?: number;
1383
+ readonly phase: SearchIndexProgressPhase;
1384
+ readonly total?: number;
1385
+ readonly unit?: "chapter" | "object" | "sentence";
1131
1386
  }
1132
- declare function createDisambiguationProfileNormalizer(options: CreateDisambiguationProfileNormalizerOptions): DisambiguationProfileNormalizer;
1133
-
1134
- interface RateLimiterOptions {
1135
- readonly concurrency: number;
1136
- readonly minRequestIntervalMs: number;
1387
+ type SearchIndexProgressReporter = (event: SearchIndexProgressEvent) => void | Promise<void>;
1388
+ interface SearchIndexTextHit {
1389
+ readonly archiveId: number;
1390
+ readonly chapterId: number;
1391
+ readonly kind: TextSentenceKind;
1392
+ readonly rank: number;
1393
+ readonly score: number;
1394
+ readonly sentenceIndex: number;
1395
+ readonly wordsCount: number;
1137
1396
  }
1138
- declare class RateLimiter {
1139
- #private;
1140
- constructor(options: RateLimiterOptions);
1141
- use<T>(operation: () => Promise<T>): Promise<T>;
1142
- blockFor(ms: number): void;
1397
+ interface SearchIndexObjectHit {
1398
+ readonly archiveId: number;
1399
+ readonly chapterId?: number;
1400
+ readonly ownerId: string;
1401
+ readonly ownerKind: SearchObjectPropertyOwnerKind;
1402
+ readonly propertyKind: SearchObjectPropertyKind;
1403
+ readonly score: number;
1143
1404
  }
1144
- declare function parseRetryAfterMs(value: string | null): number | undefined;
1405
+ interface ArchiveIndexSettings {
1406
+ readonly ftsEmbedded: boolean;
1407
+ }
1408
+
1409
+ declare function readArchiveIndexSettings(document: ReadonlyDocument): Promise<ArchiveIndexSettings>;
1410
+ declare function setFtsIndexEmbedded(document: Document, embedded: boolean): Promise<void>;
1145
1411
 
1146
1412
  interface WikipageFetchLog {
1147
1413
  readonly filePath: string | undefined;
@@ -1168,1038 +1434,796 @@ interface WikimediaClientOptions {
1168
1434
  readonly retryBaseDelayMs: number;
1169
1435
  readonly retryTimes: number;
1170
1436
  readonly userAgent?: string;
1171
- readonly wiki: string;
1172
- }
1173
- interface WikidataEntityInfo {
1174
- readonly description?: string;
1175
- readonly label?: string;
1176
- readonly qid: string;
1177
- readonly sitelinks: readonly WikidataSitelinkInfo[];
1178
- }
1179
- interface WikidataSitelinkInfo {
1180
- readonly title: string;
1181
- readonly wiki: SupportedWiki;
1182
- }
1183
- interface WikiPageInfo {
1184
- readonly isDisambiguation: boolean;
1185
- readonly pageId?: number;
1186
- readonly title: string;
1187
- readonly wiki: SupportedWiki;
1188
- readonly wikibaseItem?: string;
1189
- }
1190
- interface ParsedDisambiguationPage {
1191
- readonly linkedTitles: readonly string[];
1192
- readonly pageId?: number;
1193
- readonly text: string;
1194
- readonly title: string;
1195
- readonly wiki: SupportedWiki;
1196
- }
1197
- declare class WikimediaClient {
1198
- #private;
1199
- constructor(options: WikimediaClientOptions);
1200
- getEntities(qids: readonly string[]): Promise<ReadonlyMap<string, WikidataEntityInfo>>;
1201
- getPagesByTitles(titles: readonly string[], wiki?: SupportedWiki): Promise<ReadonlyMap<string, WikiPageInfo>>;
1202
- parseDisambiguationPage(title: string, wiki: SupportedWiki): Promise<ParsedDisambiguationPage>;
1203
- }
1204
-
1205
- declare class WikipageResolver {
1206
- #private;
1207
- constructor(input: {
1208
- readonly cache: WikipageCache;
1209
- readonly client: WikimediaClient;
1210
- readonly language: string;
1211
- readonly maxBatchSize: number;
1212
- readonly normalizer: DisambiguationProfileNormalizer | undefined;
1213
- readonly ownsCache: boolean;
1214
- readonly progress: WikipageResolveProgressReporter | undefined;
1215
- readonly wiki: string;
1216
- });
1217
- static open(options?: WikipageResolverOptions): Promise<WikipageResolver>;
1218
- close(): Promise<void>;
1219
- resolveQids(qids: readonly string[]): Promise<readonly QidResolution[]>;
1220
- }
1221
-
1222
- interface WikimatchCandidate {
1223
- readonly hasMoreOptions?: boolean;
1224
- readonly id: string;
1225
- readonly qidOptions: readonly WikimatchQidOption[];
1226
- readonly range: WikimatchTextRange;
1227
- readonly surface: string;
1228
- }
1229
- interface WikimatchSentence {
1230
- readonly id?: string;
1231
- readonly range: WikimatchTextRange;
1232
- readonly text: string;
1233
- }
1234
- interface WikimatchQidOption {
1235
- readonly description?: string;
1236
- readonly disambiguation?: DisambiguationExpansion;
1237
- readonly isDisambiguation?: boolean;
1238
- readonly label?: string;
1239
- readonly qid: string;
1240
- }
1241
- interface WikimatchTextRange {
1242
- readonly end: number;
1243
- readonly start: number;
1244
- }
1245
- interface WikimatchWindow {
1246
- readonly baseOffset: number;
1247
- readonly candidates: readonly WikimatchCandidate[];
1248
- readonly groups: readonly WikimatchConflictGroup[];
1249
- readonly text: string;
1250
- }
1251
- interface WikimatchSurface {
1252
- readonly id: string;
1253
- readonly count: number;
1254
- readonly text: string;
1255
- }
1256
- interface WikimatchConflictGroup {
1257
- readonly candidateIds: readonly string[];
1258
- readonly id: string;
1259
- readonly range: WikimatchTextRange;
1260
- }
1261
- interface BuildWikimatchWindowsOptions {
1262
- readonly candidates: readonly WikimatchCandidate[];
1263
- readonly contextWords: number;
1264
- readonly optionBudget: number;
1265
- readonly text: string;
1266
- }
1267
- interface NarrowWikimatchCandidateOptionsInput {
1268
- readonly candidate: WikimatchCandidate;
1269
- readonly policyPrompt: string;
1270
- readonly text: string;
1271
- }
1272
- interface WikimatchCandidateOptionNarrowingResult {
1273
- readonly candidate: WikimatchCandidate;
1274
- readonly fallback?: WikimatchCandidateOptionNarrowingFallback;
1275
- }
1276
- interface WikimatchCandidateOptionNarrowingFallback {
1277
- readonly issues: readonly string[];
1278
- readonly reason: "guaranteed_json_failed";
1279
- }
1280
- interface WikimatchCandidateOptionNarrowingResponse {
1281
- readonly qids: readonly WikimatchCandidateOptionNarrowingItemOutput[];
1437
+ readonly wiki: string;
1282
1438
  }
1283
- interface WikimatchCandidateOptionNarrowingItemOutput {
1284
- readonly decision: "keep" | "reject";
1439
+ interface WikidataEntityInfo {
1440
+ readonly description?: string;
1441
+ readonly label?: string;
1285
1442
  readonly qid: string;
1443
+ readonly sitelinks: readonly WikidataSitelinkInfo[];
1286
1444
  }
1287
- interface BuildWikimatchSurfaceProtectionInputOptions {
1288
- readonly candidates: readonly WikimatchCandidate[];
1289
- readonly percentile: number;
1290
- readonly text: string;
1291
- }
1292
- interface WikimatchSurfaceProtectionInput {
1293
- readonly policyPrompt: string;
1294
- readonly suspiciousSurfaces: readonly WikimatchSurface[];
1295
- }
1296
- interface WikimatchSurfaceProtectionBuildResult {
1297
- readonly candidates: readonly WikimatchCandidate[];
1298
- readonly suppressedCandidates: readonly WikimatchCandidate[];
1299
- readonly suspiciousSurfaces: readonly WikimatchSurface[];
1445
+ interface WikidataSitelinkInfo {
1446
+ readonly title: string;
1447
+ readonly wiki: SupportedWiki;
1300
1448
  }
1301
- interface WikimatchSurfaceProtectionResult {
1302
- readonly fallback?: WikimatchSurfaceProtectionFallback;
1303
- readonly protectedSurfaces: readonly WikimatchProtectedSurface[];
1449
+ interface WikiPageInfo {
1450
+ readonly isDisambiguation: boolean;
1451
+ readonly pageId?: number;
1452
+ readonly title: string;
1453
+ readonly wiki: SupportedWiki;
1454
+ readonly wikibaseItem?: string;
1304
1455
  }
1305
- interface WikimatchProtectedSurface {
1306
- readonly note?: string;
1307
- readonly surfaceId: string;
1456
+ interface ParsedDisambiguationPage {
1457
+ readonly linkedTitles: readonly string[];
1458
+ readonly pageId?: number;
1308
1459
  readonly text: string;
1460
+ readonly title: string;
1461
+ readonly wiki: SupportedWiki;
1309
1462
  }
1310
- interface WikimatchSurfaceProtectionFallback {
1311
- readonly issues: readonly string[];
1312
- readonly reason: "guaranteed_json_failed";
1463
+
1464
+ declare class WikimediaClient implements WikiClient {
1465
+ #private;
1466
+ constructor(options: WikimediaClientOptions);
1467
+ getEntities(qids: readonly string[]): Promise<ReadonlyMap<string, WikidataEntityInfo>>;
1468
+ getPagesByTitles(titles: readonly string[], wiki?: SupportedWiki): Promise<ReadonlyMap<string, WikiPageInfo>>;
1469
+ parseDisambiguationPage(title: string, wiki: SupportedWiki): Promise<ParsedDisambiguationPage>;
1313
1470
  }
1314
- interface WikimatchProtectedSurfaceOutput {
1315
- readonly note?: string;
1316
- readonly surfaceId: string;
1471
+
1472
+ interface WikipageResolverOptions {
1473
+ readonly cacheDatabasePath?: string;
1474
+ readonly concurrency?: number;
1475
+ readonly fetch?: typeof fetch;
1476
+ readonly language?: string;
1477
+ readonly logDirPath?: string;
1478
+ readonly maxBatchSize?: number;
1479
+ readonly minRequestIntervalMs?: number;
1480
+ readonly normalizer?: DisambiguationProfileNormalizer;
1481
+ readonly progress?: WikipageResolveProgressReporter;
1482
+ readonly retryBaseDelayMs?: number;
1483
+ readonly retryTimes?: number;
1484
+ readonly userAgent?: string;
1485
+ readonly wiki?: string;
1317
1486
  }
1318
- interface WikimatchSurfaceProtectionResponse {
1319
- readonly protectedSurfaces: readonly WikimatchProtectedSurfaceOutput[];
1487
+ interface WikiClient {
1488
+ /** Runtime adapter for reading Wikimedia/Wikidata data; local CLI uses WikimediaClient. */
1489
+ readonly getEntities: (qids: readonly string[]) => Promise<ReadonlyMap<string, WikidataEntityInfo>>;
1490
+ readonly getPagesByTitles: (titles: readonly string[], wiki?: SupportedWiki) => Promise<ReadonlyMap<string, WikiPageInfo>>;
1491
+ readonly parseDisambiguationPage: (title: string, wiki: SupportedWiki) => Promise<ParsedDisambiguationPage>;
1320
1492
  }
1321
- type WikimatchPolicyDecision = "continue" | "never_recall" | "recall" | "skip_this_time";
1322
- interface WikimatchPolicyJudgeInput {
1323
- readonly candidates: readonly WikimatchCandidate[];
1324
- readonly policyPrompt: string;
1325
- readonly window: WikimatchWindow;
1493
+ interface EnrichmentStore {
1494
+ /** Runtime adapter for enrichment cache reads and writes; local CLI uses WikipageCache. */
1495
+ readonly getQids: (qids: readonly string[], language: string) => Promise<ReadonlyMap<string, CachedQidRecord>>;
1496
+ readonly putQids: (records: readonly CachedQidRecord[], language: string) => Promise<void>;
1497
+ readonly getDisambiguations: (qids: readonly string[], wiki: string) => Promise<ReadonlyMap<string, CachedDisambiguationRecord>>;
1498
+ readonly putDisambiguations: (records: readonly CachedDisambiguationRecord[], wiki: string) => Promise<void>;
1326
1499
  }
1327
- interface WikimatchPolicyJudgeResult {
1328
- readonly continuations: readonly WikimatchPolicyContinuation[];
1329
- readonly fallback?: WikimatchPolicyFallback;
1330
- readonly mentions: readonly WikimatchAcceptedMention[];
1331
- readonly policyUpdates: readonly WikimatchPolicyUpdate[];
1500
+ type WikipageResolveProgressDetail = "disambiguation-page" | "entity" | "linked-page" | "page" | "qid";
1501
+ interface WikipageResolveProgress {
1502
+ readonly detail: WikipageResolveProgressDetail;
1503
+ readonly done: number;
1504
+ readonly total: number;
1332
1505
  }
1333
- interface WikimatchAcceptedMention {
1334
- readonly candidateId: string;
1335
- readonly confidence?: number;
1506
+ type WikipageResolveProgressReporter = (event: WikipageResolveProgress) => Promise<void> | void;
1507
+ interface QidResolution {
1508
+ readonly description?: string;
1509
+ readonly disambiguation?: DisambiguationExpansion;
1510
+ readonly disambiguationPages?: readonly DisambiguationPageText[];
1511
+ readonly isDisambiguation: boolean;
1512
+ readonly label?: string;
1336
1513
  readonly qid: string;
1337
- readonly range: WikimatchTextRange;
1338
- readonly note?: string;
1339
- readonly surface: string;
1340
- }
1341
- interface WikimatchPolicyUpdate {
1342
- readonly candidateId: string;
1343
- readonly decision: Exclude<WikimatchPolicyDecision, "recall" | "continue">;
1344
- readonly note?: string;
1345
- readonly qid?: string;
1346
- readonly surface: string;
1347
- }
1348
- interface WikimatchPolicyContinuation {
1349
- readonly candidateIds: readonly string[];
1350
- readonly groupId: string;
1351
- }
1352
- interface WikimatchPolicyFallback {
1353
- readonly issues: readonly string[];
1354
- readonly reason: "guaranteed_json_failed";
1355
- }
1356
- interface WikimatchPolicyDecisionOutput {
1357
- readonly candidateId: string;
1358
- readonly confidence?: number;
1359
- readonly decision: WikimatchPolicyDecision;
1360
- readonly qid?: string;
1361
- }
1362
- interface WikimatchPolicyGroupOutput {
1363
- readonly decisions: readonly WikimatchPolicyDecisionOutput[];
1364
- readonly groupId: string;
1365
- }
1366
- interface WikimatchPolicyResponse {
1367
- readonly groups: readonly WikimatchPolicyGroupOutput[];
1368
- }
1369
-
1370
- interface JudgeWikimatchPolicyOptions extends WikimatchPolicyJudgeInput {
1371
- readonly maxRetries?: number;
1372
- readonly request: GuaranteedRequest;
1373
- }
1374
- declare function judgeWikimatchPolicy(options: JudgeWikimatchPolicyOptions): Promise<WikimatchPolicyJudgeResult>;
1375
- declare function parsePolicyResponse(candidates: readonly WikimatchCandidate[], response: WikimatchPolicyResponse, groups?: readonly WikimatchConflictGroup[]): WikimatchPolicyJudgeResult;
1376
- declare function validatePolicyResponse(candidates: readonly WikimatchCandidate[], response: WikimatchPolicyResponse, groups?: readonly WikimatchConflictGroup[]): readonly string[];
1377
- declare function formatCandidateForPrompt(candidate: WikimatchCandidate, _group?: WikimatchConflictGroup): object;
1378
-
1379
- interface NarrowWikimatchCandidateOptionsOptions extends NarrowWikimatchCandidateOptionsInput {
1380
- readonly maxRetries?: number;
1381
- readonly optionBudget: number;
1382
- readonly request: GuaranteedRequest;
1383
- }
1384
- declare function narrowWikimatchCandidateOptions(options: NarrowWikimatchCandidateOptionsOptions): Promise<WikimatchCandidateOptionNarrowingResult>;
1385
- declare function parseNarrowingResponse(candidate: WikimatchCandidate, response: WikimatchCandidateOptionNarrowingResponse): WikimatchCandidateOptionNarrowingResult;
1386
- declare function validateNarrowingResponse(candidate: WikimatchCandidate, response: WikimatchCandidateOptionNarrowingResponse): readonly string[];
1387
-
1388
- declare function countWikimatchCandidateOptions(candidate: WikimatchCandidate): number;
1389
- declare function countWikimatchQidOption(option: WikimatchQidOption): number;
1390
- declare function listCandidateSelectableQids(candidate: WikimatchCandidate): readonly string[];
1391
- declare function filterCandidateQidOptions(candidate: WikimatchCandidate, allowedQids: ReadonlySet<string>): WikimatchCandidate;
1392
- declare function splitCandidateByOptionBudget(candidate: WikimatchCandidate, optionBudget: number): readonly WikimatchCandidate[];
1393
- declare function sliceCandidateByOptionBudget(candidate: WikimatchCandidate, optionBudget: number, offset: number): {
1394
- readonly candidate: WikimatchCandidate;
1395
- readonly nextOffset?: number;
1396
- };
1397
-
1398
- declare function enrichWikimatchCandidates(candidates: readonly WikimatchCandidate[], options?: {
1399
- readonly progress?: WikipageResolveProgressReporter;
1400
- readonly resolverOptions?: Omit<WikipageResolverOptions, "progress">;
1401
- }): Promise<readonly WikimatchCandidate[]>;
1402
- declare function applyQidResolutions(candidates: readonly WikimatchCandidate[], resolutions: readonly QidResolution[]): readonly WikimatchCandidate[];
1403
-
1404
- interface JudgeWikimatchSurfaceProtectionOptions extends WikimatchSurfaceProtectionInput {
1405
- readonly maxRetries?: number;
1406
- readonly request: GuaranteedRequest;
1514
+ readonly sitelink?: WikipageSitelink;
1515
+ readonly sitelinks?: readonly WikipageSitelink[];
1407
1516
  }
1408
- declare function judgeWikimatchSurfaceProtection(options: JudgeWikimatchSurfaceProtectionOptions): Promise<WikimatchSurfaceProtectionResult>;
1409
- declare function parseSurfaceProtectionResponse(surfaces: readonly WikimatchSurface[], response: WikimatchSurfaceProtectionResponse): WikimatchSurfaceProtectionResult;
1410
- declare function validateSurfaceProtectionResponse(surfaces: readonly WikimatchSurface[], response: WikimatchSurfaceProtectionResponse): readonly string[];
1411
-
1412
- declare function buildWikimatchSurfaceProtectionInput(options: BuildWikimatchSurfaceProtectionInputOptions): WikimatchSurfaceProtectionBuildResult;
1413
-
1414
- interface SuppressContainedRangeInput {
1415
- readonly range: {
1416
- readonly end: number;
1417
- readonly start: number;
1418
- };
1517
+ interface WikipageSitelink {
1518
+ readonly title: string;
1519
+ readonly wiki: string;
1419
1520
  }
1420
- declare function suppressContainedRanges<T extends SuppressContainedRangeInput>(items: readonly T[]): readonly T[];
1421
-
1422
- interface MatchWikispineSentenceCandidatesOptions {
1423
- readonly command?: string;
1424
- readonly dataDir?: string;
1425
- readonly endpoint?: string;
1426
- readonly fetch?: typeof fetch;
1427
- readonly includeDisambiguation?: boolean;
1428
- readonly maxCandidatesPerSurface?: number;
1429
- readonly onProgress?: (progress: WikispineMatchProgress) => Promise<void> | void;
1430
- readonly provider?: WikispineProvider;
1431
- readonly sentences: readonly WikimatchSentence[];
1521
+ interface DisambiguationExpansion {
1522
+ readonly checkedAt: string;
1523
+ readonly disambiguationQid: string;
1524
+ readonly linkedQids: readonly DisambiguationLinkedQid[];
1525
+ readonly pages: readonly DisambiguationPageText[];
1526
+ readonly profile?: DisambiguationProfile;
1432
1527
  }
1433
- type WikispineProvider = "cli" | "fetch";
1434
- interface WikispineMatchProgress {
1435
- readonly coveredRangeEnd: number;
1528
+ interface DisambiguationPageText {
1529
+ readonly linkedQids: readonly DisambiguationLinkedQid[];
1530
+ readonly pageId?: number;
1531
+ readonly text: string;
1532
+ readonly title: string;
1533
+ readonly wiki: "enwiki" | "zhwiki";
1436
1534
  }
1437
- interface TestWikispineRuntimeOptions {
1438
- readonly command?: string;
1439
- readonly dataDir?: string;
1440
- readonly endpoint?: string;
1441
- readonly fetch?: typeof fetch;
1442
- readonly provider?: WikispineProvider;
1535
+ interface DisambiguationLinkedQid {
1536
+ readonly qid: string;
1537
+ readonly title: string;
1443
1538
  }
1444
- interface WikispineRuntimeTestResult {
1445
- readonly durationMs: number;
1446
- readonly metadata?: WikispineMetadata;
1447
- readonly ok: true;
1448
- readonly provider: WikispineProvider;
1539
+ interface CachedQidRecord {
1540
+ readonly checkedAt: string;
1541
+ readonly description?: string;
1542
+ readonly label?: string;
1543
+ readonly qid: string;
1544
+ readonly sitelinks: readonly CachedPageRecord[];
1545
+ readonly updatedAt: string;
1449
1546
  }
1450
- interface WikispineMetadata {
1451
- readonly automaton_shard_count: number;
1452
- readonly format: string;
1453
- readonly qid_count: number;
1454
- readonly surface_count: number;
1455
- readonly surface_normalization: string;
1547
+ interface CachedDisambiguationRecord {
1548
+ readonly checkedAt: string;
1549
+ readonly disambiguationQid: string;
1550
+ readonly pages: readonly DisambiguationPageText[];
1551
+ readonly profileError?: DisambiguationProfileError;
1552
+ readonly profile?: DisambiguationProfile;
1456
1553
  }
1457
- declare const DEFAULT_WIKISPINE_FETCH_ENDPOINT = "https://wikispi-service-cxbfjlteab.cn-hangzhou.fcapp.run";
1458
- declare function matchWikispineSentenceCandidates(options: MatchWikispineSentenceCandidatesOptions): Promise<readonly WikimatchCandidate[]>;
1459
- declare function testWikispineRuntime(options: TestWikispineRuntimeOptions): Promise<WikispineRuntimeTestResult>;
1460
-
1461
- declare function buildWikimatchWindows(options: BuildWikimatchWindowsOptions): readonly WikimatchWindow[];
1462
-
1463
- interface WordBoundary {
1464
- readonly end: number;
1465
- readonly start: number;
1554
+ interface DisambiguationProfileError {
1555
+ readonly failedAt: string;
1556
+ readonly message: string;
1557
+ readonly retryAfter: string;
1466
1558
  }
1467
- declare function listWordBoundaries(text: string): readonly WordBoundary[];
1468
- declare function expandRangeByWords(input: {
1469
- readonly rangeEnd: number;
1470
- readonly rangeStart: number;
1471
- readonly text: string;
1472
- readonly words: number;
1473
- }): {
1474
- readonly end: number;
1475
- readonly start: number;
1476
- };
1477
-
1478
- type WikiGraphSamplingConfig = SamplingScopeConfig<WikiGraphScope>;
1479
- declare function createDefaultWikiGraphSampling(input?: {
1480
- readonly temperature?: TemperatureSetting;
1481
- readonly topP?: TemperatureSetting;
1482
- }): WikiGraphSamplingConfig;
1483
-
1484
- type WikiGraphOperation = "digest-epub" | "digest-markdown" | "digest-text-stream" | "digest-txt";
1485
- interface SerialDiscoveryItem {
1486
- readonly id: number;
1487
- readonly fragments?: number | undefined;
1488
- readonly title?: string | undefined;
1489
- readonly words: number;
1559
+ interface CachedPageRecord {
1560
+ readonly isDisambiguation: boolean;
1561
+ readonly pageId?: number;
1562
+ readonly title: string;
1563
+ readonly wiki: "enwiki" | "zhwiki";
1490
1564
  }
1491
- interface SerialsDiscoveredEvent {
1492
- readonly type: "serials-discovered";
1493
- readonly available: boolean;
1494
- readonly serials: readonly SerialDiscoveryItem[];
1565
+ type DisambiguationMeaningPriority = "other" | "primary" | "secondary";
1566
+ interface DisambiguationProfile {
1567
+ readonly meanings: readonly DisambiguationProfileMeaning[];
1568
+ readonly sourceQid: string;
1569
+ readonly surface?: string;
1495
1570
  }
1496
- interface SerialProgressEvent {
1497
- readonly type: "serial-progress";
1498
- readonly id: number;
1499
- readonly completedWords: number;
1500
- readonly completedFragments: number;
1571
+ interface DisambiguationProfileMeaning {
1572
+ readonly category?: string;
1573
+ readonly information: string;
1574
+ readonly name: string;
1575
+ readonly priority: DisambiguationMeaningPriority;
1576
+ readonly qid: string;
1501
1577
  }
1502
- interface DigestProgressEvent {
1503
- readonly type: "digest-progress";
1504
- readonly completedWords: number;
1505
- readonly totalWords: number;
1578
+ type DisambiguationProfileNormalizer = (input: DisambiguationProfileNormalizerInput) => Promise<DisambiguationProfile>;
1579
+ interface DisambiguationProfileNormalizerInput {
1580
+ readonly pageQidLinks: readonly DisambiguationLinkedQid[];
1581
+ readonly pages: readonly DisambiguationPageText[];
1582
+ readonly sourceQid: string;
1583
+ readonly surface?: string;
1506
1584
  }
1507
- type WikiGraphProgressEventType = WikiGraphProgressEvent["type"];
1508
- type WikiGraphProgressEvent = SerialsDiscoveredEvent | SerialProgressEvent | DigestProgressEvent;
1509
- type WikiGraphProgressCallback = (event: WikiGraphProgressEvent) => void | Promise<void>;
1510
1585
 
1511
- type TextStream = AsyncIterable<string> | Iterable<string>;
1586
+ declare class WikipageCache implements EnrichmentStore {
1587
+ #private;
1588
+ constructor(database: Database);
1589
+ static open(path?: string): Promise<WikipageCache>;
1590
+ close(): Promise<void>;
1591
+ getQids(qids: readonly string[], language: string): Promise<ReadonlyMap<string, CachedQidRecord>>;
1592
+ putQids(records: readonly CachedQidRecord[], language: string): Promise<void>;
1593
+ getDisambiguations(qids: readonly string[], wiki: string): Promise<ReadonlyMap<string, CachedDisambiguationRecord>>;
1594
+ putDisambiguations(records: readonly CachedDisambiguationRecord[], wiki: string): Promise<void>;
1595
+ }
1512
1596
 
1513
- type ReaderTextStream = TextStream;
1597
+ type GuaranteedRequest = (messages: readonly LLMessage[], index: number, maxRetries: number) => Promise<string | undefined>;
1598
+ type GuaranteedLazyRequest = <T>(operation: (request: GuaranteedRequest) => Promise<T>) => Promise<T>;
1599
+ type GuaranteedRequestController = GuaranteedRequest & {
1600
+ lazy?: GuaranteedLazyRequest;
1601
+ };
1514
1602
 
1515
- interface SerialProgressSink {
1516
- begin?(input?: {
1517
- readonly fragments: number;
1518
- readonly words: number;
1519
- }): Promise<void>;
1520
- advance(wordsCount: number): Promise<void>;
1521
- complete(finalWordsCount?: number): Promise<void>;
1603
+ interface CreateDisambiguationProfileNormalizerOptions {
1604
+ readonly maxMeanings?: number;
1605
+ readonly maxRetries?: number;
1606
+ readonly request: GuaranteedRequest;
1522
1607
  }
1608
+ declare function createDisambiguationProfileNormalizer(options: CreateDisambiguationProfileNormalizerOptions): DisambiguationProfileNormalizer;
1523
1609
 
1524
- declare const CHAPTER_STAGES: readonly ["planned", "sourced", "graphed", "summarized"];
1525
- type ChapterStage = (typeof CHAPTER_STAGES)[number];
1526
- interface ChapterEntry {
1527
- readonly chapterId: number;
1528
- readonly childCount: number;
1529
- readonly depth: number;
1530
- readonly documentOrder: number;
1531
- readonly fragmentCount: number;
1532
- readonly stage: ChapterStage;
1533
- readonly title: string | null;
1534
- readonly tocPath: readonly string[];
1535
- readonly words: number;
1536
- }
1537
- interface ChapterDetails extends ChapterEntry {
1538
- readonly graphReady: boolean;
1539
- readonly hasSummary: boolean;
1540
- readonly words: number;
1541
- }
1542
- interface ChapterTree {
1543
- readonly chapters: readonly ChapterTreeNode[];
1544
- }
1545
- interface ChapterTreeNode {
1546
- readonly children: readonly ChapterTreeNode[];
1547
- readonly id: number;
1548
- readonly title: string | null;
1549
- }
1550
- interface ChapterTreeInput {
1551
- readonly chapters: readonly ChapterTreeInputNode[];
1610
+ interface RateLimiterOptions {
1611
+ readonly concurrency: number;
1612
+ readonly minRequestIntervalMs: number;
1552
1613
  }
1553
- interface ChapterTreeInputNode {
1554
- readonly children: readonly ChapterTreeInputNode[];
1555
- readonly id: number;
1556
- readonly title?: string | null | undefined;
1614
+ declare class RateLimiter {
1615
+ #private;
1616
+ constructor(options: RateLimiterOptions);
1617
+ use<T>(operation: () => Promise<T>): Promise<T>;
1618
+ blockFor(ms: number): void;
1557
1619
  }
1558
- interface ChapterTreeApplyResult {
1559
- readonly changed: boolean;
1560
- readonly moved: readonly ChapterTreeMoveChange[];
1561
- readonly renamed: readonly ChapterTreeTitleChange[];
1562
- readonly unchanged: number;
1620
+ declare function parseRetryAfterMs(value: string | null): number | undefined;
1621
+
1622
+ declare class WikipageResolver {
1623
+ #private;
1624
+ constructor(input: {
1625
+ readonly client: WikiClient;
1626
+ readonly language: string;
1627
+ readonly maxBatchSize: number;
1628
+ readonly normalizer: DisambiguationProfileNormalizer | undefined;
1629
+ readonly ownsStore?: boolean;
1630
+ readonly progress: WikipageResolveProgressReporter | undefined;
1631
+ readonly store: EnrichmentStore;
1632
+ readonly wiki: string;
1633
+ });
1634
+ static open(options?: WikipageResolverOptions): Promise<WikipageResolver>;
1635
+ close(): Promise<void>;
1636
+ resolveQids(qids: readonly string[]): Promise<readonly QidResolution[]>;
1563
1637
  }
1564
- interface ChapterTreeMoveChange {
1565
- readonly chapterId: number;
1566
- readonly newIndex: number;
1567
- readonly newParentChapterId: number | null;
1568
- readonly newPath: readonly string[];
1569
- readonly oldIndex: number;
1570
- readonly oldParentChapterId: number | null;
1571
- readonly oldPath: readonly string[];
1638
+
1639
+ interface ArchivePageOptions {
1640
+ readonly backlinks?: boolean;
1641
+ readonly evidenceLimit?: number;
1642
+ readonly order?: ArchiveFindOrder;
1643
+ readonly sourceContext?: number;
1644
+ readonly wikipageResolverOptions?: WikipageResolverOptions;
1572
1645
  }
1573
- interface ChapterTreeTitleChange {
1574
- readonly chapterId: number;
1575
- readonly newTitle: string | null;
1576
- readonly oldTitle: string | null;
1646
+ declare function readArchiveText(document: ReadonlyDocument, id: string): Promise<string>;
1647
+ declare function readArchivePage(document: ReadonlyDocument, id: string, options?: ArchivePageOptions): Promise<ArchivePage>;
1648
+
1649
+ declare function listArchiveLinks(document: ReadonlyDocument, id: string, direction: "backlinks" | "links"): Promise<readonly GraphNeighbor[]>;
1650
+ declare function listAllArchiveLinks(document: ReadonlyDocument, id: string): Promise<readonly GraphNeighbor[]>;
1651
+ declare function listRelatedArchiveObjects(document: ReadonlyDocument, id: string, options?: ArchiveRelatedOptions): Promise<ArchiveRelatedResult>;
1652
+
1653
+ declare function formatChapterId(chapterId: number): string;
1654
+ declare function formatEdgeId(edge: ReadingEdgeRecord): string;
1655
+ declare function formatNodeId(nodeId: number): string;
1656
+ declare function formatSummaryId(chapterId: number): string;
1657
+
1658
+ declare function rebuildArchiveSearchIndex(document: Document, progress?: SearchIndexProgressReporter): Promise<void>;
1659
+ declare function isArchiveSearchIndexCurrent(document: ReadonlyDocument): Promise<boolean>;
1660
+
1661
+ declare function getArchiveIndex(document: ReadonlyDocument): Promise<ArchiveIndex>;
1662
+ declare function listArchiveObjects(document: ReadonlyDocument, kind: ArchiveListKind): Promise<readonly ArchiveListItem[]>;
1663
+ declare function listArchiveCollection(document: ReadonlyDocument, options?: ArchiveCollectionOptions): Promise<ArchiveCollectionResult>;
1664
+
1665
+ declare function listArchiveEvidence(document: ReadonlyDocument, uri: string, options?: ArchiveEvidenceOptions): Promise<ArchiveEvidence>;
1666
+
1667
+ declare function packArchiveContext(document: ReadonlyDocument, id: string, budget: number): Promise<ArchivePack>;
1668
+
1669
+ declare function findWikiGraphLibraryObjects(target: ParsedWikiGraphLibraryUri, query: string, options?: ArchiveFindOptions): Promise<ArchiveFindResult>;
1670
+ declare function findWikiGraphLibraryArchiveMembers(target: ParsedWikiGraphLibraryUri, query: string, options?: ArchiveFindOptions): Promise<ArchiveFindResult>;
1671
+ declare function listWikiGraphLibraryObjects(target: ParsedWikiGraphLibraryUri, options?: ArchiveCollectionOptions): Promise<ArchiveCollectionResult>;
1672
+ declare function listWikiGraphLibraryArchiveMembers(target: ParsedWikiGraphLibraryUri, options?: ArchiveCollectionOptions): Promise<ArchiveCollectionResult>;
1673
+ declare function readWikiGraphLibraryPage(target: ParsedWikiGraphLibraryUri, objectUri: string, options?: Parameters<typeof readArchivePage>[2]): Promise<ArchivePage>;
1674
+ declare function listWikiGraphLibraryEvidence(target: ParsedWikiGraphLibraryUri, objectUri: string, options?: ArchiveEvidenceOptions): Promise<ArchiveEvidence>;
1675
+ declare function listRelatedWikiGraphLibraryObjects(target: ParsedWikiGraphLibraryUri, objectUri: string, options?: ArchiveRelatedOptions): Promise<ArchiveRelatedResult>;
1676
+ declare function packWikiGraphLibraryContext(target: ParsedWikiGraphLibraryUri, objectUri: string, budget: number): Promise<ArchivePack>;
1677
+ declare function resolveWikiGraphLibraryQueryTargetById(libraryId: number): Promise<ParsedWikiGraphLibraryUri>;
1678
+
1679
+ type WikiGraphLibraryIndexStatus = "current" | "dirty" | "disabled" | "missing";
1680
+ interface WikiGraphLibraryIndexSource {
1681
+ readonly archiveId: number;
1682
+ readonly archiveUri: string;
1683
+ readonly exists: boolean;
1684
+ readonly lastSeenMutationToken?: string;
1685
+ readonly relativePath: string;
1686
+ readonly status: string;
1687
+ }
1688
+ interface WikiGraphLibraryIndexState {
1689
+ readonly enabled: boolean;
1690
+ readonly fingerprint?: string;
1691
+ readonly sourceFingerprint: string;
1692
+ readonly sources: readonly WikiGraphLibraryIndexSource[];
1693
+ readonly status: WikiGraphLibraryIndexStatus;
1694
+ }
1695
+ interface WikiGraphLibraryIndexQueryResult {
1696
+ readonly objectHits: readonly WikiGraphLibraryIndexObjectHit[];
1697
+ readonly terms: readonly string[];
1698
+ readonly textHits: readonly WikiGraphLibraryIndexTextHit[];
1577
1699
  }
1578
- interface MoveChapterOptions {
1579
- readonly afterChapterId?: number;
1580
- readonly beforeChapterId?: number;
1581
- readonly first?: boolean;
1582
- readonly last?: boolean;
1583
- readonly parentChapterId?: number;
1584
- readonly root?: boolean;
1700
+ interface WikiGraphLibraryIndexQueryOptions {
1701
+ readonly chapters?: readonly number[];
1702
+ readonly match?: ArchiveFindMatch;
1703
+ readonly objectHitLimit?: number;
1704
+ readonly textAfter?: {
1705
+ readonly archiveId: number;
1706
+ readonly chapterId: number;
1707
+ readonly kind: TextSentenceKind;
1708
+ readonly rank: number;
1709
+ readonly sentenceIndex: number;
1710
+ };
1711
+ readonly textHitLimit?: number;
1712
+ readonly types?: readonly ArchiveFindObjectType[] | null;
1585
1713
  }
1586
- interface AdvanceChapterStagesOptions {
1587
- readonly chapterId?: number;
1588
- readonly extractionPrompt: string;
1589
- readonly llm: LLM<WikiGraphScope>;
1590
- readonly logDirPath?: string;
1591
- readonly onProgress?: AdvanceChapterStagesProgressCallback;
1592
- readonly targetStage: ChapterStage;
1593
- readonly userLanguage?: Language;
1714
+ type WikiGraphLibraryIndexObjectHit = SearchIndexObjectHit & {
1715
+ readonly archiveUri: string;
1716
+ readonly libraryArchiveUri: string;
1717
+ };
1718
+ type WikiGraphLibraryIndexTextHit = SearchIndexTextHit & {
1719
+ readonly archiveUri: string;
1720
+ readonly libraryArchiveUri: string;
1721
+ };
1722
+ declare function readWikiGraphLibraryIndexState(target: ParsedWikiGraphLibraryUri): Promise<WikiGraphLibraryIndexState>;
1723
+ declare function rebuildWikiGraphLibraryIndex(target: ParsedWikiGraphLibraryUri, progress?: SearchIndexProgressReporter): Promise<WikiGraphLibraryIndexState>;
1724
+ declare function disableWikiGraphLibraryIndex(target: ParsedWikiGraphLibraryUri): Promise<WikiGraphLibraryIndexState>;
1725
+ declare function markWikiGraphLibraryIndexDirty(targetOrLibrary: ParsedWikiGraphLibraryUri | WikiGraphLibraryRecord): Promise<void>;
1726
+ declare function queryWikiGraphLibrarySearchIndex(target: ParsedWikiGraphLibraryUri, query: string, options?: WikiGraphLibraryIndexQueryOptions): Promise<WikiGraphLibraryIndexQueryResult | undefined>;
1727
+ declare function listWikiGraphLibraryIndexArchiveIdsForObject(target: ParsedWikiGraphLibraryUri, objectUri: string): Promise<readonly number[]>;
1728
+
1729
+ declare function resolveWikiGraphHomeDirectoryPath(): string;
1730
+ declare function withWikiGraphRuntimeStateDirectoryPath<T>(path: string | undefined, operation: () => Promise<T> | T): Promise<T>;
1731
+ /**
1732
+ * @deprecated Runtime state overrides are no longer read from process-style
1733
+ * environment objects. Use `withWikiGraphRuntimeStateDirectoryPath` instead.
1734
+ */
1735
+ declare function withWikiGraphRuntimeEnvironment<T>(_environment: NodeJS.ProcessEnv, operation: () => Promise<T> | T): Promise<T>;
1736
+ declare function resolveWikiGraphCoreDatabasePath(): string;
1737
+
1738
+ type WikiGraphTempCategory = "archive-open" | "archive-write" | "cli-output" | "sdpub-upgrade" | "stdin-create" | "url-create";
1739
+ declare function resolveWikiGraphStateRootPath(): string;
1740
+ declare function createWikiGraphTempDirectory(category: WikiGraphTempCategory): Promise<string>;
1741
+
1742
+ declare const EVIDENCE_SELECTION_PROMPT_FRAGMENT: string;
1743
+ declare const EVIDENCE_SELECTION_JSON_SHAPE: readonly [{
1744
+ readonly quote: "exact short source quote copied from the selected sentence";
1745
+ readonly sentence_id: "sentence id from the source context, such as S1";
1746
+ }];
1747
+ declare function formatEvidenceSelectionChoicePrompt(input: {
1748
+ readonly evidenceLabel: string;
1749
+ readonly generatedEvidence: unknown;
1750
+ readonly candidates: readonly {
1751
+ readonly nextText: string;
1752
+ readonly occurrenceId: string;
1753
+ readonly prevText: string;
1754
+ readonly score: number;
1755
+ readonly text: string;
1756
+ }[];
1757
+ }): string;
1758
+
1759
+ type EvidenceQuoteMatchStrategy = "empty" | "exact" | "normalized_exact" | "normalized_substring" | "fuzzy_window";
1760
+ interface EvidenceQuoteScore {
1761
+ readonly exactRaw: boolean;
1762
+ readonly exactNormalized: boolean;
1763
+ readonly exactSubstring: boolean;
1764
+ readonly matchEnd: number;
1765
+ readonly matchStart: number;
1766
+ readonly normalizedQuote: string;
1767
+ readonly normalizedSentence: string;
1768
+ readonly score: number;
1769
+ readonly strategy: EvidenceQuoteMatchStrategy;
1594
1770
  }
1595
- interface AdvanceChapterStagesProgressState {
1596
- readonly graphWords: number;
1597
- readonly summaryWords: number;
1598
- readonly totalGraphWords: number;
1599
- readonly totalSummaryWords: number;
1771
+ declare function normalizeEvidenceDisplayText(text: string): string;
1772
+ declare function normalizeEvidenceText(text: string): string;
1773
+ declare function scoreEvidenceQuote(input: {
1774
+ readonly quote: string;
1775
+ readonly sentence: string;
1776
+ }): EvidenceQuoteScore;
1777
+
1778
+ type EvidenceSentenceId = readonly [number, number];
1779
+ interface EvidenceSelectionSentence {
1780
+ readonly id: string;
1781
+ readonly sentenceId: EvidenceSentenceId;
1782
+ readonly text: string;
1600
1783
  }
1601
- type AdvanceChapterStagesProgressCallback = (event: AdvanceChapterStagesProgressEvent) => void | Promise<void>;
1602
- type AdvanceChapterStagesProgressEvent = {
1603
- readonly type: "selected";
1604
- readonly state: AdvanceChapterStagesProgressState;
1605
- readonly targetStage: ChapterStage;
1606
- readonly totalChapters: number;
1607
- } | {
1608
- readonly type: "skipped";
1609
- readonly chapter: ChapterEntry;
1610
- readonly reason: "planned";
1611
- readonly targetStage: ChapterStage;
1612
- } | {
1613
- readonly type: "progress";
1614
- readonly state: AdvanceChapterStagesProgressState;
1615
- readonly targetStage: ChapterStage;
1616
- } | {
1617
- readonly type: "started";
1618
- readonly chapter: ChapterEntry;
1619
- readonly step: "graph" | "summary";
1620
- readonly targetStage: ChapterStage;
1621
- } | {
1622
- readonly type: "completed";
1623
- readonly chapter: ChapterEntry;
1624
- readonly step: "graph" | "summary";
1625
- readonly targetStage: ChapterStage;
1626
- };
1627
- interface AdvanceChapterStagesResult {
1628
- readonly advanced: readonly ChapterEntry[];
1629
- readonly pending: readonly ChapterEntry[];
1630
- readonly skipped: readonly ChapterEntry[];
1784
+ interface EvidenceSelection {
1785
+ readonly quote?: string;
1786
+ readonly sentence_id?: string;
1631
1787
  }
1632
- interface AddChapterOptions {
1633
- readonly parentChapterId?: number;
1634
- readonly title?: string | null | undefined;
1788
+ type EvidenceSelectionList = EvidenceSelection | readonly EvidenceSelection[];
1789
+ interface EvidenceSelectionCandidate {
1790
+ readonly exactNormalized: boolean;
1791
+ readonly exactRaw: boolean;
1792
+ readonly exactSubstring: boolean;
1793
+ readonly index: number;
1794
+ readonly nextText: string;
1795
+ readonly occurrenceId: string;
1796
+ readonly prevText: string;
1797
+ readonly score: number;
1798
+ readonly sentence: EvidenceSelectionSentence;
1799
+ readonly strategy: string;
1635
1800
  }
1636
- declare function parseChapterTreeInput(input: unknown): ChapterTreeInput;
1637
- interface GenerateChapterGraphOptions {
1638
- readonly extractionPrompt: string;
1639
- readonly llm: LLM<WikiGraphScope>;
1640
- readonly logDirPath?: string;
1641
- readonly progressTracker?: SerialProgressSink;
1642
- readonly userLanguage?: Language;
1801
+ interface EvidenceSelectionResolution {
1802
+ readonly candidate: EvidenceSelectionCandidate;
1803
+ readonly confidence: number;
1804
+ readonly sentenceIds: readonly EvidenceSentenceId[];
1805
+ readonly strategy: string;
1643
1806
  }
1644
- interface GenerateChapterSummaryOptions {
1645
- readonly llm: LLM<WikiGraphScope>;
1646
- readonly logDirPath?: string;
1647
- readonly userLanguage?: Language;
1807
+ interface EvidenceSelectionFailure {
1808
+ readonly candidates: readonly EvidenceSelectionCandidate[];
1809
+ readonly code: "ambiguous" | "invalid" | "low_confidence" | "missing_sentence" | "none";
1810
+ readonly message: string;
1648
1811
  }
1649
- declare function advanceChapterStages(document: Document, options: AdvanceChapterStagesOptions): Promise<AdvanceChapterStagesResult>;
1650
- declare function addChapter(document: Document, options: AddChapterOptions): Promise<ChapterDetails>;
1651
- declare function generateChapterGraph(document: Document, chapterId: number, options: GenerateChapterGraphOptions): Promise<ChapterDetails>;
1652
- declare function generateChapterSummary(document: Document, chapterId: number, options: GenerateChapterSummaryOptions): Promise<ChapterDetails>;
1653
- declare function getChapterDetails(document: ReadonlyDocument, chapterId: number): Promise<ChapterDetails>;
1654
- declare function listChapters(document: ReadonlyDocument): Promise<readonly ChapterEntry[]>;
1655
- declare function getChapterTree(document: ReadonlyDocument): Promise<ChapterTree>;
1656
- declare function applyChapterTree(document: Document, tree: ChapterTreeInput, options?: {
1657
- readonly dryRun?: boolean;
1658
- }): Promise<ChapterTreeApplyResult>;
1659
- declare function moveChapter(document: Document, chapterId: number, options: MoveChapterOptions): Promise<ChapterDetails>;
1660
- declare function removeChapter(document: Document, chapterId: number, options?: {
1661
- readonly recursive?: boolean;
1662
- }): Promise<void>;
1663
- declare function resetChapter(document: Document, chapterId: number, stage: Exclude<ChapterStage, "summarized">): Promise<ChapterDetails>;
1664
- declare function setChapterSource(document: Document, chapterId: number, stream: ReaderTextStream): Promise<ChapterDetails>;
1665
- declare function setChapterSummary(document: Document, chapterId: number, summary: string): Promise<ChapterDetails>;
1666
- declare function setChapterTitle(document: Document, chapterId: number, title: string | null | undefined): Promise<ChapterDetails>;
1667
1812
 
1668
- interface WikiGraphSerialEntry {
1669
- readonly fragmentCount: number;
1670
- readonly serialId: number;
1671
- readonly title: string | null;
1672
- readonly tocPath: readonly string[];
1673
- }
1813
+ declare function resolveEvidenceSelection(input: {
1814
+ readonly evidence: EvidenceSelection;
1815
+ readonly sentences: readonly EvidenceSelectionSentence[];
1816
+ }): readonly [
1817
+ resolution: EvidenceSelectionResolution | undefined,
1818
+ failure: EvidenceSelectionFailure | undefined
1819
+ ];
1820
+ declare function resolveEvidenceSelectionList(input: {
1821
+ readonly evidence: EvidenceSelectionList;
1822
+ readonly sentences: readonly EvidenceSelectionSentence[];
1823
+ }): readonly [
1824
+ resolution: EvidenceSelectionResolution | undefined,
1825
+ failure: EvidenceSelectionFailure | undefined
1826
+ ];
1827
+ declare function rankEvidenceQuote(quote: string, sentences: readonly EvidenceSelectionSentence[]): EvidenceSelectionCandidate[];
1674
1828
 
1675
- declare class WikiGraphArchive {
1676
- #private;
1677
- constructor(document: ReadonlyDocument, documentDirectoryPath: string);
1678
- exportEpub(path: string): Promise<void>;
1679
- exportText(path: string): Promise<void>;
1680
- readCover(): Promise<SourceAsset | undefined>;
1681
- readMeta(): Promise<BookMeta | undefined>;
1682
- readToc(): Promise<TocFile | undefined>;
1683
- readArchiveFormatVersion(): Promise<number>;
1684
- readChapterStage(serialId: number): Promise<ChapterStage>;
1685
- listSerials(): Promise<readonly WikiGraphSerialEntry[]>;
1686
- readSerialSummary(serialId: number): Promise<string>;
1687
- saveAs(path: string): Promise<void>;
1829
+ interface WikimatchCandidate {
1830
+ readonly hasMoreOptions?: boolean;
1831
+ readonly id: string;
1832
+ readonly qidOptions: readonly WikimatchQidOption[];
1833
+ readonly range: WikimatchTextRange;
1834
+ readonly surface: string;
1688
1835
  }
1689
-
1690
- interface DigestDocumentSessionOptions {
1691
- readonly documentDirPath?: string;
1836
+ interface WikimatchSentence {
1837
+ readonly id?: string;
1838
+ readonly range: WikimatchTextRange;
1839
+ readonly text: string;
1692
1840
  }
1693
-
1694
- interface WikiGraphLLMOptions {
1695
- readonly cacheDirPath?: string;
1696
- readonly concurrent?: number;
1697
- readonly logDirPath?: string;
1698
- readonly model: LanguageModel;
1699
- readonly retryIntervalSeconds?: number;
1700
- readonly retryTimes?: number;
1701
- readonly stream?: boolean;
1702
- readonly temperature?: number | readonly number[];
1703
- readonly timeout?: number;
1704
- readonly topP?: number | readonly number[];
1841
+ interface WikimatchQidOption {
1842
+ readonly description?: string;
1843
+ readonly disambiguation?: DisambiguationExpansion;
1844
+ readonly isDisambiguation?: boolean;
1845
+ readonly label?: string;
1846
+ readonly qid: string;
1705
1847
  }
1706
- interface WikiGraphOptions {
1707
- readonly debugLogDirPath?: string;
1708
- readonly llm?: LanguageModel | WikiGraphLLMOptions;
1709
- readonly verbose?: boolean;
1848
+ interface WikimatchTextRange {
1849
+ readonly end: number;
1850
+ readonly start: number;
1710
1851
  }
1711
- type WikiGraphOpenSessionOptions = DigestDocumentSessionOptions;
1712
- interface WikiGraphSourceSessionOptions extends DigestDocumentSessionOptions {
1713
- readonly extractionPrompt?: string;
1714
- readonly onProgress?: WikiGraphProgressCallback;
1715
- readonly path: string;
1716
- readonly targetStage?: ChapterStage;
1717
- readonly userLanguage?: Language;
1852
+ interface WikimatchWindow {
1853
+ readonly baseOffset: number;
1854
+ readonly candidates: readonly WikimatchCandidate[];
1855
+ readonly groups: readonly WikimatchConflictGroup[];
1856
+ readonly text: string;
1718
1857
  }
1719
- interface WikiGraphTextStreamSessionOptions extends DigestDocumentSessionOptions {
1720
- readonly bookLanguage?: string | null;
1721
- readonly extractionPrompt?: string;
1722
- readonly onProgress?: WikiGraphProgressCallback;
1723
- readonly sourceFormat?: "markdown" | "txt";
1724
- readonly stream: AsyncIterable<string> | Iterable<string>;
1725
- readonly targetStage?: ChapterStage;
1726
- readonly title?: string | null;
1727
- readonly userLanguage?: Language;
1858
+ interface WikimatchConflictGroup {
1859
+ readonly candidateIds: readonly string[];
1860
+ readonly id: string;
1861
+ readonly range: WikimatchTextRange;
1728
1862
  }
1729
- declare class WikiGraph {
1730
- #private;
1731
- constructor(options: WikiGraphOptions);
1732
- digestEpubSession<T>(options: WikiGraphSourceSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
1733
- digestMarkdownSession<T>(options: WikiGraphSourceSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
1734
- digestTextStreamSession<T>(options: WikiGraphTextStreamSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
1735
- digestTxtSession<T>(options: WikiGraphSourceSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
1736
- openSession<T>(path: string, operation: (digest: WikiGraphArchive) => Promise<T> | T, options?: WikiGraphOpenSessionOptions): Promise<T>;
1863
+ interface BuildWikimatchWindowsOptions {
1864
+ readonly candidates: readonly WikimatchCandidate[];
1865
+ readonly contextWords: number;
1866
+ readonly optionBudget: number;
1867
+ readonly text: string;
1737
1868
  }
1738
-
1739
- interface GraphNode {
1740
- readonly content: string;
1741
- readonly id: number;
1742
- readonly importance?: ChunkImportance;
1743
- readonly label: string;
1744
- readonly retention?: ChunkRetention;
1745
- readonly sentenceIds: readonly SentenceId[];
1746
- readonly weight: number;
1747
- readonly wordsCount: number;
1869
+ type WikimatchPolicyDecision = "continue" | "never_recall" | "recall" | "skip_this_time";
1870
+ interface WikimatchPolicyJudgeInput {
1871
+ readonly candidates: readonly WikimatchCandidate[];
1872
+ readonly policyPrompt: string;
1873
+ readonly window: WikimatchWindow;
1748
1874
  }
1749
- interface GraphEdge {
1750
- readonly fromId: number;
1751
- readonly strength?: string;
1752
- readonly toId: number;
1753
- readonly weight: number;
1875
+ interface WikimatchPolicyJudgeResult {
1876
+ readonly continuations: readonly WikimatchPolicyContinuation[];
1877
+ readonly fallback?: WikimatchPolicyFallback;
1878
+ readonly mentions: readonly WikimatchAcceptedMention[];
1879
+ readonly policyUpdates: readonly WikimatchPolicyUpdate[];
1754
1880
  }
1755
- interface GraphEvidenceLine {
1756
- readonly sentenceId: SentenceId;
1757
- readonly text: string;
1881
+ interface WikimatchAcceptedMention {
1882
+ readonly candidateId: string;
1883
+ readonly confidence?: number;
1884
+ readonly qid: string;
1885
+ readonly range: WikimatchTextRange;
1886
+ readonly note?: string;
1887
+ readonly surface: string;
1758
1888
  }
1759
- interface GraphStatus {
1760
- readonly chapterId: number;
1761
- readonly edgeCount: number;
1762
- readonly graphReady: boolean;
1763
- readonly nodeCount: number;
1889
+ interface WikimatchPolicyUpdate {
1890
+ readonly candidateId: string;
1891
+ readonly decision: Exclude<WikimatchPolicyDecision, "recall" | "continue">;
1892
+ readonly note?: string;
1893
+ readonly qid?: string;
1894
+ readonly surface: string;
1764
1895
  }
1765
- interface GraphSearchHit {
1766
- readonly node: GraphNode;
1767
- readonly matchedFields: readonly GraphSearchField[];
1896
+ interface WikimatchPolicyContinuation {
1897
+ readonly candidateIds: readonly string[];
1898
+ readonly groupId: string;
1768
1899
  }
1769
- type GraphSearchField = "content" | "evidence" | "label";
1770
- interface GraphNeighbor {
1771
- readonly direction: "incoming" | "outgoing";
1772
- readonly edge: GraphEdge;
1773
- readonly node: GraphNode;
1900
+ interface WikimatchPolicyFallback {
1901
+ readonly issues: readonly string[];
1902
+ readonly reason: "guaranteed_json_failed";
1774
1903
  }
1775
- interface GraphPathStep {
1776
- readonly edge?: GraphEdge;
1777
- readonly node: GraphNode;
1904
+ interface WikimatchPolicyDecisionOutput {
1905
+ readonly candidateId: string;
1906
+ readonly confidence?: number;
1907
+ readonly decision: WikimatchPolicyDecision;
1908
+ readonly qid?: string;
1778
1909
  }
1779
- declare function getGraphStatus(document: ReadonlyDocument, chapterId: number): Promise<GraphStatus>;
1780
- declare function listGraphNodes(document: ReadonlyDocument, chapterId: number): Promise<readonly GraphNode[]>;
1781
- declare function getGraphNode(document: ReadonlyDocument, chapterId: number, nodeId: number): Promise<GraphNode>;
1782
- declare function searchGraphNodes(document: ReadonlyDocument, chapterId: number, pattern: string): Promise<readonly GraphSearchHit[]>;
1783
- declare function listGraphNeighbors(document: ReadonlyDocument, chapterId: number, nodeId: number): Promise<readonly GraphNeighbor[]>;
1784
- declare function getGraphEvidence(document: ReadonlyDocument, chapterId: number, nodeId: number): Promise<readonly GraphEvidenceLine[]>;
1785
- declare function findGraphPath(document: ReadonlyDocument, chapterId: number, fromNodeId: number, toNodeId: number): Promise<readonly GraphPathStep[]>;
1786
-
1787
- declare const TEXT_SENTENCE_KIND: {
1788
- readonly source: 1;
1789
- readonly summary: 2;
1790
- };
1791
- type TextSentenceKind = (typeof TEXT_SENTENCE_KIND)[keyof typeof TEXT_SENTENCE_KIND];
1792
- declare const SEARCH_OBJECT_PROPERTY_OWNER_KIND: {
1793
- readonly chapter: 1;
1794
- readonly chunk: 2;
1795
- readonly entity: 3;
1796
- };
1797
- type SearchObjectPropertyOwnerKind = (typeof SEARCH_OBJECT_PROPERTY_OWNER_KIND)[keyof typeof SEARCH_OBJECT_PROPERTY_OWNER_KIND];
1798
- declare const SEARCH_OBJECT_PROPERTY_KIND: {
1799
- readonly title: 1;
1800
- readonly label: 1;
1801
- readonly content: 2;
1802
- readonly surface: 1;
1803
- };
1804
- type SearchObjectPropertyKind = (typeof SEARCH_OBJECT_PROPERTY_KIND)[keyof typeof SEARCH_OBJECT_PROPERTY_KIND];
1805
- interface TextSentenceRecordInput {
1806
- readonly chapterId: number;
1807
- readonly kind: TextSentenceKind;
1808
- readonly sentenceIndex: number;
1809
- readonly text: string;
1810
- readonly wordsCount: number;
1910
+ interface WikimatchPolicyGroupOutput {
1911
+ readonly decisions: readonly WikimatchPolicyDecisionOutput[];
1912
+ readonly groupId: string;
1811
1913
  }
1812
- interface SearchObjectPropertyRecordInput {
1813
- readonly chapterId?: number;
1814
- readonly ownerId: string;
1815
- readonly ownerKind: SearchObjectPropertyOwnerKind;
1816
- readonly propertyKind: SearchObjectPropertyKind;
1817
- readonly text: string;
1914
+ interface WikimatchPolicyResponse {
1915
+ readonly groups: readonly WikimatchPolicyGroupOutput[];
1818
1916
  }
1819
- interface SearchIndexInput {
1820
- readonly objectProperties: readonly SearchObjectPropertyRecordInput[];
1821
- readonly textSentences: readonly TextSentenceRecordInput[];
1917
+
1918
+ interface JudgeWikimatchPolicyOptions extends WikimatchPolicyJudgeInput {
1919
+ readonly maxRetries?: number;
1920
+ readonly request: GuaranteedRequest;
1822
1921
  }
1823
- type SearchIndexProgressPhase = "checking" | "clearing" | "collecting" | "finalizing" | "indexing-objects" | "indexing-text";
1824
- interface SearchIndexProgressEvent {
1825
- readonly done?: number;
1826
- readonly phase: SearchIndexProgressPhase;
1827
- readonly total?: number;
1828
- readonly unit?: "chapter" | "object" | "sentence";
1922
+ declare function judgeWikimatchPolicy(options: JudgeWikimatchPolicyOptions): Promise<WikimatchPolicyJudgeResult>;
1923
+ declare function parsePolicyResponse(candidates: readonly WikimatchCandidate[], response: WikimatchPolicyResponse, groups?: readonly WikimatchConflictGroup[]): WikimatchPolicyJudgeResult;
1924
+ declare function validatePolicyResponse(candidates: readonly WikimatchCandidate[], response: WikimatchPolicyResponse, groups?: readonly WikimatchConflictGroup[]): readonly string[];
1925
+
1926
+ interface MatchWikispineSentenceCandidatesOptions {
1927
+ readonly command?: string;
1928
+ readonly dataDir?: string;
1929
+ readonly endpoint?: string;
1930
+ readonly fetch?: typeof fetch;
1931
+ readonly includeDisambiguation?: boolean;
1932
+ readonly maxCandidatesPerSurface?: number;
1933
+ readonly onProgress?: (progress: WikispineMatchProgress) => Promise<void> | void;
1934
+ readonly provider?: WikispineProvider;
1935
+ readonly sentences: readonly WikimatchSentence[];
1829
1936
  }
1830
- type SearchIndexProgressReporter = (event: SearchIndexProgressEvent) => void | Promise<void>;
1831
- type SearchIndexStatus = "current" | "dirty" | "missing";
1832
- interface SearchIndexTextHit {
1833
- readonly chapterId: number;
1834
- readonly kind: TextSentenceKind;
1835
- readonly rank: number;
1836
- readonly score: number;
1837
- readonly sentenceIndex: number;
1838
- readonly wordsCount: number;
1937
+ type WikispineProvider = "cli" | "fetch";
1938
+ interface WikispineMatchProgress {
1939
+ readonly coveredRangeEnd: number;
1839
1940
  }
1840
- interface SearchIndexObjectHit {
1841
- readonly chapterId?: number;
1842
- readonly ownerId: string;
1843
- readonly ownerKind: SearchObjectPropertyOwnerKind;
1844
- readonly propertyKind: SearchObjectPropertyKind;
1845
- readonly score: number;
1941
+ interface TestWikispineRuntimeOptions {
1942
+ readonly command?: string;
1943
+ readonly dataDir?: string;
1944
+ readonly endpoint?: string;
1945
+ readonly fetch?: typeof fetch;
1946
+ readonly provider?: WikispineProvider;
1846
1947
  }
1847
- interface SearchIndexQueryResult {
1848
- readonly objectHits: readonly SearchIndexObjectHit[];
1849
- readonly terms: readonly string[];
1850
- readonly textHits: readonly SearchIndexTextHit[];
1948
+ interface WikispineRuntimeTestResult {
1949
+ readonly durationMs: number;
1950
+ readonly metadata?: WikispineMetadata;
1951
+ readonly ok: true;
1952
+ readonly provider: WikispineProvider;
1851
1953
  }
1852
- declare const SEARCH_INDEX_FTS_HIT_LIMIT = 32000;
1853
- interface ArchiveIndexSettings {
1854
- readonly ftsEmbedded: boolean;
1954
+ interface WikispineMetadata {
1955
+ readonly automaton_shard_count: number;
1956
+ readonly format: string;
1957
+ readonly qid_count: number;
1958
+ readonly surface_count: number;
1959
+ readonly surface_normalization: string;
1855
1960
  }
1856
- declare function readArchiveIndexSettings(document: ReadonlyDocument): Promise<ArchiveIndexSettings>;
1857
- declare function setFtsIndexEmbedded(document: Document, embedded: boolean): Promise<void>;
1858
- declare function isSearchIndexCurrent(document: ReadonlyDocument, input?: SearchIndexInput): Promise<boolean>;
1859
- declare function readSearchIndexStatus(document: ReadonlyDocument, input?: SearchIndexInput): Promise<SearchIndexStatus>;
1860
- declare function ensureSearchIndex(document: Document, input: SearchIndexInput, progress?: SearchIndexProgressReporter): Promise<void>;
1861
- declare function querySearchIndex(document: ReadonlyDocument, query: string, options?: {
1862
- readonly chapters?: readonly number[];
1863
- readonly match?: ArchiveFindMatch;
1864
- readonly objectHitLimit?: number;
1865
- readonly textAfter?: {
1866
- readonly chapterId: number;
1867
- readonly kind: TextSentenceKind;
1868
- readonly rank: number;
1869
- readonly sentenceIndex: number;
1870
- };
1871
- readonly textHitLimit?: number;
1872
- readonly types?: readonly ArchiveFindObjectType[] | null;
1873
- }): Promise<SearchIndexQueryResult | undefined>;
1874
- declare function createSearchIndexFingerprint(input: SearchIndexInput): string;
1875
- declare function readSearchIndexFingerprintFromDatabase(database: Database): Promise<string | undefined>;
1961
+ declare const DEFAULT_WIKISPINE_FETCH_ENDPOINT = "https://wikispi-service-cxbfjlteab.cn-hangzhou.fcapp.run";
1962
+ declare function testWikispineRuntime(options: TestWikispineRuntimeOptions): Promise<WikispineRuntimeTestResult>;
1876
1963
 
1877
- type ArchiveObjectType = "chapter" | "chapter-title" | "chapter-tree" | "edge" | "entity" | "fragment" | "meta" | "node" | "source" | "state" | "summary" | "triple";
1878
- type ChapterStateTarget = "knowledge-graph" | "reading-graph" | "reading-summary" | "source";
1879
- type ChapterStateValue = "missing" | "ready";
1880
- type ChapterState = Record<ChapterStateTarget, ChapterStateValue>;
1881
- type ArchiveCollectionType = "chapter" | "chapter-title" | "entity" | "fragment" | "meta" | "node" | "source" | "summary" | "triple";
1882
- type ArchiveFindObjectType = "chapter" | "chapter-title" | "chapter-tree" | "entity" | "fragment" | "meta" | "node" | "source" | "summary" | "triple";
1883
- type ArchiveFindFilterType = "chapter" | "chapter-title" | "entity" | "fragment" | "meta" | "node" | "source" | "summary" | "triple";
1884
- interface ArchiveIndex {
1885
- readonly chapters: readonly ChapterEntry[];
1886
- readonly edgeCount: number;
1887
- readonly meta: BookMeta | undefined;
1888
- readonly nodeCount: number;
1889
- readonly summaryCount: number;
1890
- }
1891
- interface ArchiveFindHit {
1892
- readonly backlinks?: ArchiveBacklinks;
1893
- readonly chapter?: number;
1894
- readonly evidence?: ArchiveFindEvidencePreview;
1895
- readonly evidenceLinks?: readonly MentionLinkRecord[];
1896
- readonly evidenceMentions?: readonly EntityEvidenceMention[];
1897
- readonly field: ArchiveFindField;
1898
- readonly id: string;
1899
- readonly matchCount?: number;
1900
- readonly matchedTerms?: readonly string[];
1901
- readonly missingTerms?: readonly string[];
1902
- readonly position?: ArchiveFindPosition;
1903
- readonly score?: number;
1904
- readonly snippet: string;
1905
- readonly state?: ChapterState;
1906
- readonly title: string;
1907
- readonly triple?: {
1908
- readonly objectLabel: string;
1909
- readonly predicate: string;
1910
- readonly subjectLabel: string;
1911
- };
1912
- readonly type: ArchiveFindObjectType;
1964
+ declare function buildWikimatchWindows(options: BuildWikimatchWindowsOptions): readonly WikimatchWindow[];
1965
+
1966
+ type WikiGraphSamplingConfig = SamplingScopeConfig<WikiGraphScope>;
1967
+ declare function createDefaultWikiGraphSampling(input?: {
1968
+ readonly temperature?: TemperatureSetting;
1969
+ readonly topP?: TemperatureSetting;
1970
+ }): WikiGraphSamplingConfig;
1971
+
1972
+ type WikiGraphOperation = "digest-epub" | "digest-markdown" | "digest-text-stream" | "digest-txt";
1973
+ interface SerialDiscoveryItem {
1974
+ readonly id: number;
1975
+ readonly fragments?: number | undefined;
1976
+ readonly title?: string | undefined;
1977
+ readonly words: number;
1913
1978
  }
1914
- interface EntityEvidenceMention {
1915
- readonly match: Pick<ArchiveFindHit, "matchCount" | "matchedTerms" | "missingTerms" | "score">;
1916
- readonly mention: MentionRecord;
1979
+ interface SerialsDiscoveredEvent {
1980
+ readonly type: "serials-discovered";
1981
+ readonly available: boolean;
1982
+ readonly serials: readonly SerialDiscoveryItem[];
1917
1983
  }
1918
- interface ArchiveFindEvidencePreview {
1919
- readonly nextCursor: string | null;
1920
- readonly shown: number;
1921
- readonly sources: readonly ArchiveEvidenceItem[];
1922
- readonly total: number;
1984
+ interface SerialProgressEvent {
1985
+ readonly type: "serial-progress";
1986
+ readonly id: number;
1987
+ readonly completedWords: number;
1988
+ readonly completedFragments: number;
1923
1989
  }
1924
- type ArchiveFindField = "content" | "metadata" | "source" | "summary" | "title";
1925
- interface ArchiveFindOptions {
1926
- readonly archiveKey?: string;
1927
- readonly backlinks?: boolean;
1928
- readonly chapters?: readonly number[];
1929
- readonly cursor?: string;
1930
- readonly evidenceLimit?: number;
1931
- readonly ids?: readonly string[];
1932
- readonly limit?: number;
1933
- readonly match?: ArchiveFindMatch;
1934
- readonly order?: ArchiveFindOrder;
1935
- readonly sourceContext?: number;
1936
- readonly triplePattern?: ArchiveTriplePattern;
1937
- readonly types?: readonly ArchiveFindFilterType[];
1990
+ interface DigestProgressEvent {
1991
+ readonly type: "digest-progress";
1992
+ readonly completedWords: number;
1993
+ readonly totalWords: number;
1938
1994
  }
1939
- type ArchiveFindOrder = "doc-asc" | "doc-desc";
1940
- type ArchiveFindMatch = "all" | "any";
1941
- interface ArchiveFindPosition {
1942
- readonly chapter: number;
1943
- readonly documentOrder?: number;
1944
- readonly fragment?: number;
1945
- readonly sentence?: number;
1995
+ type WikiGraphProgressEventType = WikiGraphProgressEvent["type"];
1996
+ type WikiGraphProgressEvent = SerialsDiscoveredEvent | SerialProgressEvent | DigestProgressEvent;
1997
+ type WikiGraphProgressCallback = (event: WikiGraphProgressEvent) => void | Promise<void>;
1998
+
1999
+ type TextStream = AsyncIterable<string> | Iterable<string>;
2000
+
2001
+ type ReaderTextStream = TextStream;
2002
+
2003
+ interface ChapterTreeInput {
2004
+ readonly chapters: readonly ChapterTreeInputNode[];
1946
2005
  }
1947
- interface ArchiveFindResult {
1948
- readonly chapters: readonly number[] | null;
1949
- readonly items: readonly ArchiveFindHit[];
1950
- readonly lens: ArchiveFindLens;
1951
- readonly lensHint: ArchiveFindLensHint | null;
1952
- readonly limit: number;
1953
- readonly match: ArchiveFindMatch;
1954
- readonly nextCursor: string | null;
1955
- readonly order: ArchiveFindOrder;
1956
- readonly query: string;
1957
- readonly terms: readonly string[];
1958
- readonly types: readonly ArchiveFindFilterType[] | null;
2006
+ interface ChapterTreeInputNode {
2007
+ readonly children: readonly ChapterTreeInputNode[];
2008
+ readonly uri: string;
2009
+ readonly title?: string | null | undefined;
1959
2010
  }
1960
- type ArchiveFindLens = "broad" | "exact" | "typed";
1961
- interface ArchiveFindLensHint {
1962
- readonly lenses: {
1963
- readonly chapter: string;
1964
- readonly chunk: string;
1965
- readonly entity: string;
1966
- readonly node: string;
1967
- readonly triple: string;
1968
- };
1969
- readonly message: string;
2011
+ interface ChapterTreeApplyResult {
2012
+ readonly changed: boolean;
2013
+ readonly moved: readonly ChapterTreeMoveChange[];
2014
+ readonly renamed: readonly ChapterTreeTitleChange[];
2015
+ readonly unchanged: number;
1970
2016
  }
1971
- interface ArchiveCollectionOptions {
1972
- readonly backlinks?: boolean;
1973
- readonly chapters?: readonly number[];
1974
- readonly cursor?: string;
1975
- readonly evidenceLimit?: number;
1976
- readonly ids?: readonly string[];
1977
- readonly limit?: number;
1978
- readonly order?: ArchiveFindOrder;
1979
- readonly sourceContext?: number;
1980
- readonly triplePattern?: ArchiveTriplePattern;
1981
- readonly types?: readonly ArchiveCollectionType[];
2017
+ interface ChapterTreeMoveChange {
2018
+ readonly newUri: string;
2019
+ readonly newIndex: number;
2020
+ readonly newPath: readonly string[];
2021
+ readonly newParentUri: string | null;
2022
+ readonly oldUri: string;
2023
+ readonly oldIndex: number;
2024
+ readonly oldPath: readonly string[];
2025
+ readonly oldParentUri: string | null;
1982
2026
  }
1983
- interface ArchiveTriplePattern {
1984
- readonly objectQid?: string;
1985
- readonly predicate?: string;
1986
- readonly subjectQid?: string;
2027
+ interface ChapterTreeTitleChange {
2028
+ readonly uri: string;
2029
+ readonly newTitle: string | null;
2030
+ readonly oldTitle: string | null;
1987
2031
  }
1988
- interface ArchiveCollectionResult {
1989
- readonly chapters: readonly number[] | null;
1990
- readonly ids: readonly string[] | null;
1991
- readonly items: readonly ArchiveFindHit[];
1992
- readonly limit: number;
1993
- readonly nextCursor: string | null;
1994
- readonly order: ArchiveFindOrder;
1995
- readonly types: readonly ArchiveCollectionType[] | null;
2032
+ interface MoveChapterOptions {
2033
+ readonly afterChapterId?: number;
2034
+ readonly beforeChapterId?: number;
2035
+ readonly first?: boolean;
2036
+ readonly last?: boolean;
2037
+ readonly parentChapterId?: number;
2038
+ readonly root?: boolean;
1996
2039
  }
1997
- interface ArchiveBacklinks {
1998
- readonly chunks: ArchiveBacklinkBucket;
1999
- readonly entities: ArchiveBacklinkBucket;
2000
- readonly triples: ArchiveBacklinkBucket;
2040
+ interface AdvanceChapterStagesOptions {
2041
+ readonly chapterId?: number;
2042
+ readonly extractionPrompt?: string;
2043
+ readonly llm: LLM<WikiGraphScope>;
2044
+ readonly logDirPath?: string;
2045
+ readonly onProgress?: AdvanceChapterStagesProgressCallback;
2046
+ readonly targetStage: ChapterStage;
2047
+ readonly userLanguage?: Language;
2001
2048
  }
2002
- interface ArchiveBacklinkBucket {
2003
- readonly items: readonly ArchiveFindHit[];
2004
- readonly limit: number;
2005
- readonly nextCursor: string | null;
2049
+ interface AdvanceChapterStagesProgressState {
2050
+ readonly graphWords: number;
2051
+ readonly summaryWords: number;
2052
+ readonly totalGraphWords: number;
2053
+ readonly totalSummaryWords: number;
2006
2054
  }
2007
- type ArchiveListKind = "chapters" | "edges" | "fragments" | "meta" | "nodes" | "summaries";
2008
- type ArchiveListItem = {
2009
- readonly evidence?: ArchiveFindEvidencePreview;
2010
- readonly id: string;
2011
- readonly label: string;
2012
- readonly score?: number;
2013
- readonly state?: ChapterState;
2014
- readonly summary: string;
2015
- readonly type: Exclude<ArchiveObjectType, "triple">;
2016
- } | {
2017
- readonly evidence?: ArchiveFindEvidencePreview;
2018
- readonly id: string;
2019
- readonly label: string;
2020
- readonly evidenceLinks?: readonly MentionLinkRecord[];
2021
- readonly objectLabel: string;
2022
- readonly objectQid: string;
2023
- readonly predicate: string;
2024
- readonly score?: number;
2025
- readonly subjectLabel: string;
2026
- readonly subjectQid: string;
2027
- readonly summary: string;
2028
- readonly type: "triple";
2029
- };
2030
- type ArchivePage = {
2031
- readonly id: string;
2032
- readonly state: ChapterState;
2033
- readonly title: string;
2034
- readonly type: "chapter";
2035
- } | {
2036
- readonly id: string;
2037
- readonly title: string;
2038
- readonly type: "chapter-title";
2039
- } | {
2040
- readonly id: string;
2041
- readonly title: string;
2042
- readonly tree: ChapterTree;
2043
- readonly type: "chapter-tree";
2044
- } | {
2045
- readonly generatedNodeSummary: string;
2046
- readonly id: string;
2047
- readonly incoming: readonly GraphNeighbor[];
2048
- readonly neighbors: readonly GraphNeighbor[];
2049
- readonly outgoing: readonly GraphNeighbor[];
2050
- readonly position: ArchiveFindPosition | undefined;
2051
- readonly sourceFragments: readonly ArchiveNodeSourceFragment[];
2052
- readonly title: string;
2053
- readonly type: "node";
2054
- } | {
2055
- readonly backlinks?: ArchiveBacklinks;
2056
- readonly fragment: ArchiveSourceFragment;
2057
- readonly id: string;
2058
- readonly nextFragmentId: string | undefined;
2059
- readonly nodes: readonly ArchiveNodeLabel[];
2060
- readonly previousFragmentId: string | undefined;
2061
- readonly title: string;
2062
- readonly type: "fragment";
2063
- } | {
2064
- readonly content: string;
2065
- readonly id: string;
2066
- readonly title: string;
2067
- readonly type: "summary";
2068
- } | {
2069
- readonly evidence: ArchiveFindEvidencePreview;
2070
- readonly id: string;
2071
- readonly label: string;
2072
- readonly labels: readonly string[];
2073
- readonly mentionCount: number;
2074
- readonly qid: string;
2075
- readonly type: "entity";
2076
- } | {
2077
- readonly en: ArchiveEntityWikipageLocale | null;
2078
- readonly id: string;
2079
- readonly type: "entity-wikipage";
2080
- readonly zh: ArchiveEntityWikipageLocale | null;
2055
+ type AdvanceChapterStagesProgressCallback = (event: AdvanceChapterStagesProgressEvent) => void | Promise<void>;
2056
+ type AdvanceChapterStagesProgressEvent = {
2057
+ readonly type: "selected";
2058
+ readonly state: AdvanceChapterStagesProgressState;
2059
+ readonly targetStage: ChapterStage;
2060
+ readonly totalChapters: number;
2081
2061
  } | {
2082
- readonly evidence: ArchiveFindEvidencePreview;
2083
- readonly id: string;
2084
- readonly label: string;
2085
- readonly objectQid: string;
2086
- readonly predicate: string;
2087
- readonly subjectQid: string;
2088
- readonly type: "triple";
2062
+ readonly type: "skipped";
2063
+ readonly chapter: ChapterEntry;
2064
+ readonly reason: "planned";
2065
+ readonly targetStage: ChapterStage;
2089
2066
  } | {
2090
- readonly authors?: readonly string[];
2091
- readonly description?: string;
2092
- readonly id: string;
2093
- readonly publisher?: string;
2094
- readonly title: string;
2095
- readonly type: "meta";
2067
+ readonly type: "progress";
2068
+ readonly state: AdvanceChapterStagesProgressState;
2069
+ readonly targetStage: ChapterStage;
2096
2070
  } | {
2097
- readonly id: string;
2098
- readonly state: ChapterState;
2099
- readonly type: "state";
2071
+ readonly type: "started";
2072
+ readonly chapter: ChapterEntry;
2073
+ readonly step: "graph" | "summary";
2074
+ readonly targetStage: ChapterStage;
2100
2075
  } | {
2101
- readonly id: string;
2102
- readonly target: ChapterStateTarget;
2103
- readonly type: "state";
2104
- readonly value: ChapterStateValue;
2076
+ readonly type: "completed";
2077
+ readonly chapter: ChapterEntry;
2078
+ readonly step: "graph" | "summary";
2079
+ readonly targetStage: ChapterStage;
2105
2080
  };
2106
- interface ArchiveEntityWikipageLocale {
2107
- readonly description?: string;
2108
- readonly title: string;
2109
- readonly url: string;
2081
+ interface AdvanceChapterStagesResult {
2082
+ readonly advanced: readonly ChapterEntry[];
2083
+ readonly pending: readonly ChapterEntry[];
2084
+ readonly skipped: readonly ChapterEntry[];
2110
2085
  }
2111
- interface ArchivePack {
2112
- readonly anchor: ArchivePage;
2113
- readonly budget: number;
2114
- readonly related: readonly ArchiveListItem[];
2086
+ interface AddChapterOptions {
2087
+ readonly parentChapterId?: number;
2088
+ readonly title?: string | null | undefined;
2115
2089
  }
2116
- type ArchiveRelatedRole = "any" | "object" | "self" | "subject";
2117
- interface ArchiveRelatedOptions {
2118
- readonly cursor?: string;
2119
- readonly evidenceLimit?: number;
2120
- readonly limit?: number;
2121
- readonly order?: ArchiveFindOrder;
2122
- readonly query?: string;
2123
- readonly role?: ArchiveRelatedRole;
2124
- readonly sourceContext?: number;
2090
+
2091
+ declare function advanceChapterStages(document: Document, options: AdvanceChapterStagesOptions): Promise<AdvanceChapterStagesResult>;
2092
+
2093
+ interface SerialProgressSink {
2094
+ begin?(input?: {
2095
+ readonly fragments: number;
2096
+ readonly words: number;
2097
+ }): Promise<void>;
2098
+ advance(wordsCount: number): Promise<void>;
2099
+ complete(finalWordsCount?: number): Promise<void>;
2125
2100
  }
2126
- interface ArchiveRelatedResult {
2127
- readonly items: readonly ArchiveListItem[];
2128
- readonly limit: number;
2129
- readonly nextCursor: string | null;
2101
+
2102
+ interface GenerateChapterGraphOptions {
2103
+ readonly extractionPrompt?: string;
2104
+ readonly llm: LLM<WikiGraphScope>;
2105
+ readonly logDirPath?: string;
2106
+ readonly progressTracker?: SerialProgressSink;
2107
+ readonly userLanguage?: Language;
2130
2108
  }
2131
- interface ArchiveEvidence {
2132
- readonly items: readonly ArchiveEvidenceItem[];
2133
- readonly limit: number;
2134
- readonly nextCursor: string | null;
2109
+ interface GenerateChapterSummaryOptions {
2110
+ readonly llm: LLM<WikiGraphScope>;
2111
+ readonly logDirPath?: string;
2112
+ readonly userLanguage?: Language;
2135
2113
  }
2136
- interface ArchiveEvidenceItem {
2137
- readonly chapterId: number;
2138
- readonly endSentenceIndex: number;
2139
- readonly fragmentId?: number;
2140
- readonly id: string;
2141
- readonly score?: number;
2142
- readonly source: string;
2143
- readonly startSentenceIndex: number;
2144
- readonly title: string;
2145
- readonly type: "source";
2114
+
2115
+ declare function generateChapterGraph(document: Document, chapterId: number, options: GenerateChapterGraphOptions): Promise<ChapterDetails>;
2116
+ declare function generateChapterSummary(document: Document, chapterId: number, options: GenerateChapterSummaryOptions): Promise<ChapterDetails>;
2117
+
2118
+ declare function addChapter(document: Document, options: AddChapterOptions): Promise<ChapterDetails>;
2119
+ declare function resolveChapterPath(document: Document, chapterPath: string): Promise<number>;
2120
+ declare function resolveChapterPathReadonly(document: ReadonlyDocument, chapterPath: string): Promise<number>;
2121
+ declare function applyChapterTree(document: Document, tree: ChapterTreeInput, options?: {
2122
+ readonly dryRun?: boolean;
2123
+ }): Promise<ChapterTreeApplyResult>;
2124
+ declare function moveChapter(document: Document, chapterId: number, options: MoveChapterOptions): Promise<ChapterDetails>;
2125
+ declare function removeChapter(document: Document, chapterId: number, options?: {
2126
+ readonly recursive?: boolean;
2127
+ }): Promise<void>;
2128
+ declare function resetChapter(document: Document, chapterId: number, stage: Exclude<ChapterStage, "summarized">): Promise<ChapterDetails>;
2129
+ declare function setChapterSource(document: Document, chapterId: number, stream: ReaderTextStream): Promise<ChapterDetails>;
2130
+ declare function setChapterSummary(document: Document, chapterId: number, summary: string): Promise<ChapterDetails>;
2131
+ declare function setChapterTitle(document: Document, chapterId: number, title: string | null | undefined): Promise<ChapterDetails>;
2132
+
2133
+ declare function parseChapterTreeInput(input: unknown): ChapterTreeInput;
2134
+
2135
+ interface WikiGraphSerialEntry {
2136
+ readonly fragmentCount: number;
2137
+ readonly serialId: number;
2138
+ readonly title: string | null;
2139
+ readonly tocPath: readonly string[];
2146
2140
  }
2147
- interface ArchiveNodeLabel {
2148
- readonly id: string;
2149
- readonly title: string;
2141
+
2142
+ declare class WikiGraphArchive {
2143
+ #private;
2144
+ constructor(document: ReadonlyDocument, documentDirectoryPath: string);
2145
+ exportEpub(path: string): Promise<void>;
2146
+ exportText(path: string): Promise<void>;
2147
+ readCover(): Promise<SourceAsset | undefined>;
2148
+ readMeta(): Promise<BookMeta | undefined>;
2149
+ readToc(): Promise<TocFile | undefined>;
2150
+ readArchiveFormatVersion(): Promise<number>;
2151
+ readChapterStage(serialId: number): Promise<ChapterStage>;
2152
+ listSerials(): Promise<readonly WikiGraphSerialEntry[]>;
2153
+ readSerialSummary(serialId: number): Promise<string>;
2154
+ saveAs(path: string): Promise<void>;
2150
2155
  }
2151
- interface ArchiveSourceFragment {
2152
- readonly fragmentId?: number;
2153
- readonly id: string;
2154
- readonly preview: string;
2155
- readonly sentenceCount: number;
2156
- readonly text: string;
2157
- readonly wordsCount: number;
2156
+
2157
+ interface DigestDocumentSessionOptions {
2158
+ readonly documentDirPath?: string;
2158
2159
  }
2159
- interface ArchiveNodeSourceFragment {
2160
- readonly id: string;
2161
- readonly text: string;
2162
- readonly truncated: boolean;
2160
+
2161
+ interface WikiGraphLLMOptions {
2162
+ readonly cacheDirPath?: string;
2163
+ readonly concurrent?: number;
2164
+ readonly logDirPath?: string;
2165
+ readonly model: LanguageModel;
2166
+ readonly retryIntervalSeconds?: number;
2167
+ readonly retryTimes?: number;
2168
+ readonly stream?: boolean;
2169
+ readonly temperature?: number | readonly number[];
2170
+ readonly timeout?: number;
2171
+ readonly topP?: number | readonly number[];
2163
2172
  }
2164
- interface ArchiveEvidenceOptions {
2165
- readonly cursor?: string;
2166
- readonly limit?: number;
2167
- readonly order?: ArchiveFindOrder;
2168
- readonly query?: string;
2169
- readonly sourceContext?: number;
2173
+ interface WikiGraphOptions {
2174
+ readonly debugLogDirPath?: string;
2175
+ readonly llm?: LanguageModel | WikiGraphLLMOptions;
2176
+ readonly verbose?: boolean;
2177
+ }
2178
+ type WikiGraphOpenSessionOptions = DigestDocumentSessionOptions;
2179
+ interface WikiGraphSourceSessionOptions extends DigestDocumentSessionOptions {
2180
+ readonly extractionPrompt?: string;
2181
+ readonly onProgress?: WikiGraphProgressCallback;
2182
+ readonly path: string;
2183
+ readonly targetStage?: ChapterStage;
2184
+ readonly userLanguage?: Language;
2170
2185
  }
2171
- interface ArchivePageOptions {
2172
- readonly backlinks?: boolean;
2173
- readonly evidenceLimit?: number;
2174
- readonly order?: ArchiveFindOrder;
2175
- readonly sourceContext?: number;
2176
- readonly wikipageResolverOptions?: WikipageResolverOptions;
2186
+ interface WikiGraphTextStreamSessionOptions extends DigestDocumentSessionOptions {
2187
+ readonly bookLanguage?: string | null;
2188
+ readonly extractionPrompt?: string;
2189
+ readonly onProgress?: WikiGraphProgressCallback;
2190
+ readonly sourceFormat?: "markdown" | "txt";
2191
+ readonly stream: AsyncIterable<string> | Iterable<string>;
2192
+ readonly targetStage?: ChapterStage;
2193
+ readonly title?: string | null;
2194
+ readonly userLanguage?: Language;
2195
+ }
2196
+ declare class WikiGraph {
2197
+ #private;
2198
+ constructor(options: WikiGraphOptions);
2199
+ digestEpubSession<T>(options: WikiGraphSourceSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
2200
+ digestMarkdownSession<T>(options: WikiGraphSourceSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
2201
+ digestTextStreamSession<T>(options: WikiGraphTextStreamSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
2202
+ digestTxtSession<T>(options: WikiGraphSourceSessionOptions, operation: (digest: WikiGraphArchive) => Promise<T> | T): Promise<T>;
2203
+ openSession<T>(path: string, operation: (digest: WikiGraphArchive) => Promise<T> | T, options?: WikiGraphOpenSessionOptions): Promise<T>;
2177
2204
  }
2178
- declare function getArchiveIndex(document: ReadonlyDocument): Promise<ArchiveIndex>;
2179
- declare function listArchiveObjects(document: ReadonlyDocument, kind: ArchiveListKind): Promise<readonly ArchiveListItem[]>;
2180
- declare function listArchiveCollection(document: ReadonlyDocument, options?: ArchiveCollectionOptions): Promise<ArchiveCollectionResult>;
2181
- declare function findArchiveObjects(document: ReadonlyDocument, query: string, options?: ArchiveFindOptions): Promise<ArchiveFindResult>;
2182
- declare function rebuildArchiveSearchIndex(document: Document, progress?: SearchIndexProgressReporter): Promise<void>;
2183
- declare function isArchiveSearchIndexCurrent(document: ReadonlyDocument): Promise<boolean>;
2184
- declare function readArchiveSearchIndexStatus(document: ReadonlyDocument): Promise<"current" | "dirty" | "missing">;
2185
- declare function clearDirtyArchiveSearchIndex(document: Document): Promise<void>;
2186
- declare function createArchiveSearchIndexFingerprint(document: ReadonlyDocument): Promise<string>;
2187
- declare function grepArchiveObjects(document: ReadonlyDocument, query: string, options?: ArchiveFindOptions): Promise<ArchiveFindResult>;
2188
- declare function readArchiveText(document: ReadonlyDocument, id: string): Promise<string>;
2189
- declare function readArchivePage(document: ReadonlyDocument, id: string, options?: ArchivePageOptions): Promise<ArchivePage>;
2190
- declare function listArchiveLinks(document: ReadonlyDocument, id: string, direction: "backlinks" | "links"): Promise<readonly GraphNeighbor[]>;
2191
- declare function listAllArchiveLinks(document: ReadonlyDocument, id: string): Promise<readonly GraphNeighbor[]>;
2192
- declare function listRelatedArchiveObjects(document: ReadonlyDocument, id: string, options?: ArchiveRelatedOptions): Promise<ArchiveRelatedResult>;
2193
- declare function listArchiveEvidence(document: ReadonlyDocument, uri: string, options?: ArchiveEvidenceOptions): Promise<ArchiveEvidence>;
2194
- declare function packArchiveContext(document: ReadonlyDocument, id: string, budget: number): Promise<ArchivePack>;
2195
- declare function formatChapterId(chapterId: number): string;
2196
- declare function formatEdgeId(edge: ReadingEdgeRecord): string;
2197
- declare function formatNodeId(nodeId: number): string;
2198
- declare function formatSummaryId(chapterId: number): string;
2199
2205
 
2200
- type ContinuationCursor = {
2206
+ type QueryScope = {
2207
+ readonly kind: "archive";
2208
+ readonly archiveId: number;
2209
+ } | {
2210
+ readonly kind: "library";
2211
+ readonly libraryId: number;
2212
+ };
2213
+ type QueryIndexScope = {
2214
+ readonly kind: "archive-index";
2215
+ readonly archivePath: string;
2216
+ readonly archiveKey: string;
2217
+ } | {
2218
+ readonly kind: "library-index";
2219
+ readonly libraryId: number;
2220
+ };
2221
+ type ContinuationCursorBase = {
2201
2222
  readonly archiveKey: string;
2202
2223
  readonly archivePath: string;
2224
+ readonly indexScope: QueryIndexScope;
2225
+ };
2226
+ type ContinuationCursor = (ContinuationCursorBase & {
2203
2227
  readonly backlinks?: boolean;
2204
2228
  readonly chapters: readonly number[] | null;
2205
2229
  readonly cursor: string;
@@ -2215,10 +2239,9 @@ type ContinuationCursor = {
2215
2239
  readonly subjectQid?: string;
2216
2240
  };
2217
2241
  readonly types: readonly string[] | null;
2218
- } | {
2219
- readonly archiveKey: string;
2220
- readonly archivePath: string;
2242
+ }) | (ContinuationCursorBase & {
2221
2243
  readonly backlinks?: boolean;
2244
+ readonly chapters?: readonly number[] | null;
2222
2245
  readonly cursor: string;
2223
2246
  readonly evidenceLimit?: number;
2224
2247
  readonly format: "json" | "jsonl" | "text";
@@ -2231,9 +2254,7 @@ type ContinuationCursor = {
2231
2254
  readonly subjectQid?: string;
2232
2255
  };
2233
2256
  readonly types: readonly string[] | null;
2234
- } | {
2235
- readonly archiveKey: string;
2236
- readonly archivePath: string;
2257
+ }) | (ContinuationCursorBase & {
2237
2258
  readonly cursor: string;
2238
2259
  readonly format: "json" | "jsonl" | "text";
2239
2260
  readonly kind: "evidence";
@@ -2241,9 +2262,7 @@ type ContinuationCursor = {
2241
2262
  readonly query?: string;
2242
2263
  readonly sourceContext?: number;
2243
2264
  readonly targetUri: string;
2244
- } | {
2245
- readonly archiveKey: string;
2246
- readonly archivePath: string;
2265
+ }) | (ContinuationCursorBase & {
2247
2266
  readonly cursor: string;
2248
2267
  readonly evidenceLimit?: number;
2249
2268
  readonly format: "json" | "jsonl" | "text";
@@ -2253,115 +2272,113 @@ type ContinuationCursor = {
2253
2272
  readonly role?: "any" | "object" | "self" | "subject";
2254
2273
  readonly sourceContext?: number;
2255
2274
  readonly targetUri: string;
2256
- };
2275
+ });
2276
+
2257
2277
  declare function createContinuationCursor(input: ContinuationCursor): Promise<string>;
2258
2278
  declare function readContinuationCursor(cursorId: string): Promise<ContinuationCursor>;
2259
2279
 
2260
- interface SearchSessionInput {
2261
- readonly archiveKey: string;
2262
- readonly chapters: readonly number[] | null;
2263
- readonly chunkHits?: readonly SearchChunkHitInput[];
2264
- readonly entityHits?: readonly SearchEntityHitInput[];
2265
- readonly evidenceEvents?: readonly SearchEvidenceHitEventInput[];
2266
- readonly items?: readonly ArchiveFindHit[];
2267
- readonly lens: string;
2268
- readonly match: string;
2269
- readonly order: string;
2270
- readonly query: string;
2271
- readonly revisionScope: string;
2272
- readonly terms: readonly string[];
2273
- readonly tripleHits?: readonly SearchTripleHitInput[];
2274
- readonly types: readonly string[] | null;
2275
- }
2276
- declare const SEARCH_EVIDENCE_KIND: {
2277
- readonly mention: 1;
2278
- readonly mentionLink: 2;
2279
- readonly chunk: 3;
2280
- };
2281
- type SearchEvidenceKind = (typeof SEARCH_EVIDENCE_KIND)[keyof typeof SEARCH_EVIDENCE_KIND];
2282
- interface SearchEvidenceHitEventInput {
2283
- readonly chapterId: number;
2284
- readonly evidenceId: string;
2285
- readonly evidenceKind: SearchEvidenceKind;
2286
- readonly score: number;
2287
- readonly sentenceIndex: number;
2288
- }
2289
- interface SearchEntityHitInput {
2290
- readonly evidenceTopScores?: readonly number[];
2291
- readonly propertyTopScores?: readonly number[];
2292
- readonly qid: string;
2293
- }
2294
- interface SearchTripleHitInput {
2295
- readonly evidenceTopScores: readonly number[];
2296
- readonly objectQid: string;
2297
- readonly predicate: string;
2298
- readonly subjectQid: string;
2299
- }
2300
- interface SearchChunkHitInput {
2301
- readonly chunkId: number;
2302
- readonly evidenceTopScores?: readonly number[];
2303
- readonly propertyTopScores?: readonly number[];
2304
- }
2305
- interface SearchSessionPage {
2306
- readonly chapters: readonly number[] | null;
2307
- readonly items: readonly ArchiveFindHit[];
2308
- readonly lens: string;
2309
- readonly match: string;
2310
- readonly nextCursor: string | null;
2311
- readonly query: string;
2312
- readonly sessionId: string;
2313
- readonly terms: readonly string[];
2314
- readonly types: readonly string[] | null;
2315
- }
2316
- interface SearchSessionDescriptor {
2317
- readonly chapters: readonly number[] | null;
2318
- readonly createdAt: number;
2319
- readonly lens: string;
2320
- readonly match: string;
2321
- readonly objectCachesPopulated: boolean;
2322
- readonly query: string;
2323
- readonly sessionId: string;
2324
- readonly terms: readonly string[];
2325
- readonly types: readonly string[] | null;
2326
- }
2327
- type SearchSessionCacheInput = Omit<SearchSessionInput, "items">;
2328
- declare function readCachedSearchSessionPage(input: SearchSessionCacheInput, offset: number, limit: number): Promise<SearchSessionPage | undefined>;
2329
- declare function createSearchSession(input: SearchSessionInput): Promise<string>;
2330
2280
  declare function deleteArchiveSearchSessions(archiveKey: string): Promise<void>;
2331
- declare function runSearchCacheGc(context: GcContext): Promise<GcJobResult>;
2281
+
2282
+ declare function addBuildJob(options: AddBuildJobOptions): Promise<BuildJob>;
2283
+ declare function recordBuildJobInputRevision(input: {
2284
+ readonly currentRevision: number;
2285
+ readonly jobId: string;
2286
+ readonly ownerId: string;
2287
+ }): Promise<BuildJob>;
2288
+ declare function assertBuildJobInputRevision(input: {
2289
+ readonly currentRevision: number;
2290
+ readonly jobId: string;
2291
+ readonly ownerId: string;
2292
+ }): Promise<void>;
2293
+ declare function listBuildJobs(options?: BuildJobListOptions): Promise<BuildJob[]>;
2294
+ declare function getBuildJob(jobId: string): Promise<BuildJob>;
2295
+ declare function resolveBuildJobId(jobIdPrefix: string): Promise<string>;
2296
+ declare function pauseBuildJob(jobId: string): Promise<BuildJob>;
2297
+ declare function resumeBuildJob(jobId: string): Promise<BuildJob>;
2298
+ declare function cancelBuildJob(jobId: string): Promise<BuildJob>;
2299
+ declare function boostBuildJob(jobId: string): Promise<BuildJob>;
2300
+ declare function updateBuildJobTarget(jobId: string, target: BuildJobTarget): Promise<BuildJob>;
2301
+
2302
+ declare function assertNoActiveBuildJobs(input: {
2303
+ readonly archivePath: string;
2304
+ readonly chapterIds: readonly number[];
2305
+ readonly operation: string;
2306
+ readonly requiresTarget?: BuildJobTarget;
2307
+ }): Promise<void>;
2308
+ declare function assertNoActiveBuildJobConflicts(input: {
2309
+ readonly archivePath: string;
2310
+ readonly operation: string;
2311
+ readonly requiresTarget?: BuildJobTarget;
2312
+ readonly scope: BuildJobConflictScope;
2313
+ }): Promise<void>;
2314
+
2315
+ declare function readBuildJobEvents(job: Pick<BuildJob, "eventsPath">): Promise<BuildJobEvent[]>;
2316
+
2317
+ declare function cleanBuildJobs(options?: {
2318
+ readonly olderThanMs?: number;
2319
+ readonly states?: readonly BuildJobState[];
2320
+ }): Promise<number>;
2332
2321
 
2333
2322
  interface ChapterGraphBuildArtifact {
2334
2323
  readonly documentPath: string;
2335
2324
  readonly chapterId: number;
2325
+ readonly objectsPath: string;
2336
2326
  readonly parameter: GraphBuildParameterInput$1;
2337
2327
  }
2338
2328
  interface GraphBuildParameterInput$1 {
2339
2329
  readonly language?: string;
2340
2330
  readonly prompt: string;
2341
2331
  }
2342
- interface ChapterSummaryInputSnapshot {
2343
- readonly filePath: string;
2344
- }
2345
- interface BuildChapterGraphArtifactOptions extends GenerateChapterGraphOptions {
2332
+ interface BuildChapterGraphArtifactOptions {
2333
+ readonly extractionPrompt?: string;
2334
+ readonly llm: LLM<WikiGraphScope>;
2335
+ readonly logDirPath?: string;
2336
+ readonly progressTracker?: SerialProgressSink;
2346
2337
  readonly sourceText: readonly string[];
2338
+ readonly userLanguage?: Language;
2347
2339
  readonly workspacePath: string;
2348
2340
  }
2349
- interface BuildChapterSummaryArtifactOptions extends GenerateChapterSummaryOptions {
2350
- readonly snapshotPath?: string;
2351
- readonly sourceDocumentPath?: string;
2352
- readonly workspacePath: string;
2353
- }
2341
+
2342
+ declare function buildChapterGraphArtifact(chapterId: number, options: BuildChapterGraphArtifactOptions): Promise<ChapterGraphBuildArtifact>;
2343
+ declare function commitChapterGraphArtifact(document: Document, artifact: ChapterGraphBuildArtifact): Promise<ChapterDetails>;
2344
+
2354
2345
  declare function readChapterBuildInput(document: ReadonlyDocument, chapterId: number): Promise<{
2355
2346
  readonly details: ChapterDetails;
2356
2347
  readonly revision: number;
2357
2348
  readonly sourceText: readonly string[];
2358
2349
  }>;
2359
- declare function buildChapterGraphArtifact(chapterId: number, options: BuildChapterGraphArtifactOptions): Promise<ChapterGraphBuildArtifact>;
2360
- declare function commitChapterGraphArtifact(document: Document, artifact: ChapterGraphBuildArtifact): Promise<ChapterDetails>;
2350
+
2351
+ interface ChapterSummaryInputSnapshot {
2352
+ readonly filePath: string;
2353
+ readonly objectsPath: string;
2354
+ }
2355
+ interface BuildChapterSummaryArtifactOptions {
2356
+ readonly llm: LLM<WikiGraphScope>;
2357
+ readonly logDirPath?: string;
2358
+ readonly readingGraphObjectsPath?: string;
2359
+ readonly snapshotPath?: string;
2360
+ readonly sourceDocumentPath?: string;
2361
+ readonly userLanguage?: Language;
2362
+ readonly workspacePath: string;
2363
+ }
2364
+ interface SummaryInputSnapshotData {
2365
+ readonly chunks: readonly ChunkRecord[];
2366
+ readonly fragmentGroups: readonly SentenceGroupRecord[];
2367
+ readonly fragments: readonly FragmentRecord[];
2368
+ readonly readingEdges: readonly ReadingEdgeRecord[];
2369
+ readonly serial: SerialRecord;
2370
+ readonly snakeChunks: readonly SnakeChunkRecord[];
2371
+ readonly snakeEdges: readonly SnakeEdgeRecord[];
2372
+ readonly snakes: readonly SnakeRecord[];
2373
+ }
2374
+
2361
2375
  declare function buildChapterSummaryArtifact(document: ReadonlyDocument, chapterId: number, options: BuildChapterSummaryArtifactOptions): Promise<string>;
2362
2376
  declare function buildChapterSummaryArtifactFromSnapshot(chapterId: number, options: BuildChapterSummaryArtifactOptions & {
2363
2377
  readonly snapshotPath: string;
2364
2378
  }): Promise<string>;
2379
+ declare function buildChapterSummaryArtifactFromReadingGraphObjects(chapterId: number, options: BuildChapterSummaryArtifactOptions & {
2380
+ readonly readingGraphObjectsPath: string;
2381
+ }): Promise<string>;
2365
2382
  declare function commitChapterSummaryArtifact(document: Document, chapterId: number, summary: string): Promise<ChapterDetails>;
2366
2383
  declare function snapshotChapterSummaryInput(document: ReadonlyDocument, chapterId: number, workspacePath: string): Promise<ChapterSummaryInputSnapshot>;
2367
2384
 
@@ -2369,6 +2386,7 @@ interface ChapterKnowledgeGraphBuildArtifact {
2369
2386
  readonly chapterId: number;
2370
2387
  readonly mentionLinksPath: string;
2371
2388
  readonly mentionsPath: string;
2389
+ readonly objectsPath: string;
2372
2390
  readonly parameter: GraphBuildParameterInput;
2373
2391
  readonly workspacePath: string;
2374
2392
  }
@@ -2387,33 +2405,58 @@ interface BuildChapterKnowledgeGraphArtifactOptions {
2387
2405
  readonly workspacePath: string;
2388
2406
  }
2389
2407
  interface GenerateChapterKnowledgeGraphArtifactOptions {
2390
- readonly policyPrompt: string;
2408
+ readonly policyPrompt?: string;
2391
2409
  readonly progressTracker?: Pick<BuildJobProgressReporter, "throwIfStopped" | "updatePhase">;
2392
2410
  readonly request: GuaranteedRequestController;
2393
2411
  readonly resolverOptions?: Omit<WikipageResolverOptions, "progress">;
2394
2412
  readonly wikispine?: Pick<MatchWikispineSentenceCandidatesOptions, "command" | "dataDir" | "endpoint" | "provider">;
2395
2413
  readonly workspacePath: string;
2396
2414
  }
2415
+ type KnowledgeGraphProgressTracker = GenerateChapterKnowledgeGraphArtifactOptions["progressTracker"];
2416
+
2417
+ declare function buildChapterKnowledgeGraphArtifact(chapterId: number, options: BuildChapterKnowledgeGraphArtifactOptions): Promise<ChapterKnowledgeGraphBuildArtifact>;
2418
+
2419
+ declare function commitChapterKnowledgeGraphArtifact(document: Document, artifact: ChapterKnowledgeGraphBuildArtifact): Promise<void>;
2420
+ declare function clearChapterKnowledgeGraph(document: Document, chapterId: number): Promise<void>;
2421
+
2397
2422
  declare function generateChapterKnowledgeGraphArtifact(document: ReadonlyDocument, chapterId: number, options: GenerateChapterKnowledgeGraphArtifactOptions): Promise<ChapterKnowledgeGraphBuildArtifact>;
2398
- declare function snapshotChapterKnowledgeGraphInput(document: ReadonlyDocument, chapterId: number): Promise<ChapterKnowledgeGraphInputSnapshot>;
2399
2423
  declare function generateChapterKnowledgeGraphArtifactFromSnapshot(chapterId: number, snapshot: ChapterKnowledgeGraphInputSnapshot, options: GenerateChapterKnowledgeGraphArtifactOptions): Promise<ChapterKnowledgeGraphBuildArtifact>;
2400
- declare function buildChapterKnowledgeGraphArtifact(chapterId: number, options: BuildChapterKnowledgeGraphArtifactOptions): Promise<ChapterKnowledgeGraphBuildArtifact>;
2424
+
2401
2425
  declare function groundWikimatchCandidates(input: {
2402
2426
  readonly candidates: readonly WikimatchCandidate[];
2403
2427
  readonly policyPrompt: string;
2404
- readonly progressTracker?: Pick<BuildJobProgressReporter, "throwIfStopped" | "updatePhase">;
2428
+ readonly progressTracker?: KnowledgeGraphProgressTracker;
2405
2429
  readonly request: GuaranteedRequestController;
2406
2430
  readonly text: string;
2407
2431
  }): Promise<readonly WikimatchAcceptedMention[]>;
2432
+
2408
2433
  declare function createEnrichmentProgressReporter(progressTracker: Pick<BuildJobProgressReporter, "throwIfStopped" | "updatePhase">): (event: WikipageResolveProgress) => Promise<void>;
2409
- declare function commitChapterKnowledgeGraphArtifact(document: Document, artifact: ChapterKnowledgeGraphBuildArtifact): Promise<void>;
2410
- declare function clearChapterKnowledgeGraph(document: Document, chapterId: number): Promise<void>;
2411
2434
 
2412
- declare function writeWikgArchive(documentDirectoryPath: string, outputPath: string): Promise<void>;
2435
+ declare function snapshotChapterKnowledgeGraphInput(document: ReadonlyDocument, chapterId: number): Promise<ChapterKnowledgeGraphInputSnapshot>;
2436
+
2437
+ declare const DEFAULT_EXTRACTION_PROMPT = "Focus on the main storyline and key character developments. Preserve important dialogues and critical plot points. Background descriptions and minor details can be compressed significantly.";
2438
+ declare const DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT: string;
2439
+ declare function resolveExtractionPrompt(prompt: string | undefined): string;
2440
+ declare function resolveKnowledgeGraphRecallPrompt(prompt: string | undefined): string;
2441
+
2442
+ declare function formatChapterUri(path: string): string;
2443
+ declare function parseChapterPath(value: string, label?: string): string;
2444
+ declare function parseChapterUriPath(uri: string): string | undefined;
2445
+
2413
2446
  declare function readWikgArchiveFormatVersion(documentDirectoryPath: string): Promise<number>;
2414
2447
 
2448
+ declare function writeWikgArchive(documentDirectoryPath: string, outputPath: string): Promise<void>;
2449
+
2415
2450
  declare const WIKI_GRAPH_URI_PREFIX = "wikg://";
2416
2451
  declare const WIKI_GRAPH_JOB_URI_PREFIX = "wikg://local/job";
2452
+ interface ParsedWikiGraphUri {
2453
+ readonly protocol: string;
2454
+ readonly path: readonly string[];
2455
+ readonly fragment?: number | {
2456
+ readonly begin: number;
2457
+ readonly end: number;
2458
+ };
2459
+ }
2417
2460
  interface LocatedWikiGraphUri {
2418
2461
  readonly archivePath?: string;
2419
2462
  readonly objectUri?: string;
@@ -2421,11 +2464,12 @@ interface LocatedWikiGraphUri {
2421
2464
  declare function isWikiGraphUri(value: string | undefined): value is string;
2422
2465
  declare function isWikiGraphJobUri(value: string | undefined): value is string;
2423
2466
  declare function parseLocatedWikiGraphUri(uri: string): LocatedWikiGraphUri;
2467
+ declare function parseWikiGraphUriSyntax(uri: string): ParsedWikiGraphUri;
2424
2468
  declare function formatLocatedWikiGraphUri(archivePath: string, objectUri?: string): string;
2425
2469
  declare function formatWikiGraphCommandUri(archivePath: string, objectUri?: string, cwd?: string): string;
2426
- declare function formatLocatedChapterUri(archivePath: string, chapterId: number): string;
2427
- declare function formatLocatedChapterResourceUri(archivePath: string, chapterId: number, resource: "source" | "summary" | "title"): string;
2428
- declare function formatLocatedChapterSourceCollectionUri(archivePath: string, chapterId: number): string;
2470
+ declare function formatLocatedChapterUri(archivePath: string, chapterPath: string): string;
2471
+ declare function formatLocatedChapterResourceUri(archivePath: string, chapterPath: string, resource: "source" | "summary" | "title"): string;
2472
+ declare function formatLocatedChapterSourceCollectionUri(archivePath: string, chapterPath: string): string;
2429
2473
  declare function requireArchiveUri(uri: string): string;
2430
2474
  declare function requireLocatedObjectUri(uri: string): {
2431
2475
  readonly archivePath: string;
@@ -2451,6 +2495,69 @@ declare class WikiGraphArchiveFile {
2451
2495
  }): Promise<T>;
2452
2496
  }
2453
2497
 
2498
+ declare function ensureWikiGraphHomeSchemaCurrent(): Promise<void>;
2499
+ declare function readWikiGraphHomeSchemaVersion(coreDatabasePath?: string): Promise<number>;
2500
+
2501
+ interface WikiGraphArchiveSchemaUpgradeResult {
2502
+ readonly changed: boolean;
2503
+ readonly repairedToc: boolean;
2504
+ readonly schemaChanged: boolean;
2505
+ }
2506
+ declare function ensureWikiGraphArchiveSchemaCurrent(archivePath: string): Promise<void>;
2507
+ declare function readWikiGraphArchiveSchemaVersion(archivePath: string): Promise<number>;
2508
+ declare function upgradeWikiGraphArchiveSchema(archivePath: string): Promise<WikiGraphArchiveSchemaUpgradeResult>;
2509
+
2510
+ type WikiGraphMaintenanceUpgradeResult = {
2511
+ readonly kind: "home";
2512
+ readonly path: string;
2513
+ readonly schemaVersionBefore: number;
2514
+ readonly schemaVersionAfter: number;
2515
+ readonly status: "already-current" | "upgraded";
2516
+ } | {
2517
+ readonly kind: "archive";
2518
+ readonly path: string;
2519
+ readonly schemaVersionBefore: number;
2520
+ readonly schemaVersionAfter: number;
2521
+ readonly status: "already-current" | "upgraded";
2522
+ } | {
2523
+ readonly kind: "sdpub";
2524
+ readonly inputPath: string;
2525
+ readonly outputPath: string;
2526
+ readonly status: "migrated";
2527
+ } | WikiGraphLibraryUpgradeResult;
2528
+ interface WikiGraphLibraryUpgradeResult {
2529
+ readonly kind: "lib";
2530
+ readonly library: {
2531
+ readonly id: number;
2532
+ readonly publicId: string;
2533
+ readonly uri: string;
2534
+ readonly folderPath: string;
2535
+ readonly stagingPath: string;
2536
+ };
2537
+ readonly upgraded: readonly WikiGraphLibraryArchiveUpgradeItem[];
2538
+ readonly skipped: readonly WikiGraphLibraryArchiveUpgradeItem[];
2539
+ readonly failed?: WikiGraphLibraryArchiveFailure | undefined;
2540
+ readonly status: "already-current" | "partial" | "upgraded";
2541
+ }
2542
+ interface WikiGraphLibraryArchiveUpgradeItem {
2543
+ readonly publicId: string;
2544
+ readonly uri: string;
2545
+ readonly path: string;
2546
+ readonly schemaVersionBefore: number;
2547
+ readonly schemaVersionAfter: number;
2548
+ }
2549
+ interface WikiGraphLibraryArchiveFailure {
2550
+ readonly publicId: string;
2551
+ readonly uri: string;
2552
+ readonly path: string;
2553
+ readonly message: string;
2554
+ }
2555
+ declare function upgradeWikiGraphMaintenanceTarget(target: string, options?: {
2556
+ readonly outputPath?: string;
2557
+ }): Promise<WikiGraphMaintenanceUpgradeResult>;
2558
+ declare function assertWikiGraphLibrarySchemaCurrent(target: ParsedWikiGraphLibraryUri): Promise<void>;
2559
+ declare function upgradeWikiGraphLibrarySchema(target: ParsedWikiGraphLibraryUri): Promise<WikiGraphLibraryUpgradeResult>;
2560
+
2454
2561
  interface LegacySdpubMigrationResult {
2455
2562
  readonly inputPath: string;
2456
2563
  readonly outputPath: string;
@@ -2459,4 +2566,140 @@ declare function migrateLegacySdpubToWikg(inputPath: string, outputPath?: string
2459
2566
 
2460
2567
  declare function formatError(error: unknown): string;
2461
2568
 
2462
- export { type AddChapterOptions, type AdvanceChapterStagesOptions, type AdvanceChapterStagesProgressCallback, type AdvanceChapterStagesProgressEvent, type AdvanceChapterStagesResult, type ArchiveBacklinkBucket, type ArchiveBacklinks, type ArchiveCollectionOptions, type ArchiveCollectionResult, type ArchiveCollectionType, type ArchiveEvidence, type ArchiveEvidenceItem, type ArchiveFindEvidencePreview, type ArchiveFindField, type ArchiveFindFilterType, type ArchiveFindHit, type ArchiveFindObjectType, type ArchiveFindOptions, type ArchiveFindOrder, type ArchiveFindPosition, type ArchiveFindResult, type ArchiveIndex, type ArchiveIndexSettings, type ArchiveListItem, type ArchiveListKind, type ArchiveNodeLabel, type ArchiveNodeSourceFragment, type ArchiveObjectType, type ArchivePack, type ArchivePage, type ArchiveRelatedResult, type ArchiveTriplePattern, type BookMeta, type BuildChapterGraphArtifactOptions, type BuildChapterKnowledgeGraphArtifactOptions, type BuildChapterSummaryArtifactOptions, BuildJobProgressReporter, type BuildWikimatchSurfaceProtectionInputOptions, type BuildWikimatchWindowsOptions, CHAPTER_STAGES, CLI_FULL_COMMAND, CLI_PRIMARY_COMMAND, type CachedDisambiguationRecord, type CachedPageRecord, type CachedQidRecord, type ChapterDetails, type ChapterEntry, type ChapterGraphBuildArtifact, type ChapterKnowledgeGraphBuildArtifact, type ChapterKnowledgeGraphInputSnapshot, type ChapterStage, type ChapterTree, type ChapterTreeApplyResult, type ChapterTreeInput, type ChapterTreeInputNode, type ChapterTreeMoveChange, type ChapterTreeNode, type ChapterTreeTitleChange, ChunkImportance, type ChunkRecord, ChunkRetention, ChunkStore, type ContinuationCursor, type CreateSnakeRecord, DEFAULT_WIKISPINE_FETCH_ENDPOINT, Database, type DigestProgressEvent, DirectoryDocument, type DisambiguationExpansion, type DisambiguationLinkedQid, type DisambiguationMeaningPriority, type DisambiguationPageText, type DisambiguationProfile, type DisambiguationProfileMeaning, type DisambiguationProfileNormalizer, type DisambiguationProfileNormalizerInput, type Document, type DocumentContext, EVIDENCE_SELECTION_JSON_SHAPE, EVIDENCE_SELECTION_PROMPT_FRAGMENT, type EvidenceQuoteMatchStrategy, type EvidenceQuoteScore, type EvidenceSelection, type EvidenceSelectionCandidate, type EvidenceSelectionFailure, type EvidenceSelectionList, type EvidenceSelectionResolution, type EvidenceSelectionSentence, type EvidenceSentenceId, FragmentDraft, FragmentGroupStore, type FragmentRecord, Fragments, type GenerateChapterGraphOptions, type GenerateChapterSummaryOptions, type GraphBuildParameterRecord, GraphBuildParameterStore, type GraphEdge, type GraphEvidenceLine, type GraphNeighbor, type GraphNode, type GraphPathStep, type GraphSearchField, type GraphSearchHit, type GraphStatus, type GuaranteedRequest, type GuaranteedRequestController, type JudgeWikimatchPolicyOptions, type JudgeWikimatchSurfaceProtectionOptions, LLM, type LLMOptions, LLMPaymentRequiredError, type LLMRequestOptions, type LLMStreamProgressCallback, type LLMTokenUsage, type LLMTokenUsageCallback, type LLMessage, Language, LanguageCode, type LocatedWikiGraphUri, type MatchWikispineSentenceCandidatesOptions, type MentionLinkRecord, MentionLinkStore, type MentionRecord, MentionStore, type MoveChapterOptions, type NarrowWikimatchCandidateOptionsInput, type NarrowWikimatchCandidateOptionsOptions, ObjectMetadataKind, ObjectMetadataStore, type ObjectMetadataTarget, type QidResolution, RateLimiter, type ReadingEdgeRecord, ReadingEdgeStore, type ReadonlyChunkStore, type ReadonlyDocument, type ReadonlyFragmentGroupStore, type ReadonlyTextStreams as ReadonlyFragments, type ReadonlyGraphBuildParameterStore, type ReadonlyMentionLinkStore, type ReadonlyMentionStore, type ReadonlyObjectMetadataStore, type ReadonlyReadingEdgeStore, type ReadonlySerialTextStream as ReadonlySerialFragments, type ReadonlySerialStore, type ReadonlySerialTextStream, type ReadonlySnakeChunkStore, type ReadonlySnakeEdgeStore, type ReadonlySnakeStore, type ReadonlyTextStreams, SCHEMA_SQL, SEARCH_INDEX_FTS_HIT_LIMIT, SEARCH_OBJECT_PROPERTY_KIND, SEARCH_OBJECT_PROPERTY_OWNER_KIND, type SearchIndexInput, type SearchIndexObjectHit, type SearchIndexProgressEvent, type SearchIndexProgressPhase, type SearchIndexProgressReporter, type SearchIndexQueryResult, type SearchIndexStatus, type SearchIndexTextHit, type SearchObjectPropertyKind, type SearchObjectPropertyOwnerKind, type SearchSessionDescriptor, type SearchSessionInput, type SearchSessionPage, type SentenceGroupRecord, type SentenceId, type SentenceRecord, type SerialDiscoveryItem, SerialFragments, type SerialProgressEvent, type SerialRecord, SerialStore, SerialTextStream, type SerialsDiscoveredEvent, type SnakeChunkRecord, SnakeChunkStore, type SnakeEdgeRecord, SnakeEdgeStore, type SnakeRecord, SnakeStore, TEXT_SENTENCE_KIND, TOC_FILE_VERSION, type TestWikispineRuntimeOptions, type TextSentenceKind, TextStreams, WIKI_GRAPH_CONTEXT_VERSION, WIKI_GRAPH_EDITOR_SCOPES, WIKI_GRAPH_JOB_URI_PREFIX, WIKI_GRAPH_READER_SCOPES, WIKI_GRAPH_SCOPES, WIKI_GRAPH_URI_PREFIX, WikiGraph, WikiGraphArchive, WikiGraphArchiveFile, type WikiGraphLLMOptions, type WikiGraphOpenSessionOptions, type WikiGraphOperation, type WikiGraphOptions, type WikiGraphProgressCallback, type WikiGraphProgressEvent, type WikiGraphProgressEventType, WikiGraphScope, type WikiGraphSerialEntry, type WikiGraphSourceSessionOptions, WikiGraphTask, WikiGraphTaskContext, type WikiGraphTaskContextOptions, type WikiGraphTaskIdentity, type WikiGraphTaskType, type WikiGraphTextStreamSessionOptions, type WikimatchAcceptedMention, type WikimatchCandidate, type WikimatchCandidateOptionNarrowingFallback, type WikimatchCandidateOptionNarrowingItemOutput, type WikimatchCandidateOptionNarrowingResponse, type WikimatchCandidateOptionNarrowingResult, type WikimatchConflictGroup, type WikimatchPolicyContinuation, type WikimatchPolicyDecision, type WikimatchPolicyDecisionOutput, type WikimatchPolicyFallback, type WikimatchPolicyJudgeInput, type WikimatchPolicyJudgeResult, type WikimatchPolicyResponse, type WikimatchPolicyUpdate, type WikimatchProtectedSurface, type WikimatchQidOption, type WikimatchSentence, type WikimatchSurface, type WikimatchSurfaceProtectionBuildResult, type WikimatchSurfaceProtectionFallback, type WikimatchSurfaceProtectionInput, type WikimatchSurfaceProtectionResponse, type WikimatchSurfaceProtectionResult, type WikimatchTextRange, type WikimatchWindow, WikimediaClient, WikipageCache, WikipageResolver, type WikipageResolverOptions, type WikipageSitelink, type WikispineProvider, type WikispineRuntimeTestResult, addChapter, advanceChapterStages, applyChapterTree, applyQidResolutions, buildChapterGraphArtifact, buildChapterKnowledgeGraphArtifact, buildChapterSummaryArtifact, buildChapterSummaryArtifactFromSnapshot, buildWikimatchSurfaceProtectionInput, buildWikimatchWindows, clearChapterKnowledgeGraph, clearDirtyArchiveSearchIndex, commitChapterGraphArtifact, commitChapterKnowledgeGraphArtifact, commitChapterSummaryArtifact, countWikimatchCandidateOptions, countWikimatchQidOption, createArchiveSearchIndexFingerprint, createContinuationCursor, createDefaultWikiGraphSampling, createDisambiguationProfileNormalizer, createEnrichmentProgressReporter, createEnv, createSearchIndexFingerprint, createSearchSession, createWikiGraphTaskId, createWikiGraphTempDirectory, deleteArchiveSearchSessions, enrichWikimatchCandidates, ensureSearchIndex, ensureSharedStateDatabaseInitialized, expandRangeByWords, expectChunkImportance, expectChunkRetention, filterCandidateQidOptions, findArchiveObjects, findGraphPath, formatCandidateForPrompt, formatChapterId, formatEdgeId, formatError, formatEvidenceSelectionChoicePrompt, formatLanguageForPrompt, formatLocatedChapterResourceUri, formatLocatedChapterSourceCollectionUri, formatLocatedChapterUri, formatLocatedWikiGraphUri, formatNodeId, formatSummaryId, formatWikiGraphCommandUri, generateChapterGraph, generateChapterKnowledgeGraphArtifact, generateChapterKnowledgeGraphArtifactFromSnapshot, generateChapterSummary, getArchiveIndex, getChapterDetails, getChapterTree, getGraphEvidence, getGraphNode, getGraphStatus, getLanguageCode, getWikipageLanguageCode, grepArchiveObjects, groundWikimatchCandidates, isArchiveSearchIndexCurrent, isChunkImportance, isChunkRetention, isSearchIndexCurrent, isWikiGraphJobUri, isWikiGraphUri, judgeWikimatchPolicy, judgeWikimatchSurfaceProtection, listAllArchiveLinks, listArchiveCollection, listArchiveEvidence, listArchiveLinks, listArchiveObjects, listCandidateSelectableQids, listChapters, listGraphNeighbors, listGraphNodes, listRelatedArchiveObjects, listWordBoundaries, matchWikispineSentenceCandidates, migrateLegacySdpubToWikg, moveChapter, narrowWikimatchCandidateOptions, normalizeEvidenceDisplayText, normalizeEvidenceText, normalizeLanguageCode, openSharedStateDatabase, packArchiveContext, parseChapterTreeInput, parseLocatedWikiGraphUri, parseNarrowingResponse, parsePolicyResponse, parseRetryAfterMs, parseSurfaceProtectionResponse, querySearchIndex, rankEvidenceQuote, readArchiveIndexSettings, readArchivePage, readArchiveSearchIndexStatus, readArchiveText, readCachedSearchSessionPage, readChapterBuildInput, readContinuationCursor, readSearchIndexFingerprintFromDatabase, readSearchIndexStatus, readWikgArchiveFormatVersion, rebuildArchiveSearchIndex, removeChapter, requireArchiveUri, requireLocatedObjectOrArchiveUri, requireLocatedObjectUri, resetChapter, resolveDataDirPath, resolveEvidenceSelection, resolveEvidenceSelectionList, resolveWikiGraphCoreDatabasePath, resolveWikiGraphHomeDirectoryPath, resolveWikiGraphStateRootPath, runSearchCacheGc, scoreEvidenceQuote, searchGraphNodes, setChapterSource, setChapterSummary, setChapterTitle, setFtsIndexEmbedded, sliceCandidateByOptionBudget, snapshotChapterKnowledgeGraphInput, snapshotChapterSummaryInput, splitCandidateByOptionBudget, suppressContainedRanges, testWikispineRuntime, validateNarrowingResponse, validatePolicyResponse, validateSurfaceProtectionResponse, withLoggingContext, writeWikgArchive };
2569
+ declare const WIKG_OBJECT_SCHEMA_VERSION = 1;
2570
+ type WikgObject = WikgMetaObject | WikgParameterObject | WikgSourceFragmentObject | WikgReadingChunkObject | WikgReadingEdgeObject | WikgFragmentGroupObject | WikgSnakeObject | WikgSnakeChunkObject | WikgSnakeEdgeObject | WikgSummaryObject | WikgMentionObject | WikgMentionLinkObject | WikgEndObject;
2571
+ interface WikgMetaObject {
2572
+ readonly type: "meta";
2573
+ readonly schemaVersion: typeof WIKG_OBJECT_SCHEMA_VERSION;
2574
+ readonly chapterId: number;
2575
+ readonly stream: "knowledge-graph" | "reading-graph" | "summary";
2576
+ }
2577
+ interface WikgParameterObject {
2578
+ readonly type: "parameter";
2579
+ readonly scope: "knowledge-graph" | "reading-graph" | "summary";
2580
+ readonly language?: string;
2581
+ readonly prompt: string;
2582
+ }
2583
+ interface WikgSourceFragmentObject {
2584
+ readonly type: "source-fragment";
2585
+ readonly fragmentId: number;
2586
+ readonly summary: string;
2587
+ readonly sentences: readonly SentenceRecord[];
2588
+ }
2589
+ interface WikgReadingChunkObject {
2590
+ readonly type: "reading-chunk";
2591
+ readonly id: string;
2592
+ readonly generation: number;
2593
+ readonly sentenceIndex: number;
2594
+ readonly label: string;
2595
+ readonly content: string;
2596
+ readonly sentenceIndexes: readonly number[];
2597
+ readonly retention?: ChunkRetention;
2598
+ readonly importance?: ChunkImportance;
2599
+ readonly wordsCount: number;
2600
+ readonly weight: number;
2601
+ }
2602
+ interface WikgReadingEdgeObject {
2603
+ readonly type: "reading-edge";
2604
+ readonly fromChunkId: string;
2605
+ readonly toChunkId: string;
2606
+ readonly strength?: string;
2607
+ readonly weight: number;
2608
+ }
2609
+ interface WikgFragmentGroupObject {
2610
+ readonly type: "fragment-group";
2611
+ readonly groupId: number;
2612
+ readonly startSentenceIndex: number;
2613
+ readonly endSentenceIndex: number;
2614
+ }
2615
+ interface WikgSnakeObject {
2616
+ readonly type: "snake";
2617
+ readonly id: string;
2618
+ readonly groupId: number;
2619
+ readonly localSnakeId: number;
2620
+ readonly size: number;
2621
+ readonly firstLabel: string;
2622
+ readonly lastLabel: string;
2623
+ readonly wordsCount: number;
2624
+ readonly weight: number;
2625
+ }
2626
+ interface WikgSnakeChunkObject {
2627
+ readonly type: "snake-chunk";
2628
+ readonly snakeId: string;
2629
+ readonly chunkId: string;
2630
+ readonly position: number;
2631
+ }
2632
+ interface WikgSnakeEdgeObject {
2633
+ readonly type: "snake-edge";
2634
+ readonly fromSnakeId: string;
2635
+ readonly toSnakeId: string;
2636
+ readonly weight: number;
2637
+ }
2638
+ interface WikgSummaryObject {
2639
+ readonly type: "summary";
2640
+ readonly text: string;
2641
+ }
2642
+ interface WikgMentionObject {
2643
+ readonly type: "mention";
2644
+ readonly id: string;
2645
+ readonly fragmentId?: number;
2646
+ readonly sentenceIndex?: number;
2647
+ readonly rangeStart: number;
2648
+ readonly rangeEnd: number;
2649
+ readonly surface: string;
2650
+ readonly qid: string;
2651
+ readonly confidence?: number;
2652
+ readonly note?: string;
2653
+ }
2654
+ interface WikgMentionLinkObject {
2655
+ readonly type: "mention-link";
2656
+ readonly id: string;
2657
+ readonly sourceMentionId: string;
2658
+ readonly targetMentionId: string;
2659
+ readonly predicate: string;
2660
+ readonly evidenceSentenceIndexes: readonly number[];
2661
+ readonly confidence?: number;
2662
+ readonly note?: string;
2663
+ }
2664
+ interface WikgEndObject {
2665
+ readonly type: "end";
2666
+ }
2667
+ interface ChapterKnowledgeGraphObjects {
2668
+ readonly mentionLinks: readonly MentionLinkRecord[];
2669
+ readonly mentions: readonly MentionRecord[];
2670
+ readonly parameter?: WikgParameterObject;
2671
+ }
2672
+ declare function parseWikgObject(record: unknown): WikgObject;
2673
+ declare function writeWikgObjectsToJsonl(path: string, objects: AsyncIterable<WikgObject> | Iterable<WikgObject>): Promise<void>;
2674
+ declare function readWikgObjectsFromJsonl(path: string): AsyncGenerator<WikgObject>;
2675
+ declare function createChapterKnowledgeGraphObjectStream(input: {
2676
+ readonly chapterId: number;
2677
+ readonly mentionLinks: AsyncIterable<MentionLinkRecord> | Iterable<MentionLinkRecord>;
2678
+ readonly mentions: AsyncIterable<MentionRecord> | Iterable<MentionRecord>;
2679
+ readonly parameter?: {
2680
+ readonly language?: string;
2681
+ readonly prompt: string;
2682
+ };
2683
+ }): AsyncGenerator<WikgObject>;
2684
+ declare function collectChapterKnowledgeGraphObjects(chapterId: number, objects: AsyncIterable<WikgObject> | Iterable<WikgObject>): Promise<ChapterKnowledgeGraphObjects>;
2685
+ declare function createChapterReadingGraphObjectStream(input: {
2686
+ readonly chapterId: number;
2687
+ readonly document: ReadonlyDocument;
2688
+ readonly parameter?: {
2689
+ readonly language?: string;
2690
+ readonly prompt: string;
2691
+ };
2692
+ }): AsyncGenerator<WikgObject>;
2693
+ declare function collectReadingGraphObjects(chapterId: number, objects: AsyncIterable<WikgObject> | Iterable<WikgObject>): Promise<{
2694
+ readonly chunks: readonly WikgReadingChunkObject[];
2695
+ readonly fragmentGroups: readonly WikgFragmentGroupObject[];
2696
+ readonly fragments: readonly FragmentRecord[];
2697
+ readonly parameter?: WikgParameterObject;
2698
+ readonly readingEdges: readonly WikgReadingEdgeObject[];
2699
+ readonly snakeChunks: readonly WikgSnakeChunkObject[];
2700
+ readonly snakeEdges: readonly WikgSnakeEdgeObject[];
2701
+ readonly snakes: readonly WikgSnakeObject[];
2702
+ }>;
2703
+ declare function createSummaryInputSnapshotFromReadingGraphObjects(chapterId: number, objects: AsyncIterable<WikgObject> | Iterable<WikgObject>): Promise<SummaryInputSnapshotData>;
2704
+
2705
+ export { AddBuildJobOptions, type AddChapterOptions, type AdvanceChapterStagesOptions, type AdvanceChapterStagesProgressCallback, type AdvanceChapterStagesProgressEvent, type AdvanceChapterStagesResult, type ArchiveBacklinkBucket, type ArchiveBacklinks, type ArchiveCollectionOptions, type ArchiveCollectionResult, type ArchiveCollectionType, type ArchiveEvidence, type ArchiveEvidenceItem, type ArchiveFindEvidencePreview, type ArchiveFindField, type ArchiveFindFilterType, type ArchiveFindHit, type ArchiveFindObjectType, type ArchiveFindOptions, type ArchiveFindOrder, type ArchiveFindPosition, type ArchiveFindResult, type ArchiveIndex, type ArchiveLibrarySource, type ArchiveListItem, type ArchiveListKind, type ArchiveNodeLabel, type ArchiveNodeSourceFragment, type ArchiveObjectType, type ArchivePack, type ArchivePage, type ArchiveRelatedResult, type ArchiveTriplePattern, type BookMeta, type BuildChapterGraphArtifactOptions, type BuildChapterKnowledgeGraphArtifactOptions, type BuildChapterSummaryArtifactOptions, BuildJob, BuildJobConflictScope, BuildJobEvent, BuildJobListOptions, BuildJobProgressReporter, BuildJobState, BuildJobTarget, type BuildWikimatchWindowsOptions, CHAPTER_STAGES, CLI_FULL_COMMAND, CLI_PRIMARY_COMMAND, type CachedDisambiguationRecord, type CachedPageRecord, type CachedQidRecord, type ChapterDetails, type ChapterEntry, type ChapterGraphBuildArtifact, type ChapterKnowledgeGraphBuildArtifact, type ChapterKnowledgeGraphInputSnapshot, type ChapterStage, type ChapterTree, type ChapterTreeApplyResult, type ChapterTreeInput, type ChapterTreeInputNode, type ChapterTreeMoveChange, type ChapterTreeNode, type ChapterTreeTitleChange, type ContinuationCursor, DEFAULT_EXTRACTION_PROMPT, DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT, DEFAULT_WIKISPINE_FETCH_ENDPOINT, Database, type DigestProgressEvent, DirectoryDocument, type DisambiguationExpansion, type DisambiguationLinkedQid, type DisambiguationMeaningPriority, type DisambiguationPageText, type DisambiguationProfile, type DisambiguationProfileError, type DisambiguationProfileMeaning, type DisambiguationProfileNormalizer, type DisambiguationProfileNormalizerInput, type Document, EVIDENCE_SELECTION_JSON_SHAPE, EVIDENCE_SELECTION_PROMPT_FRAGMENT, type EnrichmentStore, type EvidenceQuoteMatchStrategy, type EvidenceQuoteScore, type EvidenceSelection, type EvidenceSelectionCandidate, type EvidenceSelectionFailure, type EvidenceSelectionList, type EvidenceSelectionResolution, type EvidenceSelectionSentence, type EvidenceSentenceId, type GenerateChapterGraphOptions, type GenerateChapterSummaryOptions, type GuaranteedRequest, type GuaranteedRequestController, type JudgeWikimatchPolicyOptions, LLM, type LLMOptions, LLMPaymentRequiredError, type LLMRequestOptions, type LLMStreamProgressCallback, type LLMTokenUsage, type LLMTokenUsageCallback, type LLMessage, Language, LanguageCode, type LocatedWikiGraphUri, type MoveChapterOptions, ObjectMetadataKind, type ObjectMetadataTarget, type ParsedWikiGraphLibraryUri, type ParsedWikiGraphUri, type QidResolution, type QueryIndexScope, type QueryScope, RateLimiter, type ReadonlyDocument, type SerialDiscoveryItem, type SerialProgressEvent, type SerialsDiscoveredEvent, TOC_FILE_VERSION, WIKG_OBJECT_SCHEMA_VERSION, WIKI_GRAPH_CONTEXT_VERSION, WIKI_GRAPH_EDITOR_SCOPES, WIKI_GRAPH_JOB_URI_PREFIX, WIKI_GRAPH_READER_SCOPES, WIKI_GRAPH_SCOPES, WIKI_GRAPH_URI_PREFIX, type WikgObject, type WikiClient, WikiGraph, WikiGraphArchive, WikiGraphArchiveFile, type WikiGraphLLMOptions, type WikiGraphLibraryArchiveRecord, type WikiGraphLibraryIndexObjectHit, type WikiGraphLibraryIndexQueryResult, type WikiGraphLibraryIndexSource, type WikiGraphLibraryIndexState, type WikiGraphLibraryIndexStatus, type WikiGraphLibraryIndexTextHit, type WikiGraphLibraryRecord, type WikiGraphLibraryScanResult, type WikiGraphLibraryUpgradeResult, type WikiGraphMaintenanceUpgradeResult, type WikiGraphOpenSessionOptions, type WikiGraphOperation, type WikiGraphOptions, type WikiGraphProgressCallback, type WikiGraphProgressEvent, type WikiGraphProgressEventType, WikiGraphScope, type WikiGraphSerialEntry, type WikiGraphSourceSessionOptions, WikiGraphTask, WikiGraphTaskContext, type WikiGraphTaskContextOptions, type WikiGraphTaskIdentity, type WikiGraphTaskType, type WikiGraphTextStreamSessionOptions, type WikimatchAcceptedMention, type WikimatchCandidate, type WikimatchConflictGroup, type WikimatchPolicyDecision, type WikimatchPolicyDecisionOutput, type WikimatchPolicyFallback, type WikimatchPolicyJudgeInput, type WikimatchPolicyJudgeResult, type WikimatchPolicyResponse, type WikimatchPolicyUpdate, type WikimatchQidOption, type WikimatchTextRange, type WikimatchWindow, WikimediaClient, WikipageCache, WikipageResolver, type WikipageResolverOptions, type WikipageSitelink, type WikispineProvider, addBuildJob, addChapter, addWikiGraphLibraryArchive, advanceChapterStages, applyChapterTree, assertBuildJobInputRevision, assertNoActiveBuildJobConflicts, assertNoActiveBuildJobs, assertWikiGraphLibrarySchemaCurrent, boostBuildJob, buildChapterGraphArtifact, buildChapterKnowledgeGraphArtifact, buildChapterSummaryArtifact, buildChapterSummaryArtifactFromReadingGraphObjects, buildChapterSummaryArtifactFromSnapshot, buildWikimatchWindows, cancelBuildJob, cleanBuildJobs, clearChapterKnowledgeGraph, clearWikiGraphLibraryMetadata, collectChapterKnowledgeGraphObjects, collectReadingGraphObjects, commitChapterGraphArtifact, commitChapterKnowledgeGraphArtifact, commitChapterSummaryArtifact, createChapterKnowledgeGraphObjectStream, createChapterReadingGraphObjectStream, createContinuationCursor, createDefaultWikiGraphSampling, createDisambiguationProfileNormalizer, createEnrichmentProgressReporter, createEnv, createSummaryInputSnapshotFromReadingGraphObjects, createWikiGraphLibrary, createWikiGraphTaskId, createWikiGraphTempDirectory, deleteArchiveSearchSessions, deleteWikiGraphLibraryMetadataKey, disableWikiGraphLibraryIndex, ensureDefaultWikiGraphLibrary, ensureLibraryManagedArchiveHasNoSearchIndex, ensureWikiGraphArchiveSchemaCurrent, ensureWikiGraphHomeSchemaCurrent, finalizeWikiGraphLibraryArchiveWrite, findArchiveObjects, findWikiGraphLibraryArchiveMembers, findWikiGraphLibraryObjects, formatChapterId, formatChapterUri, formatEdgeId, formatError, formatEvidenceSelectionChoicePrompt, formatLanguageForPrompt, formatLocatedChapterResourceUri, formatLocatedChapterSourceCollectionUri, formatLocatedChapterUri, formatLocatedWikiGraphUri, formatNodeId, formatSummaryId, formatWikiGraphCommandUri, formatWikiGraphLibraryUri, generateChapterGraph, generateChapterKnowledgeGraphArtifact, generateChapterKnowledgeGraphArtifactFromSnapshot, generateChapterSummary, getArchiveIndex, getBuildJob, getChapterDetails, getChapterTree, getLanguageCode, getWikiGraphLibraryArchive, getWikiGraphLibraryArchiveById, getWikiGraphLibraryMetadata, getWikipageLanguageCode, grepArchiveObjects, groundWikimatchCandidates, isArchiveSearchIndexCurrent, isWikiGraphJobUri, isWikiGraphLibraryUri, isWikiGraphUri, judgeWikimatchPolicy, listAllArchiveLinks, listArchiveCollection, listArchiveEvidence, listArchiveLinks, listArchiveObjects, listBuildJobs, listChapters, listRelatedArchiveObjects, listRelatedWikiGraphLibraryObjects, listWikiGraphLibraries, listWikiGraphLibraryArchiveMembers, listWikiGraphLibraryArchives, listWikiGraphLibraryEvidence, listWikiGraphLibraryIndexArchiveIdsForObject, listWikiGraphLibraryObjects, listWikiGraphLibraryScope, markWikiGraphLibraryIndexDirty, migrateLegacySdpubToWikg, moveChapter, moveWikiGraphLibraryArchive, normalizeEvidenceDisplayText, normalizeEvidenceText, normalizeLanguageCode, openSharedStateDatabase, packArchiveContext, packWikiGraphLibraryContext, parseChapterPath, parseChapterTreeInput, parseChapterUriPath, parseLocatedWikiGraphUri, parsePolicyResponse, parseRetryAfterMs, parseWikgObject, parseWikiGraphLibraryUri, parseWikiGraphUriSyntax, pauseBuildJob, putWikiGraphLibraryMetadata, queryWikiGraphLibrarySearchIndex, rankEvidenceQuote, readArchiveIndexSettings, readArchivePage, readArchiveText, readBuildJobEvents, readChapterBuildInput, readContinuationCursor, readWikgArchiveFormatVersion, readWikgObjectsFromJsonl, readWikiGraphArchiveSchemaVersion, readWikiGraphHomeSchemaVersion, readWikiGraphLibraryIndexState, readWikiGraphLibraryPage, rebindWikiGraphLibrary, rebuildArchiveSearchIndex, rebuildWikiGraphLibraryIndex, recordBuildJobInputRevision, removeChapter, removeWikiGraphLibrary, removeWikiGraphLibraryArchive, replaceWikiGraphLibraryMetadata, requireArchiveUri, requireLocatedObjectOrArchiveUri, requireLocatedObjectUri, resetChapter, resolveBuildJobId, resolveChapterPath, resolveChapterPathReadonly, resolveDataDirPath, resolveDefaultWikiGraphLibraryDirectoryPath, resolveEvidenceSelection, resolveEvidenceSelectionList, resolveExtractionPrompt, resolveKnowledgeGraphRecallPrompt, resolveWikiGraphCoreDatabasePath, resolveWikiGraphHomeDirectoryPath, resolveWikiGraphLibrary, resolveWikiGraphLibraryArchivePath, resolveWikiGraphLibraryById, resolveWikiGraphLibraryQueryTargetById, resolveWikiGraphLibraryStagingDirectoryPath, resolveWikiGraphStateRootPath, resumeBuildJob, scanWikiGraphLibrary, scoreEvidenceQuote, setChapterSource, setChapterSummary, setChapterTitle, setFtsIndexEmbedded, snapshotChapterKnowledgeGraphInput, snapshotChapterSummaryInput, testWikispineRuntime, updateBuildJobTarget, upgradeWikiGraphArchiveSchema, upgradeWikiGraphLibrarySchema, upgradeWikiGraphMaintenanceTarget, validatePolicyResponse, withLoggingContext, withWikiGraphRuntimeEnvironment, withWikiGraphRuntimeStateDirectoryPath, writeWikgArchive, writeWikgObjectsToJsonl };