@50arms/platform-mcp 0.1.475 → 0.1.477

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/README.md CHANGED
@@ -18,7 +18,7 @@ BOARD-ONLY (DX-1171): board is the first-level concept; repo is DERIVED from boa
18
18
 
19
19
  An operator session has no stored credential. Signed out, `session_connect` (optionally with `title`, the session's own Claude title) posts `POST /api/access-requests` and answers at once `{state: "approval_required", approvalUrl, confirmCode, expiresAt, instruction}`: show the user the code and open the URL; they approve in the dashboard. The server polls `POST /api/access-requests/claim` in the background, so the key is stored when the approval lands; the next `session_connect` waits up to about 45 seconds for it, then connects, or answers `approval_pending`. One tool call never blocks for minutes. `denied` is reported once; a request that lapsed (the dashboard deletes it within about a minute of expiry, so a claim answers 404) starts a fresh one on the next call.
20
20
  - **A machine secret and an auto-approved request (DX-6764, PLAN-128).** Every `session` access request also sends `machineSecret`: one random secret per machine and per dashboard, made the first time it is needed in `~/.config/danxbot/machine-secrets/<sha12(dashboard url)>.json` (mode 0600, written durably, then hard-linked into place so two sessions starting at once on a fresh machine end up with the same one; an unusable file is a loud error, never replaced). The dashboard keeps only its hash, so a person can let later sessions from this machine sign in by themselves; it is never sent to another dashboard, and the `machine` daemon's request and a dispatched agent's credential are unchanged. When the create answer says `autoApproved: true` no person decides the request: the first claim is not delayed, `session_connect` waits up to about 45 seconds for the key and answers signed in with no `approvalUrl` or `confirmCode`; a claim slower than that answers `{state: "signing_in"}`, still with no link. `autoApproved` is required in the create answer: a dashboard that does not send it fails the request loudly. A request left pending behaves as above.
21
- - **A launch token (DX-6801, DEC-522).** `session_connect` takes an optional `launch_token`: the one-use token the session that started this one passed in its prompt. A signed-out session given one redeems it once per process through the public `POST /api/access-requests/claim` with `{secret: <token>, labelId: <this session's id>}` (`labelId` is sent only on a redeem); `approved` stores the key like an approval and answers signed in, with no access request. Any other answer (`claimed`, `expired`, 404, 409 `launch_grant_refused` with its `reason`, 429) spends the token and falls through to the usual person's request, the answer carrying a `note` that names why the token was not used. A signed-in session ignores the token.
21
+ - **A launched session signs in by its grant (DX-7586, DEC-1127).** A signed-out `session_connect` with a `target`, on a registered machine, first calls the public `POST /api/access-requests/launch-claim` with `{machineSecret, labelId: <this session's id>, target}`: the dashboard redeems the grant a session on this machine wrote for that plan or card (`POST /api/session-launch-grants`), so no token passes through any agent. `approved` stores the key like an approval and answers signed in, with no access request. `none` (or a 404 from a dashboard without the route) goes on to the usual person's request; a refusal (409 `launch_grant_refused` with its `reason`, 403, 429) goes on too, the answer carrying a `note` that names why the grant was not used.
22
22
 
23
23
  - **Storage.** `~/.config/danxbot/session-keys/<sha12(dashboard url)>/<session id>.json`, mode 0600, written write-then-rename, pruned after 7 days. One file per dashboard and per session; this server reads it at boot, and `restart_notice` reads the same file through the `session-key` credential source and proves the fingerprint. The key lapses on the dashboard after 24 hours without use (every authenticated call, the relay's heartbeat included, renews it), and is revocable from the account page.
24
24
  - **A 401 on the stored key** deletes the file and returns the sign-in halt (in `session_connect`: a new request in the same call). That is a key that lapsed. A key a PERSON revoked is answered `401 key_revoked` (DX-4418): the key file is deleted and EVERY dashboard tool, `session_connect` included, returns one stop halt (who revoked it and when; commit work in progress and end; a dispatched agent makes no further call), for the rest of the process. No access request is made. The worker finds the revocation itself and ends the dispatch as revoked (every dashboard route, the dispatch-complete one included, refuses a revoked key). `plan_events_wait` answers `stopped` with the reason `key_revoked` the same way. **A 404 on create** means the dashboard predates request-and-approve and says so.
@@ -120,4 +120,4 @@ make test PROJECT=packages/danx-dashboard-mcp FILES=.e2e.test.ts
120
120
 
121
121
  ## Publishing
122
122
 
123
- Out of scope for this package's own code — the `make publish-platform-mcp` target in the danxbot root Makefile owns version bump + `npm publish` + propagation wait. Standing operator authorization per `~/.claude/skills/thehammer-publish/`.
123
+ Out of scope for this package's own code — the `make publish` target in the danxbot root Makefile owns version bump + `npm publish` + propagation wait. Standing operator authorization per `~/.claude/skills/thehammer-publish/`.
@@ -84,14 +84,9 @@ export async function createAccessRequest(fetchImpl, dashboardUrl, input) {
84
84
  };
85
85
  return { kind: "refused", status, body: json };
86
86
  }
87
- /**
88
- * DX-6801: `labelId` rides along ONLY when redeeming a launch token (the secret is then the token a parent session passed in this
89
- * session's prompt, and `labelId` this session's id, which the dashboard stores the key under); a normal poll sends `{secret}` alone.
90
- * A launch redeem the dashboard refuses answers 409 `launch_grant_refused` with a `reason`: that is a `refused` answer, body as sent.
91
- */
92
- export async function claimAccessRequest(fetchImpl, dashboardUrl, secret, labelId) {
87
+ export async function claimAccessRequest(fetchImpl, dashboardUrl, secret) {
93
88
  const url = `${baseOf(dashboardUrl)}/api/access-requests/claim`;
94
- const { status, headers, json } = await postPublic(fetchImpl, url, labelId === undefined ? { secret } : { secret, labelId });
89
+ const { status, headers, json } = await postPublic(fetchImpl, url, { secret });
95
90
  if (status === 404)
96
91
  return { kind: "not_found" };
97
92
  if (status === 429)
@@ -117,3 +112,32 @@ export async function claimAccessRequest(fetchImpl, dashboardUrl, secret, labelI
117
112
  throw new Error(`[platform-mcp] POST ${url} answered an unknown status: ${JSON.stringify(json)}`);
118
113
  }
119
114
  }
115
+ /**
116
+ * DX-7586 (DEC-1127) - a signed-out session redeems the launch grant its parent wrote for `target` (the plan or card its `session_connect` names), from this machine, with no token: the machine's
117
+ * registration secret is the credential. A dashboard from before DX-7586 has no such route and answers 404: no grant can wait there, so that is `none` too. A grant the dashboard will no longer let
118
+ * mint a key answers 409 `launch_grant_refused` with a `reason`, a `refused` answer with its body as sent.
119
+ */
120
+ export async function claimLaunchGrant(fetchImpl, dashboardUrl, input) {
121
+ const url = `${baseOf(dashboardUrl)}/api/access-requests/launch-claim`;
122
+ const { status, headers, json } = await postPublic(fetchImpl, url, input);
123
+ if (status === 404)
124
+ return { kind: "none" };
125
+ if (status === 429)
126
+ return {
127
+ kind: "rate_limited",
128
+ retryAfterSeconds: retryAfterSeconds(headers),
129
+ };
130
+ if (status !== 200)
131
+ return { kind: "refused", status, body: json };
132
+ const body = json;
133
+ switch (body?.status) {
134
+ case "none":
135
+ return { kind: "none" };
136
+ case "approved":
137
+ if (typeof body.apiKey !== "string" || body.apiKey === "")
138
+ throw new Error(`[platform-mcp] POST ${url} answered approved without an apiKey`);
139
+ return { kind: "approved", apiKey: body.apiKey };
140
+ default:
141
+ throw new Error(`[platform-mcp] POST ${url} answered an unknown status: ${JSON.stringify(json)}`);
142
+ }
143
+ }
package/dist/handlers.js CHANGED
@@ -340,7 +340,7 @@ export async function attachFile(client, args, deps = {}) {
340
340
  // DX-4386: `primary` is the dashboard's own atomic option (one live cover, set in the write's own transaction); an absent flag sends no key.
341
341
  const primary = args.primary === undefined ? {} : { primary: args.primary };
342
342
  if (args.replaces !== undefined) {
343
- return client.request({
343
+ return withAttachNextStep(await client.request({
344
344
  method: "PUT",
345
345
  basePath: "/api/issues",
346
346
  path: `${issuePath}/${args.replaces}`,
@@ -350,12 +350,12 @@ export async function attachFile(client, args, deps = {}) {
350
350
  ...primary,
351
351
  },
352
352
  board: args.board,
353
- });
353
+ }));
354
354
  }
355
355
  const filename = args.filename?.trim()
356
356
  ? args.filename.trim()
357
357
  : basename(args.path);
358
- return client.request({
358
+ return withAttachNextStep(await client.request({
359
359
  method: "POST",
360
360
  basePath: "/api/issues",
361
361
  path: issuePath,
@@ -366,7 +366,22 @@ export async function attachFile(client, args, deps = {}) {
366
366
  ...primary,
367
367
  },
368
368
  board: args.board,
369
- });
369
+ }));
370
+ }
371
+ /**
372
+ * DX-7594 (DEC-1130): a stored card attachment answers its own next step, so no role text has to explain what to do with the reply. A refusal passes through
373
+ * verbatim (its body names the fix). MACHINE-ONLY: the calling agent reads `next_step`; no person sees it.
374
+ */
375
+ function withAttachNextStep(result) {
376
+ if (!result.ok || typeof result.body !== "object" || result.body === null)
377
+ return result;
378
+ return {
379
+ ...result,
380
+ body: {
381
+ ...result.body,
382
+ next_step: "Stored. Next: embed `url` as `![description](url)` in any markdown field, and for a later version of the same picture call attach_file again with `replaces` set to this reply's `attachment_id` (never a growing list).",
383
+ },
384
+ };
370
385
  }
371
386
  /**
372
387
  * DX-5241 / PLAN-47 CAV-1: upload a local image to `POST /api/uploads/images` and answer its permanent URL plus the markdown to embed it
@@ -411,5 +426,12 @@ async function uploadInlineImage(client, args, read, fileSize, { basename, extna
411
426
  throw new Error("attach_file: the image upload answered no url");
412
427
  }
413
428
  const alt = basename(args.path, extname(args.path)).replace(/[[\]]/g, "");
414
- return { ...result, body: { url, markdown: `![${alt}](${url})` } };
429
+ return {
430
+ ...result,
431
+ body: {
432
+ url,
433
+ markdown: `![${alt}](${url})`,
434
+ next_step: "Uploaded. Next: put `markdown` in the markdown body you are writing (a `POST /api/feedback` body, for one).",
435
+ },
436
+ };
415
437
  }
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import { keyRevokedHalt } from "./key-revoked-halt.js";
11
11
  import { oneLine } from "./one-line.js";
12
+ import { fixForStop } from "./stop-fixes.js";
12
13
  import { DIGEST_PREFIX } from "./digest-hold.js";
13
14
  import { HEARTBEAT_SILENT_FAILURE_THRESHOLD, sendHeartbeat, } from "./session-stream.js";
14
15
  import { OperatorSessionStats, } from "./session-stats.js";
@@ -17,6 +18,7 @@ import { backAgainText, durationWording, } from "./dashboard-reachability.js";
17
18
  /** DX-5415: how long a stop waits for the final settle (drain + one stats flush) before giving up; shutdown must stay bounded. */
18
19
  export const FINAL_SETTLE_BOUND_MS = 10_000;
19
20
  /**
21
+ * DX-7602 (DEC-1130): a stopped listener's notice carries the exact fix for its stop reason (`fixForStop`), not a pointer to another call.
20
22
  * DX-5088 / DX-7110 - what a relay says of a notice from the shared reachability state: the sustained-outage wording follows the listener's
21
23
  * state, because a stopped relay (a terminal outcome) does not reconnect by itself, so "keeps reconnecting" would be false.
22
24
  */
@@ -26,8 +28,7 @@ function noticeLine(notice, connection) {
26
28
  const length = durationWording(notice.ms);
27
29
  const wording = connection.state === "stopped"
28
30
  ? `this session's listener has stopped${connection.reason === undefined ? "" : ` (${connection.reason})`} and does not reconnect by itself, ` +
29
- `so the dashboard has heard nothing from it for ${length}. The next plan_events_wait call says why it stopped and what to do; ` +
30
- `a person can also restart the session.`
31
+ `so the dashboard has heard nothing from it for ${length}. To fix: ${fixForStop(connection.reason ?? "")}.`
31
32
  : `this session's listener has not reached the dashboard for ${length} (its heartbeats keep failing). ` +
32
33
  `It keeps reconnecting on its own, and nothing is needed from you.`;
33
34
  return oneLine(`${DIGEST_PREFIX} ${wording}`);
package/dist/index.js CHANGED
@@ -746,10 +746,10 @@ renamedTool("50arms_api_spec",
746
746
  // might hold locally, e.g. the Slack recovery agent's CSV path).
747
747
  strictTool("attach_file", "Upload a LOCAL file. This server reads and uploads the bytes, so they never pass through your context. " +
748
748
  '`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). ' +
749
- "Card target returns `{issue, attachment_id, url, thumbnail_url, is_primary}`: `url` is permanent, embed it in any " +
749
+ "Card target returns `{issue, attachment_id, url, thumbnail_url, is_primary, next_step}`: `url` is permanent, embed it in any " +
750
750
  "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 " +
751
751
  "large CSV or log into a card field. " +
752
- '`target: "inline_image"` instead uploads a local png/jpeg/gif/webp/avif (25 MB) with NO card and returns `{url, markdown}`: put the ' +
752
+ '`target: "inline_image"` instead uploads a local png/jpeg/gif/webp/avif (25 MB) with NO card and returns `{url, markdown, next_step}`: put the ' +
753
753
  "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).", {
754
754
  target: z
755
755
  .enum(["card", "inline_image"])
@@ -1061,7 +1061,7 @@ strictTool("session_connect",
1061
1061
  .string()
1062
1062
  .min(1)
1063
1063
  .optional()
1064
- .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)."),
1064
+ .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."),
1065
1065
  title: z.string().min(1).optional().describe(
1066
1066
  // DX-4608: stored as sent; a wrong one does not refuse the connect, the reply's `naming` says what to rename it to.
1067
1067
  "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,11 +1083,6 @@ strictTool("session_connect",
1083
1083
  .describe(
1084
1084
  // DX-6939: read only by a call that makes a sign-in claim; a signed-in session's call ignores it.
1085
1085
  "The key of the team role this session's key is minted with when this call signs it in: default `session`, the system agent role every team has that a Member holds within. Name `agent` (what a dispatched worker runs on) only when a person said so: it holds keys a Member lacks, so the sign-in is refused unless that person holds them too. It must be an agent role within what the person this machine is registered to holds, or the sign-in is refused. Omit it unless a person named another role."),
1086
- launch_token: z
1087
- .string()
1088
- .min(1)
1089
- .optional()
1090
- .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."),
1091
1086
  person_sign_in: z.boolean().optional().describe(
1092
1087
  // 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.
1093
1088
  "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."),
@@ -1112,7 +1107,8 @@ async (args) => {
1112
1107
  return haltResult("session_connect: `disconnect: true` needs `target`, the plan or card this session currently holds");
1113
1108
  }
1114
1109
  // DX-4390 — no key yet: ask for one (or wait for the approval already asked for).
1115
- const ready = await access.ensureAccess(args.title, args.launch_token, args.role);
1110
+ // DX-7586: `target` lets a session another one started for it sign in by the grant waiting there.
1111
+ const ready = await access.ensureAccess(args.title, args.role, args.target);
1116
1112
  if (!ready.signedIn)
1117
1113
  return accessReply(ready);
1118
1114
  if (args.target === undefined) {
@@ -1145,7 +1141,7 @@ async (args) => {
1145
1141
  return haltResult(revokedHalt);
1146
1142
  // DX-4390 — the dashboard no longer accepts the stored key: drop it and ask again in the same call.
1147
1143
  if (result.status === 401 && access.dropKey(result)) {
1148
- return accessReply(await access.ensureAccess(args.title, undefined, args.role), "the dashboard no longer accepted this session's key");
1144
+ return accessReply(await access.ensureAccess(args.title, args.role), "the dashboard no longer accepted this session's key");
1149
1145
  }
1150
1146
  return finishConnect("session_connect", result, args.disconnect === true);
1151
1147
  });
@@ -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.475",
615
+ false ? void 0 : "0.1.477",
616
616
  readOwnManifest
617
617
  );
618
618
  function envelope(now) {
@@ -3,14 +3,26 @@ import { checkedTranscriptPath } from "./session-stats.js";
3
3
  * DX-4233 - the body of the `plan_events_wait` tool: the transcript path is checked (a refusal names it), then the relay waits,
4
4
  * and a cancelled request (`signal`, the SDK's `extra.signal`) drops the pending wait. A malformed cursor is refused by the relay.
5
5
  */
6
- export function servePlanEventsWait(relay, args, signal) {
6
+ export async function servePlanEventsWait(relay, args, signal) {
7
7
  const transcriptPath = args.transcript_path === undefined
8
8
  ? undefined
9
9
  : checkedTranscriptPath(args.transcript_path, "plan_events_wait transcript_path");
10
- return relay.wait({
10
+ const answer = await relay.wait({
11
11
  planId: args.plan_id,
12
12
  cursor: args.cursor,
13
13
  timeoutMs: args.timeout_ms,
14
14
  transcriptPath,
15
15
  }, signal);
16
+ return { ...answer, next: nextStep(answer, args.cursor) };
17
+ }
18
+ /** DEC-1130 / DX-7604: the reply names its own next call, so no role text has to explain how to re-arm or what a stop means. */
19
+ export function nextStep(answer, sentCursor) {
20
+ if ("stopped" in answer) {
21
+ const { reason, fix } = answer.stopped;
22
+ return `Stopped (${reason}): ${fix} Do not call plan_events_wait again until that is done.`;
23
+ }
24
+ const last = answer.events[answer.events.length - 1];
25
+ if (last !== undefined)
26
+ return `Take every record, then call plan_events_wait again with cursor "${last.cursor}" (the newest record you took).`;
27
+ return `Nothing new: call plan_events_wait again with ${sentCursor === null ? "no cursor" : `cursor "${sentCursor}"`} (the one you sent).`;
16
28
  }
@@ -26,7 +26,7 @@
26
26
  */
27
27
  import { existsSync } from "node:fs";
28
28
  import { hostname } from "node:os";
29
- import { claimAccessRequest, createAccessRequest, } from "./access-request.js";
29
+ import { claimAccessRequest, claimLaunchGrant, createAccessRequest, } from "./access-request.js";
30
30
  import { credentialFingerprint, } from "./credential.js";
31
31
  import { keyRevocationOf, keyRevokedHalt, } from "./key-revoked-halt.js";
32
32
  import { callMachineRegistration, deleteMachineRegistration, readMachineRegistration, writeMachineRegistration, } from "./machine-registration.js";
@@ -101,34 +101,21 @@ const REGISTRATION_STILL_MISMATCHED_ERROR = "the dashboard refused this sign-in
101
101
  const NO_SESSION_ID_ERROR = "this server has no CLAUDE_CODE_SESSION_ID, so it cannot request a session key";
102
102
  const CLAIMED_LOST_ERROR = "the dashboard says this request was already claimed, but this process never received the key; " +
103
103
  "start a new request";
104
- /** DX-6801: why a launch token signed nobody in; the session then asks a person as any signed-out session does. */
105
- const launchNote = (why) => `The launch token was not used: ${why}. This session asks a person to approve it instead: show the user the confirm code and URL.`;
106
- function launchRefusalWhy(claim) {
107
- switch (claim.kind) {
108
- case "claimed":
109
- return "it was already redeemed (a launch token works once)";
110
- case "expired":
111
- return "it expired or was withdrawn";
112
- case "not_found":
113
- return "the dashboard does not know it";
114
- case "denied":
115
- return "the dashboard answered denied";
116
- case "pending":
117
- return "the dashboard answered pending, which a launch token never is";
118
- case "rate_limited":
119
- return `the dashboard rate limited the redeem (retry after ${claim.retryAfterSeconds}s) and a token is tried once per process`;
120
- case "refused": {
121
- const body = claim.body;
122
- if (claim.status === 409 && body?.error === "launch_grant_refused") {
123
- const missing = Array.isArray(body.missingPermissions) &&
124
- body.missingPermissions.length > 0
125
- ? ` (missing permissions: ${body.missingPermissions.join(", ")})`
126
- : "";
127
- return `the dashboard refused the launch grant: ${String(body.reason)}${missing}`;
128
- }
129
- return `the dashboard refused the redeem (${claim.status}): ${JSON.stringify(claim.body)}`;
130
- }
104
+ /** DX-6801 / DX-7586: why the grant the starting session wrote signed nobody in; the session then asks a person as any signed-out session does. */
105
+ const launchNote = (why) => `The launch grant was not used: ${why}. This session asks a person to approve it instead: show the user the confirm code and URL.`;
106
+ /** DX-7586: why a launch claim (by machine and target) signed nobody in. */
107
+ function launchClaimWhy(claim) {
108
+ if (claim.kind === "rate_limited")
109
+ return `the dashboard rate limited the sign-in (retry after ${claim.retryAfterSeconds}s)`;
110
+ const body = claim.body;
111
+ if (claim.status === 409 && body?.error === "launch_grant_refused") {
112
+ const missing = Array.isArray(body.missingPermissions) &&
113
+ body.missingPermissions.length > 0
114
+ ? ` (missing permissions: ${body.missingPermissions.join(", ")})`
115
+ : "";
116
+ return `the dashboard refused the launch grant: ${String(body.reason)}${missing}`;
131
117
  }
118
+ return `the dashboard refused the sign-in (${claim.status}): ${JSON.stringify(claim.body)}`;
132
119
  }
133
120
  export const EXPIRED_NOTE = "The previous request expired before it was approved: the dashboard stopped hearing from this session. This is a new " +
134
121
  "request: show the user its new confirm code and URL.";
@@ -152,8 +139,6 @@ export class SessionAccess {
152
139
  // DX-4390: two concurrent signed-out session_connect calls must not each post a request.
153
140
  ensureQueue = Promise.resolve();
154
141
  lastKeyFileWrite = 0;
155
- // DX-6801: a launch token is redeemed at most once per process, whatever the answer.
156
- launchTokenTried = false;
157
142
  // DX-5882: why this server holds no credential (null while it holds one); logged with every "Not signed in" halt.
158
143
  signedOutCause = null;
159
144
  fetchImpl;
@@ -298,16 +283,16 @@ export class SessionAccess {
298
283
  * `session_connect` returns: the request just made, the one still pending (after waiting up to
299
284
  * `awaitMs` for it), or why there is none. Calls run one at a time.
300
285
  *
301
- * DX-6801 / DEC-522: a signed-out session given the `launchToken` the session that started it passed in its prompt redeems it
302
- * (once per process) through the public claim route, with no person approving. Any answer but `approved` spends the token and
303
- * falls through to the person's request, the answer carrying a `note` that says why the token was not used.
286
+ * DX-7586 (DEC-1127): a signed-out session on a registered machine whose call names a `target` first redeems the launch grant a session on this machine wrote for that plan or card, with no
287
+ * token and no person approving (`claimLaunchGrant`). `none` goes on as below; a refusal goes on too, the answer carrying a `note` that says why the grant was not used.
288
+ *
304
289
  */
305
- ensureAccess(title, launchToken, role) {
306
- const run = this.ensureQueue.then(() => this.ensureAccessNow(title, launchToken, role));
290
+ ensureAccess(title, role, target) {
291
+ const run = this.ensureQueue.then(() => this.ensureAccessNow(title, role, target));
307
292
  this.ensureQueue = run.catch(() => undefined);
308
293
  return run;
309
294
  }
310
- async ensureAccessNow(title, launchToken, role) {
295
+ async ensureAccessNow(title, role, target) {
311
296
  // DX-4418: a person revoked this session's access; it asks again only after `personSignIn` (DX-6894).
312
297
  const revokedHalt = this.revokedHalt();
313
298
  if (revokedHalt !== null)
@@ -319,12 +304,18 @@ export class SessionAccess {
319
304
  return notReady({ state: "no_session_id", error: NO_SESSION_ID_ERROR }, true);
320
305
  }
321
306
  let note;
322
- // DX-6801: only while no request of this process is open (a person's approval already in flight stays the way in).
323
- if (launchToken !== undefined &&
324
- !this.launchTokenTried &&
325
- this.pending === null) {
326
- this.launchTokenTried = true;
327
- const claim = await claimAccessRequest(this.fetchImpl, this.deps.dashboardUrl, launchToken, sessionId);
307
+ // DX-7586: only on a registered machine (its secret is the credential) and while no request of this process is open (a person's approval already in flight stays the way in).
308
+ if (target !== undefined &&
309
+ this.pending === null &&
310
+ readMachineRegistration(this.deps.dashboardUrl, this.deps.home) !== null) {
311
+ const claim = await claimLaunchGrant(this.fetchImpl, this.deps.dashboardUrl, {
312
+ machineSecret: machineSecretFor(this.deps.dashboardUrl, {
313
+ home: this.deps.home,
314
+ now: this.now(),
315
+ }),
316
+ labelId: sessionId,
317
+ target,
318
+ });
328
319
  if (claim.kind === "approved") {
329
320
  const stored = this.storeKey(claim.apiKey);
330
321
  if (stored.kind === "approved")
@@ -332,11 +323,11 @@ export class SessionAccess {
332
323
  if (stored.kind === "failed")
333
324
  return notReady({ state: "request_failed", error: stored.error }, true);
334
325
  }
335
- else {
336
- note = launchNote(launchRefusalWhy(claim));
326
+ else if (claim.kind !== "none") {
327
+ note = launchNote(launchClaimWhy(claim));
337
328
  }
338
329
  }
339
- // DX-7010: a machine with no registration makes no access request; `env` credentials and launch tokens returned above and never reach this.
330
+ // DX-7010: a machine with no registration makes no access request; `env` credentials returned above and never reach this.
340
331
  const unregistered = await this.machineRegistrationAnswer(note);
341
332
  if (unregistered !== null)
342
333
  return unregistered;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@50arms/platform-mcp",
3
- "version": "0.1.475",
3
+ "version": "0.1.477",
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",