staklink 0.3.36 → 0.3.40

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.
@@ -3919,10 +3919,18 @@ async function findAndLoadPm2Config(workspaceRoot2, log_cb) {
3919
3919
  }
3920
3920
  async function findPm2Config(workspaceRoot2, log_cb) {
3921
3921
  log_cb?.(`Searching for PM2 config in workspace: ${workspaceRoot2}`);
3922
+ const configFilenames = ["pm2.config.js", "pm2.config.cjs"];
3922
3923
  const configPaths = [
3923
- "/workspaces/.pod-config/.user-dockerfile/pm2.config.js",
3924
- path.join(workspaceRoot2, "pm2.config.js"),
3925
- path.join(workspaceRoot2, ".devcontainer", "pm2.config.js")
3924
+ ...configFilenames.map(
3925
+ (filename) => `/workspaces/.pod-config/.user-dockerfile/${filename}`
3926
+ ),
3927
+ ...configFilenames.map((filename) => path.join(workspaceRoot2, filename)),
3928
+ ...configFilenames.map(
3929
+ (filename) => path.join(workspaceRoot2, ".devcontainer", filename)
3930
+ ),
3931
+ ...configFilenames.map(
3932
+ (filename) => path.join(workspaceRoot2, ".pod-config", filename)
3933
+ )
3926
3934
  ];
3927
3935
  try {
3928
3936
  const subdirs = await fs2.readdir(workspaceRoot2, {
@@ -3930,10 +3938,12 @@ async function findPm2Config(workspaceRoot2, log_cb) {
3930
3938
  });
3931
3939
  const repoDirs = subdirs.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
3932
3940
  for (const repoDir of repoDirs) {
3933
- configPaths.push(
3934
- path.join(workspaceRoot2, repoDir, "pm2.config.js"),
3935
- path.join(workspaceRoot2, repoDir, ".devcontainer", "pm2.config.js")
3936
- );
3941
+ for (const filename of configFilenames) {
3942
+ configPaths.push(
3943
+ path.join(workspaceRoot2, repoDir, filename),
3944
+ path.join(workspaceRoot2, repoDir, ".devcontainer", filename)
3945
+ );
3946
+ }
3937
3947
  }
3938
3948
  } catch (error) {
3939
3949
  console.log("Error reading workspace directories:", error);
@@ -3950,7 +3960,16 @@ async function findPm2Config(workspaceRoot2, log_cb) {
3950
3960
  }
3951
3961
  async function loadPm2Config(configPath) {
3952
3962
  try {
3953
- const configContent = await fs2.readFile(configPath, "utf8");
3963
+ let configContent = await fs2.readFile(configPath, "utf8");
3964
+ configContent = configContent.replace(
3965
+ /export\s+default\s+/g,
3966
+ "module.exports = "
3967
+ );
3968
+ configContent = configContent.replace(
3969
+ /export\s*{([^}]*)as\s+default\s*}/g,
3970
+ "module.exports = $1"
3971
+ );
3972
+ configContent = configContent.replace(/export\s+/g, "");
3954
3973
  const moduleContext = { exports: {}, module: { exports: {} } };
3955
3974
  const configFunction = new Function("module", "exports", configContent);
3956
3975
  configFunction(moduleContext.module, moduleContext.exports);
@@ -4042,15 +4061,15 @@ var Runner = class {
4042
4061
  const env = proc4.env || {};
4043
4062
  return {
4044
4063
  name: proc4.name,
4045
- restart: env.RESTART === "true" || env.RESTART === "1",
4046
4064
  installCommand: env.INSTALL_COMMAND,
4047
- rebuildCommand: env.REBUILD_COMMAND,
4048
4065
  postRunCommand: env.POST_RUN_COMMAND || env.POST_START_COMMAND,
4049
4066
  preRunCommand: env.PRE_RUN_COMMAND || env.PRE_START_COMMAND,
4050
4067
  buildCommand: env.BUILD_COMMAND,
4051
4068
  testCommand: env.TEST_COMMAND,
4052
4069
  e2eTestCommand: env.E2E_TEST_COMMAND,
4070
+ restart: env.RESTART === "true" || env.RESTART === "1",
4053
4071
  resetCommand: env.RESET_COMMAND,
4072
+ rebuildCommand: env.REBUILD_COMMAND,
4054
4073
  port: env.PORT,
4055
4074
  label: env.LABEL,
4056
4075
  cwd: proc4.cwd || this.cwd
@@ -4083,7 +4102,9 @@ var Runner = class {
4083
4102
  for (const app of config.apps || []) {
4084
4103
  const processConfig = this.parseProcessApp(app);
4085
4104
  if (processConfig.rebuildCommand) {
4086
- this.log_cb(`\u{1F527} Rebuilding ${processConfig.name}...`);
4105
+ this.log_cb(
4106
+ `\u{1F527} Rebuilding ${processConfig.name}: ${processConfig.rebuildCommand}`
4107
+ );
4087
4108
  try {
4088
4109
  const { stdout, stderr } = await this.executeCommand(
4089
4110
  processConfig.rebuildCommand,
@@ -4107,7 +4128,9 @@ var Runner = class {
4107
4128
  for (const app of config.apps || []) {
4108
4129
  const processConfig = this.parseProcessApp(app);
4109
4130
  if (processConfig.installCommand) {
4110
- this.log_cb(`\u{1F4E6} Installing dependencies for ${processConfig.name}...`);
4131
+ this.log_cb(
4132
+ `\u{1F4E6} Installing dependencies for ${processConfig.name}: ${processConfig.installCommand}`
4133
+ );
4111
4134
  try {
4112
4135
  const { stdout, stderr } = await this.executeCommand(
4113
4136
  processConfig.installCommand,
@@ -4126,7 +4149,9 @@ var Runner = class {
4126
4149
  for (const app of config.apps || []) {
4127
4150
  const processConfig = this.parseProcessApp(app);
4128
4151
  if (processConfig.preRunCommand) {
4129
- this.log_cb(`\u{1F680} Running pre-run command for ${processConfig.name}...`);
4152
+ this.log_cb(
4153
+ `\u{1F680} Running pre-run command for ${processConfig.name}: ${processConfig.preRunCommand}`
4154
+ );
4130
4155
  try {
4131
4156
  await this.executeCommand(
4132
4157
  processConfig.preRunCommand,
@@ -4146,7 +4171,9 @@ var Runner = class {
4146
4171
  for (const app of config.apps || []) {
4147
4172
  const processConfig = this.parseProcessApp(app);
4148
4173
  if (processConfig.postRunCommand) {
4149
- this.log_cb(`\u{1F680} Running post-run command for ${processConfig.name}...`);
4174
+ this.log_cb(
4175
+ `\u{1F680} Running post-run command for ${processConfig.name}: ${processConfig.postRunCommand}`
4176
+ );
4150
4177
  try {
4151
4178
  await this.executeCommand(
4152
4179
  processConfig.postRunCommand,
@@ -4168,7 +4195,9 @@ var Runner = class {
4168
4195
  for (const app of config.apps || []) {
4169
4196
  const processConfig = this.parseProcessApp(app);
4170
4197
  if (processConfig.resetCommand) {
4171
- this.log_cb(`\u{1F504} Running reset command for ${processConfig.name}...`);
4198
+ this.log_cb(
4199
+ `\u{1F504} Running reset command for ${processConfig.name}: ${processConfig.resetCommand}`
4200
+ );
4172
4201
  try {
4173
4202
  await this.executeCommand(
4174
4203
  processConfig.resetCommand,
@@ -4189,7 +4218,9 @@ var Runner = class {
4189
4218
  for (const app of config.apps || []) {
4190
4219
  const processConfig = this.parseProcessApp(app);
4191
4220
  if (processConfig.buildCommand) {
4192
- this.log_cb(`\u{1F528} Running build command for ${processConfig.name}...`);
4221
+ this.log_cb(
4222
+ `\u{1F528} Running build command for ${processConfig.name}: ${processConfig.buildCommand}`
4223
+ );
4193
4224
  let is_next = false;
4194
4225
  if (processConfig.cwd) {
4195
4226
  const proj = detectProject(processConfig.cwd);
@@ -4227,7 +4258,9 @@ var Runner = class {
4227
4258
  for (const app of config.apps || []) {
4228
4259
  const processConfig = this.parseProcessApp(app);
4229
4260
  if (processConfig.testCommand) {
4230
- this.log_cb(`\u{1F9EA} Running test command for ${processConfig.name}...`);
4261
+ this.log_cb(
4262
+ `\u{1F9EA} Running test command for ${processConfig.name}: ${processConfig.testCommand}`
4263
+ );
4231
4264
  try {
4232
4265
  const { stdout, stderr } = await this.executeCommand(
4233
4266
  processConfig.testCommand,
@@ -4253,7 +4286,9 @@ var Runner = class {
4253
4286
  for (const app of config.apps || []) {
4254
4287
  const processConfig = this.parseProcessApp(app);
4255
4288
  if (processConfig.e2eTestCommand) {
4256
- this.log_cb(`\u{1F3AD} Running E2E test command for ${processConfig.name}...`);
4289
+ this.log_cb(
4290
+ `\u{1F3AD} Running E2E test command for ${processConfig.name}: ${processConfig.e2eTestCommand}`
4291
+ );
4257
4292
  const isPlaywright = processConfig.e2eTestCommand === "npx playwright test" || processConfig.e2eTestCommand === "npx -y playwright test";
4258
4293
  const cmd = isPlaywright && test_name ? `${processConfig.e2eTestCommand} ${test_name}` : processConfig.e2eTestCommand;
4259
4294
  try {
@@ -4375,8 +4410,8 @@ var Runner = class {
4375
4410
  await this.pm2.stopAll();
4376
4411
  this.log_cb("\u{1F6D1} Stopped all processes.");
4377
4412
  }
4378
- async pm2Logs() {
4379
- return await this.pm2.logs();
4413
+ async pm2Logs(lines) {
4414
+ return await this.pm2.logs(void 0, lines || 100);
4380
4415
  }
4381
4416
  async list() {
4382
4417
  try {
@@ -4394,6 +4429,14 @@ var Runner = class {
4394
4429
  return [];
4395
4430
  }
4396
4431
  }
4432
+ async flush() {
4433
+ try {
4434
+ await this.pm2.flush();
4435
+ this.log_cb(`\u2705 Flushed PM2 logs`);
4436
+ } catch (error) {
4437
+ this.log_cb(`\u274C Failed to flush logs: ${error}`);
4438
+ }
4439
+ }
4397
4440
  async getConfiguredProcesses() {
4398
4441
  try {
4399
4442
  const config = await findAndLoadPm2Config(this.cwd);
@@ -4407,9 +4450,9 @@ var Runner = class {
4407
4450
  * Get logs for a specific process
4408
4451
  * @param processName Name of the process to get logs for
4409
4452
  */
4410
- async getProcessLogs(processName) {
4453
+ async getProcessLogs(processName, lines = 100) {
4411
4454
  try {
4412
- const logs = await this.pm2.logs(processName);
4455
+ const logs = await this.pm2.logs(processName, lines);
4413
4456
  return logs;
4414
4457
  } catch (error) {
4415
4458
  this.log_cb(`\u274C Failed to get logs for ${processName}: ${error}`);
@@ -10906,7 +10949,7 @@ var glob = Object.assign(glob_, {
10906
10949
  glob.glob = glob;
10907
10950
 
10908
10951
  // src/proxy/version.ts
10909
- var VERSION = "0.3.36";
10952
+ var VERSION = "0.3.40";
10910
10953
 
10911
10954
  // src/cli.ts
10912
10955
  var STAKLINK_PROXY = "staklink-proxy";
@@ -11061,4 +11104,30 @@ program2.command("logs").description("View staklink proxy server logs").action(a
11061
11104
  process.exit(1);
11062
11105
  }
11063
11106
  });
11107
+ program2.command("reload").description("Reload all PM2 apps (stops all except proxy, reruns startup)").action(async () => {
11108
+ try {
11109
+ const root = await workspaceRoot();
11110
+ const runner = new Runner(root, console.log);
11111
+ const proxyExists = await runner.doesProcessExist(STAKLINK_PROXY);
11112
+ if (!proxyExists) {
11113
+ console.log("\u274C Staklink server is not running");
11114
+ console.log("Run 'staklink start' first");
11115
+ return;
11116
+ }
11117
+ console.log("Reloading all PM2 apps...");
11118
+ const response = await fetch("http://localhost:15552/reload-apps", {
11119
+ method: "PUT"
11120
+ });
11121
+ if (!response.ok) {
11122
+ const errorData = await response.json().catch(() => ({}));
11123
+ throw new Error(
11124
+ errorData.error || `Failed to reload: ${response.statusText}`
11125
+ );
11126
+ }
11127
+ console.log("\u2705 Apps reloaded successfully");
11128
+ } catch (error) {
11129
+ console.error("Failed to reload apps:", error);
11130
+ process.exit(1);
11131
+ }
11132
+ });
11064
11133
  program2.parse();
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.3.36",
5
+ "version": "0.3.40",
6
6
  "type": "module",
7
7
  "publisher": "stakwork",
8
8
  "engines": {
@@ -114,11 +114,10 @@
114
114
  "try-aieo": "ts-node ./src/try/try-aieo.ts"
115
115
  },
116
116
  "dependencies": {
117
- "@ai-sdk/anthropic": "^2.0.6",
118
- "@ai-sdk/google": "^2.0.8",
119
- "ai": "^5.0.22",
120
- "ai-sdk-provider-claude-code": "^1.1.0",
121
- "aieo": "^0.1.23",
117
+ "@ai-sdk/anthropic": "3.0.0-beta.66",
118
+ "@ai-sdk/google": "3.0.0-beta.62",
119
+ "ai": "6.0.0-beta.124",
120
+ "aieo": "^0.1.29",
122
121
  "async-mutex": "^0.5.0",
123
122
  "commander": "^14.0.1",
124
123
  "dotenv": "^16.4.7",
@@ -132,6 +131,7 @@
132
131
  },
133
132
  "devDependencies": {
134
133
  "@ai-sdk/openai": "^1.3.20",
134
+ "ai-sdk-provider-claude-code": "^1.1.0",
135
135
  "@anthropic-ai/sdk": "^0.39.0",
136
136
  "@google/generative-ai": "^0.24.0",
137
137
  "@playwright/test": "^1.56.1",