replicas-engine 0.1.933 → 0.1.934

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/src/index.js CHANGED
@@ -26,8 +26,13 @@ import {
26
26
  import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
- reportCommandProtectionBlock
30
- } from "./chunk-SY46VC2H.js";
29
+ getCurrentBranch,
30
+ getOriginDefaultBranch,
31
+ readRepoHeadBranches,
32
+ reportCommandProtectionBlock,
33
+ resolveDiffBase,
34
+ runGitCommand
35
+ } from "./chunk-T3YADB2L.js";
31
36
  import {
32
37
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
38
  AGENT_MESSAGE_DELTA_METHOD,
@@ -52,7 +57,7 @@ import {
52
57
  } from "./chunk-FLDA7BX3.js";
53
58
  import {
54
59
  publishedPullRequestUrls
55
- } from "./chunk-RAZD4N5G.js";
60
+ } from "./chunk-KQOMWVOJ.js";
56
61
  import {
57
62
  RELAY_MCP_TOOLS,
58
63
  RELAY_MCP_TOOL_NAMES,
@@ -74,7 +79,7 @@ import {
74
79
  refreshDelayMs,
75
80
  restartCodexAspHost,
76
81
  routineRefreshExclusions
77
- } from "./chunk-5PTJWSW3.js";
82
+ } from "./chunk-ET2HBN72.js";
78
83
  import {
79
84
  ENGINE_ENV,
80
85
  monolithRequest,
@@ -82,14 +87,16 @@ import {
82
87
  readRuntimeEnvFile,
83
88
  reloadEngineEnv,
84
89
  setAgentCredentialSnapshot
85
- } from "./chunk-3GJEQKPY.js";
90
+ } from "./chunk-CXSJSSFY.js";
86
91
  import {
87
92
  AspClient,
93
+ getCodexModelProvider
94
+ } from "./chunk-F3EHVMWY.js";
95
+ import {
88
96
  SUBPROCESS_MAX_BUFFER,
89
97
  execAsync,
90
- execFileAsync,
91
- getCodexModelProvider
92
- } from "./chunk-BXHF65NV.js";
98
+ execFileAsync
99
+ } from "./chunk-E4MPACC3.js";
93
100
  import {
94
101
  isRecord as isRecord2
95
102
  } from "./chunk-UZSNFLDQ.js";
@@ -319,7 +326,7 @@ import {
319
326
  workspaceCredentialProviderSchema,
320
327
  workspaceTokenRequestSchema,
321
328
  workspaceTokenResponseSchema
322
- } from "./chunk-RVSMHQVH.js";
329
+ } from "./chunk-3LWSEH3N.js";
323
330
  import {
324
331
  cloneMcpConfig,
325
332
  ensureCompatibilityImports,
@@ -520,7 +527,7 @@ var require_lib = __commonJS({
520
527
  "../node_modules/.bun/which@5.0.0/node_modules/which/lib/index.js"(exports, module) {
521
528
  "use strict";
522
529
  var { isexe, sync: isexeSync } = require_index_min();
523
- var { join: join40, delimiter: delimiter3, sep: sep2, posix } = __require("path");
530
+ var { join: join39, delimiter: delimiter3, sep: sep2, posix } = __require("path");
524
531
  var isWindows = process.platform === "win32";
525
532
  var rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
526
533
  var rRel = new RegExp(`^\\.${rSlash.source}`);
@@ -549,7 +556,7 @@ var require_lib = __commonJS({
549
556
  var getPathPart = (raw, cmd) => {
550
557
  const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
551
558
  const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
552
- return prefix + join40(pathPart, cmd);
559
+ return prefix + join39(pathPart, cmd);
553
560
  };
554
561
  var which = async (cmd, opt = {}) => {
555
562
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
@@ -3828,7 +3835,7 @@ var require_compile2 = __commonJS({
3828
3835
  const schOrFunc = root.refs[ref];
3829
3836
  if (schOrFunc)
3830
3837
  return schOrFunc;
3831
- let _sch = resolve8.call(this, root, ref);
3838
+ let _sch = resolve7.call(this, root, ref);
3832
3839
  if (_sch === void 0) {
3833
3840
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
3834
3841
  const { schemaId } = this.opts;
@@ -3855,7 +3862,7 @@ var require_compile2 = __commonJS({
3855
3862
  function sameSchemaEnv(s1, s2) {
3856
3863
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3857
3864
  }
3858
- function resolve8(root, ref) {
3865
+ function resolve7(root, ref) {
3859
3866
  let sch;
3860
3867
  while (typeof (sch = this.refs[ref]) == "string")
3861
3868
  ref = sch;
@@ -4486,7 +4493,7 @@ var require_fast_uri2 = __commonJS({
4486
4493
  }
4487
4494
  return uri;
4488
4495
  }
4489
- function resolve8(baseURI, relativeURI, options) {
4496
+ function resolve7(baseURI, relativeURI, options) {
4490
4497
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
4491
4498
  const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
4492
4499
  schemelessOptions.skipEscape = true;
@@ -4744,7 +4751,7 @@ var require_fast_uri2 = __commonJS({
4744
4751
  var fastUri = {
4745
4752
  SCHEMES,
4746
4753
  normalize,
4747
- resolve: resolve8,
4754
+ resolve: resolve7,
4748
4755
  resolveComponent,
4749
4756
  equal,
4750
4757
  serialize,
@@ -8641,7 +8648,7 @@ function removeCredentialFileLines(filePath, shouldRemove) {
8641
8648
  // src/git/service.ts
8642
8649
  import { readdir, readFile as readFile3, stat } from "fs/promises";
8643
8650
  import { spawn } from "child_process";
8644
- import { join as join4 } from "path";
8651
+ import { join as join3 } from "path";
8645
8652
 
8646
8653
  // src/utils/state.ts
8647
8654
  import { readFile as readFile2, mkdir as mkdir2 } from "fs/promises";
@@ -8749,74 +8756,6 @@ async function saveRepoState(repoName, state, fallbackState) {
8749
8756
  return updated.repos[repoName];
8750
8757
  }
8751
8758
 
8752
- // src/git/commands.ts
8753
- import { readdirSync, readFileSync, statSync } from "fs";
8754
- import { join as join3, resolve } from "path";
8755
- async function runGitCommand(args, cwd, options = {}) {
8756
- const { stdout } = await execFileAsync("git", args, {
8757
- cwd,
8758
- encoding: "utf-8",
8759
- maxBuffer: options.maxBuffer ?? SUBPROCESS_MAX_BUFFER
8760
- });
8761
- return stdout.trim();
8762
- }
8763
- function readRepoHeadBranches(repoPath) {
8764
- const branches = /* @__PURE__ */ new Set();
8765
- try {
8766
- let gitDir = join3(repoPath, ".git");
8767
- if (statSync(gitDir).isFile()) {
8768
- const target = readFileSync(gitDir, "utf8").trim().match(/^gitdir: (.+)$/)?.[1];
8769
- if (!target) return branches;
8770
- gitDir = resolve(repoPath, target);
8771
- }
8772
- let commonDir = gitDir;
8773
- try {
8774
- commonDir = resolve(gitDir, readFileSync(join3(gitDir, "commondir"), "utf8").trim());
8775
- } catch {
8776
- }
8777
- const headDirs = /* @__PURE__ */ new Set([gitDir, commonDir]);
8778
- try {
8779
- for (const entry of readdirSync(join3(commonDir, "worktrees"))) {
8780
- headDirs.add(join3(commonDir, "worktrees", entry));
8781
- }
8782
- } catch {
8783
- }
8784
- for (const dir of headDirs) {
8785
- try {
8786
- const branch = readFileSync(join3(dir, "HEAD"), "utf8").trim().match(/^ref:\s+refs\/heads\/(.+)$/)?.[1];
8787
- if (branch) branches.add(branch);
8788
- } catch {
8789
- }
8790
- }
8791
- } catch {
8792
- }
8793
- return branches;
8794
- }
8795
- async function branchExists(branchName, cwd) {
8796
- try {
8797
- await runGitCommand(["rev-parse", "--verify", branchName], cwd);
8798
- return true;
8799
- } catch {
8800
- return false;
8801
- }
8802
- }
8803
- async function getCurrentBranch(cwd) {
8804
- try {
8805
- return await runGitCommand(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
8806
- } catch (error) {
8807
- console.error("Error getting current branch:", error);
8808
- return null;
8809
- }
8810
- }
8811
- async function resolveDiffBase(repoPath, defaultBranch) {
8812
- const baseBranch = `origin/${defaultBranch}`;
8813
- try {
8814
- return await runGitCommand(["merge-base", baseBranch, "HEAD"], repoPath);
8815
- } catch {
8816
- }
8817
- return await branchExists(baseBranch, repoPath) ? baseBranch : "HEAD";
8818
- }
8819
-
8820
8759
  // src/git/service.ts
8821
8760
  var FULL_DIFF_MAX_BUFFER = 50 * 1024 * 1024;
8822
8761
  var MAX_DIFF_FILE_BYTES = 1024 * 1024;
@@ -8851,13 +8790,13 @@ var GitService = class {
8851
8790
  const repos = [];
8852
8791
  let complete2 = true;
8853
8792
  for (const entry of entries) {
8854
- const fullPath = join4(root, entry);
8793
+ const fullPath = join3(root, entry);
8855
8794
  try {
8856
8795
  const entryStat = await stat(fullPath);
8857
8796
  if (!entryStat.isDirectory()) {
8858
8797
  continue;
8859
8798
  }
8860
- const hasGit = Boolean(await this.safeStat(join4(fullPath, ".git")));
8799
+ const hasGit = Boolean(await this.safeStat(join3(fullPath, ".git")));
8861
8800
  if (!hasGit) {
8862
8801
  continue;
8863
8802
  }
@@ -9011,7 +8950,7 @@ var GitService = class {
9011
8950
  for (let i = 0; i < paths.length; i += UNTRACKED_STAT_CONCURRENCY) {
9012
8951
  const batch = await Promise.all(paths.slice(i, i + UNTRACKED_STAT_CONCURRENCY).map(async (path7) => {
9013
8952
  try {
9014
- return { path: path7, size: (await stat(join4(repoPath, path7))).size };
8953
+ return { path: path7, size: (await stat(join3(repoPath, path7))).size };
9015
8954
  } catch {
9016
8955
  return null;
9017
8956
  }
@@ -9053,7 +8992,7 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
9053
8992
  }
9054
8993
  }
9055
8994
  readUntrackedDiff(repoPath, paths) {
9056
- return new Promise((resolve8) => {
8995
+ return new Promise((resolve7) => {
9057
8996
  const child = spawn("git", ["diff", "--", ...paths], {
9058
8997
  cwd: repoPath,
9059
8998
  stdio: ["ignore", "pipe", "pipe"]
@@ -9074,12 +9013,12 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
9074
9013
  });
9075
9014
  child.stderr.on("data", () => {
9076
9015
  });
9077
- child.on("error", () => resolve8(""));
9016
+ child.on("error", () => resolve7(""));
9078
9017
  child.on("close", (code) => {
9079
9018
  if (code === 0 || code === 1 || truncated) {
9080
- resolve8(Buffer.concat(chunks).toString("utf-8"));
9019
+ resolve7(Buffer.concat(chunks).toString("utf-8"));
9081
9020
  } else {
9082
- resolve8("");
9021
+ resolve7("");
9083
9022
  }
9084
9023
  });
9085
9024
  });
@@ -9091,7 +9030,7 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
9091
9030
  for (const { path: path7, tooLarge } of files) {
9092
9031
  if (tooLarge) continue;
9093
9032
  try {
9094
- const contents = await readFile3(join4(repoPath, path7));
9033
+ const contents = await readFile3(join3(repoPath, path7));
9095
9034
  if (contents.length === 0 || contents.includes(0)) {
9096
9035
  continue;
9097
9036
  }
@@ -9279,7 +9218,7 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
9279
9218
  }
9280
9219
  async getGitLabAccessToken(host) {
9281
9220
  try {
9282
- const credentials = await readFile3(join4(ENGINE_ENV.HOME_DIR, ".git-credentials"), "utf-8");
9221
+ const credentials = await readFile3(join3(ENGINE_ENV.HOME_DIR, ".git-credentials"), "utf-8");
9283
9222
  for (const line of credentials.split("\n")) {
9284
9223
  const trimmed = line.trim();
9285
9224
  if (!trimmed) continue;
@@ -9300,22 +9239,13 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
9300
9239
  if (cached) {
9301
9240
  return cached;
9302
9241
  }
9303
- const fromSymbolicRef = await this.resolveDefaultBranchFromSymbolicRef(repoPath);
9242
+ const fromSymbolicRef = await getOriginDefaultBranch(repoPath);
9304
9243
  if (fromSymbolicRef) {
9305
9244
  this.defaultBranchCache.set(repoPath, fromSymbolicRef);
9306
9245
  return fromSymbolicRef;
9307
9246
  }
9308
9247
  return "main";
9309
9248
  }
9310
- async resolveDefaultBranchFromSymbolicRef(repoPath) {
9311
- try {
9312
- const output = await runGitCommand(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], repoPath);
9313
- const match = output.match(/^origin\/(.+)$/);
9314
- return match ? match[1] : null;
9315
- } catch {
9316
- return null;
9317
- }
9318
- }
9319
9249
  async refreshRepoMetadata(repo, currentBranch, startHooksCompleted, persistedState, observedBranches, includeDiffs = false) {
9320
9250
  const notFound = { status: "not_found" };
9321
9251
  const prResult = currentBranch === repo.defaultBranch ? notFound : await this.getPullRequestUrl(repo.name, repo.path, currentBranch, persistedState);
@@ -9743,7 +9673,7 @@ function resolveIdentityRoute(requestUrl) {
9743
9673
  return { target, audience: decode(encodedAudience) };
9744
9674
  }
9745
9675
  function readJsonBody(request) {
9746
- return new Promise((resolve8) => {
9676
+ return new Promise((resolve7) => {
9747
9677
  const chunks = [];
9748
9678
  let size = 0;
9749
9679
  request.on("data", (chunk) => {
@@ -9751,15 +9681,15 @@ function readJsonBody(request) {
9751
9681
  if (size <= MAX_TOKEN_REQUEST_BYTES) chunks.push(chunk);
9752
9682
  });
9753
9683
  request.on("end", () => {
9754
- if (size > MAX_TOKEN_REQUEST_BYTES) return resolve8(null);
9684
+ if (size > MAX_TOKEN_REQUEST_BYTES) return resolve7(null);
9755
9685
  const text = Buffer.concat(chunks).toString("utf8").trim();
9756
9686
  try {
9757
- resolve8(text ? JSON.parse(text) : {});
9687
+ resolve7(text ? JSON.parse(text) : {});
9758
9688
  } catch {
9759
- resolve8(null);
9689
+ resolve7(null);
9760
9690
  }
9761
9691
  });
9762
- request.on("error", () => resolve8(null));
9692
+ request.on("error", () => resolve7(null));
9763
9693
  });
9764
9694
  }
9765
9695
  function createIdentityProxy(tokens) {
@@ -9814,7 +9744,7 @@ function createIdentityProxy(tokens) {
9814
9744
  }
9815
9745
 
9816
9746
  // src/lifecycle.ts
9817
- import { readFileSync as readFileSync2, rmSync, writeFileSync } from "fs";
9747
+ import { readFileSync, rmSync, writeFileSync } from "fs";
9818
9748
  var CLAIM_FILE = "/tmp/replicas-engine.claim";
9819
9749
  var EngineLifecycle = class {
9820
9750
  state = "parked";
@@ -9827,7 +9757,7 @@ var EngineLifecycle = class {
9827
9757
  /** The workspace an earlier run of this engine activated for and never slept. */
9828
9758
  get claimedWorkspaceId() {
9829
9759
  try {
9830
- return readFileSync2(CLAIM_FILE, "utf-8").trim() || null;
9760
+ return readFileSync(CLAIM_FILE, "utf-8").trim() || null;
9831
9761
  } catch {
9832
9762
  return null;
9833
9763
  }
@@ -9847,11 +9777,11 @@ var EngineLifecycle = class {
9847
9777
  }
9848
9778
  waitForActive(timeoutMs) {
9849
9779
  if (this.active) return Promise.resolve();
9850
- return new Promise((resolve8) => {
9851
- const timer = setTimeout(resolve8, timeoutMs);
9780
+ return new Promise((resolve7) => {
9781
+ const timer = setTimeout(resolve7, timeoutMs);
9852
9782
  this.activeWaiters.push(() => {
9853
9783
  clearTimeout(timer);
9854
- resolve8();
9784
+ resolve7();
9855
9785
  });
9856
9786
  });
9857
9787
  }
@@ -9867,7 +9797,7 @@ var lifecycle = new EngineLifecycle();
9867
9797
  // src/utils/logger.ts
9868
9798
  import { mkdir as mkdir3, writeFile as writeFile2 } from "fs/promises";
9869
9799
  import { homedir as homedir2 } from "os";
9870
- import { join as join5 } from "path";
9800
+ import { join as join4 } from "path";
9871
9801
  import { format } from "util";
9872
9802
  import { randomBytes } from "crypto";
9873
9803
 
@@ -9902,9 +9832,9 @@ var StreamWriter = class {
9902
9832
  return true;
9903
9833
  }
9904
9834
  flush(signal) {
9905
- return new Promise((resolve8, reject) => {
9835
+ return new Promise((resolve7, reject) => {
9906
9836
  if (!this.stream) {
9907
- resolve8();
9837
+ resolve7();
9908
9838
  return;
9909
9839
  }
9910
9840
  if (this.flushTimer) {
@@ -9921,7 +9851,7 @@ var StreamWriter = class {
9921
9851
  s.write("", (error) => {
9922
9852
  signal?.removeEventListener("abort", onAbort);
9923
9853
  if (error) reject(error);
9924
- else resolve8();
9854
+ else resolve7();
9925
9855
  });
9926
9856
  });
9927
9857
  }
@@ -9942,7 +9872,7 @@ var StreamWriter = class {
9942
9872
  };
9943
9873
 
9944
9874
  // src/utils/logger.ts
9945
- var LOG_DIR = join5(homedir2(), ".replicas", "logs");
9875
+ var LOG_DIR = join4(homedir2(), ".replicas", "logs");
9946
9876
  var EngineLogger = class {
9947
9877
  _sessionId = null;
9948
9878
  patched = false;
@@ -9953,7 +9883,7 @@ var EngineLogger = class {
9953
9883
  async initialize() {
9954
9884
  await mkdir3(LOG_DIR, { recursive: true });
9955
9885
  this._sessionId = this.createSessionId();
9956
- const logPath = join5(LOG_DIR, `${this._sessionId}.log`);
9886
+ const logPath = join4(LOG_DIR, `${this._sessionId}.log`);
9957
9887
  await writeFile2(logPath, `=== Replicas Engine Session ${this._sessionId} ===
9958
9888
  `, "utf-8");
9959
9889
  this.writer.open(logPath);
@@ -10000,7 +9930,7 @@ var engineLogger = new EngineLogger();
10000
9930
  // src/services/replicas-config-service.ts
10001
9931
  import { readFile as readFile7, appendFile, writeFile as writeFile4, mkdir as mkdir6 } from "fs/promises";
10002
9932
  import { existsSync as existsSync4 } from "fs";
10003
- import { join as join10 } from "path";
9933
+ import { join as join9 } from "path";
10004
9934
  import { homedir as homedir7 } from "os";
10005
9935
  import { spawn as spawn2 } from "child_process";
10006
9936
 
@@ -10008,20 +9938,20 @@ import { spawn as spawn2 } from "child_process";
10008
9938
  import { mkdir as mkdir4, readFile as readFile5 } from "fs/promises";
10009
9939
  import { existsSync as existsSync3 } from "fs";
10010
9940
  import { homedir as homedir5 } from "os";
10011
- import { join as join8 } from "path";
9941
+ import { join as join7 } from "path";
10012
9942
 
10013
9943
  // src/managers/agent-auth-detection.ts
10014
9944
  import { existsSync as existsSync2 } from "fs";
10015
9945
  import { homedir as homedir4 } from "os";
10016
- import { join as join7 } from "path";
9946
+ import { join as join6 } from "path";
10017
9947
 
10018
9948
  // src/managers/agent-auth-paths.ts
10019
9949
  import { homedir as homedir3 } from "os";
10020
- import { join as join6 } from "path";
10021
- var OPENCODE_AUTH_PATH = join6(homedir3(), ".local", "share", "opencode", "auth.json");
10022
- var PI_AUTH_PATH = join6(homedir3(), ".pi", "agent", "auth.json");
10023
- var PI_MCP_CONFIG_PATH = join6(homedir3(), ".pi", "agent", "mcp.json");
10024
- var MUSE_AUTH_PATH = join6(homedir3(), ".config", "muse", "auth.json");
9950
+ import { join as join5 } from "path";
9951
+ var OPENCODE_AUTH_PATH = join5(homedir3(), ".local", "share", "opencode", "auth.json");
9952
+ var PI_AUTH_PATH = join5(homedir3(), ".pi", "agent", "auth.json");
9953
+ var PI_MCP_CONFIG_PATH = join5(homedir3(), ".pi", "agent", "mcp.json");
9954
+ var MUSE_AUTH_PATH = join5(homedir3(), ".config", "muse", "auth.json");
10025
9955
 
10026
9956
  // src/managers/codex-auth.ts
10027
9957
  function detectCodexAuthMethod() {
@@ -10029,7 +9959,7 @@ function detectCodexAuthMethod() {
10029
9959
  }
10030
9960
 
10031
9961
  // src/managers/agent-auth-detection.ts
10032
- var CLAUDE_CREDENTIALS_PATH = join7(homedir4(), ".claude", ".credentials.json");
9962
+ var CLAUDE_CREDENTIALS_PATH = join6(homedir4(), ".claude", ".credentials.json");
10033
9963
  function detectClaudeAuthMethod() {
10034
9964
  if (ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD === "ollama") return "ollama";
10035
9965
  if (existsSync2(CLAUDE_CREDENTIALS_PATH)) {
@@ -10095,10 +10025,10 @@ async function getPiProviderCredentials() {
10095
10025
  }
10096
10026
 
10097
10027
  // src/services/environment-details-service.ts
10098
- var REPLICAS_DIR = join8(homedir5(), ".replicas");
10099
- var DETAILS_FILE = join8(REPLICAS_DIR, "environment-details.json");
10100
- var GH_HOSTS_PATH = join8(homedir5(), ".config", "gh", "hosts.yml");
10101
- var GIT_CREDENTIALS_PATH = join8(homedir5(), ".git-credentials");
10028
+ var REPLICAS_DIR = join7(homedir5(), ".replicas");
10029
+ var DETAILS_FILE = join7(REPLICAS_DIR, "environment-details.json");
10030
+ var GH_HOSTS_PATH = join7(homedir5(), ".config", "gh", "hosts.yml");
10031
+ var GIT_CREDENTIALS_PATH = join7(homedir5(), ".git-credentials");
10102
10032
  async function detectGitIdentityConfigured() {
10103
10033
  try {
10104
10034
  const { stdout } = await execFileAsync("git", ["config", "--global", "user.name"]);
@@ -10289,7 +10219,7 @@ var environmentDetailsService = new EnvironmentDetailsService();
10289
10219
  // src/services/start-hook-logs-service.ts
10290
10220
  import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile3, readdir as readdir2 } from "fs/promises";
10291
10221
  import { homedir as homedir6 } from "os";
10292
- import { join as join9 } from "path";
10222
+ import { join as join8 } from "path";
10293
10223
 
10294
10224
  // src/services/hook-log-files.ts
10295
10225
  import { createHash } from "crypto";
@@ -10301,7 +10231,7 @@ function repoHookLogFilename(repoName) {
10301
10231
  }
10302
10232
 
10303
10233
  // src/services/start-hook-logs-service.ts
10304
- var LOGS_DIR = join9(homedir6(), ".replicas", "start-hook-logs");
10234
+ var LOGS_DIR = join8(homedir6(), ".replicas", "start-hook-logs");
10305
10235
  function withPreview(stored) {
10306
10236
  const preview = buildHookOutputPreview(stored.output);
10307
10237
  return { ...stored, ...preview };
@@ -10339,7 +10269,7 @@ var StartHookLogsService = class {
10339
10269
  await this.ensureDir();
10340
10270
  const log = { hookType, hookName, repoName: hookName, ...entry };
10341
10271
  const filename = hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
10342
- await writeFile3(join9(LOGS_DIR, filename), `${JSON.stringify(log, null, 2)}
10272
+ await writeFile3(join8(LOGS_DIR, filename), `${JSON.stringify(log, null, 2)}
10343
10273
  `, "utf-8");
10344
10274
  }
10345
10275
  async saveEnvironmentLog(entry) {
@@ -10364,7 +10294,7 @@ var StartHookLogsService = class {
10364
10294
  continue;
10365
10295
  }
10366
10296
  try {
10367
- const raw = await readFile6(join9(LOGS_DIR, file), "utf-8");
10297
+ const raw = await readFile6(join8(LOGS_DIR, file), "utf-8");
10368
10298
  const stored = normalizeStored(JSON.parse(raw));
10369
10299
  if (stored) {
10370
10300
  logs.push(withPreview(stored));
@@ -10383,7 +10313,7 @@ var StartHookLogsService = class {
10383
10313
  async getFullOutput(hookType, hookName) {
10384
10314
  const filename = hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
10385
10315
  try {
10386
- const raw = await readFile6(join9(LOGS_DIR, filename), "utf-8");
10316
+ const raw = await readFile6(join8(LOGS_DIR, filename), "utf-8");
10387
10317
  const stored = normalizeStored(JSON.parse(raw));
10388
10318
  if (!stored || stored.hookType !== hookType || stored.hookName !== hookName) {
10389
10319
  return null;
@@ -10400,7 +10330,7 @@ var StartHookLogsService = class {
10400
10330
  var startHookLogsService = new StartHookLogsService();
10401
10331
 
10402
10332
  // src/services/replicas-config-service.ts
10403
- var START_HOOKS_LOG = join10(homedir7(), ".replicas", "startHooks.log");
10333
+ var START_HOOKS_LOG = join9(homedir7(), ".replicas", "startHooks.log");
10404
10334
  var START_HOOKS_RUNNING_PROMPT = `IMPORTANT - Start Hooks Running:
10405
10335
  Start hooks are shell commands/scripts set by repository owners that run on workspace startup.
10406
10336
  These hooks are currently executing in the background. You can:
@@ -10411,7 +10341,7 @@ The start hooks may install dependencies, build projects, or perform other setup
10411
10341
  If your task depends on setup being complete, check the log file before proceeding.`;
10412
10342
  async function readReplicasConfigFromDir(dirPath) {
10413
10343
  for (const filename of REPLICAS_CONFIG_FILENAMES) {
10414
- const configPath = join10(dirPath, filename);
10344
+ const configPath = join9(dirPath, filename);
10415
10345
  if (!existsSync4(configPath)) {
10416
10346
  continue;
10417
10347
  }
@@ -10460,7 +10390,7 @@ var ReplicasConfigService = class {
10460
10390
  });
10461
10391
  if (signal("SIGTERM").length === 0) return;
10462
10392
  const deadline = Date.now() + 5e3;
10463
- while (signal(0).length > 0 && Date.now() < deadline) await new Promise((resolve8) => setTimeout(resolve8, 25));
10393
+ while (signal(0).length > 0 && Date.now() < deadline) await new Promise((resolve7) => setTimeout(resolve7, 25));
10464
10394
  signal("SIGKILL");
10465
10395
  }
10466
10396
  /**
@@ -10500,7 +10430,7 @@ var ReplicasConfigService = class {
10500
10430
  const logLine = `[${timestamp}] ${message}
10501
10431
  `;
10502
10432
  try {
10503
- await mkdir6(join10(homedir7(), ".replicas"), { recursive: true });
10433
+ await mkdir6(join9(homedir7(), ".replicas"), { recursive: true });
10504
10434
  await appendFile(START_HOOKS_LOG, logLine, "utf-8");
10505
10435
  } catch (error) {
10506
10436
  console.error("Failed to write to start hooks log:", error);
@@ -10536,7 +10466,7 @@ var ReplicasConfigService = class {
10536
10466
  await this.logToFile(`[${params.repoName}] --- Running: ${params.label} ---`);
10537
10467
  emit(`$ ${params.label}
10538
10468
  `);
10539
- return new Promise((resolve8) => {
10469
+ return new Promise((resolve7) => {
10540
10470
  const proc = spawn2("bash", ["-lc", params.command], {
10541
10471
  cwd: params.cwd,
10542
10472
  env: process.env,
@@ -10549,7 +10479,7 @@ var ReplicasConfigService = class {
10549
10479
  const finish = (result) => {
10550
10480
  if (settled) return;
10551
10481
  settled = true;
10552
- resolve8(result);
10482
+ resolve7(result);
10553
10483
  };
10554
10484
  const timer = setTimeout(() => {
10555
10485
  timedOut = true;
@@ -10638,7 +10568,7 @@ var ReplicasConfigService = class {
10638
10568
  this.hooksCompleted = false;
10639
10569
  this.hooksFailed = false;
10640
10570
  try {
10641
- await mkdir6(join10(homedir7(), ".replicas"), { recursive: true });
10571
+ await mkdir6(join9(homedir7(), ".replicas"), { recursive: true });
10642
10572
  await writeFile4(
10643
10573
  START_HOOKS_LOG,
10644
10574
  `=== Start Hooks Execution Log ===
@@ -10835,10 +10765,10 @@ var replicasConfigService = new ReplicasConfigService();
10835
10765
  // src/services/event-service.ts
10836
10766
  import { mkdir as mkdir7 } from "fs/promises";
10837
10767
  import { homedir as homedir8 } from "os";
10838
- import { join as join11 } from "path";
10768
+ import { join as join10 } from "path";
10839
10769
  import { randomUUID as randomUUID2 } from "crypto";
10840
- var ENGINE_DIR = join11(homedir8(), ".replicas", "engine");
10841
- var EVENTS_FILE = join11(ENGINE_DIR, "events.jsonl");
10770
+ var ENGINE_DIR = join10(homedir8(), ".replicas", "engine");
10771
+ var EVENTS_FILE = join10(ENGINE_DIR, "events.jsonl");
10842
10772
  var EventService = class {
10843
10773
  subscribers = /* @__PURE__ */ new Map();
10844
10774
  writer = new StreamWriter();
@@ -10873,8 +10803,8 @@ import { mkdir as mkdir8, readFile as readFile8 } from "fs/promises";
10873
10803
  import { existsSync as existsSync5 } from "fs";
10874
10804
  import { randomUUID as randomUUID3 } from "crypto";
10875
10805
  import { homedir as homedir9 } from "os";
10876
- import { dirname as dirname2, join as join12 } from "path";
10877
- var PREVIEW_PORTS_FILE = join12(homedir9(), ".replicas", "preview-ports.json");
10806
+ import { dirname as dirname2, join as join11 } from "path";
10807
+ var PREVIEW_PORTS_FILE = join11(homedir9(), ".replicas", "preview-ports.json");
10878
10808
  async function readPreviewsFile() {
10879
10809
  try {
10880
10810
  if (!existsSync5(PREVIEW_PORTS_FILE)) {
@@ -10989,7 +10919,7 @@ async function registerDesktopPreview(signal) {
10989
10919
 
10990
10920
  // src/services/chat/chat-service.ts
10991
10921
  import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir20, readFile as readFile19, rename as rename4, rm as rm4 } from "fs/promises";
10992
- import { join as join35 } from "path";
10922
+ import { join as join34 } from "path";
10993
10923
  import { randomUUID as randomUUID11 } from "crypto";
10994
10924
 
10995
10925
  // ../shared/src/workspace-chat.ts
@@ -11166,7 +11096,7 @@ import {
11166
11096
  query
11167
11097
  } from "@anthropic-ai/claude-agent-sdk";
11168
11098
  import { randomUUID as randomUUID5 } from "crypto";
11169
- import { dirname as dirname4, join as join16 } from "path";
11099
+ import { dirname as dirname4, join as join15 } from "path";
11170
11100
  import { mkdir as mkdir10, readdir as readdir4, readFile as readFile10 } from "fs/promises";
11171
11101
  import { homedir as homedir11 } from "os";
11172
11102
 
@@ -11554,7 +11484,7 @@ function extractPlanFromCodexAspNotification(notification) {
11554
11484
  import { randomUUID as randomUUID4 } from "crypto";
11555
11485
  import { mkdir as mkdir9, unlink as unlink2, writeFile as writeFile5 } from "fs/promises";
11556
11486
  import { homedir as homedir10 } from "os";
11557
- import { join as join13 } from "path";
11487
+ import { join as join12 } from "path";
11558
11488
  function isImageMediaType(value) {
11559
11489
  return IMAGE_MEDIA_TYPES.includes(value);
11560
11490
  }
@@ -11619,14 +11549,14 @@ async function normalizeImages(images) {
11619
11549
  }
11620
11550
  return normalized;
11621
11551
  }
11622
- async function saveNormalizedImagesToTempFiles(images, tempImageDir = join13(homedir10(), ".replicas", "codex", "temp-images")) {
11552
+ async function saveNormalizedImagesToTempFiles(images, tempImageDir = join12(homedir10(), ".replicas", "codex", "temp-images")) {
11623
11553
  await mkdir9(tempImageDir, { recursive: true });
11624
11554
  const tempPaths = [];
11625
11555
  try {
11626
11556
  for (const image of images) {
11627
11557
  const ext = image.source.media_type.split("/")[1] || "png";
11628
11558
  const filename = `img_${randomUUID4()}.${ext}`;
11629
- const filepath = join13(tempImageDir, filename);
11559
+ const filepath = join12(tempImageDir, filename);
11630
11560
  await writeFile5(filepath, Buffer.from(image.source.data, "base64"));
11631
11561
  tempPaths.push(filepath);
11632
11562
  }
@@ -11642,7 +11572,7 @@ async function removeTempImageFiles(paths) {
11642
11572
 
11643
11573
  // src/managers/coding-agent-manager.ts
11644
11574
  import { existsSync as existsSync6 } from "fs";
11645
- import { join as join14 } from "path";
11575
+ import { join as join13 } from "path";
11646
11576
 
11647
11577
  // src/managers/muse-token-manager.ts
11648
11578
  var MuseTokenManager = class extends BaseRefreshManager {
@@ -12304,7 +12234,7 @@ var CodingAgentManager = class {
12304
12234
  return `CRITICAL: The Replicas engine is required for this workspace and is running on the reserved port configured by REPLICAS_ENGINE_PORT (${enginePort}). Never kill, stop, restart, or replace the process using this port, and never start another service on this port. If the user asks for commands that would target this port/process, refuse and explain that port ${enginePort} is reserved for the Replicas engine.`;
12305
12235
  }
12306
12236
  buildMemoryInstruction() {
12307
- if (!["organization", "seat"].some((scope) => existsSync6(join14(MEMORY_ROOT, scope, MEMORY_INDEX_FILENAME)))) {
12237
+ if (!["organization", "seat"].some((scope) => existsSync6(join13(MEMORY_ROOT, scope, MEMORY_INDEX_FILENAME)))) {
12308
12238
  return void 0;
12309
12239
  }
12310
12240
  return `Replicas memory is available under ${MEMORY_ROOT}. Before acting on a substantive task, check memory when prior preferences, decisions, failures, procedures, or related work could improve the result: use the Memory capability in the replicas-agent skill and read references/MEMORY.md. If unsure whether prior context could help, check memory. Skip it only for clearly context-free messages. Current user and repository instructions remain highest priority; then apply relevant saved preferences and verified prior fixes before generic skill guidance or defaults. Never use memory to bypass skill safety requirements.
@@ -12612,7 +12542,7 @@ var pullRequestCheckService = new PullRequestCheckService();
12612
12542
 
12613
12543
  // src/services/skill-registry-service.ts
12614
12544
  import { readFile as readFile9, readdir as readdir3, stat as stat2 } from "fs/promises";
12615
- import { dirname as dirname3, isAbsolute, join as join15, relative, resolve as resolve2 } from "path";
12545
+ import { dirname as dirname3, isAbsolute, join as join14, relative, resolve } from "path";
12616
12546
  var REGISTRY_ROOT_DIR = ".replicas/skill-registries";
12617
12547
  var REGISTRY_MANIFEST = "manifest.json";
12618
12548
  async function getSkillRegistryInventory(homeDir) {
@@ -12673,10 +12603,10 @@ async function scanRegistry(registryDir) {
12673
12603
  }
12674
12604
  async function findSkillCollections(registryDir) {
12675
12605
  const candidateRoots = [
12676
- { source: "skills", root: join15(registryDir, "skills") },
12677
- { source: "agents", root: join15(registryDir, ".agents", "skills") },
12678
- { source: "codex", root: join15(registryDir, ".codex", "skills") },
12679
- { source: "claude", root: join15(registryDir, ".claude", "skills") }
12606
+ { source: "skills", root: join14(registryDir, "skills") },
12607
+ { source: "agents", root: join14(registryDir, ".agents", "skills") },
12608
+ { source: "codex", root: join14(registryDir, ".codex", "skills") },
12609
+ { source: "claude", root: join14(registryDir, ".claude", "skills") }
12680
12610
  ];
12681
12611
  const collections = [];
12682
12612
  for (const { source, root } of candidateRoots) {
@@ -12690,9 +12620,9 @@ async function findSkillCollections(registryDir) {
12690
12620
  async function findSkillDirsInRoot(root) {
12691
12621
  const skillDirs = [];
12692
12622
  for (const dirent of await safeReadDir(root)) {
12693
- const skillDir = join15(root, dirent.name);
12623
+ const skillDir = join14(root, dirent.name);
12694
12624
  if (!await isDirectoryDirent(dirent, skillDir)) continue;
12695
- if (await fileExists(join15(skillDir, "SKILL.md"))) {
12625
+ if (await fileExists(join14(skillDir, "SKILL.md"))) {
12696
12626
  skillDirs.push(skillDir);
12697
12627
  }
12698
12628
  }
@@ -12702,9 +12632,9 @@ async function findTopLevelSkills(registryDir) {
12702
12632
  const skills = [];
12703
12633
  for (const dirent of await safeReadDir(registryDir)) {
12704
12634
  if (dirent.name.startsWith(".") || dirent.name === "skills" || dirent.name === "plugins") continue;
12705
- const skillDir = join15(registryDir, dirent.name);
12635
+ const skillDir = join14(registryDir, dirent.name);
12706
12636
  if (!await isDirectoryDirent(dirent, skillDir)) continue;
12707
- if (await fileExists(join15(skillDir, "SKILL.md"))) {
12637
+ if (await fileExists(join14(skillDir, "SKILL.md"))) {
12708
12638
  skills.push({ source: "root", skillDir });
12709
12639
  }
12710
12640
  }
@@ -12715,10 +12645,10 @@ async function findClaudePluginRoots(registryDir) {
12715
12645
  async function walk(dir) {
12716
12646
  for (const dirent of await safeReadDir(dir)) {
12717
12647
  if (dirent.name === ".git") continue;
12718
- const child = join15(dir, dirent.name);
12648
+ const child = join14(dir, dirent.name);
12719
12649
  if (!await isDirectoryDirent(dirent, child)) continue;
12720
12650
  if (dirent.name === ".claude-plugin") {
12721
- if (await fileExists(join15(child, "plugin.json"))) {
12651
+ if (await fileExists(join14(child, "plugin.json"))) {
12722
12652
  roots.push(dirname3(child));
12723
12653
  }
12724
12654
  continue;
@@ -12730,7 +12660,7 @@ async function findClaudePluginRoots(registryDir) {
12730
12660
  return uniqueStrings(roots);
12731
12661
  }
12732
12662
  async function hasCodexMarketplace(registryDir) {
12733
- return await fileExists(join15(registryDir, ".agents", "plugins", "marketplace.json")) || await fileExists(join15(registryDir, ".codex", "plugins", "marketplace.json"));
12663
+ return await fileExists(join14(registryDir, ".agents", "plugins", "marketplace.json")) || await fileExists(join14(registryDir, ".codex", "plugins", "marketplace.json"));
12734
12664
  }
12735
12665
  async function installCodexRegistryPlugins(client, inventory) {
12736
12666
  const cwds = inventory.codexMarketplaceCwds;
@@ -12772,10 +12702,10 @@ async function readManifest(homeDir) {
12772
12702
  }
12773
12703
  }
12774
12704
  function getRegistryRoot(homeDir) {
12775
- return join15(homeDir, REGISTRY_ROOT_DIR);
12705
+ return join14(homeDir, REGISTRY_ROOT_DIR);
12776
12706
  }
12777
12707
  function getManifestPath(homeDir) {
12778
- return join15(getRegistryRoot(homeDir), REGISTRY_MANIFEST);
12708
+ return join14(getRegistryRoot(homeDir), REGISTRY_MANIFEST);
12779
12709
  }
12780
12710
  function emptyInventory(registryRoot) {
12781
12711
  return {
@@ -12835,8 +12765,8 @@ async function fileExists(path7) {
12835
12765
  }
12836
12766
  }
12837
12767
  function isPathInside(parentPath, childPath) {
12838
- const parent = resolve2(parentPath);
12839
- const child = resolve2(childPath);
12768
+ const parent = resolve(parentPath);
12769
+ const child = resolve(childPath);
12840
12770
  const childRelativePath = relative(parent, child);
12841
12771
  return childRelativePath === "" || !childRelativePath.startsWith("..") && !isAbsolute(childRelativePath);
12842
12772
  }
@@ -13104,8 +13034,8 @@ var PromptStream = class {
13104
13034
  if (this.closed) {
13105
13035
  return Promise.resolve({ value: void 0, done: true });
13106
13036
  }
13107
- return new Promise((resolve8) => {
13108
- this.waiters.push(resolve8);
13037
+ return new Promise((resolve7) => {
13038
+ this.waiters.push(resolve7);
13109
13039
  });
13110
13040
  }
13111
13041
  };
@@ -13353,7 +13283,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13353
13283
  this.chatId = options.chatId;
13354
13284
  this.onChatCredential = options.onChatCredential ?? (() => {
13355
13285
  });
13356
- this.historyFilePath = options.historyFilePath ?? join16(homedir11(), ".replicas", "claude", "history.jsonl");
13286
+ this.historyFilePath = options.historyFilePath ?? join15(homedir11(), ".replicas", "claude", "history.jsonl");
13357
13287
  this.historyFile = new CodexHistoryFile(this.historyFilePath);
13358
13288
  this.initializeManager(this.processMessageInternal.bind(this));
13359
13289
  }
@@ -13544,14 +13474,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13544
13474
  const requestId = randomUUID5();
13545
13475
  const toolUseId = options.toolUseID;
13546
13476
  const { options: requestOptions, questions: requestQuestions } = handler.getRequest(input);
13547
- const result = await new Promise((resolve8) => {
13477
+ const result = await new Promise((resolve7) => {
13548
13478
  this.pendingToolInputs.set(requestId, {
13549
13479
  requestId,
13550
13480
  toolUseId,
13551
13481
  toolName,
13552
13482
  input,
13553
13483
  handler,
13554
- resolve: resolve8
13484
+ resolve: resolve7
13555
13485
  });
13556
13486
  const onAbort = () => {
13557
13487
  const pending = this.pendingToolInputs.get(requestId);
@@ -13615,7 +13545,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13615
13545
  const agentId = /^agent-(.+)\.jsonl$/.exec(file)?.[1];
13616
13546
  if (!agentId) continue;
13617
13547
  const offset = workflow.offsets.get(file) ?? 0;
13618
- const buffer = await readFile10(join16(workflow.dir, file)).catch(() => Buffer.alloc(0));
13548
+ const buffer = await readFile10(join15(workflow.dir, file)).catch(() => Buffer.alloc(0));
13619
13549
  const end = buffer.lastIndexOf(10);
13620
13550
  if (end < offset) continue;
13621
13551
  workflow.offsets.set(file, end + 1);
@@ -13707,7 +13637,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13707
13637
  error
13708
13638
  );
13709
13639
  await this.tearDownSession();
13710
- await new Promise((resolve8) => setTimeout(resolve8, delayMs));
13640
+ await new Promise((resolve7) => setTimeout(resolve7, delayMs));
13711
13641
  currentRequest = { ...request, message: CLAUDE_MIDTURN_CONTINUE_PROMPT, images: [], goalMode: false };
13712
13642
  attempt++;
13713
13643
  continue;
@@ -13720,7 +13650,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13720
13650
  error
13721
13651
  );
13722
13652
  await this.tearDownSession();
13723
- await new Promise((resolve8) => setTimeout(resolve8, delayMs));
13653
+ await new Promise((resolve7) => setTimeout(resolve7, delayMs));
13724
13654
  attempt++;
13725
13655
  continue;
13726
13656
  }
@@ -13875,8 +13805,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13875
13805
  this.pendingInterrupt = false;
13876
13806
  return;
13877
13807
  }
13878
- await new Promise((resolve8, reject) => {
13879
- this.pendingTurn = { resolve: resolve8, reject, sawActivity: false, userMessageUuids: /* @__PURE__ */ new Set([userMessage.uuid]) };
13808
+ await new Promise((resolve7, reject) => {
13809
+ this.pendingTurn = { resolve: resolve7, reject, sawActivity: false, userMessageUuids: /* @__PURE__ */ new Set([userMessage.uuid]) };
13880
13810
  promptStream.push(goalCommand ? { ...userMessage, message: { role: "user", content: `/goal ${goalObjective ?? "clear"}` } } : userMessage);
13881
13811
  });
13882
13812
  }
@@ -14666,7 +14596,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14666
14596
 
14667
14597
  // src/managers/codex-asp/codex-asp-manager.ts
14668
14598
  import { mkdir as mkdir11, writeFile as writeFile6 } from "fs/promises";
14669
- import { join as join17 } from "path";
14599
+ import { join as join16 } from "path";
14670
14600
 
14671
14601
  // src/utils/codex-quota.ts
14672
14602
  function buildCodexRateLimitsSnapshot(fields) {
@@ -14730,7 +14660,7 @@ var CodexQuotaStatusTracker = class {
14730
14660
  };
14731
14661
 
14732
14662
  // src/managers/codex-asp/mappers.ts
14733
- import { existsSync as existsSync7, readFileSync as readFileSync3 } from "fs";
14663
+ import { existsSync as existsSync7, readFileSync as readFileSync2 } from "fs";
14734
14664
  var localImageCache = /* @__PURE__ */ new Map();
14735
14665
  var DEFAULT_MODEL = DEFAULT_CODEX_MODEL;
14736
14666
  var THREAD_START_METHOD = "thread/start";
@@ -14858,7 +14788,7 @@ function userImageForLocalPath(path7) {
14858
14788
  const image = {
14859
14789
  type: "image",
14860
14790
  mediaType: inferMediaType(path7),
14861
- data: readFileSync3(path7).toString("base64")
14791
+ data: readFileSync2(path7).toString("base64")
14862
14792
  };
14863
14793
  if (image.data.length > 0) localImageCache.set(path7, image);
14864
14794
  return image;
@@ -15715,9 +15645,9 @@ var CodexAspManager = class extends CodingAgentManager {
15715
15645
  async continueWithNewProvider(host, previous, request, developerInstructions, serviceTier) {
15716
15646
  const events = codexTranscriptToEvents(threadToAspTranscript(previous));
15717
15647
  const text = canonicalizeChatTranscriptBlocks(events.map((event) => JSON.stringify(event)).join("\n"), "codex", void 0).join("\n\n");
15718
- const directory = join17(ENGINE_ENV.HOME_DIR, ".replicas", "codex", "provider-context");
15648
+ const directory = join16(ENGINE_ENV.HOME_DIR, ".replicas", "codex", "provider-context");
15719
15649
  await mkdir11(directory, { recursive: true });
15720
- const transcriptPath = join17(directory, `${previous.id}.md`);
15650
+ const transcriptPath = join16(directory, `${previous.id}.md`);
15721
15651
  await writeFile6(transcriptPath, text, "utf8");
15722
15652
  const response = await host.client.request(
15723
15653
  THREAD_START_METHOD,
@@ -15813,8 +15743,8 @@ ${text.slice(-24e3)}`
15813
15743
  }
15814
15744
  async observeTurn(host, threadId, request, startTurn) {
15815
15745
  let resolveCompleted;
15816
- const completed = new Promise((resolve8) => {
15817
- resolveCompleted = resolve8;
15746
+ const completed = new Promise((resolve7) => {
15747
+ resolveCompleted = resolve7;
15818
15748
  });
15819
15749
  let rejectDisposed = () => {
15820
15750
  };
@@ -16344,22 +16274,22 @@ ${text.slice(-24e3)}`
16344
16274
 
16345
16275
  // src/managers/cursor-manager.ts
16346
16276
  import { mkdir as mkdir13, readFile as readFile12, readdir as readdir5 } from "fs/promises";
16347
- import { basename as basename2, dirname as dirname6, extname, join as join19 } from "path";
16277
+ import { basename as basename2, dirname as dirname6, extname, join as join18 } from "path";
16348
16278
  import { Agent as CursorAgent2 } from "@cursor/sdk";
16349
16279
 
16350
16280
  // src/services/native-command-protection-hooks.ts
16351
16281
  import { existsSync as existsSync8 } from "fs";
16352
16282
  import { mkdir as mkdir12, readFile as readFile11, writeFile as writeFile7 } from "fs/promises";
16353
- import { basename, dirname as dirname5, join as join18 } from "path";
16283
+ import { basename, dirname as dirname5, join as join17 } from "path";
16354
16284
  import { fileURLToPath } from "url";
16355
16285
  var moduleDirectory = dirname5(fileURLToPath(import.meta.url));
16356
16286
  var hookPath = [
16357
- join18(moduleDirectory, "command-protection-hook.js"),
16358
- join18(moduleDirectory, "..", "command-protection-hook.ts")
16287
+ join17(moduleDirectory, "command-protection-hook.js"),
16288
+ join17(moduleDirectory, "..", "command-protection-hook.ts")
16359
16289
  ].find(existsSync8);
16360
16290
  var postToolHookPath = [
16361
- join18(moduleDirectory, "post-tool-pr-hook.js"),
16362
- join18(moduleDirectory, "..", "post-tool-pr-hook.ts")
16291
+ join17(moduleDirectory, "post-tool-pr-hook.js"),
16292
+ join17(moduleDirectory, "..", "post-tool-pr-hook.ts")
16363
16293
  ].find(existsSync8);
16364
16294
  function shellCommand(path7, provider) {
16365
16295
  if (!path7) throw new Error("Replicas hook executable is missing.");
@@ -16380,7 +16310,7 @@ function getPostToolPrHookPath() {
16380
16310
  return postToolHookPath;
16381
16311
  }
16382
16312
  async function ensureCursorCommandProtectionHook() {
16383
- const path7 = join18(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
16313
+ const path7 = join17(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
16384
16314
  let config = {};
16385
16315
  try {
16386
16316
  const parsed = JSON.parse(await readFile11(path7, "utf8"));
@@ -16479,7 +16409,7 @@ async function listCursorCommandsInDirectory(directory) {
16479
16409
  const name = basename2(entry.name, ".md");
16480
16410
  let description;
16481
16411
  try {
16482
- description = extractCursorCommandDescription(await readFile12(join19(directory, entry.name), "utf8"));
16412
+ description = extractCursorCommandDescription(await readFile12(join18(directory, entry.name), "utf8"));
16483
16413
  } catch (error) {
16484
16414
  console.warn("[CursorManager] Failed to read slash command file:", error);
16485
16415
  }
@@ -16501,7 +16431,7 @@ var CursorManager = class extends CodingAgentManager {
16501
16431
  slashCommandsRequest = null;
16502
16432
  constructor(options) {
16503
16433
  super(options);
16504
- this.historyFilePath = options.historyFilePath ?? join19(ENGINE_ENV.HOME_DIR, ".replicas", "cursor", "history.jsonl");
16434
+ this.historyFilePath = options.historyFilePath ?? join18(ENGINE_ENV.HOME_DIR, ".replicas", "cursor", "history.jsonl");
16505
16435
  this.historyFile = new CodexHistoryFile(this.historyFilePath);
16506
16436
  this.initializeManager(this.processMessageInternal.bind(this));
16507
16437
  }
@@ -16576,7 +16506,7 @@ var CursorManager = class extends CodingAgentManager {
16576
16506
  this.slashCommandsRequest ??= (async () => {
16577
16507
  try {
16578
16508
  const repoDirectories = await getAgentAdditionalDirectories();
16579
- const commandDirectories = [this.workingDirectory, ...repoDirectories, ENGINE_ENV.HOME_DIR].map((directory) => join19(directory, ".cursor", "commands"));
16509
+ const commandDirectories = [this.workingDirectory, ...repoDirectories, ENGINE_ENV.HOME_DIR].map((directory) => join18(directory, ".cursor", "commands"));
16580
16510
  const commands = mergeSlashCommands(
16581
16511
  ...await Promise.all(commandDirectories.map(listCursorCommandsInDirectory))
16582
16512
  );
@@ -16615,8 +16545,8 @@ var CursorManager = class extends CodingAgentManager {
16615
16545
  let agent = null;
16616
16546
  let sawCursorActivity = false;
16617
16547
  let reconnectNoticeTimer = null;
16618
- const aborted = new Promise((resolve8) => {
16619
- this.abortActiveTurn = () => resolve8(TURN_ABORTED);
16548
+ const aborted = new Promise((resolve7) => {
16549
+ this.abortActiveTurn = () => resolve7(TURN_ABORTED);
16620
16550
  });
16621
16551
  const linearSessionId = this.linearSessionId;
16622
16552
  const linearForwarder = new LinearEventForwarder(linearSessionId);
@@ -17151,8 +17081,8 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
17151
17081
  userMessageRecorded = true;
17152
17082
  }
17153
17083
  if (/^\/compact$/i.test(request.message.trim())) {
17154
- const completed2 = new Promise((resolve8) => {
17155
- this.compactionComplete = { resolve: resolve8 };
17084
+ const completed2 = new Promise((resolve7) => {
17085
+ this.compactionComplete = { resolve: resolve7 };
17156
17086
  });
17157
17087
  const result2 = await this.request("session/compact", {
17158
17088
  commandId: uuidV7(),
@@ -17184,8 +17114,8 @@ ${pending}
17184
17114
 
17185
17115
  ` : ""}${request.planMode ? "Plan the requested work without modifying files or running mutating commands.\n\n" : ""}${request.message}`;
17186
17116
  this.turnError = null;
17187
- const completed = new Promise((resolve8) => {
17188
- this.turnComplete = { resolve: resolve8 };
17117
+ const completed = new Promise((resolve7) => {
17118
+ this.turnComplete = { resolve: resolve7 };
17189
17119
  });
17190
17120
  const result = await this.request("turn/start", {
17191
17121
  commandId: uuidV7(),
@@ -17369,7 +17299,7 @@ ${pending}
17369
17299
  // src/managers/opencode-manager.ts
17370
17300
  import { existsSync as existsSync9 } from "fs";
17371
17301
  import { copyFile, mkdir as mkdir15, readFile as readFile13, rm as rm2 } from "fs/promises";
17372
- import { delimiter, dirname as dirname8, join as join20 } from "path";
17302
+ import { delimiter, dirname as dirname8, join as join19 } from "path";
17373
17303
  import { randomBytes as randomBytes3 } from "crypto";
17374
17304
  import { fileURLToPath as fileURLToPath2 } from "url";
17375
17305
  import { Agent } from "undici";
@@ -17398,10 +17328,10 @@ async function getAllowedOpenRouterModels() {
17398
17328
 
17399
17329
  // src/managers/opencode-manager.ts
17400
17330
  var OPENCODE_SHIM_DIR = dirname8(fileURLToPath2(new URL("../../scripts/opencode", import.meta.url)));
17401
- var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE = join20(OPENCODE_SHIM_DIR, "opencode-command-protection-plugin.ts");
17402
- var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH = join20(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.ts");
17403
- var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH = join20(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.mjs");
17404
- var OPENCODE_CONFIG_PATH = join20(ENGINE_ENV.HOME_DIR, ".config", "opencode", "opencode.json");
17331
+ var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE = join19(OPENCODE_SHIM_DIR, "opencode-command-protection-plugin.ts");
17332
+ var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH = join19(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.ts");
17333
+ var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH = join19(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.mjs");
17334
+ var OPENCODE_CONFIG_PATH = join19(ENGINE_ENV.HOME_DIR, ".config", "opencode", "opencode.json");
17405
17335
  var OPENCODE_FETCH_DISPATCHER = new Agent({ headersTimeout: 0, bodyTimeout: 0 });
17406
17336
  var OPENCODE_SERVER_STARTUP_TIMEOUT_MS = 3e4;
17407
17337
  var OPENCODE_WORKSPACE_PERMISSION = "allow";
@@ -17622,7 +17552,7 @@ var OpencodeManager = class extends CodingAgentManager {
17622
17552
  constructor(options) {
17623
17553
  super({ ...options, provider: "opencode" });
17624
17554
  this.sessionId = options.initialSessionId;
17625
- this.historyFilePath = options.historyFilePath ?? join20(ENGINE_ENV.HOME_DIR, ".replicas", "opencode", "history.jsonl");
17555
+ this.historyFilePath = options.historyFilePath ?? join19(ENGINE_ENV.HOME_DIR, ".replicas", "opencode", "history.jsonl");
17626
17556
  this.historyFile = new CodexHistoryFile(this.historyFilePath);
17627
17557
  this.initializeManager(this.processMessageInternal.bind(this));
17628
17558
  }
@@ -17699,8 +17629,8 @@ var OpencodeManager = class extends CodingAgentManager {
17699
17629
  const previousUpdate = this.clientUpdate;
17700
17630
  let finishUpdate = () => {
17701
17631
  };
17702
- this.clientUpdate = new Promise((resolve8) => {
17703
- finishUpdate = resolve8;
17632
+ this.clientUpdate = new Promise((resolve7) => {
17633
+ finishUpdate = resolve7;
17704
17634
  });
17705
17635
  await previousUpdate;
17706
17636
  try {
@@ -17774,8 +17704,8 @@ var OpencodeManager = class extends CodingAgentManager {
17774
17704
  this.configuredModels = new Set(providerModels);
17775
17705
  const eventController = new AbortController();
17776
17706
  this.eventAbortController = eventController;
17777
- this.eventSubscriptionReady = new Promise((resolve8) => {
17778
- this.resolveEventSubscriptionReady = resolve8;
17707
+ this.eventSubscriptionReady = new Promise((resolve7) => {
17708
+ this.resolveEventSubscriptionReady = resolve7;
17779
17709
  });
17780
17710
  this.subscribeToEvents(client, eventController).catch((error) => {
17781
17711
  this.resolveEventSubscriptionReady?.();
@@ -17785,7 +17715,7 @@ var OpencodeManager = class extends CodingAgentManager {
17785
17715
  });
17786
17716
  await Promise.race([
17787
17717
  this.eventSubscriptionReady,
17788
- new Promise((resolve8) => setTimeout(resolve8, 2e3))
17718
+ new Promise((resolve7) => setTimeout(resolve7, 2e3))
17789
17719
  ]);
17790
17720
  return client;
17791
17721
  } finally {
@@ -18044,7 +17974,7 @@ var OpencodeManager = class extends CodingAgentManager {
18044
17974
 
18045
17975
  // src/managers/pi-manager.ts
18046
17976
  import { mkdir as mkdir17, readFile as readFile14 } from "fs/promises";
18047
- import { dirname as dirname16, join as join28 } from "path";
17977
+ import { dirname as dirname16, join as join27 } from "path";
18048
17978
  import {
18049
17979
  createAgentSession,
18050
17980
  ModelRegistry,
@@ -18055,17 +17985,17 @@ import {
18055
17985
 
18056
17986
  // src/services/chat/history-paths.ts
18057
17987
  import { homedir as homedir12 } from "os";
18058
- import { join as join21 } from "path";
18059
- var ENGINE_DIR2 = join21(homedir12(), ".replicas", "engine");
18060
- var CHATS_FILE = join21(ENGINE_DIR2, "chats.json");
18061
- var CLAUDE_HISTORY_DIR = join21(ENGINE_DIR2, "claude-histories");
18062
- var RELAY_HISTORY_DIR = join21(ENGINE_DIR2, "relay-histories");
18063
- var CODEX_HISTORY_DIR = join21(ENGINE_DIR2, "codex-histories");
18064
- var CURSOR_HISTORY_DIR = join21(ENGINE_DIR2, "cursor-histories");
18065
- var OPENCODE_HISTORY_DIR = join21(ENGINE_DIR2, "opencode-histories");
18066
- var PI_HISTORY_DIR = join21(ENGINE_DIR2, "pi-histories");
18067
- var MUSE_HISTORY_DIR = join21(ENGINE_DIR2, "muse-histories");
18068
- var FORKS_DIR = join21(ENGINE_DIR2, "forks");
17988
+ import { join as join20 } from "path";
17989
+ var ENGINE_DIR2 = join20(homedir12(), ".replicas", "engine");
17990
+ var CHATS_FILE = join20(ENGINE_DIR2, "chats.json");
17991
+ var CLAUDE_HISTORY_DIR = join20(ENGINE_DIR2, "claude-histories");
17992
+ var RELAY_HISTORY_DIR = join20(ENGINE_DIR2, "relay-histories");
17993
+ var CODEX_HISTORY_DIR = join20(ENGINE_DIR2, "codex-histories");
17994
+ var CURSOR_HISTORY_DIR = join20(ENGINE_DIR2, "cursor-histories");
17995
+ var OPENCODE_HISTORY_DIR = join20(ENGINE_DIR2, "opencode-histories");
17996
+ var PI_HISTORY_DIR = join20(ENGINE_DIR2, "pi-histories");
17997
+ var MUSE_HISTORY_DIR = join20(ENGINE_DIR2, "muse-histories");
17998
+ var FORKS_DIR = join20(ENGINE_DIR2, "forks");
18069
17999
  var HISTORY_DIR_BY_PROVIDER = {
18070
18000
  claude: CLAUDE_HISTORY_DIR,
18071
18001
  relay: RELAY_HISTORY_DIR,
@@ -27391,14 +27321,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
27391
27321
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
27392
27322
  }
27393
27323
  function sleep(ms, signal) {
27394
- return new Promise((resolve8, reject) => {
27324
+ return new Promise((resolve7, reject) => {
27395
27325
  if (signal?.aborted) {
27396
27326
  reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
27397
27327
  return;
27398
27328
  }
27399
27329
  const timer = setTimeout(() => {
27400
27330
  signal?.removeEventListener("abort", onAbort);
27401
- resolve8();
27331
+ resolve7();
27402
27332
  }, ms);
27403
27333
  const onAbort = () => {
27404
27334
  clearTimeout(timer);
@@ -28237,7 +28167,7 @@ var Protocol = class {
28237
28167
  const flowStartedAt = Date.now();
28238
28168
  let onAbort;
28239
28169
  let cleanupMessageId;
28240
- return new Promise((resolve8, reject) => {
28170
+ return new Promise((resolve7, reject) => {
28241
28171
  const earlyReject = (error) => {
28242
28172
  reject(error);
28243
28173
  };
@@ -28305,7 +28235,7 @@ var Protocol = class {
28305
28235
  }
28306
28236
  if (decoded.kind === "invalid") return reject(decoded.error);
28307
28237
  if (decoded.kind === "input_required") {
28308
- if (options?.allowInputRequired === true) return resolve8(manualInputRequiredValue(decoded));
28238
+ if (options?.allowInputRequired === true) return resolve7(manualInputRequiredValue(decoded));
28309
28239
  const flow = {
28310
28240
  codec,
28311
28241
  request,
@@ -28317,11 +28247,11 @@ var Protocol = class {
28317
28247
  params
28318
28248
  }, resultSchema, legOptions)
28319
28249
  };
28320
- return resolve8(this._resolveNonCompleteResult(decoded, flow));
28250
+ return resolve7(this._resolveNonCompleteResult(decoded, flow));
28321
28251
  }
28322
28252
  const result = decoded.result;
28323
28253
  validateStandardSchema(resultSchema, result).then((parseResult) => {
28324
- if (parseResult.success) resolve8(parseResult.data);
28254
+ if (parseResult.success) resolve7(parseResult.data);
28325
28255
  else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
28326
28256
  }, reject);
28327
28257
  });
@@ -31273,7 +31203,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
31273
31203
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
31274
31204
  const schOrFunc = root.refs[ref];
31275
31205
  if (schOrFunc) return schOrFunc;
31276
- let _sch = resolve8.call(this, root, ref);
31206
+ let _sch = resolve7.call(this, root, ref);
31277
31207
  if (_sch === void 0) {
31278
31208
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
31279
31209
  const { schemaId } = this.opts;
@@ -31299,7 +31229,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
31299
31229
  function sameSchemaEnv(s1, s2) {
31300
31230
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
31301
31231
  }
31302
- function resolve8(root, ref) {
31232
+ function resolve7(root, ref) {
31303
31233
  let sch;
31304
31234
  while (typeof (sch = this.refs[ref]) == "string") ref = sch;
31305
31235
  return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
@@ -31749,7 +31679,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
31749
31679
  else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
31750
31680
  return uri;
31751
31681
  }
31752
- function resolve8(baseURI, relativeURI, options) {
31682
+ function resolve7(baseURI, relativeURI, options) {
31753
31683
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
31754
31684
  const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
31755
31685
  schemelessOptions.skipEscape = true;
@@ -31923,7 +31853,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
31923
31853
  const fastUri = {
31924
31854
  SCHEMES,
31925
31855
  normalize,
31926
- resolve: resolve8,
31856
+ resolve: resolve7,
31927
31857
  resolveComponent,
31928
31858
  equal,
31929
31859
  serialize,
@@ -37736,14 +37666,14 @@ var ProbeWindow = class ProbeWindow2 {
37736
37666
  */
37737
37667
  async exchange(buildRequest, timeoutMs) {
37738
37668
  const id = `server-discover-probe-${++this._probeCounter}`;
37739
- return new Promise((resolve8) => {
37669
+ return new Promise((resolve7) => {
37740
37670
  let settled = false;
37741
37671
  const settle = (reply) => {
37742
37672
  if (settled) return;
37743
37673
  settled = true;
37744
37674
  clearTimeout(timer);
37745
37675
  if (this._pending?.id === id) this._pending = void 0;
37746
- resolve8(reply);
37676
+ resolve7(reply);
37747
37677
  };
37748
37678
  const timer = setTimeout(() => settle({ kind: "timeout" }), timeoutMs);
37749
37679
  this._pending = {
@@ -38949,13 +38879,13 @@ var Client = class extends Protocol {
38949
38879
  let onCallerAbort;
38950
38880
  let resolveOpening;
38951
38881
  let rejectOpening;
38952
- const opening = new Promise((resolve8, reject) => {
38953
- resolveOpening = resolve8;
38882
+ const opening = new Promise((resolve7, reject) => {
38883
+ resolveOpening = resolve7;
38954
38884
  rejectOpening = reject;
38955
38885
  });
38956
38886
  let resolveClosed;
38957
- const closed = new Promise((resolve8) => {
38958
- resolveClosed = resolve8;
38887
+ const closed = new Promise((resolve7) => {
38888
+ resolveClosed = resolve7;
38959
38889
  });
38960
38890
  const settle = (outcome) => {
38961
38891
  if (state === "closed") return;
@@ -39435,7 +39365,7 @@ var SSEClientTransport = class {
39435
39365
  }
39436
39366
  _startOrAuth() {
39437
39367
  const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
39438
- return new Promise((resolve8, reject) => {
39368
+ return new Promise((resolve7, reject) => {
39439
39369
  this._eventSource = new EventSource(this._url.href, {
39440
39370
  ...this._eventSourceInit,
39441
39371
  fetch: async (url3, init) => {
@@ -39467,7 +39397,7 @@ var SSEClientTransport = class {
39467
39397
  response,
39468
39398
  serverUrl: this._url,
39469
39399
  fetchFn: this._fetchWithInit
39470
- }).then(() => this._startOrAuth().then(resolve8, reject), (error$2) => {
39400
+ }).then(() => this._startOrAuth().then(resolve7, reject), (error$2) => {
39471
39401
  markAuthSeamEscape(error$2);
39472
39402
  this.onerror?.(error$2);
39473
39403
  reject(error$2);
@@ -39496,7 +39426,7 @@ var SSEClientTransport = class {
39496
39426
  this.close();
39497
39427
  return;
39498
39428
  }
39499
- resolve8();
39429
+ resolve7();
39500
39430
  });
39501
39431
  this._eventSource.onmessage = (event) => {
39502
39432
  const messageEvent = event;
@@ -40172,7 +40102,7 @@ var StreamableHTTPClientTransport = class {
40172
40102
  };
40173
40103
 
40174
40104
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/server-manager.ts
40175
- import { mkdirSync as mkdirSync2, statSync as statSync3 } from "fs";
40105
+ import { mkdirSync as mkdirSync2, statSync as statSync2 } from "fs";
40176
40106
  import { isDeepStrictEqual } from "util";
40177
40107
 
40178
40108
  // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/stdio.mjs
@@ -40228,7 +40158,7 @@ var StdioClientTransport = class {
40228
40158
  */
40229
40159
  async start() {
40230
40160
  if (this._process) throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
40231
- return new Promise((resolve8, reject) => {
40161
+ return new Promise((resolve7, reject) => {
40232
40162
  this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
40233
40163
  env: {
40234
40164
  ...getDefaultEnvironment(),
@@ -40248,7 +40178,7 @@ var StdioClientTransport = class {
40248
40178
  this.onerror?.(error);
40249
40179
  });
40250
40180
  this._process.on("spawn", () => {
40251
- resolve8();
40181
+ resolve7();
40252
40182
  });
40253
40183
  this._process.on("close", (_code) => {
40254
40184
  this._process = void 0;
@@ -40313,7 +40243,7 @@ var StdioClientTransport = class {
40313
40243
  const proc = this._process;
40314
40244
  this._process = void 0;
40315
40245
  if (proc && proc.exitCode === null && proc.signalCode === null) {
40316
- const exited = new Promise((resolve8) => proc.once("exit", () => resolve8()));
40246
+ const exited = new Promise((resolve7) => proc.once("exit", () => resolve7()));
40317
40247
  try {
40318
40248
  proc.stdin?.end();
40319
40249
  } catch {
@@ -40322,7 +40252,7 @@ var StdioClientTransport = class {
40322
40252
  proc.kill("SIGTERM");
40323
40253
  } catch {
40324
40254
  }
40325
- await Promise.race([exited, new Promise((resolve8) => setTimeout(resolve8, 1e3).unref())]);
40255
+ await Promise.race([exited, new Promise((resolve7) => setTimeout(resolve7, 1e3).unref())]);
40326
40256
  if (proc.exitCode === null && proc.signalCode === null) try {
40327
40257
  proc.kill("SIGKILL");
40328
40258
  } catch {
@@ -40347,22 +40277,22 @@ var StdioClientTransport = class {
40347
40277
  if (this._process) {
40348
40278
  const processToClose = this._process;
40349
40279
  this._process = void 0;
40350
- const closePromise = new Promise((resolve8) => {
40280
+ const closePromise = new Promise((resolve7) => {
40351
40281
  processToClose.once("close", () => {
40352
- resolve8();
40282
+ resolve7();
40353
40283
  });
40354
40284
  });
40355
40285
  try {
40356
40286
  processToClose.stdin?.end();
40357
40287
  } catch {
40358
40288
  }
40359
- await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
40289
+ await Promise.race([closePromise, new Promise((resolve7) => setTimeout(resolve7, 2e3).unref())]);
40360
40290
  if (processToClose.exitCode === null) {
40361
40291
  try {
40362
40292
  processToClose.kill("SIGTERM");
40363
40293
  } catch {
40364
40294
  }
40365
- await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
40295
+ await Promise.race([closePromise, new Promise((resolve7) => setTimeout(resolve7, 2e3).unref())]);
40366
40296
  }
40367
40297
  if (processToClose.exitCode === null) try {
40368
40298
  processToClose.kill("SIGKILL");
@@ -40372,11 +40302,11 @@ var StdioClientTransport = class {
40372
40302
  this._readBuffer.clear();
40373
40303
  }
40374
40304
  send(message) {
40375
- return new Promise((resolve8) => {
40305
+ return new Promise((resolve7) => {
40376
40306
  if (!this._process?.stdin) throw new SdkError(SdkErrorCode.NotConnected, "Not connected");
40377
40307
  const json = serializeMessage(message);
40378
- if (this._process.stdin.write(json)) resolve8();
40379
- else this._process.stdin.once("drain", resolve8);
40308
+ if (this._process.stdin.write(json)) resolve7();
40309
+ else this._process.stdin.once("drain", resolve7);
40380
40310
  });
40381
40311
  }
40382
40312
  };
@@ -40397,13 +40327,13 @@ var UnixSocketClientTransport = class {
40397
40327
  if (this.socket) {
40398
40328
  throw new Error("UnixSocketClientTransport already started");
40399
40329
  }
40400
- await new Promise((resolve8, reject) => {
40330
+ await new Promise((resolve7, reject) => {
40401
40331
  const socket = createConnection(this.socketPath);
40402
40332
  this.socket = socket;
40403
40333
  let connected = false;
40404
40334
  socket.once("connect", () => {
40405
40335
  connected = true;
40406
- resolve8();
40336
+ resolve7();
40407
40337
  });
40408
40338
  socket.on("data", (chunk) => {
40409
40339
  try {
@@ -40435,12 +40365,12 @@ var UnixSocketClientTransport = class {
40435
40365
  this.socket = void 0;
40436
40366
  this.readBuffer.clear();
40437
40367
  if (!socket || socket.destroyed) return;
40438
- await new Promise((resolve8) => {
40368
+ await new Promise((resolve7) => {
40439
40369
  const timeout = setTimeout(() => socket.destroy(), 2e3);
40440
40370
  timeout.unref();
40441
40371
  socket.once("close", () => {
40442
40372
  clearTimeout(timeout);
40443
- resolve8();
40373
+ resolve7();
40444
40374
  });
40445
40375
  socket.end();
40446
40376
  });
@@ -40448,10 +40378,10 @@ var UnixSocketClientTransport = class {
40448
40378
  async send(message) {
40449
40379
  const socket = this.socket;
40450
40380
  if (!socket || socket.destroyed) throw new Error("Unix socket is not connected");
40451
- await new Promise((resolve8, reject) => {
40381
+ await new Promise((resolve7, reject) => {
40452
40382
  socket.write(serializeMessage(message), (error) => {
40453
40383
  if (error) reject(error);
40454
- else resolve8();
40384
+ else resolve7();
40455
40385
  });
40456
40386
  });
40457
40387
  }
@@ -40605,8 +40535,8 @@ async function probeMcpEndpoint(url3) {
40605
40535
  }
40606
40536
 
40607
40537
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
40608
- import { existsSync as existsSync10, readFileSync as readFileSync4, realpathSync, readdirSync as readdirSync2, statSync as statSync2, writeFileSync as writeFileSync2, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
40609
- import { join as join22, dirname as dirname9, extname as extname2, resolve as resolve3, sep } from "path";
40538
+ import { existsSync as existsSync10, readFileSync as readFileSync3, realpathSync, readdirSync, statSync, writeFileSync as writeFileSync2, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
40539
+ import { join as join21, dirname as dirname9, extname as extname2, resolve as resolve2, sep } from "path";
40610
40540
 
40611
40541
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
40612
40542
  function throwIfAborted(signal) {
@@ -40616,7 +40546,7 @@ function throwIfAborted(signal) {
40616
40546
  async function abortable(promise, signal) {
40617
40547
  if (!signal) return promise;
40618
40548
  throwIfAborted(signal);
40619
- return await new Promise((resolve8, reject) => {
40549
+ return await new Promise((resolve7, reject) => {
40620
40550
  let settled = false;
40621
40551
  const cleanup = () => signal.removeEventListener("abort", onAbort);
40622
40552
  const onAbort = () => {
@@ -40631,7 +40561,7 @@ async function abortable(promise, signal) {
40631
40561
  if (settled) return;
40632
40562
  settled = true;
40633
40563
  cleanup();
40634
- resolve8(value);
40564
+ resolve7(value);
40635
40565
  },
40636
40566
  (error) => {
40637
40567
  if (settled) return;
@@ -40763,11 +40693,11 @@ function resolveFromNpmCache(packageSpec, binName) {
40763
40693
  const { packageName, exactVersion } = parsedSpec;
40764
40694
  const packageDir = findCachedPackageDir(cacheDir, packageName, exactVersion);
40765
40695
  if (!packageDir) return null;
40766
- const packageJsonPath = join22(packageDir, "package.json");
40696
+ const packageJsonPath = join21(packageDir, "package.json");
40767
40697
  if (!existsSync10(packageJsonPath)) return null;
40768
40698
  let pkg = null;
40769
40699
  try {
40770
- pkg = JSON.parse(readFileSync4(packageJsonPath, "utf-8"));
40700
+ pkg = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
40771
40701
  } catch {
40772
40702
  return null;
40773
40703
  }
@@ -40797,10 +40727,10 @@ function resolveFromNpmCache(packageSpec, binName) {
40797
40727
  }
40798
40728
  if (!binRel) return null;
40799
40729
  const nodeModulesDir = findNodeModulesDir(packageDir);
40800
- const binLink = chosenBinName ? join22(nodeModulesDir, ".bin", chosenBinName) : null;
40730
+ const binLink = chosenBinName ? join21(nodeModulesDir, ".bin", chosenBinName) : null;
40801
40731
  let resolvedBin = binLink && existsSync10(binLink) ? safeRealpath(binLink) : "";
40802
40732
  if (!resolvedBin) {
40803
- resolvedBin = resolve3(packageDir, binRel);
40733
+ resolvedBin = resolve2(packageDir, binRel);
40804
40734
  if (!existsSync10(resolvedBin)) return null;
40805
40735
  }
40806
40736
  const isJs = detectJsBinary(resolvedBin);
@@ -40815,7 +40745,7 @@ var FORCE_CACHE_TIMEOUT_MS = 3e4;
40815
40745
  async function forceNpxCache(packageSpec, signal) {
40816
40746
  throwIfAborted(signal);
40817
40747
  try {
40818
- await new Promise((resolve8, reject) => {
40748
+ await new Promise((resolve7, reject) => {
40819
40749
  const proc = (0, import_cross_spawn2.default)(
40820
40750
  "npm",
40821
40751
  ["exec", "--yes", "--package", packageSpec, "--", "node", "-e", "1"],
@@ -40834,7 +40764,7 @@ async function forceNpxCache(packageSpec, signal) {
40834
40764
  proc.on("close", () => {
40835
40765
  clearTimeout(timer);
40836
40766
  signal?.removeEventListener("abort", abort);
40837
- resolve8();
40767
+ resolve7();
40838
40768
  });
40839
40769
  proc.on("error", (err) => {
40840
40770
  clearTimeout(timer);
@@ -40899,21 +40829,21 @@ function defaultBinName(packageName) {
40899
40829
  return packageName;
40900
40830
  }
40901
40831
  function findCachedPackageDir(cacheDir, packageName, exactVersion) {
40902
- const npxDir = join22(cacheDir, "_npx");
40832
+ const npxDir = join21(cacheDir, "_npx");
40903
40833
  if (!existsSync10(npxDir)) return null;
40904
40834
  const packagePathParts = packageName.startsWith("@") ? packageName.split("/") : [packageName];
40905
- const candidates = readdirSync2(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
40906
- const full = join22(npxDir, entry.name);
40835
+ const candidates = readdirSync(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
40836
+ const full = join21(npxDir, entry.name);
40907
40837
  const mtime = safeStatMtime(full);
40908
40838
  return { name: entry.name, mtime };
40909
40839
  }).sort((a, b) => b.mtime - a.mtime);
40910
40840
  for (const entry of candidates) {
40911
- const pkgDir = join22(npxDir, entry.name, "node_modules", ...packagePathParts);
40912
- const packageJsonPath = join22(pkgDir, "package.json");
40841
+ const pkgDir = join21(npxDir, entry.name, "node_modules", ...packagePathParts);
40842
+ const packageJsonPath = join21(pkgDir, "package.json");
40913
40843
  if (!existsSync10(packageJsonPath)) continue;
40914
40844
  if (exactVersion) {
40915
40845
  try {
40916
- const pkg = JSON.parse(readFileSync4(packageJsonPath, "utf-8"));
40846
+ const pkg = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
40917
40847
  if (pkg.version !== exactVersion) continue;
40918
40848
  } catch {
40919
40849
  continue;
@@ -40929,7 +40859,7 @@ function findNodeModulesDir(packageDir) {
40929
40859
  if (idx >= 0) {
40930
40860
  return parts.slice(0, idx + 1).join(sep);
40931
40861
  }
40932
- return join22(packageDir, "..");
40862
+ return join21(packageDir, "..");
40933
40863
  }
40934
40864
  function detectJsBinary(binPath) {
40935
40865
  const ext = extname2(binPath).toLowerCase();
@@ -40975,7 +40905,7 @@ function getNpxCachePath() {
40975
40905
  function readNpxCachePayload(cachePath) {
40976
40906
  if (!existsSync10(cachePath)) return null;
40977
40907
  try {
40978
- return JSON.parse(readFileSync4(cachePath, "utf-8"));
40908
+ return JSON.parse(readFileSync3(cachePath, "utf-8"));
40979
40909
  } catch {
40980
40910
  return null;
40981
40911
  }
@@ -41056,7 +40986,7 @@ function safeRealpath(path7) {
41056
40986
  }
41057
40987
  function safeStatMtime(path7) {
41058
40988
  try {
41059
- return statSync2(path7).mtimeMs;
40989
+ return statSync(path7).mtimeMs;
41060
40990
  } catch {
41061
40991
  return 0;
41062
40992
  }
@@ -41120,8 +41050,8 @@ function createJsonSchemaValidator() {
41120
41050
  import { spawnSync } from "child_process";
41121
41051
  import { createHash as createHash2 } from "crypto";
41122
41052
  import { createRequire } from "module";
41123
- import { readFileSync as readFileSync5, existsSync as existsSync11, rmSync as rmSync2 } from "fs";
41124
- import { dirname as dirname10, join as join23 } from "path";
41053
+ import { readFileSync as readFileSync4, existsSync as existsSync11, rmSync as rmSync2 } from "fs";
41054
+ import { dirname as dirname10, join as join22 } from "path";
41125
41055
  import { fileURLToPath as fileURLToPath3 } from "url";
41126
41056
  var require2 = createRequire(import.meta.url);
41127
41057
  var AUTH_SECRET_SERVICE = "pi-mcp-adapter.oauth";
@@ -41277,7 +41207,7 @@ function loadKeyringNativeBindingFallback(keyringRequire, platform3, arch2) {
41277
41207
  for (const target of targets) {
41278
41208
  try {
41279
41209
  const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
41280
- return keyringRequire(join23(dirname10(packageJsonPath), target.bindingFile));
41210
+ return keyringRequire(join22(dirname10(packageJsonPath), target.bindingFile));
41281
41211
  } catch (error) {
41282
41212
  lastError = error;
41283
41213
  }
@@ -41382,7 +41312,7 @@ function getServerDir(serverName, options) {
41382
41312
  throw new Error(`Invalid MCP server name: ${JSON.stringify(serverName)}`);
41383
41313
  }
41384
41314
  const storageKey = getAuthEntryAccount(serverName);
41385
- return join23(getAuthBaseDir(options), storageKey);
41315
+ return join22(getAuthBaseDir(options), storageKey);
41386
41316
  }
41387
41317
  function getAuthEntryAccount(serverName) {
41388
41318
  if (typeof serverName !== "string") {
@@ -41391,7 +41321,7 @@ function getAuthEntryAccount(serverName) {
41391
41321
  return `sha256-${createHash2("sha256").update(serverName, "utf8").digest("hex")}`;
41392
41322
  }
41393
41323
  function getAuthEntryFilePath(serverName, options) {
41394
- return join23(getServerDir(serverName, options), "tokens.json");
41324
+ return join22(getServerDir(serverName, options), "tokens.json");
41395
41325
  }
41396
41326
  function parseJsonPayload(serverName, payload, source) {
41397
41327
  try {
@@ -41541,7 +41471,7 @@ function readChunkedAuthEntry(store, serverName, account, manifest) {
41541
41471
  function readLegacyAuthEntry(serverName, options) {
41542
41472
  const filePath = getAuthEntryFilePath(serverName, options);
41543
41473
  if (!existsSync11(filePath)) return void 0;
41544
- const data = readFileSync5(filePath, "utf-8");
41474
+ const data = readFileSync4(filePath, "utf-8");
41545
41475
  return parseAuthEntryPayload(serverName, data, filePath);
41546
41476
  }
41547
41477
  function removeLegacyAuthEntry(serverName, options) {
@@ -42747,14 +42677,14 @@ var baseOpen = async (options) => {
42747
42677
  }
42748
42678
  const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
42749
42679
  if (options.wait) {
42750
- return new Promise((resolve8, reject) => {
42680
+ return new Promise((resolve7, reject) => {
42751
42681
  subprocess.once("error", reject);
42752
42682
  subprocess.once("close", (exitCode) => {
42753
42683
  if (!options.allowNonzeroExitCode && exitCode > 0) {
42754
42684
  reject(new Error(`Exited with code ${exitCode}`));
42755
42685
  return;
42756
42686
  }
42757
- resolve8(subprocess);
42687
+ resolve7(subprocess);
42758
42688
  });
42759
42689
  });
42760
42690
  }
@@ -43082,12 +43012,12 @@ async function ensureCallbackServerLocked(options = {}) {
43082
43012
  const candidateServer = createServer(handleRequest);
43083
43013
  const listenPort = strictPort ? requiredPort : 0;
43084
43014
  try {
43085
- await new Promise((resolve8, reject) => {
43015
+ await new Promise((resolve7, reject) => {
43086
43016
  candidateServer.once("error", (err) => {
43087
43017
  reject(err);
43088
43018
  });
43089
43019
  candidateServer.listen(listenPort, requestedHost, () => {
43090
- resolve8();
43020
+ resolve7();
43091
43021
  });
43092
43022
  });
43093
43023
  if (strictPort) {
@@ -43100,8 +43030,8 @@ async function ensureCallbackServerLocked(options = {}) {
43100
43030
  setOAuthCallbackPort(address.port);
43101
43031
  }
43102
43032
  if (previousServer && (needsStrictRebind || needsHostSwitch)) {
43103
- await new Promise((resolve8) => {
43104
- previousServer.close(() => resolve8());
43033
+ await new Promise((resolve7) => {
43034
+ previousServer.close(() => resolve7());
43105
43035
  });
43106
43036
  }
43107
43037
  callbackServerHost = requestedHost;
@@ -43117,8 +43047,8 @@ async function ensureCallbackServerLocked(options = {}) {
43117
43047
  reservedAuthStates.delete(reservedState);
43118
43048
  }
43119
43049
  const nodeError = error;
43120
- await new Promise((resolve8) => {
43121
- candidateServer.close(() => resolve8());
43050
+ await new Promise((resolve7) => {
43051
+ candidateServer.close(() => resolve7());
43122
43052
  });
43123
43053
  if (strictPort && nodeError.code === "EADDRINUSE") {
43124
43054
  throw new Error(
@@ -43134,14 +43064,14 @@ function releaseCallbackServer(oauthState) {
43134
43064
  }
43135
43065
  function waitForCallback(oauthState) {
43136
43066
  reservedAuthStates.delete(oauthState);
43137
- return new Promise((resolve8, reject) => {
43067
+ return new Promise((resolve7, reject) => {
43138
43068
  const timeout = setTimeout(() => {
43139
43069
  if (pendingAuths.has(oauthState)) {
43140
43070
  pendingAuths.delete(oauthState);
43141
43071
  reject(new Error("OAuth callback timeout - authorization took too long"));
43142
43072
  }
43143
43073
  }, CALLBACK_TIMEOUT_MS);
43144
- pendingAuths.set(oauthState, { resolve: resolve8, reject, timeout });
43074
+ pendingAuths.set(oauthState, { resolve: resolve7, reject, timeout });
43145
43075
  });
43146
43076
  }
43147
43077
  function cancelPendingCallback(oauthState) {
@@ -43166,9 +43096,9 @@ function stopCallbackServer() {
43166
43096
  });
43167
43097
  }
43168
43098
  if (server) {
43169
- await new Promise((resolve8) => {
43099
+ await new Promise((resolve7) => {
43170
43100
  server.close(() => {
43171
- resolve8();
43101
+ resolve7();
43172
43102
  });
43173
43103
  });
43174
43104
  server = void 0;
@@ -43994,7 +43924,7 @@ async function shutdownOAuth(runtime = legacyRuntime) {
43994
43924
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-bearer-store.ts
43995
43925
  import { createHash as createHash3 } from "crypto";
43996
43926
  import { createRequire as createRequire2 } from "module";
43997
- import { dirname as dirname11, join as join24 } from "path";
43927
+ import { dirname as dirname11, join as join23 } from "path";
43998
43928
  var require3 = createRequire2(import.meta.url);
43999
43929
  var BEARER_SECRET_SERVICE = "pi-mcp-adapter.bearer";
44000
43930
  var TEST_AUTH_STORE_ENV2 = "PI_MCP_ADAPTER_TEST_AUTH_STORE";
@@ -44096,7 +44026,7 @@ function loadKeyringNativeBindingFallback2(keyringRequire, platform3, arch2) {
44096
44026
  for (const target of targets) {
44097
44027
  try {
44098
44028
  const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
44099
- return keyringRequire(join24(dirname11(packageJsonPath), target.bindingFile));
44029
+ return keyringRequire(join23(dirname11(packageJsonPath), target.bindingFile));
44100
44030
  } catch (error) {
44101
44031
  lastError = error;
44102
44032
  }
@@ -44710,7 +44640,7 @@ function humanizeName(name) {
44710
44640
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-trace.ts
44711
44641
  import { appendFile as appendFile3, mkdir as mkdir16, writeFile as writeFile8 } from "fs/promises";
44712
44642
  import { Buffer as Buffer3 } from "buffer";
44713
- import { dirname as dirname12, isAbsolute as isAbsolute2, resolve as resolve4 } from "path";
44643
+ import { dirname as dirname12, isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
44714
44644
  var MCP_TRACE_SCHEMA_VERSION = 1;
44715
44645
  var DEFAULT_MCP_TRACE_MAX_BYTES = 256 * 1024;
44716
44646
  var DEFAULT_MCP_TRACE_MAX_EVENTS = 1e4;
@@ -44842,7 +44772,7 @@ var McpTraceWriter = class {
44842
44772
  function createMcpTraceWriter(sessionCwd, settings2 = {}, randomSuffix = Math.random().toString(36).slice(2, 10)) {
44843
44773
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
44844
44774
  const configuredPath = settings2.file;
44845
- const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath : resolve4(sessionCwd ?? process.cwd(), configuredPath) : resolve4(sessionCwd ?? process.cwd(), ".pi", "mcp-traces", `mcp-${timestamp}-${randomSuffix}.jsonl`);
44775
+ const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath : resolve3(sessionCwd ?? process.cwd(), configuredPath) : resolve3(sessionCwd ?? process.cwd(), ".pi", "mcp-traces", `mcp-${timestamp}-${randomSuffix}.jsonl`);
44846
44776
  return new McpTraceWriter({
44847
44777
  filePath,
44848
44778
  ...settings2.maxBytes !== void 0 ? { maxBytes: settings2.maxBytes } : {},
@@ -45057,7 +44987,7 @@ function resolvedCommand(config) {
45057
44987
  async function invokeRequestHeadersCommand(config, envelope, signal) {
45058
44988
  const resolved = resolvedCommand(config);
45059
44989
  if (USE_PROCESS_GROUP) assertPosixProcessDiscoveryAvailable();
45060
- return new Promise((resolve8, reject) => {
44990
+ return new Promise((resolve7, reject) => {
45061
44991
  let stdout = Buffer.alloc(0);
45062
44992
  let settled = false;
45063
44993
  const cleanupToken = randomUUID6();
@@ -45086,7 +45016,7 @@ async function invokeRequestHeadersCommand(config, envelope, signal) {
45086
45016
  if (descendantTracker) clearInterval(descendantTracker);
45087
45017
  signal.removeEventListener("abort", abort);
45088
45018
  if (result.status === "error") reject(result.error);
45089
- else resolve8(result.headers);
45019
+ else resolve7(result.headers);
45090
45020
  };
45091
45021
  const finishAfterKill = (result) => {
45092
45022
  try {
@@ -45708,7 +45638,7 @@ var McpServerManager = class {
45708
45638
  let args = (definition.args ?? []).map((argument) => interpolateEnvVars(argument));
45709
45639
  const cwd = resolveConfigPath(definition.cwd) ?? this.defaultCwd;
45710
45640
  if (cwd !== void 0) {
45711
- const cwdStats = statSync3(cwd, { throwIfNoEntry: false });
45641
+ const cwdStats = statSync2(cwd, { throwIfNoEntry: false });
45712
45642
  if (!cwdStats) throw new Error(`MCP server "${name}" configured cwd does not exist: "${cwd}"`);
45713
45643
  if (!cwdStats.isDirectory()) throw new Error(`MCP server "${name}" configured cwd is not a directory: "${cwd}"`);
45714
45644
  }
@@ -47908,7 +47838,7 @@ function getEffectiveIdleTimeoutMinutes(state, serverName) {
47908
47838
  }
47909
47839
 
47910
47840
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/onboarding-state.ts
47911
- import { existsSync as existsSync13, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync3, renameSync as renameSync2 } from "fs";
47841
+ import { existsSync as existsSync13, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3, renameSync as renameSync2 } from "fs";
47912
47842
  import { dirname as dirname13 } from "path";
47913
47843
  var DEFAULT_STATE2 = {
47914
47844
  version: 1,
@@ -47922,7 +47852,7 @@ function loadOnboardingState() {
47922
47852
  const path7 = getOnboardingStatePath();
47923
47853
  if (!existsSync13(path7)) return { ...DEFAULT_STATE2 };
47924
47854
  try {
47925
- const raw = JSON.parse(readFileSync6(path7, "utf-8"));
47855
+ const raw = JSON.parse(readFileSync5(path7, "utf-8"));
47926
47856
  if (!raw || typeof raw !== "object") return { ...DEFAULT_STATE2 };
47927
47857
  return {
47928
47858
  version: 1,
@@ -48378,12 +48308,12 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
48378
48308
  markSetupCompleted(discovery.fingerprint);
48379
48309
  }
48380
48310
  };
48381
- return new Promise((resolve8) => {
48311
+ return new Promise((resolve7) => {
48382
48312
  ctx.ui.custom(
48383
48313
  (tui, _theme, keybindings, done) => {
48384
48314
  return createMcpSetupPanel(discovery, callbacks, { mode, onboardingState, keybindings }, tui, () => {
48385
48315
  done(void 0);
48386
- resolve8({ configChanged });
48316
+ resolve7({ configChanged });
48387
48317
  });
48388
48318
  },
48389
48319
  { overlay: true, overlayOptions: { anchor: "center", width: 92 } }
@@ -48465,7 +48395,7 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
48465
48395
  const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
48466
48396
  const { createMcpPanel } = await import("./mcp-panel-2XMW56WJ.js");
48467
48397
  let configChanged = false;
48468
- await new Promise((resolve8) => {
48398
+ await new Promise((resolve7) => {
48469
48399
  ctx.ui.custom(
48470
48400
  (tui, _theme, keybindings, done) => {
48471
48401
  return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, (result) => {
@@ -48488,13 +48418,13 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
48488
48418
  ctx.ui.notify("Direct tools updated for this session.", "info");
48489
48419
  }
48490
48420
  done(void 0);
48491
- resolve8();
48421
+ resolve7();
48492
48422
  })().catch((error) => {
48493
48423
  const message = error instanceof Error ? error.message : String(error);
48494
48424
  ctx.ui.notify(`Direct tools updated, but live refresh failed: ${message}`, "error");
48495
48425
  configChanged = true;
48496
48426
  done(void 0);
48497
- resolve8();
48427
+ resolve7();
48498
48428
  });
48499
48429
  }, { noticeLines, keybindings });
48500
48430
  },
@@ -48536,12 +48466,12 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
48536
48466
  let overlayHandle;
48537
48467
  const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
48538
48468
  const { createMcpPanel } = await import("./mcp-panel-2XMW56WJ.js");
48539
- await new Promise((resolve8) => {
48469
+ await new Promise((resolve7) => {
48540
48470
  ctx.ui.custom(
48541
48471
  (tui, _theme, keybindings, done) => {
48542
48472
  return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, () => {
48543
48473
  done(void 0);
48544
- resolve8();
48474
+ resolve7();
48545
48475
  }, {
48546
48476
  authOnly: true,
48547
48477
  keybindings,
@@ -48563,7 +48493,7 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
48563
48493
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-registrar.ts
48564
48494
  import { mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
48565
48495
  import { tmpdir } from "os";
48566
- import { join as join25 } from "path";
48496
+ import { join as join24 } from "path";
48567
48497
  var MAX_BINARY_RESOURCE_BYTES = 10 * 1024 * 1024;
48568
48498
  var MAX_SESSION_RESOURCE_BYTES = 100 * 1024 * 1024;
48569
48499
  var MAX_SESSION_RESOURCE_FILES = 1e4;
@@ -48670,11 +48600,11 @@ function materializeBinaryResource(resource, scope) {
48670
48600
  return omitBinaryResource(resource, "session resource limit reached");
48671
48601
  }
48672
48602
  try {
48673
- session.directory ??= mkdtempSync(join25(tmpdir(), "pi-mcp-resource-"));
48603
+ session.directory ??= mkdtempSync(join24(tmpdir(), "pi-mcp-resource-"));
48674
48604
  } catch {
48675
48605
  return omitBinaryResource(resource, "could not be saved");
48676
48606
  }
48677
- const filePath = join25(session.directory, `resource-${++session.sequence}.bin`);
48607
+ const filePath = join24(session.directory, `resource-${++session.sequence}.bin`);
48678
48608
  session.bytes += decodedBytes;
48679
48609
  session.files += 1;
48680
48610
  try {
@@ -48767,7 +48697,7 @@ function stringifyStructuredContent(value) {
48767
48697
  import { randomBytes as randomBytes4 } from "crypto";
48768
48698
  import { mkdtemp, rm as rm3, writeFile as writeFile9 } from "fs/promises";
48769
48699
  import { tmpdir as tmpdir2 } from "os";
48770
- import { dirname as dirname14, join as join26 } from "path";
48700
+ import { dirname as dirname14, join as join25 } from "path";
48771
48701
  var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
48772
48702
  var DEFAULT_MCP_OUTPUT_MAX_LINES = 2e3;
48773
48703
  var DEFAULT_MCP_DETAILS_MAX_BYTES = 16 * 1024;
@@ -49075,8 +49005,8 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
49075
49005
  }
49076
49006
  async function saveArtifact(kind, text) {
49077
49007
  try {
49078
- const dir = await mkdtemp(join26(tmpdir2(), "pi-mcp-output-"));
49079
- const path7 = join26(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
49008
+ const dir = await mkdtemp(join25(tmpdir2(), "pi-mcp-output-"));
49009
+ const path7 = join25(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
49080
49010
  await writeFile9(path7, text, { encoding: "utf8", mode: 384 });
49081
49011
  return { path: path7 };
49082
49012
  } catch (error) {
@@ -50488,7 +50418,7 @@ data: ${JSON.stringify(payload)}
50488
50418
  markCompleted("stale");
50489
50419
  }, WATCHDOG_INTERVAL_MS);
50490
50420
  watchdog.unref();
50491
- return new Promise((resolve8, reject) => {
50421
+ return new Promise((resolve7, reject) => {
50492
50422
  const candidates = resolvePortCandidates(options.port);
50493
50423
  let candidateIndex = 0;
50494
50424
  const startSandboxProxy = (parentOrigin) => {
@@ -50625,7 +50555,7 @@ data: ${JSON.stringify(payload)}
50625
50555
  getSessionMessages: () => ({ ...sessionMessages }),
50626
50556
  getStreamSummary: () => streamSummary ? { ...streamSummary, phases: [...streamSummary.phases] } : void 0
50627
50557
  };
50628
- resolve8(handle);
50558
+ resolve7(handle);
50629
50559
  }).catch((error) => {
50630
50560
  log.error("Failed to start sandbox proxy", error instanceof Error ? error : void 0);
50631
50561
  closeListeners();
@@ -50650,7 +50580,7 @@ async function parseBody(req, res) {
50650
50580
  }
50651
50581
  }
50652
50582
  function readBody(req) {
50653
- return new Promise((resolve8, reject) => {
50583
+ return new Promise((resolve7, reject) => {
50654
50584
  let size = 0;
50655
50585
  const chunks = [];
50656
50586
  req.on("data", (chunk) => {
@@ -50664,7 +50594,7 @@ function readBody(req) {
50664
50594
  });
50665
50595
  req.on("end", () => {
50666
50596
  try {
50667
- resolve8(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
50597
+ resolve7(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
50668
50598
  } catch (error) {
50669
50599
  reject(error);
50670
50600
  }
@@ -50723,7 +50653,7 @@ function sendText(res, status, text) {
50723
50653
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/glimpse-ui.ts
50724
50654
  import { existsSync as existsSync14 } from "fs";
50725
50655
  import { execFileSync as execFileSync2 } from "child_process";
50726
- import { join as join27, dirname as dirname15 } from "path";
50656
+ import { join as join26, dirname as dirname15 } from "path";
50727
50657
  import { platform as platform2 } from "os";
50728
50658
  import { createRequire as createRequire3 } from "module";
50729
50659
  var glimpseAvailable = null;
@@ -50745,20 +50675,20 @@ function getGlimpseBinaryPath() {
50745
50675
  try {
50746
50676
  const require6 = createRequire3(import.meta.url);
50747
50677
  const glimpseuiPath = require6.resolve("glimpseui");
50748
- const binaryPath = join27(dirname15(glimpseuiPath), "glimpse");
50678
+ const binaryPath = join26(dirname15(glimpseuiPath), "glimpse");
50749
50679
  if (existsSync14(binaryPath)) return binaryPath;
50750
50680
  } catch {
50751
50681
  }
50752
50682
  try {
50753
50683
  const globalRoot = execFileSync2("npm", ["root", "-g"], { encoding: "utf-8" }).trim();
50754
- const binaryPath = join27(globalRoot, "glimpseui", "src", "glimpse");
50684
+ const binaryPath = join26(globalRoot, "glimpseui", "src", "glimpse");
50755
50685
  if (existsSync14(binaryPath)) return binaryPath;
50756
50686
  } catch {
50757
50687
  }
50758
50688
  return null;
50759
50689
  }
50760
50690
  async function openGlimpseWindow(html, options) {
50761
- const modulePath = resolvedBinaryPath ? join27(dirname15(resolvedBinaryPath), "glimpse.mjs") : "glimpseui";
50691
+ const modulePath = resolvedBinaryPath ? join26(dirname15(resolvedBinaryPath), "glimpse.mjs") : "glimpseui";
50762
50692
  const glimpse = await import(modulePath);
50763
50693
  let active = true;
50764
50694
  const win = glimpse.open(html, {
@@ -50845,22 +50775,22 @@ function isRemoteSession() {
50845
50775
  return Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
50846
50776
  }
50847
50777
  function hasActiveRemoteLogin() {
50848
- return new Promise((resolve8) => {
50778
+ return new Promise((resolve7) => {
50849
50779
  execFile6("who", { encoding: "utf8", timeout: 2e3 }, (error, out) => {
50850
50780
  if (error) {
50851
- resolve8(false);
50781
+ resolve7(false);
50852
50782
  return;
50853
50783
  }
50854
- resolve8(/\(.+\)\s*$/m.test(out));
50784
+ resolve7(/\(.+\)\s*$/m.test(out));
50855
50785
  });
50856
50786
  });
50857
50787
  }
50858
50788
  function probeMoshiGateway() {
50859
- return new Promise((resolve8) => {
50789
+ return new Promise((resolve7) => {
50860
50790
  const socket = net.connect({ host: "127.0.0.1", port: 24543 });
50861
50791
  const done = (ok) => {
50862
50792
  socket.destroy();
50863
- resolve8(ok);
50793
+ resolve7(ok);
50864
50794
  };
50865
50795
  socket.setTimeout(300);
50866
50796
  socket.once("connect", () => done(true));
@@ -57280,7 +57210,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
57280
57210
  trackUnmanagedFds: false
57281
57211
  });
57282
57212
  const activeWorker = worker;
57283
- const execution = new Promise((resolve8, reject) => {
57213
+ const execution = new Promise((resolve7, reject) => {
57284
57214
  let completed = false;
57285
57215
  activeWorker.on("message", (value) => {
57286
57216
  const message = parseWorkerMessage(value);
@@ -57292,7 +57222,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
57292
57222
  if (message.type === "done") {
57293
57223
  completed = true;
57294
57224
  if ("returnBlock" in message) output.push(toContentBlock(message.returnBlock));
57295
- resolve8();
57225
+ resolve7();
57296
57226
  return;
57297
57227
  }
57298
57228
  if (message.type === "error") {
@@ -57571,8 +57501,8 @@ async function awaitWithTimeout(promise, timeoutMs) {
57571
57501
  try {
57572
57502
  return await Promise.race([
57573
57503
  promise,
57574
- new Promise((resolve8) => {
57575
- timer = setTimeout(() => resolve8(INIT_WAIT_TIMED_OUT), timeoutMs);
57504
+ new Promise((resolve7) => {
57505
+ timer = setTimeout(() => resolve7(INIT_WAIT_TIMED_OUT), timeoutMs);
57576
57506
  timer.unref?.();
57577
57507
  })
57578
57508
  ]);
@@ -58670,7 +58600,7 @@ var PiManager = class extends CodingAgentManager {
58670
58600
  modelRuntime = null;
58671
58601
  constructor(options) {
58672
58602
  super(options);
58673
- this.historyFilePath = options.historyFilePath ?? join28(PI_HISTORY_DIR, `${Date.now()}.jsonl`);
58603
+ this.historyFilePath = options.historyFilePath ?? join27(PI_HISTORY_DIR, `${Date.now()}.jsonl`);
58674
58604
  this.historyFile = new CodexHistoryFile(this.historyFilePath);
58675
58605
  this.initializeManager(this.processMessageInternal.bind(this));
58676
58606
  }
@@ -58828,9 +58758,9 @@ var PiManager = class extends CodingAgentManager {
58828
58758
  }
58829
58759
  const resourceLoader = new DefaultResourceLoader({
58830
58760
  cwd: this.workingDirectory,
58831
- agentDir: join28(ENGINE_ENV.HOME_DIR, ".pi", "agent"),
58761
+ agentDir: join27(ENGINE_ENV.HOME_DIR, ".pi", "agent"),
58832
58762
  extensionFactories,
58833
- appendSystemPrompt: [this.buildCombinedInstructions() ?? ""]
58763
+ appendSystemPrompt: [this.buildCombinedInstructions(request.customInstructions) ?? ""]
58834
58764
  });
58835
58765
  await resourceLoader.reload();
58836
58766
  const result = await createAgentSession({
@@ -58950,8 +58880,8 @@ import {
58950
58880
  rename as rename3,
58951
58881
  unlink as unlink3
58952
58882
  } from "fs/promises";
58953
- import { existsSync as existsSync15, readFileSync as readFileSync7, readdirSync as readdirSync3 } from "fs";
58954
- import { join as join29 } from "path";
58883
+ import { existsSync as existsSync15, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "fs";
58884
+ import { join as join28 } from "path";
58955
58885
  var MAX_FAILED_RECORDS = 500;
58956
58886
  var FLUSH_DEBOUNCE_MS = 15e3;
58957
58887
  var MAX_UPLOADED_SEGMENTS = 50;
@@ -58963,7 +58893,7 @@ var AnalyticsRecordBuffer = class {
58963
58893
  options.storageName,
58964
58894
  ...options.legacyStorageNames ?? []
58965
58895
  ];
58966
- this.liveFile = join29(ENGINE_DIR2, `${options.storageName}.jsonl`);
58896
+ this.liveFile = join28(ENGINE_DIR2, `${options.storageName}.jsonl`);
58967
58897
  this.segmentFilePatterns = this.storageNames.map(
58968
58898
  (storageName) => new RegExp(`^${storageName}\\.(\\d+)\\.jsonl$`)
58969
58899
  );
@@ -58999,9 +58929,9 @@ var AnalyticsRecordBuffer = class {
58999
58929
  }
59000
58930
  readStoredRecords() {
59001
58931
  if (!existsSync15(ENGINE_DIR2)) return [];
59002
- return readdirSync3(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
58932
+ return readdirSync2(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
59003
58933
  (storageName) => entry.name === `${storageName}.jsonl` || entry.name.startsWith(`${storageName}.`) && (entry.name.endsWith(".jsonl") || entry.name.endsWith(`.jsonl${UPLOADED_SUFFIX}`))
59004
- )).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync7(join29(ENGINE_DIR2, name), "utf-8"))).map((record3) => {
58934
+ )).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync6(join28(ENGINE_DIR2, name), "utf-8"))).map((record3) => {
59005
58935
  const recordId = this.options.getRecordId?.(record3);
59006
58936
  if (recordId) this.recordIds.add(recordId);
59007
58937
  return record3;
@@ -59036,8 +58966,8 @@ var AnalyticsRecordBuffer = class {
59036
58966
  }
59037
58967
  for (const storageName of this.storageNames) {
59038
58968
  await rename3(
59039
- join29(ENGINE_DIR2, `${storageName}.jsonl`),
59040
- join29(ENGINE_DIR2, `${storageName}.${Date.now()}.jsonl`)
58969
+ join28(ENGINE_DIR2, `${storageName}.jsonl`),
58970
+ join28(ENGINE_DIR2, `${storageName}.${Date.now()}.jsonl`)
59041
58971
  ).catch(() => {
59042
58972
  });
59043
58973
  }
@@ -59047,7 +58977,7 @@ var AnalyticsRecordBuffer = class {
59047
58977
  for (const entry of entries) {
59048
58978
  if (!this.segmentFilePatterns.some((pattern) => pattern.test(entry))) continue;
59049
58979
  try {
59050
- await this.uploadSegment(join29(ENGINE_DIR2, entry));
58980
+ await this.uploadSegment(join28(ENGINE_DIR2, entry));
59051
58981
  flushed++;
59052
58982
  } catch (error) {
59053
58983
  failed++;
@@ -59076,7 +59006,7 @@ var AnalyticsRecordBuffer = class {
59076
59006
  (storageName) => entry.startsWith(`${storageName}.`)
59077
59007
  ) && entry.endsWith(UPLOADED_SUFFIX)).sort();
59078
59008
  for (const entry of uploaded.slice(0, -MAX_UPLOADED_SEGMENTS)) {
59079
- await unlink3(join29(ENGINE_DIR2, entry)).catch(() => {
59009
+ await unlink3(join28(ENGINE_DIR2, entry)).catch(() => {
59080
59010
  });
59081
59011
  }
59082
59012
  }
@@ -59871,15 +59801,15 @@ var keepAliveService = new KeepAliveService();
59871
59801
  // src/services/canvas-service.ts
59872
59802
  import { readdir as readdir7, readFile as readFile17, stat as stat4 } from "fs/promises";
59873
59803
  import { homedir as homedir13 } from "os";
59874
- import { join as join30 } from "path";
59804
+ import { join as join29 } from "path";
59875
59805
 
59876
59806
  // src/utils/contained-file.ts
59877
59807
  import { realpath, stat as stat3 } from "fs/promises";
59878
- import { resolve as resolve5 } from "path";
59808
+ import { resolve as resolve4 } from "path";
59879
59809
  async function resolveContainedFile(root, relativePath) {
59880
59810
  try {
59881
59811
  const [fullPath, resolvedRoot] = await Promise.all([
59882
- realpath(resolve5(root, relativePath)),
59812
+ realpath(resolve4(root, relativePath)),
59883
59813
  realpath(root)
59884
59814
  ]);
59885
59815
  const fileStat = await stat3(fullPath);
@@ -59913,15 +59843,15 @@ async function writeRevisionedTextFile(filePath, content, expectedRevision) {
59913
59843
 
59914
59844
  // src/services/canvas-service.ts
59915
59845
  var GLOBAL_CANVAS_DIRECTORIES = [
59916
- join30(homedir13(), ".claude", "plans"),
59917
- join30(process.env.XDG_DATA_HOME ?? join30(homedir13(), ".local", "share"), "opencode", "plans"),
59918
- join30(homedir13(), ".replicas", "canvas")
59846
+ join29(homedir13(), ".claude", "plans"),
59847
+ join29(process.env.XDG_DATA_HOME ?? join29(homedir13(), ".local", "share"), "opencode", "plans"),
59848
+ join29(homedir13(), ".replicas", "canvas")
59919
59849
  ];
59920
59850
  async function canvasDirectories() {
59921
59851
  const repositories = await gitService.listRepositories().catch(() => []);
59922
59852
  return [
59923
59853
  ...GLOBAL_CANVAS_DIRECTORIES,
59924
- ...repositories.map((repository) => join30(repository.path, ".opencode", "plans"))
59854
+ ...repositories.map((repository) => join29(repository.path, ".opencode", "plans"))
59925
59855
  ];
59926
59856
  }
59927
59857
  var CanvasService = class {
@@ -59946,7 +59876,7 @@ var CanvasService = class {
59946
59876
  for (const entry of entries) {
59947
59877
  if (entry.name.startsWith(".")) continue;
59948
59878
  const filename = current.relativePath ? `${current.relativePath}/${entry.name}` : entry.name;
59949
- const filePath = join30(current.directory, entry.name);
59879
+ const filePath = join29(current.directory, entry.name);
59950
59880
  if (entry.isDirectory()) {
59951
59881
  pending.push({ directory: filePath, relativePath: filename });
59952
59882
  continue;
@@ -59971,7 +59901,7 @@ var CanvasService = class {
59971
59901
  if (!safe) return null;
59972
59902
  const { kind, mimeType } = classifyCanvasFilename(safe);
59973
59903
  for (const directory of await this.directories()) {
59974
- const filePath = join30(directory, safe);
59904
+ const filePath = join29(directory, safe);
59975
59905
  let sizeBytes = 0;
59976
59906
  let updatedAt = "";
59977
59907
  try {
@@ -60048,7 +59978,7 @@ function isReconcileCanvasItemsResponse(value) {
60048
59978
  }
60049
59979
  async function withCanvasUploadSlot(operation) {
60050
59980
  if (activeCanvasUploads >= MAX_CONCURRENT_CANVAS_UPLOADS) {
60051
- await new Promise((resolve8) => pendingCanvasUploads.push(resolve8));
59981
+ await new Promise((resolve7) => pendingCanvasUploads.push(resolve7));
60052
59982
  } else {
60053
59983
  activeCanvasUploads++;
60054
59984
  }
@@ -60155,13 +60085,13 @@ async function reconcileCanvasItems(filenames) {
60155
60085
  import { createReadStream as createReadStream2 } from "fs";
60156
60086
  import { createHash as createHash7 } from "crypto";
60157
60087
  import { readFile as readFile18, readdir as readdir8, stat as stat5 } from "fs/promises";
60158
- import { basename as basename3, join as join32 } from "path";
60088
+ import { basename as basename3, join as join31 } from "path";
60159
60089
 
60160
60090
  // src/services/chat/chat-senders.ts
60161
- import { join as join31 } from "path";
60162
- var CHAT_SENDERS_DIR = join31(ENGINE_DIR2, "chat-senders");
60091
+ import { join as join30 } from "path";
60092
+ var CHAT_SENDERS_DIR = join30(ENGINE_DIR2, "chat-senders");
60163
60093
  function chatMessageSendersFilePath(chatId) {
60164
- return join31(CHAT_SENDERS_DIR, `${chatId}.jsonl`);
60094
+ return join30(CHAT_SENDERS_DIR, `${chatId}.jsonl`);
60165
60095
  }
60166
60096
  function parseChatMessageSendersJsonl(content) {
60167
60097
  return content.split("\n").flatMap((line) => {
@@ -60204,7 +60134,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
60204
60134
  const chat = chatsById.get(chatId);
60205
60135
  if (!shouldFlushChatTranscript(dir, chat, chatsById)) continue;
60206
60136
  tasks.push(
60207
- uploadChatTranscript(chatId, join32(dir, entry), chat, capture).then((artifact) => {
60137
+ uploadChatTranscript(chatId, join31(dir, entry), chat, capture).then((artifact) => {
60208
60138
  flushed++;
60209
60139
  if (artifact && capture) revisions.push(artifact);
60210
60140
  }).catch((err) => {
@@ -60292,7 +60222,7 @@ async function uploadChatTranscriptNow(chatId, filePath, chat, capture) {
60292
60222
  // src/services/upload-engine-logs.ts
60293
60223
  import { createReadStream as createReadStream3 } from "fs";
60294
60224
  import { readdir as readdir9, stat as stat6 } from "fs/promises";
60295
- import { join as join33 } from "path";
60225
+ import { join as join32 } from "path";
60296
60226
  var MAX_ENGINE_LOG_FLUSH_SESSIONS = 10;
60297
60227
  var MAX_ENGINE_LOG_FLUSH_BYTES = 5 * 1024 * 1024;
60298
60228
  var ENGINE_LOG_FLUSH_TIMEOUT_MS = 2e4;
@@ -60321,7 +60251,7 @@ async function flushAllEngineLogs() {
60321
60251
  const candidates = (await Promise.all(filenames.slice(0, MAX_ENGINE_LOG_FLUSH_SESSIONS).map(async (filename) => {
60322
60252
  try {
60323
60253
  const sessionId = filename.slice(0, -".log".length);
60324
- const filePath = join33(LOG_DIR, filename);
60254
+ const filePath = join32(LOG_DIR, filename);
60325
60255
  const fileStat = await runBeforeDeadline(() => stat6(filePath), deadline);
60326
60256
  if (!fileStat.isFile()) {
60327
60257
  skipped++;
@@ -60386,13 +60316,13 @@ function runBeforeDeadline(operation, deadline) {
60386
60316
  const timeoutMs = deadline - Date.now();
60387
60317
  if (timeoutMs <= 0) return Promise.reject(new DOMException("engine log flush deadline exceeded", "TimeoutError"));
60388
60318
  const signal = AbortSignal.timeout(timeoutMs);
60389
- return new Promise((resolve8, reject) => {
60319
+ return new Promise((resolve7, reject) => {
60390
60320
  const onAbort = () => reject(signal.reason);
60391
60321
  signal.addEventListener("abort", onAbort, { once: true });
60392
60322
  operation(signal).then(
60393
60323
  (value) => {
60394
60324
  signal.removeEventListener("abort", onAbort);
60395
- resolve8(value);
60325
+ resolve7(value);
60396
60326
  },
60397
60327
  (error) => {
60398
60328
  signal.removeEventListener("abort", onAbort);
@@ -60419,7 +60349,7 @@ async function uploadEngineLog(input, timeoutMs) {
60419
60349
  // src/services/chat/fork-handoff.ts
60420
60350
  import { createHash as createHash8 } from "crypto";
60421
60351
  import { mkdir as mkdir19, open as open3, writeFile as writeFile10 } from "fs/promises";
60422
- import { join as join34 } from "path";
60352
+ import { join as join33 } from "path";
60423
60353
  var EXCERPT_MAX_CHARS = 24e3;
60424
60354
  var MAX_SANITIZED_SOURCE_BYTES = 32 * 1024 * 1024;
60425
60355
  function unansweredRequest(blocks) {
@@ -60467,7 +60397,7 @@ function unseenTurnsExcerpt(seenHashes, blocks) {
60467
60397
  ${excerpt}` : excerpt;
60468
60398
  }
60469
60399
  async function buildForkHandoff(input) {
60470
- const rawHistoryPath = join34(HISTORY_DIR_BY_PROVIDER[input.sourceProvider], `${input.sourceChatId}.jsonl`);
60400
+ const rawHistoryPath = join33(HISTORY_DIR_BY_PROVIDER[input.sourceProvider], `${input.sourceChatId}.jsonl`);
60471
60401
  const { content, truncated: sourceTruncated } = await readHistoryTail(rawHistoryPath, MAX_SANITIZED_SOURCE_BYTES);
60472
60402
  let blocks = canonicalizeChatTranscriptBlocks(content, input.executionProvider, input.senders);
60473
60403
  if (input.turnLimit !== void 0) {
@@ -60475,9 +60405,9 @@ async function buildForkHandoff(input) {
60475
60405
  const start = blocks.findLastIndex((block) => block.startsWith("## User") && ++turns === input.turnLimit);
60476
60406
  blocks = blocks.slice(Math.max(0, start));
60477
60407
  }
60478
- const forkDir = join34(FORKS_DIR, input.targetChatId);
60408
+ const forkDir = join33(FORKS_DIR, input.targetChatId);
60479
60409
  await mkdir19(forkDir, { recursive: true });
60480
- const transcriptPath = join34(forkDir, "source-transcript.md");
60410
+ const transcriptPath = join33(forkDir, "source-transcript.md");
60481
60411
  const header = sourceTruncated ? `_This file was generated from only the most recent ${MAX_SANITIZED_SOURCE_BYTES / 1024 / 1024} MB of the source chat.${input.turnLimit === void 0 ? ` The complete raw event log is at ${rawHistoryPath}; grep it for anything earlier.` : ""}_
60482
60412
 
60483
60413
  ` : "";
@@ -60844,8 +60774,8 @@ var ChatService = class {
60844
60774
  if (result.status === "completed") return result;
60845
60775
  const remainingMs = timeoutMs === null ? null : timeoutMs - (Date.now() - startedAt);
60846
60776
  if (remainingMs !== null && remainingMs <= 0) return { ...result, timedOut: true };
60847
- await new Promise((resolve8) => setTimeout(
60848
- resolve8,
60777
+ await new Promise((resolve7) => setTimeout(
60778
+ resolve7,
60849
60779
  remainingMs === null ? RELAY_SUBAGENT_POLL_INTERVAL_MS : Math.min(RELAY_SUBAGENT_POLL_INTERVAL_MS, remainingMs)
60850
60780
  ));
60851
60781
  }
@@ -61261,14 +61191,14 @@ var ChatService = class {
61261
61191
  return descendants;
61262
61192
  }
61263
61193
  async deleteHistoryFile(persisted) {
61264
- const historyPath = join35(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
61194
+ const historyPath = join34(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
61265
61195
  await Promise.all([
61266
61196
  historyPath,
61267
61197
  `${historyPath}.pages.jsonl`,
61268
61198
  `${historyPath}.pages.index.json`
61269
61199
  ].map((path7) => rm4(path7, { force: true })));
61270
61200
  await rm4(chatMessageSendersFilePath(persisted.id), { force: true });
61271
- await rm4(join35(FORKS_DIR, persisted.id), { recursive: true, force: true });
61201
+ await rm4(join34(FORKS_DIR, persisted.id), { recursive: true, force: true });
61272
61202
  }
61273
61203
  /** Resolves once the target chat exists; the handoff and its first turn run in the background. */
61274
61204
  async forkChat(sourceChatId, request, trigger = "manual", reason) {
@@ -61469,7 +61399,7 @@ var ChatService = class {
61469
61399
  const chatId = chat.persisted.id;
61470
61400
  uploadChatTranscript(
61471
61401
  chatId,
61472
- join35(HISTORY_DIR_BY_PROVIDER[chat.persisted.provider], `${chatId}.jsonl`),
61402
+ join34(HISTORY_DIR_BY_PROVIDER[chat.persisted.provider], `${chatId}.jsonl`),
61473
61403
  this.toTranscriptSource(chat)
61474
61404
  ).catch((err) => {
61475
61405
  console.error("[ChatService] Failed to upload chat transcript:", { chatId, err });
@@ -61572,7 +61502,7 @@ var ChatService = class {
61572
61502
  }
61573
61503
  const baseProvider = getChatExecutionProvider(persisted);
61574
61504
  const additionalInstructions = persisted.provider === "relay" ? buildRelayInstructions(this.workingDirectory) : void 0;
61575
- const historyFilePath = join35(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
61505
+ const historyFilePath = join34(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
61576
61506
  const managerOptions = {
61577
61507
  provider: baseProvider,
61578
61508
  workingDirectory: this.workingDirectory,
@@ -61984,9 +61914,9 @@ import { extname as extname3 } from "path";
61984
61914
 
61985
61915
  // src/services/language-server-service.ts
61986
61916
  import { spawn as spawn6 } from "child_process";
61987
- import { existsSync as existsSync16, readFileSync as readFileSync8 } from "fs";
61917
+ import { existsSync as existsSync16, readFileSync as readFileSync7 } from "fs";
61988
61918
  import { createRequire as createRequire5 } from "module";
61989
- import { delimiter as delimiter2, dirname as dirname17, join as join36, relative as relative2 } from "path";
61919
+ import { delimiter as delimiter2, dirname as dirname17, join as join35, relative as relative2 } from "path";
61990
61920
  import { setTimeout as setTimeout3 } from "timers/promises";
61991
61921
  import { fileURLToPath as fileURLToPath5, pathToFileURL } from "url";
61992
61922
  import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node.js";
@@ -62024,7 +61954,7 @@ var LANGUAGE_SERVERS = {
62024
61954
  };
62025
61955
  function packageBin(packageName, binName) {
62026
61956
  const packageJsonPath = require5.resolve(`${packageName}/package.json`);
62027
- const packageJson = JSON.parse(readFileSync8(packageJsonPath, "utf8"));
61957
+ const packageJson = JSON.parse(readFileSync7(packageJsonPath, "utf8"));
62028
61958
  const bin = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin[binName];
62029
61959
  if (!bin) throw new Error(`Missing ${binName} binary`);
62030
61960
  return `${dirname17(packageJsonPath)}/${bin}`;
@@ -62105,7 +62035,7 @@ var LanguageServerService = class {
62105
62035
  if (config.package && config.bin) command = process.execPath;
62106
62036
  else if (config.command) {
62107
62037
  const commandName = config.command;
62108
- command = process.env.PATH?.split(delimiter2).map((directory) => join36(directory, commandName)).find(existsSync16);
62038
+ command = process.env.PATH?.split(delimiter2).map((directory) => join35(directory, commandName)).find(existsSync16);
62109
62039
  }
62110
62040
  const args = config.package && config.bin ? [packageBin(config.package, config.bin), ...config.args] : config.args;
62111
62041
  if (!command) return null;
@@ -62128,7 +62058,7 @@ var LanguageServerService = class {
62128
62058
  const absolutePath = fileURLToPath5(uri);
62129
62059
  const path7 = relative2(repoPath, absolutePath);
62130
62060
  if (path7.startsWith("..")) return [];
62131
- const preview = readFileSync8(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
62061
+ const preview = readFileSync7(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
62132
62062
  return [{ repoName, path: path7, line: range.start.line + 1, character: range.start.character, endCharacter: range.end.character, preview }];
62133
62063
  });
62134
62064
  return { symbol: "", detail: null, documentation: null, locations, provider: "language-server" };
@@ -62181,7 +62111,7 @@ function isBinaryExtension(filePath) {
62181
62111
  return classifyCanvasFilename(filePath).kind === "image" || binaryExts.has(ext);
62182
62112
  }
62183
62113
  function execGitAsync(args, cwd, timeoutMs) {
62184
- return new Promise((resolve8, reject) => {
62114
+ return new Promise((resolve7, reject) => {
62185
62115
  const child = execFile7("git", args, {
62186
62116
  cwd,
62187
62117
  encoding: "utf-8",
@@ -62191,7 +62121,7 @@ function execGitAsync(args, cwd, timeoutMs) {
62191
62121
  if (error) {
62192
62122
  reject(error);
62193
62123
  } else {
62194
- resolve8(stdout);
62124
+ resolve7(stdout);
62195
62125
  }
62196
62126
  });
62197
62127
  child.stdin?.end();
@@ -62447,20 +62377,20 @@ var RepoFileService = class {
62447
62377
  import { Hono } from "hono";
62448
62378
  import { z as z4 } from "zod";
62449
62379
  import { readdir as readdir11, stat as stat7, readFile as readFile23 } from "fs/promises";
62450
- import { join as join39, resolve as resolve6 } from "path";
62380
+ import { join as join38, resolve as resolve5 } from "path";
62451
62381
 
62452
62382
  // src/services/warm-hooks-service.ts
62453
62383
  import { spawn as spawn7 } from "child_process";
62454
62384
  import { readFile as readFile22 } from "fs/promises";
62455
62385
  import { existsSync as existsSync17 } from "fs";
62456
- import { join as join38 } from "path";
62386
+ import { join as join37 } from "path";
62457
62387
 
62458
62388
  // src/services/warm-hook-logs-service.ts
62459
62389
  import { mkdir as mkdir21, readFile as readFile21, writeFile as writeFile11, readdir as readdir10, appendFile as appendFile6, unlink as unlink4 } from "fs/promises";
62460
62390
  import { homedir as homedir14 } from "os";
62461
- import { join as join37 } from "path";
62462
- var LOGS_DIR2 = join37(homedir14(), ".replicas", "warm-hook-logs");
62463
- var CURRENT_RUN_LOG = join37(LOGS_DIR2, "current-run.log");
62391
+ import { join as join36 } from "path";
62392
+ var LOGS_DIR2 = join36(homedir14(), ".replicas", "warm-hook-logs");
62393
+ var CURRENT_RUN_LOG = join36(LOGS_DIR2, "current-run.log");
62464
62394
  var GLOBAL_FILENAME = "global.json";
62465
62395
  function withPreview2(stored) {
62466
62396
  const preview = buildHookOutputPreview(stored.output);
@@ -62477,7 +62407,7 @@ var WarmHookLogsService = class {
62477
62407
  hookName: "organization",
62478
62408
  ...entry
62479
62409
  };
62480
- await writeFile11(join37(LOGS_DIR2, GLOBAL_FILENAME), `${JSON.stringify(log, null, 2)}
62410
+ await writeFile11(join36(LOGS_DIR2, GLOBAL_FILENAME), `${JSON.stringify(log, null, 2)}
62481
62411
  `, "utf-8");
62482
62412
  }
62483
62413
  async saveEnvironmentHookLog(entry) {
@@ -62487,7 +62417,7 @@ var WarmHookLogsService = class {
62487
62417
  hookName: "environment",
62488
62418
  ...entry
62489
62419
  };
62490
- await writeFile11(join37(LOGS_DIR2, ENVIRONMENT_HOOK_LOG_FILENAME), `${JSON.stringify(log, null, 2)}
62420
+ await writeFile11(join36(LOGS_DIR2, ENVIRONMENT_HOOK_LOG_FILENAME), `${JSON.stringify(log, null, 2)}
62491
62421
  `, "utf-8");
62492
62422
  }
62493
62423
  async saveRepoHookLog(repoName, entry) {
@@ -62497,7 +62427,7 @@ var WarmHookLogsService = class {
62497
62427
  hookName: repoName,
62498
62428
  ...entry
62499
62429
  };
62500
- await writeFile11(join37(LOGS_DIR2, repoHookLogFilename(repoName)), `${JSON.stringify(log, null, 2)}
62430
+ await writeFile11(join36(LOGS_DIR2, repoHookLogFilename(repoName)), `${JSON.stringify(log, null, 2)}
62501
62431
  `, "utf-8");
62502
62432
  }
62503
62433
  async getAllLogs() {
@@ -62516,7 +62446,7 @@ var WarmHookLogsService = class {
62516
62446
  continue;
62517
62447
  }
62518
62448
  try {
62519
- const raw = await readFile21(join37(LOGS_DIR2, file), "utf-8");
62449
+ const raw = await readFile21(join36(LOGS_DIR2, file), "utf-8");
62520
62450
  const stored = JSON.parse(raw);
62521
62451
  logs.push(withPreview2(stored));
62522
62452
  } catch {
@@ -62554,7 +62484,7 @@ var WarmHookLogsService = class {
62554
62484
  async getFullOutput(hookType, hookName) {
62555
62485
  const filename = hookType === "global" ? GLOBAL_FILENAME : hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
62556
62486
  try {
62557
- const raw = await readFile21(join37(LOGS_DIR2, filename), "utf-8");
62487
+ const raw = await readFile21(join36(LOGS_DIR2, filename), "utf-8");
62558
62488
  const stored = JSON.parse(raw);
62559
62489
  if (stored.hookType !== hookType || stored.hookName !== hookName) {
62560
62490
  return null;
@@ -62573,7 +62503,7 @@ var warmHookLogsService = new WarmHookLogsService();
62573
62503
  // src/services/warm-hooks-service.ts
62574
62504
  async function readRepoWarmHook(repoPath) {
62575
62505
  for (const filename of REPLICAS_CONFIG_FILENAMES) {
62576
- const configPath = join38(repoPath, filename);
62506
+ const configPath = join37(repoPath, filename);
62577
62507
  if (!existsSync17(configPath)) {
62578
62508
  continue;
62579
62509
  }
@@ -62624,7 +62554,7 @@ async function executeHookScriptStreaming(params) {
62624
62554
  let bufferExceeded = false;
62625
62555
  params.onChunk(`$ ${params.label}
62626
62556
  `);
62627
- return new Promise((resolve8) => {
62557
+ return new Promise((resolve7) => {
62628
62558
  const proc = spawn7("bash", ["-lc", params.content], {
62629
62559
  cwd: params.cwd,
62630
62560
  env: process.env,
@@ -62657,7 +62587,7 @@ async function executeHookScriptStreaming(params) {
62657
62587
  proc.on("close", (code) => {
62658
62588
  clearTimeout(timer);
62659
62589
  const output = [`$ ${params.label}`, ...outputParts].join("");
62660
- resolve8({
62590
+ resolve7({
62661
62591
  exitCode: bufferExceeded ? 1 : code ?? 1,
62662
62592
  output,
62663
62593
  timedOut: killed && !bufferExceeded
@@ -62667,7 +62597,7 @@ async function executeHookScriptStreaming(params) {
62667
62597
  clearTimeout(timer);
62668
62598
  const output = [`$ ${params.label}
62669
62599
  `, ...outputParts, err.message].join("");
62670
- resolve8({
62600
+ resolve7({
62671
62601
  exitCode: 1,
62672
62602
  output,
62673
62603
  timedOut: false
@@ -63933,7 +63863,7 @@ data: ${JSON.stringify("Terminal session not found")}
63933
63863
  const logFiles = files.filter((f) => f.endsWith(".log"));
63934
63864
  const sessions = await Promise.all(
63935
63865
  logFiles.map(async (filename) => {
63936
- const filePath = join39(LOG_DIR, filename);
63866
+ const filePath = join38(LOG_DIR, filename);
63937
63867
  const fileStat = await stat7(filePath);
63938
63868
  const sessionId = filename.replace(/\.log$/, "");
63939
63869
  return {
@@ -63962,8 +63892,8 @@ data: ${JSON.stringify("Terminal session not found")}
63962
63892
  if (!isValidEngineLogSessionId(sessionId)) {
63963
63893
  return c.json(jsonError("Invalid session ID"), 400);
63964
63894
  }
63965
- const filePath = resolve6(LOG_DIR, `${sessionId}.log`);
63966
- if (!filePath.startsWith(resolve6(LOG_DIR))) {
63895
+ const filePath = resolve5(LOG_DIR, `${sessionId}.log`);
63896
+ if (!filePath.startsWith(resolve5(LOG_DIR))) {
63967
63897
  return c.json(jsonError("Invalid session ID"), 400);
63968
63898
  }
63969
63899
  let content;
@@ -64044,12 +63974,12 @@ var heartbeatService = new HeartbeatService();
64044
63974
 
64045
63975
  // src/services/workspace-sdk-service.ts
64046
63976
  import { cp, mkdir as mkdir22 } from "fs/promises";
64047
- import { dirname as dirname18, resolve as resolve7 } from "path";
63977
+ import { dirname as dirname18, resolve as resolve6 } from "path";
64048
63978
  import { fileURLToPath as fileURLToPath6 } from "url";
64049
63979
  async function installWorkspaceSdk() {
64050
- const source = resolve7(dirname18(fileURLToPath6(import.meta.url)), "../../workspace-sdk");
63980
+ const source = resolve6(dirname18(fileURLToPath6(import.meta.url)), "../../workspace-sdk");
64051
63981
  const targets = [
64052
- resolve7(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
63982
+ resolve6(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
64053
63983
  "/tmp/node_modules/@replicas/sdk"
64054
63984
  ];
64055
63985
  await Promise.all(targets.map(async (target) => {
@@ -64103,11 +64033,11 @@ async function checkActiveSSHSessions() {
64103
64033
  }
64104
64034
  }
64105
64035
  function checkDesktopReady() {
64106
- return new Promise((resolve8) => {
64036
+ return new Promise((resolve7) => {
64107
64037
  const socket = connect({ host: "127.0.0.1", port: DESKTOP_STREAM_PORT });
64108
64038
  const done = (ready) => {
64109
64039
  socket.destroy();
64110
- resolve8(ready);
64040
+ resolve7(ready);
64111
64041
  };
64112
64042
  socket.once("connect", () => done(true));
64113
64043
  socket.once("error", () => done(false));