agents-relay 1.0.0 → 1.0.2

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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +2 -1
  3. package/dist/dashboard.js +1 -1
  4. package/dist/relayd.js +2 -2
  5. package/dist/store.js +24 -9
  6. package/package.json +19 -4
  7. package/.github/workflows/publish.yml +0 -91
  8. package/AGENTS.md +0 -16
  9. package/docs/agent-network.md +0 -34
  10. package/docs/architecture.md +0 -120
  11. package/docs/autonomous-objective-jobs.md +0 -121
  12. package/docs/example.md +0 -30
  13. package/docs/github-app-rate-limit.md +0 -124
  14. package/docs/service.md +0 -43
  15. package/pack.json +0 -326
  16. package/scripts/npm-version.mjs +0 -11
  17. package/src/adapters.ts +0 -231
  18. package/src/cli.ts +0 -324
  19. package/src/continuation.ts +0 -6
  20. package/src/dashboard.ts +0 -421
  21. package/src/events.ts +0 -25
  22. package/src/github-auth.ts +0 -35
  23. package/src/github-webhook.ts +0 -37
  24. package/src/markers.ts +0 -33
  25. package/src/planner.ts +0 -150
  26. package/src/pool.ts +0 -87
  27. package/src/reconciler.ts +0 -235
  28. package/src/registry.ts +0 -35
  29. package/src/relayd.ts +0 -137
  30. package/src/scheduler.ts +0 -27
  31. package/src/store.ts +0 -526
  32. package/src/types.ts +0 -45
  33. package/src/usage.ts +0 -385
  34. package/src/workspace.ts +0 -62
  35. package/test/adapters.test.js +0 -303
  36. package/test/autonomous.test.js +0 -119
  37. package/test/core.test.js +0 -363
  38. package/test/dashboard.test.js +0 -178
  39. package/test/github-auth.test.js +0 -51
  40. package/test/github-webhook.test.js +0 -21
  41. package/test/service.test.js +0 -116
  42. package/test/store.test.js +0 -390
  43. package/test/usage.test.js +0 -88
  44. package/test/workspace.test.js +0 -95
  45. package/tsconfig.json +0 -4
@@ -1,124 +0,0 @@
1
- # GitHub App Authentication and API Consumption
2
-
3
- Agents Relay can authenticate GitHub API traffic with a GitHub App installation instead of consuming the interactive user account quota. This document also records the API-consumption changes that make webhook-driven reconciliation the normal path.
4
-
5
- ## Goals
6
-
7
- - Separate automation API traffic from the developer's interactive GitHub identity.
8
- - Cache GitHub App installation tokens instead of minting one per request.
9
- - Apply the same rate-limit cooldown to REST and GraphQL calls.
10
- - Stop periodic dashboard refreshes from causing workspace-wide GitHub scans.
11
- - Keep webhook wakes targeted to a repository and pull request.
12
- - Retain a low-frequency watchdog and startup reconciliation for missed events/restarts.
13
- - Preserve existing `gh` authentication when GitHub App settings are not configured.
14
-
15
- ## Authentication flow
16
-
17
- ```mermaid
18
- sequenceDiagram
19
- participant R as Agents Relay
20
- participant K as App private key
21
- participant G as GitHub App API
22
- participant I as Installation API
23
- R->>K: read configured PEM key
24
- R->>R: create RS256 JWT
25
- R->>I: POST installation access token
26
- I-->>R: installation token + expiry
27
- R->>R: cache token until near expiry
28
- R->>G: REST / GraphQL using installation token
29
- Note over R,G: existing gh login remains fallback when App auth is absent
30
- ```
31
-
32
- The JWT uses a 60-second backdated `iat` and an expiry nine minutes in the future. Installation tokens are cached and refreshed only when fewer than five minutes remain. No private key or token is written to durable PR state.
33
-
34
- ## Configuration
35
-
36
- All three GitHub App settings are required together. They can be provided as CLI flags or environment variables. CLI flags take precedence.
37
-
38
- | CLI flag | Environment variable | Meaning |
39
- | --- | --- | --- |
40
- | `--github-app-id` | `AGENTS_RELAY_GITHUB_APP_ID` | GitHub App ID |
41
- | `--github-app-installation-id` | `AGENTS_RELAY_GITHUB_APP_INSTALLATION_ID` | Installation ID for the account/repositories |
42
- | `--github-app-private-key-file` | `AGENTS_RELAY_GITHUB_APP_PRIVATE_KEY_FILE` | Local PEM private-key path |
43
- | `--trusted-authors` | `AGENTS_RELAY_TRUSTED_AUTHORS` | Extra trusted marker authors |
44
-
45
- Example:
46
-
47
- ```bash
48
- export AGENTS_RELAY_GITHUB_APP_ID=123456
49
- export AGENTS_RELAY_GITHUB_APP_INSTALLATION_ID=7890123
50
- export AGENTS_RELAY_GITHUB_APP_PRIVATE_KEY_FILE=$HOME/.config/agents-relay/github-app.pem
51
- npx agents-relayd --workspace ~/Workspace
52
- ```
53
-
54
- When App auth is enabled, Agents Relay trusts both the App bot identity and the current local `gh` user (when one exists). This keeps existing durable markers readable during migration from user auth to App auth.
55
-
56
- ## Rate-limit behavior
57
-
58
- REST and GraphQL now share one cooldown circuit. A rate-limit/secondary-limit/HTTP 429 failure activates exponential cooldown (one minute initially, capped at fifteen minutes). While cooldown is active, workspace refresh/reconciliation uses cached state rather than continuing to spend requests.
59
-
60
- ```mermaid
61
- flowchart TD
62
- A[GitHub request] --> B{Cooldown active?}
63
- B -->|yes| C[Return cached/degraded state]
64
- B -->|no| D[REST or GraphQL request]
65
- D --> E{Rate-limit failure?}
66
- E -->|yes| F[Increase cooldown]
67
- F --> C
68
- E -->|no| G[Reset failure backoff]
69
- G --> H[Persist/serve fresh state]
70
- ```
71
-
72
- ## Webhook-first consumption model
73
-
74
- The workspace daemon previously had several independent paths that could trigger broad GitHub reads: the five-minute watchdog, dashboard `/api/jobs` refreshes, startup discovery, and webhook reconciliation. The new flow keeps broad discovery exceptional.
75
-
76
- ```mermaid
77
- flowchart LR
78
- S[Daemon startup] --> A[One workspace discovery]
79
- A --> B[Reconcile discovered state directly]
80
- W[GitHub webhook] --> T[Target exact repository + PR]
81
- T --> R[Targeted reconciliation]
82
- R --> C[Update durable state]
83
- D[Dashboard auto refresh] --> K[Read local cache]
84
- M[Manual Jobs refresh] --> A
85
- F[30-minute webhook watchdog] --> A
86
- ```
87
-
88
- Key changes:
89
-
90
- - Startup discovery is reused directly for startup reconciliation, avoiding a second immediate workspace scan.
91
- - Dashboard automatic refresh reads the in-process/disk cache. Only an explicit Jobs refresh asks for a broad refresh.
92
- - Selected-job refresh remains targeted to that job's pull request.
93
- - Webhook mode uses a 30-minute watchdog by default instead of five minutes; `--interval` still overrides it.
94
- - Without webhook configuration, the existing five-minute watchdog remains for compatibility.
95
- - Full discovery queries every open PR but only the 20 most recently updated closed PRs; it no longer paginates the complete closed PR history.
96
-
97
- ## Discovery query shape
98
-
99
- ```mermaid
100
- flowchart TD
101
- Q[Repository discovery] --> O[OPEN PR connection]
102
- O -->|paginate until complete| OM[Managed open jobs]
103
- Q --> C[20 most recent CLOSED PRs]
104
- C --> CM[Recent terminal jobs]
105
- OM --> D[Dashboard/reconciliation set]
106
- CM --> D
107
- ```
108
-
109
- This keeps all active managed jobs discoverable while bounding historical reads needed for dashboard history and missed terminal lifecycle recovery. Webhooks remain the primary path for immediate merge/close transitions.
110
-
111
- ## Failure and migration behavior
112
-
113
- - Partial App configuration fails fast; Agents Relay will not silently mix identities.
114
- - If App authentication is not configured, existing local `gh` authentication is unchanged.
115
- - If GitHub becomes rate limited, dashboard data remains available from cache and the daemon stops broad retries until cooldown expires.
116
- - The private key is read locally and used only to sign App JWTs. Durable GitHub comments never contain the key, JWT, or installation token.
117
-
118
- ## Validation
119
-
120
- Coverage includes App-config validation, RS256 JWT signature/claims, existing fixed/auth fallback behavior, dashboard manual-vs-cached refresh wiring, startup reconciliation reuse without a second workspace scan, targeted webhook reconciliation, and open-PR pagination with bounded closed history. Run the full suite with:
121
-
122
- ```bash
123
- npm test
124
- ```
package/docs/service.md DELETED
@@ -1,43 +0,0 @@
1
- # Running the service
2
-
3
- `agents-relayd` starts the repository worker pool, event-driven reconciler, periodic recovery watchdog, and dashboard. With no `--pr`/`--id`, it discovers Git repositories under `~/Workspace` (or `--workspace PATH`), maps GitHub `origin` remotes to repositories, and watches all discovered repositories together. It listens on `127.0.0.1:8787` by default. With a GitHub webhook configured, targeted webhook reconciliation is primary and the broad recovery watchdog runs every 30 minutes by default; without a webhook, the compatibility watchdog remains 5 minutes. Dashboard auto-refresh and periodic SSE snapshots use cached workspace state instead of broad GitHub reads. Explicit Jobs refresh performs broad discovery, while selected-job refresh is targeted to one pull request.
4
-
5
- The dashboard reads a bounded window (one day by default, or `--usage-window-days`) of local Codex JSONL session telemetry at `/api/usage`. Requests recorded with GLM models are shown as Z.ai runtime usage; account quota and remaining balance are marked unavailable unless a supported source is added.
6
-
7
- ```sh
8
- npx agents-relayd --repo OWNER/REPO
9
- ```
10
-
11
- Workspace mode (the default):
12
-
13
- ```sh
14
- npx agents-relayd --workspace ~/Workspace
15
- ```
16
-
17
- Use `--repo OWNER/REPO` to retain the single-repository worker pool. Legacy single-job daemon mode remains available with `--repo OWNER/REPO --pr NUMBER --id JOB_ID`.
18
-
19
- Use service overrides as needed:
20
-
21
- ```sh
22
- npx agents-relayd --repo OWNER/REPO \
23
- --port 8787 --interval 1800000 --refresh-ms 300000 \
24
- --events nats --nats-url nats://127.0.0.1:4222
25
- ```
26
-
27
- For an installed package, launch through the package binary rather than a checkout path:
28
-
29
- ```sh
30
- npx --package agents-relay agents-relayd --repo OWNER/REPO
31
- ```
32
-
33
- With PM2:
34
-
35
- ```sh
36
- npx --package agents-relay --package pm2 pm2 start agents-relayd --name agents-relayd -- \
37
- --repo OWNER/REPO \
38
- --events nats --nats-url nats://127.0.0.1:4222
39
- ```
40
-
41
- PM2 forwards `SIGINT` and `SIGTERM`. The service clears its watchdog, unsubscribes from wake events, closes the local dashboard server, and exits only after cleanup.
42
-
43
- GitHub App installation authentication and the webhook/cache consumption model are documented in [github-app-rate-limit.md](github-app-rate-limit.md).
package/pack.json DELETED
@@ -1,326 +0,0 @@
1
- [
2
- {
3
- "id": "agents-relay@1.0.0",
4
- "name": "agents-relay",
5
- "version": "1.0.0",
6
- "size": 139459,
7
- "unpackedSize": 558932,
8
- "shasum": "5226a077ca94674bad5c7ceb2755d2dee30a4a16",
9
- "integrity": "sha512-EV0VBLgoqprIeDjTm+cW/0sefNFLGoPMSFYluWknICMaUOV6uxXiR6E/WJRuP+mTkXc9XmcmBeJbnSQtGtZbcQ==",
10
- "filename": "agents-relay-1.0.0.tgz",
11
- "files": [
12
- {
13
- "path": ".github/workflows/publish.yml",
14
- "size": 3469,
15
- "mode": 420
16
- },
17
- {
18
- "path": "AGENTS.md",
19
- "size": 955,
20
- "mode": 420
21
- },
22
- {
23
- "path": "LICENSE",
24
- "size": 1065,
25
- "mode": 420
26
- },
27
- {
28
- "path": "README.md",
29
- "size": 8465,
30
- "mode": 420
31
- },
32
- {
33
- "path": "dist/adapters.js",
34
- "size": 13461,
35
- "mode": 420
36
- },
37
- {
38
- "path": "dist/cli.js",
39
- "size": 26305,
40
- "mode": 493
41
- },
42
- {
43
- "path": "dist/continuation.js",
44
- "size": 1476,
45
- "mode": 420
46
- },
47
- {
48
- "path": "dist/dashboard.js",
49
- "size": 39154,
50
- "mode": 420
51
- },
52
- {
53
- "path": "dist/events.js",
54
- "size": 2789,
55
- "mode": 420
56
- },
57
- {
58
- "path": "dist/github-auth.js",
59
- "size": 1746,
60
- "mode": 420
61
- },
62
- {
63
- "path": "dist/github-webhook.js",
64
- "size": 2038,
65
- "mode": 420
66
- },
67
- {
68
- "path": "dist/markers.js",
69
- "size": 1996,
70
- "mode": 420
71
- },
72
- {
73
- "path": "dist/planner.js",
74
- "size": 8790,
75
- "mode": 420
76
- },
77
- {
78
- "path": "dist/pool.js",
79
- "size": 5469,
80
- "mode": 420
81
- },
82
- {
83
- "path": "dist/reconciler.js",
84
- "size": 25047,
85
- "mode": 420
86
- },
87
- {
88
- "path": "dist/registry.js",
89
- "size": 1800,
90
- "mode": 420
91
- },
92
- {
93
- "path": "dist/relayd.js",
94
- "size": 10056,
95
- "mode": 493
96
- },
97
- {
98
- "path": "dist/scheduler.js",
99
- "size": 2869,
100
- "mode": 420
101
- },
102
- {
103
- "path": "dist/store.js",
104
- "size": 30955,
105
- "mode": 420
106
- },
107
- {
108
- "path": "dist/types.js",
109
- "size": 1043,
110
- "mode": 420
111
- },
112
- {
113
- "path": "dist/usage.js",
114
- "size": 16829,
115
- "mode": 420
116
- },
117
- {
118
- "path": "dist/workspace.js",
119
- "size": 2684,
120
- "mode": 420
121
- },
122
- {
123
- "path": "docs/agent-network.md",
124
- "size": 2556,
125
- "mode": 420
126
- },
127
- {
128
- "path": "docs/architecture.md",
129
- "size": 7632,
130
- "mode": 420
131
- },
132
- {
133
- "path": "docs/autonomous-objective-jobs.md",
134
- "size": 5702,
135
- "mode": 420
136
- },
137
- {
138
- "path": "docs/example.md",
139
- "size": 1413,
140
- "mode": 420
141
- },
142
- {
143
- "path": "docs/github-app-rate-limit.md",
144
- "size": 6030,
145
- "mode": 420
146
- },
147
- {
148
- "path": "docs/service.md",
149
- "size": 2255,
150
- "mode": 420
151
- },
152
- {
153
- "path": "pack.json",
154
- "size": 0,
155
- "mode": 420
156
- },
157
- {
158
- "path": "package.json",
159
- "size": 562,
160
- "mode": 420
161
- },
162
- {
163
- "path": "scripts/npm-version.mjs",
164
- "size": 420,
165
- "mode": 493
166
- },
167
- {
168
- "path": "skills/agents-relay/agents/planner.agent.md",
169
- "size": 1265,
170
- "mode": 420
171
- },
172
- {
173
- "path": "skills/agents-relay/SKILL.md",
174
- "size": 6747,
175
- "mode": 420
176
- },
177
- {
178
- "path": "src/adapters.ts",
179
- "size": 13759,
180
- "mode": 420
181
- },
182
- {
183
- "path": "src/cli.ts",
184
- "size": 27102,
185
- "mode": 420
186
- },
187
- {
188
- "path": "src/continuation.ts",
189
- "size": 1842,
190
- "mode": 420
191
- },
192
- {
193
- "path": "src/dashboard.ts",
194
- "size": 38466,
195
- "mode": 420
196
- },
197
- {
198
- "path": "src/events.ts",
199
- "size": 3820,
200
- "mode": 420
201
- },
202
- {
203
- "path": "src/github-auth.ts",
204
- "size": 2083,
205
- "mode": 420
206
- },
207
- {
208
- "path": "src/github-webhook.ts",
209
- "size": 2353,
210
- "mode": 420
211
- },
212
- {
213
- "path": "src/markers.ts",
214
- "size": 2145,
215
- "mode": 420
216
- },
217
- {
218
- "path": "src/planner.ts",
219
- "size": 9322,
220
- "mode": 420
221
- },
222
- {
223
- "path": "src/pool.ts",
224
- "size": 5653,
225
- "mode": 420
226
- },
227
- {
228
- "path": "src/reconciler.ts",
229
- "size": 23541,
230
- "mode": 420
231
- },
232
- {
233
- "path": "src/registry.ts",
234
- "size": 2288,
235
- "mode": 420
236
- },
237
- {
238
- "path": "src/relayd.ts",
239
- "size": 9864,
240
- "mode": 493
241
- },
242
- {
243
- "path": "src/scheduler.ts",
244
- "size": 2877,
245
- "mode": 420
246
- },
247
- {
248
- "path": "src/store.ts",
249
- "size": 33718,
250
- "mode": 420
251
- },
252
- {
253
- "path": "src/types.ts",
254
- "size": 4184,
255
- "mode": 420
256
- },
257
- {
258
- "path": "src/usage.ts",
259
- "size": 17314,
260
- "mode": 420
261
- },
262
- {
263
- "path": "src/workspace.ts",
264
- "size": 2734,
265
- "mode": 420
266
- },
267
- {
268
- "path": "test/adapters.test.js",
269
- "size": 12940,
270
- "mode": 420
271
- },
272
- {
273
- "path": "test/autonomous.test.js",
274
- "size": 8417,
275
- "mode": 420
276
- },
277
- {
278
- "path": "test/core.test.js",
279
- "size": 37282,
280
- "mode": 420
281
- },
282
- {
283
- "path": "test/dashboard.test.js",
284
- "size": 9291,
285
- "mode": 420
286
- },
287
- {
288
- "path": "test/github-auth.test.js",
289
- "size": 2848,
290
- "mode": 420
291
- },
292
- {
293
- "path": "test/github-webhook.test.js",
294
- "size": 1341,
295
- "mode": 420
296
- },
297
- {
298
- "path": "test/service.test.js",
299
- "size": 6766,
300
- "mode": 420
301
- },
302
- {
303
- "path": "test/store.test.js",
304
- "size": 22991,
305
- "mode": 420
306
- },
307
- {
308
- "path": "test/usage.test.js",
309
- "size": 4797,
310
- "mode": 420
311
- },
312
- {
313
- "path": "test/workspace.test.js",
314
- "size": 5871,
315
- "mode": 420
316
- },
317
- {
318
- "path": "tsconfig.json",
319
- "size": 280,
320
- "mode": 420
321
- }
322
- ],
323
- "entryCount": 62,
324
- "bundled": []
325
- }
326
- ]
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- export function nextPatchVersion(current) {
3
- if (!current) return '1.0.0';
4
- const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(current.trim());
5
- if (!match) throw new Error(`Unsupported npm version: ${current}`);
6
- return `${match[1]}.${match[2]}.${Number(match[3]) + 1}`;
7
- }
8
-
9
- if (import.meta.url === `file://${process.argv[1]}`) {
10
- process.stdout.write(`${nextPatchVersion(process.argv[2] ?? '')}\n`);
11
- }