agents-relay 2.0.62 → 2.0.63

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.
@@ -1,4 +1,25 @@
1
1
  import { createHmac, timingSafeEqual } from 'node:crypto';
2
+ export const PACKAGE_FAILED_MARKER = 'agents-relay:package-publish-failed:v1';
3
+ export function parsePackagePublishFailureMarker(body) {
4
+ if (typeof body !== 'string')
5
+ return null;
6
+ const prefix = '<!-- ' + PACKAGE_FAILED_MARKER + ' ';
7
+ const start = body.indexOf(prefix);
8
+ if (start < 0)
9
+ return null;
10
+ const end = body.indexOf(' -->', start + prefix.length);
11
+ if (end < 0)
12
+ return null;
13
+ try {
14
+ const data = JSON.parse(body.slice(start + prefix.length, end));
15
+ if (typeof data.runId !== 'string' || !/^\d+$/.test(data.runId) || !Number.isInteger(data.attempt) || Number(data.attempt) < 1 || typeof data.sha !== 'string' || !/^[a-f0-9]{7,40}$/i.test(data.sha) || typeof data.stage !== 'string' || !data.stage)
16
+ return null;
17
+ return { runId: data.runId, attempt: Number(data.attempt), sha: data.sha, stage: data.stage };
18
+ }
19
+ catch {
20
+ return null;
21
+ }
22
+ }
2
23
  export const PACKAGE_PUBLISHED_MARKER = 'agents-relay:package-published:v1';
3
24
  export function parsePackagePublicationMarker(body) {
4
25
  if (typeof body !== 'string')
@@ -71,9 +92,11 @@ export function parseGitHubWebhook(headers, body) {
71
92
  if (event === 'issue_comment') {
72
93
  const comment = payload.comment;
73
94
  const publication = parsePackagePublicationMarker(comment?.body);
74
- if (!publication)
95
+ const publishFailure = comment?.user?.login === 'github-actions[bot]'
96
+ ? parsePackagePublishFailureMarker(comment?.body) : null;
97
+ if (!publication && !publishFailure)
75
98
  return null;
76
- return { deliveryId, event, action, repository: repositoryName, pullRequest: number, publication, pullRequestFacts: null };
99
+ return { deliveryId, event, action, repository: repositoryName, pullRequest: number, publication, ...(publishFailure ? { publishFailure } : {}), pullRequestFacts: null };
77
100
  }
78
101
  const facts = pullRequestFacts(payload, action);
79
102
  if (!facts)
package/dist/pool.js CHANGED
@@ -311,6 +311,9 @@ export class RepositoryWorkerPool {
311
311
  sha: wake.publication.sha,
312
312
  }, source));
313
313
  }
314
+ if (wake.publishFailure) {
315
+ await bus.publish(eventFor(job.id, 'release', null, 'package.publish_failed', 'failed', `Publish workflow ${wake.publishFailure.runId} failed: ${wake.publishFailure.stage}`, 'user', { ...wake.publishFailure, repository: job.repository, prNumber: job.prNumber, deliveryId: wake.deliveryId }, source));
316
+ }
314
317
  await bus.publish(eventFor(job.id, 'github', null, 'github.webhook', 'queued', `GitHub webhook ${wake.event}${wake.action ? ':' + wake.action : ''}`, 'orchestrator', { deliveryId: wake.deliveryId, event: wake.event, action: wake.action, repository: job.repository, prNumber: job.prNumber }, source));
315
318
  return;
316
319
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.62",
3
+ "version": "2.0.63",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "type": "module",
6
6
  "bin": {