agents-relay 2.0.71 → 2.0.73

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.
@@ -1,3 +1,4 @@
1
+ import { dispatchJobLifecycleSync } from './workflow/lifecycle.js';
1
2
  import { createPlanRound, pendingPlan } from './planner.js';
2
3
  import { applyJobActivateAction } from './job-actions.js';
3
4
  export async function executeManualPlan(store, jobId, guidance, timeoutMs, launchPlanner) {
@@ -22,8 +23,11 @@ export async function executeManualPlan(store, jobId, guidance, timeoutMs, launc
22
23
  round = createPlanRound(current, { guidance, manual: true, timeoutMs });
23
24
  current.plans = [...(current.plans ?? []), structuredClone(round)].sort((a, b) => a.round - b.round);
24
25
  }
25
- if (current.state === 'DRAFT')
26
- applyJobActivateAction(current);
26
+ if (current.state === 'DRAFT') {
27
+ const activation = dispatchJobLifecycleSync(current, 'activate');
28
+ if (!activation.accepted)
29
+ throw new Error(`Job ${current.id} activation rejected`);
30
+ }
27
31
  return current;
28
32
  });
29
33
  job = structuredClone(committed);
@@ -3,8 +3,18 @@ import { jobHasActiveExecution } from './job-execution-slot.js';
3
3
  import { eventFor } from './events.js';
4
4
  import { materializePlannerChild, parsePlannerResult, validatePlannerHierarchy, validatePlannerLifecycleOwnership, validatePlannerProgress } from './planner.js';
5
5
  import { samePlannerChildDefinition } from './planner-child.js';
6
+ import { dispatchJobLifecycleSync } from './workflow/lifecycle.js';
6
7
  import { withExecutionBoundary } from './reconciler-runtime.js';
7
8
  import { storySizeTimeoutMs } from './types.js';
9
+ /** Activate queued planner work inside the same authoritative SQLite mutation. */
10
+ export function activateCommittedPlannerWork(job) {
11
+ if (job.state !== 'DRAFT' || !job.tasks.some(item => item.state === 'QUEUED'))
12
+ return false;
13
+ const activation = dispatchJobLifecycleSync(job, 'activate');
14
+ if (!activation.accepted)
15
+ throw new Error(`Job ${job.id} activation rejected after planning`);
16
+ return true;
17
+ }
8
18
  export async function drainPlannerUnblocks(ports, jobId, planId) {
9
19
  const job = await ports.store.load(jobId);
10
20
  const plan = (job.plans ?? []).find(item => item.id === planId);
@@ -150,6 +160,9 @@ async function finishPlanner(ports, jobId, planId, executionId, error, raw) {
150
160
  else if (!samePlannerChildDefinition(existing, child))
151
161
  throw new Error(`Planner child ${child.id} already exists with a different definition`);
152
162
  }
163
+ // Planner children are committed atomically with Job activation.
164
+ // Otherwise the DRAFT Job is invisible to the ACTIVE-only dispatcher.
165
+ activateCommittedPlannerWork(current);
153
166
  current.updatedAt = now;
154
167
  committedPlan = true;
155
168
  return current;
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { dispatchJobLifecycleSync } from './workflow/lifecycle.js';
2
3
  export function createDashboardActions(deps) {
3
4
  const { getOverviews, requireLocalJobBinding, pool, dashboardJobAction, makeReconciler, concurrency, dashboardJobSetState, refreshAll, applyJobActivateAction, applyOrchestratorStartAction, applyOrchestratorCompleteAction, publishOrchestratorTaskStarted, publishOrchestratorTaskCompletion, bus, dashboardTaskAction, dashboardTaskSetState } = deps;
4
5
  const currentOverviews = () => getOverviews();
@@ -42,8 +43,11 @@ export function createDashboardActions(deps) {
42
43
  if (current.tasks.some((item) => item.id === task.id))
43
44
  throw new Error(`Task ${task.id} already exists`);
44
45
  current.tasks.push(structuredClone(task));
45
- if (current.state === 'DRAFT')
46
- applyJobActivateAction(current);
46
+ if (current.state === 'DRAFT') {
47
+ const activation = dispatchJobLifecycleSync(current, 'activate');
48
+ if (!activation.accepted)
49
+ throw new Error(`Job ${current.id} activation rejected`);
50
+ }
47
51
  current.updatedAt = new Date().toISOString();
48
52
  return current;
49
53
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.71",
3
+ "version": "2.0.73",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "type": "module",
6
6
  "bin": {