opencode-supertask 0.1.14 → 0.1.16

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.
@@ -27233,10 +27233,12 @@ function parseDuration(input) {
27233
27233
  import { execSync, spawnSync } from "child_process";
27234
27234
  import { join as join2, dirname as dirname2 } from "path";
27235
27235
  import { fileURLToPath as fileURLToPath2 } from "url";
27236
- import { readFileSync } from "fs";
27236
+ import { readFileSync, writeFileSync, existsSync as existsSync2 } from "fs";
27237
+ import { homedir as homedir2 } from "os";
27237
27238
  var __dirname = dirname2(fileURLToPath2(import.meta.url));
27238
27239
  var GATEWAY_ENTRY = join2(__dirname, "../gateway/index.js");
27239
27240
  var PROCESS_NAME = "supertask-gateway";
27241
+ var VERSION_FILE = join2(homedir2(), ".local/share/opencode/supertask-gateway-version");
27240
27242
  function getPackageVersion() {
27241
27243
  try {
27242
27244
  const pkgPath = join2(__dirname, "../package.json");
@@ -27246,6 +27248,20 @@ function getPackageVersion() {
27246
27248
  return "0.0.0";
27247
27249
  }
27248
27250
  }
27251
+ function getRunningVersion() {
27252
+ try {
27253
+ if (!existsSync2(VERSION_FILE)) return null;
27254
+ return readFileSync(VERSION_FILE, "utf-8").trim() || null;
27255
+ } catch {
27256
+ return null;
27257
+ }
27258
+ }
27259
+ function writeRunningVersion(version3) {
27260
+ try {
27261
+ writeFileSync(VERSION_FILE, version3, "utf-8");
27262
+ } catch {
27263
+ }
27264
+ }
27249
27265
  function pm2Bin() {
27250
27266
  return process.platform === "win32" ? "pm2.cmd" : "pm2";
27251
27267
  }
@@ -27312,14 +27328,14 @@ function ensureGateway() {
27312
27328
  const list = pm2JsonList();
27313
27329
  const proc = list.find((p) => p.name === PROCESS_NAME);
27314
27330
  if (proc && proc.pm2_env?.status === "online") {
27315
- const runningVersion = proc.pm2_env.pm_exec_path ? void 0 : void 0;
27316
- const envVersion = proc.pm2_env.env?.SUPERTASK_VERSION;
27317
- if (envVersion === currentVersion) {
27331
+ const runningVersion = getRunningVersion();
27332
+ if (runningVersion === currentVersion) {
27318
27333
  return;
27319
27334
  }
27320
- console.log(`[supertask] Version changed: ${envVersion ?? "unknown"} \u2192 ${currentVersion}, reloading Gateway...`);
27335
+ console.log(`[supertask] Version changed: ${runningVersion ?? "unknown"} \u2192 ${currentVersion}, reloading Gateway...`);
27321
27336
  pm2Exec(["delete", PROCESS_NAME]);
27322
- pm2StartGateway(currentVersion);
27337
+ const { ok } = pm2StartGateway(currentVersion);
27338
+ if (ok) writeRunningVersion(currentVersion);
27323
27339
  pm2Exec(["save"]);
27324
27340
  return;
27325
27341
  }
@@ -27344,7 +27360,8 @@ function ensureGateway() {
27344
27360
  pm2Exec(["restart", PROCESS_NAME]);
27345
27361
  } else {
27346
27362
  const version3 = getPackageVersion();
27347
- pm2StartGateway(version3);
27363
+ const { ok } = pm2StartGateway(version3);
27364
+ if (ok) writeRunningVersion(version3);
27348
27365
  }
27349
27366
  pm2Exec(["save"]);
27350
27367
  }