@abraca/mcp 1.3.1 → 1.5.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/abracadabra-mcp.cjs +25 -11
- package/dist/abracadabra-mcp.cjs.map +1 -1
- package/dist/abracadabra-mcp.esm.js +25 -11
- package/dist/abracadabra-mcp.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/tools/tree.ts +24 -12
|
@@ -19891,6 +19891,9 @@ function docToSpaceMeta(doc) {
|
|
|
19891
19891
|
//#endregion
|
|
19892
19892
|
//#region packages/mcp/src/tools/tree.ts
|
|
19893
19893
|
/**
|
|
19894
|
+
* Document tree tools — operate on the root Y.Doc's "doc-tree" Y.Map.
|
|
19895
|
+
*/
|
|
19896
|
+
/**
|
|
19894
19897
|
* Normalize a document ID so the hub/root doc ID is treated as the tree root (null).
|
|
19895
19898
|
* This lets callers pass the hub doc_id from list_spaces as parentId/rootId
|
|
19896
19899
|
* and get the expected root-level results instead of an empty set.
|
|
@@ -19899,9 +19902,15 @@ function normalizeRootId(id, server) {
|
|
|
19899
19902
|
if (id == null) return null;
|
|
19900
19903
|
return id === server.rootDocId ? null : id;
|
|
19901
19904
|
}
|
|
19905
|
+
/** Safely read a tree map value, converting Y.Map to plain object if needed. */
|
|
19906
|
+
function toPlain(val) {
|
|
19907
|
+
return val instanceof Y.Map ? val.toJSON() : val;
|
|
19908
|
+
}
|
|
19902
19909
|
function readEntries$1(treeMap) {
|
|
19903
19910
|
const entries = [];
|
|
19904
|
-
treeMap.forEach((
|
|
19911
|
+
treeMap.forEach((raw, id) => {
|
|
19912
|
+
const value = toPlain(raw);
|
|
19913
|
+
if (typeof value !== "object" || value === null) return;
|
|
19905
19914
|
entries.push({
|
|
19906
19915
|
id,
|
|
19907
19916
|
label: value.label || "Untitled",
|
|
@@ -20104,14 +20113,15 @@ function registerTreeTools(mcp, server) {
|
|
|
20104
20113
|
text: "Not connected"
|
|
20105
20114
|
}] };
|
|
20106
20115
|
}
|
|
20107
|
-
const
|
|
20108
|
-
if (!
|
|
20116
|
+
const raw = treeMap.get(id);
|
|
20117
|
+
if (!raw) {
|
|
20109
20118
|
server.setActiveToolCall(null);
|
|
20110
20119
|
return { content: [{
|
|
20111
20120
|
type: "text",
|
|
20112
20121
|
text: `Document ${id} not found`
|
|
20113
20122
|
}] };
|
|
20114
20123
|
}
|
|
20124
|
+
const entry = toPlain(raw);
|
|
20115
20125
|
treeMap.set(id, {
|
|
20116
20126
|
...entry,
|
|
20117
20127
|
label,
|
|
@@ -20141,14 +20151,15 @@ function registerTreeTools(mcp, server) {
|
|
|
20141
20151
|
text: "Not connected"
|
|
20142
20152
|
}] };
|
|
20143
20153
|
}
|
|
20144
|
-
const
|
|
20145
|
-
if (!
|
|
20154
|
+
const raw = treeMap.get(id);
|
|
20155
|
+
if (!raw) {
|
|
20146
20156
|
server.setActiveToolCall(null);
|
|
20147
20157
|
return { content: [{
|
|
20148
20158
|
type: "text",
|
|
20149
20159
|
text: `Document ${id} not found`
|
|
20150
20160
|
}] };
|
|
20151
20161
|
}
|
|
20162
|
+
const entry = toPlain(raw);
|
|
20152
20163
|
treeMap.set(id, {
|
|
20153
20164
|
...entry,
|
|
20154
20165
|
parentId: normalizeRootId(newParentId, server),
|
|
@@ -20181,8 +20192,9 @@ function registerTreeTools(mcp, server) {
|
|
|
20181
20192
|
const now = Date.now();
|
|
20182
20193
|
rootDoc.transact(() => {
|
|
20183
20194
|
for (const nid of toDelete) {
|
|
20184
|
-
const
|
|
20185
|
-
if (!
|
|
20195
|
+
const raw = treeMap.get(nid);
|
|
20196
|
+
if (!raw) continue;
|
|
20197
|
+
const entry = toPlain(raw);
|
|
20186
20198
|
trashMap.set(nid, {
|
|
20187
20199
|
label: entry.label || "Untitled",
|
|
20188
20200
|
parentId: entry.parentId ?? null,
|
|
@@ -20217,14 +20229,15 @@ function registerTreeTools(mcp, server) {
|
|
|
20217
20229
|
text: "Not connected"
|
|
20218
20230
|
}] };
|
|
20219
20231
|
}
|
|
20220
|
-
const
|
|
20221
|
-
if (!
|
|
20232
|
+
const raw = treeMap.get(id);
|
|
20233
|
+
if (!raw) {
|
|
20222
20234
|
server.setActiveToolCall(null);
|
|
20223
20235
|
return { content: [{
|
|
20224
20236
|
type: "text",
|
|
20225
20237
|
text: `Document ${id} not found`
|
|
20226
20238
|
}] };
|
|
20227
20239
|
}
|
|
20240
|
+
const entry = toPlain(raw);
|
|
20228
20241
|
treeMap.set(id, {
|
|
20229
20242
|
...entry,
|
|
20230
20243
|
type,
|
|
@@ -20265,11 +20278,12 @@ function registerTreeTools(mcp, server) {
|
|
|
20265
20278
|
type: "text",
|
|
20266
20279
|
text: "Not connected"
|
|
20267
20280
|
}] };
|
|
20268
|
-
const
|
|
20269
|
-
if (!
|
|
20281
|
+
const raw = treeMap.get(id);
|
|
20282
|
+
if (!raw) return { content: [{
|
|
20270
20283
|
type: "text",
|
|
20271
20284
|
text: `Document ${id} not found`
|
|
20272
20285
|
}] };
|
|
20286
|
+
const entry = toPlain(raw);
|
|
20273
20287
|
const newId = crypto.randomUUID();
|
|
20274
20288
|
treeMap.set(newId, {
|
|
20275
20289
|
...entry,
|