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.
- package/dist/cli/index.js +32 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/gateway/index.js +1 -1
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +24 -7
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -19308,7 +19308,7 @@ var init_worker = __esm({
|
|
|
19308
19308
|
const modelArg = modelToUse ? ` -m "${modelToUse}"` : "";
|
|
19309
19309
|
const cmd = `opencode run --agent supertask-runner${modelArg} --format json "\u6267\u884C\u4EFB\u52A1 ID: ${task.id}${modelToUse ? ` OVERRIDE_MODEL=${modelToUse}` : ""}"`;
|
|
19310
19310
|
const cwd = task.cwd || process.cwd();
|
|
19311
|
-
const child = spawn("sh", ["-c", cmd], { cwd, stdio: ["
|
|
19311
|
+
const child = spawn("sh", ["-c", cmd], { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
19312
19312
|
await TaskRunService.updatePid(run.id, process.pid, child.pid ?? 0);
|
|
19313
19313
|
let output = "";
|
|
19314
19314
|
const handleData = (data) => {
|
|
@@ -22785,7 +22785,8 @@ __export(pm2_exports, {
|
|
|
22785
22785
|
import { execSync, spawnSync } from "child_process";
|
|
22786
22786
|
import { join as join3, dirname as dirname3 } from "path";
|
|
22787
22787
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
22788
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
22788
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync4 } from "fs";
|
|
22789
|
+
import { homedir as homedir3 } from "os";
|
|
22789
22790
|
function getPackageVersion() {
|
|
22790
22791
|
try {
|
|
22791
22792
|
const pkgPath = join3(__dirname, "../package.json");
|
|
@@ -22795,6 +22796,20 @@ function getPackageVersion() {
|
|
|
22795
22796
|
return "0.0.0";
|
|
22796
22797
|
}
|
|
22797
22798
|
}
|
|
22799
|
+
function getRunningVersion() {
|
|
22800
|
+
try {
|
|
22801
|
+
if (!existsSync4(VERSION_FILE)) return null;
|
|
22802
|
+
return readFileSync3(VERSION_FILE, "utf-8").trim() || null;
|
|
22803
|
+
} catch {
|
|
22804
|
+
return null;
|
|
22805
|
+
}
|
|
22806
|
+
}
|
|
22807
|
+
function writeRunningVersion(version2) {
|
|
22808
|
+
try {
|
|
22809
|
+
writeFileSync2(VERSION_FILE, version2, "utf-8");
|
|
22810
|
+
} catch {
|
|
22811
|
+
}
|
|
22812
|
+
}
|
|
22798
22813
|
function pm2Bin() {
|
|
22799
22814
|
return process.platform === "win32" ? "pm2.cmd" : "pm2";
|
|
22800
22815
|
}
|
|
@@ -22898,6 +22913,7 @@ function install() {
|
|
|
22898
22913
|
if (!ok) {
|
|
22899
22914
|
throw new Error(`[supertask] pm2 start failed: ${output}`);
|
|
22900
22915
|
}
|
|
22916
|
+
writeRunningVersion(version2);
|
|
22901
22917
|
}
|
|
22902
22918
|
pm2Exec(["save"]);
|
|
22903
22919
|
console.log("[supertask] Configuring startup...");
|
|
@@ -22933,14 +22949,14 @@ function ensureGateway() {
|
|
|
22933
22949
|
const list = pm2JsonList();
|
|
22934
22950
|
const proc = list.find((p) => p.name === PROCESS_NAME);
|
|
22935
22951
|
if (proc && proc.pm2_env?.status === "online") {
|
|
22936
|
-
const runningVersion =
|
|
22937
|
-
|
|
22938
|
-
if (envVersion === currentVersion) {
|
|
22952
|
+
const runningVersion = getRunningVersion();
|
|
22953
|
+
if (runningVersion === currentVersion) {
|
|
22939
22954
|
return;
|
|
22940
22955
|
}
|
|
22941
|
-
console.log(`[supertask] Version changed: ${
|
|
22956
|
+
console.log(`[supertask] Version changed: ${runningVersion ?? "unknown"} \u2192 ${currentVersion}, reloading Gateway...`);
|
|
22942
22957
|
pm2Exec(["delete", PROCESS_NAME]);
|
|
22943
|
-
pm2StartGateway(currentVersion);
|
|
22958
|
+
const { ok } = pm2StartGateway(currentVersion);
|
|
22959
|
+
if (ok) writeRunningVersion(currentVersion);
|
|
22944
22960
|
pm2Exec(["save"]);
|
|
22945
22961
|
return;
|
|
22946
22962
|
}
|
|
@@ -22965,17 +22981,19 @@ function ensureGateway() {
|
|
|
22965
22981
|
pm2Exec(["restart", PROCESS_NAME]);
|
|
22966
22982
|
} else {
|
|
22967
22983
|
const version2 = getPackageVersion();
|
|
22968
|
-
pm2StartGateway(version2);
|
|
22984
|
+
const { ok } = pm2StartGateway(version2);
|
|
22985
|
+
if (ok) writeRunningVersion(version2);
|
|
22969
22986
|
}
|
|
22970
22987
|
pm2Exec(["save"]);
|
|
22971
22988
|
}
|
|
22972
|
-
var __dirname, GATEWAY_ENTRY, PROCESS_NAME;
|
|
22989
|
+
var __dirname, GATEWAY_ENTRY, PROCESS_NAME, VERSION_FILE;
|
|
22973
22990
|
var init_pm2 = __esm({
|
|
22974
22991
|
"src/daemon/pm2.ts"() {
|
|
22975
22992
|
"use strict";
|
|
22976
22993
|
__dirname = dirname3(fileURLToPath2(import.meta.url));
|
|
22977
22994
|
GATEWAY_ENTRY = join3(__dirname, "../gateway/index.js");
|
|
22978
22995
|
PROCESS_NAME = "supertask-gateway";
|
|
22996
|
+
VERSION_FILE = join3(homedir3(), ".local/share/opencode/supertask-gateway-version");
|
|
22979
22997
|
}
|
|
22980
22998
|
});
|
|
22981
22999
|
|
|
@@ -23231,14 +23249,14 @@ program2.command("template").description("\u7BA1\u7406\u4EFB\u52A1\u8C03\u5EA6\u
|
|
|
23231
23249
|
}))
|
|
23232
23250
|
);
|
|
23233
23251
|
program2.command("init").description("Initialize SuperTask (create config + run migrations)").action(async () => withDb(async () => {
|
|
23234
|
-
const { existsSync:
|
|
23235
|
-
const { homedir:
|
|
23252
|
+
const { existsSync: existsSync5, mkdirSync: mkdirSync3, writeFileSync: writeFileSync3 } = await import("fs");
|
|
23253
|
+
const { homedir: homedir4 } = await import("os");
|
|
23236
23254
|
const { join: join4, dirname: dirname4 } = await import("path");
|
|
23237
23255
|
const { CONFIG_PATH: CONFIG_PATH2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
23238
|
-
if (!
|
|
23256
|
+
if (!existsSync5(CONFIG_PATH2)) {
|
|
23239
23257
|
const dir = dirname4(CONFIG_PATH2);
|
|
23240
|
-
if (!
|
|
23241
|
-
|
|
23258
|
+
if (!existsSync5(dir)) mkdirSync3(dir, { recursive: true });
|
|
23259
|
+
writeFileSync3(CONFIG_PATH2, JSON.stringify({
|
|
23242
23260
|
worker: { maxConcurrency: 2, defaultModel: "zhipuai-coding-plan/glm-4.7" },
|
|
23243
23261
|
scheduler: { enabled: true }
|
|
23244
23262
|
}, null, 2) + "\n");
|