staklink 0.5.8 → 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 +22 -44
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
package/dist/proxy-server.cjs
CHANGED
|
@@ -61009,7 +61009,7 @@ var SSEManager = class {
|
|
|
61009
61009
|
var sseManager = new SSEManager();
|
|
61010
61010
|
|
|
61011
61011
|
// src/proxy/version.ts
|
|
61012
|
-
var VERSION = "0.5.
|
|
61012
|
+
var VERSION = "0.5.9";
|
|
61013
61013
|
|
|
61014
61014
|
// node_modules/uuid/dist/esm/stringify.js
|
|
61015
61015
|
var byteToHex = [];
|
|
@@ -61129,7 +61129,7 @@ function isReqTypeBusy(req_type) {
|
|
|
61129
61129
|
// src/agent/utils.ts
|
|
61130
61130
|
var proc5 = __toESM(require("child_process"), 1);
|
|
61131
61131
|
var COMMAND_TIMEOUT_MS = 90 * 60 * 1e3;
|
|
61132
|
-
async function executeCommand(command, cwd, env2, log_cb) {
|
|
61132
|
+
async function executeCommand(command, cwd, env2, log_cb, ctx) {
|
|
61133
61133
|
return new Promise((resolve3, reject) => {
|
|
61134
61134
|
const child = proc5.spawn("sh", ["-c", command], {
|
|
61135
61135
|
cwd,
|
|
@@ -61141,7 +61141,9 @@ async function executeCommand(command, cwd, env2, log_cb) {
|
|
|
61141
61141
|
let timedOut = false;
|
|
61142
61142
|
const timeout = setTimeout(() => {
|
|
61143
61143
|
timedOut = true;
|
|
61144
|
-
|
|
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}`);
|
|
61145
61147
|
child.kill("SIGTERM");
|
|
61146
61148
|
setTimeout(() => {
|
|
61147
61149
|
if (!child.killed) child.kill("SIGKILL");
|
|
@@ -142990,14 +142992,14 @@ ${prompt}` : prompt;
|
|
|
142990
142992
|
} catch {
|
|
142991
142993
|
}
|
|
142992
142994
|
}
|
|
142993
|
-
let res = await executeCommand(cmd, cwd, env2, (l) => log(l));
|
|
142995
|
+
let res = await executeCommand(cmd, cwd, env2, (l) => log(l), { session, command: cmd });
|
|
142994
142996
|
if (session && isStreamDecodeError(res.stdout)) {
|
|
142995
142997
|
const maxRetries = 2;
|
|
142996
142998
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
142997
142999
|
log(`Stream decode error detected, retrying (${attempt}/${maxRetries})...`);
|
|
142998
143000
|
await new Promise((r) => setTimeout(r, 2e3 * attempt));
|
|
142999
143001
|
const retryCmd = `goose run --with-builtin developer -t "continue" --system "${system}" --name ${session} --resume`;
|
|
143000
|
-
res = await executeCommand(retryCmd, cwd, env2, (l) => log(l));
|
|
143002
|
+
res = await executeCommand(retryCmd, cwd, env2, (l) => log(l), { session, command: retryCmd });
|
|
143001
143003
|
if (!isStreamDecodeError(res.stdout)) break;
|
|
143002
143004
|
}
|
|
143003
143005
|
}
|
|
@@ -147429,6 +147431,16 @@ async function deleteFile(filePath) {
|
|
|
147429
147431
|
await fs15.unlink(filePath);
|
|
147430
147432
|
}
|
|
147431
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
|
+
|
|
147432
147444
|
// src/proxy/server.ts
|
|
147433
147445
|
var PORT = parseInt(process.env.STAKLINK_PORT || "15552") || 15552;
|
|
147434
147446
|
var VSCODE_EXTENSION_URL = `http://localhost:${PORT + 1}`;
|
|
@@ -147473,20 +147485,22 @@ async function startProxyServer() {
|
|
|
147473
147485
|
});
|
|
147474
147486
|
app.use(import_express.default.json({ limit: "50mb" }));
|
|
147475
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
|
+
});
|
|
147476
147493
|
app.use("/recordings", import_express.default.static(RECORDING_DIR));
|
|
147477
147494
|
app.get("/health", (req, res) => {
|
|
147478
|
-
log("===> health check");
|
|
147479
147495
|
res.status(200).json({
|
|
147480
147496
|
ok: true,
|
|
147481
147497
|
last_hit: lastHitTimestamp
|
|
147482
147498
|
});
|
|
147483
147499
|
});
|
|
147484
147500
|
app.get("/version", (_, res) => {
|
|
147485
|
-
log("===> GET version");
|
|
147486
147501
|
res.status(200).send(VERSION);
|
|
147487
147502
|
});
|
|
147488
147503
|
app.get("/list", async (req, res) => {
|
|
147489
|
-
log("===> GET list");
|
|
147490
147504
|
const r = await newRunner();
|
|
147491
147505
|
const list = await r.list();
|
|
147492
147506
|
res.send(list);
|
|
@@ -147532,7 +147546,6 @@ async function startProxyServer() {
|
|
|
147532
147546
|
});
|
|
147533
147547
|
app.use(updateLastHit);
|
|
147534
147548
|
app.post("/code", async (req, res) => {
|
|
147535
|
-
log("===> POST code");
|
|
147536
147549
|
await handleRequest(
|
|
147537
147550
|
req,
|
|
147538
147551
|
res,
|
|
@@ -147550,7 +147563,6 @@ async function startProxyServer() {
|
|
|
147550
147563
|
);
|
|
147551
147564
|
});
|
|
147552
147565
|
app.post("/actions", async (req, res) => {
|
|
147553
|
-
log("===> POST actions");
|
|
147554
147566
|
await handleRequest(
|
|
147555
147567
|
req,
|
|
147556
147568
|
res,
|
|
@@ -147568,7 +147580,6 @@ async function startProxyServer() {
|
|
|
147568
147580
|
);
|
|
147569
147581
|
});
|
|
147570
147582
|
app.get("/rules", async (req, res) => {
|
|
147571
|
-
log("===> GET rules");
|
|
147572
147583
|
await handleRequest(
|
|
147573
147584
|
req,
|
|
147574
147585
|
res,
|
|
@@ -147582,7 +147593,6 @@ async function startProxyServer() {
|
|
|
147582
147593
|
);
|
|
147583
147594
|
});
|
|
147584
147595
|
app.get("/errors", async (req, res) => {
|
|
147585
|
-
log("===> GET errors");
|
|
147586
147596
|
await handleRequest(
|
|
147587
147597
|
req,
|
|
147588
147598
|
res,
|
|
@@ -147594,14 +147604,12 @@ async function startProxyServer() {
|
|
|
147594
147604
|
);
|
|
147595
147605
|
});
|
|
147596
147606
|
app.get("/logs", async (req, res) => {
|
|
147597
|
-
log("===> GET logs");
|
|
147598
147607
|
const r = await newRunner();
|
|
147599
147608
|
const lines = Number(req.query.lines) || 100;
|
|
147600
147609
|
const logs = await r.pm2Logs(lines);
|
|
147601
147610
|
res.send(logs);
|
|
147602
147611
|
});
|
|
147603
147612
|
app.get("/logs/:appName", async (req, res) => {
|
|
147604
|
-
log(`===> GET logs for ${req.params.appName}`);
|
|
147605
147613
|
const appName = req.params.appName;
|
|
147606
147614
|
const r = await newRunner();
|
|
147607
147615
|
try {
|
|
@@ -147617,14 +147625,11 @@ async function startProxyServer() {
|
|
|
147617
147625
|
}
|
|
147618
147626
|
});
|
|
147619
147627
|
app.get("/ports", async (req, res) => {
|
|
147620
|
-
log("===> GET ports");
|
|
147621
147628
|
const ps = await getAppsPortAndLabel();
|
|
147622
147629
|
res.json(ps);
|
|
147623
147630
|
});
|
|
147624
147631
|
app.get("/gitlog", async (req, res) => {
|
|
147625
|
-
log("===> GET gitlog");
|
|
147626
147632
|
try {
|
|
147627
|
-
log("===> gitlog");
|
|
147628
147633
|
const logs = {};
|
|
147629
147634
|
const repos = await getReposMaybe();
|
|
147630
147635
|
for (const r of repos) {
|
|
@@ -147639,38 +147644,30 @@ async function startProxyServer() {
|
|
|
147639
147644
|
}
|
|
147640
147645
|
});
|
|
147641
147646
|
app.get("/diff", async (req, res) => {
|
|
147642
|
-
log("===> GET diff");
|
|
147643
147647
|
await handleDiff(req, res);
|
|
147644
147648
|
});
|
|
147645
147649
|
app.get("/branch-diff", async (req, res) => {
|
|
147646
|
-
log("===> GET branch-diff");
|
|
147647
147650
|
await handleBranchDiff(req, res);
|
|
147648
147651
|
});
|
|
147649
147652
|
app.post("/commit", async (req, res) => {
|
|
147650
|
-
log(`===> POST /commit`);
|
|
147651
147653
|
await handleCommit(req, res);
|
|
147652
147654
|
});
|
|
147653
147655
|
app.post("/push", async (req, res) => {
|
|
147654
|
-
log(`===> POST /push`);
|
|
147655
147656
|
await handlePush(req, res);
|
|
147656
147657
|
});
|
|
147657
147658
|
app.post("/reset", async (req, res) => {
|
|
147658
|
-
log(`===> POST /reset`);
|
|
147659
147659
|
await handleReset(req, res);
|
|
147660
147660
|
});
|
|
147661
147661
|
app.post("/pr", async (req, res) => {
|
|
147662
|
-
log(`===> POST /pr`);
|
|
147663
147662
|
await handlePr(req, res);
|
|
147664
147663
|
});
|
|
147665
147664
|
app.post(
|
|
147666
147665
|
"/create-repo",
|
|
147667
147666
|
async (req, res) => {
|
|
147668
|
-
log(`===> POST /create-repo`);
|
|
147669
147667
|
await handleCreateRepo(req, res);
|
|
147670
147668
|
}
|
|
147671
147669
|
);
|
|
147672
147670
|
app.get("/events", (req, res) => {
|
|
147673
|
-
log("===> GET /events");
|
|
147674
147671
|
try {
|
|
147675
147672
|
res.setHeader("Content-Type", "text/event-stream");
|
|
147676
147673
|
res.setHeader("Cache-Control", "no-cache");
|
|
@@ -147701,19 +147698,16 @@ async function startProxyServer() {
|
|
|
147701
147698
|
}
|
|
147702
147699
|
});
|
|
147703
147700
|
app.post("/rebuild", async (req, res) => {
|
|
147704
|
-
log(`===> POST /rebuild`);
|
|
147705
147701
|
await restartConfiguredProcesses();
|
|
147706
147702
|
res.json({ success: true });
|
|
147707
147703
|
});
|
|
147708
147704
|
app.post("/restart", async (req, res) => {
|
|
147709
|
-
log(`===> POST /restart`);
|
|
147710
147705
|
await restartConfiguredProcesses();
|
|
147711
147706
|
res.json({ success: true });
|
|
147712
147707
|
});
|
|
147713
147708
|
app.put(
|
|
147714
147709
|
"/reload-apps",
|
|
147715
147710
|
async (req, res) => {
|
|
147716
|
-
log(`===> PUT /reload-apps`);
|
|
147717
147711
|
if (!isLocalRequest(req)) {
|
|
147718
147712
|
res.status(403).json({
|
|
147719
147713
|
error: "This endpoint is only accessible from localhost"
|
|
@@ -147744,7 +147738,6 @@ async function startProxyServer() {
|
|
|
147744
147738
|
}
|
|
147745
147739
|
);
|
|
147746
147740
|
app.post("/rollback", async (req, res) => {
|
|
147747
|
-
log(`===> POST /rollback`);
|
|
147748
147741
|
const ns = req.query.n || "1";
|
|
147749
147742
|
const n = parseInt(ns) || 1;
|
|
147750
147743
|
try {
|
|
@@ -147761,7 +147754,6 @@ async function startProxyServer() {
|
|
|
147761
147754
|
app.get(
|
|
147762
147755
|
"/script_progress",
|
|
147763
147756
|
async (req, res) => {
|
|
147764
|
-
log(`===> GET /script_progress`);
|
|
147765
147757
|
try {
|
|
147766
147758
|
const request_id = req.query.request_id;
|
|
147767
147759
|
if (!request_id) {
|
|
@@ -147783,13 +147775,11 @@ async function startProxyServer() {
|
|
|
147783
147775
|
app.get(
|
|
147784
147776
|
"/workspace_root",
|
|
147785
147777
|
async (req, res) => {
|
|
147786
|
-
log("===> GET /workspace_root");
|
|
147787
147778
|
const workspaceRoot2 = await workspaceRoot();
|
|
147788
147779
|
res.json({ workspaceRoot: workspaceRoot2 });
|
|
147789
147780
|
}
|
|
147790
147781
|
);
|
|
147791
147782
|
app.put("/install", async (req, res) => {
|
|
147792
|
-
log(`===> PUT /install`);
|
|
147793
147783
|
const request_id = startReq();
|
|
147794
147784
|
try {
|
|
147795
147785
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147807,7 +147797,6 @@ async function startProxyServer() {
|
|
|
147807
147797
|
}
|
|
147808
147798
|
});
|
|
147809
147799
|
app.put("/prerun", async (req, res) => {
|
|
147810
|
-
log(`===> PUT /prerun`);
|
|
147811
147800
|
const request_id = startReq();
|
|
147812
147801
|
try {
|
|
147813
147802
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147827,7 +147816,6 @@ async function startProxyServer() {
|
|
|
147827
147816
|
app.put(
|
|
147828
147817
|
"/reset_state",
|
|
147829
147818
|
async (req, res) => {
|
|
147830
|
-
log(`===> PUT /reset_state`);
|
|
147831
147819
|
const request_id = startReq();
|
|
147832
147820
|
try {
|
|
147833
147821
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147846,7 +147834,6 @@ async function startProxyServer() {
|
|
|
147846
147834
|
}
|
|
147847
147835
|
);
|
|
147848
147836
|
app.put("/latest", async (req, res) => {
|
|
147849
|
-
log(`===> PUT /latest`);
|
|
147850
147837
|
if (isReqTypeBusy("latest")) {
|
|
147851
147838
|
log("=> /latest is already being processed, ignoring request");
|
|
147852
147839
|
res.status(409).json({
|
|
@@ -147905,7 +147892,6 @@ async function startProxyServer() {
|
|
|
147905
147892
|
}
|
|
147906
147893
|
});
|
|
147907
147894
|
app.put("/build", async (req, res) => {
|
|
147908
|
-
log(`===> PUT /build`);
|
|
147909
147895
|
const request_id = startReq();
|
|
147910
147896
|
try {
|
|
147911
147897
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147926,7 +147912,6 @@ async function startProxyServer() {
|
|
|
147926
147912
|
}
|
|
147927
147913
|
});
|
|
147928
147914
|
app.put("/test", async (req, res) => {
|
|
147929
|
-
log(`===> PUT /test`);
|
|
147930
147915
|
const request_id = startReq();
|
|
147931
147916
|
try {
|
|
147932
147917
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147947,7 +147932,6 @@ async function startProxyServer() {
|
|
|
147947
147932
|
}
|
|
147948
147933
|
});
|
|
147949
147934
|
app.put("/e2e_test", async (req, res) => {
|
|
147950
|
-
log(`===> PUT /e2e_test`);
|
|
147951
147935
|
const request_id = startReq();
|
|
147952
147936
|
try {
|
|
147953
147937
|
const test_name = req.query.test_name;
|
|
@@ -148104,7 +148088,6 @@ async function startProxyServer() {
|
|
|
148104
148088
|
});
|
|
148105
148089
|
});
|
|
148106
148090
|
app.post("/validate_session", async (req, res) => {
|
|
148107
|
-
log("===> POST /validate_session");
|
|
148108
148091
|
const { session } = req.body;
|
|
148109
148092
|
if (!session) {
|
|
148110
148093
|
res.status(400).json({ error: "Missing required field: session" });
|
|
@@ -148118,7 +148101,6 @@ async function startProxyServer() {
|
|
|
148118
148101
|
}
|
|
148119
148102
|
});
|
|
148120
148103
|
app.get("/agent/session", async (req, res) => {
|
|
148121
|
-
log("===> GET /agent/session");
|
|
148122
148104
|
const sessionId = req.query.sessionId || req.query.session_id;
|
|
148123
148105
|
if (!sessionId) {
|
|
148124
148106
|
res.status(400).json({ error: "Missing required query parameter: sessionId" });
|
|
@@ -148150,7 +148132,6 @@ async function startProxyServer() {
|
|
|
148150
148132
|
}))
|
|
148151
148133
|
);
|
|
148152
148134
|
app.post("/agent/push", async (req, res) => {
|
|
148153
|
-
log("===> POST /agent/push");
|
|
148154
148135
|
await handleAgentPush(req, res);
|
|
148155
148136
|
});
|
|
148156
148137
|
app.post(
|
|
@@ -148196,7 +148177,6 @@ async function startProxyServer() {
|
|
|
148196
148177
|
app.post(
|
|
148197
148178
|
"/validate_frontend",
|
|
148198
148179
|
async (req, res) => {
|
|
148199
|
-
log("===> POST /validate_frontend");
|
|
148200
148180
|
try {
|
|
148201
148181
|
const workspaceRoot2 = await workspaceRoot();
|
|
148202
148182
|
const config3 = await findAndLoadPm2Config(workspaceRoot2, log);
|
|
@@ -148247,7 +148227,6 @@ ${logs}
|
|
|
148247
148227
|
}
|
|
148248
148228
|
);
|
|
148249
148229
|
app.get("/leaks", async (req, res) => {
|
|
148250
|
-
log(`===> GET /leaks`);
|
|
148251
148230
|
try {
|
|
148252
148231
|
const detect = gitleaksDetect();
|
|
148253
148232
|
const protect = gitleaksProtect();
|
|
@@ -148260,7 +148239,6 @@ ${logs}
|
|
|
148260
148239
|
app.post(
|
|
148261
148240
|
"/playwright_test",
|
|
148262
148241
|
async (req, res) => {
|
|
148263
|
-
log(`===> POST /playwright_test`);
|
|
148264
148242
|
const request_id = startReq();
|
|
148265
148243
|
try {
|
|
148266
148244
|
const { repoName, testFilePath, responseUrl, apiKey } = req.body;
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -11022,7 +11022,7 @@ var glob = Object.assign(glob_, {
|
|
|
11022
11022
|
glob.glob = glob;
|
|
11023
11023
|
|
|
11024
11024
|
// src/proxy/version.ts
|
|
11025
|
-
var VERSION = "0.5.
|
|
11025
|
+
var VERSION = "0.5.9";
|
|
11026
11026
|
|
|
11027
11027
|
// src/deps.ts
|
|
11028
11028
|
var import_child_process = require("child_process");
|