@50arms/platform-mcp 0.1.481 → 0.1.483

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 CHANGED
@@ -1186,17 +1186,18 @@ strictTool("plan_events_wait",
1186
1186
  // DX-4882 - `plan_id` is null for a signed-in session on no plan: its stream still carries its account's pacing and resume messages.
1187
1187
  // DX-4233 - for the 50arms plugin's relay loop. DX-4667 - and for a background waiter sub-agent of an orchestrator, which
1188
1188
  // loops on it until events exist and returns them (and the cursor) to the orchestrator it wakes. It answers `events` (each
1189
- // `{cursor, text, urgent, acks}`; empty after `timeout_ms`), the cursor to send being the last delivered event's, or `stopped` with the remedy
1189
+ // `{cursor, text, urgent, acks, offer}`; empty after `timeout_ms`), the cursor to send being the last delivered event's, or `stopped` with the remedy
1190
1190
  // to tell the session. General-audience text (DX-4550): nothing here names our own setup.
1191
1191
  "Waits for events for this session: the events of the plan it is connected to, and the messages about its usage. For a relay " +
1192
1192
  "or a background waiter that calls it in a loop and hands every event to the session; call it for nothing else. " +
1193
1193
  "`plan_id` is the plan the session is on, or null when it is on no plan (then only the usage messages arrive; a different " +
1194
1194
  "plan than the last call's, or a move to or from null, starts clean). `cursor` is the `cursor` of the last event delivered, as answered (null " +
1195
- "when none). Answers `{events: [{cursor, text, urgent, acks}]}`, with `events` empty once `timeout_ms` passes, or `{stopped: " +
1195
+ "when none). Answers `{events: [{cursor, text, urgent, acks, offer}]}`, with `events` empty once `timeout_ms` passes, or `{stopped: " +
1196
1196
  "{reason, detail, fix}}` when the stream ended: tell the session the `fix`. An event stays until a later call's " +
1197
1197
  "`cursor` passes it. `urgent` is true for an event the session must hear at once (a critical usage limit, a revoked " +
1198
1198
  "key) and false for every other: deliver an urgent one to the session even while it is working, and any other once its " +
1199
1199
  "current turn ends. `acks`: events to acknowledge as `text` says, else re-sent. " +
1200
+ "`offer`: a queued job `{item_id, assignment_id}` offered to the session, which the relay takes itself instead of delivering `text`; null on every other event. " +
1200
1201
  "One wait per session: a newer call ends the older. " +
1201
1202
  "`transcript_path` is the session's transcript file, for its usage and title.", {
1202
1203
  plan_id: z
package/dist/listen.js CHANGED
@@ -662,6 +662,28 @@ export function invalidAssignmentReason(value) {
662
662
  return "text is empty";
663
663
  return null;
664
664
  }
665
+ const isPositiveId = (value) => Number.isSafeInteger(value) && value > 0;
666
+ /** DX-7748 (DEC-1340): why an `assignment` frame cannot be read, or `null` when it can: its text, and a `job` that is absent, `null` or `{item_id, assignment_id}` as positive integers. */
667
+ export function invalidQueuedAssignmentReason(value) {
668
+ const invalid = invalidAssignmentReason(value);
669
+ if (invalid !== null)
670
+ return invalid;
671
+ const job = value.job;
672
+ if (job === undefined || job === null)
673
+ return null;
674
+ if (!isRecord(job) ||
675
+ !isPositiveId(job.item_id) ||
676
+ !isPositiveId(job.assignment_id))
677
+ return "job is not {item_id, assignment_id}";
678
+ return null;
679
+ }
680
+ /** DX-7748 (DEC-1340): the job a readable `assignment` frame offers, or `null` when it offers none. */
681
+ export function offerOfAssignment(event) {
682
+ const job = event.job ?? null;
683
+ return job === null
684
+ ? null
685
+ : { item_id: job.item_id, assignment_id: job.assignment_id };
686
+ }
665
687
  /** The one readable line for an assignment message: the dashboard's text, on one line, cut like a pacing line. Throws, naming the fault, on a malformed message. */
666
688
  export function formatAssignmentLine(event) {
667
689
  const invalid = invalidAssignmentReason(event);
@@ -684,6 +706,21 @@ export function formatLeftoverProcessesLine(event) {
684
706
  throw new Error(`malformed leftover-processes message: ${invalid}`);
685
707
  return pacingRelayLine(event.text);
686
708
  }
709
+ /** Why a queue notice cannot be read, or `null` when it can. */
710
+ export function invalidQueueNoticeReason(value) {
711
+ if (!isRecord(value))
712
+ return "the queue notice is not an object";
713
+ if (typeof value.text !== "string" || value.text.trim() === "")
714
+ return "text is empty";
715
+ return null;
716
+ }
717
+ /** 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. */
718
+ export function formatQueueNoticeLine(event) {
719
+ const invalid = invalidQueueNoticeReason(event);
720
+ if (invalid !== null)
721
+ throw new Error(`malformed queue notice: ${invalid}`);
722
+ return pacingRelayLine(event.text);
723
+ }
687
724
  /** Why an owed-comment message cannot be read, or `null` when it can. */
688
725
  export function invalidOwedCommentReason(value) {
689
726
  if (!isRecord(value))
@@ -922,7 +959,7 @@ export async function runListener(options, deps) {
922
959
  * session; a pacing change is an instruction to act now). A frame that is not JSON or not the right shape is reported from an explicit check
923
960
  * naming the fault, and the next frame still emits.
924
961
  */
925
- const emitAdvisory = (message, what, invalidReason, format, sourceOf, scope) => {
962
+ const emitAdvisory = (message, what, invalidReason, format, sourceOf, scope, offerOf) => {
926
963
  const { parsed, invalid } = readFrame(message, invalidReason);
927
964
  // `Number(null)` is 0: a frame with no id must never be read as id 0 (see the activity path below).
928
965
  const id = message.id === null ? Number.NaN : Number(message.id);
@@ -937,6 +974,7 @@ export async function runListener(options, deps) {
937
974
  const text = invalid === null ? format(parsed) : faultText(what, invalid, message);
938
975
  // DX-4721: an unreadable frame is a fault line, never the frame it failed to be (a malformed `critical` pacing frame is not a stop).
939
976
  const urgent = isUrgent(invalid === null ? sourceOf(parsed) : { source: "fault" });
977
+ const offer = invalid === null && offerOf !== undefined ? offerOf(parsed) : null;
940
978
  deps.write({
941
979
  type: "event",
942
980
  id: knownId ? id : null,
@@ -945,6 +983,7 @@ export async function runListener(options, deps) {
945
983
  urgent,
946
984
  acks: [],
947
985
  ...(scope === undefined ? {} : { scope }),
986
+ ...(offer === null ? {} : { offer }),
948
987
  });
949
988
  if (knownId)
950
989
  remember(id);
@@ -1050,8 +1089,12 @@ export async function runListener(options, deps) {
1050
1089
  // DX-7107 - processes this session started and left running: a reminder, non-urgent and session-scoped like an owed comment.
1051
1090
  if (message.event === "leftover_processes")
1052
1091
  return emitAdvisory(message, "leftover-processes message", invalidLeftoverProcessesReason, (p) => formatLeftoverProcessesLine(p), () => ({ source: "leftover_processes" }), "session");
1092
+ // 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`.
1093
+ if (message.event === "queue_notice")
1094
+ return emitAdvisory(message, "queue notice", invalidQueueNoticeReason, (p) => formatQueueNoticeLine(p), () => ({ source: "queue_notice" }), "session");
1095
+ // DX-7748 (DEC-1340): a queued job's frame names it as `job`, which the record carries as `offer` for the plugin to take.
1053
1096
  if (message.event === "assignment")
1054
- return emitAdvisory(message, "assignment message", invalidAssignmentReason, (p) => formatAssignmentLine(p), () => ({ source: "assignment" }), "session");
1097
+ return emitAdvisory(message, "assignment message", invalidQueuedAssignmentReason, (p) => formatAssignmentLine(p), () => ({ source: "assignment" }), "session", (p) => offerOfAssignment(p));
1055
1098
  // DX-4993 - the compaction control: level-triggered, no id, no replay. A frame that cannot be read is a fault line (never silence), and the next frame still lands.
1056
1099
  if (message.event === "compaction")
1057
1100
  return emitControl(message, "compaction control", invalidCompactionReason, (p) => ({ type: "compaction", control: controlOfFrame(p) }));
@@ -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.481",
615
+ false ? void 0 : "0.1.483",
616
616
  readOwnManifest
617
617
  );
618
618
  function envelope(now) {
@@ -227,11 +227,12 @@ export class PlanEventRelay {
227
227
  /** Everything buffered, each record with the cursor to store once it is delivered. */
228
228
  answer() {
229
229
  return {
230
- events: this.buffer.map(({ seq, recent, text, urgent, acks }) => ({
230
+ events: this.buffer.map(({ seq, recent, text, urgent, acks, offer }) => ({
231
231
  cursor: formatCursor({ seq, ids: recent }),
232
232
  text,
233
233
  urgent,
234
234
  acks,
235
+ offer,
235
236
  })),
236
237
  };
237
238
  }
@@ -258,6 +259,7 @@ export class PlanEventRelay {
258
259
  scope: event.scope ?? "plan",
259
260
  urgent: event.urgent,
260
261
  acks: event.acks,
262
+ offer: event.offer ?? null,
261
263
  });
262
264
  const waiter = this.waiter;
263
265
  if (waiter === null)
@@ -49,6 +49,7 @@ export const GET_ROUTE_BOARD_SCOPE = [
49
49
  ["/api/plans/:planId/usage-series", "refuse"],
50
50
  ["/api/plans/mine/architecture/sections", "refuse"],
51
51
  ["/api/plans/mine/records", "refuse"],
52
+ ["/api/platform/beta-waitlist", "refuse"],
52
53
  ["/api/platform/feedback", "refuse"],
53
54
  ["/api/platform/signup-codes", "refuse"],
54
55
  ["/api/platform/teams", "refuse"],
@@ -41,6 +41,7 @@ export function isUrgent(record) {
41
41
  case "content_compaction":
42
42
  case "owed_comment":
43
43
  case "leftover_processes":
44
+ case "queue_notice":
44
45
  case "digest":
45
46
  case "relay_notice":
46
47
  case "fault":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@50arms/platform-mcp",
3
- "version": "0.1.481",
3
+ "version": "0.1.483",
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",