morpheus-cli 0.8.3 → 0.8.4
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.
|
@@ -32,6 +32,17 @@ const ExecutionsQuerySchema = z.object({
|
|
|
32
32
|
export function createChronosJobRouter(repo, _worker) {
|
|
33
33
|
const router = Router();
|
|
34
34
|
const configManager = ConfigManager.getInstance();
|
|
35
|
+
// GET /api/chronos/executions/recent?since=<ms> — must be before /:id routes
|
|
36
|
+
router.get('/executions/recent', (req, res) => {
|
|
37
|
+
const since = Number(req.query.since) || (Date.now() - 60_000);
|
|
38
|
+
try {
|
|
39
|
+
const executions = repo.getRecentCompletions(since);
|
|
40
|
+
res.json(executions);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
res.status(500).json({ error: err.message });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
35
46
|
// POST /api/chronos/preview — must be before /:id routes
|
|
36
47
|
router.post('/preview', (req, res) => {
|
|
37
48
|
const parsed = PreviewSchema.safeParse(req.body);
|
|
@@ -238,6 +238,16 @@ export class ChronosRepository {
|
|
|
238
238
|
`).all(jobId, Math.min(limit, 100));
|
|
239
239
|
return rows.map((r) => this.deserializeExecution(r));
|
|
240
240
|
}
|
|
241
|
+
getRecentCompletions(since, limit = 20) {
|
|
242
|
+
const rows = this.db.prepare(`
|
|
243
|
+
SELECT e.*, j.prompt as job_prompt
|
|
244
|
+
FROM chronos_executions e
|
|
245
|
+
LEFT JOIN chronos_jobs j ON j.id = e.job_id
|
|
246
|
+
WHERE e.completed_at IS NOT NULL AND e.completed_at > ?
|
|
247
|
+
ORDER BY e.completed_at DESC LIMIT ?
|
|
248
|
+
`).all(since, limit);
|
|
249
|
+
return rows.map(r => ({ ...this.deserializeExecution(r), job_prompt: r.job_prompt ?? '' }));
|
|
250
|
+
}
|
|
241
251
|
pruneExecutions(jobId, keepCount) {
|
|
242
252
|
this.db.prepare(`
|
|
243
253
|
DELETE FROM chronos_executions
|