agents-relay 2.0.213 → 2.0.215

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.
@@ -89,7 +89,7 @@ function shortcutJobCompletionAllowed(job) {
89
89
  async function runCommand(args, cwd, signal) {
90
90
  if (!Array.isArray(args) || args.length === 0 || args.some(item => typeof item !== 'string'))
91
91
  throw new Error('runCommand requires a non-empty argument array');
92
- const child = spawnOwnedProcess(args[0], args.slice(1), { invocation: 'shortcut.run-command', timeoutMs: 300_000, signal, spawn: { cwd, stdio: ['ignore', 'pipe', 'pipe'] } });
92
+ const child = spawnOwnedProcess(args[0], args.slice(1), { invocation: 'shortcut.run-command', signal, spawn: { cwd, stdio: ['ignore', 'pipe', 'pipe'] } });
93
93
  let stdout = '', stderr = '';
94
94
  child.stdout?.setEncoding('utf8');
95
95
  child.stderr?.setEncoding('utf8');
@@ -196,10 +196,8 @@ export async function runAgentShortcut(options) {
196
196
  throw new Error('Shortcut invocation Task snapshot is stale; reload the durable Task before execution or receipt consumption');
197
197
  if (currentJob.executionMode !== 'shortcut' || currentJob.contentOnly !== true)
198
198
  throw new Error('Shortcut execution requires durable shortcut and content-only Job policy');
199
- if (currentJob.shortcutExecutionDeadlineAt && !Number.isFinite(Date.parse(currentJob.shortcutExecutionDeadlineAt)))
200
- throw new Error('Shortcut execution budget metadata is invalid');
201
199
  if (currentJob.shortcutExecutionStartedAt && !Number.isFinite(Date.parse(currentJob.shortcutExecutionStartedAt)))
202
- throw new Error('Shortcut execution budget metadata is invalid');
200
+ throw new Error('Shortcut execution start metadata is invalid');
203
201
  const existingShortcut = currentTask.result?.data?.shortcut;
204
202
  if (existingShortcut?.workerFallback === true)
205
203
  throw new Error('Task is durably routed to the original Worker; shortcut execution is not authorized');
@@ -262,8 +260,6 @@ export async function runAgentShortcut(options) {
262
260
  t.leaseExpiresAt = new Date(Date.now() + leaseMs).toISOString();
263
261
  if (!fresh.shortcutExecutionStartedAt)
264
262
  fresh.shortcutExecutionStartedAt = new Date().toISOString();
265
- if (!fresh.shortcutExecutionDeadlineAt)
266
- fresh.shortcutExecutionDeadlineAt = new Date(Date.parse(fresh.shortcutExecutionStartedAt) + 20 * 60 * 1000).toISOString();
267
263
  t.executionHistory = [...(t.executionHistory ?? []), { id: t.executionId, attempt: t.attempt, startedAt: new Date().toISOString() }].slice(-8);
268
264
  return fresh;
269
265
  });
@@ -332,27 +328,16 @@ export async function runAgentShortcut(options) {
332
328
  if (Object.keys(state.nodes).length > Object.keys(checkpoint(currentTask).nodes).length)
333
329
  await persist(state);
334
330
  currentJob = await store.load(job.id);
335
- if (!currentJob.shortcutExecutionStartedAt)
336
- throw new Error('Direct shortcut Job has no durable first-execution timestamp; refusing to start or reset its budget');
337
- const startedAt = Date.parse(currentJob.shortcutExecutionStartedAt);
338
- const deadlineAt = currentJob.shortcutExecutionDeadlineAt ? Date.parse(currentJob.shortcutExecutionDeadlineAt) : startedAt + 20 * 60 * 1000;
339
- if (!Number.isFinite(startedAt) || !Number.isFinite(deadlineAt) || deadlineAt !== startedAt + 20 * 60 * 1000)
340
- throw new Error('Shortcut execution budget metadata is invalid');
341
- if (!currentJob.shortcutExecutionDeadlineAt) {
342
- await store.mutateJob(job.id, fresh => {
343
- if (fresh.shortcutExecutionStartedAt !== currentJob.shortcutExecutionStartedAt)
344
- throw new Error('Shortcut execution budget origin changed');
345
- fresh.shortcutExecutionDeadlineAt = new Date(deadlineAt).toISOString();
346
- return fresh;
347
- });
348
- }
331
+ // Keep the first execution timestamp for progress/optimization metrics only.
332
+ // Twenty minutes is an orchestrator target, never an execution deadline.
333
+ if (!currentJob.shortcutExecutionStartedAt || !Number.isFinite(Date.parse(currentJob.shortcutExecutionStartedAt)))
334
+ throw new Error('Direct shortcut Job has no durable first-execution timestamp');
349
335
  const executionAbort = new AbortController();
350
336
  const abortFromCaller = () => executionAbort.abort(options.signal?.reason ?? new Error('Shortcut execution interrupted'));
351
337
  if (options.signal?.aborted)
352
338
  abortFromCaller();
353
339
  else
354
340
  options.signal?.addEventListener('abort', abortFromCaller, { once: true });
355
- const budgetTimer = setTimeout(() => executionAbort.abort(new Error('Shortcut execution budget exceeded (20 minutes)')), Math.max(0, deadlineAt - Date.now()));
356
341
  let leaseHeartbeatError;
357
342
  let heartbeatInFlight = false;
358
343
  const heartbeat = setInterval(() => {
@@ -369,11 +354,9 @@ export async function runAgentShortcut(options) {
369
354
  }).catch(error => { leaseHeartbeatError = error; executionAbort.abort(error); }).finally(() => { heartbeatInFlight = false; });
370
355
  }, heartbeatMs);
371
356
  heartbeat.unref();
372
- const stopHeartbeat = () => { clearInterval(heartbeat); clearTimeout(budgetTimer); options.signal?.removeEventListener('abort', abortFromCaller); };
357
+ const stopHeartbeat = () => { clearInterval(heartbeat); options.signal?.removeEventListener('abort', abortFromCaller); };
373
358
  const emit = (event) => options.onNodeEvent?.({ ...event, timestamp: new Date().toISOString() });
374
359
  try {
375
- if (Date.now() >= deadlineAt)
376
- return await fail('Shortcut execution budget exceeded (20 minutes)');
377
360
  // The existing Graph executor owns node readiness for both code and model
378
361
  // nodes. Model nodes execute using Relay's existing durable Worker adapter,
379
362
  // never by routing the entire Agent Graph to one Worker.
@@ -527,9 +510,8 @@ export async function runAgentShortcut(options) {
527
510
  async function findTask() { const fresh = await store.load(job.id); const found = fresh.tasks.find(item => item.id === task.id); if (!found)
528
511
  throw new Error('Task disappeared'); return found; }
529
512
  async function fail(reason) {
530
- const timedOut = reason.includes('budget exceeded') || Date.now() >= deadlineAt;
531
- const interrupted = options.signal?.aborted === true && !timedOut;
532
- const failure = timedOut ? `Shortcut execution timed out after 20 minutes: ${reason}` : interrupted ? `Shortcut execution interrupted: ${reason}` : reason;
513
+ const interrupted = options.signal?.aborted === true;
514
+ const failure = interrupted ? `Shortcut execution interrupted: ${reason}` : reason;
533
515
  for (const nodeId of Object.keys(state.inFlight ?? {}))
534
516
  emit({ nodeId, type: 'failed', data: { executionId: currentTask.executionId, reason: failure } });
535
517
  stopHeartbeat();
@@ -541,7 +523,7 @@ export async function runAgentShortcut(options) {
541
523
  t.leaseExpiresAt = null;
542
524
  t.executionId = null;
543
525
  const prior = t.result ?? { summary: 'Shortcut execution failed', data: {} };
544
- t.result = { ...prior, summary: failure, data: { ...(prior.data ?? {}), shortcut: { ...state, terminal: { status: timedOut ? 'TIMED_OUT' : interrupted ? 'INTERRUPTED' : 'FAILED', reason: failure, at: new Date().toISOString(), executionId: currentTask.executionId } } } };
526
+ t.result = { ...prior, summary: failure, data: { ...(prior.data ?? {}), shortcut: { ...state, terminal: { status: interrupted ? 'INTERRUPTED' : 'FAILED', reason: failure, at: new Date().toISOString(), executionId: currentTask.executionId } } } };
545
527
  },
546
528
  });
547
529
  if (!result?.decision.accepted)
package/dist/cli-help.js CHANGED
@@ -102,7 +102,7 @@ When provided, --thread-id persists a reviewer destination; otherwise the Job re
102
102
  Managed host interaction (Node Wrapper normally calls these automatically):
103
103
  agents-relay review interactive begin --id JOB --task-id TASK --execution-id EXEC
104
104
  agents-relay review interactive wait --id JOB --task-id TASK --execution-id EXEC --invocation-id INV
105
- agents-relay review interactive ready --id JOB --task-id TASK --execution-id EXEC --invocation-id INV --revision SHA256
105
+ agents-relay review interactive ready --id JOB --task-id TASK --execution-id EXEC --invocation-id INV --revision GIT_COMMIT_SHA
106
106
  agents-relay review interactive fail --id JOB --task-id TASK --execution-id EXEC --invocation-id INV --reason REASON
107
107
  agents-relay review interactive abort --id JOB --task-id TASK --execution-id EXEC --invocation-id INV
108
108
  The CLI controls the running Relay daemon; this is not a separate Worker step.`,
@@ -22,8 +22,8 @@ export async function runInteractiveReviewCommand(argv) {
22
22
  if (action !== 'begin' && !invocationId)
23
23
  throw new Error('review interactive ' + action + ' requires --invocation-id');
24
24
  const revision = arg(args, '--revision');
25
- if (action === 'ready' && !/^[a-f0-9]{64}$/.test(revision))
26
- throw new Error('review interactive ready requires --revision SHA256');
25
+ if (action === 'ready' && !/^[a-f0-9]{40}$/.test(revision))
26
+ throw new Error('review interactive ready requires full 40-character Git Commit SHA');
27
27
  if (action === 'fail' && !arg(args, '--reason').trim())
28
28
  throw new Error('review interactive fail requires --reason');
29
29
  const body = { command: `review.interactive.${action}`, jobId, taskId, executionId };
@@ -54,11 +54,15 @@ export function normalizeInteractiveDecision(event) {
54
54
  return null;
55
55
  if (event.source?.id !== `job/${jobId}/task/${taskId}/execution/${executionId}`)
56
56
  return null;
57
- if (value.contentHash !== undefined && typeof value.feedback !== 'string')
58
- return null;
59
57
  const feedback = typeof value.feedback === 'string' ? value.feedback : null;
58
+ const commitSha = string('commitSha');
60
59
  const contentHash = string('contentHash');
61
- if (contentHash && contentHash !== revision)
60
+ if (commitSha) {
61
+ if (!/^[a-f0-9]{40}$/.test(commitSha) || revision !== commitSha ||
62
+ value.contentHash !== undefined || value.revisionId !== undefined || feedback === null)
63
+ return null;
64
+ }
65
+ else if (contentHash && (contentHash !== revision || feedback === null))
62
66
  return null;
63
67
  const comments = value.comments;
64
68
  if (comments !== undefined && (!Array.isArray(comments) || comments.length > 100 ||
@@ -68,6 +72,7 @@ export function normalizeInteractiveDecision(event) {
68
72
  return {
69
73
  jobId, taskId, executionId, invocationId, revision, decision,
70
74
  feedback: feedback ?? undefined,
75
+ commitSha: commitSha ?? undefined,
71
76
  contentHash: contentHash ?? undefined, revisionId: string('revisionId') ?? undefined,
72
77
  previewId: string('previewId') ?? undefined, requestId: string('requestId') ?? undefined,
73
78
  idempotencyKey: string('idempotencyKey') ?? undefined,
@@ -88,11 +93,12 @@ export function interactiveDecisionFingerprint(decision) {
88
93
  comments: decision.comments ?? null,
89
94
  })).digest('hex');
90
95
  }
91
- /** First event for an unbound interaction must carry immutable video identity. */
96
+ /** Event-only review identity is exactly one complete Git commit SHA. */
92
97
  export function eventOnlyReviewEligible(delivery) {
93
- return Boolean(delivery.contentHash && /^[a-f0-9]{64}$/.test(delivery.contentHash) &&
94
- delivery.revision === delivery.contentHash && delivery.feedback !== undefined &&
95
- [delivery.revisionId, delivery.requestId, delivery.idempotencyKey, delivery.invocationId]
98
+ return Boolean(delivery.commitSha && /^[a-f0-9]{40}$/.test(delivery.commitSha) &&
99
+ delivery.revision === delivery.commitSha && !delivery.contentHash && !delivery.revisionId &&
100
+ delivery.feedback !== undefined &&
101
+ [delivery.requestId, delivery.idempotencyKey, delivery.invocationId]
96
102
  .every(value => typeof value === 'string' && value.length > 0 && value.length <= 128));
97
103
  }
98
104
  function invocationState(invocation) {
@@ -57,8 +57,8 @@ export async function abortInteractiveReview(store, jobId, taskId, executionId,
57
57
  });
58
58
  }
59
59
  export async function readyInteractiveReview(store, jobId, taskId, executionId, invocationId, revision) {
60
- if (!/^[a-f0-9]{64}$/.test(revision))
61
- throw new Error('Immutable revision must be SHA-256');
60
+ if (!/^[a-f0-9]{40}$/.test(revision))
61
+ throw new Error('Immutable review revision must be full Git Commit SHA');
62
62
  if (!store.mutateJob)
63
63
  throw new Error('Interactive review requires durable mutation');
64
64
  await store.mutateJob(jobId, job => {
@@ -1,6 +1,7 @@
1
1
  import { mkdir, readFile } from 'node:fs/promises';
2
2
  import { dirname, isAbsolute, join, resolve } from 'node:path';
3
3
  import { createTaskEntity } from './workflow/entity-creation.js';
4
+ import { taskOverallTimeoutMs } from './types.js';
4
5
  /** A model node stays within its original Shortcut Job. Its durable child Task
5
6
  * uses the existing Relay Worker adapter, lifecycle Graph and Troubleshooter.
6
7
  * The parent Shortcut Graph, not the Worker Reconciler, selects DAG readiness. */
@@ -25,14 +26,11 @@ export async function runShortcutModelNode(options) {
25
26
  if (sourceRef && (!declaredRun || dirname(resolve(sourceRef)) !== resolve(runRoot)))
26
27
  throw new Error('Shortcut Worker source evidence is not confined to the declared canonical run');
27
28
  const outputPath = join(runRoot, '.shortcut-node-results', `${taskId}.json`);
29
+ // No wall-clock cutoff. Child Workers use their standard progress-renewed
30
+ // inactivity watchdog; the foreground Shortcut parent keeps its lease live.
28
31
  const started = initial.shortcutExecutionStartedAt && Date.parse(initial.shortcutExecutionStartedAt);
29
32
  if (!started || !Number.isFinite(started))
30
- throw new Error('Model node has no immutable Shortcut deadline origin');
31
- const deadline = started + 20 * 60_000;
32
- if (initial.shortcutExecutionDeadlineAt && Date.parse(initial.shortcutExecutionDeadlineAt) !== deadline)
33
- throw new Error('Model node deadline differs from the original execution budget');
34
- if (Date.now() >= deadline)
35
- throw new Error('Shortcut execution budget exceeded before model node dispatch');
33
+ throw new Error('Model node has no Shortcut start record');
36
34
  await mkdir(dirname(outputPath), { recursive: true, mode: 0o700 });
37
35
  await store.mutateJob(jobId, current => {
38
36
  const active = current.tasks.find(t => t.id === parentTaskId);
@@ -71,7 +69,7 @@ export async function runShortcutModelNode(options) {
71
69
  agentName: node.agent, dependencies: [], capabilities: ['model'], workerRequirements: { capabilities: ['model'] },
72
70
  adapter: 'codex', input: body, output: { kind: 'file', path: outputPath },
73
71
  attempt: 0, maxAttempts: 3, leaseOwner: null, leaseExpiresAt: null, executionId: null, threadId: null,
74
- result: null, error: null, timeoutMs: Math.max(1, deadline - Date.now()), createdAt: now, updatedAt: now,
72
+ result: null, error: null, timeoutMs: taskOverallTimeoutMs('L'), createdAt: now, updatedAt: now,
75
73
  }));
76
74
  }
77
75
  return current;
@@ -79,8 +77,6 @@ export async function runShortcutModelNode(options) {
79
77
  while (true) {
80
78
  if (node.signal.aborted)
81
79
  throw node.signal.reason ?? new Error('Shortcut Worker node interrupted');
82
- if (Date.now() >= deadline)
83
- throw new Error('Shortcut execution budget exceeded while waiting for model node');
84
80
  const current = await store.load(jobId);
85
81
  if (current.state !== 'ACTIVE' || current.pause)
86
82
  throw new Error('Shortcut Job cancelled/paused while Worker node was pending');
@@ -5,24 +5,17 @@ export async function driveShortcutWorkers(options) {
5
5
  const { store, jobId, reconciler, taskId } = options;
6
6
  if (!store.mutateJob)
7
7
  throw new Error('Foreground Worker fallback requires atomic Relay SQLite');
8
- const initial = await store.mutateJob(jobId, job => {
8
+ await store.mutateJob(jobId, job => {
9
9
  if (job.executionMode !== 'shortcut' || job.contentOnly !== true || job.state !== 'ACTIVE')
10
10
  throw new Error('Not an active Shortcut Job');
11
11
  if (!job.tasks.find(task => task.id === taskId))
12
12
  throw new Error('Shortcut parent Task missing');
13
- const now = Date.now();
14
13
  if (!job.shortcutExecutionStartedAt)
15
- job.shortcutExecutionStartedAt = new Date(now).toISOString();
16
- const first = Date.parse(job.shortcutExecutionStartedAt);
17
- if (!Number.isFinite(first))
14
+ job.shortcutExecutionStartedAt = new Date().toISOString();
15
+ if (!Number.isFinite(Date.parse(job.shortcutExecutionStartedAt)))
18
16
  throw new Error('Invalid original Shortcut start time');
19
- const deadline = new Date(first + 20 * 60_000).toISOString();
20
- if (job.shortcutExecutionDeadlineAt && job.shortcutExecutionDeadlineAt !== deadline)
21
- throw new Error('Shortcut deadline changed');
22
- job.shortcutExecutionDeadlineAt = deadline;
23
17
  return job;
24
18
  });
25
- const deadline = Date.parse(initial.shortcutExecutionDeadlineAt);
26
19
  const last = new Map();
27
20
  const stopWatching = await reconciler.watch(jobId);
28
21
  const observe = (job) => {
@@ -38,8 +31,6 @@ export async function driveShortcutWorkers(options) {
38
31
  while (true) {
39
32
  if (options.signal?.aborted)
40
33
  return { status: 'INTERRUPTED', job: await store.load(jobId) };
41
- if (Date.now() >= deadline)
42
- return { status: 'TIMED_OUT', job: await store.load(jobId) };
43
34
  await reconciler.reconcile(jobId);
44
35
  let job = await store.load(jobId);
45
36
  observe(job);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.213",
3
+ "version": "2.0.215",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",
@@ -161,6 +161,8 @@ A newly created zero-task DRAFT Job waits for explicit initial planning (`plan`
161
161
 
162
162
  ## Task evidence and head identity
163
163
 
164
+ For Git-versioned Neo Project Interactive Previews, bind a verified full 40-character Git Commit SHA as the sole review revision (`data.interactive.commitSha`, and `data.interactive.revision` must equal it). Compiled media cache hashes, legacy Markcut `revisionId` and `contentHash` must not be used as the Event Review identity. The Producer creates the Stage Commit before requesting Preview; Relay continues to own the decision and Task lifecycle. Generic non-video interactions are not made into Git commits by this contract.
165
+
164
166
  ### Canonical Neo Project runs boundary
165
167
 
166
168
  `runs/` is durable runtime evidence, not source code and not temporary checkout state. When a Task's declared file output is under `runs/`, that Task and every semantic descendant execute directly in the canonical resolved project directory. Agents Relay MUST NOT create or switch those Tasks into per-execution Git worktrees.