agents-relay 2.0.256 → 2.0.257

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.
Files changed (39) hide show
  1. package/README.md +26 -13
  2. package/dist/agent-script-discovery.js +56 -0
  3. package/dist/cli-coordinator.js +71 -0
  4. package/dist/cli-help.js +36 -30
  5. package/dist/cli-job-create.js +37 -4
  6. package/dist/cli.js +21 -12
  7. package/dist/dag-result-contract.js +2 -2
  8. package/dist/{shortcut-stage-contract.js → dag-stage-contract.js} +1 -1
  9. package/dist/dag-task-runtime.js +4 -33
  10. package/dist/dashboard-jel.js +8 -12
  11. package/dist/job-execution-slot.js +3 -11
  12. package/dist/pool.js +2 -13
  13. package/dist/reconciler.js +5 -28
  14. package/dist/relay-job-snapshot-reads.js +2 -5
  15. package/dist/relay-workflow-operations.js +2 -3
  16. package/dist/relayd-control.js +5 -0
  17. package/dist/relayd.js +1 -3
  18. package/dist/runtime-status.js +0 -33
  19. package/dist/script-task-adapter.js +2 -2
  20. package/dist/task-inactivity-watchdog.js +3 -6
  21. package/dist/worker-failure-recovery.js +1 -1
  22. package/dist/workflow/action-ledger.js +1 -1
  23. package/dist/workflow/contracts.js +0 -28
  24. package/dist/workflow/definitions-v2.js +1 -8
  25. package/dist/workflow/runtime.js +0 -9
  26. package/package.json +6 -6
  27. package/skills/agents-relay/SKILL.md +41 -20
  28. package/skills/agents-relay/contracts/event-contract.md +4 -5
  29. package/skills/agents-relay/contracts/task-job-contract.md +35 -1
  30. package/workflow/job-lifecycle.mmd +0 -8
  31. package/workflow/task-lifecycle.mmd +1 -26
  32. package/dist/agent-shortcut.js +0 -587
  33. package/dist/cli-shortcut-local.js +0 -50
  34. package/dist/cli-shortcut.js +0 -267
  35. package/dist/reconciler-shortcut.js +0 -74
  36. package/dist/shortcut-node-revision.js +0 -21
  37. package/dist/shortcut-node-worker.js +0 -144
  38. package/dist/shortcut-review-wake.js +0 -64
  39. package/dist/shortcut-worker-runner.js +0 -64
@@ -1,16 +1,8 @@
1
- /** A Coordinator is a durable Task but does not occupy a Worker execution slot.
2
- * Legacy delegated Shortcut Workers preserve their original foreground semantics. */
3
- function occupiesSlot(job, task) {
1
+ /** Coordinator Tasks hold no Worker slot. Actual Agent executions are leased. */
2
+ function occupiesSlot(_job, task) {
4
3
  if (task.agentGraph && task.result?.data?.dag?.version === 1)
5
4
  return false;
6
- const shortcut = task.result?.data?.shortcut;
7
- const delegatedWorker = job.executionMode === 'shortcut' && job.contentOnly === true && task.state === 'RUNNING'
8
- && shortcut && typeof shortcut === 'object'
9
- && Object.keys(shortcut.workerNodes ?? {}).length > 0;
10
- const durableWait = job.executionMode === 'shortcut' && job.contentOnly === true && task.state === 'RUNNING'
11
- && task.leaseOwner === null && shortcut && typeof shortcut === 'object'
12
- && Object.keys(shortcut.waits ?? {}).length > 0;
13
- return task.state !== 'AWAITING_DECISION' && !durableWait && !delegatedWorker &&
5
+ return task.state !== 'AWAITING_DECISION' &&
14
6
  (task.state === 'RUNNING' || (task.executionId !== null && !['SUCCEEDED', 'FAILED', 'CANCELLED'].includes(task.state)));
15
7
  }
16
8
  function plannerOccupies(job, planId) {
package/dist/pool.js CHANGED
@@ -76,19 +76,17 @@ export class RepositoryWorkerPool {
76
76
  makeReconciler;
77
77
  localInventory;
78
78
  resolveLocalJob;
79
- onShortcutDecision;
80
79
  running = false;
81
80
  pending = false;
82
81
  reconcileLocks = new Map();
83
82
  coordinator;
84
83
  dispatchTail = Promise.resolve();
85
84
  watchedBus;
86
- constructor(concurrency, makeReconciler, localInventory, resolveLocalJob, onShortcutDecision) {
85
+ constructor(concurrency, makeReconciler, localInventory, resolveLocalJob) {
87
86
  this.concurrency = concurrency;
88
87
  this.makeReconciler = makeReconciler;
89
88
  this.localInventory = localInventory;
90
89
  this.resolveLocalJob = resolveLocalJob;
91
- this.onShortcutDecision = onShortcutDecision;
92
90
  const reportCoordinatorError = (error, signal) => {
93
91
  observability().record({
94
92
  stage: 'reconcile', event: 'reconcile.coordinator_failed', level: 'error', outcome: 'failed',
@@ -178,12 +176,6 @@ export class RepositoryWorkerPool {
178
176
  if (signal.event.type === 'github.webhook')
179
177
  continue;
180
178
  const outcome = await reconciler.applyEvent(signal.event);
181
- // The decision is durably applied before invoking the Shortcut CLI hook.
182
- // A replay can also wake a still-QUEUED Task without a new decision.
183
- if (signal.event.type === 'task.interactive_decision' && !target.job.tasks.some(t => unifiedDAG(target.job, t)) &&
184
- ['task.interactive_decision.accepted', 'task.interactive_decision.duplicate'].includes(outcome.reason) &&
185
- await this.onShortcutDecision?.(jobId, signal.event.task_id))
186
- continue;
187
179
  shouldReconcile ||= outcome.reconcile;
188
180
  }
189
181
  if (shouldReconcile)
@@ -195,9 +187,6 @@ export class RepositoryWorkerPool {
195
187
  for (const job of jobs) {
196
188
  if (capacity <= 0)
197
189
  break;
198
- // Legacy in-flight Shortcut Jobs retain their original foreground owner.
199
- if (job.executionMode === 'shortcut' && !job.tasks.some(t => unifiedDAG(job, t)))
200
- continue;
201
190
  const store = await this.requireLocalStore(job.id);
202
191
  await store.hydrate?.(job);
203
192
  const ready = job.tasks.filter(task => (task.state === 'QUEUED' && task.executionId === null) || (task.state === 'DRAFT' && task.dependencies.length > 0)).length;
@@ -280,7 +269,7 @@ export class RepositoryWorkerPool {
280
269
  // GitHub transport is observational. It must never wake lifecycle execution.
281
270
  if (event.type === 'github.webhook')
282
271
  return;
283
- const wake = event.type === 'job.wake' || event.type === 'review.created' || event.type === 'planner.completed' || event.type === 'shortcut.result';
272
+ const wake = event.type === 'job.wake' || event.type === 'review.created' || event.type === 'planner.completed';
284
273
  if (!lifecycle && !wake)
285
274
  return;
286
275
  await this.coordinator.acceptTransport({
@@ -32,7 +32,6 @@ import { cleanupMergedJobWorktree } from './job-worktree-cleanup.js';
32
32
  import { jobHasConflictingExecution } from './job-execution-slot.js';
33
33
  import { requiresWorkerInactivityWatchdog } from './task-inactivity-watchdog.js';
34
34
  import { managedWorkerInput } from './managed-worker-input.js';
35
- import { launchShortcutEffect, resumeShortcutEffect, resumeShortcutEventWaits } from './reconciler-shortcut.js';
36
35
  export { managedWorkerInput } from './managed-worker-input.js';
37
36
  import { recoverExpiredExecutions, recoverStartupOrphans as recoverStartupExecutionOrphans } from './execution-recovery.js';
38
37
  import { dispatchJobReconcile } from './workflow/job-reconcile-v2.js';
@@ -57,15 +56,11 @@ export class Reconciler extends ReconcilerReviewBase {
57
56
  if (task.kind !== 'planner' && task.adapter !== 'orchestrator')
58
57
  await this.launch(job, task);
59
58
  }, context => `effect.launchTask:${context.jobId}:${context.taskId ?? 'task'}:${String(context.data?.attempt ?? 0)}:${String(context.data?.reviewInvocationId ?? 'initial')}`));
60
- 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)}`));
61
- 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 ?? '')}`));
62
59
  this.workflowEffects.register(new CallbackWorkflowEffectHandler('effect.cancelActiveTasks', async (context) => this.cancelActiveTasks(context.jobId, String(context.data?.reason ?? 'Job terminated'))));
63
60
  this.workflowEffects.register(new CallbackWorkflowEffectHandler('effect.cleanupJobWorktree', async (context) => cleanupMergedJobWorktree(await this.store.load(context.jobId), this.options.projectPathForJob), context => `effect.cleanupJobWorktree:${context.jobId}`));
64
61
  }
65
62
  async dispatchExecutableTasks(jobId) {
66
63
  const scheduled = refreshTaskDependencies(await this.store.load(jobId));
67
- if (scheduled.executionMode === 'shortcut' && !scheduled.tasks.some(t => unifiedDAG(scheduled, t)) && !this.options.shortcutRunnerOwner)
68
- return scheduled;
69
64
  if (scheduled.pause)
70
65
  return scheduled;
71
66
  for (const task of scheduled.tasks.filter(item => item.state === 'SUCCEEDED' && (item.continuation || scheduled.continuation) && !item.continuationDeliveredAt)) {
@@ -79,8 +74,7 @@ export class Reconciler extends ReconcilerReviewBase {
79
74
  const firstDAG = ready[0]?.dagNode?.parentTaskId;
80
75
  const dispatchable = (firstDAG ? ready.filter(t => t.dagNode?.parentTaskId === firstDAG) : ready.slice(0, 1)).slice(0, capacity);
81
76
  for (const task of dispatchable) {
82
- const shortcut = task.result?.data?.shortcut;
83
- await transitionTaskEvent(task, 'dispatch', { dispatchable: true, shortcutExecution: scheduled.executionMode === 'shortcut' && scheduled.contentOnly === true && shortcut?.workerFallback !== true && Boolean(task.agentGraph) && !unifiedDAG(scheduled, task), shortcutFallback: shortcut?.workerFallback === true, shortcutHasGraph: Boolean(task.agentGraph) }, async (actionId) => {
77
+ await transitionTaskEvent(task, 'dispatch', { dispatchable: true }, async (actionId) => {
84
78
  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 } : {}) } });
85
79
  await this.applyTaskEffectOutcomes(scheduled, task, outcomes);
86
80
  }, async () => { await this.store.saveTask(task); });
@@ -95,8 +89,6 @@ export class Reconciler extends ReconcilerReviewBase {
95
89
  let job = await this.store.load(jobId);
96
90
  // The same durable Job flag covers children, retries, and Troubleshooters.
97
91
  // Do not let a background Reconciler mutate or dispatch any of them.
98
- if (job.executionMode === 'shortcut' && !job.tasks.some(t => unifiedDAG(job, t)) && !this.options.shortcutRunnerOwner)
99
- return job;
100
92
  await drainProductionWorkflowOutbox(this.store, this.options);
101
93
  await deliverPendingEscalations(this.store, jobId, this.options.escalationNotifier);
102
94
  job = await this.store.load(jobId);
@@ -131,7 +123,6 @@ export class Reconciler extends ReconcilerReviewBase {
131
123
  await recoverExpiredExecutions(job, now, this.executionRecoveryPorts(job));
132
124
  await repairLegacyOrchestrators(jobId, now, { store: this.store, owner: this.options.owner, emit: event => this.emit(event) });
133
125
  await recoverInteractiveDecisions(this.store, jobId);
134
- await this.resumeShortcutEventWaits(jobId);
135
126
  await this.recoverPlannerChildren(job);
136
127
  await retryPendingPlannerUnblocks({
137
128
  store: this.store,
@@ -204,7 +195,7 @@ export class Reconciler extends ReconcilerReviewBase {
204
195
  scheduled = refreshTaskDependencies(await this.store.load(jobId));
205
196
  }
206
197
  scheduled = refreshTaskDependencies(await this.maybeCreatePlanner(scheduled));
207
- scheduled = refreshTaskDependencies(await reconcileDAGSchedule({ store: this.store, jobId, job: scheduled, projectPathForTask: async (j, t) => j.graphStartContext?.projectPath ?? j.shortcutRunnerContext?.projectPath ?? (this.options.projectPathForJob ? this.options.projectPathForJob(j, t) : t.routing?.cwd ?? process.cwd()), roots: this.options.executionContextRoots }));
198
+ scheduled = refreshTaskDependencies(await reconcileDAGSchedule({ store: this.store, jobId, job: scheduled, projectPathForTask: async (j, t) => j.graphStartContext?.projectPath ?? (this.options.projectPathForJob ? this.options.projectPathForJob(j, t) : t.routing?.cwd ?? process.cwd()), roots: this.options.executionContextRoots }));
208
199
  if (scheduled.state !== previousState || scheduled.updatedAt !== job.updatedAt)
209
200
  await this.store.saveJob(scheduled);
210
201
  scheduled = await this.dispatchExecutableTasks(jobId);
@@ -254,17 +245,6 @@ export class Reconciler extends ReconcilerReviewBase {
254
245
  this.reconciling = false;
255
246
  }
256
247
  }
257
- async resumeShortcutEventWaits(jobId) {
258
- await resumeShortcutEventWaits(this.store, this.options, jobId, async (job, task, matched) => {
259
- await transitionTaskEvent(task, 'shortcut.result', { shortcutResultCorrelated: true }, async (actionId) => {
260
- if (actionId !== 'effect.resumeShortcut')
261
- throw new Error(`Unexpected action ${actionId} for a correlated shortcut result`);
262
- const outcomes = await this.workflowEffects.execute([actionId], { jobId, taskId: task.id,
263
- transitionKey: `shortcut-result:${matched.executionId}:${matched.nodeId}:${matched.waitId}`, data: { ...matched } });
264
- await this.applyTaskEffectOutcomes(job, task, outcomes);
265
- }, async () => this.store.saveTask(task));
266
- }, event => this.emit(event));
267
- }
268
248
  async cancelActiveTasks(jobId, reason) {
269
249
  return cancelActiveTasks(this.store, jobId, reason, taskId => { const live = this.plannerLive.get(taskId); if (live) {
270
250
  clearTimeout(live.timer);
@@ -285,11 +265,10 @@ export class Reconciler extends ReconcilerReviewBase {
285
265
  emitFailed: async (task, reason) => { await this.emit(eventFor(job.id, task.id, task.parentTaskId, 'task.failed', 'failed', task.error ?? reason, 'user', { reason })); },
286
266
  };
287
267
  }
288
- async recoverLostExecutions(job, now) { if (job.executionMode !== 'shortcut' || job.tasks.some(t => unifiedDAG(job, t)) || this.options.shortcutRunnerOwner)
289
- await recoverExpiredExecutions(job, now, this.executionRecoveryPorts(job)); }
268
+ async recoverLostExecutions(job, now) { await recoverExpiredExecutions(job, now, this.executionRecoveryPorts(job)); }
290
269
  async recoverStartupOrphans(jobId) {
291
270
  const job = await this.store.load(jobId);
292
- if (job.state === 'ACTIVE' && (job.executionMode !== 'shortcut' || job.tasks.some(t => unifiedDAG(job, t)) || this.options.shortcutRunnerOwner === true)) {
271
+ if (job.state === 'ACTIVE') {
293
272
  await recoverStartupExecutionOrphans(job, this.executionRecoveryPorts(job));
294
273
  }
295
274
  return this.store.load(jobId);
@@ -305,8 +284,6 @@ export class Reconciler extends ReconcilerReviewBase {
305
284
  // Terminal Jobs can repair projections and re-review, but must not reopen planning.
306
285
  if (job.state !== 'ACTIVE')
307
286
  return job;
308
- if (job.executionMode === 'shortcut')
309
- return job;
310
287
  const pending = pendingPlan(job);
311
288
  const recoverable = pending && !this.plannerLive.has(pending.id)
312
289
  && (!pending.executionId || pending.leaseOwner !== this.options.owner || !pending.leaseExpiresAt || Date.parse(pending.leaseExpiresAt) <= (this.options.now ?? new Date()).getTime())
@@ -463,7 +440,7 @@ export class Reconciler extends ReconcilerReviewBase {
463
440
  let executionContext;
464
441
  try {
465
442
  const role = isFinalReviewAgent(task.agentName) ? 'reviewer' : task.agentName === 'troubleshooter' ? 'troubleshooter' : task.parentTaskId ? 'nested-worker' : 'worker';
466
- const projectPath = task.dagNode && (job.graphStartContext?.projectPath ?? job.shortcutRunnerContext?.projectPath) ? (job.graphStartContext?.projectPath ?? job.shortcutRunnerContext.projectPath) : this.options.projectPathForJob ? await this.options.projectPathForJob(job, task) : task.routing?.cwd ?? process.cwd();
443
+ const projectPath = task.dagNode && job.graphStartContext?.projectPath ? job.graphStartContext.projectPath : this.options.projectPathForJob ? await this.options.projectPathForJob(job, task) : task.routing?.cwd ?? process.cwd();
467
444
  executionContext = await this.resolvedContext(job, task, role, projectPath);
468
445
  }
469
446
  catch (error) {
@@ -1,11 +1,8 @@
1
1
  import { normalizeLegacyTaskLifecycle } from './types.js';
2
2
  import { normalizeLegacyJobPrNumber } from './job-pr-number-migration.js';
3
3
  export function currentJobMetadata(job) {
4
- // Retired historical modes must not survive reads or writes. Only the
5
- // supported opt-in Direct Shortcut mode is part of the active Job contract.
6
- const { schedule: _schedule, executionMode, ...current } = job;
7
- return (executionMode === 'shortcut'
8
- ? { ...current, executionMode: 'shortcut' } : current);
4
+ const { schedule: _schedule, executionMode: _executionMode, contentOnly: _contentOnly, shortcutExecutionStartedAt: _shortcutStarted, shortcutRunnerContext: _shortcutContext, shortcutExecutionDeadlineAt: _shortcutDeadline, ...current } = job;
5
+ return current;
9
6
  }
10
7
  export function normalizeRelayJob(json) {
11
8
  const job = currentJobMetadata(normalizeLegacyJobPrNumber(JSON.parse(json)));
@@ -85,11 +85,10 @@ export class SQLiteWorkflowOperations {
85
85
  throw new Error('authoritative job snapshot unavailable');
86
86
  const job = JSON.parse(row.json);
87
87
  const task = job.tasks.find(item => item.id === identity.taskId);
88
- const shortcut = task?.result?.data?.shortcut;
89
- const decision = dispatchWorkflowGraphSync(taskLifecycleV2, { initialState: 'QUEUED', input: { transport: 'event', id: 'dispatch', payload: {} }, durableFacts: { dispatchable: true, shortcutExecution: job.executionMode === 'shortcut' && job.contentOnly === true && shortcut?.workerFallback !== true && Boolean(task?.agentGraph), shortcutFallback: shortcut?.workerFallback === true, shortcutHasGraph: Boolean(task?.agentGraph), shortcutDirectInvocation: job.executionMode === 'shortcut' && job.contentOnly === true } });
88
+ const decision = dispatchWorkflowGraphSync(taskLifecycleV2, { initialState: 'QUEUED', input: { transport: 'event', id: 'dispatch', payload: {} }, durableFacts: { dispatchable: true } });
90
89
  if (!decision.accepted)
91
90
  throw new Error('canonical Task Graph did not authorize launch');
92
- const actionId = decision.actions.find(action => action.id === 'effect.launchTask' || action.id === 'effect.launchShortcut')?.id;
91
+ const actionId = decision.actions.find(action => action.id === 'effect.launchTask')?.id;
93
92
  if (!actionId)
94
93
  throw new Error('canonical Task Graph did not authorize launch');
95
94
  return new WorkflowActionLedger(this.db).reserveForClaimedDispatch({
@@ -27,6 +27,8 @@ export function createWorkspaceControl(deps) {
27
27
  throw new Error('job.create requires repository');
28
28
  if ('schedule' in options)
29
29
  throw new Error('Job schedules are unsupported');
30
+ if (options.coordinator && body.initialPlan === true)
31
+ throw Error('Coordinator Job must not request an initial Planner');
30
32
  const result = await ensureManagedGitHubJob(client, repository, trusted, {
31
33
  id: typeof options.id === 'string' && options.id ? options.id : undefined,
32
34
  idempotencyKey: typeof options.idempotencyKey === 'string' ? options.idempotencyKey : undefined,
@@ -42,6 +44,7 @@ export function createWorkspaceControl(deps) {
42
44
  creatorThreadId: typeof options.creatorThreadId === 'string' ? options.creatorThreadId : undefined,
43
45
  implementationThreadId: typeof options.implementationThreadId === 'string' ? options.implementationThreadId : undefined,
44
46
  noGitHub,
47
+ coordinator: options.coordinator,
45
48
  persist: body.initialPlan !== true,
46
49
  });
47
50
  if (!repositories.includes(repository))
@@ -73,6 +76,8 @@ export function createWorkspaceControl(deps) {
73
76
  await reconciler.close();
74
77
  }
75
78
  }
79
+ if (options.coordinator)
80
+ return { repository, pr: result.pr.number, job: result.job.id, state: result.job.state, taskId: 'coordinator' };
76
81
  return { repository, pr: result.pr.number, job: result.job.id, state: result.job.state };
77
82
  }
78
83
  if (!jobId)
package/dist/relayd.js CHANGED
@@ -10,7 +10,6 @@ import { ZAdapter } from './z-adapter.js';
10
10
  import { CodexThreadContinuation, CommandContinuation, WebhookContinuation } from './continuation.js';
11
11
  import { serveDashboard } from './dashboard.js';
12
12
  import { RepositoryWorkerPool } from './pool.js';
13
- import { createShortcutReviewWake } from './shortcut-review-wake.js';
14
13
  import { Reconciler } from './reconciler.js';
15
14
  import { dashboardManagedJobs, GitHubStore, InMemoryStore, resolvePullRequest } from './store.js';
16
15
  import { GitHubProjectionWriter } from './projected-store.js';
@@ -392,8 +391,7 @@ export async function runDaemon(argv) {
392
391
  })();
393
392
  return githubBindingSyncInFlight;
394
393
  };
395
- const shortcutReviewWake = createShortcutReviewWake(async (jobId) => (await localJobBinding(jobId))?.job ?? null);
396
- const pool = new RepositoryWorkerPool(concurrency, makeReconciler, inventoryFromLocal, localJobBinding, shortcutReviewWake);
394
+ const pool = new RepositoryWorkerPool(concurrency, makeReconciler, inventoryFromLocal, localJobBinding);
397
395
  const initial = cachedOverviews;
398
396
  const fallback = initial[0]?.job;
399
397
  const dashboardStore = fallback ? (await requireLocalJobBinding(fallback.id)).store : new InMemoryStore();
@@ -36,39 +36,6 @@ export function deriveJobRuntimeStatus(job, _prState = 'OPEN') {
36
36
  return 'COMPLETED';
37
37
  if (job.state === 'DRAFT')
38
38
  return 'IDLE';
39
- // A Shortcut Job is owned by an external foreground runner, not the Relay
40
- // scheduler queue. Do not advertise a not-yet-invoked Shortcut as QUEUED,
41
- // or a content-only Shortcut as pending a PR merge/review.
42
- if (job.executionMode === 'shortcut' && job.contentOnly === true) {
43
- const now = Date.now();
44
- const hasLiveLease = (task) => task.state === 'RUNNING'
45
- && Boolean(task.executionId && task.leaseOwner && task.leaseExpiresAt)
46
- && Number.isFinite(Date.parse(task.leaseExpiresAt)) && Date.parse(task.leaseExpiresAt) > now;
47
- const children = job.tasks.filter(task => task.parentTaskId !== null);
48
- if (children.some(task => task.state === 'BLOCKED') && !children.some(hasLiveLease))
49
- return 'BLOCKED';
50
- if (children.some(task => task.state === 'FAILED') && !children.some(hasLiveLease))
51
- return 'FAILED';
52
- if (job.tasks.some(task => task.state === 'FAILED') && !job.tasks.some(hasLiveLease))
53
- return 'FAILED';
54
- if (job.pause)
55
- return 'WAITING';
56
- if (job.tasks.some(task => task.state === 'AWAITING_DECISION'))
57
- return 'WAITING';
58
- if (job.tasks.some(hasLiveLease))
59
- return 'RUNNING';
60
- const running = job.tasks.filter(task => task.state === 'RUNNING');
61
- // WAITING_EVENT intentionally releases the runner lease but keeps the Task
62
- // RUNNING until its correlated event receipt arrives.
63
- if (running.some(task => task.leaseOwner === null && Boolean(task.executionId)
64
- && Object.values(task.result?.data?.shortcut?.waits ?? {})
65
- .some(wait => wait.executionId === task.executionId)))
66
- return 'WAITING';
67
- // A RUNNING Task without a current lease or event wait is not executing.
68
- if (running.length > 0)
69
- return 'BLOCKED';
70
- return 'WAITING'; // External Shortcut Runner has not started or needs a resume.
71
- }
72
39
  // A DAG Coordinator is not a leased worker. Human review waiting takes
73
40
  // precedence unless another Agent Task is genuinely running.
74
41
  if (job.tasks.some(t => t.state === 'AWAITING_DECISION') &&
@@ -5,7 +5,7 @@ import { mkdir, writeFile } from 'node:fs/promises';
5
5
  import { pathToFileURL } from 'node:url';
6
6
  import { eventFor } from './events.js';
7
7
  import { executionEventSource } from './execution-event-identity.js';
8
- import { discoverShortcut } from './agent-shortcut.js';
8
+ import { discoverScriptAgent } from './agent-script-discovery.js';
9
9
  import { spawnOwnedProcess } from './owned-process.js';
10
10
  const valid = (value) => {
11
11
  if (!value || typeof value !== 'object' || Array.isArray(value))
@@ -75,7 +75,7 @@ export class ScriptTaskAdapter {
75
75
  const projectPath = context.executionContext?.project.path ?? input.projectPath;
76
76
  if (typeof projectPath !== 'string' || !isAbsolute(projectPath))
77
77
  throw Error('No trusted Script Project context');
78
- const script = await discoverShortcut(task.agentName, projectPath, this.roots.sharedRoot ?? undefined, this.roots.workspaceRoot ?? undefined, this.roots.globalRoot ?? undefined);
78
+ const script = await discoverScriptAgent(task.agentName, projectPath, this.roots.sharedRoot ?? undefined, this.roots.workspaceRoot ?? undefined, this.roots.globalRoot ?? undefined);
79
79
  if (!script)
80
80
  throw Error(`Declared Agent Shortcut is unavailable: ${task.agentName}`);
81
81
  await send('task.started', 'running', 'Script Worker started');
@@ -1,10 +1,7 @@
1
1
  import { executionEventSource, eventSourceId } from './execution-event-identity.js';
2
- /** A foreground Shortcut Graph parent is not a Worker: its elapsed budget
3
- * belongs to the direct runner. Real Worker child Tasks keep standard timeouts. */
4
- export function requiresWorkerInactivityWatchdog(job, task) {
5
- const shortcut = task.result?.data?.shortcut;
6
- return !(job.executionMode === 'shortcut' && job.contentOnly === true
7
- && Boolean(task.agentGraph) && shortcut?.workerFallback !== true);
2
+ /** A Coordinator has no Worker execution; Agent Tasks retain all watchdogs. */
3
+ export function requiresWorkerInactivityWatchdog(_job, task) {
4
+ return !(task.agentGraph && task.executionId === null);
8
5
  }
9
6
  export function isRecoverableWatchdogFailure(task) {
10
7
  if (['worker_start_timeout', 'terminal_event_timeout', 'worker_exit_before_start', 'worker_exit_without_terminal_event', 'worker_delivery_after_start'].includes(task.failureReason ?? ''))
@@ -16,7 +16,7 @@ export async function handleWorkerLaunchFailure(ports, jobId, taskId, executionI
16
16
  && currentTask.executionId === executionId
17
17
  && !currentTask.lastProgressEventAt
18
18
  && !activeExecution?.workerStarted;
19
- const canRetryNoStart = noStarted && currentJob.executionMode !== 'shortcut'
19
+ const canRetryNoStart = noStarted
20
20
  && (currentTask?.adapter === 'chatgpt' || currentTask?.adapter === 'z')
21
21
  && !isFinalReviewAgent(currentTask.agentName)
22
22
  && currentTask.agentName !== 'troubleshooter' && currentTask.kind !== 'planner'
@@ -50,7 +50,7 @@ export class WorkflowActionLedger {
50
50
  * execution lease; task.started later transitions it to RUNNING. */
51
51
  reserveForClaimedDispatch(identity, decision, conditionId) {
52
52
  if (!decision.accepted || decision.source !== 'QUEUED' || decision.target !== 'QUEUED'
53
- || !['effect.launchTask', 'effect.launchShortcut'].includes(identity.actionId))
53
+ || identity.actionId !== 'effect.launchTask')
54
54
  throw Error('dispatch reservation requires canonical QUEUED Graph launch decision');
55
55
  return this.reserveForRunningTask(identity, decision, conditionId, new Date().toISOString(), 'QUEUED');
56
56
  }
@@ -39,13 +39,6 @@ export const WORKFLOW_EVENT_NAMES = [
39
39
  'task.failed',
40
40
  'task.progress',
41
41
  'task.started',
42
- 'shortcut.waiting',
43
- 'shortcut.completed',
44
- 'content.completed',
45
- 'shortcut.failed',
46
- 'shortcut.result',
47
- 'effect.launchShortcut.failed',
48
- 'effect.resumeShortcut.failed',
49
42
  'task.unblocked',
50
43
  'watchdog.failed',
51
44
  'worker.delivery_failed',
@@ -58,12 +51,7 @@ export const WORKFLOW_FACT_NAMES = [
58
51
  'dependenciesUnsatisfied',
59
52
  'runnable',
60
53
  'dispatchable',
61
- 'shortcutExecution',
62
- 'shortcutFallback',
63
- 'shortcutHasGraph',
64
- 'shortcutDirectInvocation',
65
54
  'shortcutEffectsSafe',
66
- 'shortcutResultCorrelated',
67
55
  'notMerged',
68
56
  'autoMerge',
69
57
  'recoverableExecution',
@@ -88,16 +76,12 @@ export const WORKFLOW_MUTATION_NAMES = [
88
76
  'mutation.markStartupOrphanedExhausted',
89
77
  'mutation.markUnknownOutcome',
90
78
  'mutation.markPlannerUnavailable',
91
- 'mutation.markShortcutWorkerFallback',
92
- 'mutation.markShortcutRecoveryRequired',
93
79
  'mutation.preparePlatformFallback',
94
80
  'mutation.prepareNoStartFallback',
95
81
  'mutation.quarantinePlatformFailure',
96
82
  ];
97
83
  export const WORKFLOW_EFFECT_NAMES = [
98
84
  'effect.launchTask',
99
- 'effect.launchShortcut',
100
- 'effect.resumeShortcut',
101
85
  'effect.cancelActiveTasks',
102
86
  'effect.mergePullRequest',
103
87
  'effect.deliverLocalMerge',
@@ -110,18 +94,6 @@ export const WORKFLOW_EFFECT_POLICIES = {
110
94
  retry: 'workflow',
111
95
  observability: 'workflow.effect',
112
96
  },
113
- 'effect.launchShortcut': {
114
- idempotency: 'job-task-attempt',
115
- failureEvent: 'effect.launchShortcut.failed',
116
- retry: 'workflow',
117
- observability: 'workflow.effect',
118
- },
119
- 'effect.resumeShortcut': {
120
- idempotency: 'job-task-attempt',
121
- failureEvent: 'effect.resumeShortcut.failed',
122
- retry: 'workflow',
123
- observability: 'workflow.effect',
124
- },
125
97
  'effect.cancelActiveTasks': {
126
98
  idempotency: 'job-transition',
127
99
  failureEvent: 'effect.cancelActiveTasks.failed',
@@ -5,7 +5,7 @@ import { WORKFLOW_EFFECT_NAMES, WORKFLOW_EVENT_NAMES, WORKFLOW_MUTATION_NAMES, }
5
5
  const TASK_STATES = ['DRAFT', 'QUEUED', 'RUNNING', 'AWAITING_DECISION', 'BLOCKED', 'SUCCEEDED', 'FAILED', 'CANCELLED'];
6
6
  const JOB_STATES = ['DRAFT', 'ACTIVE', 'COMPLETED', 'CANCELLED'];
7
7
  const conditionRegistry = new ConditionRegistry([
8
- ...new Set(['dependenciesSatisfied', 'dependenciesUnsatisfied', 'runnable', 'dispatchable', 'recoverableExecution', 'troubleshooterRecovery', 'troubleshooterTask', 'awaitingInteractiveDecision', 'retryAvailable', 'notMerged', 'autoMerge', 'prOpen', 'reviewDisabled', 'implementationComplete', 'headAvailable', 'mergeCapable', 'localCompletionAllowed', 'localMergeReady', 'shortcutCompletionAllowed', 'contentCompletionAllowed'])
8
+ ...new Set(['dependenciesSatisfied', 'dependenciesUnsatisfied', 'runnable', 'dispatchable', 'recoverableExecution', 'troubleshooterRecovery', 'troubleshooterTask', 'awaitingInteractiveDecision', 'retryAvailable', 'notMerged', 'autoMerge', 'prOpen', 'reviewDisabled', 'implementationComplete', 'headAvailable', 'mergeCapable', 'localCompletionAllowed', 'localMergeReady'])
9
9
  ].map(booleanCondition));
10
10
  const boolGuard = (name) => conditionRegistry.guard(name);
11
11
  export const lifecycleConditions = conditionRegistry;
@@ -29,12 +29,7 @@ export const taskLifecycleV2 = load('task-lifecycle', TASK_STATES, {
29
29
  dependenciesUnsatisfied: boolGuard('dependenciesUnsatisfied'),
30
30
  runnable: boolGuard('runnable'),
31
31
  dispatchable: boolGuard('dispatchable'),
32
- shortcutExecution: facts => facts.durableFacts.shortcutExecution === true,
33
- shortcutFallback: facts => facts.durableFacts.shortcutFallback === true,
34
- shortcutHasGraph: facts => facts.durableFacts.shortcutHasGraph === true,
35
- shortcutDirectInvocation: facts => facts.durableFacts.shortcutDirectInvocation === true,
36
32
  shortcutEffectsSafe: facts => facts.durableFacts.shortcutEffectsSafe === true,
37
- shortcutResultCorrelated: facts => facts.durableFacts.shortcutResultCorrelated === true,
38
33
  recoverableExecution: boolGuard('recoverableExecution'),
39
34
  troubleshooterRecovery: boolGuard('troubleshooterRecovery'),
40
35
  troubleshooterTask: boolGuard('troubleshooterTask'),
@@ -63,8 +58,6 @@ export const jobLifecycleV2 = load('job-lifecycle', JOB_STATES, {
63
58
  && values.reviewSatisfied === true && values.localMergePresent === true
64
59
  && values.reviewHeadCurrent === true && values.mergeAttemptReady === true;
65
60
  },
66
- shortcutCompletionAllowed: facts => facts.durableFacts.shortcutCompletionAllowed === true,
67
- contentCompletionAllowed: facts => facts.durableFacts.contentCompletionAllowed === true,
68
61
  });
69
62
  function topologyTargets(graph, from) {
70
63
  const source = [...graph.nodes.values()].find(node => node.kind === 'state' && node.semanticId === from);
@@ -38,15 +38,6 @@ export function applyTaskMutation(task, mutation) {
38
38
  }
39
39
  if (mutation === 'mutation.markPlannerUnavailable')
40
40
  task.error = 'No objective planner configured';
41
- if (mutation === 'mutation.markShortcutWorkerFallback') {
42
- const data = task.result?.data ?? {};
43
- const shortcut = data.shortcut && typeof data.shortcut === 'object' ? data.shortcut : {};
44
- task.result = { summary: task.result?.summary ?? 'Shortcut fallback selected', data: { ...data, shortcut: { ...shortcut, workerFallback: true } } };
45
- task.failureReason = 'shortcut_fallback';
46
- }
47
- if (mutation === 'mutation.markShortcutRecoveryRequired') {
48
- task.failureReason = 'shortcut_requires_recovery';
49
- }
50
41
  if (mutation === 'mutation.prepareNoStartFallback') {
51
42
  const route = task.routing;
52
43
  if (task.adapter !== 'chatgpt' && task.adapter !== 'z')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.256",
3
+ "version": "2.0.257",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,11 +16,11 @@
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 test/verification/l3-shortcut-review.test.mjs test/verification/l3-unified-dag.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 test/verification/l3-unified-dag.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/verification/l3-unified-dag.test.mjs test/agent-shortcut.test.js",
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",
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",
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-coordinator-review.test.mjs test/verification/l3-unified-dag.test.mjs",
20
+ "test:l3:dag": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/verification/l3-coordinator-review.test.mjs test/verification/l3-unified-dag.test.mjs",
21
+ "test:dag": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/verification/l3-coordinator-review.test.mjs test/verification/l3-unified-dag.test.mjs test/pool-dag-continuation.test.js test/coordinator-atomic-create.test.js",
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/coordinator-atomic-create.test.js test/pool-dag-continuation.test.js",
23
+ "test:full": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/*.test.js test/verification/l3-coordinator-review.test.mjs test/verification/l3-unified-dag.test.mjs && npm run test:verification:l3",
24
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",
25
25
  "test:verification:l4:contracts": "npm run build && node --test test/verification/l4/prompt-evals.test.mjs",
26
26
  "test:verification:l4": "node test/verification/l4/run-all.mjs",
@@ -5,15 +5,15 @@ description: Use Agents Relay for durable multi-step or multi-agent work that ne
5
5
 
6
6
  # Agents Relay
7
7
 
8
- Agents Relay manages durable Jobs and Tasks. Use its CLI for Job/Task state and actions; do not read its private storage, GitHub projections, or internal service APIs. Prefer completing simple, non-delegated work directly without Relay.
8
+ Relay owns durable Jobs and Tasks. Use its CLI—not private storage or GitHub projections. Handle one-shot work directly.
9
9
 
10
10
  ## Job Execution Lifecycle (JEL)
11
11
 
12
- Explain **JEL** to the user: **Create → Plan → Execute → Final Review → Merge → Completed**. After work/recovery Tasks terminate (SUCCEEDED/FAILED/CANCELLED), Final Review judges completion: PASS merges; CHANGES_REQUIRED persists findings, starts Planner N+1 for minimal fixes, then re-reviews. No automatic post-success Plan. Planner/Workers use discovered **ponytail** Skill (YAGNI, reuse, minimal Tasks); preserve mandatory safeguards.
12
+ Explain **JEL** to the user: **Create → [optional Plan] → Execute → Final Review → Merge → Completed**. A Coordinator Agent Graph does not need an initial Planner; otherwise the same Task/Review/Merge lifecycle applies. After work/recovery Tasks terminate (SUCCEEDED/FAILED/CANCELLED), Final Review judges completion: PASS merges; CHANGES_REQUIRED persists findings, starts Planner N+1 for minimal fixes, then re-reviews. No automatic post-success Plan. Planner/Workers use discovered **ponytail** Skill (YAGNI, reuse, minimal Tasks); preserve mandatory safeguards.
13
13
 
14
14
  ## 1. Choose and start a Job
15
15
 
16
- Use Relay for durable multi-Task work. Record the standalone objective, constraints, acceptance checks, and deliverables before Job creation.
16
+ Use Relay for durable multi-Task work with explicit objectives and acceptance criteria.
17
17
 
18
18
  Consult CLI help; examples:
19
19
 
@@ -23,7 +23,7 @@ npx agents-relay job show --id JOB_ID
23
23
  npx agents-relay task list --repo OWNER/REPO --id JOB_ID
24
24
  ```
25
25
 
26
- Use the returned Job ID; never invent IDs. Omit `--initial-plan` only for create-only work. GitHub is audit-only; local Git owns merge. For local-only operations use `--no-github`.
26
+ Use returned Job IDs. Omit `--initial-plan` for DRAFT-only or Coordinator Graph work. GitHub is audit-only; local Git owns merge. For local-only operations use `--no-github`.
27
27
 
28
28
  Read `contracts/task-job-contract.md` before authoring or changing Jobs or Tasks and `contracts/orchestrator-workflows.md` when handling initial planning, P0/self Jobs, or merge/delivery boundaries. For content work, load the active Neo Project rules, its Agent Graph if present, and the relevant stage contracts—not a presumed universal production sequence.
29
29
 
@@ -42,19 +42,42 @@ node <matching-absolute-dist/cli.js> plan context --id JOB --plan-id PLAN --exec
42
42
 
43
43
  Task and Planner context commands reject stale identities. Optional `--repo` constrains the Job. Never infer Task content from GitHub. Planner submits via `apply_cli`; only `PLAN_APPLIED:<plan-id>:<execution-id>` proves application. Authorized delegation creates durable child Tasks.
44
44
 
45
- Graph Tasks use Relay's ordinary Task Reconciler: `agentGraph` becomes a
46
- **Coordinator** with durable Agent-named children created as dependencies become
47
- ready. Script and Model are Task execution choices; each has the same
48
- Task-level retry, failure and review semantics. `job run --id JOB --task-id TASK` activates any create-only Graph Job and
49
- hands it to that same Reconciler; it is not a separate DAG scheduler or Job
50
- execution mode. All DAG Agent Tasks continue immediately when predecessor
51
- results or human Review decisions are durably accepted: the event directly
52
- wakes this Job's ordinary Reconciler to dispatch dependency-ready Script and
53
- Model Tasks before global Job-queue selection. `QUEUED` remains a durable
54
- recovery/resource-wait state, not a required scheduler round-trip. Global
55
- Worker Pool capacity is still enforced. Final Review is independently
56
- controlled by `--review`/`--no-review`; normal Git Merge by
57
- `--auto-merge`/`--no-auto-merge`. A Graph needs no Planner unless requested.
45
+ ### Plan-free Coordinator / DAG execution
46
+
47
+ `agentGraph` is a declarative dependency DAG. Relay persists one Coordinator
48
+ Task and one independent **Agent Task for each node as its dependencies become
49
+ ready**. The Coordinator owns the Graph but does not lease a Worker or use a
50
+ second execution state machine. Script and Model nodes have identical durable
51
+ Task lifecycle, retry, recovery, human review and terminal event semantics.
52
+ An Agent terminal event **immediately** reconciles and dispatches ready
53
+ successors when capacity allows. Otherwise QUEUED retains recovery and fair
54
+ admission. Branches can run concurrently; fan-ins await dependencies.
55
+
56
+ To create a plan-free Coordinator Job, include its Graph and execution paths
57
+ **in the original Job creation**, atomically with the durable Job. For example:
58
+
59
+ ```sh
60
+ npx agents-relay job create --repo OWNER/REPO --title "Episode" \
61
+ --objective-file job.md \
62
+ --coordinator-graph-file /absolute/project/graph.mmd \
63
+ --coordinator-input-file /absolute/run/neo-project-run.input.md \
64
+ --coordinator-output-path /absolute/run/neo-project-run.result.json \
65
+ --coordinator-project-root /absolute/project \
66
+ --coordinator-workspace-root /absolute/workspace \
67
+ --coordinator-shared-root /absolute/shared
68
+ npx agents-relay job run --id JOB_ID --task-id coordinator \
69
+ --project-path /absolute/project --workspace-root /absolute/workspace \
70
+ --shared-root /absolute/shared
71
+ ```
72
+
73
+ Creation atomically persists **DRAFT Job + Coordinator Task**. Activation
74
+ returns a scheduled receipt, not completion. Neo's `neo project run` wraps this
75
+ creation/binding/activation sequence and resumes an existing Run without
76
+ creating a second Job. Do not use legacy `--shortcut-execution`, `--mode
77
+ shortcut`, `--shortcut-local`, `--legacy-shortcut-runtime` or receipts.
78
+ Final Review (`--review`/`--no-review`) and local Git Merge
79
+ (`--auto-merge`/`--no-auto-merge`) are independent ordinary Job policies;
80
+ there is no automatic Plan or special content-only completion mode.
58
81
 
59
82
  ## 3. Verify, review, and recover
60
83
 
@@ -88,9 +111,7 @@ Markcut). The reviewed Task enters `AWAITING_DECISION`. An inbox/compile receipt
88
111
  is **not approval**. An accepted Approve resumes the same Agent Task; Request
89
112
  Changes resumes the same Task with feedback (a scripted Task can switch to its
90
113
  Model executor for semantic revision, then return to Script for validation).
91
- One execution ID identifies at most one review. Preview does **not** create Git
92
- commits, snapshots or independent reviewer Tasks. Legacy in-flight Shortcut
93
- checkpoints remain compatible. See `contracts/event-contract.md`.
114
+ One execution ID identifies at most one review. Preview does **not** create Git commits, snapshots or independent reviewer Tasks. Review feedback and decisions live in Relay's durable Task history, not a synthetic Git revision. See `contracts/event-contract.md`.
94
115
 
95
116
  ## 5. Manage services when needed
96
117