@arbol-ai/maximus 7.2.2 → 7.2.3
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.
- package/dist/analytics/analytics.d.ts +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/body.d.ts +1 -1
- package/dist/capture/index.d.ts +40 -0
- package/dist/capture/index.js +182 -0
- package/dist/chunks/delay-B9YcAv-2.js +25 -0
- package/dist/chunks/{record-D2H3cg8S.js → exact-length-CNFWdMzi.js} +1 -11
- package/dist/chunks/{execution-C-ZHm0Ya.js → execution-DxGsKvjA.js} +201 -21
- package/dist/chunks/{schemas-q-51wBMQ.js → schemas-CldDAUy1.js} +1 -1
- package/dist/chunks/{src-D0yQz-d-.js → src-Ct4fEN4z.js} +57 -12
- package/dist/chunks/{telemetry-DvZgrzZn.js → telemetry-Bcq3GquK.js} +4 -4
- package/dist/chunks/{types-B1C3Ogo5.d.ts → types-D_QnYxPM.d.ts} +247 -30
- package/dist/chunks/{validation-DWxKk1Js.js → validation-B8XH1b_o.js} +276 -14
- package/dist/client/client.d.ts +1 -1
- package/dist/client/client.js +2 -1
- package/dist/diagnostics.d.ts +1 -1
- package/dist/diagnostics.js +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/http-paths.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/internals.d.ts +2 -2
- package/dist/internals.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +22 -12
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.js +3 -3
- package/dist/webhooks.d.ts +1 -1
- package/dist/workers/runtime.d.ts +1 -1
- package/dist/workers/runtime.js +36 -7
- package/package.json +5 -1
- package/skills/maximus/SKILL.md +5 -0
- package/skills/maximus/references/adding-an-operation.md +2 -0
- package/skills/maximus/references/building-a-service.md +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { C as withoutSecretKeyword, T as isRecord } from "./validation-B8XH1b_o.js";
|
|
1
2
|
import { FailureSchema, standardErrors } from "../errors.js";
|
|
2
3
|
import { r as readBodyText } from "./body-BcMbreNd.js";
|
|
3
|
-
import { t as
|
|
4
|
-
import { C as operationMatchesScopes, D as pathParameterSchemas, O as attachmentResponse, S as operationBodyLimit, T as operationScopes, _ as STANDARD_CODES, b as mcpOpenWorld, c as tokenEndpoints, d as err, h as DEFAULT_MAX_BODY_BYTES, i as createTokenAuthorization, k as binaryBody, l as tokenIssuer, m as sha256Hex, n as defineApp, p as ok, s as tokenAudiences, t as executeOperation, u as usesOwnBearer, v as composeOperations, w as operationOutputLimit, y as isPublicOperation } from "./execution-C-ZHm0Ya.js";
|
|
4
|
+
import { C as operationMatchesScopes, D as pathParameterSchemas, O as attachmentResponse, S as operationBodyLimit, T as operationScopes, _ as STANDARD_CODES, a as createTokenAuthorization, b as mcpOpenWorld, c as tokenAudiences, d as usesOwnBearer, f as err, h as DEFAULT_MAX_BODY_BYTES, k as binaryBody, l as tokenEndpoints, m as ok, n as recordCapture, r as defineApp, t as executeOperation, u as tokenIssuer, v as composeOperations, w as operationOutputLimit, y as isPublicOperation } from "./execution-DxGsKvjA.js";
|
|
5
5
|
import { createHttpRouteResolver, operationPathParameters } from "../http-paths.js";
|
|
6
|
-
import {
|
|
6
|
+
import { n as sha256Hex } from "./delay-B9YcAv-2.js";
|
|
7
|
+
import { a as recordExecution, i as recordAdmission, l as withTelemetry, o as reportUnexpected, s as telemetryEnabled } from "./telemetry-Bcq3GquK.js";
|
|
7
8
|
import { n as mediaType } from "./json-Dwni3u4c.js";
|
|
8
9
|
import { Type, Type as Type$1, Type as t } from "@sinclair/typebox";
|
|
9
10
|
import { stringify } from "yaml";
|
|
@@ -370,11 +371,13 @@ function replaceReferences(value, replace) {
|
|
|
370
371
|
* against its enclosing `$id`, as in JSON Schema; structurally different definitions that share an
|
|
371
372
|
* `$id` (for example a normalized input projection and its output) become distinct components. A
|
|
372
373
|
* reference outside any definition must name exactly one variant. Use-site annotations stay beside
|
|
373
|
-
* the reference. The owner's runtime schemas are not
|
|
374
|
+
* the reference, and `secret`, which only capture reads, is left out. The owner's runtime schemas are not
|
|
375
|
+
* changed.
|
|
374
376
|
*/
|
|
375
377
|
function bundleSchemas(sources, existing) {
|
|
378
|
+
const published = sources.map((source) => withoutSecretKeyword(source));
|
|
376
379
|
const ids = /* @__PURE__ */ new Set();
|
|
377
|
-
for (const source of
|
|
380
|
+
for (const source of published) collectIds(source, ids);
|
|
378
381
|
const components = {};
|
|
379
382
|
const variants = /* @__PURE__ */ new Map();
|
|
380
383
|
const taken = new Set(Object.keys(existing));
|
|
@@ -414,7 +417,7 @@ function bundleSchemas(sources, existing) {
|
|
|
414
417
|
return [key, rewrite(child, scope)];
|
|
415
418
|
}));
|
|
416
419
|
}
|
|
417
|
-
const rewritten =
|
|
420
|
+
const rewritten = published.map((source) => rewrite(source, /* @__PURE__ */ new Map()));
|
|
418
421
|
/**
|
|
419
422
|
* A pending reference as the one component its name now has; refused when the name has several shapes or
|
|
420
423
|
* none.
|
|
@@ -904,6 +907,8 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
904
907
|
let surface = "http";
|
|
905
908
|
let plain = false;
|
|
906
909
|
let requestEnv = env;
|
|
910
|
+
let verified;
|
|
911
|
+
const userAgent = incoming.headers.get("user-agent")?.slice(0, 200) || void 0;
|
|
907
912
|
const context = {
|
|
908
913
|
requestId,
|
|
909
914
|
fail: (error, headers) => failure(error, requestId, resolutionContext(), headers),
|
|
@@ -926,6 +931,19 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
926
931
|
applicationScopes,
|
|
927
932
|
background
|
|
928
933
|
});
|
|
934
|
+
/** Captures a refusal before execution, of this request's operation or the one a transport names. */
|
|
935
|
+
function captureRefusal(error, refused, scopedEnv) {
|
|
936
|
+
recordCapture(manifest, scopedEnv, background, {
|
|
937
|
+
operation: refused,
|
|
938
|
+
surface,
|
|
939
|
+
requestId,
|
|
940
|
+
principal,
|
|
941
|
+
...verified ? { verified } : {},
|
|
942
|
+
requestStarted: started,
|
|
943
|
+
result: err(error),
|
|
944
|
+
call: userAgent ? { userAgent } : {}
|
|
945
|
+
});
|
|
946
|
+
}
|
|
929
947
|
/** A refusal before execution, observed as a rejected admission. */
|
|
930
948
|
function reject(error) {
|
|
931
949
|
recordAdmission(manifest, requestEnv, background, {
|
|
@@ -936,6 +954,7 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
936
954
|
started,
|
|
937
955
|
errorCode: error.code
|
|
938
956
|
});
|
|
957
|
+
captureRefusal(error, operation, requestEnv);
|
|
939
958
|
return failure(error, requestId, resolutionContext());
|
|
940
959
|
}
|
|
941
960
|
/**
|
|
@@ -1000,7 +1019,8 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
1000
1019
|
}, operationRoute?.definition.op.scopeMatch);
|
|
1001
1020
|
if (!result.ok) return reject(result.error);
|
|
1002
1021
|
const authenticated = result.value;
|
|
1003
|
-
const
|
|
1022
|
+
const bearer = /^Bearer (\S+)$/i.exec(incoming.headers.get("authorization") ?? "")?.[1];
|
|
1023
|
+
const accessToken = ownBearer ? void 0 : bearer;
|
|
1004
1024
|
const actor = {
|
|
1005
1025
|
actorId: authenticated.actorId,
|
|
1006
1026
|
actorKind: authenticated.actorKind,
|
|
@@ -1008,6 +1028,11 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
1008
1028
|
requestId
|
|
1009
1029
|
};
|
|
1010
1030
|
principal = actor;
|
|
1031
|
+
if (manifest.capture) verified = {
|
|
1032
|
+
scopes: authenticated.scopes,
|
|
1033
|
+
...authenticated.client ? { client: authenticated.client } : {},
|
|
1034
|
+
...bearer ? { token: bearer } : {}
|
|
1035
|
+
};
|
|
1011
1036
|
if (!await withinRateLimit(scopedEnv, authenticated)) return reject(standardErrors.rateLimited.create());
|
|
1012
1037
|
let request = incoming;
|
|
1013
1038
|
let bodyText = "";
|
|
@@ -1038,10 +1063,14 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
1038
1063
|
* Runs one operation through the shared execution path as the admitted caller, and records the call.
|
|
1039
1064
|
*/
|
|
1040
1065
|
async function invoke(name, op, input) {
|
|
1041
|
-
if (transport && !operations.some(([selectedName, selected]) => selectedName === name && selected === op))
|
|
1042
|
-
|
|
1043
|
-
error
|
|
1044
|
-
|
|
1066
|
+
if (transport && !operations.some(([selectedName, selected]) => selectedName === name && selected === op)) {
|
|
1067
|
+
const error = standardErrors.notFound.create();
|
|
1068
|
+
captureRefusal(error, null, scopedEnv);
|
|
1069
|
+
return {
|
|
1070
|
+
ok: false,
|
|
1071
|
+
error
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1045
1074
|
const admissionStarted = performance.now();
|
|
1046
1075
|
if (!await admitRequest()) {
|
|
1047
1076
|
const error = standardErrors.rateLimited.create();
|
|
@@ -1053,19 +1082,21 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
1053
1082
|
started: admissionStarted,
|
|
1054
1083
|
errorCode: error.code
|
|
1055
1084
|
});
|
|
1085
|
+
captureRefusal(error, name, scopedEnv);
|
|
1056
1086
|
return {
|
|
1057
1087
|
ok: false,
|
|
1058
1088
|
error
|
|
1059
1089
|
};
|
|
1060
1090
|
}
|
|
1061
1091
|
if (telemetryEnabled(manifest.telemetry, scopedEnv)) hooks.annotate?.(name, requestId);
|
|
1092
|
+
const call = userAgent ? { userAgent } : {};
|
|
1062
1093
|
const invocationStarted = performance.now();
|
|
1063
1094
|
const output = await executeOperation(manifest, op, scopedEnv, actor, input, authenticated.client ? {
|
|
1064
1095
|
surface: transport ? "mcp" : "http",
|
|
1065
1096
|
scopes: authenticated.scopes,
|
|
1066
1097
|
client: authenticated.client,
|
|
1067
1098
|
...accessToken ? { token: accessToken } : {}
|
|
1068
|
-
} : void 0, background, byteOperation ? binaryBody(incoming, op.maxBodyBytes ?? fallbackBodyBytes) : void 0);
|
|
1099
|
+
} : void 0, background, byteOperation ? binaryBody(incoming, op.maxBodyBytes ?? fallbackBodyBytes) : void 0, call);
|
|
1069
1100
|
recordExecution(manifest, scopedEnv, background, {
|
|
1070
1101
|
principal: actor,
|
|
1071
1102
|
operation: name,
|
|
@@ -1073,6 +1104,17 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
1073
1104
|
started: invocationStarted,
|
|
1074
1105
|
result: output
|
|
1075
1106
|
});
|
|
1107
|
+
recordCapture(manifest, scopedEnv, background, {
|
|
1108
|
+
operation: name,
|
|
1109
|
+
surface: transport ? "mcp" : "http",
|
|
1110
|
+
requestId,
|
|
1111
|
+
principal: actor,
|
|
1112
|
+
...verified ? { verified } : {},
|
|
1113
|
+
requestStarted: started,
|
|
1114
|
+
executionStarted: invocationStarted,
|
|
1115
|
+
result: output,
|
|
1116
|
+
call
|
|
1117
|
+
});
|
|
1076
1118
|
return output;
|
|
1077
1119
|
}
|
|
1078
1120
|
if (transport) return transport.handle({
|
|
@@ -1086,6 +1128,9 @@ function createHttpHandler(manifest, hooks = {}) {
|
|
|
1086
1128
|
url: (path) => `${manifest.origin}${paths.mount(path)}`,
|
|
1087
1129
|
invoke,
|
|
1088
1130
|
admitRequest,
|
|
1131
|
+
refused: (error, name) => {
|
|
1132
|
+
captureRefusal(error, name ?? null, scopedEnv);
|
|
1133
|
+
},
|
|
1089
1134
|
bodyBytes: new TextEncoder().encode(bodyText).byteLength,
|
|
1090
1135
|
bodyLimit: (op) => op.maxBodyBytes ?? fallbackBodyBytes
|
|
1091
1136
|
});
|
|
@@ -91,9 +91,9 @@ function createDiagnostics(errorNames = []) {
|
|
|
91
91
|
* Telemetry: invocation-local diagnostics kept in AsyncLocalStorage, safe native log events, and observers
|
|
92
92
|
* that receive execution and admission observations as background work.
|
|
93
93
|
*/
|
|
94
|
-
/** Microseconds
|
|
95
|
-
function elapsedMicros(started) {
|
|
96
|
-
return Math.max(0, Math.round((
|
|
94
|
+
/** Microseconds from `started` to `until` or now, each a `performance.now()` reading. */
|
|
95
|
+
function elapsedMicros(started, until = performance.now()) {
|
|
96
|
+
return Math.max(0, Math.round((until - started) * 1e3));
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* Hands one event to one observer as background work: a failed delivery is logged with its request id
|
|
@@ -217,4 +217,4 @@ function recordExecution(manifest, env, background, invocation) {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
//#endregion
|
|
220
|
-
export {
|
|
220
|
+
export { recordExecution as a, withDiagnostics as c, recordAdmission as i, withTelemetry as l, diagnosticsEnabled as n, reportUnexpected as o, elapsedMicros as r, telemetryEnabled as s, activeTraceId as t, createDiagnostics as u };
|
|
@@ -307,27 +307,55 @@ interface BinaryBody {
|
|
|
307
307
|
read: () => Promise<Result<Uint8Array<ArrayBuffer>, Failure>>;
|
|
308
308
|
}
|
|
309
309
|
//#endregion
|
|
310
|
-
//#region src/
|
|
311
|
-
/** Opaque owner codecs already carry their decoded static type; only native transforms need traversal. */
|
|
312
|
-
type HasNativeTransform<S extends TSchema> = typeof TransformKind extends keyof S ? true : string extends S[typeof Kind] ? false : S extends TObject<infer P> ? true extends { [K in keyof P]: HasNativeTransform<P[K]>; }[keyof P] ? true : false : S extends TArray<infer I> ? HasNativeTransform<I> : S extends TUnion<infer U> | TTuple<infer U> ? HasNativeTransform<U[number]> : S extends TRecord<TSchema, infer V> ? HasNativeTransform<V> : false;
|
|
313
|
-
/**
|
|
314
|
-
* A schema's decoded value. TypeBox's deep decoder can recurse indefinitely through opaque owner
|
|
315
|
-
* codecs; a schema without native transforms already has exactly its decoded `Static` type.
|
|
316
|
-
*/
|
|
317
|
-
type StaticDecode$1<S extends TSchema> = true extends HasNativeTransform<S> ? StaticDecode<S> : Static<S>;
|
|
318
|
-
//#endregion
|
|
319
|
-
//#region src/scopes.d.ts
|
|
320
|
-
/**
|
|
321
|
-
* Scope names and matching: the namespaced form every scope takes, and whether granted scopes admit a
|
|
322
|
-
* request.
|
|
323
|
-
*/
|
|
324
|
-
/** Whether a caller needs any one of several scopes (`any`, the default) or all of them. */
|
|
325
|
-
type ScopeMatch = 'any' | 'all';
|
|
310
|
+
//#region src/capture-record.d.ts
|
|
326
311
|
/**
|
|
327
|
-
*
|
|
328
|
-
*
|
|
312
|
+
* One complete record of a call: who called which operation over which transport, when and for how long, what
|
|
313
|
+
* it answered, and, under `payloads: 'all'`, its input and output without what their schemas mark
|
|
314
|
+
* `secret: true`. A refusal before the operation ran has `stage: 'admission'` and null wherever admission had
|
|
315
|
+
* not learned the value: a token is never read before it is verified.
|
|
329
316
|
*/
|
|
330
|
-
declare
|
|
317
|
+
declare const CaptureRecordSchema: import("@sinclair/typebox").TObject<{
|
|
318
|
+
id: import("@sinclair/typebox").TString;
|
|
319
|
+
service: import("@sinclair/typebox").TString;
|
|
320
|
+
operation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
321
|
+
organizationId: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
322
|
+
actorId: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
323
|
+
actorKind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"user">, import("@sinclair/typebox").TLiteral<"service">]>, import("@sinclair/typebox").TNull]>;
|
|
324
|
+
requestId: import("@sinclair/typebox").TString;
|
|
325
|
+
traceId: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
326
|
+
surface: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"http">, import("@sinclair/typebox").TLiteral<"mcp">, import("@sinclair/typebox").TLiteral<"rpc">]>;
|
|
327
|
+
occurredAt: import("@sinclair/typebox").TInteger;
|
|
328
|
+
durationMicros: import("@sinclair/typebox").TInteger;
|
|
329
|
+
outcome: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"success">, import("@sinclair/typebox").TLiteral<"failure">]>;
|
|
330
|
+
errorCode: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
331
|
+
stage: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"execution">, import("@sinclair/typebox").TLiteral<"admission">]>;
|
|
332
|
+
version: import("@sinclair/typebox").TString;
|
|
333
|
+
effect: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"read">, import("@sinclair/typebox").TLiteral<"write">, import("@sinclair/typebox").TLiteral<"delete">]>, import("@sinclair/typebox").TNull]>;
|
|
334
|
+
scopes: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
335
|
+
visibility: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"public">, import("@sinclair/typebox").TLiteral<"internal">]>, import("@sinclair/typebox").TNull]>;
|
|
336
|
+
httpMethod: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
337
|
+
httpPath: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
338
|
+
mcpTool: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
339
|
+
rpcCaller: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
340
|
+
clientId: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
341
|
+
clientClass: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"human">, import("@sinclair/typebox").TLiteral<"machine">, import("@sinclair/typebox").TLiteral<"dcr">]>, import("@sinclair/typebox").TNull]>;
|
|
342
|
+
grantedScopes: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>, import("@sinclair/typebox").TNull]>;
|
|
343
|
+
userAgent: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
344
|
+
tokenSha256: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
345
|
+
dimensions: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
346
|
+
startedAt: import("@sinclair/typebox").TInteger;
|
|
347
|
+
admissionMicros: import("@sinclair/typebox").TInteger;
|
|
348
|
+
input: import("@sinclair/typebox").TUnknown;
|
|
349
|
+
output: import("@sinclair/typebox").TUnknown;
|
|
350
|
+
failureData: import("@sinclair/typebox").TUnknown;
|
|
351
|
+
payloadRef: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
352
|
+
$ref: import("@sinclair/typebox").TString;
|
|
353
|
+
bytes: import("@sinclair/typebox").TInteger;
|
|
354
|
+
sha256: import("@sinclair/typebox").TString;
|
|
355
|
+
}>, import("@sinclair/typebox").TNull]>;
|
|
356
|
+
}>;
|
|
357
|
+
/** One capture record. */
|
|
358
|
+
type CaptureRecord = Static<typeof CaptureRecordSchema>;
|
|
331
359
|
//#endregion
|
|
332
360
|
//#region src/oauth.d.ts
|
|
333
361
|
/**
|
|
@@ -351,6 +379,19 @@ declare function protectedResourceMetadata<E>(resource: OAuthResource<E>, env: E
|
|
|
351
379
|
scopes_supported: string[];
|
|
352
380
|
};
|
|
353
381
|
//#endregion
|
|
382
|
+
//#region src/scopes.d.ts
|
|
383
|
+
/**
|
|
384
|
+
* Scope names and matching: the namespaced form every scope takes, and whether granted scopes admit a
|
|
385
|
+
* request.
|
|
386
|
+
*/
|
|
387
|
+
/** Whether a caller needs any one of several scopes (`any`, the default) or all of them. */
|
|
388
|
+
type ScopeMatch = 'any' | 'all';
|
|
389
|
+
/**
|
|
390
|
+
* Whether granted scopes admit a requirement: any one of the required scopes, or all of them with `all`.
|
|
391
|
+
* An empty requirement admits nobody.
|
|
392
|
+
*/
|
|
393
|
+
declare function matchesScopes(required: readonly string[], granted: readonly string[], match?: ScopeMatch): boolean;
|
|
394
|
+
//#endregion
|
|
354
395
|
//#region src/tokens.d.ts
|
|
355
396
|
/**
|
|
356
397
|
* Who calls, as every operation receives it: the actor, its kind, its verified organization and the request
|
|
@@ -691,6 +732,155 @@ declare function recordExecution<E>(manifest: {
|
|
|
691
732
|
result: Result<unknown, Failure>;
|
|
692
733
|
}): void;
|
|
693
734
|
//#endregion
|
|
735
|
+
//#region src/execution.d.ts
|
|
736
|
+
/**
|
|
737
|
+
* What a transport knows of one call beyond its principal and token, and where execution leaves what the
|
|
738
|
+
* recording points read once the call has answered.
|
|
739
|
+
*/
|
|
740
|
+
interface ExecutionCall {
|
|
741
|
+
/** Over native RPC, the caller admission checked: `Invocation.rpcCaller`. */
|
|
742
|
+
readonly rpcCaller?: string;
|
|
743
|
+
/** On HTTP and MCP, the request's user agent: `Invocation.userAgent`. */
|
|
744
|
+
readonly userAgent?: string;
|
|
745
|
+
/** Set once the input is admitted: what its schema checked, and the decoded value the handler receives. */
|
|
746
|
+
admitted?: {
|
|
747
|
+
readonly checked: unknown;
|
|
748
|
+
readonly decoded: unknown;
|
|
749
|
+
};
|
|
750
|
+
/** Set once preparation answers: the context the handler receives. */
|
|
751
|
+
context?: unknown;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* The execution path every transport shares: checks that the caller may run the operation, decodes the input,
|
|
755
|
+
* prepares the context, runs the middleware and the handler, then checks the result against the declared
|
|
756
|
+
* output and failures. An unexpected error becomes `INTERNAL_ERROR` and is reported, never thrown. `call` hands
|
|
757
|
+
* the admitted input and the prepared context to the recording points, which only the Result would otherwise
|
|
758
|
+
* reach.
|
|
759
|
+
*/
|
|
760
|
+
declare function executeOperation<E, C, O extends Record<string, OperationShape>>(manifest: AppManifest<E, C, O>, operation: OperationShape, env: E, principal: Principal, input: unknown, authority?: InvocationAuthority, background?: BackgroundContext, body?: BinaryBody, call?: ExecutionCall): Promise<Result<unknown, Failure>>;
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/capture.d.ts
|
|
763
|
+
/** What a context is read as unless `defineCapture` names its type. */
|
|
764
|
+
type AnyContext = Record<string, any>;
|
|
765
|
+
/**
|
|
766
|
+
* What a `dimensions` callback learns of a call. It belongs to that call: read what it already knows, and start
|
|
767
|
+
* nothing.
|
|
768
|
+
*/
|
|
769
|
+
interface CaptureInvocation<E, C = AnyContext> {
|
|
770
|
+
/** The Worker's bindings. */
|
|
771
|
+
readonly env: E;
|
|
772
|
+
/** The operation's name; null when a refusal names none. */
|
|
773
|
+
readonly operation: string | null;
|
|
774
|
+
/** The transport that admitted the call. */
|
|
775
|
+
readonly surface: CaptureRecord['surface'];
|
|
776
|
+
/** The verified caller; null when the refusal came before it was verified. */
|
|
777
|
+
readonly principal: Principal | null;
|
|
778
|
+
/** What admission verified about the token, without the token. Absent as `Invocation.authority` is. */
|
|
779
|
+
readonly authority?: Omit<InvocationAuthority, 'token'>;
|
|
780
|
+
/** Over RPC, the caller admission checked. */
|
|
781
|
+
readonly rpcCaller?: string;
|
|
782
|
+
/** On HTTP and MCP, the request's user agent. What the caller claims. */
|
|
783
|
+
readonly userAgent?: string;
|
|
784
|
+
/** What the handler received, when the call got that far; empty before its context was prepared. */
|
|
785
|
+
readonly context: Partial<C>;
|
|
786
|
+
/** The decoded input, secrets included, for the callback to read ids from; absent for a refused input. */
|
|
787
|
+
readonly input?: unknown;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* What a call is about, in the service's own words: `{ agentId, conversationId }`. Each value is an identifier
|
|
791
|
+
* of up to 256 characters that the record may carry; any other value is left out.
|
|
792
|
+
*/
|
|
793
|
+
type CaptureDimensions = Readonly<Record<string, string | null | undefined>>;
|
|
794
|
+
/** Where records go. */
|
|
795
|
+
interface CaptureSink<E> {
|
|
796
|
+
/**
|
|
797
|
+
* Keeps one record; a rejection is a failed delivery. Capture itself never retries: a sink retries what it
|
|
798
|
+
* can safely repeat, as `pipeline` does, and one that cannot, an append whose outcome may be lost, does not.
|
|
799
|
+
*/
|
|
800
|
+
send: (record: CaptureRecord, env: E) => Promise<unknown>;
|
|
801
|
+
/**
|
|
802
|
+
* Whether this env can take records at all, such as a binding that exists in production and not in a preview.
|
|
803
|
+
* When it answers false, the call builds no record and logs nothing. Always when omitted.
|
|
804
|
+
*/
|
|
805
|
+
available?: (env: E) => boolean;
|
|
806
|
+
}
|
|
807
|
+
/** What `defineCapture` declares, and what `maximus()` takes as `capture`. */
|
|
808
|
+
interface CaptureConfig<E = unknown, C = AnyContext> {
|
|
809
|
+
/**
|
|
810
|
+
* Whether calls are captured: a boolean, or a function that decides for each env; on by default. It is apart
|
|
811
|
+
* from `telemetry.enabled`. A function that throws turns capture off for that call and logs
|
|
812
|
+
* `maximus.capture.switch_failed`.
|
|
813
|
+
*/
|
|
814
|
+
enabled?: boolean | ((env: E) => boolean);
|
|
815
|
+
/** Where records go. */
|
|
816
|
+
sink: CaptureSink<E>;
|
|
817
|
+
/**
|
|
818
|
+
* `all` also records each decoded input, checked output and failure data, without what their schemas mark
|
|
819
|
+
* `secret: true`; `none`, the default, records the metadata alone.
|
|
820
|
+
*/
|
|
821
|
+
payloads?: 'all' | 'none';
|
|
822
|
+
/**
|
|
823
|
+
* What the call is about, as `record.dimensions`. It runs as background work, and one that throws leaves the
|
|
824
|
+
* record without dimensions and logs `maximus.capture.dimensions_failed`.
|
|
825
|
+
*/
|
|
826
|
+
dimensions?: (invocation: CaptureInvocation<E, C>) => CaptureDimensions;
|
|
827
|
+
}
|
|
828
|
+
/** What a recording point reads of the application. */
|
|
829
|
+
interface CaptureApplication<E> {
|
|
830
|
+
name: string;
|
|
831
|
+
version: string;
|
|
832
|
+
operations: Readonly<Record<string, OperationShape>>;
|
|
833
|
+
errors: ErrorCatalog;
|
|
834
|
+
capture?: CaptureConfig<E>;
|
|
835
|
+
telemetry?: TelemetryConfig<E>;
|
|
836
|
+
}
|
|
837
|
+
/** What admission verified about a token, once it has. */
|
|
838
|
+
interface VerifiedCaller {
|
|
839
|
+
/** The scopes the token grants. */
|
|
840
|
+
readonly scopes: readonly string[];
|
|
841
|
+
/** The OAuth client it was issued to, when it names one. */
|
|
842
|
+
readonly client?: TokenClient;
|
|
843
|
+
/** The token as presented, which only its digest leaves this module as. */
|
|
844
|
+
readonly token?: string;
|
|
845
|
+
}
|
|
846
|
+
/** One call, or one refusal, as a transport hands it to `recordCapture`. */
|
|
847
|
+
interface CapturedCall {
|
|
848
|
+
/** The operation's name; null when a refusal names none. */
|
|
849
|
+
operation: string | null;
|
|
850
|
+
/** The transport that admitted the call. */
|
|
851
|
+
surface: CaptureRecord['surface'];
|
|
852
|
+
/** The request's id. */
|
|
853
|
+
requestId: string;
|
|
854
|
+
/** The verified caller; null before it was verified. */
|
|
855
|
+
principal: Principal | null;
|
|
856
|
+
/** What admission verified about the token; absent before it did, and over RPC. */
|
|
857
|
+
verified?: VerifiedCaller;
|
|
858
|
+
/** A `performance.now()` reading when the transport began admitting the call. */
|
|
859
|
+
requestStarted: number;
|
|
860
|
+
/** A `performance.now()` reading when execution began; absent for a refusal before it. */
|
|
861
|
+
executionStarted?: number;
|
|
862
|
+
/** What the caller received. */
|
|
863
|
+
result: Result<unknown, Failure>;
|
|
864
|
+
/** What the transport knows of the call beyond this, and what execution left for the record. */
|
|
865
|
+
call?: ExecutionCall;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Captures one call beside `recordExecution` or `recordAdmission`, as background work: it never throws, never
|
|
869
|
+
* delays or changes the response and never affects an observer. A failed delivery logs
|
|
870
|
+
* `maximus.capture.delivery_failed` with the request id alone. Nothing is recorded without a background context,
|
|
871
|
+
* or while capture is off, whether telemetry is on or not.
|
|
872
|
+
*/
|
|
873
|
+
declare function recordCapture<E>(application: CaptureApplication<E>, env: E, background: BackgroundContext | undefined, captured: CapturedCall): void;
|
|
874
|
+
//#endregion
|
|
875
|
+
//#region src/schema-types.d.ts
|
|
876
|
+
/** Opaque owner codecs already carry their decoded static type; only native transforms need traversal. */
|
|
877
|
+
type HasNativeTransform<S extends TSchema> = typeof TransformKind extends keyof S ? true : string extends S[typeof Kind] ? false : S extends TObject<infer P> ? true extends { [K in keyof P]: HasNativeTransform<P[K]>; }[keyof P] ? true : false : S extends TArray<infer I> ? HasNativeTransform<I> : S extends TUnion<infer U> | TTuple<infer U> ? HasNativeTransform<U[number]> : S extends TRecord<TSchema, infer V> ? HasNativeTransform<V> : false;
|
|
878
|
+
/**
|
|
879
|
+
* A schema's decoded value. TypeBox's deep decoder can recurse indefinitely through opaque owner
|
|
880
|
+
* codecs; a schema without native transforms already has exactly its decoded `Static` type.
|
|
881
|
+
*/
|
|
882
|
+
type StaticDecode$1<S extends TSchema> = true extends HasNativeTransform<S> ? StaticDecode<S> : Static<S>;
|
|
883
|
+
//#endregion
|
|
694
884
|
//#region src/manifest.d.ts
|
|
695
885
|
/** Transport-verified authority, separate from the unchanged ordinary RPC principal. */
|
|
696
886
|
interface InvocationAuthority {
|
|
@@ -728,6 +918,16 @@ interface Invocation<Env> {
|
|
|
728
918
|
* over ordinary RPC.
|
|
729
919
|
*/
|
|
730
920
|
readonly authority?: InvocationAuthority;
|
|
921
|
+
/**
|
|
922
|
+
* Over native RPC, the `caller` of the Service Binding, which admission checked against the operation's
|
|
923
|
+
* callers; absent on HTTP and MCP.
|
|
924
|
+
*/
|
|
925
|
+
readonly rpcCaller?: string;
|
|
926
|
+
/**
|
|
927
|
+
* On HTTP and MCP, the request's `user-agent`, cut to 200 characters; absent over RPC. It is what the caller
|
|
928
|
+
* claims, for an audit to read: never authorization.
|
|
929
|
+
*/
|
|
930
|
+
readonly userAgent?: string;
|
|
731
931
|
/** Already decoded operation input; preparation must not re-validate or log it. */
|
|
732
932
|
readonly input?: unknown;
|
|
733
933
|
/** Builder-owned operation identifier, never taken from caller input. */
|
|
@@ -982,6 +1182,11 @@ interface AppManifest<Env, C, Ops extends Record<string, OperationShape>> {
|
|
|
982
1182
|
* where the trace id comes from.
|
|
983
1183
|
*/
|
|
984
1184
|
telemetry?: TelemetryConfig<Env>;
|
|
1185
|
+
/**
|
|
1186
|
+
* One complete record of every operation call and refusal for a store the application declares, apart from
|
|
1187
|
+
* telemetry: `defineCapture` from `@arbol-ai/maximus/capture`.
|
|
1188
|
+
*/
|
|
1189
|
+
capture?: CaptureConfig<Env>;
|
|
985
1190
|
/**
|
|
986
1191
|
* A Workers rate limiting binding each HTTP and MCP call must pass, per organization and actor;
|
|
987
1192
|
* `retryAfter` sets a refusal's `Retry-After` seconds, 60 by default.
|
|
@@ -1109,11 +1314,11 @@ interface InputIssue {
|
|
|
1109
1314
|
* field issues. Schema messages name the expectation, not the value; owner refinements must too.
|
|
1110
1315
|
*/
|
|
1111
1316
|
declare function decodeInput<Schema extends TSchema>(schema: Schema, input: unknown): {
|
|
1112
|
-
error?: undefined;
|
|
1113
1317
|
ok: true;
|
|
1114
1318
|
value: StaticDecode$1<Schema>;
|
|
1115
1319
|
} | {
|
|
1116
1320
|
value?: undefined;
|
|
1321
|
+
checked?: undefined;
|
|
1117
1322
|
ok: false;
|
|
1118
1323
|
error: {
|
|
1119
1324
|
code: 'INVALID_INPUT';
|
|
@@ -1204,7 +1409,8 @@ declare const transformSchema: <S extends TSchema, O>(schema: S, transform: (val
|
|
|
1204
1409
|
} : Record<never, never>);
|
|
1205
1410
|
/**
|
|
1206
1411
|
* Admits a value as `source`, then checks and decodes the result as `target`: a wire shape read into its
|
|
1207
|
-
* canonical one. Runs inside `inputSchema()`.
|
|
1412
|
+
* canonical one. Runs inside `inputSchema()`. A `target` that marks a field `secret: true` needs `source` to
|
|
1413
|
+
* mark it too, or it throws a TypeError.
|
|
1208
1414
|
*/
|
|
1209
1415
|
declare const pipeSchema: <S extends TSchema, O extends TSchema>(source: S, target: O) => O & WireType<SchemaInput<S>>;
|
|
1210
1416
|
/**
|
|
@@ -1264,6 +1470,20 @@ declare function checkSchema<S extends TSchema>(schema: S, input: unknown): Chec
|
|
|
1264
1470
|
/** `checkSchema`, throwing its SchemaValidationError on refusal. */
|
|
1265
1471
|
declare function readSchema<S extends TSchema>(schema: S, input: unknown): StaticDecode$1<S>;
|
|
1266
1472
|
//#endregion
|
|
1473
|
+
//#region src/secrets.d.ts
|
|
1474
|
+
/**
|
|
1475
|
+
* A copy of a value without every field its schema marks with `secret: true`, at any depth: through objects,
|
|
1476
|
+
* records, arrays, tuples, unions, intersections, optional fields and references. The input is never changed.
|
|
1477
|
+
* A marked list element goes with its value, a marked tuple position becomes `null`, and a schema marked at
|
|
1478
|
+
* its root answers `undefined`.
|
|
1479
|
+
*
|
|
1480
|
+
* Pass a value of the shape the schema describes: what it checked, before any codec ran. It fails closed where
|
|
1481
|
+
* a schema cannot speak for a value: a name marked in any member of a union is removed from all of them, a
|
|
1482
|
+
* key a strict object refuses is removed, as is a value of another type, or one under a `$ref` the schema does
|
|
1483
|
+
* not define.
|
|
1484
|
+
*/
|
|
1485
|
+
declare function withoutSecrets(schema: TSchema, value: unknown): unknown;
|
|
1486
|
+
//#endregion
|
|
1267
1487
|
//#region src/pagination.d.ts
|
|
1268
1488
|
/**
|
|
1269
1489
|
* How to reach a list's neighboring pages: whether they exist and their opaque cursors, named `PageInfo`.
|
|
@@ -1425,6 +1645,11 @@ interface TransportContext {
|
|
|
1425
1645
|
* first, and `invoke` counts each of its calls itself.
|
|
1426
1646
|
*/
|
|
1427
1647
|
admitRequest: () => Promise<boolean>;
|
|
1648
|
+
/**
|
|
1649
|
+
* Captures a refusal the transport answers itself, such as a call to a tool the caller cannot see: its code,
|
|
1650
|
+
* and the operation when it names one.
|
|
1651
|
+
*/
|
|
1652
|
+
refused: (failure: Failure, operation?: string) => void;
|
|
1428
1653
|
/** Bytes of the request body the transport received. */
|
|
1429
1654
|
bodyBytes: number;
|
|
1430
1655
|
/** The body limit HTTP applies to an operation; a transport holds each invocation to it. */
|
|
@@ -1631,16 +1856,8 @@ declare function createOpenApi<E, C, O extends Record<string, OperationShape>>(m
|
|
|
1631
1856
|
operationExtensions?: (name: string, operation: OperationShape) => Record<`x-${string}`, unknown>;
|
|
1632
1857
|
}): Record<string, unknown>;
|
|
1633
1858
|
//#endregion
|
|
1634
|
-
//#region src/execution.d.ts
|
|
1635
|
-
/**
|
|
1636
|
-
* The execution path every transport shares: checks that the caller may run the operation, decodes the input,
|
|
1637
|
-
* prepares the context, runs the middleware and the handler, then checks the result against the declared
|
|
1638
|
-
* output and failures. An unexpected error becomes `INTERNAL_ERROR` and is reported, never thrown.
|
|
1639
|
-
*/
|
|
1640
|
-
declare function executeOperation<E, C, O extends Record<string, OperationShape>>(manifest: AppManifest<E, C, O>, operation: OperationShape, env: E, principal: Principal, input: unknown, authority?: InvocationAuthority, background?: BackgroundContext, body?: BinaryBody): Promise<Result<unknown, Failure>>;
|
|
1641
|
-
//#endregion
|
|
1642
1859
|
//#region src/define-app.d.ts
|
|
1643
1860
|
/** Checks the application, then hands it back unchanged. */
|
|
1644
1861
|
declare function defineApp<Env, C>(): <const Ops extends Record<string, OperationShape>>(manifest: AppManifest<Env, C, Ops>) => AppManifest<Env, C, Ops>;
|
|
1645
1862
|
//#endregion
|
|
1646
|
-
export {
|
|
1863
|
+
export { TPage as $, Attachment as $n, ExecutionCall as $t, OrganizationIdSchema as A, BinaryBody as An, Exposure as At, HttpsUrlSchema as B, ErrorFactory as Bn, isPublicOperation as Bt, HttpOptions as C, projectToken as Cn, decodeSchema as Ct, TransportContext as D, protectedResourceMetadata as Dn, ApplicationConfiguration as Dt, RouteContext as E, OAuthResource as En, ApplicationBuilder as Et, t$1 as F, isResult as Fn, McpSkill as Ft, PostalAddressSchema as G, resultSchema as Gn, AnyContext as Gt, NamedReferenceSchema as H, FailureData as Hn, operationMatchesScopes as Ht, DeletedObject as I, ok as In, OperationMiddleware as It, Page as J, TraceParent as Jn, CaptureInvocation as Jt, SignedUrl as K, standardErrors as Kn, CaptureConfig as Kt, DeletedObjectSchema as L, DefinedErrors as Ln, OperationScope as Lt, TSchema$2 as M, Result as Mn, InvocationAuthority as Mt, Type$2 as N, Success as Nn, McpConfiguration as Nt, createHttpHandler as O, CaptureRecord as On, maximus as Ot, UuidSchema as P, err as Pn, McpGuide as Pt, PageQueryFields as Q, parseTraceParent as Qn, recordCapture as Qt, EmailAddressSchema as R, ErrorCatalog as Rn, OperationShape as Rt, operationPathParameters as S, createTokenVerifier as Sn, decodeInput as St, HttpTransport as T, matchesScopes as Tn, parseSchema as Tt, PhoneNumberSchema as U, FailureSchema as Un, operationScopes as Ut, NamedReference as V, Failure as Vn, operation as Vt, PostalAddress as W, defineErrors as Wn, StaticDecode$1 as Wt, PageInfoSchema as X, durableCorrelation as Xn, CapturedCall as Xt, PageInfo as Y, createRequestId as Yn, CaptureSink as Yt, PageQuery as Z, isRequestId as Zn, VerifiedCaller as Zt, HttpRouteMatch as _, TokenPolicy as _n, strictObject as _t, t as a, TelemetryConfig as an, SchemaInput as at, isInputHeaderName as b, TokenScheme as bn, urlSchema as bt, readJsonBody as c, reportUnexpected as cn, defaultSchema as ct, BodyReadOptions as d, Principal as dn, inspectSchema as dt, executeOperation as en, AttachmentOutputSchema as er, pageLimit as et, HttpBodyFailure as f, PrincipalSchema as fn, literalUnion as ft, HttpRouteDefinition as g, TokenDevelopment as gn, refineSchema as gt, readBodyText as h, TokenClient as hn, pipeSchema as ht, Type$1 as i, Observer as in, readSchema as it, Static$2 as j, FailureResult as jn, Invocation as jt, EmptyInputSchema as k, CaptureRecordSchema as kn, AppManifest as kt, readJsonResponse as l, telemetryEnabled as ln, extendObject as lt, readBodyBytes as m, TokenClaims as mn, normalizeSchema as mt, Static$1 as n, BackgroundContext as nn, Checked as nt, createOpenApi as o, diagnosticsEnabled as on, SchemaIssue as ot, HttpBodyFailureReason as p, TokenAlgorithm as pn, looseObject as pt, SignedUrlSchema as q, DurableCorrelation as qn, CaptureDimensions as qt, TSchema$1 as r, ExecutionObservation as rn, checkSchema as rt, isJsonMediaType as s, recordExecution as sn, SchemaValidationError as st, defineApp as t, AdmissionObservation as tn, withoutSecrets as tt, retryAfterSeconds as u, withDiagnostics as un, inputSchema as ut, createHttpRouteResolver as v, TokenPrincipal as vn, stripObject as vt, HttpRoute as w, ScopeMatch as wn, parseInput as wt, isPathParameterValue as x, createTokenAuthorization as xn, InputIssue as xt, decodePathParameter as y, TokenResolutionContext as yn, transformSchema as yt, HexColorSchema as z, ErrorDefinition as zn, composeOperations as zt };
|