@50arms/platform-mcp 0.1.561 → 0.1.563
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/index.js +41 -20
- package/dist/machine-toolkit.js +1 -1
- package/dist/result-limit.js +21 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -556,9 +556,14 @@ function jsonResult(value) {
|
|
|
556
556
|
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
557
557
|
};
|
|
558
558
|
}
|
|
559
|
-
/**
|
|
560
|
-
|
|
561
|
-
|
|
559
|
+
/**
|
|
560
|
+
* DX-4400 / DX-6117 — a dashboard route's result, its body delivered as a file when over `MCP_MAX_RESULT_CHARS`,
|
|
561
|
+
* or always as a file when the caller asked for one (`reply_to_file`, DX-8226).
|
|
562
|
+
*/
|
|
563
|
+
function boundedJsonResult(result, opts) {
|
|
564
|
+
return {
|
|
565
|
+
content: [{ type: "text", text: boundedResultText(result, opts) }],
|
|
566
|
+
};
|
|
562
567
|
}
|
|
563
568
|
/** DX-4523 - every tool `strictTool` registered, by name: what `ToolSurface` switches. */
|
|
564
569
|
const registeredTools = new Map();
|
|
@@ -682,6 +687,11 @@ renamedTool("50arms_api",
|
|
|
682
687
|
.min(1)
|
|
683
688
|
.optional()
|
|
684
689
|
.describe("Absolute path of an image file (png, jpg, webp, svg; max 1 MB) sent as the raw body instead of `body`."),
|
|
690
|
+
// DX-8226 — a caller that must not carry the reply inline (a plugin hook; Claude Code refuses a tool result over its limit): the answer is always the file form.
|
|
691
|
+
reply_to_file: z
|
|
692
|
+
.boolean()
|
|
693
|
+
.optional()
|
|
694
|
+
.describe("Write the reply's JSON body to a local file and answer only where it is, whatever its size: the tool result is `{ok, status, reply_file: {path, bytes, chars, sha256, instruction}}`."),
|
|
685
695
|
// DX-7947 (AC 76323): the agent's sign-offs of the behavior rules a write needs; where they go (the body, or the header of a `body_file` write) is `placeSignoffs`'s.
|
|
686
696
|
behavior_rule_signoffs: behaviorSignoffsSchema
|
|
687
697
|
.optional()
|
|
@@ -716,13 +726,16 @@ renamedTool("50arms_api",
|
|
|
716
726
|
// DX-6089: `GET /api/plan-sessions/me/role`'s role text lands in a local file; the reply names it.
|
|
717
727
|
const spilled = spillRoleInstruction(result);
|
|
718
728
|
// DX-6556: a manual pickup that connected the session is a connect, whatever tool carried it.
|
|
719
|
-
if (isPickupConnect(spilled))
|
|
720
|
-
|
|
729
|
+
if (isPickupConnect(spilled)) {
|
|
730
|
+
// DX-8226 (82640, DEC-2598): the connect's answer reaches the caller through the same bounded path as every other `50arms_api` answer, with what the connect adds beside `body`.
|
|
731
|
+
const outcome = await finishConnect(calledAs, spilled, false);
|
|
732
|
+
return boundedJsonResult(outcome.kind === "connected" ? outcome.answer : outcome.result, { toFile: args.reply_to_file === true });
|
|
733
|
+
}
|
|
721
734
|
// DX-7110: an answer that says 50 Arms is unreachable is not followed by a health read of it; either way the notices no relay carried ride on it.
|
|
722
735
|
const answered = isUnreachableAnswer(spilled)
|
|
723
736
|
? spilled
|
|
724
737
|
: await listenerReminder.apply(spilled);
|
|
725
|
-
return boundedJsonResult(mergeReminders(answered, client.reachability.takePending()));
|
|
738
|
+
return boundedJsonResult(mergeReminders(answered, client.reachability.takePending()), { toFile: args.reply_to_file === true });
|
|
726
739
|
});
|
|
727
740
|
// ---------------- 50arms_api_list (DX-3465 A5, PLN-11 R-25) ----------------
|
|
728
741
|
renamedTool("50arms_api_list",
|
|
@@ -1180,7 +1193,11 @@ async (args) => {
|
|
|
1180
1193
|
if (result.status === 401 && access.dropKey(result)) {
|
|
1181
1194
|
return accessReply(await access.ensureAccess(args.title, args.role), "the dashboard no longer accepted this session's key");
|
|
1182
1195
|
}
|
|
1183
|
-
|
|
1196
|
+
const outcome = await finishConnect("session_connect", result, args.disconnect === true);
|
|
1197
|
+
// R-25: `session_connect` answers inline and whole, never through the bounded path.
|
|
1198
|
+
if (outcome.kind === "blocked")
|
|
1199
|
+
return jsonResult(withAppVersion(outcome.result.body, outcome.result));
|
|
1200
|
+
return jsonResult(outcome.kind === "left" ? outcome.result : outcome.answer);
|
|
1184
1201
|
});
|
|
1185
1202
|
// DX-6735: started by each connect that holds an agent, and never awaited by it.
|
|
1186
1203
|
const reportCheckoutDocsRoot = createCheckoutDocsRootReporter(() => client, process.cwd());
|
|
@@ -1196,27 +1213,31 @@ async function finishConnect(tool, result, disconnect) {
|
|
|
1196
1213
|
if (!disconnect) {
|
|
1197
1214
|
agentGate.record(result.body);
|
|
1198
1215
|
if (agentGate.current() !== null)
|
|
1199
|
-
return
|
|
1216
|
+
return { kind: "blocked", result };
|
|
1200
1217
|
void reportCheckoutDocsRoot();
|
|
1201
1218
|
}
|
|
1202
1219
|
if (disconnect) {
|
|
1203
1220
|
removeSessionConnectionAfterLeave(result, config.session?.id);
|
|
1204
|
-
return
|
|
1221
|
+
return { kind: "left", result };
|
|
1205
1222
|
}
|
|
1206
1223
|
const connection = access.connection();
|
|
1207
1224
|
if (connection === null)
|
|
1208
1225
|
throw new Error(`${tool}: no credential after a successful connect`);
|
|
1209
|
-
return
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1226
|
+
return {
|
|
1227
|
+
kind: "connected",
|
|
1228
|
+
// DEC-2598: what the MCP adds to a connect's answer sits in the envelope beside `body`, as `app_version` does.
|
|
1229
|
+
answer: {
|
|
1230
|
+
...result,
|
|
1231
|
+
dashboard: connectedDashboard(),
|
|
1232
|
+
...recordSessionConnectionAfterConnect(result, {
|
|
1233
|
+
sessionId: config.session?.id,
|
|
1234
|
+
projectKey: projectKeyOf(process.cwd()),
|
|
1235
|
+
dashboardUrl: connection.dashboardUrl,
|
|
1236
|
+
source: connection.source,
|
|
1237
|
+
fingerprint: connection.fingerprint,
|
|
1238
|
+
}),
|
|
1239
|
+
},
|
|
1240
|
+
};
|
|
1220
1241
|
}
|
|
1221
1242
|
// ---------------- plan_events_wait (DX-4233) ----------------
|
|
1222
1243
|
strictTool("plan_events_wait",
|
package/dist/machine-toolkit.js
CHANGED
|
@@ -612,7 +612,7 @@ var readOwnManifest = () => JSON.parse(
|
|
|
612
612
|
readFileSync(new URL("../../package.json", import.meta.url), "utf8")
|
|
613
613
|
).version;
|
|
614
614
|
var TOOLKIT_VERSION = resolveToolkitVersion(
|
|
615
|
-
false ? void 0 : "0.1.
|
|
615
|
+
false ? void 0 : "0.1.563",
|
|
616
616
|
readOwnManifest
|
|
617
617
|
);
|
|
618
618
|
function envelope(now) {
|
package/dist/result-limit.js
CHANGED
|
@@ -4,35 +4,39 @@ import path from "node:path";
|
|
|
4
4
|
import { writeFileDurable } from "./durable-write.js";
|
|
5
5
|
/**
|
|
6
6
|
* DX-4400 — the most characters one `50arms_api`, `50arms_api_spec` or `50arms_api_list` result may carry
|
|
7
|
-
* back to the agent. Every character is context the agent pays for on every later call,
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* back to the agent. Every character is context the agent pays for on every later call. DX-8226: measured, Claude
|
|
8
|
+
* Code refused a 63,012-character result (EV-192), so this cap sits below that size and a reply above it is written
|
|
9
|
+
* to a file instead. Claude Code's documented default for an MCP tool result (25,000 tokens) is not verified in
|
|
10
|
+
* this repo's code. Hex-heavy JSON runs near 2 characters per token, which is why the cap is in characters.
|
|
11
|
+
* A deliberate, narrow exception to PLAN-11 rule R-25 (verbatim forwarding): `session_connect` and the lifecycle
|
|
12
|
+
* tools never pass here.
|
|
10
13
|
*/
|
|
11
|
-
export const MCP_MAX_RESULT_CHARS =
|
|
14
|
+
export const MCP_MAX_RESULT_CHARS = 40_000;
|
|
12
15
|
const FILE_INSTRUCTION = "The reply was over the inline limit, so its body is this file, whole: read it with Read (in parts with offset and limit when it is long), or grep it.";
|
|
13
16
|
/**
|
|
14
|
-
* The text the agent receives for `result`: its compact JSON when that fits `MCP_MAX_RESULT_CHARS
|
|
15
|
-
* `
|
|
16
|
-
* `<tmp>/danx-api/<
|
|
17
|
-
*
|
|
17
|
+
* The text the agent receives for `result`: its compact JSON when that fits `MCP_MAX_RESULT_CHARS` and the caller
|
|
18
|
+
* did not ask for a file (`toFile`, DX-8226), otherwise the envelope with `reply_file:{path, bytes, chars, sha256, instruction}`
|
|
19
|
+
* in place of `body`: the body written whole to `<tmp>/danx-api/<first 16 hex of sha256>.json` (DX-6117, as `docs_read` and
|
|
20
|
+
* the role text do). `sha256` is the full hex digest of the file's bytes. Never truncates, never forwards a part. Every other
|
|
21
|
+
* field of the envelope (`ok` and `status`, so a write that already committed is still reported as committed, `app_version`, and
|
|
22
|
+
* what the MCP adds beside `body` such as a connect's `dashboard`, DEC-2598) stays beside `reply_file`; the file holds only the route's reply.
|
|
18
23
|
*/
|
|
19
|
-
export function boundedResultText(result, deps = {}) {
|
|
24
|
+
export function boundedResultText(result, options = {}, deps = {}) {
|
|
20
25
|
const text = JSON.stringify(result);
|
|
21
|
-
if (text.length <= MCP_MAX_RESULT_CHARS)
|
|
26
|
+
if (!options.toFile && text.length <= MCP_MAX_RESULT_CHARS)
|
|
22
27
|
return text;
|
|
23
|
-
const body =
|
|
24
|
-
const
|
|
28
|
+
const { body: replyBody, ...envelope } = result;
|
|
29
|
+
const body = JSON.stringify(replyBody);
|
|
30
|
+
const sha256 = createHash("sha256").update(body, "utf8").digest("hex");
|
|
31
|
+
const file = path.join(deps.tmpDir ?? os.tmpdir(), "danx-api", `${sha256.slice(0, 16)}.json`);
|
|
25
32
|
writeFileDurable(file, body);
|
|
26
33
|
return JSON.stringify({
|
|
27
|
-
|
|
28
|
-
status: result.status,
|
|
29
|
-
...(result.app_version === undefined
|
|
30
|
-
? {}
|
|
31
|
-
: { app_version: result.app_version }),
|
|
34
|
+
...envelope,
|
|
32
35
|
reply_file: {
|
|
33
36
|
path: file,
|
|
34
37
|
bytes: Buffer.byteLength(body, "utf8"),
|
|
35
38
|
chars: body.length,
|
|
39
|
+
sha256,
|
|
36
40
|
instruction: FILE_INSTRUCTION,
|
|
37
41
|
},
|
|
38
42
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@50arms/platform-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.563",
|
|
4
4
|
"description": "Stdio MCP server fronting the 50 Arms dashboard API for agents (operator sessions and dispatched workers alike): the generic 50arms_api/50arms_api_list/50arms_api_spec tools reach any route the caller's credential may call, plus dedicated agent-specific tools (session_connect, request_permission, attach_file, and 50arms_slack_reply) (DX-3465, PLN-11 R-25).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|