@sjawhar/claude-envoy 6.5.0 → 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.
- package/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/README.md +6 -3
- package/dist/codex-hook.js +337 -126
- package/dist/dispatch.js +804 -156
- package/dist/envoy-channel.js +341 -130
- package/dist/session-hook.js +337 -126
- package/dist/session-title-hook.js +0 -3
- package/package.json +1 -1
- package/src/codex/codex-server.ts +1 -1
package/dist/session-hook.js
CHANGED
|
@@ -17922,21 +17922,22 @@ var ISSUE_UPDATE_OPTIONS_RULE = "include_children, unlink_children and include_p
|
|
|
17922
17922
|
var ISSUE_UPDATE_RULE = `${ISSUE_UPDATE_FIELDS_RULE} ${ISSUE_UPDATE_DONE_RULE}; ${ISSUE_UPDATE_REASON_RULE}; ${ISSUE_UPDATE_LABELS_RULE}. ${ISSUE_UPDATE_OPTIONS_RULE}`;
|
|
17923
17923
|
function issueStatusOptionsProblem(input) {
|
|
17924
17924
|
const options = issueStatusOptionsOf(input);
|
|
17925
|
+
const optionInput = input;
|
|
17925
17926
|
if (options.length === 0)
|
|
17926
17927
|
return;
|
|
17927
17928
|
const named = options.join(", ").replace(/, ([^,]*)$/, " and $1");
|
|
17928
17929
|
const others = ISSUE_UPDATE_PATCH_FIELDS.filter((field) => input[field] !== undefined);
|
|
17929
17930
|
return brokenParts([
|
|
17930
17931
|
[
|
|
17931
|
-
!(
|
|
17932
|
+
!(optionInput.include_children === true && optionInput.unlink_children === true),
|
|
17932
17933
|
"include_children does not go with unlink_children. The open children move with the issue or leave it, so name one of the two."
|
|
17933
17934
|
],
|
|
17934
17935
|
[
|
|
17935
|
-
!(
|
|
17936
|
+
!(optionInput.include_children === true && optionInput.status === "done"),
|
|
17936
17937
|
"include_children does not go with status done. Only a person who is signed in at a browser can close the open issues under an issue together with it, and this call presents a token. That person does it on the issue's page in Dispatch: Close issue, then Move them with it."
|
|
17937
17938
|
],
|
|
17938
17939
|
[
|
|
17939
|
-
typeof
|
|
17940
|
+
typeof optionInput.status === "string",
|
|
17940
17941
|
`status is required with ${named}. Add status, or drop ${named}.`
|
|
17941
17942
|
],
|
|
17942
17943
|
[
|
|
@@ -18089,8 +18090,8 @@ var RESULT_SHAPE_RULE = `${RESULT_RETRACT_RULE} A call with retract takes reason
|
|
|
18089
18090
|
function resultProblem(value) {
|
|
18090
18091
|
const input = value;
|
|
18091
18092
|
const carried = RESULT_RECORD_FIELDS.filter((field) => input[field] !== undefined);
|
|
18092
|
-
if (typeof input
|
|
18093
|
-
const reason = input
|
|
18093
|
+
if (typeof input.retract === "string") {
|
|
18094
|
+
const reason = input.reason;
|
|
18094
18095
|
if (typeof reason !== "string" || reason.trim() === "") {
|
|
18095
18096
|
return "retract needs reason, the words that say why the result is wrong.";
|
|
18096
18097
|
}
|
|
@@ -18099,7 +18100,7 @@ function resultProblem(value) {
|
|
|
18099
18100
|
}
|
|
18100
18101
|
return;
|
|
18101
18102
|
}
|
|
18102
|
-
if (input
|
|
18103
|
+
if (input.reason !== undefined) {
|
|
18103
18104
|
return "reason goes with retract, and this call carries no retract. Name the result to retract, or drop reason.";
|
|
18104
18105
|
}
|
|
18105
18106
|
const missing = RESULT_REQUIRED_FIELDS.filter((field) => input[field] === undefined);
|
|
@@ -18710,7 +18711,7 @@ var dispatchToolSpecs = [
|
|
|
18710
18711
|
{
|
|
18711
18712
|
name: "dispatch_project_update",
|
|
18712
18713
|
example: { project: "CORE", proven_sessions: "on" },
|
|
18713
|
-
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
|
|
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.",
|
|
18714
18715
|
arguments: (z) => ({
|
|
18715
18716
|
project: z.string().describe("Project key whose setting to change, such as CORE."),
|
|
18716
18717
|
proven_sessions: z.enum(["on", "off"]).describe("on turns the setting on; off turns it off and needs the person scope.")
|
|
@@ -18763,7 +18764,7 @@ var dispatchToolSpecs = [
|
|
|
18763
18764
|
{
|
|
18764
18765
|
name: "dispatch_whoami",
|
|
18765
18766
|
example: {},
|
|
18766
|
-
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
|
|
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.",
|
|
18767
18768
|
arguments: () => ({}),
|
|
18768
18769
|
strict: true
|
|
18769
18770
|
},
|
|
@@ -18777,7 +18778,7 @@ var dispatchToolSpecs = [
|
|
|
18777
18778
|
{
|
|
18778
18779
|
name: "dispatch_api",
|
|
18779
18780
|
example: { path: "/api/v1/issues/DSP-1/events?limit=200" },
|
|
18780
|
-
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.",
|
|
18781
18782
|
arguments: (z) => ({
|
|
18782
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.'),
|
|
18783
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(),
|
|
@@ -19568,6 +19569,52 @@ var DispatchTargetedDeliverySchema = union([
|
|
|
19568
19569
|
DispatchTargetedCommentDeliverySchema,
|
|
19569
19570
|
DispatchTargetedMessageDeliverySchema
|
|
19570
19571
|
]);
|
|
19572
|
+
function isCommentTargetedDelivery(delivery) {
|
|
19573
|
+
return "comment_id" in delivery;
|
|
19574
|
+
}
|
|
19575
|
+
var DispatchTargetedFrameSchema = object({
|
|
19576
|
+
event: DispatchEventSchema,
|
|
19577
|
+
delivery: DispatchTargetedDeliverySchema
|
|
19578
|
+
}).superRefine(({ event, delivery }, context) => {
|
|
19579
|
+
if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
|
|
19580
|
+
return;
|
|
19581
|
+
}
|
|
19582
|
+
if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
|
|
19583
|
+
return;
|
|
19584
|
+
}
|
|
19585
|
+
context.addIssue({
|
|
19586
|
+
code: "custom",
|
|
19587
|
+
message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
|
|
19588
|
+
});
|
|
19589
|
+
});
|
|
19590
|
+
var RecoverableDispatchDeliveryFailureSchema = object({
|
|
19591
|
+
event: object({
|
|
19592
|
+
type: _enum2(["message.created", "comment.created"]),
|
|
19593
|
+
issue_key: string2().nullable(),
|
|
19594
|
+
payload: object({ id: string2(), body: string2().optional() }).passthrough()
|
|
19595
|
+
}).passthrough(),
|
|
19596
|
+
delivery: DispatchTargetedDeliverySchema
|
|
19597
|
+
}).refine(({ event, delivery }) => event.type === "comment.created" ? isCommentTargetedDelivery(delivery) : !isCommentTargetedDelivery(delivery) && DispatchTargetedResourceIDSchema.safeParse(event.payload.id).success, { message: "delivery resource must match its event type" });
|
|
19598
|
+
function readDispatchPayload(value) {
|
|
19599
|
+
if (typeof value === "object" && value !== null && "delivery" in value) {
|
|
19600
|
+
const targeted = DispatchTargetedFrameSchema.safeParse(value);
|
|
19601
|
+
if (targeted.success) {
|
|
19602
|
+
const { event: wireEvent } = value;
|
|
19603
|
+
return {
|
|
19604
|
+
kind: "event",
|
|
19605
|
+
event: targeted.data.event,
|
|
19606
|
+
wireEvent,
|
|
19607
|
+
delivery: targeted.data.delivery
|
|
19608
|
+
};
|
|
19609
|
+
}
|
|
19610
|
+
const recovered = RecoverableDispatchDeliveryFailureSchema.safeParse(value);
|
|
19611
|
+
if (recovered.success)
|
|
19612
|
+
return { kind: "recovered", failure: recovered.data };
|
|
19613
|
+
return { kind: "raw", targeted: true };
|
|
19614
|
+
}
|
|
19615
|
+
const parsed = DispatchEventSchema.safeParse(value);
|
|
19616
|
+
return parsed.success ? { kind: "event", event: parsed.data, wireEvent: value } : { kind: "raw", targeted: false };
|
|
19617
|
+
}
|
|
19571
19618
|
// ../contracts/src/dispatch-api-user.ts
|
|
19572
19619
|
var UserIssueStateSchema = strictObject({
|
|
19573
19620
|
pinned: boolean2(),
|
|
@@ -22914,6 +22961,181 @@ function fileTextBytes(text) {
|
|
|
22914
22961
|
return encoder4.encode(text);
|
|
22915
22962
|
}
|
|
22916
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
|
+
|
|
22917
23139
|
// ../envoy-client/src/errors.ts
|
|
22918
23140
|
function dispatchField(error, field) {
|
|
22919
23141
|
if (!("fromDispatch" in error))
|
|
@@ -22941,9 +23163,6 @@ function reachedNothing(error) {
|
|
|
22941
23163
|
}
|
|
22942
23164
|
|
|
22943
23165
|
class LoggableError extends Error {
|
|
22944
|
-
constructor(message) {
|
|
22945
|
-
super(message);
|
|
22946
|
-
}
|
|
22947
23166
|
}
|
|
22948
23167
|
var SERVER_REFUSALS = [
|
|
22949
23168
|
"Authorization Violation",
|
|
@@ -22978,6 +23197,10 @@ function natsFailureReason(error) {
|
|
|
22978
23197
|
}
|
|
22979
23198
|
|
|
22980
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
|
+
];
|
|
22981
23204
|
var PREFIXED_FLAGS = [
|
|
22982
23205
|
{
|
|
22983
23206
|
tool: "dispatch_comment",
|
|
@@ -23249,7 +23472,10 @@ function parseCommand(argv, io) {
|
|
|
23249
23472
|
return { kind: "help" };
|
|
23250
23473
|
const tool = toolForCommand(command);
|
|
23251
23474
|
if (tool === undefined) {
|
|
23252
|
-
const commands = [
|
|
23475
|
+
const commands = [
|
|
23476
|
+
...toolsByCommand.keys(),
|
|
23477
|
+
...COMMANDS_OUTSIDE_THE_SPECS.map(({ name }) => name)
|
|
23478
|
+
].join(", ");
|
|
23253
23479
|
return {
|
|
23254
23480
|
kind: "refused",
|
|
23255
23481
|
problems: [`unknown command ${quoteWord(command)}; the commands are: ${commands}`]
|
|
@@ -23526,17 +23752,21 @@ function commandHelp(tool) {
|
|
|
23526
23752
|
`);
|
|
23527
23753
|
}
|
|
23528
23754
|
function commandsHelp() {
|
|
23529
|
-
const
|
|
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));
|
|
23530
23763
|
return [
|
|
23531
23764
|
"Usage: dispatch <command> [flags]",
|
|
23532
|
-
...
|
|
23533
|
-
const sentence = /^.*?[.!?](?=\s|$)/s.exec(spec.description)?.[0] ?? spec.description;
|
|
23534
|
-
return ` ${commandName(spec.name).padEnd(width)} ${sentence}`;
|
|
23535
|
-
}),
|
|
23765
|
+
...rows.map(({ name, sentence }) => ` ${name.padEnd(width)} ${sentence}`),
|
|
23536
23766
|
"",
|
|
23537
|
-
"Run dispatch <command> --help for its flags and an example. --dry-run checks
|
|
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.",
|
|
23538
23768
|
"",
|
|
23539
|
-
"dispatch login --device
|
|
23769
|
+
"dispatch login --device is no Dispatch call: it needs no host or session.",
|
|
23540
23770
|
""
|
|
23541
23771
|
].join(`
|
|
23542
23772
|
`);
|
|
@@ -27784,7 +28014,7 @@ function parseFrameJSON(text) {
|
|
|
27784
28014
|
const containers = typeof value === "object" && value !== null ? [value] : [];
|
|
27785
28015
|
for (let next = containers.pop();next !== undefined; next = containers.pop()) {
|
|
27786
28016
|
const members = next;
|
|
27787
|
-
|
|
28017
|
+
Reflect.deleteProperty(members, "__proto__");
|
|
27788
28018
|
let names = Object.keys(members);
|
|
27789
28019
|
if (names.some((name) => name.search(LONE_SURROGATE) !== -1)) {
|
|
27790
28020
|
const held = names.map((name) => members[name]);
|
|
@@ -28016,32 +28246,6 @@ function createDeliveryDedupe(now = Date.now) {
|
|
|
28016
28246
|
}
|
|
28017
28247
|
};
|
|
28018
28248
|
}
|
|
28019
|
-
function isCommentTargetedDelivery(delivery) {
|
|
28020
|
-
return "comment_id" in delivery;
|
|
28021
|
-
}
|
|
28022
|
-
var DispatchTargetedFrameSchema = object({
|
|
28023
|
-
event: DispatchEventSchema,
|
|
28024
|
-
delivery: DispatchTargetedDeliverySchema
|
|
28025
|
-
}).superRefine(({ event, delivery }, context) => {
|
|
28026
|
-
if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
|
|
28027
|
-
return;
|
|
28028
|
-
}
|
|
28029
|
-
if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
|
|
28030
|
-
return;
|
|
28031
|
-
}
|
|
28032
|
-
context.addIssue({
|
|
28033
|
-
code: "custom",
|
|
28034
|
-
message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
|
|
28035
|
-
});
|
|
28036
|
-
});
|
|
28037
|
-
var RecoverableDispatchDeliveryFailureSchema = object({
|
|
28038
|
-
event: object({
|
|
28039
|
-
type: _enum2(["message.created", "comment.created"]),
|
|
28040
|
-
issue_key: string2().nullable(),
|
|
28041
|
-
payload: object({ id: string2(), body: string2().optional() }).passthrough()
|
|
28042
|
-
}).passthrough(),
|
|
28043
|
-
delivery: DispatchTargetedDeliverySchema
|
|
28044
|
-
}).refine(({ event, delivery }) => event.type === "comment.created" ? isCommentTargetedDelivery(delivery) : !isCommentTargetedDelivery(delivery) && DispatchTargetedResourceIDSchema.safeParse(event.payload.id).success, { message: "delivery resource must match its event type" });
|
|
28045
28249
|
function eventPictures(event) {
|
|
28046
28250
|
let text;
|
|
28047
28251
|
if (event.type.startsWith("message.")) {
|
|
@@ -28073,16 +28277,22 @@ function carriedItem(event) {
|
|
|
28073
28277
|
const resource = event.type.startsWith("comment.") || event.type.startsWith("suggestion.") ? "comment" : event.type.startsWith("message.") ? "message" : undefined;
|
|
28074
28278
|
if (resource === undefined || !isObject3(event.payload))
|
|
28075
28279
|
return;
|
|
28076
|
-
const id = event.payload
|
|
28280
|
+
const { id } = event.payload;
|
|
28077
28281
|
if (typeof id !== "string" || id === "")
|
|
28078
28282
|
return;
|
|
28079
28283
|
return { resource, id, issueKey: event.issue_key };
|
|
28080
28284
|
}
|
|
28081
28285
|
function payloadWasOmitted(payload) {
|
|
28082
|
-
|
|
28286
|
+
if (!isObject3(payload))
|
|
28287
|
+
return false;
|
|
28288
|
+
const { payload_omitted } = payload;
|
|
28289
|
+
return payload_omitted === true;
|
|
28083
28290
|
}
|
|
28084
28291
|
function bodyWasCut(payload) {
|
|
28085
|
-
|
|
28292
|
+
if (!isObject3(payload))
|
|
28293
|
+
return false;
|
|
28294
|
+
const { body_truncated } = payload;
|
|
28295
|
+
return body_truncated === true || payloadWasOmitted(payload);
|
|
28086
28296
|
}
|
|
28087
28297
|
function wholeItemRoute(item) {
|
|
28088
28298
|
return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
|
|
@@ -28327,7 +28537,10 @@ var DISPATCH_BOOKKEEPING = new Set([
|
|
|
28327
28537
|
]);
|
|
28328
28538
|
function dispatchPayloadForReader(event, sessionID, issuedAt, toReader) {
|
|
28329
28539
|
const whole = dispatchPayload(event);
|
|
28330
|
-
|
|
28540
|
+
let changedField;
|
|
28541
|
+
if (event.type !== "issue.created" && isObject3(whole))
|
|
28542
|
+
({ changed: changedField } = whole);
|
|
28543
|
+
const changed = Array.isArray(changedField) ? changedField : [];
|
|
28331
28544
|
const payload = withoutEmptyFields(whole, (key, item) => changed.includes(key) || (key === "suggestion" || key === "forced") && item !== null && item !== undefined);
|
|
28332
28545
|
if (!isObject3(payload) || Array.isArray(payload))
|
|
28333
28546
|
return payload;
|
|
@@ -28442,27 +28655,25 @@ function parseDispatchFrame(rawPayload, wholeBody) {
|
|
|
28442
28655
|
try {
|
|
28443
28656
|
value = parseFrameJSON(rawPayload);
|
|
28444
28657
|
} catch {
|
|
28445
|
-
return {
|
|
28658
|
+
return {};
|
|
28446
28659
|
}
|
|
28447
|
-
|
|
28448
|
-
|
|
28449
|
-
|
|
28450
|
-
const
|
|
28660
|
+
const reading = readDispatchPayload(value);
|
|
28661
|
+
switch (reading.kind) {
|
|
28662
|
+
case "event": {
|
|
28663
|
+
const { notify, quiet } = reading.wireEvent;
|
|
28451
28664
|
return {
|
|
28452
|
-
event: withWholeBody(
|
|
28453
|
-
notify
|
|
28454
|
-
quiet
|
|
28455
|
-
delivery:
|
|
28665
|
+
event: withWholeBody(reading.event, wholeBody),
|
|
28666
|
+
notify,
|
|
28667
|
+
quiet,
|
|
28668
|
+
delivery: reading.delivery
|
|
28456
28669
|
};
|
|
28457
28670
|
}
|
|
28458
|
-
|
|
28459
|
-
|
|
28460
|
-
const delivery = recoverable.data.delivery;
|
|
28671
|
+
case "recovered": {
|
|
28672
|
+
const { delivery, event } = reading.failure;
|
|
28461
28673
|
const commentDelivery = isCommentTargetedDelivery(delivery);
|
|
28462
28674
|
const resource = commentDelivery ? "comment" : "message";
|
|
28463
|
-
const id = commentDelivery ? delivery.comment_id :
|
|
28675
|
+
const id = commentDelivery ? delivery.comment_id : event.payload.id;
|
|
28464
28676
|
return {
|
|
28465
|
-
raw: value,
|
|
28466
28677
|
rejectedDelivery: {
|
|
28467
28678
|
resource,
|
|
28468
28679
|
id,
|
|
@@ -28470,24 +28681,15 @@ function parseDispatchFrame(rawPayload, wholeBody) {
|
|
|
28470
28681
|
mode: delivery.mode,
|
|
28471
28682
|
replyPath: dispatchReplyPath(resource, id),
|
|
28472
28683
|
replyFields: commentDelivery ? { target: delivery.target } : {},
|
|
28473
|
-
issueKey:
|
|
28474
|
-
body:
|
|
28684
|
+
issueKey: event.issue_key,
|
|
28685
|
+
body: event.payload.body ?? ""
|
|
28475
28686
|
},
|
|
28476
28687
|
malformedDelivery: true
|
|
28477
28688
|
};
|
|
28478
28689
|
}
|
|
28479
|
-
|
|
28690
|
+
case "raw":
|
|
28691
|
+
return reading.targeted ? { malformedDelivery: true } : {};
|
|
28480
28692
|
}
|
|
28481
|
-
const parsed = DispatchEventSchema.safeParse(value);
|
|
28482
|
-
if (!parsed.success)
|
|
28483
|
-
return { raw: value };
|
|
28484
|
-
const wireEvent = value;
|
|
28485
|
-
return {
|
|
28486
|
-
event: withWholeBody(parsed.data, wholeBody),
|
|
28487
|
-
notify: wireEvent.notify,
|
|
28488
|
-
quiet: wireEvent.quiet,
|
|
28489
|
-
delivery: undefined
|
|
28490
|
-
};
|
|
28491
28693
|
}
|
|
28492
28694
|
var INBOUND_CARD_MAX_BYTES = 1 << 20;
|
|
28493
28695
|
function encodeWithin(value, maxBytes) {
|
|
@@ -28502,6 +28704,28 @@ function encodeWithin(value, maxBytes) {
|
|
|
28502
28704
|
return lines.join(`
|
|
28503
28705
|
`);
|
|
28504
28706
|
}
|
|
28707
|
+
function headerActor(actor) {
|
|
28708
|
+
const { kind, id, act, service } = actor;
|
|
28709
|
+
return {
|
|
28710
|
+
kind,
|
|
28711
|
+
...id === undefined ? {} : { id },
|
|
28712
|
+
...act === undefined ? {} : { act: ActorActSchema.safeParse(act).data ?? "not shown" },
|
|
28713
|
+
...kind !== "session" || service === undefined ? {} : { service: typeof service === "string" ? service : "not shown" }
|
|
28714
|
+
};
|
|
28715
|
+
}
|
|
28716
|
+
function dispatchCardAsText(rendered, event, reason, bound) {
|
|
28717
|
+
let text;
|
|
28718
|
+
try {
|
|
28719
|
+
text = JSON.stringify(event);
|
|
28720
|
+
} catch {}
|
|
28721
|
+
const asText = text === undefined ? undefined : encodeWithin({ envoy: { ...rendered, dispatch: text } }, bound);
|
|
28722
|
+
if (asText !== undefined)
|
|
28723
|
+
return asText;
|
|
28724
|
+
const notShown = `not shown: ${reason}`;
|
|
28725
|
+
const owner = event.owner === undefined ? {} : { owner: event.owner };
|
|
28726
|
+
const header = { type: event.type, actor: headerActor(event.actor), payload: notShown };
|
|
28727
|
+
return encodeWithin({ envoy: { ...rendered, dispatch: { ...owner, ...header } } }, bound) ?? encodeWithin({ envoy: { dispatch: { ...owner, ...header } } }, bound) ?? encodeWithin({ envoy: { dispatch: header } }, bound) ?? encode5({ envoy: { dispatch: { payload: notShown } } });
|
|
28728
|
+
}
|
|
28505
28729
|
function inboundTimestamp(milliseconds) {
|
|
28506
28730
|
if (milliseconds === undefined)
|
|
28507
28731
|
return "unknown";
|
|
@@ -28609,13 +28833,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28609
28833
|
dispatchReply = dispatchCommentReplyWith(frame.event, topic, commentPayload);
|
|
28610
28834
|
if (frame.event.type === "message.created") {
|
|
28611
28835
|
const message = DispatchTargetedMessagePayloadSchema.safeParse(frame.event.payload);
|
|
28612
|
-
const requested =
|
|
28613
|
-
if (message.success && requested
|
|
28836
|
+
const requested = frame.delivery;
|
|
28837
|
+
if (message.success && requested !== undefined && !isCommentTargetedDelivery(requested)) {
|
|
28614
28838
|
delivery = {
|
|
28615
28839
|
resource: "message",
|
|
28616
28840
|
id: message.data.id,
|
|
28617
|
-
attempt: requested.
|
|
28618
|
-
mode: requested.
|
|
28841
|
+
attempt: requested.attempt,
|
|
28842
|
+
mode: requested.mode,
|
|
28619
28843
|
replyPath: dispatchReplyPath("message", message.data.id),
|
|
28620
28844
|
replyFields: {},
|
|
28621
28845
|
issueKey: frame.event.issue_key,
|
|
@@ -28633,15 +28857,15 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28633
28857
|
}
|
|
28634
28858
|
} else if (frame.event.type === "comment.created") {
|
|
28635
28859
|
const comment = DispatchTargetedCommentPayloadSchema.safeParse(frame.event.payload);
|
|
28636
|
-
const requested =
|
|
28637
|
-
if (comment.success && requested
|
|
28860
|
+
const requested = frame.delivery;
|
|
28861
|
+
if (comment.success && requested !== undefined && isCommentTargetedDelivery(requested)) {
|
|
28638
28862
|
delivery = {
|
|
28639
28863
|
resource: "comment",
|
|
28640
|
-
id: requested.
|
|
28641
|
-
attempt: requested.
|
|
28642
|
-
mode: requested.
|
|
28643
|
-
replyPath: dispatchReplyPath("comment", requested.
|
|
28644
|
-
replyFields: { target: requested.
|
|
28864
|
+
id: requested.comment_id,
|
|
28865
|
+
attempt: requested.attempt,
|
|
28866
|
+
mode: requested.mode,
|
|
28867
|
+
replyPath: dispatchReplyPath("comment", requested.comment_id),
|
|
28868
|
+
replyFields: { target: requested.target },
|
|
28645
28869
|
issueKey: frame.event.issue_key,
|
|
28646
28870
|
body: comment.data.body,
|
|
28647
28871
|
...comment.data.body_truncated === true ? { bodyTruncated: true } : {}
|
|
@@ -28660,7 +28884,9 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28660
28884
|
let actor = frame.event.actor;
|
|
28661
28885
|
if ("origin" in frame.event.actor) {
|
|
28662
28886
|
const { origin, ...rest } = frame.event.actor;
|
|
28663
|
-
|
|
28887
|
+
let title;
|
|
28888
|
+
if (isObject3(origin))
|
|
28889
|
+
({ session_title: title } = origin);
|
|
28664
28890
|
actor = typeof title === "string" && title !== "" ? { ...rest, origin: { session_title: title } } : rest;
|
|
28665
28891
|
}
|
|
28666
28892
|
const owner = dispatchOwner(frame.event, topic);
|
|
@@ -28682,7 +28908,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28682
28908
|
trailer = humanEditDiffBlock(edit.data.diff, edit.data.diff_truncated);
|
|
28683
28909
|
}
|
|
28684
28910
|
} else {
|
|
28685
|
-
|
|
28911
|
+
dispatchIssue = "payload";
|
|
28686
28912
|
rejectedDelivery = frame.rejectedDelivery;
|
|
28687
28913
|
malformedDelivery = frame.malformedDelivery === true;
|
|
28688
28914
|
}
|
|
@@ -28737,7 +28963,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28737
28963
|
args: { topic: `notifications.role.${role}`, message: "..." }
|
|
28738
28964
|
}
|
|
28739
28965
|
},
|
|
28740
|
-
...dispatchRendered ? { dispatch: dispatchEvent } : {
|
|
28966
|
+
...dispatchRendered ? dispatchEvent === undefined ? {} : { dispatch: dispatchEvent } : {
|
|
28741
28967
|
...summaryIsHead ? {} : { summary: payloadSummary },
|
|
28742
28968
|
...message === undefined ? {} : { message }
|
|
28743
28969
|
},
|
|
@@ -28747,7 +28973,6 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28747
28973
|
},
|
|
28748
28974
|
...unrecognised === undefined ? {} : { unrecognised }
|
|
28749
28975
|
};
|
|
28750
|
-
const payloadKey = dispatchRendered ? "dispatch" : "message";
|
|
28751
28976
|
const payloadValue = dispatchRendered ? dispatchEvent : message;
|
|
28752
28977
|
const cardBound = Math.max(INBOUND_CARD_MAX_BYTES, 2 * (Buffer.byteLength(raw) + (wholeBody === undefined ? 0 : Buffer.byteLength(escapeString(wholeBody)))));
|
|
28753
28978
|
let card;
|
|
@@ -28761,7 +28986,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28761
28986
|
}
|
|
28762
28987
|
if (card === undefined) {
|
|
28763
28988
|
payloadShownAsText ??= `its layout is larger than the ${cardBound} bytes a card holds`;
|
|
28764
|
-
card = encode5({ envoy: { ...rendered,
|
|
28989
|
+
card = dispatchEvent === undefined ? encode5({ envoy: { ...rendered, message: envelope.payload } }) : dispatchCardAsText(rendered, dispatchEvent, payloadShownAsText, cardBound);
|
|
28765
28990
|
}
|
|
28766
28991
|
return {
|
|
28767
28992
|
skip: false,
|
|
@@ -29855,7 +30080,8 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
29855
30080
|
if (tool === "dispatch_read" && typeof args.message === "string") {
|
|
29856
30081
|
return { args, ref, owner: null };
|
|
29857
30082
|
}
|
|
29858
|
-
|
|
30083
|
+
const { retract } = args;
|
|
30084
|
+
if (tool === "dispatch_result" && typeof retract === "string") {
|
|
29859
30085
|
return { args, ref, owner: null };
|
|
29860
30086
|
}
|
|
29861
30087
|
const legionIssue = env.LEGION_ISSUE;
|
|
@@ -29931,7 +30157,7 @@ function refusalWithCode(error, ...clauses) {
|
|
|
29931
30157
|
const told = joined !== "" && /[.!?]$/.test(error.message) ? `${error.message} ${suffix.charAt(0).toUpperCase()}${suffix.slice(1)}` : `${error.message}${joined}`;
|
|
29932
30158
|
return new DispatchServiceError(error.code, error.status, `${error.code}: ${told}`, error);
|
|
29933
30159
|
}
|
|
29934
|
-
function parentStatusConflictLines(error, tool, args
|
|
30160
|
+
function parentStatusConflictLines(error, tool, args) {
|
|
29935
30161
|
if (!dispatchAnswered(error, 409) || error.code !== "PARENT_STATUS_CONFLICT")
|
|
29936
30162
|
return;
|
|
29937
30163
|
const issues = error.issues ?? [];
|
|
@@ -29942,28 +30168,15 @@ function parentStatusConflictLines(error, tool, args, legionIssue) {
|
|
|
29942
30168
|
return [
|
|
29943
30169
|
messageFor(error),
|
|
29944
30170
|
...issues.map((issue) => `${issue.key} [${issue.status}] ${issue.title}`),
|
|
29945
|
-
...nextSteps(tool, args, parents, children
|
|
30171
|
+
...nextSteps(tool, args, parents, children)
|
|
29946
30172
|
];
|
|
29947
30173
|
}
|
|
29948
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.";
|
|
29949
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.";
|
|
29950
|
-
function otherProjectSentence(named, keys) {
|
|
29951
|
-
const project = named === undefined ? undefined : issueProject(named);
|
|
29952
|
-
if (project === undefined)
|
|
29953
|
-
return "";
|
|
29954
|
-
const others = keys.filter((key) => {
|
|
29955
|
-
const other = issueProject(key);
|
|
29956
|
-
return other !== undefined && other !== project;
|
|
29957
|
-
});
|
|
29958
|
-
if (others.length === 0)
|
|
29959
|
-
return "";
|
|
29960
|
-
const one = others.length === 1;
|
|
29961
|
-
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.`;
|
|
29962
|
-
}
|
|
29963
30176
|
function includeParentCall(key) {
|
|
29964
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`;
|
|
29965
30178
|
}
|
|
29966
|
-
function nextSteps(tool, args, parents, children
|
|
30179
|
+
function nextSteps(tool, args, parents, children) {
|
|
29967
30180
|
if (tool === "dispatch_issue") {
|
|
29968
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.`);
|
|
29969
30182
|
}
|
|
@@ -29971,9 +30184,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
|
|
|
29971
30184
|
const written = issueUpdate ? args : {};
|
|
29972
30185
|
const fields = Object.keys(written).filter((field) => field !== "issue" && written[field] !== undefined);
|
|
29973
30186
|
const issue = optionalString(written, "issue");
|
|
29974
|
-
const named = issueUpdate ? issue ?? legionIssue : undefined;
|
|
29975
30187
|
const childHolds = children.length > 0;
|
|
29976
|
-
const childScope = otherProjectSentence(named, children);
|
|
29977
30188
|
const status = optionalString(written, "status");
|
|
29978
30189
|
const parent = optionalString(written, "parent");
|
|
29979
30190
|
const alone = `--status${status === "done" ? " and --reason" : ""} alone`;
|
|
@@ -29986,7 +30197,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
|
|
|
29986
30197
|
const afterStatus = childHolds ? ", after the status change," : "";
|
|
29987
30198
|
return [
|
|
29988
30199
|
...childHolds ? [
|
|
29989
|
-
`${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}
|
|
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}.`
|
|
29990
30201
|
] : [],
|
|
29991
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}.`)
|
|
29992
30203
|
];
|
|
@@ -29994,8 +30205,8 @@ function nextSteps(tool, args, parents, children, legionIssue) {
|
|
|
29994
30205
|
const others = ISSUE_UPDATE_PATCH_FIELDS.some((field) => written[field] !== undefined);
|
|
29995
30206
|
const apart = (subject) => others ? ` ${subject} with ${alone}, so send the call's other changes in a call of their own.` : "";
|
|
29996
30207
|
return [
|
|
29997
|
-
...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}
|
|
29998
|
-
...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}
|
|
30208
|
+
...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}`] : [],
|
|
30209
|
+
...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}`] : []
|
|
29999
30210
|
];
|
|
30000
30211
|
}
|
|
30001
30212
|
function dispatchAnswered(error, status) {
|
|
@@ -31814,7 +32025,8 @@ async function relatedCommand(context) {
|
|
|
31814
32025
|
};
|
|
31815
32026
|
}
|
|
31816
32027
|
function printsJson(tool, args) {
|
|
31817
|
-
|
|
32028
|
+
const { json } = args;
|
|
32029
|
+
return tool === "dispatch_issues" && json === true;
|
|
31818
32030
|
}
|
|
31819
32031
|
async function issuesCommand(context) {
|
|
31820
32032
|
const { args, client, input } = context;
|
|
@@ -31880,7 +32092,8 @@ async function issuesCommand(context) {
|
|
|
31880
32092
|
};
|
|
31881
32093
|
}
|
|
31882
32094
|
function dryRunAsksDispatch(tool, args) {
|
|
31883
|
-
|
|
32095
|
+
const { retract } = args;
|
|
32096
|
+
return tool === "dispatch_result" && retract === undefined;
|
|
31884
32097
|
}
|
|
31885
32098
|
async function resultCommand(context) {
|
|
31886
32099
|
const { args, client, actor } = context;
|
|
@@ -31987,7 +32200,7 @@ import {
|
|
|
31987
32200
|
utimesSync,
|
|
31988
32201
|
writeFileSync
|
|
31989
32202
|
} from "fs";
|
|
31990
|
-
import { isAbsolute as isAbsolute3, join as join5, resolve as
|
|
32203
|
+
import { isAbsolute as isAbsolute3, join as join5, resolve as resolve3 } from "path";
|
|
31991
32204
|
var ASKGATE_RECORD = "askgate";
|
|
31992
32205
|
var MARKER_MAX_AGE_MS = 2 * 60 * 60000;
|
|
31993
32206
|
var STORE_BEAT_MS = 10 * 60000;
|
|
@@ -32045,7 +32258,7 @@ function fileOperands(argv) {
|
|
|
32045
32258
|
}
|
|
32046
32259
|
function operandPath(cwd, file) {
|
|
32047
32260
|
if (file.flag === "--path")
|
|
32048
|
-
return
|
|
32261
|
+
return resolve3(cwd, file.operand);
|
|
32049
32262
|
return isAbsolute3(file.operand) ? file.operand : `${cwd}/${file.operand}`;
|
|
32050
32263
|
}
|
|
32051
32264
|
function bytesDigest(bytes) {
|
|
@@ -32419,12 +32632,10 @@ var WRITE_ROUTES = [
|
|
|
32419
32632
|
commands: ["architecture-sync"]
|
|
32420
32633
|
}
|
|
32421
32634
|
];
|
|
32635
|
+
var WRITE_ROUTE_SEGMENTS = WRITE_ROUTES.map((row) => ({ row, segments: row.pattern.split("/") }));
|
|
32422
32636
|
function writeRoute(method, path) {
|
|
32423
32637
|
const segments = path.split("/");
|
|
32424
|
-
return
|
|
32425
|
-
const pattern = row.pattern.split("/");
|
|
32426
|
-
return row.method === method && pattern.length === segments.length && pattern.every((part, at) => part.startsWith("{") ? segments[at] !== "" : part === segments[at]);
|
|
32427
|
-
});
|
|
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;
|
|
32428
32639
|
}
|
|
32429
32640
|
|
|
32430
32641
|
class ApiGateRefusal extends Error {
|
|
@@ -35288,9 +35499,9 @@ async function whoamiCommand(context) {
|
|
|
35288
35499
|
} else {
|
|
35289
35500
|
acting = `Session ${session} runs under the shared token: ${unowned}`;
|
|
35290
35501
|
}
|
|
35291
|
-
const
|
|
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." : "";
|
|
35292
35503
|
return {
|
|
35293
|
-
text: acting + elsewhere +
|
|
35504
|
+
text: acting + elsewhere + projectSentence,
|
|
35294
35505
|
details: { session, owner, service, project, project_scope: projectScope }
|
|
35295
35506
|
};
|
|
35296
35507
|
}
|