staklink 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/proxy-server.cjs +129 -17
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
package/dist/proxy-server.cjs
CHANGED
|
@@ -60411,6 +60411,23 @@ var Repo = class {
|
|
|
60411
60411
|
log("nowBranch:", nowBranch);
|
|
60412
60412
|
return nowBranch.includes(`* ${base_branch}`);
|
|
60413
60413
|
}
|
|
60414
|
+
async getDefaultBranch() {
|
|
60415
|
+
try {
|
|
60416
|
+
const result = await this.execCommand(
|
|
60417
|
+
`git remote show origin | sed -n '/HEAD branch/s/.*: //p'`
|
|
60418
|
+
);
|
|
60419
|
+
return result.trim();
|
|
60420
|
+
} catch {
|
|
60421
|
+
try {
|
|
60422
|
+
await this.execCommand(
|
|
60423
|
+
"git show-ref --verify --quiet refs/heads/main"
|
|
60424
|
+
);
|
|
60425
|
+
return "main";
|
|
60426
|
+
} catch {
|
|
60427
|
+
return "master";
|
|
60428
|
+
}
|
|
60429
|
+
}
|
|
60430
|
+
}
|
|
60414
60431
|
async checkoutMainBranchOrBaseBranch(base_branch) {
|
|
60415
60432
|
if (base_branch) {
|
|
60416
60433
|
return this.execCommand(`git checkout -f ${base_branch}`);
|
|
@@ -60777,7 +60794,7 @@ var SSEManager = class {
|
|
|
60777
60794
|
var sseManager = new SSEManager();
|
|
60778
60795
|
|
|
60779
60796
|
// src/proxy/version.ts
|
|
60780
|
-
var VERSION = "0.4.
|
|
60797
|
+
var VERSION = "0.4.7";
|
|
60781
60798
|
|
|
60782
60799
|
// node_modules/uuid/dist/esm/stringify.js
|
|
60783
60800
|
var byteToHex = [];
|
|
@@ -139995,6 +140012,27 @@ var SCREENSHOT_DIR = import_path3.default.join(
|
|
|
139995
140012
|
"tmp",
|
|
139996
140013
|
"screenshots"
|
|
139997
140014
|
);
|
|
140015
|
+
var RECORDING_DIR = import_path3.default.join(
|
|
140016
|
+
import_os2.default.homedir(),
|
|
140017
|
+
".agent-browser",
|
|
140018
|
+
"tmp",
|
|
140019
|
+
"recordings"
|
|
140020
|
+
);
|
|
140021
|
+
async function cleanupAllRecordings() {
|
|
140022
|
+
try {
|
|
140023
|
+
const entries = await import_promises2.default.readdir(RECORDING_DIR);
|
|
140024
|
+
await Promise.all(
|
|
140025
|
+
entries.map(
|
|
140026
|
+
(file3) => import_promises2.default.unlink(import_path3.default.join(RECORDING_DIR, file3)).catch(() => {
|
|
140027
|
+
})
|
|
140028
|
+
)
|
|
140029
|
+
);
|
|
140030
|
+
if (entries.length > 0) {
|
|
140031
|
+
log(`Cleaned up ${entries.length} leftover recording(s)`);
|
|
140032
|
+
}
|
|
140033
|
+
} catch {
|
|
140034
|
+
}
|
|
140035
|
+
}
|
|
139998
140036
|
async function cleanupAllScreenshots() {
|
|
139999
140037
|
try {
|
|
140000
140038
|
const entries = await import_promises2.default.readdir(SCREENSHOT_DIR);
|
|
@@ -140011,6 +140049,27 @@ async function cleanupAllScreenshots() {
|
|
|
140011
140049
|
} catch {
|
|
140012
140050
|
}
|
|
140013
140051
|
}
|
|
140052
|
+
async function collectRecordings(since) {
|
|
140053
|
+
try {
|
|
140054
|
+
const entries = await import_promises2.default.readdir(RECORDING_DIR);
|
|
140055
|
+
const webms = entries.filter((e) => e.endsWith(".webm"));
|
|
140056
|
+
const results = [];
|
|
140057
|
+
for (const file3 of webms) {
|
|
140058
|
+
const filePath = import_path3.default.join(RECORDING_DIR, file3);
|
|
140059
|
+
const stat4 = await import_promises2.default.stat(filePath);
|
|
140060
|
+
if (stat4.mtimeMs < since) {
|
|
140061
|
+
continue;
|
|
140062
|
+
}
|
|
140063
|
+
results.push({
|
|
140064
|
+
filename: file3,
|
|
140065
|
+
url: `recordings/${file3}`
|
|
140066
|
+
});
|
|
140067
|
+
}
|
|
140068
|
+
return results;
|
|
140069
|
+
} catch {
|
|
140070
|
+
return [];
|
|
140071
|
+
}
|
|
140072
|
+
}
|
|
140014
140073
|
async function collectScreenshots(since) {
|
|
140015
140074
|
try {
|
|
140016
140075
|
const entries = await import_promises2.default.readdir(SCREENSHOT_DIR);
|
|
@@ -140068,10 +140127,12 @@ var createAsyncAgentHandler = (getParams, transformResult) => {
|
|
|
140068
140127
|
}).then(async (result) => {
|
|
140069
140128
|
const finalResult = transformResult ? transformResult(result) : result;
|
|
140070
140129
|
const screenshots = await collectScreenshots(startTime);
|
|
140130
|
+
const recordings = await collectRecordings(startTime);
|
|
140071
140131
|
finishReq(request_id, {
|
|
140072
140132
|
success: true,
|
|
140073
140133
|
result: finalResult,
|
|
140074
|
-
...screenshots.length > 0 && { screenshots }
|
|
140134
|
+
...screenshots.length > 0 && { screenshots },
|
|
140135
|
+
...recordings.length > 0 && { recordings }
|
|
140075
140136
|
});
|
|
140076
140137
|
}).catch((error88) => {
|
|
140077
140138
|
error("Agent error:", error88);
|
|
@@ -141205,37 +141266,42 @@ async function handleBranchDiff(req, res) {
|
|
|
141205
141266
|
try {
|
|
141206
141267
|
const results = [];
|
|
141207
141268
|
const repos = await getReposMaybe();
|
|
141208
|
-
const baseBranch = req.query.base || "main";
|
|
141209
141269
|
for (const r of repos) {
|
|
141210
141270
|
const repo = await NewRepo(r);
|
|
141211
141271
|
const repoName = getRepoNameFromUrl(r);
|
|
141212
141272
|
const currentBranch = (await repo.printCurrentBranch()).trim();
|
|
141213
|
-
|
|
141214
|
-
|
|
141215
|
-
|
|
141216
|
-
|
|
141217
|
-
|
|
141218
|
-
|
|
141219
|
-
} catch {
|
|
141273
|
+
const baseBranch = req.query.base || await repo.getDefaultBranch();
|
|
141274
|
+
const onBaseBranch = currentBranch === baseBranch;
|
|
141275
|
+
let diffBase;
|
|
141276
|
+
if (onBaseBranch) {
|
|
141277
|
+
diffBase = "HEAD";
|
|
141278
|
+
} else {
|
|
141220
141279
|
try {
|
|
141221
|
-
|
|
141280
|
+
diffBase = (await repo.execCommand(`git merge-base ${baseBranch} HEAD`)).trim();
|
|
141222
141281
|
} catch {
|
|
141223
|
-
|
|
141224
|
-
|
|
141225
|
-
|
|
141226
|
-
|
|
141282
|
+
try {
|
|
141283
|
+
diffBase = (await repo.execCommand(
|
|
141284
|
+
`git merge-base origin/${baseBranch} HEAD`
|
|
141285
|
+
)).trim();
|
|
141286
|
+
} catch {
|
|
141287
|
+
warn(
|
|
141288
|
+
`Could not find merge base for ${repoName}, skipping...`
|
|
141289
|
+
);
|
|
141290
|
+
continue;
|
|
141291
|
+
}
|
|
141227
141292
|
}
|
|
141228
141293
|
}
|
|
141229
141294
|
let diffOutput = "";
|
|
141230
141295
|
try {
|
|
141231
141296
|
diffOutput = await repo.execCommand(
|
|
141232
|
-
`git diff --name-status ${
|
|
141297
|
+
`git diff --name-status ${diffBase}`
|
|
141233
141298
|
);
|
|
141234
141299
|
} catch (error88) {
|
|
141235
141300
|
warn(`Error getting branch diff for repo ${repoName}:`, error88);
|
|
141236
141301
|
continue;
|
|
141237
141302
|
}
|
|
141238
141303
|
const lines = diffOutput.trim().split("\n").filter((line) => line);
|
|
141304
|
+
const trackedFiles = /* @__PURE__ */ new Set();
|
|
141239
141305
|
for (const line of lines) {
|
|
141240
141306
|
const parts = line.split(" ");
|
|
141241
141307
|
if (parts.length < 2) {
|
|
@@ -141243,6 +141309,7 @@ async function handleBranchDiff(req, res) {
|
|
|
141243
141309
|
}
|
|
141244
141310
|
const status = parts[0];
|
|
141245
141311
|
const filePath = parts[1];
|
|
141312
|
+
trackedFiles.add(filePath);
|
|
141246
141313
|
let action;
|
|
141247
141314
|
if (status.startsWith("A")) {
|
|
141248
141315
|
action = "create";
|
|
@@ -141258,7 +141325,7 @@ async function handleBranchDiff(req, res) {
|
|
|
141258
141325
|
} else {
|
|
141259
141326
|
try {
|
|
141260
141327
|
content = await repo.execCommand(
|
|
141261
|
-
`git diff ${
|
|
141328
|
+
`git diff ${diffBase} -- "${filePath}"`
|
|
141262
141329
|
);
|
|
141263
141330
|
} catch (error88) {
|
|
141264
141331
|
warn(`Error getting branch diff for ${filePath}:`, error88);
|
|
@@ -141272,6 +141339,47 @@ async function handleBranchDiff(req, res) {
|
|
|
141272
141339
|
errors: []
|
|
141273
141340
|
});
|
|
141274
141341
|
}
|
|
141342
|
+
let untrackedOutput = "";
|
|
141343
|
+
try {
|
|
141344
|
+
untrackedOutput = await repo.execCommand(
|
|
141345
|
+
"git ls-files --others --exclude-standard"
|
|
141346
|
+
);
|
|
141347
|
+
} catch (error88) {
|
|
141348
|
+
warn(
|
|
141349
|
+
`Error getting untracked files for repo ${repoName}:`,
|
|
141350
|
+
error88
|
|
141351
|
+
);
|
|
141352
|
+
}
|
|
141353
|
+
const untrackedLines = untrackedOutput.trim().split("\n").filter((line) => line && !trackedFiles.has(line));
|
|
141354
|
+
for (const filePath of untrackedLines) {
|
|
141355
|
+
let content = "";
|
|
141356
|
+
const binaryContent = await binaryDiffContent(
|
|
141357
|
+
repo,
|
|
141358
|
+
filePath,
|
|
141359
|
+
"create"
|
|
141360
|
+
);
|
|
141361
|
+
if (binaryContent !== null) {
|
|
141362
|
+
content = binaryContent;
|
|
141363
|
+
} else {
|
|
141364
|
+
try {
|
|
141365
|
+
const fileContent = await repo.execCommand(`cat "${filePath}"`);
|
|
141366
|
+
const fileLines = fileContent.split("\n");
|
|
141367
|
+
content = `--- /dev/null
|
|
141368
|
+
+++ b/${filePath}
|
|
141369
|
+
@@ -0,0 +1,${fileLines.length} @@
|
|
141370
|
+
${fileLines.map((line) => "+" + line).join("\n")}`;
|
|
141371
|
+
} catch (error88) {
|
|
141372
|
+
warn(`Error reading untracked file ${filePath}:`, error88);
|
|
141373
|
+
}
|
|
141374
|
+
}
|
|
141375
|
+
results.push({
|
|
141376
|
+
file: `${repoName}/${filePath}`,
|
|
141377
|
+
action: "create",
|
|
141378
|
+
content,
|
|
141379
|
+
repoName,
|
|
141380
|
+
errors: []
|
|
141381
|
+
});
|
|
141382
|
+
}
|
|
141275
141383
|
}
|
|
141276
141384
|
res.status(200).json(results);
|
|
141277
141385
|
} catch (error88) {
|
|
@@ -141886,6 +141994,7 @@ async function startProxyServer() {
|
|
|
141886
141994
|
});
|
|
141887
141995
|
app.use(import_express.default.json({ limit: "50mb" }));
|
|
141888
141996
|
app.use(import_express.default.urlencoded({ extended: true }));
|
|
141997
|
+
app.use("/recordings", import_express.default.static(RECORDING_DIR));
|
|
141889
141998
|
app.get("/health", (req, res) => {
|
|
141890
141999
|
log("===> health check");
|
|
141891
142000
|
res.status(200).json({
|
|
@@ -142639,6 +142748,9 @@ console.log("Starting staklink proxy server...");
|
|
|
142639
142748
|
cleanupAllScreenshots().catch((err) => {
|
|
142640
142749
|
warn("Screenshot cleanup failed:", err);
|
|
142641
142750
|
});
|
|
142751
|
+
cleanupAllRecordings().catch((err) => {
|
|
142752
|
+
warn("Recording cleanup failed:", err);
|
|
142753
|
+
});
|
|
142642
142754
|
startProxyServer().catch((err) => {
|
|
142643
142755
|
error("Failed to start proxy server:", err);
|
|
142644
142756
|
process.exit(1);
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -10967,7 +10967,7 @@ var glob = Object.assign(glob_, {
|
|
|
10967
10967
|
glob.glob = glob;
|
|
10968
10968
|
|
|
10969
10969
|
// src/proxy/version.ts
|
|
10970
|
-
var VERSION = "0.4.
|
|
10970
|
+
var VERSION = "0.4.7";
|
|
10971
10971
|
|
|
10972
10972
|
// src/deps.ts
|
|
10973
10973
|
var import_child_process = require("child_process");
|