@ontos-ai/knowhere-claw 0.1.4 → 0.1.5
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/README.md +3 -0
- package/dist/_virtual/_rolldown/runtime.js +2 -1
- package/dist/config.js +115 -1
- package/dist/connect-builder.js +181 -0
- package/dist/graph-builder.js +204 -0
- package/dist/index.js +15 -3
- package/dist/kg-service.js +249 -0
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js +212 -0
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/pre-binding.js +35 -0
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/abi_crosswalk.js +2609 -0
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/napi.js +142 -0
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js +103 -0
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js +199 -0
- package/dist/node_modules/.pnpm/@mapbox_node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/package.js +67 -0
- package/dist/node_modules/.pnpm/abbrev@1.1.1/node_modules/abbrev/abbrev.js +59 -0
- package/dist/node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js +11 -0
- package/dist/node_modules/.pnpm/aproba@2.1.0/node_modules/aproba/index.js +119 -0
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/index.js +13 -0
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-base.js +16 -0
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-group.js +98 -0
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-stream.js +37 -0
- package/dist/node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker.js +32 -0
- package/dist/node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js +53 -0
- package/dist/node_modules/.pnpm/brace-expansion@1.1.12/node_modules/brace-expansion/index.js +132 -0
- package/dist/node_modules/.pnpm/color-support@1.1.3/node_modules/color-support/browser.js +18 -0
- package/dist/node_modules/.pnpm/concat-map@0.0.1/node_modules/concat-map/index.js +19 -0
- package/dist/node_modules/.pnpm/console-control-strings@1.1.0/node_modules/console-control-strings/index.js +104 -0
- package/dist/node_modules/.pnpm/delegates@1.0.0/node_modules/delegates/index.js +104 -0
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/detect-libc.js +221 -0
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/elf.js +26 -0
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js +48 -0
- package/dist/node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js +24 -0
- package/dist/node_modules/.pnpm/emoji-regex@8.0.0/node_modules/emoji-regex/index.js +10 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/copy-sync.js +120 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/copy.js +100 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/copy/index.js +15 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/empty/index.js +43 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/file.js +53 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/index.js +27 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/link.js +56 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink-paths.js +89 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink-type.js +35 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/ensure/symlink.js +81 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/fs/index.js +113 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/index.js +29 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/index.js +22 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/jsonfile.js +15 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/output-json-sync.js +15 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/json/output-json.js +15 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/index.js +20 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/make-dir.js +33 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/mkdirs/utils.js +17 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/index.js +15 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/move-sync.js +56 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/move/move.js +49 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/output-file/index.js +30 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/path-exists/index.js +18 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/remove/index.js +27 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/async.js +15 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/stat.js +131 -0
- package/dist/node_modules/.pnpm/fs-extra@11.3.4/node_modules/fs-extra/lib/util/utimes.js +34 -0
- package/dist/node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js +51 -0
- package/dist/node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js +171 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/base-theme.js +21 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/error.js +27 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/has-color.js +9 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/index.js +224 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/plumbing.js +48 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/process.js +8 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/progress-bar.js +46 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/render-template.js +155 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/set-immediate.js +14 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/set-interval.js +8 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/spin.js +10 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/template-item.js +58 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/theme-set.js +99 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/themes.js +67 -0
- package/dist/node_modules/.pnpm/gauge@3.0.2/node_modules/gauge/wide-truncate.js +22 -0
- package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/common.js +162 -0
- package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/glob.js +451 -0
- package/dist/node_modules/.pnpm/glob@7.2.3/node_modules/glob/sync.js +280 -0
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js +20 -0
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js +362 -0
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js +92 -0
- package/dist/node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js +255 -0
- package/dist/node_modules/.pnpm/has-unicode@2.0.1/node_modules/has-unicode/index.js +14 -0
- package/dist/node_modules/.pnpm/inflight@1.0.6/node_modules/inflight/inflight.js +45 -0
- package/dist/node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js +27 -0
- package/dist/node_modules/.pnpm/is-fullwidth-code-point@3.0.0/node_modules/is-fullwidth-code-point/index.js +14 -0
- package/dist/node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/index.js +68 -0
- package/dist/node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/utils.js +19 -0
- package/dist/node_modules/.pnpm/minimatch@3.1.5/node_modules/minimatch/minimatch.js +578 -0
- package/dist/node_modules/.pnpm/nodejieba@2.6.0/node_modules/nodejieba/index.js +46 -0
- package/dist/node_modules/.pnpm/nopt@5.0.0/node_modules/nopt/lib/nopt.js +330 -0
- package/dist/node_modules/.pnpm/npmlog@5.0.1/node_modules/npmlog/log.js +305 -0
- package/dist/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +54 -0
- package/dist/node_modules/.pnpm/once@1.4.0/node_modules/once/once.js +44 -0
- package/dist/node_modules/.pnpm/path-is-absolute@1.0.1/node_modules/path-is-absolute/index.js +19 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/errors-browser.js +88 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_duplex.js +75 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_passthrough.js +19 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js +666 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_transform.js +89 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js +423 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/async_iterator.js +172 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/buffer_list.js +243 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/destroy.js +77 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +87 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from-browser.js +10 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/pipeline.js +80 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/state.js +21 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/stream-browser.js +8 -0
- package/dist/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/readable-browser.js +23 -0
- package/dist/node_modules/.pnpm/rimraf@3.0.2/node_modules/rimraf/rimraf.js +229 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js +79 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js +282 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js +186 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js +14 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js +41 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js +34 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js +15 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js +32 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js +22 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js +19 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js +14 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js +18 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js +14 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js +99 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js +28 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js +8 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js +23 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js +36 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js +15 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js +84 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js +15 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js +31 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js +31 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js +45 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js +64 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js +35 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js +102 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js +11 -0
- package/dist/node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js +17 -0
- package/dist/node_modules/.pnpm/set-blocking@2.0.0/node_modules/set-blocking/index.js +12 -0
- package/dist/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +130 -0
- package/dist/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +16 -0
- package/dist/node_modules/.pnpm/string-width@4.2.3/node_modules/string-width/index.js +30 -0
- package/dist/node_modules/.pnpm/strip-ansi@6.0.1/node_modules/strip-ansi/index.js +10 -0
- package/dist/node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js +26 -0
- package/dist/node_modules/.pnpm/util-deprecate@1.0.2/node_modules/util-deprecate/browser.js +59 -0
- package/dist/node_modules/.pnpm/wide-align@1.1.5/node_modules/wide-align/align.js +52 -0
- package/dist/node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js +26 -0
- package/dist/tools.js +163 -3
- package/openclaw.plugin.json +1 -1
- package/package.json +15 -6
- package/skills/knowhere/SKILL.md +1 -1
- package/dist/__tests__/channel-route.test.d.ts +0 -1
- package/dist/__tests__/ingest-tool.test.d.ts +0 -1
- package/dist/__tests__/read-result-file-tool.test.d.ts +0 -1
- package/dist/__tests__/tracker-progress.test.d.ts +0 -1
- package/dist/channel-delivery.d.ts +0 -21
- package/dist/client.d.ts +0 -33
- package/dist/config.d.ts +0 -12
- package/dist/error-message.d.ts +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/parser.d.ts +0 -16
- package/dist/session.d.ts +0 -11
- package/dist/store.d.ts +0 -79
- package/dist/text.d.ts +0 -10
- package/dist/tools.d.ts +0 -8
- package/dist/tracker-progress.d.ts +0 -10
- package/dist/types.d.ts +0 -248
|
@@ -0,0 +1,249 @@
|
|
|
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
|
+
import { buildConnections, init_connect_builder } from "./connect-builder.js";
|
|
5
|
+
import { buildKnowledgeGraph } from "./graph-builder.js";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
//#region src/kg-service.ts
|
|
10
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
11
|
+
var import_nodejieba = /* @__PURE__ */ __toESM(require_nodejieba(), 1);
|
|
12
|
+
init_connect_builder();
|
|
13
|
+
const DEFAULT_CONNECT_CONFIG = {
|
|
14
|
+
minKeywordOverlap: 3,
|
|
15
|
+
keywordScoreWeight: 1,
|
|
16
|
+
maxConnectionsPerChunk: 10,
|
|
17
|
+
minScoreThreshold: .8,
|
|
18
|
+
crossFileOnly: true,
|
|
19
|
+
maxContentOverlap: .8
|
|
20
|
+
};
|
|
21
|
+
const DEFAULT_KG_CONFIG = {
|
|
22
|
+
enableKnowledgeGraph: true,
|
|
23
|
+
kbIdSource: "disabled",
|
|
24
|
+
concurrentBuildStrategy: "queue",
|
|
25
|
+
buildTimeout: 3e5,
|
|
26
|
+
notifyOnGraphFailure: false
|
|
27
|
+
};
|
|
28
|
+
var KnowledgeGraphService = class {
|
|
29
|
+
config;
|
|
30
|
+
logger;
|
|
31
|
+
degradationMode = "full";
|
|
32
|
+
buildQueues = /* @__PURE__ */ new Map();
|
|
33
|
+
jiebaInitialized = false;
|
|
34
|
+
constructor(params) {
|
|
35
|
+
this.config = {
|
|
36
|
+
...DEFAULT_KG_CONFIG,
|
|
37
|
+
...params.config,
|
|
38
|
+
kbId: params.config.kbId || void 0,
|
|
39
|
+
connectConfig: {
|
|
40
|
+
...DEFAULT_CONNECT_CONFIG,
|
|
41
|
+
...params.config.connectConfig
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
this.logger = params.logger;
|
|
45
|
+
}
|
|
46
|
+
async initialize() {
|
|
47
|
+
if (!this.config.enableKnowledgeGraph) {
|
|
48
|
+
this.degradationMode = "disabled";
|
|
49
|
+
this.logger.info("Knowledge graph disabled by configuration");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
await this.checkPythonEnvironment();
|
|
54
|
+
await this.initializeJieba();
|
|
55
|
+
this.degradationMode = "full";
|
|
56
|
+
this.logger.info("Knowledge graph service initialized in full mode");
|
|
57
|
+
} catch (error) {
|
|
58
|
+
this.logger.warn(`Knowledge graph initialization failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
59
|
+
if (error.code === "PYTHON_MISSING") {
|
|
60
|
+
this.degradationMode = "disabled";
|
|
61
|
+
this.logger.warn("Python not found, knowledge graph disabled");
|
|
62
|
+
} else if (error.code === "NODEJIEBA_MISSING") {
|
|
63
|
+
this.degradationMode = "basic";
|
|
64
|
+
this.logger.warn("Nodejieba missing, using basic tokenization");
|
|
65
|
+
} else this.degradationMode = "disabled";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async checkPythonEnvironment() {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const python = spawn("python3", ["--version"]);
|
|
71
|
+
python.on("error", (err) => {
|
|
72
|
+
const error = /* @__PURE__ */ new Error("Python3 not found in PATH");
|
|
73
|
+
error.code = "PYTHON_MISSING";
|
|
74
|
+
reject(error);
|
|
75
|
+
});
|
|
76
|
+
python.on("close", (code) => {
|
|
77
|
+
if (code === 0) {
|
|
78
|
+
this.logger.info("Python3 environment detected");
|
|
79
|
+
resolve();
|
|
80
|
+
} else {
|
|
81
|
+
const error = /* @__PURE__ */ new Error(`Python3 check failed with code ${code}`);
|
|
82
|
+
error.code = "PYTHON_MISSING";
|
|
83
|
+
reject(error);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async initializeJieba() {
|
|
89
|
+
try {
|
|
90
|
+
import_nodejieba.load();
|
|
91
|
+
this.jiebaInitialized = true;
|
|
92
|
+
this.logger.info("Nodejieba initialized successfully");
|
|
93
|
+
} catch (error) {
|
|
94
|
+
const err = /* @__PURE__ */ new Error("Failed to initialize nodejieba");
|
|
95
|
+
err.code = "NODEJIEBA_MISSING";
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async extractKeywords(text, topK = 20) {
|
|
100
|
+
if (this.degradationMode === "disabled") return [];
|
|
101
|
+
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) => {
|
|
104
|
+
if (kw.length <= 1) return false;
|
|
105
|
+
if (/^\d+$/.test(kw)) return false;
|
|
106
|
+
return true;
|
|
107
|
+
}).slice(0, topK);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
this.logger.warn(`Jieba extraction failed, falling back to basic: ${error}`);
|
|
110
|
+
this.degradationMode = "basic";
|
|
111
|
+
}
|
|
112
|
+
return text.split(/\s+/).filter((w) => w.length > 1).slice(0, topK);
|
|
113
|
+
}
|
|
114
|
+
resolveKbId(context) {
|
|
115
|
+
if (!this.config.enableKnowledgeGraph) return null;
|
|
116
|
+
if (this.config.kbId?.trim()) return this.config.kbId.trim();
|
|
117
|
+
switch (this.config.kbIdSource || "disabled") {
|
|
118
|
+
case "disabled": return null;
|
|
119
|
+
case "agent": return context.agentId ? `agent-${context.agentId}` : null;
|
|
120
|
+
case "agent-session":
|
|
121
|
+
if (context.agentId && context.sessionId) return `agent-${context.agentId}-session-${context.sessionId}`;
|
|
122
|
+
if (context.agentId && context.sessionKey) return `agent-${context.agentId}-session-${context.sessionKey}`;
|
|
123
|
+
return context.agentId ? `agent-${context.agentId}` : null;
|
|
124
|
+
case "global": return "global";
|
|
125
|
+
default: return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
getKbPath(kbId) {
|
|
129
|
+
return path.join(os.homedir(), ".knowhere", kbId);
|
|
130
|
+
}
|
|
131
|
+
async ensureKbDirectory(kbId) {
|
|
132
|
+
const kbPath = this.getKbPath(kbId);
|
|
133
|
+
await import_lib.default.ensureDir(kbPath);
|
|
134
|
+
return kbPath;
|
|
135
|
+
}
|
|
136
|
+
async saveDocumentToKb(params) {
|
|
137
|
+
const kbPath = await this.ensureKbDirectory(params.kbId);
|
|
138
|
+
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 });
|
|
141
|
+
const keywordsPath = path.join(docDir, "keywords.json");
|
|
142
|
+
await import_lib.default.writeJSON(keywordsPath, params.keywords, { spaces: 2 });
|
|
143
|
+
const metadataPath = path.join(docDir, "metadata.json");
|
|
144
|
+
await import_lib.default.writeJSON(metadataPath, params.metadata, { spaces: 2 });
|
|
145
|
+
this.logger.info(`Document saved to knowledge base: kb=${params.kbId} doc=${params.docId}`);
|
|
146
|
+
}
|
|
147
|
+
async scheduleBuild(kbId, task) {
|
|
148
|
+
if ((this.config.concurrentBuildStrategy || "queue") === "skip") {
|
|
149
|
+
if (this.buildQueues.has(kbId)) {
|
|
150
|
+
this.logger.info(`Skipping KG build for ${kbId} (already building)`);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const next = (this.buildQueues.get(kbId) || Promise.resolve()).then(() => task()).catch((err) => {
|
|
155
|
+
this.logger.error(`KG build failed for ${kbId}: ${err}`);
|
|
156
|
+
throw err;
|
|
157
|
+
}).finally(() => {
|
|
158
|
+
if (this.buildQueues.get(kbId) === next) this.buildQueues.delete(kbId);
|
|
159
|
+
});
|
|
160
|
+
this.buildQueues.set(kbId, next);
|
|
161
|
+
await next;
|
|
162
|
+
}
|
|
163
|
+
async buildKnowledgeGraph(kbId) {
|
|
164
|
+
const kbPath = this.getKbPath(kbId);
|
|
165
|
+
const docs = await import_lib.default.readdir(kbPath);
|
|
166
|
+
const docDirs = [];
|
|
167
|
+
for (const doc of docs) {
|
|
168
|
+
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);
|
|
170
|
+
}
|
|
171
|
+
if (docDirs.length < 2) {
|
|
172
|
+
this.logger.info(`Not enough documents for graph building (need >=2, have ${docDirs.length}), skipping`);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.logger.info(`Building knowledge graph for ${docDirs.length} documents in kb=${kbId}`);
|
|
176
|
+
try {
|
|
177
|
+
const allChunks = [];
|
|
178
|
+
for (const docDir of docDirs) {
|
|
179
|
+
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);
|
|
182
|
+
if (chunksData.chunks && Array.isArray(chunksData.chunks)) allChunks.push(...chunksData.chunks);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (allChunks.length === 0) {
|
|
186
|
+
this.logger.warn(`No chunks found in kb=${kbId}, skipping graph build`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.logger.info(`Loaded ${allChunks.length} chunks from ${docDirs.length} documents`);
|
|
190
|
+
const connections = buildConnections(allChunks, this.config.connectConfig, this.logger);
|
|
191
|
+
this.logger.info(`Built ${connections.length} connections`);
|
|
192
|
+
const chunkStatsPath = path.join(kbPath, "chunk_stats.json");
|
|
193
|
+
let chunkStats = {};
|
|
194
|
+
if (await import_lib.default.pathExists(chunkStatsPath)) chunkStats = await import_lib.default.readJSON(chunkStatsPath);
|
|
195
|
+
const knowledgeGraph = buildKnowledgeGraph(allChunks, connections, chunkStats, this.jiebaInitialized, this.logger);
|
|
196
|
+
const graphFile = path.join(kbPath, "knowledge_graph.json");
|
|
197
|
+
await import_lib.default.writeJSON(graphFile, knowledgeGraph, { spaces: 2 });
|
|
198
|
+
this.logger.info(`Knowledge graph saved to ${graphFile}`);
|
|
199
|
+
await this.updateKbMetadata(kbPath, {
|
|
200
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
201
|
+
documentCount: docDirs.length
|
|
202
|
+
});
|
|
203
|
+
this.logger.info(`Knowledge graph built successfully for kb=${kbId}`);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
this.logger.error(`Failed to build knowledge graph: ${error}`);
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async updateKbMetadata(kbPath, updates) {
|
|
210
|
+
const metadataPath = path.join(kbPath, "kb_metadata.json");
|
|
211
|
+
let metadata = {};
|
|
212
|
+
if (await import_lib.default.pathExists(metadataPath)) metadata = await import_lib.default.readJSON(metadataPath);
|
|
213
|
+
const updated = {
|
|
214
|
+
...metadata,
|
|
215
|
+
...updates
|
|
216
|
+
};
|
|
217
|
+
await import_lib.default.writeJSON(metadataPath, updated, { spaces: 2 });
|
|
218
|
+
}
|
|
219
|
+
async queryGraph(kbId, fileKey) {
|
|
220
|
+
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);
|
|
223
|
+
if (!fileKey) return graph.edges;
|
|
224
|
+
return graph.edges.filter((edge) => edge.source === fileKey || edge.target === fileKey);
|
|
225
|
+
}
|
|
226
|
+
async getKnowledgeGraph(kbId) {
|
|
227
|
+
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);
|
|
230
|
+
}
|
|
231
|
+
async listKnowledgeBases() {
|
|
232
|
+
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);
|
|
235
|
+
}
|
|
236
|
+
async getKbMetadata(kbId) {
|
|
237
|
+
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);
|
|
240
|
+
}
|
|
241
|
+
isEnabled() {
|
|
242
|
+
return this.degradationMode !== "disabled";
|
|
243
|
+
}
|
|
244
|
+
getDegradationMode() {
|
|
245
|
+
return this.degradationMode;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
//#endregion
|
|
249
|
+
export { KnowledgeGraphService };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { __commonJSMin, __require } from "../../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_s3_setup } from "./util/s3_setup.js";
|
|
3
|
+
import { require_nopt } from "../../../../../nopt@5.0.0/node_modules/nopt/lib/nopt.js";
|
|
4
|
+
import { require_log } from "../../../../../npmlog@5.0.1/node_modules/npmlog/log.js";
|
|
5
|
+
import { require_napi } from "./util/napi.js";
|
|
6
|
+
import { require_pre_binding } from "./pre-binding.js";
|
|
7
|
+
import { require_package } from "../package.js";
|
|
8
|
+
//#region node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
|
|
9
|
+
var require_node_pre_gyp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10
|
+
/**
|
|
11
|
+
* Module exports.
|
|
12
|
+
*/
|
|
13
|
+
module.exports = exports;
|
|
14
|
+
/**
|
|
15
|
+
* Module dependencies.
|
|
16
|
+
*/
|
|
17
|
+
exports.mockS3Http = require_s3_setup().get_mockS3Http();
|
|
18
|
+
exports.mockS3Http("on");
|
|
19
|
+
const mocking = exports.mockS3Http("get");
|
|
20
|
+
const fs = __require("fs");
|
|
21
|
+
const path = __require("path");
|
|
22
|
+
const nopt = require_nopt();
|
|
23
|
+
const log = require_log();
|
|
24
|
+
log.disableProgress();
|
|
25
|
+
const napi = require_napi();
|
|
26
|
+
const EE = __require("events").EventEmitter;
|
|
27
|
+
const inherits = __require("util").inherits;
|
|
28
|
+
const cli_commands = [
|
|
29
|
+
"clean",
|
|
30
|
+
"install",
|
|
31
|
+
"reinstall",
|
|
32
|
+
"build",
|
|
33
|
+
"rebuild",
|
|
34
|
+
"package",
|
|
35
|
+
"testpackage",
|
|
36
|
+
"publish",
|
|
37
|
+
"unpublish",
|
|
38
|
+
"info",
|
|
39
|
+
"testbinary",
|
|
40
|
+
"reveal",
|
|
41
|
+
"configure"
|
|
42
|
+
];
|
|
43
|
+
const aliases = {};
|
|
44
|
+
log.heading = "node-pre-gyp";
|
|
45
|
+
if (mocking) log.warn(`mocking s3 to ${process.env.node_pre_gyp_mock_s3}`);
|
|
46
|
+
Object.defineProperty(exports, "find", {
|
|
47
|
+
get: function() {
|
|
48
|
+
return require_pre_binding().find;
|
|
49
|
+
},
|
|
50
|
+
enumerable: true
|
|
51
|
+
});
|
|
52
|
+
function Run({ package_json_path = "./package.json", argv }) {
|
|
53
|
+
this.package_json_path = package_json_path;
|
|
54
|
+
this.commands = {};
|
|
55
|
+
const self = this;
|
|
56
|
+
cli_commands.forEach((command) => {
|
|
57
|
+
self.commands[command] = function(argvx, callback) {
|
|
58
|
+
log.verbose("command", command, argvx);
|
|
59
|
+
return __require("./" + command)(self, argvx, callback);
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
this.parseArgv(argv);
|
|
63
|
+
this.binaryHostSet = false;
|
|
64
|
+
}
|
|
65
|
+
inherits(Run, EE);
|
|
66
|
+
exports.Run = Run;
|
|
67
|
+
const proto = Run.prototype;
|
|
68
|
+
/**
|
|
69
|
+
* Export the contents of the package.json.
|
|
70
|
+
*/
|
|
71
|
+
proto.package = require_package();
|
|
72
|
+
/**
|
|
73
|
+
* nopt configuration definitions
|
|
74
|
+
*/
|
|
75
|
+
proto.configDefs = {
|
|
76
|
+
help: Boolean,
|
|
77
|
+
arch: String,
|
|
78
|
+
debug: Boolean,
|
|
79
|
+
directory: String,
|
|
80
|
+
proxy: String,
|
|
81
|
+
loglevel: String
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* nopt shorthands
|
|
85
|
+
*/
|
|
86
|
+
proto.shorthands = {
|
|
87
|
+
release: "--no-debug",
|
|
88
|
+
C: "--directory",
|
|
89
|
+
debug: "--debug",
|
|
90
|
+
j: "--jobs",
|
|
91
|
+
silent: "--loglevel=silent",
|
|
92
|
+
silly: "--loglevel=silly",
|
|
93
|
+
verbose: "--loglevel=verbose"
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* expose the command aliases for the bin file to use.
|
|
97
|
+
*/
|
|
98
|
+
proto.aliases = aliases;
|
|
99
|
+
/**
|
|
100
|
+
* Parses the given argv array and sets the 'opts', 'argv',
|
|
101
|
+
* 'command', and 'package_json' properties.
|
|
102
|
+
*/
|
|
103
|
+
proto.parseArgv = function parseOpts(argv) {
|
|
104
|
+
this.opts = nopt(this.configDefs, this.shorthands, argv);
|
|
105
|
+
this.argv = this.opts.argv.remain.slice();
|
|
106
|
+
const commands = this.todo = [];
|
|
107
|
+
argv = this.argv.map((arg) => {
|
|
108
|
+
if (arg in this.aliases) arg = this.aliases[arg];
|
|
109
|
+
return arg;
|
|
110
|
+
});
|
|
111
|
+
argv.slice().forEach((arg) => {
|
|
112
|
+
if (arg in this.commands) {
|
|
113
|
+
const args = argv.splice(0, argv.indexOf(arg));
|
|
114
|
+
argv.shift();
|
|
115
|
+
if (commands.length > 0) commands[commands.length - 1].args = args;
|
|
116
|
+
commands.push({
|
|
117
|
+
name: arg,
|
|
118
|
+
args: []
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
if (commands.length > 0) commands[commands.length - 1].args = argv.splice(0);
|
|
123
|
+
let package_json_path = this.package_json_path;
|
|
124
|
+
if (this.opts.directory) package_json_path = path.join(this.opts.directory, package_json_path);
|
|
125
|
+
this.package_json = JSON.parse(fs.readFileSync(package_json_path));
|
|
126
|
+
this.todo = napi.expand_commands(this.package_json, this.opts, commands);
|
|
127
|
+
const npm_config_prefix = "npm_config_";
|
|
128
|
+
Object.keys(process.env).forEach((name) => {
|
|
129
|
+
if (name.indexOf(npm_config_prefix) !== 0) return;
|
|
130
|
+
const val = process.env[name];
|
|
131
|
+
if (name === npm_config_prefix + "loglevel") log.level = val;
|
|
132
|
+
else {
|
|
133
|
+
name = name.substring(11);
|
|
134
|
+
if (name === "argv") if (this.opts.argv && this.opts.argv.remain && this.opts.argv.remain.length) {} else this.opts[name] = val;
|
|
135
|
+
else this.opts[name] = val;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
if (this.opts.loglevel) log.level = this.opts.loglevel;
|
|
139
|
+
log.resume();
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* allow the binary.host property to be set at execution time.
|
|
143
|
+
*
|
|
144
|
+
* for this to take effect requires all the following to be true.
|
|
145
|
+
* - binary is a property in package.json
|
|
146
|
+
* - binary.host is falsey
|
|
147
|
+
* - binary.staging_host is not empty
|
|
148
|
+
* - binary.production_host is not empty
|
|
149
|
+
*
|
|
150
|
+
* if any of the previous checks fail then the function returns an empty string
|
|
151
|
+
* and makes no changes to package.json's binary property.
|
|
152
|
+
*
|
|
153
|
+
*
|
|
154
|
+
* if command is "publish" then the default is set to "binary.staging_host"
|
|
155
|
+
* if command is not "publish" the the default is set to "binary.production_host"
|
|
156
|
+
*
|
|
157
|
+
* if the command-line option '--s3_host' is set to "staging" or "production" then
|
|
158
|
+
* "binary.host" is set to the specified "staging_host" or "production_host". if
|
|
159
|
+
* '--s3_host' is any other value an exception is thrown.
|
|
160
|
+
*
|
|
161
|
+
* if '--s3_host' is not present then "binary.host" is set to the default as above.
|
|
162
|
+
*
|
|
163
|
+
* this strategy was chosen so that any command other than "publish" or "unpublish" uses "production"
|
|
164
|
+
* as the default without requiring any command-line options but that "publish" and "unpublish" require
|
|
165
|
+
* '--s3_host production_host' to be specified in order to *really* publish (or unpublish). publishing
|
|
166
|
+
* to staging can be done freely without worrying about disturbing any production releases.
|
|
167
|
+
*/
|
|
168
|
+
proto.setBinaryHostProperty = function(command) {
|
|
169
|
+
if (this.binaryHostSet) return this.package_json.binary.host;
|
|
170
|
+
const p = this.package_json;
|
|
171
|
+
if (!p || !p.binary || p.binary.host) return "";
|
|
172
|
+
if (!p.binary.staging_host || !p.binary.production_host) return "";
|
|
173
|
+
let target = "production_host";
|
|
174
|
+
if (command === "publish" || command === "unpublish") target = "staging_host";
|
|
175
|
+
const npg_s3_host = process.env.node_pre_gyp_s3_host;
|
|
176
|
+
if (npg_s3_host === "staging" || npg_s3_host === "production") target = `${npg_s3_host}_host`;
|
|
177
|
+
else if (this.opts["s3_host"] === "staging" || this.opts["s3_host"] === "production") target = `${this.opts["s3_host"]}_host`;
|
|
178
|
+
else if (this.opts["s3_host"] || npg_s3_host) throw new Error(`invalid s3_host ${this.opts["s3_host"] || npg_s3_host}`);
|
|
179
|
+
p.binary.host = p.binary[target];
|
|
180
|
+
this.binaryHostSet = true;
|
|
181
|
+
return p.binary.host;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Returns the usage instructions for node-pre-gyp.
|
|
185
|
+
*/
|
|
186
|
+
proto.usage = function usage() {
|
|
187
|
+
return [
|
|
188
|
+
"",
|
|
189
|
+
" Usage: node-pre-gyp <command> [options]",
|
|
190
|
+
"",
|
|
191
|
+
" where <command> is one of:",
|
|
192
|
+
cli_commands.map((c) => {
|
|
193
|
+
return " - " + c + " - " + __require("./" + c).usage;
|
|
194
|
+
}).join("\n"),
|
|
195
|
+
"",
|
|
196
|
+
"node-pre-gyp@" + this.version + " " + path.resolve(__dirname, ".."),
|
|
197
|
+
"node@" + process.versions.node
|
|
198
|
+
].join("\n");
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Version number getter.
|
|
202
|
+
*/
|
|
203
|
+
Object.defineProperty(proto, "version", {
|
|
204
|
+
get: function() {
|
|
205
|
+
return this.package.version;
|
|
206
|
+
},
|
|
207
|
+
enumerable: true
|
|
208
|
+
});
|
|
209
|
+
}));
|
|
210
|
+
//#endregion
|
|
211
|
+
export default require_node_pre_gyp();
|
|
212
|
+
export { require_node_pre_gyp };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { __commonJSMin, __require } from "../../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_napi } from "./util/napi.js";
|
|
3
|
+
import { require_versioning } from "./util/versioning.js";
|
|
4
|
+
import { require_node_pre_gyp } from "./node-pre-gyp.js";
|
|
5
|
+
//#region node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/pre-binding.js
|
|
6
|
+
var require_pre_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7
|
+
const npg = require_node_pre_gyp();
|
|
8
|
+
const versioning = require_versioning();
|
|
9
|
+
const napi = require_napi();
|
|
10
|
+
const existsSync = __require("fs").existsSync || __require("path").existsSync;
|
|
11
|
+
const path = __require("path");
|
|
12
|
+
module.exports = exports;
|
|
13
|
+
exports.usage = "Finds the require path for the node-pre-gyp installed module";
|
|
14
|
+
exports.validate = function(package_json, opts) {
|
|
15
|
+
versioning.validate_config(package_json, opts);
|
|
16
|
+
};
|
|
17
|
+
exports.find = function(package_json_path, opts) {
|
|
18
|
+
if (!existsSync(package_json_path)) throw new Error(package_json_path + "does not exist");
|
|
19
|
+
const prog = new npg.Run({
|
|
20
|
+
package_json_path,
|
|
21
|
+
argv: process.argv
|
|
22
|
+
});
|
|
23
|
+
prog.setBinaryHostProperty();
|
|
24
|
+
const package_json = prog.package_json;
|
|
25
|
+
versioning.validate_config(package_json, opts);
|
|
26
|
+
let napi_build_version;
|
|
27
|
+
if (napi.get_napi_build_versions(package_json, opts)) napi_build_version = napi.get_best_napi_build_version(package_json, opts);
|
|
28
|
+
opts = opts || {};
|
|
29
|
+
if (!opts.module_root) opts.module_root = path.dirname(package_json_path);
|
|
30
|
+
return versioning.evaluate(package_json, opts, napi_build_version).module;
|
|
31
|
+
};
|
|
32
|
+
}));
|
|
33
|
+
//#endregion
|
|
34
|
+
export default require_pre_binding();
|
|
35
|
+
export { require_pre_binding };
|