@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/bin.js CHANGED
@@ -324,7 +324,9 @@ async function getReviews(input, client) {
324
324
  hasReply: hasReply(review),
325
325
  replySource: review.replySource ?? null,
326
326
  hasDraft: review.hasDraft ?? false,
327
- reply: review.developerResponse ? typeof review.developerResponse === "object" ? review.developerResponse.response : review.developerResponse : review.reply || null
327
+ reply: review.developerResponse ? typeof review.developerResponse === "object" ? review.developerResponse.response : review.developerResponse : review.reply || null,
328
+ // FLO-2571: where an App Store reply stands at Apple.
329
+ replyPublication: typeof review.developerResponse === "object" ? review.developerResponse?.publication ?? null : null
328
330
  }))
329
331
  })
330
332
  }
@@ -1261,7 +1263,10 @@ var listPendingActionsSchema = z9.object({
1261
1263
  limit: z9.number().int().min(1).max(100).default(50).describe("Maximum number of actions to return")
1262
1264
  });
1263
1265
  var approveActionSchema = z9.object({
1264
- actionId: z9.string().describe("The inbox item ID to approve (from list_pending_actions)")
1266
+ actionId: z9.string().describe("The inbox item ID to approve (from list_pending_actions)"),
1267
+ wholeGroup: z9.boolean().optional().describe(
1268
+ "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."
1269
+ )
1265
1270
  });
1266
1271
  var rejectActionSchema = z9.object({
1267
1272
  actionId: z9.string().describe("The inbox item ID to reject (from list_pending_actions)"),
@@ -1352,6 +1357,13 @@ async function commandItem(client, itemId, intent, reason) {
1352
1357
  }
1353
1358
  };
1354
1359
  }
1360
+ function approveMessage(command, applied2, result) {
1361
+ if (!applied2) return refusedMessage(result);
1362
+ if (command === "acknowledge") return "Acknowledged.";
1363
+ if (result?.alreadyLive)
1364
+ return "Already live: the store already shows this change, so nothing was sent. The item is done.";
1365
+ return "Approved. Fload delivers it after a short undo window; the inbox shows where it is.";
1366
+ }
1355
1367
  function refusedMessage(result) {
1356
1368
  const said = result?.error ?? "The approval could not be recorded.";
1357
1369
  const check = result?.policyRefusal?.check;
@@ -1359,6 +1371,10 @@ function refusedMessage(result) {
1359
1371
  }
1360
1372
  async function approveAction(input, client) {
1361
1373
  try {
1374
+ if (input.wholeGroup) {
1375
+ const grouped = await approveGroup(client, input.actionId);
1376
+ if (grouped) return grouped;
1377
+ }
1362
1378
  const { command, result } = await commandItem(
1363
1379
  client,
1364
1380
  input.actionId,
@@ -1372,7 +1388,7 @@ async function approveAction(input, client) {
1372
1388
  command,
1373
1389
  result: result?.result ?? "unknown",
1374
1390
  ...result?.error ? { error: result.error } : {},
1375
- message: applied2 ? command === "acknowledge" ? "Acknowledged." : "Approved. Fload delivers it after a short undo window; the inbox shows where it is." : refusedMessage(result),
1391
+ message: approveMessage(command, applied2, result),
1376
1392
  item: result?.item
1377
1393
  },
1378
1394
  !applied2
@@ -1381,6 +1397,80 @@ async function approveAction(input, client) {
1381
1397
  return toolError(error);
1382
1398
  }
1383
1399
  }
1400
+ async function groupOf(client, item) {
1401
+ if (!item.proposalBatch || item.status !== "needs_approval") return [item];
1402
+ const isSibling = (other) => typeof other === "object" && other !== null && other.status === "needs_approval" && other.proposalBatch === item.proposalBatch && other.assetId === item.assetId && other.id !== item.id;
1403
+ const siblings = [];
1404
+ let cursor;
1405
+ do {
1406
+ const response = await client.get("/api/actions/items", {
1407
+ view: "open",
1408
+ limit: 100,
1409
+ ...item.assetId ? { assetId: item.assetId } : {},
1410
+ ...cursor ? { cursor } : {}
1411
+ });
1412
+ siblings.push(...(response.items ?? []).filter(isSibling));
1413
+ cursor = response.nextCursor;
1414
+ } while (cursor);
1415
+ return [item, ...siblings];
1416
+ }
1417
+ async function approveGroup(client, actionId) {
1418
+ const detail = await client.get(
1419
+ `/api/actions/items/${encodeURIComponent(actionId)}`
1420
+ );
1421
+ if (!detail.item) throw new Error("Action not found");
1422
+ const group = await groupOf(client, detail.item);
1423
+ if (group.length <= 1) return null;
1424
+ const approvable = group.filter(
1425
+ (item) => item.allowedCommands?.includes("approve")
1426
+ );
1427
+ const skipped = group.filter((item) => !approvable.includes(item)).map((item) => item.id);
1428
+ if (approvable.length === 0)
1429
+ return toolText(
1430
+ {
1431
+ success: false,
1432
+ actionId,
1433
+ skipped,
1434
+ message: "Nothing in this card can be approved right now."
1435
+ },
1436
+ true
1437
+ );
1438
+ const answer = await client.postForAnswer(
1439
+ "/api/actions/commands",
1440
+ {
1441
+ command: "approve",
1442
+ idempotencyKey: `mcp:approve-group:${actionId}:${randomUUID()}`,
1443
+ targets: approvable.map((item) => ({
1444
+ itemId: item.id,
1445
+ ...item.currentRevisionId ? { revisionId: item.currentRevisionId } : {}
1446
+ }))
1447
+ }
1448
+ );
1449
+ const results = (answer.body?.results ?? []).map((result) => ({
1450
+ itemId: result.itemId,
1451
+ result: result.result,
1452
+ ...result.error ? {
1453
+ error: publicMcpErrorMessage(
1454
+ result.error,
1455
+ "Fload could not apply this change."
1456
+ )
1457
+ } : {}
1458
+ }));
1459
+ const approved = results.filter(
1460
+ (r) => r.result === "applied" || r.result === "replayed"
1461
+ ).length;
1462
+ return toolText(
1463
+ {
1464
+ success: approved > 0,
1465
+ actionId,
1466
+ approved,
1467
+ results,
1468
+ ...skipped.length ? { skipped } : {},
1469
+ 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."
1470
+ },
1471
+ approved === 0
1472
+ );
1473
+ }
1384
1474
  async function rejectAction(input, client) {
1385
1475
  try {
1386
1476
  const { command, result } = await commandItem(
@@ -1822,9 +1912,26 @@ async function getConversationMessages(input, client) {
1822
1912
  };
1823
1913
  }
1824
1914
  }
1915
+ var FREE_CONVERSATION_LABEL = "Free: your first conversation";
1916
+ var FREE_CONVERSATION_ENDED_NOTICE = "Your free first conversation has ended; messages now use credits.";
1917
+ function answerCostOf(data) {
1918
+ if (!data || typeof data !== "object") return null;
1919
+ const usage = data;
1920
+ const free = usage.freeConversation;
1921
+ if (free && typeof free.messagesLeft === "number") {
1922
+ return {
1923
+ free: true,
1924
+ label: FREE_CONVERSATION_LABEL,
1925
+ messagesLeft: free.messagesLeft,
1926
+ ...free.ended === true ? { notice: FREE_CONVERSATION_ENDED_NOTICE } : {}
1927
+ };
1928
+ }
1929
+ return typeof usage.credits === "number" ? { free: false, credits: usage.credits } : null;
1930
+ }
1825
1931
  function parseUiMessageStream(raw) {
1826
1932
  let reply = "";
1827
1933
  const toolsUsed = [];
1934
+ let cost = null;
1828
1935
  for (const line of raw.split("\n")) {
1829
1936
  if (!line.startsWith("data:")) continue;
1830
1937
  const payload = line.slice(5).trim();
@@ -1835,11 +1942,13 @@ function parseUiMessageStream(raw) {
1835
1942
  reply += String(event.delta ?? event.textDelta ?? "");
1836
1943
  } else if (typeof event.type === "string" && event.type === "tool-input-start" && typeof event.toolName === "string") {
1837
1944
  toolsUsed.push(event.toolName);
1945
+ } else if (event.type === "data-usage") {
1946
+ cost = answerCostOf(event.data) ?? cost;
1838
1947
  }
1839
1948
  } catch {
1840
1949
  }
1841
1950
  }
1842
- return { reply, toolsUsed };
1951
+ return { reply, toolsUsed, cost };
1843
1952
  }
1844
1953
  async function sendChatMessage(input, client) {
1845
1954
  try {
@@ -1880,7 +1989,7 @@ async function sendChatMessage(input, client) {
1880
1989
  };
1881
1990
  }
1882
1991
  const raw = await client.postStream("/api/chat", body);
1883
- const { reply, toolsUsed } = parseUiMessageStream(raw);
1992
+ const { reply, toolsUsed, cost } = parseUiMessageStream(raw);
1884
1993
  return {
1885
1994
  content: [
1886
1995
  {
@@ -1889,6 +1998,8 @@ async function sendChatMessage(input, client) {
1889
1998
  conversationId,
1890
1999
  reply: reply || "The assistant returned no text response.",
1891
2000
  toolsUsed,
2001
+ // FLO-2669: the credits the answer used, or that it was free.
2002
+ ...cost ? { cost } : {},
1892
2003
  tip: "Pass this conversationId to continue the conversation or to get_conversation_messages for the full transcript."
1893
2004
  })
1894
2005
  }
@@ -1962,7 +2073,7 @@ function registerTools(server, client, options = {}) {
1962
2073
  tool(
1963
2074
  "get_reviews",
1964
2075
  "Get reviews",
1965
- "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. Useful for sentiment analysis, support workflows, and review management.",
2076
+ '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.',
1966
2077
  getReviewsSchema,
1967
2078
  getReviews,
1968
2079
  { readOnlyHint: true, openWorldHint: false }
@@ -2220,7 +2331,7 @@ function registerTools(server, client, options = {}) {
2220
2331
  tool(
2221
2332
  "send_chat_message",
2222
2333
  "Send chat message",
2223
- "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.",
2334
+ "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).",
2224
2335
  sendChatMessageSchema,
2225
2336
  sendChatMessage,
2226
2337
  { readOnlyHint: false, destructiveHint: false, openWorldHint: true }