@ontos-ai/knowhere-claw 0.2.1 → 0.2.2
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.
- package/dist/_virtual/_rolldown/runtime.js +1 -35
- package/dist/client.js +1 -1
- package/dist/graph-builder.js +8 -4
- package/dist/kg-service.js +25 -28
- package/dist/parser.js +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
- package/dist/node_modules/.pnpm/@knowhere-ai_sdk@0.1.1/node_modules/@knowhere-ai/sdk/dist/index.js +0 -717
- 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
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/pre-binding.js +0 -35
- 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
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/napi.js +0 -142
- 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
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js +0 -199
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/package.js +0 -67
- package/dist/node_modules/.pnpm/abbrev@1.1.1/node_modules/abbrev/abbrev.js +0 -59
- package/dist/node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js +0 -11
- package/dist/node_modules/.pnpm/aproba@2.1.0/node_modules/aproba/index.js +0 -119
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/index.js +0 -13
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-base.js +0 -16
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-group.js +0 -98
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-stream.js +0 -37
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker.js +0 -32
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/adapters.js +0 -83
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/fetch.js +0 -170
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/xhr.js +0 -106
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/axios.js +0 -57
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/CancelToken.js +0 -90
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/CanceledError.js +0 -20
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/isCancel.js +0 -6
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/Axios.js +0 -174
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/AxiosError.js +0 -70
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/AxiosHeaders.js +0 -204
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/InterceptorManager.js +0 -60
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/buildFullPath.js +0 -20
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/dispatchRequest.js +0 -52
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/mergeConfig.js +0 -81
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/settle.js +0 -18
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/transformData.js +0 -25
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/defaults/index.js +0 -107
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/defaults/transitional.js +0 -9
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/env/data.js +0 -4
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -50
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -77
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/bind.js +0 -15
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/buildURL.js +0 -40
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/combineURLs.js +0 -14
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/composeSignals.js +0 -39
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/cookies.js +0 -31
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/formDataToJSON.js +0 -67
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -14
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -8
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/parseHeaders.js +0 -53
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/parseProtocol.js +0 -7
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/progressEventReducer.js +0 -38
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/resolveConfig.js +0 -36
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/speedometer.js +0 -36
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/spread.js +0 -29
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/throttle.js +0 -38
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/toFormData.js +0 -151
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -18
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/trackStream.js +0 -69
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/validator.js +0 -76
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -4
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -4
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -5
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/index.js +0 -22
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/common/utils.js +0 -46
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/index.js +0 -9
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/utils.js +0 -698
- package/dist/node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js +0 -53
- package/dist/node_modules/.pnpm/brace-expansion@1.1.12/node_modules/brace-expansion/index.js +0 -132
- package/dist/node_modules/.pnpm/color-support@1.1.3/node_modules/color-support/browser.js +0 -18
- package/dist/node_modules/.pnpm/concat-map@0.0.1/node_modules/concat-map/index.js +0 -19
- package/dist/node_modules/.pnpm/console-control-strings@1.1.0/node_modules/console-control-strings/index.js +0 -104
- package/dist/node_modules/.pnpm/delegates@1.0.0/node_modules/delegates/index.js +0 -104
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/detect-libc.js +0 -221
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/elf.js +0 -26
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js +0 -48
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js +0 -24
- package/dist/node_modules/.pnpm/emoji-regex@8.0.0/node_modules/emoji-regex/index.js +0 -10
- package/dist/node_modules/.pnpm/fflate@0.8.2/node_modules/fflate/esm/browser.js +0 -426
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/copy-sync.js +0 -120
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/copy.js +0 -100
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/index.js +0 -15
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/empty/index.js +0 -43
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/file.js +0 -53
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/index.js +0 -27
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/link.js +0 -56
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -89
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -35
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink.js +0 -81
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/fs/index.js +0 -113
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/index.js +0 -29
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/index.js +0 -22
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/jsonfile.js +0 -15
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/output-json-sync.js +0 -15
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/output-json.js +0 -15
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/index.js +0 -20
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -33
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/utils.js +0 -17
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/index.js +0 -15
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/move-sync.js +0 -56
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/move.js +0 -49
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/output-file/index.js +0 -30
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/path-exists/index.js +0 -18
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/remove/index.js +0 -27
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/async.js +0 -15
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/stat.js +0 -131
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/utimes.js +0 -34
- package/dist/node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js +0 -51
- package/dist/node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js +0 -171
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/base-theme.js +0 -21
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/error.js +0 -27
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/has-color.js +0 -9
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/index.js +0 -224
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/plumbing.js +0 -48
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/process.js +0 -8
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/progress-bar.js +0 -46
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/render-template.js +0 -155
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/set-immediate.js +0 -14
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/set-interval.js +0 -8
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/spin.js +0 -10
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/template-item.js +0 -58
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/theme-set.js +0 -99
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/themes.js +0 -67
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/wide-truncate.js +0 -22
- package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/common.js +0 -162
- package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/glob.js +0 -451
- package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/sync.js +0 -280
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js +0 -20
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js +0 -362
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js +0 -92
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js +0 -255
- package/dist/node_modules/.pnpm/has-unicode@2.0.1/node_modules/has-unicode/index.js +0 -14
- package/dist/node_modules/.pnpm/inflight@1.0.6/node_modules/inflight/inflight.js +0 -45
- package/dist/node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js +0 -27
- package/dist/node_modules/.pnpm/is-fullwidth-code-point@3.0.0/node_modules/is-fullwidth-code-point/index.js +0 -14
- package/dist/node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/index.js +0 -68
- package/dist/node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/utils.js +0 -19
- package/dist/node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/dist/jszip.min.js +0 -3110
- package/dist/node_modules/.pnpm/minimatch@3.1.5/node_modules/minimatch/minimatch.js +0 -578
- package/dist/node_modules/.pnpm/nodejieba@2.6.0/node_modules/nodejieba/index.js +0 -46
- package/dist/node_modules/.pnpm/nopt@5.0.0/node_modules/nopt/lib/nopt.js +0 -330
- package/dist/node_modules/.pnpm/npmlog@5.0.1/node_modules/npmlog/log.js +0 -305
- package/dist/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +0 -54
- package/dist/node_modules/.pnpm/once@1.4.0/node_modules/once/once.js +0 -44
- package/dist/node_modules/.pnpm/path-is-absolute@1.0.1/node_modules/path-is-absolute/index.js +0 -19
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/errors-browser.js +0 -88
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_duplex.js +0 -75
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_passthrough.js +0 -19
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js +0 -666
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_transform.js +0 -89
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js +0 -423
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/async_iterator.js +0 -172
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -243
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -77
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -87
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from-browser.js +0 -10
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -80
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/state.js +0 -21
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -8
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/readable-browser.js +0 -23
- package/dist/node_modules/.pnpm/rimraf@3.0.2/node_modules/rimraf/rimraf.js +0 -229
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js +0 -79
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js +0 -282
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js +0 -186
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js +0 -14
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js +0 -41
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js +0 -34
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js +0 -15
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js +0 -32
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js +0 -22
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js +0 -19
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js +0 -14
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js +0 -18
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js +0 -14
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js +0 -99
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js +0 -28
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js +0 -8
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js +0 -23
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js +0 -36
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js +0 -15
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js +0 -84
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js +0 -15
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js +0 -31
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js +0 -31
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js +0 -45
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js +0 -64
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js +0 -35
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js +0 -102
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js +0 -11
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js +0 -17
- package/dist/node_modules/.pnpm/set-blocking@2.0.0/node_modules/set-blocking/index.js +0 -12
- package/dist/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +0 -130
- package/dist/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +0 -16
- package/dist/node_modules/.pnpm/string-width@4.2.3/node_modules/string-width/index.js +0 -30
- package/dist/node_modules/.pnpm/strip-ansi@6.0.1/node_modules/strip-ansi/index.js +0 -10
- package/dist/node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js +0 -26
- package/dist/node_modules/.pnpm/util-deprecate@1.0.2/node_modules/util-deprecate/browser.js +0 -59
- package/dist/node_modules/.pnpm/wide-align@1.1.5/node_modules/wide-align/align.js +0 -52
- package/dist/node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js +0 -26
package/dist/node_modules/.pnpm/@knowhere-ai_sdk@0.1.1/node_modules/@knowhere-ai/sdk/dist/index.js
DELETED
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
import { __toESM } from "../../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import axios from "../../../../../axios@1.13.6/node_modules/axios/lib/axios.js";
|
|
3
|
-
import { require_jszip_min } from "../../../../../jszip@3.10.1/node_modules/jszip/dist/jszip.min.js";
|
|
4
|
-
import { createReadStream, promises } from "fs";
|
|
5
|
-
import { dirname, join } from "path";
|
|
6
|
-
//#region node_modules/.pnpm/@knowhere-ai+sdk@0.1.1/node_modules/@knowhere-ai/sdk/dist/index.mjs
|
|
7
|
-
var import_jszip_min = /* @__PURE__ */ __toESM(require_jszip_min(), 1);
|
|
8
|
-
var VERSION = "0.1.0";
|
|
9
|
-
var DEFAULT_BASE_URL = "https://api.knowhereto.ai";
|
|
10
|
-
var DEFAULT_TIMEOUT = 6e4;
|
|
11
|
-
var DEFAULT_MAX_RETRIES = 5;
|
|
12
|
-
var DEFAULT_POLL_INTERVAL = 1e4;
|
|
13
|
-
var MAX_POLL_INTERVAL = 3e4;
|
|
14
|
-
var DEFAULT_POLL_TIMEOUT = 18e5;
|
|
15
|
-
var POLL_INTERVAL_INCREASE_THRESHOLD = 6e4;
|
|
16
|
-
var POLL_INTERVAL_MULTIPLIER = 1.2;
|
|
17
|
-
var INITIAL_RETRY_DELAY = 500;
|
|
18
|
-
var MAX_RETRY_DELAY = 3e4;
|
|
19
|
-
var RETRY_DELAY_BASE = 2;
|
|
20
|
-
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
21
|
-
409,
|
|
22
|
-
429,
|
|
23
|
-
503,
|
|
24
|
-
504
|
|
25
|
-
]);
|
|
26
|
-
var TERMINAL_JOB_STATUSES = /* @__PURE__ */ new Set(["done", "failed"]);
|
|
27
|
-
var ENV = {
|
|
28
|
-
API_KEY: "KNOWHERE_API_KEY",
|
|
29
|
-
BASE_URL: "KNOWHERE_BASE_URL",
|
|
30
|
-
LOG_LEVEL: "KNOWHERE_LOG_LEVEL"
|
|
31
|
-
};
|
|
32
|
-
var KnowhereError = class extends Error {
|
|
33
|
-
constructor(message) {
|
|
34
|
-
super(message);
|
|
35
|
-
this.name = "KnowhereError";
|
|
36
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var NetworkError = class extends KnowhereError {
|
|
40
|
-
constructor(message, cause) {
|
|
41
|
-
super(message);
|
|
42
|
-
this.cause = cause;
|
|
43
|
-
this.name = "NetworkError";
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var TimeoutError = class extends NetworkError {
|
|
47
|
-
constructor(message = "Request timed out") {
|
|
48
|
-
super(message);
|
|
49
|
-
this.name = "TimeoutError";
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var PollingTimeoutError = class extends KnowhereError {
|
|
53
|
-
constructor(message = "Polling timed out", elapsedMs) {
|
|
54
|
-
super(message);
|
|
55
|
-
this.elapsedMs = elapsedMs;
|
|
56
|
-
this.name = "PollingTimeoutError";
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var ValidationError = class extends KnowhereError {
|
|
60
|
-
constructor(message) {
|
|
61
|
-
super(message);
|
|
62
|
-
this.name = "ValidationError";
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var APIError = class extends KnowhereError {
|
|
66
|
-
constructor(message, statusCode, code, requestId, details, body) {
|
|
67
|
-
super(message);
|
|
68
|
-
this.statusCode = statusCode;
|
|
69
|
-
this.code = code;
|
|
70
|
-
this.requestId = requestId;
|
|
71
|
-
this.details = details;
|
|
72
|
-
this.body = body;
|
|
73
|
-
this.name = "APIError";
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
var BadRequestError = class extends APIError {
|
|
77
|
-
constructor(message, code, requestId, details, body) {
|
|
78
|
-
super(message, 400, code, requestId, details, body);
|
|
79
|
-
this.name = "BadRequestError";
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var AuthenticationError = class extends APIError {
|
|
83
|
-
constructor(message = "Authentication failed", code, requestId, details, body) {
|
|
84
|
-
super(message, 401, code, requestId, details, body);
|
|
85
|
-
this.name = "AuthenticationError";
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
var PaymentRequiredError = class extends APIError {
|
|
89
|
-
constructor(message = "Payment required", code, requestId, details, body) {
|
|
90
|
-
super(message, 402, code, requestId, details, body);
|
|
91
|
-
this.name = "PaymentRequiredError";
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var PermissionDeniedError = class extends APIError {
|
|
95
|
-
constructor(message = "Permission denied", code, requestId, details, body) {
|
|
96
|
-
super(message, 403, code, requestId, details, body);
|
|
97
|
-
this.name = "PermissionDeniedError";
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
var NotFoundError = class extends APIError {
|
|
101
|
-
constructor(message = "Resource not found", code, requestId, details, body) {
|
|
102
|
-
super(message, 404, code, requestId, details, body);
|
|
103
|
-
this.name = "NotFoundError";
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var ConflictError = class extends APIError {
|
|
107
|
-
constructor(message = "Conflict", code, requestId, details, body) {
|
|
108
|
-
super(message, 409, code, requestId, details, body);
|
|
109
|
-
this.name = "ConflictError";
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
var RateLimitError = class extends APIError {
|
|
113
|
-
constructor(message = "Rate limit exceeded", code, requestId, details, body, retryAfter) {
|
|
114
|
-
super(message, 429, code, requestId, details, body);
|
|
115
|
-
this.retryAfter = retryAfter;
|
|
116
|
-
this.name = "RateLimitError";
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
var InternalServerError = class extends APIError {
|
|
120
|
-
constructor(message = "Internal server error", code, requestId, details, body) {
|
|
121
|
-
super(message, 500, code, requestId, details, body);
|
|
122
|
-
this.name = "InternalServerError";
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var ServiceUnavailableError = class extends APIError {
|
|
126
|
-
constructor(message = "Service unavailable", statusCode = 503, code, requestId, details, body) {
|
|
127
|
-
super(message, statusCode, code, requestId, details, body);
|
|
128
|
-
this.name = "ServiceUnavailableError";
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
var GatewayTimeoutError = class extends APIError {
|
|
132
|
-
constructor(message = "Gateway timeout", code, requestId, details, body) {
|
|
133
|
-
super(message, 504, code, requestId, details, body);
|
|
134
|
-
this.name = "GatewayTimeoutError";
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
function createAPIError(statusCode, message, code, requestId, details, body, retryAfter) {
|
|
138
|
-
switch (statusCode) {
|
|
139
|
-
case 400: return new BadRequestError(message, code, requestId, details, body);
|
|
140
|
-
case 401: return new AuthenticationError(message, code, requestId, details, body);
|
|
141
|
-
case 402: return new PaymentRequiredError(message, code, requestId, details, body);
|
|
142
|
-
case 403: return new PermissionDeniedError(message, code, requestId, details, body);
|
|
143
|
-
case 404: return new NotFoundError(message, code, requestId, details, body);
|
|
144
|
-
case 409: return new ConflictError(message, code, requestId, details, body);
|
|
145
|
-
case 429: return new RateLimitError(message, code, requestId, details, body, retryAfter);
|
|
146
|
-
case 500: return new InternalServerError(message, code, requestId, details, body);
|
|
147
|
-
case 502:
|
|
148
|
-
case 503: return new ServiceUnavailableError(message, statusCode, code, requestId, details, body);
|
|
149
|
-
case 504: return new GatewayTimeoutError(message, code, requestId, details, body);
|
|
150
|
-
default: return new APIError(message, statusCode, code, requestId, details, body);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
var JobFailedError = class extends KnowhereError {
|
|
154
|
-
constructor(message, code, jobResult) {
|
|
155
|
-
super(message);
|
|
156
|
-
this.code = code;
|
|
157
|
-
this.jobResult = jobResult;
|
|
158
|
-
this.name = "JobFailedError";
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
function sleep(ms) {
|
|
162
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
163
|
-
}
|
|
164
|
-
function snakeToCamel(str) {
|
|
165
|
-
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
166
|
-
}
|
|
167
|
-
function camelToSnake(str) {
|
|
168
|
-
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
169
|
-
}
|
|
170
|
-
function keysToCamel(obj) {
|
|
171
|
-
if (obj === null || obj === void 0) return obj;
|
|
172
|
-
if (Array.isArray(obj)) return obj.map((item) => keysToCamel(item));
|
|
173
|
-
if (typeof obj === "object" && obj.constructor === Object) {
|
|
174
|
-
const result = {};
|
|
175
|
-
for (const [key, value] of Object.entries(obj)) result[snakeToCamel(key)] = keysToCamel(value);
|
|
176
|
-
return result;
|
|
177
|
-
}
|
|
178
|
-
return obj;
|
|
179
|
-
}
|
|
180
|
-
function keysToSnake(obj) {
|
|
181
|
-
if (obj === null || obj === void 0) return obj;
|
|
182
|
-
if (Array.isArray(obj)) return obj.map((item) => keysToSnake(item));
|
|
183
|
-
if (typeof obj === "object" && obj.constructor === Object) {
|
|
184
|
-
const result = {};
|
|
185
|
-
for (const [key, value] of Object.entries(obj)) result[camelToSnake(key)] = keysToSnake(value);
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
|
-
return obj;
|
|
189
|
-
}
|
|
190
|
-
function parseDates(obj) {
|
|
191
|
-
if (obj === null || obj === void 0) return obj;
|
|
192
|
-
if (Array.isArray(obj)) return obj.map((item) => parseDates(item));
|
|
193
|
-
if (typeof obj === "object" && obj.constructor === Object) {
|
|
194
|
-
const result = {};
|
|
195
|
-
for (const [key, value] of Object.entries(obj)) if ((key.endsWith("At") || key.endsWith("Date")) && typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/.test(value)) result[key] = new Date(value);
|
|
196
|
-
else result[key] = parseDates(value);
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
return obj;
|
|
200
|
-
}
|
|
201
|
-
function isTerminalStatus(status) {
|
|
202
|
-
return TERMINAL_JOB_STATUSES.has(status);
|
|
203
|
-
}
|
|
204
|
-
function enrichJobResult(jobResult) {
|
|
205
|
-
Object.defineProperties(jobResult, {
|
|
206
|
-
isTerminal: {
|
|
207
|
-
get() {
|
|
208
|
-
return isTerminalStatus(this.status);
|
|
209
|
-
},
|
|
210
|
-
enumerable: true
|
|
211
|
-
},
|
|
212
|
-
isDone: {
|
|
213
|
-
get() {
|
|
214
|
-
return this.status === "done";
|
|
215
|
-
},
|
|
216
|
-
enumerable: true
|
|
217
|
-
},
|
|
218
|
-
isFailed: {
|
|
219
|
-
get() {
|
|
220
|
-
return this.status === "failed";
|
|
221
|
-
},
|
|
222
|
-
enumerable: true
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
return jobResult;
|
|
226
|
-
}
|
|
227
|
-
function sanitizePath(path) {
|
|
228
|
-
let sanitized = path.replace(/^\/+/, "");
|
|
229
|
-
sanitized = sanitized.replace(/\.\.(\/|\\)/g, "");
|
|
230
|
-
sanitized = sanitized.replace(/\\/g, "/");
|
|
231
|
-
return sanitized;
|
|
232
|
-
}
|
|
233
|
-
function getFileExtension(filename) {
|
|
234
|
-
const match = filename.match(/\.([^.]+)$/);
|
|
235
|
-
return match ? match[1].toLowerCase() : "";
|
|
236
|
-
}
|
|
237
|
-
function jitter(value, percent = .2) {
|
|
238
|
-
const randomFactor = 1 + (Math.random() * 2 - 1) * percent;
|
|
239
|
-
return Math.round(value * randomFactor);
|
|
240
|
-
}
|
|
241
|
-
function shouldRetry(error, attempt, maxRetries) {
|
|
242
|
-
if (attempt >= maxRetries) return false;
|
|
243
|
-
if (isRetryableError(error)) return true;
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
function isRetryableError(error) {
|
|
247
|
-
if (error instanceof Error && (error.message.includes("ECONNRESET") || error.message.includes("ETIMEDOUT") || error.message.includes("ENOTFOUND") || error.message.includes("ECONNREFUSED"))) return true;
|
|
248
|
-
const errorWithResponse = error;
|
|
249
|
-
const statusCode = errorWithResponse?.response?.status ?? errorWithResponse?.statusCode;
|
|
250
|
-
if (statusCode && typeof statusCode === "number" && RETRYABLE_STATUS_CODES.has(statusCode)) {
|
|
251
|
-
if (statusCode === 429) {
|
|
252
|
-
const code = errorWithResponse?.response?.data?.code ?? errorWithResponse?.code;
|
|
253
|
-
const retryAfter = errorWithResponse?.response?.headers?.["retry-after"];
|
|
254
|
-
if (code === "QUOTA_EXCEEDED" && !retryAfter) return false;
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
257
|
-
if (statusCode === 409) return (errorWithResponse?.response?.data?.code ?? errorWithResponse?.code) === "ABORTED";
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
function calculateRetryDelay(attempt) {
|
|
263
|
-
const delayWithJitter = jitter(INITIAL_RETRY_DELAY * Math.pow(RETRY_DELAY_BASE, attempt));
|
|
264
|
-
return Math.min(delayWithJitter, MAX_RETRY_DELAY);
|
|
265
|
-
}
|
|
266
|
-
function getRetryAfter(error) {
|
|
267
|
-
const retryAfter = error?.response?.headers?.["retry-after"];
|
|
268
|
-
if (!retryAfter || typeof retryAfter !== "string") return;
|
|
269
|
-
const seconds = parseInt(retryAfter, 10);
|
|
270
|
-
if (!isNaN(seconds)) return seconds * 1e3;
|
|
271
|
-
const date = new Date(retryAfter);
|
|
272
|
-
if (!isNaN(date.getTime())) return Math.max(0, date.getTime() - Date.now());
|
|
273
|
-
}
|
|
274
|
-
async function withRetry(fn, maxRetries, onRetry) {
|
|
275
|
-
let lastError;
|
|
276
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) try {
|
|
277
|
-
return await fn();
|
|
278
|
-
} catch (error) {
|
|
279
|
-
lastError = error;
|
|
280
|
-
if (!shouldRetry(error, attempt, maxRetries)) throw error;
|
|
281
|
-
let delay = calculateRetryDelay(attempt);
|
|
282
|
-
const retryAfter = getRetryAfter(error);
|
|
283
|
-
if (retryAfter !== void 0) delay = retryAfter;
|
|
284
|
-
if (onRetry) onRetry(attempt + 1, error);
|
|
285
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
286
|
-
}
|
|
287
|
-
throw lastError;
|
|
288
|
-
}
|
|
289
|
-
var HttpClient = class {
|
|
290
|
-
axios;
|
|
291
|
-
maxRetries;
|
|
292
|
-
uploadTimeout;
|
|
293
|
-
constructor(options) {
|
|
294
|
-
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
295
|
-
this.uploadTimeout = options.uploadTimeout ?? 6e5;
|
|
296
|
-
this.axios = axios.create({
|
|
297
|
-
baseURL: options.baseURL,
|
|
298
|
-
timeout: options.timeout ?? DEFAULT_TIMEOUT,
|
|
299
|
-
headers: {
|
|
300
|
-
"User-Agent": `knowhere-node-sdk/${VERSION}`,
|
|
301
|
-
Authorization: `Bearer ${options.apiKey}`,
|
|
302
|
-
"Content-Type": "application/json",
|
|
303
|
-
...options.defaultHeaders
|
|
304
|
-
},
|
|
305
|
-
httpAgent: options.httpAgent,
|
|
306
|
-
httpsAgent: options.httpsAgent
|
|
307
|
-
});
|
|
308
|
-
this.setupInterceptors();
|
|
309
|
-
}
|
|
310
|
-
setupInterceptors() {
|
|
311
|
-
this.axios.interceptors.request.use((config) => {
|
|
312
|
-
if (config.data && typeof config.data === "object") config.data = keysToSnake(config.data);
|
|
313
|
-
return config;
|
|
314
|
-
}, (error) => {
|
|
315
|
-
return Promise.reject(this.handleError(error));
|
|
316
|
-
});
|
|
317
|
-
this.axios.interceptors.response.use((response) => {
|
|
318
|
-
if (response.data && typeof response.data === "object") {
|
|
319
|
-
let data = keysToCamel(response.data);
|
|
320
|
-
data = parseDates(data);
|
|
321
|
-
response.data = data;
|
|
322
|
-
}
|
|
323
|
-
return response;
|
|
324
|
-
}, (error) => {
|
|
325
|
-
return Promise.reject(this.handleError(error));
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
handleError(error) {
|
|
329
|
-
if (!error.response) {
|
|
330
|
-
if (error.code === "ECONNABORTED" || error.message.includes("timeout")) return new TimeoutError("Request timed out");
|
|
331
|
-
return new NetworkError(error.message || "Network error", error);
|
|
332
|
-
}
|
|
333
|
-
const { status, data, headers } = error.response;
|
|
334
|
-
const errorData = data;
|
|
335
|
-
const message = typeof errorData?.message === "string" ? errorData.message : typeof errorData?.error === "string" ? errorData.error : `HTTP ${status} error`;
|
|
336
|
-
const code = typeof errorData?.code === "string" ? errorData.code : void 0;
|
|
337
|
-
const requestId = headers["x-request-id"];
|
|
338
|
-
const details = errorData?.details;
|
|
339
|
-
let retryAfter;
|
|
340
|
-
if (status === 429) {
|
|
341
|
-
const retryAfterMs = getRetryAfter(error);
|
|
342
|
-
retryAfter = retryAfterMs ? Math.ceil(retryAfterMs / 1e3) : void 0;
|
|
343
|
-
}
|
|
344
|
-
return createAPIError(status, message, code, requestId, details, data, retryAfter);
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* GET request
|
|
348
|
-
*/
|
|
349
|
-
async get(url, config) {
|
|
350
|
-
return withRetry(async () => {
|
|
351
|
-
return (await this.axios.get(url, config)).data;
|
|
352
|
-
}, this.maxRetries, (attempt, error) => {
|
|
353
|
-
console.warn(`Retry attempt ${attempt} for GET ${url}:`, error);
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* POST request
|
|
358
|
-
*/
|
|
359
|
-
async post(url, data, config) {
|
|
360
|
-
return withRetry(async () => {
|
|
361
|
-
return (await this.axios.post(url, data, config)).data;
|
|
362
|
-
}, this.maxRetries, (attempt, error) => {
|
|
363
|
-
console.warn(`Retry attempt ${attempt} for POST ${url}:`, error);
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* PUT request (typically for uploads, no retry)
|
|
368
|
-
*/
|
|
369
|
-
async put(url, data, config) {
|
|
370
|
-
return (await this.axios.put(url, data, {
|
|
371
|
-
...config,
|
|
372
|
-
timeout: this.uploadTimeout
|
|
373
|
-
})).data;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Download file as buffer
|
|
377
|
-
*/
|
|
378
|
-
async download(url, config) {
|
|
379
|
-
return withRetry(async () => {
|
|
380
|
-
const response = await this.axios.get(url, {
|
|
381
|
-
...config,
|
|
382
|
-
responseType: "arraybuffer"
|
|
383
|
-
});
|
|
384
|
-
return Buffer.from(response.data);
|
|
385
|
-
}, this.maxRetries, (attempt, error) => {
|
|
386
|
-
console.warn(`Retry attempt ${attempt} for download ${url}:`, error);
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Upload file with progress tracking
|
|
391
|
-
*/
|
|
392
|
-
async upload(url, data, options) {
|
|
393
|
-
await this.axios.put(url, data, {
|
|
394
|
-
headers: { ...options?.headers },
|
|
395
|
-
timeout: this.uploadTimeout,
|
|
396
|
-
signal: options?.signal,
|
|
397
|
-
onUploadProgress: (progressEvent) => {
|
|
398
|
-
if (options?.onProgress) {
|
|
399
|
-
const loaded = progressEvent.loaded;
|
|
400
|
-
const total = progressEvent.total;
|
|
401
|
-
const percent = total ? Math.round(loaded / total * 100) : 0;
|
|
402
|
-
options.onProgress({
|
|
403
|
-
loaded,
|
|
404
|
-
total,
|
|
405
|
-
percent
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Get the underlying axios instance
|
|
413
|
-
*/
|
|
414
|
-
getAxiosInstance() {
|
|
415
|
-
return this.axios;
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
var BaseResource = class {
|
|
419
|
-
httpClient;
|
|
420
|
-
constructor(httpClient) {
|
|
421
|
-
this.httpClient = httpClient;
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
async function uploadFile(httpClient, uploadUrl, file, options) {
|
|
425
|
-
let data;
|
|
426
|
-
let contentLength;
|
|
427
|
-
if (typeof file === "string") {
|
|
428
|
-
contentLength = (await promises.stat(file)).size;
|
|
429
|
-
data = createReadStream(file);
|
|
430
|
-
} else if (file instanceof Buffer) {
|
|
431
|
-
contentLength = file.length;
|
|
432
|
-
data = file;
|
|
433
|
-
} else if (isReadStream(file)) {
|
|
434
|
-
data = file;
|
|
435
|
-
contentLength = file.bytesRead;
|
|
436
|
-
} else if (file instanceof Uint8Array) {
|
|
437
|
-
contentLength = file.length;
|
|
438
|
-
data = Buffer.from(file);
|
|
439
|
-
} else throw new ValidationError("Unsupported file type");
|
|
440
|
-
await httpClient.upload(uploadUrl, data, {
|
|
441
|
-
headers: {
|
|
442
|
-
"Content-Type": "application/octet-stream",
|
|
443
|
-
...contentLength ? { "Content-Length": contentLength.toString() } : {},
|
|
444
|
-
...options?.headers
|
|
445
|
-
},
|
|
446
|
-
onProgress: options?.onProgress,
|
|
447
|
-
signal: options?.signal
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
function isReadStream(obj) {
|
|
451
|
-
return typeof obj === "object" && obj !== null && "pipe" in obj && "read" in obj && typeof obj.pipe === "function";
|
|
452
|
-
}
|
|
453
|
-
async function pollJobStatus(httpClient, jobId, options) {
|
|
454
|
-
const pollInterval = options?.pollInterval ?? DEFAULT_POLL_INTERVAL;
|
|
455
|
-
const pollTimeout = options?.pollTimeout ?? DEFAULT_POLL_TIMEOUT;
|
|
456
|
-
const onProgress = options?.onProgress;
|
|
457
|
-
const signal = options?.signal;
|
|
458
|
-
const startTime = Date.now();
|
|
459
|
-
let currentInterval = pollInterval;
|
|
460
|
-
while (true) {
|
|
461
|
-
if (signal?.aborted) throw new Error("Polling aborted");
|
|
462
|
-
const jobResult = await httpClient.get(`/v1/jobs/${jobId}`);
|
|
463
|
-
enrichJobResult(jobResult);
|
|
464
|
-
const elapsed = Date.now() - startTime;
|
|
465
|
-
const elapsedSeconds = Math.floor(elapsed / 1e3);
|
|
466
|
-
if (onProgress) onProgress({
|
|
467
|
-
status: jobResult.status,
|
|
468
|
-
elapsedSeconds,
|
|
469
|
-
jobResult
|
|
470
|
-
});
|
|
471
|
-
if (jobResult.isTerminal) {
|
|
472
|
-
if (jobResult.isDone) return jobResult;
|
|
473
|
-
if (jobResult.isFailed && jobResult.error) throw new JobFailedError(jobResult.error.message, jobResult.error.code, jobResult);
|
|
474
|
-
throw new JobFailedError(`Job ${jobId} failed with status ${jobResult.status}`, "UNKNOWN_ERROR", jobResult);
|
|
475
|
-
}
|
|
476
|
-
if (elapsed >= pollTimeout) throw new PollingTimeoutError(`Polling timeout after ${elapsedSeconds} seconds`, elapsed);
|
|
477
|
-
if (elapsed > POLL_INTERVAL_INCREASE_THRESHOLD) currentInterval = Math.min(currentInterval * POLL_INTERVAL_MULTIPLIER, MAX_POLL_INTERVAL);
|
|
478
|
-
await sleep(currentInterval);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
async function parseResult(httpClient, resultUrl, options) {
|
|
482
|
-
const zipBuffer = await httpClient.download(resultUrl);
|
|
483
|
-
if (options?.verifyChecksum !== false) {}
|
|
484
|
-
const zip = await import_jszip_min.default.loadAsync(zipBuffer);
|
|
485
|
-
const manifestFile = zip.file("manifest.json");
|
|
486
|
-
if (!manifestFile) throw new KnowhereError("manifest.json not found in ZIP");
|
|
487
|
-
const manifestContent = await manifestFile.async("string");
|
|
488
|
-
let manifest = JSON.parse(manifestContent);
|
|
489
|
-
manifest = keysToCamel(manifest);
|
|
490
|
-
manifest = parseDates(manifest);
|
|
491
|
-
const chunksFile = zip.file("chunks.json");
|
|
492
|
-
if (!chunksFile) throw new KnowhereError("chunks.json not found in ZIP");
|
|
493
|
-
const chunksContent = await chunksFile.async("string");
|
|
494
|
-
let chunksData = JSON.parse(chunksContent);
|
|
495
|
-
chunksData = keysToCamel(chunksData);
|
|
496
|
-
const chunks = [];
|
|
497
|
-
for (const chunkData of chunksData) {
|
|
498
|
-
const chunk = await processChunk(zip, chunkData);
|
|
499
|
-
chunks.push(chunk);
|
|
500
|
-
}
|
|
501
|
-
let fullMarkdown;
|
|
502
|
-
const fullMdFile = zip.file("full.md");
|
|
503
|
-
if (fullMdFile) fullMarkdown = await fullMdFile.async("string");
|
|
504
|
-
let hierarchy;
|
|
505
|
-
const hierarchyFile = zip.file("hierarchy.json");
|
|
506
|
-
if (hierarchyFile) {
|
|
507
|
-
const hierarchyContent = await hierarchyFile.async("string");
|
|
508
|
-
hierarchy = JSON.parse(hierarchyContent);
|
|
509
|
-
}
|
|
510
|
-
return {
|
|
511
|
-
manifest,
|
|
512
|
-
chunks,
|
|
513
|
-
fullMarkdown,
|
|
514
|
-
hierarchy,
|
|
515
|
-
rawZip: zipBuffer,
|
|
516
|
-
get textChunks() {
|
|
517
|
-
return chunks.filter((c) => c.type === "text");
|
|
518
|
-
},
|
|
519
|
-
get imageChunks() {
|
|
520
|
-
return chunks.filter((c) => c.type === "image");
|
|
521
|
-
},
|
|
522
|
-
get tableChunks() {
|
|
523
|
-
return chunks.filter((c) => c.type === "table");
|
|
524
|
-
},
|
|
525
|
-
get jobId() {
|
|
526
|
-
return manifest.jobId;
|
|
527
|
-
},
|
|
528
|
-
get statistics() {
|
|
529
|
-
return manifest.statistics;
|
|
530
|
-
},
|
|
531
|
-
getChunk(chunkId) {
|
|
532
|
-
return chunks.find((c) => c.chunkId === chunkId);
|
|
533
|
-
},
|
|
534
|
-
async save(directory) {
|
|
535
|
-
await promises.mkdir(directory, { recursive: true });
|
|
536
|
-
await promises.writeFile(join(directory, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
537
|
-
await promises.writeFile(join(directory, "chunks.json"), JSON.stringify(chunks, null, 2));
|
|
538
|
-
if (fullMarkdown) await promises.writeFile(join(directory, "full.md"), fullMarkdown);
|
|
539
|
-
if (hierarchy) await promises.writeFile(join(directory, "hierarchy.json"), JSON.stringify(hierarchy, null, 2));
|
|
540
|
-
for (const imageChunk of this.imageChunks) await imageChunk.save(directory);
|
|
541
|
-
for (const tableChunk of this.tableChunks) await tableChunk.save(directory);
|
|
542
|
-
await promises.writeFile(join(directory, "result.zip"), zipBuffer);
|
|
543
|
-
return directory;
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
async function processChunk(zip, chunkData) {
|
|
548
|
-
if (chunkData.type === "text") return chunkData;
|
|
549
|
-
if (chunkData.type === "image") {
|
|
550
|
-
const imageChunk = chunkData;
|
|
551
|
-
const sanitized = sanitizePath(imageChunk.filePath);
|
|
552
|
-
const imageFile = zip.file(sanitized);
|
|
553
|
-
if (!imageFile) throw new KnowhereError(`Image file not found: ${imageChunk.filePath}`);
|
|
554
|
-
const imageBuffer = await imageFile.async("nodebuffer");
|
|
555
|
-
return {
|
|
556
|
-
...imageChunk,
|
|
557
|
-
data: imageBuffer,
|
|
558
|
-
get format() {
|
|
559
|
-
return getFileExtension(this.filePath);
|
|
560
|
-
},
|
|
561
|
-
async save(directory) {
|
|
562
|
-
const outputPath = join(directory, sanitizePath(this.filePath));
|
|
563
|
-
const outputDir = dirname(outputPath);
|
|
564
|
-
await promises.mkdir(outputDir, { recursive: true });
|
|
565
|
-
await promises.writeFile(outputPath, this.data);
|
|
566
|
-
return outputPath;
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
if (chunkData.type === "table") {
|
|
571
|
-
const tableChunk = chunkData;
|
|
572
|
-
const sanitized = sanitizePath(tableChunk.filePath);
|
|
573
|
-
const htmlFile = zip.file(sanitized);
|
|
574
|
-
if (!htmlFile) throw new KnowhereError(`Table file not found: ${tableChunk.filePath}`);
|
|
575
|
-
const html = await htmlFile.async("string");
|
|
576
|
-
return {
|
|
577
|
-
...tableChunk,
|
|
578
|
-
html,
|
|
579
|
-
async save(directory) {
|
|
580
|
-
const outputPath = join(directory, sanitizePath(this.filePath));
|
|
581
|
-
const outputDir = dirname(outputPath);
|
|
582
|
-
await promises.mkdir(outputDir, { recursive: true });
|
|
583
|
-
await promises.writeFile(outputPath, this.html);
|
|
584
|
-
return outputPath;
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
throw new KnowhereError(`Unknown chunk type: ${chunkData.type}`);
|
|
589
|
-
}
|
|
590
|
-
var Jobs = class extends BaseResource {
|
|
591
|
-
/**
|
|
592
|
-
* Create a new parsing job
|
|
593
|
-
*/
|
|
594
|
-
async create(params) {
|
|
595
|
-
return await this.httpClient.post("/v1/jobs", params);
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Get job status
|
|
599
|
-
*/
|
|
600
|
-
async get(jobId) {
|
|
601
|
-
const jobResult = await this.httpClient.get(`/v1/jobs/${jobId}`);
|
|
602
|
-
enrichJobResult(jobResult);
|
|
603
|
-
return jobResult;
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* Upload file for a job
|
|
607
|
-
*/
|
|
608
|
-
async upload(jobId, params) {
|
|
609
|
-
const response = await this.httpClient.get(`/v1/jobs/${jobId}`);
|
|
610
|
-
if (!response.uploadUrl) throw new NotFoundError("Upload URL not available for this job");
|
|
611
|
-
await uploadFile(this.httpClient, response.uploadUrl, params.file, {
|
|
612
|
-
headers: response.uploadHeaders,
|
|
613
|
-
onProgress: params.onProgress,
|
|
614
|
-
signal: params.signal
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Wait for job completion
|
|
619
|
-
*/
|
|
620
|
-
async wait(jobId, options) {
|
|
621
|
-
return pollJobStatus(this.httpClient, jobId, options);
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Load parse result from completed job
|
|
625
|
-
*/
|
|
626
|
-
async load(jobId, options) {
|
|
627
|
-
const jobResult = await this.get(jobId);
|
|
628
|
-
if (!jobResult.isDone) throw new Error(`Job ${jobId} is not done yet (status: ${jobResult.status})`);
|
|
629
|
-
if (!jobResult.resultUrl) throw new NotFoundError("Result URL not available");
|
|
630
|
-
return parseResult(this.httpClient, jobResult.resultUrl, options);
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
var Knowhere = class {
|
|
634
|
-
/** Jobs resource for low-level API */
|
|
635
|
-
jobs;
|
|
636
|
-
httpClient;
|
|
637
|
-
/**
|
|
638
|
-
* Create a new Knowhere client
|
|
639
|
-
*/
|
|
640
|
-
constructor(options = {}) {
|
|
641
|
-
const apiKey = options.apiKey ?? process.env[ENV.API_KEY];
|
|
642
|
-
if (!apiKey) throw new ValidationError(`API key is required. Provide it via options.apiKey or ${ENV.API_KEY} environment variable.`);
|
|
643
|
-
this.httpClient = new HttpClient({
|
|
644
|
-
baseURL: options.baseURL ?? process.env[ENV.BASE_URL] ?? DEFAULT_BASE_URL,
|
|
645
|
-
apiKey,
|
|
646
|
-
timeout: options.timeout,
|
|
647
|
-
uploadTimeout: options.uploadTimeout,
|
|
648
|
-
maxRetries: options.maxRetries,
|
|
649
|
-
defaultHeaders: options.defaultHeaders,
|
|
650
|
-
httpAgent: options.httpAgent,
|
|
651
|
-
httpsAgent: options.httpsAgent
|
|
652
|
-
});
|
|
653
|
-
this.jobs = new Jobs(this.httpClient);
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* High-level API: Parse a document and return structured results
|
|
657
|
-
*
|
|
658
|
-
* @example
|
|
659
|
-
* ```typescript
|
|
660
|
-
* // Parse from URL
|
|
661
|
-
* const result = await client.parse({ url: 'https://example.com/doc.pdf' });
|
|
662
|
-
*
|
|
663
|
-
* // Parse from file
|
|
664
|
-
* const result = await client.parse({ file: './document.pdf' });
|
|
665
|
-
*
|
|
666
|
-
* // Parse with options
|
|
667
|
-
* const result = await client.parse({
|
|
668
|
-
* url: 'https://example.com/doc.pdf',
|
|
669
|
-
* model: 'advanced',
|
|
670
|
-
* ocr: true,
|
|
671
|
-
* onUploadProgress: (p) => console.log(`${p.percent}%`),
|
|
672
|
-
* });
|
|
673
|
-
* ```
|
|
674
|
-
*/
|
|
675
|
-
async parse(params) {
|
|
676
|
-
if (!params.url && !params.file) throw new ValidationError("Either url or file must be provided");
|
|
677
|
-
if (params.url && params.file) throw new ValidationError("Only one of url or file can be provided");
|
|
678
|
-
const sourceType = params.url ? "url" : "file";
|
|
679
|
-
const parsingParams = {
|
|
680
|
-
model: params.model,
|
|
681
|
-
ocrEnabled: params.ocr,
|
|
682
|
-
docType: params.docType,
|
|
683
|
-
smartTitleParse: params.smartTitleParse,
|
|
684
|
-
summaryImage: params.summaryImage,
|
|
685
|
-
summaryTable: params.summaryTable,
|
|
686
|
-
summaryTxt: params.summaryText,
|
|
687
|
-
addFragDesc: params.addFragDesc,
|
|
688
|
-
kbDir: params.kbDir
|
|
689
|
-
};
|
|
690
|
-
Object.keys(parsingParams).forEach((key) => {
|
|
691
|
-
if (parsingParams[key] === void 0) delete parsingParams[key];
|
|
692
|
-
});
|
|
693
|
-
const webhook = params.webhook;
|
|
694
|
-
const job = await this.jobs.create({
|
|
695
|
-
sourceType,
|
|
696
|
-
sourceUrl: params.url,
|
|
697
|
-
fileName: params.fileName,
|
|
698
|
-
dataId: params.dataId,
|
|
699
|
-
parsingParams: Object.keys(parsingParams).length > 0 ? parsingParams : void 0,
|
|
700
|
-
webhook
|
|
701
|
-
});
|
|
702
|
-
if (params.file) await this.jobs.upload(job.jobId, {
|
|
703
|
-
file: params.file,
|
|
704
|
-
onProgress: params.onUploadProgress,
|
|
705
|
-
signal: params.signal
|
|
706
|
-
});
|
|
707
|
-
const jobResult = await this.jobs.wait(job.jobId, {
|
|
708
|
-
pollInterval: params.pollInterval,
|
|
709
|
-
pollTimeout: params.pollTimeout,
|
|
710
|
-
onProgress: params.onPollProgress,
|
|
711
|
-
signal: params.signal
|
|
712
|
-
});
|
|
713
|
-
return await this.jobs.load(jobResult.jobId, { verifyChecksum: params.verifyChecksum });
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
//#endregion
|
|
717
|
-
export { Knowhere };
|