@sjawhar/claude-envoy 5.27.2 → 5.29.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.
package/dist/dispatch.js CHANGED
@@ -1208,17 +1208,19 @@ function errorClass(error) {
1208
1208
  }
1209
1209
 
1210
1210
  // ../envoy-client/src/errors.ts
1211
- function dispatchCode(error) {
1212
- if (!("fromDispatch" in error) || !("code" in error))
1211
+ function dispatchField(error, field) {
1212
+ if (!("fromDispatch" in error))
1213
1213
  return;
1214
- const code = error.code;
1215
- return typeof code === "string" && code !== "" ? code : undefined;
1214
+ const value = Reflect.get(error, field);
1215
+ return typeof value === "string" && value !== "" ? value : undefined;
1216
1216
  }
1217
1217
  function messageFor(error) {
1218
1218
  if (!(error instanceof Error))
1219
1219
  return scrub(String(error));
1220
- const code = dispatchCode(error);
1221
- return scrub(code === undefined || error.message.startsWith(code) ? error.message : `${code}: ${error.message}`);
1220
+ const code = dispatchField(error, "code");
1221
+ const message = code === undefined || error.message.startsWith(code) ? error.message : `${code}: ${error.message}`;
1222
+ const hint = dispatchField(error, "hint");
1223
+ return scrub(hint === undefined ? message : `${message}; ${hint}`);
1222
1224
  }
1223
1225
  function hasErrnoCode(error, code) {
1224
1226
  return error instanceof Error && "code" in error && error.code === code;
@@ -15089,6 +15091,25 @@ var projectKeyValidation = {
15089
15091
  message: `project is not a project key: ${PROJECT_KEY_RULE}`
15090
15092
  };
15091
15093
  var ARCHITECTURE_SOURCE_REPO_PATTERN = /^[A-Za-z0-9_-]+\/(?!\.\.?$)[A-Za-z0-9._-]+$/;
15094
+ var API_ROUTE_PATTERN = /^\/api\/v1(?=[/?]|$)/;
15095
+ 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 ..";
15096
+ function apiPathProblem(value) {
15097
+ const { path } = value;
15098
+ if (typeof path !== "string")
15099
+ return;
15100
+ const named = JSON.stringify(path);
15101
+ if (!API_ROUTE_PATTERN.test(path)) {
15102
+ 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).`;
15103
+ }
15104
+ if (!/^[!-~]*$/.test(path) || /[\\#]/.test(path)) {
15105
+ return `path ${named} holds a space, a backslash, a # or a character outside printable ASCII: percent-encode it.`;
15106
+ }
15107
+ const route = path.split("?", 1)[0] ?? "";
15108
+ if (route.split("/").some((segment) => /^(?:\.|%2e){1,2}$/i.test(segment))) {
15109
+ return `path ${named} holds a . or .. segment: name the route itself.`;
15110
+ }
15111
+ return;
15112
+ }
15092
15113
  var ISSUE_STATUSES = [
15093
15114
  "triage",
15094
15115
  "icebox",
@@ -15161,8 +15182,8 @@ var dispatchToolSpecs = [
15161
15182
  route: z.string().describe("Route the issue to role:<name> or session:<id>; an empty string clears it.").optional(),
15162
15183
  parent: z.string().describe("Parent issue key, in any project; an empty string clears the parent. A parent in another project passes on no repository, components or legion label.").optional(),
15163
15184
  blocked_by: z.array(z.string({ min: 1 }), { max: MAX_ISSUE_BLOCKERS }).describe("Replacement list of issue keys this issue waits on, of any project; [] clears it. Dispatch refuses a dependency cycle.").optional(),
15164
- advances: z.array(z.string({ min: 1 }), { max: MAX_ISSUE_ADVANCES }).describe("Replacement list of priority ids this issue advances, which dispatch priorities lists; [] clears the issue's own, leaving every priority it inherits from the issues above it. A set that moves two or more relations is a whole-set write and carries advances_revision; the call reads the issue and sends the revision that read answered, so pass advances_revision only to answer a 409 ADVANCES_REVISION.").optional(),
15165
- advances_revision: z.number().describe("The advances_revision the read this set answers returned, sent with advances and alone changing nothing. Omit it and the call sends the revision of its own read; pass the revision a 409 ADVANCES_REVISION named to write the set you mean against it.").optional(),
15185
+ advances: z.array(z.string({ min: 1 }), { max: MAX_ISSUE_ADVANCES }).describe("Replacement list of priority ids this issue advances, which dispatch priorities lists; [] clears the issue's own, leaving every priority it inherits from the issues above it. Without advances_revision, Dispatch takes a list that adds or removes one priority, and refuses a list that changes two or more with 409 ADVANCES_REVISION, which names the issue's revision.").optional(),
15186
+ advances_revision: z.number().describe("The issue's advances revision, which the Advances line of dispatch read --issue <KEY> prints and a 409 ADVANCES_REVISION names. To change two or more priorities, read the issue, then send this revision with the whole list you mean. Alone it changes nothing.").optional(),
15166
15187
  components: componentsArgument(z).optional(),
15167
15188
  repo: z.string().describe("The repository the issue targets, owner/name. An empty string clears it, so the issue takes the nearest ancestor's in its own project, or the project's default, again.").optional(),
15168
15189
  before: z.string().describe(`Move the issue above this issue on its project's board: an issue key in the same project. With after, the issue lands between the two. ${BOARD_NEIGHBOUR_REFUSAL}`).optional(),
@@ -15694,6 +15715,20 @@ var dispatchToolSpecs = [
15694
15715
  arguments: () => ({}),
15695
15716
  strict: true
15696
15717
  },
15718
+ {
15719
+ name: "dispatch_api",
15720
+ example: { path: "/api/v1/issues/DSP-1/events?limit=200" },
15721
+ 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.",
15722
+ arguments: (z) => ({
15723
+ 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.")
15724
+ }),
15725
+ validation: {
15726
+ check: (value) => apiPathProblem(value) === undefined,
15727
+ message: API_PATH_RULE,
15728
+ refusal: (value) => apiPathProblem(value) ?? API_PATH_RULE
15729
+ },
15730
+ strict: true
15731
+ },
15697
15732
  {
15698
15733
  name: "dispatch_handoff_write",
15699
15734
  example: {
@@ -20436,6 +20471,7 @@ class DispatchServiceError extends Error {
20436
20471
  mismatches;
20437
20472
  issues;
20438
20473
  changed;
20474
+ hint;
20439
20475
  constructor(code, status, message, details = {}) {
20440
20476
  super(message);
20441
20477
  this.code = code;
@@ -20445,6 +20481,7 @@ class DispatchServiceError extends Error {
20445
20481
  this.mismatches = details.mismatches;
20446
20482
  this.issues = details.issues;
20447
20483
  this.changed = details.changed;
20484
+ this.hint = details.hint;
20448
20485
  }
20449
20486
  }
20450
20487
 
@@ -20934,6 +20971,10 @@ class DispatchClient {
20934
20971
  async limits() {
20935
20972
  return this.#json("GET", ["api", "v1", "limits"]);
20936
20973
  }
20974
+ async readRoute(path) {
20975
+ const url = new URL(path.slice(1), `${this.#baseUrl}/`).toString();
20976
+ return this.#response("GET", url, await this.#send("GET", url));
20977
+ }
20937
20978
  async inbox(assignee) {
20938
20979
  return this.#json("GET", ["api", "v1", "inbox"], undefined, { assignee });
20939
20980
  }
@@ -21622,7 +21663,7 @@ class DispatchClient {
21622
21663
  if (response.status === 409 && error.code === IDEMPOTENCY_KEY_COMMITTED) {
21623
21664
  throw new DispatchWriteLandedError(IDEMPOTENCY_KEY_COMMITTED, response.status, method, requestForText(this.#baseUrl, url, DISPATCH_URL_SETTING));
21624
21665
  }
21625
- throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error);
21666
+ throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, { ...error, hint: typeof error.hint === "string" ? error.hint : undefined });
21626
21667
  }
21627
21668
  throw this.#gatewayError(method, url, response, text, "Dispatch's error JSON");
21628
21669
  }
@@ -25922,6 +25963,7 @@ var issueFreeTools = {
25922
25963
  dispatch_answers: true,
25923
25964
  dispatch_whoami: true,
25924
25965
  dispatch_limits: true,
25966
+ dispatch_api: true,
25925
25967
  dispatch_inbox: true,
25926
25968
  dispatch_send_to_agent: true,
25927
25969
  dispatch_architecture_sync: true
@@ -26628,9 +26670,9 @@ function advancesLine(issue) {
26628
26670
  return "Advances: unknown (this Dispatch server predates priorities; upgrade it)";
26629
26671
  }
26630
26672
  const advances = issue.advances ?? [];
26631
- if (advances.length === 0)
26632
- return "Advances: no priority";
26633
- return `Advances: ${advances.map(advanceText).join(", ")}`;
26673
+ const set = advances.length === 0 ? "no priority" : advances.map(advanceText).join(", ");
26674
+ const revision = issue.advances_revision === undefined ? "" : `; revision ${issue.advances_revision}`;
26675
+ return `Advances: ${set}${revision}`;
26634
26676
  }
26635
26677
  function claimText(claim, agents, read = {}) {
26636
26678
  const titles = agents?.titles;
@@ -27304,11 +27346,16 @@ function refuseUnsavedRepository(verb, issue, repo) {
27304
27346
  const lost = repo === "" ? "the repository was not cleared" : `${repo} was not saved`;
27305
27347
  throw new Error(`Dispatch ${verb} ${issue.key} without its repository: this Dispatch server predates repository fields, so ${lost}; upgrade the server`);
27306
27348
  }
27307
- function advancesRevisionToSend(issue, named) {
27308
- if (issue.advances_revision === undefined) {
27309
- throw new Error(`Dispatch read ${issue.key} without its advances: this Dispatch server predates priorities, so nothing was sent; upgrade the server`);
27310
- }
27311
- return named ?? issue.advances_revision;
27349
+ function refuseServerWithoutAdvances(issue) {
27350
+ if (issue.advances_revision !== undefined)
27351
+ return;
27352
+ throw new Error(`Dispatch read ${issue.key} without its advances: this Dispatch server predates priorities, so nothing was sent; upgrade the server`);
27353
+ }
27354
+ function advancesRevisionAnswer(issueKey, error) {
27355
+ if (!dispatchAnswered(error, 409) || error.code !== "ADVANCES_REVISION")
27356
+ return "";
27357
+ const held = /(\d+)\D*$/.exec(error.message)?.[1] ?? "<the revision named above>";
27358
+ return `read the issue with ${commandLine("dispatch_read", { issue: issueKey })}, then send the whole set you mean with ${fieldFlag("dispatch_issue_update", "advances_revision")} ${held}`;
27312
27359
  }
27313
27360
  async function issueCommand(context) {
27314
27361
  const { args, client, actor, input, linkBase } = context;
@@ -27419,7 +27466,9 @@ async function issueUpdateCommand(context) {
27419
27466
  } catch (error) {
27420
27467
  throw refusalWithCode(error);
27421
27468
  }
27422
- const advancesWrite = advances === undefined ? undefined : { advances, advances_revision: advancesRevisionToSend(before, advancesRevision) };
27469
+ if (advances !== undefined)
27470
+ refuseServerWithoutAdvances(before);
27471
+ const advancesWrite = advances === undefined ? undefined : { advances, ...defined("advances_revision", advancesRevision) };
27423
27472
  if (status === "done" && typeof before.closed_at === "string") {
27424
27473
  throw refusalWithCode(new DispatchServiceError("ISSUE_CLOSED", 409, "issue is closed"), `${issueKey} closed at ${before.closed_at}, so the reason was not posted and the close was not sent`);
27425
27474
  }
@@ -27477,15 +27526,17 @@ async function issueUpdateCommand(context) {
27477
27526
  throw error;
27478
27527
  const answered = error instanceof DispatchWriteUnsettledError ? error.last : error;
27479
27528
  const taken = dispatchAnswered(answered, 500) && newLinks.length > 0 ? `one of ${newLinks.join(", ")} may already be linked from another issue (a URL links exactly one issue)` : "";
27529
+ const revisionClause = advancesRevisionAnswer(issueKey, error);
27480
27530
  if (closingNote === undefined) {
27481
27531
  if (taken !== "" && !(error instanceof DispatchServiceError)) {
27482
27532
  throw withAccount(error, taken);
27483
27533
  }
27484
- throw refusalWithCode(error, taken);
27534
+ throw refusalWithCode(error, taken, revisionClause);
27485
27535
  }
27486
27536
  const landed = closeAccount(error, closingNote);
27487
- if (error instanceof DispatchServiceError)
27488
- throw refusalWithCode(error, taken, landed);
27537
+ if (error instanceof DispatchServiceError) {
27538
+ throw refusalWithCode(error, taken, revisionClause, landed);
27539
+ }
27489
27540
  throw withAccount(error, [taken, landed].filter((clause) => clause !== "").join("; "));
27490
27541
  }
27491
27542
  refuseUnsavedRepository("updated", after, repo);
@@ -31252,6 +31303,10 @@ async function refreshDeviceLogin(path, login, options) {
31252
31303
  return next;
31253
31304
  }
31254
31305
 
31306
+ // ../cipher-client/src/environment.ts
31307
+ import { readFile as readFile6 } from "fs/promises";
31308
+ import { join as join6 } from "path";
31309
+
31255
31310
  // ../cipher-client/src/metadata-identity.ts
31256
31311
  import { Agent, request } from "http";
31257
31312
  var METADATA_HOST_VAR = "GCE_METADATA_HOST";
@@ -31561,6 +31616,8 @@ var BROKER_URL_VAR = "AGENT_SECRETS_URL";
31561
31616
  var IDENTITY_VAR = "AGENT_SECRETS_MACHINE_IDENTITY";
31562
31617
  var MACHINE_TOKEN_FILE_VAR = "AGENT_SECRETS_MACHINE_TOKEN_FILE";
31563
31618
  var MACHINE_AUDIENCE_VAR = "AGENT_SECRETS_MACHINE_AUDIENCE";
31619
+ var KEY_DIR_VAR = "AGENT_SECRETS_KEY_DIR";
31620
+ var ROLE_KEY_FILE = "key.pem";
31564
31621
  var SESSION_VAR = "AGENT_SECRETS_SESSION";
31565
31622
  var PROJECTS_VAR = "AGENT_SECRETS_PROJECTS";
31566
31623
  var MAX_PROJECTS = 16;
@@ -31574,6 +31631,7 @@ var BROKER_VARIABLES = [
31574
31631
  BROKER_URL_VAR,
31575
31632
  IDENTITY_VAR,
31576
31633
  MACHINE_TOKEN_FILE_VAR,
31634
+ KEY_DIR_VAR,
31577
31635
  MACHINE_AUDIENCE_VAR,
31578
31636
  SESSION_VAR,
31579
31637
  PROJECTS_VAR,
@@ -31649,6 +31707,21 @@ function tradeProjects(env) {
31649
31707
  }
31650
31708
  return sorted;
31651
31709
  }
31710
+ async function machineKey(env) {
31711
+ const dir = value(env, KEY_DIR_VAR);
31712
+ if (value(env, IDENTITY_VAR) !== IDENTITY_KUBERNETES || dir === "")
31713
+ return await newDpopKey();
31714
+ const path = join6(dir, ROLE_KEY_FILE);
31715
+ let pem;
31716
+ try {
31717
+ pem = await readFile6(path, "utf8");
31718
+ } catch (error) {
31719
+ throw new Error(`read this role's agent-secrets key ${path}: ${messageOf(error)}`, {
31720
+ cause: error
31721
+ });
31722
+ }
31723
+ return await importDpopKey(pem, `this role's agent-secrets key ${path}`);
31724
+ }
31652
31725
  async function brokerTokenClient(env, own = "", read) {
31653
31726
  const brokerUrl = value(env, BROKER_URL_VAR);
31654
31727
  const machine = machineIdentity(env);
@@ -31676,7 +31749,7 @@ async function brokerTokenClient(env, own = "", read) {
31676
31749
  if (record === undefined) {
31677
31750
  const client = new BrokerTokenClient({
31678
31751
  brokerUrl,
31679
- key: await newDpopKey(),
31752
+ key: await machineKey(env),
31680
31753
  subject: machine,
31681
31754
  session: tradeSession(env, own),
31682
31755
  launcherCredential: false,
@@ -32343,6 +32416,16 @@ async function commandContext(session) {
32343
32416
  };
32344
32417
  }
32345
32418
 
32419
+ // ../envoy-client/src/dispatch-commands/api.ts
32420
+ async function apiCommand(context) {
32421
+ const path = stringArg(context.args, "path");
32422
+ const answer = await context.newClient().readRoute(path);
32423
+ return {
32424
+ text: typeof answer === "string" ? answer : JSON.stringify(answer, null, 2),
32425
+ details: { path }
32426
+ };
32427
+ }
32428
+
32346
32429
  // ../envoy-client/src/dispatch-commands/render-item.ts
32347
32430
  function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgoing) {
32348
32431
  const answer = ask.answer;
@@ -34005,7 +34088,7 @@ function priorityWorkLine(work) {
34005
34088
  }
34006
34089
  function priorityIssueLine(issue, agents) {
34007
34090
  const advances = issue.advances ?? [];
34008
- const moved = issue.moved_at === null ? "" : ` \xB7 parked ${issue.moved_at}${issue.moved_by === null ? "" : ` by ${actorLabel(issue.moved_by, agents?.titles)}`}`;
34091
+ const moved = issue.moved_at === null ? "" : ` \xB7 moved to ${issue.status} ${issue.moved_at}${issue.moved_by === null ? "" : ` by ${actorLabel(issue.moved_by, agents?.titles)}`}`;
34009
34092
  return `- ${issue.key} [${issue.status}] ${issue.title} \xB7 ${issue.project}` + (issue.assignee === null ? "" : ` \xB7 ${issue.assignee}`) + (issue.claim === null ? "" : ` \xB7 claimed by ${claimText(issue.claim, agents)}`) + (advances.length === 0 ? "" : ` \xB7 advances ${advances.map(advanceText).join(", ")}`) + moved + ` \xB7 changed ${issue.changed_at}`;
34010
34093
  }
34011
34094
  function priorityFaultLines(heading, fault, agents) {
@@ -34021,7 +34104,7 @@ function priorityFaultLines(heading, fault, agents) {
34021
34104
  }
34022
34105
  function formatPriorities(response, agents) {
34023
34106
  const priorities = response.priorities ?? [];
34024
- const parked = response.priority_work_parked;
34107
+ const backlog = response.priority_work_parked;
34025
34108
  const unplaced = response.work_under_no_priority;
34026
34109
  if (response.empty !== undefined)
34027
34110
  return response.empty;
@@ -34034,7 +34117,7 @@ function formatPriorities(response, agents) {
34034
34117
  "",
34035
34118
  ...priorityFaultLines("Work under no priority", { count: unplaced.count, issues: unplaced.issues, by: unplaced.by_project }, agents),
34036
34119
  "",
34037
- ...priorityFaultLines("Priority work parked", { count: parked.count, issues: parked.issues, by: parked.by_priority }, agents)
34120
+ ...priorityFaultLines("Priority work in backlog or icebox", { count: backlog.count, issues: backlog.issues, by: backlog.by_priority }, agents)
34038
34121
  ].join(`
34039
34122
  `);
34040
34123
  }
@@ -34420,26 +34503,26 @@ async function reviewCommand(context) {
34420
34503
 
34421
34504
  // ../envoy-client/src/session-answers.ts
34422
34505
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync3 } from "fs";
34423
- import { join as join7 } from "path";
34506
+ import { join as join8 } from "path";
34424
34507
 
34425
34508
  // ../envoy-client/src/dispatch-session-directory.ts
34426
34509
  import { randomUUID as randomUUID5 } from "crypto";
34427
34510
  import { renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
34428
34511
  import { homedir as homedir2 } from "os";
34429
- import { join as join6 } from "path";
34512
+ import { join as join7 } from "path";
34430
34513
  var SESSION_ID_PATH_SEGMENT = /^[A-Za-z0-9._-]{1,128}$/;
34431
34514
  var PRIVATE_FILE = 384;
34432
34515
  function sessionStateRoot(env) {
34433
34516
  const stateDir = env["DISPATCH_STATE_DIR"];
34434
34517
  if (stateDir)
34435
34518
  return stateDir;
34436
- return join6(env["XDG_STATE_HOME"] || join6(homedir2(), ".local", "state"), "dispatch");
34519
+ return join7(env["XDG_STATE_HOME"] || join7(homedir2(), ".local", "state"), "dispatch");
34437
34520
  }
34438
34521
  function sessionDirectory(env, sessionId) {
34439
34522
  if (!SESSION_ID_PATH_SEGMENT.test(sessionId) || sessionId === "." || sessionId === "..") {
34440
34523
  throw new Error(`dispatch: the session id ${JSON.stringify(sessionId)} is not 1-128 letters, digits, ".", "_" or "-"`);
34441
34524
  }
34442
- return join6(sessionStateRoot(env), "sessions", sessionId);
34525
+ return join7(sessionStateRoot(env), "sessions", sessionId);
34443
34526
  }
34444
34527
  function writeAtomically(path, text) {
34445
34528
  const temporary = `${path}.${process.pid}.${randomUUID5()}.tmp`;
@@ -34590,7 +34673,7 @@ processGlobal2[STATE_KEY] = state;
34590
34673
  var CACHE_FILE = "answers.json";
34591
34674
  function readCacheFile(directory, url) {
34592
34675
  try {
34593
- const value = JSON.parse(readFileSync3(join7(directory, CACHE_FILE), "utf-8"));
34676
+ const value = JSON.parse(readFileSync3(join8(directory, CACHE_FILE), "utf-8"));
34594
34677
  if (typeof value === "object" && value !== null && "dispatch_url" in value && typeof value.dispatch_url === "string" && value.dispatch_url === url && "read_at" in value && typeof value.read_at === "string" && "total" in value && typeof value.total === "number" && "items" in value && Array.isArray(value.items)) {
34595
34678
  return {
34596
34679
  dispatch_url: value.dispatch_url,
@@ -34711,7 +34794,7 @@ async function readSessionAnswers(options) {
34711
34794
  if (directory !== undefined) {
34712
34795
  try {
34713
34796
  mkdirSync2(directory, { recursive: true, mode: 448 });
34714
- writeAtomically(join7(directory, CACHE_FILE), JSON.stringify(cache));
34797
+ writeAtomically(join8(directory, CACHE_FILE), JSON.stringify(cache));
34715
34798
  } catch {}
34716
34799
  }
34717
34800
  return { cache };
@@ -35062,6 +35145,7 @@ var dispatchCommands = {
35062
35145
  dispatch_answers: onSession(answersCommand),
35063
35146
  dispatch_whoami: onSession(whoamiCommand),
35064
35147
  dispatch_limits: onSession(limitsCommand),
35148
+ dispatch_api: onSession(apiCommand),
35065
35149
  dispatch_inbox: onSession(inboxCommand)
35066
35150
  };
35067
35151
  // ../envoy-client/src/dispatch-execute.ts
@@ -35097,7 +35181,7 @@ import {
35097
35181
  statSync as statSync2,
35098
35182
  writeFileSync as writeFileSync3
35099
35183
  } from "fs";
35100
- import { join as join8 } from "path";
35184
+ import { join as join9 } from "path";
35101
35185
  var PRIVATE_DIR = 448;
35102
35186
  var PRIVATE_FILE2 = 384;
35103
35187
  var IDLE_SESSION_MS = 14 * 86400000;
@@ -35125,7 +35209,7 @@ function stringList(value) {
35125
35209
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
35126
35210
  }
35127
35211
  function loadSessionMemory(dir, sessionId) {
35128
- const path = join8(dir, "state.json");
35212
+ const path = join9(dir, "state.json");
35129
35213
  const text = readIfPresent(path);
35130
35214
  if (text === undefined)
35131
35215
  return new Set;
@@ -35149,7 +35233,7 @@ function writeMemory(dir, sessionId, follows) {
35149
35233
  pictures: [...shownPictures(sessionId)],
35150
35234
  follows: [...follows]
35151
35235
  };
35152
- writeAtomically(join8(dir, "state.json"), `${JSON.stringify(state)}
35236
+ writeAtomically(join9(dir, "state.json"), `${JSON.stringify(state)}
35153
35237
  `);
35154
35238
  }
35155
35239
  function appendResult(dir, entry) {
@@ -35158,7 +35242,7 @@ function appendResult(dir, entry) {
35158
35242
  }
35159
35243
  function writeResult(dir, entry) {
35160
35244
  const line = { at: new Date().toISOString(), ...entry };
35161
- appendFileSync2(join8(dir, "results.jsonl"), `${JSON.stringify(line)}
35245
+ appendFileSync2(join9(dir, "results.jsonl"), `${JSON.stringify(line)}
35162
35246
  `, { mode: PRIVATE_FILE2 });
35163
35247
  }
35164
35248
  function recordOutcome(dir, sessionId, follows, entry) {
@@ -35169,8 +35253,8 @@ function recordOutcome(dir, sessionId, follows, entry) {
35169
35253
  function writePicture(dir, image) {
35170
35254
  const bytes = Buffer.from(image.data, "base64");
35171
35255
  const name = createHash3("sha256").update(bytes).digest("hex").slice(0, 16);
35172
- const pictures = join8(dir, "pictures");
35173
- const path = join8(pictures, `${name}.${PICTURE_EXTENSIONS[image.mimeType]}`);
35256
+ const pictures = join9(dir, "pictures");
35257
+ const path = join9(pictures, `${name}.${PICTURE_EXTENSIONS[image.mimeType]}`);
35174
35258
  ensureDirectory(pictures);
35175
35259
  try {
35176
35260
  writeFileSync3(path, bytes, { mode: PRIVATE_FILE2, flag: "wx" });
@@ -35181,21 +35265,21 @@ function writePicture(dir, image) {
35181
35265
  return { path, bytes: bytes.length };
35182
35266
  }
35183
35267
  function writeLongOutput(dir, text) {
35184
- const out = join8(dir, "out");
35268
+ const out = join9(dir, "out");
35185
35269
  ensureDirectory(out);
35186
- const path = join8(out, `${new Date().toISOString().replaceAll(":", "-")}-${process.pid}.md`);
35270
+ const path = join9(out, `${new Date().toISOString().replaceAll(":", "-")}-${process.pid}.md`);
35187
35271
  writeFileSync3(path, text, { mode: PRIVATE_FILE2 });
35188
35272
  return path;
35189
35273
  }
35190
35274
  function writeSessionTitle(dir, title) {
35191
35275
  ensureDirectory(dir);
35192
- writeAtomically(join8(dir, "title"), title);
35276
+ writeAtomically(join9(dir, "title"), title);
35193
35277
  }
35194
35278
  function readSessionTitle(dir) {
35195
- return readIfPresent(join8(dir, "title")) || undefined;
35279
+ return readIfPresent(join9(dir, "title")) || undefined;
35196
35280
  }
35197
35281
  function pruneSessions(root, now) {
35198
- const stamp = join8(root, PRUNED_STAMP);
35282
+ const stamp = join9(root, PRUNED_STAMP);
35199
35283
  try {
35200
35284
  if (now - statSync2(stamp).mtimeMs < PRUNE_INTERVAL_MS)
35201
35285
  return;
@@ -35203,7 +35287,7 @@ function pruneSessions(root, now) {
35203
35287
  if (!hasErrnoCode(error, "ENOENT"))
35204
35288
  throw error;
35205
35289
  }
35206
- const sessions = join8(root, "sessions");
35290
+ const sessions = join9(root, "sessions");
35207
35291
  let entries = [];
35208
35292
  try {
35209
35293
  entries = readdirSync2(sessions, { withFileTypes: true });
@@ -35214,7 +35298,7 @@ function pruneSessions(root, now) {
35214
35298
  for (const entry of entries) {
35215
35299
  if (!entry.isDirectory())
35216
35300
  continue;
35217
- const dir = join8(sessions, entry.name);
35301
+ const dir = join9(sessions, entry.name);
35218
35302
  try {
35219
35303
  const idle = now - statSync2(dir).mtimeMs > IDLE_SESSION_MS;
35220
35304
  if (idle && askgateState(dir, now).kind === "off" && !recordNamesStore(dir)) {