repoburg 1.3.323 → 1.3.324
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/agent-pane/backend/dist/index.js +279 -265
- package/agent-pane/backend/dist/server.js +280 -266
- package/agent-pane/frontend/dist/assets/{TerminalView-Z7ZJ436H.js → TerminalView-DQaRNqT-.js} +1 -1
- package/agent-pane/frontend/dist/assets/index-CUuZmtId.css +1 -0
- package/agent-pane/frontend/dist/assets/index-kBNaARow.js +862 -0
- package/agent-pane/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
- package/agent-pane/frontend/dist/assets/index-C1m0abtH.css +0 -1
- package/agent-pane/frontend/dist/assets/index-CjwvHfxy.js +0 -862
|
@@ -43989,6 +43989,165 @@ async function registerProviderRoutes(fastify) {
|
|
|
43989
43989
|
var InferenceCredentialsError = class extends Error {
|
|
43990
43990
|
};
|
|
43991
43991
|
|
|
43992
|
+
// src/repoburg/backend-resolver.ts
|
|
43993
|
+
import path4 from "node:path";
|
|
43994
|
+
var RepoburgSignInRequiredError = class extends Error {
|
|
43995
|
+
constructor(projectPath) {
|
|
43996
|
+
super(
|
|
43997
|
+
`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'.`
|
|
43998
|
+
);
|
|
43999
|
+
this.projectPath = projectPath;
|
|
44000
|
+
this.name = "RepoburgSignInRequiredError";
|
|
44001
|
+
}
|
|
44002
|
+
code = "repoburg_sign_in_required";
|
|
44003
|
+
};
|
|
44004
|
+
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
44005
|
+
var HEALTH_TIMEOUT_MS = 3e4;
|
|
44006
|
+
function daemonBaseUrl() {
|
|
44007
|
+
return (process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
44008
|
+
}
|
|
44009
|
+
var HttpError = class extends Error {
|
|
44010
|
+
constructor(status, body, url2) {
|
|
44011
|
+
super(`${url2} failed: ${status} ${body}`);
|
|
44012
|
+
this.status = status;
|
|
44013
|
+
this.body = body;
|
|
44014
|
+
this.url = url2;
|
|
44015
|
+
}
|
|
44016
|
+
};
|
|
44017
|
+
async function fetchJson(url2, init, timeoutMs = 5e3) {
|
|
44018
|
+
const controller = new AbortController();
|
|
44019
|
+
const timer3 = setTimeout(() => controller.abort(), timeoutMs);
|
|
44020
|
+
let response;
|
|
44021
|
+
try {
|
|
44022
|
+
response = await fetch(url2, { ...init, signal: controller.signal });
|
|
44023
|
+
} finally {
|
|
44024
|
+
clearTimeout(timer3);
|
|
44025
|
+
}
|
|
44026
|
+
const text2 = await response.text();
|
|
44027
|
+
if (!response.ok) {
|
|
44028
|
+
throw new HttpError(response.status, text2, url2);
|
|
44029
|
+
}
|
|
44030
|
+
try {
|
|
44031
|
+
return JSON.parse(text2);
|
|
44032
|
+
} catch {
|
|
44033
|
+
throw new Error(`Unexpected non-JSON response from ${url2}`);
|
|
44034
|
+
}
|
|
44035
|
+
}
|
|
44036
|
+
function daemonErrorMessage(err) {
|
|
44037
|
+
if (err instanceof HttpError) {
|
|
44038
|
+
try {
|
|
44039
|
+
const parsed = JSON.parse(err.body);
|
|
44040
|
+
return parsed.message || parsed.error || err.body;
|
|
44041
|
+
} catch {
|
|
44042
|
+
return err.body;
|
|
44043
|
+
}
|
|
44044
|
+
}
|
|
44045
|
+
return err.message;
|
|
44046
|
+
}
|
|
44047
|
+
var resolvedCache = /* @__PURE__ */ new Map();
|
|
44048
|
+
function invalidateBackend(baseUrl) {
|
|
44049
|
+
for (const [key, value] of resolvedCache) {
|
|
44050
|
+
if (value.baseUrl === baseUrl) resolvedCache.delete(key);
|
|
44051
|
+
}
|
|
44052
|
+
}
|
|
44053
|
+
async function backendHealthy(baseUrl, expectedPath) {
|
|
44054
|
+
try {
|
|
44055
|
+
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
44056
|
+
if (health.status !== "ok") return false;
|
|
44057
|
+
if (expectedPath && health.projectPath) {
|
|
44058
|
+
return path4.resolve(health.projectPath) === path4.resolve(expectedPath);
|
|
44059
|
+
}
|
|
44060
|
+
return true;
|
|
44061
|
+
} catch {
|
|
44062
|
+
return false;
|
|
44063
|
+
}
|
|
44064
|
+
}
|
|
44065
|
+
async function waitForHealthy(baseUrl, name, expectedPath) {
|
|
44066
|
+
const deadline = Date.now() + HEALTH_TIMEOUT_MS;
|
|
44067
|
+
while (Date.now() < deadline) {
|
|
44068
|
+
if (await backendHealthy(baseUrl, expectedPath)) return;
|
|
44069
|
+
await new Promise((resolve) => setTimeout(resolve, HEALTH_POLL_INTERVAL_MS));
|
|
44070
|
+
}
|
|
44071
|
+
throw new Error(
|
|
44072
|
+
`Backend '${name}' on ${baseUrl} did not become healthy within ${HEALTH_TIMEOUT_MS / 1e3}s. Check daemon logs: repoburg logs ${name}`
|
|
44073
|
+
);
|
|
44074
|
+
}
|
|
44075
|
+
function serviceBaseUrl(service) {
|
|
44076
|
+
return `http://localhost:${service.port}`;
|
|
44077
|
+
}
|
|
44078
|
+
function coveringService(services, absPath) {
|
|
44079
|
+
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path4.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
44080
|
+
}
|
|
44081
|
+
async function restartService(daemon, name) {
|
|
44082
|
+
try {
|
|
44083
|
+
await fetchJson(`${daemon}/services/${name}/restart`, { method: "POST" });
|
|
44084
|
+
} catch (err) {
|
|
44085
|
+
throw new Error(`Daemon failed to restart backend '${name}': ${daemonErrorMessage(err)}`);
|
|
44086
|
+
}
|
|
44087
|
+
}
|
|
44088
|
+
async function startService(daemon, projectPath) {
|
|
44089
|
+
try {
|
|
44090
|
+
return await fetchJson(`${daemon}/services/start`, {
|
|
44091
|
+
method: "POST",
|
|
44092
|
+
headers: { "Content-Type": "application/json" },
|
|
44093
|
+
body: JSON.stringify({ path: projectPath })
|
|
44094
|
+
});
|
|
44095
|
+
} catch (err) {
|
|
44096
|
+
if (err instanceof HttpError && err.status === 401) throw new RepoburgSignInRequiredError(projectPath);
|
|
44097
|
+
throw new Error(`Daemon failed to start backend for ${projectPath}: ${daemonErrorMessage(err)}`);
|
|
44098
|
+
}
|
|
44099
|
+
}
|
|
44100
|
+
function cache(absPath, service) {
|
|
44101
|
+
const resolved = {
|
|
44102
|
+
baseUrl: serviceBaseUrl(service),
|
|
44103
|
+
port: service.port,
|
|
44104
|
+
name: service.name,
|
|
44105
|
+
servesPath: service.path
|
|
44106
|
+
};
|
|
44107
|
+
resolvedCache.set(absPath, resolved);
|
|
44108
|
+
return resolved;
|
|
44109
|
+
}
|
|
44110
|
+
async function resolveBackendUrl(projectPath, opts = {}) {
|
|
44111
|
+
const autoStart = opts.autoStart !== false;
|
|
44112
|
+
const envUrl = process.env.REPOBURG_BACKEND_URL;
|
|
44113
|
+
if (envUrl) {
|
|
44114
|
+
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
44115
|
+
}
|
|
44116
|
+
const absPath = path4.resolve(projectPath);
|
|
44117
|
+
const daemon = daemonBaseUrl();
|
|
44118
|
+
const cached3 = resolvedCache.get(absPath);
|
|
44119
|
+
if (cached3 && await backendHealthy(cached3.baseUrl, cached3.servesPath ?? absPath)) {
|
|
44120
|
+
return cached3;
|
|
44121
|
+
}
|
|
44122
|
+
try {
|
|
44123
|
+
await fetchJson(`${daemon}/health`, void 0, 3e3);
|
|
44124
|
+
} catch {
|
|
44125
|
+
throw new Error(
|
|
44126
|
+
`Repoburg daemon not reachable at ${daemon}. Start it with 'repoburg-daemon', or set REPOBURG_BACKEND_URL to a running backend.`
|
|
44127
|
+
);
|
|
44128
|
+
}
|
|
44129
|
+
const services = await fetchJson(`${daemon}/services`);
|
|
44130
|
+
const match = coveringService(services, absPath);
|
|
44131
|
+
if (match && match.status === "running") {
|
|
44132
|
+
if (await backendHealthy(serviceBaseUrl(match), match.path)) {
|
|
44133
|
+
return cache(absPath, match);
|
|
44134
|
+
}
|
|
44135
|
+
if (!autoStart) return null;
|
|
44136
|
+
await restartService(daemon, match.name);
|
|
44137
|
+
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
44138
|
+
return cache(absPath, match);
|
|
44139
|
+
}
|
|
44140
|
+
if (!autoStart) return null;
|
|
44141
|
+
if (match) {
|
|
44142
|
+
await restartService(daemon, match.name);
|
|
44143
|
+
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
44144
|
+
return cache(absPath, match);
|
|
44145
|
+
}
|
|
44146
|
+
const service = await startService(daemon, absPath);
|
|
44147
|
+
await waitForHealthy(serviceBaseUrl(service), service.name, absPath);
|
|
44148
|
+
return cache(absPath, service);
|
|
44149
|
+
}
|
|
44150
|
+
|
|
43992
44151
|
// src/routes/models.ts
|
|
43993
44152
|
function inferenceRuntime(id, reply) {
|
|
43994
44153
|
const provider = hasProvider(id) ? getProvider(id) : void 0;
|
|
@@ -44002,6 +44161,9 @@ function sendInferenceError(reply, error51) {
|
|
|
44002
44161
|
if (error51 instanceof InferenceCredentialsError) {
|
|
44003
44162
|
return reply.code(400).send({ error: error51.message });
|
|
44004
44163
|
}
|
|
44164
|
+
if (error51 instanceof RepoburgSignInRequiredError) {
|
|
44165
|
+
return reply.code(403).send({ error: error51.message, code: error51.code });
|
|
44166
|
+
}
|
|
44005
44167
|
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
44006
44168
|
return reply.code(503).send({ error: message });
|
|
44007
44169
|
}
|
|
@@ -44638,23 +44800,23 @@ import http from "node:http";
|
|
|
44638
44800
|
import net from "node:net";
|
|
44639
44801
|
import crypto from "node:crypto";
|
|
44640
44802
|
import os3 from "node:os";
|
|
44641
|
-
import
|
|
44803
|
+
import path5 from "node:path";
|
|
44642
44804
|
import { mkdir, readdir as readdir2, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
|
|
44643
|
-
var VSCODE_WEB_DATA_DIR =
|
|
44805
|
+
var VSCODE_WEB_DATA_DIR = path5.join(os3.homedir(), ".repoburg", "vscode-web");
|
|
44644
44806
|
function resolveDesktopUserDir() {
|
|
44645
44807
|
if (process.platform === "darwin") {
|
|
44646
|
-
return
|
|
44808
|
+
return path5.join(os3.homedir(), "Library", "Application Support", "Code", "User");
|
|
44647
44809
|
}
|
|
44648
44810
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
44649
|
-
return
|
|
44811
|
+
return path5.join(process.env.APPDATA, "Code", "User");
|
|
44650
44812
|
}
|
|
44651
44813
|
if (process.platform === "linux") {
|
|
44652
|
-
return
|
|
44814
|
+
return path5.join(os3.homedir(), ".config", "Code", "User");
|
|
44653
44815
|
}
|
|
44654
44816
|
return null;
|
|
44655
44817
|
}
|
|
44656
44818
|
async function linkUnlessExists(src, dst) {
|
|
44657
|
-
await mkdir(
|
|
44819
|
+
await mkdir(path5.dirname(dst), { recursive: true });
|
|
44658
44820
|
try {
|
|
44659
44821
|
await lstat(dst);
|
|
44660
44822
|
return false;
|
|
@@ -44669,19 +44831,19 @@ function fileRegistryUri(dir) {
|
|
|
44669
44831
|
}
|
|
44670
44832
|
async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
|
|
44671
44833
|
try {
|
|
44672
|
-
const desktopExt =
|
|
44834
|
+
const desktopExt = path5.join(os3.homedir(), ".vscode", "extensions");
|
|
44673
44835
|
let entries;
|
|
44674
44836
|
try {
|
|
44675
44837
|
entries = await readdir2(desktopExt, { withFileTypes: true });
|
|
44676
44838
|
} catch {
|
|
44677
44839
|
return;
|
|
44678
44840
|
}
|
|
44679
|
-
const serverExt =
|
|
44841
|
+
const serverExt = path5.join(dataDir, "extensions");
|
|
44680
44842
|
const linkedFolders = [];
|
|
44681
44843
|
for (const entry of entries) {
|
|
44682
44844
|
if (!entry.isDirectory()) continue;
|
|
44683
|
-
const target =
|
|
44684
|
-
await linkUnlessExists(
|
|
44845
|
+
const target = path5.join(serverExt, entry.name);
|
|
44846
|
+
await linkUnlessExists(path5.join(desktopExt, entry.name), target);
|
|
44685
44847
|
const st = await lstat(target).catch(() => null);
|
|
44686
44848
|
if (st?.isSymbolicLink()) linkedFolders.push(entry.name);
|
|
44687
44849
|
}
|
|
@@ -44689,15 +44851,15 @@ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
|
|
|
44689
44851
|
await pruneObsolete(serverExt, linkedFolders);
|
|
44690
44852
|
const desktopUser = resolveDesktopUserDir();
|
|
44691
44853
|
if (!desktopUser) return;
|
|
44692
|
-
const serverUser =
|
|
44854
|
+
const serverUser = path5.join(dataDir, "data", "User");
|
|
44693
44855
|
for (const item of ["settings.json", "keybindings.json", "snippets"]) {
|
|
44694
|
-
const src =
|
|
44856
|
+
const src = path5.join(desktopUser, item);
|
|
44695
44857
|
try {
|
|
44696
44858
|
await access(src);
|
|
44697
44859
|
} catch {
|
|
44698
44860
|
continue;
|
|
44699
44861
|
}
|
|
44700
|
-
await linkUnlessExists(src,
|
|
44862
|
+
await linkUnlessExists(src, path5.join(serverUser, item));
|
|
44701
44863
|
}
|
|
44702
44864
|
} catch {
|
|
44703
44865
|
}
|
|
@@ -44705,13 +44867,13 @@ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
|
|
|
44705
44867
|
async function mergeExtensionRegistry(desktopExt, serverExt, linkedFolders) {
|
|
44706
44868
|
let desktopEntries = [];
|
|
44707
44869
|
try {
|
|
44708
|
-
desktopEntries = JSON.parse(await readFile(
|
|
44870
|
+
desktopEntries = JSON.parse(await readFile(path5.join(desktopExt, "extensions.json"), "utf8"));
|
|
44709
44871
|
} catch {
|
|
44710
44872
|
return;
|
|
44711
44873
|
}
|
|
44712
44874
|
const linked = new Set(linkedFolders);
|
|
44713
44875
|
const toAdd = desktopEntries.filter((e) => e.identifier?.id && linked.has(e.relativeLocation));
|
|
44714
|
-
const serverRegistryPath =
|
|
44876
|
+
const serverRegistryPath = path5.join(serverExt, "extensions.json");
|
|
44715
44877
|
let serverEntries = [];
|
|
44716
44878
|
try {
|
|
44717
44879
|
serverEntries = JSON.parse(await readFile(serverRegistryPath, "utf8"));
|
|
@@ -44721,13 +44883,13 @@ async function mergeExtensionRegistry(desktopExt, serverExt, linkedFolders) {
|
|
|
44721
44883
|
const additions = toAdd.filter((e) => !known.has(`${e.identifier.id.toLowerCase()}@${e.version}`));
|
|
44722
44884
|
if (additions.length === 0) return;
|
|
44723
44885
|
for (const entry of additions) {
|
|
44724
|
-
const dir =
|
|
44886
|
+
const dir = path5.join(serverExt, entry.relativeLocation);
|
|
44725
44887
|
serverEntries.push({ ...entry, location: fileRegistryUri(dir) });
|
|
44726
44888
|
}
|
|
44727
44889
|
await writeFile(serverRegistryPath, JSON.stringify(serverEntries));
|
|
44728
44890
|
}
|
|
44729
44891
|
async function pruneObsolete(serverExt, linkedFolders) {
|
|
44730
|
-
const obsoletePath =
|
|
44892
|
+
const obsoletePath = path5.join(serverExt, ".obsolete");
|
|
44731
44893
|
let obsolete;
|
|
44732
44894
|
try {
|
|
44733
44895
|
obsolete = JSON.parse(await readFile(obsoletePath, "utf8"));
|
|
@@ -45186,15 +45348,15 @@ function proxyHandler(request, reply) {
|
|
|
45186
45348
|
|
|
45187
45349
|
// src/routes/apps.ts
|
|
45188
45350
|
import fs7 from "node:fs";
|
|
45189
|
-
import
|
|
45351
|
+
import path12 from "node:path";
|
|
45190
45352
|
|
|
45191
45353
|
// src/apps/instances.ts
|
|
45192
45354
|
import fs3 from "node:fs";
|
|
45193
|
-
import
|
|
45355
|
+
import path7 from "node:path";
|
|
45194
45356
|
|
|
45195
45357
|
// src/apps/apps-registry.ts
|
|
45196
45358
|
import fs2 from "node:fs";
|
|
45197
|
-
import
|
|
45359
|
+
import path6 from "node:path";
|
|
45198
45360
|
import os4 from "node:os";
|
|
45199
45361
|
import { fileURLToPath } from "node:url";
|
|
45200
45362
|
|
|
@@ -99419,10 +99581,10 @@ function setAppsRootOverride(root) {
|
|
|
99419
99581
|
rootOverride = root;
|
|
99420
99582
|
}
|
|
99421
99583
|
function appsRoot() {
|
|
99422
|
-
return rootOverride ?? process.env.AGENT_PANE_APPS_DIR ??
|
|
99584
|
+
return rootOverride ?? process.env.AGENT_PANE_APPS_DIR ?? path6.join(os4.homedir(), ".repoburg", "agent-pane", "apps");
|
|
99423
99585
|
}
|
|
99424
99586
|
function appDir(id) {
|
|
99425
|
-
return
|
|
99587
|
+
return path6.join(appsRoot(), id);
|
|
99426
99588
|
}
|
|
99427
99589
|
var examplesRootOverride = null;
|
|
99428
99590
|
function setExamplesRootOverride(root) {
|
|
@@ -99431,16 +99593,16 @@ function setExamplesRootOverride(root) {
|
|
|
99431
99593
|
function examplesRoot() {
|
|
99432
99594
|
if (examplesRootOverride) return examplesRootOverride;
|
|
99433
99595
|
if (process.env.AGENT_PANE_EXAMPLES_DIR) return process.env.AGENT_PANE_EXAMPLES_DIR;
|
|
99434
|
-
const here =
|
|
99435
|
-
for (const candidate of [
|
|
99596
|
+
const here = path6.dirname(fileURLToPath(import.meta.url));
|
|
99597
|
+
for (const candidate of [path6.resolve(here, "../../examples"), path6.resolve(here, "../../../examples")]) {
|
|
99436
99598
|
if (fs2.existsSync(candidate)) return candidate;
|
|
99437
99599
|
}
|
|
99438
99600
|
return null;
|
|
99439
99601
|
}
|
|
99440
99602
|
function isInAppFolder(cwd) {
|
|
99441
99603
|
if (!cwd) return false;
|
|
99442
|
-
const rel =
|
|
99443
|
-
return rel !== "" && !
|
|
99604
|
+
const rel = path6.relative(path6.resolve(appsRoot()), path6.resolve(cwd));
|
|
99605
|
+
return rel !== "" && !path6.isAbsolute(rel) && rel.split(path6.sep)[0] !== "..";
|
|
99444
99606
|
}
|
|
99445
99607
|
function appsConventions() {
|
|
99446
99608
|
return APPS_MD_SKELETON;
|
|
@@ -99449,7 +99611,7 @@ function ensureAppsRoot() {
|
|
|
99449
99611
|
const root = appsRoot();
|
|
99450
99612
|
fs2.mkdirSync(root, { recursive: true });
|
|
99451
99613
|
for (const name of ["CLAUDE.md", "AGENTS.md"]) {
|
|
99452
|
-
const file2 =
|
|
99614
|
+
const file2 = path6.join(root, name);
|
|
99453
99615
|
try {
|
|
99454
99616
|
if (fs2.existsSync(file2) && fs2.readFileSync(file2, "utf-8") === APPS_MD_FILE) continue;
|
|
99455
99617
|
fs2.writeFileSync(file2, APPS_MD_FILE);
|
|
@@ -99714,7 +99876,7 @@ folder's own CLAUDE.md / AGENTS.md. -->
|
|
|
99714
99876
|
${APPS_MD_SKELETON}`;
|
|
99715
99877
|
function readManifestIn(dir) {
|
|
99716
99878
|
try {
|
|
99717
|
-
const raw = fs2.readFileSync(
|
|
99879
|
+
const raw = fs2.readFileSync(path6.join(dir, "manifest.json"), "utf-8");
|
|
99718
99880
|
const parsed = JSON.parse(raw);
|
|
99719
99881
|
if (!parsed || typeof parsed.title !== "string") return null;
|
|
99720
99882
|
return {
|
|
@@ -99741,7 +99903,7 @@ function readManifest(id) {
|
|
|
99741
99903
|
}
|
|
99742
99904
|
function readAppFile(id, name) {
|
|
99743
99905
|
try {
|
|
99744
|
-
return fs2.readFileSync(
|
|
99906
|
+
return fs2.readFileSync(path6.join(appDir(id), name), "utf-8");
|
|
99745
99907
|
} catch {
|
|
99746
99908
|
return "";
|
|
99747
99909
|
}
|
|
@@ -99774,11 +99936,11 @@ function startAppsWatch(onAppChange) {
|
|
|
99774
99936
|
try {
|
|
99775
99937
|
watcher = fs2.watch(root, { recursive: true }, (_event, filename) => {
|
|
99776
99938
|
const rel = String(filename ?? "");
|
|
99777
|
-
const segs = rel.split(
|
|
99939
|
+
const segs = rel.split(path6.sep);
|
|
99778
99940
|
const appId = segs[0];
|
|
99779
99941
|
const file2 = segs[segs.length - 1];
|
|
99780
|
-
if (!appId || appId ===
|
|
99781
|
-
if (segs.length === 1 && isRegularFile(
|
|
99942
|
+
if (!appId || appId === path6.basename(root) || !APP_ID_RE.test(appId) || file2 === "state.json") return;
|
|
99943
|
+
if (segs.length === 1 && isRegularFile(path6.join(root, appId))) return;
|
|
99782
99944
|
const timer3 = pendingChanges.get(appId);
|
|
99783
99945
|
if (timer3) clearTimeout(timer3);
|
|
99784
99946
|
pendingChanges.set(
|
|
@@ -99849,7 +100011,7 @@ function getInstanceState(appId, workspace = "") {
|
|
|
99849
100011
|
const stored = readRow(appId, workspace);
|
|
99850
100012
|
if (stored) return stored;
|
|
99851
100013
|
if (workspace === "") {
|
|
99852
|
-
const legacyFile =
|
|
100014
|
+
const legacyFile = path7.join(appDir(appId), "state.json");
|
|
99853
100015
|
if (fs3.existsSync(legacyFile)) {
|
|
99854
100016
|
const legacy = readState(appId);
|
|
99855
100017
|
const imported = { pinned: legacy.pinned, data: legacy.data, version: 1 };
|
|
@@ -99882,9 +100044,9 @@ function resolveToolWorkspace(workspace) {
|
|
|
99882
100044
|
const rows = getDb().prepare("SELECT path, deleted FROM workspaces").all();
|
|
99883
100045
|
const active = rows.filter((w) => !w.deleted).map((w) => w.path);
|
|
99884
100046
|
if (active.includes(workspace)) return workspace;
|
|
99885
|
-
const cwd =
|
|
100047
|
+
const cwd = path7.isAbsolute(workspace) ? path7.resolve(workspace) : "";
|
|
99886
100048
|
if (isInAppFolder(cwd)) return "";
|
|
99887
|
-
const covering = rows.filter((w) => cwd === w.path || cwd.startsWith(w.path +
|
|
100049
|
+
const covering = rows.filter((w) => cwd === w.path || cwd.startsWith(w.path + path7.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
99888
100050
|
if (covering && !covering.deleted) return covering.path;
|
|
99889
100051
|
throw new Error(`Unknown workspace: ${workspace}. Known workspaces: ${active.join(", ") || "none"}`);
|
|
99890
100052
|
}
|
|
@@ -99911,7 +100073,7 @@ function importAppInstances(appId, instances) {
|
|
|
99911
100073
|
import fs5 from "node:fs";
|
|
99912
100074
|
|
|
99913
100075
|
// src/apps/app-sessions.ts
|
|
99914
|
-
import
|
|
100076
|
+
import path9 from "node:path";
|
|
99915
100077
|
|
|
99916
100078
|
// src/sidecar/transcript-locator.ts
|
|
99917
100079
|
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
@@ -99997,7 +100159,7 @@ function locateTranscriptCached(session) {
|
|
|
99997
100159
|
import crypto2 from "node:crypto";
|
|
99998
100160
|
import fs4 from "node:fs";
|
|
99999
100161
|
import os5 from "node:os";
|
|
100000
|
-
import
|
|
100162
|
+
import path8 from "node:path";
|
|
100001
100163
|
var APP_FILE_MAX_BYTES = 5 * 1024 * 1024;
|
|
100002
100164
|
var APP_FILE_TYPES = {
|
|
100003
100165
|
"image/png": "png",
|
|
@@ -100022,11 +100184,11 @@ function setAppFilesRootOverride(root) {
|
|
|
100022
100184
|
rootOverride2 = root;
|
|
100023
100185
|
}
|
|
100024
100186
|
function appFilesRoot() {
|
|
100025
|
-
return rootOverride2 ?? process.env.AGENT_PANE_APP_FILES_DIR ??
|
|
100187
|
+
return rootOverride2 ?? process.env.AGENT_PANE_APP_FILES_DIR ?? path8.join(os5.homedir(), ".repoburg", "agent-pane", "app-files");
|
|
100026
100188
|
}
|
|
100027
100189
|
function appFilesDir(appId) {
|
|
100028
100190
|
if (!APP_ID_RE.test(appId)) throw new AppFileError("Invalid app id", 400);
|
|
100029
|
-
return
|
|
100191
|
+
return path8.join(appFilesRoot(), appId);
|
|
100030
100192
|
}
|
|
100031
100193
|
function appFileUrl(appId, fileId) {
|
|
100032
100194
|
return `/api/apps/${appId}/files/${fileId}`;
|
|
@@ -100087,7 +100249,7 @@ function saveAppFile(appId, upload) {
|
|
|
100087
100249
|
const type = sniffImageType(bytes);
|
|
100088
100250
|
if (!type) throw new AppFileError(`The file is not a ${ACCEPTED} image`, 400);
|
|
100089
100251
|
const fileId = `${crypto2.createHash("sha256").update(bytes).digest("hex")}.${APP_FILE_TYPES[type]}`;
|
|
100090
|
-
const file2 =
|
|
100252
|
+
const file2 = path8.join(dir, fileId);
|
|
100091
100253
|
if (!fs4.existsSync(file2)) {
|
|
100092
100254
|
fs4.mkdirSync(dir, { recursive: true });
|
|
100093
100255
|
const tmp = `${file2}.${process.pid}.${crypto2.randomBytes(4).toString("hex")}.tmp`;
|
|
@@ -100119,7 +100281,7 @@ function getAppFile(appId, ref) {
|
|
|
100119
100281
|
if (!APP_ID_RE.test(appId)) return null;
|
|
100120
100282
|
const fileId = appFileRefId(appId, ref);
|
|
100121
100283
|
if (!fileId) return null;
|
|
100122
|
-
const file2 =
|
|
100284
|
+
const file2 = path8.join(appFilesDir(appId), fileId);
|
|
100123
100285
|
try {
|
|
100124
100286
|
const stat2 = fs4.statSync(file2);
|
|
100125
100287
|
if (!stat2.isFile()) return null;
|
|
@@ -100131,7 +100293,7 @@ function getAppFile(appId, ref) {
|
|
|
100131
100293
|
function readAppFileData(appId, fileId) {
|
|
100132
100294
|
if (!APP_ID_RE.test(appId) || !APP_FILE_ID_RE.test(fileId)) return null;
|
|
100133
100295
|
try {
|
|
100134
|
-
return { bytes: fs4.readFileSync(
|
|
100296
|
+
return { bytes: fs4.readFileSync(path8.join(appFilesDir(appId), fileId)), type: fileType(fileId) };
|
|
100135
100297
|
} catch {
|
|
100136
100298
|
return null;
|
|
100137
100299
|
}
|
|
@@ -100159,7 +100321,7 @@ function writeImportedAppFiles(appId, files) {
|
|
|
100159
100321
|
const dir = appFilesDir(appId);
|
|
100160
100322
|
fs4.mkdirSync(dir, { recursive: true });
|
|
100161
100323
|
for (const [fileId, bytes] of files) {
|
|
100162
|
-
const file2 =
|
|
100324
|
+
const file2 = path8.join(dir, fileId);
|
|
100163
100325
|
if (!fs4.existsSync(file2)) fs4.writeFileSync(file2, bytes);
|
|
100164
100326
|
}
|
|
100165
100327
|
}
|
|
@@ -100264,7 +100426,7 @@ function appSessionInfo(appId, sessionId) {
|
|
|
100264
100426
|
function sessionVisibleTo(session, appId, workspace) {
|
|
100265
100427
|
if (!workspace) return true;
|
|
100266
100428
|
const cwd = session.cwd;
|
|
100267
|
-
if (cwd && (cwd === workspace || cwd.startsWith(workspace.endsWith(
|
|
100429
|
+
if (cwd && (cwd === workspace || cwd.startsWith(workspace.endsWith(path9.sep) ? workspace : workspace + path9.sep))) {
|
|
100268
100430
|
return true;
|
|
100269
100431
|
}
|
|
100270
100432
|
return session.origin_app_workspace === workspace && openedByApp(session, appId);
|
|
@@ -100484,7 +100646,7 @@ function stopAppAlarms() {
|
|
|
100484
100646
|
|
|
100485
100647
|
// src/apps/app-compile.ts
|
|
100486
100648
|
import vm from "node:vm";
|
|
100487
|
-
import
|
|
100649
|
+
import path10 from "node:path";
|
|
100488
100650
|
import ts from "typescript";
|
|
100489
100651
|
|
|
100490
100652
|
// src/apps/app-lint.ts
|
|
@@ -100790,10 +100952,10 @@ declare const AgentPane: {
|
|
|
100790
100952
|
fileUrl(ref: AgentPaneFileRef): string;
|
|
100791
100953
|
};
|
|
100792
100954
|
`;
|
|
100793
|
-
var
|
|
100955
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
100794
100956
|
function invalidateCompiledApp(appId) {
|
|
100795
|
-
if (!appId)
|
|
100796
|
-
else
|
|
100957
|
+
if (!appId) cache2.clear();
|
|
100958
|
+
else cache2.delete(appId);
|
|
100797
100959
|
}
|
|
100798
100960
|
function tsDiagnosticToFile(file2, d) {
|
|
100799
100961
|
if (!d.file) return null;
|
|
@@ -100913,15 +101075,15 @@ function typeCheckModules(appId, modules) {
|
|
|
100913
101075
|
};
|
|
100914
101076
|
const host = ts.createCompilerHost(options);
|
|
100915
101077
|
const origReadFile = host.readFile.bind(host);
|
|
100916
|
-
host.readFile = (fname) =>
|
|
101078
|
+
host.readFile = (fname) => path10.basename(fname) === BRIDGE_DTS_FILE ? BRIDGE_DTS : origReadFile(fname);
|
|
100917
101079
|
host.writeFile = () => {
|
|
100918
101080
|
};
|
|
100919
|
-
const bridgePath =
|
|
100920
|
-
const rootNames = [...modules.map((m) =>
|
|
101081
|
+
const bridgePath = path10.join(dir, BRIDGE_DTS_FILE);
|
|
101082
|
+
const rootNames = [...modules.map((m) => path10.join(dir, m.file)), bridgePath];
|
|
100921
101083
|
const program = ts.createProgram(rootNames, options, host);
|
|
100922
101084
|
const out = [];
|
|
100923
101085
|
for (const mod of modules) {
|
|
100924
|
-
const sf = program.getSourceFile(
|
|
101086
|
+
const sf = program.getSourceFile(path10.join(dir, mod.file));
|
|
100925
101087
|
if (!sf) continue;
|
|
100926
101088
|
out.push(
|
|
100927
101089
|
...[...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)].map((d) => tsDiagnosticToFile(mod.file, d)).filter((d) => d !== null)
|
|
@@ -100948,7 +101110,7 @@ function checkJsSyntax(js) {
|
|
|
100948
101110
|
}
|
|
100949
101111
|
}
|
|
100950
101112
|
function compileAppJs(appId) {
|
|
100951
|
-
const cached3 =
|
|
101113
|
+
const cached3 = cache2.get(appId);
|
|
100952
101114
|
if (cached3) return cached3;
|
|
100953
101115
|
const tsSource = readAppFile(appId, APP_TS);
|
|
100954
101116
|
let result;
|
|
@@ -100996,7 +101158,7 @@ function compileAppJs(appId) {
|
|
|
100996
101158
|
readManifest(appId)?.icon
|
|
100997
101159
|
)
|
|
100998
101160
|
);
|
|
100999
|
-
|
|
101161
|
+
cache2.set(appId, result);
|
|
101000
101162
|
return result;
|
|
101001
101163
|
}
|
|
101002
101164
|
|
|
@@ -101498,7 +101660,7 @@ function anyAppHasTools() {
|
|
|
101498
101660
|
|
|
101499
101661
|
// src/apps/app-zip.ts
|
|
101500
101662
|
import fs6 from "node:fs";
|
|
101501
|
-
import
|
|
101663
|
+
import path11 from "node:path";
|
|
101502
101664
|
|
|
101503
101665
|
// src/apps/zip.ts
|
|
101504
101666
|
import zlib from "node:zlib";
|
|
@@ -101670,7 +101832,7 @@ function collectAppFiles(id) {
|
|
|
101670
101832
|
if (isSkipped(entry.name)) continue;
|
|
101671
101833
|
const relPath = rel ? `${rel}/${entry.name}` : entry.name;
|
|
101672
101834
|
if (!rel && entry.name === "state.json") continue;
|
|
101673
|
-
const full =
|
|
101835
|
+
const full = path11.join(dir, entry.name);
|
|
101674
101836
|
if (entry.isDirectory()) walk(full, relPath);
|
|
101675
101837
|
else if (entry.isFile()) out.push({ name: `${id}/${relPath}`, data: fs6.readFileSync(full) });
|
|
101676
101838
|
}
|
|
@@ -101686,7 +101848,7 @@ function collectAppData(id) {
|
|
|
101686
101848
|
for (const fileId of listAppFileIds(id)) {
|
|
101687
101849
|
out.push({
|
|
101688
101850
|
name: `${id}/${APP_DATA_DIR}/files/${fileId}`,
|
|
101689
|
-
data: fs6.readFileSync(
|
|
101851
|
+
data: fs6.readFileSync(path11.join(appFilesDir(id), fileId))
|
|
101690
101852
|
});
|
|
101691
101853
|
}
|
|
101692
101854
|
return out;
|
|
@@ -101713,7 +101875,7 @@ function parseAppData(entries) {
|
|
|
101713
101875
|
const instances = doc.instances.map((item) => {
|
|
101714
101876
|
const inst = item;
|
|
101715
101877
|
const workspace = inst && typeof inst.workspace === "string" ? inst.workspace : null;
|
|
101716
|
-
const valid = workspace !== null && (workspace === "" ||
|
|
101878
|
+
const valid = workspace !== null && (workspace === "" || path11.isAbsolute(workspace)) && !seen.has(workspace) && (inst.data === null || typeof inst.data === "object" && !Array.isArray(inst.data));
|
|
101717
101879
|
if (!valid) throw new AppZipError(`${APP_DATA_DIR}/data.json has an invalid instance`, 400);
|
|
101718
101880
|
seen.add(workspace);
|
|
101719
101881
|
return { workspace, pinned: inst.pinned === true, data: inst.data };
|
|
@@ -101802,7 +101964,7 @@ function rehomeInstances(data, id) {
|
|
|
101802
101964
|
const newDir = appFilesDir(id);
|
|
101803
101965
|
const oldDir = data.filesDir?.replace(/[\\/]+$/, "");
|
|
101804
101966
|
if (oldDir && oldDir !== newDir) {
|
|
101805
|
-
swaps.push([`${oldDir}/`, `${newDir}${
|
|
101967
|
+
swaps.push([`${oldDir}/`, `${newDir}${path11.sep}`], [`${oldDir}\\`, `${newDir}${path11.sep}`]);
|
|
101806
101968
|
}
|
|
101807
101969
|
if (swaps.length === 0) return data.instances;
|
|
101808
101970
|
const replace = (s) => swaps.reduce((out, [from, to]) => out.split(from).join(to), s);
|
|
@@ -101816,15 +101978,15 @@ function importAppZip(id, buf, opts = {}) {
|
|
|
101816
101978
|
if (readManifest(id) || fs6.existsSync(appDir(id))) throw new AppZipError("App already exists", 409);
|
|
101817
101979
|
const withData = opts.data ? data : null;
|
|
101818
101980
|
ensureAppsRoot();
|
|
101819
|
-
const tmp =
|
|
101981
|
+
const tmp = path11.join(appsRoot(), `.import-${v4_default()}`);
|
|
101820
101982
|
try {
|
|
101821
101983
|
for (const [rel, bytes] of files) {
|
|
101822
|
-
const file2 =
|
|
101823
|
-
fs6.mkdirSync(
|
|
101984
|
+
const file2 = path11.join(tmp, ...rel.split("/"));
|
|
101985
|
+
fs6.mkdirSync(path11.dirname(file2), { recursive: true });
|
|
101824
101986
|
fs6.writeFileSync(file2, bytes);
|
|
101825
101987
|
}
|
|
101826
101988
|
if (!files.has("manifest.json")) {
|
|
101827
|
-
fs6.writeFileSync(
|
|
101989
|
+
fs6.writeFileSync(path11.join(tmp, "manifest.json"), JSON.stringify({ title: id }, null, 2));
|
|
101828
101990
|
} else if (!readManifestIn(tmp)) {
|
|
101829
101991
|
throw new AppZipError('manifest.json is invalid (it needs at least a "title" string)', 400);
|
|
101830
101992
|
}
|
|
@@ -101936,7 +102098,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101936
102098
|
try {
|
|
101937
102099
|
for (const entry of fs7.readdirSync(exRoot, { withFileTypes: true })) {
|
|
101938
102100
|
if (!entry.isDirectory() || !APP_ID_RE.test(entry.name)) continue;
|
|
101939
|
-
const manifest = readManifestIn(
|
|
102101
|
+
const manifest = readManifestIn(path12.join(exRoot, entry.name));
|
|
101940
102102
|
if (!manifest) continue;
|
|
101941
102103
|
out.push({
|
|
101942
102104
|
id: entry.name,
|
|
@@ -101957,7 +102119,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101957
102119
|
if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
|
|
101958
102120
|
const exRoot = examplesRoot();
|
|
101959
102121
|
if (!exRoot) return reply.code(404).send({ error: "Examples catalog not available" });
|
|
101960
|
-
const src =
|
|
102122
|
+
const src = path12.join(exRoot, id);
|
|
101961
102123
|
if (!readManifestIn(src)) return reply.code(404).send({ error: "Example not found" });
|
|
101962
102124
|
if (readManifest(id)) return reply.code(409).send({ error: "App already installed" });
|
|
101963
102125
|
ensureAppsRoot();
|
|
@@ -101996,7 +102158,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101996
102158
|
fs7.mkdirSync(dir, { recursive: true });
|
|
101997
102159
|
const cleanTitle2 = title.trim();
|
|
101998
102160
|
fs7.writeFileSync(
|
|
101999
|
-
|
|
102161
|
+
path12.join(dir, "manifest.json"),
|
|
102000
102162
|
JSON.stringify(
|
|
102001
102163
|
{
|
|
102002
102164
|
title: cleanTitle2,
|
|
@@ -102007,8 +102169,8 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
102007
102169
|
2
|
|
102008
102170
|
)
|
|
102009
102171
|
);
|
|
102010
|
-
fs7.writeFileSync(
|
|
102011
|
-
fs7.writeFileSync(
|
|
102172
|
+
fs7.writeFileSync(path12.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
|
|
102173
|
+
fs7.writeFileSync(path12.join(dir, "app.ts"), SKELETON_TS);
|
|
102012
102174
|
return { ok: true, id };
|
|
102013
102175
|
}
|
|
102014
102176
|
);
|
|
@@ -102572,16 +102734,16 @@ async function loadFresh(timezone) {
|
|
|
102572
102734
|
]);
|
|
102573
102735
|
return { data: parseCcusageJson(stdout), generatedAt: Date.now() };
|
|
102574
102736
|
}
|
|
102575
|
-
var
|
|
102737
|
+
var cache3 = /* @__PURE__ */ new Map();
|
|
102576
102738
|
var inflight = /* @__PURE__ */ new Map();
|
|
102577
102739
|
function loadCcusage(timezone, fresh) {
|
|
102578
|
-
const cached3 =
|
|
102740
|
+
const cached3 = cache3.get(timezone);
|
|
102579
102741
|
if (cached3 && !fresh) return Promise.resolve(cached3);
|
|
102580
102742
|
let run = inflight.get(timezone);
|
|
102581
102743
|
if (!run) {
|
|
102582
102744
|
run = loadFresh(timezone).then((result) => {
|
|
102583
|
-
if (
|
|
102584
|
-
|
|
102745
|
+
if (cache3.size >= 4) cache3.clear();
|
|
102746
|
+
cache3.set(timezone, result);
|
|
102585
102747
|
return result;
|
|
102586
102748
|
}).finally(() => inflight.delete(timezone));
|
|
102587
102749
|
inflight.set(timezone, run);
|
|
@@ -102986,7 +103148,7 @@ async function registerUsageRoutes(fastify) {
|
|
|
102986
103148
|
|
|
102987
103149
|
// src/claude/session-import.ts
|
|
102988
103150
|
import { readFile as readFile2, realpath } from "node:fs/promises";
|
|
102989
|
-
import
|
|
103151
|
+
import path13 from "node:path";
|
|
102990
103152
|
import { getSessionInfo, listSessions } from "@anthropic-ai/claude-agent-sdk";
|
|
102991
103153
|
|
|
102992
103154
|
// src/claude/widget-tool.ts
|
|
@@ -118031,7 +118193,7 @@ async function realDir(dir) {
|
|
|
118031
118193
|
}
|
|
118032
118194
|
}
|
|
118033
118195
|
async function sameDir(a, realB) {
|
|
118034
|
-
const realA = await realDir(a) ??
|
|
118196
|
+
const realA = await realDir(a) ?? path13.resolve(a);
|
|
118035
118197
|
return realA === realB;
|
|
118036
118198
|
}
|
|
118037
118199
|
function knownClaudeSessionIds(db2) {
|
|
@@ -118201,22 +118363,22 @@ async function registerClaudeSessionRoutes(fastify) {
|
|
|
118201
118363
|
|
|
118202
118364
|
// src/codex/session-import.ts
|
|
118203
118365
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
118204
|
-
import
|
|
118366
|
+
import path15 from "node:path";
|
|
118205
118367
|
|
|
118206
118368
|
// src/apps/register-mcp.ts
|
|
118207
118369
|
import fs8 from "node:fs";
|
|
118208
|
-
import
|
|
118370
|
+
import path14 from "node:path";
|
|
118209
118371
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
118210
118372
|
var MCP_SERVER_NAME = "agentpane-miniapps";
|
|
118211
118373
|
function panePublicUrl() {
|
|
118212
118374
|
return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
118213
118375
|
}
|
|
118214
118376
|
function stdioScriptPath() {
|
|
118215
|
-
const here =
|
|
118377
|
+
const here = path14.dirname(fileURLToPath2(import.meta.url));
|
|
118216
118378
|
const candidates = [
|
|
118217
|
-
|
|
118379
|
+
path14.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
|
|
118218
118380
|
// src/apps/ → backend/scripts
|
|
118219
|
-
|
|
118381
|
+
path14.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
|
|
118220
118382
|
// dist bundle → backend/scripts
|
|
118221
118383
|
];
|
|
118222
118384
|
for (const candidate of candidates) {
|
|
@@ -118475,7 +118637,7 @@ async function realDir2(dir) {
|
|
|
118475
118637
|
async function workspaceDirs(workspacePath) {
|
|
118476
118638
|
const real = await realDir2(workspacePath);
|
|
118477
118639
|
if (!real) return null;
|
|
118478
|
-
const given =
|
|
118640
|
+
const given = path15.resolve(workspacePath);
|
|
118479
118641
|
return given === real ? [real] : [given, real];
|
|
118480
118642
|
}
|
|
118481
118643
|
function titleOf2(thread) {
|
|
@@ -118715,7 +118877,7 @@ async function registerCodexSessionRoutes(fastify) {
|
|
|
118715
118877
|
|
|
118716
118878
|
// src/session-host/flags.ts
|
|
118717
118879
|
import fs9 from "node:fs";
|
|
118718
|
-
import
|
|
118880
|
+
import path16 from "node:path";
|
|
118719
118881
|
var DEFAULT_FLAGS = {
|
|
118720
118882
|
claude: true,
|
|
118721
118883
|
codex: true,
|
|
@@ -118734,13 +118896,13 @@ function setPaneDataDir(dir) {
|
|
|
118734
118896
|
}
|
|
118735
118897
|
function sessionHostsRoot() {
|
|
118736
118898
|
const override = process.env.AGENT_PANE_SESSION_HOSTS_DIR;
|
|
118737
|
-
if (override) return
|
|
118738
|
-
return paneDataDir ?
|
|
118899
|
+
if (override) return path16.resolve(override);
|
|
118900
|
+
return paneDataDir ? path16.join(paneDataDir, "session-hosts") : null;
|
|
118739
118901
|
}
|
|
118740
118902
|
function flagsFilePath() {
|
|
118741
118903
|
const root = sessionHostsRoot();
|
|
118742
|
-
if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return
|
|
118743
|
-
return paneDataDir ?
|
|
118904
|
+
if (process.env.AGENT_PANE_SESSION_HOSTS_DIR) return path16.join(path16.dirname(root), "session-hosts.json");
|
|
118905
|
+
return paneDataDir ? path16.join(paneDataDir, "session-hosts.json") : null;
|
|
118744
118906
|
}
|
|
118745
118907
|
function readFlagFile(file2) {
|
|
118746
118908
|
if (!file2) return {};
|
|
@@ -118812,7 +118974,7 @@ var LOG_HEADER_LEN = LOG_HEADER_PREFIX.length + LOG_HEADER_DIGITS + 1;
|
|
|
118812
118974
|
// src/session-host/registry.ts
|
|
118813
118975
|
import { randomBytes, randomUUID as randomUUID2 } from "node:crypto";
|
|
118814
118976
|
import fs11 from "node:fs";
|
|
118815
|
-
import
|
|
118977
|
+
import path18 from "node:path";
|
|
118816
118978
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
118817
118979
|
|
|
118818
118980
|
// src/session-host/client.ts
|
|
@@ -118820,7 +118982,7 @@ import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
|
|
|
118820
118982
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
118821
118983
|
import fs10 from "node:fs";
|
|
118822
118984
|
import net2 from "node:net";
|
|
118823
|
-
import
|
|
118985
|
+
import path17 from "node:path";
|
|
118824
118986
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
118825
118987
|
var HostRequestError = class extends Error {
|
|
118826
118988
|
reply;
|
|
@@ -118832,11 +118994,11 @@ var HostRequestError = class extends Error {
|
|
|
118832
118994
|
function hostScriptPath() {
|
|
118833
118995
|
const override = process.env.AGENT_PANE_SESSION_HOST_SCRIPT;
|
|
118834
118996
|
if (override) return override;
|
|
118835
|
-
const here =
|
|
118997
|
+
const here = path17.dirname(fileURLToPath3(import.meta.url));
|
|
118836
118998
|
const candidates = [
|
|
118837
|
-
|
|
118999
|
+
path17.resolve(here, "../../scripts/session-host.mjs"),
|
|
118838
119000
|
// src/session-host/ → backend/scripts
|
|
118839
|
-
|
|
119001
|
+
path17.resolve(here, "../scripts/session-host.mjs")
|
|
118840
119002
|
// dist bundle → backend/scripts
|
|
118841
119003
|
];
|
|
118842
119004
|
for (const candidate of candidates) {
|
|
@@ -118845,10 +119007,10 @@ function hostScriptPath() {
|
|
|
118845
119007
|
return null;
|
|
118846
119008
|
}
|
|
118847
119009
|
function hostSocketPath(dir) {
|
|
118848
|
-
const direct =
|
|
119010
|
+
const direct = path17.join(dir, "sock");
|
|
118849
119011
|
if (Buffer.byteLength(direct) < 100) return direct;
|
|
118850
119012
|
const uid = typeof process.getuid === "function" ? process.getuid() : 0;
|
|
118851
|
-
return
|
|
119013
|
+
return path17.join("/tmp", `rbsh-${uid}`, path17.basename(dir), "sock");
|
|
118852
119014
|
}
|
|
118853
119015
|
function readJson(file2) {
|
|
118854
119016
|
try {
|
|
@@ -118858,10 +119020,10 @@ function readJson(file2) {
|
|
|
118858
119020
|
}
|
|
118859
119021
|
}
|
|
118860
119022
|
function readHostExit(dir) {
|
|
118861
|
-
return readJson(
|
|
119023
|
+
return readJson(path17.join(dir, "exit.json"));
|
|
118862
119024
|
}
|
|
118863
119025
|
function readHostChild(dir) {
|
|
118864
|
-
return readJson(
|
|
119026
|
+
return readJson(path17.join(dir, "child.json"));
|
|
118865
119027
|
}
|
|
118866
119028
|
function isPidAlive(pid) {
|
|
118867
119029
|
if (!pid || pid <= 0) return false;
|
|
@@ -119051,7 +119213,7 @@ async function waitForHost(dir, timeoutMs = 1e4) {
|
|
|
119051
119213
|
function readLogOldest(dir) {
|
|
119052
119214
|
let fd = null;
|
|
119053
119215
|
try {
|
|
119054
|
-
fd = fs10.openSync(
|
|
119216
|
+
fd = fs10.openSync(path17.join(dir, "out.log"), "r");
|
|
119055
119217
|
const buf = Buffer.alloc(LOG_HEADER_LEN);
|
|
119056
119218
|
const n = fs10.readSync(fd, buf, 0, LOG_HEADER_LEN, 0);
|
|
119057
119219
|
const text2 = buf.subarray(0, n).toString("utf8");
|
|
@@ -119068,7 +119230,7 @@ function readHostLog(dir, after) {
|
|
|
119068
119230
|
const oldest = readLogOldest(dir);
|
|
119069
119231
|
if (oldest === null || after < oldest) return null;
|
|
119070
119232
|
try {
|
|
119071
|
-
const all = fs10.readFileSync(
|
|
119233
|
+
const all = fs10.readFileSync(path17.join(dir, "out.log"));
|
|
119072
119234
|
const start = LOG_HEADER_LEN + (after - oldest);
|
|
119073
119235
|
if (start > all.length) return null;
|
|
119074
119236
|
return all.subarray(start);
|
|
@@ -119082,7 +119244,7 @@ function removeHostDir(dir) {
|
|
|
119082
119244
|
} catch (err) {
|
|
119083
119245
|
console.error(`[session-host] could not remove ${dir}:`, err.message);
|
|
119084
119246
|
}
|
|
119085
|
-
const alias =
|
|
119247
|
+
const alias = path17.dirname(hostSocketPath(dir));
|
|
119086
119248
|
if (alias !== dir) {
|
|
119087
119249
|
try {
|
|
119088
119250
|
fs10.unlinkSync(alias);
|
|
@@ -119145,16 +119307,16 @@ function newHostDir() {
|
|
|
119145
119307
|
const root = sessionHostsRoot();
|
|
119146
119308
|
if (!root) throw new Error("session hosts have no directory");
|
|
119147
119309
|
const id = randomBytes(8).toString("hex");
|
|
119148
|
-
return { id, dir:
|
|
119310
|
+
return { id, dir: path18.join(root, id) };
|
|
119149
119311
|
}
|
|
119150
119312
|
var cachedVersion;
|
|
119151
119313
|
function runtimeVersion() {
|
|
119152
119314
|
if (cachedVersion !== void 0) return cachedVersion;
|
|
119153
119315
|
cachedVersion = null;
|
|
119154
|
-
const here =
|
|
119316
|
+
const here = path18.dirname(fileURLToPath4(import.meta.url));
|
|
119155
119317
|
for (const rel of ["../../../../package.json", "../../../package.json"]) {
|
|
119156
119318
|
try {
|
|
119157
|
-
const pkg = JSON.parse(fs11.readFileSync(
|
|
119319
|
+
const pkg = JSON.parse(fs11.readFileSync(path18.resolve(here, rel), "utf8"));
|
|
119158
119320
|
if (pkg.name === "repoburg" && pkg.version) {
|
|
119159
119321
|
cachedVersion = pkg.version;
|
|
119160
119322
|
break;
|
|
@@ -119167,13 +119329,13 @@ function runtimeVersion() {
|
|
|
119167
119329
|
function writeHostMeta(dir, meta3) {
|
|
119168
119330
|
fs11.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
119169
119331
|
fs11.chmodSync(dir, 448);
|
|
119170
|
-
const tmp =
|
|
119332
|
+
const tmp = path18.join(dir, "meta.json.tmp");
|
|
119171
119333
|
fs11.writeFileSync(tmp, JSON.stringify(meta3, null, 2) + "\n", { mode: 384 });
|
|
119172
|
-
fs11.renameSync(tmp,
|
|
119334
|
+
fs11.renameSync(tmp, path18.join(dir, "meta.json"));
|
|
119173
119335
|
}
|
|
119174
119336
|
function readHostMeta(dir) {
|
|
119175
119337
|
try {
|
|
119176
|
-
return JSON.parse(fs11.readFileSync(
|
|
119338
|
+
return JSON.parse(fs11.readFileSync(path18.join(dir, "meta.json"), "utf8"));
|
|
119177
119339
|
} catch {
|
|
119178
119340
|
return null;
|
|
119179
119341
|
}
|
|
@@ -119318,7 +119480,7 @@ async function adoptHosts(db2, root, adoption, result) {
|
|
|
119318
119480
|
const seen = /* @__PURE__ */ new Set();
|
|
119319
119481
|
const queue = [];
|
|
119320
119482
|
for (const id of entries) {
|
|
119321
|
-
const dir =
|
|
119483
|
+
const dir = path18.join(root, id);
|
|
119322
119484
|
try {
|
|
119323
119485
|
if (!fs11.statSync(dir).isDirectory()) continue;
|
|
119324
119486
|
} catch {
|
|
@@ -119886,7 +120048,7 @@ function mapTokenUsage(data) {
|
|
|
119886
120048
|
import { spawn as spawn6 } from "node:child_process";
|
|
119887
120049
|
import fs12 from "node:fs";
|
|
119888
120050
|
import os6 from "node:os";
|
|
119889
|
-
import
|
|
120051
|
+
import path19 from "node:path";
|
|
119890
120052
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
119891
120053
|
var TABTAPE_MCP_NAME = "tabtape";
|
|
119892
120054
|
var PLAYWRIGHT_MCP_NAME = "playwright";
|
|
@@ -119900,15 +120062,15 @@ function disabled() {
|
|
|
119900
120062
|
function tabtapeBaseUrl() {
|
|
119901
120063
|
return (process.env.AGENT_PANE_TABTAPE_URL || `${sessionHostDaemonUrl()}/tabtape`).replace(/\/+$/, "");
|
|
119902
120064
|
}
|
|
119903
|
-
function playwrightMcpScript(from =
|
|
120065
|
+
function playwrightMcpScript(from = path19.dirname(fileURLToPath5(import.meta.url))) {
|
|
119904
120066
|
if (scriptOverride !== void 0) return scriptOverride;
|
|
119905
120067
|
let dir = from;
|
|
119906
120068
|
for (let i = 0; i < 6; i++) {
|
|
119907
|
-
const script =
|
|
119908
|
-
if (fs12.existsSync(script) && fs12.existsSync(
|
|
120069
|
+
const script = path19.join(dir, "tabtape", "playwright", "mcp.mjs");
|
|
120070
|
+
if (fs12.existsSync(script) && fs12.existsSync(path19.join(dir, "tabtape", "extension", "dist", "manifest.json"))) {
|
|
119909
120071
|
return script;
|
|
119910
120072
|
}
|
|
119911
|
-
const parent =
|
|
120073
|
+
const parent = path19.dirname(dir);
|
|
119912
120074
|
if (parent === dir) break;
|
|
119913
120075
|
dir = parent;
|
|
119914
120076
|
}
|
|
@@ -119950,7 +120112,7 @@ function jsonServerNames(file2, pick2) {
|
|
|
119950
120112
|
}
|
|
119951
120113
|
function claudeConfigFile() {
|
|
119952
120114
|
if (process.env.AGENT_PANE_CLAUDE_CONFIG_FILE) return process.env.AGENT_PANE_CLAUDE_CONFIG_FILE;
|
|
119953
|
-
return
|
|
120115
|
+
return path19.join(process.env.CLAUDE_CONFIG_DIR || os6.homedir(), ".claude.json");
|
|
119954
120116
|
}
|
|
119955
120117
|
function claudeUserMcpNames(cwd) {
|
|
119956
120118
|
const file2 = claudeConfigFile();
|
|
@@ -119960,7 +120122,7 @@ function claudeUserMcpNames(cwd) {
|
|
|
119960
120122
|
file2,
|
|
119961
120123
|
(json2) => json2.projects?.[cwd]?.mcpServers
|
|
119962
120124
|
),
|
|
119963
|
-
...jsonServerNames(
|
|
120125
|
+
...jsonServerNames(path19.join(cwd, ".mcp.json"), (json2) => json2.mcpServers)
|
|
119964
120126
|
]);
|
|
119965
120127
|
}
|
|
119966
120128
|
async function claudeBrowserMcpServers(cwd) {
|
|
@@ -119983,10 +120145,10 @@ function tomlServerNames(file2) {
|
|
|
119983
120145
|
return names;
|
|
119984
120146
|
}
|
|
119985
120147
|
function codexUserMcpNames(cwd) {
|
|
119986
|
-
const home = process.env.CODEX_HOME ||
|
|
120148
|
+
const home = process.env.CODEX_HOME || path19.join(os6.homedir(), ".codex");
|
|
119987
120149
|
return /* @__PURE__ */ new Set([
|
|
119988
|
-
...tomlServerNames(
|
|
119989
|
-
...tomlServerNames(
|
|
120150
|
+
...tomlServerNames(path19.join(home, "config.toml")),
|
|
120151
|
+
...tomlServerNames(path19.join(cwd, ".codex", "config.toml"))
|
|
119990
120152
|
]);
|
|
119991
120153
|
}
|
|
119992
120154
|
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.`;
|
|
@@ -120028,13 +120190,13 @@ async function repoburgBrowserMcpServers(_cwd) {
|
|
|
120028
120190
|
}
|
|
120029
120191
|
var prepared = false;
|
|
120030
120192
|
function chromiumDownloadCommand(execPath = process.execPath) {
|
|
120031
|
-
const bin =
|
|
120032
|
-
const npx =
|
|
120193
|
+
const bin = path19.dirname(execPath);
|
|
120194
|
+
const npx = path19.join(bin, process.platform === "win32" ? "npx.cmd" : "npx");
|
|
120033
120195
|
if (!fs12.existsSync(npx)) return null;
|
|
120034
120196
|
return {
|
|
120035
120197
|
command: npx,
|
|
120036
120198
|
args: ["-y", "@playwright/mcp@latest", "install-browser", "chromium"],
|
|
120037
|
-
env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(
|
|
120199
|
+
env: { ...process.env, PATH: [bin, process.env.PATH].filter(Boolean).join(path19.delimiter) }
|
|
120038
120200
|
};
|
|
120039
120201
|
}
|
|
120040
120202
|
function prepareBrowserMcp() {
|
|
@@ -124215,154 +124377,6 @@ var RepoburgHttpClient = class {
|
|
|
124215
124377
|
}
|
|
124216
124378
|
};
|
|
124217
124379
|
|
|
124218
|
-
// src/repoburg/backend-resolver.ts
|
|
124219
|
-
import path19 from "node:path";
|
|
124220
|
-
var HEALTH_POLL_INTERVAL_MS = 1e3;
|
|
124221
|
-
var HEALTH_TIMEOUT_MS = 3e4;
|
|
124222
|
-
function daemonBaseUrl() {
|
|
124223
|
-
return (process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
|
|
124224
|
-
}
|
|
124225
|
-
var HttpError = class extends Error {
|
|
124226
|
-
constructor(status, body, url2) {
|
|
124227
|
-
super(`${url2} failed: ${status} ${body}`);
|
|
124228
|
-
this.status = status;
|
|
124229
|
-
this.body = body;
|
|
124230
|
-
this.url = url2;
|
|
124231
|
-
}
|
|
124232
|
-
};
|
|
124233
|
-
async function fetchJson(url2, init, timeoutMs = 5e3) {
|
|
124234
|
-
const controller = new AbortController();
|
|
124235
|
-
const timer3 = setTimeout(() => controller.abort(), timeoutMs);
|
|
124236
|
-
let response;
|
|
124237
|
-
try {
|
|
124238
|
-
response = await fetch(url2, { ...init, signal: controller.signal });
|
|
124239
|
-
} finally {
|
|
124240
|
-
clearTimeout(timer3);
|
|
124241
|
-
}
|
|
124242
|
-
const text2 = await response.text();
|
|
124243
|
-
if (!response.ok) {
|
|
124244
|
-
throw new HttpError(response.status, text2, url2);
|
|
124245
|
-
}
|
|
124246
|
-
try {
|
|
124247
|
-
return JSON.parse(text2);
|
|
124248
|
-
} catch {
|
|
124249
|
-
throw new Error(`Unexpected non-JSON response from ${url2}`);
|
|
124250
|
-
}
|
|
124251
|
-
}
|
|
124252
|
-
function daemonErrorMessage(err) {
|
|
124253
|
-
if (err instanceof HttpError) {
|
|
124254
|
-
try {
|
|
124255
|
-
const parsed = JSON.parse(err.body);
|
|
124256
|
-
return parsed.message || parsed.error || err.body;
|
|
124257
|
-
} catch {
|
|
124258
|
-
return err.body;
|
|
124259
|
-
}
|
|
124260
|
-
}
|
|
124261
|
-
return err.message;
|
|
124262
|
-
}
|
|
124263
|
-
var resolvedCache = /* @__PURE__ */ new Map();
|
|
124264
|
-
function invalidateBackend(baseUrl) {
|
|
124265
|
-
for (const [key, value] of resolvedCache) {
|
|
124266
|
-
if (value.baseUrl === baseUrl) resolvedCache.delete(key);
|
|
124267
|
-
}
|
|
124268
|
-
}
|
|
124269
|
-
async function backendHealthy(baseUrl, expectedPath) {
|
|
124270
|
-
try {
|
|
124271
|
-
const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
|
|
124272
|
-
if (health.status !== "ok") return false;
|
|
124273
|
-
if (expectedPath && health.projectPath) {
|
|
124274
|
-
return path19.resolve(health.projectPath) === path19.resolve(expectedPath);
|
|
124275
|
-
}
|
|
124276
|
-
return true;
|
|
124277
|
-
} catch {
|
|
124278
|
-
return false;
|
|
124279
|
-
}
|
|
124280
|
-
}
|
|
124281
|
-
async function waitForHealthy(baseUrl, name, expectedPath) {
|
|
124282
|
-
const deadline = Date.now() + HEALTH_TIMEOUT_MS;
|
|
124283
|
-
while (Date.now() < deadline) {
|
|
124284
|
-
if (await backendHealthy(baseUrl, expectedPath)) return;
|
|
124285
|
-
await new Promise((resolve) => setTimeout(resolve, HEALTH_POLL_INTERVAL_MS));
|
|
124286
|
-
}
|
|
124287
|
-
throw new Error(
|
|
124288
|
-
`Backend '${name}' on ${baseUrl} did not become healthy within ${HEALTH_TIMEOUT_MS / 1e3}s. Check daemon logs: repoburg logs ${name}`
|
|
124289
|
-
);
|
|
124290
|
-
}
|
|
124291
|
-
function serviceBaseUrl(service) {
|
|
124292
|
-
return `http://localhost:${service.port}`;
|
|
124293
|
-
}
|
|
124294
|
-
function coveringService(services, absPath) {
|
|
124295
|
-
return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path19.sep)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
124296
|
-
}
|
|
124297
|
-
async function restartService(daemon, name) {
|
|
124298
|
-
try {
|
|
124299
|
-
await fetchJson(`${daemon}/services/${name}/restart`, { method: "POST" });
|
|
124300
|
-
} catch (err) {
|
|
124301
|
-
throw new Error(`Daemon failed to restart backend '${name}': ${daemonErrorMessage(err)}`);
|
|
124302
|
-
}
|
|
124303
|
-
}
|
|
124304
|
-
async function startService(daemon, projectPath) {
|
|
124305
|
-
try {
|
|
124306
|
-
return await fetchJson(`${daemon}/services/start`, {
|
|
124307
|
-
method: "POST",
|
|
124308
|
-
headers: { "Content-Type": "application/json" },
|
|
124309
|
-
body: JSON.stringify({ path: projectPath })
|
|
124310
|
-
});
|
|
124311
|
-
} catch (err) {
|
|
124312
|
-
throw new Error(`Daemon failed to start backend for ${projectPath}: ${daemonErrorMessage(err)}`);
|
|
124313
|
-
}
|
|
124314
|
-
}
|
|
124315
|
-
function cache3(absPath, service) {
|
|
124316
|
-
const resolved = {
|
|
124317
|
-
baseUrl: serviceBaseUrl(service),
|
|
124318
|
-
port: service.port,
|
|
124319
|
-
name: service.name,
|
|
124320
|
-
servesPath: service.path
|
|
124321
|
-
};
|
|
124322
|
-
resolvedCache.set(absPath, resolved);
|
|
124323
|
-
return resolved;
|
|
124324
|
-
}
|
|
124325
|
-
async function resolveBackendUrl(projectPath, opts = {}) {
|
|
124326
|
-
const autoStart = opts.autoStart !== false;
|
|
124327
|
-
const envUrl = process.env.REPOBURG_BACKEND_URL;
|
|
124328
|
-
if (envUrl) {
|
|
124329
|
-
return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
|
|
124330
|
-
}
|
|
124331
|
-
const absPath = path19.resolve(projectPath);
|
|
124332
|
-
const daemon = daemonBaseUrl();
|
|
124333
|
-
const cached3 = resolvedCache.get(absPath);
|
|
124334
|
-
if (cached3 && await backendHealthy(cached3.baseUrl, cached3.servesPath ?? absPath)) {
|
|
124335
|
-
return cached3;
|
|
124336
|
-
}
|
|
124337
|
-
try {
|
|
124338
|
-
await fetchJson(`${daemon}/health`, void 0, 3e3);
|
|
124339
|
-
} catch {
|
|
124340
|
-
throw new Error(
|
|
124341
|
-
`Repoburg daemon not reachable at ${daemon}. Start it with 'repoburg-daemon', or set REPOBURG_BACKEND_URL to a running backend.`
|
|
124342
|
-
);
|
|
124343
|
-
}
|
|
124344
|
-
const services = await fetchJson(`${daemon}/services`);
|
|
124345
|
-
const match = coveringService(services, absPath);
|
|
124346
|
-
if (match && match.status === "running") {
|
|
124347
|
-
if (await backendHealthy(serviceBaseUrl(match), match.path)) {
|
|
124348
|
-
return cache3(absPath, match);
|
|
124349
|
-
}
|
|
124350
|
-
if (!autoStart) return null;
|
|
124351
|
-
await restartService(daemon, match.name);
|
|
124352
|
-
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
124353
|
-
return cache3(absPath, match);
|
|
124354
|
-
}
|
|
124355
|
-
if (!autoStart) return null;
|
|
124356
|
-
if (match) {
|
|
124357
|
-
await restartService(daemon, match.name);
|
|
124358
|
-
await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
|
|
124359
|
-
return cache3(absPath, match);
|
|
124360
|
-
}
|
|
124361
|
-
const service = await startService(daemon, absPath);
|
|
124362
|
-
await waitForHealthy(serviceBaseUrl(service), service.name, absPath);
|
|
124363
|
-
return cache3(absPath, service);
|
|
124364
|
-
}
|
|
124365
|
-
|
|
124366
124380
|
// src/repoburg/action-mapping.ts
|
|
124367
124381
|
function parseJsonArgs(raw) {
|
|
124368
124382
|
if (!raw) return null;
|