@fload-ai/mcp 0.10.0 → 0.12.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/dist/.tsbuildinfo +1 -1
- package/dist/bin.js +118 -7
- package/dist/bin.js.map +2 -2
- package/dist/index.js +118 -7
- package/dist/index.js.map +2 -2
- package/dist/tools/actions.d.ts +1 -0
- package/dist/tools/actions.d.ts.map +1 -1
- package/dist/tools/chat.d.ts +12 -0
- package/dist/tools/chat.d.ts.map +1 -1
- package/dist/tools/index.js +120 -7
- package/dist/tools/index.js.map +2 -2
- package/dist/tools/reviews.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -404,7 +404,9 @@ async function getReviews(input, client) {
|
|
|
404
404
|
hasReply: hasReply(review),
|
|
405
405
|
replySource: review.replySource ?? null,
|
|
406
406
|
hasDraft: review.hasDraft ?? false,
|
|
407
|
-
reply: review.developerResponse ? typeof review.developerResponse === "object" ? review.developerResponse.response : review.developerResponse : review.reply || null
|
|
407
|
+
reply: review.developerResponse ? typeof review.developerResponse === "object" ? review.developerResponse.response : review.developerResponse : review.reply || null,
|
|
408
|
+
// FLO-2571: where an App Store reply stands at Apple.
|
|
409
|
+
replyPublication: typeof review.developerResponse === "object" ? review.developerResponse?.publication ?? null : null
|
|
408
410
|
}))
|
|
409
411
|
})
|
|
410
412
|
}
|
|
@@ -1316,7 +1318,10 @@ var listPendingActionsSchema = z8.object({
|
|
|
1316
1318
|
limit: z8.number().int().min(1).max(100).default(50).describe("Maximum number of actions to return")
|
|
1317
1319
|
});
|
|
1318
1320
|
var approveActionSchema = z8.object({
|
|
1319
|
-
actionId: z8.string().describe("The inbox item ID to approve (from list_pending_actions)")
|
|
1321
|
+
actionId: z8.string().describe("The inbox item ID to approve (from list_pending_actions)"),
|
|
1322
|
+
wholeGroup: z8.boolean().optional().describe(
|
|
1323
|
+
"Approve every language of this item's card at once: the items still waiting for approval that share its proposalBatch (one listing change across locales, as the inbox shows it as one card with one Approve). Languages that cannot be approved now are left as they are and listed."
|
|
1324
|
+
)
|
|
1320
1325
|
});
|
|
1321
1326
|
var rejectActionSchema = z8.object({
|
|
1322
1327
|
actionId: z8.string().describe("The inbox item ID to reject (from list_pending_actions)"),
|
|
@@ -1407,6 +1412,13 @@ async function commandItem(client, itemId, intent, reason) {
|
|
|
1407
1412
|
}
|
|
1408
1413
|
};
|
|
1409
1414
|
}
|
|
1415
|
+
function approveMessage(command, applied2, result) {
|
|
1416
|
+
if (!applied2) return refusedMessage(result);
|
|
1417
|
+
if (command === "acknowledge") return "Acknowledged.";
|
|
1418
|
+
if (result?.alreadyLive)
|
|
1419
|
+
return "Already live: the store already shows this change, so nothing was sent. The item is done.";
|
|
1420
|
+
return "Approved. Fload delivers it after a short undo window; the inbox shows where it is.";
|
|
1421
|
+
}
|
|
1410
1422
|
function refusedMessage(result) {
|
|
1411
1423
|
const said = result?.error ?? "The approval could not be recorded.";
|
|
1412
1424
|
const check = result?.policyRefusal?.check;
|
|
@@ -1414,6 +1426,10 @@ function refusedMessage(result) {
|
|
|
1414
1426
|
}
|
|
1415
1427
|
async function approveAction(input, client) {
|
|
1416
1428
|
try {
|
|
1429
|
+
if (input.wholeGroup) {
|
|
1430
|
+
const grouped = await approveGroup(client, input.actionId);
|
|
1431
|
+
if (grouped) return grouped;
|
|
1432
|
+
}
|
|
1417
1433
|
const { command, result } = await commandItem(
|
|
1418
1434
|
client,
|
|
1419
1435
|
input.actionId,
|
|
@@ -1427,7 +1443,7 @@ async function approveAction(input, client) {
|
|
|
1427
1443
|
command,
|
|
1428
1444
|
result: result?.result ?? "unknown",
|
|
1429
1445
|
...result?.error ? { error: result.error } : {},
|
|
1430
|
-
message:
|
|
1446
|
+
message: approveMessage(command, applied2, result),
|
|
1431
1447
|
item: result?.item
|
|
1432
1448
|
},
|
|
1433
1449
|
!applied2
|
|
@@ -1436,6 +1452,80 @@ async function approveAction(input, client) {
|
|
|
1436
1452
|
return toolError(error);
|
|
1437
1453
|
}
|
|
1438
1454
|
}
|
|
1455
|
+
async function groupOf(client, item) {
|
|
1456
|
+
if (!item.proposalBatch || item.status !== "needs_approval") return [item];
|
|
1457
|
+
const isSibling = (other) => typeof other === "object" && other !== null && other.status === "needs_approval" && other.proposalBatch === item.proposalBatch && other.assetId === item.assetId && other.id !== item.id;
|
|
1458
|
+
const siblings = [];
|
|
1459
|
+
let cursor;
|
|
1460
|
+
do {
|
|
1461
|
+
const response = await client.get("/api/actions/items", {
|
|
1462
|
+
view: "open",
|
|
1463
|
+
limit: 100,
|
|
1464
|
+
...item.assetId ? { assetId: item.assetId } : {},
|
|
1465
|
+
...cursor ? { cursor } : {}
|
|
1466
|
+
});
|
|
1467
|
+
siblings.push(...(response.items ?? []).filter(isSibling));
|
|
1468
|
+
cursor = response.nextCursor;
|
|
1469
|
+
} while (cursor);
|
|
1470
|
+
return [item, ...siblings];
|
|
1471
|
+
}
|
|
1472
|
+
async function approveGroup(client, actionId) {
|
|
1473
|
+
const detail = await client.get(
|
|
1474
|
+
`/api/actions/items/${encodeURIComponent(actionId)}`
|
|
1475
|
+
);
|
|
1476
|
+
if (!detail.item) throw new Error("Action not found");
|
|
1477
|
+
const group = await groupOf(client, detail.item);
|
|
1478
|
+
if (group.length <= 1) return null;
|
|
1479
|
+
const approvable = group.filter(
|
|
1480
|
+
(item) => item.allowedCommands?.includes("approve")
|
|
1481
|
+
);
|
|
1482
|
+
const skipped = group.filter((item) => !approvable.includes(item)).map((item) => item.id);
|
|
1483
|
+
if (approvable.length === 0)
|
|
1484
|
+
return toolText(
|
|
1485
|
+
{
|
|
1486
|
+
success: false,
|
|
1487
|
+
actionId,
|
|
1488
|
+
skipped,
|
|
1489
|
+
message: "Nothing in this card can be approved right now."
|
|
1490
|
+
},
|
|
1491
|
+
true
|
|
1492
|
+
);
|
|
1493
|
+
const answer = await client.postForAnswer(
|
|
1494
|
+
"/api/actions/commands",
|
|
1495
|
+
{
|
|
1496
|
+
command: "approve",
|
|
1497
|
+
idempotencyKey: `mcp:approve-group:${actionId}:${randomUUID()}`,
|
|
1498
|
+
targets: approvable.map((item) => ({
|
|
1499
|
+
itemId: item.id,
|
|
1500
|
+
...item.currentRevisionId ? { revisionId: item.currentRevisionId } : {}
|
|
1501
|
+
}))
|
|
1502
|
+
}
|
|
1503
|
+
);
|
|
1504
|
+
const results = (answer.body?.results ?? []).map((result) => ({
|
|
1505
|
+
itemId: result.itemId,
|
|
1506
|
+
result: result.result,
|
|
1507
|
+
...result.error ? {
|
|
1508
|
+
error: publicMcpErrorMessage(
|
|
1509
|
+
result.error,
|
|
1510
|
+
"Fload could not apply this change."
|
|
1511
|
+
)
|
|
1512
|
+
} : {}
|
|
1513
|
+
}));
|
|
1514
|
+
const approved = results.filter(
|
|
1515
|
+
(r) => r.result === "applied" || r.result === "replayed"
|
|
1516
|
+
).length;
|
|
1517
|
+
return toolText(
|
|
1518
|
+
{
|
|
1519
|
+
success: approved > 0,
|
|
1520
|
+
actionId,
|
|
1521
|
+
approved,
|
|
1522
|
+
results,
|
|
1523
|
+
...skipped.length ? { skipped } : {},
|
|
1524
|
+
message: approved > 0 ? `Approved ${approved} of ${group.length}. Fload delivers them after a short undo window; the inbox shows where each is.` : "The approval could not be recorded."
|
|
1525
|
+
},
|
|
1526
|
+
approved === 0
|
|
1527
|
+
);
|
|
1528
|
+
}
|
|
1439
1529
|
async function rejectAction(input, client) {
|
|
1440
1530
|
try {
|
|
1441
1531
|
const { command, result } = await commandItem(
|
|
@@ -1877,9 +1967,26 @@ async function getConversationMessages(input, client) {
|
|
|
1877
1967
|
};
|
|
1878
1968
|
}
|
|
1879
1969
|
}
|
|
1970
|
+
var FREE_CONVERSATION_LABEL = "Free: your first conversation";
|
|
1971
|
+
var FREE_CONVERSATION_ENDED_NOTICE = "Your free first conversation has ended; messages now use credits.";
|
|
1972
|
+
function answerCostOf(data) {
|
|
1973
|
+
if (!data || typeof data !== "object") return null;
|
|
1974
|
+
const usage = data;
|
|
1975
|
+
const free = usage.freeConversation;
|
|
1976
|
+
if (free && typeof free.messagesLeft === "number") {
|
|
1977
|
+
return {
|
|
1978
|
+
free: true,
|
|
1979
|
+
label: FREE_CONVERSATION_LABEL,
|
|
1980
|
+
messagesLeft: free.messagesLeft,
|
|
1981
|
+
...free.ended === true ? { notice: FREE_CONVERSATION_ENDED_NOTICE } : {}
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
return typeof usage.credits === "number" ? { free: false, credits: usage.credits } : null;
|
|
1985
|
+
}
|
|
1880
1986
|
function parseUiMessageStream(raw) {
|
|
1881
1987
|
let reply = "";
|
|
1882
1988
|
const toolsUsed = [];
|
|
1989
|
+
let cost = null;
|
|
1883
1990
|
for (const line of raw.split("\n")) {
|
|
1884
1991
|
if (!line.startsWith("data:")) continue;
|
|
1885
1992
|
const payload = line.slice(5).trim();
|
|
@@ -1890,11 +1997,13 @@ function parseUiMessageStream(raw) {
|
|
|
1890
1997
|
reply += String(event.delta ?? event.textDelta ?? "");
|
|
1891
1998
|
} else if (typeof event.type === "string" && event.type === "tool-input-start" && typeof event.toolName === "string") {
|
|
1892
1999
|
toolsUsed.push(event.toolName);
|
|
2000
|
+
} else if (event.type === "data-usage") {
|
|
2001
|
+
cost = answerCostOf(event.data) ?? cost;
|
|
1893
2002
|
}
|
|
1894
2003
|
} catch {
|
|
1895
2004
|
}
|
|
1896
2005
|
}
|
|
1897
|
-
return { reply, toolsUsed };
|
|
2006
|
+
return { reply, toolsUsed, cost };
|
|
1898
2007
|
}
|
|
1899
2008
|
async function sendChatMessage(input, client) {
|
|
1900
2009
|
try {
|
|
@@ -1935,7 +2044,7 @@ async function sendChatMessage(input, client) {
|
|
|
1935
2044
|
};
|
|
1936
2045
|
}
|
|
1937
2046
|
const raw = await client.postStream("/api/chat", body);
|
|
1938
|
-
const { reply, toolsUsed } = parseUiMessageStream(raw);
|
|
2047
|
+
const { reply, toolsUsed, cost } = parseUiMessageStream(raw);
|
|
1939
2048
|
return {
|
|
1940
2049
|
content: [
|
|
1941
2050
|
{
|
|
@@ -1944,6 +2053,8 @@ async function sendChatMessage(input, client) {
|
|
|
1944
2053
|
conversationId,
|
|
1945
2054
|
reply: reply || "The assistant returned no text response.",
|
|
1946
2055
|
toolsUsed,
|
|
2056
|
+
// FLO-2669: the credits the answer used, or that it was free.
|
|
2057
|
+
...cost ? { cost } : {},
|
|
1947
2058
|
tip: "Pass this conversationId to continue the conversation or to get_conversation_messages for the full transcript."
|
|
1948
2059
|
})
|
|
1949
2060
|
}
|
|
@@ -2017,7 +2128,7 @@ function registerTools(server, client, options = {}) {
|
|
|
2017
2128
|
tool(
|
|
2018
2129
|
"get_reviews",
|
|
2019
2130
|
"Get reviews",
|
|
2020
|
-
|
|
2131
|
+
'Get app reviews with flexible filtering. Filter by app (assetId or bundleId), platform, rating (1-5 stars), replied status, and date range. Returns reviews with metadata, author, body text, and reply status. For an App Store reply, replyPublication says where it stands at Apple: "publishing" (sent; Apple has not published it yet, usually within a day), "live" (live on the App Store), "removed" (Apple no longer shows it), or null (not known: never call it live). Useful for sentiment analysis, support workflows, and review management.',
|
|
2021
2132
|
getReviewsSchema,
|
|
2022
2133
|
getReviews,
|
|
2023
2134
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -2275,7 +2386,7 @@ function registerTools(server, client, options = {}) {
|
|
|
2275
2386
|
tool(
|
|
2276
2387
|
"send_chat_message",
|
|
2277
2388
|
"Send chat message",
|
|
2278
|
-
"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.",
|
|
2389
|
+
"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. The result's `cost` says what the answer used: `credits`, or `free: true` with the free answers left when a new organization's free first conversation carried it (and a `notice` on the answer that ended it).",
|
|
2279
2390
|
sendChatMessageSchema,
|
|
2280
2391
|
sendChatMessage,
|
|
2281
2392
|
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|