@carrierllc/mcp 0.13.11 → 0.13.13

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.
@@ -1820,7 +1820,7 @@ function storefrontScreen(input) {
1820
1820
  // package.json
1821
1821
  var package_default = {
1822
1822
  name: "@carrierllc/mcp",
1823
- version: "0.13.11",
1823
+ version: "0.13.13",
1824
1824
  description: "Carrier MCP \u2014 natural-language control of MVNO/eSIM fleets via eSIMVault OCS. Stdio mode for direct integration with Claude Desktop, Cursor, Windsurf, and MCP-compatible clients. Ships the `carrier` CLI (plugin install + white-label eSIM storefront scaffold).",
1825
1825
  license: "MIT",
1826
1826
  author: "Carrier (Lifecycle Innovations Limited)",
@@ -1901,7 +1901,7 @@ var package_default = {
1901
1901
  // src/version.ts
1902
1902
  var CARRIER_VERSION = package_default.version;
1903
1903
 
1904
- // ../../packages/ocs-client/dist/chunk-66I2ZRZF.js
1904
+ // ../../packages/ocs-client/dist/chunk-BOZG5AMY.js
1905
1905
  var OCS_MAX_USAGE_WINDOW_DAYS = 7;
1906
1906
  function clampUsagePeriod(start, end, maxDays = OCS_MAX_USAGE_WINDOW_DAYS) {
1907
1907
  const endMs = Date.parse(`${end}T00:00:00Z`);
@@ -2143,27 +2143,48 @@ function addEsimStatusRow(acc, rec) {
2143
2143
  }
2144
2144
  function extractEsimStatusCounts(json) {
2145
2145
  const acc = emptyEsimStatusCounts();
2146
+ for (const row of extractEsimStatusByAccount(json)) {
2147
+ acc.active += row.active;
2148
+ acc.suspended += row.suspended;
2149
+ acc.inventory += row.inventory;
2150
+ acc.other += row.other;
2151
+ }
2152
+ acc.total = acc.active + acc.suspended + acc.inventory + acc.other;
2153
+ return acc;
2154
+ }
2155
+ function accountRows(json) {
2146
2156
  const root = json ?? {};
2147
2157
  const payload = root.data ?? root.esimStatusPerAccount ?? root;
2148
- const accounts = Array.isArray(payload) ? payload : Array.isArray(payload.account) ? payload.account : [];
2149
- for (const account of accounts) {
2158
+ if (Array.isArray(payload)) return payload;
2159
+ return Array.isArray(payload.account) ? payload.account : [];
2160
+ }
2161
+ function extractEsimStatusByAccount(json) {
2162
+ const out = [];
2163
+ for (const account of accountRows(json)) {
2150
2164
  const rec = account ?? {};
2165
+ const row = emptyEsimStatusCounts();
2166
+ const id = Number(rec.id ?? rec.accountId);
2167
+ if (rec.id !== void 0 || rec.accountId !== void 0) {
2168
+ if (Number.isFinite(id)) row.id = id;
2169
+ }
2170
+ if (typeof rec.name === "string") row.name = rec.name;
2151
2171
  const sponsors = Array.isArray(rec.sponsor) ? rec.sponsor : [];
2152
2172
  if (sponsors.length > 0) {
2153
2173
  for (const sp of sponsors) {
2154
2174
  const esim = sp?.esim ?? {};
2155
2175
  const statuses = Array.isArray(esim.status) ? esim.status : [];
2156
- for (const row of statuses) addEsimStatusRow(acc, row ?? {});
2176
+ for (const status of statuses) addEsimStatusRow(row, status ?? {});
2157
2177
  }
2158
- continue;
2178
+ } else {
2179
+ row.active += Number(rec.active ?? 0);
2180
+ row.suspended += Number(rec.suspended ?? 0);
2181
+ row.inventory += Number(rec.inventory ?? rec.notActivated ?? rec.free ?? 0);
2182
+ row.other += Number(rec.other ?? rec.terminated ?? 0);
2159
2183
  }
2160
- acc.active += Number(rec.active ?? 0);
2161
- acc.suspended += Number(rec.suspended ?? 0);
2162
- acc.inventory += Number(rec.inventory ?? rec.notActivated ?? rec.free ?? 0);
2163
- acc.other += Number(rec.other ?? rec.terminated ?? 0);
2184
+ row.total = row.active + row.suspended + row.inventory + row.other;
2185
+ out.push(row);
2164
2186
  }
2165
- acc.total = acc.active + acc.suspended + acc.inventory + acc.other;
2166
- return acc;
2187
+ return out;
2167
2188
  }
2168
2189
  function esimStatusPerAccountParams(args) {
2169
2190
  if (typeof args === "number") return { accountId: args };
@@ -2532,6 +2553,11 @@ function packageTemplateCreateParams(input) {
2532
2553
  }
2533
2554
  return out;
2534
2555
  }
2556
+ async function withTemplateResellerId(params, resolveId) {
2557
+ const existing = params["resellerid"];
2558
+ if (typeof existing === "number" && Number.isFinite(existing)) return params;
2559
+ return { ...params, resellerid: await resolveId() };
2560
+ }
2535
2561
  function packageTemplateCreateFromToolJson(template) {
2536
2562
  let parsed;
2537
2563
  try {
@@ -2679,7 +2705,7 @@ function packageTemplateModifyFromToolJson(changes, method) {
2679
2705
  return packageTemplateModifyParams(body, method);
2680
2706
  }
2681
2707
 
2682
- // ../../packages/ocs-client/dist/chunk-L4DSDLRS.js
2708
+ // ../../packages/ocs-client/dist/chunk-N2EPJJVN.js
2683
2709
  import { z } from "zod";
2684
2710
  var OCS_V1_METHODS = /* @__PURE__ */ new Set([
2685
2711
  "getResellerInfo",
@@ -3024,7 +3050,7 @@ async function runWithBudget(method, attempt, budget = ocsBudgetFor(method)) {
3024
3050
  throw lastTimeout ?? new OcsTimeoutError(method, budget.attemptMs, budget.totalMs, Math.max(attempts, 1));
3025
3051
  }
3026
3052
 
3027
- // ../../packages/ocs-client/dist/chunk-XP62UVUD.js
3053
+ // ../../packages/ocs-client/dist/chunk-KZB25Q7W.js
3028
3054
  var RATE_LIMIT = 10;
3029
3055
  var WINDOW_MS = 1e3;
3030
3056
  var windows = /* @__PURE__ */ new Map();
@@ -4107,6 +4133,113 @@ function applySubscriberFilters(raw, args) {
4107
4133
  }
4108
4134
  return rewrapSubscriberList(raw, envelope, rows, filtered, matched);
4109
4135
  }
4136
+ var OCS_SUBSCRIBER_SEARCH_KEYS = [
4137
+ "accountId",
4138
+ "iccid",
4139
+ "imsi",
4140
+ "msisdn",
4141
+ "activationCode",
4142
+ "iccidPrefix",
4143
+ "imsiPrefix",
4144
+ "msisdnPrefix"
4145
+ ];
4146
+ function hasSubscriberSearchKey(params) {
4147
+ return OCS_SUBSCRIBER_SEARCH_KEYS.some((key) => {
4148
+ const v = params[key];
4149
+ return v !== void 0 && v !== null && String(v).trim() !== "";
4150
+ });
4151
+ }
4152
+ function flattenResellerAccounts(raw) {
4153
+ const records = [];
4154
+ if (Array.isArray(raw)) {
4155
+ records.push(...raw);
4156
+ } else if (raw !== null && typeof raw === "object") {
4157
+ const obj = raw;
4158
+ if (Array.isArray(obj["reseller"])) {
4159
+ for (const entry of obj["reseller"]) {
4160
+ const accounts = entry?.["account"];
4161
+ if (Array.isArray(accounts)) records.push(...accounts);
4162
+ }
4163
+ }
4164
+ if (Array.isArray(obj["account"])) records.push(...obj["account"]);
4165
+ }
4166
+ const seen = /* @__PURE__ */ new Set();
4167
+ const out = [];
4168
+ for (const rec of records) {
4169
+ if (rec === null || typeof rec !== "object") continue;
4170
+ const r = rec;
4171
+ const id = Number(r["id"] ?? r["accountId"]);
4172
+ if (!Number.isFinite(id) || seen.has(id)) continue;
4173
+ seen.add(id);
4174
+ out.push(typeof r["name"] === "string" ? { id, name: r["name"] } : { id });
4175
+ }
4176
+ return out;
4177
+ }
4178
+ function pickDefaultAccount(accounts) {
4179
+ if (accounts.length === 0) return void 0;
4180
+ const first = [...accounts].sort((a, b) => a.id - b.id)[0];
4181
+ return {
4182
+ accountId: first.id,
4183
+ ...first.name !== void 0 ? { name: first.name } : {},
4184
+ accountCount: accounts.length
4185
+ };
4186
+ }
4187
+ var NO_ACCOUNTS_MESSAGE = "OCS requires a subscriber search key, and no default account could be chosen because this reseller has no accounts yet. Create an account in OCS, or pass accountId / set preferred_account_id once one exists.";
4188
+ function lookupFailedMessage(detail) {
4189
+ return `OCS requires a subscriber search key, and this organization's default account could not be looked up (${detail}). Pass accountId, or set preferred_account_id, or retry.`;
4190
+ }
4191
+ function errorText(err) {
4192
+ return err instanceof Error ? err.message : String(err);
4193
+ }
4194
+ async function resolveDefaultAccount(opts) {
4195
+ const cached = await opts.cache?.get().catch(() => null);
4196
+ if (cached && Number.isFinite(cached.accountId)) return { ok: true, ...cached };
4197
+ let resellerId;
4198
+ const given = Number(opts.resellerId);
4199
+ if (opts.resellerId !== void 0 && opts.resellerId !== "" && Number.isFinite(given)) {
4200
+ resellerId = given;
4201
+ } else {
4202
+ try {
4203
+ const info = await opts.call("getResellerInfo", {});
4204
+ const id = Number(info?.id);
4205
+ if (Number.isFinite(id)) resellerId = id;
4206
+ } catch {
4207
+ }
4208
+ }
4209
+ let raw;
4210
+ try {
4211
+ raw = await opts.call("listResellerAccount", resellerId !== void 0 ? { resellerId } : {});
4212
+ } catch (err) {
4213
+ return { ok: false, reason: "lookup_failed", message: lookupFailedMessage(errorText(err)) };
4214
+ }
4215
+ const pick = pickDefaultAccount(flattenResellerAccounts(raw));
4216
+ if (!pick) return { ok: false, reason: "no_accounts", message: NO_ACCOUNTS_MESSAGE };
4217
+ await opts.cache?.put(pick).catch(() => void 0);
4218
+ return { ok: true, ...pick };
4219
+ }
4220
+ function defaultAccountNote(pick) {
4221
+ const label = pick.name ? `${pick.accountId} (${pick.name})` : String(pick.accountId);
4222
+ return pick.accountCount > 1 ? `No account was specified, so this shows account ${label} only \u2014 the lowest of ${pick.accountCount} accounts under this reseller. Pass accountId to see another account.` : `No account was specified, so this shows account ${label}, the only account under this reseller.`;
4223
+ }
4224
+ async function scopeListSubscriberParams(opts) {
4225
+ if (opts.managed || hasSubscriberSearchKey(opts.params)) return { ok: true, params: opts.params };
4226
+ const preferred = Number(opts.preferredAccountId);
4227
+ if (opts.preferredAccountId !== void 0 && opts.preferredAccountId.trim() !== "" && Number.isFinite(preferred)) {
4228
+ return { ok: true, params: { ...opts.params, accountId: preferred } };
4229
+ }
4230
+ const resolved = await resolveDefaultAccount({
4231
+ call: opts.call,
4232
+ ...opts.resellerId !== void 0 ? { resellerId: opts.resellerId } : {},
4233
+ ...opts.cache ? { cache: opts.cache } : {}
4234
+ });
4235
+ if (!resolved.ok) return resolved;
4236
+ const { ok: _ok, ...pick } = resolved;
4237
+ return {
4238
+ ok: true,
4239
+ params: { ...opts.params, accountId: pick.accountId },
4240
+ defaultAccount: { ...pick, note: defaultAccountNote(pick) }
4241
+ };
4242
+ }
4110
4243
  var descriptions = /* @__PURE__ */ new Map();
4111
4244
  function recordToolDescription(name, description) {
4112
4245
  if (description) descriptions.set(name, description);
@@ -4743,11 +4876,13 @@ export {
4743
4876
  packageActivePeriodParams,
4744
4877
  recurringIdForPackage,
4745
4878
  extractEsimStatusCounts,
4879
+ extractEsimStatusByAccount,
4746
4880
  esimStatusPerAccountParams,
4747
4881
  ocsHlrBitrate,
4748
4882
  ocsHlrBitrateFromBps,
4749
4883
  ocsSimStatus,
4750
4884
  locationZoneCreateParams,
4885
+ withTemplateResellerId,
4751
4886
  packageTemplateCreateFromToolJson,
4752
4887
  packageTemplateModifyFromToolJson,
4753
4888
  getLimitForEndpoint,
@@ -4758,6 +4893,7 @@ export {
4758
4893
  buildListSubscriberParams,
4759
4894
  extractSubscriberStatus,
4760
4895
  applySubscriberFilters,
4896
+ scopeListSubscriberParams,
4761
4897
  recordToolDescription,
4762
4898
  buildRouterCatalog,
4763
4899
  ROUTER_RULES,
@@ -4818,4 +4954,4 @@ export {
4818
4954
  storefrontScreen,
4819
4955
  CARRIER_VERSION
4820
4956
  };
4821
- //# sourceMappingURL=chunk-ZLPXWOYO.js.map
4957
+ //# sourceMappingURL=chunk-OJITGTFO.js.map