lastlight-core 0.25.9 → 0.26.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/config/default.yaml +20 -1
- package/dist/admin/chat-session-reader.d.ts +3 -3
- package/dist/admin/chat-session-reader.js +8 -8
- package/dist/admin/chat-session-reader.js.map +1 -1
- package/dist/admin/routes.js +97 -99
- package/dist/admin/routes.js.map +1 -1
- package/dist/admin/sessions.d.ts +7 -7
- package/dist/admin/sessions.js +6 -4
- package/dist/admin/sessions.js.map +1 -1
- package/dist/config/config.d.ts +15 -0
- package/dist/config/config.js +28 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/repo-config.js +6 -7
- package/dist/config/repo-config.js.map +1 -1
- package/dist/connectors/messaging/base.js +2 -2
- package/dist/connectors/messaging/base.js.map +1 -1
- package/dist/connectors/messaging/session-manager.d.ts +29 -31
- package/dist/connectors/messaging/session-manager.js +156 -189
- package/dist/connectors/messaging/session-manager.js.map +1 -1
- package/dist/connectors/messaging/thread-transcript.d.ts +2 -2
- package/dist/connectors/messaging/thread-transcript.js +14 -8
- package/dist/connectors/messaging/thread-transcript.js.map +1 -1
- package/dist/connectors/slack/connector.js +5 -5
- package/dist/connectors/slack/connector.js.map +1 -1
- package/dist/cron/feedback-poll.js +6 -6
- package/dist/cron/feedback-poll.js.map +1 -1
- package/dist/cron/handlers.js +3 -3
- package/dist/cron/handlers.js.map +1 -1
- package/dist/cron/jobs.d.ts +1 -1
- package/dist/cron/jobs.js +2 -2
- package/dist/cron/jobs.js.map +1 -1
- package/dist/cron/repo-digest.js +4 -4
- package/dist/cron/repo-digest.js.map +1 -1
- package/dist/cron/runner.js +2 -2
- package/dist/cron/runner.js.map +1 -1
- package/dist/cron/scheduler.js +1 -1
- package/dist/cron/scheduler.js.map +1 -1
- package/dist/engine/chat/chat-prompt.d.ts +11 -4
- package/dist/engine/chat/chat-prompt.js.map +1 -1
- package/dist/engine/chat/chat-runner.d.ts +3 -2
- package/dist/engine/chat/chat-runner.js +9 -7
- package/dist/engine/chat/chat-runner.js.map +1 -1
- package/dist/engine/dispatcher.js +29 -25
- package/dist/engine/dispatcher.js.map +1 -1
- package/dist/engine/executors/orchestrator.d.ts +28 -0
- package/dist/engine/executors/orchestrator.js +70 -1
- package/dist/engine/executors/orchestrator.js.map +1 -1
- package/dist/engine/feedback/ingest.d.ts +4 -4
- package/dist/engine/feedback/ingest.js +13 -13
- package/dist/engine/feedback/ingest.js.map +1 -1
- package/dist/engine/feedback/slack.d.ts +2 -2
- package/dist/engine/feedback/slack.js +6 -6
- package/dist/engine/feedback/slack.js.map +1 -1
- package/dist/engine/fix-harvest.d.ts +1 -1
- package/dist/engine/fix-harvest.js +3 -3
- package/dist/engine/fix-harvest.js.map +1 -1
- package/dist/engine/github/team-visibility.js +7 -7
- package/dist/engine/github/team-visibility.js.map +1 -1
- package/dist/engine/pr-escalation.js +7 -7
- package/dist/engine/pr-escalation.js.map +1 -1
- package/dist/engine/pr-state.d.ts +1 -1
- package/dist/engine/pr-state.js +12 -10
- package/dist/engine/pr-state.js.map +1 -1
- package/dist/engine/review-check.d.ts +1 -1
- package/dist/engine/review-check.js +5 -5
- package/dist/engine/review-check.js.map +1 -1
- package/dist/engine/router.js +3 -3
- package/dist/engine/router.js.map +1 -1
- package/dist/index.js +108 -65
- package/dist/index.js.map +1 -1
- package/dist/sandbox/docker.d.ts +33 -1
- package/dist/sandbox/docker.js +95 -1
- package/dist/sandbox/docker.js.map +1 -1
- package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +3 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js +9 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
- package/dist/sandbox/k8s/pod.d.ts +11 -0
- package/dist/sandbox/k8s/pod.js +11 -6
- package/dist/sandbox/k8s/pod.js.map +1 -1
- package/dist/sandbox/k8s/service-containers.d.ts +43 -0
- package/dist/sandbox/k8s/service-containers.js +87 -0
- package/dist/sandbox/k8s/service-containers.js.map +1 -0
- package/dist/sandbox/reap.d.ts +9 -0
- package/dist/sandbox/reap.js +36 -0
- package/dist/sandbox/reap.js.map +1 -1
- package/dist/sandbox/sandbox.d.ts +14 -0
- package/dist/sandbox/sandbox.js +9 -0
- package/dist/sandbox/sandbox.js.map +1 -1
- package/dist/sandbox/service-containers-docker.d.ts +45 -0
- package/dist/sandbox/service-containers-docker.js +78 -0
- package/dist/sandbox/service-containers-docker.js.map +1 -0
- package/dist/state/approval-store.d.ts +23 -14
- package/dist/state/approval-store.js +137 -86
- package/dist/state/approval-store.js.map +1 -1
- package/dist/state/client.d.ts +105 -0
- package/dist/state/client.js +68 -0
- package/dist/state/client.js.map +1 -0
- package/dist/state/cron-run-store.d.ts +32 -12
- package/dist/state/cron-run-store.js +105 -39
- package/dist/state/cron-run-store.js.map +1 -1
- package/dist/state/db.d.ts +61 -23
- package/dist/state/db.js +171 -105
- package/dist/state/db.js.map +1 -1
- package/dist/state/dialect.d.ts +77 -0
- package/dist/state/dialect.js +129 -0
- package/dist/state/dialect.js.map +1 -0
- package/dist/state/execution-store.d.ts +124 -103
- package/dist/state/execution-store.js +569 -374
- package/dist/state/execution-store.js.map +1 -1
- package/dist/state/feedback-store.d.ts +20 -20
- package/dist/state/feedback-store.js +241 -187
- package/dist/state/feedback-store.js.map +1 -1
- package/dist/state/legacy-sqlite.d.ts +15 -0
- package/dist/state/legacy-sqlite.js +131 -0
- package/dist/state/legacy-sqlite.js.map +1 -0
- package/dist/state/repo-ref.d.ts +9 -4
- package/dist/state/repo-ref.js +12 -6
- package/dist/state/repo-ref.js.map +1 -1
- package/dist/state/schema/pg.d.ts +2788 -0
- package/dist/state/schema/pg.js +301 -0
- package/dist/state/schema/pg.js.map +1 -0
- package/dist/state/schema/sqlite.d.ts +3063 -0
- package/dist/state/schema/sqlite.js +391 -0
- package/dist/state/schema/sqlite.js.map +1 -0
- package/dist/state/team-store.d.ts +26 -13
- package/dist/state/team-store.js +140 -93
- package/dist/state/team-store.js.map +1 -1
- package/dist/state/user-store.d.ts +31 -13
- package/dist/state/user-store.js +180 -80
- package/dist/state/user-store.js.map +1 -1
- package/dist/state/workflow-run-store.d.ts +95 -56
- package/dist/state/workflow-run-store.js +419 -314
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/workflows/admission.d.ts +4 -3
- package/dist/workflows/admission.js +34 -10
- package/dist/workflows/admission.js.map +1 -1
- package/dist/workflows/handlers/post-review.js +3 -3
- package/dist/workflows/handlers/post-review.js.map +1 -1
- package/dist/workflows/resume.js +22 -15
- package/dist/workflows/resume.js.map +1 -1
- package/dist/workflows/runner.js +27 -12
- package/dist/workflows/runner.js.map +1 -1
- package/dist/workflows/simple.d.ts +23 -0
- package/dist/workflows/simple.js +40 -16
- package/dist/workflows/simple.js.map +1 -1
- package/drizzle/pg/0000_init.sql +235 -0
- package/drizzle/pg/meta/0000_snapshot.json +1751 -0
- package/drizzle/pg/meta/_journal.json +13 -0
- package/drizzle/sqlite/0000_baseline.sql +257 -0
- package/drizzle/sqlite/0001_backfill_repo_refs.sql +74 -0
- package/drizzle/sqlite/meta/0000_snapshot.json +1593 -0
- package/drizzle/sqlite/meta/0001_snapshot.json +1593 -0
- package/drizzle/sqlite/meta/_journal.json +20 -0
- package/package.json +12 -6
- package/dist/state/migrate.d.ts +0 -15
- package/dist/state/migrate.js +0 -518
- package/dist/state/migrate.js.map +0 -1
package/dist/admin/routes.js
CHANGED
|
@@ -119,21 +119,6 @@ export function rangeResponse(rangeHeader, buf, mime, cacheControl) {
|
|
|
119
119
|
headers: { ...baseHeaders, "Content-Length": String(total) },
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Parse a JSON status column (`extension_status` / `skills_status`) into the
|
|
124
|
-
* object the dashboard renders. Tolerates null / malformed JSON (returns
|
|
125
|
-
* undefined) so a bad row never breaks the executions endpoint.
|
|
126
|
-
*/
|
|
127
|
-
function parseJsonColumn(raw) {
|
|
128
|
-
if (!raw)
|
|
129
|
-
return undefined;
|
|
130
|
-
try {
|
|
131
|
-
return JSON.parse(raw);
|
|
132
|
-
}
|
|
133
|
-
catch {
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
122
|
/**
|
|
138
123
|
* Check if a session is live by matching against running container taskIds.
|
|
139
124
|
* Sessions are live if they were recently active (within 5 min) and a container
|
|
@@ -178,7 +163,7 @@ function mountSessionRoutes(app, sessions, prefix) {
|
|
|
178
163
|
// Session list — enriched with live container status
|
|
179
164
|
app.get(`${prefix}`, async (c) => {
|
|
180
165
|
const limit = Number(c.req.query("limit") ?? 200);
|
|
181
|
-
const allIds = sessions.listSessionIds();
|
|
166
|
+
const allIds = await sessions.listSessionIds();
|
|
182
167
|
const [metas, containers] = await Promise.all([
|
|
183
168
|
Promise.all(allIds.slice(0, limit * 2).map((id) => sessions.getSessionMeta(id))),
|
|
184
169
|
listRunningContainers(),
|
|
@@ -201,7 +186,7 @@ function mountSessionRoutes(app, sessions, prefix) {
|
|
|
201
186
|
stream.onAbort(() => { stopped = true; });
|
|
202
187
|
const push = async () => {
|
|
203
188
|
const [allIds, containers] = await Promise.all([
|
|
204
|
-
|
|
189
|
+
sessions.listSessionIds(),
|
|
205
190
|
listRunningContainers(),
|
|
206
191
|
]);
|
|
207
192
|
const liveTaskIds = new Set(containers.map((c) => c.taskId).filter(Boolean));
|
|
@@ -232,7 +217,7 @@ function mountSessionRoutes(app, sessions, prefix) {
|
|
|
232
217
|
// Single session
|
|
233
218
|
app.get(`${prefix}/:id`, async (c) => {
|
|
234
219
|
const id = c.req.param("id");
|
|
235
|
-
if (sessions.exists(id)) {
|
|
220
|
+
if (await sessions.exists(id)) {
|
|
236
221
|
const meta = await sessions.getSessionMeta(id);
|
|
237
222
|
if (meta)
|
|
238
223
|
return c.json({ session: meta });
|
|
@@ -243,7 +228,7 @@ function mountSessionRoutes(app, sessions, prefix) {
|
|
|
243
228
|
app.get(`${prefix}/:id/messages`, async (c) => {
|
|
244
229
|
const id = c.req.param("id");
|
|
245
230
|
const sinceIndex = Number(c.req.query("since") ?? -1);
|
|
246
|
-
if (sessions.exists(id)) {
|
|
231
|
+
if (await sessions.exists(id)) {
|
|
247
232
|
const all = await sessions.read(id);
|
|
248
233
|
const next = all.filter((x) => x.index > sinceIndex);
|
|
249
234
|
return c.json({
|
|
@@ -258,10 +243,10 @@ function mountSessionRoutes(app, sessions, prefix) {
|
|
|
258
243
|
app.get(`${prefix}/:id/stream`, async (c) => {
|
|
259
244
|
const id = c.req.param("id");
|
|
260
245
|
const sinceIndex = Number(c.req.query("since") ?? -1);
|
|
261
|
-
if (!sessions.exists(id)) {
|
|
246
|
+
if (!(await sessions.exists(id))) {
|
|
262
247
|
return c.json({ error: "session not found" }, 404);
|
|
263
248
|
}
|
|
264
|
-
const filePath = sessions.getFilePath(id);
|
|
249
|
+
const filePath = await sessions.getFilePath(id);
|
|
265
250
|
if (!filePath) {
|
|
266
251
|
return c.json({ error: "session file not found" }, 404);
|
|
267
252
|
}
|
|
@@ -796,7 +781,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
796
781
|
const slackUserId = userInfo["https://slack.com/user_id"];
|
|
797
782
|
if (slackUserId) {
|
|
798
783
|
try {
|
|
799
|
-
const user = db.users.upsertSlackUser({
|
|
784
|
+
const user = await db.users.upsertSlackUser({
|
|
800
785
|
slackUserId,
|
|
801
786
|
name: userInfo.name ?? null,
|
|
802
787
|
email: userInfo.email ?? null,
|
|
@@ -926,7 +911,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
926
911
|
}
|
|
927
912
|
if (typeof userInfo.id === "number") {
|
|
928
913
|
try {
|
|
929
|
-
db.users.getOrCreateUserByGithub({
|
|
914
|
+
await db.users.getOrCreateUserByGithub({
|
|
930
915
|
githubId: userInfo.id,
|
|
931
916
|
login,
|
|
932
917
|
name: userInfo.name ?? null,
|
|
@@ -961,23 +946,23 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
961
946
|
// Stats — running count uses live Docker containers, not stale DB records
|
|
962
947
|
app.get("/stats", async (c) => {
|
|
963
948
|
const [stats, containers] = await Promise.all([
|
|
964
|
-
|
|
949
|
+
db.executions.executionStats(),
|
|
965
950
|
listRunningContainers(),
|
|
966
951
|
]);
|
|
967
952
|
stats.running = containers.length;
|
|
968
953
|
return c.json(stats);
|
|
969
954
|
});
|
|
970
955
|
// Daily aggregated stats (last N days)
|
|
971
|
-
app.get("/stats/daily", (c) => {
|
|
956
|
+
app.get("/stats/daily", async (c) => {
|
|
972
957
|
const daysParam = c.req.query("days");
|
|
973
958
|
const days = Math.min(Math.max(1, parseInt(daysParam ?? "30", 10) || 30), 90);
|
|
974
|
-
return c.json({ daily: db.executions.dailyStats(days) });
|
|
959
|
+
return c.json({ daily: await db.executions.dailyStats(days) });
|
|
975
960
|
});
|
|
976
961
|
// Hourly aggregated stats (rolling last N hours, default 24)
|
|
977
|
-
app.get("/stats/hourly", (c) => {
|
|
962
|
+
app.get("/stats/hourly", async (c) => {
|
|
978
963
|
const hoursParam = c.req.query("hours");
|
|
979
964
|
const hours = Math.min(Math.max(1, parseInt(hoursParam ?? "24", 10) || 24), 168);
|
|
980
|
-
return c.json({ hourly: db.executions.hourlyStats(hours) });
|
|
965
|
+
return c.json({ hourly: await db.executions.hourlyStats(hours) });
|
|
981
966
|
});
|
|
982
967
|
// ── Feedback signals (issue #255) ─────────────────────────────────────────
|
|
983
968
|
// A 👍/👎 on something the bot wrote, scored against the run that wrote it.
|
|
@@ -985,11 +970,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
985
970
|
// poller, never by an operator — the whole point is that the data is what
|
|
986
971
|
// people actually did.
|
|
987
972
|
// The raw feed, newest first. Retracted signals are excluded unless asked for.
|
|
988
|
-
app.get("/feedback/signals", (c) => {
|
|
973
|
+
app.get("/feedback/signals", async (c) => {
|
|
989
974
|
const limit = Math.min(Math.max(parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
|
|
990
975
|
const offset = Math.max(parseInt(c.req.query("offset") ?? "0", 10) || 0, 0);
|
|
991
976
|
const source = c.req.query("source");
|
|
992
|
-
const { signals, total } = db.feedback.list({
|
|
977
|
+
const { signals, total } = await db.feedback.list({
|
|
993
978
|
limit,
|
|
994
979
|
offset,
|
|
995
980
|
workflowName: c.req.query("workflow") || undefined,
|
|
@@ -1002,22 +987,22 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1002
987
|
// Per-workflow standing — the leaderboard. `averageScore` covers scored
|
|
1003
988
|
// signals only, so a run everybody merely glanced at (👀) isn't reported as
|
|
1004
989
|
// mediocre.
|
|
1005
|
-
app.get("/feedback/summary", (c) => {
|
|
990
|
+
app.get("/feedback/summary", async (c) => {
|
|
1006
991
|
const days = Math.min(Math.max(1, parseInt(c.req.query("days") ?? "30", 10) || 30), 365);
|
|
1007
|
-
return c.json({ summary: db.feedback.summaryByWorkflow(days), days });
|
|
992
|
+
return c.json({ summary: await db.feedback.summaryByWorkflow(days), days });
|
|
1008
993
|
});
|
|
1009
994
|
// Zero-filled daily series for the chart, optionally for one workflow.
|
|
1010
|
-
app.get("/feedback/daily", (c) => {
|
|
995
|
+
app.get("/feedback/daily", async (c) => {
|
|
1011
996
|
const days = Math.min(Math.max(1, parseInt(c.req.query("days") ?? "30", 10) || 30), 90);
|
|
1012
997
|
const workflow = c.req.query("workflow") || undefined;
|
|
1013
|
-
return c.json({ daily: db.feedback.dailyScores(days, workflow) });
|
|
998
|
+
return c.json({ daily: await db.feedback.dailyScores(days, workflow) });
|
|
1014
999
|
});
|
|
1015
1000
|
// Everything said about one run — the run-detail badge.
|
|
1016
|
-
app.get("/workflow-runs/:id/feedback", (c) => {
|
|
1017
|
-
const run = db.runs.getRun(c.req.param("id"));
|
|
1001
|
+
app.get("/workflow-runs/:id/feedback", async (c) => {
|
|
1002
|
+
const run = await db.runs.getRun(c.req.param("id"));
|
|
1018
1003
|
if (!run)
|
|
1019
1004
|
return c.json({ error: "workflow run not found" }, 404);
|
|
1020
|
-
return c.json({ signals: db.feedback.forRun(run.id) });
|
|
1005
|
+
return c.json({ signals: await db.feedback.forRun(run.id) });
|
|
1021
1006
|
});
|
|
1022
1007
|
// Running Docker containers
|
|
1023
1008
|
app.get("/containers", async (c) => {
|
|
@@ -1098,11 +1083,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1098
1083
|
const taskId = match[1];
|
|
1099
1084
|
// Mark any running executions with matching skill as failed. Phase
|
|
1100
1085
|
// skill keys are `<workflowName>:<phaseName>` — match on the colon.
|
|
1101
|
-
const skills = db.executions.runningExecutions()
|
|
1086
|
+
const skills = (await db.executions.runningExecutions())
|
|
1102
1087
|
.filter((e) => e.skill.includes(":") || e.skill === "pr-fix")
|
|
1103
1088
|
.filter((e) => taskId.includes(e.triggerId?.replace(/[^a-z0-9]/gi, "") || "---"));
|
|
1104
1089
|
for (const e of skills) {
|
|
1105
|
-
db.executions.recordFinish(e.id, { success: false, error: "terminated via admin dashboard" });
|
|
1090
|
+
await db.executions.recordFinish(e.id, { success: false, error: "terminated via admin dashboard" });
|
|
1106
1091
|
}
|
|
1107
1092
|
}
|
|
1108
1093
|
return c.json({ killed: name });
|
|
@@ -1112,10 +1097,10 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1112
1097
|
}
|
|
1113
1098
|
});
|
|
1114
1099
|
// Execution records from DB
|
|
1115
|
-
app.get("/executions", (c) => {
|
|
1100
|
+
app.get("/executions", async (c) => {
|
|
1116
1101
|
const limit = Number(c.req.query("limit") ?? 100);
|
|
1117
1102
|
const offset = Number(c.req.query("offset") ?? 0);
|
|
1118
|
-
const executions = db.executions.allExecutions(limit, offset);
|
|
1103
|
+
const executions = await db.executions.allExecutions(limit, offset);
|
|
1119
1104
|
return c.json({ executions });
|
|
1120
1105
|
});
|
|
1121
1106
|
// Free-text log search — the backbone of remote debugging via the CLI
|
|
@@ -1134,7 +1119,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1134
1119
|
const limit = Math.min(Math.max(parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
|
|
1135
1120
|
const results = [];
|
|
1136
1121
|
if (scope === "errors" || scope === "all") {
|
|
1137
|
-
for (const r of db.executions.searchErrors(q, limit)) {
|
|
1122
|
+
for (const r of await db.executions.searchErrors(q, limit)) {
|
|
1138
1123
|
results.push({
|
|
1139
1124
|
source: "error",
|
|
1140
1125
|
executionId: r.id,
|
|
@@ -1151,7 +1136,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1151
1136
|
if (scope === "messages" || scope === "all") {
|
|
1152
1137
|
const needle = q.toLowerCase();
|
|
1153
1138
|
const maxSessions = 200; // newest-first cap on transcripts scanned
|
|
1154
|
-
const ids = sessions.listSessionIds().slice(0, maxSessions);
|
|
1139
|
+
const ids = (await sessions.listSessionIds()).slice(0, maxSessions);
|
|
1155
1140
|
outer: for (const id of ids) {
|
|
1156
1141
|
let msgs;
|
|
1157
1142
|
try {
|
|
@@ -1184,7 +1169,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1184
1169
|
// status. Returns `total` so the dashboard can drive a "load more" pager.
|
|
1185
1170
|
// `status=active` is shorthand for ('running','paused') — used by the
|
|
1186
1171
|
// header's "live" filter on the workflows tab.
|
|
1187
|
-
app.get("/workflow-runs", (c) => {
|
|
1172
|
+
app.get("/workflow-runs", async (c) => {
|
|
1188
1173
|
const rawLimit = c.req.query("limit");
|
|
1189
1174
|
const rawOffset = c.req.query("offset");
|
|
1190
1175
|
const since = c.req.query("since") || undefined;
|
|
@@ -1215,7 +1200,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1215
1200
|
else if (statusParam) {
|
|
1216
1201
|
statuses = statusParam.split(",").filter(Boolean);
|
|
1217
1202
|
}
|
|
1218
|
-
const { runs, total } = db.runs.list({
|
|
1203
|
+
const { runs, total } = await db.runs.list({
|
|
1219
1204
|
limit,
|
|
1220
1205
|
offset,
|
|
1221
1206
|
sinceIso: since,
|
|
@@ -1227,19 +1212,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1227
1212
|
return c.json({ workflowRuns: runs, total });
|
|
1228
1213
|
});
|
|
1229
1214
|
// Distinct workflow names — used to populate the dashboard's filter row.
|
|
1230
|
-
app.get("/workflow-names", (c) => {
|
|
1231
|
-
return c.json({ names: db.runs.distinctNames() });
|
|
1215
|
+
app.get("/workflow-names", async (c) => {
|
|
1216
|
+
return c.json({ names: await db.runs.distinctNames() });
|
|
1232
1217
|
});
|
|
1233
|
-
app.get("/workflow-runs/:id", (c) => {
|
|
1218
|
+
app.get("/workflow-runs/:id", async (c) => {
|
|
1234
1219
|
const id = c.req.param("id");
|
|
1235
|
-
const run = db.runs.getRun(id);
|
|
1220
|
+
const run = await db.runs.getRun(id);
|
|
1236
1221
|
if (!run)
|
|
1237
1222
|
return c.json({ error: "workflow run not found" }, 404);
|
|
1238
1223
|
// Enrich the actor with the `users` identity (issue #205) so the run
|
|
1239
1224
|
// detail panel can show a real name + avatar, not just the raw login.
|
|
1240
1225
|
// Best-effort: absent (password/cron/system actors, or a login with no
|
|
1241
1226
|
// row) → the panel falls back to the login string + actor-type badge.
|
|
1242
|
-
const triggeredByUser = run.triggeredBy ? db.users.findByLogin(run.triggeredBy) : null;
|
|
1227
|
+
const triggeredByUser = run.triggeredBy ? await db.users.findByLogin(run.triggeredBy) : null;
|
|
1243
1228
|
return c.json({
|
|
1244
1229
|
workflowRun: run,
|
|
1245
1230
|
triggeredByUser: triggeredByUser
|
|
@@ -1254,12 +1239,12 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1254
1239
|
// List the executions belonging to a workflow run, ordered by start time.
|
|
1255
1240
|
// Used by the dashboard's pipeline-detail view to look up the session id
|
|
1256
1241
|
// (and usage metrics) for any phase the user clicks.
|
|
1257
|
-
app.get("/workflow-runs/:id/executions", (c) => {
|
|
1242
|
+
app.get("/workflow-runs/:id/executions", async (c) => {
|
|
1258
1243
|
const id = c.req.param("id");
|
|
1259
|
-
const run = db.runs.getRun(id);
|
|
1244
|
+
const run = await db.runs.getRun(id);
|
|
1260
1245
|
if (!run)
|
|
1261
1246
|
return c.json({ error: "workflow run not found" }, 404);
|
|
1262
|
-
const rows = db.executions.getExecutionsForWorkflowRun(run.id, run.triggerId, run.workflowName);
|
|
1247
|
+
const rows = await db.executions.getExecutionsForWorkflowRun(run.id, run.triggerId, run.workflowName);
|
|
1263
1248
|
const prefix = `${run.workflowName}:`;
|
|
1264
1249
|
const executions = rows.map((r) => ({
|
|
1265
1250
|
id: r.id,
|
|
@@ -1280,8 +1265,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1280
1265
|
outputTokens: r.outputTokens,
|
|
1281
1266
|
apiDurationMs: r.apiDurationMs,
|
|
1282
1267
|
stopReason: r.stopReason,
|
|
1283
|
-
|
|
1284
|
-
|
|
1268
|
+
// Already parsed objects on the way out of the store — passed through as
|
|
1269
|
+
// they are. Re-parsing them would throw, and the old helper's `catch`
|
|
1270
|
+
// swallowed that into `undefined`, silently emptying the panel.
|
|
1271
|
+
extensions: r.extensionStatus,
|
|
1272
|
+
skills: r.skillsStatus,
|
|
1285
1273
|
}));
|
|
1286
1274
|
return c.json({ executions });
|
|
1287
1275
|
});
|
|
@@ -1289,17 +1277,17 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1289
1277
|
// the pipeline's approval-gate nodes + the detail panel's read-only approval
|
|
1290
1278
|
// history (status, who responded, when, and any comment). The global
|
|
1291
1279
|
// /approvals endpoint only lists pending ones, so it can't show history.
|
|
1292
|
-
app.get("/workflow-runs/:id/approvals", (c) => {
|
|
1280
|
+
app.get("/workflow-runs/:id/approvals", async (c) => {
|
|
1293
1281
|
const id = c.req.param("id");
|
|
1294
|
-
const run = db.runs.getRun(id);
|
|
1282
|
+
const run = await db.runs.getRun(id);
|
|
1295
1283
|
if (!run)
|
|
1296
1284
|
return c.json({ error: "workflow run not found" }, 404);
|
|
1297
|
-
const approvals = db.approvals.listForWorkflow(run.id);
|
|
1285
|
+
const approvals = await db.approvals.listForWorkflow(run.id);
|
|
1298
1286
|
return c.json({ approvals });
|
|
1299
1287
|
});
|
|
1300
1288
|
app.post("/workflow-runs/:id/cancel", async (c) => {
|
|
1301
1289
|
const id = c.req.param("id");
|
|
1302
|
-
const run = db.runs.getRun(id);
|
|
1290
|
+
const run = await db.runs.getRun(id);
|
|
1303
1291
|
if (!run)
|
|
1304
1292
|
return c.json({ error: "workflow run not found" }, 404);
|
|
1305
1293
|
if (run.status !== "running" && run.status !== "paused" && run.status !== "queued") {
|
|
@@ -1309,7 +1297,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1309
1297
|
// executions ledger (via the finish error below), never overwriting the
|
|
1310
1298
|
// run's original `triggered_by`.
|
|
1311
1299
|
const actor = actorFromContext(c) ?? "admin";
|
|
1312
|
-
db.runs.cancelRun(id);
|
|
1300
|
+
await db.runs.cancelRun(id);
|
|
1313
1301
|
// Flipping the DB row alone only stops the runner before the NEXT phase.
|
|
1314
1302
|
// Kill any sandbox container currently executing a phase of this run so
|
|
1315
1303
|
// the in-flight phase stops too. Container names are
|
|
@@ -1336,9 +1324,9 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1336
1324
|
// avoids clobbering a sibling run that happens to share the same
|
|
1337
1325
|
// trigger — e.g. two webhook deliveries for the same PR that
|
|
1338
1326
|
// raced before dedup closed.
|
|
1339
|
-
for (const e of db.executions.runningExecutions()) {
|
|
1327
|
+
for (const e of await db.executions.runningExecutions()) {
|
|
1340
1328
|
if (e.workflowRunId === id) {
|
|
1341
|
-
db.executions.recordFinish(e.id, { success: false, error: `cancelled via admin dashboard by ${actor}` });
|
|
1329
|
+
await db.executions.recordFinish(e.id, { success: false, error: `cancelled via admin dashboard by ${actor}` });
|
|
1342
1330
|
}
|
|
1343
1331
|
}
|
|
1344
1332
|
}
|
|
@@ -1421,7 +1409,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1421
1409
|
// like cancel/respond.
|
|
1422
1410
|
app.post("/workflow-runs/:id/retry", async (c) => {
|
|
1423
1411
|
const id = c.req.param("id");
|
|
1424
|
-
const run = db.runs.getRun(id);
|
|
1412
|
+
const run = await db.runs.getRun(id);
|
|
1425
1413
|
if (!run)
|
|
1426
1414
|
return c.json({ error: "workflow run not found" }, 404);
|
|
1427
1415
|
if (run.status !== "failed" && run.status !== "cancelled") {
|
|
@@ -1441,9 +1429,9 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1441
1429
|
// it can render exactly the phases the YAML file declares — including
|
|
1442
1430
|
// user-defined custom workflows. No hardcoded phase list, no fallback.
|
|
1443
1431
|
// List all agent workflows for the dashboard's Workflows browser.
|
|
1444
|
-
app.get("/workflows", (c) => {
|
|
1432
|
+
app.get("/workflows", async (c) => {
|
|
1445
1433
|
const defs = listAgentWorkflows();
|
|
1446
|
-
const overrides = db.getAllWorkflowOverrides();
|
|
1434
|
+
const overrides = await db.getAllWorkflowOverrides();
|
|
1447
1435
|
const workflows = defs.map((def) => ({
|
|
1448
1436
|
name: def.name,
|
|
1449
1437
|
kind: def.kind,
|
|
@@ -1486,14 +1474,14 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1486
1474
|
});
|
|
1487
1475
|
// Full structured definition: every phase field, used by the definition
|
|
1488
1476
|
// browser to render phase details and the diagram.
|
|
1489
|
-
app.get("/workflows/:name/full", (c) => {
|
|
1477
|
+
app.get("/workflows/:name/full", async (c) => {
|
|
1490
1478
|
const name = c.req.param("name");
|
|
1491
1479
|
try {
|
|
1492
1480
|
const def = getWorkflow(name);
|
|
1493
1481
|
return c.json({
|
|
1494
1482
|
workflow: def,
|
|
1495
1483
|
triggers: getWorkflowTriggers(name),
|
|
1496
|
-
enabled: db.isWorkflowEnabled(name),
|
|
1484
|
+
enabled: await db.isWorkflowEnabled(name),
|
|
1497
1485
|
});
|
|
1498
1486
|
}
|
|
1499
1487
|
catch (err) {
|
|
@@ -1514,9 +1502,9 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1514
1502
|
catch {
|
|
1515
1503
|
return c.json({ error: `unknown workflow: ${name}` }, 404);
|
|
1516
1504
|
}
|
|
1517
|
-
const current = db.isWorkflowEnabled(name);
|
|
1505
|
+
const current = await db.isWorkflowEnabled(name);
|
|
1518
1506
|
const next = !current;
|
|
1519
|
-
db.setWorkflowEnabled(name, next, "admin");
|
|
1507
|
+
await db.setWorkflowEnabled(name, next, "admin");
|
|
1520
1508
|
return c.json({ name, enabled: next });
|
|
1521
1509
|
});
|
|
1522
1510
|
// Raw YAML file content — preserves comments and formatting for the
|
|
@@ -1613,17 +1601,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1613
1601
|
return false;
|
|
1614
1602
|
return runOwner === owner && runRepo === repo && issueKey === key;
|
|
1615
1603
|
}
|
|
1616
|
-
function computeArtifactMetadata(owner, repo, key, doc) {
|
|
1617
|
-
const approvals = db.approvals.listByArtifact(doc);
|
|
1604
|
+
async function computeArtifactMetadata(owner, repo, key, doc) {
|
|
1605
|
+
const approvals = await db.approvals.listByArtifact(doc);
|
|
1618
1606
|
if (approvals.length === 0) {
|
|
1619
1607
|
// No approval references this artifact. Docs that aren't guarded by an
|
|
1620
1608
|
// approval remain editable (status.md, executor-summary.md, etc.).
|
|
1621
1609
|
return { editable: true, lock: null };
|
|
1622
1610
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1611
|
+
// Sequential on purpose: one run lookup per approval, in the store's order,
|
|
1612
|
+
// rather than fanning N reads at the DB at once.
|
|
1613
|
+
const enriched = [];
|
|
1614
|
+
for (const approval of approvals) {
|
|
1615
|
+
enriched.push({ approval, run: await db.runs.getRun(approval.workflowRunId) });
|
|
1616
|
+
}
|
|
1627
1617
|
const matching = enriched.filter(({ run }) => runMatchesArtifactTarget(run, owner, repo, key));
|
|
1628
1618
|
const latestMatching = matching[0];
|
|
1629
1619
|
if (latestMatching && latestMatching.approval.status === "pending") {
|
|
@@ -1659,7 +1649,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1659
1649
|
// the server keeps returning global data (see issue #169).
|
|
1660
1650
|
app.get("/repos", async (c) => {
|
|
1661
1651
|
const managed = new Set(getManagedRepos());
|
|
1662
|
-
const activity = new Map(db.runs.distinctRepos().map((r) => [r.repo, r]));
|
|
1652
|
+
const activity = new Map((await db.runs.distinctRepos()).map((r) => [r.repo, r]));
|
|
1663
1653
|
// Fold in artifact-key counts (bounded scan — the tab is a browse view, not
|
|
1664
1654
|
// a report). A repo may have artifacts but no runs, so union it in too.
|
|
1665
1655
|
const artifactCounts = new Map();
|
|
@@ -1853,14 +1843,14 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1853
1843
|
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
1854
1844
|
}
|
|
1855
1845
|
});
|
|
1856
|
-
app.get("/artifacts/:owner/:repo/:key/:doc/metadata", (c) => {
|
|
1846
|
+
app.get("/artifacts/:owner/:repo/:key/:doc/metadata", async (c) => {
|
|
1857
1847
|
if (!buildAssetStore)
|
|
1858
1848
|
return c.json({ error: "build-assets store not configured" }, 404);
|
|
1859
1849
|
const { owner, repo, key, doc } = c.req.param();
|
|
1860
1850
|
try {
|
|
1861
1851
|
// Validate the doc path upfront so traversal attempts surface as 400s.
|
|
1862
1852
|
buildAssetStore.fileFor({ owner, repo, issueKey: key }, doc);
|
|
1863
|
-
const metadata = computeArtifactMetadata(owner, repo, key, doc);
|
|
1853
|
+
const metadata = await computeArtifactMetadata(owner, repo, key, doc);
|
|
1864
1854
|
return c.json(metadata);
|
|
1865
1855
|
}
|
|
1866
1856
|
catch (err) {
|
|
@@ -1876,7 +1866,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1876
1866
|
try {
|
|
1877
1867
|
// Validate the doc path before hitting the approval gate.
|
|
1878
1868
|
buildAssetStore.fileFor({ owner, repo, issueKey: key }, doc);
|
|
1879
|
-
const metadata = computeArtifactMetadata(owner, repo, key, doc);
|
|
1869
|
+
const metadata = await computeArtifactMetadata(owner, repo, key, doc);
|
|
1880
1870
|
if (!metadata.editable) {
|
|
1881
1871
|
return c.json({ error: "artifact_locked", lock: metadata.lock }, 403);
|
|
1882
1872
|
}
|
|
@@ -1889,19 +1879,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1889
1879
|
}
|
|
1890
1880
|
});
|
|
1891
1881
|
// ── Approval Gates ─────────────────────────────────────────────
|
|
1892
|
-
app.get("/approvals", (c) => {
|
|
1893
|
-
const approvals = db.approvals.listPending();
|
|
1882
|
+
app.get("/approvals", async (c) => {
|
|
1883
|
+
const approvals = await db.approvals.listPending();
|
|
1894
1884
|
return c.json({ approvals });
|
|
1895
1885
|
});
|
|
1896
1886
|
// Single approval, enriched with an `artifactRef` the focused approval view
|
|
1897
1887
|
// uses to open the right doc. `artifactRef` is null when the gate carries no
|
|
1898
1888
|
// artifact. In server mode the ref points at the editable store doc; in repo
|
|
1899
1889
|
// mode it carries a GitHub blob URL (the doc is committed on the branch).
|
|
1900
|
-
app.get("/approvals/:id", (c) => {
|
|
1901
|
-
const approval = db.approvals.getById(c.req.param("id"));
|
|
1890
|
+
app.get("/approvals/:id", async (c) => {
|
|
1891
|
+
const approval = await db.approvals.getById(c.req.param("id"));
|
|
1902
1892
|
if (!approval)
|
|
1903
1893
|
return c.json({ error: "approval not found" }, 404);
|
|
1904
|
-
const run = db.runs.getRun(approval.workflowRunId);
|
|
1894
|
+
const run = await db.runs.getRun(approval.workflowRunId);
|
|
1905
1895
|
let artifactRef = null;
|
|
1906
1896
|
if (approval.artifact && run && run.repo) {
|
|
1907
1897
|
// The row is the (owner, BARE repo) pair (issue #279); `context.owner` is
|
|
@@ -1926,7 +1916,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1926
1916
|
app.post("/approvals/:id/respond", async (c) => {
|
|
1927
1917
|
const id = c.req.param("id");
|
|
1928
1918
|
const body = await c.req.json();
|
|
1929
|
-
const approval = db.approvals.getById(id);
|
|
1919
|
+
const approval = await db.approvals.getById(id);
|
|
1930
1920
|
if (!approval)
|
|
1931
1921
|
return c.json({ error: "approval not found" }, 404);
|
|
1932
1922
|
if (approval.status !== "pending")
|
|
@@ -1936,7 +1926,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1936
1926
|
const actor = actorFromContext(c) ?? "admin";
|
|
1937
1927
|
if (body.decision === "rejected") {
|
|
1938
1928
|
// One transaction: respond 'rejected' + fail the run.
|
|
1939
|
-
db.runs.resolveGateAndFail(id, actor, body.reason);
|
|
1929
|
+
await db.runs.resolveGateAndFail(id, actor, body.reason);
|
|
1940
1930
|
}
|
|
1941
1931
|
else {
|
|
1942
1932
|
// Record the approval, then let resumeWorkflow flip the run back to
|
|
@@ -1952,11 +1942,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1952
1942
|
// respond() is a compare-and-set on the still-pending row, so a racing
|
|
1953
1943
|
// responder (the status check above is a TOCTOU read) changes 0 rows.
|
|
1954
1944
|
// Only the winner resumes — the loser must not dispatch a second time.
|
|
1955
|
-
const changed = db.approvals.respond(id, "approved", actor, body.reason);
|
|
1945
|
+
const changed = await db.approvals.respond(id, "approved", actor, body.reason);
|
|
1956
1946
|
if (changed !== 1) {
|
|
1957
1947
|
return c.json({ error: "already resolved" }, 409);
|
|
1958
1948
|
}
|
|
1959
|
-
const workflowRun = db.runs.getRun(approval.workflowRunId);
|
|
1949
|
+
const workflowRun = await db.runs.getRun(approval.workflowRunId);
|
|
1960
1950
|
if (workflowRun && config.resumeWorkflow) {
|
|
1961
1951
|
config.resumeWorkflow(workflowRun, actor).catch((err) => {
|
|
1962
1952
|
log.error("Failed to resume workflow", { workflowRunId: workflowRun.id, err });
|
|
@@ -2013,8 +2003,8 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2013
2003
|
const optedInRepos = (cron, repos, policy) => repos.filter((repo) => cronVote(cron, repoCronPrefs(getCachedRepoLayer(repo)?.config, policy)) === "enable");
|
|
2014
2004
|
// List every cron defined in workflows/cron-*.yaml, merged with the
|
|
2015
2005
|
// override row (if any) and the live scheduler state.
|
|
2016
|
-
app.get("/crons", (c) => {
|
|
2017
|
-
const overrides = db.getAllCronOverrides();
|
|
2006
|
+
app.get("/crons", async (c) => {
|
|
2007
|
+
const overrides = await db.getAllCronOverrides();
|
|
2018
2008
|
const liveByName = new Map((config.cronScheduler?.list() ?? []).map((j) => [j.name, j]));
|
|
2019
2009
|
const defs = getCronWorkflows();
|
|
2020
2010
|
const managedRepos = getManagedRepos();
|
|
@@ -2025,7 +2015,15 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2025
2015
|
const mayVote = repoLayerMayVote(policy);
|
|
2026
2016
|
// One query for the whole list rather than one per cron, under the
|
|
2027
2017
|
// dashboard's 10s poll.
|
|
2028
|
-
const latestCronRuns = db.cronRuns.latestByCron();
|
|
2018
|
+
const latestCronRuns = await db.cronRuns.latestByCron();
|
|
2019
|
+
// Same rule for the failure counts, hoisted out of the map below for the
|
|
2020
|
+
// same reason: the store exposes no batch form of `recentFailures`, so this
|
|
2021
|
+
// is a sequential walk rather than N reads fanned at the DB at once from
|
|
2022
|
+
// inside the render loop.
|
|
2023
|
+
const failuresByCron = new Map();
|
|
2024
|
+
for (const def of defs) {
|
|
2025
|
+
failuresByCron.set(def.name, await db.cronRuns.recentFailures(def.name));
|
|
2026
|
+
}
|
|
2029
2027
|
const crons = defs.map((def) => {
|
|
2030
2028
|
const override = overrides.get(def.name) ?? null;
|
|
2031
2029
|
const enabled = override ? override.enabled : true;
|
|
@@ -2042,7 +2040,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2042
2040
|
// dispatched children sorted first: an arbitrary run, not the tick. A
|
|
2043
2041
|
// zero-discovery fire dispatched no children at all, so it showed nothing.
|
|
2044
2042
|
const last = latestCronRuns.get(def.name) ?? null;
|
|
2045
|
-
const recentFailures =
|
|
2043
|
+
const recentFailures = failuresByCron.get(def.name) ?? 0;
|
|
2046
2044
|
return {
|
|
2047
2045
|
name: def.name,
|
|
2048
2046
|
workflow: def.workflow ?? null,
|
|
@@ -2082,10 +2080,10 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2082
2080
|
const def = getCronWorkflows().find((d) => d.name === name);
|
|
2083
2081
|
if (!def)
|
|
2084
2082
|
return c.json({ error: `cron not found: ${name}` }, 404);
|
|
2085
|
-
const override = db.getCronOverride(name);
|
|
2083
|
+
const override = await db.getCronOverride(name);
|
|
2086
2084
|
const currentlyEnabled = override ? override.enabled : true;
|
|
2087
2085
|
const nextEnabled = !currentlyEnabled;
|
|
2088
|
-
db.setCronOverride(name, { enabled: nextEnabled, updatedBy: "admin" });
|
|
2086
|
+
await db.setCronOverride(name, { enabled: nextEnabled, updatedBy: "admin" });
|
|
2089
2087
|
// Off is "off BY DEFAULT", not "unregistered" (issue #180): a managed repo
|
|
2090
2088
|
// may opt itself back into a globally-off cron from its `.lastlight/`, and
|
|
2091
2089
|
// that is resolved at TICK time — so the tick has to keep running. It just
|
|
@@ -2133,8 +2131,8 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2133
2131
|
const msg = err instanceof Error ? err.message : String(err);
|
|
2134
2132
|
return c.json({ error: `invalid schedule: ${msg}` }, 400);
|
|
2135
2133
|
}
|
|
2136
|
-
db.setCronOverride(name, { schedule, updatedBy: "admin" });
|
|
2137
|
-
const override = db.getCronOverride(name);
|
|
2134
|
+
await db.setCronOverride(name, { schedule, updatedBy: "admin" });
|
|
2135
|
+
const override = await db.getCronOverride(name);
|
|
2138
2136
|
if (override?.enabled !== false) {
|
|
2139
2137
|
config.cronScheduler.update({
|
|
2140
2138
|
name,
|
|
@@ -2146,7 +2144,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2146
2144
|
return c.json({ name, schedule });
|
|
2147
2145
|
});
|
|
2148
2146
|
// Drop the override row and re-register the cron at its YAML default.
|
|
2149
|
-
app.delete("/crons/:name/override", (c) => {
|
|
2147
|
+
app.delete("/crons/:name/override", async (c) => {
|
|
2150
2148
|
if (!config.cronScheduler) {
|
|
2151
2149
|
return c.json({ error: "cron scheduler not configured" }, 503);
|
|
2152
2150
|
}
|
|
@@ -2154,7 +2152,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2154
2152
|
const def = getCronWorkflows().find((d) => d.name === name);
|
|
2155
2153
|
if (!def)
|
|
2156
2154
|
return c.json({ error: `cron not found: ${name}` }, 404);
|
|
2157
|
-
db.clearCronOverride(name);
|
|
2155
|
+
await db.clearCronOverride(name);
|
|
2158
2156
|
const job = {
|
|
2159
2157
|
name,
|
|
2160
2158
|
schedule: def.schedule,
|
|
@@ -2297,7 +2295,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
2297
2295
|
// stuck (`dependabot-ci-fix` for a dependency PR, `pr-fix` otherwise)
|
|
2298
2296
|
// without a second GitHub read to re-derive what the router already decided
|
|
2299
2297
|
// once. A PR we have never fixed falls back to the configured `pr_fix` route.
|
|
2300
|
-
const prior = db.runs.latestForTrigger([...PR_FIX_SHAPED_WORKFLOWS], prTriggerId(repo, prNumber));
|
|
2298
|
+
const prior = await db.runs.latestForTrigger([...PR_FIX_SHAPED_WORKFLOWS], prTriggerId(repo, prNumber));
|
|
2301
2299
|
const workflowName = prior?.workflowName ?? getRoutes().github?.pr_fix ?? "pr-fix";
|
|
2302
2300
|
const state = await resolvePrState(owner, name, prNumber, {
|
|
2303
2301
|
github,
|