@carrierllc/mcp 0.13.79 → 0.13.80
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-C4CICMRO.js";
|
|
95
95
|
import "./chunk-SHKKVIIA.js";
|
|
96
96
|
|
|
97
97
|
// src/index.ts
|
|
@@ -209,6 +209,68 @@ async function assertManagedIccidAccess(baseUrl2, auth, iccid) {
|
|
|
209
209
|
|
|
210
210
|
// ../../packages/carrier-ai/dist/index.js
|
|
211
211
|
import { AwsClient } from "aws4fetch";
|
|
212
|
+
var PRODUCTION_ATLAS_BASE_URL = "https://atlas.carrier.llc";
|
|
213
|
+
var AtlasConfigError = class extends Error {
|
|
214
|
+
code = "ATLAS_NOT_CONFIGURED";
|
|
215
|
+
};
|
|
216
|
+
function clean(value) {
|
|
217
|
+
const trimmed = value?.trim();
|
|
218
|
+
return trimmed ? trimmed.replace(/\/+$/, "") : void 0;
|
|
219
|
+
}
|
|
220
|
+
function canonicalHost(url) {
|
|
221
|
+
return url.hostname.toLowerCase().replace(/\.+$/, "");
|
|
222
|
+
}
|
|
223
|
+
var PRODUCTION_HOST = canonicalHost(new URL(PRODUCTION_ATLAS_BASE_URL));
|
|
224
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "[::1]", "localhost"]);
|
|
225
|
+
function parse(url, environment) {
|
|
226
|
+
let parsed;
|
|
227
|
+
try {
|
|
228
|
+
parsed = new URL(url);
|
|
229
|
+
} catch {
|
|
230
|
+
throw new AtlasConfigError(`ATLAS_BASE_URL is not a valid URL (CARRIER_ENVIRONMENT=${environment}).`);
|
|
231
|
+
}
|
|
232
|
+
if (parsed.protocol !== "https:" && !(parsed.protocol === "http:" && LOOPBACK_HOSTS.has(canonicalHost(parsed)))) {
|
|
233
|
+
throw new AtlasConfigError(`ATLAS_BASE_URL must use https (got ${parsed.protocol}).`);
|
|
234
|
+
}
|
|
235
|
+
if (parsed.username || parsed.password) {
|
|
236
|
+
throw new AtlasConfigError("ATLAS_BASE_URL may not contain credentials.");
|
|
237
|
+
}
|
|
238
|
+
return parsed;
|
|
239
|
+
}
|
|
240
|
+
function resolveInternalAtlasBase(env) {
|
|
241
|
+
const configured = clean(env.ATLAS_BASE_URL) ?? clean(env.ATLAS_API_URL);
|
|
242
|
+
const environment = env.CARRIER_ENVIRONMENT?.trim().toLowerCase();
|
|
243
|
+
if (!environment || environment === "production") {
|
|
244
|
+
if (configured) parse(configured, environment || "production");
|
|
245
|
+
return configured ?? PRODUCTION_ATLAS_BASE_URL;
|
|
246
|
+
}
|
|
247
|
+
if (!configured) {
|
|
248
|
+
throw new AtlasConfigError(
|
|
249
|
+
`ATLAS_BASE_URL is required when CARRIER_ENVIRONMENT=${environment}; refusing to fall back to production Atlas.`
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
if (canonicalHost(parse(configured, environment)) === PRODUCTION_HOST) {
|
|
253
|
+
throw new AtlasConfigError(
|
|
254
|
+
`CARRIER_ENVIRONMENT=${environment} may not call production Atlas (${configured}).`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
return configured;
|
|
258
|
+
}
|
|
259
|
+
var AtlasRedirectError = class extends Error {
|
|
260
|
+
constructor(status) {
|
|
261
|
+
super(`Atlas answered with a redirect (HTTP ${status}); internal calls never follow redirects.`);
|
|
262
|
+
this.status = status;
|
|
263
|
+
}
|
|
264
|
+
status;
|
|
265
|
+
code = "ATLAS_REDIRECT_REFUSED";
|
|
266
|
+
};
|
|
267
|
+
async function internalAtlasFetch(url, init = {}) {
|
|
268
|
+
const response = await fetch(url, { ...init, redirect: "manual" });
|
|
269
|
+
if (response.type === "opaqueredirect" || response.status >= 300 && response.status < 400) {
|
|
270
|
+
throw new AtlasRedirectError(response.status);
|
|
271
|
+
}
|
|
272
|
+
return response;
|
|
273
|
+
}
|
|
212
274
|
var NANO_USD_PER_USD = 1e9;
|
|
213
275
|
var AI_COST_MULTIPLIER = 4;
|
|
214
276
|
var AI_PRICE_MAX_AGE_DAYS = 30;
|
|
@@ -273,8 +335,14 @@ async function aiWalletRequest(env, orgId, suffix = "", body2) {
|
|
|
273
335
|
if (!orgId || !env.CARRIER_INTERNAL_API_KEY || !env.ATLAS_BASE_URL) {
|
|
274
336
|
throw new AiCreditError("AI credit wallet is not configured.", "AI_WALLET_UNAVAILABLE");
|
|
275
337
|
}
|
|
276
|
-
|
|
277
|
-
|
|
338
|
+
let base;
|
|
339
|
+
try {
|
|
340
|
+
base = resolveInternalAtlasBase({ ATLAS_BASE_URL: env.ATLAS_BASE_URL, CARRIER_ENVIRONMENT: env.CARRIER_ENVIRONMENT });
|
|
341
|
+
} catch {
|
|
342
|
+
throw new AiCreditError("AI credit wallet is not configured.", "AI_WALLET_UNAVAILABLE");
|
|
343
|
+
}
|
|
344
|
+
const response = await internalAtlasFetch(
|
|
345
|
+
`${base}/internal/ai-wallet/${encodeURIComponent(orgId)}${suffix}`,
|
|
278
346
|
{
|
|
279
347
|
method: body2 === void 0 ? "GET" : "POST",
|
|
280
348
|
headers: {
|
|
@@ -408,7 +476,7 @@ var MAX_ENTRIES = 16;
|
|
|
408
476
|
var MAX_KEY_LEN = 256;
|
|
409
477
|
var MAX_VALUE_LEN = 256;
|
|
410
478
|
var ALLOWED = /[^a-zA-Z0-9\s:_@$#=/+,\-.]/g;
|
|
411
|
-
function
|
|
479
|
+
function clean2(value, max) {
|
|
412
480
|
return value.replace(ALLOWED, "").slice(0, max);
|
|
413
481
|
}
|
|
414
482
|
var REQUEST_METADATA_HEADER = "X-Amzn-Bedrock-Request-Metadata";
|
|
@@ -423,8 +491,8 @@ function requestMetadata(attr2) {
|
|
|
423
491
|
];
|
|
424
492
|
for (const [k, v] of pairs) {
|
|
425
493
|
if (v === void 0 || v === "") continue;
|
|
426
|
-
const key =
|
|
427
|
-
const value =
|
|
494
|
+
const key = clean2(k, MAX_KEY_LEN);
|
|
495
|
+
const value = clean2(v, MAX_VALUE_LEN);
|
|
428
496
|
if (key && value && Object.keys(out).length < MAX_ENTRIES) out[key] = value;
|
|
429
497
|
}
|
|
430
498
|
return Object.keys(out).length > 0 ? out : null;
|
|
@@ -7028,7 +7096,6 @@ function installAnnotationDefaults(server2, scopes) {
|
|
|
7028
7096
|
var UNKNOWN_TOOL_SCOPE = "admin";
|
|
7029
7097
|
|
|
7030
7098
|
// src/wallet-client.ts
|
|
7031
|
-
var DEFAULT_ATLAS_BASE_URL = "https://atlas.carrier.llc";
|
|
7032
7099
|
var WalletClientError = class extends Error {
|
|
7033
7100
|
status;
|
|
7034
7101
|
constructor(message, status) {
|
|
@@ -7045,10 +7112,12 @@ function resolveConfig(env) {
|
|
|
7045
7112
|
0
|
|
7046
7113
|
);
|
|
7047
7114
|
}
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
)
|
|
7115
|
+
let baseUrl2;
|
|
7116
|
+
try {
|
|
7117
|
+
baseUrl2 = resolveInternalAtlasBase(env);
|
|
7118
|
+
} catch (err9) {
|
|
7119
|
+
throw new WalletClientError(err9.message, 0);
|
|
7120
|
+
}
|
|
7052
7121
|
return { baseUrl: baseUrl2, key };
|
|
7053
7122
|
}
|
|
7054
7123
|
async function atlasFetch(env, path, init) {
|
|
@@ -7061,7 +7130,7 @@ async function atlasFetch(env, path, init) {
|
|
|
7061
7130
|
}
|
|
7062
7131
|
let res;
|
|
7063
7132
|
try {
|
|
7064
|
-
res = await
|
|
7133
|
+
res = await internalAtlasFetch(`${baseUrl2}${path}`, { method: init.method, headers, body: body2 });
|
|
7065
7134
|
} catch (e) {
|
|
7066
7135
|
throw new WalletClientError(
|
|
7067
7136
|
`ATLAS wallet request failed: ${e instanceof Error ? e.message : "network error"}`,
|
|
@@ -7549,8 +7618,8 @@ var AI_WALLET_TOOL_SCOPES = {
|
|
|
7549
7618
|
ai_wallet_auto_topup: "write"
|
|
7550
7619
|
};
|
|
7551
7620
|
async function aiWallet(env, orgId, method, body2) {
|
|
7552
|
-
const response = await
|
|
7553
|
-
`${env
|
|
7621
|
+
const response = await internalAtlasFetch(
|
|
7622
|
+
`${resolveInternalAtlasBase(env)}/internal/ai-topup/${encodeURIComponent(orgId)}`,
|
|
7554
7623
|
{
|
|
7555
7624
|
method,
|
|
7556
7625
|
headers: {
|
|
@@ -13795,6 +13864,7 @@ var stdioEnv = {
|
|
|
13795
13864
|
// registered (catalog parity with the Worker) and return an explicit
|
|
13796
13865
|
// configuration error instead of silently disappearing from tools/list.
|
|
13797
13866
|
ATLAS_BASE_URL: process.env.ATLAS_BASE_URL,
|
|
13867
|
+
CARRIER_ENVIRONMENT: process.env.CARRIER_ENVIRONMENT,
|
|
13798
13868
|
CARRIER_INTERNAL_API_KEY: process.env.CARRIER_INTERNAL_API_KEY,
|
|
13799
13869
|
WALLET_CHECKOUT_SUCCESS_URL: process.env.WALLET_CHECKOUT_SUCCESS_URL,
|
|
13800
13870
|
WALLET_CHECKOUT_CANCEL_URL: process.env.WALLET_CHECKOUT_CANCEL_URL,
|