wiki-graph-sdk 0.8.1 → 0.8.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/README.md +25 -0
- package/dist/archives.cjs +7 -0
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +2 -0
- package/dist/archives.js +8 -0
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +1 -0
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +50 -10
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +54 -10
- package/dist/default-worker.js.map +1 -1
- package/dist/embedding.cjs.map +1 -1
- package/dist/embedding.js +1 -0
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +52 -10
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.d.ts +3 -0
- package/dist/gc.js +56 -10
- package/dist/gc.js.map +1 -1
- package/dist/host-pQiVAKEY.d.ts +10 -0
- package/dist/index.cjs +86 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +90 -12
- package/dist/index.js.map +1 -1
- package/dist/local-config.cjs.map +1 -1
- package/dist/local-config.js +1 -0
- 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.map +1 -1
- package/dist/runtime-config.js +1 -0
- package/dist/runtime-config.js.map +1 -1
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.js +1 -0
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +81 -42
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +7 -2
- package/dist/worker.js +85 -42
- 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,
|
|
@@ -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 {
|
|
@@ -2364,6 +2385,13 @@ var WikiGraphArchiveHandle = class {
|
|
|
2364
2385
|
);
|
|
2365
2386
|
return status;
|
|
2366
2387
|
}
|
|
2388
|
+
/** Clear cached search sessions without changing the archive index. */
|
|
2389
|
+
async clearSearchSessions(options = {}) {
|
|
2390
|
+
await this.#runtime.run(
|
|
2391
|
+
async () => await (0, import_wiki_graph_core7.deleteArchiveSearchSessions)(this.path),
|
|
2392
|
+
options.signal
|
|
2393
|
+
);
|
|
2394
|
+
}
|
|
2367
2395
|
async listChapters(options = {}) {
|
|
2368
2396
|
return await this.#readDocument(
|
|
2369
2397
|
async (document) => await (0, import_wiki_graph_core7.listChapters)(document),
|
|
@@ -3294,6 +3322,8 @@ async function createFindOptions(cursor, limit) {
|
|
|
3294
3322
|
cursor: cursor.cursor,
|
|
3295
3323
|
...cursor.evidenceLimit === void 0 ? {} : { evidenceLimit: cursor.evidenceLimit },
|
|
3296
3324
|
limit,
|
|
3325
|
+
...cursor.match === void 0 ? {} : { match: cursor.match },
|
|
3326
|
+
...cursor.order === void 0 ? {} : { order: cursor.order },
|
|
3297
3327
|
...cursor.queryMode === void 0 ? {} : { queryMode: cursor.queryMode },
|
|
3298
3328
|
...cursor.skipUnindexed === void 0 ? {} : { skipUnindexed: cursor.skipUnindexed },
|
|
3299
3329
|
...cursor.sourceContext === void 0 ? {} : { sourceContext: cursor.sourceContext },
|
|
@@ -3397,6 +3427,8 @@ function createContinuationPayload(context, cursor) {
|
|
|
3397
3427
|
indexScope: context.indexScope,
|
|
3398
3428
|
kind: "search",
|
|
3399
3429
|
...createLibraryQueryPayload(context),
|
|
3430
|
+
...context.match === void 0 ? {} : { match: context.match },
|
|
3431
|
+
...context.order === void 0 ? {} : { order: context.order },
|
|
3400
3432
|
...context.query === void 0 ? {} : { query: context.query },
|
|
3401
3433
|
...context.queryMode === void 0 ? {} : { queryMode: context.queryMode },
|
|
3402
3434
|
...context.skipUnindexed === void 0 ? {} : { skipUnindexed: context.skipUnindexed },
|
|
@@ -3599,12 +3631,41 @@ function getGenerationPlanningProfile(task) {
|
|
|
3599
3631
|
// src/worker.ts
|
|
3600
3632
|
var import_worker = require("wiki-graph-core/worker");
|
|
3601
3633
|
var import_wiki_graph_core13 = require("wiki-graph-core");
|
|
3634
|
+
|
|
3635
|
+
// src/host.ts
|
|
3636
|
+
var import_platform2 = require("wiki-graph-core/platform");
|
|
3637
|
+
function prepareWikiGraphSDKHost(host) {
|
|
3638
|
+
if (host?.platform === void 0) {
|
|
3639
|
+
ensureNodeWikiGraphPlatform();
|
|
3640
|
+
return;
|
|
3641
|
+
}
|
|
3642
|
+
(0, import_platform2.installWikiGraphPlatform)(host.platform);
|
|
3643
|
+
}
|
|
3644
|
+
function assertWikiGraphSDKHostOptions(options) {
|
|
3645
|
+
if (options.host?.storage !== void 0 && options.stateDir !== void 0) {
|
|
3646
|
+
throw new TypeError(
|
|
3647
|
+
"Wiki Graph SDK host.storage and stateDir cannot be used together."
|
|
3648
|
+
);
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
async function withWikiGraphSDKHost(options, operation) {
|
|
3652
|
+
assertWikiGraphSDKHostOptions(options);
|
|
3653
|
+
prepareWikiGraphSDKHost(options.host);
|
|
3654
|
+
if (options.host?.storage !== void 0) {
|
|
3655
|
+
return await (0, import_platform2.withWikiGraphStorage)(options.host.storage, operation);
|
|
3656
|
+
}
|
|
3657
|
+
return await withNodeWikiGraphStorage(options.stateDir, operation);
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
// src/worker.ts
|
|
3602
3661
|
var import_worker2 = require("wiki-graph-core/worker");
|
|
3603
3662
|
async function runBuildJobWorker(options) {
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3663
|
+
const { host, stateDir, ...coreOptions } = options;
|
|
3664
|
+
await withWikiGraphSDKHost(
|
|
3665
|
+
{
|
|
3666
|
+
...host === void 0 ? {} : { host },
|
|
3667
|
+
...stateDir === void 0 ? {} : { stateDir }
|
|
3668
|
+
},
|
|
3608
3669
|
async () => await (0, import_worker.runBuildJobWorker)(coreOptions)
|
|
3609
3670
|
);
|
|
3610
3671
|
}
|
|
@@ -5030,11 +5091,13 @@ var WikiGraphSDK = class {
|
|
|
5030
5091
|
libraries;
|
|
5031
5092
|
maintenance;
|
|
5032
5093
|
constructor(options = {}) {
|
|
5033
|
-
|
|
5094
|
+
assertWikiGraphSDKHostOptions(options);
|
|
5095
|
+
prepareWikiGraphSDKHost(options.host);
|
|
5034
5096
|
this.#context = {
|
|
5035
5097
|
cwd: options.cwd ?? process.cwd(),
|
|
5036
5098
|
env: { ...process.env, ...options.env },
|
|
5037
5099
|
envPolicy: options.envPolicy ?? "production",
|
|
5100
|
+
...options.host === void 0 ? {} : { host: options.host },
|
|
5038
5101
|
providers: { ...options.providers },
|
|
5039
5102
|
...options.stateDir === void 0 ? {} : { stateDir: options.stateDir }
|
|
5040
5103
|
};
|
|
@@ -5060,8 +5123,11 @@ var WikiGraphSDK = class {
|
|
|
5060
5123
|
}
|
|
5061
5124
|
return await operation();
|
|
5062
5125
|
});
|
|
5063
|
-
const result =
|
|
5064
|
-
|
|
5126
|
+
const result = await withWikiGraphSDKHost(
|
|
5127
|
+
{
|
|
5128
|
+
...this.#context.host === void 0 ? {} : { host: this.#context.host },
|
|
5129
|
+
...this.#context.stateDir === void 0 ? {} : { stateDir: this.#context.stateDir }
|
|
5130
|
+
},
|
|
5065
5131
|
runWithContext
|
|
5066
5132
|
);
|
|
5067
5133
|
throwIfAborted2(signal);
|
|
@@ -5113,6 +5179,7 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5113
5179
|
createEntryRuntimeContext,
|
|
5114
5180
|
createGenerationPerformanceHints,
|
|
5115
5181
|
createNodeTemplateEnvironment,
|
|
5182
|
+
createNodeWikiGraphPlatform,
|
|
5116
5183
|
createNodeWikiGraphStorage,
|
|
5117
5184
|
createStageLLM,
|
|
5118
5185
|
createWikiGraphSDK,
|
|
@@ -5127,6 +5194,8 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5127
5194
|
formatLocatedChapterSourceCollectionUri,
|
|
5128
5195
|
formatLocatedChapterUri,
|
|
5129
5196
|
formatLocatedWikiGraphUri,
|
|
5197
|
+
formatSourceArtifactUri,
|
|
5198
|
+
formatSourceLocatorFragment,
|
|
5130
5199
|
formatWikiGraphCommandUri,
|
|
5131
5200
|
formatWikiGraphLibraryUri,
|
|
5132
5201
|
getNodeResourcePath,
|
|
@@ -5136,7 +5205,9 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5136
5205
|
inspectWikiGraphArchive,
|
|
5137
5206
|
installNodeWikiGraphPlatform,
|
|
5138
5207
|
isSourceLocatorScopeUri,
|
|
5208
|
+
isWikiGraphJobUri,
|
|
5139
5209
|
isWikiGraphLibraryUri,
|
|
5210
|
+
isWikiGraphUri,
|
|
5140
5211
|
loadRequiredStageConfig,
|
|
5141
5212
|
loadWikiGraphRuntimeConfig,
|
|
5142
5213
|
maskLocalConfigSection,
|
|
@@ -5148,6 +5219,7 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5148
5219
|
parseChapterUriPath,
|
|
5149
5220
|
parseLocalConfigSection,
|
|
5150
5221
|
parseLocatedWikiGraphUri,
|
|
5222
|
+
parseSourceLocatorFragment,
|
|
5151
5223
|
parseSourceTextJsonl,
|
|
5152
5224
|
parseWikiGraphLibraryUri,
|
|
5153
5225
|
parseWikiGraphUriSyntax,
|
|
@@ -5156,7 +5228,10 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5156
5228
|
readLocalConfigSection,
|
|
5157
5229
|
readWikiGraphEmbeddingConfig,
|
|
5158
5230
|
replaceLocalConfigSection,
|
|
5231
|
+
requireArchiveUri,
|
|
5159
5232
|
requireKnowledgeGraphWikispineConfig,
|
|
5233
|
+
requireLocatedObjectOrArchiveUri,
|
|
5234
|
+
requireLocatedObjectUri,
|
|
5160
5235
|
resolveExtractionPrompt,
|
|
5161
5236
|
resolveHostedProviderEndpoint,
|
|
5162
5237
|
resolveKnowledgeGraphRecallPrompt,
|