@sjawhar/claude-envoy 6.26.0 → 6.27.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.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "6.26.0"
5
+ "version": "6.27.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.26.0",
3
+ "version": "6.27.0",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -19693,6 +19693,14 @@ var LISTENER_CALL_ATTEMPTS = 2;
19693
19693
  var LISTENER_CALL_BUDGET_MS = LISTENER_CALL_ATTEMPTS * LISTENER_CALL_TIMEOUT_MS + (LISTENER_CALL_ATTEMPTS - 1) * LISTENER_CALL_RETRY_DELAY_MS;
19694
19694
  var THIRD_REFRESH_DONE_MS = 3 * SESSION_HEARTBEAT_MS + LISTENER_CALL_BUDGET_MS;
19695
19695
  var BUS_UNANSWERED_PREFIX = "envoy: the message bus did not answer";
19696
+ // ../contracts/src/legion-handoff.ts
19697
+ var LegionAgentHandoffSchema = object({
19698
+ original_topic: string2().min(1),
19699
+ target_session: string2().min(1),
19700
+ role_token: string2().min(1),
19701
+ project: string2().min(1),
19702
+ envelope: EnvelopeSchema
19703
+ }).strict();
19696
19704
  // ../contracts/src/related-forms.ts
19697
19705
  function relatedCheckFormOf(suggestions) {
19698
19706
  const { outcome, missing } = suggestions;
package/dist/dispatch.js CHANGED
@@ -20293,6 +20293,14 @@ var LISTENER_CALL_ATTEMPTS = 2;
20293
20293
  var LISTENER_CALL_BUDGET_MS = LISTENER_CALL_ATTEMPTS * LISTENER_CALL_TIMEOUT_MS + (LISTENER_CALL_ATTEMPTS - 1) * LISTENER_CALL_RETRY_DELAY_MS;
20294
20294
  var THIRD_REFRESH_DONE_MS = 3 * SESSION_HEARTBEAT_MS + LISTENER_CALL_BUDGET_MS;
20295
20295
  var BUS_UNANSWERED_PREFIX = "envoy: the message bus did not answer";
20296
+ // ../contracts/src/legion-handoff.ts
20297
+ var LegionAgentHandoffSchema = object({
20298
+ original_topic: string2().min(1),
20299
+ target_session: string2().min(1),
20300
+ role_token: string2().min(1),
20301
+ project: string2().min(1),
20302
+ envelope: EnvelopeSchema
20303
+ }).strict();
20296
20304
  // ../contracts/src/related-forms.ts
20297
20305
  function relatedCheckFormOf(suggestions) {
20298
20306
  const { outcome, missing } = suggestions;
@@ -42493,6 +42493,14 @@ var LISTENER_CALL_ATTEMPTS = 2;
42493
42493
  var LISTENER_CALL_BUDGET_MS = LISTENER_CALL_ATTEMPTS * LISTENER_CALL_TIMEOUT_MS + (LISTENER_CALL_ATTEMPTS - 1) * LISTENER_CALL_RETRY_DELAY_MS;
42494
42494
  var THIRD_REFRESH_DONE_MS = 3 * SESSION_HEARTBEAT_MS + LISTENER_CALL_BUDGET_MS;
42495
42495
  var BUS_UNANSWERED_PREFIX = "envoy: the message bus did not answer";
42496
+ // ../contracts/src/legion-handoff.ts
42497
+ var LegionAgentHandoffSchema = object({
42498
+ original_topic: string2().min(1),
42499
+ target_session: string2().min(1),
42500
+ role_token: string2().min(1),
42501
+ project: string2().min(1),
42502
+ envelope: EnvelopeSchema
42503
+ }).strict();
42496
42504
  // ../contracts/src/related-forms.ts
42497
42505
  function relatedCheckFormOf(suggestions) {
42498
42506
  const { outcome, missing } = suggestions;
@@ -68960,7 +68968,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
68960
68968
 
68961
68969
  // package.json
68962
68970
  var name2 = "@sjawhar/claude-envoy";
68963
- var version2 = "6.26.0";
68971
+ var version2 = "6.27.0";
68964
68972
  var package_default = {
68965
68973
  name: name2,
68966
68974
  version: version2,
@@ -68971,7 +68979,7 @@ var package_default = {
68971
68979
  repository: { type: "git", url: "https://github.com/cybermonklabs/legion" },
68972
68980
  scripts: { channel: "bun bin/envoy-channel.ts", "verify-build": "bash scripts/verify-build.sh", prepack: "bash scripts/pack-skills.sh", postpack: "bash scripts/pack-skills.sh --restore", typecheck: "bun ../contracts/scripts/gen-api.ts && bunx tsc --noEmit", test: "bun test --timeout=60000", lint: "bunx biome check src/ hooks/ scripts/" },
68973
68981
  devDependencies: { "@biomejs/biome": "2.5.15", "@legion/cipher-client": "workspace:*", "@legion/contracts": "workspace:*", "@legion/envoy-client": "workspace:*", "@legion/pi-shared": "workspace:*", "@legion/test-fixtures": "workspace:*", "@modelcontextprotocol/sdk": "^1.30.0", "bun-types": "latest", nats: "^2.29.2", typescript: "^5.3.0", zod: "4.3.6" },
68974
- legion: { daemonApiVersion: 291 }
68982
+ legion: { daemonApiVersion: 292 }
68975
68983
  };
68976
68984
 
68977
68985
  // ../pi-shared/src/agent-stream.ts
@@ -71348,16 +71356,24 @@ var LegionReleaseRecordsResponse = object({
71348
71356
  resumes: array(legionResumeRecord),
71349
71357
  holds: array(legionHoldRecord)
71350
71358
  });
71359
+ var legionWatchedWorkflow = object({
71360
+ owner: nonEmptyString2,
71361
+ repo: nonEmptyString2,
71362
+ workflow: nonEmptyString2,
71363
+ events: array(nonEmptyString2).min(1)
71364
+ });
71351
71365
  var LegionControllerRegisterResponse = object({
71352
71366
  claimToken: nonEmptyString2,
71353
71367
  role: literal("controller").optional(),
71354
71368
  generation: number2().int().positive(),
71355
71369
  secret: nonEmptyString2,
71356
- replaces: nonEmptyString2.optional()
71370
+ replaces: nonEmptyString2.optional(),
71371
+ watchedWorkflows: array(legionWatchedWorkflow).optional()
71357
71372
  });
71358
71373
  var LegionControllerSecretResponse = object({
71359
71374
  secret: nonEmptyString2,
71360
- designGateSteps: array(legionDesignStep)
71375
+ designGateSteps: array(legionDesignStep),
71376
+ watchedWorkflows: array(legionWatchedWorkflow)
71361
71377
  });
71362
71378
  var LegionControllerCredentialResponse = object({
71363
71379
  owners: record(nonEmptyString2, object({
@@ -71776,7 +71792,17 @@ var LEGION_ANSWER_READS = {
71776
71792
  "promptAgents",
71777
71793
  "replaces"
71778
71794
  ],
71779
- LegionControllerRegisterResponse: ["claimToken", "generation", "secret", "replaces"],
71795
+ LegionControllerRegisterResponse: [
71796
+ "claimToken",
71797
+ "generation",
71798
+ "secret",
71799
+ "replaces",
71800
+ "watchedWorkflows",
71801
+ "watchedWorkflows[].owner",
71802
+ "watchedWorkflows[].repo",
71803
+ "watchedWorkflows[].workflow",
71804
+ "watchedWorkflows[].events"
71805
+ ],
71780
71806
  LegionGrantResponse: ["grantId"],
71781
71807
  LegionErrorResponse: ["error", "code"],
71782
71808
  LegionReleaseRecordsResponse: [
@@ -72207,7 +72233,7 @@ function claimRoleAtFirstTurn(host, role, replaces, firstTurn) {
72207
72233
  host.recordClaimStep?.({ claimedBy: by, at: Date.now() });
72208
72234
  (async () => {
72209
72235
  try {
72210
- await claimRoleAgainOnBusy(() => host.claimRole(role, replaces), role, {
72236
+ await claimRoleAgainOnBusy(() => host.claimRole(role, replaces), roleClaimWords(role), {
72211
72237
  log: host.log,
72212
72238
  firstDelayMs: host.roleClaimRetryFirstDelayMs,
72213
72239
  signal: host.signal
@@ -72231,7 +72257,10 @@ function claimRoleAtFirstTurn(host, role, replaces, firstTurn) {
72231
72257
  }
72232
72258
  var ROLE_CLAIM_RETRY_FIRST_DELAY_MS = 1000;
72233
72259
  var ROLE_CLAIM_RETRY_MAX_DELAY_MS = 30000;
72234
- async function claimRoleAgainOnBusy(claim, role, options) {
72260
+ function roleClaimWords(role) {
72261
+ return { what: `claim of Envoy role ${role}`, again: "claiming it again" };
72262
+ }
72263
+ async function claimRoleAgainOnBusy(claim, words, options) {
72235
72264
  let wait = options.firstDelayMs ?? ROLE_CLAIM_RETRY_FIRST_DELAY_MS;
72236
72265
  for (let attempt = 1;; attempt++) {
72237
72266
  try {
@@ -72242,7 +72271,7 @@ async function claimRoleAgainOnBusy(claim, role, options) {
72242
72271
  throw error;
72243
72272
  if (options.maxAttempts !== undefined && attempt >= options.maxAttempts)
72244
72273
  throw error;
72245
- options.log(`claim of Envoy role ${role} was answered 503 at attempt ${attempt}; claiming it again in ${wait} ms: ${messageFor(error)}`, error);
72274
+ options.log(`${words.what} was answered 503 at attempt ${attempt}; ${words.again} in ${wait} ms: ${messageFor(error)}`, error);
72246
72275
  const waited = Promise.withResolvers();
72247
72276
  const timer = setTimeout(waited.resolve, wait);
72248
72277
  timer.unref?.();
@@ -19711,6 +19711,14 @@ var LISTENER_CALL_ATTEMPTS = 2;
19711
19711
  var LISTENER_CALL_BUDGET_MS = LISTENER_CALL_ATTEMPTS * LISTENER_CALL_TIMEOUT_MS + (LISTENER_CALL_ATTEMPTS - 1) * LISTENER_CALL_RETRY_DELAY_MS;
19712
19712
  var THIRD_REFRESH_DONE_MS = 3 * SESSION_HEARTBEAT_MS + LISTENER_CALL_BUDGET_MS;
19713
19713
  var BUS_UNANSWERED_PREFIX = "envoy: the message bus did not answer";
19714
+ // ../contracts/src/legion-handoff.ts
19715
+ var LegionAgentHandoffSchema = object({
19716
+ original_topic: string2().min(1),
19717
+ target_session: string2().min(1),
19718
+ role_token: string2().min(1),
19719
+ project: string2().min(1),
19720
+ envelope: EnvelopeSchema
19721
+ }).strict();
19714
19722
  // ../contracts/src/related-forms.ts
19715
19723
  function relatedCheckFormOf(suggestions) {
19716
19724
  const { outcome, missing } = suggestions;
@@ -33,9 +33,12 @@ whole suite is the CI job that runs it.
33
33
  never `ci-ok`, which passes when jobs it did not select were skipped
34
34
  (`.github/scripts/ci-ok.sh`).
35
35
  2. Name it as GitHub writes it: `<caller> / <job>` for a job of a called workflow (`test / test`).
36
- 3. Name a held-back job only when a test that job alone runs is the proof: the merge queue runs
37
- it anyway, and while a check names it, its label (`lane:<output>`, never `full-ci`) reruns it
38
- on every push; without the label the check reads `absent` or `skipped`.
36
+ 3. Name a held-back job only when a test that job alone runs is the proof: while a check names it,
37
+ its label (on cybermonklabs/legion `lane:<output>`, never `full-ci`) reruns it on every push, and
38
+ without the label the check reads `absent` or `skipped`. The merge queue runs a slow suite when
39
+ the queue's own selection, against the queue's base, picks it, and on cybermonklabs/legion
40
+ ci-ok's `not run at this head:` line names a held-back job that a pull request's paths select and
41
+ that it did not run.
39
42
  4. Write in `negative_control` the case inside that job that fails when the property breaks: a
40
43
  step with `continue-on-error` keeps its job green.
41
44
 
@@ -0,0 +1,41 @@
1
+ # Watched workflows
2
+
3
+ Read this at every start and on each delivered run of a watched workflow. Your system prompt's `Watched workflows:` line names each entry as `<owner>/<repo>/<file>`, with the events whose runs count. It is the list of this launch, and no notice or message changes it. With no such line and no such run delivered, nothing here applies.
4
+
5
+ ## Which runs count
6
+
7
+ A delivery on a watched workflow's topic is a completed run on its repository's default branch. It is a watched run whether or not the prompt names its entry, and step 1 says whether it counts.
8
+
9
+ 1. A run counts when its `conclusion` is `failure`, `timed_out`, `startup_failure` or `cancelled`. No other conclusion counts.
10
+ 2. A `cancelled` run does not count only when a newer run of the same workflow on the default branch, from an event the entry names (for an entry the prompt does not name, the cancelled run's own event), started before the cancelled run ended. Read the runs:
11
+
12
+ ```text
13
+ gh run list --repo '<owner>/<repo>' --workflow '<file>' --branch '<default branch>' --limit 20 --json databaseId,event,status,conclusion,startedAt,updatedAt,url
14
+ ```
15
+
16
+ A newer run has a larger `databaseId` than the cancelled run, an `event` the entry names, and a `startedAt` before the cancelled run's `updatedAt`. When such a newer run exists, that newer run's end decides, not the cancelled run. When the newer run's `status` is `completed`, take the newer run by steps 1 to 5. When it did not end yet, take nothing now: its own delivery decides. Every other `cancelled` run counts. A `cancelled` run counts when a run on another branch took its place.
17
+
18
+ ## Route a counted run
19
+
20
+ A counted run is a clear defect.
21
+
22
+ 3. Before you route a counted run, search Dispatch for its run id: `dispatch search --query '<run id>'`. The search ranks loosely, so read each hit: when an issue or a comment names the run already, as `run <run id>` or by its URL, do not route it again. Steps 4 and 5 write `run <run id>` as words of their own for this search.
23
+ 4. Search for an open issue of the workflow: `dispatch search --query '<owner>/<repo>/<file>'`. When an open issue tracks a defect of the workflow, comment `<owner>/<repo>/<file> ended <conclusion> again: run <run id>, <run URL>` on it (`dispatch comment --issue '<KEY>' --body-file -`). When a live tree owns that issue (its record's `tree` in `read_state`), add `--mention 'role:<that tree's architect's token>'`, built as `skill://legion-controller/references/operations.md#a-request-to-another-session` says, so the comment reaches it. File nothing new.
24
+ 5. Otherwise, route the run as `skill://legion-controller/references/finding-asks.md#file-a-clear-defect` routes a clear defect that you find yourself. Its evidence is `run <run id>, <run URL>`. The issue that you file has a title that names `<owner>/<repo>/<file>`. Its spec ends with `Filed for Legion from controller on <report issue>: run <run id>, <run URL>`.
25
+
26
+ ## At every start
27
+
28
+ 6. Read each repository that the prompt's entries name, once, for its default branch and GitHub's spelling of its name (entries whose `<owner>/<repo>` differ only in case name one repository):
29
+
30
+ ```text
31
+ gh api 'repos/<owner>/<repo>' --jq '[.full_name, .default_branch]'
32
+ ```
33
+
34
+ Compare its `full_name` with the `<owner>/<repo>` of each entry of that repository. When they differ (a difference of case counts), name that entry in your summary: its topic never matches a run. When the read fails, step 7 applies to each entry of that repository. Then, for each entry and each event of the entry, read its newest completed run on its repository's default branch:
35
+
36
+ ```text
37
+ gh run list --repo '<owner>/<repo>' --workflow '<file>' --branch '<default branch>' --event '<event>' --status completed --limit 1 --json databaseId,conclusion,event,headBranch,startedAt,updatedAt,url
38
+ ```
39
+
40
+ Its `databaseId` is the run id, and its `updatedAt` is the run's end. When that run counts by step 1, take it by steps 2 to 5, as a delivered run. A `legion:` notice that Envoy took a watched topic after a 503 asks for this read for one entry and event: make it with the command above, only when the prompt's line names that entry with that event.
41
+ 7. When a `gh` read of step 2 or 6 fails, name the entry and `gh`'s first line in your summary. Act on nothing that read would decide. When a value for a placeholder of those commands holds `'` (a branch name can), run nothing with it: name the entry and the value in your summary.
@@ -46,7 +46,8 @@ When the run gives no result, the line reads `CI run <name> has no result (<case
46
46
  - A job the repository runs on a pull request only under a label (on cybermonklabs/legion, the slow suites) does not run without it.
47
47
  A job that holds its own steps then has a run concluded `skipped`; a job that calls a workflow, as each such job on cybermonklabs/legion does, has only its own run, under its bare name (`test`), concluded `skipped`, and no job of the called file starts, so the run a check names (`test / test`) is `absent`.
48
48
  The implementer adds that job's own `lane:<output>` label, never `full-ci`, then pushes, because the workflow starts on a push and not on a label.
49
- The label stays on while a `ci_check` of the issue names such a job, and comes off when none does: the merge queue runs every held-back job before the change lands, so a held-back job that no check names needs no label.
49
+ The label stays on while a `ci_check` of the issue names such a job, and comes off when none does: a pull request runs a held-back job only for a need its body names, a check that names the job is that need, and while the label is on each push runs the job again.
50
+ On cybermonklabs/legion the label acts on the pull request's runs alone: the merge queue runs a slow suite when the queue's own generator selects it against the queue's base, whatever the labels, so a change can merge with no run of a held-back job its paths select and no check names, and ci-ok's `not run at this head:` line names that job on the pull request.
50
51
  No job runs on a pull request in part: on cybermonklabs/legion test, pi-legion and envoy-infra-go are held back, while tooling-checks, pi-legion-build and envoy-infra-build, their builds and checks, run on every pull request, each job's check named `<job> / <job>` (`test / test`, `tooling-checks / tooling-checks`); the browser suite's pull-request lane is dispatch-browser-pr, whose checks are named `dispatch-browser-pr / <job>`, and its full lane, dispatch-browser, is held back (`lane:dispatch_browser`).
51
52
  On cybermonklabs/legion a check of the edited-migrations, gofmt, OpenAPI or pmdoc steps names `envoy-go-build / envoy-go-build`, which every pull request runs; envoy-go-checks is envoy's script tests, a held-back slow suite, and a check naming it for those steps passes under its label with none of them run.
52
53
 
@@ -43,7 +43,7 @@ The pull request body's `Checks` lines are in `skill://legion-worker/references/
43
43
  ## The rules every phase's evidence follows
44
44
 
45
45
  - 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 a failing test for each way it breaks that no existing test catches.
46
- Lint, types and the unit and integration suites are CI's: read on GitHub the ones the head ran, rerun no lane as evidence, and wait for none; a suite the repository holds back for its merge queue has no run at the head, and that is no gap.
46
+ Lint, types and the unit and integration suites are CI's: read on GitHub the ones the head ran, rerun no lane as evidence, and wait for none; a slow suite the repository holds back on a pull request has no run at the head unless a label turns it on, and that is no gap in the tester's evidence; the merge queue runs such a suite when the queue's own selection, against the queue's base, picks it, and on cybermonklabs/legion ci-ok's `not run at this head:` line names each one the head's paths select.
47
47
 
48
48
  - On a new head, the tester reruns each check the change since the head it last tested can reach (for a merge of the base, `skill://legion-worker/references/conflicts-and-rewrites.md#reading-a-merge-of-the-base`) 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.
49
49
 
@@ -18,4 +18,4 @@ An install of your own (an interpreter, a browser, a second toolchain, an extrac
18
18
 
19
19
  ## The Dispatch browser suite
20
20
 
21
- A spec you add or change in `packages/dispatch` runs in the pod one spec a command (`bun run e2e -- e2e/<spec file>`), against the pod's own Postgres (*The database your tests use* in `skill://legion-worker/references/tools.md`). The change's proof is CI at the head: a pull request runs the rows tagged `@pr` in the `dispatch-browser-pr` checks, and every other row runs in the `dispatch-browser` checks, which the merge queue runs before the change lands and a pull request runs only under `lane:dispatch_browser`, for a need the pull request names.
21
+ A spec you add or change in `packages/dispatch` runs in the pod one spec a command (`bun run e2e -- e2e/<spec file>`), against the pod's own Postgres (*The database your tests use* in `skill://legion-worker/references/tools.md`). The change's proof is CI at the head: a pull request runs the rows tagged `@pr` in the `dispatch-browser-pr` checks, and every other row runs in the `dispatch-browser` checks, which the merge queue runs when the queue's own generator selects them against the queue's base, and a pull request runs only under `lane:dispatch_browser`, for a need the pull request names; ci-ok's `not run at this head:` line names `dispatch-browser` on a pull request whose paths select it and that did not run it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "6.26.0",
3
+ "version": "6.27.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -45,6 +45,6 @@
45
45
  "zod": "4.3.6"
46
46
  },
47
47
  "legion": {
48
- "daemonApiVersion": 291
48
+ "daemonApiVersion": 292
49
49
  }
50
50
  }