@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
@@ -5,7 +5,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
5
5
  * Safe error descriptions for diagnostics: an error's known names, its causes' names, its issue count and
6
6
  * its stack locations, never a message.
7
7
  */
8
- /** Built-in identities only; each consumer supplies its domain error names. */
8
+ /** The built-in error names a description keeps; `createDiagnostics` adds the names a consumer supplies. */
9
9
  const BUILTIN_ERROR_NAMES = [
10
10
  "AbortError",
11
11
  "AggregateError",
@@ -19,7 +19,10 @@ const BUILTIN_ERROR_NAMES = [
19
19
  "TypeError",
20
20
  "URIError"
21
21
  ];
22
- /** Read a diagnostic property without letting a getter or Proxy break recovery. */
22
+ /**
23
+ * A property of a thrown value, or undefined when it has none or reading it throws, so a getter or a Proxy
24
+ * cannot break the handling of an error.
25
+ */
23
26
  function errorProperty(value, key) {
24
27
  try {
25
28
  return typeof value === "object" && value !== null && key in value ? Reflect.get(value, key) : void 0;
@@ -28,9 +31,11 @@ function errorProperty(value, key) {
28
31
  }
29
32
  }
30
33
  /**
31
- * Create a pure projection for SDK events and owner-written log lines. Names are
32
- * developer constants, never values taken from an upstream response. Messages,
33
- * record keys, URLs and query parameters are never returned. No logging occurs.
34
+ * The error describer for diagnostics, for an SDK's events or a log line its owner writes: `describeError`
35
+ * answers an `ErrorDescription`, and `safeErrorName` an error's name when it is built in or among
36
+ * `errorNames`, else `UnknownError`. Pass constant names of your own errors, never a value taken from an
37
+ * upstream response. No message, record key, URL or query parameter reaches a description, and nothing is
38
+ * logged.
34
39
  */
35
40
  function createDiagnostics(errorNames = []) {
36
41
  const names = /* @__PURE__ */ new Set([...BUILTIN_ERROR_NAMES, ...errorNames]);
@@ -118,7 +123,10 @@ function activeTraceId(config) {
118
123
  return null;
119
124
  }
120
125
  }
121
- /** Logs a refused admission (`maximus.admission.rejected`) and hands it to the observers. */
126
+ /**
127
+ * Logs a refused admission (`maximus.admission.rejected`) and hands it to the observers as background work.
128
+ * Nothing is recorded while telemetry is off or without a background context.
129
+ */
122
130
  function recordAdmission(manifest, env, background, admission) {
123
131
  if (!background || !telemetryEnabled(manifest.telemetry, env)) return;
124
132
  const event = {
@@ -148,11 +156,20 @@ function recordAdmission(manifest, env, background, admission) {
148
156
  for (const observer of manifest.telemetry?.observers ?? []) if (observer.admission) deliver(background, event.requestId, () => observer.admission?.(event, env));
149
157
  }
150
158
  /**
151
- * Whether telemetry is on for this env: it is unless `enabled` is false, or a function that returns false or
152
- * has no env to read.
159
+ * Whether telemetry is on for this env: it is unless `enabled` is false, or a function that returns false,
160
+ * has no env to read or throws.
153
161
  */
154
162
  function telemetryEnabled(config, env) {
155
- return typeof config?.enabled === "function" ? env !== void 0 && config.enabled(env) : config?.enabled !== false;
163
+ if (typeof config?.enabled !== "function") return config?.enabled !== false;
164
+ if (env === void 0) return false;
165
+ try {
166
+ return config.enabled(env);
167
+ } catch {
168
+ try {
169
+ console.error(JSON.stringify({ event: "maximus.telemetry.switch_failed" }));
170
+ } catch {}
171
+ return false;
172
+ }
156
173
  }
157
174
  /** Describes errors by their built-in names only. */
158
175
  const diagnostics = createDiagnostics();
@@ -182,7 +199,8 @@ function diagnosticsEnabled() {
182
199
  }
183
200
  /**
184
201
  * Logs an unexpected error by its safe description only (`maximus.unexpected`: error and cause names, issue
185
- * count, stack locations; never a message) and tells the observers.
202
+ * count, stack locations; never a message) and tells the observers of the current `withDiagnostics` scope.
203
+ * It does nothing while diagnostics are off.
186
204
  */
187
205
  function reportUnexpected(error, surface = "application", requestId) {
188
206
  if (!diagnosticsEnabled()) return;
@@ -198,7 +216,10 @@ function reportUnexpected(error, surface = "application", requestId) {
198
216
  observer.error?.(error, surface, requestId);
199
217
  } catch {}
200
218
  }
201
- /** Hands the observation of one operation call to the observers, as background work. */
219
+ /**
220
+ * Hands the observation of one operation call to the observers, as background work. Nothing is recorded
221
+ * while telemetry is off or without a background context.
222
+ */
202
223
  function recordExecution(manifest, env, background, invocation) {
203
224
  if (!background || !telemetryEnabled(manifest.telemetry, env)) return;
204
225
  const event = {