opencode-supertask 0.1.39 → 0.1.41
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 +27 -1
- package/LICENSE +21 -0
- package/README.md +159 -352
- package/README.zh-CN.md +250 -0
- package/dist/cli/index.js +580 -171
- package/dist/cli/index.js.map +1 -1
- package/dist/daemon/gateway-diagnostic-runner.d.ts +2 -0
- package/dist/daemon/gateway-diagnostic-runner.js +461 -0
- package/dist/daemon/gateway-diagnostic-runner.js.map +1 -0
- package/dist/gateway/index.js +543 -615
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +90 -28
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +410 -528
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.d.ts +9 -0
- package/dist/worker/index.js +225 -69
- package/dist/worker/index.js.map +1 -1
- package/dist/worker/launcher.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 +12 -3
package/dist/plugin/supertask.js
CHANGED
|
@@ -26774,6 +26774,7 @@ var tasks = sqliteTable("tasks", {
|
|
|
26774
26774
|
name: text("name").notNull(),
|
|
26775
26775
|
agent: text("agent").notNull(),
|
|
26776
26776
|
model: text("model").default("default"),
|
|
26777
|
+
variant: text("variant"),
|
|
26777
26778
|
prompt: text("prompt").notNull(),
|
|
26778
26779
|
cwd: text("cwd"),
|
|
26779
26780
|
// 分类与优先级
|
|
@@ -26818,6 +26819,7 @@ var taskRuns = sqliteTable("task_runs", {
|
|
|
26818
26819
|
taskId: integer2("task_id").notNull().references(() => tasks.id, { onDelete: "cascade" }),
|
|
26819
26820
|
sessionId: text("session_id"),
|
|
26820
26821
|
model: text("model"),
|
|
26822
|
+
variant: text("variant"),
|
|
26821
26823
|
status: text("status").default("running"),
|
|
26822
26824
|
startedAt: integer2("started_at", { mode: "timestamp" }).$defaultFn(() => /* @__PURE__ */ new Date()),
|
|
26823
26825
|
finishedAt: integer2("finished_at", { mode: "timestamp" }),
|
|
@@ -26838,6 +26840,7 @@ var taskTemplates = sqliteTable("task_templates", {
|
|
|
26838
26840
|
name: text("name").notNull(),
|
|
26839
26841
|
agent: text("agent").notNull(),
|
|
26840
26842
|
model: text("model").default("default"),
|
|
26843
|
+
variant: text("variant"),
|
|
26841
26844
|
prompt: text("prompt").notNull(),
|
|
26842
26845
|
cwd: text("cwd"),
|
|
26843
26846
|
category: text("category").default("general"),
|
|
@@ -27012,6 +27015,22 @@ function normalizeTaskBatchId(batchId) {
|
|
|
27012
27015
|
return batchId.trim() || null;
|
|
27013
27016
|
}
|
|
27014
27017
|
|
|
27018
|
+
// src/core/model-variant.ts
|
|
27019
|
+
var MAX_MODEL_VARIANT_LENGTH = 128;
|
|
27020
|
+
var CONTROL_CHARACTER_PATTERN = /[\u0000-\u001F\u007F]/;
|
|
27021
|
+
function normalizeModelVariant(value) {
|
|
27022
|
+
if (value === void 0 || value === null) return value;
|
|
27023
|
+
const normalized = value.trim();
|
|
27024
|
+
if (!normalized) return null;
|
|
27025
|
+
if (normalized.length > MAX_MODEL_VARIANT_LENGTH) {
|
|
27026
|
+
throw new Error(`variant \u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 ${MAX_MODEL_VARIANT_LENGTH} \u4E2A\u5B57\u7B26`);
|
|
27027
|
+
}
|
|
27028
|
+
if (CONTROL_CHARACTER_PATTERN.test(normalized)) {
|
|
27029
|
+
throw new Error("variant \u4E0D\u80FD\u5305\u542B\u63A7\u5236\u5B57\u7B26");
|
|
27030
|
+
}
|
|
27031
|
+
return normalized;
|
|
27032
|
+
}
|
|
27033
|
+
|
|
27015
27034
|
// src/core/services/task.service.ts
|
|
27016
27035
|
var { tasks: tasks2, taskRuns: taskRuns2 } = schema_exports;
|
|
27017
27036
|
var cleanupInvocation = 0;
|
|
@@ -27077,7 +27096,8 @@ var TaskService = class {
|
|
|
27077
27096
|
static async add(data) {
|
|
27078
27097
|
const normalizedData = {
|
|
27079
27098
|
...data,
|
|
27080
|
-
batchId: normalizeTaskBatchId(data.batchId)
|
|
27099
|
+
batchId: normalizeTaskBatchId(data.batchId),
|
|
27100
|
+
variant: normalizeModelVariant(data.variant)
|
|
27081
27101
|
};
|
|
27082
27102
|
this.validateNewTask(normalizedData);
|
|
27083
27103
|
return db.transaction((tx) => {
|
|
@@ -27105,7 +27125,11 @@ var TaskService = class {
|
|
|
27105
27125
|
}
|
|
27106
27126
|
static async update(id, data, scope = {}) {
|
|
27107
27127
|
if (Object.keys(data).length === 0) throw new Error("\u81F3\u5C11\u63D0\u4F9B\u4E00\u4E2A\u8981\u4FEE\u6539\u7684\u5B57\u6BB5");
|
|
27108
|
-
const normalizedData =
|
|
27128
|
+
const normalizedData = {
|
|
27129
|
+
...data,
|
|
27130
|
+
...data.batchId === void 0 ? {} : { batchId: normalizeTaskBatchId(data.batchId) ?? null },
|
|
27131
|
+
...data.variant === void 0 ? {} : { variant: normalizeModelVariant(data.variant) ?? null }
|
|
27132
|
+
};
|
|
27109
27133
|
return db.transaction((tx) => {
|
|
27110
27134
|
const task = tx.select().from(tasks2).where(and(
|
|
27111
27135
|
eq(tasks2.id, id),
|
|
@@ -27117,6 +27141,7 @@ var TaskService = class {
|
|
|
27117
27141
|
name: normalizedData.name ?? task.name,
|
|
27118
27142
|
agent: normalizedData.agent ?? task.agent,
|
|
27119
27143
|
model: normalizedData.model ?? task.model,
|
|
27144
|
+
variant: normalizedData.variant === void 0 ? task.variant : normalizedData.variant,
|
|
27120
27145
|
prompt: normalizedData.prompt ?? task.prompt,
|
|
27121
27146
|
cwd: task.cwd,
|
|
27122
27147
|
category: normalizedData.category ?? task.category,
|
|
@@ -27130,13 +27155,23 @@ var TaskService = class {
|
|
|
27130
27155
|
});
|
|
27131
27156
|
const maxRetries = normalizedData.maxRetries ?? task.maxRetries ?? 3;
|
|
27132
27157
|
const exhausted = task.status === "failed" && (task.retryCount ?? 0) > maxRetries;
|
|
27133
|
-
|
|
27158
|
+
const updated = tx.update(tasks2).set({
|
|
27134
27159
|
...normalizedData,
|
|
27135
27160
|
...exhausted ? {
|
|
27136
27161
|
status: "dead_letter",
|
|
27137
27162
|
retryAfter: null
|
|
27138
27163
|
} : {}
|
|
27139
27164
|
}).where(eq(tasks2.id, id)).returning().get() ?? null;
|
|
27165
|
+
if (exhausted && updated) {
|
|
27166
|
+
const finishedAt = /* @__PURE__ */ new Date();
|
|
27167
|
+
tx.update(tasks2).set({
|
|
27168
|
+
status: "dead_letter",
|
|
27169
|
+
finishedAt,
|
|
27170
|
+
retryAfter: null,
|
|
27171
|
+
resultLog: `\u4F9D\u8D56\u4EFB\u52A1 #${id} \u5DF2\u8FDB\u5165\u4E0D\u53EF\u6062\u590D\u7EC8\u6001`
|
|
27172
|
+
}).where(blockedDependentsOf(id)).run();
|
|
27173
|
+
}
|
|
27174
|
+
return updated;
|
|
27140
27175
|
}, { behavior: "immediate" });
|
|
27141
27176
|
}
|
|
27142
27177
|
static validateNewTask(data) {
|
|
@@ -27157,7 +27192,7 @@ var TaskService = class {
|
|
|
27157
27192
|
throw new Error(`${name} \u5FC5\u987B\u662F ${min} \u5230 ${max} \u4E4B\u95F4\u7684\u6574\u6570`);
|
|
27158
27193
|
}
|
|
27159
27194
|
}
|
|
27160
|
-
static
|
|
27195
|
+
static buildRunnableTaskWhere(scope) {
|
|
27161
27196
|
const baseConditions = [...this.buildScopeWhere(scope)];
|
|
27162
27197
|
const nowMs = Date.now();
|
|
27163
27198
|
const retryAfterFilter = or(
|
|
@@ -27192,40 +27227,43 @@ var TaskService = class {
|
|
|
27192
27227
|
if (batchFilter) {
|
|
27193
27228
|
conditions.push(batchFilter);
|
|
27194
27229
|
}
|
|
27195
|
-
|
|
27230
|
+
return and(
|
|
27196
27231
|
...conditions,
|
|
27197
27232
|
or(
|
|
27198
27233
|
isNull(tasks2.dependsOn),
|
|
27199
27234
|
sql`EXISTS (
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27204
|
-
|
|
27235
|
+
SELECT 1 FROM tasks AS dependency_task
|
|
27236
|
+
WHERE dependency_task.id = ${tasks2.dependsOn}
|
|
27237
|
+
AND dependency_task.status = 'done'
|
|
27238
|
+
AND dependency_task.cwd IS ${tasks2.cwd}
|
|
27239
|
+
)`
|
|
27205
27240
|
),
|
|
27206
27241
|
or(
|
|
27207
27242
|
isNull(tasks2.batchId),
|
|
27208
27243
|
sql`trim(${tasks2.batchId}, ${TASK_BATCH_TRIM_CHARACTERS}) = ''`,
|
|
27209
27244
|
sql`NOT EXISTS (
|
|
27210
|
-
|
|
27211
|
-
|
|
27212
|
-
|
|
27213
|
-
|
|
27214
|
-
|
|
27215
|
-
|
|
27216
|
-
|
|
27217
|
-
|
|
27218
|
-
|
|
27219
|
-
)
|
|
27245
|
+
SELECT 1 FROM tasks AS running_batch_task
|
|
27246
|
+
WHERE trim(running_batch_task.batch_id, ${TASK_BATCH_TRIM_CHARACTERS})
|
|
27247
|
+
= trim(${tasks2.batchId}, ${TASK_BATCH_TRIM_CHARACTERS})
|
|
27248
|
+
AND (
|
|
27249
|
+
running_batch_task.status = 'running'
|
|
27250
|
+
OR EXISTS (
|
|
27251
|
+
SELECT 1 FROM task_runs AS running_batch_run
|
|
27252
|
+
WHERE running_batch_run.task_id = running_batch_task.id
|
|
27253
|
+
AND running_batch_run.status = 'running'
|
|
27220
27254
|
)
|
|
27221
|
-
|
|
27255
|
+
)
|
|
27256
|
+
)`
|
|
27222
27257
|
),
|
|
27223
27258
|
sql`NOT EXISTS (
|
|
27224
|
-
|
|
27225
|
-
|
|
27226
|
-
|
|
27227
|
-
|
|
27228
|
-
)
|
|
27259
|
+
SELECT 1 FROM task_runs AS candidate_active_run
|
|
27260
|
+
WHERE candidate_active_run.task_id = ${tasks2.id}
|
|
27261
|
+
AND candidate_active_run.status = 'running'
|
|
27262
|
+
)`
|
|
27263
|
+
);
|
|
27264
|
+
}
|
|
27265
|
+
static async next(scope = {}) {
|
|
27266
|
+
const result = await db.select().from(tasks2).where(this.buildRunnableTaskWhere(scope)).orderBy(
|
|
27229
27267
|
desc(tasks2.urgency),
|
|
27230
27268
|
desc(tasks2.importance),
|
|
27231
27269
|
asc(tasks2.createdAt),
|
|
@@ -27233,6 +27271,22 @@ var TaskService = class {
|
|
|
27233
27271
|
).limit(1);
|
|
27234
27272
|
return result[0] ?? null;
|
|
27235
27273
|
}
|
|
27274
|
+
static async claimNext(scope = {}) {
|
|
27275
|
+
return db.transaction((tx) => {
|
|
27276
|
+
const candidate = tx.select().from(tasks2).where(this.buildRunnableTaskWhere(scope)).orderBy(
|
|
27277
|
+
desc(tasks2.urgency),
|
|
27278
|
+
desc(tasks2.importance),
|
|
27279
|
+
asc(tasks2.createdAt),
|
|
27280
|
+
asc(tasks2.id)
|
|
27281
|
+
).limit(1).get();
|
|
27282
|
+
if (!candidate) return null;
|
|
27283
|
+
return tx.update(tasks2).set({
|
|
27284
|
+
status: "running",
|
|
27285
|
+
startedAt: /* @__PURE__ */ new Date(),
|
|
27286
|
+
finishedAt: null
|
|
27287
|
+
}).where(eq(tasks2.id, candidate.id)).returning().get() ?? null;
|
|
27288
|
+
}, { behavior: "immediate" });
|
|
27289
|
+
}
|
|
27236
27290
|
static async countRunning(scope = {}) {
|
|
27237
27291
|
const scopeConditions = scope.legacyCwd ? [sql`${tasks2.cwd} IS NULL OR trim(${tasks2.cwd}) = ''`] : this.buildScopeWhere(scope);
|
|
27238
27292
|
if (scope.batchId !== void 0) {
|
|
@@ -27891,7 +27945,8 @@ var TaskTemplateService = class {
|
|
|
27891
27945
|
static async create(data) {
|
|
27892
27946
|
const normalizedData = {
|
|
27893
27947
|
...data,
|
|
27894
|
-
batchId: normalizeTaskBatchId(data.batchId)
|
|
27948
|
+
batchId: normalizeTaskBatchId(data.batchId),
|
|
27949
|
+
variant: normalizeModelVariant(data.variant)
|
|
27895
27950
|
};
|
|
27896
27951
|
this.validate(normalizedData);
|
|
27897
27952
|
const now = Date.now();
|
|
@@ -27957,7 +28012,8 @@ var TaskTemplateService = class {
|
|
|
27957
28012
|
static async update(id, data) {
|
|
27958
28013
|
const normalizedData = {
|
|
27959
28014
|
...data,
|
|
27960
|
-
batchId: normalizeTaskBatchId(data.batchId) ?? null
|
|
28015
|
+
batchId: normalizeTaskBatchId(data.batchId) ?? null,
|
|
28016
|
+
...data.variant === void 0 ? {} : { variant: normalizeModelVariant(data.variant) ?? null }
|
|
27961
28017
|
};
|
|
27962
28018
|
this.validate(normalizedData);
|
|
27963
28019
|
const now = Date.now();
|
|
@@ -29604,6 +29660,7 @@ var SuperTaskPlugin = async () => {
|
|
|
29604
29660
|
agent: tool.schema.string().trim().min(1).describe("\u6267\u884C\u7684 Agent \u540D\u79F0\uFF0C\u5982 localize-gen, course-gen"),
|
|
29605
29661
|
prompt: tool.schema.string().trim().min(1).describe("\u53D1\u9001\u7ED9 Agent \u7684\u5B8C\u6574\u63D0\u793A\u8BCD"),
|
|
29606
29662
|
model: tool.schema.string().optional().describe("\u4F7F\u7528\u7684\u6A21\u578B\uFF0C\u5982 gemini-2.5-pro"),
|
|
29663
|
+
variant: tool.schema.string().trim().min(1).max(128).optional().describe("\u6A21\u578B variant\uFF0C\u5982 low\u3001high\u3001xhigh\uFF1B\u4EC5\u5728\u6A21\u578B\u652F\u6301\u65F6\u4F7F\u7528"),
|
|
29607
29664
|
category: tool.schema.enum(["translate", "generate", "review", "test", "general"]).optional().describe("\u4EFB\u52A1\u5206\u7C7B"),
|
|
29608
29665
|
importance: tool.schema.number().int().min(1).max(5).optional().describe("\u91CD\u8981\u7A0B\u5EA6 1-5\uFF085 \u6700\u91CD\u8981\uFF09"),
|
|
29609
29666
|
urgency: tool.schema.number().int().min(1).max(5).optional().describe("\u7D27\u6025\u7A0B\u5EA6 1-5\uFF085 \u6700\u7D27\u6025\uFF09"),
|
|
@@ -29624,6 +29681,7 @@ var SuperTaskPlugin = async () => {
|
|
|
29624
29681
|
agent: args.agent,
|
|
29625
29682
|
prompt: args.prompt,
|
|
29626
29683
|
model: args.model,
|
|
29684
|
+
variant: args.variant,
|
|
29627
29685
|
category: args.category ?? "general",
|
|
29628
29686
|
importance: args.importance ?? 3,
|
|
29629
29687
|
urgency: args.urgency ?? 3,
|
|
@@ -29657,6 +29715,7 @@ var SuperTaskPlugin = async () => {
|
|
|
29657
29715
|
name: task.name,
|
|
29658
29716
|
agent: task.agent,
|
|
29659
29717
|
model: task.model,
|
|
29718
|
+
variant: task.variant,
|
|
29660
29719
|
prompt: task.prompt,
|
|
29661
29720
|
cwd: task.cwd,
|
|
29662
29721
|
category: task.category,
|
|
@@ -29778,6 +29837,7 @@ var SuperTaskPlugin = async () => {
|
|
|
29778
29837
|
name: task.name,
|
|
29779
29838
|
agent: task.agent,
|
|
29780
29839
|
model: task.model,
|
|
29840
|
+
variant: task.variant,
|
|
29781
29841
|
prompt: task.prompt,
|
|
29782
29842
|
cwd: task.cwd,
|
|
29783
29843
|
category: task.category,
|
|
@@ -29801,6 +29861,7 @@ var SuperTaskPlugin = async () => {
|
|
|
29801
29861
|
agent: tool.schema.string().trim().min(1).describe("\u6267\u884C\u7684 Agent \u540D\u79F0"),
|
|
29802
29862
|
prompt: tool.schema.string().trim().min(1).describe("\u53D1\u9001\u7ED9 Agent \u7684\u5B8C\u6574\u63D0\u793A\u8BCD"),
|
|
29803
29863
|
model: tool.schema.string().optional().describe("\u4F7F\u7528\u7684\u6A21\u578B"),
|
|
29864
|
+
variant: tool.schema.string().trim().min(1).max(128).optional().describe("\u6A21\u578B variant\uFF0C\u5982 low\u3001high\u3001xhigh\uFF1B\u4EC5\u5728\u6A21\u578B\u652F\u6301\u65F6\u4F7F\u7528"),
|
|
29804
29865
|
category: tool.schema.enum(["translate", "generate", "review", "test", "general"]).optional().describe("\u4EFB\u52A1\u5206\u7C7B"),
|
|
29805
29866
|
importance: tool.schema.number().int().min(1).max(5).optional().describe("\u91CD\u8981\u7A0B\u5EA6 1-5"),
|
|
29806
29867
|
urgency: tool.schema.number().int().min(1).max(5).optional().describe("\u7D27\u6025\u7A0B\u5EA6 1-5"),
|
|
@@ -29844,6 +29905,7 @@ var SuperTaskPlugin = async () => {
|
|
|
29844
29905
|
agent: args.agent,
|
|
29845
29906
|
prompt: args.prompt,
|
|
29846
29907
|
model: args.model,
|
|
29908
|
+
variant: args.variant,
|
|
29847
29909
|
category: args.category ?? "general",
|
|
29848
29910
|
importance: args.importance ?? 3,
|
|
29849
29911
|
urgency: args.urgency ?? 3,
|