@50arms/platform-mcp 0.1.464 → 0.1.465

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.
Files changed (66) hide show
  1. package/dist/access-request.js +19 -6
  2. package/dist/agent-gate.js +19 -5
  3. package/dist/board-id.js +8 -2
  4. package/dist/checkout-docs-root.js +10 -2
  5. package/dist/clear-control.js +18 -4
  6. package/dist/compaction-control.js +30 -7
  7. package/dist/credential.js +10 -2
  8. package/dist/danxbot-api-examples.js +20 -3
  9. package/dist/design-screenshot.js +22 -5
  10. package/dist/digest-hold.js +14 -3
  11. package/dist/docs-tools.js +46 -12
  12. package/dist/durable-write.js +10 -2
  13. package/dist/forbidden-hint.js +13 -2
  14. package/dist/guarded-calls.js +6 -2
  15. package/dist/handlers.js +66 -14
  16. package/dist/heartbeat-reporter.js +8 -3
  17. package/dist/http-client.js +4 -2
  18. package/dist/index.js +242 -80
  19. package/dist/job-key.js +3 -1
  20. package/dist/json-body.js +3 -1
  21. package/dist/key-revoked-halt.js +2 -1
  22. package/dist/leftover-wire.js +17 -4
  23. package/dist/lifecycle.js +11 -3
  24. package/dist/listen.js +242 -64
  25. package/dist/listener-reminder.js +8 -2
  26. package/dist/machine-daemon/autostart.js +16 -4
  27. package/dist/machine-daemon/beat.js +18 -4
  28. package/dist/machine-daemon/cli.js +15 -4
  29. package/dist/machine-daemon/install.js +33 -9
  30. package/dist/machine-daemon/leftovers.js +134 -30
  31. package/dist/machine-daemon/state.js +9 -3
  32. package/dist/machine-daemon.js +531 -128
  33. package/dist/machine-registration.js +27 -6
  34. package/dist/machine-secret.js +8 -3
  35. package/dist/machine-toolkit.js +377 -81
  36. package/dist/mini-app-build.js +19 -5
  37. package/dist/mini-app-checkout.js +38 -10
  38. package/dist/mini-app-output.js +22 -5
  39. package/dist/mini-app-publish.js +34 -11
  40. package/dist/mini-app-restore.js +30 -9
  41. package/dist/one-line.js +3 -1
  42. package/dist/permission-request.js +14 -3
  43. package/dist/permission-watch.js +10 -3
  44. package/dist/plan-events-relay.js +96 -19
  45. package/dist/plan-events-tool.js +9 -2
  46. package/dist/plugin-publish.js +23 -6
  47. package/dist/plugin-screenshot.js +18 -6
  48. package/dist/restart-notice.js +47 -15
  49. package/dist/result-limit.js +6 -1
  50. package/dist/role-instruction-file.js +16 -4
  51. package/dist/route-board-scope.js +6 -2
  52. package/dist/session-access.js +110 -32
  53. package/dist/session-connection.js +23 -7
  54. package/dist/session-control-file.js +1 -1
  55. package/dist/session-key.js +12 -4
  56. package/dist/session-options.js +6 -2
  57. package/dist/session-stats.js +2 -1
  58. package/dist/session-stream.js +81 -20
  59. package/dist/shutdown.js +3 -1
  60. package/dist/subagents-live.js +8 -2
  61. package/dist/terms-halt.js +4 -2
  62. package/dist/tool-access.js +17 -4
  63. package/dist/tool-surface.js +9 -2
  64. package/dist/transcript-lineage.js +5 -2
  65. package/dist/urgent-records.js +1 -0
  66. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -72,31 +72,31 @@
72
72
  * agent reads `body.error` + structured fields to decide next action.
73
73
  * 5xx and network failures throw — never silently swallowed.
74
74
  */
75
- import { MACHINE_DAEMON_SUBCOMMANDS, runMachineDaemonCommand } from "./machine-daemon/cli.js";
75
+ import { MACHINE_DAEMON_SUBCOMMANDS, runMachineDaemonCommand, } from "./machine-daemon/cli.js";
76
76
  import { isEntrypointModule } from "./entrypoint.js";
77
77
  import { compactionFilesIn } from "./compaction-control.js";
78
78
  import { clearFilesIn } from "./clear-control.js";
79
- import { PlanEventRelay, WAIT_MAX_MS, WAIT_MIN_MS } from "./plan-events-relay.js";
79
+ import { PlanEventRelay, WAIT_MAX_MS, WAIT_MIN_MS, } from "./plan-events-relay.js";
80
80
  import { READ_IDLE_TIMEOUT_MS } from "./listen.js";
81
- import { REQUEST_TIMEOUT_MS, realScheduleInterval, realSleep } from "./session-stream.js";
81
+ import { REQUEST_TIMEOUT_MS, realScheduleInterval, realSleep, } from "./session-stream.js";
82
82
  import { servePlanEventsWait } from "./plan-events-tool.js";
83
83
  import { lookupRestartNotice, RESTART_NOTICE_ARGS } from "./restart-notice.js";
84
84
  import { makeSessionStop, stopWhenSessionEnds } from "./shutdown.js";
85
- import { SUBAGENTS_LIVE_SUBCOMMAND, runSubagentsLiveCommand } from "./subagents-live.js";
86
- import { resolveBootCredential } from "./credential.js";
85
+ import { SUBAGENTS_LIVE_SUBCOMMAND, runSubagentsLiveCommand, } from "./subagents-live.js";
86
+ import { resolveBootCredential, } from "./credential.js";
87
87
  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
91
  import { JobKeyHolder } from "./job-key.js";
92
92
  import { readOwnVersion } from "./version-floor.js";
93
- import { createCheckoutDocsRootReporter, readCheckoutRepo } from "./checkout-docs-root.js";
94
- import { isPickupConnect, projectKeyOf, recordSessionConnectionAfterConnect, removeSessionConnectionAfterLeave } from "./session-connection.js";
93
+ import { createCheckoutDocsRootReporter, readCheckoutRepo, } from "./checkout-docs-root.js";
94
+ import { isPickupConnect, projectKeyOf, recordSessionConnectionAfterConnect, removeSessionConnectionAfterLeave, } from "./session-connection.js";
95
95
  import { createListenerReminder, isPlanConnectedOnThisMachine, } from "./listener-reminder.js";
96
96
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
97
97
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
98
98
  import { z } from "zod";
99
- import { boardRefArgSchema, parseBoardRefText, repoNameArgSchema } from "./board-id.js";
99
+ import { boardRefArgSchema, parseBoardRefText, repoNameArgSchema, } from "./board-id.js";
100
100
  import { DashboardHttpClient } from "./http-client.js";
101
101
  import { claimSessionAgent, sessionConnect, danxbotApi, danxbotApiList, danxbotApiSpec, attachFile, DANXBOT_API_METHODS, } from "./handlers.js";
102
102
  import { miniAppPublish } from "./mini-app-publish.js";
@@ -110,11 +110,11 @@ import { bodyValueSchema, queryValueSchema } from "./types.js";
110
110
  import { termsAcceptanceCallHalt, termsHaltFor } from "./terms-halt.js";
111
111
  import { danxbotApiExamplesText } from "./danxbot-api-examples.js";
112
112
  import { assertWithinTextLimit } from "./text-limit.js";
113
- import { registerLifecycleTools, presentCallbacksFromEnv } from "./lifecycle.js";
113
+ import { registerLifecycleTools, presentCallbacksFromEnv, } from "./lifecycle.js";
114
114
  import { LEGACY_TOOL_NAMES, TOOL_ACCESS } from "./tool-access.js";
115
115
  import { ToolAccessSync, ToolSurface } from "./tool-surface.js";
116
116
  import { PermissionWatch } from "./permission-watch.js";
117
- import { AgentGate, isAgentGateOpenCall, isAgentGateOpenSpec, onlyAgentProposalRoutes } from "./agent-gate.js";
117
+ import { AgentGate, isAgentGateOpenCall, isAgentGateOpenSpec, onlyAgentProposalRoutes, } from "./agent-gate.js";
118
118
  import { SYNC_ATTEMPTS, retryBounded } from "./bounded-retry.js";
119
119
  import { dashboardIdentity } from "./dashboard-identity.js";
120
120
  function readEnvOrDie(name) {
@@ -213,7 +213,11 @@ function boot() {
213
213
  });
214
214
  listenerReminder = createListenerReminder({
215
215
  sessionId: config.session?.id,
216
- fetchHealth: () => dashboardClient.requestOwn({ method: "GET", basePath: "", path: "/api/plan-sessions/me/listener-health" }),
216
+ fetchHealth: () => dashboardClient.requestOwn({
217
+ method: "GET",
218
+ basePath: "",
219
+ path: "/api/plan-sessions/me/listener-health",
220
+ }),
217
221
  isPlanConnected: isPlanConnectedOnThisMachine,
218
222
  now: Date.now,
219
223
  logLine: (line) => console.error(line),
@@ -239,7 +243,11 @@ function boot() {
239
243
  const connection = access.connection();
240
244
  return connection === null || session === undefined
241
245
  ? null
242
- : { dashboardUrl: connection.dashboardUrl, token: access.currentToken(), sessionId: session.id };
246
+ : {
247
+ dashboardUrl: connection.dashboardUrl,
248
+ token: access.currentToken(),
249
+ sessionId: session.id,
250
+ };
243
251
  },
244
252
  fetch: (input, init) => fetch(input, init),
245
253
  sleep: realSleep,
@@ -266,7 +274,11 @@ async function readKeyPermissions() {
266
274
  if (!access.isSignedIn())
267
275
  return { outcome: "no-key" };
268
276
  // DX-5076: this process reading its own key's permissions is not the agent acting.
269
- const guarded = await access.guard(() => client.requestOwn({ method: "GET", basePath: "", path: "/api/auth/permissions" }));
277
+ const guarded = await access.guard(() => client.requestOwn({
278
+ method: "GET",
279
+ basePath: "",
280
+ path: "/api/auth/permissions",
281
+ }));
270
282
  if ("halt" in guarded)
271
283
  return { outcome: "no-key" };
272
284
  const { result } = guarded;
@@ -275,8 +287,10 @@ async function readKeyPermissions() {
275
287
  if (!result.ok) {
276
288
  throw new Error(`GET /api/auth/permissions answered ${result.status}: ${JSON.stringify(result.body)}`);
277
289
  }
278
- const permissions = result.body?.permissions;
279
- if (!Array.isArray(permissions) || !permissions.every((p) => typeof p === "string")) {
290
+ const permissions = result.body
291
+ ?.permissions;
292
+ if (!Array.isArray(permissions) ||
293
+ !permissions.every((p) => typeof p === "string")) {
280
294
  throw new Error(`GET /api/auth/permissions answered without a permissions list: ${JSON.stringify(result.body)}`);
281
295
  }
282
296
  return { outcome: "held", permissions: new Set(permissions) };
@@ -298,7 +312,10 @@ function syncPolicy() {
298
312
  async function syncToolsWithPolicy() {
299
313
  const { attempts, fatal } = syncPolicy();
300
314
  try {
301
- await retryBounded(() => toolAccessSync.sync(), { attempts, sleep: sleepHoldingProcess });
315
+ await retryBounded(() => toolAccessSync.sync(), {
316
+ attempts,
317
+ sleep: sleepHoldingProcess,
318
+ });
302
319
  }
303
320
  catch (err) {
304
321
  if (fatal)
@@ -332,7 +349,13 @@ function adoptCreatedAgent(created) {
332
349
  console.error("agent created: no credential after the dashboard signed this session in; the local connection record was not written");
333
350
  }
334
351
  else {
335
- const recorded = recordSessionConnectionAfterConnect({ ok: true }, { sessionId: config.session?.id, projectKey: projectKeyOf(process.cwd()), dashboardUrl: connection.dashboardUrl, source: connection.source, fingerprint: connection.fingerprint });
352
+ const recorded = recordSessionConnectionAfterConnect({ ok: true }, {
353
+ sessionId: config.session?.id,
354
+ projectKey: projectKeyOf(process.cwd()),
355
+ dashboardUrl: connection.dashboardUrl,
356
+ source: connection.source,
357
+ fingerprint: connection.fingerprint,
358
+ });
336
359
  if (recorded.connection_record_error !== undefined)
337
360
  console.error(`agent created: ${recorded.connection_record_error}`);
338
361
  }
@@ -460,27 +483,44 @@ function connectedDashboard() {
460
483
  function accessReply(ready, note) {
461
484
  // the dashboard this session is on is named in the sign-in answer, so a session aimed at the wrong dashboard shows it before any write
462
485
  if (ready.signedIn)
463
- return jsonResult({ state: "signed_in", ...(note ? { note } : {}), dashboard: connectedDashboard() });
486
+ return jsonResult({
487
+ state: "signed_in",
488
+ ...(note ? { note } : {}),
489
+ dashboard: connectedDashboard(),
490
+ });
464
491
  // DX-4418: a person revoked this session's access: the one stop halt, verbatim, never a request.
465
492
  if (ready.halt !== undefined)
466
493
  return haltResult(ready.halt);
467
494
  // DX-6392: every access answer names the dashboard it is on, not only the signed-in one (AC 57978).
468
- const answer = { ...ready.answer, dashboard: connectedDashboard(), ...(note ? { note } : {}) };
469
- return ready.isError ? haltResult(JSON.stringify(answer)) : jsonResult(answer);
495
+ const answer = {
496
+ ...ready.answer,
497
+ dashboard: connectedDashboard(),
498
+ ...(note ? { note } : {}),
499
+ };
500
+ return ready.isError
501
+ ? haltResult(JSON.stringify(answer))
502
+ : jsonResult(answer);
470
503
  }
471
504
  // 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`).
472
- const { guardedCall } = makeGuardedCalls({ access: () => access, gate: agentGate });
505
+ const { guardedCall } = makeGuardedCalls({
506
+ access: () => access,
507
+ gate: agentGate,
508
+ });
473
509
  // 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
510
  const jobKey = new JobKeyHolder((line) => console.error(line));
475
511
  /** DX-4390 — a tool's dashboard call behind the sign-in halt (and the 401 sign-out). */
476
512
  async function guardedJson(run) {
477
513
  const guarded = await guardedCall(run);
478
- return "halt" in guarded ? haltResult(guarded.halt) : jsonResult(guarded.result);
514
+ return "halt" in guarded
515
+ ? haltResult(guarded.halt)
516
+ : jsonResult(guarded.result);
479
517
  }
480
518
  /** DX-4400 — `guardedJson` for the read tools whose answer can be a whole document: bounded. */
481
519
  async function guardedBoundedJson(run, opts) {
482
520
  const guarded = await guardedCall(run, opts);
483
- return "halt" in guarded ? haltResult(guarded.halt) : boundedJsonResult(guarded.result);
521
+ return "halt" in guarded
522
+ ? haltResult(guarded.halt)
523
+ : boundedJsonResult(guarded.result);
484
524
  }
485
525
  function jsonResult(value) {
486
526
  return {
@@ -608,7 +648,10 @@ renamedTool("50arms_api",
608
648
  .describe("Absolute path of an image file (png, jpg, webp, svg; max 1 MB) sent as the raw body instead of `body`."),
609
649
  ...boardField,
610
650
  // DX-5033 - sends x-danx-plugin-background (see DanxbotApiArgs.background); an agent setting it would hide its own calls from the pause and idle logic.
611
- background: z.boolean().optional().describe("Set only by plugin hooks; an agent never sets it."),
651
+ background: z
652
+ .boolean()
653
+ .optional()
654
+ .describe("Set only by plugin hooks; an agent never sets it."),
612
655
  },
613
656
  // DX-3997 — the result rides back verbatim, plus the dashboard's own `reminders[]` entries
614
657
  // for this plan-connected session (the server decides; `listener-reminder.ts` only relays).
@@ -640,7 +683,7 @@ renamedTool("50arms_api",
640
683
  renamedTool("50arms_api_list",
641
684
  // DX-3528 — the list is filtered by the same permission check every request takes.
642
685
  "Start here to find the route for any job: lists the dashboard API routes your credential may call, `{routes: " +
643
- "[\"METHOD /path/template\", ...]}`, the strings `50arms_api_spec` takes (`POST /api/issues/:id/transition`). A route " +
686
+ '["METHOD /path/template", ...]}`, the strings `50arms_api_spec` takes (`POST /api/issues/:id/transition`). A route ' +
644
687
  "not listed is not callable by you.", {},
645
688
  // DX-5765: with no agent held it lists exactly the two proposal routes an agent-less session may call.
646
689
  () => async () => {
@@ -663,7 +706,9 @@ renamedTool("50arms_api_spec",
663
706
  },
664
707
  // DX-5765: with no agent held it answers for the two proposal routes only; any other endpoint keeps the no-agent answer.
665
708
  () => async (args) => {
666
- return guardedBoundedJson(() => danxbotApiSpec(client, args), { gateOpen: isAgentGateOpenSpec(args.endpoints) });
709
+ return guardedBoundedJson(() => danxbotApiSpec(client, args), {
710
+ gateOpen: isAgentGateOpenSpec(args.endpoints),
711
+ });
667
712
  });
668
713
  // ---------------- attach_file (DX-3465 A4, checklist item 36140) ----------------
669
714
  //
@@ -676,24 +721,45 @@ renamedTool("50arms_api_spec",
676
721
  // — a role needs local-file-upload only when it deals with files an agent
677
722
  // might hold locally, e.g. the Slack recovery agent's CSV path).
678
723
  strictTool("attach_file", "Upload a LOCAL file. This server reads and uploads the bytes, so they never pass through your context. " +
679
- "`target: \"card\"` (default) attaches it to a card; `target: \"inline_image\"` uploads an image for a markdown body and replies `{url, markdown}` (below). The card attachment mirrors to the card's linked Trello card and Slack thread. 25 MB limit (413). " +
724
+ '`target: "card"` (default) attaches it to a card; `target: "inline_image"` uploads an image for a markdown body and replies `{url, markdown}` (below). The card attachment mirrors to the card\'s linked Trello card and Slack thread. 25 MB limit (413). ' +
680
725
  "Card target returns `{issue, attachment_id, url, thumbnail_url, is_primary}`: `url` is permanent, embed it in any " +
681
726
  "markdown field as `![description](url)` and it renders inline. Use it when a screenshot or file judges something faster than prose, or instead of pasting a " +
682
727
  "large CSV or log into a card field. " +
683
- "`target: \"inline_image\"` instead uploads a local png/jpeg/gif/webp/avif (25 MB) with NO card and returns `{url, markdown}`: put the " +
728
+ '`target: "inline_image"` instead uploads a local png/jpeg/gif/webp/avif (25 MB) with NO card and returns `{url, markdown}`: put the ' +
684
729
  "markdown in any markdown body, notably a `POST /api/feedback` body (`50arms_api`'s `body_file` sends one raw png/jpg/webp/svg of at most 1 MB to a route that takes a file; this tool adds the upload routes, gif/avif, and the 25 MB limit).", {
685
- target: z.enum(["card", "inline_image"]).optional().describe("`card` (default): attach to a card. `inline_image`: upload an image for a markdown body; takes only `path`."),
686
- card_id: z.string().min(1).optional().describe("The card id to attach the file to. Required for target `card`; not allowed with `inline_image`."),
687
- path: z.string().min(1).describe("Absolute local path on the machine this server runs on (`/tmp/a.png` or `C:\\x\\a.png`)."),
688
- filename: z.string().min(1).optional().describe("Override for the stored filename; default: path's basename."),
689
- content_type: z.string().min(1).optional().describe("Override for the stored MIME type; default: an extension guess."),
730
+ target: z
731
+ .enum(["card", "inline_image"])
732
+ .optional()
733
+ .describe("`card` (default): attach to a card. `inline_image`: upload an image for a markdown body; takes only `path`."),
734
+ card_id: z
735
+ .string()
736
+ .min(1)
737
+ .optional()
738
+ .describe("The card id to attach the file to. Required for target `card`; not allowed with `inline_image`."),
739
+ path: z
740
+ .string()
741
+ .min(1)
742
+ .describe("Absolute local path on the machine this server runs on (`/tmp/a.png` or `C:\\x\\a.png`)."),
743
+ filename: z
744
+ .string()
745
+ .min(1)
746
+ .optional()
747
+ .describe("Override for the stored filename; default: path's basename."),
748
+ content_type: z
749
+ .string()
750
+ .min(1)
751
+ .optional()
752
+ .describe("Override for the stored MIME type; default: an extension guess."),
690
753
  replaces: z
691
754
  .number()
692
755
  .int()
693
756
  .positive()
694
757
  .optional()
695
758
  .describe("Id of this card's attachment to replace in place: it keeps its id, name and cover flag. Not with `filename`."),
696
- primary: z.boolean().optional().describe("Make this attachment the card's single cover (lead image)."),
759
+ primary: z
760
+ .boolean()
761
+ .optional()
762
+ .describe("Make this attachment the card's single cover (lead image)."),
697
763
  ...boardField,
698
764
  }, async (args) => guardedJson(() => attachFile(client, args)));
699
765
  // ---------------- mini_app_publish (DX-5294, replaces DX-4077's design_publish) ----------------
@@ -721,8 +787,13 @@ strictTool("mini_app_publish", "Build a page with this repo's own mini app and p
721
787
  "design and call again. Limits: the frame has no network (use fixture props); on Windows name `node` and a committed script, never npm or npx.", {
722
788
  target: z
723
789
  .object({
724
- repo: repoNameArgSchema.optional().describe("The name of the repo whose mini app builds the page; default: the repo of the card's board."),
725
- name: z.string().min(1).describe("A mini app target's name, as listed in `mini_app_targets` of `GET /api/repos/<repo name>` (`50arms_api`, fields {mini_app_targets: true})."),
790
+ repo: repoNameArgSchema
791
+ .optional()
792
+ .describe("The name of the repo whose mini app builds the page; default: the repo of the card's board."),
793
+ name: z
794
+ .string()
795
+ .min(1)
796
+ .describe("A mini app target's name, as listed in `mini_app_targets` of `GET /api/repos/<repo name>` (`50arms_api`, fields {mini_app_targets: true})."),
726
797
  })
727
798
  .strict(),
728
799
  dir: z
@@ -735,21 +806,49 @@ strictTool("mini_app_publish", "Build a page with this repo's own mini app and p
735
806
  .describe("The revision note, shown beside the revision on the card: what changed since the last revision, which decision note it answers, what is still open."),
736
807
  destination: z
737
808
  .object({
738
- kind: z.literal("card_design").describe("Where the page goes: a design of a card."),
739
- card_id: z.string().min(1).describe("The card this design goes on: any existing card but an Epic or Feature."),
740
- design_no: z.number().int().positive().optional().describe("Add a revision to this existing design of the card (its `designs` relation). Not with `design_title`."),
741
- design_title: z.string().min(1).optional().describe("Start a NEW design on the card with this title, fixed for good. Not with `design_no`."),
742
- design_element: z.string().min(1).optional().describe("With `design_title` (required there, refused with `design_no`): the one thing this design decides, a few words (\"Indicator pill\", \"Popover layout\"). It joins that element's open design problem, matched ignoring case and extra spaces."),
809
+ kind: z
810
+ .literal("card_design")
811
+ .describe("Where the page goes: a design of a card."),
812
+ card_id: z
813
+ .string()
814
+ .min(1)
815
+ .describe("The card this design goes on: any existing card but an Epic or Feature."),
816
+ design_no: z
817
+ .number()
818
+ .int()
819
+ .positive()
820
+ .optional()
821
+ .describe("Add a revision to this existing design of the card (its `designs` relation). Not with `design_title`."),
822
+ design_title: z
823
+ .string()
824
+ .min(1)
825
+ .optional()
826
+ .describe("Start a NEW design on the card with this title, fixed for good. Not with `design_no`."),
827
+ design_element: z
828
+ .string()
829
+ .min(1)
830
+ .optional()
831
+ .describe('With `design_title` (required there, refused with `design_no`): the one thing this design decides, a few words ("Indicator pill", "Popover layout"). It joins that element\'s open design problem, matched ignoring case and extra spaces.'),
743
832
  })
744
833
  .strict(),
745
834
  option_groups: z
746
835
  .array(z
747
836
  .object({
748
- key: z.string().describe("The stable id a pick is recorded under (non-blank, at most 40 characters, unique among the groups)."),
749
- label: z.string().describe("The group's name as the viewer shows it (non-blank, at most 30 characters)."),
750
- options: z.array(z.string()).describe("The group's choices, each one short phrase, word or letter (non-blank, at most 30 characters, unique in the group)."),
751
- multiple: z.boolean().describe("true when a person may pick several options, false for exactly one."),
752
- recommended: z.array(z.string()).describe("Your recommended pick(s), each one of `options`: exactly one when `multiple` is false, at least one when true. Every group starts on them."),
837
+ key: z
838
+ .string()
839
+ .describe("The stable id a pick is recorded under (non-blank, at most 40 characters, unique among the groups)."),
840
+ label: z
841
+ .string()
842
+ .describe("The group's name as the viewer shows it (non-blank, at most 30 characters)."),
843
+ options: z
844
+ .array(z.string())
845
+ .describe("The group's choices, each one short phrase, word or letter (non-blank, at most 30 characters, unique in the group)."),
846
+ multiple: z
847
+ .boolean()
848
+ .describe("true when a person may pick several options, false for exactly one."),
849
+ recommended: z
850
+ .array(z.string())
851
+ .describe("Your recommended pick(s), each one of `options`: exactly one when `multiple` is false, at least one when true. Every group starts on them."),
753
852
  })
754
853
  .strict())
755
854
  .optional()
@@ -764,7 +863,9 @@ strictTool("mini_app_publish", "Build a page with this repo's own mini app and p
764
863
  "RESTATE it whole every revision (a new revision starts unticked). Ticking never blocks approval. A missing or empty list, or a blank item, is a 400."),
765
864
  browser_check: z
766
865
  .object({
767
- status: z.enum(["checked", "not_checked"]).describe("checked: you looked at it in a browser; not_checked: you had none."),
866
+ status: z
867
+ .enum(["checked", "not_checked"])
868
+ .describe("checked: you looked at it in a browser; not_checked: you had none."),
768
869
  note: z
769
870
  .string()
770
871
  .regex(/\S/)
@@ -778,9 +879,20 @@ strictTool("mini_app_publish", "Build a page with this repo's own mini app and p
778
879
  .min(1)
779
880
  .optional()
780
881
  .describe("With `design_title`; required when this publish opens a design problem (no open one for `design_element`), refused otherwise: one plain question naming what is being designed, at most 200 characters."),
781
- problem_summary: z.string().min(1).optional().describe("With `problem_statement`: 1-3 plain sentences."),
782
- problem_context: z.string().min(1).optional().describe("With `problem_statement`: markdown background for a first-time reader."),
783
- }, async (args) => guardedJson(() => miniAppPublish(client, args, { baseUrl: config.baseUrl, cwd: process.cwd() })));
882
+ problem_summary: z
883
+ .string()
884
+ .min(1)
885
+ .optional()
886
+ .describe("With `problem_statement`: 1-3 plain sentences."),
887
+ problem_context: z
888
+ .string()
889
+ .min(1)
890
+ .optional()
891
+ .describe("With `problem_statement`: markdown background for a first-time reader."),
892
+ }, async (args) => guardedJson(() => miniAppPublish(client, args, {
893
+ baseUrl: config.baseUrl,
894
+ cwd: process.cwd(),
895
+ })));
784
896
  // ---------------- mini_app_restore (DX-6070) ----------------
785
897
  //
786
898
  // Agent-specific like mini_app_publish: it WRITES local files, which `50arms_api` cannot. A design's source is stored with every revision on the
@@ -793,8 +905,17 @@ strictTool("mini_app_restore", "Write a design revision's stored source back to
793
905
  "Files with equal content are `unchanged`; files in the folder that the revision lacks are left alone and listed in `extra_local`. " +
794
906
  "Returns `{design_dir, revision_no, built_from_commit, written, unchanged, extra_local}`.", {
795
907
  card_id: z.string().min(1).describe("The card the design is on."),
796
- design_no: z.number().int().positive().describe("The design's number on the card (its `designs` relation)."),
797
- revision_no: z.number().int().positive().optional().describe("The revision to restore; default: the design's latest."),
908
+ design_no: z
909
+ .number()
910
+ .int()
911
+ .positive()
912
+ .describe("The design's number on the card (its `designs` relation)."),
913
+ revision_no: z
914
+ .number()
915
+ .int()
916
+ .positive()
917
+ .optional()
918
+ .describe("The revision to restore; default: the design's latest."),
798
919
  }, async (args) => guardedJson(() => miniAppRestore(client, args, { cwd: process.cwd() })));
799
920
  // ---------------- plugin_publish (DX-5237, parent DX-4679) ----------------
800
921
  //
@@ -805,11 +926,27 @@ strictTool("plugin_publish", "Build a card-type plugin project (Vite, `danxPlugi
805
926
  "`plugin` (a new key creates it): uploads `dist/`, the source `.tar.gz` and a screenshot of the plugin's own render (its `CardView` drawn with a sample card on the dashboard's `/plugin-preview` page). " +
806
927
  "Returns `{ok: true, status, body: {plugin, plugin_id, revision_id, revision_no, approval_url, screenshot}}`: `approval_url` is Settings > Plugins, where a team admin approves the revision; you cannot. " +
807
928
  "`screenshot` is `captured` or `none: <reason>` (the publish still succeeds). A build error throws with the build's output; a refused upload comes back verbatim as `{ok: false, status, body, plugin, step}`.", {
808
- dir: z.string().min(1).describe("The project directory: absolute, or relative to this server's cwd."),
809
- plugin: z.string().min(1).describe("The plugin's key: lowercase letters, digits, - and _, at most 64."),
810
- note: z.string().min(1).describe("What this revision changes, shown to the approver."),
811
- name: z.string().min(1).optional().describe("Display name for a plugin this call creates; default: the key."),
812
- }, async (args) => guardedJson(() => pluginPublish(client, args, { baseUrl: config.baseUrl, cwd: process.cwd() })));
929
+ dir: z
930
+ .string()
931
+ .min(1)
932
+ .describe("The project directory: absolute, or relative to this server's cwd."),
933
+ plugin: z
934
+ .string()
935
+ .min(1)
936
+ .describe("The plugin's key: lowercase letters, digits, - and _, at most 64."),
937
+ note: z
938
+ .string()
939
+ .min(1)
940
+ .describe("What this revision changes, shown to the approver."),
941
+ name: z
942
+ .string()
943
+ .min(1)
944
+ .optional()
945
+ .describe("Display name for a plugin this call creates; default: the key."),
946
+ }, async (args) => guardedJson(() => pluginPublish(client, args, {
947
+ baseUrl: config.baseUrl,
948
+ cwd: process.cwd(),
949
+ })));
813
950
  // ---------------- docs_search / docs_read (DX-5582) ----------------
814
951
  //
815
952
  // One pair of tools over three places a docs root lives (`source`): this checkout's `docs/pages`, another local docs root, or a team repo's hosted
@@ -818,13 +955,25 @@ strictTool("plugin_publish", "Build a card-type plugin project (Vite, `danxPlugi
818
955
  strictTool("docs_search", "Search docs with the shared @50arms/docs engine. Returns `{query, results: [{id, type, title, summary, file, bytes, lines, look_in?}]}`, best first, never a page body; " +
819
956
  "then `docs_read` the id you pick. `file` is an absolute path for local/dir and the page's path in the repo's docs for remote; `bytes`/`lines` size it for offset/limit reads.", {
820
957
  source: docsSourceShape,
821
- query: z.string().min(1).describe("A question or the words a page would use."),
822
- limit: z.number().int().min(1).max(MAX_SEARCH_LIMIT).optional().describe(`Most results (default ${DEFAULT_LIMIT}).`),
958
+ query: z
959
+ .string()
960
+ .min(1)
961
+ .describe("A question or the words a page would use."),
962
+ limit: z
963
+ .number()
964
+ .int()
965
+ .min(1)
966
+ .max(MAX_SEARCH_LIMIT)
967
+ .optional()
968
+ .describe(`Most results (default ${DEFAULT_LIMIT}).`),
823
969
  }, async (args) => guardedJson(() => docsSearch(client, args, { cwd: process.cwd() })));
824
970
  strictTool("docs_read", "Get a docs page as a file on this machine: returns `{id, path, bytes, lines}`, never the text. local/dir: the page's own file. remote: a fresh copy fetched from the dashboard into the temp directory. " +
825
971
  "Read `path` with your own file tools (offset/limit, grep). An unknown id is refused with the nearest ids.", {
826
972
  source: docsSourceShape,
827
- id: z.string().min(1).describe("A page id from docs_search, e.g. topic.mini-apps."),
973
+ id: z
974
+ .string()
975
+ .min(1)
976
+ .describe("A page id from docs_search, e.g. topic.mini-apps."),
828
977
  }, async (args) => guardedJson(() => docsRead(client, args, { cwd: process.cwd() })));
829
978
  // ---------------- request_permission (DX-4434, parent DX-4432) ----------------
830
979
  strictTool("request_permission", "Ask a person to grant this key ONE MORE permission. Call it when a call was refused `403 forbidden` naming a " +
@@ -838,7 +987,10 @@ strictTool("request_permission", "Ask a person to grant this key ONE MORE permis
838
987
  .array(z.string().min(1))
839
988
  .min(1)
840
989
  .describe("The permission keys to ask for: the `permission` a `403 forbidden` named."),
841
- reason: z.string().min(1).describe("Why you need them; shown to the person who approves."),
990
+ reason: z
991
+ .string()
992
+ .min(1)
993
+ .describe("Why you need them; shown to the person who approves."),
842
994
  }, async (args) => {
843
995
  const asked = await permissionRequests.ask(args);
844
996
  if ("halt" in asked)
@@ -886,15 +1038,19 @@ strictTool("session_connect",
886
1038
  .min(1)
887
1039
  .optional()
888
1040
  .describe("What to hold: `PLAN-n` (a plan's `ref` in `50arms_api` `GET /api/plans`) or a card's id as the board shows it, for a card on no plan. Omit only to sign in (it still takes your team agent)."),
889
- title: z
890
- .string()
891
- .min(1)
892
- .optional()
893
- .describe(
1041
+ title: z.string().min(1).optional().describe(
894
1042
  // DX-4608: stored as sent; a wrong one does not refuse the connect, the reply's `naming` says what to rename it to.
895
- 'The `naming` block\'s exact `{Name}: PLAN-NNN {short title}` or `{Name}: {CARD-ID} {card title}`, after renaming this thread. Omit on the first connect.'),
896
- assignment_id: z.number().int().positive().optional().describe("The assignment this connect answers, when a person's assignment message names one. Refused `assignment_ended` once it is over: then do nothing more about it."),
897
- disconnect: z.boolean().optional().describe("true = leave `target` (the plan or card you hold); no `title`."),
1043
+ "The `naming` block's exact `{Name}: PLAN-NNN {short title}` or `{Name}: {CARD-ID} {card title}`, after renaming this thread. Omit on the first connect."),
1044
+ assignment_id: z
1045
+ .number()
1046
+ .int()
1047
+ .positive()
1048
+ .optional()
1049
+ .describe("The assignment this connect answers, when a person's assignment message names one. Refused `assignment_ended` once it is over: then do nothing more about it."),
1050
+ disconnect: z
1051
+ .boolean()
1052
+ .optional()
1053
+ .describe("true = leave `target` (the plan or card you hold); no `title`."),
898
1054
  role: z
899
1055
  .string()
900
1056
  // Keep in step with `ROLE_KEY_PATTERN` (`src/lib/auth-rules.ts`): this published package cannot import the service's source.
@@ -908,16 +1064,10 @@ strictTool("session_connect",
908
1064
  .min(1)
909
1065
  .optional()
910
1066
  .describe("The one-use token the session that started this one passed in its prompt. With it a signed-out session signs in with no person approving it; a token that cannot be used says why and the session asks a person as usual. Omit it otherwise."),
911
- person_sign_in: z
912
- .boolean()
913
- .optional()
914
- .describe(
1067
+ person_sign_in: z.boolean().optional().describe(
915
1068
  // DX-6894 (DEC-589): set only by the plugin band when a PERSON presses its Sign in; the one call that leaves a revoked key's stop.
916
1069
  "Set only by the plugin's Sign in button when a person presses it; an agent never sets it. On a session whose key a person revoked it lifts the stop and starts a new access request a person must approve; any call without it still answers the stop."),
917
- registration_only: z
918
- .boolean()
919
- .optional()
920
- .describe(
1070
+ registration_only: z.boolean().optional().describe(
921
1071
  // DX-7010: set only by the plugin band; it answers before `ensureAccess`, so it makes no access request and claims no team agent.
922
1072
  "Set only by the plugin's band; an agent never sets it. Answers whether this machine is registered, `machine_registered` or the registration link, and makes no access request."),
923
1073
  },
@@ -926,7 +1076,10 @@ strictTool("session_connect",
926
1076
  // must resolve (the relay needs none of this: it lives in each server, with that server's own credential).
927
1077
  async (args) => {
928
1078
  if (args.registration_only === true)
929
- return accessReply({ signedIn: false, ...(await access.registrationOnly()) });
1079
+ return accessReply({
1080
+ signedIn: false,
1081
+ ...(await access.registrationOnly()),
1082
+ });
930
1083
  // DX-6894 — a person's Sign in press leaves the revoked stop; every call without it still answers that stop.
931
1084
  if (args.person_sign_in === true)
932
1085
  access.personSignIn();
@@ -953,7 +1106,11 @@ async (args) => {
953
1106
  void reportCheckoutDocsRoot();
954
1107
  return jsonResult({
955
1108
  ...claimed.body,
956
- ...(agentGate.current() === null ? { instruction: "This session is signed in. Call `session_connect` with `target` to connect it to a plan or a card." } : {}),
1109
+ ...(agentGate.current() === null
1110
+ ? {
1111
+ instruction: "This session is signed in. Call `session_connect` with `target` to connect it to a plan or a card.",
1112
+ }
1113
+ : {}),
957
1114
  });
958
1115
  }
959
1116
  // DX-6089: the role text lands in a local file; the reply names it (`role-instruction-file.ts`).
@@ -1022,7 +1179,12 @@ strictTool("plan_events_wait",
1022
1179
  "current turn ends. `acks`: events to acknowledge as `text` says, else re-sent. " +
1023
1180
  "One wait per session: a newer call ends the older. " +
1024
1181
  "`transcript_path` is the session's transcript file, for its usage and title.", {
1025
- plan_id: z.number().int().positive().nullable().describe("Number of the plan this session is connected to (the `n` of `PLAN-n`, within your team), or null when it is on no plan."),
1182
+ plan_id: z
1183
+ .number()
1184
+ .int()
1185
+ .positive()
1186
+ .nullable()
1187
+ .describe("Number of the plan this session is connected to (the `n` of `PLAN-n`, within your team), or null when it is on no plan."),
1026
1188
  cursor: z
1027
1189
  .string()
1028
1190
  .nullable()
package/dist/job-key.js CHANGED
@@ -25,7 +25,9 @@ export class JobKeyHolder {
25
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
26
  */
27
27
  afterCall(call, result, viaJobKey) {
28
- if (viaJobKey && (result.status === 401 || (result.ok && call.method === "POST" && pathOf(call) === COMPLETE_PATH))) {
28
+ if (viaJobKey &&
29
+ (result.status === 401 ||
30
+ (result.ok && call.method === "POST" && pathOf(call) === COMPLETE_PATH))) {
29
31
  this.key = null;
30
32
  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
33
  return result;
package/dist/json-body.js CHANGED
@@ -6,7 +6,9 @@
6
6
  * dashboard error name, only that a JSON object may carry a top-level string field named `error`.
7
7
  */
8
8
  export function errorCodeOf(body) {
9
- return typeof body === "object" && body !== null && typeof body.error === "string"
9
+ return typeof body === "object" &&
10
+ body !== null &&
11
+ typeof body.error === "string"
10
12
  ? body.error
11
13
  : null;
12
14
  }
@@ -8,7 +8,8 @@ export function keyRevocationOf(result) {
8
8
  const body = result.body;
9
9
  if (body?.error !== "key_revoked")
10
10
  return null;
11
- if (typeof body.revokedBy !== "string" || typeof body.revokedAt !== "string") {
11
+ if (typeof body.revokedBy !== "string" ||
12
+ typeof body.revokedAt !== "string") {
12
13
  throw new Error("[platform-mcp] a key_revoked refusal carried no revokedBy / revokedAt");
13
14
  }
14
15
  return { revokedBy: body.revokedBy, revokedAt: body.revokedAt };
@@ -20,13 +20,26 @@ export function readLeftoverProcess(v) {
20
20
  const { pid, command, age_seconds, cpu_percent, why } = v;
21
21
  if (!Number.isSafeInteger(pid) || pid <= 0)
22
22
  return null;
23
- if (typeof command !== "string" || command.trim() === "" || command.length > LEFTOVER_COMMAND_MAX_CHARS + 3)
23
+ if (typeof command !== "string" ||
24
+ command.trim() === "" ||
25
+ command.length > LEFTOVER_COMMAND_MAX_CHARS + 3)
24
26
  return null;
25
- if (typeof age_seconds !== "number" || !Number.isFinite(age_seconds) || age_seconds < 0)
27
+ if (typeof age_seconds !== "number" ||
28
+ !Number.isFinite(age_seconds) ||
29
+ age_seconds < 0)
26
30
  return null;
27
- if (cpu_percent !== null && (typeof cpu_percent !== "number" || !Number.isFinite(cpu_percent) || cpu_percent < 0))
31
+ if (cpu_percent !== null &&
32
+ (typeof cpu_percent !== "number" ||
33
+ !Number.isFinite(cpu_percent) ||
34
+ cpu_percent < 0))
28
35
  return null;
29
36
  if (!LEFTOVER_WHY.includes(why))
30
37
  return null;
31
- return { pid: pid, command, age_seconds, cpu_percent: cpu_percent, why: why };
38
+ return {
39
+ pid: pid,
40
+ command,
41
+ age_seconds,
42
+ cpu_percent: cpu_percent,
43
+ why: why,
44
+ };
32
45
  }