agent-valley 4.9.8 → 4.10.0

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.9.8",
4
+ "version": "4.10.0",
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
@@ -7134,7 +7134,10 @@ function chiefRecoveryStopped(mission) {
7134
7134
  return !Number.isFinite(stoppedAt) || !Number.isFinite(intervenedAt) || intervenedAt <= stoppedAt;
7135
7135
  }
7136
7136
  function isNativeAgentTimeout(reason) {
7137
- return /^Agent timed out after \d+(?:\.\d+)?s$/i.test(reason);
7137
+ return /^Agent timed out after \d+(?:\.\d+)?s$/i.test(reason) || isNativeAgentStall(reason);
7138
+ }
7139
+ function isNativeAgentStall(reason) {
7140
+ return /^Agent stalled: no activity for \d+s$/i.test(reason);
7138
7141
  }
7139
7142
  function isUnavailableAgentModel(reason) {
7140
7143
  const normalized = reason.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ");
@@ -35786,11 +35789,21 @@ async function registerBuiltinSessions() {
35786
35789
  }
35787
35790
 
35788
35791
  // ../../packages/core/src/sessions/adapters/agent-runner-service.ts
35792
+ var DEFAULT_INACTIVITY_TIMEOUT_SEC = 1800;
35793
+ function resolveInactivityTimeoutSec(requested, source = process.env) {
35794
+ const configured = Number.parseInt(source.AV_AGENT_INACTIVITY_TIMEOUT_SEC ?? "", 10);
35795
+ const seconds = requested ?? (Number.isFinite(configured) ? configured : DEFAULT_INACTIVITY_TIMEOUT_SEC);
35796
+ return Number.isFinite(seconds) && seconds > 0 ? Math.round(seconds) : 0;
35797
+ }
35798
+ function agentStallMessage(seconds) {
35799
+ return `Agent stalled: no activity for ${seconds}s`;
35800
+ }
35789
35801
  var MAX_OUTPUT_SNIPPET = 24;
35790
35802
 
35791
35803
  class AgentRunnerService {
35792
35804
  activeSessions = new Map;
35793
35805
  activeTimers = new Map;
35806
+ activeIdleTimers = new Map;
35794
35807
  lastOutputs = new Map;
35795
35808
  activeAgentTypes = new Map;
35796
35809
  cancelAttempts = new Map;
@@ -35889,6 +35902,10 @@ class AgentRunnerService {
35889
35902
  if (timer)
35890
35903
  clearTimeout(timer);
35891
35904
  this.activeTimers.delete(attempt.id);
35905
+ const idleTimer = this.activeIdleTimers.get(attempt.id);
35906
+ if (idleTimer)
35907
+ clearTimeout(idleTimer);
35908
+ this.activeIdleTimers.delete(attempt.id);
35892
35909
  this.activeSessions.delete(attempt.id);
35893
35910
  this.activeAgentTypes.delete(attempt.id);
35894
35911
  this.lastOutputs.delete(attempt.id);
@@ -35933,17 +35950,43 @@ class AgentRunnerService {
35933
35950
  handled = true;
35934
35951
  cleanup(false);
35935
35952
  });
35953
+ const inactivitySec = resolveInactivityTimeoutSec(options.inactivityTimeout);
35954
+ const touch = () => {
35955
+ if (!inactivitySec || handled)
35956
+ return;
35957
+ const previous = this.activeIdleTimers.get(attempt.id);
35958
+ if (previous)
35959
+ clearTimeout(previous);
35960
+ this.activeIdleTimers.set(attempt.id, setTimeout(async () => {
35961
+ this.activeIdleTimers.delete(attempt.id);
35962
+ if (handled || !this.activeSessions.has(attempt.id))
35963
+ return;
35964
+ logger.warn("orchestrator", "Agent stalled", {
35965
+ attemptId: attempt.id,
35966
+ issueId: attempt.issueId,
35967
+ inactivityMs: inactivitySec * 1000
35968
+ });
35969
+ handled = true;
35970
+ await this.kill(attempt.id);
35971
+ callbacks.onError({ code: "TIMEOUT", message: agentStallMessage(inactivitySec), recoverable: true });
35972
+ }, inactivitySec * 1000));
35973
+ };
35936
35974
  session.on("spawned", (e) => {
35975
+ touch();
35937
35976
  if (!handled)
35938
35977
  callbacks.onSpawned?.(e.pid);
35939
35978
  });
35940
35979
  session.on("heartbeat", (e) => {
35980
+ touch();
35941
35981
  if (!handled)
35942
35982
  callbacks.onHeartbeat(e.timestamp);
35943
35983
  });
35984
+ session.on("toolUse", () => touch());
35985
+ session.on("fileChange", () => touch());
35944
35986
  session.on("output", (e) => {
35945
35987
  if (handled)
35946
35988
  return;
35989
+ touch();
35947
35990
  callbacks.onOutput?.(e.chunk);
35948
35991
  const snippet = e.chunk.trim().replace(/\s+/g, " ").slice(-MAX_OUTPUT_SNIPPET);
35949
35992
  if (snippet)
@@ -36009,6 +36052,7 @@ class AgentRunnerService {
36009
36052
  executing.then(forgetExecution, forgetExecution);
36010
36053
  if (handled)
36011
36054
  return;
36055
+ touch();
36012
36056
  const timer = setTimeout(async () => {
36013
36057
  if (this.activeSessions.has(attempt.id)) {
36014
36058
  logger.warn("orchestrator", "Agent timed out", {
@@ -57384,7 +57428,7 @@ var goalVerificationCheckSchema = discriminatedUnion("kind", [
57384
57428
  kind: literal("file"),
57385
57429
  path: path4,
57386
57430
  minBytes: number2().int().min(1).max(4194304).default(1),
57387
- contains: array(text6).min(1).max(10).optional(),
57431
+ contains: array(text6).min(1).max(20).optional(),
57388
57432
  sha256: sha256.optional()
57389
57433
  }),
57390
57434
  strictObject({
@@ -57393,26 +57437,32 @@ var goalVerificationCheckSchema = discriminatedUnion("kind", [
57393
57437
  pointer: string2().max(1024).refine((value) => value === "" || /^(?:\/(?:[^~]|~[01])*)+$/.test(value), {
57394
57438
  message: "Use an RFC 6901 JSON pointer such as /engines/node."
57395
57439
  }),
57396
- equals: union([string2().max(4000), number2().finite(), boolean2(), _null3()])
57440
+ equals: union([
57441
+ string2().max(4000),
57442
+ number2().finite(),
57443
+ boolean2(),
57444
+ _null3(),
57445
+ array(union([string2().max(4000), number2().finite(), boolean2(), _null3()])).max(50)
57446
+ ])
57397
57447
  }),
57398
57448
  strictObject({
57399
57449
  kind: literal("command"),
57400
57450
  program: _enum(["git", "node", "bun", "cargo"]),
57401
57451
  args: array(string2().min(1).max(1024)).min(1).max(30),
57402
57452
  timeoutMs: number2().int().min(100).max(3600000).default(120000),
57403
- stdoutIncludes: array(text6).min(1).max(10).optional()
57453
+ stdoutIncludes: array(text6).min(1).max(20).optional()
57404
57454
  }).refine((check) => safeVerificationCommand(check.program, check.args), {
57405
57455
  message: "Use explicit node/bun/Vitest tests, read-only Git, or exactly cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace. Other Cargo commands or flags, shells, scripts, installs and publishing are forbidden."
57406
57456
  })
57407
57457
  ]);
57408
57458
  var goalVerificationContractSchema = strictObject({
57409
57459
  version: literal(1),
57410
- criteria: array(strictObject({ criterion: text6, checks: array(goalVerificationCheckSchema).min(1).max(10) })).min(1).max(20)
57460
+ criteria: array(strictObject({ criterion: text6, checks: array(goalVerificationCheckSchema).min(1).max(20) })).min(1).max(20)
57411
57461
  }).superRefine((contract, ctx) => {
57412
57462
  if (new Set(contract.criteria.map((entry) => entry.criterion)).size !== contract.criteria.length)
57413
57463
  ctx.addIssue({ code: "custom", message: "Assess each success criterion exactly once." });
57414
- if (contract.criteria.reduce((sum, entry) => sum + entry.checks.length, 0) > 40)
57415
- ctx.addIssue({ code: "custom", message: "Keep the verification contract within 40 executable checks." });
57464
+ if (contract.criteria.reduce((sum, entry) => sum + entry.checks.length, 0) > 80)
57465
+ ctx.addIssue({ code: "custom", message: "Keep the verification contract within 80 executable checks." });
57416
57466
  });
57417
57467
  function validateGoalVerificationContract(input, successCriteria) {
57418
57468
  const contract = goalVerificationContractSchema.parse(input);
@@ -57885,11 +57935,12 @@ async function inspectCheck(check, root, options, budget) {
57885
57935
  } catch {
57886
57936
  return { ...common, passed: false, summary: checkSummary(false, "Observed file is not valid UTF-8 JSON.") };
57887
57937
  }
57888
- const passed = Object.is(jsonPointerValue(json, check.pointer), check.equals);
57938
+ const observed = jsonPointerValue(json, check.pointer);
57939
+ const passed = Array.isArray(check.equals) ? Array.isArray(observed) && observed.length === check.equals.length && check.equals.every((expected, index) => Object.is(observed[index], expected)) : Object.is(observed, check.equals);
57889
57940
  return {
57890
57941
  ...common,
57891
57942
  passed,
57892
- summary: checkSummary(passed, passed ? "Observed JSON pointer equals its required scalar." : "Observed JSON pointer is missing or has a different value.")
57943
+ summary: checkSummary(passed, passed ? "Observed JSON pointer equals its required value." : "Observed JSON pointer is missing or has a different value.")
57893
57944
  };
57894
57945
  }
57895
57946
  async function executeGoalVerification(input, workspaceRoot, options) {
@@ -76196,6 +76247,8 @@ function taskDecompositionGuidance(mission, phase) {
76196
76247
  var CHIEF_DIRECTOR_ROLE = "Act as the Chief Director, the autonomous executive responsible for realizing the user's intent. Understand the product, customers, market and operating context; interpret abstract goals, identify opportunities and anticipate consequences. Synthesize Technical Director, Design Director and Marketing Director advice, resolve their competing interests and make the final business judgment. Form a strategy, mobilize Actors and installed skills, test assumptions against actual outcomes and adapt the strategy when evidence changes. Maximize the user's benefit and profit with initiative, including uncertain or unconventional opportunities. Own the team's decisions, execution and explanation; the operator retains ultimate operational responsibility.";
76197
76248
  var CHIEF_DECISION_RESPONSIBILITY = "The user supplies intent and receives reports. Own decisions across discovery, product direction, technology, design, marketing, execution and evaluation within the original charter, available permissions and saved limits. Resolve ambiguity with justified assumptions rather than handing a menu of choices back to the user. Consider several plausible explanations and opportunities, choose a course of action and explain why it serves the outcome. Seek evidence through authorized research, experiments and Actor work; distinguish measured facts from judgment and uncertainty. Reconsider a failing strategy and act on useful opportunities without waiting for step-by-step instructions. Report decisions made, alternatives considered, actual results, lessons and next actions. Missing authorization, credentials or trustworthy evidence remain unmet prerequisites; never invent them or claim completion without evidence.";
76198
76249
  var PARALLEL_SOURCE_PROVENANCE = "Parallel source provenance: in each sourceEvidence record, baselineHead is the accepted committed source baseline for cross-workspace citations, and baselineTree is the product tree of that exact commit (git rev-parse <baselineHead>^{tree}). When supplied, snapshotCommit and snapshotRef identify the Actor's initial isolated input snapshot, and snapshotTree is that snapshot's input tree, which may include an uncommitted source overlay absent from the committed baseline. workerRef preserves the Actor's checked-out HEAD at collection; uncommitted task edits may be absent from that commit and must be verified in the integrated worktree, using the delivery receipt when available. Label observations of the Actor's local HEAD, snapshot or uncommitted diffs with that scope and the actual inspected revision and paths; do not claim local changes are already in the committed baseline. An Actor-local file being tracked at its snapshot revision does not imply that it is already tracked in the review checkout. The Actor's snapshot HEAD and the review workspace's current HEAD can differ. Preserve actual source hashes; never substitute another checkout's HEAD or invent a missing revision.";
76250
+ var EXHAUSTIVE_REVIEW_RULE = "Enumerate every blocking defect across the whole deliverable in this single review so that one repair round can resolve them all; do not reserve findings for a later round, and do not escalate the acceptance bar beyond the task's own acceptance and the mission goal.";
76251
+ var REPAIR_REVIEW_RULE = "This is a repair review: previousReview lists the findings the Actor was asked to fix. Verify each one is resolved. Additional blocking findings are limited to defects in the repaired or newly changed code and severe pre-existing defects (data loss, deadlock, leaked permits or locks, security exposure, silent failure). Record other pre-existing concerns in summary as non-blocking notes, not findings.";
76199
76252
  function context(mission) {
76200
76253
  const unavailableAdvice = unavailableDirectorAdvice(mission);
76201
76254
  return JSON.stringify({
@@ -76263,7 +76316,7 @@ function planPrompt(mission) {
76263
76316
  "OMA is required: every task's Actor must have at least one relevant installed OMA skill. The runtime applies a matching installed OMA agent definition and all its declared skills before native execution. Empty skill assignments or missing agent definitions block dispatch; select a suitable skilled Actor rather than bypassing OMA. Additional native subagent delegation remains available when the assignment needs it."
76264
76317
  ] : [],
76265
76318
  mission.verificationMode === "chief" ? [
76266
- 'Design verificationContract: {"version":1,"criteria":[{"criterion":"exact goalBrief success criterion","checks":[{"kind":"file","path":"report.md","minBytes":200,"contains":["required finding"]}]}]}. Cover every success criterion exactly once. File checks inspect actual relative regular files; JSON checks use {"kind":"json","path":"package.json","pointer":"/engines/node","equals":">=26"}. Behavioral goals need relevant executable tests: {"kind":"command","program":"node","args":["node_modules/vitest/vitest.mjs","run","tests/login.test.ts"]}, or node --test / bun test with explicit test paths.',
76319
+ 'Design verificationContract: {"version":1,"criteria":[{"criterion":"exact goalBrief success criterion","checks":[{"kind":"file","path":"report.md","minBytes":200,"contains":["required finding"]}]}]}. Cover every success criterion exactly once. File checks inspect actual relative regular files; JSON checks use {"kind":"json","path":"package.json","pointer":"/engines/node","equals":">=26"}; equals is a string, number, boolean, null or a flat array of those. Each criterion takes at most 20 checks and the contract at most 80. Behavioral goals need relevant executable tests: {"kind":"command","program":"node","args":["node_modules/vitest/vitest.mjs","run","tests/login.test.ts"]}, or node --test / bun test with explicit test paths.',
76267
76320
  'For an authorized Rust workspace build/test goal, native Cargo checks are supported exactly as {"kind":"command","program":"cargo","args":["fmt","--all","--","--check"]}, {"kind":"command","program":"cargo","args":["clippy","--workspace","--all-targets","--","-D","warnings"]}, and {"kind":"command","program":"cargo","args":["test","--workspace"]}. Use one or more of these checks for the corresponding Rust criteria; do not replace required Cargo gates with JavaScript wrappers or report claims. Workers prepare the Rust toolchain, dependencies and lockfile during implementation. Cargo verification runs offline and binds workspace manifests, Rust sources and local tool configuration to the evidence.',
76268
76321
  "These are the complete command shapes. The supplied schema is sufficient; no harness validator-source discovery is needed. No shell, package scripts, other build/install/publish commands, absolute paths, globs or extra flags. A report claiming success is insufficient for a behavioral criterion. Keep checks immutable during recovery; assign workers the needed test/report deliverables."
76269
76322
  ].join(`
@@ -76362,6 +76415,7 @@ function reviewPrompt(mission, task, state) {
76362
76415
  "No container or service observation policy is configured for this mission: do not require a deployment target inventory, target health, availability or recent-error observations, and do not treat the sandbox's deliberate av.yaml read denial as a blocker. Numeric targets in goal criteria mean the goal's own documented targets."
76363
76416
  ],
76364
76417
  "Reject incomplete requirements, missing deliverables, weakened tests, correctness defects, or missing evidence.",
76418
+ ...task ? [EXHAUSTIVE_REVIEW_RULE, ...state?.review ? [REPAIR_REVIEW_RULE] : []] : [],
76365
76419
  ...mission.technicalLeadId ? [
76366
76420
  "The Technical Director's technical preferences are advisory. Do not reject an authorized Chief Director strategy merely for choosing higher cost or a different stack; assess actual goal, acceptance, correctness and evidence."
76367
76421
  ] : [],
@@ -7126,7 +7126,10 @@ function chiefRecoveryStopped(mission) {
7126
7126
  return !Number.isFinite(stoppedAt) || !Number.isFinite(intervenedAt) || intervenedAt <= stoppedAt;
7127
7127
  }
7128
7128
  function isNativeAgentTimeout(reason) {
7129
- return /^Agent timed out after \d+(?:\.\d+)?s$/i.test(reason);
7129
+ return /^Agent timed out after \d+(?:\.\d+)?s$/i.test(reason) || isNativeAgentStall(reason);
7130
+ }
7131
+ function isNativeAgentStall(reason) {
7132
+ return /^Agent stalled: no activity for \d+s$/i.test(reason);
7130
7133
  }
7131
7134
  function isUnavailableAgentModel(reason) {
7132
7135
  const normalized = reason.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-valley",
3
- "version": "4.9.8",
3
+ "version": "4.10.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=26.10.0",