@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/tools/actions.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const listPendingActionsSchema: z.ZodObject<{
|
|
|
10
10
|
}, z.core.$strip>;
|
|
11
11
|
export declare const approveActionSchema: z.ZodObject<{
|
|
12
12
|
actionId: z.ZodString;
|
|
13
|
+
wholeGroup: z.ZodOptional<z.ZodBoolean>;
|
|
13
14
|
}, z.core.$strip>;
|
|
14
15
|
export declare const rejectActionSchema: z.ZodObject<{
|
|
15
16
|
actionId: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/tools/actions.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/tools/actions.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAmDvD,eAAO,MAAM,wBAAwB;;;;;;;iBAenC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;iBAU9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;iBAa7B,CAAC;AAGH,eAAO,MAAM,oBAAoB;;iBAM/B,CAAC;AAGH,eAAO,MAAM,4BAA4B;;;iBAcvC,CAAC;AAiCH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,EAC/C,MAAM,EAAE,cAAc;;;;;;GAgBvB;AAkFD,wBAAsB,aAAa,CACjC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,EAC1C,MAAM,EAAE,cAAc;;;;;;GA8BvB;AA8GD,wBAAsB,YAAY,CAChC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,EACzC,MAAM,EAAE,cAAc;;;;;;GA8BvB;AAOD,wBAAsB,cAAc,CAClC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,EAC3C,MAAM,EAAE,cAAc;;;;;;GAqCvB;AAyED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,EACnD,MAAM,EAAE,cAAc;;;;;;GAwDvB"}
|
package/dist/tools/chat.d.ts
CHANGED
|
@@ -37,9 +37,21 @@ export declare function getConversationMessages(input: z.input<typeof getConvers
|
|
|
37
37
|
}[];
|
|
38
38
|
isError: boolean;
|
|
39
39
|
}>;
|
|
40
|
+
export declare const FREE_CONVERSATION_LABEL = "Free: your first conversation";
|
|
41
|
+
export declare const FREE_CONVERSATION_ENDED_NOTICE = "Your free first conversation has ended; messages now use credits.";
|
|
42
|
+
export type ChatAnswerCost = {
|
|
43
|
+
free: false;
|
|
44
|
+
credits: number;
|
|
45
|
+
} | {
|
|
46
|
+
free: true;
|
|
47
|
+
label: string;
|
|
48
|
+
messagesLeft: number;
|
|
49
|
+
notice?: string;
|
|
50
|
+
};
|
|
40
51
|
export declare function parseUiMessageStream(raw: string): {
|
|
41
52
|
reply: string;
|
|
42
53
|
toolsUsed: string[];
|
|
54
|
+
cost: ChatAnswerCost | null;
|
|
43
55
|
};
|
|
44
56
|
export declare function sendChatMessage(input: z.input<typeof sendChatMessageSchema>, client: FloadApiClient): Promise<{
|
|
45
57
|
isError?: boolean | undefined;
|
package/dist/tools/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/tools/chat.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,eAAO,MAAM,uBAAuB;;iBAQlC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;iBAKxC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;iBAehC,CAAC;AASH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,EAC9C,MAAM,EAAE,cAAc;;;;;;;;;;;;GAgCvB;AAKD,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,EACpD,MAAM,EAAE,cAAc;;;;;;;;;;;;GA+BvB;
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/tools/chat.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,eAAO,MAAM,uBAAuB;;iBAQlC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;iBAKxC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;iBAehC,CAAC;AASH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,EAC9C,MAAM,EAAE,cAAc;;;;;;;;;;;;GAgCvB;AAKD,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,EACpD,MAAM,EAAE,cAAc;;;;;;;;;;;;GA+BvB;AAQD,eAAO,MAAM,uBAAuB,kCAAkC,CAAC;AACvE,eAAO,MAAM,8BAA8B,sEAC0B,CAAC;AAOtE,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA6BzE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7B,CA0BA;AAOD,wBAAsB,eAAe,CACnC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,EAC5C,MAAM,EAAE,cAAc;;;;;;GAoFvB"}
|
package/dist/tools/index.js
CHANGED
|
@@ -279,7 +279,9 @@ async function getReviews(input, client) {
|
|
|
279
279
|
hasReply: hasReply(review),
|
|
280
280
|
replySource: review.replySource ?? null,
|
|
281
281
|
hasDraft: review.hasDraft ?? false,
|
|
282
|
-
reply: review.developerResponse ? typeof review.developerResponse === "object" ? review.developerResponse.response : review.developerResponse : review.reply || null
|
|
282
|
+
reply: review.developerResponse ? typeof review.developerResponse === "object" ? review.developerResponse.response : review.developerResponse : review.reply || null,
|
|
283
|
+
// FLO-2571: where an App Store reply stands at Apple.
|
|
284
|
+
replyPublication: typeof review.developerResponse === "object" ? review.developerResponse?.publication ?? null : null
|
|
283
285
|
}))
|
|
284
286
|
})
|
|
285
287
|
}
|
|
@@ -1216,7 +1218,10 @@ var listPendingActionsSchema = z8.object({
|
|
|
1216
1218
|
limit: z8.number().int().min(1).max(100).default(50).describe("Maximum number of actions to return")
|
|
1217
1219
|
});
|
|
1218
1220
|
var approveActionSchema = z8.object({
|
|
1219
|
-
actionId: z8.string().describe("The inbox item ID to approve (from list_pending_actions)")
|
|
1221
|
+
actionId: z8.string().describe("The inbox item ID to approve (from list_pending_actions)"),
|
|
1222
|
+
wholeGroup: z8.boolean().optional().describe(
|
|
1223
|
+
"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."
|
|
1224
|
+
)
|
|
1220
1225
|
});
|
|
1221
1226
|
var rejectActionSchema = z8.object({
|
|
1222
1227
|
actionId: z8.string().describe("The inbox item ID to reject (from list_pending_actions)"),
|
|
@@ -1307,6 +1312,13 @@ async function commandItem(client, itemId, intent, reason) {
|
|
|
1307
1312
|
}
|
|
1308
1313
|
};
|
|
1309
1314
|
}
|
|
1315
|
+
function approveMessage(command, applied2, result) {
|
|
1316
|
+
if (!applied2) return refusedMessage(result);
|
|
1317
|
+
if (command === "acknowledge") return "Acknowledged.";
|
|
1318
|
+
if (result?.alreadyLive)
|
|
1319
|
+
return "Already live: the store already shows this change, so nothing was sent. The item is done.";
|
|
1320
|
+
return "Approved. Fload delivers it after a short undo window; the inbox shows where it is.";
|
|
1321
|
+
}
|
|
1310
1322
|
function refusedMessage(result) {
|
|
1311
1323
|
const said = result?.error ?? "The approval could not be recorded.";
|
|
1312
1324
|
const check = result?.policyRefusal?.check;
|
|
@@ -1314,6 +1326,10 @@ function refusedMessage(result) {
|
|
|
1314
1326
|
}
|
|
1315
1327
|
async function approveAction(input, client) {
|
|
1316
1328
|
try {
|
|
1329
|
+
if (input.wholeGroup) {
|
|
1330
|
+
const grouped = await approveGroup(client, input.actionId);
|
|
1331
|
+
if (grouped) return grouped;
|
|
1332
|
+
}
|
|
1317
1333
|
const { command, result } = await commandItem(
|
|
1318
1334
|
client,
|
|
1319
1335
|
input.actionId,
|
|
@@ -1327,7 +1343,7 @@ async function approveAction(input, client) {
|
|
|
1327
1343
|
command,
|
|
1328
1344
|
result: result?.result ?? "unknown",
|
|
1329
1345
|
...result?.error ? { error: result.error } : {},
|
|
1330
|
-
message:
|
|
1346
|
+
message: approveMessage(command, applied2, result),
|
|
1331
1347
|
item: result?.item
|
|
1332
1348
|
},
|
|
1333
1349
|
!applied2
|
|
@@ -1336,6 +1352,80 @@ async function approveAction(input, client) {
|
|
|
1336
1352
|
return toolError(error);
|
|
1337
1353
|
}
|
|
1338
1354
|
}
|
|
1355
|
+
async function groupOf(client, item) {
|
|
1356
|
+
if (!item.proposalBatch || item.status !== "needs_approval") return [item];
|
|
1357
|
+
const isSibling = (other) => typeof other === "object" && other !== null && other.status === "needs_approval" && other.proposalBatch === item.proposalBatch && other.assetId === item.assetId && other.id !== item.id;
|
|
1358
|
+
const siblings = [];
|
|
1359
|
+
let cursor;
|
|
1360
|
+
do {
|
|
1361
|
+
const response = await client.get("/api/actions/items", {
|
|
1362
|
+
view: "open",
|
|
1363
|
+
limit: 100,
|
|
1364
|
+
...item.assetId ? { assetId: item.assetId } : {},
|
|
1365
|
+
...cursor ? { cursor } : {}
|
|
1366
|
+
});
|
|
1367
|
+
siblings.push(...(response.items ?? []).filter(isSibling));
|
|
1368
|
+
cursor = response.nextCursor;
|
|
1369
|
+
} while (cursor);
|
|
1370
|
+
return [item, ...siblings];
|
|
1371
|
+
}
|
|
1372
|
+
async function approveGroup(client, actionId) {
|
|
1373
|
+
const detail = await client.get(
|
|
1374
|
+
`/api/actions/items/${encodeURIComponent(actionId)}`
|
|
1375
|
+
);
|
|
1376
|
+
if (!detail.item) throw new Error("Action not found");
|
|
1377
|
+
const group = await groupOf(client, detail.item);
|
|
1378
|
+
if (group.length <= 1) return null;
|
|
1379
|
+
const approvable = group.filter(
|
|
1380
|
+
(item) => item.allowedCommands?.includes("approve")
|
|
1381
|
+
);
|
|
1382
|
+
const skipped = group.filter((item) => !approvable.includes(item)).map((item) => item.id);
|
|
1383
|
+
if (approvable.length === 0)
|
|
1384
|
+
return toolText(
|
|
1385
|
+
{
|
|
1386
|
+
success: false,
|
|
1387
|
+
actionId,
|
|
1388
|
+
skipped,
|
|
1389
|
+
message: "Nothing in this card can be approved right now."
|
|
1390
|
+
},
|
|
1391
|
+
true
|
|
1392
|
+
);
|
|
1393
|
+
const answer = await client.postForAnswer(
|
|
1394
|
+
"/api/actions/commands",
|
|
1395
|
+
{
|
|
1396
|
+
command: "approve",
|
|
1397
|
+
idempotencyKey: `mcp:approve-group:${actionId}:${randomUUID()}`,
|
|
1398
|
+
targets: approvable.map((item) => ({
|
|
1399
|
+
itemId: item.id,
|
|
1400
|
+
...item.currentRevisionId ? { revisionId: item.currentRevisionId } : {}
|
|
1401
|
+
}))
|
|
1402
|
+
}
|
|
1403
|
+
);
|
|
1404
|
+
const results = (answer.body?.results ?? []).map((result) => ({
|
|
1405
|
+
itemId: result.itemId,
|
|
1406
|
+
result: result.result,
|
|
1407
|
+
...result.error ? {
|
|
1408
|
+
error: publicMcpErrorMessage(
|
|
1409
|
+
result.error,
|
|
1410
|
+
"Fload could not apply this change."
|
|
1411
|
+
)
|
|
1412
|
+
} : {}
|
|
1413
|
+
}));
|
|
1414
|
+
const approved = results.filter(
|
|
1415
|
+
(r) => r.result === "applied" || r.result === "replayed"
|
|
1416
|
+
).length;
|
|
1417
|
+
return toolText(
|
|
1418
|
+
{
|
|
1419
|
+
success: approved > 0,
|
|
1420
|
+
actionId,
|
|
1421
|
+
approved,
|
|
1422
|
+
results,
|
|
1423
|
+
...skipped.length ? { skipped } : {},
|
|
1424
|
+
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."
|
|
1425
|
+
},
|
|
1426
|
+
approved === 0
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1339
1429
|
async function rejectAction(input, client) {
|
|
1340
1430
|
try {
|
|
1341
1431
|
const { command, result } = await commandItem(
|
|
@@ -1777,9 +1867,26 @@ async function getConversationMessages(input, client) {
|
|
|
1777
1867
|
};
|
|
1778
1868
|
}
|
|
1779
1869
|
}
|
|
1870
|
+
var FREE_CONVERSATION_LABEL = "Free: your first conversation";
|
|
1871
|
+
var FREE_CONVERSATION_ENDED_NOTICE = "Your free first conversation has ended; messages now use credits.";
|
|
1872
|
+
function answerCostOf(data) {
|
|
1873
|
+
if (!data || typeof data !== "object") return null;
|
|
1874
|
+
const usage = data;
|
|
1875
|
+
const free = usage.freeConversation;
|
|
1876
|
+
if (free && typeof free.messagesLeft === "number") {
|
|
1877
|
+
return {
|
|
1878
|
+
free: true,
|
|
1879
|
+
label: FREE_CONVERSATION_LABEL,
|
|
1880
|
+
messagesLeft: free.messagesLeft,
|
|
1881
|
+
...free.ended === true ? { notice: FREE_CONVERSATION_ENDED_NOTICE } : {}
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
return typeof usage.credits === "number" ? { free: false, credits: usage.credits } : null;
|
|
1885
|
+
}
|
|
1780
1886
|
function parseUiMessageStream(raw) {
|
|
1781
1887
|
let reply = "";
|
|
1782
1888
|
const toolsUsed = [];
|
|
1889
|
+
let cost = null;
|
|
1783
1890
|
for (const line of raw.split("\n")) {
|
|
1784
1891
|
if (!line.startsWith("data:")) continue;
|
|
1785
1892
|
const payload = line.slice(5).trim();
|
|
@@ -1790,11 +1897,13 @@ function parseUiMessageStream(raw) {
|
|
|
1790
1897
|
reply += String(event.delta ?? event.textDelta ?? "");
|
|
1791
1898
|
} else if (typeof event.type === "string" && event.type === "tool-input-start" && typeof event.toolName === "string") {
|
|
1792
1899
|
toolsUsed.push(event.toolName);
|
|
1900
|
+
} else if (event.type === "data-usage") {
|
|
1901
|
+
cost = answerCostOf(event.data) ?? cost;
|
|
1793
1902
|
}
|
|
1794
1903
|
} catch {
|
|
1795
1904
|
}
|
|
1796
1905
|
}
|
|
1797
|
-
return { reply, toolsUsed };
|
|
1906
|
+
return { reply, toolsUsed, cost };
|
|
1798
1907
|
}
|
|
1799
1908
|
async function sendChatMessage(input, client) {
|
|
1800
1909
|
try {
|
|
@@ -1835,7 +1944,7 @@ async function sendChatMessage(input, client) {
|
|
|
1835
1944
|
};
|
|
1836
1945
|
}
|
|
1837
1946
|
const raw = await client.postStream("/api/chat", body);
|
|
1838
|
-
const { reply, toolsUsed } = parseUiMessageStream(raw);
|
|
1947
|
+
const { reply, toolsUsed, cost } = parseUiMessageStream(raw);
|
|
1839
1948
|
return {
|
|
1840
1949
|
content: [
|
|
1841
1950
|
{
|
|
@@ -1844,6 +1953,8 @@ async function sendChatMessage(input, client) {
|
|
|
1844
1953
|
conversationId,
|
|
1845
1954
|
reply: reply || "The assistant returned no text response.",
|
|
1846
1955
|
toolsUsed,
|
|
1956
|
+
// FLO-2669: the credits the answer used, or that it was free.
|
|
1957
|
+
...cost ? { cost } : {},
|
|
1847
1958
|
tip: "Pass this conversationId to continue the conversation or to get_conversation_messages for the full transcript."
|
|
1848
1959
|
})
|
|
1849
1960
|
}
|
|
@@ -1917,7 +2028,7 @@ function registerTools(server, client, options = {}) {
|
|
|
1917
2028
|
tool(
|
|
1918
2029
|
"get_reviews",
|
|
1919
2030
|
"Get reviews",
|
|
1920
|
-
|
|
2031
|
+
'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.',
|
|
1921
2032
|
getReviewsSchema,
|
|
1922
2033
|
getReviews,
|
|
1923
2034
|
{ readOnlyHint: true, openWorldHint: false }
|
|
@@ -2175,13 +2286,15 @@ function registerTools(server, client, options = {}) {
|
|
|
2175
2286
|
tool(
|
|
2176
2287
|
"send_chat_message",
|
|
2177
2288
|
"Send chat message",
|
|
2178
|
-
"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.",
|
|
2289
|
+
"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).",
|
|
2179
2290
|
sendChatMessageSchema,
|
|
2180
2291
|
sendChatMessage,
|
|
2181
2292
|
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
2182
2293
|
);
|
|
2183
2294
|
}
|
|
2184
2295
|
export {
|
|
2296
|
+
FREE_CONVERSATION_ENDED_NOTICE,
|
|
2297
|
+
FREE_CONVERSATION_LABEL,
|
|
2185
2298
|
approveAction,
|
|
2186
2299
|
approveActionSchema,
|
|
2187
2300
|
checkActionNow,
|