@hiai-gg/docsmint 2.0.4 → 2.1.1

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 (309) hide show
  1. package/README.md +74 -5
  2. package/dist/backend/index.js +94475 -92073
  3. package/dist/backend-account-runtime-cleanup.js +293 -292
  4. package/dist/backend-api-key-facade.js +6 -5
  5. package/dist/backend-pipeline-cancellation.js +287 -286
  6. package/dist/client.d.ts +33 -7
  7. package/dist/client.js +55 -1
  8. package/dist/frontend/CategoryDialog-CVJi5PJu.js +602 -0
  9. package/dist/frontend/{ConfirmDialog-B1MjKlVQ.js → ConfirmDialog-0JwB8mKN.js} +5 -8
  10. package/dist/frontend/{CreateSnapshotDialog-BTMoPFdj.js → CreateSnapshotDialog-BLrtuYs5.js} +63 -68
  11. package/dist/frontend/{DatePicker-Bmjko3X7.js → DatePicker-BwSb8TRv.js} +17 -29
  12. package/dist/frontend/{DeleteDialog-BkfIeKXO.js → DeleteDialog-s7Dr6bXg.js} +51 -56
  13. package/dist/frontend/{FolderNode-Do8pIfyA.js → FolderNode-Y7cV9xeX.js} +105 -106
  14. package/dist/frontend/{FolderTreeSelector-FyxhcHjr.js → FolderTreeSelector-BR3lYmPU.js} +18 -20
  15. package/dist/frontend/HiAiEditor-BQERr-cd.js +3077 -0
  16. package/dist/frontend/{HiaiDocsExtensionProvider-Cc3yzW5I.js → HiaiDocsExtensionProvider-A2nGddUR.js} +2 -3
  17. package/dist/frontend/{Icon-3EYzvNyk.js → Icon-CiHcxcpv.js} +1 -2
  18. package/dist/frontend/SettingsDialog-BvS74JZu.js +978 -0
  19. package/dist/frontend/{ShareDialog-Ddvl7xvb.js → ShareDialog-Bo50h_Oe.js} +23 -25
  20. package/dist/frontend/Sidebar-i0kbanpg.js +2123 -0
  21. package/dist/frontend/{TagCreateDialog-DQmMJe_E.js → TagCreateDialog-DhKfsfv3.js} +78 -86
  22. package/dist/frontend/action_cancel-BdsWzQKU.js +4 -0
  23. package/dist/frontend/action_close-CVhfLPRQ.js +4 -0
  24. package/dist/frontend/action_create-ByaroO1_.js +4 -0
  25. package/dist/frontend/action_delete-SRloglWY.js +4 -0
  26. package/dist/frontend/action_go_to-DO1bicF-.js +4 -0
  27. package/dist/frontend/action_loading-iQ0KsN6i.js +4 -0
  28. package/dist/frontend/action_save-DeqrZQwV.js +4 -0
  29. package/dist/frontend/api/attachments.js +1 -2
  30. package/dist/frontend/api/categories.js +1 -2
  31. package/dist/frontend/api/documents.js +1 -2
  32. package/dist/frontend/api/folders.js +1 -2
  33. package/dist/frontend/api/settings.js +1 -2
  34. package/dist/frontend/api/share.js +1 -2
  35. package/dist/frontend/api/tags.js +1 -2
  36. package/dist/frontend/{api-keys-DIwAdYkg.js → api-keys-B63imiLr.js} +2 -3
  37. package/dist/frontend/app-shell.js +55 -79
  38. package/dist/frontend/{attachments-C225gTA7.js → attachments-Bfly-sam.js} +2 -3
  39. package/dist/frontend/{auth-client-CXR-7mIO.js → auth-client-Dx7d9Tzo.js} +409 -343
  40. package/dist/frontend/{bundle-mjs-CZ3g1Uzr.js → bundle-mjs-clTO1WW-.js} +5 -23
  41. package/dist/frontend/{camera-DtgHzfVI.js → camera-DsdOPOcD.js} +2 -3
  42. package/dist/frontend/{categories-C8AAkhCR.js → categories-CusvHb5Y.js} +3 -4
  43. package/dist/frontend/{categories_update_error-4aSI8PTr.js → categories_update_error-Cn8DBBHv.js} +2 -3
  44. package/dist/frontend/{check-DVx65aSv.js → check-DiMZRkKS.js} +2 -3
  45. package/dist/frontend/{chevron-down-C2tbZ8Ol.js → chevron-down-CxFrMFDJ.js} +2 -3
  46. package/dist/frontend/{circle-check-BAN-D7yg.js → circle-check-B4F_qgPx.js} +2 -3
  47. package/dist/frontend/{client-GbtOH90i.js → client-BDdDd84W.js} +1 -2
  48. package/dist/frontend/{clipboard-Cgzxc0_R.js → clipboard-Dt1oW6nm.js} +1 -2
  49. package/dist/frontend/{clock-ByiB0SwQ.js → clock-dcpueRk-.js} +2 -3
  50. package/dist/frontend/collaboration.js +6 -12
  51. package/dist/frontend/components/category-dialog.js +1 -2
  52. package/dist/frontend/components/create-snapshot-dialog.js +1 -2
  53. package/dist/frontend/components/delete-dialog.js +1 -2
  54. package/dist/frontend/components/editor/compact-editor.js +2 -3
  55. package/dist/frontend/components/editor/document-editor.js +1 -2
  56. package/dist/frontend/components/editor/document-title.js +3 -4
  57. package/dist/frontend/components/editor/docx-serializer.js +123 -167
  58. package/dist/frontend/components/editor/extensions.js +1 -2
  59. package/dist/frontend/components/editor/markdown-toggle.js +5 -6
  60. package/dist/frontend/components/editor/markdown.js +1 -2
  61. package/dist/frontend/components/folder-node.js +1 -2
  62. package/dist/frontend/components/folder-tree-selector.js +1 -2
  63. package/dist/frontend/components/save-as-dialog.js +86 -90
  64. package/dist/frontend/components/settings.js +1 -2
  65. package/dist/frontend/components/share-dialog.js +1 -2
  66. package/dist/frontend/components/sidebar.js +1 -2
  67. package/dist/frontend/components/tag-create-dialog.js +1 -2
  68. package/dist/frontend/components/version-history.js +177 -180
  69. package/dist/frontend/{context-D0zPFXZ4.js → context-BguSRnCt.js} +1 -2
  70. package/dist/frontend/{copy-CRzvfZGb.js → copy-Bag46YaR.js} +2 -3
  71. package/dist/frontend/dashboard.js +666 -690
  72. package/dist/frontend/{db-Dya0HRhS.js → db-B1ZV452J.js} +22 -39
  73. package/dist/frontend/{dialog-a_ZcpEC5.js → dialog-C0Bpok1d.js} +10 -18
  74. package/dist/frontend/{dist-CcHOStsA.js → dist-BlcV_BOY.js} +2 -3
  75. package/dist/frontend/{dist-qd_OnyUC.js → dist-DjId3RKL.js} +8 -21
  76. package/dist/frontend/dist-Dl9qg10h.js +301 -0
  77. package/dist/frontend/{dndzone-CDhrbpTg.js → dndzone-C62yjeG3.js} +38 -53
  78. package/dist/frontend/doc-tabs.js +1 -2
  79. package/dist/frontend/doc_title_label-BOuZzvqv.js +4 -0
  80. package/dist/frontend/doc_title_placeholder-ZxpdWWEn.js +4 -0
  81. package/dist/frontend/{document-drop-coordinator-Da7HcXgv.js → document-drop-coordinator-C_o93kKW.js} +3 -4
  82. package/dist/frontend/document-drop-coordinator.js +1 -2
  83. package/dist/frontend/{documents-CwCs1rA7.js → documents-CDJb8dv-.js} +4 -8
  84. package/dist/frontend/{dropdown-menu-DrHYReIC.js → dropdown-menu-B3nk2aM-.js} +13 -24
  85. package/dist/frontend/{editor-content-sanitizer-CWjqiz0T.js → editor-content-sanitizer-5MjSVPVn.js} +1 -2
  86. package/dist/frontend/editor-preferences.js +1 -2
  87. package/dist/frontend/{editor-preferences.svelte-Bt_A9k7n.js → editor-preferences.svelte-BpTE4mbz.js} +3 -5
  88. package/dist/frontend/{editorExtensions-DPR-CjMu.js → editorExtensions-DbiFj4tn.js} +3 -4
  89. package/dist/frontend/{editor_markdown_placeholder-BIWDUF1E.js → editor_markdown_placeholder-BztIY9Ci.js} +2 -3
  90. package/dist/frontend/{ellipsis-vertical-qxNgoXu-.js → ellipsis-vertical-Oymsv1R4.js} +2 -3
  91. package/dist/frontend/{error_dismiss-Dx_JbRjs.js → error_dismiss-C651ZdWI.js} +2 -3
  92. package/dist/frontend/error_generic-BlWqOE-a.js +4 -0
  93. package/dist/frontend/extension.js +1 -2
  94. package/dist/frontend/{folder-D74E-Kdp.js → folder-BpmB_sAy.js} +3 -5
  95. package/dist/frontend/folder-refresh.js +1 -2
  96. package/dist/frontend/{folders-CC0UWkZH.js → folders-DgKSovXa.js} +2 -3
  97. package/dist/frontend/{folders_rename-BJo4Gipq.js → folders_rename-Cxbg5GIw.js} +2 -3
  98. package/dist/frontend/frontend.css +1 -1
  99. package/dist/frontend/i18n.js +144 -145
  100. package/dist/frontend/{identity-BOA7Jejv.js → identity-B7HeOzDJ.js} +4 -5
  101. package/dist/frontend/{input-Q_7qCfnU.js → input-CbeB9220.js} +2 -3
  102. package/dist/frontend/keyboard.js +1 -2
  103. package/dist/frontend/{keyboard.svelte-CApmX0vl.js → keyboard.svelte-BBUdhTsM.js} +2 -3
  104. package/dist/frontend/{label-Dj8FDEhf.js → label-CfBWf3gI.js} +2 -3
  105. package/dist/frontend/{lib-aUbBbIW2.js → lib-CITdCbKa.js} +176 -365
  106. package/dist/frontend/{loader-circle-D3t5NkvC.js → loader-circle-skKwfRCB.js} +2 -3
  107. package/dist/frontend/markdown-6E9TWC6V.js +11 -0
  108. package/dist/frontend/offline/identity.js +1 -2
  109. package/dist/frontend/{popper-layer-force-mount-CNtiLgbV.js → popper-layer-force-mount-BG0eyrCk.js} +112 -284
  110. package/dist/frontend/{resolve-BG4HgzpN.js → resolve-DbT-KhGZ.js} +2 -3
  111. package/dist/frontend/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-CwxnZyOB.js} +2 -3
  112. package/dist/frontend/{rotate-ccw-B1ybQ8oQ.js → rotate-ccw-DAUX7np7.js} +2 -3
  113. package/dist/frontend/{route-context-DYQlUfzL.js → route-context-6OHiGtfb.js} +2 -4
  114. package/dist/frontend/{runtime-CwWSo6c9.js → runtime-CGUiMzK6.js} +1 -2
  115. package/dist/frontend/{schemas-1Na35n71.js → schemas-YXxhj5o8.js} +850 -880
  116. package/dist/frontend/scroll_to_top_aria-lJc2RSx_.js +4 -0
  117. package/dist/frontend/{search-preferences-B1GdbdUc.js → search-preferences-DuLDczRu.js} +1 -2
  118. package/dist/frontend/search.js +277 -292
  119. package/dist/frontend/{search_title-DOC0cPlQ.js → search_title-BETwQYJq.js} +2 -3
  120. package/dist/frontend/{select-value-BkI1W1bn.js → select-value-BY5Hw6Rl.js} +28 -65
  121. package/dist/frontend/{settings-BRcYFQa_.js → settings-DyePuqjp.js} +3 -4
  122. package/dist/frontend/{share-D5yo0JOh.js → share-3gWTTYvH.js} +2 -3
  123. package/dist/frontend/{share-context-BJ4GF4yT.js → share-context-C2xyVP9M.js} +29 -37
  124. package/dist/frontend/{share_copied-DPxVzfWh.js → share_copied-BuAnmpbz.js} +2 -3
  125. package/dist/frontend/{share_toggle_password-DdxfIjj1.js → share_toggle_password-LEYUeHWr.js} +2 -3
  126. package/dist/frontend/shared-document.js +27 -36
  127. package/dist/frontend/{sidebar_uncategorized-qJ2_Aonf.js → sidebar_uncategorized-C5PGOflV.js} +2 -3
  128. package/dist/frontend/{sort_relevance-DwYX5MO9.js → sort_relevance-DpCVLby_.js} +2 -3
  129. package/dist/frontend/{subfolders-refresh-store.svelte-DxP21a1c.js → subfolders-refresh-store.svelte-CeyqvNpu.js} +1 -2
  130. package/dist/frontend/{tag-qbTBLj-g.js → tag-Wdfe0rKU.js} +3 -5
  131. package/dist/frontend/{tag-store.svelte-ogVCMCbv.js → tag-store.svelte-C9VYWqLQ.js} +2 -3
  132. package/dist/frontend/{tags-CF_cqzSV.js → tags-DlDVothf.js} +3 -4
  133. package/dist/frontend/{tags_load_error-BKjA1pI0.js → tags_load_error-BINNpPPV.js} +2 -3
  134. package/dist/frontend/{tags_new-BiNAJ9Bx.js → tags_new-Dw0Uy43-.js} +2 -3
  135. package/dist/frontend/{textarea-BNK0LFUK.js → textarea-D6emvAwM.js} +2 -3
  136. package/dist/frontend/theme.js +2 -3
  137. package/dist/frontend/{theme.svelte-BRdxXd-B.js → theme.svelte-BiXvrqwh.js} +7 -23
  138. package/dist/frontend/{theme_system-BBNUhYKh.js → theme_system-YIfa_2Xt.js} +2 -3
  139. package/dist/frontend/utils/clipboard.js +1 -2
  140. package/dist/frontend/utils/dndzone.js +1 -2
  141. package/dist/frontend/{utils-BovMJHdA.js → utils-CnAmIMwr.js} +2 -3
  142. package/dist/frontend/utils-DH0uqK40.js +6 -0
  143. package/dist/frontend/utils.js +1 -2
  144. package/dist/frontend/version_create_snapshot-D8xjbuCq.js +4 -0
  145. package/dist/frontend/{version_restored_from-dVRN3Zdk.js → version_restored_from-DYFFSuQj.js} +2 -3
  146. package/dist/frontend/{version_snapshot_label_placeholder-DrMikux0.js → version_snapshot_label_placeholder-BhKq1NQ7.js} +2 -3
  147. package/dist/frontend/{weekday_we-C5H_M-df.js → weekday_we-BxbzNVWR.js} +2 -3
  148. package/dist/frontend/{x-CvSSnrjl.js → x-CBUgPygC.js} +2 -3
  149. package/dist/frontend/{yjs-VUcKqaKW.js → yjs-BbwnvxgY.js} +9 -23
  150. package/dist/frontend-ssr/api/attachments.js +2 -3
  151. package/dist/frontend-ssr/api/categories.js +1 -2
  152. package/dist/frontend-ssr/api/documents.js +1 -2
  153. package/dist/frontend-ssr/api/folders.js +1 -2
  154. package/dist/frontend-ssr/api/settings.js +1 -2
  155. package/dist/frontend-ssr/api/share.js +2 -3
  156. package/dist/frontend-ssr/api/tags.js +1 -2
  157. package/dist/frontend-ssr/app-shell.js +19 -28
  158. package/dist/frontend-ssr/assets/{CategoryDialog-DuZLLlt7.js → CategoryDialog-2CCX508O.js} +17 -20
  159. package/dist/frontend-ssr/assets/{ConfirmDialog-0WVu9BCE.js → ConfirmDialog-Cc6lcY1N.js} +8 -14
  160. package/dist/frontend-ssr/assets/{CreateSnapshotDialog-3vhDTFNu.js → CreateSnapshotDialog-BB8fXF9W.js} +9 -10
  161. package/dist/frontend-ssr/assets/{DatePicker-t12leL2Y.js → DatePicker-CfzKzipR.js} +9 -15
  162. package/dist/frontend-ssr/assets/{DeleteDialog-B0AU1fJR.js → DeleteDialog-DRU4UgOW.js} +4 -5
  163. package/dist/frontend-ssr/assets/{FolderNode-C-B-s8x1.js → FolderNode-Dg_5-orQ.js} +11 -12
  164. package/dist/frontend-ssr/assets/{FolderTreeSelector-DdQuEcj0.js → FolderTreeSelector-D0reTdFS.js} +5 -7
  165. package/dist/frontend-ssr/assets/{HiAiEditor-Bj6tiE97.js → HiAiEditor-DeHWAIj-.js} +44 -69
  166. package/dist/frontend-ssr/assets/{HiaiDocsExtensionProvider-BRKWmcDd.js → HiaiDocsExtensionProvider-D6cGL-9s.js} +2 -3
  167. package/dist/frontend-ssr/assets/{Icon-DE_3EnuF.js → Icon-CrIRbT5O.js} +4 -8
  168. package/dist/frontend-ssr/assets/{SettingsDialog-h4SFwpUa.js → SettingsDialog-BpHY3IMb.js} +29 -40
  169. package/dist/frontend-ssr/assets/{ShareDialog-CpE9zd_f.js → ShareDialog-CY40nWZJ.js} +7 -9
  170. package/dist/frontend-ssr/assets/{Sidebar-BFBpsd3L.js → Sidebar-fpYk5MGO.js} +55 -63
  171. package/dist/frontend-ssr/assets/{TagCreateDialog-DBHO1DPU.js → TagCreateDialog-C2tpdEuj.js} +13 -14
  172. package/dist/frontend-ssr/assets/{action_cancel-OVgQDP5Q.js → action_cancel-CsBbxW0m.js} +2 -3
  173. package/dist/frontend-ssr/assets/{action_close-DagDyMXk.js → action_close-lFKBqBwg.js} +2 -3
  174. package/dist/frontend-ssr/assets/{action_create-hqJWjyqh.js → action_create-BV4ZOcQW.js} +2 -3
  175. package/dist/frontend-ssr/assets/{action_delete-B1-16jSo.js → action_delete-CNmRhKQP.js} +2 -3
  176. package/dist/frontend-ssr/assets/{action_go_to-DQScgw7P.js → action_go_to-tN5I26xM.js} +2 -3
  177. package/dist/frontend-ssr/assets/{action_save-Bx7vlLZI.js → action_save-YCfMiKb4.js} +2 -3
  178. package/dist/frontend-ssr/assets/{api-keys-CHOrbU-Q.js → api-keys-G6oimJIv.js} +2 -3
  179. package/dist/frontend-ssr/assets/{auth-client-BC4hSFKF.js → auth-client-BnnnJDAb.js} +368 -256
  180. package/dist/frontend-ssr/assets/{camera-B6ldo_Js.js → camera-OYNSMvMd.js} +2 -3
  181. package/dist/frontend-ssr/assets/{categories-C_dxFoHi.js → categories-bBPviKjl.js} +2 -3
  182. package/dist/frontend-ssr/assets/{categories_update_error-DkKgsqdD.js → categories_update_error-Bfx5vtvt.js} +11 -21
  183. package/dist/frontend-ssr/assets/{chevron-down-DQcr6JUc.js → chevron-down-DB6YsSbQ.js} +2 -3
  184. package/dist/frontend-ssr/assets/{chevron-right-9szrliZx.js → chevron-right-DOt2uY6b.js} +2 -3
  185. package/dist/frontend-ssr/assets/{circle-check-BgP9MRRv.js → circle-check-DQhTm9YR.js} +2 -3
  186. package/dist/frontend-ssr/assets/{client-rfwQYYHY.js → client-B2AniXwV.js} +1 -2
  187. package/dist/frontend-ssr/assets/{clipboard-CXOaoz2W.js → clipboard-CXKnyYba.js} +1 -2
  188. package/dist/frontend-ssr/assets/{clock-roNtGlT6.js → clock-B08dVWtf.js} +2 -3
  189. package/dist/frontend-ssr/assets/{context-Bi_mO-NS.js → context-C_xxvxnR.js} +1 -2
  190. package/dist/frontend-ssr/assets/{copy-BYqYnBIQ.js → copy-2jsznHar.js} +2 -3
  191. package/dist/frontend-ssr/assets/{db-C3rFdTZa.js → db-BEKLU5Fc.js} +2 -3
  192. package/dist/frontend-ssr/assets/{dialog-SqCnTT43.js → dialog-C6U-DqLr.js} +9 -17
  193. package/dist/frontend-ssr/assets/{dist-CaZQ1FhA.js → dist-DqXTz_zE.js} +9 -12
  194. package/dist/frontend-ssr/assets/{dist-CqxHwOlp.js → dist-ip9bPdma.js} +3 -6
  195. package/dist/frontend-ssr/assets/{dndzone-CnTCMhPd.js → dndzone-Dx3jt_e4.js} +4 -6
  196. package/dist/frontend-ssr/assets/{doc_title_label-Ev_ltlh3.js → doc_title_label-CE_l-Gum.js} +2 -3
  197. package/dist/frontend-ssr/assets/{doc_title_placeholder-DSHpUb7w.js → doc_title_placeholder-7_i7PtG6.js} +2 -3
  198. package/dist/frontend-ssr/assets/{document-drop-coordinator-CEaYACsC.js → document-drop-coordinator-BVytYy2K.js} +1 -2
  199. package/dist/frontend-ssr/assets/{documents-CEuA1V6N.js → documents-B_wpQFTh.js} +2 -3
  200. package/dist/frontend-ssr/assets/{dropdown-menu-CE6U0f1b.js → dropdown-menu-BS5fcN9l.js} +12 -23
  201. package/dist/frontend-ssr/assets/{editor-content-sanitizer-Gjm93iR-.js → editor-content-sanitizer-CIdFjBSC.js} +1 -2
  202. package/dist/frontend-ssr/assets/{editor-preferences.svelte-iI5jJM1x.js → editor-preferences.svelte-CdAXTd-I.js} +2 -4
  203. package/dist/frontend-ssr/assets/{editorExtensions-rhletNji.js → editorExtensions-2O7O2Nhv.js} +2 -3
  204. package/dist/frontend-ssr/assets/{editor_markdown_placeholder-BpezdkOr.js → editor_markdown_placeholder-CAeLJjFT.js} +3 -5
  205. package/dist/frontend-ssr/assets/{editor_toolbar_undo-CKJAOqv2.js → editor_toolbar_undo-CVCfQIS1.js} +29 -57
  206. package/dist/frontend-ssr/assets/{ellipsis-vertical-Cg1MrZsl.js → ellipsis-vertical-IFHt2NM1.js} +2 -3
  207. package/dist/frontend-ssr/assets/{error_generic-DTK0kwxT.js → error_generic-BB80i0Vk.js} +3 -5
  208. package/dist/frontend-ssr/assets/{folder-DHB-CEcQ.js → folder-CXa1_bm5.js} +2 -3
  209. package/dist/frontend-ssr/assets/{folders-BOXeb9hz.js → folders-CTLqWbMm.js} +2 -3
  210. package/dist/frontend-ssr/assets/{folders_rename-DvciOb6K.js → folders_rename-ydbfwQlj.js} +7 -13
  211. package/dist/frontend-ssr/assets/{identity-DNIo1bgc.js → identity-DTz1SQwC.js} +2 -3
  212. package/dist/frontend-ssr/assets/{input-DVrBVPgs.js → input-Bxw9sFF0.js} +2 -3
  213. package/dist/frontend-ssr/assets/{keyboard.svelte-BgF47N3L.js → keyboard.svelte-njehUCm3.js} +1 -2
  214. package/dist/frontend-ssr/assets/{label-vtCK3pTp.js → label-CMWedjs6.js} +2 -3
  215. package/dist/frontend-ssr/assets/{loader-circle-D3NWhCif.js → loader-circle-zbKj9Qb-.js} +2 -3
  216. package/dist/frontend-ssr/assets/{markdown-Co31-Tl2.js → markdown-BmIhDQp7.js} +2 -3
  217. package/dist/frontend-ssr/assets/{popper-layer-force-mount-C4dMMt-f.js → popper-layer-force-mount-CSHZsG2E.js} +78 -156
  218. package/dist/frontend-ssr/assets/{resolve-BqHozBXl.js → resolve-Wqdff4CL.js} +1 -2
  219. package/dist/frontend-ssr/assets/{rotate-ccw-DNf3nwMD.js → rotate-ccw-B7SaTFWf.js} +2 -3
  220. package/dist/frontend-ssr/assets/{route-context-BPRerEtZ.js → route-context-BsqLFt5Y.js} +2 -4
  221. package/dist/frontend-ssr/assets/{runtime-O78RzRqx.js → runtime-BX6-jTn_.js} +1 -2
  222. package/dist/frontend-ssr/assets/{scroll_to_top_aria-BN4ZfOnM.js → scroll_to_top_aria-CAYSiGHO.js} +2 -3
  223. package/dist/frontend-ssr/assets/{search_title-CKUsQDT0.js → search_title-C7NVXXq3.js} +2 -3
  224. package/dist/frontend-ssr/assets/{search_toggle_filters-hS9rvQhC.js → search_toggle_filters-Bq_YVD8s.js} +15 -29
  225. package/dist/frontend-ssr/assets/{select-value-Ce5c_fuA.js → select-value-TgslfiUB.js} +18 -34
  226. package/dist/frontend-ssr/assets/{settings-DWCpfCPj.js → settings-B1MA_FjO.js} +3 -4
  227. package/dist/frontend-ssr/assets/{share-context-B4UpvTSw.js → share-context-RVh8AExX.js} +17 -22
  228. package/dist/frontend-ssr/assets/{share_copied-BxU9rjXG.js → share_copied-CrwEwkb3.js} +31 -61
  229. package/dist/frontend-ssr/assets/{share_toggle_password-C6OmroqR.js → share_toggle_password-Co56z0Ha.js} +11 -21
  230. package/dist/frontend-ssr/assets/{sidebar_uncategorized-Dx-LTd5w.js → sidebar_uncategorized-COWdmZ3d.js} +6 -11
  231. package/dist/frontend-ssr/assets/{subfolders-refresh-store.svelte-CXHxQWKh.js → subfolders-refresh-store.svelte-LxG18U0n.js} +1 -2
  232. package/dist/frontend-ssr/assets/{tag-Cqv0fWVG.js → tag-BGhtDKpP.js} +3 -5
  233. package/dist/frontend-ssr/assets/{tag-store.svelte-QRysvGKe.js → tag-store.svelte-CUUgAaDD.js} +2 -3
  234. package/dist/frontend-ssr/assets/{tags-BBCoFYro.js → tags-C7u-LBsl.js} +2 -3
  235. package/dist/frontend-ssr/assets/{tags_load_error-CPrc6Gzs.js → tags_load_error-DW4FbHvr.js} +19 -37
  236. package/dist/frontend-ssr/assets/{tags_new-VmMr9v2V.js → tags_new-Dr3ByMPZ.js} +4 -7
  237. package/dist/frontend-ssr/assets/{textarea-BdjOJJVb.js → textarea-Bz5Tz4rw.js} +2 -3
  238. package/dist/frontend-ssr/assets/{theme.svelte-D6bbaJ9m.js → theme.svelte-CdHah46l.js} +3 -5
  239. package/dist/frontend-ssr/assets/{theme_system-BucaNntV.js → theme_system-E97FASeq.js} +19 -37
  240. package/dist/frontend-ssr/assets/{utils-DvZnctjz.js → utils-085zSPe5.js} +1 -2
  241. package/dist/frontend-ssr/assets/{utils-D3X7I8nz.js → utils-DF6CmRDX.js} +1 -2
  242. package/dist/frontend-ssr/assets/{version_create_snapshot-COHzwjle.js → version_create_snapshot-DeeYB7bb.js} +2 -3
  243. package/dist/frontend-ssr/assets/{version_restored_from-CertjFDl.js → version_restored_from-CTt2LM4A.js} +13 -25
  244. package/dist/frontend-ssr/assets/{version_snapshot_label_placeholder-Cy_rMCij.js → version_snapshot_label_placeholder-BbGD9YuN.js} +12 -23
  245. package/dist/frontend-ssr/assets/{weekday_we-DrI3U230.js → weekday_we-BzGQ-iFc.js} +22 -43
  246. package/dist/frontend-ssr/collaboration.js +2 -4
  247. package/dist/frontend-ssr/components/category-dialog.js +1 -2
  248. package/dist/frontend-ssr/components/create-snapshot-dialog.js +1 -2
  249. package/dist/frontend-ssr/components/delete-dialog.js +1 -2
  250. package/dist/frontend-ssr/components/editor/compact-editor.js +2 -3
  251. package/dist/frontend-ssr/components/editor/document-editor.js +1 -2
  252. package/dist/frontend-ssr/components/editor/document-title.js +3 -4
  253. package/dist/frontend-ssr/components/editor/docx-serializer.js +1 -2
  254. package/dist/frontend-ssr/components/editor/extensions.js +1 -2
  255. package/dist/frontend-ssr/components/editor/markdown-toggle.js +4 -5
  256. package/dist/frontend-ssr/components/editor/markdown.js +1 -2
  257. package/dist/frontend-ssr/components/folder-node.js +1 -2
  258. package/dist/frontend-ssr/components/folder-tree-selector.js +1 -2
  259. package/dist/frontend-ssr/components/save-as-dialog.js +12 -13
  260. package/dist/frontend-ssr/components/settings.js +1 -2
  261. package/dist/frontend-ssr/components/share-dialog.js +1 -2
  262. package/dist/frontend-ssr/components/sidebar.js +1 -2
  263. package/dist/frontend-ssr/components/tag-create-dialog.js +1 -2
  264. package/dist/frontend-ssr/components/version-history.js +18 -21
  265. package/dist/frontend-ssr/dashboard.js +64 -88
  266. package/dist/frontend-ssr/doc-tabs.js +1 -2
  267. package/dist/frontend-ssr/document-drop-coordinator.js +1 -2
  268. package/dist/frontend-ssr/editor-preferences.js +1 -2
  269. package/dist/frontend-ssr/extension.js +1 -2
  270. package/dist/frontend-ssr/folder-refresh.js +1 -2
  271. package/dist/frontend-ssr/i18n.js +315 -603
  272. package/dist/frontend-ssr/keyboard.js +1 -2
  273. package/dist/frontend-ssr/offline/identity.js +1 -2
  274. package/dist/frontend-ssr/search.js +17 -20
  275. package/dist/frontend-ssr/shared-document.js +5 -8
  276. package/dist/frontend-ssr/theme.js +2 -3
  277. package/dist/frontend-ssr/utils/clipboard.js +1 -2
  278. package/dist/frontend-ssr/utils/dndzone.js +1 -2
  279. package/dist/frontend-ssr/utils.js +1 -2
  280. package/dist/index.d.ts +1 -1
  281. package/dist/index.js +1 -1
  282. package/dist/lifecycle-runtime.js +3998 -17872
  283. package/dist/mcp-cli.js +357 -78
  284. package/dist/mcp-server.d.ts +92 -23
  285. package/dist/mcp-server.js +525 -78
  286. package/dist/types.d.ts +68 -1
  287. package/package.json +5 -5
  288. package/packages/cli/src/index.ts +1 -1
  289. package/packages/db/src/schema.ts +3 -1
  290. package/server.json +2 -2
  291. package/dist/frontend/CategoryDialog-CJeAYxcd.js +0 -630
  292. package/dist/frontend/HiAiEditor-DDpfdQEg.js +0 -3129
  293. package/dist/frontend/SettingsDialog-DzlYW50I.js +0 -991
  294. package/dist/frontend/Sidebar-rFiVen96.js +0 -2149
  295. package/dist/frontend/action_cancel-Cuxsznzz.js +0 -5
  296. package/dist/frontend/action_close-BJm_52wm.js +0 -5
  297. package/dist/frontend/action_create-CtBQrRuj.js +0 -5
  298. package/dist/frontend/action_delete-BXBIzvn0.js +0 -5
  299. package/dist/frontend/action_go_to-VmK5jmEk.js +0 -5
  300. package/dist/frontend/action_loading-BLCGJVA9.js +0 -5
  301. package/dist/frontend/action_save-BRN2Z_GP.js +0 -5
  302. package/dist/frontend/dist-DcHl92QO.js +0 -316
  303. package/dist/frontend/doc_title_label-DS9jSIh2.js +0 -5
  304. package/dist/frontend/doc_title_placeholder-DBQpM1aH.js +0 -5
  305. package/dist/frontend/error_generic-CzNtmBT4.js +0 -5
  306. package/dist/frontend/markdown-O9YJA70S.js +0 -12
  307. package/dist/frontend/scroll_to_top_aria-CvkNF_Hu.js +0 -5
  308. package/dist/frontend/utils-BlHvR6OL.js +0 -7
  309. package/dist/frontend/version_create_snapshot-3bu-0qzH.js +0 -5
@@ -1,6 +1,188 @@
1
1
  // @bun
2
- // ../mcp-server/src/server.ts
3
- import { McpServer } from "@modelcontextprotocol/server";
2
+ // ../mcp-server/src/argument-diagnostics.ts
3
+ import {
4
+ McpServer
5
+ } from "@modelcontextprotocol/server";
6
+ var contracts = new WeakMap;
7
+ function object(value) {
8
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
9
+ }
10
+ function captureMcpInputSchema(server, name, schema) {
11
+ let registered = contracts.get(server);
12
+ if (!registered) {
13
+ registered = new Map;
14
+ contracts.set(server, registered);
15
+ }
16
+ registered.set(name, {
17
+ validate: (value) => schema["~standard"].validate(value, undefined),
18
+ jsonSchema: () => schema["~standard"].jsonSchema.input({ target: "draft-2020-12" })
19
+ });
20
+ return schema;
21
+ }
22
+ var codes = new Set([
23
+ "invalid_type",
24
+ "too_big",
25
+ "too_small",
26
+ "invalid_format",
27
+ "not_multiple_of",
28
+ "unrecognized_keys",
29
+ "invalid_union",
30
+ "invalid_key",
31
+ "invalid_element",
32
+ "invalid_value",
33
+ "custom"
34
+ ]);
35
+ function diagnostics(tool, input, schemaValue, issues) {
36
+ const schema = object(schemaValue) ?? {};
37
+ const branches = Array.isArray(schema.oneOf) ? schema.oneOf.map((item) => object(item) ?? {}) : [schema];
38
+ const knownFields = new Set;
39
+ function fields(value) {
40
+ const item = object(value);
41
+ if (!item)
42
+ return;
43
+ for (const [name, child] of Object.entries(object(item.properties) ?? {})) {
44
+ knownFields.add(name);
45
+ fields(child);
46
+ }
47
+ if (item.items)
48
+ fields(item.items);
49
+ for (const key of ["oneOf", "anyOf", "allOf"])
50
+ if (Array.isArray(item[key]))
51
+ for (const child of item[key])
52
+ fields(child);
53
+ }
54
+ fields(schema);
55
+ const args = object(input) ?? {};
56
+ const selector = ["mode", "action", "view", "kind"].find((key) => branches.some((branch) => {
57
+ const property = object(object(branch.properties)?.[key]);
58
+ return property && (typeof property.const === "string" || Array.isArray(property.enum));
59
+ }));
60
+ const variants = branches.map((branch) => {
61
+ const property = selector ? object(object(branch.properties)?.[selector]) : undefined;
62
+ const values = property && typeof property.const === "string" ? [property.const] : Array.isArray(property?.enum) ? property.enum.filter((value) => typeof value === "string") : [];
63
+ return {
64
+ values,
65
+ required: Array.isArray(branch.required) ? branch.required.filter((value) => typeof value === "string" && knownFields.has(value)) : []
66
+ };
67
+ });
68
+ const selected = selector ? args[selector] : undefined;
69
+ const branch = typeof selected === "string" && variants.some((variant) => variant.values.includes(selected)) ? selected : null;
70
+ return {
71
+ tool,
72
+ branch,
73
+ expectedArgs: variants.map((variant) => ({
74
+ branches: variant.values,
75
+ required: variant.required
76
+ })),
77
+ issues: issues.slice(0, 32).map((value) => {
78
+ const issue = object(value) ?? {};
79
+ const path = Array.isArray(issue.path) ? issue.path.map((part) => object(part)?.key ?? part).filter((part) => typeof part === "string" ? knownFields.has(part) : typeof part === "number" && Number.isInteger(part) && part >= 0 && part < 1e4) : [];
80
+ return {
81
+ path,
82
+ code: typeof issue.code === "string" && codes.has(issue.code) ? issue.code : "invalid_argument"
83
+ };
84
+ })
85
+ };
86
+ }
87
+ function decorateMcpArgumentTransport(transport, server) {
88
+ const pending = new Map;
89
+ let closed = false;
90
+ let overflowed = false;
91
+ function remember(message) {
92
+ if (closed || overflowed)
93
+ return;
94
+ if (!("method" in message) || !("id" in message) || typeof message.id !== "string" && typeof message.id !== "number")
95
+ return;
96
+ const previous = pending.get(message.id);
97
+ if (previous) {
98
+ previous.count++;
99
+ previous.ambiguous = true;
100
+ previous.candidate = undefined;
101
+ return;
102
+ }
103
+ if (pending.size >= 1024) {
104
+ overflowed = true;
105
+ pending.clear();
106
+ return;
107
+ }
108
+ const params = "params" in message ? object(message.params) : undefined;
109
+ const name = params?.name;
110
+ const contract = message.method === "tools/call" && typeof name === "string" ? contracts.get(server)?.get(name) : undefined;
111
+ pending.set(message.id, {
112
+ count: 1,
113
+ ambiguous: false,
114
+ ...contract && typeof name === "string" ? { candidate: { tool: name, args: params?.arguments ?? {}, contract } } : {}
115
+ });
116
+ }
117
+ async function send(message, options) {
118
+ const id = "id" in message && (typeof message.id === "string" || typeof message.id === "number") && !("method" in message) ? message.id : undefined;
119
+ const entry = id === undefined ? undefined : pending.get(id);
120
+ let outgoing = message;
121
+ try {
122
+ const candidate = entry && !entry.ambiguous ? entry.candidate : undefined;
123
+ const result = "result" in message ? object(message.result) : undefined;
124
+ const block = result && Array.isArray(result.content) && result.content.length === 1 ? object(result.content[0]) : undefined;
125
+ if (id !== undefined && candidate && result?.isError === true && Object.keys(result).length === 2 && block?.type === "text" && Object.keys(block).length === 2 && typeof block.text === "string" && block.text.startsWith(`Input validation error: Invalid arguments for tool ${candidate.tool}:`)) {
126
+ try {
127
+ const validation = object(await candidate.contract.validate(candidate.args));
128
+ if (Array.isArray(validation?.issues) && validation.issues.length && !entry?.ambiguous && pending.get(id) === entry) {
129
+ const data = diagnostics(candidate.tool, candidate.args, candidate.contract.jsonSchema(), validation.issues);
130
+ outgoing = {
131
+ jsonrpc: "2.0",
132
+ id,
133
+ error: { code: -32602, message: "Invalid tool arguments", data }
134
+ };
135
+ }
136
+ } catch {}
137
+ }
138
+ await transport.send(outgoing, options);
139
+ } finally {
140
+ if (id !== undefined && entry && pending.get(id) === entry && --entry.count === 0)
141
+ pending.delete(id);
142
+ }
143
+ }
144
+ return new Proxy(transport, {
145
+ get(target, property) {
146
+ if (property === "send")
147
+ return send;
148
+ if (property === "close")
149
+ return async () => {
150
+ closed = true;
151
+ pending.clear();
152
+ await target.close();
153
+ };
154
+ const value = Reflect.get(target, property, target);
155
+ return typeof value === "function" ? value.bind(target) : value;
156
+ },
157
+ set(target, property, value) {
158
+ if (property === "onmessage")
159
+ return Reflect.set(target, property, (message, extra) => {
160
+ try {
161
+ remember(message);
162
+ } catch {
163
+ overflowed = true;
164
+ pending.clear();
165
+ }
166
+ if (typeof value === "function")
167
+ value(message, extra);
168
+ }, target);
169
+ if (property === "onclose")
170
+ return Reflect.set(target, property, () => {
171
+ closed = true;
172
+ pending.clear();
173
+ if (typeof value === "function")
174
+ value();
175
+ }, target);
176
+ return Reflect.set(target, property, value, target);
177
+ }
178
+ });
179
+ }
180
+
181
+ class DocsMintMcpServer extends McpServer {
182
+ connect(transport) {
183
+ return super.connect(decorateMcpArgumentTransport(transport, this));
184
+ }
185
+ }
4
186
 
5
187
  // dist/client.js
6
188
  var docsApiErrorBrand = Symbol.for("io.github.hiai-gg.docsmint.DocsApiError");
@@ -53,11 +235,15 @@ class DocsTimeoutError extends DocsNetworkError {
53
235
  class DocsClient {
54
236
  config;
55
237
  constructor(config) {
238
+ if (config.apiPrefix !== undefined && config.apiPrefix !== "/api" && config.apiPrefix !== "/api/v1") {
239
+ throw new Error("DocsClient: apiPrefix must be /api or /api/v1");
240
+ }
56
241
  if (!config.baseUrl) {
57
242
  throw new Error("DocsClient: `baseUrl` is required");
58
243
  }
59
244
  this.config = {
60
245
  baseUrl: config.baseUrl.replace(/\/+$/, ""),
246
+ apiPrefix: config.apiPrefix ?? "/api",
61
247
  apiKey: config.apiKey,
62
248
  requestContext: this.snapshotContext(config.requestContext),
63
249
  fetch: config.fetch ?? fetch,
@@ -97,6 +283,16 @@ class DocsClient {
97
283
  return this.request("GET", "/api/documents", {
98
284
  query: this.cleanQuery({
99
285
  folderId: options?.folderId,
286
+ categoryId: options?.categoryId,
287
+ visibility: options?.visibility,
288
+ rootOnly: options?.rootOnly,
289
+ tagIds: options?.tagIds?.join(","),
290
+ tagMatch: options?.tagMatch,
291
+ q: options?.q,
292
+ updatedFrom: options?.updatedFrom,
293
+ updatedTo: options?.updatedTo,
294
+ sortBy: options?.sortBy,
295
+ sortOrder: options?.sortOrder,
100
296
  tag: options?.tag,
101
297
  page: options?.page,
102
298
  limit: options?.limit
@@ -107,6 +303,15 @@ class DocsClient {
107
303
  return this.request("GET", "/api/documents/cursor", {
108
304
  query: this.cleanQuery({
109
305
  categoryId: options.categoryId,
306
+ folderId: options.folderId,
307
+ rootOnly: options.rootOnly,
308
+ tag: options.tag,
309
+ tagIds: options.tagIds?.join(","),
310
+ tagMatch: options.tagMatch,
311
+ visibility: options.visibility,
312
+ q: options.q,
313
+ updatedFrom: options.updatedFrom,
314
+ updatedTo: options.updatedTo,
110
315
  cursor: options.cursor,
111
316
  limit: options.limit,
112
317
  sortBy: options.sortBy,
@@ -138,6 +343,14 @@ class DocsClient {
138
343
  async unpublishDoc(id, context) {
139
344
  return this.request("POST", `/api/documents/${encodeURIComponent(id)}/unpublish`, undefined, context);
140
345
  }
346
+ async exportDocWithMetadata(id, context) {
347
+ const response = await this.fetchRaw("GET", `/api/documents/${encodeURIComponent(id)}/export`, { query: { format: "json" } }, context);
348
+ if (!response.ok)
349
+ throw await this.toApiError(response);
350
+ if (response.headers.get("content-type")?.includes("json"))
351
+ return response.json();
352
+ return { markdown: await response.text() };
353
+ }
141
354
  async exportDoc(id, context) {
142
355
  return this.getDocMarkdown(id, context);
143
356
  }
@@ -221,6 +434,12 @@ class DocsClient {
221
434
  async revokeApiKey(id, context) {
222
435
  return this.request("DELETE", `/api/keys/${encodeURIComponent(id)}`, undefined, context);
223
436
  }
437
+ async whoami(context) {
438
+ return this.request("GET", "/api/whoami", undefined, context);
439
+ }
440
+ async listWorkspaces(context) {
441
+ return this.request("GET", "/api/workspaces", undefined, context);
442
+ }
224
443
  async search(query, options, context) {
225
444
  return this.request("GET", "/api/search", {
226
445
  query: this.cleanQuery({
@@ -236,7 +455,8 @@ class DocsClient {
236
455
  graph: options?.graph,
237
456
  graphHops: options?.graphHops,
238
457
  graphBoost: options?.graphBoost,
239
- includeChunks: options?.includeChunks
458
+ includeChunks: options?.includeChunks,
459
+ includeDiagnostics: options?.includeDiagnostics
240
460
  })
241
461
  }, context);
242
462
  }
@@ -426,7 +646,8 @@ class DocsClient {
426
646
  throw this.wrapNetworkError(lastError, requestContext?.requestId);
427
647
  }
428
648
  buildUrl(path, query) {
429
- let url = `${this.config.baseUrl}${path}`;
649
+ const resolvedPath = path.startsWith("/api/") ? `${this.config.apiPrefix}${path.slice(4)}` : path;
650
+ let url = `${this.config.baseUrl}${resolvedPath}`;
430
651
  if (query && Object.keys(query).length > 0) {
431
652
  const params = new URLSearchParams;
432
653
  for (const [key, value] of Object.entries(query)) {
@@ -720,6 +941,12 @@ var folderSchema = z.looseObject({
720
941
  documents: z.array(documentListItemSchema).optional()
721
942
  });
722
943
  var exportedDocumentSchema = z.looseObject({
944
+ id: z.string().optional(),
945
+ title: z.string().optional(),
946
+ updatedAt: z.string().optional(),
947
+ workspaceId: z.string().nullable().optional(),
948
+ workspaceSlug: z.string().nullable().optional(),
949
+ url: z.string().nullable().optional(),
723
950
  markdown: z.string(),
724
951
  filename: z.string().optional()
725
952
  });
@@ -948,7 +1175,9 @@ function createMcpDocsClient(docsClient, requestContext) {
948
1175
  search: (params) => docsClient.search(params.query, {
949
1176
  folder: params.folder,
950
1177
  tags: params.tags?.join(","),
951
- limit: params.limit
1178
+ limit: params.limit,
1179
+ includeChunks: params.includeChunks,
1180
+ includeDiagnostics: params.includeDiagnostics
952
1181
  }, context),
953
1182
  getDocument: (id) => docsClient.getDoc(id, context),
954
1183
  createDocument: (input) => docsClient.createDoc({
@@ -969,7 +1198,7 @@ function createMcpDocsClient(docsClient, requestContext) {
969
1198
  refreshDocumentIndex: (documentId) => docsClient.refreshDocumentIndex(documentId, context),
970
1199
  createSnapshot: (documentId, input) => docsClient.createSnapshot(documentId, input, context),
971
1200
  getVersionHistory: (documentId, onlySnapshots) => docsClient.listVersions(documentId, { onlySnapshots }, context),
972
- exportDocument: async (id) => ({ markdown: await docsClient.exportDoc(id, context) })
1201
+ exportDocument: (id) => docsClient.exportDocWithMetadata(id, context)
973
1202
  };
974
1203
  }
975
1204
  function createDefaultDocsClient() {
@@ -986,13 +1215,38 @@ var client = new Proxy({}, {
986
1215
 
987
1216
  // ../mcp-server/src/client-routing-schema.ts
988
1217
  import { z as z2 } from "zod";
1218
+ function canonical(value) {
1219
+ if (Array.isArray(value))
1220
+ return `[${value.map(canonical).join(",")}]`;
1221
+ if (value && typeof value === "object")
1222
+ return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
1223
+ return JSON.stringify(value) ?? "null";
1224
+ }
1225
+ function mergePropertyVariants(values) {
1226
+ const unique = [
1227
+ ...new Map(values.map((value) => [canonical(value), value])).values()
1228
+ ];
1229
+ if (unique.length === 1)
1230
+ return unique[0];
1231
+ const literalObjects = unique.filter((value) => value && typeof value === "object" && ("const" in value));
1232
+ if (literalObjects.length === unique.length) {
1233
+ const withoutConst = literalObjects.map(({ const: _literal, ...rest }) => rest);
1234
+ if (withoutConst.every((value) => canonical(value) === canonical(withoutConst[0]))) {
1235
+ return {
1236
+ ...withoutConst[0],
1237
+ enum: literalObjects.map((value) => value.const)
1238
+ };
1239
+ }
1240
+ }
1241
+ return { anyOf: unique };
1242
+ }
989
1243
  function hoistObjectUnionClosure(schema) {
990
1244
  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))
1245
+ if (!Array.isArray(variants) || !variants.every((variant) => typeof variant === "object" && variant !== null && variant.type === "object" && variant.additionalProperties === false && typeof variant.properties === "object" && variant.properties !== null))
992
1246
  return schema;
993
1247
  const propertyVariants = new Map;
994
- for (const variant2 of variants) {
995
- for (const [key, property] of Object.entries(variant2.properties)) {
1248
+ for (const variant of variants) {
1249
+ for (const [key, property] of Object.entries(variant.properties)) {
996
1250
  const values = propertyVariants.get(key) ?? [];
997
1251
  values.push(property);
998
1252
  propertyVariants.set(key, values);
@@ -1003,12 +1257,12 @@ function hoistObjectUnionClosure(schema) {
1003
1257
  type: "object",
1004
1258
  properties: Object.fromEntries([...propertyVariants].map(([key, values]) => [
1005
1259
  key,
1006
- values.length === 1 ? values[0] : { anyOf: values }
1260
+ mergePropertyVariants(values)
1007
1261
  ])),
1008
1262
  additionalProperties: false,
1009
- oneOf: variants.map((variant2) => {
1010
- const { additionalProperties: _closure, ...branch } = variant2;
1011
- const excluded = [...propertyVariants.keys()].filter((key) => !(key in variant2.properties));
1263
+ oneOf: variants.map((variant) => {
1264
+ const { additionalProperties: _closure, ...branch } = variant;
1265
+ const excluded = [...propertyVariants.keys()].filter((key) => !(key in variant.properties));
1012
1266
  return excluded.length === 0 ? branch : {
1013
1267
  ...branch,
1014
1268
  allOf: [
@@ -1031,11 +1285,21 @@ function withClientRoutingSchema(schema) {
1031
1285
  const { workspaceId, ...args } = value;
1032
1286
  const selected = selector.safeParse(workspaceId);
1033
1287
  if (!selected.success)
1034
- return { issues: selected.error.issues };
1288
+ return {
1289
+ issues: selected.error.issues.map((issue) => ({
1290
+ ...issue,
1291
+ path: ["workspaceId", ...issue.path]
1292
+ }))
1293
+ };
1035
1294
  const validated = await standard.validate(args, options);
1036
1295
  if (validated.issues)
1037
1296
  return validated;
1038
- return { value: { ...validated.value, ...selected.data ? { workspaceId: selected.data } : {} } };
1297
+ return {
1298
+ value: {
1299
+ ...validated.value,
1300
+ ...selected.data ? { workspaceId: selected.data } : {}
1301
+ }
1302
+ };
1039
1303
  },
1040
1304
  jsonSchema: {
1041
1305
  ...standard.jsonSchema,
@@ -1044,11 +1308,17 @@ function withClientRoutingSchema(schema) {
1044
1308
  const routingProperty = z2.toJSONSchema(selector);
1045
1309
  return {
1046
1310
  ...published,
1047
- properties: { ...published.properties, workspaceId: routingProperty },
1311
+ properties: {
1312
+ ...published.properties,
1313
+ workspaceId: routingProperty
1314
+ },
1048
1315
  ...Array.isArray(published.oneOf) ? {
1049
1316
  oneOf: published.oneOf.map((branch) => ({
1050
1317
  ...branch,
1051
- properties: { ...branch.properties, workspaceId: routingProperty }
1318
+ properties: {
1319
+ ...branch.properties,
1320
+ workspaceId: routingProperty
1321
+ }
1052
1322
  }))
1053
1323
  } : {}
1054
1324
  };
@@ -1076,7 +1346,7 @@ function required(method, name) {
1076
1346
  throw new Error(`The injected legacy MCP client does not support ${name}; use a public DocsClient.`);
1077
1347
  return method;
1078
1348
  }
1079
- function registerBatchAndWorkspaceCapabilities(server, client2, wrap) {
1349
+ function registerBatchAndWorkspaceCapabilities(server, client, wrap) {
1080
1350
  async function batch(input) {
1081
1351
  const results = [];
1082
1352
  let aborted = false;
@@ -1088,25 +1358,25 @@ function registerBatchAndWorkspaceCapabilities(server, client2, wrap) {
1088
1358
  try {
1089
1359
  switch (input.action) {
1090
1360
  case "move":
1091
- await client2.updateDocument(id, { folderId: input.folderId });
1361
+ await client.updateDocument(id, { folderId: input.folderId });
1092
1362
  break;
1093
1363
  case "set_category":
1094
- await client2.updateDocument(id, { categoryId: input.categoryId });
1364
+ await client.updateDocument(id, { categoryId: input.categoryId });
1095
1365
  break;
1096
1366
  case "add_tag":
1097
- await required(client2.addTagToDocument, "add_tag")(id, input.tagId);
1367
+ await required(client.addTagToDocument, "add_tag")(id, input.tagId);
1098
1368
  break;
1099
1369
  case "remove_tag":
1100
- await required(client2.removeTagFromDocument, "remove_tag")(id, input.tagId);
1370
+ await required(client.removeTagFromDocument, "remove_tag")(id, input.tagId);
1101
1371
  break;
1102
1372
  case "trash":
1103
- await required(client2.deleteDocument, "trash")(id);
1373
+ await required(client.deleteDocument, "trash")(id);
1104
1374
  break;
1105
1375
  case "restore":
1106
- await required(client2.restoreTrashedDocument, "restore")(id);
1376
+ await required(client.restoreTrashedDocument, "restore")(id);
1107
1377
  break;
1108
1378
  case "refresh_index":
1109
- await client2.refreshDocumentIndex(id);
1379
+ await client.refreshDocumentIndex(id);
1110
1380
  break;
1111
1381
  }
1112
1382
  results.push({ id, status: "ok" });
@@ -1124,19 +1394,19 @@ function registerBatchAndWorkspaceCapabilities(server, client2, wrap) {
1124
1394
  }
1125
1395
  server.registerTool("batch_documents", {
1126
1396
  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.",
1127
- inputSchema: withClientRoutingSchema(batchInput),
1397
+ inputSchema: captureMcpInputSchema(server, "batch_documents", withClientRoutingSchema(batchInput)),
1128
1398
  outputSchema: toolOutputSchemas.batch_documents,
1129
1399
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false }
1130
1400
  }, wrap("batch_documents", batch, toolOutputSchemas.batch_documents));
1131
1401
  server.registerTool("get_workspace_item", {
1132
1402
  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.",
1133
- inputSchema: withClientRoutingSchema(z3.strictObject({ kind: z3.enum(["folder", "category", "tag"]).describe("The workspace resource type to read by ID."), id: uuid })),
1403
+ inputSchema: captureMcpInputSchema(server, "get_workspace_item", withClientRoutingSchema(z3.strictObject({ kind: z3.enum(["folder", "category", "tag"]).describe("The workspace resource type to read by ID."), id: uuid }))),
1134
1404
  outputSchema: toolOutputSchemas.get_workspace_item,
1135
1405
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }
1136
1406
  }, wrap("get_workspace_item", async ({ kind, id }) => {
1137
1407
  if (kind === "folder")
1138
- return { operation: kind, result: await required(client2.getFolder, "get_workspace_item(folder)")(id) };
1139
- const listed = kind === "category" ? await client2.listCategories() : await client2.listTags();
1408
+ return { operation: kind, result: await required(client.getFolder, "get_workspace_item(folder)")(id) };
1409
+ const listed = kind === "category" ? await client.listCategories() : await client.listTags();
1140
1410
  const result = Array.isArray(listed) ? listed.find((item) => item.id === id) : undefined;
1141
1411
  if (!result)
1142
1412
  throw new HiaiDocsError(`${kind} not found`, 404, null, "NOT_FOUND");
@@ -1157,38 +1427,38 @@ function required2(value, name) {
1157
1427
  throw new Error(`The injected legacy MCP client does not support ${name}; use a public DocsClient.`);
1158
1428
  return value;
1159
1429
  }
1160
- function registerCompactCapabilities(server, client2, wrap) {
1430
+ function registerCompactCapabilities(server, client, wrap) {
1161
1431
  function register(name, description, inputSchema, annotations, handler) {
1162
- server.registerTool(name, { description, inputSchema: withClientRoutingSchema(inputSchema), outputSchema: toolOutputSchemas[name], annotations }, wrap(name, handler, toolOutputSchemas[name]));
1432
+ server.registerTool(name, { description, inputSchema: captureMcpInputSchema(server, name, withClientRoutingSchema(inputSchema)), outputSchema: toolOutputSchemas[name], annotations }, wrap(name, handler, toolOutputSchemas[name]));
1163
1433
  }
1164
1434
  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", [
1165
- 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.") }),
1166
- 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.") })
1167
- ]), read, async (input) => input.mode === "list" ? { operation: "list", result: await client2.listDocuments(input) } : { operation: "search", result: await client2.search(input) });
1435
+ z4.strictObject({ mode: z4.literal("list").describe("Select the list operation explicitly."), folderId: uuid2.optional(), categoryId: uuid2.optional().describe("Filter by effective category UUID, including inherited folder placement."), visibility: z4.enum(["private", "shared", "public"]).optional().describe("Optional document visibility filter; never expands access."), rootOnly: z4.boolean().optional().describe("Return only documents without a folder; cannot combine with folderId."), tag: uuid2.optional(), tagIds: z4.array(uuid2).min(1).optional().describe("Filter by tag UUIDs; cannot combine with the legacy tag field."), tagMatch: z4.enum(["all", "any"]).optional().describe("Require all supplied tags by default, or any supplied tag."), q: z4.string().optional().describe("Literal case-insensitive title/content filter; does not invoke semantic search."), updatedFrom: z4.iso.datetime({ offset: true }).optional().describe("Inclusive updated timestamp lower bound, with timezone."), updatedTo: z4.iso.datetime({ offset: true }).optional().describe("Exclusive updated timestamp upper bound, with timezone."), sortBy: z4.enum(["updatedAt", "createdAt", "title"]).optional().describe("Stable server-side sort field; defaults to updatedAt."), sortOrder: z4.enum(["asc", "desc"]).optional().describe("Sort direction, descending by default with an ID tie-breaker."), 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.") }),
1436
+ z4.strictObject({ mode: z4.literal("search").describe("Select the search operation explicitly."), query: text.describe("Text to search in the original language."), includeDiagnostics: z4.boolean().optional().describe("Include redacted diagnostic details; omitted by default."), includeChunks: z4.boolean().optional().describe("Include matching text chunks only when requested."), 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.") })
1437
+ ]), read, async (input) => input.mode === "list" ? { operation: "list", result: await client.listDocuments(input) } : { operation: "search", result: await client.search(input) });
1168
1438
  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", [
1169
1439
  z4.strictObject({ view: z4.literal("detail").describe("Select the detail operation explicitly."), id: uuid2 }),
1170
1440
  z4.strictObject({ view: z4.literal("markdown").describe("Select the markdown operation explicitly."), id: uuid2 }),
1171
1441
  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.") })
1172
1442
  ]), read, async (input) => {
1173
1443
  if (input.view === "detail")
1174
- return { operation: "detail", result: await client2.getDocument(input.id) };
1444
+ return { operation: "detail", result: await client.getDocument(input.id) };
1175
1445
  if (input.view === "markdown")
1176
- return { operation: "markdown", result: await client2.exportDocument(input.id) };
1177
- return { operation: "versions", result: await client2.getVersionHistory(input.id, input.onlySnapshots) };
1446
+ return { operation: "markdown", result: await client.exportDocument(input.id) };
1447
+ return { operation: "versions", result: await client.getVersionHistory(input.id, input.onlySnapshots) };
1178
1448
  });
1179
1449
  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", [
1180
1450
  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.") }),
1181
1451
  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)
1182
1452
  ]), destructive, async (input) => {
1183
1453
  if (input.action === "create") {
1184
- const { action: _action2, ...data2 } = input;
1185
- return { operation: "create", result: await client2.createDocument(data2) };
1454
+ const { action: _action, ...data } = input;
1455
+ return { operation: "create", result: await client.createDocument(data) };
1186
1456
  }
1187
1457
  const { action: _action, id, ...data } = input;
1188
- return { operation: "update", result: await client2.updateDocument(id, data) };
1458
+ return { operation: "update", result: await client.updateDocument(id, data) };
1189
1459
  });
1190
1460
  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 }) => {
1191
- await required2(client2.deleteDocument, "delete_document")(id);
1461
+ await required2(client.deleteDocument, "delete_document")(id);
1192
1462
  return { id, deleted: true };
1193
1463
  });
1194
1464
  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", [
@@ -1200,24 +1470,24 @@ function registerCompactCapabilities(server, client2, wrap) {
1200
1470
  if (input.kind === "workspaces")
1201
1471
  throw new Error("Workspace routing is not configured");
1202
1472
  if (input.kind === "folders")
1203
- return { operation: "folders", result: await client2.listFolders({ parentId: input.parentId }) };
1473
+ return { operation: "folders", result: await client.listFolders({ parentId: input.parentId }) };
1204
1474
  if (input.kind === "categories")
1205
- return { operation: "categories", result: await client2.listCategories() };
1206
- return { operation: "tags", result: await client2.listTags() };
1475
+ return { operation: "categories", result: await client.listCategories() };
1476
+ return { operation: "tags", result: await client.listTags() };
1207
1477
  });
1208
1478
  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", [
1209
1479
  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.") }),
1210
1480
  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)
1211
1481
  ]), destructive, async (input) => {
1212
1482
  if (input.action === "create") {
1213
- const { action: _action2, ...data2 } = input;
1214
- return { operation: "create", result: await client2.createFolder(data2) };
1483
+ const { action: _action, ...data } = input;
1484
+ return { operation: "create", result: await client.createFolder(data) };
1215
1485
  }
1216
1486
  const { action: _action, id, ...data } = input;
1217
- return { operation: "update", result: await required2(client2.updateFolder, "update_folder")(id, data) };
1487
+ return { operation: "update", result: await required2(client.updateFolder, "update_folder")(id, data) };
1218
1488
  });
1219
1489
  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 }) => {
1220
- await required2(client2.deleteFolder, "delete_folder")(id);
1490
+ await required2(client.deleteFolder, "delete_folder")(id);
1221
1491
  return { id, deleted: true };
1222
1492
  });
1223
1493
  register("save_category", "Create or update a workspace category. Full workspace write access is required; category-scoped credentials cannot manage categories.", z4.discriminatedUnion("action", [
@@ -1225,12 +1495,12 @@ function registerCompactCapabilities(server, client2, wrap) {
1225
1495
  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)
1226
1496
  ]), destructive, async (input) => {
1227
1497
  if (input.action === "create")
1228
- return { operation: "create", result: await client2.createCategory({ name: input.name }) };
1498
+ return { operation: "create", result: await client.createCategory({ name: input.name }) };
1229
1499
  const { action: _action, id, ...data } = input;
1230
- return { operation: "update", result: await required2(client2.updateCategory, "update_category")(id, data) };
1500
+ return { operation: "update", result: await required2(client.updateCategory, "update_category")(id, data) };
1231
1501
  });
1232
1502
  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 }) => {
1233
- await required2(client2.deleteCategory, "delete_category")(id);
1503
+ await required2(client.deleteCategory, "delete_category")(id);
1234
1504
  return { id, deleted: true };
1235
1505
  });
1236
1506
  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", [
@@ -1238,42 +1508,42 @@ function registerCompactCapabilities(server, client2, wrap) {
1238
1508
  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)
1239
1509
  ]), destructive, async (input) => {
1240
1510
  if (input.action === "create")
1241
- return { operation: "create", result: await required2(client2.createTag, "create_tag")({ name: input.name, color: input.color }) };
1511
+ return { operation: "create", result: await required2(client.createTag, "create_tag")({ name: input.name, color: input.color }) };
1242
1512
  const { action: _action, id, ...data } = input;
1243
- return { operation: "update", result: await required2(client2.updateTag, "update_tag")(id, data) };
1513
+ return { operation: "update", result: await required2(client.updateTag, "update_tag")(id, data) };
1244
1514
  });
1245
1515
  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 }) => {
1246
- await required2(client2.deleteTag, "delete_tag")(id);
1516
+ await required2(client.deleteTag, "delete_tag")(id);
1247
1517
  return { id, deleted: true };
1248
1518
  });
1249
1519
  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 }) => {
1250
1520
  if (action === "add") {
1251
- await required2(client2.addTagToDocument, "add_tag_to_document")(documentId, tagId);
1521
+ await required2(client.addTagToDocument, "add_tag_to_document")(documentId, tagId);
1252
1522
  return { operation: "add", result: { documentId, tagId, assigned: true } };
1253
1523
  }
1254
- await required2(client2.removeTagFromDocument, "remove_tag_from_document")(documentId, tagId);
1524
+ await required2(client.removeTagFromDocument, "remove_tag_from_document")(documentId, tagId);
1255
1525
  return { operation: "remove", result: { documentId, tagId, removed: true } };
1256
1526
  });
1257
- 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 }));
1258
- 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));
1527
+ 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 }) => client.createSnapshot(documentId, { label, description }));
1528
+ 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(client.restoreDocumentVersion, "restore_document_version")(documentId, versionId));
1259
1529
  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", [
1260
1530
  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.") }),
1261
1531
  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.") })
1262
- ]), read, async (input) => input.mode === "neighbors" ? { operation: "neighbors", result: await client2.getRelatedDocuments(input.documentId, input.limit) } : { operation: "search", result: await client2.searchGraph(input) });
1263
- 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));
1264
- 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));
1265
- 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")());
1266
- 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));
1532
+ ]), read, async (input) => input.mode === "neighbors" ? { operation: "neighbors", result: await client.getRelatedDocuments(input.documentId, input.limit) } : { operation: "search", result: await client.searchGraph(input) });
1533
+ 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 }) => client.getDocumentIndexStatus(documentId));
1534
+ 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 }) => client.refreshDocumentIndex(documentId));
1535
+ 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(client.listTrash, "list_trash")());
1536
+ 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(client.restoreTrashedDocument, "restore_trashed_document")(id));
1267
1537
  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 }) => {
1268
- await required2(client2.permanentlyDeleteDocument, "permanently_delete_document")(id);
1538
+ await required2(client.permanentlyDeleteDocument, "permanently_delete_document")(id);
1269
1539
  return { id, deleted: true };
1270
1540
  });
1271
- registerBatchAndWorkspaceCapabilities(server, client2, wrap);
1541
+ registerBatchAndWorkspaceCapabilities(server, client, wrap);
1272
1542
  }
1273
1543
 
1274
1544
  // ../mcp-server/src/prompts-resources.ts
1275
1545
  import { z as z5 } from "zod";
1276
- function registerPromptsAndResources(server, client2) {
1546
+ function registerPromptsAndResources(server, client) {
1277
1547
  server.registerPrompt("organize_workspace", {
1278
1548
  description: "Plan safe document organization using DocsMint categories and folders.",
1279
1549
  argsSchema: z5.object({
@@ -1332,9 +1602,9 @@ Use find_documents(mode=search) for normal retrieval. Use explore_graph only wit
1332
1602
  }));
1333
1603
  server.registerResource("workspace-catalog", "docsmint://workspace/catalog", {}, async (uri) => {
1334
1604
  const [categories, folders, tags] = await Promise.all([
1335
- client2.listCategories(),
1336
- client2.listFolders({}),
1337
- client2.listTags()
1605
+ client.listCategories(),
1606
+ client.listFolders({}),
1607
+ client.listTags()
1338
1608
  ]);
1339
1609
  return {
1340
1610
  contents: [
@@ -1381,9 +1651,181 @@ var capabilityCatalog = {
1381
1651
  "docsmint://workspace/catalog"
1382
1652
  ]
1383
1653
  };
1654
+ // ../mcp-server/src/catalog.ts
1655
+ import {
1656
+ InMemoryTransport
1657
+ } from "@modelcontextprotocol/server";
1658
+ function object2(value) {
1659
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1660
+ }
1661
+ function example(schema) {
1662
+ if ("const" in schema)
1663
+ return schema.const;
1664
+ if (Array.isArray(schema.enum))
1665
+ return schema.enum[0];
1666
+ if (Array.isArray(schema.anyOf))
1667
+ return example(object2(schema.anyOf[0]));
1668
+ if (schema.type === "null")
1669
+ return null;
1670
+ if (schema.type === "boolean")
1671
+ return false;
1672
+ if (schema.type === "number" || schema.type === "integer")
1673
+ return Math.max(1, Number(schema.minimum ?? 1));
1674
+ if (schema.type === "array")
1675
+ return [example(object2(schema.items))];
1676
+ if (schema.type === "object" || schema.properties) {
1677
+ return Object.fromEntries(Object.entries(object2(schema.properties)).filter(([name]) => Array.isArray(schema.required) && schema.required.includes(name) || name === "title" || name === "name").map(([name, value]) => [name, example(object2(value))]));
1678
+ }
1679
+ if (schema.format === "uuid")
1680
+ return "11111111-1111-4111-8111-111111111111";
1681
+ if (schema.format === "date-time")
1682
+ return "2026-01-01T00:00:00.000Z";
1683
+ return "Example";
1684
+ }
1685
+ async function generateDocsmintMcpCatalog() {
1686
+ const docsClient = new DocsClient({
1687
+ baseUrl: "https://catalog.invalid",
1688
+ retries: 1,
1689
+ fetch: async () => {
1690
+ throw new Error("Catalog generation must not access document storage");
1691
+ }
1692
+ });
1693
+ const server = createDocsmintMcpServer({ docsClient });
1694
+ const [peer, transport] = InMemoryTransport.createLinkedPair();
1695
+ let id = 0;
1696
+ const waiting = new Map;
1697
+ peer.onmessage = (message) => {
1698
+ if (!("id" in message) || typeof message.id !== "number")
1699
+ return;
1700
+ const pending = waiting.get(message.id);
1701
+ if (!pending)
1702
+ return;
1703
+ waiting.delete(message.id);
1704
+ if ("error" in message)
1705
+ pending.reject(new Error("MCP catalog discovery failed"));
1706
+ else if ("result" in message)
1707
+ pending.resolve(object2(message.result));
1708
+ };
1709
+ async function rpc(method, params = {}) {
1710
+ const requestId = ++id;
1711
+ const result = new Promise((resolve, reject) => waiting.set(requestId, { resolve, reject }));
1712
+ await peer.send({ jsonrpc: "2.0", id: requestId, method, params });
1713
+ return result;
1714
+ }
1715
+ async function collect(method, field) {
1716
+ const values = [];
1717
+ const seen = new Set;
1718
+ let cursor;
1719
+ do {
1720
+ const page = await rpc(method, cursor ? { cursor } : {});
1721
+ if (!Array.isArray(page[field]))
1722
+ throw new Error(`Invalid ${method} discovery result`);
1723
+ values.push(...page[field]);
1724
+ cursor = typeof page.nextCursor === "string" ? page.nextCursor : undefined;
1725
+ if (cursor && seen.has(cursor))
1726
+ throw new Error(`Repeated ${method} discovery cursor`);
1727
+ if (cursor)
1728
+ seen.add(cursor);
1729
+ } while (cursor);
1730
+ return values;
1731
+ }
1732
+ try {
1733
+ await Promise.all([peer.start(), server.connect(transport)]);
1734
+ const initialized = await rpc("initialize", {
1735
+ protocolVersion: "2025-06-18",
1736
+ capabilities: {},
1737
+ clientInfo: { name: "docsmint-catalog-generator", version: "1" }
1738
+ });
1739
+ await peer.send({ jsonrpc: "2.0", method: "notifications/initialized" });
1740
+ const tools = await collect("tools/list", "tools");
1741
+ const prompts = await collect("prompts/list", "prompts");
1742
+ const resources = await collect("resources/list", "resources");
1743
+ const info = object2(initialized.serverInfo);
1744
+ if (typeof info.name !== "string" || typeof info.version !== "string")
1745
+ throw new Error("Missing MCP server identity");
1746
+ return {
1747
+ server: { name: info.name, version: info.version },
1748
+ tools: tools.map((tool) => {
1749
+ const schema = object2(tool.inputSchema);
1750
+ const branches = Array.isArray(schema.oneOf) ? schema.oneOf : [schema];
1751
+ return {
1752
+ ...tool,
1753
+ examples: branches.map((branch) => object2(example(object2(branch))))
1754
+ };
1755
+ }),
1756
+ prompts,
1757
+ resources
1758
+ };
1759
+ } finally {
1760
+ await peer.close();
1761
+ await server.close();
1762
+ }
1763
+ }
1764
+ // ../mcp-server/src/http.ts
1765
+ import { AsyncLocalStorage } from "async_hooks";
1766
+ import { createMcpHandler } from "@modelcontextprotocol/server";
1767
+ function createDocsmintMcpHttpHandler(options) {
1768
+ const servers = new AsyncLocalStorage;
1769
+ const transport = createMcpHandler(async () => {
1770
+ const server = servers.getStore();
1771
+ if (!server)
1772
+ throw new Error("MCP request context unavailable");
1773
+ return server;
1774
+ }, { legacy: "stateless", responseMode: "json", onerror: options.onerror });
1775
+ return {
1776
+ close: () => transport.close(),
1777
+ async fetch(request) {
1778
+ const canonical = new URL(request.url);
1779
+ if (canonical.pathname.endsWith("/mcp/")) {
1780
+ canonical.pathname = canonical.pathname.slice(0, -1);
1781
+ request = new Request(canonical, request);
1782
+ }
1783
+ const origin = request.headers.get("origin");
1784
+ const allowed = !origin || options.allowedOrigins.includes(origin);
1785
+ const cors = new Headers({ Vary: "Origin" });
1786
+ if (origin && allowed)
1787
+ cors.set("Access-Control-Allow-Origin", origin);
1788
+ function finish(response) {
1789
+ const headers = new Headers(response.headers);
1790
+ headers.set("Vary", [headers.get("Vary"), "Origin"].filter(Boolean).join(", "));
1791
+ for (const [name, value] of cors)
1792
+ if (name !== "vary")
1793
+ headers.set(name, value);
1794
+ return new Response(response.body, {
1795
+ status: response.status,
1796
+ statusText: response.statusText,
1797
+ headers
1798
+ });
1799
+ }
1800
+ if (options.enabled === false)
1801
+ return finish(new Response(null, { status: 404 }));
1802
+ if (!allowed)
1803
+ return finish(Response.json({ error: "Origin not allowed" }, { status: 403 }));
1804
+ if (request.method === "OPTIONS") {
1805
+ cors.set("Access-Control-Allow-Methods", "POST, OPTIONS");
1806
+ cors.set("Access-Control-Allow-Headers", "Authorization, Content-Type, MCP-Protocol-Version, X-Docsmint-Workspace");
1807
+ return new Response(null, { status: 204, headers: cors });
1808
+ }
1809
+ if (request.method !== "POST")
1810
+ return finish(new Response(null, {
1811
+ status: 405,
1812
+ headers: { Allow: "POST, OPTIONS" }
1813
+ }));
1814
+ try {
1815
+ const server = await options.createServer(request);
1816
+ if (server instanceof Response)
1817
+ return finish(server);
1818
+ return finish(await servers.run(server, () => transport.fetch(request)));
1819
+ } catch (error) {
1820
+ options.onerror?.(error instanceof Error ? error : new Error("MCP transport failure"));
1821
+ return finish(Response.json({ error: "MCP transport failure" }, { status: 500 }));
1822
+ }
1823
+ }
1824
+ };
1825
+ }
1384
1826
 
1385
1827
  // ../mcp-server/src/server.ts
1386
- function wrapHandler(name, handler, outputSchema, workspaceRouting) {
1828
+ function wrapHandler(name, handler, outputSchema, workspaceRouting, decorateResult) {
1387
1829
  return async (args) => {
1388
1830
  try {
1389
1831
  const { workspaceId, ...data } = args;
@@ -1401,12 +1843,15 @@ function wrapHandler(name, handler, outputSchema, workspaceRouting) {
1401
1843
  } else {
1402
1844
  output = await handler(data);
1403
1845
  }
1846
+ if (decorateResult)
1847
+ output = await decorateResult(name, output);
1404
1848
  const parsedOutput = outputSchema ? await outputSchema.safeParseAsync(output) : undefined;
1405
1849
  if (parsedOutput && !parsedOutput.success) {
1406
1850
  throw new Error(`Tool '${name}' returned a result outside its published output schema`);
1407
1851
  }
1852
+ const result = parsedOutput?.success ? parsedOutput.data : output;
1408
1853
  return {
1409
- content: [{ type: "text", text: JSON.stringify(output, null, 2) }],
1854
+ content: [{ type: "text", text: JSON.stringify(result) }],
1410
1855
  ...parsedOutput?.success ? { structuredContent: parsedOutput.data } : {}
1411
1856
  };
1412
1857
  } catch (error) {
@@ -1434,20 +1879,22 @@ function wrapHandler(name, handler, outputSchema, workspaceRouting) {
1434
1879
  }
1435
1880
  };
1436
1881
  }
1437
- function registerDocsmintMcpCapabilities(server, client2, workspaceRouting) {
1438
- const wrap = (name, handler, outputSchema) => wrapHandler(name, handler, outputSchema, workspaceRouting);
1439
- registerCompactCapabilities(server, client2, wrap);
1440
- registerPromptsAndResources(server, client2);
1882
+ function registerDocsmintMcpCapabilities(server, client, workspaceRouting, decorateResult) {
1883
+ const wrap = (name, handler, outputSchema) => wrapHandler(name, handler, outputSchema, workspaceRouting, decorateResult);
1884
+ registerCompactCapabilities(server, client, wrap);
1885
+ registerPromptsAndResources(server, client);
1441
1886
  }
1442
1887
  function createDocsmintMcpServer(options = {}) {
1443
- const server = new McpServer({ name: "docsmint", version: "2.0.4" });
1444
- const client2 = options.docsClient ? createMcpDocsClient(options.docsClient, options.requestContext) : options.client ?? createMcpDocsClient(createDefaultDocsClient(), options.requestContext);
1445
- registerDocsmintMcpCapabilities(server, client2, options.workspaceRouting);
1888
+ const server = new DocsMintMcpServer({ name: "docsmint", version: "2.1.1" });
1889
+ const client = options.docsClient ? createMcpDocsClient(options.docsClient, options.requestContext) : options.client ?? createMcpDocsClient(createDefaultDocsClient(), options.requestContext);
1890
+ registerDocsmintMcpCapabilities(server, client, options.workspaceRouting, options.decorateResult);
1446
1891
  return server;
1447
1892
  }
1448
1893
  export {
1449
1894
  capabilityCatalog,
1895
+ createDocsmintMcpHttpHandler,
1450
1896
  createDocsmintMcpServer,
1451
1897
  createMcpScopedResult,
1898
+ generateDocsmintMcpCatalog,
1452
1899
  registerDocsmintMcpCapabilities
1453
1900
  };