@arbol-ai/maximus 8.5.2 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/analytics/analytics.d.ts +1 -1
  2. package/dist/analytics/analytics.js +1 -1
  3. package/dist/body.d.ts +1 -1
  4. package/dist/body.js +1 -1
  5. package/dist/capture/index.d.ts +1 -1
  6. package/dist/capture/index.js +2 -2
  7. package/dist/chunks/{define-app-CvTei9a8.js → define-app-BpSKvXET.js} +45 -5
  8. package/dist/chunks/{http-layout-pnmGxDOY.js → http-layout-BsQlLNeo.js} +4 -5
  9. package/dist/chunks/{execution-BJGx5Kxb.js → meter-B_WuFl_c.js} +64 -3
  10. package/dist/chunks/{openapi-CoKhMm1C.js → openapi-C2A4SxMi.js} +4 -4
  11. package/dist/chunks/{openapi-file-Crm9fT4U.js → openapi-file-DlBVI3lc.js} +2 -2
  12. package/dist/chunks/{pages-D0zdaO0w.js → pages-B0xdWws9.js} +1 -1
  13. package/dist/chunks/{runtime-CUhyce4d.js → runtime-DjCjXIdf.js} +18 -6
  14. package/dist/chunks/{scaffold-DZD6dfoZ.js → scaffold-BfrJN0Yk.js} +1 -1
  15. package/dist/chunks/{scaffold-DGrcjR3h.js → scaffold-C16tbL7M.js} +1 -1
  16. package/dist/chunks/{server-tygU8dw_.js → server-UtQtcegf.js} +5 -5
  17. package/dist/chunks/{src-DfMzoKE_.js → src-CYk0Af0t.js} +17 -10
  18. package/dist/chunks/{tasks-DYdY-dBI.js → tasks-CD-B6_nv.js} +2 -2
  19. package/dist/chunks/{tasks-C873C3le.js → tasks-DELqUSq8.js} +1 -1
  20. package/dist/chunks/{tokens-D4gRyyPu.js → tokens-D6yVDtEU.js} +2 -1
  21. package/dist/chunks/{types-BfGa2aJT.d.ts → types-AjJyXA62.d.ts} +181 -8
  22. package/dist/chunks/{workers-types-Cxf-5cH7.d.ts → workers-types-B6F5WEuu.d.ts} +1 -1
  23. package/dist/client.d.ts +1 -1
  24. package/dist/diagnostics.d.ts +1 -1
  25. package/dist/diagnostics.js +1 -1
  26. package/dist/errors.d.ts +1 -1
  27. package/dist/http-paths.d.ts +1 -1
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +4 -4
  30. package/dist/internals.d.ts +2 -2
  31. package/dist/internals.js +5 -5
  32. package/dist/mcp/index.d.ts +1 -1
  33. package/dist/mcp/index.js +1 -1
  34. package/dist/mcp/tasks.d.ts +1 -1
  35. package/dist/mcp/tasks.js +1 -1
  36. package/dist/project/config.d.ts +5 -3
  37. package/dist/project/config.js +1 -1
  38. package/dist/project/index.d.ts +2 -2
  39. package/dist/project/index.js +2 -2
  40. package/dist/schemas.d.ts +1 -1
  41. package/dist/standard-failures.d.ts +1 -1
  42. package/dist/tooling/cli.js +2 -2
  43. package/dist/vite/index.d.ts +11 -2
  44. package/dist/vite/index.js +20 -10
  45. package/dist/webhooks.d.ts +1 -1
  46. package/dist/workers/runtime.d.ts +1 -1
  47. package/dist/workers/runtime.js +1 -1
  48. package/package.json +10 -10
  49. package/skills/maximus/SKILL.md +9 -7
  50. package/skills/maximus/references/project.md +5 -4
  51. package/skills/maximus/references/routes-and-tools.md +22 -0
  52. package/skills/maximus/references/testing.md +1 -1
  53. package/templates/project/.github/workflows/ci.yml.template +23 -2
  54. package/templates/project/CLAUDE.md.template +1 -1
  55. package/templates/project/README.md.template +3 -3
  56. package/templates/project/package.json.template +13 -13
@@ -1,9 +1,9 @@
1
- import { t as checkMcpResourceNames } from "../chunks/define-app-CvTei9a8.js";
2
1
  import { a as operationPathParameters } from "../chunks/http-paths-D043DkJv.js";
3
- import { a as ownsPrefix, t as VERSIONED_PATH } from "../chunks/http-layout-pnmGxDOY.js";
4
- import { t as checkPagePaths } from "../chunks/pages-D0zdaO0w.js";
2
+ import { a as ownsPrefix, t as VERSIONED_PATH } from "../chunks/http-layout-BsQlLNeo.js";
5
3
  import { t as routeName } from "../chunks/names-ncD7A3DV.js";
4
+ import { t as checkPagePaths } from "../chunks/pages-B0xdWws9.js";
6
5
  import { a as projectPath, i as projectFiles, o as publicFiles, r as compareNames, s as routeShape, t as PROJECT_DIRECTORIES } from "../chunks/project-files-C0OX7MQQ.js";
6
+ import { t as checkMcpResourceNames } from "../chunks/define-app-BpSKvXET.js";
7
7
  import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
8
8
  import { dirname, join, posix, relative, resolve, sep } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
@@ -44,7 +44,7 @@ const SERVICE_NAME = /^(?=.{2,63}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
44
44
  /** The application's options and the Worker's settings, apart. `assets` is maximus()'s own. */
45
45
  function split(options) {
46
46
  if ("assets" in options) throw new TypeError("maximus() configures the assets: index.html at the root makes the project a web app.");
47
- const { name, namespace, title, description, groups, version, origin, tokens, rpc, http, maxBodyBytes, maxOutputBytes, rateLimit, env, services, webApp, ...worker } = options;
47
+ const { name, namespace, title, description, groups, version, origin, tokens, rpc, http, maxBodyBytes, maxOutputBytes, rateLimit, meter, env, services, webApp, ...worker } = options;
48
48
  return {
49
49
  application: {
50
50
  name,
@@ -59,7 +59,8 @@ function split(options) {
59
59
  http,
60
60
  maxBodyBytes,
61
61
  maxOutputBytes,
62
- rateLimit
62
+ rateLimit,
63
+ meter
63
64
  },
64
65
  env,
65
66
  services,
@@ -217,7 +218,8 @@ function projectOptions(root, options, phase = "production") {
217
218
  rpc: application.rpc ?? { callers: [] },
218
219
  ...application.maxBodyBytes === void 0 ? {} : { maxBodyBytes: application.maxBodyBytes },
219
220
  ...application.maxOutputBytes === void 0 ? {} : { maxOutputBytes: application.maxOutputBytes },
220
- ...application.rateLimit === void 0 ? {} : { rateLimit: application.rateLimit }
221
+ ...application.rateLimit === void 0 ? {} : { rateLimit: application.rateLimit },
222
+ ...application.meter === void 0 ? {} : { meter: application.meter }
221
223
  },
222
224
  worker: {
223
225
  http: {
@@ -1103,7 +1105,8 @@ function prepareProject(directory, mode, project) {
1103
1105
  const routes = discoverRoutes(root, files.routes, application);
1104
1106
  const tools = discoverTools(root, files.mcp, application);
1105
1107
  const servesMcp = routes.mcp || tools.length > 0 || described !== void 0;
1106
- if (servesMcp && project.application.tokens.source === "cloudflare-access") throw new TypeError("A project behind Cloudflare Access serves no MCP, whose clients sign in through OAuth: remove mcp from its routes, and the mcp/ folder.");
1108
+ const { tokens } = project.application;
1109
+ if (servesMcp && tokens.source === "cloudflare-access" && tokens.access?.managedOAuth !== true) throw new TypeError("A project behind Cloudflare Access serves no MCP, whose clients sign in through OAuth: remove mcp from its routes, and the mcp/ folder.");
1107
1110
  const binders = [
1108
1111
  ...files.routes.length ? ["bindRoute"] : [],
1109
1112
  ...tools.length ? ["bindTool"] : [],
@@ -1186,6 +1189,7 @@ function prepareProject(directory, mode, project) {
1186
1189
  " base: typeof base;",
1187
1190
  ...catalog ? [" errors: typeof errors;"] : [],
1188
1191
  " env: Env;",
1192
+ ...project.application.meter ? [` meter: Env[${JSON.stringify(project.application.meter.binding)}];`] : [],
1189
1193
  " }",
1190
1194
  "}"
1191
1195
  ]),
@@ -1378,7 +1382,7 @@ function auth0({ domain, audience, algorithms = ["RS256"] }) {
1378
1382
  * for a team that is not a team name, such as the team's domain, and an AUD tag that is not 64 lowercase
1379
1383
  * hexadecimal characters.
1380
1384
  */
1381
- function cloudflareAccess({ team, aud, organizationId, scopes }) {
1385
+ function cloudflareAccess({ team, aud, managedOAuth, organizationId, scopes }) {
1382
1386
  if (typeof team !== "string" || !TEAM_NAME.test(team)) throw new TypeError("cloudflareAccess() takes the Zero Trust team name, such as acme for acme.cloudflareaccess.com.");
1383
1387
  if (typeof aud !== "string" || !AUD_TAG.test(aud)) throw new TypeError("cloudflareAccess() takes the Access application's AUD tag: 64 lowercase hexadecimal characters.");
1384
1388
  const issuer = `https://${team}.cloudflareaccess.com`;
@@ -1389,6 +1393,7 @@ function cloudflareAccess({ team, aud, organizationId, scopes }) {
1389
1393
  audience: [aud],
1390
1394
  algorithms: ["RS256"],
1391
1395
  access: {
1396
+ ...managedOAuth === void 0 ? {} : { managedOAuth },
1392
1397
  ...organizationId === void 0 ? {} : { organizationId },
1393
1398
  people: scopes.people,
1394
1399
  ...scopes.services === void 0 ? {} : { services: scopes.services }
@@ -1453,11 +1458,16 @@ function maximus(options) {
1453
1458
  project,
1454
1459
  testing()
1455
1460
  ];
1456
- const customize = () => worker;
1457
1461
  return [
1458
1462
  configure,
1459
1463
  project,
1460
- ...cloudflare({ config: customize })
1464
+ ...cloudflare({ config(loaded) {
1465
+ if (!worker) throw new TypeError("Maximus has not prepared its Worker configuration.");
1466
+ return "worker" in loaded ? {
1467
+ ...loaded,
1468
+ worker
1469
+ } : worker;
1470
+ } })
1461
1471
  ];
1462
1472
  }
1463
1473
  /** The path of this package's stand-in for `cloudflare:workers`, with this extension. */
@@ -1,4 +1,4 @@
1
- import { jr as Failure, yr as Result } from "./chunks/types-BfGa2aJT.js";
1
+ import { Br as Failure, Or as Result } from "./chunks/types-AjJyXA62.js";
2
2
  /** Why a webhook signature was refused: absent, malformed, outside the time tolerance, or not matching. */
3
3
  export declare const WEBHOOK_SIGNATURE_FAILURES: readonly ['missing', 'malformed', 'expired', 'mismatch'];
4
4
  /** Why a webhook signature was refused. */
@@ -1,2 +1,2 @@
1
- import { a as credentials, i as createWorker, n as WorkerOptions, o as WorkerAssetsOptions, r as WorkerRuntime, t as RpcMethods } from "../chunks/workers-types-Cxf-5cH7.js";
1
+ import { a as credentials, i as createWorker, n as WorkerOptions, o as WorkerAssetsOptions, r as WorkerRuntime, t as RpcMethods } from "../chunks/workers-types-B6F5WEuu.js";
2
2
  export { RpcMethods, type WorkerAssetsOptions, WorkerOptions, WorkerRuntime, createWorker, credentials };
@@ -1,3 +1,3 @@
1
- import { n as credentials, t as createWorker } from "../chunks/runtime-CUhyce4d.js";
1
+ import { n as credentials, t as createWorker } from "../chunks/runtime-DjCjXIdf.js";
2
2
 
3
3
  export { createWorker, credentials };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbol-ai/maximus",
3
- "version": "8.5.2",
3
+ "version": "8.6.0",
4
4
  "description": "Maximus: define a service once and serve it over HTTP, MCP and Worker RPC on Cloudflare Workers, configured in vite.config.ts, with its OpenAPI and CLI.",
5
5
  "keywords": [
6
6
  "api",
@@ -142,23 +142,23 @@
142
142
  },
143
143
  "dependencies": {
144
144
  "@modelcontextprotocol/server": "2.4.0",
145
- "@scalar/openapi-parser": "0.29.20",
145
+ "@scalar/openapi-parser": "0.29.28",
146
146
  "ajv-formats": "3.0.1",
147
- "jose": "6.2.13",
147
+ "jose": "6.2.18",
148
148
  "rou3": "1.0.0",
149
- "standardwebhooks": "1.1.1",
150
- "typebox": "1.4.5"
149
+ "standardwebhooks": "1.3.0",
150
+ "typebox": "1.4.7"
151
151
  },
152
152
  "devDependencies": {
153
- "@cloudflare/vite-plugin": "2.0.0-beta.v.5",
153
+ "@cloudflare/vite-plugin": "2.0.0-rc.5",
154
154
  "@modelcontextprotocol/ext-tasks": "0.2.3",
155
155
  "@types/pg": "8.23.1",
156
156
  "ajv": "8.20.0",
157
- "cf": "1.0.0-beta.27",
158
- "miniflare": "5.20261023.0-beta",
157
+ "cf": "1.0.0-rc.6",
158
+ "miniflare": "5.20261123.1-beta",
159
159
  "pg": "8.23.1",
160
- "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
161
- "vite-plus": "1.4.0",
160
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
161
+ "vite-plus": "1.8.0",
162
162
  "yaml": "2.9.1"
163
163
  },
164
164
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: maximus
3
- description: Build, extend, test, upgrade and deploy services with the Maximus framework (@arbol-ai/maximus, whose /vite entry configures a project), organization-scoped APIs on Cloudflare Workers whose route files declare each contract once and are served over HTTP with OpenAPI, as MCP tools and over Worker RPC. Use when a project configures maximus() in vite.config.ts or imports @arbol-ai/maximus, or a task involves Maximus routes, MCP tools, scopes, error catalogs, context.ts, middleware, bindings, Worker RPC, OpenAPI, tests, the maximus CLI or deploying with cf.
3
+ description: Build, extend, test, upgrade and deploy services with the Maximus framework (@arbol-ai/maximus, whose /vite entry configures a project), organization-scoped APIs on Cloudflare Workers whose route files declare each contract once and are served over HTTP with OpenAPI, as MCP tools and over Worker RPC. Use when a project configures maximus() in vite.config.ts or imports @arbol-ai/maximus, or a task involves Maximus routes, MCP tools, scopes, error catalogs, context.ts, middleware, bindings, Worker RPC, metering billable calls, OpenAPI, tests, the maximus CLI or deploying with cf.
4
4
  ---
5
5
 
6
6
  # Maximus
@@ -70,7 +70,7 @@ each one.
70
70
  | `bun run test` | `vp test run`: the tests, in Node. |
71
71
  | `bun run typecheck` | `maximus prepare`, then `tsc`, which also checks type tests. |
72
72
  | `bun run check`, `bun run fix` | Lint and format; with fixes. |
73
- | `bun run verify` | Types, lint and format, tests and the build. CI runs it. |
73
+ | `bun run verify` | Types, lint and format, and the build. CI runs it. |
74
74
  | `bun run deploy` | `bun run verify`, then `cf deploy --prebuilt --mode production`. |
75
75
  | `bunx maximus skills` | Links this skill into the project's `.agents/skills`, `.claude/skills` and `.codex/skills`. |
76
76
 
@@ -90,13 +90,14 @@ Every `maximus` command says what it did in a sentence; `--json` prints it as JS
90
90
  | A rule for every operation, on every transport | `defineOperationMiddleware` in `middleware/`. |
91
91
  | Headers or an early answer around every request | `defineMiddleware` in `middleware/`. It runs before admission and sees no principal. |
92
92
  | Access tokens Auth0 issues | `tokens: auth0({ domain, audience })` from `@arbol-ai/maximus/vite`, with RBAC and permissions in the access token turned on. See [references/project.md](references/project.md#tokens). |
93
- | An application behind Cloudflare Access | `tokens: cloudflareAccess({ team, aud, organizationId, scopes })` from `@arbol-ai/maximus/vite`. It serves no MCP and no OAuth discovery. See [references/project.md](references/project.md#tokens). |
93
+ | An application behind Cloudflare Access | `tokens: cloudflareAccess({ team, aud, organizationId, scopes })` from `@arbol-ai/maximus/vite`. MCP needs `managedOAuth: true` and Managed OAuth at the edge. See [references/project.md](references/project.md#tokens). |
94
94
  | Tokens your authorization server does not issue | `auth.ts` with `defineAuth({ resolve })`, which verifies cryptographically. |
95
95
  | A provider's webhook, without a token | A page named for its method, `pages/webhooks/<provider>.post.ts`, which verifies the signature on the exact bytes with `@arbol-ai/maximus/webhooks`. See [references/project.md](references/project.md). |
96
96
  | Many items in one answer | `output: Page(Item, { $id: 'ItemPage' })` with `input: PageQueryFields`. |
97
97
  | A file upload or download | `http: { body: 'bytes' }` with `body.read()`; `output: AttachmentOutputSchema` with `http: { response: 'attachment' }`. |
98
98
  | Data in Postgres | `withTenantTransaction` from `@arbol-ai/maximus/postgres`. |
99
99
  | A record of every call, for audit or a lake | `capture.ts` with `defineCapture` from `@arbol-ai/maximus/capture`; mark credential fields `secret: true`. See [Capture](https://github.com/getarbol/maximus/blob/main/docs/guides/capture.md). |
100
+ | Charge for a call | `meter: { feature, when }` in its contract, and `meter: { binding }` in `maximus()`, typed by `BillingService`. See [Metering](https://github.com/getarbol/maximus/blob/main/docs/guides/metering.md). |
100
101
  | Guidance agents read over MCP | `mcp/instructions.md`, `mcp/guides/<name>.md`, `mcp/skills/<name>.md`: static text for every caller, never tenant data. |
101
102
  | A service on 8.2 or earlier | [Upgrading to 8.3](https://github.com/getarbol/maximus/blob/main/docs/upgrading-to-8.3.md): TypeBox 1.x. |
102
103
  | A 7.x service | [Upgrading to 8.0](https://github.com/getarbol/maximus/blob/main/docs/upgrading-to-8.md), then to 8.3. |
@@ -119,9 +120,9 @@ Every `maximus` command says what it did in a sentence; `--json` prints it as JS
119
120
  - **Exposure is explicit.** A route is a tool only with `mcp` and an RPC method only with `rpc`. Effects,
120
121
  `visibility`, descriptions and MCP hints never authorize: scopes and your own checks do.
121
122
  - **No private data in logs or errors.** Request bodies, input values, credentials, tokens, personal or
122
- clinical data never go in a log line, a failure's `data` or message, a refinement message, an MCP guide or
123
- skill, or an example. Report a caught error with `reportUnexpected(error, surface)`, which keeps its name
124
- and drops its message.
123
+ clinical data never go in a log line, a failure's `data` or message, a refinement message, a meter's
124
+ label, an MCP guide or skill, or an example. Report a caught error with `reportUnexpected(error, surface)`,
125
+ which keeps its name and drops its message.
125
126
  - **Content leaves only through capture.** Observers still receive metadata alone, never input, output or
126
127
  credentials. Capture (`capture.ts`) is a separate, declared destination, which the owner authorized on 3
127
128
  November 2026: content reaches a store through it, never through a log line, an observer or a failure. Mark
@@ -144,7 +145,7 @@ Load the one the task needs:
144
145
  the root modules, bindings and `Env`, the development token, what `prepare` generates, pages, background
145
146
  work, Durable Objects and web apps.
146
147
  - [references/routes-and-tools.md](references/routes-and-tools.md): file names and what they derive, every
147
- contract field, input, schemas and codecs, lists, byte bodies, tools, context and middleware.
148
+ contract field, input, schemas and codecs, lists, byte bodies, metering, tools, context and middleware.
148
149
  - [references/errors-and-results.md](references/errors-and-results.md): the catalog, `fail`, declared
149
150
  failures, the standard failures, uncertain outcomes and other services' failures.
150
151
  - [references/transports.md](references/transports.md): HTTP and OpenAPI, MCP, Worker RPC, and Workers
@@ -181,6 +182,7 @@ The documentation is in the Maximus repository, indexed by
181
182
  - Ship it: [Testing](https://github.com/getarbol/maximus/blob/main/docs/guides/testing.md),
182
183
  [Observability](https://github.com/getarbol/maximus/blob/main/docs/guides/observability.md),
183
184
  [Capture](https://github.com/getarbol/maximus/blob/main/docs/guides/capture.md),
185
+ [Metering](https://github.com/getarbol/maximus/blob/main/docs/guides/metering.md),
184
186
  [Deploying](https://github.com/getarbol/maximus/blob/main/docs/guides/deploying.md),
185
187
  [Lint and format](https://github.com/getarbol/maximus/blob/main/docs/guides/lint-and-format.md).
186
188
  - Reference: [Configuration](https://github.com/getarbol/maximus/blob/main/docs/reference/configuration.md),
@@ -34,6 +34,7 @@ export default defineConfig({
34
34
  | `http` | `{ basePath, healthPath }`: `/api` and `/health` by default. |
35
35
  | `maxBodyBytes`, `maxOutputBytes` | The limits of every operation that sets none: 32 KiB and 256 KiB. |
36
36
  | `rateLimit` | `{ binding, retryAfter }`: a rate limiting binding every HTTP and MCP call passes, per organization and actor. |
37
+ | `meter` | `{ binding }`: the binding of the billing service that routes and tools declaring `meter` report to. Type it with `BillingService<Feature>` from `@arbol-ai/maximus`, whose `Feature` names the facts they may report. See [Metering](https://github.com/getarbol/maximus/blob/main/docs/guides/metering.md). |
37
38
  | `env` | The Worker's bindings, from `cf/config`'s `bindings`. |
38
39
  | `webApp` | `{ headers }` for a web app's pages and files. |
39
40
  | Any other key | A Worker setting as Cloudflare names it: `compatibilityDate`, `compatibilityFlags`, `triggers`, `exports`, `observability`, `placement`, `limits`, `domains`, `workersDev`, `previewUrls`. |
@@ -84,9 +85,9 @@ tokens: cloudflareAccess({
84
85
  that holds each caller's in `claims.organization`, beside the spread preset. The Worker then reads the
85
86
  token from `cf-access-jwt-assertion` alone and verifies it against the team's keys; a production build
86
87
  answers `404` to any host but `origin`; a write another site's page sends answers `403`; `authority.token`
87
- is absent; and the Worker serves no OAuth discovery and no MCP, so `prepare` refuses a route or a file of
88
- `mcp/` that declares MCP. Under `vp dev` and in tests, the development token still signs in as a bearer
89
- token.
88
+ is absent. The Worker serves no OAuth discovery. If Cloudflare Access serves Managed OAuth at the edge,
89
+ set `managedOAuth: true` in `cloudflareAccess()` to serve MCP with the same verified assertions and
90
+ scopes. Under `vp dev` and in tests, the development token still signs in as a bearer token.
90
91
  - Spread a preset to add what it leaves out: `tokens: { ...auth0({ domain, audience }), development: false }`.
91
92
 
92
93
  Tokens that no issuer signs, such as keys the service issues itself, are verified by `auth.ts`. See
@@ -170,7 +171,7 @@ every change), `vp build`, `vp test` and `bun run typecheck` run it. It parses m
170
171
  | `env.d.ts` | `Env`. |
171
172
  | `middleware.ts` | The modules of `middleware/`, apart by phase. |
172
173
  | `base.ts` | The application builder: configuration, `errors.ts`, `auth.ts`, `context.ts`, `telemetry.ts`, MCP Markdown, operation middleware. |
173
- | `register.d.ts` | `MaximusRegister`: types every handler's context, failures and `Env`. |
174
+ | `register.d.ts` | `MaximusRegister`: types every handler's context, failures and `Env`, and the facts a `meter` names. |
174
175
  | `app.ts` | `app`: every route and tool, built. |
175
176
  | `worker.ts`, `entry.ts` | The Worker: `export default` its handler, `export const Service` its RPC entrypoint, and the Durable Object classes. |
176
177
  | `http.ts` | `handler`: the API as the Worker serves it, for tests in Node. |
@@ -103,6 +103,7 @@ object, and its handler may return nothing.
103
103
  | `rpc` | `true` for every caller in `rpc.callers`, or `{ callers }` for some of them. |
104
104
  | `task` | `true` or `{ ttlMs }`: a call that outlasts one second answers a task (MCP Tasks, or `Prefer: respond-async`); needs `MAXIMUS_TASKS`. |
105
105
  | `maxBodyBytes`, `maxOutputBytes` | Its own limits, up to 16 MiB; the application's (32 KiB and 256 KiB) otherwise. |
106
+ | `meter` | `{ feature, when?, value?, properties? }`: the fact a billable call is, reported after the answer; see below. |
106
107
 
107
108
  A field no operation has does not compile, and `.build()` refuses it. A contract kept in a `const` keeps
108
109
  its types with `satisfies HandlerOptions`.
@@ -201,6 +202,27 @@ async ({ input, body, documents }) => {
201
202
  A download declares `output: AttachmentOutputSchema` and `http: { response: 'attachment' }`, and answers
202
203
  `{ body, contentType, filename, byteLength }`. Both are HTTP alone: never an MCP tool or an RPC method.
203
204
 
205
+ ## Metering
206
+
207
+ A route or tool that is charged for declares the fact a billable call is, and `maximus()` names the billing
208
+ service's binding, `meter: { binding: 'BILLING' }`, typed in `Env` with `BillingService<Feature>` from
209
+ `@arbol-ai/maximus`, whose `Feature` lists the facts the service reports:
210
+
211
+ ```ts
212
+ // In the contract: a lookup the source answered is one `lookups`.
213
+ meter: { feature: 'lookups', when: (output) => output.verification === 'source_report' },
214
+ ```
215
+
216
+ - `when(output, input)` says whether this answer is billable, every success when omitted; `value(output,
217
+ input)` gives its units, 1 by default; `properties(output, input)` its labels, ids and short codes alone.
218
+ - The fact is reported for `principal.organizationId`, after the answer, once, over HTTP, MCP, RPC and as a
219
+ task. A failure reports nothing, and a report that fails is logged and never fails the call.
220
+ - What happens inside the work is the handler's own call to the same binding: a cost paid on the way, whether
221
+ or not the call then succeeds, `background?.waitUntil(env.BILLING.reportUsage(principal.organizationId,
222
+ { feature: 'provider_cost', value: cost }))`, and a check before spending, `env.BILLING.canSpend(…)`.
223
+
224
+ See [Metering](https://github.com/getarbol/maximus/blob/main/docs/guides/metering.md).
225
+
204
226
  ## Tools only agents call
205
227
 
206
228
  A file of `mcp/tools/`, named in kebab-case, default-exports `defineTool(handler, contract)`:
@@ -9,7 +9,7 @@ one organization never reaches another's data, how it handles other services' fa
9
9
  - `bun run test`: `vp test run`, in Node. `vp test` prepares the project as `vp dev` does, and leaves
10
10
  Cloudflare's plugin out.
11
11
  - `bun run typecheck`: `maximus prepare && tsc`, which checks the type tests; `vp test run` does not.
12
- - `bun run verify`: types, lint and format, tests and the build.
12
+ - `bun run verify` checks types, lint and format, and builds.
13
13
 
14
14
  ## Call the API
15
15
 
@@ -2,7 +2,22 @@ name: Verify and deploy
2
2
  on:
3
3
  push:
4
4
  branches: [main]
5
+ paths-ignore: &documentation
6
+ - '**/*.md'
7
+ - '**/*.mdx'
8
+ - '**/*.rst'
9
+ - '**/*.txt'
10
+ - '**/LICENSE'
11
+ - '**/LICENSE.*'
12
+ - '**/NOTICE'
13
+ - '**/NOTICE.*'
14
+ - .github/ISSUE_TEMPLATE/**
15
+ - .github/PULL_REQUEST_TEMPLATE/**
16
+ - .github/PULL_REQUEST_TEMPLATE
17
+ - .github/CODEOWNERS
5
18
  pull_request:
19
+ paths-ignore: *documentation
20
+ types: [opened, synchronize, reopened, ready_for_review, converted_to_draft, edited, labeled, unlabeled]
6
21
  workflow_dispatch:
7
22
  permissions:
8
23
  contents: read
@@ -11,6 +26,12 @@ concurrency:
11
26
  cancel-in-progress: false
12
27
  jobs:
13
28
  deploy:
29
+ if: >-
30
+ github.event_name != 'pull_request' || (!github.event.pull_request.draft
31
+ && !startsWith(github.event.pull_request.title, 'WIP') && !startsWith(github.event.pull_request.title, '[WIP]')
32
+ && !contains(github.event.pull_request.labels.*.name, 'wip')
33
+ && !contains(github.event.pull_request.labels.*.name, 'work-in-progress')
34
+ && !contains(github.event.pull_request.labels.*.name, 'status: wip'))
14
35
  runs-on: ubuntu-latest
15
36
  timeout-minutes: 15
16
37
  env:
@@ -26,9 +47,9 @@ jobs:
26
47
  # Bun runs every command; Vite+ and Cloudflare's local runtime run on Node.js underneath.
27
48
  - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
28
49
  with:
29
- node-version: '24'
50
+ node-version: '24.22.x'
30
51
  - run: bun install --frozen-lockfile --ignore-scripts
31
- # Types, lint and format, the tests and the build.
52
+ # Types, lint, format and the build.
32
53
  - run: bun run verify
33
54
  - run: bunx cf deploy --prebuilt --mode production --dry-run
34
55
  - name: Deploy main
@@ -47,7 +47,7 @@ of tokens.issuer, so set it to the real authorization server before deploying.
47
47
  ## Workflows
48
48
 
49
49
  `bun run dev` runs the Worker locally and `bun run test` runs the tests. `bun run verify` runs type
50
- generation, TypeScript, lint and format, the tests and the build; CI runs it on every pull request. Use
50
+ generation, TypeScript, lint and format, and the build. CI runs it on ready pull requests with code changes. Use
51
51
  `cf` for Cloudflare: discover commands with `cf cli search` and inspect a command's API request with
52
52
  `cf schema` before running it. Deploy with `bun run deploy` or the GitHub workflow. Preserve unrelated work
53
53
  and Git identity configuration, and add no assistant attribution to commits.
@@ -40,8 +40,8 @@ maps every file and folder a project can hold.
40
40
 
41
41
  ## Test, verify and deploy
42
42
 
43
- `bun run test` runs the tests in `tests/` in Node, and `bun run verify` runs the types, lint and format,
44
- the tests and the build. Before the first deployment, set `origin` in `vite.config.ts` to the Worker's
43
+ `bun run test` runs the tests in `tests/` in Node. `bun run verify` checks types, lint and format, and
44
+ builds the Worker. Before the first deployment, set `origin` in `vite.config.ts` to the Worker's
45
45
  HTTPS URL (its workers.dev URL or a custom domain you own) and `tokens.issuer` to your authorization server.
46
46
  Then:
47
47
 
@@ -50,6 +50,6 @@ bunx cf auth login
50
50
  bun run deploy
51
51
  ```
52
52
 
53
- The GitHub workflow verifies every pull request and deploys `main`, given the repository secrets
53
+ The GitHub workflow verifies ready pull requests with code changes and deploys `main`, given the repository secrets
54
54
  `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`. The
55
55
  [Maximus documentation](https://github.com/getarbol/maximus/blob/main/docs/README.md) covers the rest.
@@ -16,31 +16,31 @@
16
16
  "typecheck": "maximus prepare && tsc",
17
17
  "check": "vp check",
18
18
  "fix": "vp check --fix",
19
- "verify": "bun run typecheck && bun run check && bun run test && bun run build",
19
+ "verify": "bun run typecheck && bun run check && bun run build",
20
20
  "deploy": "bun run verify && cf deploy --prebuilt --mode production"
21
21
  },
22
22
  "dependencies": {
23
23
  "@arbol-ai/maximus": "__MAXIMUS_VERSION__"
24
24
  },
25
25
  "devDependencies": {
26
- "@cloudflare/vite-plugin": "2.0.0-beta.v.5",
27
- "@cloudflare/workers-types": "5.20261027.1",
28
- "@types/node": "26.6.5",
29
- "cf": "1.0.0-beta.23",
30
- "oxfmt": "0.74.0",
31
- "oxlint": "1.89.0",
26
+ "@cloudflare/vite-plugin": "2.0.0-rc.5",
27
+ "@cloudflare/workers-types": "5.20261125.1",
28
+ "@types/node": "26.6.11",
29
+ "cf": "1.0.0-rc.6",
30
+ "oxfmt": "0.80.0",
31
+ "oxlint": "1.95.0",
32
32
  "typescript": "7.0.2",
33
- "ultracite": "8.1.0",
34
- "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
35
- "vite-plus": "1.4.0"
33
+ "ultracite": "8.3.1",
34
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
35
+ "vite-plus": "1.8.0"
36
36
  },
37
37
  "overrides": {
38
- "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
39
- "vitest": "5.0.5"
38
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
39
+ "vitest": "5.1.1"
40
40
  },
41
41
  "engines": {
42
42
  "bun": ">=1.4.4",
43
- "node": ">=22.18"
43
+ "node": "^22.23.0 || ^24.22.0 || ^26.12.0"
44
44
  },
45
45
  "packageManager": "bun@1.4.4"
46
46
  }