replicas-engine 0.1.889 → 0.1.891

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
@@ -91,7 +91,7 @@ import {
91
91
  evaluateCommandProtection,
92
92
  extractToolCommand,
93
93
  reportCommandProtectionBlock
94
- } from "./chunk-WMRZEQIH.js";
94
+ } from "./chunk-4NFLZXZX.js";
95
95
  import {
96
96
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
97
  AGENT_MESSAGE_DELTA_METHOD,
@@ -114,6 +114,9 @@ import {
114
114
  putPresignedFile,
115
115
  recoverCompletedTurn
116
116
  } from "./chunk-FLDA7BX3.js";
117
+ import {
118
+ publishedPullRequestUrls
119
+ } from "./chunk-U2T2QCYP.js";
117
120
  import {
118
121
  RELAY_MCP_TOOLS,
119
122
  RELAY_MCP_TOOL_NAMES,
@@ -134,21 +137,21 @@ import {
134
137
  refreshDelayMs,
135
138
  restartCodexAspHost,
136
139
  routineRefreshExclusions
137
- } from "./chunk-N7JSMN3R.js";
140
+ } from "./chunk-TDLEF5FU.js";
138
141
  import {
139
142
  ENGINE_ENV,
140
143
  IS_WARMING_MODE,
141
144
  monolithRequest,
142
145
  monolithService,
143
146
  setAgentCredentialSnapshot
144
- } from "./chunk-RG6ZP2EU.js";
147
+ } from "./chunk-DG4VIQXA.js";
145
148
  import {
146
149
  AspClient,
147
150
  SUBPROCESS_MAX_BUFFER,
148
151
  execAsync,
149
152
  execFileAsync,
150
153
  getCodexModelProvider
151
- } from "./chunk-F33TXACU.js";
154
+ } from "./chunk-EDLDRUYW.js";
152
155
  import {
153
156
  isRecord as isRecord2
154
157
  } from "./chunk-UZSNFLDQ.js";
@@ -244,6 +247,7 @@ import {
244
247
  areSameUserMessageEvents,
245
248
  areUserMessagesWithinMatchWindow,
246
249
  autoCompactThresholdField,
250
+ buildCodeHostPrUrl,
247
251
  buildCodexTokenUsageContextUsagePayload,
248
252
  buildGitCredentialHelperScript,
249
253
  buildHookOutputPreview,
@@ -343,6 +347,7 @@ import {
343
347
  parseAgentEvents,
344
348
  parseChatHistoryCursor,
345
349
  parseChatTranscriptArtifact,
350
+ parseCodeHostPrUrl,
346
351
  parseDisplayMessages,
347
352
  parseFrontmatter,
348
353
  parseGitRemote,
@@ -367,7 +372,7 @@ import {
367
372
  waitRelaySubagentRequestSchema,
368
373
  withTimeout,
369
374
  workspaceCredentialProviderSchema
370
- } from "./chunk-45I2CJU6.js";
375
+ } from "./chunk-OBAGPETY.js";
371
376
  import {
372
377
  __commonJS,
373
378
  __export,
@@ -472,12 +477,12 @@ var require_isexe = __commonJS({
472
477
  if (typeof Promise !== "function") {
473
478
  throw new TypeError("callback not provided");
474
479
  }
475
- return new Promise(function(resolve7, reject) {
480
+ return new Promise(function(resolve8, reject) {
476
481
  isexe(path8, options || {}, function(er, is) {
477
482
  if (er) {
478
483
  reject(er);
479
484
  } else {
480
- resolve7(is);
485
+ resolve8(is);
481
486
  }
482
487
  });
483
488
  });
@@ -544,27 +549,27 @@ var require_which = __commonJS({
544
549
  opt = {};
545
550
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
546
551
  const found = [];
547
- const step = (i) => new Promise((resolve7, reject) => {
552
+ const step = (i) => new Promise((resolve8, reject) => {
548
553
  if (i === pathEnv.length)
549
- return opt.all && found.length ? resolve7(found) : reject(getNotFoundError(cmd));
554
+ return opt.all && found.length ? resolve8(found) : reject(getNotFoundError(cmd));
550
555
  const ppRaw = pathEnv[i];
551
556
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
552
557
  const pCmd = path8.join(pathPart, cmd);
553
558
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
554
- resolve7(subStep(p, i, 0));
559
+ resolve8(subStep(p, i, 0));
555
560
  });
556
- const subStep = (p, i, ii) => new Promise((resolve7, reject) => {
561
+ const subStep = (p, i, ii) => new Promise((resolve8, reject) => {
557
562
  if (ii === pathExt.length)
558
- return resolve7(step(i + 1));
563
+ return resolve8(step(i + 1));
559
564
  const ext = pathExt[ii];
560
565
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
561
566
  if (!er && is) {
562
567
  if (opt.all)
563
568
  found.push(p + ext);
564
569
  else
565
- return resolve7(p + ext);
570
+ return resolve8(p + ext);
566
571
  }
567
- return resolve7(subStep(p, i, ii + 1));
572
+ return resolve8(subStep(p, i, ii + 1));
568
573
  });
569
574
  });
570
575
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -3827,7 +3832,7 @@ var require_compile2 = __commonJS({
3827
3832
  const schOrFunc = root.refs[ref];
3828
3833
  if (schOrFunc)
3829
3834
  return schOrFunc;
3830
- let _sch = resolve7.call(this, root, ref);
3835
+ let _sch = resolve8.call(this, root, ref);
3831
3836
  if (_sch === void 0) {
3832
3837
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
3833
3838
  const { schemaId } = this.opts;
@@ -3854,7 +3859,7 @@ var require_compile2 = __commonJS({
3854
3859
  function sameSchemaEnv(s1, s2) {
3855
3860
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3856
3861
  }
3857
- function resolve7(root, ref) {
3862
+ function resolve8(root, ref) {
3858
3863
  let sch;
3859
3864
  while (typeof (sch = this.refs[ref]) == "string")
3860
3865
  ref = sch;
@@ -4485,7 +4490,7 @@ var require_fast_uri2 = __commonJS({
4485
4490
  }
4486
4491
  return uri;
4487
4492
  }
4488
- function resolve7(baseURI, relativeURI, options) {
4493
+ function resolve8(baseURI, relativeURI, options) {
4489
4494
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
4490
4495
  const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
4491
4496
  schemelessOptions.skipEscape = true;
@@ -4743,7 +4748,7 @@ var require_fast_uri2 = __commonJS({
4743
4748
  var fastUri = {
4744
4749
  SCHEMES,
4745
4750
  normalize,
4746
- resolve: resolve7,
4751
+ resolve: resolve8,
4747
4752
  resolveComponent,
4748
4753
  equal,
4749
4754
  serialize,
@@ -8655,11 +8660,12 @@ var DEFAULT_STATE = {
8655
8660
  };
8656
8661
  var stateWriteLock = new AsyncLock();
8657
8662
  async function updateEngineState(updater) {
8658
- await stateWriteLock.run(async () => {
8663
+ return stateWriteLock.run(async () => {
8659
8664
  await mkdir2(STATE_DIR, { recursive: true });
8660
8665
  const currentState = await loadEngineState();
8661
8666
  const nextState = updater(currentState);
8662
8667
  await atomicWriteFile(STATE_FILE, JSON.stringify(nextState, null, 2));
8668
+ return nextState;
8663
8669
  });
8664
8670
  }
8665
8671
  function isEngineRepoDiff(value) {
@@ -8730,7 +8736,7 @@ async function loadRepoState(repoName) {
8730
8736
  return state.repos[repoName] ?? null;
8731
8737
  }
8732
8738
  async function saveRepoState(repoName, state, fallbackState) {
8733
- await updateEngineState((currentState) => {
8739
+ const updated = await updateEngineState((currentState) => {
8734
8740
  const currentRepoState = currentState.repos[repoName] ?? fallbackState;
8735
8741
  return {
8736
8742
  ...currentState,
@@ -8738,16 +8744,19 @@ async function saveRepoState(repoName, state, fallbackState) {
8738
8744
  ...currentState.repos,
8739
8745
  [repoName]: {
8740
8746
  ...currentRepoState,
8741
- ...state
8747
+ ...state,
8748
+ // Publication events and repository refreshes can finish in either order.
8749
+ prUrls: [.../* @__PURE__ */ new Set([...currentRepoState.prUrls, ...state.prUrls ?? []])]
8742
8750
  }
8743
8751
  }
8744
8752
  };
8745
8753
  });
8754
+ return updated.repos[repoName];
8746
8755
  }
8747
8756
 
8748
8757
  // src/git/commands.ts
8749
- import { readFileSync } from "fs";
8750
- import { join as join3 } from "path";
8758
+ import { readdirSync, readFileSync, statSync } from "fs";
8759
+ import { join as join3, resolve } from "path";
8751
8760
  async function runGitCommand(args, cwd, options = {}) {
8752
8761
  const { stdout } = await execFileAsync("git", args, {
8753
8762
  cwd,
@@ -8756,14 +8765,37 @@ async function runGitCommand(args, cwd, options = {}) {
8756
8765
  });
8757
8766
  return stdout.trim();
8758
8767
  }
8759
- function readRepoHeadBranch(repoPath) {
8768
+ function readRepoHeadBranches(repoPath) {
8769
+ const branches = /* @__PURE__ */ new Set();
8760
8770
  try {
8761
- const contents = readFileSync(join3(repoPath, ".git", "HEAD"), "utf-8").trim();
8762
- const match = contents.match(/^ref:\s+refs\/heads\/(.+)$/);
8763
- return match ? match[1] : null;
8771
+ let gitDir = join3(repoPath, ".git");
8772
+ if (statSync(gitDir).isFile()) {
8773
+ const target = readFileSync(gitDir, "utf8").trim().match(/^gitdir: (.+)$/)?.[1];
8774
+ if (!target) return branches;
8775
+ gitDir = resolve(repoPath, target);
8776
+ }
8777
+ let commonDir = gitDir;
8778
+ try {
8779
+ commonDir = resolve(gitDir, readFileSync(join3(gitDir, "commondir"), "utf8").trim());
8780
+ } catch {
8781
+ }
8782
+ const headDirs = /* @__PURE__ */ new Set([gitDir, commonDir]);
8783
+ try {
8784
+ for (const entry of readdirSync(join3(commonDir, "worktrees"))) {
8785
+ headDirs.add(join3(commonDir, "worktrees", entry));
8786
+ }
8787
+ } catch {
8788
+ }
8789
+ for (const dir of headDirs) {
8790
+ try {
8791
+ const branch = readFileSync(join3(dir, "HEAD"), "utf8").trim().match(/^ref:\s+refs\/heads\/(.+)$/)?.[1];
8792
+ if (branch) branches.add(branch);
8793
+ } catch {
8794
+ }
8795
+ }
8764
8796
  } catch {
8765
- return null;
8766
8797
  }
8798
+ return branches;
8767
8799
  }
8768
8800
  async function branchExists(branchName, cwd) {
8769
8801
  try {
@@ -8893,7 +8925,10 @@ var GitService = class {
8893
8925
  const persistedState = await loadRepoState(repo.name);
8894
8926
  const currentBranch = await getCurrentBranch(repo.path) ?? repo.defaultBranch;
8895
8927
  const startHooksCompleted = persistedState?.startHooksCompleted ?? false;
8896
- const observed = observedBranchesByRepo?.get(repo.name);
8928
+ const observed = /* @__PURE__ */ new Set([
8929
+ ...readRepoHeadBranches(repo.path),
8930
+ ...observedBranchesByRepo?.get(repo.name) ?? []
8931
+ ]);
8897
8932
  const state = await this.refreshRepoMetadata(
8898
8933
  repo,
8899
8934
  currentBranch,
@@ -8912,19 +8947,33 @@ var GitService = class {
8912
8947
  }
8913
8948
  return { repos: states, complete: complete2 };
8914
8949
  }
8915
- // Fast branch snapshot for per-event observation during a turn. Reads
8916
- // .git/HEAD directly for each repo (no subprocess) so callers can safely
8917
- // invoke this on every agent event without measurable overhead.
8918
8950
  async snapshotCurrentBranches() {
8919
8951
  const repos = await this.listRepositories();
8920
- const branches = /* @__PURE__ */ new Map();
8952
+ return new Map(repos.map((repo) => [repo.name, readRepoHeadBranches(repo.path)]));
8953
+ }
8954
+ async recordPublishedPullRequest(prUrl) {
8955
+ if (!URL.canParse(prUrl)) return false;
8956
+ const parsed = parseCodeHostPrUrl(prUrl);
8957
+ if (!parsed || !Number.isSafeInteger(parsed.number) || parsed.number <= 0) return false;
8958
+ const url3 = new URL(prUrl);
8959
+ if (url3.host.toLowerCase() !== parsed.host || !["https:", "http:"].includes(url3.protocol)) return false;
8960
+ const canonicalUrl = buildCodeHostPrUrl(parsed.repoUrl, parsed.provider, parsed.number);
8961
+ const repos = await this.listRepositories();
8921
8962
  for (const repo of repos) {
8922
- const branch = readRepoHeadBranch(repo.path);
8923
- if (branch) {
8924
- branches.set(repo.name, branch);
8925
- }
8963
+ const remote = parseGitRemote(await runGitCommand(["remote", "get-url", "origin"], repo.path).catch(() => ""));
8964
+ if (!remote || remote.host !== parsed.host) continue;
8965
+ const sameRepository = parsed.provider === "github" ? remote.path.toLowerCase() === parsed.repositoryPath.toLowerCase() : remote.path === parsed.repositoryPath;
8966
+ if (!sameRepository) continue;
8967
+ await saveRepoState(repo.name, { prUrls: [canonicalUrl] }, {
8968
+ ...repo,
8969
+ currentBranch: await getCurrentBranch(repo.path) ?? repo.defaultBranch,
8970
+ prUrls: [],
8971
+ gitDiff: null,
8972
+ startHooksCompleted: false
8973
+ });
8974
+ return true;
8926
8975
  }
8927
- return branches;
8976
+ return false;
8928
8977
  }
8929
8978
  getGitDiffStats(repoPath, defaultBranch) {
8930
8979
  return this.diffStatsInFlight.run(repoPath, async () => {
@@ -8980,7 +9029,7 @@ var GitService = class {
8980
9029
  }
8981
9030
  }
8982
9031
  readUntrackedDiff(repoPath, paths) {
8983
- return new Promise((resolve7) => {
9032
+ return new Promise((resolve8) => {
8984
9033
  const child = spawn("git", ["diff", "--", ...paths], {
8985
9034
  cwd: repoPath,
8986
9035
  stdio: ["ignore", "pipe", "pipe"]
@@ -9001,12 +9050,12 @@ var GitService = class {
9001
9050
  });
9002
9051
  child.stderr.on("data", () => {
9003
9052
  });
9004
- child.on("error", () => resolve7(""));
9053
+ child.on("error", () => resolve8(""));
9005
9054
  child.on("close", (code) => {
9006
9055
  if (code === 0 || code === 1 || truncated) {
9007
- resolve7(Buffer.concat(chunks).toString("utf-8"));
9056
+ resolve8(Buffer.concat(chunks).toString("utf-8"));
9008
9057
  } else {
9009
- resolve7("");
9058
+ resolve8("");
9010
9059
  }
9011
9060
  });
9012
9061
  });
@@ -9270,8 +9319,7 @@ var GitService = class {
9270
9319
  startHooksCompleted,
9271
9320
  ...await this.resolveCodeHost(repo.path)
9272
9321
  };
9273
- await saveRepoState(repo.name, state, state);
9274
- return state;
9322
+ return saveRepoState(repo.name, state, state);
9275
9323
  }
9276
9324
  async safeStat(path8) {
9277
9325
  try {
@@ -9752,9 +9800,9 @@ var StreamWriter = class {
9752
9800
  return true;
9753
9801
  }
9754
9802
  flush(signal) {
9755
- return new Promise((resolve7, reject) => {
9803
+ return new Promise((resolve8, reject) => {
9756
9804
  if (!this.stream) {
9757
- resolve7();
9805
+ resolve8();
9758
9806
  return;
9759
9807
  }
9760
9808
  if (this.flushTimer) {
@@ -9771,7 +9819,7 @@ var StreamWriter = class {
9771
9819
  s.write("", (error) => {
9772
9820
  signal?.removeEventListener("abort", onAbort);
9773
9821
  if (error) reject(error);
9774
- else resolve7();
9822
+ else resolve8();
9775
9823
  });
9776
9824
  });
9777
9825
  }
@@ -10395,7 +10443,7 @@ var ReplicasConfigService = class {
10395
10443
  await this.logToFile(`[${params.repoName}] --- Running: ${params.label} ---`);
10396
10444
  emit(`$ ${params.label}
10397
10445
  `);
10398
- return new Promise((resolve7) => {
10446
+ return new Promise((resolve8) => {
10399
10447
  const proc = spawn2("bash", ["-lc", params.command], {
10400
10448
  cwd: params.cwd,
10401
10449
  env: process.env,
@@ -10406,7 +10454,7 @@ var ReplicasConfigService = class {
10406
10454
  const finish = (result) => {
10407
10455
  if (settled) return;
10408
10456
  settled = true;
10409
- resolve7(result);
10457
+ resolve8(result);
10410
10458
  };
10411
10459
  const timer = setTimeout(() => {
10412
10460
  timedOut = true;
@@ -10832,7 +10880,7 @@ async function registerDesktopPreview() {
10832
10880
  if (await attemptRegistration()) {
10833
10881
  return;
10834
10882
  }
10835
- await new Promise((resolve7) => setTimeout(resolve7, RETRY_DELAY_MS));
10883
+ await new Promise((resolve8) => setTimeout(resolve8, RETRY_DELAY_MS));
10836
10884
  }
10837
10885
  console.error(
10838
10886
  `[DesktopPreview] Gave up registering port ${DESKTOP_STREAM_PORT} after ${REGISTRATION_TIMEOUT_MS}ms`
@@ -12322,6 +12370,22 @@ var CHECK_TIMEOUT_MS = 3e4;
12322
12370
  var PullRequestCheckService = class {
12323
12371
  running = null;
12324
12372
  trailing = null;
12373
+ async recordPublishedPullRequest(url3) {
12374
+ if (await gitService.recordPublishedPullRequest(url3)) {
12375
+ this.check().catch((error) => console.error("[PullRequestCheck] Failed to report published PR:", error));
12376
+ }
12377
+ }
12378
+ async onToolResult(result) {
12379
+ if (!result.success) return;
12380
+ const urls = publishedPullRequestUrls(result);
12381
+ try {
12382
+ for (const url3 of urls) await gitService.recordPublishedPullRequest(url3);
12383
+ } finally {
12384
+ if (urls.length > 0 || shouldRefreshPullRequests(result.toolName, result.toolInput)) {
12385
+ this.check().catch((error) => console.error("[PullRequestCheck] Failed to report tool result:", error));
12386
+ }
12387
+ }
12388
+ }
12325
12389
  // Plain single-flight would hand a caller a result gathered before its PR
12326
12390
  // existed, so callers arriving mid-run instead share one trailing run that
12327
12391
  // starts after the current one settles.
@@ -12351,7 +12415,7 @@ var pullRequestCheckService = new PullRequestCheckService();
12351
12415
 
12352
12416
  // src/services/skill-registry-service.ts
12353
12417
  import { readFile as readFile9, readdir as readdir3, stat as stat2 } from "fs/promises";
12354
- import { dirname as dirname3, isAbsolute, join as join15, relative, resolve } from "path";
12418
+ import { dirname as dirname3, isAbsolute, join as join15, relative, resolve as resolve2 } from "path";
12355
12419
  var REGISTRY_ROOT_DIR = ".replicas/skill-registries";
12356
12420
  var REGISTRY_MANIFEST = "manifest.json";
12357
12421
  async function getSkillRegistryInventory(homeDir) {
@@ -12574,8 +12638,8 @@ async function fileExists(path8) {
12574
12638
  }
12575
12639
  }
12576
12640
  function isPathInside(parentPath, childPath) {
12577
- const parent = resolve(parentPath);
12578
- const child = resolve(childPath);
12641
+ const parent = resolve2(parentPath);
12642
+ const child = resolve2(childPath);
12579
12643
  const childRelativePath = relative(parent, child);
12580
12644
  return childRelativePath === "" || !childRelativePath.startsWith("..") && !isAbsolute(childRelativePath);
12581
12645
  }
@@ -12842,8 +12906,8 @@ var PromptStream = class {
12842
12906
  if (this.closed) {
12843
12907
  return Promise.resolve({ value: void 0, done: true });
12844
12908
  }
12845
- return new Promise((resolve7) => {
12846
- this.waiters.push(resolve7);
12909
+ return new Promise((resolve8) => {
12910
+ this.waiters.push(resolve8);
12847
12911
  });
12848
12912
  }
12849
12913
  };
@@ -13230,14 +13294,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13230
13294
  const requestId = randomUUID5();
13231
13295
  const toolUseId = options.toolUseID;
13232
13296
  const { options: requestOptions, questions: requestQuestions } = handler.getRequest(input);
13233
- const result = await new Promise((resolve7) => {
13297
+ const result = await new Promise((resolve8) => {
13234
13298
  this.pendingToolInputs.set(requestId, {
13235
13299
  requestId,
13236
13300
  toolUseId,
13237
13301
  toolName,
13238
13302
  input,
13239
13303
  handler,
13240
- resolve: resolve7
13304
+ resolve: resolve8
13241
13305
  });
13242
13306
  const onAbort = () => {
13243
13307
  const pending = this.pendingToolInputs.get(requestId);
@@ -13388,7 +13452,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13388
13452
  error
13389
13453
  );
13390
13454
  await this.tearDownSession();
13391
- await new Promise((resolve7) => setTimeout(resolve7, delayMs));
13455
+ await new Promise((resolve8) => setTimeout(resolve8, delayMs));
13392
13456
  currentRequest = { ...request, message: CLAUDE_MIDTURN_CONTINUE_PROMPT, images: [] };
13393
13457
  attempt++;
13394
13458
  continue;
@@ -13401,7 +13465,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13401
13465
  error
13402
13466
  );
13403
13467
  await this.tearDownSession();
13404
- await new Promise((resolve7) => setTimeout(resolve7, delayMs));
13468
+ await new Promise((resolve8) => setTimeout(resolve8, delayMs));
13405
13469
  attempt++;
13406
13470
  continue;
13407
13471
  }
@@ -13562,8 +13626,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13562
13626
  this.pendingInterrupt = false;
13563
13627
  return;
13564
13628
  }
13565
- await new Promise((resolve7, reject) => {
13566
- this.pendingTurn = { resolve: resolve7, reject, sawActivity: false, userMessageUuid };
13629
+ await new Promise((resolve8, reject) => {
13630
+ this.pendingTurn = { resolve: resolve8, reject, sawActivity: false, userMessageUuid };
13567
13631
  promptStream.push(userMessage);
13568
13632
  });
13569
13633
  }
@@ -14248,6 +14312,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14248
14312
  this.supportedSlashCommands = normalizeClaudeSlashCommands(message.commands);
14249
14313
  this.slashCommandsDiscoveredAt = Date.now();
14250
14314
  }
14315
+ if (message.type === "system" && String(message.subtype) === "code_change_published" && "url" in message && typeof message.url === "string") {
14316
+ await pullRequestCheckService.recordPublishedPullRequest(message.url).catch((error) => {
14317
+ console.error("[ClaudeManager] Failed to record published PR:", error);
14318
+ });
14319
+ }
14251
14320
  this.trackNativeCompaction(message);
14252
14321
  if (message.type === "system" && message.subtype === "task_started" && message.ambient) {
14253
14322
  this.ambientTaskIds.add(message.task_id);
@@ -15429,8 +15498,8 @@ ${text.slice(-24e3)}`
15429
15498
  }
15430
15499
  async observeTurn(host, threadId, request, startTurn) {
15431
15500
  let resolveCompleted;
15432
- const completed = new Promise((resolve7) => {
15433
- resolveCompleted = resolve7;
15501
+ const completed = new Promise((resolve8) => {
15502
+ resolveCompleted = resolve8;
15434
15503
  });
15435
15504
  let rejectDisposed = () => {
15436
15505
  };
@@ -15527,8 +15596,10 @@ ${text.slice(-24e3)}`
15527
15596
  );
15528
15597
  linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
15529
15598
  const completedItem = notification.params.item;
15530
- if (completedItem.type === "commandExecution" && completedItem.exitCode === 0 && shouldRefreshPullRequests("commandExecution", { command: completedItem.command }) || completedItem.type === "mcpToolCall" && completedItem.status === "completed" && shouldRefreshPullRequests(completedItem.tool, completedItem.arguments) || completedItem.type === "dynamicToolCall" && completedItem.success !== false && shouldRefreshPullRequests(completedItem.tool, completedItem.arguments)) {
15531
- pullRequestCheckService.check().catch(() => {
15599
+ const toolResult = completedItem.type === "commandExecution" ? { toolName: "commandExecution", toolInput: { command: completedItem.command }, output: completedItem.aggregatedOutput, success: completedItem.exitCode === 0 } : completedItem.type === "mcpToolCall" ? { toolName: completedItem.tool, toolInput: completedItem.arguments, output: completedItem.result, success: completedItem.status === "completed" && !completedItem.error } : completedItem.type === "dynamicToolCall" ? { toolName: completedItem.tool, toolInput: completedItem.arguments, output: completedItem.contentItems, success: completedItem.success === true } : null;
15600
+ if (toolResult) {
15601
+ pullRequestCheckService.onToolResult(toolResult).catch((error) => {
15602
+ console.error("[CodexAspManager] Failed to capture published PR:", error);
15532
15603
  });
15533
15604
  }
15534
15605
  },
@@ -16285,8 +16356,8 @@ var CursorManager = class extends CodingAgentManager {
16285
16356
  let agent = null;
16286
16357
  let sawCursorActivity = false;
16287
16358
  let reconnectNoticeTimer = null;
16288
- const aborted = new Promise((resolve7) => {
16289
- this.abortActiveTurn = () => resolve7(TURN_ABORTED);
16359
+ const aborted = new Promise((resolve8) => {
16360
+ this.abortActiveTurn = () => resolve8(TURN_ABORTED);
16290
16361
  });
16291
16362
  const linearSessionId = this.linearSessionId;
16292
16363
  const linearForwarder = new LinearEventForwarder(linearSessionId);
@@ -16672,8 +16743,8 @@ var DeepseekApiClient = class extends AbstractApiClient {
16672
16743
  if (item === null) return;
16673
16744
  if (item) yield item;
16674
16745
  }
16675
- await new Promise((resolve7) => {
16676
- wake = resolve7;
16746
+ await new Promise((resolve8) => {
16747
+ wake = resolve8;
16677
16748
  });
16678
16749
  }
16679
16750
  } finally {
@@ -16832,7 +16903,7 @@ var DeepseekManager = class extends CodingAgentManager {
16832
16903
  stdio: ["ignore", "pipe", "pipe"]
16833
16904
  });
16834
16905
  this.process = child;
16835
- const baseUrl = await new Promise((resolve7, reject) => {
16906
+ const baseUrl = await new Promise((resolve8, reject) => {
16836
16907
  let stdout = "";
16837
16908
  let stderr = "";
16838
16909
  const timeout = setTimeout(() => {
@@ -16844,7 +16915,7 @@ var DeepseekManager = class extends CodingAgentManager {
16844
16915
  const match = stdout.match(/dsh web:\s+(http:\/\/[^\s]+)/);
16845
16916
  if (!match?.[1]) return;
16846
16917
  clearTimeout(timeout);
16847
- resolve7(match[1]);
16918
+ resolve8(match[1]);
16848
16919
  });
16849
16920
  child.stderr?.on("data", (chunk) => {
16850
16921
  stderr = (stderr + chunk.toString()).slice(-8e3);
@@ -17018,8 +17089,8 @@ var DeepseekManager = class extends CodingAgentManager {
17018
17089
  }));
17019
17090
  }
17020
17091
  this.recordUserMessageHistoryEvent(request, this.historyFile);
17021
- this.turnCompletion = new Promise((resolve7) => {
17022
- this.resolveTurnCompletion = resolve7;
17092
+ this.turnCompletion = new Promise((resolve8) => {
17093
+ this.resolveTurnCompletion = resolve8;
17023
17094
  });
17024
17095
  const images = await normalizeImages(request.images ?? []);
17025
17096
  const combinedInstructions = this.activeAgentPreset ? "" : this.buildCombinedInstructions(request.customInstructions);
@@ -17294,8 +17365,8 @@ var AcpManager = class extends CodingAgentManager {
17294
17365
  outputByteLimit,
17295
17366
  truncated: false,
17296
17367
  exitStatus: null,
17297
- exited: new Promise((resolve7) => {
17298
- resolveExit = resolve7;
17368
+ exited: new Promise((resolve8) => {
17369
+ resolveExit = resolve8;
17299
17370
  })
17300
17371
  };
17301
17372
  const append = (chunk) => {
@@ -17411,8 +17482,8 @@ var AcpManager = class extends CodingAgentManager {
17411
17482
  if (!this.interactiveTools) return { outcome: { outcome: "cancelled" } };
17412
17483
  const requestId = randomUUID7();
17413
17484
  const toolCallId = params.toolCall.toolCallId;
17414
- return new Promise((resolve7) => {
17415
- this.pendingPermissions.set(requestId, { toolCallId, options: params.options, resolve: resolve7 });
17485
+ return new Promise((resolve8) => {
17486
+ this.pendingPermissions.set(requestId, { toolCallId, options: params.options, resolve: resolve8 });
17416
17487
  this.recordHistoryEvent("acp-session-update", {
17417
17488
  provider: this.acp.provider,
17418
17489
  update: { ...params.toolCall, sessionUpdate: "tool_call", status: "pending" }
@@ -17565,14 +17636,14 @@ ${request.message}` : request.message
17565
17636
  async function ensureResolvableDnsConfig() {
17566
17637
  const contents = await readFile15("/etc/resolv.conf");
17567
17638
  if (contents.length === 0 || contents.at(-1) === 10) return;
17568
- await new Promise((resolve7, reject) => {
17639
+ await new Promise((resolve8, reject) => {
17569
17640
  const child = spawn5("sudo", ["tee", "-a", "/etc/resolv.conf"], { stdio: ["pipe", "ignore", "pipe"] });
17570
17641
  let stderr = "";
17571
17642
  child.stderr.on("data", (chunk) => {
17572
17643
  stderr += chunk;
17573
17644
  });
17574
17645
  child.on("error", reject);
17575
- child.on("exit", (code) => code === 0 ? resolve7() : reject(new Error(`Failed to normalize /etc/resolv.conf: ${stderr.trim()}`)));
17646
+ child.on("exit", (code) => code === 0 ? resolve8() : reject(new Error(`Failed to normalize /etc/resolv.conf: ${stderr.trim()}`)));
17576
17647
  child.stdin.end("\n");
17577
17648
  });
17578
17649
  }
@@ -17970,8 +18041,8 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
17970
18041
  userMessageRecorded = true;
17971
18042
  }
17972
18043
  if (/^\/compact$/i.test(request.message.trim())) {
17973
- const completed2 = new Promise((resolve7) => {
17974
- this.compactionComplete = { resolve: resolve7 };
18044
+ const completed2 = new Promise((resolve8) => {
18045
+ this.compactionComplete = { resolve: resolve8 };
17975
18046
  });
17976
18047
  const result2 = await this.request("session/compact", {
17977
18048
  commandId: uuidV7(),
@@ -18003,8 +18074,8 @@ ${pending}
18003
18074
 
18004
18075
  ` : ""}${request.planMode ? "Plan the requested work without modifying files or running mutating commands.\n\n" : ""}${request.message}`;
18005
18076
  this.turnError = null;
18006
- const completed = new Promise((resolve7) => {
18007
- this.turnComplete = { resolve: resolve7 };
18077
+ const completed = new Promise((resolve8) => {
18078
+ this.turnComplete = { resolve: resolve8 };
18008
18079
  });
18009
18080
  const result = await this.request("turn/start", {
18010
18081
  commandId: uuidV7(),
@@ -18518,8 +18589,8 @@ var OpencodeManager = class extends CodingAgentManager {
18518
18589
  const previousUpdate = this.clientUpdate;
18519
18590
  let finishUpdate = () => {
18520
18591
  };
18521
- this.clientUpdate = new Promise((resolve7) => {
18522
- finishUpdate = resolve7;
18592
+ this.clientUpdate = new Promise((resolve8) => {
18593
+ finishUpdate = resolve8;
18523
18594
  });
18524
18595
  await previousUpdate;
18525
18596
  try {
@@ -18593,8 +18664,8 @@ var OpencodeManager = class extends CodingAgentManager {
18593
18664
  this.configuredModels = new Set(providerModels);
18594
18665
  const eventController = new AbortController();
18595
18666
  this.eventAbortController = eventController;
18596
- this.eventSubscriptionReady = new Promise((resolve7) => {
18597
- this.resolveEventSubscriptionReady = resolve7;
18667
+ this.eventSubscriptionReady = new Promise((resolve8) => {
18668
+ this.resolveEventSubscriptionReady = resolve8;
18598
18669
  });
18599
18670
  this.subscribeToEvents(client2, eventController).catch((error) => {
18600
18671
  this.resolveEventSubscriptionReady?.();
@@ -18604,7 +18675,7 @@ var OpencodeManager = class extends CodingAgentManager {
18604
18675
  });
18605
18676
  await Promise.race([
18606
18677
  this.eventSubscriptionReady,
18607
- new Promise((resolve7) => setTimeout(resolve7, 2e3))
18678
+ new Promise((resolve8) => setTimeout(resolve8, 2e3))
18608
18679
  ]);
18609
18680
  return client2;
18610
18681
  } finally {
@@ -28218,14 +28289,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
28218
28289
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
28219
28290
  }
28220
28291
  function sleep(ms, signal) {
28221
- return new Promise((resolve7, reject) => {
28292
+ return new Promise((resolve8, reject) => {
28222
28293
  if (signal?.aborted) {
28223
28294
  reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
28224
28295
  return;
28225
28296
  }
28226
28297
  const timer = setTimeout(() => {
28227
28298
  signal?.removeEventListener("abort", onAbort);
28228
- resolve7();
28299
+ resolve8();
28229
28300
  }, ms);
28230
28301
  const onAbort = () => {
28231
28302
  clearTimeout(timer);
@@ -29064,7 +29135,7 @@ var Protocol = class {
29064
29135
  const flowStartedAt = Date.now();
29065
29136
  let onAbort;
29066
29137
  let cleanupMessageId;
29067
- return new Promise((resolve7, reject) => {
29138
+ return new Promise((resolve8, reject) => {
29068
29139
  const earlyReject = (error) => {
29069
29140
  reject(error);
29070
29141
  };
@@ -29132,7 +29203,7 @@ var Protocol = class {
29132
29203
  }
29133
29204
  if (decoded.kind === "invalid") return reject(decoded.error);
29134
29205
  if (decoded.kind === "input_required") {
29135
- if (options?.allowInputRequired === true) return resolve7(manualInputRequiredValue(decoded));
29206
+ if (options?.allowInputRequired === true) return resolve8(manualInputRequiredValue(decoded));
29136
29207
  const flow = {
29137
29208
  codec,
29138
29209
  request,
@@ -29144,11 +29215,11 @@ var Protocol = class {
29144
29215
  params
29145
29216
  }, resultSchema, legOptions)
29146
29217
  };
29147
- return resolve7(this._resolveNonCompleteResult(decoded, flow));
29218
+ return resolve8(this._resolveNonCompleteResult(decoded, flow));
29148
29219
  }
29149
29220
  const result = decoded.result;
29150
29221
  validateStandardSchema(resultSchema, result).then((parseResult) => {
29151
- if (parseResult.success) resolve7(parseResult.data);
29222
+ if (parseResult.success) resolve8(parseResult.data);
29152
29223
  else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
29153
29224
  }, reject);
29154
29225
  });
@@ -32100,7 +32171,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
32100
32171
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
32101
32172
  const schOrFunc = root.refs[ref];
32102
32173
  if (schOrFunc) return schOrFunc;
32103
- let _sch = resolve7.call(this, root, ref);
32174
+ let _sch = resolve8.call(this, root, ref);
32104
32175
  if (_sch === void 0) {
32105
32176
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
32106
32177
  const { schemaId } = this.opts;
@@ -32126,7 +32197,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
32126
32197
  function sameSchemaEnv(s1, s2) {
32127
32198
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
32128
32199
  }
32129
- function resolve7(root, ref) {
32200
+ function resolve8(root, ref) {
32130
32201
  let sch;
32131
32202
  while (typeof (sch = this.refs[ref]) == "string") ref = sch;
32132
32203
  return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
@@ -32576,7 +32647,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32576
32647
  else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
32577
32648
  return uri;
32578
32649
  }
32579
- function resolve7(baseURI, relativeURI, options) {
32650
+ function resolve8(baseURI, relativeURI, options) {
32580
32651
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
32581
32652
  const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
32582
32653
  schemelessOptions.skipEscape = true;
@@ -32750,7 +32821,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32750
32821
  const fastUri = {
32751
32822
  SCHEMES,
32752
32823
  normalize,
32753
- resolve: resolve7,
32824
+ resolve: resolve8,
32754
32825
  resolveComponent,
32755
32826
  equal,
32756
32827
  serialize,
@@ -38563,14 +38634,14 @@ var ProbeWindow = class ProbeWindow2 {
38563
38634
  */
38564
38635
  async exchange(buildRequest, timeoutMs) {
38565
38636
  const id = `server-discover-probe-${++this._probeCounter}`;
38566
- return new Promise((resolve7) => {
38637
+ return new Promise((resolve8) => {
38567
38638
  let settled = false;
38568
38639
  const settle = (reply) => {
38569
38640
  if (settled) return;
38570
38641
  settled = true;
38571
38642
  clearTimeout(timer);
38572
38643
  if (this._pending?.id === id) this._pending = void 0;
38573
- resolve7(reply);
38644
+ resolve8(reply);
38574
38645
  };
38575
38646
  const timer = setTimeout(() => settle({ kind: "timeout" }), timeoutMs);
38576
38647
  this._pending = {
@@ -39776,13 +39847,13 @@ var Client = class extends Protocol {
39776
39847
  let onCallerAbort;
39777
39848
  let resolveOpening;
39778
39849
  let rejectOpening;
39779
- const opening = new Promise((resolve7, reject) => {
39780
- resolveOpening = resolve7;
39850
+ const opening = new Promise((resolve8, reject) => {
39851
+ resolveOpening = resolve8;
39781
39852
  rejectOpening = reject;
39782
39853
  });
39783
39854
  let resolveClosed;
39784
- const closed = new Promise((resolve7) => {
39785
- resolveClosed = resolve7;
39855
+ const closed = new Promise((resolve8) => {
39856
+ resolveClosed = resolve8;
39786
39857
  });
39787
39858
  const settle = (outcome) => {
39788
39859
  if (state === "closed") return;
@@ -40262,7 +40333,7 @@ var SSEClientTransport = class {
40262
40333
  }
40263
40334
  _startOrAuth() {
40264
40335
  const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
40265
- return new Promise((resolve7, reject) => {
40336
+ return new Promise((resolve8, reject) => {
40266
40337
  this._eventSource = new EventSource(this._url.href, {
40267
40338
  ...this._eventSourceInit,
40268
40339
  fetch: async (url3, init) => {
@@ -40294,7 +40365,7 @@ var SSEClientTransport = class {
40294
40365
  response,
40295
40366
  serverUrl: this._url,
40296
40367
  fetchFn: this._fetchWithInit
40297
- }).then(() => this._startOrAuth().then(resolve7, reject), (error$2) => {
40368
+ }).then(() => this._startOrAuth().then(resolve8, reject), (error$2) => {
40298
40369
  markAuthSeamEscape(error$2);
40299
40370
  this.onerror?.(error$2);
40300
40371
  reject(error$2);
@@ -40323,7 +40394,7 @@ var SSEClientTransport = class {
40323
40394
  this.close();
40324
40395
  return;
40325
40396
  }
40326
- resolve7();
40397
+ resolve8();
40327
40398
  });
40328
40399
  this._eventSource.onmessage = (event) => {
40329
40400
  const messageEvent = event;
@@ -40999,7 +41070,7 @@ var StreamableHTTPClientTransport = class {
40999
41070
  };
41000
41071
 
41001
41072
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/server-manager.ts
41002
- import { mkdirSync as mkdirSync2, statSync as statSync2 } from "fs";
41073
+ import { mkdirSync as mkdirSync2, statSync as statSync3 } from "fs";
41003
41074
  import { isDeepStrictEqual } from "util";
41004
41075
 
41005
41076
  // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/stdio.mjs
@@ -41055,7 +41126,7 @@ var StdioClientTransport = class {
41055
41126
  */
41056
41127
  async start() {
41057
41128
  if (this._process) throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
41058
- return new Promise((resolve7, reject) => {
41129
+ return new Promise((resolve8, reject) => {
41059
41130
  this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
41060
41131
  env: {
41061
41132
  ...getDefaultEnvironment(),
@@ -41075,7 +41146,7 @@ var StdioClientTransport = class {
41075
41146
  this.onerror?.(error);
41076
41147
  });
41077
41148
  this._process.on("spawn", () => {
41078
- resolve7();
41149
+ resolve8();
41079
41150
  });
41080
41151
  this._process.on("close", (_code) => {
41081
41152
  this._process = void 0;
@@ -41140,7 +41211,7 @@ var StdioClientTransport = class {
41140
41211
  const proc = this._process;
41141
41212
  this._process = void 0;
41142
41213
  if (proc && proc.exitCode === null && proc.signalCode === null) {
41143
- const exited = new Promise((resolve7) => proc.once("exit", () => resolve7()));
41214
+ const exited = new Promise((resolve8) => proc.once("exit", () => resolve8()));
41144
41215
  try {
41145
41216
  proc.stdin?.end();
41146
41217
  } catch {
@@ -41149,7 +41220,7 @@ var StdioClientTransport = class {
41149
41220
  proc.kill("SIGTERM");
41150
41221
  } catch {
41151
41222
  }
41152
- await Promise.race([exited, new Promise((resolve7) => setTimeout(resolve7, 1e3).unref())]);
41223
+ await Promise.race([exited, new Promise((resolve8) => setTimeout(resolve8, 1e3).unref())]);
41153
41224
  if (proc.exitCode === null && proc.signalCode === null) try {
41154
41225
  proc.kill("SIGKILL");
41155
41226
  } catch {
@@ -41174,22 +41245,22 @@ var StdioClientTransport = class {
41174
41245
  if (this._process) {
41175
41246
  const processToClose = this._process;
41176
41247
  this._process = void 0;
41177
- const closePromise = new Promise((resolve7) => {
41248
+ const closePromise = new Promise((resolve8) => {
41178
41249
  processToClose.once("close", () => {
41179
- resolve7();
41250
+ resolve8();
41180
41251
  });
41181
41252
  });
41182
41253
  try {
41183
41254
  processToClose.stdin?.end();
41184
41255
  } catch {
41185
41256
  }
41186
- await Promise.race([closePromise, new Promise((resolve7) => setTimeout(resolve7, 2e3).unref())]);
41257
+ await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
41187
41258
  if (processToClose.exitCode === null) {
41188
41259
  try {
41189
41260
  processToClose.kill("SIGTERM");
41190
41261
  } catch {
41191
41262
  }
41192
- await Promise.race([closePromise, new Promise((resolve7) => setTimeout(resolve7, 2e3).unref())]);
41263
+ await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
41193
41264
  }
41194
41265
  if (processToClose.exitCode === null) try {
41195
41266
  processToClose.kill("SIGKILL");
@@ -41199,11 +41270,11 @@ var StdioClientTransport = class {
41199
41270
  this._readBuffer.clear();
41200
41271
  }
41201
41272
  send(message) {
41202
- return new Promise((resolve7) => {
41273
+ return new Promise((resolve8) => {
41203
41274
  if (!this._process?.stdin) throw new SdkError(SdkErrorCode.NotConnected, "Not connected");
41204
41275
  const json = serializeMessage(message);
41205
- if (this._process.stdin.write(json)) resolve7();
41206
- else this._process.stdin.once("drain", resolve7);
41276
+ if (this._process.stdin.write(json)) resolve8();
41277
+ else this._process.stdin.once("drain", resolve8);
41207
41278
  });
41208
41279
  }
41209
41280
  };
@@ -41224,13 +41295,13 @@ var UnixSocketClientTransport = class {
41224
41295
  if (this.socket) {
41225
41296
  throw new Error("UnixSocketClientTransport already started");
41226
41297
  }
41227
- await new Promise((resolve7, reject) => {
41298
+ await new Promise((resolve8, reject) => {
41228
41299
  const socket = createConnection(this.socketPath);
41229
41300
  this.socket = socket;
41230
41301
  let connected = false;
41231
41302
  socket.once("connect", () => {
41232
41303
  connected = true;
41233
- resolve7();
41304
+ resolve8();
41234
41305
  });
41235
41306
  socket.on("data", (chunk) => {
41236
41307
  try {
@@ -41262,12 +41333,12 @@ var UnixSocketClientTransport = class {
41262
41333
  this.socket = void 0;
41263
41334
  this.readBuffer.clear();
41264
41335
  if (!socket || socket.destroyed) return;
41265
- await new Promise((resolve7) => {
41336
+ await new Promise((resolve8) => {
41266
41337
  const timeout = setTimeout(() => socket.destroy(), 2e3);
41267
41338
  timeout.unref();
41268
41339
  socket.once("close", () => {
41269
41340
  clearTimeout(timeout);
41270
- resolve7();
41341
+ resolve8();
41271
41342
  });
41272
41343
  socket.end();
41273
41344
  });
@@ -41275,10 +41346,10 @@ var UnixSocketClientTransport = class {
41275
41346
  async send(message) {
41276
41347
  const socket = this.socket;
41277
41348
  if (!socket || socket.destroyed) throw new Error("Unix socket is not connected");
41278
- await new Promise((resolve7, reject) => {
41349
+ await new Promise((resolve8, reject) => {
41279
41350
  socket.write(serializeMessage(message), (error) => {
41280
41351
  if (error) reject(error);
41281
- else resolve7();
41352
+ else resolve8();
41282
41353
  });
41283
41354
  });
41284
41355
  }
@@ -41432,8 +41503,8 @@ async function probeMcpEndpoint(url3) {
41432
41503
  }
41433
41504
 
41434
41505
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
41435
- import { existsSync as existsSync11, readFileSync as readFileSync4, realpathSync, readdirSync, statSync, writeFileSync, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
41436
- import { join as join24, dirname as dirname11, extname as extname2, resolve as resolve2, sep } from "path";
41506
+ import { existsSync as existsSync11, readFileSync as readFileSync4, realpathSync, readdirSync as readdirSync2, statSync as statSync2, writeFileSync, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
41507
+ import { join as join24, dirname as dirname11, extname as extname2, resolve as resolve3, sep } from "path";
41437
41508
 
41438
41509
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
41439
41510
  function throwIfAborted(signal) {
@@ -41443,7 +41514,7 @@ function throwIfAborted(signal) {
41443
41514
  async function abortable(promise, signal) {
41444
41515
  if (!signal) return promise;
41445
41516
  throwIfAborted(signal);
41446
- return await new Promise((resolve7, reject) => {
41517
+ return await new Promise((resolve8, reject) => {
41447
41518
  let settled = false;
41448
41519
  const cleanup = () => signal.removeEventListener("abort", onAbort);
41449
41520
  const onAbort = () => {
@@ -41458,7 +41529,7 @@ async function abortable(promise, signal) {
41458
41529
  if (settled) return;
41459
41530
  settled = true;
41460
41531
  cleanup();
41461
- resolve7(value);
41532
+ resolve8(value);
41462
41533
  },
41463
41534
  (error) => {
41464
41535
  if (settled) return;
@@ -41627,7 +41698,7 @@ function resolveFromNpmCache(packageSpec, binName) {
41627
41698
  const binLink = chosenBinName ? join24(nodeModulesDir, ".bin", chosenBinName) : null;
41628
41699
  let resolvedBin = binLink && existsSync11(binLink) ? safeRealpath(binLink) : "";
41629
41700
  if (!resolvedBin) {
41630
- resolvedBin = resolve2(packageDir, binRel);
41701
+ resolvedBin = resolve3(packageDir, binRel);
41631
41702
  if (!existsSync11(resolvedBin)) return null;
41632
41703
  }
41633
41704
  const isJs = detectJsBinary(resolvedBin);
@@ -41642,7 +41713,7 @@ var FORCE_CACHE_TIMEOUT_MS = 3e4;
41642
41713
  async function forceNpxCache(packageSpec, signal) {
41643
41714
  throwIfAborted(signal);
41644
41715
  try {
41645
- await new Promise((resolve7, reject) => {
41716
+ await new Promise((resolve8, reject) => {
41646
41717
  const proc = (0, import_cross_spawn2.default)(
41647
41718
  "npm",
41648
41719
  ["exec", "--yes", "--package", packageSpec, "--", "node", "-e", "1"],
@@ -41661,7 +41732,7 @@ async function forceNpxCache(packageSpec, signal) {
41661
41732
  proc.on("close", () => {
41662
41733
  clearTimeout(timer);
41663
41734
  signal?.removeEventListener("abort", abort);
41664
- resolve7();
41735
+ resolve8();
41665
41736
  });
41666
41737
  proc.on("error", (err) => {
41667
41738
  clearTimeout(timer);
@@ -41729,7 +41800,7 @@ function findCachedPackageDir(cacheDir, packageName, exactVersion) {
41729
41800
  const npxDir = join24(cacheDir, "_npx");
41730
41801
  if (!existsSync11(npxDir)) return null;
41731
41802
  const packagePathParts = packageName.startsWith("@") ? packageName.split("/") : [packageName];
41732
- const candidates = readdirSync(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
41803
+ const candidates = readdirSync2(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
41733
41804
  const full = join24(npxDir, entry.name);
41734
41805
  const mtime = safeStatMtime(full);
41735
41806
  return { name: entry.name, mtime };
@@ -41883,7 +41954,7 @@ function safeRealpath(path8) {
41883
41954
  }
41884
41955
  function safeStatMtime(path8) {
41885
41956
  try {
41886
- return statSync(path8).mtimeMs;
41957
+ return statSync2(path8).mtimeMs;
41887
41958
  } catch {
41888
41959
  return 0;
41889
41960
  }
@@ -43574,14 +43645,14 @@ var baseOpen = async (options) => {
43574
43645
  }
43575
43646
  const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
43576
43647
  if (options.wait) {
43577
- return new Promise((resolve7, reject) => {
43648
+ return new Promise((resolve8, reject) => {
43578
43649
  subprocess.once("error", reject);
43579
43650
  subprocess.once("close", (exitCode) => {
43580
43651
  if (!options.allowNonzeroExitCode && exitCode > 0) {
43581
43652
  reject(new Error(`Exited with code ${exitCode}`));
43582
43653
  return;
43583
43654
  }
43584
- resolve7(subprocess);
43655
+ resolve8(subprocess);
43585
43656
  });
43586
43657
  });
43587
43658
  }
@@ -43909,12 +43980,12 @@ async function ensureCallbackServerLocked(options = {}) {
43909
43980
  const candidateServer = createServer(handleRequest);
43910
43981
  const listenPort = strictPort ? requiredPort : 0;
43911
43982
  try {
43912
- await new Promise((resolve7, reject) => {
43983
+ await new Promise((resolve8, reject) => {
43913
43984
  candidateServer.once("error", (err) => {
43914
43985
  reject(err);
43915
43986
  });
43916
43987
  candidateServer.listen(listenPort, requestedHost, () => {
43917
- resolve7();
43988
+ resolve8();
43918
43989
  });
43919
43990
  });
43920
43991
  if (strictPort) {
@@ -43927,8 +43998,8 @@ async function ensureCallbackServerLocked(options = {}) {
43927
43998
  setOAuthCallbackPort(address.port);
43928
43999
  }
43929
44000
  if (previousServer && (needsStrictRebind || needsHostSwitch)) {
43930
- await new Promise((resolve7) => {
43931
- previousServer.close(() => resolve7());
44001
+ await new Promise((resolve8) => {
44002
+ previousServer.close(() => resolve8());
43932
44003
  });
43933
44004
  }
43934
44005
  callbackServerHost = requestedHost;
@@ -43944,8 +44015,8 @@ async function ensureCallbackServerLocked(options = {}) {
43944
44015
  reservedAuthStates.delete(reservedState);
43945
44016
  }
43946
44017
  const nodeError = error;
43947
- await new Promise((resolve7) => {
43948
- candidateServer.close(() => resolve7());
44018
+ await new Promise((resolve8) => {
44019
+ candidateServer.close(() => resolve8());
43949
44020
  });
43950
44021
  if (strictPort && nodeError.code === "EADDRINUSE") {
43951
44022
  throw new Error(
@@ -43961,14 +44032,14 @@ function releaseCallbackServer(oauthState) {
43961
44032
  }
43962
44033
  function waitForCallback(oauthState) {
43963
44034
  reservedAuthStates.delete(oauthState);
43964
- return new Promise((resolve7, reject) => {
44035
+ return new Promise((resolve8, reject) => {
43965
44036
  const timeout = setTimeout(() => {
43966
44037
  if (pendingAuths.has(oauthState)) {
43967
44038
  pendingAuths.delete(oauthState);
43968
44039
  reject(new Error("OAuth callback timeout - authorization took too long"));
43969
44040
  }
43970
44041
  }, CALLBACK_TIMEOUT_MS);
43971
- pendingAuths.set(oauthState, { resolve: resolve7, reject, timeout });
44042
+ pendingAuths.set(oauthState, { resolve: resolve8, reject, timeout });
43972
44043
  });
43973
44044
  }
43974
44045
  function cancelPendingCallback(oauthState) {
@@ -43993,9 +44064,9 @@ function stopCallbackServer() {
43993
44064
  });
43994
44065
  }
43995
44066
  if (server) {
43996
- await new Promise((resolve7) => {
44067
+ await new Promise((resolve8) => {
43997
44068
  server.close(() => {
43998
- resolve7();
44069
+ resolve8();
43999
44070
  });
44000
44071
  });
44001
44072
  server = void 0;
@@ -45537,7 +45608,7 @@ function humanizeName(name) {
45537
45608
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-trace.ts
45538
45609
  import { appendFile as appendFile3, mkdir as mkdir18, writeFile as writeFile10 } from "fs/promises";
45539
45610
  import { Buffer as Buffer3 } from "buffer";
45540
- import { dirname as dirname14, isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
45611
+ import { dirname as dirname14, isAbsolute as isAbsolute2, resolve as resolve4 } from "path";
45541
45612
  var MCP_TRACE_SCHEMA_VERSION = 1;
45542
45613
  var DEFAULT_MCP_TRACE_MAX_BYTES = 256 * 1024;
45543
45614
  var DEFAULT_MCP_TRACE_MAX_EVENTS = 1e4;
@@ -45669,7 +45740,7 @@ var McpTraceWriter = class {
45669
45740
  function createMcpTraceWriter(sessionCwd, settings2 = {}, randomSuffix = Math.random().toString(36).slice(2, 10)) {
45670
45741
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
45671
45742
  const configuredPath = settings2.file;
45672
- const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath : resolve3(sessionCwd ?? process.cwd(), configuredPath) : resolve3(sessionCwd ?? process.cwd(), ".pi", "mcp-traces", `mcp-${timestamp}-${randomSuffix}.jsonl`);
45743
+ const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath : resolve4(sessionCwd ?? process.cwd(), configuredPath) : resolve4(sessionCwd ?? process.cwd(), ".pi", "mcp-traces", `mcp-${timestamp}-${randomSuffix}.jsonl`);
45673
45744
  return new McpTraceWriter({
45674
45745
  filePath,
45675
45746
  ...settings2.maxBytes !== void 0 ? { maxBytes: settings2.maxBytes } : {},
@@ -45884,7 +45955,7 @@ function resolvedCommand(config) {
45884
45955
  async function invokeRequestHeadersCommand(config, envelope, signal) {
45885
45956
  const resolved = resolvedCommand(config);
45886
45957
  if (USE_PROCESS_GROUP) assertPosixProcessDiscoveryAvailable();
45887
- return new Promise((resolve7, reject) => {
45958
+ return new Promise((resolve8, reject) => {
45888
45959
  let stdout = Buffer.alloc(0);
45889
45960
  let settled = false;
45890
45961
  const cleanupToken = randomUUID8();
@@ -45913,7 +45984,7 @@ async function invokeRequestHeadersCommand(config, envelope, signal) {
45913
45984
  if (descendantTracker) clearInterval(descendantTracker);
45914
45985
  signal.removeEventListener("abort", abort);
45915
45986
  if (result.status === "error") reject(result.error);
45916
- else resolve7(result.headers);
45987
+ else resolve8(result.headers);
45917
45988
  };
45918
45989
  const finishAfterKill = (result) => {
45919
45990
  try {
@@ -46535,7 +46606,7 @@ var McpServerManager = class {
46535
46606
  let args = (definition.args ?? []).map((argument) => interpolateEnvVars(argument));
46536
46607
  const cwd = resolveConfigPath(definition.cwd) ?? this.defaultCwd;
46537
46608
  if (cwd !== void 0) {
46538
- const cwdStats = statSync2(cwd, { throwIfNoEntry: false });
46609
+ const cwdStats = statSync3(cwd, { throwIfNoEntry: false });
46539
46610
  if (!cwdStats) throw new Error(`MCP server "${name}" configured cwd does not exist: "${cwd}"`);
46540
46611
  if (!cwdStats.isDirectory()) throw new Error(`MCP server "${name}" configured cwd is not a directory: "${cwd}"`);
46541
46612
  }
@@ -49205,12 +49276,12 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
49205
49276
  markSetupCompleted(discovery.fingerprint);
49206
49277
  }
49207
49278
  };
49208
- return new Promise((resolve7) => {
49279
+ return new Promise((resolve8) => {
49209
49280
  ctx.ui.custom(
49210
49281
  (tui, _theme, keybindings, done) => {
49211
49282
  return createMcpSetupPanel(discovery, callbacks, { mode, onboardingState, keybindings }, tui, () => {
49212
49283
  done(void 0);
49213
- resolve7({ configChanged });
49284
+ resolve8({ configChanged });
49214
49285
  });
49215
49286
  },
49216
49287
  { overlay: true, overlayOptions: { anchor: "center", width: 92 } }
@@ -49292,7 +49363,7 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
49292
49363
  const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
49293
49364
  const { createMcpPanel } = await import("./mcp-panel-IBIVWX27.js");
49294
49365
  let configChanged = false;
49295
- await new Promise((resolve7) => {
49366
+ await new Promise((resolve8) => {
49296
49367
  ctx.ui.custom(
49297
49368
  (tui, _theme, keybindings, done) => {
49298
49369
  return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, (result) => {
@@ -49315,13 +49386,13 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
49315
49386
  ctx.ui.notify("Direct tools updated for this session.", "info");
49316
49387
  }
49317
49388
  done(void 0);
49318
- resolve7();
49389
+ resolve8();
49319
49390
  })().catch((error) => {
49320
49391
  const message = error instanceof Error ? error.message : String(error);
49321
49392
  ctx.ui.notify(`Direct tools updated, but live refresh failed: ${message}`, "error");
49322
49393
  configChanged = true;
49323
49394
  done(void 0);
49324
- resolve7();
49395
+ resolve8();
49325
49396
  });
49326
49397
  }, { noticeLines, keybindings });
49327
49398
  },
@@ -49363,12 +49434,12 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
49363
49434
  let overlayHandle;
49364
49435
  const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
49365
49436
  const { createMcpPanel } = await import("./mcp-panel-IBIVWX27.js");
49366
- await new Promise((resolve7) => {
49437
+ await new Promise((resolve8) => {
49367
49438
  ctx.ui.custom(
49368
49439
  (tui, _theme, keybindings, done) => {
49369
49440
  return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, () => {
49370
49441
  done(void 0);
49371
- resolve7();
49442
+ resolve8();
49372
49443
  }, {
49373
49444
  authOnly: true,
49374
49445
  keybindings,
@@ -51315,7 +51386,7 @@ data: ${JSON.stringify(payload)}
51315
51386
  markCompleted("stale");
51316
51387
  }, WATCHDOG_INTERVAL_MS);
51317
51388
  watchdog.unref();
51318
- return new Promise((resolve7, reject) => {
51389
+ return new Promise((resolve8, reject) => {
51319
51390
  const candidates = resolvePortCandidates(options.port);
51320
51391
  let candidateIndex = 0;
51321
51392
  const startSandboxProxy = (parentOrigin) => {
@@ -51452,7 +51523,7 @@ data: ${JSON.stringify(payload)}
51452
51523
  getSessionMessages: () => ({ ...sessionMessages }),
51453
51524
  getStreamSummary: () => streamSummary ? { ...streamSummary, phases: [...streamSummary.phases] } : void 0
51454
51525
  };
51455
- resolve7(handle);
51526
+ resolve8(handle);
51456
51527
  }).catch((error) => {
51457
51528
  log.error("Failed to start sandbox proxy", error instanceof Error ? error : void 0);
51458
51529
  closeListeners();
@@ -51477,7 +51548,7 @@ async function parseBody(req, res) {
51477
51548
  }
51478
51549
  }
51479
51550
  function readBody(req) {
51480
- return new Promise((resolve7, reject) => {
51551
+ return new Promise((resolve8, reject) => {
51481
51552
  let size = 0;
51482
51553
  const chunks = [];
51483
51554
  req.on("data", (chunk) => {
@@ -51491,7 +51562,7 @@ function readBody(req) {
51491
51562
  });
51492
51563
  req.on("end", () => {
51493
51564
  try {
51494
- resolve7(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
51565
+ resolve8(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
51495
51566
  } catch (error) {
51496
51567
  reject(error);
51497
51568
  }
@@ -51672,22 +51743,22 @@ function isRemoteSession() {
51672
51743
  return Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
51673
51744
  }
51674
51745
  function hasActiveRemoteLogin() {
51675
- return new Promise((resolve7) => {
51746
+ return new Promise((resolve8) => {
51676
51747
  execFile6("who", { encoding: "utf8", timeout: 2e3 }, (error, out) => {
51677
51748
  if (error) {
51678
- resolve7(false);
51749
+ resolve8(false);
51679
51750
  return;
51680
51751
  }
51681
- resolve7(/\(.+\)\s*$/m.test(out));
51752
+ resolve8(/\(.+\)\s*$/m.test(out));
51682
51753
  });
51683
51754
  });
51684
51755
  }
51685
51756
  function probeMoshiGateway() {
51686
- return new Promise((resolve7) => {
51757
+ return new Promise((resolve8) => {
51687
51758
  const socket = net.connect({ host: "127.0.0.1", port: 24543 });
51688
51759
  const done = (ok) => {
51689
51760
  socket.destroy();
51690
- resolve7(ok);
51761
+ resolve8(ok);
51691
51762
  };
51692
51763
  socket.setTimeout(300);
51693
51764
  socket.once("connect", () => done(true));
@@ -58107,7 +58178,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
58107
58178
  trackUnmanagedFds: false
58108
58179
  });
58109
58180
  const activeWorker = worker;
58110
- const execution = new Promise((resolve7, reject) => {
58181
+ const execution = new Promise((resolve8, reject) => {
58111
58182
  let completed = false;
58112
58183
  activeWorker.on("message", (value) => {
58113
58184
  const message = parseWorkerMessage(value);
@@ -58119,7 +58190,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
58119
58190
  if (message.type === "done") {
58120
58191
  completed = true;
58121
58192
  if ("returnBlock" in message) output.push(toContentBlock(message.returnBlock));
58122
- resolve7();
58193
+ resolve8();
58123
58194
  return;
58124
58195
  }
58125
58196
  if (message.type === "error") {
@@ -58398,8 +58469,8 @@ async function awaitWithTimeout(promise, timeoutMs) {
58398
58469
  try {
58399
58470
  return await Promise.race([
58400
58471
  promise,
58401
- new Promise((resolve7) => {
58402
- timer = setTimeout(() => resolve7(INIT_WAIT_TIMED_OUT), timeoutMs);
58472
+ new Promise((resolve8) => {
58473
+ timer = setTimeout(() => resolve8(INIT_WAIT_TIMED_OUT), timeoutMs);
58403
58474
  timer.unref?.();
58404
58475
  })
58405
58476
  ]);
@@ -59777,7 +59848,7 @@ import {
59777
59848
  rename as rename4,
59778
59849
  unlink as unlink3
59779
59850
  } from "fs/promises";
59780
- import { existsSync as existsSync16, readFileSync as readFileSync7, readdirSync as readdirSync2 } from "fs";
59851
+ import { existsSync as existsSync16, readFileSync as readFileSync7, readdirSync as readdirSync3 } from "fs";
59781
59852
  import { join as join31 } from "path";
59782
59853
  var MAX_FAILED_RECORDS = 500;
59783
59854
  var FLUSH_DEBOUNCE_MS = 15e3;
@@ -59826,7 +59897,7 @@ var AnalyticsRecordBuffer = class {
59826
59897
  }
59827
59898
  readStoredRecords() {
59828
59899
  if (!existsSync16(ENGINE_DIR2)) return [];
59829
- return readdirSync2(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
59900
+ return readdirSync3(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
59830
59901
  (storageName) => entry.name === `${storageName}.jsonl` || entry.name.startsWith(`${storageName}.`) && (entry.name.endsWith(".jsonl") || entry.name.endsWith(`.jsonl${UPLOADED_SUFFIX}`))
59831
59902
  )).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync7(join31(ENGINE_DIR2, name), "utf-8"))).map((record3) => {
59832
59903
  const recordId = this.options.getRecordId?.(record3);
@@ -60758,11 +60829,11 @@ import { join as join32 } from "path";
60758
60829
 
60759
60830
  // src/utils/contained-file.ts
60760
60831
  import { realpath, stat as stat3 } from "fs/promises";
60761
- import { resolve as resolve4 } from "path";
60832
+ import { resolve as resolve5 } from "path";
60762
60833
  async function resolveContainedFile(root, relativePath) {
60763
60834
  try {
60764
60835
  const [fullPath, resolvedRoot] = await Promise.all([
60765
- realpath(resolve4(root, relativePath)),
60836
+ realpath(resolve5(root, relativePath)),
60766
60837
  realpath(root)
60767
60838
  ]);
60768
60839
  const fileStat = await stat3(fullPath);
@@ -60931,7 +61002,7 @@ function isReconcileCanvasItemsResponse(value) {
60931
61002
  }
60932
61003
  async function withCanvasUploadSlot(operation) {
60933
61004
  if (activeCanvasUploads >= MAX_CONCURRENT_CANVAS_UPLOADS) {
60934
- await new Promise((resolve7) => pendingCanvasUploads.push(resolve7));
61005
+ await new Promise((resolve8) => pendingCanvasUploads.push(resolve8));
60935
61006
  } else {
60936
61007
  activeCanvasUploads++;
60937
61008
  }
@@ -61257,13 +61328,13 @@ function runBeforeDeadline(operation, deadline) {
61257
61328
  const timeoutMs = deadline - Date.now();
61258
61329
  if (timeoutMs <= 0) return Promise.reject(new DOMException("engine log flush deadline exceeded", "TimeoutError"));
61259
61330
  const signal = AbortSignal.timeout(timeoutMs);
61260
- return new Promise((resolve7, reject) => {
61331
+ return new Promise((resolve8, reject) => {
61261
61332
  const onAbort = () => reject(signal.reason);
61262
61333
  signal.addEventListener("abort", onAbort, { once: true });
61263
61334
  operation(signal).then(
61264
61335
  (value) => {
61265
61336
  signal.removeEventListener("abort", onAbort);
61266
- resolve7(value);
61337
+ resolve8(value);
61267
61338
  },
61268
61339
  (error) => {
61269
61340
  signal.removeEventListener("abort", onAbort);
@@ -61674,8 +61745,8 @@ var ChatService = class {
61674
61745
  if (result.status === "completed") return result;
61675
61746
  const remainingMs = timeoutMs === null ? null : timeoutMs - (Date.now() - startedAt);
61676
61747
  if (remainingMs !== null && remainingMs <= 0) return { ...result, timedOut: true };
61677
- await new Promise((resolve7) => setTimeout(
61678
- resolve7,
61748
+ await new Promise((resolve8) => setTimeout(
61749
+ resolve8,
61679
61750
  remainingMs === null ? RELAY_SUBAGENT_POLL_INTERVAL_MS : Math.min(RELAY_SUBAGENT_POLL_INTERVAL_MS, remainingMs)
61680
61751
  ));
61681
61752
  }
@@ -62729,13 +62800,13 @@ var ChatService = class {
62729
62800
  async observeCurrentBranches(chat) {
62730
62801
  try {
62731
62802
  const snapshot = await gitService.snapshotCurrentBranches();
62732
- for (const [repoName, branch] of snapshot) {
62803
+ for (const [repoName, branches] of snapshot) {
62733
62804
  let observed = chat.observedBranchesByRepo.get(repoName);
62734
62805
  if (!observed) {
62735
62806
  observed = /* @__PURE__ */ new Set();
62736
62807
  chat.observedBranchesByRepo.set(repoName, observed);
62737
62808
  }
62738
- observed.add(branch);
62809
+ for (const branch of branches) observed.add(branch);
62739
62810
  }
62740
62811
  } catch {
62741
62812
  }
@@ -62980,7 +63051,7 @@ function isBinaryExtension(filePath) {
62980
63051
  return classifyCanvasFilename(filePath).kind === "image" || binaryExts.has(ext);
62981
63052
  }
62982
63053
  function execGitAsync(args, cwd, timeoutMs) {
62983
- return new Promise((resolve7, reject) => {
63054
+ return new Promise((resolve8, reject) => {
62984
63055
  const child = execFile7("git", args, {
62985
63056
  cwd,
62986
63057
  encoding: "utf-8",
@@ -62990,7 +63061,7 @@ function execGitAsync(args, cwd, timeoutMs) {
62990
63061
  if (error) {
62991
63062
  reject(error);
62992
63063
  } else {
62993
- resolve7(stdout);
63064
+ resolve8(stdout);
62994
63065
  }
62995
63066
  });
62996
63067
  child.stdin?.end();
@@ -63246,7 +63317,7 @@ var RepoFileService = class {
63246
63317
  import { Hono } from "hono";
63247
63318
  import { z as z6 } from "zod";
63248
63319
  import { readdir as readdir12, stat as stat7, readFile as readFile26 } from "fs/promises";
63249
- import { join as join41, resolve as resolve5 } from "path";
63320
+ import { join as join41, resolve as resolve6 } from "path";
63250
63321
 
63251
63322
  // src/services/warm-hooks-service.ts
63252
63323
  import { spawn as spawn10 } from "child_process";
@@ -63423,7 +63494,7 @@ async function executeHookScriptStreaming(params) {
63423
63494
  let bufferExceeded = false;
63424
63495
  params.onChunk(`$ ${params.label}
63425
63496
  `);
63426
- return new Promise((resolve7) => {
63497
+ return new Promise((resolve8) => {
63427
63498
  const proc = spawn10("bash", ["-lc", params.content], {
63428
63499
  cwd: params.cwd,
63429
63500
  env: process.env,
@@ -63456,7 +63527,7 @@ async function executeHookScriptStreaming(params) {
63456
63527
  proc.on("close", (code) => {
63457
63528
  clearTimeout(timer);
63458
63529
  const output = [`$ ${params.label}`, ...outputParts].join("");
63459
- resolve7({
63530
+ resolve8({
63460
63531
  exitCode: bufferExceeded ? 1 : code ?? 1,
63461
63532
  output,
63462
63533
  timedOut: killed && !bufferExceeded
@@ -63466,7 +63537,7 @@ async function executeHookScriptStreaming(params) {
63466
63537
  clearTimeout(timer);
63467
63538
  const output = [`$ ${params.label}
63468
63539
  `, ...outputParts, err.message].join("");
63469
- resolve7({
63540
+ resolve8({
63470
63541
  exitCode: 1,
63471
63542
  output,
63472
63543
  timedOut: false
@@ -63826,8 +63897,19 @@ function createJsonEventStream(run, onError) {
63826
63897
  function createV1Routes(deps) {
63827
63898
  const app2 = new Hono();
63828
63899
  app2.post("/pull-requests/check", async (c) => {
63829
- pullRequestCheckService.check().catch(() => {
63830
- });
63900
+ if (c.req.header("content-type")?.includes("application/json")) {
63901
+ const result = z6.object({
63902
+ toolName: z6.string(),
63903
+ toolInput: z6.unknown(),
63904
+ output: z6.unknown(),
63905
+ success: z6.boolean()
63906
+ }).safeParse(await c.req.json().catch(() => null));
63907
+ if (!result.success) return c.json({ error: "Invalid PR tool result" }, 400);
63908
+ await pullRequestCheckService.onToolResult(result.data);
63909
+ } else {
63910
+ pullRequestCheckService.check().catch(() => {
63911
+ });
63912
+ }
63831
63913
  return c.json({ accepted: true }, 202);
63832
63914
  });
63833
63915
  const loadChatHistory = async (c, chatId, page2, failureMessage, unexpectedStatus, legacy = false) => {
@@ -64750,8 +64832,8 @@ data: ${JSON.stringify("Terminal session not found")}
64750
64832
  if (!isValidEngineLogSessionId(sessionId)) {
64751
64833
  return c.json(jsonError("Invalid session ID"), 400);
64752
64834
  }
64753
- const filePath = resolve5(LOG_DIR, `${sessionId}.log`);
64754
- if (!filePath.startsWith(resolve5(LOG_DIR))) {
64835
+ const filePath = resolve6(LOG_DIR, `${sessionId}.log`);
64836
+ if (!filePath.startsWith(resolve6(LOG_DIR))) {
64755
64837
  return c.json(jsonError("Invalid session ID"), 400);
64756
64838
  }
64757
64839
  let content;
@@ -64828,12 +64910,12 @@ var heartbeatService = new HeartbeatService();
64828
64910
 
64829
64911
  // src/services/workspace-sdk-service.ts
64830
64912
  import { cp, mkdir as mkdir24 } from "fs/promises";
64831
- import { dirname as dirname20, resolve as resolve6 } from "path";
64913
+ import { dirname as dirname20, resolve as resolve7 } from "path";
64832
64914
  import { fileURLToPath as fileURLToPath7 } from "url";
64833
64915
  async function installWorkspaceSdk() {
64834
- const source = resolve6(dirname20(fileURLToPath7(import.meta.url)), "../../workspace-sdk");
64916
+ const source = resolve7(dirname20(fileURLToPath7(import.meta.url)), "../../workspace-sdk");
64835
64917
  const targets = [
64836
- resolve6(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
64918
+ resolve7(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
64837
64919
  "/tmp/node_modules/@replicas/sdk"
64838
64920
  ];
64839
64921
  await Promise.all(targets.map(async (target) => {
@@ -64848,8 +64930,8 @@ var startupTimings = {};
64848
64930
  var ENGINE_INIT_GATE_TIMEOUT_MS = 35 * 60 * 1e3;
64849
64931
  var resolveEngineReady = () => {
64850
64932
  };
64851
- var engineReadyPromise = new Promise((resolve7) => {
64852
- resolveEngineReady = resolve7;
64933
+ var engineReadyPromise = new Promise((resolve8) => {
64934
+ resolveEngineReady = resolve8;
64853
64935
  });
64854
64936
  async function timeStartupStep(name, fn) {
64855
64937
  const startedAt = performance.now();
@@ -64869,7 +64951,7 @@ async function waitForInitializationGate() {
64869
64951
  if (Date.now() >= deadline) {
64870
64952
  throw new Error("Timed out waiting for deferred engine initialization gate");
64871
64953
  }
64872
- await new Promise((resolve7) => setTimeout(resolve7, 25));
64954
+ await new Promise((resolve8) => setTimeout(resolve8, 25));
64873
64955
  }
64874
64956
  }
64875
64957
  await timeStartupStep("engine_logger_initialize", () => engineLogger.initialize());
@@ -64901,11 +64983,11 @@ async function checkActiveSSHSessions() {
64901
64983
  }
64902
64984
  }
64903
64985
  function checkDesktopReady() {
64904
- return new Promise((resolve7) => {
64986
+ return new Promise((resolve8) => {
64905
64987
  const socket = connect({ host: "127.0.0.1", port: DESKTOP_STREAM_PORT });
64906
64988
  const done = (ready) => {
64907
64989
  socket.destroy();
64908
- resolve7(ready);
64990
+ resolve8(ready);
64909
64991
  };
64910
64992
  socket.once("connect", () => done(true));
64911
64993
  socket.once("error", () => done(false));
@@ -64942,7 +65024,7 @@ app.get("/health", async (c) => {
64942
65024
  if (!engineReady && waitMs > 0) {
64943
65025
  await Promise.race([
64944
65026
  engineReadyPromise,
64945
- new Promise((resolve7) => setTimeout(resolve7, waitMs))
65027
+ new Promise((resolve8) => setTimeout(resolve8, waitMs))
64946
65028
  ]);
64947
65029
  }
64948
65030
  c.header(ENGINE_HEALTH_WAIT_HEADER, "1");