@sjawhar/claude-envoy 6.5.1 → 6.7.0

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.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "6.5.1"
5
+ "version": "6.7.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.5.1",
3
+ "version": "6.7.0",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
package/README.md CHANGED
@@ -36,7 +36,8 @@ message from Dispatch's Agents page as that person's own turn.
36
36
  Dispatch is on or off, a checkout's
37
37
  `.opencode/envoy.json`, which is not read, is one `envoy: <file> is not read: mkdir -p … && mv …`
38
38
  line while the checkout has no `.envoy/envoy.json`. The `dispatch` command reads the file
39
- `ENVOY_CONFIG_FILE` names whenever `DISPATCH_HOST` is set. A subagent's Bash can lack what the
39
+ `ENVOY_CONFIG_FILE` names whenever `DISPATCH_HOST` is set (`dispatch login` reads none, and
40
+ `dispatch proxy` none without `DISPATCH_TOKEN_BROKER=1`). A subagent's Bash can lack what the
40
41
  hook writes there (Claude Code issue 46696); its `dispatch` command, finding no
41
42
  `DISPATCH_HOST`, then takes host `claude` from the `CLAUDE_CODE_CHILD_SESSION=1` Claude Code sets
42
43
  in every Bash, and reads `CLAUDE_CONFIG_DIR` itself. With Dispatch configured,
@@ -248,7 +249,8 @@ which Claude Code sets fresh in every Bash command and moves to the new id on `/
248
249
  `DISPATCH_SESSION_ID` inherited from a parent session is ignored. A write that makes the session
249
250
  follow an ask prints `Following ask <id> on <issue>: …` once per ask, after its result; a result
250
251
  longer than 25,000 characters is written to a file the output names. It reads the envoy.json
251
- below on every call.
252
+ below on every call. `dispatch login` acts as no session and reads no envoy.json, and
253
+ `dispatch proxy` reads it only under `DISPATCH_TOKEN_BROKER=1`.
252
254
 
253
255
  Dispatch asks remain on native Dispatch.
254
256
  An Envoy delivery is one-way ingress, not a remote
@@ -573,7 +575,8 @@ socket carries no agent stream, so neither live view
573
575
  takes its control subject and the Agents page shows nothing of the session's turns, which the
574
576
  start notice says. The `open-asks` hook
575
577
  hands the file on to the session's Bash as `ENVOY_CONFIG_FILE` beside `DISPATCH_HOST=claude`, and
576
- the `dispatch` command reads the file `ENVOY_CONFIG_FILE` names whenever `DISPATCH_HOST` is set; a
578
+ the `dispatch` command reads the file `ENVOY_CONFIG_FILE` names whenever `DISPATCH_HOST` is set
579
+ (but for `dispatch login`, and for `dispatch proxy` without `DISPATCH_TOKEN_BROKER=1`); a
577
580
  Bash with neither, as a subagent's can be, has `CLAUDE_CODE_CHILD_SESSION=1` and takes this plugin's
578
581
  rule. With Envoy off the channel server lists no tool, refuses every call with
579
582
  `Envoy is off for this session: <why>` (the section's notice or error), subscribes nothing, and
@@ -15112,7 +15112,7 @@ var dispatchToolSpecs = [
15112
15112
  {
15113
15113
  name: "dispatch_project_update",
15114
15114
  example: { project: "CORE", proven_sessions: "on" },
15115
- description: "Turn a project's proven-sessions setting on or off. With it on, an architect's write of an " + "issue's spec or Verification document passes only on a credential that proves the " + "architect's session. A role-holder publication then passes only on a credential that " + "proves legion-daemon:<project>. on sends PUT /api/v1/projects/{key}/proven-sessions, which " + "any credential that may write the project's issues may send. off sends DELETE on the same " + "path, which needs the person scope: a credential without it is refused with 403 " + "OAUTH_SCOPE_REQUIRED, and the shared token and a pod's token hold none. A token scoped to " + "another project is refused with 403 PROJECT_SCOPE. Only the project's roll-out issue " + "turns it on, once the project's daemon and pods write with their own tokens. Turned on " + "before that, it stops every architect write and every role-holder publication on the " + "shared token, until a person turns it off. The answer names the project and the setting " + "as Dispatch stored it.",
15115
+ description: "Turn a project's proven-sessions setting on or off. With it on, an architect's write of an " + "issue's spec or Verification document passes only on a credential that proves the " + "architect's session. A role-holder publication then passes only on a credential that " + "proves legion-daemon:<project>, or legion-daemon:<P> of another project's daemon on a " + "broker token that names P. on sends PUT /api/v1/projects/{key}/proven-sessions, which " + "any credential that may write the project's issues may send. off sends DELETE on the same " + "path, which needs the person scope: a credential without it is refused with 403 " + "OAUTH_SCOPE_REQUIRED, and the shared token and a pod's token hold none. A token scoped to " + "another project turns the setting on, as the shared token does, and off only with the " + "person scope. A token scoped to one project gets 403 PROJECT_SCOPE for a project that " + "does not exist and for a private project that it does not name. Only the project's " + "roll-out issue turns it on, once the project's daemon and pods write with their own " + "tokens. Turned on before that, it stops every architect write and every role-holder " + "publication on the shared token, until a person turns it off. The answer names the " + "project and the setting as Dispatch stored it.",
15116
15116
  arguments: (z) => ({
15117
15117
  project: z.string().describe("Project key whose setting to change, such as CORE."),
15118
15118
  proven_sessions: z.enum(["on", "off"]).describe("on turns the setting on; off turns it off and needs the person scope.")
@@ -15165,7 +15165,7 @@ var dispatchToolSpecs = [
15165
15165
  {
15166
15166
  name: "dispatch_whoami",
15167
15167
  example: {},
15168
- description: "Who Dispatch takes this session for: {session, owner, service, project, project_scope}. session is the session Dispatch records your writes as. It is the session your credential proved, and the tool says so when that is not the session you run in. owner is the lowercase email of the person you act for, and is the first choice of assignee for issues you create. owner is null under the shared token and under a broker token that names a service and no person. With a null owner, a create with no assignee falls back to the parent's assignee, when the parent is in the issue's own project, and then to the project's default assignee, which every project names, so every issue you create has an assignee. A question on an issue reaches the person it was handed to, else the issue's assignee, else the project's default assignee. service is the subject of the verified service-account token that authenticated you, or the service a broker token naming no person names: a job's identity as its job entry lists it, the Kubernetes account an exchange entry lists, or the fleet of a machine nobody has signed in on; else null. project_scope is a broker token's project scope, and null for every other credential. A job's broker token has the project scope named or public, holds no OAuth scope and writes as its service: a route that needs an OAuth scope refuses it with 403 OAUTH_SCOPE_REQUIRED before Dispatch's project check runs. named may write its one project, and that check judges its write to another project as it judges a person's named token's for the same project: 403 PROJECT_SCOPE until dispatch://INFRA-4799 changes that answer for both. public names no one project, so it may write wherever a token that names no project may. An exchange entry's broker token that names its account has the project scope named and no project, and writes as that account wherever a token that names no project may. A machine's broker token that names a service has the project scope person; it may read and is refused every write with SIGN_IN_REQUIRED, which names the command a person signs in on that machine with. project is the one project key your credential may write, or null when it names none.",
15168
+ description: "Who Dispatch takes this session for: {session, owner, service, project, project_scope}. session is the session Dispatch records your writes as. It is the session your credential proved, and the tool says so when that is not the session you run in. owner is the lowercase email of the person you act for, and is the first choice of assignee for issues you create. owner is null under the shared token and under a broker token that names a service and no person. With a null owner, a create with no assignee falls back to the parent's assignee, when the parent is in the issue's own project, and then to the project's default assignee, which every project names, so every issue you create has an assignee. A question on an issue reaches the person it was handed to, else the issue's assignee, else the project's default assignee. service is the subject of the verified service-account token that authenticated you, or the service a broker token naming no person names: a job's identity as its job entry lists it, the Kubernetes account an exchange entry lists, or the fleet of a machine nobody has signed in on; else null. project_scope is a broker token's project scope, and null for every other credential. A job's broker token has the project scope named or public, holds no OAuth scope and writes as its service: a route that needs an OAuth scope refuses it with 403 OAUTH_SCOPE_REQUIRED before Dispatch's project check runs. named names one project, and that check judges its writes as it judges a person's named token's for the same project: it refuses a write that belongs to the deployment, such as a project create, with 403 PROJECT_SCOPE_DEPLOYMENT. public names no one project, so it may write wherever a token that names no project may. An exchange entry's broker token that names its account has the project scope named and no project, and writes as that account wherever a token that names no project may. A machine's broker token that names a service has the project scope person; it may read and is refused every write with SIGN_IN_REQUIRED, which names the command a person signs in on that machine with. project is the project your credential's token names, or null when it names none. A token that names a project also writes other projects' objects, as a credential that names none does. The one exception is a private project that the token does not name.",
15169
15169
  arguments: () => ({}),
15170
15170
  strict: true
15171
15171
  },
@@ -15179,7 +15179,7 @@ var dispatchToolSpecs = [
15179
15179
  {
15180
15180
  name: "dispatch_api",
15181
15181
  example: { path: "/api/v1/issues/DSP-1/events?limit=200" },
15182
- description: "Send one request of a route of Dispatch's HTTP API under /api/v1, with this session's own credential, and print the answer's body: Dispatch's JSON, indented, for jq to read; any other body of a 2xx, such as a file version's bytes or a document version's Markdown, as it came. It sends a GET of path unless method names another: path is a route beginning /api/v1, with its query after ?; dispatch api --path /api/v1 lists every route. With method it sends POST, PUT, PATCH or DELETE instead, and body, when given, as the request's JSON body (Content-Type: application/json), read from a file with --body-file <file> or from stdin with --body-file -; a body goes only with a method. A write that a named dispatch command makes goes through that command (dispatch --help lists them): dispatch api is for a route no command sends. In a session whose AskGate reviews Dispatch writes it sends GET alone, and refuses each method, naming the dispatch command that makes that write, and exits 1. It sends the request once, and once more only after Dispatch answers that the token it presented is not live (Dispatch then authenticated nothing, so nothing ran), with no redirect followed and no Idempotency-Key. On a 2xx answer it exits 0 and prints Dispatch's JSON as above, and any other body unchanged, with nothing added: an answer with Content-Disposition: attachment (a file version, a ?download=true read) is stored content, printed byte for byte whatever its type, JSON included. A 2xx whose body holds a credential the command presented (its token or its request's DPoP proof) is not printed: it exits 1 with CREDENTIAL_ECHOED, naming the status and saying a write may have been made. Any other answer exits 1 with its code: when Dispatch refuses the request, the command prints Dispatch's error with its code and, where Dispatch gives one, its hint; an answer that is neither a 2xx nor Dispatch's JSON, such as a proxy's page, is named by its status. A usage error, such as a path outside /api/v1 or a body with no method, exits 2. Where no host runs the command, as in a GitHub Actions job, it reads Dispatch from the environment alone, and a broker trade names the session of DISPATCH_SESSION_ID, else of AGENT_SECRETS_SESSION. Under Claude Code, a JSON answer longer than the output limit is written to a file the output names; a body printed as it came is written whole.",
15182
+ description: "Send one request of a route of Dispatch's HTTP API under /api/v1, with this session's own credential, and print the answer's body: Dispatch's JSON, indented, for jq to read; any other body of a 2xx, such as a file version's bytes or a document version's Markdown, as it came. It sends a GET of path unless method names another: path is a route beginning /api/v1, with its query after ?; dispatch api --path /api/v1 lists every route. With method it sends POST, PUT, PATCH or DELETE instead, and body, when given, as the request's JSON body (Content-Type: application/json), read from a file with --body-file <file> or from stdin with --body-file -; a body goes only with a method. A write that a named dispatch command makes goes through that command (dispatch --help lists them), or, for an issue comment POST that carries an Idempotency-Key, through dispatch proxy: dispatch api is for a route no command sends. In a session whose AskGate reviews Dispatch writes it sends GET alone, and refuses each method, naming the dispatch command that makes that write, and exits 1. It sends the request once, and once more only after Dispatch answers that the token it presented is not live (Dispatch then authenticated nothing, so nothing ran), with no redirect followed and no Idempotency-Key. On a 2xx answer it exits 0 and prints Dispatch's JSON as above, and any other body unchanged, with nothing added: an answer with Content-Disposition: attachment (a file version, a ?download=true read) is stored content, printed byte for byte whatever its type, JSON included. A 2xx whose body holds a credential the command presented (its token or its request's DPoP proof) is not printed: it exits 1 with CREDENTIAL_ECHOED, naming the status and saying a write may have been made. Any other answer exits 1 with its code: when Dispatch refuses the request, the command prints Dispatch's error with its code and, where Dispatch gives one, its hint; an answer that is neither a 2xx nor Dispatch's JSON, such as a proxy's page, is named by its status. A usage error, such as a path outside /api/v1 or a body with no method, exits 2. Where no host runs the command, as in a GitHub Actions job, it reads Dispatch from the environment alone, and a broker trade names the session of DISPATCH_SESSION_ID, else of AGENT_SECRETS_SESSION. Under Claude Code, a JSON answer longer than the output limit is written to a file the output names; a body printed as it came is written whole.",
15183
15183
  arguments: (z) => ({
15184
15184
  path: z.string({ min: 1 }).describe('The route, beginning /api/v1, with its query after ?, such as /api/v1/issues/ACME-12/events?limit=200. No scheme or host, no . or .. segment, and no ", <, >, ^, `, { or } before the query: percent-encode them.'),
15185
15185
  method: z.enum(DISPATCH_API_METHODS).describe("The method sent in place of GET: POST, PUT, PATCH or DELETE. Omit it to send a GET.").optional(),
@@ -19362,6 +19362,181 @@ function fileTextBytes(text) {
19362
19362
  return encoder2.encode(text);
19363
19363
  }
19364
19364
 
19365
+ // ../envoy-client/src/dispatch-login-command.ts
19366
+ var LOGIN_COMMAND = "login";
19367
+ var LOGIN_SENTENCE = "Logs this machine in at the secrets broker, once per machine, for a machine with no identity of its own, such as a laptop.";
19368
+ function loginHelp() {
19369
+ return [
19370
+ "Usage: dispatch login --device [--person <address>]",
19371
+ "",
19372
+ `${LOGIN_SENTENCE} It prints a code and the page to type it into; the person the login names approves it there, signed in to Dispatch. The login is then kept in the file AGENT_SECRETS_DEVICE_LOGIN_FILE names (default ~/.config/legion/device-login.json), mode 0600, and every session that sets AGENT_SECRETS_MACHINE_IDENTITY=device-login trades it for its broker token.`,
19373
+ "",
19374
+ "Flags:",
19375
+ " --device",
19376
+ " Log in with the broker's device grant: the only way there is, and required.",
19377
+ " --person <address>",
19378
+ " The person who approves the login, by the address they sign in to Dispatch with; else AGENT_SECRETS_PERSON.",
19379
+ "",
19380
+ "It reads AGENT_SECRETS_URL, the broker, and needs no Dispatch host or session.",
19381
+ "",
19382
+ "It exits 0 once the login is kept; 1 when the broker could not be reached or refused it, the person denied it, its code expired, or the login could not be kept; and 2 on a usage error, before any request.",
19383
+ "",
19384
+ "Example: dispatch login --device --person ada@example.com",
19385
+ ""
19386
+ ].join(`
19387
+ `);
19388
+ }
19389
+
19390
+ // ../envoy-client/src/dispatch-proxy-command.ts
19391
+ import { resolve } from "path";
19392
+ var PROXY_COMMAND = "proxy";
19393
+ var PROXY_SENTENCE = "Runs a command with a proxy on a unix socket that sends the command's Dispatch reads, and its comment POSTs that carry an Idempotency-Key, with this session's broker token.";
19394
+ var SOCKET_PATH_MAX_BYTES = 107;
19395
+ function proxyExitLine(requests, trades, renewed) {
19396
+ return `dispatch proxy: ${requests} requests, ${trades} trades, ${renewed} after BROKER_TOKEN_NOT_ACTIVE`;
19397
+ }
19398
+ function proxyHelp() {
19399
+ return [
19400
+ "Usage: dispatch proxy --socket <path> [--dry-run] -- <command> [<argument>...]",
19401
+ "",
19402
+ PROXY_SENTENCE,
19403
+ "",
19404
+ "The proxy listens on a unix socket at <path> for the whole run of <command>. It sends each",
19405
+ "request it takes to the Dispatch server and the session that a dispatch command resolves in",
19406
+ "the same environment, with this session's broker token and a new DPoP proof. So the tool",
19407
+ "holds no credential and signs nothing. It adds the path of each request to the path of the",
19408
+ "Dispatch URL, and it does not decode the query. The proxy trades for the token once before it",
19409
+ "starts the command, and again only when the token has less than 5 minutes to live, or after",
19410
+ "Dispatch answers 401 BROKER_TOKEN_NOT_ACTIVE. It runs only under DISPATCH_TOKEN_BROKER=1.",
19411
+ "",
19412
+ "What it sends:",
19413
+ " GET /api/... any GET whose path starts with /api/",
19414
+ " POST /api/v1/issues/<key>/comments a comment that carries an Idempotency-Key header",
19415
+ "It sends no other write. A tool reads much and writes little. Where a dispatch command sends a",
19416
+ "write, the write goes through that command, so AskGate reviews it wherever AskGate gates that",
19417
+ "command. The proxy's refusal of the write names that command. Where no other dispatch command",
19418
+ "sends a write under /api/v1, the refusal names dispatch api --method, which sends it outside a",
19419
+ "session whose AskGate reviews Dispatch writes. The comment needs a key so that a resend posts",
19420
+ "it once. The comment POST passes no AskGate review. The proxy is not one of the writes that",
19421
+ "AskGate gates, and the Dispatch server checks no marker. A session that holds a Dispatch token",
19422
+ "can post the same comment with that token already.",
19423
+ "",
19424
+ "It listens on a unix socket only, made with mode 0600, and opens no TCP port. The roles of a",
19425
+ "pod share the pod's network, so a port would let another role act as this one. A socket path",
19426
+ "that exists is refused, so give it a path in a new directory (mktemp -d). A socket that a",
19427
+ "killed proxy left behind refuses the next start.",
19428
+ "",
19429
+ "How a tool calls it: the command runs with DISPATCH_PROXY_SOCKET set to the socket's path.",
19430
+ "The host in a URL is not read. Write the path and the query.",
19431
+ ' curl --unix-socket "$DISPATCH_PROXY_SOCKET" http://dispatch/api/v1/issues',
19432
+ " In Python, an http.client.HTTPConnection whose connect opens an AF_UNIX socket:",
19433
+ " import http.client, os, socket",
19434
+ " class ProxyConnection(http.client.HTTPConnection):",
19435
+ " def connect(self):",
19436
+ " self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)",
19437
+ ' self.sock.connect(os.environ["DISPATCH_PROXY_SOCKET"])',
19438
+ ' connection = ProxyConnection("dispatch")',
19439
+ ' connection.request("GET", "/api/v1/issues?project=DSP")',
19440
+ " answer = connection.getresponse()",
19441
+ " print(answer.status, answer.read())",
19442
+ "",
19443
+ "What it answers: Dispatch's status, headers and body as Dispatch sent them. An answer that",
19444
+ "carries Transfer-Encoding as well as Content-Length is the one exception: it comes back",
19445
+ "without that Content-Length (RFC 9112, section 6.3), with its body chunked. It follows no",
19446
+ "redirect. Its own refusals have a JSON body with a code and an error, and each code starts",
19447
+ "with PROXY_. No code of Dispatch's does. It never answers 403 or 404 of its own.",
19448
+ " 400 PROXY_TARGET_REFUSED a target that names a host (http://... or //...)",
19449
+ " 405 PROXY_METHOD_REFUSED each other method or path, and a comment POST with no",
19450
+ " Idempotency-Key. The error names the dispatch command to",
19451
+ " use, where one exists. For a write under /api/v1 that no",
19452
+ " other dispatch command sends, it names dispatch api",
19453
+ " --method. It also refuses a target that holds a # or a",
19454
+ " control character, and a path with a . or .. segment",
19455
+ " (plain or percent-encoded), a backslash, or %2F or %5C in",
19456
+ " either case: each can reach another route than the one the",
19457
+ " target names.",
19458
+ " 502 PROXY_TRADE_REFUSED the token has ended and the broker refused a new one. The",
19459
+ " error is in the broker's words.",
19460
+ " 502 PROXY_DISPATCH_UNREACHABLE Dispatch did not answer",
19461
+ "",
19462
+ "Flags:",
19463
+ " --socket <path>",
19464
+ " The socket to listen on. Also --socket=<path>. A path over 107 bytes is refused.",
19465
+ " --dry-run",
19466
+ " Checks the arguments and the environment, prints the Dispatch server, the session and",
19467
+ " the socket it would use, and starts nothing.",
19468
+ " --help",
19469
+ " Prints this help.",
19470
+ "Every word after -- is the command's, flags included.",
19471
+ "",
19472
+ "It exits with the command's status. A command that a signal ended is 128 plus the signal's",
19473
+ "number. A command that does not exist is 127, and one that cannot run is 126. It exits 2 when",
19474
+ "it cannot start, and runs no command then. It sends SIGTERM, SIGINT and SIGHUP on to the",
19475
+ "command and serves until the command ends. Then it removes its socket. The last line it",
19476
+ "writes on standard error is:",
19477
+ " dispatch proxy: <n> requests, <m> trades, <r> after BROKER_TOKEN_NOT_ACTIVE",
19478
+ "Here n counts the requests sent to Dispatch, m the trades that gave a token, and r those of",
19479
+ "them that followed a BROKER_TOKEN_NOT_ACTIVE answer.",
19480
+ "",
19481
+ 'Example: dispatch proxy --socket "$(mktemp -d)/d.sock" -- python3 work-cost.py',
19482
+ ""
19483
+ ].join(`
19484
+ `);
19485
+ }
19486
+ function parseProxyArgv(rest, cwd) {
19487
+ const separator = rest.indexOf("--");
19488
+ const own = separator === -1 ? rest : rest.slice(0, separator);
19489
+ if (own.includes("--help"))
19490
+ return { kind: "help" };
19491
+ let socket;
19492
+ let dryRun = false;
19493
+ for (let at = 0;at < own.length; at += 1) {
19494
+ const word = own[at] ?? "";
19495
+ if (word === "--dry-run") {
19496
+ dryRun = true;
19497
+ continue;
19498
+ }
19499
+ if (word !== "--socket" && !word.startsWith("--socket=")) {
19500
+ return {
19501
+ kind: "refused",
19502
+ problem: separator === -1 ? `${JSON.stringify(word)} is no flag of dispatch proxy, and the command goes after --.` : `${JSON.stringify(word)} is no flag of dispatch proxy.`
19503
+ };
19504
+ }
19505
+ if (socket !== undefined)
19506
+ return { kind: "refused", problem: "--socket is given twice." };
19507
+ let value;
19508
+ if (word === "--socket") {
19509
+ at += 1;
19510
+ value = own[at];
19511
+ } else {
19512
+ value = word.slice("--socket=".length);
19513
+ }
19514
+ if (value === undefined || value === "" || value.startsWith("-")) {
19515
+ return { kind: "refused", problem: "--socket takes the path of the socket to listen on." };
19516
+ }
19517
+ socket = value;
19518
+ }
19519
+ if (socket === undefined) {
19520
+ return { kind: "refused", problem: "--socket <path> is missing." };
19521
+ }
19522
+ const command = separator === -1 ? [] : rest.slice(separator + 1);
19523
+ if (command.length === 0) {
19524
+ return {
19525
+ kind: "refused",
19526
+ problem: "No command is given: write it after --, as -- <command> [<argument>...]."
19527
+ };
19528
+ }
19529
+ const path = resolve(cwd, socket);
19530
+ const bytes = Buffer.byteLength(path);
19531
+ if (bytes > SOCKET_PATH_MAX_BYTES) {
19532
+ return {
19533
+ kind: "refused",
19534
+ problem: `The socket path ${JSON.stringify(path)} is ${bytes} bytes, over the ${SOCKET_PATH_MAX_BYTES} a unix socket path holds. Give a shorter path, such as one in a new directory of mktemp -d.`
19535
+ };
19536
+ }
19537
+ return { kind: "run", socket: path, dryRun, command };
19538
+ }
19539
+
19365
19540
  // ../contracts/src/held-secrets.ts
19366
19541
  var WITHHELD = "<withheld>";
19367
19542
  var SCRUB_RUN = 10;
@@ -19626,6 +19801,10 @@ function natsFailureReason(error) {
19626
19801
  }
19627
19802
 
19628
19803
  // ../envoy-client/src/dispatch-command.ts
19804
+ var COMMANDS_OUTSIDE_THE_SPECS = [
19805
+ { name: PROXY_COMMAND, sentence: PROXY_SENTENCE, help: proxyHelp },
19806
+ { name: LOGIN_COMMAND, sentence: LOGIN_SENTENCE, help: loginHelp }
19807
+ ];
19629
19808
  var PREFIXED_FLAGS = [
19630
19809
  {
19631
19810
  tool: "dispatch_comment",
@@ -19897,7 +20076,10 @@ function parseCommand(argv, io) {
19897
20076
  return { kind: "help" };
19898
20077
  const tool = toolForCommand(command);
19899
20078
  if (tool === undefined) {
19900
- const commands = [...toolsByCommand.keys()].join(", ");
20079
+ const commands = [
20080
+ ...toolsByCommand.keys(),
20081
+ ...COMMANDS_OUTSIDE_THE_SPECS.map(({ name }) => name)
20082
+ ].join(", ");
19901
20083
  return {
19902
20084
  kind: "refused",
19903
20085
  problems: [`unknown command ${quoteWord(command)}; the commands are: ${commands}`]
@@ -20174,17 +20356,21 @@ function commandHelp(tool) {
20174
20356
  `);
20175
20357
  }
20176
20358
  function commandsHelp() {
20177
- const width = Math.max(...[...toolsByCommand.keys()].map((command) => command.length));
20359
+ const rows = [
20360
+ ...dispatchToolSpecs.map((spec) => ({
20361
+ name: commandName(spec.name),
20362
+ sentence: /^.*?[.!?](?=\s|$)/s.exec(spec.description)?.[0] ?? spec.description
20363
+ })),
20364
+ ...COMMANDS_OUTSIDE_THE_SPECS
20365
+ ];
20366
+ const width = Math.max(...rows.map(({ name }) => name.length));
20178
20367
  return [
20179
20368
  "Usage: dispatch <command> [flags]",
20180
- ...dispatchToolSpecs.map((spec) => {
20181
- const sentence = /^.*?[.!?](?=\s|$)/s.exec(spec.description)?.[0] ?? spec.description;
20182
- return ` ${commandName(spec.name).padEnd(width)} ${sentence}`;
20183
- }),
20369
+ ...rows.map(({ name, sentence }) => ` ${name.padEnd(width)} ${sentence}`),
20184
20370
  "",
20185
- "Run dispatch <command> --help for its flags and an example. --dry-run checks a command's arguments as the call would and prints them as given. It stores nothing. A command whose dry run asks Dispatch something past that check (dispatch artifact: how Dispatch would store its text; dispatch result: the pull-request body line the record would print) says so in its --help.",
20371
+ "Run dispatch <command> --help for its flags and an example. Every command but dispatch login takes --dry-run, which checks its arguments as the call would and prints them as given. It stores nothing. A command whose dry run asks Dispatch something past that check (dispatch artifact: how Dispatch would store its text; dispatch result: the pull-request body line the record would print) says so in its --help. dispatch proxy's dry run also checks its environment and prints the Dispatch server, the session and the socket it would use, and starts nothing.",
20186
20372
  "",
20187
- "dispatch login --device logs a machine with no identity of its own, such as a laptop, in at the secrets broker, once per machine; it is no Dispatch call, and needs no host or session (dispatch login --help).",
20373
+ "dispatch login --device is no Dispatch call: it needs no host or session.",
20188
20374
  ""
20189
20375
  ].join(`
20190
20376
  `);
@@ -24027,7 +24213,8 @@ var POLICY_SENTINELS = {
24027
24213
  machineNotAllowed: "exchange: the machine is not one the entry allows",
24028
24214
  sessionFixed: "exchange: the entry fixes the session name its tokens carry",
24029
24215
  projectsFixed: "exchange: the request names projects other than the one its entry gives",
24030
- projectsNoPerson: "exchange: a token that names no person names no project"
24216
+ projectsNoPerson: "exchange: a token that names no person names no project",
24217
+ restrictedOneProject: "exchange: a restricted member's machine login names exactly one project"
24031
24218
  };
24032
24219
  function policy(sentinel, format, ...slots) {
24033
24220
  return `${escapeRegExp(`The subject token was refused: ${POLICY_SENTINELS[sentinel]}: `)}${formatPattern(format, slots)}\\.`;
@@ -24065,20 +24252,23 @@ var POLICY_REFUSAL_PATTERNS = [
24065
24252
  policy("projectsFixed", "%s's entry names no project, and the request named %s", IDENTITY, PROJECT_LIST),
24066
24253
  policy("projectsFixed", "%s writes the project %s that its entry names, and the request named %s", IDENTITY, PROJECT_SLOT, PROJECT_LIST),
24067
24254
  policy("projectsFixed", "%s's entry gives its token the projects %s, and the request named %s, which that list does not name", IDENTITY, JOB_LIST, PROJECT_SLOT),
24255
+ policy("restrictedOneProject", "%s is a restricted member, who sees only the projects that name them, and the trade asked for %d; set AGENT_SECRETS_PROJECTS to the one project this session works on", PERSON_SLOT, NUMBER),
24068
24256
  `${escapeRegExp("The subject token was refused: ")}${formatPattern("the subject token was not minted for %s, which is the audience this broker accepts from %s", [URI, URI])}\\.`
24069
24257
  ];
24070
24258
  var KNOWN_BROKER_REFUSAL_PATTERNS = [
24071
24259
  `${PERSON_SLOT} revoked this machine's sign-in, so the key this proof was signed with trades nothing\\. Sign in again with \`agent-secrets login\`\\.`,
24072
24260
  `${PERSON_SLOT}'s sign-in on this box key was made on another machine, and a sign-in belongs to the machine it was made on\\. Sign in again with \`agent-secrets login\`\\.`,
24261
+ `${PERSON_SLOT}'s sign-in on this box key was made by another Google account, and a sign-in belongs to the account that made it\\. Sign in again with \`agent-secrets login\`\\.`,
24262
+ `The Google account this token was minted for no longer holds ${PERSON_SLOT}: another account holds that address now, and the broker takes no sign-in of the account it replaced\\.`,
24073
24263
  "The machine login the subject token belongs to has ended\\.",
24074
24264
  "The machine login has ended\\.",
24075
24265
  "Another live machine login holds the key this proof was signed with\\. A (?:machine makes a key of its own|sign-in makes a box key of its own)\\.",
24076
24266
  "A live read token is bound to the key this proof was signed with\\. Make a new key\\.",
24077
- `${PERSON_SLOT} is a restricted member, whose token names its projects: set AGENT_SECRETS_PROJECTS to the projects this session works on\\.`,
24078
24267
  `The token names a project its person cannot see: ${PROJECT_SLOT}\\.`,
24079
24268
  `The subject token was refused: its entry names the project ${PROJECT_SLOT}, which its person ${PERSON_SLOT} cannot see\\.`,
24080
24269
  `The subject token was refused: its entry names no project, and its person ${PERSON_SLOT} is a restricted member, who sees only the projects that name them\\.`,
24081
24270
  "Dispatch could not be asked whether the token's person sees the projects it names; try again\\.",
24271
+ "Dispatch could not be asked what kind of member the machine login's approver is, so this broker cannot tell whether the token is held to one project; try again\\.",
24082
24272
  `The session name '${SESSION_SLOT}' belongs to another identity: one the broker's configuration fixes it for, or one that has written under it within the last [0-9]{1,4} days\\. Ask under a name of your own\\.`,
24083
24273
  `No registration says this pod may write under the session name '${SESSION_SLOT}'\\. A pod writes under a session name its deployment registered for it\\.`,
24084
24274
  `Refused: this pod's registration for session '${SESSION_SLOT}' is bound to another key; a role trades only for its own session\\.`,
@@ -24088,6 +24278,7 @@ var KNOWN_BROKER_REFUSAL_PATTERNS = [
24088
24278
  "Only a person's sign-in is traded for the approve capability's proxy placeholder, on a broker that serves it\\.",
24089
24279
  "A trade for the approve capability's proxy placeholder asks for the scope read, and a trade narrowed to reading approves nothing: trade for the placeholder without the scope, a cut or a DPoP-Holder proof\\.",
24090
24280
  `${PERSON_SLOT}'s credentials are held by Dispatch; they work again when \\k<person> signs in to Dispatch, or when Dispatch can confirm \\k<person> with Google again`,
24281
+ `Google's Workspace Directory no longer confirms ${PERSON_SLOT}; their credentials work again once it does`,
24091
24282
  "The 'as_of' parameter names a cut, and only a trade that asks for the scope read may name one\\.",
24092
24283
  "The 'as_of' parameter is not an RFC 3339 time with at most six fractional digits\\.",
24093
24284
  "The 'as_of' parameter names the zero time, which is no cut: a trade that reads the present names no cut\\.",
@@ -28756,7 +28947,7 @@ function refusalWithCode(error, ...clauses) {
28756
28947
  const told = joined !== "" && /[.!?]$/.test(error.message) ? `${error.message} ${suffix.charAt(0).toUpperCase()}${suffix.slice(1)}` : `${error.message}${joined}`;
28757
28948
  return new DispatchServiceError(error.code, error.status, `${error.code}: ${told}`, error);
28758
28949
  }
28759
- function parentStatusConflictLines(error, tool, args, legionIssue) {
28950
+ function parentStatusConflictLines(error, tool, args) {
28760
28951
  if (!dispatchAnswered(error, 409) || error.code !== "PARENT_STATUS_CONFLICT")
28761
28952
  return;
28762
28953
  const issues = error.issues ?? [];
@@ -28767,28 +28958,15 @@ function parentStatusConflictLines(error, tool, args, legionIssue) {
28767
28958
  return [
28768
28959
  messageFor(error),
28769
28960
  ...issues.map((issue) => `${issue.key} [${issue.status}] ${issue.title}`),
28770
- ...nextSteps(tool, args, parents, children, legionIssue)
28961
+ ...nextSteps(tool, args, parents, children)
28771
28962
  ];
28772
28963
  }
28773
28964
  var CHILD_FLAGS = "dispatch issue-update --status takes --unlink-children, which removes its open children from it, or, with a status other than done, --include-children, which moves the open issues under the issue with it. A person signed in at a browser closes them with it on the issue's page.";
28774
28965
  var PARENT_FLAG = "dispatch issue-update --status takes --include-parent, which moves each issue above the issue that is not in work to in_progress.";
28775
- function otherProjectSentence(named, keys) {
28776
- const project = named === undefined ? undefined : issueProject(named);
28777
- if (project === undefined)
28778
- return "";
28779
- const others = keys.filter((key) => {
28780
- const other = issueProject(key);
28781
- return other !== undefined && other !== project;
28782
- });
28783
- if (others.length === 0)
28784
- return "";
28785
- const one = others.length === 1;
28786
- return ` ${others.join(", ")} ${one ? "is" : "are"} not in the project of ${named}. A credential scoped to one project is refused a step that writes ${one ? "it" : "them"} (403 PROJECT_SCOPE), so a person, or a credential that names no project, must make that step.`;
28787
- }
28788
28966
  function includeParentCall(key) {
28789
28967
  return `${commandLine("dispatch_issue_update", { issue: key, status: "in_progress", include_parent: true })}, which also moves each issue above ${key} that is not in work`;
28790
28968
  }
28791
- function nextSteps(tool, args, parents, children, legionIssue) {
28969
+ function nextSteps(tool, args, parents, children) {
28792
28970
  if (tool === "dispatch_issue") {
28793
28971
  return parents.map((key) => `dispatch issue takes no flag that moves a done parent. Reopen ${key} first, with ${includeParentCall(key)}, then run dispatch issue again; or run it with --parent naming an open issue, or with no --parent.`);
28794
28972
  }
@@ -28796,9 +28974,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
28796
28974
  const written = issueUpdate ? args : {};
28797
28975
  const fields = Object.keys(written).filter((field) => field !== "issue" && written[field] !== undefined);
28798
28976
  const issue = optionalString(written, "issue");
28799
- const named = issueUpdate ? issue ?? legionIssue : undefined;
28800
28977
  const childHolds = children.length > 0;
28801
- const childScope = otherProjectSentence(named, children);
28802
28978
  const status = optionalString(written, "status");
28803
28979
  const parent = optionalString(written, "parent");
28804
28980
  const alone = `--status${status === "done" ? " and --reason" : ""} alone`;
@@ -28811,7 +28987,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
28811
28987
  const afterStatus = childHolds ? ", after the status change," : "";
28812
28988
  return [
28813
28989
  ...childHolds ? [
28814
- `${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}.${childScope}`
28990
+ `${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}.`
28815
28991
  ] : [],
28816
28992
  ...parents.map((key) => `dispatch issue-update takes no flag that moves the parent a reparent names. Move ${key} into work first, with ${includeParentCall(key)}; then${afterStatus} run the reparent again: ${reparent}.`)
28817
28993
  ];
@@ -28819,8 +28995,8 @@ function nextSteps(tool, args, parents, children, legionIssue) {
28819
28995
  const others = ISSUE_UPDATE_PATCH_FIELDS.some((field) => written[field] !== undefined);
28820
28996
  const apart = (subject) => others ? ` ${subject} with ${alone}, so send the call's other changes in a call of their own.` : "";
28821
28997
  return [
28822
- ...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}${childScope}`] : [],
28823
- ...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}${otherProjectSentence(named, parents)}`] : []
28998
+ ...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}`] : [],
28999
+ ...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}`] : []
28824
29000
  ];
28825
29001
  }
28826
29002
  function dispatchAnswered(error, status) {
@@ -30814,7 +30990,7 @@ import {
30814
30990
  utimesSync,
30815
30991
  writeFileSync
30816
30992
  } from "fs";
30817
- import { isAbsolute as isAbsolute2, join as join3, resolve as resolve2 } from "path";
30993
+ import { isAbsolute as isAbsolute2, join as join3, resolve as resolve3 } from "path";
30818
30994
  var ASKGATE_RECORD = "askgate";
30819
30995
  var MARKER_MAX_AGE_MS = 2 * 60 * 60000;
30820
30996
  var STORE_BEAT_MS = 10 * 60000;
@@ -30872,7 +31048,7 @@ function fileOperands(argv) {
30872
31048
  }
30873
31049
  function operandPath(cwd, file) {
30874
31050
  if (file.flag === "--path")
30875
- return resolve2(cwd, file.operand);
31051
+ return resolve3(cwd, file.operand);
30876
31052
  return isAbsolute2(file.operand) ? file.operand : `${cwd}/${file.operand}`;
30877
31053
  }
30878
31054
  function bytesDigest(bytes) {
@@ -31246,12 +31422,10 @@ var WRITE_ROUTES = [
31246
31422
  commands: ["architecture-sync"]
31247
31423
  }
31248
31424
  ];
31425
+ var WRITE_ROUTE_SEGMENTS = WRITE_ROUTES.map((row) => ({ row, segments: row.pattern.split("/") }));
31249
31426
  function writeRoute(method, path) {
31250
31427
  const segments = path.split("/");
31251
- return WRITE_ROUTES.find((row) => {
31252
- const pattern = row.pattern.split("/");
31253
- return row.method === method && pattern.length === segments.length && pattern.every((part, at) => part.startsWith("{") ? segments[at] !== "" : part === segments[at]);
31254
- });
31428
+ return WRITE_ROUTE_SEGMENTS.find((route) => route.row.method === method && route.segments.length === segments.length && route.segments.every((part, at) => part.startsWith("{") ? segments[at] !== "" : part === segments[at]))?.row;
31255
31429
  }
31256
31430
 
31257
31431
  class ApiGateRefusal extends Error {
@@ -34115,9 +34289,9 @@ async function whoamiCommand(context) {
34115
34289
  } else {
34116
34290
  acting = `Session ${session} runs under the shared token: ${unowned}`;
34117
34291
  }
34118
- const writable = readOnly ? "" : project !== null ? ` It may write project ${project} and no other.` : writesAsService ? " It names no one project, so it may write wherever a token that names no project may." : "";
34292
+ const projectSentence = readOnly ? "" : project !== null ? ` Its token names project ${project}.` : writesAsService ? " It names no one project, so it may write wherever a token that names no project may." : "";
34119
34293
  return {
34120
- text: acting + elsewhere + writable,
34294
+ text: acting + elsewhere + projectSentence,
34121
34295
  details: { session, owner, service, project, project_scope: projectScope }
34122
34296
  };
34123
34297
  }