@arbol-ai/maximus 7.3.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +36 -38
  2. package/bin/maximus.js +4 -0
  3. package/config/oxfmt.mjs +1 -0
  4. package/config/oxlint.mjs +10 -0
  5. package/dist/analytics/analytics.d.ts +21 -9
  6. package/dist/analytics/analytics.js +19 -5
  7. package/dist/body.d.ts +1 -1
  8. package/dist/body.js +2 -2
  9. package/dist/chunks/agent-skills-Ef65jTf_.js +49 -0
  10. package/dist/chunks/agent-skills-m7y1EUch.js +3 -0
  11. package/dist/chunks/{body-6LichrQm.js → body-DOIHwIIl.js} +14 -7
  12. package/dist/chunks/{correlation-BEkcFFGT.js → correlation-4b23a-a4.js} +8 -5
  13. package/dist/chunks/define-app-CfVZBt7D.js +336 -0
  14. package/dist/chunks/errors-WfyKhiyk.js +131 -0
  15. package/dist/chunks/execution-CfZEx_JP.js +84 -0
  16. package/dist/chunks/generate-C-9FKW0o.js +197 -0
  17. package/dist/chunks/handler-DWTGoduQ.js +140 -0
  18. package/dist/chunks/http-layout-_h7xwgPC.js +128 -0
  19. package/dist/chunks/http-paths-DMBxwpp6.js +218 -0
  20. package/dist/chunks/{json-Bu4BLT25.js → json-B14evE6-.js} +21 -5
  21. package/dist/chunks/names-ncD7A3DV.js +280 -0
  22. package/dist/chunks/openapi-CV0KmJpS.js +1588 -0
  23. package/dist/chunks/openapi-file-OjSs9mRv.js +83 -0
  24. package/dist/chunks/pages-DyC0m8Zb.js +14 -0
  25. package/dist/chunks/prepare-configured-BmRJLg6J.js +3 -0
  26. package/dist/chunks/prepare-configured-Cithjf80.js +52 -0
  27. package/dist/chunks/project-files-C0OX7MQQ.js +130 -0
  28. package/dist/chunks/query-kind-CWKAXEME.js +40 -0
  29. package/dist/chunks/record-DQUDTpEA.js +10 -0
  30. package/dist/chunks/result-CKgZHrnj.js +56 -0
  31. package/dist/chunks/{runtime-BPnaa-NK.js → runtime-CVVf5hmp.js} +50 -25
  32. package/dist/chunks/scaffold-DGrcjR3h.js +3 -0
  33. package/dist/chunks/scaffold-DZD6dfoZ.js +138 -0
  34. package/dist/chunks/{schemas-CzTvbXb6.js → schemas-p_aRcMC1.js} +30 -14
  35. package/dist/chunks/server-CCc7fil4.js +410 -0
  36. package/dist/chunks/src--HZrH1U9.js +568 -0
  37. package/dist/chunks/standard-failures-CLjxS2ea.js +74 -0
  38. package/dist/chunks/{telemetry-BTwB68m5.js → telemetry-C3LfZcOB.js} +32 -11
  39. package/dist/chunks/{types-BWxDd3tY.d.ts → types-BQYB4Ads.d.ts} +998 -337
  40. package/dist/chunks/{validation-r-sgmsqb.js → validation-fTohBT6R.js} +69 -28
  41. package/dist/chunks/workers-types-iONp32T4.d.ts +143 -0
  42. package/dist/chunks/yaml-Dk2L24yQ.js +74 -0
  43. package/dist/diagnostics.d.ts +6 -4
  44. package/dist/diagnostics.js +2 -2
  45. package/dist/errors.d.ts +2 -2
  46. package/dist/errors.js +2 -125
  47. package/dist/http-paths.d.ts +1 -1
  48. package/dist/http-paths.js +1 -197
  49. package/dist/index.d.ts +2 -2
  50. package/dist/index.js +12 -10
  51. package/dist/internals.d.ts +1 -1
  52. package/dist/internals.js +5 -3
  53. package/dist/mcp/index.d.ts +3 -2
  54. package/dist/mcp/index.js +5 -387
  55. package/dist/postgres/index.d.ts +25 -8
  56. package/dist/postgres/index.js +17 -8
  57. package/dist/project/config.d.ts +139 -0
  58. package/dist/project/config.js +196 -0
  59. package/dist/project/index.d.ts +17 -4
  60. package/dist/project/index.js +44 -9
  61. package/dist/projection.d.ts +14 -13
  62. package/dist/projection.js +8 -32
  63. package/dist/schemas.d.ts +1 -1
  64. package/dist/schemas.js +2 -2
  65. package/dist/standard-failures.d.ts +2 -89
  66. package/dist/standard-failures.js +1 -72
  67. package/dist/tooling/cli.js +151 -107
  68. package/dist/tooling/testing.js +2 -2
  69. package/dist/vite/cloudflare-workers.js +25 -0
  70. package/dist/vite/index.d.ts +157 -0
  71. package/dist/vite/index.js +1477 -0
  72. package/dist/webhooks.d.ts +12 -10
  73. package/dist/webhooks.js +26 -12
  74. package/dist/workers/runtime.d.ts +1 -1
  75. package/dist/workers/runtime.js +1 -1
  76. package/package.json +30 -22
  77. package/skills/maximus/SKILL.md +165 -69
  78. package/skills/maximus/references/deploying.md +73 -0
  79. package/skills/maximus/references/errors-and-results.md +114 -55
  80. package/skills/maximus/references/project.md +202 -0
  81. package/skills/maximus/references/routes-and-tools.md +256 -0
  82. package/skills/maximus/references/testing.md +137 -50
  83. package/skills/maximus/references/transports.md +113 -100
  84. package/skills/maximus/references/writing-code.md +84 -0
  85. package/templates/mcp/mcp/instructions.md.template +2 -0
  86. package/templates/mcp/routes/v1/greeting.get.ts.template +12 -0
  87. package/templates/mcp/tests/mcp.test.ts.template +36 -0
  88. package/templates/project/.agents/skills/project/SKILL.md.template +21 -12
  89. package/templates/project/.github/workflows/ci.yml.template +4 -1
  90. package/templates/project/CLAUDE.md.template +41 -22
  91. package/templates/project/README.md.template +54 -47
  92. package/templates/project/middleware/10-response.ts.template +16 -0
  93. package/templates/project/package.json.template +16 -8
  94. package/templates/project/pages/index.ts.template +2 -4
  95. package/templates/project/routes/v1/greeting.get.ts.template +10 -0
  96. package/templates/project/routes/v1/greeting.post.ts.template +12 -0
  97. package/templates/project/tests/greeting.test.ts.template +45 -0
  98. package/templates/project/tsconfig.json.template +8 -5
  99. package/templates/project/vite.config.ts.template +15 -7
  100. package/templates/web/app/main.tsx.template +16 -0
  101. package/templates/web/app/root.tsx.template +17 -0
  102. package/templates/web/app/routes/index.tsx.template +9 -0
  103. package/templates/web/index.html.template +12 -0
  104. package/templates/web/package.json.template +12 -0
  105. package/templates/web/tsconfig.json.template +7 -0
  106. package/templates/web/vite.config.ts.template +22 -0
  107. package/dist/chunks/execution-B-yy4C7N.js +0 -691
  108. package/dist/chunks/prepare-project-zi106pWF.js +0 -146
  109. package/dist/chunks/record-DY-lX9w1.js +0 -34
  110. package/dist/chunks/src-DPSpGNnT.js +0 -1164
  111. package/dist/client/client.d.ts +0 -129
  112. package/dist/client/client.js +0 -321
  113. package/dist/tooling/vite.d.ts +0 -3
  114. package/dist/tooling/vite.js +0 -44
  115. package/skills/maximus/references/adding-an-operation.md +0 -179
  116. package/skills/maximus/references/building-a-service.md +0 -167
  117. package/skills/maximus/references/migration-from-v2.md +0 -62
  118. package/skills/maximus/references/migration-to-v5.md +0 -37
  119. package/skills/maximus/references/publishing-and-verification.md +0 -39
  120. package/templates/project/cloudflare.config.ts.template +0 -24
  121. package/templates/project/routes/v1/greeting.ts.template +0 -22
  122. package/templates/project/src/app.ts.template +0 -2
  123. package/templates/project/src/application.ts.template +0 -26
  124. package/templates/project/src/index.ts.template +0 -3
  125. package/templates/project/src/worker.ts.template +0 -6
  126. package/templates/service/.agents/skills/project/SKILL.md.template +0 -10
  127. package/templates/service/.github/workflows/ci.yml.template +0 -21
  128. package/templates/service/.gitignore.template +0 -9
  129. package/templates/service/CLAUDE.md.template +0 -5
  130. package/templates/service/README.md.template +0 -45
  131. package/templates/service/cloudflare.config.ts.template +0 -30
  132. package/templates/service/package.json.template +0 -36
  133. package/templates/service/src/app.ts.template +0 -30
  134. package/templates/service/src/index.ts.template +0 -13
  135. package/templates/service/tests/contract.test.ts.template +0 -12
  136. package/templates/service/tsconfig.json.template +0 -16
  137. package/templates/service/vite.config.ts.template +0 -13
  138. package/templates/service/vitest.config.ts.template +0 -10
package/README.md CHANGED
@@ -1,52 +1,50 @@
1
1
  # @arbol-ai/maximus
2
2
 
3
- Maximus defines an organization-scoped service once and serves it on Cloudflare Workers over HTTP
4
- with its OpenAPI 3.1 contract, as MCP tools and as Worker RPC methods. It is one package: the root is
5
- the core (the fluent builder, TypeBox schemas, tokens and scopes, the error catalog, middleware, the
6
- native HTTP handler and OpenAPI), and each other capability is an entry.
3
+ Maximus builds organization-scoped APIs on Cloudflare Workers that people and AI agents call alike. Each
4
+ route is a file that declares its handler and its contract once, and the same Worker serves it over HTTP
5
+ with an OpenAPI 3.1 document, as an MCP tool when the route names one, and over native RPC to the Workers
6
+ you allow.
7
7
 
8
8
  ```sh
9
- bun add @arbol-ai/maximus
9
+ bun create maximus my-api
10
10
  ```
11
11
 
12
12
  ```ts
13
- import { defineErrors, maximus, ok, t } from '@arbol-ai/maximus';
14
-
15
- export const app = maximus<Env>({
16
- name: 'notes',
17
- namespace: 'notes',
18
- title: 'Notes',
19
- version: '1.0.0',
20
- origin: 'https://notes.example.com',
21
- tokens: { issuer: 'https://auth.example.com/', audience: 'https://notes.example.com' },
22
- errors: defineErrors({}),
23
- rpc: { callers: [] },
24
- })
25
- .operation(
26
- 'listNotes',
27
- {
28
- scope: 'notes:notes:read',
29
- effect: 'read',
30
- title: 'List notes',
31
- description: "List the organization's notes.",
32
- input: t.Object({}, { additionalProperties: false }),
33
- output: t.Object({ notes: t.Array(t.String()) }, { additionalProperties: false }),
34
- http: { method: 'GET', path: '/v1/notes' },
35
- },
36
- async () => ok({ notes: [] })
37
- )
38
- .build();
13
+ // routes/v1/notes/[noteId].get.ts
14
+ import { defineHandler, UuidSchema } from '@arbol-ai/maximus';
15
+
16
+ import { NoteSchema } from '#src/notes.ts';
17
+
18
+ /** GET /api/v1/notes/{noteId}, also the MCP tool get_note: one note of the caller's organization. */
19
+ export default defineHandler(
20
+ async ({ input, notes, fail }) => {
21
+ const note = await notes.find(input.noteId);
22
+ if (!note) {
23
+ return fail('NOTE_NOT_FOUND');
24
+ }
25
+ return note;
26
+ },
27
+ {
28
+ description: 'Read one note of the organization by its id.',
29
+ input: { noteId: UuidSchema },
30
+ output: NoteSchema,
31
+ failures: ['NOTE_NOT_FOUND'],
32
+ mcp: { name: 'get_note' },
33
+ }
34
+ );
39
35
  ```
40
36
 
41
- Entries: the root (the core), `/workers` (the Worker), `/mcp` (MCP tools), `/client` (a typed
42
- client), `/schemas` (browser-safe schemas), `/errors` and `/failures` (runtime-free), `/body`,
43
- `/webhooks`, `/http-paths`, `/projection`, `/diagnostics`, `/internals` (the transport SPI), `/analytics`,
44
- `/postgres` (with the optional peer `pg`), `/testing`, `/oxlint` and `/oxfmt`. It installs the
45
- `maximus` CLI and ships the Maximus Agent Skill in `skills/maximus/`.
46
- See [package exports](https://github.com/getarbol/maximus/blob/main/docs/reference/exports.md).
37
+ This package is the framework. Its root entry holds routes and operations, TypeBox schemas, tokens and
38
+ scopes, the error catalog and the HTTP handler with its OpenAPI document; each optional capability is an
39
+ entry of its own, such as `@arbol-ai/maximus/mcp`, `/workers` or `/postgres`, and a Worker carries only the
40
+ entries it imports. The package installs the `maximus` command and ships the Maximus skill for coding agents
41
+ in `skills/maximus/`. `maximus()` from `@arbol-ai/maximus/vite` makes `vite.config.ts` a project's one
42
+ configuration.
47
43
 
48
44
  - [Getting started](https://github.com/getarbol/maximus/blob/main/docs/getting-started.md)
49
45
  - [Concepts](https://github.com/getarbol/maximus/blob/main/docs/concepts.md)
50
- - [Configuration reference](https://github.com/getarbol/maximus/blob/main/docs/reference/configuration.md) and [operation reference](https://github.com/getarbol/maximus/blob/main/docs/reference/operations.md)
46
+ - [Package exports](https://github.com/getarbol/maximus/blob/main/docs/reference/exports.md), every entry
47
+ - [CLI](https://github.com/getarbol/maximus/blob/main/docs/reference/cli.md), the `maximus` command
48
+ - [All documentation](https://github.com/getarbol/maximus/blob/main/docs/README.md)
51
49
 
52
50
  Released under the MIT License.
package/bin/maximus.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ // The `maximus` command. It loads the built CLI, so a workspace that installs before it builds still links
3
+ // the command, which a package manager links only to a file that exists.
4
+ import '../dist/tooling/cli.js';
package/config/oxfmt.mjs CHANGED
@@ -21,6 +21,7 @@ export default defineConfig({
21
21
  '**/.maximus/**',
22
22
  '**/.wrangler/**',
23
23
  '**/dist/**',
24
+ '**/openapi*.json',
24
25
  '**/.agents/**',
25
26
  '**/.claude/**',
26
27
  '**/.codex/**',
package/config/oxlint.mjs CHANGED
@@ -98,6 +98,16 @@ export default defineConfig({
98
98
  // Node tooling imports stay explicit, and immutable option defaults stay local.
99
99
  'unicorn/import-style': 'off',
100
100
  'unicorn/no-object-as-default-parameter': 'off',
101
+ // A route file names its path parameter as its input field: `[taskId].get.ts`.
102
+ 'unicorn/filename-case': [
103
+ 'error',
104
+ {
105
+ case: 'kebabCase',
106
+ ignore: [
107
+ String.raw`^\[[a-z][A-Za-z0-9]*\](?:\.(?:get|post|put|patch|delete))?(?:\.(?:dev|prod))?\.[cm]?[jt]sx?$`,
108
+ ],
109
+ },
110
+ ],
101
111
  },
102
112
  overrides: [
103
113
  {
@@ -1,4 +1,4 @@
1
- import { $t as Observer, En as Result, Fn as Failure } from "../chunks/types-BWxDd3tY.js";
1
+ import { Sn as Observer } from "../chunks/types-BQYB4Ads.js";
2
2
  import { Static } from "@sinclair/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: import("@sinclair/typebox").TObject<{
@@ -18,15 +18,27 @@ export declare const ExecutionEventSchema: import("@sinclair/typebox").TObject<{
18
18
  }>;
19
19
  /** An analytics event. */
20
20
  export type ExecutionEvent = Static<typeof ExecutionEventSchema>;
21
- /** A store that records analytics events and answers whether it kept each one. */
22
- export interface ExecutionSink {
21
+ /** What `analytics()` takes: where events go, whether it records, and how events name the actor. */
22
+ export interface AnalyticsOptions<E> {
23
23
  /**
24
- * Keeps one event; an `ok: false` result means the event was not kept, which counts as a delivery failure.
24
+ * Whether events are recorded: a boolean, or a function that decides for each env; on by default. A
25
+ * function that throws turns recording off for that call.
25
26
  */
26
- record: (event: ExecutionEvent) => Promise<Result<null, Failure>>;
27
- }
28
- /** Safe metadata projection; no request or response bodies reach this sink. */
29
- export declare function analytics<E>(options: {
30
27
  enabled?: boolean | ((env: E) => boolean);
28
+ /** Keeps one event in the application's store; an `ok: false` result counts as a delivery failure. */
31
29
  record: (env: E, event: ExecutionEvent) => Promise<unknown>;
32
- }): Observer<E>;
30
+ /**
31
+ * How an event names its actor. `pseudonymous`, the default, records the hex SHA-256 of the organization id
32
+ * and the actor id: distinct actors stay countable, and an identity provider that uses email addresses as
33
+ * subjects does not put them in analytics. `id` records the actor id as the token states it.
34
+ */
35
+ actor?: 'pseudonymous' | 'id';
36
+ }
37
+ /**
38
+ * An observer that records one allowlisted event for each operation call: who called which operation, over
39
+ * which surface, how it ended and how long it took. No input, output, credential or message ever reaches
40
+ * it. `.build()` and `defineErrors` refuse a service name, an operation name or a failure code the event
41
+ * could not carry; an event that still does not match `ExecutionEventSchema` is never recorded: the
42
+ * observer fails, and diagnostics report it.
43
+ */
44
+ export declare function analytics<E>(options: AnalyticsOptions<E>): Observer<E>;
@@ -1,6 +1,7 @@
1
- import { i as UuidSchema, n as OrganizationIdSchema } from "../chunks/schemas-CzTvbXb6.js";
2
- import { a as telemetryEnabled } from "../chunks/telemetry-BTwB68m5.js";
1
+ import { i as UuidSchema, n as OrganizationIdSchema } from "../chunks/schemas-p_aRcMC1.js";
2
+ import { a as telemetryEnabled } from "../chunks/telemetry-C3LfZcOB.js";
3
3
  import { Type } from "@sinclair/typebox";
4
+ import { Value } from "@sinclair/typebox/value";
4
5
 
5
6
  // src/analytics/analytics.ts
6
7
  /**
@@ -34,16 +35,28 @@ const ExecutionEventSchema = Type.Object({
34
35
  outcome: Type.Union([Type.Literal("success"), Type.Literal("failure")]),
35
36
  errorCode: Type.Union([Type.String({ pattern: "^[A-Z][A-Z0-9_]{0,80}$" }), Type.Null()])
36
37
  }, { additionalProperties: false });
37
- /** Safe metadata projection; no request or response bodies reach this sink. */
38
+ /** The hex SHA-256 of an actor within its organization. */
39
+ async function pseudonym(organizationId, actorId) {
40
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${organizationId}:${actorId}`));
41
+ return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
42
+ }
43
+ /**
44
+ * An observer that records one allowlisted event for each operation call: who called which operation, over
45
+ * which surface, how it ended and how long it took. No input, output, credential or message ever reaches
46
+ * it. `.build()` and `defineErrors` refuse a service name, an operation name or a failure code the event
47
+ * could not carry; an event that still does not match `ExecutionEventSchema` is never recorded: the
48
+ * observer fails, and diagnostics report it.
49
+ */
38
50
  function analytics(options) {
39
51
  return { async execution(observation, env) {
40
52
  if (!telemetryEnabled(options, env)) return;
53
+ const { organizationId, actorId } = observation.principal;
41
54
  const event = {
42
55
  id: crypto.randomUUID(),
43
56
  service: observation.service,
44
57
  operation: observation.operation,
45
- organizationId: observation.principal.organizationId,
46
- actorId: observation.principal.actorId,
58
+ organizationId,
59
+ actorId: options.actor === "id" ? actorId : await pseudonym(organizationId, actorId),
47
60
  actorKind: observation.principal.actorKind,
48
61
  requestId: observation.principal.requestId,
49
62
  traceId: observation.traceId,
@@ -53,6 +66,7 @@ function analytics(options) {
53
66
  outcome: observation.outcome,
54
67
  errorCode: observation.errorCode
55
68
  };
69
+ if (!Value.Check(ExecutionEventSchema, event)) throw new TypeError("The analytics event does not match ExecutionEventSchema.");
56
70
  const result = await options.record(env, event);
57
71
  if (result && typeof result === "object" && "ok" in result && result.ok === false) throw new Error("Analytics sink rejected the event.");
58
72
  } };
package/dist/body.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { S as readBodyText, _ as retryAfterSeconds, b as HttpBodyFailureReason, g as readJsonResponse, h as readJsonBody, m as isJsonMediaType, v as BodyReadOptions, x as readBodyBytes, y as HttpBodyFailure } from "./chunks/types-BWxDd3tY.js";
1
+ import { _ as readBodyText, d as readJsonResponse, f as retryAfterSeconds, g as readBodyBytes, h as HttpBodyFailureReason, l as isJsonMediaType, m as HttpBodyFailure, p as BodyReadOptions, u as readJsonBody } from "./chunks/types-BQYB4Ads.js";
2
2
  export { type BodyReadOptions, type HttpBodyFailure, type HttpBodyFailureReason, isJsonMediaType, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, retryAfterSeconds };
package/dist/body.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as readBodyBytes, r as readBodyText } from "./chunks/body-6LichrQm.js";
2
- import { a as retryAfterSeconds, i as readJsonResponse, r as readJsonBody, t as isJsonMediaType } from "./chunks/json-Bu4BLT25.js";
1
+ import { n as readBodyBytes, r as readBodyText } from "./chunks/body-DOIHwIIl.js";
2
+ import { a as retryAfterSeconds, i as readJsonResponse, r as readJsonBody, t as isJsonMediaType } from "./chunks/json-B14evE6-.js";
3
3
 
4
4
  export { isJsonMediaType, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, retryAfterSeconds };
@@ -0,0 +1,49 @@
1
+ import { n as checkProjectFolder } from "./project-files-C0OX7MQQ.js";
2
+ import { existsSync, lstatSync, mkdirSync, readlinkSync, symlinkSync } from "node:fs";
3
+ import { join, relative, resolve } from "node:path";
4
+
5
+ // src/tooling/internal/agent-skills.ts
6
+ /**
7
+ * The Maximus skill where coding agents look for skills: `.agents/skills/maximus`, `.claude/skills/maximus`
8
+ * and `.codex/skills/maximus` link to the copy installed in `node_modules/@arbol-ai/maximus/skills/maximus`,
9
+ * so agents always read the skill of the release the project runs.
10
+ */
11
+ /** The installed skill, from the project's root. */
12
+ const INSTALLED = "node_modules/@arbol-ai/maximus/skills/maximus";
13
+ /** The folders coding agents read a project's skills from. */
14
+ const HARNESSES = [
15
+ ".agents",
16
+ ".claude",
17
+ ".codex"
18
+ ];
19
+ /**
20
+ * Links the installed Maximus skill into each agent's skills folder of the project at `directory`, and
21
+ * returns the links it created. A link already in place is kept; anything else at a link's path is refused,
22
+ * never replaced, and so is an agent's folder or skills folder that is a symlink. A link may point at nothing
23
+ * until `bun install` installs the package.
24
+ */
25
+ function linkAgentSkills(directory) {
26
+ const root = resolve(directory);
27
+ const planned = HARNESSES.map((harness) => {
28
+ const folder = join(root, harness, "skills");
29
+ return {
30
+ folder,
31
+ link: join(folder, "maximus"),
32
+ target: relative(folder, join(root, INSTALLED))
33
+ };
34
+ });
35
+ for (const { folder, link, target } of planned) {
36
+ checkProjectFolder(root, folder);
37
+ const present = lstatSync(link, { throwIfNoEntry: false });
38
+ if (present && !(present.isSymbolicLink() && readlinkSync(link) === target)) throw new TypeError(`${relative(root, link)} exists and is not the Maximus skill link; move it first.`);
39
+ }
40
+ const created = [];
41
+ for (const { folder, link, target } of planned) if (!existsSync(link) && !lstatSync(link, { throwIfNoEntry: false })) {
42
+ mkdirSync(folder, { recursive: true });
43
+ symlinkSync(target, link);
44
+ created.push(relative(root, link));
45
+ }
46
+ return created;
47
+ }
48
+
49
+ export { linkAgentSkills as t };
@@ -0,0 +1,3 @@
1
+ import { t as linkAgentSkills } from "./agent-skills-Ef65jTf_.js";
2
+
3
+ export { linkAgentSkills };
@@ -1,5 +1,5 @@
1
1
  // src/internal/body.ts
2
- /** Closed decoding vocabulary used by bounded transport readers. */
2
+ /** Every reason a bounded read can fail with: the values of a body failure's `data.reason`. */
3
3
  const HTTP_BODY_FAILURES = [
4
4
  "too_large",
5
5
  "invalid_length",
@@ -9,7 +9,10 @@ const HTTP_BODY_FAILURES = [
9
9
  "aborted",
10
10
  "read_failed"
11
11
  ];
12
- /** Construct only closed decoder metadata. No exception, input bytes or telemetry. */
12
+ /**
13
+ * The body failure for a reason: `HTTP_BODY_INVALID`, with the reason as its only data and nothing of the
14
+ * body. A reason outside `HTTP_BODY_FAILURES` throws a TypeError.
15
+ */
13
16
  function httpBodyFailure(reason) {
14
17
  if (!HTTP_BODY_FAILURES.includes(reason)) throw new TypeError("Invalid HTTP body reason");
15
18
  return {
@@ -20,9 +23,11 @@ function httpBodyFailure(reason) {
20
23
  };
21
24
  }
22
25
  /**
23
- * Read at most the owner's byte limit, including chunked bodies. Returns original
24
- * bytes for signature verification. Expected decoding failures are plain results.
25
- * Rejected streams are cancelled without awaiting a remote acknowledgement.
26
+ * Reads a request's or a response's body as bytes, at most `maxBytes` of them, chunked bodies included, and
27
+ * answers them unchanged, as a signature check needs them; an absent body is no bytes. A `content-length`
28
+ * that is malformed or above the limit is refused before reading. Every expected failure is a result
29
+ * (`too_large`, `invalid_length`, `aborted` or `read_failed`), and a refused body is cancelled without
30
+ * waiting for the other side.
26
31
  */
27
32
  async function readBodyBytes(source, options) {
28
33
  if (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 1) throw new RangeError("Invalid body byte limit");
@@ -60,7 +65,6 @@ async function readBodyBytes(source, options) {
60
65
  let size = 0;
61
66
  try {
62
67
  while (true) {
63
- if (options.signal?.aborted) return fail("aborted");
64
68
  const chunk = await reader.read();
65
69
  if (options.signal?.aborted) return fail("aborted");
66
70
  if (chunk.done) break;
@@ -85,7 +89,10 @@ async function readBodyBytes(source, options) {
85
89
  reader.releaseLock();
86
90
  }
87
91
  }
88
- /** Decode bounded UTF-8; signed text adapters can retain vendor replacement semantics. */
92
+ /**
93
+ * Reads a body as `readBodyBytes` does and decodes it as UTF-8. Invalid UTF-8 fails as `invalid_utf8`,
94
+ * unless `fatalUtf8: false` replaces it with U+FFFD, as a provider that signs its decoded text may require.
95
+ */
89
96
  async function readBodyText(source, options) {
90
97
  const bytes = await readBodyBytes(source, options);
91
98
  if (!bytes.ok) return bytes;
@@ -7,14 +7,17 @@
7
7
  const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8
8
  /** A Cloudflare ray id, with its optional data center suffix. */
9
9
  const RAY_PATTERN = /^[0-9a-f]{16}(?:-[A-Z]{3})?$/;
10
- /** Only technical support identifiers. Never use these values as authority or dedupe keys. */
10
+ /**
11
+ * Whether a value is a request id: a UUID or a Cloudflare ray id. A request id correlates diagnostics; never
12
+ * use one as authority or as a deduplication key.
13
+ */
11
14
  function isRequestId(value) {
12
15
  return typeof value === "string" && (UUID_PATTERN.test(value) || RAY_PATTERN.test(value));
13
16
  }
14
17
  /**
15
- * Public ingress mints an id by default. Only pass trustedEdgeRay from the
16
- * Cloudflare edge or a separately authenticated internal caller; arbitrary
17
- * X-Request-Id/CF-Ray supplied by an untrusted caller must not be adopted.
18
+ * A request id: `trustedEdgeRay` when it is a valid request id, otherwise a random UUID. Pass a ray id only
19
+ * from the Cloudflare edge or from a caller authenticated separately, never an `x-request-id` or `cf-ray`
20
+ * value an untrusted caller sent.
18
21
  */
19
22
  function createRequestId(trustedEdgeRay) {
20
23
  return isRequestId(trustedEdgeRay) ? trustedEdgeRay : crypto.randomUUID();
@@ -31,7 +34,7 @@ function parseTraceParent(value) {
31
34
  }
32
35
  /**
33
36
  * The correlation to persist with durable work: a valid request id and, when it parses, the originating
34
- * `traceparent`.
37
+ * `traceparent`. A request id that is not one throws a TypeError.
35
38
  */
36
39
  function durableCorrelation(requestId, originTraceParent) {
37
40
  if (!isRequestId(requestId)) throw new TypeError("Invalid correlation id");