@50arms/platform-mcp 0.1.463 → 0.1.464

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.
@@ -8,13 +8,14 @@ import { withForbiddenHint } from "./forbidden-hint.js";
8
8
  * DX-4434: a refused call's `403 forbidden` gains its `request_permission` hint here, the ONE place it is added.
9
9
  */
10
10
  export function makeGuardedCalls(deps) {
11
+ // DX-7098: `foreignKey` - the call went out on a system job's key, so a 401 says nothing about the session's own key (`SessionAccess.guard`).
11
12
  const guardedCall = async (run, opts = {}) => {
12
13
  if (opts.gateOpen !== true) {
13
14
  const noAgent = agentGateHalt(deps.gate);
14
15
  if (noAgent !== null)
15
16
  return { halt: noAgent };
16
17
  }
17
- const guarded = await deps.access().guard(run);
18
+ const guarded = await deps.access().guard(run, { foreignKey: opts.foreignKey === true });
18
19
  return "halt" in guarded ? guarded : { result: withForbiddenHint(guarded.result) };
19
20
  };
20
21
  return { guardedCall };
package/dist/handlers.js CHANGED
@@ -152,7 +152,9 @@ async function readRawBodyFile(path, deps) {
152
152
  * route that used to attach a reminder to a deleted per-operation tool's
153
153
  * response still attaches it here, with zero special MCP-side plumbing).
154
154
  */
155
- export async function danxbotApi(client, args, deps = {}) {
155
+ export async function danxbotApi(client, args, deps = {},
156
+ // DX-7098: a system job's key (`job-key.ts`), never a model-supplied value: `DanxbotApiArgs` still carries no credential.
157
+ bearer) {
156
158
  // The file is checked and read BEFORE the request, so a bad path leaves nothing behind on the dashboard.
157
159
  const rawBody = args.body_file === undefined ? undefined : await readRawBodyFile(args.body_file, deps);
158
160
  return client.request({
@@ -169,6 +171,7 @@ export async function danxbotApi(client, args, deps = {}) {
169
171
  rawBody,
170
172
  board: args.board,
171
173
  background: args.background,
174
+ ...(bearer === undefined ? {} : { bearer }),
172
175
  });
173
176
  }
174
177
  // ---------------- 50arms_api_list (DX-3465 A5, PLN-11 R-25) ----------------
@@ -40,7 +40,7 @@ export class DashboardHttpClient {
40
40
  }
41
41
  const url = this.buildUrl(args.method, args.path, args.query, args.board, args.basePath);
42
42
  const headers = {
43
- Authorization: `Bearer ${this.config.token}`,
43
+ Authorization: `Bearer ${args.bearer ?? this.config.token}`,
44
44
  Accept: "application/json",
45
45
  };
46
46
  // DX-1398 Hop 3 (outbound) — stamp the cross-process trace at the SAME
package/dist/index.js CHANGED
@@ -88,6 +88,7 @@ import { SessionKeyUnusableError, deleteSessionKey } from "./session-key.js";
88
88
  import { SessionAccess } from "./session-access.js";
89
89
  import { PermissionRequests } from "./permission-request.js";
90
90
  import { makeGuardedCalls } from "./guarded-calls.js";
91
+ import { JobKeyHolder } from "./job-key.js";
91
92
  import { readOwnVersion } from "./version-floor.js";
92
93
  import { createCheckoutDocsRootReporter, readCheckoutRepo } from "./checkout-docs-root.js";
93
94
  import { isPickupConnect, projectKeyOf, recordSessionConnectionAfterConnect, removeSessionConnectionAfterLeave } from "./session-connection.js";
@@ -469,6 +470,8 @@ function accessReply(ready, note) {
469
470
  }
470
471
  // DX-4390 / DX-4434 / DX-5549 / DX-5550: every tool's dashboard call goes through `guardedCall` (the agent gate, then the sign-in halt; see `guarded-calls.ts`).
471
472
  const { guardedCall } = makeGuardedCalls({ access: () => access, gate: agentGate });
473
+ // DX-7098 - the key of a system job this session's sub-agent took: memory only; `50arms_api` sends the model's calls with it while it is held.
474
+ const jobKey = new JobKeyHolder((line) => console.error(line));
472
475
  /** DX-4390 — a tool's dashboard call behind the sign-in halt (and the 401 sign-out). */
473
476
  async function guardedJson(run) {
474
477
  const guarded = await guardedCall(run);
@@ -614,10 +617,15 @@ renamedTool("50arms_api",
614
617
  const refused = termsAcceptanceCallHalt(args, config.baseUrl);
615
618
  if (refused)
616
619
  return haltResult(refused);
617
- const guarded = await guardedCall(() => danxbotApi(client, args), { gateOpen: isAgentGateOpenCall(args.method, args.path) });
620
+ // DX-7098: while a system job's key is held the model's calls go out on it (never the take, never a hook's background call).
621
+ const bearer = jobKey.bearerFor(args);
622
+ const guarded = await guardedCall(() => danxbotApi(client, args, {}, bearer ?? undefined), {
623
+ gateOpen: isAgentGateOpenCall(args.method, args.path),
624
+ foreignKey: bearer !== null,
625
+ });
618
626
  if ("halt" in guarded)
619
627
  return haltResult(guarded.halt);
620
- const result = guarded.result;
628
+ const result = jobKey.afterCall(args, guarded.result, bearer !== null);
621
629
  const halt = termsHaltFor(result);
622
630
  if (halt)
623
631
  return haltResult(halt);
@@ -0,0 +1,45 @@
1
+ /** The take route, `POST /api/issues/:id/system-job`. */
2
+ const TAKE_PATH = /^\/api\/issues\/[^/?]+\/system-job(?:\?.*)?$/;
3
+ /** The dispatch-complete call that ends a job. */
4
+ const COMPLETE_PATH = "/api/dispatch-callbacks/complete";
5
+ /** Stands in for `job_key` in the answer the model reads. */
6
+ export const JOB_KEY_HELD_NOTE = "held by the platform MCP: your 50arms_api calls now go out on the job's key until the dispatch-complete call answers";
7
+ export class JobKeyHolder {
8
+ log;
9
+ key = null;
10
+ constructor(log = () => undefined) {
11
+ this.log = log;
12
+ }
13
+ /** Whether a job key is held now. */
14
+ held() {
15
+ return this.key !== null;
16
+ }
17
+ /** The bearer `call` goes out with: the job key while one is held, except for a take and a background call; `null` means the session's own key. */
18
+ bearerFor(call) {
19
+ if (this.key === null || call.background === true || isTake(call))
20
+ return null;
21
+ return this.key;
22
+ }
23
+ /**
24
+ * After `call` answered `result` (`viaJobKey`: it went out on the job key): a take's answer gives up its `job_key` to this holder and the model reads the
25
+ * answer without it; the job key ends on a 2xx dispatch-complete answer or a 401 to a call made with it. Answers the result the model reads.
26
+ */
27
+ afterCall(call, result, viaJobKey) {
28
+ if (viaJobKey && (result.status === 401 || (result.ok && call.method === "POST" && pathOf(call) === COMPLETE_PATH))) {
29
+ this.key = null;
30
+ this.log(`[platform-mcp] the system job's key ended (${result.status} on ${call.method} ${pathOf(call)}); calls go out on the session's key again`);
31
+ return result;
32
+ }
33
+ if (!isTake(call) || !result.ok)
34
+ return result;
35
+ const body = result.body;
36
+ const jobKey = body?.job_key;
37
+ if (typeof jobKey !== "string" || jobKey === "")
38
+ throw new Error("[platform-mcp] a system-job take answered no job_key");
39
+ this.key = jobKey;
40
+ this.log(`[platform-mcp] took a system job (dispatch ${String(body?.dispatch_id)}); the model's calls go out on its key`);
41
+ return { ...result, body: { ...body, job_key: JOB_KEY_HELD_NOTE } };
42
+ }
43
+ }
44
+ const pathOf = (call) => call.path.split("?", 1)[0];
45
+ const isTake = (call) => call.method === "POST" && TAKE_PATH.test(call.path);
@@ -443,7 +443,7 @@ function resolveToolkitVersion(stamped, readManifest) {
443
443
  return stamped ?? readManifest();
444
444
  }
445
445
  var readOwnManifest = () => JSON.parse(readFileSync2(new URL("../../package.json", import.meta.url), "utf8")).version;
446
- var TOOLKIT_VERSION = resolveToolkitVersion(false ? void 0 : "0.1.463", readOwnManifest);
446
+ var TOOLKIT_VERSION = resolveToolkitVersion(false ? void 0 : "0.1.464", readOwnManifest);
447
447
  function envelope(now) {
448
448
  return { contract_version: CONTRACT_VERSION, toolkit_version: TOOLKIT_VERSION, profile: PROFILE, measured_at: now.toISOString() };
449
449
  }
@@ -76,6 +76,11 @@ export const GET_ROUTE_BOARD_SCOPE = [
76
76
  ["/api/team/quality/gates", "refuse"],
77
77
  ["/api/team/quality/people", "refuse"],
78
78
  ["/api/team/roles", "refuse"],
79
+ ["/api/test-runs/audit/daily", "refuse"],
80
+ ["/api/test-runs/audit/file", "refuse"],
81
+ ["/api/test-runs/audit/files", "refuse"],
82
+ ["/api/test-runs/audit/run", "refuse"],
83
+ ["/api/test-runs/audit/runs", "refuse"],
79
84
  ["/api/test-runs/backlog-snapshots/latest", "refuse"],
80
85
  ["/api/test-runs/file-times", "refuse"],
81
86
  ["/api/test-runs/main-health", "refuse"],
@@ -237,7 +237,7 @@ export class SessionAccess {
237
237
  * Run a dashboard call for a tool: halted while signed out, and signed out (key file deleted)
238
238
  * when the dashboard answers 401 to this session's key.
239
239
  */
240
- async guard(run) {
240
+ async guard(run, opts = {}) {
241
241
  const revokedHalt = this.revokedHalt();
242
242
  if (revokedHalt !== null)
243
243
  return { halt: revokedHalt };
@@ -246,6 +246,9 @@ export class SessionAccess {
246
246
  return { halt: SIGN_IN_HALT };
247
247
  }
248
248
  const result = await run();
249
+ // DX-7098: a call made on a system job's key (`job-key.ts`) is refused for that key alone: never the session's revoked halt or sign-out.
250
+ if (opts.foreignKey === true)
251
+ return { result };
249
252
  const refused = this.refusalHalt(result);
250
253
  if (refused !== null)
251
254
  return { halt: refused };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@50arms/platform-mcp",
3
- "version": "0.1.463",
3
+ "version": "0.1.464",
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",