opencode-supertask 0.2.1 → 0.3.0
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 +19 -0
- package/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/dist/cli/{chunk-5VKFECHP.js → chunk-764OMIPC.js} +2 -2
- package/dist/cli/{chunk-J34FWHQU.js → chunk-ETLJ4YXW.js} +3 -2
- package/dist/cli/chunk-ETLJ4YXW.js.map +1 -0
- package/dist/cli/{chunk-AZM76ISG.js → chunk-INW2NH3O.js} +6 -5
- package/dist/cli/chunk-INW2NH3O.js.map +1 -0
- package/dist/cli/{chunk-CMEP6IB4.js → chunk-K6UTYKN5.js} +19 -5
- package/dist/cli/{chunk-CMEP6IB4.js.map → chunk-K6UTYKN5.js.map} +1 -1
- package/dist/cli/{chunk-DF56RPNL.js → chunk-MZLIVCEU.js} +10 -2
- package/dist/cli/{chunk-DF56RPNL.js.map → chunk-MZLIVCEU.js.map} +1 -1
- package/dist/cli/{chunk-DIJEKFBV.js → chunk-USBQGFQZ.js} +3 -3
- package/dist/cli/{chunk-EQWICVCJ.js → chunk-XUCZLWCB.js} +48 -6
- package/dist/cli/chunk-XUCZLWCB.js.map +1 -0
- package/dist/cli/{chunk-YGELD2E5.js → chunk-ZIR7RA5B.js} +7 -4
- package/dist/cli/{chunk-YGELD2E5.js.map → chunk-ZIR7RA5B.js.map} +1 -1
- package/dist/cli/{database-maintenance.service-F3IZU52F.js → database-maintenance.service-VZCH7ZEV.js} +4 -4
- package/dist/cli/{db-H7GIFWS2.js → db-KWSXP22E.js} +2 -2
- package/dist/cli/{doctor-smoke-QXHF7UNN.js → doctor-smoke-ZKWNHC3O.js} +5 -5
- package/dist/cli/{gateway-BYLLK72W.js → gateway-HUXVEDMU.js} +183 -14
- package/dist/cli/gateway-HUXVEDMU.js.map +1 -0
- package/dist/cli/{gateway-wake-U4HTV56Q.js → gateway-wake-M5EXAIGD.js} +2 -2
- package/dist/cli/index.js +32 -32
- package/dist/cli/{job-templates-RPQJ4XXW.js → job-templates-FH7SGS34.js} +5 -5
- package/dist/cli/{logs-QD2N62KK.js → logs-XNLR23TK.js} +5 -5
- package/dist/cli/{task-run.service-QMDINJKG.js → task-run.service-HCMHWOGW.js} +3 -3
- package/dist/cli/task-template.service-VA4WBJA4.js +12 -0
- package/dist/cli/{task.service-ZVDJ6VSQ.js → task.service-RB6RKV7T.js} +3 -3
- package/dist/cli/{web-J3FJ23FE.js → web-TQO6JLBN.js} +151 -12
- package/dist/cli/web-TQO6JLBN.js.map +1 -0
- package/dist/gateway/index.js +395 -21
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +64 -10
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +211 -14
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.js +221 -13
- package/dist/worker/index.js.map +1 -1
- package/drizzle/0010_task_metadata.sql +2 -0
- package/drizzle/meta/0010_snapshot.json +695 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/dist/cli/chunk-AZM76ISG.js.map +0 -1
- package/dist/cli/chunk-EQWICVCJ.js.map +0 -1
- package/dist/cli/chunk-J34FWHQU.js.map +0 -1
- package/dist/cli/gateway-BYLLK72W.js.map +0 -1
- package/dist/cli/task-template.service-SZBKGLCB.js +0 -12
- package/dist/cli/web-J3FJ23FE.js.map +0 -1
- /package/dist/cli/{chunk-5VKFECHP.js.map → chunk-764OMIPC.js.map} +0 -0
- /package/dist/cli/{chunk-DIJEKFBV.js.map → chunk-USBQGFQZ.js.map} +0 -0
- /package/dist/cli/{database-maintenance.service-F3IZU52F.js.map → database-maintenance.service-VZCH7ZEV.js.map} +0 -0
- /package/dist/cli/{db-H7GIFWS2.js.map → db-KWSXP22E.js.map} +0 -0
- /package/dist/cli/{doctor-smoke-QXHF7UNN.js.map → doctor-smoke-ZKWNHC3O.js.map} +0 -0
- /package/dist/cli/{gateway-wake-U4HTV56Q.js.map → gateway-wake-M5EXAIGD.js.map} +0 -0
- /package/dist/cli/{job-templates-RPQJ4XXW.js.map → job-templates-FH7SGS34.js.map} +0 -0
- /package/dist/cli/{logs-QD2N62KK.js.map → logs-XNLR23TK.js.map} +0 -0
- /package/dist/cli/{task-run.service-QMDINJKG.js.map → task-run.service-HCMHWOGW.js.map} +0 -0
- /package/dist/cli/{task-template.service-SZBKGLCB.js.map → task-template.service-VA4WBJA4.js.map} +0 -0
- /package/dist/cli/{task.service-ZVDJ6VSQ.js.map → task.service-RB6RKV7T.js.map} +0 -0
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
import {
|
|
4
4
|
DatabaseMaintenanceConflictError,
|
|
5
5
|
DatabaseMaintenanceService
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-USBQGFQZ.js";
|
|
7
7
|
import "./chunk-ZBH7YWXF.js";
|
|
8
8
|
import "./chunk-YB7MYTE5.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-XUCZLWCB.js";
|
|
10
|
+
import "./chunk-ZIR7RA5B.js";
|
|
11
11
|
import "./chunk-3PIYMBV3.js";
|
|
12
12
|
export {
|
|
13
13
|
DatabaseMaintenanceConflictError,
|
|
14
14
|
DatabaseMaintenanceService
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=database-maintenance.service-
|
|
16
|
+
//# sourceMappingURL=database-maintenance.service-VZCH7ZEV.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
migrateSqliteDatabase,
|
|
11
11
|
schema_exports,
|
|
12
12
|
sqlite
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZIR7RA5B.js";
|
|
14
14
|
import "./chunk-3PIYMBV3.js";
|
|
15
15
|
export {
|
|
16
16
|
DB_FILE_PATH,
|
|
@@ -23,4 +23,4 @@ export {
|
|
|
23
23
|
schema_exports as schema,
|
|
24
24
|
sqlite
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=db-
|
|
26
|
+
//# sourceMappingURL=db-KWSXP22E.js.map
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
TaskRunService
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-764OMIPC.js";
|
|
6
6
|
import {
|
|
7
7
|
wakeGateway
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MZLIVCEU.js";
|
|
9
9
|
import "./chunk-ZBH7YWXF.js";
|
|
10
10
|
import "./chunk-YB7MYTE5.js";
|
|
11
11
|
import {
|
|
12
12
|
TaskService
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XUCZLWCB.js";
|
|
14
14
|
import {
|
|
15
15
|
DB_FILE_PATH
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ZIR7RA5B.js";
|
|
17
17
|
import "./chunk-3PIYMBV3.js";
|
|
18
18
|
|
|
19
19
|
// src/cli/doctor-smoke.ts
|
|
@@ -147,4 +147,4 @@ async function runDoctorSmoke(options) {
|
|
|
147
147
|
export {
|
|
148
148
|
runDoctorSmoke
|
|
149
149
|
};
|
|
150
|
-
//# sourceMappingURL=doctor-smoke-
|
|
150
|
+
//# sourceMappingURL=doctor-smoke-ZKWNHC3O.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
markGatewayFailure,
|
|
8
8
|
markGatewaySuccess,
|
|
9
9
|
resetGatewayHealth
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ETLJ4YXW.js";
|
|
11
11
|
import {
|
|
12
12
|
OpenCodeInvocationError,
|
|
13
13
|
buildOpenCodeRunArgs,
|
|
@@ -16,16 +16,16 @@ import {
|
|
|
16
16
|
} from "./chunk-LX5CBJLP.js";
|
|
17
17
|
import {
|
|
18
18
|
TaskRunService
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-764OMIPC.js";
|
|
20
20
|
import {
|
|
21
21
|
DUE_TEMPLATE_BATCH_SIZE,
|
|
22
22
|
cloneTaskFromTemplate,
|
|
23
23
|
getDueTemplates,
|
|
24
24
|
initializeNextRunAt
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-INW2NH3O.js";
|
|
26
26
|
import {
|
|
27
27
|
TaskTemplateService
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-K6UTYKN5.js";
|
|
29
29
|
import {
|
|
30
30
|
identifyGatewayProcess,
|
|
31
31
|
inspectSpawnedProcessTreePresence,
|
|
@@ -45,8 +45,9 @@ import {
|
|
|
45
45
|
import {
|
|
46
46
|
TaskService,
|
|
47
47
|
normalizeTaskBatchId,
|
|
48
|
+
parseTaskMetadata,
|
|
48
49
|
validateTaskWorkingDirectory
|
|
49
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-XUCZLWCB.js";
|
|
50
51
|
import {
|
|
51
52
|
and,
|
|
52
53
|
asc,
|
|
@@ -57,7 +58,7 @@ import {
|
|
|
57
58
|
isNull,
|
|
58
59
|
schema_exports,
|
|
59
60
|
sqlite
|
|
60
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-ZIR7RA5B.js";
|
|
61
62
|
import {
|
|
62
63
|
getPackageVersion
|
|
63
64
|
} from "./chunk-DYXFSX5J.js";
|
|
@@ -68,6 +69,135 @@ import "./chunk-3PIYMBV3.js";
|
|
|
68
69
|
|
|
69
70
|
// src/worker/index.ts
|
|
70
71
|
import { spawn } from "child_process";
|
|
72
|
+
|
|
73
|
+
// src/gateway/webhook.ts
|
|
74
|
+
import { createHmac } from "crypto";
|
|
75
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
76
|
+
var DEFAULT_MAX_ATTEMPTS = 2;
|
|
77
|
+
var MAX_SUMMARY_CHARS = 2e3;
|
|
78
|
+
function signWebhookPayload(secret, timestamp, body) {
|
|
79
|
+
const digest = createHmac("sha256", secret).update(`${timestamp}.${body}`).digest("hex");
|
|
80
|
+
return `sha256=${digest}`;
|
|
81
|
+
}
|
|
82
|
+
function extractOutputSummary(rawLog, maxChars = MAX_SUMMARY_CHARS) {
|
|
83
|
+
if (!rawLog) return "";
|
|
84
|
+
const texts = [];
|
|
85
|
+
let framed = false;
|
|
86
|
+
for (const line of rawLog.split("\n")) {
|
|
87
|
+
const trimmed = line.trim();
|
|
88
|
+
if (!trimmed) continue;
|
|
89
|
+
try {
|
|
90
|
+
const event = JSON.parse(trimmed);
|
|
91
|
+
if (event.type) framed = true;
|
|
92
|
+
if (event.type === "text" && typeof event.part?.text === "string" && event.part.text.trim()) {
|
|
93
|
+
texts.push(event.part.text.trim());
|
|
94
|
+
} else if (event.type === "error") {
|
|
95
|
+
const msg = event.error?.data?.message || event.error?.message;
|
|
96
|
+
if (typeof msg === "string" && msg.trim()) texts.push(msg.trim());
|
|
97
|
+
}
|
|
98
|
+
} catch {
|
|
99
|
+
if (!framed) texts.push(trimmed);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const combined = texts.join("\n").trim();
|
|
103
|
+
if (combined.length <= maxChars) return combined;
|
|
104
|
+
return `${combined.slice(0, Math.max(0, maxChars - 1))}\u2026`;
|
|
105
|
+
}
|
|
106
|
+
function toMs(value) {
|
|
107
|
+
if (value == null) return null;
|
|
108
|
+
if (value instanceof Date) return value.getTime();
|
|
109
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
function buildTaskWebhookPayload(event, task, run, outputOverride) {
|
|
113
|
+
const startedAt = toMs(task.startedAt);
|
|
114
|
+
const finishedAt = toMs(task.finishedAt) ?? Date.now();
|
|
115
|
+
const durationMs = startedAt != null && finishedAt > startedAt ? finishedAt - startedAt : 0;
|
|
116
|
+
return {
|
|
117
|
+
event,
|
|
118
|
+
timestamp: Date.now(),
|
|
119
|
+
task: {
|
|
120
|
+
id: task.id,
|
|
121
|
+
name: task.name,
|
|
122
|
+
agent: task.agent,
|
|
123
|
+
model: task.model ?? null,
|
|
124
|
+
variant: task.variant ?? null,
|
|
125
|
+
cwd: task.cwd ?? null,
|
|
126
|
+
templateId: task.templateId ?? null,
|
|
127
|
+
status: task.status ?? event.slice("task.".length),
|
|
128
|
+
metadata: parseTaskMetadata(task.metadata),
|
|
129
|
+
startedAt,
|
|
130
|
+
finishedAt,
|
|
131
|
+
durationMs
|
|
132
|
+
},
|
|
133
|
+
run,
|
|
134
|
+
outputSummary: extractOutputSummary(outputOverride ?? task.resultLog)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async function dispatchTaskWebhook(payload, options = {}) {
|
|
138
|
+
const url = (options.url ?? process.env.SUPERTASK_WEBHOOK_URL ?? "").trim();
|
|
139
|
+
if (!url) return false;
|
|
140
|
+
try {
|
|
141
|
+
const parsed = new URL(url);
|
|
142
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
|
|
143
|
+
} catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const secret = (options.secret ?? process.env.SUPERTASK_WEBHOOK_SECRET ?? "").trim();
|
|
147
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
148
|
+
const maxAttempts = Math.max(1, options.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
|
|
149
|
+
const fetchFn = options.fetchImpl ?? fetch;
|
|
150
|
+
const body = JSON.stringify(payload);
|
|
151
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
152
|
+
const ts = Date.now();
|
|
153
|
+
const headers = {
|
|
154
|
+
"content-type": "application/json",
|
|
155
|
+
"x-supertask-event": payload.event,
|
|
156
|
+
"x-supertask-timestamp": String(ts)
|
|
157
|
+
};
|
|
158
|
+
if (secret) {
|
|
159
|
+
headers["x-supertask-signature"] = signWebhookPayload(secret, ts, body);
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
const resp = await fetchFn(url, {
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers,
|
|
165
|
+
body,
|
|
166
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
167
|
+
});
|
|
168
|
+
if (resp.ok) return true;
|
|
169
|
+
if (resp.status >= 400 && resp.status < 500 && resp.status !== 429) {
|
|
170
|
+
console.warn(JSON.stringify({
|
|
171
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
172
|
+
level: "warn",
|
|
173
|
+
msg: "task webhook rejected",
|
|
174
|
+
event: payload.event,
|
|
175
|
+
taskId: payload.task.id,
|
|
176
|
+
status: resp.status
|
|
177
|
+
}));
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
if (attempt >= maxAttempts) {
|
|
182
|
+
console.warn(JSON.stringify({
|
|
183
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
184
|
+
level: "warn",
|
|
185
|
+
msg: "task webhook delivery failed",
|
|
186
|
+
event: payload.event,
|
|
187
|
+
taskId: payload.task.id,
|
|
188
|
+
error: err instanceof Error ? err.message : String(err)
|
|
189
|
+
}));
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (attempt < maxAttempts) {
|
|
194
|
+
await new Promise((resolve) => setTimeout(resolve, 300 * attempt));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/worker/index.ts
|
|
71
201
|
import { fileURLToPath } from "url";
|
|
72
202
|
import { existsSync } from "fs";
|
|
73
203
|
import { dirname, join } from "path";
|
|
@@ -397,6 +527,12 @@ var WorkerEngine = class {
|
|
|
397
527
|
} catch (error) {
|
|
398
528
|
const message = error instanceof Error ? error.message : String(error);
|
|
399
529
|
await TaskService.failRun(task.id, run.id, message, { setDeadLetter: true });
|
|
530
|
+
void dispatchTaskWebhook(buildTaskWebhookPayload(
|
|
531
|
+
"task.dead_letter",
|
|
532
|
+
{ ...task, status: "dead_letter", finishedAt: /* @__PURE__ */ new Date(), resultLog: message },
|
|
533
|
+
{ id: run.id, sessionId: null, status: "failed" },
|
|
534
|
+
message
|
|
535
|
+
));
|
|
400
536
|
this.releaseBatch(task);
|
|
401
537
|
continue;
|
|
402
538
|
}
|
|
@@ -411,7 +547,14 @@ var WorkerEngine = class {
|
|
|
411
547
|
});
|
|
412
548
|
} catch (error) {
|
|
413
549
|
if (!(error instanceof OpenCodeInvocationError)) throw error;
|
|
414
|
-
|
|
550
|
+
const message = `${error.message}\uFF08OpenCode ${openCode.version}\uFF09`;
|
|
551
|
+
await TaskService.failRun(task.id, run.id, message, { setDeadLetter: true });
|
|
552
|
+
void dispatchTaskWebhook(buildTaskWebhookPayload(
|
|
553
|
+
"task.dead_letter",
|
|
554
|
+
{ ...task, status: "dead_letter", finishedAt: /* @__PURE__ */ new Date(), resultLog: message },
|
|
555
|
+
{ id: run.id, sessionId: null, status: "failed" },
|
|
556
|
+
message
|
|
557
|
+
));
|
|
415
558
|
this.releaseBatch(task);
|
|
416
559
|
continue;
|
|
417
560
|
}
|
|
@@ -453,6 +596,14 @@ var WorkerEngine = class {
|
|
|
453
596
|
}
|
|
454
597
|
async spawnTask(task, runId, launchIdentity, args) {
|
|
455
598
|
const cwd = task.cwd || process.cwd();
|
|
599
|
+
const childEnv = {
|
|
600
|
+
...process.env,
|
|
601
|
+
PWD: cwd,
|
|
602
|
+
[MANAGED_RUN_ENV]: MANAGED_RUN_ENV_VALUE
|
|
603
|
+
};
|
|
604
|
+
delete childEnv.SUPERTASK_API_TOKEN;
|
|
605
|
+
delete childEnv.SUPERTASK_WEBHOOK_SECRET;
|
|
606
|
+
delete childEnv.SUPERTASK_WEBHOOK_URL;
|
|
456
607
|
const child = spawn(process.execPath, [
|
|
457
608
|
this.launcherEntry(),
|
|
458
609
|
LAUNCH_IDENTITY_ARGUMENT,
|
|
@@ -461,23 +612,21 @@ var WorkerEngine = class {
|
|
|
461
612
|
...args
|
|
462
613
|
], {
|
|
463
614
|
cwd,
|
|
464
|
-
env:
|
|
465
|
-
...process.env,
|
|
466
|
-
PWD: cwd,
|
|
467
|
-
[MANAGED_RUN_ENV]: MANAGED_RUN_ENV_VALUE
|
|
468
|
-
},
|
|
615
|
+
env: childEnv,
|
|
469
616
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
470
617
|
detached: process.platform !== "win32"
|
|
471
618
|
});
|
|
472
619
|
const entry = {
|
|
473
620
|
task,
|
|
474
621
|
runId,
|
|
622
|
+
sessionId: null,
|
|
475
623
|
launchIdentity,
|
|
476
624
|
child,
|
|
477
625
|
commandContext: runCommandContext(this.opencodeBin, args, cwd),
|
|
478
626
|
output: new RunOutput(
|
|
479
627
|
this.maxOutputChars,
|
|
480
628
|
(sessionId) => {
|
|
629
|
+
entry.sessionId = sessionId;
|
|
481
630
|
TaskRunService.updateSessionId(runId, sessionId).catch((err) => {
|
|
482
631
|
this.logError("sessionId update failed", err, task.id);
|
|
483
632
|
});
|
|
@@ -729,6 +878,12 @@ ${output2}` : ""}`;
|
|
|
729
878
|
status: "cancelled",
|
|
730
879
|
reason: "run-cancelled"
|
|
731
880
|
});
|
|
881
|
+
void dispatchTaskWebhook(buildTaskWebhookPayload(
|
|
882
|
+
"task.cancelled",
|
|
883
|
+
{ ...entry.task, status: "cancelled", finishedAt: /* @__PURE__ */ new Date(), resultLog: log2 },
|
|
884
|
+
{ id: entry.runId, sessionId: entry.sessionId, status: "failed" },
|
|
885
|
+
log2
|
|
886
|
+
));
|
|
732
887
|
console.log(JSON.stringify({
|
|
733
888
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
734
889
|
level: "info",
|
|
@@ -758,6 +913,12 @@ ${output}` : ""}` : output;
|
|
|
758
913
|
status: "done",
|
|
759
914
|
reason: "run-done"
|
|
760
915
|
});
|
|
916
|
+
void dispatchTaskWebhook(buildTaskWebhookPayload(
|
|
917
|
+
"task.done",
|
|
918
|
+
{ ...entry.task, status: "done", finishedAt: /* @__PURE__ */ new Date(), resultLog: log },
|
|
919
|
+
{ id: entry.runId, sessionId: entry.sessionId, status: "done" },
|
|
920
|
+
log
|
|
921
|
+
));
|
|
761
922
|
console.log(JSON.stringify({
|
|
762
923
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
763
924
|
level: "info",
|
|
@@ -803,6 +964,13 @@ ${output}` : ""}` : output;
|
|
|
803
964
|
status: failed.status,
|
|
804
965
|
reason: "run-failed"
|
|
805
966
|
});
|
|
967
|
+
const webhookEvent = failed.status === "dead_letter" ? "task.dead_letter" : "task.failed";
|
|
968
|
+
void dispatchTaskWebhook(buildTaskWebhookPayload(
|
|
969
|
+
webhookEvent,
|
|
970
|
+
{ ...entry.task, status: failed.status, finishedAt: /* @__PURE__ */ new Date(), resultLog: log },
|
|
971
|
+
{ id: entry.runId, sessionId: entry.sessionId, status: "failed" },
|
|
972
|
+
log
|
|
973
|
+
));
|
|
806
974
|
console.error(JSON.stringify({
|
|
807
975
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
808
976
|
level: "error",
|
|
@@ -1660,6 +1828,7 @@ async function runGatewayMain(deps = {}) {
|
|
|
1660
1828
|
await resolveDeps();
|
|
1661
1829
|
if (shuttingDown) return;
|
|
1662
1830
|
initializeGatewayHealth({
|
|
1831
|
+
workerMaxConcurrency: cfg.worker.maxConcurrency,
|
|
1663
1832
|
workerPollIntervalMs: cfg.worker.pollIntervalMs,
|
|
1664
1833
|
schedulerEnabled: cfg.scheduler.enabled,
|
|
1665
1834
|
schedulerCheckIntervalMs: cfg.scheduler.checkIntervalMs,
|
|
@@ -1672,7 +1841,7 @@ async function runGatewayMain(deps = {}) {
|
|
|
1672
1841
|
if (deps.startDashboard) {
|
|
1673
1842
|
dashboardServer = await deps.startDashboard(cfg);
|
|
1674
1843
|
} else {
|
|
1675
|
-
const { dashboardApp, setDashboardRuntimeConfig } = await import("./web-
|
|
1844
|
+
const { dashboardApp, setDashboardRuntimeConfig } = await import("./web-TQO6JLBN.js");
|
|
1676
1845
|
if (shuttingDown) return;
|
|
1677
1846
|
setDashboardRuntimeConfig(cfg);
|
|
1678
1847
|
dashboardServer = Bun.serve({
|
|
@@ -1735,4 +1904,4 @@ export {
|
|
|
1735
1904
|
updateLockHeartbeat,
|
|
1736
1905
|
updateLockHeartbeatResult
|
|
1737
1906
|
};
|
|
1738
|
-
//# sourceMappingURL=gateway-
|
|
1907
|
+
//# sourceMappingURL=gateway-HUXVEDMU.js.map
|