@carrierllc/mcp 0.13.80 → 0.13.81

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-QOEAUPWD.js";
95
95
  import "./chunk-SHKKVIIA.js";
96
96
 
97
97
  // src/index.ts
@@ -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