@arbol-ai/maximus 8.1.0 → 8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/analytics/analytics.d.ts +16 -16
  2. package/dist/analytics/analytics.js +3 -3
  3. package/dist/body.d.ts +2 -2
  4. package/dist/body.js +2 -1
  5. package/dist/capture/index.d.ts +1 -1
  6. package/dist/capture/index.js +3 -4
  7. package/dist/chunks/{define-app-BxGZdNmS.js → define-app-CQpWqqqE.js} +33 -14
  8. package/dist/chunks/destination-5xTX0b7E.js +65 -0
  9. package/dist/chunks/{digest-C7UGt760.js → digest-C51F1bhA.js} +1 -2
  10. package/dist/chunks/{errors-CWgE9uvM.js → errors-BoutSmiy.js} +2 -3
  11. package/dist/chunks/{execution-BTiAWA4n.js → execution-Bpq6s4nA.js} +9 -8
  12. package/dist/chunks/{generate-C-9FKW0o.js → generate-Dg88LzLU.js} +1 -1
  13. package/dist/chunks/{handler-iebR-urt.js → handler-DSpyrWc-.js} +6 -2
  14. package/dist/chunks/{http-layout-BvlbD__1.js → http-layout-BcYH4I2w.js} +1 -1
  15. package/dist/chunks/{http-paths-DMBxwpp6.js → http-paths-D043DkJv.js} +50 -81
  16. package/dist/chunks/http-routes-B6tCsnxB.js +29 -0
  17. package/dist/chunks/{openapi-BF3eCpux.js → openapi-D2rds7vy.js} +27 -116
  18. package/dist/chunks/{openapi-file-RcXoq0AF.js → openapi-file-BK8zET5U.js} +24 -6
  19. package/dist/chunks/{pages-BCksUeRf.js → pages-B7ysoFAM.js} +1 -1
  20. package/dist/chunks/result-CF4OzG9O.js +29 -0
  21. package/dist/chunks/{runtime-D5eR9-Es.js → runtime-8OpxAvsI.js} +132 -7
  22. package/dist/chunks/schemas-_UJcx_uY.js +813 -0
  23. package/dist/chunks/{server-B9C8KPwa.js → server-CVhTLNj2.js} +37 -101
  24. package/dist/chunks/{src-C-4z443M.js → src-B_LthUVU.js} +39 -18
  25. package/dist/chunks/tasks-C873C3le.js +100 -0
  26. package/dist/chunks/tasks-DYdY-dBI.js +267 -0
  27. package/dist/chunks/{types-Dqo3oGig.d.ts → types-BfGa2aJT.d.ts} +346 -138
  28. package/dist/chunks/validation-CpzAxj2_.js +201 -0
  29. package/dist/chunks/{workers-types-BgjyDtGd.d.ts → workers-types-Cxf-5cH7.d.ts} +6 -1
  30. package/dist/client.d.ts +92 -0
  31. package/dist/client.js +300 -0
  32. package/dist/diagnostics.d.ts +1 -1
  33. package/dist/errors.d.ts +1 -1
  34. package/dist/errors.js +1 -1
  35. package/dist/http-paths.d.ts +1 -1
  36. package/dist/http-paths.js +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +11 -9
  39. package/dist/internals.d.ts +1 -1
  40. package/dist/internals.js +4 -4
  41. package/dist/mcp/index.d.ts +1 -1
  42. package/dist/mcp/index.js +1 -1
  43. package/dist/mcp/tasks.d.ts +33 -0
  44. package/dist/mcp/tasks.js +3 -0
  45. package/dist/project/config.d.ts +2 -2
  46. package/dist/project/config.js +3 -2
  47. package/dist/project/index.d.ts +2 -2
  48. package/dist/project/index.js +3 -3
  49. package/dist/schemas.d.ts +2 -2
  50. package/dist/schemas.js +3 -3
  51. package/dist/standard-failures.d.ts +1 -1
  52. package/dist/tooling/cli.js +2 -2
  53. package/dist/vite/index.d.ts +1 -1
  54. package/dist/vite/index.js +6 -5
  55. package/dist/webhooks.d.ts +13 -2
  56. package/dist/webhooks.js +38 -1
  57. package/dist/workers/runtime.d.ts +1 -1
  58. package/dist/workers/runtime.js +1 -1
  59. package/package.json +15 -3
  60. package/skills/maximus/SKILL.md +7 -4
  61. package/skills/maximus/references/routes-and-tools.md +9 -1
  62. package/dist/chunks/result-CKgZHrnj.js +0 -56
  63. package/dist/chunks/schemas-BOFxZP1c.js +0 -227
  64. package/dist/chunks/validation-DMu0rkMQ.js +0 -670
@@ -1,20 +1,20 @@
1
- import { Pn as Observer } from "../chunks/types-Dqo3oGig.js";
2
- import { Static } from "@sinclair/typebox";
1
+ import { Hn as Observer } from "../chunks/types-BfGa2aJT.js";
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
- export declare const ExecutionEventSchema: import("@sinclair/typebox").TObject<{
5
- id: import("@sinclair/typebox").TString;
6
- service: import("@sinclair/typebox").TString;
7
- operation: import("@sinclair/typebox").TString;
8
- organizationId: import("@sinclair/typebox").TString;
9
- actorId: import("@sinclair/typebox").TString;
10
- actorKind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"user">, import("@sinclair/typebox").TLiteral<"service">]>;
11
- requestId: import("@sinclair/typebox").TString;
12
- traceId: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
13
- surface: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"http">, import("@sinclair/typebox").TLiteral<"mcp">, import("@sinclair/typebox").TLiteral<"rpc">]>;
14
- occurredAt: import("@sinclair/typebox").TInteger;
15
- durationMicros: import("@sinclair/typebox").TInteger;
16
- outcome: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"success">, import("@sinclair/typebox").TLiteral<"failure">]>;
17
- errorCode: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
4
+ export declare const ExecutionEventSchema: Type.TObject<{
5
+ id: Type.TString;
6
+ service: Type.TString;
7
+ operation: Type.TString;
8
+ organizationId: Type.TString;
9
+ actorId: Type.TString;
10
+ actorKind: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"service">]>;
11
+ requestId: Type.TString;
12
+ traceId: Type.TUnion<[Type.TString, Type.TNull]>;
13
+ surface: Type.TUnion<[Type.TLiteral<"http">, Type.TLiteral<"mcp">, Type.TLiteral<"rpc">]>;
14
+ occurredAt: Type.TInteger;
15
+ durationMicros: Type.TInteger;
16
+ outcome: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"failure">]>;
17
+ errorCode: Type.TUnion<[Type.TString, Type.TNull]>;
18
18
  }>;
19
19
  /** An analytics event. */
20
20
  export type ExecutionEvent = Static<typeof ExecutionEventSchema>;
@@ -1,7 +1,7 @@
1
- import { i as UuidSchema, n as OrganizationIdSchema } from "../chunks/schemas-BOFxZP1c.js";
1
+ import { f as Value } from "../chunks/validation-CpzAxj2_.js";
2
+ import { i as UuidSchema, n as OrganizationIdSchema } from "../chunks/schemas-_UJcx_uY.js";
2
3
  import { s as telemetryEnabled } from "../chunks/telemetry-BtxJh69Q.js";
3
- import { Type } from "@sinclair/typebox";
4
- import { Value } from "@sinclair/typebox/value";
4
+ import { Type } from "typebox";
5
5
 
6
6
  // src/analytics/analytics.ts
7
7
  /**
package/dist/body.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { c as isJsonMediaType, d as retryAfterSeconds, f as BodyReadOptions, g as readBodyText, h as readBodyBytes, l as readJsonBody, m as HttpBodyFailureReason, p as HttpBodyFailure, u as readJsonResponse } from "./chunks/types-Dqo3oGig.js";
2
- export { type BodyReadOptions, type HttpBodyFailure, type HttpBodyFailureReason, isJsonMediaType, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, retryAfterSeconds };
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-BfGa2aJT.js";
2
+ export { type BodyReadOptions, type HttpBodyFailure, type HttpBodyFailureReason, isJsonMediaType, publicDestination, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, retryAfterSeconds };
package/dist/body.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { n as readBodyBytes, r as readBodyText } from "./chunks/body-DOIHwIIl.js";
2
2
  import { a as retryAfterSeconds, i as readJsonResponse, r as readJsonBody, t as isJsonMediaType } from "./chunks/json-B14evE6-.js";
3
+ import { t as publicDestination } from "./chunks/destination-5xTX0b7E.js";
3
4
 
4
- export { isJsonMediaType, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, retryAfterSeconds };
5
+ export { isJsonMediaType, publicDestination, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, retryAfterSeconds };
@@ -1,4 +1,4 @@
1
- import { Cn as CaptureDimensions, Ht as RegisteredEnv, Sn as CaptureConfig, Tn as CaptureSink, it as withoutSecrets, or as CaptureRecord, sr as CaptureRecordSchema, wn as CaptureInvocation, xn as AnyContext } from "../chunks/types-Dqo3oGig.js";
1
+ import { An as CaptureConfig, Kt as RegisteredEnv, Mn as CaptureInvocation, Nn as CaptureSink, ct as withoutSecrets, hr as CaptureRecordSchema, jn as CaptureDimensions, kn as AnyContext, mr as CaptureRecord } from "../chunks/types-BfGa2aJT.js";
2
2
  /** What `pipeline()` takes. */
3
3
  interface PipelineOptions<E> {
4
4
  /**
@@ -1,9 +1,8 @@
1
- import { E as withoutSecrets } from "../chunks/validation-DMu0rkMQ.js";
1
+ import { B as withoutSecrets, i as UuidSchema, n as OrganizationIdSchema } from "../chunks/schemas-_UJcx_uY.js";
2
2
  import { t as isRecord } from "../chunks/record-DQUDTpEA.js";
3
- import { i as UuidSchema, n as OrganizationIdSchema } from "../chunks/schemas-BOFxZP1c.js";
4
- import { t as sha256Hex } from "../chunks/digest-C7UGt760.js";
3
+ import { t as sha256Hex } from "../chunks/digest-C51F1bhA.js";
5
4
  import { t as delay } from "../chunks/delay-BsKQP_lF.js";
6
- import { Type } from "@sinclair/typebox";
5
+ import { Type } from "typebox";
7
6
 
8
7
  // src/capture-record.ts
9
8
  /**
@@ -1,10 +1,11 @@
1
- import { d as hasUncompiledCodecs } from "./validation-DMu0rkMQ.js";
2
- import { i as standardErrors } from "./errors-CWgE9uvM.js";
1
+ import { R as holdsSecrets, T as hasUncompiledCodecs } from "./schemas-_UJcx_uY.js";
2
+ import { i as standardErrors } from "./errors-BoutSmiy.js";
3
3
  import { n as readBodyBytes } from "./body-DOIHwIIl.js";
4
- import { a as operationPathParameters, r as isInputHeaderName, t as createHttpRouteResolver } from "./http-paths-DMBxwpp6.js";
5
- import { i as pathParameterSchemas } from "./result-CKgZHrnj.js";
6
- import { C as MAX_BODY_BYTES_CEILING, M as isNamespacedScope, c as tokenAudiences, f as hasSchemaReferences, j as operationScopes, r as checkTokenAuthority, t as createOpenApi, w as STANDARD_CODES } from "./openapi-BF3eCpux.js";
7
- import { Kind } from "@sinclair/typebox";
4
+ import { a as operationPathParameters, r as isInputHeaderName, t as createHttpRouteResolver } from "./http-paths-D043DkJv.js";
5
+ import { t as pathParameterSchemas } from "./http-routes-B6tCsnxB.js";
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-DYdY-dBI.js";
7
+ import { c as tokenAudiences, f as hasSchemaReferences, r as checkTokenAuthority, t as createOpenApi } from "./openapi-D2rds7vy.js";
8
+ import { IsKind } from "typebox";
8
9
 
9
10
  // src/internal/exact-length.ts
10
11
  /**
@@ -62,7 +63,7 @@ function binaryBody(request, maxBytes) {
62
63
  }
63
64
  /** Whether an output schema is `AttachmentOutputSchema`. */
64
65
  function isAttachmentSchema(schema) {
65
- return schema[Kind] === "HttpAttachment";
66
+ return IsKind(schema, "HttpAttachment");
66
67
  }
67
68
  /**
68
69
  * Whether an output is a well-formed `Attachment` within `maxBytes`: exactly its four fields, bytes of
@@ -121,6 +122,11 @@ function attachmentStream(body, byteLength) {
121
122
  }
122
123
 
123
124
  // src/define-app.ts
125
+ /**
126
+ * What `.build()` refuses. Every rule an application must keep is checked once, at construction, so a
127
+ * service that breaks one never starts: each refusal is a TypeError whose message names the rule, and most
128
+ * of the rules about one operation also name that operation.
129
+ */
124
130
  /** Names a Worker entrypoint already uses, or that would break a class or a promise. */
125
131
  const RESERVED_NAMES = /* @__PURE__ */ new Set([
126
132
  "fetch",
@@ -142,6 +148,7 @@ const OPERATION_FIELDS = new Set(Object.keys({
142
148
  visibility: true,
143
149
  mcp: true,
144
150
  rpc: true,
151
+ task: true,
145
152
  scope: true,
146
153
  scopeMatch: true,
147
154
  conditionalScopes: true,
@@ -257,13 +264,20 @@ function checkOperationContract(name, op, namespace) {
257
264
  if (!scopes.length || new Set(scopes).size !== scopes.length || scopes.some((scope) => !isNamespacedScope(scope, namespace))) throw new TypeError(`Operation "${name}": every scope is "${namespace}:<resource>:<action>", listed once. Use safe operation names, namespaced scopes and strict object schemas.`);
258
265
  if (!(strictObject(op.input, op.http?.method !== "GET") && (isAttachmentSchema(op.output) || strictObject(op.output, true)))) throw new TypeError(`Operation "${name}": input and output are strict objects or unions of strict objects; a GET input is one strict object (its query). Use safe operation names, namespaced scopes and strict object schemas.`);
259
266
  if (looseRecord(op.input) || looseRecord(op.output)) throw new TypeError(`Operation "${name}": a record whose keys follow a pattern takes additionalProperties: false, t.Record(key, value, { additionalProperties: false }), or a key outside the pattern passes unchecked.`);
267
+ if (!validTask(op.task)) throw new TypeError(`Operation "${name}": task is true or { ttlMs }, a positive integer of milliseconds up to a day.`);
268
+ if (op.task && holdsSecrets(op.output)) throw new TypeError(`Operation "${name}": a task keeps its result until it expires, so its output marks nothing secret: true.`);
269
+ }
270
+ /** Whether `task` is absent, `true` or `{ ttlMs }`: a positive integer of milliseconds up to a day. */
271
+ function validTask(task) {
272
+ if (task === void 0 || task === true) return true;
273
+ return typeof task === "object" && Object.keys(task).length === 1 && Number.isInteger(task.ttlMs) && task.ttlMs > 0 && task.ttlMs <= 864e5;
260
274
  }
261
275
  /** Byte bodies, attachments, limits, header-sourced fields and the route itself. */
262
276
  function checkHttpExposure(name, op, routes) {
263
277
  if (op.http?.body !== void 0 && op.http.body !== "bytes" || op.http?.response !== void 0 && op.http.response !== "attachment") throw new TypeError(`Operation "${name}": unsupported HTTP binary contract.`);
264
278
  const binary = op.http?.body === "bytes";
265
279
  const attachment = isAttachmentSchema(op.output);
266
- if ((binary || attachment) && (!op.http || op.mcp || op.rpc)) throw new TypeError(`Operation "${name}": byte bodies and attachments are HTTP-only.`);
280
+ if ((binary || attachment) && (!op.http || op.mcp || op.rpc || op.task)) throw new TypeError(`Operation "${name}": byte bodies and attachments are HTTP-only and never tasks.`);
267
281
  if (op.http?.response === "attachment" !== attachment || binary && op.http?.method === "GET") throw new TypeError(`Operation "${name}": declare matching attachment output and non-GET byte bodies.`);
268
282
  if (!validBodyLimit(op.maxOutputBytes)) throw new TypeError(`Operation "${name}": invalid output byte limit.`);
269
283
  if (op.http?.successStatus !== void 0 && ![
@@ -274,7 +288,8 @@ function checkHttpExposure(name, op, routes) {
274
288
  if (op.http?.headers) {
275
289
  const pathFields = new Set(operationPathParameters(op.http.path));
276
290
  const headers = Object.entries(op.http.headers);
277
- if (!binary || op.input.type !== "object" || new Set(headers.map(([, wire]) => wire.toLowerCase())).size !== headers.length || headers.some(([field, wire]) => !Object.hasOwn(op.input.properties, field) || pathFields.has(field) || !isInputHeaderName(wire))) throw new TypeError(`Operation "${name}": byte operation headers must name unique, non-authority metadata fields.`);
291
+ const input = op.input;
292
+ if (!binary || input.type !== "object" || new Set(headers.map(([, wire]) => wire.toLowerCase())).size !== headers.length || headers.some(([field, wire]) => !Object.hasOwn(input.properties ?? {}, field) || pathFields.has(field) || !isInputHeaderName(wire))) throw new TypeError(`Operation "${name}": byte operation headers must name unique, non-authority metadata fields.`);
278
293
  }
279
294
  if (!validBodyLimit(op.maxBodyBytes) || op.maxBodyBytes !== void 0 && op.http?.method === "GET") throw new TypeError(`Operation "${name}": an operation body limit is a positive integer up to 16 MiB, on a non-GET route.`);
280
295
  if (op.http) {
@@ -285,7 +300,7 @@ function checkHttpExposure(name, op, routes) {
285
300
  }
286
301
  }
287
302
  /**
288
- * A schema reference (TypeBox `Ref` or `Recursive`) resolves when the OpenAPI document bundles the schemas,
303
+ * A schema reference (TypeBox `Ref` or `Cyclic`) resolves when the OpenAPI document bundles the schemas,
289
304
  * to the one definition its name has. An application whose schemas refer to a name is bundled at
290
305
  * construction, so a reference that names no single definition is refused before the service starts rather
291
306
  * than when the document is first requested; schemas without references have nothing to resolve.
@@ -324,8 +339,11 @@ function checkSkillTool(mcp, tools) {
324
339
  function validBodyLimit(value) {
325
340
  return value === void 0 || Number.isInteger(value) && value > 0 && value <= 16777216;
326
341
  }
327
- /** The key pattern of `t.Record(t.String(), value)`, which every key matches, so every value is checked. */
328
- const ANY_KEY = "^(.*)$";
342
+ /**
343
+ * The key patterns of `t.Record(t.String(), value)`, which every key matches, so every value is checked: TypeBox
344
+ * 1.x writes the first, and 0.34 wrote the second.
345
+ */
346
+ const ANY_KEYS = /* @__PURE__ */ new Set(["^.*$", "^(.*)$"]);
329
347
  /**
330
348
  * Whether a schema holds, at any depth, a record whose keys follow a pattern but that admits other keys:
331
349
  * without `additionalProperties: false`, a key outside the pattern passes with any value at all.
@@ -335,7 +353,7 @@ function looseRecord(schema) {
335
353
  if (!schema || typeof schema !== "object") return false;
336
354
  const node = schema;
337
355
  const patterns = node.patternProperties;
338
- if (patterns && typeof patterns === "object" && node.additionalProperties !== false && Object.keys(patterns).some((pattern) => pattern !== ANY_KEY)) return true;
356
+ if (patterns && typeof patterns === "object" && node.additionalProperties !== false && Object.keys(patterns).some((pattern) => !ANY_KEYS.has(pattern))) return true;
339
357
  return Object.values(node).some(looseRecord);
340
358
  }
341
359
  /**
@@ -343,7 +361,8 @@ function looseRecord(schema) {
343
361
  * a union whose every member is a strict object, so a request body or a result
344
362
  * can be discriminated by a field (`{ channel: 'email', … } | { channel: 'sms', … }`).
345
363
  */
346
- function strictObject(schema, unions) {
364
+ function strictObject(node, unions) {
365
+ const schema = (node.$ref === void 0 ? void 0 : node.$defs?.[node.$ref]) ?? node;
347
366
  if (schema.type === "object") return schema.additionalProperties === false;
348
367
  const members = schema.anyOf;
349
368
  return unions && Array.isArray(members) && members.length > 0 && members.every((member) => strictObject(member, false));
@@ -0,0 +1,65 @@
1
+ // src/internal/destination.ts
2
+ /**
3
+ * Where a Worker may send a request for someone it does not control, such as a server an organization
4
+ * registered. A Worker cannot resolve a name before it fetches it, so the rules hold on the URL itself.
5
+ */
6
+ /**
7
+ * Top-level names reserved for special use or private networks (RFC 2606, 6761, 6762, 7686, 8375 and 9476),
8
+ * and the ones internal networks use.
9
+ */
10
+ const PRIVATE_TOP_LEVEL_NAMES = /* @__PURE__ */ new Set([
11
+ "alt",
12
+ "arpa",
13
+ "cloudflare",
14
+ "corp",
15
+ "example",
16
+ "home",
17
+ "internal",
18
+ "intranet",
19
+ "invalid",
20
+ "lan",
21
+ "local",
22
+ "localdomain",
23
+ "localhost",
24
+ "onion",
25
+ "private",
26
+ "test"
27
+ ]);
28
+ /**
29
+ * Cloudflare's own domains and Arbol's, subdomains included: Arbol's services are reached through the Gateway
30
+ * and native RPC, and neither ever stands for someone else's server.
31
+ */
32
+ const PLATFORM_DOMAINS = [
33
+ "cloudflare.com",
34
+ "cloudflareaccess.com",
35
+ "cloudflareclient.com",
36
+ "cloudflare-dns.com",
37
+ "cloudflare-gateway.com",
38
+ "getarbol.app",
39
+ "getarbol.com"
40
+ ];
41
+ /**
42
+ * A DNS name of two labels or more: letters, digits and inner hyphens, at most 63 characters a label and 253
43
+ * in all, under a top-level name of letters. An IP literal is none.
44
+ */
45
+ const DNS_NAME = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
46
+ /**
47
+ * The URL, when a Worker may send a request there for someone it does not control: https on its default port,
48
+ * with no credentials or fragment, to a public DNS name; never an IP literal, a special-use or private-network
49
+ * name, nor Cloudflare's or Arbol's own hosts. Undefined for anything else. Send the request with
50
+ * `redirect: 'manual'` and refuse a `3xx`, so no redirect takes it elsewhere.
51
+ */
52
+ function publicDestination(value) {
53
+ let url;
54
+ try {
55
+ url = new URL(value);
56
+ } catch {
57
+ return;
58
+ }
59
+ const host = url.hostname;
60
+ const topLevelName = host.slice(host.lastIndexOf(".") + 1);
61
+ if (url.protocol !== "https:" || url.port !== "" || url.username !== "" || url.password !== "" || url.hash !== "" || !DNS_NAME.test(host) || PRIVATE_TOP_LEVEL_NAMES.has(topLevelName) || PLATFORM_DOMAINS.some((domain) => host === domain || host.endsWith(`.${domain}`))) return;
62
+ return url;
63
+ }
64
+
65
+ export { publicDestination as t };
@@ -1,7 +1,6 @@
1
1
  // src/internal/digest.ts
2
2
  /**
3
- * SHA-256 digests in hexadecimal, for rate limit keys, the development token's comparison and skill
4
- * manifests.
3
+ * SHA-256 digests in hexadecimal, for rate limit keys, the development token's comparison and capture.
5
4
  */
6
5
  /** The SHA-256 digest of text or bytes, in lowercase hexadecimal. */
7
6
  async function sha256Hex(value) {
@@ -1,7 +1,6 @@
1
+ import { a as parseSchema, f as Value } from "./validation-CpzAxj2_.js";
1
2
  import { t as STANDARD_FAILURES } from "./standard-failures-Lh4mSfwG.js";
2
- import { a as parseSchema } from "./validation-DMu0rkMQ.js";
3
- import { Type } from "@sinclair/typebox";
4
- import { Value } from "@sinclair/typebox/value";
3
+ import { Type } from "typebox";
5
4
 
6
5
  // src/errors.ts
7
6
  /**
@@ -1,12 +1,12 @@
1
- import { E as withoutSecrets, t as admitInput, w as holdsSecrets } from "./validation-DMu0rkMQ.js";
2
- import { i as standardErrors } from "./errors-CWgE9uvM.js";
3
- import { a as isAttachmentSchema, o as validAttachment } from "./define-app-BxGZdNmS.js";
4
- import { t as err } from "./result-CKgZHrnj.js";
5
- import { A as operationOutputLimit, b as ADMISSION_CODES, j as operationScopes, k as operationMatchesScopes, w as STANDARD_CODES, x as BODY_CODES } from "./openapi-BF3eCpux.js";
6
- import { t as sha256Hex } from "./digest-C7UGt760.js";
1
+ import { f as Value, t as admitInput } from "./validation-CpzAxj2_.js";
2
+ import { B as withoutSecrets, R as holdsSecrets } from "./schemas-_UJcx_uY.js";
3
+ import { i as standardErrors } from "./errors-BoutSmiy.js";
4
+ import { a as isAttachmentSchema, o as validAttachment } from "./define-app-CQpWqqqE.js";
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-DYdY-dBI.js";
6
+ import { t as err } from "./result-CF4OzG9O.js";
7
+ import { t as sha256Hex } from "./digest-C51F1bhA.js";
7
8
  import { t as delay } from "./delay-BsKQP_lF.js";
8
9
  import { o as reportUnexpected, r as elapsedMicros, s as telemetryEnabled, t as activeTraceId } from "./telemetry-BtxJh69Q.js";
9
- import { Value } from "@sinclair/typebox/value";
10
10
 
11
11
  // src/capture.ts
12
12
  /** The most entries a `dimensions` callback's answer keeps. */
@@ -215,7 +215,8 @@ async function executeOperation(manifest, operation, env, principal, input, auth
215
215
  ...background ? { background } : {},
216
216
  ...trustedAuthority ? { authority: trustedAuthority } : {},
217
217
  ...call?.rpcCaller ? { rpcCaller: call.rpcCaller } : {},
218
- ...call?.userAgent ? { userAgent: call.userAgent } : {}
218
+ ...call?.userAgent ? { userAgent: call.userAgent } : {},
219
+ ...call?.taskId ? { taskId: call.taskId } : {}
219
220
  };
220
221
  /**
221
222
  * A failure the call answers, from its context, middleware or handler: one of the catalog and, when the
@@ -1,4 +1,4 @@
1
- import { a as operationPathParameters } from "./http-paths-DMBxwpp6.js";
1
+ import { a as operationPathParameters } from "./http-paths-D043DkJv.js";
2
2
  import { a as projectPath, i as projectFiles, n as checkProjectFolder, s as routeShape } from "./project-files-C0OX7MQQ.js";
3
3
  import { existsSync, lstatSync, mkdirSync, writeFileSync } from "node:fs";
4
4
  import { dirname, join, relative, resolve } from "node:path";
@@ -1,4 +1,4 @@
1
- import { KindGuard, Type } from "@sinclair/typebox";
1
+ import { Type } from "typebox";
2
2
 
3
3
  // src/handler.ts
4
4
  /**
@@ -24,10 +24,14 @@ var Failed = class Failed {
24
24
  return value instanceof Failed;
25
25
  }
26
26
  };
27
+ /** Whether a value is a TypeBox type rather than a record of fields. */
28
+ function isTypeBoxType(value) {
29
+ return "~kind" in value || "~unsafe" in value;
30
+ }
27
31
  /** The schema `input` or `output` stands for, as `SchemaOf` types it: no fields is an empty strict object. */
28
32
  function schemaOf(value) {
29
33
  if (value === void 0) return Type.Object({}, { additionalProperties: false });
30
- return KindGuard.IsSchema(value) ? value : Type.Object(value, { additionalProperties: false });
34
+ return isTypeBoxType(value) ? value : Type.Object(value, { additionalProperties: false });
31
35
  }
32
36
  /** Every declaration `defineHandler` returned, so binding refuses any other value. */
33
37
  const handlers = /* @__PURE__ */ new WeakSet();
@@ -1,4 +1,4 @@
1
- import { u as usesOwnBearer, v as usesCloudflareAccess } from "./openapi-BF3eCpux.js";
1
+ import { u as usesOwnBearer, v as usesCloudflareAccess } from "./openapi-D2rds7vy.js";
2
2
 
3
3
  // src/internal/http-layout.ts
4
4
  /**
@@ -1,7 +1,9 @@
1
+ import { addRoute, createRouter, findRoute, routesOverlap } from "rou3";
2
+
1
3
  // src/http-paths.ts
2
4
  /**
3
5
  * `@arbol-ai/maximus/http-paths`: versioned route templates, path parameter decoding, and the router that
4
- * matches a request to exactly one operation.
6
+ * matches a request to exactly one operation, on rou3's route tree.
5
7
  */
6
8
  /** A fixed path segment of a route template. */
7
9
  const STATIC_SEGMENT = /^[a-zA-Z0-9_-]+$/;
@@ -80,30 +82,35 @@ function routeName(route) {
80
82
  return `${route.definition.http?.method} ${route.definition.http?.path}`;
81
83
  }
82
84
  /**
85
+ * Two templates of one method that match a common path, in the order a refusal names them: from the last
86
+ * segment where one is fixed and the other a parameter, the fixed one first.
87
+ */
88
+ function overlapping(left, right) {
89
+ if (left.segments.length !== right.segments.length || !routesOverlap(left.pattern, right.pattern)) return;
90
+ for (let index = left.segments.length - 1; index >= 0; index -= 1) {
91
+ const leftFixed = !left.segments[index]?.startsWith("{");
92
+ if (leftFixed !== !right.segments[index]?.startsWith("{")) return leftFixed ? [left, right] : [right, left];
93
+ }
94
+ return [left, right];
95
+ }
96
+ /**
83
97
  * The router for a set of definitions: `match(method, path)` finds the one route a request reaches, with its
84
98
  * decoded parameters, and `ownsPath(path)` says whether any route answers a path. A definition without `http`
85
99
  * is skipped. Construction throws a TypeError for an unsupported method, a malformed template, a duplicate
86
- * route, or two templates that could match the same path. A fixed route is one map lookup; templates compile
87
- * into states with one transition per segment, so matching never scans the routes.
100
+ * route, or two templates that could match the same path; a fixed route may share its path with a template,
101
+ * and wins it. Matching is rou3's route tree, fixed segments before parameters.
88
102
  */
89
103
  function createHttpRouteResolver(definitions) {
90
- const exact = /* @__PURE__ */ new Map();
91
- const roots = /* @__PURE__ */ new Map();
92
- let nextId = 0;
93
- /** A new tree node with the next id. */
94
- const branch = () => {
95
- const node = {
96
- id: nextId,
97
- fixed: /* @__PURE__ */ new Map()
98
- };
99
- nextId += 1;
100
- return node;
101
- };
104
+ const router = createRouter();
105
+ const fixed = /* @__PURE__ */ new Set();
106
+ const shapes = /* @__PURE__ */ new Map();
107
+ const templates = /* @__PURE__ */ new Map();
102
108
  for (const definition of definitions) {
103
109
  if (!definition.http) continue;
104
- if (!HTTP_METHODS.has(definition.http.method)) throw new TypeError(`Operation routes require a supported HTTP method: ${definition.http.method} ${definition.http.path}`);
105
- const names = operationPathParameters(definition.http.path);
106
- const segments = definition.http.path.slice(1).split("/");
110
+ const { method, path } = definition.http;
111
+ if (!HTTP_METHODS.has(method)) throw new TypeError(`Operation routes require a supported HTTP method: ${method} ${path}`);
112
+ const names = operationPathParameters(path);
113
+ const segments = path.slice(1).split("/");
107
114
  const route = {
108
115
  definition,
109
116
  parameters: segments.flatMap((segment, position) => {
@@ -115,73 +122,35 @@ function createHttpRouteResolver(definitions) {
115
122
  })
116
123
  };
117
124
  if (names.length === 0) {
118
- const key = `${definition.http.method} ${definition.http.path}`;
119
- if (exact.has(key)) throw new TypeError(`Duplicate operation route: ${key}`);
120
- exact.set(key, route);
125
+ const key = `${method} ${path}`;
126
+ if (fixed.has(key)) throw new TypeError(`Duplicate operation route: ${key}`);
127
+ fixed.add(key);
128
+ addRoute(router, method, path, route);
121
129
  continue;
122
130
  }
123
- let node = roots.get(definition.http.method);
124
- if (!node) {
125
- node = branch();
126
- roots.set(definition.http.method, node);
127
- }
128
- for (const segment of segments) if (segment.startsWith("{")) {
129
- node.parameter ??= branch();
130
- node = node.parameter;
131
- } else {
132
- let child = node.fixed.get(segment);
133
- if (!child) {
134
- child = branch();
135
- node.fixed.set(segment, child);
136
- }
137
- node = child;
138
- }
139
- if (node.route) throw new TypeError(`Ambiguous operation path templates: ${routeName(node.route)} and ${routeName(route)}`);
140
- node.route = route;
141
- }
142
- const states = /* @__PURE__ */ new Map();
143
- /**
144
- * The state for a set of tree nodes: their routes (at most one), and for each next segment the state of
145
- * every node it can lead to, compiled once per set.
146
- */
147
- function compile(nodes) {
148
- const distinct = [...new Map(nodes.map((node) => [node.id, node])).values()];
149
- const key = distinct.map((node) => node.id).toSorted((left, right) => left - right).join(",");
150
- const known = states.get(key);
151
- if (known) return known;
152
- const routes = distinct.flatMap((node) => node.route ? [node.route] : []);
153
- if (routes.length > 1) throw new TypeError(`Ambiguous overlapping operation path templates: ${routes.map(routeName).join(" and ")}`);
154
- const state = {
155
- fixed: /* @__PURE__ */ new Map(),
156
- route: routes[0]
131
+ const shape = `${method} ${path.replaceAll(/\{\w+\}/g, "{}")}`;
132
+ const same = shapes.get(shape);
133
+ if (same) throw new TypeError(`Ambiguous operation path templates: ${routeName(same)} and ${routeName(route)}`);
134
+ shapes.set(shape, route);
135
+ const template = {
136
+ route,
137
+ segments,
138
+ pattern: path.replaceAll(/\{(\w+)\}/g, ":$1")
157
139
  };
158
- states.set(key, state);
159
- const parameters = distinct.flatMap((node) => node.parameter ? [node.parameter] : []);
160
- if (parameters.length > 0) state.parameter = compile(parameters);
161
- const fixed = new Set(distinct.flatMap((node) => [...node.fixed.keys()]));
162
- for (const segment of fixed) {
163
- const children = distinct.flatMap((node) => {
164
- const child = node.fixed.get(segment);
165
- return child ? [child] : [];
166
- });
167
- state.fixed.set(segment, compile([...children, ...parameters]));
168
- }
169
- return state;
140
+ templates.set(method, [...templates.get(method) ?? [], template]);
141
+ addRoute(router, method, template.pattern, route);
142
+ }
143
+ for (const declared of templates.values()) for (const [index, template] of declared.entries()) for (const other of declared.slice(0, index)) {
144
+ const pair = overlapping(other, template);
145
+ if (pair) throw new TypeError(`Ambiguous overlapping operation path templates: ${routeName(pair[0].route)} and ${routeName(pair[1].route)}`);
170
146
  }
171
- const templates = new Map([...roots].map(([method, root]) => [method, compile([root])]));
172
147
  /**
173
- * The route for a method and the path's segments: an exact route first, then one transition per segment
174
- * through the compiled states.
148
+ * The route for a method and the path's segments. An empty segment matches none, where rou3 would ignore a
149
+ * trailing slash.
175
150
  */
176
- function findRoute(method, segments) {
177
- const fixed = exact.get(`${method} /${segments.join("/")}`);
178
- if (fixed) return fixed;
179
- let state = templates.get(method);
180
- for (const segment of segments) {
181
- if (!segment || !state) return null;
182
- state = state.fixed.get(segment) ?? state.parameter;
183
- }
184
- return state?.route ?? null;
151
+ function routeOf(method, segments) {
152
+ if (segments.some((segment) => !segment)) return null;
153
+ return findRoute(router, method, `/${segments.join("/")}`, { params: false })?.data ?? null;
185
154
  }
186
155
  /**
187
156
  * The route a request reaches, with its path parameters: every segment is decoded before it is matched, so
@@ -196,7 +165,7 @@ function createHttpRouteResolver(definitions) {
196
165
  if (decoded === null) return null;
197
166
  segments.push(decoded);
198
167
  }
199
- const route = findRoute(method, segments);
168
+ const route = routeOf(method, segments);
200
169
  if (!route) return null;
201
170
  const parameters = {};
202
171
  for (const parameter of route.parameters) parameters[parameter.name] = segments[parameter.position] ?? "";
@@ -210,7 +179,7 @@ function createHttpRouteResolver(definitions) {
210
179
  /** Whether any route answers a declared path, so a transport cannot claim an operation's path. */
211
180
  ownsPath(path) {
212
181
  const segments = path.slice(1).split("/");
213
- return [...HTTP_METHODS].some((method) => findRoute(method, segments) !== null);
182
+ return [...HTTP_METHODS].some((method) => routeOf(method, segments) !== null);
214
183
  }
215
184
  };
216
185
  }
@@ -0,0 +1,29 @@
1
+ // src/internal/http-routes.ts
2
+ /**
3
+ * The parameter's schema in an object input, or in each member of a union. Every one must declare the
4
+ * parameter as a required string field, or this throws a TypeError.
5
+ */
6
+ function pathParameterSchemas(input, parameter) {
7
+ const node = input;
8
+ if (node.type === "object") {
9
+ const schema = node.properties?.[parameter];
10
+ if (!schema || schema.type !== "string" || !node.required?.includes(parameter)) throw new TypeError(`Path parameter "${parameter}" must be a required string input field.`);
11
+ return [schema];
12
+ }
13
+ if (Array.isArray(node.anyOf) && node.anyOf.length > 0) return node.anyOf.flatMap((schema) => pathParameterSchemas(schema, parameter));
14
+ throw new TypeError("Path parameters require object input contracts.");
15
+ }
16
+ /**
17
+ * The group a route's path names, which OpenAPI publishes as its tag: its first fixed segment after the
18
+ * version, in words, such as `Notes` for `/v1/notes/{noteId}` and `Task lists` for `/v1/task-lists`;
19
+ * undefined when only parameters follow the version.
20
+ */
21
+ function routeGroup(path) {
22
+ const segments = path.split("/").filter(Boolean);
23
+ const segment = (/^v[1-9][0-9]*$/.test(segments[0] ?? "") ? segments.slice(1) : segments).find((part) => !part.startsWith("{"));
24
+ if (segment === void 0) return;
25
+ const words = segment.replaceAll(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/).filter(Boolean).join(" ").toLowerCase();
26
+ return words.charAt(0).toUpperCase() + words.slice(1);
27
+ }
28
+
29
+ export { routeGroup as n, pathParameterSchemas as t };