@appsoftwareltd/etherpk-mcp 0.24.0 → 0.26.0
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/dist/main.js +54 -7
- package/dist/main.js.map +1 -1
- package/package.json +6 -6
package/dist/main.js
CHANGED
|
@@ -820,7 +820,7 @@ function looksLikeAgentSetupCode(value) {
|
|
|
820
820
|
}
|
|
821
821
|
var package_default = {
|
|
822
822
|
name: "@appsoftwareltd/etherpk-mcp",
|
|
823
|
-
version: "0.
|
|
823
|
+
version: "0.26.0",
|
|
824
824
|
license: "Elastic-2.0",
|
|
825
825
|
description: "EtherPK Headless Client: an MCP server over a synced knowledge graph, run beside the agent on the user's own machine.",
|
|
826
826
|
type: "module",
|
|
@@ -9776,15 +9776,33 @@ function sanitizeQuickNotes(raw) {
|
|
|
9776
9776
|
if (typeof text !== "string" || text.trim() === "") continue;
|
|
9777
9777
|
if (typeof createdAt !== "number" || !Number.isFinite(createdAt)) continue;
|
|
9778
9778
|
seen.add(id);
|
|
9779
|
-
out.push({
|
|
9779
|
+
out.push(filedUnder({
|
|
9780
9780
|
id,
|
|
9781
9781
|
text: text.trim(),
|
|
9782
9782
|
createdAt
|
|
9783
|
-
});
|
|
9783
|
+
}, entry.under));
|
|
9784
9784
|
if (out.length >= MAX_QUICK_NOTES) break;
|
|
9785
9785
|
}
|
|
9786
9786
|
return out;
|
|
9787
9787
|
}
|
|
9788
|
+
/**
|
|
9789
|
+
* A concept name a note can be filed under, or undefined: one line of text, trimmed. Anything
|
|
9790
|
+
* else (a list from a newer client, a hand-edited file) files the note under nothing, which
|
|
9791
|
+
* still moves it.
|
|
9792
|
+
*/
|
|
9793
|
+
function sanitizeUnder(raw) {
|
|
9794
|
+
if (typeof raw !== "string") return void 0;
|
|
9795
|
+
const name = raw.trim();
|
|
9796
|
+
return name === "" || /[\r\n]/.test(name) ? void 0 : name;
|
|
9797
|
+
}
|
|
9798
|
+
/** `note` filed under `under` when that is a concept name, and under nothing otherwise. */
|
|
9799
|
+
function filedUnder(note, under) {
|
|
9800
|
+
const filed = sanitizeUnder(under);
|
|
9801
|
+
return filed ? {
|
|
9802
|
+
...note,
|
|
9803
|
+
under: filed
|
|
9804
|
+
} : note;
|
|
9805
|
+
}
|
|
9788
9806
|
new Intl.Segmenter(void 0, { granularity: "word" });
|
|
9789
9807
|
/**
|
|
9790
9808
|
* The spelling a dictionary is asked about: a curly apostrophe (`’`), which keyboards and
|
|
@@ -10576,6 +10594,15 @@ function memberListName(name) {
|
|
|
10576
10594
|
memberKey: name.slice(colon + 1)
|
|
10577
10595
|
};
|
|
10578
10596
|
}
|
|
10597
|
+
/** The text of every Quick Note in a root document: the shared `quickNotes` array and each `quickNotes:<member>`. */
|
|
10598
|
+
function quickNoteTextsIn(doc) {
|
|
10599
|
+
const texts = [];
|
|
10600
|
+
for (const name of [...doc.share.keys()]) {
|
|
10601
|
+
if (name !== "quickNotes" && memberListName(name)?.kind !== "quickNotes") continue;
|
|
10602
|
+
for (const note of sanitizeQuickNotes(doc.getArray(name).toArray())) texts.push(note.text);
|
|
10603
|
+
}
|
|
10604
|
+
return texts;
|
|
10605
|
+
}
|
|
10579
10606
|
/** An empty member key would name one list every member shares: the opposite of a per-person list. */
|
|
10580
10607
|
function requireMemberKey(memberKey, what) {
|
|
10581
10608
|
if (memberKey === "") throw new Error(`${what}: a member key is required`);
|
|
@@ -10807,7 +10834,8 @@ function quickNotesOver(doc, array) {
|
|
|
10807
10834
|
array.push([{
|
|
10808
10835
|
id: note.id,
|
|
10809
10836
|
text: note.text,
|
|
10810
|
-
createdAt: note.createdAt
|
|
10837
|
+
createdAt: note.createdAt,
|
|
10838
|
+
...note.under ? { under: note.under } : {}
|
|
10811
10839
|
}]);
|
|
10812
10840
|
},
|
|
10813
10841
|
remove(ids) {
|
|
@@ -11787,6 +11815,7 @@ function createGraphSync(deps) {
|
|
|
11787
11815
|
return () => metaMap.unobserve(listener);
|
|
11788
11816
|
},
|
|
11789
11817
|
quickNotes: () => quickNotesOver(root.doc, quickNotesArray),
|
|
11818
|
+
allQuickNoteTexts: () => quickNoteTextsIn(root.doc),
|
|
11790
11819
|
quickNotesOf(memberKey) {
|
|
11791
11820
|
requireMemberKey(memberKey, "quickNotesOf");
|
|
11792
11821
|
return quickNotesOver(root.doc, root.doc.getArray(`quickNotes:${memberKey}`));
|
|
@@ -17113,7 +17142,8 @@ function createAssetStore(adapter) {
|
|
|
17113
17142
|
const { stem, ext } = splitNameExt(name);
|
|
17114
17143
|
const index = await assetsByContent();
|
|
17115
17144
|
const key = contentKey(hash, ext);
|
|
17116
|
-
const
|
|
17145
|
+
const held = index.get(key);
|
|
17146
|
+
const existing = held !== void 0 && await adapter.exists("assets", held) ? held : void 0;
|
|
17117
17147
|
const fileName = existing ?? assetFileName(name, hash);
|
|
17118
17148
|
if (!existing) {
|
|
17119
17149
|
await adapter.writeBinary("assets", fileName, bytes);
|
|
@@ -18545,6 +18575,21 @@ function assetIdFromRef(ref) {
|
|
|
18545
18575
|
const m = /(?:^|\.)([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\.[^.]+)?$/.exec(file);
|
|
18546
18576
|
return m ? m[1] : null;
|
|
18547
18577
|
}
|
|
18578
|
+
/**
|
|
18579
|
+
* Run `send` while no other tab, page or worker of this browser is sending the same graph's
|
|
18580
|
+
* queue. More than one of them can hold a store for one graph (an open workspace, the Share
|
|
18581
|
+
* Target's page, the app as it starts), and two senders would upload each file twice. One that
|
|
18582
|
+
* finds the queue being sent reports nothing sent and nothing waiting: the sender that holds
|
|
18583
|
+
* the lock says what happened. Without Web Locks (a test, an old browser) it runs.
|
|
18584
|
+
*/
|
|
18585
|
+
async function oneSenderAtATime(graphId, send) {
|
|
18586
|
+
const locks = typeof navigator === "undefined" ? void 0 : navigator.locks;
|
|
18587
|
+
if (!locks) return send();
|
|
18588
|
+
return locks.request(`etherpk-queued-uploads:${graphId}`, { ifAvailable: true }, (lock) => lock ? send() : {
|
|
18589
|
+
sent: 0,
|
|
18590
|
+
waiting: 0
|
|
18591
|
+
});
|
|
18592
|
+
}
|
|
18548
18593
|
function createServerAssetStore(deps) {
|
|
18549
18594
|
const f = deps.fetch ?? fetch;
|
|
18550
18595
|
const online = deps.online ?? (() => typeof navigator === "undefined" || navigator.onLine !== false);
|
|
@@ -18869,6 +18914,8 @@ function createServerAssetStore(deps) {
|
|
|
18869
18914
|
};
|
|
18870
18915
|
}
|
|
18871
18916
|
let sending = null;
|
|
18917
|
+
/** A save is kept on this device with no network call: told to (`queueFirst`), or offline. */
|
|
18918
|
+
const queuesWithoutAsking = () => deps.copies !== void 0 && (deps.queueFirst === true || !online());
|
|
18872
18919
|
return {
|
|
18873
18920
|
async save({ name, bytes, type }, onBytes) {
|
|
18874
18921
|
const ring = keyring();
|
|
@@ -18922,7 +18969,7 @@ function createServerAssetStore(deps) {
|
|
|
18922
18969
|
queued: true
|
|
18923
18970
|
};
|
|
18924
18971
|
};
|
|
18925
|
-
if (
|
|
18972
|
+
if (queuesWithoutAsking()) return queue();
|
|
18926
18973
|
const dedupToken = await assetDedupToken(await dedupSecret(ring), hash);
|
|
18927
18974
|
let begun;
|
|
18928
18975
|
try {
|
|
@@ -19012,7 +19059,7 @@ function createServerAssetStore(deps) {
|
|
|
19012
19059
|
}, { pinned: true });
|
|
19013
19060
|
},
|
|
19014
19061
|
uploadQueued() {
|
|
19015
|
-
sending ??= sendQueued
|
|
19062
|
+
sending ??= oneSenderAtATime(deps.graphId, sendQueued).finally(() => {
|
|
19016
19063
|
sending = null;
|
|
19017
19064
|
});
|
|
19018
19065
|
return sending;
|