repoburg 1.3.323 → 1.3.325

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.
@@ -43972,6 +43972,165 @@ async function registerProviderRoutes(fastify) {
43972
43972
  var InferenceCredentialsError = class extends Error {
43973
43973
  };
43974
43974
 
43975
+ // src/repoburg/backend-resolver.ts
43976
+ import path4 from "node:path";
43977
+ var RepoburgSignInRequiredError = class extends Error {
43978
+ constructor(projectPath) {
43979
+ super(
43980
+ `This machine is not signed in to Repoburg, so Repoburg cannot start in ${projectPath}. Sign in from the model picker (Repoburg), or run 'repoburg login'.`
43981
+ );
43982
+ this.projectPath = projectPath;
43983
+ this.name = "RepoburgSignInRequiredError";
43984
+ }
43985
+ code = "repoburg_sign_in_required";
43986
+ };
43987
+ var HEALTH_POLL_INTERVAL_MS = 1e3;
43988
+ var HEALTH_TIMEOUT_MS = 3e4;
43989
+ function daemonBaseUrl() {
43990
+ return (process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
43991
+ }
43992
+ var HttpError = class extends Error {
43993
+ constructor(status, body, url2) {
43994
+ super(`${url2} failed: ${status} ${body}`);
43995
+ this.status = status;
43996
+ this.body = body;
43997
+ this.url = url2;
43998
+ }
43999
+ };
44000
+ async function fetchJson(url2, init, timeoutMs = 5e3) {
44001
+ const controller = new AbortController();
44002
+ const timer3 = setTimeout(() => controller.abort(), timeoutMs);
44003
+ let response;
44004
+ try {
44005
+ response = await fetch(url2, { ...init, signal: controller.signal });
44006
+ } finally {
44007
+ clearTimeout(timer3);
44008
+ }
44009
+ const text2 = await response.text();
44010
+ if (!response.ok) {
44011
+ throw new HttpError(response.status, text2, url2);
44012
+ }
44013
+ try {
44014
+ return JSON.parse(text2);
44015
+ } catch {
44016
+ throw new Error(`Unexpected non-JSON response from ${url2}`);
44017
+ }
44018
+ }
44019
+ function daemonErrorMessage(err) {
44020
+ if (err instanceof HttpError) {
44021
+ try {
44022
+ const parsed = JSON.parse(err.body);
44023
+ return parsed.message || parsed.error || err.body;
44024
+ } catch {
44025
+ return err.body;
44026
+ }
44027
+ }
44028
+ return err.message;
44029
+ }
44030
+ var resolvedCache = /* @__PURE__ */ new Map();
44031
+ function invalidateBackend(baseUrl) {
44032
+ for (const [key, value] of resolvedCache) {
44033
+ if (value.baseUrl === baseUrl) resolvedCache.delete(key);
44034
+ }
44035
+ }
44036
+ async function backendHealthy(baseUrl, expectedPath) {
44037
+ try {
44038
+ const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
44039
+ if (health.status !== "ok") return false;
44040
+ if (expectedPath && health.projectPath) {
44041
+ return path4.resolve(health.projectPath) === path4.resolve(expectedPath);
44042
+ }
44043
+ return true;
44044
+ } catch {
44045
+ return false;
44046
+ }
44047
+ }
44048
+ async function waitForHealthy(baseUrl, name, expectedPath) {
44049
+ const deadline = Date.now() + HEALTH_TIMEOUT_MS;
44050
+ while (Date.now() < deadline) {
44051
+ if (await backendHealthy(baseUrl, expectedPath)) return;
44052
+ await new Promise((resolve) => setTimeout(resolve, HEALTH_POLL_INTERVAL_MS));
44053
+ }
44054
+ throw new Error(
44055
+ `Backend '${name}' on ${baseUrl} did not become healthy within ${HEALTH_TIMEOUT_MS / 1e3}s. Check daemon logs: repoburg logs ${name}`
44056
+ );
44057
+ }
44058
+ function serviceBaseUrl(service) {
44059
+ return `http://localhost:${service.port}`;
44060
+ }
44061
+ function coveringService(services, absPath) {
44062
+ return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path4.sep)).sort((a, b) => b.path.length - a.path.length)[0];
44063
+ }
44064
+ async function restartService(daemon, name) {
44065
+ try {
44066
+ await fetchJson(`${daemon}/services/${name}/restart`, { method: "POST" });
44067
+ } catch (err) {
44068
+ throw new Error(`Daemon failed to restart backend '${name}': ${daemonErrorMessage(err)}`);
44069
+ }
44070
+ }
44071
+ async function startService(daemon, projectPath) {
44072
+ try {
44073
+ return await fetchJson(`${daemon}/services/start`, {
44074
+ method: "POST",
44075
+ headers: { "Content-Type": "application/json" },
44076
+ body: JSON.stringify({ path: projectPath })
44077
+ });
44078
+ } catch (err) {
44079
+ if (err instanceof HttpError && err.status === 401) throw new RepoburgSignInRequiredError(projectPath);
44080
+ throw new Error(`Daemon failed to start backend for ${projectPath}: ${daemonErrorMessage(err)}`);
44081
+ }
44082
+ }
44083
+ function cache(absPath, service) {
44084
+ const resolved = {
44085
+ baseUrl: serviceBaseUrl(service),
44086
+ port: service.port,
44087
+ name: service.name,
44088
+ servesPath: service.path
44089
+ };
44090
+ resolvedCache.set(absPath, resolved);
44091
+ return resolved;
44092
+ }
44093
+ async function resolveBackendUrl(projectPath, opts = {}) {
44094
+ const autoStart = opts.autoStart !== false;
44095
+ const envUrl = process.env.REPOBURG_BACKEND_URL;
44096
+ if (envUrl) {
44097
+ return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
44098
+ }
44099
+ const absPath = path4.resolve(projectPath);
44100
+ const daemon = daemonBaseUrl();
44101
+ const cached3 = resolvedCache.get(absPath);
44102
+ if (cached3 && await backendHealthy(cached3.baseUrl, cached3.servesPath ?? absPath)) {
44103
+ return cached3;
44104
+ }
44105
+ try {
44106
+ await fetchJson(`${daemon}/health`, void 0, 3e3);
44107
+ } catch {
44108
+ throw new Error(
44109
+ `Repoburg daemon not reachable at ${daemon}. Start it with 'repoburg-daemon', or set REPOBURG_BACKEND_URL to a running backend.`
44110
+ );
44111
+ }
44112
+ const services = await fetchJson(`${daemon}/services`);
44113
+ const match = coveringService(services, absPath);
44114
+ if (match && match.status === "running") {
44115
+ if (await backendHealthy(serviceBaseUrl(match), match.path)) {
44116
+ return cache(absPath, match);
44117
+ }
44118
+ if (!autoStart) return null;
44119
+ await restartService(daemon, match.name);
44120
+ await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
44121
+ return cache(absPath, match);
44122
+ }
44123
+ if (!autoStart) return null;
44124
+ if (match) {
44125
+ await restartService(daemon, match.name);
44126
+ await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
44127
+ return cache(absPath, match);
44128
+ }
44129
+ const service = await startService(daemon, absPath);
44130
+ await waitForHealthy(serviceBaseUrl(service), service.name, absPath);
44131
+ return cache(absPath, service);
44132
+ }
44133
+
43975
44134
  // src/routes/models.ts
43976
44135
  function inferenceRuntime(id, reply) {
43977
44136
  const provider = hasProvider(id) ? getProvider(id) : void 0;
@@ -43985,6 +44144,9 @@ function sendInferenceError(reply, error51) {
43985
44144
  if (error51 instanceof InferenceCredentialsError) {
43986
44145
  return reply.code(400).send({ error: error51.message });
43987
44146
  }
44147
+ if (error51 instanceof RepoburgSignInRequiredError) {
44148
+ return reply.code(403).send({ error: error51.message, code: error51.code });
44149
+ }
43988
44150
  const message = error51 instanceof Error ? error51.message : String(error51);
43989
44151
  return reply.code(503).send({ error: message });
43990
44152
  }
@@ -44621,23 +44783,23 @@ import http from "node:http";
44621
44783
  import net from "node:net";
44622
44784
  import crypto from "node:crypto";
44623
44785
  import os3 from "node:os";
44624
- import path4 from "node:path";
44786
+ import path5 from "node:path";
44625
44787
  import { mkdir, readdir as readdir2, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
44626
- var VSCODE_WEB_DATA_DIR = path4.join(os3.homedir(), ".repoburg", "vscode-web");
44788
+ var VSCODE_WEB_DATA_DIR = path5.join(os3.homedir(), ".repoburg", "vscode-web");
44627
44789
  function resolveDesktopUserDir() {
44628
44790
  if (process.platform === "darwin") {
44629
- return path4.join(os3.homedir(), "Library", "Application Support", "Code", "User");
44791
+ return path5.join(os3.homedir(), "Library", "Application Support", "Code", "User");
44630
44792
  }
44631
44793
  if (process.platform === "win32" && process.env.APPDATA) {
44632
- return path4.join(process.env.APPDATA, "Code", "User");
44794
+ return path5.join(process.env.APPDATA, "Code", "User");
44633
44795
  }
44634
44796
  if (process.platform === "linux") {
44635
- return path4.join(os3.homedir(), ".config", "Code", "User");
44797
+ return path5.join(os3.homedir(), ".config", "Code", "User");
44636
44798
  }
44637
44799
  return null;
44638
44800
  }
44639
44801
  async function linkUnlessExists(src, dst) {
44640
- await mkdir(path4.dirname(dst), { recursive: true });
44802
+ await mkdir(path5.dirname(dst), { recursive: true });
44641
44803
  try {
44642
44804
  await lstat(dst);
44643
44805
  return false;
@@ -44652,19 +44814,19 @@ function fileRegistryUri(dir) {
44652
44814
  }
44653
44815
  async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
44654
44816
  try {
44655
- const desktopExt = path4.join(os3.homedir(), ".vscode", "extensions");
44817
+ const desktopExt = path5.join(os3.homedir(), ".vscode", "extensions");
44656
44818
  let entries;
44657
44819
  try {
44658
44820
  entries = await readdir2(desktopExt, { withFileTypes: true });
44659
44821
  } catch {
44660
44822
  return;
44661
44823
  }
44662
- const serverExt = path4.join(dataDir, "extensions");
44824
+ const serverExt = path5.join(dataDir, "extensions");
44663
44825
  const linkedFolders = [];
44664
44826
  for (const entry of entries) {
44665
44827
  if (!entry.isDirectory()) continue;
44666
- const target = path4.join(serverExt, entry.name);
44667
- await linkUnlessExists(path4.join(desktopExt, entry.name), target);
44828
+ const target = path5.join(serverExt, entry.name);
44829
+ await linkUnlessExists(path5.join(desktopExt, entry.name), target);
44668
44830
  const st = await lstat(target).catch(() => null);
44669
44831
  if (st?.isSymbolicLink()) linkedFolders.push(entry.name);
44670
44832
  }
@@ -44672,15 +44834,15 @@ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
44672
44834
  await pruneObsolete(serverExt, linkedFolders);
44673
44835
  const desktopUser = resolveDesktopUserDir();
44674
44836
  if (!desktopUser) return;
44675
- const serverUser = path4.join(dataDir, "data", "User");
44837
+ const serverUser = path5.join(dataDir, "data", "User");
44676
44838
  for (const item of ["settings.json", "keybindings.json", "snippets"]) {
44677
- const src = path4.join(desktopUser, item);
44839
+ const src = path5.join(desktopUser, item);
44678
44840
  try {
44679
44841
  await access(src);
44680
44842
  } catch {
44681
44843
  continue;
44682
44844
  }
44683
- await linkUnlessExists(src, path4.join(serverUser, item));
44845
+ await linkUnlessExists(src, path5.join(serverUser, item));
44684
44846
  }
44685
44847
  } catch {
44686
44848
  }
@@ -44688,13 +44850,13 @@ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
44688
44850
  async function mergeExtensionRegistry(desktopExt, serverExt, linkedFolders) {
44689
44851
  let desktopEntries = [];
44690
44852
  try {
44691
- desktopEntries = JSON.parse(await readFile(path4.join(desktopExt, "extensions.json"), "utf8"));
44853
+ desktopEntries = JSON.parse(await readFile(path5.join(desktopExt, "extensions.json"), "utf8"));
44692
44854
  } catch {
44693
44855
  return;
44694
44856
  }
44695
44857
  const linked = new Set(linkedFolders);
44696
44858
  const toAdd = desktopEntries.filter((e) => e.identifier?.id && linked.has(e.relativeLocation));
44697
- const serverRegistryPath = path4.join(serverExt, "extensions.json");
44859
+ const serverRegistryPath = path5.join(serverExt, "extensions.json");
44698
44860
  let serverEntries = [];
44699
44861
  try {
44700
44862
  serverEntries = JSON.parse(await readFile(serverRegistryPath, "utf8"));
@@ -44704,13 +44866,13 @@ async function mergeExtensionRegistry(desktopExt, serverExt, linkedFolders) {
44704
44866
  const additions = toAdd.filter((e) => !known.has(`${e.identifier.id.toLowerCase()}@${e.version}`));
44705
44867
  if (additions.length === 0) return;
44706
44868
  for (const entry of additions) {
44707
- const dir = path4.join(serverExt, entry.relativeLocation);
44869
+ const dir = path5.join(serverExt, entry.relativeLocation);
44708
44870
  serverEntries.push({ ...entry, location: fileRegistryUri(dir) });
44709
44871
  }
44710
44872
  await writeFile(serverRegistryPath, JSON.stringify(serverEntries));
44711
44873
  }
44712
44874
  async function pruneObsolete(serverExt, linkedFolders) {
44713
- const obsoletePath = path4.join(serverExt, ".obsolete");
44875
+ const obsoletePath = path5.join(serverExt, ".obsolete");
44714
44876
  let obsolete;
44715
44877
  try {
44716
44878
  obsolete = JSON.parse(await readFile(obsoletePath, "utf8"));
@@ -45169,15 +45331,15 @@ function proxyHandler(request, reply) {
45169
45331
 
45170
45332
  // src/routes/apps.ts
45171
45333
  import fs7 from "node:fs";
45172
- import path11 from "node:path";
45334
+ import path12 from "node:path";
45173
45335
 
45174
45336
  // src/apps/instances.ts
45175
45337
  import fs3 from "node:fs";
45176
- import path6 from "node:path";
45338
+ import path7 from "node:path";
45177
45339
 
45178
45340
  // src/apps/apps-registry.ts
45179
45341
  import fs2 from "node:fs";
45180
- import path5 from "node:path";
45342
+ import path6 from "node:path";
45181
45343
  import os4 from "node:os";
45182
45344
  import { fileURLToPath } from "node:url";
45183
45345
 
@@ -99402,10 +99564,10 @@ function setAppsRootOverride(root) {
99402
99564
  rootOverride = root;
99403
99565
  }
99404
99566
  function appsRoot() {
99405
- return rootOverride ?? process.env.AGENT_PANE_APPS_DIR ?? path5.join(os4.homedir(), ".repoburg", "agent-pane", "apps");
99567
+ return rootOverride ?? process.env.AGENT_PANE_APPS_DIR ?? path6.join(os4.homedir(), ".repoburg", "agent-pane", "apps");
99406
99568
  }
99407
99569
  function appDir(id) {
99408
- return path5.join(appsRoot(), id);
99570
+ return path6.join(appsRoot(), id);
99409
99571
  }
99410
99572
  var examplesRootOverride = null;
99411
99573
  function setExamplesRootOverride(root) {
@@ -99414,16 +99576,16 @@ function setExamplesRootOverride(root) {
99414
99576
  function examplesRoot() {
99415
99577
  if (examplesRootOverride) return examplesRootOverride;
99416
99578
  if (process.env.AGENT_PANE_EXAMPLES_DIR) return process.env.AGENT_PANE_EXAMPLES_DIR;
99417
- const here = path5.dirname(fileURLToPath(import.meta.url));
99418
- for (const candidate of [path5.resolve(here, "../../examples"), path5.resolve(here, "../../../examples")]) {
99579
+ const here = path6.dirname(fileURLToPath(import.meta.url));
99580
+ for (const candidate of [path6.resolve(here, "../../examples"), path6.resolve(here, "../../../examples")]) {
99419
99581
  if (fs2.existsSync(candidate)) return candidate;
99420
99582
  }
99421
99583
  return null;
99422
99584
  }
99423
99585
  function isInAppFolder(cwd) {
99424
99586
  if (!cwd) return false;
99425
- const rel = path5.relative(path5.resolve(appsRoot()), path5.resolve(cwd));
99426
- return rel !== "" && !path5.isAbsolute(rel) && rel.split(path5.sep)[0] !== "..";
99587
+ const rel = path6.relative(path6.resolve(appsRoot()), path6.resolve(cwd));
99588
+ return rel !== "" && !path6.isAbsolute(rel) && rel.split(path6.sep)[0] !== "..";
99427
99589
  }
99428
99590
  function appsConventions() {
99429
99591
  return APPS_MD_SKELETON;
@@ -99432,7 +99594,7 @@ function ensureAppsRoot() {
99432
99594
  const root = appsRoot();
99433
99595
  fs2.mkdirSync(root, { recursive: true });
99434
99596
  for (const name of ["CLAUDE.md", "AGENTS.md"]) {
99435
- const file2 = path5.join(root, name);
99597
+ const file2 = path6.join(root, name);
99436
99598
  try {
99437
99599
  if (fs2.existsSync(file2) && fs2.readFileSync(file2, "utf-8") === APPS_MD_FILE) continue;
99438
99600
  fs2.writeFileSync(file2, APPS_MD_FILE);
@@ -99697,7 +99859,7 @@ folder's own CLAUDE.md / AGENTS.md. -->
99697
99859
  ${APPS_MD_SKELETON}`;
99698
99860
  function readManifestIn(dir) {
99699
99861
  try {
99700
- const raw = fs2.readFileSync(path5.join(dir, "manifest.json"), "utf-8");
99862
+ const raw = fs2.readFileSync(path6.join(dir, "manifest.json"), "utf-8");
99701
99863
  const parsed = JSON.parse(raw);
99702
99864
  if (!parsed || typeof parsed.title !== "string") return null;
99703
99865
  return {
@@ -99724,7 +99886,7 @@ function readManifest(id) {
99724
99886
  }
99725
99887
  function readAppFile(id, name) {
99726
99888
  try {
99727
- return fs2.readFileSync(path5.join(appDir(id), name), "utf-8");
99889
+ return fs2.readFileSync(path6.join(appDir(id), name), "utf-8");
99728
99890
  } catch {
99729
99891
  return "";
99730
99892
  }
@@ -99757,11 +99919,11 @@ function startAppsWatch(onAppChange) {
99757
99919
  try {
99758
99920
  watcher = fs2.watch(root, { recursive: true }, (_event, filename) => {
99759
99921
  const rel = String(filename ?? "");
99760
- const segs = rel.split(path5.sep);
99922
+ const segs = rel.split(path6.sep);
99761
99923
  const appId = segs[0];
99762
99924
  const file2 = segs[segs.length - 1];
99763
- if (!appId || appId === path5.basename(root) || !APP_ID_RE.test(appId) || file2 === "state.json") return;
99764
- if (segs.length === 1 && isRegularFile(path5.join(root, appId))) return;
99925
+ if (!appId || appId === path6.basename(root) || !APP_ID_RE.test(appId) || file2 === "state.json") return;
99926
+ if (segs.length === 1 && isRegularFile(path6.join(root, appId))) return;
99765
99927
  const timer3 = pendingChanges.get(appId);
99766
99928
  if (timer3) clearTimeout(timer3);
99767
99929
  pendingChanges.set(
@@ -99832,7 +99994,7 @@ function getInstanceState(appId, workspace = "") {
99832
99994
  const stored = readRow(appId, workspace);
99833
99995
  if (stored) return stored;
99834
99996
  if (workspace === "") {
99835
- const legacyFile = path6.join(appDir(appId), "state.json");
99997
+ const legacyFile = path7.join(appDir(appId), "state.json");
99836
99998
  if (fs3.existsSync(legacyFile)) {
99837
99999
  const legacy = readState(appId);
99838
100000
  const imported = { pinned: legacy.pinned, data: legacy.data, version: 1 };
@@ -99865,9 +100027,9 @@ function resolveToolWorkspace(workspace) {
99865
100027
  const rows = getDb().prepare("SELECT path, deleted FROM workspaces").all();
99866
100028
  const active = rows.filter((w) => !w.deleted).map((w) => w.path);
99867
100029
  if (active.includes(workspace)) return workspace;
99868
- const cwd = path6.isAbsolute(workspace) ? path6.resolve(workspace) : "";
100030
+ const cwd = path7.isAbsolute(workspace) ? path7.resolve(workspace) : "";
99869
100031
  if (isInAppFolder(cwd)) return "";
99870
- const covering = rows.filter((w) => cwd === w.path || cwd.startsWith(w.path + path6.sep)).sort((a, b) => b.path.length - a.path.length)[0];
100032
+ const covering = rows.filter((w) => cwd === w.path || cwd.startsWith(w.path + path7.sep)).sort((a, b) => b.path.length - a.path.length)[0];
99871
100033
  if (covering && !covering.deleted) return covering.path;
99872
100034
  throw new Error(`Unknown workspace: ${workspace}. Known workspaces: ${active.join(", ") || "none"}`);
99873
100035
  }
@@ -99894,7 +100056,7 @@ function importAppInstances(appId, instances) {
99894
100056
  import fs5 from "node:fs";
99895
100057
 
99896
100058
  // src/apps/app-sessions.ts
99897
- import path8 from "node:path";
100059
+ import path9 from "node:path";
99898
100060
 
99899
100061
  // src/sidecar/transcript-locator.ts
99900
100062
  import { existsSync as existsSync2, readdirSync } from "node:fs";
@@ -99980,7 +100142,7 @@ function locateTranscriptCached(session) {
99980
100142
  import crypto2 from "node:crypto";
99981
100143
  import fs4 from "node:fs";
99982
100144
  import os5 from "node:os";
99983
- import path7 from "node:path";
100145
+ import path8 from "node:path";
99984
100146
  var APP_FILE_MAX_BYTES = 5 * 1024 * 1024;
99985
100147
  var APP_FILE_TYPES = {
99986
100148
  "image/png": "png",
@@ -100005,11 +100167,11 @@ function setAppFilesRootOverride(root) {
100005
100167
  rootOverride2 = root;
100006
100168
  }
100007
100169
  function appFilesRoot() {
100008
- return rootOverride2 ?? process.env.AGENT_PANE_APP_FILES_DIR ?? path7.join(os5.homedir(), ".repoburg", "agent-pane", "app-files");
100170
+ return rootOverride2 ?? process.env.AGENT_PANE_APP_FILES_DIR ?? path8.join(os5.homedir(), ".repoburg", "agent-pane", "app-files");
100009
100171
  }
100010
100172
  function appFilesDir(appId) {
100011
100173
  if (!APP_ID_RE.test(appId)) throw new AppFileError("Invalid app id", 400);
100012
- return path7.join(appFilesRoot(), appId);
100174
+ return path8.join(appFilesRoot(), appId);
100013
100175
  }
100014
100176
  function appFileUrl(appId, fileId) {
100015
100177
  return `/api/apps/${appId}/files/${fileId}`;
@@ -100070,7 +100232,7 @@ function saveAppFile(appId, upload) {
100070
100232
  const type = sniffImageType(bytes);
100071
100233
  if (!type) throw new AppFileError(`The file is not a ${ACCEPTED} image`, 400);
100072
100234
  const fileId = `${crypto2.createHash("sha256").update(bytes).digest("hex")}.${APP_FILE_TYPES[type]}`;
100073
- const file2 = path7.join(dir, fileId);
100235
+ const file2 = path8.join(dir, fileId);
100074
100236
  if (!fs4.existsSync(file2)) {
100075
100237
  fs4.mkdirSync(dir, { recursive: true });
100076
100238
  const tmp = `${file2}.${process.pid}.${crypto2.randomBytes(4).toString("hex")}.tmp`;
@@ -100102,7 +100264,7 @@ function getAppFile(appId, ref) {
100102
100264
  if (!APP_ID_RE.test(appId)) return null;
100103
100265
  const fileId = appFileRefId(appId, ref);
100104
100266
  if (!fileId) return null;
100105
- const file2 = path7.join(appFilesDir(appId), fileId);
100267
+ const file2 = path8.join(appFilesDir(appId), fileId);
100106
100268
  try {
100107
100269
  const stat2 = fs4.statSync(file2);
100108
100270
  if (!stat2.isFile()) return null;
@@ -100114,7 +100276,7 @@ function getAppFile(appId, ref) {
100114
100276
  function readAppFileData(appId, fileId) {
100115
100277
  if (!APP_ID_RE.test(appId) || !APP_FILE_ID_RE.test(fileId)) return null;
100116
100278
  try {
100117
- return { bytes: fs4.readFileSync(path7.join(appFilesDir(appId), fileId)), type: fileType(fileId) };
100279
+ return { bytes: fs4.readFileSync(path8.join(appFilesDir(appId), fileId)), type: fileType(fileId) };
100118
100280
  } catch {
100119
100281
  return null;
100120
100282
  }
@@ -100142,7 +100304,7 @@ function writeImportedAppFiles(appId, files) {
100142
100304
  const dir = appFilesDir(appId);
100143
100305
  fs4.mkdirSync(dir, { recursive: true });
100144
100306
  for (const [fileId, bytes] of files) {
100145
- const file2 = path7.join(dir, fileId);
100307
+ const file2 = path8.join(dir, fileId);
100146
100308
  if (!fs4.existsSync(file2)) fs4.writeFileSync(file2, bytes);
100147
100309
  }
100148
100310
  }
@@ -100247,7 +100409,7 @@ function appSessionInfo(appId, sessionId) {
100247
100409
  function sessionVisibleTo(session, appId, workspace) {
100248
100410
  if (!workspace) return true;
100249
100411
  const cwd = session.cwd;
100250
- if (cwd && (cwd === workspace || cwd.startsWith(workspace.endsWith(path8.sep) ? workspace : workspace + path8.sep))) {
100412
+ if (cwd && (cwd === workspace || cwd.startsWith(workspace.endsWith(path9.sep) ? workspace : workspace + path9.sep))) {
100251
100413
  return true;
100252
100414
  }
100253
100415
  return session.origin_app_workspace === workspace && openedByApp(session, appId);
@@ -100467,7 +100629,7 @@ function stopAppAlarms() {
100467
100629
 
100468
100630
  // src/apps/app-compile.ts
100469
100631
  import vm from "node:vm";
100470
- import path9 from "node:path";
100632
+ import path10 from "node:path";
100471
100633
  import ts from "typescript";
100472
100634
 
100473
100635
  // src/apps/app-lint.ts
@@ -100773,10 +100935,10 @@ declare const AgentPane: {
100773
100935
  fileUrl(ref: AgentPaneFileRef): string;
100774
100936
  };
100775
100937
  `;
100776
- var cache = /* @__PURE__ */ new Map();
100938
+ var cache2 = /* @__PURE__ */ new Map();
100777
100939
  function invalidateCompiledApp(appId) {
100778
- if (!appId) cache.clear();
100779
- else cache.delete(appId);
100940
+ if (!appId) cache2.clear();
100941
+ else cache2.delete(appId);
100780
100942
  }
100781
100943
  function tsDiagnosticToFile(file2, d) {
100782
100944
  if (!d.file) return null;
@@ -100896,15 +101058,15 @@ function typeCheckModules(appId, modules) {
100896
101058
  };
100897
101059
  const host = ts.createCompilerHost(options);
100898
101060
  const origReadFile = host.readFile.bind(host);
100899
- host.readFile = (fname) => path9.basename(fname) === BRIDGE_DTS_FILE ? BRIDGE_DTS : origReadFile(fname);
101061
+ host.readFile = (fname) => path10.basename(fname) === BRIDGE_DTS_FILE ? BRIDGE_DTS : origReadFile(fname);
100900
101062
  host.writeFile = () => {
100901
101063
  };
100902
- const bridgePath = path9.join(dir, BRIDGE_DTS_FILE);
100903
- const rootNames = [...modules.map((m) => path9.join(dir, m.file)), bridgePath];
101064
+ const bridgePath = path10.join(dir, BRIDGE_DTS_FILE);
101065
+ const rootNames = [...modules.map((m) => path10.join(dir, m.file)), bridgePath];
100904
101066
  const program = ts.createProgram(rootNames, options, host);
100905
101067
  const out = [];
100906
101068
  for (const mod of modules) {
100907
- const sf = program.getSourceFile(path9.join(dir, mod.file));
101069
+ const sf = program.getSourceFile(path10.join(dir, mod.file));
100908
101070
  if (!sf) continue;
100909
101071
  out.push(
100910
101072
  ...[...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)].map((d) => tsDiagnosticToFile(mod.file, d)).filter((d) => d !== null)
@@ -100931,7 +101093,7 @@ function checkJsSyntax(js) {
100931
101093
  }
100932
101094
  }
100933
101095
  function compileAppJs(appId) {
100934
- const cached3 = cache.get(appId);
101096
+ const cached3 = cache2.get(appId);
100935
101097
  if (cached3) return cached3;
100936
101098
  const tsSource = readAppFile(appId, APP_TS);
100937
101099
  let result;
@@ -100979,7 +101141,7 @@ function compileAppJs(appId) {
100979
101141
  readManifest(appId)?.icon
100980
101142
  )
100981
101143
  );
100982
- cache.set(appId, result);
101144
+ cache2.set(appId, result);
100983
101145
  return result;
100984
101146
  }
100985
101147
 
@@ -101481,7 +101643,7 @@ function anyAppHasTools() {
101481
101643
 
101482
101644
  // src/apps/app-zip.ts
101483
101645
  import fs6 from "node:fs";
101484
- import path10 from "node:path";
101646
+ import path11 from "node:path";
101485
101647
 
101486
101648
  // src/apps/zip.ts
101487
101649
  import zlib from "node:zlib";
@@ -101653,7 +101815,7 @@ function collectAppFiles(id) {
101653
101815
  if (isSkipped(entry.name)) continue;
101654
101816
  const relPath = rel ? `${rel}/${entry.name}` : entry.name;
101655
101817
  if (!rel && entry.name === "state.json") continue;
101656
- const full = path10.join(dir, entry.name);
101818
+ const full = path11.join(dir, entry.name);
101657
101819
  if (entry.isDirectory()) walk(full, relPath);
101658
101820
  else if (entry.isFile()) out.push({ name: `${id}/${relPath}`, data: fs6.readFileSync(full) });
101659
101821
  }
@@ -101669,7 +101831,7 @@ function collectAppData(id) {
101669
101831
  for (const fileId of listAppFileIds(id)) {
101670
101832
  out.push({
101671
101833
  name: `${id}/${APP_DATA_DIR}/files/${fileId}`,
101672
- data: fs6.readFileSync(path10.join(appFilesDir(id), fileId))
101834
+ data: fs6.readFileSync(path11.join(appFilesDir(id), fileId))
101673
101835
  });
101674
101836
  }
101675
101837
  return out;
@@ -101696,7 +101858,7 @@ function parseAppData(entries) {
101696
101858
  const instances = doc.instances.map((item) => {
101697
101859
  const inst = item;
101698
101860
  const workspace = inst && typeof inst.workspace === "string" ? inst.workspace : null;
101699
- const valid = workspace !== null && (workspace === "" || path10.isAbsolute(workspace)) && !seen.has(workspace) && (inst.data === null || typeof inst.data === "object" && !Array.isArray(inst.data));
101861
+ const valid = workspace !== null && (workspace === "" || path11.isAbsolute(workspace)) && !seen.has(workspace) && (inst.data === null || typeof inst.data === "object" && !Array.isArray(inst.data));
101700
101862
  if (!valid) throw new AppZipError(`${APP_DATA_DIR}/data.json has an invalid instance`, 400);
101701
101863
  seen.add(workspace);
101702
101864
  return { workspace, pinned: inst.pinned === true, data: inst.data };
@@ -101785,7 +101947,7 @@ function rehomeInstances(data, id) {
101785
101947
  const newDir = appFilesDir(id);
101786
101948
  const oldDir = data.filesDir?.replace(/[\\/]+$/, "");
101787
101949
  if (oldDir && oldDir !== newDir) {
101788
- swaps.push([`${oldDir}/`, `${newDir}${path10.sep}`], [`${oldDir}\\`, `${newDir}${path10.sep}`]);
101950
+ swaps.push([`${oldDir}/`, `${newDir}${path11.sep}`], [`${oldDir}\\`, `${newDir}${path11.sep}`]);
101789
101951
  }
101790
101952
  if (swaps.length === 0) return data.instances;
101791
101953
  const replace = (s) => swaps.reduce((out, [from, to]) => out.split(from).join(to), s);
@@ -101799,15 +101961,15 @@ function importAppZip(id, buf, opts = {}) {
101799
101961
  if (readManifest(id) || fs6.existsSync(appDir(id))) throw new AppZipError("App already exists", 409);
101800
101962
  const withData = opts.data ? data : null;
101801
101963
  ensureAppsRoot();
101802
- const tmp = path10.join(appsRoot(), `.import-${v4_default()}`);
101964
+ const tmp = path11.join(appsRoot(), `.import-${v4_default()}`);
101803
101965
  try {
101804
101966
  for (const [rel, bytes] of files) {
101805
- const file2 = path10.join(tmp, ...rel.split("/"));
101806
- fs6.mkdirSync(path10.dirname(file2), { recursive: true });
101967
+ const file2 = path11.join(tmp, ...rel.split("/"));
101968
+ fs6.mkdirSync(path11.dirname(file2), { recursive: true });
101807
101969
  fs6.writeFileSync(file2, bytes);
101808
101970
  }
101809
101971
  if (!files.has("manifest.json")) {
101810
- fs6.writeFileSync(path10.join(tmp, "manifest.json"), JSON.stringify({ title: id }, null, 2));
101972
+ fs6.writeFileSync(path11.join(tmp, "manifest.json"), JSON.stringify({ title: id }, null, 2));
101811
101973
  } else if (!readManifestIn(tmp)) {
101812
101974
  throw new AppZipError('manifest.json is invalid (it needs at least a "title" string)', 400);
101813
101975
  }
@@ -101919,7 +102081,7 @@ async function registerAppRoutes(fastify, opts) {
101919
102081
  try {
101920
102082
  for (const entry of fs7.readdirSync(exRoot, { withFileTypes: true })) {
101921
102083
  if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
101922
- const manifest = readManifestIn(path11.join(exRoot, entry.name));
102084
+ const manifest = readManifestIn(path12.join(exRoot, entry.name));
101923
102085
  if (!manifest) continue;
101924
102086
  out.push({
101925
102087
  id: entry.name,
@@ -101940,7 +102102,7 @@ async function registerAppRoutes(fastify, opts) {
101940
102102
  if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
101941
102103
  const exRoot = examplesRoot();
101942
102104
  if (!exRoot) return reply.code(404).send({ error: "Examples catalog not available" });
101943
- const src = path11.join(exRoot, id);
102105
+ const src = path12.join(exRoot, id);
101944
102106
  if (!readManifestIn(src)) return reply.code(404).send({ error: "Example not found" });
101945
102107
  if (readManifest(id)) return reply.code(409).send({ error: "App already installed" });
101946
102108
  ensureAppsRoot();
@@ -101979,7 +102141,7 @@ async function registerAppRoutes(fastify, opts) {
101979
102141
  fs7.mkdirSync(dir, { recursive: true });
101980
102142
  const cleanTitle2 = title.trim();
101981
102143
  fs7.writeFileSync(
101982
- path11.join(dir, "manifest.json"),
102144
+ path12.join(dir, "manifest.json"),
101983
102145
  JSON.stringify(
101984
102146
  {
101985
102147
  title: cleanTitle2,
@@ -101990,8 +102152,8 @@ async function registerAppRoutes(fastify, opts) {
101990
102152
  2
101991
102153
  )
101992
102154
  );
101993
- fs7.writeFileSync(path11.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
101994
- fs7.writeFileSync(path11.join(dir, "app.ts"), SKELETON_TS);
102155
+ fs7.writeFileSync(path12.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
102156
+ fs7.writeFileSync(path12.join(dir, "app.ts"), SKELETON_TS);
101995
102157
  return { ok: true, id };
101996
102158
  }
101997
102159
  );
@@ -102555,16 +102717,16 @@ async function loadFresh(timezone) {
102555
102717
  ]);
102556
102718
  return { data: parseCcusageJson(stdout), generatedAt: Date.now() };
102557
102719
  }
102558
- var cache2 = /* @__PURE__ */ new Map();
102720
+ var cache3 = /* @__PURE__ */ new Map();
102559
102721
  var inflight = /* @__PURE__ */ new Map();
102560
102722
  function loadCcusage(timezone, fresh) {
102561
- const cached3 = cache2.get(timezone);
102723
+ const cached3 = cache3.get(timezone);
102562
102724
  if (cached3 && !fresh) return Promise.resolve(cached3);
102563
102725
  let run = inflight.get(timezone);
102564
102726
  if (!run) {
102565
102727
  run = loadFresh(timezone).then((result) => {
102566
- if (cache2.size >= 4) cache2.clear();
102567
- cache2.set(timezone, result);
102728
+ if (cache3.size >= 4) cache3.clear();
102729
+ cache3.set(timezone, result);
102568
102730
  return result;
102569
102731
  }).finally(() => inflight.delete(timezone));
102570
102732
  inflight.set(timezone, run);
@@ -102969,7 +103131,7 @@ async function registerUsageRoutes(fastify) {
102969
103131
 
102970
103132
  // src/claude/session-import.ts
102971
103133
  import { readFile as readFile2, realpath } from "node:fs/promises";
102972
- import path12 from "node:path";
103134
+ import path13 from "node:path";
102973
103135
  import { getSessionInfo, listSessions } from "@anthropic-ai/claude-agent-sdk";
102974
103136
 
102975
103137
  // src/claude/widget-tool.ts
@@ -118014,7 +118176,7 @@ async function realDir(dir) {
118014
118176
  }
118015
118177
  }
118016
118178
  async function sameDir(a, realB) {
118017
- const realA = await realDir(a) ?? path12.resolve(a);
118179
+ const realA = await realDir(a) ?? path13.resolve(a);
118018
118180
  return realA === realB;
118019
118181
  }
118020
118182
  function knownClaudeSessionIds(db2) {
@@ -118184,22 +118346,22 @@ async function registerClaudeSessionRoutes(fastify) {
118184
118346
 
118185
118347
  // src/codex/session-import.ts
118186
118348
  import { realpath as realpath2 } from "node:fs/promises";
118187
- import path14 from "node:path";
118349
+ import path15 from "node:path";
118188
118350
 
118189
118351
  // src/apps/register-mcp.ts
118190
118352
  import fs8 from "node:fs";
118191
- import path13 from "node:path";
118353
+ import path14 from "node:path";
118192
118354
  import { fileURLToPath as fileURLToPath2 } from "node:url";
118193
118355
  var MCP_SERVER_NAME = "agentpane-miniapps";
118194
118356
  function panePublicUrl() {
118195
118357
  return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
118196
118358
  }
118197
118359
  function stdioScriptPath() {
118198
- const here = path13.dirname(fileURLToPath2(import.meta.url));
118360
+ const here = path14.dirname(fileURLToPath2(import.meta.url));
118199
118361
  const candidates = [
118200
- path13.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
118362
+ path14.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
118201
118363
  // src/apps/ → backend/scripts
118202
- path13.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
118364
+ path14.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
118203
118365
  // dist bundle → backend/scripts
118204
118366
  ];
118205
118367
  for (const candidate of candidates) {
@@ -118458,7 +118620,7 @@ async function realDir2(dir) {
118458
118620
  async function workspaceDirs(workspacePath) {
118459
118621
  const real = await realDir2(workspacePath);
118460
118622
  if (!real) return null;
118461
- const given = path14.resolve(workspacePath);
118623
+ const given = path15.resolve(workspacePath);
118462
118624
  return given === real ? [real] : [given, real];
118463
118625
  }
118464
118626
  function titleOf2(thread) {
@@ -118698,7 +118860,7 @@ async function registerCodexSessionRoutes(fastify) {
118698
118860
 
118699
118861
  // src/session-host/flags.ts
118700
118862
  import fs9 from "node:fs";
118701
- import path15 from "node:path";
118863
+ import path16 from "node:path";
118702
118864
  var DEFAULT_FLAGS = {
118703
118865
  claude: true,
118704
118866
  codex: true,
@@ -118717,13 +118879,13 @@ function setPaneDataDir(dir) {
118717
118879
  }
118718
118880
  function sessionHostsRoot() {
118719
118881
  const override = process.env.AGENT_PANE_SESSION_HOSTS_DIR;
118720
- if (override) return path15.resolve(override);
118721
- return paneDataDir ? path15.join(paneDataDir, "session-hosts") : null;
118882
+ if (override) return path16.resolve(override);
118883
+ return paneDataDir ? path16.join(paneDataDir, "session-hosts") : null;
118722
118884
  }
118723
118885
  function flagsFilePath() {
118724
118886
  const root = sessionHostsRoot();
118725
- if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return path15.join(path15.dirname(root), "session-hosts.json");
118726
- return paneDataDir ? path15.join(paneDataDir, "session-hosts.json") : null;
118887
+ if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return path16.join(path16.dirname(root), "session-hosts.json");
118888
+ return paneDataDir ? path16.join(paneDataDir, "session-hosts.json") : null;
118727
118889
  }
118728
118890
  function readFlagFile(file2) {
118729
118891
  if (!file2) return {};
@@ -118795,7 +118957,7 @@ var LOG_HEADER_LEN = LOG_HEADER_PREFIX.length + LOG_HEADER_DIGITS + 1;
118795
118957
  // src/session-host/registry.ts
118796
118958
  import { randomBytes, randomUUID as randomUUID2 } from "node:crypto";
118797
118959
  import fs11 from "node:fs";
118798
- import path17 from "node:path";
118960
+ import path18 from "node:path";
118799
118961
  import { fileURLToPath as fileURLToPath4 } from "node:url";
118800
118962
 
118801
118963
  // src/session-host/client.ts
@@ -118803,7 +118965,7 @@ import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
118803
118965
  import { EventEmitter as EventEmitter2 } from "node:events";
118804
118966
  import fs10 from "node:fs";
118805
118967
  import net2 from "node:net";
118806
- import path16 from "node:path";
118968
+ import path17 from "node:path";
118807
118969
  import { fileURLToPath as fileURLToPath3 } from "node:url";
118808
118970
  var HostRequestError = class extends Error {
118809
118971
  reply;
@@ -118815,11 +118977,11 @@ var HostRequestError = class extends Error {
118815
118977
  function hostScriptPath() {
118816
118978
  const override = process.env.AGENT_PANE_SESSION_HOST_SCRIPT;
118817
118979
  if (override) return override;
118818
- const here = path16.dirname(fileURLToPath3(import.meta.url));
118980
+ const here = path17.dirname(fileURLToPath3(import.meta.url));
118819
118981
  const candidates = [
118820
- path16.resolve(here, "../../scripts/session-host.mjs"),
118982
+ path17.resolve(here, "../../scripts/session-host.mjs"),
118821
118983
  // src/session-host/ → backend/scripts
118822
- path16.resolve(here, "../scripts/session-host.mjs")
118984
+ path17.resolve(here, "../scripts/session-host.mjs")
118823
118985
  // dist bundle → backend/scripts
118824
118986
  ];
118825
118987
  for (const candidate of candidates) {
@@ -118828,10 +118990,10 @@ function hostScriptPath() {
118828
118990
  return null;
118829
118991
  }
118830
118992
  function hostSocketPath(dir) {
118831
- const direct = path16.join(dir, "sock");
118993
+ const direct = path17.join(dir, "sock");
118832
118994
  if (Buffer.byteLength(direct) < 100) return direct;
118833
118995
  const uid = typeof process.getuid === "function" ? process.getuid() : 0;
118834
- return path16.join("/tmp", `rbsh-${uid}`, path16.basename(dir), "sock");
118996
+ return path17.join("/tmp", `rbsh-${uid}`, path17.basename(dir), "sock");
118835
118997
  }
118836
118998
  function readJson(file2) {
118837
118999
  try {
@@ -118841,10 +119003,10 @@ function readJson(file2) {
118841
119003
  }
118842
119004
  }
118843
119005
  function readHostExit(dir) {
118844
- return readJson(path16.join(dir, "exit.json"));
119006
+ return readJson(path17.join(dir, "exit.json"));
118845
119007
  }
118846
119008
  function readHostChild(dir) {
118847
- return readJson(path16.join(dir, "child.json"));
119009
+ return readJson(path17.join(dir, "child.json"));
118848
119010
  }
118849
119011
  function isPidAlive(pid) {
118850
119012
  if (!pid || pid <= 0) return false;
@@ -119034,7 +119196,7 @@ async function waitForHost(dir, timeoutMs = 1e4) {
119034
119196
  function readLogOldest(dir) {
119035
119197
  let fd = null;
119036
119198
  try {
119037
- fd = fs10.openSync(path16.join(dir, "out.log"), "r");
119199
+ fd = fs10.openSync(path17.join(dir, "out.log"), "r");
119038
119200
  const buf = Buffer.alloc(LOG_HEADER_LEN);
119039
119201
  const n = fs10.readSync(fd, buf, 0, LOG_HEADER_LEN, 0);
119040
119202
  const text2 = buf.subarray(0, n).toString("utf8");
@@ -119051,7 +119213,7 @@ function readHostLog(dir, after) {
119051
119213
  const oldest = readLogOldest(dir);
119052
119214
  if (oldest === null || after < oldest) return null;
119053
119215
  try {
119054
- const all = fs10.readFileSync(path16.join(dir, "out.log"));
119216
+ const all = fs10.readFileSync(path17.join(dir, "out.log"));
119055
119217
  const start = LOG_HEADER_LEN + (after - oldest);
119056
119218
  if (start > all.length) return null;
119057
119219
  return all.subarray(start);
@@ -119065,7 +119227,7 @@ function removeHostDir(dir) {
119065
119227
  } catch (err) {
119066
119228
  console.error(`[session-host] could not remove ${dir}:`, err.message);
119067
119229
  }
119068
- const alias = path16.dirname(hostSocketPath(dir));
119230
+ const alias = path17.dirname(hostSocketPath(dir));
119069
119231
  if (alias !== dir) {
119070
119232
  try {
119071
119233
  fs10.unlinkSync(alias);
@@ -119128,16 +119290,16 @@ function newHostDir() {
119128
119290
  const root = sessionHostsRoot();
119129
119291
  if (!root) throw new Error("session hosts have no directory");
119130
119292
  const id = randomBytes(8).toString("hex");
119131
- return { id, dir: path17.join(root, id) };
119293
+ return { id, dir: path18.join(root, id) };
119132
119294
  }
119133
119295
  var cachedVersion;
119134
119296
  function runtimeVersion() {
119135
119297
  if (cachedVersion !== void 0) return cachedVersion;
119136
119298
  cachedVersion = null;
119137
- const here = path17.dirname(fileURLToPath4(import.meta.url));
119299
+ const here = path18.dirname(fileURLToPath4(import.meta.url));
119138
119300
  for (const rel of ["../../../../package.json", "../../../package.json"]) {
119139
119301
  try {
119140
- const pkg = JSON.parse(fs11.readFileSync(path17.resolve(here, rel), "utf8"));
119302
+ const pkg = JSON.parse(fs11.readFileSync(path18.resolve(here, rel), "utf8"));
119141
119303
  if (pkg.name === "repoburg" && pkg.version) {
119142
119304
  cachedVersion = pkg.version;
119143
119305
  break;
@@ -119150,13 +119312,13 @@ function runtimeVersion() {
119150
119312
  function writeHostMeta(dir, meta3) {
119151
119313
  fs11.mkdirSync(dir, { recursive: true, mode: 448 });
119152
119314
  fs11.chmodSync(dir, 448);
119153
- const tmp = path17.join(dir, "meta.json.tmp");
119315
+ const tmp = path18.join(dir, "meta.json.tmp");
119154
119316
  fs11.writeFileSync(tmp, JSON.stringify(meta3, null, 2) + "\n", { mode: 384 });
119155
- fs11.renameSync(tmp, path17.join(dir, "meta.json"));
119317
+ fs11.renameSync(tmp, path18.join(dir, "meta.json"));
119156
119318
  }
119157
119319
  function readHostMeta(dir) {
119158
119320
  try {
119159
- return JSON.parse(fs11.readFileSync(path17.join(dir, "meta.json"), "utf8"));
119321
+ return JSON.parse(fs11.readFileSync(path18.join(dir, "meta.json"), "utf8"));
119160
119322
  } catch {
119161
119323
  return null;
119162
119324
  }
@@ -119301,7 +119463,7 @@ async function adoptHosts(db2, root, adoption, result) {
119301
119463
  const seen = /* @__PURE__ */ new Set();
119302
119464
  const queue = [];
119303
119465
  for (const id of entries) {
119304
- const dir = path17.join(root, id);
119466
+ const dir = path18.join(root, id);
119305
119467
  try {
119306
119468
  if (!fs11.statSync(dir).isDirectory()) continue;
119307
119469
  } catch {
@@ -119428,7 +119590,7 @@ async function shutDownAllHosts() {
119428
119590
  }
119429
119591
  await Promise.all(
119430
119592
  entries.map(async (id) => {
119431
- const dir = path17.join(root, id);
119593
+ const dir = path18.join(root, id);
119432
119594
  const row = db2 ? getHostRow(db2, id) : void 0;
119433
119595
  try {
119434
119596
  await shutDownHost(dir, { eof: row?.runtime === "codex" });
@@ -119899,7 +120061,7 @@ function mapTokenUsage(data) {
119899
120061
  import { spawn as spawn6 } from "node:child_process";
119900
120062
  import fs12 from "node:fs";
119901
120063
  import os6 from "node:os";
119902
- import path18 from "node:path";
120064
+ import path19 from "node:path";
119903
120065
  import { fileURLToPath as fileURLToPath5 } from "node:url";
119904
120066
  var TABTAPE_MCP_NAME = "tabtape";
119905
120067
  var PLAYWRIGHT_MCP_NAME = "playwright";
@@ -119913,15 +120075,15 @@ function disabled() {
119913
120075
  function tabtapeBaseUrl() {
119914
120076
  return (process.env.AGENT_PANE_TABTAPE_URL || `${sessionHostDaemonUrl()}/tabtape`).replace(/\/+$/, "");
119915
120077
  }
119916
- function playwrightMcpScript(from = path18.dirname(fileURLToPath5(import.meta.url))) {
120078
+ function playwrightMcpScript(from = path19.dirname(fileURLToPath5(import.meta.url))) {
119917
120079
  if (scriptOverride !== void 0) return scriptOverride;
119918
120080
  let dir = from;
119919
120081
  for (let i = 0; i < 6; i++) {
119920
- const script = path18.join(dir, "tabtape", "playwright", "mcp.mjs");
119921
- if (fs12.existsSync(script) && fs12.existsSync(path18.join(dir, "tabtape", "extension", "dist", "manifest.json"))) {
120082
+ const script = path19.join(dir, "tabtape", "playwright", "mcp.mjs");
120083
+ if (fs12.existsSync(script) && fs12.existsSync(path19.join(dir, "tabtape", "extension", "dist", "manifest.json"))) {
119922
120084
  return script;
119923
120085
  }
119924
- const parent = path18.dirname(dir);
120086
+ const parent = path19.dirname(dir);
119925
120087
  if (parent === dir) break;
119926
120088
  dir = parent;
119927
120089
  }
@@ -119963,7 +120125,7 @@ function jsonServerNames(file2, pick2) {
119963
120125
  }
119964
120126
  function claudeConfigFile() {
119965
120127
  if (process.env.AGENT_PANE_CLAUDE_CONFIG_FILE) return process.env.AGENT_PANE_CLAUDE_CONFIG_FILE;
119966
- return path18.join(process.env.CLAUDE_CONFIG_DIR || os6.homedir(), ".claude.json");
120128
+ return path19.join(process.env.CLAUDE_CONFIG_DIR || os6.homedir(), ".claude.json");
119967
120129
  }
119968
120130
  function claudeUserMcpNames(cwd) {
119969
120131
  const file2 = claudeConfigFile();
@@ -119973,7 +120135,7 @@ function claudeUserMcpNames(cwd) {
119973
120135
  file2,
119974
120136
  (json2) => json2.projects?.[cwd]?.mcpServers
119975
120137
  ),
119976
- ...jsonServerNames(path18.join(cwd, ".mcp.json"), (json2) => json2.mcpServers)
120138
+ ...jsonServerNames(path19.join(cwd, ".mcp.json"), (json2) => json2.mcpServers)
119977
120139
  ]);
119978
120140
  }
119979
120141
  async function claudeBrowserMcpServers(cwd) {
@@ -119996,10 +120158,10 @@ function tomlServerNames(file2) {
119996
120158
  return names;
119997
120159
  }
119998
120160
  function codexUserMcpNames(cwd) {
119999
- const home = process.env.CODEX_HOME || path18.join(os6.homedir(), ".codex");
120161
+ const home = process.env.CODEX_HOME || path19.join(os6.homedir(), ".codex");
120000
120162
  return /* @__PURE__ */ new Set([
120001
- ...tomlServerNames(path18.join(home, "config.toml")),
120002
- ...tomlServerNames(path18.join(cwd, ".codex", "config.toml"))
120163
+ ...tomlServerNames(path19.join(home, "config.toml")),
120164
+ ...tomlServerNames(path19.join(cwd, ".codex", "config.toml"))
120003
120165
  ]);
120004
120166
  }
120005
120167
  var CODEX_BROWSER_CHECK_INSTRUCTIONS = `Browser checks: when you check a change end-to-end in a browser, use the playwright MCP tools (a Chromium with the tabtape recorder) and record the check. Call the tabtape tool get_record_link (name: what you check, url: the first page), open its start link with browser_navigate, do the check, then open its stop link: that page shows the replay link, which you give the user. When a check fails, look into the recording with the tabtape tools before guessing. If recording does not work (the start page says "Nothing happened", or tabtape cannot be reached), carry on with the check and tell the user the recording failed.`;
@@ -120041,13 +120203,13 @@ async function repoburgBrowserMcpServers(_cwd) {
120041
120203
  }
120042
120204
  var prepared = false;
120043
120205
  function chromiumDownloadCommand(execPath = process.execPath) {
120044
- const bin = path18.dirname(execPath);
120045
- const npx = path18.join(bin, process.platform === "win32" ? "npx.cmd" : "npx");
120206
+ const bin = path19.dirname(execPath);
120207
+ const npx = path19.join(bin, process.platform === "win32" ? "npx.cmd" : "npx");
120046
120208
  if (!fs12.existsSync(npx)) return null;
120047
120209
  return {
120048
120210
  command: npx,
120049
120211
  args: ["-y", "@playwright/mcp@latest", "install-browser", "chromium"],
120050
- env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(path18.delimiter) }
120212
+ env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(path19.delimiter) }
120051
120213
  };
120052
120214
  }
120053
120215
  function prepareBrowserMcp() {
@@ -122378,6 +122540,7 @@ function clearResume(entry) {
122378
122540
  entry.resume = null;
122379
122541
  }
122380
122542
  function pushPrompt(entry, content) {
122543
+ entry.echoPendingTurnId = entry.turnId ?? null;
122381
122544
  entry.promptQueue.push({
122382
122545
  type: "user",
122383
122546
  message: { role: "user", content },
@@ -122643,6 +122806,7 @@ async function ensureSessionStarted(session, mapKey, resumeSessionId, resume, ad
122643
122806
  return entry;
122644
122807
  }
122645
122808
  async function dispatchFrame(entry, sessionId, message, db2, opts = {}) {
122809
+ if (skipsForeignResult(entry, message)) return;
122646
122810
  trackIdle(entry, message);
122647
122811
  if (isBackgroundTasksChanged(message)) {
122648
122812
  handleBackgroundTasksChanged(message, sessionId, entry);
@@ -122662,6 +122826,7 @@ async function dispatchFrame(entry, sessionId, message, db2, opts = {}) {
122662
122826
  handlePeerMessage(entry, sessionId, message, peer, db2);
122663
122827
  return;
122664
122828
  }
122829
+ if (isOwnEcho(message)) entry.echoPendingTurnId = null;
122665
122830
  if (entry.selfStarted && isModelFrame(message)) reopenForFollowUp(entry, sessionId, db2);
122666
122831
  const currentTurnId = entry.turnId;
122667
122832
  if (!currentTurnId) {
@@ -122671,6 +122836,7 @@ async function dispatchFrame(entry, sessionId, message, db2, opts = {}) {
122671
122836
  if (entry.resume && !trackResumeFrame(entry, message, db2)) return;
122672
122837
  if (message.type === "result" && !message.parent_tool_use_id) {
122673
122838
  entry.resultTurnId = currentTurnId;
122839
+ entry.echoPendingTurnId = null;
122674
122840
  }
122675
122841
  if (opts.awaitResult && message.type === "result") {
122676
122842
  await handleResultMessage(message, sessionId, currentTurnId, entry, db2);
@@ -122678,6 +122844,19 @@ async function dispatchFrame(entry, sessionId, message, db2, opts = {}) {
122678
122844
  }
122679
122845
  await handleMessage(message, sessionId, currentTurnId, entry, db2);
122680
122846
  }
122847
+ function isOwnEcho(message) {
122848
+ if (message.type !== "user") return false;
122849
+ const m = message;
122850
+ if (!m.isReplay || m.parent_tool_use_id) return false;
122851
+ return !m.origin || m.origin.kind === "human";
122852
+ }
122853
+ function skipsForeignResult(entry, message) {
122854
+ if (message.type !== "result" || !entry.turnId || entry.echoPendingTurnId !== entry.turnId) return false;
122855
+ const m = message;
122856
+ if (m.parent_tool_use_id || !m.origin?.kind || m.origin.kind === "human") return false;
122857
+ bindHostTurn2(entry, entry.turnId);
122858
+ return true;
122859
+ }
122681
122860
  function isTurnLive2(db2, turnId) {
122682
122861
  const row = db2.prepare("SELECT status FROM turns WHERE id = ?").get(turnId);
122683
122862
  return row?.status === "pending" || row?.status === "running";
@@ -122713,6 +122892,7 @@ function handleSessionState(entry, state, db2) {
122713
122892
  entry.selfStarted = !entry.resume && !turnInProgress(entry, db2);
122714
122893
  } else if (state === "idle") {
122715
122894
  entry.selfStarted = false;
122895
+ entry.echoPendingTurnId = null;
122716
122896
  }
122717
122897
  }
122718
122898
  function handlePeerMessage(entry, sessionId, message, origin, db2) {
@@ -124228,154 +124408,6 @@ var RepoburgHttpClient = class {
124228
124408
  }
124229
124409
  };
124230
124410
 
124231
- // src/repoburg/backend-resolver.ts
124232
- import path19 from "node:path";
124233
- var HEALTH_POLL_INTERVAL_MS = 1e3;
124234
- var HEALTH_TIMEOUT_MS = 3e4;
124235
- function daemonBaseUrl() {
124236
- return (process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
124237
- }
124238
- var HttpError = class extends Error {
124239
- constructor(status, body, url2) {
124240
- super(`${url2} failed: ${status} ${body}`);
124241
- this.status = status;
124242
- this.body = body;
124243
- this.url = url2;
124244
- }
124245
- };
124246
- async function fetchJson(url2, init, timeoutMs = 5e3) {
124247
- const controller = new AbortController();
124248
- const timer3 = setTimeout(() => controller.abort(), timeoutMs);
124249
- let response;
124250
- try {
124251
- response = await fetch(url2, { ...init, signal: controller.signal });
124252
- } finally {
124253
- clearTimeout(timer3);
124254
- }
124255
- const text2 = await response.text();
124256
- if (!response.ok) {
124257
- throw new HttpError(response.status, text2, url2);
124258
- }
124259
- try {
124260
- return JSON.parse(text2);
124261
- } catch {
124262
- throw new Error(`Unexpected non-JSON response from ${url2}`);
124263
- }
124264
- }
124265
- function daemonErrorMessage(err) {
124266
- if (err instanceof HttpError) {
124267
- try {
124268
- const parsed = JSON.parse(err.body);
124269
- return parsed.message || parsed.error || err.body;
124270
- } catch {
124271
- return err.body;
124272
- }
124273
- }
124274
- return err.message;
124275
- }
124276
- var resolvedCache = /* @__PURE__ */ new Map();
124277
- function invalidateBackend(baseUrl) {
124278
- for (const [key, value] of resolvedCache) {
124279
- if (value.baseUrl === baseUrl) resolvedCache.delete(key);
124280
- }
124281
- }
124282
- async function backendHealthy(baseUrl, expectedPath) {
124283
- try {
124284
- const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
124285
- if (health.status !== "ok") return false;
124286
- if (expectedPath && health.projectPath) {
124287
- return path19.resolve(health.projectPath) === path19.resolve(expectedPath);
124288
- }
124289
- return true;
124290
- } catch {
124291
- return false;
124292
- }
124293
- }
124294
- async function waitForHealthy(baseUrl, name, expectedPath) {
124295
- const deadline = Date.now() + HEALTH_TIMEOUT_MS;
124296
- while (Date.now() < deadline) {
124297
- if (await backendHealthy(baseUrl, expectedPath)) return;
124298
- await new Promise((resolve) => setTimeout(resolve, HEALTH_POLL_INTERVAL_MS));
124299
- }
124300
- throw new Error(
124301
- `Backend '${name}' on ${baseUrl} did not become healthy within ${HEALTH_TIMEOUT_MS / 1e3}s. Check daemon logs: repoburg logs ${name}`
124302
- );
124303
- }
124304
- function serviceBaseUrl(service) {
124305
- return `http://localhost:${service.port}`;
124306
- }
124307
- function coveringService(services, absPath) {
124308
- return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path19.sep)).sort((a, b) => b.path.length - a.path.length)[0];
124309
- }
124310
- async function restartService(daemon, name) {
124311
- try {
124312
- await fetchJson(`${daemon}/services/${name}/restart`, { method: "POST" });
124313
- } catch (err) {
124314
- throw new Error(`Daemon failed to restart backend '${name}': ${daemonErrorMessage(err)}`);
124315
- }
124316
- }
124317
- async function startService(daemon, projectPath) {
124318
- try {
124319
- return await fetchJson(`${daemon}/services/start`, {
124320
- method: "POST",
124321
- headers: { "Content-Type": "application/json" },
124322
- body: JSON.stringify({ path: projectPath })
124323
- });
124324
- } catch (err) {
124325
- throw new Error(`Daemon failed to start backend for ${projectPath}: ${daemonErrorMessage(err)}`);
124326
- }
124327
- }
124328
- function cache3(absPath, service) {
124329
- const resolved = {
124330
- baseUrl: serviceBaseUrl(service),
124331
- port: service.port,
124332
- name: service.name,
124333
- servesPath: service.path
124334
- };
124335
- resolvedCache.set(absPath, resolved);
124336
- return resolved;
124337
- }
124338
- async function resolveBackendUrl(projectPath, opts = {}) {
124339
- const autoStart = opts.autoStart !== false;
124340
- const envUrl = process.env.REPOBURG_BACKEND_URL;
124341
- if (envUrl) {
124342
- return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
124343
- }
124344
- const absPath = path19.resolve(projectPath);
124345
- const daemon = daemonBaseUrl();
124346
- const cached3 = resolvedCache.get(absPath);
124347
- if (cached3 && await backendHealthy(cached3.baseUrl, cached3.servesPath ?? absPath)) {
124348
- return cached3;
124349
- }
124350
- try {
124351
- await fetchJson(`${daemon}/health`, void 0, 3e3);
124352
- } catch {
124353
- throw new Error(
124354
- `Repoburg daemon not reachable at ${daemon}. Start it with 'repoburg-daemon', or set REPOBURG_BACKEND_URL to a running backend.`
124355
- );
124356
- }
124357
- const services = await fetchJson(`${daemon}/services`);
124358
- const match = coveringService(services, absPath);
124359
- if (match && match.status === "running") {
124360
- if (await backendHealthy(serviceBaseUrl(match), match.path)) {
124361
- return cache3(absPath, match);
124362
- }
124363
- if (!autoStart) return null;
124364
- await restartService(daemon, match.name);
124365
- await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
124366
- return cache3(absPath, match);
124367
- }
124368
- if (!autoStart) return null;
124369
- if (match) {
124370
- await restartService(daemon, match.name);
124371
- await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
124372
- return cache3(absPath, match);
124373
- }
124374
- const service = await startService(daemon, absPath);
124375
- await waitForHealthy(serviceBaseUrl(service), service.name, absPath);
124376
- return cache3(absPath, service);
124377
- }
124378
-
124379
124411
  // src/repoburg/action-mapping.ts
124380
124412
  function parseJsonArgs(raw) {
124381
124413
  if (!raw) return null;