staklink 0.4.6 → 0.4.8

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.
@@ -60794,7 +60794,7 @@ var SSEManager = class {
60794
60794
  var sseManager = new SSEManager();
60795
60795
 
60796
60796
  // src/proxy/version.ts
60797
- var VERSION = "0.4.6";
60797
+ var VERSION = "0.4.8";
60798
60798
 
60799
60799
  // node_modules/uuid/dist/esm/stringify.js
60800
60800
  var byteToHex = [];
@@ -60972,6 +60972,8 @@ var SYSTEM_CORE = `You are a software systems expert. You are working on a cloud
60972
60972
 
60973
60973
  Do not commit or push code to github. That is handled by a workflow after you are done working.
60974
60974
 
60975
+ CRITICAL: You are running inside the "staklink-proxy" PM2 process. NEVER run "pm2 stop all", "pm2 delete all", "pm2 restart all", or "pm2 kill" - these commands will terminate your own process and abort your session. To restart the user's apps, use "npx -y staklink reload" or target specific processes by name (e.g. "pm2 restart frontend").
60976
+
60975
60977
  `;
60976
60978
  var SYSTEM_SUFFIX = `
60977
60979
  You can ignore the .pod-config directory if you see it, its just config stuff
@@ -139507,7 +139509,9 @@ services:
139507
139509
  FROM ghcr.io/stakwork/staklink-js:latest
139508
139510
  </Dockerfile>
139509
139511
 
139510
- IMPORTANT: YOU DO NOT NEED TO INCLUDE FILES THAT DID NOT CHANGE. Only include files that you modified.`;
139512
+ IMPORTANT: YOU DO NOT NEED TO INCLUDE FILES THAT DID NOT CHANGE. Only include files that you modified.
139513
+
139514
+ CRITICAL: NEVER run "pm2 stop all", "pm2 delete all", "pm2 restart all", or "pm2 kill". You are running INSIDE the staklink-proxy PM2 process - these commands will kill your own process and abort this repair session! To restart the user's apps, ALWAYS use "npx -y staklink reload" which safely restarts only the user's apps without touching staklink-proxy. If you need to stop or restart a specific user process, use "pm2 stop <name>" or "pm2 restart <name>" with the specific process name (never "all").`;
139511
139515
  var REPAIR_PROMPT = `Please inspect the current running environment, and try to fix it. The user tried to load the frontend on the defined PORT, but something went wrong.`;
139512
139516
  var makeRepairPrompt = (podConfigPath, history, initialPrompt) => {
139513
139517
  let p = initialPrompt ? initialPrompt : REPAIR_PROMPT;
@@ -139519,7 +139523,7 @@ IMPORTANT: You may be in a multi-repo workspace! If so, make sure the "cwd" fiel
139519
139523
 
139520
139524
  This project is currently running a remote code-server instance. Docker is optional, but may be used. The docker-compose file has already been started. You can use the regular docker commands (docker ps, docker logs, etc) to inspect the running containers.
139521
139525
 
139522
- The actual core project code is being run with pm2! You can use pm2 commands to inspect the running processes. However, there is another service running in pm2 also (called staklink-proxy), that is not part of the software project at hand. DO NOT run "pm2 logs" just like that... only read logs of specific processes from the pm2 config file one at a time! Your goal is to get all supporting services and processes running in order to run the main project frontend. (Of course, sometimes its just one simple frontend process without supporting services. It really just depends on the project).
139526
+ The actual core project code is being run with pm2! You can use pm2 commands to inspect the running processes. However, there is another service running in pm2 also (called staklink-proxy), that is not part of the software project at hand. YOU ARE RUNNING INSIDE staklink-proxy! Never run "pm2 stop all", "pm2 delete all", "pm2 restart all", or "pm2 kill" - these will kill your own process! DO NOT run "pm2 logs" just like that... only read logs of specific processes from the pm2 config file one at a time! Your goal is to get all supporting services and processes running in order to run the main project frontend. (Of course, sometimes its just one simple frontend process without supporting services. It really just depends on the project).
139523
139527
 
139524
139528
  Along with general env vars, we have SPECIAL env vars for pm2, that tell the code-server system how to automatically build and start the project.
139525
139529
  - PORT: The port the project runs on (e.g. 3000)
@@ -140012,6 +140016,27 @@ var SCREENSHOT_DIR = import_path3.default.join(
140012
140016
  "tmp",
140013
140017
  "screenshots"
140014
140018
  );
140019
+ var RECORDING_DIR = import_path3.default.join(
140020
+ import_os2.default.homedir(),
140021
+ ".agent-browser",
140022
+ "tmp",
140023
+ "recordings"
140024
+ );
140025
+ async function cleanupAllRecordings() {
140026
+ try {
140027
+ const entries = await import_promises2.default.readdir(RECORDING_DIR);
140028
+ await Promise.all(
140029
+ entries.map(
140030
+ (file3) => import_promises2.default.unlink(import_path3.default.join(RECORDING_DIR, file3)).catch(() => {
140031
+ })
140032
+ )
140033
+ );
140034
+ if (entries.length > 0) {
140035
+ log(`Cleaned up ${entries.length} leftover recording(s)`);
140036
+ }
140037
+ } catch {
140038
+ }
140039
+ }
140015
140040
  async function cleanupAllScreenshots() {
140016
140041
  try {
140017
140042
  const entries = await import_promises2.default.readdir(SCREENSHOT_DIR);
@@ -140028,6 +140053,27 @@ async function cleanupAllScreenshots() {
140028
140053
  } catch {
140029
140054
  }
140030
140055
  }
140056
+ async function collectRecordings(since) {
140057
+ try {
140058
+ const entries = await import_promises2.default.readdir(RECORDING_DIR);
140059
+ const webms = entries.filter((e) => e.endsWith(".webm"));
140060
+ const results = [];
140061
+ for (const file3 of webms) {
140062
+ const filePath = import_path3.default.join(RECORDING_DIR, file3);
140063
+ const stat4 = await import_promises2.default.stat(filePath);
140064
+ if (stat4.mtimeMs < since) {
140065
+ continue;
140066
+ }
140067
+ results.push({
140068
+ filename: file3,
140069
+ url: `recordings/${file3}`
140070
+ });
140071
+ }
140072
+ return results;
140073
+ } catch {
140074
+ return [];
140075
+ }
140076
+ }
140031
140077
  async function collectScreenshots(since) {
140032
140078
  try {
140033
140079
  const entries = await import_promises2.default.readdir(SCREENSHOT_DIR);
@@ -140085,10 +140131,12 @@ var createAsyncAgentHandler = (getParams, transformResult) => {
140085
140131
  }).then(async (result) => {
140086
140132
  const finalResult = transformResult ? transformResult(result) : result;
140087
140133
  const screenshots = await collectScreenshots(startTime);
140134
+ const recordings = await collectRecordings(startTime);
140088
140135
  finishReq(request_id, {
140089
140136
  success: true,
140090
140137
  result: finalResult,
140091
- ...screenshots.length > 0 && { screenshots }
140138
+ ...screenshots.length > 0 && { screenshots },
140139
+ ...recordings.length > 0 && { recordings }
140092
140140
  });
140093
140141
  }).catch((error88) => {
140094
140142
  error("Agent error:", error88);
@@ -141950,6 +141998,7 @@ async function startProxyServer() {
141950
141998
  });
141951
141999
  app.use(import_express.default.json({ limit: "50mb" }));
141952
142000
  app.use(import_express.default.urlencoded({ extended: true }));
142001
+ app.use("/recordings", import_express.default.static(RECORDING_DIR));
141953
142002
  app.get("/health", (req, res) => {
141954
142003
  log("===> health check");
141955
142004
  res.status(200).json({
@@ -142703,6 +142752,9 @@ console.log("Starting staklink proxy server...");
142703
142752
  cleanupAllScreenshots().catch((err) => {
142704
142753
  warn("Screenshot cleanup failed:", err);
142705
142754
  });
142755
+ cleanupAllRecordings().catch((err) => {
142756
+ warn("Recording cleanup failed:", err);
142757
+ });
142706
142758
  startProxyServer().catch((err) => {
142707
142759
  error("Failed to start proxy server:", err);
142708
142760
  process.exit(1);
@@ -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.6";
10970
+ var VERSION = "0.4.8";
10971
10971
 
10972
10972
  // src/deps.ts
10973
10973
  var import_child_process = require("child_process");
@@ -11232,9 +11232,9 @@ program2.command("reload").description("Reload all PM2 apps (stops all except pr
11232
11232
  const runner = new Runner(root, console.log);
11233
11233
  const proxyExists = await runner.doesProcessExist(STAKLINK_PROXY);
11234
11234
  if (!proxyExists) {
11235
- console.log("\u274C Staklink server is not running");
11236
- console.log("Run 'staklink start' first");
11237
- return;
11235
+ console.error("\u274C Staklink server is not running");
11236
+ console.error("Run 'staklink start' first");
11237
+ process.exit(1);
11238
11238
  }
11239
11239
  console.log("Reloading all PM2 apps...");
11240
11240
  const response = await fetch("http://localhost:15552/reload-apps", {
@@ -11252,4 +11252,4 @@ program2.command("reload").description("Reload all PM2 apps (stops all except pr
11252
11252
  process.exit(1);
11253
11253
  }
11254
11254
  });
11255
- program2.parse();
11255
+ program2.parseAsync();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "staklink",
3
3
  "displayName": "staklink",
4
4
  "description": "staklink process manager",
5
- "version": "0.4.6",
5
+ "version": "0.4.8",
6
6
  "type": "module",
7
7
  "publisher": "stakwork",
8
8
  "engines": {