@sjawhar/claude-envoy 6.5.1 → 6.6.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.
@@ -18711,7 +18711,7 @@ var dispatchToolSpecs = [
18711
18711
  {
18712
18712
  name: "dispatch_project_update",
18713
18713
  example: { project: "CORE", proven_sessions: "on" },
18714
- 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.",
18714
+ 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.",
18715
18715
  arguments: (z) => ({
18716
18716
  project: z.string().describe("Project key whose setting to change, such as CORE."),
18717
18717
  proven_sessions: z.enum(["on", "off"]).describe("on turns the setting on; off turns it off and needs the person scope.")
@@ -18764,7 +18764,7 @@ var dispatchToolSpecs = [
18764
18764
  {
18765
18765
  name: "dispatch_whoami",
18766
18766
  example: {},
18767
- 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.",
18767
+ 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.",
18768
18768
  arguments: () => ({}),
18769
18769
  strict: true
18770
18770
  },
@@ -18778,7 +18778,7 @@ var dispatchToolSpecs = [
18778
18778
  {
18779
18779
  name: "dispatch_api",
18780
18780
  example: { path: "/api/v1/issues/DSP-1/events?limit=200" },
18781
- 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.",
18781
+ 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.",
18782
18782
  arguments: (z) => ({
18783
18783
  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.'),
18784
18784
  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(),
@@ -22961,6 +22961,181 @@ function fileTextBytes(text) {
22961
22961
  return encoder4.encode(text);
22962
22962
  }
22963
22963
 
22964
+ // ../envoy-client/src/dispatch-login-command.ts
22965
+ var LOGIN_COMMAND = "login";
22966
+ 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.";
22967
+ function loginHelp() {
22968
+ return [
22969
+ "Usage: dispatch login --device [--person <address>]",
22970
+ "",
22971
+ `${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.`,
22972
+ "",
22973
+ "Flags:",
22974
+ " --device",
22975
+ " Log in with the broker's device grant: the only way there is, and required.",
22976
+ " --person <address>",
22977
+ " The person who approves the login, by the address they sign in to Dispatch with; else AGENT_SECRETS_PERSON.",
22978
+ "",
22979
+ "It reads AGENT_SECRETS_URL, the broker, and needs no Dispatch host or session.",
22980
+ "",
22981
+ "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.",
22982
+ "",
22983
+ "Example: dispatch login --device --person ada@example.com",
22984
+ ""
22985
+ ].join(`
22986
+ `);
22987
+ }
22988
+
22989
+ // ../envoy-client/src/dispatch-proxy-command.ts
22990
+ import { resolve } from "path";
22991
+ var PROXY_COMMAND = "proxy";
22992
+ 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.";
22993
+ var SOCKET_PATH_MAX_BYTES = 107;
22994
+ function proxyExitLine(requests, trades, renewed) {
22995
+ return `dispatch proxy: ${requests} requests, ${trades} trades, ${renewed} after BROKER_TOKEN_NOT_ACTIVE`;
22996
+ }
22997
+ function proxyHelp() {
22998
+ return [
22999
+ "Usage: dispatch proxy --socket <path> [--dry-run] -- <command> [<argument>...]",
23000
+ "",
23001
+ PROXY_SENTENCE,
23002
+ "",
23003
+ "The proxy listens on a unix socket at <path> for the whole run of <command>. It sends each",
23004
+ "request it takes to the Dispatch server and the session that a dispatch command resolves in",
23005
+ "the same environment, with this session's broker token and a new DPoP proof. So the tool",
23006
+ "holds no credential and signs nothing. It adds the path of each request to the path of the",
23007
+ "Dispatch URL, and it does not decode the query. The proxy trades for the token once before it",
23008
+ "starts the command, and again only when the token has less than 5 minutes to live, or after",
23009
+ "Dispatch answers 401 BROKER_TOKEN_NOT_ACTIVE. It runs only under DISPATCH_TOKEN_BROKER=1.",
23010
+ "",
23011
+ "What it sends:",
23012
+ " GET /api/... any GET whose path starts with /api/",
23013
+ " POST /api/v1/issues/<key>/comments a comment that carries an Idempotency-Key header",
23014
+ "It sends no other write. A tool reads much and writes little. Where a dispatch command sends a",
23015
+ "write, the write goes through that command, so AskGate reviews it wherever AskGate gates that",
23016
+ "command. The proxy's refusal of the write names that command. Where no other dispatch command",
23017
+ "sends a write under /api/v1, the refusal names dispatch api --method, which sends it outside a",
23018
+ "session whose AskGate reviews Dispatch writes. The comment needs a key so that a resend posts",
23019
+ "it once. The comment POST passes no AskGate review. The proxy is not one of the writes that",
23020
+ "AskGate gates, and the Dispatch server checks no marker. A session that holds a Dispatch token",
23021
+ "can post the same comment with that token already.",
23022
+ "",
23023
+ "It listens on a unix socket only, made with mode 0600, and opens no TCP port. The roles of a",
23024
+ "pod share the pod's network, so a port would let another role act as this one. A socket path",
23025
+ "that exists is refused, so give it a path in a new directory (mktemp -d). A socket that a",
23026
+ "killed proxy left behind refuses the next start.",
23027
+ "",
23028
+ "How a tool calls it: the command runs with DISPATCH_PROXY_SOCKET set to the socket's path.",
23029
+ "The host in a URL is not read. Write the path and the query.",
23030
+ ' curl --unix-socket "$DISPATCH_PROXY_SOCKET" http://dispatch/api/v1/issues',
23031
+ " In Python, an http.client.HTTPConnection whose connect opens an AF_UNIX socket:",
23032
+ " import http.client, os, socket",
23033
+ " class ProxyConnection(http.client.HTTPConnection):",
23034
+ " def connect(self):",
23035
+ " self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)",
23036
+ ' self.sock.connect(os.environ["DISPATCH_PROXY_SOCKET"])',
23037
+ ' connection = ProxyConnection("dispatch")',
23038
+ ' connection.request("GET", "/api/v1/issues?project=DSP")',
23039
+ " answer = connection.getresponse()",
23040
+ " print(answer.status, answer.read())",
23041
+ "",
23042
+ "What it answers: Dispatch's status, headers and body as Dispatch sent them. An answer that",
23043
+ "carries Transfer-Encoding as well as Content-Length is the one exception: it comes back",
23044
+ "without that Content-Length (RFC 9112, section 6.3), with its body chunked. It follows no",
23045
+ "redirect. Its own refusals have a JSON body with a code and an error, and each code starts",
23046
+ "with PROXY_. No code of Dispatch's does. It never answers 403 or 404 of its own.",
23047
+ " 400 PROXY_TARGET_REFUSED a target that names a host (http://... or //...)",
23048
+ " 405 PROXY_METHOD_REFUSED each other method or path, and a comment POST with no",
23049
+ " Idempotency-Key. The error names the dispatch command to",
23050
+ " use, where one exists. For a write under /api/v1 that no",
23051
+ " other dispatch command sends, it names dispatch api",
23052
+ " --method. It also refuses a target that holds a # or a",
23053
+ " control character, and a path with a . or .. segment",
23054
+ " (plain or percent-encoded), a backslash, or %2F or %5C in",
23055
+ " either case: each can reach another route than the one the",
23056
+ " target names.",
23057
+ " 502 PROXY_TRADE_REFUSED the token has ended and the broker refused a new one. The",
23058
+ " error is in the broker's words.",
23059
+ " 502 PROXY_DISPATCH_UNREACHABLE Dispatch did not answer",
23060
+ "",
23061
+ "Flags:",
23062
+ " --socket <path>",
23063
+ " The socket to listen on. Also --socket=<path>. A path over 107 bytes is refused.",
23064
+ " --dry-run",
23065
+ " Checks the arguments and the environment, prints the Dispatch server, the session and",
23066
+ " the socket it would use, and starts nothing.",
23067
+ " --help",
23068
+ " Prints this help.",
23069
+ "Every word after -- is the command's, flags included.",
23070
+ "",
23071
+ "It exits with the command's status. A command that a signal ended is 128 plus the signal's",
23072
+ "number. A command that does not exist is 127, and one that cannot run is 126. It exits 2 when",
23073
+ "it cannot start, and runs no command then. It sends SIGTERM, SIGINT and SIGHUP on to the",
23074
+ "command and serves until the command ends. Then it removes its socket. The last line it",
23075
+ "writes on standard error is:",
23076
+ " dispatch proxy: <n> requests, <m> trades, <r> after BROKER_TOKEN_NOT_ACTIVE",
23077
+ "Here n counts the requests sent to Dispatch, m the trades that gave a token, and r those of",
23078
+ "them that followed a BROKER_TOKEN_NOT_ACTIVE answer.",
23079
+ "",
23080
+ 'Example: dispatch proxy --socket "$(mktemp -d)/d.sock" -- python3 work-cost.py',
23081
+ ""
23082
+ ].join(`
23083
+ `);
23084
+ }
23085
+ function parseProxyArgv(rest, cwd) {
23086
+ const separator = rest.indexOf("--");
23087
+ const own = separator === -1 ? rest : rest.slice(0, separator);
23088
+ if (own.includes("--help"))
23089
+ return { kind: "help" };
23090
+ let socket;
23091
+ let dryRun = false;
23092
+ for (let at = 0;at < own.length; at += 1) {
23093
+ const word = own[at] ?? "";
23094
+ if (word === "--dry-run") {
23095
+ dryRun = true;
23096
+ continue;
23097
+ }
23098
+ if (word !== "--socket" && !word.startsWith("--socket=")) {
23099
+ return {
23100
+ kind: "refused",
23101
+ 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.`
23102
+ };
23103
+ }
23104
+ if (socket !== undefined)
23105
+ return { kind: "refused", problem: "--socket is given twice." };
23106
+ let value;
23107
+ if (word === "--socket") {
23108
+ at += 1;
23109
+ value = own[at];
23110
+ } else {
23111
+ value = word.slice("--socket=".length);
23112
+ }
23113
+ if (value === undefined || value === "" || value.startsWith("-")) {
23114
+ return { kind: "refused", problem: "--socket takes the path of the socket to listen on." };
23115
+ }
23116
+ socket = value;
23117
+ }
23118
+ if (socket === undefined) {
23119
+ return { kind: "refused", problem: "--socket <path> is missing." };
23120
+ }
23121
+ const command = separator === -1 ? [] : rest.slice(separator + 1);
23122
+ if (command.length === 0) {
23123
+ return {
23124
+ kind: "refused",
23125
+ problem: "No command is given: write it after --, as -- <command> [<argument>...]."
23126
+ };
23127
+ }
23128
+ const path = resolve(cwd, socket);
23129
+ const bytes = Buffer.byteLength(path);
23130
+ if (bytes > SOCKET_PATH_MAX_BYTES) {
23131
+ return {
23132
+ kind: "refused",
23133
+ 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.`
23134
+ };
23135
+ }
23136
+ return { kind: "run", socket: path, dryRun, command };
23137
+ }
23138
+
22964
23139
  // ../envoy-client/src/errors.ts
22965
23140
  function dispatchField(error, field) {
22966
23141
  if (!("fromDispatch" in error))
@@ -23022,6 +23197,10 @@ function natsFailureReason(error) {
23022
23197
  }
23023
23198
 
23024
23199
  // ../envoy-client/src/dispatch-command.ts
23200
+ var COMMANDS_OUTSIDE_THE_SPECS = [
23201
+ { name: PROXY_COMMAND, sentence: PROXY_SENTENCE, help: proxyHelp },
23202
+ { name: LOGIN_COMMAND, sentence: LOGIN_SENTENCE, help: loginHelp }
23203
+ ];
23025
23204
  var PREFIXED_FLAGS = [
23026
23205
  {
23027
23206
  tool: "dispatch_comment",
@@ -23293,7 +23472,10 @@ function parseCommand(argv, io) {
23293
23472
  return { kind: "help" };
23294
23473
  const tool = toolForCommand(command);
23295
23474
  if (tool === undefined) {
23296
- const commands = [...toolsByCommand.keys()].join(", ");
23475
+ const commands = [
23476
+ ...toolsByCommand.keys(),
23477
+ ...COMMANDS_OUTSIDE_THE_SPECS.map(({ name }) => name)
23478
+ ].join(", ");
23297
23479
  return {
23298
23480
  kind: "refused",
23299
23481
  problems: [`unknown command ${quoteWord(command)}; the commands are: ${commands}`]
@@ -23570,17 +23752,21 @@ function commandHelp(tool) {
23570
23752
  `);
23571
23753
  }
23572
23754
  function commandsHelp() {
23573
- const width = Math.max(...[...toolsByCommand.keys()].map((command) => command.length));
23755
+ const rows = [
23756
+ ...dispatchToolSpecs.map((spec) => ({
23757
+ name: commandName(spec.name),
23758
+ sentence: /^.*?[.!?](?=\s|$)/s.exec(spec.description)?.[0] ?? spec.description
23759
+ })),
23760
+ ...COMMANDS_OUTSIDE_THE_SPECS
23761
+ ];
23762
+ const width = Math.max(...rows.map(({ name }) => name.length));
23574
23763
  return [
23575
23764
  "Usage: dispatch <command> [flags]",
23576
- ...dispatchToolSpecs.map((spec) => {
23577
- const sentence = /^.*?[.!?](?=\s|$)/s.exec(spec.description)?.[0] ?? spec.description;
23578
- return ` ${commandName(spec.name).padEnd(width)} ${sentence}`;
23579
- }),
23765
+ ...rows.map(({ name, sentence }) => ` ${name.padEnd(width)} ${sentence}`),
23580
23766
  "",
23581
- "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.",
23767
+ "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.",
23582
23768
  "",
23583
- "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).",
23769
+ "dispatch login --device is no Dispatch call: it needs no host or session.",
23584
23770
  ""
23585
23771
  ].join(`
23586
23772
  `);
@@ -29971,7 +30157,7 @@ function refusalWithCode(error, ...clauses) {
29971
30157
  const told = joined !== "" && /[.!?]$/.test(error.message) ? `${error.message} ${suffix.charAt(0).toUpperCase()}${suffix.slice(1)}` : `${error.message}${joined}`;
29972
30158
  return new DispatchServiceError(error.code, error.status, `${error.code}: ${told}`, error);
29973
30159
  }
29974
- function parentStatusConflictLines(error, tool, args, legionIssue) {
30160
+ function parentStatusConflictLines(error, tool, args) {
29975
30161
  if (!dispatchAnswered(error, 409) || error.code !== "PARENT_STATUS_CONFLICT")
29976
30162
  return;
29977
30163
  const issues = error.issues ?? [];
@@ -29982,28 +30168,15 @@ function parentStatusConflictLines(error, tool, args, legionIssue) {
29982
30168
  return [
29983
30169
  messageFor(error),
29984
30170
  ...issues.map((issue) => `${issue.key} [${issue.status}] ${issue.title}`),
29985
- ...nextSteps(tool, args, parents, children, legionIssue)
30171
+ ...nextSteps(tool, args, parents, children)
29986
30172
  ];
29987
30173
  }
29988
30174
  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.";
29989
30175
  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.";
29990
- function otherProjectSentence(named, keys) {
29991
- const project = named === undefined ? undefined : issueProject(named);
29992
- if (project === undefined)
29993
- return "";
29994
- const others = keys.filter((key) => {
29995
- const other = issueProject(key);
29996
- return other !== undefined && other !== project;
29997
- });
29998
- if (others.length === 0)
29999
- return "";
30000
- const one = others.length === 1;
30001
- 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.`;
30002
- }
30003
30176
  function includeParentCall(key) {
30004
30177
  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`;
30005
30178
  }
30006
- function nextSteps(tool, args, parents, children, legionIssue) {
30179
+ function nextSteps(tool, args, parents, children) {
30007
30180
  if (tool === "dispatch_issue") {
30008
30181
  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.`);
30009
30182
  }
@@ -30011,9 +30184,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
30011
30184
  const written = issueUpdate ? args : {};
30012
30185
  const fields = Object.keys(written).filter((field) => field !== "issue" && written[field] !== undefined);
30013
30186
  const issue = optionalString(written, "issue");
30014
- const named = issueUpdate ? issue ?? legionIssue : undefined;
30015
30187
  const childHolds = children.length > 0;
30016
- const childScope = otherProjectSentence(named, children);
30017
30188
  const status = optionalString(written, "status");
30018
30189
  const parent = optionalString(written, "parent");
30019
30190
  const alone = `--status${status === "done" ? " and --reason" : ""} alone`;
@@ -30026,7 +30197,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
30026
30197
  const afterStatus = childHolds ? ", after the status change," : "";
30027
30198
  return [
30028
30199
  ...childHolds ? [
30029
- `${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}`
30200
+ `${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}.`
30030
30201
  ] : [],
30031
30202
  ...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}.`)
30032
30203
  ];
@@ -30034,8 +30205,8 @@ function nextSteps(tool, args, parents, children, legionIssue) {
30034
30205
  const others = ISSUE_UPDATE_PATCH_FIELDS.some((field) => written[field] !== undefined);
30035
30206
  const apart = (subject) => others ? ` ${subject} with ${alone}, so send the call's other changes in a call of their own.` : "";
30036
30207
  return [
30037
- ...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}${childScope}`] : [],
30038
- ...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}${otherProjectSentence(named, parents)}`] : []
30208
+ ...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}`] : [],
30209
+ ...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}`] : []
30039
30210
  ];
30040
30211
  }
30041
30212
  function dispatchAnswered(error, status) {
@@ -32029,7 +32200,7 @@ import {
32029
32200
  utimesSync,
32030
32201
  writeFileSync
32031
32202
  } from "fs";
32032
- import { isAbsolute as isAbsolute3, join as join5, resolve as resolve2 } from "path";
32203
+ import { isAbsolute as isAbsolute3, join as join5, resolve as resolve3 } from "path";
32033
32204
  var ASKGATE_RECORD = "askgate";
32034
32205
  var MARKER_MAX_AGE_MS = 2 * 60 * 60000;
32035
32206
  var STORE_BEAT_MS = 10 * 60000;
@@ -32087,7 +32258,7 @@ function fileOperands(argv) {
32087
32258
  }
32088
32259
  function operandPath(cwd, file) {
32089
32260
  if (file.flag === "--path")
32090
- return resolve2(cwd, file.operand);
32261
+ return resolve3(cwd, file.operand);
32091
32262
  return isAbsolute3(file.operand) ? file.operand : `${cwd}/${file.operand}`;
32092
32263
  }
32093
32264
  function bytesDigest(bytes) {
@@ -32461,12 +32632,10 @@ var WRITE_ROUTES = [
32461
32632
  commands: ["architecture-sync"]
32462
32633
  }
32463
32634
  ];
32635
+ var WRITE_ROUTE_SEGMENTS = WRITE_ROUTES.map((row) => ({ row, segments: row.pattern.split("/") }));
32464
32636
  function writeRoute(method, path) {
32465
32637
  const segments = path.split("/");
32466
- return WRITE_ROUTES.find((row) => {
32467
- const pattern = row.pattern.split("/");
32468
- return row.method === method && pattern.length === segments.length && pattern.every((part, at) => part.startsWith("{") ? segments[at] !== "" : part === segments[at]);
32469
- });
32638
+ 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;
32470
32639
  }
32471
32640
 
32472
32641
  class ApiGateRefusal extends Error {
@@ -35330,9 +35499,9 @@ async function whoamiCommand(context) {
35330
35499
  } else {
35331
35500
  acting = `Session ${session} runs under the shared token: ${unowned}`;
35332
35501
  }
35333
- 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." : "";
35502
+ 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." : "";
35334
35503
  return {
35335
- text: acting + elsewhere + writable,
35504
+ text: acting + elsewhere + projectSentence,
35336
35505
  details: { session, owner, service, project, project_scope: projectScope }
35337
35506
  };
35338
35507
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "6.5.1",
3
+ "version": "6.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -140,7 +140,7 @@ export function callingThread(meta: unknown): string | undefined {
140
140
  export function dispatchToolDefinition() {
141
141
  return {
142
142
  description:
143
- 'Runs the `dispatch` command as this session, outside Codex\'s sandbox. Pass the words after `dispatch` as `args` (for example ["read", "--issue", "LEGION-3"]) and what the command would read on standard input as `stdin` (the text of a here-document given as `--body-file -`). `["--help"]` lists the commands. Answers with what the command printed and its exit code: 0 written or read, 2 a usage error, 1 any other failure: Dispatch\'s refusal, a Dispatch the command cannot reach, or `ANSWER_NOT_KEPT` for a call that wrote nothing, which you run again.',
143
+ 'Runs the `dispatch` command as this session, outside Codex\'s sandbox. Pass the words after `dispatch` as `args` (for example ["read", "--issue", "LEGION-3"]) and what the command would read on standard input as `stdin` (the text of a here-document given as `--body-file -`). `["--help"]` lists the commands. Answers with what the command printed and its exit code. A command that a Dispatch spec defines exits 0 when it wrote or read. It exits 1 when Dispatch or AskGate refused it, Dispatch failed, the command could not reach Dispatch, its trade for a token at the secrets broker failed, or Dispatch kept no answer for a call that writes nothing (`ANSWER_NOT_KEPT`, which you run again). It exits 2 on a usage error or a session or configuration it cannot use. `dispatch proxy` and `dispatch login` give their own exit codes in their help.',
144
144
  inputSchema: {
145
145
  properties: {
146
146
  args: {