@carrierllc/mcp 0.13.77 → 0.13.78
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/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
verifyStorefront,
|
|
92
92
|
withOcsListSummary,
|
|
93
93
|
withTemplateResellerId
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-G7BQL3FL.js";
|
|
95
95
|
import "./chunk-SHKKVIIA.js";
|
|
96
96
|
|
|
97
97
|
// src/index.ts
|
|
@@ -211,6 +211,8 @@ async function assertManagedIccidAccess(baseUrl2, auth, iccid) {
|
|
|
211
211
|
import { AwsClient } from "aws4fetch";
|
|
212
212
|
var NANO_EUR_PER_EUR = 1e9;
|
|
213
213
|
var AI_COST_MULTIPLIER = 4;
|
|
214
|
+
var AI_PRICE_MAX_AGE_DAYS = 30;
|
|
215
|
+
var DAY_MS = 864e5;
|
|
214
216
|
var AiCreditError = class extends Error {
|
|
215
217
|
constructor(message, code) {
|
|
216
218
|
super(message);
|
|
@@ -222,7 +224,19 @@ var AiCreditError = class extends Error {
|
|
|
222
224
|
function positive(value) {
|
|
223
225
|
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
224
226
|
}
|
|
225
|
-
function
|
|
227
|
+
function validRate(rate) {
|
|
228
|
+
return typeof rate === "number" && Number.isFinite(rate) && rate >= 0;
|
|
229
|
+
}
|
|
230
|
+
function validLongContext(rates) {
|
|
231
|
+
const tier = rates.longContext;
|
|
232
|
+
if (tier === void 0) return true;
|
|
233
|
+
return typeof tier === "object" && tier !== null && Number.isSafeInteger(tier.thresholdTokens) && tier.thresholdTokens > 0 && tier.thresholdTokens < rates.maxInputTokens && [tier.inputPerMTok, tier.outputPerMTok, tier.cacheReadPerMTok, tier.cacheWritePerMTok].every(validRate) && positive(tier.inputPerMTok) && positive(tier.outputPerMTok);
|
|
234
|
+
}
|
|
235
|
+
function aiRatesForPrompt(rates, promptTokens) {
|
|
236
|
+
const tier = rates.longContext;
|
|
237
|
+
return tier && promptTokens > tier.thresholdTokens ? tier : rates;
|
|
238
|
+
}
|
|
239
|
+
function readAiCreditPricing(raw, modelId, now = Date.now()) {
|
|
226
240
|
let value;
|
|
227
241
|
try {
|
|
228
242
|
value = JSON.parse(raw ?? "");
|
|
@@ -231,9 +245,15 @@ function readAiCreditPricing(raw, modelId) {
|
|
|
231
245
|
}
|
|
232
246
|
const rates = value?.models?.[modelId];
|
|
233
247
|
const validDate = (date) => typeof date === "string" && Number.isFinite(Date.parse(date));
|
|
234
|
-
if (!positive(value?.eurPerUsd) || !validDate(value.fxAsOf) || !validDate(value.priceAsOf) || !rates || ![rates.inputPerMTok, rates.outputPerMTok, rates.cacheReadPerMTok, rates.cacheWritePerMTok].every(
|
|
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)) {
|
|
235
249
|
throw new AiCreditError("AI credit pricing is not configured for this model.", "AI_PRICING_UNAVAILABLE");
|
|
236
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
|
+
}
|
|
256
|
+
}
|
|
237
257
|
return value;
|
|
238
258
|
}
|
|
239
259
|
function aiSupplierCost(usage, pricing, modelId) {
|
|
@@ -241,8 +261,9 @@ function aiSupplierCost(usage, pricing, modelId) {
|
|
|
241
261
|
if (!counts.every((count) => Number.isSafeInteger(count) && count >= 0)) {
|
|
242
262
|
throw new AiCreditError("Supplier usage is invalid.", "AI_USAGE_INVALID");
|
|
243
263
|
}
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
264
|
+
const model = pricing.models[modelId];
|
|
265
|
+
if (!model) throw new AiCreditError("Unpriced model.", "AI_PRICING_UNAVAILABLE");
|
|
266
|
+
const rates = aiRatesForPrompt(model, usage.inputTokens + usage.cacheReadTokens + usage.cacheWriteTokens);
|
|
246
267
|
const usd = (usage.inputTokens * rates.inputPerMTok + usage.outputTokens * rates.outputPerMTok + usage.cacheReadTokens * rates.cacheReadPerMTok + usage.cacheWriteTokens * rates.cacheWritePerMTok) / 1e6;
|
|
247
268
|
const nanos2 = Math.round(usd * pricing.eurPerUsd * NANO_EUR_PER_EUR);
|
|
248
269
|
if (!Number.isSafeInteger(nanos2 * AI_COST_MULTIPLIER) || nanos2 < 0) {
|
|
@@ -286,7 +307,12 @@ function createAiCreditBilling(env) {
|
|
|
286
307
|
}
|
|
287
308
|
const ref = `ai:${crypto.randomUUID()}`;
|
|
288
309
|
const rates = pricing.models[modelId];
|
|
289
|
-
const
|
|
310
|
+
const tiers = [
|
|
311
|
+
{ prompt: Math.min(rates.maxInputTokens, rates.longContext?.thresholdTokens ?? rates.maxInputTokens), rates },
|
|
312
|
+
...rates.longContext ? [{ prompt: rates.maxInputTokens, rates: rates.longContext }] : []
|
|
313
|
+
];
|
|
314
|
+
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;
|
|
290
316
|
if (!Number.isSafeInteger(maxCost) || maxCost <= 0) {
|
|
291
317
|
throw new AiCreditError("Invalid reservation budget.", "AI_PRICING_UNAVAILABLE");
|
|
292
318
|
}
|
|
@@ -432,18 +458,27 @@ function extractUsage(payload) {
|
|
|
432
458
|
};
|
|
433
459
|
}
|
|
434
460
|
var HAIKU_RATES = {
|
|
435
|
-
inputPerMTok: 1,
|
|
436
|
-
outputPerMTok: 5,
|
|
437
|
-
cacheReadPerMTok: 0.
|
|
438
|
-
cacheWritePerMTok:
|
|
439
|
-
|
|
461
|
+
inputPerMTok: 0.1,
|
|
462
|
+
outputPerMTok: 0.5,
|
|
463
|
+
cacheReadPerMTok: 0.01,
|
|
464
|
+
cacheWritePerMTok: 0.125,
|
|
465
|
+
longContext: {
|
|
466
|
+
thresholdTokens: 1e5,
|
|
467
|
+
inputPerMTok: 0.5,
|
|
468
|
+
outputPerMTok: 2.5,
|
|
469
|
+
cacheReadPerMTok: 0.05,
|
|
470
|
+
cacheWritePerMTok: 0.625
|
|
471
|
+
},
|
|
472
|
+
asOf: "2026-11-09"
|
|
440
473
|
};
|
|
441
|
-
function estimateCostUsd(u,
|
|
474
|
+
function estimateCostUsd(u, card = HAIKU_RATES) {
|
|
475
|
+
const prompt = u.inputTokens + u.cacheReadTokens + u.cacheWriteTokens;
|
|
476
|
+
const rates = card.longContext && prompt > card.longContext.thresholdTokens ? card.longContext : card;
|
|
442
477
|
const perTok = (mtok) => mtok / 1e6;
|
|
443
478
|
return u.inputTokens * perTok(rates.inputPerMTok) + u.outputTokens * perTok(rates.outputPerMTok) + u.cacheReadTokens * perTok(rates.cacheReadPerMTok) + u.cacheWriteTokens * perTok(rates.cacheWritePerMTok);
|
|
444
479
|
}
|
|
445
480
|
var DEFAULT_BEDROCK_REGION = "us-east-1";
|
|
446
|
-
var DEFAULT_MODEL_ID = "
|
|
481
|
+
var DEFAULT_MODEL_ID = "global.anthropic.claude-haiku-5-5";
|
|
447
482
|
var RETIRED_HAIKU_MARKERS = [
|
|
448
483
|
"claude-3-haiku",
|
|
449
484
|
"claude-3-5-haiku",
|