@fload-ai/mcp 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/api-client.d.ts +5 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +21 -2
- package/dist/api-client.js.map +2 -2
- package/dist/bin.d.ts +1 -1
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +747 -711
- package/dist/bin.js.map +4 -4
- package/dist/config.d.ts +1 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/index.js +668 -638
- package/dist/index.js.map +4 -4
- package/dist/rate-limiter.d.ts.map +1 -1
- package/dist/tools/actions.d.ts +27 -33
- package/dist/tools/actions.d.ts.map +1 -1
- package/dist/tools/ads.d.ts +8 -15
- package/dist/tools/ads.d.ts.map +1 -1
- package/dist/tools/agents.d.ts +22 -48
- package/dist/tools/agents.d.ts.map +1 -1
- package/dist/tools/analytics.d.ts +12 -34
- package/dist/tools/analytics.d.ts.map +1 -1
- package/dist/tools/apps.d.ts +8 -17
- package/dist/tools/apps.d.ts.map +1 -1
- package/dist/tools/aso.d.ts +43 -51
- package/dist/tools/aso.d.ts.map +1 -1
- package/dist/tools/chat.d.ts +7 -23
- package/dist/tools/chat.d.ts.map +1 -1
- package/dist/tools/dashboard.d.ts +2 -2
- package/dist/tools/dashboard.d.ts.map +1 -1
- package/dist/tools/index.d.ts +0 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +666 -644
- package/dist/tools/index.js.map +4 -4
- package/dist/tools/reviews.d.ts +17 -60
- package/dist/tools/reviews.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/tools/anomalies.d.ts +0 -107
- package/dist/tools/anomalies.d.ts.map +0 -1
- package/dist/tools/forecasting.d.ts +0 -32
- package/dist/tools/forecasting.d.ts.map +0 -1
- package/dist/tools/growth.d.ts +0 -43
- package/dist/tools/growth.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -27,6 +27,8 @@ var FloadApiClient = class {
|
|
|
27
27
|
this.baseUrl = baseUrl;
|
|
28
28
|
this.apiKey = apiKey;
|
|
29
29
|
}
|
|
30
|
+
baseUrl;
|
|
31
|
+
apiKey;
|
|
30
32
|
async request(path, options = {}) {
|
|
31
33
|
const url = `${this.baseUrl}${path}`;
|
|
32
34
|
const headers = {
|
|
@@ -52,8 +54,7 @@ var FloadApiClient = class {
|
|
|
52
54
|
const searchParams = new URLSearchParams();
|
|
53
55
|
if (params) {
|
|
54
56
|
for (const [key, value] of Object.entries(params)) {
|
|
55
|
-
if (value !== void 0)
|
|
56
|
-
searchParams.set(key, String(value));
|
|
57
|
+
if (value !== void 0) searchParams.set(key, String(value));
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
const query = searchParams.toString();
|
|
@@ -65,6 +66,24 @@ var FloadApiClient = class {
|
|
|
65
66
|
body: body ? JSON.stringify(body) : void 0
|
|
66
67
|
});
|
|
67
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* POST that hands back the answer instead of throwing on a non-2xx status:
|
|
71
|
+
* for endpoints whose refusals carry a structured body (FLO-1595: the
|
|
72
|
+
* Actions commands answer one target with that target's own status and
|
|
73
|
+
* reason). `body` is null when the response is not JSON.
|
|
74
|
+
*/
|
|
75
|
+
async postForAnswer(path, body) {
|
|
76
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: {
|
|
79
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
80
|
+
...body ? { "Content-Type": "application/json" } : {}
|
|
81
|
+
},
|
|
82
|
+
body: body ? JSON.stringify(body) : void 0
|
|
83
|
+
});
|
|
84
|
+
const parsed = await response.json().catch(() => null);
|
|
85
|
+
return { ok: response.ok, status: response.status, body: parsed };
|
|
86
|
+
}
|
|
68
87
|
async patch(path, body) {
|
|
69
88
|
return this.request(path, {
|
|
70
89
|
method: "PATCH",
|
|
@@ -110,6 +129,8 @@ var RateLimiter = class {
|
|
|
110
129
|
this.maxCalls = maxCalls;
|
|
111
130
|
this.windowMs = windowMs;
|
|
112
131
|
}
|
|
132
|
+
maxCalls;
|
|
133
|
+
windowMs;
|
|
113
134
|
calls = /* @__PURE__ */ new Map();
|
|
114
135
|
check(key) {
|
|
115
136
|
const now = Date.now();
|
|
@@ -117,8 +138,8 @@ var RateLimiter = class {
|
|
|
117
138
|
let timestamps = this.calls.get(key) || [];
|
|
118
139
|
timestamps = timestamps.filter((t) => t > windowStart);
|
|
119
140
|
if (timestamps.length >= this.maxCalls) {
|
|
120
|
-
const oldestInWindow = timestamps
|
|
121
|
-
const retryAfterMs = oldestInWindow + this.windowMs - now;
|
|
141
|
+
const [oldestInWindow] = timestamps;
|
|
142
|
+
const retryAfterMs = oldestInWindow === void 0 ? Number.NaN : oldestInWindow + this.windowMs - now;
|
|
122
143
|
this.calls.set(key, timestamps);
|
|
123
144
|
return { allowed: false, remaining: 0, retryAfterMs };
|
|
124
145
|
}
|
|
@@ -166,10 +187,8 @@ async function listApps(input, client) {
|
|
|
166
187
|
});
|
|
167
188
|
const apps = response.data ?? [];
|
|
168
189
|
const filtered = input.platform ? apps.filter((app) => {
|
|
169
|
-
if (input.platform === "ios")
|
|
170
|
-
|
|
171
|
-
if (input.platform === "android")
|
|
172
|
-
return !!app.googleAppId;
|
|
190
|
+
if (input.platform === "ios") return !!app.appleAppId;
|
|
191
|
+
if (input.platform === "android") return !!app.googleAppId;
|
|
173
192
|
return true;
|
|
174
193
|
}) : apps;
|
|
175
194
|
return {
|
|
@@ -279,6 +298,9 @@ var getReviewsSchema = z2.object({
|
|
|
279
298
|
startDate: z2.string().optional().describe("Filter reviews from this date (ISO format: YYYY-MM-DD)"),
|
|
280
299
|
endDate: z2.string().optional().describe("Filter reviews until this date (ISO format: YYYY-MM-DD)"),
|
|
281
300
|
limit: z2.number().int().min(1).max(200).default(50).describe("Maximum number of reviews to return"),
|
|
301
|
+
cursor: z2.string().optional().describe(
|
|
302
|
+
"nextCursor from the previous get_reviews call, to fetch the next page with the same app and filters"
|
|
303
|
+
),
|
|
282
304
|
sortBy: z2.enum(["date", "rating"]).default("date").describe("Sort reviews by date or rating")
|
|
283
305
|
});
|
|
284
306
|
var generateReviewReplySchema = z2.object({
|
|
@@ -337,19 +359,7 @@ async function getReviews(input, client) {
|
|
|
337
359
|
isError: true
|
|
338
360
|
};
|
|
339
361
|
}
|
|
340
|
-
const params =
|
|
341
|
-
limit: input.limit
|
|
342
|
-
};
|
|
343
|
-
if (input.platform)
|
|
344
|
-
params.platform = input.platform;
|
|
345
|
-
if (input.rating !== void 0)
|
|
346
|
-
params.rating = input.rating;
|
|
347
|
-
if (input.replied !== void 0)
|
|
348
|
-
params.responseStatus = input.replied ? "replied" : "unreplied";
|
|
349
|
-
if (input.startDate)
|
|
350
|
-
params.startDate = input.startDate;
|
|
351
|
-
if (input.endDate)
|
|
352
|
-
params.endDate = input.endDate;
|
|
362
|
+
const params = reviewQueryParameters(input);
|
|
353
363
|
const response = await client.get(
|
|
354
364
|
`/api/assets/${assetId}/reviews`,
|
|
355
365
|
params
|
|
@@ -376,6 +386,8 @@ async function getReviews(input, client) {
|
|
|
376
386
|
type: "text",
|
|
377
387
|
text: formatAsJson({
|
|
378
388
|
summary,
|
|
389
|
+
// Pass back as `cursor` to get the next page; null = last page.
|
|
390
|
+
nextCursor: response.data?.nextCursor ?? null,
|
|
379
391
|
reviews: reviews.map((review) => ({
|
|
380
392
|
id: review.id,
|
|
381
393
|
appId: review.appId,
|
|
@@ -410,6 +422,19 @@ async function getReviews(input, client) {
|
|
|
410
422
|
};
|
|
411
423
|
}
|
|
412
424
|
}
|
|
425
|
+
function reviewQueryParameters(input) {
|
|
426
|
+
const params = {
|
|
427
|
+
limit: input.limit
|
|
428
|
+
};
|
|
429
|
+
if (input.cursor) params.cursor = input.cursor;
|
|
430
|
+
if (input.platform) params.platform = input.platform;
|
|
431
|
+
if (input.rating !== void 0) params.rating = input.rating;
|
|
432
|
+
if (input.replied !== void 0)
|
|
433
|
+
params.responseStatus = input.replied ? "replied" : "unreplied";
|
|
434
|
+
if (input.startDate) params.startDate = input.startDate;
|
|
435
|
+
if (input.endDate) params.endDate = input.endDate;
|
|
436
|
+
return params;
|
|
437
|
+
}
|
|
413
438
|
async function generateReviewReply(input, client) {
|
|
414
439
|
try {
|
|
415
440
|
const response = await client.post(
|
|
@@ -500,45 +525,140 @@ async function translateReview(input, client) {
|
|
|
500
525
|
|
|
501
526
|
// src/tools/analytics.ts
|
|
502
527
|
import { z as z3 } from "zod";
|
|
528
|
+
function summarize(points, change) {
|
|
529
|
+
const values = (Array.isArray(points) ? points : []).map((point) => point.value ?? point.total).filter((value) => typeof value === "number");
|
|
530
|
+
return {
|
|
531
|
+
value: change?.currentValue ?? null,
|
|
532
|
+
effectiveFromDate: change?.effectiveFromDate ?? null,
|
|
533
|
+
effectiveToDate: change?.effectiveToDate ?? null,
|
|
534
|
+
min: values.length > 0 ? Math.min(...values) : null,
|
|
535
|
+
max: values.length > 0 ? Math.max(...values) : null,
|
|
536
|
+
dataPoints: values.length
|
|
537
|
+
};
|
|
538
|
+
}
|
|
503
539
|
var discoverMetricsSchema = z3.object({
|
|
504
540
|
assetId: z3.string().uuid().describe("App UUID to check available metrics for")
|
|
505
541
|
});
|
|
506
542
|
var getMetricsSchema = z3.object({
|
|
507
543
|
assetId: z3.string().uuid().describe("App UUID"),
|
|
508
|
-
metrics: z3.array(z3.string()).min(1).describe(
|
|
544
|
+
metrics: z3.array(z3.string()).min(1).describe(
|
|
545
|
+
'Metric names to query (e.g., ["proceeds", "totalDownloads"]). Use discover_metrics first to see available metrics.'
|
|
546
|
+
),
|
|
509
547
|
startDate: z3.string().optional().describe("Start date (YYYY-MM-DD). Defaults to 30 days ago."),
|
|
510
548
|
endDate: z3.string().optional().describe("End date (YYYY-MM-DD). Defaults to today."),
|
|
511
549
|
granularity: z3.enum(["daily", "weekly", "monthly"]).default("daily").describe("Data granularity"),
|
|
512
|
-
dimension: z3.string().optional().describe(
|
|
513
|
-
|
|
550
|
+
dimension: z3.string().optional().describe(
|
|
551
|
+
'Optional dimension to break down by (e.g., "storefront" for country, "platform" for device). Use discover_dimensions to see options.'
|
|
552
|
+
),
|
|
553
|
+
dimensionFilter: z3.string().optional().describe(
|
|
554
|
+
'Filter to a specific dimension value (e.g., "US" when dimension is "storefront")'
|
|
555
|
+
)
|
|
514
556
|
});
|
|
515
557
|
var discoverDimensionsSchema = z3.object({
|
|
516
558
|
assetId: z3.string().uuid().describe("App UUID"),
|
|
517
|
-
dimension: z3.string().optional().describe(
|
|
559
|
+
dimension: z3.string().optional().describe(
|
|
560
|
+
'If provided, returns the available values for this dimension (e.g., countries for "storefront")'
|
|
561
|
+
)
|
|
518
562
|
});
|
|
519
563
|
var METRIC_INFO = {
|
|
520
|
-
proceeds: {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
564
|
+
proceeds: {
|
|
565
|
+
displayName: "Net Revenue (after store cut)",
|
|
566
|
+
category: "Revenue",
|
|
567
|
+
type: "currency"
|
|
568
|
+
},
|
|
569
|
+
total_revenue: {
|
|
570
|
+
displayName: "Gross Revenue",
|
|
571
|
+
category: "Revenue",
|
|
572
|
+
type: "currency"
|
|
573
|
+
},
|
|
574
|
+
total_downloads: {
|
|
575
|
+
displayName: "Total Downloads",
|
|
576
|
+
category: "Downloads",
|
|
577
|
+
type: "count"
|
|
578
|
+
},
|
|
579
|
+
units: {
|
|
580
|
+
displayName: "First-time Downloads",
|
|
581
|
+
category: "Downloads",
|
|
582
|
+
type: "count"
|
|
583
|
+
},
|
|
584
|
+
redownloads: {
|
|
585
|
+
displayName: "Re-downloads",
|
|
586
|
+
category: "Downloads",
|
|
587
|
+
type: "count"
|
|
588
|
+
},
|
|
589
|
+
page_views: {
|
|
590
|
+
displayName: "App Store Page Views",
|
|
591
|
+
category: "Downloads",
|
|
592
|
+
type: "count"
|
|
593
|
+
},
|
|
594
|
+
impressions: {
|
|
595
|
+
displayName: "App Store Impressions",
|
|
596
|
+
category: "Downloads",
|
|
597
|
+
type: "count"
|
|
598
|
+
},
|
|
599
|
+
sessions: {
|
|
600
|
+
displayName: "App Sessions",
|
|
601
|
+
category: "Engagement",
|
|
602
|
+
type: "count"
|
|
603
|
+
},
|
|
604
|
+
active_devices: {
|
|
605
|
+
displayName: "Active Devices",
|
|
606
|
+
category: "Engagement",
|
|
607
|
+
type: "count"
|
|
608
|
+
},
|
|
529
609
|
crashes: { displayName: "Crashes", category: "Engagement", type: "count" },
|
|
530
|
-
paying_users: {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
610
|
+
paying_users: {
|
|
611
|
+
displayName: "Paying Users",
|
|
612
|
+
category: "Engagement",
|
|
613
|
+
type: "count"
|
|
614
|
+
},
|
|
615
|
+
active_subs: {
|
|
616
|
+
displayName: "Active Subscriptions",
|
|
617
|
+
category: "Subscriptions",
|
|
618
|
+
type: "count"
|
|
619
|
+
},
|
|
620
|
+
active_trials: {
|
|
621
|
+
displayName: "Active Trials",
|
|
622
|
+
category: "Subscriptions",
|
|
623
|
+
type: "count"
|
|
624
|
+
},
|
|
625
|
+
new_trials: {
|
|
626
|
+
displayName: "New Trials",
|
|
627
|
+
category: "Subscriptions",
|
|
628
|
+
type: "count"
|
|
629
|
+
},
|
|
630
|
+
trial_conversion_rate: {
|
|
631
|
+
displayName: "Trial Conversion Rate",
|
|
632
|
+
category: "Subscriptions",
|
|
633
|
+
type: "percentage"
|
|
634
|
+
},
|
|
635
|
+
subscription_retention_rate: {
|
|
636
|
+
displayName: "Subscription Retention Rate",
|
|
637
|
+
category: "Subscriptions",
|
|
638
|
+
type: "percentage"
|
|
639
|
+
},
|
|
640
|
+
products_sold: {
|
|
641
|
+
displayName: "Products Sold (IAP)",
|
|
642
|
+
category: "Revenue",
|
|
643
|
+
type: "count"
|
|
644
|
+
},
|
|
537
645
|
ad_spend: { displayName: "Ad Spend", category: "Ads", type: "currency" },
|
|
538
|
-
ad_impressions: {
|
|
646
|
+
ad_impressions: {
|
|
647
|
+
displayName: "Ad Impressions",
|
|
648
|
+
category: "Ads",
|
|
649
|
+
type: "count"
|
|
650
|
+
},
|
|
539
651
|
ad_taps: { displayName: "Ad Taps/Clicks", category: "Ads", type: "count" },
|
|
540
|
-
ad_installs: {
|
|
541
|
-
|
|
652
|
+
ad_installs: {
|
|
653
|
+
displayName: "Ad-attributed Installs",
|
|
654
|
+
category: "Ads",
|
|
655
|
+
type: "count"
|
|
656
|
+
},
|
|
657
|
+
ad_conversions: {
|
|
658
|
+
displayName: "Ad Conversions",
|
|
659
|
+
category: "Ads",
|
|
660
|
+
type: "count"
|
|
661
|
+
}
|
|
542
662
|
};
|
|
543
663
|
var DIMENSION_INFO = {
|
|
544
664
|
storefront: "Country",
|
|
@@ -572,28 +692,32 @@ async function discoverMetrics(input, client) {
|
|
|
572
692
|
});
|
|
573
693
|
const byCategory = {};
|
|
574
694
|
for (const m of enriched) {
|
|
575
|
-
|
|
576
|
-
byCategory[m.category] = [];
|
|
577
|
-
byCategory[m.category].push(m);
|
|
695
|
+
(byCategory[m.category] ??= []).push(m);
|
|
578
696
|
}
|
|
579
697
|
return {
|
|
580
|
-
content: [
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
698
|
+
content: [
|
|
699
|
+
{
|
|
700
|
+
type: "text",
|
|
701
|
+
text: formatAsJson({
|
|
702
|
+
assetId: input.assetId,
|
|
703
|
+
totalAvailable: availableMetrics.length,
|
|
704
|
+
metricsByCategory: byCategory,
|
|
705
|
+
dataGroups: metricGroups,
|
|
706
|
+
tip: 'Use the metric "name" field in get_metrics. You can query multiple metrics at once.'
|
|
707
|
+
})
|
|
708
|
+
}
|
|
709
|
+
]
|
|
590
710
|
};
|
|
591
711
|
} catch (error) {
|
|
592
|
-
return {
|
|
712
|
+
return {
|
|
713
|
+
content: [{ type: "text", text: formatError(error) }],
|
|
714
|
+
isError: true
|
|
715
|
+
};
|
|
593
716
|
}
|
|
594
717
|
}
|
|
595
718
|
async function getMetrics(input, client) {
|
|
596
719
|
try {
|
|
720
|
+
const granularity = input.granularity ?? "daily";
|
|
597
721
|
const endDate = input.endDate || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
598
722
|
const startDate = input.startDate || (() => {
|
|
599
723
|
const d = /* @__PURE__ */ new Date();
|
|
@@ -604,60 +728,53 @@ async function getMetrics(input, client) {
|
|
|
604
728
|
metrics: input.metrics.join(","),
|
|
605
729
|
fromDate: startDate,
|
|
606
730
|
toDate: endDate,
|
|
607
|
-
granularity
|
|
731
|
+
granularity
|
|
608
732
|
};
|
|
609
|
-
if (input.dimension)
|
|
610
|
-
params.dimension = input.dimension;
|
|
733
|
+
if (input.dimension) params.dimension = input.dimension;
|
|
611
734
|
if (input.dimensionFilter && input.dimension) {
|
|
612
735
|
params[`filter.${input.dimension}`] = input.dimensionFilter;
|
|
613
736
|
}
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
737
|
+
const path = `/api/assets/${input.assetId}/metrics/timeseries`;
|
|
738
|
+
const response = await client.get(path, params);
|
|
739
|
+
const summaryResponse = input.granularity === "daily" ? response : await client.get(path, {
|
|
740
|
+
...params,
|
|
741
|
+
granularity: "daily"
|
|
742
|
+
});
|
|
618
743
|
const data = response.data ?? {};
|
|
619
|
-
const changes =
|
|
744
|
+
const changes = summaryResponse.changes ?? {};
|
|
620
745
|
const meta = response.meta ?? {};
|
|
621
746
|
const summaries = {};
|
|
622
|
-
for (const [metricName,
|
|
623
|
-
|
|
624
|
-
if (!Array.isArray(points) || points.length === 0) {
|
|
625
|
-
summaries[metricName] = { total: 0, average: 0, min: 0, max: 0, dataPoints: 0 };
|
|
626
|
-
continue;
|
|
627
|
-
}
|
|
628
|
-
const values = points.map((p) => p.value);
|
|
629
|
-
const total = values.reduce((s, v) => s + v, 0);
|
|
630
|
-
summaries[metricName] = {
|
|
631
|
-
total: Math.round(total * 100) / 100,
|
|
632
|
-
average: Math.round(total / values.length * 100) / 100,
|
|
633
|
-
min: Math.min(...values),
|
|
634
|
-
max: Math.max(...values),
|
|
635
|
-
dataPoints: values.length
|
|
636
|
-
};
|
|
747
|
+
for (const [metricName, points] of Object.entries(data)) {
|
|
748
|
+
summaries[metricName] = summarize(points, changes[metricName]);
|
|
637
749
|
}
|
|
638
750
|
const info = METRIC_INFO;
|
|
639
751
|
return {
|
|
640
|
-
content: [
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
name
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
752
|
+
content: [
|
|
753
|
+
{
|
|
754
|
+
type: "text",
|
|
755
|
+
text: formatAsJson({
|
|
756
|
+
assetId: input.assetId,
|
|
757
|
+
dateRange: { start: startDate, end: endDate },
|
|
758
|
+
granularity,
|
|
759
|
+
dimension: input.dimension || null,
|
|
760
|
+
metrics: Object.keys(data).map((name) => ({
|
|
761
|
+
name,
|
|
762
|
+
displayName: info[name]?.displayName || name,
|
|
763
|
+
type: info[name]?.type || "count",
|
|
764
|
+
summary: summaries[name],
|
|
765
|
+
change: changes[name] || null
|
|
766
|
+
})),
|
|
767
|
+
timeseries: data,
|
|
768
|
+
meta
|
|
769
|
+
})
|
|
770
|
+
}
|
|
771
|
+
]
|
|
658
772
|
};
|
|
659
773
|
} catch (error) {
|
|
660
|
-
return {
|
|
774
|
+
return {
|
|
775
|
+
content: [{ type: "text", text: formatError(error) }],
|
|
776
|
+
isError: true
|
|
777
|
+
};
|
|
661
778
|
}
|
|
662
779
|
}
|
|
663
780
|
async function discoverDimensions(input, client) {
|
|
@@ -667,15 +784,17 @@ async function discoverDimensions(input, client) {
|
|
|
667
784
|
`/api/assets/${input.assetId}/metrics/dimensions/${input.dimension}/values`
|
|
668
785
|
);
|
|
669
786
|
return {
|
|
670
|
-
content: [
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
787
|
+
content: [
|
|
788
|
+
{
|
|
789
|
+
type: "text",
|
|
790
|
+
text: formatAsJson({
|
|
791
|
+
assetId: input.assetId,
|
|
792
|
+
dimension: input.dimension,
|
|
793
|
+
displayName: DIMENSION_INFO[input.dimension] || input.dimension,
|
|
794
|
+
values: response2.data ?? response2
|
|
795
|
+
})
|
|
796
|
+
}
|
|
797
|
+
]
|
|
679
798
|
};
|
|
680
799
|
}
|
|
681
800
|
const response = await client.get(`/api/assets/${input.assetId}/metrics/dimensions`);
|
|
@@ -688,17 +807,22 @@ async function discoverDimensions(input, client) {
|
|
|
688
807
|
return { name: id, displayName: dim.label ?? DIMENSION_INFO[id] ?? id };
|
|
689
808
|
});
|
|
690
809
|
return {
|
|
691
|
-
content: [
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
810
|
+
content: [
|
|
811
|
+
{
|
|
812
|
+
type: "text",
|
|
813
|
+
text: formatAsJson({
|
|
814
|
+
assetId: input.assetId,
|
|
815
|
+
dimensions: enriched,
|
|
816
|
+
tip: 'Use dimension name in get_metrics "dimension" param. Use discover_dimensions with a specific dimension to see available values.'
|
|
817
|
+
})
|
|
818
|
+
}
|
|
819
|
+
]
|
|
699
820
|
};
|
|
700
821
|
} catch (error) {
|
|
701
|
-
return {
|
|
822
|
+
return {
|
|
823
|
+
content: [{ type: "text", text: formatError(error) }],
|
|
824
|
+
isError: true
|
|
825
|
+
};
|
|
702
826
|
}
|
|
703
827
|
}
|
|
704
828
|
|
|
@@ -707,25 +831,10 @@ import { z as z4 } from "zod";
|
|
|
707
831
|
function asRecord(value) {
|
|
708
832
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
709
833
|
}
|
|
710
|
-
var AGENT_TYPES = [
|
|
711
|
-
"review",
|
|
712
|
-
"monitoring",
|
|
713
|
-
"forecasting",
|
|
714
|
-
"growth",
|
|
715
|
-
"aso",
|
|
716
|
-
"ads",
|
|
717
|
-
"product",
|
|
718
|
-
"submission_review"
|
|
719
|
-
];
|
|
834
|
+
var AGENT_TYPES = ["review", "aso"];
|
|
720
835
|
var AGENT_DESCRIPTIONS = {
|
|
721
836
|
review: "AI-powered review management \u2014 drafts and sends replies to app store reviews",
|
|
722
|
-
|
|
723
|
-
forecasting: "Revenue and metric forecasting \u2014 generates forward-looking projections",
|
|
724
|
-
growth: "Growth audit \u2014 analyzes app performance and provides growth scoring",
|
|
725
|
-
aso: "App Store Optimization \u2014 listing optimization suggestions for better visibility",
|
|
726
|
-
ads: "Ad campaign analysis \u2014 performance tracking and optimization recommendations",
|
|
727
|
-
product: "Product agent \u2014 automated app installation testing via BrowserStack",
|
|
728
|
-
submission_review: "Submission review \u2014 GitHub-based review workflow for app submissions"
|
|
837
|
+
aso: "App Store Optimization \u2014 listing optimization suggestions for better visibility"
|
|
729
838
|
};
|
|
730
839
|
var listAgentsSchema = z4.object({});
|
|
731
840
|
var getAgentDetailsSchema = z4.object({
|
|
@@ -738,23 +847,25 @@ var getAgentRunHistorySchema = z4.object({
|
|
|
738
847
|
limit: z4.number().int().min(1).max(100).default(20).describe("Maximum number of runs to return")
|
|
739
848
|
});
|
|
740
849
|
var triggerAgentRunSchema = z4.object({
|
|
741
|
-
agentId: z4.string().describe("The agent ID to trigger a run for"),
|
|
850
|
+
agentId: z4.string().describe("The agent ID to trigger a run for (the `id` from list_agents)"),
|
|
742
851
|
assetId: z4.string().uuid().optional().describe("Optional app UUID to run the agent against")
|
|
743
852
|
});
|
|
744
853
|
var pauseAgentSchema = z4.object({
|
|
745
|
-
agentId: z4.string().describe("The agent ID to pause")
|
|
854
|
+
agentId: z4.string().describe("The agent ID to pause (the `id` from list_agents)")
|
|
746
855
|
});
|
|
747
856
|
var resumeAgentSchema = z4.object({
|
|
748
|
-
agentId: z4.string().describe("The agent ID to resume")
|
|
857
|
+
agentId: z4.string().describe("The agent ID to resume (the `id` from list_agents)")
|
|
749
858
|
});
|
|
750
859
|
var getAgentActivitySchema = z4.object({
|
|
751
|
-
agentId: z4.string().describe("The agent ID to get activity for")
|
|
860
|
+
agentId: z4.string().describe("The agent ID to get activity for (the `id` from list_agents)")
|
|
752
861
|
});
|
|
753
862
|
async function listAgents(_input, client) {
|
|
754
863
|
try {
|
|
755
864
|
let apiAgents = null;
|
|
756
865
|
try {
|
|
757
|
-
const response = await client.get(
|
|
866
|
+
const response = await client.get(
|
|
867
|
+
"/api/agents"
|
|
868
|
+
);
|
|
758
869
|
apiAgents = Array.isArray(response) ? response : response.data ?? response.agents ?? null;
|
|
759
870
|
} catch {
|
|
760
871
|
}
|
|
@@ -803,8 +914,7 @@ async function getAgentDetails(input, client) {
|
|
|
803
914
|
try {
|
|
804
915
|
try {
|
|
805
916
|
const params = {};
|
|
806
|
-
if (input.assetId)
|
|
807
|
-
params.assetId = input.assetId;
|
|
917
|
+
if (input.assetId) params.assetId = input.assetId;
|
|
808
918
|
const response2 = await client.get(`/api/agents/by-type/${input.agentType}`, params);
|
|
809
919
|
if (response2.agent) {
|
|
810
920
|
return {
|
|
@@ -851,8 +961,7 @@ async function getAgentRunHistory(input, client) {
|
|
|
851
961
|
let agentId;
|
|
852
962
|
try {
|
|
853
963
|
const byTypeParams = {};
|
|
854
|
-
if (input.assetId)
|
|
855
|
-
byTypeParams.assetId = input.assetId;
|
|
964
|
+
if (input.assetId) byTypeParams.assetId = input.assetId;
|
|
856
965
|
const byType = await client.get(
|
|
857
966
|
`/api/agents/by-type/${input.agentType}`,
|
|
858
967
|
byTypeParams
|
|
@@ -1005,188 +1114,23 @@ async function getAgentActivity(input, client) {
|
|
|
1005
1114
|
}
|
|
1006
1115
|
}
|
|
1007
1116
|
|
|
1008
|
-
// src/tools/anomalies.ts
|
|
1009
|
-
import { z as z5 } from "zod";
|
|
1010
|
-
var getAnomaliesSchema = z5.object({
|
|
1011
|
-
assetId: z5.string().uuid().optional().describe("Filter anomalies by app UUID"),
|
|
1012
|
-
severity: z5.enum(["low", "medium", "high", "critical"]).optional().describe("Filter by severity level"),
|
|
1013
|
-
type: z5.enum(["surge", "decline"]).optional().describe("Filter by anomaly type"),
|
|
1014
|
-
status: z5.enum(["new", "viewed", "acknowledged", "dismissed"]).optional().describe("Filter by status"),
|
|
1015
|
-
metricName: z5.string().optional().describe('Filter by metric name (e.g., "proceeds", "units")'),
|
|
1016
|
-
fromDate: z5.string().optional().describe("Filter anomalies from this date (YYYY-MM-DD)"),
|
|
1017
|
-
toDate: z5.string().optional().describe("Filter anomalies until this date (YYYY-MM-DD)"),
|
|
1018
|
-
excludeDismissed: z5.boolean().default(true).describe("Exclude dismissed anomalies (default: true)"),
|
|
1019
|
-
limit: z5.number().int().min(1).max(100).default(50).describe("Maximum number of anomalies to return")
|
|
1020
|
-
});
|
|
1021
|
-
var getAnomalyDetailSchema = z5.object({
|
|
1022
|
-
id: z5.string().uuid().describe("The anomaly UUID to get details for")
|
|
1023
|
-
});
|
|
1024
|
-
var acknowledgeAnomalySchema = z5.object({
|
|
1025
|
-
id: z5.string().uuid().describe("The anomaly UUID to acknowledge")
|
|
1026
|
-
});
|
|
1027
|
-
var dismissAnomalySchema = z5.object({
|
|
1028
|
-
id: z5.string().uuid().describe("The anomaly UUID to dismiss")
|
|
1029
|
-
});
|
|
1030
|
-
async function getAnomalies(input, client) {
|
|
1031
|
-
try {
|
|
1032
|
-
const params = {
|
|
1033
|
-
limit: input.limit
|
|
1034
|
-
};
|
|
1035
|
-
if (input.assetId)
|
|
1036
|
-
params.assetId = input.assetId;
|
|
1037
|
-
if (input.severity)
|
|
1038
|
-
params.severity = input.severity;
|
|
1039
|
-
if (input.type)
|
|
1040
|
-
params.type = input.type;
|
|
1041
|
-
if (input.status)
|
|
1042
|
-
params.status = input.status;
|
|
1043
|
-
if (input.metricName)
|
|
1044
|
-
params.metricName = input.metricName;
|
|
1045
|
-
if (input.fromDate)
|
|
1046
|
-
params.fromDate = input.fromDate;
|
|
1047
|
-
if (input.toDate)
|
|
1048
|
-
params.toDate = input.toDate;
|
|
1049
|
-
const response = await client.get(
|
|
1050
|
-
"/api/anomalies",
|
|
1051
|
-
params
|
|
1052
|
-
);
|
|
1053
|
-
let anomalies = response.data ?? response.anomalies ?? [];
|
|
1054
|
-
if (input.excludeDismissed && !input.status) {
|
|
1055
|
-
anomalies = anomalies.filter((a) => a.status !== "dismissed");
|
|
1056
|
-
}
|
|
1057
|
-
return {
|
|
1058
|
-
content: [
|
|
1059
|
-
{
|
|
1060
|
-
type: "text",
|
|
1061
|
-
text: formatAsJson({
|
|
1062
|
-
total: anomalies.length,
|
|
1063
|
-
anomalies: anomalies.map((anomaly) => ({
|
|
1064
|
-
id: anomaly.id,
|
|
1065
|
-
assetId: anomaly.assetId,
|
|
1066
|
-
assetName: anomaly.assetName,
|
|
1067
|
-
assetIcon: anomaly.assetIcon,
|
|
1068
|
-
anomalyDate: anomaly.anomalyDate,
|
|
1069
|
-
metricName: anomaly.metricName,
|
|
1070
|
-
sourceType: anomaly.sourceType,
|
|
1071
|
-
type: anomaly.type,
|
|
1072
|
-
severity: anomaly.severity,
|
|
1073
|
-
actualValue: parseFloat(String(anomaly.actualValue || "0")),
|
|
1074
|
-
expectedValue: parseFloat(String(anomaly.expectedValue || "0")),
|
|
1075
|
-
deviationPercent: parseFloat(
|
|
1076
|
-
String(anomaly.deviationPercent || "0")
|
|
1077
|
-
),
|
|
1078
|
-
confidence: parseFloat(String(anomaly.confidence || "0")),
|
|
1079
|
-
explanation: anomaly.explanation,
|
|
1080
|
-
suggestedActions: anomaly.suggestedActions,
|
|
1081
|
-
status: anomaly.status,
|
|
1082
|
-
detectedAt: anomaly.detectedAt
|
|
1083
|
-
}))
|
|
1084
|
-
})
|
|
1085
|
-
}
|
|
1086
|
-
]
|
|
1087
|
-
};
|
|
1088
|
-
} catch (error) {
|
|
1089
|
-
return {
|
|
1090
|
-
content: [
|
|
1091
|
-
{
|
|
1092
|
-
type: "text",
|
|
1093
|
-
text: formatError(error)
|
|
1094
|
-
}
|
|
1095
|
-
],
|
|
1096
|
-
isError: true
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
async function getAnomalyDetail(input, client) {
|
|
1101
|
-
try {
|
|
1102
|
-
const response = await client.get(`/api/anomalies/${input.id}`);
|
|
1103
|
-
return {
|
|
1104
|
-
content: [
|
|
1105
|
-
{
|
|
1106
|
-
type: "text",
|
|
1107
|
-
text: formatAsJson(response)
|
|
1108
|
-
}
|
|
1109
|
-
]
|
|
1110
|
-
};
|
|
1111
|
-
} catch (error) {
|
|
1112
|
-
return {
|
|
1113
|
-
content: [
|
|
1114
|
-
{
|
|
1115
|
-
type: "text",
|
|
1116
|
-
text: formatError(error)
|
|
1117
|
-
}
|
|
1118
|
-
],
|
|
1119
|
-
isError: true
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
async function acknowledgeAnomaly(input, client) {
|
|
1124
|
-
try {
|
|
1125
|
-
const response = await client.patch(`/api/anomalies/${input.id}/acknowledge`);
|
|
1126
|
-
return {
|
|
1127
|
-
content: [
|
|
1128
|
-
{
|
|
1129
|
-
type: "text",
|
|
1130
|
-
text: formatAsJson(response)
|
|
1131
|
-
}
|
|
1132
|
-
]
|
|
1133
|
-
};
|
|
1134
|
-
} catch (error) {
|
|
1135
|
-
return {
|
|
1136
|
-
content: [
|
|
1137
|
-
{
|
|
1138
|
-
type: "text",
|
|
1139
|
-
text: formatError(error)
|
|
1140
|
-
}
|
|
1141
|
-
],
|
|
1142
|
-
isError: true
|
|
1143
|
-
};
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
async function dismissAnomaly(input, client) {
|
|
1147
|
-
try {
|
|
1148
|
-
const response = await client.patch(`/api/anomalies/${input.id}/dismiss`);
|
|
1149
|
-
return {
|
|
1150
|
-
content: [
|
|
1151
|
-
{
|
|
1152
|
-
type: "text",
|
|
1153
|
-
text: formatAsJson(response)
|
|
1154
|
-
}
|
|
1155
|
-
]
|
|
1156
|
-
};
|
|
1157
|
-
} catch (error) {
|
|
1158
|
-
return {
|
|
1159
|
-
content: [
|
|
1160
|
-
{
|
|
1161
|
-
type: "text",
|
|
1162
|
-
text: formatError(error)
|
|
1163
|
-
}
|
|
1164
|
-
],
|
|
1165
|
-
isError: true
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
1117
|
// src/tools/ads.ts
|
|
1171
|
-
import { z as
|
|
1172
|
-
var getAdsPerformanceSchema =
|
|
1173
|
-
assetId:
|
|
1174
|
-
platform:
|
|
1175
|
-
fromDate:
|
|
1176
|
-
toDate:
|
|
1177
|
-
limit:
|
|
1118
|
+
import { z as z5 } from "zod";
|
|
1119
|
+
var getAdsPerformanceSchema = z5.object({
|
|
1120
|
+
assetId: z5.string().uuid().optional().describe("Filter by app UUID"),
|
|
1121
|
+
platform: z5.enum(["apple_search_ads", "google_ads", "meta_ads", "tiktok_ads"]).optional().describe("Filter by ad platform"),
|
|
1122
|
+
fromDate: z5.string().optional().describe("Start date for performance data (YYYY-MM-DD)"),
|
|
1123
|
+
toDate: z5.string().optional().describe("End date for performance data (YYYY-MM-DD)"),
|
|
1124
|
+
limit: z5.number().int().min(1).max(100).default(50).describe("Maximum number of campaigns to return")
|
|
1178
1125
|
});
|
|
1179
1126
|
async function getAdsPerformance(input, client) {
|
|
1180
1127
|
try {
|
|
1181
1128
|
const params = {};
|
|
1182
|
-
if (input.assetId)
|
|
1183
|
-
|
|
1184
|
-
if (input.
|
|
1185
|
-
params.from = input.fromDate;
|
|
1186
|
-
if (input.toDate)
|
|
1187
|
-
params.to = input.toDate;
|
|
1129
|
+
if (input.assetId) params.assetId = input.assetId;
|
|
1130
|
+
if (input.fromDate) params.from = input.fromDate;
|
|
1131
|
+
if (input.toDate) params.to = input.toDate;
|
|
1188
1132
|
const response = await client.get(
|
|
1189
|
-
"/api/ads
|
|
1133
|
+
"/api/ads/campaigns",
|
|
1190
1134
|
params
|
|
1191
1135
|
);
|
|
1192
1136
|
let campaigns = response.data ?? response.campaigns ?? [];
|
|
@@ -1200,6 +1144,12 @@ async function getAdsPerformance(input, client) {
|
|
|
1200
1144
|
type: "text",
|
|
1201
1145
|
text: formatAsJson({
|
|
1202
1146
|
total: campaigns.length,
|
|
1147
|
+
// The server couldn't read the metrics: null spend is unknown,
|
|
1148
|
+
// never "no spend".
|
|
1149
|
+
...response.metricsUnavailable ? {
|
|
1150
|
+
metricsUnavailable: true,
|
|
1151
|
+
note: "The ads metrics could not be read right now, so spend, impressions, taps and installs are unknown (null), not zero. Try again later."
|
|
1152
|
+
} : {},
|
|
1203
1153
|
campaigns: campaigns.map((campaign) => ({
|
|
1204
1154
|
id: campaign.id,
|
|
1205
1155
|
assetId: campaign.assetId,
|
|
@@ -1236,114 +1186,19 @@ async function getAdsPerformance(input, client) {
|
|
|
1236
1186
|
}
|
|
1237
1187
|
}
|
|
1238
1188
|
|
|
1239
|
-
// src/tools/growth.ts
|
|
1240
|
-
import { z as z7 } from "zod";
|
|
1241
|
-
var getGrowthAuditSchema = z7.object({
|
|
1242
|
-
assetId: z7.string().uuid().describe("App UUID to audit")
|
|
1243
|
-
});
|
|
1244
|
-
var getGrowthScoreSchema = z7.object({
|
|
1245
|
-
assetId: z7.string().uuid().describe("App UUID to score")
|
|
1246
|
-
});
|
|
1247
|
-
async function getGrowthAudit(input, client) {
|
|
1248
|
-
try {
|
|
1249
|
-
const response = await client.get(`/api/growth/audit/${input.assetId}`);
|
|
1250
|
-
return {
|
|
1251
|
-
content: [
|
|
1252
|
-
{
|
|
1253
|
-
type: "text",
|
|
1254
|
-
text: formatAsJson(response.data || response)
|
|
1255
|
-
}
|
|
1256
|
-
]
|
|
1257
|
-
};
|
|
1258
|
-
} catch (error) {
|
|
1259
|
-
return {
|
|
1260
|
-
content: [
|
|
1261
|
-
{
|
|
1262
|
-
type: "text",
|
|
1263
|
-
text: formatError(error)
|
|
1264
|
-
}
|
|
1265
|
-
],
|
|
1266
|
-
isError: true
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
async function getGrowthScore(input, client) {
|
|
1271
|
-
try {
|
|
1272
|
-
const response = await client.get(`/api/growth/score/${input.assetId}`);
|
|
1273
|
-
return {
|
|
1274
|
-
content: [
|
|
1275
|
-
{
|
|
1276
|
-
type: "text",
|
|
1277
|
-
text: formatAsJson(response.data || response)
|
|
1278
|
-
}
|
|
1279
|
-
]
|
|
1280
|
-
};
|
|
1281
|
-
} catch (error) {
|
|
1282
|
-
return {
|
|
1283
|
-
content: [
|
|
1284
|
-
{
|
|
1285
|
-
type: "text",
|
|
1286
|
-
text: formatError(error)
|
|
1287
|
-
}
|
|
1288
|
-
],
|
|
1289
|
-
isError: true
|
|
1290
|
-
};
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
// src/tools/forecasting.ts
|
|
1295
|
-
import { z as z8 } from "zod";
|
|
1296
|
-
var getForecastsSchema = z8.object({
|
|
1297
|
-
assetId: z8.string().uuid().describe("App UUID to get forecasts for"),
|
|
1298
|
-
metric: z8.enum(["proceeds", "total_revenue", "total_downloads", "active_subs", "new_trials"]).describe("The metric to forecast"),
|
|
1299
|
-
forecastWeeks: z8.number().int().min(4).max(156).optional().describe("Weeks to forecast forward (default 104)"),
|
|
1300
|
-
historicalWeeks: z8.number().int().min(12).max(156).optional().describe("Weeks of history to base the forecast on (default 104)")
|
|
1301
|
-
});
|
|
1302
|
-
async function getForecasts(input, client) {
|
|
1303
|
-
try {
|
|
1304
|
-
const response = await client.get("/api/forecasting/forecast", {
|
|
1305
|
-
assetId: input.assetId,
|
|
1306
|
-
metricName: input.metric,
|
|
1307
|
-
forecastWeeks: input.forecastWeeks,
|
|
1308
|
-
historicalWeeks: input.historicalWeeks
|
|
1309
|
-
});
|
|
1310
|
-
return {
|
|
1311
|
-
content: [
|
|
1312
|
-
{
|
|
1313
|
-
type: "text",
|
|
1314
|
-
text: formatAsJson(response.data || response)
|
|
1315
|
-
}
|
|
1316
|
-
]
|
|
1317
|
-
};
|
|
1318
|
-
} catch (error) {
|
|
1319
|
-
return {
|
|
1320
|
-
content: [
|
|
1321
|
-
{
|
|
1322
|
-
type: "text",
|
|
1323
|
-
text: formatError(error)
|
|
1324
|
-
}
|
|
1325
|
-
],
|
|
1326
|
-
isError: true
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
1189
|
// src/tools/dashboard.ts
|
|
1332
|
-
import { z as
|
|
1190
|
+
import { z as z6 } from "zod";
|
|
1333
1191
|
function parseDashboardNumber(value) {
|
|
1334
|
-
if (value === null || value === void 0 || value === "")
|
|
1335
|
-
return null;
|
|
1192
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
1336
1193
|
const parsed = typeof value === "number" ? value : Number.parseFloat(value);
|
|
1337
1194
|
return Number.isFinite(parsed) ? parsed : null;
|
|
1338
1195
|
}
|
|
1339
1196
|
function getSidebarAssets(response) {
|
|
1340
|
-
if (!response)
|
|
1341
|
-
|
|
1342
|
-
if (Array.isArray(response))
|
|
1343
|
-
return response;
|
|
1197
|
+
if (!response) return [];
|
|
1198
|
+
if (Array.isArray(response)) return response;
|
|
1344
1199
|
return response.data ?? [];
|
|
1345
1200
|
}
|
|
1346
|
-
var getDashboardOverviewSchema =
|
|
1201
|
+
var getDashboardOverviewSchema = z6.object({});
|
|
1347
1202
|
async function getDashboardOverview(_input, client) {
|
|
1348
1203
|
try {
|
|
1349
1204
|
const overviewPromise = client.get("/api/dashboard/overview-metrics").catch(() => null);
|
|
@@ -1398,152 +1253,317 @@ async function getDashboardOverview(_input, client) {
|
|
|
1398
1253
|
}
|
|
1399
1254
|
|
|
1400
1255
|
// src/tools/actions.ts
|
|
1401
|
-
import {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1256
|
+
import { randomUUID } from "node:crypto";
|
|
1257
|
+
import { z as z7 } from "zod";
|
|
1258
|
+
var listPendingActionsSchema = z7.object({
|
|
1259
|
+
assetId: z7.string().uuid().optional().describe("Filter by app UUID"),
|
|
1260
|
+
view: z7.enum(["open", "queued"]).default("open").describe(
|
|
1261
|
+
"open (default): items waiting on the user. queued: approved work Fload is sending or checking in the store (an item being checked offers check_now)."
|
|
1262
|
+
),
|
|
1263
|
+
limit: z7.number().int().min(1).max(100).default(50).describe("Maximum number of actions to return")
|
|
1408
1264
|
});
|
|
1409
|
-
var approveActionSchema =
|
|
1410
|
-
actionId:
|
|
1265
|
+
var approveActionSchema = z7.object({
|
|
1266
|
+
actionId: z7.string().describe("The inbox item ID to approve (from list_pending_actions)")
|
|
1411
1267
|
});
|
|
1412
|
-
var rejectActionSchema =
|
|
1413
|
-
actionId:
|
|
1268
|
+
var rejectActionSchema = z7.object({
|
|
1269
|
+
actionId: z7.string().describe("The inbox item ID to reject (from list_pending_actions)"),
|
|
1270
|
+
reason: z7.string().trim().min(1).max(1e3).optional().describe(
|
|
1271
|
+
"Why, in the user's words. Kept with the rejection so the agents do not propose the same thing again."
|
|
1272
|
+
)
|
|
1414
1273
|
});
|
|
1274
|
+
var checkActionNowSchema = z7.object({
|
|
1275
|
+
actionId: z7.string().describe(
|
|
1276
|
+
'The inbox item ID to check now (from list_pending_actions with view "queued", or an approve_action result; its commands include check_now)'
|
|
1277
|
+
)
|
|
1278
|
+
});
|
|
1279
|
+
var renameCustomPageActionSchema = z7.object({
|
|
1280
|
+
actionId: z7.string().describe(
|
|
1281
|
+
'The inbox item ID of the "Create custom product page" request (from list_pending_actions; it failed because App Store Connect already has a page of that name, or it waits for approval)'
|
|
1282
|
+
),
|
|
1283
|
+
name: z7.string().trim().min(1).max(100).describe(
|
|
1284
|
+
"The new page name: at most 100 characters (UTF-16 units), not its current name, not a page the app already has"
|
|
1285
|
+
)
|
|
1286
|
+
});
|
|
1287
|
+
function commandFor(kind, intent) {
|
|
1288
|
+
if (kind === "notice")
|
|
1289
|
+
return intent === "approve" ? "acknowledge" : "dismiss";
|
|
1290
|
+
return intent;
|
|
1291
|
+
}
|
|
1292
|
+
function toolText(payload, isError = false) {
|
|
1293
|
+
return {
|
|
1294
|
+
content: [{ type: "text", text: formatAsJson(payload) }],
|
|
1295
|
+
...isError ? { isError: true } : {}
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
function toolError(error) {
|
|
1299
|
+
return {
|
|
1300
|
+
content: [{ type: "text", text: formatError(error) }],
|
|
1301
|
+
isError: true
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1415
1304
|
async function listPendingActions(input, client) {
|
|
1416
1305
|
try {
|
|
1417
|
-
const params = {
|
|
1418
|
-
limit: input.limit
|
|
1419
|
-
};
|
|
1420
1306
|
const response = await client.get(
|
|
1421
|
-
"/api/
|
|
1422
|
-
|
|
1307
|
+
"/api/actions/items",
|
|
1308
|
+
{ view: input.view ?? "open", assetId: input.assetId, limit: input.limit }
|
|
1423
1309
|
);
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
)
|
|
1429
|
-
}
|
|
1430
|
-
return {
|
|
1431
|
-
content: [
|
|
1432
|
-
{
|
|
1433
|
-
type: "text",
|
|
1434
|
-
text: formatAsJson({
|
|
1435
|
-
total: actions.length,
|
|
1436
|
-
actions
|
|
1437
|
-
})
|
|
1438
|
-
}
|
|
1439
|
-
]
|
|
1440
|
-
};
|
|
1310
|
+
const actions = response.items ?? [];
|
|
1311
|
+
return toolText({
|
|
1312
|
+
total: actions.length,
|
|
1313
|
+
actions,
|
|
1314
|
+
hasMore: Boolean(response.nextCursor)
|
|
1315
|
+
});
|
|
1441
1316
|
} catch (error) {
|
|
1442
|
-
return
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1317
|
+
return toolError(error);
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
async function commandItem(client, itemId, intent, reason) {
|
|
1321
|
+
const detail = await client.get(
|
|
1322
|
+
`/api/actions/items/${encodeURIComponent(itemId)}`
|
|
1323
|
+
);
|
|
1324
|
+
const item = detail.item;
|
|
1325
|
+
if (!item) throw new Error("Action not found");
|
|
1326
|
+
const command = commandFor(item.kind, intent);
|
|
1327
|
+
const answer = await client.postForAnswer(
|
|
1328
|
+
"/api/actions/commands",
|
|
1329
|
+
{
|
|
1330
|
+
command,
|
|
1331
|
+
idempotencyKey: `mcp:${command}:${item.id}:${randomUUID()}`,
|
|
1332
|
+
targets: [
|
|
1333
|
+
{
|
|
1334
|
+
itemId: item.id,
|
|
1335
|
+
...command === "approve" && item.currentRevisionId ? { revisionId: item.currentRevisionId } : {}
|
|
1447
1336
|
}
|
|
1448
1337
|
],
|
|
1449
|
-
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1338
|
+
...command === "reject" && reason ? { reason } : {}
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
const result = answer.body?.results?.[0];
|
|
1342
|
+
if (!result)
|
|
1343
|
+
throw new Error(
|
|
1344
|
+
answer.ok ? "Fload returned no result for the command." : "Fload rejected the request. Please check access and try again."
|
|
1345
|
+
);
|
|
1346
|
+
return {
|
|
1347
|
+
command,
|
|
1348
|
+
result: {
|
|
1349
|
+
...result,
|
|
1350
|
+
error: result.error ? publicMcpErrorMessage(
|
|
1351
|
+
result.error,
|
|
1352
|
+
"Fload could not apply this change."
|
|
1353
|
+
) : void 0
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1452
1356
|
}
|
|
1453
1357
|
async function approveAction(input, client) {
|
|
1454
1358
|
try {
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1457
|
-
|
|
1359
|
+
const { command, result } = await commandItem(
|
|
1360
|
+
client,
|
|
1361
|
+
input.actionId,
|
|
1362
|
+
"approve"
|
|
1363
|
+
);
|
|
1364
|
+
const applied2 = result?.result === "applied" || result?.result === "replayed";
|
|
1365
|
+
return toolText(
|
|
1366
|
+
{
|
|
1367
|
+
success: applied2,
|
|
1368
|
+
actionId: input.actionId,
|
|
1369
|
+
command,
|
|
1370
|
+
result: result?.result ?? "unknown",
|
|
1371
|
+
...result?.error ? { error: result.error } : {},
|
|
1372
|
+
message: applied2 ? command === "acknowledge" ? "Acknowledged." : "Approved. Fload delivers it after a short undo window; the inbox shows where it is." : result?.error ?? "The approval could not be recorded.",
|
|
1373
|
+
item: result?.item
|
|
1374
|
+
},
|
|
1375
|
+
!applied2
|
|
1458
1376
|
);
|
|
1459
|
-
return {
|
|
1460
|
-
content: [
|
|
1461
|
-
{
|
|
1462
|
-
type: "text",
|
|
1463
|
-
text: formatAsJson({
|
|
1464
|
-
success: true,
|
|
1465
|
-
actionId: input.actionId,
|
|
1466
|
-
status: "approved",
|
|
1467
|
-
message: "Reply has been approved and queued for sending",
|
|
1468
|
-
...asRecord2(response.data)
|
|
1469
|
-
})
|
|
1470
|
-
}
|
|
1471
|
-
]
|
|
1472
|
-
};
|
|
1473
1377
|
} catch (error) {
|
|
1474
|
-
return
|
|
1475
|
-
content: [
|
|
1476
|
-
{
|
|
1477
|
-
type: "text",
|
|
1478
|
-
text: formatError(error)
|
|
1479
|
-
}
|
|
1480
|
-
],
|
|
1481
|
-
isError: true
|
|
1482
|
-
};
|
|
1378
|
+
return toolError(error);
|
|
1483
1379
|
}
|
|
1484
1380
|
}
|
|
1485
1381
|
async function rejectAction(input, client) {
|
|
1486
1382
|
try {
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1383
|
+
const { command, result } = await commandItem(
|
|
1384
|
+
client,
|
|
1385
|
+
input.actionId,
|
|
1386
|
+
"reject",
|
|
1387
|
+
input.reason
|
|
1388
|
+
);
|
|
1389
|
+
const applied2 = result?.result === "applied" || result?.result === "replayed";
|
|
1390
|
+
return toolText(
|
|
1391
|
+
{
|
|
1392
|
+
success: applied2,
|
|
1393
|
+
actionId: input.actionId,
|
|
1394
|
+
command,
|
|
1395
|
+
result: result?.result ?? "unknown",
|
|
1396
|
+
...result?.error ? { error: result.error } : {},
|
|
1397
|
+
message: applied2 ? command === "dismiss" ? "Dismissed." : "Rejected. Nothing was sent." : result?.error ?? "The rejection could not be recorded.",
|
|
1398
|
+
item: result?.item
|
|
1399
|
+
},
|
|
1400
|
+
!applied2
|
|
1489
1401
|
);
|
|
1490
|
-
return {
|
|
1491
|
-
content: [
|
|
1492
|
-
{
|
|
1493
|
-
type: "text",
|
|
1494
|
-
text: formatAsJson({
|
|
1495
|
-
success: true,
|
|
1496
|
-
actionId: input.actionId,
|
|
1497
|
-
status: "rejected",
|
|
1498
|
-
message: "Draft reply has been rejected and removed",
|
|
1499
|
-
...asRecord2(response.data)
|
|
1500
|
-
})
|
|
1501
|
-
}
|
|
1502
|
-
]
|
|
1503
|
-
};
|
|
1504
1402
|
} catch (error) {
|
|
1505
|
-
return
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1403
|
+
return toolError(error);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
async function checkActionNow(input, client) {
|
|
1407
|
+
try {
|
|
1408
|
+
const answer = await client.postForAnswer(
|
|
1409
|
+
"/api/actions/commands",
|
|
1410
|
+
{
|
|
1411
|
+
command: "check_now",
|
|
1412
|
+
idempotencyKey: `mcp:check_now:${input.actionId}:${randomUUID()}`,
|
|
1413
|
+
targets: [{ itemId: input.actionId }]
|
|
1414
|
+
}
|
|
1415
|
+
);
|
|
1416
|
+
const result = answer.body?.results?.[0];
|
|
1417
|
+
const applied2 = result?.result === "applied" || result?.result === "replayed";
|
|
1418
|
+
const error = result?.error ? publicMcpErrorMessage(result.error, "Fload could not check it now.") : void 0;
|
|
1419
|
+
return toolText(
|
|
1420
|
+
{
|
|
1421
|
+
success: applied2,
|
|
1422
|
+
actionId: input.actionId,
|
|
1423
|
+
command: "check_now",
|
|
1424
|
+
result: result?.result ?? "unknown",
|
|
1425
|
+
...error ? { error } : {},
|
|
1426
|
+
message: applied2 ? "Fload is checking the store now; the item updates as soon as the store shows the change." : error ?? (answer.ok ? "Fload returned no result for the command." : "Fload rejected the request. Please check access and try again."),
|
|
1427
|
+
item: result?.item
|
|
1428
|
+
},
|
|
1429
|
+
!applied2
|
|
1430
|
+
);
|
|
1431
|
+
} catch (error) {
|
|
1432
|
+
return toolError(error);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
var applied = (result) => result?.result === "applied" || result?.result === "replayed";
|
|
1436
|
+
async function sendItemCommand(client, body) {
|
|
1437
|
+
const { command, itemId, revisionId, ...extra } = body;
|
|
1438
|
+
const answer = await client.postForAnswer(
|
|
1439
|
+
"/api/actions/commands",
|
|
1440
|
+
{
|
|
1441
|
+
command,
|
|
1442
|
+
idempotencyKey: `mcp:${command}:${itemId}:${randomUUID()}`,
|
|
1443
|
+
targets: [{ itemId, ...revisionId ? { revisionId } : {} }],
|
|
1444
|
+
...extra
|
|
1445
|
+
}
|
|
1446
|
+
);
|
|
1447
|
+
const result = answer.body?.results?.[0];
|
|
1448
|
+
if (applied(result)) return { result, refusal: null };
|
|
1449
|
+
const said = result?.error ?? answer.body?.message;
|
|
1450
|
+
return {
|
|
1451
|
+
result,
|
|
1452
|
+
refusal: publicMcpErrorMessage(
|
|
1453
|
+
said,
|
|
1454
|
+
answer.ok ? "Fload returned no result for the command." : "Fload rejected the request. Please check access and try again."
|
|
1455
|
+
)
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
function renameAnswer(input, outcome, item) {
|
|
1459
|
+
const success = outcome.renamed && outcome.approved;
|
|
1460
|
+
return toolText(
|
|
1461
|
+
{
|
|
1462
|
+
success,
|
|
1463
|
+
actionId: input.actionId,
|
|
1464
|
+
...outcome,
|
|
1465
|
+
...item === void 0 ? {} : { item }
|
|
1466
|
+
},
|
|
1467
|
+
!success
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1470
|
+
async function renameCustomPageAction(input, client) {
|
|
1471
|
+
try {
|
|
1472
|
+
const name = input.name.trim();
|
|
1473
|
+
const detail = await client.get(
|
|
1474
|
+
`/api/actions/items/${encodeURIComponent(input.actionId)}`
|
|
1475
|
+
);
|
|
1476
|
+
const item = detail.item;
|
|
1477
|
+
if (!item || item.kind !== "asc_custom_product_page" || !item.subjectKey?.startsWith("asc-cpp:"))
|
|
1478
|
+
return renameAnswer(input, {
|
|
1479
|
+
renamed: false,
|
|
1480
|
+
approved: false,
|
|
1481
|
+
message: "This item is not a request to create a custom product page."
|
|
1482
|
+
});
|
|
1483
|
+
const edit = await sendItemCommand(client, {
|
|
1484
|
+
command: "edit",
|
|
1485
|
+
itemId: item.id,
|
|
1486
|
+
revisionId: item.currentRevisionId,
|
|
1487
|
+
pageName: name
|
|
1488
|
+
});
|
|
1489
|
+
if (edit.refusal)
|
|
1490
|
+
return renameAnswer(input, {
|
|
1491
|
+
renamed: false,
|
|
1492
|
+
approved: false,
|
|
1493
|
+
message: edit.refusal
|
|
1494
|
+
});
|
|
1495
|
+
const renamed = edit.result?.item;
|
|
1496
|
+
const approve = await sendItemCommand(client, {
|
|
1497
|
+
command: "approve",
|
|
1498
|
+
itemId: item.id,
|
|
1499
|
+
revisionId: renamed?.currentRevisionId ?? null
|
|
1500
|
+
});
|
|
1501
|
+
return renameAnswer(
|
|
1502
|
+
input,
|
|
1503
|
+
approve.refusal ? {
|
|
1504
|
+
renamed: true,
|
|
1505
|
+
approved: false,
|
|
1506
|
+
// The server's own refusal, as it said it.
|
|
1507
|
+
message: approve.refusal,
|
|
1508
|
+
next: `The page is renamed to \u201C${name}\u201D and waits for approval (approve_action).`
|
|
1509
|
+
} : {
|
|
1510
|
+
renamed: true,
|
|
1511
|
+
approved: true,
|
|
1512
|
+
message: `Renamed to \u201C${name}\u201D and approved. Fload creates the page after a short undo window; the inbox shows where it is.`
|
|
1513
|
+
},
|
|
1514
|
+
approve.result?.item ?? renamed
|
|
1515
|
+
);
|
|
1516
|
+
} catch (error) {
|
|
1517
|
+
return toolError(error);
|
|
1514
1518
|
}
|
|
1515
1519
|
}
|
|
1516
1520
|
|
|
1517
1521
|
// src/tools/aso.ts
|
|
1518
|
-
import { z as
|
|
1519
|
-
var getAsoSummarySchema =
|
|
1520
|
-
assetId:
|
|
1522
|
+
import { z as z8 } from "zod";
|
|
1523
|
+
var getAsoSummarySchema = z8.object({
|
|
1524
|
+
assetId: z8.string().uuid().describe("App UUID to get ASO summary for")
|
|
1521
1525
|
});
|
|
1522
|
-
var getAsoRecommendationsSchema =
|
|
1523
|
-
assetId:
|
|
1526
|
+
var getAsoRecommendationsSchema = z8.object({
|
|
1527
|
+
assetId: z8.string().uuid().describe("App UUID to get ASO recommendations for")
|
|
1524
1528
|
});
|
|
1525
|
-
var getAsoKeywordsSchema =
|
|
1526
|
-
assetId:
|
|
1527
|
-
locale:
|
|
1529
|
+
var getAsoKeywordsSchema = z8.object({
|
|
1530
|
+
assetId: z8.string().uuid().describe("App UUID to get keyword intelligence for"),
|
|
1531
|
+
locale: z8.string().optional().describe(
|
|
1532
|
+
'Locale code to filter keywords (e.g., "en-US", "de-DE"). Returns all locales if omitted.'
|
|
1533
|
+
)
|
|
1528
1534
|
});
|
|
1529
|
-
var getAsoExperimentsSchema =
|
|
1530
|
-
assetId:
|
|
1531
|
-
status:
|
|
1532
|
-
|
|
1533
|
-
|
|
1535
|
+
var getAsoExperimentsSchema = z8.object({
|
|
1536
|
+
assetId: z8.string().uuid().describe("App UUID to list ASO experiments for"),
|
|
1537
|
+
status: z8.enum([
|
|
1538
|
+
"proposed",
|
|
1539
|
+
"approved",
|
|
1540
|
+
"applied",
|
|
1541
|
+
"measuring",
|
|
1542
|
+
"completed",
|
|
1543
|
+
"reverted"
|
|
1544
|
+
]).optional().describe("Filter experiments by status"),
|
|
1545
|
+
limit: z8.number().int().min(1).max(100).default(20).describe("Maximum number of experiments to return"),
|
|
1546
|
+
cursor: z8.string().optional().describe("Pagination cursor from a previous response (meta.nextCursor)")
|
|
1534
1547
|
});
|
|
1535
|
-
var getAsoLocaleSnapshotsSchema =
|
|
1536
|
-
assetId:
|
|
1537
|
-
store:
|
|
1538
|
-
locale:
|
|
1539
|
-
|
|
1548
|
+
var getAsoLocaleSnapshotsSchema = z8.object({
|
|
1549
|
+
assetId: z8.string().uuid().describe("App UUID to get locale snapshots for"),
|
|
1550
|
+
store: z8.enum(["ios", "android"]).default("ios").describe("Which store listing to read"),
|
|
1551
|
+
locale: z8.string().optional().describe(
|
|
1552
|
+
'Filter to a single locale (e.g. "en-US"). Returns all locales if omitted.'
|
|
1553
|
+
),
|
|
1554
|
+
view: z8.enum(["latest", "history"]).default("latest").describe(
|
|
1555
|
+
'"latest" (default) = newest snapshot per (locale, type); "history" = raw revisions newest first'
|
|
1556
|
+
),
|
|
1557
|
+
limit: z8.number().int().min(1).max(500).optional().describe("Maximum snapshot rows to return (newest first)")
|
|
1540
1558
|
});
|
|
1541
|
-
var triggerAsoAnalysisSchema =
|
|
1542
|
-
assetId:
|
|
1559
|
+
var triggerAsoAnalysisSchema = z8.object({
|
|
1560
|
+
assetId: z8.string().uuid().describe("App UUID to trigger ASO analysis for")
|
|
1543
1561
|
});
|
|
1544
1562
|
async function getAsoSummary(input, client) {
|
|
1545
1563
|
try {
|
|
1546
|
-
const response = await client.get(
|
|
1564
|
+
const response = await client.get(
|
|
1565
|
+
`/api/assets/${input.assetId}/aso/summary`
|
|
1566
|
+
);
|
|
1547
1567
|
return {
|
|
1548
1568
|
content: [
|
|
1549
1569
|
{
|
|
@@ -1566,7 +1586,9 @@ async function getAsoSummary(input, client) {
|
|
|
1566
1586
|
}
|
|
1567
1587
|
async function getAsoRecommendations(input, client) {
|
|
1568
1588
|
try {
|
|
1569
|
-
const response = await client.get(
|
|
1589
|
+
const response = await client.get(
|
|
1590
|
+
`/api/assets/${input.assetId}/aso/recommendations`
|
|
1591
|
+
);
|
|
1570
1592
|
return {
|
|
1571
1593
|
content: [
|
|
1572
1594
|
{
|
|
@@ -1590,9 +1612,11 @@ async function getAsoRecommendations(input, client) {
|
|
|
1590
1612
|
async function getAsoKeywords(input, client) {
|
|
1591
1613
|
try {
|
|
1592
1614
|
const params = {};
|
|
1593
|
-
if (input.locale)
|
|
1594
|
-
|
|
1595
|
-
|
|
1615
|
+
if (input.locale) params.locale = input.locale;
|
|
1616
|
+
const response = await client.get(
|
|
1617
|
+
`/api/assets/${input.assetId}/aso/keyword-intelligence`,
|
|
1618
|
+
params
|
|
1619
|
+
);
|
|
1596
1620
|
return {
|
|
1597
1621
|
content: [
|
|
1598
1622
|
{
|
|
@@ -1619,9 +1643,11 @@ async function getAsoExperiments(input, client) {
|
|
|
1619
1643
|
limit: input.limit,
|
|
1620
1644
|
cursor: input.cursor
|
|
1621
1645
|
};
|
|
1622
|
-
if (input.status)
|
|
1623
|
-
|
|
1624
|
-
|
|
1646
|
+
if (input.status) params.status = input.status;
|
|
1647
|
+
const response = await client.get(
|
|
1648
|
+
`/api/assets/${input.assetId}/aso/experiments`,
|
|
1649
|
+
params
|
|
1650
|
+
);
|
|
1625
1651
|
return {
|
|
1626
1652
|
content: [
|
|
1627
1653
|
{
|
|
@@ -1649,6 +1675,7 @@ async function getAsoLocaleSnapshots(input, client) {
|
|
|
1649
1675
|
{
|
|
1650
1676
|
store: input.store,
|
|
1651
1677
|
locale: input.locale,
|
|
1678
|
+
view: input.view,
|
|
1652
1679
|
limit: input.limit
|
|
1653
1680
|
}
|
|
1654
1681
|
);
|
|
@@ -1698,20 +1725,40 @@ async function triggerAsoAnalysis(input, client) {
|
|
|
1698
1725
|
};
|
|
1699
1726
|
}
|
|
1700
1727
|
}
|
|
1728
|
+
var getAsoEvidenceSchema = z8.object({ assetId: z8.string().uuid() });
|
|
1729
|
+
async function getAsoEvidence(input, client) {
|
|
1730
|
+
try {
|
|
1731
|
+
const response = await client.get(
|
|
1732
|
+
`/api/assets/${input.assetId}/aso/methodology`
|
|
1733
|
+
);
|
|
1734
|
+
return {
|
|
1735
|
+
content: [{ type: "text", text: formatAsJson(response) }]
|
|
1736
|
+
};
|
|
1737
|
+
} catch (error) {
|
|
1738
|
+
return {
|
|
1739
|
+
content: [{ type: "text", text: formatError(error) }],
|
|
1740
|
+
isError: true
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1701
1744
|
|
|
1702
1745
|
// src/tools/chat.ts
|
|
1703
|
-
import { randomUUID } from "node:crypto";
|
|
1704
|
-
import { z as
|
|
1705
|
-
var listConversationsSchema =
|
|
1706
|
-
limit:
|
|
1746
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1747
|
+
import { z as z9 } from "zod";
|
|
1748
|
+
var listConversationsSchema = z9.object({
|
|
1749
|
+
limit: z9.number().int().min(1).max(100).default(20).describe("Maximum number of conversations to return")
|
|
1707
1750
|
});
|
|
1708
|
-
var getConversationMessagesSchema =
|
|
1709
|
-
conversationId:
|
|
1751
|
+
var getConversationMessagesSchema = z9.object({
|
|
1752
|
+
conversationId: z9.string().uuid().describe("The conversation UUID to get messages for")
|
|
1710
1753
|
});
|
|
1711
|
-
var sendChatMessageSchema =
|
|
1712
|
-
message:
|
|
1713
|
-
conversationId:
|
|
1714
|
-
|
|
1754
|
+
var sendChatMessageSchema = z9.object({
|
|
1755
|
+
message: z9.string().describe("The message to send to the AI chat"),
|
|
1756
|
+
conversationId: z9.string().uuid().optional().describe(
|
|
1757
|
+
"Existing conversation UUID to continue. Starts a new conversation if omitted."
|
|
1758
|
+
),
|
|
1759
|
+
agentType: z9.string().optional().describe(
|
|
1760
|
+
"Agent type to use for the conversation (e.g., review, monitoring)"
|
|
1761
|
+
)
|
|
1715
1762
|
});
|
|
1716
1763
|
async function listConversations(input, client) {
|
|
1717
1764
|
try {
|
|
@@ -1744,7 +1791,9 @@ async function listConversations(input, client) {
|
|
|
1744
1791
|
}
|
|
1745
1792
|
async function getConversationMessages(input, client) {
|
|
1746
1793
|
try {
|
|
1747
|
-
const response = await client.get(
|
|
1794
|
+
const response = await client.get(
|
|
1795
|
+
`/api/chat/messages/${input.conversationId}`
|
|
1796
|
+
);
|
|
1748
1797
|
const messages = response.data || response.messages || response;
|
|
1749
1798
|
return {
|
|
1750
1799
|
content: [
|
|
@@ -1774,11 +1823,9 @@ function parseUiMessageStream(raw) {
|
|
|
1774
1823
|
let reply = "";
|
|
1775
1824
|
const toolsUsed = [];
|
|
1776
1825
|
for (const line of raw.split("\n")) {
|
|
1777
|
-
if (!line.startsWith("data:"))
|
|
1778
|
-
continue;
|
|
1826
|
+
if (!line.startsWith("data:")) continue;
|
|
1779
1827
|
const payload = line.slice(5).trim();
|
|
1780
|
-
if (!payload || payload === "[DONE]")
|
|
1781
|
-
continue;
|
|
1828
|
+
if (!payload || payload === "[DONE]") continue;
|
|
1782
1829
|
try {
|
|
1783
1830
|
const event = JSON.parse(payload);
|
|
1784
1831
|
if (event.type === "text-delta") {
|
|
@@ -1793,7 +1840,7 @@ function parseUiMessageStream(raw) {
|
|
|
1793
1840
|
}
|
|
1794
1841
|
async function sendChatMessage(input, client) {
|
|
1795
1842
|
try {
|
|
1796
|
-
const conversationId = input.conversationId ??
|
|
1843
|
+
const conversationId = input.conversationId ?? randomUUID2();
|
|
1797
1844
|
let priorMessages = [];
|
|
1798
1845
|
if (input.conversationId) {
|
|
1799
1846
|
const history = await client.get(`/api/chat/messages/${input.conversationId}`, { limit: 1e3 });
|
|
@@ -1801,8 +1848,7 @@ async function sendChatMessage(input, client) {
|
|
|
1801
1848
|
const textParts = (message.parts ?? []).filter(
|
|
1802
1849
|
(part) => part.type === "text" && typeof part.text === "string"
|
|
1803
1850
|
);
|
|
1804
|
-
if (textParts.length === 0)
|
|
1805
|
-
continue;
|
|
1851
|
+
if (textParts.length === 0) continue;
|
|
1806
1852
|
priorMessages.push({
|
|
1807
1853
|
id: message.id,
|
|
1808
1854
|
role: message.role,
|
|
@@ -1816,7 +1862,7 @@ async function sendChatMessage(input, client) {
|
|
|
1816
1862
|
messages: [
|
|
1817
1863
|
...priorMessages,
|
|
1818
1864
|
{
|
|
1819
|
-
id:
|
|
1865
|
+
id: randomUUID2(),
|
|
1820
1866
|
role: "user",
|
|
1821
1867
|
parts: [{ type: "text", text: input.message }]
|
|
1822
1868
|
}
|
|
@@ -1888,7 +1934,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1888
1934
|
{
|
|
1889
1935
|
title,
|
|
1890
1936
|
description,
|
|
1891
|
-
inputSchema: schema
|
|
1937
|
+
inputSchema: schema,
|
|
1892
1938
|
annotations: { title, ...annotations }
|
|
1893
1939
|
},
|
|
1894
1940
|
wrapTool(handler)
|
|
@@ -1945,7 +1991,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1945
1991
|
tool(
|
|
1946
1992
|
"discover_metrics",
|
|
1947
1993
|
"Discover available metrics",
|
|
1948
|
-
"Discover what metrics are available for an app. Returns all available metrics organized by category (revenue, downloads, subscriptions, engagement, ads).
|
|
1994
|
+
"Discover what metrics are available for an app. Returns all available metrics organized by category (revenue, downloads, subscriptions, engagement, ads). Use it before get_metrics when you don't yet know which metric names this app has data for.",
|
|
1949
1995
|
discoverMetricsSchema,
|
|
1950
1996
|
discoverMetrics,
|
|
1951
1997
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -1953,7 +1999,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1953
1999
|
tool(
|
|
1954
2000
|
"get_metrics",
|
|
1955
2001
|
"Get metrics",
|
|
1956
|
-
"Query metric timeseries data for an app. Supports 30+ metrics (proceeds, totalDownloads, activeSubs, sessions, crashes, adSpend, etc.). Can query multiple metrics at once. Supports dimensional breakdowns (by country, platform, campaign). Use discover_metrics first to see available metrics.",
|
|
2002
|
+
"Query metric timeseries data for an app. Supports 30+ metrics (proceeds, totalDownloads, activeSubs, sessions, crashes, adSpend, adAvgCPA, etc.). Can query multiple metrics at once. Supports dimensional breakdowns (by country, platform, campaign). Each metric's summary.value is its value over the period, aggregated the right way for that metric: summed for flows like downloads, the latest value for levels like active subscriptions, and total over total for ratios like CPA. It covers summary.effectiveFromDate to summary.effectiveToDate: the requested days, less recent days whose data is not complete yet. Quote summary.value with that range rather than adding up the points. Use discover_metrics first to see available metrics.",
|
|
1957
2003
|
getMetricsSchema,
|
|
1958
2004
|
getMetrics,
|
|
1959
2005
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -1969,7 +2015,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1969
2015
|
tool(
|
|
1970
2016
|
"list_agents",
|
|
1971
2017
|
"List agents",
|
|
1972
|
-
"List
|
|
2018
|
+
"List the AI agents activated in the user's organization, with their status. Each entry's `id` is the agentId that trigger_agent_run, pause_agent, resume_agent and get_agent_activity take. Only activated agents are listed; if an agent type is missing, it has not been activated for this organization (the user activates it from the Agents page in Fload). Entries without an `id` mean the live list could not be loaded.",
|
|
1973
2019
|
listAgentsSchema,
|
|
1974
2020
|
listAgents,
|
|
1975
2021
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -1977,7 +2023,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1977
2023
|
tool(
|
|
1978
2024
|
"get_agent_details",
|
|
1979
2025
|
"Get agent details",
|
|
1980
|
-
"Get detailed configuration and status for a specific agent type. For the review agent, returns per-asset settings (mode, tone, custom instructions).
|
|
2026
|
+
"Get detailed configuration and status for a specific agent type. For the review agent, returns per-asset settings (mode, tone, custom instructions).",
|
|
1981
2027
|
getAgentDetailsSchema,
|
|
1982
2028
|
getAgentDetails,
|
|
1983
2029
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -1985,7 +2031,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1985
2031
|
tool(
|
|
1986
2032
|
"get_agent_run_history",
|
|
1987
2033
|
"Get agent run history",
|
|
1988
|
-
"Get run history for a specific agent type.
|
|
2034
|
+
"Get run history for a specific agent type. Returns run status, timing, and error details.",
|
|
1989
2035
|
getAgentRunHistorySchema,
|
|
1990
2036
|
getAgentRunHistory,
|
|
1991
2037
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -1993,7 +2039,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1993
2039
|
tool(
|
|
1994
2040
|
"trigger_agent_run",
|
|
1995
2041
|
"Trigger agent run",
|
|
1996
|
-
"Trigger a manual run for an agent. Optionally specify an asset (app) to run the agent against. Returns the triggered run details. Reversible in the sense that agent runs can be paused or dismissed.",
|
|
2042
|
+
"Trigger a manual run for an agent. Take the agentId from list_agents (the `id` of an activated agent). Optionally specify an asset (app) to run the agent against. Returns the triggered run details. Reversible in the sense that agent runs can be paused or dismissed.",
|
|
1997
2043
|
triggerAgentRunSchema,
|
|
1998
2044
|
triggerAgentRun,
|
|
1999
2045
|
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
@@ -2001,59 +2047,37 @@ function registerTools(server, client, options = {}) {
|
|
|
2001
2047
|
tool(
|
|
2002
2048
|
"pause_agent",
|
|
2003
2049
|
"Pause agent",
|
|
2004
|
-
"Pause a running agent. The agent will stop processing until resumed. Reversible via resume_agent.",
|
|
2050
|
+
"Pause a running agent. Take the agentId from list_agents (the `id` of an activated agent). The agent will stop processing until resumed. Reversible via resume_agent.",
|
|
2005
2051
|
pauseAgentSchema,
|
|
2006
2052
|
pauseAgent,
|
|
2007
|
-
{
|
|
2053
|
+
{
|
|
2054
|
+
readOnlyHint: false,
|
|
2055
|
+
destructiveHint: false,
|
|
2056
|
+
idempotentHint: true,
|
|
2057
|
+
openWorldHint: false
|
|
2058
|
+
}
|
|
2008
2059
|
);
|
|
2009
2060
|
tool(
|
|
2010
2061
|
"resume_agent",
|
|
2011
2062
|
"Resume agent",
|
|
2012
|
-
"Resume a paused agent. The agent will continue processing from where it left off. Reversible via pause_agent.",
|
|
2063
|
+
"Resume a paused agent. Take the agentId from list_agents (the `id` of an activated agent). The agent will continue processing from where it left off. Reversible via pause_agent.",
|
|
2013
2064
|
resumeAgentSchema,
|
|
2014
2065
|
resumeAgent,
|
|
2015
|
-
{
|
|
2066
|
+
{
|
|
2067
|
+
readOnlyHint: false,
|
|
2068
|
+
destructiveHint: false,
|
|
2069
|
+
idempotentHint: true,
|
|
2070
|
+
openWorldHint: false
|
|
2071
|
+
}
|
|
2016
2072
|
);
|
|
2017
2073
|
tool(
|
|
2018
2074
|
"get_agent_activity",
|
|
2019
2075
|
"Get agent activity",
|
|
2020
|
-
"Get the recent activity log for an agent. Returns a chronological list of actions the agent has taken, including timestamps, event types, and details.",
|
|
2076
|
+
"Get the recent activity log for an agent. Take the agentId from list_agents (the `id` of an activated agent). Returns a chronological list of actions the agent has taken, including timestamps, event types, and details.",
|
|
2021
2077
|
getAgentActivitySchema,
|
|
2022
2078
|
getAgentActivity,
|
|
2023
2079
|
{ readOnlyHint: true, openWorldHint: false }
|
|
2024
2080
|
);
|
|
2025
|
-
tool(
|
|
2026
|
-
"get_anomalies",
|
|
2027
|
-
"Get anomalies",
|
|
2028
|
-
"Get detected anomalies (unusual metric changes) for your apps. Filter by app, severity (low/medium/high/critical), type (surge/decline), status, metric name, and date range. Returns actual vs expected values, deviation percentage, confidence, and suggested actions.",
|
|
2029
|
-
getAnomaliesSchema,
|
|
2030
|
-
getAnomalies,
|
|
2031
|
-
{ readOnlyHint: true, openWorldHint: false }
|
|
2032
|
-
);
|
|
2033
|
-
tool(
|
|
2034
|
-
"get_anomaly_detail",
|
|
2035
|
-
"Get anomaly detail",
|
|
2036
|
-
"Get full detail for a single anomaly including chart data. Returns the anomaly metadata, actual vs expected values, and historical metric data points for visualization.",
|
|
2037
|
-
getAnomalyDetailSchema,
|
|
2038
|
-
getAnomalyDetail,
|
|
2039
|
-
{ readOnlyHint: true, openWorldHint: false }
|
|
2040
|
-
);
|
|
2041
|
-
tool(
|
|
2042
|
-
"acknowledge_anomaly",
|
|
2043
|
-
"Acknowledge anomaly",
|
|
2044
|
-
'Mark an anomaly as acknowledged. This updates the anomaly status from "new" to "acknowledged", indicating it has been reviewed but not dismissed. Reversible \u2014 anomaly can be reset or dismissed later.',
|
|
2045
|
-
acknowledgeAnomalySchema,
|
|
2046
|
-
acknowledgeAnomaly,
|
|
2047
|
-
{ readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
2048
|
-
);
|
|
2049
|
-
tool(
|
|
2050
|
-
"dismiss_anomaly",
|
|
2051
|
-
"Dismiss anomaly",
|
|
2052
|
-
'Dismiss an anomaly. This updates the anomaly status to "dismissed", removing it from active alerts. Dismissed anomalies are excluded from queries by default. Soft state change \u2014 the anomaly row is preserved and can be un-dismissed later.',
|
|
2053
|
-
dismissAnomalySchema,
|
|
2054
|
-
dismissAnomaly,
|
|
2055
|
-
{ readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
2056
|
-
);
|
|
2057
2081
|
tool(
|
|
2058
2082
|
"get_ads_performance",
|
|
2059
2083
|
"Get ads performance",
|
|
@@ -2062,34 +2086,10 @@ function registerTools(server, client, options = {}) {
|
|
|
2062
2086
|
getAdsPerformance,
|
|
2063
2087
|
{ readOnlyHint: true, openWorldHint: false }
|
|
2064
2088
|
);
|
|
2065
|
-
tool(
|
|
2066
|
-
"get_growth_audit",
|
|
2067
|
-
"Get growth audit",
|
|
2068
|
-
"Get a comprehensive growth audit for an app. Synthesizes data from review sentiment analysis, recent anomalies, valuation trends, and connector health into an actionable growth assessment.",
|
|
2069
|
-
getGrowthAuditSchema,
|
|
2070
|
-
getGrowthAudit,
|
|
2071
|
-
{ readOnlyHint: true, openWorldHint: false }
|
|
2072
|
-
);
|
|
2073
|
-
tool(
|
|
2074
|
-
"get_growth_score",
|
|
2075
|
-
"Get growth score",
|
|
2076
|
-
"Get a calculated growth score (0-100) and grade (A-F) for an app. The score is based on app store rating, valuation trend, recent anomalies, review sentiment, and data connector health. Includes a breakdown of scoring factors.",
|
|
2077
|
-
getGrowthScoreSchema,
|
|
2078
|
-
getGrowthScore,
|
|
2079
|
-
{ readOnlyHint: true, openWorldHint: false }
|
|
2080
|
-
);
|
|
2081
|
-
tool(
|
|
2082
|
-
"get_forecasts",
|
|
2083
|
-
"Get forecasts",
|
|
2084
|
-
"Get a statistical forecast for an app metric (proceeds, total_revenue, total_downloads, active_subs, or new_trials). Returns weekly historical values plus a forward projection with confidence bounds.",
|
|
2085
|
-
getForecastsSchema,
|
|
2086
|
-
getForecasts,
|
|
2087
|
-
{ readOnlyHint: true, openWorldHint: false }
|
|
2088
|
-
);
|
|
2089
2089
|
tool(
|
|
2090
2090
|
"get_dashboard_overview",
|
|
2091
2091
|
"Get dashboard overview",
|
|
2092
|
-
"Get an aggregated dashboard overview for the organization. Returns portfolio summary (apps, valuations, ratings), data connector health status, and alerts (
|
|
2092
|
+
"Get an aggregated dashboard overview for the organization. Returns portfolio summary (apps, valuations, ratings), data connector health status, and alerts (pending review drafts).",
|
|
2093
2093
|
getDashboardOverviewSchema,
|
|
2094
2094
|
getDashboardOverview,
|
|
2095
2095
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -2097,7 +2097,7 @@ function registerTools(server, client, options = {}) {
|
|
|
2097
2097
|
tool(
|
|
2098
2098
|
"list_pending_actions",
|
|
2099
2099
|
"List pending actions",
|
|
2100
|
-
|
|
2100
|
+
'List the inbox items waiting on the user: agent proposals to approve (review replies, listing changes, Apple Search Ads changes, plans) and notices to act on. Each item carries its kind, title, status, inbox bucket, the app, and the commands it accepts. Filter by app. view "queued" lists approved work Fload is sending or checking in the store instead.',
|
|
2101
2101
|
listPendingActionsSchema,
|
|
2102
2102
|
listPendingActions,
|
|
2103
2103
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -2105,7 +2105,7 @@ function registerTools(server, client, options = {}) {
|
|
|
2105
2105
|
tool(
|
|
2106
2106
|
"approve_action",
|
|
2107
2107
|
"Approve pending action",
|
|
2108
|
-
"Approve
|
|
2108
|
+
"Approve an inbox item (actionId from list_pending_actions); a notice is acknowledged instead. Approving a review reply or a listing change publishes it to the store after a short undo window \u2014 treat as destructive (publicly visible, cannot be silently undone).",
|
|
2109
2109
|
approveActionSchema,
|
|
2110
2110
|
approveAction,
|
|
2111
2111
|
{ readOnlyHint: false, destructiveHint: true, openWorldHint: true }
|
|
@@ -2113,11 +2113,27 @@ function registerTools(server, client, options = {}) {
|
|
|
2113
2113
|
tool(
|
|
2114
2114
|
"reject_action",
|
|
2115
2115
|
"Reject pending action",
|
|
2116
|
-
"Reject
|
|
2116
|
+
"Reject an inbox item (actionId from list_pending_actions); a notice is dismissed instead. Nothing is sent to the store. Pass the user's reason when they gave one: it is kept with the rejection so the agents do not propose the same thing again.",
|
|
2117
2117
|
rejectActionSchema,
|
|
2118
2118
|
rejectAction,
|
|
2119
2119
|
{ readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
2120
2120
|
);
|
|
2121
|
+
tool(
|
|
2122
|
+
"check_action_now",
|
|
2123
|
+
"Check a change in the store now",
|
|
2124
|
+
'For an inbox item Fload is reading back from the store (status verifying, its commands include check_now; list them with list_pending_actions view "queued"): read the store again now instead of at the next scheduled check. The item concludes as soon as the store shows the change. Nothing is written to the store. At most once every 30 seconds per item.',
|
|
2125
|
+
checkActionNowSchema,
|
|
2126
|
+
checkActionNow,
|
|
2127
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
2128
|
+
);
|
|
2129
|
+
tool(
|
|
2130
|
+
"rename_custom_page_action",
|
|
2131
|
+
"Rename a custom product page request and send it",
|
|
2132
|
+
'For a "Create custom product page" inbox item (actionId from list_pending_actions) that App Store Connect refused because the app already has a page of that name, or one still waiting for approval: rename it (name: at most 100 characters, not its current name, not a page the app already has) and approve it again on the same item. Fload then creates the page under the new name after a short undo window. Treat as destructive: it creates a page in App Store Connect. If the approve is refused, the item keeps its new name and waits for approval.',
|
|
2133
|
+
renameCustomPageActionSchema,
|
|
2134
|
+
renameCustomPageAction,
|
|
2135
|
+
{ readOnlyHint: false, destructiveHint: true, openWorldHint: true }
|
|
2136
|
+
);
|
|
2121
2137
|
tool(
|
|
2122
2138
|
"get_aso_summary",
|
|
2123
2139
|
"Get ASO summary",
|
|
@@ -2134,6 +2150,14 @@ function registerTools(server, client, options = {}) {
|
|
|
2134
2150
|
getAsoRecommendations,
|
|
2135
2151
|
{ readOnlyHint: true, openWorldHint: false }
|
|
2136
2152
|
);
|
|
2153
|
+
tool(
|
|
2154
|
+
"get_aso_evidence",
|
|
2155
|
+
"Get ASO decisions and evidence",
|
|
2156
|
+
"Read ASO methodology assessments, per-object decisions, source evidence, limitations, ranking power, localization readiness and test plans. Records are newest first; historical approvals are not current execution permission. A priority score never overrides a blocked decision or the prohibition on competitor names in all metadata.",
|
|
2157
|
+
getAsoEvidenceSchema,
|
|
2158
|
+
getAsoEvidence,
|
|
2159
|
+
{ readOnlyHint: true, openWorldHint: false }
|
|
2160
|
+
);
|
|
2137
2161
|
tool(
|
|
2138
2162
|
"get_aso_keywords",
|
|
2139
2163
|
"Get ASO keywords",
|
|
@@ -2153,7 +2177,7 @@ function registerTools(server, client, options = {}) {
|
|
|
2153
2177
|
tool(
|
|
2154
2178
|
"get_aso_locale_snapshots",
|
|
2155
2179
|
"Get ASO locale snapshots",
|
|
2156
|
-
|
|
2180
|
+
'Get current App Store and Google Play listing snapshots across all locales for an app. Returns the live title, subtitle, keywords, description, and promotional text for each locale \u2014 by default the latest snapshot per locale and type; pass view "history" for raw revisions newest first. Useful for auditing localized metadata consistency.',
|
|
2157
2181
|
getAsoLocaleSnapshotsSchema,
|
|
2158
2182
|
getAsoLocaleSnapshots,
|
|
2159
2183
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -2185,7 +2209,7 @@ function registerTools(server, client, options = {}) {
|
|
|
2185
2209
|
tool(
|
|
2186
2210
|
"send_chat_message",
|
|
2187
2211
|
"Send chat message",
|
|
2188
|
-
"Send a message to the Fload AI chat assistant. Starts a new conversation if no conversationId is provided, or continues an existing one. Optionally specify an agentType to route to a specialized agent (review,
|
|
2212
|
+
"Send a message to the Fload AI chat assistant. Starts a new conversation if no conversationId is provided, or continues an existing one. Optionally specify an agentType to route to a specialized agent (review, aso). Adds a message to your chat history \u2014 not publicly visible.",
|
|
2189
2213
|
sendChatMessageSchema,
|
|
2190
2214
|
sendChatMessage,
|
|
2191
2215
|
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
@@ -2205,20 +2229,26 @@ async function createMcpServer(_config, client) {
|
|
|
2205
2229
|
}
|
|
2206
2230
|
|
|
2207
2231
|
// src/config.ts
|
|
2208
|
-
import "dotenv/config";
|
|
2209
2232
|
import { readFileSync, existsSync } from "fs";
|
|
2210
2233
|
import { homedir } from "os";
|
|
2211
2234
|
import { join } from "path";
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2235
|
+
import { z as z10 } from "zod";
|
|
2236
|
+
var ConfigFileSchema = z10.object({
|
|
2237
|
+
apiKey: z10.string().optional().catch(void 0),
|
|
2238
|
+
apiUrl: z10.string().optional().catch(void 0)
|
|
2239
|
+
});
|
|
2240
|
+
function loadConfig(env = process.env) {
|
|
2241
|
+
const apiKey = env.FLOAD_API_KEY;
|
|
2242
|
+
const apiUrl = env.FLOAD_API_URL || "https://api.fload.com";
|
|
2215
2243
|
if (apiKey) {
|
|
2216
2244
|
return { apiKey, apiUrl };
|
|
2217
2245
|
}
|
|
2218
2246
|
const configPath = join(homedir(), ".fload", "config.json");
|
|
2219
2247
|
if (existsSync(configPath)) {
|
|
2220
2248
|
try {
|
|
2221
|
-
const configData =
|
|
2249
|
+
const configData = ConfigFileSchema.parse(
|
|
2250
|
+
JSON.parse(readFileSync(configPath, "utf-8"))
|
|
2251
|
+
);
|
|
2222
2252
|
if (configData.apiKey) {
|
|
2223
2253
|
return {
|
|
2224
2254
|
apiKey: configData.apiKey,
|