agents-relay 2.0.251 → 2.0.252

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.
@@ -234,7 +234,7 @@ export async function runAgentShortcut(options) {
234
234
  const pending = Object.entries(state.inFlight);
235
235
  const inv = currentTask.interactiveInvocation;
236
236
  if (pending.length !== 1 || !inv?.decidedAt || !['approved', 'changes_requested'].includes(inv.status) ||
237
- inv.executionId !== pending[0][1] || !/^[a-f0-9]{40}$/.test(inv.revision))
237
+ inv.executionId !== pending[0][1] || inv.revision !== inv.executionId)
238
238
  throw new Error('Shortcut checkpoint contains an interrupted module execution; refusing automatic replay');
239
239
  resumedReview = { nodeId: pending[0][0], status: inv.status,
240
240
  revision: inv.revision, invocationId: inv.invocationId, feedback: inv.feedback, comments: inv.comments };
package/dist/cli-help.js CHANGED
@@ -98,13 +98,10 @@ Usage: npx agents-relay review job --repo OWNER/REPO --id JOB_ID [--thread-id TH
98
98
 
99
99
  When provided, --thread-id persists a reviewer destination; otherwise the Job reviewer thread, then creator thread, then legacy review route is used. The command wakes Relay. Review Task creation, idempotency, routing and delivery remain graph/daemon-owned. Rejects in-flight/queued reviews; does not itself mark review delivered.
100
100
 
101
- Managed host interaction (Node Wrapper normally calls these automatically):
102
- agents-relay review interactive begin --id JOB --task-id TASK --execution-id EXEC
103
- agents-relay review interactive wait --id JOB --task-id TASK --execution-id EXEC --invocation-id INV
104
- agents-relay review interactive ready --id JOB --task-id TASK --execution-id EXEC --invocation-id INV --revision GIT_COMMIT_SHA
105
- agents-relay review interactive fail --id JOB --task-id TASK --execution-id EXEC --invocation-id INV --reason REASON
106
- agents-relay review interactive abort --id JOB --task-id TASK --execution-id EXEC --invocation-id INV
107
- The CLI controls the running Relay daemon; this is not a separate Worker step.`,
101
+ Worker-facing: agents-relay review interactive --path /absolute/file.md --id JOB --task-id TASK --execution-id EXEC
102
+ This calls Neo review.preview and requests exactly one human review for the current execution. No Git commit or extra invocation ID.
103
+ Internal Neo delivery: review interactive begin|wait|fail|abort with --id, --task-id and --execution-id; fail adds --reason.
104
+ Task AWAITING_DECISION resumes on an execution-bound Approve or Request Changes event.`,
108
105
  artifact: `Check a JSON artifact against a project-owned JSON Schema. Read-only; does not affect Task state or planning.
109
106
 
110
107
  Usage: agents-relay artifact validate --artifact PATH --schema PATH
@@ -1,6 +1,12 @@
1
1
  import { arg, hasArg, relayControlCommand } from './cli-support.js';
2
2
  import { normalizeThreadId } from './reviewer-thread.js';
3
3
  import { runOutcomeReview } from './outcome-review.js';
4
+ import { mkdtemp, writeFile, rm } from 'node:fs/promises';
5
+ import { tmpdir } from 'node:os';
6
+ import { join, isAbsolute } from 'node:path';
7
+ import { promisify } from 'node:util';
8
+ import { execFile } from 'node:child_process';
9
+ const execFileAsync = promisify(execFile);
4
10
  export function reviewRequestThreadOverride(args) {
5
11
  const values = [...args];
6
12
  return hasArg(values, '--thread-id')
@@ -10,27 +16,38 @@ export function reviewRequestThreadOverride(args) {
10
16
  /** Stable local CLI contract for a caller-supplied single-call interactive review tool. */
11
17
  export async function runInteractiveReviewCommand(argv) {
12
18
  const [action, ...args] = argv;
13
- const commands = ['begin', 'wait', 'ready', 'fail', 'abort'];
19
+ const commands = ['begin', 'wait', 'fail', 'abort'];
20
+ if (action === 'request' || action === '--path') {
21
+ const options = action === '--path' ? argv : ['request', ...args];
22
+ const flags = action === '--path' ? options : options.slice(1);
23
+ const path = arg(flags, '--path'), jobId = arg(flags, '--id'), taskId = arg(flags, '--task-id'), executionId = arg(flags, '--execution-id');
24
+ if (!path || !isAbsolute(path) || !jobId || !taskId || !executionId)
25
+ throw new Error('review interactive requires --path ABS --id JOB --task-id TASK --execution-id EXEC');
26
+ const dir = await mkdtemp(join(tmpdir(), 'relay-review-'));
27
+ try {
28
+ const file = join(dir, 'request.json');
29
+ await writeFile(file, JSON.stringify({ path, relay: { jobId, taskId, executionId } }), { mode: 0o600 });
30
+ const { stdout } = await execFileAsync('neo', ['mcp', 'call', 'review.preview', '--args-file', file], { timeout: 120000, maxBuffer: 1024 * 1024 });
31
+ const receipt = JSON.parse(stdout);
32
+ if (receipt?.isError === true || receipt?.result?.isError === true)
33
+ throw Error('Neo review.preview rejected: ' + JSON.stringify(receipt).slice(0, 600));
34
+ console.log(JSON.stringify(receipt));
35
+ }
36
+ finally {
37
+ await rm(dir, { recursive: true, force: true });
38
+ }
39
+ return;
40
+ }
14
41
  if (!action || !commands.includes(action))
15
- throw new Error('review interactive requires begin|wait|ready|fail|abort');
42
+ throw new Error('review interactive requires --path or begin|wait|fail|abort');
16
43
  const jobId = arg(args, '--id');
17
44
  const taskId = arg(args, '--task-id');
18
45
  const executionId = arg(args, '--execution-id');
19
- const invocationId = arg(args, '--invocation-id');
20
46
  if (!jobId || !taskId || !executionId)
21
47
  throw new Error('review interactive requires --id --task-id --execution-id');
22
- if (action !== 'begin' && !invocationId)
23
- throw new Error('review interactive ' + action + ' requires --invocation-id');
24
- const revision = arg(args, '--revision');
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
48
  if (action === 'fail' && !arg(args, '--reason').trim())
28
49
  throw new Error('review interactive fail requires --reason');
29
50
  const body = { command: `review.interactive.${action}`, jobId, taskId, executionId };
30
- if (action !== 'begin')
31
- body.invocationId = invocationId;
32
- if (action === 'ready')
33
- body.revision = revision;
34
51
  if (action === 'fail')
35
52
  body.reason = arg(args, '--reason');
36
53
  console.log(JSON.stringify(await relayControlCommand(args, body)));
@@ -23,7 +23,7 @@ export const interactiveInvocationGraph = new GraphRuntime(graphSource, {
23
23
  events: { 'task.interactive_decision': { id: 'task.interactive_decision' }, 'task.interactive_recover': { id: 'task.interactive_recover' } },
24
24
  });
25
25
  export function hostInteractiveDecisionEvent(context, feedback, receivedAt = new Date().toISOString()) {
26
- if (!feedback.eventId || !feedback.invocationId || !feedback.revision ||
26
+ if (!feedback.eventId ||
27
27
  !['approved', 'changes_requested'].includes(feedback.decision)) {
28
28
  throw new Error('Incomplete generic interactive decision');
29
29
  }
@@ -31,7 +31,7 @@ export function hostInteractiveDecisionEvent(context, feedback, receivedAt = new
31
31
  version: 1, event_id: feedback.eventId, job_id: context.jobId,
32
32
  task_id: context.taskId, parent_task_id: null, type: 'task.interactive_decision',
33
33
  status: 'running', timestamp: receivedAt, visibility: 'orchestrator', level: 'info',
34
- message: `Host interactive decision received for revision ${feedback.revision}`,
34
+ message: `Host interactive decision received for execution ${context.executionId}`,
35
35
  source: { id: `job/${context.jobId}/task/${context.taskId}/execution/${context.executionId}`, component: 'agents-relay' },
36
36
  data: { interactive: { ...context, ...feedback, eventId: undefined } },
37
37
  };
@@ -47,22 +47,20 @@ export function normalizeInteractiveDecision(event) {
47
47
  const jobId = string('jobId');
48
48
  const taskId = string('taskId');
49
49
  const executionId = string('executionId');
50
- const invocationId = string('invocationId');
51
- const revision = string('revision');
50
+ // The current Task execution is the sole review identity.
51
+ if (!executionId)
52
+ return null;
53
+ const invocationId = executionId;
54
+ const revision = executionId;
52
55
  const decision = value.decision === 'approved' || value.decision === 'changes_requested' ? value.decision : null;
53
- if (!jobId || !taskId || !executionId || !invocationId || !revision || !decision)
56
+ if (!jobId || !taskId || !executionId || !decision)
57
+ return null;
58
+ if (['invocationId', 'revision', 'commitSha', 'revisionId', 'contentHash'].some(key => Object.hasOwn(value, key)))
54
59
  return null;
55
60
  if (event.source?.id !== `job/${jobId}/task/${taskId}/execution/${executionId}`)
56
61
  return null;
57
62
  const feedback = typeof value.feedback === 'string' ? value.feedback : null;
58
- const commitSha = string('commitSha');
59
- const contentHash = string('contentHash');
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))
63
+ if (feedback === null)
66
64
  return null;
67
65
  const comments = value.comments;
68
66
  if (comments !== undefined && (!Array.isArray(comments) || comments.length > 100 ||
@@ -72,8 +70,6 @@ export function normalizeInteractiveDecision(event) {
72
70
  return {
73
71
  jobId, taskId, executionId, invocationId, revision, decision,
74
72
  feedback: feedback ?? undefined,
75
- commitSha: commitSha ?? undefined,
76
- contentHash: contentHash ?? undefined, revisionId: string('revisionId') ?? undefined,
77
73
  previewId: string('previewId') ?? undefined, requestId: string('requestId') ?? undefined,
78
74
  idempotencyKey: string('idempotencyKey') ?? undefined,
79
75
  comments: comments,
@@ -93,14 +89,8 @@ export function interactiveDecisionFingerprint(decision) {
93
89
  comments: decision.comments ?? null,
94
90
  })).digest('hex');
95
91
  }
96
- /** Event-only review identity is exactly one complete Git commit SHA. */
97
- export function eventOnlyReviewEligible(delivery) {
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]
102
- .every(value => typeof value === 'string' && value.length > 0 && value.length <= 128));
103
- }
92
+ /** Unbound event-only decisions cannot authorize a Task. */
93
+ export function eventOnlyReviewEligible(_delivery) { return false; }
104
94
  function invocationState(invocation) {
105
95
  return invocation?.status ?? 'awaiting_decision';
106
96
  }
@@ -159,11 +149,12 @@ export class HostInteractiveInvocationCoordinator {
159
149
  constructor(options) {
160
150
  this.options = options;
161
151
  }
162
- async bind(jobId, task, executionId, invocationId, revision) {
152
+ async bind(jobId, task, executionId) {
163
153
  if (task.state !== 'RUNNING')
164
154
  throw new Error(`Task ${task.id} must be RUNNING to bind an interactive invocation`);
165
155
  if (task.executionId !== executionId)
166
156
  throw new Error(`Task ${task.id} does not own execution ${executionId}`);
157
+ const invocationId = executionId, revision = executionId;
167
158
  const now = (this.options.now ?? (() => new Date()))().toISOString();
168
159
  const invocation = { invocationId, revision, executionId, status: 'awaiting_decision', boundAt: now };
169
160
  const boundJobId = task.jobId ?? jobId;
@@ -1,5 +1,3 @@
1
- /** Relay-owned admission/ready/failure for host-owned interactive review requests. */
2
- import { randomUUID } from 'node:crypto';
3
1
  import { tryTransitionTaskEvent } from './task-transitions.js';
4
2
  import { applyTaskUnblockRetrySnapshot } from './task-actions.js';
5
3
  import { appendTaskComment } from './task-comments.js';
@@ -8,15 +6,15 @@ import { eventFor } from './events.js';
8
6
  export function interactiveWaitingEvent(jobId, taskId, parentTaskId, executionId) {
9
7
  return eventFor(jobId, taskId, parentTaskId, 'task.interactive_waiting', 'waiting', 'Interactive review requested', 'orchestrator', {}, { id: `job/${jobId}/task/${taskId}/execution/${executionId}`, component: 'interactive-review' });
10
8
  }
11
- export function interactiveTemplate(jobId, taskId, executionId, invocationId) {
9
+ export function interactiveTemplate(jobId, taskId, executionId) {
12
10
  return { type: 'task.interactive_decision', source: `job/${jobId}/task/${taskId}/execution/${executionId}`,
13
- data: { interactive: { jobId, taskId, executionId, invocationId } } };
11
+ data: { interactive: { jobId, taskId, executionId } } };
14
12
  }
15
13
  export async function beginInteractiveReview(store, jobId, taskId, executionId) {
16
14
  if (!store.mutateJob)
17
15
  throw new Error('Interactive review requires atomic durable Job mutation');
18
- const proposedId = randomUUID();
19
- let invocationId = '';
16
+ // An execution owns at most one review. No separate review identity.
17
+ const invocationId = executionId;
20
18
  let reused = false;
21
19
  await store.mutateJob(jobId, (job) => {
22
20
  const task = job.tasks.find((item) => item.id === taskId);
@@ -24,7 +22,6 @@ export async function beginInteractiveReview(store, jobId, taskId, executionId)
24
22
  throw new Error('Interactive review requires current ACTIVE/RUNNING Task execution');
25
23
  const existing = task.interactiveInvocation;
26
24
  if (existing?.status === 'awaiting_decision' && existing.executionId === executionId) {
27
- invocationId = existing.invocationId;
28
25
  reused = true; // Wrapper rejects a second compile for this pending request.
29
26
  }
30
27
  else if (!existing || (existing.executionId !== executionId &&
@@ -33,8 +30,7 @@ export async function beginInteractiveReview(store, jobId, taskId, executionId)
33
30
  // a prior approval, requested revision, or stale undelivered preview.
34
31
  // The current execution guard prevents replacing an in-flight decision;
35
32
  // historical decisions remain in the ledger and Task comments.
36
- invocationId = proposedId;
37
- task.interactiveInvocation = { invocationId, executionId, revision: `pending:${invocationId}`,
33
+ task.interactiveInvocation = { invocationId, executionId, revision: executionId,
38
34
  status: 'awaiting_decision', boundAt: new Date().toISOString() };
39
35
  task.updatedAt = new Date().toISOString();
40
36
  }
@@ -43,16 +39,16 @@ export async function beginInteractiveReview(store, jobId, taskId, executionId)
43
39
  }
44
40
  return job;
45
41
  });
46
- return { jobId, taskId, executionId, invocationId, reused,
47
- eventTemplate: interactiveTemplate(jobId, taskId, executionId, invocationId) };
42
+ return { jobId, taskId, executionId, reused,
43
+ eventTemplate: interactiveTemplate(jobId, taskId, executionId) };
48
44
  }
49
- export async function abortInteractiveReview(store, jobId, taskId, executionId, invocationId) {
45
+ export async function abortInteractiveReview(store, jobId, taskId, executionId) {
50
46
  if (!store.mutateJob)
51
47
  throw new Error('Interactive review requires durable mutation');
52
48
  await store.mutateJob(jobId, job => {
53
49
  const task = job.tasks.find(t => t.id === taskId);
54
50
  if (task?.state === 'RUNNING' && task.executionId === executionId &&
55
- task.interactiveInvocation?.invocationId === invocationId &&
51
+ task.interactiveInvocation?.executionId === executionId &&
56
52
  task.interactiveInvocation.status === 'awaiting_decision') {
57
53
  task.interactiveInvocation = undefined;
58
54
  task.updatedAt = new Date().toISOString();
@@ -60,33 +56,14 @@ export async function abortInteractiveReview(store, jobId, taskId, executionId,
60
56
  return job;
61
57
  });
62
58
  }
63
- export async function readyInteractiveReview(store, jobId, taskId, executionId, invocationId, revision) {
64
- if (!/^[a-f0-9]{40}$/.test(revision))
65
- throw new Error('Immutable review revision must be full Git Commit SHA');
66
- if (!store.mutateJob)
67
- throw new Error('Interactive review requires durable mutation');
68
- await store.mutateJob(jobId, job => {
69
- const task = job.tasks.find(t => t.id === taskId);
70
- const inv = task?.interactiveInvocation;
71
- if (!task || task.state !== 'AWAITING_DECISION' || !inv || inv.executionId !== executionId ||
72
- inv.invocationId !== invocationId || inv.status !== 'awaiting_decision')
73
- throw new Error('Interactive review is not awaiting this execution/invocation');
74
- if (inv.revision !== `pending:${invocationId}` && inv.revision !== revision)
75
- throw new Error('Conflicting immutable review revision');
76
- inv.revision = revision;
77
- task.updatedAt = new Date().toISOString();
78
- return job;
79
- });
80
- return { ready: true, invocationId, revision };
81
- }
82
- export async function failInteractiveReview(store, jobId, taskId, executionId, invocationId, reason) {
59
+ export async function failInteractiveReview(store, jobId, taskId, executionId, reason) {
83
60
  if (!store.mutateJob)
84
61
  throw new Error('Interactive review requires durable mutation');
85
62
  let requeued = false;
86
63
  await store.mutateJob(jobId, job => {
87
64
  const task = job.tasks.find(t => t.id === taskId);
88
65
  const inv = task?.interactiveInvocation;
89
- if (!task || !inv || inv.executionId !== executionId || inv.invocationId !== invocationId ||
66
+ if (!task || !inv || inv.executionId !== executionId || inv.executionId !== executionId ||
90
67
  inv.status !== 'awaiting_decision')
91
68
  return job;
92
69
  if (task.state === 'AWAITING_DECISION') {
@@ -73,7 +73,7 @@ export class ReconcilerRuntimeBase {
73
73
  });
74
74
  }
75
75
  async applyHostInvocationEvent(event) { const result = await this.hostInvocations.applyEvent(event); const resumed = result.resumeWorker && result.decision ? await resumeInteractiveTask(this.store, result.decision.jobId, result.decision.taskId, result.decision.invocationId, result.decision.revision, result.decision.decision) : false; return { applied: result.outcome !== 'ignored', reconcile: resumed || result.outcome === 'accepted', reason: `task.interactive_decision.${result.outcome}` }; }
76
- bindInteractiveInvocation(jobId, task, executionId, invocationId, revision) { return this.hostInvocations.bind(jobId, task, executionId, invocationId, revision); }
76
+ bindInteractiveInvocation(jobId, task, executionId) { return this.hostInvocations.bind(jobId, task, executionId); }
77
77
  async applyJobEffectOutcomes(job, outcomes) {
78
78
  await applyJobEffectOutcomes(this.store, event => this.emit(event), job, outcomes);
79
79
  }
@@ -1,5 +1,5 @@
1
1
  import { submitTargetedRevisionRequest } from './review-revision-model.js';
2
- import { beginInteractiveReview, abortInteractiveReview, readyInteractiveReview, failInteractiveReview, interactiveWaitingEvent } from './interactive-request.js';
2
+ import { beginInteractiveReview, abortInteractiveReview, failInteractiveReview, interactiveWaitingEvent } from './interactive-request.js';
3
3
  import { localSourceHead, localWorkingHead } from './local-git-merge.js';
4
4
  import { appendTaskComment } from './task-comments.js';
5
5
  import { InMemoryStore } from './store.js';
@@ -81,23 +81,20 @@ export function createWorkspaceControl(deps) {
81
81
  if (command.startsWith('review.interactive.')) {
82
82
  const taskId = typeof body.taskId === 'string' ? body.taskId : '';
83
83
  const executionId = typeof body.executionId === 'string' ? body.executionId : '';
84
- const invocationId = typeof body.invocationId === 'string' ? body.invocationId : '';
85
84
  if (!taskId || !executionId)
86
85
  throw new Error('Interactive review requires taskId and executionId');
87
86
  if (command === 'review.interactive.begin')
88
87
  return await beginInteractiveReview(store, jobId, taskId, executionId);
89
- if (!invocationId)
90
- throw new Error('Interactive review requires invocationId');
91
88
  if (command === 'review.interactive.abort') {
92
- await abortInteractiveReview(store, jobId, taskId, executionId, invocationId);
89
+ await abortInteractiveReview(store, jobId, taskId, executionId);
93
90
  return { aborted: true };
94
91
  }
95
92
  if (command === 'review.interactive.wait') {
96
93
  const current = (await store.load(jobId)).tasks.find((t) => t.id === taskId);
97
- if (current?.state === 'AWAITING_DECISION' && current.interactiveInvocation?.invocationId === invocationId)
94
+ if (current?.state === 'AWAITING_DECISION' && current.interactiveInvocation?.executionId === executionId)
98
95
  return { waiting: true, taskState: 'AWAITING_DECISION' };
99
96
  if (current?.state !== 'RUNNING' || current.executionId !== executionId ||
100
- current.interactiveInvocation?.invocationId !== invocationId)
97
+ current.interactiveInvocation?.executionId !== executionId)
101
98
  throw new Error('Stale interactive waiting request');
102
99
  const reconciler = makeReconciler(store, concurrency);
103
100
  const event = interactiveWaitingEvent(jobId, taskId, current.parentTaskId, executionId);
@@ -119,10 +116,8 @@ export function createWorkspaceControl(deps) {
119
116
  await reconciler.close();
120
117
  }
121
118
  }
122
- if (command === 'review.interactive.ready')
123
- return await readyInteractiveReview(store, jobId, taskId, executionId, invocationId, typeof body.revision === 'string' ? body.revision : '');
124
119
  if (command === 'review.interactive.fail') {
125
- const result = await failInteractiveReview(store, jobId, taskId, executionId, invocationId, typeof body.reason === 'string' ? body.reason : 'Interactive review failed');
120
+ const result = await failInteractiveReview(store, jobId, taskId, executionId, typeof body.reason === 'string' ? body.reason : 'Interactive review failed');
126
121
  if (result.requeued)
127
122
  await pool.reconcileLocalJob(jobId, 'interactive.preview-failed');
128
123
  return result;
@@ -12,7 +12,7 @@ export async function runShortcutModelNode(options) {
12
12
  if (!/^[A-Za-z_][\w.-]*$/.test(node.id))
13
13
  throw new Error('Invalid shortcut model node ID');
14
14
  const review = node.reviewDecision;
15
- if (review && (!/^[a-f0-9]{40}$/.test(review.revision) || !/^[0-9a-f-]{36}$/i.test(review.invocationId)))
15
+ if (review && (review.revision !== review.invocationId))
16
16
  throw new Error('Invalid semantic Revision identity');
17
17
  const taskId = `shortcut-${parentTaskId}-${node.id}${review ? '-revision-' + review.invocationId : ''}`;
18
18
  const initial = await store.load(jobId);
@@ -18,7 +18,7 @@ export function eligibleShortcutReviewTask(job, taskId) {
18
18
  const cp = task.result?.data?.shortcut;
19
19
  const pending = Object.values(cp?.inFlight ?? {});
20
20
  if (pending.length !== 1 || !rev?.decidedAt || !['approved', 'changes_requested'].includes(rev.status) ||
21
- !/^[a-f0-9]{40}$/.test(rev.revision) || rev.executionId !== pending[0] || !rev.invocationId)
21
+ rev.revision !== rev.executionId || rev.executionId !== pending[0])
22
22
  return null;
23
23
  return task;
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.251",
3
+ "version": "2.0.252",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",