wiki-graph-sdk 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/archives.cjs +71 -7
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.js +67 -3
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +65 -1
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.d.ts +13 -3
- package/dist/conversions.js +65 -1
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +17 -16
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +13 -11
- package/dist/default-worker.js.map +1 -1
- package/dist/index.cjs +173 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +86 -20
- package/dist/index.js.map +1 -1
- package/dist/worker.cjs +37 -0
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +17 -1
- package/dist/worker.js +39 -2
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -36,18 +36,18 @@ __export(src_exports, {
|
|
|
36
36
|
DEFAULT_GENERATION_JOB_CONCURRENCY: () => DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
37
37
|
DEFAULT_GENERATION_REQUEST_CONCURRENCY: () => DEFAULT_GENERATION_REQUEST_CONCURRENCY,
|
|
38
38
|
DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT: () => import_wiki_graph_core8.DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT,
|
|
39
|
-
LLMPaymentRequiredError: () =>
|
|
39
|
+
LLMPaymentRequiredError: () => import_wiki_graph_core17.LLMPaymentRequiredError,
|
|
40
40
|
LOCAL_CONFIG_SECTIONS: () => LOCAL_CONFIG_SECTIONS,
|
|
41
41
|
NodeDirectory: () => NodeDirectory,
|
|
42
42
|
NodeFile: () => NodeFile,
|
|
43
|
-
WIKI_GRAPH_URI_PREFIX: () =>
|
|
43
|
+
WIKI_GRAPH_URI_PREFIX: () => import_wiki_graph_core17.WIKI_GRAPH_URI_PREFIX,
|
|
44
44
|
WikiGraphArchiveExistsError: () => WikiGraphArchiveExistsError,
|
|
45
45
|
WikiGraphArchiveHandle: () => WikiGraphArchiveHandle,
|
|
46
46
|
WikiGraphArchiveManager: () => WikiGraphArchiveManager,
|
|
47
47
|
WikiGraphConfigManager: () => WikiGraphConfigManager,
|
|
48
48
|
WikiGraphContinuationManager: () => WikiGraphContinuationManager,
|
|
49
49
|
WikiGraphConversionManager: () => WikiGraphConversionManager,
|
|
50
|
-
WikiGraphError: () =>
|
|
50
|
+
WikiGraphError: () => import_wiki_graph_core17.WikiGraphError,
|
|
51
51
|
WikiGraphJob: () => WikiGraphJob,
|
|
52
52
|
WikiGraphJobManager: () => WikiGraphJobManager,
|
|
53
53
|
WikiGraphLibrary: () => WikiGraphLibrary,
|
|
@@ -68,35 +68,35 @@ __export(src_exports, {
|
|
|
68
68
|
embedQueryText: () => embedQueryText,
|
|
69
69
|
embedQueryTextWithLocalConfig: () => embedQueryTextWithLocalConfig,
|
|
70
70
|
ensureNodeWikiGraphPlatform: () => ensureNodeWikiGraphPlatform,
|
|
71
|
-
formatError: () =>
|
|
71
|
+
formatError: () => import_wiki_graph_core17.formatError,
|
|
72
72
|
formatGenerationPlanningDuration: () => formatGenerationPlanningDuration,
|
|
73
73
|
formatGenerationPlanningModel: () => formatGenerationPlanningModel,
|
|
74
|
-
formatLocatedChapterResourceUri: () =>
|
|
75
|
-
formatLocatedChapterSourceCollectionUri: () =>
|
|
76
|
-
formatLocatedChapterUri: () =>
|
|
77
|
-
formatLocatedWikiGraphUri: () =>
|
|
78
|
-
formatWikiGraphCommandUri: () =>
|
|
79
|
-
formatWikiGraphLibraryUri: () =>
|
|
74
|
+
formatLocatedChapterResourceUri: () => import_wiki_graph_core17.formatLocatedChapterResourceUri,
|
|
75
|
+
formatLocatedChapterSourceCollectionUri: () => import_wiki_graph_core17.formatLocatedChapterSourceCollectionUri,
|
|
76
|
+
formatLocatedChapterUri: () => import_wiki_graph_core17.formatLocatedChapterUri,
|
|
77
|
+
formatLocatedWikiGraphUri: () => import_wiki_graph_core17.formatLocatedWikiGraphUri,
|
|
78
|
+
formatWikiGraphCommandUri: () => import_wiki_graph_core17.formatWikiGraphCommandUri,
|
|
79
|
+
formatWikiGraphLibraryUri: () => import_wiki_graph_core17.formatWikiGraphLibraryUri,
|
|
80
80
|
getNodeResourcePath: () => getNodeResourcePath,
|
|
81
81
|
getWikiGraphSDKRuntimeContext: () => getWikiGraphSDKRuntimeContext,
|
|
82
82
|
getWikiGraphSDKStateDir: () => getWikiGraphSDKStateDir,
|
|
83
83
|
installNodeWikiGraphPlatform: () => installNodeWikiGraphPlatform,
|
|
84
|
-
isSourceLocatorScopeUri: () =>
|
|
85
|
-
isWikiGraphLibraryUri: () =>
|
|
84
|
+
isSourceLocatorScopeUri: () => import_wiki_graph_core17.isSourceLocatorScopeUri,
|
|
85
|
+
isWikiGraphLibraryUri: () => import_wiki_graph_core17.isWikiGraphLibraryUri,
|
|
86
86
|
loadRequiredStageConfig: () => loadRequiredStageConfig,
|
|
87
87
|
loadWikiGraphRuntimeConfig: () => loadWikiGraphRuntimeConfig,
|
|
88
88
|
maskLocalConfigSection: () => maskLocalConfigSection,
|
|
89
89
|
nodeWikiGraphPlatform: () => nodeWikiGraphPlatform,
|
|
90
90
|
nodeWikispineCommandRunner: () => nodeWikispineCommandRunner,
|
|
91
91
|
normalizeLocalConfigKey: () => normalizeLocalConfigKey,
|
|
92
|
-
parseChapterPath: () =>
|
|
93
|
-
parseChapterTreeInput: () =>
|
|
94
|
-
parseChapterUriPath: () =>
|
|
92
|
+
parseChapterPath: () => import_wiki_graph_core17.parseChapterPath,
|
|
93
|
+
parseChapterTreeInput: () => import_wiki_graph_core17.parseChapterTreeInput,
|
|
94
|
+
parseChapterUriPath: () => import_wiki_graph_core17.parseChapterUriPath,
|
|
95
95
|
parseLocalConfigSection: () => parseLocalConfigSection,
|
|
96
|
-
parseLocatedWikiGraphUri: () =>
|
|
97
|
-
parseSourceTextJsonl: () =>
|
|
98
|
-
parseWikiGraphLibraryUri: () =>
|
|
99
|
-
parseWikiGraphUriSyntax: () =>
|
|
96
|
+
parseLocatedWikiGraphUri: () => import_wiki_graph_core17.parseLocatedWikiGraphUri,
|
|
97
|
+
parseSourceTextJsonl: () => import_wiki_graph_core17.parseSourceTextJsonl,
|
|
98
|
+
parseWikiGraphLibraryUri: () => import_wiki_graph_core17.parseWikiGraphLibraryUri,
|
|
99
|
+
parseWikiGraphUriSyntax: () => import_wiki_graph_core17.parseWikiGraphUriSyntax,
|
|
100
100
|
planGenerationTask: () => planGenerationTask,
|
|
101
101
|
putLocalConfigValue: () => putLocalConfigValue,
|
|
102
102
|
readLocalConfigSection: () => readLocalConfigSection,
|
|
@@ -117,15 +117,18 @@ __export(src_exports, {
|
|
|
117
117
|
module.exports = __toCommonJS(src_exports);
|
|
118
118
|
|
|
119
119
|
// src/archive/archive.ts
|
|
120
|
-
var
|
|
120
|
+
var import_crypto2 = require("crypto");
|
|
121
121
|
var import_promises3 = require("fs/promises");
|
|
122
122
|
var import_os3 = require("os");
|
|
123
|
-
var
|
|
123
|
+
var import_path4 = require("path");
|
|
124
124
|
var import_stream = require("stream");
|
|
125
125
|
var import_wiki_graph_core5 = require("wiki-graph-core");
|
|
126
126
|
|
|
127
127
|
// src/conversions.ts
|
|
128
|
+
var import_crypto = require("crypto");
|
|
129
|
+
var import_fs = require("fs");
|
|
128
130
|
var import_promises2 = require("fs/promises");
|
|
131
|
+
var import_path3 = require("path");
|
|
129
132
|
var import_wiki_graph_core2 = require("wiki-graph-core");
|
|
130
133
|
|
|
131
134
|
// src/llm.ts
|
|
@@ -1462,6 +1465,9 @@ var WikiGraphConversionManager = class {
|
|
|
1462
1465
|
if (options.targetStage !== void 0 && options.output.format !== "wikg") {
|
|
1463
1466
|
throw new Error("targetStage is only supported for wikg output.");
|
|
1464
1467
|
}
|
|
1468
|
+
if (options.output.format === "pcex") {
|
|
1469
|
+
throw new Error("pcex is supported only as a conversion input.");
|
|
1470
|
+
}
|
|
1465
1471
|
if (options.targetStage !== void 0 && options.input.format === "wikg") {
|
|
1466
1472
|
throw new Error(
|
|
1467
1473
|
"targetStage is only supported when creating a wikg archive."
|
|
@@ -1480,7 +1486,13 @@ var WikiGraphConversionManager = class {
|
|
|
1480
1486
|
options.digestDirectory,
|
|
1481
1487
|
requiresDigest
|
|
1482
1488
|
);
|
|
1489
|
+
let chapterCount;
|
|
1483
1490
|
const write = async (archive) => {
|
|
1491
|
+
if (requiresDigest) await options.onSourceImported?.();
|
|
1492
|
+
if (typeof archive.readToc === "function") {
|
|
1493
|
+
const toc = await archive.readToc();
|
|
1494
|
+
chapterCount = toc === void 0 ? void 0 : countTocChapters(toc.items);
|
|
1495
|
+
}
|
|
1484
1496
|
await writeArchive(archive, options.output.path, options.output.format);
|
|
1485
1497
|
};
|
|
1486
1498
|
if (options.input.format === "wikg") {
|
|
@@ -1513,16 +1525,28 @@ var WikiGraphConversionManager = class {
|
|
|
1513
1525
|
};
|
|
1514
1526
|
if (options.input.format === "epub") {
|
|
1515
1527
|
await app.digestEpubSession(digestOptions, write);
|
|
1528
|
+
} else if (options.input.format === "pcex") {
|
|
1529
|
+
await app.digestPcexSession(
|
|
1530
|
+
{
|
|
1531
|
+
...digestOptions,
|
|
1532
|
+
pdfDigest: options.input.sourcePdf.digest,
|
|
1533
|
+
...options.input.sourcePdf.name === void 0 ? {} : { pdfName: options.input.sourcePdf.name }
|
|
1534
|
+
},
|
|
1535
|
+
write
|
|
1536
|
+
);
|
|
1516
1537
|
} else if (options.input.format === "markdown") {
|
|
1517
1538
|
await app.digestMarkdownSession(digestOptions, write);
|
|
1518
1539
|
} else {
|
|
1519
1540
|
await app.digestTxtSession(digestOptions, write);
|
|
1520
1541
|
}
|
|
1521
1542
|
}
|
|
1543
|
+
const sourceArtifact = await resolveSourceArtifact(options.input);
|
|
1522
1544
|
return {
|
|
1545
|
+
...chapterCount === void 0 ? {} : { chapterCount },
|
|
1523
1546
|
inputFormat: options.input.format,
|
|
1524
1547
|
outputFormat: options.output.format,
|
|
1525
|
-
outputPath: options.output.path
|
|
1548
|
+
outputPath: options.output.path,
|
|
1549
|
+
...sourceArtifact === void 0 ? {} : { sourceArtifact }
|
|
1526
1550
|
};
|
|
1527
1551
|
}
|
|
1528
1552
|
};
|
|
@@ -1538,8 +1562,48 @@ async function writeArchive(archive, path, format) {
|
|
|
1538
1562
|
const file = new NodeFile(resolveWikiGraphRuntimePath(path));
|
|
1539
1563
|
if (format === "epub") await archive.exportEpub(file);
|
|
1540
1564
|
else if (format === "wikg") await archive.saveAs(file);
|
|
1565
|
+
else if (format === "pcex") throw new Error("pcex output is not supported.");
|
|
1541
1566
|
else await archive.exportText(file);
|
|
1542
1567
|
}
|
|
1568
|
+
async function resolveSourceArtifact(input) {
|
|
1569
|
+
if (!("path" in input) || input.format === "wikg") return void 0;
|
|
1570
|
+
if (input.format === "pcex") {
|
|
1571
|
+
return {
|
|
1572
|
+
digest: input.sourcePdf.digest.trim().toLowerCase(),
|
|
1573
|
+
mediaType: "application/pdf",
|
|
1574
|
+
...input.sourcePdf.name === void 0 ? {} : { name: input.sourcePdf.name }
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
if (input.format !== "epub") return void 0;
|
|
1578
|
+
const path = resolveWikiGraphRuntimePath(input.path);
|
|
1579
|
+
const hash = (0, import_crypto.createHash)("sha256");
|
|
1580
|
+
try {
|
|
1581
|
+
for await (const chunk of (0, import_fs.createReadStream)(path)) {
|
|
1582
|
+
hash.update(chunk);
|
|
1583
|
+
}
|
|
1584
|
+
} catch (error) {
|
|
1585
|
+
if (isNodeErrorCode(error, "ENOENT")) return void 0;
|
|
1586
|
+
throw error;
|
|
1587
|
+
}
|
|
1588
|
+
return {
|
|
1589
|
+
digest: hash.digest("hex"),
|
|
1590
|
+
mediaType: "application/epub+zip",
|
|
1591
|
+
name: (0, import_path3.basename)(path)
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
function isNodeErrorCode(error, code) {
|
|
1595
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
1596
|
+
}
|
|
1597
|
+
function countTocChapters(items) {
|
|
1598
|
+
let count = 0;
|
|
1599
|
+
for (const item of items) {
|
|
1600
|
+
if (item.serialId !== void 0) count += 1;
|
|
1601
|
+
count += countTocChapters(
|
|
1602
|
+
item.children
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
return count;
|
|
1606
|
+
}
|
|
1543
1607
|
|
|
1544
1608
|
// src/query-runtime.ts
|
|
1545
1609
|
var import_wiki_graph_core3 = require("wiki-graph-core");
|
|
@@ -2247,9 +2311,9 @@ var WikiGraphArchiveManager = class {
|
|
|
2247
2311
|
if (options.replace !== true && await nodePathExists(path)) {
|
|
2248
2312
|
throw new WikiGraphArchiveExistsError(path);
|
|
2249
2313
|
}
|
|
2250
|
-
const outputPath = (0,
|
|
2251
|
-
(0,
|
|
2252
|
-
`.${(0,
|
|
2314
|
+
const outputPath = (0, import_path4.join)(
|
|
2315
|
+
(0, import_path4.dirname)(path),
|
|
2316
|
+
`.${(0, import_path4.basename)(path)}.${(0, import_crypto2.randomUUID)()}.tmp.wikg`
|
|
2253
2317
|
);
|
|
2254
2318
|
try {
|
|
2255
2319
|
if (options.importPath === void 0) {
|
|
@@ -2892,7 +2956,7 @@ function createPathLocation(path) {
|
|
|
2892
2956
|
}
|
|
2893
2957
|
async function createEmptyArchiveFile(path) {
|
|
2894
2958
|
const directoryPath = await (0, import_promises3.mkdtemp)(
|
|
2895
|
-
(0,
|
|
2959
|
+
(0, import_path4.join)((0, import_os3.tmpdir)(), "wikigraph-archive-write-")
|
|
2896
2960
|
);
|
|
2897
2961
|
try {
|
|
2898
2962
|
const directory = new NodeDirectory(directoryPath);
|
|
@@ -3479,7 +3543,7 @@ function createLibraryQueryPayload(context) {
|
|
|
3479
3543
|
}
|
|
3480
3544
|
|
|
3481
3545
|
// src/default-worker.ts
|
|
3482
|
-
var
|
|
3546
|
+
var import_wiki_graph_core12 = require("wiki-graph-core");
|
|
3483
3547
|
var import_worker3 = require("wiki-graph-core/worker");
|
|
3484
3548
|
|
|
3485
3549
|
// src/stage.ts
|
|
@@ -3514,6 +3578,7 @@ async function loadRequiredStageConfig(options) {
|
|
|
3514
3578
|
|
|
3515
3579
|
// src/worker.ts
|
|
3516
3580
|
var import_worker = require("wiki-graph-core/worker");
|
|
3581
|
+
var import_wiki_graph_core11 = require("wiki-graph-core");
|
|
3517
3582
|
var import_worker2 = require("wiki-graph-core/worker");
|
|
3518
3583
|
async function runBuildJobWorker(options) {
|
|
3519
3584
|
installNodeWikiGraphPlatform();
|
|
@@ -3530,7 +3595,7 @@ async function runWikiGraphQueueWorker(options = {}) {
|
|
|
3530
3595
|
await runBuildJobWorker({
|
|
3531
3596
|
concurrency: config.concurrent?.job ?? DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
3532
3597
|
executeJob: async (job, reporter, context) => {
|
|
3533
|
-
await (0,
|
|
3598
|
+
await (0, import_wiki_graph_core12.withLoggingContext)(
|
|
3534
3599
|
{ logDirectory: job.log, operation: "build-job" },
|
|
3535
3600
|
async () => await executeBuildJob(job, reporter, context)
|
|
3536
3601
|
);
|
|
@@ -3553,7 +3618,7 @@ async function executeBuildJob(job, reporter, context) {
|
|
|
3553
3618
|
let stage = await readChapterStage(job);
|
|
3554
3619
|
if (stage === "sourced") {
|
|
3555
3620
|
await executeStep(job, "reading-graph", execution, reporter, context, {
|
|
3556
|
-
...execution.extractionPrompt === void 0 ? {} : {
|
|
3621
|
+
...execution.extractionPrompt === void 0 ? {} : { prompt: execution.extractionPrompt }
|
|
3557
3622
|
});
|
|
3558
3623
|
stage = await readChapterStage(job);
|
|
3559
3624
|
}
|
|
@@ -3586,8 +3651,8 @@ async function executeBuildJob(job, reporter, context) {
|
|
|
3586
3651
|
}
|
|
3587
3652
|
}
|
|
3588
3653
|
await executeStep(job, job.target, execution, reporter, context, {
|
|
3589
|
-
...job.target === "reading-graph" ? {
|
|
3590
|
-
...job.target === "knowledge-graph" ? {
|
|
3654
|
+
...job.target === "reading-graph" ? { prompt: execution.extractionPrompt } : {},
|
|
3655
|
+
...job.target === "knowledge-graph" ? { prompt: execution.knowledgeGraphPrompt } : {}
|
|
3591
3656
|
});
|
|
3592
3657
|
} finally {
|
|
3593
3658
|
await execution.close();
|
|
@@ -3602,9 +3667,9 @@ async function executeStep(job, kind, execution, reporter, context, inputOptions
|
|
|
3602
3667
|
const stepWorkspace = await resetStepWorkspace(job.workspace, kind);
|
|
3603
3668
|
const inputFile = await stepWorkspace.createFile("input.jsonl");
|
|
3604
3669
|
const outputWorkspace = await stepWorkspace.createDirectory("output");
|
|
3605
|
-
const revision = await new
|
|
3670
|
+
const revision = await new import_wiki_graph_core12.WikiGraphArchiveFile(job.archive).readDocument(
|
|
3606
3671
|
async (document) => {
|
|
3607
|
-
await (0,
|
|
3672
|
+
await (0, import_wiki_graph_core12.getChapterDetails)(document, job.chapterId);
|
|
3608
3673
|
return await (0, import_worker3.writeChapterJobInputFile)(
|
|
3609
3674
|
document,
|
|
3610
3675
|
job.chapterId,
|
|
@@ -3614,7 +3679,7 @@ async function executeStep(job, kind, execution, reporter, context, inputOptions
|
|
|
3614
3679
|
);
|
|
3615
3680
|
}
|
|
3616
3681
|
);
|
|
3617
|
-
await (0,
|
|
3682
|
+
await (0, import_wiki_graph_core12.recordBuildJobInputRevision)({
|
|
3618
3683
|
currentRevision: revision,
|
|
3619
3684
|
jobId: job.jobId,
|
|
3620
3685
|
ownerId: requireRunningJobOwnerId(job)
|
|
@@ -3644,8 +3709,8 @@ async function executeStep(job, kind, execution, reporter, context, inputOptions
|
|
|
3644
3709
|
total: 1,
|
|
3645
3710
|
unit: "item"
|
|
3646
3711
|
});
|
|
3647
|
-
await new
|
|
3648
|
-
assertJobStillRunning(await (0,
|
|
3712
|
+
await new import_wiki_graph_core12.WikiGraphArchiveFile(job.archive).write(async (document) => {
|
|
3713
|
+
assertJobStillRunning(await (0, import_wiki_graph_core12.getBuildJob)(job.jobId));
|
|
3649
3714
|
await (0, import_worker3.applyChapterJobArtifactFile)(
|
|
3650
3715
|
document,
|
|
3651
3716
|
job.chapterId,
|
|
@@ -3661,7 +3726,7 @@ async function executeStep(job, kind, execution, reporter, context, inputOptions
|
|
|
3661
3726
|
unit: "item"
|
|
3662
3727
|
});
|
|
3663
3728
|
await reporter.stepCompleted(kind);
|
|
3664
|
-
assertJobStillRunning(await (0,
|
|
3729
|
+
assertJobStillRunning(await (0, import_wiki_graph_core12.getBuildJob)(job.jobId));
|
|
3665
3730
|
}
|
|
3666
3731
|
async function openJobExecutor(job, config, signal, reporter) {
|
|
3667
3732
|
const generation = !job.target.startsWith("index-");
|
|
@@ -3680,13 +3745,13 @@ async function openJobExecutor(job, config, signal, reporter) {
|
|
|
3680
3745
|
const request = llm === void 0 ? void 0 : async (messages, index, maxRetries) => await llm.request(messages, {
|
|
3681
3746
|
retryIndex: index,
|
|
3682
3747
|
retryMax: maxRetries,
|
|
3683
|
-
scope:
|
|
3748
|
+
scope: import_wiki_graph_core12.WikiGraphScope.ReaderExtraction,
|
|
3684
3749
|
signal
|
|
3685
3750
|
});
|
|
3686
3751
|
if (request !== void 0 && llm !== void 0) {
|
|
3687
3752
|
request.lazy = async (operation) => await llm.request(async () => await operation(request));
|
|
3688
3753
|
}
|
|
3689
|
-
const wikimediaResolver = job.target !== "knowledge-graph" ? void 0 : await (0,
|
|
3754
|
+
const wikimediaResolver = job.target !== "knowledge-graph" ? void 0 : await (0, import_wiki_graph_core12.openWikimediaResolver)(
|
|
3690
3755
|
config.wikimedia === void 0 ? {
|
|
3691
3756
|
kind: "local",
|
|
3692
3757
|
llmRequest: requireValue(
|
|
@@ -3729,12 +3794,12 @@ async function resetStepWorkspace(workspace, kind) {
|
|
|
3729
3794
|
return await workspace.createDirectory(name);
|
|
3730
3795
|
}
|
|
3731
3796
|
async function readChapterStage(job) {
|
|
3732
|
-
return await new
|
|
3733
|
-
async (document) => (await (0,
|
|
3797
|
+
return await new import_wiki_graph_core12.WikiGraphArchiveFile(job.archive).readDocument(
|
|
3798
|
+
async (document) => (await (0, import_wiki_graph_core12.getChapterDetails)(document, job.chapterId)).stage
|
|
3734
3799
|
);
|
|
3735
3800
|
}
|
|
3736
3801
|
async function assertCurrentFtsArtifact(job) {
|
|
3737
|
-
await new
|
|
3802
|
+
await new import_wiki_graph_core12.WikiGraphArchiveFile(job.archive).readDocument(async (document) => {
|
|
3738
3803
|
const revision = await document.serials.getRevision(job.chapterId);
|
|
3739
3804
|
const artifact = await document.indexArtifacts.get(job.chapterId, "fts");
|
|
3740
3805
|
if (artifact?.sourceRevision !== revision) {
|
|
@@ -3833,27 +3898,27 @@ function normalizeOptionalPath(path) {
|
|
|
3833
3898
|
}
|
|
3834
3899
|
|
|
3835
3900
|
// src/jobs.ts
|
|
3836
|
-
var
|
|
3901
|
+
var import_wiki_graph_core13 = require("wiki-graph-core");
|
|
3837
3902
|
var TERMINAL_STATES = /* @__PURE__ */ new Set(["canceled", "failed", "succeeded"]);
|
|
3838
3903
|
var TERMINAL_EVENT_GRACE_READS = 3;
|
|
3839
3904
|
var CORE_BUILD_JOB_BACKEND = {
|
|
3840
|
-
add: async (options) => await (0,
|
|
3841
|
-
boost: async (jobId) => await (0,
|
|
3842
|
-
cancel: async (jobId) => await (0,
|
|
3843
|
-
get: async (jobId) => await (0,
|
|
3844
|
-
list: async (options) => await (0,
|
|
3845
|
-
pause: async (jobId) => await (0,
|
|
3905
|
+
add: async (options) => await (0, import_wiki_graph_core13.addBuildJob)(options),
|
|
3906
|
+
boost: async (jobId) => await (0, import_wiki_graph_core13.boostBuildJob)(jobId),
|
|
3907
|
+
cancel: async (jobId) => await (0, import_wiki_graph_core13.cancelBuildJob)(jobId),
|
|
3908
|
+
get: async (jobId) => await (0, import_wiki_graph_core13.getBuildJob)(jobId),
|
|
3909
|
+
list: async (options) => await (0, import_wiki_graph_core13.listBuildJobs)(options),
|
|
3910
|
+
pause: async (jobId) => await (0, import_wiki_graph_core13.pauseBuildJob)(jobId),
|
|
3846
3911
|
readEventChunk: async (job, cursor) => await readIncrementalBuildJobEvents(job, cursor),
|
|
3847
|
-
readEvents: async (job) => await (0,
|
|
3848
|
-
resume: async (jobId) => await (0,
|
|
3849
|
-
setTarget: async (jobId, target) => await (0,
|
|
3912
|
+
readEvents: async (job) => await (0, import_wiki_graph_core13.readBuildJobEvents)(job),
|
|
3913
|
+
resume: async (jobId) => await (0, import_wiki_graph_core13.resumeBuildJob)(jobId),
|
|
3914
|
+
setTarget: async (jobId, target) => await (0, import_wiki_graph_core13.updateBuildJobTarget)(jobId, target)
|
|
3850
3915
|
};
|
|
3851
3916
|
async function readIncrementalBuildJobEvents(job, cursor) {
|
|
3852
3917
|
let reader;
|
|
3853
3918
|
try {
|
|
3854
3919
|
reader = await job.events.openReader();
|
|
3855
3920
|
} catch {
|
|
3856
|
-
return { cursor, events: await (0,
|
|
3921
|
+
return { cursor, events: await (0, import_wiki_graph_core13.readBuildJobEvents)(job) };
|
|
3857
3922
|
}
|
|
3858
3923
|
try {
|
|
3859
3924
|
const offset = cursor <= reader.size ? cursor : 0;
|
|
@@ -3886,7 +3951,7 @@ var WikiGraphJobManager = class {
|
|
|
3886
3951
|
return this.#createHandle(job);
|
|
3887
3952
|
}
|
|
3888
3953
|
async clean() {
|
|
3889
|
-
return await this.#runtime.run(async () => await (0,
|
|
3954
|
+
return await this.#runtime.run(async () => await (0, import_wiki_graph_core13.cleanBuildJobs)());
|
|
3890
3955
|
}
|
|
3891
3956
|
async get(jobId) {
|
|
3892
3957
|
return this.#createHandle(
|
|
@@ -3895,7 +3960,7 @@ var WikiGraphJobManager = class {
|
|
|
3895
3960
|
}
|
|
3896
3961
|
async resolveId(reference) {
|
|
3897
3962
|
return await this.#runtime.run(
|
|
3898
|
-
async () => await (0,
|
|
3963
|
+
async () => await (0, import_wiki_graph_core13.resolveBuildJobId)(reference)
|
|
3899
3964
|
);
|
|
3900
3965
|
}
|
|
3901
3966
|
async list(options = {}) {
|
|
@@ -3923,9 +3988,9 @@ var WikiGraphJobManager = class {
|
|
|
3923
3988
|
const entries = (await Promise.all(
|
|
3924
3989
|
[...jobsByArchive].map(async ([archivePath, archiveJobs]) => {
|
|
3925
3990
|
try {
|
|
3926
|
-
const chapters = await new
|
|
3991
|
+
const chapters = await new import_wiki_graph_core13.WikiGraphArchiveFile(
|
|
3927
3992
|
new NodeFile(archivePath)
|
|
3928
|
-
).readDocument(async (document) => await (0,
|
|
3993
|
+
).readDocument(async (document) => await (0, import_wiki_graph_core13.listChapters)(document));
|
|
3929
3994
|
const chaptersById = new Map(
|
|
3930
3995
|
chapters.map((chapter) => [chapter.chapterId, chapter])
|
|
3931
3996
|
);
|
|
@@ -3935,7 +4000,7 @@ var WikiGraphJobManager = class {
|
|
|
3935
4000
|
[
|
|
3936
4001
|
job.jobId,
|
|
3937
4002
|
{
|
|
3938
|
-
locatedUri: (0,
|
|
4003
|
+
locatedUri: (0, import_wiki_graph_core13.formatLocatedChapterUri)(
|
|
3939
4004
|
archivePath,
|
|
3940
4005
|
chapter.path
|
|
3941
4006
|
),
|
|
@@ -3962,10 +4027,10 @@ var WikiGraphJobManager = class {
|
|
|
3962
4027
|
const target = options.target ?? "reading-summary";
|
|
3963
4028
|
await validateQueueTargetConfig(target, options.llmJSON);
|
|
3964
4029
|
const selectedExplicitly = options.chapterId !== void 0 || options.chapterIds !== void 0 || options.chapterPath !== void 0 || options.depth !== void 0;
|
|
3965
|
-
const candidates = await new
|
|
4030
|
+
const candidates = await new import_wiki_graph_core13.WikiGraphArchiveFile(
|
|
3966
4031
|
location.archiveFile
|
|
3967
4032
|
).readDocument(async (document) => {
|
|
3968
|
-
const chapters = await (0,
|
|
4033
|
+
const chapters = await (0, import_wiki_graph_core13.listChapters)(document);
|
|
3969
4034
|
const selected = await selectQueueChapters(document, chapters, options);
|
|
3970
4035
|
const checked = await Promise.all(
|
|
3971
4036
|
selected.map(async (chapter) => ({
|
|
@@ -4023,10 +4088,10 @@ var WikiGraphJobManager = class {
|
|
|
4023
4088
|
const target = options.target ?? "reading-summary";
|
|
4024
4089
|
await validateQueueTargetConfig(target, options.llmJSON);
|
|
4025
4090
|
const selectedExplicitly = options.chapterId !== void 0 || options.chapterIds !== void 0 || options.chapterPath !== void 0 || options.depth !== void 0;
|
|
4026
|
-
const candidates = await new
|
|
4091
|
+
const candidates = await new import_wiki_graph_core13.WikiGraphArchiveFile(
|
|
4027
4092
|
location.archiveFile
|
|
4028
4093
|
).readDocument(async (document) => {
|
|
4029
|
-
const chapters = await (0,
|
|
4094
|
+
const chapters = await (0, import_wiki_graph_core13.listChapters)(document);
|
|
4030
4095
|
const selected = await selectQueueChapters(document, chapters, options);
|
|
4031
4096
|
return await Promise.all(
|
|
4032
4097
|
selected.map(async (chapter) => ({
|
|
@@ -4200,7 +4265,7 @@ async function selectQueueChapters(document, chapters, options) {
|
|
|
4200
4265
|
if (options.chapterPath === void 0) {
|
|
4201
4266
|
return options.depth === void 0 ? chapters : chapters.filter((chapter) => chapter.depth <= options.depth);
|
|
4202
4267
|
}
|
|
4203
|
-
const rootId = await (0,
|
|
4268
|
+
const rootId = await (0, import_wiki_graph_core13.resolveChapterPathReadonly)(
|
|
4204
4269
|
document,
|
|
4205
4270
|
options.chapterPath
|
|
4206
4271
|
);
|
|
@@ -4294,7 +4359,7 @@ function forwardAbort(source, target) {
|
|
|
4294
4359
|
}
|
|
4295
4360
|
|
|
4296
4361
|
// src/libraries.ts
|
|
4297
|
-
var
|
|
4362
|
+
var import_wiki_graph_core14 = require("wiki-graph-core");
|
|
4298
4363
|
var import_promises4 = require("fs/promises");
|
|
4299
4364
|
var WikiGraphLibraryManager = class {
|
|
4300
4365
|
#runtime;
|
|
@@ -4305,20 +4370,20 @@ var WikiGraphLibraryManager = class {
|
|
|
4305
4370
|
const record = await this.#runtime.run(async () => {
|
|
4306
4371
|
const path = resolveWikiGraphRuntimePath(folder);
|
|
4307
4372
|
await (0, import_promises4.mkdir)(path);
|
|
4308
|
-
return await (0,
|
|
4373
|
+
return await (0, import_wiki_graph_core14.createWikiGraphLibrary)({ folder: new NodeDirectory(path) });
|
|
4309
4374
|
});
|
|
4310
4375
|
return new WikiGraphLibrary(this.#runtime, record);
|
|
4311
4376
|
}
|
|
4312
|
-
async get(uri = (0,
|
|
4377
|
+
async get(uri = (0, import_wiki_graph_core14.formatWikiGraphLibraryUri)()) {
|
|
4313
4378
|
const target = requireLibraryTarget(uri);
|
|
4314
4379
|
const record = await this.#runtime.run(
|
|
4315
|
-
async () => await (0,
|
|
4380
|
+
async () => await (0, import_wiki_graph_core14.resolveWikiGraphLibrary)(target)
|
|
4316
4381
|
);
|
|
4317
4382
|
return new WikiGraphLibrary(this.#runtime, record);
|
|
4318
4383
|
}
|
|
4319
4384
|
async addArchive(options) {
|
|
4320
4385
|
return await this.#runtime.run(
|
|
4321
|
-
async () => await (0,
|
|
4386
|
+
async () => await (0, import_wiki_graph_core14.addWikiGraphLibraryArchive)({
|
|
4322
4387
|
inputFile: new NodeFile(
|
|
4323
4388
|
resolveWikiGraphRuntimePath(options.inputPath)
|
|
4324
4389
|
),
|
|
@@ -4329,12 +4394,12 @@ var WikiGraphLibraryManager = class {
|
|
|
4329
4394
|
}
|
|
4330
4395
|
async assertCurrent(target) {
|
|
4331
4396
|
await this.#runtime.run(
|
|
4332
|
-
async () => await (0,
|
|
4397
|
+
async () => await (0, import_wiki_graph_core14.assertWikiGraphLibrarySchemaCurrent)(requireLibraryTarget(target))
|
|
4333
4398
|
);
|
|
4334
4399
|
}
|
|
4335
4400
|
async rebind(target, folder) {
|
|
4336
4401
|
return await this.#runtime.run(
|
|
4337
|
-
async () => await (0,
|
|
4402
|
+
async () => await (0, import_wiki_graph_core14.rebindWikiGraphLibrary)({
|
|
4338
4403
|
folder: new NodeDirectory(resolveWikiGraphRuntimePath(folder)),
|
|
4339
4404
|
target: requireLibraryTarget(target)
|
|
4340
4405
|
})
|
|
@@ -4342,22 +4407,22 @@ var WikiGraphLibraryManager = class {
|
|
|
4342
4407
|
}
|
|
4343
4408
|
async remove(target) {
|
|
4344
4409
|
return await this.#runtime.run(
|
|
4345
|
-
async () => await (0,
|
|
4410
|
+
async () => await (0, import_wiki_graph_core14.removeWikiGraphLibrary)(requireLibraryTarget(target))
|
|
4346
4411
|
);
|
|
4347
4412
|
}
|
|
4348
4413
|
async scan(target) {
|
|
4349
4414
|
return await this.#runtime.run(
|
|
4350
|
-
async () => await (0,
|
|
4415
|
+
async () => await (0, import_wiki_graph_core14.scanWikiGraphLibrary)(requireLibraryTarget(target))
|
|
4351
4416
|
);
|
|
4352
4417
|
}
|
|
4353
4418
|
async getArchive(target) {
|
|
4354
4419
|
return await this.#runtime.run(
|
|
4355
|
-
async () => await (0,
|
|
4420
|
+
async () => await (0, import_wiki_graph_core14.getWikiGraphLibraryArchive)(requireLibraryTarget(target))
|
|
4356
4421
|
);
|
|
4357
4422
|
}
|
|
4358
4423
|
async moveArchive(options) {
|
|
4359
4424
|
return await this.#runtime.run(
|
|
4360
|
-
async () => await (0,
|
|
4425
|
+
async () => await (0, import_wiki_graph_core14.moveWikiGraphLibraryArchive)({
|
|
4361
4426
|
target: requireLibraryTarget(options.target),
|
|
4362
4427
|
to: options.to
|
|
4363
4428
|
})
|
|
@@ -4365,19 +4430,19 @@ var WikiGraphLibraryManager = class {
|
|
|
4365
4430
|
}
|
|
4366
4431
|
async removeArchive(target) {
|
|
4367
4432
|
return await this.#runtime.run(
|
|
4368
|
-
async () => await (0,
|
|
4433
|
+
async () => await (0, import_wiki_graph_core14.removeWikiGraphLibraryArchive)({
|
|
4369
4434
|
target: requireLibraryTarget(target)
|
|
4370
4435
|
})
|
|
4371
4436
|
);
|
|
4372
4437
|
}
|
|
4373
4438
|
async indexState(target) {
|
|
4374
4439
|
return await this.#runtime.run(
|
|
4375
|
-
async () => await (0,
|
|
4440
|
+
async () => await (0, import_wiki_graph_core14.readWikiGraphLibraryIndexState)(requireLibraryTarget(target))
|
|
4376
4441
|
);
|
|
4377
4442
|
}
|
|
4378
4443
|
async rebuildIndex(target, onProgress) {
|
|
4379
4444
|
return await this.#runtime.run(
|
|
4380
|
-
async () => await (0,
|
|
4445
|
+
async () => await (0, import_wiki_graph_core14.rebuildWikiGraphLibraryIndex)(
|
|
4381
4446
|
requireLibraryTarget(target),
|
|
4382
4447
|
onProgress
|
|
4383
4448
|
)
|
|
@@ -4385,17 +4450,17 @@ var WikiGraphLibraryManager = class {
|
|
|
4385
4450
|
}
|
|
4386
4451
|
async cleanIndex(target) {
|
|
4387
4452
|
return await this.#runtime.run(
|
|
4388
|
-
async () => await (0,
|
|
4453
|
+
async () => await (0, import_wiki_graph_core14.cleanWikiGraphLibraryIndex)(requireLibraryTarget(target))
|
|
4389
4454
|
);
|
|
4390
4455
|
}
|
|
4391
4456
|
async getMetadata(target) {
|
|
4392
4457
|
return await this.#runtime.run(
|
|
4393
|
-
async () => await (0,
|
|
4458
|
+
async () => await (0, import_wiki_graph_core14.getWikiGraphLibraryMetadata)(requireLibraryTarget(target))
|
|
4394
4459
|
);
|
|
4395
4460
|
}
|
|
4396
4461
|
async replaceMetadata(target, value) {
|
|
4397
4462
|
return await this.#runtime.run(
|
|
4398
|
-
async () => await (0,
|
|
4463
|
+
async () => await (0, import_wiki_graph_core14.replaceWikiGraphLibraryMetadata)(
|
|
4399
4464
|
requireLibraryTarget(target),
|
|
4400
4465
|
value
|
|
4401
4466
|
)
|
|
@@ -4403,7 +4468,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4403
4468
|
}
|
|
4404
4469
|
async putMetadata(target, key, value) {
|
|
4405
4470
|
return await this.#runtime.run(
|
|
4406
|
-
async () => await (0,
|
|
4471
|
+
async () => await (0, import_wiki_graph_core14.putWikiGraphLibraryMetadata)(
|
|
4407
4472
|
requireLibraryTarget(target),
|
|
4408
4473
|
key,
|
|
4409
4474
|
value
|
|
@@ -4412,7 +4477,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4412
4477
|
}
|
|
4413
4478
|
async deleteMetadata(target, key) {
|
|
4414
4479
|
return await this.#runtime.run(
|
|
4415
|
-
async () => await (0,
|
|
4480
|
+
async () => await (0, import_wiki_graph_core14.deleteWikiGraphLibraryMetadataKey)(
|
|
4416
4481
|
requireLibraryTarget(target),
|
|
4417
4482
|
key
|
|
4418
4483
|
)
|
|
@@ -4420,13 +4485,13 @@ var WikiGraphLibraryManager = class {
|
|
|
4420
4485
|
}
|
|
4421
4486
|
async clearMetadata(target) {
|
|
4422
4487
|
return await this.#runtime.run(
|
|
4423
|
-
async () => await (0,
|
|
4488
|
+
async () => await (0, import_wiki_graph_core14.clearWikiGraphLibraryMetadata)(requireLibraryTarget(target))
|
|
4424
4489
|
);
|
|
4425
4490
|
}
|
|
4426
4491
|
async search(target, query, options = {}) {
|
|
4427
4492
|
return await this.#runtime.run(async () => {
|
|
4428
4493
|
const embeddingProvider = await createConfiguredEmbeddingProvider();
|
|
4429
|
-
return await (0,
|
|
4494
|
+
return await (0, import_wiki_graph_core14.findWikiGraphLibraryObjects)(
|
|
4430
4495
|
requireLibraryTarget(target),
|
|
4431
4496
|
query,
|
|
4432
4497
|
{
|
|
@@ -4439,7 +4504,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4439
4504
|
async searchArchiveMembers(target, query, options = {}) {
|
|
4440
4505
|
return await this.#runtime.run(async () => {
|
|
4441
4506
|
const embeddingProvider = await createConfiguredEmbeddingProvider();
|
|
4442
|
-
return await (0,
|
|
4507
|
+
return await (0, import_wiki_graph_core14.findWikiGraphLibraryArchiveMembers)(
|
|
4443
4508
|
requireLibraryTarget(target),
|
|
4444
4509
|
query,
|
|
4445
4510
|
{
|
|
@@ -4451,7 +4516,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4451
4516
|
}
|
|
4452
4517
|
async objects(target, options = {}) {
|
|
4453
4518
|
return await this.#runtime.run(
|
|
4454
|
-
async () => await (0,
|
|
4519
|
+
async () => await (0, import_wiki_graph_core14.listWikiGraphLibraryObjects)(
|
|
4455
4520
|
requireLibraryTarget(target),
|
|
4456
4521
|
options
|
|
4457
4522
|
)
|
|
@@ -4459,7 +4524,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4459
4524
|
}
|
|
4460
4525
|
async archiveMembers(target, options = {}) {
|
|
4461
4526
|
return await this.#runtime.run(
|
|
4462
|
-
async () => await (0,
|
|
4527
|
+
async () => await (0, import_wiki_graph_core14.listWikiGraphLibraryArchiveMembers)(
|
|
4463
4528
|
requireLibraryTarget(target),
|
|
4464
4529
|
options
|
|
4465
4530
|
)
|
|
@@ -4469,7 +4534,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4469
4534
|
return await this.#runtime.run(
|
|
4470
4535
|
async () => await withConfiguredWikimediaResolver(
|
|
4471
4536
|
objectUri,
|
|
4472
|
-
async (wikimediaOptions) => await (0,
|
|
4537
|
+
async (wikimediaOptions) => await (0, import_wiki_graph_core14.readWikiGraphLibraryPage)(
|
|
4473
4538
|
requireLibraryTarget(target),
|
|
4474
4539
|
objectUri,
|
|
4475
4540
|
{ ...options, ...wikimediaOptions }
|
|
@@ -4479,7 +4544,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4479
4544
|
}
|
|
4480
4545
|
async related(target, objectUri, options = {}) {
|
|
4481
4546
|
return await this.#runtime.run(
|
|
4482
|
-
async () => await (0,
|
|
4547
|
+
async () => await (0, import_wiki_graph_core14.listRelatedWikiGraphLibraryObjects)(
|
|
4483
4548
|
requireLibraryTarget(target),
|
|
4484
4549
|
objectUri,
|
|
4485
4550
|
options
|
|
@@ -4488,7 +4553,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4488
4553
|
}
|
|
4489
4554
|
async evidence(target, objectUri, options = {}) {
|
|
4490
4555
|
return await this.#runtime.run(
|
|
4491
|
-
async () => await (0,
|
|
4556
|
+
async () => await (0, import_wiki_graph_core14.listWikiGraphLibraryEvidence)(
|
|
4492
4557
|
requireLibraryTarget(target),
|
|
4493
4558
|
objectUri,
|
|
4494
4559
|
options
|
|
@@ -4497,7 +4562,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4497
4562
|
}
|
|
4498
4563
|
async pack(target, objectUri, budget = 5e3) {
|
|
4499
4564
|
return await this.#runtime.run(
|
|
4500
|
-
async () => await (0,
|
|
4565
|
+
async () => await (0, import_wiki_graph_core14.packWikiGraphLibraryContext)(
|
|
4501
4566
|
requireLibraryTarget(target),
|
|
4502
4567
|
objectUri,
|
|
4503
4568
|
budget
|
|
@@ -4506,7 +4571,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4506
4571
|
}
|
|
4507
4572
|
async list() {
|
|
4508
4573
|
const records = await this.#runtime.run(
|
|
4509
|
-
async () => await (0,
|
|
4574
|
+
async () => await (0, import_wiki_graph_core14.listWikiGraphLibraries)()
|
|
4510
4575
|
);
|
|
4511
4576
|
return records.map((record) => new WikiGraphLibrary(this.#runtime, record));
|
|
4512
4577
|
}
|
|
@@ -4522,32 +4587,32 @@ var WikiGraphLibrary = class {
|
|
|
4522
4587
|
return this.#record;
|
|
4523
4588
|
}
|
|
4524
4589
|
get uri() {
|
|
4525
|
-
return (0,
|
|
4590
|
+
return (0, import_wiki_graph_core14.formatWikiGraphLibraryUri)(
|
|
4526
4591
|
this.#record.isDefault ? void 0 : this.#record.publicId
|
|
4527
4592
|
);
|
|
4528
4593
|
}
|
|
4529
4594
|
async archives() {
|
|
4530
4595
|
const target = requireLibraryTarget(this.uri);
|
|
4531
4596
|
return await this.#runtime.run(
|
|
4532
|
-
async () => await (0,
|
|
4597
|
+
async () => await (0, import_wiki_graph_core14.listWikiGraphLibraryArchives)(target)
|
|
4533
4598
|
);
|
|
4534
4599
|
}
|
|
4535
4600
|
async scan() {
|
|
4536
4601
|
const target = requireLibraryTarget(this.uri);
|
|
4537
4602
|
return await this.#runtime.run(
|
|
4538
|
-
async () => await (0,
|
|
4603
|
+
async () => await (0, import_wiki_graph_core14.scanWikiGraphLibrary)(target)
|
|
4539
4604
|
);
|
|
4540
4605
|
}
|
|
4541
4606
|
async remove() {
|
|
4542
4607
|
const target = requireLibraryTarget(this.uri);
|
|
4543
4608
|
return await this.#runtime.run(
|
|
4544
|
-
async () => await (0,
|
|
4609
|
+
async () => await (0, import_wiki_graph_core14.removeWikiGraphLibrary)(target)
|
|
4545
4610
|
);
|
|
4546
4611
|
}
|
|
4547
4612
|
};
|
|
4548
4613
|
function requireLibraryTarget(value) {
|
|
4549
4614
|
if (typeof value !== "string") return value;
|
|
4550
|
-
const target = (0,
|
|
4615
|
+
const target = (0, import_wiki_graph_core14.parseWikiGraphLibraryUri)(value);
|
|
4551
4616
|
if (target === void 0) {
|
|
4552
4617
|
throw new TypeError(`Invalid Wiki Graph library URI: ${value}`);
|
|
4553
4618
|
}
|
|
@@ -4555,8 +4620,8 @@ function requireLibraryTarget(value) {
|
|
|
4555
4620
|
}
|
|
4556
4621
|
|
|
4557
4622
|
// src/maintenance.ts
|
|
4558
|
-
var
|
|
4559
|
-
var
|
|
4623
|
+
var import_wiki_graph_core15 = require("wiki-graph-core");
|
|
4624
|
+
var import_path5 = require("path");
|
|
4560
4625
|
var WikiGraphMaintenanceManager = class {
|
|
4561
4626
|
#runtime;
|
|
4562
4627
|
constructor(runtime) {
|
|
@@ -4566,22 +4631,22 @@ var WikiGraphMaintenanceManager = class {
|
|
|
4566
4631
|
return await this.#runtime.run(
|
|
4567
4632
|
async () => {
|
|
4568
4633
|
if (target.kind === "home") {
|
|
4569
|
-
return await (0,
|
|
4634
|
+
return await (0, import_wiki_graph_core15.upgradeWikiGraphMaintenanceTarget)({ kind: "home" });
|
|
4570
4635
|
}
|
|
4571
4636
|
if (target.kind === "library") {
|
|
4572
|
-
const parsed = (0,
|
|
4637
|
+
const parsed = (0, import_wiki_graph_core15.parseWikiGraphLibraryUri)(target.uri);
|
|
4573
4638
|
if (parsed === void 0 || parsed.kind === "archive") {
|
|
4574
4639
|
throw new Error(
|
|
4575
4640
|
`Invalid Wiki Graph library upgrade target: ${target.uri}`
|
|
4576
4641
|
);
|
|
4577
4642
|
}
|
|
4578
|
-
return await (0,
|
|
4643
|
+
return await (0, import_wiki_graph_core15.upgradeWikiGraphMaintenanceTarget)({
|
|
4579
4644
|
kind: "library",
|
|
4580
4645
|
target: parsed
|
|
4581
4646
|
});
|
|
4582
4647
|
}
|
|
4583
4648
|
const path = resolveWikiGraphRuntimePath(target.path);
|
|
4584
|
-
return await (0,
|
|
4649
|
+
return await (0, import_wiki_graph_core15.upgradeWikiGraphMaintenanceTarget)({
|
|
4585
4650
|
file: new NodeFile(path),
|
|
4586
4651
|
kind: "archive"
|
|
4587
4652
|
});
|
|
@@ -4594,9 +4659,9 @@ var WikiGraphMaintenanceManager = class {
|
|
|
4594
4659
|
return await this.#runtime.run(async () => {
|
|
4595
4660
|
const resolvedInputPath = resolveWikiGraphRuntimePath(inputPath);
|
|
4596
4661
|
const resolvedOutputPath = resolveWikiGraphRuntimePath(outputPath);
|
|
4597
|
-
await (0,
|
|
4662
|
+
await (0, import_wiki_graph_core15.migrateLegacySdpubToWikg)(
|
|
4598
4663
|
new NodeFile(resolvedInputPath),
|
|
4599
|
-
new NodeFile(resolvedOutputPath, (0,
|
|
4664
|
+
new NodeFile(resolvedOutputPath, (0, import_path5.basename)(resolvedOutputPath))
|
|
4600
4665
|
);
|
|
4601
4666
|
return {
|
|
4602
4667
|
inputPath: resolvedInputPath,
|
|
@@ -4610,7 +4675,7 @@ function defaultWikgOutputPath(inputPath) {
|
|
|
4610
4675
|
}
|
|
4611
4676
|
|
|
4612
4677
|
// src/sdk.ts
|
|
4613
|
-
var
|
|
4678
|
+
var import_wiki_graph_core16 = require("wiki-graph-core");
|
|
4614
4679
|
var WikiGraphSDK = class {
|
|
4615
4680
|
#context;
|
|
4616
4681
|
#homeReady;
|
|
@@ -4641,7 +4706,7 @@ var WikiGraphSDK = class {
|
|
|
4641
4706
|
throwIfAborted(signal);
|
|
4642
4707
|
const runWithContext = async () => await withWikiGraphSDKRuntimeContext(this.#context, async () => {
|
|
4643
4708
|
if (options.skipHomeBootstrap !== true) {
|
|
4644
|
-
this.#homeReady ??= (0,
|
|
4709
|
+
this.#homeReady ??= (0, import_wiki_graph_core16.ensureWikiGraphHomeSchemaCurrent)().catch(
|
|
4645
4710
|
(error) => {
|
|
4646
4711
|
this.#homeReady = void 0;
|
|
4647
4712
|
throw error;
|
|
@@ -4671,7 +4736,7 @@ function createWikiGraphSDK(options = {}) {
|
|
|
4671
4736
|
}
|
|
4672
4737
|
|
|
4673
4738
|
// src/index.ts
|
|
4674
|
-
var
|
|
4739
|
+
var import_wiki_graph_core17 = require("wiki-graph-core");
|
|
4675
4740
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4676
4741
|
0 && (module.exports = {
|
|
4677
4742
|
DANGEROUS_RUNTIME_ENV_NAMES,
|