wiki-graph-sdk 0.8.2 → 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 +8 -3
- package/dist/archives.cjs +18 -19
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.js +6 -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 +6 -7
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +40 -17
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +37 -14
- 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 +6 -7
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +61 -9
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.d.ts +1 -1
- package/dist/gc.js +61 -9
- package/dist/gc.js.map +1 -1
- package/dist/host-IbqJ8WSV.d.ts +18 -0
- package/dist/index.cjs +48 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -16
- 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 +6 -7
- package/dist/local-config.js.map +1 -1
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js.map +1 -1
- package/dist/runtime-config.cjs +6 -7
- package/dist/runtime-config.cjs.map +1 -1
- package/dist/runtime-config.js +6 -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 +6 -7
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +55 -31
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +61 -37
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
- package/dist/host-pQiVAKEY.d.ts +0 -10
package/README.md
CHANGED
|
@@ -40,13 +40,18 @@ const wikiGraph = createWikiGraphSDK({
|
|
|
40
40
|
libraryRoot: "/path/to/home",
|
|
41
41
|
documentStoreRoot: "/path/to/documents",
|
|
42
42
|
}),
|
|
43
|
+
stateDir: "/path/to/state",
|
|
43
44
|
},
|
|
44
45
|
});
|
|
45
46
|
```
|
|
46
47
|
|
|
47
|
-
Storage
|
|
48
|
-
are process-wide; SDK instances in one process
|
|
49
|
-
platform.
|
|
48
|
+
Storage and SDK configuration state are scoped to the SDK instance. Platform
|
|
49
|
+
services, including lifecycle, are process-wide; SDK instances in one process
|
|
50
|
+
must use one compatible platform. The top-level `stateDir` remains a shorthand
|
|
51
|
+
for the default Node host. When supplying `host.storage`, put the independent
|
|
52
|
+
configuration root in the required `host.stateDir` field instead. A custom
|
|
53
|
+
`host.storage` without `host.stateDir` is rejected rather than falling back to
|
|
54
|
+
the current user's `~/.wikigraph` directory.
|
|
50
55
|
|
|
51
56
|
Applications may replace the configured LLM and embedding implementations for
|
|
52
57
|
one SDK instance:
|
package/dist/archives.cjs
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = __toCommonJS(archive_exports);
|
|
|
41
41
|
|
|
42
42
|
// src/archive/archive.ts
|
|
43
43
|
var import_crypto2 = require("crypto");
|
|
44
|
-
var
|
|
44
|
+
var import_promises5 = require("fs/promises");
|
|
45
45
|
var import_os3 = require("os");
|
|
46
46
|
var import_path5 = require("path");
|
|
47
47
|
var import_stream = require("stream");
|
|
@@ -50,7 +50,7 @@ var import_wiki_graph_core7 = require("wiki-graph-core");
|
|
|
50
50
|
// src/conversions.ts
|
|
51
51
|
var import_crypto = require("crypto");
|
|
52
52
|
var import_fs = require("fs");
|
|
53
|
-
var
|
|
53
|
+
var import_promises4 = require("fs/promises");
|
|
54
54
|
var import_path4 = require("path");
|
|
55
55
|
var import_wiki_graph_core3 = require("wiki-graph-core");
|
|
56
56
|
|
|
@@ -831,13 +831,15 @@ function getWikiGraphSDKRuntimeContext() {
|
|
|
831
831
|
};
|
|
832
832
|
}
|
|
833
833
|
function getWikiGraphSDKStateDir() {
|
|
834
|
-
|
|
834
|
+
const context = getWikiGraphSDKRuntimeContext();
|
|
835
|
+
return context.host?.stateDir ?? context.stateDir;
|
|
835
836
|
}
|
|
836
837
|
function getWikiGraphSDKProviders() {
|
|
837
838
|
return getWikiGraphSDKRuntimeContext().providers ?? {};
|
|
838
839
|
}
|
|
839
840
|
|
|
840
841
|
// src/local-config.ts
|
|
842
|
+
var import_promises2 = require("fs/promises");
|
|
841
843
|
var import_path = require("path");
|
|
842
844
|
var import_os = require("os");
|
|
843
845
|
var LOCAL_CONFIG_SCHEMA_SQL = `
|
|
@@ -867,13 +869,10 @@ function validateLocalConfigSection(section, value) {
|
|
|
867
869
|
}
|
|
868
870
|
}
|
|
869
871
|
async function withLocalConfigDatabase(operation) {
|
|
872
|
+
const stateDir = getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph");
|
|
873
|
+
await (0, import_promises2.mkdir)(stateDir, { recursive: true });
|
|
870
874
|
const database = await (0, import_wiki_graph_core.openSharedStateDatabase)(
|
|
871
|
-
new NodeFile(
|
|
872
|
-
(0, import_path.join)(
|
|
873
|
-
getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph"),
|
|
874
|
-
"core.sqlite"
|
|
875
|
-
)
|
|
876
|
-
),
|
|
875
|
+
new NodeFile((0, import_path.join)(stateDir, "core.sqlite")),
|
|
877
876
|
LOCAL_CONFIG_SCHEMA_SQL
|
|
878
877
|
);
|
|
879
878
|
try {
|
|
@@ -1271,7 +1270,7 @@ function resolveWikiGraphRuntimePath(path) {
|
|
|
1271
1270
|
}
|
|
1272
1271
|
|
|
1273
1272
|
// src/archive/target.ts
|
|
1274
|
-
var
|
|
1273
|
+
var import_promises3 = require("fs/promises");
|
|
1275
1274
|
var import_path3 = require("path");
|
|
1276
1275
|
var import_wiki_graph_core2 = require("wiki-graph-core");
|
|
1277
1276
|
var WikiGraphArchiveOwnershipError = class extends Error {
|
|
@@ -1370,7 +1369,7 @@ async function resolveLibraryLocation(target) {
|
|
|
1370
1369
|
}
|
|
1371
1370
|
async function canonicalPath(path) {
|
|
1372
1371
|
try {
|
|
1373
|
-
return await (0,
|
|
1372
|
+
return await (0, import_promises3.realpath)(path);
|
|
1374
1373
|
} catch {
|
|
1375
1374
|
const absolute = (0, import_path3.resolve)(path);
|
|
1376
1375
|
const parent = (0, import_path3.dirname)(absolute);
|
|
@@ -1421,7 +1420,7 @@ function requireUnambiguousManagedMatch(path, matches) {
|
|
|
1421
1420
|
}
|
|
1422
1421
|
async function readFileIdentity(path) {
|
|
1423
1422
|
try {
|
|
1424
|
-
const value = await (0,
|
|
1423
|
+
const value = await (0, import_promises3.stat)(path);
|
|
1425
1424
|
return `${value.dev}:${value.ino}`;
|
|
1426
1425
|
} catch {
|
|
1427
1426
|
return void 0;
|
|
@@ -1545,7 +1544,7 @@ async function prepareDigestDirectory(path, required) {
|
|
|
1545
1544
|
if (!required || normalized === void 0 || normalized === "")
|
|
1546
1545
|
return void 0;
|
|
1547
1546
|
const resolved = resolveWikiGraphRuntimePath(normalized);
|
|
1548
|
-
await (0,
|
|
1547
|
+
await (0, import_promises4.rm)(resolved, { force: true, recursive: true });
|
|
1549
1548
|
return new NodeDirectory(resolved);
|
|
1550
1549
|
}
|
|
1551
1550
|
async function writeArchive(archive, path, format) {
|
|
@@ -1938,10 +1937,10 @@ var WikiGraphArchiveManager = class {
|
|
|
1938
1937
|
});
|
|
1939
1938
|
}
|
|
1940
1939
|
if (options.replace === true) {
|
|
1941
|
-
await (0,
|
|
1940
|
+
await (0, import_promises5.rename)(outputPath, path);
|
|
1942
1941
|
} else {
|
|
1943
1942
|
try {
|
|
1944
|
-
await (0,
|
|
1943
|
+
await (0, import_promises5.link)(outputPath, path);
|
|
1945
1944
|
} catch (error) {
|
|
1946
1945
|
if (isNodeEEXISTError(error)) {
|
|
1947
1946
|
throw new WikiGraphArchiveExistsError(path);
|
|
@@ -1951,7 +1950,7 @@ var WikiGraphArchiveManager = class {
|
|
|
1951
1950
|
}
|
|
1952
1951
|
return { locatedUri: (0, import_wiki_graph_core7.formatLocatedWikiGraphUri)(path), path };
|
|
1953
1952
|
} finally {
|
|
1954
|
-
await (0,
|
|
1953
|
+
await (0, import_promises5.rm)(outputPath, { force: true, recursive: true });
|
|
1955
1954
|
}
|
|
1956
1955
|
}, options.signal);
|
|
1957
1956
|
}
|
|
@@ -2572,7 +2571,7 @@ function selectChapterSubtree(chapters, rootChapterId, depth) {
|
|
|
2572
2571
|
);
|
|
2573
2572
|
}
|
|
2574
2573
|
async function createEmptyArchiveFile(path) {
|
|
2575
|
-
const directoryPath = await (0,
|
|
2574
|
+
const directoryPath = await (0, import_promises5.mkdtemp)(
|
|
2576
2575
|
(0, import_path5.join)((0, import_os3.tmpdir)(), "wikigraph-archive-write-")
|
|
2577
2576
|
);
|
|
2578
2577
|
try {
|
|
@@ -2587,7 +2586,7 @@ async function createEmptyArchiveFile(path) {
|
|
|
2587
2586
|
}
|
|
2588
2587
|
await (0, import_wiki_graph_core7.writeWikgArchive)(directory, new NodeFile(path));
|
|
2589
2588
|
} finally {
|
|
2590
|
-
await (0,
|
|
2589
|
+
await (0, import_promises5.rm)(directoryPath, { force: true, recursive: true });
|
|
2591
2590
|
}
|
|
2592
2591
|
}
|
|
2593
2592
|
function isNodeEEXISTError(error) {
|
|
@@ -2595,7 +2594,7 @@ function isNodeEEXISTError(error) {
|
|
|
2595
2594
|
}
|
|
2596
2595
|
async function nodePathExists(path) {
|
|
2597
2596
|
try {
|
|
2598
|
-
await (0,
|
|
2597
|
+
await (0, import_promises5.stat)(path);
|
|
2599
2598
|
return true;
|
|
2600
2599
|
} catch (error) {
|
|
2601
2600
|
if (isNodeENOENTError(error)) return false;
|