@carrierllc/mcp 0.13.31 → 0.13.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  verifyStorefront,
45
45
  walletScreen,
46
46
  which
47
- } from "./chunk-EHJEAI4V.js";
47
+ } from "./chunk-2P76KIOS.js";
48
48
  import {
49
49
  copyTree,
50
50
  exists,
@@ -1289,11 +1289,11 @@ function formatAskAnswer(text3, tool, structured, intent = "") {
1289
1289
  const line = subscriberLine(value2);
1290
1290
  if (line) lines.push(line);
1291
1291
  }
1292
- } else if (found?.[0] === "reseller") {
1293
- const accounts = projectResellerAccounts(rows2);
1294
- lines.push(...facts(accounts.length ? accounts : rows2));
1295
- } else if (found?.[0] === "template" || found?.[0] === "prepaidPackageTemplate") {
1296
- lines.push(...facts(projectPackageTemplates(rows2) ?? rows2));
1292
+ } else if (tool === "list_reseller_accounts" && found?.[0] === "reseller" && rows2.length) {
1293
+ const nested = object(summary.nested)?.accounts;
1294
+ lines.push(...resellerAccountLines(rows2, measured(nested) ? nested : void 0));
1295
+ } else if (tool === "list_package_templates" && (found?.[0] === "template" || found?.[0] === "prepaidPackageTemplate") && rows2.length) {
1296
+ lines.push(...templateLines(rows2));
1297
1297
  } else lines.push(...facts(rows2));
1298
1298
  if (rows2.length > MAX_ROWS && noun === "subscribers") lines.push(`Showing ${MAX_ROWS} of ${rows2.length} returned rows. ${RAW_HINT}`);
1299
1299
  } else lines.push("Row details were not returned.");
@@ -1344,12 +1344,19 @@ var FIELD_TYPES = {
1344
1344
  packageId: "scalar",
1345
1345
  zoneId: "scalar",
1346
1346
  subscriberId: "scalar",
1347
- // Live listPrepaidPackageTemplate rows use these wire names, not templateId.
1347
+ // packageOnly is a boolean on the live listResellerAccount account rows.
1348
+ packageOnly: "boolean"
1349
+ };
1350
+ var TEMPLATE_FIELD_TYPES = {
1348
1351
  prepaidpackagetemplateid: "scalar",
1349
1352
  prepaidpackagetemplatename: "string",
1350
1353
  resellerid: "scalar",
1351
- locationzoneid: "scalar",
1352
- // listResellerAccount account rows. packageOnly is a boolean on the live shape.
1354
+ locationzoneid: "scalar"
1355
+ };
1356
+ var ACCOUNT_FIELD_TYPES = {
1357
+ id: "scalar",
1358
+ name: "string",
1359
+ balance: "money",
1353
1360
  packageOnly: "boolean"
1354
1361
  };
1355
1362
  function inline(value) {
@@ -1362,13 +1369,18 @@ function label(key) {
1362
1369
  const words = key.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ");
1363
1370
  return words.charAt(0).toUpperCase() + words.slice(1);
1364
1371
  }
1372
+ function validField(expected, value) {
1373
+ if (expected === "scalar") return typeof value === "string" || typeof value === "number" && Number.isFinite(value);
1374
+ if (expected === "money") return typeof value === "number" && Number.isFinite(value) || typeof value === "string" && /^[+-]?\d+(?:\.\d+)?$/.test(value) && Number.isFinite(Number(value));
1375
+ if (!expected) return false;
1376
+ return typeof value === expected && (expected !== "number" || Number.isFinite(value));
1377
+ }
1365
1378
  function recordFacts(record2, fields = FIELD_TYPES, warnUnknown = true) {
1366
1379
  const lines = [];
1367
1380
  let unsupported = false;
1368
1381
  for (const [key, value] of Object.entries(record2)) {
1369
1382
  const expected = Object.hasOwn(fields, key) ? fields[key] : void 0;
1370
- const valid = expected === "scalar" ? typeof value === "string" || typeof value === "number" && Number.isFinite(value) : expected === "money" ? typeof value === "number" && Number.isFinite(value) || typeof value === "string" && /^[+-]?\d+(?:\.\d+)?$/.test(value) && Number.isFinite(Number(value)) : typeof value === expected && (expected !== "number" || Number.isFinite(value));
1371
- if (!expected || !valid) {
1383
+ if (!expected || !validField(expected, value)) {
1372
1384
  if (warnUnknown || expected) unsupported = true;
1373
1385
  continue;
1374
1386
  }
@@ -1378,39 +1390,99 @@ function recordFacts(record2, fields = FIELD_TYPES, warnUnknown = true) {
1378
1390
  return lines.length ? lines : ["No result fields were returned."];
1379
1391
  }
1380
1392
  var TEMPLATE_WIRE_FIELDS = ["prepaidpackagetemplateid", "prepaidpackagetemplatename", "resellerid", "locationzoneid"];
1381
- var ACCOUNT_WIRE_FIELDS = ["id", "name", "balance", "packageOnly"];
1382
- function projectResellerAccounts(rows2) {
1383
- const accounts = [];
1384
- for (const row of rows2) {
1385
- const reseller = object(row);
1386
- if (!reseller || !Array.isArray(reseller.account)) continue;
1387
- for (const item of reseller.account) {
1393
+ var ACCOUNT_FIELD_ORDER = ["name", "balance", "packageOnly"];
1394
+ function own(record2, key) {
1395
+ return Object.hasOwn(record2, key) ? record2[key] : void 0;
1396
+ }
1397
+ function identifier(value, state) {
1398
+ if (value === void 0) return void 0;
1399
+ if (!validField("scalar", value)) {
1400
+ state.unsupported++;
1401
+ return void 0;
1402
+ }
1403
+ return inline(value) || void 0;
1404
+ }
1405
+ function resellerAccountLines(rows2, nestedAccounts) {
1406
+ const state = { unsupported: 0 };
1407
+ const accountLines = [];
1408
+ let listed = 0;
1409
+ let empty = 0;
1410
+ for (const entry of rows2) {
1411
+ const reseller = object(entry);
1412
+ if (!reseller) {
1413
+ state.unsupported++;
1414
+ continue;
1415
+ }
1416
+ const accounts = own(reseller, "account");
1417
+ if (!Array.isArray(accounts)) {
1418
+ state.unsupported++;
1419
+ continue;
1420
+ }
1421
+ if (accounts.length === 0) {
1422
+ empty++;
1423
+ continue;
1424
+ }
1425
+ const resellerId = identifier(own(reseller, "id"), state);
1426
+ const resellerName = own(reseller, "name");
1427
+ if (resellerName !== void 0 && typeof resellerName !== "string") state.unsupported++;
1428
+ const association = `reseller ${resellerId ?? "(identifier not reported)"}${typeof resellerName === "string" && inline(resellerName) ? ` (${inline(resellerName)})` : ""}`;
1429
+ for (const item of accounts) {
1388
1430
  const account = object(item);
1389
- if (!account) continue;
1390
- const projected = {};
1391
- if (typeof reseller.id === "number" && Number.isFinite(reseller.id)) projected.resellerId = reseller.id;
1392
- for (const key of ACCOUNT_WIRE_FIELDS) {
1393
- if (Object.hasOwn(account, key)) projected[key] = account[key];
1431
+ if (!account) {
1432
+ state.unsupported++;
1433
+ continue;
1434
+ }
1435
+ listed++;
1436
+ if (accountLines.length >= MAX_ROWS) continue;
1437
+ const parts = [`Account ${identifier(own(account, "id"), state) ?? "(identifier not reported)"}`, association];
1438
+ for (const key of ACCOUNT_FIELD_ORDER) {
1439
+ const value = own(account, key);
1440
+ if (value === void 0) continue;
1441
+ if (!validField(ACCOUNT_FIELD_TYPES[key], value)) {
1442
+ state.unsupported++;
1443
+ continue;
1444
+ }
1445
+ parts.push(`${label(key)}: ${typeof value === "boolean" ? String(value) : inline(value)}`);
1394
1446
  }
1395
- accounts.push(projected);
1447
+ accountLines.push(parts.join("; "));
1396
1448
  }
1397
1449
  }
1398
- return accounts;
1399
- }
1400
- function projectPackageTemplates(rows2) {
1401
- const projected = [];
1402
- for (const row of rows2) {
1450
+ const lines = [];
1451
+ if (nestedAccounts !== void 0 && listed < nestedAccounts) {
1452
+ lines.push(`Only ${listed} of the reported ${nestedAccounts} accounts are present in the response; the remaining account details are unavailable.`);
1453
+ }
1454
+ if (state.unsupported) lines.push(UNSUPPORTED);
1455
+ if (empty) lines.push(`No accounts are listed under ${empty} ${empty === 1 ? "reseller" : "resellers"} in the returned rows.`);
1456
+ if (listed > MAX_ROWS) lines.push(`Showing ${accountLines.length} of ${listed} returned accounts. ${RAW_HINT}`);
1457
+ return [...lines, ...accountLines];
1458
+ }
1459
+ function templateLines(rows2) {
1460
+ const state = { unsupported: 0 };
1461
+ const itemLines = [];
1462
+ rows2.forEach((row, i) => {
1403
1463
  const record2 = object(row);
1404
- if (!record2) return void 0;
1464
+ if (!record2) {
1465
+ state.unsupported++;
1466
+ return;
1467
+ }
1405
1468
  const wire = Object.hasOwn(record2, "prepaidpackagetemplateid") || Object.hasOwn(record2, "prepaidpackagetemplatename");
1406
- if (!wire) return void 0;
1407
- const next = {};
1408
- for (const key of TEMPLATE_WIRE_FIELDS) {
1409
- if (Object.hasOwn(record2, key)) next[key] = record2[key];
1469
+ const types = wire ? TEMPLATE_FIELD_TYPES : FIELD_TYPES;
1470
+ const entries = wire ? TEMPLATE_WIRE_FIELDS.filter((key) => Object.hasOwn(record2, key)).map((key) => [key, record2[key]]) : Object.entries(record2);
1471
+ const parts = [];
1472
+ for (const [key, value] of entries) {
1473
+ const expected = Object.hasOwn(types, key) ? types[key] : void 0;
1474
+ if (!expected || !validField(expected, value)) {
1475
+ state.unsupported++;
1476
+ continue;
1477
+ }
1478
+ parts.push(`${label(key)}: ${typeof value === "boolean" ? String(value) : inline(value)}`);
1410
1479
  }
1411
- projected.push(next);
1412
- }
1413
- return projected;
1480
+ if (itemLines.length < MAX_ROWS) itemLines.push(`Item ${i + 1}: ${parts.length ? parts.join("; ") : "No result fields were returned."}`);
1481
+ });
1482
+ const lines = [];
1483
+ if (state.unsupported) lines.push(UNSUPPORTED);
1484
+ if (rows2.length > MAX_ROWS) lines.push(`Showing ${MAX_ROWS} of ${rows2.length} returned rows. ${RAW_HINT}`);
1485
+ return [...lines, ...itemLines];
1414
1486
  }
1415
1487
  function facts(value) {
1416
1488
  if (Array.isArray(value)) {