@ancha-labs/cli 0.4.28 → 0.4.30

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.
@@ -93,8 +93,8 @@ ancha run --on cloud
93
93
  - When every attempt ended before the agent did anything (it exited with an error within 5 seconds without a call, or its command could not start), the run's last lines say that first: "Your agent didn't run: it exited with code 1 within 96 ms in all 3 attempts", the end of its log from the cloud machine, the likely fix read from that log, and the commands to run again. The checks that failed because of it are one line; `ancha explain <run id> --all` lists them. With `--json`, `run_finished` carries the same as `agentNeverRan`.
94
94
  - The agent gets Ancha's and the tools' variables, `agent.env`, and the workspace's secrets for the names in `agent.pass_env`, as they were when the run was accepted. Its model providers are `openrouter.ai`, `api.openai.com` and `api.anthropic.com`, or the ones `agent.execution.modelHosts` names.
95
95
  - Model-graded checks and the people in a world run on the workspace's model credit, so a cloud run needs no `OPENROUTER_API_KEY`.
96
- - `--agent`, `--seed`, `--strict`, `--min-pass-rate`, `--allow-unwrapped` and `--idempotency-key` mean what they mean on this computer. `--compare <baseline>` compares with a saved baseline: `ancha baseline save before --from <run id>`, fix the agent, then `--compare before`. A cloud run's keys come from the workspace, so `--pass-env` and `--inherit-env` belong to runs on this computer, and its results live in the workspace, so it takes no `--out` or `--upload`.
97
- - With `--json` the run announces acceptance with `run_submitted` (`run_detached` with `--detach`), carrying `target: "cloud"` and adding `defaulted: true` when the saved login chose cloud. A followed run prints NDJSON events and ends with `run_finished`: `url` is the result, `summary` the verdict with the attempt and check counts, and `next` the commands to run next. The exit codes are `ancha run`'s: 0 when every check passes, 1 when a check failed, 3 when an attempt could not run or be graded, 4 with `--strict` for an endpoint coverage error or a verdict using simulated tool answers, and 2 for a cancelled run.
96
+ - `--agent`, `--seed`, `--strict`, `--allow-simulated`, `--min-pass-rate`, `--allow-unwrapped` and `--idempotency-key` mean what they mean on this computer. `--compare <baseline>` compares with a saved baseline: `ancha baseline save before --from <run id>`, fix the agent, then `--compare before`. A cloud run's keys come from the workspace, so `--pass-env` and `--inherit-env` belong to runs on this computer, and its results live in the workspace, so it takes no `--out` or `--upload`.
97
+ - With `--json` the run announces acceptance with `run_submitted` (`run_detached` with `--detach`), carrying `target: "cloud"` and adding `defaulted: true` when the saved login chose cloud. A followed run prints NDJSON events and ends with `run_finished`: `url` is the result, `summary` the verdict with the attempt and check counts, and `next` the commands to run next. The exit codes are `ancha run`'s: 0 when every check passes, 1 when a check failed, 3 when an attempt could not run or be graded, 4 for an endpoint coverage error with `--strict`, or a verdict using simulated tool answers with `--strict` or in CI, and 2 for a cancelled run.
98
98
 
99
99
  ## Follow a run from anywhere
100
100
 
@@ -152,6 +152,8 @@ npx -y @ancha-labs/cli run --on cloud --attempts 3 --concurrency 3 --json
152
152
 
153
153
  The key needs the Write tier or Admin. `ANCHA_API_KEY` wins over a saved login; never commit it or put it in `ancha.yaml`. A CI step that may be retried passes `--idempotency-key <key>`: the same key and the same run return the original run instead of starting another.
154
154
 
155
+ When `CI=true` or `CI=1` (case-insensitive), a verdict using simulated tool answers exits 4. `--allow-simulated` keeps the ordinary verdict exit code, including with `--strict`; endpoint coverage errors still exit 4 only with `--strict`. Record the tool's answers or wrap the tool so its real logic runs; `ancha docs traces` explains both paths. JSON summaries carry the tests, trials and checks in `strict.simulatedAnswers` and the reason in `strict.message`.
156
+
155
157
  ## What else the workspace holds
156
158
 
157
159
  - `ancha agent` (except `agent detect`), `ancha world list|show|create|update|archive`, `ancha test`, `ancha runs` and `ancha attempt` work on the workspace's agents, worlds, tests and runs, the ones the console shows, and every JSON object they print names its `workspace`. `--local` keeps them on this project's `.ancha/`. `ancha playground` stays on this computer.
@@ -0,0 +1,41 @@
1
+ # A company world
2
+
3
+ Create a NetSuite world from the public pages of a company's website. Ancha extracts a company profile, then generates deterministic books, fictional customers and vendors, a product and service catalog, and 25 tests with answers: 10 read tasks and 15 write workflows.
4
+
5
+ In your agent's project:
6
+
7
+ ```sh
8
+ ancha world company https://www.example.com --tool netsuite
9
+ ancha run ancha/tests/example/*.yaml --on local
10
+ ```
11
+
12
+ Use the exact next command printed by `world company`; its folder is named after the company's profile. Configure your agent with `ancha init --on local` if the project needs an `ancha.yaml`.
13
+
14
+ The profile supplies the company name, customer and vendor categories, offerings, and scale. The books use four subsidiary roles (holdings, platform, US add-on and Europe), USD and EUR, and 18 months of transactions. Amounts, dates, record identities and workflows come from the deterministic NetSuite dataset. People and counterparties are fictional.
15
+
16
+ | Flag | Meaning |
17
+ | --- | --- |
18
+ | `--tool netsuite` | Generate NetSuite books and tests. Required. |
19
+ | `--size s\|m\|l` | Choose the size; otherwise use small, medium or large from the profile, with unknown scale choosing s. |
20
+ | `--profile <file>` | Rebuild from a saved JSON profile using local files, with zero model calls. Use in place of the URL. |
21
+ | `--force` | Replace existing generated files after checking every output path. |
22
+ | `--json` | Print paths, record counts, model calls, known cost and the next command as JSON. |
23
+ | `--on local` | Write files on this computer. |
24
+
25
+ URL mode reads the start page and up to three same-origin business pages, honours `robots.txt` as `ancha-world`, and extracts text without executing scripts. It uses your `OPENROUTER_API_KEY`, or your logged-in workspace's model relay. The model returns a strict company profile, with one repair call when needed.
26
+
27
+ For a company named Example, the command writes:
28
+
29
+ - `ancha/profiles/example.json`: the reusable version 1 company profile.
30
+ - `ancha/profiles/example.provenance.json`: source URL, fetched URLs and text hashes, model, call count, known cost and date.
31
+ - `ancha/worlds/example.yaml`: the world and its NetSuite seed.
32
+ - `ancha/evals/example.jsonl`: tasks and expected answers.
33
+ - `ancha/tests/example/*.yaml`: 25 tests that reference the world.
34
+
35
+ Rebuild with the saved profile:
36
+
37
+ ```sh
38
+ ancha world company --profile ancha/profiles/example.json --tool netsuite --force --json
39
+ ```
40
+
41
+ The same profile and size produce byte-identical world, eval and test files. The generation date is recorded in provenance.
@@ -4,7 +4,9 @@
4
4
 
5
5
  `ancha run --dry-run` checks `ancha.yaml` and every test, prints the tests, trials and parallelism, and starts nothing: no server, no agent, no trial. It lists each model-graded check and whether it is required. Dry runs work without a judge key; grading in a real run uses `OPENROUTER_API_KEY` on this computer or the workspace's model key in a cloud run. With `--json`, `judge.checks`, `judge.keySet` and `judge.requirement` carry these details.
6
6
 
7
- The run says where it runs. A cloud run announces acceptance with `run_submitted` (`run_detached` with `--detach`); both carry `target: "cloud"` and add `defaulted: true` when the saved login chose cloud. A run on this computer starts its NDJSON with `run_started`, which carries `workspace` and `target`. A completed run ends with `run_finished`. Without `--json`, each finished trial prints one line, such as `trial 2 ✗ 3m02s · 3 checks failed`, before the summary. The agent's exit code and the checks are independent: a clean exit with failed checks is a failure. Exits: 0 success; 1 failed checks, threshold or regression; 2 usage, config, test file or authentication error; 3 infrastructure or a trial the harness couldn't complete; 4 an endpoint coverage error or a verdict using simulated tool answers under `--strict`. The summary names the tests, trials and evaluated checks using those answers. Exit-code precedence is 3, 2, 4, then 1.
7
+ The run says where it runs. A cloud run announces acceptance with `run_submitted` (`run_detached` with `--detach`); both carry `target: "cloud"` and add `defaulted: true` when the saved login chose cloud. A run on this computer starts its NDJSON with `run_started`, which carries `workspace` and `target`. A completed run ends with `run_finished`. Without `--json`, each finished trial prints one line, such as `trial 2 ✗ 3m02s · 3 checks failed`, before the summary. The agent's exit code and the checks are independent: a clean exit with failed checks is a failure. Exits: 0 success; 1 failed checks, threshold or regression; 2 usage, config, test file or authentication error; 3 infrastructure or a trial the harness couldn't complete; 4 an endpoint coverage error with `--strict`, or a verdict using simulated tool answers with `--strict` or in CI. The summary names the tests, trials and evaluated checks using those answers. Exit-code precedence is 3, 2, 4, then 1.
8
+
9
+ When `CI=true` or `CI=1` (case-insensitive), a verdict using simulated tool answers exits 4. `--allow-simulated` keeps the ordinary verdict exit code, including with `--strict`; endpoint coverage errors still exit 4 only with `--strict`. Record the tool's answers or wrap the tool so its real logic runs; `ancha docs traces` explains both paths. JSON summaries carry the tests, trials and checks in `strict.simulatedAnswers` and the reason in `strict.message`.
8
10
 
9
11
  ## What the agent gets
10
12
 
@@ -93,7 +93,7 @@ Fix the agent, not the tests or checks. The exception is a check that is wrong f
93
93
 
94
94
  ## Exit codes
95
95
 
96
- 0 pass; 1 a check failed, the pass rate is below `min_pass_rate`, a comparison regressed, or `ancha test` needs a subcommand; 2 usage, config, test file or authentication error; 3 infrastructure, or a trial the harness couldn't complete; 4 an endpoint coverage error or a verdict using simulated tool answers, with `--strict`. A harness failure takes precedence over the others.
96
+ 0 pass; 1 a check failed, the pass rate is below `min_pass_rate`, a comparison regressed, or `ancha test` needs a subcommand; 2 usage, config, test file or authentication error; 3 infrastructure, or a trial the harness couldn't complete; 4 an endpoint coverage error with `--strict`, or a verdict using simulated tool answers with `--strict` or in CI (`CI=true` or `CI=1`, case-insensitive). `--allow-simulated` keeps the ordinary verdict exit code for simulated answers. A harness failure takes precedence over the others.
97
97
 
98
98
  Add `--json` for machine-readable results. Runs emit NDJSON; `env list` and `sandbox list` return arrays. Read the command-specific result fields with `ancha schema` and `ancha docs traces`. Errors carry `code` and `message`; `hint` names the next action.
99
99
 
@@ -25,6 +25,8 @@ ancha import email-trace.json --offline --checks checks.yaml --on local
25
25
 
26
26
  `--expect` adds the stated production failure as a judge check. `--answer checks.success="<required end state>"` defines the successful outcome. Both stay alongside selected checks.
27
27
 
28
+ For a failed trace, the test page shows a **Suggested end state** with evidence for each clause. Choose **Use this**, **Edit**, or **Dismiss**; accepting saves your text as `checks.success` in a new test version. If the suggestion asks a question, edit the text to answer it first. `ancha traces show <id>` displays the suggestion after `success:`, and `--json` includes `endStateDraft`. You can also reimport with `--force --answer 'checks.success=<text>'`. Your accepted answer sets the required end state for the test.
29
+
28
30
  New imports set `tools.<name>.exhausted: repeat_last` for reads: repeated calls reuse the last matching fixture. Writes use `exhausted: fail`: a call beyond its matching fixtures returns a tool error. Scenes that omit `exhausted` retain their existing behavior. Reads with no matching fixture can reuse an exact-argument answer from another trace; the example names its source trace. Borrowed examples have complete argument and result capture and are replayable. Reported examples require `--use-reported-results`. A function-only test uses `twins: []`, `seed: {}`, `tools`, `trigger` and `checks` together with its scene identity and clock.
29
31
 
30
32
  With `--json`, local trace import includes `workspace`, detected `format`, `evidence`, `candidates`, `required_checks` and connection commands. Multi-conversation imports place evidence and checks on each entry in `scenes`.
@@ -71,6 +73,8 @@ await entry(async input => runAgent(input.task, tools));
71
73
 
72
74
  In Python, use `ancha.wrap_tools` with the same function names. [Tool wrappers](https://docs.ancha.io/reference/tool-wrappers) covers both languages. Ancha supplies `ANCHA_TOOLS_URL` and `ANCHA_TOOLS_TOKEN` to the wrappers. Wrappers register the tools' descriptions and parameter schemas; Python functions supply these through signatures and type hints. Before simulating a call, Ancha checks for missing required arguments and unknown arguments where the schema sets `additionalProperties: false`; these errors carry the `validated` source. Replay and real-function calls use the recorded occurrence and configured route. The simulator receives the full schema and interprets values as the real tool would. `entry` sends the full definitions before starting the agent. When a function runs in the test, its wrapper records the returned result or raised exception as part of the same call. Checks and `ancha explain` use that outcome. A missing completion report makes the attempt invalid with an unconfirmed outcome. For a function linked to a twin, writes call the native twin API; subsequent reads use that twin's current state. The function returns the current result, so use its returned IDs for replies, reactions and later changes. Wrap these functions and configure their native clients with the environment variables from `ancha connect <tool>`. For tools listed in `connection.mcp`, configure your MCP client's URL with `{{tools.mcp_url}}` and its Bearer token with `{{tools.mcp_token}}` in `agent.env`; see `ancha docs run` for environment templates.
73
75
 
76
+ A verdict using simulated tool answers exits 4 with `--strict` or when `CI=true` or `CI=1` (case-insensitive). Record the tool's answers to replay them, or wrap the tool and select it with `tools.run` so its real logic runs over the test's records. `--allow-simulated` keeps the ordinary verdict exit code for simulated answers, including with `--strict`. The summary names the affected tests, trials and checks.
77
+
74
78
  An imported customer conversation sets `agent_input: per_event` in its test. The test sets the input mode and runs the command once per customer message, taking precedence over `agent.input` in `ancha.yaml`. Bind the reply function your agent already uses:
75
79
 
76
80
  ```ts
@@ -127,7 +131,7 @@ When a test doesn't fail the way production did, `ancha traces diff <trace file>
127
131
 
128
132
  `ancha runs export <run> --json` writes one IR trace per attempt, including the saved task, agent identity, test definition, outcome and check evidence. Reimporting uses those saved criteria and production verdicts.
129
133
 
130
- With `--json`, `traces` returns `{traces, next}`, `traces show` returns `{trace, test, preview, next}`, and `traces diff` returns `{production, attempt, scope, onlyInProduction, onlyInAttempt, firstDifference, next}`. Offline import returns `{workspace, format, scene, evidence, candidates, required_checks, checks, summary, questions, setup, next}` for one conversation, or `{scenes, questions, skipped, next}` for several. Each imported scene's `checks` lists its check IDs, whether they are required, and their production verdicts. Hosted import emits one result object per saved test and a `trace_skipped` event for each skipped trace. Pull returns `{world, name, version, checks, summary, questions, scene, kept, next}`; `pull --all` returns `{written, skipped, next}`. Export returns `{runId, files, next}`. `--limit` takes a positive safe integer; for example, `ancha traces --limit 5 --json`.
134
+ With `--json`, `traces` returns `{traces, next}`, `traces show` returns `{trace, test, preview, endStateDraft, next}`, and `traces diff` returns `{production, attempt, scope, onlyInProduction, onlyInAttempt, firstDifference, next}`. Offline import returns `{workspace, format, scene, evidence, candidates, required_checks, checks, summary, questions, setup, next}` for one conversation, or `{scenes, questions, skipped, next}` for several. Each imported scene's `checks` lists its check IDs, whether they are required, and their production verdicts. Hosted import emits one result object per saved test and a `trace_skipped` event for each skipped trace. Pull returns `{world, name, version, checks, summary, questions, scene, kept, next}`; `pull --all` returns `{written, skipped, next}`. Export returns `{runId, files, next}`. `--limit` takes a positive safe integer; for example, `ancha traces --limit 5 --json`.
131
135
 
132
136
  ### Function tool evidence
133
137