@arbol-ai/maximus 7.3.1 → 8.0.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 (138) hide show
  1. package/README.md +36 -38
  2. package/bin/maximus.js +4 -0
  3. package/config/oxfmt.mjs +1 -0
  4. package/config/oxlint.mjs +10 -0
  5. package/dist/analytics/analytics.d.ts +21 -9
  6. package/dist/analytics/analytics.js +19 -5
  7. package/dist/body.d.ts +1 -1
  8. package/dist/body.js +2 -2
  9. package/dist/chunks/agent-skills-Ef65jTf_.js +49 -0
  10. package/dist/chunks/agent-skills-m7y1EUch.js +3 -0
  11. package/dist/chunks/{body-6LichrQm.js → body-DOIHwIIl.js} +14 -7
  12. package/dist/chunks/{correlation-BEkcFFGT.js → correlation-4b23a-a4.js} +8 -5
  13. package/dist/chunks/define-app-CfVZBt7D.js +336 -0
  14. package/dist/chunks/errors-WfyKhiyk.js +131 -0
  15. package/dist/chunks/execution-CfZEx_JP.js +84 -0
  16. package/dist/chunks/generate-C-9FKW0o.js +197 -0
  17. package/dist/chunks/handler-DWTGoduQ.js +140 -0
  18. package/dist/chunks/http-layout-_h7xwgPC.js +128 -0
  19. package/dist/chunks/http-paths-DMBxwpp6.js +218 -0
  20. package/dist/chunks/{json-Bu4BLT25.js → json-B14evE6-.js} +21 -5
  21. package/dist/chunks/names-ncD7A3DV.js +280 -0
  22. package/dist/chunks/openapi-CV0KmJpS.js +1588 -0
  23. package/dist/chunks/openapi-file-OjSs9mRv.js +83 -0
  24. package/dist/chunks/pages-DyC0m8Zb.js +14 -0
  25. package/dist/chunks/prepare-configured-BmRJLg6J.js +3 -0
  26. package/dist/chunks/prepare-configured-Cithjf80.js +52 -0
  27. package/dist/chunks/project-files-C0OX7MQQ.js +130 -0
  28. package/dist/chunks/query-kind-CWKAXEME.js +40 -0
  29. package/dist/chunks/record-DQUDTpEA.js +10 -0
  30. package/dist/chunks/result-CKgZHrnj.js +56 -0
  31. package/dist/chunks/{runtime-BPnaa-NK.js → runtime-CVVf5hmp.js} +50 -25
  32. package/dist/chunks/scaffold-DGrcjR3h.js +3 -0
  33. package/dist/chunks/scaffold-DZD6dfoZ.js +138 -0
  34. package/dist/chunks/{schemas-CzTvbXb6.js → schemas-p_aRcMC1.js} +30 -14
  35. package/dist/chunks/server-CCc7fil4.js +410 -0
  36. package/dist/chunks/src--HZrH1U9.js +568 -0
  37. package/dist/chunks/standard-failures-CLjxS2ea.js +74 -0
  38. package/dist/chunks/{telemetry-BTwB68m5.js → telemetry-C3LfZcOB.js} +32 -11
  39. package/dist/chunks/{types-BWxDd3tY.d.ts → types-BQYB4Ads.d.ts} +998 -337
  40. package/dist/chunks/{validation-r-sgmsqb.js → validation-fTohBT6R.js} +69 -28
  41. package/dist/chunks/workers-types-iONp32T4.d.ts +143 -0
  42. package/dist/chunks/yaml-Dk2L24yQ.js +74 -0
  43. package/dist/diagnostics.d.ts +6 -4
  44. package/dist/diagnostics.js +2 -2
  45. package/dist/errors.d.ts +2 -2
  46. package/dist/errors.js +2 -125
  47. package/dist/http-paths.d.ts +1 -1
  48. package/dist/http-paths.js +1 -197
  49. package/dist/index.d.ts +2 -2
  50. package/dist/index.js +12 -10
  51. package/dist/internals.d.ts +1 -1
  52. package/dist/internals.js +5 -3
  53. package/dist/mcp/index.d.ts +3 -2
  54. package/dist/mcp/index.js +5 -387
  55. package/dist/postgres/index.d.ts +25 -8
  56. package/dist/postgres/index.js +17 -8
  57. package/dist/project/config.d.ts +139 -0
  58. package/dist/project/config.js +196 -0
  59. package/dist/project/index.d.ts +17 -4
  60. package/dist/project/index.js +44 -9
  61. package/dist/projection.d.ts +14 -13
  62. package/dist/projection.js +8 -32
  63. package/dist/schemas.d.ts +1 -1
  64. package/dist/schemas.js +2 -2
  65. package/dist/standard-failures.d.ts +2 -89
  66. package/dist/standard-failures.js +1 -72
  67. package/dist/tooling/cli.js +151 -107
  68. package/dist/tooling/testing.js +2 -2
  69. package/dist/vite/cloudflare-workers.js +25 -0
  70. package/dist/vite/index.d.ts +157 -0
  71. package/dist/vite/index.js +1477 -0
  72. package/dist/webhooks.d.ts +12 -10
  73. package/dist/webhooks.js +26 -12
  74. package/dist/workers/runtime.d.ts +1 -1
  75. package/dist/workers/runtime.js +1 -1
  76. package/package.json +30 -22
  77. package/skills/maximus/SKILL.md +165 -69
  78. package/skills/maximus/references/deploying.md +73 -0
  79. package/skills/maximus/references/errors-and-results.md +114 -55
  80. package/skills/maximus/references/project.md +202 -0
  81. package/skills/maximus/references/routes-and-tools.md +256 -0
  82. package/skills/maximus/references/testing.md +137 -50
  83. package/skills/maximus/references/transports.md +113 -100
  84. package/skills/maximus/references/writing-code.md +84 -0
  85. package/templates/mcp/mcp/instructions.md.template +2 -0
  86. package/templates/mcp/routes/v1/greeting.get.ts.template +12 -0
  87. package/templates/mcp/tests/mcp.test.ts.template +36 -0
  88. package/templates/project/.agents/skills/project/SKILL.md.template +21 -12
  89. package/templates/project/.github/workflows/ci.yml.template +4 -1
  90. package/templates/project/CLAUDE.md.template +41 -22
  91. package/templates/project/README.md.template +54 -47
  92. package/templates/project/middleware/10-response.ts.template +16 -0
  93. package/templates/project/package.json.template +16 -8
  94. package/templates/project/pages/index.ts.template +2 -4
  95. package/templates/project/routes/v1/greeting.get.ts.template +10 -0
  96. package/templates/project/routes/v1/greeting.post.ts.template +12 -0
  97. package/templates/project/tests/greeting.test.ts.template +45 -0
  98. package/templates/project/tsconfig.json.template +8 -5
  99. package/templates/project/vite.config.ts.template +15 -7
  100. package/templates/web/app/main.tsx.template +16 -0
  101. package/templates/web/app/root.tsx.template +17 -0
  102. package/templates/web/app/routes/index.tsx.template +9 -0
  103. package/templates/web/index.html.template +12 -0
  104. package/templates/web/package.json.template +12 -0
  105. package/templates/web/tsconfig.json.template +7 -0
  106. package/templates/web/vite.config.ts.template +22 -0
  107. package/dist/chunks/execution-B-yy4C7N.js +0 -691
  108. package/dist/chunks/prepare-project-zi106pWF.js +0 -146
  109. package/dist/chunks/record-DY-lX9w1.js +0 -34
  110. package/dist/chunks/src-DPSpGNnT.js +0 -1164
  111. package/dist/client/client.d.ts +0 -129
  112. package/dist/client/client.js +0 -321
  113. package/dist/tooling/vite.d.ts +0 -3
  114. package/dist/tooling/vite.js +0 -44
  115. package/skills/maximus/references/adding-an-operation.md +0 -179
  116. package/skills/maximus/references/building-a-service.md +0 -167
  117. package/skills/maximus/references/migration-from-v2.md +0 -62
  118. package/skills/maximus/references/migration-to-v5.md +0 -37
  119. package/skills/maximus/references/publishing-and-verification.md +0 -39
  120. package/templates/project/cloudflare.config.ts.template +0 -24
  121. package/templates/project/routes/v1/greeting.ts.template +0 -22
  122. package/templates/project/src/app.ts.template +0 -2
  123. package/templates/project/src/application.ts.template +0 -26
  124. package/templates/project/src/index.ts.template +0 -3
  125. package/templates/project/src/worker.ts.template +0 -6
  126. package/templates/service/.agents/skills/project/SKILL.md.template +0 -10
  127. package/templates/service/.github/workflows/ci.yml.template +0 -21
  128. package/templates/service/.gitignore.template +0 -9
  129. package/templates/service/CLAUDE.md.template +0 -5
  130. package/templates/service/README.md.template +0 -45
  131. package/templates/service/cloudflare.config.ts.template +0 -30
  132. package/templates/service/package.json.template +0 -36
  133. package/templates/service/src/app.ts.template +0 -30
  134. package/templates/service/src/index.ts.template +0 -13
  135. package/templates/service/tests/contract.test.ts.template +0 -12
  136. package/templates/service/tsconfig.json.template +0 -16
  137. package/templates/service/vite.config.ts.template +0 -13
  138. package/templates/service/vitest.config.ts.template +0 -10
@@ -1,167 +0,0 @@
1
- # Building a service
2
-
3
- For optional file conventions, use `maximus init <directory> --name <name> --layout project`.
4
- `routes/` factories receive their versioned file path and return builders derived from
5
- `src/application.ts`; `pages/` returns public native Responses. Middleware runs after authorization.
6
- Cron, queue, email and Durable Object modules are discovered into ignored `.maximus/` imports by
7
- `maximus prepare` and `maximusProject()` from `@arbol-ai/maximus/vite`. Configure infrastructure
8
- explicitly in `cloudflare.config.ts`. Read `docs/guides/project-structure.md` in the Maximus repository
9
- for conventions and boundaries. The generated project uses non-test validation and automatic
10
- deployment on main; production API authentication initially refuses every token.
11
-
12
- ## Packages
13
-
14
- ```sh
15
- bun add @arbol-ai/maximus # everything: /workers, /mcp, /client, the maximus CLI, …
16
- bun add -d cf vite @cloudflare/vite-plugin@beta typescript @cloudflare/workers-types
17
- ```
18
-
19
- ## Layout
20
-
21
- ```text
22
- src/
23
- application.ts export const base = maximus<Env>({ ... })
24
- tokens.ts the TokenPolicy (issuer, audience, optional resolve)
25
- env.ts Env: the bindings, typed by the narrow interfaces the code uses
26
- api/<resource>/
27
- schemas.ts TypeBox schemas
28
- <resource>.ts named domain functions
29
- operations.ts export const <resource> = base.operation(...)...
30
- app.ts export const app = base.mount(a).mount(b).build() (no cloudflare:workers import)
31
- index.ts createWorker(app, ...) and the exports
32
- cloudflare.config.ts the Worker for cf: name, runtime, entrypoint, bindings, triggers, exports
33
- vite.config.ts cloudflare() from @cloudflare/vite-plugin, which cf builds and runs with
34
- ```
35
-
36
- `app.ts` must stay importable outside workerd so tests and scripts can load it.
37
-
38
- ## Configuration
39
-
40
- ```ts
41
- import { defineErrors, maximus } from '@arbol-ai/maximus';
42
-
43
- export const errors = defineErrors({
44
- noteNotFound: { code: 'NOTE_NOT_FOUND', status: 404, message: 'The note does not exist.' },
45
- });
46
-
47
- export const base = maximus<Env>({
48
- name: 'notes', // lowercase; health, MCP server name, telemetry
49
- namespace: 'notes', // ^[a-z][a-z0-9-]{1,63}$, prefixes every scope
50
- title: 'Notes',
51
- version: '1.0.0',
52
- origin: 'https://notes.example.com', // must be https:, the public URL
53
- tokens: { issuer: 'https://auth.example.com/', audience: 'https://notes.example.com' },
54
- errors,
55
- rpc: { callers: [] }, // deployments allowed over native RPC
56
- // optional: mcp, telemetry, rateLimit, maxBodyBytes, maxOutputBytes
57
- });
58
- ```
59
-
60
- - `tokens.issuer` has no default. Without it the app builds, but OAuth tokens are refused and
61
- `/openapi.json` answers 500.
62
- - `mcp` configuration requires `transports: [mcp()]` in `createWorker`, or the Worker fails to start.
63
-
64
- ## Tokens
65
-
66
- Default: OAuth access tokens from any provider, RS256 (or `tokens.algorithms`) from
67
- `<issuer>.well-known/jwks.json` (or `tokens.jwksUri`), exact issuer and audience (`tokens.audience`
68
- may list several, any one accepted; the first is the discovery `resource`). Standard claims: `sub`
69
- (actor; `<client>@clients` is a machine), `org_id` (required; 1-128 letters, digits, `_`, `-`),
70
- `azp`/`client_id` (optional), `scope`; a person holds only the scopes their `permissions` claim also
71
- lists, none without it (Auth0 with RBAC and permissions in the token). `tokens.claims` maps providers
72
- that name them differently: `{ scopes: 'scp', client: 'cid', permissions: false, machineSubject:
73
- '{client}' }` (Okta), `{ scopes: 'permissions' }` (WorkOS session tokens). Set `permissions: false`
74
- only when the authorization server grants each person no more than they may hold, and
75
- `machineSubject: '{client}'` only when it assigns every client id. OpenAPI's OAuth flows use
76
- `tokens.authorizationEndpoint` and `tokens.tokenEndpoint` (Auth0's `authorize` and `oauth/token` by
77
- default); for other providers copy them and `jwksUri` from the server's
78
- `/.well-known/oauth-authorization-server` metadata.
79
-
80
- Other credentials: `tokens.resolve(token, context)` verifies cryptographically and returns a
81
- `TokenPrincipal` (`{ actorId, actorKind, organizationId, scopes, client? }`) or a `Result`
82
- (`FORBIDDEN` → 403, any other failure or a throw → 401). `context` has `env`, `request`, `surface`,
83
- `applicationScopes`, `background`. Return a `client` so calls carry `authority`.
84
-
85
- `tokens.scheme`: `{ type: 'bearer', description }` for application-issued tokens (needs `resolve`, no
86
- OAuth discovery, cannot mount MCP); `{ type: 'oauth+bearer', description }` for OAuth people plus
87
- resolver-verified workload keys (every operation in the OpenAPI document declares `actorKinds`).
88
-
89
- Local development (`examples/minimal-http/src/tokens.ts`): `tokens.development: { binding:
90
- 'DEVELOPMENT_TOKEN' }` accepts that token, at least 32 characters, from `.dev.vars` only from
91
- `localhost`/`127.0.0.1`/`[::1]`, as `local-developer` holding every declared scope; every other token is
92
- verified as usual. Never write that resolver by hand.
93
-
94
- ## Env
95
-
96
- Type bindings by what the code uses, so tests can fake them without casts:
97
-
98
- ```ts
99
- export interface NoteStore {
100
- get: (key: string) => Promise<string | null>;
101
- put: (key: string, value: string) => Promise<void>;
102
- }
103
- export interface Env {
104
- NOTES: NoteStore; // a KVNamespace satisfies it
105
- PRICING: Service<typeof PricingService>; // RPC binding typed from the owner's entrypoint
106
- }
107
- ```
108
-
109
- ## The Worker
110
-
111
- ```ts
112
- import { mcp } from '@arbol-ai/maximus/mcp';
113
- import { createWorker } from '@arbol-ai/maximus/workers';
114
-
115
- import { app } from './app';
116
-
117
- const worker = createWorker(app, {
118
- transports: [mcp()], // serves the MCP tools; required by app mcp configuration
119
- // routes, http: { basePath, origins, mounts, before, aroundOperation, fallback, healthPath },
120
- // assets, handlers: { scheduled, queue }
121
- });
122
-
123
- export default worker.handler;
124
- export const NotesService = worker.entrypoint; // if any operation declares rpc
125
- ```
126
-
127
- ## cloudflare.config.ts
128
-
129
- ```ts
130
- import { bindings, defineConfig } from 'cf/config';
131
-
132
- import * as entrypoint from './src/index.ts' with { type: 'cf-worker' };
133
-
134
- export default defineConfig(({ mode }) => ({
135
- worker: {
136
- name: 'notes',
137
- compatibilityDate: '2026-10-12',
138
- compatibilityFlags: ['nodejs_compat'], // required: node:async_hooks
139
- entrypoint,
140
- observability: { enabled: true },
141
- env: {
142
- NOTES: bindings.kv(), // no id: cf deploy provisions it
143
- DEVELOPMENT_TOKEN: mode === 'development' && bindings.secret(), // cf dev only, from .dev.vars
144
- },
145
- },
146
- }));
147
- ```
148
-
149
- `cf` is in beta and needs Node 22+. Wrangler files are not read: convert one with `cf migrate`.
150
-
151
- ## Run locally
152
-
153
- ```sh
154
- echo "DEVELOPMENT_TOKEN=$(openssl rand -hex 32)" > .dev.vars
155
- bunx cf dev # Vite on http://localhost:5173
156
- curl -s http://localhost:5173/health
157
- curl -s http://localhost:5173/openapi.json
158
- curl -s http://localhost:5173/v1/notes -H "authorization: Bearer $(sed 's/^DEVELOPMENT_TOKEN=//' .dev.vars)"
159
- ```
160
-
161
- Several Workers together: the caller's `vite.config.ts` runs the others as auxiliary Workers,
162
- `cloudflare({ auxiliaryWorkers: [{ config: otherWorker, devOnly: true }] })`.
163
-
164
- ## Native endpoints (served automatically)
165
-
166
- `/` (name, OpenAPI path, MCP path), `/health`, `/openapi.json`, `/openapi.yaml`, `/openapi.yml`,
167
- `/.well-known/oauth-protected-resource` and `…/mcp`. They are reserved paths.
@@ -1,62 +0,0 @@
1
- # Migrating from 2.x
2
-
3
- Move every `@getarbol/maximus*` dependency to the same 3.x version together.
4
- (`@getarbol/maximus-postgres` is versioned on its own and unaffected.) Signed admission, unsigned
5
- delegation and the service artifact below describe 3.x and 4.x; 5.0 removed them (see
6
- `migration-to-v5.md`).
7
-
8
- ## Breaking changes in 3.0.0
9
-
10
- | Area | 2.x | 3.x | Do |
11
- | --- | --- | --- | --- |
12
- | Issuer | `tokens.issuer` had a built-in default | No default | Set `tokens.issuer` everywhere OAuth tokens are verified or documented. Missing → every OAuth token is 401 and `/openapi.json` is 500. |
13
- | Proof type | `arbol-admission+jwt` | `maximus-admission+jwt` | Release signer and all owners together. |
14
- | OpenAPI extensions | `x-arbol-service-id`, `-publication`, `-publish`, `-input-schema`, `-actor-kinds` | `x-maximus-…` | Update readers of classified documents. |
15
- | Security schemes | `arbolToken`, `arbolHuman`, `arbolMachine` | `oauth2`, `bearer` | Update clients and generators. |
16
- | Service owner | `'arbol'` | `'platform'` | Replace in `service.owner`. |
17
- | `maximus token` | `ARBOL_CLIENT_ID`, `ARBOL_CLIENT_SECRET`, `ARBOL_ISSUER` | `--issuer` (required), `MAXIMUS_CLIENT_ID`, `MAXIMUS_CLIENT_SECRET` | Removed in 4.0: drop it from operator scripts. |
18
-
19
- ## Notable 3.x additions
20
-
21
- - 3.1.0: `@getarbol/maximus/projection`, `callAdmitted`, admission service schemas, `OUTCOME_UNKNOWN`.
22
- - 3.2.0: `checkSchema`, `readSchema`.
23
- - 3.3.0: `INVALID_INPUT` carries `data.issues` everywhere; clients expecting `data: {}` must accept it.
24
- - 3.3.1: plain routes beneath a transport path.
25
- - 3.4.0: `admission.attachments`; `describe` for an internal runtime's agent.
26
- - 3.4.1: `callAdmitted` fixed for real Service Binding stubs; upgrade dispatchers from 3.4.0.
27
- - 3.5.0: runtime-free `@getarbol/maximus/admitted` and `@getarbol/maximus/failures`.
28
- - 3.6.0: `.build()` refuses a missing or non-HTTPS `tokens.issuer` and input codecs outside
29
- `inputSchema()`.
30
-
31
- ## Classifying an unclassified (pre-2.13) service
32
-
33
- 1. `publication: 'private' | 'selected'`.
34
- 2. `publish: { rest, mcp }` on every operation (`true` only with the transport declared, never for
35
- internal operations or in a private service).
36
- 3. `actorKinds` on every operation.
37
- 4. `api: { resource, verb, id? }` on every published or admitted operation.
38
- 5. `service: { kind, owner, publicName?, dependencies?, connections?, roles? }`.
39
- 6. `bun --bun maximus check`, then `bun --bun maximus export --allow-dirty --out artifact.json`.
40
-
41
- `.build()` names the next operation and rule to fix.
42
-
43
- ## Unsigned delegation → signed admission
44
-
45
- | | Before | After |
46
- | --- | --- | --- |
47
- | Operation | `delegated: { surfaces, actorKinds, clientClasses }` | `admission: { callers, ingresses }`, `actorKinds` |
48
- | Application | `delegation: { authorize(env, grant) }` | `admission: { verification, authorize }` |
49
- | Props | `{ caller: 'gateway', mode: 'delegated' }` | `{ caller: '<dispatcher>', mode: 'admitted' }` |
50
-
51
- Same `worker.delegatedEntrypoint`. Unsigned grants are refused once `publication` is set.
52
-
53
- ## From 1.x
54
-
55
- Explicit packages instead of Elysia/Eden; one fluent base with mounted resource modules; opt-in MCP
56
- and telemetry; remove `Function` test shims; check consumers' RPC types against `Service<T>` with a
57
- `never` control; keep Durable Object class names, migration tags and durable keys.
58
-
59
- ## Verify
60
-
61
- Typecheck, tests, dry-run bundle, `maximus check` for classified services, then verify the deployed
62
- Worker (health, OpenAPI, a 401 without token, a real call).
@@ -1,37 +0,0 @@
1
- # Migrating to 5.0
2
-
3
- The platform Gateway is a proxy to each service's own origin; services call each other over native
4
- RPC. 5.0 removes what nothing calls anymore. TypeScript names each removed option that remains.
5
-
6
- ## Remove from the application
7
-
8
- - `gateway: { audience, issuer, … }`: list the platform audience in `tokens.audience` instead
9
- (`[OWN, PLATFORM]`); the origin verifies the forwarded token like any other. Move rules that
10
- `gateway.authorize` applied into context or middleware.
11
- - `originRoutes`: a selected service's origin serves and documents every declared route (as
12
- `'declared'` did). With `'none'` it now also serves `/`, `/openapi.json` and `/health`; a web app
13
- that needs `/` sets `http.basePath`.
14
- - `contract`, `admission`, `delegation`.
15
- - `service.kind`, `service.owner`, `service.dependencies`, `service.connections` (keep
16
- `publicName`, `permissions`, `roles`).
17
- - On operations: `admission`, `delegated`, `resourceSlots`, `execution`.
18
-
19
- ## Remove from the Worker
20
-
21
- - `worker.delegatedEntrypoint` and its export (and the export declared in `cloudflare.config.ts` or
22
- Wrangler), and bindings with props `mode: 'token' | 'admitted' | 'delegated'`.
23
- - `maximus publish`, `maximus export`, `maximus permissions` steps in CI.
24
-
25
- ## Imports
26
-
27
- - `isResult`: from `@getarbol/maximus` (was `/admitted`).
28
- - Gone: `/admitted` (`callAdmitted`), `/delegation` (everything), `exportServiceContract`,
29
- `ContractBuild`, `gatewayServes`, `GatewayPolicy`, `GatewayCall`, `OriginRoutes`, and from
30
- `/projection` `publicName`, `cliCommand`, `restRoute`, `encodeQuery`, `decodeQuery`.
31
- - `originServes(publication, operation, surface)` lost its `originRoutes` argument.
32
- - `authority.admission` is gone; `authority.token` remains.
33
-
34
- ## OpenAPI
35
-
36
- `x-maximus-gateway`, `x-maximus-failures` and `x-maximus-service.kind` are gone; `x-maximus-tokens:
37
- { issuer, audiences }` names whose tokens the service verifies. The `artifact` projection is gone.
@@ -1,39 +0,0 @@
1
- # Deploying and verifying
2
-
3
- ## A new service (`@arbol-ai/maximus`)
4
-
5
- One command, `bunx @arbol-ai/maximus init <dir> --name <name>`: a starter project on the CLI's own
6
- release, scripted with `cf`; it passes `bun run verify` as generated. Replace the placeholder origin,
7
- audience and issuer in `src/app.ts` before deploying. Develop, build and deploy with `cf dev`,
8
- `cf build`, `cf workers types` and `cf deploy`: Maximus does not wrap them.
9
-
10
- `createOpenApi(app)` builds the document the origin serves at `/openapi.json`, for SDKs or a contract
11
- check at build time. Nothing is published from the service: deploying it is the release.
12
-
13
- ## Before deploying
14
-
15
- ```sh
16
- bun run typecheck # cf build does not typecheck
17
- bun run test
18
- cf build # then read .cloudflare/output/v0/workers/default/worker.config.json: no dev token
19
- cf deploy --prebuilt --mode production # --dry-run first; cf auth login or CLOUDFLARE_API_TOKEN
20
- ```
21
-
22
- `nodejs_compat` on; secrets as `bindings.secret()`, uploaded with `cf deploy --secrets-file` or kept
23
- in Secrets Store, never in `bindings.text()`; `.dev.vars` local only, and the development token
24
- declared for `cf dev` alone; Durable Object class names unchanged and declared as exports; preview
25
- environments use their own audience, state and credentials.
26
-
27
- ## After deploying
28
-
29
- Verify the real Worker: `/health` version; `/openapi.json` operations (`verifyContract`); `401`
30
- without a token; a real token call for a test organization; MCP `tools/list`;
31
- RPC calls through a real caller. Keep tokens and raw responses in an ignored `.private/`
32
- (0700/0600) and never print sensitive bodies to shared logs. Mocks are never evidence of a live
33
- deployment.
34
-
35
- ## Releasing Maximus itself (framework repository)
36
-
37
- `bun run verify` (build, typecheck, lint, tests, packed-package and isolation checks), packages in
38
- dependency order from packed tarballs, never with `workspace:` or `file:` dependencies; then install
39
- from the registry, run consumers' workerd tests and dry bundles, and verify a real deployment.
@@ -1,24 +0,0 @@
1
- import { bindings, defineConfig } from 'cf/config';
2
-
3
- import * as entrypoint from './src/index.ts' with { type: 'cf-worker' };
4
-
5
- export default defineConfig(({ mode }) => ({
6
- worker: {
7
- name: '__PROJECT_NAME__',
8
- compatibilityDate: '__COMPATIBILITY_DATE__',
9
- // Maximus keeps request diagnostics in AsyncLocalStorage.
10
- compatibilityFlags: ['nodejs_compat'],
11
- entrypoint,
12
- workersDev: true,
13
- previewUrls: false,
14
- observability: {
15
- enabled: true,
16
- redactQueryString: true,
17
- logs: { enabled: true, invocationLogs: true },
18
- traces: { enabled: true },
19
- },
20
- env: {
21
- DEVELOPMENT_TOKEN: mode === 'development' && bindings.secret(),
22
- },
23
- },
24
- }));
@@ -1,22 +0,0 @@
1
- import { EmptyInputSchema, ok, t } from '@arbol-ai/maximus';
2
-
3
- import { base } from '../../src/application';
4
-
5
- const GreetingSchema = t.Object({ message: t.String() }, { $id: 'Greeting', additionalProperties: false });
6
-
7
- /** The filename supplies the versioned path; Maximus still owns admission and schema validation. */
8
- export default function greeting(path: string) {
9
- return base.operation(
10
- 'getGreeting',
11
- {
12
- title: 'Get a greeting',
13
- description: 'Return a greeting to an authenticated caller.',
14
- scope: '__PROJECT_NAME__:greeting:read',
15
- effect: 'read',
16
- http: { method: 'GET', path },
17
- input: EmptyInputSchema,
18
- output: GreetingSchema,
19
- },
20
- () => Promise.resolve(ok({ message: 'Hello World' }))
21
- );
22
- }
@@ -1,2 +0,0 @@
1
- /** Importable outside workerd; the generated composition retains every operation's inferred type. */
2
- export { app } from '../.maximus/app';
@@ -1,26 +0,0 @@
1
- import { defineErrors, err, maximus, standardErrors } from '@arbol-ai/maximus';
2
-
3
- import { middleware } from '../.maximus/middleware';
4
-
5
- let application = maximus<Env>({
6
- name: '__PROJECT_NAME__',
7
- namespace: '__PROJECT_NAME__',
8
- title: '__PROJECT_NAME__',
9
- version: '0.1.0',
10
- origin: 'https://__PROJECT_NAME__.example.com',
11
- tokens: {
12
- audience: 'https://__PROJECT_NAME__.example.com',
13
- scheme: { type: 'bearer', description: 'Production authentication has not been configured.' },
14
- // Fail closed until the application configures its identity provider or verified token resolver.
15
- resolve: () => Promise.resolve(err(standardErrors.unauthorized.create())),
16
- development: { binding: 'DEVELOPMENT_TOKEN' },
17
- },
18
- errors: defineErrors({}),
19
- rpc: { callers: [] },
20
- });
21
-
22
- /** All discovered operations share middleware that runs after native authentication and scope checks. */
23
- for (const handler of middleware) {
24
- application = application.use(handler);
25
- }
26
- export const base = application;
@@ -1,3 +0,0 @@
1
- export { default } from '../.maximus/worker';
2
- // oxlint-disable-next-line oxc/no-barrel-file -- Cloudflare requires every discovered class on its entrypoint.
3
- export * from '../.maximus/worker';
@@ -1,6 +0,0 @@
1
- import type { WorkerOptions } from '@arbol-ai/maximus/workers';
2
-
3
- /** Keep API ownership separate from public pages. Bindings and triggers belong in cloudflare.config.ts. */
4
- export const options: WorkerOptions<Env> = {
5
- http: { basePath: '/api', healthPath: '/health' },
6
- };
@@ -1,10 +0,0 @@
1
- ---
2
- name: __PROJECT_NAME__-development
3
- description: Add and verify operations in the __PROJECT_NAME__ service.
4
- ---
5
-
6
- Read CLAUDE.md and the Maximus skill at node_modules/@arbol-ai/maximus/skills/maximus/SKILL.md.
7
- Declare strict input/output, effect and scope in src/api/<resource>/operations.ts and mount the
8
- module in src/app.ts. Expose only the transports a caller needs (http, mcp, rpc). Keep upstream
9
- protocols and state in this project. Use @arbol-ai/maximus/testing for the contract smoke and add
10
- domain tests for the risks unique to this service.
@@ -1,21 +0,0 @@
1
- name: Verify
2
- on: [push, pull_request]
3
- permissions:
4
- contents: read
5
- packages: read
6
- jobs:
7
- verify:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/checkout@v7
11
- - uses: oven-sh/setup-bun@v2
12
- with:
13
- bun-version: 1.4.3
14
- # cf runs on Node 22 or later.
15
- - uses: actions/setup-node@v7
16
- with:
17
- node-version: 24
18
- - run: bun install --frozen-lockfile --ignore-scripts
19
- env:
20
- NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN || github.token }}
21
- - run: bun run verify
@@ -1,9 +0,0 @@
1
- node_modules/
2
- dist/
3
- .cloudflare/
4
- .wrangler/
5
- .env*
6
- .dev.vars*
7
- .private/
8
- coverage/
9
- .vite-plus/
@@ -1,5 +0,0 @@
1
- # Agent guide
2
-
3
- Read .agents/skills/project/SKILL.md and the installed Maximus skill (node_modules/@arbol-ai/maximus/skills/maximus/SKILL.md). Code/docs are English. Use organizationId, strict schemas and namespaced scopes. Keep credentials and provider evidence in ignored .private/ (0700/0600). Add operations in resource modules; compose once in app.ts. Domain functions are shared with scripts. Tests own provider behavior, not framework JWT/protocol matrices. Run bun run verify. Never call live providers in CI. Configure audience, issuer, callers and deployment resources before release.
4
-
5
- The root vite.config.ts owns the Vite+ toolchain. Use vp dev, vp build and vp check. Tests require an explicit human request; verify and deployment do not run them.
@@ -1,45 +0,0 @@
1
- # `__PROJECT_NAME__`
2
-
3
- A [Maximus](https://github.com/getarbol/maximus) service on Cloudflare Workers. It
4
- declares each operation once and serves it over HTTP with its OpenAPI document, and, when an
5
- operation asks for them, as an MCP tool and a Worker RPC method.
6
-
7
- ## Before the first deployment
8
-
9
- `src/app.ts` uses placeholders: set `origin` to the service's public HTTPS origin, `tokens.audience`
10
- to the audience its access tokens carry and `tokens.issuer` to the authorization server that issues
11
- them. The starter declares no operation, so it serves only its discovery documents and `/health`.
12
-
13
- ## Run it locally
14
-
15
- `bun run dev` serves the Worker on `localhost` with `vp dev`. `maximus init` wrote a random development
16
- token to `.dev.vars`, which Git ignores and `cloudflare.config.ts` declares for `vp dev` alone, so no
17
- deployed build carries it. From `localhost` it is a developer holding every scope the service declares:
18
-
19
- ```sh
20
- TOKEN=$(sed 's/^DEVELOPMENT_TOKEN=//' .dev.vars)
21
- curl -H "authorization: Bearer $TOKEN" http://localhost:5173/v1/<your operation's route>
22
- ```
23
-
24
- ## Commands
25
-
26
- | Command | Runs |
27
- | ------------------------------- | -------------------------------------------------------------------------------------------- |
28
- | `bun install` | Installs the dependencies. |
29
- | `bun run dev` | The Worker locally, with `vp dev`. |
30
- | `bun run typecheck` | Generates the binding and runtime types with `cf workers types`, then TypeScript. |
31
- | `bun run check` / `bun run fix` | Vite+ lint and format with the Maximus presets. |
32
- | `bun run test` | The tests, in the Workers runtime. |
33
- | `bun run build` | `vp build`, which writes the build `cf deploy` uploads. |
34
- | `bun run verify` | Type generation, TypeScript, Vite+ lint/format and build; no tests. |
35
- | `bun run deploy` | `verify`, then deploys that same build with `cf deploy`. Sign in with `cf auth login` first. |
36
-
37
- ## Layout
38
-
39
- - `src/app.ts`: the application. Declare operations in resource modules
40
- (`src/api/<resource>/operations.ts`) that build on `base`, and mount each module here once.
41
- - `src/index.ts`: the Worker: its default export serves HTTP, and the named entrypoint serves RPC.
42
- - `tests/`: the contract smoke and the tests for what is specific to this service.
43
-
44
- Use synthetic data in tests, give previews their own resources and never point CI at production.
45
- Keep credentials and provider evidence out of the repository (`.private/` is ignored).
@@ -1,30 +0,0 @@
1
- /**
2
- * The Worker as `cf` develops, builds and deploys it: its name, runtime, entrypoint and bindings.
3
- */
4
- import { bindings, defineConfig } from 'cf/config';
5
-
6
- import * as entrypoint from './src/index.ts' with { type: 'cf-worker' };
7
-
8
- export default defineConfig(({ mode }) => ({
9
- worker: {
10
- name: '__PROJECT_NAME__',
11
- compatibilityDate: '2026-10-12',
12
- // Maximus keeps per-invocation diagnostics in AsyncLocalStorage (node:async_hooks).
13
- compatibilityFlags: ['nodejs_compat'],
14
- entrypoint,
15
- // A workers.dev URL or a preview URL would be one more origin for the same Worker.
16
- workersDev: false,
17
- previewUrls: false,
18
- observability: {
19
- enabled: true,
20
- redactQueryString: true,
21
- logs: { enabled: true, invocationLogs: true },
22
- traces: { enabled: true },
23
- },
24
- env: {
25
- // The development token `maximus init` wrote to .dev.vars, declared for `cf dev` alone: no build that
26
- // is deployed carries it.
27
- DEVELOPMENT_TOKEN: mode === 'development' && bindings.secret(),
28
- },
29
- },
30
- }));
@@ -1,36 +0,0 @@
1
- {
2
- "name": "__PROJECT_NAME__",
3
- "private": true,
4
- "type": "module",
5
- "scripts": {
6
- "dev": "vp dev",
7
- "typecheck": "cf workers types && tsc",
8
- "check": "vp check",
9
- "fix": "vp check --fix",
10
- "test": "vp test run",
11
- "build": "vp build",
12
- "verify": "bun run typecheck && bun run check && bun run build",
13
- "deploy": "bun run verify && cf deploy --prebuilt --mode production"
14
- },
15
- "dependencies": {
16
- "@arbol-ai/maximus": "__MAXIMUS_VERSION__"
17
- },
18
- "devDependencies": {
19
- "@cloudflare/vite-plugin": "^2.0.0-beta.v.1",
20
- "@cloudflare/vitest-plugin": "^1.4.4",
21
- "@types/node": "^26.6.5",
22
- "cf": "^1.0.0-beta.18",
23
- "oxfmt": "0.74.0",
24
- "oxlint": "1.89.0",
25
- "typescript": "^7.0.2",
26
- "ultracite": "^8.0.1",
27
- "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
28
- "vite-plus": "1.4.0",
29
- "vitest": "^5.0.5"
30
- },
31
- "overrides": {
32
- "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
33
- "vitest": "5.0.5"
34
- },
35
- "packageManager": "bun@1.4.3"
36
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * The service's application: its configuration, its error catalog and, as you add them, its operations.
3
- */
4
- import { defineErrors, maximus } from '@arbol-ai/maximus';
5
-
6
- /**
7
- * The service's one application. Set its public origin, the OAuth audience its tokens are issued for
8
- * and the authorization server that issues them before the first deployment.
9
- */
10
- export const base = maximus<Env>({
11
- name: '__PROJECT_NAME__',
12
- namespace: '__PROJECT_NAME__',
13
- title: '__PROJECT_NAME__',
14
- version: '0.1.0',
15
- origin: 'https://__PROJECT_NAME__.example.com',
16
- tokens: {
17
- audience: 'https://__PROJECT_NAME__.example.com',
18
- issuer: 'https://auth.example.com/',
19
- // From localhost only: the token `maximus init` wrote to `.dev.vars`, for `cf dev`.
20
- development: { binding: 'DEVELOPMENT_TOKEN' },
21
- },
22
- errors: defineErrors({}),
23
- rpc: { callers: [] },
24
- });
25
-
26
- /**
27
- * The checked application. Chain operations on `base`, or mount resource modules built on it, before
28
- * `.build()`.
29
- */
30
- export const app = base.build();
@@ -1,13 +0,0 @@
1
- /**
2
- * The service's Worker: its fetch handler and its RPC entrypoint.
3
- */
4
- import { createWorker } from '@arbol-ai/maximus/workers';
5
-
6
- import { app } from './app';
7
-
8
- /** The application as a Worker. */
9
- const worker = createWorker(app);
10
-
11
- /** The named RPC entrypoint other Workers bind to; its methods are the operations that declare `rpc`. */
12
- export const __ENTRYPOINT__ = worker.entrypoint;
13
- export default worker.handler;
@@ -1,12 +0,0 @@
1
- /**
2
- * The service's contract smoke test, against the Worker in workerd.
3
- */
4
- import { verifyContract } from '@arbol-ai/maximus/testing';
5
- import { exports } from 'cloudflare:workers';
6
- import { expect, it } from 'vite-plus/test';
7
-
8
- it('publishes one runtime contract', async () => {
9
- const contract = await verifyContract((request) => exports.default.fetch(request), 'https://example.test');
10
- // A new service publishes no paths yet; list them here as you add operations.
11
- expect(contract.paths).toEqual([]);
12
- });
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2024",
4
- "lib": ["ES2024"],
5
- "module": "preserve",
6
- "moduleResolution": "bundler",
7
- "types": ["node"],
8
- "strict": true,
9
- "noEmit": true,
10
- "allowImportingTsExtensions": true,
11
- "isolatedModules": true,
12
- "verbatimModuleSyntax": true,
13
- "skipLibCheck": true
14
- },
15
- "include": ["src", "tests", "cloudflare.config.ts", ".cloudflare/types"]
16
- }