agent-valley 4.8.0 → 4.8.2

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,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "av",
4
- "version": "4.8.0",
4
+ "version": "4.8.2",
5
5
  "description": "Delegate repository goals to Agent Valley and inspect mission progress and verification evidence.",
6
6
  "author": {
7
7
  "name": "Agent Valley"
package/dist/index.js CHANGED
@@ -7527,6 +7527,11 @@ var init_operations = __esm(() => {
7527
7527
  outcome: _enum(["pending", "passed", "rejected", "failed"]),
7528
7528
  executionState: _enum(["running", "settled", "unknown"]).optional(),
7529
7529
  executionRecovery: _enum(["local-process", "reconcile"]).optional(),
7530
+ routingExclusion: strictObject({
7531
+ reason: literal("coordinator-cancelled"),
7532
+ dispatchAt: exports_iso.datetime(),
7533
+ pauseAt: exports_iso.datetime()
7534
+ }).optional(),
7530
7535
  routingReason: text3.optional(),
7531
7536
  evidence: text3.optional(),
7532
7537
  fingerprint: text3.optional()
@@ -53532,6 +53537,80 @@ import { createHash as createHash9 } from "node:crypto";
53532
53537
  import { constants as constants5 } from "node:fs";
53533
53538
  import { lstat as lstat8, open as open7, realpath as realpath9 } from "node:fs/promises";
53534
53539
  import { relative as relative6, resolve as resolve16, sep as sep6 } from "node:path";
53540
+
53541
+ // ../../packages/core/src/chief/cancelled-work-run.ts
53542
+ var cancellationMessages = new Set([
53543
+ "Operator stopped the order. Its checks and worktree were retained; repair any interrupted effects before resuming with --retry.",
53544
+ "Mission interrupted. Its checks, budget and child workspace records were retained for resume.",
53545
+ "The OS-owned service is shutting down. Re-observe the saved execution before continuing the same goal within its original limits."
53546
+ ]);
53547
+ function settledFailure(run) {
53548
+ return run.stage === "work" && !!run.taskId && run.outcome === "failed" && run.executionState === "settled" && run.executionRecovery === "local-process" && !run.evidence?.trim() && Number.isFinite(Date.parse(run.startedAt)) && Number.isFinite(Date.parse(run.finishedAt ?? "")) && Date.parse(run.finishedAt ?? "") >= Date.parse(run.startedAt);
53549
+ }
53550
+ function archivedWorkCancellation(run) {
53551
+ const proof = run.routingExclusion;
53552
+ if (settledFailure(run) && proof?.reason === "coordinator-cancelled" && Date.parse(proof.dispatchAt) <= Date.parse(run.startedAt) && Date.parse(proof.pauseAt) >= Date.parse(run.finishedAt ?? ""))
53553
+ return proof;
53554
+ }
53555
+ function cancelledWorkRunProofs(mission) {
53556
+ const runs = mission.operations?.runs ?? [];
53557
+ const history = mission.history ?? [];
53558
+ const proofs = new Map;
53559
+ for (const run of runs) {
53560
+ const proof = archivedWorkCancellation(run);
53561
+ if (proof)
53562
+ proofs.set(run.runId, proof);
53563
+ }
53564
+ for (const [pauseIndex, pause] of history.entries()) {
53565
+ if (pause.stage !== "paused" || pause.taskId || !cancellationMessages.has(pause.message))
53566
+ continue;
53567
+ const pausedAt = Date.parse(pause.at);
53568
+ if (!Number.isFinite(pausedAt))
53569
+ continue;
53570
+ for (const run of runs) {
53571
+ if (!settledFailure(run) || Date.parse(run.finishedAt ?? "") > pausedAt)
53572
+ continue;
53573
+ const state = mission.tasks?.find((task) => task.id === run.taskId);
53574
+ if (state?.effectState === "running" || state?.effectState === "unknown")
53575
+ continue;
53576
+ const dispatchIndex = history.findLastIndex((entry, index) => {
53577
+ const prefix = `Running ${run.taskId} with ${run.actorId}, attempt `;
53578
+ return index < pauseIndex && entry.stage === "work" && entry.taskId === run.taskId && entry.message.startsWith(prefix) && /^[1-9]\d*\.$/.test(entry.message.slice(prefix.length)) && Date.parse(entry.at) <= Date.parse(run.startedAt);
53579
+ });
53580
+ const dispatch = history[dispatchIndex];
53581
+ if (!dispatch)
53582
+ continue;
53583
+ const dispatchedAt = Date.parse(dispatch.at);
53584
+ if (runs.filter((entry) => {
53585
+ const start = Date.parse(entry.startedAt);
53586
+ if (!Number.isFinite(start))
53587
+ return true;
53588
+ if (start > pausedAt)
53589
+ return false;
53590
+ const finish = Date.parse(entry.finishedAt ?? "");
53591
+ return !Number.isFinite(finish) || finish >= dispatchedAt;
53592
+ }).length !== 1)
53593
+ continue;
53594
+ const intermediate = history.slice(dispatchIndex + 1, pauseIndex);
53595
+ const uninterrupted = intermediate.every((entry) => {
53596
+ if (entry.stage === "skill-compatibility")
53597
+ return true;
53598
+ if (entry.stage !== "oma-dispatch" || entry.taskId !== run.taskId)
53599
+ return false;
53600
+ try {
53601
+ const record = JSON.parse(entry.message);
53602
+ return record.attemptId === run.runId && record.actorId === run.actorId;
53603
+ } catch {
53604
+ return false;
53605
+ }
53606
+ });
53607
+ if (uninterrupted)
53608
+ proofs.set(run.runId, { reason: "coordinator-cancelled", dispatchAt: dispatch.at, pauseAt: pause.at });
53609
+ }
53610
+ }
53611
+ return proofs;
53612
+ }
53613
+ // ../../packages/core/src/chief/organization-outcomes.ts
53535
53614
  init_organization_types();
53536
53615
 
53537
53616
  // ../../packages/core/src/chief/review-gate-check.ts
@@ -53652,6 +53731,7 @@ async function recordMissionOrganizationOutcome(sourceRepo, mission) {
53652
53731
  mission.verification?.ok,
53653
53732
  mission.finalReview?.criteria
53654
53733
  ]);
53734
+ const cancellations = cancelledWorkRunProofs(mission);
53655
53735
  return recordOrganizationOutcome(sourceRepo, {
53656
53736
  missionId: mission.id,
53657
53737
  missionVersion,
@@ -53662,7 +53742,10 @@ async function recordMissionOrganizationOutcome(sourceRepo, mission) {
53662
53742
  summary: (mission.report?.summary ?? mission.error ?? `Mission ${mission.status}`).slice(0, 2000),
53663
53743
  evidence: await deliveredArtifacts(mission.workspace.path),
53664
53744
  observations: [],
53665
- runs: mission.operations?.runs ?? [],
53745
+ runs: (mission.operations?.runs ?? []).map((run) => {
53746
+ const routingExclusion = cancellations.get(run.runId);
53747
+ return routingExclusion ? { ...run, routingExclusion } : run;
53748
+ }),
53666
53749
  verification: mission.verification ? {
53667
53750
  ok: mission.verification.ok,
53668
53751
  fingerprint: mission.verification.fingerprint,
@@ -53694,7 +53777,8 @@ async function getOrganizationRouteEvidence(sourceRepo) {
53694
53777
  totalCostUsd: 0,
53695
53778
  successfulDeliverableCostUsd: null
53696
53779
  };
53697
- group.samples++;
53780
+ if (!archivedWorkCancellation(run))
53781
+ group.samples++;
53698
53782
  if (run.outcome === "passed")
53699
53783
  group.successes++;
53700
53784
  group.totalCostUsd = group.totalCostUsd === null || run.costUsd === null ? null : group.totalCostUsd + run.costUsd;
@@ -54386,6 +54470,61 @@ function validateFinalReview(review, mission) {
54386
54470
  return review;
54387
54471
  }
54388
54472
 
54473
+ // ../../packages/core/src/chief/bounded-work-routing.ts
54474
+ import { createHash as createHash13 } from "node:crypto";
54475
+ function repairDecision(mission, taskId, taskRuns) {
54476
+ return mission.supervision?.decisions.findLast((entry) => ["repair", "reassign", "replan"].includes(entry.action) && (!entry.taskId || entry.taskId === taskId) && entry.round > 0 && entry.round <= (mission.supervision?.maxRounds ?? 0) && entry.round <= (mission.supervision?.rounds ?? 0) && Number.isFinite(Date.parse(entry.at)) && taskRuns.some((run) => Number.isFinite(Date.parse(run.finishedAt ?? "")) && Date.parse(run.finishedAt ?? "") < Date.parse(entry.at)));
54477
+ }
54478
+ function unreviewed(run, decision) {
54479
+ const finished = Date.parse(run.finishedAt ?? "");
54480
+ return run.outcome === "pending" && (!decision || !Number.isFinite(finished) || finished >= Date.parse(decision.at));
54481
+ }
54482
+ function hasUnreviewedRoutingProbe(mission, taskId, taskRuns) {
54483
+ const decision = repairDecision(mission, taskId, taskRuns);
54484
+ return taskRuns.some((run) => run.routingReason?.startsWith("Bounded routing probe ") && unreviewed(run, decision));
54485
+ }
54486
+ function boundedWorkRoute(mission, taskId, candidates, evidence, taskRuns, failed, routeKey) {
54487
+ if (!taskId)
54488
+ return;
54489
+ const task = mission.plan?.tasks.find((entry) => entry.id === taskId);
54490
+ const state = mission.tasks.find((entry) => entry.id === taskId);
54491
+ if (!task || !state || state.status === "completed" || (state.repairRound ?? 0) > mission.maxRepairs)
54492
+ return;
54493
+ if (mission.tasks.some((entry) => entry.effectState === "unknown" || entry.effectState === "running") || state.effectState === "completed" || mission.operations?.runs.some((run) => run.executionState === "unknown" || run.taskId === taskId && (run.executionState === "running" || !Number.isFinite(Date.parse(run.startedAt)) || !Number.isFinite(Date.parse(run.finishedAt ?? "")))))
54494
+ return;
54495
+ const decision = repairDecision(mission, taskId, taskRuns);
54496
+ if (taskRuns.some((run) => unreviewed(run, decision)))
54497
+ return;
54498
+ const scope = createHash13("sha256").update(JSON.stringify({
54499
+ taskId,
54500
+ repairRound: state.repairRound ?? 0,
54501
+ ...decision ? { chief: [decision.round, decision.at, decision.action, decision.taskId ?? null] } : {}
54502
+ })).digest("hex");
54503
+ const prefix = `Bounded routing probe ${scope}: `;
54504
+ const used = new Set(taskRuns.filter((run) => run.routingReason?.startsWith(prefix)).map(routeKey));
54505
+ const available = candidates.filter((candidate) => {
54506
+ if (used.has(routeKey(candidate)))
54507
+ return false;
54508
+ if (!failed.has(routeKey(candidate)))
54509
+ return true;
54510
+ const failure = taskRuns.findLast((run) => routeKey(run) === routeKey(candidate) && (run.outcome === "failed" || run.outcome === "rejected"));
54511
+ return decision !== undefined && failure !== undefined && Number.isFinite(Date.parse(failure.finishedAt ?? "")) && Date.parse(failure.finishedAt ?? "") < Date.parse(decision.at);
54512
+ });
54513
+ const observed = (candidate) => evidence.find((entry) => routeKey(entry) === routeKey(candidate));
54514
+ const successRate = (candidate) => {
54515
+ const record = observed(candidate);
54516
+ return record?.samples ? record.successes / record.samples : -1;
54517
+ };
54518
+ const cost = (candidate) => observed(candidate)?.successfulDeliverableCostUsd ?? Number.POSITIVE_INFINITY;
54519
+ const candidate = available.sort((a, b) => successRate(b) - successRate(a) || cost(a) - cost(b)).at(0);
54520
+ if (!candidate)
54521
+ return;
54522
+ return {
54523
+ candidate,
54524
+ reason: `${prefix}No fresh route met the measured quality preference. Selected ${candidate.actorType}/${candidate.model ?? "native default"} from the saved ready, compatible pool for one probe at this checkpoint; ` + "below-threshold evidence, task failures and spent execution limits remain unchanged."
54525
+ };
54526
+ }
54527
+
54389
54528
  // ../../packages/core/src/chief/handoff-contract.ts
54390
54529
  init_zod();
54391
54530
  var handoffRouteSchema = strictObject({
@@ -54409,6 +54548,7 @@ function unavailableProviders(state) {
54409
54548
  var routeKey = (entry) => `${entry.actorType}\x00${entry.model ?? ""}`;
54410
54549
  function routeEvidence(mission) {
54411
54550
  const evidence = new Map;
54551
+ const cancelled = cancelledWorkRunProofs(mission);
54412
54552
  for (const item of mission.operations?.routingEvidence ?? [])
54413
54553
  evidence.set(routeKey(item), { ...item });
54414
54554
  for (const run of mission.operations?.runs ?? []) {
@@ -54423,7 +54563,8 @@ function routeEvidence(mission) {
54423
54563
  totalCostUsd: 0,
54424
54564
  successfulDeliverableCostUsd: null
54425
54565
  };
54426
- item.samples += 1;
54566
+ if (!cancelled.has(run.runId))
54567
+ item.samples += 1;
54427
54568
  if (run.outcome === "passed")
54428
54569
  item.successes += 1;
54429
54570
  item.totalCostUsd = item.totalCostUsd === null || run.costUsd === null ? null : item.totalCostUsd + run.costUsd;
@@ -54472,14 +54613,13 @@ function selectWorkActor(mission, actor, taskId, compatibleRoutes) {
54472
54613
  const observed = evidence.find((item) => routeKey(item) === routeKey(candidate));
54473
54614
  return !observed || observed.samples < routing.minSamples || observed.successes / observed.samples >= routing.minSuccessRate;
54474
54615
  });
54475
- if (!eligible.length)
54476
- throw new Error("No routing candidate meets the measured minimum success rate. Inspect real failures or configure a new candidate before starting another mission.");
54477
54616
  const qualified = eligible.map((candidate) => ({ candidate, evidence: evidence.find((item) => routeKey(item) === routeKey(candidate)) })).filter((item) => item.evidence !== undefined && item.evidence.samples >= routing.minSamples && item.evidence.successes / item.evidence.samples >= routing.minSuccessRate && item.evidence.successfulDeliverableCostUsd !== null).sort((a, b) => a.evidence.successfulDeliverableCostUsd - b.evidence.successfulDeliverableCostUsd);
54478
54617
  const measured = qualified.at(0);
54479
54618
  const initial = measured?.candidate ?? [...eligible].sort((a, b) => price2(a) - price2(b)).at(0);
54480
- if (!initial)
54481
- throw new Error("Restore a ready work routing candidate before continuing this mission.");
54482
- const taskRuns = (mission.operations?.runs ?? []).filter((run) => run.stage === "work" && run.taskId === taskId);
54619
+ const cancelled = cancelledWorkRunProofs(mission);
54620
+ const taskRuns = (mission.operations?.runs ?? []).filter((run) => run.stage === "work" && run.taskId === taskId && !cancelled.has(run.runId));
54621
+ if (hasUnreviewedRoutingProbe(mission, taskId, taskRuns))
54622
+ throw new Error("This task has an unreviewed bounded routing probe. Resume its retained review or obtain a later Chief repair decision before dispatching more work.");
54483
54623
  const failed = new Set;
54484
54624
  for (let i = taskRuns.length - 1;i >= 0; i--) {
54485
54625
  const run = taskRuns[i];
@@ -54491,12 +54631,19 @@ function selectWorkActor(mission, actor, taskId, compatibleRoutes) {
54491
54631
  failed.add(routeKey(run));
54492
54632
  }
54493
54633
  const ordered = [
54494
- initial,
54495
- ...eligible.filter((item) => routeKey(item) !== routeKey(initial)).sort((a, b) => price2(a) - price2(b))
54634
+ ...initial ? [initial] : [],
54635
+ ...eligible.filter((item) => !initial || routeKey(item) !== routeKey(initial)).sort((a, b) => price2(a) - price2(b))
54496
54636
  ];
54497
54637
  const selected = ordered.find((item) => !failed.has(routeKey(item)));
54498
- if (!selected)
54499
- throw new Error("Every configured routing candidate failed this task. Inspect recorded reviews and work evidence before resuming; configure a new candidate or a new mission.");
54638
+ if (!selected) {
54639
+ const probe = boundedWorkRoute(mission, taskId, compatible, evidence, taskRuns, failed, routeKey);
54640
+ if (probe)
54641
+ return {
54642
+ actor: { ...actor, agentType: probe.candidate.actorType, model: probe.candidate.model },
54643
+ reason: probe.reason
54644
+ };
54645
+ throw new Error(eligible.length ? "Every configured routing candidate failed this task. Its bounded probes are spent; obtain a Chief repair decision or reconcile the recorded failures before continuing." : "No routing candidate meets the measured minimum success rate and this task has no remaining bounded probe. Inspect its saved failures and Chief repair checkpoint before continuing.");
54646
+ }
54500
54647
  const reason = failed.size ? `Escalated after ${failed.size} actually rejected/failed route(s) for this task.` : measured ? `Selected observed successful-deliverable cost after ${measured.evidence.samples} real samples.` : Number.isFinite(price2(selected)) ? "No qualifying measured route; selected the lowest configured input/output price sum (not a measured run cost)." : "No qualifying measured cost or complete prices; selected configured candidate order with unknown cost.";
54501
54648
  return { actor: { ...actor, agentType: selected.actorType, model: selected.model }, reason };
54502
54649
  }
@@ -55155,7 +55302,7 @@ import { isAbsolute as isAbsolute10 } from "node:path";
55155
55302
 
55156
55303
  // ../../packages/core/src/chief/capture.ts
55157
55304
  import { spawn as spawn7 } from "node:child_process";
55158
- import { createHash as createHash13, randomUUID as randomUUID11 } from "node:crypto";
55305
+ import { createHash as createHash14, randomUUID as randomUUID11 } from "node:crypto";
55159
55306
  import { chmod as chmod4, mkdir as mkdir9, readFile as readFile7, writeFile as writeFile4 } from "node:fs/promises";
55160
55307
  import { join as join19 } from "node:path";
55161
55308
 
@@ -69675,7 +69822,7 @@ class MissionCapture {
69675
69822
  name,
69676
69823
  mimeType,
69677
69824
  sizeBytes: contents.length,
69678
- sha256: createHash13("sha256").update(contents).digest("hex")
69825
+ sha256: createHash14("sha256").update(contents).digest("hex")
69679
69826
  };
69680
69827
  }
69681
69828
  async frame() {
@@ -69839,7 +69986,7 @@ ${JSON.stringify(rejected)}`
69839
69986
  }
69840
69987
 
69841
69988
  // ../../packages/core/src/chief/technical-lead.ts
69842
- import { createHash as createHash14 } from "node:crypto";
69989
+ import { createHash as createHash15 } from "node:crypto";
69843
69990
  var TECHNICAL_DIRECTOR_ROLE = "Serve as the Chief Director's permanent Technical Director counterpart. Rigorously minimize total cost and wasted work while maximizing execution efficiency. Protect the user goal and quality requirements; standardize on the existing stack, reuse maintained modules and native integrations, keep dependencies justified and consistent, and favor the smallest maintainable solution.";
69844
69991
  var CTO_ROLE = TECHNICAL_DIRECTOR_ROLE;
69845
69992
  function missionAdviceKey(mission) {
@@ -69874,7 +70021,7 @@ function missionAdviceKey(mission) {
69874
70021
  dependencies: [...dependencies].sort()
69875
70022
  }))
69876
70023
  };
69877
- return createHash14("sha256").update(JSON.stringify(input)).digest("hex");
70024
+ return createHash15("sha256").update(JSON.stringify(input)).digest("hex");
69878
70025
  }
69879
70026
  var technicalPlanKey = missionAdviceKey;
69880
70027
  function technicalReviewPrompt(mission) {
@@ -70014,7 +70161,7 @@ init_metric_source_policy();
70014
70161
 
70015
70162
  // ../../packages/core/src/chief/oma-actor.ts
70016
70163
  init_dist();
70017
- import { createHash as createHash15 } from "node:crypto";
70164
+ import { createHash as createHash16 } from "node:crypto";
70018
70165
  import { constants as constants8 } from "node:fs";
70019
70166
  import { open as open10, readdir as readdir6, realpath as realpath14, stat as stat3 } from "node:fs/promises";
70020
70167
  import { isAbsolute as isAbsolute9, join as join21, relative as relative10, sep as sep10 } from "node:path";
@@ -70427,7 +70574,7 @@ ${chosen.source}`, bodies].join(`
70427
70574
  `);
70428
70575
  if (Buffer.byteLength(guidance) > MAX_GUIDANCE_BYTES)
70429
70576
  throw new Error("The OMA agent and bound skill instructions exceed 256 KB. Reduce assigned instructions before resuming.");
70430
- return { agentId: chosen.agentId, guidance, skills, digest: createHash15("sha256").update(guidance).digest("hex") };
70577
+ return { agentId: chosen.agentId, guidance, skills, digest: createHash16("sha256").update(guidance).digest("hex") };
70431
70578
  }
70432
70579
 
70433
70580
  // ../../packages/core/src/chief/schemas.ts
@@ -71320,7 +71467,7 @@ import { realpath as realpath17 } from "node:fs/promises";
71320
71467
  import { join as join28 } from "node:path";
71321
71468
 
71322
71469
  // src/chief-code-delivery.ts
71323
- import { createHash as createHash17, randomUUID as randomUUID12 } from "node:crypto";
71470
+ import { createHash as createHash18, randomUUID as randomUUID12 } from "node:crypto";
71324
71471
  import { lstat as lstat12, mkdir as mkdir12, readFile as readFile9, realpath as realpath16, writeFile as writeFile7 } from "node:fs/promises";
71325
71472
  import { join as join27, resolve as resolve20 } from "node:path";
71326
71473
  init_execution();
@@ -71415,7 +71562,7 @@ function recordServiceShutdown(mission, unconfirmedTermination) {
71415
71562
 
71416
71563
  // src/chief-code-delivery-git.ts
71417
71564
  import { execFile as execFile2 } from "node:child_process";
71418
- import { createHash as createHash16 } from "node:crypto";
71565
+ import { createHash as createHash17 } from "node:crypto";
71419
71566
  import { lstat as lstat11, mkdtemp, realpath as realpath15, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
71420
71567
  import { isAbsolute as isAbsolute12, join as join26, relative as relative11, resolve as resolve19, sep as sep11 } from "node:path";
71421
71568
  import { promisify as promisify2 } from "node:util";
@@ -71531,7 +71678,7 @@ async function prepareDeliveryPatch(workspace, baseSha, allowedPaths, directory)
71531
71678
  ], env);
71532
71679
  const treeSha = (await gitRead(workspace, ["write-tree"], env)).trim();
71533
71680
  await writeFile6(patchPath, patch, { encoding: "utf8", mode: 384, flag: "wx" });
71534
- return { treeSha, patchSha256: createHash16("sha256").update(patch).digest("hex"), changedPaths, patchPath };
71681
+ return { treeSha, patchSha256: createHash17("sha256").update(patch).digest("hex"), changedPaths, patchPath };
71535
71682
  } finally {
71536
71683
  await rm3(indexPath, { force: true });
71537
71684
  await rm3(`${indexPath}.lock`, { force: true });
@@ -71731,7 +71878,7 @@ async function deliverMissionCode(mission, store, signal) {
71731
71878
  }
71732
71879
  if (!delivery.nonce || delivery.verifiedFingerprint !== mission.fingerprint)
71733
71880
  throw new DeliveryBlocked("Restore the prepared delivery nonce and verified fingerprint before resuming.");
71734
- if (createHash17("sha256").update(await readFile9(patchPath)).digest("hex") !== delivery.patchSha256)
71881
+ if (createHash18("sha256").update(await readFile9(patchPath)).digest("hex") !== delivery.patchSha256)
71735
71882
  throw new DeliveryBlocked("Prepared patch bytes changed. Preserve the delivery record and restore its original patch.");
71736
71883
  const message = `${delivery.policy.message}
71737
71884
 
@@ -72036,7 +72183,7 @@ function applyResumeOptions(mission, goal, options) {
72036
72183
  }
72037
72184
 
72038
72185
  // src/mission-jobs.ts
72039
- import { createHash as createHash18 } from "node:crypto";
72186
+ import { createHash as createHash19 } from "node:crypto";
72040
72187
  import { lstat as lstat13, mkdir as mkdir13, readdir as readdir8, readFile as readFile10 } from "node:fs/promises";
72041
72188
  import { join as join29 } from "node:path";
72042
72189
  init_atomic_json();
@@ -72057,7 +72204,7 @@ var jobSchema = object({
72057
72204
  cancelRequestedAt: string2().optional()
72058
72205
  });
72059
72206
  function digest6(value) {
72060
- return createHash18("sha256").update(value).digest("hex");
72207
+ return createHash19("sha256").update(value).digest("hex");
72061
72208
  }
72062
72209
  function jobLiveness(job) {
72063
72210
  if (job.phase !== "started" || !job.pid)
@@ -72462,7 +72609,7 @@ var executeContainerCommand = (command) => new Promise((resolve, reject) => {
72462
72609
  });
72463
72610
 
72464
72611
  // ../../packages/core/src/chief/container-observation-text.ts
72465
- import { createHash as createHash19 } from "node:crypto";
72612
+ import { createHash as createHash20 } from "node:crypto";
72466
72613
  var secretName = /(?:password|passwd|secret|token|(?:api|access|private)[_-]?key|credential|authorization|cookie)/i;
72467
72614
  function sanitizeContainerText(value, env) {
72468
72615
  const secrets = Object.entries(env).filter(([name, secret]) => secretName.test(name) && Boolean(secret)).flatMap(([, secret]) => [
@@ -72477,7 +72624,7 @@ function sanitizeContainerText(value, env) {
72477
72624
  return escaped.length ? reduced.replace(new RegExp(escaped.join("|"), "g"), "[redacted]") : reduced;
72478
72625
  }
72479
72626
  function containerDigest(value) {
72480
- return createHash19("sha256").update(JSON.stringify(value)).digest("hex");
72627
+ return createHash20("sha256").update(JSON.stringify(value)).digest("hex");
72481
72628
  }
72482
72629
  function containerErrorEvidence(text) {
72483
72630
  return text.split(/\r?\n/).filter((line) => /\b(?:error|fatal|panic|exception|traceback|segmentation fault|out of memory)\b/i.test(line)).filter((line) => !/\b(?:0|zero|no|without)\s+errors?\b|\berror(?:s)?\s*[=:]\s*0\b/i.test(line)).map((line) => line.replace(/^\d{4}-\d\d-\d\d[T ][\d:.]+(?:Z|[+-]\d\d:\d\d)?\s+/, "").trim()).filter(Boolean).slice(-20);
@@ -72956,7 +73103,7 @@ async function recordContinuousAcceptance(operation) {
72956
73103
  }
72957
73104
 
72958
73105
  // ../../packages/core/src/chief/continuous-operation.ts
72959
- import { createHash as createHash20, randomUUID as randomUUID13 } from "node:crypto";
73106
+ import { createHash as createHash21, randomUUID as randomUUID13 } from "node:crypto";
72960
73107
 
72961
73108
  // ../../packages/core/src/chief/continuous-acceptance.ts
72962
73109
  async function acceptContinuousChild(operation, mission, ports, save, now) {
@@ -73012,7 +73159,7 @@ async function acceptContinuousChild(operation, mission, ports, save, now) {
73012
73159
  // ../../packages/core/src/chief/continuous-operation.ts
73013
73160
  init_execution();
73014
73161
  function continuousDecisionKey(decision, observationFingerprint, observationRevision) {
73015
- return createHash20("sha256").update(JSON.stringify({ goal: decision.goal, evidence: decision.evidence, observationFingerprint, observationRevision })).digest("hex");
73162
+ return createHash21("sha256").update(JSON.stringify({ goal: decision.goal, evidence: decision.evidence, observationFingerprint, observationRevision })).digest("hex");
73016
73163
  }
73017
73164
  async function runContinuousOperation(operation, ports) {
73018
73165
  operationSchema.parse(operation);
@@ -73076,7 +73223,7 @@ async function runContinuousOperation(operation, ports) {
73076
73223
  const previous = operation.recovery?.target === "child" && operation.recovery.checkpointId === mission.id ? operation.recovery : undefined;
73077
73224
  const prior = previous?.attempts ?? 0;
73078
73225
  const failedAttempts = previous?.failedAttempts ?? prior;
73079
- const waitKey = scheduledChiefWait(mission) ? createHash20("sha256").update(JSON.stringify({
73226
+ const waitKey = scheduledChiefWait(mission) ? createHash21("sha256").update(JSON.stringify({
73080
73227
  decision: mission.supervision?.decisions.at(-1),
73081
73228
  nextRunAt: mission.execution?.nextRunAt
73082
73229
  })).digest("hex") : undefined;
@@ -73169,13 +73316,17 @@ async function runContinuousOperation(operation, ports) {
73169
73316
  };
73170
73317
  if (operation.phase === "completed")
73171
73318
  return operation;
73319
+ const observingResumedChild = ["paused", "running", "accepting"].includes(operation.phase) && operation.recovery?.target === "child" && operation.recovery.checkpointId === operation.currentMissionId && operation.recovery.disposition === "protected";
73320
+ if (observingResumedChild && operation.recovery)
73321
+ operation.recovery.reason = "Operation resumed; observing the original child checkpoint before deciding recovery. Previous protection evidence remains in the child checkpoint; its protections and spent limits remain in force.";
73172
73322
  if (operation.phase === "paused") {
73173
73323
  operation.phase = operation.resumePhase ?? (operation.currentMissionId ? "running" : operation.nextRunAt ? "waiting" : "deciding");
73174
73324
  operation.resumePhase = undefined;
73175
73325
  operation.pauseKind = undefined;
73176
73326
  operation.error = undefined;
73177
73327
  await save();
73178
- }
73328
+ } else if (observingResumedChild)
73329
+ await save();
73179
73330
  try {
73180
73331
  while (true) {
73181
73332
  if (ports.signal?.aborted)
@@ -73217,6 +73368,12 @@ async function runContinuousOperation(operation, ports) {
73217
73368
  return pause(`Completed child ${id} is missing. Restore its saved mission record before continuing.`);
73218
73369
  mission = await ports.runMission(operation, id, decision.goal, operation.baseline.path);
73219
73370
  } else if (mission.status !== "completed" && mission.status !== "paused" && mission.status !== "failed") {
73371
+ const recovery = operation.recovery;
73372
+ if (recovery?.target === "child" && recovery.checkpointId === id && recovery.disposition === "protected" && !mission.tasks.some((task) => task.effectState === "running") && automaticMissionRecovery(mission, Date.parse(now())).retry) {
73373
+ recovery.disposition = "retrying";
73374
+ recovery.reason = `The original child resumed ${mission.status}; joining its saved coordinator without spending another recovery attempt.`;
73375
+ await save();
73376
+ }
73220
73377
  mission = await ports.runMission(operation, id, decision.goal, operation.baseline.path);
73221
73378
  }
73222
73379
  assertIdentity(mission);
@@ -73329,12 +73486,12 @@ async function runContinuousOperation(operation, ports) {
73329
73486
 
73330
73487
  // ../../packages/core/src/chief/continuous-source-integration.ts
73331
73488
  init_zod();
73332
- import { createHash as createHash22 } from "node:crypto";
73489
+ import { createHash as createHash23 } from "node:crypto";
73333
73490
  import { lstat as lstat18, mkdir as mkdir17, readdir as readdir10, readFile as readFile15, realpath as realpath22, writeFile as writeFile10 } from "node:fs/promises";
73334
73491
  import { join as join35, resolve as resolve25 } from "node:path";
73335
73492
 
73336
73493
  // ../../packages/core/src/chief/content-transaction.ts
73337
- import { createHash as createHash21 } from "node:crypto";
73494
+ import { createHash as createHash22 } from "node:crypto";
73338
73495
  import { readFile as readFile12 } from "node:fs/promises";
73339
73496
 
73340
73497
  // ../../packages/core/src/chief/parallel-git.ts
@@ -73429,7 +73586,7 @@ async function parallelTreeImages(workspace, tree) {
73429
73586
  async function integrateContentTransaction(workspace, transaction, hooks) {
73430
73587
  await hooks.assertLive?.();
73431
73588
  const patch = await readFile12(transaction.patchPath);
73432
- if (createHash21("sha256").update(patch).digest("hex") !== transaction.patchSha256)
73589
+ if (createHash22("sha256").update(patch).digest("hex") !== transaction.patchSha256)
73433
73590
  throw new Error("Integration patch changed. Restore its saved SHA256 before integration.");
73434
73591
  const current = await captureParallelBaseline(workspace);
73435
73592
  const images = await parallelTreeImages(workspace, current.tree);
@@ -73999,7 +74156,7 @@ async function integrateContinuousSource(operation, previous, next, signal) {
73999
74156
  let patch = await sourcePatch(next.path, previous.baselineTree, next.baselineTree, changes.filter((change) => !projected || change.path !== ".gitignore").map((change) => change.path));
74000
74157
  if (projected && changes.some((change) => change.path === ".gitignore"))
74001
74158
  patch += projected.patch;
74002
- const patchSha256 = createHash22("sha256").update(patch).digest("hex");
74159
+ const patchSha256 = createHash23("sha256").update(patch).digest("hex");
74003
74160
  const identity = {
74004
74161
  version: 1,
74005
74162
  operationId: operation.id,
@@ -74793,7 +74950,7 @@ function ensureLatestOmaCli(options = {}) {
74793
74950
  }
74794
74951
 
74795
74952
  // ../../packages/core/src/oma/receipt-storage.ts
74796
- import { createHash as createHash23 } from "node:crypto";
74953
+ import { createHash as createHash24 } from "node:crypto";
74797
74954
  import { lstatSync as lstatSync2, readdirSync, realpathSync as realpathSync6 } from "node:fs";
74798
74955
  import { homedir as homedir7 } from "node:os";
74799
74956
  import { basename, dirname as dirname8, isAbsolute as isAbsolute13, join as join37, relative as relative13, resolve as resolve26, sep as sep13 } from "node:path";
@@ -74809,7 +74966,7 @@ function omaReceiptDirectories(workspace, options = {}) {
74809
74966
  if (!/^(0|[1-9][0-9]{0,9})$/.test(profile))
74810
74967
  throw new Error("OMA_PROFILE must be a non-negative profile number");
74811
74968
  const stateHome = env.OMA_STATE_HOME === undefined ? absolutePath(env.OMA_HOME || join37(options.home ?? homedir7(), ".oma"), "OMA_HOME") : absolutePath(env.OMA_STATE_HOME, "OMA_STATE_HOME");
74812
- const project = createHash23("sha256").update(realpathSync6(resolve26(workspace))).digest("hex");
74969
+ const project = createHash24("sha256").update(realpathSync6(resolve26(workspace))).digest("hex");
74813
74970
  return [
74814
74971
  join37(stateHome, "u", profile, "projects", project, "agent-runs"),
74815
74972
  ...profile === "0" ? [join37(resolve26(workspace), ".agents", "state", "agent-runs")] : []
@@ -75310,7 +75467,7 @@ init_worktree_lifecycle();
75310
75467
  init_execution();
75311
75468
 
75312
75469
  // ../../packages/core/src/chief/parallel-workspace.ts
75313
- import { createHash as createHash24 } from "node:crypto";
75470
+ import { createHash as createHash25 } from "node:crypto";
75314
75471
  import { lstat as lstat19, mkdir as mkdir19, readFile as readFile16, realpath as realpath24, rm as rm6, writeFile as writeFile12 } from "node:fs/promises";
75315
75472
  import { dirname as dirname10, join as join39, sep as sep15 } from "node:path";
75316
75473
  init_parallel_contract();
@@ -75333,7 +75490,7 @@ async function assertMissionWorkspace(mission) {
75333
75490
 
75334
75491
  // ../../packages/core/src/chief/parallel-workspace.ts
75335
75492
  init_parallel_contract();
75336
- var hash2 = (value) => createHash24("sha256").update(value).digest("hex");
75493
+ var hash2 = (value) => createHash25("sha256").update(value).digest("hex");
75337
75494
  var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
75338
75495
  function identity3(missionId, taskId, attempt) {
75339
75496
  if (!taskId || taskId.length > 200 || !Number.isSafeInteger(attempt) || attempt < 1)
@@ -75916,7 +76073,7 @@ function resetHandoffForRetry(mission, retry) {
75916
76073
  }
75917
76074
 
75918
76075
  // ../../packages/core/src/chief/structured-stage.ts
75919
- import { createHash as createHash25 } from "node:crypto";
76076
+ import { createHash as createHash26 } from "node:crypto";
75920
76077
 
75921
76078
  // ../../packages/core/src/chief/coordinator-state.ts
75922
76079
  class ContractViolation extends Error {
@@ -76114,7 +76271,7 @@ function legacyPlanningTimeout(mission, stage, key) {
76114
76271
  }
76115
76272
  async function runStructuredStage(options) {
76116
76273
  const { mission, stage, prompt, run, parse, save } = options;
76117
- const key = createHash25("sha256").update(`${stage}\x00${options.scopeKey ?? stage}`).digest("hex");
76274
+ const key = createHash26("sha256").update(`${stage}\x00${options.scopeKey ?? stage}`).digest("hex");
76118
76275
  let attempts = 0;
76119
76276
  let reason = "No validated response is available for this saved context.";
76120
76277
  const legacy = legacyPlanningTimeout(mission, stage, key);
@@ -76377,7 +76534,7 @@ import { randomUUID as randomUUID17 } from "node:crypto";
76377
76534
  import { join as join44 } from "node:path";
76378
76535
  init_execution();
76379
76536
  // src/chief-delivery.ts
76380
- import { createHash as createHash27 } from "node:crypto";
76537
+ import { createHash as createHash28 } from "node:crypto";
76381
76538
  import { mkdir as mkdir21, writeFile as writeFile13 } from "node:fs/promises";
76382
76539
  import { join as join43 } from "node:path";
76383
76540
 
@@ -76764,7 +76921,7 @@ init_report_delivery_contract();
76764
76921
  init_zod();
76765
76922
  init_atomic_json();
76766
76923
  init_report_delivery_contract();
76767
- import { createHash as createHash26 } from "node:crypto";
76924
+ import { createHash as createHash27 } from "node:crypto";
76768
76925
  import { constants as constants13 } from "node:fs";
76769
76926
  import { mkdir as mkdir20, open as open15, readdir as readdir11, readFile as readFile17, realpath as realpath25 } from "node:fs/promises";
76770
76927
  import { isAbsolute as isAbsolute15, join as join41, relative as relative15, resolve as resolve29 } from "node:path";
@@ -76791,7 +76948,7 @@ var outboxRecordSchema = strictObject({
76791
76948
  message: string2().max(1000)
76792
76949
  }).refine((record) => record.nextPart <= record.parts && (record.status !== "delivered" || record.nextPart === record.parts));
76793
76950
  function sha2562(content) {
76794
- return createHash26("sha256").update(content).digest("hex");
76951
+ return createHash27("sha256").update(content).digest("hex");
76795
76952
  }
76796
76953
  function receipt(record) {
76797
76954
  const {
@@ -76874,7 +77031,7 @@ async function verifiedAttachment(attachment, artifactRoot, readBytes) {
76874
77031
  if (!stat.isFile() || stat.size !== attachment.sizeBytes)
76875
77032
  throw failure;
76876
77033
  if (!readBytes) {
76877
- const digest = createHash26("sha256");
77034
+ const digest = createHash27("sha256");
76878
77035
  for await (const chunk of file.createReadStream({ autoClose: false }))
76879
77036
  digest.update(chunk);
76880
77037
  if (digest.digest("hex") !== attachment.sha256)
@@ -77121,7 +77278,7 @@ ${explanation.eli5}`);
77121
77278
  const artifactRoot = join43(repository, ".agent-valley/captures");
77122
77279
  if (config.reporting?.destinations.length) {
77123
77280
  const bytes = Buffer.from(report);
77124
- const sha256 = createHash27("sha256").update(bytes).digest("hex");
77281
+ const sha256 = createHash28("sha256").update(bytes).digest("hex");
77125
77282
  const reportDirectory = join43(artifactRoot, mission.id);
77126
77283
  const attachmentPath = join43(reportDirectory, `report-${sha256}.md`);
77127
77284
  await mkdir21(reportDirectory, { recursive: true, mode: 448 });
@@ -79054,11 +79211,11 @@ import { realpath as realpath30 } from "node:fs/promises";
79054
79211
 
79055
79212
  // ../../packages/core/src/chief/continuous-retention.ts
79056
79213
  init_zod();
79057
- import { createHash as createHash28 } from "node:crypto";
79214
+ import { createHash as createHash29 } from "node:crypto";
79058
79215
  import { constants as constants17 } from "node:fs";
79059
79216
  import { lstat as lstat23, open as open18, readdir as readdir12, realpath as realpath29, rename as rename4, rm as rm7 } from "node:fs/promises";
79060
79217
  import { dirname as dirname11, join as join51, resolve as resolve32 } from "node:path";
79061
- var digest7 = (content) => createHash28("sha256").update(content).digest("hex");
79218
+ var digest7 = (content) => createHash29("sha256").update(content).digest("hex");
79062
79219
  var sha2 = string2().regex(/^[a-f0-9]{40,64}$/);
79063
79220
  var preparedSchema = strictObject({
79064
79221
  version: literal(1),
@@ -134086,7 +134243,7 @@ async function readStatus(port) {
134086
134243
  init_team_schema();
134087
134244
  init_yaml_loader();
134088
134245
  init_credentials();
134089
- import { createHash as createHash30, randomUUID as randomUUID25 } from "node:crypto";
134246
+ import { createHash as createHash31, randomUUID as randomUUID25 } from "node:crypto";
134090
134247
  import { closeSync, fsyncSync, mkdirSync as mkdirSync8, openSync, readFileSync as readFileSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync7 } from "node:fs";
134091
134248
  import { dirname as dirname17, resolve as resolve47 } from "node:path";
134092
134249
 
@@ -134096,7 +134253,7 @@ init_team_event_codec();
134096
134253
  import { isDeepStrictEqual } from "node:util";
134097
134254
 
134098
134255
  // ../../packages/core/src/relay/turso-team-store.ts
134099
- import { createHash as createHash29, randomBytes as randomBytes3 } from "node:crypto";
134256
+ import { createHash as createHash30, randomBytes as randomBytes3 } from "node:crypto";
134100
134257
  import { createClient as createClient2 } from "@libsql/client";
134101
134258
 
134102
134259
  // ../../node_modules/.bun/drizzle-orm@0.45.4+0c7b544c7f7b61ad/node_modules/drizzle-orm/entity.js
@@ -138389,7 +138546,7 @@ var invalidRequest = () => new TeamRelayError("invalid_request", "Supply a valid
138389
138546
  function tokenHash(token) {
138390
138547
  if (!/^avt_[A-Za-z0-9_-]{43}$/.test(token))
138391
138548
  throw sessionError();
138392
- return createHash29("sha256").update(token).digest("hex");
138549
+ return createHash30("sha256").update(token).digest("hex");
138393
138550
  }
138394
138551
  function assertTeamForeignKeys(value) {
138395
138552
  if (value !== 1)
@@ -138743,7 +138900,7 @@ function expiration(days) {
138743
138900
  async function removeUndeliveredToken(store, token) {
138744
138901
  await store.client.execute({
138745
138902
  sql: "delete from team_tokens where token_hash=?",
138746
- args: [createHash30("sha256").update(token).digest("hex")]
138903
+ args: [createHash31("sha256").update(token).digest("hex")]
138747
138904
  });
138748
138905
  }
138749
138906
  function registerTeamCommands(program, deps = {}) {
@@ -7519,6 +7519,11 @@ var init_operations = __esm(() => {
7519
7519
  outcome: _enum(["pending", "passed", "rejected", "failed"]),
7520
7520
  executionState: _enum(["running", "settled", "unknown"]).optional(),
7521
7521
  executionRecovery: _enum(["local-process", "reconcile"]).optional(),
7522
+ routingExclusion: strictObject({
7523
+ reason: literal("coordinator-cancelled"),
7524
+ dispatchAt: exports_iso.datetime(),
7525
+ pauseAt: exports_iso.datetime()
7526
+ }).optional(),
7522
7527
  routingReason: text3.optional(),
7523
7528
  evidence: text3.optional(),
7524
7529
  fingerprint: text3.optional()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-valley",
3
- "version": "4.8.0",
3
+ "version": "4.8.2",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=26.10.0",