@arbol-ai/maximus 8.6.0 → 8.7.1

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 (39) hide show
  1. package/dist/analytics/analytics.d.ts +1 -1
  2. package/dist/body.d.ts +1 -1
  3. package/dist/capture/index.d.ts +1 -1
  4. package/dist/chunks/{define-app-BpSKvXET.js → define-app-DLftS8E6.js} +2 -1
  5. package/dist/chunks/{http-layout-BsQlLNeo.js → http-layout-CaZSEy2I.js} +1 -1
  6. package/dist/chunks/{meter-B_WuFl_c.js → meter-77troMd8.js} +1 -1
  7. package/dist/chunks/{openapi-C2A4SxMi.js → openapi-7EYOVkFi.js} +4 -2
  8. package/dist/chunks/{openapi-file-DlBVI3lc.js → openapi-file-DK8aTUmo.js} +1 -1
  9. package/dist/chunks/{pages-B0xdWws9.js → pages-DEnVoMAV.js} +1 -1
  10. package/dist/chunks/{runtime-DjCjXIdf.js → runtime-B7DDXiOv.js} +3 -3
  11. package/dist/chunks/{server-UtQtcegf.js → server-1mO5c8-V.js} +1 -1
  12. package/dist/chunks/{src-CYk0Af0t.js → src-pzoGmAK9.js} +5 -5
  13. package/dist/chunks/{tokens-D6yVDtEU.js → tokens-BtC4LJ8a.js} +81 -2
  14. package/dist/chunks/{types-AjJyXA62.d.ts → types-CkaHVgDO.d.ts} +58 -2
  15. package/dist/chunks/{workers-types-B6F5WEuu.d.ts → workers-types-BjNko_ZU.d.ts} +1 -1
  16. package/dist/client.d.ts +1 -1
  17. package/dist/diagnostics.d.ts +1 -1
  18. package/dist/errors.d.ts +1 -1
  19. package/dist/http-paths.d.ts +1 -1
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +4 -4
  22. package/dist/internals.d.ts +1 -1
  23. package/dist/internals.js +2 -2
  24. package/dist/mcp/index.d.ts +1 -1
  25. package/dist/mcp/index.js +1 -1
  26. package/dist/mcp/tasks.d.ts +1 -1
  27. package/dist/project/config.d.ts +1 -1
  28. package/dist/project/index.d.ts +2 -2
  29. package/dist/project/index.js +2 -2
  30. package/dist/schemas.d.ts +1 -1
  31. package/dist/standard-failures.d.ts +1 -1
  32. package/dist/tooling/cli.js +1 -1
  33. package/dist/vite/index.d.ts +7 -1
  34. package/dist/vite/index.js +6 -4
  35. package/dist/webhooks.d.ts +1 -1
  36. package/dist/workers/runtime.d.ts +1 -1
  37. package/dist/workers/runtime.js +1 -1
  38. package/package.json +4 -4
  39. package/skills/maximus/references/project.md +1 -0
@@ -1,4 +1,4 @@
1
- import { Zn as Observer } from "../chunks/types-AjJyXA62.js";
1
+ import { rr as Observer } from "../chunks/types-CkaHVgDO.js";
2
2
  import { Static, Type } from "typebox";
3
3
  /** An analytics event: the allowlisted metadata of one operation call, flattened, with an id of its own. */
4
4
  export declare const ExecutionEventSchema: Type.TObject<{
package/dist/body.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as readBodyText, c as isJsonMediaType, d as retryAfterSeconds, f as publicDestination, g as readBodyBytes, h as HttpBodyFailureReason, l as readJsonBody, m as HttpBodyFailure, p as BodyReadOptions, u as readJsonResponse } from "./chunks/types-AjJyXA62.js";
1
+ import { _ as readBodyText, c as isJsonMediaType, d as retryAfterSeconds, f as publicDestination, g as readBodyBytes, h as HttpBodyFailureReason, l as readJsonBody, m as HttpBodyFailure, p as BodyReadOptions, u as readJsonResponse } from "./chunks/types-CkaHVgDO.js";
2
2
  export { type BodyReadOptions, type HttpBodyFailure, type HttpBodyFailureReason, isJsonMediaType, publicDestination, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, retryAfterSeconds };
@@ -1,4 +1,4 @@
1
- import { Bn as CaptureDimensions, Cr as CaptureRecord, Hn as CaptureSink, Kt as RegisteredEnv, Rn as AnyContext, Vn as CaptureInvocation, ct as withoutSecrets, wr as CaptureRecordSchema, zn as CaptureConfig } from "../chunks/types-AjJyXA62.js";
1
+ import { Ar as CaptureRecordSchema, Gn as CaptureConfig, Jn as CaptureSink, Kn as CaptureDimensions, Kt as RegisteredEnv, Wn as AnyContext, ct as withoutSecrets, kr as CaptureRecord, qn as CaptureInvocation } from "../chunks/types-CkaHVgDO.js";
2
2
  /** What `pipeline()` takes. */
3
3
  interface PipelineOptions<E> {
4
4
  /**
@@ -4,7 +4,7 @@ import { a as operationPathParameters, r as isInputHeaderName, t as createHttpRo
4
4
  import { R as holdsSecrets, T as hasUncompiledCodecs } from "./schemas-_UJcx_uY.js";
5
5
  import { t as pathParameterSchemas } from "./http-routes-B6tCsnxB.js";
6
6
  import { b as operationScopes, d as MAX_BODY_BYTES_CEILING, f as STANDARD_CODES, t as MAX_TASK_TTL_MS, x as isNamespacedScope } from "./tasks-CD-B6_nv.js";
7
- import { g as hasSchemaReferences, m as bundleSchemas, o as tokenAudiences, t as checkTokenAuthority } from "./tokens-D6yVDtEU.js";
7
+ import { b as checkRoles, g as hasSchemaReferences, m as bundleSchemas, o as tokenAudiences, t as checkTokenAuthority } from "./tokens-BtC4LJ8a.js";
8
8
  import { IsKind } from "typebox";
9
9
 
10
10
  // src/internal/exact-length.ts
@@ -208,6 +208,7 @@ function checkApplication(manifest) {
208
208
  checkTelemetry(manifest.telemetry);
209
209
  checkCapture(manifest.capture);
210
210
  checkMeter(manifest.meter);
211
+ checkRoles(manifest);
211
212
  checkTokenAuthority(manifest.tokens, manifest.namespace);
212
213
  tokenAudiences(manifest.tokens);
213
214
  if (Object.keys(manifest.tokens.resources ?? {}).length > 0 && manifest.tokens.resourceMetadataUrl === void 0) throw new TypeError("tokens.resources requires tokens.resourceMetadataUrl: name the metadata a 401 challenge points at.");
@@ -1,4 +1,4 @@
1
- import { f as usesCloudflareAccess, l as usesOwnBearer } from "./tokens-D6yVDtEU.js";
1
+ import { f as usesCloudflareAccess, l as usesOwnBearer } from "./tokens-BtC4LJ8a.js";
2
2
 
3
3
  // src/internal/http-layout.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { f as Value, t as admitInput } from "./validation-CpzAxj2_.js";
2
2
  import { B as withoutSecrets, R as holdsSecrets } from "./schemas-_UJcx_uY.js";
3
3
  import { i as standardErrors } from "./errors-BoutSmiy.js";
4
- import { a as isAttachmentSchema, o as validAttachment } from "./define-app-BpSKvXET.js";
4
+ import { a as isAttachmentSchema, o as validAttachment } from "./define-app-DLftS8E6.js";
5
5
  import { b as operationScopes, c as ADMISSION_CODES, f as STANDARD_CODES, l as BODY_CODES, v as operationMatchesScopes, y as operationOutputLimit } from "./tasks-CD-B6_nv.js";
6
6
  import { t as err } from "./result-CF4OzG9O.js";
7
7
  import { t as sha256Hex } from "./digest-C51F1bhA.js";
@@ -1,4 +1,4 @@
1
- import { _ as schemaIds, f as usesCloudflareAccess, h as canonical, m as bundleSchemas, s as tokenEndpoints } from "./tokens-D6yVDtEU.js";
1
+ import { S as resolveRoles, _ as schemaIds, f as usesCloudflareAccess, h as canonical, m as bundleSchemas, s as tokenEndpoints } from "./tokens-BtC4LJ8a.js";
2
2
  import { a as operationPathParameters } from "./http-paths-D043DkJv.js";
3
3
  import { L as wireInput } from "./schemas-_UJcx_uY.js";
4
4
  import { t as queryKind } from "./query-kind-CWKAXEME.js";
@@ -323,7 +323,8 @@ function bodyWithoutPathParameters(input, names) {
323
323
  * The document the origin serves at `/openapi.json`: every public operation that declares an HTTP route,
324
324
  * never an internal one, under one tag per group. Each request body, success envelope and failure is a named
325
325
  * component, which a generated client names its types after; each operation also carries its scopes,
326
- * effect, limits in force, MCP tool hints and native RPC as `x-*` extensions.
326
+ * effect, limits in force, MCP tool hints and native RPC as `x-*` extensions. An application that declares
327
+ * roles publishes each with the scopes it holds, as `x-maximus-roles`.
327
328
  *
328
329
  * Every schema reference in it is a local `#/components/schemas/<name>` pointer: the `$id`-named
329
330
  * schemas of its paths and components (TypeBox Cyclic/Ref) become components, as `bundleSchemas`
@@ -478,6 +479,7 @@ function openApiDocument(manifest, kind) {
478
479
  } : { name: group };
479
480
  }),
480
481
  paths,
482
+ ...rpc || !manifest.roles ? {} : { "x-maximus-roles": resolveRoles(manifest) },
481
483
  components: {
482
484
  schemas: components.schemas,
483
485
  ...headers.size ? { headers: Object.fromEntries([...headers].map((name) => [name, HEADERS[name]])) } : {},
@@ -1,4 +1,4 @@
1
- import { n as createRpcOpenApi } from "./openapi-C2A4SxMi.js";
1
+ import { n as createRpcOpenApi } from "./openapi-7EYOVkFi.js";
2
2
  import { t as prepareConfiguredProject } from "./prepare-configured-Cithjf80.js";
3
3
  import { t as packageDirectory } from "./scaffold-BfrJN0Yk.js";
4
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { a as ownsPrefix, i as nativePaths, t as VERSIONED_PATH } from "./http-layout-BsQlLNeo.js";
1
+ import { a as ownsPrefix, i as nativePaths, t as VERSIONED_PATH } from "./http-layout-CaZSEy2I.js";
2
2
 
3
3
  // src/project/pages.ts
4
4
  /**
@@ -1,8 +1,8 @@
1
- import { n as executeOperation, r as recordCapture, t as recordMeter } from "./meter-B_WuFl_c.js";
1
+ import { n as executeOperation, r as recordCapture, t as recordMeter } from "./meter-77troMd8.js";
2
2
  import { i as standardErrors } from "./errors-BoutSmiy.js";
3
- import { r as createHttpHandler } from "./src-CYk0Af0t.js";
3
+ import { r as createHttpHandler } from "./src-pzoGmAK9.js";
4
4
  import { r as ok, t as err } from "./result-CF4OzG9O.js";
5
- import { p as PrincipalSchema } from "./tokens-D6yVDtEU.js";
5
+ import { p as PrincipalSchema } from "./tokens-BtC4LJ8a.js";
6
6
  import { i as parseInput } from "./validation-CpzAxj2_.js";
7
7
  import { a as recordExecution, l as withTelemetry, o as reportUnexpected, s as telemetryEnabled } from "./telemetry-BtxJh69Q.js";
8
8
  import { r as isRequestId } from "./correlation-4b23a-a4.js";
@@ -2,7 +2,7 @@ import { d as MAX_BODY_BYTES_CEILING, h as mcpOpenWorld, v as operationMatchesSc
2
2
  import { o as reportUnexpected } from "./telemetry-BtxJh69Q.js";
3
3
  import { i as standardErrors } from "./errors-BoutSmiy.js";
4
4
  import { L as wireInput } from "./schemas-_UJcx_uY.js";
5
- import { h as canonical, v as standaloneSchema } from "./tokens-D6yVDtEU.js";
5
+ import { h as canonical, v as standaloneSchema } from "./tokens-BtC4LJ8a.js";
6
6
  import { t as toYaml } from "./yaml-Dk2L24yQ.js";
7
7
  import { a as mcpTask, n as attachTasks, o as toolResult, r as declaresTasks } from "./tasks-DELqUSq8.js";
8
8
  import { McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler } from "@modelcontextprotocol/server";
@@ -1,14 +1,14 @@
1
- import { i as binaryBody, n as defineApp, r as attachmentResponse } from "./define-app-BpSKvXET.js";
1
+ import { i as binaryBody, n as defineApp, r as attachmentResponse } from "./define-app-DLftS8E6.js";
2
2
  import { a as taskAccess, b as operationScopes, m as isPublicOperation, o as taskView, p as composeOperations, s as withTaskOperations, u as DEFAULT_MAX_BODY_BYTES, v as operationMatchesScopes } from "./tasks-CD-B6_nv.js";
3
3
  import { r as ok, t as err } from "./result-CF4OzG9O.js";
4
4
  import { i as standardErrors } from "./errors-BoutSmiy.js";
5
- import { c as tokenIssuer, i as presentedToken, n as createTokenAuthorization, o as tokenAudiences, u as isCrossSiteWrite } from "./tokens-D6yVDtEU.js";
6
- import { n as executeOperation, r as recordCapture, t as recordMeter } from "./meter-B_WuFl_c.js";
5
+ import { c as tokenIssuer, i as presentedToken, n as createTokenAuthorization, o as tokenAudiences, u as isCrossSiteWrite } from "./tokens-BtC4LJ8a.js";
6
+ import { n as executeOperation, r as recordCapture, t as recordMeter } from "./meter-77troMd8.js";
7
7
  import { t as createHttpRouteResolver } from "./http-paths-D043DkJv.js";
8
8
  import { r as readBodyText } from "./body-DOIHwIIl.js";
9
9
  import { t as sha256Hex } from "./digest-C51F1bhA.js";
10
- import { a as ownsPrefix, i as nativePaths, n as composition, o as servesCloudflareAccess, r as httpTransports, s as servesOwnBearer, t as VERSIONED_PATH } from "./http-layout-BsQlLNeo.js";
11
- import { i as queryKinds, r as queryInput, t as createOpenApi } from "./openapi-C2A4SxMi.js";
10
+ import { a as ownsPrefix, i as nativePaths, n as composition, o as servesCloudflareAccess, r as httpTransports, s as servesOwnBearer, t as VERSIONED_PATH } from "./http-layout-CaZSEy2I.js";
11
+ import { i as queryKinds, r as queryInput, t as createOpenApi } from "./openapi-7EYOVkFi.js";
12
12
  import { n as mediaType } from "./json-B14evE6-.js";
13
13
  import { t as toYaml } from "./yaml-Dk2L24yQ.js";
14
14
  import { a as recordExecution, i as recordAdmission, l as withTelemetry, o as reportUnexpected, s as telemetryEnabled } from "./telemetry-BtxJh69Q.js";
@@ -2,12 +2,91 @@ import { i as parseInput } from "./validation-CpzAxj2_.js";
2
2
  import { i as UuidSchema, n as OrganizationIdSchema, z as withoutSecretKeyword } from "./schemas-_UJcx_uY.js";
3
3
  import { t as isRecord } from "./record-DQUDTpEA.js";
4
4
  import { i as standardErrors } from "./errors-BoutSmiy.js";
5
- import { S as matchesScopes, x as isNamespacedScope } from "./tasks-CD-B6_nv.js";
5
+ import { S as matchesScopes, b as operationScopes, m as isPublicOperation, x as isNamespacedScope } from "./tasks-CD-B6_nv.js";
6
6
  import { r as ok, t as err } from "./result-CF4OzG9O.js";
7
7
  import { t as sha256Hex } from "./digest-C51F1bhA.js";
8
8
  import { Type } from "typebox";
9
9
  import { createRemoteJWKSet, jwtVerify } from "jose";
10
10
 
11
+ // src/roles.ts
12
+ /**
13
+ * A service's roles: what a person, or a key that stands for one, may do there, in the few words an
14
+ * administrator chooses among. A role names resources and what it may do with them; its scopes are derived
15
+ * from that, so nobody lists permissions by hand.
16
+ */
17
+ /** The most roles a service declares: few enough that each is explained in one sentence. */
18
+ const MAX_ROLES = 3;
19
+ /**
20
+ * Declares a service's roles for its application's `roles`. It returns them unchanged: what it adds is the
21
+ * type check that a role extends another declared role and never itself. `.build()` checks the rest
22
+ * against the application's operations.
23
+ */
24
+ function defineRoles(roles) {
25
+ return roles;
26
+ }
27
+ const ROLE_NAME = /^[a-z][a-z0-9-]{1,31}$/;
28
+ const ROLE_FIELDS = /* @__PURE__ */ new Set([
29
+ "description",
30
+ "extends",
31
+ "can",
32
+ "all"
33
+ ]);
34
+ /** Every scope a public operation takes: the ones that admit a call and the ones its handler checks. */
35
+ function publicScopes(operations) {
36
+ return new Set(Object.values(operations).filter(isPublicOperation).flatMap((operation) => [...operationScopes(operation), ...operation.conditionalScopes ?? []]));
37
+ }
38
+ /** The scopes a role names itself, without the ones it extends. */
39
+ function ownScopes(namespace, role) {
40
+ return Object.entries(role.can ?? {}).flatMap(([action, resources]) => resources.map((resource) => `${namespace}:${resource}:${action}`));
41
+ }
42
+ /**
43
+ * Each role of an application with every scope it holds; an application without roles has none. Call it on
44
+ * a built application: `.build()` has then checked the roles, and this only expands them.
45
+ */
46
+ function resolveRoles(application) {
47
+ const roles = application.roles ?? {};
48
+ const everything = publicScopes(application.operations);
49
+ const resolved = /* @__PURE__ */ new Map();
50
+ const scopesOf = (name, path) => {
51
+ const known = resolved.get(name);
52
+ if (known) return known;
53
+ const role = roles[name];
54
+ if (!role || path.includes(name)) throw new TypeError(`Role "${path[0] ?? name}": it extends a role that is not declared, or itself.`);
55
+ const scopes = role.all ? [...everything] : [...ownScopes(application.namespace, role), ...role.extends ? scopesOf(role.extends, [...path, name]) : []];
56
+ const sorted = [...new Set(scopes)].toSorted();
57
+ resolved.set(name, sorted);
58
+ return sorted;
59
+ };
60
+ return Object.fromEntries(Object.entries(roles).map(([name, role]) => [name, {
61
+ description: role.description,
62
+ permissions: scopesOf(name, [])
63
+ }]));
64
+ }
65
+ /**
66
+ * Refuses roles an application cannot have, with a TypeError that names the role: more than `MAX_ROLES`, a
67
+ * name that is not a word, an unknown field, a missing description, `all` beside `can` or `extends`, a role
68
+ * extending an undeclared one or itself, a scope no public operation takes, and a role that holds nothing.
69
+ * Roles need not cover every public operation: one that takes a scope no role names is for whoever holds
70
+ * that scope otherwise, such as the service's staff or an organization's owner.
71
+ */
72
+ function checkRoles(application) {
73
+ const { roles } = application;
74
+ if (roles === void 0) return;
75
+ const names = Object.keys(roles);
76
+ if (names.length === 0 || names.length > 3) throw new TypeError(`An application declares between one and ${3} roles, or none at all.`);
77
+ const everything = publicScopes(application.operations);
78
+ for (const [name, role] of Object.entries(roles)) {
79
+ if (!ROLE_NAME.test(name)) throw new TypeError(`Role "${name}": a role's name is a lowercase kebab-case word of 2 to 32 characters.`);
80
+ const unknown = Object.keys(role).find((field) => !ROLE_FIELDS.has(field));
81
+ if (unknown) throw new TypeError(`Role "${name}": "${unknown}" is not a role field.`);
82
+ if (typeof role.description !== "string" || !role.description.trim()) throw new TypeError(`Role "${name}": a description says what the role is for.`);
83
+ if (role.all !== void 0 && (role.all !== true || role.can !== void 0 || role.extends !== void 0)) throw new TypeError(`Role "${name}": "all: true" stands alone, without "can" or "extends".`);
84
+ for (const scope of ownScopes(application.namespace, role)) if (!isNamespacedScope(scope, application.namespace) || !everything.has(scope)) throw new TypeError(`Role "${name}": no public operation takes the scope "${scope}".`);
85
+ }
86
+ const resolved = resolveRoles(application);
87
+ for (const [name, role] of Object.entries(resolved)) if (role.permissions.length === 0) throw new TypeError(`Role "${name}": it holds no scope.`);
88
+ }
89
+
11
90
  // src/schema-bundle.ts
12
91
  /**
13
92
  * Schema bundling: named schemas (`$id`) become shared components for an OpenAPI document, or are written
@@ -702,4 +781,4 @@ function createTokenAuthorization(policy, given) {
702
781
  };
703
782
  }
704
783
 
705
- export { schemaIds as _, projectToken as a, tokenIssuer as c, projectAccessToken as d, usesCloudflareAccess as f, hasSchemaReferences as g, canonical as h, presentedToken as i, usesOwnBearer as l, bundleSchemas as m, createTokenAuthorization as n, tokenAudiences as o, PrincipalSchema as p, createTokenVerifier as r, tokenEndpoints as s, checkTokenAuthority as t, isCrossSiteWrite as u, standaloneSchema as v };
784
+ export { resolveRoles as S, schemaIds as _, projectToken as a, checkRoles as b, tokenIssuer as c, projectAccessToken as d, usesCloudflareAccess as f, hasSchemaReferences as g, canonical as h, presentedToken as i, usesOwnBearer as l, bundleSchemas as m, createTokenAuthorization as n, tokenAudiences as o, PrincipalSchema as p, createTokenVerifier as r, tokenEndpoints as s, checkTokenAuthority as t, isCrossSiteWrite as u, standaloneSchema as v, defineRoles as x, MAX_ROLES as y };
@@ -1121,6 +1121,54 @@ interface MeterApplication<E> {
1121
1121
  * failure, without a background context, or while the env has no such binding, as in a preview.
1122
1122
  */
1123
1123
  declare function recordMeter<E>(application: MeterApplication<E>, env: E, background: BackgroundContext | undefined, metered: MeteredCall): void;
1124
+ /** The most roles a service declares: few enough that each is explained in one sentence. */
1125
+ declare const MAX_ROLES = 3;
1126
+ /** One role of a service. */
1127
+ interface RoleDefinition<Name extends string = string> {
1128
+ /** What the role is for, in a sentence a person reads before giving it. */
1129
+ description: string;
1130
+ /** Another role of the service this one includes: whatever that role may do, this one may too. */
1131
+ extends?: Name;
1132
+ /**
1133
+ * What the role may do, by action: `{ read: ['notes'], write: ['notes'] }` holds `<namespace>:notes:read`
1134
+ * and `<namespace>:notes:write`. Each scope it names is one a public operation takes.
1135
+ */
1136
+ can?: Readonly<Record<string, readonly string[]>>;
1137
+ /**
1138
+ * Every scope a public operation takes, the ones its handler checks included. A role with it declares
1139
+ * neither `can` nor `extends`. Only for a service whose public operations take no scope reserved for its own
1140
+ * staff or for a machine: where one does, as an alternative or a conditional scope, `all` would hand it to
1141
+ * whoever holds the role, so list `can` instead.
1142
+ */
1143
+ all?: true;
1144
+ }
1145
+ /** A service's roles by name: a lowercase kebab-case word, such as `viewer`. At most `MAX_ROLES`. */
1146
+ type RoleDefinitions = Readonly<Record<string, RoleDefinition>>;
1147
+ /** A role as it is published: what it is for and every scope it holds, the ones it extends included. */
1148
+ interface ResolvedRole {
1149
+ description: string;
1150
+ /** In name order, each once. */
1151
+ permissions: readonly string[];
1152
+ }
1153
+ /** Refuses, in the type, a role field no role has, such as a misspelled one, which would do nothing. */
1154
+ type KnownRoleFields<R> = Readonly<Record<Exclude<keyof R, keyof RoleDefinition>, never>>;
1155
+ /**
1156
+ * Declares a service's roles for its application's `roles`. It returns them unchanged: what it adds is the
1157
+ * type check that a role extends another declared role and never itself. `.build()` checks the rest
1158
+ * against the application's operations.
1159
+ */
1160
+ declare function defineRoles<const R extends { readonly [K in keyof R]: RoleDefinition<Exclude<Extract<keyof R, string>, K>> & KnownRoleFields<R[K]>; }>(roles: R): R;
1161
+ /** What `resolveRoles` and `checkRoles` read of an application. */
1162
+ interface RoleSource {
1163
+ namespace: string;
1164
+ operations: Readonly<Record<string, OperationShape>>;
1165
+ roles?: RoleDefinitions;
1166
+ }
1167
+ /**
1168
+ * Each role of an application with every scope it holds; an application without roles has none. Call it on
1169
+ * a built application: `.build()` has then checked the roles, and this only expands them.
1170
+ */
1171
+ declare function resolveRoles(application: RoleSource): Record<string, ResolvedRole>;
1124
1172
  /**
1125
1173
  * A schema's JSON Schema keywords, as Maximus reads them to publish, route and check a contract. TypeBox 1.x
1126
1174
  * types a schema without its options, so a service reads one through this view:
@@ -1492,6 +1540,13 @@ interface AppManifest<Env, C, Ops extends Record<string, OperationShape>> {
1492
1540
  * `{ Notes: "The notes of the caller's organization." }`: the description of its OpenAPI tag.
1493
1541
  */
1494
1542
  groups?: Readonly<Record<string, string>>;
1543
+ /**
1544
+ * The service's roles, from `defineRoles()`: at most three, each saying what it may do with the service's
1545
+ * resources. `.build()` refuses a role that names a scope no public operation takes; the OpenAPI document
1546
+ * publishes each role with the scopes it holds. Omitted, the service declares no roles and who holds its
1547
+ * scopes is decided elsewhere.
1548
+ */
1549
+ roles?: RoleDefinitions;
1495
1550
  /**
1496
1551
  * The service's version: OpenAPI `info.version`, the MCP server version and the `version` that `/health`
1497
1552
  * reports.
@@ -2914,7 +2969,8 @@ declare function retryAfterSeconds(value: string | null, nowMs: number, maximum?
2914
2969
  * The document the origin serves at `/openapi.json`: every public operation that declares an HTTP route,
2915
2970
  * never an internal one, under one tag per group. Each request body, success envelope and failure is a named
2916
2971
  * component, which a generated client names its types after; each operation also carries its scopes,
2917
- * effect, limits in force, MCP tool hints and native RPC as `x-*` extensions.
2972
+ * effect, limits in force, MCP tool hints and native RPC as `x-*` extensions. An application that declares
2973
+ * roles publishes each with the scopes it holds, as `x-maximus-roles`.
2918
2974
  *
2919
2975
  * Every schema reference in it is a local `#/components/schemas/<name>` pointer: the `$id`-named
2920
2976
  * schemas of its paths and components (TypeBox Cyclic/Ref) become components, as `bundleSchemas`
@@ -2944,4 +3000,4 @@ declare function createRpcOpenApi<E, C, O extends Record<string, OperationShape>
2944
3000
  * the argument.
2945
3001
  */
2946
3002
  declare function defineApp<Env, C>(): <const Ops extends Record<string, OperationShape>>(manifest: AppManifest<Env, C, Ops>) => AppManifest<Env, C, Ops>;
2947
- export { PageInfo as $, diagnosticsEnabled as $n, defineContext as $t, TransportContext as A, LimitVerdict as An, err as Ar, decodeSchema as At, DeletedObject as B, CaptureDimensions as Bn, Failure as Br, HandlerArguments as Bt, isPathParameterValue as C, isPublicOperation as Cn, CaptureRecord as Cr, stripObject as Ct, HttpRoute as D, SchemaKeywords as Dn, FailureResult as Dr, SchemaValidationError as Dt, HttpOptions as E, operationScopes as En, BodyFailure as Er, SchemaIssue as Et, Static$2 as F, UsageEvent as Fn, CreateArguments as Fr, ContextDeclaration as Ft, NamedReference as G, recordCapture as Gn, standardErrors as Gr, PreparedContext as Gt, EmailAddressSchema as H, CaptureSink as Hn, FailureSchema as Hr, HandlerHttp as Ht, TSchema$2 as I, UsageReceipt as In, DefinedErrors as Ir, DomainCode as It, PostalAddress as J, AdmissionObservation as Jn, createRequestId as Jr, SchemaOf as Jt, NamedReferenceSchema as K, ExecutionCall as Kn, DurableCorrelation as Kr, RegisteredEnv as Kt, Type$2 as L, recordMeter as Ln, ErrorCatalog as Lr, Fail as Lt, projectAccessToken as M, OperationMeter as Mn, ok as Mr, parseSchema as Mt, EmptyInputSchema as N, SpendVerdict as Nn, Attachment as Nr, AuthOptions as Nt, HttpTransport as O, StaticDecode as On, Result as Or, InputIssue as Ot, OrganizationIdSchema as P, TokenUsage as Pn, AttachmentOutputSchema as Pr, ContextArguments as Pt, Page as Q, TelemetryConfig as Qn, defineAuth as Qt, UuidSchema as R, AnyContext as Rn, ErrorDefinition as Rr, Failed as Rt, isInputHeaderName as S, composeOperations as Sn, protectedResourceMetadata as Sr, strictObject as St, HttpMiddleware as T, operationMatchesScopes as Tn, BinaryBody as Tr, urlSchema as Tt, HexColorSchema as U, CapturedCall as Un, defineErrors as Ur, HandlerMcp as Ut, DeletedObjectSchema as V, CaptureInvocation as Vn, FailureData as Vr, HandlerDeclaration as Vt, HttpsUrlSchema as W, VerifiedCaller as Wn, resultSchema as Wr, HandlerOptions as Wt, SignedUrl as X, ExecutionObservation as Xn, isRequestId as Xr, ToolDeclaration as Xt, PostalAddressSchema as Y, BackgroundContext as Yn, durableCorrelation as Yr, SchemaOrFields as Yt, SignedUrlSchema as Z, Observer as Zn, parseTraceParent as Zr, ToolOptions as Zt, readBodyText as _, McpSkill as _n, Principal as _r, literalUnion as _t, t as a, ApplicationBuilder as an, TokenAlgorithm as ar, cursorKey as at, createHttpRouteResolver as b, OperationScope as bn, TokenPrincipal as br, pipeSchema as bt, isJsonMediaType as c, TaskAccess as cn, TokenPolicy as cr, withoutSecrets as ct, retryAfterSeconds as d, AppManifest as dn, TokenSource as dr, readSchema as dt, defineHandler as en, recordExecution as er, PageInfoSchema as et, publicDestination as f, Exposure as fn, createTokenAuthorization as fr, SchemaInput as ft, readBodyBytes as g, McpGuide as gn, matchesScopes as gr, inspectSchema as gt, HttpBodyFailureReason as h, McpConfiguration as hn, ScopeMatch as hr, inputSchema as ht, Type$1 as i, StandardFailure as in, TokenAccess as ir, TPage as it, createHttpHandler as j, MeteredCall as jn, isResult as jr, parseInput as jt, RouteContext as k, BillingService as kn, Success as kr, decodeInput as kt, readJsonBody as l, TaskRecord as ln, TokenResolutionContext as lr, Checked as lt, HttpBodyFailure as m, InvocationAuthority as mn, projectToken as mr, extendObject as mt, Static$1 as n, defineTool as nn, telemetryEnabled as nr, PageQuery as nt, createOpenApi as o, ApplicationConfiguration as on, TokenClaims as or, cutPage as ot, BodyReadOptions as p, Invocation as pn, createTokenVerifier as pr, defaultSchema as pt, PhoneNumberSchema as q, executeOperation as qn, TraceParent as qr, RouteBody as qt, TSchema$1 as r, STANDARD_FAILURES as rn, withDiagnostics as rr, PageQueryFields as rt, createRpcOpenApi as s, maximus as sn, TokenDevelopment as sr, pageLimit as st, defineApp as t, defineTelemetry as tn, reportUnexpected as tr, PageOrder as tt, readJsonResponse as u, TaskStore as un, TokenScheme as ur, checkSchema as ut, HttpRouteDefinition as v, OperationHandler as vn, PrincipalSchema as vr, looseObject as vt, operationPathParameters as w, operation as wn, CaptureRecordSchema as wr, transformSchema as wt, decodePathParameter as x, OperationShape as xn, OAuthResource as xr, refineSchema as xt, HttpRouteMatch as y, OperationMiddleware as yn, TokenClient as yr, normalizeSchema as yt, t$1 as z, CaptureConfig as zn, ErrorFactory as zr, HandlerAnswer as zt };
3003
+ export { PageInfo as $, executeOperation as $n, TraceParent as $r, defineContext as $t, TransportContext as A, ResolvedRole as An, CaptureRecordSchema as Ar, decodeSchema as At, DeletedObject as B, TokenUsage as Bn, AttachmentOutputSchema as Br, HandlerArguments as Bt, isPathParameterValue as C, isPublicOperation as Cn, Principal as Cr, stripObject as Ct, HttpRoute as D, SchemaKeywords as Dn, OAuthResource as Dr, SchemaValidationError as Dt, HttpOptions as E, operationScopes as En, TokenPrincipal as Er, SchemaIssue as Et, Static$2 as F, BillingService as Fn, Success as Fr, ContextDeclaration as Ft, NamedReference as G, CaptureConfig as Gn, ErrorFactory as Gr, PreparedContext as Gt, EmailAddressSchema as H, UsageReceipt as Hn, DefinedErrors as Hr, HandlerHttp as Ht, TSchema$2 as I, LimitVerdict as In, err as Ir, DomainCode as It, PostalAddress as J, CaptureSink as Jn, FailureSchema as Jr, SchemaOf as Jt, NamedReferenceSchema as K, CaptureDimensions as Kn, Failure as Kr, RegisteredEnv as Kt, Type$2 as L, MeteredCall as Ln, isResult as Lr, Fail as Lt, projectAccessToken as M, RoleDefinitions as Mn, BodyFailure as Mr, parseSchema as Mt, EmptyInputSchema as N, defineRoles as Nn, FailureResult as Nr, AuthOptions as Nt, HttpTransport as O, StaticDecode as On, protectedResourceMetadata as Or, InputIssue as Ot, OrganizationIdSchema as P, resolveRoles as Pn, Result as Pr, ContextArguments as Pt, Page as Q, ExecutionCall as Qn, DurableCorrelation as Qr, defineAuth as Qt, UuidSchema as R, OperationMeter as Rn, ok as Rr, Failed as Rt, isInputHeaderName as S, composeOperations as Sn, matchesScopes as Sr, strictObject as St, HttpMiddleware as T, operationMatchesScopes as Tn, TokenClient as Tr, urlSchema as Tt, HexColorSchema as U, recordMeter as Un, ErrorCatalog as Ur, HandlerMcp as Ut, DeletedObjectSchema as V, UsageEvent as Vn, CreateArguments as Vr, HandlerDeclaration as Vt, HttpsUrlSchema as W, AnyContext as Wn, ErrorDefinition as Wr, HandlerOptions as Wt, SignedUrl as X, VerifiedCaller as Xn, resultSchema as Xr, ToolDeclaration as Xt, PostalAddressSchema as Y, CapturedCall as Yn, defineErrors as Yr, SchemaOrFields as Yt, SignedUrlSchema as Z, recordCapture as Zn, standardErrors as Zr, ToolOptions as Zt, readBodyText as _, McpSkill as _n, TokenSource as _r, literalUnion as _t, t as a, ApplicationBuilder as an, diagnosticsEnabled as ar, cursorKey as at, createHttpRouteResolver as b, OperationScope as bn, projectToken as br, pipeSchema as bt, isJsonMediaType as c, TaskAccess as cn, telemetryEnabled as cr, withoutSecrets as ct, retryAfterSeconds as d, AppManifest as dn, TokenAlgorithm as dr, readSchema as dt, createRequestId as ei, defineHandler as en, AdmissionObservation as er, PageInfoSchema as et, publicDestination as f, Exposure as fn, TokenClaims as fr, SchemaInput as ft, readBodyBytes as g, McpGuide as gn, TokenScheme as gr, inspectSchema as gt, HttpBodyFailureReason as h, McpConfiguration as hn, TokenResolutionContext as hr, inputSchema as ht, Type$1 as i, StandardFailure as in, TelemetryConfig as ir, TPage as it, createHttpHandler as j, RoleDefinition as jn, BinaryBody as jr, parseInput as jt, RouteContext as k, MAX_ROLES as kn, CaptureRecord as kr, decodeInput as kt, readJsonBody as l, TaskRecord as ln, withDiagnostics as lr, Checked as lt, HttpBodyFailure as m, InvocationAuthority as mn, TokenPolicy as mr, extendObject as mt, Static$1 as n, isRequestId as ni, defineTool as nn, ExecutionObservation as nr, PageQuery as nt, createOpenApi as o, ApplicationConfiguration as on, recordExecution as or, cutPage as ot, BodyReadOptions as p, Invocation as pn, TokenDevelopment as pr, defaultSchema as pt, PhoneNumberSchema as q, CaptureInvocation as qn, FailureData as qr, RouteBody as qt, TSchema$1 as r, parseTraceParent as ri, STANDARD_FAILURES as rn, Observer as rr, PageQueryFields as rt, createRpcOpenApi as s, maximus as sn, reportUnexpected as sr, pageLimit as st, defineApp as t, durableCorrelation as ti, defineTelemetry as tn, BackgroundContext as tr, PageOrder as tt, readJsonResponse as u, TaskStore as un, TokenAccess as ur, checkSchema as ut, HttpRouteDefinition as v, OperationHandler as vn, createTokenAuthorization as vr, looseObject as vt, operationPathParameters as w, operation as wn, PrincipalSchema as wr, transformSchema as wt, decodePathParameter as x, OperationShape as xn, ScopeMatch as xr, refineSchema as xt, HttpRouteMatch as y, OperationMiddleware as yn, createTokenVerifier as yr, normalizeSchema as yt, t$1 as z, SpendVerdict as zn, Attachment as zr, HandlerAnswer as zt };
@@ -1,4 +1,4 @@
1
- import { Br as Failure, D as HttpRoute, E as HttpOptions, Or as Result, _r as Principal, dn as AppManifest, n as Static, r as TSchema, un as TaskStore, xn as OperationShape } from "./types-AjJyXA62.js";
1
+ import { Cr as Principal, D as HttpRoute, E as HttpOptions, Kr as Failure, Pr as Result, dn as AppManifest, n as Static, r as TSchema, un as TaskStore, xn as OperationShape } from "./types-CkaHVgDO.js";
2
2
  import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
3
3
  /** A Workers static-assets binding; product stores and secrets never satisfy this capability. */
4
4
  interface AssetBinding {
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Br as Failure, F as Static, xn as OperationShape } from "./chunks/types-AjJyXA62.js";
1
+ import { F as Static, Kr as Failure, xn as OperationShape } from "./chunks/types-CkaHVgDO.js";
2
2
  /** What every HTTP operation answers: its data on success, its failure otherwise, and the request id. */
3
3
  export type Envelope<T> = {
4
4
  success: true;
@@ -1,4 +1,4 @@
1
- import { $n as diagnosticsEnabled, Jr as createRequestId, Kr as DurableCorrelation, Qn as TelemetryConfig, Xn as ExecutionObservation, Xr as isRequestId, Yn as BackgroundContext, Yr as durableCorrelation, Zn as Observer, Zr as parseTraceParent, er as recordExecution, nr as telemetryEnabled, qr as TraceParent, rr as withDiagnostics, tr as reportUnexpected } from "./chunks/types-AjJyXA62.js";
1
+ import { $r as TraceParent, Qr as DurableCorrelation, ar as diagnosticsEnabled, cr as telemetryEnabled, ei as createRequestId, ir as TelemetryConfig, lr as withDiagnostics, ni as isRequestId, nr as ExecutionObservation, or as recordExecution, ri as parseTraceParent, rr as Observer, sr as reportUnexpected, ti as durableCorrelation, tr as BackgroundContext } from "./chunks/types-CkaHVgDO.js";
2
2
  /**
3
3
  * What diagnostics may say about an error: its name, its causes' names, its issue count and its stack
4
4
  * locations.
package/dist/errors.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Br as Failure, Fr as CreateArguments, Gr as standardErrors, Hr as FailureSchema, Ir as DefinedErrors, Lr as ErrorCatalog, Rr as ErrorDefinition, Ur as defineErrors, Vr as FailureData, Wr as resultSchema, Xr as isRequestId, zr as ErrorFactory } from "./chunks/types-AjJyXA62.js";
1
+ import { Gr as ErrorFactory, Hr as DefinedErrors, Jr as FailureSchema, Kr as Failure, Ur as ErrorCatalog, Vr as CreateArguments, Wr as ErrorDefinition, Xr as resultSchema, Yr as defineErrors, Zr as standardErrors, ni as isRequestId, qr as FailureData } from "./chunks/types-CkaHVgDO.js";
2
2
  export { CreateArguments, DefinedErrors, ErrorCatalog, ErrorDefinition, ErrorFactory, Failure, FailureData, FailureSchema, defineErrors, isRequestId, resultSchema, standardErrors };
@@ -1,2 +1,2 @@
1
- import { C as isPathParameterValue, S as isInputHeaderName, b as createHttpRouteResolver, v as HttpRouteDefinition, w as operationPathParameters, x as decodePathParameter, y as HttpRouteMatch } from "./chunks/types-AjJyXA62.js";
1
+ import { C as isPathParameterValue, S as isInputHeaderName, b as createHttpRouteResolver, v as HttpRouteDefinition, w as operationPathParameters, x as decodePathParameter, y as HttpRouteMatch } from "./chunks/types-CkaHVgDO.js";
2
2
  export { HttpRouteDefinition, HttpRouteMatch, createHttpRouteResolver, decodePathParameter, isInputHeaderName, isPathParameterValue, operationPathParameters };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as PageInfo, $t as defineContext, A as TransportContext, An as LimitVerdict, Ar as err, B as DeletedObject, Br as Failure, Bt as HandlerArguments, Cn as isPublicOperation, D as HttpRoute, Dn as SchemaKeywords, Dr as FailureResult, E as HttpOptions, En as operationScopes, Er as BodyFailure, Fn as UsageEvent, Ft as ContextDeclaration, G as NamedReference, Gr as standardErrors, Gt as PreparedContext, H as EmailAddressSchema, Hr as FailureSchema, Ht as HandlerHttp, In as UsageReceipt, Ir as DefinedErrors, It as DomainCode, J as PostalAddress, Jn as AdmissionObservation, Jt as SchemaOf, K as NamedReferenceSchema, Lr as ErrorCatalog, Lt as Fail, M as projectAccessToken, Mn as OperationMeter, Mr as ok, Mt as parseSchema, N as EmptyInputSchema, Nn as SpendVerdict, Nr as Attachment, Nt as AuthOptions, O as HttpTransport, Or as Result, P as OrganizationIdSchema, Pn as TokenUsage, Pr as AttachmentOutputSchema, Pt as ContextArguments, Q as Page, Qn as TelemetryConfig, Qt as defineAuth, R as UuidSchema, Rr as ErrorDefinition, Rt as Failed, Sr as protectedResourceMetadata, T as HttpMiddleware, Tn as operationMatchesScopes, Tr as BinaryBody, U as HexColorSchema, Ur as defineErrors, Ut as HandlerMcp, V as DeletedObjectSchema, Vr as FailureData, Vt as HandlerDeclaration, W as HttpsUrlSchema, Wr as resultSchema, Wt as HandlerOptions, X as SignedUrl, Xn as ExecutionObservation, Xt as ToolDeclaration, Y as PostalAddressSchema, Yn as BackgroundContext, Yt as SchemaOrFields, Z as SignedUrlSchema, Zn as Observer, Zt as ToolOptions, _ as readBodyText, _n as McpSkill, _r as Principal, a as t, an as ApplicationBuilder, ar as TokenAlgorithm, at as cursorKey, b as createHttpRouteResolver, bn as OperationScope, br as TokenPrincipal, c as isJsonMediaType, cr as TokenPolicy, d as retryAfterSeconds, dn as AppManifest, dr as TokenSource, en as defineHandler, et as PageInfoSchema, f as publicDestination, fn as Exposure, fr as createTokenAuthorization, g as readBodyBytes, gn as McpGuide, gr as matchesScopes, h as HttpBodyFailureReason, hn as McpConfiguration, hr as ScopeMatch, i as Type, ir as TokenAccess, it as TPage, j as createHttpHandler, jr as isResult, jt as parseInput, k as RouteContext, kn as BillingService, kr as Success, l as readJsonBody, lr as TokenResolutionContext, m as HttpBodyFailure, mn as InvocationAuthority, mr as projectToken, n as Static, nn as defineTool, nt as PageQuery, o as createOpenApi, on as ApplicationConfiguration, or as TokenClaims, ot as cutPage, p as BodyReadOptions, pn as Invocation, pr as createTokenVerifier, q as PhoneNumberSchema, qt as RouteBody, r as TSchema, rt as PageQueryFields, s as createRpcOpenApi, sn as maximus, sr as TokenDevelopment, st as pageLimit, tn as defineTelemetry, tr as reportUnexpected, tt as PageOrder, u as readJsonResponse, ur as TokenScheme, v as HttpRouteDefinition, vr as PrincipalSchema, xn as OperationShape, xr as OAuthResource, y as HttpRouteMatch, yn as OperationMiddleware, yr as TokenClient, zr as ErrorFactory, zt as HandlerAnswer } from "./chunks/types-AjJyXA62.js";
2
- export { type AdmissionObservation, type AppManifest, type ApplicationBuilder, type ApplicationConfiguration, type Attachment, AttachmentOutputSchema, type AuthOptions, type BackgroundContext, type BillingService, type BinaryBody, type BodyFailure, type BodyReadOptions, type ContextArguments, type ContextDeclaration, type DefinedErrors, type DeletedObject, DeletedObjectSchema, type DomainCode, EmailAddressSchema, EmptyInputSchema, type ErrorCatalog, type ErrorDefinition, type ErrorFactory, type ExecutionObservation, type Exposure, type Fail, type Failed, type Failure, type FailureData, type FailureResult, FailureSchema, type HandlerAnswer, type HandlerArguments, type HandlerDeclaration, type HandlerHttp, type HandlerMcp, type HandlerOptions, HexColorSchema, type HttpBodyFailure, type HttpBodyFailureReason, type HttpMiddleware, type HttpOptions, type HttpRoute, type HttpRouteDefinition, type HttpRouteMatch, type HttpTransport, HttpsUrlSchema, type Invocation, type InvocationAuthority, type LimitVerdict, type McpConfiguration, type McpGuide, type McpSkill, type NamedReference, NamedReferenceSchema, type OAuthResource, type Observer, type OperationMeter, type OperationMiddleware, type OperationScope, type OperationShape, OrganizationIdSchema, Page, type PageInfo, PageInfoSchema, type PageOrder, type PageQuery, PageQueryFields, PhoneNumberSchema, type PostalAddress, PostalAddressSchema, type PreparedContext, type Principal, PrincipalSchema, type Result, type RouteBody, type RouteContext, type SchemaKeywords, type SchemaOf, type SchemaOrFields, type ScopeMatch, type SignedUrl, SignedUrlSchema, type SpendVerdict, type Static, type Success, type TPage, type TSchema, type TelemetryConfig, type TokenAccess, type TokenAlgorithm, type TokenClaims, type TokenClient, type TokenDevelopment, type TokenPolicy, type TokenPrincipal, type TokenResolutionContext, type TokenScheme, type TokenSource, type TokenUsage, type ToolDeclaration, type ToolOptions, type TransportContext, Type, type UsageEvent, type UsageReceipt, UuidSchema, createHttpHandler, createHttpRouteResolver, createOpenApi, createRpcOpenApi, createTokenAuthorization, createTokenVerifier, cursorKey, cutPage, defineAuth, defineContext, defineErrors, defineHandler, defineTelemetry, defineTool, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectAccessToken, projectToken, protectedResourceMetadata, publicDestination, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resultSchema, retryAfterSeconds, standardErrors, t };
1
+ import { $ as PageInfo, $t as defineContext, A as TransportContext, An as ResolvedRole, B as DeletedObject, Bn as TokenUsage, Br as AttachmentOutputSchema, Bt as HandlerArguments, Cn as isPublicOperation, Cr as Principal, D as HttpRoute, Dn as SchemaKeywords, Dr as OAuthResource, E as HttpOptions, En as operationScopes, Er as TokenPrincipal, Fn as BillingService, Fr as Success, Ft as ContextDeclaration, G as NamedReference, Gr as ErrorFactory, Gt as PreparedContext, H as EmailAddressSchema, Hn as UsageReceipt, Hr as DefinedErrors, Ht as HandlerHttp, In as LimitVerdict, Ir as err, It as DomainCode, J as PostalAddress, Jr as FailureSchema, Jt as SchemaOf, K as NamedReferenceSchema, Kr as Failure, Lr as isResult, Lt as Fail, M as projectAccessToken, Mn as RoleDefinitions, Mr as BodyFailure, Mt as parseSchema, N as EmptyInputSchema, Nn as defineRoles, Nr as FailureResult, Nt as AuthOptions, O as HttpTransport, Or as protectedResourceMetadata, P as OrganizationIdSchema, Pn as resolveRoles, Pr as Result, Pt as ContextArguments, Q as Page, Qt as defineAuth, R as UuidSchema, Rn as OperationMeter, Rr as ok, Rt as Failed, Sr as matchesScopes, T as HttpMiddleware, Tn as operationMatchesScopes, Tr as TokenClient, U as HexColorSchema, Ur as ErrorCatalog, Ut as HandlerMcp, V as DeletedObjectSchema, Vn as UsageEvent, Vt as HandlerDeclaration, W as HttpsUrlSchema, Wr as ErrorDefinition, Wt as HandlerOptions, X as SignedUrl, Xr as resultSchema, Xt as ToolDeclaration, Y as PostalAddressSchema, Yr as defineErrors, Yt as SchemaOrFields, Z as SignedUrlSchema, Zr as standardErrors, Zt as ToolOptions, _ as readBodyText, _n as McpSkill, _r as TokenSource, a as t, an as ApplicationBuilder, at as cursorKey, b as createHttpRouteResolver, bn as OperationScope, br as projectToken, c as isJsonMediaType, d as retryAfterSeconds, dn as AppManifest, dr as TokenAlgorithm, en as defineHandler, er as AdmissionObservation, et as PageInfoSchema, f as publicDestination, fn as Exposure, fr as TokenClaims, g as readBodyBytes, gn as McpGuide, gr as TokenScheme, h as HttpBodyFailureReason, hn as McpConfiguration, hr as TokenResolutionContext, i as Type, ir as TelemetryConfig, it as TPage, j as createHttpHandler, jn as RoleDefinition, jr as BinaryBody, jt as parseInput, k as RouteContext, kn as MAX_ROLES, l as readJsonBody, m as HttpBodyFailure, mn as InvocationAuthority, mr as TokenPolicy, n as Static, nn as defineTool, nr as ExecutionObservation, nt as PageQuery, o as createOpenApi, on as ApplicationConfiguration, ot as cutPage, p as BodyReadOptions, pn as Invocation, pr as TokenDevelopment, q as PhoneNumberSchema, qr as FailureData, qt as RouteBody, r as TSchema, rr as Observer, rt as PageQueryFields, s as createRpcOpenApi, sn as maximus, sr as reportUnexpected, st as pageLimit, tn as defineTelemetry, tr as BackgroundContext, tt as PageOrder, u as readJsonResponse, ur as TokenAccess, v as HttpRouteDefinition, vr as createTokenAuthorization, wr as PrincipalSchema, xn as OperationShape, xr as ScopeMatch, y as HttpRouteMatch, yn as OperationMiddleware, yr as createTokenVerifier, zn as SpendVerdict, zr as Attachment, zt as HandlerAnswer } from "./chunks/types-CkaHVgDO.js";
2
+ export { type AdmissionObservation, type AppManifest, type ApplicationBuilder, type ApplicationConfiguration, type Attachment, AttachmentOutputSchema, type AuthOptions, type BackgroundContext, type BillingService, type BinaryBody, type BodyFailure, type BodyReadOptions, type ContextArguments, type ContextDeclaration, type DefinedErrors, type DeletedObject, DeletedObjectSchema, type DomainCode, EmailAddressSchema, EmptyInputSchema, type ErrorCatalog, type ErrorDefinition, type ErrorFactory, type ExecutionObservation, type Exposure, type Fail, type Failed, type Failure, type FailureData, type FailureResult, FailureSchema, type HandlerAnswer, type HandlerArguments, type HandlerDeclaration, type HandlerHttp, type HandlerMcp, type HandlerOptions, HexColorSchema, type HttpBodyFailure, type HttpBodyFailureReason, type HttpMiddleware, type HttpOptions, type HttpRoute, type HttpRouteDefinition, type HttpRouteMatch, type HttpTransport, HttpsUrlSchema, type Invocation, type InvocationAuthority, type LimitVerdict, MAX_ROLES, type McpConfiguration, type McpGuide, type McpSkill, type NamedReference, NamedReferenceSchema, type OAuthResource, type Observer, type OperationMeter, type OperationMiddleware, type OperationScope, type OperationShape, OrganizationIdSchema, Page, type PageInfo, PageInfoSchema, type PageOrder, type PageQuery, PageQueryFields, PhoneNumberSchema, type PostalAddress, PostalAddressSchema, type PreparedContext, type Principal, PrincipalSchema, type ResolvedRole, type Result, type RoleDefinition, type RoleDefinitions, type RouteBody, type RouteContext, type SchemaKeywords, type SchemaOf, type SchemaOrFields, type ScopeMatch, type SignedUrl, SignedUrlSchema, type SpendVerdict, type Static, type Success, type TPage, type TSchema, type TelemetryConfig, type TokenAccess, type TokenAlgorithm, type TokenClaims, type TokenClient, type TokenDevelopment, type TokenPolicy, type TokenPrincipal, type TokenResolutionContext, type TokenScheme, type TokenSource, type TokenUsage, type ToolDeclaration, type ToolOptions, type TransportContext, Type, type UsageEvent, type UsageReceipt, UuidSchema, createHttpHandler, createHttpRouteResolver, createOpenApi, createRpcOpenApi, createTokenAuthorization, createTokenVerifier, cursorKey, cutPage, defineAuth, defineContext, defineErrors, defineHandler, defineRoles, defineTelemetry, defineTool, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectAccessToken, projectToken, protectedResourceMetadata, publicDestination, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resolveRoles, resultSchema, retryAfterSeconds, standardErrors, t };
package/dist/index.js CHANGED
@@ -4,13 +4,13 @@ import { i as standardErrors, n as defineErrors, r as resultSchema, t as Failure
4
4
  import { n as readBodyBytes, r as readBodyText } from "./chunks/body-DOIHwIIl.js";
5
5
  import { t as createHttpRouteResolver } from "./chunks/http-paths-D043DkJv.js";
6
6
  import { S as matchesScopes, b as operationScopes, m as isPublicOperation, v as operationMatchesScopes } from "./chunks/tasks-CD-B6_nv.js";
7
- import { a as projectToken, d as projectAccessToken, n as createTokenAuthorization, p as PrincipalSchema, r as createTokenVerifier } from "./chunks/tokens-D6yVDtEU.js";
7
+ import { S as resolveRoles, a as projectToken, d as projectAccessToken, n as createTokenAuthorization, p as PrincipalSchema, r as createTokenVerifier, x as defineRoles, y as MAX_ROLES } from "./chunks/tokens-BtC4LJ8a.js";
8
8
  import { n as isResult, r as ok, t as err } from "./chunks/result-CF4OzG9O.js";
9
- import { a as maximus, i as protectedResourceMetadata, n as t, r as createHttpHandler, t as Type } from "./chunks/src-CYk0Af0t.js";
9
+ import { a as maximus, i as protectedResourceMetadata, n as t, r as createHttpHandler, t as Type } from "./chunks/src-pzoGmAK9.js";
10
10
  import { a as defineTelemetry, i as defineHandler, n as defineAuth, o as defineTool, r as defineContext } from "./chunks/handler-DSpyrWc-.js";
11
11
  import { o as reportUnexpected } from "./chunks/telemetry-BtxJh69Q.js";
12
- import { n as createRpcOpenApi, t as createOpenApi } from "./chunks/openapi-C2A4SxMi.js";
12
+ import { n as createRpcOpenApi, t as createOpenApi } from "./chunks/openapi-7EYOVkFi.js";
13
13
  import { a as retryAfterSeconds, i as readJsonResponse, r as readJsonBody, t as isJsonMediaType } from "./chunks/json-B14evE6-.js";
14
14
  import { t as publicDestination } from "./chunks/destination-5xTX0b7E.js";
15
15
 
16
- export { AttachmentOutputSchema, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, FailureSchema, HexColorSchema, HttpsUrlSchema, NamedReferenceSchema, OrganizationIdSchema, Page, PageInfoSchema, PageQueryFields, PhoneNumberSchema, PostalAddressSchema, PrincipalSchema, SignedUrlSchema, Type, UuidSchema, createHttpHandler, createHttpRouteResolver, createOpenApi, createRpcOpenApi, createTokenAuthorization, createTokenVerifier, cursorKey, cutPage, defineAuth, defineContext, defineErrors, defineHandler, defineTelemetry, defineTool, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectAccessToken, projectToken, protectedResourceMetadata, publicDestination, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resultSchema, retryAfterSeconds, standardErrors, t };
16
+ export { AttachmentOutputSchema, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, FailureSchema, HexColorSchema, HttpsUrlSchema, MAX_ROLES, NamedReferenceSchema, OrganizationIdSchema, Page, PageInfoSchema, PageQueryFields, PhoneNumberSchema, PostalAddressSchema, PrincipalSchema, SignedUrlSchema, Type, UuidSchema, createHttpHandler, createHttpRouteResolver, createOpenApi, createRpcOpenApi, createTokenAuthorization, createTokenVerifier, cursorKey, cutPage, defineAuth, defineContext, defineErrors, defineHandler, defineRoles, defineTelemetry, defineTool, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectAccessToken, projectToken, protectedResourceMetadata, publicDestination, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resolveRoles, resultSchema, retryAfterSeconds, standardErrors, t };
@@ -1,2 +1,2 @@
1
- import { A as TransportContext, E as HttpOptions, En as operationScopes, Gn as recordCapture, Kn as ExecutionCall, Ln as recordMeter, O as HttpTransport, Qn as TelemetryConfig, Sn as composeOperations, Un as CapturedCall, Wn as VerifiedCaller, Yn as BackgroundContext, b as createHttpRouteResolver, dn as AppManifest, er as recordExecution, jn as MeteredCall, mn as InvocationAuthority, nr as telemetryEnabled, pn as Invocation, qn as executeOperation, rr as withDiagnostics, t as defineApp, v as HttpRouteDefinition, wn as operation, xn as OperationShape, y as HttpRouteMatch, yn as OperationMiddleware, zn as CaptureConfig } from "./chunks/types-AjJyXA62.js";
1
+ import { $n as executeOperation, A as TransportContext, E as HttpOptions, En as operationScopes, Gn as CaptureConfig, Ln as MeteredCall, O as HttpTransport, Qn as ExecutionCall, Sn as composeOperations, Un as recordMeter, Xn as VerifiedCaller, Yn as CapturedCall, Zn as recordCapture, b as createHttpRouteResolver, cr as telemetryEnabled, dn as AppManifest, ir as TelemetryConfig, lr as withDiagnostics, mn as InvocationAuthority, or as recordExecution, pn as Invocation, t as defineApp, tr as BackgroundContext, v as HttpRouteDefinition, wn as operation, xn as OperationShape, y as HttpRouteMatch, yn as OperationMiddleware } from "./chunks/types-CkaHVgDO.js";
2
2
  export { type AppManifest, type BackgroundContext, type CaptureConfig, type CapturedCall, type ExecutionCall, type HttpOptions, type HttpRouteDefinition, type HttpRouteMatch, type HttpTransport, type Invocation, type InvocationAuthority, type MeteredCall, type OperationMiddleware, type OperationShape, type TelemetryConfig, type TransportContext, type VerifiedCaller, composeOperations, createHttpRouteResolver, defineApp, executeOperation, operation, operationScopes, recordCapture, recordExecution, recordMeter, telemetryEnabled, withDiagnostics };
package/dist/internals.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as executeOperation, r as recordCapture, t as recordMeter } from "./chunks/meter-B_WuFl_c.js";
2
- import { n as defineApp } from "./chunks/define-app-BpSKvXET.js";
1
+ import { n as executeOperation, r as recordCapture, t as recordMeter } from "./chunks/meter-77troMd8.js";
2
+ import { n as defineApp } from "./chunks/define-app-DLftS8E6.js";
3
3
  import { b as operationScopes, g as operation, p as composeOperations } from "./chunks/tasks-CD-B6_nv.js";
4
4
  import { a as recordExecution, c as withDiagnostics, s as telemetryEnabled } from "./chunks/telemetry-BtxJh69Q.js";
5
5
  import { t as createHttpRouteResolver } from "./chunks/http-paths-D043DkJv.js";
@@ -1,4 +1,4 @@
1
- import { O as HttpTransport } from "../chunks/types-AjJyXA62.js";
1
+ import { O as HttpTransport } from "../chunks/types-CkaHVgDO.js";
2
2
  /**
3
3
  * The MCP transport, for `createWorker(app, { transports: [mcp()] })`: serves the operations that declare
4
4
  * `mcp` as tools over Streamable HTTP at `/mcp` (or `path`), with the OpenAPI document and guides as
package/dist/mcp/index.js CHANGED
@@ -13,7 +13,7 @@ function mcp(options = {}) {
13
13
  scope: (namespace) => `${namespace}:mcp:use`,
14
14
  maxBodyBytes: (operations, fallback) => Math.max(fallback, ...operations.flatMap(([, op]) => op.mcp ? [op.maxBodyBytes ?? fallback] : [])),
15
15
  async handle(context) {
16
- const { handleMcp } = await import("../chunks/server-UtQtcegf.js");
16
+ const { handleMcp } = await import("../chunks/server-1mO5c8-V.js");
17
17
  return handleMcp(context);
18
18
  }
19
19
  };
@@ -1,4 +1,4 @@
1
- import { Br as Failure, Or as Result, cn as TaskAccess, ln as TaskRecord } from "../chunks/types-AjJyXA62.js";
1
+ import { Kr as Failure, Pr as Result, cn as TaskAccess, ln as TaskRecord } from "../chunks/types-CkaHVgDO.js";
2
2
  import { CallToolResult, McpServer } from "@modelcontextprotocol/server";
3
3
  /** The Tasks extension's id, which a client declares on each request and a server among its capabilities. */
4
4
  export declare const TASKS_EXTENSION = "io.modelcontextprotocol/tasks";
@@ -1,4 +1,4 @@
1
- import { Ft as ContextDeclaration, Mn as OperationMeter, T as HttpMiddleware, Vt as HandlerDeclaration, Xt as ToolDeclaration, an as ApplicationBuilder, dn as AppManifest, fn as Exposure, pn as Invocation, vn as OperationHandler, xn as OperationShape, yn as OperationMiddleware } from "../chunks/types-AjJyXA62.js";
1
+ import { Ft as ContextDeclaration, Rn as OperationMeter, T as HttpMiddleware, Vt as HandlerDeclaration, Xt as ToolDeclaration, an as ApplicationBuilder, dn as AppManifest, fn as Exposure, pn as Invocation, vn as OperationHandler, xn as OperationShape, yn as OperationMiddleware } from "../chunks/types-CkaHVgDO.js";
2
2
  import { TSchema } from "typebox";
3
3
  /** A route's HTTP method. */
4
4
  type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
@@ -1,5 +1,5 @@
1
- import { D as HttpRoute, dn as AppManifest, xn as OperationShape } from "../chunks/types-AjJyXA62.js";
2
- import { n as WorkerOptions, r as WorkerRuntime } from "../chunks/workers-types-B6F5WEuu.js";
1
+ import { D as HttpRoute, dn as AppManifest, xn as OperationShape } from "../chunks/types-CkaHVgDO.js";
2
+ import { n as WorkerOptions, r as WorkerRuntime } from "../chunks/workers-types-BjNko_ZU.js";
3
3
  /** File modules use native Workers handlers; unmatched events fail instead of disappearing. */
4
4
  type Handlers<E> = Omit<ExportedHandler<E>, 'fetch'>;
5
5
  /** One schedule, declared beside the code it runs. Configure its trigger in Cloudflare as well. */
@@ -1,6 +1,6 @@
1
1
  import { i as standardErrors } from "../chunks/errors-BoutSmiy.js";
2
- import { r as createAssetHandler, t as createWorker } from "../chunks/runtime-DjCjXIdf.js";
3
- import { t as checkPagePaths } from "../chunks/pages-B0xdWws9.js";
2
+ import { r as createAssetHandler, t as createWorker } from "../chunks/runtime-B7DDXiOv.js";
3
+ import { t as checkPagePaths } from "../chunks/pages-DEnVoMAV.js";
4
4
 
5
5
  // src/project/handlers.ts
6
6
  /** Compose file handlers with explicit fallbacks, preserving the platform's execution context. */
package/dist/schemas.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as PageInfo, At as decodeSchema, B as DeletedObject, Ct as stripObject, Dn as SchemaKeywords, Dt as SchemaValidationError, Et as SchemaIssue, F as Static, G as NamedReference, H as EmailAddressSchema, I as TSchema, J as PostalAddress, K as NamedReferenceSchema, L as Type, Mt as parseSchema, N as EmptyInputSchema, Nr as Attachment, On as StaticDecode, Ot as InputIssue, P as OrganizationIdSchema, Pr as AttachmentOutputSchema, Q as Page, R as UuidSchema, St as strictObject, Tt as urlSchema, U as HexColorSchema, V as DeletedObjectSchema, W as HttpsUrlSchema, X as SignedUrl, Y as PostalAddressSchema, Z as SignedUrlSchema, _t as literalUnion, at as cursorKey, bt as pipeSchema, ct as withoutSecrets, dt as readSchema, et as PageInfoSchema, ft as SchemaInput, gt as inspectSchema, ht as inputSchema, it as TPage, jt as parseInput, kt as decodeInput, lt as Checked, mt as extendObject, nt as PageQuery, ot as cutPage, pt as defaultSchema, q as PhoneNumberSchema, rt as PageQueryFields, st as pageLimit, tt as PageOrder, ut as checkSchema, vt as looseObject, wt as transformSchema, xt as refineSchema, yt as normalizeSchema, z as t } from "./chunks/types-AjJyXA62.js";
1
+ import { $ as PageInfo, At as decodeSchema, B as DeletedObject, Br as AttachmentOutputSchema, Ct as stripObject, Dn as SchemaKeywords, Dt as SchemaValidationError, Et as SchemaIssue, F as Static, G as NamedReference, H as EmailAddressSchema, I as TSchema, J as PostalAddress, K as NamedReferenceSchema, L as Type, Mt as parseSchema, N as EmptyInputSchema, On as StaticDecode, Ot as InputIssue, P as OrganizationIdSchema, Q as Page, R as UuidSchema, St as strictObject, Tt as urlSchema, U as HexColorSchema, V as DeletedObjectSchema, W as HttpsUrlSchema, X as SignedUrl, Y as PostalAddressSchema, Z as SignedUrlSchema, _t as literalUnion, at as cursorKey, bt as pipeSchema, ct as withoutSecrets, dt as readSchema, et as PageInfoSchema, ft as SchemaInput, gt as inspectSchema, ht as inputSchema, it as TPage, jt as parseInput, kt as decodeInput, lt as Checked, mt as extendObject, nt as PageQuery, ot as cutPage, pt as defaultSchema, q as PhoneNumberSchema, rt as PageQueryFields, st as pageLimit, tt as PageOrder, ut as checkSchema, vt as looseObject, wt as transformSchema, xt as refineSchema, yt as normalizeSchema, z as t, zr as Attachment } from "./chunks/types-CkaHVgDO.js";
2
2
  export { type Attachment, AttachmentOutputSchema, type Checked, type DeletedObject, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, HexColorSchema, HttpsUrlSchema, type InputIssue, type NamedReference, NamedReferenceSchema, OrganizationIdSchema, Page, type PageInfo, PageInfoSchema, type PageOrder, type PageQuery, PageQueryFields, PhoneNumberSchema, type PostalAddress, PostalAddressSchema, type SchemaInput, type SchemaIssue, type SchemaKeywords, SchemaValidationError, type SignedUrl, SignedUrlSchema, type Static, type StaticDecode, type TPage, type TSchema, Type, UuidSchema, checkSchema, cursorKey, cutPage, decodeInput, decodeSchema, defaultSchema, extendObject, inputSchema, inspectSchema, literalUnion, looseObject, normalizeSchema, pageLimit, parseInput, parseSchema, pipeSchema, readSchema, refineSchema, strictObject, stripObject, t, transformSchema, urlSchema, withoutSecrets };
@@ -1,2 +1,2 @@
1
- import { in as StandardFailure, rn as STANDARD_FAILURES } from "./chunks/types-AjJyXA62.js";
1
+ import { in as StandardFailure, rn as STANDARD_FAILURES } from "./chunks/types-CkaHVgDO.js";
2
2
  export { STANDARD_FAILURES, StandardFailure };
@@ -139,7 +139,7 @@ async function run() {
139
139
  return;
140
140
  }
141
141
  case "openapi": {
142
- const { writeOpenApi } = await import("../chunks/openapi-file-DlBVI3lc.js");
142
+ const { writeOpenApi } = await import("../chunks/openapi-file-DK8aTUmo.js");
143
143
  const written = await writeOpenApi(rest[0] ?? ".", {
144
144
  ...values.out === void 0 ? {} : { out: values.out },
145
145
  check: values.check
@@ -1,4 +1,4 @@
1
- import { ar as TokenAlgorithm, cr as TokenPolicy, sr as TokenDevelopment } from "../chunks/types-AjJyXA62.js";
1
+ import { Mn as RoleDefinitions, dr as TokenAlgorithm, mr as TokenPolicy, pr as TokenDevelopment } from "../chunks/types-CkaHVgDO.js";
2
2
  import { WorkerConfig } from "cf/config";
3
3
  import { Plugin } from "vite";
4
4
  /** Where the Worker runs: `development` under `vp dev`, `production` in every build. */
@@ -55,6 +55,12 @@ interface MaximusOptions extends Omit<WorkerConfig, 'name' | 'entrypoint' | 'env
55
55
  * after the version, in words, unless its contract declares one.
56
56
  */
57
57
  groups?: Readonly<Record<string, string>>;
58
+ /**
59
+ * The service's roles, from `defineRoles()`: at most three, each saying what it may do with the service's
60
+ * resources. The build refuses a role that names a scope no public route takes; OpenAPI publishes each
61
+ * role with the scopes it holds.
62
+ */
63
+ roles?: RoleDefinitions;
58
64
  /** The version OpenAPI, the MCP server and `/health` report; by default, the package's version. */
59
65
  version?: string;
60
66
  /**
@@ -1,9 +1,9 @@
1
1
  import { a as operationPathParameters } from "../chunks/http-paths-D043DkJv.js";
2
- import { a as ownsPrefix, t as VERSIONED_PATH } from "../chunks/http-layout-BsQlLNeo.js";
2
+ import { a as ownsPrefix, t as VERSIONED_PATH } from "../chunks/http-layout-CaZSEy2I.js";
3
3
  import { t as routeName } from "../chunks/names-ncD7A3DV.js";
4
- import { t as checkPagePaths } from "../chunks/pages-B0xdWws9.js";
4
+ import { t as checkPagePaths } from "../chunks/pages-DEnVoMAV.js";
5
5
  import { a as projectPath, i as projectFiles, o as publicFiles, r as compareNames, s as routeShape, t as PROJECT_DIRECTORIES } from "../chunks/project-files-C0OX7MQQ.js";
6
- import { t as checkMcpResourceNames } from "../chunks/define-app-BpSKvXET.js";
6
+ import { t as checkMcpResourceNames } from "../chunks/define-app-DLftS8E6.js";
7
7
  import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
8
8
  import { dirname, join, posix, relative, resolve, sep } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
@@ -44,7 +44,7 @@ const SERVICE_NAME = /^(?=.{2,63}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
44
44
  /** The application's options and the Worker's settings, apart. `assets` is maximus()'s own. */
45
45
  function split(options) {
46
46
  if ("assets" in options) throw new TypeError("maximus() configures the assets: index.html at the root makes the project a web app.");
47
- const { name, namespace, title, description, groups, version, origin, tokens, rpc, http, maxBodyBytes, maxOutputBytes, rateLimit, meter, env, services, webApp, ...worker } = options;
47
+ const { name, namespace, title, description, groups, roles, version, origin, tokens, rpc, http, maxBodyBytes, maxOutputBytes, rateLimit, meter, env, services, webApp, ...worker } = options;
48
48
  return {
49
49
  application: {
50
50
  name,
@@ -52,6 +52,7 @@ function split(options) {
52
52
  title,
53
53
  description,
54
54
  groups,
55
+ roles,
55
56
  version,
56
57
  origin,
57
58
  tokens,
@@ -208,6 +209,7 @@ function projectOptions(root, options, phase = "production") {
208
209
  title: application.title ?? name,
209
210
  ...application.description === void 0 ? {} : { description: application.description },
210
211
  ...application.groups === void 0 ? {} : { groups: application.groups },
212
+ ...application.roles === void 0 ? {} : { roles: application.roles },
211
213
  version,
212
214
  origin: application.origin,
213
215
  tokens: {
@@ -1,4 +1,4 @@
1
- import { Br as Failure, Or as Result } from "./chunks/types-AjJyXA62.js";
1
+ import { Kr as Failure, Pr as Result } from "./chunks/types-CkaHVgDO.js";
2
2
  /** Why a webhook signature was refused: absent, malformed, outside the time tolerance, or not matching. */
3
3
  export declare const WEBHOOK_SIGNATURE_FAILURES: readonly ['missing', 'malformed', 'expired', 'mismatch'];
4
4
  /** Why a webhook signature was refused. */
@@ -1,2 +1,2 @@
1
- import { a as credentials, i as createWorker, n as WorkerOptions, o as WorkerAssetsOptions, r as WorkerRuntime, t as RpcMethods } from "../chunks/workers-types-B6F5WEuu.js";
1
+ import { a as credentials, i as createWorker, n as WorkerOptions, o as WorkerAssetsOptions, r as WorkerRuntime, t as RpcMethods } from "../chunks/workers-types-BjNko_ZU.js";
2
2
  export { RpcMethods, type WorkerAssetsOptions, WorkerOptions, WorkerRuntime, createWorker, credentials };
@@ -1,3 +1,3 @@
1
- import { n as credentials, t as createWorker } from "../chunks/runtime-DjCjXIdf.js";
1
+ import { n as credentials, t as createWorker } from "../chunks/runtime-B7DDXiOv.js";
2
2
 
3
3
  export { createWorker, credentials };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbol-ai/maximus",
3
- "version": "8.6.0",
3
+ "version": "8.7.1",
4
4
  "description": "Maximus: define a service once and serve it over HTTP, MCP and Worker RPC on Cloudflare Workers, configured in vite.config.ts, with its OpenAPI and CLI.",
5
5
  "keywords": [
6
6
  "api",
@@ -142,7 +142,7 @@
142
142
  },
143
143
  "dependencies": {
144
144
  "@modelcontextprotocol/server": "2.4.0",
145
- "@scalar/openapi-parser": "0.29.28",
145
+ "@scalar/openapi-parser": "0.29.29",
146
146
  "ajv-formats": "3.0.1",
147
147
  "jose": "6.2.18",
148
148
  "rou3": "1.0.0",
@@ -150,12 +150,12 @@
150
150
  "typebox": "1.4.7"
151
151
  },
152
152
  "devDependencies": {
153
- "@cloudflare/vite-plugin": "2.0.0-rc.5",
153
+ "@cloudflare/vite-plugin": "2.0.0-rc.7",
154
154
  "@modelcontextprotocol/ext-tasks": "0.2.3",
155
155
  "@types/pg": "8.23.1",
156
156
  "ajv": "8.20.0",
157
157
  "cf": "1.0.0-rc.6",
158
- "miniflare": "5.20261123.1-beta",
158
+ "miniflare": "5.20261127.1-beta",
159
159
  "pg": "8.23.1",
160
160
  "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
161
161
  "vite-plus": "1.8.0",
@@ -29,6 +29,7 @@ export default defineConfig({
29
29
  | `name` | The Worker's name, the MCP server's and the scopes' prefix: lowercase letters, digits and single hyphens. By default, the package's name without its scope. |
30
30
  | `namespace`, `title`, `version` | The scopes' prefix (the name), the human name (the name), the version `/health` reports (the package's). |
31
31
  | `description`, `groups` | The OpenAPI document's description of the service, and of each group of routes by its name: `{ Notes: "The notes of the caller's organization." }`. |
32
+ | `roles` | The service's roles, from `defineRoles()`: at most three, each `{ description, can?, extends?, all? }`. `can: { read: ['notes'] }` holds `notes:notes:read`; `all: true` holds every public scope. The build refuses a scope no public route takes; OpenAPI publishes them as `x-maximus-roles`. Never `all` where a public route also admits a staff or machine scope: it would hold that scope too. Only a service people hold roles in declares them. |
32
33
  | `rpc` | `{ callers: ['example-orders'] }`: the services allowed to call RPC methods, by the `caller` their binding's props name, which is the calling service's `name`. None by default. |
33
34
  | `services` | `{ PRICING: { worker: 'example-pricing', openapi: '../pricing/openapi.rpc.json' } }`: other Maximus services this one calls over RPC, each bound to its Worker's `Service` entrypoint with this service as the caller, and typed from the RPC document it publishes. See [transports.md](transports.md#worker-rpc). |
34
35
  | `http` | `{ basePath, healthPath }`: `/api` and `/health` by default. |