@arbol-ai/maximus 0.0.0-stage → 7.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 (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -2
  3. package/config/oxfmt.d.mts +8 -0
  4. package/config/oxfmt.mjs +30 -0
  5. package/config/oxlint-plugin.mjs +41 -0
  6. package/config/oxlint.d.mts +8 -0
  7. package/config/oxlint.mjs +118 -0
  8. package/dist/analytics/analytics.d.ts +34 -0
  9. package/dist/analytics/analytics.js +62 -0
  10. package/dist/body.d.ts +2 -0
  11. package/dist/body.js +4 -0
  12. package/dist/chunks/body-BcMbreNd.js +106 -0
  13. package/dist/chunks/correlation-gaiEoMBr.js +45 -0
  14. package/dist/chunks/execution-qfZuMSIu.js +700 -0
  15. package/dist/chunks/json-Dwni3u4c.js +63 -0
  16. package/dist/chunks/record-D2H3cg8S.js +36 -0
  17. package/dist/chunks/schemas-q-51wBMQ.js +216 -0
  18. package/dist/chunks/src-Ph5KHCRP.js +1160 -0
  19. package/dist/chunks/telemetry-DvZgrzZn.js +220 -0
  20. package/dist/chunks/types-CGwAhnTE.d.ts +1630 -0
  21. package/dist/chunks/validation-DWxKk1Js.js +382 -0
  22. package/dist/client/client.d.ts +131 -0
  23. package/dist/client/client.js +325 -0
  24. package/dist/diagnostics.d.ts +41 -0
  25. package/dist/diagnostics.js +4 -0
  26. package/dist/errors.d.ts +2 -0
  27. package/dist/errors.js +128 -0
  28. package/dist/http-paths.d.ts +2 -0
  29. package/dist/http-paths.js +200 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +11 -0
  32. package/dist/internals.d.ts +2 -0
  33. package/dist/internals.js +5 -0
  34. package/dist/mcp/index.d.ts +12 -0
  35. package/dist/mcp/index.js +406 -0
  36. package/dist/postgres/index.d.ts +81 -0
  37. package/dist/postgres/index.js +140 -0
  38. package/dist/schemas.d.ts +2 -0
  39. package/dist/schemas.js +4 -0
  40. package/dist/standard-failures.d.ts +91 -0
  41. package/dist/standard-failures.js +75 -0
  42. package/dist/tooling/cli.js +110 -0
  43. package/dist/tooling/testing.d.ts +7 -0
  44. package/dist/tooling/testing.js +21 -0
  45. package/dist/webhooks.d.ts +69 -0
  46. package/dist/webhooks.js +162 -0
  47. package/dist/workers/runtime.d.ts +112 -0
  48. package/dist/workers/runtime.js +228 -0
  49. package/package.json +153 -4
  50. package/skills/maximus/SKILL.md +89 -0
  51. package/skills/maximus/references/adding-an-operation.md +179 -0
  52. package/skills/maximus/references/building-a-service.md +158 -0
  53. package/skills/maximus/references/errors-and-results.md +77 -0
  54. package/skills/maximus/references/migration-from-v2.md +62 -0
  55. package/skills/maximus/references/migration-to-v5.md +37 -0
  56. package/skills/maximus/references/publishing-and-verification.md +39 -0
  57. package/skills/maximus/references/testing.md +73 -0
  58. package/skills/maximus/references/transports.md +119 -0
  59. package/templates/service/.agents/skills/project/SKILL.md.template +10 -0
  60. package/templates/service/.github/workflows/ci.yml.template +21 -0
  61. package/templates/service/.gitignore.template +8 -0
  62. package/templates/service/CLAUDE.md.template +3 -0
  63. package/templates/service/README.md.template +45 -0
  64. package/templates/service/cloudflare.config.ts.template +30 -0
  65. package/templates/service/oxfmt.config.ts.template +1 -0
  66. package/templates/service/oxlint.config.ts.template +1 -0
  67. package/templates/service/package.json.template +31 -0
  68. package/templates/service/src/app.ts.template +30 -0
  69. package/templates/service/src/index.ts.template +13 -0
  70. package/templates/service/tests/contract.test.ts.template +12 -0
  71. package/templates/service/tsconfig.json.template +16 -0
  72. package/templates/service/vite.config.ts.template +7 -0
  73. package/templates/service/vitest.config.ts.template +10 -0
@@ -0,0 +1,73 @@
1
+ # Testing
2
+
3
+ Maximus tests its own guarantees (token verification, routing, envelopes, validation boundaries,
4
+ diagnostics privacy, MCP pagination). Test what only the service knows: domain rules, tenant
5
+ isolation in queries, provider projections, state, retries and policies. Do not copy the framework's
6
+ matrices into every service.
7
+
8
+ ## Handler tests (Node or Bun, Vitest)
9
+
10
+ ```ts
11
+ import { createHttpHandler } from '@arbol-ai/maximus';
12
+ import { app } from '../src/app'; // app.ts must not import cloudflare:workers
13
+
14
+ const handle = createHttpHandler(app);
15
+ const response = await handle(new Request('http://localhost:5173/v1/notes'), env);
16
+ ```
17
+
18
+ - Fake bindings through the narrow interfaces in `Env` (a `Map` behind a `NoteStore`), not casts.
19
+ - Default OAuth verification: `createHttpHandler(app, { verify: async () => claims })` replaces only
20
+ the JWT check. Person claims: `{ sub, azp, org_id: 'org_1234567890abcdef', scope, permissions }`;
21
+ machine: `{ sub: '<client>@clients', client_id: '<client>', org_id, scope }`. Send
22
+ `authorization: Bearer a.b.c` (JWT-shaped). Never pass `verify` in production.
23
+ - Custom `tokens.resolve`: put the test credential in `env` and exercise the real resolver.
24
+ - Typed client against the handler:
25
+
26
+ ```ts
27
+ const client = createClient<typeof app>('http://localhost:5173', token, {
28
+ response: 'data',
29
+ fetch: async (input, init) => await handle(new Request(input, init), env),
30
+ });
31
+ ```
32
+
33
+ ## MCP
34
+
35
+ ```ts
36
+ const handle = createHttpHandler(app, { verify: async () => claims, transports: [mcp()] });
37
+ // POST /mcp with accept: application/json, text/event-stream and a JSON-RPC body;
38
+ // parse the response with /data: (\{[^\n]*)/
39
+ ```
40
+
41
+ ## Without a transport
42
+
43
+ `executeOperation(app, app.operations.name, env, principal, input, authority?)` from
44
+ `@arbol-ai/maximus/internals` runs the shared execution path (input decoding, derive, middleware,
45
+ handler, output check) for RPC-only operations. Principal:
46
+ `{ actorId, actorKind, organizationId: 'org_' + 16 alphanumerics, requestId: crypto.randomUUID() }`.
47
+
48
+ ## Contract smoke
49
+
50
+ `verifyContract((request) => handle(request, env), origin)` from `@arbol-ai/maximus/testing` checks
51
+ that `/openapi.json` and `/openapi.yaml` are the same document and returns `{ paths, operations }`.
52
+ Run one per service against the real Worker (workerd or a deployment).
53
+
54
+ ## workerd
55
+
56
+ Durable Objects, real bindings and Service Bindings: Cloudflare's Vitest integration with remote
57
+ bindings off, or Miniflare with several Workers.
58
+
59
+ ## RPC types
60
+
61
+ ```ts
62
+ type AssertFalse<T extends false> = T;
63
+ type IsNever<T> = [T] extends [never] ? true : false;
64
+ export type QuoteReturnExists = AssertFalse<IsNever<Awaited<ReturnType<Service<typeof PricingService>['quoteItems']>>>>;
65
+ // @ts-expect-error The control must fail; otherwise the check proves nothing.
66
+ export type NeverControl = AssertFalse<IsNever<never>>;
67
+ ```
68
+
69
+ ## CI rules
70
+
71
+ Synthetic data only; no live providers, paid services or production resources; remote bindings
72
+ off. Scripts call domain functions or the typed client, never a second provider implementation.
73
+ Keep security, privacy and retry tests where they are.
@@ -0,0 +1,119 @@
1
+ # Transports
2
+
3
+ | | HTTP | MCP | Native RPC |
4
+ | --- | --- | --- | --- |
5
+ | Opt in | `http: { method, path }` | `mcp: { name, idempotent }` + `transports: [mcp()]` | `rpc: true` or `{ callers }` + app `rpc.callers` |
6
+ | Caller proves | Bearer token | Bearer token with `<namespace>:mcp:use` | Service Binding props `{ caller }` |
7
+ | Scopes checked | Yes | Yes, also to list tools | No |
8
+ | Success | Envelope `{ success: true, data, error: null, metadata: { requestId } }` | `structuredContent` + JSON text | `{ ok: true, value }` |
9
+ | Failure | Catalog status + `{ success: false, data: null, error, metadata }` | `isError: true`, failure JSON text | `{ ok: false, error }` |
10
+
11
+ All three share input validation, `derive`, middleware, the handler and output validation.
12
+
13
+ ## HTTP and OpenAPI
14
+
15
+ - Responses always carry `x-request-id`, `cache-control: private, no-store`, `nosniff` and
16
+ `server-timing`. A `401` carries `WWW-Authenticate: Bearer resource_metadata="<origin>/.well-known/oauth-protected-resource"`.
17
+ - `/openapi.json`, `/openapi.yaml`, `/openapi.yml`: OpenAPI 3.1 of the public HTTP operations (never
18
+ an internal one): scopes as OAuth security requirements (`<issuer>authorize`, `<issuer>oauth/token`
19
+ by default), one response per failure status naming the codes that answer with it
20
+ (`FailureResponse` narrowed to them), and the operation extensions `x-required-scopes`,
21
+ `x-scope-match` (with more than one scope), `x-conditional-scopes`, `x-effect`, `x-mcp-tool` (with
22
+ `x-mcp-idempotent`, `x-mcp-open-world`), `x-native-rpc`, `x-max-body-bytes` and
23
+ `x-max-output-bytes` (the limits in force), `x-body`, `x-input-headers` and `x-response`. The root
24
+ holds only `openapi`, `info`, `servers`, `paths` and `components`; the tag defaults to the
25
+ operation's name. Every `$ref` is local: a schema's `$id` (shared schemas, `PageInfo`, each `Page`,
26
+ recursive schemas) becomes `#/components/schemas/<id>`; every envelope's `metadata` refers to
27
+ `ResponseMetadata` and every failure narrows `Failure`. MCP tool schemas stay self-contained: named
28
+ schemas written in place, without `$id`.
29
+ - `createOpenApi(app)` builds that same document at build time.
30
+ - Rate limiting: `rateLimit: { binding, retryAfter }` (a Workers rate limit binding), keyed by
31
+ organization and actor after authentication; 429 `RATE_LIMITED`.
32
+ - Typed callers: `createClient<typeof app>(baseUrl, token, { response: 'data' })` from
33
+ `@arbol-ai/maximus/client`, importing `app` as a type only. HTTPS (plain `http://` only on
34
+ loopback), no redirects, no write retries, `fetch` option for tests.
35
+
36
+ ## MCP
37
+
38
+ - Endpoint `/mcp` (or `mcp({ path })`, `/` for a dedicated host), Streamable HTTP, stateless.
39
+ Clients send `accept: application/json, text/event-stream`; answers are SSE `data:` lines.
40
+ - Tools visible to a token: its scopes match the operation and `actorKinds` allows its actor. 50 per
41
+ `tools/list` page. Calls of unseen tools are JSON-RPC errors.
42
+ - Annotations: `readOnlyHint` = effect read, `destructiveHint` = effect delete, `idempotentHint` =
43
+ `mcp.idempotent`, `openWorldHint` = `mcp.openWorld ?? true`. Hints are not authorization.
44
+ - App `mcp`: `instructions`; `guides: [{ name, title, text }]` (resources and prompts);
45
+ `skills: [{ name, description, text }]` (MCP Skills extension, `skill://<name>/SKILL.md`);
46
+ `skillTool: 'read_skill'` (skills as one read-only tool, first in the catalog).
47
+ - A union input lists as one object (every member's fields, the discriminator as an `enum`), since
48
+ hosts refuse a root `anyOf`; each call is still checked against the exact union.
49
+ - An unexpected failure of the server answers the JSON-RPC `Internal error`, never its own text, and
50
+ is reported as `maximus.unexpected`.
51
+ - Resources `openapi-json` and `openapi-yaml` expose the public contract, named by the URLs that
52
+ serve it (below `http.basePath`); reading grants nothing.
53
+ - The endpoint admits the largest `maxBodyBytes` among the tools the caller may call and holds each
54
+ call to its own.
55
+ - A `bearer` token scheme cannot mount MCP. Keep credential and permission management out of tools.
56
+
57
+ ## Native RPC
58
+
59
+ Owner:
60
+
61
+ ```ts
62
+ maximus<Env>({ /* ... */ rpc: { callers: ['orders'] } })
63
+ .operation('quoteItems', { /* ... */ rpc: true }, handler);
64
+ export const PricingService = createWorker(app).entrypoint;
65
+ ```
66
+
67
+ Owner `cloudflare.config.ts` declares `exports: { PricingService: exports.worker() }` and exports its
68
+ `defineWorker` definition; caller `cloudflare.config.ts`:
69
+
70
+ ```ts
71
+ PRICING: bindings.worker({ worker: pricingWorker, exportName: 'PricingService', props: { caller: 'orders' } }),
72
+ ```
73
+
74
+ Locally, the caller's `vite.config.ts` runs the owner beside it:
75
+ `cloudflare({ auxiliaryWorkers: [{ config: pricingWorker, devOnly: true }] })`.
76
+
77
+ ```ts
78
+ // Env: PRICING: Service<typeof PricingService>
79
+ const quote = await env.PRICING.quoteItems(principal, { items }); // forward the verified principal
80
+ ```
81
+
82
+ - The owner requires props exactly `{ caller }` with an admitted caller, and a principal that matches
83
+ `{ actorId, actorKind, organizationId, requestId }` exactly; otherwise `UNAUTHORIZED`.
84
+ - No scopes are checked and `authority` is absent: the calling deployment is trusted. When the owner
85
+ must verify the original authority, call its HTTP route with the caller's token
86
+ (`authority.token`).
87
+ - Owner failures belong to the owner's catalog: translate them before returning them, or the
88
+ caller's output check turns them into `INTERNAL_ERROR`. Catch thrown calls (owner unreachable).
89
+ - `worker.service(Class)` and `worker.durableObject(Class)` wrap your own entrypoints and Durable
90
+ Objects with diagnostics and adapters. Never rename Durable Object classes or migration tags.
91
+
92
+ ## Plain routes and Worker composition
93
+
94
+ ```ts
95
+ createWorker(app, {
96
+ routes: { '/webhooks/payments': paymentWebhook }, // exact paths, no principal, not in OpenAPI
97
+ http: {
98
+ basePath: '/api', // operations + discovery below /api; transports stay absolute
99
+ mounts: { '/files': serveFiles }, // prefix + slash-delimited descendants
100
+ before: async (request) => null, // first; a Response answers
101
+ aroundOperation: async (request, env, op, run) => run(env), // matched HTTP operations; run once
102
+ origins: ['https://notes.example.com'], // exact HTTPS origins, others 404
103
+ healthPath: '/healthz',
104
+ },
105
+ assets: { binding: 'ASSETS', pages: { paths: ['/'] }, immutablePrefixes: ['/assets/'] },
106
+ handlers: { scheduled: runJobs },
107
+ });
108
+ ```
109
+
110
+ - A plain route (`HttpRoute<Env>`: `(request, env, { requestId, fail, waitUntil })`) verifies its
111
+ own signature on the exact bytes (`readBodyBytes(request, { maxBytes, signal })`) before treating
112
+ them as data, answers failures with `context.fail(failure, headers?)`, and may set its own
113
+ `cache-control`.
114
+ - Reserved: `/v<n>/…`, native paths, transport paths, `tokens.resources` keys. Collisions fail at
115
+ construction. A route may sit beneath a transport's path.
116
+ - `fallback` (or `assets`, not both) answers only paths outside API, versioned, native,
117
+ `/.well-known` and transport namespaces.
118
+ - Assets: configure the binding with `html_handling: "none"`, `not_found_handling: "none"` and
119
+ `run_worker_first: true`.
@@ -0,0 +1,10 @@
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.
@@ -0,0 +1,21 @@
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
19
+ env:
20
+ NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN || github.token }}
21
+ - run: bun run verify
@@ -0,0 +1,8 @@
1
+ node_modules/
2
+ dist/
3
+ .cloudflare/
4
+ .wrangler/
5
+ .env*
6
+ .dev.vars*
7
+ .private/
8
+ coverage/
@@ -0,0 +1,3 @@
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.
@@ -0,0 +1,45 @@
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 `cf dev`. `maximus init` wrote a random development
16
+ token to `.dev.vars`, which Git ignores and `cloudflare.config.ts` declares for `cf 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 `cf dev`. |
30
+ | `bun run typecheck` | Generates the binding and runtime types with `cf workers types`, then TypeScript. |
31
+ | `bun run check` / `bun run fix` | Lint and format with the Maximus presets. |
32
+ | `bun run test` | The tests, in the Workers runtime. |
33
+ | `bun run build` | `cf build`, which writes the build `cf deploy` uploads. |
34
+ | `bun run verify` | Everything above. |
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).
@@ -0,0 +1,30 @@
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
+ }));
@@ -0,0 +1 @@
1
+ export { default } from '@arbol-ai/maximus/oxfmt';
@@ -0,0 +1 @@
1
+ export { default } from '@arbol-ai/maximus/oxlint';
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "cf dev",
7
+ "typecheck": "cf workers types && tsc",
8
+ "check": "ultracite check",
9
+ "fix": "ultracite fix",
10
+ "test": "vitest run",
11
+ "build": "cf build",
12
+ "verify": "bun run typecheck && bun run check && bun run test && 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.73.0",
24
+ "oxlint": "^1.88.0",
25
+ "typescript": "^7.0.2",
26
+ "ultracite": "^8.0.1",
27
+ "vite": "^8.3.4",
28
+ "vitest": "^5.0.5"
29
+ },
30
+ "packageManager": "bun@1.4.3"
31
+ }
@@ -0,0 +1,30 @@
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();
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,12 @@
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 'vitest';
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
+ });
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The build `cf` runs: Cloudflare's Vite plugin bundles the Worker and, under `cf dev`, runs it in workerd.
3
+ */
4
+ import { cloudflare } from '@cloudflare/vite-plugin';
5
+ import { defineConfig } from 'vite';
6
+
7
+ export default defineConfig({ plugins: [cloudflare()] });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The tests run in workerd, with the Worker and the bindings cloudflare.config.ts declares.
3
+ */
4
+ import { cloudflareTest } from '@cloudflare/vitest-plugin';
5
+ import { defineConfig } from 'vitest/config';
6
+
7
+ export default defineConfig({
8
+ plugins: [cloudflareTest({ remoteBindings: false, experimental: { newConfig: true } })],
9
+ test: { include: ['tests/**/*.test.ts'] },
10
+ });