@ontos-ai/knowhere-claw 0.2.0 → 0.2.2-beta.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 (244) hide show
  1. package/README.md +1 -1
  2. package/dist/__tests__/channel-route.test.d.ts +1 -0
  3. package/dist/__tests__/ingest-tool.test.d.ts +1 -0
  4. package/dist/__tests__/kg-service-test-helper.d.ts +2 -0
  5. package/dist/__tests__/kg-service.test.d.ts +1 -0
  6. package/dist/__tests__/read-result-file-tool.test.d.ts +1 -0
  7. package/dist/__tests__/tracker-progress.test.d.ts +1 -0
  8. package/dist/_virtual/_rolldown/runtime.js +1 -35
  9. package/dist/channel-delivery.d.ts +21 -0
  10. package/dist/client.d.ts +33 -0
  11. package/dist/client.js +1 -1
  12. package/dist/config.d.ts +13 -0
  13. package/dist/connect-builder.d.ts +48 -0
  14. package/dist/connect-builder.js +1 -2
  15. package/dist/error-message.d.ts +1 -0
  16. package/dist/graph-builder.d.ts +75 -0
  17. package/dist/graph-builder.js +9 -5
  18. package/dist/index.d.ts +9 -0
  19. package/dist/kg-service.d.ts +38 -0
  20. package/dist/kg-service.js +39 -33
  21. package/dist/parser.d.ts +16 -0
  22. package/dist/parser.js +1 -1
  23. package/dist/session.d.ts +11 -0
  24. package/dist/store.d.ts +79 -0
  25. package/dist/text.d.ts +10 -0
  26. package/dist/tools.d.ts +10 -0
  27. package/dist/tools.js +123 -34
  28. package/dist/tracker-progress.d.ts +10 -0
  29. package/dist/types.d.ts +320 -0
  30. package/openclaw.plugin.json +1 -1
  31. package/package.json +3 -2
  32. package/skills/knowhere/SKILL.md +14 -9
  33. package/dist/node_modules/.pnpm/@knowhere-ai_sdk@0.1.1/node_modules/@knowhere-ai/sdk/dist/index.js +0 -717
  34. package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js +0 -212
  35. package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/pre-binding.js +0 -35
  36. package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/abi_crosswalk.js +0 -2609
  37. package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/napi.js +0 -142
  38. package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js +0 -103
  39. package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js +0 -199
  40. package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/package.js +0 -67
  41. package/dist/node_modules/.pnpm/abbrev@1.1.1/node_modules/abbrev/abbrev.js +0 -59
  42. package/dist/node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js +0 -11
  43. package/dist/node_modules/.pnpm/aproba@2.1.0/node_modules/aproba/index.js +0 -119
  44. package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/index.js +0 -13
  45. package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-base.js +0 -16
  46. package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-group.js +0 -98
  47. package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-stream.js +0 -37
  48. package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker.js +0 -32
  49. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/adapters.js +0 -83
  50. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/fetch.js +0 -170
  51. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/xhr.js +0 -106
  52. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/axios.js +0 -57
  53. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/CancelToken.js +0 -90
  54. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/CanceledError.js +0 -20
  55. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/isCancel.js +0 -6
  56. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/Axios.js +0 -174
  57. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/AxiosError.js +0 -70
  58. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/AxiosHeaders.js +0 -204
  59. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/InterceptorManager.js +0 -60
  60. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/buildFullPath.js +0 -20
  61. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/dispatchRequest.js +0 -52
  62. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/mergeConfig.js +0 -81
  63. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/settle.js +0 -18
  64. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/transformData.js +0 -25
  65. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/defaults/index.js +0 -107
  66. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/defaults/transitional.js +0 -9
  67. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/env/data.js +0 -4
  68. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -50
  69. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -77
  70. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/bind.js +0 -15
  71. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/buildURL.js +0 -40
  72. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/combineURLs.js +0 -14
  73. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/composeSignals.js +0 -39
  74. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/cookies.js +0 -31
  75. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/formDataToJSON.js +0 -67
  76. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -14
  77. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  78. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -8
  79. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/parseHeaders.js +0 -53
  80. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/parseProtocol.js +0 -7
  81. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/progressEventReducer.js +0 -38
  82. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/resolveConfig.js +0 -36
  83. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/speedometer.js +0 -36
  84. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/spread.js +0 -29
  85. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/throttle.js +0 -38
  86. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/toFormData.js +0 -151
  87. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -18
  88. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/trackStream.js +0 -69
  89. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/validator.js +0 -76
  90. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -4
  91. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -4
  92. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -5
  93. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/index.js +0 -22
  94. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/common/utils.js +0 -46
  95. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/index.js +0 -9
  96. package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/utils.js +0 -698
  97. package/dist/node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js +0 -53
  98. package/dist/node_modules/.pnpm/brace-expansion@1.1.12/node_modules/brace-expansion/index.js +0 -132
  99. package/dist/node_modules/.pnpm/color-support@1.1.3/node_modules/color-support/browser.js +0 -18
  100. package/dist/node_modules/.pnpm/concat-map@0.0.1/node_modules/concat-map/index.js +0 -19
  101. package/dist/node_modules/.pnpm/console-control-strings@1.1.0/node_modules/console-control-strings/index.js +0 -104
  102. package/dist/node_modules/.pnpm/delegates@1.0.0/node_modules/delegates/index.js +0 -104
  103. package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/detect-libc.js +0 -221
  104. package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/elf.js +0 -26
  105. package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js +0 -48
  106. package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js +0 -24
  107. package/dist/node_modules/.pnpm/emoji-regex@8.0.0/node_modules/emoji-regex/index.js +0 -10
  108. package/dist/node_modules/.pnpm/fflate@0.8.2/node_modules/fflate/esm/browser.js +0 -426
  109. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/copy-sync.js +0 -120
  110. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/copy.js +0 -100
  111. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/index.js +0 -15
  112. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/empty/index.js +0 -43
  113. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/file.js +0 -53
  114. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/index.js +0 -27
  115. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/link.js +0 -56
  116. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -89
  117. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -35
  118. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink.js +0 -81
  119. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/fs/index.js +0 -113
  120. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/index.js +0 -29
  121. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/index.js +0 -22
  122. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/jsonfile.js +0 -15
  123. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/output-json-sync.js +0 -15
  124. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/output-json.js +0 -15
  125. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/index.js +0 -20
  126. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -33
  127. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/utils.js +0 -17
  128. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/index.js +0 -15
  129. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/move-sync.js +0 -56
  130. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/move.js +0 -49
  131. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/output-file/index.js +0 -30
  132. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/path-exists/index.js +0 -18
  133. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/remove/index.js +0 -27
  134. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/async.js +0 -15
  135. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/stat.js +0 -131
  136. package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/utimes.js +0 -34
  137. package/dist/node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js +0 -51
  138. package/dist/node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js +0 -171
  139. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/base-theme.js +0 -21
  140. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/error.js +0 -27
  141. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/has-color.js +0 -9
  142. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/index.js +0 -224
  143. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/plumbing.js +0 -48
  144. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/process.js +0 -8
  145. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/progress-bar.js +0 -46
  146. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/render-template.js +0 -155
  147. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/set-immediate.js +0 -14
  148. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/set-interval.js +0 -8
  149. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/spin.js +0 -10
  150. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/template-item.js +0 -58
  151. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/theme-set.js +0 -99
  152. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/themes.js +0 -67
  153. package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/wide-truncate.js +0 -22
  154. package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/common.js +0 -162
  155. package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/glob.js +0 -451
  156. package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/sync.js +0 -280
  157. package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js +0 -20
  158. package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js +0 -362
  159. package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js +0 -92
  160. package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js +0 -255
  161. package/dist/node_modules/.pnpm/has-unicode@2.0.1/node_modules/has-unicode/index.js +0 -14
  162. package/dist/node_modules/.pnpm/inflight@1.0.6/node_modules/inflight/inflight.js +0 -45
  163. package/dist/node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js +0 -27
  164. package/dist/node_modules/.pnpm/is-fullwidth-code-point@3.0.0/node_modules/is-fullwidth-code-point/index.js +0 -14
  165. package/dist/node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/index.js +0 -68
  166. package/dist/node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/utils.js +0 -19
  167. package/dist/node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/dist/jszip.min.js +0 -3110
  168. package/dist/node_modules/.pnpm/minimatch@3.1.5/node_modules/minimatch/minimatch.js +0 -578
  169. package/dist/node_modules/.pnpm/nodejieba@2.6.0/node_modules/nodejieba/index.js +0 -46
  170. package/dist/node_modules/.pnpm/nopt@5.0.0/node_modules/nopt/lib/nopt.js +0 -330
  171. package/dist/node_modules/.pnpm/npmlog@5.0.1/node_modules/npmlog/log.js +0 -305
  172. package/dist/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +0 -54
  173. package/dist/node_modules/.pnpm/once@1.4.0/node_modules/once/once.js +0 -44
  174. package/dist/node_modules/.pnpm/path-is-absolute@1.0.1/node_modules/path-is-absolute/index.js +0 -19
  175. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/errors-browser.js +0 -88
  176. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_duplex.js +0 -75
  177. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_passthrough.js +0 -19
  178. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js +0 -666
  179. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_transform.js +0 -89
  180. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js +0 -423
  181. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/async_iterator.js +0 -172
  182. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -243
  183. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -77
  184. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -87
  185. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from-browser.js +0 -10
  186. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -80
  187. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/state.js +0 -21
  188. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -8
  189. package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/readable-browser.js +0 -23
  190. package/dist/node_modules/.pnpm/rimraf@3.0.2/node_modules/rimraf/rimraf.js +0 -229
  191. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js +0 -79
  192. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js +0 -282
  193. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js +0 -186
  194. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js +0 -14
  195. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js +0 -41
  196. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js +0 -34
  197. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js +0 -15
  198. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js +0 -11
  199. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js +0 -11
  200. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js +0 -32
  201. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js +0 -11
  202. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js +0 -11
  203. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js +0 -11
  204. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js +0 -22
  205. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js +0 -11
  206. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js +0 -11
  207. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js +0 -11
  208. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js +0 -11
  209. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js +0 -11
  210. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js +0 -19
  211. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js +0 -11
  212. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js +0 -14
  213. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js +0 -11
  214. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js +0 -11
  215. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js +0 -18
  216. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js +0 -11
  217. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js +0 -14
  218. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js +0 -99
  219. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js +0 -28
  220. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js +0 -8
  221. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js +0 -23
  222. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js +0 -36
  223. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js +0 -15
  224. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js +0 -84
  225. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js +0 -11
  226. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js +0 -15
  227. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js +0 -11
  228. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js +0 -31
  229. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js +0 -31
  230. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js +0 -45
  231. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js +0 -64
  232. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js +0 -35
  233. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js +0 -102
  234. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js +0 -11
  235. package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js +0 -17
  236. package/dist/node_modules/.pnpm/set-blocking@2.0.0/node_modules/set-blocking/index.js +0 -12
  237. package/dist/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +0 -130
  238. package/dist/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +0 -16
  239. package/dist/node_modules/.pnpm/string-width@4.2.3/node_modules/string-width/index.js +0 -30
  240. package/dist/node_modules/.pnpm/strip-ansi@6.0.1/node_modules/strip-ansi/index.js +0 -10
  241. package/dist/node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js +0 -26
  242. package/dist/node_modules/.pnpm/util-deprecate@1.0.2/node_modules/util-deprecate/browser.js +0 -59
  243. package/dist/node_modules/.pnpm/wide-align@1.1.5/node_modules/wide-align/align.js +0 -52
  244. package/dist/node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js +0 -26
package/README.md CHANGED
@@ -116,7 +116,7 @@ Within each scope, the plugin keeps:
116
116
  ## Common Workflow
117
117
 
118
118
  1. Provide a file path or URL to the agent.
119
- 2. The agent ingests it into Knowhere and waits for the parse to finish.
119
+ 2. The agent ingests it into Knowhere. By default this starts parsing asynchronously and returns a job ID; when the current turn needs the parsed result immediately, the agent can call `knowhere_ingest_document` with `blockUntilComplete: true`.
120
120
  3. Follow-up questions reuse stored results from the current scope.
121
121
  4. When needed, the agent can preview structure, search chunks, read raw result
122
122
  files, or clear stored documents.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { KnowledgeGraphService } from "../kg-service";
2
+ export declare function createKgServiceStub(): KnowledgeGraphService;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,38 +1,4 @@
1
1
  //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
2
  var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
9
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
- var __exportAll = (all, no_symbols) => {
11
- let target = {};
12
- for (var name in all) __defProp(target, name, {
13
- get: all[name],
14
- enumerable: true
15
- });
16
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
- return target;
18
- };
19
- var __copyProps = (to, from, except, desc) => {
20
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
- key = keys[i];
22
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
- get: ((k) => from[k]).bind(null, key),
24
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
- });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
32
- }) : target, mod));
33
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
34
- if (typeof require !== "undefined") return require.apply(this, arguments);
35
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
36
- });
37
3
  //#endregion
38
- export { __commonJSMin, __esmMin, __exportAll, __require, __toESM };
4
+ export { __esmMin };
@@ -0,0 +1,21 @@
1
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
2
+ import type { ChannelRouteRecord } from "./types";
3
+ type DeliverySurface = "discord" | "imessage" | "line" | "signal" | "slack" | "telegram" | "whatsapp";
4
+ type DeliveryResult = {
5
+ delivered: boolean;
6
+ surface?: DeliverySurface;
7
+ to?: string;
8
+ accountId?: string;
9
+ };
10
+ export declare function deliverChannelMessage(params: {
11
+ api: OpenClawPluginApi;
12
+ operationLabel: string;
13
+ context?: unknown;
14
+ sessionKey?: string;
15
+ messages?: unknown[];
16
+ channelRoute?: ChannelRouteRecord;
17
+ text: string;
18
+ mediaUrl?: string;
19
+ mediaLocalRoots?: readonly string[];
20
+ }): Promise<DeliveryResult>;
21
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { KnowhereIngestRequest, KnowhereIngestResult, KnowhereJobList, KnowhereJobListRequest, KnowhereJobResult } from "./types";
2
+ export declare class KnowhereClient {
3
+ private readonly apiKey;
4
+ private readonly baseUrl;
5
+ private readonly requestTimeoutMs;
6
+ private readonly uploadTimeoutMs;
7
+ private readonly pollIntervalMs;
8
+ private readonly pollTimeoutMs;
9
+ private readonly logger;
10
+ private readonly sdk;
11
+ constructor(params: {
12
+ apiKey: string;
13
+ baseUrl: string;
14
+ requestTimeoutMs: number;
15
+ uploadTimeoutMs: number;
16
+ pollIntervalMs: number;
17
+ pollTimeoutMs: number;
18
+ logger: {
19
+ debug?: (message: string) => void;
20
+ info: (message: string) => void;
21
+ };
22
+ });
23
+ ingestDocument(params: KnowhereIngestRequest): Promise<KnowhereIngestResult>;
24
+ private logPollProgress;
25
+ getJob(jobId: string): Promise<KnowhereJobResult>;
26
+ listJobs(options?: KnowhereJobListRequest): Promise<KnowhereJobList>;
27
+ getCompletedJobResult(jobId: string): Promise<KnowhereIngestResult>;
28
+ private downloadResultArchive;
29
+ private uploadFile;
30
+ private requestJson;
31
+ private requestBuffer;
32
+ private request;
33
+ }
package/dist/client.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { isRecord } from "./types.js";
2
- import { Knowhere } from "./node_modules/.pnpm/@knowhere-ai_sdk@0.1.1/node_modules/@knowhere-ai/sdk/dist/index.js";
3
2
  import { formatErrorMessage } from "./error-message.js";
4
3
  import path from "node:path";
5
4
  import { createHash } from "node:crypto";
6
5
  import { openAsBlob } from "node:fs";
6
+ import { Knowhere } from "@knowhere-ai/sdk";
7
7
  //#region src/client.ts
8
8
  const RETRYABLE_STATUS_CODES = new Set([
9
9
  409,
@@ -0,0 +1,13 @@
1
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
2
+ import type { JsonSchemaObject, ResolvedKnowhereConfig, StringRecord, KnowledgeGraphConfig } from "./types";
3
+ export declare const DEFAULT_BASE_URL = "https://api.knowhereto.ai";
4
+ export declare const knowherePluginConfigSchema: JsonSchemaObject;
5
+ export declare function resolveKnowhereConfig(api: OpenClawPluginApi): ResolvedKnowhereConfig;
6
+ export declare const API_KEY_URL = "https://knowhereto.ai/api-keys";
7
+ export declare const PURCHASE_CREDITS_URL = "https://knowhereto.ai/usage?buy=true";
8
+ export declare function assertKnowhereApiKey(config: ResolvedKnowhereConfig): void;
9
+ export declare function isPaymentRequiredError(error: unknown): boolean;
10
+ export declare function formatPaymentRequiredMessage(): string;
11
+ export declare function readPersistedApiKey(storageDir: string): Promise<string | null>;
12
+ export declare function persistApiKey(storageDir: string, apiKey: string): Promise<void>;
13
+ export declare function resolveKnowledgeGraphConfig(raw: StringRecord): KnowledgeGraphConfig;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Connection Builder Module
3
+ *
4
+ * TypeScript implementation of knowhere-api/apps/worker/app/services/connect_builder/builder.py
5
+ * Builds connections between chunks based on keyword overlap and content similarity.
6
+ */
7
+ import type { PluginLogger } from "./types";
8
+ /**
9
+ * Chunk data structure for building connections
10
+ */
11
+ export interface ChunkData {
12
+ chunk_id: string;
13
+ path: string;
14
+ content: string;
15
+ metadata: {
16
+ keywords?: string[];
17
+ tokens?: string[];
18
+ summary?: string;
19
+ length?: number;
20
+ [key: string]: unknown;
21
+ };
22
+ }
23
+ /**
24
+ * Connection result between two chunks
25
+ */
26
+ export interface Connection {
27
+ source: string;
28
+ target: string;
29
+ relation: string;
30
+ score: number;
31
+ sharedKeywords: string[];
32
+ }
33
+ /**
34
+ * Configuration for connection building
35
+ */
36
+ export interface ConnectBuilderConfig {
37
+ minKeywordOverlap: number;
38
+ keywordScoreWeight: number;
39
+ maxConnectionsPerChunk: number;
40
+ minScoreThreshold: number;
41
+ crossFileOnly: boolean;
42
+ maxContentOverlap: number;
43
+ }
44
+ /**
45
+ * Main function to build connections between chunks
46
+ * Equivalent to Python: build_connections
47
+ */
48
+ export declare function buildConnections(chunks: ChunkData[], config: ConnectBuilderConfig, logger?: PluginLogger): Connection[];
@@ -120,7 +120,6 @@ function buildConnections(chunks, config, logger) {
120
120
  const sourceChunk = chunkById.get(sourceId);
121
121
  if (!sourceChunk) continue;
122
122
  const sourceKeywords = getKeywords(sourceChunk);
123
- sourceKeywords.map(normalizeKeyword);
124
123
  const sourceFileKey = extractFileKey(sourceChunk.path);
125
124
  for (const targetId of targetIds) {
126
125
  const targetChunk = chunkById.get(targetId);
@@ -165,7 +164,7 @@ function buildConnections(chunks, config, logger) {
165
164
  connectionsByChunk.get(conn.target).push(conn);
166
165
  }
167
166
  const kept = /* @__PURE__ */ new Set();
168
- for (const [chunkId, conns] of connectionsByChunk) {
167
+ for (const [, conns] of connectionsByChunk) {
169
168
  const topN = conns.sort((a, b) => b.score - a.score).slice(0, config.maxConnectionsPerChunk);
170
169
  for (const conn of topN) kept.add(conn);
171
170
  }
@@ -0,0 +1 @@
1
+ export declare function formatErrorMessage(error: unknown): string;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Graph Builder Module
3
+ *
4
+ * TypeScript implementation of knowhere-api/apps/worker/app/services/connect_builder/graph_builder.py
5
+ * Builds file-level knowledge graphs from chunk connections with TF-IDF and importance scoring.
6
+ */
7
+ import type { ChunkData, Connection } from "./connect-builder";
8
+ import type { PluginLogger } from "./types";
9
+ /**
10
+ * File-level edge in the knowledge graph
11
+ */
12
+ interface FileEdge {
13
+ source: string;
14
+ target: string;
15
+ connection_count: number;
16
+ avg_score: number;
17
+ top_connections: Array<{
18
+ source_chunk: string;
19
+ source_id: string;
20
+ target_chunk: string;
21
+ target_id: string;
22
+ relation: string;
23
+ score: number;
24
+ }>;
25
+ }
26
+ /**
27
+ * File metadata in the knowledge graph
28
+ */
29
+ interface FileMetadata {
30
+ chunks_count: number;
31
+ types: Record<string, number>;
32
+ top_keywords: string[];
33
+ top_summary: string;
34
+ importance: number;
35
+ }
36
+ /**
37
+ * Complete knowledge graph structure
38
+ */
39
+ export interface KnowledgeGraph {
40
+ version: string;
41
+ stats: {
42
+ total_files: number;
43
+ total_chunks: number;
44
+ total_cross_file_edges: number;
45
+ };
46
+ files: Record<string, FileMetadata>;
47
+ edges: FileEdge[];
48
+ }
49
+ /**
50
+ * Chunk statistics for usage tracking
51
+ */
52
+ export interface ChunkStats {
53
+ [chunkId: string]: {
54
+ hit_count: number;
55
+ last_accessed?: string;
56
+ };
57
+ }
58
+ /**
59
+ * Main function to build knowledge graph
60
+ * Equivalent to Python: build_knowledge_graph
61
+ */
62
+ export declare function buildKnowledgeGraph(chunks: ChunkData[], connections: Connection[], chunkStats: ChunkStats, jiebaInitialized: boolean, logger?: PluginLogger): KnowledgeGraph;
63
+ /**
64
+ * Incremental update: match new chunks against existing chunks
65
+ * Equivalent to Python: _incremental_connections
66
+ */
67
+ export declare function incrementalConnections(newChunks: ChunkData[], existingChunks: ChunkData[], config: {
68
+ minKeywordOverlap: number;
69
+ keywordScoreWeight: number;
70
+ maxConnectionsPerChunk: number;
71
+ minScoreThreshold: number;
72
+ crossFileOnly: boolean;
73
+ maxContentOverlap: number;
74
+ }, logger?: PluginLogger): Connection[];
75
+ export {};
@@ -1,7 +1,11 @@
1
- import { __toESM } from "./_virtual/_rolldown/runtime.js";
2
- import { require_nodejieba } from "./node_modules/.pnpm/nodejieba@2.6.0/node_modules/nodejieba/index.js";
1
+ import * as nodejieba from "nodejieba";
3
2
  //#region src/graph-builder.ts
4
- var import_nodejieba = /* @__PURE__ */ __toESM(require_nodejieba(), 1);
3
+ /**
4
+ * Graph Builder Module
5
+ *
6
+ * TypeScript implementation of knowhere-api/apps/worker/app/services/connect_builder/graph_builder.py
7
+ * Builds file-level knowledge graphs from chunk connections with TF-IDF and importance scoring.
8
+ */
5
9
  /**
6
10
  * Extract file key from chunk path
7
11
  */
@@ -25,13 +29,13 @@ function extractTokensFromContent(content, jiebaInitialized) {
25
29
  const cleanContent = content.replace(/<[^>]*>/g, " ");
26
30
  if (!jiebaInitialized) return cleanContent.split(/\s+/).filter((w) => w.length > 1);
27
31
  try {
28
- return import_nodejieba.cut(cleanContent).filter((token) => {
32
+ return nodejieba.cut(cleanContent).filter((token) => {
29
33
  if (token.length <= 1) return false;
30
34
  if (/^\d+$/.test(token)) return false;
31
35
  if (/^[^\w\u4e00-\u9fa5]+$/.test(token)) return false;
32
36
  return true;
33
37
  });
34
- } catch (error) {
38
+ } catch {
35
39
  return cleanContent.split(/\s+/).filter((w) => w.length > 1);
36
40
  }
37
41
  }
@@ -0,0 +1,9 @@
1
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
2
+ declare const plugin: {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ configSchema: import("./types").JsonSchemaObject;
7
+ register(api: OpenClawPluginApi): void;
8
+ };
9
+ export default plugin;
@@ -0,0 +1,38 @@
1
+ import type { KnowledgeGraphConfig, PluginLogger, ToolRuntimeContext, KbMetadata, KnowledgeGraph, FileEdge } from "./types";
2
+ export interface KnowledgeGraphServiceParams {
3
+ config: KnowledgeGraphConfig;
4
+ logger: PluginLogger;
5
+ }
6
+ type DegradationMode = "full" | "basic" | "disabled";
7
+ export declare class KnowledgeGraphService {
8
+ private readonly config;
9
+ private readonly logger;
10
+ private degradationMode;
11
+ private buildQueues;
12
+ private jiebaInitialized;
13
+ constructor(params: KnowledgeGraphServiceParams);
14
+ initialize(): Promise<void>;
15
+ private checkPythonEnvironment;
16
+ private initializeJieba;
17
+ extractKeywords(text: string, topK?: number): Promise<string[]>;
18
+ resolveKbId(context: ToolRuntimeContext): string | null;
19
+ getKbPath(kbId: string): string;
20
+ ensureKbDirectory(kbId: string): Promise<string>;
21
+ saveDocumentToKb(params: {
22
+ kbId: string;
23
+ docId: string;
24
+ sourcePath: string;
25
+ keywords: string[];
26
+ metadata: Record<string, unknown>;
27
+ }): Promise<void>;
28
+ scheduleBuild(kbId: string, task: () => Promise<void>): Promise<void>;
29
+ buildKnowledgeGraph(kbId: string): Promise<void>;
30
+ private updateKbMetadata;
31
+ queryGraph(kbId: string, fileKey?: string): Promise<FileEdge[]>;
32
+ getKnowledgeGraph(kbId: string): Promise<KnowledgeGraph | null>;
33
+ listKnowledgeBases(): Promise<string[]>;
34
+ getKbMetadata(kbId: string): Promise<KbMetadata | null>;
35
+ isEnabled(): boolean;
36
+ getDegradationMode(): DegradationMode;
37
+ }
38
+ export {};
@@ -1,14 +1,11 @@
1
- import { __toESM } from "./_virtual/_rolldown/runtime.js";
2
- import { require_lib } from "./node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/index.js";
3
- import { require_nodejieba } from "./node_modules/.pnpm/nodejieba@2.6.0/node_modules/nodejieba/index.js";
4
1
  import { buildConnections, init_connect_builder } from "./connect-builder.js";
5
2
  import { buildKnowledgeGraph } from "./graph-builder.js";
6
3
  import path from "node:path";
7
4
  import { spawn } from "node:child_process";
5
+ import fs from "fs-extra";
8
6
  import os from "node:os";
7
+ import * as nodejieba from "nodejieba";
9
8
  //#region src/kg-service.ts
10
- var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
11
- var import_nodejieba = /* @__PURE__ */ __toESM(require_nodejieba(), 1);
12
9
  init_connect_builder();
13
10
  const DEFAULT_CONNECT_CONFIG = {
14
11
  minKeywordOverlap: 3,
@@ -25,6 +22,15 @@ const DEFAULT_KG_CONFIG = {
25
22
  buildTimeout: 3e5,
26
23
  notifyOnGraphFailure: false
27
24
  };
25
+ function formatUnknownError(error) {
26
+ return error instanceof Error ? error.message : String(error);
27
+ }
28
+ function extractKeywordText(item) {
29
+ if (typeof item === "string") return item;
30
+ if (typeof item === "number" || typeof item === "boolean" || typeof item === "bigint") return String(item);
31
+ if (typeof item === "object" && item !== null && "word" in item && typeof item.word === "string") return item.word;
32
+ return null;
33
+ }
28
34
  var KnowledgeGraphService = class {
29
35
  config;
30
36
  logger;
@@ -68,7 +74,7 @@ var KnowledgeGraphService = class {
68
74
  async checkPythonEnvironment() {
69
75
  return new Promise((resolve, reject) => {
70
76
  const python = spawn("python3", ["--version"]);
71
- python.on("error", (err) => {
77
+ python.on("error", () => {
72
78
  const error = /* @__PURE__ */ new Error("Python3 not found in PATH");
73
79
  error.code = "PYTHON_MISSING";
74
80
  reject(error);
@@ -87,10 +93,10 @@ var KnowledgeGraphService = class {
87
93
  }
88
94
  async initializeJieba() {
89
95
  try {
90
- import_nodejieba.load();
96
+ nodejieba.load();
91
97
  this.jiebaInitialized = true;
92
98
  this.logger.info("Nodejieba initialized successfully");
93
- } catch (error) {
99
+ } catch {
94
100
  const err = /* @__PURE__ */ new Error("Failed to initialize nodejieba");
95
101
  err.code = "NODEJIEBA_MISSING";
96
102
  throw err;
@@ -99,14 +105,14 @@ var KnowledgeGraphService = class {
99
105
  async extractKeywords(text, topK = 20) {
100
106
  if (this.degradationMode === "disabled") return [];
101
107
  if (this.degradationMode === "full" && this.jiebaInitialized) try {
102
- const rawKeywords = import_nodejieba.extract(text, topK);
103
- return (Array.isArray(rawKeywords) ? rawKeywords : []).map((item) => typeof item === "string" ? item : String(item.word || item)).filter((kw) => {
108
+ const rawKeywords = nodejieba.extract(text, topK);
109
+ return (Array.isArray(rawKeywords) ? rawKeywords : []).map((item) => extractKeywordText(item)).filter((keyword) => keyword !== null).filter((kw) => {
104
110
  if (kw.length <= 1) return false;
105
111
  if (/^\d+$/.test(kw)) return false;
106
112
  return true;
107
113
  }).slice(0, topK);
108
114
  } catch (error) {
109
- this.logger.warn(`Jieba extraction failed, falling back to basic: ${error}`);
115
+ this.logger.warn(`Jieba extraction failed, falling back to basic: ${formatUnknownError(error)}`);
110
116
  this.degradationMode = "basic";
111
117
  }
112
118
  return text.split(/\s+/).filter((w) => w.length > 1).slice(0, topK);
@@ -130,18 +136,18 @@ var KnowledgeGraphService = class {
130
136
  }
131
137
  async ensureKbDirectory(kbId) {
132
138
  const kbPath = this.getKbPath(kbId);
133
- await import_lib.default.ensureDir(kbPath);
139
+ await fs.ensureDir(kbPath);
134
140
  return kbPath;
135
141
  }
136
142
  async saveDocumentToKb(params) {
137
143
  const kbPath = await this.ensureKbDirectory(params.kbId);
138
144
  const docDir = path.join(kbPath, params.docId);
139
- await import_lib.default.ensureDir(docDir);
140
- await import_lib.default.copy(params.sourcePath, docDir, { overwrite: true });
145
+ await fs.ensureDir(docDir);
146
+ await fs.copy(params.sourcePath, docDir, { overwrite: true });
141
147
  const keywordsPath = path.join(docDir, "keywords.json");
142
- await import_lib.default.writeJSON(keywordsPath, params.keywords, { spaces: 2 });
148
+ await fs.writeJSON(keywordsPath, params.keywords, { spaces: 2 });
143
149
  const metadataPath = path.join(docDir, "metadata.json");
144
- await import_lib.default.writeJSON(metadataPath, params.metadata, { spaces: 2 });
150
+ await fs.writeJSON(metadataPath, params.metadata, { spaces: 2 });
145
151
  this.logger.info(`Document saved to knowledge base: kb=${params.kbId} doc=${params.docId}`);
146
152
  }
147
153
  async scheduleBuild(kbId, task) {
@@ -162,11 +168,11 @@ var KnowledgeGraphService = class {
162
168
  }
163
169
  async buildKnowledgeGraph(kbId) {
164
170
  const kbPath = this.getKbPath(kbId);
165
- const docs = await import_lib.default.readdir(kbPath);
171
+ const docs = await fs.readdir(kbPath);
166
172
  const docDirs = [];
167
173
  for (const doc of docs) {
168
174
  const docPath = path.join(kbPath, doc);
169
- if ((await import_lib.default.stat(docPath)).isDirectory() && doc !== "knowledge_graph.json" && doc !== "chunk_stats.json" && doc !== "kb_metadata.json") docDirs.push(doc);
175
+ if ((await fs.stat(docPath)).isDirectory() && doc !== "knowledge_graph.json" && doc !== "chunk_stats.json" && doc !== "kb_metadata.json") docDirs.push(doc);
170
176
  }
171
177
  if (docDirs.length < 2) {
172
178
  this.logger.info(`Not enough documents for graph building (need >=2, have ${docDirs.length}), skipping`);
@@ -177,8 +183,8 @@ var KnowledgeGraphService = class {
177
183
  const allChunks = [];
178
184
  for (const docDir of docDirs) {
179
185
  const chunksPath = path.join(kbPath, docDir, "chunks.json");
180
- if (await import_lib.default.pathExists(chunksPath)) {
181
- const chunksData = await import_lib.default.readJSON(chunksPath);
186
+ if (await fs.pathExists(chunksPath)) {
187
+ const chunksData = await fs.readJSON(chunksPath);
182
188
  if (chunksData.chunks && Array.isArray(chunksData.chunks)) allChunks.push(...chunksData.chunks);
183
189
  }
184
190
  }
@@ -191,10 +197,10 @@ var KnowledgeGraphService = class {
191
197
  this.logger.info(`Built ${connections.length} connections`);
192
198
  const chunkStatsPath = path.join(kbPath, "chunk_stats.json");
193
199
  let chunkStats = {};
194
- if (await import_lib.default.pathExists(chunkStatsPath)) chunkStats = await import_lib.default.readJSON(chunkStatsPath);
200
+ if (await fs.pathExists(chunkStatsPath)) chunkStats = await fs.readJSON(chunkStatsPath);
195
201
  const knowledgeGraph = buildKnowledgeGraph(allChunks, connections, chunkStats, this.jiebaInitialized, this.logger);
196
202
  const graphFile = path.join(kbPath, "knowledge_graph.json");
197
- await import_lib.default.writeJSON(graphFile, knowledgeGraph, { spaces: 2 });
203
+ await fs.writeJSON(graphFile, knowledgeGraph, { spaces: 2 });
198
204
  this.logger.info(`Knowledge graph saved to ${graphFile}`);
199
205
  await this.updateKbMetadata(kbPath, {
200
206
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
@@ -202,41 +208,41 @@ var KnowledgeGraphService = class {
202
208
  });
203
209
  this.logger.info(`Knowledge graph built successfully for kb=${kbId}`);
204
210
  } catch (error) {
205
- this.logger.error(`Failed to build knowledge graph: ${error}`);
211
+ this.logger.error(`Failed to build knowledge graph: ${formatUnknownError(error)}`);
206
212
  throw error;
207
213
  }
208
214
  }
209
215
  async updateKbMetadata(kbPath, updates) {
210
216
  const metadataPath = path.join(kbPath, "kb_metadata.json");
211
217
  let metadata = {};
212
- if (await import_lib.default.pathExists(metadataPath)) metadata = await import_lib.default.readJSON(metadataPath);
218
+ if (await fs.pathExists(metadataPath)) metadata = await fs.readJSON(metadataPath);
213
219
  const updated = {
214
220
  ...metadata,
215
221
  ...updates
216
222
  };
217
- await import_lib.default.writeJSON(metadataPath, updated, { spaces: 2 });
223
+ await fs.writeJSON(metadataPath, updated, { spaces: 2 });
218
224
  }
219
225
  async queryGraph(kbId, fileKey) {
220
226
  const graphPath = path.join(this.getKbPath(kbId), "knowledge_graph.json");
221
- if (!await import_lib.default.pathExists(graphPath)) return [];
222
- const graph = await import_lib.default.readJSON(graphPath);
227
+ if (!await fs.pathExists(graphPath)) return [];
228
+ const graph = await fs.readJSON(graphPath);
223
229
  if (!fileKey) return graph.edges;
224
230
  return graph.edges.filter((edge) => edge.source === fileKey || edge.target === fileKey);
225
231
  }
226
232
  async getKnowledgeGraph(kbId) {
227
233
  const graphPath = path.join(this.getKbPath(kbId), "knowledge_graph.json");
228
- if (!await import_lib.default.pathExists(graphPath)) return null;
229
- return await import_lib.default.readJSON(graphPath);
234
+ if (!await fs.pathExists(graphPath)) return null;
235
+ return await fs.readJSON(graphPath);
230
236
  }
231
237
  async listKnowledgeBases() {
232
238
  const knowhereRoot = path.join(os.homedir(), ".knowhere");
233
- if (!await import_lib.default.pathExists(knowhereRoot)) return [];
234
- return (await import_lib.default.readdir(knowhereRoot, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
239
+ if (!await fs.pathExists(knowhereRoot)) return [];
240
+ return (await fs.readdir(knowhereRoot, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
235
241
  }
236
242
  async getKbMetadata(kbId) {
237
243
  const metadataPath = path.join(this.getKbPath(kbId), "kb_metadata.json");
238
- if (!await import_lib.default.pathExists(metadataPath)) return null;
239
- return await import_lib.default.readJSON(metadataPath);
244
+ if (!await fs.pathExists(metadataPath)) return null;
245
+ return await fs.readJSON(metadataPath);
240
246
  }
241
247
  isEnabled() {
242
248
  return this.degradationMode !== "disabled";
@@ -0,0 +1,16 @@
1
+ import type { KnowhereDownloadedResult, KnowhereManifest, KnowhereParseResult, KnowhereStatistics, StoredBrowseIndex, StoredChunk } from "./types";
2
+ type KnowhereStoredResultSummary = {
3
+ manifest: KnowhereManifest;
4
+ chunkCount: number;
5
+ statistics: KnowhereStatistics;
6
+ };
7
+ export declare const STORED_BROWSE_INDEX_VERSION = 2;
8
+ export declare function resolveResultEntryPath(rootDir: string, entryPath: string): string;
9
+ export declare function buildStoredPathPrefixes(storedPath: string): string[];
10
+ export declare function isStoredBrowseIndex(value: unknown): value is StoredBrowseIndex;
11
+ export declare function buildStoredBrowseIndex(resultDir: string, manifest: KnowhereManifest, chunks: StoredChunk[]): Promise<StoredBrowseIndex>;
12
+ export declare function extractKnowhereResultArchive(downloadedResult: KnowhereDownloadedResult, targetDir: string): Promise<void>;
13
+ export declare function readStoredKnowhereResultSummary(resultDir: string): Promise<KnowhereStoredResultSummary>;
14
+ export declare function readStoredKnowhereResultContent(resultDir: string): Promise<Omit<KnowhereParseResult, "browseIndex">>;
15
+ export declare function readStoredKnowhereParseResult(resultDir: string): Promise<KnowhereParseResult>;
16
+ export {};
package/dist/parser.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { isNodeError, isRecord } from "./types.js";
2
- import { strFromU8, unzipSync } from "./node_modules/.pnpm/fflate@0.8.2/node_modules/fflate/esm/browser.js";
3
2
  import fs from "node:fs/promises";
4
3
  import path from "node:path";
5
4
  import { createHash } from "node:crypto";
5
+ import { strFromU8, unzipSync } from "fflate";
6
6
  const CHUNKS_FILE_NAME = "chunks.json";
7
7
  const FULL_MARKDOWN_FILE_NAME = "full.md";
8
8
  const HIERARCHY_FILE_NAME = "hierarchy.json";
@@ -0,0 +1,11 @@
1
+ export type ParsedConversationSessionKey = {
2
+ agentId: string;
3
+ surface: string;
4
+ remainder: string;
5
+ segments: string[];
6
+ };
7
+ export declare function parseConversationSessionKey(sessionKey: string | undefined): ParsedConversationSessionKey | undefined;
8
+ export declare function normalizeConversationScopeKey(sessionKey: string | undefined): string | undefined;
9
+ export declare function resolveSharedConversationScopeKey(sessionKey: string | undefined): string | undefined;
10
+ export declare function findConversationSegmentValue(session: ParsedConversationSessionKey | undefined, ...keys: string[]): string | undefined;
11
+ export declare function deriveMessageContextScopeKey(context: unknown): string | undefined;