@carrierllc/mcp 0.13.80 → 0.13.82

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-C4CICMRO.js";
94
+ } from "./chunk-FKHHZ7V2.js";
95
95
  import "./chunk-SHKKVIIA.js";
96
96
 
97
97
  // src/index.ts
@@ -1469,22 +1469,22 @@ function boundZonesResult(raw, opts = {}) {
1469
1469
  const { verbose = false, resellerId } = opts;
1470
1470
  const maxZones = opts.maxZones ?? ZONES_MAX_ZONES;
1471
1471
  const maxOperators = opts.maxOperators ?? (verbose ? ZONES_VERBOSE_MAX_OPERATORS : ZONES_MAX_OPERATORS);
1472
- const totalOperators = all.reduce((n, z30) => n + (z30.operators?.length ?? 0), 0);
1472
+ const totalOperators = all.reduce((n, z31) => n + (z31.operators?.length ?? 0), 0);
1473
1473
  const keptZones = all.slice(0, maxZones);
1474
1474
  let budget = maxOperators;
1475
1475
  let returnedOperators = 0;
1476
- const zones = keptZones.map((z30) => {
1477
- const ops = z30.operators ?? [];
1476
+ const zones = keptZones.map((z31) => {
1477
+ const ops = z31.operators ?? [];
1478
1478
  const take = Math.max(0, Math.min(ops.length, budget));
1479
1479
  budget -= take;
1480
1480
  returnedOperators += take;
1481
1481
  const sliced = ops.slice(0, take);
1482
1482
  if (verbose) {
1483
- return { ...z30, operators: sliced, operatorCount: ops.length };
1483
+ return { ...z31, operators: sliced, operatorCount: ops.length };
1484
1484
  }
1485
1485
  return {
1486
- zoneId: z30.zoneId,
1487
- zoneName: z30.zoneName,
1486
+ zoneId: z31.zoneId,
1487
+ zoneName: z31.zoneName,
1488
1488
  operatorCount: ops.length,
1489
1489
  operators: sliced.map((o) => ({
1490
1490
  net: o.networkId,
@@ -5550,7 +5550,7 @@ function registerAllBacklogTools(server2, ctx) {
5550
5550
  }
5551
5551
 
5552
5552
  // src/tools-carrier-ask.ts
5553
- import { z as z18 } from "zod";
5553
+ import { z as z19 } from "zod";
5554
5554
 
5555
5555
  // src/tools-ui-agent.ts
5556
5556
  import { z as z5 } from "zod";
@@ -7153,7 +7153,8 @@ async function walletTopup(env, orgId, args) {
7153
7153
  {
7154
7154
  method: "POST",
7155
7155
  body: {
7156
- eur_cents: args.eurCents,
7156
+ amount_cents: args.amountCents,
7157
+ currency: args.currency,
7157
7158
  ref: args.ref,
7158
7159
  ...args.type ? { type: args.type } : {}
7159
7160
  }
@@ -7203,23 +7204,24 @@ function denyUnlessScoped(props2, toolName, scopes) {
7203
7204
  }
7204
7205
 
7205
7206
  // src/wallet-tools.ts
7207
+ var PACK_CURRENCY = "usd";
7206
7208
  var PACKS = [
7207
- { id: "pack_25", eurCents: 2500, bonusPct: 0 },
7208
- { id: "pack_50", eurCents: 5e3, bonusPct: 0 },
7209
- { id: "pack_100", eurCents: 1e4, bonusPct: 0 },
7210
- { id: "pack_500", eurCents: 5e4, bonusPct: 0 },
7211
- { id: "pack_1000", eurCents: 1e5, bonusPct: 3 },
7212
- { id: "pack_2500", eurCents: 25e4, bonusPct: 6 },
7213
- { id: "pack_5000", eurCents: 5e5, bonusPct: 10 }
7209
+ { id: "pack_25", amountCents: 2500, bonusPct: 0 },
7210
+ { id: "pack_50", amountCents: 5e3, bonusPct: 0 },
7211
+ { id: "pack_100", amountCents: 1e4, bonusPct: 0 },
7212
+ { id: "pack_500", amountCents: 5e4, bonusPct: 0 },
7213
+ { id: "pack_1000", amountCents: 1e5, bonusPct: 3 },
7214
+ { id: "pack_2500", amountCents: 25e4, bonusPct: 6 },
7215
+ { id: "pack_5000", amountCents: 5e5, bonusPct: 10 }
7214
7216
  ];
7215
7217
  function bonusCentsFor(pack) {
7216
- return Math.floor(pack.eurCents * pack.bonusPct / 100);
7218
+ return Math.floor(pack.amountCents * pack.bonusPct / 100);
7217
7219
  }
7218
7220
  function resolvePack(idOrCents) {
7219
7221
  if (typeof idOrCents === "number") {
7220
- return PACKS.find((p) => p.eurCents === idOrCents);
7222
+ return PACKS.find((p) => p.amountCents === idOrCents);
7221
7223
  }
7222
- return PACKS.find((p) => p.id === idOrCents) ?? PACKS.find((p) => String(p.eurCents) === idOrCents);
7224
+ return PACKS.find((p) => p.id === idOrCents) ?? PACKS.find((p) => String(p.amountCents) === idOrCents);
7223
7225
  }
7224
7226
  var STRIPE_API = "https://api.stripe.com";
7225
7227
  async function stripePostForm(stripeKey, path, params, opts) {
@@ -7238,6 +7240,36 @@ async function stripePostForm(stripeKey, path, params, opts) {
7238
7240
  const data = await res.json();
7239
7241
  return { ok: res.ok, status: res.status, data };
7240
7242
  }
7243
+ var walletCustomerKey = (sub) => `stripe_wallet_customer_id:${sub}`;
7244
+ var walletPmKey = (sub) => `stripe_wallet_pm_id:${sub}`;
7245
+ function isCurrencyLockError(data) {
7246
+ const err9 = data?.error;
7247
+ if (!err9) return false;
7248
+ const message = typeof err9.message === "string" ? err9.message : "";
7249
+ const code = typeof err9.code === "string" ? err9.code : "";
7250
+ return /currenc/i.test(code) || /cannot combine currencies|currency.{0,60}customer|customer.{0,60}currency/i.test(message);
7251
+ }
7252
+ async function ensureWalletCustomer(env, stripeKey, sub, orgId) {
7253
+ if (!env.CARRIER_USERS) throw new Error("Wallet customer needs the hosted KV binding");
7254
+ const known = await env.CARRIER_USERS.get(walletCustomerKey(sub)).catch(() => null);
7255
+ if (known) return known;
7256
+ const res = await stripePostForm(
7257
+ stripeKey,
7258
+ "/v1/customers",
7259
+ new URLSearchParams({
7260
+ description: "Carrier prepaid wallet (USD)",
7261
+ "metadata[kind]": "wallet_usd_customer",
7262
+ "metadata[org_id]": orgId,
7263
+ "metadata[billing_sub]": sub
7264
+ }),
7265
+ { idempotencyKey: `wallet-usd-customer:${sub}` }
7266
+ );
7267
+ if (!res.ok || !res.data.id) {
7268
+ throw new Error(`Stripe wallet customer create failed: ${JSON.stringify(res.data)}`);
7269
+ }
7270
+ await env.CARRIER_USERS.put(walletCustomerKey(sub), res.data.id);
7271
+ return res.data.id;
7272
+ }
7241
7273
  var DEFAULT_SUCCESS_URL = "https://app.carrier.llc/billing?topup=success";
7242
7274
  var DEFAULT_CANCEL_URL = "https://app.carrier.llc/billing?topup=cancelled";
7243
7275
  async function createTopupCheckout(env, args) {
@@ -7246,28 +7278,32 @@ async function createTopupCheckout(env, args) {
7246
7278
  const bonusCents = bonusCentsFor(args.pack);
7247
7279
  const successUrl = args.successUrl ?? env.WALLET_CHECKOUT_SUCCESS_URL ?? DEFAULT_SUCCESS_URL;
7248
7280
  const cancelUrl = args.cancelUrl ?? env.WALLET_CHECKOUT_CANCEL_URL ?? DEFAULT_CANCEL_URL;
7249
- const bonusLabel = bonusCents > 0 ? ` (+\u20AC${(bonusCents / 100).toFixed(2)} bonus)` : "";
7281
+ const bonusLabel = bonusCents > 0 ? ` (+$${(bonusCents / 100).toFixed(2)} bonus)` : "";
7250
7282
  if (!env.CARRIER_USERS) {
7251
7283
  throw new Error(
7252
7284
  "Wallet top-up is not available in local stdio mode: the prepaid wallet is credited by the hosted Carrier service after payment, and this process cannot reach the customer record that crediting depends on. Creating the session here would bill the card against a duplicate Stripe customer and the wallet would never be credited. Top up from the console at https://app.carrier.llc/billing, or connect to the hosted MCP at https://mcp.carrier.llc/mcp, which has the binding. `wallet_balance` still works here if ATLAS_BASE_URL and CARRIER_INTERNAL_API_KEY are set."
7253
7285
  );
7254
7286
  }
7255
7287
  const billingSub = await resolveBillingSub(env, args.orgId);
7256
- const existingCustomer = await env.CARRIER_USERS.get(`stripe_customer_id:${billingSub}`).catch(() => null);
7288
+ const walletCustomer = await env.CARRIER_USERS.get(walletCustomerKey(billingSub)).catch(
7289
+ () => null
7290
+ );
7291
+ const existingCustomer = walletCustomer ?? await env.CARRIER_USERS.get(`stripe_customer_id:${billingSub}`).catch(() => null);
7257
7292
  const params = new URLSearchParams({
7258
7293
  mode: "payment",
7259
7294
  success_url: successUrl,
7260
7295
  cancel_url: cancelUrl,
7261
7296
  "line_items[0][quantity]": "1",
7262
- "line_items[0][price_data][currency]": "eur",
7263
- "line_items[0][price_data][unit_amount]": String(args.pack.eurCents),
7264
- "line_items[0][price_data][product_data][name]": `Carrier wallet top-up \u2014 \u20AC${(args.pack.eurCents / 100).toFixed(2)}${bonusLabel}`,
7297
+ "line_items[0][price_data][currency]": PACK_CURRENCY,
7298
+ "line_items[0][price_data][unit_amount]": String(args.pack.amountCents),
7299
+ "line_items[0][price_data][product_data][name]": `Carrier wallet top-up \u2014 $${(args.pack.amountCents / 100).toFixed(2)}${bonusLabel}`,
7265
7300
  client_reference_id: args.orgId,
7266
7301
  "metadata[kind]": "wallet_topup",
7267
7302
  "metadata[org_id]": args.orgId,
7268
7303
  "metadata[pack_id]": args.pack.id,
7269
- "metadata[pack_eur_cents]": String(args.pack.eurCents),
7270
- "metadata[bonus_eur_cents]": String(bonusCents),
7304
+ "metadata[currency]": PACK_CURRENCY,
7305
+ "metadata[pack_cents]": String(args.pack.amountCents),
7306
+ "metadata[bonus_cents]": String(bonusCents),
7271
7307
  // Save the payment method for reuse so subsequent off-session auto-top-up
7272
7308
  // charges (runAutoTopup) can charge it without the customer present.
7273
7309
  "payment_intent_data[setup_future_usage]": "off_session",
@@ -7275,19 +7311,29 @@ async function createTopupCheckout(env, args) {
7275
7311
  // payment_intent.succeeded webhook can also credit idempotently.
7276
7312
  "payment_intent_data[metadata][kind]": "wallet_topup",
7277
7313
  "payment_intent_data[metadata][org_id]": args.orgId,
7278
- "payment_intent_data[metadata][pack_eur_cents]": String(args.pack.eurCents),
7279
- "payment_intent_data[metadata][bonus_eur_cents]": String(bonusCents)
7314
+ "payment_intent_data[metadata][currency]": PACK_CURRENCY,
7315
+ "payment_intent_data[metadata][pack_cents]": String(args.pack.amountCents),
7316
+ "payment_intent_data[metadata][bonus_cents]": String(bonusCents)
7280
7317
  });
7281
7318
  if (existingCustomer) {
7282
7319
  params.set("customer", existingCustomer);
7283
7320
  } else {
7284
7321
  params.set("customer_creation", "always");
7285
7322
  }
7286
- const result3 = await stripePostForm(
7323
+ let result3 = await stripePostForm(
7287
7324
  stripeKey,
7288
7325
  "/v1/checkout/sessions",
7289
7326
  params
7290
7327
  );
7328
+ if (!result3.ok && existingCustomer && !walletCustomer && isCurrencyLockError(result3.data)) {
7329
+ const usdCustomer = await ensureWalletCustomer(env, stripeKey, billingSub, args.orgId);
7330
+ params.set("customer", usdCustomer);
7331
+ result3 = await stripePostForm(
7332
+ stripeKey,
7333
+ "/v1/checkout/sessions",
7334
+ params
7335
+ );
7336
+ }
7291
7337
  if (!result3.ok) {
7292
7338
  throw new Error(`Stripe checkout session create failed: ${JSON.stringify(result3.data)}`);
7293
7339
  }
@@ -7318,26 +7364,30 @@ async function runAutoTopup(env, args) {
7318
7364
  if (!env.CARRIER_USERS) {
7319
7365
  return { charged: false, creditedCents: 0, reason: "no_payment_method" };
7320
7366
  }
7321
- const customerId = await env.CARRIER_USERS.get(`stripe_customer_id:${args.sub}`).catch(
7367
+ const walletCustomerId = await env.CARRIER_USERS.get(walletCustomerKey(args.sub)).catch(
7322
7368
  () => null
7323
7369
  );
7324
- const pmId = await env.CARRIER_USERS.get(`stripe_pm_id:${args.sub}`).catch(() => null);
7370
+ const walletPmId = walletCustomerId ? await env.CARRIER_USERS.get(walletPmKey(args.sub)).catch(() => null) : null;
7371
+ const useWallet = Boolean(walletCustomerId && walletPmId);
7372
+ const customerId = useWallet ? walletCustomerId : await env.CARRIER_USERS.get(`stripe_customer_id:${args.sub}`).catch(() => null);
7373
+ const pmId = useWallet ? walletPmId : await env.CARRIER_USERS.get(`stripe_pm_id:${args.sub}`).catch(() => null);
7325
7374
  if (!customerId || !pmId) {
7326
7375
  return { charged: false, creditedCents: 0, reason: "no_payment_method" };
7327
7376
  }
7328
7377
  const bonusCents = bonusCentsFor(pack);
7329
7378
  const body2 = new URLSearchParams({
7330
- amount: String(pack.eurCents),
7331
- currency: "eur",
7379
+ amount: String(pack.amountCents),
7380
+ currency: PACK_CURRENCY,
7332
7381
  customer: customerId,
7333
7382
  payment_method: pmId,
7334
7383
  confirm: "true",
7335
7384
  off_session: "true",
7336
- description: `Carrier wallet auto-top-up \u2014 \u20AC${(pack.eurCents / 100).toFixed(2)}`,
7385
+ description: `Carrier wallet auto-top-up \u2014 $${(pack.amountCents / 100).toFixed(2)}`,
7337
7386
  "metadata[kind]": "wallet_topup",
7338
7387
  "metadata[org_id]": args.orgId,
7339
- "metadata[pack_eur_cents]": String(pack.eurCents),
7340
- "metadata[bonus_eur_cents]": String(bonusCents),
7388
+ "metadata[currency]": PACK_CURRENCY,
7389
+ "metadata[pack_cents]": String(pack.amountCents),
7390
+ "metadata[bonus_cents]": String(bonusCents),
7341
7391
  "metadata[auto_topup]": "true"
7342
7392
  });
7343
7393
  const resp = await stripePostForm(
@@ -7360,10 +7410,11 @@ async function runAutoTopup(env, args) {
7360
7410
  paymentIntentId: resp.data.id
7361
7411
  };
7362
7412
  }
7363
- const creditedCents = pack.eurCents + bonusCents;
7413
+ const creditedCents = pack.amountCents + bonusCents;
7364
7414
  try {
7365
7415
  const topup = await walletTopup(env, args.orgId, {
7366
- eurCents: creditedCents,
7416
+ amountCents: creditedCents,
7417
+ currency: PACK_CURRENCY,
7367
7418
  ref: resp.data.id,
7368
7419
  type: "auto_topup"
7369
7420
  });
@@ -7404,7 +7455,7 @@ function registerWalletTools(server2, ctx) {
7404
7455
  "wallet_balance",
7405
7456
  {
7406
7457
  title: "Wallet Balance",
7407
- description: "Read the caller organisation's Carrier prepaid wallet: current balance and auto-top-up settings. The wallet is what Carrier bills your own eSIM spend against \u2014 it is not an OCS balance and not your MCP plan credits. Params: none (the organisation is taken from the session). Returns: { org_id, balance_eur_cents, auto_topup_enabled, auto_topup_threshold_cents, auto_topup_pack_cents } \u2014 all amounts in EUR cents, not euros. Do NOT use this for a reseller account balance in OCS \u2014 use `get_reseller_info` or `list_reseller_accounts`. Do NOT use this for a subscriber's OCS balance \u2014 use `get_subscriber`. Do NOT use this for MCP plan credits \u2014 use `credit_balance`. Do NOT use this for money held at Stripe \u2014 use `stripe_connect_balance`.",
7458
+ description: "Read the caller organisation's Carrier prepaid wallet: current balance and auto-top-up settings. The wallet is what Carrier bills your own eSIM spend against \u2014 it is not an OCS balance and not your MCP plan credits. Params: none (the organisation is taken from the session). Returns: { org_id, balance_cents, currency, balance_usd_cents, balance_eur_cents, auto_topup_enabled, auto_topup_threshold_cents, auto_topup_pack_cents } \u2014 all amounts in cents, not dollars. `balance_cents` is the spendable total; `balance_eur_cents` is credit bought in EUR before the USD move, spent first, never topped up. Do NOT use this for a reseller account balance in OCS \u2014 use `get_reseller_info` or `list_reseller_accounts`. Do NOT use this for a subscriber's OCS balance \u2014 use `get_subscriber`. Do NOT use this for MCP plan credits \u2014 use `credit_balance`. Do NOT use this for money held at Stripe \u2014 use `stripe_connect_balance`.",
7408
7459
  inputSchema: {},
7409
7460
  // Derived from the object literal this handler builds below, not from the
7410
7461
  // description. All five keys are always present on the success path, so
@@ -7416,13 +7467,16 @@ function registerWalletTools(server2, ctx) {
7416
7467
  // state a new operator is in, into an output validation error.
7417
7468
  outputSchema: {
7418
7469
  org_id: z9.string().describe("Carrier organisation the wallet belongs to"),
7419
- balance_eur_cents: z9.number().int().describe("Current balance in EUR cents"),
7470
+ balance_cents: z9.number().int().describe("Spendable balance in cents: USD plus any legacy EUR credit"),
7471
+ currency: z9.literal("usd").describe("Currency new top-ups are credited in"),
7472
+ balance_usd_cents: z9.number().int().describe("USD balance in cents"),
7473
+ balance_eur_cents: z9.number().int().describe("Legacy EUR balance in cents. Spent before USD; no new EUR is credited."),
7420
7474
  auto_topup_enabled: z9.boolean(),
7421
7475
  auto_topup_threshold_cents: z9.number().int().nullable().describe(
7422
- "Balance at or below which an auto top-up fires, EUR cents. Null when auto-top-up is unconfigured."
7476
+ "Spendable balance below which an auto top-up fires, USD cents. Null when auto-top-up is unconfigured."
7423
7477
  ),
7424
7478
  auto_topup_pack_cents: z9.number().int().nullable().describe(
7425
- "Amount an auto top-up charges, EUR cents. Null when auto-top-up is unconfigured."
7479
+ "Amount an auto top-up charges, USD cents. Null when auto-top-up is unconfigured."
7426
7480
  )
7427
7481
  },
7428
7482
  annotations: annotationsFor("wallet_balance", "read")
@@ -7445,6 +7499,9 @@ function registerWalletTools(server2, ctx) {
7445
7499
  });
7446
7500
  return okStructured({
7447
7501
  org_id: orgId,
7502
+ balance_cents: wallet.balance_cents,
7503
+ currency: wallet.currency,
7504
+ balance_usd_cents: wallet.balance_usd_cents,
7448
7505
  balance_eur_cents: wallet.balance_eur_cents,
7449
7506
  auto_topup_enabled: wallet.auto_topup_enabled,
7450
7507
  auto_topup_threshold_cents: wallet.auto_topup_threshold_cents,
@@ -7461,10 +7518,10 @@ function registerWalletTools(server2, ctx) {
7461
7518
  "wallet_topup_checkout",
7462
7519
  {
7463
7520
  title: "Wallet Top-up Checkout",
7464
- description: "Create a Stripe Checkout link so a human can top up the Carrier prepaid wallet by card. This tool charges nothing itself: it returns a hosted URL, and the wallet is credited (pack amount + bonus) only after someone completes the payment in a browser. Params: `pack` (optional \u2014 pack id `pack_25`/`pack_50`/`pack_100`/`pack_500`/`pack_1000`/`pack_2500`/`pack_5000`, or an exact EUR-cents amount matching a catalog pack; omit to list the packs and their bonuses without creating a session). Returns: { pack_id, pack_eur_cents, bonus_eur_cents, checkout_session_id, checkout_url } \u2014 amounts in EUR cents. Do NOT use this when the wallet must be funded now with no human in the loop \u2014 use `wallet_auto_topup`, which charges the saved card immediately. Do NOT use this to move money in OCS \u2014 `modify_account_balance` and `modify_subscriber_balance` are unrelated ledgers.",
7521
+ description: "Create a Stripe Checkout link so a human can top up the Carrier prepaid wallet by card. This tool charges nothing itself: it returns a hosted URL, and the wallet is credited (pack amount + bonus) only after someone completes the payment in a browser. Params: `pack` (optional \u2014 pack id `pack_25`/`pack_50`/`pack_100`/`pack_500`/`pack_1000`/`pack_2500`/`pack_5000`, or an exact USD-cents amount matching a catalog pack; omit to list the packs and their bonuses without creating a session). Returns: { pack_id, pack_cents, bonus_cents, currency, checkout_session_id, checkout_url } \u2014 amounts in USD cents. Do NOT use this when the wallet must be funded now with no human in the loop \u2014 use `wallet_auto_topup`, which charges the saved card immediately. Do NOT use this to move money in OCS \u2014 `modify_account_balance` and `modify_subscriber_balance` are unrelated ledgers.",
7465
7522
  inputSchema: {
7466
7523
  pack: z9.string().optional().describe(
7467
- "Pack id (pack_25/pack_50/pack_100/pack_500/pack_1000/pack_2500/pack_5000) or exact EUR-cents amount. Omit to list packs."
7524
+ "Pack id (pack_25/pack_50/pack_100/pack_500/pack_1000/pack_2500/pack_5000) or exact USD-cents amount. Omit to list packs."
7468
7525
  )
7469
7526
  },
7470
7527
  /**
@@ -7479,16 +7536,18 @@ function registerWalletTools(server2, ctx) {
7479
7536
  packs: z9.array(
7480
7537
  z9.object({
7481
7538
  id: z9.string(),
7482
- eur_cents: z9.number().int(),
7539
+ amount_cents: z9.number().int(),
7540
+ currency: z9.literal("usd"),
7483
7541
  bonus_pct: z9.number(),
7484
- bonus_eur_cents: z9.number().int(),
7485
- credited_eur_cents: z9.number().int()
7542
+ bonus_cents: z9.number().int(),
7543
+ credited_cents: z9.number().int()
7486
7544
  })
7487
7545
  ).optional().describe("Catalogue arm \u2014 present only when `pack` was omitted."),
7488
7546
  org_id: z9.string().optional().describe("Session arm."),
7489
7547
  pack_id: z9.string().optional().describe("Session arm."),
7490
- pack_eur_cents: z9.number().int().optional().describe("Session arm."),
7491
- bonus_eur_cents: z9.number().int().optional().describe("Session arm."),
7548
+ pack_cents: z9.number().int().optional().describe("Session arm."),
7549
+ bonus_cents: z9.number().int().optional().describe("Session arm."),
7550
+ currency: z9.literal("usd").optional().describe("Session arm."),
7492
7551
  checkout_session_id: z9.string().optional().describe("Session arm."),
7493
7552
  checkout_url: z9.string().nullable().optional().describe("Session arm. Stripe may return null for a session URL.")
7494
7553
  },
@@ -7503,10 +7562,11 @@ function registerWalletTools(server2, ctx) {
7503
7562
  return okStructured({
7504
7563
  packs: PACKS.map((p) => ({
7505
7564
  id: p.id,
7506
- eur_cents: p.eurCents,
7565
+ amount_cents: p.amountCents,
7566
+ currency: PACK_CURRENCY,
7507
7567
  bonus_pct: p.bonusPct,
7508
- bonus_eur_cents: bonusCentsFor(p),
7509
- credited_eur_cents: p.eurCents + bonusCentsFor(p)
7568
+ bonus_cents: bonusCentsFor(p),
7569
+ credited_cents: p.amountCents + bonusCentsFor(p)
7510
7570
  }))
7511
7571
  });
7512
7572
  }
@@ -7530,8 +7590,9 @@ function registerWalletTools(server2, ctx) {
7530
7590
  return okStructured({
7531
7591
  org_id: orgId,
7532
7592
  pack_id: selected.id,
7533
- pack_eur_cents: selected.eurCents,
7534
- bonus_eur_cents: bonusCentsFor(selected),
7593
+ pack_cents: selected.amountCents,
7594
+ bonus_cents: bonusCentsFor(selected),
7595
+ currency: PACK_CURRENCY,
7535
7596
  checkout_session_id: session.id,
7536
7597
  checkout_url: session.url
7537
7598
  });
@@ -7545,9 +7606,9 @@ function registerWalletTools(server2, ctx) {
7545
7606
  "wallet_auto_topup",
7546
7607
  {
7547
7608
  title: "Wallet Auto Top-up (charges card now)",
7548
- description: "Charge the organisation's saved card off-session, right now, and credit the Carrier prepaid wallet with the pack. This spends real money without any browser step or human confirmation, so only call it when the user has asked to be charged. Params: `pack_cents` (optional integer, EUR cents \u2014 must match a catalog pack; omit to use the organisation's configured auto-top-up pack). Returns on success: { org_id, charged: true, credited_eur_cents, balance_after_cents, payment_intent_id } \u2014 amounts in EUR cents. Returns { charged: false, reason } as an error when the card declines or no payment method is saved. Do NOT use this to let a human pay in a browser \u2014 use `wallet_topup_checkout`, which only returns a link. Do NOT use this to change the threshold that triggers automatic top-ups; this tool performs one charge and does not edit the configuration. Do NOT use this to credit an OCS reseller account or subscriber \u2014 see `modify_account_balance` and `modify_subscriber_balance`.",
7609
+ description: "Charge the organisation's saved card off-session, right now, and credit the Carrier prepaid wallet with the pack. This spends real money without any browser step or human confirmation, so only call it when the user has asked to be charged. Params: `pack_cents` (optional integer, USD cents \u2014 must match a catalog pack; omit to use the organisation's configured auto-top-up pack). Returns on success: { org_id, charged: true, credited_cents, currency, balance_after_cents, payment_intent_id } \u2014 amounts in USD cents. Returns { charged: false, reason } as an error when the card declines or no payment method is saved. Do NOT use this to let a human pay in a browser \u2014 use `wallet_topup_checkout`, which only returns a link. Do NOT use this to change the threshold that triggers automatic top-ups; this tool performs one charge and does not edit the configuration. Do NOT use this to credit an OCS reseller account or subscriber \u2014 see `modify_account_balance` and `modify_subscriber_balance`.",
7549
7610
  inputSchema: {
7550
- pack_cents: z9.number().int().positive().optional().describe("Override pack amount in EUR cents (must match a catalog pack).")
7611
+ pack_cents: z9.number().int().positive().optional().describe("Override pack amount in USD cents (must match a catalog pack).")
7551
7612
  },
7552
7613
  /**
7553
7614
  * Only the charged arm is described here — `charged: false` returns
@@ -7564,7 +7625,8 @@ function registerWalletTools(server2, ctx) {
7564
7625
  outputSchema: {
7565
7626
  org_id: z9.string(),
7566
7627
  charged: z9.literal(true),
7567
- credited_eur_cents: z9.number().int(),
7628
+ credited_cents: z9.number().int(),
7629
+ currency: z9.literal("usd"),
7568
7630
  balance_after_cents: z9.number().int().optional().describe("Absent when the charge succeeded but crediting is pending."),
7569
7631
  payment_intent_id: z9.string().optional(),
7570
7632
  note: z9.string().optional().describe("Present when the charge landed but the credit is still pending.")
@@ -7595,7 +7657,8 @@ function registerWalletTools(server2, ctx) {
7595
7657
  return okStructured({
7596
7658
  org_id: orgId,
7597
7659
  charged: true,
7598
- credited_eur_cents: result3.creditedCents,
7660
+ credited_cents: result3.creditedCents,
7661
+ currency: PACK_CURRENCY,
7599
7662
  // Spread rather than assign, so the key is absent instead of set to
7600
7663
  // `undefined`. JSON.stringify drops an undefined value anyway, so
7601
7664
  // assigning it would make `content` and `structuredContent` disagree
@@ -8801,9 +8864,220 @@ function registerStorefrontPlanTools(server2, props2, call = (path, body2) => {
8801
8864
  );
8802
8865
  }
8803
8866
 
8804
- // src/tools-atlas.ts
8867
+ // src/tools-storefront-management.ts
8805
8868
  import { z as z15 } from "zod";
8806
8869
 
8870
+ // ../../packages/sdk/src/storefront-operations.ts
8871
+ var STOREFRONT_OPERATIONS = {
8872
+ list_storefronts: ["GET", "", "read"],
8873
+ get_storefront: ["GET", "/{storefront_id}", "read"],
8874
+ create_storefront: ["POST", "", "write"],
8875
+ update_storefront: ["PATCH", "/{storefront_id}", "write"],
8876
+ upsert_storefront_plan: ["POST", "/{storefront_id}/plans", "write"],
8877
+ update_storefront_plan: ["PATCH", "/{storefront_id}/plans/{slug}", "write"],
8878
+ list_storefront_orders: ["GET", "/orders", "read"],
8879
+ plan_storefront_publish: ["POST", "/{storefront_id}/publish-plan", "read"],
8880
+ publish_storefront: ["POST", "/{storefront_id}/publish", "write"],
8881
+ unpublish_storefront: ["POST", "/{storefront_id}/unpublish", "write"],
8882
+ verify_storefront: ["GET", "/{storefront_id}/readiness", "read"],
8883
+ list_storefront_domains: ["GET", "/{storefront_id}/domains", "read"],
8884
+ plan_storefront_domain: ["POST", "/{storefront_id}/domains/plan", "read"],
8885
+ attach_storefront_domain: ["POST", "/{storefront_id}/domains", "write"],
8886
+ verify_storefront_domain: ["POST", "/{storefront_id}/domains/{hostname}/verify", "write"],
8887
+ detach_storefront_domain: ["DELETE", "/{storefront_id}/domains/{hostname}", "write"],
8888
+ plan_storefront_dns: ["POST", "/{storefront_id}/domains/{hostname}/dns-plan", "read"]
8889
+ };
8890
+ var IDEMPOTENCY_REQUIRED = [
8891
+ "create_storefront",
8892
+ "publish_storefront",
8893
+ "attach_storefront_domain"
8894
+ ];
8895
+ var MAX_METADATA_LENGTH = 200;
8896
+ var CONTROL_CHARACTERS = /[\u0000-\u001f\u007f]/;
8897
+ function metadataValue(name, value) {
8898
+ if (value === void 0) return void 0;
8899
+ if (typeof value !== "string" || !value.trim() || value.length > MAX_METADATA_LENGTH) {
8900
+ throw new Error(`${name} must be a non-empty string of at most ${MAX_METADATA_LENGTH} characters`);
8901
+ }
8902
+ if (CONTROL_CHARACTERS.test(value)) throw new Error(`${name} must not contain control characters`);
8903
+ return value;
8904
+ }
8905
+ function storefrontRequest(operation, input) {
8906
+ if (!Object.hasOwn(STOREFRONT_OPERATIONS, operation)) {
8907
+ throw new Error(`Unknown storefront operation: ${String(operation)}`);
8908
+ }
8909
+ if (input === null || typeof input !== "object" || Array.isArray(input)) {
8910
+ throw new Error("input must be an object");
8911
+ }
8912
+ const [method, suffix] = STOREFRONT_OPERATIONS[operation];
8913
+ const rest = { ...input };
8914
+ if (IDEMPOTENCY_REQUIRED.includes(operation) && (typeof rest.idempotency_key !== "string" || !rest.idempotency_key.trim())) {
8915
+ throw new Error("idempotency_key_required");
8916
+ }
8917
+ const path = `/v1/storefronts${suffix.replace(/\{(\w+)\}/g, (_match, key) => {
8918
+ const value = rest[key];
8919
+ if (typeof value !== "string" || value.length === 0) throw new Error(`${key} is required`);
8920
+ if (value === "." || value === "..") throw new Error(`${key} must not be a dot segment`);
8921
+ delete rest[key];
8922
+ return encodeURIComponent(value);
8923
+ })}`;
8924
+ const idempotencyKey = metadataValue("idempotency_key", rest.idempotency_key);
8925
+ const confirmToken = metadataValue("confirm_token", rest.confirm_token);
8926
+ delete rest.idempotency_key;
8927
+ delete rest.confirm_token;
8928
+ if (method === "GET") {
8929
+ if (confirmToken !== void 0 || idempotencyKey !== void 0) {
8930
+ throw new Error("Read requests do not accept mutation metadata");
8931
+ }
8932
+ const params = new URLSearchParams();
8933
+ for (const key of Object.keys(rest).sort()) {
8934
+ const value = rest[key];
8935
+ if (value === void 0 || value === null) continue;
8936
+ const valid = typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
8937
+ if (!valid) throw new Error(`${key} must be a scalar query value`);
8938
+ params.set(key, String(value));
8939
+ }
8940
+ const query = params.toString();
8941
+ return { method, path: query ? `${path}?${query}` : path };
8942
+ }
8943
+ if (method === "DELETE" && Object.values(rest).some((value) => value !== void 0)) {
8944
+ throw new Error("DELETE does not accept content fields");
8945
+ }
8946
+ return {
8947
+ method,
8948
+ path,
8949
+ ...method !== "DELETE" ? { body: rest } : {},
8950
+ ...idempotencyKey !== void 0 ? { idempotencyKey } : {},
8951
+ ...confirmToken !== void 0 ? { confirmToken } : {}
8952
+ };
8953
+ }
8954
+
8955
+ // src/tools-storefront-management.ts
8956
+ var OPERATIONS = Object.keys(STOREFRONT_OPERATIONS);
8957
+ var OPERATOR_OPERATIONS = OPERATIONS.filter((operation) => !operation.startsWith("publish_"));
8958
+ var STOREFRONT_MANAGEMENT_TOOL_SCOPES = Object.fromEntries(
8959
+ OPERATOR_OPERATIONS.map((operation) => [operation, STOREFRONT_OPERATIONS[operation][2]])
8960
+ );
8961
+ var IDEMPOTENCY_REQUIRED2 = /* @__PURE__ */ new Set([
8962
+ "create_storefront",
8963
+ "attach_storefront_domain"
8964
+ ]);
8965
+ var FORBIDDEN_FIELDS = /* @__PURE__ */ new Set([
8966
+ "org_id",
8967
+ "orgId",
8968
+ "sub",
8969
+ "scope",
8970
+ "scopes",
8971
+ "token",
8972
+ "api_key",
8973
+ "provider_token",
8974
+ "url",
8975
+ "repo_url",
8976
+ "callback_url",
8977
+ "command",
8978
+ "directory",
8979
+ "working_directory",
8980
+ "cwd"
8981
+ ]);
8982
+ var ORDER_STATUSES = ["pending", "provisioning", "ready", "failed"];
8983
+ var HOSTNAME_IN_BODY = /* @__PURE__ */ new Set(["plan_storefront_domain", "attach_storefront_domain"]);
8984
+ function pathFields(operation) {
8985
+ return [...STOREFRONT_OPERATIONS[operation][1].matchAll(/\{(\w+)\}/g)].map((match) => match[1]);
8986
+ }
8987
+ function topLevelShape(operation) {
8988
+ const [method] = STOREFRONT_OPERATIONS[operation];
8989
+ const shape = {};
8990
+ for (const field of pathFields(operation)) shape[field] = z15.string().min(1).max(253);
8991
+ if (HOSTNAME_IN_BODY.has(operation)) shape.hostname = z15.string().min(1).max(253);
8992
+ if (operation === "list_storefront_orders") {
8993
+ shape.storefront_id = z15.string().min(1).max(253).optional();
8994
+ shape.status = z15.enum(ORDER_STATUSES).optional();
8995
+ shape.limit = z15.number().int().min(1).max(200).optional();
8996
+ }
8997
+ if (method !== "GET") shape.input = z15.record(z15.string(), z15.unknown()).optional();
8998
+ if (method !== "GET") shape.confirm_token = z15.string().min(1).max(200).optional();
8999
+ if (method === "POST" || method === "PATCH") {
9000
+ shape.idempotency_key = IDEMPOTENCY_REQUIRED2.has(operation) ? z15.string().trim().min(1).max(200) : z15.string().trim().min(1).max(200).optional();
9001
+ }
9002
+ return shape;
9003
+ }
9004
+ var SAFETY_HINTS = {
9005
+ create_storefront: { idempotentHint: true },
9006
+ update_storefront: { idempotentHint: true },
9007
+ upsert_storefront_plan: { idempotentHint: true },
9008
+ update_storefront_plan: { idempotentHint: true },
9009
+ unpublish_storefront: { idempotentHint: true, destructiveHint: true },
9010
+ attach_storefront_domain: { idempotentHint: true },
9011
+ detach_storefront_domain: { idempotentHint: true, destructiveHint: true }
9012
+ };
9013
+ function isConfirmationChallenge(result3) {
9014
+ if (result3.status !== 202 || !isPlainObject(result3.body)) return false;
9015
+ return typeof result3.body.confirm_token === "string" || result3.body.error === "confirmation_required";
9016
+ }
9017
+ function failure(body2) {
9018
+ return { isError: true, content: [{ type: "text", text: JSON.stringify(body2) }] };
9019
+ }
9020
+ function isPlainObject(value) {
9021
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9022
+ }
9023
+ function registerStorefrontManagementTools(server2, props2, call, transportMode = "hosted", options) {
9024
+ for (const operation of OPERATOR_OPERATIONS) {
9025
+ if (options?.exclude?.has(operation)) continue;
9026
+ const shape = topLevelShape(operation);
9027
+ const allowed = new Set(Object.keys(shape));
9028
+ server2.registerTool(
9029
+ operation,
9030
+ {
9031
+ title: operation.replaceAll("_", " "),
9032
+ description: `Call the caller's storefront operation: ${STOREFRONT_OPERATIONS[operation][0]} /v1/storefronts${STOREFRONT_OPERATIONS[operation][1]}. Use input for the full JSON body. Caller identity comes from the session. A pending or queued response is not a finished deployment, and a 202 confirmation challenge applied nothing.`,
9033
+ inputSchema: z15.strictObject(shape),
9034
+ annotations: annotationsFor(operation, STOREFRONT_OPERATIONS[operation][2], SAFETY_HINTS[operation] ?? {})
9035
+ },
9036
+ async (args, extra) => {
9037
+ const denied = denyUnlessScoped(props2, operation, STOREFRONT_MANAGEMENT_TOOL_SCOPES);
9038
+ if (denied) return denied;
9039
+ if (transportMode === "hosted" && !props2.org_id?.trim()) return failure({ error: "org_required" });
9040
+ const { input, ...top } = args;
9041
+ for (const field of Object.keys(top)) {
9042
+ if (FORBIDDEN_FIELDS.has(field) || !allowed.has(field)) return failure({ error: "forbidden_input", field });
9043
+ }
9044
+ if (input !== void 0 && !isPlainObject(input)) return failure({ error: "invalid_input" });
9045
+ const content = input ?? {};
9046
+ if (Object.hasOwn(content, "confirm_token") || Object.hasOwn(content, "idempotency_key")) {
9047
+ return failure({ error: "metadata_must_be_top_level" });
9048
+ }
9049
+ for (const field of Object.keys(content)) {
9050
+ if (FORBIDDEN_FIELDS.has(field)) return failure({ error: "forbidden_input", field });
9051
+ }
9052
+ for (const [field, value] of Object.entries(top)) {
9053
+ if (value === void 0) continue;
9054
+ if (Object.hasOwn(content, field)) return failure({ error: "duplicate_input", field });
9055
+ }
9056
+ let request;
9057
+ try {
9058
+ request = storefrontRequest(operation, { ...content, ...top });
9059
+ } catch (error) {
9060
+ return failure({ error: error instanceof Error ? error.message : "invalid_request" });
9061
+ }
9062
+ let result3;
9063
+ try {
9064
+ result3 = await call(request, extra);
9065
+ } catch {
9066
+ return failure({ error: "storefront_call_failed" });
9067
+ }
9068
+ const succeeded = result3.ok && result3.status >= 200 && result3.status < 300 && !isConfirmationChallenge(result3);
9069
+ return {
9070
+ content: [{ type: "text", text: JSON.stringify({ status: result3.status, body: result3.body }) }],
9071
+ ...succeeded ? {} : { isError: true }
9072
+ };
9073
+ }
9074
+ );
9075
+ }
9076
+ }
9077
+
9078
+ // src/tools-atlas.ts
9079
+ import { z as z16 } from "zod";
9080
+
8807
9081
  // src/atlas-public.ts
8808
9082
  var ATLAS_PUBLIC_BASE_URL = "https://atlas.carrier.llc";
8809
9083
  function atlasBaseUrl(env) {
@@ -8860,13 +9134,13 @@ var ATLAS_TOOL_SCOPES = {
8860
9134
  get_atlas_network_status: "read"
8861
9135
  };
8862
9136
  var coverageSchema = {
8863
- country: z15.string().regex(/^[A-Za-z]{2}$/, "country must be a 2-letter ISO code").describe("ISO 3166-1 alpha-2 country code, for example JP or NL"),
8864
- status: z15.enum(["up", "degraded", "down", "unknown"]).optional().describe("Keep only networks whose latest probe has this status"),
8865
- technology: z15.enum(["2G", "3G", "4G", "5G"]).optional().describe("Keep only networks of this radio generation")
9137
+ country: z16.string().regex(/^[A-Za-z]{2}$/, "country must be a 2-letter ISO code").describe("ISO 3166-1 alpha-2 country code, for example JP or NL"),
9138
+ status: z16.enum(["up", "degraded", "down", "unknown"]).optional().describe("Keep only networks whose latest probe has this status"),
9139
+ technology: z16.enum(["2G", "3G", "4G", "5G"]).optional().describe("Keep only networks of this radio generation")
8866
9140
  };
8867
9141
  var networkSchema = {
8868
- mcc: z15.string().regex(/^\d{3}$/, "mcc must be 3 digits").describe("Mobile Country Code"),
8869
- mnc: z15.string().regex(/^\d{2,3}$/, "mnc must be 2 or 3 digits").describe("Mobile Network Code")
9142
+ mcc: z16.string().regex(/^\d{3}$/, "mcc must be 3 digits").describe("Mobile Country Code"),
9143
+ mnc: z16.string().regex(/^\d{2,3}$/, "mnc must be 2 or 3 digits").describe("Mobile Network Code")
8870
9144
  };
8871
9145
  function jsonResult3(body2) {
8872
9146
  return {
@@ -8921,15 +9195,15 @@ function registerAtlasTools(server2, ctx) {
8921
9195
  }
8922
9196
 
8923
9197
  // src/tools-network-default.ts
8924
- import { z as z16 } from "zod";
9198
+ import { z as z17 } from "zod";
8925
9199
  var NETWORK_DEFAULT_TOOL_SCOPES = {
8926
9200
  get_network_default: "read",
8927
9201
  set_network_default: "write",
8928
9202
  plan_network_default: "read"
8929
9203
  };
8930
- var choiceShape = z16.object({
8931
- mode: z16.enum(NETWORK_DEFAULT_MODES),
8932
- steeringListId: z16.number().int().positive().optional()
9204
+ var choiceShape = z17.object({
9205
+ mode: z17.enum(NETWORK_DEFAULT_MODES),
9206
+ steeringListId: z17.number().int().positive().optional()
8933
9207
  }).describe("`cheapest_available`, `all`, or `custom` with a steeringListId from list_steering_lists");
8934
9208
  function ioFor(ctx, token2) {
8935
9209
  const kv = ctx.env.CARRIER_USERS;
@@ -8984,9 +9258,9 @@ function registerNetworkDefaultTools(server2, ctx) {
8984
9258
  title: "Set Network Default",
8985
9259
  description: "Use this to set the organisation's network default to `cheapest_available`, `all`, or `custom` (a steering list id from `list_steering_lists`, which must exist). This only stores the setting. It changes no SIM, writes nothing to OCS and does not migrate existing customers: it applies to NEW assignments. A single assignment can still override it with `plan_network_default`'s `simOverride`. Params: `mode` (required), `steeringListId` (required when mode is `custom`), `dry_run` (preview only). Do NOT use this to assign a list to one SIM \u2014 use `modify_subscriber_steering_list`.",
8986
9260
  inputSchema: {
8987
- mode: z16.enum(NETWORK_DEFAULT_MODES).describe("cheapest_available | all | custom"),
8988
- steeringListId: z16.number().int().positive().optional().describe("Required when mode is custom"),
8989
- dry_run: z16.boolean().optional().describe("If true, validate and return what would be stored; store nothing")
9261
+ mode: z17.enum(NETWORK_DEFAULT_MODES).describe("cheapest_available | all | custom"),
9262
+ steeringListId: z17.number().int().positive().optional().describe("Required when mode is custom"),
9263
+ dry_run: z17.boolean().optional().describe("If true, validate and return what would be stored; store nothing")
8990
9264
  },
8991
9265
  annotations: { readOnlyHint: false, idempotentHint: true, destructiveHint: false }
8992
9266
  },
@@ -9015,10 +9289,10 @@ function registerNetworkDefaultTools(server2, ctx) {
9015
9289
  title: "Plan Network Default",
9016
9290
  description: "Use this to see which networks a SIM would be given in one or more countries, before anything is assigned. By default that is the cheapest available network per country (lowest data rate above zero, among rules really in force). Precedence: `simOverride`, then `packageOverride`, then the org default, then `cheapest_available`. Read only: `applied` is always false. If the tariff is missing or cannot be compared it falls back to ALL networks and says so in `warnings` and `summary` (`fellBackToAll: true`); never present that as a cheapest choice. The price basis is the wholesale data rate per MB, not the end price. Creating a steering list has no OCS REST method, so when no existing list matches the result is `needs_list`, not a created list. Params: `countries` (ISO-3166 alpha-2 codes, required), `simOverride`, `packageOverride`, `resellerId` (optional).",
9017
9291
  inputSchema: {
9018
- countries: z16.array(z16.string().length(2)).min(1).describe('ISO-3166 alpha-2 codes, e.g. ["CA"]'),
9292
+ countries: z17.array(z17.string().length(2)).min(1).describe('ISO-3166 alpha-2 codes, e.g. ["CA"]'),
9019
9293
  simOverride: choiceShape.optional(),
9020
9294
  packageOverride: choiceShape.optional(),
9021
- resellerId: z16.number().int().positive().optional().describe("Omit to use the token owner's reseller")
9295
+ resellerId: z17.number().int().positive().optional().describe("Omit to use the token owner's reseller")
9022
9296
  },
9023
9297
  annotations: { readOnlyHint: true }
9024
9298
  },
@@ -9033,7 +9307,7 @@ function registerNetworkDefaultTools(server2, ctx) {
9033
9307
  }
9034
9308
 
9035
9309
  // src/affiliate-tools.ts
9036
- import { z as z17 } from "zod";
9310
+ import { z as z18 } from "zod";
9037
9311
  var AFFILIATE_TOOL_SCOPES = {
9038
9312
  affiliate_status: "read",
9039
9313
  affiliate_commissions: "read",
@@ -9104,7 +9378,7 @@ function registerAffiliateTools(server2, ctx) {
9104
9378
  title: "Affiliate Commissions",
9105
9379
  description: "Read-only: returns the list of commission records for the authenticated operator.",
9106
9380
  inputSchema: {
9107
- limit: z17.number().int().min(1).max(200).optional().default(50).describe("Maximum number of commission records to return (1-200, default: 50).")
9381
+ limit: z18.number().int().min(1).max(200).optional().default(50).describe("Maximum number of commission records to return (1-200, default: 50).")
9108
9382
  },
9109
9383
  annotations: annotationsFor("affiliate_commissions", "read")
9110
9384
  },
@@ -10603,6 +10877,7 @@ var ALL_TOOL_SCOPES = Object.freeze({
10603
10877
  // Storefront deploy tools exist only in this package, not in the Worker.
10604
10878
  ...STOREFRONT_DEPLOY_TOOL_SCOPES,
10605
10879
  ...STOREFRONT_PLAN_TOOL_SCOPES,
10880
+ ...STOREFRONT_MANAGEMENT_TOOL_SCOPES,
10606
10881
  ...ATLAS_TOOL_SCOPES,
10607
10882
  ...NETWORK_DEFAULT_TOOL_SCOPES,
10608
10883
  ...AFFILIATE_TOOL_SCOPES,
@@ -11285,15 +11560,15 @@ function registerAllCarrierAskTools(server2, ctx) {
11285
11560
  title: "Natural Language Carrier Tool Router",
11286
11561
  description: "Use this when you want to perform a carrier operation but don't know which specific tool to call. Describe your intent in plain language and carrier_ask will identify the correct tool(s) and suggest the required parameters. For simple read intents, it executes directly and returns results. For destructive operations it returns a confirm_token that you must pass in a second call. Params: `intent` (string \u2014 natural language description of what you want to do), `context` (optional: iccid, account_id, reseller_id if already known). Returns: RouteResult \u2014 confirmed | pending_confirm | ambiguous | none. Do NOT use this when you know the right tool \u2014 direct calls are faster and cheaper.",
11287
11562
  inputSchema: {
11288
- intent: z18.string().min(3).describe(
11563
+ intent: z19.string().min(3).describe(
11289
11564
  "Natural-language description of the operation to perform (e.g. 'suspend ICCID 89316 until next month', 'show fleet health', 'assign Europe 5GB package to subscriber 89316...')"
11290
11565
  ),
11291
- context: z18.object({
11292
- iccid: z18.string().optional().describe("Subscriber ICCID if already known"),
11293
- account_id: z18.number().optional().describe("Account ID if already known"),
11294
- reseller_id: z18.number().optional().describe("Reseller ID if already known")
11566
+ context: z19.object({
11567
+ iccid: z19.string().optional().describe("Subscriber ICCID if already known"),
11568
+ account_id: z19.number().optional().describe("Account ID if already known"),
11569
+ reseller_id: z19.number().optional().describe("Reseller ID if already known")
11295
11570
  }).optional().describe("Optional pre-resolved context to improve routing accuracy"),
11296
- confirm_token: z18.string().optional().describe(
11571
+ confirm_token: z19.string().optional().describe(
11297
11572
  "One-time token from a previous carrier_ask call with confirm_required=true. Providing this executes the previously staged destructive operation."
11298
11573
  )
11299
11574
  }
@@ -11497,7 +11772,7 @@ function registerAllCarrierAskTools(server2, ctx) {
11497
11772
  title: "Describe a Carrier Tool",
11498
11773
  description: "Get full documentation for any registered Carrier MCP tool: description, parameters, 2-3 example invocations, required scope, destructive flag, and guidance. Params: `tool_name` (exact MCP tool name, e.g. 'assign_package'). Returns: structured tool metadata. Does NOT execute the tool.",
11499
11774
  inputSchema: {
11500
- tool_name: z18.string().describe("The exact MCP tool name to describe (e.g. 'assign_package', 'hlr_set_bitrate')")
11775
+ tool_name: z19.string().describe("The exact MCP tool name to describe (e.g. 'assign_package', 'hlr_set_bitrate')")
11501
11776
  }
11502
11777
  },
11503
11778
  wrapHandler(
@@ -11590,7 +11865,7 @@ function buildExamples(toolName) {
11590
11865
  }
11591
11866
 
11592
11867
  // src/list-recent-ocs-events.ts
11593
- import { z as z19 } from "zod";
11868
+ import { z as z20 } from "zod";
11594
11869
 
11595
11870
  // ../../packages/ocs-spec/src/ocs-event-buffer-read.ts
11596
11871
  var LIFECYCLE_RESELLER_ID2 = 1170;
@@ -11719,10 +11994,10 @@ var ALLOWED_EVENT_TYPES = [
11719
11994
  "usage.anomaly"
11720
11995
  ];
11721
11996
  var listRecentOcsEventsSchema = {
11722
- iccid: z19.string().regex(/^\d{19,20}$/).describe("ICCID, 19 or 20 digits, ITU-T E.118 format"),
11723
- limit: z19.number().int().min(1).max(50).default(20).describe("Max events to return, newest first"),
11724
- event_types: z19.array(z19.enum(ALLOWED_EVENT_TYPES)).optional().describe("Filter to specific event types"),
11725
- since: z19.string().datetime().optional().describe("ISO-8601 timestamp; only events after this point")
11997
+ iccid: z20.string().regex(/^\d{19,20}$/).describe("ICCID, 19 or 20 digits, ITU-T E.118 format"),
11998
+ limit: z20.number().int().min(1).max(50).default(20).describe("Max events to return, newest first"),
11999
+ event_types: z20.array(z20.enum(ALLOWED_EVENT_TYPES)).optional().describe("Filter to specific event types"),
12000
+ since: z20.string().datetime().optional().describe("ISO-8601 timestamp; only events after this point")
11726
12001
  };
11727
12002
  async function listRecentOcsEvents2(iccid, limit, eventTypes, since, kv) {
11728
12003
  return listRecentOcsEvents(iccid, limit, eventTypes, since, kv);
@@ -11785,7 +12060,7 @@ function registerListRecentOcsEventsTool(server2, ctx) {
11785
12060
  }
11786
12061
 
11787
12062
  // src/tools-rate-governor.ts
11788
- import { z as z20 } from "zod";
12063
+ import { z as z21 } from "zod";
11789
12064
  var MONITORED_ENDPOINTS = [
11790
12065
  "subscriberNetworkEventsOverPeriod",
11791
12066
  // 30/min
@@ -11817,7 +12092,7 @@ function registerRateLimitStatusTool(server2, ctx) {
11817
12092
  title: "API Rate-Limit Governor Status",
11818
12093
  description: "Inspect Bridge4IP OCS rate-limit governor state \u2014 bucket fill levels, per-endpoint limits, and 80% alert thresholds. Use this to answer: 'are we rate limited', 'check ocs quota', 'how full is the rate limit bucket', 'rate limit status'. Params: `endpoint` (optional \u2014 OCS camelCase method name to inspect a single bucket, e.g. 'subscriberUsageOverPeriod'; omit for all monitored endpoints). Returns: per-endpoint { limit_per_min, batch_cap_per_min, calls_in_window, batch_calls_in_window, utilisation_pct, alert (true when \u226580% of limit) }. Note: counts come from the in-process sliding-window log (same key as OCS calls: API token + endpoint) \u2014 they reset when the Worker isolate recycles. Use as a relative signal, not an exact counter. Do NOT use this to adjust limits \u2014 limits are set by Bridge4IP contract and cannot be changed via MCP.",
11819
12094
  inputSchema: {
11820
- endpoint: z20.string().optional().describe(
12095
+ endpoint: z21.string().optional().describe(
11821
12096
  "OCS method name in camelCase (e.g. 'subscriberUsageOverPeriod'). Omit to return status for all monitored endpoints."
11822
12097
  )
11823
12098
  },
@@ -11873,7 +12148,7 @@ function registerRateLimitStatusTool(server2, ctx) {
11873
12148
  }
11874
12149
 
11875
12150
  // src/tools-depletion-events.ts
11876
- import { z as z21 } from "zod";
12151
+ import { z as z22 } from "zod";
11877
12152
  function ok6(payload) {
11878
12153
  return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }] };
11879
12154
  }
@@ -11901,10 +12176,10 @@ function registerDepletionEventsTool(server2, ctx) {
11901
12176
  title: "Subscriber Bundle Depletion Events",
11902
12177
  description: "Look up bundle depletion events for a subscriber (or list recent fleet-wide depletions). Returns the most recent bundle.depleted event stored when the prepaid usage webhook received a last_slice notification. Events are retained for 7 days. Use subscriberId to check a specific subscriber, or omit to list the 20 most recent fleet-wide depletions. Requires 'read' scope.",
11903
12178
  inputSchema: {
11904
- subscriberId: z21.string().optional().describe(
12179
+ subscriberId: z22.string().optional().describe(
11905
12180
  "OCS subscriber ID to look up. Omit to list the 20 most recent fleet-wide depletions."
11906
12181
  ),
11907
- since: z21.string().optional().describe(
12182
+ since: z22.string().optional().describe(
11908
12183
  "ISO-8601 timestamp \u2014 only return events at or after this time (for single-subscriber lookup)."
11909
12184
  )
11910
12185
  },
@@ -12019,7 +12294,7 @@ function registerDepletionEventsTool(server2, ctx) {
12019
12294
  }
12020
12295
 
12021
12296
  // src/tools-country-history.ts
12022
- import { z as z22 } from "zod";
12297
+ import { z as z23 } from "zod";
12023
12298
  function isoDate(now, daysAgo = 0) {
12024
12299
  const d = new Date(now.getTime() - daysAgo * 864e5);
12025
12300
  return d.toISOString().slice(0, 10);
@@ -12042,10 +12317,10 @@ function registerCountryHistoryTool(server2, ctx) {
12042
12317
  title: "Subscriber Country History",
12043
12318
  description: "Return cross-border movement history for a subscriber, reconstructed from OCS Gy charging events. Reads `gyAnswer.events` from `subscriberNetworkEventsOverPeriod` \u2014 every Gy record carries its own country, operator and MCC \u2014 and collapses consecutive same-country records into stays with first-seen and last-seen timestamps. This needs no webhook: it works with Relay LU and Relay Gy off. Relay `country.entered` events from the 24h ring-buffer are merged in as a supplement when present. Use this to answer: 'where has subscriber X traveled', 'show country history for ICCID', 'border crossings for this SIM'. Params: `subscriberId` (ICCID, 19\u201320 digits), `startDate`/`endDate` (YYYY-MM-DD, max 7 days apart, default the last 7 days), `limit` (1\u201350, default 20, newest first). Returns: `stays` ({ country, country_name, first_seen, last_seen, operators, mccs, event_count, used_bytes }), `transitions` ({ from, to, at }), and `country_events` in the legacy flat shape. `used_bytes` already handles the string-typed `usedUnits` and its 'N/A' values. Do NOT use this for raw per-session records \u2014 use `subscriber_network_events` for those.",
12044
12319
  inputSchema: {
12045
- subscriberId: z22.string().regex(/^\d{19,20}$/, "subscriberId must be a 19\u201320 digit ICCID").describe("Subscriber ICCID (19\u201320 digits, ITU-T E.118)"),
12046
- startDate: z22.string().regex(/^\d{4}-\d{2}-\d{2}$/, "startDate must be YYYY-MM-DD").optional().describe("Start of the period, YYYY-MM-DD inclusive (default: 7 days ago)"),
12047
- endDate: z22.string().regex(/^\d{4}-\d{2}-\d{2}$/, "endDate must be YYYY-MM-DD").optional().describe("End of the period, YYYY-MM-DD inclusive, max 7 days from start (default: today)"),
12048
- limit: z22.number().int().min(1).max(50).default(20).optional().describe("Maximum number of country_events to return, newest first (default 20, max 50)")
12320
+ subscriberId: z23.string().regex(/^\d{19,20}$/, "subscriberId must be a 19\u201320 digit ICCID").describe("Subscriber ICCID (19\u201320 digits, ITU-T E.118)"),
12321
+ startDate: z23.string().regex(/^\d{4}-\d{2}-\d{2}$/, "startDate must be YYYY-MM-DD").optional().describe("Start of the period, YYYY-MM-DD inclusive (default: 7 days ago)"),
12322
+ endDate: z23.string().regex(/^\d{4}-\d{2}-\d{2}$/, "endDate must be YYYY-MM-DD").optional().describe("End of the period, YYYY-MM-DD inclusive, max 7 days from start (default: today)"),
12323
+ limit: z23.number().int().min(1).max(50).default(20).optional().describe("Maximum number of country_events to return, newest first (default 20, max 50)")
12049
12324
  },
12050
12325
  annotations: { readOnlyHint: true, idempotentHint: true }
12051
12326
  },
@@ -12153,7 +12428,7 @@ function registerCountryHistoryTool(server2, ctx) {
12153
12428
  }
12154
12429
 
12155
12430
  // src/apps/fleet-health-app.ts
12156
- import { z as z23 } from "zod";
12431
+ import { z as z24 } from "zod";
12157
12432
  import {
12158
12433
  registerAppTool,
12159
12434
  registerAppResource,
@@ -12269,7 +12544,7 @@ function registerFleetHealthApp(server2, ctx) {
12269
12544
  title: "Fleet Health Dashboard",
12270
12545
  description: "Draw the fleet overview as an interactive panel: eSIM status, per-account breakdown and low-balance alerts. Returns structuredContent for the panel, so it only helps a client that can render MCP UI resources. Do NOT use this when the answer has to be readable text, or in any headless or scripted context \u2014 `fleet_health` returns the same data as prose.",
12271
12546
  inputSchema: {
12272
- accountId: z23.number().optional().describe("Filter to a specific account (omit for all)")
12547
+ accountId: z24.number().optional().describe("Filter to a specific account (omit for all)")
12273
12548
  },
12274
12549
  annotations: { readOnlyHint: true },
12275
12550
  _meta: {
@@ -12312,7 +12587,7 @@ function registerFleetHealthApp(server2, ctx) {
12312
12587
  }
12313
12588
 
12314
12589
  // src/apps/provisioning-wizard.ts
12315
- import { z as z24 } from "zod";
12590
+ import { z as z25 } from "zod";
12316
12591
  import {
12317
12592
  registerAppTool as registerAppTool2,
12318
12593
  registerAppResource as registerAppResource2,
@@ -12417,10 +12692,10 @@ function registerProvisioningWizard(server2, ctx) {
12417
12692
  title: "eSIM Provisioning Wizard",
12418
12693
  description: "Interactive 3-step wizard to provision an eSIM: select subscriber, choose package template, preview (dry_run) and confirm execution.",
12419
12694
  inputSchema: {
12420
- step: z24.enum(["init", "select-package", "preview", "confirm"]).describe("Current wizard step"),
12421
- wizardId: z24.string().optional().describe("Wizard session ID (absent on init)"),
12422
- subscriber_iccid: z24.string().optional().describe("Subscriber ICCID (required for select-package)"),
12423
- package_template_id: z24.number().optional().describe("Package template ID (required for preview)")
12695
+ step: z25.enum(["init", "select-package", "preview", "confirm"]).describe("Current wizard step"),
12696
+ wizardId: z25.string().optional().describe("Wizard session ID (absent on init)"),
12697
+ subscriber_iccid: z25.string().optional().describe("Subscriber ICCID (required for select-package)"),
12698
+ package_template_id: z25.number().optional().describe("Package template ID (required for preview)")
12424
12699
  },
12425
12700
  _meta: {
12426
12701
  ui: {
@@ -12690,7 +12965,7 @@ function registerProvisioningWizard(server2, ctx) {
12690
12965
  }
12691
12966
 
12692
12967
  // src/apps/balance-topup.ts
12693
- import { z as z25 } from "zod";
12968
+ import { z as z26 } from "zod";
12694
12969
  import {
12695
12970
  registerAppTool as registerAppTool3,
12696
12971
  registerAppResource as registerAppResource3,
@@ -12743,9 +13018,9 @@ function registerBalanceTopupApp(server2, ctx) {
12743
13018
  title: "Balance Top-up Form",
12744
13019
  description: "Adjust the OCS reseller-account balance behind one subscriber, through a form panel the user can review before it commits. Defaults to preview: a call that omits `preview` returns a projection and writes nothing. Only `preview: false` performs the OCS write. Params: `iccid` (subscriber identifier used to find the account), `delta` (amount to add when positive, deduct when negative), `preview` (boolean, default true). Requires `admin` scope plus recent MFA, and a client that can render UI panels. Do NOT use this in a headless or scripted context \u2014 call `modify_account_balance` directly, which takes an `accountId` and needs no panel. Do NOT use this for a subscriber's own balance \u2014 the `iccid` here only locates the account; per-subscriber money is `modify_subscriber_balance`. Do NOT use this for the Carrier prepaid wallet or MCP credits \u2014 see `wallet_topup_checkout` and `credit_balance`.",
12745
13020
  inputSchema: {
12746
- iccid: z25.string().describe("The subscriber ICCID for the account lookup"),
12747
- delta: z25.number().describe("Amount to add (positive) or deduct (negative) from the account balance"),
12748
- preview: z25.boolean().default(true).describe("If true, return preview without writing. If false, execute the balance change.")
13021
+ iccid: z26.string().describe("The subscriber ICCID for the account lookup"),
13022
+ delta: z26.number().describe("Amount to add (positive) or deduct (negative) from the account balance"),
13023
+ preview: z26.boolean().default(true).describe("If true, return preview without writing. If false, execute the balance change.")
12749
13024
  },
12750
13025
  annotations: { destructiveHint: true },
12751
13026
  _meta: {
@@ -12828,7 +13103,7 @@ function registerAllApps(server2, ctx) {
12828
13103
  }
12829
13104
 
12830
13105
  // src/prompts.ts
12831
- import { z as z26 } from "zod";
13106
+ import { z as z27 } from "zod";
12832
13107
  function registerAllPrompts(server2) {
12833
13108
  server2.registerPrompt(
12834
13109
  "fleet_health_report",
@@ -12864,7 +13139,7 @@ Format as a structured report with sections, tables, and actionable recommendati
12864
13139
  {
12865
13140
  title: "Subscriber Deep Dive",
12866
13141
  description: "Comprehensive analysis of a single subscriber: profile, packages, usage patterns, location history, recommendations.",
12867
- argsSchema: { iccid: z26.string().describe("The subscriber ICCID to analyse") }
13142
+ argsSchema: { iccid: z27.string().describe("The subscriber ICCID to analyse") }
12868
13143
  },
12869
13144
  async ({ iccid }) => ({
12870
13145
  messages: [
@@ -12963,7 +13238,7 @@ Analyze and present:
12963
13238
  {
12964
13239
  title: "Bulk Operations Planner",
12965
13240
  description: "Plan bulk operations safely: mass package assignments, account migrations, balance adjustments, or status changes.",
12966
- argsSchema: { operation: z26.string().describe("Describe the bulk operation you want to perform") }
13241
+ argsSchema: { operation: z27.string().describe("Describe the bulk operation you want to perform") }
12967
13242
  },
12968
13243
  async ({ operation }) => ({
12969
13244
  messages: [
@@ -12996,7 +13271,7 @@ NEVER execute destructive operations without confirmation.`
12996
13271
  }
12997
13272
 
12998
13273
  // src/tools-pricing.ts
12999
- import { z as z27 } from "zod";
13274
+ import { z as z28 } from "zod";
13000
13275
  function registerAllPricingTools(server2, ctx) {
13001
13276
  const allTools = [...PRICING_TOOLS, ...PROJECTS_TOOLS];
13002
13277
  for (const tool of allTools) {
@@ -13103,19 +13378,19 @@ function buildZodSchema(schema) {
13103
13378
  for (const [key, prop] of Object.entries(properties)) {
13104
13379
  let field;
13105
13380
  if (prop.enum) {
13106
- field = z27.enum(prop.enum);
13381
+ field = z28.enum(prop.enum);
13107
13382
  } else if (prop.type === "number") {
13108
- field = z27.number();
13383
+ field = z28.number();
13109
13384
  } else if (prop.type === "boolean") {
13110
- field = z27.boolean();
13385
+ field = z28.boolean();
13111
13386
  } else if (prop.type === "array") {
13112
13387
  if (prop.items?.type === "number") {
13113
- field = z27.array(z27.number());
13388
+ field = z28.array(z28.number());
13114
13389
  } else {
13115
- field = z27.array(z27.string());
13390
+ field = z28.array(z28.string());
13116
13391
  }
13117
13392
  } else {
13118
- field = z27.string();
13393
+ field = z28.string();
13119
13394
  }
13120
13395
  const required = schema.required ?? [];
13121
13396
  if (!required.includes(key)) {
@@ -13130,7 +13405,7 @@ function buildZodSchema(schema) {
13130
13405
  }
13131
13406
 
13132
13407
  // src/tools-greenzone.ts
13133
- import { z as z28 } from "zod";
13408
+ import { z as z29 } from "zod";
13134
13409
 
13135
13410
  // src/greenzone-whitelist.ts
13136
13411
  var STATE_KEY = "greenzone:state";
@@ -13421,9 +13696,9 @@ function registerGreenzoneTools(server2, ctx) {
13421
13696
  title: "Greenzone Whitelist \u2014 Add",
13422
13697
  description: "Add a hostname and/or IP address to the Bridge4IP Greenzone whitelist. The Greenzone whitelist controls which hosts/IPs are exempt from data charging after a subscriber's bundle is depleted. This operates via browser automation (Kapture) against the OCS portal \u2014 no REST API exists for this surface. Provide `host` (e.g. 'example.com') and/or `ip` (e.g. '203.0.113.0/24'). At least one of host or ip must be provided. Returns Kapture step sequence for Claude Code to execute. Requires 'write' scope and Kapture running in Sam's Chrome.",
13423
13698
  inputSchema: {
13424
- host: z28.string().optional().describe("Hostname to whitelist (e.g. 'example.com')"),
13425
- ip: z28.string().optional().describe("IP address or CIDR to whitelist (e.g. '203.0.113.0/24')"),
13426
- dry_run: z28.boolean().optional().describe("If true, return the Kapture steps without executing portal automation")
13699
+ host: z29.string().optional().describe("Hostname to whitelist (e.g. 'example.com')"),
13700
+ ip: z29.string().optional().describe("IP address or CIDR to whitelist (e.g. '203.0.113.0/24')"),
13701
+ dry_run: z29.boolean().optional().describe("If true, return the Kapture steps without executing portal automation")
13427
13702
  },
13428
13703
  annotations: { destructiveHint: true }
13429
13704
  },
@@ -13482,9 +13757,9 @@ function registerGreenzoneTools(server2, ctx) {
13482
13757
  title: "Greenzone Whitelist \u2014 Remove",
13483
13758
  description: "Remove a hostname and/or IP address from the Bridge4IP Greenzone whitelist. This operates via browser automation (Kapture) against the OCS portal. Provide `host` and/or `ip` to remove \u2014 at least one required. Returns Kapture step sequence for Claude Code to execute. Requires 'write' scope and Kapture running in Sam's Chrome.",
13484
13759
  inputSchema: {
13485
- host: z28.string().optional().describe("Hostname to remove from whitelist"),
13486
- ip: z28.string().optional().describe("IP address or CIDR to remove from whitelist"),
13487
- dry_run: z28.boolean().optional().describe("If true, return the Kapture steps without executing portal automation")
13760
+ host: z29.string().optional().describe("Hostname to remove from whitelist"),
13761
+ ip: z29.string().optional().describe("IP address or CIDR to remove from whitelist"),
13762
+ dry_run: z29.boolean().optional().describe("If true, return the Kapture steps without executing portal automation")
13488
13763
  },
13489
13764
  annotations: { destructiveHint: true }
13490
13765
  },
@@ -13543,7 +13818,7 @@ function registerGreenzoneTools(server2, ctx) {
13543
13818
  title: "Greenzone Whitelist \u2014 List",
13544
13819
  description: "List current Greenzone whitelist entries from the KV cache. Returns all whitelisted hosts and IPs, when the state was last synced, and whether the last hourly reconciliation detected drift from the portal. This is a fast read from KV \u2014 no browser automation required. Use `from_portal: true` to trigger a live portal read via Kapture instead of KV. Requires 'read' scope.",
13545
13820
  inputSchema: {
13546
- from_portal: z28.boolean().optional().describe(
13821
+ from_portal: z29.boolean().optional().describe(
13547
13822
  "When true, return Kapture steps to read live portal state instead of KV cache"
13548
13823
  )
13549
13824
  },
@@ -13595,7 +13870,7 @@ function registerGreenzoneTools(server2, ctx) {
13595
13870
  }
13596
13871
 
13597
13872
  // src/tools-ui-agent-generic.ts
13598
- import { z as z29 } from "zod";
13873
+ import { z as z30 } from "zod";
13599
13874
  var COST_PER_STEP_USD = 0.014;
13600
13875
  var SESSION_OVERHEAD_USD = 5e-3;
13601
13876
  function estimateCostUsd2(steps) {
@@ -13637,13 +13912,13 @@ function registerUiAgentGenericTools(server2, ctx, runtime) {
13637
13912
  title: "Dispatch Generic Browsing Agent",
13638
13913
  description: "Send a plain-language task to a hosted browsing agent, which drives a real browser on the open web \u2014 navigating pages, searching, extracting content, filling forms outside the OCS portal. Each run costs roughly $0.20-1.00 in model spend against your own BROWSER_USE_API_KEY, so treat it as the expensive last resort, not a lookup. Limited to CARRIER_BROWSER_USE_MAX_RUNS runs per CLI session (default 10). Params: `prompt` (1-4000 chars \u2014 name the target URL and the exact data or action), `max_steps` (1-30, default 15; prices the dry-run estimate only), `dry_run` (true returns only `estimated_cost_usd` and creates no session). Returns the finished result: unlike the hosted Worker, a local CLI has no background runtime, so this call blocks for the length of the run. Requires `write` scope. Do NOT use this to work out which Carrier tool answers a request \u2014 that is `carrier_ask`, which costs nothing. Do NOT use this for anything the OCS API already covers; every other tool here is faster, free, and audited.",
13639
13914
  inputSchema: {
13640
- prompt: z29.string().min(1).max(4e3).describe(
13915
+ prompt: z30.string().min(1).max(4e3).describe(
13641
13916
  "Natural-language task description for the browsing agent. Be specific: include target URLs, data to extract, or actions to perform."
13642
13917
  ),
13643
- max_steps: z29.number().int().min(1).max(30).optional().describe(
13918
+ max_steps: z30.number().int().min(1).max(30).optional().describe(
13644
13919
  "Advisory step budget (1\u201330, default 15). Prices the dry-run estimate; the hosted agent sets its own depth."
13645
13920
  ),
13646
- dry_run: z29.boolean().optional().describe(
13921
+ dry_run: z30.boolean().optional().describe(
13647
13922
  "Preview cost estimate without dispatching. Returns estimated_cost_usd only \u2014 no browser session is created."
13648
13923
  )
13649
13924
  }
@@ -13780,7 +14055,7 @@ function registerUiAgentGenericTools(server2, ctx, runtime) {
13780
14055
  title: "Poll Browsing Agent Task Status",
13781
14056
  description: "Returns the current state of a browsing-agent task by `task_id`, including its result once finished. In the local CLI, ui_agent_ask already returns the finished result, so this is mainly for re-reading a task within the same session. Task records do not survive the CLI process exiting. Requires `read` scope.",
13782
14057
  inputSchema: {
13783
- task_id: z29.string().describe("Task ID returned by ui_agent_ask")
14058
+ task_id: z30.string().describe("Task ID returned by ui_agent_ask")
13784
14059
  }
13785
14060
  },
13786
14061
  async (args) => {
@@ -13821,6 +14096,53 @@ function registerUiAgentGenericTools(server2, ctx, runtime) {
13821
14096
  );
13822
14097
  }
13823
14098
 
14099
+ // src/storefront-api-call.ts
14100
+ var STOREFRONT_API_DEFAULT_BASE_URL = "https://api.carrier.llc";
14101
+ var READ_TIMEOUT_MS = 1e4;
14102
+ var WRITE_TIMEOUT_MS2 = 3e4;
14103
+ function createStorefrontApiCall(options) {
14104
+ return async (request, extra) => {
14105
+ const token2 = await options.getToken(extra);
14106
+ if (!token2) {
14107
+ return {
14108
+ ok: false,
14109
+ status: 401,
14110
+ body: {
14111
+ error: "carrier_api_auth_required",
14112
+ message: "No Carrier API credential is available for this session, so the storefront call was not attempted."
14113
+ }
14114
+ };
14115
+ }
14116
+ const base = (options.baseUrl?.trim() || STOREFRONT_API_DEFAULT_BASE_URL).replace(/\/+$/, "");
14117
+ const headers = {
14118
+ Authorization: `Bearer ${token2}`,
14119
+ Accept: "application/json"
14120
+ };
14121
+ if (request.body !== void 0) headers["Content-Type"] = "application/json";
14122
+ if (request.idempotencyKey !== void 0) headers["Idempotency-Key"] = request.idempotencyKey;
14123
+ if (request.confirmToken !== void 0) headers["X-Confirm-Token"] = request.confirmToken;
14124
+ const response = await fetch(`${base}${request.path}`, {
14125
+ method: request.method,
14126
+ redirect: "error",
14127
+ headers,
14128
+ ...request.body !== void 0 ? { body: JSON.stringify(request.body) } : {},
14129
+ signal: AbortSignal.timeout(request.method === "GET" ? READ_TIMEOUT_MS : WRITE_TIMEOUT_MS2)
14130
+ });
14131
+ const text = await response.text();
14132
+ let body2;
14133
+ if (text.trim() === "") {
14134
+ body2 = {};
14135
+ } else {
14136
+ try {
14137
+ body2 = JSON.parse(text);
14138
+ } catch {
14139
+ body2 = { message: text };
14140
+ }
14141
+ }
14142
+ return { ok: response.ok, status: response.status, body: body2 };
14143
+ };
14144
+ }
14145
+
13824
14146
  // src/index.ts
13825
14147
  var baseUrl = process.env.CARRIER_OCS_BASE_URL ?? process.env.ESIMVAULT_BASE_URL ?? "https://ocs.esimvault.cloud";
13826
14148
  var token = process.env.CARRIER_OCS_API_TOKEN ?? process.env.ESIMVAULT_API_TOKEN;
@@ -13954,6 +14276,16 @@ registerStorefrontLogoTools(
13954
14276
  );
13955
14277
  registerStorefrontDeployTools(server, props);
13956
14278
  registerStorefrontPlanTools(server, props);
14279
+ registerStorefrontManagementTools(
14280
+ server,
14281
+ props,
14282
+ createStorefrontApiCall({
14283
+ baseUrl: process.env.CARRIER_API_URL,
14284
+ getToken: () => process.env.CARRIER_API_KEY?.trim() || process.env.CARRIER_ORG_API_KEY?.trim() || void 0
14285
+ }),
14286
+ "rest",
14287
+ { exclude: new Set(Object.keys(STOREFRONT_PLAN_TOOL_SCOPES)) }
14288
+ );
13957
14289
  registerAtlasTools(server, toolCtx);
13958
14290
  registerAllPrompts(server);
13959
14291
  var transport = new StdioServerTransport();