agents-relay 2.0.0 → 2.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.
package/dist/dashboard.js CHANGED
@@ -13,6 +13,9 @@ const EVENTS_HISTORY_FILE = process.env.EVENTS_BUS_DATA_DIR ? join(process.env.E
13
13
  function isPositiveInteger(candidate) {
14
14
  return typeof candidate === 'number' && Number.isInteger(candidate) && candidate > 0;
15
15
  }
16
+ function isTaskId(candidate) {
17
+ return candidate.length > 0;
18
+ }
16
19
  function isSafeRepositorySegment(segment) {
17
20
  return segment !== '.' && segment !== '..';
18
21
  }
@@ -261,11 +264,11 @@ export function serveDashboard(store, port = 8787, bus, refreshMs = 300000, jobI
261
264
  let result;
262
265
  if (body.action === 'create' && body.task && resolvedActions?.taskCreate)
263
266
  result = await resolvedActions.taskCreate(requestedJobId, body.task);
264
- else if (body.action === 'retry' && /^[A-Za-z0-9_-]+$/.test(requestedTaskId) && resolvedActions?.taskRetry)
267
+ else if (body.action === 'retry' && isTaskId(requestedTaskId) && resolvedActions?.taskRetry)
265
268
  result = await resolvedActions.taskRetry(requestedJobId, requestedTaskId);
266
- else if (body.action === 'cancel' && /^[A-Za-z0-9_-]+$/.test(requestedTaskId) && resolvedActions?.taskCancel)
269
+ else if (body.action === 'cancel' && isTaskId(requestedTaskId) && resolvedActions?.taskCancel)
267
270
  result = await resolvedActions.taskCancel(requestedJobId, requestedTaskId);
268
- else if (body.action === 'complete' && /^[A-Za-z0-9_-]+$/.test(requestedTaskId) && typeof body.summary === 'string' && body.summary.trim() && resolvedActions?.taskComplete)
271
+ else if (body.action === 'complete' && isTaskId(requestedTaskId) && typeof body.summary === 'string' && body.summary.trim() && resolvedActions?.taskComplete)
269
272
  result = await resolvedActions.taskComplete(requestedJobId, requestedTaskId, body.summary);
270
273
  else
271
274
  throw new Error('Task command unavailable');
@@ -288,7 +291,7 @@ export function serveDashboard(store, port = 8787, bus, refreshMs = 300000, jobI
288
291
  const requestedTaskId = url.searchParams.get('task') ?? '';
289
292
  const action = url.searchParams.get('action') ?? '';
290
293
  const handler = action === 'retry' ? resolvedActions?.taskRetry : action === 'cancel' ? resolvedActions?.taskCancel : undefined;
291
- if (req.method !== 'POST' || !/^[A-Za-z0-9_-]+$/.test(requestedJobId) || !/^[A-Za-z0-9_-]+$/.test(requestedTaskId) || !handler) {
294
+ if (req.method !== 'POST' || !/^[A-Za-z0-9_-]+$/.test(requestedJobId) || !isTaskId(requestedTaskId) || !handler) {
292
295
  res.writeHead(404);
293
296
  res.end('Task action unavailable');
294
297
  return;
@@ -339,7 +342,7 @@ export function serveDashboard(store, port = 8787, bus, refreshMs = 300000, jobI
339
342
  const requestedTaskId = url.searchParams.get('task') ?? '';
340
343
  const requestedState = url.searchParams.get('state') ?? '';
341
344
  const validState = ['DRAFT', 'QUEUED', 'RUNNING', 'BLOCKED', 'SUCCEEDED', 'FAILED', 'CANCELLED'].includes(requestedState);
342
- if (req.method !== 'POST' || !/^[A-Za-z0-9_-]+$/.test(requestedJobId) || !/^[A-Za-z0-9_-]+$/.test(requestedTaskId) || !validState || !resolvedActions?.taskSetState) {
345
+ if (req.method !== 'POST' || !/^[A-Za-z0-9_-]+$/.test(requestedJobId) || !isTaskId(requestedTaskId) || !validState || !resolvedActions?.taskSetState) {
343
346
  res.writeHead(404);
344
347
  res.end('Task state override unavailable');
345
348
  return;
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { runDaemon } from './relayd.js';
3
+ runDaemon(process.argv.slice(2)).catch(error => {
4
+ console.error(error instanceof Error ? error.message : String(error));
5
+ process.exitCode = 1;
6
+ });
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "agents-relay": "dist/cli.js",
8
- "agents-relayd": "dist/relayd.js"
8
+ "agents-relayd": "dist/relayd-main.js"
9
9
  },
10
10
  "scripts": {
11
- "build": "tsc -p tsconfig.json && chmod +x dist/cli.js dist/relayd.js",
11
+ "build": "tsc -p tsconfig.json && chmod +x dist/cli.js dist/relayd.js dist/relayd-main.js",
12
12
  "test": "npm run build && node --test test/*.test.js",
13
13
  "test:chatgpt-temp-quality": "AGENTS_RELAY_RUN_CHATGPT_TEMP_QUALITY=1 AGENTS_RELAY_CHATGPT_BROWSER_WORKER_AGENT=/Users/chengli/Workspace/neo/skills/chatgpt-browser-worker/agents/browser-worker.agent.md sh -c \"npm run build && node test/quality/run-temporary-chat.mjs\"",
14
14
  "dev": "tsx src/cli.ts",