opencode-supertask 0.1.15 → 0.1.17
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 +71 -21
- package/dist/cli/index.js.map +1 -1
- package/dist/gateway/index.js +8 -7
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +21753 -21080
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +8 -7
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.js +8 -7
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -9554,9 +9554,10 @@ var init_task_service = __esm({
|
|
|
9554
9554
|
const hasExcludedBatches = scope.excludedBatchIds && scope.excludedBatchIds.length > 0;
|
|
9555
9555
|
let batchFilter;
|
|
9556
9556
|
if (hasExcludedBatches) {
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9557
|
+
batchFilter = or(
|
|
9558
|
+
isNull(tasks2.batchId),
|
|
9559
|
+
sql`${tasks2.batchId} NOT IN ${scope.excludedBatchIds}`
|
|
9560
|
+
);
|
|
9560
9561
|
}
|
|
9561
9562
|
const statusConditions = or(
|
|
9562
9563
|
and(
|
|
@@ -9721,7 +9722,7 @@ var init_task_service = __esm({
|
|
|
9721
9722
|
if (conditions.length > 0) {
|
|
9722
9723
|
query = query.where(and(...conditions));
|
|
9723
9724
|
}
|
|
9724
|
-
query = query.orderBy(desc(tasks2.createdAt));
|
|
9725
|
+
query = query.orderBy(desc(tasks2.createdAt), desc(tasks2.id));
|
|
9725
9726
|
if (options.limit) {
|
|
9726
9727
|
query = query.limit(options.limit);
|
|
9727
9728
|
}
|
|
@@ -19169,10 +19170,10 @@ var init_task_run_service = __esm({
|
|
|
19169
19170
|
return result[0] || null;
|
|
19170
19171
|
}
|
|
19171
19172
|
static async listByTaskId(taskId) {
|
|
19172
|
-
return await db.select().from(taskRuns2).where(eq(taskRuns2.taskId, taskId)).orderBy(desc(taskRuns2.startedAt));
|
|
19173
|
+
return await db.select().from(taskRuns2).where(eq(taskRuns2.taskId, taskId)).orderBy(desc(taskRuns2.startedAt), desc(taskRuns2.id));
|
|
19173
19174
|
}
|
|
19174
19175
|
static async getLatestByTaskId(taskId) {
|
|
19175
|
-
const result = await db.select().from(taskRuns2).where(eq(taskRuns2.taskId, taskId)).orderBy(desc(taskRuns2.startedAt)).limit(1);
|
|
19176
|
+
const result = await db.select().from(taskRuns2).where(eq(taskRuns2.taskId, taskId)).orderBy(desc(taskRuns2.startedAt), desc(taskRuns2.id)).limit(1);
|
|
19176
19177
|
return result[0] || null;
|
|
19177
19178
|
}
|
|
19178
19179
|
static async getLatestByTaskIds(taskIds) {
|
|
@@ -19220,7 +19221,7 @@ var init_task_run_service = __esm({
|
|
|
19220
19221
|
}));
|
|
19221
19222
|
}
|
|
19222
19223
|
static async getRunningRunByTaskId(taskId) {
|
|
19223
|
-
const result = await db.select().from(taskRuns2).where(and(eq(taskRuns2.taskId, taskId), eq(taskRuns2.status, "running"))).orderBy(desc(taskRuns2.startedAt)).limit(1);
|
|
19224
|
+
const result = await db.select().from(taskRuns2).where(and(eq(taskRuns2.taskId, taskId), eq(taskRuns2.status, "running"))).orderBy(desc(taskRuns2.startedAt), desc(taskRuns2.id)).limit(1);
|
|
19224
19225
|
return result[0] || null;
|
|
19225
19226
|
}
|
|
19226
19227
|
static async deleteByTaskIds(taskIds) {
|
|
@@ -22780,12 +22781,14 @@ __export(pm2_exports, {
|
|
|
22780
22781
|
ensureGateway: () => ensureGateway,
|
|
22781
22782
|
install: () => install,
|
|
22782
22783
|
isGatewayRunning: () => isGatewayRunning,
|
|
22783
|
-
uninstall: () => uninstall
|
|
22784
|
+
uninstall: () => uninstall,
|
|
22785
|
+
upgrade: () => upgrade
|
|
22784
22786
|
});
|
|
22785
22787
|
import { execSync, spawnSync } from "child_process";
|
|
22786
22788
|
import { join as join3, dirname as dirname3 } from "path";
|
|
22787
22789
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
22788
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
22790
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync4 } from "fs";
|
|
22791
|
+
import { homedir as homedir3 } from "os";
|
|
22789
22792
|
function getPackageVersion() {
|
|
22790
22793
|
try {
|
|
22791
22794
|
const pkgPath = join3(__dirname, "../package.json");
|
|
@@ -22795,6 +22798,20 @@ function getPackageVersion() {
|
|
|
22795
22798
|
return "0.0.0";
|
|
22796
22799
|
}
|
|
22797
22800
|
}
|
|
22801
|
+
function getRunningVersion() {
|
|
22802
|
+
try {
|
|
22803
|
+
if (!existsSync4(VERSION_FILE)) return null;
|
|
22804
|
+
return readFileSync3(VERSION_FILE, "utf-8").trim() || null;
|
|
22805
|
+
} catch {
|
|
22806
|
+
return null;
|
|
22807
|
+
}
|
|
22808
|
+
}
|
|
22809
|
+
function writeRunningVersion(version2) {
|
|
22810
|
+
try {
|
|
22811
|
+
writeFileSync2(VERSION_FILE, version2, "utf-8");
|
|
22812
|
+
} catch {
|
|
22813
|
+
}
|
|
22814
|
+
}
|
|
22798
22815
|
function pm2Bin() {
|
|
22799
22816
|
return process.platform === "win32" ? "pm2.cmd" : "pm2";
|
|
22800
22817
|
}
|
|
@@ -22898,6 +22915,7 @@ function install() {
|
|
|
22898
22915
|
if (!ok) {
|
|
22899
22916
|
throw new Error(`[supertask] pm2 start failed: ${output}`);
|
|
22900
22917
|
}
|
|
22918
|
+
writeRunningVersion(version2);
|
|
22901
22919
|
}
|
|
22902
22920
|
pm2Exec(["save"]);
|
|
22903
22921
|
console.log("[supertask] Configuring startup...");
|
|
@@ -22927,20 +22945,40 @@ function uninstall() {
|
|
|
22927
22945
|
console.log("[supertask] Note: pm2 startup config was not removed (you may have other pm2 processes).");
|
|
22928
22946
|
console.log("[supertask] To fully remove pm2 startup: pm2 unstartup");
|
|
22929
22947
|
}
|
|
22948
|
+
function upgrade() {
|
|
22949
|
+
const before = getRunningVersion();
|
|
22950
|
+
const currentVersion = getPackageVersion();
|
|
22951
|
+
const list = pm2JsonList();
|
|
22952
|
+
const proc = list.find((p) => p.name === PROCESS_NAME);
|
|
22953
|
+
if (proc) {
|
|
22954
|
+
console.log(`[supertask] Stopping Gateway (version ${before ?? "unknown"})...`);
|
|
22955
|
+
pm2Exec(["delete", PROCESS_NAME]);
|
|
22956
|
+
}
|
|
22957
|
+
console.log(`[supertask] Starting Gateway (version ${currentVersion})...`);
|
|
22958
|
+
const { ok } = pm2StartGateway(currentVersion);
|
|
22959
|
+
if (ok) {
|
|
22960
|
+
writeRunningVersion(currentVersion);
|
|
22961
|
+
pm2Exec(["save"]);
|
|
22962
|
+
console.log(`[supertask] Gateway upgraded: ${before ?? "unknown"} \u2192 ${currentVersion}`);
|
|
22963
|
+
} else {
|
|
22964
|
+
throw new Error(`[supertask] Failed to start Gateway after upgrade`);
|
|
22965
|
+
}
|
|
22966
|
+
return { before, after: currentVersion, restarted: true };
|
|
22967
|
+
}
|
|
22930
22968
|
function ensureGateway() {
|
|
22931
22969
|
const currentVersion = getPackageVersion();
|
|
22932
22970
|
try {
|
|
22933
22971
|
const list = pm2JsonList();
|
|
22934
22972
|
const proc = list.find((p) => p.name === PROCESS_NAME);
|
|
22935
22973
|
if (proc && proc.pm2_env?.status === "online") {
|
|
22936
|
-
const runningVersion =
|
|
22937
|
-
|
|
22938
|
-
if (envVersion === currentVersion) {
|
|
22974
|
+
const runningVersion = getRunningVersion();
|
|
22975
|
+
if (runningVersion === currentVersion) {
|
|
22939
22976
|
return;
|
|
22940
22977
|
}
|
|
22941
|
-
console.log(`[supertask] Version changed: ${
|
|
22978
|
+
console.log(`[supertask] Version changed: ${runningVersion ?? "unknown"} \u2192 ${currentVersion}, reloading Gateway...`);
|
|
22942
22979
|
pm2Exec(["delete", PROCESS_NAME]);
|
|
22943
|
-
pm2StartGateway(currentVersion);
|
|
22980
|
+
const { ok } = pm2StartGateway(currentVersion);
|
|
22981
|
+
if (ok) writeRunningVersion(currentVersion);
|
|
22944
22982
|
pm2Exec(["save"]);
|
|
22945
22983
|
return;
|
|
22946
22984
|
}
|
|
@@ -22965,17 +23003,19 @@ function ensureGateway() {
|
|
|
22965
23003
|
pm2Exec(["restart", PROCESS_NAME]);
|
|
22966
23004
|
} else {
|
|
22967
23005
|
const version2 = getPackageVersion();
|
|
22968
|
-
pm2StartGateway(version2);
|
|
23006
|
+
const { ok } = pm2StartGateway(version2);
|
|
23007
|
+
if (ok) writeRunningVersion(version2);
|
|
22969
23008
|
}
|
|
22970
23009
|
pm2Exec(["save"]);
|
|
22971
23010
|
}
|
|
22972
|
-
var __dirname, GATEWAY_ENTRY, PROCESS_NAME;
|
|
23011
|
+
var __dirname, GATEWAY_ENTRY, PROCESS_NAME, VERSION_FILE;
|
|
22973
23012
|
var init_pm2 = __esm({
|
|
22974
23013
|
"src/daemon/pm2.ts"() {
|
|
22975
23014
|
"use strict";
|
|
22976
23015
|
__dirname = dirname3(fileURLToPath2(import.meta.url));
|
|
22977
23016
|
GATEWAY_ENTRY = join3(__dirname, "../gateway/index.js");
|
|
22978
23017
|
PROCESS_NAME = "supertask-gateway";
|
|
23018
|
+
VERSION_FILE = join3(homedir3(), ".local/share/opencode/supertask-gateway-version");
|
|
22979
23019
|
}
|
|
22980
23020
|
});
|
|
22981
23021
|
|
|
@@ -23231,14 +23271,14 @@ program2.command("template").description("\u7BA1\u7406\u4EFB\u52A1\u8C03\u5EA6\u
|
|
|
23231
23271
|
}))
|
|
23232
23272
|
);
|
|
23233
23273
|
program2.command("init").description("Initialize SuperTask (create config + run migrations)").action(async () => withDb(async () => {
|
|
23234
|
-
const { existsSync:
|
|
23235
|
-
const { homedir:
|
|
23274
|
+
const { existsSync: existsSync5, mkdirSync: mkdirSync3, writeFileSync: writeFileSync3 } = await import("fs");
|
|
23275
|
+
const { homedir: homedir4 } = await import("os");
|
|
23236
23276
|
const { join: join4, dirname: dirname4 } = await import("path");
|
|
23237
23277
|
const { CONFIG_PATH: CONFIG_PATH2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
23238
|
-
if (!
|
|
23278
|
+
if (!existsSync5(CONFIG_PATH2)) {
|
|
23239
23279
|
const dir = dirname4(CONFIG_PATH2);
|
|
23240
|
-
if (!
|
|
23241
|
-
|
|
23280
|
+
if (!existsSync5(dir)) mkdirSync3(dir, { recursive: true });
|
|
23281
|
+
writeFileSync3(CONFIG_PATH2, JSON.stringify({
|
|
23242
23282
|
worker: { maxConcurrency: 2, defaultModel: "zhipuai-coding-plan/glm-4.7" },
|
|
23243
23283
|
scheduler: { enabled: true }
|
|
23244
23284
|
}, null, 2) + "\n");
|
|
@@ -23302,5 +23342,15 @@ program2.command("uninstall").description("Stop and remove Gateway pm2 service")
|
|
|
23302
23342
|
process.exit(1);
|
|
23303
23343
|
}
|
|
23304
23344
|
});
|
|
23345
|
+
program2.command("upgrade").description("Restart Gateway with current plugin version").action(async () => {
|
|
23346
|
+
try {
|
|
23347
|
+
const { upgrade: pm2Upgrade } = await Promise.resolve().then(() => (init_pm2(), pm2_exports));
|
|
23348
|
+
const result = pm2Upgrade();
|
|
23349
|
+
console.log(JSON.stringify({ before: result.before, after: result.after, restarted: result.restarted }));
|
|
23350
|
+
} catch (err) {
|
|
23351
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
23352
|
+
process.exit(1);
|
|
23353
|
+
}
|
|
23354
|
+
});
|
|
23305
23355
|
program2.parse();
|
|
23306
23356
|
//# sourceMappingURL=index.js.map
|