@carrierllc/mcp 0.13.78 → 0.13.79

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/index.js CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  verifyStorefront,
92
92
  withOcsListSummary,
93
93
  withTemplateResellerId
94
- } from "./chunk-G7BQL3FL.js";
94
+ } from "./chunk-4LA42G67.js";
95
95
  import "./chunk-SHKKVIIA.js";
96
96
 
97
97
  // src/index.ts
@@ -209,7 +209,7 @@ async function assertManagedIccidAccess(baseUrl2, auth, iccid) {
209
209
 
210
210
  // ../../packages/carrier-ai/dist/index.js
211
211
  import { AwsClient } from "aws4fetch";
212
- var NANO_EUR_PER_EUR = 1e9;
212
+ var NANO_USD_PER_USD = 1e9;
213
213
  var AI_COST_MULTIPLIER = 4;
214
214
  var AI_PRICE_MAX_AGE_DAYS = 30;
215
215
  var DAY_MS = 864e5;
@@ -245,14 +245,12 @@ function readAiCreditPricing(raw, modelId, now = Date.now()) {
245
245
  }
246
246
  const rates = value?.models?.[modelId];
247
247
  const validDate = (date) => typeof date === "string" && Number.isFinite(Date.parse(date));
248
- if (!positive(value?.eurPerUsd) || !validDate(value.fxAsOf) || !validDate(value.priceAsOf) || !rates || ![rates.inputPerMTok, rates.outputPerMTok, rates.cacheReadPerMTok, rates.cacheWritePerMTok].every(validRate) || !positive(rates.inputPerMTok) || !positive(rates.outputPerMTok) || !Number.isSafeInteger(rates.maxInputTokens) || rates.maxInputTokens <= 0 || !validLongContext(rates)) {
248
+ if (!value || !validDate(value.priceAsOf) || !rates || ![rates.inputPerMTok, rates.outputPerMTok, rates.cacheReadPerMTok, rates.cacheWritePerMTok].every(validRate) || !positive(rates.inputPerMTok) || !positive(rates.outputPerMTok) || !Number.isSafeInteger(rates.maxInputTokens) || rates.maxInputTokens <= 0 || !validLongContext(rates)) {
249
249
  throw new AiCreditError("AI credit pricing is not configured for this model.", "AI_PRICING_UNAVAILABLE");
250
250
  }
251
- for (const date of [value.fxAsOf, value.priceAsOf]) {
252
- const age = now - Date.parse(date);
253
- if (age > AI_PRICE_MAX_AGE_DAYS * DAY_MS || age < -DAY_MS) {
254
- throw new AiCreditError("AI credit pricing is out of date.", "AI_PRICING_STALE");
255
- }
251
+ const age = now - Date.parse(value.priceAsOf);
252
+ if (age > AI_PRICE_MAX_AGE_DAYS * DAY_MS || age < -DAY_MS) {
253
+ throw new AiCreditError("AI credit pricing is out of date.", "AI_PRICING_STALE");
256
254
  }
257
255
  return value;
258
256
  }
@@ -265,11 +263,11 @@ function aiSupplierCost(usage, pricing, modelId) {
265
263
  if (!model) throw new AiCreditError("Unpriced model.", "AI_PRICING_UNAVAILABLE");
266
264
  const rates = aiRatesForPrompt(model, usage.inputTokens + usage.cacheReadTokens + usage.cacheWriteTokens);
267
265
  const usd = (usage.inputTokens * rates.inputPerMTok + usage.outputTokens * rates.outputPerMTok + usage.cacheReadTokens * rates.cacheReadPerMTok + usage.cacheWriteTokens * rates.cacheWritePerMTok) / 1e6;
268
- const nanos2 = Math.round(usd * pricing.eurPerUsd * NANO_EUR_PER_EUR);
266
+ const nanos2 = Math.round(usd * NANO_USD_PER_USD);
269
267
  if (!Number.isSafeInteger(nanos2 * AI_COST_MULTIPLIER) || nanos2 < 0) {
270
268
  throw new AiCreditError("Supplier cost is outside the supported range.", "AI_USAGE_INVALID");
271
269
  }
272
- return { supplier_cost_nano_eur: nanos2, supplier_cost_usd: usd };
270
+ return { supplier_cost_nano_usd: nanos2, supplier_cost_usd: usd };
273
271
  }
274
272
  async function aiWalletRequest(env, orgId, suffix = "", body2) {
275
273
  if (!orgId || !env.CARRIER_INTERNAL_API_KEY || !env.ATLAS_BASE_URL) {
@@ -312,18 +310,16 @@ function createAiCreditBilling(env) {
312
310
  ...rates.longContext ? [{ prompt: rates.maxInputTokens, rates: rates.longContext }] : []
313
311
  ];
314
312
  const maxUsd = Math.max(...tiers.map(({ prompt, rates: tier }) => (prompt * Math.max(tier.inputPerMTok, tier.cacheReadPerMTok, tier.cacheWritePerMTok) + maxOutputTokens * tier.outputPerMTok) / 1e6));
315
- const maxCost = Math.ceil(maxUsd * pricing.eurPerUsd * NANO_EUR_PER_EUR) * AI_COST_MULTIPLIER;
313
+ const maxCost = Math.ceil(maxUsd * NANO_USD_PER_USD) * AI_COST_MULTIPLIER;
316
314
  if (!Number.isSafeInteger(maxCost) || maxCost <= 0) {
317
315
  throw new AiCreditError("Invalid reservation budget.", "AI_PRICING_UNAVAILABLE");
318
316
  }
319
317
  const reservation = {
320
318
  ref,
321
319
  model_id: modelId,
322
- max_cost_nano_eur: maxCost,
320
+ max_cost_nano_usd: maxCost,
323
321
  cost_basis: {
324
322
  rates,
325
- eur_per_usd: pricing.eurPerUsd,
326
- fx_as_of: pricing.fxAsOf,
327
323
  price_as_of: pricing.priceAsOf,
328
324
  surface: attribution?.surface ?? "unknown"
329
325
  }
@@ -361,8 +357,6 @@ function createAiCreditBilling(env) {
361
357
  model_id: modelId,
362
358
  surface: attribution?.surface ?? "unknown",
363
359
  usage,
364
- eur_per_usd: pricing.eurPerUsd,
365
- fx_as_of: pricing.fxAsOf,
366
360
  price_as_of: pricing.priceAsOf,
367
361
  rates: pricing.models[modelId]
368
362
  };
@@ -7575,14 +7569,14 @@ function registerAiWalletTools(server2, ctx) {
7575
7569
  "ai_wallet_auto_topup",
7576
7570
  {
7577
7571
  title: "AI Wallet Auto Top-up Settings",
7578
- description: "Read or change automatic EUR replenishment for the separate AI-credit wallet. This does not charge a card and does not change the eSIM connectivity wallet. Params: enabled (optional boolean), amount_cents (optional integer nominal EUR cents, minimum 1000, maximum 100000). Omitting both reads the current setting. Omitting amount while disabling preserves the saved amount. Sending only an amount changes the amount and keeps the current on/off setting. Reading is open to any organisation member; org admin required to change.",
7572
+ description: "Read or change automatic USD replenishment for the separate AI-credit wallet. This does not charge a card and does not change the eSIM connectivity wallet. Params: enabled (optional boolean), amount_cents (optional integer nominal USD cents, minimum 1000, maximum 100000). Omitting both reads the current setting. Omitting amount while disabling preserves the saved amount. Sending only an amount changes the amount and keeps the current on/off setting. Reading is open to any organisation member; org admin required to change.",
7579
7573
  inputSchema: {
7580
7574
  enabled: z10.boolean().optional(),
7581
7575
  amount_cents: z10.number().int().min(MIN_AI_TOPUP_CENTS).max(MAX_AI_TOPUP_CENTS).optional()
7582
7576
  },
7583
7577
  outputSchema: {
7584
7578
  org_id: z10.string(),
7585
- balance_eur_micros: z10.number().int(),
7579
+ balance_usd_micros: z10.number().int(),
7586
7580
  auto_topup_enabled: z10.boolean(),
7587
7581
  auto_topup_amount_cents: z10.number().int()
7588
7582
  },
@@ -9502,7 +9496,7 @@ async function resolveUserTier2(env, sub) {
9502
9496
  var PRICING_TOOLS = [
9503
9497
  {
9504
9498
  name: "ai_credit_balance",
9505
- description: "Read your organization's AI credit wallet in EUR: balance_eur and available_eur. Pro plan payments fund this wallet and AI usage spends it. No token counts are exposed.",
9499
+ description: "Read your organization's AI credit wallet in USD: balance_usd and available_usd. Pro plan payments fund this wallet and AI usage spends it. No token counts are exposed.",
9506
9500
  scope: "read",
9507
9501
  inputSchema: { type: "object", properties: {}, required: [] },
9508
9502
  handler: async (env, props2) => {
@@ -9512,13 +9506,13 @@ var PRICING_TOOLS = [
9512
9506
  signal: AbortSignal.timeout(5e3)
9513
9507
  });
9514
9508
  if (!response.ok) throw new Error("AI credits unavailable. Sign in to Carrier and select an organization.");
9515
- const { balance_eur: balance_eur2, available_eur: available_eur2 } = (await response.json()).data;
9516
- return { currency: "EUR", balance_eur: balance_eur2, available_eur: available_eur2 };
9509
+ const { balance_usd: balance_usd2, available_usd: available_usd2 } = (await response.json()).data;
9510
+ return { currency: "USD", balance_usd: balance_usd2, available_usd: available_usd2 };
9517
9511
  }
9518
9512
  if (env.CARRIER_AI_CREDITS_ENABLED !== "true") throw new Error("AI credits are not available on this deployment.");
9519
9513
  if (!props2.org_id) throw new Error("Select an organization to read AI credits.");
9520
- const { balance_eur, available_eur } = await aiWalletRequest(env, props2.org_id);
9521
- return { currency: "EUR", balance_eur, available_eur };
9514
+ const { balance_usd, available_usd } = await aiWalletRequest(env, props2.org_id);
9515
+ return { currency: "USD", balance_usd, available_usd };
9522
9516
  }
9523
9517
  },
9524
9518
  // -------------------------------------------------------------------------