@hiai-gg/docsmint 1.0.2 → 2.0.2

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.
Files changed (147) hide show
  1. package/README.md +21 -6
  2. package/dist/backend/index.js +14356 -12995
  3. package/dist/frontend/{CategoryDialog-B6zqtwE6.js → CategoryDialog-CJeAYxcd.js} +7 -7
  4. package/dist/frontend/{ConfirmDialog-Dk7wwcj9.js → ConfirmDialog-B1MjKlVQ.js} +5 -5
  5. package/dist/frontend/{CreateSnapshotDialog-BPYjO1qN.js → CreateSnapshotDialog-BTMoPFdj.js} +4 -4
  6. package/dist/frontend/{DatePicker-SiGLx9yh.js → DatePicker-Bmjko3X7.js} +12 -12
  7. package/dist/frontend/{DeleteDialog-D1jox8h1.js → DeleteDialog-BkfIeKXO.js} +3 -3
  8. package/dist/frontend/{FolderNode-BG4l6I5C.js → FolderNode-Do8pIfyA.js} +4 -4
  9. package/dist/frontend/{FolderTreeSelector-DqO-f0nt.js → FolderTreeSelector-FyxhcHjr.js} +3 -3
  10. package/dist/frontend/{HiAiEditor-Dxqt8BUN.js → HiAiEditor-DDpfdQEg.js} +42 -42
  11. package/dist/frontend/{Icon-y7xxAIC6.js → Icon-3EYzvNyk.js} +1 -1
  12. package/dist/frontend/{SettingsDialog-DnrPV8dM.js → SettingsDialog-DzlYW50I.js} +18 -18
  13. package/dist/frontend/{ShareDialog-CmX-VoJ9.js → ShareDialog-Ddvl7xvb.js} +1 -1
  14. package/dist/frontend/{Sidebar-BI_ccYTl.js → Sidebar-rFiVen96.js} +29 -29
  15. package/dist/frontend/{TagCreateDialog-C5j3H49u.js → TagCreateDialog-DQmMJe_E.js} +5 -5
  16. package/dist/frontend/api/categories.js +1 -1
  17. package/dist/frontend/api/settings.js +1 -1
  18. package/dist/frontend/api/tags.js +1 -1
  19. package/dist/frontend/app-shell.js +6 -6
  20. package/dist/frontend/{auth-client-Dc0mkuZH.js → auth-client-CXR-7mIO.js} +11 -11
  21. package/dist/frontend/{camera-BI-BtnIm.js → camera-DtgHzfVI.js} +2 -2
  22. package/dist/frontend/{categories-Bjcc41We.js → categories-C8AAkhCR.js} +1 -1
  23. package/dist/frontend/{check-sdTlLwi9.js → check-DVx65aSv.js} +2 -2
  24. package/dist/frontend/{chevron-down-DlBnIE7Y.js → chevron-down-C2tbZ8Ol.js} +2 -2
  25. package/dist/frontend/{circle-check-hWC-HeKu.js → circle-check-BAN-D7yg.js} +2 -2
  26. package/dist/frontend/{clock-C4FHq-9q.js → clock-ByiB0SwQ.js} +2 -2
  27. package/dist/frontend/components/category-dialog.js +1 -1
  28. package/dist/frontend/components/create-snapshot-dialog.js +1 -1
  29. package/dist/frontend/components/delete-dialog.js +1 -1
  30. package/dist/frontend/components/editor/compact-editor.js +1 -1
  31. package/dist/frontend/components/editor/document-editor.js +1 -1
  32. package/dist/frontend/components/editor/extensions.js +1 -1
  33. package/dist/frontend/components/editor/markdown-toggle.js +3 -3
  34. package/dist/frontend/components/editor/markdown.js +1 -1
  35. package/dist/frontend/components/folder-node.js +1 -1
  36. package/dist/frontend/components/folder-tree-selector.js +1 -1
  37. package/dist/frontend/components/save-as-dialog.js +7 -7
  38. package/dist/frontend/components/settings.js +1 -1
  39. package/dist/frontend/components/share-dialog.js +1 -1
  40. package/dist/frontend/components/sidebar.js +1 -1
  41. package/dist/frontend/components/tag-create-dialog.js +1 -1
  42. package/dist/frontend/components/version-history.js +10 -10
  43. package/dist/frontend/{copy-4H99lwAQ.js → copy-CRzvfZGb.js} +2 -2
  44. package/dist/frontend/dashboard.js +48 -48
  45. package/dist/frontend/{db-DUOtrCBC.js → db-Dya0HRhS.js} +1 -1
  46. package/dist/frontend/{dialog-DC97Hnxo.js → dialog-a_ZcpEC5.js} +9 -9
  47. package/dist/frontend/{dist-D7zL6zdU.js → dist-CcHOStsA.js} +2 -2
  48. package/dist/frontend/dist-DcHl92QO.js +316 -0
  49. package/dist/frontend/{dndzone-BrakBHwm.js → dndzone-CDhrbpTg.js} +1 -1
  50. package/dist/frontend/{dropdown-menu-COZwS7c0.js → dropdown-menu-DrHYReIC.js} +12 -12
  51. package/dist/frontend/{editorExtensions-Cu__YKW7.js → editorExtensions-DPR-CjMu.js} +1 -1
  52. package/dist/frontend/{ellipsis-vertical-CObXWXZW.js → ellipsis-vertical-qxNgoXu-.js} +2 -2
  53. package/dist/frontend/{folder-BAX6qBYy.js → folder-D74E-Kdp.js} +3 -3
  54. package/dist/frontend/frontend.css +1 -1
  55. package/dist/frontend/{identity-D_rjww-V.js → identity-BOA7Jejv.js} +1 -1
  56. package/dist/frontend/{input-CrlYAH2S.js → input-Q_7qCfnU.js} +2 -2
  57. package/dist/frontend/{label-B0syEfns.js → label-Dj8FDEhf.js} +2 -2
  58. package/dist/frontend/{lib-DYgslUw1.js → lib-aUbBbIW2.js} +3357 -3328
  59. package/dist/frontend/{loader-circle-DnyUzAmN.js → loader-circle-D3t5NkvC.js} +2 -2
  60. package/dist/frontend/{markdown-Co8ZAKf4.js → markdown-O9YJA70S.js} +2 -2
  61. package/dist/frontend/offline/identity.js +1 -1
  62. package/dist/frontend/{popper-layer-force-mount-BAYjg6Pp.js → popper-layer-force-mount-CNtiLgbV.js} +63 -63
  63. package/dist/frontend/{rotate-ccw-DtZDfSK3.js → rotate-ccw-B1ybQ8oQ.js} +2 -2
  64. package/dist/frontend/schemas-1Na35n71.js +3988 -0
  65. package/dist/frontend/search.js +13 -13
  66. package/dist/frontend/{select-value-D9VqY5n5.js → select-value-BkI1W1bn.js} +19 -19
  67. package/dist/frontend/{settings-CW_SR-EH.js → settings-BRcYFQa_.js} +1 -1
  68. package/dist/frontend/{share-context-DooXPYKd.js → share-context-BJ4GF4yT.js} +8 -8
  69. package/dist/frontend/{tag-ChpMfbfa.js → tag-qbTBLj-g.js} +3 -3
  70. package/dist/frontend/{tags-CzPNUoFw.js → tags-CF_cqzSV.js} +1 -1
  71. package/dist/frontend/{textarea-l_gRXsrH.js → textarea-BNK0LFUK.js} +2 -2
  72. package/dist/frontend/theme.js +1 -1
  73. package/dist/frontend/{theme.svelte-gLPpG6eU.js → theme.svelte-BRdxXd-B.js} +3 -3
  74. package/dist/frontend/utils/dndzone.js +1 -1
  75. package/dist/frontend/{utils-B4LKx7VS.js → utils-BlHvR6OL.js} +1 -1
  76. package/dist/frontend/{x-B2ifxSH7.js → x-CvSSnrjl.js} +2 -2
  77. package/dist/frontend-ssr/api/settings.js +1 -1
  78. package/dist/frontend-ssr/app-shell.js +6 -6
  79. package/dist/frontend-ssr/assets/{CategoryDialog-C41IBNWG.js → CategoryDialog-DuZLLlt7.js} +7 -7
  80. package/dist/frontend-ssr/assets/{ConfirmDialog-CWO0HBaS.js → ConfirmDialog-0WVu9BCE.js} +8 -8
  81. package/dist/frontend-ssr/assets/{CreateSnapshotDialog-CECCRK0d.js → CreateSnapshotDialog-3vhDTFNu.js} +4 -4
  82. package/dist/frontend-ssr/assets/{DatePicker-CCylVH0q.js → DatePicker-t12leL2Y.js} +7 -7
  83. package/dist/frontend-ssr/assets/{DeleteDialog-BVnmzR2e.js → DeleteDialog-B0AU1fJR.js} +3 -3
  84. package/dist/frontend-ssr/assets/{FolderNode-CscMQ9sf.js → FolderNode-C-B-s8x1.js} +5 -5
  85. package/dist/frontend-ssr/assets/{FolderTreeSelector-DnrKCYtl.js → FolderTreeSelector-DdQuEcj0.js} +4 -4
  86. package/dist/frontend-ssr/assets/{HiAiEditor-D-FYXUht.js → HiAiEditor-Bj6tiE97.js} +30 -30
  87. package/dist/frontend-ssr/assets/{Icon-Clqe8D8X.js → Icon-DE_3EnuF.js} +4 -4
  88. package/dist/frontend-ssr/assets/{SettingsDialog-BaI2MU5d.js → SettingsDialog-h4SFwpUa.js} +16 -16
  89. package/dist/frontend-ssr/assets/{ShareDialog-DHPbSHZg.js → ShareDialog-CpE9zd_f.js} +1 -1
  90. package/dist/frontend-ssr/assets/{Sidebar-BpTS2uCa.js → Sidebar-BFBpsd3L.js} +26 -26
  91. package/dist/frontend-ssr/assets/{TagCreateDialog-CPg-nG0D.js → TagCreateDialog-DBHO1DPU.js} +4 -4
  92. package/dist/frontend-ssr/assets/{auth-client-Bo5Fg-sb.js → auth-client-BC4hSFKF.js} +13 -13
  93. package/dist/frontend-ssr/assets/{camera-Dwwtgvfn.js → camera-B6ldo_Js.js} +2 -2
  94. package/dist/frontend-ssr/assets/{chevron-down-C6BTPJFz.js → chevron-down-DQcr6JUc.js} +2 -2
  95. package/dist/frontend-ssr/assets/{chevron-right-CseGE1qd.js → chevron-right-9szrliZx.js} +2 -2
  96. package/dist/frontend-ssr/assets/{circle-check-BRhWPZo1.js → circle-check-BgP9MRRv.js} +2 -2
  97. package/dist/frontend-ssr/assets/{clock-DpP_Y7WP.js → clock-roNtGlT6.js} +2 -2
  98. package/dist/frontend-ssr/assets/{copy-DRMKiRZ0.js → copy-BYqYnBIQ.js} +2 -2
  99. package/dist/frontend-ssr/assets/{db-DUKz2X3Z.js → db-C3rFdTZa.js} +1 -1
  100. package/dist/frontend-ssr/assets/{dialog--tDgDGw9.js → dialog-SqCnTT43.js} +9 -9
  101. package/dist/frontend-ssr/assets/{dist-DqeAICTy.js → dist-CaZQ1FhA.js} +10 -10
  102. package/dist/frontend-ssr/assets/{dist-CshZmNmp.js → dist-CqxHwOlp.js} +3 -3
  103. package/dist/frontend-ssr/assets/{dndzone-WtNaDxoQ.js → dndzone-CnTCMhPd.js} +1 -1
  104. package/dist/frontend-ssr/assets/{dropdown-menu--acO7nXs.js → dropdown-menu-CE6U0f1b.js} +12 -12
  105. package/dist/frontend-ssr/assets/{ellipsis-vertical-BErUuhWg.js → ellipsis-vertical-Cg1MrZsl.js} +2 -2
  106. package/dist/frontend-ssr/assets/{folder-DszunwKc.js → folder-DHB-CEcQ.js} +2 -2
  107. package/dist/frontend-ssr/assets/{identity-_M3U9lqe.js → identity-DNIo1bgc.js} +1 -1
  108. package/dist/frontend-ssr/assets/{input-BlAj7LzC.js → input-DVrBVPgs.js} +2 -2
  109. package/dist/frontend-ssr/assets/{label-BRToaMg9.js → label-vtCK3pTp.js} +2 -2
  110. package/dist/frontend-ssr/assets/{loader-circle-BpRVrMZg.js → loader-circle-D3NWhCif.js} +2 -2
  111. package/dist/frontend-ssr/assets/{popper-layer-force-mount-Djnq7l7a.js → popper-layer-force-mount-C4dMMt-f.js} +71 -71
  112. package/dist/frontend-ssr/assets/{rotate-ccw-1GOD_yt_.js → rotate-ccw-DNf3nwMD.js} +2 -2
  113. package/dist/frontend-ssr/assets/{select-value-BCWSsoTd.js → select-value-Ce5c_fuA.js} +18 -18
  114. package/dist/frontend-ssr/assets/{settings-DaOQ4Gv2.js → settings-DWCpfCPj.js} +1 -1
  115. package/dist/frontend-ssr/assets/{share-context-BvXQrIIH.js → share-context-B4UpvTSw.js} +9 -9
  116. package/dist/frontend-ssr/assets/{tag-DFh6nF9R.js → tag-Cqv0fWVG.js} +3 -3
  117. package/dist/frontend-ssr/assets/{textarea-BuszTo9i.js → textarea-BdjOJJVb.js} +2 -2
  118. package/dist/frontend-ssr/assets/{theme.svelte-CGgnJc3k.js → theme.svelte-D6bbaJ9m.js} +3 -3
  119. package/dist/frontend-ssr/assets/{utils-BK35BJKQ.js → utils-D3X7I8nz.js} +1 -1
  120. package/dist/frontend-ssr/components/category-dialog.js +1 -1
  121. package/dist/frontend-ssr/components/create-snapshot-dialog.js +1 -1
  122. package/dist/frontend-ssr/components/delete-dialog.js +1 -1
  123. package/dist/frontend-ssr/components/editor/compact-editor.js +1 -1
  124. package/dist/frontend-ssr/components/editor/document-editor.js +1 -1
  125. package/dist/frontend-ssr/components/editor/markdown-toggle.js +1 -1
  126. package/dist/frontend-ssr/components/folder-node.js +1 -1
  127. package/dist/frontend-ssr/components/folder-tree-selector.js +1 -1
  128. package/dist/frontend-ssr/components/save-as-dialog.js +6 -6
  129. package/dist/frontend-ssr/components/settings.js +1 -1
  130. package/dist/frontend-ssr/components/share-dialog.js +1 -1
  131. package/dist/frontend-ssr/components/sidebar.js +1 -1
  132. package/dist/frontend-ssr/components/tag-create-dialog.js +1 -1
  133. package/dist/frontend-ssr/components/version-history.js +10 -10
  134. package/dist/frontend-ssr/dashboard.js +40 -40
  135. package/dist/frontend-ssr/offline/identity.js +1 -1
  136. package/dist/frontend-ssr/search.js +8 -8
  137. package/dist/frontend-ssr/theme.js +1 -1
  138. package/dist/frontend-ssr/utils/dndzone.js +1 -1
  139. package/dist/lifecycle-runtime.js +7129 -1986
  140. package/dist/mcp-cli.js +171 -73
  141. package/dist/mcp-server.d.ts +15 -0
  142. package/dist/mcp-server.js +175 -73
  143. package/package.json +16 -7
  144. package/packages/cli/src/index.ts +1 -1
  145. package/server.json +2 -2
  146. package/dist/frontend/dist-BLpDfrDC.js +0 -316
  147. package/dist/frontend/schemas-CdPhcuru.js +0 -3001
@@ -570,9 +570,6 @@ var RESOURCE_PERMISSIONS = new Set([
570
570
  "edit",
571
571
  "write"
572
572
  ]);
573
- // ../mcp-server/src/compact.ts
574
- import { z as z3 } from "zod";
575
-
576
573
  // ../mcp-server/src/output-schemas.ts
577
574
  import { z } from "zod";
578
575
  var tagSchema = z.looseObject({
@@ -801,7 +798,7 @@ var operationOutputSchemas = {
801
798
  permanently_delete_document: deleteAcknowledgmentSchema
802
799
  };
803
800
  var variant = (operation, result) => z.object({ operation: z.literal(operation), result });
804
- var toolOutputSchemas = {
801
+ var singleToolOutputSchemas = {
805
802
  delete_document: operationOutputSchemas.delete_document,
806
803
  delete_folder: operationOutputSchemas.delete_folder,
807
804
  delete_category: operationOutputSchemas.delete_category,
@@ -827,6 +824,7 @@ var toolOutputSchemas = {
827
824
  variant("update", operationOutputSchemas.update_document)
828
825
  ]),
829
826
  list_workspace_structure: z.union([
827
+ variant("workspaces", z.array(z.object({ id: z.string().uuid(), name: z.string(), slug: z.string(), entireWorkspace: z.boolean(), categoryIds: z.array(z.string().uuid()) }))),
830
828
  variant("folders", operationOutputSchemas.list_folders),
831
829
  variant("categories", operationOutputSchemas.list_categories),
832
830
  variant("tags", operationOutputSchemas.list_tags)
@@ -869,9 +867,30 @@ var toolOutputSchemas = {
869
867
  variant("tag", tagSchema)
870
868
  ])
871
869
  };
870
+ var workspaceSchema = z.object({ id: z.string().uuid(), name: z.string(), slug: z.string() });
871
+ var scoped = (data) => z.object({
872
+ operation: z.string(),
873
+ scopedResults: z.array(z.object({ workspace: workspaceSchema, categoryId: z.string().uuid().nullable(), data }))
874
+ });
875
+ var scopedSchemas = {
876
+ find_documents: scoped(singleToolOutputSchemas.find_documents),
877
+ list_workspace_structure: scoped(singleToolOutputSchemas.list_workspace_structure),
878
+ list_trash: scoped(singleToolOutputSchemas.list_trash)
879
+ };
880
+ var toolOutputSchemas = {
881
+ ...singleToolOutputSchemas,
882
+ find_documents: z.union([...singleToolOutputSchemas.find_documents.options, scopedSchemas.find_documents]),
883
+ list_workspace_structure: z.union([...singleToolOutputSchemas.list_workspace_structure.options, scopedSchemas.list_workspace_structure]),
884
+ list_trash: z.union([singleToolOutputSchemas.list_trash, scopedSchemas.list_trash])
885
+ };
886
+ function createMcpScopedResult(toolName, input) {
887
+ return scopedSchemas[toolName].parse(input);
888
+ }
889
+ // ../mcp-server/src/compact.ts
890
+ import { z as z4 } from "zod";
872
891
 
873
892
  // ../mcp-server/src/batch-workspace.ts
874
- import { z as z2 } from "zod";
893
+ import { z as z3 } from "zod";
875
894
 
876
895
  // ../mcp-server/src/client.ts
877
896
  var DEFAULT_BASE_URL = "http://localhost:50700";
@@ -965,18 +984,82 @@ var client = new Proxy({}, {
965
984
  }
966
985
  });
967
986
 
987
+ // ../mcp-server/src/client-routing-schema.ts
988
+ import { z as z2 } from "zod";
989
+ function hoistObjectUnionClosure(schema) {
990
+ const variants = schema.oneOf;
991
+ if (!Array.isArray(variants) || !variants.every((variant2) => typeof variant2 === "object" && variant2 !== null && variant2.type === "object" && variant2.additionalProperties === false && typeof variant2.properties === "object" && variant2.properties !== null))
992
+ return schema;
993
+ const propertyVariants = new Map;
994
+ for (const variant2 of variants) {
995
+ for (const [key, property] of Object.entries(variant2.properties)) {
996
+ const values = propertyVariants.get(key) ?? [];
997
+ values.push(property);
998
+ propertyVariants.set(key, values);
999
+ }
1000
+ }
1001
+ return {
1002
+ ...schema,
1003
+ type: "object",
1004
+ properties: Object.fromEntries([...propertyVariants].map(([key, values]) => [
1005
+ key,
1006
+ values.length === 1 ? values[0] : { anyOf: values }
1007
+ ])),
1008
+ additionalProperties: false,
1009
+ oneOf: variants.map((variant2) => {
1010
+ const { additionalProperties: _closure, ...branch } = variant2;
1011
+ const excluded = [...propertyVariants.keys()].filter((key) => !(key in variant2.properties));
1012
+ return excluded.length === 0 ? branch : {
1013
+ ...branch,
1014
+ allOf: [
1015
+ ...Array.isArray(branch.allOf) ? branch.allOf : [],
1016
+ { not: { anyOf: excluded.map((key) => ({ required: [key] })) } }
1017
+ ]
1018
+ };
1019
+ })
1020
+ };
1021
+ }
1022
+ function withClientRoutingSchema(schema) {
1023
+ const standard = schema["~standard"];
1024
+ const selector = z2.string().uuid().optional().describe("Workspace UUID from list_workspace_structure(kind=workspaces). Required for ambiguous creates and structure changes; omit to search all granted scopes.");
1025
+ return {
1026
+ "~standard": {
1027
+ ...standard,
1028
+ validate: async (value, options) => {
1029
+ if (!value || typeof value !== "object" || Array.isArray(value))
1030
+ return standard.validate(value, options);
1031
+ const { workspaceId, ...args } = value;
1032
+ const selected = selector.safeParse(workspaceId);
1033
+ if (!selected.success)
1034
+ return { issues: selected.error.issues };
1035
+ const validated = await standard.validate(args, options);
1036
+ if (validated.issues)
1037
+ return validated;
1038
+ return { value: { ...validated.value, ...selected.data ? { workspaceId: selected.data } : {} } };
1039
+ },
1040
+ jsonSchema: {
1041
+ ...standard.jsonSchema,
1042
+ input: (options) => (() => {
1043
+ const published = hoistObjectUnionClosure(standard.jsonSchema.input(options));
1044
+ return { ...published, properties: { ...published.properties, workspaceId: z2.toJSONSchema(selector) } };
1045
+ })()
1046
+ }
1047
+ }
1048
+ };
1049
+ }
1050
+
968
1051
  // ../mcp-server/src/batch-workspace.ts
969
- var uuid = z2.string().uuid().describe("UUID of an item visible to the active API key.");
970
- var documentIds = z2.array(uuid).min(1).max(25).refine((ids) => new Set(ids).size === ids.length, "Document IDs must be unique.").describe("One to 25 distinct document UUIDs, explicitly selected by the user; no search expansion.");
1052
+ var uuid = z3.string().uuid().describe("UUID of an item visible to the active API key.");
1053
+ var documentIds = z3.array(uuid).min(1).max(25).refine((ids) => new Set(ids).size === ids.length, "Document IDs must be unique.").describe("One to 25 distinct document UUIDs, explicitly selected by the user; no search expansion.");
971
1054
  var base = { documentIds };
972
- var batchInput = z2.discriminatedUnion("action", [
973
- z2.strictObject({ ...base, action: z2.literal("move").describe("Move each document to the same folder."), folderId: uuid.nullable().describe("Destination folder UUID, or null for no folder.") }),
974
- z2.strictObject({ ...base, action: z2.literal("set_category").describe("Set one explicit category on every document."), categoryId: uuid.nullable().describe("Category UUID, or null to clear explicit category.") }),
975
- z2.strictObject({ ...base, action: z2.literal("add_tag").describe("Assign one existing tag to every document."), tagId: uuid.describe("Existing tag UUID to assign to each document.") }),
976
- z2.strictObject({ ...base, action: z2.literal("remove_tag").describe("Remove one tag assignment from every document."), tagId: uuid.describe("Existing tag UUID to unassign from each document.") }),
977
- z2.strictObject({ ...base, action: z2.literal("trash").describe("Move every document to trash without permanent deletion.") }),
978
- z2.strictObject({ ...base, action: z2.literal("restore").describe("Restore every selected document from trash.") }),
979
- z2.strictObject({ ...base, action: z2.literal("refresh_index").describe("Request explicit indexing retry for every document.") })
1055
+ var batchInput = z3.discriminatedUnion("action", [
1056
+ z3.strictObject({ ...base, action: z3.literal("move").describe("Move each document to the same folder."), folderId: uuid.nullable().describe("Destination folder UUID, or null for no folder.") }),
1057
+ z3.strictObject({ ...base, action: z3.literal("set_category").describe("Set one explicit category on every document."), categoryId: uuid.nullable().describe("Category UUID, or null to clear explicit category.") }),
1058
+ z3.strictObject({ ...base, action: z3.literal("add_tag").describe("Assign one existing tag to every document."), tagId: uuid.describe("Existing tag UUID to assign to each document.") }),
1059
+ z3.strictObject({ ...base, action: z3.literal("remove_tag").describe("Remove one tag assignment from every document."), tagId: uuid.describe("Existing tag UUID to unassign from each document.") }),
1060
+ z3.strictObject({ ...base, action: z3.literal("trash").describe("Move every document to trash without permanent deletion.") }),
1061
+ z3.strictObject({ ...base, action: z3.literal("restore").describe("Restore every selected document from trash.") }),
1062
+ z3.strictObject({ ...base, action: z3.literal("refresh_index").describe("Request explicit indexing retry for every document.") })
980
1063
  ]);
981
1064
  function required(method, name) {
982
1065
  if (!method)
@@ -1031,13 +1114,13 @@ function registerBatchAndWorkspaceCapabilities(server, client2, wrap) {
1031
1114
  }
1032
1115
  server.registerTool("batch_documents", {
1033
1116
  description: "Use for multiple explicitly selected documents that need the same action; for one document prefer the matching single-document tool. Accepts 1\u201325 IDs for automation compatibility. Supports move, set_category, add_tag, remove_tag, trash, restore, or refresh_index. Processes sequentially through the existing API with a permission check per document and a per-ID result; partial success is possible. Stops after authentication or rate-limit failure. Never expands a search result or permanently purges documents; version restore is separate.",
1034
- inputSchema: batchInput,
1117
+ inputSchema: withClientRoutingSchema(batchInput),
1035
1118
  outputSchema: toolOutputSchemas.batch_documents,
1036
1119
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false }
1037
1120
  }, wrap("batch_documents", batch, toolOutputSchemas.batch_documents));
1038
1121
  server.registerTool("get_workspace_item", {
1039
1122
  description: "Read one visible folder, category, or tag by UUID. Folder uses its direct API getter; category and tag lookup uses the complete permission-filtered lists. An absent or out-of-scope ID is reported as not found. Use list_workspace_structure to discover IDs first.",
1040
- inputSchema: z2.strictObject({ kind: z2.enum(["folder", "category", "tag"]).describe("The workspace resource type to read by ID."), id: uuid }),
1123
+ inputSchema: withClientRoutingSchema(z3.strictObject({ kind: z3.enum(["folder", "category", "tag"]).describe("The workspace resource type to read by ID."), id: uuid })),
1041
1124
  outputSchema: toolOutputSchemas.get_workspace_item,
1042
1125
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }
1043
1126
  }, wrap("get_workspace_item", async ({ kind, id }) => {
@@ -1052,10 +1135,10 @@ function registerBatchAndWorkspaceCapabilities(server, client2, wrap) {
1052
1135
  }
1053
1136
 
1054
1137
  // ../mcp-server/src/compact.ts
1055
- var uuid2 = z3.string().uuid().describe("UUID returned by the corresponding list or read operation.");
1056
- var text = z3.string().min(1).describe("Non-empty human-readable name or title.");
1057
- var title = z3.string().min(1).max(500).describe("Document title, from 1 to 500 characters.");
1058
- var content = z3.string().describe("Markdown document content; an empty string clears the content on update.");
1138
+ var uuid2 = z4.string().uuid().describe("UUID returned by the corresponding list or read operation.");
1139
+ var text = z4.string().min(1).describe("Non-empty human-readable name or title.");
1140
+ var title = z4.string().min(1).max(500).describe("Document title, from 1 to 500 characters.");
1141
+ var content = z4.string().describe("Markdown document content; an empty string clears the content on update.");
1059
1142
  var read = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
1060
1143
  var write = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
1061
1144
  var destructive = { ...write, destructiveHint: true };
@@ -1066,16 +1149,16 @@ function required2(value, name) {
1066
1149
  }
1067
1150
  function registerCompactCapabilities(server, client2, wrap) {
1068
1151
  function register(name, description, inputSchema, annotations, handler) {
1069
- server.registerTool(name, { description, inputSchema, outputSchema: toolOutputSchemas[name], annotations }, wrap(name, handler, toolOutputSchemas[name]));
1152
+ server.registerTool(name, { description, inputSchema: withClientRoutingSchema(inputSchema), outputSchema: toolOutputSchemas[name], annotations }, wrap(name, handler, toolOutputSchemas[name]));
1070
1153
  }
1071
- register("find_documents", "Find readable documents in the active scope. Use mode=list for paginated browsing by folder or tag UUID; use mode=search for hybrid text and semantic retrieval with tag names.", z3.discriminatedUnion("mode", [
1072
- z3.strictObject({ mode: z3.literal("list").describe("Select the list operation explicitly."), folderId: uuid2.optional(), tag: uuid2.optional(), page: z3.number().int().min(1).optional().describe("One-based page number; defaults to the API first page."), limit: z3.number().int().min(1).max(1000).optional().describe("Maximum documents per page, up to 1000.") }),
1073
- z3.strictObject({ mode: z3.literal("search").describe("Select the search operation explicitly."), query: text.describe("Text to search in the original language."), folder: z3.string().optional().describe("Optional folder UUID filter for search."), tags: z3.array(z3.string()).optional().describe("Optional tag names; all supplied names must match."), limit: z3.number().int().min(1).max(100).optional().describe("Maximum results to return, up to 100.") })
1154
+ register("find_documents", "Find readable documents in the active scope. Use mode=list for paginated browsing by folder or tag UUID; use mode=search for hybrid text and semantic retrieval with tag names.", z4.discriminatedUnion("mode", [
1155
+ z4.strictObject({ mode: z4.literal("list").describe("Select the list operation explicitly."), folderId: uuid2.optional(), tag: uuid2.optional(), page: z4.number().int().min(1).optional().describe("One-based page number; defaults to the API first page."), limit: z4.number().int().min(1).max(1000).optional().describe("Maximum documents per page, up to 1000.") }),
1156
+ z4.strictObject({ mode: z4.literal("search").describe("Select the search operation explicitly."), query: text.describe("Text to search in the original language."), folder: z4.string().optional().describe("Optional folder UUID filter for search."), tags: z4.array(z4.string()).optional().describe("Optional tag names; all supplied names must match."), limit: z4.number().int().min(1).max(100).optional().describe("Maximum results to return, up to 100.") })
1074
1157
  ]), read, async (input) => input.mode === "list" ? { operation: "list", result: await client2.listDocuments(input) } : { operation: "search", result: await client2.search(input) });
1075
- register("read_document", "Read one document by UUID. Choose detail for content and metadata, markdown for portable export, or versions for saved revisions and snapshots. All views are read-only.", z3.discriminatedUnion("view", [
1076
- z3.strictObject({ view: z3.literal("detail").describe("Select the detail operation explicitly."), id: uuid2 }),
1077
- z3.strictObject({ view: z3.literal("markdown").describe("Select the markdown operation explicitly."), id: uuid2 }),
1078
- z3.strictObject({ view: z3.literal("versions").describe("Select the versions operation explicitly."), id: uuid2, onlySnapshots: z3.boolean().optional().describe("When true, return only named snapshots.") })
1158
+ register("read_document", "Read one document by UUID. Choose detail for content and metadata, markdown for portable export, or versions for saved revisions and snapshots. All views are read-only.", z4.discriminatedUnion("view", [
1159
+ z4.strictObject({ view: z4.literal("detail").describe("Select the detail operation explicitly."), id: uuid2 }),
1160
+ z4.strictObject({ view: z4.literal("markdown").describe("Select the markdown operation explicitly."), id: uuid2 }),
1161
+ z4.strictObject({ view: z4.literal("versions").describe("Select the versions operation explicitly."), id: uuid2, onlySnapshots: z4.boolean().optional().describe("When true, return only named snapshots.") })
1079
1162
  ]), read, async (input) => {
1080
1163
  if (input.view === "detail")
1081
1164
  return { operation: "detail", result: await client2.getDocument(input.id) };
@@ -1083,9 +1166,9 @@ function registerCompactCapabilities(server, client2, wrap) {
1083
1166
  return { operation: "markdown", result: await client2.exportDocument(input.id) };
1084
1167
  return { operation: "versions", result: await client2.getVersionHistory(input.id, input.onlySnapshots) };
1085
1168
  });
1086
- register("save_document", "Create or update one document. Use action=create for a new document or action=update for an existing one; batch_documents handles the same placement change across multiple existing documents. Creation requires write access; content edits require edit access, and placement changes may require write access. Content or placement changes queue normal indexing.", z3.discriminatedUnion("action", [
1087
- z3.strictObject({ action: z3.literal("create").describe("Select the create operation explicitly."), title: title.optional(), content: content.optional(), folderId: uuid2.optional(), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category.") }),
1088
- z3.strictObject({ action: z3.literal("update").describe("Select the update operation explicitly."), id: uuid2, title: title.optional(), content: content.optional(), folderId: uuid2.nullable().optional().describe("Optional folder UUID; null clears the placement on update."), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category.") }).refine((value) => value.title !== undefined || value.content !== undefined || value.folderId !== undefined || value.categoryId !== undefined)
1169
+ register("save_document", "Create or update one document. Use action=create for a new document or action=update for an existing one; batch_documents handles the same placement change across multiple existing documents. Creation requires write access; content edits require edit access, and placement changes may require write access. Content or placement changes queue normal indexing.", z4.discriminatedUnion("action", [
1170
+ z4.strictObject({ action: z4.literal("create").describe("Select the create operation explicitly."), title: title.optional(), content: content.optional(), folderId: uuid2.optional(), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category.") }),
1171
+ z4.strictObject({ action: z4.literal("update").describe("Select the update operation explicitly."), id: uuid2, title: title.optional(), content: content.optional(), folderId: uuid2.nullable().optional().describe("Optional folder UUID; null clears the placement on update."), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category.") }).refine((value) => value.title !== undefined || value.content !== undefined || value.folderId !== undefined || value.categoryId !== undefined)
1089
1172
  ]), destructive, async (input) => {
1090
1173
  if (input.action === "create") {
1091
1174
  const { action: _action2, ...data2 } = input;
@@ -1094,24 +1177,27 @@ function registerCompactCapabilities(server, client2, wrap) {
1094
1177
  const { action: _action, id, ...data } = input;
1095
1178
  return { operation: "update", result: await client2.updateDocument(id, data) };
1096
1179
  });
1097
- register("delete_document", "Move one document to trash without purging content or versions. Use batch_documents(action=trash) for multiple explicit IDs. Requires write access and an explicit delete request; permanently_delete_document is a separate irreversible action.", z3.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1180
+ register("delete_document", "Move one document to trash without purging content or versions. Use batch_documents(action=trash) for multiple explicit IDs. Requires write access and an explicit delete request; permanently_delete_document is a separate irreversible action.", z4.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1098
1181
  await required2(client2.deleteDocument, "delete_document")(id);
1099
1182
  return { id, deleted: true };
1100
1183
  });
1101
- register("list_workspace_structure", "List visible folders, categories, or tags in the active workspace or category scope. Set kind=folders to inspect root folders or children of parentId.", z3.discriminatedUnion("kind", [
1102
- z3.strictObject({ kind: z3.literal("folders").describe("Select the folders operation explicitly."), parentId: uuid2.optional() }),
1103
- z3.strictObject({ kind: z3.literal("categories").describe("Select the categories operation explicitly.") }),
1104
- z3.strictObject({ kind: z3.literal("tags").describe("Select the tags operation explicitly.") })
1184
+ register("list_workspace_structure", "Discover permitted spaces with kind=workspaces, including empty spaces; use returned workspaceId for scoped operations. List folders, categories, or tags; set kind=folders for root folders or children of parentId. Unselected reads cover all granted scopes when supported by the host.", z4.discriminatedUnion("kind", [
1185
+ z4.strictObject({ kind: z4.literal("workspaces").describe("Discover every workspace granted to this connection, including empty ones.") }),
1186
+ z4.strictObject({ kind: z4.literal("folders").describe("Select the folders operation explicitly."), parentId: uuid2.optional() }),
1187
+ z4.strictObject({ kind: z4.literal("categories").describe("Select the categories operation explicitly.") }),
1188
+ z4.strictObject({ kind: z4.literal("tags").describe("Select the tags operation explicitly.") })
1105
1189
  ]), read, async (input) => {
1190
+ if (input.kind === "workspaces")
1191
+ throw new Error("Workspace routing is not configured");
1106
1192
  if (input.kind === "folders")
1107
1193
  return { operation: "folders", result: await client2.listFolders({ parentId: input.parentId }) };
1108
1194
  if (input.kind === "categories")
1109
1195
  return { operation: "categories", result: await client2.listCategories() };
1110
1196
  return { operation: "tags", result: await client2.listTags() };
1111
1197
  });
1112
- register("save_folder", "Create or update a folder. action=update can rename or move an existing folder; the API enforces category boundaries and queues affected documents for reindexing.", z3.discriminatedUnion("action", [
1113
- z3.strictObject({ action: z3.literal("create").describe("Select the create operation explicitly."), name: text.max(255), parentId: uuid2.nullable().optional().describe("Optional parent folder UUID; null selects the root."), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category.") }),
1114
- z3.strictObject({ action: z3.literal("update").describe("Select the update operation explicitly."), id: uuid2, name: text.max(255).optional(), parentId: uuid2.nullable().optional().describe("Optional parent folder UUID; null selects the root."), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category."), order: z3.number().int().nonnegative().optional().describe("New non-negative display order.") }).refine((value) => value.name !== undefined || value.parentId !== undefined || value.categoryId !== undefined || value.order !== undefined)
1198
+ register("save_folder", "Create or update a folder. action=update can rename or move an existing folder; the API enforces category boundaries and queues affected documents for reindexing.", z4.discriminatedUnion("action", [
1199
+ z4.strictObject({ action: z4.literal("create").describe("Select the create operation explicitly."), name: text.max(255), parentId: uuid2.nullable().optional().describe("Optional parent folder UUID; null selects the root."), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category.") }),
1200
+ z4.strictObject({ action: z4.literal("update").describe("Select the update operation explicitly."), id: uuid2, name: text.max(255).optional(), parentId: uuid2.nullable().optional().describe("Optional parent folder UUID; null selects the root."), categoryId: uuid2.nullable().optional().describe("Optional category UUID; null clears the explicit category."), order: z4.number().int().nonnegative().optional().describe("New non-negative display order.") }).refine((value) => value.name !== undefined || value.parentId !== undefined || value.categoryId !== undefined || value.order !== undefined)
1115
1201
  ]), destructive, async (input) => {
1116
1202
  if (input.action === "create") {
1117
1203
  const { action: _action2, ...data2 } = input;
@@ -1120,37 +1206,37 @@ function registerCompactCapabilities(server, client2, wrap) {
1120
1206
  const { action: _action, id, ...data } = input;
1121
1207
  return { operation: "update", result: await required2(client2.updateFolder, "update_folder")(id, data) };
1122
1208
  });
1123
- register("delete_folder", "Delete a folder while preserving its documents; child folders and documents are detached under the API rules. Requires write access.", z3.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1209
+ register("delete_folder", "Delete a folder while preserving its documents; child folders and documents are detached under the API rules. Requires write access.", z4.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1124
1210
  await required2(client2.deleteFolder, "delete_folder")(id);
1125
1211
  return { id, deleted: true };
1126
1212
  });
1127
- register("save_category", "Create or update a workspace category. Full workspace write access is required; category-scoped credentials cannot manage categories.", z3.discriminatedUnion("action", [
1128
- z3.strictObject({ action: z3.literal("create").describe("Select the create operation explicitly."), name: text.max(255) }),
1129
- z3.strictObject({ action: z3.literal("update").describe("Select the update operation explicitly."), id: uuid2, name: text.max(255).optional(), order: z3.number().int().nonnegative().optional().describe("New non-negative display order.") }).refine((value) => value.name !== undefined || value.order !== undefined)
1213
+ register("save_category", "Create or update a workspace category. Full workspace write access is required; category-scoped credentials cannot manage categories.", z4.discriminatedUnion("action", [
1214
+ z4.strictObject({ action: z4.literal("create").describe("Select the create operation explicitly."), name: text.max(255) }),
1215
+ z4.strictObject({ action: z4.literal("update").describe("Select the update operation explicitly."), id: uuid2, name: text.max(255).optional(), order: z4.number().int().nonnegative().optional().describe("New non-negative display order.") }).refine((value) => value.name !== undefined || value.order !== undefined)
1130
1216
  ]), destructive, async (input) => {
1131
1217
  if (input.action === "create")
1132
1218
  return { operation: "create", result: await client2.createCategory({ name: input.name }) };
1133
1219
  const { action: _action, id, ...data } = input;
1134
1220
  return { operation: "update", result: await required2(client2.updateCategory, "update_category")(id, data) };
1135
1221
  });
1136
- register("delete_category", "Delete a workspace category and detach its documents without deleting them. Requires full workspace write access; category-scoped credentials are denied.", z3.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1222
+ register("delete_category", "Delete a workspace category and detach its documents without deleting them. Requires full workspace write access; category-scoped credentials are denied.", z4.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1137
1223
  await required2(client2.deleteCategory, "delete_category")(id);
1138
1224
  return { id, deleted: true };
1139
1225
  });
1140
- register("save_tag", "Create or update a workspace tag. Full workspace write access is required; renaming or recoloring a tag causes affected documents to be reindexed.", z3.discriminatedUnion("action", [
1141
- z3.strictObject({ action: z3.literal("create").describe("Select the create operation explicitly."), name: text.max(100), color: z3.string().max(20).optional().describe("Optional tag color, at most 20 characters.") }),
1142
- z3.strictObject({ action: z3.literal("update").describe("Select the update operation explicitly."), id: uuid2, name: text.max(100).optional(), color: z3.string().max(20).optional().describe("Optional tag color, at most 20 characters.") }).refine((value) => value.name !== undefined || value.color !== undefined)
1226
+ register("save_tag", "Create or update a workspace tag. Full workspace write access is required; renaming or recoloring a tag causes affected documents to be reindexed.", z4.discriminatedUnion("action", [
1227
+ z4.strictObject({ action: z4.literal("create").describe("Select the create operation explicitly."), name: text.max(100), color: z4.string().max(20).optional().describe("Optional tag color, at most 20 characters.") }),
1228
+ z4.strictObject({ action: z4.literal("update").describe("Select the update operation explicitly."), id: uuid2, name: text.max(100).optional(), color: z4.string().max(20).optional().describe("Optional tag color, at most 20 characters.") }).refine((value) => value.name !== undefined || value.color !== undefined)
1143
1229
  ]), destructive, async (input) => {
1144
1230
  if (input.action === "create")
1145
1231
  return { operation: "create", result: await required2(client2.createTag, "create_tag")({ name: input.name, color: input.color }) };
1146
1232
  const { action: _action, id, ...data } = input;
1147
1233
  return { operation: "update", result: await required2(client2.updateTag, "update_tag")(id, data) };
1148
1234
  });
1149
- register("delete_tag", "Delete a workspace tag and remove its document assignments. Full workspace write access is required; documents themselves remain.", z3.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1235
+ register("delete_tag", "Delete a workspace tag and remove its document assignments. Full workspace write access is required; documents themselves remain.", z4.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1150
1236
  await required2(client2.deleteTag, "delete_tag")(id);
1151
1237
  return { id, deleted: true };
1152
1238
  });
1153
- register("set_document_tag", "Add or remove an existing tag assignment on one document. Use batch_documents for the same tag action across multiple explicit IDs. Requires edit access to each document; action=remove preserves the tag itself.", z3.strictObject({ action: z3.enum(["add", "remove"]).describe("Add or remove exactly one tag assignment."), documentId: uuid2, tagId: uuid2 }), destructive, async ({ action, documentId, tagId }) => {
1239
+ register("set_document_tag", "Add or remove an existing tag assignment on one document. Use batch_documents for the same tag action across multiple explicit IDs. Requires edit access to each document; action=remove preserves the tag itself.", z4.strictObject({ action: z4.enum(["add", "remove"]).describe("Add or remove exactly one tag assignment."), documentId: uuid2, tagId: uuid2 }), destructive, async ({ action, documentId, tagId }) => {
1154
1240
  if (action === "add") {
1155
1241
  await required2(client2.addTagToDocument, "add_tag_to_document")(documentId, tagId);
1156
1242
  return { operation: "add", result: { documentId, tagId, assigned: true } };
@@ -1158,17 +1244,17 @@ function registerCompactCapabilities(server, client2, wrap) {
1158
1244
  await required2(client2.removeTagFromDocument, "remove_tag_from_document")(documentId, tagId);
1159
1245
  return { operation: "remove", result: { documentId, tagId, removed: true } };
1160
1246
  });
1161
- register("create_snapshot", "Save a named snapshot of an existing document before a planned change. The snapshot can later be restored with restore_document_version.", z3.strictObject({ documentId: uuid2, label: text.max(200).describe("Snapshot label, from 1 to 200 characters."), description: z3.string().max(1000).optional().describe("Optional snapshot note, at most 1000 characters.") }), write, async ({ documentId, label, description }) => client2.createSnapshot(documentId, { label, description }));
1162
- register("restore_document_version", "Restore content from a version or snapshot listed by read_document(view=versions). This changes current content and queues indexing; it does not restore a trashed document.", z3.strictObject({ documentId: uuid2, versionId: uuid2 }), destructive, async ({ documentId, versionId }) => required2(client2.restoreDocumentVersion, "restore_document_version")(documentId, versionId));
1163
- register("explore_graph", "Explore graph relations from readable seed documents. mode=neighbors traverses one document without a query; mode=search ranks relations from one or more seed IDs with optional query text.", z3.discriminatedUnion("mode", [
1164
- z3.strictObject({ mode: z3.literal("neighbors").describe("Select the neighbors operation explicitly."), documentId: uuid2, limit: z3.number().int().min(1).max(100).optional().describe("Maximum results to return, up to 100.") }),
1165
- z3.strictObject({ mode: z3.literal("search").describe("Select the search operation explicitly."), docIds: z3.array(uuid2).min(1).max(50).describe("One to 50 authorized seed document UUIDs."), query: z3.string().max(2000).optional().describe("Optional graph relevance query, at most 2000 characters."), limit: z3.number().int().min(1).max(100).optional().describe("Maximum results to return, up to 100.") })
1247
+ register("create_snapshot", "Save a named snapshot of an existing document before a planned change. The snapshot can later be restored with restore_document_version.", z4.strictObject({ documentId: uuid2, label: text.max(200).describe("Snapshot label, from 1 to 200 characters."), description: z4.string().max(1000).optional().describe("Optional snapshot note, at most 1000 characters.") }), write, async ({ documentId, label, description }) => client2.createSnapshot(documentId, { label, description }));
1248
+ register("restore_document_version", "Restore content from a version or snapshot listed by read_document(view=versions). This changes current content and queues indexing; it does not restore a trashed document.", z4.strictObject({ documentId: uuid2, versionId: uuid2 }), destructive, async ({ documentId, versionId }) => required2(client2.restoreDocumentVersion, "restore_document_version")(documentId, versionId));
1249
+ register("explore_graph", "Explore graph relations from readable seed documents. mode=neighbors traverses one document without a query; mode=search ranks relations from one or more seed IDs with optional query text.", z4.discriminatedUnion("mode", [
1250
+ z4.strictObject({ mode: z4.literal("neighbors").describe("Select the neighbors operation explicitly."), documentId: uuid2, limit: z4.number().int().min(1).max(100).optional().describe("Maximum results to return, up to 100.") }),
1251
+ z4.strictObject({ mode: z4.literal("search").describe("Select the search operation explicitly."), docIds: z4.array(uuid2).min(1).max(50).describe("One to 50 authorized seed document UUIDs."), query: z4.string().max(2000).optional().describe("Optional graph relevance query, at most 2000 characters."), limit: z4.number().int().min(1).max(100).optional().describe("Maximum results to return, up to 100.") })
1166
1252
  ]), read, async (input) => input.mode === "neighbors" ? { operation: "neighbors", result: await client2.getRelatedDocuments(input.documentId, input.limit) } : { operation: "search", result: await client2.searchGraph(input) });
1167
- register("get_document_index_status", "Read current indexing and pipeline status for one document without starting work. Use refresh_document_index only when an explicit retry is intended.", z3.strictObject({ documentId: uuid2 }), read, async ({ documentId }) => client2.getDocumentIndexStatus(documentId));
1168
- register("refresh_document_index", "Queue an explicit asynchronous reindex for one document; use batch_documents(action=refresh_index) for multiple explicit IDs. Routine content and placement changes already schedule indexing; check get_document_index_status first.", z3.strictObject({ documentId: uuid2 }), write, async ({ documentId }) => client2.refreshDocumentIndex(documentId));
1169
- register("list_trash", "List soft-deleted documents visible to the active workspace or category scope. Requires read access and does not restore or purge anything.", z3.strictObject({}), read, async () => required2(client2.listTrash, "list_trash")());
1170
- register("restore_trashed_document", "Return one document from trash to the active library; use batch_documents(action=restore) for multiple explicit IDs. This restores the document itself, unlike restore_document_version which changes content.", z3.strictObject({ id: uuid2 }), write, async ({ id }) => required2(client2.restoreTrashedDocument, "restore_trashed_document")(id));
1171
- register("permanently_delete_document", "Irreversibly purge a document already in trash, including its version history. Use only on an explicit user request after checking list_trash.", z3.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1253
+ register("get_document_index_status", "Read current indexing and pipeline status for one document without starting work. Use refresh_document_index only when an explicit retry is intended.", z4.strictObject({ documentId: uuid2 }), read, async ({ documentId }) => client2.getDocumentIndexStatus(documentId));
1254
+ register("refresh_document_index", "Queue an explicit asynchronous reindex for one document; use batch_documents(action=refresh_index) for multiple explicit IDs. Routine content and placement changes already schedule indexing; check get_document_index_status first.", z4.strictObject({ documentId: uuid2 }), write, async ({ documentId }) => client2.refreshDocumentIndex(documentId));
1255
+ register("list_trash", "List soft-deleted documents visible to the active workspace or category scope. Requires read access and does not restore or purge anything.", z4.strictObject({}), read, async () => required2(client2.listTrash, "list_trash")());
1256
+ register("restore_trashed_document", "Return one document from trash to the active library; use batch_documents(action=restore) for multiple explicit IDs. This restores the document itself, unlike restore_document_version which changes content.", z4.strictObject({ id: uuid2 }), write, async ({ id }) => required2(client2.restoreTrashedDocument, "restore_trashed_document")(id));
1257
+ register("permanently_delete_document", "Irreversibly purge a document already in trash, including its version history. Use only on an explicit user request after checking list_trash.", z4.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1172
1258
  await required2(client2.permanentlyDeleteDocument, "permanently_delete_document")(id);
1173
1259
  return { id, deleted: true };
1174
1260
  });
@@ -1176,13 +1262,13 @@ function registerCompactCapabilities(server, client2, wrap) {
1176
1262
  }
1177
1263
 
1178
1264
  // ../mcp-server/src/prompts-resources.ts
1179
- import { z as z4 } from "zod";
1265
+ import { z as z5 } from "zod";
1180
1266
  function registerPromptsAndResources(server, client2) {
1181
1267
  server.registerPrompt("organize_workspace", {
1182
1268
  description: "Plan safe document organization using DocsMint categories and folders.",
1183
- argsSchema: z4.object({
1184
- objective: z4.string(),
1185
- language: z4.string().optional()
1269
+ argsSchema: z5.object({
1270
+ objective: z5.string(),
1271
+ language: z5.string().optional()
1186
1272
  })
1187
1273
  }, ({ objective, language }) => ({
1188
1274
  messages: [
@@ -1197,9 +1283,9 @@ function registerPromptsAndResources(server, client2) {
1197
1283
  }));
1198
1284
  server.registerPrompt("research_workspace", {
1199
1285
  description: "Research a question with hybrid search and GraphRAG while citing DocsMint document IDs.",
1200
- argsSchema: z4.object({
1201
- question: z4.string(),
1202
- language: z4.string().optional()
1286
+ argsSchema: z5.object({
1287
+ question: z5.string(),
1288
+ language: z5.string().optional()
1203
1289
  })
1204
1290
  }, ({ question, language }) => ({
1205
1291
  messages: [
@@ -1287,10 +1373,24 @@ var capabilityCatalog = {
1287
1373
  };
1288
1374
 
1289
1375
  // ../mcp-server/src/server.ts
1290
- function wrapHandler(name, handler, outputSchema) {
1376
+ function wrapHandler(name, handler, outputSchema, workspaceRouting) {
1291
1377
  return async (args) => {
1292
1378
  try {
1293
- const output = await handler(args);
1379
+ const { workspaceId, ...data } = args;
1380
+ if (workspaceId !== undefined) {
1381
+ if (!workspaceRouting)
1382
+ throw new Error("Workspace routing is not configured");
1383
+ await workspaceRouting.assertSelection(workspaceId);
1384
+ }
1385
+ let output;
1386
+ if (name === "list_workspace_structure" && data.kind === "workspaces") {
1387
+ if (!workspaceRouting)
1388
+ throw new Error("Workspace routing is not configured");
1389
+ const workspaces = await workspaceRouting.listWorkspaces();
1390
+ output = { operation: "workspaces", result: workspaceId ? workspaces.filter((item) => item.id === workspaceId) : workspaces };
1391
+ } else {
1392
+ output = await handler(data);
1393
+ }
1294
1394
  const parsedOutput = outputSchema ? await outputSchema.safeParseAsync(output) : undefined;
1295
1395
  if (parsedOutput && !parsedOutput.success) {
1296
1396
  throw new Error(`Tool '${name}' returned a result outside its published output schema`);
@@ -1324,18 +1424,20 @@ function wrapHandler(name, handler, outputSchema) {
1324
1424
  }
1325
1425
  };
1326
1426
  }
1327
- function registerDocsmintMcpCapabilities(server, client2) {
1328
- registerCompactCapabilities(server, client2, wrapHandler);
1427
+ function registerDocsmintMcpCapabilities(server, client2, workspaceRouting) {
1428
+ const wrap = (name, handler, outputSchema) => wrapHandler(name, handler, outputSchema, workspaceRouting);
1429
+ registerCompactCapabilities(server, client2, wrap);
1329
1430
  registerPromptsAndResources(server, client2);
1330
1431
  }
1331
1432
  function createDocsmintMcpServer(options = {}) {
1332
- const server = new McpServer({ name: "docsmint", version: "1.0.2" });
1433
+ const server = new McpServer({ name: "docsmint", version: "2.0.2" });
1333
1434
  const client2 = options.docsClient ? createMcpDocsClient(options.docsClient, options.requestContext) : options.client ?? createMcpDocsClient(createDefaultDocsClient(), options.requestContext);
1334
- registerDocsmintMcpCapabilities(server, client2);
1435
+ registerDocsmintMcpCapabilities(server, client2, options.workspaceRouting);
1335
1436
  return server;
1336
1437
  }
1337
1438
  export {
1338
1439
  capabilityCatalog,
1339
1440
  createDocsmintMcpServer,
1441
+ createMcpScopedResult,
1340
1442
  registerDocsmintMcpCapabilities
1341
1443
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hiai-gg/docsmint",
3
3
  "mcpName": "io.github.HiAi-gg/docsmint",
4
- "version": "1.0.2",
4
+ "version": "2.0.2",
5
5
  "type": "module",
6
6
  "browser": {
7
7
  "./dist/backend-launcher.js": false,
@@ -363,10 +363,11 @@
363
363
  "backend/src/lib/lifecycle-service.ts",
364
364
  "server.json",
365
365
  "README.md",
366
- "LICENSE"
366
+ "LICENSE",
367
+ "packages/cli/src/index.ts"
367
368
  ],
368
369
  "engines": {
369
- "bun": ">= 1.3.14"
370
+ "bun": ">= 1.4.0"
370
371
  },
371
372
  "publishConfig": {
372
373
  "access": "public"
@@ -380,19 +381,20 @@
380
381
  "prepublishOnly": "cd packages/sdk && bun run build"
381
382
  },
382
383
  "dependencies": {
383
- "@modelcontextprotocol/server": "2.0.0",
384
+ "@modelcontextprotocol/server": "2.3.0",
384
385
  "bullmq": "^6.3.2",
385
386
  "commander": "^15.0.0",
386
387
  "ioredis": "^6.0.0",
387
- "zod": "4.4.3"
388
+ "zod": "4.6.7",
389
+ "happy-dom": "21.0.4"
388
390
  },
389
391
  "peerDependencies": {
390
392
  "drizzle-orm": "^0.45.2",
391
393
  "postgres": "^3.4.9",
392
394
  "@aws-sdk/client-s3": "^3.1121.0",
393
395
  "pino": "^10.0.0",
394
- "@sveltejs/kit": "^2.70.3",
395
- "svelte": "^5.57.0"
396
+ "@sveltejs/kit": "^3.1.0",
397
+ "svelte": "^5.57.1"
396
398
  },
397
399
  "peerDependenciesMeta": {
398
400
  "drizzle-orm": {
@@ -407,5 +409,12 @@
407
409
  "pino": {
408
410
  "optional": true
409
411
  }
412
+ },
413
+ "overrides": {
414
+ "happy-dom": "21.0.4",
415
+ "@sveltejs/kit": "^3.1.0",
416
+ "svelte": "^5.57.1",
417
+ "@scalar/themes": "0.19.3",
418
+ "@scalar/types": "0.25.0"
410
419
  }
411
420
  }
@@ -25,7 +25,7 @@ import { registerSearch } from './commands/search.js';
25
25
  import { registerSnapshot } from './commands/snapshot.js';
26
26
  import { registerUpdate } from './commands/update.js';
27
27
 
28
- const VERSION = '1.0.2';
28
+ const VERSION = '2.0.2';
29
29
 
30
30
  const program = new Command();
31
31
  program.name('docsmint').description('CLI for the DocsMint knowledge workspace').version(VERSION);
package/server.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "id": "1249550690",
11
11
  "subfolder": "packages/mcp-server"
12
12
  },
13
- "version": "1.0.2",
13
+ "version": "2.0.2",
14
14
  "icons": [
15
15
  {
16
16
  "src": "https://raw.githubusercontent.com/HiAi-gg/docsmint/main/frontend/static/logo-dark.png",
@@ -34,7 +34,7 @@
34
34
  "registryType": "npm",
35
35
  "registryBaseUrl": "https://registry.npmjs.org",
36
36
  "identifier": "@hiai-gg/docsmint",
37
- "version": "1.0.2",
37
+ "version": "2.0.2",
38
38
  "runtimeHint": "npx",
39
39
  "transport": {
40
40
  "type": "stdio"