agents-relay 2.0.250 → 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.
- package/README.md +8 -0
- package/dist/agent-shortcut.js +1 -1
- package/dist/cli-help.js +4 -7
- package/dist/cli-review.js +29 -12
- package/dist/interactive-invocation.js +15 -24
- package/dist/interactive-request.js +16 -40
- package/dist/reconciler-runtime.js +1 -1
- package/dist/reconciler.js +2 -2
- package/dist/relayd-control.js +5 -10
- package/dist/shortcut-node-worker.js +1 -1
- package/dist/shortcut-review-wake.js +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -19,6 +19,14 @@ Relay appends `--handoff-file`, optional `--on-needs-user-file`, and `--cwd`
|
|
|
19
19
|
without using a shell. No Neo executable is assumed. Missing/failed executors
|
|
20
20
|
produce `technical_failure` rather than silently resolving a blocker.
|
|
21
21
|
|
|
22
|
+
**Shortcut three-node L3 gate:** `npm run test:l3:shortcut` runs four isolated,
|
|
23
|
+
deterministic three-agent DAG scenarios: no review, sequential approvals,
|
|
24
|
+
Request Changes for a scripted node with a durable revision Worker, and
|
|
25
|
+
Request Changes for a model-only node with re-review. They exercise real
|
|
26
|
+
Shortcut CLI/SQLite/Git review identities and the real Reconciler with a
|
|
27
|
+
synthetic model adapter; no external model, iPhone, or production Job is used.
|
|
28
|
+
The gate is also included in `test:shortcut:dags` and `test:publish`.
|
|
29
|
+
|
|
22
30
|
**Interactive Review:** Relay owns the generic
|
|
23
31
|
`review.interactive.begin/wait/ready/fail/abort` lifecycle, immutable revision
|
|
24
32
|
binding and decision correlation. The caller (e.g. Neo's Markcut MCP wrapper)
|
package/dist/agent-shortcut.js
CHANGED
|
@@ -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] ||
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
package/dist/cli-review.js
CHANGED
|
@@ -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', '
|
|
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|
|
|
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 ||
|
|
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
|
|
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
|
-
|
|
51
|
-
|
|
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 || !
|
|
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
|
-
|
|
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
|
-
/**
|
|
97
|
-
export function eventOnlyReviewEligible(
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
19
|
-
|
|
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,18 +22,15 @@ 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 &&
|
|
31
|
-
(existing.status === 'changes_requested' || existing.status === 'awaiting_decision'))) {
|
|
32
|
-
// A new authoritative
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
invocationId = proposedId;
|
|
38
|
-
task.interactiveInvocation = { invocationId, executionId, revision: `pending:${invocationId}`,
|
|
28
|
+
(existing.status === 'changes_requested' || existing.status === 'awaiting_decision' || existing.status === 'approved'))) {
|
|
29
|
+
// A new authoritative execution can open the next Stage Preview after
|
|
30
|
+
// a prior approval, requested revision, or stale undelivered preview.
|
|
31
|
+
// The current execution guard prevents replacing an in-flight decision;
|
|
32
|
+
// historical decisions remain in the ledger and Task comments.
|
|
33
|
+
task.interactiveInvocation = { invocationId, executionId, revision: executionId,
|
|
39
34
|
status: 'awaiting_decision', boundAt: new Date().toISOString() };
|
|
40
35
|
task.updatedAt = new Date().toISOString();
|
|
41
36
|
}
|
|
@@ -44,16 +39,16 @@ export async function beginInteractiveReview(store, jobId, taskId, executionId)
|
|
|
44
39
|
}
|
|
45
40
|
return job;
|
|
46
41
|
});
|
|
47
|
-
return { jobId, taskId, executionId,
|
|
48
|
-
eventTemplate: interactiveTemplate(jobId, taskId, executionId
|
|
42
|
+
return { jobId, taskId, executionId, reused,
|
|
43
|
+
eventTemplate: interactiveTemplate(jobId, taskId, executionId) };
|
|
49
44
|
}
|
|
50
|
-
export async function abortInteractiveReview(store, jobId, taskId, executionId
|
|
45
|
+
export async function abortInteractiveReview(store, jobId, taskId, executionId) {
|
|
51
46
|
if (!store.mutateJob)
|
|
52
47
|
throw new Error('Interactive review requires durable mutation');
|
|
53
48
|
await store.mutateJob(jobId, job => {
|
|
54
49
|
const task = job.tasks.find(t => t.id === taskId);
|
|
55
50
|
if (task?.state === 'RUNNING' && task.executionId === executionId &&
|
|
56
|
-
task.interactiveInvocation?.
|
|
51
|
+
task.interactiveInvocation?.executionId === executionId &&
|
|
57
52
|
task.interactiveInvocation.status === 'awaiting_decision') {
|
|
58
53
|
task.interactiveInvocation = undefined;
|
|
59
54
|
task.updatedAt = new Date().toISOString();
|
|
@@ -61,33 +56,14 @@ export async function abortInteractiveReview(store, jobId, taskId, executionId,
|
|
|
61
56
|
return job;
|
|
62
57
|
});
|
|
63
58
|
}
|
|
64
|
-
export async function
|
|
65
|
-
if (!/^[a-f0-9]{40}$/.test(revision))
|
|
66
|
-
throw new Error('Immutable review revision must be full Git Commit SHA');
|
|
67
|
-
if (!store.mutateJob)
|
|
68
|
-
throw new Error('Interactive review requires durable mutation');
|
|
69
|
-
await store.mutateJob(jobId, job => {
|
|
70
|
-
const task = job.tasks.find(t => t.id === taskId);
|
|
71
|
-
const inv = task?.interactiveInvocation;
|
|
72
|
-
if (!task || task.state !== 'AWAITING_DECISION' || !inv || inv.executionId !== executionId ||
|
|
73
|
-
inv.invocationId !== invocationId || inv.status !== 'awaiting_decision')
|
|
74
|
-
throw new Error('Interactive review is not awaiting this execution/invocation');
|
|
75
|
-
if (inv.revision !== `pending:${invocationId}` && inv.revision !== revision)
|
|
76
|
-
throw new Error('Conflicting immutable review revision');
|
|
77
|
-
inv.revision = revision;
|
|
78
|
-
task.updatedAt = new Date().toISOString();
|
|
79
|
-
return job;
|
|
80
|
-
});
|
|
81
|
-
return { ready: true, invocationId, revision };
|
|
82
|
-
}
|
|
83
|
-
export async function failInteractiveReview(store, jobId, taskId, executionId, invocationId, reason) {
|
|
59
|
+
export async function failInteractiveReview(store, jobId, taskId, executionId, reason) {
|
|
84
60
|
if (!store.mutateJob)
|
|
85
61
|
throw new Error('Interactive review requires durable mutation');
|
|
86
62
|
let requeued = false;
|
|
87
63
|
await store.mutateJob(jobId, job => {
|
|
88
64
|
const task = job.tasks.find(t => t.id === taskId);
|
|
89
65
|
const inv = task?.interactiveInvocation;
|
|
90
|
-
if (!task || !inv || inv.executionId !== executionId || inv.
|
|
66
|
+
if (!task || !inv || inv.executionId !== executionId || inv.executionId !== executionId ||
|
|
91
67
|
inv.status !== 'awaiting_decision')
|
|
92
68
|
return job;
|
|
93
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
|
|
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
|
}
|
package/dist/reconciler.js
CHANGED
|
@@ -54,7 +54,7 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
54
54
|
return;
|
|
55
55
|
if (task.kind !== 'planner' && task.adapter !== 'orchestrator')
|
|
56
56
|
await this.launch(job, task);
|
|
57
|
-
}, context => `effect.launchTask:${context.jobId}:${context.taskId ?? 'task'}:${String(context.data?.attempt ?? 0)}`));
|
|
57
|
+
}, context => `effect.launchTask:${context.jobId}:${context.taskId ?? 'task'}:${String(context.data?.attempt ?? 0)}:${String(context.data?.reviewInvocationId ?? 'initial')}`));
|
|
58
58
|
this.workflowEffects.register(new CallbackWorkflowEffectHandler('effect.launchShortcut', async (context) => launchShortcutEffect(this.store, this.options, context.jobId, context.taskId, event => this.emit(event)), context => `effect.launchShortcut:${context.jobId}:${context.taskId ?? 'task'}:${String(context.data?.attempt ?? 0)}`));
|
|
59
59
|
this.workflowEffects.register(new CallbackWorkflowEffectHandler('effect.resumeShortcut', async (context) => resumeShortcutEffect(this.store, this.options, context.jobId, context.taskId, context.data, event => this.emit(event)), context => `effect.resumeShortcut:${context.jobId}:${context.taskId ?? 'task'}:${String(context.data?.executionId ?? '')}:${String(context.data?.nodeId ?? '')}:${String(context.data?.waitId ?? '')}`));
|
|
60
60
|
this.workflowEffects.register(new CallbackWorkflowEffectHandler('effect.cancelActiveTasks', async (context) => this.cancelActiveTasks(context.jobId, String(context.data?.reason ?? 'Job terminated'))));
|
|
@@ -83,7 +83,7 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
83
83
|
for (const task of dispatchable) {
|
|
84
84
|
const shortcut = task.result?.data?.shortcut;
|
|
85
85
|
await transitionTaskEvent(task, 'dispatch', { dispatchable: true, shortcutExecution: scheduled.executionMode === 'shortcut' && scheduled.contentOnly === true && shortcut?.workerFallback !== true && Boolean(task.agentGraph), shortcutFallback: shortcut?.workerFallback === true, shortcutHasGraph: Boolean(task.agentGraph) }, async (actionId) => {
|
|
86
|
-
const outcomes = await this.workflowEffects.execute([actionId], { jobId: scheduled.id, taskId: task.id, transitionKey: `dispatch:${task.attempt}`, data: { attempt: task.attempt } });
|
|
86
|
+
const outcomes = await this.workflowEffects.execute([actionId], { jobId: scheduled.id, taskId: task.id, transitionKey: `dispatch:${task.attempt}`, data: { attempt: task.attempt, ...(task.interactiveInvocation?.decidedAt ? { reviewInvocationId: task.interactiveInvocation.invocationId } : {}) } });
|
|
87
87
|
await this.applyTaskEffectOutcomes(scheduled, task, outcomes);
|
|
88
88
|
}, async () => { await this.store.saveTask(task); });
|
|
89
89
|
}
|
package/dist/relayd-control.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { submitTargetedRevisionRequest } from './review-revision-model.js';
|
|
2
|
-
import { beginInteractiveReview, abortInteractiveReview,
|
|
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
|
|
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?.
|
|
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?.
|
|
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,
|
|
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 && (
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "2.0.252",
|
|
4
4
|
"description": "Durable async agent jobs coordinated through GitHub pull requests",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"test": "npm run test:full",
|
|
17
17
|
"test:chatgpt-temp-quality": "AGENTS_RELAY_RUN_CHATGPT_TEMP_QUALITY=1 sh -c \"npm run build && node test/quality/run-temporary-chat.mjs\"",
|
|
18
18
|
"dev": "tsx src/cli.ts",
|
|
19
|
-
"test:publish": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 --test-force-exit test/*.test.js",
|
|
20
|
-
"test:shortcut
|
|
19
|
+
"test:publish": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 --test-force-exit test/*.test.js test/verification/l3-shortcut-review.test.mjs",
|
|
20
|
+
"test:l3:shortcut": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/verification/l3-shortcut-review.test.mjs",
|
|
21
|
+
"test:shortcut:dags": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/verification/shortcut-dag-matrix.test.mjs test/verification/l3-shortcut-review.test.mjs test/agent-shortcut.test.js",
|
|
21
22
|
"test:fast": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=2 test/workflow-lifecycle.test.js test/workflow-v2-lifecycle-parity.test.js test/workflow-effects.test.js test/relay-store.test.js test/local-authority.test.js test/local-jobid-routing.test.js test/interactive-request.test.js test/local-sqlite-jobid.test.js test/no-github.test.js test/reconcile-coordinator.test.js test/service-publication.test.js test/github-webhook.test.js test/verification/shortcut-dag-matrix.test.mjs",
|
|
22
23
|
"test:full": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/*.test.js test/verification/shortcut-dag-matrix.test.mjs && npm run test:verification:l3",
|
|
23
24
|
"test:verification:l1": "npm run build && node --test test/verification/harness.test.mjs test/verification/contract.test.mjs test/browser-worker-pool-graph.test.js test/verification/graph-inventory.test.mjs test/verification/dashboard-drilldown.test.mjs test/verification/evidence-matrix.test.mjs test/verification/task-resolution-classification.test.mjs test/verification/planner-contract.test.mjs test/verification/force-restate-validation.test.mjs test/planner-child-recovery.test.js",
|