@sjawhar/claude-envoy 2.31.0 → 2.31.2

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": "2.31.0"
5
+ "version": "2.31.2"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "2.31.0",
3
+ "version": "2.31.2",
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/dist/dispatch.js CHANGED
@@ -1020,6 +1020,20 @@ function messageFor(error) {
1020
1020
  function hasErrnoCode(error, code) {
1021
1021
  return error instanceof Error && "code" in error && error.code === code;
1022
1022
  }
1023
+ function withoutUserinfo(url) {
1024
+ let parsed;
1025
+ try {
1026
+ parsed = new URL(url);
1027
+ } catch {
1028
+ return url.slice(url.lastIndexOf("@") + 1);
1029
+ }
1030
+ if (parsed.username === "" && parsed.password === "")
1031
+ return url;
1032
+ parsed.username = "";
1033
+ parsed.password = "";
1034
+ const shown = parsed.toString();
1035
+ return shown.endsWith("/") && !url.endsWith("/") ? shown.slice(0, -1) : shown;
1036
+ }
1023
1037
 
1024
1038
  // ../envoy-client/src/askgate-marker.ts
1025
1039
  var ASKGATE_RECORD = "askgate";
@@ -18484,7 +18498,8 @@ class DispatchWriteLandedError extends Error {
18484
18498
  name = "DispatchWriteLandedError";
18485
18499
  constructor(code, status, method, url) {
18486
18500
  const lost = code === IDEMPOTENCY_ANSWER_NOT_KEPT ? "Dispatch kept no copy of its answer, which was too large" : "its answer was lost on the way back";
18487
- super(`${method} ${url} was made, but ${lost} (${code}), so this command cannot print what it ` + "made: read it back with `dispatch read`, or with the matching list for something it created.");
18501
+ const request = `${method} ${withoutUserinfo(url)}`;
18502
+ super(`${request} was made, but ${lost} (${code}), so this command cannot print what it ` + "made: read it back with `dispatch read`, or with the matching list for something it created.");
18488
18503
  this.code = code;
18489
18504
  this.status = status;
18490
18505
  }
@@ -18505,7 +18520,8 @@ class DispatchNoRouteError extends DispatchServiceError {
18505
18520
  }
18506
18521
  }
18507
18522
  function reviewNoRouteRefusal(baseUrl, route, version) {
18508
- return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${baseUrl} answered no route for ${route} each time the review was sent, and an ` + "answer of no route records no review. This build is older than that route. No other review " + "route was asked: the review route an older build serves takes no version, and it " + `would record the review at a version that build chooses, which may not be version ${version}. ` + `The no-route answer does not name the build; GET ${baseUrl}/healthz names the commit of the ` + "build that answers it, when that build was stamped with one.");
18523
+ const shown = withoutUserinfo(baseUrl);
18524
+ return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${shown} answered no route for ${route} each time the review was sent, and an ` + "answer of no route records no review. This build is older than that route. No other review " + "route was asked: the review route an older build serves takes no version, and it " + `would record the review at a version that build chooses, which may not be version ${version}. ` + `The no-route answer does not name the build; GET ${shown}/healthz names the commit of the ` + "build that answers it, when that build was stamped with one.");
18509
18525
  }
18510
18526
  var ISSUE_EVENTS_PAGE_MAX = 200;
18511
18527
  var DISPATCH_TOOL_DEADLINE_MS = 60000;
@@ -18767,7 +18783,8 @@ class DispatchClient {
18767
18783
  const refusal = whyNotAPage(answer);
18768
18784
  if (refusal === undefined)
18769
18785
  return answer;
18770
- throw new Error(`GET ${this.#url(path, query)} asked for a page ({issues, total, limit, offset}) and got ` + refusal);
18786
+ const url = withoutUserinfo(this.#url(path, query));
18787
+ throw new Error(`GET ${url} asked for a page ({issues, total, limit, offset}) and got ${refusal}`);
18771
18788
  }
18772
18789
  async listAllIssues(options) {
18773
18790
  const path = ["api", "v1", "issues"];
@@ -18775,7 +18792,8 @@ class DispatchClient {
18775
18792
  const answer = await this.#json("GET", path, undefined, query);
18776
18793
  if (Array.isArray(answer))
18777
18794
  return answer;
18778
- throw new Error(`GET ${this.#url(path, query)} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
18795
+ const url = withoutUserinfo(this.#url(path, query));
18796
+ throw new Error(`GET ${url} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
18779
18797
  }
18780
18798
  async listIssueArtifacts(issue) {
18781
18799
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
@@ -19242,7 +19260,7 @@ class DispatchClient {
19242
19260
  headers[IDEMPOTENCY_KEY_HEADER] = key;
19243
19261
  const { pausesMs, withinMs, silenceMs, inFlightPauseMs, inFlightWithinMs } = this.writeRetry;
19244
19262
  const pause = this.writeRetry.pause ?? pauseFor;
19245
- const request = `${method} ${url}`;
19263
+ const request = `${method} ${withoutUserinfo(url)}`;
19246
19264
  const started = this.#now();
19247
19265
  const bodyBytes = body === undefined ? 0 : typeof body.content === "string" ? Buffer.byteLength(body.content) : body.content.byteLength;
19248
19266
  const upload = bodyBytes >= STREAMED_BODY_MIN;
@@ -19425,7 +19443,8 @@ class DispatchClient {
19425
19443
  }
19426
19444
  const reasonPhrase = excerpt(response.statusText, this.token);
19427
19445
  const reason = reasonPhrase === "" ? "" : ` ${reasonPhrase}`;
19428
- throw new DispatchGatewayError(response.status, `${method} ${url} answered ${response.status}${reason} with ${body}, ${GATEWAY_PAGE}`, gatewayAdvice(method, response.status));
19446
+ const request = `${method} ${withoutUserinfo(url)}`;
19447
+ throw new DispatchGatewayError(response.status, `${request} answered ${response.status}${reason} with ${body}, ${GATEWAY_PAGE}`, gatewayAdvice(method, response.status));
19429
19448
  }
19430
19449
  const replayed = response.headers.get(IDEMPOTENCY_REPLAYED_HEADER)?.trim() === "?1";
19431
19450
  if (answerNotKept(response.status, replayed, payload)) {
@@ -19498,7 +19517,8 @@ function asObject(value) {
19498
19517
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
19499
19518
  }
19500
19519
  function sessionContext(input, checked) {
19501
- const { url: configUrl, credential } = input.config;
19520
+ const { url, credential } = input.config;
19521
+ const configUrl = withoutUserinfo(url);
19502
19522
  const baseFetch = input.fetchImpl ?? fetch;
19503
19523
  const fetchImpl = Object.assign(async (...args) => {
19504
19524
  try {
@@ -19516,9 +19536,9 @@ function sessionContext(input, checked) {
19516
19536
  ownerArguments: checked.owner,
19517
19537
  pictures: checked.pictures,
19518
19538
  configUrl,
19519
- linkBase: input.config.publicUrl ?? configUrl,
19539
+ linkBase: withoutUserinfo(input.config.publicUrl ?? url),
19520
19540
  hostSession: input.sessionId?.trim(),
19521
- newClient: () => new DispatchClient(configUrl, credential, fetchImpl, {
19541
+ newClient: () => new DispatchClient(url, credential, fetchImpl, {
19522
19542
  signal: input.signal,
19523
19543
  writeRetry: input.writeRetry,
19524
19544
  sleep: input.sleep
@@ -22965,6 +22985,7 @@ function openAskLine(ask, baseUrl) {
22965
22985
  return `- ${openAskAge(ask.age_seconds)} \xB7 ${priority}${ownerTitle(ask.owner)} \xB7 asked of ${waitsOnPerson(ask) ?? "nobody"} \xB7 ${ask.question} \xB7 ${new URL(ask.ref, baseUrl).toString()}`;
22966
22986
  }
22967
22987
  function formatOpenAsksSummary(response, baseUrl) {
22988
+ const linkBase = withoutUserinfo(baseUrl);
22968
22989
  const scope = "active open asks you authored on open issues and project documents";
22969
22990
  if (response.count === 0) {
22970
22991
  return ["There are no unanswered asks for this session.", `Scope: ${scope}.`].join(`
@@ -22976,10 +22997,10 @@ function formatOpenAsksSummary(response, baseUrl) {
22976
22997
  `${response.count} unanswered ${response.count === 1 ? "ask" : "asks"} you authored on active issues and project documents.`,
22977
22998
  "",
22978
22999
  `Waiting on human (${waitingOnHuman.length}):`,
22979
- ...waitingOnHuman.map((ask) => openAskLine(ask, baseUrl)),
23000
+ ...waitingOnHuman.map((ask) => openAskLine(ask, linkBase)),
22980
23001
  "",
22981
23002
  `Waiting on agent (${waitingOnAgent.length}):`,
22982
- ...waitingOnAgent.map((ask) => openAskLine(ask, baseUrl))
23003
+ ...waitingOnAgent.map((ask) => openAskLine(ask, linkBase))
22983
23004
  ].join(`
22984
23005
  `);
22985
23006
  }
@@ -25587,6 +25608,12 @@ function withinWindow(items, now) {
25587
25608
  const start = now - SESSION_ANSWERS_WINDOW_MS;
25588
25609
  return items.filter((item) => Date.parse(item.at) >= start);
25589
25610
  }
25611
+ function windowOf(items, now) {
25612
+ return {
25613
+ words: sessionAnswersWords(withinWindow(items, now)),
25614
+ since: new Date(now - SESSION_ANSWERS_WINDOW_MS).toISOString()
25615
+ };
25616
+ }
25590
25617
  function sessionAnswersWords(items) {
25591
25618
  return items.map((item) => JSON.stringify([
25592
25619
  item.kind,
@@ -25603,7 +25630,7 @@ function leftOutLine(count, namesCommand) {
25603
25630
  const counted = `${count} older ${count === 1 ? "item" : "items"} left out to stay under ${MAX_CHARS_TEXT} characters`;
25604
25631
  return namesCommand ? `${counted}: run \`dispatch answers\` to read every one in full.` : `${counted}.`;
25605
25632
  }
25606
- function renderShown(items, options) {
25633
+ function renderSessionAnswers(items, options) {
25607
25634
  const inWindow = withinWindow(items, Number(options.now));
25608
25635
  const unsent = inWindow.length === items.length ? Math.max(0, (options.total ?? items.length) - items.length) : 0;
25609
25636
  const count = inWindow.length + unsent;
@@ -25631,7 +25658,7 @@ As read at ${options.cached.readAt}; this read failed: ${failureSentence(options
25631
25658
  ].join(`
25632
25659
 
25633
25660
  `);
25634
- return { text, shown: inWindow.slice(0, blocks.length) };
25661
+ return text;
25635
25662
  }
25636
25663
  function renderSessionAnswersList(items, options) {
25637
25664
  const shown = withinWindow(items, Number(options.now));
@@ -25704,24 +25731,19 @@ async function readSessionAnswers(options) {
25704
25731
  const entries = state.sessions.get(session) ?? new Map;
25705
25732
  state.sessions.set(session, entries);
25706
25733
  const carry = (cache, reason, noRoute = false) => {
25707
- const rendered = cache === undefined ? undefined : renderShown(cache.items, {
25708
- now: now(),
25734
+ const at = now();
25735
+ const text = cache === undefined ? undefined : renderSessionAnswers(cache.items, {
25736
+ now: at,
25709
25737
  total: cache.total,
25710
25738
  cached: { readAt: cache.read_at, reason },
25711
25739
  withoutCommand: noRoute
25712
25740
  });
25713
- if (cache === undefined || rendered === undefined) {
25741
+ if (cache === undefined || text === undefined) {
25714
25742
  if (noRoute)
25715
25743
  return { text: undefined, source: "unavailable", reason };
25716
25744
  return { text: sessionAnswersFailureLine(reason), source: "failure", reason };
25717
25745
  }
25718
- return {
25719
- text: rendered.text,
25720
- source: "cache",
25721
- readAt: cache.read_at,
25722
- words: sessionAnswersWords(rendered.shown),
25723
- reason
25724
- };
25746
+ return { text, source: "cache", readAt: cache.read_at, ...windowOf(cache.items, at), reason };
25725
25747
  };
25726
25748
  if (!dispatch.enabled) {
25727
25749
  const url = options.dispatchUrl;
@@ -25748,7 +25770,7 @@ async function readSessionAnswers(options) {
25748
25770
  current.noRouteReported = true;
25749
25771
  return {
25750
25772
  ...read,
25751
- notice: `Dispatch at ${url} has no answers route (its build is older than the route), so people's answers cannot be read from it`
25773
+ notice: `Dispatch at ${withoutUserinfo(url)} has no answers route (its build is older than the route), so people's answers cannot be read from it`
25752
25774
  };
25753
25775
  };
25754
25776
  if ((state.noRouteUntil.get(url) ?? 0) > now())
@@ -25762,6 +25784,7 @@ async function readSessionAnswers(options) {
25762
25784
  retryNoRoute: false
25763
25785
  });
25764
25786
  const started = client.sessionAnswers(session, {
25787
+ since: new Date(now() - SESSION_ANSWERS_WINDOW_MS).toISOString(),
25765
25788
  maxChars: SESSION_ANSWERS_MAX_CHARS,
25766
25789
  signal: AbortSignal.timeout(READ_TIMEOUT_MS)
25767
25790
  }).then((response) => {
@@ -25813,12 +25836,12 @@ async function readSessionAnswers(options) {
25813
25836
  return noRoute();
25814
25837
  if ("failure" in outcome)
25815
25838
  return carry(current.cache, outcome.failure);
25816
- const rendered = renderShown(outcome.cache.items, { now: now(), total: outcome.cache.total });
25839
+ const at = now();
25817
25840
  return {
25818
- text: rendered?.text,
25841
+ text: renderSessionAnswers(outcome.cache.items, { now: at, total: outcome.cache.total }),
25819
25842
  source: "fresh",
25820
25843
  readAt: outcome.cache.read_at,
25821
- words: sessionAnswersWords(rendered?.shown ?? [])
25844
+ ...windowOf(outcome.cache.items, at)
25822
25845
  };
25823
25846
  }
25824
25847
  async function sessionAnswersSettled(session) {
@@ -30578,7 +30601,7 @@ function createEnvoyClient(config) {
30578
30601
  }
30579
30602
  if (unminted !== undefined && (response.status === 401 || response.status === 403)) {
30580
30603
  return {
30581
- unanswered: new Error(`${init.method ?? "GET"} ${url} answered ${response.status}, and this machine's Envoy credential could not be minted: ${messageFor(unminted)}`, { cause: unminted })
30604
+ unanswered: new Error(`${init.method ?? "GET"} ${withoutUserinfo(url)} answered ${response.status}, and this machine's Envoy credential could not be minted: ${messageFor(unminted)}`, { cause: unminted })
30582
30605
  };
30583
30606
  }
30584
30607
  try {
@@ -30608,7 +30631,7 @@ function createEnvoyClient(config) {
30608
30631
  return body;
30609
30632
  const error = new EnvoyApiError({
30610
30633
  method: init.method ?? "GET",
30611
- url,
30634
+ url: withoutUserinfo(url),
30612
30635
  status: response.status,
30613
30636
  responseBody: body
30614
30637
  });
@@ -43213,6 +43213,20 @@ function messageFor(error) {
43213
43213
  function hasErrnoCode(error, code) {
43214
43214
  return error instanceof Error && "code" in error && error.code === code;
43215
43215
  }
43216
+ function withoutUserinfo(url) {
43217
+ let parsed;
43218
+ try {
43219
+ parsed = new URL(url);
43220
+ } catch {
43221
+ return url.slice(url.lastIndexOf("@") + 1);
43222
+ }
43223
+ if (parsed.username === "" && parsed.password === "")
43224
+ return url;
43225
+ parsed.username = "";
43226
+ parsed.password = "";
43227
+ const shown = parsed.toString();
43228
+ return shown.endsWith("/") && !url.endsWith("/") ? shown.slice(0, -1) : shown;
43229
+ }
43216
43230
 
43217
43231
  // ../envoy-client/src/dispatch-command.ts
43218
43232
  var STDIN = "-";
@@ -43799,7 +43813,8 @@ class DispatchWriteLandedError extends Error {
43799
43813
  name = "DispatchWriteLandedError";
43800
43814
  constructor(code, status, method, url) {
43801
43815
  const lost = code === IDEMPOTENCY_ANSWER_NOT_KEPT ? "Dispatch kept no copy of its answer, which was too large" : "its answer was lost on the way back";
43802
- super(`${method} ${url} was made, but ${lost} (${code}), so this command cannot print what it ` + "made: read it back with `dispatch read`, or with the matching list for something it created.");
43816
+ const request = `${method} ${withoutUserinfo(url)}`;
43817
+ super(`${request} was made, but ${lost} (${code}), so this command cannot print what it ` + "made: read it back with `dispatch read`, or with the matching list for something it created.");
43803
43818
  this.code = code;
43804
43819
  this.status = status;
43805
43820
  }
@@ -43820,7 +43835,8 @@ class DispatchNoRouteError extends DispatchServiceError {
43820
43835
  }
43821
43836
  }
43822
43837
  function reviewNoRouteRefusal(baseUrl, route, version) {
43823
- return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${baseUrl} answered no route for ${route} each time the review was sent, and an ` + "answer of no route records no review. This build is older than that route. No other review " + "route was asked: the review route an older build serves takes no version, and it " + `would record the review at a version that build chooses, which may not be version ${version}. ` + `The no-route answer does not name the build; GET ${baseUrl}/healthz names the commit of the ` + "build that answers it, when that build was stamped with one.");
43838
+ const shown = withoutUserinfo(baseUrl);
43839
+ return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${shown} answered no route for ${route} each time the review was sent, and an ` + "answer of no route records no review. This build is older than that route. No other review " + "route was asked: the review route an older build serves takes no version, and it " + `would record the review at a version that build chooses, which may not be version ${version}. ` + `The no-route answer does not name the build; GET ${shown}/healthz names the commit of the ` + "build that answers it, when that build was stamped with one.");
43824
43840
  }
43825
43841
  var ISSUE_EVENTS_PAGE_MAX = 200;
43826
43842
  var DISPATCH_TOOL_DEADLINE_MS = 60000;
@@ -44082,7 +44098,8 @@ class DispatchClient {
44082
44098
  const refusal = whyNotAPage(answer);
44083
44099
  if (refusal === undefined)
44084
44100
  return answer;
44085
- throw new Error(`GET ${this.#url(path, query)} asked for a page ({issues, total, limit, offset}) and got ` + refusal);
44101
+ const url = withoutUserinfo(this.#url(path, query));
44102
+ throw new Error(`GET ${url} asked for a page ({issues, total, limit, offset}) and got ${refusal}`);
44086
44103
  }
44087
44104
  async listAllIssues(options) {
44088
44105
  const path = ["api", "v1", "issues"];
@@ -44090,7 +44107,8 @@ class DispatchClient {
44090
44107
  const answer = await this.#json("GET", path, undefined, query);
44091
44108
  if (Array.isArray(answer))
44092
44109
  return answer;
44093
- throw new Error(`GET ${this.#url(path, query)} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
44110
+ const url = withoutUserinfo(this.#url(path, query));
44111
+ throw new Error(`GET ${url} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
44094
44112
  }
44095
44113
  async listIssueArtifacts(issue) {
44096
44114
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
@@ -44557,7 +44575,7 @@ class DispatchClient {
44557
44575
  headers[IDEMPOTENCY_KEY_HEADER] = key;
44558
44576
  const { pausesMs, withinMs, silenceMs, inFlightPauseMs, inFlightWithinMs } = this.writeRetry;
44559
44577
  const pause = this.writeRetry.pause ?? pauseFor;
44560
- const request = `${method} ${url}`;
44578
+ const request = `${method} ${withoutUserinfo(url)}`;
44561
44579
  const started = this.#now();
44562
44580
  const bodyBytes = body === undefined ? 0 : typeof body.content === "string" ? Buffer.byteLength(body.content) : body.content.byteLength;
44563
44581
  const upload = bodyBytes >= STREAMED_BODY_MIN;
@@ -44740,7 +44758,8 @@ class DispatchClient {
44740
44758
  }
44741
44759
  const reasonPhrase = excerpt(response.statusText, this.token);
44742
44760
  const reason = reasonPhrase === "" ? "" : ` ${reasonPhrase}`;
44743
- throw new DispatchGatewayError(response.status, `${method} ${url} answered ${response.status}${reason} with ${body}, ${GATEWAY_PAGE}`, gatewayAdvice(method, response.status));
44761
+ const request = `${method} ${withoutUserinfo(url)}`;
44762
+ throw new DispatchGatewayError(response.status, `${request} answered ${response.status}${reason} with ${body}, ${GATEWAY_PAGE}`, gatewayAdvice(method, response.status));
44744
44763
  }
44745
44764
  const replayed = response.headers.get(IDEMPOTENCY_REPLAYED_HEADER)?.trim() === "?1";
44746
44765
  if (answerNotKept(response.status, replayed, payload)) {
@@ -46371,7 +46390,7 @@ function createEnvoyClient(config) {
46371
46390
  }
46372
46391
  if (unminted !== undefined && (response.status === 401 || response.status === 403)) {
46373
46392
  return {
46374
- unanswered: new Error(`${init.method ?? "GET"} ${url} answered ${response.status}, and this machine's Envoy credential could not be minted: ${messageFor(unminted)}`, { cause: unminted })
46393
+ unanswered: new Error(`${init.method ?? "GET"} ${withoutUserinfo(url)} answered ${response.status}, and this machine's Envoy credential could not be minted: ${messageFor(unminted)}`, { cause: unminted })
46375
46394
  };
46376
46395
  }
46377
46396
  try {
@@ -46401,7 +46420,7 @@ function createEnvoyClient(config) {
46401
46420
  return body;
46402
46421
  const error = new EnvoyApiError({
46403
46422
  method: init.method ?? "GET",
46404
- url,
46423
+ url: withoutUserinfo(url),
46405
46424
  status: response.status,
46406
46425
  responseBody: body
46407
46426
  });
@@ -48616,7 +48635,8 @@ function asObject(value) {
48616
48635
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
48617
48636
  }
48618
48637
  function sessionContext(input, checked) {
48619
- const { url: configUrl, credential } = input.config;
48638
+ const { url, credential } = input.config;
48639
+ const configUrl = withoutUserinfo(url);
48620
48640
  const baseFetch = input.fetchImpl ?? fetch;
48621
48641
  const fetchImpl = Object.assign(async (...args) => {
48622
48642
  try {
@@ -48634,9 +48654,9 @@ function sessionContext(input, checked) {
48634
48654
  ownerArguments: checked.owner,
48635
48655
  pictures: checked.pictures,
48636
48656
  configUrl,
48637
- linkBase: input.config.publicUrl ?? configUrl,
48657
+ linkBase: withoutUserinfo(input.config.publicUrl ?? url),
48638
48658
  hostSession: input.sessionId?.trim(),
48639
- newClient: () => new DispatchClient(configUrl, credential, fetchImpl, {
48659
+ newClient: () => new DispatchClient(url, credential, fetchImpl, {
48640
48660
  signal: input.signal,
48641
48661
  writeRetry: input.writeRetry,
48642
48662
  sleep: input.sleep
@@ -50094,6 +50114,7 @@ function openAskLine(ask, baseUrl) {
50094
50114
  return `- ${openAskAge(ask.age_seconds)} \xB7 ${priority}${ownerTitle(ask.owner)} \xB7 asked of ${waitsOnPerson(ask) ?? "nobody"} \xB7 ${ask.question} \xB7 ${new URL(ask.ref, baseUrl).toString()}`;
50095
50115
  }
50096
50116
  function formatOpenAsksSummary(response, baseUrl) {
50117
+ const linkBase = withoutUserinfo(baseUrl);
50097
50118
  const scope = "active open asks you authored on open issues and project documents";
50098
50119
  if (response.count === 0) {
50099
50120
  return ["There are no unanswered asks for this session.", `Scope: ${scope}.`].join(`
@@ -50105,10 +50126,10 @@ function formatOpenAsksSummary(response, baseUrl) {
50105
50126
  `${response.count} unanswered ${response.count === 1 ? "ask" : "asks"} you authored on active issues and project documents.`,
50106
50127
  "",
50107
50128
  `Waiting on human (${waitingOnHuman.length}):`,
50108
- ...waitingOnHuman.map((ask) => openAskLine(ask, baseUrl)),
50129
+ ...waitingOnHuman.map((ask) => openAskLine(ask, linkBase)),
50109
50130
  "",
50110
50131
  `Waiting on agent (${waitingOnAgent.length}):`,
50111
- ...waitingOnAgent.map((ask) => openAskLine(ask, baseUrl))
50132
+ ...waitingOnAgent.map((ask) => openAskLine(ask, linkBase))
50112
50133
  ].join(`
50113
50134
  `);
50114
50135
  }
@@ -52619,6 +52640,12 @@ function withinWindow(items, now) {
52619
52640
  const start = now - SESSION_ANSWERS_WINDOW_MS;
52620
52641
  return items.filter((item) => Date.parse(item.at) >= start);
52621
52642
  }
52643
+ function windowOf(items, now) {
52644
+ return {
52645
+ words: sessionAnswersWords(withinWindow(items, now)),
52646
+ since: new Date(now - SESSION_ANSWERS_WINDOW_MS).toISOString()
52647
+ };
52648
+ }
52622
52649
  function sessionAnswersWords(items) {
52623
52650
  return items.map((item) => JSON.stringify([
52624
52651
  item.kind,
@@ -52635,7 +52662,7 @@ function leftOutLine(count, namesCommand) {
52635
52662
  const counted = `${count} older ${count === 1 ? "item" : "items"} left out to stay under ${MAX_CHARS_TEXT} characters`;
52636
52663
  return namesCommand ? `${counted}: run \`dispatch answers\` to read every one in full.` : `${counted}.`;
52637
52664
  }
52638
- function renderShown(items, options) {
52665
+ function renderSessionAnswers(items, options) {
52639
52666
  const inWindow = withinWindow(items, Number(options.now));
52640
52667
  const unsent = inWindow.length === items.length ? Math.max(0, (options.total ?? items.length) - items.length) : 0;
52641
52668
  const count = inWindow.length + unsent;
@@ -52663,7 +52690,7 @@ As read at ${options.cached.readAt}; this read failed: ${failureSentence(options
52663
52690
  ].join(`
52664
52691
 
52665
52692
  `);
52666
- return { text, shown: inWindow.slice(0, blocks.length) };
52693
+ return text;
52667
52694
  }
52668
52695
  function renderSessionAnswersList(items, options) {
52669
52696
  const shown = withinWindow(items, Number(options.now));
@@ -52736,24 +52763,19 @@ async function readSessionAnswers(options) {
52736
52763
  const entries = state.sessions.get(session) ?? new Map;
52737
52764
  state.sessions.set(session, entries);
52738
52765
  const carry = (cache, reason, noRoute = false) => {
52739
- const rendered = cache === undefined ? undefined : renderShown(cache.items, {
52740
- now: now(),
52766
+ const at = now();
52767
+ const text = cache === undefined ? undefined : renderSessionAnswers(cache.items, {
52768
+ now: at,
52741
52769
  total: cache.total,
52742
52770
  cached: { readAt: cache.read_at, reason },
52743
52771
  withoutCommand: noRoute
52744
52772
  });
52745
- if (cache === undefined || rendered === undefined) {
52773
+ if (cache === undefined || text === undefined) {
52746
52774
  if (noRoute)
52747
52775
  return { text: undefined, source: "unavailable", reason };
52748
52776
  return { text: sessionAnswersFailureLine(reason), source: "failure", reason };
52749
52777
  }
52750
- return {
52751
- text: rendered.text,
52752
- source: "cache",
52753
- readAt: cache.read_at,
52754
- words: sessionAnswersWords(rendered.shown),
52755
- reason
52756
- };
52778
+ return { text, source: "cache", readAt: cache.read_at, ...windowOf(cache.items, at), reason };
52757
52779
  };
52758
52780
  if (!dispatch.enabled) {
52759
52781
  const url = options.dispatchUrl;
@@ -52780,7 +52802,7 @@ async function readSessionAnswers(options) {
52780
52802
  current.noRouteReported = true;
52781
52803
  return {
52782
52804
  ...read,
52783
- notice: `Dispatch at ${url} has no answers route (its build is older than the route), so people's answers cannot be read from it`
52805
+ notice: `Dispatch at ${withoutUserinfo(url)} has no answers route (its build is older than the route), so people's answers cannot be read from it`
52784
52806
  };
52785
52807
  };
52786
52808
  if ((state.noRouteUntil.get(url) ?? 0) > now())
@@ -52794,6 +52816,7 @@ async function readSessionAnswers(options) {
52794
52816
  retryNoRoute: false
52795
52817
  });
52796
52818
  const started = client.sessionAnswers(session, {
52819
+ since: new Date(now() - SESSION_ANSWERS_WINDOW_MS).toISOString(),
52797
52820
  maxChars: SESSION_ANSWERS_MAX_CHARS,
52798
52821
  signal: AbortSignal.timeout(READ_TIMEOUT_MS)
52799
52822
  }).then((response) => {
@@ -52845,12 +52868,12 @@ async function readSessionAnswers(options) {
52845
52868
  return noRoute();
52846
52869
  if ("failure" in outcome)
52847
52870
  return carry(current.cache, outcome.failure);
52848
- const rendered = renderShown(outcome.cache.items, { now: now(), total: outcome.cache.total });
52871
+ const at = now();
52849
52872
  return {
52850
- text: rendered?.text,
52873
+ text: renderSessionAnswers(outcome.cache.items, { now: at, total: outcome.cache.total }),
52851
52874
  source: "fresh",
52852
52875
  readAt: outcome.cache.read_at,
52853
- words: sessionAnswersWords(rendered?.shown ?? [])
52876
+ ...windowOf(outcome.cache.items, at)
52854
52877
  };
52855
52878
  }
52856
52879
  async function sessionAnswersSettled(session) {
@@ -57425,7 +57448,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
57425
57448
 
57426
57449
  // package.json
57427
57450
  var name = "@sjawhar/claude-envoy";
57428
- var version2 = "2.31.0";
57451
+ var version2 = "2.31.2";
57429
57452
  var legion = {
57430
57453
  daemonApiVersion: 144
57431
57454
  };
@@ -16833,6 +16833,20 @@ function messageFor(error) {
16833
16833
  function hasErrnoCode(error, code) {
16834
16834
  return error instanceof Error && "code" in error && error.code === code;
16835
16835
  }
16836
+ function withoutUserinfo(url) {
16837
+ let parsed;
16838
+ try {
16839
+ parsed = new URL(url);
16840
+ } catch {
16841
+ return url.slice(url.lastIndexOf("@") + 1);
16842
+ }
16843
+ if (parsed.username === "" && parsed.password === "")
16844
+ return url;
16845
+ parsed.username = "";
16846
+ parsed.password = "";
16847
+ const shown = parsed.toString();
16848
+ return shown.endsWith("/") && !url.endsWith("/") ? shown.slice(0, -1) : shown;
16849
+ }
16836
16850
 
16837
16851
  // ../envoy-client/src/dispatch-command.ts
16838
16852
  var STDIN = "-";
@@ -18207,7 +18221,8 @@ class DispatchWriteLandedError extends Error {
18207
18221
  name = "DispatchWriteLandedError";
18208
18222
  constructor(code, status, method, url) {
18209
18223
  const lost = code === IDEMPOTENCY_ANSWER_NOT_KEPT ? "Dispatch kept no copy of its answer, which was too large" : "its answer was lost on the way back";
18210
- super(`${method} ${url} was made, but ${lost} (${code}), so this command cannot print what it ` + "made: read it back with `dispatch read`, or with the matching list for something it created.");
18224
+ const request = `${method} ${withoutUserinfo(url)}`;
18225
+ super(`${request} was made, but ${lost} (${code}), so this command cannot print what it ` + "made: read it back with `dispatch read`, or with the matching list for something it created.");
18211
18226
  this.code = code;
18212
18227
  this.status = status;
18213
18228
  }
@@ -18228,7 +18243,8 @@ class DispatchNoRouteError extends DispatchServiceError {
18228
18243
  }
18229
18244
  }
18230
18245
  function reviewNoRouteRefusal(baseUrl, route, version) {
18231
- return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${baseUrl} answered no route for ${route} each time the review was sent, and an ` + "answer of no route records no review. This build is older than that route. No other review " + "route was asked: the review route an older build serves takes no version, and it " + `would record the review at a version that build chooses, which may not be version ${version}. ` + `The no-route answer does not name the build; GET ${baseUrl}/healthz names the commit of the ` + "build that answers it, when that build was stamped with one.");
18246
+ const shown = withoutUserinfo(baseUrl);
18247
+ return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${shown} answered no route for ${route} each time the review was sent, and an ` + "answer of no route records no review. This build is older than that route. No other review " + "route was asked: the review route an older build serves takes no version, and it " + `would record the review at a version that build chooses, which may not be version ${version}. ` + `The no-route answer does not name the build; GET ${shown}/healthz names the commit of the ` + "build that answers it, when that build was stamped with one.");
18232
18248
  }
18233
18249
  var ISSUE_EVENTS_PAGE_MAX = 200;
18234
18250
  var DISPATCH_TOOL_DEADLINE_MS = 60000;
@@ -18490,7 +18506,8 @@ class DispatchClient {
18490
18506
  const refusal = whyNotAPage(answer);
18491
18507
  if (refusal === undefined)
18492
18508
  return answer;
18493
- throw new Error(`GET ${this.#url(path, query)} asked for a page ({issues, total, limit, offset}) and got ` + refusal);
18509
+ const url = withoutUserinfo(this.#url(path, query));
18510
+ throw new Error(`GET ${url} asked for a page ({issues, total, limit, offset}) and got ${refusal}`);
18494
18511
  }
18495
18512
  async listAllIssues(options) {
18496
18513
  const path = ["api", "v1", "issues"];
@@ -18498,7 +18515,8 @@ class DispatchClient {
18498
18515
  const answer = await this.#json("GET", path, undefined, query);
18499
18516
  if (Array.isArray(answer))
18500
18517
  return answer;
18501
- throw new Error(`GET ${this.#url(path, query)} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
18518
+ const url = withoutUserinfo(this.#url(path, query));
18519
+ throw new Error(`GET ${url} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
18502
18520
  }
18503
18521
  async listIssueArtifacts(issue) {
18504
18522
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
@@ -18965,7 +18983,7 @@ class DispatchClient {
18965
18983
  headers[IDEMPOTENCY_KEY_HEADER] = key;
18966
18984
  const { pausesMs, withinMs, silenceMs, inFlightPauseMs, inFlightWithinMs } = this.writeRetry;
18967
18985
  const pause = this.writeRetry.pause ?? pauseFor;
18968
- const request = `${method} ${url}`;
18986
+ const request = `${method} ${withoutUserinfo(url)}`;
18969
18987
  const started = this.#now();
18970
18988
  const bodyBytes = body === undefined ? 0 : typeof body.content === "string" ? Buffer.byteLength(body.content) : body.content.byteLength;
18971
18989
  const upload = bodyBytes >= STREAMED_BODY_MIN;
@@ -19148,7 +19166,8 @@ class DispatchClient {
19148
19166
  }
19149
19167
  const reasonPhrase = excerpt(response.statusText, this.token);
19150
19168
  const reason = reasonPhrase === "" ? "" : ` ${reasonPhrase}`;
19151
- throw new DispatchGatewayError(response.status, `${method} ${url} answered ${response.status}${reason} with ${body}, ${GATEWAY_PAGE}`, gatewayAdvice(method, response.status));
19169
+ const request = `${method} ${withoutUserinfo(url)}`;
19170
+ throw new DispatchGatewayError(response.status, `${request} answered ${response.status}${reason} with ${body}, ${GATEWAY_PAGE}`, gatewayAdvice(method, response.status));
19152
19171
  }
19153
19172
  const replayed = response.headers.get(IDEMPOTENCY_REPLAYED_HEADER)?.trim() === "?1";
19154
19173
  if (answerNotKept(response.status, replayed, payload)) {
@@ -20455,7 +20474,8 @@ function asObject(value) {
20455
20474
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
20456
20475
  }
20457
20476
  function sessionContext(input, checked) {
20458
- const { url: configUrl, credential } = input.config;
20477
+ const { url, credential } = input.config;
20478
+ const configUrl = withoutUserinfo(url);
20459
20479
  const baseFetch = input.fetchImpl ?? fetch;
20460
20480
  const fetchImpl = Object.assign(async (...args) => {
20461
20481
  try {
@@ -20473,9 +20493,9 @@ function sessionContext(input, checked) {
20473
20493
  ownerArguments: checked.owner,
20474
20494
  pictures: checked.pictures,
20475
20495
  configUrl,
20476
- linkBase: input.config.publicUrl ?? configUrl,
20496
+ linkBase: withoutUserinfo(input.config.publicUrl ?? url),
20477
20497
  hostSession: input.sessionId?.trim(),
20478
- newClient: () => new DispatchClient(configUrl, credential, fetchImpl, {
20498
+ newClient: () => new DispatchClient(url, credential, fetchImpl, {
20479
20499
  signal: input.signal,
20480
20500
  writeRetry: input.writeRetry,
20481
20501
  sleep: input.sleep
@@ -21933,6 +21953,7 @@ function openAskLine(ask, baseUrl) {
21933
21953
  return `- ${openAskAge(ask.age_seconds)} \xB7 ${priority}${ownerTitle(ask.owner)} \xB7 asked of ${waitsOnPerson(ask) ?? "nobody"} \xB7 ${ask.question} \xB7 ${new URL(ask.ref, baseUrl).toString()}`;
21934
21954
  }
21935
21955
  function formatOpenAsksSummary(response, baseUrl) {
21956
+ const linkBase = withoutUserinfo(baseUrl);
21936
21957
  const scope = "active open asks you authored on open issues and project documents";
21937
21958
  if (response.count === 0) {
21938
21959
  return ["There are no unanswered asks for this session.", `Scope: ${scope}.`].join(`
@@ -21944,10 +21965,10 @@ function formatOpenAsksSummary(response, baseUrl) {
21944
21965
  `${response.count} unanswered ${response.count === 1 ? "ask" : "asks"} you authored on active issues and project documents.`,
21945
21966
  "",
21946
21967
  `Waiting on human (${waitingOnHuman.length}):`,
21947
- ...waitingOnHuman.map((ask) => openAskLine(ask, baseUrl)),
21968
+ ...waitingOnHuman.map((ask) => openAskLine(ask, linkBase)),
21948
21969
  "",
21949
21970
  `Waiting on agent (${waitingOnAgent.length}):`,
21950
- ...waitingOnAgent.map((ask) => openAskLine(ask, baseUrl))
21971
+ ...waitingOnAgent.map((ask) => openAskLine(ask, linkBase))
21951
21972
  ].join(`
21952
21973
  `);
21953
21974
  }
@@ -24555,6 +24576,12 @@ function withinWindow(items, now) {
24555
24576
  const start = now - SESSION_ANSWERS_WINDOW_MS;
24556
24577
  return items.filter((item) => Date.parse(item.at) >= start);
24557
24578
  }
24579
+ function windowOf(items, now) {
24580
+ return {
24581
+ words: sessionAnswersWords(withinWindow(items, now)),
24582
+ since: new Date(now - SESSION_ANSWERS_WINDOW_MS).toISOString()
24583
+ };
24584
+ }
24558
24585
  function sessionAnswersWords(items) {
24559
24586
  return items.map((item) => JSON.stringify([
24560
24587
  item.kind,
@@ -24571,7 +24598,7 @@ function leftOutLine(count, namesCommand) {
24571
24598
  const counted = `${count} older ${count === 1 ? "item" : "items"} left out to stay under ${MAX_CHARS_TEXT} characters`;
24572
24599
  return namesCommand ? `${counted}: run \`dispatch answers\` to read every one in full.` : `${counted}.`;
24573
24600
  }
24574
- function renderShown(items, options) {
24601
+ function renderSessionAnswers(items, options) {
24575
24602
  const inWindow = withinWindow(items, Number(options.now));
24576
24603
  const unsent = inWindow.length === items.length ? Math.max(0, (options.total ?? items.length) - items.length) : 0;
24577
24604
  const count = inWindow.length + unsent;
@@ -24599,7 +24626,7 @@ As read at ${options.cached.readAt}; this read failed: ${failureSentence(options
24599
24626
  ].join(`
24600
24627
 
24601
24628
  `);
24602
- return { text, shown: inWindow.slice(0, blocks.length) };
24629
+ return text;
24603
24630
  }
24604
24631
  function renderSessionAnswersList(items, options) {
24605
24632
  const shown = withinWindow(items, Number(options.now));
@@ -24672,24 +24699,19 @@ async function readSessionAnswers(options) {
24672
24699
  const entries = state.sessions.get(session) ?? new Map;
24673
24700
  state.sessions.set(session, entries);
24674
24701
  const carry = (cache, reason, noRoute = false) => {
24675
- const rendered = cache === undefined ? undefined : renderShown(cache.items, {
24676
- now: now(),
24702
+ const at = now();
24703
+ const text = cache === undefined ? undefined : renderSessionAnswers(cache.items, {
24704
+ now: at,
24677
24705
  total: cache.total,
24678
24706
  cached: { readAt: cache.read_at, reason },
24679
24707
  withoutCommand: noRoute
24680
24708
  });
24681
- if (cache === undefined || rendered === undefined) {
24709
+ if (cache === undefined || text === undefined) {
24682
24710
  if (noRoute)
24683
24711
  return { text: undefined, source: "unavailable", reason };
24684
24712
  return { text: sessionAnswersFailureLine(reason), source: "failure", reason };
24685
24713
  }
24686
- return {
24687
- text: rendered.text,
24688
- source: "cache",
24689
- readAt: cache.read_at,
24690
- words: sessionAnswersWords(rendered.shown),
24691
- reason
24692
- };
24714
+ return { text, source: "cache", readAt: cache.read_at, ...windowOf(cache.items, at), reason };
24693
24715
  };
24694
24716
  if (!dispatch.enabled) {
24695
24717
  const url = options.dispatchUrl;
@@ -24716,7 +24738,7 @@ async function readSessionAnswers(options) {
24716
24738
  current.noRouteReported = true;
24717
24739
  return {
24718
24740
  ...read,
24719
- notice: `Dispatch at ${url} has no answers route (its build is older than the route), so people's answers cannot be read from it`
24741
+ notice: `Dispatch at ${withoutUserinfo(url)} has no answers route (its build is older than the route), so people's answers cannot be read from it`
24720
24742
  };
24721
24743
  };
24722
24744
  if ((state.noRouteUntil.get(url) ?? 0) > now())
@@ -24730,6 +24752,7 @@ async function readSessionAnswers(options) {
24730
24752
  retryNoRoute: false
24731
24753
  });
24732
24754
  const started = client.sessionAnswers(session, {
24755
+ since: new Date(now() - SESSION_ANSWERS_WINDOW_MS).toISOString(),
24733
24756
  maxChars: SESSION_ANSWERS_MAX_CHARS,
24734
24757
  signal: AbortSignal.timeout(READ_TIMEOUT_MS)
24735
24758
  }).then((response) => {
@@ -24781,12 +24804,12 @@ async function readSessionAnswers(options) {
24781
24804
  return noRoute();
24782
24805
  if ("failure" in outcome)
24783
24806
  return carry(current.cache, outcome.failure);
24784
- const rendered = renderShown(outcome.cache.items, { now: now(), total: outcome.cache.total });
24807
+ const at = now();
24785
24808
  return {
24786
- text: rendered?.text,
24809
+ text: renderSessionAnswers(outcome.cache.items, { now: at, total: outcome.cache.total }),
24787
24810
  source: "fresh",
24788
24811
  readAt: outcome.cache.read_at,
24789
- words: sessionAnswersWords(rendered?.shown ?? [])
24812
+ ...windowOf(outcome.cache.items, at)
24790
24813
  };
24791
24814
  }
24792
24815
  async function sessionAnswersSettled(session) {
@@ -29668,8 +29691,9 @@ async function refreshedAnswers(session, cwd, dispatchUrl, startedAt, by) {
29668
29691
  if (outcome.dispatch_url === dispatchUrl) {
29669
29692
  return { text: outcome.text ?? undefined, notice: outcome.notice ?? undefined };
29670
29693
  }
29694
+ const read = outcome.dispatch_url === null ? "no Dispatch" : withoutUserinfo(outcome.dispatch_url);
29671
29695
  return {
29672
- reason: `the refresher read ${outcome.dispatch_url ?? "no Dispatch"}, not the Dispatch envoy.json names now`
29696
+ reason: `the refresher read ${read}, not the Dispatch envoy.json names now`
29673
29697
  };
29674
29698
  }
29675
29699
  const left = remainingUntil(by);
@@ -15,6 +15,20 @@ function messageFor(error) {
15
15
  function hasErrnoCode(error, code) {
16
16
  return error instanceof Error && "code" in error && error.code === code;
17
17
  }
18
+ function withoutUserinfo(url) {
19
+ let parsed;
20
+ try {
21
+ parsed = new URL(url);
22
+ } catch {
23
+ return url.slice(url.lastIndexOf("@") + 1);
24
+ }
25
+ if (parsed.username === "" && parsed.password === "")
26
+ return url;
27
+ parsed.username = "";
28
+ parsed.password = "";
29
+ const shown = parsed.toString();
30
+ return shown.endsWith("/") && !url.endsWith("/") ? shown.slice(0, -1) : shown;
31
+ }
18
32
 
19
33
  // src/session-state.ts
20
34
  import { readFileSync } from "fs";
@@ -96,7 +96,7 @@ import {
96
96
  import { DispatchClient } from "@legion/envoy-client/dispatch-http"
97
97
  import { sessionDirectory, writeAtomically } from "@legion/envoy-client/dispatch-session-directory"
98
98
  import { offWithError } from "@legion/envoy-client/envoy-config"
99
- import { hasErrnoCode, messageFor } from "@legion/envoy-client/errors"
99
+ import { hasErrnoCode, messageFor, withoutUserinfo } from "@legion/envoy-client/errors"
100
100
  import {
101
101
  readSessionAnswers,
102
102
  SESSION_ANSWERS_DEADLINE_MS,
@@ -451,8 +451,12 @@ async function refreshedAnswers(
451
451
  if (outcome.dispatch_url === dispatchUrl) {
452
452
  return { text: outcome.text ?? undefined, notice: outcome.notice ?? undefined }
453
453
  }
454
+ // Compared whole above; the reason reaches the session's context, so it names the URL
455
+ // without the user and password it may carry.
456
+ const read =
457
+ outcome.dispatch_url === null ? "no Dispatch" : withoutUserinfo(outcome.dispatch_url)
454
458
  return {
455
- reason: `the refresher read ${outcome.dispatch_url ?? "no Dispatch"}, not the Dispatch envoy.json names now`,
459
+ reason: `the refresher read ${read}, not the Dispatch envoy.json names now`,
456
460
  }
457
461
  }
458
462
  const left = remainingUntil(by)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "2.31.0",
3
+ "version": "2.31.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",