agents-relay 1.0.167 → 1.0.168
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/dist/relayd.js +10 -6
- package/package.json +1 -1
package/dist/relayd.js
CHANGED
|
@@ -19,9 +19,13 @@ import { deriveJobRuntimeStatus } from './runtime-status.js';
|
|
|
19
19
|
import { decisionMode, LayaCliDecisionEngine } from './decision.js';
|
|
20
20
|
import { JsonlDecisionAuditStore } from './decision-audit.js';
|
|
21
21
|
import { summarizeRuntime } from './runtime-summary.js';
|
|
22
|
-
import {
|
|
22
|
+
import { runScheduledBucket } from './scheduled-jobs.js';
|
|
23
|
+
import { scheduleBucket } from './scheduler.js';
|
|
23
24
|
const PR_REFRESH_COALESCE_MS = 1000;
|
|
24
25
|
export const SCHEDULE_HEARTBEAT_MS = 600_000;
|
|
26
|
+
export function dueScheduledOverviews(overviews, now = new Date()) {
|
|
27
|
+
return overviews.filter(item => item.githubState === 'OPEN' && item.job.executionMode === 'autonomous' && item.job.schedule && Date.parse(item.job.schedule.nextRunAt) <= now.getTime());
|
|
28
|
+
}
|
|
25
29
|
export function shouldCoalescePullRequestRefresh(completedAt, now = Date.now(), force = false) {
|
|
26
30
|
return !force && completedAt !== null && now >= completedAt && now - completedAt < PR_REFRESH_COALESCE_MS;
|
|
27
31
|
}
|
|
@@ -286,12 +290,13 @@ export async function runDaemon(argv) {
|
|
|
286
290
|
if (client.rateLimitStatus().limited)
|
|
287
291
|
return;
|
|
288
292
|
const now = new Date();
|
|
289
|
-
for (const
|
|
293
|
+
for (const item of dueScheduledOverviews(cachedOverviews, now)) {
|
|
294
|
+
const repository = item.job.repository;
|
|
290
295
|
try {
|
|
291
|
-
await
|
|
296
|
+
await runScheduledBucket(client, repository, trusted, { prNumber: item.job.prNumber, jobId: item.job.id, bucket: scheduleBucket(new Date(item.job.schedule.nextRunAt)) }, { reconcile: async () => { await pool.reconcileTarget(repository, item.job.prNumber, item.job.id); }, idle: async () => { } }, now);
|
|
292
297
|
}
|
|
293
298
|
catch (error) {
|
|
294
|
-
process.stderr.write(`warning: scheduled heartbeat unavailable for ${repository}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
299
|
+
process.stderr.write(`warning: scheduled heartbeat unavailable for ${repository}#${item.job.prNumber}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
302
|
};
|
|
@@ -304,9 +309,8 @@ export async function runDaemon(argv) {
|
|
|
304
309
|
process.once('SIGINT', stop);
|
|
305
310
|
process.once('SIGTERM', stop);
|
|
306
311
|
console.log('Dashboard listening; repository worker pool active');
|
|
307
|
-
void scheduleHeartbeatSafely();
|
|
308
312
|
void refreshAll(true)
|
|
309
|
-
.then(items => pool.reconcileKnown(items))
|
|
313
|
+
.then(async (items) => { await scheduleHeartbeatSafely(); await pool.reconcileKnown(items); })
|
|
310
314
|
.catch(error => process.stderr.write(`warning: startup reconciliation unavailable: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
311
315
|
}
|
|
312
316
|
if (isEntrypoint(import.meta.url))
|