@arbol-ai/maximus 8.1.0 → 8.4.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 (62) 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 -2
  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/{json-B14evE6-.js → destination-DIkn8W6K.js} +65 -1
  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-CGtS2rOb.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-D67OfW9B.js} +40 -19
  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/diagnostics.d.ts +1 -1
  31. package/dist/errors.d.ts +1 -1
  32. package/dist/errors.js +1 -1
  33. package/dist/http-paths.d.ts +1 -1
  34. package/dist/http-paths.js +1 -1
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +11 -10
  37. package/dist/internals.d.ts +1 -1
  38. package/dist/internals.js +4 -4
  39. package/dist/mcp/index.d.ts +1 -1
  40. package/dist/mcp/index.js +1 -1
  41. package/dist/mcp/tasks.d.ts +33 -0
  42. package/dist/mcp/tasks.js +3 -0
  43. package/dist/project/config.d.ts +2 -2
  44. package/dist/project/config.js +3 -2
  45. package/dist/project/index.d.ts +2 -2
  46. package/dist/project/index.js +3 -3
  47. package/dist/schemas.d.ts +2 -2
  48. package/dist/schemas.js +3 -3
  49. package/dist/standard-failures.d.ts +1 -1
  50. package/dist/tooling/cli.js +2 -2
  51. package/dist/vite/index.d.ts +1 -1
  52. package/dist/vite/index.js +6 -5
  53. package/dist/webhooks.d.ts +13 -2
  54. package/dist/webhooks.js +38 -1
  55. package/dist/workers/runtime.d.ts +1 -1
  56. package/dist/workers/runtime.js +1 -1
  57. package/package.json +11 -3
  58. package/skills/maximus/SKILL.md +7 -4
  59. package/skills/maximus/references/routes-and-tools.md +9 -1
  60. package/dist/chunks/result-CKgZHrnj.js +0 -56
  61. package/dist/chunks/schemas-BOFxZP1c.js +0 -227
  62. package/dist/chunks/validation-DMu0rkMQ.js +0 -670
@@ -0,0 +1,201 @@
1
+ import "ajv-formats/dist/formats.js";
2
+ import "typebox/format";
3
+ import "typebox/system";
4
+ import { AssertError, DecodeUnsafe, HasCodec, Value } from "typebox/value";
5
+
6
+ // src/internal/decode-issues.ts
7
+ /** Every issue of a refused value, as `readSchema` throws it and `checkSchema` returns it. */
8
+ var SchemaValidationError = class extends TypeError {
9
+ /** Every issue of the refused value; the error's message is the first one's. */
10
+ issues;
11
+ constructor(issues) {
12
+ super(issues[0]?.message ?? "The input does not match its schema.");
13
+ this.name = "SchemaValidationError";
14
+ this.issues = issues;
15
+ }
16
+ };
17
+ /**
18
+ * What an owner refinement's message starts with when it carries issues of its own, as JSON, or the errors of
19
+ * the schema a pipe reads its value into: TypeBox reports a refinement as one message at the refined value.
20
+ */
21
+ const CARRIED = "\0maximus:";
22
+ /** A refinement's message that carries issues at their paths below the refined value. */
23
+ function carriedIssues(issues) {
24
+ return `${CARRIED}${JSON.stringify(issues)}`;
25
+ }
26
+ /** A refinement's message that carries the errors of another schema, read below the refined value. */
27
+ function carriedErrors(errors) {
28
+ return carriedIssues(schemaIssues(errors));
29
+ }
30
+ /** The segments of a JSON Pointer, unescaped. */
31
+ function segments(path) {
32
+ return path.split("/").slice(1).map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
33
+ }
34
+ /** The issues of a refinement's error at its value's path: those it carries, or its own message. */
35
+ function refinementIssues(message, path) {
36
+ if (!message.startsWith(CARRIED)) return [{
37
+ code: "custom",
38
+ message,
39
+ path
40
+ }];
41
+ return JSON.parse(message.slice(9)).map((issue) => ({
42
+ ...issue,
43
+ path: [...path, ...issue.path]
44
+ }));
45
+ }
46
+ /**
47
+ * Field issues for TypeBox's errors, in their order. A missing or an unexpected property is an issue at its own
48
+ * path; a union that matched no member is one issue, its members' errors left out; a refinement is the issues
49
+ * it carries, or its message.
50
+ */
51
+ function schemaIssues(errors) {
52
+ const unions = errors.filter((error) => error.keyword === "anyOf").map(({ schemaPath }) => `${schemaPath}/anyOf/`);
53
+ const issues = [];
54
+ for (const error of errors) {
55
+ if (unions.some((union) => error.schemaPath.startsWith(union))) continue;
56
+ const path = segments(error.instancePath);
57
+ if (error.keyword === "required") for (const name of error.params.requiredProperties) issues.push({
58
+ code: "invalid_input",
59
+ message: "must be present",
60
+ path: [...path, name]
61
+ });
62
+ else if (error.keyword === "additionalProperties") for (const name of error.params.additionalProperties) issues.push({
63
+ code: "invalid_input",
64
+ message: "must not be present",
65
+ path: [...path, name]
66
+ });
67
+ else if (error.keyword === "~refine") issues.push(...refinementIssues(error.params.message, path));
68
+ else if (!(error.keyword === "boolean" && error.schemaPath.endsWith("/additionalProperties"))) issues.push({
69
+ code: "invalid_input",
70
+ message: error.message,
71
+ path
72
+ });
73
+ }
74
+ return issues;
75
+ }
76
+ /**
77
+ * The issues of a refused decode, at most `limit`, each with its path from the input's root, or null when
78
+ * nothing refused the input: an owner codec threw something other than a `SchemaValidationError`, which is the
79
+ * codec's fault for the caller to report. TypeBox builds at most as many errors as `internal/value.ts` allows,
80
+ * so an input with millions of them costs no more than a refusal carries.
81
+ */
82
+ function decodeIssues(error, limit = Number.POSITIVE_INFINITY) {
83
+ if (error instanceof SchemaValidationError) return error.issues.slice(0, limit);
84
+ if (error instanceof AssertError) return schemaIssues(error.cause.errors).slice(0, limit);
85
+ return null;
86
+ }
87
+ /** RFC 6901 JSON Pointer of an issue path; the empty string names the whole input. */
88
+ function jsonPointer(path) {
89
+ return path.map((part) => `/${String(part).replaceAll("~", "~0").replaceAll("/", "~1")}`).join("");
90
+ }
91
+
92
+ // src/validation.ts
93
+ /**
94
+ * Checks a value against a schema without decoding it: the value when it matches, else an `INVALID_INPUT`
95
+ * failure without issues. Use `decodeInput` for input with defaults and codecs.
96
+ */
97
+ function parseInput(schema, input) {
98
+ if (Value.Check(schema, input)) return {
99
+ ok: true,
100
+ value: input
101
+ };
102
+ return {
103
+ ok: false,
104
+ error: {
105
+ code: "INVALID_INPUT",
106
+ message: "The input does not match its schema.",
107
+ retryable: false,
108
+ data: {}
109
+ }
110
+ };
111
+ }
112
+ /** Checks a value against a schema and returns it typed, or throws a TypeError that names no value. */
113
+ function parseSchema(schema, input) {
114
+ if (!Value.Check(schema, input)) throw new TypeError("Value does not match its schema");
115
+ return input;
116
+ }
117
+ /**
118
+ * Whether a value is a bounded plain JSON tree, which TypeBox's traversals expect and every transport admits:
119
+ * no cycles, class instances, functions, non-finite numbers, nesting beyond 100 levels or own `__proto__` key.
120
+ */
121
+ function boundedInput(value, depth = 0, parents = /* @__PURE__ */ new Set()) {
122
+ if (depth > 100) return false;
123
+ if (value === void 0 || value === null || typeof value === "string" || typeof value === "boolean") return true;
124
+ if (typeof value === "number") return Number.isFinite(value);
125
+ if (typeof value !== "object" || parents.has(value)) return false;
126
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return false;
127
+ if (Object.hasOwn(value, "__proto__")) return false;
128
+ parents.add(value);
129
+ const valid = Object.values(value).every((child) => boundedInput(child, depth + 1, parents));
130
+ parents.delete(value);
131
+ return valid;
132
+ }
133
+ /**
134
+ * Decodes input against its schema: admits only a bounded plain JSON tree, applies the declared defaults to a
135
+ * copy, checks it, refinements included, and runs its codecs. Throws a `SchemaValidationError` (or TypeBox's
136
+ * assertion error) when the input is refused, and whatever an owner codec throws otherwise. Output is checked,
137
+ * never decoded: what a handler returns must already be canonical.
138
+ */
139
+ function decodeSchema(schema, input) {
140
+ return admitSchema(schema, input).value;
141
+ }
142
+ /** Decodes input as `decodeSchema` does, and also answers what the schema checked, before any codec ran. */
143
+ function admitSchema(schema, input) {
144
+ if (!boundedInput(input)) throw new SchemaValidationError([{
145
+ code: "invalid_input",
146
+ message: "Input must be a bounded plain JSON tree.",
147
+ path: []
148
+ }]);
149
+ const checked = Value.Default(schema, Value.Clone(input));
150
+ Value.Assert(schema, checked);
151
+ return {
152
+ value: HasCodec(schema) ? DecodeUnsafe({}, schema, Value.Clone(checked)) : checked,
153
+ checked
154
+ };
155
+ }
156
+ /** The longest path or message one issue carries. */
157
+ const MAX_ISSUE_TEXT = 256;
158
+ /**
159
+ * Decodes input as `decodeSchema` does and answers a refusal as the `INVALID_INPUT` failure, with its first
160
+ * field issues: where the input failed and what was expected, never a value. A fault of an owner codec, an
161
+ * error that refuses nothing, is thrown for the caller to report: it is the server's failure, not the input's.
162
+ */
163
+ function decodeInput(schema, input) {
164
+ const admitted = admitInput(schema, input);
165
+ return admitted.ok ? {
166
+ ok: true,
167
+ value: admitted.value
168
+ } : admitted;
169
+ }
170
+ /**
171
+ * `decodeInput`, also answering, for an admitted input, `checked`: the plain JSON its schema checked before any
172
+ * codec ran, the one shape the schema's own keywords describe.
173
+ */
174
+ function admitInput(schema, input) {
175
+ let admitted;
176
+ try {
177
+ admitted = admitSchema(schema, input);
178
+ } catch (error) {
179
+ const refused = decodeIssues(error, 10);
180
+ if (!refused) throw error;
181
+ return {
182
+ ok: false,
183
+ error: {
184
+ code: "INVALID_INPUT",
185
+ message: "The input does not match its schema.",
186
+ retryable: false,
187
+ data: { issues: refused.map((issue) => ({
188
+ path: jsonPointer(issue.path).slice(0, MAX_ISSUE_TEXT),
189
+ message: issue.message.slice(0, MAX_ISSUE_TEXT)
190
+ })) }
191
+ }
192
+ };
193
+ }
194
+ return {
195
+ ok: true,
196
+ value: admitted.value,
197
+ checked: admitted.checked
198
+ };
199
+ }
200
+
201
+ export { parseSchema as a, carriedIssues as c, HasCodec as d, Value as f, parseInput as i, decodeIssues as l, decodeInput as n, SchemaValidationError as o, decodeSchema as r, carriedErrors as s, admitInput as t, DecodeUnsafe as u };
@@ -1,4 +1,4 @@
1
- import { Cr as Failure, E as HttpRoute, T as HttpOptions, dr as Result, er as Principal, in as AppManifest, mn as OperationShape, n as Static, r as TSchema } from "./types-Dqo3oGig.js";
1
+ import { D as HttpRoute, E as HttpOptions, cr as Principal, dn as AppManifest, jr as Failure, n as Static, r as TSchema, un as TaskStore, xn as OperationShape, yr as Result } from "./types-BfGa2aJT.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 {
@@ -101,6 +101,11 @@ interface WorkerRuntime<E, O extends Record<string, OperationShape>> {
101
101
  * methods and type.
102
102
  */
103
103
  durableObject: <T extends DurableObject<E>, D extends new (state: DurableObject['ctx'], env: E) => T>(implementation: D) => D;
104
+ /**
105
+ * The task store of the operations that declare `task: true`: export it by name, `MaximusTasks`, as the class
106
+ * of a SQLite Durable Object binding named `MAXIMUS_TASKS`.
107
+ */
108
+ tasks: new (state: DurableObject['ctx'], env: E) => DurableObject<E> & TaskStore;
104
109
  }
105
110
  /**
106
111
  * What `createWorker` takes besides the application: the Worker's other handlers, its transports, the HTTP
@@ -1,4 +1,4 @@
1
- import { Ar as TraceParent, Bn as withDiagnostics, Fn as TelemetryConfig, In as diagnosticsEnabled, Ln as recordExecution, Mn as BackgroundContext, Mr as durableCorrelation, Nn as ExecutionObservation, Nr as isRequestId, Pn as Observer, Pr as parseTraceParent, Rn as reportUnexpected, jr as createRequestId, kr as DurableCorrelation, zn as telemetryEnabled } from "./chunks/types-Dqo3oGig.js";
1
+ import { Bn as BackgroundContext, Br as durableCorrelation, Gn as recordExecution, Hn as Observer, Hr as parseTraceParent, Jn as withDiagnostics, Kn as reportUnexpected, Lr as DurableCorrelation, Rr as TraceParent, Un as TelemetryConfig, Vn as ExecutionObservation, Vr as isRequestId, Wn as diagnosticsEnabled, qn as telemetryEnabled, zr as createRequestId } from "./chunks/types-BfGa2aJT.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 { Cr as Failure, Dr as resultSchema, Er as defineErrors, Nr as isRequestId, Or as standardErrors, Sr as ErrorFactory, Tr as FailureSchema, br as ErrorCatalog, vr as CreateArguments, wr as FailureData, xr as ErrorDefinition, yr as DefinedErrors } from "./chunks/types-Dqo3oGig.js";
1
+ import { Ar as ErrorFactory, Dr as DefinedErrors, Er as CreateArguments, Fr as resultSchema, Ir as standardErrors, Mr as FailureData, Nr as FailureSchema, Or as ErrorCatalog, Pr as defineErrors, Vr as isRequestId, jr as Failure, kr as ErrorDefinition } from "./chunks/types-BfGa2aJT.js";
2
2
  export { CreateArguments, DefinedErrors, ErrorCatalog, ErrorDefinition, ErrorFactory, Failure, FailureData, FailureSchema, defineErrors, isRequestId, resultSchema, standardErrors };
package/dist/errors.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { r as isRequestId } from "./chunks/correlation-4b23a-a4.js";
2
- import { i as standardErrors, n as defineErrors, r as resultSchema, t as FailureSchema } from "./chunks/errors-CWgE9uvM.js";
2
+ import { i as standardErrors, n as defineErrors, r as resultSchema, t as FailureSchema } from "./chunks/errors-BoutSmiy.js";
3
3
 
4
4
  export { FailureSchema, defineErrors, isRequestId, resultSchema, standardErrors };
@@ -1,2 +1,2 @@
1
- import { C as operationPathParameters, S as isPathParameterValue, _ as HttpRouteDefinition, b as decodePathParameter, v as HttpRouteMatch, x as isInputHeaderName, y as createHttpRouteResolver } from "./chunks/types-Dqo3oGig.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-BfGa2aJT.js";
2
2
  export { HttpRouteDefinition, HttpRouteMatch, createHttpRouteResolver, decodePathParameter, isInputHeaderName, isPathParameterValue, operationPathParameters };
@@ -1,3 +1,3 @@
1
- import { a as operationPathParameters, i as isPathParameterValue, n as decodePathParameter, r as isInputHeaderName, t as createHttpRouteResolver } from "./chunks/http-paths-DMBxwpp6.js";
1
+ import { a as operationPathParameters, i as isPathParameterValue, n as decodePathParameter, r as isInputHeaderName, t as createHttpRouteResolver } from "./chunks/http-paths-D043DkJv.js";
2
2
 
3
3
  export { createHttpRouteResolver, decodePathParameter, isInputHeaderName, isPathParameterValue, operationPathParameters };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as PageInfoSchema, $n as matchesScopes, A as createHttpHandler, At as ContextArguments, B as DeletedObjectSchema, Bt as HandlerOptions, Cr as Failure, D as HttpTransport, Dr as resultSchema, Dt as parseInput, E as HttpRoute, Er as defineErrors, Fn as TelemetryConfig, Ft as HandlerAnswer, G as NamedReferenceSchema, Gn as TokenPolicy, Gt as SchemaOrFields, H as HexColorSchema, Hn as TokenAlgorithm, It as HandlerArguments, J as PostalAddressSchema, Jn as TokenSource, Jt as defineAuth, K as PhoneNumberSchema, Kn as TokenResolutionContext, Kt as ToolDeclaration, L as UuidSchema, Lt as HandlerDeclaration, M as EmptyInputSchema, Mn as BackgroundContext, Mt as DomainCode, N as OrganizationIdSchema, Nn as ExecutionObservation, Nt as Fail, O as RouteContext, Or as standardErrors, Ot as parseSchema, Pn as Observer, Pt as Failed, Q as PageInfo, Qn as ScopeMatch, Qt as defineTool, Rn as reportUnexpected, Rt as HandlerHttp, Sr as ErrorFactory, T as HttpOptions, Tr as FailureSchema, U as HttpsUrlSchema, Un as TokenClaims, Ut as RouteBody, V as EmailAddressSchema, Vn as TokenAccess, Vt as PreparedContext, W as NamedReference, Wn as TokenDevelopment, Wt as SchemaOf, X as SignedUrlSchema, Xn as createTokenVerifier, Xt as defineHandler, Y as SignedUrl, Yn as createTokenAuthorization, Yt as defineContext, Z as Page, Zn as projectToken, Zt as defineTelemetry, _ as HttpRouteDefinition, _r as AttachmentOutputSchema, a as t, an as Exposure, ar as protectedResourceMetadata, br as ErrorCatalog, c as isJsonMediaType, cn as McpConfiguration, cr as BinaryBody, d as retryAfterSeconds, dr as Result, er as Principal, et as PageQuery, f as BodyReadOptions, fn as OperationMiddleware, fr as Success, g as readBodyText, gn as isPublicOperation, gr as Attachment, h as readBodyBytes, hr as ok, i as Type, in as AppManifest, ir as OAuthResource, j as projectAccessToken, jn as AdmissionObservation, jt as ContextDeclaration, k as TransportContext, kt as AuthOptions, l as readJsonBody, ln as McpGuide, lr as BodyFailure, m as HttpBodyFailureReason, mn as OperationShape, mr as isResult, n as Static, nn as ApplicationConfiguration, nr as TokenClient, nt as TPage, o as createOpenApi, on as Invocation, p as HttpBodyFailure, pn as OperationScope, pr as err, q as PostalAddress, qn as TokenScheme, qt as ToolOptions, r as TSchema, rn as maximus, rr as TokenPrincipal, rt as pageLimit, s as createRpcOpenApi, sn as InvocationAuthority, tn as ApplicationBuilder, tr as PrincipalSchema, tt as PageQueryFields, u as readJsonResponse, un as McpSkill, ur as FailureResult, v as HttpRouteMatch, vn as operationMatchesScopes, w as HttpMiddleware, wr as FailureData, xr as ErrorDefinition, y as createHttpRouteResolver, yn as operationScopes, yr as DefinedErrors, z as DeletedObject, zt as HandlerMcp } from "./chunks/types-Dqo3oGig.js";
2
- export { type AdmissionObservation, type AppManifest, type ApplicationBuilder, type ApplicationConfiguration, type Attachment, AttachmentOutputSchema, type AuthOptions, type BackgroundContext, 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 McpConfiguration, type McpGuide, type McpSkill, type NamedReference, NamedReferenceSchema, type OAuthResource, type Observer, type OperationMiddleware, type OperationScope, type OperationShape, OrganizationIdSchema, Page, type PageInfo, PageInfoSchema, type PageQuery, PageQueryFields, PhoneNumberSchema, type PostalAddress, PostalAddressSchema, type PreparedContext, type Principal, PrincipalSchema, type Result, type RouteBody, type RouteContext, type SchemaOf, type SchemaOrFields, type ScopeMatch, type SignedUrl, SignedUrlSchema, 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 ToolDeclaration, type ToolOptions, type TransportContext, Type, UuidSchema, createHttpHandler, createHttpRouteResolver, createOpenApi, createRpcOpenApi, createTokenAuthorization, createTokenVerifier, defineAuth, defineContext, defineErrors, defineHandler, defineTelemetry, defineTool, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectAccessToken, projectToken, protectedResourceMetadata, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resultSchema, retryAfterSeconds, standardErrors, t };
1
+ import { $ as PageInfo, $n as TokenPolicy, $t as defineContext, A as TransportContext, Ar as ErrorFactory, B as DeletedObject, Bn as BackgroundContext, Bt as HandlerArguments, Cn as isPublicOperation, Cr as ok, D as HttpRoute, Dn as SchemaKeywords, Dr as DefinedErrors, E as HttpOptions, En as operationScopes, Fr as resultSchema, Ft as ContextDeclaration, G as NamedReference, Gt as PreparedContext, H as EmailAddressSchema, Hn as Observer, Ht as HandlerHttp, Ir as standardErrors, It as DomainCode, J as PostalAddress, Jt as SchemaOf, K as NamedReferenceSchema, Kn as reportUnexpected, Lt as Fail, M as projectAccessToken, Mr as FailureData, Mt as parseSchema, N as EmptyInputSchema, Nr as FailureSchema, Nt as AuthOptions, O as HttpTransport, Or as ErrorCatalog, P as OrganizationIdSchema, Pr as defineErrors, Pt as ContextArguments, Q as Page, Qn as TokenDevelopment, Qt as defineAuth, R as UuidSchema, Rt as Failed, Sr as isResult, T as HttpMiddleware, Tn as operationMatchesScopes, Tr as AttachmentOutputSchema, U as HexColorSchema, Un as TelemetryConfig, Ut as HandlerMcp, V as DeletedObjectSchema, Vn as ExecutionObservation, Vt as HandlerDeclaration, W as HttpsUrlSchema, Wt as HandlerOptions, X as SignedUrl, Xn as TokenAlgorithm, Xt as ToolDeclaration, Y as PostalAddressSchema, Yn as TokenAccess, Yt as SchemaOrFields, Z as SignedUrlSchema, Zn as TokenClaims, Zt as ToolOptions, _ as readBodyText, _n as McpSkill, _r as BodyFailure, a as t, an as ApplicationBuilder, ar as projectToken, at as cursorKey, b as createHttpRouteResolver, bn as OperationScope, br as Success, c as isJsonMediaType, cr as Principal, d as retryAfterSeconds, dn as AppManifest, dr as TokenPrincipal, en as defineHandler, er as TokenResolutionContext, et as PageInfoSchema, f as publicDestination, fn as Exposure, fr as OAuthResource, g as readBodyBytes, gn as McpGuide, gr as BinaryBody, h as HttpBodyFailureReason, hn as McpConfiguration, i as Type, ir as createTokenVerifier, it as TPage, j as createHttpHandler, jr as Failure, jt as parseInput, k as RouteContext, kr as ErrorDefinition, l as readJsonBody, lr as PrincipalSchema, m as HttpBodyFailure, mn as InvocationAuthority, n as Static, nn as defineTool, nr as TokenSource, nt as PageQuery, o as createOpenApi, on as ApplicationConfiguration, or as ScopeMatch, ot as cutPage, p as BodyReadOptions, pn as Invocation, pr as protectedResourceMetadata, q as PhoneNumberSchema, qt as RouteBody, r as TSchema, rr as createTokenAuthorization, rt as PageQueryFields, s as createRpcOpenApi, sn as maximus, sr as matchesScopes, st as pageLimit, tn as defineTelemetry, tr as TokenScheme, tt as PageOrder, u as readJsonResponse, ur as TokenClient, v as HttpRouteDefinition, vr as FailureResult, wr as Attachment, xn as OperationShape, xr as err, y as HttpRouteMatch, yn as OperationMiddleware, yr as Result, zn as AdmissionObservation, zt as HandlerAnswer } from "./chunks/types-BfGa2aJT.js";
2
+ export { type AdmissionObservation, type AppManifest, type ApplicationBuilder, type ApplicationConfiguration, type Attachment, AttachmentOutputSchema, type AuthOptions, type BackgroundContext, 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 McpConfiguration, type McpGuide, type McpSkill, type NamedReference, NamedReferenceSchema, type OAuthResource, type Observer, 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 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 ToolDeclaration, type ToolOptions, type TransportContext, 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 };
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
- import { a as parseSchema, i as parseInput } from "./chunks/validation-DMu0rkMQ.js";
2
- import { i as standardErrors, n as defineErrors, r as resultSchema, t as FailureSchema } from "./chunks/errors-CWgE9uvM.js";
1
+ import { a as parseSchema, i as parseInput } from "./chunks/validation-CpzAxj2_.js";
2
+ import { _ as cursorKey, b as AttachmentOutputSchema, c as HexColorSchema, d as PhoneNumberSchema, f as PostalAddressSchema, g as PageQueryFields, h as PageInfoSchema, i as UuidSchema, l as HttpsUrlSchema, m as Page, n as OrganizationIdSchema, o as DeletedObjectSchema, p as SignedUrlSchema, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as cutPage, y as pageLimit } from "./chunks/schemas-_UJcx_uY.js";
3
+ import { i as standardErrors, n as defineErrors, r as resultSchema, t as FailureSchema } from "./chunks/errors-BoutSmiy.js";
3
4
  import { n as readBodyBytes, r as readBodyText } from "./chunks/body-DOIHwIIl.js";
4
- import { t as createHttpRouteResolver } from "./chunks/http-paths-DMBxwpp6.js";
5
- import { n as isResult, r as ok, t as err } from "./chunks/result-CKgZHrnj.js";
6
- import { E as isPublicOperation, N as matchesScopes, _ as projectAccessToken, a as createTokenVerifier, i as createTokenAuthorization, j as operationScopes, k as operationMatchesScopes, n as createRpcOpenApi, s as projectToken, t as createOpenApi, y as PrincipalSchema } from "./chunks/openapi-BF3eCpux.js";
7
- import { _ as pageLimit, c as HexColorSchema, d as PhoneNumberSchema, f as PostalAddressSchema, g as PageQueryFields, h as PageInfoSchema, i as UuidSchema, l as HttpsUrlSchema, m as Page, n as OrganizationIdSchema, o as DeletedObjectSchema, p as SignedUrlSchema, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as AttachmentOutputSchema } from "./chunks/schemas-BOFxZP1c.js";
8
- import { a as maximus, i as protectedResourceMetadata, n as t, r as createHttpHandler, t as Type } from "./chunks/src-C-4z443M.js";
9
- import { a as defineTelemetry, i as defineHandler, n as defineAuth, o as defineTool, r as defineContext } from "./chunks/handler-iebR-urt.js";
5
+ import { t as createHttpRouteResolver } from "./chunks/http-paths-D043DkJv.js";
6
+ import { S as matchesScopes, b as operationScopes, m as isPublicOperation, v as operationMatchesScopes } from "./chunks/tasks-DYdY-dBI.js";
7
+ import { _ as projectAccessToken, a as createTokenVerifier, i as createTokenAuthorization, n as createRpcOpenApi, s as projectToken, t as createOpenApi, y as PrincipalSchema } from "./chunks/openapi-D2rds7vy.js";
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-D67OfW9B.js";
10
+ import { a as defineTelemetry, i as defineHandler, n as defineAuth, o as defineTool, r as defineContext } from "./chunks/handler-DSpyrWc-.js";
10
11
  import { o as reportUnexpected } from "./chunks/telemetry-BtxJh69Q.js";
11
- import { a as retryAfterSeconds, i as readJsonResponse, r as readJsonBody, t as isJsonMediaType } from "./chunks/json-B14evE6-.js";
12
+ import { a as readJsonResponse, i as readJsonBody, n as isJsonMediaType, o as retryAfterSeconds, t as publicDestination } from "./chunks/destination-DIkn8W6K.js";
12
13
 
13
- 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, defineAuth, defineContext, defineErrors, defineHandler, defineTelemetry, defineTool, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectAccessToken, projectToken, protectedResourceMetadata, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resultSchema, retryAfterSeconds, standardErrors, t };
14
+ 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 };
@@ -1,2 +1,2 @@
1
- import { An as executeOperation, Bn as withDiagnostics, D as HttpTransport, Dn as VerifiedCaller, En as CapturedCall, Fn as TelemetryConfig, Ln as recordExecution, Mn as BackgroundContext, On as recordCapture, Sn as CaptureConfig, T as HttpOptions, _ as HttpRouteDefinition, _n as operation, fn as OperationMiddleware, hn as composeOperations, in as AppManifest, k as TransportContext, kn as ExecutionCall, mn as OperationShape, on as Invocation, sn as InvocationAuthority, t as defineApp, v as HttpRouteMatch, y as createHttpRouteResolver, yn as operationScopes, zn as telemetryEnabled } from "./chunks/types-Dqo3oGig.js";
1
+ import { A as TransportContext, An as CaptureConfig, Bn as BackgroundContext, E as HttpOptions, En as operationScopes, Fn as VerifiedCaller, Gn as recordExecution, In as recordCapture, Jn as withDiagnostics, Ln as ExecutionCall, O as HttpTransport, Pn as CapturedCall, Rn as executeOperation, Sn as composeOperations, Un as TelemetryConfig, b as createHttpRouteResolver, dn as AppManifest, mn as InvocationAuthority, pn as Invocation, qn as telemetryEnabled, t as defineApp, v as HttpRouteDefinition, wn as operation, xn as OperationShape, y as HttpRouteMatch, yn as OperationMiddleware } from "./chunks/types-BfGa2aJT.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 OperationMiddleware, type OperationShape, type TelemetryConfig, type TransportContext, type VerifiedCaller, composeOperations, createHttpRouteResolver, defineApp, executeOperation, operation, operationScopes, recordCapture, recordExecution, telemetryEnabled, withDiagnostics };
package/dist/internals.js CHANGED
@@ -1,7 +1,7 @@
1
- import { n as defineApp } from "./chunks/define-app-BxGZdNmS.js";
2
- import { t as createHttpRouteResolver } from "./chunks/http-paths-DMBxwpp6.js";
3
- import { O as operation, T as composeOperations, j as operationScopes } from "./chunks/openapi-BF3eCpux.js";
1
+ import { n as defineApp } from "./chunks/define-app-CQpWqqqE.js";
2
+ import { t as createHttpRouteResolver } from "./chunks/http-paths-D043DkJv.js";
3
+ import { b as operationScopes, g as operation, p as composeOperations } from "./chunks/tasks-DYdY-dBI.js";
4
4
  import { a as recordExecution, c as withDiagnostics, s as telemetryEnabled } from "./chunks/telemetry-BtxJh69Q.js";
5
- import { n as recordCapture, t as executeOperation } from "./chunks/execution-BTiAWA4n.js";
5
+ import { n as recordCapture, t as executeOperation } from "./chunks/execution-Bpq6s4nA.js";
6
6
 
7
7
  export { composeOperations, createHttpRouteResolver, defineApp, executeOperation, operation, operationScopes, recordCapture, recordExecution, telemetryEnabled, withDiagnostics };
@@ -1,4 +1,4 @@
1
- import { D as HttpTransport } from "../chunks/types-Dqo3oGig.js";
1
+ import { O as HttpTransport } from "../chunks/types-BfGa2aJT.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-B9C8KPwa.js");
16
+ const { handleMcp } = await import("../chunks/server-CVhTLNj2.js");
17
17
  return handleMcp(context);
18
18
  }
19
19
  };
@@ -0,0 +1,33 @@
1
+ import { cn as TaskAccess, jr as Failure, ln as TaskRecord, yr as Result } from "../chunks/types-BfGa2aJT.js";
2
+ import { CallToolResult, McpServer } from "@modelcontextprotocol/server";
3
+ /** The Tasks extension's id, which a client declares on each request and a server among its capabilities. */
4
+ export declare const TASKS_EXTENSION = "io.modelcontextprotocol/tasks";
5
+ /** A task as an MCP client reads it, a JSON-RPC result. A failed operation completes the task with a tool error. */
6
+ export type McpTask = {
7
+ taskId: string;
8
+ status: 'working' | 'completed' | 'cancelled';
9
+ createdAt: string;
10
+ lastUpdatedAt: string;
11
+ ttlMs: number;
12
+ pollIntervalMs: number;
13
+ /** The tool call's result, once completed. */
14
+ result?: CallToolResult;
15
+ };
16
+ /**
17
+ * Whether a request's `_meta` declares the Tasks extension: an empty object at
18
+ * `io.modelcontextprotocol/clientCapabilities` › `extensions` › `io.modelcontextprotocol/tasks`, as
19
+ * `@modelcontextprotocol/ext-tasks` reads it.
20
+ */
21
+ export declare function declaresTasks(meta: unknown): boolean;
22
+ /** Whether a `tools/call` result is a task the server created, `resultType: "task"`, rather than the call's result. */
23
+ export declare function isTaskResult(result: unknown): boolean;
24
+ /** A Result as a tool call answers it: the value, or the failure as a tool error the model can read. */
25
+ export declare function toolResult(result: Result<unknown, Failure>): CallToolResult;
26
+ /** A task as an MCP client reads it. A failed operation completes its tool call with a tool error. */
27
+ export declare function mcpTask(task: TaskRecord): McpTask;
28
+ /**
29
+ * Declares the Tasks extension on `server` and serves `tasks/get` and `tasks/cancel` for the caller's tasks. A
30
+ * task id the caller did not start, or one that expired, is invalid params (-32602).
31
+ */
32
+ export declare function attachTasks(server: McpServer, tasks: TaskAccess): void;
33
+ export type { TaskAccess, TaskRecord };
@@ -0,0 +1,3 @@
1
+ import { a as mcpTask, i as isTaskResult, n as attachTasks, o as toolResult, r as declaresTasks, t as TASKS_EXTENSION } from "../chunks/tasks-C873C3le.js";
2
+
3
+ export { TASKS_EXTENSION, attachTasks, declaresTasks, isTaskResult, mcpTask, toolResult };
@@ -1,5 +1,5 @@
1
- import { Kt as ToolDeclaration, Lt as HandlerDeclaration, an as Exposure, dn as OperationHandler, fn as OperationMiddleware, in as AppManifest, jt as ContextDeclaration, mn as OperationShape, on as Invocation, tn as ApplicationBuilder, w as HttpMiddleware } from "../chunks/types-Dqo3oGig.js";
2
- import { TSchema } from "@sinclair/typebox";
1
+ import { Ft as ContextDeclaration, 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-BfGa2aJT.js";
2
+ import { TSchema } from "typebox";
3
3
  /** A route's HTTP method. */
4
4
  type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
5
5
  /**
@@ -1,5 +1,6 @@
1
- import { a as routeGroup, r as ok, t as err } from "../chunks/result-CKgZHrnj.js";
2
- import { c as isHandlerDeclaration, l as isToolDeclaration, s as isContextDeclaration, t as Failed } from "../chunks/handler-iebR-urt.js";
1
+ import { n as routeGroup } from "../chunks/http-routes-B6tCsnxB.js";
2
+ import { r as ok, t as err } from "../chunks/result-CF4OzG9O.js";
3
+ import { c as isHandlerDeclaration, l as isToolDeclaration, s as isContextDeclaration, t as Failed } from "../chunks/handler-DSpyrWc-.js";
3
4
  import { n as routeTitle, t as routeName } from "../chunks/names-ncD7A3DV.js";
4
5
 
5
6
  // src/project/bind.ts
@@ -1,5 +1,5 @@
1
- import { E as HttpRoute, in as AppManifest, mn as OperationShape } from "../chunks/types-Dqo3oGig.js";
2
- import { n as WorkerOptions, r as WorkerRuntime } from "../chunks/workers-types-BgjyDtGd.js";
1
+ import { D as HttpRoute, dn as AppManifest, xn as OperationShape } from "../chunks/types-BfGa2aJT.js";
2
+ import { n as WorkerOptions, r as WorkerRuntime } from "../chunks/workers-types-Cxf-5cH7.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
- import { i as standardErrors } from "../chunks/errors-CWgE9uvM.js";
2
- import { r as createAssetHandler, t as createWorker } from "../chunks/runtime-D5eR9-Es.js";
3
- import { t as checkPagePaths } from "../chunks/pages-BCksUeRf.js";
1
+ import { i as standardErrors } from "../chunks/errors-BoutSmiy.js";
2
+ import { r as createAssetHandler, t as createWorker } from "../chunks/runtime-CGtS2rOb.js";
3
+ import { t as checkPagePaths } from "../chunks/pages-B7ysoFAM.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 PageInfoSchema, B as DeletedObjectSchema, Ct as urlSchema, Dt as parseInput, Et as decodeSchema, F as TSchema, G as NamedReferenceSchema, H as HexColorSchema, I as Type, J as PostalAddressSchema, K as PhoneNumberSchema, L as UuidSchema, M as EmptyInputSchema, N as OrganizationIdSchema, Ot as parseSchema, P as Static, Q as PageInfo, R as t, St as transformSchema, Tt as decodeInput, U as HttpsUrlSchema, V as EmailAddressSchema, W as NamedReference, X as SignedUrlSchema, Y as SignedUrl, Z as Page, _r as AttachmentOutputSchema, _t as normalizeSchema, at as Checked, bn as StaticDecode, bt as strictObject, ct as SchemaInput, dt as defaultSchema, et as PageQuery, ft as extendObject, gr as Attachment, gt as looseObject, ht as literalUnion, it as withoutSecrets, lt as SchemaIssue, mt as inspectSchema, nt as TPage, ot as checkSchema, pt as inputSchema, q as PostalAddress, rt as pageLimit, st as readSchema, tt as PageQueryFields, ut as SchemaValidationError, vt as pipeSchema, wt as InputIssue, xt as stripObject, yt as refineSchema, z as DeletedObject } from "./chunks/types-Dqo3oGig.js";
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 PageQuery, PageQueryFields, PhoneNumberSchema, type PostalAddress, PostalAddressSchema, type SchemaInput, type SchemaIssue, SchemaValidationError, type SignedUrl, SignedUrlSchema, type Static, type StaticDecode, type TPage, type TSchema, Type, UuidSchema, checkSchema, decodeInput, decodeSchema, defaultSchema, extendObject, inputSchema, inspectSchema, literalUnion, looseObject, normalizeSchema, pageLimit, parseInput, parseSchema, pipeSchema, readSchema, refineSchema, strictObject, stripObject, t, transformSchema, urlSchema, withoutSecrets };
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, On as StaticDecode, Ot as InputIssue, P as OrganizationIdSchema, Q as Page, R as UuidSchema, St as strictObject, Tr as AttachmentOutputSchema, 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, wr as Attachment, wt as transformSchema, xt as refineSchema, yt as normalizeSchema, z as t } from "./chunks/types-BfGa2aJT.js";
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 };
package/dist/schemas.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E as withoutSecrets, S as urlSchema, _ as pipeSchema, a as parseSchema, b as stripObject, c as SchemaValidationError, f as inputSchema, g as normalizeSchema, h as looseObject, i as parseInput, l as defaultSchema, m as literalUnion, n as decodeInput, p as inspectSchema, r as decodeSchema, u as extendObject, v as refineSchema, x as transformSchema, y as strictObject } from "./chunks/validation-DMu0rkMQ.js";
2
- import { _ as pageLimit, a as t, b as readSchema, c as HexColorSchema, d as PhoneNumberSchema, f as PostalAddressSchema, g as PageQueryFields, h as PageInfoSchema, i as UuidSchema, l as HttpsUrlSchema, m as Page, n as OrganizationIdSchema, o as DeletedObjectSchema, p as SignedUrlSchema, r as Type, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as AttachmentOutputSchema, y as checkSchema } from "./chunks/schemas-BOFxZP1c.js";
1
+ import { a as parseSchema, i as parseInput, n as decodeInput, o as SchemaValidationError, r as decodeSchema } from "./chunks/validation-CpzAxj2_.js";
2
+ import { A as normalizeSchema, B as withoutSecrets, C as defaultSchema, D as inspectSchema, E as inputSchema, F as transformSchema, I as urlSchema, M as refineSchema, N as strictObject, O as literalUnion, P as stripObject, S as readSchema, _ as cursorKey, a as t, b as AttachmentOutputSchema, c as HexColorSchema, d as PhoneNumberSchema, f as PostalAddressSchema, g as PageQueryFields, h as PageInfoSchema, i as UuidSchema, j as pipeSchema, k as looseObject, l as HttpsUrlSchema, m as Page, n as OrganizationIdSchema, o as DeletedObjectSchema, p as SignedUrlSchema, r as Type, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as cutPage, w as extendObject, x as checkSchema, y as pageLimit } from "./chunks/schemas-_UJcx_uY.js";
3
3
 
4
- export { AttachmentOutputSchema, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, HexColorSchema, HttpsUrlSchema, NamedReferenceSchema, OrganizationIdSchema, Page, PageInfoSchema, PageQueryFields, PhoneNumberSchema, PostalAddressSchema, SchemaValidationError, SignedUrlSchema, Type, UuidSchema, checkSchema, decodeInput, decodeSchema, defaultSchema, extendObject, inputSchema, inspectSchema, literalUnion, looseObject, normalizeSchema, pageLimit, parseInput, parseSchema, pipeSchema, readSchema, refineSchema, strictObject, stripObject, t, transformSchema, urlSchema, withoutSecrets };
4
+ export { AttachmentOutputSchema, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, HexColorSchema, HttpsUrlSchema, NamedReferenceSchema, OrganizationIdSchema, Page, PageInfoSchema, PageQueryFields, PhoneNumberSchema, PostalAddressSchema, SchemaValidationError, SignedUrlSchema, 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 { $t as STANDARD_FAILURES, en as StandardFailure } from "./chunks/types-Dqo3oGig.js";
1
+ import { in as StandardFailure, rn as STANDARD_FAILURES } from "./chunks/types-BfGa2aJT.js";
2
2
  export { STANDARD_FAILURES, StandardFailure };
@@ -109,7 +109,7 @@ async function run() {
109
109
  return;
110
110
  }
111
111
  case "gen": {
112
- const { generateRoute, generateTool } = await import("../chunks/generate-C-9FKW0o.js");
112
+ const { generateRoute, generateTool } = await import("../chunks/generate-Dg88LzLU.js");
113
113
  const [kind, ...args] = rest;
114
114
  if (kind === "route" && args.length === 2) {
115
115
  const [method = "", path = ""] = args;
@@ -139,7 +139,7 @@ async function run() {
139
139
  return;
140
140
  }
141
141
  case "openapi": {
142
- const { writeOpenApi } = await import("../chunks/openapi-file-RcXoq0AF.js");
142
+ const { writeOpenApi } = await import("../chunks/openapi-file-BK8zET5U.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 { Gn as TokenPolicy, Hn as TokenAlgorithm, Wn as TokenDevelopment } from "../chunks/types-Dqo3oGig.js";
1
+ import { $n as TokenPolicy, Qn as TokenDevelopment, Xn as TokenAlgorithm } from "../chunks/types-BfGa2aJT.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. */
@@ -1,7 +1,7 @@
1
- import { t as checkMcpResourceNames } from "../chunks/define-app-BxGZdNmS.js";
2
- import { a as operationPathParameters } from "../chunks/http-paths-DMBxwpp6.js";
3
- import { a as ownsPrefix, t as VERSIONED_PATH } from "../chunks/http-layout-BvlbD__1.js";
4
- import { t as checkPagePaths } from "../chunks/pages-BCksUeRf.js";
1
+ import { t as checkMcpResourceNames } from "../chunks/define-app-CQpWqqqE.js";
2
+ import { a as operationPathParameters } from "../chunks/http-paths-D043DkJv.js";
3
+ import { a as ownsPrefix, t as VERSIONED_PATH } from "../chunks/http-layout-BcYH4I2w.js";
4
+ import { t as checkPagePaths } from "../chunks/pages-B7ysoFAM.js";
5
5
  import { t as routeName } from "../chunks/names-ncD7A3DV.js";
6
6
  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";
7
7
  import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -1227,7 +1227,8 @@ function prepareProject(directory, mode, project) {
1227
1227
  "",
1228
1228
  "export default worker.handler;",
1229
1229
  "export const Service = worker.entrypoint;",
1230
- ...durableObjects
1230
+ ...durableObjects,
1231
+ ...Object.hasOwn(project.env.production, "MAXIMUS_TASKS") ? ["export const MaximusTasks = worker.tasks;"] : []
1231
1232
  ]),
1232
1233
  "http.ts": generatedModule(mode, [
1233
1234
  "import { createHttpHandler } from '@arbol-ai/maximus';",
@@ -1,4 +1,4 @@
1
- import { Cr as Failure, dr as Result } from "./chunks/types-Dqo3oGig.js";
1
+ import { jr as Failure, yr as Result } from "./chunks/types-BfGa2aJT.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. */
@@ -66,4 +66,15 @@ export declare function verifyStandardWebhook(options: {
66
66
  }): Promise<Result<{
67
67
  id: string;
68
68
  timestamp: number;
69
- }, WebhookSignatureFailure>>;
69
+ }, WebhookSignatureFailure>>;
70
+ /**
71
+ * Signs a Standard Webhooks delivery with the specification's own `standardwebhooks` package: the headers to
72
+ * send with `payload`, exactly as given. The secret is the `whsec_<base64>` value the receiver verifies with,
73
+ * and `id` names the delivery, which the receiver keeps as its idempotency key.
74
+ */
75
+ export declare function signStandardWebhook(options: {
76
+ id: string;
77
+ now?: () => number;
78
+ payload: string;
79
+ secret: string;
80
+ }): Record<'webhook-id' | 'webhook-signature' | 'webhook-timestamp', string>;
package/dist/webhooks.js CHANGED
@@ -1,4 +1,28 @@
1
+ import { Webhook } from "standardwebhooks";
2
+
1
3
  // src/webhooks.ts
4
+ /**
5
+ * `@arbol-ai/maximus/webhooks`: webhook signature verification for the three schemes providers use, and
6
+ * {@link signStandardWebhook}, which signs a delivery as the Standard Webhooks specification does.
7
+ *
8
+ * - {@link verifyHmacSignature}: an HMAC-SHA256 of the raw body, hex or base64,
9
+ * in one header (the common `X-…-Signature` / `X-Hub-Signature-256` scheme).
10
+ * - {@link verifyTimestampedSignature}: `t=<unix>,v1=<hex>` headers signing
11
+ * `<t>.<body>` (the Stripe-style scheme; some providers label it `v0`).
12
+ * - {@link verifyStandardWebhook}: the Standard Webhooks specification
13
+ * (`webhook-id`, `webhook-timestamp`, `webhook-signature: v1,<base64> …`),
14
+ * used by many webhook platforms; `svix-*` header names are accepted too.
15
+ *
16
+ * Every comparison runs through `crypto.subtle.verify`, so there is no userland
17
+ * timing leak. Timestamps are checked in both directions (a signed request
18
+ * from the future is as suspicious as a replayed one). Call these on the raw
19
+ * body, before parsing it; a failure carries only a closed reason, never the
20
+ * body, a header value or the secret. A missing or empty secret throws a
21
+ * TypeError: it is the deployment's mistake, not the sender's.
22
+ *
23
+ * Sources: https://github.com/standard-webhooks/standard-webhooks/blob/main/spec/standard-webhooks.md,
24
+ * https://docs.stripe.com/webhooks#verify-manually.
25
+ */
2
26
  /** Why a webhook signature was refused: absent, malformed, outside the time tolerance, or not matching. */
3
27
  const WEBHOOK_SIGNATURE_FAILURES = [
4
28
  "missing",
@@ -171,5 +195,18 @@ async function verifyStandardWebhook(options) {
171
195
  };
172
196
  return failure("mismatch");
173
197
  }
198
+ /**
199
+ * Signs a Standard Webhooks delivery with the specification's own `standardwebhooks` package: the headers to
200
+ * send with `payload`, exactly as given. The secret is the `whsec_<base64>` value the receiver verifies with,
201
+ * and `id` names the delivery, which the receiver keeps as its idempotency key.
202
+ */
203
+ function signStandardWebhook(options) {
204
+ const timestamp = new Date(options.now?.() ?? Date.now());
205
+ return {
206
+ "webhook-id": options.id,
207
+ "webhook-timestamp": String(Math.floor(timestamp.getTime() / 1e3)),
208
+ "webhook-signature": new Webhook(requireSecret(options.secret)).sign(options.id, timestamp, options.payload)
209
+ };
210
+ }
174
211
 
175
- export { DEFAULT_TOLERANCE_SECONDS, MAX_SIGNATURES, WEBHOOK_SIGNATURE_FAILURES, verifyHmacSignature, verifyStandardWebhook, verifyTimestampedSignature, webhookSignatureFailure };
212
+ export { DEFAULT_TOLERANCE_SECONDS, MAX_SIGNATURES, WEBHOOK_SIGNATURE_FAILURES, signStandardWebhook, verifyHmacSignature, verifyStandardWebhook, verifyTimestampedSignature, webhookSignatureFailure };
@@ -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-BgjyDtGd.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-Cxf-5cH7.js";
2
2
  export { RpcMethods, type WorkerAssetsOptions, WorkerOptions, WorkerRuntime, createWorker, credentials };