agents-relay 2.0.255 → 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 +28 -15
  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 -14
  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
@@ -56,24 +56,37 @@ export async function aggregateManagedGitHubJobs(client, repositories, trustedAu
56
56
  const groups = await Promise.all(uniqueRepositories.map(repository => listManagedGitHubJobs(client, repository, trustedAuthors)));
57
57
  return groups.flat().sort((a, b) => b.job.updatedAt.localeCompare(a.job.updatedAt) || b.job.prNumber - a.job.prNumber);
58
58
  }
59
+ /** Measure leased workers, not Coordinator Tasks or human-review waits.
60
+ * Legacy non-DAG Jobs retain the previous one-slot accounting. DAG branches
61
+ * may use several slots, but never exceed the global Worker Pool budget. */
62
+ export function activeWorkerSlots(job) {
63
+ if (!job.tasks.some(t => Boolean(t.dagNode)))
64
+ return jobHasActiveExecution(job) ? 1 : 0;
65
+ const leased = job.tasks.filter(t => t.executionId !== null && t.leaseOwner &&
66
+ (t.state === 'RUNNING' || t.state === 'QUEUED') && !unifiedDAG(job, t)).length;
67
+ const planning = (job.plans ?? []).filter(p => Boolean(p.executionId) && p.status === 'PLANNING').length;
68
+ return leased + planning;
69
+ }
70
+ function remainingWorkerSlots(concurrency, jobs) {
71
+ const unique = new Map(jobs.map(job => [job.id, job]));
72
+ return Math.max(0, concurrency - [...unique.values()].reduce((used, job) => used + (job.state === 'ACTIVE' || job.projectionRecovery?.status === 'repairing' ? activeWorkerSlots(job) : 0), 0));
73
+ }
59
74
  export class RepositoryWorkerPool {
60
75
  concurrency;
61
76
  makeReconciler;
62
77
  localInventory;
63
78
  resolveLocalJob;
64
- onShortcutDecision;
65
79
  running = false;
66
80
  pending = false;
67
81
  reconcileLocks = new Map();
68
82
  coordinator;
69
83
  dispatchTail = Promise.resolve();
70
84
  watchedBus;
71
- constructor(concurrency, makeReconciler, localInventory, resolveLocalJob, onShortcutDecision) {
85
+ constructor(concurrency, makeReconciler, localInventory, resolveLocalJob) {
72
86
  this.concurrency = concurrency;
73
87
  this.makeReconciler = makeReconciler;
74
88
  this.localInventory = localInventory;
75
89
  this.resolveLocalJob = resolveLocalJob;
76
- this.onShortcutDecision = onShortcutDecision;
77
90
  const reportCoordinatorError = (error, signal) => {
78
91
  observability().record({
79
92
  stage: 'reconcile', event: 'reconcile.coordinator_failed', level: 'error', outcome: 'failed',
@@ -134,8 +147,17 @@ export class RepositoryWorkerPool {
134
147
  throw new Error('Local job not found: ' + jobId);
135
148
  await this.withDispatchGate(async () => {
136
149
  await this.reconcileExclusive(jobId, async () => {
137
- await withObservabilityCorrelation({ jobId, repository: target.job.repository }, () => this.makeReconciler(target.store, 0).reconcile(jobId));
150
+ const current = await target.store.load(jobId);
151
+ const dag = current.state === 'ACTIVE' && current.tasks.some(t => unifiedDAG(current, t));
152
+ // DAG continuation goes straight to the existing Reconciler on the
153
+ // terminal event. No zero-capacity pass followed by global Job queue
154
+ // selection. If the pool is full, the durable Task remains QUEUED and
155
+ // the ordinary recovery/scheduler path will pick it up later.
156
+ const slots = dag ? remainingWorkerSlots(this.concurrency, [...(await this.localInventory()).map(item => item.job).filter(j => j.id !== jobId), current]) : 0;
157
+ await withObservabilityCorrelation({ jobId, repository: current.repository }, () => this.makeReconciler(target.store, slots).reconcile(jobId));
138
158
  });
159
+ // Still free slots for unrelated Jobs on completion; this scan is not
160
+ // on the critical path for DAG successor dispatch, which occurred above.
139
161
  await this.reconcileDiscovered(await this.localInventory());
140
162
  });
141
163
  void reason;
@@ -154,12 +176,6 @@ export class RepositoryWorkerPool {
154
176
  if (signal.event.type === 'github.webhook')
155
177
  continue;
156
178
  const outcome = await reconciler.applyEvent(signal.event);
157
- // The decision is durably applied before invoking the Shortcut CLI hook.
158
- // A replay can also wake a still-QUEUED Task without a new decision.
159
- if (signal.event.type === 'task.interactive_decision' && !target.job.tasks.some(t => unifiedDAG(target.job, t)) &&
160
- ['task.interactive_decision.accepted', 'task.interactive_decision.duplicate'].includes(outcome.reason) &&
161
- await this.onShortcutDecision?.(jobId, signal.event.task_id))
162
- continue;
163
179
  shouldReconcile ||= outcome.reconcile;
164
180
  }
165
181
  if (shouldReconcile)
@@ -167,13 +183,10 @@ export class RepositoryWorkerPool {
167
183
  }
168
184
  async reconcileDiscovered(discovered) {
169
185
  const jobs = runnableManagedJobs(discovered);
170
- let capacity = Math.max(0, this.concurrency - jobs.filter(job => jobHasActiveExecution(job)).length);
186
+ let capacity = remainingWorkerSlots(this.concurrency, jobs);
171
187
  for (const job of jobs) {
172
188
  if (capacity <= 0)
173
189
  break;
174
- // Legacy in-flight Shortcut Jobs retain their original foreground owner.
175
- if (job.executionMode === 'shortcut' && !job.tasks.some(t => unifiedDAG(job, t)))
176
- continue;
177
190
  const store = await this.requireLocalStore(job.id);
178
191
  await store.hydrate?.(job);
179
192
  const ready = job.tasks.filter(task => (task.state === 'QUEUED' && task.executionId === null) || (task.state === 'DRAFT' && task.dependencies.length > 0)).length;
@@ -256,7 +269,7 @@ export class RepositoryWorkerPool {
256
269
  // GitHub transport is observational. It must never wake lifecycle execution.
257
270
  if (event.type === 'github.webhook')
258
271
  return;
259
- 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';
260
273
  if (!lifecycle && !wake)
261
274
  return;
262
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.255",
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",