@50arms/platform-mcp 0.1.498 → 0.1.500
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/handlers.js +1 -1
- package/dist/index.js +8 -6
- package/dist/listen.js +63 -24
- package/dist/machine-toolkit.js +1 -1
- package/dist/route-board-scope.generated.js +2 -0
- package/package.json +1 -1
package/dist/handlers.js
CHANGED
|
@@ -76,7 +76,7 @@ export async function sessionConnect(client, args) {
|
|
|
76
76
|
path: "/me/connect",
|
|
77
77
|
basePath: PLAN_SESSIONS_BASE_PATH,
|
|
78
78
|
body: {
|
|
79
|
-
target: args.target,
|
|
79
|
+
...(args.target === undefined ? {} : { target: args.target }),
|
|
80
80
|
...(args.title === undefined ? {} : { title: args.title }),
|
|
81
81
|
...(args.assignment_id === undefined
|
|
82
82
|
? {}
|
package/dist/index.js
CHANGED
|
@@ -1056,13 +1056,14 @@ strictTool("session_connect",
|
|
|
1056
1056
|
// action's rule in the event line itself (`listen.ts`), the mantra in the reply's own `reminders[]` text.
|
|
1057
1057
|
// DX-4390 — signed out, this is also how the session asks for access.
|
|
1058
1058
|
// DX-4608 / DX-5549: a title in the format naming another agent than the held one is refused.
|
|
1059
|
-
|
|
1059
|
+
// DX-7796 (AC 72009): `assignment_id` with no `target` takes the docs land job a ready agent was assigned (an assignment naming only a board's docs accept): it binds that job, never a plan or card.
|
|
1060
|
+
"Connect THIS session to ONE plan or card, named by `target`: `PLAN-n`, or a card's id for a card on no plan. Omit `target` only to sign in (it still takes your team agent) or, with `assignment_id`, to take a docs land job. Signed out, it requests access: " +
|
|
1060
1061
|
"the reply is `state: approval_required` or `approval_pending` with an `approvalUrl` and `confirmCode` " +
|
|
1061
1062
|
"(show the code, open the URL, then call again; a call re-asks an expired one). " +
|
|
1062
1063
|
"Unregistered machine: `machine_registration_required` or `_pending` with `registrationUrl` and `claimCode`: give both to the user and stop. " +
|
|
1063
1064
|
"Signed in, the reply carries `owedComments` (unanswered person comments: read first, answer each, ack then reply), `missedEvents` (untold operator " +
|
|
1064
1065
|
"events: read next), `naming` and `listenerHealth` (when its `state` is not `healthy`, do its `nextStep`); " +
|
|
1065
|
-
"for a plan also `browserInstruction` (do it now), `briefing` (goals, rules, caveats, architecture, open cards)
|
|
1066
|
+
"for a plan also `browserInstruction` (do it now), `briefing` (goals, rules, caveats, architecture, open cards). " +
|
|
1066
1067
|
"Holds a plan or a card, never both: connecting elsewhere moves it (`movedFrom` names the plan it left). " +
|
|
1067
1068
|
"A plan's second session is refused `plan_has_live_session`; do not retry. " +
|
|
1068
1069
|
"A card is refused `card_on_plan` when it or a card above it is on a plan (connect to that plan) and `card_held` when another live session holds it; holding one assigns it to you, like a manual pickup. " +
|
|
@@ -1074,7 +1075,7 @@ strictTool("session_connect",
|
|
|
1074
1075
|
.string()
|
|
1075
1076
|
.min(1)
|
|
1076
1077
|
.optional()
|
|
1077
|
-
.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). A signed-out session another session started for this target signs in by itself, with no person approving."),
|
|
1078
|
+
.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), or when an assignment message says to connect with its `assignment_id` and no target (a docs land job). A signed-out session another session started for this target signs in by itself, with no person approving."),
|
|
1078
1079
|
title: z.string().min(1).optional().describe(
|
|
1079
1080
|
// DX-4608: stored as sent; a wrong one does not refuse the connect, the reply's `naming` says what to rename it to.
|
|
1080
1081
|
"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."),
|
|
@@ -1083,7 +1084,7 @@ strictTool("session_connect",
|
|
|
1083
1084
|
.int()
|
|
1084
1085
|
.positive()
|
|
1085
1086
|
.optional()
|
|
1086
|
-
.describe("The assignment this connect answers, when
|
|
1087
|
+
.describe("The assignment this connect answers, when an assignment message names one; with no `target` when the message says so (a docs land job). Refused `assignment_ended` once it is over: then do nothing more about it."),
|
|
1087
1088
|
disconnect: z
|
|
1088
1089
|
.boolean()
|
|
1089
1090
|
.optional()
|
|
@@ -1124,7 +1125,8 @@ async (args) => {
|
|
|
1124
1125
|
const ready = await access.ensureAccess(args.title, args.role, args.target);
|
|
1125
1126
|
if (!ready.signedIn)
|
|
1126
1127
|
return accessReply(ready);
|
|
1127
|
-
|
|
1128
|
+
// DX-7796 (AC 72009): `assignment_id` with no target answers a docs land assignment, so it goes to the dashboard's connect; with neither, this call only signs in.
|
|
1129
|
+
if (args.target === undefined && args.assignment_id === undefined) {
|
|
1128
1130
|
// DX-4523 - signed in (possibly just now): show the tools this key's permissions allow.
|
|
1129
1131
|
await syncToolsAfterSignIn();
|
|
1130
1132
|
// DX-5549: signing in takes a team agent. The dashboard's answer (the agent and the instruction to use its name, or why there is none) is the reply.
|
|
@@ -1151,7 +1153,7 @@ async (args) => {
|
|
|
1151
1153
|
});
|
|
1152
1154
|
}
|
|
1153
1155
|
// DX-6089: the role text lands in a local file; the reply names it (`role-instruction-file.ts`).
|
|
1154
|
-
const result = spillRoleInstruction(await sessionConnect(client,
|
|
1156
|
+
const result = spillRoleInstruction(await sessionConnect(client, args));
|
|
1155
1157
|
// DX-4418 — a person revoked this key: the stop halt, and nothing asks again.
|
|
1156
1158
|
const revokedHalt = access.refusalHalt(result);
|
|
1157
1159
|
if (revokedHalt !== null)
|
package/dist/listen.js
CHANGED
|
@@ -137,31 +137,55 @@ export function invalidEventReason(value) {
|
|
|
137
137
|
return "the event is not an object";
|
|
138
138
|
if (typeof value.id !== "number" || !Number.isSafeInteger(value.id))
|
|
139
139
|
return "id is not an integer";
|
|
140
|
-
// DX-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
// DX-7658: the subject is a card, the plan itself or (new) a behavior policy or group: `policy` set with every other subject field null, and no board.
|
|
141
|
+
const onPolicy = value.policy !== undefined && value.policy !== null;
|
|
142
|
+
if (onPolicy) {
|
|
143
|
+
const p = value.policy;
|
|
144
|
+
if (!isRecord(p) ||
|
|
145
|
+
(p.kind !== "behavior_policy" && p.kind !== "behavior_policy_group") ||
|
|
146
|
+
typeof p.id !== "number" ||
|
|
147
|
+
!Number.isSafeInteger(p.id) ||
|
|
148
|
+
p.id < 1 ||
|
|
149
|
+
typeof p.ref !== "string" ||
|
|
150
|
+
p.ref === "" ||
|
|
151
|
+
typeof p.teamId !== "number")
|
|
152
|
+
return "policy is not null or {kind, id, ref, teamId}";
|
|
153
|
+
if (value.cardId !== null || value.planId !== null)
|
|
154
|
+
return "cardId and planId are not null on a policy event";
|
|
146
155
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
else {
|
|
157
|
+
// DX-6211: the subject is a card (`cardId` a string) or the plan itself (`planId` a positive integer and `cardId` null), never both and never neither.
|
|
158
|
+
if (value.planId !== null &&
|
|
159
|
+
!(typeof value.planId === "number" &&
|
|
160
|
+
Number.isSafeInteger(value.planId) &&
|
|
161
|
+
value.planId > 0)) {
|
|
162
|
+
return "planId is not null or a positive integer";
|
|
163
|
+
}
|
|
164
|
+
if (typeof value.planId === "number") {
|
|
165
|
+
if (value.cardId !== null)
|
|
166
|
+
return "cardId is not null on a plan event";
|
|
167
|
+
if (typeof value.planRef !== "string" || value.planRef === "")
|
|
168
|
+
return "planRef is not a string on a plan event";
|
|
169
|
+
}
|
|
170
|
+
else if (typeof value.cardId !== "string") {
|
|
171
|
+
return "cardId is not a string";
|
|
172
|
+
}
|
|
155
173
|
}
|
|
156
174
|
for (const field of ["cardTitle", "actor", "kind"]) {
|
|
157
175
|
if (typeof value[field] !== "string")
|
|
158
176
|
return `${field} is not a string`;
|
|
159
177
|
}
|
|
160
|
-
// DX-5466: null is legal only on a pause release (a plan/session anchor has no board); no text marker ever travels here.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
// DX-5466: null is legal only on a pause release (a plan/session anchor has no board); no text marker ever travels here. DX-7658: and on a policy event, which has none.
|
|
179
|
+
if (onPolicy) {
|
|
180
|
+
if (value.boardId !== null)
|
|
181
|
+
return "boardId is not null on a policy event";
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const isReleaseWithoutBoard = value.boardId === null && value.release === true;
|
|
185
|
+
const isBoardId = typeof value.boardId === "number" && Number.isSafeInteger(value.boardId);
|
|
186
|
+
if (!isReleaseWithoutBoard && !isBoardId)
|
|
187
|
+
return "boardId is not an integer";
|
|
188
|
+
}
|
|
165
189
|
// DX-2730 D4 — checked with the rest of the envelope, before any kind-specific
|
|
166
190
|
// detail check, exactly like every other envelope field above.
|
|
167
191
|
if (typeof value.origin !== "string" || !ACTIVITY_ORIGINS.has(value.origin)) {
|
|
@@ -333,8 +357,17 @@ export function replyInstruction(cardId, commentId) {
|
|
|
333
357
|
export function planReplyInstruction(planId, commentId) {
|
|
334
358
|
return replyInstructionAt(`/api/plans/${planId}/comments/${commentId}/reply`);
|
|
335
359
|
}
|
|
336
|
-
/** DX-
|
|
360
|
+
/** DX-7658: {@link replyInstruction} for a person's comment written in the thread of a behavior policy or group, answered by the ready agent that holds the thread through its reply route. */
|
|
361
|
+
export function policyReplyInstruction(policy, commentId) {
|
|
362
|
+
const base = policy.kind === "behavior_policy"
|
|
363
|
+
? "/api/behavior-policies"
|
|
364
|
+
: "/api/behavior-policy-groups";
|
|
365
|
+
return replyInstructionAt(`${base}/${policy.id}/comments/${commentId}/reply`);
|
|
366
|
+
}
|
|
367
|
+
/** DX-6211: the event's subject as the line names it: the card's id, or the plan's reference (`PLAN-72`, sent by the dashboard as `planRef`) for a plan event, or (DX-7658) the policy's or group's (`BP-3`, `BPG-3`). Only called on an event `invalidEventReason` accepted. */
|
|
337
368
|
function subjectRef(event) {
|
|
369
|
+
if (event.policy !== undefined && event.policy !== null)
|
|
370
|
+
return event.policy.ref;
|
|
338
371
|
return typeof event.planId === "number"
|
|
339
372
|
? event.planRef
|
|
340
373
|
: event.cardId;
|
|
@@ -359,17 +392,23 @@ function describe(event) {
|
|
|
359
392
|
return `${who} notice: ${quoted(d.excerpt)}`;
|
|
360
393
|
// DX-6211: a comment written on the plan itself is answered through the plan's reply route, and the line says it was written on the plan.
|
|
361
394
|
const onPlan = typeof event.planId === "number";
|
|
395
|
+
const policy = event.policy ?? null;
|
|
362
396
|
const reply = !isPersonsComment(event)
|
|
363
397
|
? ""
|
|
364
|
-
: `. ${onPlan ? planReplyInstruction(event.planId, d.comment_id) : replyInstruction(event.cardId, d.comment_id)}`;
|
|
398
|
+
: `. ${policy !== null ? policyReplyInstruction(policy, d.comment_id) : onPlan ? planReplyInstruction(event.planId, d.comment_id) : replyInstruction(event.cardId, d.comment_id)}`;
|
|
399
|
+
const where = policy !== null
|
|
400
|
+
? ` in the thread of ${policy.ref}`
|
|
401
|
+
: onPlan
|
|
402
|
+
? " on the plan"
|
|
403
|
+
: "";
|
|
365
404
|
// DX-7616: a comment about an Evidence record names it, as a comment on a problem names the problem.
|
|
366
405
|
const evidence = d.evidence;
|
|
367
406
|
if (problem === undefined)
|
|
368
407
|
return evidence === undefined
|
|
369
|
-
? `${who} commented${
|
|
370
|
-
: `${who} commented${
|
|
408
|
+
? `${who} commented${where}: ${quoted(d.excerpt)}${reply}`
|
|
409
|
+
: `${who} commented${where} on Evidence record ${evidence.ref} ${quoted(evidence.question)}: ${quoted(d.excerpt)}${reply}`;
|
|
371
410
|
// DX-7108 (operator correction, comment 21778): a person's comment that answers the problem is recorded as its answer by the session, quoting the comment.
|
|
372
|
-
const answerHint = !isPersonsComment(event) || onPlan
|
|
411
|
+
const answerHint = !isPersonsComment(event) || onPlan || policy !== null
|
|
373
412
|
? ""
|
|
374
413
|
: `. If the comment decides the problem, record it as the answer in the same turn: POST /api/issues/${event.cardId}/problems/${problem.id}/answer with the chosen solution_id or freeform and provenance {"source":"comment","source_ref":"${d.comment_id}","quote":"<their words>"}`;
|
|
375
414
|
return `${who} commented on problem ${quoted(problem.statement)}: ${quoted(d.excerpt)}${reply}${answerHint}`;
|
package/dist/machine-toolkit.js
CHANGED
|
@@ -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.
|
|
615
|
+
false ? void 0 : "0.1.500",
|
|
616
616
|
readOwnManifest
|
|
617
617
|
);
|
|
618
618
|
function envelope(now) {
|
|
@@ -7,7 +7,9 @@ export const GET_ROUTE_BOARD_SCOPE = [
|
|
|
7
7
|
["/api/behavior-events", "refuse"],
|
|
8
8
|
["/api/behavior-events/:event/attachments", "refuse"],
|
|
9
9
|
["/api/behavior-policies", "refuse"],
|
|
10
|
+
["/api/behavior-policies/:ref/comments", "refuse"],
|
|
10
11
|
["/api/behavior-policy-groups", "refuse"],
|
|
12
|
+
["/api/behavior-policy-groups/:group/comments", "refuse"],
|
|
11
13
|
["/api/boards", "refuse"],
|
|
12
14
|
["/api/boards/:boardId", "refuse"],
|
|
13
15
|
["/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.
|
|
3
|
+
"version": "0.1.500",
|
|
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",
|