@carrierllc/mcp 0.13.62 → 0.13.63
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-SZR42TUZ.js → chunk-WCIQ6OYP.js} +453 -138
- package/dist/chunk-WCIQ6OYP.js.map +1 -0
- package/dist/cli.js +7 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.js +605 -603
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-SZR42TUZ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
loadStorefrontBrand,
|
|
41
41
|
locationParams,
|
|
42
42
|
locationZoneCreateParams,
|
|
43
|
+
marketingSnapshot,
|
|
43
44
|
mccToIso,
|
|
44
45
|
mergeEnvLocal,
|
|
45
46
|
modifySubscriberContactInfoFromTool,
|
|
@@ -48,6 +49,7 @@ import {
|
|
|
48
49
|
networkDefaultPartition,
|
|
49
50
|
networkEventRows,
|
|
50
51
|
networkEventsOverPeriodParams,
|
|
52
|
+
ocsArray,
|
|
51
53
|
ocsHlrBitrate,
|
|
52
54
|
ocsHlrBitrateFromBps,
|
|
53
55
|
ocsLocalDateTime,
|
|
@@ -68,13 +70,19 @@ import {
|
|
|
68
70
|
recordToolDescription,
|
|
69
71
|
recurringIdForPackage,
|
|
70
72
|
recurringPackageParams,
|
|
73
|
+
regionalArpu,
|
|
74
|
+
regionalArpuPeriod,
|
|
71
75
|
renderHtml,
|
|
76
|
+
renderMarketingContext,
|
|
77
|
+
renderRegionalArpu,
|
|
72
78
|
repairPlanFor,
|
|
73
79
|
scopeListSubscriberParams,
|
|
74
80
|
setNetworkDefault,
|
|
75
81
|
staleActivePackages,
|
|
76
82
|
storefrontClerkUrls,
|
|
83
|
+
subscriberIccid,
|
|
77
84
|
subscriberIdParams,
|
|
85
|
+
subscriberListEnvelope,
|
|
78
86
|
subscriberRows,
|
|
79
87
|
subscriberSimId,
|
|
80
88
|
summarizeNetworkEvents,
|
|
@@ -82,7 +90,7 @@ import {
|
|
|
82
90
|
verifyStorefront,
|
|
83
91
|
withOcsListSummary,
|
|
84
92
|
withTemplateResellerId
|
|
85
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-WCIQ6OYP.js";
|
|
86
94
|
import "./chunk-SHKKVIIA.js";
|
|
87
95
|
|
|
88
96
|
// src/index.ts
|
|
@@ -1113,7 +1121,7 @@ function boundTariffResult(raw, opts = {}) {
|
|
|
1113
1121
|
const cap = opts.maxRules ?? (verbose ? TARIFF_VERBOSE_MAX_RULES : TARIFF_MAX_RULES);
|
|
1114
1122
|
const kept = matched.slice(0, cap);
|
|
1115
1123
|
const truncated = kept.length < matched.length;
|
|
1116
|
-
const
|
|
1124
|
+
const result3 = {
|
|
1117
1125
|
resellerId,
|
|
1118
1126
|
totalRules: all.length,
|
|
1119
1127
|
matchedRules: matched.length,
|
|
@@ -1123,22 +1131,22 @@ function boundTariffResult(raw, opts = {}) {
|
|
|
1123
1131
|
rules: []
|
|
1124
1132
|
};
|
|
1125
1133
|
if (country !== void 0 || trafficType !== void 0) {
|
|
1126
|
-
|
|
1127
|
-
if (country !== void 0)
|
|
1128
|
-
if (trafficType !== void 0)
|
|
1134
|
+
result3.filters = {};
|
|
1135
|
+
if (country !== void 0) result3.filters.country = country;
|
|
1136
|
+
if (trafficType !== void 0) result3.filters.trafficType = trafficType;
|
|
1129
1137
|
}
|
|
1130
1138
|
if (verbose) {
|
|
1131
|
-
|
|
1132
|
-
if (truncated)
|
|
1133
|
-
return
|
|
1139
|
+
result3.rules = kept;
|
|
1140
|
+
if (truncated) result3.note = truncationNote("tariff", kept.length, matched.length);
|
|
1141
|
+
return result3;
|
|
1134
1142
|
}
|
|
1135
1143
|
const currencies = new Set(
|
|
1136
1144
|
kept.map((r) => r.currency?.currencycode).filter((c) => typeof c === "string")
|
|
1137
1145
|
);
|
|
1138
1146
|
const hoistCurrency = currencies.size === 1;
|
|
1139
|
-
if (hoistCurrency)
|
|
1147
|
+
if (hoistCurrency) result3.currency = [...currencies][0];
|
|
1140
1148
|
const columns = trafficType ? RATE_COLUMNS[trafficType] : ALL_RATE_COLUMNS;
|
|
1141
|
-
|
|
1149
|
+
result3.rules = kept.map((r) => {
|
|
1142
1150
|
const op = r.operator ?? {};
|
|
1143
1151
|
const row = {};
|
|
1144
1152
|
if (op.countryIso2 !== void 0) row.iso = op.countryIso2;
|
|
@@ -1160,14 +1168,14 @@ function boundTariffResult(raw, opts = {}) {
|
|
|
1160
1168
|
}
|
|
1161
1169
|
}
|
|
1162
1170
|
if (!hoistCurrency) legend.cur = "ISO-4217 currency code";
|
|
1163
|
-
|
|
1171
|
+
result3.fields = legend;
|
|
1164
1172
|
const notes = [];
|
|
1165
1173
|
if (truncated) notes.push(truncationNote("tariff", kept.length, matched.length));
|
|
1166
1174
|
notes.push(
|
|
1167
1175
|
`Projected result: nested operator detail (mccMncs, tadigs, continent, countryCode, utcOffset), the sponsor object, plan ids (roamingplanruleid, roamingplanid, sponsoridx) and the validity/discount flags (startdate, enddate, isDiscounted, hidden, dailyCap) are omitted. Pass verbose=true for the full untouched rule shape (capped at ${TARIFF_VERBOSE_MAX_RULES} rows \u2014 use 'country'/'trafficType' with it).`
|
|
1168
1176
|
);
|
|
1169
|
-
|
|
1170
|
-
return
|
|
1177
|
+
result3.note = notes.join(" ");
|
|
1178
|
+
return result3;
|
|
1171
1179
|
}
|
|
1172
1180
|
var ZONE_FIELD_LEGEND = {
|
|
1173
1181
|
zoneId: "location zone id \u2014 pass to package-template tools",
|
|
@@ -1180,22 +1188,22 @@ function boundZonesResult(raw, opts = {}) {
|
|
|
1180
1188
|
const { verbose = false, resellerId } = opts;
|
|
1181
1189
|
const maxZones = opts.maxZones ?? ZONES_MAX_ZONES;
|
|
1182
1190
|
const maxOperators = opts.maxOperators ?? (verbose ? ZONES_VERBOSE_MAX_OPERATORS : ZONES_MAX_OPERATORS);
|
|
1183
|
-
const totalOperators = all.reduce((n,
|
|
1191
|
+
const totalOperators = all.reduce((n, z29) => n + (z29.operators?.length ?? 0), 0);
|
|
1184
1192
|
const keptZones = all.slice(0, maxZones);
|
|
1185
1193
|
let budget = maxOperators;
|
|
1186
1194
|
let returnedOperators = 0;
|
|
1187
|
-
const zones = keptZones.map((
|
|
1188
|
-
const ops =
|
|
1195
|
+
const zones = keptZones.map((z29) => {
|
|
1196
|
+
const ops = z29.operators ?? [];
|
|
1189
1197
|
const take = Math.max(0, Math.min(ops.length, budget));
|
|
1190
1198
|
budget -= take;
|
|
1191
1199
|
returnedOperators += take;
|
|
1192
1200
|
const sliced = ops.slice(0, take);
|
|
1193
1201
|
if (verbose) {
|
|
1194
|
-
return { ...
|
|
1202
|
+
return { ...z29, operators: sliced, operatorCount: ops.length };
|
|
1195
1203
|
}
|
|
1196
1204
|
return {
|
|
1197
|
-
zoneId:
|
|
1198
|
-
zoneName:
|
|
1205
|
+
zoneId: z29.zoneId,
|
|
1206
|
+
zoneName: z29.zoneName,
|
|
1199
1207
|
operatorCount: ops.length,
|
|
1200
1208
|
operators: sliced.map((o) => ({
|
|
1201
1209
|
net: o.networkId,
|
|
@@ -1205,7 +1213,7 @@ function boundZonesResult(raw, opts = {}) {
|
|
|
1205
1213
|
};
|
|
1206
1214
|
});
|
|
1207
1215
|
const truncated = keptZones.length < all.length || returnedOperators < totalOperators;
|
|
1208
|
-
const
|
|
1216
|
+
const result3 = {
|
|
1209
1217
|
resellerId,
|
|
1210
1218
|
totalZones: all.length,
|
|
1211
1219
|
returnedZones: keptZones.length,
|
|
@@ -1218,13 +1226,13 @@ function boundZonesResult(raw, opts = {}) {
|
|
|
1218
1226
|
const notes = [];
|
|
1219
1227
|
if (truncated) notes.push(truncationNote("zones", returnedOperators, totalOperators));
|
|
1220
1228
|
if (!verbose) {
|
|
1221
|
-
|
|
1229
|
+
result3.fields = ZONE_FIELD_LEGEND;
|
|
1222
1230
|
notes.push(
|
|
1223
1231
|
`Projected result: per-operator mccMncs, tadigs, continent, countryCode, countryName and utcOffset are omitted, as is the repeated reseller object. Pass verbose=true for the full untouched zone shape (capped at ${ZONES_VERBOSE_MAX_OPERATORS} operator entries).`
|
|
1224
1232
|
);
|
|
1225
1233
|
}
|
|
1226
|
-
if (notes.length)
|
|
1227
|
-
return
|
|
1234
|
+
if (notes.length) result3.note = notes.join(" ");
|
|
1235
|
+
return result3;
|
|
1228
1236
|
}
|
|
1229
1237
|
|
|
1230
1238
|
// src/tools.ts
|
|
@@ -1397,11 +1405,11 @@ function wrapHandler(toolName, ocsMethod, requiredScope, ctx, handler, options)
|
|
|
1397
1405
|
]
|
|
1398
1406
|
};
|
|
1399
1407
|
}
|
|
1400
|
-
let
|
|
1408
|
+
let result3;
|
|
1401
1409
|
try {
|
|
1402
1410
|
const skipToken = typeof options?.skipUserToken === "function" ? options.skipUserToken(args) : options?.skipUserToken;
|
|
1403
1411
|
const token2 = skipToken ? "" : await ctx.getUserToken(ctx.props.sub);
|
|
1404
|
-
|
|
1412
|
+
result3 = extra === void 0 ? await handler(args, token2) : await handler(args, token2, extra);
|
|
1405
1413
|
} catch (err9) {
|
|
1406
1414
|
try {
|
|
1407
1415
|
Sentry.captureException(err9, {
|
|
@@ -1428,30 +1436,30 @@ function wrapHandler(toolName, ocsMethod, requiredScope, ctx, handler, options)
|
|
|
1428
1436
|
content: [{ type: "text", text: `Error: ${message}` }]
|
|
1429
1437
|
};
|
|
1430
1438
|
}
|
|
1431
|
-
const handledOcsCode =
|
|
1439
|
+
const handledOcsCode = result3.ocsStatusCode;
|
|
1432
1440
|
if (handledOcsCode !== void 0) {
|
|
1433
|
-
const { ocsStatusCode: _auditOnly, ...clientResult } =
|
|
1441
|
+
const { ocsStatusCode: _auditOnly, ...clientResult } = result3;
|
|
1434
1442
|
void _auditOnly;
|
|
1435
|
-
|
|
1443
|
+
result3 = clientResult;
|
|
1436
1444
|
}
|
|
1437
1445
|
ctx.audit({
|
|
1438
1446
|
tool_name: toolName,
|
|
1439
1447
|
ocs_method: ocsMethod,
|
|
1440
|
-
status:
|
|
1448
|
+
status: result3.isError ? "error" : "ok",
|
|
1441
1449
|
dry_run: isDryRun,
|
|
1442
1450
|
duration_ms: Date.now() - start,
|
|
1443
1451
|
...handledOcsCode !== void 0 ? { ocs_status_code: handledOcsCode } : {}
|
|
1444
1452
|
});
|
|
1445
|
-
if (!
|
|
1453
|
+
if (!result3.isError && !isDryRun) {
|
|
1446
1454
|
recordUsage(ctx.env, ctx.props.sub, ctx.props.tier);
|
|
1447
1455
|
}
|
|
1448
|
-
return
|
|
1456
|
+
return result3;
|
|
1449
1457
|
};
|
|
1450
1458
|
}
|
|
1451
1459
|
async function ocsCall(env, token2, method, params = {}, listKind) {
|
|
1452
1460
|
const client2 = new OcsClient(env.CARRIER_OCS_BASE_URL, token2);
|
|
1453
|
-
const
|
|
1454
|
-
const payload = listKind ? withOcsListSummary(
|
|
1461
|
+
const result3 = await client2.call(method, params);
|
|
1462
|
+
const payload = listKind ? withOcsListSummary(result3, listKind) : result3;
|
|
1455
1463
|
return {
|
|
1456
1464
|
content: [{ type: "text", text: JSON.stringify(payload, null, 2) }]
|
|
1457
1465
|
};
|
|
@@ -2749,7 +2757,7 @@ function registerAllTools(server2, ctx) {
|
|
|
2749
2757
|
}
|
|
2750
2758
|
|
|
2751
2759
|
// src/intelligence.ts
|
|
2752
|
-
import { z as
|
|
2760
|
+
import { z as z3 } from "zod";
|
|
2753
2761
|
|
|
2754
2762
|
// ../../packages/ocs-spec/ocs-methods.json
|
|
2755
2763
|
var ocs_methods_default = {
|
|
@@ -3829,7 +3837,8 @@ var ocsIntelligenceMethods = ocsSpec.v1_intelligence_methods;
|
|
|
3829
3837
|
var ocsBacklog = ocsSpec.v1_1_backlog;
|
|
3830
3838
|
var ocsAppMethods = ocsSpec.v1_app_methods;
|
|
3831
3839
|
|
|
3832
|
-
// src/intelligence.ts
|
|
3840
|
+
// src/marketing-intelligence.ts
|
|
3841
|
+
import { z as z2 } from "zod";
|
|
3833
3842
|
async function safeCall(env, token2, method, params = {}) {
|
|
3834
3843
|
try {
|
|
3835
3844
|
const client2 = new OcsClient(env.CARRIER_OCS_BASE_URL, token2);
|
|
@@ -3839,12 +3848,118 @@ async function safeCall(env, token2, method, params = {}) {
|
|
|
3839
3848
|
return { data: null, error: err9 instanceof Error ? err9.message : String(err9) };
|
|
3840
3849
|
}
|
|
3841
3850
|
}
|
|
3851
|
+
function result(text, isError = false) {
|
|
3852
|
+
return { content: [{ type: "text", text }], ...isError ? { isError: true } : {} };
|
|
3853
|
+
}
|
|
3854
|
+
function registerMarketingIntelligenceTool(server2, ctx) {
|
|
3855
|
+
server2.registerTool("marketing_intelligence", {
|
|
3856
|
+
title: "Marketing Intelligence Report",
|
|
3857
|
+
description: "Reports regional ARPU from historical rated subscriber charges, measured subscribers, and catalogue coverage. Countries and currencies remain separate; missing charges are reported.",
|
|
3858
|
+
inputSchema: {
|
|
3859
|
+
accountId: z2.number().optional().describe("Filter to a specific account"),
|
|
3860
|
+
start: z2.string().optional().describe("Usage period start (YYYY-MM-DD, maximum seven inclusive days)"),
|
|
3861
|
+
end: z2.string().optional().describe("Usage period end (YYYY-MM-DD, default today UTC)")
|
|
3862
|
+
},
|
|
3863
|
+
annotations: { readOnlyHint: true }
|
|
3864
|
+
}, async ({ accountId, start, end }) => {
|
|
3865
|
+
let period;
|
|
3866
|
+
try {
|
|
3867
|
+
period = regionalArpuPeriod(start, end);
|
|
3868
|
+
} catch (err9) {
|
|
3869
|
+
return result(err9 instanceof Error ? err9.message : String(err9), true);
|
|
3870
|
+
}
|
|
3871
|
+
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
3872
|
+
const params = {};
|
|
3873
|
+
const accountIds = tenantAccountIds(ctx.managedAuth);
|
|
3874
|
+
if (accountIds?.length === 0) return result("Subscriber not found", true);
|
|
3875
|
+
if (!ctx.managedAuth.managed && accountIds !== void 0 && accountId !== void 0 && !accountIds.includes(accountId)) return result("Account not found", true);
|
|
3876
|
+
if (accountIds !== void 0) {
|
|
3877
|
+
params.accountId = accountId !== void 0 && accountIds.includes(accountId) ? accountId : accountIds[0];
|
|
3878
|
+
} else if (accountId !== void 0) {
|
|
3879
|
+
params.accountId = accountId;
|
|
3880
|
+
}
|
|
3881
|
+
const scope = await scopeListSubscriberParams({
|
|
3882
|
+
params,
|
|
3883
|
+
managed: ctx.managedAuth.managed,
|
|
3884
|
+
preferredAccountId: ctx.managedAuth.preferredAccountId,
|
|
3885
|
+
call: async (method, callParams) => {
|
|
3886
|
+
const response = await safeCall(ctx.env, token2, method, callParams);
|
|
3887
|
+
if (response.error) throw new Error(response.error);
|
|
3888
|
+
return response.data;
|
|
3889
|
+
}
|
|
3890
|
+
});
|
|
3891
|
+
if (!scope.ok) return result(scope.message, true);
|
|
3892
|
+
const [subsResult, templatesResult, resellerId] = await Promise.all([
|
|
3893
|
+
safeCall(ctx.env, token2, "listSubscriber", scope.params),
|
|
3894
|
+
safeCall(ctx.env, token2, "listPrepaidPackageTemplate", {}),
|
|
3895
|
+
getDefaultResellerId(ctx.env, token2)
|
|
3896
|
+
]);
|
|
3897
|
+
if (subsResult.error) return result(`Failed to fetch subscribers: ${subsResult.error}`, true);
|
|
3898
|
+
const subscribers = ocsArray(subsResult.data, ["subscriberList", "subscribers", "subscriber"]);
|
|
3899
|
+
const distinct = [...new Map(subscribers.map((sub, index) => [subscriberIccid(sub) || `missing-iccid:${index}`, sub])).entries()];
|
|
3900
|
+
const sample = distinct.slice(0, 100);
|
|
3901
|
+
const reads = [];
|
|
3902
|
+
const snapshots = [];
|
|
3903
|
+
for (let i = 0; i < sample.length; i += 10) {
|
|
3904
|
+
reads.push(...await Promise.all(sample.slice(i, i + 10).map(async ([subscriber, sub]) => {
|
|
3905
|
+
const iccid = subscriberIccid(sub);
|
|
3906
|
+
if (!iccid) return { subscriber, data: null, error: "Missing subscriber ICCID" };
|
|
3907
|
+
const access = await assertManagedIccidAccess(
|
|
3908
|
+
ctx.env.CARRIER_OCS_BASE_URL,
|
|
3909
|
+
{ ...ctx.managedAuth, token: token2 },
|
|
3910
|
+
iccid
|
|
3911
|
+
);
|
|
3912
|
+
if (!access.ok) return { subscriber, data: null, error: access.error };
|
|
3913
|
+
const usage = await safeCall(ctx.env, token2, "subscriberUsageOverPeriod", {
|
|
3914
|
+
subscriber: { iccid },
|
|
3915
|
+
period
|
|
3916
|
+
});
|
|
3917
|
+
const current = await safeCall(ctx.env, token2, "getSingleSubscriber", { iccid });
|
|
3918
|
+
if (!isManagedSubscriberDenied(ctx.managedAuth, current.data)) {
|
|
3919
|
+
snapshots.push(marketingSnapshot(sub, current.data));
|
|
3920
|
+
}
|
|
3921
|
+
return { subscriber, data: usage.data, error: usage.error };
|
|
3922
|
+
})));
|
|
3923
|
+
}
|
|
3924
|
+
const envelope = subscriberListEnvelope(subsResult.data);
|
|
3925
|
+
const total = typeof envelope?.nbFound === "number" && Number.isFinite(envelope.nbFound) ? Math.max(distinct.length, envelope.nbFound) : distinct.length;
|
|
3926
|
+
const report = regionalArpu(reads, {
|
|
3927
|
+
period,
|
|
3928
|
+
total_subscribers: total,
|
|
3929
|
+
truncated: envelope?.hasMore === true || envelope?.truncated === true || sample.length < distinct.length
|
|
3930
|
+
});
|
|
3931
|
+
const sections = ["# Marketing Intelligence Report\n", renderRegionalArpu(report)];
|
|
3932
|
+
if (scope.defaultAccount) sections.push(scope.defaultAccount.note);
|
|
3933
|
+
const zonesResult = await safeCall(ctx.env, token2, "listDetailedLocationZone", resellerId);
|
|
3934
|
+
const zones = ocsArray(zonesResult.data, "zones");
|
|
3935
|
+
const templates = ocsArray(templatesResult.data, "templates");
|
|
3936
|
+
sections.push(
|
|
3937
|
+
`
|
|
3938
|
+
## Coverage Catalog
|
|
3939
|
+
- Location zones available: ${zonesResult.error ? `Unavailable (${zonesResult.error})` : zones.length}
|
|
3940
|
+
- Package templates available: ${templatesResult.error ? `Unavailable (${templatesResult.error})` : templates.length}`
|
|
3941
|
+
);
|
|
3942
|
+
sections.push(renderMarketingContext(snapshots, sample.length, templates));
|
|
3943
|
+
return result(sections.join("\n"));
|
|
3944
|
+
});
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
// src/intelligence.ts
|
|
3948
|
+
async function safeCall2(env, token2, method, params = {}) {
|
|
3949
|
+
try {
|
|
3950
|
+
const client2 = new OcsClient(env.CARRIER_OCS_BASE_URL, token2);
|
|
3951
|
+
const data = await client2.call(method, params);
|
|
3952
|
+
return { data, error: null };
|
|
3953
|
+
} catch (err9) {
|
|
3954
|
+
return { data: null, error: err9 instanceof Error ? err9.message : String(err9) };
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3842
3957
|
async function fetchActiveSubscribers(env, token2, accountId, resellerId) {
|
|
3843
3958
|
let accountIds;
|
|
3844
3959
|
if (accountId !== void 0) {
|
|
3845
3960
|
accountIds = [accountId];
|
|
3846
3961
|
} else {
|
|
3847
|
-
const accountsResult = await
|
|
3962
|
+
const accountsResult = await safeCall2(
|
|
3848
3963
|
env,
|
|
3849
3964
|
token2,
|
|
3850
3965
|
"listResellerAccount",
|
|
@@ -3857,7 +3972,7 @@ async function fetchActiveSubscribers(env, token2, accountId, resellerId) {
|
|
|
3857
3972
|
}
|
|
3858
3973
|
const aggregated = [];
|
|
3859
3974
|
for (const acctId of accountIds) {
|
|
3860
|
-
const subResult = await
|
|
3975
|
+
const subResult = await safeCall2(
|
|
3861
3976
|
env,
|
|
3862
3977
|
token2,
|
|
3863
3978
|
"listSubscriber",
|
|
@@ -3868,7 +3983,7 @@ async function fetchActiveSubscribers(env, token2, accountId, resellerId) {
|
|
|
3868
3983
|
}
|
|
3869
3984
|
return { data: filterActiveSubscribers(aggregated), error: null };
|
|
3870
3985
|
}
|
|
3871
|
-
function
|
|
3986
|
+
function result2(text, isError = false) {
|
|
3872
3987
|
return { content: [{ type: "text", text }], ...isError ? { isError: true } : {} };
|
|
3873
3988
|
}
|
|
3874
3989
|
function registerIntelligenceTools(server2, ctx) {
|
|
@@ -3876,7 +3991,7 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3876
3991
|
title: "Diagnose Subscriber Issues",
|
|
3877
3992
|
description: "Smart diagnostic that chains multiple API calls to analyze why a subscriber may be offline, throttled, or having connectivity issues. Returns a structured diagnosis with root cause analysis and recommended actions.",
|
|
3878
3993
|
inputSchema: {
|
|
3879
|
-
iccid:
|
|
3994
|
+
iccid: z3.string().describe("The subscriber ICCID to diagnose")
|
|
3880
3995
|
},
|
|
3881
3996
|
annotations: { readOnlyHint: true }
|
|
3882
3997
|
}, async ({ iccid }) => {
|
|
@@ -3884,9 +3999,9 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3884
3999
|
const findings = [];
|
|
3885
4000
|
const actions = [];
|
|
3886
4001
|
let severity = "healthy";
|
|
3887
|
-
const sub = await
|
|
3888
|
-
if (sub.error) return
|
|
3889
|
-
if (!sub.data) return
|
|
4002
|
+
const sub = await safeCall2(ctx.env, token2, "getSingleSubscriber", { iccid });
|
|
4003
|
+
if (sub.error) return result2(`Failed to fetch subscriber: ${sub.error}`, true);
|
|
4004
|
+
if (!sub.data) return result2("Subscriber not found", true);
|
|
3890
4005
|
const status = (extractSubscriberStatus(sub.data) ?? "").toUpperCase();
|
|
3891
4006
|
const balance = Number(sub.data.balance ?? 0);
|
|
3892
4007
|
if (status === "") {
|
|
@@ -3897,7 +4012,7 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3897
4012
|
actions.push(`Reactivate subscriber via modify_subscriber_status`);
|
|
3898
4013
|
severity = "critical";
|
|
3899
4014
|
}
|
|
3900
|
-
const pkgs = await
|
|
4015
|
+
const pkgs = await safeCall2(ctx.env, token2, "listSubscriberPrepaidPackages", { iccid });
|
|
3901
4016
|
const allPkgs = prepaidPackageRows(pkgs.data);
|
|
3902
4017
|
const activePkgs = allPkgs.filter((p) => isActivePackage(p));
|
|
3903
4018
|
const stalePkgs = staleActivePackages(allPkgs);
|
|
@@ -3949,7 +4064,7 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3949
4064
|
if (severity !== "critical") severity = "warning";
|
|
3950
4065
|
}
|
|
3951
4066
|
const simId = subscriberSimId(sub.data);
|
|
3952
|
-
const sim = simId !== void 0 ? await
|
|
4067
|
+
const sim = simId !== void 0 ? await safeCall2(ctx.env, token2, "getSimProviderStatus", simId) : { data: null, error: null };
|
|
3953
4068
|
if (sim.data) {
|
|
3954
4069
|
const simStatus = (extractSimProviderStatus(sim.data) ?? "").toUpperCase();
|
|
3955
4070
|
if (simStatus && !["ENABLED", "ACTIVE", "ACTIVATED"].includes(simStatus)) {
|
|
@@ -3960,7 +4075,7 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3960
4075
|
}
|
|
3961
4076
|
const now = /* @__PURE__ */ new Date();
|
|
3962
4077
|
const eventWindow = lastNDaysPeriod(3, now);
|
|
3963
|
-
const events = await
|
|
4078
|
+
const events = await safeCall2(ctx.env, token2, "subscriberNetworkEventsOverPeriod", {
|
|
3964
4079
|
subscriber: { iccid },
|
|
3965
4080
|
period: eventWindow
|
|
3966
4081
|
});
|
|
@@ -3998,7 +4113,7 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3998
4113
|
}
|
|
3999
4114
|
}
|
|
4000
4115
|
const imsiForBitrate = imsiFromSubscriberRecord(sub.data) ?? null;
|
|
4001
|
-
const bitrate = imsiForBitrate ? await
|
|
4116
|
+
const bitrate = imsiForBitrate ? await safeCall2(ctx.env, token2, "hlrGetBitrate", { imsi: imsiForBitrate }) : { data: null, error: null };
|
|
4002
4117
|
if (bitrate.data) {
|
|
4003
4118
|
const rate = Number(bitrate.data.bitrate ?? bitrate.data.maxBitrate ?? 0);
|
|
4004
4119
|
if (rate > 0 && rate < 1e6) {
|
|
@@ -4028,26 +4143,26 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
4028
4143
|
`- Balance: ${balance}`,
|
|
4029
4144
|
`- Active Packages: ${pkgs.error ? "unknown" : activePkgs.length}`
|
|
4030
4145
|
].join("\n");
|
|
4031
|
-
return
|
|
4146
|
+
return result2(report);
|
|
4032
4147
|
});
|
|
4033
4148
|
server2.registerTool("fleet_health", {
|
|
4034
4149
|
title: "Fleet Health Dashboard",
|
|
4035
4150
|
description: "Aggregates eSIM status counts, low-balance accounts, and provides a fleet-wide health summary in a single call. Identifies accounts that need attention.",
|
|
4036
4151
|
inputSchema: {
|
|
4037
|
-
accountId:
|
|
4152
|
+
accountId: z3.number().optional().describe("Filter to a specific account (omit for all)")
|
|
4038
4153
|
},
|
|
4039
4154
|
annotations: { readOnlyHint: true }
|
|
4040
4155
|
}, async ({ accountId }) => {
|
|
4041
4156
|
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
4042
4157
|
const resellerId = await getDefaultResellerId(ctx.env, token2).catch(() => void 0);
|
|
4043
4158
|
const [statusResult, accountsResult, resellerInfoResult] = await Promise.all([
|
|
4044
|
-
|
|
4159
|
+
safeCall2(
|
|
4045
4160
|
ctx.env,
|
|
4046
4161
|
token2,
|
|
4047
4162
|
"esimStatusPerAccount",
|
|
4048
4163
|
accountId !== void 0 ? { accountId } : resellerId !== void 0 ? { resellerId } : {}
|
|
4049
4164
|
),
|
|
4050
|
-
|
|
4165
|
+
safeCall2(
|
|
4051
4166
|
ctx.env,
|
|
4052
4167
|
token2,
|
|
4053
4168
|
"listResellerAccount",
|
|
@@ -4057,7 +4172,7 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
4057
4172
|
// parent is out of credit, and that is the one state which silently
|
|
4058
4173
|
// zeroes every rating group (2026-08-28: reseller 1170 at 0.00 while
|
|
4059
4174
|
// fleet_health reported "require no action").
|
|
4060
|
-
resellerId !== void 0 ?
|
|
4175
|
+
resellerId !== void 0 ? safeCall2(
|
|
4061
4176
|
ctx.env,
|
|
4062
4177
|
token2,
|
|
4063
4178
|
"getResellerInfo",
|
|
@@ -4172,15 +4287,15 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4172
4287
|
## Errors`);
|
|
4173
4288
|
if (statusResult.error) sections.push(`- esimStatusPerAccount: ${statusResult.error}`);
|
|
4174
4289
|
if (accountsResult.error) sections.push(`- listResellerAccount: ${accountsResult.error}`);
|
|
4175
|
-
return
|
|
4290
|
+
return result2(sections.join("\n"), true);
|
|
4176
4291
|
}
|
|
4177
|
-
return
|
|
4292
|
+
return result2(sections.join("\n"));
|
|
4178
4293
|
});
|
|
4179
4294
|
server2.registerTool("detect_usage_anomalies", {
|
|
4180
4295
|
title: "Detect Usage Anomalies",
|
|
4181
4296
|
description: "Analyzes a subscriber's recent usage patterns over the last 7 days to detect anomalies: sudden spikes, unusual off-hours activity, or consumption rates that would exhaust the package before expiry.",
|
|
4182
4297
|
inputSchema: {
|
|
4183
|
-
iccid:
|
|
4298
|
+
iccid: z3.string().describe("The subscriber ICCID to analyze")
|
|
4184
4299
|
},
|
|
4185
4300
|
annotations: { readOnlyHint: true }
|
|
4186
4301
|
}, async ({ iccid }) => {
|
|
@@ -4188,13 +4303,13 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4188
4303
|
const now = /* @__PURE__ */ new Date();
|
|
4189
4304
|
const usagePeriod = lastNDaysPeriod(OCS_MAX_USAGE_WINDOW_DAYS, now);
|
|
4190
4305
|
const [usageResult, pkgResult] = await Promise.all([
|
|
4191
|
-
|
|
4306
|
+
safeCall2(ctx.env, token2, "subscriberUsageOverPeriod", {
|
|
4192
4307
|
subscriber: { iccid },
|
|
4193
4308
|
period: usagePeriod
|
|
4194
4309
|
}),
|
|
4195
|
-
|
|
4310
|
+
safeCall2(ctx.env, token2, "listSubscriberPrepaidPackages", { iccid })
|
|
4196
4311
|
]);
|
|
4197
|
-
if (usageResult.error) return
|
|
4312
|
+
if (usageResult.error) return result2(`Failed to fetch usage: ${usageResult.error}`, true);
|
|
4198
4313
|
const sections = [`# Usage Anomaly Report: ${iccid}
|
|
4199
4314
|
`];
|
|
4200
4315
|
const anomalies = [];
|
|
@@ -4255,13 +4370,13 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4255
4370
|
sections.push(`
|
|
4256
4371
|
## No anomalies detected \u2014 usage appears normal.`);
|
|
4257
4372
|
}
|
|
4258
|
-
return
|
|
4373
|
+
return result2(sections.join("\n"));
|
|
4259
4374
|
});
|
|
4260
4375
|
server2.registerTool("optimize_package", {
|
|
4261
4376
|
title: "Package Optimization Advisor",
|
|
4262
4377
|
description: "Compares a subscriber's actual usage against their current package and all available templates. Recommends better-fit packages to reduce waste or prevent overages. Calculates potential savings.",
|
|
4263
4378
|
inputSchema: {
|
|
4264
|
-
iccid:
|
|
4379
|
+
iccid: z3.string().describe("The subscriber ICCID to optimize")
|
|
4265
4380
|
},
|
|
4266
4381
|
annotations: { readOnlyHint: true }
|
|
4267
4382
|
}, async ({ iccid }) => {
|
|
@@ -4269,12 +4384,12 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4269
4384
|
const now = /* @__PURE__ */ new Date();
|
|
4270
4385
|
const usagePeriod = lastNDaysPeriod(OCS_MAX_USAGE_WINDOW_DAYS, now);
|
|
4271
4386
|
const [usageResult, pkgResult, templatesResult] = await Promise.all([
|
|
4272
|
-
|
|
4387
|
+
safeCall2(ctx.env, token2, "subscriberUsageOverPeriod", {
|
|
4273
4388
|
subscriber: { iccid },
|
|
4274
4389
|
period: usagePeriod
|
|
4275
4390
|
}),
|
|
4276
|
-
|
|
4277
|
-
|
|
4391
|
+
safeCall2(ctx.env, token2, "listSubscriberPrepaidPackages", { iccid }),
|
|
4392
|
+
safeCall2(ctx.env, token2, "listPrepaidPackageTemplate", {})
|
|
4278
4393
|
]);
|
|
4279
4394
|
const sections = [`# Package Optimization: ${iccid}
|
|
4280
4395
|
`];
|
|
@@ -4340,13 +4455,13 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4340
4455
|
sections.push(`
|
|
4341
4456
|
*No usage data available \u2014 cannot recommend packages without usage history.*`);
|
|
4342
4457
|
}
|
|
4343
|
-
return
|
|
4458
|
+
return result2(sections.join("\n"));
|
|
4344
4459
|
});
|
|
4345
4460
|
server2.registerTool("churn_risk", {
|
|
4346
4461
|
title: "Churn Risk Assessment",
|
|
4347
4462
|
description: "Analyzes a subscriber's usage trends, package status, balance, and activity to produce a churn risk score (0-100) with contributing factors and retention recommendations.",
|
|
4348
4463
|
inputSchema: {
|
|
4349
|
-
iccid:
|
|
4464
|
+
iccid: z3.string().describe("The subscriber ICCID to assess")
|
|
4350
4465
|
},
|
|
4351
4466
|
annotations: { readOnlyHint: true }
|
|
4352
4467
|
}, async ({ iccid }) => {
|
|
@@ -4354,13 +4469,13 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4354
4469
|
const now = /* @__PURE__ */ new Date();
|
|
4355
4470
|
const usagePeriod = lastNDaysPeriod(OCS_MAX_USAGE_WINDOW_DAYS, now);
|
|
4356
4471
|
const [subResult, usageResult, pkgResult, activeResult] = await Promise.all([
|
|
4357
|
-
|
|
4358
|
-
|
|
4472
|
+
safeCall2(ctx.env, token2, "getSingleSubscriber", { iccid }),
|
|
4473
|
+
safeCall2(ctx.env, token2, "subscriberUsageOverPeriod", {
|
|
4359
4474
|
subscriber: { iccid },
|
|
4360
4475
|
period: usagePeriod
|
|
4361
4476
|
}),
|
|
4362
|
-
|
|
4363
|
-
|
|
4477
|
+
safeCall2(ctx.env, token2, "listSubscriberPrepaidPackages", { iccid }),
|
|
4478
|
+
safeCall2(ctx.env, token2, "getSubscriberActivePeriod", { iccid })
|
|
4364
4479
|
]);
|
|
4365
4480
|
let riskScore = 0;
|
|
4366
4481
|
const factors = [];
|
|
@@ -4462,14 +4577,14 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4462
4577
|
sections.push("1. No immediate action required");
|
|
4463
4578
|
sections.push("2. Continue monitoring via regular fleet_health checks");
|
|
4464
4579
|
}
|
|
4465
|
-
return
|
|
4580
|
+
return result2(sections.join("\n"));
|
|
4466
4581
|
});
|
|
4467
4582
|
server2.registerTool("audit_network_coverage", {
|
|
4468
4583
|
title: "Network Coverage Audit",
|
|
4469
4584
|
description: "Analyzes which networks your subscribers are actually connecting to in a given country or across all countries. Compares against your steering lists to identify mismatches \u2014 subscribers roaming on expensive or non-preferred networks. Use this to answer: 'Am I using the right networks in country X?'",
|
|
4470
4585
|
inputSchema: {
|
|
4471
|
-
accountId:
|
|
4472
|
-
limit:
|
|
4586
|
+
accountId: z3.number().optional().describe("Filter to a specific account"),
|
|
4587
|
+
limit: z3.number().optional().describe("Max subscribers to sample (default 50)")
|
|
4473
4588
|
},
|
|
4474
4589
|
annotations: { readOnlyHint: true }
|
|
4475
4590
|
}, async ({ accountId, limit: sampleLimit }) => {
|
|
@@ -4478,9 +4593,9 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4478
4593
|
const resellerId = await getDefaultResellerId(ctx.env, token2);
|
|
4479
4594
|
const [subsResult, steeringResult] = await Promise.all([
|
|
4480
4595
|
fetchActiveSubscribers(ctx.env, token2, accountId, resellerId),
|
|
4481
|
-
|
|
4596
|
+
safeCall2(ctx.env, token2, "listSteeringList", resellerId)
|
|
4482
4597
|
]);
|
|
4483
|
-
if (subsResult.error) return
|
|
4598
|
+
if (subsResult.error) return result2(`Failed to fetch subscribers: ${subsResult.error}`, true);
|
|
4484
4599
|
const sections = [`# Network Coverage Audit
|
|
4485
4600
|
`];
|
|
4486
4601
|
const steeringMap = /* @__PURE__ */ new Map();
|
|
@@ -4500,7 +4615,7 @@ Package-only accounts at 0 balance require no action.`);
|
|
|
4500
4615
|
const batch = subs.slice(i, i + batchSize);
|
|
4501
4616
|
const locations = await Promise.all(
|
|
4502
4617
|
batch.map(
|
|
4503
|
-
(s) =>
|
|
4618
|
+
(s) => safeCall2(ctx.env, token2, "getSubscriberLocation", {
|
|
4504
4619
|
iccid: String(s.iccid ?? "")
|
|
4505
4620
|
})
|
|
4506
4621
|
)
|
|
@@ -4542,129 +4657,16 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
4542
4657
|
} else {
|
|
4543
4658
|
sections.push("No location data available for sampled subscribers.");
|
|
4544
4659
|
}
|
|
4545
|
-
return
|
|
4546
|
-
});
|
|
4547
|
-
server2.registerTool("marketing_intelligence", {
|
|
4548
|
-
title: "Marketing Intelligence Report",
|
|
4549
|
-
description: "Analyzes your subscriber base to identify high-growth markets, underserved regions, and revenue concentration. Answers: 'Which countries should I target with marketing?' and 'Where are my most valuable subscribers?'",
|
|
4550
|
-
inputSchema: {
|
|
4551
|
-
accountId: z2.number().optional().describe("Filter to a specific account")
|
|
4552
|
-
},
|
|
4553
|
-
annotations: { readOnlyHint: true }
|
|
4554
|
-
}, async ({ accountId }) => {
|
|
4555
|
-
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
4556
|
-
const params = {};
|
|
4557
|
-
if (accountId !== void 0) params.accountId = accountId;
|
|
4558
|
-
const [subsResult, templatesResult, resellerId] = await Promise.all([
|
|
4559
|
-
safeCall(ctx.env, token2, "listSubscriber", params),
|
|
4560
|
-
safeCall(ctx.env, token2, "listPrepaidPackageTemplate", {}),
|
|
4561
|
-
getDefaultResellerId(ctx.env, token2)
|
|
4562
|
-
]);
|
|
4563
|
-
const zonesResult = await safeCall(
|
|
4564
|
-
ctx.env,
|
|
4565
|
-
token2,
|
|
4566
|
-
"listDetailedLocationZone",
|
|
4567
|
-
resellerId
|
|
4568
|
-
);
|
|
4569
|
-
const sections = [`# Marketing Intelligence Report
|
|
4570
|
-
`];
|
|
4571
|
-
if (subsResult.data && Array.isArray(subsResult.data)) {
|
|
4572
|
-
const total = subsResult.data.length;
|
|
4573
|
-
sections.push(`## Fleet Size: ${total} subscribers sampled
|
|
4574
|
-
`);
|
|
4575
|
-
const sample = subsResult.data.slice(0, 100);
|
|
4576
|
-
const countryData = /* @__PURE__ */ new Map();
|
|
4577
|
-
const batchSize = 10;
|
|
4578
|
-
for (let i = 0; i < sample.length; i += batchSize) {
|
|
4579
|
-
const batch = sample.slice(i, i + batchSize);
|
|
4580
|
-
const locations = await Promise.all(
|
|
4581
|
-
batch.map(
|
|
4582
|
-
(s) => safeCall(ctx.env, token2, "getSubscriberLocation", {
|
|
4583
|
-
iccid: String(s.iccid ?? "")
|
|
4584
|
-
})
|
|
4585
|
-
)
|
|
4586
|
-
);
|
|
4587
|
-
for (let j = 0; j < batch.length; j++) {
|
|
4588
|
-
const loc = locations[j];
|
|
4589
|
-
const sub = batch[j];
|
|
4590
|
-
const country = loc.data ? String(loc.data.country ?? loc.data.countryCode ?? "Unknown") : "Unknown";
|
|
4591
|
-
if (!countryData.has(country)) {
|
|
4592
|
-
countryData.set(country, { subscribers: 0, activePackages: 0, totalBalance: 0 });
|
|
4593
|
-
}
|
|
4594
|
-
const cd = countryData.get(country);
|
|
4595
|
-
cd.subscribers++;
|
|
4596
|
-
cd.totalBalance += Number(sub.balance ?? 0);
|
|
4597
|
-
}
|
|
4598
|
-
}
|
|
4599
|
-
if (countryData.size > 0) {
|
|
4600
|
-
const sorted = [...countryData.entries()].sort((a, b) => b[1].subscribers - a[1].subscribers);
|
|
4601
|
-
sections.push(`## Subscriber Concentration by Country`);
|
|
4602
|
-
sections.push(`| Country | Subscribers | % of Fleet | Avg Balance |`);
|
|
4603
|
-
sections.push(`|---------|-----------|------------|-------------|`);
|
|
4604
|
-
for (const [country, data] of sorted) {
|
|
4605
|
-
const pct = (data.subscribers / sample.length * 100).toFixed(1);
|
|
4606
|
-
const avgBal = (data.totalBalance / data.subscribers).toFixed(2);
|
|
4607
|
-
sections.push(`| ${country} | ${data.subscribers} | ${pct}% | ${avgBal} |`);
|
|
4608
|
-
}
|
|
4609
|
-
sections.push(`
|
|
4610
|
-
## Market Insights`);
|
|
4611
|
-
const topMarket = sorted[0];
|
|
4612
|
-
if (topMarket) {
|
|
4613
|
-
sections.push(`- **Strongest market**: ${topMarket[0]} (${topMarket[1].subscribers} subscribers)`);
|
|
4614
|
-
if (topMarket[1].subscribers / sample.length > 0.5) {
|
|
4615
|
-
sections.push(` Revenue concentration risk \u2014 >50% of fleet in one market`);
|
|
4616
|
-
}
|
|
4617
|
-
}
|
|
4618
|
-
const highValue = sorted.filter(([, d]) => d.subscribers >= 3).sort((a, b) => b[1].totalBalance / b[1].subscribers - a[1].totalBalance / a[1].subscribers).slice(0, 3);
|
|
4619
|
-
if (highValue.length > 0) {
|
|
4620
|
-
sections.push(`
|
|
4621
|
-
### High-Value Markets (by avg balance)`);
|
|
4622
|
-
for (const [country, data] of highValue) {
|
|
4623
|
-
sections.push(`- **${country}**: avg balance ${(data.totalBalance / data.subscribers).toFixed(2)} (${data.subscribers} subs)`);
|
|
4624
|
-
}
|
|
4625
|
-
}
|
|
4626
|
-
const emerging = sorted.filter(([, d]) => d.subscribers >= 1 && d.subscribers <= 3);
|
|
4627
|
-
if (emerging.length > 0) {
|
|
4628
|
-
sections.push(`
|
|
4629
|
-
### Emerging Markets (early traction, 1-3 subscribers)`);
|
|
4630
|
-
sections.push(`These markets show initial demand \u2014 consider targeted campaigns:`);
|
|
4631
|
-
for (const [country, data] of emerging) {
|
|
4632
|
-
sections.push(`- ${country}: ${data.subscribers} subscriber(s)`);
|
|
4633
|
-
}
|
|
4634
|
-
}
|
|
4635
|
-
}
|
|
4636
|
-
}
|
|
4637
|
-
if (zonesResult.data && Array.isArray(zonesResult.data)) {
|
|
4638
|
-
sections.push(`
|
|
4639
|
-
## Coverage Catalog`);
|
|
4640
|
-
sections.push(`- Location zones available: ${zonesResult.data.length}`);
|
|
4641
|
-
}
|
|
4642
|
-
if (templatesResult.data && Array.isArray(templatesResult.data)) {
|
|
4643
|
-
sections.push(`- Package templates available: ${templatesResult.data.length}`);
|
|
4644
|
-
const prices = templatesResult.data.map((t) => Number(t.price ?? t.cost ?? 0)).filter((p) => p > 0);
|
|
4645
|
-
if (prices.length > 0) {
|
|
4646
|
-
const avgPrice = prices.reduce((a, b) => a + b, 0) / prices.length;
|
|
4647
|
-
const minPrice = Math.min(...prices);
|
|
4648
|
-
const maxPrice = Math.max(...prices);
|
|
4649
|
-
sections.push(`
|
|
4650
|
-
### Pricing Range`);
|
|
4651
|
-
sections.push(`- Min: ${minPrice.toFixed(2)} | Avg: ${avgPrice.toFixed(2)} | Max: ${maxPrice.toFixed(2)}`);
|
|
4652
|
-
}
|
|
4653
|
-
}
|
|
4654
|
-
sections.push(`
|
|
4655
|
-
## Recommended Actions`);
|
|
4656
|
-
sections.push(`1. Run \`audit_network_coverage\` to verify network quality in top markets`);
|
|
4657
|
-
sections.push(`2. Run \`high_cost_subscribers\` to identify margin pressure`);
|
|
4658
|
-
sections.push(`3. Consider creating regional package templates for emerging markets`);
|
|
4659
|
-
return result(sections.join("\n"));
|
|
4660
|
+
return result2(sections.join("\n"));
|
|
4660
4661
|
});
|
|
4662
|
+
registerMarketingIntelligenceTool(server2, ctx);
|
|
4661
4663
|
server2.registerTool("high_cost_subscribers", {
|
|
4662
4664
|
title: "High Cost Subscriber Report",
|
|
4663
4665
|
description: "Identifies subscribers with disproportionately high data consumption relative to their package value. Finds subscribers burning through data at rates that erode margins. Answers: 'Which subscribers are costing me money?'",
|
|
4664
4666
|
inputSchema: {
|
|
4665
|
-
accountId:
|
|
4666
|
-
limit:
|
|
4667
|
-
thresholdPct:
|
|
4667
|
+
accountId: z3.number().optional().describe("Filter to a specific account"),
|
|
4668
|
+
limit: z3.number().optional().describe("Max subscribers to analyze (default 100)"),
|
|
4669
|
+
thresholdPct: z3.number().optional().describe("Usage % threshold to flag (default 80)")
|
|
4668
4670
|
},
|
|
4669
4671
|
annotations: { readOnlyHint: true }
|
|
4670
4672
|
}, async ({ accountId, limit: maxLimit, thresholdPct }) => {
|
|
@@ -4673,8 +4675,8 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
4673
4675
|
const threshold = thresholdPct ?? 80;
|
|
4674
4676
|
const resellerId = await getDefaultResellerId(ctx.env, token2);
|
|
4675
4677
|
const subsResult = await fetchActiveSubscribers(ctx.env, token2, accountId, resellerId);
|
|
4676
|
-
if (subsResult.error) return
|
|
4677
|
-
if (!subsResult.data || subsResult.data.length === 0) return
|
|
4678
|
+
if (subsResult.error) return result2(`Failed to fetch subscribers: ${subsResult.error}`, true);
|
|
4679
|
+
if (!subsResult.data || subsResult.data.length === 0) return result2("No subscribers found", true);
|
|
4678
4680
|
const sections = [`# High Cost Subscriber Report
|
|
4679
4681
|
`];
|
|
4680
4682
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -4688,12 +4690,12 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
4688
4690
|
batch.map(async (sub) => {
|
|
4689
4691
|
const iccid = String(sub.iccid ?? "");
|
|
4690
4692
|
const [usage, pkgs, loc] = await Promise.all([
|
|
4691
|
-
|
|
4693
|
+
safeCall2(ctx.env, token2, "subscriberUsageOverPeriod", {
|
|
4692
4694
|
subscriber: { iccid },
|
|
4693
4695
|
period: usagePeriod
|
|
4694
4696
|
}),
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
+
safeCall2(ctx.env, token2, "listSubscriberPrepaidPackages", { iccid }),
|
|
4698
|
+
safeCall2(ctx.env, token2, "getSubscriberLocation", { iccid })
|
|
4697
4699
|
]);
|
|
4698
4700
|
const dailyRows = extractDailyUsage(usage.data);
|
|
4699
4701
|
const dailyAvgBytes = dailyRows.length > 0 ? dailyRows.reduce((sum, r) => sum + r.bytes, 0) / dailyRows.length : 0;
|
|
@@ -4767,39 +4769,39 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
4767
4769
|
sections.push(`3. Run \`optimize_package\` on flagged ICCIDs to find better-fit plans`);
|
|
4768
4770
|
sections.push(`4. Negotiate better wholesale rates for high-volume countries`);
|
|
4769
4771
|
}
|
|
4770
|
-
return
|
|
4772
|
+
return result2(sections.join("\n"));
|
|
4771
4773
|
});
|
|
4772
4774
|
server2.registerTool("detect_country_entry", {
|
|
4773
4775
|
title: "Detect Country Entry",
|
|
4774
4776
|
description: "Detects when a subscriber has entered a new country by reading networkInfo.lastMcc from getSingleSubscriber (one cheap OCS call \u2014 avoids the per-call cost of getSubscriberLocationByCellId). Resolves MCC \u2192 ISO 3166-1 alpha-2 and optionally diffs against a caller-supplied expectedCountry to return countryChanged. Designed for downstream country-entry upsell workflows (e.g. mango.talk SMS/push offers). NOT AN AI TOOL: this is a deterministic MCC lookup and returns no model-written analysis, unlike the eight intelligence composites. COST NOTE: This tool makes exactly one OCS call per invocation. Consumers running polling crons MUST enforce their own rate floor \u2014 this layer provides no throttle.",
|
|
4775
4777
|
inputSchema: {
|
|
4776
|
-
subscriber:
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4778
|
+
subscriber: z3.union([
|
|
4779
|
+
z3.object({ subscriberId: z3.number() }).describe("Internal subscriber ID"),
|
|
4780
|
+
z3.object({ imsi: z3.string() }).describe("IMSI"),
|
|
4781
|
+
z3.object({ iccid: z3.string() }).describe("ICCID"),
|
|
4782
|
+
z3.object({ msisdn: z3.string() }).describe("MSISDN / phone number"),
|
|
4783
|
+
z3.object({ multiImsi: z3.string() }).describe("Multi-IMSI identifier"),
|
|
4784
|
+
z3.object({ activationCode: z3.string() }).describe("eSIM activation code")
|
|
4783
4785
|
]).describe("Subscriber identifier (use exactly one field)"),
|
|
4784
|
-
expectedCountry:
|
|
4786
|
+
expectedCountry: z3.string().length(2).transform((code) => code.toUpperCase()).optional().describe(
|
|
4785
4787
|
'Caller\u2019s last-known ISO 3166-1 alpha-2 country for this subscriber (e.g. "RU"). When provided, countryChanged is included in the response.'
|
|
4786
4788
|
)
|
|
4787
4789
|
},
|
|
4788
4790
|
annotations: { readOnlyHint: true }
|
|
4789
4791
|
}, async ({ subscriber, expectedCountry }) => {
|
|
4790
4792
|
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
4791
|
-
const sub = await
|
|
4793
|
+
const sub = await safeCall2(
|
|
4792
4794
|
ctx.env,
|
|
4793
4795
|
token2,
|
|
4794
4796
|
"getSingleSubscriber",
|
|
4795
4797
|
subscriber
|
|
4796
4798
|
);
|
|
4797
|
-
if (sub.error) return
|
|
4798
|
-
if (!sub.data) return
|
|
4799
|
+
if (sub.error) return result2(`Failed to fetch subscriber: ${sub.error}`, true);
|
|
4800
|
+
if (!sub.data) return result2("Subscriber not found", true);
|
|
4799
4801
|
const subscriberId = sub.data.subscriberId ?? sub.data.id ?? ("subscriberId" in subscriber ? subscriber.subscriberId : void 0);
|
|
4800
4802
|
const networkInfo = sub.data.networkInfo;
|
|
4801
4803
|
if (networkInfo === null || networkInfo === void 0 || typeof networkInfo !== "object") {
|
|
4802
|
-
return
|
|
4804
|
+
return result2(
|
|
4803
4805
|
JSON.stringify({ status: "no_location_data", subscriberId: subscriberId ?? null })
|
|
4804
4806
|
);
|
|
4805
4807
|
}
|
|
@@ -4807,7 +4809,7 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
4807
4809
|
const lastMnc = networkInfo.lastMnc != null ? Number(networkInfo.lastMnc) : null;
|
|
4808
4810
|
const lastSeenAtUtc = networkInfo.time != null ? String(networkInfo.time) : null;
|
|
4809
4811
|
if (lastMcc === null || isNaN(lastMcc)) {
|
|
4810
|
-
return
|
|
4812
|
+
return result2(
|
|
4811
4813
|
JSON.stringify({ status: "no_location_data", subscriberId: subscriberId ?? null })
|
|
4812
4814
|
);
|
|
4813
4815
|
}
|
|
@@ -4825,14 +4827,14 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
4825
4827
|
response.expectedCountry = expectedCountry;
|
|
4826
4828
|
response.countryChanged = currentCountry !== null ? currentCountry !== expectedCountry : null;
|
|
4827
4829
|
}
|
|
4828
|
-
return
|
|
4830
|
+
return result2(JSON.stringify(response, null, 2));
|
|
4829
4831
|
});
|
|
4830
4832
|
}
|
|
4831
4833
|
|
|
4832
4834
|
// src/tools-backlog.ts
|
|
4833
|
-
import { z as
|
|
4835
|
+
import { z as z4 } from "zod";
|
|
4834
4836
|
var DRY_RUN_FIELD2 = {
|
|
4835
|
-
dry_run:
|
|
4837
|
+
dry_run: z4.boolean().optional().describe(
|
|
4836
4838
|
"If true, do not call OCS \u2014 return the would-be request for confirmation"
|
|
4837
4839
|
)
|
|
4838
4840
|
};
|
|
@@ -4862,9 +4864,9 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4862
4864
|
title: "Assign Phone Number to Subscriber",
|
|
4863
4865
|
description: "Use this to assign a phone number (MSISDN) to a subscriber. Supports both fake/test MSISDNs and real production MSISDNs via the `phone_type` parameter. Required for MSISDN assignment workflows before activating voice services. Params: `iccid` (subscriber identifier), `phone_number` (E.164 format, e.g. +31612345678), `phone_type` ('fake' for test/dev, 'real' for production). Returns: updated subscriber record with the new MSISDN. Do NOT use this to check a subscriber's current MSISDN \u2014 use `get_subscriber` instead.",
|
|
4864
4866
|
inputSchema: {
|
|
4865
|
-
iccid:
|
|
4866
|
-
phone_number:
|
|
4867
|
-
phone_type:
|
|
4867
|
+
iccid: z4.string().describe("The subscriber ICCID (20-digit ICC identifier)"),
|
|
4868
|
+
phone_number: z4.string().describe("E.164 phone number to assign (e.g. +31612345678)"),
|
|
4869
|
+
phone_type: z4.enum(["fake", "real"]).describe(
|
|
4868
4870
|
"'fake' assigns a test/dev MSISDN (affectSubscriberFakePhoneNumber in OCS); 'real' assigns a production MSISDN (affectSubscriberRealPhoneNumber in OCS)"
|
|
4869
4871
|
),
|
|
4870
4872
|
...DRY_RUN_FIELD2
|
|
@@ -4879,9 +4881,9 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4879
4881
|
async ({ iccid, phone_number, phone_type }, token2) => {
|
|
4880
4882
|
const ocsMethod = phone_type === "fake" ? "affectSubscriberFakePhoneNumber" : "affectSubscriberRealPhoneNumber";
|
|
4881
4883
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
4882
|
-
const
|
|
4884
|
+
const result3 = await client2.call(ocsMethod, { subscriber: iccid, phoneNumber: phone_number });
|
|
4883
4885
|
return {
|
|
4884
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
4886
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
4885
4887
|
};
|
|
4886
4888
|
}
|
|
4887
4889
|
)
|
|
@@ -4892,14 +4894,14 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4892
4894
|
title: "Get Location by Cell ID (GeoSense)",
|
|
4893
4895
|
description: "Powered by Bridge4IP GeoSense \u2014 cell-level location resolution with sub-cell accuracy where available. Use this to resolve a cell tower tuple (radio type + MCC + MNC + LAC + optional cellId) to a latitude/longitude estimate. No subscriber identifier required \u2014 caller supplies cell parameters directly. Useful for fraud detection, roaming cost attribution, and network troubleshooting when you have raw cell info from an external source (e.g. a Relay LU webhook event). Params: `radio_type` ('2G'|'3G'|'4G'|'5G'|'NB-IoT'; also accepts 'NBIOT'|'nb-iot'|'nbiot' \u2014 normalised to 'NB-IoT'), `mcc` (int), `mnc` (int), `lac` (int), `cell_id` (int, optional but strongly recommended for accuracy), `signal_strength` (number dBm, optional). Returns: { latitude, longitude, accuracy } \u2014 accuracy is median error in meters at 50% confidence. Without cell_id accuracy degrades significantly (>10 km). Do NOT use this for bulk fleet location sweeps \u2014 one OCS call per cell tower; use `audit_network_coverage` for fleet-level analysis instead.",
|
|
4894
4896
|
inputSchema: {
|
|
4895
|
-
radio_type:
|
|
4897
|
+
radio_type: z4.string().transform(normalizeRadioType).refine((v) => VALID_RADIO_TYPES.has(v), {
|
|
4896
4898
|
message: "radio_type must be one of: 2G, 3G, 4G, 5G, NB-IoT (also accepts NBIOT, nb-iot, nbiot)"
|
|
4897
4899
|
}).describe("Radio access technology type: '2G'|'3G'|'4G'|'5G'|'NB-IoT'. Also accepts 'NBIOT'|'nb-iot'|'nbiot' \u2014 normalised to 'NB-IoT'."),
|
|
4898
|
-
mcc:
|
|
4899
|
-
mnc:
|
|
4900
|
-
lac:
|
|
4901
|
-
cell_id:
|
|
4902
|
-
signal_strength:
|
|
4900
|
+
mcc: z4.number().int().describe("Mobile Country Code (e.g. 250 for Russia, 234 for UK)"),
|
|
4901
|
+
mnc: z4.number().int().describe("Mobile Network Code"),
|
|
4902
|
+
lac: z4.number().int().describe("Location Area Code"),
|
|
4903
|
+
cell_id: z4.number().int().optional().describe("Cell tower ID \u2014 strongly recommended for accuracy"),
|
|
4904
|
+
signal_strength: z4.number().optional().describe("Signal strength in dBm (e.g. -89). Optional, improves accuracy.")
|
|
4903
4905
|
},
|
|
4904
4906
|
annotations: { readOnlyHint: true }
|
|
4905
4907
|
},
|
|
@@ -4920,9 +4922,9 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4920
4922
|
const params = { radioType: radio_type, mcc, mnc, lac };
|
|
4921
4923
|
if (cell_id !== void 0) params.cellId = cell_id;
|
|
4922
4924
|
if (signal_strength !== void 0) params.signalStrength = signal_strength;
|
|
4923
|
-
const
|
|
4925
|
+
const result3 = await client2.call("getSubscriberLocationByCellId", params);
|
|
4924
4926
|
return {
|
|
4925
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
4927
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
4926
4928
|
};
|
|
4927
4929
|
}
|
|
4928
4930
|
)
|
|
@@ -4933,7 +4935,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4933
4935
|
title: "List Destination Lists",
|
|
4934
4936
|
description: "Use this to retrieve the full catalog of destination lists available to this reseller. A destination list is a named set of phone number prefixes (country codes) that control which numbers a subscriber may call on a voice/SMS package. Returns: array of destination list records, each with `id`, `name`, and prefix count. Do NOT use this to read the prefixes inside a specific list \u2014 use `list_destination_prefixes` with a known `destinationListId` for that. Do NOT use this for data-only eSIM products without MOC voice; destination lists only apply to packages with voice/SMS allowances.",
|
|
4935
4937
|
inputSchema: {
|
|
4936
|
-
resellerId:
|
|
4938
|
+
resellerId: z4.number().optional().describe("Reseller ID (omit to use the token owner's reseller)")
|
|
4937
4939
|
},
|
|
4938
4940
|
annotations: { readOnlyHint: true }
|
|
4939
4941
|
},
|
|
@@ -4953,9 +4955,9 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4953
4955
|
return resolvedId;
|
|
4954
4956
|
})();
|
|
4955
4957
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
4956
|
-
const
|
|
4958
|
+
const result3 = await client2.call("listDetailedDestinationList", id);
|
|
4957
4959
|
return {
|
|
4958
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
4960
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
4959
4961
|
};
|
|
4960
4962
|
}
|
|
4961
4963
|
)
|
|
@@ -4966,8 +4968,8 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4966
4968
|
title: "Modify Subscriber Mobile Plan",
|
|
4967
4969
|
description: "Use this to change the mobile pricing plan assigned to a specific subscriber. The mobile plan determines per-country rates for data, voice, and SMS. Changing the plan takes effect immediately on the next OCS rating cycle. Params: `iccid` (subscriber identifier), `mobile_plan_id` (integer plan ID \u2014 obtain valid plan IDs from the OCS reseller settings or `get_tariff`). Returns: updated subscriber record confirming the new plan assignment. Do NOT use this to change package allowances \u2014 use `modify_package_limits` for that. Do NOT use this to change account-level pricing \u2014 this only affects the individual subscriber.",
|
|
4968
4970
|
inputSchema: {
|
|
4969
|
-
iccid:
|
|
4970
|
-
mobile_plan_id:
|
|
4971
|
+
iccid: z4.string().describe("The subscriber ICCID (20-digit ICC identifier)"),
|
|
4972
|
+
mobile_plan_id: z4.number().describe("The mobile pricing plan ID to assign to this subscriber"),
|
|
4971
4973
|
...DRY_RUN_FIELD2
|
|
4972
4974
|
},
|
|
4973
4975
|
annotations: { destructiveHint: true }
|
|
@@ -4979,12 +4981,12 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4979
4981
|
ctx,
|
|
4980
4982
|
async ({ iccid, mobile_plan_id }, token2) => {
|
|
4981
4983
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
4982
|
-
const
|
|
4984
|
+
const result3 = await client2.call(
|
|
4983
4985
|
"modifySubscriberMobilePlan",
|
|
4984
4986
|
{ subscriberId: { iccid }, mobilePlanId: mobile_plan_id }
|
|
4985
4987
|
);
|
|
4986
4988
|
return {
|
|
4987
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
4989
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
4988
4990
|
};
|
|
4989
4991
|
}
|
|
4990
4992
|
)
|
|
@@ -4995,11 +4997,11 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
4995
4997
|
title: "Modify Subscriber Package Active Period",
|
|
4996
4998
|
description: "Use this to change the start and/or end date of a prepaid package's active period for a specific subscriber. This controls WHEN the package runs, not what it contains. Useful for scheduling packages in advance (e.g. activate on arrival date) or extending a package that would otherwise expire while the subscriber is still travelling. Params: `iccid` (subscriber identifier), `package_id` (from `list_subscriber_packages`), `start_date` (ISO 8601 date, optional), `end_date` (ISO 8601 date, optional). Returns: updated package record with new active period. Do NOT use this to change a package's data/voice allowance \u2014 use `modify_package_limits`. Do NOT use this to change the expiry date of a package \u2014 use `modify_package_expiry`.",
|
|
4997
4999
|
inputSchema: {
|
|
4998
|
-
iccid:
|
|
4999
|
-
package_id:
|
|
5000
|
-
start_date:
|
|
5001
|
-
end_date:
|
|
5002
|
-
comment:
|
|
5000
|
+
iccid: z4.string().describe("The subscriber ICCID (20-digit ICC identifier)"),
|
|
5001
|
+
package_id: z4.number().describe("The subscriber package ID (from list_subscriber_packages)"),
|
|
5002
|
+
start_date: z4.string().optional().describe("New start date in ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss)"),
|
|
5003
|
+
end_date: z4.string().optional().describe("New end date in ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss)"),
|
|
5004
|
+
comment: z4.string().optional().describe(
|
|
5003
5005
|
"Audit note stored on the OCS package record. OCS requires this field, so a default is sent when it is omitted."
|
|
5004
5006
|
),
|
|
5005
5007
|
...DRY_RUN_FIELD2
|
|
@@ -5027,12 +5029,12 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5027
5029
|
comment,
|
|
5028
5030
|
current
|
|
5029
5031
|
});
|
|
5030
|
-
const
|
|
5032
|
+
const result3 = await client2.call(
|
|
5031
5033
|
"modifySubscriberPrepaidPackageActivePeriod",
|
|
5032
5034
|
params
|
|
5033
5035
|
);
|
|
5034
5036
|
return {
|
|
5035
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5037
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5036
5038
|
};
|
|
5037
5039
|
}
|
|
5038
5040
|
)
|
|
@@ -5043,8 +5045,8 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5043
5045
|
title: "Modify Subscriber VoIP Plan",
|
|
5044
5046
|
description: "Use this to change the VoIP pricing plan assigned to a specific subscriber. VoIP plans control billing rates for VoIP calls made through the OCS platform, separate from the standard mobile plan's call rates. Params: `iccid` (subscriber identifier), `voip_plan_id` (integer VoIP plan ID from the OCS reseller settings). Returns: updated subscriber record confirming the new VoIP plan. Do NOT use this for mobile (non-VoIP) plan changes \u2014 use `modify_subscriber_mobile_plan`. For data-only eSIM products without VoIP services this tool has no effect.",
|
|
5045
5047
|
inputSchema: {
|
|
5046
|
-
iccid:
|
|
5047
|
-
voip_plan_id:
|
|
5048
|
+
iccid: z4.string().describe("The subscriber ICCID (20-digit ICC identifier)"),
|
|
5049
|
+
voip_plan_id: z4.number().describe("The VoIP pricing plan ID to assign to this subscriber"),
|
|
5048
5050
|
...DRY_RUN_FIELD2
|
|
5049
5051
|
},
|
|
5050
5052
|
annotations: { destructiveHint: true }
|
|
@@ -5056,12 +5058,12 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5056
5058
|
ctx,
|
|
5057
5059
|
async ({ iccid, voip_plan_id }, token2) => {
|
|
5058
5060
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
5059
|
-
const
|
|
5061
|
+
const result3 = await client2.call(
|
|
5060
5062
|
"modifySubscriberVoipPlan",
|
|
5061
5063
|
{ subscriberId: { iccid }, voipPlanId: voip_plan_id }
|
|
5062
5064
|
);
|
|
5063
5065
|
return {
|
|
5064
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5066
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5065
5067
|
};
|
|
5066
5068
|
}
|
|
5067
5069
|
)
|
|
@@ -5072,7 +5074,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5072
5074
|
title: "Push Steering List to Subscriber Device",
|
|
5073
5075
|
description: "Use this AFTER `modify_subscriber_steering_list` to actively push the updated OPLMN (operator preference list) to the subscriber's physical eSIM/SIM. Without this call, the steering list assignment change is recorded in OCS but the device continues using the old operator preference list until it performs a network re-registration. This is required for immediate operator switching (e.g. steering a subscriber away from an expensive roaming partner in real time). Params: `iccid` (subscriber identifier). Returns: push confirmation from OCS with delivery status. Do NOT call this without first calling `modify_subscriber_steering_list` \u2014 pushing without an assigned steering list is a no-op and wastes an OCS call.",
|
|
5074
5076
|
inputSchema: {
|
|
5075
|
-
iccid:
|
|
5077
|
+
iccid: z4.string().describe("The subscriber ICCID (20-digit ICC identifier)"),
|
|
5076
5078
|
...DRY_RUN_FIELD2
|
|
5077
5079
|
},
|
|
5078
5080
|
annotations: { destructiveHint: true }
|
|
@@ -5084,12 +5086,12 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5084
5086
|
ctx,
|
|
5085
5087
|
async ({ iccid }, token2) => {
|
|
5086
5088
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
5087
|
-
const
|
|
5089
|
+
const result3 = await client2.call(
|
|
5088
5090
|
"pushSteeringToSubs",
|
|
5089
5091
|
{ iccid }
|
|
5090
5092
|
);
|
|
5091
5093
|
return {
|
|
5092
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5094
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5093
5095
|
};
|
|
5094
5096
|
}
|
|
5095
5097
|
)
|
|
@@ -5100,7 +5102,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5100
5102
|
title: "Reset Subscriber Green Zone Counter",
|
|
5101
5103
|
description: "ADMIN: Use this to reset the Green Zone (Greenzone) volume counter for a subscriber. The Green Zone counter tracks bytes consumed on the reseller-defined whitelist of hosts/IPs after the subscriber's bundle is depleted \u2014 NOT the Diameter Gz/Gy accounting interface. Typically used after a billing dispute or test-cycle reset. This operation is IRREVERSIBLE \u2014 volumeOnGZ is permanently zeroed. Params: `iccid` (subscriber identifier). Returns: new counter state with volumeOnGZ (bytes, normally 0 after reset), lastResetDate, lastUpdateDate. Always call `get_subscriber` with `with_gz_counter=true` first to capture the snapshot. Do NOT use this to pause data usage \u2014 use `set_subscriber_traffic_restrictions` with `dataAllowed=false` instead.",
|
|
5102
5104
|
inputSchema: {
|
|
5103
|
-
iccid:
|
|
5105
|
+
iccid: z4.string().describe("The subscriber ICCID (20-digit ICC identifier)"),
|
|
5104
5106
|
...DRY_RUN_FIELD2
|
|
5105
5107
|
},
|
|
5106
5108
|
annotations: { destructiveHint: true }
|
|
@@ -5112,9 +5114,9 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5112
5114
|
ctx,
|
|
5113
5115
|
async ({ iccid }, token2) => {
|
|
5114
5116
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
5115
|
-
const
|
|
5117
|
+
const result3 = await client2.call("resetSubsGzCounter", { iccid });
|
|
5116
5118
|
return {
|
|
5117
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5119
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5118
5120
|
};
|
|
5119
5121
|
}
|
|
5120
5122
|
)
|
|
@@ -5125,7 +5127,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5125
5127
|
title: "Carrier Webhook / Relay Flag Status",
|
|
5126
5128
|
description: "Use this to check the current Bridge4IP webhook and relay flag configuration for this reseller. Returns the active state of all four traffic relay flags: Relay LU (Update Location \u2014 cell tower changes, closest to country-change signal), Relay Gy (mobile data usage events), Relay VoIP (VoIP usage events), Relay calls+SMS (call and SMS events). Also returns which notification webhooks are enabled (prepaid package usage threshold, reseller low credit, ES2 eSIM status, recurring packages) as a passthrough object. All relay/notification configuration is done in the OCS portal UI \u2014 this tool is READ-ONLY and reflects current state. Relay LU is the highest-value flag: when active, Bridge4IP pushes real-time Update Location events (mcc, mnc, lac, cellId) to the configured HTTP endpoint.",
|
|
5127
5129
|
inputSchema: {
|
|
5128
|
-
reseller_id:
|
|
5130
|
+
reseller_id: z4.number().int().optional().describe("Reseller ID (omit to use the token owner's reseller)")
|
|
5129
5131
|
},
|
|
5130
5132
|
annotations: { readOnlyHint: true }
|
|
5131
5133
|
},
|
|
@@ -5145,7 +5147,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5145
5147
|
const raw = await client2.call("getResellerInfo", params);
|
|
5146
5148
|
const traffic = raw.trafficInfo ?? {};
|
|
5147
5149
|
const notification = raw.notificationInfo ?? {};
|
|
5148
|
-
const
|
|
5150
|
+
const result3 = {
|
|
5149
5151
|
resellerId: raw.id ?? resellerId,
|
|
5150
5152
|
traffic: {
|
|
5151
5153
|
relayGy: traffic.relayGy === true,
|
|
@@ -5156,7 +5158,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5156
5158
|
notification
|
|
5157
5159
|
};
|
|
5158
5160
|
return {
|
|
5159
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5161
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5160
5162
|
};
|
|
5161
5163
|
}
|
|
5162
5164
|
)
|
|
@@ -5167,7 +5169,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5167
5169
|
title: "List VoIP Tariffs",
|
|
5168
5170
|
description: "Use this to list VoIP tariff definitions available to a reseller. Despite the OCS method name (listSubscriberVoipTariff), this is a reseller-level catalog listing \u2014 not a per-ICCID lookup. Use results (or get_reseller_info chargingInfo.voipPlan.id) to feed `list_voip_tariff_rule` for rate detail. Params: `reseller_id` (integer, optional \u2014 omit to use the token owner's reseller). Returns: OCS VoIP tariff records (may be empty when no VoIP catalog is configured). Do NOT use this for mobile wholesale rates \u2014 use `get_tariff` (getCustomerTariff). Do NOT use this to assign a VoIP plan \u2014 use `modify_subscriber_voip_plan`.",
|
|
5169
5171
|
inputSchema: {
|
|
5170
|
-
reseller_id:
|
|
5172
|
+
reseller_id: z4.number().int().positive().optional().describe("Reseller ID (omit to list tariffs for the token owner's reseller)")
|
|
5171
5173
|
},
|
|
5172
5174
|
annotations: { readOnlyHint: true }
|
|
5173
5175
|
},
|
|
@@ -5182,9 +5184,9 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5182
5184
|
if (reseller_id !== void 0) {
|
|
5183
5185
|
params.resellerId = reseller_id;
|
|
5184
5186
|
}
|
|
5185
|
-
const
|
|
5187
|
+
const result3 = await client2.call("listSubscriberVoipTariff", params);
|
|
5186
5188
|
return {
|
|
5187
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5189
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5188
5190
|
};
|
|
5189
5191
|
}
|
|
5190
5192
|
)
|
|
@@ -5195,7 +5197,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5195
5197
|
title: "List VoIP Tariff Rules",
|
|
5196
5198
|
description: "Use this to list the rate rules (costs) for a specific VoIP plan/tariff. OCS expects a bare integer plan id in the request body (not an object). Obtain plan ids from `get_reseller_info` \u2192 chargingInfo.voipPlan.id, or from `list_subscriber_voip_tariff`. Params: `voip_plan_id` (integer, required \u2014 VoIP plan/tariff id). Returns: VoIP tariff rule rows for that plan, or an OCS error when the id is unknown. Do NOT use this for mobile (non-VoIP) wholesale rates \u2014 use `get_tariff`. Do NOT use this to change a subscriber's VoIP plan \u2014 use `modify_subscriber_voip_plan`.",
|
|
5197
5199
|
inputSchema: {
|
|
5198
|
-
voip_plan_id:
|
|
5200
|
+
voip_plan_id: z4.number().int().positive().describe(
|
|
5199
5201
|
"VoIP plan/tariff ID (bare integer to OCS listVoipTariffRule; from get_reseller_info chargingInfo.voipPlan.id or list_subscriber_voip_tariff)"
|
|
5200
5202
|
)
|
|
5201
5203
|
},
|
|
@@ -5208,9 +5210,9 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5208
5210
|
ctx,
|
|
5209
5211
|
async ({ voip_plan_id }, token2) => {
|
|
5210
5212
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
5211
|
-
let
|
|
5213
|
+
let result3;
|
|
5212
5214
|
try {
|
|
5213
|
-
|
|
5215
|
+
result3 = await client2.call("listVoipTariffRule", voip_plan_id);
|
|
5214
5216
|
} catch (err9) {
|
|
5215
5217
|
if (err9 instanceof OcsApiError && err9.code === 11) {
|
|
5216
5218
|
return {
|
|
@@ -5228,7 +5230,7 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5228
5230
|
throw err9;
|
|
5229
5231
|
}
|
|
5230
5232
|
return {
|
|
5231
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5233
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5232
5234
|
};
|
|
5233
5235
|
}
|
|
5234
5236
|
)
|
|
@@ -5239,8 +5241,8 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5239
5241
|
title: "Change Network Profile of Location Zone",
|
|
5240
5242
|
description: "Use this to attach or change the network profile on an existing location zone. A network profile defines sponsor/roaming configuration used when the zone is referenced by package templates. Params: `location_zone_id` (integer from list_detailed_location_zones), `network_profile_id` (integer from list_network_profiles). Returns: OCS confirmation of the updated zone/profile binding. Do NOT use this to create a new location zone \u2014 use `create_location_zone` (which requires networkProfileId at creation time). Do NOT use this for edit/delete of zone TADIG lists \u2014 those remain UI-agent-only (G-19).",
|
|
5241
5243
|
inputSchema: {
|
|
5242
|
-
location_zone_id:
|
|
5243
|
-
network_profile_id:
|
|
5244
|
+
location_zone_id: z4.number().int().positive().describe("Location zone ID (locationZoneId / zoneId from list_detailed_location_zones)"),
|
|
5245
|
+
network_profile_id: z4.number().int().positive().describe("Network profile ID (from list_network_profiles)"),
|
|
5244
5246
|
...DRY_RUN_FIELD2
|
|
5245
5247
|
},
|
|
5246
5248
|
annotations: { destructiveHint: true }
|
|
@@ -5255,12 +5257,12 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5255
5257
|
network_profile_id
|
|
5256
5258
|
}, token2) => {
|
|
5257
5259
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
5258
|
-
const
|
|
5260
|
+
const result3 = await client2.call("changeNetworkProfileOfLocationZone", {
|
|
5259
5261
|
locationZoneId: location_zone_id,
|
|
5260
5262
|
networkProfileId: network_profile_id
|
|
5261
5263
|
});
|
|
5262
5264
|
return {
|
|
5263
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
5265
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
5264
5266
|
};
|
|
5265
5267
|
}
|
|
5266
5268
|
)
|
|
@@ -5268,10 +5270,10 @@ function registerAllBacklogTools(server2, ctx) {
|
|
|
5268
5270
|
}
|
|
5269
5271
|
|
|
5270
5272
|
// src/tools-carrier-ask.ts
|
|
5271
|
-
import { z as
|
|
5273
|
+
import { z as z17 } from "zod";
|
|
5272
5274
|
|
|
5273
5275
|
// src/tools-ui-agent.ts
|
|
5274
|
-
import { z as
|
|
5276
|
+
import { z as z5 } from "zod";
|
|
5275
5277
|
|
|
5276
5278
|
// src/ui-agent-stub.ts
|
|
5277
5279
|
var REMOTE_MCP_URL = "https://mcp.carrier.llc/mcp";
|
|
@@ -5561,13 +5563,13 @@ function wrapPortalHandler(toolName, gapId, requiredScope, ctx, runtime, optIn,
|
|
|
5561
5563
|
throw err9;
|
|
5562
5564
|
}
|
|
5563
5565
|
try {
|
|
5564
|
-
const
|
|
5566
|
+
const result3 = await runUiAgent(
|
|
5565
5567
|
fullPrompt,
|
|
5566
5568
|
`Carrier CLI UI Agent: ${toolName} (${gapId})`,
|
|
5567
5569
|
runtime.env,
|
|
5568
5570
|
{ ownerSub: ctx.props.sub, redact }
|
|
5569
5571
|
);
|
|
5570
|
-
if (!
|
|
5572
|
+
if (!result3.task_id) {
|
|
5571
5573
|
ctx.audit({
|
|
5572
5574
|
tool_name: toolName,
|
|
5573
5575
|
ocs_method: ocsMethod,
|
|
@@ -5584,38 +5586,38 @@ function wrapPortalHandler(toolName, gapId, requiredScope, ctx, runtime, optIn,
|
|
|
5584
5586
|
true
|
|
5585
5587
|
);
|
|
5586
5588
|
}
|
|
5587
|
-
runtime.dispatchedTaskIds.add(
|
|
5589
|
+
runtime.dispatchedTaskIds.add(result3.task_id);
|
|
5588
5590
|
ctx.audit({
|
|
5589
5591
|
tool_name: toolName,
|
|
5590
5592
|
ocs_method: ocsMethod,
|
|
5591
|
-
status:
|
|
5593
|
+
status: result3.status === "error" ? "error" : "ui_agent_dispatched",
|
|
5592
5594
|
dry_run: false,
|
|
5593
5595
|
duration_ms: Date.now() - start,
|
|
5594
5596
|
event_type: "ui_agent_dispatch",
|
|
5595
|
-
manus_task_id:
|
|
5597
|
+
manus_task_id: result3.task_id
|
|
5596
5598
|
// AE blob position is the contract; the name is history
|
|
5597
5599
|
});
|
|
5598
5600
|
return jsonResult({
|
|
5599
|
-
status:
|
|
5601
|
+
status: result3.status === "stopped" ? "ui_agent_completed" : result3.status === "waiting" ? "ui_agent_awaiting_input" : result3.status,
|
|
5600
5602
|
tool: toolName,
|
|
5601
5603
|
gap_id: gapId,
|
|
5602
5604
|
// Held still across the vendor swap and across transports: MCP clients
|
|
5603
5605
|
// and the console read these names.
|
|
5604
|
-
steel_task_id:
|
|
5605
|
-
steel_session_viewer_url:
|
|
5606
|
+
steel_task_id: result3.task_id,
|
|
5607
|
+
steel_session_viewer_url: result3.session_viewer_url,
|
|
5606
5608
|
// Redacted defensively. `runUiAgent` already applies the same redactor
|
|
5607
5609
|
// before the record is stored, so this is the second of two passes over
|
|
5608
5610
|
// the fields an agent can echo its instructions into. Field-by-field
|
|
5609
5611
|
// rather than over the serialised JSON: a password containing a quote
|
|
5610
5612
|
// or a backslash is escaped by JSON.stringify and would no longer match
|
|
5611
5613
|
// a plain substring replace.
|
|
5612
|
-
result:
|
|
5613
|
-
...
|
|
5614
|
-
summary: redact(
|
|
5615
|
-
...
|
|
5616
|
-
...
|
|
5614
|
+
result: result3.result ? {
|
|
5615
|
+
...result3.result,
|
|
5616
|
+
summary: redact(result3.result.summary),
|
|
5617
|
+
...result3.result.entity_id !== void 0 ? { entity_id: redact(result3.result.entity_id) } : {},
|
|
5618
|
+
...result3.result.error_message !== void 0 ? { error_message: redact(result3.result.error_message) } : {}
|
|
5617
5619
|
} : void 0,
|
|
5618
|
-
cost_usd:
|
|
5620
|
+
cost_usd: result3.spend?.costUsd,
|
|
5619
5621
|
session_spend_usd: runtime.spend.costUsd,
|
|
5620
5622
|
runs_remaining_this_session: runtime.budget.remaining,
|
|
5621
5623
|
note: "The run completed in-process \u2014 a local CLI has no background runtime, so this call blocked for its duration.",
|
|
@@ -5653,9 +5655,9 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5653
5655
|
title: "Create Steering List (UI Agent)",
|
|
5654
5656
|
description: "Creates a new network steering list (OPLMN preference configuration) via the OCS web dashboard. This operation is not available via the OCS REST API. A browser agent is dispatched to perform the operation. Params: `name` (steering list name), `description` (optional)." + NOTE,
|
|
5655
5657
|
inputSchema: {
|
|
5656
|
-
name:
|
|
5657
|
-
description:
|
|
5658
|
-
dry_run:
|
|
5658
|
+
name: z5.string().describe("Name for the new steering list"),
|
|
5659
|
+
description: z5.string().optional().describe("Optional description for the steering list"),
|
|
5660
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5659
5661
|
}
|
|
5660
5662
|
},
|
|
5661
5663
|
gated(
|
|
@@ -5674,11 +5676,11 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5674
5676
|
title: "Build Steering List (UI Agent)",
|
|
5675
5677
|
description: "Adds or removes operators (MCC-MNC) from an existing steering list via the OCS web dashboard. This operation is not available via the OCS REST API. Params: `steering_list_id`, `add_operators` (array of MCC-MNC to add), `remove_operators` (array to remove), `operator_type` ('priority' or 'excluded')." + NOTE,
|
|
5676
5678
|
inputSchema: {
|
|
5677
|
-
steering_list_id:
|
|
5678
|
-
add_operators:
|
|
5679
|
-
remove_operators:
|
|
5680
|
-
operator_type:
|
|
5681
|
-
dry_run:
|
|
5679
|
+
steering_list_id: z5.number().describe("ID of the steering list to modify"),
|
|
5680
|
+
add_operators: z5.array(z5.string()).optional().describe("MCC-MNC codes to add (e.g. ['20801', '26201'])"),
|
|
5681
|
+
remove_operators: z5.array(z5.string()).optional().describe("MCC-MNC codes to remove"),
|
|
5682
|
+
operator_type: z5.enum(["priority", "excluded"]).default("priority").describe("Whether operators are priority or excluded"),
|
|
5683
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5682
5684
|
}
|
|
5683
5685
|
},
|
|
5684
5686
|
gated(
|
|
@@ -5697,9 +5699,9 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5697
5699
|
title: "Set Account Steering List (UI Agent)",
|
|
5698
5700
|
description: "Assigns or removes a steering list at the account level via the OCS web dashboard. The subscriber-level counterpart `modify_subscriber_steering_list` is available via API; this account-level operation is UI-only. Params: `account_id`, `steering_list_id` (0 to remove)." + NOTE,
|
|
5699
5701
|
inputSchema: {
|
|
5700
|
-
account_id:
|
|
5701
|
-
steering_list_id:
|
|
5702
|
-
dry_run:
|
|
5702
|
+
account_id: z5.number().describe("Account ID to assign the steering list to"),
|
|
5703
|
+
steering_list_id: z5.number().describe("Steering list ID to assign (0 to remove/unset)"),
|
|
5704
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5703
5705
|
}
|
|
5704
5706
|
},
|
|
5705
5707
|
gated(
|
|
@@ -5718,11 +5720,11 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5718
5720
|
title: "Request Reseller Relay Change",
|
|
5719
5721
|
description: "Drafts a parent-reseller/support request for Relay Gy, calls/SMS relay, or VoIP relay when those portal controls are read-only at the current reseller tier. Does not send the request or mutate the portal.",
|
|
5720
5722
|
inputSchema: {
|
|
5721
|
-
reseller_id:
|
|
5722
|
-
relay_gy:
|
|
5723
|
-
relay_calls_sms:
|
|
5724
|
-
relay_voip:
|
|
5725
|
-
reason:
|
|
5723
|
+
reseller_id: z5.number().optional().describe("Reseller id; defaults to the authenticated reseller"),
|
|
5724
|
+
relay_gy: z5.boolean().optional().describe("Desired Relay Gy state"),
|
|
5725
|
+
relay_calls_sms: z5.boolean().optional().describe("Desired calls/SMS relay state"),
|
|
5726
|
+
relay_voip: z5.boolean().optional().describe("Desired VoIP relay state"),
|
|
5727
|
+
reason: z5.string().optional().describe("Operational reason for the requested change")
|
|
5726
5728
|
}
|
|
5727
5729
|
},
|
|
5728
5730
|
async (args) => {
|
|
@@ -5814,10 +5816,10 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5814
5816
|
title: "Create Account (UI Agent)",
|
|
5815
5817
|
description: "Creates a new sub-account under the reseller via the OCS web dashboard. This operation is not available via the OCS REST API. Params: `name` (account name), `description` (optional), `initial_balance` (optional, default 0)." + NOTE,
|
|
5816
5818
|
inputSchema: {
|
|
5817
|
-
name:
|
|
5818
|
-
description:
|
|
5819
|
-
initial_balance:
|
|
5820
|
-
dry_run:
|
|
5819
|
+
name: z5.string().describe("Name for the new account"),
|
|
5820
|
+
description: z5.string().optional().describe("Optional description"),
|
|
5821
|
+
initial_balance: z5.number().optional().describe("Initial balance in account currency (default 0)"),
|
|
5822
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5821
5823
|
}
|
|
5822
5824
|
},
|
|
5823
5825
|
gated(
|
|
@@ -5836,10 +5838,10 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5836
5838
|
title: "Create Destination List (UI Agent)",
|
|
5837
5839
|
description: "Creates a new destination list (named set of phone number prefixes for MOC call permissions) via the OCS web dashboard. Params: `name`, `prefixes` (array of prefix strings), `description`." + NOTE,
|
|
5838
5840
|
inputSchema: {
|
|
5839
|
-
name:
|
|
5840
|
-
prefixes:
|
|
5841
|
-
description:
|
|
5842
|
-
dry_run:
|
|
5841
|
+
name: z5.string().describe("Name for the new destination list"),
|
|
5842
|
+
prefixes: z5.array(z5.string()).optional().describe("Phone number prefixes to include (e.g. ['+31', '+49'])"),
|
|
5843
|
+
description: z5.string().optional().describe("Optional description"),
|
|
5844
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5843
5845
|
}
|
|
5844
5846
|
},
|
|
5845
5847
|
gated(
|
|
@@ -5858,11 +5860,11 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5858
5860
|
title: "Edit Destination List (UI Agent)",
|
|
5859
5861
|
description: "Edits an existing destination list via the OCS web dashboard. Params: `destination_list_id`, `add_prefixes`, `remove_prefixes`, `new_name`." + NOTE,
|
|
5860
5862
|
inputSchema: {
|
|
5861
|
-
destination_list_id:
|
|
5862
|
-
add_prefixes:
|
|
5863
|
-
remove_prefixes:
|
|
5864
|
-
new_name:
|
|
5865
|
-
dry_run:
|
|
5863
|
+
destination_list_id: z5.number().describe("ID of the destination list to edit"),
|
|
5864
|
+
add_prefixes: z5.array(z5.string()).optional().describe("Prefixes to add"),
|
|
5865
|
+
remove_prefixes: z5.array(z5.string()).optional().describe("Prefixes to remove"),
|
|
5866
|
+
new_name: z5.string().optional().describe("Rename the destination list"),
|
|
5867
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5866
5868
|
}
|
|
5867
5869
|
},
|
|
5868
5870
|
gated(
|
|
@@ -5881,8 +5883,8 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5881
5883
|
title: "Delete Destination List (UI Agent)",
|
|
5882
5884
|
description: "Deletes a destination list via the OCS web dashboard. Params: `destination_list_id`. WARNING: This is destructive and cannot be undone." + NOTE,
|
|
5883
5885
|
inputSchema: {
|
|
5884
|
-
destination_list_id:
|
|
5885
|
-
dry_run:
|
|
5886
|
+
destination_list_id: z5.number().describe("ID of the destination list to delete"),
|
|
5887
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5886
5888
|
}
|
|
5887
5889
|
},
|
|
5888
5890
|
gated(
|
|
@@ -5901,8 +5903,8 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5901
5903
|
title: "Delete Package Template (UI Agent)",
|
|
5902
5904
|
description: "Deletes a package template from the product catalog via the OCS web dashboard. This operation is not available via the OCS REST API. Params: `template_id`. WARNING: This is destructive." + NOTE,
|
|
5903
5905
|
inputSchema: {
|
|
5904
|
-
template_id:
|
|
5905
|
-
dry_run:
|
|
5906
|
+
template_id: z5.number().describe("ID of the package template to delete"),
|
|
5907
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5906
5908
|
}
|
|
5907
5909
|
},
|
|
5908
5910
|
gated(
|
|
@@ -5921,11 +5923,11 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5921
5923
|
title: "Edit Location Zone (UI Agent)",
|
|
5922
5924
|
description: "Edits an existing location zone via the OCS web dashboard. `create_location_zone` is available via API; edit is UI-only. Params: `zone_id`, `new_name`, `add_countries`, `remove_countries`." + NOTE,
|
|
5923
5925
|
inputSchema: {
|
|
5924
|
-
zone_id:
|
|
5925
|
-
new_name:
|
|
5926
|
-
add_countries:
|
|
5927
|
-
remove_countries:
|
|
5928
|
-
dry_run:
|
|
5926
|
+
zone_id: z5.number().describe("ID of the location zone to edit"),
|
|
5927
|
+
new_name: z5.string().optional().describe("Rename the location zone"),
|
|
5928
|
+
add_countries: z5.array(z5.string()).optional().describe("ISO country codes to add (e.g. ['NL', 'DE'])"),
|
|
5929
|
+
remove_countries: z5.array(z5.string()).optional().describe("ISO country codes to remove"),
|
|
5930
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5929
5931
|
}
|
|
5930
5932
|
},
|
|
5931
5933
|
gated(
|
|
@@ -5944,8 +5946,8 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5944
5946
|
title: "Delete Location Zone (UI Agent)",
|
|
5945
5947
|
description: "Deletes a location zone via the OCS web dashboard. `create_location_zone` is available via API; delete is UI-only. Params: `zone_id`. WARNING: Zones in use by active templates may not be deletable." + NOTE,
|
|
5946
5948
|
inputSchema: {
|
|
5947
|
-
zone_id:
|
|
5948
|
-
dry_run:
|
|
5949
|
+
zone_id: z5.number().describe("ID of the location zone to delete"),
|
|
5950
|
+
dry_run: z5.boolean().optional().describe("Preview the agent prompt without dispatching")
|
|
5949
5951
|
}
|
|
5950
5952
|
},
|
|
5951
5953
|
gated(
|
|
@@ -5961,7 +5963,7 @@ function registerAllUiAgentTools(server2, ctx, runtime, optIn = readPortalOptIn(
|
|
|
5961
5963
|
}
|
|
5962
5964
|
|
|
5963
5965
|
// src/tools-ui-agent-ask.ts
|
|
5964
|
-
import { z as
|
|
5966
|
+
import { z as z6 } from "zod";
|
|
5965
5967
|
var UI_AGENT_ASK_TOOL_SCOPES = {
|
|
5966
5968
|
ui_agent_reply: "write",
|
|
5967
5969
|
ui_agent_list_pending: "read"
|
|
@@ -6013,8 +6015,8 @@ function registerUiAgentAskTools(server2, ctx, runtime) {
|
|
|
6013
6015
|
title: "Reply to Paused UI Agent Task",
|
|
6014
6016
|
description: "Resumes a browser automation task that paused to ask a question. Use ui_agent_list_pending to find tasks waiting for input. Provide the task_id and your reply (e.g. a 2FA code, a field value, or a yes/no answer). The reply content is never recorded in audit logs \u2014 only its length is logged.",
|
|
6015
6017
|
inputSchema: {
|
|
6016
|
-
task_id:
|
|
6017
|
-
reply:
|
|
6018
|
+
task_id: z6.string().describe("Task ID to resume (from ui_agent_list_pending)"),
|
|
6019
|
+
reply: z6.string().describe(
|
|
6018
6020
|
"Your answer to the agent's question (e.g. a 2FA code or confirmation)"
|
|
6019
6021
|
)
|
|
6020
6022
|
}
|
|
@@ -6184,7 +6186,7 @@ function registerUiAgentAskTools(server2, ctx, runtime) {
|
|
|
6184
6186
|
}
|
|
6185
6187
|
|
|
6186
6188
|
// src/carrier-api-tools.ts
|
|
6187
|
-
import { z as
|
|
6189
|
+
import { z as z7 } from "zod";
|
|
6188
6190
|
var CARRIER_API_TOOL_SCOPES = {
|
|
6189
6191
|
list_connectivity_offering_templates: "read",
|
|
6190
6192
|
create_benefit_campaign: "write",
|
|
@@ -6291,12 +6293,12 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6291
6293
|
title: "Create a benefit campaign",
|
|
6292
6294
|
description: "Create a member-benefit campaign: a capped number of eSIM claims for one offering revision, each costing a fixed amount from your sponsor wallet. Calls POST /v1/connectivity/benefit-campaigns on api.carrier.llc with your own MCP access token and returns the new campaign id. Needs write scope. A campaign cannot be deleted once created. cost_cents above the deployment ceiling is rejected with cost_above_limit and creates nothing. Params: offering_id, revision (>=1), max_claims (>=1), cost_cents (>=1, per claim), expires_at (epoch milliseconds), product_id (optional, an active product of your organization). Do NOT use this to claim or issue an eSIM \u2014 that is claim_benefit and issue_benefit_claim.",
|
|
6293
6295
|
inputSchema: {
|
|
6294
|
-
offering_id:
|
|
6295
|
-
revision:
|
|
6296
|
-
max_claims:
|
|
6297
|
-
cost_cents:
|
|
6298
|
-
expires_at:
|
|
6299
|
-
product_id:
|
|
6296
|
+
offering_id: z7.string().min(1).max(200).describe("Offering the campaign issues from."),
|
|
6297
|
+
revision: z7.number().int().min(1).max(Number.MAX_SAFE_INTEGER).describe("Offering revision, 1 or higher."),
|
|
6298
|
+
max_claims: z7.number().int().min(1).max(Number.MAX_SAFE_INTEGER).describe("Most claims the campaign accepts."),
|
|
6299
|
+
cost_cents: z7.number().int().min(1).max(Number.MAX_SAFE_INTEGER).describe("Cost of one claim in cents. The API enforces a ceiling."),
|
|
6300
|
+
expires_at: z7.number().int().min(1).max(Number.MAX_SAFE_INTEGER).describe("Expiry as epoch milliseconds."),
|
|
6301
|
+
product_id: z7.string().min(1).max(200).optional().describe("Optional product to issue from.")
|
|
6300
6302
|
},
|
|
6301
6303
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true }
|
|
6302
6304
|
},
|
|
@@ -6326,8 +6328,8 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6326
6328
|
title: "Claim a benefit",
|
|
6327
6329
|
description: "Claim one benefit from a campaign for an external reference, which places a hold on the sponsor wallet. Calls POST /v1/connectivity/benefit-campaigns/{id}/claims on api.carrier.llc with your own MCP access token. Needs write scope. Safe to repeat with the same external_ref: the same claim comes back (HTTP 200) and nothing is held twice. Results: 201 held, 200 replay of an existing claim, 202 funding outcome unknown (repeat the call), 402 wallet cannot fund the claim, 409 campaign paused, expired or full. Params: campaign_id (cbc_ plus 32 hex), external_ref (1 to 200 characters, your own reference for the person). Do NOT use this to issue the eSIM \u2014 that is issue_benefit_claim, called with the claim id from this result.",
|
|
6328
6330
|
inputSchema: {
|
|
6329
|
-
campaign_id:
|
|
6330
|
-
external_ref:
|
|
6331
|
+
campaign_id: z7.string().regex(CAMPAIGN_ID_PATTERN).describe("Campaign id, cbc_ followed by 32 hex characters."),
|
|
6332
|
+
external_ref: z7.string().min(1).max(200).describe("Your own reference for the claimant, 1 to 200 characters.")
|
|
6331
6333
|
},
|
|
6332
6334
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
6333
6335
|
},
|
|
@@ -6353,8 +6355,8 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6353
6355
|
title: "Issue the eSIM for a held claim",
|
|
6354
6356
|
description: "Issue ONE REAL eSIM for a held claim and settle the wallet hold. This spends money and cannot be undone. Calls POST /v1/connectivity/benefit-campaigns/{id}/claims/{claimId}/issue on api.carrier.llc with your own MCP access token. Needs write scope. A retry returns the same eSIM and never a second one, but do not retry blindly: on 202 the outcome is unknown and the hold is kept, so wait and call again once. Results: 200 settled with the eSIM, 202 outcome unknown, 404 not found (or issuing is switched off), 409 the claim is not issuable. Params: campaign_id (cbc_ plus 32 hex), claim_id (cbl_ plus 32 hex, from claim_benefit). No other params. Do NOT use this before claim_benefit returned a held claim.",
|
|
6355
6357
|
inputSchema: {
|
|
6356
|
-
campaign_id:
|
|
6357
|
-
claim_id:
|
|
6358
|
+
campaign_id: z7.string().regex(CAMPAIGN_ID_PATTERN).describe("Campaign id, cbc_ followed by 32 hex characters."),
|
|
6359
|
+
claim_id: z7.string().regex(CLAIM_ID_PATTERN).describe("Claim id from claim_benefit, cbl_ followed by 32 hex characters.")
|
|
6358
6360
|
},
|
|
6359
6361
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true }
|
|
6360
6362
|
},
|
|
@@ -6380,8 +6382,8 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6380
6382
|
title: "Pause or resume a benefit campaign",
|
|
6381
6383
|
description: "Pause a campaign so it accepts no new claims, or resume it. Calls POST /v1/connectivity/benefit-campaigns/{id}/status on api.carrier.llc with your own MCP access token. Needs write scope. Pausing blocks NEW claims; it does not release holds that were already made. Params: campaign_id (cbc_ plus 32 hex), status (active or paused).",
|
|
6382
6384
|
inputSchema: {
|
|
6383
|
-
campaign_id:
|
|
6384
|
-
status:
|
|
6385
|
+
campaign_id: z7.string().regex(CAMPAIGN_ID_PATTERN).describe("Campaign id, cbc_ followed by 32 hex characters."),
|
|
6386
|
+
status: z7.enum(["active", "paused"]).describe("The status to set.")
|
|
6385
6387
|
},
|
|
6386
6388
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
6387
6389
|
},
|
|
@@ -6407,9 +6409,9 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6407
6409
|
title: "Issue a claim right for a booking reference",
|
|
6408
6410
|
description: "Issue ONE single-use right for one external booking or member reference, which the claimant presents to claim a benefit. Calls POST /v1/connectivity/benefit-campaigns/{id}/entitlements on api.carrier.llc with your own MCP access token. Needs write scope. The token is returned once and is never stored in plain text; a second right for the same reference is refused. Params: campaign_id (cbc_ plus 32 hex), external_ref (1 to 200 characters), ttl_ms (optional lifetime in milliseconds).",
|
|
6409
6411
|
inputSchema: {
|
|
6410
|
-
campaign_id:
|
|
6411
|
-
external_ref:
|
|
6412
|
-
ttl_ms:
|
|
6412
|
+
campaign_id: z7.string().regex(CAMPAIGN_ID_PATTERN).describe("Campaign id, cbc_ followed by 32 hex characters."),
|
|
6413
|
+
external_ref: z7.string().min(1).max(200).describe("Your own reference for the person, 1 to 200 characters."),
|
|
6414
|
+
ttl_ms: z7.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional().describe("Lifetime of the right in milliseconds. Defaults to 30 days.")
|
|
6413
6415
|
},
|
|
6414
6416
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true }
|
|
6415
6417
|
},
|
|
@@ -6438,8 +6440,8 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6438
6440
|
title: "Close a claim whose issuance outcome is unknown",
|
|
6439
6441
|
description: "Ask the provider what happened to a claim whose issuance ended in an unknown outcome. Calls POST /v1/connectivity/benefit-campaigns/{id}/claims/{claimId}/reconcile on api.carrier.llc with your own MCP access token. Needs write scope. It never dispatches a second eSIM: it reads the existing issuance under the same claim id. Results: 200 the claim is closed, 202 the outcome is still unknown (call again later), 409 the claim never started issuing or is not held. Params: campaign_id (cbc_ plus 32 hex), claim_id (cbl_ plus 32 hex).",
|
|
6440
6442
|
inputSchema: {
|
|
6441
|
-
campaign_id:
|
|
6442
|
-
claim_id:
|
|
6443
|
+
campaign_id: z7.string().regex(CAMPAIGN_ID_PATTERN).describe("Campaign id, cbc_ followed by 32 hex characters."),
|
|
6444
|
+
claim_id: z7.string().regex(CLAIM_ID_PATTERN).describe("Claim id, cbl_ followed by 32 hex characters.")
|
|
6443
6445
|
},
|
|
6444
6446
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
6445
6447
|
},
|
|
@@ -6465,11 +6467,11 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6465
6467
|
title: "Record one experiment event",
|
|
6466
6468
|
description: "Record ONE event of an experiment: what a participant saw or did. Calls POST /v1/connectivity/experiment-events on api.carrier.llc with your own MCP access token. Needs write scope. Safe to repeat with the same event_id: the event is stored once and the replay returns 200. Params: event_id (your own id for this event), experiment_id, revision (>=1), link (the participant), measure (viewed, confirmed, issued or first_data).",
|
|
6467
6469
|
inputSchema: {
|
|
6468
|
-
event_id:
|
|
6469
|
-
experiment_id:
|
|
6470
|
-
revision:
|
|
6471
|
-
link:
|
|
6472
|
-
measure:
|
|
6470
|
+
event_id: z7.string().min(1).max(200).describe("Your own id for this event."),
|
|
6471
|
+
experiment_id: z7.string().min(1).max(200).describe("The experiment this event belongs to."),
|
|
6472
|
+
revision: z7.number().int().min(1).max(Number.MAX_SAFE_INTEGER).describe("The revision of the experiment."),
|
|
6473
|
+
link: z7.string().min(1).max(200).describe("The participant this event is about."),
|
|
6474
|
+
measure: z7.enum(["viewed", "confirmed", "issued", "first_data"]).describe("What the participant did.")
|
|
6473
6475
|
},
|
|
6474
6476
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
6475
6477
|
},
|
|
@@ -6498,9 +6500,9 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6498
6500
|
title: "Counts for one experiment",
|
|
6499
6501
|
description: "Count the events of one experiment per measure inside a time window. Calls GET /v1/connectivity/experiment-events/{experimentId}/report on api.carrier.llc with your own MCP access token. Needs read scope. The counts describe what happened; they do not say why. A measure without events is absent, never zero. Params: experiment_id, from and to (epoch milliseconds, to is exclusive).",
|
|
6500
6502
|
inputSchema: {
|
|
6501
|
-
experiment_id:
|
|
6502
|
-
from:
|
|
6503
|
-
to:
|
|
6503
|
+
experiment_id: z7.string().min(1).max(200).describe("The experiment to report on."),
|
|
6504
|
+
from: z7.number().int().min(0).max(Number.MAX_SAFE_INTEGER).describe("Start of the window, epoch milliseconds."),
|
|
6505
|
+
to: z7.number().int().min(0).max(Number.MAX_SAFE_INTEGER).describe("End of the window, epoch milliseconds, exclusive.")
|
|
6504
6506
|
},
|
|
6505
6507
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true }
|
|
6506
6508
|
},
|
|
@@ -6522,7 +6524,7 @@ function registerCarrierApiTools(server2, ctx) {
|
|
|
6522
6524
|
}
|
|
6523
6525
|
|
|
6524
6526
|
// src/tools-ui-agent-schedule.ts
|
|
6525
|
-
import { z as
|
|
6527
|
+
import { z as z8 } from "zod";
|
|
6526
6528
|
var UI_AGENT_SCHEDULE_TOOL_SCOPES = {
|
|
6527
6529
|
ui_agent_schedule_create: "admin",
|
|
6528
6530
|
ui_agent_schedule_list: "read",
|
|
@@ -6560,14 +6562,14 @@ function registerScheduleAndUsageTools(server2, ctx, runtime) {
|
|
|
6560
6562
|
title: "Create UI Agent Schedule",
|
|
6561
6563
|
description: "Creates a recurring browser-agent run on a cron schedule, to automate periodic OCS audits, fleet health checks, or any recurring browser-automation task. Minimum interval: 5 minutes. Requires admin scope." + STDIO_NOTE,
|
|
6562
6564
|
inputSchema: {
|
|
6563
|
-
name:
|
|
6564
|
-
cron:
|
|
6565
|
+
name: z8.string().describe("Human-readable name for this schedule"),
|
|
6566
|
+
cron: z8.string().describe(
|
|
6565
6567
|
"Standard 5-field cron expression (minute hour day month weekday). Minimum interval: 5 minutes. Example: '0 */6 * * *' = every 6 hours."
|
|
6566
6568
|
),
|
|
6567
|
-
prompt_template:
|
|
6569
|
+
prompt_template: z8.string().describe(
|
|
6568
6570
|
"Agent prompt/task template the browser agent will execute on each run"
|
|
6569
6571
|
),
|
|
6570
|
-
profile:
|
|
6572
|
+
profile: z8.string().optional().describe(
|
|
6571
6573
|
"Browser-agent profile to use. Defaults to the deployment's configured profile."
|
|
6572
6574
|
)
|
|
6573
6575
|
}
|
|
@@ -6589,7 +6591,7 @@ function registerScheduleAndUsageTools(server2, ctx, runtime) {
|
|
|
6589
6591
|
title: "Delete UI Agent Schedule",
|
|
6590
6592
|
description: "Permanently deletes a recurring browser-agent schedule. This cannot be undone. Use ui_agent_schedule_pause to temporarily suspend instead. Requires admin scope." + STDIO_NOTE,
|
|
6591
6593
|
inputSchema: {
|
|
6592
|
-
schedule_id:
|
|
6594
|
+
schedule_id: z8.string().describe("ID of the schedule to delete")
|
|
6593
6595
|
}
|
|
6594
6596
|
},
|
|
6595
6597
|
async () => !ctx.props.scope.includes("admin") ? scopeDenied(ctx, "ui_agent_schedule_delete", "admin") : uiAgentStubError("ui_agent_schedule_delete", "recurring_runtime")
|
|
@@ -6600,7 +6602,7 @@ function registerScheduleAndUsageTools(server2, ctx, runtime) {
|
|
|
6600
6602
|
title: "Pause UI Agent Schedule",
|
|
6601
6603
|
description: "Pauses an active recurring browser-agent schedule. The schedule is preserved and can be resumed later with ui_agent_schedule_resume. Requires admin scope." + STDIO_NOTE,
|
|
6602
6604
|
inputSchema: {
|
|
6603
|
-
schedule_id:
|
|
6605
|
+
schedule_id: z8.string().describe("ID of the schedule to pause")
|
|
6604
6606
|
}
|
|
6605
6607
|
},
|
|
6606
6608
|
async () => !ctx.props.scope.includes("admin") ? scopeDenied(ctx, "ui_agent_schedule_pause", "admin") : uiAgentStubError("ui_agent_schedule_pause", "recurring_runtime")
|
|
@@ -6611,7 +6613,7 @@ function registerScheduleAndUsageTools(server2, ctx, runtime) {
|
|
|
6611
6613
|
title: "Resume UI Agent Schedule",
|
|
6612
6614
|
description: "Resumes a paused recurring browser-agent schedule. Requires admin scope." + STDIO_NOTE,
|
|
6613
6615
|
inputSchema: {
|
|
6614
|
-
schedule_id:
|
|
6616
|
+
schedule_id: z8.string().describe("ID of the schedule to resume")
|
|
6615
6617
|
}
|
|
6616
6618
|
},
|
|
6617
6619
|
async () => !ctx.props.scope.includes("admin") ? scopeDenied(ctx, "ui_agent_schedule_resume", "admin") : uiAgentStubError("ui_agent_schedule_resume", "recurring_runtime")
|
|
@@ -6668,7 +6670,7 @@ function registerScheduleAndUsageTools(server2, ctx, runtime) {
|
|
|
6668
6670
|
}
|
|
6669
6671
|
|
|
6670
6672
|
// src/wallet-tools.ts
|
|
6671
|
-
import { z as
|
|
6673
|
+
import { z as z9 } from "zod";
|
|
6672
6674
|
import * as Sentry2 from "@sentry/cloudflare";
|
|
6673
6675
|
|
|
6674
6676
|
// src/audit-schema.ts
|
|
@@ -6996,15 +6998,15 @@ async function createTopupCheckout(env, args) {
|
|
|
6996
6998
|
} else {
|
|
6997
6999
|
params.set("customer_creation", "always");
|
|
6998
7000
|
}
|
|
6999
|
-
const
|
|
7001
|
+
const result3 = await stripePostForm(
|
|
7000
7002
|
stripeKey,
|
|
7001
7003
|
"/v1/checkout/sessions",
|
|
7002
7004
|
params
|
|
7003
7005
|
);
|
|
7004
|
-
if (!
|
|
7005
|
-
throw new Error(`Stripe checkout session create failed: ${JSON.stringify(
|
|
7006
|
+
if (!result3.ok) {
|
|
7007
|
+
throw new Error(`Stripe checkout session create failed: ${JSON.stringify(result3.data)}`);
|
|
7006
7008
|
}
|
|
7007
|
-
return { id:
|
|
7009
|
+
return { id: result3.data.id, url: result3.data.url };
|
|
7008
7010
|
}
|
|
7009
7011
|
async function runAutoTopup(env, args) {
|
|
7010
7012
|
const stripeKey = env.STRIPE_SECRET_KEY;
|
|
@@ -7128,13 +7130,13 @@ function registerWalletTools(server2, ctx) {
|
|
|
7128
7130
|
// — returns null here. Requiring a number turned that, the most common
|
|
7129
7131
|
// state a new operator is in, into an output validation error.
|
|
7130
7132
|
outputSchema: {
|
|
7131
|
-
org_id:
|
|
7132
|
-
balance_eur_cents:
|
|
7133
|
-
auto_topup_enabled:
|
|
7134
|
-
auto_topup_threshold_cents:
|
|
7133
|
+
org_id: z9.string().describe("Carrier organisation the wallet belongs to"),
|
|
7134
|
+
balance_eur_cents: z9.number().int().describe("Current balance in EUR cents"),
|
|
7135
|
+
auto_topup_enabled: z9.boolean(),
|
|
7136
|
+
auto_topup_threshold_cents: z9.number().int().nullable().describe(
|
|
7135
7137
|
"Balance at or below which an auto top-up fires, EUR cents. Null when auto-top-up is unconfigured."
|
|
7136
7138
|
),
|
|
7137
|
-
auto_topup_pack_cents:
|
|
7139
|
+
auto_topup_pack_cents: z9.number().int().nullable().describe(
|
|
7138
7140
|
"Amount an auto top-up charges, EUR cents. Null when auto-top-up is unconfigured."
|
|
7139
7141
|
)
|
|
7140
7142
|
},
|
|
@@ -7176,7 +7178,7 @@ function registerWalletTools(server2, ctx) {
|
|
|
7176
7178
|
title: "Wallet Top-up Checkout",
|
|
7177
7179
|
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.",
|
|
7178
7180
|
inputSchema: {
|
|
7179
|
-
pack:
|
|
7181
|
+
pack: z9.string().optional().describe(
|
|
7180
7182
|
"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."
|
|
7181
7183
|
)
|
|
7182
7184
|
},
|
|
@@ -7189,21 +7191,21 @@ function registerWalletTools(server2, ctx) {
|
|
|
7189
7191
|
* documented here. Marking either arm required would break the other.
|
|
7190
7192
|
*/
|
|
7191
7193
|
outputSchema: {
|
|
7192
|
-
packs:
|
|
7193
|
-
|
|
7194
|
-
id:
|
|
7195
|
-
eur_cents:
|
|
7196
|
-
bonus_pct:
|
|
7197
|
-
bonus_eur_cents:
|
|
7198
|
-
credited_eur_cents:
|
|
7194
|
+
packs: z9.array(
|
|
7195
|
+
z9.object({
|
|
7196
|
+
id: z9.string(),
|
|
7197
|
+
eur_cents: z9.number().int(),
|
|
7198
|
+
bonus_pct: z9.number(),
|
|
7199
|
+
bonus_eur_cents: z9.number().int(),
|
|
7200
|
+
credited_eur_cents: z9.number().int()
|
|
7199
7201
|
})
|
|
7200
7202
|
).optional().describe("Catalogue arm \u2014 present only when `pack` was omitted."),
|
|
7201
|
-
org_id:
|
|
7202
|
-
pack_id:
|
|
7203
|
-
pack_eur_cents:
|
|
7204
|
-
bonus_eur_cents:
|
|
7205
|
-
checkout_session_id:
|
|
7206
|
-
checkout_url:
|
|
7203
|
+
org_id: z9.string().optional().describe("Session arm."),
|
|
7204
|
+
pack_id: z9.string().optional().describe("Session arm."),
|
|
7205
|
+
pack_eur_cents: z9.number().int().optional().describe("Session arm."),
|
|
7206
|
+
bonus_eur_cents: z9.number().int().optional().describe("Session arm."),
|
|
7207
|
+
checkout_session_id: z9.string().optional().describe("Session arm."),
|
|
7208
|
+
checkout_url: z9.string().nullable().optional().describe("Session arm. Stripe may return null for a session URL.")
|
|
7207
7209
|
},
|
|
7208
7210
|
annotations: annotationsFor("wallet_topup_checkout", "write")
|
|
7209
7211
|
},
|
|
@@ -7260,7 +7262,7 @@ function registerWalletTools(server2, ctx) {
|
|
|
7260
7262
|
title: "Wallet Auto Top-up (charges card now)",
|
|
7261
7263
|
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`.",
|
|
7262
7264
|
inputSchema: {
|
|
7263
|
-
pack_cents:
|
|
7265
|
+
pack_cents: z9.number().int().positive().optional().describe("Override pack amount in EUR cents (must match a catalog pack).")
|
|
7264
7266
|
},
|
|
7265
7267
|
/**
|
|
7266
7268
|
* Only the charged arm is described here — `charged: false` returns
|
|
@@ -7275,12 +7277,12 @@ function registerWalletTools(server2, ctx) {
|
|
|
7275
7277
|
* into a validation error.
|
|
7276
7278
|
*/
|
|
7277
7279
|
outputSchema: {
|
|
7278
|
-
org_id:
|
|
7279
|
-
charged:
|
|
7280
|
-
credited_eur_cents:
|
|
7281
|
-
balance_after_cents:
|
|
7282
|
-
payment_intent_id:
|
|
7283
|
-
note:
|
|
7280
|
+
org_id: z9.string(),
|
|
7281
|
+
charged: z9.literal(true),
|
|
7282
|
+
credited_eur_cents: z9.number().int(),
|
|
7283
|
+
balance_after_cents: z9.number().int().optional().describe("Absent when the charge succeeded but crediting is pending."),
|
|
7284
|
+
payment_intent_id: z9.string().optional(),
|
|
7285
|
+
note: z9.string().optional().describe("Present when the charge landed but the credit is still pending.")
|
|
7284
7286
|
},
|
|
7285
7287
|
annotations: annotationsFor("wallet_auto_topup", "write")
|
|
7286
7288
|
},
|
|
@@ -7290,32 +7292,32 @@ function registerWalletTools(server2, ctx) {
|
|
|
7290
7292
|
const orgId = defaultOrgId;
|
|
7291
7293
|
const start = Date.now();
|
|
7292
7294
|
try {
|
|
7293
|
-
const
|
|
7295
|
+
const result3 = await runAutoTopup(env, { orgId, sub: props2.sub, packCents: pack_cents });
|
|
7294
7296
|
writeAudit(env, {
|
|
7295
7297
|
tool_name: "wallet_auto_topup",
|
|
7296
7298
|
ocs_method: "stripe.payment_intent.off_session",
|
|
7297
|
-
status:
|
|
7299
|
+
status: result3.charged ? "ok" : "error",
|
|
7298
7300
|
dry_run: false,
|
|
7299
7301
|
duration_ms: Date.now() - start,
|
|
7300
7302
|
sub: props2.sub,
|
|
7301
7303
|
reseller_id: props2.reseller_id
|
|
7302
7304
|
});
|
|
7303
|
-
if (!
|
|
7305
|
+
if (!result3.charged) {
|
|
7304
7306
|
return err(
|
|
7305
|
-
JSON.stringify({ org_id: orgId, charged: false, reason:
|
|
7307
|
+
JSON.stringify({ org_id: orgId, charged: false, reason: result3.reason })
|
|
7306
7308
|
);
|
|
7307
7309
|
}
|
|
7308
7310
|
return okStructured({
|
|
7309
7311
|
org_id: orgId,
|
|
7310
7312
|
charged: true,
|
|
7311
|
-
credited_eur_cents:
|
|
7313
|
+
credited_eur_cents: result3.creditedCents,
|
|
7312
7314
|
// Spread rather than assign, so the key is absent instead of set to
|
|
7313
7315
|
// `undefined`. JSON.stringify drops an undefined value anyway, so
|
|
7314
7316
|
// assigning it would make `content` and `structuredContent` disagree
|
|
7315
7317
|
// about whether the field is there.
|
|
7316
|
-
...
|
|
7317
|
-
...
|
|
7318
|
-
...
|
|
7318
|
+
...result3.balanceAfterCents !== void 0 ? { balance_after_cents: result3.balanceAfterCents } : {},
|
|
7319
|
+
...result3.paymentIntentId !== void 0 ? { payment_intent_id: result3.paymentIntentId } : {},
|
|
7320
|
+
...result3.reason ? { note: result3.reason } : {}
|
|
7319
7321
|
});
|
|
7320
7322
|
} catch (e) {
|
|
7321
7323
|
Sentry2.captureException(e);
|
|
@@ -7326,7 +7328,7 @@ function registerWalletTools(server2, ctx) {
|
|
|
7326
7328
|
}
|
|
7327
7329
|
|
|
7328
7330
|
// src/stripe-connect-tools.ts
|
|
7329
|
-
import { z as
|
|
7331
|
+
import { z as z10 } from "zod";
|
|
7330
7332
|
import * as Sentry3 from "@sentry/cloudflare";
|
|
7331
7333
|
|
|
7332
7334
|
// src/binding-unavailable.ts
|
|
@@ -7482,7 +7484,7 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7482
7484
|
title: "Stripe Connect Status",
|
|
7483
7485
|
description: "Read-only: returns the Stripe Connect account status, capabilities, and requirements for the authenticated operator.",
|
|
7484
7486
|
inputSchema: {
|
|
7485
|
-
operator_id:
|
|
7487
|
+
operator_id: z10.string().optional().describe("Override operator_id (admin use). Defaults to caller's org/user.")
|
|
7486
7488
|
},
|
|
7487
7489
|
annotations: annotationsFor("stripe_connect_status", "read")
|
|
7488
7490
|
},
|
|
@@ -7506,9 +7508,9 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7506
7508
|
if (!accountId) {
|
|
7507
7509
|
return ok(JSON.stringify({ status: "not_connected", operator_id: opId }));
|
|
7508
7510
|
}
|
|
7509
|
-
const
|
|
7510
|
-
if (!
|
|
7511
|
-
const a =
|
|
7511
|
+
const result3 = await stripeGet(stripeKey, `/v1/accounts/${accountId}`);
|
|
7512
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7513
|
+
const a = result3.data;
|
|
7512
7514
|
const status = a.charges_enabled && a.details_submitted ? "active" : "pending";
|
|
7513
7515
|
writeAudit(env, {
|
|
7514
7516
|
tool_name: "stripe_connect_status",
|
|
@@ -7543,8 +7545,8 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7543
7545
|
title: "List Stripe Payouts",
|
|
7544
7546
|
description: "List money Stripe has already sent from the operator's connected account to their bank, newest first. Read-only. Params: `limit` (1-50, default 10), `status` (optional Stripe payout status, e.g. 'paid', 'pending', 'failed'). Returns: { payouts: [{ id, amount, currency, status, arrival_date, automatic, created }], has_more } \u2014 amount in the currency's smallest unit. Do NOT use this for money still sitting at Stripe and not yet paid out \u2014 use `stripe_connect_balance`.",
|
|
7545
7547
|
inputSchema: {
|
|
7546
|
-
limit:
|
|
7547
|
-
status:
|
|
7548
|
+
limit: z10.number().int().min(1).max(50).default(10).describe("Number of payouts to return."),
|
|
7549
|
+
status: z10.enum(["pending", "paid", "failed", "canceled", "in_transit"]).optional().describe("Filter by payout status.")
|
|
7548
7550
|
},
|
|
7549
7551
|
annotations: annotationsFor("stripe_connect_payouts", "read")
|
|
7550
7552
|
},
|
|
@@ -7559,8 +7561,8 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7559
7561
|
if (!accountId) return err2("No connected Stripe account found.");
|
|
7560
7562
|
const params = new URLSearchParams({ limit: String(limit) });
|
|
7561
7563
|
if (status) params.set("status", status);
|
|
7562
|
-
const
|
|
7563
|
-
if (!
|
|
7564
|
+
const result3 = await stripeGet(stripeKey, `/v1/payouts?${params.toString()}`, accountId);
|
|
7565
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7564
7566
|
writeAudit(env, {
|
|
7565
7567
|
tool_name: "stripe_connect_payouts",
|
|
7566
7568
|
ocs_method: "stripe.payouts.list",
|
|
@@ -7570,7 +7572,7 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7570
7572
|
sub: props2.sub,
|
|
7571
7573
|
reseller_id: props2.reseller_id
|
|
7572
7574
|
});
|
|
7573
|
-
return ok(JSON.stringify({ payouts:
|
|
7575
|
+
return ok(JSON.stringify({ payouts: result3.data.data, has_more: result3.data.has_more }));
|
|
7574
7576
|
} catch (e) {
|
|
7575
7577
|
Sentry3.captureException(e);
|
|
7576
7578
|
return err2(`Error: ${e instanceof Error ? e.message : "unknown"}`);
|
|
@@ -7583,8 +7585,8 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7583
7585
|
title: "Stripe Connect Charges",
|
|
7584
7586
|
description: "List recent payments (charges) on the operator's connected Stripe account, e.g. storefront purchases. Read-only. Params: limit (1-100), starting_after (charge id for paging). Returns: { charges: [{ id, amount, amount_refunded, currency, status, paid, captured, refunded, created, payment_intent, payment_method_type, metadata }], has_more }. Do NOT use this for payouts to the bank \u2014 use `stripe_connect_payouts`.",
|
|
7585
7587
|
inputSchema: {
|
|
7586
|
-
limit:
|
|
7587
|
-
starting_after:
|
|
7588
|
+
limit: z10.number().int().min(1).max(100).default(20).describe("Number of charges to return."),
|
|
7589
|
+
starting_after: z10.string().regex(/^(ch|py)_[A-Za-z0-9]+$/).optional().describe("Charge id to page after.")
|
|
7588
7590
|
},
|
|
7589
7591
|
annotations: annotationsFor("stripe_connect_charges_list", "read")
|
|
7590
7592
|
},
|
|
@@ -7599,12 +7601,12 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7599
7601
|
if (!accountId) return err2("No connected Stripe account found.");
|
|
7600
7602
|
const params = new URLSearchParams({ limit: String(limit) });
|
|
7601
7603
|
if (starting_after) params.set("starting_after", starting_after);
|
|
7602
|
-
const
|
|
7604
|
+
const result3 = await stripeGet(
|
|
7603
7605
|
stripeKey,
|
|
7604
7606
|
`/v1/charges?${params.toString()}`,
|
|
7605
7607
|
accountId
|
|
7606
7608
|
);
|
|
7607
|
-
if (!
|
|
7609
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7608
7610
|
writeAudit(env, {
|
|
7609
7611
|
tool_name: "stripe_connect_charges_list",
|
|
7610
7612
|
ocs_method: "stripe.charges.list",
|
|
@@ -7614,7 +7616,7 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7614
7616
|
sub: props2.sub,
|
|
7615
7617
|
reseller_id: props2.reseller_id
|
|
7616
7618
|
});
|
|
7617
|
-
const charges = (
|
|
7619
|
+
const charges = (result3.data.data ?? []).map((ch) => ({
|
|
7618
7620
|
id: ch["id"],
|
|
7619
7621
|
amount: ch["amount"],
|
|
7620
7622
|
amount_refunded: ch["amount_refunded"],
|
|
@@ -7628,7 +7630,7 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7628
7630
|
payment_method_type: ch["payment_method_details"]?.type ?? null,
|
|
7629
7631
|
metadata: ch["metadata"]
|
|
7630
7632
|
}));
|
|
7631
|
-
return ok(JSON.stringify({ charges, has_more:
|
|
7633
|
+
return ok(JSON.stringify({ charges, has_more: result3.data.has_more }));
|
|
7632
7634
|
} catch (e) {
|
|
7633
7635
|
Sentry3.captureException(e);
|
|
7634
7636
|
return err2(`stripe_connect_charges_list failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -7652,8 +7654,8 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7652
7654
|
if (!stripeKey) return err2("Stripe not configured");
|
|
7653
7655
|
const accountId = await getAccountId();
|
|
7654
7656
|
if (!accountId) return err2("No connected Stripe account found.");
|
|
7655
|
-
const
|
|
7656
|
-
if (!
|
|
7657
|
+
const result3 = await stripeGet(stripeKey, `/v1/balance`, accountId);
|
|
7658
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7657
7659
|
writeAudit(env, {
|
|
7658
7660
|
tool_name: "stripe_connect_balance",
|
|
7659
7661
|
ocs_method: "stripe.balance.read",
|
|
@@ -7665,8 +7667,8 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7665
7667
|
});
|
|
7666
7668
|
return ok(JSON.stringify({
|
|
7667
7669
|
account_id: accountId,
|
|
7668
|
-
available:
|
|
7669
|
-
pending:
|
|
7670
|
+
available: result3.data.available ?? [],
|
|
7671
|
+
pending: result3.data.pending ?? []
|
|
7670
7672
|
}));
|
|
7671
7673
|
} catch (e) {
|
|
7672
7674
|
Sentry3.captureException(e);
|
|
@@ -7680,10 +7682,10 @@ function registerStripeConnectTools(server2, ctx) {
|
|
|
7680
7682
|
title: "Refund a Charge (moves real money)",
|
|
7681
7683
|
description: "Refund money to a customer on one charge in the operator's connected Stripe account. This returns real funds and Stripe cannot reverse a refund once issued. Two-step by design: call without `confirm_token` to get a token and a summary of what would be refunded, then call again with that token to execute. The token expires in 5 minutes. Params: `charge_id` (Stripe charge id, `ch_...`), `amount_cents` (optional integer in the charge's smallest currency unit \u2014 omit for a full refund), `reason` ('duplicate' | 'fraudulent' | 'requested_by_customer', optional), `confirm_token`. Returns: the refund id and status. Requires `write` scope. Do NOT use this on a payment that was authorized but not captured \u2014 cancel its PaymentIntent instead (Stripe POST /v1/payment_intents/:id/cancel). Do NOT use this to contest a chargeback \u2014 read the case with `stripe_connect_dispute_list` first, since refunding a disputed charge can cost the operator twice.",
|
|
7682
7684
|
inputSchema: {
|
|
7683
|
-
charge_id:
|
|
7684
|
-
amount_cents:
|
|
7685
|
-
reason:
|
|
7686
|
-
confirm_token:
|
|
7685
|
+
charge_id: z10.string().min(1).describe("Stripe charge ID (ch_...)."),
|
|
7686
|
+
amount_cents: z10.number().int().min(1).optional().describe("Partial refund amount in cents. Omit for full refund."),
|
|
7687
|
+
reason: z10.enum(["duplicate", "fraudulent", "requested_by_customer"]).optional(),
|
|
7688
|
+
confirm_token: z10.string().optional().describe("Confirmation token from previous call. Required to execute.")
|
|
7687
7689
|
},
|
|
7688
7690
|
annotations: annotationsFor("stripe_connect_refund", "write")
|
|
7689
7691
|
},
|
|
@@ -7712,14 +7714,14 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7712
7714
|
const params = { charge: charge_id };
|
|
7713
7715
|
if (amount_cents) params.amount = String(amount_cents);
|
|
7714
7716
|
if (reason) params.reason = reason;
|
|
7715
|
-
const
|
|
7717
|
+
const result3 = await stripePost(
|
|
7716
7718
|
stripeKey,
|
|
7717
7719
|
"/v1/refunds",
|
|
7718
7720
|
params,
|
|
7719
7721
|
accountId,
|
|
7720
7722
|
refundIdempotencyKey(props2.sub, charge_id, amount_cents, reason)
|
|
7721
7723
|
);
|
|
7722
|
-
if (!
|
|
7724
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7723
7725
|
writeAudit(env, {
|
|
7724
7726
|
tool_name: toolName,
|
|
7725
7727
|
ocs_method: "stripe.refund.create",
|
|
@@ -7729,7 +7731,7 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7729
7731
|
sub: props2.sub,
|
|
7730
7732
|
reseller_id: props2.reseller_id
|
|
7731
7733
|
});
|
|
7732
|
-
return ok(`Refund issued: ${
|
|
7734
|
+
return ok(`Refund issued: ${result3.data.id} \u2014 status: ${result3.data.status}`);
|
|
7733
7735
|
} catch (e) {
|
|
7734
7736
|
Sentry3.captureException(e);
|
|
7735
7737
|
return err2(`Error: ${e instanceof Error ? e.message : "unknown"}`);
|
|
@@ -7742,8 +7744,8 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7742
7744
|
title: "List Chargeback Disputes",
|
|
7743
7745
|
description: "List chargebacks customers have raised with their bank against the operator's connected Stripe account. Read-only \u2014 responding to one is Dashboard work. Params: `limit` (1-50, default 10), `status` (optional Stripe dispute status, e.g. 'needs_response', 'under_review'). Returns: { disputes: [{ id, charge, amount, currency, status, reason, evidence_details.due_by }], has_more } \u2014 amount in the currency's smallest unit, `due_by` a Unix timestamp or null. Do NOT use this for charges Stripe is holding for fraud review before they settle \u2014 those are `radar_review_list`. Check this before refunding: refunding a disputed charge can cost the operator the amount twice.",
|
|
7744
7746
|
inputSchema: {
|
|
7745
|
-
limit:
|
|
7746
|
-
status:
|
|
7747
|
+
limit: z10.number().int().min(1).max(50).default(10),
|
|
7748
|
+
status: z10.string().optional().describe("Filter by dispute status (e.g. needs_response, under_review).")
|
|
7747
7749
|
},
|
|
7748
7750
|
annotations: annotationsFor("stripe_connect_dispute_list", "read")
|
|
7749
7751
|
},
|
|
@@ -7758,8 +7760,8 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7758
7760
|
if (!accountId) return err2("No connected Stripe account found.");
|
|
7759
7761
|
const params = new URLSearchParams({ limit: String(limit) });
|
|
7760
7762
|
if (status) params.set("status", status);
|
|
7761
|
-
const
|
|
7762
|
-
if (!
|
|
7763
|
+
const result3 = await stripeGet(stripeKey, `/v1/disputes?${params.toString()}`, accountId);
|
|
7764
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7763
7765
|
writeAudit(env, {
|
|
7764
7766
|
tool_name: "stripe_connect_dispute_list",
|
|
7765
7767
|
ocs_method: "stripe.disputes.list",
|
|
@@ -7769,7 +7771,7 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7769
7771
|
sub: props2.sub,
|
|
7770
7772
|
reseller_id: props2.reseller_id
|
|
7771
7773
|
});
|
|
7772
|
-
return ok(JSON.stringify({ disputes:
|
|
7774
|
+
return ok(JSON.stringify({ disputes: result3.data.data, has_more: result3.data.has_more }));
|
|
7773
7775
|
} catch (e) {
|
|
7774
7776
|
Sentry3.captureException(e);
|
|
7775
7777
|
return err2(`Error: ${e instanceof Error ? e.message : "unknown"}`);
|
|
@@ -7782,8 +7784,8 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7782
7784
|
title: "List Radar Fraud Reviews",
|
|
7783
7785
|
description: "List the Stripe Radar fraud reviews waiting on a manual approve/decline decision, newest first. Reads only \u2014 deciding a review is a separate call. Params: `open_only` (boolean, default true; Stripe lists open reviews only, so false returns the same set), `limit` (1-50, default 10). Returns: { reviews: [{ id (`prv_...`), charge, reason, opened_reason, closed_reason, created, closed }], has_more }. Call this first to get the `review_id` that `radar_review_approve` and `radar_review_decline` require. Do NOT use this for chargebacks the customer has already raised with their bank \u2014 use `stripe_connect_dispute_list`.",
|
|
7784
7786
|
inputSchema: {
|
|
7785
|
-
open_only:
|
|
7786
|
-
limit:
|
|
7787
|
+
open_only: z10.boolean().default(true).describe("Stripe lists only open (undecided) reviews; kept for compatibility."),
|
|
7788
|
+
limit: z10.number().int().min(1).max(50).default(10)
|
|
7787
7789
|
},
|
|
7788
7790
|
annotations: annotationsFor("radar_review_list", "read")
|
|
7789
7791
|
},
|
|
@@ -7800,9 +7802,9 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7800
7802
|
const stripeKey = env.STRIPE_ORG_SECRET_KEY ?? env.STRIPE_SECRET_KEY;
|
|
7801
7803
|
if (!stripeKey) return err2("Stripe not configured");
|
|
7802
7804
|
const params = new URLSearchParams({ limit: String(limit) });
|
|
7803
|
-
const
|
|
7804
|
-
if (!
|
|
7805
|
-
const reviews = open_only ?
|
|
7805
|
+
const result3 = await stripeGet(stripeKey, `/v1/reviews?${params.toString()}`);
|
|
7806
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7807
|
+
const reviews = open_only ? result3.data.data.filter((r) => r.open !== false) : result3.data.data;
|
|
7806
7808
|
writeAudit(env, {
|
|
7807
7809
|
tool_name: "radar_review_list",
|
|
7808
7810
|
ocs_method: "stripe.radar.reviews.list",
|
|
@@ -7812,7 +7814,7 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7812
7814
|
sub: props2.sub,
|
|
7813
7815
|
reseller_id: props2.reseller_id
|
|
7814
7816
|
});
|
|
7815
|
-
return ok(JSON.stringify({ reviews, has_more:
|
|
7817
|
+
return ok(JSON.stringify({ reviews, has_more: result3.data.has_more }));
|
|
7816
7818
|
} catch (e) {
|
|
7817
7819
|
Sentry3.captureException(e);
|
|
7818
7820
|
return err2(`Error: ${e instanceof Error ? e.message : "unknown"}`);
|
|
@@ -7825,8 +7827,8 @@ Call again with confirm_token="${token2}" to execute. Token expires in 5 minutes
|
|
|
7825
7827
|
title: "Approve Radar Review (captures charge)",
|
|
7826
7828
|
description: "Clear a Stripe Radar fraud review so the held charge is captured and the money is taken. Approving overrides Radar's fraud signal, so a genuinely fraudulent charge approved here usually returns later as a chargeback plus a fee. Two-step by design: call without `confirm_token` to get a token, then call again with it to execute. Params: `review_id` (`prv_...`, from `radar_review_list`), `confirm_token`. Requires `admin` scope. Do NOT call this to turn a suspicious charge away \u2014 Stripe has no review decline; refund the charge (`stripe_connect_refund`) or cancel an uncaptured PaymentIntent. Do NOT call this to return money on a charge that already went through \u2014 that is `stripe_connect_refund`.",
|
|
7827
7829
|
inputSchema: {
|
|
7828
|
-
review_id:
|
|
7829
|
-
confirm_token:
|
|
7830
|
+
review_id: z10.string().min(1).describe("Stripe Radar review ID (prv_...)."),
|
|
7831
|
+
confirm_token: z10.string().optional()
|
|
7830
7832
|
},
|
|
7831
7833
|
annotations: annotationsFor("radar_review_approve", "admin")
|
|
7832
7834
|
},
|
|
@@ -7853,13 +7855,13 @@ Call again with confirm_token="${token2}" to execute. Expires in 5 minutes.`
|
|
|
7853
7855
|
try {
|
|
7854
7856
|
const stripeKey = env.STRIPE_ORG_SECRET_KEY ?? env.STRIPE_SECRET_KEY;
|
|
7855
7857
|
if (!stripeKey) return err2("Stripe not configured");
|
|
7856
|
-
const
|
|
7858
|
+
const result3 = await stripePost(
|
|
7857
7859
|
stripeKey,
|
|
7858
7860
|
// POST /v1/reviews/:id/approve (docs.stripe.com/api/radar/reviews/approve).
|
|
7859
7861
|
`/v1/reviews/${encodeURIComponent(review_id)}/approve`,
|
|
7860
7862
|
{}
|
|
7861
7863
|
);
|
|
7862
|
-
if (!
|
|
7864
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7863
7865
|
writeAudit(env, {
|
|
7864
7866
|
tool_name: toolName,
|
|
7865
7867
|
ocs_method: "stripe.radar.review.approve",
|
|
@@ -7882,8 +7884,8 @@ Call again with confirm_token="${token2}" to execute. Expires in 5 minutes.`
|
|
|
7882
7884
|
title: "Decline Radar Review (not supported by Stripe)",
|
|
7883
7885
|
description: "Always refuses and calls nothing: Stripe has no endpoint to decline a Radar review (its Reviews API only lists, retrieves and approves). Payments in review have usually already been processed. To turn one away, refund the charge on Carrier's platform account in Stripe itself (Dashboard, or platform-scoped POST /v1/refunds with no Stripe-Account header): `stripe_connect_refund` always acts as the operator's connected account, so it will NOT find a platform charge from this review list. or, for a payment authorized but not captured, cancel its PaymentIntent (Stripe POST /v1/payment_intents/:id/cancel); either closes the review. Params: `review_id` (`prv_...`), `confirm_token` (ignored). Requires `admin` scope. Do NOT call this expecting a charge to be blocked; nothing happens.",
|
|
7884
7886
|
inputSchema: {
|
|
7885
|
-
review_id:
|
|
7886
|
-
confirm_token:
|
|
7887
|
+
review_id: z10.string().min(1),
|
|
7888
|
+
confirm_token: z10.string().optional()
|
|
7887
7889
|
},
|
|
7888
7890
|
annotations: annotationsFor("radar_review_decline", "admin")
|
|
7889
7891
|
},
|
|
@@ -7904,9 +7906,9 @@ Call again with confirm_token="${token2}" to execute. Expires in 5 minutes.`
|
|
|
7904
7906
|
title: "Add Value to Radar List",
|
|
7905
7907
|
description: "Add one value to an existing Stripe Radar value list, changing how every future charge is scored. Whether the value ends up blocked or allowed depends entirely on which list you name in `value_list_id` \u2014 this tool does not choose, and putting a value on the allow list when you meant the block list silently lets fraud through. Confirm the list's purpose before calling. Two-step by design: call without `confirm_token` to get a token, then call again with it to execute. Params: `value_list_id` (`rsl_...`, an existing list), `value` (one email, IP address, card fingerprint, or ISO country code \u2014 one item per call), `confirm_token`. Requires `admin` scope. Do NOT use this to decide a single charge that is already under review \u2014 use `radar_review_approve` or `radar_review_decline`. Do NOT use this to create a list or a rule: only `value` is added, and rules cannot be edited through this API at all (see `radar_rule_toggle`).",
|
|
7906
7908
|
inputSchema: {
|
|
7907
|
-
value_list_id:
|
|
7908
|
-
value:
|
|
7909
|
-
confirm_token:
|
|
7909
|
+
value_list_id: z10.string().min(1).describe("Stripe Radar value list ID (rsl_...)."),
|
|
7910
|
+
value: z10.string().min(1).describe("The value to add (email, IP address, country code, etc.)."),
|
|
7911
|
+
confirm_token: z10.string().optional()
|
|
7910
7912
|
},
|
|
7911
7913
|
annotations: annotationsFor("radar_value_list_add", "admin")
|
|
7912
7914
|
},
|
|
@@ -7933,12 +7935,12 @@ Expires in 5 minutes.`
|
|
|
7933
7935
|
try {
|
|
7934
7936
|
const stripeKey = env.STRIPE_ORG_SECRET_KEY ?? env.STRIPE_SECRET_KEY;
|
|
7935
7937
|
if (!stripeKey) return err2("Stripe not configured");
|
|
7936
|
-
const
|
|
7938
|
+
const result3 = await stripePost(
|
|
7937
7939
|
stripeKey,
|
|
7938
7940
|
"/v1/radar/value_list_items",
|
|
7939
7941
|
{ value_list: value_list_id, value }
|
|
7940
7942
|
);
|
|
7941
|
-
if (!
|
|
7943
|
+
if (!result3.ok) return err2(`Stripe error: ${JSON.stringify(result3.data)}`);
|
|
7942
7944
|
writeAudit(env, {
|
|
7943
7945
|
tool_name: toolName,
|
|
7944
7946
|
ocs_method: "stripe.radar.value_list.add",
|
|
@@ -7961,8 +7963,8 @@ Expires in 5 minutes.`
|
|
|
7961
7963
|
title: "Radar Rule Toggle (instructions only)",
|
|
7962
7964
|
description: "Return the Stripe Dashboard steps for enabling or disabling a Radar rule. This tool changes nothing: Stripe has no public API for rule state, so the call always succeeds and the rule stays exactly as it was. Never report the rule as toggled. Params: `rule_id` (Stripe Radar rule id), `enabled` (true for the enable instructions, false for disable). Returns: the Dashboard URL and steps for a human to follow. Requires `admin` scope. Do NOT use this when a change must actually take effect from an agent \u2014 the only Radar state reachable through this API is value-list membership, via `radar_value_list_add`.",
|
|
7963
7965
|
inputSchema: {
|
|
7964
|
-
rule_id:
|
|
7965
|
-
enabled:
|
|
7966
|
+
rule_id: z10.string().min(1).describe("Stripe Radar rule ID."),
|
|
7967
|
+
enabled: z10.boolean().describe("true = enable, false = disable.")
|
|
7966
7968
|
},
|
|
7967
7969
|
annotations: annotationsFor("radar_rule_toggle", "admin")
|
|
7968
7970
|
},
|
|
@@ -7987,7 +7989,7 @@ Note: If you need this automated, use the Radar for Platforms beta \u2014 contac
|
|
|
7987
7989
|
}
|
|
7988
7990
|
|
|
7989
7991
|
// src/tools-storefront-logo.ts
|
|
7990
|
-
import { z as
|
|
7992
|
+
import { z as z11 } from "zod";
|
|
7991
7993
|
var STOREFRONT_LOGO_TOOL_SCOPES = {
|
|
7992
7994
|
generate_storefront_logo: "read"
|
|
7993
7995
|
};
|
|
@@ -8000,9 +8002,9 @@ function registerStorefrontLogoTools(server2, env = {}, props2) {
|
|
|
8000
8002
|
title: "Generate Storefront Logo",
|
|
8001
8003
|
description: "Generate a storefront logo (SVG always; PNG when an image key is configured on the Carrier worker). Works for any authenticated Carrier MCP user \u2014 no local image-API key required. Write the SVG to public/brand/logo.svg in the storefront.",
|
|
8002
8004
|
inputSchema: {
|
|
8003
|
-
name:
|
|
8004
|
-
accent:
|
|
8005
|
-
tagline:
|
|
8005
|
+
name: z11.string().min(1).describe("Brand / shop name, e.g. Bananas"),
|
|
8006
|
+
accent: z11.string().regex(/^#?[0-9A-Fa-f]{6}$/).optional().describe("Accent hex, e.g. #FF8A00"),
|
|
8007
|
+
tagline: z11.string().optional().describe("Optional tagline for AI-enhanced marks")
|
|
8006
8008
|
},
|
|
8007
8009
|
annotations: annotationsFor("generate_storefront_logo", "read")
|
|
8008
8010
|
},
|
|
@@ -8036,7 +8038,7 @@ function registerStorefrontLogoTools(server2, env = {}, props2) {
|
|
|
8036
8038
|
}
|
|
8037
8039
|
|
|
8038
8040
|
// src/tools-storefront-deploy.ts
|
|
8039
|
-
import { z as
|
|
8041
|
+
import { z as z12 } from "zod";
|
|
8040
8042
|
var STOREFRONT_DEPLOY_TOOL_SCOPES = {
|
|
8041
8043
|
list_deploy_targets: "read",
|
|
8042
8044
|
deploy_storefront: "write",
|
|
@@ -8053,7 +8055,7 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8053
8055
|
title: "List Deploy Targets",
|
|
8054
8056
|
description: "Report which storefront deploy hosts (Cloudflare, Vercel, Netlify, Fly) are installed, logged in, and ready on this machine, and which one a deploy would pick.",
|
|
8055
8057
|
inputSchema: {
|
|
8056
|
-
dir:
|
|
8058
|
+
dir: z12.string().min(1).describe("Path to the scaffolded storefront directory")
|
|
8057
8059
|
},
|
|
8058
8060
|
annotations: annotationsFor("list_deploy_targets", "read")
|
|
8059
8061
|
},
|
|
@@ -8079,17 +8081,17 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8079
8081
|
title: "Deploy Storefront",
|
|
8080
8082
|
description: "Build and deploy a scaffolded storefront to whichever host is available on this machine, then push its runtime secrets (CARRIER_API_KEY, CLERK_SECRET_KEY) to that host.",
|
|
8081
8083
|
inputSchema: {
|
|
8082
|
-
dir:
|
|
8083
|
-
target:
|
|
8084
|
-
name:
|
|
8085
|
-
force:
|
|
8084
|
+
dir: z12.string().min(1).describe("Path to the scaffolded storefront directory"),
|
|
8085
|
+
target: z12.enum(TARGET_IDS).optional().describe("Force a host instead of auto-detecting"),
|
|
8086
|
+
name: z12.string().optional().describe("Project/worker name (defaults from brand)"),
|
|
8087
|
+
force: z12.boolean().optional().describe(
|
|
8086
8088
|
'Acknowledge the scaffold-default-name risk: required when the resolved name is the scaffold default "storefront"'
|
|
8087
8089
|
),
|
|
8088
|
-
skip_build:
|
|
8089
|
-
push_secrets:
|
|
8090
|
-
provision_clerk:
|
|
8091
|
-
verify:
|
|
8092
|
-
domain:
|
|
8090
|
+
skip_build: z12.boolean().optional().describe("Deploy the existing build without rebuilding"),
|
|
8091
|
+
push_secrets: z12.boolean().optional().describe("Stage runtime secrets on the host before deploy (default true)"),
|
|
8092
|
+
provision_clerk: z12.boolean().optional().default(true).describe("Provision and configure Clerk automatically (default true)"),
|
|
8093
|
+
verify: z12.boolean().optional().describe("Probe the deployed URL and report whether it actually serves (default true)"),
|
|
8094
|
+
domain: z12.boolean().optional().describe("Route the brand domain to the deployment (Cloudflare provisions DNS + cert)")
|
|
8093
8095
|
},
|
|
8094
8096
|
annotations: annotationsFor("deploy_storefront", "write")
|
|
8095
8097
|
},
|
|
@@ -8153,7 +8155,7 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8153
8155
|
const built = await buildSite(dir, buildFor);
|
|
8154
8156
|
if (!built) return err4(`Build failed for ${buildFor}. Run the build locally to see why.`);
|
|
8155
8157
|
}
|
|
8156
|
-
const
|
|
8158
|
+
const result3 = await deploySite(dir, brand, {
|
|
8157
8159
|
preferred,
|
|
8158
8160
|
pushSecrets: push_secrets !== false,
|
|
8159
8161
|
customDomain: domain === true,
|
|
@@ -8164,29 +8166,29 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8164
8166
|
explicitName: name,
|
|
8165
8167
|
force: force === true
|
|
8166
8168
|
});
|
|
8167
|
-
if (!
|
|
8168
|
-
return err4(
|
|
8169
|
+
if (!result3.ok) {
|
|
8170
|
+
return err4(result3.reason ?? "Deploy failed.");
|
|
8169
8171
|
}
|
|
8170
|
-
if (provision_clerk !== false &&
|
|
8172
|
+
if (provision_clerk !== false && result3.url) {
|
|
8171
8173
|
const secretKey = clerkCredentials?.secretKey ?? (await discoverSecrets(dir, process.env)).CLERK_SECRET_KEY;
|
|
8172
8174
|
if (secretKey) {
|
|
8173
8175
|
const configured = await configureClerkInstance(
|
|
8174
8176
|
secretKey,
|
|
8175
|
-
storefrontClerkUrls(
|
|
8177
|
+
storefrontClerkUrls(result3.url, brand.domain)
|
|
8176
8178
|
);
|
|
8177
8179
|
clerkConfigured = configured.applied;
|
|
8178
8180
|
clerkConfigureFailures = configured.failed;
|
|
8179
8181
|
}
|
|
8180
8182
|
}
|
|
8181
|
-
const verification = verify !== false &&
|
|
8183
|
+
const verification = verify !== false && result3.url ? await verifyStorefront(result3.url, dir, process.env) : void 0;
|
|
8182
8184
|
const repairHint = skip_build && clerkEnvWritten.includes("NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY") ? "Clerk keys were written to .env.local, but the publishable key is only inlined at build time; rebuild and redeploy to apply it." : verification && !verification.ok ? repairPlanFor(verification.diagnosis)?.note ?? verification.summary : void 0;
|
|
8183
8185
|
return ok3({
|
|
8184
8186
|
deployed: true,
|
|
8185
|
-
target:
|
|
8186
|
-
project:
|
|
8187
|
-
url:
|
|
8188
|
-
secrets_staged:
|
|
8189
|
-
secrets_failed:
|
|
8187
|
+
target: result3.target,
|
|
8188
|
+
project: result3.projectName,
|
|
8189
|
+
url: result3.url ?? null,
|
|
8190
|
+
secrets_staged: result3.secrets?.pushed ?? [],
|
|
8191
|
+
secrets_failed: result3.secrets?.failed ?? [],
|
|
8190
8192
|
clerk_provisioned: clerkProvisioned,
|
|
8191
8193
|
clerk_tier: clerkTier,
|
|
8192
8194
|
clerk_configured: clerkConfigured.length,
|
|
@@ -8196,7 +8198,7 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8196
8198
|
diagnosis: verification?.ok === false ? verification.diagnosis : void 0,
|
|
8197
8199
|
probes: verification ? formatProbes(verification.probes) : void 0,
|
|
8198
8200
|
repair_hint: repairHint,
|
|
8199
|
-
warning:
|
|
8201
|
+
warning: result3.secrets?.pushed.includes("CARRIER_API_KEY") ? void 0 : "CARRIER_API_KEY was not staged \u2014 / and /shop will return 500 until it is set."
|
|
8200
8202
|
});
|
|
8201
8203
|
} catch (e) {
|
|
8202
8204
|
return err4(e instanceof Error ? e.message : "deploy failed");
|
|
@@ -8209,11 +8211,11 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8209
8211
|
title: "Provision Storefront Clerk App",
|
|
8210
8212
|
description: "Create a Clerk application (Platform API) or reuse Clerk keys already on this machine, write them into the storefront .env.local, and configure allowed origins and redirect URLs on the instance.",
|
|
8211
8213
|
inputSchema: {
|
|
8212
|
-
dir:
|
|
8213
|
-
name:
|
|
8214
|
-
production:
|
|
8215
|
-
no_create:
|
|
8216
|
-
url:
|
|
8214
|
+
dir: z12.string().min(1).describe("Path to the scaffolded storefront directory"),
|
|
8215
|
+
name: z12.string().optional().describe("Clerk application name (defaults from brand)"),
|
|
8216
|
+
production: z12.boolean().optional().describe("Also create a production instance (Platform API only)"),
|
|
8217
|
+
no_create: z12.boolean().optional().describe("Never create a new application; only reuse existing keys"),
|
|
8218
|
+
url: z12.string().optional().describe("Deployed URL to whitelist as origin and redirect")
|
|
8217
8219
|
},
|
|
8218
8220
|
annotations: annotationsFor("provision_storefront_clerk", "write")
|
|
8219
8221
|
},
|
|
@@ -8226,7 +8228,7 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8226
8228
|
if (denied) return denied;
|
|
8227
8229
|
try {
|
|
8228
8230
|
const brand = await loadStorefrontBrand(dir, name ? { name } : void 0);
|
|
8229
|
-
const
|
|
8231
|
+
const result3 = await provisionClerk({
|
|
8230
8232
|
name: name ?? brand.name,
|
|
8231
8233
|
domain: brand.domain,
|
|
8232
8234
|
production: production === true,
|
|
@@ -8235,28 +8237,28 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8235
8237
|
storefront: dir,
|
|
8236
8238
|
cli: clerkCliDeps()
|
|
8237
8239
|
});
|
|
8238
|
-
if (!
|
|
8240
|
+
if (!result3.ok || !result3.credentials) {
|
|
8239
8241
|
return ok3({
|
|
8240
8242
|
provisioned: false,
|
|
8241
|
-
tier:
|
|
8242
|
-
reason:
|
|
8243
|
-
guidance:
|
|
8243
|
+
tier: result3.tier,
|
|
8244
|
+
reason: result3.reason,
|
|
8245
|
+
guidance: result3.guidance ?? []
|
|
8244
8246
|
});
|
|
8245
8247
|
}
|
|
8246
8248
|
const written = await mergeEnvLocal(dir, {
|
|
8247
|
-
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:
|
|
8248
|
-
CLERK_SECRET_KEY:
|
|
8249
|
+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: result3.credentials.publishableKey,
|
|
8250
|
+
CLERK_SECRET_KEY: result3.credentials.secretKey
|
|
8249
8251
|
});
|
|
8250
8252
|
const { allowedOrigins, redirectUrls } = storefrontClerkUrls(url, brand.domain);
|
|
8251
|
-
const configured = await configureClerkInstance(
|
|
8253
|
+
const configured = await configureClerkInstance(result3.credentials.secretKey, {
|
|
8252
8254
|
allowedOrigins,
|
|
8253
8255
|
redirectUrls
|
|
8254
8256
|
});
|
|
8255
8257
|
return ok3({
|
|
8256
8258
|
provisioned: true,
|
|
8257
|
-
tier:
|
|
8258
|
-
application_id:
|
|
8259
|
-
instance_id:
|
|
8259
|
+
tier: result3.tier,
|
|
8260
|
+
application_id: result3.credentials.applicationId ?? null,
|
|
8261
|
+
instance_id: result3.credentials.instanceId ?? null,
|
|
8260
8262
|
env_written: written,
|
|
8261
8263
|
configured: configured.applied,
|
|
8262
8264
|
configure_failures: configured.failed
|
|
@@ -8269,7 +8271,7 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
8269
8271
|
}
|
|
8270
8272
|
|
|
8271
8273
|
// src/tools-storefront-plan.ts
|
|
8272
|
-
import { z as
|
|
8274
|
+
import { z as z13 } from "zod";
|
|
8273
8275
|
|
|
8274
8276
|
// src/lib/storefront-plan-update.ts
|
|
8275
8277
|
var STRIPE_PRICE_ID_RE = /^price_[A-Za-z0-9_]+$/;
|
|
@@ -8375,14 +8377,14 @@ function registerStorefrontPlanTools(server2, props2, call = (path, body2) => {
|
|
|
8375
8377
|
server2.registerTool(name, {
|
|
8376
8378
|
title: name === "list_storefronts" ? "List Storefronts" : "Get Storefront",
|
|
8377
8379
|
description: "Read hosted storefront plans including stored OCS account ids and account_status.",
|
|
8378
|
-
inputSchema: name === "get_storefront" ? { storefront_id:
|
|
8380
|
+
inputSchema: name === "get_storefront" ? { storefront_id: z13.string().min(1) } : {},
|
|
8379
8381
|
annotations: annotationsFor(name, "read")
|
|
8380
8382
|
}, async (args) => {
|
|
8381
8383
|
const denied = denyUnlessScoped(props2, name, STOREFRONT_PLAN_TOOL_SCOPES);
|
|
8382
8384
|
if (denied) return denied;
|
|
8383
8385
|
try {
|
|
8384
|
-
const
|
|
8385
|
-
return
|
|
8386
|
+
const result3 = await read("storefront_id" in args ? String(args.storefront_id) : void 0);
|
|
8387
|
+
return result3.ok ? ok4(JSON.stringify(result3.body)) : err5(JSON.stringify(result3.body));
|
|
8386
8388
|
} catch (e) {
|
|
8387
8389
|
return err5(e instanceof Error ? e.message : "storefront read failed");
|
|
8388
8390
|
}
|
|
@@ -8394,14 +8396,14 @@ function registerStorefrontPlanTools(server2, props2, call = (path, body2) => {
|
|
|
8394
8396
|
title: "Update Storefront Plan",
|
|
8395
8397
|
description: "Change the retail price, whether a plan is for sale, its OCS account, its display order, or the stored Stripe Price on the caller's own hosted storefront. The plan must already exist. A price of zero or less is refused. stripe_price_id and stripe_price_mode are set together; null clears both. The id must look like price_\u2026 and be 1-255 characters. A plan on another storefront is not found and is left unchanged. The Price is stored, not yet charged. This does not create a Stripe Price, and a buyer cannot set one. The later checkout must verify the Price on the connected account.",
|
|
8396
8398
|
inputSchema: {
|
|
8397
|
-
ocs_account_id:
|
|
8398
|
-
storefront_id:
|
|
8399
|
-
slug:
|
|
8400
|
-
price_cents:
|
|
8401
|
-
active:
|
|
8402
|
-
sort_order:
|
|
8403
|
-
stripe_price_id:
|
|
8404
|
-
stripe_price_mode:
|
|
8399
|
+
ocs_account_id: z13.number().int().positive().optional().describe("Owned OCS account override. Omit for automatic resolution."),
|
|
8400
|
+
storefront_id: z13.string().min(1).describe("Id of the hosted storefront"),
|
|
8401
|
+
slug: z13.string().min(1).describe("Plan slug, such as eu-1gb"),
|
|
8402
|
+
price_cents: z13.number().int().positive().optional().describe("Retail price in minor units. Must be greater than zero. Omit to leave the price."),
|
|
8403
|
+
active: z13.boolean().optional().describe("Whether the plan is for sale. Omit to leave it."),
|
|
8404
|
+
sort_order: z13.number().int().nonnegative().optional().describe("Display order, lowest first. Omit to leave it."),
|
|
8405
|
+
stripe_price_id: z13.string().regex(/^price_[A-Za-z0-9_]+$/).max(255).nullable().optional().describe("Existing Stripe Price id (price_\u2026, 1-255 characters), stored, not yet charged. Set with stripe_price_mode. Null clears both. Omit to leave them."),
|
|
8406
|
+
stripe_price_mode: z13.enum(["test", "live"]).nullable().optional().describe("test or live. Set with stripe_price_id. Null clears both. Omit to leave them.")
|
|
8405
8407
|
},
|
|
8406
8408
|
annotations: annotationsFor("update_storefront_plan", "write")
|
|
8407
8409
|
},
|
|
@@ -8418,9 +8420,9 @@ function registerStorefrontPlanTools(server2, props2, call = (path, body2) => {
|
|
|
8418
8420
|
});
|
|
8419
8421
|
if (!update.ok) return err5(update.message);
|
|
8420
8422
|
try {
|
|
8421
|
-
const
|
|
8422
|
-
const text = JSON.stringify(
|
|
8423
|
-
return
|
|
8423
|
+
const result3 = await call(`${storefront_id}/${slug}`, update.body);
|
|
8424
|
+
const text = JSON.stringify(result3.body);
|
|
8425
|
+
return result3.ok ? ok4(text) : err5(text);
|
|
8424
8426
|
} catch (e) {
|
|
8425
8427
|
return err5(e instanceof Error ? e.message : "plan update failed");
|
|
8426
8428
|
}
|
|
@@ -8429,7 +8431,7 @@ function registerStorefrontPlanTools(server2, props2, call = (path, body2) => {
|
|
|
8429
8431
|
}
|
|
8430
8432
|
|
|
8431
8433
|
// src/tools-atlas.ts
|
|
8432
|
-
import { z as
|
|
8434
|
+
import { z as z14 } from "zod";
|
|
8433
8435
|
|
|
8434
8436
|
// src/atlas-public.ts
|
|
8435
8437
|
var ATLAS_PUBLIC_BASE_URL = "https://atlas.carrier.llc";
|
|
@@ -8487,13 +8489,13 @@ var ATLAS_TOOL_SCOPES = {
|
|
|
8487
8489
|
get_atlas_network_status: "read"
|
|
8488
8490
|
};
|
|
8489
8491
|
var coverageSchema = {
|
|
8490
|
-
country:
|
|
8491
|
-
status:
|
|
8492
|
-
technology:
|
|
8492
|
+
country: z14.string().regex(/^[A-Za-z]{2}$/, "country must be a 2-letter ISO code").describe("ISO 3166-1 alpha-2 country code, for example JP or NL"),
|
|
8493
|
+
status: z14.enum(["up", "degraded", "down", "unknown"]).optional().describe("Keep only networks whose latest probe has this status"),
|
|
8494
|
+
technology: z14.enum(["2G", "3G", "4G", "5G"]).optional().describe("Keep only networks of this radio generation")
|
|
8493
8495
|
};
|
|
8494
8496
|
var networkSchema = {
|
|
8495
|
-
mcc:
|
|
8496
|
-
mnc:
|
|
8497
|
+
mcc: z14.string().regex(/^\d{3}$/, "mcc must be 3 digits").describe("Mobile Country Code"),
|
|
8498
|
+
mnc: z14.string().regex(/^\d{2,3}$/, "mnc must be 2 or 3 digits").describe("Mobile Network Code")
|
|
8497
8499
|
};
|
|
8498
8500
|
function jsonResult3(body2) {
|
|
8499
8501
|
return {
|
|
@@ -8548,15 +8550,15 @@ function registerAtlasTools(server2, ctx) {
|
|
|
8548
8550
|
}
|
|
8549
8551
|
|
|
8550
8552
|
// src/tools-network-default.ts
|
|
8551
|
-
import { z as
|
|
8553
|
+
import { z as z15 } from "zod";
|
|
8552
8554
|
var NETWORK_DEFAULT_TOOL_SCOPES = {
|
|
8553
8555
|
get_network_default: "read",
|
|
8554
8556
|
set_network_default: "write",
|
|
8555
8557
|
plan_network_default: "read"
|
|
8556
8558
|
};
|
|
8557
|
-
var choiceShape =
|
|
8558
|
-
mode:
|
|
8559
|
-
steeringListId:
|
|
8559
|
+
var choiceShape = z15.object({
|
|
8560
|
+
mode: z15.enum(NETWORK_DEFAULT_MODES),
|
|
8561
|
+
steeringListId: z15.number().int().positive().optional()
|
|
8560
8562
|
}).describe("`cheapest_available`, `all`, or `custom` with a steeringListId from list_steering_lists");
|
|
8561
8563
|
function ioFor(ctx, token2) {
|
|
8562
8564
|
const kv = ctx.env.CARRIER_USERS;
|
|
@@ -8611,9 +8613,9 @@ function registerNetworkDefaultTools(server2, ctx) {
|
|
|
8611
8613
|
title: "Set Network Default",
|
|
8612
8614
|
description: "Use this to set the organisation's network default to `cheapest_available`, `all`, or `custom` (a steering list id from `list_steering_lists`, which must exist). This only stores the setting. It changes no SIM, writes nothing to OCS and does not migrate existing customers: it applies to NEW assignments. A single assignment can still override it with `plan_network_default`'s `simOverride`. Params: `mode` (required), `steeringListId` (required when mode is `custom`), `dry_run` (preview only). Do NOT use this to assign a list to one SIM \u2014 use `modify_subscriber_steering_list`.",
|
|
8613
8615
|
inputSchema: {
|
|
8614
|
-
mode:
|
|
8615
|
-
steeringListId:
|
|
8616
|
-
dry_run:
|
|
8616
|
+
mode: z15.enum(NETWORK_DEFAULT_MODES).describe("cheapest_available | all | custom"),
|
|
8617
|
+
steeringListId: z15.number().int().positive().optional().describe("Required when mode is custom"),
|
|
8618
|
+
dry_run: z15.boolean().optional().describe("If true, validate and return what would be stored; store nothing")
|
|
8617
8619
|
},
|
|
8618
8620
|
annotations: { readOnlyHint: false, idempotentHint: true, destructiveHint: false }
|
|
8619
8621
|
},
|
|
@@ -8642,10 +8644,10 @@ function registerNetworkDefaultTools(server2, ctx) {
|
|
|
8642
8644
|
title: "Plan Network Default",
|
|
8643
8645
|
description: "Use this to see which networks a SIM would be given in one or more countries, before anything is assigned. By default that is the cheapest available network per country (lowest data rate above zero, among rules really in force). Precedence: `simOverride`, then `packageOverride`, then the org default, then `cheapest_available`. Read only: `applied` is always false. If the tariff is missing or cannot be compared it falls back to ALL networks and says so in `warnings` and `summary` (`fellBackToAll: true`); never present that as a cheapest choice. The price basis is the wholesale data rate per MB, not the end price. Creating a steering list has no OCS REST method, so when no existing list matches the result is `needs_list`, not a created list. Params: `countries` (ISO-3166 alpha-2 codes, required), `simOverride`, `packageOverride`, `resellerId` (optional).",
|
|
8644
8646
|
inputSchema: {
|
|
8645
|
-
countries:
|
|
8647
|
+
countries: z15.array(z15.string().length(2)).min(1).describe('ISO-3166 alpha-2 codes, e.g. ["CA"]'),
|
|
8646
8648
|
simOverride: choiceShape.optional(),
|
|
8647
8649
|
packageOverride: choiceShape.optional(),
|
|
8648
|
-
resellerId:
|
|
8650
|
+
resellerId: z15.number().int().positive().optional().describe("Omit to use the token owner's reseller")
|
|
8649
8651
|
},
|
|
8650
8652
|
annotations: { readOnlyHint: true }
|
|
8651
8653
|
},
|
|
@@ -8660,7 +8662,7 @@ function registerNetworkDefaultTools(server2, ctx) {
|
|
|
8660
8662
|
}
|
|
8661
8663
|
|
|
8662
8664
|
// src/affiliate-tools.ts
|
|
8663
|
-
import { z as
|
|
8665
|
+
import { z as z16 } from "zod";
|
|
8664
8666
|
var AFFILIATE_TOOL_SCOPES = {
|
|
8665
8667
|
affiliate_status: "read",
|
|
8666
8668
|
affiliate_commissions: "read",
|
|
@@ -8731,7 +8733,7 @@ function registerAffiliateTools(server2, ctx) {
|
|
|
8731
8733
|
title: "Affiliate Commissions",
|
|
8732
8734
|
description: "Read-only: returns the list of commission records for the authenticated operator.",
|
|
8733
8735
|
inputSchema: {
|
|
8734
|
-
limit:
|
|
8736
|
+
limit: z16.number().int().min(1).max(200).optional().default(50).describe("Maximum number of commission records to return (1-200, default: 50).")
|
|
8735
8737
|
},
|
|
8736
8738
|
annotations: annotationsFor("affiliate_commissions", "read")
|
|
8737
8739
|
},
|
|
@@ -10882,15 +10884,15 @@ function registerAllCarrierAskTools(server2, ctx) {
|
|
|
10882
10884
|
title: "Natural Language Carrier Tool Router",
|
|
10883
10885
|
description: "Use this when you want to perform a carrier operation but don't know which specific tool to call. Describe your intent in plain language and carrier_ask will identify the correct tool(s) and suggest the required parameters. For simple read intents, it executes directly and returns results. For destructive operations it returns a confirm_token that you must pass in a second call. Params: `intent` (string \u2014 natural language description of what you want to do), `context` (optional: iccid, account_id, reseller_id if already known). Returns: RouteResult \u2014 confirmed | pending_confirm | ambiguous | none. Do NOT use this when you know the right tool \u2014 direct calls are faster and cheaper.",
|
|
10884
10886
|
inputSchema: {
|
|
10885
|
-
intent:
|
|
10887
|
+
intent: z17.string().min(3).describe(
|
|
10886
10888
|
"Natural-language description of the operation to perform (e.g. 'suspend ICCID 89316 until next month', 'show fleet health', 'assign Europe 5GB package to subscriber 89316...')"
|
|
10887
10889
|
),
|
|
10888
|
-
context:
|
|
10889
|
-
iccid:
|
|
10890
|
-
account_id:
|
|
10891
|
-
reseller_id:
|
|
10890
|
+
context: z17.object({
|
|
10891
|
+
iccid: z17.string().optional().describe("Subscriber ICCID if already known"),
|
|
10892
|
+
account_id: z17.number().optional().describe("Account ID if already known"),
|
|
10893
|
+
reseller_id: z17.number().optional().describe("Reseller ID if already known")
|
|
10892
10894
|
}).optional().describe("Optional pre-resolved context to improve routing accuracy"),
|
|
10893
|
-
confirm_token:
|
|
10895
|
+
confirm_token: z17.string().optional().describe(
|
|
10894
10896
|
"One-time token from a previous carrier_ask call with confirm_required=true. Providing this executes the previously staged destructive operation."
|
|
10895
10897
|
)
|
|
10896
10898
|
}
|
|
@@ -11094,7 +11096,7 @@ function registerAllCarrierAskTools(server2, ctx) {
|
|
|
11094
11096
|
title: "Describe a Carrier Tool",
|
|
11095
11097
|
description: "Get full documentation for any registered Carrier MCP tool: description, parameters, 2-3 example invocations, required scope, destructive flag, and guidance. Params: `tool_name` (exact MCP tool name, e.g. 'assign_package'). Returns: structured tool metadata. Does NOT execute the tool.",
|
|
11096
11098
|
inputSchema: {
|
|
11097
|
-
tool_name:
|
|
11099
|
+
tool_name: z17.string().describe("The exact MCP tool name to describe (e.g. 'assign_package', 'hlr_set_bitrate')")
|
|
11098
11100
|
}
|
|
11099
11101
|
},
|
|
11100
11102
|
wrapHandler(
|
|
@@ -11187,7 +11189,7 @@ function buildExamples(toolName) {
|
|
|
11187
11189
|
}
|
|
11188
11190
|
|
|
11189
11191
|
// src/list-recent-ocs-events.ts
|
|
11190
|
-
import { z as
|
|
11192
|
+
import { z as z18 } from "zod";
|
|
11191
11193
|
|
|
11192
11194
|
// ../../packages/ocs-spec/src/ocs-event-buffer-read.ts
|
|
11193
11195
|
var LIFECYCLE_RESELLER_ID2 = 1170;
|
|
@@ -11316,10 +11318,10 @@ var ALLOWED_EVENT_TYPES = [
|
|
|
11316
11318
|
"usage.anomaly"
|
|
11317
11319
|
];
|
|
11318
11320
|
var listRecentOcsEventsSchema = {
|
|
11319
|
-
iccid:
|
|
11320
|
-
limit:
|
|
11321
|
-
event_types:
|
|
11322
|
-
since:
|
|
11321
|
+
iccid: z18.string().regex(/^\d{19,20}$/).describe("ICCID, 19 or 20 digits, ITU-T E.118 format"),
|
|
11322
|
+
limit: z18.number().int().min(1).max(50).default(20).describe("Max events to return, newest first"),
|
|
11323
|
+
event_types: z18.array(z18.enum(ALLOWED_EVENT_TYPES)).optional().describe("Filter to specific event types"),
|
|
11324
|
+
since: z18.string().datetime().optional().describe("ISO-8601 timestamp; only events after this point")
|
|
11323
11325
|
};
|
|
11324
11326
|
async function listRecentOcsEvents2(iccid, limit, eventTypes, since, kv) {
|
|
11325
11327
|
return listRecentOcsEvents(iccid, limit, eventTypes, since, kv);
|
|
@@ -11360,7 +11362,7 @@ function registerListRecentOcsEventsTool(server2, ctx) {
|
|
|
11360
11362
|
"OCS_EVENT_ROUTING",
|
|
11361
11363
|
"the OCS event ring buffer"
|
|
11362
11364
|
);
|
|
11363
|
-
const
|
|
11365
|
+
const result3 = await listRecentOcsEvents2(
|
|
11364
11366
|
iccid,
|
|
11365
11367
|
limit,
|
|
11366
11368
|
event_types,
|
|
@@ -11368,7 +11370,7 @@ function registerListRecentOcsEventsTool(server2, ctx) {
|
|
|
11368
11370
|
env.OCS_EVENT_ROUTING
|
|
11369
11371
|
);
|
|
11370
11372
|
return {
|
|
11371
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
11373
|
+
content: [{ type: "text", text: JSON.stringify(result3, null, 2) }]
|
|
11372
11374
|
};
|
|
11373
11375
|
} catch (err9) {
|
|
11374
11376
|
const message = err9 instanceof Error ? err9.message : String(err9);
|
|
@@ -11382,7 +11384,7 @@ function registerListRecentOcsEventsTool(server2, ctx) {
|
|
|
11382
11384
|
}
|
|
11383
11385
|
|
|
11384
11386
|
// src/tools-rate-governor.ts
|
|
11385
|
-
import { z as
|
|
11387
|
+
import { z as z19 } from "zod";
|
|
11386
11388
|
var MONITORED_ENDPOINTS = [
|
|
11387
11389
|
"subscriberNetworkEventsOverPeriod",
|
|
11388
11390
|
// 30/min
|
|
@@ -11414,7 +11416,7 @@ function registerRateLimitStatusTool(server2, ctx) {
|
|
|
11414
11416
|
title: "API Rate-Limit Governor Status",
|
|
11415
11417
|
description: "Inspect Bridge4IP OCS rate-limit governor state \u2014 bucket fill levels, per-endpoint limits, and 80% alert thresholds. Use this to answer: 'are we rate limited', 'check ocs quota', 'how full is the rate limit bucket', 'rate limit status'. Params: `endpoint` (optional \u2014 OCS camelCase method name to inspect a single bucket, e.g. 'subscriberUsageOverPeriod'; omit for all monitored endpoints). Returns: per-endpoint { limit_per_min, batch_cap_per_min, calls_in_window, batch_calls_in_window, utilisation_pct, alert (true when \u226580% of limit) }. Note: counts come from the in-process sliding-window log (same key as OCS calls: API token + endpoint) \u2014 they reset when the Worker isolate recycles. Use as a relative signal, not an exact counter. Do NOT use this to adjust limits \u2014 limits are set by Bridge4IP contract and cannot be changed via MCP.",
|
|
11416
11418
|
inputSchema: {
|
|
11417
|
-
endpoint:
|
|
11419
|
+
endpoint: z19.string().optional().describe(
|
|
11418
11420
|
"OCS method name in camelCase (e.g. 'subscriberUsageOverPeriod'). Omit to return status for all monitored endpoints."
|
|
11419
11421
|
)
|
|
11420
11422
|
},
|
|
@@ -11470,7 +11472,7 @@ function registerRateLimitStatusTool(server2, ctx) {
|
|
|
11470
11472
|
}
|
|
11471
11473
|
|
|
11472
11474
|
// src/tools-depletion-events.ts
|
|
11473
|
-
import { z as
|
|
11475
|
+
import { z as z20 } from "zod";
|
|
11474
11476
|
function ok6(payload) {
|
|
11475
11477
|
return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }] };
|
|
11476
11478
|
}
|
|
@@ -11498,10 +11500,10 @@ function registerDepletionEventsTool(server2, ctx) {
|
|
|
11498
11500
|
title: "Subscriber Bundle Depletion Events",
|
|
11499
11501
|
description: "Look up bundle depletion events for a subscriber (or list recent fleet-wide depletions). Returns the most recent bundle.depleted event stored when the prepaid usage webhook received a last_slice notification. Events are retained for 7 days. Use subscriberId to check a specific subscriber, or omit to list the 20 most recent fleet-wide depletions. Requires 'read' scope.",
|
|
11500
11502
|
inputSchema: {
|
|
11501
|
-
subscriberId:
|
|
11503
|
+
subscriberId: z20.string().optional().describe(
|
|
11502
11504
|
"OCS subscriber ID to look up. Omit to list the 20 most recent fleet-wide depletions."
|
|
11503
11505
|
),
|
|
11504
|
-
since:
|
|
11506
|
+
since: z20.string().optional().describe(
|
|
11505
11507
|
"ISO-8601 timestamp \u2014 only return events at or after this time (for single-subscriber lookup)."
|
|
11506
11508
|
)
|
|
11507
11509
|
},
|
|
@@ -11616,7 +11618,7 @@ function registerDepletionEventsTool(server2, ctx) {
|
|
|
11616
11618
|
}
|
|
11617
11619
|
|
|
11618
11620
|
// src/tools-country-history.ts
|
|
11619
|
-
import { z as
|
|
11621
|
+
import { z as z21 } from "zod";
|
|
11620
11622
|
function isoDate(now, daysAgo = 0) {
|
|
11621
11623
|
const d = new Date(now.getTime() - daysAgo * 864e5);
|
|
11622
11624
|
return d.toISOString().slice(0, 10);
|
|
@@ -11639,10 +11641,10 @@ function registerCountryHistoryTool(server2, ctx) {
|
|
|
11639
11641
|
title: "Subscriber Country History",
|
|
11640
11642
|
description: "Return cross-border movement history for a subscriber, reconstructed from OCS Gy charging events. Reads `gyAnswer.events` from `subscriberNetworkEventsOverPeriod` \u2014 every Gy record carries its own country, operator and MCC \u2014 and collapses consecutive same-country records into stays with first-seen and last-seen timestamps. This needs no webhook: it works with Relay LU and Relay Gy off. Relay `country.entered` events from the 24h ring-buffer are merged in as a supplement when present. Use this to answer: 'where has subscriber X traveled', 'show country history for ICCID', 'border crossings for this SIM'. Params: `subscriberId` (ICCID, 19\u201320 digits), `startDate`/`endDate` (YYYY-MM-DD, max 7 days apart, default the last 7 days), `limit` (1\u201350, default 20, newest first). Returns: `stays` ({ country, country_name, first_seen, last_seen, operators, mccs, event_count, used_bytes }), `transitions` ({ from, to, at }), and `country_events` in the legacy flat shape. `used_bytes` already handles the string-typed `usedUnits` and its 'N/A' values. Do NOT use this for raw per-session records \u2014 use `subscriber_network_events` for those.",
|
|
11641
11643
|
inputSchema: {
|
|
11642
|
-
subscriberId:
|
|
11643
|
-
startDate:
|
|
11644
|
-
endDate:
|
|
11645
|
-
limit:
|
|
11644
|
+
subscriberId: z21.string().regex(/^\d{19,20}$/, "subscriberId must be a 19\u201320 digit ICCID").describe("Subscriber ICCID (19\u201320 digits, ITU-T E.118)"),
|
|
11645
|
+
startDate: z21.string().regex(/^\d{4}-\d{2}-\d{2}$/, "startDate must be YYYY-MM-DD").optional().describe("Start of the period, YYYY-MM-DD inclusive (default: 7 days ago)"),
|
|
11646
|
+
endDate: z21.string().regex(/^\d{4}-\d{2}-\d{2}$/, "endDate must be YYYY-MM-DD").optional().describe("End of the period, YYYY-MM-DD inclusive, max 7 days from start (default: today)"),
|
|
11647
|
+
limit: z21.number().int().min(1).max(50).default(20).optional().describe("Maximum number of country_events to return, newest first (default 20, max 50)")
|
|
11646
11648
|
},
|
|
11647
11649
|
annotations: { readOnlyHint: true, idempotentHint: true }
|
|
11648
11650
|
},
|
|
@@ -11750,7 +11752,7 @@ function registerCountryHistoryTool(server2, ctx) {
|
|
|
11750
11752
|
}
|
|
11751
11753
|
|
|
11752
11754
|
// src/apps/fleet-health-app.ts
|
|
11753
|
-
import { z as
|
|
11755
|
+
import { z as z22 } from "zod";
|
|
11754
11756
|
import {
|
|
11755
11757
|
registerAppTool,
|
|
11756
11758
|
registerAppResource,
|
|
@@ -11798,7 +11800,7 @@ function toFleetInput(raw) {
|
|
|
11798
11800
|
|
|
11799
11801
|
// src/apps/fleet-health-app.ts
|
|
11800
11802
|
var FLEET_APP_RESOURCE_URI = "ui://fleet-health-dashboard";
|
|
11801
|
-
async function
|
|
11803
|
+
async function safeCall3(client2, method, params) {
|
|
11802
11804
|
try {
|
|
11803
11805
|
return { data: await client2.call(method, params), error: null };
|
|
11804
11806
|
} catch (err9) {
|
|
@@ -11812,8 +11814,8 @@ async function loadFleet(ctx, accountId) {
|
|
|
11812
11814
|
const statusParams = accountId !== void 0 ? { accountId } : resellerId !== void 0 ? { resellerId } : {};
|
|
11813
11815
|
const accountParams = resellerId !== void 0 ? { resellerId } : {};
|
|
11814
11816
|
const [status, accounts] = await Promise.all([
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
+
safeCall3(client2, "esimStatusPerAccount", statusParams),
|
|
11818
|
+
safeCall3(client2, "listResellerAccount", accountParams)
|
|
11817
11819
|
]);
|
|
11818
11820
|
return toFleetInput({
|
|
11819
11821
|
status: status.data,
|
|
@@ -11866,7 +11868,7 @@ function registerFleetHealthApp(server2, ctx) {
|
|
|
11866
11868
|
title: "Fleet Health Dashboard",
|
|
11867
11869
|
description: "Draw the fleet overview as an interactive panel: eSIM status, per-account breakdown and low-balance alerts. Returns structuredContent for the panel, so it only helps a client that can render MCP UI resources. Do NOT use this when the answer has to be readable text, or in any headless or scripted context \u2014 `fleet_health` returns the same data as prose.",
|
|
11868
11870
|
inputSchema: {
|
|
11869
|
-
accountId:
|
|
11871
|
+
accountId: z22.number().optional().describe("Filter to a specific account (omit for all)")
|
|
11870
11872
|
},
|
|
11871
11873
|
annotations: { readOnlyHint: true },
|
|
11872
11874
|
_meta: {
|
|
@@ -11909,7 +11911,7 @@ function registerFleetHealthApp(server2, ctx) {
|
|
|
11909
11911
|
}
|
|
11910
11912
|
|
|
11911
11913
|
// src/apps/provisioning-wizard.ts
|
|
11912
|
-
import { z as
|
|
11914
|
+
import { z as z23 } from "zod";
|
|
11913
11915
|
import {
|
|
11914
11916
|
registerAppTool as registerAppTool2,
|
|
11915
11917
|
registerAppResource as registerAppResource2,
|
|
@@ -12014,10 +12016,10 @@ function registerProvisioningWizard(server2, ctx) {
|
|
|
12014
12016
|
title: "eSIM Provisioning Wizard",
|
|
12015
12017
|
description: "Interactive 3-step wizard to provision an eSIM: select subscriber, choose package template, preview (dry_run) and confirm execution.",
|
|
12016
12018
|
inputSchema: {
|
|
12017
|
-
step:
|
|
12018
|
-
wizardId:
|
|
12019
|
-
subscriber_iccid:
|
|
12020
|
-
package_template_id:
|
|
12019
|
+
step: z23.enum(["init", "select-package", "preview", "confirm"]).describe("Current wizard step"),
|
|
12020
|
+
wizardId: z23.string().optional().describe("Wizard session ID (absent on init)"),
|
|
12021
|
+
subscriber_iccid: z23.string().optional().describe("Subscriber ICCID (required for select-package)"),
|
|
12022
|
+
package_template_id: z23.number().optional().describe("Package template ID (required for preview)")
|
|
12021
12023
|
},
|
|
12022
12024
|
_meta: {
|
|
12023
12025
|
ui: {
|
|
@@ -12248,7 +12250,7 @@ function registerProvisioningWizard(server2, ctx) {
|
|
|
12248
12250
|
isError: true
|
|
12249
12251
|
};
|
|
12250
12252
|
}
|
|
12251
|
-
const
|
|
12253
|
+
const result3 = await safeCallWithToken(
|
|
12252
12254
|
client2,
|
|
12253
12255
|
token2,
|
|
12254
12256
|
"affectPackageToSubscriber",
|
|
@@ -12258,12 +12260,12 @@ function registerProvisioningWizard(server2, ctx) {
|
|
|
12258
12260
|
}
|
|
12259
12261
|
);
|
|
12260
12262
|
await deleteWizardSession(ctx.env, ctx.props.sub, wizardId);
|
|
12261
|
-
if (
|
|
12263
|
+
if (result3.error) {
|
|
12262
12264
|
return {
|
|
12263
12265
|
content: [
|
|
12264
12266
|
{
|
|
12265
12267
|
type: "text",
|
|
12266
|
-
text: `Provisioning failed: ${
|
|
12268
|
+
text: `Provisioning failed: ${result3.error}`
|
|
12267
12269
|
}
|
|
12268
12270
|
],
|
|
12269
12271
|
isError: true
|
|
@@ -12274,7 +12276,7 @@ function registerProvisioningWizard(server2, ctx) {
|
|
|
12274
12276
|
structuredContent: {
|
|
12275
12277
|
wizardId,
|
|
12276
12278
|
step: "done",
|
|
12277
|
-
result:
|
|
12279
|
+
result: result3.data
|
|
12278
12280
|
}
|
|
12279
12281
|
};
|
|
12280
12282
|
}
|
|
@@ -12287,7 +12289,7 @@ function registerProvisioningWizard(server2, ctx) {
|
|
|
12287
12289
|
}
|
|
12288
12290
|
|
|
12289
12291
|
// src/apps/balance-topup.ts
|
|
12290
|
-
import { z as
|
|
12292
|
+
import { z as z24 } from "zod";
|
|
12291
12293
|
import {
|
|
12292
12294
|
registerAppTool as registerAppTool3,
|
|
12293
12295
|
registerAppResource as registerAppResource3,
|
|
@@ -12340,9 +12342,9 @@ function registerBalanceTopupApp(server2, ctx) {
|
|
|
12340
12342
|
title: "Balance Top-up Form",
|
|
12341
12343
|
description: "Adjust the OCS reseller-account balance behind one subscriber, through a form panel the user can review before it commits. Defaults to preview: a call that omits `preview` returns a projection and writes nothing. Only `preview: false` performs the OCS write. Params: `iccid` (subscriber identifier used to find the account), `delta` (amount to add when positive, deduct when negative), `preview` (boolean, default true). Requires `admin` scope plus recent MFA, and a client that can render UI panels. Do NOT use this in a headless or scripted context \u2014 call `modify_account_balance` directly, which takes an `accountId` and needs no panel. Do NOT use this for a subscriber's own balance \u2014 the `iccid` here only locates the account; per-subscriber money is `modify_subscriber_balance`. Do NOT use this for the Carrier prepaid wallet or MCP credits \u2014 see `wallet_topup_checkout` and `credit_balance`.",
|
|
12342
12344
|
inputSchema: {
|
|
12343
|
-
iccid:
|
|
12344
|
-
delta:
|
|
12345
|
-
preview:
|
|
12345
|
+
iccid: z24.string().describe("The subscriber ICCID for the account lookup"),
|
|
12346
|
+
delta: z24.number().describe("Amount to add (positive) or deduct (negative) from the account balance"),
|
|
12347
|
+
preview: z24.boolean().default(true).describe("If true, return preview without writing. If false, execute the balance change.")
|
|
12346
12348
|
},
|
|
12347
12349
|
annotations: { destructiveHint: true },
|
|
12348
12350
|
_meta: {
|
|
@@ -12361,13 +12363,13 @@ function registerBalanceTopupApp(server2, ctx) {
|
|
|
12361
12363
|
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
12362
12364
|
const client2 = new OcsClient(ctx.env.CARRIER_OCS_BASE_URL, token2);
|
|
12363
12365
|
if (preview === true) {
|
|
12364
|
-
const
|
|
12366
|
+
const result3 = await safeCallWithToken2(
|
|
12365
12367
|
client2,
|
|
12366
12368
|
token2,
|
|
12367
12369
|
"getSingleSubscriber",
|
|
12368
12370
|
{ iccid }
|
|
12369
12371
|
);
|
|
12370
|
-
const currentBalance =
|
|
12372
|
+
const currentBalance = result3.data ? Number(result3.data["balance"] ?? result3.data["accountBalance"] ?? 0) : 0;
|
|
12371
12373
|
const newBalance2 = currentBalance + delta;
|
|
12372
12374
|
const structured2 = {
|
|
12373
12375
|
iccid,
|
|
@@ -12425,7 +12427,7 @@ function registerAllApps(server2, ctx) {
|
|
|
12425
12427
|
}
|
|
12426
12428
|
|
|
12427
12429
|
// src/prompts.ts
|
|
12428
|
-
import { z as
|
|
12430
|
+
import { z as z25 } from "zod";
|
|
12429
12431
|
function registerAllPrompts(server2) {
|
|
12430
12432
|
server2.registerPrompt(
|
|
12431
12433
|
"fleet_health_report",
|
|
@@ -12461,7 +12463,7 @@ Format as a structured report with sections, tables, and actionable recommendati
|
|
|
12461
12463
|
{
|
|
12462
12464
|
title: "Subscriber Deep Dive",
|
|
12463
12465
|
description: "Comprehensive analysis of a single subscriber: profile, packages, usage patterns, location history, recommendations.",
|
|
12464
|
-
argsSchema: { iccid:
|
|
12466
|
+
argsSchema: { iccid: z25.string().describe("The subscriber ICCID to analyse") }
|
|
12465
12467
|
},
|
|
12466
12468
|
async ({ iccid }) => ({
|
|
12467
12469
|
messages: [
|
|
@@ -12560,7 +12562,7 @@ Analyze and present:
|
|
|
12560
12562
|
{
|
|
12561
12563
|
title: "Bulk Operations Planner",
|
|
12562
12564
|
description: "Plan bulk operations safely: mass package assignments, account migrations, balance adjustments, or status changes.",
|
|
12563
|
-
argsSchema: { operation:
|
|
12565
|
+
argsSchema: { operation: z25.string().describe("Describe the bulk operation you want to perform") }
|
|
12564
12566
|
},
|
|
12565
12567
|
async ({ operation }) => ({
|
|
12566
12568
|
messages: [
|
|
@@ -12593,7 +12595,7 @@ NEVER execute destructive operations without confirmation.`
|
|
|
12593
12595
|
}
|
|
12594
12596
|
|
|
12595
12597
|
// src/tools-pricing.ts
|
|
12596
|
-
import { z as
|
|
12598
|
+
import { z as z26 } from "zod";
|
|
12597
12599
|
function registerAllPricingTools(server2, ctx) {
|
|
12598
12600
|
const allTools = [...PRICING_TOOLS, ...PROJECTS_TOOLS];
|
|
12599
12601
|
for (const tool of allTools) {
|
|
@@ -12657,7 +12659,7 @@ function buildPricingHandler(tool, ctx) {
|
|
|
12657
12659
|
}
|
|
12658
12660
|
}
|
|
12659
12661
|
try {
|
|
12660
|
-
const
|
|
12662
|
+
const result3 = await tool.handler(ctx.env, ctx.props, args);
|
|
12661
12663
|
recordUsage(ctx.env, ctx.props.sub, tier);
|
|
12662
12664
|
deductCredits(ctx.env, ctx.props.sub, tier, tool.scope);
|
|
12663
12665
|
ctx.audit({
|
|
@@ -12671,7 +12673,7 @@ function buildPricingHandler(tool, ctx) {
|
|
|
12671
12673
|
content: [
|
|
12672
12674
|
{
|
|
12673
12675
|
type: "text",
|
|
12674
|
-
text: JSON.stringify(
|
|
12676
|
+
text: JSON.stringify(result3, null, 2)
|
|
12675
12677
|
}
|
|
12676
12678
|
]
|
|
12677
12679
|
};
|
|
@@ -12696,23 +12698,23 @@ function toolNameToTitle(name) {
|
|
|
12696
12698
|
}
|
|
12697
12699
|
function buildZodSchema(schema) {
|
|
12698
12700
|
const properties = schema.properties ?? {};
|
|
12699
|
-
const
|
|
12701
|
+
const result3 = {};
|
|
12700
12702
|
for (const [key, prop] of Object.entries(properties)) {
|
|
12701
12703
|
let field;
|
|
12702
12704
|
if (prop.enum) {
|
|
12703
|
-
field =
|
|
12705
|
+
field = z26.enum(prop.enum);
|
|
12704
12706
|
} else if (prop.type === "number") {
|
|
12705
|
-
field =
|
|
12707
|
+
field = z26.number();
|
|
12706
12708
|
} else if (prop.type === "boolean") {
|
|
12707
|
-
field =
|
|
12709
|
+
field = z26.boolean();
|
|
12708
12710
|
} else if (prop.type === "array") {
|
|
12709
12711
|
if (prop.items?.type === "number") {
|
|
12710
|
-
field =
|
|
12712
|
+
field = z26.array(z26.number());
|
|
12711
12713
|
} else {
|
|
12712
|
-
field =
|
|
12714
|
+
field = z26.array(z26.string());
|
|
12713
12715
|
}
|
|
12714
12716
|
} else {
|
|
12715
|
-
field =
|
|
12717
|
+
field = z26.string();
|
|
12716
12718
|
}
|
|
12717
12719
|
const required = schema.required ?? [];
|
|
12718
12720
|
if (!required.includes(key)) {
|
|
@@ -12721,13 +12723,13 @@ function buildZodSchema(schema) {
|
|
|
12721
12723
|
if (prop.description) {
|
|
12722
12724
|
field = field.describe(prop.description);
|
|
12723
12725
|
}
|
|
12724
|
-
|
|
12726
|
+
result3[key] = field;
|
|
12725
12727
|
}
|
|
12726
|
-
return
|
|
12728
|
+
return result3;
|
|
12727
12729
|
}
|
|
12728
12730
|
|
|
12729
12731
|
// src/tools-greenzone.ts
|
|
12730
|
-
import { z as
|
|
12732
|
+
import { z as z27 } from "zod";
|
|
12731
12733
|
|
|
12732
12734
|
// src/greenzone-whitelist.ts
|
|
12733
12735
|
var STATE_KEY = "greenzone:state";
|
|
@@ -13018,9 +13020,9 @@ function registerGreenzoneTools(server2, ctx) {
|
|
|
13018
13020
|
title: "Greenzone Whitelist \u2014 Add",
|
|
13019
13021
|
description: "Add a hostname and/or IP address to the Bridge4IP Greenzone whitelist. The Greenzone whitelist controls which hosts/IPs are exempt from data charging after a subscriber's bundle is depleted. This operates via browser automation (Kapture) against the OCS portal \u2014 no REST API exists for this surface. Provide `host` (e.g. 'example.com') and/or `ip` (e.g. '203.0.113.0/24'). At least one of host or ip must be provided. Returns Kapture step sequence for Claude Code to execute. Requires 'write' scope and Kapture running in Sam's Chrome.",
|
|
13020
13022
|
inputSchema: {
|
|
13021
|
-
host:
|
|
13022
|
-
ip:
|
|
13023
|
-
dry_run:
|
|
13023
|
+
host: z27.string().optional().describe("Hostname to whitelist (e.g. 'example.com')"),
|
|
13024
|
+
ip: z27.string().optional().describe("IP address or CIDR to whitelist (e.g. '203.0.113.0/24')"),
|
|
13025
|
+
dry_run: z27.boolean().optional().describe("If true, return the Kapture steps without executing portal automation")
|
|
13024
13026
|
},
|
|
13025
13027
|
annotations: { destructiveHint: true }
|
|
13026
13028
|
},
|
|
@@ -13079,9 +13081,9 @@ function registerGreenzoneTools(server2, ctx) {
|
|
|
13079
13081
|
title: "Greenzone Whitelist \u2014 Remove",
|
|
13080
13082
|
description: "Remove a hostname and/or IP address from the Bridge4IP Greenzone whitelist. This operates via browser automation (Kapture) against the OCS portal. Provide `host` and/or `ip` to remove \u2014 at least one required. Returns Kapture step sequence for Claude Code to execute. Requires 'write' scope and Kapture running in Sam's Chrome.",
|
|
13081
13083
|
inputSchema: {
|
|
13082
|
-
host:
|
|
13083
|
-
ip:
|
|
13084
|
-
dry_run:
|
|
13084
|
+
host: z27.string().optional().describe("Hostname to remove from whitelist"),
|
|
13085
|
+
ip: z27.string().optional().describe("IP address or CIDR to remove from whitelist"),
|
|
13086
|
+
dry_run: z27.boolean().optional().describe("If true, return the Kapture steps without executing portal automation")
|
|
13085
13087
|
},
|
|
13086
13088
|
annotations: { destructiveHint: true }
|
|
13087
13089
|
},
|
|
@@ -13140,7 +13142,7 @@ function registerGreenzoneTools(server2, ctx) {
|
|
|
13140
13142
|
title: "Greenzone Whitelist \u2014 List",
|
|
13141
13143
|
description: "List current Greenzone whitelist entries from the KV cache. Returns all whitelisted hosts and IPs, when the state was last synced, and whether the last hourly reconciliation detected drift from the portal. This is a fast read from KV \u2014 no browser automation required. Use `from_portal: true` to trigger a live portal read via Kapture instead of KV. Requires 'read' scope.",
|
|
13142
13144
|
inputSchema: {
|
|
13143
|
-
from_portal:
|
|
13145
|
+
from_portal: z27.boolean().optional().describe(
|
|
13144
13146
|
"When true, return Kapture steps to read live portal state instead of KV cache"
|
|
13145
13147
|
)
|
|
13146
13148
|
},
|
|
@@ -13192,7 +13194,7 @@ function registerGreenzoneTools(server2, ctx) {
|
|
|
13192
13194
|
}
|
|
13193
13195
|
|
|
13194
13196
|
// src/tools-ui-agent-generic.ts
|
|
13195
|
-
import { z as
|
|
13197
|
+
import { z as z28 } from "zod";
|
|
13196
13198
|
var COST_PER_STEP_USD = 0.014;
|
|
13197
13199
|
var SESSION_OVERHEAD_USD = 5e-3;
|
|
13198
13200
|
function estimateCostUsd2(steps) {
|
|
@@ -13234,13 +13236,13 @@ function registerUiAgentGenericTools(server2, ctx, runtime) {
|
|
|
13234
13236
|
title: "Dispatch Generic Browsing Agent",
|
|
13235
13237
|
description: "Send a plain-language task to a hosted browsing agent, which drives a real browser on the open web \u2014 navigating pages, searching, extracting content, filling forms outside the OCS portal. Each run costs roughly $0.20-1.00 in model spend against your own BROWSER_USE_API_KEY, so treat it as the expensive last resort, not a lookup. Limited to CARRIER_BROWSER_USE_MAX_RUNS runs per CLI session (default 10). Params: `prompt` (1-4000 chars \u2014 name the target URL and the exact data or action), `max_steps` (1-30, default 15; prices the dry-run estimate only), `dry_run` (true returns only `estimated_cost_usd` and creates no session). Returns the finished result: unlike the hosted Worker, a local CLI has no background runtime, so this call blocks for the length of the run. Requires `write` scope. Do NOT use this to work out which Carrier tool answers a request \u2014 that is `carrier_ask`, which costs nothing. Do NOT use this for anything the OCS API already covers; every other tool here is faster, free, and audited.",
|
|
13236
13238
|
inputSchema: {
|
|
13237
|
-
prompt:
|
|
13239
|
+
prompt: z28.string().min(1).max(4e3).describe(
|
|
13238
13240
|
"Natural-language task description for the browsing agent. Be specific: include target URLs, data to extract, or actions to perform."
|
|
13239
13241
|
),
|
|
13240
|
-
max_steps:
|
|
13242
|
+
max_steps: z28.number().int().min(1).max(30).optional().describe(
|
|
13241
13243
|
"Advisory step budget (1\u201330, default 15). Prices the dry-run estimate; the hosted agent sets its own depth."
|
|
13242
13244
|
),
|
|
13243
|
-
dry_run:
|
|
13245
|
+
dry_run: z28.boolean().optional().describe(
|
|
13244
13246
|
"Preview cost estimate without dispatching. Returns estimated_cost_usd only \u2014 no browser session is created."
|
|
13245
13247
|
)
|
|
13246
13248
|
}
|
|
@@ -13312,31 +13314,31 @@ function registerUiAgentGenericTools(server2, ctx, runtime) {
|
|
|
13312
13314
|
throw err9;
|
|
13313
13315
|
}
|
|
13314
13316
|
try {
|
|
13315
|
-
const
|
|
13317
|
+
const result3 = await runUiAgent(
|
|
13316
13318
|
prompt,
|
|
13317
13319
|
"Carrier CLI browsing agent",
|
|
13318
13320
|
runtime.env
|
|
13319
13321
|
);
|
|
13320
|
-
runtime.dispatchedTaskIds.add(
|
|
13322
|
+
runtime.dispatchedTaskIds.add(result3.task_id);
|
|
13321
13323
|
ctx.audit({
|
|
13322
13324
|
tool_name: toolName,
|
|
13323
13325
|
ocs_method: "[ui-agent:generic-ask]",
|
|
13324
|
-
status:
|
|
13326
|
+
status: result3.status === "error" ? "error" : "ok",
|
|
13325
13327
|
dry_run: false,
|
|
13326
13328
|
duration_ms: Date.now() - start,
|
|
13327
13329
|
event_type: "ui_agent_dispatch"
|
|
13328
13330
|
});
|
|
13329
13331
|
return {
|
|
13330
|
-
...
|
|
13332
|
+
...result3.status === "error" ? { isError: true } : {},
|
|
13331
13333
|
content: [
|
|
13332
13334
|
{
|
|
13333
13335
|
type: "text",
|
|
13334
13336
|
text: JSON.stringify(
|
|
13335
13337
|
{
|
|
13336
|
-
status:
|
|
13337
|
-
task_id:
|
|
13338
|
-
...
|
|
13339
|
-
result:
|
|
13338
|
+
status: result3.status,
|
|
13339
|
+
task_id: result3.task_id,
|
|
13340
|
+
...result3.session_viewer_url ? { session_viewer_url: result3.session_viewer_url } : {},
|
|
13341
|
+
result: result3.result,
|
|
13340
13342
|
session_spend_usd: runtime.spend.costUsd,
|
|
13341
13343
|
runs_remaining_this_session: runtime.budget.remaining,
|
|
13342
13344
|
note: "The run completed in-process. Task records live only for this CLI session \u2014 ui_agent_status can read this task_id until the process exits."
|
|
@@ -13377,7 +13379,7 @@ function registerUiAgentGenericTools(server2, ctx, runtime) {
|
|
|
13377
13379
|
title: "Poll Browsing Agent Task Status",
|
|
13378
13380
|
description: "Returns the current state of a browsing-agent task by `task_id`, including its result once finished. In the local CLI, ui_agent_ask already returns the finished result, so this is mainly for re-reading a task within the same session. Task records do not survive the CLI process exiting. Requires `read` scope.",
|
|
13379
13381
|
inputSchema: {
|
|
13380
|
-
task_id:
|
|
13382
|
+
task_id: z28.string().describe("Task ID returned by ui_agent_ask")
|
|
13381
13383
|
}
|
|
13382
13384
|
},
|
|
13383
13385
|
async (args) => {
|