agents-relay 2.0.1 → 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 +8 -5
- package/package.json +1 -1
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' &&
|
|
267
|
+
else if (body.action === 'retry' && isTaskId(requestedTaskId) && resolvedActions?.taskRetry)
|
|
265
268
|
result = await resolvedActions.taskRetry(requestedJobId, requestedTaskId);
|
|
266
|
-
else if (body.action === 'cancel' &&
|
|
269
|
+
else if (body.action === 'cancel' && isTaskId(requestedTaskId) && resolvedActions?.taskCancel)
|
|
267
270
|
result = await resolvedActions.taskCancel(requestedJobId, requestedTaskId);
|
|
268
|
-
else if (body.action === 'complete' &&
|
|
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) ||
|
|
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) ||
|
|
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;
|