@qvac/core 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (586) hide show
  1. package/LICENSE.md +198 -0
  2. package/NOTICE.md +13 -0
  3. package/README.md +694 -0
  4. package/SECURITY.md +6 -0
  5. package/dist/assistant.bundle +47256 -0
  6. package/dist/assistant.cjs +18 -0
  7. package/dist/assistant.d.ts +8 -0
  8. package/dist/prebuilds-manifest.json +380 -0
  9. package/dist-lib/client.d.ts +2 -0
  10. package/dist-lib/client.js +1 -0
  11. package/dist-lib/index.d.ts +13 -0
  12. package/dist-lib/index.js +10 -0
  13. package/dist-lib/lib/agent-icons.d.ts +3 -0
  14. package/dist-lib/lib/agent-icons.js +1 -0
  15. package/dist-lib/lib/api/agents.d.ts +5 -0
  16. package/dist-lib/lib/api/agents.js +38 -0
  17. package/dist-lib/lib/api/app-config.d.ts +5 -0
  18. package/dist-lib/lib/api/app-config.js +108 -0
  19. package/dist-lib/lib/api/approval-rules.d.ts +3 -0
  20. package/dist-lib/lib/api/approval-rules.js +9 -0
  21. package/dist-lib/lib/api/attachments.d.ts +8 -0
  22. package/dist-lib/lib/api/attachments.js +15 -0
  23. package/dist-lib/lib/api/chat-groups.d.ts +5 -0
  24. package/dist-lib/lib/api/chat-groups.js +12 -0
  25. package/dist-lib/lib/api/chat.d.ts +5 -0
  26. package/dist-lib/lib/api/chat.js +38 -0
  27. package/dist-lib/lib/api/chunks.d.ts +5 -0
  28. package/dist-lib/lib/api/chunks.js +61 -0
  29. package/dist-lib/lib/api/config.d.ts +5 -0
  30. package/dist-lib/lib/api/config.js +15 -0
  31. package/dist-lib/lib/api/current-mesh.d.ts +5 -0
  32. package/dist-lib/lib/api/current-mesh.js +12 -0
  33. package/dist-lib/lib/api/custom-models.d.ts +5 -0
  34. package/dist-lib/lib/api/custom-models.js +45 -0
  35. package/dist-lib/lib/api/devices.d.ts +8 -0
  36. package/dist-lib/lib/api/devices.js +125 -0
  37. package/dist-lib/lib/api/diagnostics.d.ts +7 -0
  38. package/dist-lib/lib/api/diagnostics.js +7 -0
  39. package/dist-lib/lib/api/effective-ctx-size.d.ts +2 -0
  40. package/dist-lib/lib/api/effective-ctx-size.js +10 -0
  41. package/dist-lib/lib/api/execution.d.ts +3 -0
  42. package/dist-lib/lib/api/execution.js +45 -0
  43. package/dist-lib/lib/api/files.d.ts +3 -0
  44. package/dist-lib/lib/api/files.js +48 -0
  45. package/dist-lib/lib/api/index.d.ts +62 -0
  46. package/dist-lib/lib/api/index.js +172 -0
  47. package/dist-lib/lib/api/instrument.d.ts +2 -0
  48. package/dist-lib/lib/api/instrument.js +86 -0
  49. package/dist-lib/lib/api/knowledge.d.ts +8 -0
  50. package/dist-lib/lib/api/knowledge.js +26 -0
  51. package/dist-lib/lib/api/logs.d.ts +14 -0
  52. package/dist-lib/lib/api/logs.js +116 -0
  53. package/dist-lib/lib/api/mesh.d.ts +13 -0
  54. package/dist-lib/lib/api/mesh.js +25 -0
  55. package/dist-lib/lib/api/model-download.d.ts +5 -0
  56. package/dist-lib/lib/api/model-download.js +47 -0
  57. package/dist-lib/lib/api/network.d.ts +8 -0
  58. package/dist-lib/lib/api/network.js +6 -0
  59. package/dist-lib/lib/api/notifications.d.ts +21 -0
  60. package/dist-lib/lib/api/notifications.js +108 -0
  61. package/dist-lib/lib/api/rag.d.ts +7 -0
  62. package/dist-lib/lib/api/rag.js +216 -0
  63. package/dist-lib/lib/api/sync.d.ts +3 -0
  64. package/dist-lib/lib/api/sync.js +6 -0
  65. package/dist-lib/lib/api/tool-activity.d.ts +5 -0
  66. package/dist-lib/lib/api/tool-activity.js +53 -0
  67. package/dist-lib/lib/api/tool-configs.d.ts +6 -0
  68. package/dist-lib/lib/api/tool-configs.js +27 -0
  69. package/dist-lib/lib/api/watchable.d.ts +12 -0
  70. package/dist-lib/lib/api/watchable.js +121 -0
  71. package/dist-lib/lib/assistant-client.d.ts +21 -0
  72. package/dist-lib/lib/assistant-client.js +52 -0
  73. package/dist-lib/lib/assistant-tree.d.ts +50 -0
  74. package/dist-lib/lib/assistant-tree.js +184 -0
  75. package/dist-lib/lib/assistant.d.ts +425 -0
  76. package/dist-lib/lib/assistant.js +2706 -0
  77. package/dist-lib/lib/audio-format.d.ts +4 -0
  78. package/dist-lib/lib/audio-format.js +4 -0
  79. package/dist-lib/lib/chat-title.d.ts +5 -0
  80. package/dist-lib/lib/chat-title.js +58 -0
  81. package/dist-lib/lib/client.d.ts +25 -0
  82. package/dist-lib/lib/client.js +53 -0
  83. package/dist-lib/lib/collabora/convert.d.ts +9 -0
  84. package/dist-lib/lib/collabora/convert.js +62 -0
  85. package/dist-lib/lib/collabora/entry.d.ts +1 -0
  86. package/dist-lib/lib/collabora/entry.js +44 -0
  87. package/dist-lib/lib/collabora/protocol.d.ts +15 -0
  88. package/dist-lib/lib/collabora/protocol.js +24 -0
  89. package/dist-lib/lib/collabora/worker.d.ts +5 -0
  90. package/dist-lib/lib/collabora/worker.js +111 -0
  91. package/dist-lib/lib/compaction.d.ts +30 -0
  92. package/dist-lib/lib/compaction.js +95 -0
  93. package/dist-lib/lib/constants.d.ts +4 -0
  94. package/dist-lib/lib/constants.js +4 -0
  95. package/dist-lib/lib/core/agent.d.ts +15 -0
  96. package/dist-lib/lib/core/agent.js +149 -0
  97. package/dist-lib/lib/core/app-build.d.ts +7 -0
  98. package/dist-lib/lib/core/app-build.js +1 -0
  99. package/dist-lib/lib/core/approval-rules.d.ts +15 -0
  100. package/dist-lib/lib/core/approval-rules.js +41 -0
  101. package/dist-lib/lib/core/async-iterable.d.ts +13 -0
  102. package/dist-lib/lib/core/async-iterable.js +65 -0
  103. package/dist-lib/lib/core/attachment-link.d.ts +7 -0
  104. package/dist-lib/lib/core/attachment-link.js +6 -0
  105. package/dist-lib/lib/core/audio-attachment.d.ts +1 -0
  106. package/dist-lib/lib/core/audio-attachment.js +4 -0
  107. package/dist-lib/lib/core/blind-peers.d.ts +6 -0
  108. package/dist-lib/lib/core/blind-peers.js +13 -0
  109. package/dist-lib/lib/core/chat-activity.d.ts +7 -0
  110. package/dist-lib/lib/core/chat-activity.js +244 -0
  111. package/dist-lib/lib/core/chat-group.d.ts +14 -0
  112. package/dist-lib/lib/core/chat-group.js +79 -0
  113. package/dist-lib/lib/core/chat-search.d.ts +17 -0
  114. package/dist-lib/lib/core/chat-search.js +199 -0
  115. package/dist-lib/lib/core/chat.d.ts +37 -0
  116. package/dist-lib/lib/core/chat.js +196 -0
  117. package/dist-lib/lib/core/chunk.d.ts +61 -0
  118. package/dist-lib/lib/core/chunk.js +212 -0
  119. package/dist-lib/lib/core/contract/activity.d.ts +11 -0
  120. package/dist-lib/lib/core/contract/activity.js +45 -0
  121. package/dist-lib/lib/core/contract/agents.d.ts +2 -0
  122. package/dist-lib/lib/core/contract/agents.js +29 -0
  123. package/dist-lib/lib/core/contract/approval-rules.d.ts +2 -0
  124. package/dist-lib/lib/core/contract/approval-rules.js +14 -0
  125. package/dist-lib/lib/core/contract/attestations.d.ts +2 -0
  126. package/dist-lib/lib/core/contract/attestations.js +14 -0
  127. package/dist-lib/lib/core/contract/chat-group.d.ts +2 -0
  128. package/dist-lib/lib/core/contract/chat-group.js +20 -0
  129. package/dist-lib/lib/core/contract/chat.d.ts +2 -0
  130. package/dist-lib/lib/core/contract/chat.js +18 -0
  131. package/dist-lib/lib/core/contract/chunks.d.ts +2 -0
  132. package/dist-lib/lib/core/contract/chunks.js +156 -0
  133. package/dist-lib/lib/core/contract/devices.d.ts +2 -0
  134. package/dist-lib/lib/core/contract/devices.js +110 -0
  135. package/dist-lib/lib/core/contract/index.d.ts +2 -0
  136. package/dist-lib/lib/core/contract/index.js +30 -0
  137. package/dist-lib/lib/core/contract/indexing.d.ts +4 -0
  138. package/dist-lib/lib/core/contract/indexing.js +82 -0
  139. package/dist-lib/lib/core/contract/knowledge.d.ts +2 -0
  140. package/dist-lib/lib/core/contract/knowledge.js +55 -0
  141. package/dist-lib/lib/core/contract/members.d.ts +2 -0
  142. package/dist-lib/lib/core/contract/members.js +96 -0
  143. package/dist-lib/lib/core/contract/seed-defaults.d.ts +2 -0
  144. package/dist-lib/lib/core/contract/seed-defaults.js +29 -0
  145. package/dist-lib/lib/core/contract/tool-activity.d.ts +2 -0
  146. package/dist-lib/lib/core/contract/tool-activity.js +25 -0
  147. package/dist-lib/lib/core/contract/tool-configs.d.ts +2 -0
  148. package/dist-lib/lib/core/contract/tool-configs.js +50 -0
  149. package/dist-lib/lib/core/contract/types.d.ts +11 -0
  150. package/dist-lib/lib/core/contract/types.js +1 -0
  151. package/dist-lib/lib/core/contract/writers.d.ts +2 -0
  152. package/dist-lib/lib/core/contract/writers.js +112 -0
  153. package/dist-lib/lib/core/cpu-info-node.d.ts +3 -0
  154. package/dist-lib/lib/core/cpu-info-node.js +2 -0
  155. package/dist-lib/lib/core/departures.d.ts +41 -0
  156. package/dist-lib/lib/core/departures.js +145 -0
  157. package/dist-lib/lib/core/device-attestation.d.ts +6 -0
  158. package/dist-lib/lib/core/device-attestation.js +12 -0
  159. package/dist-lib/lib/core/devices.d.ts +14 -0
  160. package/dist-lib/lib/core/devices.js +11 -0
  161. package/dist-lib/lib/core/document-attachment.d.ts +22 -0
  162. package/dist-lib/lib/core/document-attachment.js +35 -0
  163. package/dist-lib/lib/core/files/attachments.d.ts +8 -0
  164. package/dist-lib/lib/core/files/attachments.js +50 -0
  165. package/dist-lib/lib/core/files/index.d.ts +133 -0
  166. package/dist-lib/lib/core/files/index.js +585 -0
  167. package/dist-lib/lib/core/files/knowledge.d.ts +9 -0
  168. package/dist-lib/lib/core/files/knowledge.js +31 -0
  169. package/dist-lib/lib/core/files/preview/image.d.ts +4 -0
  170. package/dist-lib/lib/core/files/preview/image.js +42 -0
  171. package/dist-lib/lib/core/files/preview/index.d.ts +33 -0
  172. package/dist-lib/lib/core/files/preview/index.js +161 -0
  173. package/dist-lib/lib/core/files/processing/claims.d.ts +26 -0
  174. package/dist-lib/lib/core/files/processing/claims.js +89 -0
  175. package/dist-lib/lib/core/files/processing/document.d.ts +100 -0
  176. package/dist-lib/lib/core/files/processing/document.js +101 -0
  177. package/dist-lib/lib/core/files/processing/index.d.ts +75 -0
  178. package/dist-lib/lib/core/files/processing/index.js +295 -0
  179. package/dist-lib/lib/core/files/processing/ownership.d.ts +11 -0
  180. package/dist-lib/lib/core/files/processing/ownership.js +41 -0
  181. package/dist-lib/lib/core/files/processing/protocol.d.ts +29 -0
  182. package/dist-lib/lib/core/files/processing/protocol.js +70 -0
  183. package/dist-lib/lib/core/files/processing/settle.d.ts +10 -0
  184. package/dist-lib/lib/core/files/processing/settle.js +75 -0
  185. package/dist-lib/lib/core/files/processing/source.d.ts +36 -0
  186. package/dist-lib/lib/core/files/processing/source.js +96 -0
  187. package/dist-lib/lib/core/files/processing/state.d.ts +64 -0
  188. package/dist-lib/lib/core/files/processing/state.js +118 -0
  189. package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +3 -0
  190. package/dist-lib/lib/core/files/rag/artifact/codec.js +172 -0
  191. package/dist-lib/lib/core/files/rag/artifact/id.d.ts +10 -0
  192. package/dist-lib/lib/core/files/rag/artifact/id.js +39 -0
  193. package/dist-lib/lib/core/files/rag/artifact/types.d.ts +24 -0
  194. package/dist-lib/lib/core/files/rag/artifact/types.js +41 -0
  195. package/dist-lib/lib/core/files/rag/build.d.ts +25 -0
  196. package/dist-lib/lib/core/files/rag/build.js +60 -0
  197. package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +12 -0
  198. package/dist-lib/lib/core/files/rag/chunk/chunking.js +117 -0
  199. package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +30 -0
  200. package/dist-lib/lib/core/files/rag/chunk/metadata.js +89 -0
  201. package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +7 -0
  202. package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +18 -0
  203. package/dist-lib/lib/core/files/rag/document-types.d.ts +11 -0
  204. package/dist-lib/lib/core/files/rag/document-types.js +94 -0
  205. package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +1 -0
  206. package/dist-lib/lib/core/files/rag/extract/csv-text.js +117 -0
  207. package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +22 -0
  208. package/dist-lib/lib/core/files/rag/extract/document-types.js +152 -0
  209. package/dist-lib/lib/core/files/rag/extract/extract.d.ts +17 -0
  210. package/dist-lib/lib/core/files/rag/extract/extract.js +81 -0
  211. package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +1 -0
  212. package/dist-lib/lib/core/files/rag/extract/html-table-text.js +125 -0
  213. package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +1 -0
  214. package/dist-lib/lib/core/files/rag/extract/html-text.js +132 -0
  215. package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +2 -0
  216. package/dist-lib/lib/core/files/rag/extract/office-collabora.js +8 -0
  217. package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +17 -0
  218. package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +141 -0
  219. package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +12 -0
  220. package/dist-lib/lib/core/files/rag/extract/pdf-text.js +43 -0
  221. package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +1 -0
  222. package/dist-lib/lib/core/files/rag/extract/rtf-text.js +15 -0
  223. package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +1 -0
  224. package/dist-lib/lib/core/files/rag/extract/text-decoding.js +91 -0
  225. package/dist-lib/lib/core/files/rag/extract/types.d.ts +36 -0
  226. package/dist-lib/lib/core/files/rag/extract/types.js +12 -0
  227. package/dist-lib/lib/core/files/rag/extract/utf.d.ts +2 -0
  228. package/dist-lib/lib/core/files/rag/extract/utf.js +18 -0
  229. package/dist-lib/lib/core/files/rag/index.d.ts +54 -0
  230. package/dist-lib/lib/core/files/rag/index.js +79 -0
  231. package/dist-lib/lib/core/files/rag/limits.d.ts +2 -0
  232. package/dist-lib/lib/core/files/rag/limits.js +2 -0
  233. package/dist-lib/lib/core/files/rag/load.d.ts +28 -0
  234. package/dist-lib/lib/core/files/rag/load.js +250 -0
  235. package/dist-lib/lib/core/files/rag/models.d.ts +1 -0
  236. package/dist-lib/lib/core/files/rag/models.js +1 -0
  237. package/dist-lib/lib/core/files/rag/policy.d.ts +2 -0
  238. package/dist-lib/lib/core/files/rag/policy.js +23 -0
  239. package/dist-lib/lib/core/files/rag/produce.d.ts +21 -0
  240. package/dist-lib/lib/core/files/rag/produce.js +214 -0
  241. package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +2 -0
  242. package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +16 -0
  243. package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +4 -0
  244. package/dist-lib/lib/core/files/rag/retrieval/coverage.js +48 -0
  245. package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +10 -0
  246. package/dist-lib/lib/core/files/rag/retrieval/diversity.js +37 -0
  247. package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +5 -0
  248. package/dist-lib/lib/core/files/rag/retrieval/floor.js +21 -0
  249. package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +6 -0
  250. package/dist-lib/lib/core/files/rag/retrieval/format.js +21 -0
  251. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +22 -0
  252. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +137 -0
  253. package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +2 -0
  254. package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +53 -0
  255. package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +16 -0
  256. package/dist-lib/lib/core/files/rag/retrieval/notices.js +27 -0
  257. package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +8 -0
  258. package/dist-lib/lib/core/files/rag/retrieval/scoring.js +82 -0
  259. package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +3 -0
  260. package/dist-lib/lib/core/files/rag/retrieval/search.js +46 -0
  261. package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +10 -0
  262. package/dist-lib/lib/core/files/rag/retrieval/selection.js +63 -0
  263. package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +6 -0
  264. package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +79 -0
  265. package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +13 -0
  266. package/dist-lib/lib/core/files/rag/retrieval/sources.js +20 -0
  267. package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +13 -0
  268. package/dist-lib/lib/core/files/rag/retrieval/target.js +89 -0
  269. package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +8 -0
  270. package/dist-lib/lib/core/files/rag/retrieval/terms.js +70 -0
  271. package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +28 -0
  272. package/dist-lib/lib/core/files/rag/retrieval/types.js +1 -0
  273. package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +8 -0
  274. package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +41 -0
  275. package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +1 -0
  276. package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +96 -0
  277. package/dist-lib/lib/core/files/rag/vector/memory.d.ts +15 -0
  278. package/dist-lib/lib/core/files/rag/vector/memory.js +135 -0
  279. package/dist-lib/lib/core/files/rag/vector/types.d.ts +28 -0
  280. package/dist-lib/lib/core/files/rag/vector/types.js +1 -0
  281. package/dist-lib/lib/core/files/records/chunks.d.ts +3 -0
  282. package/dist-lib/lib/core/files/records/chunks.js +12 -0
  283. package/dist-lib/lib/core/files/records/index.d.ts +10 -0
  284. package/dist-lib/lib/core/files/records/index.js +8 -0
  285. package/dist-lib/lib/core/files/records/knowledge.d.ts +22 -0
  286. package/dist-lib/lib/core/files/records/knowledge.js +105 -0
  287. package/dist-lib/lib/core/files/records/linkage.d.ts +11 -0
  288. package/dist-lib/lib/core/files/records/linkage.js +27 -0
  289. package/dist-lib/lib/core/files/records/output.d.ts +8 -0
  290. package/dist-lib/lib/core/files/records/output.js +38 -0
  291. package/dist-lib/lib/core/files/records/reclaim.d.ts +5 -0
  292. package/dist-lib/lib/core/files/records/reclaim.js +73 -0
  293. package/dist-lib/lib/core/files/records/routing.d.ts +23 -0
  294. package/dist-lib/lib/core/files/records/routing.js +62 -0
  295. package/dist-lib/lib/core/files/records/source.d.ts +16 -0
  296. package/dist-lib/lib/core/files/records/source.js +70 -0
  297. package/dist-lib/lib/core/files/records/sweep.d.ts +2 -0
  298. package/dist-lib/lib/core/files/records/sweep.js +30 -0
  299. package/dist-lib/lib/core/files/store/blob.d.ts +29 -0
  300. package/dist-lib/lib/core/files/store/blob.js +98 -0
  301. package/dist-lib/lib/core/files/store/index.d.ts +36 -0
  302. package/dist-lib/lib/core/files/store/index.js +89 -0
  303. package/dist-lib/lib/core/files/store/inline.d.ts +8 -0
  304. package/dist-lib/lib/core/files/store/inline.js +38 -0
  305. package/dist-lib/lib/core/files/store/reference.d.ts +27 -0
  306. package/dist-lib/lib/core/files/store/reference.js +168 -0
  307. package/dist-lib/lib/core/files/store/server.d.ts +27 -0
  308. package/dist-lib/lib/core/files/store/server.js +114 -0
  309. package/dist-lib/lib/core/files/store/sweep.d.ts +2 -0
  310. package/dist-lib/lib/core/files/store/sweep.js +45 -0
  311. package/dist-lib/lib/core/files/upload-input.d.ts +27 -0
  312. package/dist-lib/lib/core/files/upload-input.js +52 -0
  313. package/dist-lib/lib/core/files/upload.d.ts +32 -0
  314. package/dist-lib/lib/core/files/upload.js +201 -0
  315. package/dist-lib/lib/core/fs-drives.d.ts +18 -0
  316. package/dist-lib/lib/core/fs-drives.js +58 -0
  317. package/dist-lib/lib/core/gpu-info-node.d.ts +3 -0
  318. package/dist-lib/lib/core/gpu-info-node.js +2 -0
  319. package/dist-lib/lib/core/handoff-channel.d.ts +46 -0
  320. package/dist-lib/lib/core/handoff-channel.js +102 -0
  321. package/dist-lib/lib/core/health-assistant.d.ts +7 -0
  322. package/dist-lib/lib/core/health-assistant.js +24 -0
  323. package/dist-lib/lib/core/helpers/index.d.ts +5 -0
  324. package/dist-lib/lib/core/helpers/index.js +74 -0
  325. package/dist-lib/lib/core/hosted-agents.d.ts +36 -0
  326. package/dist-lib/lib/core/hosted-agents.js +127 -0
  327. package/dist-lib/lib/core/id.d.ts +1 -0
  328. package/dist-lib/lib/core/id.js +5 -0
  329. package/dist-lib/lib/core/identity.d.ts +14 -0
  330. package/dist-lib/lib/core/identity.js +45 -0
  331. package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -0
  332. package/dist-lib/lib/core/image/cache-sweep.js +67 -0
  333. package/dist-lib/lib/core/image/normalize.d.ts +3 -0
  334. package/dist-lib/lib/core/image/normalize.js +49 -0
  335. package/dist-lib/lib/core/image/sniff.d.ts +3 -0
  336. package/dist-lib/lib/core/image/sniff.js +149 -0
  337. package/dist-lib/lib/core/invite.d.ts +14 -0
  338. package/dist-lib/lib/core/invite.js +36 -0
  339. package/dist-lib/lib/core/local/index.d.ts +71 -0
  340. package/dist-lib/lib/core/local/index.js +391 -0
  341. package/dist-lib/lib/core/membership.d.ts +15 -0
  342. package/dist-lib/lib/core/membership.js +40 -0
  343. package/dist-lib/lib/core/mesh.d.ts +153 -0
  344. package/dist-lib/lib/core/mesh.js +509 -0
  345. package/dist-lib/lib/core/migrations/agent-catalog.d.ts +6 -0
  346. package/dist-lib/lib/core/migrations/agent-catalog.js +17 -0
  347. package/dist-lib/lib/core/migrations/index.d.ts +5 -0
  348. package/dist-lib/lib/core/migrations/index.js +7 -0
  349. package/dist-lib/lib/core/migrations/membership.d.ts +11 -0
  350. package/dist-lib/lib/core/migrations/membership.js +26 -0
  351. package/dist-lib/lib/core/min-version.d.ts +6 -0
  352. package/dist-lib/lib/core/min-version.js +31 -0
  353. package/dist-lib/lib/core/next-frame.d.ts +6 -0
  354. package/dist-lib/lib/core/next-frame.js +27 -0
  355. package/dist-lib/lib/core/notification.d.ts +6 -0
  356. package/dist-lib/lib/core/notification.js +162 -0
  357. package/dist-lib/lib/core/ota-config.d.ts +19 -0
  358. package/dist-lib/lib/core/ota-config.js +44 -0
  359. package/dist-lib/lib/core/prompt-history.d.ts +12 -0
  360. package/dist-lib/lib/core/prompt-history.js +40 -0
  361. package/dist-lib/lib/core/search-fold.d.ts +1 -0
  362. package/dist-lib/lib/core/search-fold.js +4 -0
  363. package/dist-lib/lib/core/secret-handoff.d.ts +17 -0
  364. package/dist-lib/lib/core/secret-handoff.js +29 -0
  365. package/dist-lib/lib/core/send.d.ts +18 -0
  366. package/dist-lib/lib/core/send.js +46 -0
  367. package/dist-lib/lib/core/skill-overlay-handoff.d.ts +25 -0
  368. package/dist-lib/lib/core/skill-overlay-handoff.js +50 -0
  369. package/dist-lib/lib/core/skill-overlay-receiver.d.ts +8 -0
  370. package/dist-lib/lib/core/skill-overlay-receiver.js +20 -0
  371. package/dist-lib/lib/core/skill-secrets.d.ts +25 -0
  372. package/dist-lib/lib/core/skill-secrets.js +79 -0
  373. package/dist-lib/lib/core/sync/chats.d.ts +3 -0
  374. package/dist-lib/lib/core/sync/chats.js +5 -0
  375. package/dist-lib/lib/core/sync/chunks.d.ts +9 -0
  376. package/dist-lib/lib/core/sync/chunks.js +16 -0
  377. package/dist-lib/lib/core/sync/devices.d.ts +4 -0
  378. package/dist-lib/lib/core/sync/devices.js +12 -0
  379. package/dist-lib/lib/core/sync/files.d.ts +16 -0
  380. package/dist-lib/lib/core/sync/files.js +109 -0
  381. package/dist-lib/lib/core/sync/index.d.ts +5 -0
  382. package/dist-lib/lib/core/sync/index.js +63 -0
  383. package/dist-lib/lib/core/sync-status.d.ts +17 -0
  384. package/dist-lib/lib/core/sync-status.js +129 -0
  385. package/dist-lib/lib/core/system-info.d.ts +24 -0
  386. package/dist-lib/lib/core/system-info.js +66 -0
  387. package/dist-lib/lib/core/tool-activity.d.ts +22 -0
  388. package/dist-lib/lib/core/tool-activity.js +39 -0
  389. package/dist-lib/lib/core/tool-configs.d.ts +13 -0
  390. package/dist-lib/lib/core/tool-configs.js +141 -0
  391. package/dist-lib/lib/core.d.ts +291 -0
  392. package/dist-lib/lib/core.js +2126 -0
  393. package/dist-lib/lib/credential-pusher.d.ts +67 -0
  394. package/dist-lib/lib/credential-pusher.js +290 -0
  395. package/dist-lib/lib/custom-model-pusher.d.ts +9 -0
  396. package/dist-lib/lib/custom-model-pusher.js +42 -0
  397. package/dist-lib/lib/custom-model-source.d.ts +15 -0
  398. package/dist-lib/lib/custom-model-source.js +46 -0
  399. package/dist-lib/lib/deadline.d.ts +9 -0
  400. package/dist-lib/lib/deadline.js +31 -0
  401. package/dist-lib/lib/diagnostics.d.ts +35 -0
  402. package/dist-lib/lib/diagnostics.js +14 -0
  403. package/dist-lib/lib/fetch-node.d.ts +1 -0
  404. package/dist-lib/lib/fetch-node.js +1 -0
  405. package/dist-lib/lib/fs-drive-bridge.d.ts +12 -0
  406. package/dist-lib/lib/fs-drive-bridge.js +186 -0
  407. package/dist-lib/lib/fs-grant-keys.d.ts +2 -0
  408. package/dist-lib/lib/fs-grant-keys.js +6 -0
  409. package/dist-lib/lib/fs-grants.d.ts +10 -0
  410. package/dist-lib/lib/fs-grants.js +44 -0
  411. package/dist-lib/lib/image-cache-dir.d.ts +1 -0
  412. package/dist-lib/lib/image-cache-dir.js +5 -0
  413. package/dist-lib/lib/integrations/index.d.ts +4 -0
  414. package/dist-lib/lib/integrations/index.js +3 -0
  415. package/dist-lib/lib/integrations/mcp-providers.d.ts +12 -0
  416. package/dist-lib/lib/integrations/mcp-providers.js +22 -0
  417. package/dist-lib/lib/integrations/oauth-providers.d.ts +14 -0
  418. package/dist-lib/lib/integrations/oauth-providers.js +116 -0
  419. package/dist-lib/lib/integrations/setup-routes.d.ts +12 -0
  420. package/dist-lib/lib/integrations/setup-routes.js +114 -0
  421. package/dist-lib/lib/knowledge-search.d.ts +7 -0
  422. package/dist-lib/lib/knowledge-search.js +53 -0
  423. package/dist-lib/lib/kv-cache-reclaim.d.ts +5 -0
  424. package/dist-lib/lib/kv-cache-reclaim.js +29 -0
  425. package/dist-lib/lib/kv-cache.d.ts +18 -0
  426. package/dist-lib/lib/kv-cache.js +33 -0
  427. package/dist-lib/lib/legacy-core-domain.d.ts +258 -0
  428. package/dist-lib/lib/legacy-core-domain.js +1 -0
  429. package/dist-lib/lib/llm-model-names.d.ts +1 -0
  430. package/dist-lib/lib/llm-model-names.js +1 -0
  431. package/dist-lib/lib/log-buffer.d.ts +7 -0
  432. package/dist-lib/lib/log-buffer.js +16 -0
  433. package/dist-lib/lib/log-levels.d.ts +7 -0
  434. package/dist-lib/lib/log-levels.js +1 -0
  435. package/dist-lib/lib/log.d.ts +60 -0
  436. package/dist-lib/lib/log.js +149 -0
  437. package/dist-lib/lib/logger-type.d.ts +13 -0
  438. package/dist-lib/lib/logger-type.js +1 -0
  439. package/dist-lib/lib/logger.d.ts +5 -0
  440. package/dist-lib/lib/logger.js +18 -0
  441. package/dist-lib/lib/model-catalog-revision.d.ts +9 -0
  442. package/dist-lib/lib/model-catalog-revision.js +65 -0
  443. package/dist-lib/lib/model-clamp.d.ts +6 -0
  444. package/dist-lib/lib/model-clamp.js +20 -0
  445. package/dist-lib/lib/model-context.d.ts +13 -0
  446. package/dist-lib/lib/model-context.js +71 -0
  447. package/dist-lib/lib/model-download-status.d.ts +29 -0
  448. package/dist-lib/lib/model-download-status.js +56 -0
  449. package/dist-lib/lib/model-download.d.ts +191 -0
  450. package/dist-lib/lib/model-download.js +787 -0
  451. package/dist-lib/lib/oauth/asana.d.ts +35 -0
  452. package/dist-lib/lib/oauth/asana.js +71 -0
  453. package/dist-lib/lib/oauth/browser-connect.d.ts +22 -0
  454. package/dist-lib/lib/oauth/browser-connect.js +83 -0
  455. package/dist-lib/lib/oauth/client.d.ts +9 -0
  456. package/dist-lib/lib/oauth/client.js +9 -0
  457. package/dist-lib/lib/oauth/common.d.ts +38 -0
  458. package/dist-lib/lib/oauth/common.js +36 -0
  459. package/dist-lib/lib/oauth/crypto.d.ts +3 -0
  460. package/dist-lib/lib/oauth/crypto.js +25 -0
  461. package/dist-lib/lib/oauth/fetch-platform.d.ts +1 -0
  462. package/dist-lib/lib/oauth/fetch-platform.js +1 -0
  463. package/dist-lib/lib/oauth/flow-core.d.ts +6 -0
  464. package/dist-lib/lib/oauth/flow-core.js +37 -0
  465. package/dist-lib/lib/oauth/flow.d.ts +3 -0
  466. package/dist-lib/lib/oauth/flow.js +24 -0
  467. package/dist-lib/lib/oauth/google.d.ts +37 -0
  468. package/dist-lib/lib/oauth/google.js +77 -0
  469. package/dist-lib/lib/oauth/host.d.ts +5 -0
  470. package/dist-lib/lib/oauth/host.js +3 -0
  471. package/dist-lib/lib/oauth/keys.d.ts +25 -0
  472. package/dist-lib/lib/oauth/keys.js +93 -0
  473. package/dist-lib/lib/oauth/loopback.d.ts +3 -0
  474. package/dist-lib/lib/oauth/loopback.js +119 -0
  475. package/dist-lib/lib/oauth/loopback.stub.d.ts +3 -0
  476. package/dist-lib/lib/oauth/loopback.stub.js +6 -0
  477. package/dist-lib/lib/oauth/notion.d.ts +34 -0
  478. package/dist-lib/lib/oauth/notion.js +82 -0
  479. package/dist-lib/lib/oauth/pkce-runtime.d.ts +3 -0
  480. package/dist-lib/lib/oauth/pkce-runtime.js +5 -0
  481. package/dist-lib/lib/oauth/pkce.d.ts +8 -0
  482. package/dist-lib/lib/oauth/pkce.js +6 -0
  483. package/dist-lib/lib/oauth/providers.d.ts +5 -0
  484. package/dist-lib/lib/oauth/providers.js +73 -0
  485. package/dist-lib/lib/oauth/redirect-types.d.ts +19 -0
  486. package/dist-lib/lib/oauth/redirect-types.js +1 -0
  487. package/dist-lib/lib/oauth/register.d.ts +3 -0
  488. package/dist-lib/lib/oauth/register.js +34 -0
  489. package/dist-lib/lib/oauth/resolve.d.ts +17 -0
  490. package/dist-lib/lib/oauth/resolve.js +57 -0
  491. package/dist-lib/lib/oauth/spotify.d.ts +32 -0
  492. package/dist-lib/lib/oauth/spotify.js +73 -0
  493. package/dist-lib/lib/oauth/token-exchange-core.d.ts +6 -0
  494. package/dist-lib/lib/oauth/token-exchange-core.js +97 -0
  495. package/dist-lib/lib/oauth/token-exchange.d.ts +5 -0
  496. package/dist-lib/lib/oauth/token-exchange.js +9 -0
  497. package/dist-lib/lib/oauth/types.d.ts +54 -0
  498. package/dist-lib/lib/oauth/types.js +1 -0
  499. package/dist-lib/lib/oauth.client.d.ts +5 -0
  500. package/dist-lib/lib/oauth.client.js +2 -0
  501. package/dist-lib/lib/oauth.d.ts +14 -0
  502. package/dist-lib/lib/oauth.js +12 -0
  503. package/dist-lib/lib/obsidian-key.d.ts +1 -0
  504. package/dist-lib/lib/obsidian-key.js +1 -0
  505. package/dist-lib/lib/race-resource.d.ts +5 -0
  506. package/dist-lib/lib/race-resource.js +25 -0
  507. package/dist-lib/lib/reconnecting-watch.d.ts +2 -0
  508. package/dist-lib/lib/reconnecting-watch.js +78 -0
  509. package/dist-lib/lib/retry-budget.d.ts +14 -0
  510. package/dist-lib/lib/retry-budget.js +39 -0
  511. package/dist-lib/lib/run-notices.d.ts +23 -0
  512. package/dist-lib/lib/run-notices.js +33 -0
  513. package/dist-lib/lib/run-transcript.d.ts +35 -0
  514. package/dist-lib/lib/run-transcript.js +106 -0
  515. package/dist-lib/lib/skill-readiness.d.ts +2 -0
  516. package/dist-lib/lib/skill-readiness.js +21 -0
  517. package/dist-lib/lib/skill-types.d.ts +70 -0
  518. package/dist-lib/lib/skill-types.js +1 -0
  519. package/dist-lib/lib/spec-loader.d.ts +14 -0
  520. package/dist-lib/lib/spec-loader.js +9 -0
  521. package/dist-lib/lib/suspend-lifecycle.d.ts +17 -0
  522. package/dist-lib/lib/suspend-lifecycle.js +33 -0
  523. package/dist-lib/lib/task.d.ts +26 -0
  524. package/dist-lib/lib/task.js +69 -0
  525. package/dist-lib/lib/unref.d.ts +3 -0
  526. package/dist-lib/lib/unref.js +4 -0
  527. package/dist-lib/lib/wav-duration.d.ts +1 -0
  528. package/dist-lib/lib/wav-duration.js +53 -0
  529. package/dist-lib/lib/write-queue.d.ts +22 -0
  530. package/dist-lib/lib/write-queue.js +39 -0
  531. package/dist-lib/schema/build.d.ts +1 -0
  532. package/dist-lib/schema/build.js +120 -0
  533. package/dist-lib/schema/config.d.ts +4 -0
  534. package/dist-lib/schema/config.js +7 -0
  535. package/dist-lib/schema/content.d.ts +20 -0
  536. package/dist-lib/schema/content.js +122 -0
  537. package/dist-lib/schema/engine.d.ts +2 -0
  538. package/dist-lib/schema/engine.js +2013 -0
  539. package/dist-lib/schema/field-order.d.ts +1 -0
  540. package/dist-lib/schema/field-order.js +95 -0
  541. package/dist-lib/schema/local.d.ts +2 -0
  542. package/dist-lib/schema/local.js +133 -0
  543. package/dist-lib/schema/qvac.d.ts +22 -0
  544. package/dist-lib/schema/qvac.js +722 -0
  545. package/dist-lib/spec/bind.d.ts +2 -0
  546. package/dist-lib/spec/bind.js +520 -0
  547. package/dist-lib/spec/calls.d.ts +3 -0
  548. package/dist-lib/spec/calls.js +129 -0
  549. package/dist-lib/spec/capabilities.d.ts +263 -0
  550. package/dist-lib/spec/config/hyperconf/index.d.ts +15 -0
  551. package/dist-lib/spec/config/hyperconf/index.js +24 -0
  552. package/dist-lib/spec/config/hyperconf/package.json +3 -0
  553. package/dist-lib/spec/config/hyperschema/index.js +81 -0
  554. package/dist-lib/spec/config/hyperschema/schema.json +19 -0
  555. package/dist-lib/spec/hrpc/hrpc.json +1500 -0
  556. package/dist-lib/spec/hrpc/index.d.ts +3 -0
  557. package/dist-lib/spec/hrpc/index.js +1545 -0
  558. package/dist-lib/spec/hrpc/messages.d.ts +4 -0
  559. package/dist-lib/spec/hrpc/messages.js +8373 -0
  560. package/dist-lib/spec/hyperschema/index.d.ts +20 -0
  561. package/dist-lib/spec/hyperschema/index.js +8373 -0
  562. package/dist-lib/spec/hyperschema/schema.json +6202 -0
  563. package/dist-lib/spec/hyperschema/types.d.ts +1545 -0
  564. package/dist-lib/spec/index.d.ts +36 -0
  565. package/dist-lib/spec/index.js +6 -0
  566. package/dist-lib/spec/local/hyperdb/db.json +186 -0
  567. package/dist-lib/spec/local/hyperdb/index.d.ts +9 -0
  568. package/dist-lib/spec/local/hyperdb/index.js +855 -0
  569. package/dist-lib/spec/local/hyperdb/messages.js +2189 -0
  570. package/dist-lib/spec/local/hyperschema/index.js +1208 -0
  571. package/dist-lib/spec/local/hyperschema/schema.json +639 -0
  572. package/dist-lib/spec/local/hyperschema/types.d.ts +159 -0
  573. package/dist-lib/spec/mesh/hyperdb/db.json +702 -0
  574. package/dist-lib/spec/mesh/hyperdb/index.d.ts +9 -0
  575. package/dist-lib/spec/mesh/hyperdb/index.js +2260 -0
  576. package/dist-lib/spec/mesh/hyperdb/messages.js +7453 -0
  577. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +174 -0
  578. package/dist-lib/spec/mesh/hyperdispatch/index.d.ts +13 -0
  579. package/dist-lib/spec/mesh/hyperdispatch/index.js +566 -0
  580. package/dist-lib/spec/mesh/hyperdispatch/messages.js +5713 -0
  581. package/dist-lib/spec/mesh/hyperschema/index.d.ts +14 -0
  582. package/dist-lib/spec/mesh/hyperschema/index.js +5713 -0
  583. package/dist-lib/spec/mesh/hyperschema/schema.json +3142 -0
  584. package/dist-lib/spec/mesh/hyperschema/types.d.ts +754 -0
  585. package/ducks.png +0 -0
  586. package/package.json +332 -1
@@ -0,0 +1,81 @@
1
+ import { extractCsvText } from "./csv-text.js";
2
+ import { classifyRagDocument, RAG_DOCUMENT_KIND } from "./document-types.js";
3
+ import { extractHtmlText } from "./html-text.js";
4
+ import { extractPdfText } from "./pdf-text.js";
5
+ import { extractRtfText } from "./rtf-text.js";
6
+ import { decodeTextBytes } from "./text-decoding.js";
7
+ import { RAG_EXTRACT_ERROR_CODE, RagExtractError } from "./types.js";
8
+ export async function extractRagDocumentFromBytes(input, opts = {}) {
9
+ const fileName = input.fileName ?? input.title ?? input.sourcePath ?? 'document';
10
+ const kind = classifyRagDocument({
11
+ fileName,
12
+ bytes: input.bytes,
13
+ ...(input.mimeType ? { mimeType: input.mimeType } : {})
14
+ });
15
+ if (kind === RAG_DOCUMENT_KIND.unsupported) {
16
+ throw new RagExtractError(RAG_EXTRACT_ERROR_CODE.unsupportedFile, `Unsupported document type: ${fileName}`);
17
+ }
18
+ try {
19
+ const content = await extractText(kind, input.bytes, fileName, opts);
20
+ return buildDocumentInput(input, fileName, content);
21
+ }
22
+ catch (e) {
23
+ if (e instanceof RagExtractError)
24
+ throw e;
25
+ throw new RagExtractError(RAG_EXTRACT_ERROR_CODE.extractionFailed, errorMessage(e));
26
+ }
27
+ }
28
+ function buildDocumentInput(input, fileName, content) {
29
+ return {
30
+ title: input.title ?? fileNameFromPath(fileName),
31
+ content,
32
+ ...(input.id !== undefined ? { id: input.id } : {}),
33
+ ...(input.blobId !== undefined ? { blobId: input.blobId } : {}),
34
+ ...(input.sourcePath !== undefined ? { sourcePath: input.sourcePath } : {}),
35
+ ...(input.sourceUrl !== undefined ? { sourceUrl: input.sourceUrl } : {}),
36
+ ...(input.mimeType !== undefined ? { mimeType: input.mimeType } : {}),
37
+ ...(input.artifactId !== undefined ? { artifactId: input.artifactId } : {}),
38
+ ...(input.attachmentId !== undefined ? { attachmentId: input.attachmentId } : {}),
39
+ ...(input.messageId !== undefined ? { messageId: input.messageId } : {}),
40
+ ...(input.chatId !== undefined ? { chatId: input.chatId } : {})
41
+ };
42
+ }
43
+ async function extractText(kind, bytes, fileName, opts) {
44
+ if (kind === RAG_DOCUMENT_KIND.pdf) {
45
+ const extractPdf = opts.extractors?.pdf ?? extractPdfText;
46
+ try {
47
+ return await extractPdf(bytes);
48
+ }
49
+ catch (e) {
50
+ throw new Error(`PDF extraction failed: ${errorMessage(e)}`);
51
+ }
52
+ }
53
+ if (kind === RAG_DOCUMENT_KIND.office) {
54
+ const extractOffice = opts.extractors?.office;
55
+ if (!extractOffice) {
56
+ throw new RagExtractError(RAG_EXTRACT_ERROR_CODE.unsupportedFile, 'Office document extraction is not available on this device');
57
+ }
58
+ try {
59
+ return await extractOffice(bytes, fileName, { signal: opts.signal });
60
+ }
61
+ catch (e) {
62
+ throw new Error(`Office document extraction failed: ${errorMessage(e)}`);
63
+ }
64
+ }
65
+ const text = decodeTextBytes(bytes);
66
+ if (kind === RAG_DOCUMENT_KIND.rtf)
67
+ return extractRtfText(text);
68
+ if (kind === RAG_DOCUMENT_KIND.html)
69
+ return extractHtmlText(text);
70
+ if (kind === RAG_DOCUMENT_KIND.csv)
71
+ return extractCsvText(text);
72
+ if (kind === RAG_DOCUMENT_KIND.tsv)
73
+ return extractCsvText(text, '\t');
74
+ return text;
75
+ }
76
+ function fileNameFromPath(path) {
77
+ return path.split(/[\\/]/).filter(Boolean).pop() ?? path;
78
+ }
79
+ function errorMessage(error) {
80
+ return error instanceof Error ? error.message : String(error);
81
+ }
@@ -0,0 +1 @@
1
+ export declare function formatHtmlTables(source: string): string;
@@ -0,0 +1,125 @@
1
+ const TABLE_BLOCK = /<table\b[^>]*>[\s\S]*?<\/table\s*>/gi;
2
+ const CAPTION_BLOCK = /<caption\b[^>]*>([\s\S]*?)<\/caption\s*>/i;
3
+ const TABLE_TAG = /<\/?(tr|th|td)\b[^>]*>/gi;
4
+ const DROP_BLOCKS = /<(script|style|noscript|template|svg)\b[^>]*>[\s\S]*?<\/\1\s*>/gi;
5
+ const COMMENT = /<!--[\s\S]*?-->/g;
6
+ const BREAK_TAG = /<br\s*\/?>/gi;
7
+ const TAG = /<[^>]*>/g;
8
+ export function formatHtmlTables(source) {
9
+ return source.replace(TABLE_BLOCK, (table) => `\n\n${formatTable(table)}\n\n`);
10
+ }
11
+ function formatTable(table) {
12
+ const caption = extractCaption(table);
13
+ const rowsText = formatTableRows(table.replace(CAPTION_BLOCK, ' '));
14
+ return caption ? joinTableParts(caption, rowsText) : rowsText;
15
+ }
16
+ function extractCaption(table) {
17
+ const caption = normalizeCell(CAPTION_BLOCK.exec(table)?.[1] ?? '');
18
+ return caption.length > 0 ? caption : null;
19
+ }
20
+ function joinTableParts(caption, rowsText) {
21
+ return rowsText.length > 0 ? `${caption}\n\n${rowsText}` : caption;
22
+ }
23
+ function formatTableRows(table) {
24
+ const rows = parseRows(table).filter((row) => row.some((cell) => cell.text.length > 0));
25
+ const first = rows[0];
26
+ if (!first)
27
+ return normalizeCell(table);
28
+ if (!isColumnHeaderRow(first, rows.length))
29
+ return formatFlatRows(rows);
30
+ const headers = first.map((cell, index) => cell.text || `column_${index + 1}`);
31
+ const dataRows = rows
32
+ .slice(1)
33
+ .map((row) => formatDataRow(headers, row))
34
+ .filter((line) => line.length > 0);
35
+ return dataRows.length > 0
36
+ ? [`Columns: ${headers.join(', ')}`, ...dataRows].join('\n\n')
37
+ : formatFlatRows([first]);
38
+ }
39
+ function parseRows(table) {
40
+ const rows = [];
41
+ let row = null;
42
+ let cell = null;
43
+ let cursor = 0;
44
+ for (const match of table.matchAll(TABLE_TAG)) {
45
+ if (cell) {
46
+ cell.html += table.slice(cursor, match.index);
47
+ }
48
+ ;
49
+ ({ row, cell } = applyTableTag(rows, row, cell, match[0] ?? ''));
50
+ cursor = match.index + match[0].length;
51
+ }
52
+ if (cell) {
53
+ cell.html += table.slice(cursor);
54
+ }
55
+ finishRow(rows, row, cell);
56
+ return rows;
57
+ }
58
+ function applyTableTag(rows, row, cell, source) {
59
+ const tag = parseTableTag(source);
60
+ if (tag?.name === 'tr') {
61
+ return tag.closing ? finishRow(rows, row, cell) : startRow(rows, row, cell);
62
+ }
63
+ if (tag?.name === 'th' || tag?.name === 'td') {
64
+ return tag.closing ? finishCell(row, cell) : startCell(row, cell, tag.name === 'th');
65
+ }
66
+ return { row, cell };
67
+ }
68
+ function startRow(rows, row, cell) {
69
+ finishRow(rows, row, cell);
70
+ return { row: [], cell: null };
71
+ }
72
+ function startCell(row, cell, header) {
73
+ const state = finishCell(row, cell);
74
+ return { row: state.row ?? [], cell: { html: '', header } };
75
+ }
76
+ function finishRow(rows, row, cell) {
77
+ const state = finishCell(row, cell);
78
+ if (state.row && state.row.length > 0) {
79
+ rows.push(state.row);
80
+ }
81
+ return { row: null, cell: null };
82
+ }
83
+ function finishCell(row, cell) {
84
+ if (!cell)
85
+ return { row, cell: null };
86
+ const nextRow = row ?? [];
87
+ nextRow.push({ text: normalizeCell(cell.html), header: cell.header });
88
+ return { row: nextRow, cell: null };
89
+ }
90
+ function parseTableTag(tag) {
91
+ const match = /^<\s*(\/)?\s*(tr|th|td)\b/i.exec(tag);
92
+ return match ? { name: match[2] ?? '', closing: Boolean(match[1]) } : null;
93
+ }
94
+ function isColumnHeaderRow(row, rowCount) {
95
+ return rowCount > 1 && row.length >= 2 && row.every((cell) => cell.header);
96
+ }
97
+ function formatDataRow(headers, row) {
98
+ const parts = [];
99
+ const columnCount = Math.max(headers.length, row.length);
100
+ for (let index = 0; index < columnCount; index++) {
101
+ const value = row[index]?.text ?? '';
102
+ if (value.length === 0)
103
+ continue;
104
+ parts.push(`${headers[index] ?? `column_${index + 1}`}: ${value}`);
105
+ }
106
+ return parts.join(' | ');
107
+ }
108
+ function formatFlatRows(rows) {
109
+ return rows
110
+ .map((row) => row
111
+ .map((cell) => cell.text)
112
+ .filter((cell) => cell.length > 0)
113
+ .join(' | '))
114
+ .filter((line) => line.length > 0)
115
+ .join('\n');
116
+ }
117
+ function normalizeCell(html) {
118
+ return html
119
+ .replace(DROP_BLOCKS, ' ')
120
+ .replace(COMMENT, ' ')
121
+ .replace(BREAK_TAG, ' ')
122
+ .replace(TAG, ' ')
123
+ .replace(/\s+/g, ' ')
124
+ .trim();
125
+ }
@@ -0,0 +1 @@
1
+ export declare function extractHtmlText(source: string): string;
@@ -0,0 +1,132 @@
1
+ import { formatHtmlTables } from "./html-table-text.js";
2
+ const DROP_BLOCKS = /<(script|style|noscript|template|svg|head)\b[^>]*>[\s\S]*?<\/\1\s*>/gi;
3
+ const COMMENT = /<!--[\s\S]*?-->/g;
4
+ const HEADING_OPEN = /<h([1-6])\b[^>]*>/gi;
5
+ const HEADING_CLOSE = /<\/h[1-6]\s*>/gi;
6
+ const LIST_ITEM_OPEN = /<li\b[^>]*>/gi;
7
+ const LIST_ITEM_CLOSE = /<\/li\s*>/gi;
8
+ const TABLE_CELL_OPEN = /<t[hd]\b[^>]*>/gi;
9
+ const TABLE_CELL_CLOSE = /<\/t[hd]\s*>/gi;
10
+ const TABLE_ROW_OPEN = /<tr\b[^>]*>/gi;
11
+ const TABLE_ROW_CLOSE = /<\/tr\s*>/gi;
12
+ const BREAK_TAG = /<br\s*\/?>/gi;
13
+ const BLOCK_CONTAINER_TAGS = 'p|div|section|article|header|footer|main|aside|nav|blockquote|pre|figure|figcaption|ul|ol|table|thead|tbody|tfoot|address|form|fieldset';
14
+ const BLOCK_CLOSE = new RegExp(`</(${BLOCK_CONTAINER_TAGS})\\s*>`, 'gi');
15
+ const BLOCK_OPEN = new RegExp(`<(${BLOCK_CONTAINER_TAGS}|hr)\\b[^>]*>`, 'gi');
16
+ const STRAY_CLOSE_BRACKET = />/g;
17
+ const NAMED_ENTITIES = new Map([
18
+ ['amp', '&'],
19
+ ['lt', '<'],
20
+ ['gt', '>'],
21
+ ['quot', '"'],
22
+ ['apos', "'"],
23
+ ['nbsp', ' '],
24
+ ['copy', '©'],
25
+ ['reg', '®'],
26
+ ['trade', '™'],
27
+ ['hellip', '…'],
28
+ ['mdash', '—'],
29
+ ['ndash', '–'],
30
+ ['lsquo', '‘'],
31
+ ['rsquo', '’'],
32
+ ['ldquo', '“'],
33
+ ['rdquo', '”'],
34
+ ['middot', '·'],
35
+ ['bull', '•'],
36
+ ['deg', '°'],
37
+ ['times', '×'],
38
+ ['divide', '÷'],
39
+ ['plusmn', '±'],
40
+ ['laquo', '«'],
41
+ ['raquo', '»'],
42
+ ['euro', '€'],
43
+ ['pound', '£'],
44
+ ['yen', '¥'],
45
+ ['cent', '¢'],
46
+ ['sect', '§'],
47
+ ['para', '¶'],
48
+ ['iexcl', '¡'],
49
+ ['iquest', '¿'],
50
+ ['dagger', '†'],
51
+ ['Dagger', '‡'],
52
+ ['sbquo', '‚'],
53
+ ['bdquo', '„'],
54
+ ['prime', '′'],
55
+ ['Prime', '″'],
56
+ ['frac12', '½'],
57
+ ['frac14', '¼'],
58
+ ['frac34', '¾']
59
+ ]);
60
+ const NUMERIC_ENTITY = /&#(x[0-9a-fA-F]+|[0-9]+);/g;
61
+ const NAMED_ENTITY = /&([a-zA-Z][a-zA-Z0-9]+);/g;
62
+ export function extractHtmlText(source) {
63
+ const structured = markStructure(formatHtmlTables(dropNonContent(source)));
64
+ const text = stripTagsFully(structured);
65
+ return normalizeWhitespace(decodeEntities(text));
66
+ }
67
+ function dropNonContent(source) {
68
+ let previous = source;
69
+ let current = source.replace(DROP_BLOCKS, ' ').replace(COMMENT, ' ');
70
+ while (current !== previous) {
71
+ previous = current;
72
+ current = current.replace(DROP_BLOCKS, ' ').replace(COMMENT, ' ');
73
+ }
74
+ return current;
75
+ }
76
+ function stripTagsFully(source) {
77
+ let output = '';
78
+ let cursor = 0;
79
+ while (cursor < source.length) {
80
+ const open = source.indexOf('<', cursor);
81
+ if (open === -1) {
82
+ return output + stripStrayCloseBrackets(source.slice(cursor));
83
+ }
84
+ output += stripStrayCloseBrackets(source.slice(cursor, open));
85
+ const close = source.indexOf('>', open + 1);
86
+ if (close === -1) {
87
+ return `${output} `;
88
+ }
89
+ cursor = close + 1;
90
+ }
91
+ return output;
92
+ }
93
+ function stripStrayCloseBrackets(text) {
94
+ return text.replace(STRAY_CLOSE_BRACKET, ' ');
95
+ }
96
+ function markStructure(html) {
97
+ return html
98
+ .replace(HEADING_OPEN, (_match, level) => `\n\n${'#'.repeat(Number(level))} `)
99
+ .replace(HEADING_CLOSE, '\n\n')
100
+ .replace(TABLE_CELL_OPEN, ' | ')
101
+ .replace(TABLE_CELL_CLOSE, '')
102
+ .replace(TABLE_ROW_OPEN, '\n')
103
+ .replace(TABLE_ROW_CLOSE, '')
104
+ .replace(LIST_ITEM_OPEN, '\n- ')
105
+ .replace(LIST_ITEM_CLOSE, '')
106
+ .replace(BREAK_TAG, '\n')
107
+ .replace(BLOCK_OPEN, '\n\n')
108
+ .replace(BLOCK_CLOSE, '\n\n');
109
+ }
110
+ function decodeEntities(text) {
111
+ return text
112
+ .replace(NUMERIC_ENTITY, (_match, code) => {
113
+ const codePoint = code.startsWith('x') || code.startsWith('X')
114
+ ? Number.parseInt(code.slice(1), 16)
115
+ : Number.parseInt(code, 10);
116
+ return Number.isFinite(codePoint) && codePoint >= 0 && codePoint <= 0x10ffff
117
+ ? String.fromCodePoint(codePoint)
118
+ : '';
119
+ })
120
+ .replace(NAMED_ENTITY, (match, name) => NAMED_ENTITIES.get(name) ?? match);
121
+ }
122
+ function normalizeWhitespace(text) {
123
+ return text
124
+ .replace(/\r\n?/g, '\n')
125
+ .replace(/[ \t\f\v]+/g, ' ')
126
+ .replace(/[ \t]+\n/g, '\n')
127
+ .replace(/\n[ \t]+/g, '\n')
128
+ .replace(/^\| ?/gm, '')
129
+ .replace(/ \|\s*$/gm, '')
130
+ .replace(/\n{3,}/g, '\n\n')
131
+ .trim();
132
+ }
@@ -0,0 +1,2 @@
1
+ import type { RagFileExtractor } from './extract.ts';
2
+ export declare const extractOfficeText: RagFileExtractor;
@@ -0,0 +1,8 @@
1
+ import { convertToText } from "../../../../collabora/convert.js";
2
+ import { MAX_OFFICE_BYTES } from "../limits.js";
3
+ export const extractOfficeText = (bytes, fileName, opts) => {
4
+ if (bytes.byteLength > MAX_OFFICE_BYTES) {
5
+ throw new Error(`document is too large to convert: ${bytes.byteLength} bytes, limit ${MAX_OFFICE_BYTES}`);
6
+ }
7
+ return convertToText({ bytes, fileName, to: 'md', signal: opts?.signal });
8
+ };
@@ -0,0 +1,17 @@
1
+ export declare class BareTextDecoder {
2
+ readonly encoding: string;
3
+ readonly fatal: boolean;
4
+ readonly ignoreBOM: boolean;
5
+ constructor(label?: string, options?: {
6
+ fatal?: boolean;
7
+ ignoreBOM?: boolean;
8
+ });
9
+ decode(input?: ArrayBufferView | ArrayBuffer): string;
10
+ }
11
+ export declare class BareTextEncoder {
12
+ encode(input?: string): Uint8Array;
13
+ }
14
+ export declare function decodeBytes(bytes: Uint8Array, label: string, options?: {
15
+ fatal?: boolean;
16
+ ignoreBOM?: boolean;
17
+ }): string;
@@ -0,0 +1,141 @@
1
+ import b4a from 'b4a';
2
+ import { AbortController, AbortSignal } from 'bare-abort-controller';
3
+ import { ReadableStream } from 'web-streams-polyfill/dist/ponyfill.mjs';
4
+ import { decodeLatin1, decodeUtf16 } from "./utf.js";
5
+ const g = globalThis;
6
+ if (!g.ReadableStream)
7
+ g.ReadableStream = ReadableStream;
8
+ if (!g.DOMException) {
9
+ g.DOMException = class DOMException extends Error {
10
+ constructor(message, name = 'Error') {
11
+ super(message);
12
+ this.name = name;
13
+ }
14
+ };
15
+ }
16
+ export class BareTextDecoder {
17
+ encoding;
18
+ fatal;
19
+ ignoreBOM;
20
+ constructor(label = 'utf-8', options = {}) {
21
+ this.encoding = parseEncoding(label);
22
+ this.fatal = options.fatal === true;
23
+ this.ignoreBOM = options.ignoreBOM === true;
24
+ }
25
+ decode(input) {
26
+ if (input === undefined)
27
+ return '';
28
+ const bytes = ArrayBuffer.isView(input)
29
+ ? b4a.from(input.buffer, input.byteOffset, input.byteLength)
30
+ : b4a.from(input);
31
+ return decodeBytes(bytes, this.encoding, { fatal: this.fatal, ignoreBOM: this.ignoreBOM });
32
+ }
33
+ }
34
+ export class BareTextEncoder {
35
+ encode(input = '') {
36
+ return b4a.from(String(input), 'utf8');
37
+ }
38
+ }
39
+ if (!g.TextDecoder)
40
+ g.TextDecoder = BareTextDecoder;
41
+ if (!g.TextEncoder)
42
+ g.TextEncoder = BareTextEncoder;
43
+ export function decodeBytes(bytes, label, options = {}) {
44
+ const fatal = options.fatal === true;
45
+ const encoding = parseEncoding(label);
46
+ const text = encoding === 'utf-16le'
47
+ ? utf16(bytes, true, fatal)
48
+ : encoding === 'utf-16be'
49
+ ? utf16(bytes, false, fatal)
50
+ : encoding === 'latin1'
51
+ ? decodeLatin1(bytes)
52
+ : decodeUtf8(bytes, fatal);
53
+ return options.ignoreBOM || text.charCodeAt(0) !== 0xfeff ? text : text.slice(1);
54
+ }
55
+ function parseEncoding(label) {
56
+ const l = String(label).trim().toLowerCase();
57
+ if (l.includes('utf-16') || l.includes('utf16') || l === 'ucs-2' || l === 'ucs2') {
58
+ return l.includes('be') ? 'utf-16be' : 'utf-16le';
59
+ }
60
+ if (l.includes('latin1') || l.includes('8859'))
61
+ return 'latin1';
62
+ return 'utf-8';
63
+ }
64
+ function utf16(bytes, littleEndian, fatal) {
65
+ if (fatal && bytes.length % 2 !== 0)
66
+ throw new TypeError('truncated utf-16 sequence');
67
+ const text = decodeUtf16(bytes, littleEndian);
68
+ if (fatal)
69
+ assertPairedSurrogates(text);
70
+ return text;
71
+ }
72
+ function assertPairedSurrogates(text) {
73
+ for (let i = 0; i < text.length; i++) {
74
+ const unit = text.charCodeAt(i);
75
+ if (unit >= 0xd800 && unit <= 0xdbff) {
76
+ const low = text.charCodeAt(i + 1);
77
+ if (Number.isNaN(low) || low < 0xdc00 || low > 0xdfff) {
78
+ throw new TypeError('lone high surrogate');
79
+ }
80
+ i++;
81
+ }
82
+ else if (unit >= 0xdc00 && unit <= 0xdfff) {
83
+ throw new TypeError('lone low surrogate');
84
+ }
85
+ }
86
+ }
87
+ function decodeUtf8(bytes, fatal) {
88
+ if (fatal && !isValidUtf8(bytes))
89
+ throw new TypeError('invalid utf-8 sequence');
90
+ return b4a.toString(bytes, 'utf8');
91
+ }
92
+ function isValidUtf8(bytes) {
93
+ for (let i = 0; i < bytes.length;) {
94
+ const b0 = bytes[i];
95
+ if (b0 < 0x80) {
96
+ i++;
97
+ continue;
98
+ }
99
+ let size;
100
+ let min;
101
+ let cp;
102
+ if ((b0 & 0xe0) === 0xc0) {
103
+ size = 2;
104
+ min = 0x80;
105
+ cp = b0 & 0x1f;
106
+ }
107
+ else if ((b0 & 0xf0) === 0xe0) {
108
+ size = 3;
109
+ min = 0x800;
110
+ cp = b0 & 0x0f;
111
+ }
112
+ else if ((b0 & 0xf8) === 0xf0) {
113
+ size = 4;
114
+ min = 0x10000;
115
+ cp = b0 & 0x07;
116
+ }
117
+ else {
118
+ return false;
119
+ }
120
+ if (i + size > bytes.length)
121
+ return false;
122
+ for (let j = 1; j < size; j++) {
123
+ const bj = bytes[i + j];
124
+ if ((bj & 0xc0) !== 0x80)
125
+ return false;
126
+ cp = (cp << 6) | (bj & 0x3f);
127
+ }
128
+ if (cp < min || cp > 0x10ffff || (cp >= 0xd800 && cp <= 0xdfff))
129
+ return false;
130
+ i += size;
131
+ }
132
+ return true;
133
+ }
134
+ if (!g.AbortController) {
135
+ g.AbortController = AbortController;
136
+ g.AbortSignal = AbortSignal;
137
+ }
138
+ const clone = globalThis.structuredClone;
139
+ if (clone) {
140
+ g.structuredClone = (value, options) => clone(value, (options ?? undefined));
141
+ }
@@ -0,0 +1,12 @@
1
+ import './pdf-platform.ts';
2
+ export declare function extractPdfText(bytes: Uint8Array, options?: {
3
+ maxChars?: number;
4
+ }): Promise<string>;
5
+ export interface PdfHead {
6
+ readonly text: string;
7
+ readonly pagesRead: number;
8
+ readonly totalPages: number;
9
+ }
10
+ export declare function extractPdfHead(bytes: Uint8Array, { maxChars }?: {
11
+ maxChars?: number;
12
+ }): Promise<PdfHead>;
@@ -0,0 +1,43 @@
1
+ import "./pdf-platform.js";
2
+ import { getDocument } from 'unpdf/pdfjs';
3
+ export function extractPdfText(bytes, options = {}) {
4
+ return extractPdfHead(bytes, options).then((head) => head.text);
5
+ }
6
+ export async function extractPdfHead(bytes, { maxChars = Infinity } = {}) {
7
+ const pdf = await getDocument({
8
+ data: new Uint8Array(bytes),
9
+ disableFontFace: true,
10
+ isEvalSupported: false,
11
+ useSystemFonts: true,
12
+ verbosity: 0
13
+ }).promise;
14
+ try {
15
+ const pages = [];
16
+ let total = 0;
17
+ for (let pageNumber = 1; pageNumber <= pdf.numPages; pageNumber++) {
18
+ const page = await pdf.getPage(pageNumber);
19
+ const textContent = await page.getTextContent();
20
+ const pageText = textContent.items.map(textItem).filter(Boolean).join(' ');
21
+ pages.push(pageText);
22
+ total += pageText.length;
23
+ if (total > maxChars)
24
+ break;
25
+ }
26
+ const text = pages
27
+ .join('\n\n')
28
+ .replace(/[ \t]+\n/g, '\n')
29
+ .trim();
30
+ return { text, pagesRead: pages.length, totalPages: pdf.numPages };
31
+ }
32
+ finally {
33
+ await pdf.destroy();
34
+ }
35
+ }
36
+ function textItem(item) {
37
+ if (!isRecord(item) || typeof item.str !== 'string')
38
+ return '';
39
+ return item.str.trim();
40
+ }
41
+ function isRecord(value) {
42
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
43
+ }
@@ -0,0 +1 @@
1
+ export declare function extractRtfText(source: string): string;
@@ -0,0 +1,15 @@
1
+ const HEX_ESCAPE = /\\'([0-9a-fA-F]{2})/g;
2
+ const CONTROL_WORD = /\\[a-zA-Z]+-?\d* ?/g;
3
+ const CONTROL_SYMBOL = /\\[^a-zA-Z0-9]/g;
4
+ export function extractRtfText(source) {
5
+ return source
6
+ .replaceAll('\\par', '\n')
7
+ .replaceAll('\\line', '\n')
8
+ .replace(HEX_ESCAPE, (_match, hex) => String.fromCharCode(Number.parseInt(hex, 16)))
9
+ .replace(CONTROL_WORD, '')
10
+ .replace(CONTROL_SYMBOL, '')
11
+ .replace(/[{}]/g, '')
12
+ .replace(/[ \t]+\n/g, '\n')
13
+ .replace(/\n{3,}/g, '\n\n')
14
+ .trim();
15
+ }
@@ -0,0 +1 @@
1
+ export declare function decodeTextBytes(bytes: Uint8Array): string;