@zuplo/cli 6.73.28 → 6.73.29

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.
@@ -475,7 +475,6 @@ export declare class AIGatewayMeteringInboundPolicy extends InboundPolicy<AIGate
475
475
  increments: AIGatewayMeterIncrements,
476
476
  context: ZuploContext
477
477
  ): Promise<void>;
478
- private static incrementMetersInternal;
479
478
  private checkWarnings;
480
479
  private checkQuotaWarning;
481
480
  private createHierarchicalQuotaExceededResponse;
@@ -492,6 +491,131 @@ export declare interface AIGatewayMeteringInboundPolicyOptions {
492
491
  throwOnFailure?: boolean;
493
492
  }
494
493
 
494
+ /**
495
+ * Meters AI Gateway v2 usage and enforces options-driven usage limits.
496
+ *
497
+ * The authentication policy must run before this policy so the app
498
+ * configuration id is available for meter storage and analytics.
499
+ *
500
+ * @title AI Gateway Metering (v2)
501
+ * @beta
502
+ * @product ai-gateway
503
+ * @requiresAI
504
+ * @param request - The ZuploRequest
505
+ * @param context - The ZuploContext
506
+ * @param options - The policy options set in policies.json
507
+ * @param policyName - The name of the policy as set in policies.json
508
+ * @returns The request, or a 429 response when a limit is exceeded
509
+ */
510
+ export declare class AIGatewayMeteringV2InboundPolicy extends InboundPolicy<AIGatewayMeteringV2InboundPolicyOptions> {
511
+ #private;
512
+ static readonly policyType = "ai-gateway-metering-v2";
513
+ constructor(
514
+ options: AIGatewayMeteringV2InboundPolicyOptions,
515
+ policyName: string
516
+ );
517
+ /** Set the meter increments accumulated for this request. */
518
+ static setIncrements(
519
+ context: ZuploContext,
520
+ increments: AIGatewayMeterIncrements
521
+ ): void;
522
+ /** Read the meter increments accumulated for this request. */
523
+ static getIncrements(context: ZuploContext): AIGatewayMeterIncrements;
524
+ /** Set the quota-fallback marker for this request. */
525
+ static setQuotaFallback(
526
+ context: ZuploContext,
527
+ quotaFallback: QuotaFallbackModels
528
+ ): void;
529
+ /** Read the quota-fallback marker for this request. */
530
+ static getQuotaFallback(
531
+ context: ZuploContext
532
+ ): QuotaFallbackModels | undefined;
533
+ /**
534
+ * Compose request-scoped limit overrides with any limits already set.
535
+ *
536
+ * Limits intentionally merge at each meter, period, and setting leaf because
537
+ * independent policies may tighten one path without restating sibling limits.
538
+ * Defined values from the newest call win; undefined values never erase an
539
+ * earlier value.
540
+ *
541
+ * @param context - The current request context
542
+ * @param limits - Limits or partial leaf overrides to compose
543
+ */
544
+ static setLimits(
545
+ context: ZuploContext,
546
+ limits: AIGatewayMeteringV2LimitOverrides
547
+ ): void;
548
+ /** Read request-scoped limit overrides. */
549
+ static getLimits(
550
+ context: ZuploContext
551
+ ): AIGatewayMeteringV2LimitOverrides | undefined;
552
+ /** Increment meters directly, for example after a streaming response. */
553
+ static incrementMeters(
554
+ configurationId: string,
555
+ increments: AIGatewayMeterIncrements,
556
+ context: ZuploContext
557
+ ): Promise<void>;
558
+ handler(
559
+ request: ZuploRequest,
560
+ context: ZuploContext
561
+ ): Promise<ZuploRequest | Response>;
562
+ private resolveConfiguration;
563
+ private fetchCurrentMeters;
564
+ private checkWarnings;
565
+ private hasWarning;
566
+ private findViolation;
567
+ private requestCapability;
568
+ private createQuotaExceededResponse;
569
+ }
570
+
571
+ /**
572
+ * Options for metering AI Gateway v2 usage and enforcing request-time limits.
573
+ * @public
574
+ */
575
+ export declare interface AIGatewayMeteringV2InboundPolicyOptions {
576
+ /**
577
+ * Throw when the metering service is unavailable instead of failing open.
578
+ */
579
+ throwOnFailure?: boolean;
580
+ /**
581
+ * Usage limits grouped by meter.
582
+ */
583
+ limits?: {
584
+ costs?: QuotaLimit;
585
+ tokens?: QuotaLimit;
586
+ requests?: QuotaLimit;
587
+ };
588
+ }
589
+
590
+ /**
591
+ * Request-scoped usage-limit overrides accepted by
592
+ * `AIGatewayMeteringV2InboundPolicy.setLimits`.
593
+ */
594
+ export declare interface AIGatewayMeteringV2LimitOverrides {
595
+ costs?: AIGatewayMeteringV2MeterLimitOverrides;
596
+ tokens?: AIGatewayMeteringV2MeterLimitOverrides;
597
+ requests?: AIGatewayMeteringV2MeterLimitOverrides;
598
+ }
599
+
600
+ /** Daily and monthly overrides for one usage meter. */
601
+ declare interface AIGatewayMeteringV2MeterLimitOverrides {
602
+ daily?: AIGatewayMeteringV2PeriodLimitOverride;
603
+ monthly?: AIGatewayMeteringV2PeriodLimitOverride;
604
+ }
605
+
606
+ /** Settings that a policy can override for one usage-limit period. */
607
+ declare interface AIGatewayMeteringV2PeriodLimitOverride {
608
+ enabled?: boolean;
609
+ limit?: number;
610
+ warning?: AIGatewayMeteringV2WarningLimitOverride;
611
+ }
612
+
613
+ /** Warning settings that a policy can override for one usage-limit period. */
614
+ declare interface AIGatewayMeteringV2WarningLimitOverride {
615
+ enabled?: boolean;
616
+ threshold?: number;
617
+ }
618
+
495
619
  /**
496
620
  * Matches AI Gateway requests against curated allow lists or open block lists,
497
621
  * then stores the winning model reference for the route handler.
@@ -12178,6 +12302,17 @@ export declare interface QuotaInboundPolicyOptions {
12178
12302
  };
12179
12303
  }
12180
12304
 
12305
+ declare interface QuotaLimit {
12306
+ daily?: QuotaSettings;
12307
+ monthly?: QuotaSettings;
12308
+ }
12309
+
12310
+ declare interface QuotaSettings {
12311
+ enabled: boolean;
12312
+ limit?: number;
12313
+ warning?: WarningSettings;
12314
+ }
12315
+
12181
12316
  /**
12182
12317
  * The identifying element of the request that enforces distinct rate limits. For example, you can limit by `user`, `ip`, `function` or `all` - function allows you to specify a simple function to create a string identifier to create a rate-limit group.
12183
12318
  * @public
@@ -15720,6 +15855,14 @@ declare interface WaitUntilFunc {
15720
15855
  (promise: Promise<any>): void;
15721
15856
  }
15722
15857
 
15858
+ declare interface WarningSettings {
15859
+ enabled: boolean;
15860
+ /**
15861
+ * Percentage of the limit at which to emit a warning event.
15862
+ */
15863
+ threshold?: number;
15864
+ }
15865
+
15723
15866
  /**
15724
15867
  * Authenticate bots using web-bot-auth HTTP Message Signatures.
15725
15868
  *
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.73.28",
4
+ "version": "6.73.29",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "6.73.28",
3
+ "version": "6.73.29",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -27,10 +27,10 @@
27
27
  "@opentelemetry/api": "1.9.0",
28
28
  "@opentelemetry/api-logs": "0.220.0",
29
29
  "@swc/core": "1.10.18",
30
- "@zuplo/core": "6.73.28",
30
+ "@zuplo/core": "6.73.29",
31
31
  "@zuplo/editor": "1.0.29844086763",
32
- "@zuplo/openapi-tools": "6.73.28",
33
- "@zuplo/runtime": "6.73.28",
32
+ "@zuplo/openapi-tools": "6.73.29",
33
+ "@zuplo/runtime": "6.73.29",
34
34
  "chalk": "5.4.1",
35
35
  "chokidar": "3.5.3",
36
36
  "cookie": "1.0.2",
@@ -61,8 +61,8 @@
61
61
  "workerd": "1.20241230.0",
62
62
  "yargs": "17.7.2",
63
63
  "zod": "3.25.76",
64
- "@zuplo/graphql": "6.73.28",
65
- "@zuplo/otel": "6.73.28"
64
+ "@zuplo/graphql": "6.73.29",
65
+ "@zuplo/otel": "6.73.29"
66
66
  },
67
67
  "bundleDependencies": [
68
68
  "@inquirer/prompts",