@50arms/platform-mcp 0.1.494 → 0.1.496

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.
@@ -74,7 +74,6 @@ 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();
78
77
  }
79
78
  else if (outcome.status === 401) {
80
79
  return stopOnRefusal(deps);
@@ -244,7 +244,6 @@ async function runBeatLoop(deps) {
244
244
  });
245
245
  if (outcome.status === 200) {
246
246
  deps.log(`beat ok at ${beatAt.toISOString()}`);
247
- deps.landingWake();
248
247
  } else if (outcome.status === 401) {
249
248
  return stopOnRefusal(deps);
250
249
  } else {
@@ -842,61 +841,6 @@ function createSystemLeftoverTracker(log, run = runCommand, platform = process.p
842
841
  });
843
842
  }
844
843
 
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
-
900
844
  // src/machine-toolkit/deadline.ts
901
845
  var realScheduler = (fire, ms) => {
902
846
  const timer = setTimeout(fire, ms);
@@ -909,13 +853,13 @@ import {
909
853
  chmodSync,
910
854
  existsSync as existsSync2,
911
855
  mkdirSync,
912
- readFileSync as readFileSync4,
856
+ readFileSync as readFileSync3,
913
857
  renameSync,
914
858
  statSync,
915
859
  writeFileSync
916
860
  } from "node:fs";
917
861
  import { homedir as homedir2 } from "node:os";
918
- import { dirname, join as join3 } from "node:path";
862
+ import { dirname, join as join2 } from "node:path";
919
863
  var MACHINE_DAEMON_DIR_NAME = ".danxbot";
920
864
  function createStatusWriter(write) {
921
865
  let current = {
@@ -935,25 +879,25 @@ function createStatusWriter(write) {
935
879
  return { beat: merge, report: merge };
936
880
  }
937
881
  function danxbotHome() {
938
- return join3(homedir2(), MACHINE_DAEMON_DIR_NAME);
882
+ return join2(homedir2(), MACHINE_DAEMON_DIR_NAME);
939
883
  }
940
884
  function daemonConfigPath(home = danxbotHome()) {
941
- return join3(home, "machine-daemon.json");
885
+ return join2(home, "machine-daemon.json");
942
886
  }
943
887
  function daemonStatusPath(home = danxbotHome()) {
944
- return join3(home, "machine-daemon-status.json");
888
+ return join2(home, "machine-daemon-status.json");
945
889
  }
946
890
  function daemonRefreshMarkerPath(home = danxbotHome()) {
947
- return join3(home, "machine-daemon-refresh.json");
891
+ return join2(home, "machine-daemon-refresh.json");
948
892
  }
949
893
  function daemonLogPath(home = danxbotHome()) {
950
- return join3(home, "machine-daemon.log");
894
+ return join2(home, "machine-daemon.log");
951
895
  }
952
896
  function daemonBundleDir(home = danxbotHome()) {
953
- return join3(home, "machine-daemon");
897
+ return join2(home, "machine-daemon");
954
898
  }
955
899
  function toolkitBundlePath(home = danxbotHome()) {
956
- return join3(daemonBundleDir(home), "machine-toolkit.js");
900
+ return join2(daemonBundleDir(home), "machine-toolkit.js");
957
901
  }
958
902
  function writeOwnerOnlyJson(file, value) {
959
903
  mkdirSync(dirname(file), { recursive: true });
@@ -968,7 +912,7 @@ function writeOwnerOnlyJson(file, value) {
968
912
  }
969
913
  function readJsonIfPresent(file) {
970
914
  if (!existsSync2(file)) return null;
971
- return JSON.parse(readFileSync4(file, "utf8"));
915
+ return JSON.parse(readFileSync3(file, "utf8"));
972
916
  }
973
917
  var DAEMON_LOG_MAX_BYTES = 1024 * 1024;
974
918
  function createDaemonLog(file, now = () => /* @__PURE__ */ new Date(), maxBytes = DAEMON_LOG_MAX_BYTES) {
@@ -1087,20 +1031,20 @@ var ContractViolation = class extends Error {
1087
1031
  }
1088
1032
  };
1089
1033
  var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
1090
- var join4 = (path, key) => path === "" ? key : `${path}.${key}`;
1034
+ var join3 = (path, key) => path === "" ? key : `${path}.${key}`;
1091
1035
  function objectAt(v, path, fail) {
1092
1036
  if (!isObject(v)) return fail(path, "must be an object");
1093
1037
  return v;
1094
1038
  }
1095
1039
  function exactKeys(o, path, keys, fail) {
1096
- for (const k of keys) if (!(k in o)) fail(join4(path, k), "is required");
1040
+ for (const k of keys) if (!(k in o)) fail(join3(path, k), "is required");
1097
1041
  for (const k of Object.keys(o))
1098
- if (!keys.includes(k)) fail(join4(path, k), "is not part of the contract");
1042
+ if (!keys.includes(k)) fail(join3(path, k), "is not part of the contract");
1099
1043
  }
1100
1044
  function stringAt(o, key, path, fail) {
1101
1045
  const v = o[key];
1102
1046
  if (typeof v !== "string" || v === "")
1103
- return fail(join4(path, key), "must be a non-empty string");
1047
+ return fail(join3(path, key), "must be a non-empty string");
1104
1048
  return v;
1105
1049
  }
1106
1050
  function listAt(v, path, fail) {
@@ -1112,7 +1056,7 @@ function checkItem(v, path, extra, fail) {
1112
1056
  exactKeys(o, path, ["id", "detail", ...extra], fail);
1113
1057
  stringAt(o, "id", path, fail);
1114
1058
  if (typeof o.detail !== "string")
1115
- fail(join4(path, "detail"), "must be a string");
1059
+ fail(join3(path, "detail"), "must be a string");
1116
1060
  for (const k of extra) stringAt(o, k, path, fail);
1117
1061
  }
1118
1062
  function checkItems(v, path, extra, fail) {
@@ -1203,7 +1147,7 @@ var VALIDATORS = {
1203
1147
  if (step.status !== "done" && step.status !== "skipped" && step.status !== "failed")
1204
1148
  fail(`${path}.status`, "must be 'done', 'skipped' or 'failed'");
1205
1149
  if (typeof step.detail !== "string")
1206
- fail(join4(path, "detail"), "must be a string");
1150
+ fail(join3(path, "detail"), "must be a string");
1207
1151
  });
1208
1152
  },
1209
1153
  "label-check"(o, fail) {
@@ -1506,8 +1450,6 @@ async function runDaemonProcess() {
1506
1450
  pid: process.pid,
1507
1451
  installed: () => existsSync3(daemonConfigPath()),
1508
1452
  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 }),
1511
1453
  reporter: createReporter({
1512
1454
  config,
1513
1455
  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.494",
615
+ false ? void 0 : "0.1.496",
616
616
  readOwnManifest
617
617
  );
618
618
  function envelope(now) {
@@ -5,7 +5,9 @@ export const GET_ROUTE_BOARD_SCOPE = [
5
5
  ["/api/agents/:agentId/halt-history", "refuse"],
6
6
  ["/api/audit-events", "refuse"],
7
7
  ["/api/behavior-events", "refuse"],
8
+ ["/api/behavior-events/:event/attachments", "refuse"],
8
9
  ["/api/behavior-policies", "refuse"],
10
+ ["/api/behavior-policy-groups", "refuse"],
9
11
  ["/api/boards", "refuse"],
10
12
  ["/api/boards/:boardId", "refuse"],
11
13
  ["/api/boards/:boardId/context-cost", "refuse"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@50arms/platform-mcp",
3
- "version": "0.1.494",
3
+ "version": "0.1.496",
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",
@@ -1,57 +0,0 @@
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
- }