@sjawhar/claude-envoy 4.15.4 → 4.16.1
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/bin/envoy-send.ts +1 -1
- package/dist/codex-hook.js +13 -13
- package/dist/dispatch.js +13 -13
- package/dist/envoy-channel.js +1894 -1622
- package/dist/session-hook.js +13 -13
- package/legion/skills/legion-worker/references/merge-gate.md +1 -0
- package/legion/skills/legion-worker/references/pr-body.md +5 -3
- package/package.json +3 -3
- package/scripts/build-inputs.txt +1 -1
- package/src/envoy-channel-server.ts +3 -3
- package/src/legion-claim.ts +11 -1
- package/src/legion-phase-hook.ts +6 -5
- package/src/legion-tool.ts +11 -1
package/dist/session-hook.js
CHANGED
|
@@ -18538,7 +18538,7 @@ function askAnswerText(answer) {
|
|
|
18538
18538
|
return `${selected} - ${text}`;
|
|
18539
18539
|
}
|
|
18540
18540
|
|
|
18541
|
-
// ../
|
|
18541
|
+
// ../cipher-client/src/wire.ts
|
|
18542
18542
|
var TOKEN_PATH = "/v1/oauth/token";
|
|
18543
18543
|
var GRANT_TYPE_TOKEN_EXCHANGE = "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
18544
18544
|
var EXCHANGE_CLIENT_ID = "dispatch-token-exchange";
|
|
@@ -18554,7 +18554,7 @@ var TOKEN_TYPE_DPOP = "DPoP";
|
|
|
18554
18554
|
var POD_SESSION_NOT_REGISTERED = "pod_session_not_registered";
|
|
18555
18555
|
var SESSION_NAME_NOT_THIS_REGISTRARS = "session_name_not_this_registrars";
|
|
18556
18556
|
|
|
18557
|
-
// ../
|
|
18557
|
+
// ../cipher-client/src/refusal-text.ts
|
|
18558
18558
|
var KNOWN_BROKER_REFUSALS = new Set([
|
|
18559
18559
|
"no entry lists the account this token names",
|
|
18560
18560
|
"too many token requests; try again later",
|
|
@@ -18725,7 +18725,7 @@ function shownOAuthCode(code) {
|
|
|
18725
18725
|
return KNOWN_OAUTH_ERROR_CODES.has(code) ? code : `unrecognised error code (${code.length} chars)`;
|
|
18726
18726
|
}
|
|
18727
18727
|
|
|
18728
|
-
// ../
|
|
18728
|
+
// ../cipher-client/src/signins.ts
|
|
18729
18729
|
import { readdir, readFile } from "fs/promises";
|
|
18730
18730
|
import { join } from "path";
|
|
18731
18731
|
|
|
@@ -18737,7 +18737,7 @@ function withoutTrailingSlashes(url) {
|
|
|
18737
18737
|
return url.slice(0, end);
|
|
18738
18738
|
}
|
|
18739
18739
|
|
|
18740
|
-
// ../
|
|
18740
|
+
// ../cipher-client/src/error-text.ts
|
|
18741
18741
|
function messageOf(error) {
|
|
18742
18742
|
return error instanceof Error ? error.message : String(error);
|
|
18743
18743
|
}
|
|
@@ -18747,7 +18747,7 @@ function readErrorCode(error) {
|
|
|
18747
18747
|
return typeof code === "string" && READ_ERROR_CODE.test(code) ? code : "an error";
|
|
18748
18748
|
}
|
|
18749
18749
|
|
|
18750
|
-
// ../
|
|
18750
|
+
// ../cipher-client/src/signins.ts
|
|
18751
18751
|
var SIGNIN_DIR_VAR = "AGENT_SECRETS_SIGNIN_DIR";
|
|
18752
18752
|
var PERSON_VAR = "AGENT_SECRETS_PERSON";
|
|
18753
18753
|
var PERSON_TRADE_VAR = "PERSON_SIGNIN_TRADE";
|
|
@@ -18877,7 +18877,7 @@ async function signInFlow(env) {
|
|
|
18877
18877
|
};
|
|
18878
18878
|
}
|
|
18879
18879
|
|
|
18880
|
-
// ../
|
|
18880
|
+
// ../cipher-client/src/token-errors.ts
|
|
18881
18881
|
var TOO_MANY_REQUESTS = 429;
|
|
18882
18882
|
var INVALID_DPOP_PROOF = "invalid_dpop_proof";
|
|
18883
18883
|
var USE_DPOP_NONCE = "use_dpop_nonce";
|
|
@@ -26965,7 +26965,7 @@ function readDispatchFirstContext(skillFile) {
|
|
|
26965
26965
|
`);
|
|
26966
26966
|
}
|
|
26967
26967
|
|
|
26968
|
-
// ../
|
|
26968
|
+
// ../cipher-client/src/dpop.ts
|
|
26969
26969
|
import {
|
|
26970
26970
|
createHash,
|
|
26971
26971
|
createPrivateKey,
|
|
@@ -27039,7 +27039,7 @@ async function importDpopKey(pkcs8Pem, name) {
|
|
|
27039
27039
|
return dpopKey(privateKey, publicJwkOf(privateKey, name));
|
|
27040
27040
|
}
|
|
27041
27041
|
|
|
27042
|
-
// ../
|
|
27042
|
+
// ../cipher-client/src/metadata-identity.ts
|
|
27043
27043
|
import { Agent, request } from "http";
|
|
27044
27044
|
var METADATA_HOST_VAR = "GCE_METADATA_HOST";
|
|
27045
27045
|
var DEFAULT_METADATA_HOST = "metadata.google.internal";
|
|
@@ -28338,7 +28338,7 @@ async function genericGrantRequest(config, grantType, parameters, options) {
|
|
|
28338
28338
|
return result;
|
|
28339
28339
|
}
|
|
28340
28340
|
|
|
28341
|
-
// ../
|
|
28341
|
+
// ../cipher-client/src/token-client.ts
|
|
28342
28342
|
var DEFAULT_RENEW_BEFORE_MS = 5 * 60000;
|
|
28343
28343
|
var BROKER_URL_SETTING = "the broker URL";
|
|
28344
28344
|
var RETRY_FIRST_WAIT_MS = 15000;
|
|
@@ -28752,7 +28752,7 @@ function heldUntil(token) {
|
|
|
28752
28752
|
}
|
|
28753
28753
|
}
|
|
28754
28754
|
|
|
28755
|
-
// ../
|
|
28755
|
+
// ../cipher-client/src/person-identity.ts
|
|
28756
28756
|
var ISSUER_TIMEOUT_SECONDS = 30;
|
|
28757
28757
|
var INVALID_GRANT2 = "invalid_grant";
|
|
28758
28758
|
function issuerSaid(error) {
|
|
@@ -28830,7 +28830,7 @@ function personIdentity(record, flow, options = {}) {
|
|
|
28830
28830
|
};
|
|
28831
28831
|
}
|
|
28832
28832
|
|
|
28833
|
-
// ../
|
|
28833
|
+
// ../cipher-client/src/pool-identity.ts
|
|
28834
28834
|
var DEFAULT_SECURITY_TOKEN_SERVICE_URL = "https://sts.googleapis.com/v1/token";
|
|
28835
28835
|
var DEFAULT_IAM_CREDENTIALS_URL = "https://iamcredentials.googleapis.com";
|
|
28836
28836
|
var REQUESTED_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token";
|
|
@@ -28964,7 +28964,7 @@ function poolIdentity(options) {
|
|
|
28964
28964
|
};
|
|
28965
28965
|
}
|
|
28966
28966
|
|
|
28967
|
-
// ../
|
|
28967
|
+
// ../cipher-client/src/projected-token.ts
|
|
28968
28968
|
import { readFile as readFile2 } from "fs/promises";
|
|
28969
28969
|
function projectedToken(path, variable) {
|
|
28970
28970
|
const named = `the projected service-account token ${variable} names`;
|
|
@@ -28988,7 +28988,7 @@ function projectedToken(path, variable) {
|
|
|
28988
28988
|
};
|
|
28989
28989
|
}
|
|
28990
28990
|
|
|
28991
|
-
// ../
|
|
28991
|
+
// ../cipher-client/src/environment.ts
|
|
28992
28992
|
var BROKER_URL_VAR = "AGENT_SECRETS_URL";
|
|
28993
28993
|
var IDENTITY_VAR = "AGENT_SECRETS_MACHINE_IDENTITY";
|
|
28994
28994
|
var MACHINE_TOKEN_FILE_VAR = "AGENT_SECRETS_MACHINE_TOKEN_FILE";
|
|
@@ -7,6 +7,7 @@ Read it when you review or approve, or work a look of a closed issue's productio
|
|
|
7
7
|
1. Read CI on GitHub and the issue's results with `dispatch results --issue <issue>`, never from a handoff.
|
|
8
8
|
2. When the diff the round reads touches runtime code (the whole change, or the difference from the commit your task names), run `task(agent="thermonuclear-deep-review")` and `task(agent="thermonuclear-code-quality")` once at the head the round reviews, and `wait` for each result: each runs as a job of its own. Each agent reviews only the diff its task supplies, so name in each task the commit, the head and `git diff <sha> <head>` as the diff, or the whole change. The last two sentences of your task, `Last reviewed commit: <sha>.` and `Review entry: <n>.`, are the daemon's; your role prompt says how to read them.
|
|
9
9
|
3. A result that carries no report, or that names another place for it, is a failed run, not a verdict: run that agent again, or read its transcript. Reading the agent's diff yourself and recording that in its place is the same as answering the rubric from a bare verdict. When you can do neither, that half of the round has no review: tell the architect, do not approve, and wait with a `WAITING` line naming what you wait on until it answers.
|
|
10
|
+
4. A `CHANGES` from either half is answered in the review: its findings are carried into a `REQUEST_CHANGES`, or each finding is recorded with why it does not stand. Your `APPROVE` needs both halves run at the reviewed head, or both `Thermo` rows reading `not run` because the diff the round reads touches no runtime code (the whole change, or the difference from the last reviewed commit to the head).
|
|
10
11
|
|
|
11
12
|
### What the base requires
|
|
12
13
|
|
|
@@ -27,8 +27,10 @@ The implementer writes the body from this template when the pull request opens;
|
|
|
27
27
|
- Thread <node id>: accepted by the reviewer — <its reason, one line>; resolved at <head-sha>.
|
|
28
28
|
- Thread <node id>: still open — <what remains>; unresolved at <head-sha>.
|
|
29
29
|
|
|
30
|
-
**Thermo:** `simplify-settled-diff` once at <head-sha
|
|
31
|
-
|
|
30
|
+
**Thermo:** `simplify-settled-diff` once at <head-sha>, a docs-only PR included: <0 applied | applied → new head <sha>>; defects reported: <none | <n>, fixed in <sha>>; thermonuclear pair at the reviewed head <sha> over <the whole change | <last-reviewed-sha>..<sha>>, one row per half:
|
|
31
|
+
- `thermonuclear-deep-review`: <APPROVE | CHANGES>, <n> findings stand
|
|
32
|
+
- `thermonuclear-code-quality`: <APPROVE | CHANGES>, <n> findings stand
|
|
33
|
+
Where the diff the round reads touches no runtime code, each row reads `not run (<the whole change | <last-reviewed-sha>..<sha>> touches no runtime code)`, and the two rows of the last round the pair ran in stay beside them.
|
|
32
34
|
|
|
33
35
|
**Checks:** one line per `check` block of the issue's Verification document, in the document's
|
|
34
36
|
order. Each is the line `dispatch result` printed when the result was recorded, or the
|
|
@@ -63,7 +65,7 @@ The implementer keeps `Outcome`, `Why`, `Change`, `Proven by` and `Size` true af
|
|
|
63
65
|
- The tester tries to break the changed surface (wrong and boundary inputs, the second and the concurrent run, the party it must refuse) and writes the red test for a way no test would catch. Lint, types and the unit and integration suites are CI's: read them on GitHub at the head, rerun no lane as evidence, and wait for none.
|
|
64
66
|
- After a forward merge, the tester reruns each check the merge can reach (`skill://legion-worker/references/conflicts-and-rewrites.md`) and records each other check with no `ci_check` at the new head unrun, its `--observed` naming the earlier pass and why the merge misses it. A class search that finds an instance, or a parent's last round, takes a full test round.
|
|
65
67
|
- The implementer runs `skill://simplify-settled-diff` once per pull request, in its first implementing round, after its own results and before it completes, whatever the diff touches, a docs-only diff included. Applied: rerun the fast local checks and the issue's checks the simplify diff touches, and record them at the applied head. A defect the pass reports is fixed outside the pass and the results recorded again, never dropped as out of scope; the `Thermo` line names the count and the fixing commit.
|
|
66
|
-
- The reviewer's pair runs at the head each round reviews, over the diff that round reads, when that diff touches runtime code; the `Thermo` line records the range it read, and earlier rounds'
|
|
68
|
+
- The reviewer's pair runs at the head each round reviews, over the diff that round reads, when that diff touches runtime code; the `Thermo` line records the range it read and a row per half, and earlier rounds' rows stay beside them.
|
|
67
69
|
|
|
68
70
|
## Never waiting on CI
|
|
69
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjawhar/claude-envoy",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Claude Code plugin for Legion's Envoy bus",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"AGENTS.md"
|
|
20
20
|
],
|
|
21
21
|
"legion": {
|
|
22
|
-
"daemonApiVersion":
|
|
22
|
+
"daemonApiVersion": 193
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@biomejs/biome": "^2.3.14",
|
|
39
|
-
"@legion/
|
|
39
|
+
"@legion/cipher-client": "0.1.0",
|
|
40
40
|
"@legion/contracts": "0.10.0",
|
|
41
41
|
"@legion/envoy-client": "0.1.0",
|
|
42
42
|
"@legion/pi-shared": "0.1.0",
|
package/scripts/build-inputs.txt
CHANGED
|
@@ -83,7 +83,6 @@ import {
|
|
|
83
83
|
roleHeldBy,
|
|
84
84
|
type SubscribeResult,
|
|
85
85
|
} from "@legion/envoy-client/transport"
|
|
86
|
-
import { createLegionDaemonClient } from "@legion/pi-shared/daemon-client"
|
|
87
86
|
import { findPushedBranchHead, paneHandoffReport } from "@legion/pi-shared/handoff-record"
|
|
88
87
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js"
|
|
89
88
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
@@ -120,6 +119,7 @@ import {
|
|
|
120
119
|
type LegionClaim,
|
|
121
120
|
legionPane,
|
|
122
121
|
logLegion,
|
|
122
|
+
paneDaemonClient,
|
|
123
123
|
startLegionClaim,
|
|
124
124
|
stopPane,
|
|
125
125
|
} from "./legion-claim"
|
|
@@ -2528,7 +2528,7 @@ export async function runEnvoyChannelServer(): Promise<void> {
|
|
|
2528
2528
|
// NATS_AUTH=broker waits for the session's token for as long as the server lives.
|
|
2529
2529
|
let starting = "it reads its settings"
|
|
2530
2530
|
let claim: LegionClaim | undefined
|
|
2531
|
-
const daemon = pane === undefined ? undefined :
|
|
2531
|
+
const daemon = pane === undefined ? undefined : paneDaemonClient(pane.daemonUrl)
|
|
2532
2532
|
// INFRA-220: the phase reminder's Claude Code host (`./legion-phase-hook`), which Claude Code's
|
|
2533
2533
|
// own hooks drive through the `legion_phase_hook` tool. It is started here, beside the claim it
|
|
2534
2534
|
// gates on, and restores this session's record as it starts, before any hook can be answered.
|
|
@@ -2564,7 +2564,7 @@ export async function runEnvoyChannelServer(): Promise<void> {
|
|
|
2564
2564
|
claim: () => claim?.capability(),
|
|
2565
2565
|
booted: claimBooted.promise,
|
|
2566
2566
|
firstTurnStarted: () => reportFirstTurn?.(),
|
|
2567
|
-
|
|
2567
|
+
readRecord: (issue, signal) => daemon.record(issue, { signal }),
|
|
2568
2568
|
reportActivity: (input) => daemon.activity(input),
|
|
2569
2569
|
inbox: inbox === undefined ? undefined : (text) => inbox.notification({ content: text }),
|
|
2570
2570
|
publish: client.publish,
|
package/src/legion-claim.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { messageFor } from "@legion/envoy-client/errors"
|
|
|
6
6
|
import { readSecretFile } from "@legion/envoy-client/secret-file"
|
|
7
7
|
import type { EnvoyClient } from "@legion/envoy-client/transport"
|
|
8
8
|
import { claimFirstTurnBoundMs } from "@legion/pi-shared/claim-first-turn-bound"
|
|
9
|
-
import type
|
|
9
|
+
import { createLegionDaemonClient, type LegionDaemonClient } from "@legion/pi-shared/daemon-client"
|
|
10
10
|
import { bootLegionClaim, type LegionClaimBoot } from "@legion/pi-shared/legion-claim-core"
|
|
11
11
|
import type { ClaimCapability } from "@legion/pi-shared/legion-phase-ops"
|
|
12
12
|
import { legion } from "../package.json" with { type: "json" }
|
|
@@ -61,6 +61,16 @@ export function legionPane(env: NodeJS.ProcessEnv): LegionPane | undefined {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* The pane's client for the daemon. It states this build's own `legion.daemonApiVersion` on
|
|
66
|
+
* every request, read from the manifest of the module this process loaded, as the claim's
|
|
67
|
+
* registration below reads it: the daemon serves each answer in the shape the contract the
|
|
68
|
+
* caller states describes, so a pane an older or newer daemon answers still reads its answers.
|
|
69
|
+
*/
|
|
70
|
+
export function paneDaemonClient(daemonUrl: string): LegionDaemonClient {
|
|
71
|
+
return createLegionDaemonClient(daemonUrl, { pluginContract: legion.daemonApiVersion })
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
/** Writes one line to the pane's log, the server's stderr. */
|
|
65
75
|
export function logLegion(line: string): void {
|
|
66
76
|
process.stderr.write(`[legion] ${line}\n`)
|
package/src/legion-phase-hook.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto"
|
|
2
2
|
import { readFileSync, renameSync, rmSync, writeFileSync } from "node:fs"
|
|
3
3
|
import { dirname, join } from "node:path"
|
|
4
|
-
import type {
|
|
4
|
+
import type { LegionIssue } from "@legion/contracts/legion-api"
|
|
5
5
|
import { messageFor } from "@legion/envoy-client/errors"
|
|
6
6
|
import type { ActivityInput } from "@legion/pi-shared/daemon-client"
|
|
7
7
|
import type { ClaimCapability } from "@legion/pi-shared/legion-phase-ops"
|
|
@@ -182,9 +182,10 @@ export interface PhaseHookDeps {
|
|
|
182
182
|
* registered its step — the bridge's seeding `/rename` — signals nothing, and one after the
|
|
183
183
|
* name is taken costs nothing. */
|
|
184
184
|
readonly firstTurnStarted: () => void
|
|
185
|
-
/**
|
|
186
|
-
* check's bound passes (`PhaseReminderDeps.
|
|
187
|
-
|
|
185
|
+
/** One issue's record, for the reminder's record check, aborted with `signal` once the
|
|
186
|
+
* check's bound passes (`PhaseReminderDeps.readRecord`): the record, or `undefined` for an
|
|
187
|
+
* issue the daemon records nothing of. */
|
|
188
|
+
readonly readRecord: (issue: string, signal: AbortSignal) => Promise<LegionIssue | undefined>
|
|
188
189
|
/** Sends this session's activity report to the daemon (`LegionDaemonClient.activity`), so the
|
|
189
190
|
* idle rule can decide whether the pane's pod may be released (INFRA-945). */
|
|
190
191
|
readonly reportActivity: (input: ActivityInput) => Promise<void>
|
|
@@ -410,7 +411,7 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
|
|
|
410
411
|
// count was never recorded is what the count exists to catch.
|
|
411
412
|
saveEntry: saveRecord,
|
|
412
413
|
claim: deps.claim,
|
|
413
|
-
|
|
414
|
+
readRecord: deps.readRecord,
|
|
414
415
|
// The server's own listener client, so the notice reaches the one this session already talks
|
|
415
416
|
// to; Envoy off for the session leaves it undefined, the runner says so once at debug, and
|
|
416
417
|
// the reminder keeps coming without a notice.
|
package/src/legion-tool.ts
CHANGED
|
@@ -9,8 +9,17 @@ import {
|
|
|
9
9
|
PHASE_OP_SENTENCES,
|
|
10
10
|
PHASE_OPS,
|
|
11
11
|
phaseOpParameters,
|
|
12
|
+
pluginBuildOf,
|
|
12
13
|
} from "@legion/pi-shared/legion-phase-ops"
|
|
13
14
|
import { z } from "zod"
|
|
15
|
+
import pkg from "../package.json" with { type: "json" }
|
|
16
|
+
|
|
17
|
+
/** This plugin's own build, which `read_build` answers with: the manifest of the module this
|
|
18
|
+
* process loaded, never a path read anywhere else. In a pod a Claude Code role installs no plugin
|
|
19
|
+
* (the daemon's `NoPluginInstall`) and loads its image's own claude-envoy, so a relaunch keeps
|
|
20
|
+
* this build and only the update round over the pod brings another. It is an Oh My Pi role's
|
|
21
|
+
* relaunch that installs its plugin pair fresh under the role's state home. */
|
|
22
|
+
const BUILD = pluginBuildOf(pkg)
|
|
14
23
|
|
|
15
24
|
/** The tool's name: Claude Code shows it as `mcp__legion__legion`, under the pane's one server. */
|
|
16
25
|
export const LEGION_TOOL_NAME = "legion"
|
|
@@ -23,7 +32,7 @@ export function legionToolDefinition() {
|
|
|
23
32
|
description: legionToolDescription({
|
|
24
33
|
envoyPublish: "mcp__legion__envoy_publish",
|
|
25
34
|
before: PHASE_OP_SENTENCES.readRecord + PHASE_OP_SENTENCES.readReleaseRecords,
|
|
26
|
-
after: PHASE_OP_SENTENCES.requestBackwardMove,
|
|
35
|
+
after: PHASE_OP_SENTENCES.requestBackwardMove + PHASE_OP_SENTENCES.readBuild,
|
|
27
36
|
}),
|
|
28
37
|
inputSchema: z.toJSONSchema(z.object({ op: z.enum(PHASE_OPS), ...phaseOpParameters(z) })),
|
|
29
38
|
}
|
|
@@ -64,6 +73,7 @@ export async function executeLegionTool(
|
|
|
64
73
|
{
|
|
65
74
|
daemon: runtime.daemon,
|
|
66
75
|
claim,
|
|
76
|
+
build: BUILD,
|
|
67
77
|
handoffReport: runtime.handoffReport,
|
|
68
78
|
branchHead: runtime.branchHead,
|
|
69
79
|
...(signal === undefined ? {} : { restart: { signal } }),
|