opencode-supertask 0.1.16 → 0.1.18

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 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
- const conditions2 = [];
9558
- conditions2.push(sql`${tasks2.batchId} NOT IN ${scope.excludedBatchIds}`);
9559
- batchFilter = and(...conditions2);
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,7 +22781,8 @@ __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";
@@ -22943,6 +22945,26 @@ function uninstall() {
22943
22945
  console.log("[supertask] Note: pm2 startup config was not removed (you may have other pm2 processes).");
22944
22946
  console.log("[supertask] To fully remove pm2 startup: pm2 unstartup");
22945
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
+ }
22946
22968
  function ensureGateway() {
22947
22969
  const currentVersion = getPackageVersion();
22948
22970
  try {
@@ -23320,5 +23342,33 @@ program2.command("uninstall").description("Stop and remove Gateway pm2 service")
23320
23342
  process.exit(1);
23321
23343
  }
23322
23344
  });
23345
+ program2.command("upgrade").description("Update npm package and restart Gateway").action(async () => {
23346
+ const { execSync: execSync2 } = await import("child_process");
23347
+ const { homedir: homedir4 } = await import("os");
23348
+ const { join: join4 } = await import("path");
23349
+ const configDir = join4(homedir4(), ".config/opencode");
23350
+ console.log("Updating opencode-supertask...");
23351
+ try {
23352
+ execSync2("npm install opencode-supertask@latest", {
23353
+ cwd: configDir,
23354
+ stdio: "inherit",
23355
+ timeout: 6e4
23356
+ });
23357
+ } catch (err) {
23358
+ console.error("npm install failed:", err instanceof Error ? err.message : String(err));
23359
+ console.error("Try manually: cd ~/.config/opencode && npm install opencode-supertask@latest");
23360
+ process.exit(1);
23361
+ }
23362
+ try {
23363
+ const { upgrade: pm2Upgrade } = await Promise.resolve().then(() => (init_pm2(), pm2_exports));
23364
+ const result = pm2Upgrade();
23365
+ console.log(`
23366
+ SuperTask upgraded: ${result.before ?? "unknown"} \u2192 ${result.after}`);
23367
+ console.log("Gateway restarted. Please restart opencode to load the new plugin.");
23368
+ } catch (err) {
23369
+ console.error("Gateway restart failed:", err instanceof Error ? err.message : String(err));
23370
+ process.exit(1);
23371
+ }
23372
+ });
23323
23373
  program2.parse();
23324
23374
  //# sourceMappingURL=index.js.map