@sjawhar/claude-envoy 6.14.0 → 6.14.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.
@@ -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.14.0"
5
+ "version": "6.14.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.14.0",
3
+ "version": "6.14.1",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
package/README.md CHANGED
@@ -113,7 +113,26 @@ message from Dispatch's Agents page as that person's own turn.
113
113
  to 20,000 messages in 72 hours); a crash between handing a message over and recording it
114
114
  can deliver it twice, never lose it. A message that fails three times is replaced by one notice
115
115
  naming it. A registration the listener can give no consumer is refused by name, and the server
116
- says once on stderr that Envoy inbound is unavailable and asks again at every heartbeat.
116
+ says once, on stderr and as a notice to the session, that Envoy inbound is unavailable, and asks
117
+ again at every heartbeat. When a registration is accepted after that, it says once on stderr that
118
+ the session receives again, and tells the session once, as a notice, that Envoy inbound is
119
+ restored and that what the stream stored meanwhile arrives now. A registration the listener
120
+ answers with the bus-outage 503 (its message bus did not answer) is held for two minutes from
121
+ the first such answer, also where its retry got no answer or a 5xx that names no reason; after
122
+ that the server says once that the registration is not recorded for certain, since the retry
123
+ may have landed, and, when one is accepted, that the listener recorded one. A retry the
124
+ listener refuses with a reason, such as `consumer_limit`, is told at once as Envoy inbound
125
+ unavailable. A refusal or a lost relay subject after that notice is told once more, as Envoy
126
+ inbound unavailable, and the accepted registration after it says that Envoy inbound is
127
+ restored. An edge listener's 503 `repositories_unknown` (it could not read the repositories of
128
+ the session's projects) is told at once as Envoy GitHub topics withheld: the listener withholds
129
+ the messages of the session's GitHub topics. If the listener already held the session's
130
+ registration, it kept that registration and the session's consumer, so the session receives its
131
+ other messages; if it held none, the session receives nothing until a registration is accepted.
132
+ The notice and the stderr line say both. The accepted registration after it says that the
133
+ listener follows those topics again. A refusal or a lost relay subject after that notice is told
134
+ once more, as Envoy inbound unavailable. A session whose shutdown has begun registers nothing,
135
+ and is told neither that Envoy inbound is unavailable nor that it is restored.
117
136
  - No receipt is published. A role message reaches this session as a forward the listener stored on
118
137
  the session's own subject, which its consumer relays and whose `done` answers for it; the
119
138
  listener waits only for the stream's acknowledgement that it stored the forward. A frame's reply
@@ -128,7 +147,9 @@ message from Dispatch's Agents page as that person's own turn.
128
147
  so Dispatch learns what the session takes without waiting for a heartbeat. With no capability
129
148
  the listener refuses every targeted delivery (`session … does not advertise aside`) and
130
149
  Dispatch shows the session as taking no messages, which is the right answer for a session
131
- nothing can reach.
150
+ nothing can reach. A plain `envoy_send` names no mode, so the listener stores it, and it
151
+ answers `no_receiver` with no `recipient_state`: the sender reads that the session runs but
152
+ takes no message into its conversation now, and never that it is `live`.
132
153
  - A targeted Dispatch delivery the shared renderer rejects is never shown to the model: when it
133
154
  names a message, the server posts `Invalid Dispatch targeted delivery frame` to
134
155
  `POST /api/v1/messages/{id}/reply` so the attempt fails visibly; otherwise it is logged and dropped.
@@ -512,6 +533,25 @@ both committed files to none; the range is a field of the entry's source, not a
512
533
  entry.
513
534
  A checkout's `package.json` version names no release either, for the same reason: the build job
514
535
  writes the release's version into the manifest it packs.
536
+ On npm 12 or later, `claude plugin update claude-envoy@legion-plugins` fails with
537
+ `code EALLOWREMOTE`, unless the one command allows a fetch from a URL:
538
+
539
+ ```sh
540
+ npm_config_allow_remote=all claude plugin update claude-envoy@legion-plugins
541
+ ```
542
+
543
+ Claude Code fetches the package by its tarball URL on the registry
544
+ (`https://registry.npmjs.org/@sjawhar/claude-envoy/-/claude-envoy-<version>.tgz`) and not by its
545
+ name. npm 12 sets `allow-remote` to `none` by default, and with that setting it refuses to fetch a
546
+ package from a URL: `Could not download @sjawhar/claude-envoy@2.31.4 from the npm registry: code
547
+ EALLOWREMOTE` (Claude Code 2.1.325, npm 12.0.1). The same package fetched by its name passes, and
548
+ the package declares no dependencies, so the cause is in how Claude Code asks npm and no change to
549
+ this package or to the marketplace entry removes it. The variable applies to that one command, so
550
+ every other install on the machine keeps npm's default.
551
+ In a shell that a Claude Code session started, `CLAUDE_CONFIG_DIR` names that session's
552
+ configuration directory, so put `env -u CLAUDE_CONFIG_DIR` in front of the command to update the
553
+ default `~/.claude`. Each scope that holds the plugin (user, project) updates on its own, so run
554
+ the update in each one.
515
555
  Each release publishes its own changelog entries into its GitHub release body, rendered from the
516
556
  fragments its own commits added, and each fragment stays under `.changes/unreleased/`.
517
557
  `CHANGELOG.md` is the history before that and stops where the fragments begin.
@@ -19187,6 +19187,7 @@ var SESSION_LIVE_WINDOW_MS = 300000;
19187
19187
  var LISTENER_CALL_TIMEOUT_MS = 5000;
19188
19188
  var LISTENER_CALL_RETRY_DELAY_MS = 250;
19189
19189
  var LISTENER_CALL_ATTEMPTS = 2;
19190
+ var BUS_UNANSWERED_PREFIX = "envoy: the message bus did not answer";
19190
19191
  // ../contracts/src/related-forms.ts
19191
19192
  function relatedCheckFormOf(suggestions) {
19192
19193
  const { outcome, missing } = suggestions;
@@ -38059,6 +38060,8 @@ function keepNatsCredential(connection, credential, warn) {
38059
38060
  if (credential.needsReconnect())
38060
38061
  await connection.reconnect();
38061
38062
  } catch (error) {
38063
+ if (stopped)
38064
+ return;
38062
38065
  if (error instanceof SessionMovedError) {
38063
38066
  schedule(0);
38064
38067
  return;
package/dist/dispatch.js CHANGED
@@ -19787,6 +19787,7 @@ var SESSION_LIVE_WINDOW_MS = 300000;
19787
19787
  var LISTENER_CALL_TIMEOUT_MS = 5000;
19788
19788
  var LISTENER_CALL_RETRY_DELAY_MS = 250;
19789
19789
  var LISTENER_CALL_ATTEMPTS = 2;
19790
+ var BUS_UNANSWERED_PREFIX = "envoy: the message bus did not answer";
19790
19791
  // ../contracts/src/related-forms.ts
19791
19792
  function relatedCheckFormOf(suggestions) {
19792
19793
  const { outcome, missing } = suggestions;
@@ -29807,6 +29808,8 @@ function keepNatsCredential(connection, credential, warn) {
29807
29808
  if (credential.needsReconnect())
29808
29809
  await connection.reconnect();
29809
29810
  } catch (error) {
29811
+ if (stopped)
29812
+ return;
29810
29813
  if (error instanceof SessionMovedError) {
29811
29814
  schedule(0);
29812
29815
  return;
@@ -40180,6 +40183,9 @@ class EnvoyApiError extends Error {
40180
40183
  this.notSent = notSentAnswer && shown.afterUnanswered !== true;
40181
40184
  }
40182
40185
  }
40186
+ function isBusUnanswered(error) {
40187
+ return error instanceof EnvoyApiError && error.details.status === 503 && error.message.startsWith(BUS_UNANSWERED_PREFIX);
40188
+ }
40183
40189
  var mintedDedupeKey2 = new RegExp(MINTED_DEDUPE_KEY_PATTERN);
40184
40190
 
40185
40191
  class EnvoySendUnconfirmedError extends Error {
@@ -40202,6 +40208,28 @@ class EnvoySendUnconfirmedError extends Error {
40202
40208
  this.resendSafe = resendSafe;
40203
40209
  }
40204
40210
  }
40211
+ var STOP_GATE = {
40212
+ subscribe: "refused",
40213
+ unsubscribe: "refused",
40214
+ getInterest: "refused",
40215
+ setRole: "refused",
40216
+ getRole: "refused",
40217
+ unregisterSession: "sent",
40218
+ handBack: "sent",
40219
+ send: "sent",
40220
+ publish: "sent",
40221
+ listSessions: "sent"
40222
+ };
40223
+
40224
+ class EnvoyStoppingError extends Error {
40225
+ call;
40226
+ name = "EnvoyStoppingError";
40227
+ constructor(call, method, url) {
40228
+ super(`this session is stopping, so it sends the listener nothing: ${method} ${url} was not sent`);
40229
+ this.call = call;
40230
+ }
40231
+ }
40232
+ var handBacks = new WeakMap;
40205
40233
  function resolveCallTiming(config) {
40206
40234
  return {
40207
40235
  timeoutMs: config.timeoutMs ?? LISTENER_CALL_TIMEOUT_MS,
@@ -40225,7 +40253,9 @@ function createEnvoyClient(config) {
40225
40253
  }
40226
40254
  };
40227
40255
  const noAnswer = (method, url, error) => new Error(`${method ?? "GET"} ${shown(url)} got no answer: ${errorClass(error)}`);
40228
- const attemptOnce = async (url, init, deadlineMs, actingSession) => {
40256
+ const attemptOnce = async (url, init, deadlineMs, actingSession, refusedByStop) => {
40257
+ if (refusedByStop())
40258
+ return { stopping: true };
40229
40259
  let response;
40230
40260
  let unminted;
40231
40261
  const deadline = AbortSignal.timeout(deadlineMs);
@@ -40241,6 +40271,8 @@ function createEnvoyClient(config) {
40241
40271
  }
40242
40272
  if (unminted !== undefined && deadline.aborted)
40243
40273
  return { notSent: unminted };
40274
+ if (refusedByStop())
40275
+ return { stopping: true };
40244
40276
  sent.note(presented);
40245
40277
  for (const [name, value] of Object.entries(presented ?? {}))
40246
40278
  headers.set(name, value);
@@ -40268,59 +40300,70 @@ function createEnvoyClient(config) {
40268
40300
  return { unanswered: noAnswer(init.method, url, error) };
40269
40301
  }
40270
40302
  };
40271
- const request = async (path, init, options = {}) => {
40303
+ const request = async (call, path, init, options = {}) => {
40272
40304
  const url = `${baseUrl}${path}`;
40273
40305
  const tries = options.retry === false ? 1 : attempts;
40306
+ const gated = STOP_GATE[call] === "refused";
40307
+ const refusedByStop = () => gated && config.stopping?.() === true;
40308
+ let busUnanswered;
40309
+ let sent = false;
40274
40310
  let unanswered = false;
40311
+ let lastEnd;
40275
40312
  for (let attempt = 0;attempt < tries; attempt += 1) {
40276
40313
  options.onAttempt?.();
40277
- const outcome = await attemptOnce(url, init, options.timeoutMs ?? timeoutMs, options.actingSession);
40314
+ const outcome = await attemptOnce(url, init, options.timeoutMs ?? timeoutMs, options.actingSession, refusedByStop);
40315
+ if ("stopping" in outcome) {
40316
+ if (sent && lastEnd !== undefined)
40317
+ throw lastEnd();
40318
+ throw new EnvoyStoppingError(call, init.method ?? "GET", shown(url));
40319
+ }
40320
+ let end;
40278
40321
  if ("unanswered" in outcome) {
40279
40322
  unanswered = true;
40280
40323
  options.onUnanswered?.();
40281
- if (attempt + 1 < tries) {
40282
- await waitForRetry(retryDelayMs);
40283
- continue;
40284
- }
40285
- throw outcome.unanswered;
40286
- }
40287
- if ("notSent" in outcome) {
40288
- if (attempt + 1 < tries) {
40289
- await waitForRetry(retryDelayMs);
40290
- continue;
40291
- }
40292
- options.onNotSent?.();
40293
- throw outcome.notSent;
40294
- }
40295
- const { response, body } = outcome;
40296
- if (response.ok)
40297
- return body;
40298
- const redacted = tokens();
40299
- const error = new EnvoyApiError({
40300
- method: init.method ?? "GET",
40301
- url: shown(url),
40302
- status: response.status,
40303
- responseBody: body
40304
- }, {
40305
- tokens: redacted,
40306
- redirectTo: redirectOrigin(response, url, redacted),
40307
- afterUnanswered: unanswered
40308
- });
40309
- if (mayHaveReachedServer(response.status)) {
40324
+ sent = true;
40325
+ end = () => busUnanswered ?? outcome.unanswered;
40326
+ } else if ("notSent" in outcome) {
40327
+ end = () => {
40328
+ options.onNotSent?.();
40329
+ return busUnanswered ?? outcome.notSent;
40330
+ };
40331
+ } else {
40332
+ const { response, body } = outcome;
40333
+ if (response.ok)
40334
+ return body;
40335
+ const redacted = tokens();
40336
+ const error = new EnvoyApiError({
40337
+ method: init.method ?? "GET",
40338
+ url: shown(url),
40339
+ status: response.status,
40340
+ responseBody: body
40341
+ }, {
40342
+ tokens: redacted,
40343
+ redirectTo: redirectOrigin(response, url, redacted),
40344
+ afterUnanswered: unanswered
40345
+ });
40346
+ if (!mayHaveReachedServer(response.status))
40347
+ throw error;
40310
40348
  if (!error.notSent) {
40311
40349
  unanswered = true;
40312
40350
  options.onUnanswered?.();
40351
+ sent = true;
40313
40352
  }
40314
- if (attempt + 1 < tries) {
40315
- await waitForRetry(retryDelayMs);
40316
- continue;
40317
- }
40353
+ if (options.busUnansweredStands === true && isBusUnanswered(error))
40354
+ busUnanswered = error;
40355
+ end = () => error.reason === undefined ? busUnanswered ?? error : error;
40318
40356
  }
40319
- throw error;
40357
+ lastEnd = end;
40358
+ if (attempt + 1 < tries) {
40359
+ await waitForRetry(retryDelayMs);
40360
+ continue;
40361
+ }
40362
+ throw end();
40320
40363
  }
40321
40364
  throw new Error("Envoy request exhausted retries");
40322
40365
  };
40323
- const post = (path, body, options) => request(path, {
40366
+ const post = (call, path, body, options) => request(call, path, {
40324
40367
  method: "POST",
40325
40368
  headers: {
40326
40369
  "Content-Type": "application/json",
@@ -40344,16 +40387,17 @@ function createEnvoyClient(config) {
40344
40387
  plugin: input.plugin.name,
40345
40388
  plugin_version: input.plugin.version
40346
40389
  });
40347
- return {
40348
- subscribe: async (input) => parseSubscribeAnswer(answerJson(await post("/v1/interests/subscribe", subscribeBody(input), { actingSession: input.sessionID }), "POST", "/v1/interests/subscribe")),
40349
- unsubscribe: async (input) => {
40350
- await post("/v1/interests/unsubscribe", {
40351
- session_id: input.sessionID,
40352
- topics: expandSubscriptionTopics(input.topics),
40353
- ...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID }
40354
- }, { actingSession: input.sessionID });
40355
- },
40356
- getInterest: async (sessionID) => InterestWireSchema.parse(answerJson(await request(`/v1/interests/${sessionID}`, {}), "GET", `/v1/interests/${sessionID}`)),
40390
+ const removeTopics = async (call, input) => {
40391
+ await post(call, "/v1/interests/unsubscribe", {
40392
+ session_id: input.sessionID,
40393
+ topics: expandSubscriptionTopics(input.topics),
40394
+ ...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID }
40395
+ }, { actingSession: input.sessionID, busUnansweredStands: true });
40396
+ };
40397
+ const client = {
40398
+ subscribe: async (input) => parseSubscribeAnswer(answerJson(await post("subscribe", "/v1/interests/subscribe", subscribeBody(input), { actingSession: input.sessionID, busUnansweredStands: true }), "POST", "/v1/interests/subscribe")),
40399
+ unsubscribe: (input) => removeTopics("unsubscribe", input),
40400
+ getInterest: async (sessionID) => InterestWireSchema.parse(answerJson(await request("getInterest", `/v1/interests/${sessionID}`, {}), "GET", `/v1/interests/${sessionID}`)),
40357
40401
  send: async (input) => {
40358
40402
  const idempotencyKey = input.idempotencyKey ?? crypto.randomUUID();
40359
40403
  let unanswered = false;
@@ -40361,7 +40405,7 @@ function createEnvoyClient(config) {
40361
40405
  let made = 0;
40362
40406
  let response;
40363
40407
  try {
40364
- const answer = await post("/v1/messages/send", {
40408
+ const answer = await post("send", "/v1/messages/send", {
40365
40409
  source: input.source ?? "agent",
40366
40410
  ...sourceSession(input.sourceSessionID),
40367
40411
  target_session: input.targetSessionID,
@@ -40391,19 +40435,24 @@ function createEnvoyClient(config) {
40391
40435
  throw error;
40392
40436
  throw new EnvoySendUnconfirmedError(input.targetSessionID, idempotencyKey, made, error);
40393
40437
  }
40394
- return {
40438
+ const stored = {
40395
40439
  envelope: response,
40396
40440
  recipient: response.recipient ?? input.targetSessionID,
40397
40441
  confirmed: response.recipient !== undefined,
40398
- recipientState: response.recipient_state ?? "live",
40399
- state: response.state === "stopped" ? "stopped" : "connected",
40400
40442
  ...lastSeenOf(response.last_seen),
40401
40443
  duplicate: response.duplicate === true
40402
40444
  };
40445
+ if (response.state === "no_receiver")
40446
+ return { ...stored, state: "no_receiver" };
40447
+ return {
40448
+ ...stored,
40449
+ recipientState: response.recipient_state ?? "live",
40450
+ state: response.state === "stopped" ? "stopped" : "connected"
40451
+ };
40403
40452
  },
40404
40453
  publish: async (input) => {
40405
40454
  const idempotencyKey = input.idempotencyKey ?? crypto.randomUUID();
40406
- const raw = answerJson(await post("/v1/messages/publish", {
40455
+ const raw = answerJson(await post("publish", "/v1/messages/publish", {
40407
40456
  source: input.source ?? "agent",
40408
40457
  ...sourceSession(input.sourceSessionID),
40409
40458
  topic: input.topic,
@@ -40431,7 +40480,7 @@ function createEnvoyClient(config) {
40431
40480
  },
40432
40481
  unregisterSession: async (input) => {
40433
40482
  const query = input.clientInstanceID === undefined ? "" : `?client_instance_id=${encodeURIComponent(input.clientInstanceID)}`;
40434
- await request(`/v1/sessions/${encodeURIComponent(input.sessionID)}${query}`, { method: "DELETE" }, {
40483
+ await request("unregisterSession", `/v1/sessions/${encodeURIComponent(input.sessionID)}${query}`, { method: "DELETE" }, {
40435
40484
  actingSession: input.sessionID,
40436
40485
  ...input.timeoutMs === undefined ? {} : { timeoutMs: Math.max(1, input.timeoutMs), retry: false }
40437
40486
  });
@@ -40448,7 +40497,7 @@ function createEnvoyClient(config) {
40448
40497
  };
40449
40498
  let raw;
40450
40499
  try {
40451
- raw = await post("/v1/roles/set", body, { actingSession: input.sessionID });
40500
+ raw = await post("setRole", "/v1/roles/set", body, { actingSession: input.sessionID });
40452
40501
  } catch (error) {
40453
40502
  if (error instanceof EnvoyApiError && error.details.status === 409) {
40454
40503
  let answer;
@@ -40466,7 +40515,7 @@ function createEnvoyClient(config) {
40466
40515
  const { warnings, ...interest } = RoleSetWireSchema.parse(answerJson(raw, "POST", "/v1/roles/set"));
40467
40516
  return { claimed: true, interest, warnings };
40468
40517
  },
40469
- getRole: async (role) => RoleWireSchema.parse(answerJson(await request(`/v1/roles/${encodeURIComponent(role)}`, { method: "GET" }), "GET", `/v1/roles/${encodeURIComponent(role)}`)),
40518
+ getRole: async (role) => RoleWireSchema.parse(answerJson(await request("getRole", `/v1/roles/${encodeURIComponent(role)}`, { method: "GET" }), "GET", `/v1/roles/${encodeURIComponent(role)}`)),
40470
40519
  listSessions: async (input = {}) => {
40471
40520
  const search = new URLSearchParams;
40472
40521
  if (input.directory !== undefined)
@@ -40476,9 +40525,11 @@ function createEnvoyClient(config) {
40476
40525
  if (input.include !== undefined)
40477
40526
  search.set("include", input.include);
40478
40527
  const query = search.size === 0 ? "" : `?${search.toString()}`;
40479
- return SessionWireSchema.array().parse(answerJson(await request(`/v1/sessions${query}`, {}), "GET", `/v1/sessions${query}`));
40528
+ return SessionWireSchema.array().parse(answerJson(await request("listSessions", `/v1/sessions${query}`, {}), "GET", `/v1/sessions${query}`));
40480
40529
  }
40481
40530
  };
40531
+ handBacks.set(client, (input) => removeTopics("handBack", input));
40532
+ return client;
40482
40533
  }
40483
40534
  function waitForRetry(delayMs) {
40484
40535
  const { promise, resolve } = Promise.withResolvers();