agents-relay 1.0.8 → 1.0.10
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/pool.js +17 -0
- package/dist/reconciler.js +9 -8
- package/dist/relayd.js +4 -3
- package/package.json +1 -1
package/dist/pool.js
CHANGED
|
@@ -21,6 +21,7 @@ export class RepositoryWorkerPool {
|
|
|
21
21
|
makeReconciler;
|
|
22
22
|
running = false;
|
|
23
23
|
pending = false;
|
|
24
|
+
jobTargets = new Map();
|
|
24
25
|
constructor(client, repository, trustedAuthors, concurrency, makeReconciler) {
|
|
25
26
|
this.client = client;
|
|
26
27
|
this.trustedAuthors = trustedAuthors;
|
|
@@ -30,6 +31,8 @@ export class RepositoryWorkerPool {
|
|
|
30
31
|
}
|
|
31
32
|
repositories;
|
|
32
33
|
async reconcileDiscovered(discovered) {
|
|
34
|
+
for (const item of discovered)
|
|
35
|
+
this.jobTargets.set(item.job.id, { repository: item.job.repository, prNumber: item.job.prNumber });
|
|
33
36
|
// Terminal PRs must be reconciled before OPEN-job scheduling. Otherwise the
|
|
34
37
|
// OPEN-only runnable filter can strand durable jobs after GitHub merges/closes them.
|
|
35
38
|
for (const job of terminalManagedJobs(discovered)) {
|
|
@@ -71,11 +74,25 @@ export class RepositoryWorkerPool {
|
|
|
71
74
|
async reconcileTarget(repository, prNumber, jobId) {
|
|
72
75
|
if (!this.repositories.includes(repository))
|
|
73
76
|
return;
|
|
77
|
+
this.jobTargets.set(jobId, { repository, prNumber });
|
|
74
78
|
const store = new GitHubStore(this.client, repository, prNumber, this.trustedAuthors);
|
|
75
79
|
await this.makeReconciler(store, Math.max(1, this.concurrency)).reconcile(jobId);
|
|
76
80
|
}
|
|
81
|
+
async handleTerminalEvent(event) {
|
|
82
|
+
const target = this.jobTargets.get(event.job_id);
|
|
83
|
+
if (!target || !this.repositories.includes(target.repository)) {
|
|
84
|
+
process.stderr.write(`warning: terminal event target unknown for job ${event.job_id}\n`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const store = new GitHubStore(this.client, target.repository, target.prNumber, this.trustedAuthors);
|
|
88
|
+
await this.makeReconciler(store, Math.max(1, this.concurrency)).handleEvent(event);
|
|
89
|
+
}
|
|
77
90
|
async watch(bus) {
|
|
78
91
|
return bus.subscribeAll(async (event) => {
|
|
92
|
+
if (['task.completed', 'task.failed', 'task.blocked'].includes(event.type)) {
|
|
93
|
+
await this.handleTerminalEvent(event);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
79
96
|
if (event.type === 'job.wake' || event.type === 'github.webhook') {
|
|
80
97
|
const repository = typeof event.data?.repository === 'string' ? event.data.repository : '';
|
|
81
98
|
const prNumber = Number(event.data?.prNumber);
|
package/dist/reconciler.js
CHANGED
|
@@ -50,18 +50,19 @@ export class Reconciler {
|
|
|
50
50
|
this.store = store;
|
|
51
51
|
this.options = options;
|
|
52
52
|
}
|
|
53
|
+
async handleEvent(event) {
|
|
54
|
+
if (['task.completed', 'task.failed', 'task.blocked'].includes(event.type)) {
|
|
55
|
+
await this.applyTerminalEvent(event);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (event.type === 'job.wake' || event.type === 'github.webhook')
|
|
59
|
+
await this.reconcile(event.job_id);
|
|
60
|
+
}
|
|
53
61
|
async watch(jobId) {
|
|
54
62
|
if (!this.options.eventBus)
|
|
55
63
|
return async () => { };
|
|
56
64
|
try {
|
|
57
|
-
return await this.options.eventBus.subscribe(jobId,
|
|
58
|
-
if (['task.completed', 'task.failed', 'task.blocked'].includes(event.type)) {
|
|
59
|
-
await this.applyTerminalEvent(event);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (event.type === 'job.wake' || event.type === 'github.webhook')
|
|
63
|
-
await this.reconcile(jobId);
|
|
64
|
-
});
|
|
65
|
+
return await this.options.eventBus.subscribe(jobId, event => this.handleEvent(event));
|
|
65
66
|
}
|
|
66
67
|
catch (error) {
|
|
67
68
|
await this.reportTransportFailure(error);
|
package/dist/relayd.js
CHANGED
|
@@ -113,7 +113,7 @@ export async function runDaemon(argv) {
|
|
|
113
113
|
await persistCache();
|
|
114
114
|
return refreshed;
|
|
115
115
|
};
|
|
116
|
-
const initial =
|
|
116
|
+
const initial = cachedOverviews;
|
|
117
117
|
const fallback = initial[0]?.job;
|
|
118
118
|
const dashboardStore = fallback ? new GitHubStore(client, fallback.repository, fallback.prNumber, trusted) : new InMemoryStore();
|
|
119
119
|
const secretFile = value(argv, '--github-webhook-secret-file');
|
|
@@ -170,8 +170,9 @@ export async function runDaemon(argv) {
|
|
|
170
170
|
process.once('SIGINT', stop);
|
|
171
171
|
process.once('SIGTERM', stop);
|
|
172
172
|
console.log('Dashboard listening; repository worker pool active');
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
void refreshAll()
|
|
174
|
+
.then(items => pool.reconcileKnown(items))
|
|
175
|
+
.catch(error => process.stderr.write(`warning: startup reconciliation unavailable: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
175
176
|
}
|
|
176
177
|
if (isEntrypoint(import.meta.url))
|
|
177
178
|
runDaemon(process.argv.slice(2)).catch(error => { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; });
|