agents-relay 1.0.7 → 1.0.9
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/events.js +26 -8
- package/dist/relayd.js +4 -3
- package/package.json +1 -1
package/dist/events.js
CHANGED
|
@@ -24,13 +24,31 @@ export class NatsEventBus {
|
|
|
24
24
|
async publish(event) { const nats = await this.moduleLoaded(); const subject = `${this.subjectPrefix}.${subjectToken(event.job_id)}.${event.type}`; (await this.client()).publish(subject, nats.StringCodec().encode(JSON.stringify(event))); }
|
|
25
25
|
async subscribe(jobId, wake) { return this.subscribeSubject(`${this.subjectPrefix}.${subjectToken(jobId)}.>`, wake); }
|
|
26
26
|
async subscribeAll(wake) { return this.subscribeSubject(`${this.subjectPrefix}.>`, wake); }
|
|
27
|
-
async subscribeSubject(subject, wake) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
async subscribeSubject(subject, wake) {
|
|
28
|
+
const nats = await this.moduleLoaded();
|
|
29
|
+
const codec = nats.StringCodec();
|
|
30
|
+
const subscription = (await this.client()).subscribe(subject);
|
|
31
|
+
let active = true;
|
|
32
|
+
void (async () => {
|
|
33
|
+
for await (const message of subscription) {
|
|
34
|
+
if (!active)
|
|
35
|
+
break;
|
|
36
|
+
let event;
|
|
37
|
+
try {
|
|
38
|
+
event = JSON.parse(codec.decode(message.data));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
await wake(event);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
process.stderr.write(`warning: event handler failed for ${subject}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})();
|
|
51
|
+
return async () => { active = false; subscription.unsubscribe(); };
|
|
52
|
+
}
|
|
35
53
|
}
|
|
36
54
|
export function eventFor(jobId, taskId, parentTaskId, type, status, message, visibility = 'orchestrator', data) { return { version: 1, event_id: randomUUID(), job_id: jobId, task_id: taskId, parent_task_id: parentTaskId, type, status, timestamp: new Date().toISOString(), visibility, level: status === 'failed' || status === 'blocked' ? 'error' : 'info', message, data }; }
|
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; });
|