opencode-supertask 0.1.39 → 0.1.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.
- package/CHANGELOG.md +9 -0
- package/README.md +152 -352
- package/README.zh-CN.md +243 -0
- package/dist/cli/index.js +215 -47
- package/dist/cli/index.js.map +1 -1
- package/dist/gateway/index.js +195 -43
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +37 -4
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +179 -41
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.d.ts +1 -0
- package/dist/worker/index.js +34 -3
- package/dist/worker/index.js.map +1 -1
- package/drizzle/0008_good_smasher.sql +3 -0
- package/drizzle/meta/0008_snapshot.json +606 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
package/dist/worker/index.d.ts
CHANGED
package/dist/worker/index.js
CHANGED
|
@@ -5157,6 +5157,7 @@ var tasks = sqliteTable("tasks", {
|
|
|
5157
5157
|
name: text("name").notNull(),
|
|
5158
5158
|
agent: text("agent").notNull(),
|
|
5159
5159
|
model: text("model").default("default"),
|
|
5160
|
+
variant: text("variant"),
|
|
5160
5161
|
prompt: text("prompt").notNull(),
|
|
5161
5162
|
cwd: text("cwd"),
|
|
5162
5163
|
// 分类与优先级
|
|
@@ -5201,6 +5202,7 @@ var taskRuns = sqliteTable("task_runs", {
|
|
|
5201
5202
|
taskId: integer("task_id").notNull().references(() => tasks.id, { onDelete: "cascade" }),
|
|
5202
5203
|
sessionId: text("session_id"),
|
|
5203
5204
|
model: text("model"),
|
|
5205
|
+
variant: text("variant"),
|
|
5204
5206
|
status: text("status").default("running"),
|
|
5205
5207
|
startedAt: integer("started_at", { mode: "timestamp" }).$defaultFn(() => /* @__PURE__ */ new Date()),
|
|
5206
5208
|
finishedAt: integer("finished_at", { mode: "timestamp" }),
|
|
@@ -5221,6 +5223,7 @@ var taskTemplates = sqliteTable("task_templates", {
|
|
|
5221
5223
|
name: text("name").notNull(),
|
|
5222
5224
|
agent: text("agent").notNull(),
|
|
5223
5225
|
model: text("model").default("default"),
|
|
5226
|
+
variant: text("variant"),
|
|
5224
5227
|
prompt: text("prompt").notNull(),
|
|
5225
5228
|
cwd: text("cwd"),
|
|
5226
5229
|
category: text("category").default("general"),
|
|
@@ -5395,6 +5398,22 @@ function normalizeTaskBatchId(batchId) {
|
|
|
5395
5398
|
return batchId.trim() || null;
|
|
5396
5399
|
}
|
|
5397
5400
|
|
|
5401
|
+
// src/core/model-variant.ts
|
|
5402
|
+
var MAX_MODEL_VARIANT_LENGTH = 128;
|
|
5403
|
+
var CONTROL_CHARACTER_PATTERN = /[\u0000-\u001F\u007F]/;
|
|
5404
|
+
function normalizeModelVariant(value) {
|
|
5405
|
+
if (value === void 0 || value === null) return value;
|
|
5406
|
+
const normalized = value.trim();
|
|
5407
|
+
if (!normalized) return null;
|
|
5408
|
+
if (normalized.length > MAX_MODEL_VARIANT_LENGTH) {
|
|
5409
|
+
throw new Error(`variant \u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 ${MAX_MODEL_VARIANT_LENGTH} \u4E2A\u5B57\u7B26`);
|
|
5410
|
+
}
|
|
5411
|
+
if (CONTROL_CHARACTER_PATTERN.test(normalized)) {
|
|
5412
|
+
throw new Error("variant \u4E0D\u80FD\u5305\u542B\u63A7\u5236\u5B57\u7B26");
|
|
5413
|
+
}
|
|
5414
|
+
return normalized;
|
|
5415
|
+
}
|
|
5416
|
+
|
|
5398
5417
|
// src/core/services/task.service.ts
|
|
5399
5418
|
var { tasks: tasks2, taskRuns: taskRuns2 } = schema_exports;
|
|
5400
5419
|
var cleanupInvocation = 0;
|
|
@@ -5460,7 +5479,8 @@ var TaskService = class {
|
|
|
5460
5479
|
static async add(data) {
|
|
5461
5480
|
const normalizedData = {
|
|
5462
5481
|
...data,
|
|
5463
|
-
batchId: normalizeTaskBatchId(data.batchId)
|
|
5482
|
+
batchId: normalizeTaskBatchId(data.batchId),
|
|
5483
|
+
variant: normalizeModelVariant(data.variant)
|
|
5464
5484
|
};
|
|
5465
5485
|
this.validateNewTask(normalizedData);
|
|
5466
5486
|
return db.transaction((tx) => {
|
|
@@ -5488,7 +5508,11 @@ var TaskService = class {
|
|
|
5488
5508
|
}
|
|
5489
5509
|
static async update(id, data, scope = {}) {
|
|
5490
5510
|
if (Object.keys(data).length === 0) throw new Error("\u81F3\u5C11\u63D0\u4F9B\u4E00\u4E2A\u8981\u4FEE\u6539\u7684\u5B57\u6BB5");
|
|
5491
|
-
const normalizedData =
|
|
5511
|
+
const normalizedData = {
|
|
5512
|
+
...data,
|
|
5513
|
+
...data.batchId === void 0 ? {} : { batchId: normalizeTaskBatchId(data.batchId) ?? null },
|
|
5514
|
+
...data.variant === void 0 ? {} : { variant: normalizeModelVariant(data.variant) ?? null }
|
|
5515
|
+
};
|
|
5492
5516
|
return db.transaction((tx) => {
|
|
5493
5517
|
const task = tx.select().from(tasks2).where(and(
|
|
5494
5518
|
eq(tasks2.id, id),
|
|
@@ -5500,6 +5524,7 @@ var TaskService = class {
|
|
|
5500
5524
|
name: normalizedData.name ?? task.name,
|
|
5501
5525
|
agent: normalizedData.agent ?? task.agent,
|
|
5502
5526
|
model: normalizedData.model ?? task.model,
|
|
5527
|
+
variant: normalizedData.variant === void 0 ? task.variant : normalizedData.variant,
|
|
5503
5528
|
prompt: normalizedData.prompt ?? task.prompt,
|
|
5504
5529
|
cwd: task.cwd,
|
|
5505
5530
|
category: normalizedData.category ?? task.category,
|
|
@@ -6783,6 +6808,7 @@ var WorkerEngine = class {
|
|
|
6783
6808
|
const run = await TaskRunService.create({
|
|
6784
6809
|
taskId: task.id,
|
|
6785
6810
|
model: this.resolveModel(task.model),
|
|
6811
|
+
variant: this.resolveVariant(task.variant),
|
|
6786
6812
|
status: "running",
|
|
6787
6813
|
workerPid: process.pid,
|
|
6788
6814
|
lockedAt: Date.now(),
|
|
@@ -6845,8 +6871,10 @@ var WorkerEngine = class {
|
|
|
6845
6871
|
}
|
|
6846
6872
|
async spawnTask(task, runId, launchIdentity) {
|
|
6847
6873
|
const model = this.resolveModel(task.model);
|
|
6874
|
+
const variant = this.resolveVariant(task.variant);
|
|
6848
6875
|
const args = ["run", "--agent", task.agent, "--format", "json"];
|
|
6849
6876
|
if (model) args.push("-m", model);
|
|
6877
|
+
if (variant) args.push("--variant", variant);
|
|
6850
6878
|
args.push(task.prompt);
|
|
6851
6879
|
const cwd = task.cwd || process.cwd();
|
|
6852
6880
|
const child = spawn(process.execPath, [
|
|
@@ -7005,7 +7033,7 @@ var WorkerEngine = class {
|
|
|
7005
7033
|
);
|
|
7006
7034
|
return;
|
|
7007
7035
|
}
|
|
7008
|
-
const failure = code === 0 ? void 0 : `${spawnError ? "\u65E0\u6CD5\u542F\u52A8 opencode" : "opencode \u9000\u51FA\u7801"} ${spawnError?.message ?? code ?? "null"}${signal ? `\uFF0C\u4FE1\u53F7 ${signal}` : ""}\uFF08agent=${entry.task.agent}\uFF0Cmodel=${this.resolveModel(entry.task.model) ?? "Agent/\u9ED8\u8BA4\u914D\u7F6E"}\uFF0Ccwd=${entry.task.cwd ?? process.cwd()}\uFF09`;
|
|
7036
|
+
const failure = code === 0 ? void 0 : `${spawnError ? "\u65E0\u6CD5\u542F\u52A8 opencode" : "opencode \u9000\u51FA\u7801"} ${spawnError?.message ?? code ?? "null"}${signal ? `\uFF0C\u4FE1\u53F7 ${signal}` : ""}\uFF08agent=${entry.task.agent}\uFF0Cmodel=${this.resolveModel(entry.task.model) ?? "Agent/\u9ED8\u8BA4\u914D\u7F6E"}\uFF0Cvariant=${this.resolveVariant(entry.task.variant) ?? "Agent/\u6A21\u578B\u9ED8\u8BA4\u914D\u7F6E"}\uFF0Ccwd=${entry.task.cwd ?? process.cwd()}\uFF09`;
|
|
7009
7037
|
this.runDetached(
|
|
7010
7038
|
this.settleEntry(entry, code, failure),
|
|
7011
7039
|
"task settlement failed",
|
|
@@ -7194,6 +7222,9 @@ ${output}` : ""}`;
|
|
|
7194
7222
|
if (!taskModel || taskModel === "default") return null;
|
|
7195
7223
|
return taskModel;
|
|
7196
7224
|
}
|
|
7225
|
+
resolveVariant(taskVariant) {
|
|
7226
|
+
return taskVariant?.trim() || null;
|
|
7227
|
+
}
|
|
7197
7228
|
runDetached(operation, message, taskId) {
|
|
7198
7229
|
operation.catch((error) => {
|
|
7199
7230
|
markGatewayFailure("worker", error);
|