@abraca/mcp 1.3.1 → 1.3.4

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.
@@ -19895,6 +19895,9 @@ function docToSpaceMeta(doc) {
19895
19895
  //#endregion
19896
19896
  //#region packages/mcp/src/tools/tree.ts
19897
19897
  /**
19898
+ * Document tree tools — operate on the root Y.Doc's "doc-tree" Y.Map.
19899
+ */
19900
+ /**
19898
19901
  * Normalize a document ID so the hub/root doc ID is treated as the tree root (null).
19899
19902
  * This lets callers pass the hub doc_id from list_spaces as parentId/rootId
19900
19903
  * and get the expected root-level results instead of an empty set.
@@ -19903,9 +19906,15 @@ function normalizeRootId(id, server) {
19903
19906
  if (id == null) return null;
19904
19907
  return id === server.rootDocId ? null : id;
19905
19908
  }
19909
+ /** Safely read a tree map value, converting Y.Map to plain object if needed. */
19910
+ function toPlain(val) {
19911
+ return val instanceof yjs.Map ? val.toJSON() : val;
19912
+ }
19906
19913
  function readEntries$1(treeMap) {
19907
19914
  const entries = [];
19908
- treeMap.forEach((value, id) => {
19915
+ treeMap.forEach((raw, id) => {
19916
+ const value = toPlain(raw);
19917
+ if (typeof value !== "object" || value === null) return;
19909
19918
  entries.push({
19910
19919
  id,
19911
19920
  label: value.label || "Untitled",
@@ -20108,14 +20117,15 @@ function registerTreeTools(mcp, server) {
20108
20117
  text: "Not connected"
20109
20118
  }] };
20110
20119
  }
20111
- const entry = treeMap.get(id);
20112
- if (!entry) {
20120
+ const raw = treeMap.get(id);
20121
+ if (!raw) {
20113
20122
  server.setActiveToolCall(null);
20114
20123
  return { content: [{
20115
20124
  type: "text",
20116
20125
  text: `Document ${id} not found`
20117
20126
  }] };
20118
20127
  }
20128
+ const entry = toPlain(raw);
20119
20129
  treeMap.set(id, {
20120
20130
  ...entry,
20121
20131
  label,
@@ -20145,14 +20155,15 @@ function registerTreeTools(mcp, server) {
20145
20155
  text: "Not connected"
20146
20156
  }] };
20147
20157
  }
20148
- const entry = treeMap.get(id);
20149
- if (!entry) {
20158
+ const raw = treeMap.get(id);
20159
+ if (!raw) {
20150
20160
  server.setActiveToolCall(null);
20151
20161
  return { content: [{
20152
20162
  type: "text",
20153
20163
  text: `Document ${id} not found`
20154
20164
  }] };
20155
20165
  }
20166
+ const entry = toPlain(raw);
20156
20167
  treeMap.set(id, {
20157
20168
  ...entry,
20158
20169
  parentId: normalizeRootId(newParentId, server),
@@ -20185,8 +20196,9 @@ function registerTreeTools(mcp, server) {
20185
20196
  const now = Date.now();
20186
20197
  rootDoc.transact(() => {
20187
20198
  for (const nid of toDelete) {
20188
- const entry = treeMap.get(nid);
20189
- if (!entry) continue;
20199
+ const raw = treeMap.get(nid);
20200
+ if (!raw) continue;
20201
+ const entry = toPlain(raw);
20190
20202
  trashMap.set(nid, {
20191
20203
  label: entry.label || "Untitled",
20192
20204
  parentId: entry.parentId ?? null,
@@ -20221,14 +20233,15 @@ function registerTreeTools(mcp, server) {
20221
20233
  text: "Not connected"
20222
20234
  }] };
20223
20235
  }
20224
- const entry = treeMap.get(id);
20225
- if (!entry) {
20236
+ const raw = treeMap.get(id);
20237
+ if (!raw) {
20226
20238
  server.setActiveToolCall(null);
20227
20239
  return { content: [{
20228
20240
  type: "text",
20229
20241
  text: `Document ${id} not found`
20230
20242
  }] };
20231
20243
  }
20244
+ const entry = toPlain(raw);
20232
20245
  treeMap.set(id, {
20233
20246
  ...entry,
20234
20247
  type,
@@ -20269,11 +20282,12 @@ function registerTreeTools(mcp, server) {
20269
20282
  type: "text",
20270
20283
  text: "Not connected"
20271
20284
  }] };
20272
- const entry = treeMap.get(id);
20273
- if (!entry) return { content: [{
20285
+ const raw = treeMap.get(id);
20286
+ if (!raw) return { content: [{
20274
20287
  type: "text",
20275
20288
  text: `Document ${id} not found`
20276
20289
  }] };
20290
+ const entry = toPlain(raw);
20277
20291
  const newId = crypto.randomUUID();
20278
20292
  treeMap.set(newId, {
20279
20293
  ...entry,