@zuplo/runtime 6.70.62 → 6.70.66

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.
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{b as l}from"../chunk-LGEY3NNC.js";import{a as o,da as n}from"../chunk-ZIKV2LUM.js";function g(u={request:new Request("https://api.example.com")}){let e=[];function t(i){e.push(Promise.resolve(i))}return o(t,"waitUntil"),{context:new s({event:{waitUntil:t},route:u.route}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(g,"createMockContext");var p={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},s=class extends EventTarget{static{o(this,"MockZuploContext")}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=p,parentContext:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:n.console.info,log:n.console.log,debug:n.console.debug,warn:n.console.warn,error:n.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=r,this.#e=e,this.analyticsContext=new l(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,r){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,t,r){let d=o(i=>{try{typeof t=="function"?t(i):t.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,d,r)}};export{s as MockZuploContext,g as createMockContext};
25
+ import{b as l}from"../chunk-C2TBCXWG.js";import{a as o,da as n}from"../chunk-ZIKV2LUM.js";function g(u={request:new Request("https://api.example.com")}){let e=[];function t(i){e.push(Promise.resolve(i))}return o(t,"waitUntil"),{context:new s({event:{waitUntil:t},route:u.route}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(g,"createMockContext");var p={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},s=class extends EventTarget{static{o(this,"MockZuploContext")}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=p,parentContext:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:n.console.info,log:n.console.log,debug:n.console.debug,warn:n.console.warn,error:n.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=r,this.#e=e,this.analyticsContext=new l(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,r){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,t,r){let d=o(i=>{try{typeof t=="function"?t(i):t.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,d,r)}};export{s as MockZuploContext,g as createMockContext};
26
26
  //# sourceMappingURL=index.js.map
@@ -176,6 +176,22 @@ export declare class AIGatewayMeteringInboundPolicy extends InboundPolicy<AIGate
176
176
  increments: AIGatewayMeterIncrements
177
177
  ): void;
178
178
  static getIncrements(context: ZuploContext): AIGatewayMeterIncrements;
179
+ /**
180
+ * Record the global quota fallback models for the current request. Set by the
181
+ * metering policy when a quota is exceeded and a fallback is configured; read
182
+ * by the LLM translation handler, which routes to the capability-appropriate
183
+ * model instead of the (over-budget) primary.
184
+ *
185
+ * @param context - The ZuploContext
186
+ * @param quotaFallback - The validated quota fallback models.
187
+ */
188
+ static setQuotaFallback(
189
+ context: ZuploContext,
190
+ quotaFallback: QuotaFallbackModels
191
+ ): void;
192
+ static getQuotaFallback(
193
+ context: ZuploContext
194
+ ): QuotaFallbackModels | undefined;
179
195
  constructor(
180
196
  options: AIGatewayMeteringInboundPolicyOptions,
181
197
  policyName: string
@@ -185,6 +201,23 @@ export declare class AIGatewayMeteringInboundPolicy extends InboundPolicy<AIGate
185
201
  context: ZuploContext
186
202
  ): Promise<Response | ZuploRequest<RequestGeneric_2>>;
187
203
  private fetchCurrentMeters;
204
+ /**
205
+ * The capability a request targets, derived from its path, or `undefined` for
206
+ * paths that do not support quota fallback (e.g. `/v1/responses`, which the LLM
207
+ * handler serves without the fallback chain). Used to decide whether a quota
208
+ * fallback actually applies to *this* request.
209
+ */
210
+ private requestCapability;
211
+ /**
212
+ * Validate and return the configured quota fallback when it applies to *this*
213
+ * request's capability, or `undefined` otherwise (no config, malformed config,
214
+ * an unsupported path, or no model configured for the request's capability).
215
+ * Returning `undefined` blocks the request with a 429 — so a fallback is only
216
+ * counted and applied when the handler can actually serve the request with it.
217
+ * The config is customer-authored and reaches us through an `unknown` cast, so
218
+ * we validate it through Zod before acting on it.
219
+ */
220
+ private resolveQuotaFallback;
188
221
  private checkHierarchicalQuotaLimits;
189
222
  /**
190
223
  * Increment meters via API. Can be used by providers for streaming responses.
@@ -2969,6 +3002,7 @@ declare const EventType: {
2969
3002
  readonly AI_GATEWAY_LATENCY_HISTOGRAM: "ai_gateway_latency_histogram";
2970
3003
  readonly AI_GATEWAY_WARNING_COUNT: "ai_gateway_warning_count";
2971
3004
  readonly AI_GATEWAY_BLOCKED_COUNT: "ai_gateway_blocked_count";
3005
+ readonly AI_GATEWAY_FALLBACK_COUNT: "ai_gateway_fallback_count";
2972
3006
  readonly MCP_REQUEST_RECEIVED: "mcp_request_received";
2973
3007
  readonly MCP_REQUEST_COMPLETED: "mcp_request_completed";
2974
3008
  readonly MCP_REQUEST_REJECTED: "mcp_request_rejected";
@@ -5666,7 +5700,7 @@ declare type LokiTransportVersion = 1 | 2;
5666
5700
  * @title MCP Auth0 OAuth
5667
5701
  * @product mcp-gateway
5668
5702
  */
5669
- export declare class McpAuth0OAuthInboundPolicy extends InboundPolicy<McpAuth0OAuthInboundPolicyOptions> {
5703
+ export declare class McpAuth0OAuthInboundPolicy extends InboundPolicy<ValidatedAuth0OAuthOptions> {
5670
5704
  #private;
5671
5705
  constructor(rawOptions: unknown, policyName: string);
5672
5706
  handler(
@@ -5717,6 +5751,69 @@ export declare interface McpAuth0OAuthInboundPolicyOptions {
5717
5751
  */
5718
5752
  cimdEnabled?: boolean;
5719
5753
  };
5754
+ /**
5755
+ * Optional Identity Assertion JWT Authorization Grant (ID-JAG / XAA) support for the gateway token endpoint.
5756
+ */
5757
+ idJag?:
5758
+ | {
5759
+ /**
5760
+ * Disable ID-JAG support.
5761
+ */
5762
+ enabled: false;
5763
+ }
5764
+ | {
5765
+ /**
5766
+ * Enable ID-JAG support.
5767
+ */
5768
+ enabled: true;
5769
+ /**
5770
+ * Trusted ID-JAG issuers. These values are never published in OAuth metadata.
5771
+ *
5772
+ * @minItems 1
5773
+ */
5774
+ trustedIssuers: [
5775
+ {
5776
+ /**
5777
+ * Exact issuer URL expected in the ID-JAG iss claim.
5778
+ */
5779
+ issuer: string;
5780
+ /**
5781
+ * JWKS URL used to verify ID-JAG signatures from this issuer.
5782
+ */
5783
+ jwksUrl: string;
5784
+ /**
5785
+ * Optional allow-list of client IDs accepted from this issuer. The ID-JAG client_id must still match the authenticated token-endpoint client.
5786
+ */
5787
+ expectedClientIds?: string[];
5788
+ /**
5789
+ * How the ID-JAG subject is mapped into the gateway subject ID.
5790
+ */
5791
+ subjectMapping?: "iss_prefix" | "iss_tenant_prefix" | "sub_id_only";
5792
+ },
5793
+ ...{
5794
+ /**
5795
+ * Exact issuer URL expected in the ID-JAG iss claim.
5796
+ */
5797
+ issuer: string;
5798
+ /**
5799
+ * JWKS URL used to verify ID-JAG signatures from this issuer.
5800
+ */
5801
+ jwksUrl: string;
5802
+ /**
5803
+ * Optional allow-list of client IDs accepted from this issuer. The ID-JAG client_id must still match the authenticated token-endpoint client.
5804
+ */
5805
+ expectedClientIds?: string[];
5806
+ /**
5807
+ * How the ID-JAG subject is mapped into the gateway subject ID.
5808
+ */
5809
+ subjectMapping?: "iss_prefix" | "iss_tenant_prefix" | "sub_id_only";
5810
+ }[],
5811
+ ];
5812
+ /**
5813
+ * Optional allow-list of RFC 9396 authorization_details type values accepted from ID-JAGs.
5814
+ */
5815
+ authorizationDetailsTypesAllowed?: string[];
5816
+ };
5720
5817
  /**
5721
5818
  * Optional overrides for the derived browser-login settings.
5722
5819
  */
@@ -5727,6 +5824,38 @@ export declare interface McpAuth0OAuthInboundPolicyOptions {
5727
5824
  };
5728
5825
  }
5729
5826
 
5827
+ declare const mcpAuth0OAuthOptionsSchema: z.ZodObject<
5828
+ {
5829
+ auth0Domain: z.ZodString;
5830
+ audience: z.ZodOptional<z.ZodString>;
5831
+ clientId: z.ZodString;
5832
+ clientSecret: z.ZodString;
5833
+ scope: z.ZodOptional<z.ZodString>;
5834
+ gateway: z.ZodOptional<
5835
+ z.ZodObject<
5836
+ {
5837
+ accessTokenTtlSeconds: z.ZodOptional<z.ZodNumber>;
5838
+ refreshTokenTtlSeconds: z.ZodOptional<z.ZodNumber>;
5839
+ cimdEnabled: z.ZodOptional<z.ZodBoolean>;
5840
+ },
5841
+ z.core.$strict
5842
+ >
5843
+ >;
5844
+ idJag: z.ZodOptional<z.ZodUnknown>;
5845
+ browserLoginOverrides: z.ZodOptional<
5846
+ z.ZodObject<
5847
+ {
5848
+ remoteTimeoutMs: z.ZodOptional<z.ZodNumber>;
5849
+ stateTtlSeconds: z.ZodOptional<z.ZodNumber>;
5850
+ sessionTtlSeconds: z.ZodOptional<z.ZodNumber>;
5851
+ },
5852
+ z.core.$strict
5853
+ >
5854
+ >;
5855
+ },
5856
+ z.core.$strict
5857
+ >;
5858
+
5730
5859
  /**
5731
5860
  * Authenticate MCP gateway requests using a gateway-issued OAuth access token,
5732
5861
  * with browser login delegated to Clerk.
@@ -6260,6 +6389,69 @@ export declare interface McpOAuthInboundPolicyOptions {
6260
6389
  */
6261
6390
  cimdEnabled?: boolean;
6262
6391
  };
6392
+ /**
6393
+ * Optional Identity Assertion JWT Authorization Grant (ID-JAG / XAA) support for the gateway token endpoint.
6394
+ */
6395
+ idJag?:
6396
+ | {
6397
+ /**
6398
+ * Disable ID-JAG support.
6399
+ */
6400
+ enabled: false;
6401
+ }
6402
+ | {
6403
+ /**
6404
+ * Enable ID-JAG support.
6405
+ */
6406
+ enabled: true;
6407
+ /**
6408
+ * Trusted ID-JAG issuers. These values are never published in OAuth metadata.
6409
+ *
6410
+ * @minItems 1
6411
+ */
6412
+ trustedIssuers: [
6413
+ {
6414
+ /**
6415
+ * Exact issuer URL expected in the ID-JAG iss claim.
6416
+ */
6417
+ issuer: string;
6418
+ /**
6419
+ * JWKS URL used to verify ID-JAG signatures from this issuer.
6420
+ */
6421
+ jwksUrl: string;
6422
+ /**
6423
+ * Optional allow-list of client IDs accepted from this issuer. The ID-JAG client_id must still match the authenticated token-endpoint client.
6424
+ */
6425
+ expectedClientIds?: string[];
6426
+ /**
6427
+ * How the ID-JAG subject is mapped into the gateway subject ID.
6428
+ */
6429
+ subjectMapping?: "iss_prefix" | "iss_tenant_prefix" | "sub_id_only";
6430
+ },
6431
+ ...{
6432
+ /**
6433
+ * Exact issuer URL expected in the ID-JAG iss claim.
6434
+ */
6435
+ issuer: string;
6436
+ /**
6437
+ * JWKS URL used to verify ID-JAG signatures from this issuer.
6438
+ */
6439
+ jwksUrl: string;
6440
+ /**
6441
+ * Optional allow-list of client IDs accepted from this issuer. The ID-JAG client_id must still match the authenticated token-endpoint client.
6442
+ */
6443
+ expectedClientIds?: string[];
6444
+ /**
6445
+ * How the ID-JAG subject is mapped into the gateway subject ID.
6446
+ */
6447
+ subjectMapping?: "iss_prefix" | "iss_tenant_prefix" | "sub_id_only";
6448
+ }[],
6449
+ ];
6450
+ /**
6451
+ * Optional allow-list of RFC 9396 authorization_details type values accepted from ID-JAGs.
6452
+ */
6453
+ authorizationDetailsTypesAllowed?: string[];
6454
+ };
6263
6455
  }
6264
6456
 
6265
6457
  declare type McpOAuthRuntimeConfig = z.infer<
@@ -6314,6 +6506,50 @@ declare const mcpOAuthRuntimeConfigSchema: z.ZodObject<
6314
6506
  }
6315
6507
  >
6316
6508
  >;
6509
+ idJag: z.ZodDefault<
6510
+ z.ZodOptional<
6511
+ z.ZodDefault<
6512
+ z.ZodDiscriminatedUnion<
6513
+ [
6514
+ z.ZodObject<
6515
+ {
6516
+ enabled: z.ZodLiteral<false>;
6517
+ },
6518
+ z.core.$strict
6519
+ >,
6520
+ z.ZodObject<
6521
+ {
6522
+ enabled: z.ZodLiteral<true>;
6523
+ trustedIssuers: z.ZodArray<
6524
+ z.ZodObject<
6525
+ {
6526
+ issuer: z.ZodURL;
6527
+ jwksUrl: z.ZodURL;
6528
+ expectedClientIds: z.ZodOptional<
6529
+ z.ZodArray<z.ZodString>
6530
+ >;
6531
+ subjectMapping: z.ZodDefault<
6532
+ z.ZodEnum<{
6533
+ iss_prefix: "iss_prefix";
6534
+ iss_tenant_prefix: "iss_tenant_prefix";
6535
+ sub_id_only: "sub_id_only";
6536
+ }>
6537
+ >;
6538
+ },
6539
+ z.core.$strict
6540
+ >
6541
+ >;
6542
+ authorizationDetailsTypesAllowed: z.ZodOptional<
6543
+ z.ZodArray<z.ZodString>
6544
+ >;
6545
+ },
6546
+ z.core.$strict
6547
+ >,
6548
+ ]
6549
+ >
6550
+ >
6551
+ >
6552
+ >;
6317
6553
  },
6318
6554
  z.core.$strict
6319
6555
  >;
@@ -6844,6 +7080,12 @@ export declare interface MockApiInboundOptions {
6844
7080
  */
6845
7081
  export declare const MockApiInboundPolicy: InboundPolicyHandler<MockApiInboundOptions>;
6846
7082
 
7083
+ declare interface ModelConfiguration {
7084
+ environmentVariable: string;
7085
+ model: string;
7086
+ provider: string;
7087
+ }
7088
+
6847
7089
  declare type Modify<T, R> = Omit<T, keyof R> & R;
6848
7090
 
6849
7091
  declare interface MoesifContext {
@@ -8667,6 +8909,15 @@ export declare interface QuotaDetail {
8667
8909
  };
8668
8910
  }
8669
8911
 
8912
+ /**
8913
+ * Global quota fallback models, keyed by capability. Applied whenever any
8914
+ * configured quota limit (any meter/period) is exceeded.
8915
+ */
8916
+ declare interface QuotaFallbackModels {
8917
+ completions?: ModelConfiguration;
8918
+ embeddings?: ModelConfiguration;
8919
+ }
8920
+
8670
8921
  /**
8671
8922
  * The Quota policy enables you to set monthly, weekly, daily or hourly quotas on your API.
8672
8923
  *
@@ -10830,6 +11081,10 @@ export declare function urlRewriteHandler(
10830
11081
 
10831
11082
  declare type UserDataDefault = any;
10832
11083
 
11084
+ declare type ValidatedAuth0OAuthOptions = z.infer<
11085
+ typeof mcpAuth0OAuthOptionsSchema
11086
+ >;
11087
+
10833
11088
  /**
10834
11089
  * Validates the body of an incoming request based on a JSON schema.
10835
11090
  *