@sjawhar/claude-envoy 4.14.5 → 4.14.6

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": "4.14.5"
5
+ "version": "4.14.6"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "4.14.5",
3
+ "version": "4.14.6",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -16714,6 +16714,7 @@ var EnvelopeSchema = object({
16714
16714
  expires_at: number2().int().optional(),
16715
16715
  kept_at: number2().int().optional(),
16716
16716
  mention_dedupe_keys: record(string2(), string2()).optional(),
16717
+ role: string2().min(1).optional(),
16717
16718
  payload_summary: string2().min(1),
16718
16719
  payload: string2().optional(),
16719
16720
  payload_ref: string2().optional(),
package/dist/dispatch.js CHANGED
@@ -18011,6 +18011,7 @@ var EnvelopeSchema = object({
18011
18011
  expires_at: number2().int().optional(),
18012
18012
  kept_at: number2().int().optional(),
18013
18013
  mention_dedupe_keys: record(string2(), string2()).optional(),
18014
+ role: string2().min(1).optional(),
18014
18015
  payload_summary: string2().min(1),
18015
18016
  payload: string2().optional(),
18016
18017
  payload_ref: string2().optional(),
@@ -39493,6 +39493,7 @@ var EnvelopeSchema = object({
39493
39493
  expires_at: number2().int().optional(),
39494
39494
  kept_at: number2().int().optional(),
39495
39495
  mention_dedupe_keys: record(string2(), string2()).optional(),
39496
+ role: string2().min(1).optional(),
39496
39497
  payload_summary: string2().min(1),
39497
39498
  payload: string2().optional(),
39498
39499
  payload_ref: string2().optional(),
@@ -58530,7 +58531,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
58530
58531
 
58531
58532
  // package.json
58532
58533
  var name2 = "@sjawhar/claude-envoy";
58533
- var version2 = "4.14.5";
58534
+ var version2 = "4.14.6";
58534
58535
  var legion = {
58535
58536
  daemonApiVersion: 178
58536
58537
  };
@@ -59846,9 +59847,14 @@ function claimRoleAtFirstTurn(host, role, firstTurn) {
59846
59847
  clearTimeout(bound);
59847
59848
  (async () => {
59848
59849
  try {
59849
- await host.claimRole(role);
59850
+ await claimRoleAgainOnBusy(() => host.claimRole(role), role, {
59851
+ log: host.log,
59852
+ firstDelayMs: host.roleClaimRetryFirstDelayMs,
59853
+ signal: host.signal
59854
+ });
59850
59855
  } catch (error) {
59851
- stopAfterRegistration(host, role, error);
59856
+ if (!host.signal?.aborted)
59857
+ stopAfterRegistration(host, role, error);
59852
59858
  }
59853
59859
  done.resolve();
59854
59860
  })();
@@ -59858,6 +59864,43 @@ function claimRoleAtFirstTurn(host, role, firstTurn) {
59858
59864
  firstTurn(claim);
59859
59865
  return done.promise;
59860
59866
  }
59867
+ var ROLE_CLAIM_RETRY_FIRST_DELAY_MS = 1000;
59868
+ var ROLE_CLAIM_RETRY_MAX_DELAY_MS = 30000;
59869
+ async function claimRoleAgainOnBusy(claim, role, options) {
59870
+ let wait = options.firstDelayMs ?? ROLE_CLAIM_RETRY_FIRST_DELAY_MS;
59871
+ for (let attempt = 1;; attempt++) {
59872
+ try {
59873
+ await claim();
59874
+ return;
59875
+ } catch (error) {
59876
+ if (!listenerAskedToClaimAgain(error) || options.signal?.aborted)
59877
+ throw error;
59878
+ if (options.maxAttempts !== undefined && attempt >= options.maxAttempts)
59879
+ throw error;
59880
+ options.log(`claim of Envoy role ${role} was answered 503 at attempt ${attempt}, so nothing was claimed; claiming it again in ${wait} ms: ${messageFor(error)}`);
59881
+ const waited = Promise.withResolvers();
59882
+ const timer = setTimeout(waited.resolve, wait);
59883
+ timer.unref?.();
59884
+ const abort = () => {
59885
+ clearTimeout(timer);
59886
+ waited.resolve();
59887
+ };
59888
+ options.signal?.addEventListener("abort", abort, { once: true });
59889
+ await waited.promise;
59890
+ options.signal?.removeEventListener("abort", abort);
59891
+ if (options.signal?.aborted)
59892
+ throw error;
59893
+ wait = Math.min(wait * 2, ROLE_CLAIM_RETRY_MAX_DELAY_MS);
59894
+ }
59895
+ }
59896
+ }
59897
+ function listenerAskedToClaimAgain(error) {
59898
+ if (!(error instanceof Error) || error.name !== "EnvoyApiError" || !("details" in error)) {
59899
+ return false;
59900
+ }
59901
+ const { details } = error;
59902
+ return typeof details === "object" && details !== null && "status" in details && details.status === 503;
59903
+ }
59861
59904
 
59862
59905
  // src/legion-phase-hook.ts
59863
59906
  import { randomUUID as randomUUID4 } from "crypto";
@@ -60656,6 +60699,7 @@ function startLegionClaim(deps) {
60656
60699
  firstTurnBoundMs: claimFirstTurnBoundMs(deps.env ?? process.env, paneReminderLog(deps.log)),
60657
60700
  onRoleRegained: (listener) => deps.session.onRoleRegained(listener),
60658
60701
  log: deps.log,
60702
+ signal: deps.signal,
60659
60703
  stopping: "stopping the pane so the daemon launches it again",
60660
60704
  stop: () => {
60661
60705
  if (!deps.signal.aborted)
@@ -16918,6 +16918,7 @@ var EnvelopeSchema = object({
16918
16918
  expires_at: number2().int().optional(),
16919
16919
  kept_at: number2().int().optional(),
16920
16920
  mention_dedupe_keys: record(string2(), string2()).optional(),
16921
+ role: string2().min(1).optional(),
16921
16922
  payload_summary: string2().min(1),
16922
16923
  payload: string2().optional(),
16923
16924
  payload_ref: string2().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "4.14.5",
3
+ "version": "4.14.6",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -31,7 +31,10 @@ refuse() {
31
31
  listing=$(tar -tvzf "$tar_file")
32
32
  members=$(tar -tzf "$tar_file")
33
33
 
34
- if ! printf '%s\n' "$members" | grep -qxF package/skills/dispatch-first/SKILL.md; then
34
+ # Each lookup reads the listing from a here-string, never from `printf … | grep -q`: grep -q exits
35
+ # at its first match, and a printf still writing then dies of SIGPIPE, which pipefail turns into
36
+ # exit 141 and so into a refusal of a member the tarball holds.
37
+ if ! grep -qxF package/skills/dispatch-first/SKILL.md <<<"$members"; then
35
38
  refuse "$tar_file holds no package/skills/dispatch-first/SKILL.md, which the dispatch-first hook reads on every session: pack it with the prepack that resolves skills/<name> (scripts/pack-skills.sh)"
36
39
  fi
37
40
 
@@ -42,7 +45,7 @@ fi
42
45
 
43
46
  names=$(printf '%s\n' "$members" | sed -n 's|^package/skills/\([^/]*\)/.*|\1|p' | sort -u)
44
47
  while IFS= read -r name; do
45
- if ! printf '%s\n' "$members" | grep -qxF "package/skills/$name/SKILL.md"; then
48
+ if ! grep -qxF "package/skills/$name/SKILL.md" <<<"$members"; then
46
49
  refuse "$tar_file packs package/skills/$name with no SKILL.md, so the skill it ships is incomplete"
47
50
  fi
48
51
  done <<< "$names"
@@ -319,6 +319,8 @@ export function startLegionClaim(deps: {
319
319
  firstTurnBoundMs: claimFirstTurnBoundMs(deps.env ?? process.env, paneReminderLog(deps.log)),
320
320
  onRoleRegained: (listener) => deps.session.onRoleRegained(listener),
321
321
  log: deps.log,
322
+ // The server's shutdown: a claim answered 503 is not made again once it aborts.
323
+ signal: deps.signal,
322
324
  stopping: "stopping the pane so the daemon launches it again",
323
325
  // A boot the shutdown aborted stops nothing: this server is already going, and `stop`
324
326
  // would SIGTERM the `claude` it runs under on its way out.