@ancha-labs/cli 0.4.20 → 0.4.21
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/bin/ancha.mjs +15 -1
- package/lib/ancha.mjs +39592 -37747
- package/lib/assets/docs/apps.md +1 -1
- package/lib/assets/docs/run.md +3 -1
- package/lib/assets/docs/scenes.md +24 -0
- package/lib/assets/docs/setup.md +1 -1
- package/lib/assets/harbor/companion.mjs +6895 -5775
- package/lib/assets/templates/starter/scene.yaml +1 -1
- package/lib/assets/ui/app.js +4 -4
- package/lib/mcp-entry.mjs +121 -5
- package/lib/worker.mjs +35129 -33365
- package/lib/world-server.mjs +6847 -5727
- package/package.json +1 -1
package/lib/assets/docs/apps.md
CHANGED
|
@@ -10,7 +10,7 @@ agent:
|
|
|
10
10
|
url: "http://127.0.0.1:{{agent.port}}/api/slack/events" # where the app receives the tools' events (webhooks, push)
|
|
11
11
|
ready_url: "http://127.0.0.1:{{agent.port}}/api/health" # answers 2xx once the app is up
|
|
12
12
|
startup_timeout: 180s # the start script's whole budget: reset, seed, boot
|
|
13
|
-
idle: 20s # how long the app may look quiet while it still works
|
|
13
|
+
idle: 20s # how long the app may look quiet while it still works; skip_idle jumps the clock only after this much quiet
|
|
14
14
|
setup_calls: true # the app may call the world while it starts (subscriptions, lookups), before time starts
|
|
15
15
|
clock: node # Date in the app's Node processes follows the world's clock, for flows that wait days
|
|
16
16
|
env: # rendered per trial: {{slack.url}}, {{slack.token}}, {{gmail.url}}, {{gmail.token}} …
|
package/lib/assets/docs/run.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`ancha run` loads `ancha.yaml` and runs the configured agent against every test its `scenes:` globs match (`scenes/**/scene.yaml` by default), `trials` times each, in fresh worlds. Pass test files (`scene.yaml`) to run only those; `--json` prints the run as NDJSON events. `--agent "<command>"` overrides `agent.command`; `-n 1 --parallel 1` runs one diagnostic trial; `--out <dir>` chooses where results go (use the same `--out` for `explain`, `report` and `compare`). Paths are relative to the directory you run `ancha` from.
|
|
4
4
|
|
|
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.
|
|
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
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.
|
|
8
8
|
|
|
@@ -12,6 +12,8 @@ New run summaries use `verdictVersion: 3`. Each test (an entry of `scenes`) has
|
|
|
12
12
|
|
|
13
13
|
Each trial gets the tools' URLs and fake credentials (`ancha docs integrations`), `ANCHA_TASK` and `ANCHA_TASK_FILE` (a file holding the task), `ANCHA_ATTEMPT_ID`, `ANCHA_STATE_DIR` (keep memory there, so trials stay independent), `ANCHA_EVENTS_URL`, `ANCHA_EVENTS_TOKEN` and `ANCHA_DONE_URL` for agents that receive events or finish explicitly, and `ANCHA_AGENT_PORT` for HTTP agents. No SDK is installed and no paid AI call is made for you. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: "{{task}}" }` (`{{task_file}}` for the file's path); `ancha init` writes that line when it finds the name in the agent's code or usage text.
|
|
14
14
|
|
|
15
|
+
Map your agent's tool settings with `agent.env`: `{{<tool>.url}}`, `{{<tool>.host_url}}` and `{{<tool>.token}}` use that tool's connection. Jira also offers `{{jira.email}}` (the login email, also `{{jira.access_key}}`) and `{{jira.access_key_secret}}` (the API token). For example, `env: { JIRA_USERNAME: "{{jira.email}}", JIRA_INSTANCE_URL: "{{jira.url}}"` gives an agent its own names for Jira's email and URL; `JIRA_API_TOKEN` is supplied automatically. An unknown template produces `CONFIG_INVALID` with the available template names before a run or upload check starts the agent.
|
|
16
|
+
|
|
15
17
|
With `--on local`, the agent runs as a process on this computer. It is not sealed: it can reach this computer's network. Its environment is limited to a base set from this shell (`PATH`, `HOME`, `USER`, `LOGNAME`, `SHELL`, `LANG`, `LC_*`, `TERM`, `TMPDIR`, `TZ`, `NODE_EXTRA_CA_CERTS`, `SSL_CERT_FILE`, `VIRTUAL_ENV`, `CONDA_PREFIX`, `PYTHONPATH`) plus Ancha's and the tools' variables. Real credentials in your shell, such as `GITHUB_TOKEN` or `DD_API_KEY`, never reach it unless you name them:
|
|
16
18
|
|
|
17
19
|
```yaml
|
|
@@ -58,3 +58,27 @@ Validate with `ancha scene validate scenes/my-scene/scene.yaml --json`. Referenc
|
|
|
58
58
|
`ancha init --template incidents` copies the complete versioned incident pack when included in your distribution, with all listed companions/fixtures. Missing or unsafe pack assets fail before config creation. No runtime includes or fabricated incident fixtures are generated.
|
|
59
59
|
|
|
60
60
|
Never give oracle/null companions, private checks, seeds or control-plane state to the tested AI agent. Use a separate tested-agent working directory/context when the coding agent would otherwise index those fixtures.
|
|
61
|
+
|
|
62
|
+
## Jira and PayPal end-state checks
|
|
63
|
+
|
|
64
|
+
Grade the records the agent leaves in the world with `jira.issue`, `jira.comment`, `jira.transition`, `paypal.invoice`, `paypal.order` and `paypal.payment`. `ancha twins seed jira --json` and `ancha twins seed paypal --json` include examples.
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
checks:
|
|
68
|
+
- id: five_new_tickets
|
|
69
|
+
state: { jira.issue: { project: OPS, after_start: true, count_eq: 5 } }
|
|
70
|
+
- id: checkout_bug
|
|
71
|
+
state: { jira.issue: { project: OPS, type: Bug, summary_contains: checkout, description_contains: Acceptance criteria, after_start: true } }
|
|
72
|
+
- id: correct_order_total
|
|
73
|
+
state: { paypal.order: { currency: USD, total: "466.40", tax: "131.40", after_start: true, count_eq: 1 } }
|
|
74
|
+
- id: invoice_sent
|
|
75
|
+
state: { paypal.invoice: { recipient: buyer@example.test, total: "276.60", tax: "84.60", sent: true, after_start: true } }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
All supplied filters match the same record. Choose `count_eq` for an exact count, `count_gte` for a minimum, or `exists: false` for none; without these, one match is enough. `after_start: true` selects records created during the attempt. The default includes seeded history.
|
|
79
|
+
|
|
80
|
+
Jira issues accept `issue`, `project`, `type`, `summary_contains`, `description_contains`, `labels`, `assignee`, `status` and `parent` (an epic for standard issues). Use `assignee: null` for unassigned issues and `parent: null` for no parent. Comments accept `issue`, `author` and `text_contains`; transitions accept `issue`, `from`, `to` and `author`. Text containment accepts a string or an all-required list and ignores case. Issue refs (`$issue.ops_slow`) and user refs (`$user.rachel`) belong to `seed.jira`; native issue keys and account ids also work.
|
|
81
|
+
|
|
82
|
+
PayPal orders accept `id`, `status`, `intent`, `payer_email`, `description_contains`, `invoice_id`, `currency`, `total`, `tax` and `items`. Invoice checks accept `id`, `status`, `recipient`, `currency`, `total`, `tax`, `sent` and `items`. Items have an exact `name` and optional `quantity` and `unit_amount`; invoice items also accept `tax_percent` and computed line `tax`. Quote amounts and quantities as decimal strings. Each requested item matches a distinct item; extra items are allowed. Payment checks accept `id`, `order`, `status`, `payer_email`, `invoice_id`, `currency`, `amount` and `refunded`. Order `id` and payment `order` can name a seed order as `$order.ref`.
|
|
83
|
+
|
|
84
|
+
Invoice item tax is computed on quantity × unit amount after item discount, rounded to cents. For 1.5 units at $120.00, a 10% item discount and 50% tax, the item tax is $81.00. Invoice responses include each item's computed `tax.amount`, and captured checks compare it directly. `ancha explain --json` shows expected filters and actual records with their amounts and statuses.
|
package/lib/assets/docs/setup.md
CHANGED
|
@@ -67,7 +67,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
|
|
|
67
67
|
|
|
68
68
|
`ancha init --agent "node agent.mjs"`, with your own start command, writes:
|
|
69
69
|
- `ancha.yaml`: how to start the agent, how many trials, which tests;
|
|
70
|
-
- `scenes/starter/`: a starter test that checks the agent reaches each tool, with two reference companions (`oracle.mjs` passes, `null.mjs` makes no calls);
|
|
70
|
+
- `scenes/starter/`: a starter test that checks the agent reaches each tool, with a 60-second timeout for startup and model calls, and two reference companions (`oracle.mjs` passes, `null.mjs` makes no calls);
|
|
71
71
|
- for an agent that uses NetSuite, in a project with no tests and no `traces/` folder: `ancha/worlds/netsuite-pe-m.yaml`, the NetSuite books of a private-equity portfolio company, and 25 tests in `ancha/tests/`: 10 read tasks and 15 write workflows (their evals in `ancha/evals/`). `--data netsuite-pe:s` or `--data netsuite-pe:l` writes another size, `--data none` leaves them out;
|
|
72
72
|
- `.claude/skills/ancha/SKILL.md` and an Ancha section in `AGENTS.md`, for coding agents;
|
|
73
73
|
- `.ancha/` in `.gitignore`: run history, traces and fake tokens never belong in git.
|