From 9136c8309ae88a0957bdfa848f92d73172643fe6 Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:23:29 +0100 Subject: [PATCH 01/13] chore: scaffold Worker and tooling --- .env.example | 11 + .gitignore | 7 + .oxfmtrc.json | 22 + .oxlintrc.json | 13 + package.json | 35 + pnpm-lock.yaml | 2539 ++++++++++++++++++++++++++++ pnpm-workspace.yaml | 3 + prek.toml | 27 + test/raw.d.ts | 4 + test/support/cloudflare-workers.ts | 18 + tsconfig.json | 21 + vitest.config.ts | 12 + wrangler.jsonc | 19 + 13 files changed, 2731 insertions(+) create mode 100644 .env.example create mode 100644 .oxfmtrc.json create mode 100644 .oxlintrc.json create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 prek.toml create mode 100644 test/raw.d.ts create mode 100644 test/support/cloudflare-workers.ts create mode 100644 tsconfig.json create mode 100644 vitest.config.ts create mode 100644 wrangler.jsonc diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..884ef56 --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +CLOUDFLARE_ACCOUNT_ID= +# Only for `just access`; needs Access: Apps and Policies Write +CLOUDFLARE_API_TOKEN= +CLAIRIC_DOMAIN=clairic.example.com +ACCESS_TEAM_DOMAIN=yourteam.cloudflareaccess.com +# Comma-separated Access login emails allowed to connect +ACCESS_EMAILS=you@example.com +# Optional identity provider id; empty allows every login method the team has +ACCESS_IDP_ID= +# Written by `just access` +ACCESS_AUD= diff --git a/.gitignore b/.gitignore index 1301e01..0b3f48f 100644 --- a/.gitignore +++ b/.gitignore @@ -147,3 +147,10 @@ vite.config.ts.timestamp-* # Turbo Repo .turbo + +# wrangler +.wrangler/ +.dev.vars* + +# generated by wrangler types on install +worker-configuration.d.ts diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000..94100ea --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,22 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "useTabs": true, + "printWidth": 100, + "sortPackageJson": true, + "sortImports": { + "groups": [ + ["type"], + ["builtin", "external"], + ["internal", "subpath"], + ["parent", "sibling", "index"] + ], + "newlinesBetween": true + }, + "overrides": [{ "files": ["**/*.jsonc"], "options": { "trailingComma": "none" } }], + "ignorePatterns": [ + "worker-configuration.d.ts", + "test/fixtures/**", + "prek.toml", + "**/*.md" + ] +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..5765856 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,13 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["unicorn", "oxc", "typescript", "vitest", "import", "promise"], + "options": { "typeAware": true, "reportUnusedDisableDirectives": "warn" }, + "categories": { "correctness": "error", "suspicious": "error", "perf": "warn" }, + "rules": { + "eqeqeq": "error", + "unicorn/filename-case": ["error", { "case": "kebabCase" }], + "id-denylist": ["error", "data", "result", "temp", "info", "tmp", "val"], + "no-await-in-loop": "off" + }, + "ignorePatterns": ["worker-configuration.d.ts"] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..238f98d --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "clairic-mcp", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { + "postinstall": "wrangler types" + }, + "dependencies": { + "@modelcontextprotocol/server": "^2.3.1", + "jose": "^6.2.12", + "zod": "^4.6.7" + }, + "devDependencies": { + "oxfmt": "^0.73.0", + "oxlint": "^1.88.0", + "oxlint-tsgolint": "^7.0.2004", + "typescript": "^7.0.2", + "vitest": "^5.0.5", + "wrangler": "^4.151.1" + }, + "devEngines": { + "packageManager": { + "name": "pnpm", + "version": "12.14.0", + "onFail": "download" + }, + "runtime": { + "name": "node", + "version": "^24.22.0", + "onFail": "download" + } + }, + "packageManager": "pnpm@12.14.0" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..d07c177 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,2539 @@ +--- +lockfileVersion: '9.0' + +importers: + + .: + configDependencies: {} + packageManagerDependencies: + pnpm: + specifier: 12.14.0 + version: 12.14.0 + +packages: + + '@pnpm/exe.android-arm64@12.14.0': + resolution: {integrity: sha512-+iSh7x21C3A2hqc+Z0ZmbKTcn6YNlzrXM142PsnQH/dLj0DYxFzoBvc6XAnL/yfQ5nnH2ebBiRj/zVxr61fZbQ==} + cpu: [arm64] + os: [android] + + '@pnpm/exe.android-x64@12.14.0': + resolution: {integrity: sha512-qT+0LqEr2wBVaxcG2T8cX/R8SSRz2Rvpp8nRR4fh8tnGUZRch87gFmsHUAoSQh7w6j1h0qTjrA384j4xi8frvw==} + cpu: [x64] + os: [android] + + '@pnpm/exe.darwin-arm64@12.14.0': + resolution: {integrity: sha512-tnrdUB8ecJoehuKKqi1YHCBVl61xtJ9XVGcx5EviC6fWO4DeGI8GtXrjvJxDBM3nuVjJeWistgsUp/N142x4sw==} + cpu: [arm64] + os: [darwin] + + '@pnpm/exe.darwin-x64@12.14.0': + resolution: {integrity: sha512-vlBfGkruqQRsEHTW43cPwpYd7QlbIJ//cvpAdb3bVXkI8SgTPoXhCnc05m+ZNiPrrEkBsX/t7KHw9aXpkzPm3Q==} + cpu: [x64] + os: [darwin] + + '@pnpm/exe.freebsd-x64@12.14.0': + resolution: {integrity: sha512-Qg5rxBrGYl6Tfso+EyygPf84fY1Fzy55E/0or+iuYKtnf0vc0MlHJfVIlT7pBukMRntQHRik7hUi0Z4s7AlJsw==} + cpu: [x64] + os: [freebsd] + + '@pnpm/exe.linux-arm64-musl@12.14.0': + resolution: {integrity: sha512-DRIe4yQkXBGA/PhVJdzlbnllxBdAtnMMvTVLLcGpsK5FvJz9kxD2Hyxtn68ovmNkVX06f6p45cQwfm3wx2jn1A==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-arm64@12.14.0': + resolution: {integrity: sha512-7joGShZ44Nk3WpNU+60JoOPjCXlgxhJAq11S2UiVtwCUDgTer1yTPPfxGW8pxaD6046actYLIYDbZNlubHWs0A==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-ppc64@12.14.0': + resolution: {integrity: sha512-gSoryn7ySdXd//gjgf3MvvA8ZerJayaSbuMZMtAWq4vb2/wlVEgpl0Kvqt54y58TRj533Qjq2txKgnxd4JyoAQ==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-riscv64@12.14.0': + resolution: {integrity: sha512-EMjew1H9WqQ7pL+tYqCPwiuB+0PeCiJRV7fyWeuFw0wwYUajFBjcaPO3IGAVu9sdmJDU+e+HYv/Zey6aKae0Vw==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-s390x@12.14.0': + resolution: {integrity: sha512-shYOj/SFoXD35fHe0pWr2JofwSXulC0BnEIXLj2QokDi0EF//AfKsui35yKIkTEl+s2VJybc3PO4iJNhKIj5Qw==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-x64-musl@12.14.0': + resolution: {integrity: sha512-btZiZ2Ot0llKK1ndSfA5i3IRX7/S0VrmzseNH/BJ4c+Cady+S81H6vvU1zByggHMyqQhC8OgxO5PiIY7D9bH0Q==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-x64@12.14.0': + resolution: {integrity: sha512-F6K8e/jWxiuEYJaQtRRUG9ynBSTEHa+t7Lf86MKuOO5UA7WVVMbi+oB8nY6iKW++ncWS2yG6T9faXZGxqNsfoQ==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.win32-arm64@12.14.0': + resolution: {integrity: sha512-DOjlkVB6TtTKeAAe0hNZXn5S7YqESmo1Z6SGbR4BZNQ4isRg31XVHjX2RFTbY8gnZq68IwzyLmPqlEjMmYxofg==} + cpu: [arm64] + os: [win32] + + '@pnpm/exe.win32-x64@12.14.0': + resolution: {integrity: sha512-/LSX6mew/sLf08XqcjemuklNKf1K/Ftpgj4//hK/HKzI2dKbmxDB27a/2OaQ5a0O3/3OFzlssXDziZsi+yVBwQ==} + cpu: [x64] + os: [win32] + + pnpm@12.14.0: + resolution: {integrity: sha512-wYum2HmT09Fky16JSPMrLAbuhUSH4GzY2GeBNC+z5btGNDZwNHEehoArqpw3vqkGzhkprQjXCITJfYAd8TOJpg==} + engines: {node: '>=18.*'} + hasBin: true + +snapshots: + + '@pnpm/exe.android-arm64@12.14.0': + optional: true + + '@pnpm/exe.android-x64@12.14.0': + optional: true + + '@pnpm/exe.darwin-arm64@12.14.0': + optional: true + + '@pnpm/exe.darwin-x64@12.14.0': + optional: true + + '@pnpm/exe.freebsd-x64@12.14.0': + optional: true + + '@pnpm/exe.linux-arm64-musl@12.14.0': + optional: true + + '@pnpm/exe.linux-arm64@12.14.0': + optional: true + + '@pnpm/exe.linux-ppc64@12.14.0': + optional: true + + '@pnpm/exe.linux-riscv64@12.14.0': + optional: true + + '@pnpm/exe.linux-s390x@12.14.0': + optional: true + + '@pnpm/exe.linux-x64-musl@12.14.0': + optional: true + + '@pnpm/exe.linux-x64@12.14.0': + optional: true + + '@pnpm/exe.win32-arm64@12.14.0': + optional: true + + '@pnpm/exe.win32-x64@12.14.0': + optional: true + + pnpm@12.14.0: + optionalDependencies: + '@pnpm/exe.android-arm64': 12.14.0 + '@pnpm/exe.android-x64': 12.14.0 + '@pnpm/exe.darwin-arm64': 12.14.0 + '@pnpm/exe.darwin-x64': 12.14.0 + '@pnpm/exe.freebsd-x64': 12.14.0 + '@pnpm/exe.linux-arm64': 12.14.0 + '@pnpm/exe.linux-arm64-musl': 12.14.0 + '@pnpm/exe.linux-ppc64': 12.14.0 + '@pnpm/exe.linux-riscv64': 12.14.0 + '@pnpm/exe.linux-s390x': 12.14.0 + '@pnpm/exe.linux-x64': 12.14.0 + '@pnpm/exe.linux-x64-musl': 12.14.0 + '@pnpm/exe.win32-arm64': 12.14.0 + '@pnpm/exe.win32-x64': 12.14.0 + +--- +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + '@modelcontextprotocol/server': + specifier: ^2.3.1 + version: 2.3.1 + jose: + specifier: ^6.2.12 + version: 6.2.12 + zod: + specifier: ^4.6.7 + version: 4.6.7 + devDependencies: + node: + specifier: runtime:^24.22.0 + version: runtime:24.22.0 + oxfmt: + specifier: ^0.73.0 + version: 0.73.0 + oxlint: + specifier: ^1.88.0 + version: 1.88.0(oxlint-tsgolint@7.0.2004) + oxlint-tsgolint: + specifier: ^7.0.2004 + version: 7.0.2004 + typescript: + specifier: ^7.0.2 + version: 7.0.2 + vitest: + specifier: ^5.0.5 + version: 5.0.5(vite@8.3.4(esbuild@0.28.2)) + wrangler: + specifier: ^4.151.1 + version: 4.151.1 + +packages: + + '@cloudflare/kv-asset-handler@0.5.0': + resolution: {integrity: sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==} + engines: {node: '>=22.0.0'} + + '@cloudflare/unenv-preset@2.16.2': + resolution: {integrity: sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ==} + peerDependencies: + unenv: 2.0.0-rc.24 + workerd: '>1.20260305.0 <2.0.0-0' + peerDependenciesMeta: + workerd: + optional: true + + '@cloudflare/workerd-darwin-64@1.20261012.1': + resolution: {integrity: sha512-dkTL9aY3V4D40b+jBpGPCistWUPFQ/M61wlWi6i1o8MvHFFgEw7EQkcaYEv6Yd3bkPDD/3TFT4hRsMb2xVZSwQ==} + engines: {node: '>=16'} + cpu: [x64] + os: [darwin] + + '@cloudflare/workerd-darwin-arm64@1.20261012.1': + resolution: {integrity: sha512-2/nVGcKXjNNI+DhxKSepTKvFng9H7aN2WXv6Zu67iqgI6JrxypNt5kTPv4ZHosxrcfyKMci/2RfN7GIrN0BitQ==} + engines: {node: '>=16'} + cpu: [arm64] + os: [darwin] + + '@cloudflare/workerd-linux-64@1.20261012.1': + resolution: {integrity: sha512-uMe7ONHnLxStD1Ye0YFHBO36uj4cStv5P53rW+5GVWXFT8BRjqVixlH0IqCAHe1Pmcwyd1+7fVoGde89MZSCJg==} + engines: {node: '>=16'} + cpu: [x64] + os: [linux] + + '@cloudflare/workerd-linux-arm64@1.20261012.1': + resolution: {integrity: sha512-I0VMdcXk7ygG5vYDce0ePTBFdnBXC0i9WiBY5mWiv0iTinbfea6/rHqSQ7B1UMpjgrYVs9E0m4bZ9ufsk5GCFA==} + engines: {node: '>=16'} + cpu: [arm64] + os: [linux] + + '@cloudflare/workerd-windows-64@1.20261012.1': + resolution: {integrity: sha512-c5hQvNx574UEoknaCFvMa/NdLrrYiALNbe6sx1okW8uOiRYWxrFuA8WpXFnBJ5XJypm0TEAHYaUTGv3rRLpY7Q==} + engines: {node: '>=16'} + cpu: [x64] + os: [win32] + + '@cspotcode/source-map-support@0.8.1': + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + + '@emnapi/runtime@1.11.3': + resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==} + + '@esbuild/aix-ppc64@0.28.2': + resolution: {integrity: sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.28.2': + resolution: {integrity: sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.28.2': + resolution: {integrity: sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.28.2': + resolution: {integrity: sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.28.2': + resolution: {integrity: sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.28.2': + resolution: {integrity: sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.28.2': + resolution: {integrity: sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.28.2': + resolution: {integrity: sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.28.2': + resolution: {integrity: sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.28.2': + resolution: {integrity: sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.28.2': + resolution: {integrity: sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.28.2': + resolution: {integrity: sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.28.2': + resolution: {integrity: sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.28.2': + resolution: {integrity: sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.28.2': + resolution: {integrity: sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.28.2': + resolution: {integrity: sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.28.2': + resolution: {integrity: sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.28.2': + resolution: {integrity: sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.28.2': + resolution: {integrity: sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.28.2': + resolution: {integrity: sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.28.2': + resolution: {integrity: sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.28.2': + resolution: {integrity: sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.28.2': + resolution: {integrity: sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.28.2': + resolution: {integrity: sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.28.2': + resolution: {integrity: sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.28.2': + resolution: {integrity: sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@img/colour@1.1.0': + resolution: {integrity: sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==} + engines: {node: '>=18'} + + '@img/sharp-darwin-arm64@0.35.5': + resolution: {integrity: sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [darwin] + + '@img/sharp-darwin-x64@0.35.5': + resolution: {integrity: sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [darwin] + + '@img/sharp-freebsd-wasm32@0.35.5': + resolution: {integrity: sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==} + engines: {node: '>=20.9.0'} + os: [freebsd] + + '@img/sharp-libvips-darwin-arm64@1.3.4': + resolution: {integrity: sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==} + cpu: [arm64] + os: [darwin] + + '@img/sharp-libvips-darwin-x64@1.3.4': + resolution: {integrity: sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==} + cpu: [x64] + os: [darwin] + + '@img/sharp-libvips-linux-arm64@1.3.4': + resolution: {integrity: sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-arm@1.3.4': + resolution: {integrity: sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-ppc64@1.3.4': + resolution: {integrity: sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-riscv64@1.3.4': + resolution: {integrity: sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-s390x@1.3.4': + resolution: {integrity: sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-x64@1.3.4': + resolution: {integrity: sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linuxmusl-arm64@1.3.4': + resolution: {integrity: sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@img/sharp-libvips-linuxmusl-x64@1.3.4': + resolution: {integrity: sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-linux-arm64@0.35.5': + resolution: {integrity: sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-arm@0.35.5': + resolution: {integrity: sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==} + engines: {node: '>=20.9.0'} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-ppc64@0.35.5': + resolution: {integrity: sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==} + engines: {node: '>=20.9.0'} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-riscv64@0.35.5': + resolution: {integrity: sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==} + engines: {node: '>=20.9.0'} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-s390x@0.35.5': + resolution: {integrity: sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==} + engines: {node: '>=20.9.0'} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-x64@0.35.5': + resolution: {integrity: sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@img/sharp-linuxmusl-arm64@0.35.5': + resolution: {integrity: sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@img/sharp-linuxmusl-x64@0.35.5': + resolution: {integrity: sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-wasm32@0.35.5': + resolution: {integrity: sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==} + engines: {node: '>=20.9.0'} + + '@img/sharp-webcontainers-wasm32@0.35.5': + resolution: {integrity: sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==} + engines: {node: '>=20.9.0'} + cpu: [wasm32] + + '@img/sharp-win32-arm64@0.35.5': + resolution: {integrity: sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [win32] + + '@img/sharp-win32-ia32@0.35.5': + resolution: {integrity: sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==} + engines: {node: ^20.9.0} + cpu: [ia32] + os: [win32] + + '@img/sharp-win32-x64@0.35.5': + resolution: {integrity: sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [win32] + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.6.0': + resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + + '@jridgewell/trace-mapping@0.3.9': + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + + '@modelcontextprotocol/core@2.3.1': + resolution: {integrity: sha512-laVmIhPGpWi7rG9q+0UigblRN0Hws/Yjlb6qLFtVqryXVLkc4h+yN8z731POD2LnAGQlFe7/tXhUm7Bi0YB91g==} + engines: {node: '>=20'} + + '@modelcontextprotocol/server@2.3.1': + resolution: {integrity: sha512-e59MfWuSssj6DoQ96JCTqdW1AXT5/XtnTl0WWd6MU1Ka434fFUGGosCLJbGNySDhHGvxQWoRWK137FXYFkYNWw==} + engines: {node: '>=20'} + + '@oxc-project/types@0.154.0': + resolution: {integrity: sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==} + + '@oxfmt/binding-android-arm-eabi@0.73.0': + resolution: {integrity: sha512-dhunAdMbi/4o0Y66/+Wl6rpsNqpvE4i26Qw6bB77A97L2lJoktWg6m+X9QOon8iOEEqzD9rEZqFi5uZ4oIzhCA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxfmt/binding-android-arm64@0.73.0': + resolution: {integrity: sha512-dBoypjC2/xeyKyIhN2waX0/XeoccH9k0lVVe+sGRc4X8HSJVRtqyZDoXdr7bGY9A75c51dX0z0dLDpGQKwCdCg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxfmt/binding-darwin-arm64@0.73.0': + resolution: {integrity: sha512-Tn7Y+qWIpCQK+qdYwBcn6YvqeBuPiuG3tcNlYg16a5QL2o3rSmrgBB1nCyYqo0uvc1LNrfQW9/CK2tzFuID/Fg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxfmt/binding-darwin-x64@0.73.0': + resolution: {integrity: sha512-yVb0E0tg/+9Xc9YJCBq66qF1DC/aN5mhb5nnHz0k4ikwkMANtSul2VPDSwjYdXR6/DFimc+pPUgLBqkIa5Ctuw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxfmt/binding-freebsd-x64@0.73.0': + resolution: {integrity: sha512-IKR4lFnBkYNL9Uqdxa5GMTQLvnLj+3sDwTvh2atHCzah0xeo+1xR5bigRU8uyXlOsA4VpXUn0UAimq4E4RBGmQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxfmt/binding-linux-arm-gnueabihf@0.73.0': + resolution: {integrity: sha512-7qnZ4g0ZCO3aZevOOQpZIABYwwXJW1lLDo2elviGdPQ0i11255xKEMFsi97fC1/nauQFseCJfELUy/k2JoOP+g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm-musleabihf@0.73.0': + resolution: {integrity: sha512-36eBico2j/WPB84gb4FYd/jjqGCKOwU4M+TWLBUIqlnzTozQueLy0joA5BwsSp2OZFVkOlpCwvA3ndPamdiyLw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm64-gnu@0.73.0': + resolution: {integrity: sha512-VZ3cSgCAT18knKo52DcACmAuIoqG6qVEyeZRFbJd0xmYQ8GyYjuBc6IAh6MZHijT6q7p4/HPI+6ZWsCuhdV6iw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-arm64-musl@0.73.0': + resolution: {integrity: sha512-8YVzH59XSHcqwXNgc5qK851zCqwpmBgOifARXEPPe5/xTsIbHceYoPZAyqfpYV0CfKmzSaEDBgYHFza4rhx+Zw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-linux-ppc64-gnu@0.73.0': + resolution: {integrity: sha512-MqRJnmCys0rwOgpWyEidSA7v/bvOqfNDJhPkQoR9mPVYrvSmMaW2Xhdpl28cbTA+brOM1is62GjIvJplVlUVpw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-riscv64-gnu@0.73.0': + resolution: {integrity: sha512-4t2F3SWJSK/O/kRRFnL0elJzn75fJGGu71gs1HtiWcS80SmJOpkHiwwLnTp9suGdns8VHEPxYS0GTcyVwHKWBA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-riscv64-musl@0.73.0': + resolution: {integrity: sha512-D8b4I8I1kLdJQFwdFXNV+cwh3xWSiNKofjdGUk0nDpc0AHOds8T+poGbP9RWQMvgsvMb9OMgp/aV7ahBR37TbQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-linux-s390x-gnu@0.73.0': + resolution: {integrity: sha512-QrC1S5VL1+N5rvorB15jH7CPvjVHA7GyUI5oVEd8Bd9m5605RDBQYTxDQ920DuylRoZOh2V7/xXpfCtFUrojUQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-x64-gnu@0.73.0': + resolution: {integrity: sha512-dFcUKQPltCEPa+YlkF3zqufn6nJPZdG73LpnjBvZFFsU3laCMssDXSYB99mVaj43FqdEgjpz5TO6gbYXcczd9g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-x64-musl@0.73.0': + resolution: {integrity: sha512-LmQe+nV8e+eUwfPNCxDF+owbsg88toBiR/8rZRgVOeKQP3MaGefXZRvBoc1UG37iWEQ/9JlCXG9Mc4nf4N3agw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-openharmony-arm64@0.73.0': + resolution: {integrity: sha512-8weOr1OKknE0G2DbR6ejJUT9AOsoBU6cXlsetmbihHv1K+bK7qP61T6lJxY0k/aAO7GyOJiRGNlL+04r4eH8Xg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxfmt/binding-win32-arm64-msvc@0.73.0': + resolution: {integrity: sha512-mZV+QxXYgb8E18gzAFItb937VIsE4dqWdStrD3tRRC52UubOYEuU+e7NaIqUsGdB5YsJqNeuck3Ue/af2r9wyA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxfmt/binding-win32-ia32-msvc@0.73.0': + resolution: {integrity: sha512-QJPUsbgUb97ZPPMkFUq6VQq0fLhC4Np19KL9aB/qKVwXnpKE6MIiILXqzhKnQ/UbnEDjKJ7Xv1d6zH4bYPCUdQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxfmt/binding-win32-x64-msvc@0.73.0': + resolution: {integrity: sha512-cGcze2fu+ykIaFtkEvZlkZ3HvnCLk+WISthtq99zWTWn0x13t5L9TxvGdLZMUMvtfYR+ICkiCwKnguVubdcw0w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@oxlint-tsgolint/darwin-arm64@7.0.2004': + resolution: {integrity: sha512-uJk3ttju7Lz+Nv8WG4CsLyewoL1qf/Ny8S8OksJ7Bm/F14Tc9gMfW6arM1PCc57IzH/X/I79YsCWTgxX1FKibQ==} + cpu: [arm64] + os: [darwin] + + '@oxlint-tsgolint/darwin-x64@7.0.2004': + resolution: {integrity: sha512-0BFfHTzDxNDFPcu0UZAXT6CyCJHAXM0dZveyDb4KEHa2qF/DSnOKOrmvK/wFuFol9kvijbGM9JfuOsor+zWXRw==} + cpu: [x64] + os: [darwin] + + '@oxlint-tsgolint/linux-arm64@7.0.2004': + resolution: {integrity: sha512-TAehQc+qdRXyDN3nl/r/3/oPrBVrbtrDeGMkFyG6mf+XphpoJ2lAMVFLclyvrVZCw02RbKROjyw8h72XwQQHcw==} + cpu: [arm64] + os: [linux] + + '@oxlint-tsgolint/linux-x64@7.0.2004': + resolution: {integrity: sha512-LPunZvm6ZbWPfHMAyfZf9ci3HHvNEzLejO8zdqO3GoVGoSEHqqufHUD7+OgeatVSaJP7uXDJ2HaNOHIoH7go4Q==} + cpu: [x64] + os: [linux] + + '@oxlint-tsgolint/win32-arm64@7.0.2004': + resolution: {integrity: sha512-FVWplzDImWhiuawnIZVETaQecv4GWom6Jv4Fx2xj7hhXXDZ5okEgiw1gTCImHTIQsi2ycC5oSxVwrn69bMh7iw==} + cpu: [arm64] + os: [win32] + + '@oxlint-tsgolint/win32-x64@7.0.2004': + resolution: {integrity: sha512-7PsxuUx11Ry9DYTWcljTzRbmZY9B6O9fFFfZV+aodQEMy6pfRT3fhoQRv9PtGN/89z1pPz3nFKrsFm6WqNtX7w==} + cpu: [x64] + os: [win32] + + '@oxlint/binding-android-arm-eabi@1.88.0': + resolution: {integrity: sha512-k6Fgkf86ubfeH4GvqYsRolfuVAp0pfYVZvifSlXNHPdMaWUOfxUrmLEeDD7hF6U2oJuhsVxhSWq86/xCJ+9MmA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxlint/binding-android-arm64@1.88.0': + resolution: {integrity: sha512-AsIyhl9o1ejwtac7NMbhKpMdSml6NWR0ljKjZERxC8OHYDAW8o/Om9n1QHVLi4VCEUo42Zte2/Op9kyoGpJZMg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxlint/binding-darwin-arm64@1.88.0': + resolution: {integrity: sha512-qgBjB7eEKcCB4RqjXGuoSZq74g0wD09fWFJ+HWcCJcKaga8TeUHtb+BY0SsxdleSLBgx4RZ7qmgo0EzqEq7JoQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxlint/binding-darwin-x64@1.88.0': + resolution: {integrity: sha512-sCz3X5Mw/xdzEzn4fsCt1Iq8NKJnGNfhR+b9B5k+4DysYAHsmIhYoocnBPiQ9kvY3+pUun2A0Z8Vtun/Nv6YoQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxlint/binding-freebsd-x64@1.88.0': + resolution: {integrity: sha512-xTOdYOIqCufgIj0knvxu86FBfovP6QBiD7ngNva01gb8xPQCD5gXkE5APGczH35zStim1O3zqvFbLQmY85xXRg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxlint/binding-linux-arm-gnueabihf@1.88.0': + resolution: {integrity: sha512-BLadtw88NdYJBrAtC1dYzrPfSP2d5zgx6iuZycdD0YmZBJ2Nqbit9Z4PSaIb6gxK25dweArGMPbOmq/0ugwUPg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxlint/binding-linux-arm-musleabihf@1.88.0': + resolution: {integrity: sha512-wILSczl/DaZsCcf7j7tvNbssp8hxEHIJxrv4j7+JjI3TAL1U/JTWbeUtoJJC/vo8+2hkTmHLYoKJjmiNbijdXw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxlint/binding-linux-arm64-gnu@1.88.0': + resolution: {integrity: sha512-jutT2Hy8JCuZuMwIFHo2HtyxfOfBJHyQxlBHBK1SL9W2f8n/WhjAP0FnDMz9d/mjhv9+QA0mx5AdQ9fDjsrFFg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-arm64-musl@1.88.0': + resolution: {integrity: sha512-8N8iGV9hh4Lkeuq7QsEkjoXNRRflqR1G2qyoGYXcA0k5qllrdqmfylKEXyHIVERxqNDyMO4StqDQ0uLxXcBQAg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxlint/binding-linux-ppc64-gnu@1.88.0': + resolution: {integrity: sha512-5ydcQt3znNQ/rGEWYRvpS2cK9+T18P2VYgnyJ+eloEAwi9YUmsXy5VGrRqNWIK6qzWwHGnEE3ojVqqQNo+f0hA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-riscv64-gnu@1.88.0': + resolution: {integrity: sha512-iGx0uvFT54b/5DPJdEBCxYIrVB3v0uTy+JhRh3CyEp8/22BXDkG8rffkFwREdLsdj9mOrPbJYVOZw8ipcBuzjw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-riscv64-musl@1.88.0': + resolution: {integrity: sha512-Wt47mKMWelVjRjuR7BCFxXkB0m79K1sTEbqMHRWciKUgo5iv7sWsF4RXSOyFYHD9zerNrkRZblnN273rhwOA1Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@oxlint/binding-linux-s390x-gnu@1.88.0': + resolution: {integrity: sha512-g3L12KCS4+1gtUt3RbJ4F+Yxx4LNmmZLEPfhd8rAHEJjJk2lAgNfnjGoP/phJyhG5WS6VbNYbJtadJelNfvTMA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-x64-gnu@1.88.0': + resolution: {integrity: sha512-og/XHVDOD9ZJgRiZkT9DgzQd4sr+JZW7e4l17Q/jVMZiIbeEd4uIu9iAoUbTF1gIvVZoRc4QDOxyVUvQGp4WHg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-x64-musl@1.88.0': + resolution: {integrity: sha512-EmhBsp+xuKb6YbZNEMLBo80Xw71AZOIm18do8ni/GLX/Lw1XzNhVYpbxO1KasYtoAvrGtCOdCPULRlIE0bPbTQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxlint/binding-openharmony-arm64@1.88.0': + resolution: {integrity: sha512-DBUcx/KwYdg1DAz+G01P/GFv512J04EsZadbHptx2FTpWT/MWRg21ZToNHt9pnsfQRBQ3et/g+vqzbvrdAVbuA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxlint/binding-win32-arm64-msvc@1.88.0': + resolution: {integrity: sha512-xeVd0n4XG5HvynxfYvXi6uB+JvZbVZataowPS8cYpMbYg9mwE4sSyElFQd4LVJFifq8bRLDSR18XgEildmcXAg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxlint/binding-win32-ia32-msvc@1.88.0': + resolution: {integrity: sha512-MA6iOw//amleaz2mVMsZrA7NHlEexjTrhIxSMFCXQi6IUuQO+3Od00GZhr2iCYw6RFzMW36jkKK/WHBXMsoQAw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxlint/binding-win32-x64-msvc@1.88.0': + resolution: {integrity: sha512-3Sz6rVWe8Dy+ufsXurFN1GX2dX43F/lQMSLelK9gFjiba7nHvLlqlhR5cHlWVnCpSqUY1hN9pyCX9XToe6ve6g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@poppinss/colors@4.1.6': + resolution: {integrity: sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==} + + '@poppinss/dumper@0.6.5': + resolution: {integrity: sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==} + + '@poppinss/exception@1.2.3': + resolution: {integrity: sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==} + + '@rolldown/binding-android-arm-eabi@1.2.14': + resolution: {integrity: sha512-aWR+XKH9+rW7m5fWq/5360J3mHycrx/o6xZM2DQFdJnTMdyP7/WzxPjhtLbVWdKo2y612/4U1bWqb3HQhiF7vg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm64@1.2.14': + resolution: {integrity: sha512-QiVxHofl6A8lQU7WAtOUY4QMVZXohxwz7WJJoeh8NBEUyKfIkMRKhYyq8az/1RypNiIXzNTtiS6KwHz0erxYRQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.2.14': + resolution: {integrity: sha512-lTQOzHuBIooh3jIr5XINQkjPGEuGy+Dsy0meXDr6Sjty0b99kYgGh4uBC/8mJX1T0kC8d6S0aPP1Y+bHkh6aBw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.14': + resolution: {integrity: sha512-hyMKEGatjmBYCs/Q4sbIcL/GqpFEqsX3wc+HYVQ/85A4rxc1o7rPm4DUI4GV4k/h0ITddwFSGpqQunI14GXjTA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.2.14': + resolution: {integrity: sha512-u371GbXoVXrEgP20PwzoGNOdAOqAMhzo19JzzY+V4YmmnC+DTOoqdbMu+O+54emM59Mik/UdrtWgcuEDKWRPKA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.14': + resolution: {integrity: sha512-BqwKsdZQf6EqVWr8fv2MrDYzAvOZ7+NYFSJESRGs87fkseEhs0TU9TXgRJTkZoRRkxTizyEg1LKUXfU3/78uqg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.2.14': + resolution: {integrity: sha512-SD9kY8M009x/7s57Z1dgUVlP5+uYBgKQK0Tkr1WIWngrtUJmRCW1RJFMY7QDla2khXhmg2i5Io7MUjcmZNZ/KQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.2.14': + resolution: {integrity: sha512-BJ2CL19M6uuWesMgnqJzgxoI+N+eV7b0A9O9vLV42y+gitC41fNa8KElau1tHVzuLWX5GzEuxMPhAO0tQXQMkg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.2.14': + resolution: {integrity: sha512-4+Kl8daPV8NDHaD7mfCcc1pRM+Qg7ab8DyMm5FG5WoZgv4h2i3KFN1CybYBNbQqmuYm7ftJLvmMI1eHYJ22S/Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.14': + resolution: {integrity: sha512-V/h8ePq1fKDrmtFMz6xcCN3DKvuvMRrwwD1q0PkBeeo4DpK64biaKvqWGVxqCeYKqeRk7gE7/iKPxLCn08O97A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.14': + resolution: {integrity: sha512-WxalXzgrLVpKC93xfpaJ3gCXUWzeCr+FRCbDVD2mUAy4L6Vo3lNVz0epUEUpxPWJkLNYUwM4OSIikv36OJ9mLg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.2.14': + resolution: {integrity: sha512-3G3tnAmTpdk9jO3GQtyHXqeFD2SlecfTws/Y3M2mmj9nMBwwuLT4kur8sZKeu7ENUHSpVO3cIsm5A52LEWWwlg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.2.14': + resolution: {integrity: sha512-qyr5XiNGxm2ytx17vvtcJ9nXn6v1gENETi503bJx3OGwZ1tSonj7BosxbMa/xeAfSl5iS9X6KjEWYXLu6v1L7Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-win32-arm64-msvc@1.2.14': + resolution: {integrity: sha512-oA4o5o0S2yB199YyYXDzKUv1Z56Rc+mgOjwm7Z/vJ9Z8igiDPYvoOuDyo6g7AK/ZaF09nPhDKVnGBcYHO11GXA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.14': + resolution: {integrity: sha512-9mE94bf2GZUaR/fUSXCMpBoWkctu421Mi0ORpm4zqfbkjKep7RxzPFa5etcGs5h+2KApoWBOA/hAJa/7saGgEQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.0.1': + resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==} + + '@sindresorhus/is@7.2.0': + resolution: {integrity: sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==} + engines: {node: '>=18'} + + '@speed-highlight/core@1.2.24': + resolution: {integrity: sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==} + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + + '@types/estree@1.0.9': + resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} + + '@typescript/typescript-aix-ppc64@7.0.2': + resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [aix] + + '@typescript/typescript-darwin-arm64@7.0.2': + resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [darwin] + + '@typescript/typescript-darwin-x64@7.0.2': + resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [darwin] + + '@typescript/typescript-freebsd-arm64@7.0.2': + resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [freebsd] + + '@typescript/typescript-freebsd-x64@7.0.2': + resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [freebsd] + + '@typescript/typescript-linux-arm64@7.0.2': + resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [linux] + + '@typescript/typescript-linux-arm@7.0.2': + resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==} + engines: {node: '>=16.20.0'} + cpu: [arm] + os: [linux] + + '@typescript/typescript-linux-loong64@7.0.2': + resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==} + engines: {node: '>=16.20.0'} + cpu: [loong64] + os: [linux] + + '@typescript/typescript-linux-mips64el@7.0.2': + resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==} + engines: {node: '>=16.20.0'} + cpu: [mips64el] + os: [linux] + + '@typescript/typescript-linux-ppc64@7.0.2': + resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [linux] + + '@typescript/typescript-linux-riscv64@7.0.2': + resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==} + engines: {node: '>=16.20.0'} + cpu: [riscv64] + os: [linux] + + '@typescript/typescript-linux-s390x@7.0.2': + resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==} + engines: {node: '>=16.20.0'} + cpu: [s390x] + os: [linux] + + '@typescript/typescript-linux-x64@7.0.2': + resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [linux] + + '@typescript/typescript-netbsd-arm64@7.0.2': + resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [netbsd] + + '@typescript/typescript-netbsd-x64@7.0.2': + resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [netbsd] + + '@typescript/typescript-openbsd-arm64@7.0.2': + resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [openbsd] + + '@typescript/typescript-openbsd-x64@7.0.2': + resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [openbsd] + + '@typescript/typescript-sunos-x64@7.0.2': + resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [sunos] + + '@typescript/typescript-win32-arm64@7.0.2': + resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [win32] + + '@typescript/typescript-win32-x64@7.0.2': + resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [win32] + + '@vitest/mocker@5.0.5': + resolution: {integrity: sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==} + peerDependencies: + msw: ^2.4.9 || ^3.0.0 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + + '@vitest/spy@5.0.5': + resolution: {integrity: sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==} + + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + + blake3-wasm@2.1.5: + resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==} + + chai@6.3.0: + resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} + engines: {node: '>=18'} + + cookie@1.1.1: + resolution: {integrity: sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==} + engines: {node: '>=18'} + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + error-stack-parser-es@1.0.5: + resolution: {integrity: sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==} + + es-module-lexer@2.3.2: + resolution: {integrity: sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==} + + esbuild@0.28.2: + resolution: {integrity: sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==} + engines: {node: '>=18'} + hasBin: true + + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + + expect-type@1.4.0: + resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} + engines: {node: '>=12.0.0'} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + jose@6.2.12: + resolution: {integrity: sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==} + + kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + + magic-string@1.4.3: + resolution: {integrity: sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==} + + miniflare@5.20261012.1-beta: + resolution: {integrity: sha512-8Canhy6g9+vAhqMc0o80YphqYIwpiA3aAp8aX+uDXU7J/qbUeoZzcII9c2V1P4uT/eHD4SB93qet1o1bRY3BuQ==} + engines: {node: '>=22.0.0'} + + nanoid@3.3.20: + resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + node@runtime:24.22.0: + resolution: + type: variations + variants: + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-y7HWJfv6YbI/1KlJ6kHJsIu3kF+8dUA7sR1LzKc6VWY= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-aix-ppc64.tar.gz + targets: + - cpu: ppc64 + os: aix + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-apck2bUKXyK0gWze1EG1qNndrlRhkaXlt++lpeLuJtU= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-darwin-arm64.tar.gz + targets: + - cpu: arm64 + os: darwin + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-SV4/JzxkXzxGd9Q4MEzfxwFynqXexXKPXI52ot7OS5E= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-darwin-x64.tar.gz + targets: + - cpu: x64 + os: darwin + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-t+eZHVQHgVrfp0oqnNTbaDVSyM4y/0opXCLpcoScP10= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-linux-arm64.tar.gz + targets: + - cpu: arm64 + os: linux + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-jLp7v2iam1imXlgRFG6o0B5J0H5x97hGLk9v/NfS5/0= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-linux-ppc64le.tar.gz + targets: + - cpu: ppc64le + os: linux + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-WQFxj1Uf+qduJQny1hLVvhb6ic3fvi1gEyXBDify0rY= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-linux-s390x.tar.gz + targets: + - cpu: s390x + os: linux + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-qVoPryjW98STA28FWdbTK3uMeaoG5BWxJ4L5aUaERIQ= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-linux-x64-musl.tar.gz + targets: + - cpu: x64 + os: linux + libc: musl + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-KOoKQ43poTvXiR/XWO7mx4Ge6K9UQt/Y1FvWXlbUIow= + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-linux-x64.tar.gz + targets: + - cpu: x64 + os: linux + - resolution: + archive: zip + bin: + node: node.exe + integrity: sha256-OlwgmlvFnmWzvA+hPtXhZqJr09VTMoR/SYt2sDdAjWE= + prefix: node-v24.22.0-win-arm64 + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-win-arm64.zip + targets: + - cpu: arm64 + os: win32 + - resolution: + archive: zip + bin: + node: node.exe + integrity: sha256-+Wg6GYd+EqmxZzBcjbcQQNgSh2NZ3iHw0ul8PzIfgMM= + prefix: node-v24.22.0-win-x64 + type: binary + url: https://nodejs.org/download/release/v24.22.0/node-v24.22.0-win-x64.zip + targets: + - cpu: x64 + os: win32 + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-aBKlPls3+8MkdtbDURA40rw7vRs7s0jWwE3Sxwocj0o= + type: binary + url: https://unofficial-builds.nodejs.org/download/release/v24.22.0/node-v24.22.0-linux-arm64-musl.tar.gz + targets: + - cpu: arm64 + os: linux + libc: musl + - resolution: + archive: tarball + bin: + node: bin/node + integrity: sha256-cs0lP74MJTnVIgjtCY1Ht4/ywyunYpXY5rWwzgZ9y6U= + type: binary + url: https://unofficial-builds.nodejs.org/download/release/v24.22.0/node-v24.22.0-linux-x64-musl.tar.gz + targets: + - cpu: x64 + os: linux + libc: musl + version: 24.22.0 + hasBin: true + + obug@3.0.0: + resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==} + engines: {node: '>=12.20.0'} + + oxfmt@0.73.0: + resolution: {integrity: sha512-Ke4xbpuzqIBP4bkd48q815RhqWNJqOBzxVA9199M4qcF0y0LtpUv7UTg1dJ5ea6jw0RBUDZvX3qOUMNmmxfxbw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@astrojs/compiler-rs': ^0.4.0 || ^0.5.0 + svelte: ^5.0.0 + vite-plus: '*' + peerDependenciesMeta: + '@astrojs/compiler-rs': + optional: true + svelte: + optional: true + vite-plus: + optional: true + + oxlint-tsgolint@7.0.2004: + resolution: {integrity: sha512-vQ9WDF3fiZJvRdSDosNOflerOCOpwol6vWzVDxW76RcU19cjTh7engvkHLvmv+tzedR8fAiJUVUGr6IVZdkzXQ==} + hasBin: true + + oxlint@1.88.0: + resolution: {integrity: sha512-uIcFgw8BmqvFRGzH5+r7d2zJMEexwNSrEmM6WQNnGh3VkO0XYTEFoyxyNE6tjKMUib9Cue4XJA2DoWruO5D6aw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + oxlint-tsgolint: '>=7.0.2003' + vite-plus: '*' + peerDependenciesMeta: + oxlint-tsgolint: + optional: true + vite-plus: + optional: true + + path-to-regexp@6.3.0: + resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} + + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + + postcss@8.5.31: + resolution: {integrity: sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==} + engines: {node: ^10 || ^12 || >=14} + + rolldown@1.2.14: + resolution: {integrity: sha512-eTBTTqMR6uHKLgcUqpJP8ntzDI6V4LYA8negAMBEI7gkgVvOdrx6VsvS2Ym+83KhOPdLCHWJu0w7UQFJZhHKNw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + semver@7.8.5: + resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} + engines: {node: '>=10'} + hasBin: true + + sharp@0.35.5: + resolution: {integrity: sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==} + engines: {node: '>=20.9.0'} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + + source-map-js@1.2.2: + resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} + engines: {node: '>=0.10.0'} + + std-env@4.3.0: + resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} + + supports-color@10.2.2: + resolution: {integrity: sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==} + engines: {node: '>=18'} + + tinybench@6.2.2: + resolution: {integrity: sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA==} + engines: {node: '>=20.0.0'} + + tinyexec@1.3.1: + resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==} + engines: {node: '>=18'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tinypool@2.2.0: + resolution: {integrity: sha512-jBrmx4lYmaC9k/mgPbylxs7kBUxHtD8256up+HjLaDFfXScKJQyil+SWXSvhAtT7XHo+yTVlpB81PGmHP8oLSQ==} + engines: {node: ^20.0.0 || >=22.0.0} + + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + + typescript@7.0.2: + resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} + engines: {node: '>=16.20.0'} + hasBin: true + + undici@7.29.1: + resolution: {integrity: sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q==} + engines: {node: '>=20.18.1'} + + unenv@2.0.0-rc.24: + resolution: {integrity: sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==} + + vite@8.3.4: + resolution: {integrity: sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.7.1 + esbuild: ^0.27.0 || ^0.28.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + + vitest@5.0.5: + resolution: {integrity: sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==} + engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@opentelemetry/api': ^1.9.0 + '@types/node': ^22.0.0 || >=24.0.0 + '@vitest/browser-playwright': 5.0.5 + '@vitest/browser-preview': 5.0.5 + '@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0 + '@vitest/coverage-istanbul': 5.0.5 + '@vitest/coverage-v8': 5.0.5 + '@vitest/ui': 5.0.5 + happy-dom: '*' + jsdom: '*' + vite: ^6.4.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@opentelemetry/api': + optional: true + '@types/node': + optional: true + '@vitest/browser-playwright': + optional: true + '@vitest/browser-preview': + optional: true + '@vitest/browser-webdriverio': + optional: true + '@vitest/coverage-istanbul': + optional: true + '@vitest/coverage-v8': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + + why-is-node-running@3.2.1: + resolution: {integrity: sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==} + engines: {node: '>=20.11'} + hasBin: true + + workerd@1.20261012.1: + resolution: {integrity: sha512-tEHoMPsMga0seVjxfsR8Pd3f8IRqYwkq++dTUKI5Gdgj6zuSDluYwisydq+dn90SsIACwBquJUQ1nBpcOqaWTA==} + engines: {node: '>=16'} + hasBin: true + + wrangler@4.151.1: + resolution: {integrity: sha512-OAsa9UAHZshM6mq2PXcVoyxXgWThAanZMBc/IirtqEWd/BauRtmUKzAniOu/pU0pd3pxKuMZ2vsbF4eo6RiNDA==} + engines: {node: '>=22.0.0'} + hasBin: true + peerDependencies: + '@cloudflare/workers-types': ^5.20261006.1 + peerDependenciesMeta: + '@cloudflare/workers-types': + optional: true + + ws@8.21.0: + resolution: {integrity: sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + youch-core@0.3.3: + resolution: {integrity: sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==} + + youch@4.1.0-beta.10: + resolution: {integrity: sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==} + + zod@4.6.7: + resolution: {integrity: sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==} + +snapshots: + + '@cloudflare/kv-asset-handler@0.5.0': {} + + '@cloudflare/unenv-preset@2.16.2(unenv@2.0.0-rc.24)(workerd@1.20261012.1)': + dependencies: + unenv: 2.0.0-rc.24 + optionalDependencies: + workerd: 1.20261012.1 + + '@cloudflare/workerd-darwin-64@1.20261012.1': + optional: true + + '@cloudflare/workerd-darwin-arm64@1.20261012.1': + optional: true + + '@cloudflare/workerd-linux-64@1.20261012.1': + optional: true + + '@cloudflare/workerd-linux-arm64@1.20261012.1': + optional: true + + '@cloudflare/workerd-windows-64@1.20261012.1': + optional: true + + '@cspotcode/source-map-support@0.8.1': + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + + '@emnapi/runtime@1.11.3': + dependencies: + tslib: 2.8.1 + optional: true + + '@esbuild/aix-ppc64@0.28.2': + optional: true + + '@esbuild/android-arm64@0.28.2': + optional: true + + '@esbuild/android-arm@0.28.2': + optional: true + + '@esbuild/android-x64@0.28.2': + optional: true + + '@esbuild/darwin-arm64@0.28.2': + optional: true + + '@esbuild/darwin-x64@0.28.2': + optional: true + + '@esbuild/freebsd-arm64@0.28.2': + optional: true + + '@esbuild/freebsd-x64@0.28.2': + optional: true + + '@esbuild/linux-arm64@0.28.2': + optional: true + + '@esbuild/linux-arm@0.28.2': + optional: true + + '@esbuild/linux-ia32@0.28.2': + optional: true + + '@esbuild/linux-loong64@0.28.2': + optional: true + + '@esbuild/linux-mips64el@0.28.2': + optional: true + + '@esbuild/linux-ppc64@0.28.2': + optional: true + + '@esbuild/linux-riscv64@0.28.2': + optional: true + + '@esbuild/linux-s390x@0.28.2': + optional: true + + '@esbuild/linux-x64@0.28.2': + optional: true + + '@esbuild/netbsd-arm64@0.28.2': + optional: true + + '@esbuild/netbsd-x64@0.28.2': + optional: true + + '@esbuild/openbsd-arm64@0.28.2': + optional: true + + '@esbuild/openbsd-x64@0.28.2': + optional: true + + '@esbuild/openharmony-arm64@0.28.2': + optional: true + + '@esbuild/sunos-x64@0.28.2': + optional: true + + '@esbuild/win32-arm64@0.28.2': + optional: true + + '@esbuild/win32-ia32@0.28.2': + optional: true + + '@esbuild/win32-x64@0.28.2': + optional: true + + '@img/colour@1.1.0': {} + + '@img/sharp-darwin-arm64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-darwin-arm64': 1.3.4 + optional: true + + '@img/sharp-darwin-x64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-darwin-x64': 1.3.4 + optional: true + + '@img/sharp-freebsd-wasm32@0.35.5': + dependencies: + '@img/sharp-wasm32': 0.35.5 + optional: true + + '@img/sharp-libvips-darwin-arm64@1.3.4': + optional: true + + '@img/sharp-libvips-darwin-x64@1.3.4': + optional: true + + '@img/sharp-libvips-linux-arm64@1.3.4': + optional: true + + '@img/sharp-libvips-linux-arm@1.3.4': + optional: true + + '@img/sharp-libvips-linux-ppc64@1.3.4': + optional: true + + '@img/sharp-libvips-linux-riscv64@1.3.4': + optional: true + + '@img/sharp-libvips-linux-s390x@1.3.4': + optional: true + + '@img/sharp-libvips-linux-x64@1.3.4': + optional: true + + '@img/sharp-libvips-linuxmusl-arm64@1.3.4': + optional: true + + '@img/sharp-libvips-linuxmusl-x64@1.3.4': + optional: true + + '@img/sharp-linux-arm64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm64': 1.3.4 + optional: true + + '@img/sharp-linux-arm@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm': 1.3.4 + optional: true + + '@img/sharp-linux-ppc64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linux-ppc64': 1.3.4 + optional: true + + '@img/sharp-linux-riscv64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linux-riscv64': 1.3.4 + optional: true + + '@img/sharp-linux-s390x@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linux-s390x': 1.3.4 + optional: true + + '@img/sharp-linux-x64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linux-x64': 1.3.4 + optional: true + + '@img/sharp-linuxmusl-arm64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-arm64': 1.3.4 + optional: true + + '@img/sharp-linuxmusl-x64@0.35.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-x64': 1.3.4 + optional: true + + '@img/sharp-wasm32@0.35.5': + dependencies: + '@emnapi/runtime': 1.11.3 + optional: true + + '@img/sharp-webcontainers-wasm32@0.35.5': + dependencies: + '@img/sharp-wasm32': 0.35.5 + optional: true + + '@img/sharp-win32-arm64@0.35.5': + optional: true + + '@img/sharp-win32-ia32@0.35.5': + optional: true + + '@img/sharp-win32-x64@0.35.5': + optional: true + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/sourcemap-codec@1.6.0': {} + + '@jridgewell/trace-mapping@0.3.31': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.6.0 + + '@jridgewell/trace-mapping@0.3.9': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.6.0 + + '@modelcontextprotocol/core@2.3.1': + dependencies: + zod: 4.6.7 + + '@modelcontextprotocol/server@2.3.1': + dependencies: + '@modelcontextprotocol/core': 2.3.1 + zod: 4.6.7 + + '@oxc-project/types@0.154.0': {} + + '@oxfmt/binding-android-arm-eabi@0.73.0': + optional: true + + '@oxfmt/binding-android-arm64@0.73.0': + optional: true + + '@oxfmt/binding-darwin-arm64@0.73.0': + optional: true + + '@oxfmt/binding-darwin-x64@0.73.0': + optional: true + + '@oxfmt/binding-freebsd-x64@0.73.0': + optional: true + + '@oxfmt/binding-linux-arm-gnueabihf@0.73.0': + optional: true + + '@oxfmt/binding-linux-arm-musleabihf@0.73.0': + optional: true + + '@oxfmt/binding-linux-arm64-gnu@0.73.0': + optional: true + + '@oxfmt/binding-linux-arm64-musl@0.73.0': + optional: true + + '@oxfmt/binding-linux-ppc64-gnu@0.73.0': + optional: true + + '@oxfmt/binding-linux-riscv64-gnu@0.73.0': + optional: true + + '@oxfmt/binding-linux-riscv64-musl@0.73.0': + optional: true + + '@oxfmt/binding-linux-s390x-gnu@0.73.0': + optional: true + + '@oxfmt/binding-linux-x64-gnu@0.73.0': + optional: true + + '@oxfmt/binding-linux-x64-musl@0.73.0': + optional: true + + '@oxfmt/binding-openharmony-arm64@0.73.0': + optional: true + + '@oxfmt/binding-win32-arm64-msvc@0.73.0': + optional: true + + '@oxfmt/binding-win32-ia32-msvc@0.73.0': + optional: true + + '@oxfmt/binding-win32-x64-msvc@0.73.0': + optional: true + + '@oxlint-tsgolint/darwin-arm64@7.0.2004': + optional: true + + '@oxlint-tsgolint/darwin-x64@7.0.2004': + optional: true + + '@oxlint-tsgolint/linux-arm64@7.0.2004': + optional: true + + '@oxlint-tsgolint/linux-x64@7.0.2004': + optional: true + + '@oxlint-tsgolint/win32-arm64@7.0.2004': + optional: true + + '@oxlint-tsgolint/win32-x64@7.0.2004': + optional: true + + '@oxlint/binding-android-arm-eabi@1.88.0': + optional: true + + '@oxlint/binding-android-arm64@1.88.0': + optional: true + + '@oxlint/binding-darwin-arm64@1.88.0': + optional: true + + '@oxlint/binding-darwin-x64@1.88.0': + optional: true + + '@oxlint/binding-freebsd-x64@1.88.0': + optional: true + + '@oxlint/binding-linux-arm-gnueabihf@1.88.0': + optional: true + + '@oxlint/binding-linux-arm-musleabihf@1.88.0': + optional: true + + '@oxlint/binding-linux-arm64-gnu@1.88.0': + optional: true + + '@oxlint/binding-linux-arm64-musl@1.88.0': + optional: true + + '@oxlint/binding-linux-ppc64-gnu@1.88.0': + optional: true + + '@oxlint/binding-linux-riscv64-gnu@1.88.0': + optional: true + + '@oxlint/binding-linux-riscv64-musl@1.88.0': + optional: true + + '@oxlint/binding-linux-s390x-gnu@1.88.0': + optional: true + + '@oxlint/binding-linux-x64-gnu@1.88.0': + optional: true + + '@oxlint/binding-linux-x64-musl@1.88.0': + optional: true + + '@oxlint/binding-openharmony-arm64@1.88.0': + optional: true + + '@oxlint/binding-win32-arm64-msvc@1.88.0': + optional: true + + '@oxlint/binding-win32-ia32-msvc@1.88.0': + optional: true + + '@oxlint/binding-win32-x64-msvc@1.88.0': + optional: true + + '@poppinss/colors@4.1.6': + dependencies: + kleur: 4.1.5 + + '@poppinss/dumper@0.6.5': + dependencies: + '@poppinss/colors': 4.1.6 + '@sindresorhus/is': 7.2.0 + supports-color: 10.2.2 + + '@poppinss/exception@1.2.3': {} + + '@rolldown/binding-android-arm-eabi@1.2.14': + optional: true + + '@rolldown/binding-android-arm64@1.2.14': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.14': + optional: true + + '@rolldown/binding-darwin-x64@1.2.14': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.14': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.14': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.14': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.14': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.14': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.14': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.14': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.14': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.14': + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.14': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.14': + optional: true + + '@rolldown/pluginutils@1.0.1': {} + + '@sindresorhus/is@7.2.0': {} + + '@speed-highlight/core@1.2.24': {} + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/deep-eql@4.0.2': {} + + '@types/estree@1.0.9': {} + + '@typescript/typescript-aix-ppc64@7.0.2': + optional: true + + '@typescript/typescript-darwin-arm64@7.0.2': + optional: true + + '@typescript/typescript-darwin-x64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-x64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm@7.0.2': + optional: true + + '@typescript/typescript-linux-loong64@7.0.2': + optional: true + + '@typescript/typescript-linux-mips64el@7.0.2': + optional: true + + '@typescript/typescript-linux-ppc64@7.0.2': + optional: true + + '@typescript/typescript-linux-riscv64@7.0.2': + optional: true + + '@typescript/typescript-linux-s390x@7.0.2': + optional: true + + '@typescript/typescript-linux-x64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-sunos-x64@7.0.2': + optional: true + + '@typescript/typescript-win32-arm64@7.0.2': + optional: true + + '@typescript/typescript-win32-x64@7.0.2': + optional: true + + '@vitest/mocker@5.0.5(vite@8.3.4(esbuild@0.28.2))': + dependencies: + '@jridgewell/trace-mapping': 0.3.31 + '@vitest/spy': 5.0.5 + estree-walker: 3.0.3 + magic-string: 1.4.3 + optionalDependencies: + vite: 8.3.4(esbuild@0.28.2) + + '@vitest/spy@5.0.5': {} + + assertion-error@2.0.1: {} + + blake3-wasm@2.1.5: {} + + chai@6.3.0: {} + + cookie@1.1.1: {} + + detect-libc@2.1.2: {} + + error-stack-parser-es@1.0.5: {} + + es-module-lexer@2.3.2: {} + + esbuild@0.28.2: + optionalDependencies: + '@esbuild/aix-ppc64': 0.28.2 + '@esbuild/android-arm': 0.28.2 + '@esbuild/android-arm64': 0.28.2 + '@esbuild/android-x64': 0.28.2 + '@esbuild/darwin-arm64': 0.28.2 + '@esbuild/darwin-x64': 0.28.2 + '@esbuild/freebsd-arm64': 0.28.2 + '@esbuild/freebsd-x64': 0.28.2 + '@esbuild/linux-arm': 0.28.2 + '@esbuild/linux-arm64': 0.28.2 + '@esbuild/linux-ia32': 0.28.2 + '@esbuild/linux-loong64': 0.28.2 + '@esbuild/linux-mips64el': 0.28.2 + '@esbuild/linux-ppc64': 0.28.2 + '@esbuild/linux-riscv64': 0.28.2 + '@esbuild/linux-s390x': 0.28.2 + '@esbuild/linux-x64': 0.28.2 + '@esbuild/netbsd-arm64': 0.28.2 + '@esbuild/netbsd-x64': 0.28.2 + '@esbuild/openbsd-arm64': 0.28.2 + '@esbuild/openbsd-x64': 0.28.2 + '@esbuild/openharmony-arm64': 0.28.2 + '@esbuild/sunos-x64': 0.28.2 + '@esbuild/win32-arm64': 0.28.2 + '@esbuild/win32-ia32': 0.28.2 + '@esbuild/win32-x64': 0.28.2 + + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.9 + + expect-type@1.4.0: {} + + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + + fsevents@2.3.3: + optional: true + + jose@6.2.12: {} + + kleur@4.1.5: {} + + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + + magic-string@1.4.3: + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + + miniflare@5.20261012.1-beta: + dependencies: + '@cspotcode/source-map-support': 0.8.1 + sharp: 0.35.5 + undici: 7.29.1 + workerd: 1.20261012.1 + ws: 8.21.0 + youch: 4.1.0-beta.10 + transitivePeerDependencies: + - '@types/node' + - bufferutil + - utf-8-validate + + nanoid@3.3.20: {} + + node@runtime:24.22.0: {} + + obug@3.0.0: {} + + oxfmt@0.73.0: + dependencies: + tinypool: 2.2.0 + optionalDependencies: + '@oxfmt/binding-android-arm-eabi': 0.73.0 + '@oxfmt/binding-android-arm64': 0.73.0 + '@oxfmt/binding-darwin-arm64': 0.73.0 + '@oxfmt/binding-darwin-x64': 0.73.0 + '@oxfmt/binding-freebsd-x64': 0.73.0 + '@oxfmt/binding-linux-arm-gnueabihf': 0.73.0 + '@oxfmt/binding-linux-arm-musleabihf': 0.73.0 + '@oxfmt/binding-linux-arm64-gnu': 0.73.0 + '@oxfmt/binding-linux-arm64-musl': 0.73.0 + '@oxfmt/binding-linux-ppc64-gnu': 0.73.0 + '@oxfmt/binding-linux-riscv64-gnu': 0.73.0 + '@oxfmt/binding-linux-riscv64-musl': 0.73.0 + '@oxfmt/binding-linux-s390x-gnu': 0.73.0 + '@oxfmt/binding-linux-x64-gnu': 0.73.0 + '@oxfmt/binding-linux-x64-musl': 0.73.0 + '@oxfmt/binding-openharmony-arm64': 0.73.0 + '@oxfmt/binding-win32-arm64-msvc': 0.73.0 + '@oxfmt/binding-win32-ia32-msvc': 0.73.0 + '@oxfmt/binding-win32-x64-msvc': 0.73.0 + + oxlint-tsgolint@7.0.2004: + optionalDependencies: + '@oxlint-tsgolint/darwin-arm64': 7.0.2004 + '@oxlint-tsgolint/darwin-x64': 7.0.2004 + '@oxlint-tsgolint/linux-arm64': 7.0.2004 + '@oxlint-tsgolint/linux-x64': 7.0.2004 + '@oxlint-tsgolint/win32-arm64': 7.0.2004 + '@oxlint-tsgolint/win32-x64': 7.0.2004 + + oxlint@1.88.0(oxlint-tsgolint@7.0.2004): + optionalDependencies: + '@oxlint/binding-android-arm-eabi': 1.88.0 + '@oxlint/binding-android-arm64': 1.88.0 + '@oxlint/binding-darwin-arm64': 1.88.0 + '@oxlint/binding-darwin-x64': 1.88.0 + '@oxlint/binding-freebsd-x64': 1.88.0 + '@oxlint/binding-linux-arm-gnueabihf': 1.88.0 + '@oxlint/binding-linux-arm-musleabihf': 1.88.0 + '@oxlint/binding-linux-arm64-gnu': 1.88.0 + '@oxlint/binding-linux-arm64-musl': 1.88.0 + '@oxlint/binding-linux-ppc64-gnu': 1.88.0 + '@oxlint/binding-linux-riscv64-gnu': 1.88.0 + '@oxlint/binding-linux-riscv64-musl': 1.88.0 + '@oxlint/binding-linux-s390x-gnu': 1.88.0 + '@oxlint/binding-linux-x64-gnu': 1.88.0 + '@oxlint/binding-linux-x64-musl': 1.88.0 + '@oxlint/binding-openharmony-arm64': 1.88.0 + '@oxlint/binding-win32-arm64-msvc': 1.88.0 + '@oxlint/binding-win32-ia32-msvc': 1.88.0 + '@oxlint/binding-win32-x64-msvc': 1.88.0 + oxlint-tsgolint: 7.0.2004 + + path-to-regexp@6.3.0: {} + + pathe@2.0.3: {} + + picocolors@1.1.1: {} + + picomatch@4.0.7: {} + + postcss@8.5.31: + dependencies: + nanoid: 3.3.20 + picocolors: 1.1.1 + source-map-js: 1.2.2 + + rolldown@1.2.14: + dependencies: + '@oxc-project/types': 0.154.0 + '@rolldown/pluginutils': 1.0.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.14 + '@rolldown/binding-android-arm64': 1.2.14 + '@rolldown/binding-darwin-arm64': 1.2.14 + '@rolldown/binding-darwin-x64': 1.2.14 + '@rolldown/binding-freebsd-x64': 1.2.14 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.14 + '@rolldown/binding-linux-arm64-gnu': 1.2.14 + '@rolldown/binding-linux-arm64-musl': 1.2.14 + '@rolldown/binding-linux-ppc64-gnu': 1.2.14 + '@rolldown/binding-linux-s390x-gnu': 1.2.14 + '@rolldown/binding-linux-x64-gnu': 1.2.14 + '@rolldown/binding-linux-x64-musl': 1.2.14 + '@rolldown/binding-openharmony-arm64': 1.2.14 + '@rolldown/binding-win32-arm64-msvc': 1.2.14 + '@rolldown/binding-win32-x64-msvc': 1.2.14 + + semver@7.8.5: {} + + sharp@0.35.5: + dependencies: + '@img/colour': 1.1.0 + detect-libc: 2.1.2 + semver: 7.8.5 + optionalDependencies: + '@img/sharp-darwin-arm64': 0.35.5 + '@img/sharp-darwin-x64': 0.35.5 + '@img/sharp-freebsd-wasm32': 0.35.5 + '@img/sharp-libvips-darwin-arm64': 1.3.4 + '@img/sharp-libvips-darwin-x64': 1.3.4 + '@img/sharp-libvips-linux-arm': 1.3.4 + '@img/sharp-libvips-linux-arm64': 1.3.4 + '@img/sharp-libvips-linux-ppc64': 1.3.4 + '@img/sharp-libvips-linux-riscv64': 1.3.4 + '@img/sharp-libvips-linux-s390x': 1.3.4 + '@img/sharp-libvips-linux-x64': 1.3.4 + '@img/sharp-libvips-linuxmusl-arm64': 1.3.4 + '@img/sharp-libvips-linuxmusl-x64': 1.3.4 + '@img/sharp-linux-arm': 0.35.5 + '@img/sharp-linux-arm64': 0.35.5 + '@img/sharp-linux-ppc64': 0.35.5 + '@img/sharp-linux-riscv64': 0.35.5 + '@img/sharp-linux-s390x': 0.35.5 + '@img/sharp-linux-x64': 0.35.5 + '@img/sharp-linuxmusl-arm64': 0.35.5 + '@img/sharp-linuxmusl-x64': 0.35.5 + '@img/sharp-webcontainers-wasm32': 0.35.5 + '@img/sharp-win32-arm64': 0.35.5 + '@img/sharp-win32-ia32': 0.35.5 + '@img/sharp-win32-x64': 0.35.5 + + source-map-js@1.2.2: {} + + std-env@4.3.0: {} + + supports-color@10.2.2: {} + + tinybench@6.2.2: {} + + tinyexec@1.3.1: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + + tinypool@2.2.0: {} + + tslib@2.8.1: + optional: true + + typescript@7.0.2: + optionalDependencies: + '@typescript/typescript-aix-ppc64': 7.0.2 + '@typescript/typescript-darwin-arm64': 7.0.2 + '@typescript/typescript-darwin-x64': 7.0.2 + '@typescript/typescript-freebsd-arm64': 7.0.2 + '@typescript/typescript-freebsd-x64': 7.0.2 + '@typescript/typescript-linux-arm': 7.0.2 + '@typescript/typescript-linux-arm64': 7.0.2 + '@typescript/typescript-linux-loong64': 7.0.2 + '@typescript/typescript-linux-mips64el': 7.0.2 + '@typescript/typescript-linux-ppc64': 7.0.2 + '@typescript/typescript-linux-riscv64': 7.0.2 + '@typescript/typescript-linux-s390x': 7.0.2 + '@typescript/typescript-linux-x64': 7.0.2 + '@typescript/typescript-netbsd-arm64': 7.0.2 + '@typescript/typescript-netbsd-x64': 7.0.2 + '@typescript/typescript-openbsd-arm64': 7.0.2 + '@typescript/typescript-openbsd-x64': 7.0.2 + '@typescript/typescript-sunos-x64': 7.0.2 + '@typescript/typescript-win32-arm64': 7.0.2 + '@typescript/typescript-win32-x64': 7.0.2 + + undici@7.29.1: {} + + unenv@2.0.0-rc.24: + dependencies: + pathe: 2.0.3 + + vite@8.3.4(esbuild@0.28.2): + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.31 + rolldown: 1.2.14 + tinyglobby: 0.2.17 + optionalDependencies: + esbuild: 0.28.2 + fsevents: 2.3.3 + + vitest@5.0.5(vite@8.3.4(esbuild@0.28.2)): + dependencies: + '@types/chai': 5.2.3 + '@vitest/mocker': 5.0.5(vite@8.3.4(esbuild@0.28.2)) + chai: 6.3.0 + es-module-lexer: 2.3.2 + expect-type: 1.4.0 + magic-string: 1.4.3 + obug: 3.0.0 + picomatch: 4.0.7 + std-env: 4.3.0 + tinybench: 6.2.2 + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + vite: 8.3.4(esbuild@0.28.2) + why-is-node-running: 3.2.1 + transitivePeerDependencies: + - msw + + why-is-node-running@3.2.1: {} + + workerd@1.20261012.1: + optionalDependencies: + '@cloudflare/workerd-darwin-64': 1.20261012.1 + '@cloudflare/workerd-darwin-arm64': 1.20261012.1 + '@cloudflare/workerd-linux-64': 1.20261012.1 + '@cloudflare/workerd-linux-arm64': 1.20261012.1 + '@cloudflare/workerd-windows-64': 1.20261012.1 + + wrangler@4.151.1: + dependencies: + '@cloudflare/kv-asset-handler': 0.5.0 + '@cloudflare/unenv-preset': 2.16.2(unenv@2.0.0-rc.24)(workerd@1.20261012.1) + blake3-wasm: 2.1.5 + esbuild: 0.28.2 + miniflare: 5.20261012.1-beta + path-to-regexp: 6.3.0 + unenv: 2.0.0-rc.24 + workerd: 1.20261012.1 + optionalDependencies: + fsevents: 2.3.3 + transitivePeerDependencies: + - '@types/node' + - bufferutil + - utf-8-validate + + ws@8.21.0: {} + + youch-core@0.3.3: + dependencies: + '@poppinss/exception': 1.2.3 + error-stack-parser-es: 1.0.5 + + youch@4.1.0-beta.10: + dependencies: + '@poppinss/colors': 4.1.6 + '@poppinss/dumper': 0.6.5 + '@speed-highlight/core': 1.2.24 + cookie: 1.1.1 + youch-core: 0.3.3 + + zod@4.6.7: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..02365ef --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +allowBuilds: + esbuild: true + workerd: true diff --git a/prek.toml b/prek.toml new file mode 100644 index 0000000..dd06271 --- /dev/null +++ b/prek.toml @@ -0,0 +1,27 @@ +#:schema https://www.schemastore.org/prek.json +minimum_prek_version = "0.4.11" + +[priorities] +safety = 0 +format = 10 +lint = 20 +types = 30 +tests = 40 + +[[repos]] +repo = "builtin" +hooks = [ + { id = "check-merge-conflict", priority = "safety" }, + { id = "detect-private-key", priority = "safety" }, + { id = "check-added-large-files", priority = "safety" }, + { id = "check-yaml", priority = "safety", args = ["--allow-multiple-documents"] }, +] + +[[repos]] +repo = "local" +hooks = [ + { id = "oxfmt", name = "oxfmt", entry = "pnpm exec oxfmt --no-error-on-unmatched-pattern", language = "system", priority = "format", types_or = ["ts", "json"] }, + { id = "oxlint", name = "oxlint", entry = "pnpm exec oxlint", language = "system", pass_filenames = false, priority = "lint", types_or = ["ts"] }, + { id = "tsc", name = "tsc", entry = "pnpm exec tsc --noEmit -p .", language = "system", pass_filenames = false, priority = "types", types_or = ["ts"] }, + { id = "vitest", name = "vitest", entry = "pnpm exec vitest run", language = "system", pass_filenames = false, priority = "tests", types_or = ["ts", "xml", "json"] }, +] diff --git a/test/raw.d.ts b/test/raw.d.ts new file mode 100644 index 0000000..b7f0cf9 --- /dev/null +++ b/test/raw.d.ts @@ -0,0 +1,4 @@ +declare module "*?raw" { + const text: string; + export default text; +} diff --git a/test/support/cloudflare-workers.ts b/test/support/cloudflare-workers.ts new file mode 100644 index 0000000..6a5fa2a --- /dev/null +++ b/test/support/cloudflare-workers.ts @@ -0,0 +1,18 @@ +// Stand-in for the workerd module, so tools run under vitest: AI.run is whatever a test installs. +type Run = (model: string, inputs: Record) => Promise; + +let run: Run = () => Promise.reject(new Error("no AI.run stub installed")); + +export function stubAiRun(next: Run) { + run = next; +} + +export const env = { + AI: { run: (model: string, inputs: Record) => run(model, inputs) }, + ACCESS_TEAM_DOMAIN: "", + ACCESS_AUD: "", +}; + +export function waitUntil(promise: Promise) { + void promise; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ee7e316 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "es2024", + "lib": ["ES2024"], + "module": "esnext", + "moduleResolution": "bundler", + "types": [], + "resolveJsonModule": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "erasableSyntaxOnly": true, + "noEmit": true, + "skipLibCheck": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true + }, + "include": ["src", "test", "worker-configuration.d.ts"] +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..908fd10 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,12 @@ +import { fileURLToPath } from "node:url"; +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + resolve: { + alias: { + "cloudflare:workers": fileURLToPath( + new URL("test/support/cloudflare-workers.ts", import.meta.url), + ), + }, + }, +}); diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 0000000..ff4f890 --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,19 @@ +{ + "$schema": "node_modules/wrangler/config-schema.json", + "name": "clairic-mcp", + "main": "src/index.ts", + "compatibility_date": "2026-10-19", + // No dependency imports node:*; the MCP SDK resolves its workerd shims. + "compatibility_flags": ["no_nodejs_compat", "no_nodejs_compat_v2"], + // Access fronts only the custom domain `just deploy` attaches; a workers.dev or preview URL + // would reach the Worker without passing Access. + "workers_dev": false, + "preview_urls": false, + "observability": { "enabled": true }, + "ai": { "binding": "AI" }, + // Empty values reject every request. `just deploy` sets both from .env. + "vars": { + "ACCESS_TEAM_DOMAIN": "", + "ACCESS_AUD": "" + } +} From f2f7714419abc6e916b5f53e0491b5796dfc88cc Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:23:31 +0100 Subject: [PATCH 02/13] feat: extract tool over Clairic with typed fields --- src/auth.ts | 18 +++++++ src/clairic/client.ts | 105 ++++++++++++++++++++++++++++++++++++ src/clairic/fields.ts | 108 +++++++++++++++++++++++++++++++++++++ src/clairic/render.ts | 119 +++++++++++++++++++++++++++++++++++++++++ src/clairic/sources.ts | 102 +++++++++++++++++++++++++++++++++++ src/index.ts | 16 ++++++ src/lib/http.ts | 70 ++++++++++++++++++++++++ src/lib/result.ts | 49 +++++++++++++++++ src/server.ts | 10 ++++ src/tools/extract.ts | 99 ++++++++++++++++++++++++++++++++++ 10 files changed, 696 insertions(+) create mode 100644 src/auth.ts create mode 100644 src/clairic/client.ts create mode 100644 src/clairic/fields.ts create mode 100644 src/clairic/render.ts create mode 100644 src/clairic/sources.ts create mode 100644 src/index.ts create mode 100644 src/lib/http.ts create mode 100644 src/lib/result.ts create mode 100644 src/server.ts create mode 100644 src/tools/extract.ts diff --git a/src/auth.ts b/src/auth.ts new file mode 100644 index 0000000..13db2eb --- /dev/null +++ b/src/auth.ts @@ -0,0 +1,18 @@ +import { createRemoteJWKSet, jwtVerify } from "jose"; + +let accessKeys: ReturnType | undefined; + +// Access sits in front of the Worker and signs every request it lets through. +// Checking the signature here keeps a route Access does not cover from serving tools. +export async function isAccessVerified(request: Request, env: Env): Promise { + const assertion = request.headers.get("cf-access-jwt-assertion"); + if (!assertion) return false; + const issuer = `https://${env.ACCESS_TEAM_DOMAIN}`; + accessKeys ??= createRemoteJWKSet(new URL(`${issuer}/cdn-cgi/access/certs`)); + try { + await jwtVerify(assertion, accessKeys, { issuer, audience: env.ACCESS_AUD }); + return true; + } catch { + return false; + } +} diff --git a/src/clairic/client.ts b/src/clairic/client.ts new file mode 100644 index 0000000..2cfb40f --- /dev/null +++ b/src/clairic/client.ts @@ -0,0 +1,105 @@ +import type { FieldSpec } from "./fields"; + +import { env } from "cloudflare:workers"; + +import { backoffMs } from "../lib/http"; + +export interface ClairicImage { + content_type: string; + base64: string; +} + +export interface ClairicRequest { + state: string; + fields: Record; + images?: ClairicImage[]; + reference_date?: string; + options?: { include_quantiles?: boolean }; +} + +// Start and end character offsets into the state. +type Span = number[]; + +// Numbers, or ISO dates for date estimates. +export interface Distribution { + value: unknown; + mean?: unknown; + median?: unknown; + p10?: unknown; + p90?: unknown; + p_below?: number; + p_above?: number; + quantiles?: unknown[]; +} + +export interface ClairicAnswer extends Distribution { + type: string; + guess?: unknown; + p_null?: number; + confidence?: number; + unit?: string; + span?: Span; + spans?: Span[]; + steps?: Distribution[]; +} + +export interface ClairicResponse { + answers: Record; + truncated: boolean; + usage: { + input_tokens: number; + state_tokens?: number; + image_tokens?: number; + schema_tokens?: number; + passes?: number; + }; +} + +export class ClairicError extends Error { + // True when Clairic refused the request itself, so sending it again unchanged cannot help. + readonly rejected: boolean; + + constructor(message: string, rejected: boolean) { + super(message); + this.rejected = rejected; + } +} + +// Workers AI reports a request Clairic refuses as "3030: AiError: AiError: ()". +const rejectedCode = "3030"; + +function toClairicError(error: unknown): ClairicError { + const message = error instanceof Error ? error.message : String(error); + const code = /^(\d{4}):/.exec(message)?.[1]; + const reason = message + .replace(/^\d{4}:\s*/, "") + .replace(/^(AiError:\s*)+/, "") + .replace(/\s*\([0-9a-f-]{36}\)$/, ""); + return new ClairicError(reason, code === rejectedCode); +} + +export async function runClairic(request: ClairicRequest): Promise { + const inputs = { model: "clairic", ...request }; + for (let attempt = 1; ; attempt++) { + let response: unknown; + try { + response = await env.AI.run("@cf/cloudflare/clairic", inputs); + } catch (error) { + const failure = toClairicError(error); + if (failure.rejected || attempt === 2) throw failure; + await new Promise((resolve) => setTimeout(resolve, backoffMs(attempt))); + continue; + } + if (isClairicResponse(response)) return response; + throw new ClairicError( + "its response had no answers or usage; the preview API may have changed", + false, + ); + } +} + +const isRecord = (value: unknown): value is Record => + typeof value === "object" && value !== null && !Array.isArray(value); + +const isClairicResponse = (value: unknown): value is ClairicResponse => + isRecord(value) && isRecord(value.answers) && isRecord(value.usage); diff --git a/src/clairic/fields.ts b/src/clairic/fields.ts new file mode 100644 index 0000000..de23108 --- /dev/null +++ b/src/clairic/fields.ts @@ -0,0 +1,108 @@ +import * as z from "zod"; + +// Option texts follow Clairic's own input schema, so the caller reads the same rules the model enforces. +const instructions = z + .string() + .optional() + .describe( + "What the field should contain, in plain language, e.g. 'Total amount due, including tax and shipping, after discounts'. The main lever on accuracy.", + ); +const nullThreshold = z + .number() + .gt(0) + .max(1) + .optional() + .describe("Probability of null above which the value is null (default 0.5)."); +const unit = z.string().optional().describe("Unit label, e.g. 'USD' or 'kWh'."); +const integer = z.boolean().optional(); +const decimals = z.number().int().min(0).max(6).optional(); +const isoDate = z.string().regex(/^\d{4}-\d{2}-\d{2}$/); +const bound = z.union([z.number(), isoDate]); +const scale = z.enum(["linear", "log"]).optional(); + +const simple = (type: "text" | "date" | "time" | "datetime", description: string) => + z + .object({ type: z.literal(type), instructions, null_threshold: nullThreshold }) + .describe(description); + +export const fieldSpec = z.discriminatedUnion("type", [ + simple("text", "An exact span copied from the input, with its line number."), + z + .object({ + type: z.literal("number"), + instructions, + unit, + integer, + decimals, + null_threshold: nullThreshold, + }) + .describe("A number read from the input or worked out from it in one or two steps."), + simple("date", "A calendar date, ISO form."), + simple("time", "A time of day, ISO form."), + simple("datetime", "A date and time, ISO form."), + z + .object({ + type: z.literal("duration"), + instructions, + unit: z + .enum(["seconds", "minutes", "hours", "days", "weeks", "months", "years"]) + .optional() + .describe("Default seconds."), + integer, + decimals, + null_threshold: nullThreshold, + }) + .describe("A length of time, e.g. days between two dates in the input."), + z + .object({ + type: z.literal("list"), + instructions, + items: z.enum(["text", "number", "date"]), + unit, + decimals: decimals.describe("Number lists only."), + }) + .describe("Every matching value, in input order. Empty when nothing matches."), + z + .object({ + type: z.literal("estimate"), + instructions, + min: bound.describe("Lowest allowed value: a number, or an ISO date for date estimates."), + max: bound.describe("Highest allowed value: a number, or an ISO date for date estimates."), + step: z + .union([z.number().positive(), z.enum(["month", "year"])]) + .optional() + .describe( + "Grid of the answer: a positive number (days for date estimates), or month/year.", + ), + scale, + unit, + }) + .describe( + "A value the input does not state but gives evidence for (comparables, history, description). Returns a median and an 80% interval; without evidence the interval is wide.", + ), + z + .object({ + type: z.literal("forecast"), + instructions, + min: bound, + max: bound, + horizon: z.number().int().min(1).max(64).describe("Number of future steps."), + interval: z.enum(["step", "minute", "hour", "day", "week", "month", "quarter", "year"]), + step: z.union([z.number().positive(), z.enum(["month", "year"])]).optional(), + scale, + unit, + }) + .describe( + "Future values of a series in the input, one estimate per step. Basic: later steps flatten toward the average.", + ), +]); + +export type FieldSpec = z.infer; + +export const fieldName = z.string().regex(/^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/); + +export const fieldSpecs = z + .record(fieldName, fieldSpec) + .describe( + "Map of field name to typed spec; descriptive snake_case names help. No upper limit: thirty fields cost about the same as three.", + ); diff --git a/src/clairic/render.ts b/src/clairic/render.ts new file mode 100644 index 0000000..86e232a --- /dev/null +++ b/src/clairic/render.ts @@ -0,0 +1,119 @@ +import type { ClairicAnswer, ClairicResponse, Distribution } from "./client"; +import type { FieldSpec } from "./fields"; + +// A convention, not derived: answers outside these bounds are marked for the user to verify. +export const review = { minConfidence: 0.9, unsureNullLow: 0.1, unsureNullHigh: 0.9 } as const; + +export function probability(p: number): string { + if (p < 0.001) return "<0.001"; + if (p > 0.999) return ">0.999"; + return p.toFixed(3); +} + +export const lineOf = (state: string, offset: number) => state.slice(0, offset).split("\n").length; + +const show = (value: unknown) => + typeof value === "string" ? JSON.stringify(value) : String(value); +const round = (value: unknown) => + typeof value === "number" ? String(Number(value.toFixed(2))) : String(value); + +function needsCheck(answer: ClairicAnswer): boolean { + const unsureNull = + answer.p_null !== undefined && + answer.p_null > review.unsureNullLow && + answer.p_null < review.unsureNullHigh; + const weak = + answer.value !== null && + answer.confidence !== undefined && + answer.confidence < review.minConfidence; + return unsureNull || weak; +} + +function distribution(estimate: Distribution, unit: string): string { + const parts = [ + `median ${round(estimate.median)}`, + `80% interval ${round(estimate.p10)} to ${round(estimate.p90)}`, + ]; + if (estimate.mean !== undefined) parts.push(`mean ${round(estimate.mean)}`); + if ((estimate.p_below ?? 0) > 0.05) + parts.push(`p_below ${probability(estimate.p_below!)}: lower min`); + if ((estimate.p_above ?? 0) > 0.05) + parts.push(`p_above ${probability(estimate.p_above!)}: raise max`); + if (estimate.quantiles) + parts.push(`percentiles 1 to 99: ${estimate.quantiles.map(round).join(", ")}`); + return `${round(estimate.value)}${unit} (${parts.join(", ")})`; +} + +function renderAnswer( + name: string, + answer: ClairicAnswer, + spec: FieldSpec | undefined, + state: string, +): string[] { + const label = answer.unit ?? (spec && "unit" in spec ? spec.unit : undefined); + const unit = label ? ` ${label}` : ""; + const check = needsCheck(answer) ? " [check]" : ""; + const line = (offset: number | undefined) => + offset !== undefined && state ? `line ${lineOf(state, offset)}` : undefined; + + if (answer.type === "forecast" && answer.steps) { + return [ + `${name}: ${answer.steps.length} steps ahead`, + ...answer.steps.map((step, index) => ` ${index + 1}: ${distribution(step, unit)}`), + ]; + } + if (answer.type === "estimate") { + return [`${name}: ${distribution(answer, unit)}`]; + } + if (Array.isArray(answer.value)) { + if (!answer.value.length) return [`${name}: none found`]; + const confidence = + answer.confidence === undefined ? "" : ` (confidence ${probability(answer.confidence)})`; + return [ + `${name}: ${answer.value.length} item${answer.value.length === 1 ? "" : "s"}${confidence}${check}`, + ...answer.value.map((item, index) => { + const where = line(answer.spans?.[index]?.[0]); + return ` - ${show(item)}${unit}${where ? ` (${where})` : ""}`; + }), + ]; + } + if (answer.value === null) { + const parts = [`p_null ${probability(answer.p_null ?? 1)}`]; + if (answer.guess !== undefined && answer.guess !== null) { + const confidence = + answer.confidence === undefined ? "" : ` at confidence ${probability(answer.confidence)}`; + parts.push(`best guess ${show(answer.guess)}${unit}${confidence}`); + } + return [`${name}: null (${parts.join("; ")})${check}`]; + } + const parts = [line(answer.span?.[0])]; + if (answer.confidence !== undefined) parts.push(`confidence ${probability(answer.confidence)}`); + if (answer.p_null !== undefined) parts.push(`p_null ${probability(answer.p_null)}`); + return [`${name}: ${show(answer.value)}${unit} (${parts.filter(Boolean).join(", ")})${check}`]; +} + +export function renderAnswers( + response: ClairicResponse, + context: { state: string; fields: Record; referenceDate: string }, +): string { + const answers = Object.entries(response.answers); + const lines = answers.flatMap(([name, answer]) => + renderAnswer(name, answer, context.fields[name], context.state), + ); + const { input_tokens, passes = 1 } = response.usage; + lines.push( + "", + `Reference date ${context.referenceDate}. Clairic read ${input_tokens} input tokens in ${passes} pass${passes === 1 ? "" : "es"}.`, + ); + if (answers.some(([, answer]) => needsCheck(answer))) { + lines.push( + `[check] marks answers with confidence under ${review.minConfidence} or p_null between ${review.unsureNullLow} and ${review.unsureNullHigh}. Tell the user to verify them; do not present them as fact.`, + ); + } + if (response.truncated) { + lines.push( + "The input did not fit Clairic's 65,536-token window, so it read only the start; later text is missing from these answers. For a url, call again with a later offset; otherwise send the relevant part of the text.", + ); + } + return lines.join("\n"); +} diff --git a/src/clairic/sources.ts b/src/clairic/sources.ts new file mode 100644 index 0000000..5859f6b --- /dev/null +++ b/src/clairic/sources.ts @@ -0,0 +1,102 @@ +import type { ClairicImage } from "./client"; + +import { fetchSource } from "../lib/http"; +import { ToolInputError } from "../lib/result"; + +export const maxImageBytes = 4 * 1024 * 1024; +export const maxImagesBytes = 8 * 1024 * 1024; + +const entities: Record = { + amp: "&", + lt: "<", + gt: ">", + quot: '"', + apos: "'", + nbsp: " ", + pound: "£", + euro: "€", + cent: "¢", + yen: "¥", +}; + +function decodeEntities(text: string): string { + return text.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (match, name: string) => { + if (name[0] !== "#") return entities[name.toLowerCase()] ?? match; + const code = + name[1] === "x" || name[1] === "X" ? parseInt(name.slice(2), 16) : Number(name.slice(1)); + return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : match; + }); +} + +// Block-level closing tags become line breaks so line numbers in answers still mean something. +export function htmlToText(html: string): string { + return decodeEntities( + html + .replace(/<(script|style|noscript|template|svg|head)\b[\s\S]*?<\/\1\s*>/gi, " ") + .replace(//g, " ") + .replace( + /<(br|hr)\b[^>]*>|<\/(p|div|li|tr|h[1-6]|table|section|article|header|footer)\s*>/gi, + "\n", + ) + .replace(/<[^>]+>/g, " "), + ) + .replace(/[^\S\n]+/g, " ") + .replace(/ *\n */g, "\n") + .replace(/\n{2,}/g, "\n") + .trim(); +} + +const textTypes = /^(text\/|application\/(json|xml|[\w.+-]+\+(json|xml))$)/; + +export async function loadText(url: string): Promise { + const response = await fetchSource(url); + const contentType = (response.headers.get("content-type") ?? "") + .split(";")[0]! + .trim() + .toLowerCase(); + if (contentType === "text/html" || contentType === "application/xhtml+xml") { + return htmlToText(await response.text()); + } + if (textTypes.test(contentType) || contentType === "") return response.text(); + await response.body?.cancel(); + if (contentType.startsWith("image/")) { + throw new ToolInputError(`${url} is an image; pass it in image_urls instead of url.`); + } + if (contentType === "application/pdf") { + throw new ToolInputError( + `${url} is a PDF, which Clairic cannot read. Ask the user to paste its text, or pass public URLs of page screenshots in image_urls.`, + ); + } + throw new ToolInputError( + `${url} is ${contentType}; Clairic reads text and PNG, JPEG or WebP images only.`, + ); +} + +// The bytes decide the type: hosts often serve images as application/octet-stream. +export function imageType(bytes: Uint8Array): string | undefined { + const ascii = (start: number, end: number) => String.fromCharCode(...bytes.subarray(start, end)); + if (bytes[0] === 0x89 && ascii(1, 4) === "PNG") return "image/png"; + if (bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) return "image/jpeg"; + if (ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP") return "image/webp"; + return undefined; +} + +function base64(bytes: Uint8Array): string { + let binary = ""; + for (let start = 0; start < bytes.length; start += 0x8000) { + binary += String.fromCharCode(...bytes.subarray(start, start + 0x8000)); + } + return btoa(binary); +} + +export async function loadImage(url: string): Promise<{ image: ClairicImage; bytes: number }> { + const bytes = new Uint8Array(await (await fetchSource(url)).arrayBuffer()); + const contentType = imageType(bytes); + if (!contentType) throw new ToolInputError(`${url} is not a PNG, JPEG or WebP image.`); + if (bytes.length > maxImageBytes) { + throw new ToolInputError( + `${url} is ${(bytes.length / 2 ** 20).toFixed(1)} MiB; Clairic takes images up to 4 MiB.`, + ); + } + return { image: { content_type: contentType, base64: base64(bytes) }, bytes: bytes.length }; +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..87ec171 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,16 @@ +import { createMcpHandler } from "@modelcontextprotocol/server"; + +import { isAccessVerified } from "./auth"; +import { createServer } from "./server"; + +const mcp = createMcpHandler(createServer); + +export default { + async fetch(request, env) { + if (new URL(request.url).pathname !== "/mcp") return new Response("Not found", { status: 404 }); + if (env.DEV_SKIP_AUTH !== "1" && !(await isAccessVerified(request, env))) { + return new Response("Unauthorized", { status: 401 }); + } + return mcp.fetch(request); + }, +} satisfies ExportedHandler; diff --git a/src/lib/http.ts b/src/lib/http.ts new file mode 100644 index 0000000..ae7b8a2 --- /dev/null +++ b/src/lib/http.ts @@ -0,0 +1,70 @@ +import { version } from "../../package.json"; + +export const userAgent = `clairic-mcp/${version}`; + +export class UpstreamError extends Error { + readonly status: number; + readonly url: string; + readonly attempts: number; + readonly retryAfterMs?: number; + + constructor(status: number, url: string, attempts: number, retryAfterMs?: number) { + super(`${url} answered ${status || "nothing"} after ${attempts} attempts`); + this.status = status; + this.url = url; + this.attempts = attempts; + this.retryAfterMs = retryAfterMs; + } +} + +const retriedStatuses = new Set([408, 425, 429, 500, 502, 503, 504]); +const maxAttempts = 4; +const attemptTimeoutMs = 20_000; +// Total time one call may spend retrying; a tool call should answer, even with an error, within it. +const budgetMs = 30_000; + +const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + +// Full jitter: a random wait up to an exponentially growing cap. +export const backoffMs = (attempt: number) => Math.random() * Math.min(8_000, 500 * 2 ** attempt); + +export function serverWaitMs(headers: Headers, now: number): number | undefined { + const retryAfter = headers.get("retry-after"); + if (retryAfter) { + const seconds = Number(retryAfter); + if (Number.isFinite(seconds)) return seconds * 1000; + const date = Date.parse(retryAfter); + if (!Number.isNaN(date)) return Math.max(0, date - now); + } + const reset = Number(headers.get("x-ratelimit-reset")); + return reset ? Math.max(0, reset * 1000 - now) : undefined; +} + +// Returns the response unread, so the caller decides between text and bytes. +export async function fetchSource(url: string): Promise { + const deadline = Date.now() + budgetMs; + for (let attempt = 1; ; attempt++) { + let status = 0; + let wait: number | undefined; + try { + const response = await fetch(url, { + headers: { "user-agent": userAgent }, + signal: AbortSignal.timeout( + Math.max(1_000, Math.min(attemptTimeoutMs, deadline - Date.now())), + ), + }); + if (response.ok) return response; + await response.body?.cancel(); + status = response.status; + if (!retriedStatuses.has(status)) throw new UpstreamError(status, url, attempt); + wait = serverWaitMs(response.headers, Date.now()); + } catch (error) { + if (error instanceof UpstreamError) throw error; + } + const delay = wait ?? backoffMs(attempt); + if (attempt === maxAttempts || Date.now() + delay > deadline) { + throw new UpstreamError(status, url, attempt, wait); + } + await sleep(delay); + } +} diff --git a/src/lib/result.ts b/src/lib/result.ts new file mode 100644 index 0000000..9c4c36d --- /dev/null +++ b/src/lib/result.ts @@ -0,0 +1,49 @@ +import type { CallToolResult } from "@modelcontextprotocol/server"; + +import { ClairicError } from "../clairic/client"; +import { UpstreamError } from "./http"; + +// Thrown for input a tool cannot act on; the message says what to send instead. +export class ToolInputError extends Error {} + +function failure(text: string): CallToolResult { + return { isError: true, content: [{ type: "text", text }] }; +} + +// Transient failures have already been retried, so these messages never ask the caller to retry at once. +export function describeUpstreamError(error: UpstreamError): string { + const tries = `${error.attempts} attempt${error.attempts === 1 ? "" : "s"}`; + const wait = error.retryAfterMs + ? ` It asks clients to wait ${Math.ceil(error.retryAfterMs / 1000)} seconds.` + : ""; + if (error.status === 404) return `${error.url} returned 404; check the address.`; + if (error.status === 401 || error.status === 403) { + return `${error.url} needs a login or blocks scripts (HTTP ${error.status}). Ask the user to paste the text, or send a screenshot's public URL in image_urls.`; + } + if (error.status === 429) return `${error.url} is rate limiting this server (${tries}).${wait}`; + if (error.status === 0) { + return `${error.url} did not answer after ${tries}. Tell the user and offer to try again later.`; + } + if (error.status >= 500) { + return `${error.url} kept failing with HTTP ${error.status} after ${tries}.${wait} Tell the user and offer to try again later.`; + } + return `${error.url} answered HTTP ${error.status}.`; +} + +export function describeClairicError(error: ClairicError): string { + if (error.rejected) { + return `Clairic rejected the request: ${error.message}. Fix the field specs and call again.`; + } + return `Clairic failed: ${error.message}. Tell the user and offer to try again later.`; +} + +export async function runTool(work: () => Promise): Promise { + try { + return { content: [{ type: "text", text: await work() }] }; + } catch (error) { + if (error instanceof ToolInputError) return failure(error.message); + if (error instanceof UpstreamError) return failure(describeUpstreamError(error)); + if (error instanceof ClairicError) return failure(describeClairicError(error)); + throw error; + } +} diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..c5be575 --- /dev/null +++ b/src/server.ts @@ -0,0 +1,10 @@ +import { McpServer } from "@modelcontextprotocol/server"; + +import { version } from "../package.json"; +import { registerExtractTools } from "./tools/extract"; + +export function createServer(): McpServer { + const server = new McpServer({ name: "clairic-mcp", version }); + registerExtractTools(server); + return server; +} diff --git a/src/tools/extract.ts b/src/tools/extract.ts new file mode 100644 index 0000000..6e1a24f --- /dev/null +++ b/src/tools/extract.ts @@ -0,0 +1,99 @@ +import type { McpServer } from "@modelcontextprotocol/server"; + +import * as z from "zod"; + +import { type ClairicImage, runClairic } from "../clairic/client"; +import { fieldSpecs } from "../clairic/fields"; +import { renderAnswers } from "../clairic/render"; +import { loadImage, loadText, maxImagesBytes } from "../clairic/sources"; +import { runTool, ToolInputError } from "../lib/result"; + +// About 100k tokens, past Clairic's 65,536-token window; it truncates the rest and says so. +const maxStateCharacters = 400_000; + +const webUrl = z.url({ protocol: /^https?$/ }); + +export function registerExtractTools(server: McpServer) { + server.registerTool( + "extract", + { + title: "Extract typed values with Clairic", + description: `Answer a schema of typed fields from text, a web page or images with Clairic, Cloudflare's extraction model. Every answer is a value of the requested type or null, never invented text, and comes with its doubt: confidence and p_null for single values, a median and 80% interval for estimates and forecasts, line numbers for text copied from the input. + +Use it when the answer is a value: something to read (an order number, a deadline), compute in one or two steps (a total including tax, days between two dates), estimate from evidence (a fair price from comparable listings) or forecast from a series. Write the fields yourself from what the user needs; give each one instructions. It cannot judge or summarise: ask it for values, not opinions. + +Arithmetic over many steps or many table rows is unreliable: extract the inputs as separate fields and do the maths yourself. Answers marked [check] are uncertain; tell the user to verify them instead of stating them as fact. A null means the input does not determine the value; the best guess shown next to it is not an answer.`, + inputSchema: z.object({ + text: z.string().optional().describe("The text to read. Exclusive with url."), + url: webUrl + .optional() + .describe( + "A public page or text document the server fetches; HTML is reduced to its text. Not for PDFs or anything behind a login.", + ), + image_urls: z + .array(webUrl) + .max(4) + .optional() + .describe( + "Up to 4 public PNG, JPEG or WebP images (4 MiB each, 8 MiB together), read before the text, e.g. a photo of a receipt.", + ), + fields: fieldSpecs, + reference_date: z + .string() + .regex(/^\d{4}-\d{2}-\d{2}$/) + .optional() + .describe( + "ISO date for 'today' and for dates written without a year. Defaults to the current UTC date.", + ), + include_quantiles: z + .boolean() + .default(false) + .describe("Also return all 99 percentiles of estimates."), + offset: z + .number() + .int() + .min(0) + .default(0) + .describe("url only: character offset into the page text, for pages Clairic truncated."), + }), + annotations: { readOnlyHint: true, openWorldHint: true }, + }, + ({ text, url, image_urls, fields, reference_date, include_quantiles, offset }) => + runTool(async () => { + if (text !== undefined && url) + throw new ToolInputError("Send either text or url, not both."); + if (!text && !url && !image_urls?.length) { + throw new ToolInputError("Send the input as text, url or image_urls."); + } + if (offset && !url) throw new ToolInputError("offset applies to url only."); + if (!Object.keys(fields).length) throw new ToolInputError("Define at least one field."); + + const [page, loaded] = await Promise.all([ + url ? loadText(url) : undefined, + Promise.all((image_urls ?? []).map(loadImage)), + ]); + const totalBytes = loaded.reduce((sum, { bytes }) => sum + bytes, 0); + if (totalBytes > maxImagesBytes) { + throw new ToolInputError( + `The images total ${(totalBytes / 2 ** 20).toFixed(1)} MiB; Clairic takes 8 MiB at most. Send fewer.`, + ); + } + const images: ClairicImage[] = loaded.map(({ image }) => image); + const state = (page ?? text ?? "").slice(offset, offset + maxStateCharacters); + if (url && !state) throw new ToolInputError(`${url} has no text at offset ${offset}.`); + const referenceDate = reference_date ?? new Date().toISOString().slice(0, 10); + + const response = await runClairic({ + state, + fields, + ...(images.length && { images }), + reference_date: referenceDate, + ...(include_quantiles && { options: { include_quantiles } }), + }); + const source = url + ? `Read ${url}${offset ? ` from character ${offset}` : ""} (${state.length} characters).\n\n` + : ""; + return source + renderAnswers(response, { state, fields, referenceDate }); + }), + ); +} From 2038c5ccbf6a8f657ca79dc7a924da5a5ba5da2a Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:23:33 +0100 Subject: [PATCH 03/13] test: fixtures from live Clairic responses --- test/fields.test.ts | 21 ++++ test/fixtures/clairic/forecast.json | 1 + test/fixtures/clairic/invalid-estimate.txt | 1 + test/fixtures/clairic/invoice.json | 1 + test/render.test.ts | 79 +++++++++++++ test/sources.test.ts | 53 +++++++++ test/support/invoice.ts | 26 +++++ test/tools.test.ts | 126 +++++++++++++++++++++ 8 files changed, 308 insertions(+) create mode 100644 test/fields.test.ts create mode 100644 test/fixtures/clairic/forecast.json create mode 100644 test/fixtures/clairic/invalid-estimate.txt create mode 100644 test/fixtures/clairic/invoice.json create mode 100644 test/render.test.ts create mode 100644 test/sources.test.ts create mode 100644 test/support/invoice.ts create mode 100644 test/tools.test.ts diff --git a/test/fields.test.ts b/test/fields.test.ts new file mode 100644 index 0000000..9b19b1d --- /dev/null +++ b/test/fields.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "vitest"; + +import { fieldSpecs } from "../src/clairic/fields"; +import { invoiceFields } from "./support/invoice"; + +test("accepts the fields of Cloudflare's invoice example", () => { + expect(fieldSpecs.safeParse(invoiceFields).success).toBe(true); +}); + +test.each([ + ["an estimate without bounds", { price: { type: "estimate" } }], + ["a list without items", { names: { type: "list" } }], + [ + "a forecast beyond 64 steps", + { kwh: { type: "forecast", min: 0, max: 1, horizon: 65, interval: "month" } }, + ], + ["a field name Clairic refuses", { "1st total": { type: "number" } }], + ["an unknown type", { total: { type: "money" } }], +])("rejects %s", (_, fields) => { + expect(fieldSpecs.safeParse(fields).success).toBe(false); +}); diff --git a/test/fixtures/clairic/forecast.json b/test/fixtures/clairic/forecast.json new file mode 100644 index 0000000..5f49e74 --- /dev/null +++ b/test/fixtures/clairic/forecast.json @@ -0,0 +1 @@ +{"model":"clairic","answers":{"next_months":{"type":"forecast","value":[225.91430707590655,230.23623891114093,232.15941225388192],"median":[225.43177315182643,229.35092016676546,230.93913912795887],"p10":[201.59312420119463,199.244498104155,195.79589141950612],"p90":[250.42353174071158,263.5081244743037,271.5938732056746],"steps":[{"value":225.91430707590655,"mean":225.91430707590655,"median":225.43177315182643,"p10":201.59312420119463,"p90":250.42353174071158,"p_below":0.000005264747414912563,"p_above":0.0000016967242117971182},{"value":230.23623891114093,"mean":230.23623891114093,"median":229.35092016676546,"p10":199.244498104155,"p90":263.5081244743037,"p_below":0.000006306878731265897,"p_above":0.000002611600393720437},{"value":232.15941225388192,"mean":232.15941225388192,"median":230.93913912795887,"p10":195.79589141950612,"p90":271.5938732056746,"p_below":0.000008053795681917109,"p_above":0.000004022432221972849}]}},"truncated":false,"usage":{"state_tokens":84,"image_tokens":0,"schema_tokens":294,"input_tokens":378,"output_tokens":0,"passes":1}} diff --git a/test/fixtures/clairic/invalid-estimate.txt b/test/fixtures/clairic/invalid-estimate.txt new file mode 100644 index 0000000..9e949e6 --- /dev/null +++ b/test/fixtures/clairic/invalid-estimate.txt @@ -0,0 +1 @@ +3030: AiError: AiError: estimate price needs numeric min and max (1985aebb-7949-47e9-9cec-ab7440a8f87e) diff --git a/test/fixtures/clairic/invoice.json b/test/fixtures/clairic/invoice.json new file mode 100644 index 0000000..b279a7e --- /dev/null +++ b/test/fixtures/clairic/invoice.json @@ -0,0 +1 @@ +{"model":"clairic","answers":{"invoice_number":{"type":"text","p_null":0.000004589956006384455,"span":[8,16],"guess":"INV-2291","confidence":0.9999902248382568,"value":"INV-2291"},"due_date":{"type":"date","p_null":8.645929483463988e-7,"guess":"2026-10-02","confidence":0.9999784234498212,"value":"2026-10-02"},"total":{"type":"number","p_null":6.477912393165752e-7,"guess":1080,"confidence":0.9999247828116393,"value":1080},"contacts":{"type":"list","value":["Dana Ruiz","Priya Shah"],"spans":[[120,129],[131,141]],"confidence":0.999724577631014},"po_number":{"type":"text","p_null":0.9999997615814209,"span":[8,16],"guess":"INV-2291","confidence":0.9993239641189575,"value":null},"days_to_pay":{"type":"estimate","value":31,"mean":31.321300181940213,"median":31,"p10":24,"p90":38,"p_below":0.000002900673962358269,"p_above":0.00000768005247664405},"payment_term":{"type":"duration","p_null":2.5854138829828344e-9,"unit":"days","guess":30,"confidence":1,"value":30}},"truncated":false,"usage":{"state_tokens":62,"image_tokens":0,"schema_tokens":502,"input_tokens":688,"output_tokens":0,"passes":3}} diff --git a/test/render.test.ts b/test/render.test.ts new file mode 100644 index 0000000..3e0489b --- /dev/null +++ b/test/render.test.ts @@ -0,0 +1,79 @@ +import type { ClairicResponse } from "../src/clairic/client"; +import type { FieldSpec } from "../src/clairic/fields"; + +import { expect, test } from "vitest"; + +import { lineOf, probability, renderAnswers } from "../src/clairic/render"; +import forecast from "./fixtures/clairic/forecast.json"; +import invoice from "./fixtures/clairic/invoice.json"; +import { invoiceFields, invoiceState } from "./support/invoice"; + +const render = (response: ClairicResponse, fields = invoiceFields, state = invoiceState) => + renderAnswers(response, { state, fields, referenceDate: "2026-10-19" }); + +test("renders every answer type of the recorded invoice", () => { + expect(render(invoice).split("\n")).toEqual([ + 'invoice_number: "INV-2291" (line 1, confidence >0.999, p_null <0.001)', + 'due_date: "2026-10-02" (confidence >0.999, p_null <0.001)', + "total: 1080 USD (confidence >0.999, p_null <0.001)", + "contacts: 2 items (confidence >0.999)", + ' - "Dana Ruiz" (line 3)', + ' - "Priya Shah" (line 3)', + 'po_number: null (p_null >0.999; best guess "INV-2291" at confidence >0.999)', + "days_to_pay: 31 (median 31, 80% interval 24 to 38, mean 31.32)", + "payment_term: 30 days (confidence >0.999, p_null <0.001)", + "", + "Reference date 2026-10-19. Clairic read 688 input tokens in 3 passes.", + ]); +}); + +test("renders a forecast one step per line", () => { + const fields: Record = { + next_months: { type: "forecast", min: 0, max: 600, horizon: 3, interval: "month", unit: "kWh" }, + }; + expect(render(forecast, fields, "").split("\n").slice(0, 4)).toEqual([ + "next_months: 3 steps ahead", + " 1: 225.91 kWh (median 225.43, 80% interval 201.59 to 250.42, mean 225.91)", + " 2: 230.24 kWh (median 229.35, 80% interval 199.24 to 263.51, mean 230.24)", + " 3: 232.16 kWh (median 230.94, 80% interval 195.8 to 271.59, mean 232.16)", + ]); +}); + +test("marks weak and unsure answers for review and explains the mark", () => { + const response: ClairicResponse = { + answers: { + weak: { type: "number", value: 12, confidence: 0.6, p_null: 0.01 }, + unsure_null: { type: "text", value: null, p_null: 0.7, guess: "x", confidence: 0.5 }, + sure_null: { type: "text", value: null, p_null: 0.98 }, + }, + truncated: false, + usage: { input_tokens: 10, passes: 1 }, + }; + const lines = render(response, {}, "").split("\n"); + expect(lines[0]).toBe("weak: 12 (confidence 0.600, p_null 0.010) [check]"); + expect(lines[1]).toBe( + 'unsure_null: null (p_null 0.700; best guess "x" at confidence 0.500) [check]', + ); + expect(lines[2]).toBe("sure_null: null (p_null 0.980)"); + expect(lines.at(-1)).toMatch(/^\[check\] marks answers/); +}); + +test("flags estimates clipped by their bounds and truncated input", () => { + const response: ClairicResponse = { + answers: { + price: { type: "estimate", value: 100, median: 100, p10: 90, p90: 100, p_above: 0.3 }, + }, + truncated: true, + usage: { input_tokens: 65_536 }, + }; + const text = render(response, {}, ""); + expect(text).toContain("p_above 0.300: raise max"); + expect(text).toContain("read only the start"); +}); + +test("line numbers count newlines before the offset", () => { + expect(lineOf("a\nb\nc", 0)).toBe(1); + expect(lineOf("a\nb\nc", 2)).toBe(2); + expect(lineOf("a\nb\nc", 4)).toBe(3); + expect(probability(0.5)).toBe("0.500"); +}); diff --git a/test/sources.test.ts b/test/sources.test.ts new file mode 100644 index 0000000..de4238f --- /dev/null +++ b/test/sources.test.ts @@ -0,0 +1,53 @@ +import { beforeEach, expect, test, vi } from "vitest"; + +import { htmlToText, imageType, loadImage, loadText, maxImageBytes } from "../src/clairic/sources"; + +const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 1, 2, 3]); + +let served: Response; + +beforeEach(() => { + vi.stubGlobal("fetch", () => Promise.resolve(served)); +}); + +test("reduces HTML to text with one block per line", () => { + const html = `x +

Order A-88412

+

Total: £649 + £52.10 & VAT

  • one
  • two
`; + expect(htmlToText(html)).toBe("Order A-88412\nTotal: £649 + £52.10 & VAT\none\ntwo"); +}); + +test("passes plain text and JSON through", async () => { + served = new Response('{"total": 12}', { + headers: { "content-type": "application/json; charset=utf-8" }, + }); + expect(await loadText("https://example.com/a.json")).toBe('{"total": 12}'); +}); + +test.each([ + ["application/pdf", /is a PDF/], + ["image/png", /pass it in image_urls/], + ["application/zip", /reads text and PNG, JPEG or WebP/], +])("refuses %s as text", async (contentType, message) => { + served = new Response("x", { headers: { "content-type": contentType } }); + await expect(loadText("https://example.com/f")).rejects.toThrow(message); +}); + +test("recognises images by their bytes, whatever the server calls them", async () => { + expect(imageType(png)).toBe("image/png"); + expect(imageType(new Uint8Array([0xff, 0xd8, 0xff, 0xe0]))).toBe("image/jpeg"); + expect(imageType(new TextEncoder().encode("RIFF\0\0\0\0WEBPVP8 "))).toBe("image/webp"); + served = new Response(png, { headers: { "content-type": "application/octet-stream" } }); + const { image, bytes } = await loadImage("https://example.com/receipt"); + expect(image).toEqual({ content_type: "image/png", base64: btoa(String.fromCharCode(...png)) }); + expect(bytes).toBe(png.length); +}); + +test("refuses files that are not images and images over 4 MiB", async () => { + served = new Response(""); + await expect(loadImage("https://example.com/page")).rejects.toThrow(/not a PNG, JPEG or WebP/); + const big = new Uint8Array(maxImageBytes + 1); + big.set(png); + served = new Response(big); + await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/up to 4 MiB/); +}); diff --git a/test/support/invoice.ts b/test/support/invoice.ts new file mode 100644 index 0000000..b63e148 --- /dev/null +++ b/test/support/invoice.ts @@ -0,0 +1,26 @@ +import type { FieldSpec } from "../../src/clairic/fields"; + +// The exact state and fields the fixtures were recorded with. +export const invoiceState = + "Invoice INV-2291 from Northwind Supply, issued 2026-09-02, net 30.\n4 pallets at $250.00 each, shipping $80.00.\nContact: Dana Ruiz, Priya Shah."; + +export const invoiceFields: Record = { + invoice_number: { type: "text" }, + due_date: { type: "date", instructions: "Issue date plus the net payment days" }, + total: { + type: "number", + decimals: 2, + unit: "USD", + instructions: "Amount due including shipping", + }, + contacts: { type: "list", items: "text" }, + po_number: { type: "text", instructions: "Purchase order number" }, + days_to_pay: { + type: "estimate", + min: 0, + max: 120, + step: 1, + instructions: "Days after issue until this invoice is paid", + }, + payment_term: { type: "duration", unit: "days", integer: true, instructions: "Net payment term" }, +}; diff --git a/test/tools.test.ts b/test/tools.test.ts new file mode 100644 index 0000000..d41907f --- /dev/null +++ b/test/tools.test.ts @@ -0,0 +1,126 @@ +import { createMcpHandler } from "@modelcontextprotocol/server"; +import { beforeEach, expect, test, vi } from "vitest"; + +import { createServer } from "../src/server"; +import rejection from "./fixtures/clairic/invalid-estimate.txt?raw"; +import invoice from "./fixtures/clairic/invoice.json"; +import { stubAiRun } from "./support/cloudflare-workers"; +import { invoiceFields, invoiceState } from "./support/invoice"; + +const mcp = createMcpHandler(createServer); + +interface ToolResult { + isError?: boolean; + text: string; +} + +async function callTool(args: Record): Promise { + const response = await mcp.fetch( + new Request("http://localhost/mcp", { + method: "POST", + headers: { + "content-type": "application/json", + accept: "application/json, text/event-stream", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "tools/call", + params: { name: "extract", arguments: args }, + }), + }), + ); + const body = await response.text(); + const json = body.startsWith("{") ? body : (/^data: (.*)$/m.exec(body)?.[1] ?? ""); + const reply = JSON.parse(json).result; + return { isError: reply.isError, text: reply.content[0].text }; +} + +let sent: Record[]; +const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); + +beforeEach(() => { + sent = []; + stubAiRun((_, inputs) => { + sent.push(inputs); + return Promise.resolve(invoice); + }); + vi.stubGlobal("fetch", (url: string) => + Promise.resolve( + url.endsWith(".png") + ? new Response(png) + : new Response(`

${invoiceState.replaceAll("\n", "

")}

`, { + headers: { "content-type": "text/html" }, + }), + ), + ); +}); + +test("extracts from text and sends Clairic the request it documents", async () => { + const { isError, text } = await callTool({ + text: invoiceState, + fields: invoiceFields, + reference_date: "2026-10-19", + }); + expect(isError).toBeUndefined(); + expect(text).toContain("total: 1080 USD"); + expect(sent).toEqual([ + { model: "clairic", state: invoiceState, fields: invoiceFields, reference_date: "2026-10-19" }, + ]); +}); + +test("reads a page as text with its block structure", async () => { + const { text } = await callTool({ url: "https://example.com/invoice", fields: invoiceFields }); + expect(sent[0]?.state).toBe(invoiceState); + expect(sent[0]?.reference_date).toMatch(/^\d{4}-\d{2}-\d{2}$/); + expect(text).toMatch(/^Read https:\/\/example\.com\/invoice \(\d+ characters\)/); +}); + +test("embeds image URLs as base64 because Clairic refuses remote URLs", async () => { + await callTool({ image_urls: ["https://example.com/receipt.png"], fields: invoiceFields }); + expect(sent[0]?.images).toEqual([ + { content_type: "image/png", base64: btoa(String.fromCharCode(...png)) }, + ]); + expect(sent[0]?.state).toBe(""); +}); + +test.each([ + [{ text: "a", url: "https://example.com" }, "either text or url"], + [{}, "as text, url or image_urls"], + [{ text: "a", offset: 5 }, "offset applies to url only"], +])("refuses %j", async (input, message) => { + const { isError, text } = await callTool({ ...input, fields: invoiceFields }); + expect(isError).toBe(true); + expect(text).toContain(message); + expect(sent).toEqual([]); +}); + +test("passes Clairic's own reason through when it rejects the fields", async () => { + let calls = 0; + stubAiRun(() => { + calls++; + return Promise.reject(new Error(rejection.trim())); + }); + const { isError, text } = await callTool({ + text: "x", + fields: { price: { type: "estimate", min: 0, max: 1 } }, + }); + expect(isError).toBe(true); + expect(text).toBe( + "Clairic rejected the request: estimate price needs numeric min and max. Fix the field specs and call again.", + ); + expect(calls).toBe(1); +}); + +test("retries an unexplained Workers AI failure once", async () => { + let calls = 0; + stubAiRun(() => { + calls++; + return calls === 1 + ? Promise.reject(new Error("3040: Capacity temporarily exceeded")) + : Promise.resolve(invoice); + }); + const { isError } = await callTool({ text: invoiceState, fields: invoiceFields }); + expect(isError).toBeUndefined(); + expect(calls).toBe(2); +}); From 21439e7130c77a79846ee4eb1d450e7ae26e7859 Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:25:37 +0100 Subject: [PATCH 04/13] fix: cap fetched pages and images while reading, not after --- src/clairic/sources.ts | 25 +++++++++++++++---------- src/lib/http.ts | 30 ++++++++++++++++++++++++++++++ test/sources.test.ts | 20 ++++++++++++++++++-- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/src/clairic/sources.ts b/src/clairic/sources.ts index 5859f6b..47e15ca 100644 --- a/src/clairic/sources.ts +++ b/src/clairic/sources.ts @@ -1,10 +1,12 @@ import type { ClairicImage } from "./client"; -import { fetchSource } from "../lib/http"; +import { fetchSource, readCapped } from "../lib/http"; import { ToolInputError } from "../lib/result"; export const maxImageBytes = 4 * 1024 * 1024; export const maxImagesBytes = 8 * 1024 * 1024; +// Pages carry markup on top of the 400,000 characters Clairic is sent; anything larger is refused unread. +export const maxTextBytes = 8 * 1024 * 1024; const entities: Record = { amp: "&", @@ -54,10 +56,17 @@ export async function loadText(url: string): Promise { .split(";")[0]! .trim() .toLowerCase(); - if (contentType === "text/html" || contentType === "application/xhtml+xml") { - return htmlToText(await response.text()); + const html = contentType === "text/html" || contentType === "application/xhtml+xml"; + if (html || textTypes.test(contentType) || contentType === "") { + const bytes = await readCapped(response, maxTextBytes); + if (!bytes) { + throw new ToolInputError( + `${url} is larger than ${maxTextBytes / 2 ** 20} MiB. Ask the user for the relevant part as text.`, + ); + } + const text = new TextDecoder().decode(bytes); + return html ? htmlToText(text) : text; } - if (textTypes.test(contentType) || contentType === "") return response.text(); await response.body?.cancel(); if (contentType.startsWith("image/")) { throw new ToolInputError(`${url} is an image; pass it in image_urls instead of url.`); @@ -90,13 +99,9 @@ function base64(bytes: Uint8Array): string { } export async function loadImage(url: string): Promise<{ image: ClairicImage; bytes: number }> { - const bytes = new Uint8Array(await (await fetchSource(url)).arrayBuffer()); + const bytes = await readCapped(await fetchSource(url), maxImageBytes); + if (!bytes) throw new ToolInputError(`${url} is larger than 4 MiB, Clairic's limit per image.`); const contentType = imageType(bytes); if (!contentType) throw new ToolInputError(`${url} is not a PNG, JPEG or WebP image.`); - if (bytes.length > maxImageBytes) { - throw new ToolInputError( - `${url} is ${(bytes.length / 2 ** 20).toFixed(1)} MiB; Clairic takes images up to 4 MiB.`, - ); - } return { image: { content_type: contentType, base64: base64(bytes) }, bytes: bytes.length }; } diff --git a/src/lib/http.ts b/src/lib/http.ts index ae7b8a2..bd95087 100644 --- a/src/lib/http.ts +++ b/src/lib/http.ts @@ -40,6 +40,36 @@ export function serverWaitMs(headers: Headers, now: number): number | undefined return reset ? Math.max(0, reset * 1000 - now) : undefined; } +// Reads at most maxBytes, so a huge file cannot exhaust the isolate's memory; undefined when larger. +export async function readCapped( + response: Response, + maxBytes: number, +): Promise { + if (Number(response.headers.get("content-length")) > maxBytes) { + await response.body?.cancel(); + return undefined; + } + const reader = response.body?.getReader(); + if (!reader) return new Uint8Array(); + const chunks: Uint8Array[] = []; + let total = 0; + for (let chunk = await reader.read(); !chunk.done; chunk = await reader.read()) { + total += chunk.value.length; + if (total > maxBytes) { + await reader.cancel(); + return undefined; + } + chunks.push(chunk.value); + } + const bytes = new Uint8Array(total); + let offset = 0; + for (const chunk of chunks) { + bytes.set(chunk, offset); + offset += chunk.length; + } + return bytes; +} + // Returns the response unread, so the caller decides between text and bytes. export async function fetchSource(url: string): Promise { const deadline = Date.now() + budgetMs; diff --git a/test/sources.test.ts b/test/sources.test.ts index de4238f..0c15c33 100644 --- a/test/sources.test.ts +++ b/test/sources.test.ts @@ -1,6 +1,13 @@ import { beforeEach, expect, test, vi } from "vitest"; -import { htmlToText, imageType, loadImage, loadText, maxImageBytes } from "../src/clairic/sources"; +import { + htmlToText, + imageType, + loadImage, + loadText, + maxImageBytes, + maxTextBytes, +} from "../src/clairic/sources"; const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 1, 2, 3]); @@ -49,5 +56,14 @@ test("refuses files that are not images and images over 4 MiB", async () => { const big = new Uint8Array(maxImageBytes + 1); big.set(png); served = new Response(big); - await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/up to 4 MiB/); + await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/larger than 4 MiB/); + served = new Response(png, { headers: { "content-length": String(maxImageBytes + 1) } }); + await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/larger than 4 MiB/); +}); + +test("refuses text larger than the cap without reading it whole", async () => { + served = new Response(new Uint8Array(maxTextBytes + 1), { + headers: { "content-type": "text/plain" }, + }); + await expect(loadText("https://example.com/huge.txt")).rejects.toThrow(/larger than 8 MiB/); }); From df217e3428fe07d75eded926510135e9bb9c46c7 Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:25:40 +0100 Subject: [PATCH 05/13] feat: access and deploy recipes --- .env.example | 5 +++-- justfile | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 justfile diff --git a/.env.example b/.env.example index 884ef56..5857676 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,7 @@ CLOUDFLARE_ACCOUNT_ID= -# Only for `just access`; needs Access: Apps and Policies Write -CLOUDFLARE_API_TOKEN= +# Only for `just access`: an API token with Access: Apps and Policies Write. +# Not named CLOUDFLARE_API_TOKEN, so wrangler keeps using your own login to deploy. +ACCESS_API_TOKEN= CLAIRIC_DOMAIN=clairic.example.com ACCESS_TEAM_DOMAIN=yourteam.cloudflareaccess.com # Comma-separated Access login emails allowed to connect diff --git a/justfile b/justfile new file mode 100644 index 0000000..3eb6a96 --- /dev/null +++ b/justfile @@ -0,0 +1,63 @@ +set dotenv-load + +# Create the Access policy and application that guard the Worker, then store the app's AUD in .env +access: + #!/usr/bin/env bash + set -euo pipefail + : "${CLOUDFLARE_ACCOUNT_ID:?set it in .env}" "${ACCESS_API_TOKEN:?set it in .env or the environment}" + : "${CLAIRIC_DOMAIN:?set it in .env}" "${ACCESS_EMAILS:?set it in .env}" + if [ -n "${ACCESS_AUD:-}" ]; then + echo "ACCESS_AUD is already set in .env, so the Access application exists. Clear it to create another." >&2 + exit 1 + fi + api="https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/access" + post() { + local reply + if ! reply=$(curl -sS --fail-with-body -X POST "$api/$1" \ + -H "Authorization: Bearer $ACCESS_API_TOKEN" -H "Content-Type: application/json" --data "$2"); then + echo "POST $1 failed: $reply" >&2 + return 1 + fi + echo "$reply" + } + policy_body=$(jq -cn --arg emails "$ACCESS_EMAILS" '{ + name: "clairic-mcp users", + decision: "allow", + include: ($emails | split(",") | map(gsub("^\\s+|\\s+$"; "")) | map(select(. != "")) | map({email: {email: .}})) + }') + policy=$(post policies "$policy_body" | jq -r .result.id) + echo "Created Access policy $policy" >&2 + app_body=$(jq -cn --arg domain "$CLAIRIC_DOMAIN" --arg policy "$policy" --arg idp "${ACCESS_IDP_ID:-}" '{ + name: "clairic-mcp", + type: "self_hosted", + domain: $domain, + destinations: [{type: "public", uri: $domain}], + policies: [{id: $policy, precedence: 1}], + session_duration: "24h", + oauth_configuration: { + enabled: true, + grant: {session_duration: "336h", access_token_lifetime: "15m"}, + dynamic_client_registration: { + enabled: true, + allowed_uris: ["https://claude.ai/api/mcp/auth_callback"], + allow_any_on_localhost: true, + allow_any_on_loopback: true + } + } + } + (if $idp == "" then {} else {allowed_idps: [$idp], auto_redirect_to_identity: true} end)') + app=$(post apps "$app_body") + echo "Created Access application $(jq -r .result.id <<< "$app") on $CLAIRIC_DOMAIN" >&2 + { grep -v '^ACCESS_AUD=' .env || true; echo "ACCESS_AUD=$(jq -r .result.aud <<< "$app")"; } > .env.next + mv .env.next .env + +# Check, test and deploy the Worker to CLAIRIC_DOMAIN behind the Access application +deploy: + #!/usr/bin/env bash + set -euo pipefail + : "${CLAIRIC_DOMAIN:?set it in .env}" "${ACCESS_TEAM_DOMAIN:?set it in .env}" "${ACCESS_AUD:?run just access first}" + pnpm exec tsc --noEmit -p . + pnpm exec oxlint + pnpm exec oxfmt --check . + pnpm exec vitest run + pnpm exec wrangler deploy --domain "$CLAIRIC_DOMAIN" \ + --var "ACCESS_TEAM_DOMAIN:$ACCESS_TEAM_DOMAIN" --var "ACCESS_AUD:$ACCESS_AUD" From b111d1c275bea21dcd603afce08abfac2fb35fba Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:27:08 +0100 Subject: [PATCH 06/13] fix: keep the page title when reducing HTML to text --- src/clairic/sources.ts | 4 ++-- test/sources.test.ts | 2 +- wrangler.jsonc | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/clairic/sources.ts b/src/clairic/sources.ts index 47e15ca..0316874 100644 --- a/src/clairic/sources.ts +++ b/src/clairic/sources.ts @@ -34,10 +34,10 @@ function decodeEntities(text: string): string { export function htmlToText(html: string): string { return decodeEntities( html - .replace(/<(script|style|noscript|template|svg|head)\b[\s\S]*?<\/\1\s*>/gi, " ") + .replace(/<(script|style|noscript|template|svg)\b[\s\S]*?<\/\1\s*>/gi, " ") .replace(//g, " ") .replace( - /<(br|hr)\b[^>]*>|<\/(p|div|li|tr|h[1-6]|table|section|article|header|footer)\s*>/gi, + /<(br|hr)\b[^>]*>|<\/(title|p|div|li|tr|h[1-6]|table|section|article|header|footer)\s*>/gi, "\n", ) .replace(/<[^>]+>/g, " "), diff --git a/test/sources.test.ts b/test/sources.test.ts index 0c15c33..37f31ea 100644 --- a/test/sources.test.ts +++ b/test/sources.test.ts @@ -21,7 +21,7 @@ test("reduces HTML to text with one block per line", () => { const html = `x

Order A-88412

Total: £649 + £52.10 & VAT

  • one
  • two
`; - expect(htmlToText(html)).toBe("Order A-88412\nTotal: £649 + £52.10 & VAT\none\ntwo"); + expect(htmlToText(html)).toBe("x\nOrder A-88412\nTotal: £649 + £52.10 & VAT\none\ntwo"); }); test("passes plain text and JSON through", async () => { diff --git a/wrangler.jsonc b/wrangler.jsonc index ff4f890..118f04e 100644 --- a/wrangler.jsonc +++ b/wrangler.jsonc @@ -10,7 +10,8 @@ "workers_dev": false, "preview_urls": false, "observability": { "enabled": true }, - "ai": { "binding": "AI" }, + // Workers AI always runs remotely, so `wrangler dev` bills the account too. + "ai": { "binding": "AI", "remote": true }, // Empty values reject every request. `just deploy` sets both from .env. "vars": { "ACCESS_TEAM_DOMAIN": "", From 70838606864ea8a9c9bc145d2cd87f85fbd83742 Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:30:26 +0100 Subject: [PATCH 07/13] chore: target ES2025 --- .oxfmtrc.json | 7 +------ tsconfig.json | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 94100ea..daf5240 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -13,10 +13,5 @@ "newlinesBetween": true }, "overrides": [{ "files": ["**/*.jsonc"], "options": { "trailingComma": "none" } }], - "ignorePatterns": [ - "worker-configuration.d.ts", - "test/fixtures/**", - "prek.toml", - "**/*.md" - ] + "ignorePatterns": ["worker-configuration.d.ts", "test/fixtures/**", "prek.toml", "**/*.md"] } diff --git a/tsconfig.json b/tsconfig.json index ee7e316..fd1e708 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "target": "es2024", - "lib": ["ES2024"], + "target": "es2025", + "lib": ["ES2025"], "module": "esnext", "moduleResolution": "bundler", "types": [], From dc98f667dc5ef382222fc48dd9066d815b5f4e6a Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 23:01:39 +0100 Subject: [PATCH 08/13] fix: findings from an xhigh review - field specs are strict objects and dates are real ISO dates - fetched text honours the charset and decodes typographic entities - a body that breaks off mid-read is an upstream error, not a crash - x-ratelimit-reset is read as epoch or relative seconds - small estimates keep three significant digits; empty lists show confidence - the reply says when input past 400,000 characters was cut and where to resume - DEV_SKIP_AUTH type-checks without .dev.vars, so a fresh clone deploys - just access deletes its policy when creating the app fails - prek formats jsonc and yaml and runs tests on text fixtures - the rejection fixture is re-recorded with the request its test sends --- justfile | 3 + prek.toml | 4 +- src/clairic/client.ts | 4 +- src/clairic/fields.ts | 15 ++--- src/clairic/render.ts | 31 ++++++--- src/clairic/sources.ts | 73 +++++++++++++++------- src/index.ts | 4 +- src/lib/http.ts | 24 ++++--- src/lib/result.ts | 2 +- src/tools/extract.ts | 18 +++--- test/fields.test.ts | 2 + test/fixtures/clairic/invalid-estimate.txt | 1 - test/fixtures/clairic/inverted-bounds.txt | 1 + test/http.test.ts | 15 +++++ test/render.test.ts | 25 ++++++-- test/sources.test.ts | 29 +++++++++ test/tools.test.ts | 14 +++-- 17 files changed, 199 insertions(+), 66 deletions(-) delete mode 100644 test/fixtures/clairic/invalid-estimate.txt create mode 100644 test/fixtures/clairic/inverted-bounds.txt create mode 100644 test/http.test.ts diff --git a/justfile b/justfile index 3eb6a96..6c484e5 100644 --- a/justfile +++ b/justfile @@ -27,6 +27,8 @@ access: }') policy=$(post policies "$policy_body" | jq -r .result.id) echo "Created Access policy $policy" >&2 + # A policy left without its application would be duplicated by the next run, since ACCESS_AUD stays empty. + trap 'echo "Deleting Access policy $policy" >&2; curl -sS -o /dev/null -X DELETE "$api/policies/$policy" -H "Authorization: Bearer $ACCESS_API_TOKEN"' ERR app_body=$(jq -cn --arg domain "$CLAIRIC_DOMAIN" --arg policy "$policy" --arg idp "${ACCESS_IDP_ID:-}" '{ name: "clairic-mcp", type: "self_hosted", @@ -46,6 +48,7 @@ access: } } + (if $idp == "" then {} else {allowed_idps: [$idp], auto_redirect_to_identity: true} end)') app=$(post apps "$app_body") + trap - ERR echo "Created Access application $(jq -r .result.id <<< "$app") on $CLAIRIC_DOMAIN" >&2 { grep -v '^ACCESS_AUD=' .env || true; echo "ACCESS_AUD=$(jq -r .result.aud <<< "$app")"; } > .env.next mv .env.next .env diff --git a/prek.toml b/prek.toml index dd06271..45ef76b 100644 --- a/prek.toml +++ b/prek.toml @@ -20,8 +20,8 @@ hooks = [ [[repos]] repo = "local" hooks = [ - { id = "oxfmt", name = "oxfmt", entry = "pnpm exec oxfmt --no-error-on-unmatched-pattern", language = "system", priority = "format", types_or = ["ts", "json"] }, + { id = "oxfmt", name = "oxfmt", entry = "pnpm exec oxfmt --no-error-on-unmatched-pattern", language = "system", priority = "format", types_or = ["ts", "json", "jsonc", "yaml"] }, { id = "oxlint", name = "oxlint", entry = "pnpm exec oxlint", language = "system", pass_filenames = false, priority = "lint", types_or = ["ts"] }, { id = "tsc", name = "tsc", entry = "pnpm exec tsc --noEmit -p .", language = "system", pass_filenames = false, priority = "types", types_or = ["ts"] }, - { id = "vitest", name = "vitest", entry = "pnpm exec vitest run", language = "system", pass_filenames = false, priority = "tests", types_or = ["ts", "xml", "json"] }, + { id = "vitest", name = "vitest", entry = "pnpm exec vitest run", language = "system", pass_filenames = false, priority = "tests", types_or = ["ts", "json", "plain-text"] }, ] diff --git a/src/clairic/client.ts b/src/clairic/client.ts index 2cfb40f..08d6e53 100644 --- a/src/clairic/client.ts +++ b/src/clairic/client.ts @@ -2,7 +2,7 @@ import type { FieldSpec } from "./fields"; import { env } from "cloudflare:workers"; -import { backoffMs } from "../lib/http"; +import { backoffMs, sleep } from "../lib/http"; export interface ClairicImage { content_type: string; @@ -87,7 +87,7 @@ export async function runClairic(request: ClairicRequest): Promise setTimeout(resolve, backoffMs(attempt))); + await sleep(backoffMs(attempt)); continue; } if (isClairicResponse(response)) return response; diff --git a/src/clairic/fields.ts b/src/clairic/fields.ts index de23108..a9cd88c 100644 --- a/src/clairic/fields.ts +++ b/src/clairic/fields.ts @@ -16,19 +16,20 @@ const nullThreshold = z const unit = z.string().optional().describe("Unit label, e.g. 'USD' or 'kWh'."); const integer = z.boolean().optional(); const decimals = z.number().int().min(0).max(6).optional(); -const isoDate = z.string().regex(/^\d{4}-\d{2}-\d{2}$/); +export const isoDate = z.iso.date(); const bound = z.union([z.number(), isoDate]); const scale = z.enum(["linear", "log"]).optional(); +// Strict objects, so a misspelled option fails validation instead of being dropped unseen. const simple = (type: "text" | "date" | "time" | "datetime", description: string) => z - .object({ type: z.literal(type), instructions, null_threshold: nullThreshold }) + .strictObject({ type: z.literal(type), instructions, null_threshold: nullThreshold }) .describe(description); export const fieldSpec = z.discriminatedUnion("type", [ simple("text", "An exact span copied from the input, with its line number."), z - .object({ + .strictObject({ type: z.literal("number"), instructions, unit, @@ -41,7 +42,7 @@ export const fieldSpec = z.discriminatedUnion("type", [ simple("time", "A time of day, ISO form."), simple("datetime", "A date and time, ISO form."), z - .object({ + .strictObject({ type: z.literal("duration"), instructions, unit: z @@ -54,7 +55,7 @@ export const fieldSpec = z.discriminatedUnion("type", [ }) .describe("A length of time, e.g. days between two dates in the input."), z - .object({ + .strictObject({ type: z.literal("list"), instructions, items: z.enum(["text", "number", "date"]), @@ -63,7 +64,7 @@ export const fieldSpec = z.discriminatedUnion("type", [ }) .describe("Every matching value, in input order. Empty when nothing matches."), z - .object({ + .strictObject({ type: z.literal("estimate"), instructions, min: bound.describe("Lowest allowed value: a number, or an ISO date for date estimates."), @@ -81,7 +82,7 @@ export const fieldSpec = z.discriminatedUnion("type", [ "A value the input does not state but gives evidence for (comparables, history, description). Returns a median and an 80% interval; without evidence the interval is wide.", ), z - .object({ + .strictObject({ type: z.literal("forecast"), instructions, min: bound, diff --git a/src/clairic/render.ts b/src/clairic/render.ts index 86e232a..f482de5 100644 --- a/src/clairic/render.ts +++ b/src/clairic/render.ts @@ -10,12 +10,28 @@ export function probability(p: number): string { return p.toFixed(3); } -export const lineOf = (state: string, offset: number) => state.slice(0, offset).split("\n").length; +// Newline offsets are found once, so a long list of spans does not rescan the state per item. +export function lineFinder(state: string): (offset: number) => number { + const breaks = Array.from(state.matchAll(/\n/g), (match) => match.index); + return (offset) => { + let low = 0; + let high = breaks.length; + while (low < high) { + const middle = (low + high) >>> 1; + if (breaks[middle]! < offset) low = middle + 1; + else high = middle; + } + return low + 1; + }; +} const show = (value: unknown) => typeof value === "string" ? JSON.stringify(value) : String(value); -const round = (value: unknown) => - typeof value === "number" ? String(Number(value.toFixed(2))) : String(value); +// Below 1, three significant digits instead of two decimals, so small estimates do not print as 0. +const round = (value: unknown) => { + if (typeof value !== "number") return String(value); + return String(Number(Math.abs(value) < 1 ? value.toPrecision(3) : value.toFixed(2))); +}; function needsCheck(answer: ClairicAnswer): boolean { const unsureNull = @@ -48,13 +64,13 @@ function renderAnswer( name: string, answer: ClairicAnswer, spec: FieldSpec | undefined, - state: string, + lineAt: ((offset: number) => number) | undefined, ): string[] { const label = answer.unit ?? (spec && "unit" in spec ? spec.unit : undefined); const unit = label ? ` ${label}` : ""; const check = needsCheck(answer) ? " [check]" : ""; const line = (offset: number | undefined) => - offset !== undefined && state ? `line ${lineOf(state, offset)}` : undefined; + offset !== undefined && lineAt ? `line ${lineAt(offset)}` : undefined; if (answer.type === "forecast" && answer.steps) { return [ @@ -66,9 +82,9 @@ function renderAnswer( return [`${name}: ${distribution(answer, unit)}`]; } if (Array.isArray(answer.value)) { - if (!answer.value.length) return [`${name}: none found`]; const confidence = answer.confidence === undefined ? "" : ` (confidence ${probability(answer.confidence)})`; + if (!answer.value.length) return [`${name}: none found${confidence}${check}`]; return [ `${name}: ${answer.value.length} item${answer.value.length === 1 ? "" : "s"}${confidence}${check}`, ...answer.value.map((item, index) => { @@ -97,8 +113,9 @@ export function renderAnswers( context: { state: string; fields: Record; referenceDate: string }, ): string { const answers = Object.entries(response.answers); + const lineAt = context.state ? lineFinder(context.state) : undefined; const lines = answers.flatMap(([name, answer]) => - renderAnswer(name, answer, context.fields[name], context.state), + renderAnswer(name, answer, context.fields[name], lineAt), ); const { input_tokens, passes = 1 } = response.usage; lines.push( diff --git a/src/clairic/sources.ts b/src/clairic/sources.ts index 0316874..9e8afc8 100644 --- a/src/clairic/sources.ts +++ b/src/clairic/sources.ts @@ -8,25 +8,46 @@ export const maxImagesBytes = 8 * 1024 * 1024; // Pages carry markup on top of the 400,000 characters Clairic is sent; anything larger is refused unread. export const maxTextBytes = 8 * 1024 * 1024; -const entities: Record = { - amp: "&", - lt: "<", - gt: ">", - quot: '"', - apos: "'", - nbsp: " ", - pound: "£", - euro: "€", - cent: "¢", - yen: "¥", +// Code points rather than characters, so the source stays ASCII; nbsp and thinsp become plain spaces. +const entityCodes: Record = { + amp: 0x26, + lt: 0x3c, + gt: 0x3e, + quot: 0x22, + apos: 0x27, + nbsp: 0x20, + thinsp: 0x20, + pound: 0xa3, + euro: 0x20ac, + cent: 0xa2, + yen: 0xa5, + lsquo: 0x2018, + rsquo: 0x2019, + ldquo: 0x201c, + rdquo: 0x201d, + laquo: 0xab, + raquo: 0xbb, + ndash: 0x2013, + mdash: 0x2014, + hellip: 0x2026, + bull: 0x2022, + middot: 0xb7, + copy: 0xa9, + reg: 0xae, + trade: 0x2122, + deg: 0xb0, + times: 0xd7, }; function decodeEntities(text: string): string { return text.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (match, name: string) => { - if (name[0] !== "#") return entities[name.toLowerCase()] ?? match; const code = - name[1] === "x" || name[1] === "X" ? parseInt(name.slice(2), 16) : Number(name.slice(1)); - return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : match; + name[0] !== "#" + ? entityCodes[name.toLowerCase()] + : name[1] === "x" || name[1] === "X" + ? parseInt(name.slice(2), 16) + : Number(name.slice(1)); + return code && code <= 0x10ffff ? String.fromCodePoint(code) : match; }); } @@ -50,25 +71,33 @@ export function htmlToText(html: string): string { const textTypes = /^(text\/|application\/(json|xml|[\w.+-]+\+(json|xml))$)/; +// Pages that are not UTF-8 name their charset in the header; a label the runtime lacks falls back to UTF-8. +function decoderFor(contentTypeHeader: string): TextDecoder { + const charset = /;\s*charset\s*=\s*"?([^";\s]+)/i.exec(contentTypeHeader)?.[1]; + try { + return new TextDecoder(charset); + } catch { + return new TextDecoder(); + } +} + export async function loadText(url: string): Promise { const response = await fetchSource(url); - const contentType = (response.headers.get("content-type") ?? "") - .split(";")[0]! - .trim() - .toLowerCase(); + const header = response.headers.get("content-type") ?? ""; + const contentType = header.split(";")[0]!.trim().toLowerCase(); const html = contentType === "text/html" || contentType === "application/xhtml+xml"; if (html || textTypes.test(contentType) || contentType === "") { - const bytes = await readCapped(response, maxTextBytes); + const bytes = await readCapped(response, url, maxTextBytes); if (!bytes) { throw new ToolInputError( `${url} is larger than ${maxTextBytes / 2 ** 20} MiB. Ask the user for the relevant part as text.`, ); } - const text = new TextDecoder().decode(bytes); + const text = decoderFor(header).decode(bytes); return html ? htmlToText(text) : text; } await response.body?.cancel(); - if (contentType.startsWith("image/")) { + if (/^image\/(png|jpeg|webp)$/.test(contentType)) { throw new ToolInputError(`${url} is an image; pass it in image_urls instead of url.`); } if (contentType === "application/pdf") { @@ -99,7 +128,7 @@ function base64(bytes: Uint8Array): string { } export async function loadImage(url: string): Promise<{ image: ClairicImage; bytes: number }> { - const bytes = await readCapped(await fetchSource(url), maxImageBytes); + const bytes = await readCapped(await fetchSource(url), url, maxImageBytes); if (!bytes) throw new ToolInputError(`${url} is larger than 4 MiB, Clairic's limit per image.`); const contentType = imageType(bytes); if (!contentType) throw new ToolInputError(`${url} is not a PNG, JPEG or WebP image.`); diff --git a/src/index.ts b/src/index.ts index 87ec171..a789622 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,9 @@ const mcp = createMcpHandler(createServer); export default { async fetch(request, env) { if (new URL(request.url).pathname !== "/mcp") return new Response("Not found", { status: 404 }); - if (env.DEV_SKIP_AUTH !== "1" && !(await isAccessVerified(request, env))) { + // DEV_SKIP_AUTH comes only from .dev.vars, so Env declares it only where that file exists. + const skipAuth = "DEV_SKIP_AUTH" in env && env.DEV_SKIP_AUTH === "1"; + if (!skipAuth && !(await isAccessVerified(request, env))) { return new Response("Unauthorized", { status: 401 }); } return mcp.fetch(request); diff --git a/src/lib/http.ts b/src/lib/http.ts index bd95087..9fca137 100644 --- a/src/lib/http.ts +++ b/src/lib/http.ts @@ -23,7 +23,7 @@ const attemptTimeoutMs = 20_000; // Total time one call may spend retrying; a tool call should answer, even with an error, within it. const budgetMs = 30_000; -const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); +export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); // Full jitter: a random wait up to an exponentially growing cap. export const backoffMs = (attempt: number) => Math.random() * Math.min(8_000, 500 * 2 ** attempt); @@ -36,13 +36,16 @@ export function serverWaitMs(headers: Headers, now: number): number | undefined const date = Date.parse(retryAfter); if (!Number.isNaN(date)) return Math.max(0, date - now); } + // Hosts send the reset either as epoch seconds (past 1e9 since 2001) or as seconds from now. const reset = Number(headers.get("x-ratelimit-reset")); - return reset ? Math.max(0, reset * 1000 - now) : undefined; + if (!reset) return undefined; + return Math.max(0, reset > 1e9 ? reset * 1000 - now : reset * 1000); } // Reads at most maxBytes, so a huge file cannot exhaust the isolate's memory; undefined when larger. export async function readCapped( response: Response, + url: string, maxBytes: number, ): Promise { if (Number(response.headers.get("content-length")) > maxBytes) { @@ -53,13 +56,18 @@ export async function readCapped( if (!reader) return new Uint8Array(); const chunks: Uint8Array[] = []; let total = 0; - for (let chunk = await reader.read(); !chunk.done; chunk = await reader.read()) { - total += chunk.value.length; - if (total > maxBytes) { - await reader.cancel(); - return undefined; + try { + for (let chunk = await reader.read(); !chunk.done; chunk = await reader.read()) { + total += chunk.value.length; + if (total > maxBytes) { + await reader.cancel(); + return undefined; + } + chunks.push(chunk.value); } - chunks.push(chunk.value); + } catch { + // The body broke off, or outlasted the attempt's timeout, after the headers arrived. + throw new UpstreamError(0, url, 1); } const bytes = new Uint8Array(total); let offset = 0; diff --git a/src/lib/result.ts b/src/lib/result.ts index 9c4c36d..930877f 100644 --- a/src/lib/result.ts +++ b/src/lib/result.ts @@ -32,7 +32,7 @@ export function describeUpstreamError(error: UpstreamError): string { export function describeClairicError(error: ClairicError): string { if (error.rejected) { - return `Clairic rejected the request: ${error.message}. Fix the field specs and call again.`; + return `Clairic rejected the request: ${error.message}. Fix what it names and call again.`; } return `Clairic failed: ${error.message}. Tell the user and offer to try again later.`; } diff --git a/src/tools/extract.ts b/src/tools/extract.ts index 6e1a24f..dd1cdab 100644 --- a/src/tools/extract.ts +++ b/src/tools/extract.ts @@ -3,7 +3,7 @@ import type { McpServer } from "@modelcontextprotocol/server"; import * as z from "zod"; import { type ClairicImage, runClairic } from "../clairic/client"; -import { fieldSpecs } from "../clairic/fields"; +import { fieldSpecs, isoDate } from "../clairic/fields"; import { renderAnswers } from "../clairic/render"; import { loadImage, loadText, maxImagesBytes } from "../clairic/sources"; import { runTool, ToolInputError } from "../lib/result"; @@ -38,9 +38,7 @@ Arithmetic over many steps or many table rows is unreliable: extract the inputs "Up to 4 public PNG, JPEG or WebP images (4 MiB each, 8 MiB together), read before the text, e.g. a photo of a receipt.", ), fields: fieldSpecs, - reference_date: z - .string() - .regex(/^\d{4}-\d{2}-\d{2}$/) + reference_date: isoDate .optional() .describe( "ISO date for 'today' and for dates written without a year. Defaults to the current UTC date.", @@ -79,7 +77,8 @@ Arithmetic over many steps or many table rows is unreliable: extract the inputs ); } const images: ClairicImage[] = loaded.map(({ image }) => image); - const state = (page ?? text ?? "").slice(offset, offset + maxStateCharacters); + const input = page ?? text ?? ""; + const state = input.slice(offset, offset + maxStateCharacters); if (url && !state) throw new ToolInputError(`${url} has no text at offset ${offset}.`); const referenceDate = reference_date ?? new Date().toISOString().slice(0, 10); @@ -91,9 +90,14 @@ Arithmetic over many steps or many table rows is unreliable: extract the inputs ...(include_quantiles && { options: { include_quantiles } }), }); const source = url - ? `Read ${url}${offset ? ` from character ${offset}` : ""} (${state.length} characters).\n\n` + ? `Read ${url}${offset ? ` from character ${offset}` : ""} (${state.length} of ${input.length} characters).\n\n` : ""; - return source + renderAnswers(response, { state, fields, referenceDate }); + const end = offset + state.length; + const cut = + !response.truncated && end < input.length + ? `\nOnly characters ${offset} to ${end} of ${input.length} were sent. ${url ? `Call again with offset ${end} for the rest.` : "Send the rest of the text in another call."}` + : ""; + return source + renderAnswers(response, { state, fields, referenceDate }) + cut; }), ); } diff --git a/test/fields.test.ts b/test/fields.test.ts index 9b19b1d..b125390 100644 --- a/test/fields.test.ts +++ b/test/fields.test.ts @@ -16,6 +16,8 @@ test.each([ ], ["a field name Clairic refuses", { "1st total": { type: "number" } }], ["an unknown type", { total: { type: "money" } }], + ["a misspelled option", { total: { type: "number", instruction: "Amount due" } }], + ["an impossible date bound", { due: { type: "estimate", min: "2026-01-01", max: "2026-13-45" } }], ])("rejects %s", (_, fields) => { expect(fieldSpecs.safeParse(fields).success).toBe(false); }); diff --git a/test/fixtures/clairic/invalid-estimate.txt b/test/fixtures/clairic/invalid-estimate.txt deleted file mode 100644 index 9e949e6..0000000 --- a/test/fixtures/clairic/invalid-estimate.txt +++ /dev/null @@ -1 +0,0 @@ -3030: AiError: AiError: estimate price needs numeric min and max (1985aebb-7949-47e9-9cec-ab7440a8f87e) diff --git a/test/fixtures/clairic/inverted-bounds.txt b/test/fixtures/clairic/inverted-bounds.txt new file mode 100644 index 0000000..aebeb34 --- /dev/null +++ b/test/fixtures/clairic/inverted-bounds.txt @@ -0,0 +1 @@ +3030: AiError: AiError: estimate price needs finite min < max, got 100 and 1 (47e32150-2566-420b-bbd1-129ae7b2b02a) diff --git a/test/http.test.ts b/test/http.test.ts new file mode 100644 index 0000000..b4fbc2b --- /dev/null +++ b/test/http.test.ts @@ -0,0 +1,15 @@ +import { expect, test } from "vitest"; + +import { serverWaitMs } from "../src/lib/http"; + +const now = Date.UTC(2026, 9, 19); + +test.each([ + [{ "retry-after": "5" }, 5_000], + [{ "retry-after": new Date(now + 7_000).toUTCString() }, 7_000], + [{ "x-ratelimit-reset": String(now / 1000 + 30) }, 30_000], + [{ "x-ratelimit-reset": "60" }, 60_000], + [{}, undefined], +])("waits as %j asks", (headers, wait) => { + expect(serverWaitMs(new Headers(headers), now)).toBe(wait); +}); diff --git a/test/render.test.ts b/test/render.test.ts index 3e0489b..0b7fc16 100644 --- a/test/render.test.ts +++ b/test/render.test.ts @@ -3,7 +3,7 @@ import type { FieldSpec } from "../src/clairic/fields"; import { expect, test } from "vitest"; -import { lineOf, probability, renderAnswers } from "../src/clairic/render"; +import { lineFinder, probability, renderAnswers } from "../src/clairic/render"; import forecast from "./fixtures/clairic/forecast.json"; import invoice from "./fixtures/clairic/invoice.json"; import { invoiceFields, invoiceState } from "./support/invoice"; @@ -71,9 +71,26 @@ test("flags estimates clipped by their bounds and truncated input", () => { expect(text).toContain("read only the start"); }); +test("keeps small estimates readable and marks an unsure empty list", () => { + const response: ClairicResponse = { + answers: { + rate: { type: "estimate", value: 0.00034, median: 0.00031, p10: 0.000125, p90: 0.0009 }, + damage: { type: "list", value: [], confidence: 0.4 }, + }, + truncated: false, + usage: { input_tokens: 10 }, + }; + const lines = render(response, {}, "").split("\n"); + expect(lines[0]).toBe("rate: 0.00034 (median 0.00031, 80% interval 0.000125 to 0.0009)"); + expect(lines[1]).toBe("damage: none found (confidence 0.400) [check]"); +}); + test("line numbers count newlines before the offset", () => { - expect(lineOf("a\nb\nc", 0)).toBe(1); - expect(lineOf("a\nb\nc", 2)).toBe(2); - expect(lineOf("a\nb\nc", 4)).toBe(3); + const lineAt = lineFinder("a\nb\nc"); + expect(lineAt(0)).toBe(1); + expect(lineAt(1)).toBe(1); + expect(lineAt(2)).toBe(2); + expect(lineAt(4)).toBe(3); + expect(lineAt(99)).toBe(3); expect(probability(0.5)).toBe("0.500"); }); diff --git a/test/sources.test.ts b/test/sources.test.ts index 37f31ea..9aaa729 100644 --- a/test/sources.test.ts +++ b/test/sources.test.ts @@ -8,6 +8,7 @@ import { maxImageBytes, maxTextBytes, } from "../src/clairic/sources"; +import { UpstreamError } from "../src/lib/http"; const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 1, 2, 3]); @@ -24,6 +25,33 @@ test("reduces HTML to text with one block per line", () => { expect(htmlToText(html)).toBe("x\nOrder A-88412\nTotal: £649 + £52.10 & VAT\none\ntwo"); }); +test("decodes the common typographic entities", () => { + const decoded = htmlToText("’“–…"); + expect(Array.from(decoded, (character) => character.codePointAt(0))).toEqual([ + 0x2019, 0x201c, 0x2013, 0x2026, + ]); +}); + +test("decodes text in the charset the server names", async () => { + served = new Response(new Uint8Array([0xa3, 0x36, 0x34, 0x39]), { + headers: { "content-type": "text/plain; charset=ISO-8859-1" }, + }); + expect(await loadText("https://example.com/latin1.txt")).toBe("£649"); +}); + +test("reports a body that breaks off as an upstream failure", async () => { + served = new Response( + new ReadableStream({ + start(controller) { + controller.enqueue(new Uint8Array([0x61])); + controller.error(new Error("connection reset")); + }, + }), + { headers: { "content-type": "text/plain" } }, + ); + await expect(loadText("https://example.com/reset.txt")).rejects.toBeInstanceOf(UpstreamError); +}); + test("passes plain text and JSON through", async () => { served = new Response('{"total": 12}', { headers: { "content-type": "application/json; charset=utf-8" }, @@ -34,6 +62,7 @@ test("passes plain text and JSON through", async () => { test.each([ ["application/pdf", /is a PDF/], ["image/png", /pass it in image_urls/], + ["image/gif", /reads text and PNG, JPEG or WebP/], ["application/zip", /reads text and PNG, JPEG or WebP/], ])("refuses %s as text", async (contentType, message) => { served = new Response("x", { headers: { "content-type": contentType } }); diff --git a/test/tools.test.ts b/test/tools.test.ts index d41907f..e870eec 100644 --- a/test/tools.test.ts +++ b/test/tools.test.ts @@ -2,7 +2,7 @@ import { createMcpHandler } from "@modelcontextprotocol/server"; import { beforeEach, expect, test, vi } from "vitest"; import { createServer } from "../src/server"; -import rejection from "./fixtures/clairic/invalid-estimate.txt?raw"; +import rejection from "./fixtures/clairic/inverted-bounds.txt?raw"; import invoice from "./fixtures/clairic/invoice.json"; import { stubAiRun } from "./support/cloudflare-workers"; import { invoiceFields, invoiceState } from "./support/invoice"; @@ -73,7 +73,13 @@ test("reads a page as text with its block structure", async () => { const { text } = await callTool({ url: "https://example.com/invoice", fields: invoiceFields }); expect(sent[0]?.state).toBe(invoiceState); expect(sent[0]?.reference_date).toMatch(/^\d{4}-\d{2}-\d{2}$/); - expect(text).toMatch(/^Read https:\/\/example\.com\/invoice \(\d+ characters\)/); + expect(text).toMatch(/^Read https:\/\/example\.com\/invoice \(\d+ of \d+ characters\)/); +}); + +test("says when the input was cut before Clairic saw it", async () => { + const { text } = await callTool({ text: "x".repeat(400_005), fields: invoiceFields }); + expect(sent[0]?.state).toHaveLength(400_000); + expect(text).toContain("Only characters 0 to 400000 of 400005 were sent."); }); test("embeds image URLs as base64 because Clairic refuses remote URLs", async () => { @@ -103,11 +109,11 @@ test("passes Clairic's own reason through when it rejects the fields", async () }); const { isError, text } = await callTool({ text: "x", - fields: { price: { type: "estimate", min: 0, max: 1 } }, + fields: { price: { type: "estimate", min: 100, max: 1 } }, }); expect(isError).toBe(true); expect(text).toBe( - "Clairic rejected the request: estimate price needs numeric min and max. Fix the field specs and call again.", + "Clairic rejected the request: estimate price needs finite min < max, got 100 and 1. Fix what it names and call again.", ); expect(calls).toBe(1); }); From 11837bf50fcf5b9be425e2534bbaf1547e06b968 Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 23:06:57 +0100 Subject: [PATCH 09/13] fix: check the images' total size before encoding them --- src/clairic/sources.ts | 9 ++++----- src/tools/extract.ts | 9 ++++++--- test/sources.test.ts | 15 ++++++++++----- test/tools.test.ts | 40 +++++++++++++++++++++++++++++++++++----- 4 files changed, 55 insertions(+), 18 deletions(-) diff --git a/src/clairic/sources.ts b/src/clairic/sources.ts index 9e8afc8..ae633ff 100644 --- a/src/clairic/sources.ts +++ b/src/clairic/sources.ts @@ -1,5 +1,3 @@ -import type { ClairicImage } from "./client"; - import { fetchSource, readCapped } from "../lib/http"; import { ToolInputError } from "../lib/result"; @@ -119,7 +117,7 @@ export function imageType(bytes: Uint8Array): string | undefined { return undefined; } -function base64(bytes: Uint8Array): string { +export function base64(bytes: Uint8Array): string { let binary = ""; for (let start = 0; start < bytes.length; start += 0x8000) { binary += String.fromCharCode(...bytes.subarray(start, start + 0x8000)); @@ -127,10 +125,11 @@ function base64(bytes: Uint8Array): string { return btoa(binary); } -export async function loadImage(url: string): Promise<{ image: ClairicImage; bytes: number }> { +// Encoding waits until the images' total size has been checked against Clairic's limit. +export async function loadImage(url: string): Promise<{ contentType: string; bytes: Uint8Array }> { const bytes = await readCapped(await fetchSource(url), url, maxImageBytes); if (!bytes) throw new ToolInputError(`${url} is larger than 4 MiB, Clairic's limit per image.`); const contentType = imageType(bytes); if (!contentType) throw new ToolInputError(`${url} is not a PNG, JPEG or WebP image.`); - return { image: { content_type: contentType, base64: base64(bytes) }, bytes: bytes.length }; + return { contentType, bytes }; } diff --git a/src/tools/extract.ts b/src/tools/extract.ts index dd1cdab..31881b6 100644 --- a/src/tools/extract.ts +++ b/src/tools/extract.ts @@ -5,7 +5,7 @@ import * as z from "zod"; import { type ClairicImage, runClairic } from "../clairic/client"; import { fieldSpecs, isoDate } from "../clairic/fields"; import { renderAnswers } from "../clairic/render"; -import { loadImage, loadText, maxImagesBytes } from "../clairic/sources"; +import { base64, loadImage, loadText, maxImagesBytes } from "../clairic/sources"; import { runTool, ToolInputError } from "../lib/result"; // About 100k tokens, past Clairic's 65,536-token window; it truncates the rest and says so. @@ -70,13 +70,16 @@ Arithmetic over many steps or many table rows is unreliable: extract the inputs url ? loadText(url) : undefined, Promise.all((image_urls ?? []).map(loadImage)), ]); - const totalBytes = loaded.reduce((sum, { bytes }) => sum + bytes, 0); + const totalBytes = loaded.reduce((sum, { bytes }) => sum + bytes.length, 0); if (totalBytes > maxImagesBytes) { throw new ToolInputError( `The images total ${(totalBytes / 2 ** 20).toFixed(1)} MiB; Clairic takes 8 MiB at most. Send fewer.`, ); } - const images: ClairicImage[] = loaded.map(({ image }) => image); + const images: ClairicImage[] = loaded.map(({ contentType, bytes }) => ({ + content_type: contentType, + base64: base64(bytes), + })); const input = page ?? text ?? ""; const state = input.slice(offset, offset + maxStateCharacters); if (url && !state) throw new ToolInputError(`${url} has no text at offset ${offset}.`); diff --git a/test/sources.test.ts b/test/sources.test.ts index 9aaa729..05d99ac 100644 --- a/test/sources.test.ts +++ b/test/sources.test.ts @@ -73,10 +73,13 @@ test("recognises images by their bytes, whatever the server calls them", async ( expect(imageType(png)).toBe("image/png"); expect(imageType(new Uint8Array([0xff, 0xd8, 0xff, 0xe0]))).toBe("image/jpeg"); expect(imageType(new TextEncoder().encode("RIFF\0\0\0\0WEBPVP8 "))).toBe("image/webp"); - served = new Response(png, { headers: { "content-type": "application/octet-stream" } }); - const { image, bytes } = await loadImage("https://example.com/receipt"); - expect(image).toEqual({ content_type: "image/png", base64: btoa(String.fromCharCode(...png)) }); - expect(bytes).toBe(png.length); + served = new Response(png, { + headers: { "content-type": "application/octet-stream" }, + }); + expect(await loadImage("https://example.com/receipt")).toEqual({ + contentType: "image/png", + bytes: png, + }); }); test("refuses files that are not images and images over 4 MiB", async () => { @@ -86,7 +89,9 @@ test("refuses files that are not images and images over 4 MiB", async () => { big.set(png); served = new Response(big); await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/larger than 4 MiB/); - served = new Response(png, { headers: { "content-length": String(maxImageBytes + 1) } }); + served = new Response(png, { + headers: { "content-length": String(maxImageBytes + 1) }, + }); await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/larger than 4 MiB/); }); diff --git a/test/tools.test.ts b/test/tools.test.ts index e870eec..50b0c4e 100644 --- a/test/tools.test.ts +++ b/test/tools.test.ts @@ -65,31 +65,58 @@ test("extracts from text and sends Clairic the request it documents", async () = expect(isError).toBeUndefined(); expect(text).toContain("total: 1080 USD"); expect(sent).toEqual([ - { model: "clairic", state: invoiceState, fields: invoiceFields, reference_date: "2026-10-19" }, + { + model: "clairic", + state: invoiceState, + fields: invoiceFields, + reference_date: "2026-10-19", + }, ]); }); test("reads a page as text with its block structure", async () => { - const { text } = await callTool({ url: "https://example.com/invoice", fields: invoiceFields }); + const { text } = await callTool({ + url: "https://example.com/invoice", + fields: invoiceFields, + }); expect(sent[0]?.state).toBe(invoiceState); expect(sent[0]?.reference_date).toMatch(/^\d{4}-\d{2}-\d{2}$/); expect(text).toMatch(/^Read https:\/\/example\.com\/invoice \(\d+ of \d+ characters\)/); }); test("says when the input was cut before Clairic saw it", async () => { - const { text } = await callTool({ text: "x".repeat(400_005), fields: invoiceFields }); + const { text } = await callTool({ + text: "x".repeat(400_005), + fields: invoiceFields, + }); expect(sent[0]?.state).toHaveLength(400_000); expect(text).toContain("Only characters 0 to 400000 of 400005 were sent."); }); test("embeds image URLs as base64 because Clairic refuses remote URLs", async () => { - await callTool({ image_urls: ["https://example.com/receipt.png"], fields: invoiceFields }); + await callTool({ + image_urls: ["https://example.com/receipt.png"], + fields: invoiceFields, + }); expect(sent[0]?.images).toEqual([ { content_type: "image/png", base64: btoa(String.fromCharCode(...png)) }, ]); expect(sent[0]?.state).toBe(""); }); +test("refuses images over 8 MiB together before sending any", async () => { + const large = new Uint8Array(3 * 2 ** 20); + large.set(png); + vi.stubGlobal("fetch", () => Promise.resolve(new Response(large))); + const { isError, text } = await callTool({ + image_urls: ["a", "b", "c"].map((name) => `https://example.com/${name}.png`), + fields: invoiceFields, + }); + expect(isError).toBe(true); + expect(text).toContain("The images total 9.0 MiB"); + expect(sent).toEqual([]); +}); + test.each([ [{ text: "a", url: "https://example.com" }, "either text or url"], [{}, "as text, url or image_urls"], @@ -126,7 +153,10 @@ test("retries an unexplained Workers AI failure once", async () => { ? Promise.reject(new Error("3040: Capacity temporarily exceeded")) : Promise.resolve(invoice); }); - const { isError } = await callTool({ text: invoiceState, fields: invoiceFields }); + const { isError } = await callTool({ + text: invoiceState, + fields: invoiceFields, + }); expect(isError).toBeUndefined(); expect(calls).toBe(2); }); From 1d8d89116b72ebf2a92ccea948dd0e53483ac569 Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 23:06:58 +0100 Subject: [PATCH 10/13] style: format at 80 columns --- .oxfmtrc.json | 13 +++++-- .oxlintrc.json | 6 ++- src/auth.ts | 10 ++++- src/clairic/client.ts | 4 +- src/clairic/fields.ts | 59 +++++++++++++++++++++++++----- src/clairic/render.ts | 45 +++++++++++++++++------ src/clairic/sources.ts | 55 +++++++++++++++++++--------- src/index.ts | 3 +- src/lib/http.ts | 27 +++++++++++--- src/lib/result.ts | 16 +++++--- src/tools/extract.ts | 53 +++++++++++++++++++++------ test/fields.test.ts | 14 +++++-- test/render.test.ts | 45 +++++++++++++++++++---- test/sources.test.ts | 36 +++++++++++++----- test/support/cloudflare-workers.ts | 4 +- test/support/invoice.ts | 12 +++++- test/tools.test.ts | 12 ++++-- 17 files changed, 320 insertions(+), 94 deletions(-) diff --git a/.oxfmtrc.json b/.oxfmtrc.json index daf5240..809b23b 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -1,7 +1,7 @@ { "$schema": "./node_modules/oxfmt/configuration_schema.json", "useTabs": true, - "printWidth": 100, + "printWidth": 80, "sortPackageJson": true, "sortImports": { "groups": [ @@ -12,6 +12,13 @@ ], "newlinesBetween": true }, - "overrides": [{ "files": ["**/*.jsonc"], "options": { "trailingComma": "none" } }], - "ignorePatterns": ["worker-configuration.d.ts", "test/fixtures/**", "prek.toml", "**/*.md"] + "overrides": [ + { "files": ["**/*.jsonc"], "options": { "trailingComma": "none" } } + ], + "ignorePatterns": [ + "worker-configuration.d.ts", + "test/fixtures/**", + "prek.toml", + "**/*.md" + ] } diff --git a/.oxlintrc.json b/.oxlintrc.json index 5765856..67686a6 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -2,7 +2,11 @@ "$schema": "./node_modules/oxlint/configuration_schema.json", "plugins": ["unicorn", "oxc", "typescript", "vitest", "import", "promise"], "options": { "typeAware": true, "reportUnusedDisableDirectives": "warn" }, - "categories": { "correctness": "error", "suspicious": "error", "perf": "warn" }, + "categories": { + "correctness": "error", + "suspicious": "error", + "perf": "warn" + }, "rules": { "eqeqeq": "error", "unicorn/filename-case": ["error", { "case": "kebabCase" }], diff --git a/src/auth.ts b/src/auth.ts index 13db2eb..9bd44e8 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -4,13 +4,19 @@ let accessKeys: ReturnType | undefined; // Access sits in front of the Worker and signs every request it lets through. // Checking the signature here keeps a route Access does not cover from serving tools. -export async function isAccessVerified(request: Request, env: Env): Promise { +export async function isAccessVerified( + request: Request, + env: Env, +): Promise { const assertion = request.headers.get("cf-access-jwt-assertion"); if (!assertion) return false; const issuer = `https://${env.ACCESS_TEAM_DOMAIN}`; accessKeys ??= createRemoteJWKSet(new URL(`${issuer}/cdn-cgi/access/certs`)); try { - await jwtVerify(assertion, accessKeys, { issuer, audience: env.ACCESS_AUD }); + await jwtVerify(assertion, accessKeys, { + issuer, + audience: env.ACCESS_AUD, + }); return true; } catch { return false; diff --git a/src/clairic/client.ts b/src/clairic/client.ts index 08d6e53..62548eb 100644 --- a/src/clairic/client.ts +++ b/src/clairic/client.ts @@ -78,7 +78,9 @@ function toClairicError(error: unknown): ClairicError { return new ClairicError(reason, code === rejectedCode); } -export async function runClairic(request: ClairicRequest): Promise { +export async function runClairic( + request: ClairicRequest, +): Promise { const inputs = { model: "clairic", ...request }; for (let attempt = 1; ; attempt++) { let response: unknown; diff --git a/src/clairic/fields.ts b/src/clairic/fields.ts index a9cd88c..8f2c1ba 100644 --- a/src/clairic/fields.ts +++ b/src/clairic/fields.ts @@ -21,9 +21,16 @@ const bound = z.union([z.number(), isoDate]); const scale = z.enum(["linear", "log"]).optional(); // Strict objects, so a misspelled option fails validation instead of being dropped unseen. -const simple = (type: "text" | "date" | "time" | "datetime", description: string) => +const simple = ( + type: "text" | "date" | "time" | "datetime", + description: string, +) => z - .strictObject({ type: z.literal(type), instructions, null_threshold: nullThreshold }) + .strictObject({ + type: z.literal(type), + instructions, + null_threshold: nullThreshold, + }) .describe(description); export const fieldSpec = z.discriminatedUnion("type", [ @@ -37,7 +44,9 @@ export const fieldSpec = z.discriminatedUnion("type", [ decimals, null_threshold: nullThreshold, }) - .describe("A number read from the input or worked out from it in one or two steps."), + .describe( + "A number read from the input or worked out from it in one or two steps.", + ), simple("date", "A calendar date, ISO form."), simple("time", "A time of day, ISO form."), simple("datetime", "A date and time, ISO form."), @@ -46,7 +55,15 @@ export const fieldSpec = z.discriminatedUnion("type", [ type: z.literal("duration"), instructions, unit: z - .enum(["seconds", "minutes", "hours", "days", "weeks", "months", "years"]) + .enum([ + "seconds", + "minutes", + "hours", + "days", + "weeks", + "months", + "years", + ]) .optional() .describe("Default seconds."), integer, @@ -62,13 +79,19 @@ export const fieldSpec = z.discriminatedUnion("type", [ unit, decimals: decimals.describe("Number lists only."), }) - .describe("Every matching value, in input order. Empty when nothing matches."), + .describe( + "Every matching value, in input order. Empty when nothing matches.", + ), z .strictObject({ type: z.literal("estimate"), instructions, - min: bound.describe("Lowest allowed value: a number, or an ISO date for date estimates."), - max: bound.describe("Highest allowed value: a number, or an ISO date for date estimates."), + min: bound.describe( + "Lowest allowed value: a number, or an ISO date for date estimates.", + ), + max: bound.describe( + "Highest allowed value: a number, or an ISO date for date estimates.", + ), step: z .union([z.number().positive(), z.enum(["month", "year"])]) .optional() @@ -87,9 +110,25 @@ export const fieldSpec = z.discriminatedUnion("type", [ instructions, min: bound, max: bound, - horizon: z.number().int().min(1).max(64).describe("Number of future steps."), - interval: z.enum(["step", "minute", "hour", "day", "week", "month", "quarter", "year"]), - step: z.union([z.number().positive(), z.enum(["month", "year"])]).optional(), + horizon: z + .number() + .int() + .min(1) + .max(64) + .describe("Number of future steps."), + interval: z.enum([ + "step", + "minute", + "hour", + "day", + "week", + "month", + "quarter", + "year", + ]), + step: z + .union([z.number().positive(), z.enum(["month", "year"])]) + .optional(), scale, unit, }) diff --git a/src/clairic/render.ts b/src/clairic/render.ts index f482de5..a3898aa 100644 --- a/src/clairic/render.ts +++ b/src/clairic/render.ts @@ -2,7 +2,11 @@ import type { ClairicAnswer, ClairicResponse, Distribution } from "./client"; import type { FieldSpec } from "./fields"; // A convention, not derived: answers outside these bounds are marked for the user to verify. -export const review = { minConfidence: 0.9, unsureNullLow: 0.1, unsureNullHigh: 0.9 } as const; +export const review = { + minConfidence: 0.9, + unsureNullLow: 0.1, + unsureNullHigh: 0.9, +} as const; export function probability(p: number): string { if (p < 0.001) return "<0.001"; @@ -30,7 +34,9 @@ const show = (value: unknown) => // Below 1, three significant digits instead of two decimals, so small estimates do not print as 0. const round = (value: unknown) => { if (typeof value !== "number") return String(value); - return String(Number(Math.abs(value) < 1 ? value.toPrecision(3) : value.toFixed(2))); + return String( + Number(Math.abs(value) < 1 ? value.toPrecision(3) : value.toFixed(2)), + ); }; function needsCheck(answer: ClairicAnswer): boolean { @@ -56,7 +62,9 @@ function distribution(estimate: Distribution, unit: string): string { if ((estimate.p_above ?? 0) > 0.05) parts.push(`p_above ${probability(estimate.p_above!)}: raise max`); if (estimate.quantiles) - parts.push(`percentiles 1 to 99: ${estimate.quantiles.map(round).join(", ")}`); + parts.push( + `percentiles 1 to 99: ${estimate.quantiles.map(round).join(", ")}`, + ); return `${round(estimate.value)}${unit} (${parts.join(", ")})`; } @@ -75,7 +83,9 @@ function renderAnswer( if (answer.type === "forecast" && answer.steps) { return [ `${name}: ${answer.steps.length} steps ahead`, - ...answer.steps.map((step, index) => ` ${index + 1}: ${distribution(step, unit)}`), + ...answer.steps.map( + (step, index) => ` ${index + 1}: ${distribution(step, unit)}`, + ), ]; } if (answer.type === "estimate") { @@ -83,8 +93,11 @@ function renderAnswer( } if (Array.isArray(answer.value)) { const confidence = - answer.confidence === undefined ? "" : ` (confidence ${probability(answer.confidence)})`; - if (!answer.value.length) return [`${name}: none found${confidence}${check}`]; + answer.confidence === undefined + ? "" + : ` (confidence ${probability(answer.confidence)})`; + if (!answer.value.length) + return [`${name}: none found${confidence}${check}`]; return [ `${name}: ${answer.value.length} item${answer.value.length === 1 ? "" : "s"}${confidence}${check}`, ...answer.value.map((item, index) => { @@ -97,20 +110,30 @@ function renderAnswer( const parts = [`p_null ${probability(answer.p_null ?? 1)}`]; if (answer.guess !== undefined && answer.guess !== null) { const confidence = - answer.confidence === undefined ? "" : ` at confidence ${probability(answer.confidence)}`; + answer.confidence === undefined + ? "" + : ` at confidence ${probability(answer.confidence)}`; parts.push(`best guess ${show(answer.guess)}${unit}${confidence}`); } return [`${name}: null (${parts.join("; ")})${check}`]; } const parts = [line(answer.span?.[0])]; - if (answer.confidence !== undefined) parts.push(`confidence ${probability(answer.confidence)}`); - if (answer.p_null !== undefined) parts.push(`p_null ${probability(answer.p_null)}`); - return [`${name}: ${show(answer.value)}${unit} (${parts.filter(Boolean).join(", ")})${check}`]; + if (answer.confidence !== undefined) + parts.push(`confidence ${probability(answer.confidence)}`); + if (answer.p_null !== undefined) + parts.push(`p_null ${probability(answer.p_null)}`); + return [ + `${name}: ${show(answer.value)}${unit} (${parts.filter(Boolean).join(", ")})${check}`, + ]; } export function renderAnswers( response: ClairicResponse, - context: { state: string; fields: Record; referenceDate: string }, + context: { + state: string; + fields: Record; + referenceDate: string; + }, ): string { const answers = Object.entries(response.answers); const lineAt = context.state ? lineFinder(context.state) : undefined; diff --git a/src/clairic/sources.ts b/src/clairic/sources.ts index ae633ff..56f1a2f 100644 --- a/src/clairic/sources.ts +++ b/src/clairic/sources.ts @@ -38,22 +38,28 @@ const entityCodes: Record = { }; function decodeEntities(text: string): string { - return text.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (match, name: string) => { - const code = - name[0] !== "#" - ? entityCodes[name.toLowerCase()] - : name[1] === "x" || name[1] === "X" - ? parseInt(name.slice(2), 16) - : Number(name.slice(1)); - return code && code <= 0x10ffff ? String.fromCodePoint(code) : match; - }); + return text.replace( + /&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, + (match, name: string) => { + const code = + name[0] !== "#" + ? entityCodes[name.toLowerCase()] + : name[1] === "x" || name[1] === "X" + ? parseInt(name.slice(2), 16) + : Number(name.slice(1)); + return code && code <= 0x10ffff ? String.fromCodePoint(code) : match; + }, + ); } // Block-level closing tags become line breaks so line numbers in answers still mean something. export function htmlToText(html: string): string { return decodeEntities( html - .replace(/<(script|style|noscript|template|svg)\b[\s\S]*?<\/\1\s*>/gi, " ") + .replace( + /<(script|style|noscript|template|svg)\b[\s\S]*?<\/\1\s*>/gi, + " ", + ) .replace(//g, " ") .replace( /<(br|hr)\b[^>]*>|<\/(title|p|div|li|tr|h[1-6]|table|section|article|header|footer)\s*>/gi, @@ -71,7 +77,9 @@ const textTypes = /^(text\/|application\/(json|xml|[\w.+-]+\+(json|xml))$)/; // Pages that are not UTF-8 name their charset in the header; a label the runtime lacks falls back to UTF-8. function decoderFor(contentTypeHeader: string): TextDecoder { - const charset = /;\s*charset\s*=\s*"?([^";\s]+)/i.exec(contentTypeHeader)?.[1]; + const charset = /;\s*charset\s*=\s*"?([^";\s]+)/i.exec( + contentTypeHeader, + )?.[1]; try { return new TextDecoder(charset); } catch { @@ -83,7 +91,8 @@ export async function loadText(url: string): Promise { const response = await fetchSource(url); const header = response.headers.get("content-type") ?? ""; const contentType = header.split(";")[0]!.trim().toLowerCase(); - const html = contentType === "text/html" || contentType === "application/xhtml+xml"; + const html = + contentType === "text/html" || contentType === "application/xhtml+xml"; if (html || textTypes.test(contentType) || contentType === "") { const bytes = await readCapped(response, url, maxTextBytes); if (!bytes) { @@ -96,7 +105,9 @@ export async function loadText(url: string): Promise { } await response.body?.cancel(); if (/^image\/(png|jpeg|webp)$/.test(contentType)) { - throw new ToolInputError(`${url} is an image; pass it in image_urls instead of url.`); + throw new ToolInputError( + `${url} is an image; pass it in image_urls instead of url.`, + ); } if (contentType === "application/pdf") { throw new ToolInputError( @@ -110,9 +121,11 @@ export async function loadText(url: string): Promise { // The bytes decide the type: hosts often serve images as application/octet-stream. export function imageType(bytes: Uint8Array): string | undefined { - const ascii = (start: number, end: number) => String.fromCharCode(...bytes.subarray(start, end)); + const ascii = (start: number, end: number) => + String.fromCharCode(...bytes.subarray(start, end)); if (bytes[0] === 0x89 && ascii(1, 4) === "PNG") return "image/png"; - if (bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) return "image/jpeg"; + if (bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) + return "image/jpeg"; if (ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP") return "image/webp"; return undefined; } @@ -126,10 +139,16 @@ export function base64(bytes: Uint8Array): string { } // Encoding waits until the images' total size has been checked against Clairic's limit. -export async function loadImage(url: string): Promise<{ contentType: string; bytes: Uint8Array }> { +export async function loadImage( + url: string, +): Promise<{ contentType: string; bytes: Uint8Array }> { const bytes = await readCapped(await fetchSource(url), url, maxImageBytes); - if (!bytes) throw new ToolInputError(`${url} is larger than 4 MiB, Clairic's limit per image.`); + if (!bytes) + throw new ToolInputError( + `${url} is larger than 4 MiB, Clairic's limit per image.`, + ); const contentType = imageType(bytes); - if (!contentType) throw new ToolInputError(`${url} is not a PNG, JPEG or WebP image.`); + if (!contentType) + throw new ToolInputError(`${url} is not a PNG, JPEG or WebP image.`); return { contentType, bytes }; } diff --git a/src/index.ts b/src/index.ts index a789622..d57eda7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,8 @@ const mcp = createMcpHandler(createServer); export default { async fetch(request, env) { - if (new URL(request.url).pathname !== "/mcp") return new Response("Not found", { status: 404 }); + if (new URL(request.url).pathname !== "/mcp") + return new Response("Not found", { status: 404 }); // DEV_SKIP_AUTH comes only from .dev.vars, so Env declares it only where that file exists. const skipAuth = "DEV_SKIP_AUTH" in env && env.DEV_SKIP_AUTH === "1"; if (!skipAuth && !(await isAccessVerified(request, env))) { diff --git a/src/lib/http.ts b/src/lib/http.ts index 9fca137..d5b1105 100644 --- a/src/lib/http.ts +++ b/src/lib/http.ts @@ -8,7 +8,12 @@ export class UpstreamError extends Error { readonly attempts: number; readonly retryAfterMs?: number; - constructor(status: number, url: string, attempts: number, retryAfterMs?: number) { + constructor( + status: number, + url: string, + attempts: number, + retryAfterMs?: number, + ) { super(`${url} answered ${status || "nothing"} after ${attempts} attempts`); this.status = status; this.url = url; @@ -23,12 +28,17 @@ const attemptTimeoutMs = 20_000; // Total time one call may spend retrying; a tool call should answer, even with an error, within it. const budgetMs = 30_000; -export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); +export const sleep = (ms: number) => + new Promise((resolve) => setTimeout(resolve, ms)); // Full jitter: a random wait up to an exponentially growing cap. -export const backoffMs = (attempt: number) => Math.random() * Math.min(8_000, 500 * 2 ** attempt); +export const backoffMs = (attempt: number) => + Math.random() * Math.min(8_000, 500 * 2 ** attempt); -export function serverWaitMs(headers: Headers, now: number): number | undefined { +export function serverWaitMs( + headers: Headers, + now: number, +): number | undefined { const retryAfter = headers.get("retry-after"); if (retryAfter) { const seconds = Number(retryAfter); @@ -57,7 +67,11 @@ export async function readCapped( const chunks: Uint8Array[] = []; let total = 0; try { - for (let chunk = await reader.read(); !chunk.done; chunk = await reader.read()) { + for ( + let chunk = await reader.read(); + !chunk.done; + chunk = await reader.read() + ) { total += chunk.value.length; if (total > maxBytes) { await reader.cancel(); @@ -94,7 +108,8 @@ export async function fetchSource(url: string): Promise { if (response.ok) return response; await response.body?.cancel(); status = response.status; - if (!retriedStatuses.has(status)) throw new UpstreamError(status, url, attempt); + if (!retriedStatuses.has(status)) + throw new UpstreamError(status, url, attempt); wait = serverWaitMs(response.headers, Date.now()); } catch (error) { if (error instanceof UpstreamError) throw error; diff --git a/src/lib/result.ts b/src/lib/result.ts index 930877f..29eb548 100644 --- a/src/lib/result.ts +++ b/src/lib/result.ts @@ -16,11 +16,13 @@ export function describeUpstreamError(error: UpstreamError): string { const wait = error.retryAfterMs ? ` It asks clients to wait ${Math.ceil(error.retryAfterMs / 1000)} seconds.` : ""; - if (error.status === 404) return `${error.url} returned 404; check the address.`; + if (error.status === 404) + return `${error.url} returned 404; check the address.`; if (error.status === 401 || error.status === 403) { return `${error.url} needs a login or blocks scripts (HTTP ${error.status}). Ask the user to paste the text, or send a screenshot's public URL in image_urls.`; } - if (error.status === 429) return `${error.url} is rate limiting this server (${tries}).${wait}`; + if (error.status === 429) + return `${error.url} is rate limiting this server (${tries}).${wait}`; if (error.status === 0) { return `${error.url} did not answer after ${tries}. Tell the user and offer to try again later.`; } @@ -37,13 +39,17 @@ export function describeClairicError(error: ClairicError): string { return `Clairic failed: ${error.message}. Tell the user and offer to try again later.`; } -export async function runTool(work: () => Promise): Promise { +export async function runTool( + work: () => Promise, +): Promise { try { return { content: [{ type: "text", text: await work() }] }; } catch (error) { if (error instanceof ToolInputError) return failure(error.message); - if (error instanceof UpstreamError) return failure(describeUpstreamError(error)); - if (error instanceof ClairicError) return failure(describeClairicError(error)); + if (error instanceof UpstreamError) + return failure(describeUpstreamError(error)); + if (error instanceof ClairicError) + return failure(describeClairicError(error)); throw error; } } diff --git a/src/tools/extract.ts b/src/tools/extract.ts index 31881b6..592283e 100644 --- a/src/tools/extract.ts +++ b/src/tools/extract.ts @@ -5,7 +5,12 @@ import * as z from "zod"; import { type ClairicImage, runClairic } from "../clairic/client"; import { fieldSpecs, isoDate } from "../clairic/fields"; import { renderAnswers } from "../clairic/render"; -import { base64, loadImage, loadText, maxImagesBytes } from "../clairic/sources"; +import { + base64, + loadImage, + loadText, + maxImagesBytes, +} from "../clairic/sources"; import { runTool, ToolInputError } from "../lib/result"; // About 100k tokens, past Clairic's 65,536-token window; it truncates the rest and says so. @@ -24,7 +29,10 @@ Use it when the answer is a value: something to read (an order number, a deadlin Arithmetic over many steps or many table rows is unreliable: extract the inputs as separate fields and do the maths yourself. Answers marked [check] are uncertain; tell the user to verify them instead of stating them as fact. A null means the input does not determine the value; the best guess shown next to it is not an answer.`, inputSchema: z.object({ - text: z.string().optional().describe("The text to read. Exclusive with url."), + text: z + .string() + .optional() + .describe("The text to read. Exclusive with url."), url: webUrl .optional() .describe( @@ -52,25 +60,42 @@ Arithmetic over many steps or many table rows is unreliable: extract the inputs .int() .min(0) .default(0) - .describe("url only: character offset into the page text, for pages Clairic truncated."), + .describe( + "url only: character offset into the page text, for pages Clairic truncated.", + ), }), annotations: { readOnlyHint: true, openWorldHint: true }, }, - ({ text, url, image_urls, fields, reference_date, include_quantiles, offset }) => + ({ + text, + url, + image_urls, + fields, + reference_date, + include_quantiles, + offset, + }) => runTool(async () => { if (text !== undefined && url) throw new ToolInputError("Send either text or url, not both."); if (!text && !url && !image_urls?.length) { - throw new ToolInputError("Send the input as text, url or image_urls."); + throw new ToolInputError( + "Send the input as text, url or image_urls.", + ); } - if (offset && !url) throw new ToolInputError("offset applies to url only."); - if (!Object.keys(fields).length) throw new ToolInputError("Define at least one field."); + if (offset && !url) + throw new ToolInputError("offset applies to url only."); + if (!Object.keys(fields).length) + throw new ToolInputError("Define at least one field."); const [page, loaded] = await Promise.all([ url ? loadText(url) : undefined, Promise.all((image_urls ?? []).map(loadImage)), ]); - const totalBytes = loaded.reduce((sum, { bytes }) => sum + bytes.length, 0); + const totalBytes = loaded.reduce( + (sum, { bytes }) => sum + bytes.length, + 0, + ); if (totalBytes > maxImagesBytes) { throw new ToolInputError( `The images total ${(totalBytes / 2 ** 20).toFixed(1)} MiB; Clairic takes 8 MiB at most. Send fewer.`, @@ -82,8 +107,10 @@ Arithmetic over many steps or many table rows is unreliable: extract the inputs })); const input = page ?? text ?? ""; const state = input.slice(offset, offset + maxStateCharacters); - if (url && !state) throw new ToolInputError(`${url} has no text at offset ${offset}.`); - const referenceDate = reference_date ?? new Date().toISOString().slice(0, 10); + if (url && !state) + throw new ToolInputError(`${url} has no text at offset ${offset}.`); + const referenceDate = + reference_date ?? new Date().toISOString().slice(0, 10); const response = await runClairic({ state, @@ -100,7 +127,11 @@ Arithmetic over many steps or many table rows is unreliable: extract the inputs !response.truncated && end < input.length ? `\nOnly characters ${offset} to ${end} of ${input.length} were sent. ${url ? `Call again with offset ${end} for the rest.` : "Send the rest of the text in another call."}` : ""; - return source + renderAnswers(response, { state, fields, referenceDate }) + cut; + return ( + source + + renderAnswers(response, { state, fields, referenceDate }) + + cut + ); }), ); } diff --git a/test/fields.test.ts b/test/fields.test.ts index b125390..1f32483 100644 --- a/test/fields.test.ts +++ b/test/fields.test.ts @@ -12,12 +12,20 @@ test.each([ ["a list without items", { names: { type: "list" } }], [ "a forecast beyond 64 steps", - { kwh: { type: "forecast", min: 0, max: 1, horizon: 65, interval: "month" } }, + { + kwh: { type: "forecast", min: 0, max: 1, horizon: 65, interval: "month" }, + }, ], ["a field name Clairic refuses", { "1st total": { type: "number" } }], ["an unknown type", { total: { type: "money" } }], - ["a misspelled option", { total: { type: "number", instruction: "Amount due" } }], - ["an impossible date bound", { due: { type: "estimate", min: "2026-01-01", max: "2026-13-45" } }], + [ + "a misspelled option", + { total: { type: "number", instruction: "Amount due" } }, + ], + [ + "an impossible date bound", + { due: { type: "estimate", min: "2026-01-01", max: "2026-13-45" } }, + ], ])("rejects %s", (_, fields) => { expect(fieldSpecs.safeParse(fields).success).toBe(false); }); diff --git a/test/render.test.ts b/test/render.test.ts index 0b7fc16..577ba2a 100644 --- a/test/render.test.ts +++ b/test/render.test.ts @@ -8,8 +8,11 @@ import forecast from "./fixtures/clairic/forecast.json"; import invoice from "./fixtures/clairic/invoice.json"; import { invoiceFields, invoiceState } from "./support/invoice"; -const render = (response: ClairicResponse, fields = invoiceFields, state = invoiceState) => - renderAnswers(response, { state, fields, referenceDate: "2026-10-19" }); +const render = ( + response: ClairicResponse, + fields = invoiceFields, + state = invoiceState, +) => renderAnswers(response, { state, fields, referenceDate: "2026-10-19" }); test("renders every answer type of the recorded invoice", () => { expect(render(invoice).split("\n")).toEqual([ @@ -29,7 +32,14 @@ test("renders every answer type of the recorded invoice", () => { test("renders a forecast one step per line", () => { const fields: Record = { - next_months: { type: "forecast", min: 0, max: 600, horizon: 3, interval: "month", unit: "kWh" }, + next_months: { + type: "forecast", + min: 0, + max: 600, + horizon: 3, + interval: "month", + unit: "kWh", + }, }; expect(render(forecast, fields, "").split("\n").slice(0, 4)).toEqual([ "next_months: 3 steps ahead", @@ -43,7 +53,13 @@ test("marks weak and unsure answers for review and explains the mark", () => { const response: ClairicResponse = { answers: { weak: { type: "number", value: 12, confidence: 0.6, p_null: 0.01 }, - unsure_null: { type: "text", value: null, p_null: 0.7, guess: "x", confidence: 0.5 }, + unsure_null: { + type: "text", + value: null, + p_null: 0.7, + guess: "x", + confidence: 0.5, + }, sure_null: { type: "text", value: null, p_null: 0.98 }, }, truncated: false, @@ -61,7 +77,14 @@ test("marks weak and unsure answers for review and explains the mark", () => { test("flags estimates clipped by their bounds and truncated input", () => { const response: ClairicResponse = { answers: { - price: { type: "estimate", value: 100, median: 100, p10: 90, p90: 100, p_above: 0.3 }, + price: { + type: "estimate", + value: 100, + median: 100, + p10: 90, + p90: 100, + p_above: 0.3, + }, }, truncated: true, usage: { input_tokens: 65_536 }, @@ -74,14 +97,22 @@ test("flags estimates clipped by their bounds and truncated input", () => { test("keeps small estimates readable and marks an unsure empty list", () => { const response: ClairicResponse = { answers: { - rate: { type: "estimate", value: 0.00034, median: 0.00031, p10: 0.000125, p90: 0.0009 }, + rate: { + type: "estimate", + value: 0.00034, + median: 0.00031, + p10: 0.000125, + p90: 0.0009, + }, damage: { type: "list", value: [], confidence: 0.4 }, }, truncated: false, usage: { input_tokens: 10 }, }; const lines = render(response, {}, "").split("\n"); - expect(lines[0]).toBe("rate: 0.00034 (median 0.00031, 80% interval 0.000125 to 0.0009)"); + expect(lines[0]).toBe( + "rate: 0.00034 (median 0.00031, 80% interval 0.000125 to 0.0009)", + ); expect(lines[1]).toBe("damage: none found (confidence 0.400) [check]"); }); diff --git a/test/sources.test.ts b/test/sources.test.ts index 05d99ac..e5ca55a 100644 --- a/test/sources.test.ts +++ b/test/sources.test.ts @@ -10,7 +10,9 @@ import { } from "../src/clairic/sources"; import { UpstreamError } from "../src/lib/http"; -const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 1, 2, 3]); +const png = new Uint8Array([ + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 1, 2, 3, +]); let served: Response; @@ -22,7 +24,9 @@ test("reduces HTML to text with one block per line", () => { const html = `x

Order A-88412

Total: £649 + £52.10 & VAT

  • one
  • two
`; - expect(htmlToText(html)).toBe("x\nOrder A-88412\nTotal: £649 + £52.10 & VAT\none\ntwo"); + expect(htmlToText(html)).toBe( + "x\nOrder A-88412\nTotal: £649 + £52.10 & VAT\none\ntwo", + ); }); test("decodes the common typographic entities", () => { @@ -49,7 +53,9 @@ test("reports a body that breaks off as an upstream failure", async () => { }), { headers: { "content-type": "text/plain" } }, ); - await expect(loadText("https://example.com/reset.txt")).rejects.toBeInstanceOf(UpstreamError); + await expect( + loadText("https://example.com/reset.txt"), + ).rejects.toBeInstanceOf(UpstreamError); }); test("passes plain text and JSON through", async () => { @@ -71,8 +77,12 @@ test.each([ test("recognises images by their bytes, whatever the server calls them", async () => { expect(imageType(png)).toBe("image/png"); - expect(imageType(new Uint8Array([0xff, 0xd8, 0xff, 0xe0]))).toBe("image/jpeg"); - expect(imageType(new TextEncoder().encode("RIFF\0\0\0\0WEBPVP8 "))).toBe("image/webp"); + expect(imageType(new Uint8Array([0xff, 0xd8, 0xff, 0xe0]))).toBe( + "image/jpeg", + ); + expect(imageType(new TextEncoder().encode("RIFF\0\0\0\0WEBPVP8 "))).toBe( + "image/webp", + ); served = new Response(png, { headers: { "content-type": "application/octet-stream" }, }); @@ -84,20 +94,28 @@ test("recognises images by their bytes, whatever the server calls them", async ( test("refuses files that are not images and images over 4 MiB", async () => { served = new Response(""); - await expect(loadImage("https://example.com/page")).rejects.toThrow(/not a PNG, JPEG or WebP/); + await expect(loadImage("https://example.com/page")).rejects.toThrow( + /not a PNG, JPEG or WebP/, + ); const big = new Uint8Array(maxImageBytes + 1); big.set(png); served = new Response(big); - await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/larger than 4 MiB/); + await expect(loadImage("https://example.com/big.png")).rejects.toThrow( + /larger than 4 MiB/, + ); served = new Response(png, { headers: { "content-length": String(maxImageBytes + 1) }, }); - await expect(loadImage("https://example.com/big.png")).rejects.toThrow(/larger than 4 MiB/); + await expect(loadImage("https://example.com/big.png")).rejects.toThrow( + /larger than 4 MiB/, + ); }); test("refuses text larger than the cap without reading it whole", async () => { served = new Response(new Uint8Array(maxTextBytes + 1), { headers: { "content-type": "text/plain" }, }); - await expect(loadText("https://example.com/huge.txt")).rejects.toThrow(/larger than 8 MiB/); + await expect(loadText("https://example.com/huge.txt")).rejects.toThrow( + /larger than 8 MiB/, + ); }); diff --git a/test/support/cloudflare-workers.ts b/test/support/cloudflare-workers.ts index 6a5fa2a..3e164f6 100644 --- a/test/support/cloudflare-workers.ts +++ b/test/support/cloudflare-workers.ts @@ -8,7 +8,9 @@ export function stubAiRun(next: Run) { } export const env = { - AI: { run: (model: string, inputs: Record) => run(model, inputs) }, + AI: { + run: (model: string, inputs: Record) => run(model, inputs), + }, ACCESS_TEAM_DOMAIN: "", ACCESS_AUD: "", }; diff --git a/test/support/invoice.ts b/test/support/invoice.ts index b63e148..0400e14 100644 --- a/test/support/invoice.ts +++ b/test/support/invoice.ts @@ -6,7 +6,10 @@ export const invoiceState = export const invoiceFields: Record = { invoice_number: { type: "text" }, - due_date: { type: "date", instructions: "Issue date plus the net payment days" }, + due_date: { + type: "date", + instructions: "Issue date plus the net payment days", + }, total: { type: "number", decimals: 2, @@ -22,5 +25,10 @@ export const invoiceFields: Record = { step: 1, instructions: "Days after issue until this invoice is paid", }, - payment_term: { type: "duration", unit: "days", integer: true, instructions: "Net payment term" }, + payment_term: { + type: "duration", + unit: "days", + integer: true, + instructions: "Net payment term", + }, }; diff --git a/test/tools.test.ts b/test/tools.test.ts index 50b0c4e..39d773e 100644 --- a/test/tools.test.ts +++ b/test/tools.test.ts @@ -31,7 +31,9 @@ async function callTool(args: Record): Promise { }), ); const body = await response.text(); - const json = body.startsWith("{") ? body : (/^data: (.*)$/m.exec(body)?.[1] ?? ""); + const json = body.startsWith("{") + ? body + : (/^data: (.*)$/m.exec(body)?.[1] ?? ""); const reply = JSON.parse(json).result; return { isError: reply.isError, text: reply.content[0].text }; } @@ -81,7 +83,9 @@ test("reads a page as text with its block structure", async () => { }); expect(sent[0]?.state).toBe(invoiceState); expect(sent[0]?.reference_date).toMatch(/^\d{4}-\d{2}-\d{2}$/); - expect(text).toMatch(/^Read https:\/\/example\.com\/invoice \(\d+ of \d+ characters\)/); + expect(text).toMatch( + /^Read https:\/\/example\.com\/invoice \(\d+ of \d+ characters\)/, + ); }); test("says when the input was cut before Clairic saw it", async () => { @@ -109,7 +113,9 @@ test("refuses images over 8 MiB together before sending any", async () => { large.set(png); vi.stubGlobal("fetch", () => Promise.resolve(new Response(large))); const { isError, text } = await callTool({ - image_urls: ["a", "b", "c"].map((name) => `https://example.com/${name}.png`), + image_urls: ["a", "b", "c"].map( + (name) => `https://example.com/${name}.png`, + ), fields: invoiceFields, }); expect(isError).toBe(true); From 8576702312e3076a856c437298a223dff5a4eada Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 23:09:33 +0100 Subject: [PATCH 11/13] chore: version with changesets; CI and release workflows --- .changeset/config.json | 12 ++ .github/dependabot.yml | 11 ++ .github/workflows/ci.yml | 49 ++++++ .github/workflows/release.yml | 58 +++++++ justfile | 12 +- package.json | 4 +- pnpm-lock.yaml | 313 +++++++++++++++++++++++++++++++++- 7 files changed, 446 insertions(+), 13 deletions(-) create mode 100644 .changeset/config.json create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..b96f7df --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://unpkg.com/@changesets/config/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [], + "privatePackages": { "version": true, "tag": true } +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f70a6f9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + cooldown: + default-days: 7 + groups: + actions: + patterns: ["*"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c89828f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: ci + +on: + pull_request: + push: + branches: [main] + merge_group: + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + linux: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - name: checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: pnpm + uses: pnpm/setup@a0881977cd8ea73b1ed212236c99ca10dcc80cf4 # v3.1.1 + with: + cache: true + require-lockfile: true + - name: tools + uses: taiki-e/install-action@1168f6810a3cb30a3514bf5756a3b7f0422c6df8 # v2.87.28 + with: + tool: zizmor + fallback: none + - name: format + run: pnpm exec oxfmt --check + - name: lint + run: pnpm exec oxlint --format github + - name: types + run: pnpm exec tsc --noEmit + - name: test + run: pnpm exec vitest run + - name: workflows + env: + GH_TOKEN: ${{ github.token }} + run: | + zizmor --format=github . + go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7bce30b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +# Pending changesets open a version PR that merges itself once CI passes; the merge +# tags the release. The App token is what lets those events trigger CI and this +# workflow again, which GITHUB_TOKEN events do not. +name: release + +on: + push: + branches: [main] + +permissions: {} + +jobs: + release: + # Copies without a release App of their own skip releasing. + if: vars.RELEASE_APP_CLIENT_ID != '' + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - name: harden runner + uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1 + with: + egress-policy: audit + - name: token + id: app + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + with: + client-id: ${{ vars.RELEASE_APP_CLIENT_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write + permission-pull-requests: write + - name: checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + # changeset version reads history to date each changeset; a shallow clone would refetch without credentials. + fetch-depth: 0 + - name: pnpm + uses: pnpm/setup@a0881977cd8ea73b1ed212236c99ca10dcc80cf4 # v3.1.1 + with: + cache: false + require-lockfile: true + - name: changesets + id: changesets + uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 + with: + github-token: ${{ steps.app.outputs.token }} + version-script: pnpm run release:version + publish-script: pnpm changeset git-tag + pr-title: "chore: release" + commit-message: "chore: release" + - name: automerge + if: steps.changesets.outputs.pr-number != '' + env: + GH_TOKEN: ${{ steps.app.outputs.token }} + PR: ${{ steps.changesets.outputs.pr-number }} + run: gh pr merge --auto --squash "$PR" diff --git a/justfile b/justfile index 6c484e5..cfc9c97 100644 --- a/justfile +++ b/justfile @@ -54,13 +54,15 @@ access: mv .env.next .env # Check, test and deploy the Worker to CLAIRIC_DOMAIN behind the Access application -deploy: +ci: + pnpm exec oxfmt --check . + pnpm exec oxlint + pnpm exec tsc --noEmit -p . + pnpm exec vitest run + +deploy: ci #!/usr/bin/env bash set -euo pipefail : "${CLAIRIC_DOMAIN:?set it in .env}" "${ACCESS_TEAM_DOMAIN:?set it in .env}" "${ACCESS_AUD:?run just access first}" - pnpm exec tsc --noEmit -p . - pnpm exec oxlint - pnpm exec oxfmt --check . - pnpm exec vitest run pnpm exec wrangler deploy --domain "$CLAIRIC_DOMAIN" \ --var "ACCESS_TEAM_DOMAIN:$ACCESS_TEAM_DOMAIN" --var "ACCESS_AUD:$ACCESS_AUD" diff --git a/package.json b/package.json index 238f98d..68c8c4d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "type": "module", "scripts": { - "postinstall": "wrangler types" + "postinstall": "wrangler types", + "release:version": "changeset version" }, "dependencies": { "@modelcontextprotocol/server": "^2.3.1", @@ -12,6 +13,7 @@ "zod": "^4.6.7" }, "devDependencies": { + "@changesets/cli": "^3.0.3", "oxfmt": "^0.73.0", "oxlint": "^1.88.0", "oxlint-tsgolint": "^7.0.2004", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d07c177..9a88d32 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -176,6 +176,9 @@ importers: specifier: ^4.6.7 version: 4.6.7 devDependencies: + '@changesets/cli': + specifier: ^3.0.3 + version: 3.0.3 node: specifier: runtime:^24.22.0 version: runtime:24.22.0 @@ -193,13 +196,82 @@ importers: version: 7.0.2 vitest: specifier: ^5.0.5 - version: 5.0.5(vite@8.3.4(esbuild@0.28.2)) + version: 5.0.5(vite@8.3.4(esbuild@0.28.2)(yaml@2.9.1)) wrangler: specifier: ^4.151.1 version: 4.151.1 packages: + '@changesets/apply-release-plan@8.1.1': + resolution: {integrity: sha512-nk2Hbq3M9NeHMdaIRBDvawKrQJzXB9sGyBUE5yWnIKtvdcNCPj75zBekJYr0gTT2ecJH3eFeTrc8eisPImcv0Q==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/assemble-release-plan@7.0.0': + resolution: {integrity: sha512-oEW8BxdA604kGGtDSCiHr5w9Tv4UWe9I2k61IBNZzCOE1kbYaJj4v+lFQNgcEZFkUc2pV/+hASErGDvpJOZCTg==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/changelog-git@1.0.0': + resolution: {integrity: sha512-3Dst2Ime2Op5nd4XmWJLPIgp11ZFqJqSkVug9izK6TDcIV4YlhPS4ECbEVR+eGI0bk0r1ItogD4j2Oli87bJrA==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/cli@3.0.3': + resolution: {integrity: sha512-L1i67bMfkK6iC/kDejuNO4pFgTRcWIObsD6Qof2woP1I4M8tj17DGlcpRaTzTv1DYSP5EMwWdEtR8X0Pj5Jg3Q==} + engines: {node: ^22.11 || ^24 || >=26, npm: '>=10.9.0', pnpm: '>=10.0.0', yarn: '>=4.5.2'} + hasBin: true + + '@changesets/config@4.0.1': + resolution: {integrity: sha512-PxpxSQLQSLDjceAgRq+4FWlU+HflDIw03mmPVipxoQx9xrXFUjmqTy3SE+n/2t+DqPdpPiLWVr5NRiLZvjyLwg==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/errors@1.0.0': + resolution: {integrity: sha512-ElN/mEzn6zmETgjwf5MclCMa9ef59sAR0lfO8VSYIsiRvbC2FbLB/92EoYw10Sl0kGixxHFiJZUSv7dA+YpR8g==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/format@0.1.2': + resolution: {integrity: sha512-Caez5XtNXCFS/G5bwyav3wuXL0tMxVd2ZGbaumWbzN08tyzO21asCw7JZhNtVsAZDCvDRUzZN+Iit9SyRITSYA==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/get-dependents-graph@3.0.0': + resolution: {integrity: sha512-ji/t5wFA1zREKXRUePE6Qi+Qu2UgxCeSSGQrphezwvQZrp49B7sJ+8+wvM0tA7zPeSxYKCojDy3WWgrl+s+awg==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/git@4.0.1': + resolution: {integrity: sha512-6vWpIAC4LkpmlqaIu37ViT5enyd9+uBwAiGqCGhASvkSHBgx4PrtTGXWTMFYpDmZbjgyonyVgMciPrW4MqtJsA==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/parse@1.0.0': + resolution: {integrity: sha512-P0iaMb9p9CRYZiTgAllEIF9AUMQHIy1G72tKlcIqJp61icZSsKQNiOPdxAMZG8m/DvZwt/oz5xEbTpike//dWg==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/pre@3.0.0': + resolution: {integrity: sha512-Zm/6YliV/a2oeWTqHJf6KxLrQwgcK1i/BRDl2m0EKZvbnxV5fG9QRhwJJGshjsZTUTS6dkfURQ2K6aAvgNw/3Q==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/read@1.0.1': + resolution: {integrity: sha512-nzvSC6RcTiWf/dsuwZFXpLzGGsRHYCL68U3uHV7srsulU93aVWY7u2GEJiDZ+4GIIElfaW5EqtKC0UHroY+LTQ==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/should-skip-package@1.0.0': + resolution: {integrity: sha512-pwqoJmbONn1XgXmZXPEExgAaT+HdZLjALFTDgIm+PnS5KeO2nLtzA2/Q+4aMFY14kFMuXKG30MObhvDzWgzDgg==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/types@7.0.0': + resolution: {integrity: sha512-c5GoiQyt3pxiXjrWSNoP8/GRf4kG+VnKzovx1OQM8dYYALlSwgedmkPmJ+ZqGxqwg9D3Bkj85Uo4KLd5BN3A0w==} + engines: {node: ^22.11 || ^24 || >=26} + + '@changesets/write@1.0.1': + resolution: {integrity: sha512-q/ThtP9gcnEP6xlv7LrY26C2mHqdGBti/MmOVngt/M/oIGYkssmQGxPK9WzBNt2juVcH/vml2WQ+ra8LXYOTaA==} + engines: {node: ^22.11 || ^24 || >=26} + + '@clack/core@1.5.1': + resolution: {integrity: sha512-iHTrHA8MtVuLl2TfZySmcKv1qO2PoyC9Z7pfSDozEuV5vtY3/wcOPKJXlqJ5Oq2Cx5DDGQGAMVx6HZfRRoVEbQ==} + engines: {node: '>= 20.12.0'} + + '@clack/prompts@1.8.1': + resolution: {integrity: sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==} + engines: {node: '>= 20.12.0'} + '@cloudflare/kv-asset-handler@0.5.0': resolution: {integrity: sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==} engines: {node: '>=22.0.0'} @@ -581,6 +653,18 @@ packages: '@jridgewell/trace-mapping@0.3.9': resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + '@manypkg/find-root@3.1.0': + resolution: {integrity: sha512-BcSqCyKhBVZ5YkSzOiheMCV41kqAFptW6xGqYSTjkVTl9XQpr+pqHhwgGCOHQtjDCv7Is6EFyA14Sm5GVbVABA==} + engines: {node: '>=20.0.0'} + + '@manypkg/get-packages@3.1.0': + resolution: {integrity: sha512-0TbBVyvPrP7xGYBI/cP8UP+yl/z+HtbTttAD7FMAJgn/kXOTwh5/60TsqP9ZYY710forNfyV0N8P/IE/ujGZJg==} + engines: {node: '>=20.0.0'} + + '@manypkg/tools@2.1.2': + resolution: {integrity: sha512-6QEf6yqFbETdwGITKq57aYoPfX/3K8XFNwsAlx0C1M7o8cb79sv1M3w+tWuWvIcSbNqrLF7OD7YpZMVVz335hQ==} + engines: {node: '>=20.0.0'} + '@modelcontextprotocol/core@2.3.1': resolution: {integrity: sha512-laVmIhPGpWi7rG9q+0UigblRN0Hws/Yjlb6qLFtVqryXVLkc4h+yN8z731POD2LnAGQlFe7/tXhUm7Bi0YB91g==} engines: {node: '>=20'} @@ -866,6 +950,10 @@ packages: cpu: [x64] os: [win32] + '@pnpm/deps.graph-sequencer@1100.0.1': + resolution: {integrity: sha512-pOr5+q1fLYKwFN3LAJuGZEnfXDcQ73zqgDHMtGy+K+uIoUqyY+6MeDCWFwfu+4EFuq76I5EPFofoNAI+Bmmq4A==} + engines: {node: '>=22.13'} + '@poppinss/colors@4.1.6': resolution: {integrity: sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==} @@ -1131,6 +1219,10 @@ packages: blake3-wasm@2.1.5: resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==} + cac@7.1.0: + resolution: {integrity: sha512-LMDU/U2yA4IPIY8KT0NsNPWEYZvAMkbgyspxJ6btJaYV+WMDOHAZCmB0lsTObiHaRS1V/ztKAl7+TSkTqXyeoA==} + engines: {node: '>=20.19.0'} + chai@6.3.0: resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} engines: {node: '>=18'} @@ -1161,6 +1253,15 @@ packages: resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} engines: {node: '>=12.0.0'} + fast-string-truncated-width@3.0.3: + resolution: {integrity: sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==} + + fast-string-width@3.0.2: + resolution: {integrity: sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==} + + fast-wrap-ansi@0.2.2: + resolution: {integrity: sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==} + fdir@6.5.0: resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} engines: {node: '>=12.0.0'} @@ -1175,13 +1276,29 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + human-id@4.2.2: + resolution: {integrity: sha512-Z+8unD6em/MJwyrkWQ2M3wygRGI1+MztbutiNwk1DCuEPXOZRWGjtcMPZYP1exY9iNZMhd7ZOSMQSo9WYtiQRw==} + hasBin: true + + import-meta-resolve@4.2.0: + resolution: {integrity: sha512-Iqv2fzaTQN28s/FwZAoFq0ZSs/7hMAHJVX+w8PZl3cY19Pxk6jFFalxQoIfW2826i/fDLXv8IiEZRIT0lDuWcg==} + + jju@1.4.0: + resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==} + jose@6.2.12: resolution: {integrity: sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==} + jsonc-parser@3.3.1: + resolution: {integrity: sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==} + kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} + launch-editor@2.14.2: + resolution: {integrity: sha512-NHJEb30MGBCkmZXLZwz25t37QR4aY03ZzPYUJXOJaOa92uWwExI9SBQUuIznBYc1xkD7cJNGX7oc3Nl3sq2kQQ==} + lightningcss-android-arm64@1.33.0: resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} engines: {node: '>= 12.0.0'} @@ -1437,6 +1554,9 @@ packages: vite-plus: optional: true + package-manager-detector@1.9.0: + resolution: {integrity: sha512-zAMfbta9nPA8AKkA4WdmNAT8R8s6Dk0/xwPsqNnRidMFcLo1YkLuPDTgs2f64XdzS8vbLNnoJ+uUIkgbz7oRHA==} + path-to-regexp@6.3.0: resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} @@ -1473,6 +1593,13 @@ packages: '@types/node': optional: true + shell-quote@1.12.0: + resolution: {integrity: sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q==} + engines: {node: '>= 0.4'} + + sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + source-map-js@1.2.2: resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} engines: {node: '>=0.10.0'} @@ -1631,6 +1758,11 @@ packages: utf-8-validate: optional: true + yaml@2.9.1: + resolution: {integrity: sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==} + engines: {node: '>= 14.6'} + hasBin: true + youch-core@0.3.3: resolution: {integrity: sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==} @@ -1642,6 +1774,122 @@ packages: snapshots: + '@changesets/apply-release-plan@8.1.1': + dependencies: + '@changesets/config': 4.0.1 + '@changesets/format': 0.1.2 + '@changesets/git': 4.0.1 + '@changesets/should-skip-package': 1.0.0 + '@changesets/types': 7.0.0 + import-meta-resolve: 4.2.0 + jsonc-parser: 3.3.1 + semver: 7.8.5 + + '@changesets/assemble-release-plan@7.0.0': + dependencies: + '@changesets/errors': 1.0.0 + '@changesets/get-dependents-graph': 3.0.0 + '@changesets/should-skip-package': 1.0.0 + '@changesets/types': 7.0.0 + semver: 7.8.5 + + '@changesets/changelog-git@1.0.0': + dependencies: + '@changesets/types': 7.0.0 + + '@changesets/cli@3.0.3': + dependencies: + '@changesets/apply-release-plan': 8.1.1 + '@changesets/assemble-release-plan': 7.0.0 + '@changesets/changelog-git': 1.0.0 + '@changesets/config': 4.0.1 + '@changesets/errors': 1.0.0 + '@changesets/get-dependents-graph': 3.0.0 + '@changesets/git': 4.0.1 + '@changesets/pre': 3.0.0 + '@changesets/read': 1.0.1 + '@changesets/should-skip-package': 1.0.0 + '@changesets/types': 7.0.0 + '@changesets/write': 1.0.1 + '@clack/prompts': 1.8.1 + '@manypkg/get-packages': 3.1.0 + '@pnpm/deps.graph-sequencer': 1100.0.1 + cac: 7.1.0 + import-meta-resolve: 4.2.0 + launch-editor: 2.14.2 + package-manager-detector: 1.9.0 + semver: 7.8.5 + tinyexec: 1.3.1 + + '@changesets/config@4.0.1': + dependencies: + '@changesets/get-dependents-graph': 3.0.0 + '@changesets/should-skip-package': 1.0.0 + '@changesets/types': 7.0.0 + '@manypkg/get-packages': 3.1.0 + picomatch: 4.0.7 + + '@changesets/errors@1.0.0': {} + + '@changesets/format@0.1.2': + dependencies: + package-manager-detector: 1.9.0 + tinyexec: 1.3.1 + + '@changesets/get-dependents-graph@3.0.0': + dependencies: + '@changesets/types': 7.0.0 + semver: 7.8.5 + + '@changesets/git@4.0.1': + dependencies: + '@changesets/errors': 1.0.0 + '@changesets/types': 7.0.0 + '@manypkg/get-packages': 3.1.0 + picomatch: 4.0.7 + tinyexec: 1.3.1 + + '@changesets/parse@1.0.0': + dependencies: + '@changesets/types': 7.0.0 + yaml: 2.9.1 + + '@changesets/pre@3.0.0': + dependencies: + '@changesets/errors': 1.0.0 + '@changesets/types': 7.0.0 + '@manypkg/get-packages': 3.1.0 + + '@changesets/read@1.0.1': + dependencies: + '@changesets/git': 4.0.1 + '@changesets/parse': 1.0.0 + '@changesets/types': 7.0.0 + + '@changesets/should-skip-package@1.0.0': + dependencies: + '@changesets/types': 7.0.0 + + '@changesets/types@7.0.0': {} + + '@changesets/write@1.0.1': + dependencies: + '@changesets/format': 0.1.2 + '@changesets/types': 7.0.0 + human-id: 4.2.2 + + '@clack/core@1.5.1': + dependencies: + fast-wrap-ansi: 0.2.2 + sisteransi: 1.0.5 + + '@clack/prompts@1.8.1': + dependencies: + '@clack/core': 1.5.1 + fast-string-width: 3.0.2 + fast-wrap-ansi: 0.2.2 + sisteransi: 1.0.5 + '@cloudflare/kv-asset-handler@0.5.0': {} '@cloudflare/unenv-preset@2.16.2(unenv@2.0.0-rc.24)(workerd@1.20261012.1)': @@ -1872,6 +2120,21 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.6.0 + '@manypkg/find-root@3.1.0': + dependencies: + '@manypkg/tools': 2.1.2 + + '@manypkg/get-packages@3.1.0': + dependencies: + '@manypkg/find-root': 3.1.0 + '@manypkg/tools': 2.1.2 + + '@manypkg/tools@2.1.2': + dependencies: + jju: 1.4.0 + tinyglobby: 0.2.17 + yaml: 2.9.1 + '@modelcontextprotocol/core@2.3.1': dependencies: zod: 4.6.7 @@ -2015,6 +2278,8 @@ snapshots: '@oxlint/binding-win32-x64-msvc@1.88.0': optional: true + '@pnpm/deps.graph-sequencer@1100.0.1': {} + '@poppinss/colors@4.1.6': dependencies: kleur: 4.1.5 @@ -2147,14 +2412,14 @@ snapshots: '@typescript/typescript-win32-x64@7.0.2': optional: true - '@vitest/mocker@5.0.5(vite@8.3.4(esbuild@0.28.2))': + '@vitest/mocker@5.0.5(vite@8.3.4(esbuild@0.28.2)(yaml@2.9.1))': dependencies: '@jridgewell/trace-mapping': 0.3.31 '@vitest/spy': 5.0.5 estree-walker: 3.0.3 magic-string: 1.4.3 optionalDependencies: - vite: 8.3.4(esbuild@0.28.2) + vite: 8.3.4(esbuild@0.28.2)(yaml@2.9.1) '@vitest/spy@5.0.5': {} @@ -2162,6 +2427,8 @@ snapshots: blake3-wasm@2.1.5: {} + cac@7.1.0: {} + chai@6.3.0: {} cookie@1.1.1: {} @@ -2207,6 +2474,16 @@ snapshots: expect-type@1.4.0: {} + fast-string-truncated-width@3.0.3: {} + + fast-string-width@3.0.2: + dependencies: + fast-string-truncated-width: 3.0.3 + + fast-wrap-ansi@0.2.2: + dependencies: + fast-string-width: 3.0.2 + fdir@6.5.0(picomatch@4.0.7): optionalDependencies: picomatch: 4.0.7 @@ -2214,10 +2491,23 @@ snapshots: fsevents@2.3.3: optional: true + human-id@4.2.2: {} + + import-meta-resolve@4.2.0: {} + + jju@1.4.0: {} + jose@6.2.12: {} + jsonc-parser@3.3.1: {} + kleur@4.1.5: {} + launch-editor@2.14.2: + dependencies: + picocolors: 1.1.1 + shell-quote: 1.12.0 + lightningcss-android-arm64@1.33.0: optional: true @@ -2346,6 +2636,8 @@ snapshots: '@oxlint/binding-win32-x64-msvc': 1.88.0 oxlint-tsgolint: 7.0.2004 + package-manager-detector@1.9.0: {} + path-to-regexp@6.3.0: {} pathe@2.0.3: {} @@ -2415,6 +2707,10 @@ snapshots: '@img/sharp-win32-ia32': 0.35.5 '@img/sharp-win32-x64': 0.35.5 + shell-quote@1.12.0: {} + + sisteransi@1.0.5: {} + source-map-js@1.2.2: {} std-env@4.3.0: {} @@ -2464,7 +2760,7 @@ snapshots: dependencies: pathe: 2.0.3 - vite@8.3.4(esbuild@0.28.2): + vite@8.3.4(esbuild@0.28.2)(yaml@2.9.1): dependencies: lightningcss: 1.33.0 picomatch: 4.0.7 @@ -2474,11 +2770,12 @@ snapshots: optionalDependencies: esbuild: 0.28.2 fsevents: 2.3.3 + yaml: 2.9.1 - vitest@5.0.5(vite@8.3.4(esbuild@0.28.2)): + vitest@5.0.5(vite@8.3.4(esbuild@0.28.2)(yaml@2.9.1)): dependencies: '@types/chai': 5.2.3 - '@vitest/mocker': 5.0.5(vite@8.3.4(esbuild@0.28.2)) + '@vitest/mocker': 5.0.5(vite@8.3.4(esbuild@0.28.2)(yaml@2.9.1)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -2489,7 +2786,7 @@ snapshots: tinybench: 6.2.2 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.4(esbuild@0.28.2) + vite: 8.3.4(esbuild@0.28.2)(yaml@2.9.1) why-is-node-running: 3.2.1 transitivePeerDependencies: - msw @@ -2523,6 +2820,8 @@ snapshots: ws@8.21.0: {} + yaml@2.9.1: {} + youch-core@0.3.3: dependencies: '@poppinss/exception': 1.2.3 From 04ccc6db25447df0042f5d58a27ce92c91c7666a Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 23:25:47 +0100 Subject: [PATCH 12/13] docs: README with setup, connecting and an example --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..94bf998 --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# clairic-mcp + +An MCP server that gives you Cloudflare's [Clairic](https://developers.cloudflare.com/workers-ai/models/clairic/) model as one tool, `extract`. It runs as a Worker on your own Cloudflare account, behind Cloudflare Access. + +You send `extract` an input (text, a public web page or up to four images) and a list of fields, each with a name and a type. Clairic gives back one answer per field: a value of that type, or null when the input doesn't settle it. Each answer carries a `confidence`, the chance the value is right, and a `p_null`, the chance the input has no value for the field. Text answers also say which line they came from. Clairic answers in one fast pass and doesn't reason step by step, so the assistant calling it picks the fields and does any arithmetic longer than a step or two. + +## Setup + +You need: + +- a Cloudflare account with a domain on it +- a Zero Trust team, which is free, with at least one login method (One-time PIN is enough) +- an API token with **Access: Apps and Policies Write**, used once by `just access` +- Node 24, pnpm, [just](https://github.com/casey/just), curl and jq + +```sh +git clone https://github.com/lmarkmann/clairic-mcp && cd clairic-mcp +pnpm install +pnpm exec wrangler login +cp .env.example .env # your account id, domain, team, allowed emails and the API token +just access # creates the Access app and policy, writes ACCESS_AUD to .env +just deploy # runs the checks, then deploys to your domain +``` + +Everything specific to your deployment lives in `.env`, which git ignores. The Worker rejects every request until `ACCESS_AUD` is set, so a deploy without `just access` serves nothing. + +Access sits in front of the whole hostname and acts as the OAuth server: a client registers itself, sends you to your team's login page, and only emails on the `clairic-mcp users` policy get through. + +## Connect + +Claude Code: + +```sh +claude mcp add --transport http clairic https:///mcp +``` + +pi: + +```sh +pi mcp add clairic --url https:///mcp +``` + +Then sign in when the client asks (`/mcp` in either one). Other clients take the same URL as a remote MCP server with the client ID and secret left empty. Access accepts callbacks on localhost and the hosted callback listed under `allowed_uris` in the `justfile`; add any other hosted callback there before you run `just access`. + +Clients keep the tool list from when they connected, so reconnect after an update changes the tool. + +## Example + +The input: + +``` +Invoice INV-2291 from Northwind Supply, issued 2026-09-02, net 30. +4 pallets at $250.00 each, shipping $80.00. +``` + +The fields: + +```json +{ + "due_date": { "type": "date", "instructions": "Issue date plus the net payment days" }, + "total": { "type": "number", "decimals": 2, "unit": "USD", "instructions": "Amount due including shipping" }, + "po_number": { "type": "text", "instructions": "Purchase order number" }, + "days_to_pay": { "type": "estimate", "min": 0, "max": 120, "step": 1, "instructions": "Days after issue until this invoice is paid" } +} +``` + +The answers: + +``` +due_date: "2026-10-02" (confidence >0.999, p_null <0.001) +total: 1080 USD (confidence >0.999, p_null <0.001) +po_number: null (p_null >0.999; best guess "INV-2291" at confidence >0.999) +days_to_pay: 31 (median 31, 80% interval 24 to 38, mean 31.32) +``` + +The due date and the total are computed, not copied. The invoice has no purchase order number, so `po_number` is null; the best guess next to it is what Clairic would say if forced to pick, not an answer. An answer with confidence under 0.9, or a p_null between 0.1 and 0.9, is marked `[check]`, and the tool tells the client to have you verify it. + +## Field types + +| Type | You get | +| --- | --- | +| `text` | A piece of the input, quoted as written, with its line number | +| `number`, `duration` | A number, optionally with a unit, fixed decimals or a whole number | +| `date`, `time`, `datetime` | An ISO value; dates without a year are read relative to the reference date | +| `list` | Every match, as text, numbers or dates | +| `estimate` | A median and an 80% interval between the `min` and `max` you set | +| `forecast` | One estimate per step ahead, from a series in the input | + +## Limits + +Clairic is in preview. Per Cloudflare's [release notes](https://developers.cloudflare.com/changelog/post/2026-10-19-clairic-workers-ai/), one- and two-step arithmetic is reliable, while long chains and sums over many table rows are not, and forecasts flatten toward the average after the first step. + +Clairic reads at most 65,536 tokens; when an input is longer the answer says so, and for a page you can call again with `offset`. The server refuses PDFs, pages over 8 MiB and anything behind a login. Images can be PNG, JPEG or WebP: up to four, 4 MiB each and 8 MiB together. From 54b76f274cf40fab359b8453e7d843f943a9d0f4 Mon Sep 17 00:00:00 2001 From: Luis Markmann <110569833+lmarkmann@users.noreply.github.com> Date: Mon, 19 Oct 2026 23:26:54 +0100 Subject: [PATCH 13/13] chore: MIT license; drop the limits section from the README --- LICENSE | 21 +++++++++++++++++++++ README.md | 6 ------ package.json | 1 + 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c98eff7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Luis Markmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 94bf998..760648b 100644 --- a/README.md +++ b/README.md @@ -85,9 +85,3 @@ The due date and the total are computed, not copied. The invoice has no purchase | `list` | Every match, as text, numbers or dates | | `estimate` | A median and an 80% interval between the `min` and `max` you set | | `forecast` | One estimate per step ahead, from a series in the input | - -## Limits - -Clairic is in preview. Per Cloudflare's [release notes](https://developers.cloudflare.com/changelog/post/2026-10-19-clairic-workers-ai/), one- and two-step arithmetic is reliable, while long chains and sums over many table rows are not, and forecasts flatten toward the average after the first step. - -Clairic reads at most 65,536 tokens; when an input is longer the answer says so, and for a page you can call again with `offset`. The server refuses PDFs, pages over 8 MiB and anything behind a login. Images can be PNG, JPEG or WebP: up to four, 4 MiB each and 8 MiB together. diff --git a/package.json b/package.json index 68c8c4d..2b9e9ae 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "clairic-mcp", "version": "0.1.0", "private": true, + "license": "MIT", "type": "module", "scripts": { "postinstall": "wrangler types",