@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/envoy-channel.js
CHANGED
|
@@ -23780,7 +23780,7 @@ function scrubProcessStreams() {
|
|
|
23780
23780
|
import { spawn as spawn2 } from "child_process";
|
|
23781
23781
|
import { unwatchFile as unwatchFile3, watchFile as watchFile3 } from "fs";
|
|
23782
23782
|
import { homedir as homedir4 } from "os";
|
|
23783
|
-
import { join as join23, resolve as
|
|
23783
|
+
import { join as join23, resolve as resolve5 } from "path";
|
|
23784
23784
|
|
|
23785
23785
|
// ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
|
|
23786
23786
|
var NEVER = Object.freeze({
|
|
@@ -37123,21 +37123,22 @@ var ISSUE_UPDATE_OPTIONS_RULE = "include_children, unlink_children and include_p
|
|
|
37123
37123
|
var ISSUE_UPDATE_RULE = `${ISSUE_UPDATE_FIELDS_RULE} ${ISSUE_UPDATE_DONE_RULE}; ${ISSUE_UPDATE_REASON_RULE}; ${ISSUE_UPDATE_LABELS_RULE}. ${ISSUE_UPDATE_OPTIONS_RULE}`;
|
|
37124
37124
|
function issueStatusOptionsProblem(input) {
|
|
37125
37125
|
const options = issueStatusOptionsOf(input);
|
|
37126
|
+
const optionInput = input;
|
|
37126
37127
|
if (options.length === 0)
|
|
37127
37128
|
return;
|
|
37128
37129
|
const named = options.join(", ").replace(/, ([^,]*)$/, " and $1");
|
|
37129
37130
|
const others = ISSUE_UPDATE_PATCH_FIELDS.filter((field) => input[field] !== undefined);
|
|
37130
37131
|
return brokenParts([
|
|
37131
37132
|
[
|
|
37132
|
-
!(
|
|
37133
|
+
!(optionInput.include_children === true && optionInput.unlink_children === true),
|
|
37133
37134
|
"include_children does not go with unlink_children. The open children move with the issue or leave it, so name one of the two."
|
|
37134
37135
|
],
|
|
37135
37136
|
[
|
|
37136
|
-
!(
|
|
37137
|
+
!(optionInput.include_children === true && optionInput.status === "done"),
|
|
37137
37138
|
"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."
|
|
37138
37139
|
],
|
|
37139
37140
|
[
|
|
37140
|
-
typeof
|
|
37141
|
+
typeof optionInput.status === "string",
|
|
37141
37142
|
`status is required with ${named}. Add status, or drop ${named}.`
|
|
37142
37143
|
],
|
|
37143
37144
|
[
|
|
@@ -37290,8 +37291,8 @@ var RESULT_SHAPE_RULE = `${RESULT_RETRACT_RULE} A call with retract takes reason
|
|
|
37290
37291
|
function resultProblem(value) {
|
|
37291
37292
|
const input = value;
|
|
37292
37293
|
const carried = RESULT_RECORD_FIELDS.filter((field) => input[field] !== undefined);
|
|
37293
|
-
if (typeof input
|
|
37294
|
-
const reason = input
|
|
37294
|
+
if (typeof input.retract === "string") {
|
|
37295
|
+
const reason = input.reason;
|
|
37295
37296
|
if (typeof reason !== "string" || reason.trim() === "") {
|
|
37296
37297
|
return "retract needs reason, the words that say why the result is wrong.";
|
|
37297
37298
|
}
|
|
@@ -37300,7 +37301,7 @@ function resultProblem(value) {
|
|
|
37300
37301
|
}
|
|
37301
37302
|
return;
|
|
37302
37303
|
}
|
|
37303
|
-
if (input
|
|
37304
|
+
if (input.reason !== undefined) {
|
|
37304
37305
|
return "reason goes with retract, and this call carries no retract. Name the result to retract, or drop reason.";
|
|
37305
37306
|
}
|
|
37306
37307
|
const missing = RESULT_REQUIRED_FIELDS.filter((field) => input[field] === undefined);
|
|
@@ -37911,7 +37912,7 @@ var dispatchToolSpecs = [
|
|
|
37911
37912
|
{
|
|
37912
37913
|
name: "dispatch_project_update",
|
|
37913
37914
|
example: { project: "CORE", proven_sessions: "on" },
|
|
37914
|
-
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
|
|
37915
|
+
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.",
|
|
37915
37916
|
arguments: (z) => ({
|
|
37916
37917
|
project: z.string().describe("Project key whose setting to change, such as CORE."),
|
|
37917
37918
|
proven_sessions: z.enum(["on", "off"]).describe("on turns the setting on; off turns it off and needs the person scope.")
|
|
@@ -37964,7 +37965,7 @@ var dispatchToolSpecs = [
|
|
|
37964
37965
|
{
|
|
37965
37966
|
name: "dispatch_whoami",
|
|
37966
37967
|
example: {},
|
|
37967
|
-
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
|
|
37968
|
+
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.",
|
|
37968
37969
|
arguments: () => ({}),
|
|
37969
37970
|
strict: true
|
|
37970
37971
|
},
|
|
@@ -37978,7 +37979,7 @@ var dispatchToolSpecs = [
|
|
|
37978
37979
|
{
|
|
37979
37980
|
name: "dispatch_api",
|
|
37980
37981
|
example: { path: "/api/v1/issues/DSP-1/events?limit=200" },
|
|
37981
|
-
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.",
|
|
37982
|
+
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.",
|
|
37982
37983
|
arguments: (z) => ({
|
|
37983
37984
|
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.'),
|
|
37984
37985
|
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(),
|
|
@@ -38769,6 +38770,52 @@ var DispatchTargetedDeliverySchema = union([
|
|
|
38769
38770
|
DispatchTargetedCommentDeliverySchema,
|
|
38770
38771
|
DispatchTargetedMessageDeliverySchema
|
|
38771
38772
|
]);
|
|
38773
|
+
function isCommentTargetedDelivery(delivery) {
|
|
38774
|
+
return "comment_id" in delivery;
|
|
38775
|
+
}
|
|
38776
|
+
var DispatchTargetedFrameSchema = object({
|
|
38777
|
+
event: DispatchEventSchema,
|
|
38778
|
+
delivery: DispatchTargetedDeliverySchema
|
|
38779
|
+
}).superRefine(({ event, delivery }, context) => {
|
|
38780
|
+
if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
|
|
38781
|
+
return;
|
|
38782
|
+
}
|
|
38783
|
+
if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
|
|
38784
|
+
return;
|
|
38785
|
+
}
|
|
38786
|
+
context.addIssue({
|
|
38787
|
+
code: "custom",
|
|
38788
|
+
message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
|
|
38789
|
+
});
|
|
38790
|
+
});
|
|
38791
|
+
var RecoverableDispatchDeliveryFailureSchema = object({
|
|
38792
|
+
event: object({
|
|
38793
|
+
type: _enum2(["message.created", "comment.created"]),
|
|
38794
|
+
issue_key: string2().nullable(),
|
|
38795
|
+
payload: object({ id: string2(), body: string2().optional() }).passthrough()
|
|
38796
|
+
}).passthrough(),
|
|
38797
|
+
delivery: DispatchTargetedDeliverySchema
|
|
38798
|
+
}).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" });
|
|
38799
|
+
function readDispatchPayload(value) {
|
|
38800
|
+
if (typeof value === "object" && value !== null && "delivery" in value) {
|
|
38801
|
+
const targeted = DispatchTargetedFrameSchema.safeParse(value);
|
|
38802
|
+
if (targeted.success) {
|
|
38803
|
+
const { event: wireEvent } = value;
|
|
38804
|
+
return {
|
|
38805
|
+
kind: "event",
|
|
38806
|
+
event: targeted.data.event,
|
|
38807
|
+
wireEvent,
|
|
38808
|
+
delivery: targeted.data.delivery
|
|
38809
|
+
};
|
|
38810
|
+
}
|
|
38811
|
+
const recovered = RecoverableDispatchDeliveryFailureSchema.safeParse(value);
|
|
38812
|
+
if (recovered.success)
|
|
38813
|
+
return { kind: "recovered", failure: recovered.data };
|
|
38814
|
+
return { kind: "raw", targeted: true };
|
|
38815
|
+
}
|
|
38816
|
+
const parsed = DispatchEventSchema.safeParse(value);
|
|
38817
|
+
return parsed.success ? { kind: "event", event: parsed.data, wireEvent: value } : { kind: "raw", targeted: false };
|
|
38818
|
+
}
|
|
38772
38819
|
// ../contracts/src/dispatch-api-user.ts
|
|
38773
38820
|
var UserIssueStateSchema = strictObject({
|
|
38774
38821
|
pinned: boolean2(),
|
|
@@ -46843,9 +46890,6 @@ function reachedNothing(error) {
|
|
|
46843
46890
|
}
|
|
46844
46891
|
|
|
46845
46892
|
class LoggableError extends Error {
|
|
46846
|
-
constructor(message) {
|
|
46847
|
-
super(message);
|
|
46848
|
-
}
|
|
46849
46893
|
}
|
|
46850
46894
|
var SERVER_REFUSALS = [
|
|
46851
46895
|
"Authorization Violation",
|
|
@@ -49980,7 +50024,186 @@ function fileTextBytes(text) {
|
|
|
49980
50024
|
return encoder4.encode(text);
|
|
49981
50025
|
}
|
|
49982
50026
|
|
|
50027
|
+
// ../envoy-client/src/dispatch-login-command.ts
|
|
50028
|
+
var LOGIN_COMMAND = "login";
|
|
50029
|
+
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.";
|
|
50030
|
+
function loginHelp() {
|
|
50031
|
+
return [
|
|
50032
|
+
"Usage: dispatch login --device [--person <address>]",
|
|
50033
|
+
"",
|
|
50034
|
+
`${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.`,
|
|
50035
|
+
"",
|
|
50036
|
+
"Flags:",
|
|
50037
|
+
" --device",
|
|
50038
|
+
" Log in with the broker's device grant: the only way there is, and required.",
|
|
50039
|
+
" --person <address>",
|
|
50040
|
+
" The person who approves the login, by the address they sign in to Dispatch with; else AGENT_SECRETS_PERSON.",
|
|
50041
|
+
"",
|
|
50042
|
+
"It reads AGENT_SECRETS_URL, the broker, and needs no Dispatch host or session.",
|
|
50043
|
+
"",
|
|
50044
|
+
"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.",
|
|
50045
|
+
"",
|
|
50046
|
+
"Example: dispatch login --device --person ada@example.com",
|
|
50047
|
+
""
|
|
50048
|
+
].join(`
|
|
50049
|
+
`);
|
|
50050
|
+
}
|
|
50051
|
+
|
|
50052
|
+
// ../envoy-client/src/dispatch-proxy-command.ts
|
|
50053
|
+
import { resolve as resolve3 } from "path";
|
|
50054
|
+
var PROXY_COMMAND = "proxy";
|
|
50055
|
+
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.";
|
|
50056
|
+
var SOCKET_PATH_MAX_BYTES = 107;
|
|
50057
|
+
function proxyExitLine(requests, trades, renewed) {
|
|
50058
|
+
return `dispatch proxy: ${requests} requests, ${trades} trades, ${renewed} after BROKER_TOKEN_NOT_ACTIVE`;
|
|
50059
|
+
}
|
|
50060
|
+
function proxyHelp() {
|
|
50061
|
+
return [
|
|
50062
|
+
"Usage: dispatch proxy --socket <path> [--dry-run] -- <command> [<argument>...]",
|
|
50063
|
+
"",
|
|
50064
|
+
PROXY_SENTENCE,
|
|
50065
|
+
"",
|
|
50066
|
+
"The proxy listens on a unix socket at <path> for the whole run of <command>. It sends each",
|
|
50067
|
+
"request it takes to the Dispatch server and the session that a dispatch command resolves in",
|
|
50068
|
+
"the same environment, with this session's broker token and a new DPoP proof. So the tool",
|
|
50069
|
+
"holds no credential and signs nothing. It adds the path of each request to the path of the",
|
|
50070
|
+
"Dispatch URL, and it does not decode the query. The proxy trades for the token once before it",
|
|
50071
|
+
"starts the command, and again only when the token has less than 5 minutes to live, or after",
|
|
50072
|
+
"Dispatch answers 401 BROKER_TOKEN_NOT_ACTIVE. It runs only under DISPATCH_TOKEN_BROKER=1.",
|
|
50073
|
+
"",
|
|
50074
|
+
"What it sends:",
|
|
50075
|
+
" GET /api/... any GET whose path starts with /api/",
|
|
50076
|
+
" POST /api/v1/issues/<key>/comments a comment that carries an Idempotency-Key header",
|
|
50077
|
+
"It sends no other write. A tool reads much and writes little. Where a dispatch command sends a",
|
|
50078
|
+
"write, the write goes through that command, so AskGate reviews it wherever AskGate gates that",
|
|
50079
|
+
"command. The proxy's refusal of the write names that command. Where no other dispatch command",
|
|
50080
|
+
"sends a write under /api/v1, the refusal names dispatch api --method, which sends it outside a",
|
|
50081
|
+
"session whose AskGate reviews Dispatch writes. The comment needs a key so that a resend posts",
|
|
50082
|
+
"it once. The comment POST passes no AskGate review. The proxy is not one of the writes that",
|
|
50083
|
+
"AskGate gates, and the Dispatch server checks no marker. A session that holds a Dispatch token",
|
|
50084
|
+
"can post the same comment with that token already.",
|
|
50085
|
+
"",
|
|
50086
|
+
"It listens on a unix socket only, made with mode 0600, and opens no TCP port. The roles of a",
|
|
50087
|
+
"pod share the pod's network, so a port would let another role act as this one. A socket path",
|
|
50088
|
+
"that exists is refused, so give it a path in a new directory (mktemp -d). A socket that a",
|
|
50089
|
+
"killed proxy left behind refuses the next start.",
|
|
50090
|
+
"",
|
|
50091
|
+
"How a tool calls it: the command runs with DISPATCH_PROXY_SOCKET set to the socket's path.",
|
|
50092
|
+
"The host in a URL is not read. Write the path and the query.",
|
|
50093
|
+
' curl --unix-socket "$DISPATCH_PROXY_SOCKET" http://dispatch/api/v1/issues',
|
|
50094
|
+
" In Python, an http.client.HTTPConnection whose connect opens an AF_UNIX socket:",
|
|
50095
|
+
" import http.client, os, socket",
|
|
50096
|
+
" class ProxyConnection(http.client.HTTPConnection):",
|
|
50097
|
+
" def connect(self):",
|
|
50098
|
+
" self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)",
|
|
50099
|
+
' self.sock.connect(os.environ["DISPATCH_PROXY_SOCKET"])',
|
|
50100
|
+
' connection = ProxyConnection("dispatch")',
|
|
50101
|
+
' connection.request("GET", "/api/v1/issues?project=DSP")',
|
|
50102
|
+
" answer = connection.getresponse()",
|
|
50103
|
+
" print(answer.status, answer.read())",
|
|
50104
|
+
"",
|
|
50105
|
+
"What it answers: Dispatch's status, headers and body as Dispatch sent them. An answer that",
|
|
50106
|
+
"carries Transfer-Encoding as well as Content-Length is the one exception: it comes back",
|
|
50107
|
+
"without that Content-Length (RFC 9112, section 6.3), with its body chunked. It follows no",
|
|
50108
|
+
"redirect. Its own refusals have a JSON body with a code and an error, and each code starts",
|
|
50109
|
+
"with PROXY_. No code of Dispatch's does. It never answers 403 or 404 of its own.",
|
|
50110
|
+
" 400 PROXY_TARGET_REFUSED a target that names a host (http://... or //...)",
|
|
50111
|
+
" 405 PROXY_METHOD_REFUSED each other method or path, and a comment POST with no",
|
|
50112
|
+
" Idempotency-Key. The error names the dispatch command to",
|
|
50113
|
+
" use, where one exists. For a write under /api/v1 that no",
|
|
50114
|
+
" other dispatch command sends, it names dispatch api",
|
|
50115
|
+
" --method. It also refuses a target that holds a # or a",
|
|
50116
|
+
" control character, and a path with a . or .. segment",
|
|
50117
|
+
" (plain or percent-encoded), a backslash, or %2F or %5C in",
|
|
50118
|
+
" either case: each can reach another route than the one the",
|
|
50119
|
+
" target names.",
|
|
50120
|
+
" 502 PROXY_TRADE_REFUSED the token has ended and the broker refused a new one. The",
|
|
50121
|
+
" error is in the broker's words.",
|
|
50122
|
+
" 502 PROXY_DISPATCH_UNREACHABLE Dispatch did not answer",
|
|
50123
|
+
"",
|
|
50124
|
+
"Flags:",
|
|
50125
|
+
" --socket <path>",
|
|
50126
|
+
" The socket to listen on. Also --socket=<path>. A path over 107 bytes is refused.",
|
|
50127
|
+
" --dry-run",
|
|
50128
|
+
" Checks the arguments and the environment, prints the Dispatch server, the session and",
|
|
50129
|
+
" the socket it would use, and starts nothing.",
|
|
50130
|
+
" --help",
|
|
50131
|
+
" Prints this help.",
|
|
50132
|
+
"Every word after -- is the command's, flags included.",
|
|
50133
|
+
"",
|
|
50134
|
+
"It exits with the command's status. A command that a signal ended is 128 plus the signal's",
|
|
50135
|
+
"number. A command that does not exist is 127, and one that cannot run is 126. It exits 2 when",
|
|
50136
|
+
"it cannot start, and runs no command then. It sends SIGTERM, SIGINT and SIGHUP on to the",
|
|
50137
|
+
"command and serves until the command ends. Then it removes its socket. The last line it",
|
|
50138
|
+
"writes on standard error is:",
|
|
50139
|
+
" dispatch proxy: <n> requests, <m> trades, <r> after BROKER_TOKEN_NOT_ACTIVE",
|
|
50140
|
+
"Here n counts the requests sent to Dispatch, m the trades that gave a token, and r those of",
|
|
50141
|
+
"them that followed a BROKER_TOKEN_NOT_ACTIVE answer.",
|
|
50142
|
+
"",
|
|
50143
|
+
'Example: dispatch proxy --socket "$(mktemp -d)/d.sock" -- python3 work-cost.py',
|
|
50144
|
+
""
|
|
50145
|
+
].join(`
|
|
50146
|
+
`);
|
|
50147
|
+
}
|
|
50148
|
+
function parseProxyArgv(rest, cwd) {
|
|
50149
|
+
const separator = rest.indexOf("--");
|
|
50150
|
+
const own = separator === -1 ? rest : rest.slice(0, separator);
|
|
50151
|
+
if (own.includes("--help"))
|
|
50152
|
+
return { kind: "help" };
|
|
50153
|
+
let socket;
|
|
50154
|
+
let dryRun = false;
|
|
50155
|
+
for (let at = 0;at < own.length; at += 1) {
|
|
50156
|
+
const word = own[at] ?? "";
|
|
50157
|
+
if (word === "--dry-run") {
|
|
50158
|
+
dryRun = true;
|
|
50159
|
+
continue;
|
|
50160
|
+
}
|
|
50161
|
+
if (word !== "--socket" && !word.startsWith("--socket=")) {
|
|
50162
|
+
return {
|
|
50163
|
+
kind: "refused",
|
|
50164
|
+
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.`
|
|
50165
|
+
};
|
|
50166
|
+
}
|
|
50167
|
+
if (socket !== undefined)
|
|
50168
|
+
return { kind: "refused", problem: "--socket is given twice." };
|
|
50169
|
+
let value;
|
|
50170
|
+
if (word === "--socket") {
|
|
50171
|
+
at += 1;
|
|
50172
|
+
value = own[at];
|
|
50173
|
+
} else {
|
|
50174
|
+
value = word.slice("--socket=".length);
|
|
50175
|
+
}
|
|
50176
|
+
if (value === undefined || value === "" || value.startsWith("-")) {
|
|
50177
|
+
return { kind: "refused", problem: "--socket takes the path of the socket to listen on." };
|
|
50178
|
+
}
|
|
50179
|
+
socket = value;
|
|
50180
|
+
}
|
|
50181
|
+
if (socket === undefined) {
|
|
50182
|
+
return { kind: "refused", problem: "--socket <path> is missing." };
|
|
50183
|
+
}
|
|
50184
|
+
const command = separator === -1 ? [] : rest.slice(separator + 1);
|
|
50185
|
+
if (command.length === 0) {
|
|
50186
|
+
return {
|
|
50187
|
+
kind: "refused",
|
|
50188
|
+
problem: "No command is given: write it after --, as -- <command> [<argument>...]."
|
|
50189
|
+
};
|
|
50190
|
+
}
|
|
50191
|
+
const path = resolve3(cwd, socket);
|
|
50192
|
+
const bytes = Buffer.byteLength(path);
|
|
50193
|
+
if (bytes > SOCKET_PATH_MAX_BYTES) {
|
|
50194
|
+
return {
|
|
50195
|
+
kind: "refused",
|
|
50196
|
+
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.`
|
|
50197
|
+
};
|
|
50198
|
+
}
|
|
50199
|
+
return { kind: "run", socket: path, dryRun, command };
|
|
50200
|
+
}
|
|
50201
|
+
|
|
49983
50202
|
// ../envoy-client/src/dispatch-command.ts
|
|
50203
|
+
var COMMANDS_OUTSIDE_THE_SPECS = [
|
|
50204
|
+
{ name: PROXY_COMMAND, sentence: PROXY_SENTENCE, help: proxyHelp },
|
|
50205
|
+
{ name: LOGIN_COMMAND, sentence: LOGIN_SENTENCE, help: loginHelp }
|
|
50206
|
+
];
|
|
49984
50207
|
var PREFIXED_FLAGS = [
|
|
49985
50208
|
{
|
|
49986
50209
|
tool: "dispatch_comment",
|
|
@@ -50252,7 +50475,10 @@ function parseCommand(argv, io) {
|
|
|
50252
50475
|
return { kind: "help" };
|
|
50253
50476
|
const tool = toolForCommand(command);
|
|
50254
50477
|
if (tool === undefined) {
|
|
50255
|
-
const commands = [
|
|
50478
|
+
const commands = [
|
|
50479
|
+
...toolsByCommand.keys(),
|
|
50480
|
+
...COMMANDS_OUTSIDE_THE_SPECS.map(({ name }) => name)
|
|
50481
|
+
].join(", ");
|
|
50256
50482
|
return {
|
|
50257
50483
|
kind: "refused",
|
|
50258
50484
|
problems: [`unknown command ${quoteWord(command)}; the commands are: ${commands}`]
|
|
@@ -50529,17 +50755,21 @@ function commandHelp(tool) {
|
|
|
50529
50755
|
`);
|
|
50530
50756
|
}
|
|
50531
50757
|
function commandsHelp() {
|
|
50532
|
-
const
|
|
50758
|
+
const rows = [
|
|
50759
|
+
...dispatchToolSpecs.map((spec) => ({
|
|
50760
|
+
name: commandName(spec.name),
|
|
50761
|
+
sentence: /^.*?[.!?](?=\s|$)/s.exec(spec.description)?.[0] ?? spec.description
|
|
50762
|
+
})),
|
|
50763
|
+
...COMMANDS_OUTSIDE_THE_SPECS
|
|
50764
|
+
];
|
|
50765
|
+
const width = Math.max(...rows.map(({ name }) => name.length));
|
|
50533
50766
|
return [
|
|
50534
50767
|
"Usage: dispatch <command> [flags]",
|
|
50535
|
-
...
|
|
50536
|
-
const sentence = /^.*?[.!?](?=\s|$)/s.exec(spec.description)?.[0] ?? spec.description;
|
|
50537
|
-
return ` ${commandName(spec.name).padEnd(width)} ${sentence}`;
|
|
50538
|
-
}),
|
|
50768
|
+
...rows.map(({ name, sentence }) => ` ${name.padEnd(width)} ${sentence}`),
|
|
50539
50769
|
"",
|
|
50540
|
-
"Run dispatch <command> --help for its flags and an example. --dry-run checks
|
|
50770
|
+
"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.",
|
|
50541
50771
|
"",
|
|
50542
|
-
"dispatch login --device
|
|
50772
|
+
"dispatch login --device is no Dispatch call: it needs no host or session.",
|
|
50543
50773
|
""
|
|
50544
50774
|
].join(`
|
|
50545
50775
|
`);
|
|
@@ -52632,7 +52862,7 @@ function parseFrameJSON(text) {
|
|
|
52632
52862
|
const containers = typeof value === "object" && value !== null ? [value] : [];
|
|
52633
52863
|
for (let next = containers.pop();next !== undefined; next = containers.pop()) {
|
|
52634
52864
|
const members = next;
|
|
52635
|
-
|
|
52865
|
+
Reflect.deleteProperty(members, "__proto__");
|
|
52636
52866
|
let names = Object.keys(members);
|
|
52637
52867
|
if (names.some((name) => name.search(LONE_SURROGATE) !== -1)) {
|
|
52638
52868
|
const held = names.map((name) => members[name]);
|
|
@@ -52864,32 +53094,6 @@ function createDeliveryDedupe(now = Date.now) {
|
|
|
52864
53094
|
}
|
|
52865
53095
|
};
|
|
52866
53096
|
}
|
|
52867
|
-
function isCommentTargetedDelivery(delivery) {
|
|
52868
|
-
return "comment_id" in delivery;
|
|
52869
|
-
}
|
|
52870
|
-
var DispatchTargetedFrameSchema = object({
|
|
52871
|
-
event: DispatchEventSchema,
|
|
52872
|
-
delivery: DispatchTargetedDeliverySchema
|
|
52873
|
-
}).superRefine(({ event, delivery }, context) => {
|
|
52874
|
-
if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
|
|
52875
|
-
return;
|
|
52876
|
-
}
|
|
52877
|
-
if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
|
|
52878
|
-
return;
|
|
52879
|
-
}
|
|
52880
|
-
context.addIssue({
|
|
52881
|
-
code: "custom",
|
|
52882
|
-
message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
|
|
52883
|
-
});
|
|
52884
|
-
});
|
|
52885
|
-
var RecoverableDispatchDeliveryFailureSchema = object({
|
|
52886
|
-
event: object({
|
|
52887
|
-
type: _enum2(["message.created", "comment.created"]),
|
|
52888
|
-
issue_key: string2().nullable(),
|
|
52889
|
-
payload: object({ id: string2(), body: string2().optional() }).passthrough()
|
|
52890
|
-
}).passthrough(),
|
|
52891
|
-
delivery: DispatchTargetedDeliverySchema
|
|
52892
|
-
}).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" });
|
|
52893
53097
|
function eventPictures(event) {
|
|
52894
53098
|
let text;
|
|
52895
53099
|
if (event.type.startsWith("message.")) {
|
|
@@ -52921,16 +53125,22 @@ function carriedItem(event) {
|
|
|
52921
53125
|
const resource = event.type.startsWith("comment.") || event.type.startsWith("suggestion.") ? "comment" : event.type.startsWith("message.") ? "message" : undefined;
|
|
52922
53126
|
if (resource === undefined || !isObject3(event.payload))
|
|
52923
53127
|
return;
|
|
52924
|
-
const id = event.payload
|
|
53128
|
+
const { id } = event.payload;
|
|
52925
53129
|
if (typeof id !== "string" || id === "")
|
|
52926
53130
|
return;
|
|
52927
53131
|
return { resource, id, issueKey: event.issue_key };
|
|
52928
53132
|
}
|
|
52929
53133
|
function payloadWasOmitted(payload) {
|
|
52930
|
-
|
|
53134
|
+
if (!isObject3(payload))
|
|
53135
|
+
return false;
|
|
53136
|
+
const { payload_omitted } = payload;
|
|
53137
|
+
return payload_omitted === true;
|
|
52931
53138
|
}
|
|
52932
53139
|
function bodyWasCut(payload) {
|
|
52933
|
-
|
|
53140
|
+
if (!isObject3(payload))
|
|
53141
|
+
return false;
|
|
53142
|
+
const { body_truncated } = payload;
|
|
53143
|
+
return body_truncated === true || payloadWasOmitted(payload);
|
|
52934
53144
|
}
|
|
52935
53145
|
function wholeItemRoute(item) {
|
|
52936
53146
|
return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
|
|
@@ -53175,7 +53385,10 @@ var DISPATCH_BOOKKEEPING = new Set([
|
|
|
53175
53385
|
]);
|
|
53176
53386
|
function dispatchPayloadForReader(event, sessionID, issuedAt, toReader) {
|
|
53177
53387
|
const whole = dispatchPayload(event);
|
|
53178
|
-
|
|
53388
|
+
let changedField;
|
|
53389
|
+
if (event.type !== "issue.created" && isObject3(whole))
|
|
53390
|
+
({ changed: changedField } = whole);
|
|
53391
|
+
const changed = Array.isArray(changedField) ? changedField : [];
|
|
53179
53392
|
const payload = withoutEmptyFields(whole, (key, item) => changed.includes(key) || (key === "suggestion" || key === "forced") && item !== null && item !== undefined);
|
|
53180
53393
|
if (!isObject3(payload) || Array.isArray(payload))
|
|
53181
53394
|
return payload;
|
|
@@ -53290,27 +53503,25 @@ function parseDispatchFrame(rawPayload, wholeBody) {
|
|
|
53290
53503
|
try {
|
|
53291
53504
|
value = parseFrameJSON(rawPayload);
|
|
53292
53505
|
} catch {
|
|
53293
|
-
return {
|
|
53506
|
+
return {};
|
|
53294
53507
|
}
|
|
53295
|
-
|
|
53296
|
-
|
|
53297
|
-
|
|
53298
|
-
const
|
|
53508
|
+
const reading = readDispatchPayload(value);
|
|
53509
|
+
switch (reading.kind) {
|
|
53510
|
+
case "event": {
|
|
53511
|
+
const { notify, quiet } = reading.wireEvent;
|
|
53299
53512
|
return {
|
|
53300
|
-
event: withWholeBody(
|
|
53301
|
-
notify
|
|
53302
|
-
quiet
|
|
53303
|
-
delivery:
|
|
53513
|
+
event: withWholeBody(reading.event, wholeBody),
|
|
53514
|
+
notify,
|
|
53515
|
+
quiet,
|
|
53516
|
+
delivery: reading.delivery
|
|
53304
53517
|
};
|
|
53305
53518
|
}
|
|
53306
|
-
|
|
53307
|
-
|
|
53308
|
-
const delivery = recoverable.data.delivery;
|
|
53519
|
+
case "recovered": {
|
|
53520
|
+
const { delivery, event } = reading.failure;
|
|
53309
53521
|
const commentDelivery = isCommentTargetedDelivery(delivery);
|
|
53310
53522
|
const resource = commentDelivery ? "comment" : "message";
|
|
53311
|
-
const id = commentDelivery ? delivery.comment_id :
|
|
53523
|
+
const id = commentDelivery ? delivery.comment_id : event.payload.id;
|
|
53312
53524
|
return {
|
|
53313
|
-
raw: value,
|
|
53314
53525
|
rejectedDelivery: {
|
|
53315
53526
|
resource,
|
|
53316
53527
|
id,
|
|
@@ -53318,24 +53529,15 @@ function parseDispatchFrame(rawPayload, wholeBody) {
|
|
|
53318
53529
|
mode: delivery.mode,
|
|
53319
53530
|
replyPath: dispatchReplyPath(resource, id),
|
|
53320
53531
|
replyFields: commentDelivery ? { target: delivery.target } : {},
|
|
53321
|
-
issueKey:
|
|
53322
|
-
body:
|
|
53532
|
+
issueKey: event.issue_key,
|
|
53533
|
+
body: event.payload.body ?? ""
|
|
53323
53534
|
},
|
|
53324
53535
|
malformedDelivery: true
|
|
53325
53536
|
};
|
|
53326
53537
|
}
|
|
53327
|
-
|
|
53538
|
+
case "raw":
|
|
53539
|
+
return reading.targeted ? { malformedDelivery: true } : {};
|
|
53328
53540
|
}
|
|
53329
|
-
const parsed = DispatchEventSchema.safeParse(value);
|
|
53330
|
-
if (!parsed.success)
|
|
53331
|
-
return { raw: value };
|
|
53332
|
-
const wireEvent = value;
|
|
53333
|
-
return {
|
|
53334
|
-
event: withWholeBody(parsed.data, wholeBody),
|
|
53335
|
-
notify: wireEvent.notify,
|
|
53336
|
-
quiet: wireEvent.quiet,
|
|
53337
|
-
delivery: undefined
|
|
53338
|
-
};
|
|
53339
53541
|
}
|
|
53340
53542
|
var INBOUND_CARD_MAX_BYTES = 1 << 20;
|
|
53341
53543
|
function encodeWithin(value, maxBytes) {
|
|
@@ -53350,6 +53552,28 @@ function encodeWithin(value, maxBytes) {
|
|
|
53350
53552
|
return lines.join(`
|
|
53351
53553
|
`);
|
|
53352
53554
|
}
|
|
53555
|
+
function headerActor(actor) {
|
|
53556
|
+
const { kind, id, act, service } = actor;
|
|
53557
|
+
return {
|
|
53558
|
+
kind,
|
|
53559
|
+
...id === undefined ? {} : { id },
|
|
53560
|
+
...act === undefined ? {} : { act: ActorActSchema.safeParse(act).data ?? "not shown" },
|
|
53561
|
+
...kind !== "session" || service === undefined ? {} : { service: typeof service === "string" ? service : "not shown" }
|
|
53562
|
+
};
|
|
53563
|
+
}
|
|
53564
|
+
function dispatchCardAsText(rendered, event, reason, bound) {
|
|
53565
|
+
let text;
|
|
53566
|
+
try {
|
|
53567
|
+
text = JSON.stringify(event);
|
|
53568
|
+
} catch {}
|
|
53569
|
+
const asText = text === undefined ? undefined : encodeWithin({ envoy: { ...rendered, dispatch: text } }, bound);
|
|
53570
|
+
if (asText !== undefined)
|
|
53571
|
+
return asText;
|
|
53572
|
+
const notShown = `not shown: ${reason}`;
|
|
53573
|
+
const owner = event.owner === undefined ? {} : { owner: event.owner };
|
|
53574
|
+
const header = { type: event.type, actor: headerActor(event.actor), payload: notShown };
|
|
53575
|
+
return encodeWithin({ envoy: { ...rendered, dispatch: { ...owner, ...header } } }, bound) ?? encodeWithin({ envoy: { dispatch: { ...owner, ...header } } }, bound) ?? encodeWithin({ envoy: { dispatch: header } }, bound) ?? encode5({ envoy: { dispatch: { payload: notShown } } });
|
|
53576
|
+
}
|
|
53353
53577
|
function inboundTimestamp(milliseconds) {
|
|
53354
53578
|
if (milliseconds === undefined)
|
|
53355
53579
|
return "unknown";
|
|
@@ -53457,13 +53681,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
53457
53681
|
dispatchReply = dispatchCommentReplyWith(frame.event, topic, commentPayload);
|
|
53458
53682
|
if (frame.event.type === "message.created") {
|
|
53459
53683
|
const message = DispatchTargetedMessagePayloadSchema.safeParse(frame.event.payload);
|
|
53460
|
-
const requested =
|
|
53461
|
-
if (message.success && requested
|
|
53684
|
+
const requested = frame.delivery;
|
|
53685
|
+
if (message.success && requested !== undefined && !isCommentTargetedDelivery(requested)) {
|
|
53462
53686
|
delivery = {
|
|
53463
53687
|
resource: "message",
|
|
53464
53688
|
id: message.data.id,
|
|
53465
|
-
attempt: requested.
|
|
53466
|
-
mode: requested.
|
|
53689
|
+
attempt: requested.attempt,
|
|
53690
|
+
mode: requested.mode,
|
|
53467
53691
|
replyPath: dispatchReplyPath("message", message.data.id),
|
|
53468
53692
|
replyFields: {},
|
|
53469
53693
|
issueKey: frame.event.issue_key,
|
|
@@ -53481,15 +53705,15 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
53481
53705
|
}
|
|
53482
53706
|
} else if (frame.event.type === "comment.created") {
|
|
53483
53707
|
const comment = DispatchTargetedCommentPayloadSchema.safeParse(frame.event.payload);
|
|
53484
|
-
const requested =
|
|
53485
|
-
if (comment.success && requested
|
|
53708
|
+
const requested = frame.delivery;
|
|
53709
|
+
if (comment.success && requested !== undefined && isCommentTargetedDelivery(requested)) {
|
|
53486
53710
|
delivery = {
|
|
53487
53711
|
resource: "comment",
|
|
53488
|
-
id: requested.
|
|
53489
|
-
attempt: requested.
|
|
53490
|
-
mode: requested.
|
|
53491
|
-
replyPath: dispatchReplyPath("comment", requested.
|
|
53492
|
-
replyFields: { target: requested.
|
|
53712
|
+
id: requested.comment_id,
|
|
53713
|
+
attempt: requested.attempt,
|
|
53714
|
+
mode: requested.mode,
|
|
53715
|
+
replyPath: dispatchReplyPath("comment", requested.comment_id),
|
|
53716
|
+
replyFields: { target: requested.target },
|
|
53493
53717
|
issueKey: frame.event.issue_key,
|
|
53494
53718
|
body: comment.data.body,
|
|
53495
53719
|
...comment.data.body_truncated === true ? { bodyTruncated: true } : {}
|
|
@@ -53508,7 +53732,9 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
53508
53732
|
let actor = frame.event.actor;
|
|
53509
53733
|
if ("origin" in frame.event.actor) {
|
|
53510
53734
|
const { origin, ...rest } = frame.event.actor;
|
|
53511
|
-
|
|
53735
|
+
let title;
|
|
53736
|
+
if (isObject3(origin))
|
|
53737
|
+
({ session_title: title } = origin);
|
|
53512
53738
|
actor = typeof title === "string" && title !== "" ? { ...rest, origin: { session_title: title } } : rest;
|
|
53513
53739
|
}
|
|
53514
53740
|
const owner = dispatchOwner(frame.event, topic);
|
|
@@ -53530,7 +53756,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
53530
53756
|
trailer = humanEditDiffBlock(edit.data.diff, edit.data.diff_truncated);
|
|
53531
53757
|
}
|
|
53532
53758
|
} else {
|
|
53533
|
-
|
|
53759
|
+
dispatchIssue = "payload";
|
|
53534
53760
|
rejectedDelivery = frame.rejectedDelivery;
|
|
53535
53761
|
malformedDelivery = frame.malformedDelivery === true;
|
|
53536
53762
|
}
|
|
@@ -53585,7 +53811,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
53585
53811
|
args: { topic: `notifications.role.${role}`, message: "..." }
|
|
53586
53812
|
}
|
|
53587
53813
|
},
|
|
53588
|
-
...dispatchRendered ? { dispatch: dispatchEvent } : {
|
|
53814
|
+
...dispatchRendered ? dispatchEvent === undefined ? {} : { dispatch: dispatchEvent } : {
|
|
53589
53815
|
...summaryIsHead ? {} : { summary: payloadSummary },
|
|
53590
53816
|
...message === undefined ? {} : { message }
|
|
53591
53817
|
},
|
|
@@ -53595,7 +53821,6 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
53595
53821
|
},
|
|
53596
53822
|
...unrecognised === undefined ? {} : { unrecognised }
|
|
53597
53823
|
};
|
|
53598
|
-
const payloadKey = dispatchRendered ? "dispatch" : "message";
|
|
53599
53824
|
const payloadValue = dispatchRendered ? dispatchEvent : message;
|
|
53600
53825
|
const cardBound = Math.max(INBOUND_CARD_MAX_BYTES, 2 * (Buffer.byteLength(raw) + (wholeBody === undefined ? 0 : Buffer.byteLength(escapeString(wholeBody)))));
|
|
53601
53826
|
let card;
|
|
@@ -53609,7 +53834,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
53609
53834
|
}
|
|
53610
53835
|
if (card === undefined) {
|
|
53611
53836
|
payloadShownAsText ??= `its layout is larger than the ${cardBound} bytes a card holds`;
|
|
53612
|
-
card = encode5({ envoy: { ...rendered,
|
|
53837
|
+
card = dispatchEvent === undefined ? encode5({ envoy: { ...rendered, message: envelope.payload } }) : dispatchCardAsText(rendered, dispatchEvent, payloadShownAsText, cardBound);
|
|
53613
53838
|
}
|
|
53614
53839
|
return {
|
|
53615
53840
|
skip: false,
|
|
@@ -54703,7 +54928,8 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
54703
54928
|
if (tool === "dispatch_read" && typeof args.message === "string") {
|
|
54704
54929
|
return { args, ref, owner: null };
|
|
54705
54930
|
}
|
|
54706
|
-
|
|
54931
|
+
const { retract } = args;
|
|
54932
|
+
if (tool === "dispatch_result" && typeof retract === "string") {
|
|
54707
54933
|
return { args, ref, owner: null };
|
|
54708
54934
|
}
|
|
54709
54935
|
const legionIssue = env.LEGION_ISSUE;
|
|
@@ -54779,7 +55005,7 @@ function refusalWithCode(error, ...clauses) {
|
|
|
54779
55005
|
const told = joined !== "" && /[.!?]$/.test(error.message) ? `${error.message} ${suffix.charAt(0).toUpperCase()}${suffix.slice(1)}` : `${error.message}${joined}`;
|
|
54780
55006
|
return new DispatchServiceError(error.code, error.status, `${error.code}: ${told}`, error);
|
|
54781
55007
|
}
|
|
54782
|
-
function parentStatusConflictLines(error, tool, args
|
|
55008
|
+
function parentStatusConflictLines(error, tool, args) {
|
|
54783
55009
|
if (!dispatchAnswered(error, 409) || error.code !== "PARENT_STATUS_CONFLICT")
|
|
54784
55010
|
return;
|
|
54785
55011
|
const issues = error.issues ?? [];
|
|
@@ -54790,28 +55016,15 @@ function parentStatusConflictLines(error, tool, args, legionIssue) {
|
|
|
54790
55016
|
return [
|
|
54791
55017
|
messageFor(error),
|
|
54792
55018
|
...issues.map((issue) => `${issue.key} [${issue.status}] ${issue.title}`),
|
|
54793
|
-
...nextSteps(tool, args, parents, children
|
|
55019
|
+
...nextSteps(tool, args, parents, children)
|
|
54794
55020
|
];
|
|
54795
55021
|
}
|
|
54796
55022
|
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.";
|
|
54797
55023
|
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.";
|
|
54798
|
-
function otherProjectSentence(named, keys) {
|
|
54799
|
-
const project = named === undefined ? undefined : issueProject(named);
|
|
54800
|
-
if (project === undefined)
|
|
54801
|
-
return "";
|
|
54802
|
-
const others = keys.filter((key) => {
|
|
54803
|
-
const other = issueProject(key);
|
|
54804
|
-
return other !== undefined && other !== project;
|
|
54805
|
-
});
|
|
54806
|
-
if (others.length === 0)
|
|
54807
|
-
return "";
|
|
54808
|
-
const one = others.length === 1;
|
|
54809
|
-
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.`;
|
|
54810
|
-
}
|
|
54811
55024
|
function includeParentCall(key) {
|
|
54812
55025
|
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`;
|
|
54813
55026
|
}
|
|
54814
|
-
function nextSteps(tool, args, parents, children
|
|
55027
|
+
function nextSteps(tool, args, parents, children) {
|
|
54815
55028
|
if (tool === "dispatch_issue") {
|
|
54816
55029
|
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.`);
|
|
54817
55030
|
}
|
|
@@ -54819,9 +55032,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
|
|
|
54819
55032
|
const written = issueUpdate ? args : {};
|
|
54820
55033
|
const fields = Object.keys(written).filter((field) => field !== "issue" && written[field] !== undefined);
|
|
54821
55034
|
const issue = optionalString(written, "issue");
|
|
54822
|
-
const named = issueUpdate ? issue ?? legionIssue : undefined;
|
|
54823
55035
|
const childHolds = children.length > 0;
|
|
54824
|
-
const childScope = otherProjectSentence(named, children);
|
|
54825
55036
|
const status = optionalString(written, "status");
|
|
54826
55037
|
const parent = optionalString(written, "parent");
|
|
54827
55038
|
const alone = `--status${status === "done" ? " and --reason" : ""} alone`;
|
|
@@ -54834,7 +55045,7 @@ function nextSteps(tool, args, parents, children, legionIssue) {
|
|
|
54834
55045
|
const afterStatus = childHolds ? ", after the status change," : "";
|
|
54835
55046
|
return [
|
|
54836
55047
|
...childHolds ? [
|
|
54837
|
-
`${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}
|
|
55048
|
+
`${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}.`
|
|
54838
55049
|
] : [],
|
|
54839
55050
|
...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}.`)
|
|
54840
55051
|
];
|
|
@@ -54842,8 +55053,8 @@ function nextSteps(tool, args, parents, children, legionIssue) {
|
|
|
54842
55053
|
const others = ISSUE_UPDATE_PATCH_FIELDS.some((field) => written[field] !== undefined);
|
|
54843
55054
|
const apart = (subject) => others ? ` ${subject} with ${alone}, so send the call's other changes in a call of their own.` : "";
|
|
54844
55055
|
return [
|
|
54845
|
-
...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}
|
|
54846
|
-
...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}
|
|
55056
|
+
...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}`] : [],
|
|
55057
|
+
...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}`] : []
|
|
54847
55058
|
];
|
|
54848
55059
|
}
|
|
54849
55060
|
function dispatchAnswered(error, status) {
|
|
@@ -56662,7 +56873,8 @@ async function relatedCommand(context) {
|
|
|
56662
56873
|
};
|
|
56663
56874
|
}
|
|
56664
56875
|
function printsJson(tool, args) {
|
|
56665
|
-
|
|
56876
|
+
const { json } = args;
|
|
56877
|
+
return tool === "dispatch_issues" && json === true;
|
|
56666
56878
|
}
|
|
56667
56879
|
async function issuesCommand(context) {
|
|
56668
56880
|
const { args, client, input } = context;
|
|
@@ -56728,7 +56940,8 @@ async function issuesCommand(context) {
|
|
|
56728
56940
|
};
|
|
56729
56941
|
}
|
|
56730
56942
|
function dryRunAsksDispatch(tool, args) {
|
|
56731
|
-
|
|
56943
|
+
const { retract } = args;
|
|
56944
|
+
return tool === "dispatch_result" && retract === undefined;
|
|
56732
56945
|
}
|
|
56733
56946
|
async function resultCommand(context) {
|
|
56734
56947
|
const { args, client, actor } = context;
|
|
@@ -56896,12 +57109,10 @@ var WRITE_ROUTES = [
|
|
|
56896
57109
|
commands: ["architecture-sync"]
|
|
56897
57110
|
}
|
|
56898
57111
|
];
|
|
57112
|
+
var WRITE_ROUTE_SEGMENTS = WRITE_ROUTES.map((row) => ({ row, segments: row.pattern.split("/") }));
|
|
56899
57113
|
function writeRoute(method, path) {
|
|
56900
57114
|
const segments = path.split("/");
|
|
56901
|
-
return
|
|
56902
|
-
const pattern = row.pattern.split("/");
|
|
56903
|
-
return row.method === method && pattern.length === segments.length && pattern.every((part, at) => part.startsWith("{") ? segments[at] !== "" : part === segments[at]);
|
|
56904
|
-
});
|
|
57115
|
+
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;
|
|
56905
57116
|
}
|
|
56906
57117
|
|
|
56907
57118
|
class ApiGateRefusal extends Error {
|
|
@@ -59765,9 +59976,9 @@ async function whoamiCommand(context) {
|
|
|
59765
59976
|
} else {
|
|
59766
59977
|
acting = `Session ${session} runs under the shared token: ${unowned}`;
|
|
59767
59978
|
}
|
|
59768
|
-
const
|
|
59979
|
+
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." : "";
|
|
59769
59980
|
return {
|
|
59770
|
-
text: acting + elsewhere +
|
|
59981
|
+
text: acting + elsewhere + projectSentence,
|
|
59771
59982
|
details: { session, owner, service, project, project_scope: projectScope }
|
|
59772
59983
|
};
|
|
59773
59984
|
}
|
|
@@ -66426,7 +66637,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
66426
66637
|
|
|
66427
66638
|
// package.json
|
|
66428
66639
|
var name2 = "@sjawhar/claude-envoy";
|
|
66429
|
-
var version2 = "6.
|
|
66640
|
+
var version2 = "6.6.0";
|
|
66430
66641
|
var package_default = {
|
|
66431
66642
|
name: name2,
|
|
66432
66643
|
version: version2,
|
|
@@ -67826,14 +68037,14 @@ import { setTimeout as delay2 } from "timers/promises";
|
|
|
67826
68037
|
|
|
67827
68038
|
// ../contracts/src/daemon-contract.ts
|
|
67828
68039
|
import { existsSync, readdirSync as readdirSync3, readFileSync as readFileSync8 } from "fs";
|
|
67829
|
-
import { dirname as dirname6, join as join13, resolve as
|
|
68040
|
+
import { dirname as dirname6, join as join13, resolve as resolve4 } from "path";
|
|
67830
68041
|
var ENTRY_FIXTURE_NAME = /^[0-9]{14}_.+\.json$/;
|
|
67831
68042
|
var DAEMON_API_FIXTURES = join13("packages", "contracts", "fixtures", "daemon-api");
|
|
67832
68043
|
function daemonContract(manifest, from) {
|
|
67833
68044
|
const declared = manifest.legion?.daemonApiVersion;
|
|
67834
68045
|
if (declared !== undefined)
|
|
67835
68046
|
return declared;
|
|
67836
|
-
for (let dir =
|
|
68047
|
+
for (let dir = resolve4(from);; dir = dirname6(dir)) {
|
|
67837
68048
|
const fixtures = join13(dir, DAEMON_API_FIXTURES);
|
|
67838
68049
|
const releasedFile = join13(fixtures, "released-contracts.json");
|
|
67839
68050
|
if (existsSync(releasedFile)) {
|
|
@@ -74894,7 +75105,7 @@ function callingThread(meta) {
|
|
|
74894
75105
|
}
|
|
74895
75106
|
function dispatchToolDefinition() {
|
|
74896
75107
|
return {
|
|
74897
|
-
description: '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
|
|
75108
|
+
description: '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.',
|
|
74898
75109
|
inputSchema: {
|
|
74899
75110
|
properties: {
|
|
74900
75111
|
args: {
|
|
@@ -74986,7 +75197,7 @@ async function runCodexEnvoyServer() {
|
|
|
74986
75197
|
const configFile = sessionConfigFile("codex", process.env);
|
|
74987
75198
|
const warn = (text) => void process.stderr.write(`envoy-channel: ${text}
|
|
74988
75199
|
`);
|
|
74989
|
-
const bundlePath =
|
|
75200
|
+
const bundlePath = resolve5(pluginRoot, process.argv[1] ?? "");
|
|
74990
75201
|
let record;
|
|
74991
75202
|
let runtime;
|
|
74992
75203
|
let notReady = "this session's Envoy side starts at its first prompt";
|