agent-valley 1.1.0 → 2.0.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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Give a Chief Director a goal for service improvement, refactoring, usability, or revenue growth. It uses installed OMA skills and Technical Director, Design Director, and Marketing Director personas to choose skills, assign Actors, review work, repair or replan, and verify progress. Its report explains the decisions, reasons, results, and verification evidence. Actors work in isolated Git worktrees; Linear/GitHub issues also support queued, parallel work.
4
4
 
5
- For ongoing improvement, use `av operate "Improve usability, reliability and revenue"`. The Chief selects successive goals using accepted changes, previous reports, measured outcomes and available tools. `av operations` shows progress; Ctrl-C pauses and `av operate --resume ID` continues. See [continuous Chief operation](./docs/guides/chief-continuous.md) for limits, cloud/MCP access and recovery.
5
+ Orders continue improving by default. Use `av order "Improve usability, reliability and revenue"`. Add `--once` to complete one goal and exit. The Chief selects successive goals using accepted changes, previous reports, measured outcomes and available tools. `av operations` shows progress; Ctrl-C pauses and `av order --resume ID` continues. See [continuous Chief operation](./docs/guides/chief-continuous.md) for limits, cloud/MCP access and recovery.
6
6
 
7
7
  > Read this in: [한국어](./README.ko.md)
8
8
 
@@ -59,9 +59,9 @@ export PATH="$HOME/.local/bin:$PATH"
59
59
 
60
60
  The interactive wizard asks for the target repository and Chief Director CLI and model, and can save a trusted verification command. Agent-led setup passes the initiating agent's own runtime and model choice to `av setup --yes --json`. Setup guides provider preparation and prepares the latest OMA CLI and skills in the target repository. OMA preparation is the default. Browser sign-in and unsupported readiness checks remain concrete pending actions. The repository must have at least one commit. After setup is ready, give AV a goal with `av order "Fix the login failure"`. See the [installation, first-task and recovery guide](./docs/guides/environment-setup.md).
61
61
 
62
- The Chief Director consults its Technical Director, Design Director and Marketing Director concurrently, turns the goal into success criteria and executable checks, creates 4–8 Actors including those advisers, and assigns work using available supported CLIs and installed OMA skills. Up to three independent Actors run in separate worktrees by default; reviewed changes are integrated before dependent work and final verification. Use `--parallel 1` for serial execution. The Technical Director focuses on cost, reuse, standardization and dependencies; the Design Director focuses on usability, user tests, data and retention, including a preference for dark patterns; the Marketing Director focuses on promotion, acquisition, revenue and ROI. The Chief Director reviews evidence and decides whether to repair, reassign, or replan when work fails. Each order produces a report with a plain-language explanation, checks, and remaining limits. Orders start without a tracker or daemon. `--actor` and `--model` override the saved Chief Director choice for one order; `--actors` supplies your own team. See [Chief Director orders and named actors](./docs/guides/chief-missions.md).
62
+ The Chief Director consults its Technical Director, Design Director and Marketing Director concurrently, turns the goal into success criteria and executable checks, creates 4–8 Actors including those advisers, and assigns work using available supported CLIs and installed OMA skills. Up to three independent Actors run in separate worktrees by default; reviewed changes are integrated before dependent work and final verification. Use `--parallel 1` for serial execution. The Technical Director focuses on cost, reuse, standardization and dependencies; the Design Director focuses on usability, user tests, data and retention, including a preference for dark patterns; the Marketing Director focuses on promotion, acquisition, revenue and ROI. The Chief Director reviews evidence and decides whether to repair, reassign, or replan when work fails. Each verified improvement produces a report with a plain-language explanation, checks, and remaining limits. Orders start without a tracker or daemon. `--actor` and `--model` override the saved Chief Director choice for one order; `--actors` supplies your own team. See [Chief Director orders and named actors](./docs/guides/chief-missions.md).
63
63
 
64
- Without `--verify` or a saved command, the Chief Director designs fixed file, JSON, or explicit test checks bound to the original success criteria. A supplied command remains immutable. The foreground supervisor resumes child crashes and scheduled retries within saved limits; `--no-supervise` runs directly and `av missions --watch` restores eligible checkpoints after a stopped supervisor or machine. Authentication and uncertain external effects pause for inspection. `--runs`, `--duration`, `--rounds`, and the configured-price estimate limit `--cost` can be increased on resume without resetting spent budgets. Unknown cost pauses when a cost limit is set; in-flight or subscription charges are not an exact billing cap.
64
+ Without `--verify` or a saved command, the Chief Director designs fixed file, JSON, or explicit test checks bound to the original success criteria. A supplied command remains immutable. The foreground supervisor resumes child crashes and scheduled retries within saved limits; `--once --no-supervise` runs a single mission directly and `av missions --watch` restores eligible checkpoints after a stopped supervisor or machine. Authentication and uncertain external effects pause for inspection. Single-mission resume can increase `--runs`, `--duration`, `--rounds`, and the configured-price estimate limit `--cost` without resetting spent budgets. Continuous orders retain the original child settings; their active decision checkpoint supports run, duration and cost adjustments described in the continuous guide. Unknown cost pauses when a cost limit is set; in-flight or subscription charges are not an exact billing cap.
65
65
 
66
66
  The Chief Director chooses how to execute and supervise the work. The user retains operational responsibility for the goal and resulting actions; the report records those actions and their verification evidence.
67
67
 
@@ -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": "1.1.0",
4
+ "version": "2.0.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"
@@ -9,22 +9,22 @@ Use the configured `av` MCP server for the repository the user selected. The Chi
9
9
 
10
10
  ## Prevent recursive delegation
11
11
 
12
- Before `av_order`, `av_resume`, `av_operate` or `av_operation_resume`, check the current process environment for `AGENT_VALLEY_MANAGED_RUN` when the client has a local shell/environment tool. Check only this variable; do not dump the environment or read credentials. If its value is `1`, or your assignment identifies you as an AV Chief Director or Actor, perform your assigned work directly. Do not start or resume another AV mission or operation, or run a nested AV setup.
12
+ Before `av_order`, `av_resume` or `av_operation_resume`, check the current process environment for `AGENT_VALLEY_MANAGED_RUN` when the client has a local shell/environment tool. Check only this variable; do not dump the environment or read credentials. If its value is `1`, or your assignment identifies you as an AV Chief Director or Actor, perform your assigned work directly. Do not start or resume another AV mission or operation, or run a nested AV setup.
13
13
 
14
14
  For web clients without a local environment tool, read `av_missions` from the configured AV server. Its structured `executionContext` must report `managed: false` and `delegationAllowed: true` before delegation. Use its advertised workspace instead of inventing a local repository path. A managed assignment or a local `AGENT_VALLEY_MANAGED_RUN=1` always takes priority over a remote server's context. If neither the local environment nor the server establishes the context, do not delegate until it is established.
15
15
 
16
16
  ## Start the goal
17
17
 
18
18
  1. Resolve the intended repository from the configured server's `av_missions` workspace, or to an absolute local path when local tools are available. Confirm it matches the user's intended project. Keep the user's goal, deliverables, constraints, and acceptance criteria intact. A request for an explanation or comparison alone does not start a mission.
19
- 2. Check `av_missions` for an existing mission when the request might continue earlier work. Use `av_status(missionId)` to inspect it before deciding to resume. Avoid creating duplicate orders.
20
- 3. Before the first `av_order` call, generate and retain an opaque `requestId` together with its exact input. Call it with that ID, `goal`, and, when needed, `workspace`. Supply `verify`, `parallel`, `runs`, `duration`, or `cost` only for user-specified overrides. Retry an uncertain or timed-out submission with the same ID and identical input; inspect missions before resubmitting. Never introduce a new request ID merely because the original response was lost.
21
- 4. Keep the returned mission ID. An accepted or started order is incomplete. Inspect `av_status` at reasonable intervals and read `av_report` when a report is available. Do not resubmit the goal because a long run has not finished.
19
+ 2. Check `av_operations` and `av_missions` for saved work when the request might continue earlier work. Inspect its corresponding status before deciding to resume. Avoid creating duplicate orders.
20
+ 3. Before the first `av_order` call, generate and retain an opaque `requestId` together with its exact input. Call it with that ID, `goal`, and, when needed, `workspace`. The default continues selecting verified improvements within that goal. Set `once: true` when the user asks to complete one goal and stop. Supply `verify`, `parallel`, `runs`, `duration`, `cost`, `cycles`, or `interval` only for user-specified overrides; `cycles` and `interval` apply only to continuous work. Retry an uncertain or timed-out submission with the same ID and identical input, including the execution mode. Never introduce a new request ID merely because the original response was lost.
21
+ 4. Keep the returned `operationId` for default continuous work or `missionId` for `once: true`. An accepted or started order is incomplete. Inspect the corresponding status/report tools at reasonable intervals. Do not resubmit the goal because a long run has not finished.
22
22
 
23
23
  AV reads the saved repository settings to select the Chief Director and available Actors. Do not invent model availability, measurements, or a successful outcome.
24
24
 
25
25
  ## Continuous improvement
26
26
 
27
- For a request to keep improving the service, use `av_operate` with the user's operating `charter`. Check `av_operations` for existing work first. Generate and retain a `requestId` with the exact input before submission; uncertain retries reuse both. Supply `cycles`, `interval` or per-mission execution limits only for authorized overrides. The default continues until stopped or paused and can incur ongoing model charges. Limits apply to each improvement and decision checkpoint, not lifetime operation spending.
27
+ `av_order` uses the user's `goal` as the operating charter unless `once: true` is supplied. Preserve the goal's scope and constraints across improvements. The default continues until stopped or paused and can incur ongoing model charges. Limits apply to each improvement and decision checkpoint, not lifetime operation spending. A user-specified `cycles` bounds cumulative verified improvements. There is one submission tool for both execution modes.
28
28
 
29
29
  Keep the returned operation ID. Read `av_operation_status(operationId)` and `av_operation_report(operationId)` for progress and decisions. Use `av_status` and `av_report` with its child mission IDs for actual verification and measurements. A running continuous operation is not a completed service improvement merely because submission succeeded.
30
30
 
@@ -40,7 +40,7 @@ Installed tools or configured MCP names do not prove login or service access. Ch
40
40
  - `av_resume(missionId, retry?, runs?, duration?, cost?, rounds?, requestId?)`: continue an existing mission. Preserve spent budgets; increase limits only within the user's authorization. Generate and retain a request ID before the first resume call and reuse it with identical input for every retry of that request.
41
41
  - `av_cancel(missionId)`: cancel when the user asks to stop the mission.
42
42
 
43
- An accepted or `starting` response is incomplete. Reconnecting to MCP does not cancel or restart the independently supervised mission; inspect the saved mission before choosing a next action. Treat `completed` as success only with the report's verified result. Explain `paused` or `failed` using its recorded reason and the next required action. `waiting`, scheduled observation, planning, or active Actor work is still incomplete. State the mission ID and current status if the client session ends before completion. A report file or delivery request does not prove that a third-party provider accepted an attachment.
43
+ An accepted or `starting` response is incomplete. Reconnecting to MCP does not cancel or restart independently supervised work; inspect its saved operation or mission before choosing a next action. Treat `completed` as success only with the report's verified result. Explain `paused` or `failed` using its recorded reason and the next required action. `waiting`, scheduled observation, planning, or active Actor work is still incomplete. State the operation or mission ID and current status if the client session ends while work remains. A report file or delivery request does not prove that a third-party provider accepted an attachment.
44
44
 
45
45
  Explain the result in plain language: what changed, how it was checked, remaining work, and material limits. Distinguish observed metrics and token usage from estimates and unknown costs. Link the actual artifacts the report identifies; never claim an upload, deployment, or merge from a planned action.
46
46
 
package/dist/index.js CHANGED
@@ -47161,13 +47161,29 @@ var budgets = {
47161
47161
  duration: number2().int().min(1).max(604800).optional(),
47162
47162
  cost: number2().finite().positive().optional()
47163
47163
  };
47164
+ var continuousControls = {
47165
+ cycles: number2().int().min(1).max(1e6).optional(),
47166
+ interval: number2().int().min(1).max(86400).optional()
47167
+ };
47164
47168
  var mcpOrderSchema = strictObject({
47165
47169
  workspace: string2().min(1).max(4096).optional(),
47166
47170
  goal: string2().trim().min(1).max(32000),
47167
47171
  requestId,
47168
47172
  verify: string2().max(32000).optional(),
47169
47173
  parallel: number2().int().min(1).max(8).optional(),
47174
+ once: boolean2().optional(),
47175
+ ...continuousControls,
47170
47176
  ...budgets
47177
+ }).superRefine((input, context) => {
47178
+ if (input.once) {
47179
+ for (const key of ["cycles", "interval"])
47180
+ if (input[key] !== undefined)
47181
+ context.addIssue({
47182
+ code: "custom",
47183
+ message: `${key} applies to continuous orders. Omit it when once is true.`,
47184
+ path: [key]
47185
+ });
47186
+ }
47171
47187
  });
47172
47188
  var mcpResumeSchema = strictObject({
47173
47189
  missionId: missionIdSchema,
@@ -47179,8 +47195,7 @@ var mcpResumeSchema = strictObject({
47179
47195
  var mcpOperateSchema = strictObject({
47180
47196
  charter: string2().trim().min(1).max(32000),
47181
47197
  requestId,
47182
- cycles: number2().int().min(1).max(1e6).optional(),
47183
- interval: number2().int().min(1).max(86400).optional(),
47198
+ ...continuousControls,
47184
47199
  verify: string2().max(32000).optional(),
47185
47200
  parallel: number2().int().min(1).max(8).optional(),
47186
47201
  ...budgets
@@ -47209,14 +47224,14 @@ function createAvMcpServer(api, options) {
47209
47224
  const managed = (options.env ?? process.env).AGENT_VALLEY_MANAGED_RUN === "1";
47210
47225
  const server = new McpServer({ name: "agent-valley", version: AV_VERSION }, {
47211
47226
  maxToolInputElements: 100,
47212
- instructions: "Submit single goals to av_order. For ongoing service improvement, use av_operate and inspect av_operations, av_operation_status and av_operation_report. Execution is asynchronous. Reports describe actual evidence and blockers. Each server is bound to one workspace; managed Actors cannot start or resume nested orders or operations."
47227
+ instructions: "Submit goals to av_order for continuous Chief supervision by default and inspect av_operations, av_operation_status and av_operation_report. Set once:true to verify one goal and inspect av_missions, av_status and av_report. Execution is asynchronous. Reports describe actual evidence and blockers. Each server is bound to one workspace; managed Actors cannot start or resume nested orders or operations."
47213
47228
  });
47214
47229
  const assertManaged = () => {
47215
47230
  if (managed)
47216
47231
  throw new Error("Managed Actors cannot start or resume nested AV missions. Return findings to the supervising Chief Director.");
47217
47232
  };
47218
47233
  server.registerTool("av_order", {
47219
- description: "Start a durable Chief Director mission in the configured repository and return its identity immediately. requestId deduplicates repeated submissions. verify is an optional trusted completion command executed by the mission.",
47234
+ description: "Start continuous Chief Director supervision by default and return operationId immediately. The Chief selects successive goals, executes, verifies and reports them until stopped or paused; cycles optionally bounds verified improvements. Set once:true to complete one goal and return missionId. Budgets apply to each mission and decision, not a global spending cap. requestId deduplicates submissions. verify is an optional trusted completion command.",
47220
47235
  inputSchema: mcpOrderSchema,
47221
47236
  annotations: write
47222
47237
  }, (input) => toolResult(async () => {
@@ -47265,22 +47280,13 @@ function createAvMcpServer(api, options) {
47265
47280
  const report = await api.report(missionId);
47266
47281
  return { contents: [{ uri: uri.href, mimeType: "text/markdown", text: report.markdown }] };
47267
47282
  });
47268
- const operate = api.operate?.bind(api);
47269
47283
  const operations = api.operations?.bind(api);
47270
47284
  const operationStatus = api.operationStatus?.bind(api);
47271
47285
  const operationReport = api.operationReport?.bind(api);
47272
47286
  const operationResume = api.operationResume?.bind(api);
47273
47287
  const operationCancel = api.operationCancel?.bind(api);
47274
- if (operate && operations && operationStatus && operationReport && operationResume && operationCancel) {
47288
+ if (operations && operationStatus && operationReport && operationResume && operationCancel) {
47275
47289
  const operationIdentity = strictObject({ operationId: missionIdSchema });
47276
- server.registerTool("av_operate", {
47277
- description: "Start continued service improvement under a durable charter. The Chief chooses successive goals, executes and verifies them, and reports decisions. Default runs until stopped or paused; cycles optionally bounds verified improvements. Budgets apply to each mission and decision, not a global spending cap. requestId deduplicates submissions.",
47278
- inputSchema: mcpOperateSchema,
47279
- annotations: write
47280
- }, (input) => toolResult(async () => {
47281
- assertManaged();
47282
- return operate(input);
47283
- }));
47284
47290
  server.registerTool("av_operations", {
47285
47291
  description: "List saved continuous operations with progress, active child and pause reasons.",
47286
47292
  inputSchema: strictObject({}),
@@ -69734,8 +69740,8 @@ Branch: ${mission.workspace.branch}`);
69734
69740
 
69735
69741
  // src/chief-supervisor.ts
69736
69742
  function orderWorkerArgs(goal, options, id) {
69737
- const args = ["order", "--worker"];
69738
- const excluded = new Set(["worker", "missionId", "supervise"]);
69743
+ const args = ["order", "--once", "--worker"];
69744
+ const excluded = new Set(["once", "worker", "missionId", "supervise"]);
69739
69745
  for (const [key, value] of Object.entries(options)) {
69740
69746
  if (excluded.has(key) || value === undefined || value === false)
69741
69747
  continue;
@@ -69966,7 +69972,7 @@ async function newOperation(charter, options, root, id) {
69966
69972
  if (options.accountRun !== undefined || options.accountCost !== undefined)
69967
69973
  throw new Error("Use --resume <operation-id> to reconcile an active decision run's observed cost.");
69968
69974
  if (!charter?.trim() || charter.length > 32000)
69969
- throw new Error('Give a nonempty operating charter up to 32 KB: av operate "Keep improving service quality and revenue" --workspace /repo.');
69975
+ throw new Error('Give a nonempty goal up to 32 KB: av order "Keep improving service quality and revenue" --workspace /repo.');
69970
69976
  const config = await resolveOrderConfig(root, options);
69971
69977
  const chief = config.personas.find((actor) => actor.id === config.chiefId);
69972
69978
  if (!chief)
@@ -70041,7 +70047,7 @@ function renderOperationReport(operation) {
70041
70047
  if (entry.evidence.length)
70042
70048
  lines.push(`Evidence: ${entry.evidence.join("; ")}`);
70043
70049
  }
70044
- lines.push("", `Resume: av operate --resume ${operation.id}`, "");
70050
+ lines.push("", `Resume: av order --resume ${operation.id}`, "");
70045
70051
  return lines.join(`
70046
70052
  `);
70047
70053
  }
@@ -70127,7 +70133,7 @@ async function runOperation(charter, options, root = process.cwd(), dependencies
70127
70133
  await saveOperationReport(root, operation);
70128
70134
  console.log(`Operation ${id}
70129
70135
  Charter: ${operation.charter}
70130
- Resume: av operate --resume ${id}`);
70136
+ Resume: av order --resume ${id}`);
70131
70137
  const missions = new MissionStore(join35(root, ".agent-valley", "missions"));
70132
70138
  return await runContinuousOperation(operation, {
70133
70139
  signal: controller.signal,
@@ -70144,8 +70150,9 @@ Resume: av operate --resume ${id}`);
70144
70150
  return;
70145
70151
  throw error;
70146
70152
  });
70147
- return superviseOrder(saved ? undefined : goal, saved ? { resume: missionId } : {
70153
+ return superviseOrder(saved ? undefined : goal, saved ? { resume: missionId, once: true } : {
70148
70154
  ...current.settings,
70155
+ once: true,
70149
70156
  missionId,
70150
70157
  baselineWorkspace: baselinePath,
70151
70158
  operationId: current.id
@@ -70170,7 +70177,7 @@ Resume: av operate --resume ${id}`);
70170
70177
  }
70171
70178
  }
70172
70179
  function registerContinuousCommands(program) {
70173
- program.command("operate [charter]").description("Continuously select, verify and measure improvements under a saved operating charter").option("--workspace <path>", "Target Git repository (defaults to av.yaml)").option("--verify <command>", "Trusted completion check for each improvement").option("--actor <type>", "Pinned Chief Director CLI").option("--model <id>", "Pinned Chief Director model").option("--director <id>", "Chief Director Actor ID").option("--actors <file>", "Configured YAML Actor roster").option("--oma", "Require OMA completion receipts for workers").option("--timeout <seconds>", "Timeout per Actor/check").option("--repairs <count>", "Repair limit per task/final review").option("--rounds <count>", "Recovery decision limit per improvement").option("--parallel <count>", "Actor concurrency per improvement").option("--runs <count>", "Initial Actor call limit; on resume, increase the active decision checkpoint limit").option("--duration <seconds>", "Initial wall-time limit; on resume, increase the active decision checkpoint limit").option("--cost <usd>", "Initial estimated cost limit; on resume, increase the active decision checkpoint limit").option("--account-run <run-id>", "On resume, reconcile an active decision run whose usage/cost was lost").option("--account-cost <usd>", "Observed USD cost for the decision --account-run after inspecting billing").option("--cycles <count>", "Cumulative verified improvement limit; default continues until stopped").option("--interval <seconds>", "Wait before selecting again when no new goal is justified (default 300)").option("--resume <id>", "Resume the saved charter and accepted work").addOption(new Option("--operation-id <id>", "Internal operation identity").hideHelp()).action(async (charter, options) => {
70180
+ program.command("operate [charter]", { hidden: true }).description("Deprecated alias for av order; resume existing operating charters").option("--workspace <path>", "Target Git repository (defaults to av.yaml)").option("--verify <command>", "Trusted completion check for each improvement").option("--actor <type>", "Pinned Chief Director CLI").option("--model <id>", "Pinned Chief Director model").option("--director <id>", "Chief Director Actor ID").option("--actors <file>", "Configured YAML Actor roster").option("--oma", "Require OMA completion receipts for workers").option("--timeout <seconds>", "Timeout per Actor/check").option("--repairs <count>", "Repair limit per task/final review").option("--rounds <count>", "Recovery decision limit per improvement").option("--parallel <count>", "Actor concurrency per improvement").option("--runs <count>", "Initial Actor call limit; on resume, increase the active decision checkpoint limit").option("--duration <seconds>", "Initial wall-time limit; on resume, increase the active decision checkpoint limit").option("--cost <usd>", "Initial estimated cost limit; on resume, increase the active decision checkpoint limit").option("--account-run <run-id>", "On resume, reconcile an active decision run whose usage/cost was lost").option("--account-cost <usd>", "Observed USD cost for the decision --account-run after inspecting billing").option("--cycles <count>", "Cumulative verified improvement limit; default continues until stopped").option("--interval <seconds>", "Wait before selecting again when no new goal is justified (default 300)").option("--resume <id>", "Resume the saved charter and accepted work").addOption(new Option("--operation-id <id>", "Internal operation identity").hideHelp()).action(async (charter, options) => {
70174
70181
  const operation = await runOperation(charter, options);
70175
70182
  console.log(`Operation ${operation.id}: ${operation.phase}; ${operation.completedCycles} verified improvements.`);
70176
70183
  if (operation.error)
@@ -70185,7 +70192,7 @@ function registerContinuousCommands(program) {
70185
70192
  }
70186
70193
  const operations = await storage.list();
70187
70194
  if (!operations.length)
70188
- console.log("No operations yet. Run av operate --help.");
70195
+ console.log("No operations yet. Run av order --help.");
70189
70196
  for (const operation of operations) {
70190
70197
  console.log(`${operation.id} ${operation.phase} ${operation.completedCycles} completed ${operation.charter.slice(0, 100)}`);
70191
70198
  if (operation.currentMissionId)
@@ -70230,6 +70237,13 @@ class OperationApi {
70230
70237
  this.store = new ContinuousOperationStore(join36(root, ".agent-valley/operations"));
70231
70238
  this.jobs = new MissionJobs(root, "operation-jobs");
70232
70239
  }
70240
+ order(raw) {
70241
+ const input = mcpOrderSchema.parse(raw);
70242
+ if (input.once)
70243
+ throw new Error("Use the mission API's order entry with once:true for a single goal.");
70244
+ const { goal, once: _once, workspace: _workspace, ...options } = input;
70245
+ return this.operate({ charter: goal, ...options });
70246
+ }
70233
70247
  operate(raw) {
70234
70248
  assertNotManagedRun(this.dependencies.env);
70235
70249
  const input = mcpOperateSchema.parse(raw);
@@ -70279,7 +70293,7 @@ class OperationApi {
70279
70293
  if (operation && ["completed", "paused"].includes(operation.phase))
70280
70294
  return this.status(id);
70281
70295
  if (!job)
70282
- throw new Error("No API launch receipt exists. Stop the original av operate process.");
70296
+ throw new Error("No API launch receipt exists. Stop the original av order process.");
70283
70297
  const current = (this.dependencies.liveness ?? jobLiveness)(job);
70284
70298
  if (current === "unknown")
70285
70299
  throw new Error("Operation process identity is uncertain. Inspect the original process; no signal was sent.");
@@ -70314,7 +70328,7 @@ class OperationApi {
70314
70328
  const previous = await this.jobs.latest(id);
70315
70329
  if (previous && (this.dependencies.liveness ?? jobLiveness)(previous) !== "stopped")
70316
70330
  throw new Error("Operation has an active or uncertain supervisor. Inspect av_operation_status before resuming.");
70317
- const args = ["operate"];
70331
+ const args = ["order"];
70318
70332
  if (resuming) {
70319
70333
  const operation = await this.load(id);
70320
70334
  if (!operation)
@@ -70413,7 +70427,7 @@ function orderOptions(input) {
70413
70427
  return options;
70414
70428
  }
70415
70429
  function launchArgs(goal, options, missionId) {
70416
- const args = ["order"];
70430
+ const args = ["order", "--once"];
70417
70431
  for (const [key, value] of Object.entries(options)) {
70418
70432
  if (value === undefined || value === false)
70419
70433
  continue;
@@ -70450,6 +70464,8 @@ class MissionApi {
70450
70464
  store;
70451
70465
  jobs;
70452
70466
  operationApi;
70467
+ operationJobs;
70468
+ orders = Promise.resolve();
70453
70469
  submissions = Promise.resolve();
70454
70470
  closed = false;
70455
70471
  constructor(projectRoot, workspace, dependencies) {
@@ -70459,6 +70475,7 @@ class MissionApi {
70459
70475
  this.store = new MissionStore(join37(projectRoot, ".agent-valley/missions"));
70460
70476
  this.jobs = new MissionJobs(projectRoot);
70461
70477
  this.operationApi = new OperationApi(projectRoot, workspace, dependencies);
70478
+ this.operationJobs = new MissionJobs(projectRoot, "operation-jobs");
70462
70479
  }
70463
70480
  static async create(workspace, dependencies = {}) {
70464
70481
  if (!isAbsolute12(workspace))
@@ -70473,7 +70490,8 @@ class MissionApi {
70473
70490
  return this.workspace;
70474
70491
  }
70475
70492
  operate(input) {
70476
- return this.operationApi.operate(input);
70493
+ const { charter, ...options } = mcpOperateSchema.parse(input);
70494
+ return this.order({ goal: charter, ...options });
70477
70495
  }
70478
70496
  operations() {
70479
70497
  return this.operationApi.list();
@@ -70495,8 +70513,18 @@ class MissionApi {
70495
70513
  const input = mcpOrderSchema.parse(raw);
70496
70514
  if (input.workspace && (!isAbsolute12(input.workspace) || await realpath21(input.workspace) !== this.workspace))
70497
70515
  throw new Error("This AV server is bound to another workspace. Start av mcp --workspace for the target repository.");
70498
- const options = { ...orderOptions(input), workspace: this.workspace };
70499
- return this.submit("order", input, options, randomUUID17(), input.goal);
70516
+ return this.serializeOrder(async () => {
70517
+ if (input.requestId) {
70518
+ const other = await (input.once ? this.operationJobs : this.jobs).findRequest(input.requestId);
70519
+ if (other)
70520
+ throw new Error("requestId already belongs to different inputs or order mode. Reuse the original mode and inputs or choose a new requestId.");
70521
+ }
70522
+ if (!input.once)
70523
+ return this.operationApi.order(input);
70524
+ const { once: _once, cycles: _cycles, interval: _interval, ...single } = input;
70525
+ const options = { ...orderOptions(single), workspace: this.workspace };
70526
+ return this.submit("order", single, options, randomUUID17(), input.goal);
70527
+ });
70500
70528
  }
70501
70529
  async resume(raw) {
70502
70530
  assertNotManagedRun(this.dependencies.env);
@@ -70573,6 +70601,7 @@ class MissionApi {
70573
70601
  });
70574
70602
  }
70575
70603
  async close() {
70604
+ await this.orders.catch(() => {});
70576
70605
  await this.submissions.catch(() => {});
70577
70606
  await this.operationApi.close();
70578
70607
  this.closed = true;
@@ -70642,6 +70671,20 @@ class MissionApi {
70642
70671
  this.submissions = result.catch(() => {});
70643
70672
  return result;
70644
70673
  }
70674
+ serializeOrder(operation) {
70675
+ this.assertOpen();
70676
+ const result = this.orders.then(async () => {
70677
+ const directory = await ensureAvDirectory(this.projectRoot, ["control", "jobs"]);
70678
+ const release = await new MissionStore(directory).lock("order-entry");
70679
+ try {
70680
+ return await operation();
70681
+ } finally {
70682
+ await release();
70683
+ }
70684
+ });
70685
+ this.orders = result.catch(() => {});
70686
+ return result;
70687
+ }
70645
70688
  async load(id) {
70646
70689
  await ensureAvDirectory(this.projectRoot, ["missions"]);
70647
70690
  try {
@@ -72632,13 +72675,66 @@ Resume: bun av order --resume ${id}`);
72632
72675
  }
72633
72676
  }
72634
72677
  }
72678
+ async function dispatchOrder(goal, options, root = process.cwd(), dependencies = {}) {
72679
+ assertNotManagedRun();
72680
+ root = await realpath23(root);
72681
+ let single = Boolean(options.once || options.worker || options.missionId || options.baselineWorkspace);
72682
+ if (options.resume && !single) {
72683
+ const missing = (error) => {
72684
+ if (error.code === "ENOENT")
72685
+ return;
72686
+ throw error;
72687
+ };
72688
+ const [operation, mission] = await Promise.all([
72689
+ operationStore(root).load(options.resume).catch(missing),
72690
+ new MissionStore(join40(root, ".agent-valley", "missions")).load(options.resume).catch(missing)
72691
+ ]);
72692
+ if (operation && mission)
72693
+ throw new Error(`Saved ID ${options.resume} names both an operation and a mission. Use --once to resume the mission; inspect av operations before resuming the operation.`);
72694
+ if (!operation && !mission)
72695
+ throw new Error(`No saved order or operation ${options.resume} was found. Run av missions or av operations and use its recorded ID.`);
72696
+ single = Boolean(mission);
72697
+ }
72698
+ const normalized = Object.fromEntries(Object.entries({
72699
+ ...options,
72700
+ actor: options.actor ?? options.agent,
72701
+ director: options.director ?? options.chief,
72702
+ actors: options.actors ?? options.personas
72703
+ }).filter(([key, value]) => value !== undefined && !["agent", "chief", "personas"].includes(key)));
72704
+ if (single) {
72705
+ if (normalized.cycles !== undefined || normalized.interval !== undefined)
72706
+ throw new Error("--cycles and --interval apply to continuing orders. Omit them when using --once or resuming a single mission.");
72707
+ const { once: _once, cycles: _cycles, interval: _interval, ...missionOptions } = normalized;
72708
+ return missionOptions.worker || missionOptions.supervise === false ? (dependencies.single ?? runOrder)(goal, missionOptions, root) : (dependencies.supervised ?? superviseOrder)(goal, missionOptions, root);
72709
+ }
72710
+ if (normalized.supervise === false)
72711
+ throw new Error("Continuing orders require supervision. Add --once to run one goal with --no-supervise.");
72712
+ if (normalized.retry || normalized.resolveEffect !== undefined || normalized.effectResult !== undefined)
72713
+ throw new Error("Resume the saved child mission ID for --retry or external-effect reconciliation. Run av operations to find its current child; the continuing order retains its charter.");
72714
+ const {
72715
+ once: _once,
72716
+ supervise: _supervise,
72717
+ worker: _worker,
72718
+ missionId: _missionId,
72719
+ baselineWorkspace: _baseline,
72720
+ ...operationOptions
72721
+ } = normalized;
72722
+ return (dependencies.continuous ?? runOperation)(goal, operationOptions, root);
72723
+ }
72635
72724
  function registerChiefCommands(program) {
72636
72725
  registerContinuousCommands(program);
72637
- program.command("order [goal]").description("Give the Chief Director a goal; delegate Actors, review, repair and verify in an isolated worktree").option("--workspace <path>", "Target Git repository (defaults to av.yaml)").option("--verify <command>", "Trusted completion check (defaults to av.yaml)").option("--actor <type>", "Chief Director CLI (default: saved actor.type, otherwise an authenticated CLI)").option("--model <id>", "Chief Director model (default: actor.model from config, otherwise the CLI default)").option("--director <id>", "Chief Director Actor ID").option("--actors <file>", "Use a configured YAML Actor roster instead of generating goal-specific Actors").addOption(new Option("--agent <type>", "Legacy alias for --actor").hideHelp()).addOption(new Option("--chief <id>", "Legacy alias for --director").hideHelp()).addOption(new Option("--personas <file>", "Legacy alias for --actors").hideHelp()).option("--oma", "Require OMA completion receipts for workers (installed skill selection is automatic)").option("--timeout <seconds>", "Timeout per actor/check (default 600 or actor.timeout)").option("--repairs <count>", "Repair limit per task/final review (default 2)").option("--rounds <count>", "Chief Director recovery decision limit, preserved on resume (default 8, maximum 50)").option("--parallel <count>", "Independent Actor concurrency (default 3, maximum 8)").option("--runs <count>", "Total Actor call limit; may be increased on resume (default 200)").option("--duration <seconds>", "Mission wall-time limit; may be increased on resume (default 86400)").option("--cost <usd>", "Configured-price estimated cost limit; unknown cost pauses further calls").option("--account-run <run-id>", "Reconcile a finished run whose usage/cost was lost").option("--account-cost <usd>", "Operator-observed USD cost for --account-run; stored separately from native usage").option("--retry", "Resume after repairing a blocker; retain prior evidence and spent budget").option("--resolve-effect <task-id>", "Reconcile an interrupted external action before resuming").option("--effect-result <result>", "External destination inspection result: completed or not-applied").option("--no-supervise", "Run directly without worker crash restart or scheduled observation polling").addOption(new Option("--worker", "Internal supervised worker").hideHelp()).addOption(new Option("--mission-id <id>", "Internal mission identity").hideHelp()).addOption(new Option("--baseline-workspace <path>", "Internal accepted operation snapshot").hideHelp()).addOption(new Option("--operation-id <id>", "Internal operation identity").hideHelp()).addOption(new Option("--native-model", "Internal pinned Chief native model default").hideHelp()).option("--resume <id>", "Resume a saved order with its original acceptance contract").action(async (goal, options) => {
72638
- const mission = options.worker || options.supervise === false ? await runOrder(goal, options) : await superviseOrder(goal, options, process.cwd());
72639
- if (!options.worker)
72640
- printOrderOutcome(mission);
72641
- process.exitCode = orderExitCode(mission);
72726
+ program.command("order [goal]").description("Give the Chief Director a goal; continuously select, execute, review and verify improvements").option("--once", "Stop after one verified goal instead of continuing improvements").option("--cycles <count>", "Cumulative verified improvement limit; default continues until stopped").option("--interval <seconds>", "Wait before selecting again when no new goal is justified (default 300)").option("--workspace <path>", "Target Git repository (defaults to av.yaml)").option("--verify <command>", "Trusted completion check (defaults to av.yaml)").option("--actor <type>", "Chief Director CLI (default: saved actor.type, otherwise an authenticated CLI)").option("--model <id>", "Chief Director model (default: actor.model from config, otherwise the CLI default)").option("--director <id>", "Chief Director Actor ID").option("--actors <file>", "Use a configured YAML Actor roster instead of generating goal-specific Actors").addOption(new Option("--agent <type>", "Legacy alias for --actor").hideHelp()).addOption(new Option("--chief <id>", "Legacy alias for --director").hideHelp()).addOption(new Option("--personas <file>", "Legacy alias for --actors").hideHelp()).option("--oma", "Require OMA completion receipts for workers (installed skill selection is automatic)").option("--timeout <seconds>", "Timeout per actor/check (default 600 or actor.timeout)").option("--repairs <count>", "Repair limit per task/final review (default 2)").option("--rounds <count>", "Chief Director recovery decision limit, preserved on resume (default 8, maximum 50)").option("--parallel <count>", "Independent Actor concurrency (default 3, maximum 8)").option("--runs <count>", "Actor call limit per goal/decision; may be increased on saved checkpoint resume (default 200)").option("--duration <seconds>", "Wall-time limit per goal/decision; may be increased on resume (default 86400)").option("--cost <usd>", "Configured-price estimated cost limit; unknown cost pauses further calls").option("--account-run <run-id>", "Reconcile a finished run whose usage/cost was lost").option("--account-cost <usd>", "Operator-observed USD cost for --account-run; stored separately from native usage").option("--retry", "Resume after repairing a blocker; retain prior evidence and spent budget").option("--resolve-effect <task-id>", "Reconcile an interrupted external action before resuming").option("--effect-result <result>", "External destination inspection result: completed or not-applied").option("--no-supervise", "With --once, run directly without worker crash restart or observation polling").addOption(new Option("--worker", "Internal supervised worker").hideHelp()).addOption(new Option("--mission-id <id>", "Internal mission identity").hideHelp()).addOption(new Option("--baseline-workspace <path>", "Internal accepted operation snapshot").hideHelp()).addOption(new Option("--operation-id <id>", "Internal operation identity").hideHelp()).addOption(new Option("--native-model", "Internal pinned Chief native model default").hideHelp()).option("--resume <id>", "Resume the saved continuing order or single mission with its original contract").action(async (goal, options) => {
72727
+ const result = await dispatchOrder(goal, options);
72728
+ if ("phase" in result) {
72729
+ console.log(`Order ${result.id}: ${result.phase}; ${result.completedCycles} verified improvements.`);
72730
+ if (result.error)
72731
+ console.error(result.error);
72732
+ process.exitCode = result.phase === "paused" ? 2 : 0;
72733
+ } else {
72734
+ if (!options.worker)
72735
+ printOrderOutcome(result);
72736
+ process.exitCode = orderExitCode(result);
72737
+ }
72642
72738
  });
72643
72739
  program.command("missions").description("List saved Chief Director orders and their workspaces").option("--watch", "Resume due or interrupted orders from their saved checkpoints").action(async (options) => {
72644
72740
  if (options.watch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-valley",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=26.10.0",