@50arms/platform-mcp 0.1.485 → 0.1.488

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.
@@ -60,6 +60,7 @@ import { appVersionOf } from "./app-version.js";
60
60
  import { boardStampOf, isReadRoute, takesBoardInBody, } from "./route-board-scope.js";
61
61
  import { assertVersionFloorSatisfied, MCP_MIN_VERSION_HEADER, MCP_VERSION_HEADER, readOwnVersion, } from "./version-floor.js";
62
62
  import { PLUGIN_BACKGROUND_HEADER } from "./session-options.js";
63
+ import { currentToolUseId, TOOL_USE_ID_HEADER } from "./tool-use.js";
63
64
  import { boundRequest } from "./request-bound.js";
64
65
  import { backoffAt, REQUEST_POLICY, } from "./request-policy.js";
65
66
  import { DashboardReachability } from "./dashboard-reachability.js";
@@ -199,6 +200,11 @@ export class DashboardHttpClient {
199
200
  if (args.background === true) {
200
201
  headers[PLUGIN_BACKGROUND_HEADER] = "1";
201
202
  }
203
+ // DX-7761: the Claude Code tool use an agent's call serves (`tool-use.ts`), so the dashboard can tell which context made it, the main thread or one sub-agent. This process's own requests serve none.
204
+ const toolUseId = caller === "agent" ? currentToolUseId() : undefined;
205
+ if (toolUseId !== undefined) {
206
+ headers[TOOL_USE_ID_HEADER] = toolUseId;
207
+ }
202
208
  let payload;
203
209
  if (args.rawBody !== undefined) {
204
210
  if (args.body !== undefined)
package/dist/index.js CHANGED
@@ -116,6 +116,7 @@ import { danxbotApiExamplesText } from "./danxbot-api-examples.js";
116
116
  import { assertWithinTextLimit } from "./text-limit.js";
117
117
  import { callbackRoute, registerLifecycleTools, presentCallbacksFromEnv, } from "./lifecycle.js";
118
118
  import { LEGACY_TOOL_NAMES, TOOL_ACCESS } from "./tool-access.js";
119
+ import { duringToolUse } from "./tool-use.js";
119
120
  import { ToolAccessSync, ToolSurface } from "./tool-surface.js";
120
121
  import { PermissionWatch } from "./permission-watch.js";
121
122
  import { AgentGate, isAgentGateOpenCall, isAgentGateOpenSpec, onlyAgentProposalRoutes, } from "./agent-gate.js";
@@ -451,32 +452,37 @@ const agentGate = new AgentGate();
451
452
  * profile). It was 3,916 characters and Claude Code delivered the first
452
453
  * 2,048, so both rules were cut from every session. `assertWithinTextLimit`
453
454
  * below refuses a block that would be cut again. Behaviour only, no rationale.
455
+ *
456
+ * DX-7620 (PLAN-149) — EVIDENCE names the Evidence record routes so a session finds them without its role text; the
457
+ * other paragraphs were tightened to make room under the limit.
454
458
  */
455
459
  const SERVER_INSTRUCTIONS = `\
456
- \`50arms_api\` is your primary channel to the dashboard: every card, plan, Slack and dispatch-callback job (ending
457
- yours too) is a call to it. Find a route with \`50arms_api_list\`. Read its exact shape with
458
- \`50arms_api_spec\` before the first call to any route you have not called before; never guess a body.
460
+ Every card, plan, Slack and dispatch-callback job is a \`50arms_api\` call. Find a route with \`50arms_api_list\`;
461
+ read its shape with \`50arms_api_spec\` before your first call; never guess a body.
459
462
 
460
- RESOURCES. Most collections take GET (list) and POST (create); a single resource (\`<collection>/<id>\`) takes
461
- GET, PATCH or PUT (send only the fields you change) and DELETE. A card is edited at
462
- \`PATCH /api/issues/<id>/edit\`. A card get or list answers the compact row, a list one page of 50 with
463
- \`total\` (page with \`limit\` and \`offset\`). Name each other field or relation you need in the \`fields\` query
464
- tree. \`GET /api/resources/<resource>/fields\` lists the names.
463
+ RESOURCES. Most collections take GET and POST; \`<collection>/<id>\` takes GET, PATCH or PUT (changed fields only)
464
+ and DELETE. A card read answers the
465
+ compact row, a list 50 per page with \`total\` (\`limit\`, \`offset\`); name any other field or relation in the
466
+ \`fields\` tree (\`GET /api/resources/<resource>/fields\` lists them).
465
467
 
466
- STALE HASH. A write to contested text sends back the \`content_hash\` or \`base_hash\` you read. A stale content write is
467
- never refused: \`collided\` says what it met, so re-read. Only 409 \`merge_base_unknown\` is: reapply your
468
- change to the text and hash it returns. Settings and sign-offs still refuse a stale hash: re-read and retry.
468
+ STALE HASH. A contested-text write sends back the \`content_hash\` or \`base_hash\` you read. A stale one is never refused
469
+ (\`collided\` says what it met: re-read), except 409 \`merge_base_unknown\`: reapply your change to the text and
470
+ hash it returns. Settings and sign-offs refuse a stale hash: re-read, retry.
469
471
 
470
- REFUSALS. A 4xx body is \`{error, ...}\`, and its other fields name the fix: \`offending_keys\`, \`failed_gate\`,
472
+ REFUSALS. A 4xx body's other fields name the fix: \`offending_keys\`, \`failed_gate\`,
471
473
  \`unresolved_items\`, \`did_you_mean\`.
472
474
 
475
+ EVIDENCE. Before you find out how something works, read the Evidence records on it (a card's \`evidence_records\`):
476
+ a starting point, never a finding. Record one at \`/api/issues/<id>/evidence-records\` on the card it is about (the
477
+ card-type rules' \`Never a card\`) as the card procedure's "Evidence records" says. Cite \`EV-<n> · B<m>\`.
478
+
473
479
  WRITING STANDARD, for every title, summary, description, comment, problem, solution and plan record you write. The
474
480
  reader is new to the subject and will not read the code or docs: what you write is their documentation. Open with
475
481
  plain background (what it is, why, what is wrong or changes) before evidence.
476
482
  Define each term a newcomer would not know. Cite exact ids (\`PBLM-2757\`, not "problem 2757"), SHAs and paths. Card ids render with their plan; never add it. Be brief; never transcribe reasoning. A title or summary alone must let the reader decide.
477
483
 
478
- DESIGN. UI designs and style options go on the card they concern (\`mini_app_publish\`), never an Artifact or HTML page.
479
- Options are design states, never a chat or text question; a person chooses.
484
+ DESIGN. UI designs and style options go on their card (\`mini_app_publish\`) as design states a person chooses,
485
+ never an Artifact, HTML page, chat or text question.
480
486
  `;
481
487
  assertWithinTextLimit("the server instructions", SERVER_INSTRUCTIONS);
482
488
  export const server = new McpServer({
@@ -576,7 +582,9 @@ function strictTool(name, description, shape, cb) {
576
582
  if (!Object.hasOwn(TOOL_ACCESS, name)) {
577
583
  throw new Error(`the "${name}" tool has no entry in TOOL_ACCESS (tool-access.ts): declare what makes it usable`);
578
584
  }
579
- const tool = server.registerTool(name, { description, inputSchema: z.object(shape).strict() }, cb);
585
+ // DX-7761: every tool serves its call holding the tool use the call names (`params._meta`, the SDK's `extra._meta`), so each request it makes carries it (`tool-use.ts`).
586
+ const serve = cb;
587
+ const tool = server.registerTool(name, { description, inputSchema: z.object(shape).strict() }, ((args, extra) => duringToolUse(extra._meta, () => serve(args, extra))));
580
588
  registeredTools.set(name, tool);
581
589
  return tool;
582
590
  }
package/dist/listen.js CHANGED
@@ -523,25 +523,8 @@ export function invalidNudgeReason(value) {
523
523
  Number.isInteger(value.freeSlots) &&
524
524
  value.freeSlots >= 0))
525
525
  return "freeSlots is not a count or null";
526
- if (value.job !== null && !isNudgeJobRef(value.job))
527
- return "job is not a {queueItemId,batchId,repo,branch} object or null";
528
526
  return null;
529
527
  }
530
- /** DX-7843: whether `value` is a fix job a nudge names: positive queue item and batch ids, and the repo and branch as text. */
531
- function isNudgeJobRef(value) {
532
- return (isRecord(value) &&
533
- isPositiveId(value.queueItemId) &&
534
- isPositiveId(value.batchId) &&
535
- typeof value.repo === "string" &&
536
- value.repo !== "" &&
537
- typeof value.branch === "string" &&
538
- value.branch !== "");
539
- }
540
- /** DX-7843 - what a nudge says to the holder of a fix job: which job, and the moves that carry it on or give it up. */
541
- function fixJobPart(job) {
542
- const id = job.queueItemId;
543
- return `Your fix job ${id} (red landing batch ${job.batchId}, ${job.repo} → ${job.branch}) is still yours and every landing waits for it: continue it now. Read where it stands with GET /api/dispatch-queue/${id}/fix, fix every failure forward on its fix branch in its worktree, check with \`make lock-rerun ITEM=${id}\`, then report with \`make lock-done ITEM=${id}\`. If you cannot work it, leave it with DELETE /api/dispatch-queue/${id}/take`;
544
- }
545
528
  function cardList(cards) {
546
529
  return cards.map((c) => `${c.id} "${c.title}"`).join(", ");
547
530
  }
@@ -604,9 +587,6 @@ export function formatNudgeLine(event) {
604
587
  const parts = [];
605
588
  if (event.unreadied.length > 0)
606
589
  parts.push(`${FILED_NOT_READIED_LABEL} (${FILED_NOT_READIED_INSTRUCTION}): ${cardList(event.unreadied)}`);
607
- // DX-7843 (AC 6, DEC-1248) - the holder of a fix job is told to continue it, and never that it lost it: the job stays its own while it is connected. The instruction leads, so a cut never takes it.
608
- if (event.job !== null)
609
- parts.push(fixJobPart(event.job));
610
590
  // DX-7127 - the label and instruction come before the ids, like the filed part, so a cut never takes the instruction.
611
591
  if (event.reviewable.length > 0)
612
592
  parts.push(`${REVIEWABLE_LABEL} (${REVIEWABLE_INSTRUCTION}; ${freeSlotsSentence(event.freeSlots)}): ${reviewableCardList(event.reviewable)}`);
@@ -726,6 +706,39 @@ export function formatLeftoverProcessesLine(event) {
726
706
  throw new Error(`malformed leftover-processes message: ${invalid}`);
727
707
  return pacingRelayLine(event.text);
728
708
  }
709
+ /** Why a job nudge cannot be read, or `null` when it can. */
710
+ export function invalidJobNudgeReason(value) {
711
+ if (!isRecord(value))
712
+ return "the job nudge is not an object";
713
+ if (typeof value.text !== "string" || value.text.trim() === "")
714
+ return "text is empty";
715
+ if (!Array.isArray(value.queue_item_ids) ||
716
+ !value.queue_item_ids.every((id) => Number.isSafeInteger(id)))
717
+ return "queue_item_ids is not a list of queue item ids";
718
+ return null;
719
+ }
720
+ /** The one readable line for a job nudge: the dashboard's text, on one line, cut like a pacing line. Throws, naming the fault, on a malformed message. */
721
+ export function formatJobNudgeLine(event) {
722
+ const invalid = invalidJobNudgeReason(event);
723
+ if (invalid !== null)
724
+ throw new Error(`malformed job nudge: ${invalid}`);
725
+ return pacingRelayLine(event.text);
726
+ }
727
+ /** Why a queue notice cannot be read, or `null` when it can. */
728
+ export function invalidQueueNoticeReason(value) {
729
+ if (!isRecord(value))
730
+ return "the queue notice is not an object";
731
+ if (typeof value.text !== "string" || value.text.trim() === "")
732
+ return "text is empty";
733
+ return null;
734
+ }
735
+ /** The one readable line for a queue notice: the dashboard's text, on one line, cut like a pacing line. Throws, naming the fault, on a malformed message. */
736
+ export function formatQueueNoticeLine(event) {
737
+ const invalid = invalidQueueNoticeReason(event);
738
+ if (invalid !== null)
739
+ throw new Error(`malformed queue notice: ${invalid}`);
740
+ return pacingRelayLine(event.text);
741
+ }
729
742
  /** Why an owed-comment message cannot be read, or `null` when it can. */
730
743
  export function invalidOwedCommentReason(value) {
731
744
  if (!isRecord(value))
@@ -1094,6 +1107,12 @@ export async function runListener(options, deps) {
1094
1107
  // DX-7107 - processes this session started and left running: a reminder, non-urgent and session-scoped like an owed comment.
1095
1108
  if (message.event === "leftover_processes")
1096
1109
  return emitAdvisory(message, "leftover-processes message", invalidLeftoverProcessesReason, (p) => formatLeftoverProcessesLine(p), () => ({ source: "leftover_processes" }), "session");
1110
+ // DX-7725 - the queued job this session holds, told to continue it: advisory like a nudge, session-scoped (the session may hold a job bound to neither plan nor card).
1111
+ if (message.event === "job_nudge")
1112
+ return emitAdvisory(message, "job nudge", invalidJobNudgeReason, (p) => formatJobNudgeLine(p), () => ({ source: "job_nudge" }), "session");
1113
+ // DX-7786 (DEC-1352) - the dispatch queue's notice about a job no agent can take: a text record, non-urgent and session-scoped, with no `offer`.
1114
+ if (message.event === "queue_notice")
1115
+ return emitAdvisory(message, "queue notice", invalidQueueNoticeReason, (p) => formatQueueNoticeLine(p), () => ({ source: "queue_notice" }), "session");
1097
1116
  // DX-7748 (DEC-1340): a queued job's frame names it as `job`, which the record carries as `offer` for the plugin to take.
1098
1117
  if (message.event === "assignment")
1099
1118
  return emitAdvisory(message, "assignment message", invalidQueuedAssignmentReason, (p) => formatAssignmentLine(p), () => ({ source: "assignment" }), "session", (p) => offerOfAssignment(p));
@@ -74,6 +74,7 @@ export async function runBeatLoop(deps) {
74
74
  });
75
75
  if (outcome.status === 200) {
76
76
  deps.log(`beat ok at ${beatAt.toISOString()}`);
77
+ deps.landingWake();
77
78
  }
78
79
  else if (outcome.status === 401) {
79
80
  return stopOnRefusal(deps);
@@ -0,0 +1,57 @@
1
+ import { readdirSync, readFileSync, rmSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { errMessage } from "../machine-toolkit/errors.js";
4
+ /** What every landing wake file's name ends in. */
5
+ export const LANDING_WAKE_SUFFIX = ".dashboard-down.json";
6
+ /** The wake file of the landing runner of `repo`, relative to `~/.danxbot/`. */
7
+ export const landingWakeFileName = (repo) => `landing-runner-${repo}${LANDING_WAKE_SUFFIX}`;
8
+ function parseWake(text) {
9
+ const v = JSON.parse(text);
10
+ if (v === null ||
11
+ typeof v.command !== "string" ||
12
+ v.command === "" ||
13
+ typeof v.cwd !== "string" ||
14
+ !Array.isArray(v.args) ||
15
+ !v.args.every((a) => typeof a === "string"))
16
+ throw new Error("it has no command, args and cwd");
17
+ return {
18
+ command: v.command,
19
+ args: v.args,
20
+ cwd: v.cwd,
21
+ why: typeof v.why === "string" ? v.why : "",
22
+ written_at: typeof v.written_at === "string" ? v.written_at : "",
23
+ };
24
+ }
25
+ /**
26
+ * Runs the command of every wake file in `dir` and removes the file. `spawnFn` is typed `typeof spawn` so the no-window scan checks the call here. A file that cannot be read or whose command cannot be started is logged and
27
+ * removed too: the daemon says it once and the runner that fails again writes a new one, where leaving it would repeat the same line every beat.
28
+ */
29
+ export function wakeLandingRunners(opts) {
30
+ let names;
31
+ try {
32
+ names = readdirSync(opts.dir).filter((n) => n.startsWith("landing-runner-") && n.endsWith(LANDING_WAKE_SUFFIX));
33
+ }
34
+ catch {
35
+ return;
36
+ }
37
+ for (const name of names) {
38
+ const file = join(opts.dir, name);
39
+ try {
40
+ const wake = parseWake(readFileSync(file, "utf8"));
41
+ rmSync(file, { force: true });
42
+ opts.log(`the dashboard answers again: starting the landing runner that ended without it (${name}; ${wake.why})`);
43
+ const child = opts.spawnFn(wake.command, [...wake.args], {
44
+ cwd: wake.cwd,
45
+ detached: true,
46
+ stdio: "ignore",
47
+ windowsHide: true,
48
+ });
49
+ child.once("error", (err) => opts.log(`the landing runner of ${name} could not be started: ${errMessage(err)}`));
50
+ child.unref();
51
+ }
52
+ catch (err) {
53
+ rmSync(file, { force: true });
54
+ opts.log(`the landing wake file ${name} could not be used (${errMessage(err)}): removed; the next runner that ends on an unreachable dashboard writes a new one`);
55
+ }
56
+ }
57
+ }
@@ -244,6 +244,7 @@ async function runBeatLoop(deps) {
244
244
  });
245
245
  if (outcome.status === 200) {
246
246
  deps.log(`beat ok at ${beatAt.toISOString()}`);
247
+ deps.landingWake();
247
248
  } else if (outcome.status === 401) {
248
249
  return stopOnRefusal(deps);
249
250
  } else {
@@ -841,6 +842,61 @@ function createSystemLeftoverTracker(log, run = runCommand, platform = process.p
841
842
  });
842
843
  }
843
844
 
845
+ // src/machine-daemon/landing-wake.ts
846
+ import { readdirSync as readdirSync2, readFileSync as readFileSync3, rmSync } from "node:fs";
847
+ import { join as join2 } from "node:path";
848
+ var LANDING_WAKE_SUFFIX = ".dashboard-down.json";
849
+ function parseWake(text) {
850
+ const v = JSON.parse(text);
851
+ if (v === null || typeof v.command !== "string" || v.command === "" || typeof v.cwd !== "string" || !Array.isArray(v.args) || !v.args.every((a) => typeof a === "string"))
852
+ throw new Error("it has no command, args and cwd");
853
+ return {
854
+ command: v.command,
855
+ args: v.args,
856
+ cwd: v.cwd,
857
+ why: typeof v.why === "string" ? v.why : "",
858
+ written_at: typeof v.written_at === "string" ? v.written_at : ""
859
+ };
860
+ }
861
+ function wakeLandingRunners(opts) {
862
+ let names;
863
+ try {
864
+ names = readdirSync2(opts.dir).filter(
865
+ (n) => n.startsWith("landing-runner-") && n.endsWith(LANDING_WAKE_SUFFIX)
866
+ );
867
+ } catch {
868
+ return;
869
+ }
870
+ for (const name of names) {
871
+ const file = join2(opts.dir, name);
872
+ try {
873
+ const wake = parseWake(readFileSync3(file, "utf8"));
874
+ rmSync(file, { force: true });
875
+ opts.log(
876
+ `the dashboard answers again: starting the landing runner that ended without it (${name}; ${wake.why})`
877
+ );
878
+ const child = opts.spawnFn(wake.command, [...wake.args], {
879
+ cwd: wake.cwd,
880
+ detached: true,
881
+ stdio: "ignore",
882
+ windowsHide: true
883
+ });
884
+ child.once(
885
+ "error",
886
+ (err) => opts.log(
887
+ `the landing runner of ${name} could not be started: ${errMessage(err)}`
888
+ )
889
+ );
890
+ child.unref();
891
+ } catch (err) {
892
+ rmSync(file, { force: true });
893
+ opts.log(
894
+ `the landing wake file ${name} could not be used (${errMessage(err)}): removed; the next runner that ends on an unreachable dashboard writes a new one`
895
+ );
896
+ }
897
+ }
898
+ }
899
+
844
900
  // src/machine-toolkit/deadline.ts
845
901
  var realScheduler = (fire, ms) => {
846
902
  const timer = setTimeout(fire, ms);
@@ -853,13 +909,13 @@ import {
853
909
  chmodSync,
854
910
  existsSync as existsSync2,
855
911
  mkdirSync,
856
- readFileSync as readFileSync3,
912
+ readFileSync as readFileSync4,
857
913
  renameSync,
858
914
  statSync,
859
915
  writeFileSync
860
916
  } from "node:fs";
861
917
  import { homedir as homedir2 } from "node:os";
862
- import { dirname, join as join2 } from "node:path";
918
+ import { dirname, join as join3 } from "node:path";
863
919
  var MACHINE_DAEMON_DIR_NAME = ".danxbot";
864
920
  function createStatusWriter(write) {
865
921
  let current = {
@@ -879,25 +935,25 @@ function createStatusWriter(write) {
879
935
  return { beat: merge, report: merge };
880
936
  }
881
937
  function danxbotHome() {
882
- return join2(homedir2(), MACHINE_DAEMON_DIR_NAME);
938
+ return join3(homedir2(), MACHINE_DAEMON_DIR_NAME);
883
939
  }
884
940
  function daemonConfigPath(home = danxbotHome()) {
885
- return join2(home, "machine-daemon.json");
941
+ return join3(home, "machine-daemon.json");
886
942
  }
887
943
  function daemonStatusPath(home = danxbotHome()) {
888
- return join2(home, "machine-daemon-status.json");
944
+ return join3(home, "machine-daemon-status.json");
889
945
  }
890
946
  function daemonRefreshMarkerPath(home = danxbotHome()) {
891
- return join2(home, "machine-daemon-refresh.json");
947
+ return join3(home, "machine-daemon-refresh.json");
892
948
  }
893
949
  function daemonLogPath(home = danxbotHome()) {
894
- return join2(home, "machine-daemon.log");
950
+ return join3(home, "machine-daemon.log");
895
951
  }
896
952
  function daemonBundleDir(home = danxbotHome()) {
897
- return join2(home, "machine-daemon");
953
+ return join3(home, "machine-daemon");
898
954
  }
899
955
  function toolkitBundlePath(home = danxbotHome()) {
900
- return join2(daemonBundleDir(home), "machine-toolkit.js");
956
+ return join3(daemonBundleDir(home), "machine-toolkit.js");
901
957
  }
902
958
  function writeOwnerOnlyJson(file, value) {
903
959
  mkdirSync(dirname(file), { recursive: true });
@@ -912,7 +968,7 @@ function writeOwnerOnlyJson(file, value) {
912
968
  }
913
969
  function readJsonIfPresent(file) {
914
970
  if (!existsSync2(file)) return null;
915
- return JSON.parse(readFileSync3(file, "utf8"));
971
+ return JSON.parse(readFileSync4(file, "utf8"));
916
972
  }
917
973
  var DAEMON_LOG_MAX_BYTES = 1024 * 1024;
918
974
  function createDaemonLog(file, now = () => /* @__PURE__ */ new Date(), maxBytes = DAEMON_LOG_MAX_BYTES) {
@@ -1031,20 +1087,20 @@ var ContractViolation = class extends Error {
1031
1087
  }
1032
1088
  };
1033
1089
  var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
1034
- var join3 = (path, key) => path === "" ? key : `${path}.${key}`;
1090
+ var join4 = (path, key) => path === "" ? key : `${path}.${key}`;
1035
1091
  function objectAt(v, path, fail) {
1036
1092
  if (!isObject(v)) return fail(path, "must be an object");
1037
1093
  return v;
1038
1094
  }
1039
1095
  function exactKeys(o, path, keys, fail) {
1040
- for (const k of keys) if (!(k in o)) fail(join3(path, k), "is required");
1096
+ for (const k of keys) if (!(k in o)) fail(join4(path, k), "is required");
1041
1097
  for (const k of Object.keys(o))
1042
- if (!keys.includes(k)) fail(join3(path, k), "is not part of the contract");
1098
+ if (!keys.includes(k)) fail(join4(path, k), "is not part of the contract");
1043
1099
  }
1044
1100
  function stringAt(o, key, path, fail) {
1045
1101
  const v = o[key];
1046
1102
  if (typeof v !== "string" || v === "")
1047
- return fail(join3(path, key), "must be a non-empty string");
1103
+ return fail(join4(path, key), "must be a non-empty string");
1048
1104
  return v;
1049
1105
  }
1050
1106
  function listAt(v, path, fail) {
@@ -1056,7 +1112,7 @@ function checkItem(v, path, extra, fail) {
1056
1112
  exactKeys(o, path, ["id", "detail", ...extra], fail);
1057
1113
  stringAt(o, "id", path, fail);
1058
1114
  if (typeof o.detail !== "string")
1059
- fail(join3(path, "detail"), "must be a string");
1115
+ fail(join4(path, "detail"), "must be a string");
1060
1116
  for (const k of extra) stringAt(o, k, path, fail);
1061
1117
  }
1062
1118
  function checkItems(v, path, extra, fail) {
@@ -1147,7 +1203,7 @@ var VALIDATORS = {
1147
1203
  if (step.status !== "done" && step.status !== "skipped" && step.status !== "failed")
1148
1204
  fail(`${path}.status`, "must be 'done', 'skipped' or 'failed'");
1149
1205
  if (typeof step.detail !== "string")
1150
- fail(join3(path, "detail"), "must be a string");
1206
+ fail(join4(path, "detail"), "must be a string");
1151
1207
  });
1152
1208
  },
1153
1209
  "label-check"(o, fail) {
@@ -1450,6 +1506,8 @@ async function runDaemonProcess() {
1450
1506
  pid: process.pid,
1451
1507
  installed: () => existsSync3(daemonConfigPath()),
1452
1508
  readBearer: readBearerOnDisk,
1509
+ // DX-7849 (R-32): a 200 beat is the dashboard answering again, which starts the landing runners that ended without it.
1510
+ landingWake: () => wakeLandingRunners({ dir: danxbotHome(), spawnFn: spawn, log }),
1453
1511
  reporter: createReporter({
1454
1512
  config,
1455
1513
  runHealth: () => runHealthChild({
@@ -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.485",
615
+ false ? void 0 : "0.1.488",
616
616
  readOwnManifest
617
617
  );
618
618
  function envelope(now) {
@@ -92,7 +92,6 @@ export const GET_ROUTE_BOARD_SCOPE = [
92
92
  ["/api/test-runs/machine-runs", "refuse"],
93
93
  ["/api/test-runs/main-health", "refuse"],
94
94
  ["/api/test-runs/over-target", "refuse"],
95
- ["/api/test-runs/quarantines", "refuse"],
96
95
  ["/api/test-runs/run-kind-stats", "refuse"],
97
96
  ["/api/test-runs/slowest", "refuse"],
98
97
  ["/api/test-runs/stale-window", "refuse"],
@@ -106,7 +105,6 @@ export const GET_ROUTE_BOARD_SCOPE = [
106
105
  ["/api/worker/dispatches/non-terminal", "refuse"],
107
106
  ["/api/worker/dispatches/recent-signal-failures", "refuse"],
108
107
  ["/api/worker/test-runs/file-times", "refuse"],
109
- ["/api/worker/test-runs/quarantines", "refuse"],
110
108
  ["/api/workers", "refuse"],
111
109
  ];
112
110
  /** DX-5337 - the routes that read the card's board from `body.board` only: the client fills a dispatch's board in there and sends no `?board=`. */
@@ -0,0 +1,24 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ /**
3
+ * DX-7761 (PLAN-134, DEC-1318 v3) - the Claude Code tool use a request serves. Claude Code names it on every MCP `tools/call` it sends, as `params._meta["claudecode/toolUseId"]`, which the SDK hands a tool's handler as `extra._meta`. Every tool runs inside `duringToolUse`
4
+ * (`strictTool`, `index.ts`), so each request the agent's call makes carries it as `x-danx-tool-use-id` (`DashboardHttpClient`, `http-client.ts`); this process's own requests (`requestOwn`) never do. The dashboard reads it to tell which context made a call, the session's main
5
+ * thread or one sub-agent (`src/auth/tool-use-id.ts` there). A call that names no tool use (another client, an older Claude Code) sends no header, and the dashboard counts that context as unknown.
6
+ */
7
+ export const TOOL_USE_ID_META_KEY = "claudecode/toolUseId";
8
+ /** The header the dashboard reads it from (`TOOL_USE_ID_HEADER`, `src/auth/tool-use-id.ts`). */
9
+ export const TOOL_USE_ID_HEADER = "x-danx-tool-use-id";
10
+ const current = new AsyncLocalStorage();
11
+ /** The tool use a `tools/call`'s `_meta` names: a non-empty string, else `null`. */
12
+ export function toolUseIdOf(meta) {
13
+ const id = meta?.[TOOL_USE_ID_META_KEY];
14
+ return typeof id === "string" && id.trim() !== "" ? id.trim() : null;
15
+ }
16
+ /** Run `serve` (a tool's handler) holding the tool use its call's `_meta` names, so every request it makes carries it. */
17
+ export function duringToolUse(meta, serve) {
18
+ const id = toolUseIdOf(meta);
19
+ return id === null ? serve() : current.run(id, serve);
20
+ }
21
+ /** The tool use the code running now serves, or `undefined` outside any tool call. */
22
+ export function currentToolUseId() {
23
+ return current.getStore();
24
+ }
@@ -41,6 +41,8 @@ export function isUrgent(record) {
41
41
  case "content_compaction":
42
42
  case "owed_comment":
43
43
  case "leftover_processes":
44
+ case "job_nudge":
45
+ case "queue_notice":
44
46
  case "digest":
45
47
  case "relay_notice":
46
48
  case "fault":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@50arms/platform-mcp",
3
- "version": "0.1.485",
3
+ "version": "0.1.488",
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",