@maxceem/agw 0.15.0 → 0.15.1

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 (2) hide show
  1. package/dist/agw.mjs +77 -43
  2. package/package.json +2 -1
package/dist/agw.mjs CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // <define:__AGW_MANIFEST__>
9
- var define_AGW_MANIFEST_default = { version: "0.15.0", wrangler: "4.96.0", upgradeFrom: ["0.15.0", "0.14.0", "0.13.1", "0.13.0", "0.12.1", "0.12.0", "0.11.2", "0.11.1", "0.11.0", "0.10.11", "0.10.10", "0.10.9", "0.10.8", "0.10.7", "0.10.6", "0.10.5", "0.10.4", "0.10.3", "0.10.2", "0.10.1", "0.10.0", "0.9.3", "0.9.2", "0.9.1", "0.9.0", "0.8.3", "0.8.2", "0.8.1", "0.8.0", "0.7.2", "0.7.1", "0.7.0", "0.6.4", "0.6.3", "0.6.2", "0.6.1", "0.6.0", "0.5.2", "0.5.1", "0.5.0", "0.4.0"], release: { url: "https://github.com/maxceem/app-ai-gateway/releases/download/v0.15.0/gateway-0.15.0.tar.gz", sha256: "a16f9357ee510e03ba06f1d9ddc531057d00fef1750a0318969da72b8c3ef282", manifest: "48e6067ef1475bf894a3f00021c5caf3ee2140fae57f64d487f32e2f93e2553f" } };
9
+ var define_AGW_MANIFEST_default = { version: "0.15.1", wrangler: "4.96.0", upgradeFrom: ["0.15.1", "0.15.0", "0.14.0", "0.13.1", "0.13.0", "0.12.1", "0.12.0", "0.11.2", "0.11.1", "0.11.0", "0.10.11", "0.10.10", "0.10.9", "0.10.8", "0.10.7", "0.10.6", "0.10.5", "0.10.4", "0.10.3", "0.10.2", "0.10.1", "0.10.0", "0.9.3", "0.9.2", "0.9.1", "0.9.0", "0.8.3", "0.8.2", "0.8.1", "0.8.0", "0.7.2", "0.7.1", "0.7.0", "0.6.4", "0.6.3", "0.6.2", "0.6.1", "0.6.0", "0.5.2", "0.5.1", "0.5.0", "0.4.0"], release: { url: "https://github.com/maxceem/app-ai-gateway/releases/download/v0.15.1/gateway-0.15.1.tar.gz", sha256: "b5938517a50f09ea3ce3f966efd949dde8e9f0f2c195d47bb0dfdcbc7ec8eda0", manifest: "888f171f040d7547b37c40b41c01a53d1f284c9671e0bdc98083e9474c4ecdab" } };
10
10
 
11
11
  // src/main.ts
12
12
  import { Writable as Writable2 } from "node:stream";
@@ -20509,25 +20509,76 @@ var ENDPOINT_PROVIDER_TYPES = PROVIDER_TYPES.filter(
20509
20509
  var APP_STATUSES = ["active", "disabled"];
20510
20510
 
20511
20511
  // ../src/shared/token-rates.ts
20512
- var TOKEN_RATE_FIELDS = [
20513
- "input",
20514
- "output",
20515
- "cached_input",
20516
- "cache_write",
20517
- "cache_write_1h",
20518
- "image_input",
20519
- "audio_input",
20520
- "video_input",
20521
- "image_output",
20522
- "long_input",
20523
- "long_output",
20524
- "long_cached_input",
20525
- "long_cache_write",
20526
- "long_cache_write_1h"
20527
- ];
20528
- var LONG_RATE_FIELDS = TOKEN_RATE_FIELDS.filter(
20529
- (field) => field.startsWith("long_")
20512
+ var TOKEN_VARIANTS = {
20513
+ cache_write: {
20514
+ // Anthropic: a write kept for an hour bills at 2x input, against 1.25x for
20515
+ // the default five minutes. `usage.cache_creation` splits the write by TTL.
20516
+ "1h": {
20517
+ label: "1h cache write",
20518
+ description: "USD per 1M tokens written to a one-hour cache, where it costs more than the default cache write.",
20519
+ reportedAt: ["cache_creation", "ephemeral_1h_input_tokens"]
20520
+ },
20521
+ // OpenAI (Responses API): a write kept for 12 hours bills at 2.5x input,
20522
+ // against 1.25x for the default 30 minutes.
20523
+ "12h": {
20524
+ label: "12h cache write",
20525
+ description: "USD per 1M tokens written to a 12-hour cache, where it costs more than the default cache write.",
20526
+ reportedAt: ["input_tokens_details", "cache_write_tokens_details", "ttl_12h_tokens"]
20527
+ }
20528
+ }
20529
+ };
20530
+ var VARIANTS = Object.entries(TOKEN_VARIANTS).flatMap(
20531
+ ([bucket, variants]) => Object.entries(variants).map(([name, spec]) => ({
20532
+ ...spec,
20533
+ bucket,
20534
+ name,
20535
+ field: `${bucket}_${name}`
20536
+ }))
20530
20537
  );
20538
+ var BUCKETS = ["input", "cached_input", "cache_write", "output"];
20539
+ var MODALITY_RATES = ["image_input", "audio_input", "video_input", "image_output"];
20540
+ var BASE_RATES = {
20541
+ input: { label: "input" },
20542
+ cached_input: { label: "cached" },
20543
+ cache_write: { label: "cache write" },
20544
+ output: { label: "output" },
20545
+ image_input: {
20546
+ label: "image input",
20547
+ description: "USD per 1M image input tokens, where they are priced apart from text input."
20548
+ },
20549
+ audio_input: {
20550
+ label: "audio input",
20551
+ description: "USD per 1M audio input tokens, where they are priced apart from text input."
20552
+ },
20553
+ video_input: {
20554
+ label: "video input",
20555
+ description: "USD per 1M video input tokens, where they are priced apart from text input."
20556
+ },
20557
+ image_output: {
20558
+ label: "image output",
20559
+ description: "USD per 1M generated image tokens, where they cost more than text output."
20560
+ }
20561
+ };
20562
+ var BUCKET_FIELDS = BUCKETS.flatMap((bucket) => [
20563
+ bucket,
20564
+ ...VARIANTS.filter((variant) => variant.bucket === bucket).map((variant) => variant.field)
20565
+ ]);
20566
+ var LONG_RATE_FIELDS = BUCKET_FIELDS.map((field) => `long_${field}`);
20567
+ var TOKEN_RATE_FIELDS = [...BUCKET_FIELDS, ...MODALITY_RATES, ...LONG_RATE_FIELDS];
20568
+ var SHORT_INFO = new Map([
20569
+ ...Object.entries(BASE_RATES),
20570
+ ...VARIANTS.map((variant) => [variant.field, variant])
20571
+ ]);
20572
+ var RATE_LABELS = Object.fromEntries(
20573
+ TOKEN_RATE_FIELDS.map((field) => {
20574
+ const short = field.startsWith("long_") ? field.slice("long_".length) : field;
20575
+ const label = SHORT_INFO.get(short)?.label ?? short;
20576
+ return [field, short === field ? label : `long ${label}`];
20577
+ })
20578
+ );
20579
+ function rateDescription(field) {
20580
+ return SHORT_INFO.get(field)?.description;
20581
+ }
20531
20582
 
20532
20583
  // ../src/contracts/schemas.ts
20533
20584
  var ISSUER_PROVIDERS = ["firebase", "supabase", "auth0", "clerk", "custom"];
@@ -23693,40 +23744,23 @@ var UsageRepriceResponseSchema = external_exports.object({
23693
23744
  recalculated_cost_usd: external_exports.number(),
23694
23745
  delta_usd: external_exports.number()
23695
23746
  });
23747
+ var CATALOG_TOKEN_RATES = Object.fromEntries(
23748
+ TOKEN_RATE_FIELDS.map((field) => {
23749
+ const description = rateDescription(field);
23750
+ return [field, description ? external_exports.number().optional().meta({ description }) : external_exports.number().optional()];
23751
+ })
23752
+ );
23696
23753
  var ModelPriceSchema = external_exports.object({
23697
23754
  kind: external_exports.enum(MODEL_KINDS).meta({
23698
23755
  description: "What the model does: text, image (generation), speech (text to speech), transcription (speech to text), embedding, or realtime (served only over a realtime session). A custom endpoint serves models of its own kind only."
23699
23756
  }),
23700
- input: external_exports.number().optional(),
23701
- output: external_exports.number().optional(),
23702
- image_input: external_exports.number().optional().meta({
23703
- description: "USD per 1M image input tokens, where they are priced apart from text input."
23704
- }),
23705
- audio_input: external_exports.number().optional().meta({
23706
- description: "USD per 1M audio input tokens, where they are priced apart from text input."
23707
- }),
23708
- video_input: external_exports.number().optional().meta({
23709
- description: "USD per 1M video input tokens, where they are priced apart from text input."
23710
- }),
23711
- image_output: external_exports.number().optional().meta({
23712
- description: "USD per 1M generated image tokens, where they cost more than text output."
23713
- }),
23714
- cached_input: external_exports.number().optional(),
23715
- cache_write: external_exports.number().optional(),
23716
- cache_write_1h: external_exports.number().optional().meta({
23717
- description: "USD per 1M tokens written to a one-hour cache, where it costs more than the default cache write."
23718
- }),
23757
+ ...CATALOG_TOKEN_RATES,
23719
23758
  per_minute: external_exports.number().optional(),
23720
23759
  per_hour: external_exports.number().optional(),
23721
23760
  per_image: external_exports.number().optional().meta({
23722
23761
  description: "USD per generated image, for a model billed per image rather than per token."
23723
23762
  }),
23724
23763
  long_context_threshold: external_exports.number().optional(),
23725
- long_input: external_exports.number().optional(),
23726
- long_output: external_exports.number().optional(),
23727
- long_cached_input: external_exports.number().optional(),
23728
- long_cache_write: external_exports.number().optional(),
23729
- long_cache_write_1h: external_exports.number().optional(),
23730
23764
  retirement_date: external_exports.string().optional().meta({
23731
23765
  description: "The day (YYYY-MM-DD) the provider stops, or stopped, serving this model. The model stays priced after it."
23732
23766
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxceem/agw",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "Manage App AI Gateway from a terminal or coding agent: providers, iOS and server apps, usage, and self-hosted deployment on Cloudflare",
6
6
  "keywords": [
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "bugs": "https://github.com/maxceem/app-ai-gateway/issues",
28
28
  "upgradeFrom": [
29
+ "0.15.0",
29
30
  "0.14.0",
30
31
  "0.13.1",
31
32
  "0.13.0",