@sjawhar/claude-envoy 5.27.2 → 5.28.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": "5.27.2"
5
+ "version": "5.28.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "5.27.2",
3
+ "version": "5.28.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
  }
@@ -14485,6 +14485,25 @@ var projectKeyValidation = {
14485
14485
  message: `project is not a project key: ${PROJECT_KEY_RULE}`
14486
14486
  };
14487
14487
  var ARCHITECTURE_SOURCE_REPO_PATTERN = /^[A-Za-z0-9_-]+\/(?!\.\.?$)[A-Za-z0-9._-]+$/;
14488
+ var API_ROUTE_PATTERN = /^\/api\/v1(?=[/?]|$)/;
14489
+ var API_PATH_RULE = "path is a route under /api/v1: it begins /api/v1 and names no scheme or host, every character is printable ASCII other than a space, a backslash and #, and no segment before the query is . or ..";
14490
+ function apiPathProblem(value) {
14491
+ const { path } = value;
14492
+ if (typeof path !== "string")
14493
+ return;
14494
+ const named = JSON.stringify(path);
14495
+ if (!API_ROUTE_PATTERN.test(path)) {
14496
+ return `path ${named} is no route under /api/v1: give the route alone, beginning /api/v1, with no scheme or host (dispatch api --path /api/v1 lists every route).`;
14497
+ }
14498
+ if (!/^[!-~]*$/.test(path) || /[\\#]/.test(path)) {
14499
+ return `path ${named} holds a space, a backslash, a # or a character outside printable ASCII: percent-encode it.`;
14500
+ }
14501
+ const route = path.split("?", 1)[0] ?? "";
14502
+ if (route.split("/").some((segment) => /^(?:\.|%2e){1,2}$/i.test(segment))) {
14503
+ return `path ${named} holds a . or .. segment: name the route itself.`;
14504
+ }
14505
+ return;
14506
+ }
14488
14507
  var ISSUE_STATUSES = [
14489
14508
  "triage",
14490
14509
  "icebox",
@@ -15090,6 +15109,20 @@ var dispatchToolSpecs = [
15090
15109
  arguments: () => ({}),
15091
15110
  strict: true
15092
15111
  },
15112
+ {
15113
+ name: "dispatch_api",
15114
+ example: { path: "/api/v1/issues/DSP-1/events?limit=200" },
15115
+ description: "Read one route of Dispatch's HTTP API that no other command reads, with this session's own credential, and print Dispatch's JSON answer, for jq to read. It sends one GET of path: a route beginning /api/v1, with its query after ?; dispatch api --path /api/v1 lists every route. It only reads: it takes no method and no body, and every write goes through the command named for it (dispatch --help lists them). When Dispatch refuses the read, the command prints Dispatch's error with its code and, where Dispatch gives one, its hint, and exits 1. Under Claude Code, an answer longer than the output limit is written to a file the output names.",
15116
+ arguments: (z) => ({
15117
+ path: z.string({ min: 1 }).describe("The route to read, beginning /api/v1, with its query after ?, such as /api/v1/issues/ACME-12/events?limit=200. No scheme or host, and no . or .. segment.")
15118
+ }),
15119
+ validation: {
15120
+ check: (value) => apiPathProblem(value) === undefined,
15121
+ message: API_PATH_RULE,
15122
+ refusal: (value) => apiPathProblem(value) ?? API_PATH_RULE
15123
+ },
15124
+ strict: true
15125
+ },
15093
15126
  {
15094
15127
  name: "dispatch_handoff_write",
15095
15128
  example: {
@@ -17509,17 +17542,19 @@ function errorClass(error) {
17509
17542
  }
17510
17543
 
17511
17544
  // ../envoy-client/src/errors.ts
17512
- function dispatchCode(error) {
17513
- if (!("fromDispatch" in error) || !("code" in error))
17545
+ function dispatchField(error, field) {
17546
+ if (!("fromDispatch" in error))
17514
17547
  return;
17515
- const code = error.code;
17516
- return typeof code === "string" && code !== "" ? code : undefined;
17548
+ const value = Reflect.get(error, field);
17549
+ return typeof value === "string" && value !== "" ? value : undefined;
17517
17550
  }
17518
17551
  function messageFor(error) {
17519
17552
  if (!(error instanceof Error))
17520
17553
  return scrub(String(error));
17521
- const code = dispatchCode(error);
17522
- return scrub(code === undefined || error.message.startsWith(code) ? error.message : `${code}: ${error.message}`);
17554
+ const code = dispatchField(error, "code");
17555
+ const message = code === undefined || error.message.startsWith(code) ? error.message : `${code}: ${error.message}`;
17556
+ const hint = dispatchField(error, "hint");
17557
+ return scrub(hint === undefined ? message : `${message}; ${hint}`);
17523
17558
  }
17524
17559
  function hasErrnoCode(error, code) {
17525
17560
  return error instanceof Error && "code" in error && error.code === code;
@@ -21342,6 +21377,7 @@ class DispatchServiceError extends Error {
21342
21377
  mismatches;
21343
21378
  issues;
21344
21379
  changed;
21380
+ hint;
21345
21381
  constructor(code, status, message, details = {}) {
21346
21382
  super(message);
21347
21383
  this.code = code;
@@ -21351,6 +21387,7 @@ class DispatchServiceError extends Error {
21351
21387
  this.mismatches = details.mismatches;
21352
21388
  this.issues = details.issues;
21353
21389
  this.changed = details.changed;
21390
+ this.hint = details.hint;
21354
21391
  }
21355
21392
  }
21356
21393
 
@@ -21840,6 +21877,10 @@ class DispatchClient {
21840
21877
  async limits() {
21841
21878
  return this.#json("GET", ["api", "v1", "limits"]);
21842
21879
  }
21880
+ async readRoute(path) {
21881
+ const url = new URL(path.slice(1), `${this.#baseUrl}/`).toString();
21882
+ return this.#response("GET", url, await this.#send("GET", url));
21883
+ }
21843
21884
  async inbox(assignee) {
21844
21885
  return this.#json("GET", ["api", "v1", "inbox"], undefined, { assignee });
21845
21886
  }
@@ -22528,7 +22569,7 @@ class DispatchClient {
22528
22569
  if (response.status === 409 && error.code === IDEMPOTENCY_KEY_COMMITTED) {
22529
22570
  throw new DispatchWriteLandedError(IDEMPOTENCY_KEY_COMMITTED, response.status, method, requestForText(this.#baseUrl, url, DISPATCH_URL_SETTING));
22530
22571
  }
22531
- throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error);
22572
+ throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, { ...error, hint: typeof error.hint === "string" ? error.hint : undefined });
22532
22573
  }
22533
22574
  throw this.#gatewayError(method, url, response, text, "Dispatch's error JSON");
22534
22575
  }
@@ -24302,6 +24343,7 @@ var issueFreeTools = {
24302
24343
  dispatch_answers: true,
24303
24344
  dispatch_whoami: true,
24304
24345
  dispatch_limits: true,
24346
+ dispatch_api: true,
24305
24347
  dispatch_inbox: true,
24306
24348
  dispatch_send_to_agent: true,
24307
24349
  dispatch_architecture_sync: true
@@ -26708,6 +26750,16 @@ async function resultsCommand(context) {
26708
26750
  };
26709
26751
  }
26710
26752
 
26753
+ // ../envoy-client/src/dispatch-commands/api.ts
26754
+ async function apiCommand(context) {
26755
+ const path = stringArg(context.args, "path");
26756
+ const answer = await context.newClient().readRoute(path);
26757
+ return {
26758
+ text: typeof answer === "string" ? answer : JSON.stringify(answer, null, 2),
26759
+ details: { path }
26760
+ };
26761
+ }
26762
+
26711
26763
  // ../envoy-client/src/dispatch-commands/render-item.ts
26712
26764
  function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgoing) {
26713
26765
  const answer = ask.answer;
@@ -29597,6 +29649,7 @@ var dispatchCommands = {
29597
29649
  dispatch_answers: onSession(answersCommand),
29598
29650
  dispatch_whoami: onSession(whoamiCommand),
29599
29651
  dispatch_limits: onSession(limitsCommand),
29652
+ dispatch_api: onSession(apiCommand),
29600
29653
  dispatch_inbox: onSession(inboxCommand)
29601
29654
  };
29602
29655
  // ../envoy-client/src/dispatch-execute.ts
@@ -29617,6 +29670,10 @@ async function executeDispatchTool(input) {
29617
29670
  return command.origin === "none" ? command.run(session) : command.run(await commandContext(session));
29618
29671
  }
29619
29672
 
29673
+ // ../cipher-client/src/environment.ts
29674
+ import { readFile as readFile6 } from "fs/promises";
29675
+ import { join as join7 } from "path";
29676
+
29620
29677
  // ../cipher-client/src/device-login.ts
29621
29678
  import { generateKeyPairSync as generateKeyPairSync2, randomUUID as randomUUID5 } from "crypto";
29622
29679
 
@@ -33413,6 +33470,8 @@ var BROKER_URL_VAR = "AGENT_SECRETS_URL";
33413
33470
  var IDENTITY_VAR = "AGENT_SECRETS_MACHINE_IDENTITY";
33414
33471
  var MACHINE_TOKEN_FILE_VAR = "AGENT_SECRETS_MACHINE_TOKEN_FILE";
33415
33472
  var MACHINE_AUDIENCE_VAR = "AGENT_SECRETS_MACHINE_AUDIENCE";
33473
+ var KEY_DIR_VAR = "AGENT_SECRETS_KEY_DIR";
33474
+ var ROLE_KEY_FILE = "key.pem";
33416
33475
  var SESSION_VAR = "AGENT_SECRETS_SESSION";
33417
33476
  var PROJECTS_VAR = "AGENT_SECRETS_PROJECTS";
33418
33477
  var MAX_PROJECTS = 16;
@@ -33426,6 +33485,7 @@ var BROKER_VARIABLES = [
33426
33485
  BROKER_URL_VAR,
33427
33486
  IDENTITY_VAR,
33428
33487
  MACHINE_TOKEN_FILE_VAR,
33488
+ KEY_DIR_VAR,
33429
33489
  MACHINE_AUDIENCE_VAR,
33430
33490
  SESSION_VAR,
33431
33491
  PROJECTS_VAR,
@@ -33501,6 +33561,21 @@ function tradeProjects(env) {
33501
33561
  }
33502
33562
  return sorted;
33503
33563
  }
33564
+ async function machineKey(env) {
33565
+ const dir = value(env, KEY_DIR_VAR);
33566
+ if (value(env, IDENTITY_VAR) !== IDENTITY_KUBERNETES || dir === "")
33567
+ return await newDpopKey();
33568
+ const path = join7(dir, ROLE_KEY_FILE);
33569
+ let pem;
33570
+ try {
33571
+ pem = await readFile6(path, "utf8");
33572
+ } catch (error) {
33573
+ throw new Error(`read this role's agent-secrets key ${path}: ${messageOf(error)}`, {
33574
+ cause: error
33575
+ });
33576
+ }
33577
+ return await importDpopKey(pem, `this role's agent-secrets key ${path}`);
33578
+ }
33504
33579
  async function brokerTokenClient(env, own = "", read) {
33505
33580
  const brokerUrl = value(env, BROKER_URL_VAR);
33506
33581
  const machine = machineIdentity(env);
@@ -33528,7 +33603,7 @@ async function brokerTokenClient(env, own = "", read) {
33528
33603
  if (record === undefined) {
33529
33604
  const client = new BrokerTokenClient({
33530
33605
  brokerUrl,
33531
- key: await newDpopKey(),
33606
+ key: await machineKey(env),
33532
33607
  subject: machine,
33533
33608
  session: tradeSession(env, own),
33534
33609
  launcherCredential: false,
@@ -34723,18 +34798,18 @@ function claudeProjectDirectory(environment, fallback) {
34723
34798
  // src/codex/codex-session-record.ts
34724
34799
  import { spawnSync } from "child_process";
34725
34800
  import { readFileSync as readFileSync4, readlinkSync, unwatchFile, watchFile } from "fs";
34726
- import { mkdir as mkdir3, readFile as readFile7, rename as rename4, utimes as utimes3, writeFile as writeFile2 } from "fs/promises";
34801
+ import { mkdir as mkdir3, readFile as readFile8, rename as rename4, utimes as utimes3, writeFile as writeFile2 } from "fs/promises";
34727
34802
  import { homedir as homedir3 } from "os";
34728
- import { basename as basename4, dirname as dirname5, join as join9 } from "path";
34803
+ import { basename as basename4, dirname as dirname5, join as join10 } from "path";
34729
34804
 
34730
34805
  // src/session-identity.ts
34731
- import { readFile as readFile6 } from "fs/promises";
34732
- import { basename as basename3, join as join8 } from "path";
34806
+ import { readFile as readFile7 } from "fs/promises";
34807
+ import { basename as basename3, join as join9 } from "path";
34733
34808
 
34734
34809
  // src/session-state.ts
34735
34810
  import { readFileSync as readFileSync3 } from "fs";
34736
34811
  import { mkdir as mkdir2, readdir as readdir3, rename as rename3, rm as rm4, stat as stat4, utimes as utimes2, writeFile } from "fs/promises";
34737
- import { dirname as dirname4, join as join7 } from "path";
34812
+ import { dirname as dirname4, join as join8 } from "path";
34738
34813
  async function writeAtomicStateFile(file, contents) {
34739
34814
  await mkdir2(dirname4(file), { recursive: true, mode: 448 });
34740
34815
  const temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
@@ -34752,7 +34827,7 @@ async function pruneStateDirectory(directory, isStale) {
34752
34827
  throw error;
34753
34828
  });
34754
34829
  for (const entry of entries) {
34755
- const file = join7(directory, entry);
34830
+ const file = join8(directory, entry);
34756
34831
  if (!await isStale(file))
34757
34832
  continue;
34758
34833
  await rm4(file, { recursive: true, force: true });
@@ -34767,7 +34842,7 @@ async function writtenLongAgo(file) {
34767
34842
  }
34768
34843
  var TITLES_DIRECTORY = "titles";
34769
34844
  function sessionTitleFile(stateDirectory, sessionId) {
34770
- return join7(stateDirectory, TITLES_DIRECTORY, `${encodeURIComponent(sessionId)}.txt`);
34845
+ return join8(stateDirectory, TITLES_DIRECTORY, `${encodeURIComponent(sessionId)}.txt`);
34771
34846
  }
34772
34847
  async function writeChosenTitle(file, title) {
34773
34848
  await writeAtomicStateFile(file, `${title}
@@ -34795,7 +34870,7 @@ async function recordChosenTitle(sessionId, title) {
34795
34870
  await writeChosenTitle(file, chosen);
34796
34871
  }
34797
34872
  async function pruneStaleSessionTitles(stateDirectory) {
34798
- await pruneStateDirectory(join7(stateDirectory, TITLES_DIRECTORY), writtenLongAgo);
34873
+ await pruneStateDirectory(join8(stateDirectory, TITLES_DIRECTORY), writtenLongAgo);
34799
34874
  }
34800
34875
 
34801
34876
  // src/session-identity.ts
@@ -34820,14 +34895,14 @@ class SessionIdentity {
34820
34895
  }
34821
34896
  }
34822
34897
  function sessionHandoffDirectory(stateDirectory, claudePid) {
34823
- return join8(stateDirectory, "sessions", String(claudePid));
34898
+ return join9(stateDirectory, "sessions", String(claudePid));
34824
34899
  }
34825
34900
  function sessionHandoffFile(stateDirectory, claudePid) {
34826
- return join8(sessionHandoffDirectory(stateDirectory, claudePid), "session-id");
34901
+ return join9(sessionHandoffDirectory(stateDirectory, claudePid), "session-id");
34827
34902
  }
34828
34903
  var ROLES_DIRECTORY = "roles";
34829
34904
  function roleStateFile(stateDirectory, sessionId) {
34830
- return join8(stateDirectory, ROLES_DIRECTORY, `${encodeURIComponent(sessionId)}.json`);
34905
+ return join9(stateDirectory, ROLES_DIRECTORY, `${encodeURIComponent(sessionId)}.json`);
34831
34906
  }
34832
34907
 
34833
34908
  class UnparseableRoleRecordError extends Error {
@@ -34839,7 +34914,7 @@ class UnparseableRoleRecordError extends Error {
34839
34914
  async function readPersistedRole(roleFile) {
34840
34915
  let bytes;
34841
34916
  try {
34842
- bytes = await readFile6(roleFile, "utf8");
34917
+ bytes = await readFile7(roleFile, "utf8");
34843
34918
  } catch (error) {
34844
34919
  if (hasErrnoCode(error, "ENOENT"))
34845
34920
  return;
@@ -34861,7 +34936,7 @@ async function writeSessionHandoff(file, sessionId) {
34861
34936
  }
34862
34937
  async function readSessionHandoff(file) {
34863
34938
  try {
34864
- const id = (await readFile6(file, "utf8")).trim();
34939
+ const id = (await readFile7(file, "utf8")).trim();
34865
34940
  return id.length === 0 ? undefined : id;
34866
34941
  } catch (error) {
34867
34942
  if (hasErrnoCode(error, "ENOENT"))
@@ -34878,14 +34953,14 @@ function processExists(pid) {
34878
34953
  }
34879
34954
  }
34880
34955
  async function pruneStaleSessionHandoffs(stateDirectory) {
34881
- await pruneStateDirectory(join8(stateDirectory, "sessions"), (file) => {
34956
+ await pruneStateDirectory(join9(stateDirectory, "sessions"), (file) => {
34882
34957
  const pid = basename3(file);
34883
34958
  return /^\d+$/.test(pid) && !processExists(Number(pid));
34884
34959
  });
34885
34960
  }
34886
34961
  async function pruneStaleSessionRoles(stateDirectory, currentSessionId) {
34887
34962
  const own = roleStateFile(stateDirectory, currentSessionId);
34888
- await pruneStateDirectory(join8(stateDirectory, ROLES_DIRECTORY), async (file) => file !== own && await writtenLongAgo(file));
34963
+ await pruneStateDirectory(join9(stateDirectory, ROLES_DIRECTORY), async (file) => file !== own && await writtenLongAgo(file));
34889
34964
  }
34890
34965
 
34891
34966
  // src/codex/codex-session-record.ts
@@ -34899,10 +34974,10 @@ var CodexSessionRecord = object({
34899
34974
  codex_started: string2().nullable().default(null)
34900
34975
  });
34901
34976
  function codexSessionRecordFile(stateDirectory, pid) {
34902
- return join9(stateDirectory, "codex-sessions", `${pid}.json`);
34977
+ return join10(stateDirectory, "codex-sessions", `${pid}.json`);
34903
34978
  }
34904
34979
  function codexEndedFile(stateDirectory, pid, sessionId) {
34905
- return join9(stateDirectory, "codex-sessions", `${pid}.${encodeURIComponent(sessionId)}.ended`);
34980
+ return join10(stateDirectory, "codex-sessions", `${pid}.${encodeURIComponent(sessionId)}.ended`);
34906
34981
  }
34907
34982
  async function markSessionEnded(stateDirectory, pid, sessionId) {
34908
34983
  const marker = codexEndedFile(stateDirectory, pid, sessionId);
@@ -34925,7 +35000,7 @@ function watchRecord(file, pid, ended, changed, intervalMs) {
34925
35000
  }
34926
35001
  async function sessionEnded(file) {
34927
35002
  try {
34928
- await readFile7(file);
35003
+ await readFile8(file);
34929
35004
  return true;
34930
35005
  } catch {
34931
35006
  return false;
@@ -34939,7 +35014,7 @@ async function writeCodexSessionRecord(file, value) {
34939
35014
  }
34940
35015
  async function readCodexSessionRecord(file) {
34941
35016
  try {
34942
- const parsed = CodexSessionRecord.safeParse(JSON.parse(await readFile7(file, "utf8")));
35017
+ const parsed = CodexSessionRecord.safeParse(JSON.parse(await readFile8(file, "utf8")));
34943
35018
  return parsed.success ? parsed.data : undefined;
34944
35019
  } catch {
34945
35020
  return;
@@ -34947,7 +35022,7 @@ async function readCodexSessionRecord(file) {
34947
35022
  }
34948
35023
  function codexHome(env) {
34949
35024
  const set = env["CODEX_HOME"];
34950
- return set !== undefined && set !== "" ? set : join9(env["HOME"] || homedir3(), ".codex");
35025
+ return set !== undefined && set !== "" ? set : join10(env["HOME"] || homedir3(), ".codex");
34951
35026
  }
34952
35027
  function codexPluginDataDirectory(pluginRoot) {
34953
35028
  const version = pluginRoot;
@@ -34957,7 +35032,7 @@ function codexPluginDataDirectory(pluginRoot) {
34957
35032
  const plugins = dirname5(cache);
34958
35033
  if (basename4(cache) !== "cache" || basename4(plugins) !== "plugins")
34959
35034
  return;
34960
- return join9(plugins, "data", `${basename4(plugin)}-${basename4(marketplace)}`);
35035
+ return join10(plugins, "data", `${basename4(plugin)}-${basename4(marketplace)}`);
34961
35036
  }
34962
35037
  var MAX_ANCESTORS = 16;
34963
35038
  function codexProcessId(readComm = procComm, readParent = procParent) {
@@ -35059,11 +35134,11 @@ function codexSubcommand(args) {
35059
35134
  }
35060
35135
  var SHARED_APP_SERVER_NOTE = "Codex runs this session in its shared app server (`codex app-server`), which runs several sessions in one process, so the Envoy plugin does not register it with Envoy: it receives no Envoy messages and does not show on Dispatch's Agents page. Its `dispatch` tool works, acting as this session.";
35061
35136
  async function pruneCodexSessionRecords(stateDirectory) {
35062
- await pruneStateDirectory(join9(stateDirectory, "codex-sessions"), (file) => {
35137
+ await pruneStateDirectory(join10(stateDirectory, "codex-sessions"), (file) => {
35063
35138
  const match = /^(\d+)\.(?:json|.+\.ended)$/.exec(basename4(file));
35064
35139
  return match !== null && !processExists(Number(match[1]));
35065
35140
  });
35066
- await pruneStateDirectory(join9(stateDirectory, "codex-servers"), (file) => {
35141
+ await pruneStateDirectory(join10(stateDirectory, "codex-servers"), (file) => {
35067
35142
  const name = basename4(file);
35068
35143
  return /^\d+$/.test(name) && !processExists(Number(name));
35069
35144
  });