@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.
- package/README.md +36 -38
- package/bin/maximus.js +4 -0
- package/config/oxfmt.mjs +1 -0
- package/config/oxlint.mjs +10 -0
- package/dist/analytics/analytics.d.ts +21 -9
- package/dist/analytics/analytics.js +19 -5
- package/dist/body.d.ts +1 -1
- package/dist/body.js +2 -2
- package/dist/chunks/agent-skills-Ef65jTf_.js +49 -0
- package/dist/chunks/agent-skills-m7y1EUch.js +3 -0
- package/dist/chunks/{body-6LichrQm.js → body-DOIHwIIl.js} +14 -7
- package/dist/chunks/{correlation-BEkcFFGT.js → correlation-4b23a-a4.js} +8 -5
- package/dist/chunks/define-app-CfVZBt7D.js +336 -0
- package/dist/chunks/errors-WfyKhiyk.js +131 -0
- package/dist/chunks/execution-CfZEx_JP.js +84 -0
- package/dist/chunks/generate-C-9FKW0o.js +197 -0
- package/dist/chunks/handler-DWTGoduQ.js +140 -0
- package/dist/chunks/http-layout-_h7xwgPC.js +128 -0
- package/dist/chunks/http-paths-DMBxwpp6.js +218 -0
- package/dist/chunks/{json-Bu4BLT25.js → json-B14evE6-.js} +21 -5
- package/dist/chunks/names-ncD7A3DV.js +280 -0
- package/dist/chunks/openapi-CV0KmJpS.js +1588 -0
- package/dist/chunks/openapi-file-OjSs9mRv.js +83 -0
- package/dist/chunks/pages-DyC0m8Zb.js +14 -0
- package/dist/chunks/prepare-configured-BmRJLg6J.js +3 -0
- package/dist/chunks/prepare-configured-Cithjf80.js +52 -0
- package/dist/chunks/project-files-C0OX7MQQ.js +130 -0
- package/dist/chunks/query-kind-CWKAXEME.js +40 -0
- package/dist/chunks/record-DQUDTpEA.js +10 -0
- package/dist/chunks/result-CKgZHrnj.js +56 -0
- package/dist/chunks/{runtime-BPnaa-NK.js → runtime-CVVf5hmp.js} +50 -25
- package/dist/chunks/scaffold-DGrcjR3h.js +3 -0
- package/dist/chunks/scaffold-DZD6dfoZ.js +138 -0
- package/dist/chunks/{schemas-CzTvbXb6.js → schemas-p_aRcMC1.js} +30 -14
- package/dist/chunks/server-CCc7fil4.js +410 -0
- package/dist/chunks/src--HZrH1U9.js +568 -0
- package/dist/chunks/standard-failures-CLjxS2ea.js +74 -0
- package/dist/chunks/{telemetry-BTwB68m5.js → telemetry-C3LfZcOB.js} +32 -11
- package/dist/chunks/{types-BWxDd3tY.d.ts → types-BQYB4Ads.d.ts} +998 -337
- package/dist/chunks/{validation-r-sgmsqb.js → validation-fTohBT6R.js} +69 -28
- package/dist/chunks/workers-types-iONp32T4.d.ts +143 -0
- package/dist/chunks/yaml-Dk2L24yQ.js +74 -0
- package/dist/diagnostics.d.ts +6 -4
- package/dist/diagnostics.js +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +2 -125
- package/dist/http-paths.d.ts +1 -1
- package/dist/http-paths.js +1 -197
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -10
- package/dist/internals.d.ts +1 -1
- package/dist/internals.js +5 -3
- package/dist/mcp/index.d.ts +3 -2
- package/dist/mcp/index.js +5 -387
- package/dist/postgres/index.d.ts +25 -8
- package/dist/postgres/index.js +17 -8
- package/dist/project/config.d.ts +139 -0
- package/dist/project/config.js +196 -0
- package/dist/project/index.d.ts +17 -4
- package/dist/project/index.js +44 -9
- package/dist/projection.d.ts +14 -13
- package/dist/projection.js +8 -32
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +2 -2
- package/dist/standard-failures.d.ts +2 -89
- package/dist/standard-failures.js +1 -72
- package/dist/tooling/cli.js +151 -107
- package/dist/tooling/testing.js +2 -2
- package/dist/vite/cloudflare-workers.js +25 -0
- package/dist/vite/index.d.ts +157 -0
- package/dist/vite/index.js +1477 -0
- package/dist/webhooks.d.ts +12 -10
- package/dist/webhooks.js +26 -12
- package/dist/workers/runtime.d.ts +1 -1
- package/dist/workers/runtime.js +1 -1
- package/package.json +30 -22
- package/skills/maximus/SKILL.md +165 -69
- package/skills/maximus/references/deploying.md +73 -0
- package/skills/maximus/references/errors-and-results.md +114 -55
- package/skills/maximus/references/project.md +202 -0
- package/skills/maximus/references/routes-and-tools.md +256 -0
- package/skills/maximus/references/testing.md +137 -50
- package/skills/maximus/references/transports.md +113 -100
- package/skills/maximus/references/writing-code.md +84 -0
- package/templates/mcp/mcp/instructions.md.template +2 -0
- package/templates/mcp/routes/v1/greeting.get.ts.template +12 -0
- package/templates/mcp/tests/mcp.test.ts.template +36 -0
- package/templates/project/.agents/skills/project/SKILL.md.template +21 -12
- package/templates/project/.github/workflows/ci.yml.template +4 -1
- package/templates/project/CLAUDE.md.template +41 -22
- package/templates/project/README.md.template +54 -47
- package/templates/project/middleware/10-response.ts.template +16 -0
- package/templates/project/package.json.template +16 -8
- package/templates/project/pages/index.ts.template +2 -4
- package/templates/project/routes/v1/greeting.get.ts.template +10 -0
- package/templates/project/routes/v1/greeting.post.ts.template +12 -0
- package/templates/project/tests/greeting.test.ts.template +45 -0
- package/templates/project/tsconfig.json.template +8 -5
- package/templates/project/vite.config.ts.template +15 -7
- package/templates/web/app/main.tsx.template +16 -0
- package/templates/web/app/root.tsx.template +17 -0
- package/templates/web/app/routes/index.tsx.template +9 -0
- package/templates/web/index.html.template +12 -0
- package/templates/web/package.json.template +12 -0
- package/templates/web/tsconfig.json.template +7 -0
- package/templates/web/vite.config.ts.template +22 -0
- package/dist/chunks/execution-B-yy4C7N.js +0 -691
- package/dist/chunks/prepare-project-zi106pWF.js +0 -146
- package/dist/chunks/record-DY-lX9w1.js +0 -34
- package/dist/chunks/src-DPSpGNnT.js +0 -1164
- package/dist/client/client.d.ts +0 -129
- package/dist/client/client.js +0 -321
- package/dist/tooling/vite.d.ts +0 -3
- package/dist/tooling/vite.js +0 -44
- package/skills/maximus/references/adding-an-operation.md +0 -179
- package/skills/maximus/references/building-a-service.md +0 -167
- package/skills/maximus/references/migration-from-v2.md +0 -62
- package/skills/maximus/references/migration-to-v5.md +0 -37
- package/skills/maximus/references/publishing-and-verification.md +0 -39
- package/templates/project/cloudflare.config.ts.template +0 -24
- package/templates/project/routes/v1/greeting.ts.template +0 -22
- package/templates/project/src/app.ts.template +0 -2
- package/templates/project/src/application.ts.template +0 -26
- package/templates/project/src/index.ts.template +0 -3
- package/templates/project/src/worker.ts.template +0 -6
- package/templates/service/.agents/skills/project/SKILL.md.template +0 -10
- package/templates/service/.github/workflows/ci.yml.template +0 -21
- package/templates/service/.gitignore.template +0 -9
- package/templates/service/CLAUDE.md.template +0 -5
- package/templates/service/README.md.template +0 -45
- package/templates/service/cloudflare.config.ts.template +0 -30
- package/templates/service/package.json.template +0 -36
- package/templates/service/src/app.ts.template +0 -30
- package/templates/service/src/index.ts.template +0 -13
- package/templates/service/tests/contract.test.ts.template +0 -12
- package/templates/service/tsconfig.json.template +0 -16
- package/templates/service/vite.config.ts.template +0 -13
- package/templates/service/vitest.config.ts.template +0 -10
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Qn as Result, ur as Failure } from "./chunks/types-BQYB4Ads.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. */
|
|
@@ -23,8 +23,9 @@ export declare const DEFAULT_TOLERANCE_SECONDS = 300;
|
|
|
23
23
|
*/
|
|
24
24
|
export declare const MAX_SIGNATURES = 8;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* optionally with a scheme prefix such as `sha256=` (removed with `prefix`).
|
|
26
|
+
* Verifies an HMAC-SHA256 of the raw body. `signature` is the header value, hex or base64 as `encoding`
|
|
27
|
+
* says, optionally with a scheme prefix such as `sha256=` (removed with `prefix`). An absent signature fails
|
|
28
|
+
* as `missing`, one that does not decode as `malformed`, and one that does not match as `mismatch`.
|
|
28
29
|
*/
|
|
29
30
|
export declare function verifyHmacSignature(options: {
|
|
30
31
|
body: string | Uint8Array;
|
|
@@ -34,9 +35,10 @@ export declare function verifyHmacSignature(options: {
|
|
|
34
35
|
signature: string | null | undefined;
|
|
35
36
|
}): Promise<Result<null, WebhookSignatureFailure>>;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* enough)
|
|
38
|
+
* Verifies a `t=<unix seconds>,<label>=<hex>` header, an HMAC-SHA256 of `<t>.<body>`. Every hex signature
|
|
39
|
+
* under one of `labels` is tried, up to {@link MAX_SIGNATURES} (a provider rotating its secret sends several;
|
|
40
|
+
* one match is enough), and the timestamp must be within `toleranceSeconds` (300 by default) of `now`, in
|
|
41
|
+
* milliseconds, in either direction. Answers the signed timestamp.
|
|
40
42
|
*/
|
|
41
43
|
export declare function verifyTimestampedSignature(options: {
|
|
42
44
|
body: string | Uint8Array;
|
|
@@ -50,10 +52,10 @@ export declare function verifyTimestampedSignature(options: {
|
|
|
50
52
|
timestamp: number;
|
|
51
53
|
}, WebhookSignatureFailure>>;
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* Verifies a Standard Webhooks delivery. The secret is the provider's `whsec_<base64>` value (the prefix is
|
|
56
|
+
* optional), the signature header may list up to {@link MAX_SIGNATURES} `v1` signatures, and the timestamp
|
|
57
|
+
* must be within `toleranceSeconds` (300 by default) of `now`, in either direction. Answers the message id,
|
|
58
|
+
* which is the delivery's idempotency key, and its timestamp.
|
|
57
59
|
*/
|
|
58
60
|
export declare function verifyStandardWebhook(options: {
|
|
59
61
|
body: string | Uint8Array;
|
package/dist/webhooks.js
CHANGED
|
@@ -60,6 +60,14 @@ function fromBase64(value) {
|
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The secret a verifier was given. A missing or empty one is a configuration error, such as a secret binding
|
|
65
|
+
* the deployment lacks, never a refusal: anyone could sign with it, so no verifier runs without one.
|
|
66
|
+
*/
|
|
67
|
+
function requireSecret(secret) {
|
|
68
|
+
if (typeof secret !== "string" && !(secret instanceof Uint8Array) || secret.length === 0) throw new TypeError("A webhook secret is required; check the binding that holds it.");
|
|
69
|
+
return secret;
|
|
70
|
+
}
|
|
63
71
|
/** An HMAC-SHA256 key that can only verify. */
|
|
64
72
|
async function hmacKey(secret) {
|
|
65
73
|
return await crypto.subtle.importKey("raw", secret, {
|
|
@@ -77,25 +85,29 @@ const failure = (reason) => ({
|
|
|
77
85
|
error: webhookSignatureFailure(reason)
|
|
78
86
|
});
|
|
79
87
|
/**
|
|
80
|
-
*
|
|
81
|
-
* optionally with a scheme prefix such as `sha256=` (removed with `prefix`).
|
|
88
|
+
* Verifies an HMAC-SHA256 of the raw body. `signature` is the header value, hex or base64 as `encoding`
|
|
89
|
+
* says, optionally with a scheme prefix such as `sha256=` (removed with `prefix`). An absent signature fails
|
|
90
|
+
* as `missing`, one that does not decode as `malformed`, and one that does not match as `mismatch`.
|
|
82
91
|
*/
|
|
83
92
|
async function verifyHmacSignature(options) {
|
|
93
|
+
const secret = requireSecret(options.secret);
|
|
84
94
|
if (!options.signature) return failure("missing");
|
|
85
95
|
const value = options.prefix && options.signature.startsWith(options.prefix) ? options.signature.slice(options.prefix.length) : options.signature;
|
|
86
96
|
const signature = options.encoding === "hex" ? fromHex(value.trim()) : fromBase64(value.trim());
|
|
87
97
|
if (!signature) return failure("malformed");
|
|
88
|
-
return await crypto.subtle.verify("HMAC", await hmacKey(bytes(
|
|
98
|
+
return await crypto.subtle.verify("HMAC", await hmacKey(bytes(secret)), signature, bytes(options.body)) ? {
|
|
89
99
|
ok: true,
|
|
90
100
|
value: null
|
|
91
101
|
} : failure("mismatch");
|
|
92
102
|
}
|
|
93
103
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* enough)
|
|
104
|
+
* Verifies a `t=<unix seconds>,<label>=<hex>` header, an HMAC-SHA256 of `<t>.<body>`. Every hex signature
|
|
105
|
+
* under one of `labels` is tried, up to {@link MAX_SIGNATURES} (a provider rotating its secret sends several;
|
|
106
|
+
* one match is enough), and the timestamp must be within `toleranceSeconds` (300 by default) of `now`, in
|
|
107
|
+
* milliseconds, in either direction. Answers the signed timestamp.
|
|
97
108
|
*/
|
|
98
109
|
async function verifyTimestampedSignature(options) {
|
|
110
|
+
const secret = requireSecret(options.secret);
|
|
99
111
|
if (!options.header) return failure("missing");
|
|
100
112
|
let timestamp = null;
|
|
101
113
|
const signatures = [];
|
|
@@ -113,7 +125,7 @@ async function verifyTimestampedSignature(options) {
|
|
|
113
125
|
if (timestamp === null || signatures.length === 0 || signatures.length > 8) return failure("malformed");
|
|
114
126
|
const now = options.now?.() ?? Date.now();
|
|
115
127
|
if (!withinTolerance(timestamp, options.toleranceSeconds ?? 300, now)) return failure("expired");
|
|
116
|
-
const key = await hmacKey(bytes(
|
|
128
|
+
const key = await hmacKey(bytes(secret));
|
|
117
129
|
const message = concat(encoder.encode(`${timestamp}.`), bytes(options.body));
|
|
118
130
|
for (const signature of signatures) if (await crypto.subtle.verify("HMAC", key, signature, message)) return {
|
|
119
131
|
ok: true,
|
|
@@ -122,12 +134,14 @@ async function verifyTimestampedSignature(options) {
|
|
|
122
134
|
return failure("mismatch");
|
|
123
135
|
}
|
|
124
136
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
137
|
+
* Verifies a Standard Webhooks delivery. The secret is the provider's `whsec_<base64>` value (the prefix is
|
|
138
|
+
* optional), the signature header may list up to {@link MAX_SIGNATURES} `v1` signatures, and the timestamp
|
|
139
|
+
* must be within `toleranceSeconds` (300 by default) of `now`, in either direction. Answers the message id,
|
|
140
|
+
* which is the delivery's idempotency key, and its timestamp.
|
|
129
141
|
*/
|
|
130
142
|
async function verifyStandardWebhook(options) {
|
|
143
|
+
const given = requireSecret(options.secret);
|
|
144
|
+
const encoded = requireSecret(given.startsWith("whsec_") ? given.slice(6) : given);
|
|
131
145
|
/** A Standard Webhooks header, or its `svix-` spelling. */
|
|
132
146
|
const header = (name) => options.headers.get(`webhook-${name}`) ?? options.headers.get(`svix-${name}`);
|
|
133
147
|
const id = header("id");
|
|
@@ -138,7 +152,7 @@ async function verifyStandardWebhook(options) {
|
|
|
138
152
|
const timestamp = Number(timestampValue);
|
|
139
153
|
const now = options.now?.() ?? Date.now();
|
|
140
154
|
if (!withinTolerance(timestamp, options.toleranceSeconds ?? 300, now)) return failure("expired");
|
|
141
|
-
const secret = fromBase64(
|
|
155
|
+
const secret = fromBase64(encoded);
|
|
142
156
|
if (!secret) return failure("malformed");
|
|
143
157
|
const signatures = signatureValue.split(" ").flatMap((entry) => {
|
|
144
158
|
const [version, value] = entry.split(",", 2);
|
|
@@ -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/types-
|
|
1
|
+
import { a as credentials, i as createWorker, n as WorkerOptions, o as WorkerAssetsOptions, r as WorkerRuntime, t as RpcMethods } from "../chunks/workers-types-iONp32T4.js";
|
|
2
2
|
export { RpcMethods, type WorkerAssetsOptions, WorkerOptions, WorkerRuntime, createWorker, credentials };
|
package/dist/workers/runtime.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbol-ai/maximus",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Maximus: define a service once and serve it over HTTP, MCP and Worker RPC on Cloudflare Workers, with its OpenAPI
|
|
3
|
+
"version": "8.0.0",
|
|
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",
|
|
7
7
|
"cloudflare",
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
"multi-tenant",
|
|
13
13
|
"openapi",
|
|
14
14
|
"rpc",
|
|
15
|
-
"typebox"
|
|
15
|
+
"typebox",
|
|
16
|
+
"vite",
|
|
17
|
+
"vite-plugin",
|
|
18
|
+
"vite-plus"
|
|
16
19
|
],
|
|
17
20
|
"homepage": "https://github.com/getarbol/maximus#readme",
|
|
18
21
|
"bugs": {
|
|
@@ -26,9 +29,10 @@
|
|
|
26
29
|
"directory": "packages/maximus"
|
|
27
30
|
},
|
|
28
31
|
"bin": {
|
|
29
|
-
"maximus": "
|
|
32
|
+
"maximus": "bin/maximus.js"
|
|
30
33
|
},
|
|
31
34
|
"files": [
|
|
35
|
+
"bin",
|
|
32
36
|
"dist",
|
|
33
37
|
"config",
|
|
34
38
|
"templates",
|
|
@@ -87,10 +91,6 @@
|
|
|
87
91
|
"types": "./dist/mcp/index.d.ts",
|
|
88
92
|
"import": "./dist/mcp/index.js"
|
|
89
93
|
},
|
|
90
|
-
"./client": {
|
|
91
|
-
"types": "./dist/client/client.d.ts",
|
|
92
|
-
"import": "./dist/client/client.js"
|
|
93
|
-
},
|
|
94
94
|
"./analytics": {
|
|
95
95
|
"types": "./dist/analytics/analytics.d.ts",
|
|
96
96
|
"import": "./dist/analytics/analytics.js"
|
|
@@ -116,43 +116,51 @@
|
|
|
116
116
|
"import": "./dist/project/index.js"
|
|
117
117
|
},
|
|
118
118
|
"./vite": {
|
|
119
|
-
"types": "./dist/
|
|
120
|
-
"import": "./dist/
|
|
119
|
+
"types": "./dist/vite/index.d.ts",
|
|
120
|
+
"import": "./dist/vite/index.js"
|
|
121
|
+
},
|
|
122
|
+
"./config": {
|
|
123
|
+
"types": "./dist/project/config.d.ts",
|
|
124
|
+
"import": "./dist/project/config.js"
|
|
121
125
|
}
|
|
122
126
|
},
|
|
123
127
|
"publishConfig": {
|
|
124
128
|
"access": "public",
|
|
125
129
|
"registry": "https://registry.npmjs.org/"
|
|
126
130
|
},
|
|
127
|
-
"scripts": {
|
|
128
|
-
"typecheck": "tsc --noEmit",
|
|
129
|
-
"build": "vp pack",
|
|
130
|
-
"test": "vp test run --exclude \"**/*.integration.test.ts\"",
|
|
131
|
-
"test:integration": "vp test run --config vitest.integration.config.ts"
|
|
132
|
-
},
|
|
133
131
|
"dependencies": {
|
|
134
|
-
"@modelcontextprotocol/server": "2.
|
|
132
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
135
133
|
"@sinclair/typebox": "0.34.52",
|
|
136
134
|
"ajv-formats": "3.0.1",
|
|
137
|
-
"jose": "6.2.
|
|
138
|
-
"yaml": "2.9.1"
|
|
135
|
+
"jose": "6.2.13"
|
|
139
136
|
},
|
|
140
137
|
"devDependencies": {
|
|
138
|
+
"@cloudflare/vite-plugin": "2.0.0-beta.v.5",
|
|
141
139
|
"@types/pg": "8.23.1",
|
|
142
140
|
"ajv": "8.20.0",
|
|
143
|
-
"
|
|
141
|
+
"cf": "1.0.0-beta.23",
|
|
142
|
+
"miniflare": "5.20261023.0-beta",
|
|
144
143
|
"pg": "8.23.1",
|
|
145
144
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
146
|
-
"vite-plus": "1.4.0"
|
|
145
|
+
"vite-plus": "1.4.0",
|
|
146
|
+
"yaml": "2.9.1"
|
|
147
147
|
},
|
|
148
148
|
"peerDependencies": {
|
|
149
|
+
"@cloudflare/vite-plugin": ">=2.0.0-beta.v.5",
|
|
150
|
+
"cf": ">=1.0.0-beta.23",
|
|
149
151
|
"oxfmt": ">=0.71.0 <1",
|
|
150
152
|
"oxlint": "^1.86.0",
|
|
151
153
|
"pg": "^8.23.1",
|
|
152
|
-
"ultracite": "^8.
|
|
154
|
+
"ultracite": "^8.1.0",
|
|
153
155
|
"vite": "^8.3.4"
|
|
154
156
|
},
|
|
155
157
|
"peerDependenciesMeta": {
|
|
158
|
+
"@cloudflare/vite-plugin": {
|
|
159
|
+
"optional": true
|
|
160
|
+
},
|
|
161
|
+
"cf": {
|
|
162
|
+
"optional": true
|
|
163
|
+
},
|
|
156
164
|
"oxfmt": {
|
|
157
165
|
"optional": true
|
|
158
166
|
},
|
package/skills/maximus/SKILL.md
CHANGED
|
@@ -1,89 +1,185 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: maximus
|
|
3
|
-
description: Build, extend, test,
|
|
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.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Maximus
|
|
7
7
|
|
|
8
|
-
Maximus
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
A Maximus service is a project. `vite.config.ts` configures it with `maximus()` from `@arbol-ai/maximus/vite`,
|
|
9
|
+
and its files declare the rest. A route file declares one operation, its handler and its contract; Maximus
|
|
10
|
+
serves it over HTTP with an OpenAPI document, as an MCP tool when the contract names one, and over native
|
|
11
|
+
RPC when the contract says so. Each transport admits its caller (an access token holding the operation's
|
|
12
|
+
scope, or a Service Binding the service trusts), then every call runs one pipeline: input decoding,
|
|
13
|
+
`context.ts`, middleware, the handler, the output check. Work with that pipeline, never around it.
|
|
14
|
+
|
|
15
|
+
## The project
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
vite.config.ts maximus(): origin, tokens.issuer, env (bindings), compatibilityDate, Worker settings
|
|
19
|
+
routes/v1/notes/[noteId].get.ts GET /api/v1/notes/{noteId}: export default defineHandler(handler, contract)
|
|
20
|
+
mcp/tools/summarize-notes.ts The MCP tool summarize_notes: export default defineTool(handler, contract)
|
|
21
|
+
mcp/instructions.md What MCP clients read when they connect; mcp/guides/ and mcp/skills/ too
|
|
22
|
+
context.ts export default defineContext(({ env, principal }) => ({ … }))
|
|
23
|
+
errors.ts export default defineErrors({ … }): the service's own failure codes
|
|
24
|
+
auth.ts export default defineAuth({ resolve }): tokens the service verifies itself
|
|
25
|
+
telemetry.ts export default defineTelemetry({ observers }): observers such as analytics()
|
|
26
|
+
middleware/ defineMiddleware (before admission) or defineOperationMiddleware (after it)
|
|
27
|
+
pages/ crons/ queues/ email/ Public pages and webhooks (pages/webhooks/x.post.ts), event handlers
|
|
28
|
+
durable-objects/ Durable Object classes, one per file
|
|
29
|
+
src/ Domain code: schemas, stores, clients of other services
|
|
30
|
+
tests/ vp test suites that call handler from #maximus/http in Node
|
|
31
|
+
.maximus/ Generated by maximus prepare: never edit it, never commit it
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Every file but `vite.config.ts` is optional. [references/project.md](references/project.md) describes
|
|
35
|
+
each one.
|
|
12
36
|
|
|
13
37
|
## Workflow
|
|
14
38
|
|
|
15
|
-
1. **Read
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
1. **Read before you write.** Read `vite.config.ts`, `errors.ts`, `context.ts`, the route closest to the
|
|
40
|
+
task and its tests. Keep the project's folders and its named domain functions.
|
|
41
|
+
2. **Generate, then fill in.** `bunx maximus gen route <method> <path>` writes a route file, a tool too with
|
|
42
|
+
`--tool <snake_name>`; `bunx maximus gen tool <kebab-name>` writes a tool only agents call. Replace the
|
|
43
|
+
placeholder handler and description, and declare strict `input` and `output` schemas and the
|
|
44
|
+
`failures`. Declare `scope`, `effect` or `operationId` only where the derived one is wrong. See
|
|
45
|
+
[references/routes-and-tools.md](references/routes-and-tools.md).
|
|
46
|
+
3. **Write it to be read.** A handler is a few statements that call named functions of `src/`, imported as
|
|
47
|
+
`#src/<module>.ts`; names are whole English words. See
|
|
48
|
+
[references/writing-code.md](references/writing-code.md).
|
|
49
|
+
4. **Scope by organization in the context.** What every handler needs, such as a store, belongs in
|
|
50
|
+
`context.ts`, built from `principal.organizationId`.
|
|
51
|
+
5. **Answer failures from the catalog.** `fail(code)` with a code of `errors.ts`, listed in the route's
|
|
52
|
+
`failures`; throw only for what should never happen. See
|
|
53
|
+
[references/errors-and-results.md](references/errors-and-results.md).
|
|
54
|
+
6. **Declare bindings in `maximus()`.** `env: { NOTES: bindings.kv() }`, with `bindings` from `cf/config`,
|
|
55
|
+
and another Worker's RPC methods in `services`; the generated `Env` types them.
|
|
56
|
+
7. **Test** each route in `tests/` through `handler` from `#maximus/http`: its answer, its refusals and that
|
|
57
|
+
one organization never reaches another's data. See [references/testing.md](references/testing.md).
|
|
58
|
+
8. **Verify** with `bun run verify` before you finish.
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
| Command | Does |
|
|
63
|
+
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
+
| `bun run dev` | `vp dev`: the Worker in workerd at `http://localhost:5173`. The development token in `.dev.vars` signs in from localhost. |
|
|
65
|
+
| `bunx maximus gen route get /v1/notes/{noteId} --tool get_note` | Writes `routes/v1/notes/[noteId].get.ts`, which is also the MCP tool `get_note`. |
|
|
66
|
+
| `bunx maximus gen tool summarize-notes` | Writes `mcp/tools/summarize-notes.ts`, the tool `summarize_notes`. |
|
|
67
|
+
| `bunx maximus prepare` | Writes `.maximus/` for production, or with `--mode development` as `vp dev` does. `vp dev`, `vp build` and `vp test` prepare by themselves. |
|
|
68
|
+
| `bunx maximus openapi` | Writes `openapi.json`, and `openapi.rpc.json` when a route declares `rpc`; `--check` fails when they differ from the routes. |
|
|
69
|
+
| `bun run test` | `vp test run`: the tests, in Node. |
|
|
70
|
+
| `bun run typecheck` | `maximus prepare`, then `tsc`, which also checks type tests. |
|
|
71
|
+
| `bun run check`, `bun run fix` | Lint and format; with fixes. |
|
|
72
|
+
| `bun run verify` | Types, lint and format, tests and the build. CI runs it. |
|
|
73
|
+
| `bun run deploy` | `bun run verify`, then `cf deploy --prebuilt --mode production`. |
|
|
74
|
+
| `bunx maximus skills` | Links this skill into the project's `.agents/skills`, `.claude/skills` and `.codex/skills`. |
|
|
75
|
+
|
|
76
|
+
Every `maximus` command says what it did in a sentence; `--json` prints it as JSON instead.
|
|
28
77
|
|
|
29
78
|
## Decisions
|
|
30
79
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
80
|
+
| Need | Choose |
|
|
81
|
+
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
82
|
+
| An endpoint for people and services | A route file. Every route is served over HTTP. |
|
|
83
|
+
| The same endpoint for agents | `mcp: { name: 'get_note' }` in its contract, which then needs a `description`. |
|
|
84
|
+
| A capability only agents call | A file of `mcp/tools/` with `defineTool`, which needs a `description` and an `effect`. |
|
|
85
|
+
| Another Worker of the account calls it | `rpc: true` in its contract and the caller's name in `rpc.callers`; commit the `openapi.rpc.json` that `bunx maximus openapi` writes. See [references/transports.md](references/transports.md). |
|
|
86
|
+
| Call another Worker of the account | `services: { PRICING: { worker: 'example-pricing', openapi: '../pricing/openapi.rpc.json' } }` in `maximus()`; import its types from `#maximus/services/pricing`. |
|
|
87
|
+
| Out of the public OpenAPI document | `visibility: 'internal'`: still routed, still checked against its scope. |
|
|
88
|
+
| Setup every call needs: stores, clients | `context.ts`. |
|
|
89
|
+
| A rule for every operation, on every transport | `defineOperationMiddleware` in `middleware/`. |
|
|
90
|
+
| Headers or an early answer around every request | `defineMiddleware` in `middleware/`. It runs before admission and sees no principal. |
|
|
91
|
+
| 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). |
|
|
92
|
+
| 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
|
+
| Tokens your authorization server does not issue | `auth.ts` with `defineAuth({ resolve })`, which verifies cryptographically. |
|
|
94
|
+
| 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). |
|
|
95
|
+
| Many items in one answer | `output: Page(Item, { $id: 'ItemPage' })` with `input: PageQueryFields`. |
|
|
96
|
+
| A file upload or download | `http: { body: 'bytes' }` with `body.read()`; `output: AttachmentOutputSchema` with `http: { response: 'attachment' }`. |
|
|
97
|
+
| Data in Postgres | `withTenantTransaction` from `@arbol-ai/maximus/postgres`. |
|
|
98
|
+
| Guidance agents read over MCP | `mcp/instructions.md`, `mcp/guides/<name>.md`, `mcp/skills/<name>.md`: static text for every caller, never tenant data. |
|
|
99
|
+
| A 7.x service | [Upgrading to 8.0](https://github.com/getarbol/maximus/blob/main/docs/upgrading-to-8.md). |
|
|
45
100
|
|
|
46
101
|
## Rules that are never broken
|
|
47
102
|
|
|
48
|
-
- **
|
|
49
|
-
organization from input, a header or a path.
|
|
50
|
-
- **
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
- **
|
|
54
|
-
|
|
55
|
-
`checkSchema
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- **
|
|
72
|
-
|
|
103
|
+
- **The organization comes from the principal.** Every store, key, query and Durable Object name starts from
|
|
104
|
+
`principal.organizationId`. Never take an organization from input, a header or a path.
|
|
105
|
+
- **Schemas are strict.** Inputs and outputs are strict objects or unions of strict objects: fields given as
|
|
106
|
+
`input: { … }` make one; a `t.Object` needs `{ additionalProperties: false }`. A shared entity has a
|
|
107
|
+
PascalCase `$id`. Use the shared schemas (`UuidSchema`, `EmailAddressSchema`, …) rather than copies.
|
|
108
|
+
- **Each value is checked once, where it enters.** Maximus checks an operation's input and output; a handler
|
|
109
|
+
never parses its input again. Data from outside the pipeline, such as a stored record, a provider's
|
|
110
|
+
answer or a model's output, goes through `readSchema` or `checkSchema`. No casts, trust flags or no-op
|
|
111
|
+
validators in their place.
|
|
112
|
+
- **Failures are declared and honest.** Answer `fail(code)` with a code of `errors.ts`, listed in
|
|
113
|
+
`failures`; the standard failures need no listing. An outage is a failure, never an empty success. A
|
|
114
|
+
write whose outcome is lost answers `OUTCOME_UNKNOWN` and is reconciled, never retried blindly.
|
|
115
|
+
- **Exposure is explicit.** A route is a tool only with `mcp` and an RPC method only with `rpc`. Effects,
|
|
116
|
+
`visibility`, descriptions and MCP hints never authorize: scopes and your own checks do.
|
|
117
|
+
- **No private data in logs or errors.** Request bodies, input values, credentials, tokens, personal or
|
|
118
|
+
clinical data never go in a log line, a failure's `data` or message, a refinement message, an MCP guide or
|
|
119
|
+
skill, or an example. Report a caught error with `reportUnexpected(error, surface)`, which keeps its name
|
|
120
|
+
and drops its message.
|
|
121
|
+
- **Worker code reads `env`, never `process.env`.** A secret is `bindings.secret()`. The development token is
|
|
122
|
+
never declared in `env` and never set on a deployed Worker.
|
|
123
|
+
- **Outbound calls:** a Worker's `fetch(…, { redirect: 'error' })` throws before it sends anything. Send with
|
|
124
|
+
`redirect: 'manual'` and refuse a `3xx`.
|
|
125
|
+
- **Generated code stays generated.** Never edit `.maximus/`: change the source files or `vite.config.ts`.
|
|
126
|
+
- **Refusals are guidance.** `maximus prepare`, `maximus()` and the application's `.build()` refuse a broken
|
|
127
|
+
project with a message that names the rule and the file or operation. Fix the declaration; never loosen
|
|
128
|
+
the check.
|
|
73
129
|
|
|
74
130
|
## References
|
|
75
131
|
|
|
76
|
-
Load the one
|
|
132
|
+
Load the one the task needs:
|
|
133
|
+
|
|
134
|
+
- [references/project.md](references/project.md): `vite.config.ts`, tokens from Auth0 or Cloudflare Access,
|
|
135
|
+
the root modules, bindings and `Env`, the development token, what `prepare` generates, pages, background
|
|
136
|
+
work, Durable Objects and web apps.
|
|
137
|
+
- [references/routes-and-tools.md](references/routes-and-tools.md): file names and what they derive, every
|
|
138
|
+
contract field, input, schemas and codecs, lists, byte bodies, tools, context and middleware.
|
|
139
|
+
- [references/errors-and-results.md](references/errors-and-results.md): the catalog, `fail`, declared
|
|
140
|
+
failures, the standard failures, uncertain outcomes and other services' failures.
|
|
141
|
+
- [references/transports.md](references/transports.md): HTTP and OpenAPI, MCP, Worker RPC, and Workers
|
|
142
|
+
composed by hand.
|
|
143
|
+
- [references/testing.md](references/testing.md): tests in Node, stand-ins for bindings, MCP, RPC documents
|
|
144
|
+
and bindings, the contract check and suites against a running Worker.
|
|
145
|
+
- [references/deploying.md](references/deploying.md): the origin and the issuer, secrets, resources,
|
|
146
|
+
`bun run deploy`, the CI workflow and checking a deployment.
|
|
147
|
+
- [references/writing-code.md](references/writing-code.md): the house style for every file you write:
|
|
148
|
+
handlers as statements, `#src/` imports, names, comments, failures and tests.
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
The documentation is in the Maximus repository, indexed by
|
|
153
|
+
[docs/README.md](https://github.com/getarbol/maximus/blob/main/docs/README.md):
|
|
77
154
|
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
155
|
+
- [Getting started](https://github.com/getarbol/maximus/blob/main/docs/getting-started.md) and
|
|
156
|
+
[Concepts](https://github.com/getarbol/maximus/blob/main/docs/concepts.md).
|
|
157
|
+
- Build the API: [Write code people and agents read easily](https://github.com/getarbol/maximus/blob/main/docs/guides/writing-code.md),
|
|
158
|
+
[Project structure](https://github.com/getarbol/maximus/blob/main/docs/guides/project-structure.md),
|
|
159
|
+
[Routes](https://github.com/getarbol/maximus/blob/main/docs/guides/routes.md),
|
|
160
|
+
[Schemas and validation](https://github.com/getarbol/maximus/blob/main/docs/guides/schemas-and-validation.md),
|
|
161
|
+
[Errors and results](https://github.com/getarbol/maximus/blob/main/docs/guides/errors-and-results.md),
|
|
162
|
+
[Authentication and scopes](https://github.com/getarbol/maximus/blob/main/docs/guides/authentication-and-scopes.md),
|
|
163
|
+
[Context and middleware](https://github.com/getarbol/maximus/blob/main/docs/guides/middleware-and-context.md).
|
|
164
|
+
- Reach it: [MCP](https://github.com/getarbol/maximus/blob/main/docs/guides/mcp.md),
|
|
165
|
+
[Worker RPC](https://github.com/getarbol/maximus/blob/main/docs/guides/worker-rpc.md),
|
|
166
|
+
[Web apps](https://github.com/getarbol/maximus/blob/main/docs/guides/web-apps.md),
|
|
167
|
+
[Worker composition](https://github.com/getarbol/maximus/blob/main/docs/guides/worker-composition.md).
|
|
168
|
+
- Use the platform: [Bindings](https://github.com/getarbol/maximus/blob/main/docs/guides/bindings.md),
|
|
169
|
+
[Background work](https://github.com/getarbol/maximus/blob/main/docs/guides/background-work.md),
|
|
170
|
+
[Durable Objects](https://github.com/getarbol/maximus/blob/main/docs/guides/durable-objects.md),
|
|
171
|
+
[Postgres transactions](https://github.com/getarbol/maximus/blob/main/docs/guides/postgres.md).
|
|
172
|
+
- Ship it: [Testing](https://github.com/getarbol/maximus/blob/main/docs/guides/testing.md),
|
|
173
|
+
[Observability](https://github.com/getarbol/maximus/blob/main/docs/guides/observability.md),
|
|
174
|
+
[Deploying](https://github.com/getarbol/maximus/blob/main/docs/guides/deploying.md),
|
|
175
|
+
[Lint and format](https://github.com/getarbol/maximus/blob/main/docs/guides/lint-and-format.md).
|
|
176
|
+
- Reference: [Configuration](https://github.com/getarbol/maximus/blob/main/docs/reference/configuration.md),
|
|
177
|
+
[Route and operation options](https://github.com/getarbol/maximus/blob/main/docs/reference/operations.md),
|
|
178
|
+
[CLI](https://github.com/getarbol/maximus/blob/main/docs/reference/cli.md),
|
|
179
|
+
[Wire formats](https://github.com/getarbol/maximus/blob/main/docs/reference/wire-formats.md),
|
|
180
|
+
[Standard failures](https://github.com/getarbol/maximus/blob/main/docs/reference/standard-failures.md),
|
|
181
|
+
[Package exports](https://github.com/getarbol/maximus/blob/main/docs/reference/exports.md).
|
|
182
|
+
- Design: [Architecture](https://github.com/getarbol/maximus/blob/main/docs/architecture.md).
|
|
87
183
|
|
|
88
|
-
|
|
89
|
-
|
|
184
|
+
This skill ships in `@arbol-ai/maximus`, at `skills/maximus/`; a project links the copy of the release it
|
|
185
|
+
installed.
|