wiki-graph-sdk 0.8.1 → 0.8.3
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 +30 -0
- package/dist/archives.cjs +25 -19
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +2 -0
- package/dist/archives.js +14 -7
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +11 -12
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +7 -7
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +83 -20
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +84 -17
- package/dist/default-worker.js.map +1 -1
- package/dist/embedding.cjs +6 -7
- package/dist/embedding.cjs.map +1 -1
- package/dist/embedding.js +7 -7
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +106 -12
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.d.ts +3 -0
- package/dist/gc.js +110 -12
- package/dist/gc.js.map +1 -1
- package/dist/host-IbqJ8WSV.d.ts +18 -0
- package/dist/index.cjs +127 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +119 -21
- package/dist/index.js.map +1 -1
- package/dist/local-config.cjs +6 -7
- package/dist/local-config.cjs.map +1 -1
- package/dist/local-config.js +7 -7
- package/dist/local-config.js.map +1 -1
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js +1 -0
- package/dist/maintenance.js.map +1 -1
- package/dist/node-platform.cjs +18 -4
- package/dist/node-platform.cjs.map +1 -1
- package/dist/node-platform.d.ts +12 -3
- package/dist/node-platform.js +18 -4
- package/dist/node-platform.js.map +1 -1
- package/dist/runtime-config.cjs +6 -7
- package/dist/runtime-config.cjs.map +1 -1
- package/dist/runtime-config.js +7 -7
- package/dist/runtime-config.js.map +1 -1
- package/dist/stage.cjs +6 -7
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.js +7 -7
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +113 -50
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +7 -2
- package/dist/worker.js +125 -58
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -61,6 +61,7 @@ __export(src_exports, {
|
|
|
61
61
|
createEntryRuntimeContext: () => createEntryRuntimeContext,
|
|
62
62
|
createGenerationPerformanceHints: () => createGenerationPerformanceHints,
|
|
63
63
|
createNodeTemplateEnvironment: () => createNodeTemplateEnvironment,
|
|
64
|
+
createNodeWikiGraphPlatform: () => createNodeWikiGraphPlatform,
|
|
64
65
|
createNodeWikiGraphStorage: () => createNodeWikiGraphStorage,
|
|
65
66
|
createStageLLM: () => createStageLLM,
|
|
66
67
|
createWikiGraphSDK: () => createWikiGraphSDK,
|
|
@@ -75,6 +76,8 @@ __export(src_exports, {
|
|
|
75
76
|
formatLocatedChapterSourceCollectionUri: () => import_wiki_graph_core19.formatLocatedChapterSourceCollectionUri,
|
|
76
77
|
formatLocatedChapterUri: () => import_wiki_graph_core19.formatLocatedChapterUri,
|
|
77
78
|
formatLocatedWikiGraphUri: () => import_wiki_graph_core19.formatLocatedWikiGraphUri,
|
|
79
|
+
formatSourceArtifactUri: () => import_wiki_graph_core19.formatSourceArtifactUri,
|
|
80
|
+
formatSourceLocatorFragment: () => import_wiki_graph_core19.formatSourceLocatorFragment,
|
|
78
81
|
formatWikiGraphCommandUri: () => import_wiki_graph_core19.formatWikiGraphCommandUri,
|
|
79
82
|
formatWikiGraphLibraryUri: () => import_wiki_graph_core19.formatWikiGraphLibraryUri,
|
|
80
83
|
getNodeResourcePath: () => getNodeResourcePath,
|
|
@@ -84,7 +87,9 @@ __export(src_exports, {
|
|
|
84
87
|
inspectWikiGraphArchive: () => inspectWikiGraphArchive,
|
|
85
88
|
installNodeWikiGraphPlatform: () => installNodeWikiGraphPlatform,
|
|
86
89
|
isSourceLocatorScopeUri: () => import_wiki_graph_core19.isSourceLocatorScopeUri,
|
|
90
|
+
isWikiGraphJobUri: () => import_wiki_graph_core19.isWikiGraphJobUri,
|
|
87
91
|
isWikiGraphLibraryUri: () => import_wiki_graph_core19.isWikiGraphLibraryUri,
|
|
92
|
+
isWikiGraphUri: () => import_wiki_graph_core19.isWikiGraphUri,
|
|
88
93
|
loadRequiredStageConfig: () => loadRequiredStageConfig,
|
|
89
94
|
loadWikiGraphRuntimeConfig: () => loadWikiGraphRuntimeConfig,
|
|
90
95
|
maskLocalConfigSection: () => maskLocalConfigSection,
|
|
@@ -96,6 +101,7 @@ __export(src_exports, {
|
|
|
96
101
|
parseChapterUriPath: () => import_wiki_graph_core19.parseChapterUriPath,
|
|
97
102
|
parseLocalConfigSection: () => parseLocalConfigSection,
|
|
98
103
|
parseLocatedWikiGraphUri: () => import_wiki_graph_core19.parseLocatedWikiGraphUri,
|
|
104
|
+
parseSourceLocatorFragment: () => import_wiki_graph_core19.parseSourceLocatorFragment,
|
|
99
105
|
parseSourceTextJsonl: () => import_wiki_graph_core19.parseSourceTextJsonl,
|
|
100
106
|
parseWikiGraphLibraryUri: () => import_wiki_graph_core19.parseWikiGraphLibraryUri,
|
|
101
107
|
parseWikiGraphUriSyntax: () => import_wiki_graph_core19.parseWikiGraphUriSyntax,
|
|
@@ -104,7 +110,10 @@ __export(src_exports, {
|
|
|
104
110
|
readLocalConfigSection: () => readLocalConfigSection,
|
|
105
111
|
readWikiGraphEmbeddingConfig: () => readWikiGraphEmbeddingConfig,
|
|
106
112
|
replaceLocalConfigSection: () => replaceLocalConfigSection,
|
|
113
|
+
requireArchiveUri: () => import_wiki_graph_core19.requireArchiveUri,
|
|
107
114
|
requireKnowledgeGraphWikispineConfig: () => requireKnowledgeGraphWikispineConfig,
|
|
115
|
+
requireLocatedObjectOrArchiveUri: () => import_wiki_graph_core19.requireLocatedObjectOrArchiveUri,
|
|
116
|
+
requireLocatedObjectUri: () => import_wiki_graph_core19.requireLocatedObjectUri,
|
|
108
117
|
resolveExtractionPrompt: () => import_wiki_graph_core10.resolveExtractionPrompt,
|
|
109
118
|
resolveHostedProviderEndpoint: () => resolveHostedProviderEndpoint,
|
|
110
119
|
resolveKnowledgeGraphRecallPrompt: () => import_wiki_graph_core10.resolveKnowledgeGraphRecallPrompt,
|
|
@@ -120,7 +129,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
120
129
|
|
|
121
130
|
// src/archive/archive.ts
|
|
122
131
|
var import_crypto2 = require("crypto");
|
|
123
|
-
var
|
|
132
|
+
var import_promises5 = require("fs/promises");
|
|
124
133
|
var import_os3 = require("os");
|
|
125
134
|
var import_path5 = require("path");
|
|
126
135
|
var import_stream = require("stream");
|
|
@@ -129,7 +138,7 @@ var import_wiki_graph_core7 = require("wiki-graph-core");
|
|
|
129
138
|
// src/conversions.ts
|
|
130
139
|
var import_crypto = require("crypto");
|
|
131
140
|
var import_fs = require("fs");
|
|
132
|
-
var
|
|
141
|
+
var import_promises4 = require("fs/promises");
|
|
133
142
|
var import_path4 = require("path");
|
|
134
143
|
var import_wiki_graph_core3 = require("wiki-graph-core");
|
|
135
144
|
|
|
@@ -836,6 +845,9 @@ var nodeWikiGraphPlatform = {
|
|
|
836
845
|
write: writeNodeZip
|
|
837
846
|
}
|
|
838
847
|
};
|
|
848
|
+
function createNodeWikiGraphPlatform(options = {}) {
|
|
849
|
+
return options.lifecycle === void 0 ? nodeWikiGraphPlatform : { ...nodeWikiGraphPlatform, lifecycle: options.lifecycle };
|
|
850
|
+
}
|
|
839
851
|
var NodeTemplateLoader = class extends import_nunjucks.Loader {
|
|
840
852
|
#dataDirectory;
|
|
841
853
|
constructor(dataDirectory) {
|
|
@@ -881,10 +893,15 @@ function resolveNodeDataDirectory() {
|
|
|
881
893
|
directory = parent;
|
|
882
894
|
}
|
|
883
895
|
}
|
|
884
|
-
function createNodeWikiGraphStorage(
|
|
896
|
+
function createNodeWikiGraphStorage(stateRootOrOptions = pathModule.join(
|
|
897
|
+
os.homedir(),
|
|
898
|
+
".wikigraph"
|
|
899
|
+
)) {
|
|
900
|
+
const libraryRoot = typeof stateRootOrOptions === "string" ? stateRootOrOptions : stateRootOrOptions.libraryRoot;
|
|
901
|
+
const documentStoreRoot = typeof stateRootOrOptions === "string" ? pathModule.join(stateRootOrOptions, "documents") : stateRootOrOptions.documentStoreRoot;
|
|
885
902
|
return {
|
|
886
|
-
library: new NodeDirectory(
|
|
887
|
-
documentStore: new NodeDirectory(
|
|
903
|
+
library: new NodeDirectory(libraryRoot),
|
|
904
|
+
documentStore: new NodeDirectory(documentStoreRoot)
|
|
888
905
|
};
|
|
889
906
|
}
|
|
890
907
|
function installNodeWikiGraphPlatform(stateRoot) {
|
|
@@ -892,7 +909,11 @@ function installNodeWikiGraphPlatform(stateRoot) {
|
|
|
892
909
|
(0, import_platform.installWikiGraphStorage)(createNodeWikiGraphStorage(stateRoot));
|
|
893
910
|
}
|
|
894
911
|
function ensureNodeWikiGraphPlatform() {
|
|
895
|
-
|
|
912
|
+
try {
|
|
913
|
+
(0, import_platform.getWikiGraphPlatform)();
|
|
914
|
+
} catch {
|
|
915
|
+
(0, import_platform.installWikiGraphPlatform)(nodeWikiGraphPlatform);
|
|
916
|
+
}
|
|
896
917
|
try {
|
|
897
918
|
(0, import_platform.getWikiGraphStorage)();
|
|
898
919
|
} catch {
|
|
@@ -943,13 +964,15 @@ function getWikiGraphSDKRuntimeContext() {
|
|
|
943
964
|
};
|
|
944
965
|
}
|
|
945
966
|
function getWikiGraphSDKStateDir() {
|
|
946
|
-
|
|
967
|
+
const context = getWikiGraphSDKRuntimeContext();
|
|
968
|
+
return context.host?.stateDir ?? context.stateDir;
|
|
947
969
|
}
|
|
948
970
|
function getWikiGraphSDKProviders() {
|
|
949
971
|
return getWikiGraphSDKRuntimeContext().providers ?? {};
|
|
950
972
|
}
|
|
951
973
|
|
|
952
974
|
// src/local-config.ts
|
|
975
|
+
var import_promises2 = require("fs/promises");
|
|
953
976
|
var import_path = require("path");
|
|
954
977
|
var import_os = require("os");
|
|
955
978
|
var LOCAL_CONFIG_SECTIONS = [
|
|
@@ -1050,13 +1073,10 @@ function validateLocalConfigSection(section, value) {
|
|
|
1050
1073
|
}
|
|
1051
1074
|
}
|
|
1052
1075
|
async function withLocalConfigDatabase(operation) {
|
|
1076
|
+
const stateDir = getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph");
|
|
1077
|
+
await (0, import_promises2.mkdir)(stateDir, { recursive: true });
|
|
1053
1078
|
const database = await (0, import_wiki_graph_core.openSharedStateDatabase)(
|
|
1054
|
-
new NodeFile(
|
|
1055
|
-
(0, import_path.join)(
|
|
1056
|
-
getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph"),
|
|
1057
|
-
"core.sqlite"
|
|
1058
|
-
)
|
|
1059
|
-
),
|
|
1079
|
+
new NodeFile((0, import_path.join)(stateDir, "core.sqlite")),
|
|
1060
1080
|
LOCAL_CONFIG_SCHEMA_SQL
|
|
1061
1081
|
);
|
|
1062
1082
|
try {
|
|
@@ -1466,7 +1486,7 @@ function resolveWikiGraphRuntimePath(path) {
|
|
|
1466
1486
|
}
|
|
1467
1487
|
|
|
1468
1488
|
// src/archive/target.ts
|
|
1469
|
-
var
|
|
1489
|
+
var import_promises3 = require("fs/promises");
|
|
1470
1490
|
var import_path3 = require("path");
|
|
1471
1491
|
var import_wiki_graph_core2 = require("wiki-graph-core");
|
|
1472
1492
|
var WikiGraphArchiveOwnershipError = class extends Error {
|
|
@@ -1595,7 +1615,7 @@ function withObjectUri(archiveLocator, objectUri) {
|
|
|
1595
1615
|
}
|
|
1596
1616
|
async function canonicalPath(path) {
|
|
1597
1617
|
try {
|
|
1598
|
-
return await (0,
|
|
1618
|
+
return await (0, import_promises3.realpath)(path);
|
|
1599
1619
|
} catch {
|
|
1600
1620
|
const absolute = (0, import_path3.resolve)(path);
|
|
1601
1621
|
const parent = (0, import_path3.dirname)(absolute);
|
|
@@ -1646,7 +1666,7 @@ function requireUnambiguousManagedMatch(path, matches) {
|
|
|
1646
1666
|
}
|
|
1647
1667
|
async function readFileIdentity(path) {
|
|
1648
1668
|
try {
|
|
1649
|
-
const value = await (0,
|
|
1669
|
+
const value = await (0, import_promises3.stat)(path);
|
|
1650
1670
|
return `${value.dev}:${value.ino}`;
|
|
1651
1671
|
} catch {
|
|
1652
1672
|
return void 0;
|
|
@@ -1770,7 +1790,7 @@ async function prepareDigestDirectory(path, required) {
|
|
|
1770
1790
|
if (!required || normalized === void 0 || normalized === "")
|
|
1771
1791
|
return void 0;
|
|
1772
1792
|
const resolved = resolveWikiGraphRuntimePath(normalized);
|
|
1773
|
-
await (0,
|
|
1793
|
+
await (0, import_promises4.rm)(resolved, { force: true, recursive: true });
|
|
1774
1794
|
return new NodeDirectory(resolved);
|
|
1775
1795
|
}
|
|
1776
1796
|
async function writeArchive(archive, path, format) {
|
|
@@ -2188,10 +2208,10 @@ var WikiGraphArchiveManager = class {
|
|
|
2188
2208
|
});
|
|
2189
2209
|
}
|
|
2190
2210
|
if (options.replace === true) {
|
|
2191
|
-
await (0,
|
|
2211
|
+
await (0, import_promises5.rename)(outputPath, path);
|
|
2192
2212
|
} else {
|
|
2193
2213
|
try {
|
|
2194
|
-
await (0,
|
|
2214
|
+
await (0, import_promises5.link)(outputPath, path);
|
|
2195
2215
|
} catch (error) {
|
|
2196
2216
|
if (isNodeEEXISTError(error)) {
|
|
2197
2217
|
throw new WikiGraphArchiveExistsError(path);
|
|
@@ -2201,7 +2221,7 @@ var WikiGraphArchiveManager = class {
|
|
|
2201
2221
|
}
|
|
2202
2222
|
return { locatedUri: (0, import_wiki_graph_core7.formatLocatedWikiGraphUri)(path), path };
|
|
2203
2223
|
} finally {
|
|
2204
|
-
await (0,
|
|
2224
|
+
await (0, import_promises5.rm)(outputPath, { force: true, recursive: true });
|
|
2205
2225
|
}
|
|
2206
2226
|
}, options.signal);
|
|
2207
2227
|
}
|
|
@@ -2364,6 +2384,13 @@ var WikiGraphArchiveHandle = class {
|
|
|
2364
2384
|
);
|
|
2365
2385
|
return status;
|
|
2366
2386
|
}
|
|
2387
|
+
/** Clear cached search sessions without changing the archive index. */
|
|
2388
|
+
async clearSearchSessions(options = {}) {
|
|
2389
|
+
await this.#runtime.run(
|
|
2390
|
+
async () => await (0, import_wiki_graph_core7.deleteArchiveSearchSessions)(this.path),
|
|
2391
|
+
options.signal
|
|
2392
|
+
);
|
|
2393
|
+
}
|
|
2367
2394
|
async listChapters(options = {}) {
|
|
2368
2395
|
return await this.#readDocument(
|
|
2369
2396
|
async (document) => await (0, import_wiki_graph_core7.listChapters)(document),
|
|
@@ -2815,7 +2842,7 @@ function selectChapterSubtree(chapters, rootChapterId, depth) {
|
|
|
2815
2842
|
);
|
|
2816
2843
|
}
|
|
2817
2844
|
async function createEmptyArchiveFile(path) {
|
|
2818
|
-
const directoryPath = await (0,
|
|
2845
|
+
const directoryPath = await (0, import_promises5.mkdtemp)(
|
|
2819
2846
|
(0, import_path5.join)((0, import_os3.tmpdir)(), "wikigraph-archive-write-")
|
|
2820
2847
|
);
|
|
2821
2848
|
try {
|
|
@@ -2830,7 +2857,7 @@ async function createEmptyArchiveFile(path) {
|
|
|
2830
2857
|
}
|
|
2831
2858
|
await (0, import_wiki_graph_core7.writeWikgArchive)(directory, new NodeFile(path));
|
|
2832
2859
|
} finally {
|
|
2833
|
-
await (0,
|
|
2860
|
+
await (0, import_promises5.rm)(directoryPath, { force: true, recursive: true });
|
|
2834
2861
|
}
|
|
2835
2862
|
}
|
|
2836
2863
|
function isNodeEEXISTError(error) {
|
|
@@ -2838,7 +2865,7 @@ function isNodeEEXISTError(error) {
|
|
|
2838
2865
|
}
|
|
2839
2866
|
async function nodePathExists(path) {
|
|
2840
2867
|
try {
|
|
2841
|
-
await (0,
|
|
2868
|
+
await (0, import_promises5.stat)(path);
|
|
2842
2869
|
return true;
|
|
2843
2870
|
} catch (error) {
|
|
2844
2871
|
if (isNodeENOENTError(error)) return false;
|
|
@@ -3294,6 +3321,8 @@ async function createFindOptions(cursor, limit) {
|
|
|
3294
3321
|
cursor: cursor.cursor,
|
|
3295
3322
|
...cursor.evidenceLimit === void 0 ? {} : { evidenceLimit: cursor.evidenceLimit },
|
|
3296
3323
|
limit,
|
|
3324
|
+
...cursor.match === void 0 ? {} : { match: cursor.match },
|
|
3325
|
+
...cursor.order === void 0 ? {} : { order: cursor.order },
|
|
3297
3326
|
...cursor.queryMode === void 0 ? {} : { queryMode: cursor.queryMode },
|
|
3298
3327
|
...cursor.skipUnindexed === void 0 ? {} : { skipUnindexed: cursor.skipUnindexed },
|
|
3299
3328
|
...cursor.sourceContext === void 0 ? {} : { sourceContext: cursor.sourceContext },
|
|
@@ -3397,6 +3426,8 @@ function createContinuationPayload(context, cursor) {
|
|
|
3397
3426
|
indexScope: context.indexScope,
|
|
3398
3427
|
kind: "search",
|
|
3399
3428
|
...createLibraryQueryPayload(context),
|
|
3429
|
+
...context.match === void 0 ? {} : { match: context.match },
|
|
3430
|
+
...context.order === void 0 ? {} : { order: context.order },
|
|
3400
3431
|
...context.query === void 0 ? {} : { query: context.query },
|
|
3401
3432
|
...context.queryMode === void 0 ? {} : { queryMode: context.queryMode },
|
|
3402
3433
|
...context.skipUnindexed === void 0 ? {} : { skipUnindexed: context.skipUnindexed },
|
|
@@ -3599,12 +3630,62 @@ function getGenerationPlanningProfile(task) {
|
|
|
3599
3630
|
// src/worker.ts
|
|
3600
3631
|
var import_worker = require("wiki-graph-core/worker");
|
|
3601
3632
|
var import_wiki_graph_core13 = require("wiki-graph-core");
|
|
3633
|
+
|
|
3634
|
+
// src/host.ts
|
|
3635
|
+
var import_platform2 = require("wiki-graph-core/platform");
|
|
3636
|
+
function prepareWikiGraphSDKHost(host) {
|
|
3637
|
+
if (host?.platform === void 0) {
|
|
3638
|
+
ensureNodeWikiGraphPlatform();
|
|
3639
|
+
return;
|
|
3640
|
+
}
|
|
3641
|
+
(0, import_platform2.installWikiGraphPlatform)(host.platform);
|
|
3642
|
+
}
|
|
3643
|
+
function assertWikiGraphSDKHostOptions(options) {
|
|
3644
|
+
if (options.host?.storage !== void 0 && options.host.stateDir === void 0) {
|
|
3645
|
+
throw new TypeError(
|
|
3646
|
+
"Wiki Graph SDK host.storage requires host.stateDir so SDK configuration cannot fall back to the default user state directory."
|
|
3647
|
+
);
|
|
3648
|
+
}
|
|
3649
|
+
if (options.stateDir !== void 0 && (options.host?.stateDir !== void 0 || options.host?.storage !== void 0)) {
|
|
3650
|
+
throw new TypeError(
|
|
3651
|
+
"Wiki Graph SDK host state/storage and top-level stateDir cannot be used together. Put the state directory in host.stateDir when providing host.storage."
|
|
3652
|
+
);
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
async function withWikiGraphSDKHost(options, operation) {
|
|
3656
|
+
const current = getWikiGraphSDKRuntimeContext();
|
|
3657
|
+
const effective = {
|
|
3658
|
+
...options.host === void 0 ? current.host === void 0 ? {} : { host: current.host } : { host: options.host },
|
|
3659
|
+
...options.stateDir === void 0 ? current.stateDir === void 0 ? {} : { stateDir: current.stateDir } : { stateDir: options.stateDir }
|
|
3660
|
+
};
|
|
3661
|
+
assertWikiGraphSDKHostOptions(effective);
|
|
3662
|
+
prepareWikiGraphSDKHost(effective.host);
|
|
3663
|
+
const runWithContext = async () => await withWikiGraphSDKRuntimeContext(
|
|
3664
|
+
{
|
|
3665
|
+
...current,
|
|
3666
|
+
...effective.host === void 0 ? {} : { host: effective.host },
|
|
3667
|
+
...effective.stateDir === void 0 ? {} : { stateDir: effective.stateDir }
|
|
3668
|
+
},
|
|
3669
|
+
operation
|
|
3670
|
+
);
|
|
3671
|
+
if (effective.host?.storage !== void 0) {
|
|
3672
|
+
return await (0, import_platform2.withWikiGraphStorage)(effective.host.storage, runWithContext);
|
|
3673
|
+
}
|
|
3674
|
+
return await withNodeWikiGraphStorage(
|
|
3675
|
+
effective.host?.stateDir ?? effective.stateDir,
|
|
3676
|
+
runWithContext
|
|
3677
|
+
);
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
// src/worker.ts
|
|
3602
3681
|
var import_worker2 = require("wiki-graph-core/worker");
|
|
3603
3682
|
async function runBuildJobWorker(options) {
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3683
|
+
const { host, stateDir, ...coreOptions } = options;
|
|
3684
|
+
await withWikiGraphSDKHost(
|
|
3685
|
+
{
|
|
3686
|
+
...host === void 0 ? {} : { host },
|
|
3687
|
+
...stateDir === void 0 ? {} : { stateDir }
|
|
3688
|
+
},
|
|
3608
3689
|
async () => await (0, import_worker.runBuildJobWorker)(coreOptions)
|
|
3609
3690
|
);
|
|
3610
3691
|
}
|
|
@@ -4495,7 +4576,7 @@ function forwardAbort(source, target) {
|
|
|
4495
4576
|
|
|
4496
4577
|
// src/libraries.ts
|
|
4497
4578
|
var import_wiki_graph_core16 = require("wiki-graph-core");
|
|
4498
|
-
var
|
|
4579
|
+
var import_promises6 = require("fs/promises");
|
|
4499
4580
|
async function resolveQueryEmbeddingProvider(queryMode) {
|
|
4500
4581
|
if (queryMode === "fts") return void 0;
|
|
4501
4582
|
const provider = await createConfiguredEmbeddingProvider();
|
|
@@ -4514,7 +4595,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4514
4595
|
async create(folder) {
|
|
4515
4596
|
const record = await this.#runtime.run(async () => {
|
|
4516
4597
|
const path = resolveWikiGraphRuntimePath(folder);
|
|
4517
|
-
await (0,
|
|
4598
|
+
await (0, import_promises6.mkdir)(path);
|
|
4518
4599
|
return await (0, import_wiki_graph_core16.createWikiGraphLibrary)({ folder: new NodeDirectory(path) });
|
|
4519
4600
|
});
|
|
4520
4601
|
return new WikiGraphLibrary(this.#runtime, record);
|
|
@@ -5030,11 +5111,13 @@ var WikiGraphSDK = class {
|
|
|
5030
5111
|
libraries;
|
|
5031
5112
|
maintenance;
|
|
5032
5113
|
constructor(options = {}) {
|
|
5033
|
-
|
|
5114
|
+
assertWikiGraphSDKHostOptions(options);
|
|
5115
|
+
prepareWikiGraphSDKHost(options.host);
|
|
5034
5116
|
this.#context = {
|
|
5035
5117
|
cwd: options.cwd ?? process.cwd(),
|
|
5036
5118
|
env: { ...process.env, ...options.env },
|
|
5037
5119
|
envPolicy: options.envPolicy ?? "production",
|
|
5120
|
+
...options.host === void 0 ? {} : { host: options.host },
|
|
5038
5121
|
providers: { ...options.providers },
|
|
5039
5122
|
...options.stateDir === void 0 ? {} : { stateDir: options.stateDir }
|
|
5040
5123
|
};
|
|
@@ -5060,8 +5143,11 @@ var WikiGraphSDK = class {
|
|
|
5060
5143
|
}
|
|
5061
5144
|
return await operation();
|
|
5062
5145
|
});
|
|
5063
|
-
const result =
|
|
5064
|
-
|
|
5146
|
+
const result = await withWikiGraphSDKHost(
|
|
5147
|
+
{
|
|
5148
|
+
...this.#context.host === void 0 ? {} : { host: this.#context.host },
|
|
5149
|
+
...this.#context.stateDir === void 0 ? {} : { stateDir: this.#context.stateDir }
|
|
5150
|
+
},
|
|
5065
5151
|
runWithContext
|
|
5066
5152
|
);
|
|
5067
5153
|
throwIfAborted2(signal);
|
|
@@ -5113,6 +5199,7 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5113
5199
|
createEntryRuntimeContext,
|
|
5114
5200
|
createGenerationPerformanceHints,
|
|
5115
5201
|
createNodeTemplateEnvironment,
|
|
5202
|
+
createNodeWikiGraphPlatform,
|
|
5116
5203
|
createNodeWikiGraphStorage,
|
|
5117
5204
|
createStageLLM,
|
|
5118
5205
|
createWikiGraphSDK,
|
|
@@ -5127,6 +5214,8 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5127
5214
|
formatLocatedChapterSourceCollectionUri,
|
|
5128
5215
|
formatLocatedChapterUri,
|
|
5129
5216
|
formatLocatedWikiGraphUri,
|
|
5217
|
+
formatSourceArtifactUri,
|
|
5218
|
+
formatSourceLocatorFragment,
|
|
5130
5219
|
formatWikiGraphCommandUri,
|
|
5131
5220
|
formatWikiGraphLibraryUri,
|
|
5132
5221
|
getNodeResourcePath,
|
|
@@ -5136,7 +5225,9 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5136
5225
|
inspectWikiGraphArchive,
|
|
5137
5226
|
installNodeWikiGraphPlatform,
|
|
5138
5227
|
isSourceLocatorScopeUri,
|
|
5228
|
+
isWikiGraphJobUri,
|
|
5139
5229
|
isWikiGraphLibraryUri,
|
|
5230
|
+
isWikiGraphUri,
|
|
5140
5231
|
loadRequiredStageConfig,
|
|
5141
5232
|
loadWikiGraphRuntimeConfig,
|
|
5142
5233
|
maskLocalConfigSection,
|
|
@@ -5148,6 +5239,7 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5148
5239
|
parseChapterUriPath,
|
|
5149
5240
|
parseLocalConfigSection,
|
|
5150
5241
|
parseLocatedWikiGraphUri,
|
|
5242
|
+
parseSourceLocatorFragment,
|
|
5151
5243
|
parseSourceTextJsonl,
|
|
5152
5244
|
parseWikiGraphLibraryUri,
|
|
5153
5245
|
parseWikiGraphUriSyntax,
|
|
@@ -5156,7 +5248,10 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5156
5248
|
readLocalConfigSection,
|
|
5157
5249
|
readWikiGraphEmbeddingConfig,
|
|
5158
5250
|
replaceLocalConfigSection,
|
|
5251
|
+
requireArchiveUri,
|
|
5159
5252
|
requireKnowledgeGraphWikispineConfig,
|
|
5253
|
+
requireLocatedObjectOrArchiveUri,
|
|
5254
|
+
requireLocatedObjectUri,
|
|
5160
5255
|
resolveExtractionPrompt,
|
|
5161
5256
|
resolveHostedProviderEndpoint,
|
|
5162
5257
|
resolveKnowledgeGraphRecallPrompt,
|