@carrierllc/mcp 0.0.1 → 0.2.0
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/README.md +216 -3
- package/dist/apps/app-state.d.ts +19 -0
- package/dist/apps/app-state.d.ts.map +1 -0
- package/dist/apps/app-state.js +28 -0
- package/dist/apps/app-state.js.map +1 -0
- package/dist/apps/balance-topup.d.ts +19 -0
- package/dist/apps/balance-topup.d.ts.map +1 -0
- package/dist/apps/balance-topup.js +121 -0
- package/dist/apps/balance-topup.js.map +1 -0
- package/dist/apps/fleet-health-app.d.ts +29 -0
- package/dist/apps/fleet-health-app.d.ts.map +1 -0
- package/dist/apps/fleet-health-app.js +152 -0
- package/dist/apps/fleet-health-app.js.map +1 -0
- package/dist/apps/index.d.ts +37 -0
- package/dist/apps/index.d.ts.map +1 -0
- package/dist/apps/index.js +42 -0
- package/dist/apps/index.js.map +1 -0
- package/dist/apps/provisioning-wizard.d.ts +11 -0
- package/dist/apps/provisioning-wizard.d.ts.map +1 -0
- package/dist/apps/provisioning-wizard.js +345 -0
- package/dist/apps/provisioning-wizard.js.map +1 -0
- package/dist/audit.d.ts +31 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +42 -0
- package/dist/audit.js.map +1 -0
- package/dist/billing-thresholds.d.ts +71 -0
- package/dist/billing-thresholds.d.ts.map +1 -0
- package/dist/billing-thresholds.js +238 -0
- package/dist/billing-thresholds.js.map +1 -0
- package/dist/billing.d.ts +95 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +239 -0
- package/dist/billing.js.map +1 -0
- package/dist/clerk.d.ts +125 -0
- package/dist/clerk.d.ts.map +1 -0
- package/dist/clerk.js +389 -0
- package/dist/clerk.js.map +1 -0
- package/dist/client.d.ts +35 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +75 -0
- package/dist/client.js.map +1 -0
- package/dist/credits.d.ts +165 -0
- package/dist/credits.d.ts.map +1 -0
- package/dist/credits.js +483 -0
- package/dist/credits.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/intelligence.d.ts +4 -0
- package/dist/intelligence.d.ts.map +1 -0
- package/dist/intelligence.js +899 -0
- package/dist/intelligence.js.map +1 -0
- package/dist/list-recent-ocs-events.d.ts +48 -0
- package/dist/list-recent-ocs-events.d.ts.map +1 -0
- package/dist/list-recent-ocs-events.js +160 -0
- package/dist/list-recent-ocs-events.js.map +1 -0
- package/dist/manus-client.d.ts +429 -0
- package/dist/manus-client.d.ts.map +1 -0
- package/dist/manus-client.js +401 -0
- package/dist/manus-client.js.map +1 -0
- package/dist/manus-common.d.ts +5 -0
- package/dist/manus-common.d.ts.map +1 -0
- package/dist/manus-common.js +5 -0
- package/dist/manus-common.js.map +1 -0
- package/dist/manus-schedule.d.ts +74 -0
- package/dist/manus-schedule.d.ts.map +1 -0
- package/dist/manus-schedule.js +213 -0
- package/dist/manus-schedule.js.map +1 -0
- package/dist/manus-usage.d.ts +32 -0
- package/dist/manus-usage.d.ts.map +1 -0
- package/dist/manus-usage.js +120 -0
- package/dist/manus-usage.js.map +1 -0
- package/dist/manus-webhook.d.ts +60 -0
- package/dist/manus-webhook.d.ts.map +1 -0
- package/dist/manus-webhook.js +361 -0
- package/dist/manus-webhook.js.map +1 -0
- package/dist/pricing-tools.d.ts +26 -0
- package/dist/pricing-tools.d.ts.map +1 -0
- package/dist/pricing-tools.js +428 -0
- package/dist/pricing-tools.js.map +1 -0
- package/dist/projects-tools.d.ts +39 -0
- package/dist/projects-tools.d.ts.map +1 -0
- package/dist/projects-tools.js +545 -0
- package/dist/projects-tools.js.map +1 -0
- package/dist/prompts.d.ts +7 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +151 -0
- package/dist/prompts.js.map +1 -0
- package/dist/stripe-connect-tools.d.ts +33 -0
- package/dist/stripe-connect-tools.d.ts.map +1 -0
- package/dist/stripe-connect-tools.js +504 -0
- package/dist/stripe-connect-tools.js.map +1 -0
- package/dist/timing-safe-equal.d.ts +5 -0
- package/dist/timing-safe-equal.d.ts.map +1 -0
- package/dist/timing-safe-equal.js +13 -0
- package/dist/timing-safe-equal.js.map +1 -0
- package/dist/tools-backlog.d.ts +28 -0
- package/dist/tools-backlog.d.ts.map +1 -0
- package/dist/tools-backlog.js +315 -0
- package/dist/tools-backlog.js.map +1 -0
- package/dist/tools-carrier-ask.d.ts +138 -0
- package/dist/tools-carrier-ask.d.ts.map +1 -0
- package/dist/tools-carrier-ask.js +913 -0
- package/dist/tools-carrier-ask.js.map +1 -0
- package/dist/tools-pricing.d.ts +18 -0
- package/dist/tools-pricing.d.ts.map +1 -0
- package/dist/tools-pricing.js +172 -0
- package/dist/tools-pricing.js.map +1 -0
- package/dist/tools-ui-agent-ask.d.ts +29 -0
- package/dist/tools-ui-agent-ask.d.ts.map +1 -0
- package/dist/tools-ui-agent-ask.js +272 -0
- package/dist/tools-ui-agent-ask.js.map +1 -0
- package/dist/tools-ui-agent-schedule.d.ts +29 -0
- package/dist/tools-ui-agent-schedule.d.ts.map +1 -0
- package/dist/tools-ui-agent-schedule.js +517 -0
- package/dist/tools-ui-agent-schedule.js.map +1 -0
- package/dist/tools-ui-agent.d.ts +40 -0
- package/dist/tools-ui-agent.d.ts.map +1 -0
- package/dist/tools-ui-agent.js +508 -0
- package/dist/tools-ui-agent.js.map +1 -0
- package/dist/tools.d.ts +60 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +1295 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +291 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -7
- package/index.js +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,218 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @carrierllc/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Natural language control of your MVNO/eSIM fleet. 43 OCS tools + 8 intelligence composites + 5 prompts. Direct stdio mode — no OAuth required.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@carrierllc/mcp)
|
|
6
|
+
[](https://github.com/Lifecycle-Innovations-Limited/carrier.llc/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
ESIMVAULT_API_TOKEN=your_key npx -y @carrierllc/mcp
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Get a key at [mcp.carrier.llc](https://mcp.carrier.llc).
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Install in Claude Desktop
|
|
21
|
+
|
|
22
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"mcpServers": {
|
|
27
|
+
"carrier": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["-y", "@carrierllc/mcp"],
|
|
30
|
+
"env": {
|
|
31
|
+
"ESIMVAULT_API_TOKEN": "YOUR_KEY"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Install in Cursor
|
|
39
|
+
|
|
40
|
+
Add to `~/.cursor/mcp.json`:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"carrier": {
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["-y", "@carrierllc/mcp"],
|
|
48
|
+
"env": {
|
|
49
|
+
"ESIMVAULT_API_TOKEN": "YOUR_KEY"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Install in Windsurf
|
|
57
|
+
|
|
58
|
+
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"carrier": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "@carrierllc/mcp"],
|
|
66
|
+
"env": {
|
|
67
|
+
"ESIMVAULT_API_TOKEN": "YOUR_KEY"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Remote HTTP (OAuth 2.1)
|
|
75
|
+
|
|
76
|
+
For multi-user deployments with OAuth 2.1 + PKCE, use the remote endpoint:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"carrier": {
|
|
82
|
+
"type": "http",
|
|
83
|
+
"url": "https://mcp.carrier.llc/mcp"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Environment variables
|
|
92
|
+
|
|
93
|
+
| Variable | Required | Default | Description |
|
|
94
|
+
|----------|----------|---------|-------------|
|
|
95
|
+
| `ESIMVAULT_API_TOKEN` | Yes | — | Your eSIMVault OCS API token |
|
|
96
|
+
| `CARRIER_OCS_API_TOKEN` | Alternative | — | Alias for `ESIMVAULT_API_TOKEN` |
|
|
97
|
+
| `CARRIER_OCS_BASE_URL` | No | `https://ocs.esimvault.cloud` | OCS base URL (no trailing slash) |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Tools (51 total)
|
|
102
|
+
|
|
103
|
+
### Reseller (6)
|
|
104
|
+
|
|
105
|
+
| Tool | Scope | Description |
|
|
106
|
+
|------|-------|-------------|
|
|
107
|
+
| `list_reseller_accounts` | read | List all accounts across all resellers |
|
|
108
|
+
| `get_reseller_info` | read | Retrieve reseller details |
|
|
109
|
+
| `esim_status_per_account` | read | eSIM status breakdown per account |
|
|
110
|
+
| `list_sponsors` | read | List all sponsor networks |
|
|
111
|
+
| `list_steering_lists` | read | List all network steering lists |
|
|
112
|
+
| `modify_account_balance` | write | Adjust or set reseller account balance |
|
|
113
|
+
|
|
114
|
+
### Subscriber (13)
|
|
115
|
+
|
|
116
|
+
| Tool | Scope | Description |
|
|
117
|
+
|------|-------|-------------|
|
|
118
|
+
| `get_subscriber` | read | Get full subscriber details by ICCID or MSISDN |
|
|
119
|
+
| `list_subscribers` | read | List subscribers with optional filters |
|
|
120
|
+
| `get_sim_provider_status` | read | Check SIM provider-level status |
|
|
121
|
+
| `get_subscriber_location` | read | Get last known subscriber location |
|
|
122
|
+
| `hlr_get_bitrate` | read | Get HLR bitrate for a subscriber |
|
|
123
|
+
| `modify_subscriber_balance` | write | Adjust or set subscriber balance |
|
|
124
|
+
| `modify_subscriber_status` | write | Change subscriber OCS status |
|
|
125
|
+
| `change_sim_status` | write | Change SIM status at provider level |
|
|
126
|
+
| `modify_subscriber_contact_info` | write | Update subscriber contact info |
|
|
127
|
+
| `set_subscriber_traffic_restrictions` | write | Configure traffic restrictions |
|
|
128
|
+
| `modify_subscriber_steering_list` | write | Change network steering list for a subscriber |
|
|
129
|
+
| `hlr_set_bitrate` | write | Set HLR bitrate for a subscriber |
|
|
130
|
+
| `move_subscriber_range_to_account` | write | Move subscriber range to another account |
|
|
131
|
+
|
|
132
|
+
### Packages (9)
|
|
133
|
+
|
|
134
|
+
| Tool | Scope | Description |
|
|
135
|
+
|------|-------|-------------|
|
|
136
|
+
| `list_subscriber_packages` | read | List all prepaid packages for a subscriber |
|
|
137
|
+
| `list_package_templates` | read | List all prepaid package templates |
|
|
138
|
+
| `assign_package` | write | Assign package template to subscriber |
|
|
139
|
+
| `assign_recurring_package` | write | Assign recurring package to subscriber |
|
|
140
|
+
| `modify_package_limits` | write | Change data/voice/SMS limits on active package |
|
|
141
|
+
| `modify_package_expiry` | write | Change expiration date of active package |
|
|
142
|
+
| `modify_package_status` | write | Activate or deactivate a subscriber package |
|
|
143
|
+
| `stop_resume_recurring_package` | write | Stop or resume recurring package auto-renewal |
|
|
144
|
+
| `delete_subscriber_package` | write | Remove a package from a subscriber |
|
|
145
|
+
|
|
146
|
+
### Templates & Zones (7)
|
|
147
|
+
|
|
148
|
+
| Tool | Scope | Description |
|
|
149
|
+
|------|-------|-------------|
|
|
150
|
+
| `clean_all_packages` | write | Remove ALL packages from a subscriber |
|
|
151
|
+
| `create_package_template` | write | Create a new prepaid package template |
|
|
152
|
+
| `modify_template_core` | write | Modify core settings of a package template |
|
|
153
|
+
| `modify_template_recurring` | write | Modify recurring settings of a package template |
|
|
154
|
+
| `modify_template_throttling` | write | Modify throttling settings of a package template |
|
|
155
|
+
| `list_location_zones` | read | List countries/networks in a location zone |
|
|
156
|
+
| `list_detailed_location_zones` | read | Get detailed location zone definitions |
|
|
157
|
+
|
|
158
|
+
### Statistics & Misc (8)
|
|
159
|
+
|
|
160
|
+
| Tool | Scope | Description |
|
|
161
|
+
|------|-------|-------------|
|
|
162
|
+
| `subscriber_usage` | read | Get daily usage for a subscriber (max 7 days) |
|
|
163
|
+
| `subscriber_network_events` | read | Get network events for a subscriber (max 7 days) |
|
|
164
|
+
| `subscriber_active_period` | read | Get subscriber active period |
|
|
165
|
+
| `get_tariff` | read | Retrieve customer tariff/pricing table |
|
|
166
|
+
| `list_destination_prefixes` | read | List phone number prefixes in destination lists |
|
|
167
|
+
| `list_network_profiles` | read | List all available network profiles |
|
|
168
|
+
| `create_location_zone` | write | Create a new location zone |
|
|
169
|
+
| `send_sms` | write | Send MT SMS to a subscriber |
|
|
170
|
+
|
|
171
|
+
### Intelligence (8)
|
|
172
|
+
|
|
173
|
+
AI composites that chain multiple OCS calls to produce structured insights:
|
|
174
|
+
|
|
175
|
+
| Tool | Description |
|
|
176
|
+
|------|-------------|
|
|
177
|
+
| `diagnose_subscriber` | Chains 5+ OCS calls to diagnose connectivity issues |
|
|
178
|
+
| `fleet_health` | Single-call fleet overview: accounts, eSIM counts, low-balance alerts |
|
|
179
|
+
| `detect_usage_anomalies` | Detect abnormal usage patterns and burn-rate risks |
|
|
180
|
+
| `optimize_package` | Match subscriber usage to the best available package |
|
|
181
|
+
| `churn_risk` | Score churn risk (0-100) with retention recommendations |
|
|
182
|
+
| `audit_network_coverage` | Audit network coverage and steering effectiveness |
|
|
183
|
+
| `marketing_intelligence` | Market segmentation and upsell opportunities |
|
|
184
|
+
| `high_cost_subscribers` | Identify highest-cost subscribers for margin optimization |
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Prompts (5)
|
|
189
|
+
|
|
190
|
+
| Prompt | Args | Description |
|
|
191
|
+
|--------|------|-------------|
|
|
192
|
+
| `fleet_health_report` | — | Full fleet health overview |
|
|
193
|
+
| `subscriber_deep_dive` | `iccid` | Deep diagnostic for a single subscriber |
|
|
194
|
+
| `revenue_optimization` | — | Revenue analysis and upsell opportunities |
|
|
195
|
+
| `coverage_analysis` | — | Network coverage audit and steering recommendations |
|
|
196
|
+
| `bulk_operations_planner` | `operation` | Plan and dry-run a bulk fleet operation |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Destructive tools and dry_run
|
|
201
|
+
|
|
202
|
+
All write/admin tools accept an optional `dry_run: true` argument. When set, the tool returns the would-be request without calling OCS — safe for previewing operations.
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
"Suspend ICCID 8988... but check what it would do first (dry_run)"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Links
|
|
211
|
+
|
|
212
|
+
- Product page: [mcp.carrier.llc](https://mcp.carrier.llc)
|
|
213
|
+
- Source: [github.com/Lifecycle-Innovations-Limited/carrier.llc](https://github.com/Lifecycle-Innovations-Limited/carrier.llc)
|
|
214
|
+
- OCS docs: [docs.esimvault.cloud/ocs-api](https://docs.esimvault.cloud/ocs-api)
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
MIT License. Copyright 2025 Lifecycle Innovations Limited.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.2b — Wizard Session KV helpers
|
|
3
|
+
*
|
|
4
|
+
* Stores ephemeral 3-step wizard state in CARRIER_USERS KV.
|
|
5
|
+
* Key pattern: app-session:<sub>:<wizardId>
|
|
6
|
+
* TTL: 600 seconds (10 minutes).
|
|
7
|
+
*/
|
|
8
|
+
import type { Env } from "../types.js";
|
|
9
|
+
export interface WizardSession {
|
|
10
|
+
step: "select-subscriber" | "select-package" | "confirm";
|
|
11
|
+
subscriber_iccid?: string;
|
|
12
|
+
package_template_id?: number;
|
|
13
|
+
dry_run: boolean;
|
|
14
|
+
initiated_at: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function loadWizardSession(env: Env, sub: string, wizardId: string): Promise<WizardSession | null>;
|
|
17
|
+
export declare function saveWizardSession(env: Env, sub: string, wizardId: string, session: WizardSession): Promise<void>;
|
|
18
|
+
export declare function deleteWizardSession(env: Env, sub: string, wizardId: string): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=app-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-state.d.ts","sourceRoot":"","sources":["../../src/apps/app-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,SAAS,CAAC;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAMD,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAQ/B;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.2b — Wizard Session KV helpers
|
|
3
|
+
*
|
|
4
|
+
* Stores ephemeral 3-step wizard state in CARRIER_USERS KV.
|
|
5
|
+
* Key pattern: app-session:<sub>:<wizardId>
|
|
6
|
+
* TTL: 600 seconds (10 minutes).
|
|
7
|
+
*/
|
|
8
|
+
function sessionKey(sub, wizardId) {
|
|
9
|
+
return `app-session:${sub}:${wizardId}`;
|
|
10
|
+
}
|
|
11
|
+
export async function loadWizardSession(env, sub, wizardId) {
|
|
12
|
+
const raw = await env.CARRIER_USERS.get(sessionKey(sub, wizardId));
|
|
13
|
+
if (!raw)
|
|
14
|
+
return null;
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(raw);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export async function saveWizardSession(env, sub, wizardId, session) {
|
|
23
|
+
await env.CARRIER_USERS.put(sessionKey(sub, wizardId), JSON.stringify(session), { expirationTtl: 600 });
|
|
24
|
+
}
|
|
25
|
+
export async function deleteWizardSession(env, sub, wizardId) {
|
|
26
|
+
await env.CARRIER_USERS.delete(sessionKey(sub, wizardId));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=app-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-state.js","sourceRoot":"","sources":["../../src/apps/app-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,SAAS,UAAU,CAAC,GAAW,EAAE,QAAgB;IAC/C,OAAO,eAAe,GAAG,IAAI,QAAQ,EAAE,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAQ,EACR,GAAW,EACX,QAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IACnE,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAQ,EACR,GAAW,EACX,QAAgB,EAChB,OAAsB;IAEtB,MAAM,GAAG,CAAC,aAAa,CAAC,GAAG,CACzB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,EACzB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EACvB,EAAE,aAAa,EAAE,GAAG,EAAE,CACvB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,GAAQ,EACR,GAAW,EACX,QAAgB;IAEhB,MAAM,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.2d — Balance Top-up Form MCP App
|
|
3
|
+
*
|
|
4
|
+
* Enterprise-only inline form for adjusting account balances via
|
|
5
|
+
* `modify_account_balance`. Supports preview-only mode before committing.
|
|
6
|
+
* Scoped to `admin` — pairs with MFA gate from PR #46.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import type { ToolContext } from "../tools.js";
|
|
10
|
+
export interface BalanceTopupStructuredContent {
|
|
11
|
+
iccid: string;
|
|
12
|
+
delta: number;
|
|
13
|
+
current_balance?: number;
|
|
14
|
+
new_balance?: number;
|
|
15
|
+
preview: boolean;
|
|
16
|
+
success?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function registerBalanceTopupApp(server: McpServer, ctx: ToolContext): void;
|
|
19
|
+
//# sourceMappingURL=balance-topup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance-topup.d.ts","sourceRoot":"","sources":["../../src/apps/balance-topup.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmB/C,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,WAAW,GACf,IAAI,CAyIN"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.2d — Balance Top-up Form MCP App
|
|
3
|
+
*
|
|
4
|
+
* Enterprise-only inline form for adjusting account balances via
|
|
5
|
+
* `modify_account_balance`. Supports preview-only mode before committing.
|
|
6
|
+
* Scoped to `admin` — pairs with MFA gate from PR #46.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { registerAppTool, registerAppResource, RESOURCE_MIME_TYPE, } from "@modelcontextprotocol/ext-apps/server";
|
|
10
|
+
import { OcsClient } from "../client.js";
|
|
11
|
+
import { wrapHandler, TOOL_SCOPES } from "../tools.js";
|
|
12
|
+
async function safeCallWithToken(client, _token, method, params = {}) {
|
|
13
|
+
try {
|
|
14
|
+
return { data: await client.call(method, params), error: null };
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
return {
|
|
18
|
+
data: null,
|
|
19
|
+
error: err instanceof Error ? err.message : String(err),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function registerBalanceTopupApp(server, ctx) {
|
|
24
|
+
// Tier guard — enterprise only
|
|
25
|
+
if (ctx.props.tier !== "enterprise")
|
|
26
|
+
return;
|
|
27
|
+
// ── Resource ─────────────────────────────────────────────────────────────
|
|
28
|
+
registerAppResource(server, "Balance Top-up Form", "ui://balance-topup-form", {
|
|
29
|
+
description: "Admin balance top-up form — enter an ICCID and delta amount to preview and commit account balance adjustments. Enterprise only. Requires recent MFA verification.",
|
|
30
|
+
}, async () => {
|
|
31
|
+
let html;
|
|
32
|
+
try {
|
|
33
|
+
const resp = await ctx.env.ASSETS.fetch(new Request("https://internal/views/balance-topup/index.html"));
|
|
34
|
+
html = await resp.text();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
html = "<html><body><p>Balance top-up form unavailable.</p></body></html>";
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
contents: [
|
|
41
|
+
{
|
|
42
|
+
uri: "ui://balance-topup-form",
|
|
43
|
+
mimeType: RESOURCE_MIME_TYPE,
|
|
44
|
+
text: html,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
// ── Tool ─────────────────────────────────────────────────────────────────
|
|
50
|
+
registerAppTool(server, "balance_topup_form", {
|
|
51
|
+
title: "Balance Top-up Form",
|
|
52
|
+
description: "Enterprise admin tool: preview or commit an account balance adjustment. Set preview=true to fetch projection (no OCS write); preview=false (default) to execute. Requires admin scope + recent MFA.",
|
|
53
|
+
inputSchema: {
|
|
54
|
+
iccid: z.string().describe("The subscriber ICCID for the account lookup"),
|
|
55
|
+
delta: z
|
|
56
|
+
.number()
|
|
57
|
+
.describe("Amount to add (positive) or deduct (negative) from the account balance"),
|
|
58
|
+
preview: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.default(true)
|
|
61
|
+
.describe("If true, return preview without writing. If false, execute the balance change."),
|
|
62
|
+
},
|
|
63
|
+
annotations: { destructiveHint: true },
|
|
64
|
+
_meta: {
|
|
65
|
+
ui: {
|
|
66
|
+
resourceUri: "ui://balance-topup-form",
|
|
67
|
+
visibility: ["model", "app"],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}, wrapHandler("modify_account_balance", "modifyAccountBalance", TOOL_SCOPES["modify_account_balance"], ctx, async ({ iccid, delta, preview }) => {
|
|
71
|
+
const token = await ctx.getUserToken(ctx.props.sub);
|
|
72
|
+
const client = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token);
|
|
73
|
+
if (preview === true) {
|
|
74
|
+
// Preview path — fetch current subscriber balance, return projection
|
|
75
|
+
const result = await safeCallWithToken(client, token, "getSingleSubscriber", { iccid });
|
|
76
|
+
const currentBalance = result.data
|
|
77
|
+
? Number(result.data["balance"] ?? result.data["accountBalance"] ?? 0)
|
|
78
|
+
: 0;
|
|
79
|
+
const newBalance = currentBalance + delta;
|
|
80
|
+
const structured = {
|
|
81
|
+
iccid,
|
|
82
|
+
delta,
|
|
83
|
+
current_balance: currentBalance,
|
|
84
|
+
new_balance: newBalance,
|
|
85
|
+
preview: true,
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: "text",
|
|
91
|
+
text: `[Preview] ICCID: ${iccid} | Current balance: ${currentBalance} | Delta: ${delta >= 0 ? "+" : ""}${delta} | New balance: ${newBalance}. No changes made.`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
structuredContent: structured,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Execute path — call modify_account_balance via OCS
|
|
98
|
+
const execResult = await safeCallWithToken(client, token, "modifyAccountBalance", { subscriber: iccid, adaptBalance: delta });
|
|
99
|
+
if (execResult.error) {
|
|
100
|
+
return {
|
|
101
|
+
isError: true,
|
|
102
|
+
content: [{ type: "text", text: `Error: ${execResult.error}` }],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const newBalance = execResult.data
|
|
106
|
+
? Number(execResult.data["balance"] ?? execResult.data["newBalance"] ?? 0)
|
|
107
|
+
: delta;
|
|
108
|
+
const structured = {
|
|
109
|
+
iccid,
|
|
110
|
+
delta,
|
|
111
|
+
new_balance: newBalance,
|
|
112
|
+
preview: false,
|
|
113
|
+
success: true,
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: "Balance updated." }],
|
|
117
|
+
structuredContent: structured,
|
|
118
|
+
};
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=balance-topup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance-topup.js","sourceRoot":"","sources":["../../src/apps/balance-topup.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,KAAK,UAAU,iBAAiB,CAC9B,MAAiB,EACjB,MAAc,EACd,MAAc,EACd,SAAoD,EAAE;IAEtD,IAAI,CAAC;QACH,OAAO,EAAE,IAAI,EA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
|
1
|
+
/**
|
|
2
|
+
* v1.2a — Fleet Health Dashboard MCP App
|
|
3
|
+
*
|
|
4
|
+
* Registers a UI-enabled tool `fleet_health_app` that returns structured data
|
|
5
|
+
* for rendering charts in the sandboxed iframe view, alongside the
|
|
6
|
+
* `ui://fleet-health-dashboard` resource that serves the HTML panel.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import type { ToolContext } from "../tools.js";
|
|
10
|
+
export interface FleetHealthStructuredContent {
|
|
11
|
+
utilization: number;
|
|
12
|
+
totalActive: number;
|
|
13
|
+
totalSuspended: number;
|
|
14
|
+
totalInventory: number;
|
|
15
|
+
totalOther: number;
|
|
16
|
+
totalAccounts: number;
|
|
17
|
+
lowBalanceCount: number;
|
|
18
|
+
accountList: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
balance: number;
|
|
21
|
+
active: number;
|
|
22
|
+
suspended: number;
|
|
23
|
+
inventory: number;
|
|
24
|
+
other: number;
|
|
25
|
+
}>;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
export declare function registerFleetHealthApp(server: McpServer, ctx: ToolContext): void;
|
|
29
|
+
//# sourceMappingURL=fleet-health-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-health-app.d.ts","sourceRoot":"","sources":["../../src/apps/fleet-health-app.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkB/C,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IAGH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,WAAW,GACf,IAAI,CAgLN"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.2a — Fleet Health Dashboard MCP App
|
|
3
|
+
*
|
|
4
|
+
* Registers a UI-enabled tool `fleet_health_app` that returns structured data
|
|
5
|
+
* for rendering charts in the sandboxed iframe view, alongside the
|
|
6
|
+
* `ui://fleet-health-dashboard` resource that serves the HTML panel.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { registerAppTool, registerAppResource, RESOURCE_MIME_TYPE, } from "@modelcontextprotocol/ext-apps/server";
|
|
10
|
+
import { OcsClient } from "../client.js";
|
|
11
|
+
async function safeCallWithToken(client, _token, method, params = {}) {
|
|
12
|
+
try {
|
|
13
|
+
return { data: await client.call(method, params), error: null };
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
return {
|
|
17
|
+
data: null,
|
|
18
|
+
error: err instanceof Error ? err.message : String(err),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function registerFleetHealthApp(server, ctx) {
|
|
23
|
+
// ── Resource ─────────────────────────────────────────────────────────────
|
|
24
|
+
registerAppResource(server, "Fleet Health Dashboard", "ui://fleet-health-dashboard", {
|
|
25
|
+
description: "Interactive Fleet Health Dashboard — eSIM status charts, account breakdown, low-balance alerts.",
|
|
26
|
+
}, async () => {
|
|
27
|
+
let html;
|
|
28
|
+
try {
|
|
29
|
+
const resp = await ctx.env.ASSETS.fetch(new Request("https://internal/views/fleet-health/index.html"));
|
|
30
|
+
html = await resp.text();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
html = "<html><body><p>Dashboard unavailable.</p></body></html>";
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
contents: [
|
|
37
|
+
{
|
|
38
|
+
uri: "ui://fleet-health-dashboard",
|
|
39
|
+
mimeType: RESOURCE_MIME_TYPE,
|
|
40
|
+
text: html,
|
|
41
|
+
_meta: {
|
|
42
|
+
ui: {
|
|
43
|
+
csp: {
|
|
44
|
+
resourceDomains: ["https://cdn.jsdelivr.net"],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
// ── Tool ─────────────────────────────────────────────────────────────────
|
|
53
|
+
registerAppTool(server, "fleet_health_app", {
|
|
54
|
+
title: "Fleet Health Dashboard",
|
|
55
|
+
description: "Renders an interactive Fleet Health Dashboard with eSIM status charts, top-10 account breakdown, and low-balance alerts. Returns structuredContent for the chart panel.",
|
|
56
|
+
inputSchema: {
|
|
57
|
+
accountId: z
|
|
58
|
+
.number()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Filter to a specific account (omit for all)"),
|
|
61
|
+
},
|
|
62
|
+
annotations: { readOnlyHint: true },
|
|
63
|
+
_meta: {
|
|
64
|
+
ui: {
|
|
65
|
+
resourceUri: "ui://fleet-health-dashboard",
|
|
66
|
+
visibility: ["model", "app"],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}, async ({ accountId }) => {
|
|
70
|
+
const token = await ctx.getUserToken(ctx.props.sub);
|
|
71
|
+
const client = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token);
|
|
72
|
+
const [statusResult, accountsResult] = await Promise.all([
|
|
73
|
+
safeCallWithToken(client, token, "esimStatusPerAccount", accountId !== undefined ? { accountId } : {}),
|
|
74
|
+
safeCallWithToken(client, token, "listResellerAccount", {}),
|
|
75
|
+
]);
|
|
76
|
+
let totalActive = 0;
|
|
77
|
+
let totalSuspended = 0;
|
|
78
|
+
let totalInventory = 0;
|
|
79
|
+
let totalOther = 0;
|
|
80
|
+
const accountList = [];
|
|
81
|
+
if (statusResult.data && Array.isArray(statusResult.data)) {
|
|
82
|
+
for (const account of statusResult.data) {
|
|
83
|
+
const active = Number(account["active"] ?? 0);
|
|
84
|
+
const suspended = Number(account["suspended"] ?? 0);
|
|
85
|
+
const inventory = Number(account["inventory"] ?? account["notActivated"] ?? 0);
|
|
86
|
+
const other = Number(account["other"] ?? account["terminated"] ?? 0);
|
|
87
|
+
totalActive += active;
|
|
88
|
+
totalSuspended += suspended;
|
|
89
|
+
totalInventory += inventory;
|
|
90
|
+
totalOther += other;
|
|
91
|
+
accountList.push({
|
|
92
|
+
name: String(account["name"] ?? account["accountId"] ?? "?"),
|
|
93
|
+
balance: 0,
|
|
94
|
+
active,
|
|
95
|
+
suspended,
|
|
96
|
+
inventory,
|
|
97
|
+
other,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Merge balance data from accounts list
|
|
102
|
+
if (accountsResult.data && Array.isArray(accountsResult.data)) {
|
|
103
|
+
for (const a of accountsResult.data) {
|
|
104
|
+
const aName = String(a["name"] ?? a["accountId"] ?? "?");
|
|
105
|
+
const entry = accountList.find((e) => e.name === aName);
|
|
106
|
+
if (entry) {
|
|
107
|
+
entry.balance = Number(a["balance"] ?? 0);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const total = totalActive + totalSuspended + totalInventory + totalOther;
|
|
112
|
+
const utilization = total > 0
|
|
113
|
+
? Math.round((totalActive / total) * 1000) / 10
|
|
114
|
+
: 0;
|
|
115
|
+
const totalAccounts = accountsResult.data && Array.isArray(accountsResult.data)
|
|
116
|
+
? accountsResult.data.length
|
|
117
|
+
: accountList.length;
|
|
118
|
+
const lowBalanceCount = accountsResult.data && Array.isArray(accountsResult.data)
|
|
119
|
+
? accountsResult.data.filter((a) => Number(a["balance"] ?? 0) < 10)
|
|
120
|
+
.length
|
|
121
|
+
: 0;
|
|
122
|
+
// Sort accountList by total eSIMs descending for top-10 bar chart
|
|
123
|
+
const sortedAccounts = [...accountList]
|
|
124
|
+
.sort((a, b) => b.active + b.suspended + b.inventory + b.other -
|
|
125
|
+
(a.active + a.suspended + a.inventory + a.other))
|
|
126
|
+
.slice(0, 10);
|
|
127
|
+
const errors = [statusResult.error, accountsResult.error]
|
|
128
|
+
.filter(Boolean)
|
|
129
|
+
.join("; ");
|
|
130
|
+
const summaryLines = [
|
|
131
|
+
`Fleet Utilization: ${utilization}%`,
|
|
132
|
+
`Active: ${totalActive} | Suspended: ${totalSuspended} | Inventory: ${totalInventory} | Other: ${totalOther}`,
|
|
133
|
+
`Total Accounts: ${totalAccounts} | Low Balance (<10): ${lowBalanceCount}`,
|
|
134
|
+
...(errors ? [`Errors: ${errors}`] : []),
|
|
135
|
+
];
|
|
136
|
+
const structuredContent = {
|
|
137
|
+
utilization,
|
|
138
|
+
totalActive,
|
|
139
|
+
totalSuspended,
|
|
140
|
+
totalInventory,
|
|
141
|
+
totalOther,
|
|
142
|
+
totalAccounts,
|
|
143
|
+
lowBalanceCount,
|
|
144
|
+
accountList: sortedAccounts,
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
content: [{ type: "text", text: summaryLines.join("\n") }],
|
|
148
|
+
structuredContent,
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=fleet-health-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-health-app.js","sourceRoot":"","sources":["../../src/apps/fleet-health-app.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,E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