@sjawhar/claude-envoy 4.14.2 → 4.14.4
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/.omp-plugin/plugin.json
CHANGED
package/AGENTS.md
CHANGED
|
@@ -1,64 +1,41 @@
|
|
|
1
1
|
# Claude Envoy
|
|
2
2
|
|
|
3
|
-
`@sjawhar/claude-envoy` is the Claude Code plugin for Envoy and Dispatch
|
|
4
|
-
One MCP stdio server (`src/envoy-channel-server.ts`) is the session's Envoy ingress and serves the `envoy_*` tools; the mod (`hooks/mod.ts`) writes into a terminal session; `bin/dispatch` puts the `dispatch` command on the Bash tool's `PATH`.
|
|
5
|
-
In a pane `legion claude-bridge` launched, the server also runs the Legion phase worker (`src/legion-*.ts`).
|
|
3
|
+
`@sjawhar/claude-envoy` is the Claude Code plugin for Envoy and Dispatch;
|
|
6
4
|
`codex/` and `src/codex/` are the Codex CLI plugin, `@sjawhar/codex-envoy`, built from this source.
|
|
7
|
-
`README.md` has the architecture, the bundle and release, and the smokes.
|
|
5
|
+
`README.md` has the architecture, the bundle and release, the commands and the smokes.
|
|
8
6
|
|
|
9
|
-
##
|
|
7
|
+
## Components
|
|
10
8
|
|
|
11
|
-
-
|
|
9
|
+
- `src/envoy-channel-server.ts`: the MCP stdio server, the session's Envoy ingress, which serves the `envoy_*` tools.
|
|
12
10
|
|
|
13
|
-
- `
|
|
11
|
+
- `hooks/mod.ts`: the mod, which writes into a terminal session; `hooks/mod-writer.ts` decides whether a message becomes a prompt or a row.
|
|
14
12
|
|
|
15
|
-
-
|
|
16
|
-
`tests/envoy-channel-stall.test.ts` runs only with `LEGION_E2E_ENVOY_STACK=1` and `go` on `PATH`.
|
|
13
|
+
- `bin/dispatch`: puts the `dispatch` command on the Bash tool's `PATH`.
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
- `src/legion-*.ts`: the Legion phase worker, which the server runs in a pane `legion claude-bridge` launched.
|
|
19
16
|
|
|
20
|
-
-
|
|
21
|
-
The `claude_envoy_build` job of `.github/workflows/release.yaml` builds and publishes after a merge that touches a path of `$CLAUDE_ENVOY_VERSION_ARGS`.
|
|
17
|
+
- `scripts/build.ts`: builds the plugin's bundles.
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- `scripts/build-inputs.txt` and `$CLAUDE_ENVOY_VERSION_ARGS` list the same paths.
|
|
26
|
-
A change that makes `scripts/build.ts` or `scripts/verify-build.sh` read a new file adds it to both.
|
|
27
|
-
|
|
28
|
-
- The build refuses a Bun other than `.bun-version`'s; call the pinned binary by path when a version manager's default differs.
|
|
19
|
+
## Rules
|
|
29
20
|
|
|
30
|
-
-
|
|
21
|
+
- Nothing commits `dist/` or `legion/`; the release builds them.
|
|
31
22
|
|
|
32
|
-
|
|
23
|
+
- A change that makes `scripts/build.ts` or `scripts/verify-build.sh` read a new file adds it to `scripts/build-inputs.txt` and to `$CLAUDE_ENVOY_VERSION_ARGS` in `.github/workflows/release.yaml`.
|
|
33
24
|
|
|
34
|
-
- `renderInbound` (`@legion/envoy-client/delivery`)
|
|
25
|
+
- Render inbound messages only through `renderInbound` (`@legion/envoy-client/delivery`).
|
|
35
26
|
|
|
36
|
-
- Subscribe the relay subject
|
|
27
|
+
- Subscribe the session's relay subject before any registration under its id, and read the id from the shared `SessionIdentity` at each use:
|
|
28
|
+
a `/clear` moves the session to a new id.
|
|
37
29
|
|
|
38
|
-
- Hand the relay the nats.js `Msg` itself: its `data`, `headers` and `reply` are prototype getters that an object spread drops.
|
|
30
|
+
- Hand the relay the nats.js `Msg` itself, never a copy: its `data`, `headers` and `reply` are prototype getters that an object spread drops.
|
|
39
31
|
|
|
40
32
|
- Every registry write goes through the session's one `serialized` chain, and nothing in it waits without a bound, since shutdown's deregistration queues behind it.
|
|
41
33
|
|
|
42
|
-
- Register the capabilities `sessionCapabilities` computes, never a constant.
|
|
43
|
-
The role record rules are `roleHeldBy` and `mayActOnRoleRecord` in `@legion/envoy-client/transport`, which pi-envoy shares.
|
|
34
|
+
- Register the capabilities `sessionCapabilities` computes, never a constant, and read role records through `roleHeldBy` and `mayActOnRoleRecord` (`@legion/envoy-client/transport`), which pi-envoy shares.
|
|
44
35
|
|
|
45
36
|
- No Dispatch call goes through the MCP server, and no permission relay is carried: no reply path here authenticates its sender.
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- Every message into a terminal session goes through the mod's `session.message`, and `hooks/mod-writer.ts` decides whether it becomes a prompt or a row: only the mod sees the turn's events and this plugin's writes in one order.
|
|
50
|
-
|
|
51
|
-
- Answer a frame `done` only on the write the mod reports, a row appended or a prompt the engine took; the writes are idempotent by Envoy event id (`writeOnce`).
|
|
52
|
-
|
|
53
|
-
- An event that carries `agentId` is a subagent's, never the session's turn (`ofSubagent`).
|
|
54
|
-
|
|
55
|
-
- `resolveModSocketPath` puts the socket under `XDG_RUNTIME_DIR` or Claude Code's configuration directory, never `TMPDIR`, within a 100-byte path.
|
|
56
|
-
|
|
57
|
-
- The mod needs Claude Code 2.1.310 or newer; `--bare`, `--safe-mode` and settings that turn hooks or mods off leave a session with no messages.
|
|
58
|
-
|
|
59
|
-
## Legion panes
|
|
60
|
-
|
|
61
|
-
- The phase reminder's machine is `@legion/pi-shared`'s; `src/legion-phase-hook.ts` only drives it from Claude Code's hooks.
|
|
38
|
+
- Every message into a terminal session goes through the mod's `session.message`.
|
|
62
39
|
|
|
63
|
-
-
|
|
64
|
-
|
|
40
|
+
- The Legion hook entries go in `legion/hooks/hooks.json` (`LEGION_HOOKS` in `scripts/build.ts`), never `hooks/hooks.json`:
|
|
41
|
+
a plain install has no `legion` server, so each would fail on every turn.
|
package/README.md
CHANGED
|
@@ -86,7 +86,8 @@ message from Dispatch's Agents page as that person's own turn.
|
|
|
86
86
|
or disconnected, comes again and is delivered once, for up to 72 hours. A
|
|
87
87
|
`notifications.team.<name>` topic is stored and delivered like any other followed topic. The
|
|
88
88
|
resume point is kept in `replay-<session id>.json` with the ledger below.
|
|
89
|
-
`packages/envoy/
|
|
89
|
+
`packages/envoy/docs/architecture.md`, "Runtime shape" (its "Session consumers" item), states
|
|
90
|
+
the listener's side.
|
|
90
91
|
- Nothing is fetched back: a message published while the session was not running, restarting or
|
|
91
92
|
disconnected (NATS restarting, the connection dropped) waits in that consumer and is delivered
|
|
92
93
|
when the session returns, the same way as any other, with a line saying when it was published
|
|
@@ -350,7 +351,7 @@ reads, to `dispatch-writing-specs`, which the session loads by name.
|
|
|
350
351
|
reviewer's pair, `thermonuclear-code-quality` and `thermonuclear-deep-review`, ships here too, so
|
|
351
352
|
one copy of each rubric reaches both harnesses. The other root skills
|
|
352
353
|
stay out of this plugin: they belong to Legion's roles (the architect, controller, oracle and retro
|
|
353
|
-
skills, and the phase workers' `legion-worker` and `simplify-settled-diff
|
|
354
|
+
skills, and the phase workers' `legion-worker` and `simplify-settled-diff`; the partition is in `scripts/pi-plugin-prepack.sh` at the repository root). A phase worker on Claude Code gets them from the
|
|
354
355
|
generated `legion/` plugin (below). Link another root skill here only when a standalone Claude
|
|
355
356
|
Code session needs it.
|
|
356
357
|
|
|
@@ -376,7 +377,9 @@ Claude Code when `legion.yaml` sets `worker_backends: {<role>: claude}` (tmux ru
|
|
|
376
377
|
error once Claude Code ended a step without taking it or exited; a relayed frame is `done` on
|
|
377
378
|
that answer.
|
|
378
379
|
|
|
379
|
-
`legion/` is generated by `scripts/build.ts
|
|
380
|
+
`legion/` is generated by `scripts/build.ts`: it copies the skills `@sjawhar/pi-legion` ships
|
|
381
|
+
(staged by `scripts/pi-plugin-prepack.sh --stage-skills @sjawhar/pi-legion`) and turns that
|
|
382
|
+
package's task agents (`packages/pi-legion/agents/`) into Claude Code's agent format. The
|
|
380
383
|
release builds it with the bundle and packs it into the published package (below), and nobody
|
|
381
384
|
edits it by hand. A standalone Claude Code session doesn't load it.
|
|
382
385
|
|
|
@@ -485,7 +488,9 @@ Nothing has to be enabled on the machine: the plugin carries a Claude Code mod (
|
|
|
485
488
|
loaded by the `modules` key of `hooks/hooks.json`), and the mod and this server meet on a Unix
|
|
486
489
|
socket of the session's own (`hooks/mod-protocol.ts`, `src/mod-link.ts`). Claude Code 2.1.310 or
|
|
487
490
|
newer runs the mod; below that it never connects, and a terminal session advertises no delivery
|
|
488
|
-
mode, so Dispatch refuses a message to it rather than reporting it delivered.
|
|
491
|
+
mode, so Dispatch refuses a message to it rather than reporting it delivered. The same holds for
|
|
492
|
+
a session started with `--bare` or `--safe-mode`, and one whose settings turn hooks or mods off
|
|
493
|
+
(`disableAllHooks`, or `allowManagedModsOnly` or `allowManagedHooksOnly` in managed settings).
|
|
489
494
|
|
|
490
495
|
That socket is `claude-envoy/ce-<hash of the session id>.sock` under `XDG_RUNTIME_DIR`, and
|
|
491
496
|
under Claude Code's own configuration directory — `CLAUDE_CONFIG_DIR`, else `$HOME/.claude` —
|
|
@@ -665,17 +670,23 @@ bash packages/claude-envoy/scripts/smoke-session-title.sh
|
|
|
665
670
|
bun run --cwd packages/claude-envoy lint
|
|
666
671
|
bun run --cwd packages/claude-envoy typecheck
|
|
667
672
|
bun run --cwd packages/claude-envoy test
|
|
673
|
+
(cd packages/claude-envoy && bun test --timeout=60000 tests/mod.test.ts) # one file
|
|
668
674
|
bun packages/claude-envoy/scripts/build.ts --out "$(mktemp -d)"
|
|
669
675
|
```
|
|
670
676
|
|
|
671
677
|
`bun run --cwd packages/claude-envoy verify-build "$(mktemp -d)/built.tar"` builds the plugin
|
|
672
678
|
twice and compares the two builds, which is what the release's build job runs; nothing in a
|
|
673
679
|
checkout holds a built copy to compare against.
|
|
680
|
+
`bun packages/claude-envoy/scripts/build.ts --codex-out <dir>` builds the Codex plugin ("Codex
|
|
681
|
+
CLI" above).
|
|
682
|
+
The real-binary tests skip unless `LEGION_TEST_CLAUDE` names a Claude Code binary.
|
|
674
683
|
`tests/answers-claude.test.ts` runs the real Claude Code, the release `.claude-code-pin` at the
|
|
675
684
|
repository root pins, against a stand-in Messages endpoint and Dispatch: the list reaches the model
|
|
676
|
-
at startup, on `--resume`, after `/compact` and in a subagent. It skips without `LEGION_TEST_CLAUDE
|
|
677
|
-
|
|
678
|
-
|
|
685
|
+
at startup, on `--resume`, after `/compact` and in a subagent. It skips without `LEGION_TEST_CLAUDE`,
|
|
686
|
+
except on GitHub Actions, where `.github/actions/install-claude-code` installs the pin.
|
|
687
|
+
`tests/envoy-channel-stall.test.ts` runs a real NATS server and Envoy listener, which it builds
|
|
688
|
+
with Go, so it runs only with `LEGION_E2E_ENVOY_STACK=1` and `go` on `PATH`.
|
|
689
|
+
Locally:
|
|
679
690
|
|
|
680
691
|
```bash
|
|
681
692
|
mkdir -p "$TMPDIR/claude-code" && bun add --cwd "$TMPDIR/claude-code" --exact --no-save "@anthropic-ai/claude-code@$(<.claude-code-pin)"
|
package/dist/envoy-channel.js
CHANGED
|
@@ -58530,7 +58530,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
58530
58530
|
|
|
58531
58531
|
// package.json
|
|
58532
58532
|
var name2 = "@sjawhar/claude-envoy";
|
|
58533
|
-
var version2 = "4.14.
|
|
58533
|
+
var version2 = "4.14.4";
|
|
58534
58534
|
var legion = {
|
|
58535
58535
|
daemonApiVersion: 178
|
|
58536
58536
|
};
|
|
@@ -60852,7 +60852,7 @@ var PHASE_OP_SENTENCES = {
|
|
|
60852
60852
|
};
|
|
60853
60853
|
var STALE_ENTRY_INSTRUCTION = "End this turn without completing. The task of the entry the phase is on is owed to this claim, and the daemon sends it by itself. " + "That task is work of its own: do what it asks at the head it names and complete it with a handoff of its own, never this completion's " + "record, commit or verdict";
|
|
60854
60854
|
function legionToolDescription(host) {
|
|
60855
|
-
return "Perform the workflow operation the Legion daemon assigned this role. The daemon advances phases; this tool cannot spawn workers. " + (host.before ?? "") + "handoff_complete (phase workers alone: the daemon refuses an architect's completion, with ACCEPTANCE_IS_SIGN_OFF where nothing else refuses it first, since an architect accepts with sign_off; " + "the daemon accepts a completion only from the role working the issue's current phase, " + "or a role's first completion of the phase it left, which it records and which moves nothing, " + "and the checking role's report on a look of its closed issue's production check) reports this phase complete: `summary` (two sentences for the " + "architect), `verdict` pass|fail from the tester alone on a phase completion (the daemon refuses a verdict from " + "any other role there) and pass|pending|fail on a production check report (pending: production does not carry the merge " + "yet, or carries it with a requirement only the deploy can show still unobserved and a look still to follow). " + "A planning, implementing, testing or reviewing phase ends with a handoff record on the " + "Dispatch issue: write it with `dispatch handoff-write --issue <issue> --phase <plan|implement|test|review> --body-file <file>` before " + "calling. This call reads from Dispatch the newest record of the phase your role works or, once the issue has moved on, of the phase it left, " + "and reports it with `commit`, the head that record's body names " + "(`head`, the 40-character lower-case commit the work it reports was done against); in implementing, the implementer's must be the commit its " + "workspace stands on, `@-`, pushed to `legion/<issue>@origin`, so push the branch first; retro, the merger's completion and a phase you left with no record, or with an implement record naming no head, report the commit the workspace stands on. It " + "refuses, posting nothing, a phase you work with no record, a Dispatch that does not answer, and, in implementing, an implement record naming no head, an " + "implementer's `@-` not yet on `legion/<issue>@origin`, or an implement record whose head is not that pushed `@-`, each naming the remedy. A production check report " + "(the task whose first line is `Production check of <KEY>`, handed once the merge closed the issue to the role the check records) needs no " + "handoff and no commit: it carries its verdict and summary alone. A pending report also names `wake_at`, an RFC 3339 time: when you want the " + "next look. A pass, a fail, and a pending on the check's last look end the check, so none of them carries `wake_at` " + "(CHECK_WAKE_UNEXPECTED), and a pending on any other look is refused without one (CHECK_WAKE_REQUIRED). A report on an issue whose check is " + "closed or never opened is refused (CHECK_NOT_OPEN), and so is one from a role the check does not record (CHECK_ROLE_MISMATCH). " + `The completion that ends the retro carries \`plan_rating\` (${LEGION_PLAN_RATING_LEAST} to ${LEGION_PLAN_RATING_MOST}) and \`plan_reason\`, as ` + "skill://legion-retro says, and the daemon refuses a completion that breaks that skill's rating rule " + "(PLAN_RATING_REQUIRED, PLAN_RATING_UNEXPECTED or PLAN_RATING_INPUT). " + "The daemon refuses " + "HANDOFF_SESSION_MISMATCH (another session wrote the record), HANDOFF_NOT_NEW (the record is the one you named for your previous phase: " + "write this phase's handoff), " + "HANDOFF_STALE_ENTRY (this completion is of a phase entry behind the one your role's phases row names, because the phase was entered " + `again while your turn ran, and nothing was recorded. ${STALE_ENTRY_INSTRUCTION}), the implementer's completion of implementing with no open ` + "pull request on `legion/<issue>` and none recorded " + "merged (HANDOFF_NO_PULL_REQUEST: open it; one naming a closed pull request is the architect's to decide); a refused completion changed " + "nothing, so fix what it names and complete again. " + "ready_for_update answers the daemon's update message on this issue's pod: `round` is the round id that message names, and the " + "daemon takes your answer for that round alone. Push every commit you want kept to the issue branch " + "first. The daemon replaces the pod and its disk when the round ends
|
|
60855
|
+
return "Perform the workflow operation the Legion daemon assigned this role. The daemon advances phases; this tool cannot spawn workers. " + (host.before ?? "") + "handoff_complete (phase workers alone: the daemon refuses an architect's completion, with ACCEPTANCE_IS_SIGN_OFF where nothing else refuses it first, since an architect accepts with sign_off; " + "the daemon accepts a completion only from the role working the issue's current phase, " + "or a role's first completion of the phase it left, which it records and which moves nothing, " + "and the checking role's report on a look of its closed issue's production check) reports this phase complete: `summary` (two sentences for the " + "architect), `verdict` pass|fail from the tester alone on a phase completion (the daemon refuses a verdict from " + "any other role there) and pass|pending|fail on a production check report (pending: production does not carry the merge " + "yet, or carries it with a requirement only the deploy can show still unobserved and a look still to follow). " + "A planning, implementing, testing or reviewing phase ends with a handoff record on the " + "Dispatch issue: write it with `dispatch handoff-write --issue <issue> --phase <plan|implement|test|review> --body-file <file>` before " + "calling. This call reads from Dispatch the newest record of the phase your role works or, once the issue has moved on, of the phase it left, " + "and reports it with `commit`, the head that record's body names " + "(`head`, the 40-character lower-case commit the work it reports was done against); in implementing, the implementer's must be the commit its " + "workspace stands on, `@-`, pushed to `legion/<issue>@origin`, so push the branch first; retro, the merger's completion and a phase you left with no record, or with an implement record naming no head, report the commit the workspace stands on. It " + "refuses, posting nothing, a phase you work with no record, a Dispatch that does not answer, and, in implementing, an implement record naming no head, an " + "implementer's `@-` not yet on `legion/<issue>@origin`, or an implement record whose head is not that pushed `@-`, each naming the remedy. A production check report " + "(the task whose first line is `Production check of <KEY>`, handed once the merge closed the issue to the role the check records) needs no " + "handoff and no commit: it carries its verdict and summary alone. A pending report also names `wake_at`, an RFC 3339 time: when you want the " + "next look. A pass, a fail, and a pending on the check's last look end the check, so none of them carries `wake_at` " + "(CHECK_WAKE_UNEXPECTED), and a pending on any other look is refused without one (CHECK_WAKE_REQUIRED). A report on an issue whose check is " + "closed or never opened is refused (CHECK_NOT_OPEN), and so is one from a role the check does not record (CHECK_ROLE_MISMATCH). " + `The completion that ends the retro carries \`plan_rating\` (${LEGION_PLAN_RATING_LEAST} to ${LEGION_PLAN_RATING_MOST}) and \`plan_reason\`, as ` + "skill://legion-retro says, and the daemon refuses a completion that breaks that skill's rating rule " + "(PLAN_RATING_REQUIRED, PLAN_RATING_UNEXPECTED or PLAN_RATING_INPUT). " + "The daemon refuses " + "HANDOFF_SESSION_MISMATCH (another session wrote the record), HANDOFF_NOT_NEW (the record is the one you named for your previous phase: " + "write this phase's handoff), " + "HANDOFF_STALE_ENTRY (this completion is of a phase entry behind the one your role's phases row names, because the phase was entered " + `again while your turn ran, and nothing was recorded. ${STALE_ENTRY_INSTRUCTION}), the implementer's completion of implementing with no open ` + "pull request on `legion/<issue>` and none recorded " + "merged (HANDOFF_NO_PULL_REQUEST: open it; one naming a closed pull request is the architect's to decide); a refused completion changed " + "nothing, so fix what it names and complete again. " + "ready_for_update answers the daemon's update message on this issue's pod: `round` is the round id that message names, and the " + "daemon takes your answer for that round alone. Push every commit you want kept to the issue branch " + "first. Then let each subagent and each background job that you started finish, or stop it. Commit and push what it made " + "before you answer. The daemon replaces the pod and its disk when the round ends. The round ends at the moment the message " + "names. It can end earlier, once every role has answered, no role is in a turn and each role's last report names no running " + "subagent or background job. No answer delays that moment, and the end of a turn is no answer. If a subagent or a background " + "job finishes after you answer, commit and push what it made. Then call ready_for_update again with the same round. " + "The call ends no phase. The daemon holds your next task until your process comes back on the new pod, in this same session. " + (host.after ?? "") + `What a later phase needs goes in your handoff; a question for another live role goes to its role topic with ${host.envoyPublish}.`;
|
|
60856
60856
|
}
|
|
60857
60857
|
async function mintClaimGrant(daemon, claim) {
|
|
60858
60858
|
const { grantId } = await daemon.grant({
|
|
@@ -27,6 +27,6 @@ Check the child and its parent in `read_state` and Dispatch. When it still looks
|
|
|
27
27
|
|
|
28
28
|
## An update round that is not finishing (`update-stalled`)
|
|
29
29
|
|
|
30
|
-
The daemon replaces a pod whose configuration moved only after an update round: it asks each role of the issue to push its work and answer `ready_for_update`, and the round ends
|
|
30
|
+
The daemon replaces a pod whose configuration moved only after an update round: it asks each role of the issue to push its work, let its subagents and background jobs finish or stop them, push what they made and answer `ready_for_update`, and the round ends at `pod_update_grace_minutes`, or earlier once all answered, no role is in a turn and each role's last report names no background work that runs. This wake says that bound has passed and `reason` names what still holds the round. Work a role did not push goes with the pod.
|
|
31
31
|
|
|
32
32
|
Whatever `reason` names (an operator's suspension, a refused pod replacement, no process in the pod, two pods, or anything else), open a finding ask naming the issue, the round and `reason`, so an operator acts on it. Send no role a message about the round, park nothing and write no status: the daemon replaces the pod once the hold clears.
|