@cossackframework/cms 0.0.0 → 0.9.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 (427) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +145 -2
  3. package/agent-docs.json +259 -0
  4. package/app/README.md +78 -0
  5. package/app/cossack-recipe.json +43 -0
  6. package/app/src/auth-bot-check.ts +32 -0
  7. package/app/src/auth-bot-token.ts +11 -0
  8. package/app/src/auth-input.ts +35 -0
  9. package/app/src/auth-options.ts +21 -0
  10. package/app/src/auth-providers.ts +16 -0
  11. package/app/src/auth.ts +1082 -0
  12. package/app/src/brand.ts +68 -0
  13. package/app/src/cms/ai.ts +54 -0
  14. package/app/src/cms/analytics.ts +33 -0
  15. package/app/src/cms/block-errors.ts +55 -0
  16. package/app/src/cms/block-inserter.ts +111 -0
  17. package/app/src/cms/block-panel.ts +68 -0
  18. package/app/src/cms/block-rows.ts +44 -0
  19. package/app/src/cms/block-tree.ts +585 -0
  20. package/app/src/cms/blocks.css +709 -0
  21. package/app/src/cms/builder.ts +126 -0
  22. package/app/src/cms/cache.ts +44 -0
  23. package/app/src/cms/carousel.client.ts +52 -0
  24. package/app/src/cms/collab/presence.ts +69 -0
  25. package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
  26. package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
  27. package/app/src/cms/collab/room.ts +881 -0
  28. package/app/src/cms/compare.client.ts +47 -0
  29. package/app/src/cms/condition-control.ts +109 -0
  30. package/app/src/cms/content-api.ts +143 -0
  31. package/app/src/cms/content.ts +524 -0
  32. package/app/src/cms/countdown.client.ts +37 -0
  33. package/app/src/cms/editor-layout-editor.ts +260 -0
  34. package/app/src/cms/editor-layout-view.ts +37 -0
  35. package/app/src/cms/editor.ts +381 -0
  36. package/app/src/cms/entry.ts +26 -0
  37. package/app/src/cms/feeds.ts +145 -0
  38. package/app/src/cms/field-controls.ts +222 -0
  39. package/app/src/cms/field-group-editor.ts +105 -0
  40. package/app/src/cms/field-group-view.ts +211 -0
  41. package/app/src/cms/form-view.ts +203 -0
  42. package/app/src/cms/form.client.ts +203 -0
  43. package/app/src/cms/guards.ts +27 -0
  44. package/app/src/cms/handoff.ts +202 -0
  45. package/app/src/cms/headings.ts +51 -0
  46. package/app/src/cms/icons.ts +80 -0
  47. package/app/src/cms/import.client.ts +16 -0
  48. package/app/src/cms/index.ts +191 -0
  49. package/app/src/cms/lightbox.client.ts +114 -0
  50. package/app/src/cms/machine.ts +118 -0
  51. package/app/src/cms/maintenance.ts +97 -0
  52. package/app/src/cms/manage.ts +1236 -0
  53. package/app/src/cms/mcp-tools.ts +388 -0
  54. package/app/src/cms/mcp.ts +242 -0
  55. package/app/src/cms/media-chooser.ts +123 -0
  56. package/app/src/cms/media-usage.ts +57 -0
  57. package/app/src/cms/middleware.ts +199 -0
  58. package/app/src/cms/middlewares.ts +13 -0
  59. package/app/src/cms/network-ui.ts +36 -0
  60. package/app/src/cms/network-view.ts +38 -0
  61. package/app/src/cms/notes-announce.ts +65 -0
  62. package/app/src/cms/notes-rail.ts +207 -0
  63. package/app/src/cms/notification-rules.ts +66 -0
  64. package/app/src/cms/recovery.ts +82 -0
  65. package/app/src/cms/replace.ts +63 -0
  66. package/app/src/cms/reserved-paths.ts +19 -0
  67. package/app/src/cms/rich-text-field.ts +325 -0
  68. package/app/src/cms/rich-text-schema.ts +91 -0
  69. package/app/src/cms/rich-text.client.ts +255 -0
  70. package/app/src/cms/search.client.ts +116 -0
  71. package/app/src/cms/seo-head.ts +78 -0
  72. package/app/src/cms/seo.ts +241 -0
  73. package/app/src/cms/settings-draft.ts +218 -0
  74. package/app/src/cms/settings-file.ts +127 -0
  75. package/app/src/cms/settings-form.ts +180 -0
  76. package/app/src/cms/settings-languages.ts +125 -0
  77. package/app/src/cms/settings-nav.ts +102 -0
  78. package/app/src/cms/settings-network.ts +151 -0
  79. package/app/src/cms/settings-permalinks.ts +114 -0
  80. package/app/src/cms/settings-scroll.ts +10 -0
  81. package/app/src/cms/settings-search.ts +77 -0
  82. package/app/src/cms/settings-section.ts +38 -0
  83. package/app/src/cms/share.client.ts +27 -0
  84. package/app/src/cms/site-editing.ts +219 -0
  85. package/app/src/cms/site-editor.client.ts +1008 -0
  86. package/app/src/cms/site-editor.ts +99 -0
  87. package/app/src/cms/site-export.ts +60 -0
  88. package/app/src/cms/site-forms.ts +143 -0
  89. package/app/src/cms/site-import.ts +28 -0
  90. package/app/src/cms/site-session.ts +36 -0
  91. package/app/src/cms/site-taskbar.ts +77 -0
  92. package/app/src/cms/site-view.ts +1014 -0
  93. package/app/src/cms/site.ts +1322 -0
  94. package/app/src/cms/sitemaps.ts +131 -0
  95. package/app/src/cms/stat.client.ts +56 -0
  96. package/app/src/cms/style-controls.ts +252 -0
  97. package/app/src/cms/tabs.client.ts +36 -0
  98. package/app/src/cms/taskbar.ts +134 -0
  99. package/app/src/cms/term-icons.ts +10 -0
  100. package/app/src/cms/traffic.ts +26 -0
  101. package/app/src/cms/ui.ts +170 -0
  102. package/app/src/cms/updates.ts +124 -0
  103. package/app/src/cms/uploads.ts +26 -0
  104. package/app/src/cms/worker.ts +13 -0
  105. package/app/src/config/auth.ts +30 -0
  106. package/app/src/config/cms.ts +18 -0
  107. package/app/src/dashboard/access.ts +344 -0
  108. package/app/src/dashboard/agent-icons.ts +44 -0
  109. package/app/src/dashboard/app-passwords.ts +62 -0
  110. package/app/src/dashboard/avatar-field.ts +58 -0
  111. package/app/src/dashboard/bulk.ts +22 -0
  112. package/app/src/dashboard/head.ts +29 -0
  113. package/app/src/dashboard/icons.ts +15 -0
  114. package/app/src/dashboard/list-table.ts +28 -0
  115. package/app/src/dashboard/modules/roles.ts +15 -0
  116. package/app/src/dashboard/modules/sessions.ts +15 -0
  117. package/app/src/dashboard/modules/settings.ts +15 -0
  118. package/app/src/dashboard/modules/users.ts +18 -0
  119. package/app/src/dashboard/page.ts +67 -0
  120. package/app/src/dashboard/registry.ts +18 -0
  121. package/app/src/dashboard/session-list.ts +98 -0
  122. package/app/src/dashboard/tabs.ts +2 -0
  123. package/app/src/dashboard/time-ago.ts +16 -0
  124. package/app/src/dashboard/types.ts +43 -0
  125. package/app/src/dashboard/user-sections.ts +172 -0
  126. package/app/src/lib/permissions.ts +84 -0
  127. package/app/src/middlewares/auth.ts +117 -0
  128. package/app/src/pages/(site)/[...path]/index.ts +609 -0
  129. package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
  130. package/app/src/pages/(site)/feed/index.ts +12 -0
  131. package/app/src/pages/(site)/index.ts +11 -0
  132. package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
  133. package/app/src/pages/(site)/layout.ts +219 -0
  134. package/app/src/pages/(site)/llms.txt/index.ts +23 -0
  135. package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
  136. package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
  137. package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
  138. package/app/src/pages/(site)/robots.txt/index.ts +29 -0
  139. package/app/src/pages/(site)/search/index.ts +36 -0
  140. package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
  141. package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
  142. package/app/src/pages/api/auth/session.ts +48 -0
  143. package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
  144. package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
  145. package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
  146. package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
  147. package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
  148. package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
  149. package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
  150. package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
  151. package/app/src/pages/api/cms/cache/purge.ts +6 -0
  152. package/app/src/pages/api/cms/collections/index.ts +6 -0
  153. package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
  154. package/app/src/pages/api/cms/comments/[id].ts +9 -0
  155. package/app/src/pages/api/cms/comments/index.ts +126 -0
  156. package/app/src/pages/api/cms/comments/queue.ts +6 -0
  157. package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
  158. package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
  159. package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
  160. package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
  161. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
  162. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
  163. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
  164. package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
  165. package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
  166. package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
  167. package/app/src/pages/api/cms/export/[collection].ts +37 -0
  168. package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
  169. package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
  170. package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
  171. package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
  172. package/app/src/pages/api/cms/import/[collection].ts +23 -0
  173. package/app/src/pages/api/cms/mcp.ts +29 -0
  174. package/app/src/pages/api/cms/me/index.ts +6 -0
  175. package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
  176. package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
  177. package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
  178. package/app/src/pages/api/cms/media/[id].ts +6 -0
  179. package/app/src/pages/api/cms/media.ts +26 -0
  180. package/app/src/pages/api/cms/menus/[location].ts +14 -0
  181. package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
  182. package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
  183. package/app/src/pages/api/cms/network/sites/index.ts +14 -0
  184. package/app/src/pages/api/cms/notes/[id].ts +13 -0
  185. package/app/src/pages/api/cms/notes/index.ts +6 -0
  186. package/app/src/pages/api/cms/payments/webhook.ts +28 -0
  187. package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
  188. package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
  189. package/app/src/pages/api/cms/plugins/index.ts +6 -0
  190. package/app/src/pages/api/cms/recovery.ts +29 -0
  191. package/app/src/pages/api/cms/redirects/index.ts +9 -0
  192. package/app/src/pages/api/cms/roles/index.ts +6 -0
  193. package/app/src/pages/api/cms/schema/[collection].ts +13 -0
  194. package/app/src/pages/api/cms/search.ts +16 -0
  195. package/app/src/pages/api/cms/settings/[group].ts +9 -0
  196. package/app/src/pages/api/cms/settings/index.ts +9 -0
  197. package/app/src/pages/api/cms/site-export.ts +34 -0
  198. package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
  199. package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
  200. package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
  201. package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
  202. package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
  203. package/app/src/pages/api/cms/uploads/index.ts +26 -0
  204. package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
  205. package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
  206. package/app/src/pages/api/cms/users/index.ts +12 -0
  207. package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
  208. package/app/src/pages/api/cms/webhooks/index.ts +9 -0
  209. package/app/src/pages/auth/[provider]/callback.ts +11 -0
  210. package/app/src/pages/auth/[provider]/redirect.ts +9 -0
  211. package/app/src/pages/auth/forgot-password/index.ts +82 -0
  212. package/app/src/pages/auth/layout.ts +32 -0
  213. package/app/src/pages/auth/login/index.ts +205 -0
  214. package/app/src/pages/auth/magic/index.ts +68 -0
  215. package/app/src/pages/auth/register/index.ts +124 -0
  216. package/app/src/pages/auth/reset-password/index.ts +74 -0
  217. package/app/src/pages/auth/setup/index.ts +194 -0
  218. package/app/src/pages/auth/two-factor/index.ts +69 -0
  219. package/app/src/pages/auth/verify/index.ts +62 -0
  220. package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
  221. package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
  222. package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
  223. package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
  224. package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
  225. package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
  226. package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
  227. package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
  228. package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
  229. package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
  230. package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
  231. package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
  232. package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
  233. package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
  234. package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
  235. package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
  236. package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
  237. package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
  238. package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
  239. package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
  240. package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
  241. package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
  242. package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
  243. package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
  244. package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
  245. package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
  246. package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
  247. package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
  248. package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
  249. package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
  250. package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
  251. package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
  252. package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
  253. package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
  254. package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
  255. package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
  256. package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
  257. package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
  258. package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
  259. package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
  260. package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
  261. package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
  262. package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
  263. package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
  264. package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
  265. package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
  266. package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
  267. package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
  268. package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
  269. package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
  270. package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
  271. package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
  272. package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
  273. package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
  274. package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
  275. package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
  276. package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
  277. package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +183 -0
  278. package/app/src/pages/dashboard/index.ts +214 -0
  279. package/app/src/pages/dashboard/layout.ts +227 -0
  280. package/app/src/pages/dashboard/profile/index.ts +211 -0
  281. package/app/src/pages/dashboard/profile/security/index.ts +249 -0
  282. package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
  283. package/app/src/pages/dashboard/roles/index.ts +134 -0
  284. package/app/src/pages/dashboard/roles/new/index.ts +95 -0
  285. package/app/src/pages/dashboard/sessions/index.ts +105 -0
  286. package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
  287. package/app/src/pages/dashboard/users/index.ts +299 -0
  288. package/app/src/pages/dashboard/users/new/index.ts +123 -0
  289. package/app/src/passkeys.client.ts +18 -0
  290. package/app/src/plugins/default-theme/assets/cover.svg +31 -0
  291. package/app/src/plugins/default-theme/assets/logo.svg +8 -0
  292. package/app/src/plugins/default-theme/parts/comments.ts +66 -0
  293. package/app/src/plugins/default-theme/parts/list.ts +38 -0
  294. package/app/src/plugins/default-theme/parts/media.ts +15 -0
  295. package/app/src/plugins/default-theme/parts/options.ts +45 -0
  296. package/app/src/plugins/default-theme/plugin.json +275 -0
  297. package/app/src/plugins/default-theme/templates/archive.ts +14 -0
  298. package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
  299. package/app/src/plugins/default-theme/templates/entry.ts +27 -0
  300. package/app/src/plugins/default-theme/templates/home.ts +8 -0
  301. package/app/src/plugins/default-theme/templates/layout.ts +40 -0
  302. package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
  303. package/app/src/plugins/default-theme/templates/search.ts +32 -0
  304. package/app/src/services/rbac.ts +65 -0
  305. package/app/src/services/roles.ts +89 -0
  306. package/app/src/services/users.ts +173 -0
  307. package/package.json +114 -2
  308. package/src/automations.ts +95 -0
  309. package/src/bindings.ts +138 -0
  310. package/src/block-references.ts +239 -0
  311. package/src/block-shape.ts +155 -0
  312. package/src/blocks.ts +1157 -0
  313. package/src/cache.ts +54 -0
  314. package/src/checks.ts +198 -0
  315. package/src/cloudflare-workers.d.ts +13 -0
  316. package/src/cloudflare.ts +61 -0
  317. package/src/collab.ts +372 -0
  318. package/src/collections.ts +421 -0
  319. package/src/comments.ts +46 -0
  320. package/src/cron.ts +95 -0
  321. package/src/dashboard-menu.ts +105 -0
  322. package/src/diff.ts +113 -0
  323. package/src/editor-layout.ts +316 -0
  324. package/src/errors.ts +50 -0
  325. package/src/field-groups.ts +498 -0
  326. package/src/fields.ts +411 -0
  327. package/src/form-builder.ts +1053 -0
  328. package/src/forms.ts +109 -0
  329. package/src/highlight.ts +134 -0
  330. package/src/hooks.ts +510 -0
  331. package/src/icon-catalog.ts +55 -0
  332. package/src/icons.ts +128 -0
  333. package/src/images.ts +149 -0
  334. package/src/index.ts +100 -0
  335. package/src/isolate-core.ts +245 -0
  336. package/src/isolate.ts +19 -0
  337. package/src/isolation.ts +69 -0
  338. package/src/mail.ts +182 -0
  339. package/src/manifest.ts +476 -0
  340. package/src/media.ts +193 -0
  341. package/src/menus.ts +287 -0
  342. package/src/module.ts +32 -0
  343. package/src/modules/content.ts +64 -0
  344. package/src/modules/forms.ts +35 -0
  345. package/src/node.ts +66 -0
  346. package/src/notes.ts +237 -0
  347. package/src/permissions.ts +139 -0
  348. package/src/plugin-settings.ts +114 -0
  349. package/src/records.ts +56 -0
  350. package/src/redirects.ts +59 -0
  351. package/src/resource.ts +245 -0
  352. package/src/richtext.ts +402 -0
  353. package/src/schema-json.ts +112 -0
  354. package/src/search.ts +89 -0
  355. package/src/seo.ts +477 -0
  356. package/src/server/accounts.ts +418 -0
  357. package/src/server/ai.ts +33 -0
  358. package/src/server/api-tokens.ts +91 -0
  359. package/src/server/areas.ts +116 -0
  360. package/src/server/audit.ts +94 -0
  361. package/src/server/auth.ts +89 -0
  362. package/src/server/automations.ts +190 -0
  363. package/src/server/autosaves.ts +69 -0
  364. package/src/server/brand-icons.ts +50 -0
  365. package/src/server/brands.ts +86 -0
  366. package/src/server/budget.ts +97 -0
  367. package/src/server/cache.ts +104 -0
  368. package/src/server/capabilities.ts +333 -0
  369. package/src/server/cloudflare.ts +92 -0
  370. package/src/server/comments.ts +237 -0
  371. package/src/server/drafts.ts +176 -0
  372. package/src/server/field-groups.ts +88 -0
  373. package/src/server/files.ts +780 -0
  374. package/src/server/forms.ts +726 -0
  375. package/src/server/handoffs.ts +107 -0
  376. package/src/server/host-schema.ts +312 -0
  377. package/src/server/host.ts +2892 -0
  378. package/src/server/images.ts +34 -0
  379. package/src/server/index.ts +59 -0
  380. package/src/server/indexnow.ts +91 -0
  381. package/src/server/isolation.ts +183 -0
  382. package/src/server/locked.ts +45 -0
  383. package/src/server/mail.ts +93 -0
  384. package/src/server/markdown.ts +24 -0
  385. package/src/server/menus.ts +286 -0
  386. package/src/server/network-policy.ts +60 -0
  387. package/src/server/network.ts +665 -0
  388. package/src/server/notes.ts +275 -0
  389. package/src/server/outbox.ts +213 -0
  390. package/src/server/path-moves.ts +33 -0
  391. package/src/server/payments.ts +59 -0
  392. package/src/server/previews.ts +62 -0
  393. package/src/server/purge.ts +140 -0
  394. package/src/server/reconcile.ts +38 -0
  395. package/src/server/redirects.ts +183 -0
  396. package/src/server/repository.ts +1107 -0
  397. package/src/server/schedules.ts +105 -0
  398. package/src/server/schema.ts +562 -0
  399. package/src/server/security.ts +391 -0
  400. package/src/server/seed.ts +52 -0
  401. package/src/server/shared-fields.ts +34 -0
  402. package/src/server/site-export.ts +151 -0
  403. package/src/server/site-import.ts +482 -0
  404. package/src/server/site-search.ts +289 -0
  405. package/src/server/site-settings.ts +286 -0
  406. package/src/server/sites.ts +243 -0
  407. package/src/server/stores.ts +314 -0
  408. package/src/server/stripe.ts +173 -0
  409. package/src/server/taxonomies.ts +415 -0
  410. package/src/server/tokens.ts +25 -0
  411. package/src/server/traffic.ts +118 -0
  412. package/src/server/users.ts +653 -0
  413. package/src/server/webhooks.ts +245 -0
  414. package/src/settings-controls.ts +54 -0
  415. package/src/settings-document.ts +111 -0
  416. package/src/settings.ts +426 -0
  417. package/src/storage/cloudflare.ts +94 -0
  418. package/src/storage/index.ts +30 -0
  419. package/src/storage/node.ts +114 -0
  420. package/src/taxonomy.ts +51 -0
  421. package/src/theme.ts +1135 -0
  422. package/src/to-markdown.ts +179 -0
  423. package/src/updates.ts +126 -0
  424. package/src/version.ts +2 -0
  425. package/src/vite.d.ts +25 -0
  426. package/src/vite.js +199 -0
  427. package/src/webhooks.ts +107 -0
@@ -0,0 +1,388 @@
1
+ /**
2
+ * The MCP tools of a site: one per management operation, over the same functions the REST
3
+ * routes and `cossack cms` use. A tool's input schema is what the client shows its model; the
4
+ * operation checks the values and the principal's permissions.
5
+ */
6
+ import type { Context } from 'hono';
7
+ import { CmsError, isCmsError } from '@cossackframework/cms';
8
+ import { ClientVisibleError } from '@cossackframework/core';
9
+ import type { JsonSchema, JsonSchemaProperty, McpTool } from './mcp';
10
+ import * as manage from './manage';
11
+
12
+ export interface ToolContext { readonly c: Context }
13
+
14
+ type Tool = McpTool<ToolContext>;
15
+ type Input = { readonly [name: string]: unknown };
16
+
17
+ const str = (description: string, extra: Partial<JsonSchemaProperty> = {}): JsonSchemaProperty => ({ type: 'string', description, ...extra });
18
+ const int = (description: string, extra: Partial<JsonSchemaProperty> = {}): JsonSchemaProperty => ({ type: 'integer', description, ...extra });
19
+ const bool = (description: string): JsonSchemaProperty => ({ type: 'boolean', description });
20
+ const obj = (description: string): JsonSchemaProperty => ({ type: 'object', description, additionalProperties: true });
21
+ const strings = (description: string): JsonSchemaProperty => ({ type: 'array', description, items: { type: 'string' } } as JsonSchemaProperty);
22
+ const schema = (properties: { [name: string]: JsonSchemaProperty }, required: string[] = []): JsonSchema => ({ type: 'object', properties, ...(required.length ? { required } : {}), additionalProperties: false });
23
+ const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false } as const;
24
+ const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } as const;
25
+ const CHANGE = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false } as const;
26
+ const DESTROY = { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false } as const;
27
+
28
+ const collection = str('The collection, such as posts or pages (see list_collections).');
29
+ const id = str('The entry ID.');
30
+ const rev = int('The revision you read, so a change made meanwhile is not overwritten (409). Left out, the current revision.');
31
+ const page = int('Page number, from 1.', { minimum: 1 });
32
+ const perPage = int('Entries per page, 1 to 100.', { minimum: 1, maximum: 100 });
33
+ const menuId = str('The menu ID (see list_menus).');
34
+ const menuItems: JsonSchemaProperty = {
35
+ type: 'array', description: 'The menu\'s items, a tree. Each has kind (link, entry, archive, term or heading), label (empty uses the target\'s title), url (link), collection (entry, archive), entry (an entry ID), taxonomy and term (a term ID), description (a line under the link in a mega menu), panel (a synced pattern\'s ID shown beside the item\'s links: a mega menu), newTab, className, attributes, meta (the field groups\' values) and children. An item with heading children or a panel opens as a mega menu; others with children as a dropdown. id is optional and made when left out.',
36
+ items: { type: 'object', additionalProperties: true },
37
+ };
38
+ const menuLocations: JsonSchemaProperty = { type: 'array', description: 'Theme location names the menu shows in, such as ["primary"] (see list_menu_locations); the complete list.', items: { type: 'string' } };
39
+ const areaName = str('The widget area\'s name, such as header (see list_widget_areas).');
40
+
41
+ /** Query strings for an operation that reads request parameters. */
42
+ function query(input: Input, names: readonly string[]): { [key: string]: string } {
43
+ const out: { [key: string]: string } = {};
44
+ for (const name of names) if (input[name] !== undefined && input[name] !== null) out[name] = String(input[name]);
45
+ return out;
46
+ }
47
+
48
+ function string(value: unknown): string {
49
+ return typeof value === 'string' ? value : '';
50
+ }
51
+
52
+ function fields(value: unknown): manage.Body {
53
+ return value && typeof value === 'object' && !Array.isArray(value) ? value as manage.Body : {};
54
+ }
55
+
56
+ export const cmsTools: readonly Tool[] = [
57
+ {
58
+ name: 'get_site', title: 'This site and who you are',
59
+ description: 'Start here: the site, who the application password acts as (roles, permissions), the content types and taxonomies, and whether the network is on.',
60
+ inputSchema: schema({}), annotations: READ,
61
+ async run(_input, { c }) {
62
+ const [who, collections, taxonomies] = await Promise.all([manage.whoami(c), manage.collectionsList(c), manage.taxonomiesList(c)]);
63
+ return { ...who, collections: collections.items.map(entry => ({ name: entry.name, label: entry.label, publishable: entry.publishable, taxonomies: entry.taxonomies })), taxonomies: taxonomies.items.map(entry => ({ name: entry.name, label: entry.label, hierarchical: entry.hierarchical })) };
64
+ },
65
+ },
66
+ {
67
+ name: 'list_collections', description: 'The content types with their fields (name, kind, required, enum values). Entries are created and changed with these field names.',
68
+ inputSchema: schema({}), annotations: READ,
69
+ async run(_input, { c }) { return manage.collectionsList(c); },
70
+ },
71
+ {
72
+ name: 'get_collection_schema', description: 'The JSON Schema of a collection\'s entries, for building a valid create_entry or update_entry call. Rich text is a ProseMirror document; blocks are { _id, type, data }.',
73
+ inputSchema: schema({ collection }, ['collection']), annotations: READ,
74
+ async run(input, { c }) { return manage.collectionSchema(c, string(input.collection)); },
75
+ },
76
+ {
77
+ name: 'list_entries', description: 'Entries of a collection, a page at a time. Without status, published entries newest first; status "any" or draft, pending, scheduled, published, trash lists others (most recently changed first). q searches; term "categories:news" filters by a term; filter matches fields by value.',
78
+ inputSchema: schema({
79
+ collection, status: str('One of draft, pending, scheduled, published, trash, or any. Default: published.'), q: str('Search words.'), page, perPage,
80
+ locale: str('A language code, on a site with several languages.'), term: str('taxonomy:slug, such as categories:news.'),
81
+ filter: { type: 'object', description: 'Field values to match, such as { "featured": true }.', additionalProperties: true },
82
+ }, ['collection']), annotations: READ,
83
+ async run(input, { c }) {
84
+ const parameters = query(input, ['status', 'q', 'page', 'perPage', 'locale', 'term']);
85
+ for (const [name, value] of Object.entries(fields(input.filter))) parameters[`filter[${name}]`] = String(value);
86
+ return manage.entriesList(c, string(input.collection), parameters);
87
+ },
88
+ },
89
+ {
90
+ name: 'search_site', title: 'Search the site',
91
+ description: 'Search the site as its visitors do: published entries they may read, from every collection or one, best first, each with its title, URL and a snippet whose parts have match: true on the words that matched. Every word is required; loose: true means nothing had them all and these have some. next: true when another page follows.',
92
+ inputSchema: schema({ q: str('What to search for: words, and "quoted phrases"; -word leaves out entries with it.'), collection: str('Only this collection (see list_collections).'), page, perPage: int('Results per page, 1 to 50.', { minimum: 1, maximum: 50 }), locale: str('A language code, on a site with several languages.') }, ['q']), annotations: READ,
93
+ async run(input, { c }) { return manage.siteSearch(c, query(input, ['q', 'collection', 'page', 'perPage', 'locale'])); },
94
+ },
95
+ {
96
+ name: 'get_entry', description: 'One entry by ID, or a published entry by slug: every field, its rev (needed to change it), URL, the synced patterns it uses and its translations. html: true adds rendered rich text and blocks.',
97
+ inputSchema: schema({ collection, id: str('The entry ID, or the slug of a published entry.'), html: bool('Also render rich text and blocks to HTML.') }, ['collection', 'id']), annotations: READ,
98
+ async run(input, { c }) {
99
+ const view = await manage.entryRead(c, string(input.collection), string(input.id), { html: input.html === true });
100
+ if (!view) throw new CmsError('CMS_NOT_FOUND', 'Entry not found.');
101
+ return view;
102
+ },
103
+ },
104
+ {
105
+ name: 'create_entry', description: 'Create an entry from its fields (see list_collections): title, status (draft by default; published publishes at once), slug, content (blocks), excerpt, taxonomy fields (term IDs), and the rest. Answers the entry with its id and rev.',
106
+ inputSchema: schema({ collection, fields: obj('The fields, as the collection declares them.') }, ['collection', 'fields']), annotations: WRITE,
107
+ async run(input, { c }) { return manage.entryCreate(c, string(input.collection), fields(input.fields)); },
108
+ },
109
+ {
110
+ name: 'update_entry', description: 'Change some fields of an entry; the others stay. Send rev from get_entry to avoid overwriting a change made meanwhile. Use publish_entry and unpublish_entry to change where it is published.',
111
+ inputSchema: schema({ collection, id, fields: obj('The fields to change.'), rev }, ['collection', 'id', 'fields']), annotations: CHANGE,
112
+ async run(input, { c }) { return manage.entryUpdate(c, string(input.collection), string(input.id), fields(input.fields), input.rev); },
113
+ },
114
+ {
115
+ name: 'delete_entry', description: 'Delete an entry permanently. To keep it recoverable, set_entry_status to trash instead.',
116
+ inputSchema: schema({ collection, id, rev }, ['collection', 'id']), annotations: DESTROY,
117
+ async run(input, { c }) { await manage.entryDelete(c, string(input.collection), string(input.id), input.rev); return { deleted: true, id: input.id }; },
118
+ },
119
+ {
120
+ name: 'publish_entry', description: 'Publish an entry now, or schedule it with a future at (ISO 8601, UTC). An entry published before keeps its date unless at is given. With "Open notes hold publishing" on, open notes refuse publishing.',
121
+ inputSchema: schema({ collection, id, at: str('When to publish, ISO 8601 such as 2026-12-01T09:00:00Z; a future time schedules. Default: now, or the entry\'s earlier publication time.'), rev }, ['collection', 'id']), annotations: CHANGE,
122
+ async run(input, { c }) { return manage.entryPublish(c, string(input.collection), string(input.id), { at: input.at, rev: input.rev }); },
123
+ },
124
+ {
125
+ name: 'unpublish_entry', description: 'Take an entry off the site: it becomes a draft and keeps its content.',
126
+ inputSchema: schema({ collection, id, rev }, ['collection', 'id']), annotations: CHANGE,
127
+ async run(input, { c }) { return manage.entryUnpublish(c, string(input.collection), string(input.id), { rev: input.rev }); },
128
+ },
129
+ {
130
+ name: 'set_entry_status', description: 'Move an entry to draft, pending (submitted for review), published or trash (recoverable; restore by setting draft).',
131
+ inputSchema: schema({ collection, id, status: str('draft, pending, published or trash.', { enum: ['draft', 'pending', 'published', 'trash'] }), rev }, ['collection', 'id', 'status']), annotations: CHANGE,
132
+ async run(input, { c }) { return manage.entrySetStatus(c, string(input.collection), string(input.id), string(input.status), input.rev); },
133
+ },
134
+ {
135
+ name: 'list_revisions', description: 'An entry\'s revisions, newest first: number, time, who, title and status then.',
136
+ inputSchema: schema({ collection, id, limit: int('How many, 1 to 100 (default 20).', { minimum: 1, maximum: 100 }) }, ['collection', 'id']), annotations: READ,
137
+ async run(input, { c }) { return manage.entryRevisions(c, string(input.collection), string(input.id), query(input, ['limit'])); },
138
+ },
139
+ {
140
+ name: 'get_revision', description: 'The full content of one revision of an entry, to compare before restoring it.',
141
+ inputSchema: schema({ collection, id, revision: int('The revision number.', { minimum: 1 }) }, ['collection', 'id', 'revision']), annotations: READ,
142
+ async run(input, { c }) { return manage.entryRevision(c, string(input.collection), string(input.id), Number(input.revision)); },
143
+ },
144
+ {
145
+ name: 'restore_revision', description: 'Restore a revision\'s fields as a new revision. The entry\'s status, publication time and place stay as they are.',
146
+ inputSchema: schema({ collection, id, revision: int('The revision number to restore.', { minimum: 1 }), rev }, ['collection', 'id', 'revision']), annotations: CHANGE,
147
+ async run(input, { c }) { return manage.entryRestore(c, string(input.collection), string(input.id), Number(input.revision), input.rev); },
148
+ },
149
+ {
150
+ name: 'list_notes', description: 'Review notes: an entry\'s threads (each a root with its replies) when collection and id are given, otherwise the entries with notes across the site. status keeps open or resolved threads.',
151
+ inputSchema: schema({ collection: str('The collection, with id, for one entry\'s notes.'), id: str('The entry ID, with collection.'), status: str('open or resolved.', { enum: ['open', 'resolved'] }), limit: int('Across the site: how many entries, 1 to 100.', { minimum: 1, maximum: 100 }) }), annotations: READ,
152
+ async run(input, { c }) {
153
+ return input.collection && input.id ? manage.notesForEntry(c, string(input.collection), string(input.id), input.status === undefined ? undefined : string(input.status)) : manage.notesAcross(c, input.status === undefined ? undefined : string(input.status), input.limit);
154
+ },
155
+ },
156
+ {
157
+ name: 'add_note', description: 'Leave a review note on an entry (a new thread), or reply to a thread with parentId. target anchors a thread: entry (default), field:<name>, block:<field>:<blockId>, or text:<field>:<blockId>.text with quote for a passage. Mention someone as @[Name](userId).',
158
+ inputSchema: schema({ collection, id, body: str('The note text.'), target: str('entry, field:<name>, block:<field>:<blockId> or text:<field>:<blockId>.text. Default entry.'), quote: str('The quoted passage, for a text target.'), parentId: str('The thread\'s root note ID, for a reply.') }, ['collection', 'id', 'body']), annotations: WRITE,
159
+ async run(input, { c }) { return manage.noteAdd(c, string(input.collection), string(input.id), input); },
160
+ },
161
+ {
162
+ name: 'update_note', description: 'Edit a note\'s body (its author only) or resolve/reopen a thread by its root note (status).',
163
+ inputSchema: schema({ noteId: str('The note ID.'), body: str('The new text.'), status: str('open or resolved, on a thread\'s root.', { enum: ['open', 'resolved'] }) }, ['noteId']), annotations: CHANGE,
164
+ async run(input, { c }) { return manage.noteChange(c, string(input.noteId), input); },
165
+ },
166
+ {
167
+ name: 'delete_note', description: 'Remove a note (its author, or a user administrator); a thread\'s root takes its replies.',
168
+ inputSchema: schema({ noteId: str('The note ID.') }, ['noteId']), annotations: DESTROY,
169
+ async run(input, { c }) { await manage.noteRemove(c, string(input.noteId)); return { deleted: true, noteId: input.noteId }; },
170
+ },
171
+ {
172
+ name: 'list_users', description: 'The site\'s users with their roles, a page at a time. q searches names and emails; role keeps one role\'s holders.',
173
+ inputSchema: schema({ q: str('Search words.'), role: str('A role ID, such as editor.'), page, perPage }), annotations: READ,
174
+ async run(input, { c }) { return manage.usersList(c, query(input, ['q', 'role', 'page', 'perPage'])); },
175
+ },
176
+ {
177
+ name: 'get_user', description: 'One user by ID or email.',
178
+ inputSchema: schema({ id: str('The user ID, or an email address.') }, ['id']), annotations: READ,
179
+ async run(input, { c }) { return manage.userGet(c, string(input.id)); },
180
+ },
181
+ {
182
+ name: 'create_user', description: 'Create a user with an email, a password (8+ characters) and optional name and roles (role IDs; role managers only; otherwise the default role).',
183
+ inputSchema: schema({ email: str('The email address.'), password: str('At least 8 characters.'), name: str('The display name.'), roles: { type: 'array', description: 'Role IDs, such as ["editor"].', items: { type: 'string' } } }, ['email', 'password']), annotations: WRITE,
184
+ async run(input, { c }) { return manage.userCreate(c, input); },
185
+ },
186
+ {
187
+ name: 'update_user', description: 'Change a user\'s name, email, password, roles (role managers) or status (active or disabled).',
188
+ inputSchema: schema({ id: str('The user ID.'), name: str('The display name.'), email: str('The email address.'), password: str('A new password, 8+ characters.'), roles: { type: 'array', description: 'The complete list of role IDs.', items: { type: 'string' } }, status: str('active or disabled.', { enum: ['active', 'disabled'] }) }, ['id']), annotations: CHANGE,
189
+ async run(input, { c }) { return manage.userUpdate(c, string(input.id), input); },
190
+ },
191
+ {
192
+ name: 'delete_user', description: 'Delete a user (on an added site, remove the member). Their content keeps its author. Never your own account.',
193
+ inputSchema: schema({ id: str('The user ID.') }, ['id']), annotations: DESTROY,
194
+ async run(input, { c }) { await manage.userDelete(c, string(input.id)); return { deleted: true, id: input.id }; },
195
+ },
196
+ {
197
+ name: 'list_roles', description: 'The roles with their permissions and how many users hold each.',
198
+ inputSchema: schema({}), annotations: READ,
199
+ async run(_input, { c }) { return manage.rolesList(c); },
200
+ },
201
+ {
202
+ name: 'get_settings', description: 'The settings you may edit as { group: { field: value } }, or one group with its fields described (general, reading, writing, discussion, seo, media, …).',
203
+ inputSchema: schema({ group: str('A settings group ID, for its values and field descriptions.') }), annotations: READ,
204
+ async run(input, { c }) { return manage.settingsRead(c, input.group === undefined ? undefined : string(input.group)); },
205
+ },
206
+ {
207
+ name: 'update_settings', description: 'Change some fields of a settings group; the others keep their values. Read the group first for its field names and kinds.',
208
+ inputSchema: schema({ group: str('The settings group ID.'), values: obj('Field values, such as { "siteTitle": "My site" }.') }, ['group', 'values']), annotations: CHANGE,
209
+ async run(input, { c }) { return manage.settingsUpdate(c, string(input.group), fields(input.values)); },
210
+ },
211
+ {
212
+ name: 'list_webhooks', description: 'The site\'s webhooks: what URL each posts to, for which events and collections, and whether it is active.',
213
+ inputSchema: schema({}), annotations: READ,
214
+ async run(_input, { c }) { return manage.webhooksList(c); },
215
+ },
216
+ {
217
+ name: 'create_webhook', description: 'Add a webhook. events: entry.created, entry.updated, entry.published, entry.unpublished, entry.deleted, form.submitted, note.created, note.resolved, payment.completed. The answer carries the signing secret once.',
218
+ inputSchema: schema({ name: str('A name for the webhook.'), url: str('The https URL to post to.'), events: strings('The events it receives.'), collections: strings('Only these collections; none means every collection.'), active: bool('Whether it posts; default true.') }, ['name', 'url', 'events']), annotations: CHANGE,
219
+ async run(input, { c }) { return manage.webhookCreate(c, input); },
220
+ },
221
+ {
222
+ name: 'delete_webhook', description: 'Remove a webhook and its delivery log.',
223
+ inputSchema: schema({ id: str('The webhook ID.') }, ['id']), annotations: DESTROY,
224
+ async run(input, { c }) { await manage.webhookDelete(c, string(input.id)); return { deleted: true }; },
225
+ },
226
+ {
227
+ name: 'list_comments', description: 'Comments by status, pending (the moderation queue) by default, newest first.',
228
+ inputSchema: schema({ status: str('pending, approved, spam or trash.'), q: str('Search words.'), page, perPage: int('Comments per page, 1 to 200.', { minimum: 1, maximum: 200 }) }), annotations: READ,
229
+ async run(input, { c }) { return manage.commentsQueue(c, query(input, ['status', 'q', 'page', 'perPage'])); },
230
+ },
231
+ {
232
+ name: 'moderate_comment', description: 'Approve a comment, hold it as pending, mark it as spam or trash it.',
233
+ inputSchema: schema({ id: str('The comment ID.'), status: str('approved, pending, spam or trash.') }, ['id', 'status']), annotations: CHANGE,
234
+ async run(input, { c }) { return manage.commentModerate(c, string(input.id), { status: input.status }); },
235
+ },
236
+ {
237
+ name: 'purge_cache', description: 'Purge the caches in front of the site (Cloudflare, or a plugin\'s CDN): every page, or the cache tags and URLs given. Changes made through the CMS purge their own pages; use this after a change made outside it.',
238
+ inputSchema: schema({ tags: strings('Cache tags to purge, such as cms:main:c:posts; none means every page.'), urls: strings('Page URLs to purge.') }), annotations: CHANGE,
239
+ async run(input, { c }) { return manage.cachePurge(c, { tags: input.tags, urls: input.urls }); },
240
+ },
241
+ {
242
+ name: 'list_taxonomies', description: 'The taxonomies (categories, tags and others) with whether their terms nest.',
243
+ inputSchema: schema({}), annotations: READ,
244
+ async run(_input, { c }) { return manage.taxonomiesList(c); },
245
+ },
246
+ {
247
+ name: 'list_terms', description: 'A taxonomy\'s terms with their IDs, which entries\' taxonomy fields hold. q searches names.',
248
+ inputSchema: schema({ taxonomy: str('The taxonomy, such as categories.'), q: str('Search words.'), page, perPage: int('Terms per page, 1 to 200.', { minimum: 1, maximum: 200 }) }, ['taxonomy']), annotations: READ,
249
+ async run(input, { c }) { return manage.termsList(c, string(input.taxonomy), query(input, ['q', 'page', 'perPage'])); },
250
+ },
251
+ {
252
+ name: 'create_term', description: 'Create a term (a category, a tag, …) in a taxonomy.',
253
+ inputSchema: schema({ taxonomy: str('The taxonomy, such as categories.'), name: str('The term\'s name.'), slug: str('The URL slug; made from the name when left out.'), description: str('A description.'), parent: str('The parent term ID, in a hierarchical taxonomy.') }, ['taxonomy', 'name']), annotations: WRITE,
254
+ async run(input, { c }) { return manage.termCreate(c, string(input.taxonomy), input); },
255
+ },
256
+ {
257
+ name: 'update_term', description: 'Rename or move a term, or change its slug or description.',
258
+ inputSchema: schema({ taxonomy: str('The taxonomy.'), id: str('The term ID.'), name: str('A new name.'), slug: str('A new slug.'), description: str('A new description.'), parent: str('A new parent term ID, or an empty string for the top level.') }, ['taxonomy', 'id']), annotations: CHANGE,
259
+ async run(input, { c }) { return manage.termUpdate(c, string(input.taxonomy), string(input.id), input); },
260
+ },
261
+ {
262
+ name: 'delete_term', description: 'Delete a term; entries keep their other terms.',
263
+ inputSchema: schema({ taxonomy: str('The taxonomy.'), id: str('The term ID.') }, ['taxonomy', 'id']), annotations: DESTROY,
264
+ async run(input, { c }) { await manage.termDelete(c, string(input.taxonomy), string(input.id)); return { deleted: true, id: input.id }; },
265
+ },
266
+ {
267
+ name: 'list_media', description: 'Files in the media library (their IDs go in media fields and image blocks). q searches titles and names; kind keeps image, video, audio, document or archive files.',
268
+ inputSchema: schema({ q: str('Search words.'), kind: str('image, video, audio, document or archive.', { enum: ['image', 'video', 'audio', 'document', 'archive'] }), page: { type: 'integer', description: 'The page, from 1.' }, perPage: { type: 'integer', description: 'Files a page, 40 by default and at most 100.' } }), annotations: READ,
269
+ async run(input, { c }) { return manage.mediaList(c, query(input, ['q', 'kind', 'page', 'perPage'])); },
270
+ },
271
+ {
272
+ name: 'update_media', description: 'Change a library file\'s title, alternative text (read where an image cannot be seen), caption or description.',
273
+ inputSchema: schema({ id: str('The file\'s ID (see list_media).'), title: str('The title.'), alt: str('The alternative text.'), caption: str('The caption.'), description: str('The description.') }, ['id']), annotations: CHANGE,
274
+ async run(input, { c }) { return manage.mediaUpdate(c, string(input.id), Object.fromEntries(['title', 'alt', 'caption', 'description'].filter(name => typeof input[name] === 'string').map(name => [name, input[name]]))); },
275
+ },
276
+ {
277
+ name: 'list_menus', description: 'The site\'s navigation menus: ID, name, how many items and the theme locations each shows in.',
278
+ inputSchema: schema({}), annotations: READ,
279
+ async run(_input, { c }) { return manage.menusList(c); },
280
+ },
281
+ {
282
+ name: 'get_menu', description: 'One menu with its items tree (every item\'s id, kind, label, target, description, panel and children), its rev (needed to change it) and locations.',
283
+ inputSchema: schema({ id: menuId }, ['id']), annotations: READ,
284
+ async run(input, { c }) { return manage.menuRead(c, string(input.id)); },
285
+ },
286
+ {
287
+ name: 'create_menu', description: 'Create a menu from a name and its items, and show it at theme locations. For a mega menu, give a top-level item heading children (one column each, with links under them) and/or a panel: the ID of a synced pattern (an entry of the patterns collection) rendered beside its links.',
288
+ inputSchema: schema({ name: str('The menu\'s name, for the dashboard.'), items: menuItems, locations: menuLocations }, ['name']), annotations: WRITE,
289
+ async run(input, { c }) { return manage.menuCreate(c, input); },
290
+ },
291
+ {
292
+ name: 'update_menu', description: 'Rename a menu, replace its items (the whole tree: read it first with get_menu and send it back changed) or set exactly the locations it shows in. Send rev from get_menu so a change made meanwhile is not overwritten.',
293
+ inputSchema: schema({ id: menuId, name: str('A new name.'), items: menuItems, locations: menuLocations, rev }, ['id']), annotations: CHANGE,
294
+ async run(input, { c }) { return manage.menuUpdate(c, string(input.id), input); },
295
+ },
296
+ {
297
+ name: 'delete_menu', description: 'Delete a menu; the locations it held show no menu (primary then lists the top-level pages).',
298
+ inputSchema: schema({ id: menuId }, ['id']), annotations: DESTROY,
299
+ async run(input, { c }) { await manage.menuDelete(c, string(input.id)); return { deleted: true, id: input.id }; },
300
+ },
301
+ {
302
+ name: 'list_themes', description: 'The themes the site may use, the active one marked, each with the problems that keep it from being used.',
303
+ inputSchema: schema({}), annotations: READ,
304
+ async run(_input, { c }) { return manage.themesList(c); },
305
+ },
306
+ {
307
+ name: 'activate_theme', description: 'Make a theme the site\'s: its templates draw every page, its menu locations and widget areas apply, and its patterns and field groups are stored.',
308
+ inputSchema: schema({ name: str('The theme\'s name (see list_themes).') }, ['name']), annotations: CHANGE,
309
+ async run(input, { c }) { return manage.themeActivate(c, string(input.name)); },
310
+ },
311
+ {
312
+ name: 'list_menu_locations', description: 'The themes\' menu locations (the active theme\'s first, such as primary and footer) and the menu shown at each.',
313
+ inputSchema: schema({}), annotations: READ,
314
+ async run(_input, { c }) { return manage.menuLocationsList(c); },
315
+ },
316
+ {
317
+ name: 'assign_menu_location', description: 'Show a menu at a theme location, replacing the one there; an empty menu shows none.',
318
+ inputSchema: schema({ location: str('The location name, such as primary.'), menu: str('The menu ID, or an empty string for no menu.') }, ['location', 'menu']), annotations: CHANGE,
319
+ async run(input, { c }) { return manage.menuLocationAssign(c, string(input.location), { menu: string(input.menu) || null }); },
320
+ },
321
+ {
322
+ name: 'list_widget_areas', description: 'The themes\' widget areas (header, footer, sidebars; the active theme\'s first) with the blocks each shows: the theme\'s defaults until the site saves its own (saved false, rev 0).',
323
+ inputSchema: schema({}), annotations: READ,
324
+ async run(_input, { c }) { return manage.areasList(c); },
325
+ },
326
+ {
327
+ name: 'get_widget_area', description: 'One widget area with its blocks and rev (0 while the theme\'s defaults show), to change and send back with update_widget_area.',
328
+ inputSchema: schema({ name: areaName }, ['name']), annotations: READ,
329
+ async run(input, { c }) { return manage.areaRead(c, string(input.name)); },
330
+ },
331
+ {
332
+ name: 'update_widget_area', description: 'Replace a widget area\'s blocks: the whole list ({ _id, type, data, children? }, such as core/site-logo, core/navigation with a location, core/search, core/group). Send rev from get_widget_area.',
333
+ inputSchema: schema({ name: areaName, blocks: { type: 'array', description: 'The area\'s blocks.', items: { type: 'object', additionalProperties: true } }, rev: int('The rev you read; 0 while the theme\'s defaults show.', { minimum: 0 }) }, ['name', 'blocks']), annotations: CHANGE,
334
+ async run(input, { c }) { return manage.areaUpdate(c, string(input.name), input); },
335
+ },
336
+ {
337
+ name: 'reset_widget_area', description: 'Forget a widget area\'s saved blocks: the theme\'s defaults show again.',
338
+ inputSchema: schema({ name: areaName }, ['name']), annotations: DESTROY,
339
+ async run(input, { c }) { await manage.areaReset(c, string(input.name)); return { reset: true, name: input.name }; },
340
+ },
341
+ {
342
+ name: 'list_sites', description: 'The network\'s sites (network admins, on the network host): the main site first, then the added sites with their addresses and status. Reach another site by connecting with ?site=<id>.',
343
+ inputSchema: schema({ q: str('Search names and addresses.'), status: str('active, archived or deleted.', { enum: ['active', 'archived', 'deleted'] }), page, perPage: int('Sites per page, 1 to 200.', { minimum: 1, maximum: 200 }) }), annotations: READ,
344
+ async run(input, { c }) { return manage.sitesList(c, query(input, ['q', 'status', 'page', 'perPage'])); },
345
+ },
346
+ {
347
+ name: 'get_network_site', description: 'One site of the network with its domains (main for the main site).',
348
+ inputSchema: schema({ id: str('The site ID.') }, ['id']), annotations: READ,
349
+ async run(input, { c }) { return manage.siteGet(c, string(input.id)); },
350
+ },
351
+ {
352
+ name: 'create_site', description: 'Add a site to the network: a name, an address under the network\'s subdomain (blog.example.com), its first administrator (a network account\'s email; yours when left out), a language, and starter content unless starter is false.',
353
+ inputSchema: schema({ name: str('The site\'s name.'), host: str('Its address, such as blog.example.com.'), admin: str('The first administrator\'s email (a network account).'), language: str('A language code, such as en.'), starter: bool('Start with a first post, a category, a contact form and its page (default true).'), id: str('The site ID; made from the name when left out.') }, ['name', 'host']), annotations: WRITE,
354
+ async run(input, { c }) { return manage.siteCreate(c, input); },
355
+ },
356
+ {
357
+ name: 'set_site_status', description: 'Archive a site (visitors get 503, members keep the dashboard), restore it (active), or delete it (recoverable for 30 days).',
358
+ inputSchema: schema({ id: str('The site ID.'), status: str('active, archived or deleted.', { enum: ['active', 'archived', 'deleted'] }) }, ['id', 'status']), annotations: DESTROY,
359
+ async run(input, { c }) { return manage.siteSetStatus(c, string(input.id), input.status); },
360
+ },
361
+ ];
362
+
363
+ /** A CMS refusal or validation problem becomes the tool's error result; anything else is a failure. */
364
+ export function toolError(error: unknown): { message: string; data?: unknown } | null {
365
+ if (isCmsError(error)) return { message: error.message, data: { error: error.message, code: error.code, ...(error.fields ? { fields: error.fields } : {}) } };
366
+ if (error instanceof ClientVisibleError) return { message: error.message, data: { error: error.message, code: 'CMS_VALIDATION' } };
367
+ return null;
368
+ }
369
+
370
+ /** What the client's model reads after connecting: how this site's content works. */
371
+ export async function siteInstructions(c: Context): Promise<string> {
372
+ const cms = c.get('cms');
373
+ const title = String(await cms.settings.get('general.siteTitle').catch(() => '')) || 'this site';
374
+ const collections = cms.collections().map(entry => `${entry.name} (${entry.label}${entry.publishable === false ? ', not published' : ''})`).join(', ');
375
+ return [
376
+ `You manage ${title}, a Cossack CMS site. Call get_site first for who you are and what the site has.`,
377
+ `Collections: ${collections || 'none yet'}. Entries have id, rev, status (draft, pending, scheduled, published, trash) and publishedAt; list_collections names every field.`,
378
+ 'Change entries with update_entry (fields only), publish_entry (now, or at a future time to schedule) and unpublish_entry. Read an entry before changing it and pass its rev.',
379
+ 'Rich text fields are ProseMirror JSON documents ({ "type": "doc", "content": [...] }); content fields are block arrays ({ "_id", "type", "data" }). get_collection_schema gives the exact shapes.',
380
+ 'Taxonomy fields hold term IDs from list_terms. Media fields hold file IDs from list_media.',
381
+ 'Review notes live on entries (list_notes, add_note); resolving a thread uses update_note with status resolved.',
382
+ 'Navigation: menus are trees of items shown at the theme\'s locations (list_menu_locations; primary is the header menu). Build one with create_menu and place it with locations or assign_menu_location. A mega menu is an item with heading children (columns) or a panel: a synced pattern (create_entry in patterns with synced true) shown beside its links.',
383
+ 'The theme\'s header, footer and sidebars are widget areas of blocks (list_widget_areas, update_widget_area); the header\'s core/navigation block names the location it renders.',
384
+ 'Layout: blocks sit in the content column unless their data.align is wide or full; a core/group with align full is a band across the page whose children keep the column (data.height short|medium|tall|screen and data.valign center make a hero). A block\'s style holds preset slugs (background, text, padding, margin, fontSize) or hex colors; containers also take gradient (a gradients preset slug), image (a media ID, with imageSize, imageRepeat, imageFixed), overlay (a color) with overlayOpacity 0-100, and video (a media ID).',
385
+ 'Section blocks for landing pages: core/card (an image or a site icon with a title, text and a link; layout overlay puts the image behind the text as one linked tile), core/compare with core/compare-item children (before and after media IDs under a handle), core/gallery (layout masonry, lightbox true for a portfolio), core/carousel (thumbnails, perView), core/video (a library file or an https url; lightbox true plays it over the page), core/steps (layout row), core/button (style primary|outline|light|link, size, icon; url may be tel: or #section), core/heading (level h1-h4; *words* between asterisks take the accent color), core/icon-list with core/icon-item children, core/testimonial, core/stat, core/pricing (one plan; put plans in core/columns), core/social-links (profile URLs; the icon comes from the address), core/map (an address or an embed URL), core/accordion with core/accordion-item children, core/tabs with core/tab children, core/spacer. Icon fields take a site icon name from get_collection_schema.',
386
+ 'Destructive tools (delete_*, reset_widget_area, set_site_status) are final or hard to undo: confirm intent before calling them.',
387
+ ].join('\n');
388
+ }