@jant/core 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/db/execute-file.js +1 -1
- package/bin/commands/db/export.js +1 -1
- package/bin/commands/migrate.js +4 -4
- package/bin/commands/posts/rebuild-html.js +1 -1
- package/bin/commands/reset-password.js +1 -1
- package/bin/commands/search/reindex.js +1 -1
- package/bin/commands/setup.js +4 -2
- package/bin/commands/site/export.js +3 -0
- package/bin/commands/site/import.js +178 -91
- package/bin/commands/site/pull-media.js +3 -2
- package/bin/commands/site/snapshot/export.js +3 -1
- package/bin/commands/site/snapshot/import.js +3 -2
- package/bin/commands/start.js +44 -0
- package/bin/commands/telegram/register-webhooks.js +1 -1
- package/bin/commands/uploads/cleanup.js +48 -9
- package/bin/jant.js +39 -4
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/runtime-target.js +1 -1
- package/bin/lib/site-pull-media.js +56 -4
- package/bin/lib/site-snapshot.js +39 -2
- package/bin/lib/sql-export.js +66 -10
- package/dist/{app-DIVtyB4m.js → app-jQI4OPRe.js} +5055 -4448
- package/dist/client/.vite/manifest.json +38 -38
- package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
- package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
- package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
- package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
- package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
- package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
- package/dist/client/_assets/client-52vQhZAv.js +296 -0
- package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-BDcCR6u1.js} +2 -2
- package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
- package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
- package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
- package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
- package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +33 -1
- package/dist/node.js +57 -13
- package/package.json +13 -18
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/import-sources.test.ts +85 -0
- package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
- package/src/__tests__/cli-commands.test.ts +40 -0
- package/src/__tests__/config-docs.test.ts +119 -16
- package/src/__tests__/custom-url-redirects.test.ts +108 -0
- package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
- package/src/__tests__/export-docs.test.ts +113 -41
- package/src/__tests__/export-feed-ids.test.ts +1 -0
- package/src/__tests__/export-format-version.test.ts +88 -0
- package/src/__tests__/export-hugo-build.test.ts +139 -4
- package/src/__tests__/export-import-roundtrip.test.ts +2 -1
- package/src/__tests__/export-service.test.ts +42 -13
- package/src/__tests__/export-smart-collection.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +287 -21
- package/src/__tests__/feed-reply-addresses.test.ts +100 -0
- package/src/__tests__/feeds-disabled.test.ts +98 -0
- package/src/__tests__/fixtures/export-format/1.json +76 -0
- package/src/__tests__/fixtures/export-format/2.json +80 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/export-fixtures.ts +1 -0
- package/src/__tests__/import-refused-aliases.test.ts +98 -0
- package/src/__tests__/import-site-command.test.ts +73 -8
- package/src/__tests__/public-types.test.ts +64 -0
- package/src/__tests__/release-fixtures.test.ts +79 -24
- package/src/__tests__/release-version.test.ts +84 -0
- package/src/__tests__/site-pull-media.test.ts +48 -0
- package/src/__tests__/snapshot-tables.test.ts +37 -0
- package/src/__tests__/sql-export.test.ts +21 -1
- package/src/__tests__/stored-file-headers.test.ts +94 -0
- package/src/__tests__/template-deploy-workflow.test.ts +101 -0
- package/src/__tests__/theme-docs.test.ts +113 -24
- package/src/__tests__/toolchain-versions.test.ts +54 -0
- package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
- package/src/__tests__/vite-config-graph.test.ts +98 -0
- package/src/app.tsx +89 -66
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
- package/src/client/__tests__/compose-bridge.test.ts +87 -0
- package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
- package/src/client/__tests__/footnote-rail.test.ts +1 -1
- package/src/client/__tests__/lazy-entries.test.ts +1 -1
- package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
- package/src/client/avatar-upload.ts +10 -10
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
- package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
- package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
- package/src/client/components/compose-types.ts +14 -0
- package/src/client/components/jant-compose-dialog.ts +96 -41
- package/src/client/components/jant-compose-editor.ts +21 -4
- package/src/client/components/jant-config-editor.ts +4 -6
- package/src/client/components/jant-media-lightbox.ts +4 -4
- package/src/client/components/jant-settings-general.ts +0 -4
- package/src/client/components/nav-manager-types.ts +6 -5
- package/src/client/compose-bridge.ts +15 -4
- package/src/client/compose-launch.ts +4 -6
- package/src/client/compose-shortcuts.ts +1 -1
- package/src/client/footnote-rail.ts +1 -1
- package/src/client/lazy-entries.ts +1 -1
- package/src/client/media-scroll-hint.ts +2 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
- package/src/client/tiptap/markdown-clipboard.ts +50 -2
- package/src/client/upload-session.ts +7 -6
- package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
- package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
- package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
- package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
- package/src/i18n/locales/public/en.po +46 -48
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +45 -46
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +45 -46
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +15 -29
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +15 -29
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +15 -29
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +43 -2
- package/src/lib/__tests__/api-settings.test.ts +3 -3
- package/src/lib/__tests__/constants.test.ts +10 -0
- package/src/lib/__tests__/discover.test.ts +8 -9
- package/src/lib/__tests__/env-values.test.ts +125 -0
- package/src/lib/__tests__/feed-path.test.ts +29 -0
- package/src/lib/__tests__/feed.test.ts +50 -22
- package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
- package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
- package/src/lib/__tests__/rate-limit.test.ts +22 -7
- package/src/lib/__tests__/resolve-config.test.ts +5 -3
- package/src/lib/__tests__/schemas.test.ts +72 -23
- package/src/lib/__tests__/slugify.test.ts +9 -0
- package/src/lib/__tests__/startup-config.test.ts +12 -0
- package/src/lib/__tests__/storage-s3.test.ts +214 -0
- package/src/lib/__tests__/theme.test.ts +20 -1
- package/src/lib/__tests__/time.test.ts +56 -0
- package/src/lib/__tests__/timeline.test.ts +46 -0
- package/src/lib/__tests__/url-fetch.test.ts +65 -1
- package/src/lib/__tests__/url.test.ts +60 -1
- package/src/lib/api-nav-items.ts +16 -20
- package/src/lib/api-post-input.ts +34 -1
- package/src/lib/api-posts.ts +125 -23
- package/src/lib/api-public-posts.ts +28 -37
- package/src/lib/api-search.ts +49 -2
- package/src/lib/api-settings.ts +159 -54
- package/src/lib/api-threads.ts +34 -11
- package/src/lib/constants.ts +6 -0
- package/src/lib/discover.ts +7 -23
- package/src/lib/env-values.ts +140 -0
- package/src/lib/env.ts +203 -12
- package/src/lib/feed-path.ts +8 -2
- package/src/lib/feed-policy.ts +110 -7
- package/src/lib/feed.ts +69 -25
- package/src/lib/filter-dimensions.ts +17 -10
- package/src/lib/github-sync-site-config.ts +1 -0
- package/src/lib/hugo-markdown.ts +5 -6
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-list-cursor.ts +33 -29
- package/src/lib/public-storage.ts +43 -0
- package/src/lib/rate-limit.ts +31 -16
- package/src/lib/render.tsx +5 -0
- package/src/lib/resolve-config.ts +16 -19
- package/src/lib/schemas.ts +248 -180
- package/src/lib/slugify.ts +6 -1
- package/src/lib/sse.ts +1 -1
- package/src/lib/startup-config.ts +20 -1
- package/src/lib/theme.ts +8 -5
- package/src/lib/thread-fold.ts +6 -0
- package/src/lib/thread-query.ts +19 -24
- package/src/lib/time.ts +137 -17
- package/src/lib/timeline.ts +56 -13
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/middleware/__tests__/auth.test.ts +27 -0
- package/src/middleware/__tests__/cors.test.ts +54 -0
- package/src/middleware/__tests__/cross-origin.test.ts +149 -0
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/cors.ts +4 -4
- package/src/middleware/cross-origin.ts +124 -0
- package/src/middleware/error-handler.ts +7 -0
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +8 -2
- package/src/node/__tests__/cli-migrate.test.ts +2 -2
- package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
- package/src/node/__tests__/cli-sql-export.test.ts +25 -1
- package/src/node/__tests__/cli-start.test.ts +66 -0
- package/src/node/__tests__/request-handler.test.ts +37 -0
- package/src/node/__tests__/runtime.test.ts +56 -1
- package/src/node/request-handler.ts +58 -5
- package/src/node/runtime.ts +37 -11
- package/src/preset.css +3 -3
- package/src/routes/__tests__/compose.test.ts +84 -0
- package/src/routes/api/__tests__/collections.test.ts +68 -0
- package/src/routes/api/__tests__/mcp.test.ts +164 -9
- package/src/routes/api/__tests__/media.test.ts +9 -1
- package/src/routes/api/__tests__/nav-items.test.ts +27 -1
- package/src/routes/api/__tests__/posts.test.ts +269 -78
- package/src/routes/api/__tests__/search.test.ts +17 -4
- package/src/routes/api/__tests__/settings.test.ts +119 -85
- package/src/routes/api/__tests__/telegram.test.ts +11 -6
- package/src/routes/api/__tests__/threads.test.ts +11 -0
- package/src/routes/api/__tests__/upload-response.test.ts +48 -0
- package/src/routes/api/__tests__/uploads.test.ts +35 -2
- package/src/routes/api/collections.ts +3 -3
- package/src/routes/api/custom-urls.ts +2 -1
- package/src/routes/api/export.ts +1 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
- package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
- package/src/routes/api/internal/sites.ts +16 -4
- package/src/routes/api/mcp.ts +1 -0
- package/src/routes/api/media.ts +7 -8
- package/src/routes/api/nav-items.ts +2 -1
- package/src/routes/api/posts.ts +18 -24
- package/src/routes/api/public/__tests__/posts.test.ts +15 -0
- package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
- package/src/routes/api/public/__tests__/threads.test.ts +41 -9
- package/src/routes/api/public/posts.ts +2 -2
- package/src/routes/api/public/threads.ts +16 -26
- package/src/routes/api/search.ts +7 -41
- package/src/routes/api/settings.ts +32 -28
- package/src/routes/api/smart-collections.ts +6 -1
- package/src/routes/api/threads.ts +25 -26
- package/src/routes/api/upload.ts +6 -21
- package/src/routes/api/uploads.ts +14 -20
- package/src/routes/auth/__tests__/dev.test.ts +16 -13
- package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
- package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
- package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
- package/src/routes/auth/__tests__/signin.test.ts +167 -2
- package/src/routes/auth/dev.ts +4 -6
- package/src/routes/auth/hosted-sso.ts +9 -6
- package/src/routes/auth/setup.tsx +35 -5
- package/src/routes/auth/signin.tsx +96 -1
- package/src/routes/compose.tsx +47 -47
- package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
- package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
- package/src/routes/dash/custom-urls.tsx +2 -0
- package/src/routes/dash/settings.tsx +79 -32
- package/src/routes/feed/__tests__/feed.test.ts +93 -3
- package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
- package/src/routes/feed/feed.ts +128 -175
- package/src/routes/feed/sitemap.ts +9 -7
- package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
- package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
- package/src/routes/pages/__tests__/collections.test.ts +3 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +34 -2
- package/src/routes/pages/__tests__/search.test.ts +5 -2
- package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
- package/src/routes/pages/archive.tsx +33 -94
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +13 -84
- package/src/routes/pages/collections.tsx +2 -0
- package/src/routes/pages/featured.tsx +7 -2
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/latest.tsx +6 -2
- package/src/routes/pages/new.tsx +1 -0
- package/src/routes/pages/page.tsx +73 -47
- package/src/routes/pages/search.tsx +5 -3
- package/src/routes/pages/smart-collection.tsx +11 -70
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/pages/theme-sample.tsx +1 -0
- package/src/runtime/__tests__/readiness.test.ts +16 -0
- package/src/runtime/cloudflare.ts +2 -3
- package/src/runtime/index.ts +3 -1
- package/src/runtime/node.ts +3 -5
- package/src/runtime/readiness.ts +5 -0
- package/src/services/__tests__/auth.test.ts +115 -0
- package/src/services/__tests__/collection.test.ts +9 -0
- package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
- package/src/services/__tests__/hosted-handoff.test.ts +208 -1
- package/src/services/__tests__/media.test.ts +47 -27
- package/src/services/__tests__/navigation.test.ts +67 -15
- package/src/services/__tests__/post.test.ts +103 -56
- package/src/services/__tests__/search.test.ts +38 -0
- package/src/services/__tests__/settings.test.ts +2 -14
- package/src/services/__tests__/smart-collection.test.ts +2 -2
- package/src/services/__tests__/telegram-ingest.test.ts +113 -0
- package/src/services/__tests__/thread.test.ts +26 -11
- package/src/services/auth.ts +36 -4
- package/src/services/collection.ts +46 -5
- package/src/services/custom-url.ts +11 -4
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +2 -2
- package/src/services/export-theme/layouts/_default/baseof.html +1 -1
- package/src/services/export-theme/layouts/collection/single.html +1 -1
- package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
- package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
- package/src/services/export-theme/styles/main.css +3 -3
- package/src/services/export.ts +68 -19
- package/src/services/github-sync.ts +10 -10
- package/src/services/hosted-handoff.ts +106 -6
- package/src/services/index.ts +3 -1
- package/src/services/language.ts +33 -0
- package/src/services/mcp.ts +176 -438
- package/src/services/media.ts +69 -21
- package/src/services/navigation.ts +19 -4
- package/src/services/path.ts +45 -3
- package/src/services/post.ts +329 -214
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +36 -3
- package/src/services/site-admin.ts +1 -0
- package/src/services/smart-collection.ts +10 -3
- package/src/services/telegram.ts +23 -6
- package/src/services/thread.ts +11 -3
- package/src/services/upload-session.ts +14 -15
- package/src/styles/components.css +2 -2
- package/src/styles/site-media.css +2 -2
- package/src/styles/tokens.css +19 -22
- package/src/styles/ui-author.css +73 -94
- package/src/styles/ui.css +62 -62
- package/src/types/app-context.ts +5 -1
- package/src/types/bindings.ts +11 -0
- package/src/types/config.ts +4 -4
- package/src/types/constants.ts +20 -0
- package/src/types/props.ts +34 -8
- package/src/types/views.ts +28 -13
- package/src/ui/color-themes.ts +6 -5
- package/src/ui/dash/settings/GeneralContent.tsx +0 -22
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
- package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
- package/src/ui/feed/LinkCard.tsx +1 -2
- package/src/ui/feed/NoteCard.tsx +1 -2
- package/src/ui/feed/QuoteCard.tsx +2 -2
- package/src/ui/feed/ThreadPreview.tsx +6 -6
- package/src/ui/feed/TimelineFeed.tsx +1 -7
- package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
- package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
- package/src/ui/layouts/BaseLayout.tsx +5 -0
- package/src/ui/pages/ArchivePage.tsx +1 -1
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +0 -1
- package/src/ui/pages/CollectionsPage.tsx +2 -2
- package/src/ui/pages/ComposePage.tsx +1 -1
- package/src/ui/pages/FeaturedPage.tsx +1 -1
- package/src/ui/pages/HomePage.tsx +1 -1
- package/src/ui/pages/PostPage.tsx +1 -1
- package/src/ui/pages/SearchPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -3
- package/src/ui/pages/SubscribePage.tsx +1 -1
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/vendor/datastar.js +9 -1956
- package/src/vendor/datastar.js.map +4 -4
- package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
- package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
- package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
- package/dist/client/_assets/client-DRuw7XCt.css +0 -2
- package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
package/src/services/mcp.ts
CHANGED
|
@@ -8,34 +8,34 @@ import {
|
|
|
8
8
|
CreatePostApiSchema,
|
|
9
9
|
FormatSchema,
|
|
10
10
|
MediaIdSchema,
|
|
11
|
+
pageLimitSchema,
|
|
12
|
+
PostContentSchema,
|
|
11
13
|
PostIdSchema,
|
|
14
|
+
SearchPostsQuerySchema,
|
|
12
15
|
StatusSchema,
|
|
13
16
|
UpdatePostApiSchema,
|
|
14
17
|
} from "../lib/schemas.js";
|
|
15
|
-
import {
|
|
16
|
-
COLLECTION_SORT_ORDERS,
|
|
17
|
-
FORMATS,
|
|
18
|
-
STATUSES,
|
|
19
|
-
THREAD_SORTS,
|
|
20
|
-
VISIBILITIES,
|
|
21
|
-
type Post,
|
|
22
|
-
} from "../types.js";
|
|
18
|
+
import { THREAD_SORTS, type Bindings, type Post } from "../types.js";
|
|
23
19
|
import type { AppConfig } from "../types/config.js";
|
|
24
20
|
import { requireStorage, type StorageDriver } from "../lib/storage.js";
|
|
25
21
|
import type { Services } from "./index.js";
|
|
26
22
|
import { CORE_VERSION } from "../lib/version.js";
|
|
27
23
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
buildApiSettingsResponse,
|
|
25
|
+
partitionApiSettingUpdates,
|
|
30
26
|
} from "../lib/api-settings.js";
|
|
31
27
|
import {
|
|
32
28
|
apiPostListOrder,
|
|
29
|
+
loadApiPostDetail,
|
|
33
30
|
loadApiPostResponse,
|
|
34
31
|
loadApiPostResponses,
|
|
35
32
|
} from "../lib/api-posts.js";
|
|
36
|
-
import {
|
|
33
|
+
import { loadSearchApiResults } from "../lib/api-search.js";
|
|
37
34
|
import { loadApiThreadResponses } from "../lib/api-threads.js";
|
|
38
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
parseThreadSelection,
|
|
37
|
+
THREAD_AUTHOR_VISIBILITIES,
|
|
38
|
+
} from "../lib/thread-query.js";
|
|
39
39
|
import {
|
|
40
40
|
ExternalServiceError,
|
|
41
41
|
NotFoundError,
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
postWriteDeps,
|
|
52
52
|
toCreatePostInput,
|
|
53
53
|
toUpdatePostInput,
|
|
54
|
+
assertUpdateFitsFormat,
|
|
54
55
|
} from "../lib/api-post-input.js";
|
|
55
56
|
|
|
56
57
|
export const MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
@@ -59,6 +60,8 @@ type JsonRpcId = string | number | null;
|
|
|
59
60
|
|
|
60
61
|
type McpHttpContext = {
|
|
61
62
|
appConfig: AppConfig;
|
|
63
|
+
/** The environment, for settings whose fallback an environment variable sets. */
|
|
64
|
+
env: Bindings;
|
|
62
65
|
services: Services;
|
|
63
66
|
storage: StorageDriver | null;
|
|
64
67
|
/**
|
|
@@ -98,12 +101,21 @@ type McpToolDefinition = {
|
|
|
98
101
|
const ListPostsToolSchema = z.object({
|
|
99
102
|
cursor: z.string().optional(),
|
|
100
103
|
format: FormatSchema.optional(),
|
|
101
|
-
limit:
|
|
104
|
+
limit: pageLimitSchema(100, 100),
|
|
102
105
|
status: StatusSchema.optional(),
|
|
106
|
+
content: PostContentSchema.optional().describe(
|
|
107
|
+
"markdown returns bodyMarkdown in place of body, bodyHtml, and bodyText",
|
|
108
|
+
),
|
|
103
109
|
});
|
|
104
110
|
|
|
105
|
-
const
|
|
106
|
-
id: PostIdSchema,
|
|
111
|
+
const PostIdToolSchema = z.object({
|
|
112
|
+
id: PostIdSchema.describe("Post TypeID"),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const GetPostToolSchema = PostIdToolSchema.extend({
|
|
116
|
+
content: PostContentSchema.optional().describe(
|
|
117
|
+
"markdown returns bodyMarkdown in place of body, bodyHtml, and bodyText",
|
|
118
|
+
),
|
|
107
119
|
});
|
|
108
120
|
|
|
109
121
|
const UpdateCollectionToolSchema = CreateCollectionSchema.partial().extend({
|
|
@@ -112,29 +124,32 @@ const UpdateCollectionToolSchema = CreateCollectionSchema.partial().extend({
|
|
|
112
124
|
});
|
|
113
125
|
|
|
114
126
|
const GetCollectionToolSchema = z.object({
|
|
115
|
-
id: CollectionIdSchema,
|
|
127
|
+
id: CollectionIdSchema.describe("Collection TypeID"),
|
|
116
128
|
});
|
|
117
129
|
|
|
130
|
+
const ListCollectionsToolSchema = z.object({
|
|
131
|
+
view: z.enum(["compose"]).optional(),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
/** A tool that takes no input. */
|
|
135
|
+
const EmptyToolSchema = z.object({});
|
|
136
|
+
|
|
118
137
|
const UpdateSettingsToolSchema = z.record(z.string(), z.string());
|
|
119
138
|
|
|
120
|
-
const SearchPostsToolSchema =
|
|
121
|
-
limit: z.coerce.number().int().min(1).max(50).optional().default(20),
|
|
122
|
-
// `q`, as `GET /api/search` names it.
|
|
123
|
-
q: z.string().trim().min(1).max(200),
|
|
124
|
-
});
|
|
139
|
+
const SearchPostsToolSchema = SearchPostsQuerySchema;
|
|
125
140
|
|
|
126
141
|
const ListMediaToolSchema = z.object({
|
|
127
|
-
limit:
|
|
142
|
+
limit: pageLimitSchema(200, 50),
|
|
128
143
|
cursor: z.string().optional(),
|
|
129
144
|
mimePrefix: z.string().trim().min(1).optional(),
|
|
130
145
|
});
|
|
131
146
|
|
|
132
147
|
const GetMediaToolSchema = z.object({
|
|
133
|
-
id: MediaIdSchema,
|
|
148
|
+
id: MediaIdSchema.describe("Media TypeID"),
|
|
134
149
|
});
|
|
135
150
|
|
|
136
151
|
const UpdateMediaAltToolSchema = z.object({
|
|
137
|
-
id: MediaIdSchema,
|
|
152
|
+
id: MediaIdSchema.describe("Media TypeID"),
|
|
138
153
|
alt: z
|
|
139
154
|
.string()
|
|
140
155
|
.max(500)
|
|
@@ -157,51 +172,39 @@ const UploadMediaToolSchema = z.object({
|
|
|
157
172
|
});
|
|
158
173
|
|
|
159
174
|
const AddCollectionThreadToolSchema = z.object({
|
|
160
|
-
collectionId: CollectionIdSchema,
|
|
161
|
-
threadId: PostIdSchema,
|
|
175
|
+
collectionId: CollectionIdSchema.describe("Collection TypeID"),
|
|
176
|
+
threadId: PostIdSchema.describe("TypeID of any post in the Thread"),
|
|
162
177
|
});
|
|
163
178
|
|
|
164
179
|
const RemoveCollectionThreadToolSchema = AddCollectionThreadToolSchema;
|
|
165
180
|
|
|
166
|
-
/**
|
|
167
|
-
* The filter dimensions `jant_threads_list` takes, spelled as the HTTP API
|
|
168
|
-
* and the archive spell them. They reach the same registry parser as a query
|
|
169
|
-
* string would, so the vocabularies can't drift.
|
|
170
|
-
*/
|
|
171
|
-
const THREAD_FILTER_TOOL_PROPERTIES = {
|
|
172
|
-
format: { type: "string", enum: [...FORMATS] },
|
|
173
|
-
collection: {
|
|
174
|
-
type: "string",
|
|
175
|
-
description: "Collection slug, or several comma-separated",
|
|
176
|
-
},
|
|
177
|
-
year: { type: "integer", description: "Publication year (UTC)" },
|
|
178
|
-
media: {
|
|
179
|
-
type: "string",
|
|
180
|
-
description:
|
|
181
|
-
"any, none, or comma-separated kinds: image, video, audio, text, document",
|
|
182
|
-
},
|
|
183
|
-
title: { type: "string", enum: ["any", "none"] },
|
|
184
|
-
replies: { type: "string", enum: ["any", "none"] },
|
|
185
|
-
visibility: {
|
|
186
|
-
type: "string",
|
|
187
|
-
enum: ["public", "featured", "hidden", "private"],
|
|
188
|
-
},
|
|
189
|
-
} as const;
|
|
190
|
-
|
|
191
181
|
const ListThreadsToolSchema = z.object({
|
|
192
182
|
cursor: z.string().optional(),
|
|
193
|
-
limit:
|
|
183
|
+
limit: pageLimitSchema(100, 20),
|
|
194
184
|
status: StatusSchema.optional(),
|
|
195
185
|
sort: z.enum(THREAD_SORTS).optional(),
|
|
196
186
|
fold: z.boolean().optional(),
|
|
197
|
-
lang: ContentLanguageSchema.optional(),
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
187
|
+
lang: ContentLanguageSchema.optional().describe("BCP 47 content language"),
|
|
188
|
+
// The filter dimensions, spelled as the HTTP API and the archive spell
|
|
189
|
+
// them. They reach the same registry parser a query string does.
|
|
190
|
+
format: FormatSchema.optional(),
|
|
191
|
+
collection: z
|
|
192
|
+
.string()
|
|
193
|
+
.optional()
|
|
194
|
+
.describe("Collection slug, or several comma-separated"),
|
|
195
|
+
year: z.number().int().optional().describe("Publication year (UTC)"),
|
|
196
|
+
media: z
|
|
197
|
+
.string()
|
|
198
|
+
.optional()
|
|
199
|
+
.describe(
|
|
200
|
+
"any, none, or comma-separated kinds: image, video, audio, text, document",
|
|
201
|
+
),
|
|
202
|
+
title: z.enum(["any", "none"]).optional(),
|
|
203
|
+
replies: z.enum(["any", "none"]).optional(),
|
|
204
|
+
visibility: z.enum(THREAD_AUTHOR_VISIBILITIES).optional(),
|
|
205
|
+
content: PostContentSchema.optional().describe(
|
|
206
|
+
"markdown returns bodyMarkdown in place of body, bodyHtml, and bodyText",
|
|
207
|
+
),
|
|
205
208
|
});
|
|
206
209
|
|
|
207
210
|
const LIST_THREADS_OWN_PARAMS = [
|
|
@@ -211,35 +214,70 @@ const LIST_THREADS_OWN_PARAMS = [
|
|
|
211
214
|
"sort",
|
|
212
215
|
"fold",
|
|
213
216
|
"lang",
|
|
217
|
+
"content",
|
|
214
218
|
] as const;
|
|
215
219
|
|
|
216
220
|
const GetThreadToolSchema = z.object({
|
|
217
|
-
id: PostIdSchema,
|
|
221
|
+
id: PostIdSchema.describe("TypeID of any post in the Thread"),
|
|
218
222
|
fold: z.boolean().optional(),
|
|
223
|
+
content: PostContentSchema.optional().describe(
|
|
224
|
+
"markdown returns bodyMarkdown in place of body, bodyHtml, and bodyText",
|
|
225
|
+
),
|
|
219
226
|
});
|
|
220
227
|
|
|
221
228
|
const ListThreadPostsToolSchema = z.object({
|
|
222
|
-
id: PostIdSchema,
|
|
229
|
+
id: PostIdSchema.describe("TypeID of any post in the Thread"),
|
|
223
230
|
cursor: z.string().optional(),
|
|
224
|
-
limit:
|
|
231
|
+
limit: pageLimitSchema(100, 100),
|
|
225
232
|
status: StatusSchema.optional(),
|
|
233
|
+
content: PostContentSchema.optional().describe(
|
|
234
|
+
"markdown returns bodyMarkdown in place of body, bodyHtml, and bodyText",
|
|
235
|
+
),
|
|
226
236
|
});
|
|
227
237
|
|
|
238
|
+
/**
|
|
239
|
+
* A tool's advertised input, generated from the schema its handler parses
|
|
240
|
+
* with, so the two can't drift apart. `extra` adds properties the handler
|
|
241
|
+
* reads before that schema, such as the ID an update names.
|
|
242
|
+
*
|
|
243
|
+
* @param schema - The schema the tool's handler parses its arguments with
|
|
244
|
+
* @param extra - Required properties read ahead of it
|
|
245
|
+
* @returns The JSON Schema `tools/list` advertises
|
|
246
|
+
*/
|
|
247
|
+
function toolInputSchema(
|
|
248
|
+
schema: z.ZodType,
|
|
249
|
+
extra: Record<string, z.ZodType> = {},
|
|
250
|
+
): Record<string, unknown> {
|
|
251
|
+
const generated = z.toJSONSchema(schema, {
|
|
252
|
+
io: "input",
|
|
253
|
+
unrepresentable: "any",
|
|
254
|
+
}) as Record<string, unknown>;
|
|
255
|
+
delete generated.$schema;
|
|
256
|
+
if (Object.keys(extra).length === 0) return generated;
|
|
257
|
+
|
|
258
|
+
const extraSchema = z.toJSONSchema(z.object(extra), {
|
|
259
|
+
io: "input",
|
|
260
|
+
unrepresentable: "any",
|
|
261
|
+
}) as { properties: Record<string, unknown>; required?: string[] };
|
|
262
|
+
return {
|
|
263
|
+
...generated,
|
|
264
|
+
properties: {
|
|
265
|
+
...extraSchema.properties,
|
|
266
|
+
...(generated.properties as Record<string, unknown> | undefined),
|
|
267
|
+
},
|
|
268
|
+
required: [
|
|
269
|
+
...(extraSchema.required ?? []),
|
|
270
|
+
...((generated.required as string[] | undefined) ?? []),
|
|
271
|
+
],
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
228
275
|
const mcpTools: McpToolDefinition[] = [
|
|
229
276
|
{
|
|
230
277
|
name: "jant_posts_list",
|
|
231
278
|
description:
|
|
232
279
|
"List posts, with optional format, status, cursor, and limit filters. Pass nextCursor back as cursor for the next page.",
|
|
233
|
-
inputSchema:
|
|
234
|
-
type: "object",
|
|
235
|
-
properties: {
|
|
236
|
-
cursor: { type: "string" },
|
|
237
|
-
format: { type: "string", enum: [...FORMATS] },
|
|
238
|
-
limit: { type: "integer", minimum: 1, maximum: 100, default: 100 },
|
|
239
|
-
status: { type: "string", enum: [...STATUSES] },
|
|
240
|
-
},
|
|
241
|
-
additionalProperties: false,
|
|
242
|
-
},
|
|
280
|
+
inputSchema: toolInputSchema(ListPostsToolSchema),
|
|
243
281
|
async execute(args, context) {
|
|
244
282
|
const input = ListPostsToolSchema.parse(args ?? {});
|
|
245
283
|
const status = input.status ?? "published";
|
|
@@ -249,7 +287,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
249
287
|
);
|
|
250
288
|
|
|
251
289
|
return {
|
|
252
|
-
posts: await
|
|
290
|
+
posts: await loadApiPostResponses(context, posts, {
|
|
291
|
+
content: input.content,
|
|
292
|
+
}),
|
|
253
293
|
nextCursor,
|
|
254
294
|
};
|
|
255
295
|
},
|
|
@@ -257,15 +297,8 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
257
297
|
{
|
|
258
298
|
name: "jant_posts_get",
|
|
259
299
|
description:
|
|
260
|
-
"Get one post, including attachments and shared Thread collection IDs.",
|
|
261
|
-
inputSchema:
|
|
262
|
-
type: "object",
|
|
263
|
-
properties: {
|
|
264
|
-
id: { type: "string", description: "Post TypeID" },
|
|
265
|
-
},
|
|
266
|
-
required: ["id"],
|
|
267
|
-
additionalProperties: false,
|
|
268
|
-
},
|
|
300
|
+
"Get one post, including attachments and shared Thread collection IDs. Set content to markdown to read the body as Markdown.",
|
|
301
|
+
inputSchema: toolInputSchema(GetPostToolSchema),
|
|
269
302
|
async execute(args, context) {
|
|
270
303
|
const input = GetPostToolSchema.parse(args ?? {});
|
|
271
304
|
const post = await context.services.posts.getById(input.id);
|
|
@@ -273,47 +306,14 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
273
306
|
throw new NotFoundError("Post");
|
|
274
307
|
}
|
|
275
308
|
|
|
276
|
-
return
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
name: "jant_posts_get_content",
|
|
281
|
-
description: "Get one post body as markdown.",
|
|
282
|
-
inputSchema: {
|
|
283
|
-
type: "object",
|
|
284
|
-
properties: {
|
|
285
|
-
id: { type: "string", description: "Post TypeID" },
|
|
286
|
-
},
|
|
287
|
-
required: ["id"],
|
|
288
|
-
additionalProperties: false,
|
|
289
|
-
},
|
|
290
|
-
async execute(args, context) {
|
|
291
|
-
const input = GetPostToolSchema.parse(args ?? {});
|
|
292
|
-
const content = await context.services.posts.getBodyContent(input.id);
|
|
293
|
-
if (!content) {
|
|
294
|
-
throw new NotFoundError("Post");
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return content;
|
|
309
|
+
return loadApiPostDetail(context, post, { content: input.content });
|
|
298
310
|
},
|
|
299
311
|
},
|
|
300
312
|
{
|
|
301
313
|
name: "jant_threads_list",
|
|
302
314
|
description:
|
|
303
315
|
"List Threads (a root post and its replies), each with its post count. Takes the archive's filters; sort is activity (default), published, updated, oldest, or rating. Set fold to include the replies the homepage shows. Pass nextCursor back as cursor for the next page.",
|
|
304
|
-
inputSchema:
|
|
305
|
-
type: "object",
|
|
306
|
-
properties: {
|
|
307
|
-
cursor: { type: "string" },
|
|
308
|
-
limit: { type: "integer", minimum: 1, maximum: 100, default: 20 },
|
|
309
|
-
status: { type: "string", enum: [...STATUSES] },
|
|
310
|
-
sort: { type: "string", enum: [...THREAD_SORTS] },
|
|
311
|
-
fold: { type: "boolean" },
|
|
312
|
-
lang: { type: "string", description: "BCP 47 content language" },
|
|
313
|
-
...THREAD_FILTER_TOOL_PROPERTIES,
|
|
314
|
-
},
|
|
315
|
-
additionalProperties: false,
|
|
316
|
-
},
|
|
316
|
+
inputSchema: toolInputSchema(ListThreadsToolSchema),
|
|
317
317
|
async execute(args, context) {
|
|
318
318
|
const input = ListThreadsToolSchema.parse(args ?? {});
|
|
319
319
|
const filterArgs = Object.fromEntries(
|
|
@@ -328,9 +328,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
328
328
|
const value = filterArgs[key];
|
|
329
329
|
return value === undefined ? undefined : String(value);
|
|
330
330
|
},
|
|
331
|
-
Object.keys(filterArgs),
|
|
332
331
|
{
|
|
333
|
-
allow: [],
|
|
334
332
|
audience: "author",
|
|
335
333
|
loadCollections: () => context.services.collections.list(),
|
|
336
334
|
},
|
|
@@ -348,11 +346,14 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
348
346
|
lang: input.lang,
|
|
349
347
|
sort: input.sort,
|
|
350
348
|
fold: input.fold,
|
|
349
|
+
timeZone: context.appConfig.timeZone,
|
|
351
350
|
},
|
|
352
351
|
{ cursor: input.cursor, limit: input.limit },
|
|
353
352
|
);
|
|
354
353
|
return {
|
|
355
|
-
threads: await loadApiThreadResponses(context, threads
|
|
354
|
+
threads: await loadApiThreadResponses(context, threads, {
|
|
355
|
+
content: input.content,
|
|
356
|
+
}),
|
|
356
357
|
nextCursor,
|
|
357
358
|
};
|
|
358
359
|
},
|
|
@@ -361,18 +362,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
361
362
|
name: "jant_threads_get",
|
|
362
363
|
description:
|
|
363
364
|
"Get the Thread any post belongs to: its root and post count, and with fold the replies the homepage shows.",
|
|
364
|
-
inputSchema:
|
|
365
|
-
type: "object",
|
|
366
|
-
properties: {
|
|
367
|
-
id: {
|
|
368
|
-
type: "string",
|
|
369
|
-
description: "TypeID of any post in the Thread",
|
|
370
|
-
},
|
|
371
|
-
fold: { type: "boolean" },
|
|
372
|
-
},
|
|
373
|
-
required: ["id"],
|
|
374
|
-
additionalProperties: false,
|
|
375
|
-
},
|
|
365
|
+
inputSchema: toolInputSchema(GetThreadToolSchema),
|
|
376
366
|
async execute(args, context) {
|
|
377
367
|
const input = GetThreadToolSchema.parse(args ?? {});
|
|
378
368
|
const root = await context.services.threads.findRoot(
|
|
@@ -385,7 +375,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
385
375
|
const summaries = await context.services.threads.summarize([root], {
|
|
386
376
|
fold: input.fold,
|
|
387
377
|
});
|
|
388
|
-
const [thread] = await loadApiThreadResponses(context, summaries
|
|
378
|
+
const [thread] = await loadApiThreadResponses(context, summaries, {
|
|
379
|
+
content: input.content,
|
|
380
|
+
});
|
|
389
381
|
return thread;
|
|
390
382
|
},
|
|
391
383
|
},
|
|
@@ -393,20 +385,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
393
385
|
name: "jant_threads_list_posts",
|
|
394
386
|
description:
|
|
395
387
|
"List the posts of the Thread any post belongs to, root first, in Thread order. Pass nextCursor back as cursor for the next page.",
|
|
396
|
-
inputSchema:
|
|
397
|
-
type: "object",
|
|
398
|
-
properties: {
|
|
399
|
-
id: {
|
|
400
|
-
type: "string",
|
|
401
|
-
description: "TypeID of any post in the Thread",
|
|
402
|
-
},
|
|
403
|
-
cursor: { type: "string" },
|
|
404
|
-
limit: { type: "integer", minimum: 1, maximum: 100, default: 100 },
|
|
405
|
-
status: { type: "string", enum: [...STATUSES] },
|
|
406
|
-
},
|
|
407
|
-
required: ["id"],
|
|
408
|
-
additionalProperties: false,
|
|
409
|
-
},
|
|
388
|
+
inputSchema: toolInputSchema(ListThreadPostsToolSchema),
|
|
410
389
|
async execute(args, context) {
|
|
411
390
|
const input = ListThreadPostsToolSchema.parse(args ?? {});
|
|
412
391
|
const root = await context.services.threads.findRoot(
|
|
@@ -422,7 +401,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
422
401
|
{ cursor: input.cursor, limit: input.limit },
|
|
423
402
|
);
|
|
424
403
|
return {
|
|
425
|
-
posts: await
|
|
404
|
+
posts: await loadApiPostResponses(context, posts, {
|
|
405
|
+
content: input.content,
|
|
406
|
+
}),
|
|
426
407
|
nextCursor,
|
|
427
408
|
};
|
|
428
409
|
},
|
|
@@ -431,49 +412,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
431
412
|
name: "jant_posts_create",
|
|
432
413
|
description:
|
|
433
414
|
"Create a post. Supports the same JSON body as POST /api/posts.",
|
|
434
|
-
inputSchema:
|
|
435
|
-
type: "object",
|
|
436
|
-
properties: {
|
|
437
|
-
format: { type: "string", enum: [...FORMATS] },
|
|
438
|
-
title: { type: "string" },
|
|
439
|
-
sourceName: { type: "string" },
|
|
440
|
-
body: { type: "string" },
|
|
441
|
-
bodyMarkdown: { type: "string" },
|
|
442
|
-
slug: { type: "string" },
|
|
443
|
-
path: { type: "string" },
|
|
444
|
-
status: { type: "string", enum: [...STATUSES] },
|
|
445
|
-
visibility: { type: "string", enum: [...VISIBILITIES] },
|
|
446
|
-
pinned: { type: "boolean" },
|
|
447
|
-
featured: { type: "boolean" },
|
|
448
|
-
url: { type: "string" },
|
|
449
|
-
sourceUrl: { type: "string" },
|
|
450
|
-
quoteText: { type: "string" },
|
|
451
|
-
rating: { type: "integer" },
|
|
452
|
-
collectionIds: {
|
|
453
|
-
type: "array",
|
|
454
|
-
items: { type: "string" },
|
|
455
|
-
},
|
|
456
|
-
replyToId: { type: "string" },
|
|
457
|
-
quietReply: { type: "boolean" },
|
|
458
|
-
publishedAt: { type: "integer" },
|
|
459
|
-
createdAt: {
|
|
460
|
-
type: "integer",
|
|
461
|
-
description:
|
|
462
|
-
"Unix seconds. When moving a post from another site, the time it was written.",
|
|
463
|
-
},
|
|
464
|
-
updatedAt: {
|
|
465
|
-
type: "integer",
|
|
466
|
-
description:
|
|
467
|
-
"Unix seconds. When moving a post from another site, the time it was last edited.",
|
|
468
|
-
},
|
|
469
|
-
attachments: {
|
|
470
|
-
type: "array",
|
|
471
|
-
items: { type: "object" },
|
|
472
|
-
},
|
|
473
|
-
},
|
|
474
|
-
required: ["format"],
|
|
475
|
-
additionalProperties: true,
|
|
476
|
-
},
|
|
415
|
+
inputSchema: toolInputSchema(CreatePostApiSchema),
|
|
477
416
|
async execute(args, context) {
|
|
478
417
|
const input = CreatePostApiSchema.parse(args ?? {});
|
|
479
418
|
const deps = postWriteDeps(context);
|
|
@@ -492,40 +431,10 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
492
431
|
name: "jant_posts_update",
|
|
493
432
|
description:
|
|
494
433
|
"Update a post. Supports the same JSON body as PUT /api/posts/:id.",
|
|
495
|
-
inputSchema: {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
id: { type: "string", description: "Post TypeID" },
|
|
499
|
-
format: { type: "string", enum: [...FORMATS] },
|
|
500
|
-
title: { type: "string" },
|
|
501
|
-
sourceName: { type: "string" },
|
|
502
|
-
body: { type: "string" },
|
|
503
|
-
bodyMarkdown: { type: "string" },
|
|
504
|
-
slug: { type: "string" },
|
|
505
|
-
status: { type: "string", enum: [...STATUSES] },
|
|
506
|
-
visibility: { type: "string", enum: [...VISIBILITIES] },
|
|
507
|
-
pinned: { type: "boolean" },
|
|
508
|
-
featured: { type: "boolean" },
|
|
509
|
-
url: { type: "string" },
|
|
510
|
-
sourceUrl: { type: "string" },
|
|
511
|
-
quoteText: { type: "string" },
|
|
512
|
-
rating: { type: "integer" },
|
|
513
|
-
collectionIds: {
|
|
514
|
-
type: "array",
|
|
515
|
-
items: { type: "string" },
|
|
516
|
-
},
|
|
517
|
-
publishedAt: { type: "integer" },
|
|
518
|
-
attachments: {
|
|
519
|
-
type: "array",
|
|
520
|
-
items: { type: "object" },
|
|
521
|
-
},
|
|
522
|
-
},
|
|
523
|
-
required: ["id"],
|
|
524
|
-
additionalProperties: true,
|
|
525
|
-
},
|
|
434
|
+
inputSchema: toolInputSchema(UpdatePostApiSchema, {
|
|
435
|
+
id: PostIdSchema.describe("Post TypeID"),
|
|
436
|
+
}),
|
|
526
437
|
async execute(args, context) {
|
|
527
|
-
// The body schema is strict, so `id` comes off before it is checked:
|
|
528
|
-
// passed along, it failed every call as an unknown field.
|
|
529
438
|
const { id, ...fields } = z
|
|
530
439
|
.object({
|
|
531
440
|
id: PostIdSchema,
|
|
@@ -533,6 +442,11 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
533
442
|
.passthrough()
|
|
534
443
|
.parse(args ?? {});
|
|
535
444
|
const input = UpdatePostApiSchema.parse(fields);
|
|
445
|
+
const existing = await context.services.posts.getById(id);
|
|
446
|
+
if (!existing) {
|
|
447
|
+
throw new NotFoundError("Post");
|
|
448
|
+
}
|
|
449
|
+
assertUpdateFitsFormat(input, existing.format);
|
|
536
450
|
const deps = postWriteDeps(context);
|
|
537
451
|
const post = await context.services.posts.updateWithAttachments(
|
|
538
452
|
id,
|
|
@@ -552,16 +466,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
552
466
|
{
|
|
553
467
|
name: "jant_posts_delete",
|
|
554
468
|
description: "Delete a post and clean up any attached media.",
|
|
555
|
-
inputSchema:
|
|
556
|
-
type: "object",
|
|
557
|
-
properties: {
|
|
558
|
-
id: { type: "string", description: "Post TypeID" },
|
|
559
|
-
},
|
|
560
|
-
required: ["id"],
|
|
561
|
-
additionalProperties: false,
|
|
562
|
-
},
|
|
469
|
+
inputSchema: toolInputSchema(PostIdToolSchema),
|
|
563
470
|
async execute(args, context) {
|
|
564
|
-
const input =
|
|
471
|
+
const input = PostIdToolSchema.parse(args ?? {});
|
|
565
472
|
const success = await context.services.posts.delete(input.id, {
|
|
566
473
|
media: context.services.media,
|
|
567
474
|
storage: context.storage,
|
|
@@ -577,22 +484,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
577
484
|
{
|
|
578
485
|
name: "jant_collections_list",
|
|
579
486
|
description: "List collections and collection directory items.",
|
|
580
|
-
inputSchema:
|
|
581
|
-
type: "object",
|
|
582
|
-
properties: {
|
|
583
|
-
view: {
|
|
584
|
-
type: "string",
|
|
585
|
-
enum: ["compose"],
|
|
586
|
-
},
|
|
587
|
-
},
|
|
588
|
-
additionalProperties: false,
|
|
589
|
-
},
|
|
487
|
+
inputSchema: toolInputSchema(ListCollectionsToolSchema),
|
|
590
488
|
async execute(args, context) {
|
|
591
|
-
const input =
|
|
592
|
-
.object({
|
|
593
|
-
view: z.enum(["compose"]).optional(),
|
|
594
|
-
})
|
|
595
|
-
.parse(args ?? {});
|
|
489
|
+
const input = ListCollectionsToolSchema.parse(args ?? {});
|
|
596
490
|
|
|
597
491
|
if (input.view === "compose") {
|
|
598
492
|
const collections =
|
|
@@ -607,6 +501,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
607
501
|
return toApiCollectionList(
|
|
608
502
|
await context.services.collections.listDirectoryData({
|
|
609
503
|
isAuthenticated: true,
|
|
504
|
+
timeZone: context.appConfig.timeZone,
|
|
610
505
|
}),
|
|
611
506
|
);
|
|
612
507
|
},
|
|
@@ -614,14 +509,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
614
509
|
{
|
|
615
510
|
name: "jant_collections_get",
|
|
616
511
|
description: "Get one collection by ID.",
|
|
617
|
-
inputSchema:
|
|
618
|
-
type: "object",
|
|
619
|
-
properties: {
|
|
620
|
-
id: { type: "string", description: "Collection TypeID" },
|
|
621
|
-
},
|
|
622
|
-
required: ["id"],
|
|
623
|
-
additionalProperties: false,
|
|
624
|
-
},
|
|
512
|
+
inputSchema: toolInputSchema(GetCollectionToolSchema),
|
|
625
513
|
async execute(args, context) {
|
|
626
514
|
const input = GetCollectionToolSchema.parse(args ?? {});
|
|
627
515
|
const collection = await context.services.collections.getById(input.id);
|
|
@@ -635,20 +523,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
635
523
|
{
|
|
636
524
|
name: "jant_collections_create",
|
|
637
525
|
description: "Create a collection.",
|
|
638
|
-
inputSchema:
|
|
639
|
-
type: "object",
|
|
640
|
-
properties: {
|
|
641
|
-
slug: { type: "string" },
|
|
642
|
-
title: { type: "string" },
|
|
643
|
-
description: { type: "string" },
|
|
644
|
-
sortOrder: {
|
|
645
|
-
type: "string",
|
|
646
|
-
enum: [...COLLECTION_SORT_ORDERS],
|
|
647
|
-
},
|
|
648
|
-
},
|
|
649
|
-
required: ["slug", "title"],
|
|
650
|
-
additionalProperties: false,
|
|
651
|
-
},
|
|
526
|
+
inputSchema: toolInputSchema(CreateCollectionSchema),
|
|
652
527
|
async execute(args, context) {
|
|
653
528
|
const input = CreateCollectionSchema.parse(args ?? {});
|
|
654
529
|
return toApiCollection(await context.services.collections.create(input));
|
|
@@ -657,23 +532,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
657
532
|
{
|
|
658
533
|
name: "jant_collections_update",
|
|
659
534
|
description: "Update a collection.",
|
|
660
|
-
inputSchema: {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
id: { type: "string", description: "Collection TypeID" },
|
|
664
|
-
slug: { type: "string" },
|
|
665
|
-
title: { type: "string" },
|
|
666
|
-
description: {
|
|
667
|
-
anyOf: [{ type: "string" }, { type: "null" }],
|
|
668
|
-
},
|
|
669
|
-
sortOrder: {
|
|
670
|
-
type: "string",
|
|
671
|
-
enum: [...COLLECTION_SORT_ORDERS],
|
|
672
|
-
},
|
|
673
|
-
},
|
|
674
|
-
required: ["id"],
|
|
675
|
-
additionalProperties: false,
|
|
676
|
-
},
|
|
535
|
+
inputSchema: toolInputSchema(UpdateCollectionToolSchema, {
|
|
536
|
+
id: CollectionIdSchema.describe("Collection TypeID"),
|
|
537
|
+
}),
|
|
677
538
|
async execute(args, context) {
|
|
678
539
|
const parsed = z
|
|
679
540
|
.object({
|
|
@@ -695,14 +556,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
695
556
|
{
|
|
696
557
|
name: "jant_collections_delete",
|
|
697
558
|
description: "Delete a collection.",
|
|
698
|
-
inputSchema:
|
|
699
|
-
type: "object",
|
|
700
|
-
properties: {
|
|
701
|
-
id: { type: "string", description: "Collection TypeID" },
|
|
702
|
-
},
|
|
703
|
-
required: ["id"],
|
|
704
|
-
additionalProperties: false,
|
|
705
|
-
},
|
|
559
|
+
inputSchema: toolInputSchema(GetCollectionToolSchema),
|
|
706
560
|
async execute(args, context) {
|
|
707
561
|
const input = GetCollectionToolSchema.parse(args ?? {});
|
|
708
562
|
const success = await context.services.collections.delete(input.id);
|
|
@@ -717,41 +571,27 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
717
571
|
name: "jant_media_list",
|
|
718
572
|
description:
|
|
719
573
|
"List uploaded media, newest first, optionally filtered by MIME prefix. Pass nextCursor back as cursor for the next page.",
|
|
720
|
-
inputSchema:
|
|
721
|
-
type: "object",
|
|
722
|
-
properties: {
|
|
723
|
-
limit: { type: "integer", minimum: 1, maximum: 200, default: 50 },
|
|
724
|
-
mimePrefix: { type: "string" },
|
|
725
|
-
cursor: { type: "string" },
|
|
726
|
-
},
|
|
727
|
-
additionalProperties: false,
|
|
728
|
-
},
|
|
574
|
+
inputSchema: toolInputSchema(ListMediaToolSchema),
|
|
729
575
|
async execute(args, context) {
|
|
730
576
|
const input = ListMediaToolSchema.parse(args ?? {});
|
|
731
|
-
const
|
|
577
|
+
const page = await context.services.media.listPage({
|
|
732
578
|
limit: input.limit,
|
|
733
579
|
mimePrefix: input.mimePrefix,
|
|
734
580
|
cursor: input.cursor,
|
|
735
581
|
});
|
|
736
582
|
|
|
737
583
|
return {
|
|
738
|
-
media: media.map((item) =>
|
|
739
|
-
|
|
740
|
-
|
|
584
|
+
media: page.media.map((item) =>
|
|
585
|
+
serializeMedia(item, context.appConfig),
|
|
586
|
+
),
|
|
587
|
+
nextCursor: page.nextCursor,
|
|
741
588
|
};
|
|
742
589
|
},
|
|
743
590
|
},
|
|
744
591
|
{
|
|
745
592
|
name: "jant_media_get",
|
|
746
593
|
description: "Get one media item by ID.",
|
|
747
|
-
inputSchema:
|
|
748
|
-
type: "object",
|
|
749
|
-
properties: {
|
|
750
|
-
id: { type: "string", description: "Media TypeID" },
|
|
751
|
-
},
|
|
752
|
-
required: ["id"],
|
|
753
|
-
additionalProperties: false,
|
|
754
|
-
},
|
|
594
|
+
inputSchema: toolInputSchema(GetMediaToolSchema),
|
|
755
595
|
async execute(args, context) {
|
|
756
596
|
const input = GetMediaToolSchema.parse(args ?? {});
|
|
757
597
|
const media = await context.services.media.getById(input.id);
|
|
@@ -766,25 +606,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
766
606
|
name: "jant_media_upload",
|
|
767
607
|
description:
|
|
768
608
|
"Upload one media file from base64 bytes and return the created media record.",
|
|
769
|
-
inputSchema:
|
|
770
|
-
type: "object",
|
|
771
|
-
properties: {
|
|
772
|
-
filename: { type: "string" },
|
|
773
|
-
contentType: { type: "string" },
|
|
774
|
-
contentBase64: { type: "string" },
|
|
775
|
-
alt: { type: "string" },
|
|
776
|
-
summary: { type: "string" },
|
|
777
|
-
width: { type: "integer", minimum: 1 },
|
|
778
|
-
height: { type: "integer", minimum: 1 },
|
|
779
|
-
durationSeconds: { type: "integer", minimum: 1 },
|
|
780
|
-
blurhash: { type: "string" },
|
|
781
|
-
waveform: { type: "string" },
|
|
782
|
-
chars: { type: "integer", minimum: 0 },
|
|
783
|
-
posterBase64: { type: "string" },
|
|
784
|
-
},
|
|
785
|
-
required: ["filename", "contentType", "contentBase64"],
|
|
786
|
-
additionalProperties: false,
|
|
787
|
-
},
|
|
609
|
+
inputSchema: toolInputSchema(UploadMediaToolSchema),
|
|
788
610
|
async execute(args, context) {
|
|
789
611
|
const input = UploadMediaToolSchema.parse(args ?? {});
|
|
790
612
|
return uploadMediaFromBase64(input, context);
|
|
@@ -793,15 +615,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
793
615
|
{
|
|
794
616
|
name: "jant_media_update",
|
|
795
617
|
description: "Update a media item: its alt text.",
|
|
796
|
-
inputSchema:
|
|
797
|
-
type: "object",
|
|
798
|
-
properties: {
|
|
799
|
-
id: { type: "string", description: "Media TypeID" },
|
|
800
|
-
alt: { type: "string" },
|
|
801
|
-
},
|
|
802
|
-
required: ["id", "alt"],
|
|
803
|
-
additionalProperties: false,
|
|
804
|
-
},
|
|
618
|
+
inputSchema: toolInputSchema(UpdateMediaAltToolSchema),
|
|
805
619
|
async execute(args, context) {
|
|
806
620
|
const input = UpdateMediaAltToolSchema.parse(args ?? {});
|
|
807
621
|
const media = await context.services.media.getById(input.id);
|
|
@@ -821,14 +635,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
821
635
|
{
|
|
822
636
|
name: "jant_media_delete",
|
|
823
637
|
description: "Delete a media item and its stored object.",
|
|
824
|
-
inputSchema:
|
|
825
|
-
type: "object",
|
|
826
|
-
properties: {
|
|
827
|
-
id: { type: "string", description: "Media TypeID" },
|
|
828
|
-
},
|
|
829
|
-
required: ["id"],
|
|
830
|
-
additionalProperties: false,
|
|
831
|
-
},
|
|
638
|
+
inputSchema: toolInputSchema(GetMediaToolSchema),
|
|
832
639
|
async execute(args, context) {
|
|
833
640
|
const input = GetMediaToolSchema.parse(args ?? {});
|
|
834
641
|
const success = await context.services.media.delete(
|
|
@@ -845,14 +652,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
845
652
|
{
|
|
846
653
|
name: "jant_attachments_get_content",
|
|
847
654
|
description: "Get a text attachment's markdown content.",
|
|
848
|
-
inputSchema:
|
|
849
|
-
type: "object",
|
|
850
|
-
properties: {
|
|
851
|
-
id: { type: "string", description: "Media TypeID" },
|
|
852
|
-
},
|
|
853
|
-
required: ["id"],
|
|
854
|
-
additionalProperties: false,
|
|
855
|
-
},
|
|
655
|
+
inputSchema: toolInputSchema(GetMediaToolSchema),
|
|
856
656
|
async execute(args, context) {
|
|
857
657
|
const input = GetMediaToolSchema.parse(args ?? {});
|
|
858
658
|
const storage = requireStorage(context.storage);
|
|
@@ -870,28 +670,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
870
670
|
{
|
|
871
671
|
name: "jant_collections_add_thread",
|
|
872
672
|
description: "Add a thread to a collection.",
|
|
873
|
-
inputSchema:
|
|
874
|
-
type: "object",
|
|
875
|
-
properties: {
|
|
876
|
-
collectionId: { type: "string", description: "Collection TypeID" },
|
|
877
|
-
threadId: {
|
|
878
|
-
type: "string",
|
|
879
|
-
description: "Root or child Post TypeID in the Thread",
|
|
880
|
-
},
|
|
881
|
-
},
|
|
882
|
-
required: ["collectionId", "threadId"],
|
|
883
|
-
additionalProperties: false,
|
|
884
|
-
},
|
|
673
|
+
inputSchema: toolInputSchema(AddCollectionThreadToolSchema),
|
|
885
674
|
async execute(args, context) {
|
|
886
675
|
const input = AddCollectionThreadToolSchema.parse(args ?? {});
|
|
887
|
-
const collection = await context.services.collections.getById(
|
|
888
|
-
input.collectionId,
|
|
889
|
-
);
|
|
890
|
-
|
|
891
|
-
if (!collection) {
|
|
892
|
-
throw new NotFoundError("Collection");
|
|
893
|
-
}
|
|
894
|
-
|
|
895
676
|
await context.services.collections.addThread(
|
|
896
677
|
input.collectionId,
|
|
897
678
|
input.threadId,
|
|
@@ -902,27 +683,9 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
902
683
|
{
|
|
903
684
|
name: "jant_collections_remove_thread",
|
|
904
685
|
description: "Remove a thread from a collection.",
|
|
905
|
-
inputSchema:
|
|
906
|
-
type: "object",
|
|
907
|
-
properties: {
|
|
908
|
-
collectionId: { type: "string", description: "Collection TypeID" },
|
|
909
|
-
threadId: {
|
|
910
|
-
type: "string",
|
|
911
|
-
description: "Root or child Post TypeID in the Thread",
|
|
912
|
-
},
|
|
913
|
-
},
|
|
914
|
-
required: ["collectionId", "threadId"],
|
|
915
|
-
additionalProperties: false,
|
|
916
|
-
},
|
|
686
|
+
inputSchema: toolInputSchema(RemoveCollectionThreadToolSchema),
|
|
917
687
|
async execute(args, context) {
|
|
918
688
|
const input = RemoveCollectionThreadToolSchema.parse(args ?? {});
|
|
919
|
-
const collection = await context.services.collections.getById(
|
|
920
|
-
input.collectionId,
|
|
921
|
-
);
|
|
922
|
-
if (!collection) {
|
|
923
|
-
throw new NotFoundError("Collection");
|
|
924
|
-
}
|
|
925
|
-
|
|
926
689
|
await context.services.collections.removeThread(
|
|
927
690
|
input.collectionId,
|
|
928
691
|
input.threadId,
|
|
@@ -933,16 +696,14 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
933
696
|
{
|
|
934
697
|
name: "jant_settings_get",
|
|
935
698
|
description: "Get editable site settings.",
|
|
936
|
-
inputSchema:
|
|
937
|
-
type: "object",
|
|
938
|
-
additionalProperties: false,
|
|
939
|
-
},
|
|
699
|
+
inputSchema: toolInputSchema(EmptyToolSchema),
|
|
940
700
|
async execute(_args, context) {
|
|
941
701
|
const allSettings = await context.services.settings.getAll();
|
|
942
702
|
return {
|
|
943
|
-
settings:
|
|
703
|
+
settings: buildApiSettingsResponse(
|
|
944
704
|
allSettings,
|
|
945
705
|
context.appConfig.demoMode,
|
|
706
|
+
context.env,
|
|
946
707
|
),
|
|
947
708
|
};
|
|
948
709
|
},
|
|
@@ -950,15 +711,10 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
950
711
|
{
|
|
951
712
|
name: "jant_settings_update",
|
|
952
713
|
description: "Update editable site settings.",
|
|
953
|
-
inputSchema:
|
|
954
|
-
type: "object",
|
|
955
|
-
additionalProperties: {
|
|
956
|
-
type: "string",
|
|
957
|
-
},
|
|
958
|
-
},
|
|
714
|
+
inputSchema: toolInputSchema(UpdateSettingsToolSchema),
|
|
959
715
|
async execute(args, context) {
|
|
960
716
|
const updates = UpdateSettingsToolSchema.parse(args ?? {});
|
|
961
|
-
const { filteredUpdates, rejectedKeys } =
|
|
717
|
+
const { filteredUpdates, rejectedKeys } = partitionApiSettingUpdates(
|
|
962
718
|
updates,
|
|
963
719
|
context.appConfig.demoMode,
|
|
964
720
|
);
|
|
@@ -981,10 +737,11 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
981
737
|
|
|
982
738
|
const allSettings = await context.services.settings.getAll();
|
|
983
739
|
return {
|
|
984
|
-
rejectedKeys,
|
|
985
|
-
settings:
|
|
740
|
+
...(rejectedKeys.length > 0 && { rejectedKeys }),
|
|
741
|
+
settings: buildApiSettingsResponse(
|
|
986
742
|
allSettings,
|
|
987
743
|
context.appConfig.demoMode,
|
|
744
|
+
context.env,
|
|
988
745
|
),
|
|
989
746
|
};
|
|
990
747
|
},
|
|
@@ -993,15 +750,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
993
750
|
name: "jant_posts_search",
|
|
994
751
|
description:
|
|
995
752
|
"Search published posts, including private ones. Each result carries its visibility.",
|
|
996
|
-
inputSchema:
|
|
997
|
-
type: "object",
|
|
998
|
-
properties: {
|
|
999
|
-
q: { type: "string", minLength: 1, maxLength: 200 },
|
|
1000
|
-
limit: { type: "integer", minimum: 1, maximum: 50, default: 20 },
|
|
1001
|
-
},
|
|
1002
|
-
required: ["q"],
|
|
1003
|
-
additionalProperties: false,
|
|
1004
|
-
},
|
|
753
|
+
inputSchema: toolInputSchema(SearchPostsToolSchema),
|
|
1005
754
|
async execute(args, context) {
|
|
1006
755
|
const input = SearchPostsToolSchema.parse(args ?? {});
|
|
1007
756
|
// The author's search, the same as `GET /api/search`: private posts
|
|
@@ -1016,13 +765,7 @@ const mcpTools: McpToolDefinition[] = [
|
|
|
1016
765
|
return {
|
|
1017
766
|
count: results.length,
|
|
1018
767
|
query: input.q,
|
|
1019
|
-
results: results
|
|
1020
|
-
toSearchApiResult(
|
|
1021
|
-
result.post,
|
|
1022
|
-
result.snippet,
|
|
1023
|
-
context.appConfig.sitePathPrefix,
|
|
1024
|
-
),
|
|
1025
|
-
),
|
|
768
|
+
results: await loadSearchApiResults(context, results),
|
|
1026
769
|
};
|
|
1027
770
|
},
|
|
1028
771
|
},
|
|
@@ -1401,15 +1144,10 @@ async function uploadMediaFromBase64(
|
|
|
1401
1144
|
return serializeMedia(media, context.appConfig);
|
|
1402
1145
|
}
|
|
1403
1146
|
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
context: McpToolContext,
|
|
1407
|
-
) {
|
|
1408
|
-
return loadApiPostResponses(context, posts, { collectionIds: true });
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1147
|
+
// MCP tools answer what their HTTP endpoints do: create and update leave out
|
|
1148
|
+
// `collectionIds`, as a list does; only a single read carries it.
|
|
1411
1149
|
function serializePost(post: Post, context: McpToolContext) {
|
|
1412
|
-
return loadApiPostResponse(context, post
|
|
1150
|
+
return loadApiPostResponse(context, post);
|
|
1413
1151
|
}
|
|
1414
1152
|
|
|
1415
1153
|
function serializeMedia(
|