@carrierllc/mcp 0.13.85 → 0.13.87
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/{chunk-LF5NVSIU.js → chunk-RCYBPELI.js} +2 -2
- package/dist/{chunk-LF5NVSIU.js.map → chunk-RCYBPELI.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/storefront/src/components/landing/HowItWorks.tsx +1 -1
- package/templates/storefront/src/vendor/carrier/country-offers.ts +179 -8
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrierllc/mcp",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.87",
|
|
4
4
|
"description": "Carrier MCP — natural-language control of MVNO/eSIM fleets via the network 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).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Carrier (Lifecycle Innovations Limited)",
|
|
@@ -67,28 +67,199 @@ export function countryOffers(plans: CoverablePlan[]): CountryOffer[] {
|
|
|
67
67
|
return offers.sort((a, b) => a.name.localeCompare(b.name, "en"));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Names buyers type that Intl.DisplayNames does not know: nicknames and
|
|
72
|
+
* colloquial forms. Keys are stored pre-folded (see searchFold). Kept in
|
|
73
|
+
* step with SEARCH_ALIASES in packages/storefront-runtime/src/countries.ts.
|
|
74
|
+
*/
|
|
71
75
|
const SEARCH_ALIASES: Record<string, string> = {
|
|
72
76
|
turkey: "TR",
|
|
77
|
+
turkije: "TR",
|
|
73
78
|
"czech republic": "CZ",
|
|
79
|
+
czechia: "CZ",
|
|
80
|
+
tsjechie: "CZ",
|
|
74
81
|
uk: "GB",
|
|
82
|
+
engeland: "GB",
|
|
83
|
+
"great britain": "GB",
|
|
84
|
+
britain: "GB",
|
|
85
|
+
"groot-brittannie": "GB",
|
|
86
|
+
"verenigd koninkrijk": "GB",
|
|
75
87
|
usa: "US",
|
|
88
|
+
america: "US",
|
|
89
|
+
amerika: "US",
|
|
90
|
+
"verenigde staten": "US",
|
|
76
91
|
uae: "AE",
|
|
77
92
|
holland: "NL",
|
|
93
|
+
nederland: "NL",
|
|
94
|
+
spanje: "ES",
|
|
95
|
+
espanol: "ES",
|
|
96
|
+
griekenland: "GR",
|
|
97
|
+
egypte: "EG",
|
|
98
|
+
marokko: "MA",
|
|
99
|
+
curacao: "CW",
|
|
100
|
+
"ivory coast": "CI",
|
|
101
|
+
duitsland: "DE",
|
|
102
|
+
frankrijk: "FR",
|
|
103
|
+
italie: "IT",
|
|
104
|
+
oostenrijk: "AT",
|
|
105
|
+
zwitserland: "CH",
|
|
106
|
+
belgie: "BE",
|
|
107
|
+
kroatie: "HR",
|
|
78
108
|
};
|
|
79
109
|
|
|
110
|
+
/** Locales whose Intl region names a buyer may type (CAR-471). */
|
|
111
|
+
const SEARCH_LOCALES = ["en", "nl", "nb", "es", "fr", "de"] as const;
|
|
112
|
+
|
|
113
|
+
const SEARCH_DISPLAY_NAMES = SEARCH_LOCALES.map((locale) => {
|
|
114
|
+
try {
|
|
115
|
+
return new Intl.DisplayNames([locale], { type: "region" });
|
|
116
|
+
} catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
/** ISO 3166-1 alpha-3 codes by alpha-2 code, so "USA" and "NLD" also find their country. */
|
|
122
|
+
const ALPHA3_PAIRS = [
|
|
123
|
+
"AD:AND AE:ARE AF:AFG AG:ATG AI:AIA AL:ALB AM:ARM AO:AGO AQ:ATA AR:ARG AS:ASM AT:AUT AU:AUS AW:ABW AX:ALA AZ:AZE",
|
|
124
|
+
"BA:BIH BB:BRB BD:BGD BE:BEL BF:BFA BG:BGR BH:BHR BI:BDI BJ:BEN BL:BLM BM:BMU BN:BRN BO:BOL BQ:BES BR:BRA BS:BHS BT:BTN BV:BVT BW:BWA BY:BLR BZ:BLZ",
|
|
125
|
+
"CA:CAN CC:CCK CD:COD CF:CAF CG:COG CH:CHE CI:CIV CK:COK CL:CHL CM:CMR CN:CHN CO:COL CR:CRI CU:CUB CV:CPV CW:CUW CX:CXR CY:CYP CZ:CZE",
|
|
126
|
+
"DE:DEU DJ:DJI DK:DNK DM:DMA DO:DOM DZ:DZA",
|
|
127
|
+
"EC:ECU EE:EST EG:EGY EH:ESH ER:ERI ES:ESP ET:ETH",
|
|
128
|
+
"FI:FIN FJ:FJI FK:FLK FM:FSM FO:FRO FR:FRA",
|
|
129
|
+
"GA:GAB GB:GBR GD:GRD GE:GEO GF:GUF GG:GGY GH:GHA GI:GIB GL:GRL GM:GMB GN:GIN GP:GLP GQ:GNQ GR:GRC GS:SGS GT:GTM GU:GUM GW:GNB GY:GUY",
|
|
130
|
+
"HK:HKG HM:HMD HN:HND HR:HRV HT:HTI HU:HUN",
|
|
131
|
+
"ID:IDN IE:IRL IL:ISR IM:IMN IN:IND IO:IOT IQ:IRQ IR:IRN IS:ISL IT:ITA",
|
|
132
|
+
"JE:JEY JM:JAM JO:JOR JP:JPN",
|
|
133
|
+
"KE:KEN KG:KGZ KH:KHM KI:KIR KM:COM KN:KNA KP:PRK KR:KOR KW:KWT KY:CYM KZ:KAZ",
|
|
134
|
+
"LA:LAO LB:LBN LC:LCA LI:LIE LK:LKA LR:LBR LS:LSO LT:LTU LU:LUX LV:LVA LY:LBY",
|
|
135
|
+
"MA:MAR MC:MCO MD:MDA ME:MNE MF:MAF MG:MDG MH:MHL MK:MKD ML:MLI MM:MMR MN:MNG MO:MAC MP:MNP MQ:MTQ MR:MRT MS:MSR MT:MLT MU:MUS MV:MDV MW:MWI MX:MEX MY:MYS MZ:MOZ",
|
|
136
|
+
"NA:NAM NC:NCL NE:NER NF:NFK NG:NGA NI:NIC NL:NLD NO:NOR NP:NPL NR:NRU NU:NIU NZ:NZL",
|
|
137
|
+
"OM:OMN",
|
|
138
|
+
"PA:PAN PE:PER PF:PYF PG:PNG PH:PHL PK:PAK PL:POL PM:SPM PN:PCN PR:PRI PS:PSE PT:PRT PW:PLW PY:PRY",
|
|
139
|
+
"QA:QAT",
|
|
140
|
+
"RE:REU RO:ROU RS:SRB RU:RUS RW:RWA",
|
|
141
|
+
"SA:SAU SB:SLB SC:SYC SD:SDN SE:SWE SG:SGP SH:SHN SI:SVN SJ:SJM SK:SVK SL:SLE SM:SMR SN:SEN SO:SOM SR:SUR SS:SSD ST:STP SV:SLV SX:SXM SY:SYR SZ:SWZ",
|
|
142
|
+
"TC:TCA TD:TCD TF:ATF TG:TGO TH:THA TJ:TJK TK:TKL TL:TLS TM:TKM TN:TUN TO:TON TR:TUR TT:TTO TV:TUV TW:TWN TZ:TZA",
|
|
143
|
+
"UA:UKR UG:UGA UM:UMI US:USA UY:URY UZ:UZB",
|
|
144
|
+
"VA:VAT VC:VCT VE:VEN VG:VGB VI:VIR VN:VNM VU:VUT",
|
|
145
|
+
"WF:WLF WS:WSM",
|
|
146
|
+
"YE:YEM YT:MYT",
|
|
147
|
+
"ZA:ZAF ZM:ZMB ZW:ZWE",
|
|
148
|
+
].join(" ");
|
|
149
|
+
|
|
150
|
+
const ALPHA3_BY_ALPHA2 = new Map<string, string>(
|
|
151
|
+
ALPHA3_PAIRS.split(" ").map((pair) => {
|
|
152
|
+
const [alpha2, alpha3] = pair.split(":");
|
|
153
|
+
return [alpha2, alpha3] as const;
|
|
154
|
+
}),
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Search normalization: case and accents folded, hyphens and apostrophes
|
|
159
|
+
* unified ("Pays-Bas", "Côte d'Ivoire"), and a leading "the" dropped so
|
|
160
|
+
* "The Netherlands" and "Netherlands" are the same search (CAR-471).
|
|
161
|
+
*/
|
|
162
|
+
function searchFold(value: string): string {
|
|
163
|
+
const folded = value
|
|
164
|
+
.normalize("NFD")
|
|
165
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
166
|
+
.toLowerCase()
|
|
167
|
+
.replace(/-/g, " ")
|
|
168
|
+
.replace(/[\u2018\u2019]/g, "'")
|
|
169
|
+
.replace(/'/g, "")
|
|
170
|
+
.replace(/\s+/g, " ")
|
|
171
|
+
.trim();
|
|
172
|
+
return folded.startsWith("the ") ? folded.slice(4) : folded;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const SEARCH_FORMS_BY_CODE = new Map<string, Set<string>>();
|
|
176
|
+
|
|
177
|
+
function addSearchForm(code: string, raw: string | undefined): void {
|
|
178
|
+
if (!raw) return;
|
|
179
|
+
const form = searchFold(raw);
|
|
180
|
+
if (form === "") return;
|
|
181
|
+
const forms = SEARCH_FORMS_BY_CODE.get(code) ?? new Set<string>();
|
|
182
|
+
forms.add(form);
|
|
183
|
+
SEARCH_FORMS_BY_CODE.set(code, forms);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
for (let first = 65; first <= 90; first += 1) {
|
|
187
|
+
for (let second = 65; second <= 90; second += 1) {
|
|
188
|
+
const code = String.fromCharCode(first, second);
|
|
189
|
+
// "UK" is reserved, never a stored code; it reaches GB via SEARCH_ALIASES.
|
|
190
|
+
if (code === "UK") continue;
|
|
191
|
+
let known = false;
|
|
192
|
+
for (const names of SEARCH_DISPLAY_NAMES) {
|
|
193
|
+
if (!names) continue;
|
|
194
|
+
try {
|
|
195
|
+
const label = names.of(code);
|
|
196
|
+
if (label && label.toUpperCase() !== code) {
|
|
197
|
+
addSearchForm(code, label);
|
|
198
|
+
known = true;
|
|
199
|
+
}
|
|
200
|
+
} catch {
|
|
201
|
+
// Not a region code in this locale.
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (!known) continue;
|
|
205
|
+
addSearchForm(code, code);
|
|
206
|
+
addSearchForm(code, ALPHA3_BY_ALPHA2.get(code));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
for (const [alias, code] of Object.entries(SEARCH_ALIASES)) {
|
|
211
|
+
addSearchForm(code, alias);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function searchFormsFor(offer: CountryOffer): ReadonlySet<string> {
|
|
215
|
+
const forms = new Set<string>(SEARCH_FORMS_BY_CODE.get(offer.code.trim().toUpperCase()) ?? []);
|
|
216
|
+
addTo(forms, offer.name);
|
|
217
|
+
addTo(forms, offer.code);
|
|
218
|
+
return forms;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function addTo(forms: Set<string>, raw: string): void {
|
|
222
|
+
const form = searchFold(raw);
|
|
223
|
+
if (form !== "") forms.add(form);
|
|
224
|
+
}
|
|
225
|
+
|
|
80
226
|
/** Shown before the buyer types, in this order, and only when the catalog sells them. */
|
|
81
227
|
export const POPULAR_COUNTRY_CODES = ["DE", "FR", "ES", "IT", "GB", "US", "JP", "TR", "NL", "TH"] as const;
|
|
82
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Search by name or code, forgiving about how the buyer types it (CAR-471):
|
|
231
|
+
* case, accents, a leading "the", nicknames, ISO alpha-2/alpha-3 codes and
|
|
232
|
+
* the country's name in English, Dutch, Norwegian, Spanish, French or German
|
|
233
|
+
* all resolve. Exact matches win over prefix matches, which win over partial
|
|
234
|
+
* matches, so "UK" finds only the United Kingdom, never Ukraine. An empty
|
|
235
|
+
* query returns everything.
|
|
236
|
+
*/
|
|
83
237
|
export function filterCountryOffers(offers: CountryOffer[], query: string): CountryOffer[] {
|
|
84
|
-
const needle =
|
|
238
|
+
const needle = searchFold(query);
|
|
85
239
|
if (needle === "") return offers;
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
240
|
+
const exact: CountryOffer[] = [];
|
|
241
|
+
const prefix: CountryOffer[] = [];
|
|
242
|
+
const partial: CountryOffer[] = [];
|
|
243
|
+
for (const offer of offers) {
|
|
244
|
+
const forms = searchFormsFor(offer);
|
|
245
|
+
if (forms.has(needle)) {
|
|
246
|
+
exact.push(offer);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
let tier = -1;
|
|
250
|
+
for (const form of forms) {
|
|
251
|
+
if (form.startsWith(needle)) {
|
|
252
|
+
tier = 1;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (tier === -1 && form.includes(needle)) tier = 2;
|
|
256
|
+
}
|
|
257
|
+
if (tier === 1) prefix.push(offer);
|
|
258
|
+
else if (tier === 2) partial.push(offer);
|
|
259
|
+
}
|
|
260
|
+
if (exact.length > 0) return exact;
|
|
261
|
+
if (prefix.length > 0) return prefix;
|
|
262
|
+
return partial;
|
|
92
263
|
}
|
|
93
264
|
|
|
94
265
|
export function visibleCountryOffers(offers: CountryOffer[], query: string): CountryOffer[] {
|