staklink 0.5.8 → 0.5.10
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 +53 -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.10";
|
|
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
|
}
|
|
@@ -147199,6 +147201,37 @@ async function handleAgentPush(req, res) {
|
|
|
147199
147201
|
return;
|
|
147200
147202
|
}
|
|
147201
147203
|
const apiKey = code.apiKey || process.env.ANTHROPIC_API_KEY || "";
|
|
147204
|
+
if (code.session) {
|
|
147205
|
+
createSession(
|
|
147206
|
+
code.session,
|
|
147207
|
+
void 0,
|
|
147208
|
+
// webhookUrl
|
|
147209
|
+
code.apiKey,
|
|
147210
|
+
// raw body key — parity with createAsyncAgentHandler
|
|
147211
|
+
void 0,
|
|
147212
|
+
// searchApiKey
|
|
147213
|
+
code.model,
|
|
147214
|
+
"goose",
|
|
147215
|
+
// handleAgentPush always uses chooseAgent("goose")
|
|
147216
|
+
void 0,
|
|
147217
|
+
// system — push prompt is built per-repo, so omit
|
|
147218
|
+
void 0,
|
|
147219
|
+
// temperature
|
|
147220
|
+
void 0,
|
|
147221
|
+
// jsonMode
|
|
147222
|
+
void 0,
|
|
147223
|
+
// summaryApiKey
|
|
147224
|
+
void 0,
|
|
147225
|
+
// mcpServers
|
|
147226
|
+
void 0,
|
|
147227
|
+
// baseUrl
|
|
147228
|
+
void 0,
|
|
147229
|
+
// headers
|
|
147230
|
+
void 0,
|
|
147231
|
+
// repoName — push can touch multiple repos; omit
|
|
147232
|
+
code._metadata
|
|
147233
|
+
);
|
|
147234
|
+
}
|
|
147202
147235
|
(async () => {
|
|
147203
147236
|
const results = { commits: [], prs: {}, branches: {} };
|
|
147204
147237
|
for (const r of repos) {
|
|
@@ -147429,6 +147462,16 @@ async function deleteFile(filePath) {
|
|
|
147429
147462
|
await fs15.unlink(filePath);
|
|
147430
147463
|
}
|
|
147431
147464
|
|
|
147465
|
+
// src/proxy/log_prefix.ts
|
|
147466
|
+
function buildCorrelationPrefix(req) {
|
|
147467
|
+
const sessionId = req.query.sessionId || req.query.session_id || req.params.sessionId;
|
|
147468
|
+
const requestId = req.query.request_id;
|
|
147469
|
+
const parts = [];
|
|
147470
|
+
if (sessionId) parts.push(`[session=${sessionId}]`);
|
|
147471
|
+
if (requestId) parts.push(`[req=${requestId}]`);
|
|
147472
|
+
return parts.length ? parts.join(" ") + " " : "";
|
|
147473
|
+
}
|
|
147474
|
+
|
|
147432
147475
|
// src/proxy/server.ts
|
|
147433
147476
|
var PORT = parseInt(process.env.STAKLINK_PORT || "15552") || 15552;
|
|
147434
147477
|
var VSCODE_EXTENSION_URL = `http://localhost:${PORT + 1}`;
|
|
@@ -147473,20 +147516,22 @@ async function startProxyServer() {
|
|
|
147473
147516
|
});
|
|
147474
147517
|
app.use(import_express.default.json({ limit: "50mb" }));
|
|
147475
147518
|
app.use(import_express.default.urlencoded({ extended: true }));
|
|
147519
|
+
app.use((req, _res, next) => {
|
|
147520
|
+
const prefix = buildCorrelationPrefix(req);
|
|
147521
|
+
log(`${prefix}===> ${req.method} ${req.path}`);
|
|
147522
|
+
next();
|
|
147523
|
+
});
|
|
147476
147524
|
app.use("/recordings", import_express.default.static(RECORDING_DIR));
|
|
147477
147525
|
app.get("/health", (req, res) => {
|
|
147478
|
-
log("===> health check");
|
|
147479
147526
|
res.status(200).json({
|
|
147480
147527
|
ok: true,
|
|
147481
147528
|
last_hit: lastHitTimestamp
|
|
147482
147529
|
});
|
|
147483
147530
|
});
|
|
147484
147531
|
app.get("/version", (_, res) => {
|
|
147485
|
-
log("===> GET version");
|
|
147486
147532
|
res.status(200).send(VERSION);
|
|
147487
147533
|
});
|
|
147488
147534
|
app.get("/list", async (req, res) => {
|
|
147489
|
-
log("===> GET list");
|
|
147490
147535
|
const r = await newRunner();
|
|
147491
147536
|
const list = await r.list();
|
|
147492
147537
|
res.send(list);
|
|
@@ -147532,7 +147577,6 @@ async function startProxyServer() {
|
|
|
147532
147577
|
});
|
|
147533
147578
|
app.use(updateLastHit);
|
|
147534
147579
|
app.post("/code", async (req, res) => {
|
|
147535
|
-
log("===> POST code");
|
|
147536
147580
|
await handleRequest(
|
|
147537
147581
|
req,
|
|
147538
147582
|
res,
|
|
@@ -147550,7 +147594,6 @@ async function startProxyServer() {
|
|
|
147550
147594
|
);
|
|
147551
147595
|
});
|
|
147552
147596
|
app.post("/actions", async (req, res) => {
|
|
147553
|
-
log("===> POST actions");
|
|
147554
147597
|
await handleRequest(
|
|
147555
147598
|
req,
|
|
147556
147599
|
res,
|
|
@@ -147568,7 +147611,6 @@ async function startProxyServer() {
|
|
|
147568
147611
|
);
|
|
147569
147612
|
});
|
|
147570
147613
|
app.get("/rules", async (req, res) => {
|
|
147571
|
-
log("===> GET rules");
|
|
147572
147614
|
await handleRequest(
|
|
147573
147615
|
req,
|
|
147574
147616
|
res,
|
|
@@ -147582,7 +147624,6 @@ async function startProxyServer() {
|
|
|
147582
147624
|
);
|
|
147583
147625
|
});
|
|
147584
147626
|
app.get("/errors", async (req, res) => {
|
|
147585
|
-
log("===> GET errors");
|
|
147586
147627
|
await handleRequest(
|
|
147587
147628
|
req,
|
|
147588
147629
|
res,
|
|
@@ -147594,14 +147635,12 @@ async function startProxyServer() {
|
|
|
147594
147635
|
);
|
|
147595
147636
|
});
|
|
147596
147637
|
app.get("/logs", async (req, res) => {
|
|
147597
|
-
log("===> GET logs");
|
|
147598
147638
|
const r = await newRunner();
|
|
147599
147639
|
const lines = Number(req.query.lines) || 100;
|
|
147600
147640
|
const logs = await r.pm2Logs(lines);
|
|
147601
147641
|
res.send(logs);
|
|
147602
147642
|
});
|
|
147603
147643
|
app.get("/logs/:appName", async (req, res) => {
|
|
147604
|
-
log(`===> GET logs for ${req.params.appName}`);
|
|
147605
147644
|
const appName = req.params.appName;
|
|
147606
147645
|
const r = await newRunner();
|
|
147607
147646
|
try {
|
|
@@ -147617,14 +147656,11 @@ async function startProxyServer() {
|
|
|
147617
147656
|
}
|
|
147618
147657
|
});
|
|
147619
147658
|
app.get("/ports", async (req, res) => {
|
|
147620
|
-
log("===> GET ports");
|
|
147621
147659
|
const ps = await getAppsPortAndLabel();
|
|
147622
147660
|
res.json(ps);
|
|
147623
147661
|
});
|
|
147624
147662
|
app.get("/gitlog", async (req, res) => {
|
|
147625
|
-
log("===> GET gitlog");
|
|
147626
147663
|
try {
|
|
147627
|
-
log("===> gitlog");
|
|
147628
147664
|
const logs = {};
|
|
147629
147665
|
const repos = await getReposMaybe();
|
|
147630
147666
|
for (const r of repos) {
|
|
@@ -147639,38 +147675,30 @@ async function startProxyServer() {
|
|
|
147639
147675
|
}
|
|
147640
147676
|
});
|
|
147641
147677
|
app.get("/diff", async (req, res) => {
|
|
147642
|
-
log("===> GET diff");
|
|
147643
147678
|
await handleDiff(req, res);
|
|
147644
147679
|
});
|
|
147645
147680
|
app.get("/branch-diff", async (req, res) => {
|
|
147646
|
-
log("===> GET branch-diff");
|
|
147647
147681
|
await handleBranchDiff(req, res);
|
|
147648
147682
|
});
|
|
147649
147683
|
app.post("/commit", async (req, res) => {
|
|
147650
|
-
log(`===> POST /commit`);
|
|
147651
147684
|
await handleCommit(req, res);
|
|
147652
147685
|
});
|
|
147653
147686
|
app.post("/push", async (req, res) => {
|
|
147654
|
-
log(`===> POST /push`);
|
|
147655
147687
|
await handlePush(req, res);
|
|
147656
147688
|
});
|
|
147657
147689
|
app.post("/reset", async (req, res) => {
|
|
147658
|
-
log(`===> POST /reset`);
|
|
147659
147690
|
await handleReset(req, res);
|
|
147660
147691
|
});
|
|
147661
147692
|
app.post("/pr", async (req, res) => {
|
|
147662
|
-
log(`===> POST /pr`);
|
|
147663
147693
|
await handlePr(req, res);
|
|
147664
147694
|
});
|
|
147665
147695
|
app.post(
|
|
147666
147696
|
"/create-repo",
|
|
147667
147697
|
async (req, res) => {
|
|
147668
|
-
log(`===> POST /create-repo`);
|
|
147669
147698
|
await handleCreateRepo(req, res);
|
|
147670
147699
|
}
|
|
147671
147700
|
);
|
|
147672
147701
|
app.get("/events", (req, res) => {
|
|
147673
|
-
log("===> GET /events");
|
|
147674
147702
|
try {
|
|
147675
147703
|
res.setHeader("Content-Type", "text/event-stream");
|
|
147676
147704
|
res.setHeader("Cache-Control", "no-cache");
|
|
@@ -147701,19 +147729,16 @@ async function startProxyServer() {
|
|
|
147701
147729
|
}
|
|
147702
147730
|
});
|
|
147703
147731
|
app.post("/rebuild", async (req, res) => {
|
|
147704
|
-
log(`===> POST /rebuild`);
|
|
147705
147732
|
await restartConfiguredProcesses();
|
|
147706
147733
|
res.json({ success: true });
|
|
147707
147734
|
});
|
|
147708
147735
|
app.post("/restart", async (req, res) => {
|
|
147709
|
-
log(`===> POST /restart`);
|
|
147710
147736
|
await restartConfiguredProcesses();
|
|
147711
147737
|
res.json({ success: true });
|
|
147712
147738
|
});
|
|
147713
147739
|
app.put(
|
|
147714
147740
|
"/reload-apps",
|
|
147715
147741
|
async (req, res) => {
|
|
147716
|
-
log(`===> PUT /reload-apps`);
|
|
147717
147742
|
if (!isLocalRequest(req)) {
|
|
147718
147743
|
res.status(403).json({
|
|
147719
147744
|
error: "This endpoint is only accessible from localhost"
|
|
@@ -147744,7 +147769,6 @@ async function startProxyServer() {
|
|
|
147744
147769
|
}
|
|
147745
147770
|
);
|
|
147746
147771
|
app.post("/rollback", async (req, res) => {
|
|
147747
|
-
log(`===> POST /rollback`);
|
|
147748
147772
|
const ns = req.query.n || "1";
|
|
147749
147773
|
const n = parseInt(ns) || 1;
|
|
147750
147774
|
try {
|
|
@@ -147761,7 +147785,6 @@ async function startProxyServer() {
|
|
|
147761
147785
|
app.get(
|
|
147762
147786
|
"/script_progress",
|
|
147763
147787
|
async (req, res) => {
|
|
147764
|
-
log(`===> GET /script_progress`);
|
|
147765
147788
|
try {
|
|
147766
147789
|
const request_id = req.query.request_id;
|
|
147767
147790
|
if (!request_id) {
|
|
@@ -147783,13 +147806,11 @@ async function startProxyServer() {
|
|
|
147783
147806
|
app.get(
|
|
147784
147807
|
"/workspace_root",
|
|
147785
147808
|
async (req, res) => {
|
|
147786
|
-
log("===> GET /workspace_root");
|
|
147787
147809
|
const workspaceRoot2 = await workspaceRoot();
|
|
147788
147810
|
res.json({ workspaceRoot: workspaceRoot2 });
|
|
147789
147811
|
}
|
|
147790
147812
|
);
|
|
147791
147813
|
app.put("/install", async (req, res) => {
|
|
147792
|
-
log(`===> PUT /install`);
|
|
147793
147814
|
const request_id = startReq();
|
|
147794
147815
|
try {
|
|
147795
147816
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147807,7 +147828,6 @@ async function startProxyServer() {
|
|
|
147807
147828
|
}
|
|
147808
147829
|
});
|
|
147809
147830
|
app.put("/prerun", async (req, res) => {
|
|
147810
|
-
log(`===> PUT /prerun`);
|
|
147811
147831
|
const request_id = startReq();
|
|
147812
147832
|
try {
|
|
147813
147833
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147827,7 +147847,6 @@ async function startProxyServer() {
|
|
|
147827
147847
|
app.put(
|
|
147828
147848
|
"/reset_state",
|
|
147829
147849
|
async (req, res) => {
|
|
147830
|
-
log(`===> PUT /reset_state`);
|
|
147831
147850
|
const request_id = startReq();
|
|
147832
147851
|
try {
|
|
147833
147852
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147846,7 +147865,6 @@ async function startProxyServer() {
|
|
|
147846
147865
|
}
|
|
147847
147866
|
);
|
|
147848
147867
|
app.put("/latest", async (req, res) => {
|
|
147849
|
-
log(`===> PUT /latest`);
|
|
147850
147868
|
if (isReqTypeBusy("latest")) {
|
|
147851
147869
|
log("=> /latest is already being processed, ignoring request");
|
|
147852
147870
|
res.status(409).json({
|
|
@@ -147905,7 +147923,6 @@ async function startProxyServer() {
|
|
|
147905
147923
|
}
|
|
147906
147924
|
});
|
|
147907
147925
|
app.put("/build", async (req, res) => {
|
|
147908
|
-
log(`===> PUT /build`);
|
|
147909
147926
|
const request_id = startReq();
|
|
147910
147927
|
try {
|
|
147911
147928
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147926,7 +147943,6 @@ async function startProxyServer() {
|
|
|
147926
147943
|
}
|
|
147927
147944
|
});
|
|
147928
147945
|
app.put("/test", async (req, res) => {
|
|
147929
|
-
log(`===> PUT /test`);
|
|
147930
147946
|
const request_id = startReq();
|
|
147931
147947
|
try {
|
|
147932
147948
|
const workspaceRoot2 = await workspaceRoot();
|
|
@@ -147947,7 +147963,6 @@ async function startProxyServer() {
|
|
|
147947
147963
|
}
|
|
147948
147964
|
});
|
|
147949
147965
|
app.put("/e2e_test", async (req, res) => {
|
|
147950
|
-
log(`===> PUT /e2e_test`);
|
|
147951
147966
|
const request_id = startReq();
|
|
147952
147967
|
try {
|
|
147953
147968
|
const test_name = req.query.test_name;
|
|
@@ -148104,7 +148119,6 @@ async function startProxyServer() {
|
|
|
148104
148119
|
});
|
|
148105
148120
|
});
|
|
148106
148121
|
app.post("/validate_session", async (req, res) => {
|
|
148107
|
-
log("===> POST /validate_session");
|
|
148108
148122
|
const { session } = req.body;
|
|
148109
148123
|
if (!session) {
|
|
148110
148124
|
res.status(400).json({ error: "Missing required field: session" });
|
|
@@ -148118,7 +148132,6 @@ async function startProxyServer() {
|
|
|
148118
148132
|
}
|
|
148119
148133
|
});
|
|
148120
148134
|
app.get("/agent/session", async (req, res) => {
|
|
148121
|
-
log("===> GET /agent/session");
|
|
148122
148135
|
const sessionId = req.query.sessionId || req.query.session_id;
|
|
148123
148136
|
if (!sessionId) {
|
|
148124
148137
|
res.status(400).json({ error: "Missing required query parameter: sessionId" });
|
|
@@ -148150,7 +148163,6 @@ async function startProxyServer() {
|
|
|
148150
148163
|
}))
|
|
148151
148164
|
);
|
|
148152
148165
|
app.post("/agent/push", async (req, res) => {
|
|
148153
|
-
log("===> POST /agent/push");
|
|
148154
148166
|
await handleAgentPush(req, res);
|
|
148155
148167
|
});
|
|
148156
148168
|
app.post(
|
|
@@ -148196,7 +148208,6 @@ async function startProxyServer() {
|
|
|
148196
148208
|
app.post(
|
|
148197
148209
|
"/validate_frontend",
|
|
148198
148210
|
async (req, res) => {
|
|
148199
|
-
log("===> POST /validate_frontend");
|
|
148200
148211
|
try {
|
|
148201
148212
|
const workspaceRoot2 = await workspaceRoot();
|
|
148202
148213
|
const config3 = await findAndLoadPm2Config(workspaceRoot2, log);
|
|
@@ -148247,7 +148258,6 @@ ${logs}
|
|
|
148247
148258
|
}
|
|
148248
148259
|
);
|
|
148249
148260
|
app.get("/leaks", async (req, res) => {
|
|
148250
|
-
log(`===> GET /leaks`);
|
|
148251
148261
|
try {
|
|
148252
148262
|
const detect = gitleaksDetect();
|
|
148253
148263
|
const protect = gitleaksProtect();
|
|
@@ -148260,7 +148270,6 @@ ${logs}
|
|
|
148260
148270
|
app.post(
|
|
148261
148271
|
"/playwright_test",
|
|
148262
148272
|
async (req, res) => {
|
|
148263
|
-
log(`===> POST /playwright_test`);
|
|
148264
148273
|
const request_id = startReq();
|
|
148265
148274
|
try {
|
|
148266
148275
|
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.10";
|
|
11026
11026
|
|
|
11027
11027
|
// src/deps.ts
|
|
11028
11028
|
var import_child_process = require("child_process");
|