agents-relay 2.0.160 → 2.0.162

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.
@@ -3,15 +3,14 @@ import { attachResolutionOwnership } from './workflow/task-resolution.js';
3
3
  /** Recover persisted child definitions without inventing new task identities. */
4
4
  export async function recoverPlannerChildren(store, job, plannerContext) {
5
5
  for (const plan of (job.plans ?? []).filter(item => item.status === 'SUCCEEDED' && item.plannerResult)) {
6
- const executionContext = await plannerContext(job, plan);
7
- // Historical plans were validated on commit. Rechecking against later Task failures
8
- // blocks recovery before the Troubleshooter graph can run.
9
- const children = plan.plannerResult.next_tasks.map(spec => materializePlannerChild(job, plan, spec, executionContext));
10
- for (const child of children) {
11
- const existing = job.tasks.find(item => item.id === child.id);
12
- if (existing)
6
+ for (const spec of plan.plannerResult.next_tasks) {
7
+ // A succeeded Plan is immutable historical evidence. Existing children may
8
+ // have accumulated execution and Resolution state since the Plan committed;
9
+ // do not rematerialize them against today's Task states.
10
+ if (job.tasks.some(item => item.id === spec.id))
13
11
  continue;
14
- const spec = plan.plannerResult.next_tasks.find(item => item.id === child.id);
12
+ const executionContext = await plannerContext(job, plan);
13
+ const child = materializePlannerChild(job, plan, spec, executionContext);
15
14
  if (spec?.resolution)
16
15
  await store.saveTask(attachResolutionOwnership(job, child, spec.resolution, 'planner'));
17
16
  await store.appendTask(child);
@@ -21,7 +20,6 @@ export async function recoverPlannerChildren(store, job, plannerContext) {
21
20
  const historicalPlanners = job.tasks.filter(task => task.kind === 'planner' && task.state === 'SUCCEEDED' && task.plannerResult);
22
21
  if (historicalPlanners.length === 0)
23
22
  return;
24
- const executionContext = await plannerContext(job, historicalPlanners[0]);
25
23
  for (const planner of historicalPlanners) {
26
24
  const result = planner.plannerResult;
27
25
  const plan = { jobId: job.id, id: planner.id, round: planner.planningRound ?? 1, source: planner.planningSource ?? 'model-planner', previousPlanId: planner.previousPlannerTaskId ?? null, trigger: planner.planTrigger ?? { source: 'continuation' }, status: 'SUCCEEDED', guidance: planner.plannerGuidance, objectiveStatus: result.objective_status, plannerResult: result, assessment: result.assessment, generatedTaskIds: result.next_tasks.map(item => item.id), headSha: planner.planTrigger?.currentHeadSha ?? job.headSha, attempt: planner.attempt, maxAttempts: planner.maxAttempts, leaseOwner: null, leaseExpiresAt: null, executionId: null, timeoutMs: planner.timeoutMs, manualPlanning: planner.manualPlanning, createdAt: planner.createdAt, updatedAt: planner.updatedAt };
@@ -31,10 +29,10 @@ export async function recoverPlannerChildren(store, job, plannerContext) {
31
29
  }
32
30
  else
33
31
  continue;
34
- const children = result.next_tasks.map(spec => materializePlannerChild(job, plan, spec, executionContext));
35
- for (const child of children)
36
- if (!job.tasks.some(item => item.id === child.id)) {
37
- const spec = result.next_tasks.find(item => item.id === child.id);
32
+ for (const spec of result.next_tasks)
33
+ if (!job.tasks.some(item => item.id === spec.id)) {
34
+ const executionContext = await plannerContext(job, planner);
35
+ const child = materializePlannerChild(job, plan, spec, executionContext);
38
36
  if (spec?.resolution)
39
37
  await store.saveTask(attachResolutionOwnership(job, child, spec.resolution, 'planner'));
40
38
  await store.appendTask(child);
package/dist/planner.js CHANGED
@@ -476,6 +476,10 @@ export class CommandObjectivePlanner {
476
476
  }
477
477
  const DEFAULT_PLANNER_AGENT = join(dirname(fileURLToPath(import.meta.url)), '..', 'skills', 'agents-relay', 'agents', 'planner.agent.md');
478
478
  const DEFAULT_TASK_JOB_CONTRACT = join(dirname(fileURLToPath(import.meta.url)), '..', 'skills', 'agents-relay', 'contracts', 'task-job-contract.md');
479
+ export function buildPlannerCodexArgs(storeDirectory, input) {
480
+ return ['exec', '--json', '--sandbox', 'workspace-write', '--add-dir', resolvePath(dirname(storeDirectory)),
481
+ '-c', 'sandbox_workspace_write.network_access=true', '--', input];
482
+ }
479
483
  function parsePlannerAgentMessage(line) {
480
484
  try {
481
485
  const value = JSON.parse(line);
@@ -504,7 +508,7 @@ export class AgentObjectivePlanner {
504
508
  const prompt = renderAgentPrompt(await buildReferenceFirstPrompt({ role: 'planner', adapter: 'codex', system: (effectivePlanner ? `[Effective planner contract SHA-256: ${effectivePlanner.hash}]\n\n` : '') + instructions.trim() + '\n\n## Shared Task / Job Contract\n\n' + contract.trim(), user: resolvedContext + '## Durable planner input\n\n' + plannerInput(context) }), 'codex');
505
509
  const runAgent = (input) => new Promise((resolve, reject) => {
506
510
  // Plan apply writes unified relay.sqlite beside AGENTS_RELAY_STORE_DIR.
507
- const child = spawnOwnedProcess(this.command, ['exec', '--json', '--sandbox', 'workspace-write', '--add-dir', resolvePath(dirname(relayStoreDirectory())), '--', input], { invocation: 'planner.agent', signal, correlation: { jobId: context.job.id }, spawn: { cwd: context.executionContext?.project.path, stdio: ['ignore', 'pipe', 'pipe'] } });
511
+ const child = spawnOwnedProcess(this.command, buildPlannerCodexArgs(relayStoreDirectory(), input), { invocation: 'planner.agent', signal, correlation: { jobId: context.job.id }, spawn: { cwd: context.executionContext?.project.path, stdio: ['ignore', 'pipe', 'pipe'] } });
508
512
  let stdoutBuffer = '', finalMessage = '', stderrTail = '';
509
513
  const consume = (line) => {
510
514
  const message = parsePlannerAgentMessage(line);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.160",
3
+ "version": "2.0.162",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "test:publish": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 --test-force-exit test/*.test.js",
20
20
  "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/local-sqlite-jobid.test.js test/no-github.test.js test/scheduled-jobs.test.js test/reconcile-coordinator.test.js test/service-publication.test.js test/github-webhook.test.js",
21
21
  "test:full": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/*.test.js && npm run test:verification:l3",
22
- "test:verification:l1": "npm run build && node --test test/verification/harness.test.mjs test/verification/contract.test.mjs 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",
22
+ "test:verification:l1": "npm run build && node --test test/verification/harness.test.mjs test/verification/contract.test.mjs 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/planner-child-recovery.test.js",
23
23
  "test:verification:l3": "npm run build && node --test --test-concurrency=1 test/verification/harness.test.mjs test/verification/l3-sqlite.test.mjs test/verification/l3-ingress.test.mjs test/verification/l3-replay.test.mjs test/verification/objective-authority.test.mjs test/verification/l3-convergence.test.mjs test/verification/l3-review-convergence.test.mjs test/verification/l3-human-escalation.test.mjs test/verification/l3-escalation-notifier.test.mjs test/verification/l3-unknown-effect.test.mjs test/verification/l3-cli-actions.test.mjs test/verification/l3-planner-round.test.mjs test/verification/l3-planner-cli.test.mjs test/verification/l3-task-resolution.test.mjs test/verification/full-recovery-gates.test.mjs test/verification/production-wiring.test.mjs test/verification/l3-full-path.test.mjs test/verification/l3-projection-recovery.test.mjs",
24
24
  "test:verification": "npm run test:verification:l1 && npm run test:verification:l2 && npm run test:verification:l3 && npm run test:verification:cross-a && node --test test/workflow-production-outbox.test.js && npm run test:verification:matrix",
25
25
  "e2e": "node e2e/runner/run.mjs",