staklink 0.5.7 → 0.5.9
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 +28 -44
- package/dist/staklink-cli.cjs +7 -1
- package/package.json +1 -1
package/dist/proxy-server.cjs
CHANGED
|
@@ -53319,6 +53319,12 @@ var Runner = class {
|
|
|
53319
53319
|
async executeCommand(command, cwd = this.cwd, description = "Command", appEnv, timeoutMs = 20 * 60 * 1e3) {
|
|
53320
53320
|
this.log_cb(`\u26A1 ${description}: ${command}`);
|
|
53321
53321
|
this.log_cb(`\u{1F4C1} Working directory: ${cwd}`);
|
|
53322
|
+
if (appEnv && Object.keys(appEnv).length > 0) {
|
|
53323
|
+
const keys = Object.keys(appEnv);
|
|
53324
|
+
this.log_cb(`App env vars injected (${keys.length}): [${keys.join(", ")}]`);
|
|
53325
|
+
} else {
|
|
53326
|
+
this.log_cb(`No app env vars provided for this command`);
|
|
53327
|
+
}
|
|
53322
53328
|
return new Promise((resolve3, reject) => {
|
|
53323
53329
|
const child = proc2.spawn("sh", ["-c", command], {
|
|
53324
53330
|
cwd,
|
|
@@ -61003,7 +61009,7 @@ var SSEManager = class {
|
|
|
61003
61009
|
var sseManager = new SSEManager();
|
|
61004
61010
|
|
|
61005
61011
|
// src/proxy/version.ts
|
|
61006
|
-
var VERSION = "0.5.
|
|
61012
|
+
var VERSION = "0.5.9";
|
|
61007
61013
|
|
|
61008
61014
|
// node_modules/uuid/dist/esm/stringify.js
|
|
61009
61015
|
var byteToHex = [];
|
|
@@ -61123,7 +61129,7 @@ function isReqTypeBusy(req_type) {
|
|
|
61123
61129
|
// src/agent/utils.ts
|
|
61124
61130
|
var proc5 = __toESM(require("child_process"), 1);
|
|
61125
61131
|
var COMMAND_TIMEOUT_MS = 90 * 60 * 1e3;
|
|
61126
|
-
async function executeCommand(command, cwd, env2, log_cb) {
|
|
61132
|
+
async function executeCommand(command, cwd, env2, log_cb, ctx) {
|
|
61127
61133
|
return new Promise((resolve3, reject) => {
|
|
61128
61134
|
const child = proc5.spawn("sh", ["-c", command], {
|
|
61129
61135
|
cwd,
|
|
@@ -61135,7 +61141,9 @@ async function executeCommand(command, cwd, env2, log_cb) {
|
|
|
61135
61141
|
let timedOut = false;
|
|
61136
61142
|
const timeout = setTimeout(() => {
|
|
61137
61143
|
timedOut = true;
|
|
61138
|
-
|
|
61144
|
+
const sessionLabel = ctx?.session ? ` [session=${ctx.session}]` : "";
|
|
61145
|
+
const cmdLabel = ctx?.command ? ` | cmd: ${ctx.command.slice(0, 120)}` : "";
|
|
61146
|
+
log_cb && log_cb(`\u23F1\uFE0F Command timed out after ${COMMAND_TIMEOUT_MS / 1e3}s, killing process${sessionLabel}${cmdLabel}`);
|
|
61139
61147
|
child.kill("SIGTERM");
|
|
61140
61148
|
setTimeout(() => {
|
|
61141
61149
|
if (!child.killed) child.kill("SIGKILL");
|
|
@@ -142984,14 +142992,14 @@ ${prompt}` : prompt;
|
|
|
142984
142992
|
} catch {
|
|
142985
142993
|
}
|
|
142986
142994
|
}
|
|
142987
|
-
let res = await executeCommand(cmd, cwd, env2, (l) => log(l));
|
|
142995
|
+
let res = await executeCommand(cmd, cwd, env2, (l) => log(l), { session, command: cmd });
|
|
142988
142996
|
if (session && isStreamDecodeError(res.stdout)) {
|
|
142989
142997
|
const maxRetries = 2;
|
|
142990
142998
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
142991
142999
|
log(`Stream decode error detected, retrying (${attempt}/${maxRetries})...`);
|
|
142992
143000
|
await new Promise((r) => setTimeout(r, 2e3 * attempt));
|
|
142993
143001
|
const retryCmd = `goose run --with-builtin developer -t "continue" --system "${system}" --name ${session} --resume`;
|
|
142994
|
-
res = await executeCommand(retryCmd, cwd, env2, (l) => log(l));
|
|
143002
|
+
res = await executeCommand(retryCmd, cwd, env2, (l) => log(l), { session, command: retryCmd });
|
|
142995
143003
|
if (!isStreamDecodeError(res.stdout)) break;
|
|
142996
143004
|
}
|
|
142997
143005
|
}
|
|
@@ -147423,6 +147431,16 @@ async function deleteFile(filePath) {
|
|
|
147423
147431
|
await fs15.unlink(filePath);
|
|
147424
147432
|
}
|
|
147425
147433
|
|
|
147434
|
+
// src/proxy/log_prefix.ts
|
|
147435
|
+
function buildCorrelationPrefix(req) {
|
|
147436
|
+
const sessionId = req.query.sessionId || req.query.session_id || req.params.sessionId;
|
|
147437
|
+
const requestId = req.query.request_id;
|
|
147438
|
+
const parts = [];
|
|
147439
|
+
if (sessionId) parts.push(`[session=${sessionId}]`);
|
|
147440
|
+
if (requestId) parts.push(`[req=${requestId}]`);
|
|
147441
|
+
return parts.length ? parts.join(" ") + " " : "";
|
|
147442
|
+
}
|
|
147443
|
+
|
|
147426
147444
|
// src/proxy/server.ts
|
|
147427
147445
|
var PORT = parseInt(process.env.STAKLINK_PORT || "15552") || 15552;
|
|
147428
147446
|
var VSCODE_EXTENSION_URL = `http://localhost:${PORT + 1}`;
|
|
@@ -147467,20 +147485,22 @@ async function startProxyServer() {
|
|
|
147467
147485
|
});
|
|
147468
147486
|
app.use(import_express.default.json({ limit: "50mb" }));
|
|
147469
147487
|
app.use(import_express.default.urlencoded({ extended: true }));
|
|
147488
|
+
app.use((req, _res, next) => {
|
|
147489
|
+
const prefix = buildCorrelationPrefix(req);
|
|
147490
|
+
log(`${prefix}===> ${req.method} ${req.path}`);
|
|
147491
|
+
next();
|
|
147492
|
+
});
|
|
147470
147493
|
app.use("/recordings", import_express.default.static(RECORDING_DIR));
|
|
147471
147494
|
app.get("/health", (req, res) => {
|
|
147472
|
-
log("===> health check");
|
|
147473
147495
|
res.status(200).json({
|
|
147474
147496
|
ok: true,
|
|
147475
147497
|
last_hit: lastHitTimestamp
|
|
147476
147498
|
});
|
|
147477
147499
|
});
|
|
147478
147500
|
app.get("/version", (_, res) => {
|
|
147479
|
-
log("===> GET version");
|
|
147480
147501
|
res.status(200).send(VERSION);
|
|
147481
147502
|
});
|
|
147482
147503
|
app.get("/list", async (req, res) => {
|
|
147483
|
-
log("===> GET list");
|
|
147484
147504
|
const r = await newRunner();
|
|
147485
147505
|
const list = await r.list();
|
|
147486
147506
|
res.send(list);
|
|
@@ -147526,7 +147546,6 @@ async function startProxyServer() {
|
|
|
147526
147546
|
});
|
|
147527
147547
|
app.use(updateLastHit);
|
|
147528
147548
|
app.post("/code", async (req, res) => {
|
|
147529
|
-
log("===> POST code");
|
|
147530
147549
|
await handleRequest(
|
|
147531
147550
|
req,
|
|
147532
147551
|
res,
|
|
@@ -147544,7 +147563,6 @@ async function startProxyServer() {
|
|
|
147544
147563
|
);
|
|
147545
147564
|
});
|
|
147546
147565
|
app.post("/actions", async (req, res) => {
|
|
147547
|
-
log("===> POST actions");
|
|
147548
147566
|
await handleRequest(
|
|
147549
147567
|
req,
|
|
147550
147568
|
res,
|
|
@@ -147562,7 +147580,6 @@ async function startProxyServer() {
|
|
|
147562
147580
|
);
|
|
147563
147581
|
});
|
|
147564
147582
|
app.get("/rules", async (req, res) => {
|
|
147565
|
-
log("===> GET rules");
|
|
147566
147583
|
await handleRequest(
|
|
147567
147584
|
req,
|
|
147568
147585
|
res,
|
|
@@ -147576,7 +147593,6 @@ async function startProxyServer() {
|
|
|
147576
147593
|
);
|
|
147577
147594
|
});
|
|
147578
147595
|
app.get("/errors", async (req, res) => {
|
|
147579
|
-
log("===> GET errors");
|
|
147580
147596
|
await handleRequest(
|
|
147581
147597
|
req,
|
|
147582
147598
|
res,
|
|
@@ -147588,14 +147604,12 @@ async function startProxyServer() {
|
|
|
147588
147604
|
);
|
|
147589
147605
|
});
|
|
147590
147606
|
app.get("/logs", async (req, res) => {
|
|
147591
|
-
log("===> GET logs");
|
|
147592
147607
|
const r = await newRunner();
|
|
147593
147608
|
const lines = Number(req.query.lines) || 100;
|
|
147594
147609
|
const logs = await r.pm2Logs(lines);
|
|
147595
147610
|
res.send(logs);
|
|
147596
147611
|
});
|
|
147597
147612
|
app.get("/logs/:appName", async (req, res) => {
|
|
147598
|
-
log(`===> GET logs for ${req.params.appName}`);
|
|
147599
147613
|
const appName = req.params.appName;
|
|
147600
147614
|
const r = await newRunner();
|
|
147601
147615
|
try {
|
|
@@ -147611,14 +147625,11 @@ async function startProxyServer() {
|
|
|
147611
147625
|
}
|
|
147612
147626
|
});
|
|
147613
147627
|
app.get("/ports", async (req, res) => {
|
|
147614
|
-
log("===> GET ports");
|
|
147615
147628
|
const ps = await getAppsPortAndLabel();
|
|
147616
147629
|
res.json(ps);
|
|
147617
147630
|
});
|
|
147618
147631
|
app.get("/gitlog", async (req, res) => {
|
|
147619
|
-
log("===> GET gitlog");
|
|
147620
147632
|
try {
|
|
147621
|
-
log("===> gitlog");
|
|
147622
147633
|
const logs = {};
|
|
147623
147634
|
const repos = await getReposMaybe();
|
|
147624
147635
|
for (const r of repos) {
|
|
@@ -147633,38 +147644,30 @@ async function startProxyServer() {
|
|
|
147633
147644
|
}
|
|
147634
147645
|
});
|
|
147635
147646
|
app.get("/diff", async (req, res) => {
|
|
147636
|
-
log("===> GET diff");
|
|
147637
147647
|
await handleDiff(req, res);
|
|
147638
147648
|
});
|
|
147639
147649
|
app.get("/branch-diff", async (req, res) => {
|
|
147640
|
-
log("===> GET branch-diff");
|
|
147641
147650
|
await handleBranchDiff(req, res);
|
|
147642
147651
|
});
|
|
147643
147652
|
app.post("/commit", async (req, res) => {
|
|
147644
|
-
log(`===> POST /commit`);
|
|
147645
147653
|
await handleCommit(req, res);
|
|
147646
147654
|
});
|
|
147647
147655
|
app.post("/push", async (req, res) => {
|
|
147648
|
-
log(`===> POST /push`);
|
|
147649
147656
|
await handlePush(req, res);
|
|
147650
147657
|
});
|
|
147651
147658
|
app.post("/reset", async (req, res) => {
|
|
147652
|
-
log(`===> POST /reset`);
|
|
147653
147659
|
await handleReset(req, res);
|
|
147654
147660
|
});
|
|
147655
147661
|
app.post("/pr", async (req, res) => {
|
|
147656
|
-
log(`===> POST /pr`);
|
|
147657
147662
|
await handlePr(req, res);
|
|
147658
147663
|
});
|
|
147659
147664
|
app.post(
|
|
147660
147665
|
"/create-repo",
|
|
147661
147666
|
async (req, res) => {
|
|
147662
|
-
log(`===> POST /create-repo`);
|
|
147663
147667
|
await handleCreateRepo(req, res);
|
|
147664
147668
|
}
|
|
147665
147669
|
);
|
|
147666
147670
|
app.get("/events", (req, res) => {
|
|
147667
|
-
log("===> GET /events");
|
|
147668
147671
|
try {
|
|
147669
147672
|
res.setHeader("Content-Type", "text/event-stream");
|
|
147670
147673
|
res.setHeader("Cache-Control", "no-cache");
|
|
@@ -147695,19 +147698,16 @@ async function startProxyServer() {
|
|
|
147695
147698
|
}
|
|
147696
147699
|
});
|
|
147697
147700
|
app.post("/rebuild", async (req, res) => {
|
|
147698
|
-
log(`===> POST /rebuild`);
|
|
147699
147701
|
await restartConfiguredProcesses();
|
|
147700
147702
|
res.json({ success: true });
|
|
147701
147703
|
});
|
|
147702
147704
|
app.post("/restart", async (req, res) => {
|
|
147703
|
-
log(`===> POST /restart`);
|
|
147704
147705
|
await restartConfiguredProcesses();
|
|
147705
147706
|
res.json({ success: true });
|
|
147706
147707
|
});
|
|
147707
147708
|
app.put(
|
|
147708
147709
|
"/reload-apps",
|
|
147709
147710
|
async (req, res) => {
|
|
147710
|
-
log(`===> PUT /reload-apps`);
|
|
147711
147711
|
if (!isLocalRequest(req)) {
|
|
147712
147712
|
res.status(403).json({
|
|
147713
147713
|
error: "This endpoint is only accessible from localhost"
|
|
@@ -147738,7 +147738,6 @@ async function startProxyServer() {
|
|
|
147738
147738
|
}
|
|
147739
147739
|
);
|
|
147740
147740
|
app.post("/rollback", async (req, res) => {
|
|
147741
|
-
log(`===> POST /rollback`);
|
|
147742
147741
|
const ns = req.query.n || "1";
|
|
147743
147742
|
const n = parseInt(ns) || 1;
|
|
147744
147743
|
try {
|
|
@@ -147755,7 +147754,6 @@ async function startProxyServer() {
|
|
|
147755
147754
|
app.get(
|
|
147756
147755
|
"/script_progress",
|
|
147757
147756
|
async (req, res) => {
|
|
147758
|
-
log(`===> GET /script_progress`);
|
|
147759
147757
|
try {
|
|
147760
147758
|
const request_id = req.query.request_id;
|
|
147761
147759
|
if (!request_id) {
|
|
@@ -147777,13 +147775,11 @@ async function startProxyServer() {
|
|
|
147777
147775
|
app.get(
|
|
147778
147776
|
"/workspace_root",
|
|
147779
147777
|
async (req, res) => {
|
|
147780
|
-
log("===> GET /workspace_root");
|
|
147781
147778
|
const workspaceRoot2 = await workspaceRoot();
|
|
147782
147779
|
res.json({ workspaceRoot: workspaceRoot2 });
|
|
147783
147780
|
}
|
|
147784
147781
|
);
|
|
147785
147782
|
app.put("/install", async (req, res) => {
|
|
147786
|
-
log(`===> PUT /install`);
|
|
147787
147783
|
const request_id = startReq();
|
|
147788
147784
|
try {
|
|
147789
147785
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147801,7 +147797,6 @@ async function startProxyServer() {
|
|
|
147801
147797
|
}
|
|
147802
147798
|
});
|
|
147803
147799
|
app.put("/prerun", async (req, res) => {
|
|
147804
|
-
log(`===> PUT /prerun`);
|
|
147805
147800
|
const request_id = startReq();
|
|
147806
147801
|
try {
|
|
147807
147802
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147821,7 +147816,6 @@ async function startProxyServer() {
|
|
|
147821
147816
|
app.put(
|
|
147822
147817
|
"/reset_state",
|
|
147823
147818
|
async (req, res) => {
|
|
147824
|
-
log(`===> PUT /reset_state`);
|
|
147825
147819
|
const request_id = startReq();
|
|
147826
147820
|
try {
|
|
147827
147821
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147840,7 +147834,6 @@ async function startProxyServer() {
|
|
|
147840
147834
|
}
|
|
147841
147835
|
);
|
|
147842
147836
|
app.put("/latest", async (req, res) => {
|
|
147843
|
-
log(`===> PUT /latest`);
|
|
147844
147837
|
if (isReqTypeBusy("latest")) {
|
|
147845
147838
|
log("=> /latest is already being processed, ignoring request");
|
|
147846
147839
|
res.status(409).json({
|
|
@@ -147899,7 +147892,6 @@ async function startProxyServer() {
|
|
|
147899
147892
|
}
|
|
147900
147893
|
});
|
|
147901
147894
|
app.put("/build", async (req, res) => {
|
|
147902
|
-
log(`===> PUT /build`);
|
|
147903
147895
|
const request_id = startReq();
|
|
147904
147896
|
try {
|
|
147905
147897
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147920,7 +147912,6 @@ async function startProxyServer() {
|
|
|
147920
147912
|
}
|
|
147921
147913
|
});
|
|
147922
147914
|
app.put("/test", async (req, res) => {
|
|
147923
|
-
log(`===> PUT /test`);
|
|
147924
147915
|
const request_id = startReq();
|
|
147925
147916
|
try {
|
|
147926
147917
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147941,7 +147932,6 @@ async function startProxyServer() {
|
|
|
147941
147932
|
}
|
|
147942
147933
|
});
|
|
147943
147934
|
app.put("/e2e_test", async (req, res) => {
|
|
147944
|
-
log(`===> PUT /e2e_test`);
|
|
147945
147935
|
const request_id = startReq();
|
|
147946
147936
|
try {
|
|
147947
147937
|
const test_name = req.query.test_name;
|
|
@@ -148098,7 +148088,6 @@ async function startProxyServer() {
|
|
|
148098
148088
|
});
|
|
148099
148089
|
});
|
|
148100
148090
|
app.post("/validate_session", async (req, res) => {
|
|
148101
|
-
log("===> POST /validate_session");
|
|
148102
148091
|
const { session } = req.body;
|
|
148103
148092
|
if (!session) {
|
|
148104
148093
|
res.status(400).json({ error: "Missing required field: session" });
|
|
@@ -148112,7 +148101,6 @@ async function startProxyServer() {
|
|
|
148112
148101
|
}
|
|
148113
148102
|
});
|
|
148114
148103
|
app.get("/agent/session", async (req, res) => {
|
|
148115
|
-
log("===> GET /agent/session");
|
|
148116
148104
|
const sessionId = req.query.sessionId || req.query.session_id;
|
|
148117
148105
|
if (!sessionId) {
|
|
148118
148106
|
res.status(400).json({ error: "Missing required query parameter: sessionId" });
|
|
@@ -148144,7 +148132,6 @@ async function startProxyServer() {
|
|
|
148144
148132
|
}))
|
|
148145
148133
|
);
|
|
148146
148134
|
app.post("/agent/push", async (req, res) => {
|
|
148147
|
-
log("===> POST /agent/push");
|
|
148148
148135
|
await handleAgentPush(req, res);
|
|
148149
148136
|
});
|
|
148150
148137
|
app.post(
|
|
@@ -148190,7 +148177,6 @@ async function startProxyServer() {
|
|
|
148190
148177
|
app.post(
|
|
148191
148178
|
"/validate_frontend",
|
|
148192
148179
|
async (req, res) => {
|
|
148193
|
-
log("===> POST /validate_frontend");
|
|
148194
148180
|
try {
|
|
148195
148181
|
const workspaceRoot2 = await workspaceRoot();
|
|
148196
148182
|
const config3 = await findAndLoadPm2Config(workspaceRoot2, log);
|
|
@@ -148241,7 +148227,6 @@ ${logs}
|
|
|
148241
148227
|
}
|
|
148242
148228
|
);
|
|
148243
148229
|
app.get("/leaks", async (req, res) => {
|
|
148244
|
-
log(`===> GET /leaks`);
|
|
148245
148230
|
try {
|
|
148246
148231
|
const detect = gitleaksDetect();
|
|
148247
148232
|
const protect = gitleaksProtect();
|
|
@@ -148254,7 +148239,6 @@ ${logs}
|
|
|
148254
148239
|
app.post(
|
|
148255
148240
|
"/playwright_test",
|
|
148256
148241
|
async (req, res) => {
|
|
148257
|
-
log(`===> POST /playwright_test`);
|
|
148258
148242
|
const request_id = startReq();
|
|
148259
148243
|
try {
|
|
148260
148244
|
const { repoName, testFilePath, responseUrl, apiKey } = req.body;
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -4527,6 +4527,12 @@ var Runner = class {
|
|
|
4527
4527
|
async executeCommand(command, cwd = this.cwd, description = "Command", appEnv, timeoutMs = 20 * 60 * 1e3) {
|
|
4528
4528
|
this.log_cb(`\u26A1 ${description}: ${command}`);
|
|
4529
4529
|
this.log_cb(`\u{1F4C1} Working directory: ${cwd}`);
|
|
4530
|
+
if (appEnv && Object.keys(appEnv).length > 0) {
|
|
4531
|
+
const keys = Object.keys(appEnv);
|
|
4532
|
+
this.log_cb(`App env vars injected (${keys.length}): [${keys.join(", ")}]`);
|
|
4533
|
+
} else {
|
|
4534
|
+
this.log_cb(`No app env vars provided for this command`);
|
|
4535
|
+
}
|
|
4530
4536
|
return new Promise((resolve, reject) => {
|
|
4531
4537
|
const child = proc2.spawn("sh", ["-c", command], {
|
|
4532
4538
|
cwd,
|
|
@@ -11016,7 +11022,7 @@ var glob = Object.assign(glob_, {
|
|
|
11016
11022
|
glob.glob = glob;
|
|
11017
11023
|
|
|
11018
11024
|
// src/proxy/version.ts
|
|
11019
|
-
var VERSION = "0.5.
|
|
11025
|
+
var VERSION = "0.5.9";
|
|
11020
11026
|
|
|
11021
11027
|
// src/deps.ts
|
|
11022
11028
|
var import_child_process = require("child_process");
|