@ancha-labs/cli 0.4.31 → 0.4.32

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.
@@ -27,20 +27,23 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
27
27
  ```
28
28
  - To name the command yourself: `ancha init --agent "<the command that starts your agent>"`.
29
29
  - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.
30
- 3. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
30
+ 3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:
31
+ - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
32
+ - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
33
+ 4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
31
34
  ```sh
32
35
  ancha secrets set ANTHROPIC_API_KEY
33
36
  ```
34
- 4. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
37
+ 5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
35
38
  ```sh
36
39
  ancha agent upload
37
40
  ```
38
41
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
39
- 5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
42
+ 6. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
40
43
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
41
- - Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
44
+ - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
42
45
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
43
- 6. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
46
+ 7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
44
47
  ```sh
45
48
  ancha traces upload ./traces
46
49
  ```
@@ -48,9 +51,7 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
48
51
  - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect "<what went wrong>"`, or for a test already made, `ancha pull <test id> --expect "<what went wrong>"`.
49
52
  - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.
50
53
  - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.
51
- 7. **Point the agent at the test's tools.** In a test, the agent calls Ancha instead of production:
52
- - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
53
- - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
54
+ - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success="<end state>"` makes completing the request decide it too.
54
55
  8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.
55
56
  ```sh
56
57
  ancha run
@@ -59,7 +60,7 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
59
60
  - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.
60
61
  - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.
61
62
  - `ancha status` shows which of these steps your workspace has done.
62
- 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every check passes and nothing regressed.
63
+ 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.
63
64
  ```sh
64
65
  ancha baseline save before --from <run id>
65
66
  ancha run --compare before
@@ -12,20 +12,23 @@
12
12
  ```
13
13
  - To name the command yourself: `ancha init --agent "<the command that starts your agent>"`.
14
14
  - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.
15
- 3. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
15
+ 3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:
16
+ - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
17
+ - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
18
+ 4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
16
19
  ```sh
17
20
  ancha secrets set ANTHROPIC_API_KEY
18
21
  ```
19
- 4. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
22
+ 5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
20
23
  ```sh
21
24
  ancha agent upload
22
25
  ```
23
26
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
24
- 5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
27
+ 6. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
25
28
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
26
- - Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
29
+ - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
27
30
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
28
- 6. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
31
+ 7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
29
32
  ```sh
30
33
  ancha traces upload ./traces
31
34
  ```
@@ -33,9 +36,7 @@
33
36
  - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect "<what went wrong>"`, or for a test already made, `ancha pull <test id> --expect "<what went wrong>"`.
34
37
  - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.
35
38
  - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.
36
- 7. **Point the agent at the test's tools.** In a test, the agent calls Ancha instead of production:
37
- - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
38
- - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
39
+ - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success="<end state>"` makes completing the request decide it too.
39
40
  8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.
40
41
  ```sh
41
42
  ancha run
@@ -44,7 +45,7 @@
44
45
  - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.
45
46
  - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.
46
47
  - `ancha status` shows which of these steps your workspace has done.
47
- 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every check passes and nothing regressed.
48
+ 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.
48
49
  ```sh
49
50
  ancha baseline save before --from <run id>
50
51
  ancha run --compare before
@@ -20,20 +20,23 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
20
20
  ```
21
21
  - To name the command yourself: `ancha init --agent "<the command that starts your agent>"`.
22
22
  - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.
23
- 3. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
23
+ 3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:
24
+ - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
25
+ - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
26
+ 4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
24
27
  ```sh
25
28
  ancha secrets set ANTHROPIC_API_KEY
26
29
  ```
27
- 4. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
30
+ 5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
28
31
  ```sh
29
32
  ancha agent upload
30
33
  ```
31
34
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
32
- 5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
35
+ 6. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
33
36
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
34
- - Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
37
+ - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
35
38
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
36
- 6. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
39
+ 7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
37
40
  ```sh
38
41
  ancha traces upload ./traces
39
42
  ```
@@ -41,9 +44,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
41
44
  - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect "<what went wrong>"`, or for a test already made, `ancha pull <test id> --expect "<what went wrong>"`.
42
45
  - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.
43
46
  - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.
44
- 7. **Point the agent at the test's tools.** In a test, the agent calls Ancha instead of production:
45
- - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
46
- - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
47
+ - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success="<end state>"` makes completing the request decide it too.
47
48
  8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.
48
49
  ```sh
49
50
  ancha run
@@ -52,7 +53,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
52
53
  - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.
53
54
  - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.
54
55
  - `ancha status` shows which of these steps your workspace has done.
55
- 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every check passes and nothing regressed.
56
+ 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.
56
57
  ```sh
57
58
  ancha baseline save before --from <run id>
58
59
  ancha run --compare before
@@ -31,7 +31,7 @@ A version 2 test names a world (`ancha/worlds/<id>.yaml`: the company, its peopl
31
31
  {"id": "ar-over-90", "question": "What is AR more than 90 days past due?", "expected": "$48,200.50 across 6 customers", "read_only": true}
32
32
  ```
33
33
 
34
- - The question is `question`, `input`, `prompt`, `query` or `task`; the expected answer is `expected`, `answer`, `ideal`, `output`, `reference` or `expected_output`. Optional: `id`, `read_only` (default true; false for an eval with `records`), `must_call` (`"METHOD /path"` or an MCP tool name), `numbers` (`[{ value, tolerance }]`), `contains`, `judge` (a rubric), `tags`, and `records`: the NetSuite state a write leaves, `[{ type, id or externalId, fields }]`. Other fields go in the test's header as comments.
34
+ - The question is `question`, `input`, `prompt`, `query` or `task`; the expected answer is `expected`, `answer`, `ideal`, `output`, `reference` or `expected_output`. Optional: `id`, `read_only` (default true; false for an eval with `records`), `must_call` (`"METHOD /path"` or an MCP tool name), `numbers` (`[{ value, tolerance, label? }]`), `contains`, `judge` (a rubric), `tags`, and `records`: the NetSuite state a write leaves, `[{ type, id or externalId, fields }]`. Other fields go in the test's header as comments.
35
35
  - Each eval becomes a test whose task is the question, with an `answer` check: the `numbers` and `contains` it gives, or the numbers, document numbers (`INV-1043`) and quoted text of its expected answer. Numbers the question states and dates are left out. A test also gets `netsuite.unchanged` over every record type when it only reads and the world has NetSuite, a `trace.called` check for each `must_call`, and a `netsuite.record` check for each of its `records`. Write evals can also give `counts: [{type, count}]` and `unchanged: {types, except: [{type, id | externalId}]}` to check record counts and protect other records. `preserved: [{type, id, except_fields: [approvalStatus, status, lastModifiedDate]}]` protects the target record’s other fields. `includeSettlement: true` in a count includes zero-cash settlement records. A record check’s `apply` names the exact applied documents; `credit` names the exact credit sources, both as `[{doc, amount}]` (with `line` for line-level identities). A record named by `externalId` can be one the agent creates:
36
36
 
37
37
  ```json
@@ -42,6 +42,17 @@ A version 2 test names a world (`ancha/worlds/<id>.yaml`: the company, its peopl
42
42
  - A CSV may name its columns anything, an Excel sheet saved as CSV among them: the import picks the question and expected-answer columns by their names and prints the ones it used, with the format it read.
43
43
  - The same file gives the same tests every time. Importing again updates the tests it wrote and keeps any you edited; `--force` replaces those too. `--prefix <p>` puts `<p>-` before every id.
44
44
 
45
+ When an expected answer states at least two numbers with distinct local names, the import carries those names as labels. For example, `“Prescott Plumbing Supply Corp.” owes USD 383,257.63 against a credit limit of USD 342,000.00` produces this answer check:
46
+
47
+ ```yaml
48
+ - id: answer
49
+ answer:
50
+ contains: [Prescott Plumbing Supply Corp.]
51
+ numbers:
52
+ - { value: 383257.63, tolerance: 0.005, label: owes }
53
+ - { value: 342000, tolerance: 0.005, label: credit limit }
54
+ ```
55
+
45
56
  ## NetSuite state checks
46
57
 
47
58
  Combine approval, protection of other records, and preservation of the target bill:
@@ -99,6 +110,7 @@ checks:
99
110
  not_contains: [I could not]
100
111
  ```
101
112
 
113
+ - Each number accepts an optional `label`, trimmed to 1–40 characters, such as `balance` or `credit limit`. Labels catch expected amounts stated directly after the wrong name, such as swapping what a customer owes with its credit limit. Names match whole words without regard to letter case; a correct occurrence under the expected name preserves the number's match.
102
114
  - `numbers` reads amounts as people write them: `1,240.00`, `$1,240`, `USD 1240`, `1,240.00 EUR`, `-1,240.00`, and `(1,240.00)` for a negative. A whole number in parentheses with no currency, such as `(5)`, counts as 5 or -5. Digits inside a word or an id (`Q3`, `INV-1043`) belong to that word. Write numbers in plain digits (`1240`, not `1.24e3`).
103
115
  - Each number matches within `tolerance`, by default half the last decimal place of `value`: `"1,200.00"` allows ±0.005, `1240.5` ±0.05, `1200` ±0.5. Write `value` as text to keep trailing zeros, or set `tolerance`.
104
116
  - An attempt with no final answer fails the check with "no final answer". `answer: {}` passes on any final answer.
@@ -18,20 +18,23 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
18
18
  ```
19
19
  - To name the command yourself: `ancha init --agent "<the command that starts your agent>"`.
20
20
  - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.
21
- 3. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
21
+ 3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:
22
+ - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
23
+ - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
24
+ 4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.
22
25
  ```sh
23
26
  ancha secrets set ANTHROPIC_API_KEY
24
27
  ```
25
- 4. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
28
+ 5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.
26
29
  ```sh
27
30
  ancha agent upload
28
31
  ```
29
32
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
30
- 5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
33
+ 6. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.
31
34
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
32
- - Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
35
+ - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
33
36
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
34
- 6. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
37
+ 7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.
35
38
  ```sh
36
39
  ancha traces upload ./traces
37
40
  ```
@@ -39,9 +42,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
39
42
  - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect "<what went wrong>"`, or for a test already made, `ancha pull <test id> --expect "<what went wrong>"`.
40
43
  - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.
41
44
  - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.
42
- 7. **Point the agent at the test's tools.** In a test, the agent calls Ancha instead of production:
43
- - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.
44
- - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
45
+ - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success="<end state>"` makes completing the request decide it too.
45
46
  8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.
46
47
  ```sh
47
48
  ancha run
@@ -50,7 +51,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
50
51
  - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.
51
52
  - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.
52
53
  - `ancha status` shows which of these steps your workspace has done.
53
- 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every check passes and nothing regressed.
54
+ 9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.
54
55
  ```sh
55
56
  ancha baseline save before --from <run id>
56
57
  ancha run --compare before
@@ -76369,6 +76369,9 @@ var NUMBER = new RegExp(
76369
76369
  "gu"
76370
76370
  );
76371
76371
  function readNumbers(text25) {
76372
+ return readNumberSpans(text25).map(({ start: _start, end: _end, ...number7 }) => number7);
76373
+ }
76374
+ function readNumberSpans(text25) {
76372
76375
  const numbers2 = [];
76373
76376
  for (const match3 of text25.normalize("NFKC").matchAll(NUMBER)) {
76374
76377
  const { open: open2, sign: sign3, before, minus, inner, digits, after, close } = match3.groups;
@@ -76377,6 +76380,8 @@ function readNumbers(text25) {
76377
76380
  const negative = sign3 !== void 0 && sign3 !== "+" || minus !== void 0 || parenthesized && amount4;
76378
76381
  const value4 = Number(digits.replaceAll(",", ""));
76379
76382
  numbers2.push({
76383
+ start: match3.index,
76384
+ end: match3.index + match3[0].length,
76380
76385
  value: negative && value4 !== 0 ? -value4 : value4,
76381
76386
  decimals: digits.split(".")[1]?.length ?? 0,
76382
76387
  text: match3[0].trim(),
@@ -76406,7 +76411,8 @@ ${text25}` : `${key4}: ${text25}`).join("\n");
76406
76411
  }
76407
76412
  var AnswerNumberSchema = external_exports.strictObject({
76408
76413
  value: external_exports.union([external_exports.number(), external_exports.string().refine((text25) => readNumbers(text25).length === 1, 'a number, or one number written as text, e.g. "1,240.00" or "(300.00)"')]).describe('The number the answer must state: a number, or one number as text ("1,240.00") to keep its decimal places'),
76409
- tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)")
76414
+ tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)"),
76415
+ label: external_exports.string().trim().min(1).max(40).optional().describe("The name of this number, such as balance or credit limit; detects expected values stated under another label")
76410
76416
  });
76411
76417
  var texts = external_exports.union([external_exports.string().min(1), external_exports.array(external_exports.string().min(1)).min(1)]);
76412
76418
  var AnswerRowSchema = external_exports.record(external_exports.string().min(1), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()])).superRefine((row2, ctx) => {
@@ -76440,6 +76446,100 @@ function expectedNumber(number7) {
76440
76446
  const read6 = typeof number7.value === "number" ? { value: number7.value, decimals: decimalsOf(number7.value) } : readNumbers(number7.value)[0];
76441
76447
  return { value: read6.value, tolerance: number7.tolerance ?? 0.5 * 10 ** -read6.decimals };
76442
76448
  }
76449
+ var LINK_WORDS = /* @__PURE__ */ new Set(["is", "was", "are", "were", "of", "at", "to", "totals"]);
76450
+ var CLAUSE_WORDS = /* @__PURE__ */ new Set(["and", "but", "while", "whereas", "with"]);
76451
+ var CURRENCY_TOKEN = new RegExp(`^(?:${CURRENCY})$`, "iu");
76452
+ var WORD_CHAR = /[\p{L}\p{N}_]/u;
76453
+ function answerTokens(text25) {
76454
+ const tokens4 = [];
76455
+ let cursor4 = 0;
76456
+ const quotes = [];
76457
+ const gap8 = (end) => {
76458
+ for (const match3 of text25.slice(cursor4, end).matchAll(/[\p{L}\p{M}]+|[^\s]/gu)) {
76459
+ const start2 = cursor4 + match3.index, word = match3[0];
76460
+ const apostrophe = (word === "'" || word === "\u2019") && (WORD_CHAR.test(text25[start2 - 1] ?? "") && (WORD_CHAR.test(text25[start2 + 1] ?? "") || quotes.at(-1) !== word) || text25[start2 - 1] === "." && /^s\b/i.test(text25.slice(start2 + 1)));
76461
+ const quote2 = !apostrophe && ['"', "'", "\u201C", "\u201D", "\u2018", "\u2019"].includes(word);
76462
+ tokens4.push({ text: word.toLowerCase(), start: start2, end: start2 + word.length, quoted: quotes.length > 0 || quote2 });
76463
+ if (quote2) {
76464
+ if (quotes.at(-1) === word) quotes.pop();
76465
+ else if (word !== "\u201D" && word !== "\u2019") quotes.push(word === "\u201C" ? "\u201D" : word === "\u2018" ? "\u2019" : word);
76466
+ }
76467
+ }
76468
+ };
76469
+ for (const number7 of readNumberSpans(text25)) {
76470
+ gap8(number7.start);
76471
+ tokens4.push({ text: number7.text, start: number7.start, end: number7.end, number: number7, quoted: quotes.length > 0 });
76472
+ cursor4 = number7.end;
76473
+ }
76474
+ gap8(text25.length);
76475
+ return tokens4;
76476
+ }
76477
+ var escapeRegex2 = (text25) => text25.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
76478
+ var labelPattern = (label7) => new RegExp(`(?<![\\p{L}\\p{N}_])${escapeRegex2(label7)}(?![\\p{L}\\p{N}_])`, "giu");
76479
+ var normalizedLabel = (label7) => label7.normalize("NFKC").toLowerCase();
76480
+ function distinctLabels(labels2) {
76481
+ return labels2.every((label7, i) => labels2.every((other, j) => i === j || !labelPattern(label7).test(other)));
76482
+ }
76483
+ function fieldRows(text25) {
76484
+ return text25.split("\n").map((line2) => {
76485
+ const lead = /^\s*\|?/.exec(line2)[0].length, end = line2.length - /\|?\s*$/.exec(line2)[0].length;
76486
+ const inner = line2.slice(lead, end), at4 = inner.indexOf("|");
76487
+ if (at4 < 0 || inner.includes("|", at4 + 1) || !inner.slice(0, at4).trim() || !inner.slice(at4 + 1).trim() || /^[\s:-]+$/.test(inner.replace("|", ""))) return line2;
76488
+ return `${line2.slice(0, lead + at4)}:${line2.slice(lead + at4 + 1)}`;
76489
+ }).join("\n");
76490
+ }
76491
+ function readLabelEvidence(text25, labels2) {
76492
+ text25 = fieldRows(text25.normalize("NFKC"));
76493
+ const tokens4 = answerTokens(text25);
76494
+ const occurrences2 = labels2.flatMap((label7) => [...text25.matchAll(labelPattern(normalizedLabel(label7)))].map((match3) => ({ label: label7, start: match3.index, end: match3.index + match3[0].length }))).sort((a, b) => a.start - b.start);
76495
+ const evidence2 = [];
76496
+ occurrences2.forEach((occurrence, index) => {
76497
+ const next2 = occurrences2[index + 1]?.start ?? text25.length;
76498
+ const after = tokens4.filter((token4) => token4.start >= occurrence.end && token4.start < next2);
76499
+ const clause2 = [];
76500
+ let previous = occurrence.end;
76501
+ for (const token4 of after) {
76502
+ if (/[\r\n]/.test(text25.slice(previous, token4.start)) || !token4.number && (/^[.!?;,|]$/.test(token4.text) || CLAUSE_WORDS.has(token4.text))) break;
76503
+ clause2.push(token4);
76504
+ previous = token4.end;
76505
+ }
76506
+ let links3 = 0;
76507
+ for (let i = 0; i < clause2.length; i++) {
76508
+ const token4 = clause2[i];
76509
+ if (token4.number) {
76510
+ evidence2.push({
76511
+ label: occurrence.label,
76512
+ number: token4.number,
76513
+ clauseNumbers: clause2.flatMap((t) => t.number ? [t.number] : []),
76514
+ quoted: token4.quoted || tokens4.some((t) => t.start >= occurrence.start && t.start < occurrence.end && t.quoted)
76515
+ });
76516
+ break;
76517
+ }
76518
+ if (CURRENCY_TOKEN.test(token4.text) || /^[*_]$/.test(token4.text)) continue;
76519
+ if (token4.text === "stands" && clause2[i + 1]?.text === "at" || ["comes", "came"].includes(token4.text) && clause2[i + 1]?.text === "to") i++;
76520
+ else if (!LINK_WORDS.has(token4.text) && token4.text !== ":" && token4.text !== "=") break;
76521
+ if (++links3 > 3) break;
76522
+ }
76523
+ });
76524
+ return evidence2;
76525
+ }
76526
+ function swappedAnswerNumbers(text25, numbers2) {
76527
+ const labelled = numbers2.filter((n2) => n2.label !== void 0);
76528
+ if (labelled.length < 2 || !distinctLabels(labelled.map((n2) => normalizedLabel(n2.label)))) return [];
76529
+ const evidence2 = readLabelEvidence(text25, labelled.map((n2) => n2.label));
76530
+ const matches10 = (actual, expected) => {
76531
+ const { value: value4, tolerance } = expectedNumber(expected);
76532
+ return numberMatches(actual, value4, tolerance);
76533
+ };
76534
+ return labelled.flatMap((expected) => {
76535
+ if (evidence2.some((e) => e.label === expected.label && matches10(e.number, expected))) return [];
76536
+ return labelled.flatMap((under) => {
76537
+ if (under === expected || matches10({ value: expectedNumber(under).value, decimals: 0, text: "" }, expected) || matches10({ value: expectedNumber(expected).value, decimals: 0, text: "" }, under)) return [];
76538
+ const wrong = evidence2.find((e) => e.label === under.label && !e.quoted && matches10(e.number, expected) && !matches10(e.number, under) && !e.clauseNumbers.some((n2) => n2.start !== e.number.start && numbers2.some((want) => matches10(n2, want))));
76539
+ return wrong ? [{ expected, under, stated: wrong.number }] : [];
76540
+ });
76541
+ });
76542
+ }
76443
76543
  function decimalsOf(value4) {
76444
76544
  const [mantissa, exponent] = String(Math.abs(value4)).split("e");
76445
76545
  return Math.max(0, (mantissa.split(".")[1]?.length ?? 0) - Number(exponent ?? 0));
@@ -94915,10 +95015,10 @@ function evaluateAnswerRows(check3, answer) {
94915
95015
  function evaluateAnswer(check3, trace) {
94916
95016
  if (check3.rows !== void 0) return evaluateAnswerRows(check3.rows, finalAnswer(trace));
94917
95017
  const contains3 = asList(check3.contains), absent = asList(check3.not_contains), sensitive = check3.case === "sensitive";
94918
- const numbers2 = (check3.numbers ?? []).map((number7) => ({ ...expectedNumber(number7), written: typeof number7.value === "string" ? number7.value : plainNumber(number7.value) }));
95018
+ const numbers2 = (check3.numbers ?? []).map((number7) => ({ ...expectedNumber(number7), label: number7.label, written: typeof number7.value === "string" ? number7.value : plainNumber(number7.value) }));
94919
95019
  const parts3 = [
94920
95020
  ...contains3.length ? [`contains ${quoted2(contains3)}`] : [],
94921
- ...numbers2.length ? [`states ${numbers2.map((n2) => `${n2.written} (\xB1${plainNumber(n2.tolerance)})`).join(", ")}`] : [],
95021
+ ...numbers2.length ? [`states ${numbers2.map((n2) => `${n2.written} (${n2.label ? `${n2.label}, ` : ""}\xB1${plainNumber(n2.tolerance)})`).join(", ")}`] : [],
94922
95022
  ...absent.length ? [`does not contain ${quoted2(absent)}`] : []
94923
95023
  ];
94924
95024
  const expected = parts3.length ? `the final answer ${parts3.join("; ")}` : "a final answer";
@@ -94946,9 +95046,10 @@ function evaluateAnswer(check3, trace) {
94946
95046
  const missing7 = contains3.filter((piece2) => !text25.includes(comparableText(piece2, sensitive)));
94947
95047
  const unstated = numbers2.filter((n2) => !stated.some((number7) => numberMatches(number7, n2.value, n2.tolerance)));
94948
95048
  const present2 = absent.filter((piece2) => text25.includes(comparableText(piece2, sensitive)));
95049
+ const swaps = swappedAnswerNumbers(answer.text, check3.numbers ?? []);
94949
95050
  const line2 = answer.text.replace(/\s+/g, " ").trim();
94950
95051
  const actual = `"${line2.length > ANSWER_QUOTE ? `${line2.slice(0, ANSWER_QUOTE - 1)}\u2026` : line2}"`;
94951
- if (!missing7.length && !unstated.length && !present2.length) {
95052
+ if (!missing7.length && !unstated.length && !present2.length && !swaps.length) {
94952
95053
  return { passed: true, expected, actual, explanation: parts3.length ? "The final answer states everything the check asks for." : "The agent gave a final answer.", evidence: [answer.seq] };
94953
95054
  }
94954
95055
  const said = stated.length ? `the numbers it states are ${list2(stated.map((number7) => number7.text))}` : "it states no numbers";
@@ -94956,6 +95057,7 @@ function evaluateAnswer(check3, trace) {
94956
95057
  ...missing7.length ? [`The final answer does not contain ${quoted2(missing7)}.`] : [],
94957
95058
  ...unstated.length ? [`It states no number within ${unstated.map((n2) => `${plainNumber(n2.tolerance)} of ${n2.written}`).join(", nor within ")}: ${said}.`] : [],
94958
95059
  ...present2.length ? [`It contains ${quoted2(present2)}, which it must not.`] : [],
95060
+ ...swaps.map((swap) => `It states ${swap.stated.text} after \u201C${swap.under.label}\u201D, but the expected \u201C${swap.under.label}\u201D is ${typeof swap.under.value === "string" ? swap.under.value : plainNumber(swap.under.value)} and ${typeof swap.expected.value === "string" ? swap.expected.value : plainNumber(swap.expected.value)} is the expected \u201C${swap.expected.label}\u201D.`),
94959
95061
  ...answer.source === "stdout" ? ["Its answer is everything it printed on stdout."] : answer.source === "reply" ? ["Its answer is its HTTP reply."] : []
94960
95062
  ].join(" ");
94961
95063
  return { passed: false, expected, actual, explanation, evidence: [answer.seq] };
@@ -151511,11 +151613,11 @@ function dateModel(model) {
151511
151613
  }
151512
151614
  return parts3;
151513
151615
  }
151514
- var escapeRegex2 = (s2) => s2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
151616
+ var escapeRegex3 = (s2) => s2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
151515
151617
  function parseDate2(value4, model) {
151516
151618
  const parts3 = dateModel(model), tokens4 = [];
151517
151619
  const pattern = parts3.map((p2) => {
151518
- if (!p2.token) return escapeRegex2(p2.literal);
151620
+ if (!p2.token) return escapeRegex3(p2.literal);
151519
151621
  if (p2.token === "FM") return "";
151520
151622
  tokens4.push(p2.token);
151521
151623
  return p2.token === "YYYY" ? "(\\d{4})" : ["MON", "MONTH"].includes(p2.token) ? "([A-Za-z]+)" : ["AM", "PM"].includes(p2.token) ? "(AM|PM)" : "(\\d{1,2})";
@@ -22184,7 +22184,7 @@ function starterCount(tool, key, state) {
22184
22184
  }
22185
22185
 
22186
22186
  // frontend/src/generated/coding-agent-skill.ts
22187
- var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, built from its production traces, and prove a fix with graded runs in the cloud. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company or rebuilt from a production trace, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself. `ancha run --on cloud` runs each attempt on a fresh machine of its own in Ancha's cloud.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; `ancha traces upload` prints the tests it made. `env list` and `sandbox list` return arrays; trace commands use the fields described in `ancha docs traces`. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, test files (`scene.yaml`) and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## First steps\n\n<!-- ancha:first-steps -->\n1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.\n ```sh\n ancha --version || npm install -g @ancha-labs/cli\n ancha login\n ```\n2. **Set up the project.** Run it in the agent's project: it finds the command that starts the agent and how the agent takes its task, and writes both to `ancha.yaml`. It installs and runs nothing.\n ```sh\n ancha init\n ```\n - To name the command yourself: `ancha init --agent \"<the command that starts your agent>\"`.\n - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.\n3. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.\n ```sh\n ancha secrets set ANTHROPIC_API_KEY\n ```\n4. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.\n ```sh\n ancha agent upload\n ```\n - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.\n5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.\n - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.\n - Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n6. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.\n ```sh\n ancha traces upload ./traces\n ```\n - From Langfuse or LangSmith, with your keys on this computer: `ancha traces upload --from langfuse --limit 50`, or `--from langsmith`.\n - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect \"<what went wrong>\"`, or for a test already made, `ancha pull <test id> --expect \"<what went wrong>\"`.\n - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.\n - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.\n7. **Point the agent at the test's tools.** In a test, the agent calls Ancha instead of production:\n - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.\n - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.\n8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.\n ```sh\n ancha run\n ```\n - Your agent and its worlds run in the cloud, each attempt on a fresh machine of its own; a run keeps going when your laptop closes, and its results land in Runs.\n - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.\n - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.\n - `ancha status` shows which of these steps your workspace has done.\n9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every check passes and nothing regressed.\n ```sh\n ancha baseline save before --from <run id>\n ancha run --compare before\n ```\n - Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.\n10. **Run it on this computer.** While you develop, `ancha run --on local` runs the agent and its worlds on this computer, with the same checks.\n ```sh\n ancha run --on local --attempts 1\n ```\n - Here the agent gets the keys in `agent.pass_env` from your shell, and model-graded checks need `OPENROUTER_API_KEY`.\n<!-- /ancha:first-steps -->\n\n## Cloud runs\n\n- `ancha run --on cloud` sends the project as one bundle: the agent's files, without hidden directories, dependencies or credential-like files, and its tests with their worlds and checks, which stay with the grader and never reach the agent. Each attempt's machine installs the dependencies, runs the agent and grades it with the same engine as a run on this computer. `--attempts <n>` sets the attempts per test, `--concurrency <n>` how many run at once.\n- The agent gets the workspace's secrets for the names in `agent.pass_env`, and its network reaches its tools and its model providers. Model-graded checks and the people in a world run on the workspace's model credit.\n- The `run_finished` event carries `url` (the result in the workspace) and `summary`, with `counts` of the attempts: requested, completed, invalid, skipped and cancelled. Interrupting the command stops the following, never the run: `ancha wait <run id>` follows it again, and `--detach` returns once the run is accepted.\n- `ancha explain <run id> --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n- When every attempt ended before the agent did anything (it exited within seconds without a call, or its command could not start), the run, `ancha wait` and `ancha explain` say that first: \"Your agent didn't run\", the end of its log once, and the likely fix read from it, such as the `agent.env` line that gives the agent its task under the name it reads. `agentNeverRan` in the JSON carries the same. Make that fix first: the failed checks follow from it, and `ancha explain <run id> --all` lists them.\n- `ancha status --json` shows the workspace's three steps (agent uploaded, tests added, tests run in the cloud) and the next command. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login. More: `ancha docs cloud`.\n\n## An app, not a command\n\nIf the AI feature lives inside an app (a web app or API server with its database, workers and scheduled jobs), don't wrap it in `agent.command`. Ancha starts the app once per attempt with `agent.start`, waits for `agent.ready_url`, delivers the tools' events to `agent.url`, and a scene's `world_rules.app_calls` call the app's own routes, such as its cron jobs, at a time. Read `ancha docs apps` before writing `ancha.yaml`. The start script gives the app a clean database, cache and seed every attempt: a new world has new URLs and tokens, and stale rows or sync cursors make an app silently do nothing.\n\n## More from production traces\n\n`ancha traces upload <file or folder> --json` sends the traces to the workspace, which rebuilds each one's world and checks, and writes each test to `scenes/from-traces/<name>/scene.yaml`: runs that went fine and runs that failed. `--from langfuse` or `--from langsmith` takes the newest traces there instead (`--limit`, `--since`), with the keys in this shell. For one trace of a failure, `--expect \"<what went wrong>\"` adds a check for it. A test lists the questions one trace cannot settle, each with the default it uses. Ask the user for the answers; don't guess them. Pass them with `ancha pull <test id> --answer <question>=<value>`. `ancha import --offline <trace file> --json` makes the tests on this computer instead, one per conversation, and uploads nothing; there, `--answer` and `--force` go on the import.\n\nA test from a run that failed should fail the same way production did. If it doesn't, run it on this computer: `ancha traces diff <trace file> latest` shows the calls production made and the attempt didn't, and the import also lists the app's own setup calls, which the start script or an `app_call` has to make.\n\nIf the user's workspace takes traces (their agents send them to it), each trace becomes a test there: `ancha pull --all --json` writes every test that is turned on (`--agent <name>` for one agent's), `ancha traces --failed --json` lists the ones where production failed a check, `ancha traces show <id> --json` previews the test, and `ancha pull <id> --json` writes one, with `--answer` for its questions. Checks you add to a pulled `scene.yaml` stay when you pull a newer version; any other edit stops the pull. More: `ancha docs traces`.\n\n## Other tests\n\nThe starter test `ancha init` writes when `scenes/` holds no tests only proves that the agent reaches each tool. For the agent's real job beyond its traces, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a test can make on it. More: `ancha docs scenes`.\n\n## The rule\n\nFix the agent, not the tests or their checks. `ancha.yaml` says how to start the agent and give it its task and keys: change it for that, never to make a check pass. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the tests, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach attempt gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task, and `ANCHA_TASK_FILE` names a file holding it. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: \"{{task}}\" }` (`{{task_file}}` for the file); `ancha init` writes that line when it finds the name.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\nThe agent's own keys are the names in `agent.pass_env` in `ancha.yaml`, such as `agent.pass_env: [OPENAI_API_KEY]`, and `agent.env` sets fixed values, such as the path of a key file. In the cloud each name comes from the workspace's secrets (`ancha secrets set NAME`). `ancha run --on local` starts the agent on this computer instead, with this computer's network and those names from this shell (or `--pass-env NAME`); `--on docker` seals it in a container (`agent.execution: { mode: container, image: node:24-slim }`, which needs Docker). An agent without its model key stops at its first model call.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain <run id> --json`.\n- Exit 2: usage, config, test file or authentication error, or a cancelled cloud run. `AUTH_INVALID` means `ancha login` again or a valid `ANCHA_API_KEY`; `CONFIG_INVALID` naming a workspace secret means `ancha secrets set NAME`. Read the `hint`.\n- Exit 3: infrastructure, or an attempt the harness couldn't run or grade. It counts as invalid, never as a failed check, so it's not the agent's fault; run again, and `ancha agent upload --json` if it repeats.\n- Exit 4, only with `--strict`: an endpoint coverage error or a verdict using simulated tool answers. The summary names the tests, trials and evaluated checks using those answers. `ancha explain` lists endpoint errors; `ancha twins coverage <tool>` shows the endpoint inventory.\n\nRead the error's stable `code` and `message`, then follow its `hint` when provided. More: `ancha docs`, `ancha docs <topic>` for setup, run, traces, explain, compare, scenes, integrations, cloud and playgrounds, and https://docs.ancha.io/coding-agents.\n\nTell the user what you ran, where it ran, the pass rate, the evidence and the result link. Never claim a fix until `ancha run --compare` exits 0.\n";
22187
+ var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, built from its production traces, and prove a fix with graded runs in the cloud. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company or rebuilt from a production trace, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself. `ancha run --on cloud` runs each attempt on a fresh machine of its own in Ancha's cloud.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; `ancha traces upload` prints the tests it made. `env list` and `sandbox list` return arrays; trace commands use the fields described in `ancha docs traces`. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, test files (`scene.yaml`) and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## First steps\n\n<!-- ancha:first-steps -->\n1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.\n ```sh\n ancha --version || npm install -g @ancha-labs/cli\n ancha login\n ```\n2. **Set up the project.** Run it in the agent's project: it finds the command that starts the agent and how the agent takes its task, and writes both to `ancha.yaml`. It installs and runs nothing.\n ```sh\n ancha init\n ```\n - To name the command yourself: `ancha init --agent \"<the command that starts your agent>\"`.\n - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.\n3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:\n - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.\n - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.\n4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.\n ```sh\n ancha secrets set ANTHROPIC_API_KEY\n ```\n5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.\n ```sh\n ancha agent upload\n ```\n - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.\n6. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows.\n - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.\n - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.\n ```sh\n ancha traces upload ./traces\n ```\n - From Langfuse or LangSmith, with your keys on this computer: `ancha traces upload --from langfuse --limit 50`, or `--from langsmith`.\n - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect \"<what went wrong>\"`, or for a test already made, `ancha pull <test id> --expect \"<what went wrong>\"`.\n - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.\n - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.\n - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success=\"<end state>\"` makes completing the request decide it too.\n8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.\n ```sh\n ancha run\n ```\n - Your agent and its worlds run in the cloud, each attempt on a fresh machine of its own; a run keeps going when your laptop closes, and its results land in Runs.\n - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.\n - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.\n - `ancha status` shows which of these steps your workspace has done.\n9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.\n ```sh\n ancha baseline save before --from <run id>\n ancha run --compare before\n ```\n - Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.\n10. **Run it on this computer.** While you develop, `ancha run --on local` runs the agent and its worlds on this computer, with the same checks.\n ```sh\n ancha run --on local --attempts 1\n ```\n - Here the agent gets the keys in `agent.pass_env` from your shell, and model-graded checks need `OPENROUTER_API_KEY`.\n<!-- /ancha:first-steps -->\n\n## Cloud runs\n\n- `ancha run --on cloud` sends the project as one bundle: the agent's files, without hidden directories, dependencies or credential-like files, and its tests with their worlds and checks, which stay with the grader and never reach the agent. Each attempt's machine installs the dependencies, runs the agent and grades it with the same engine as a run on this computer. `--attempts <n>` sets the attempts per test, `--concurrency <n>` how many run at once.\n- The agent gets the workspace's secrets for the names in `agent.pass_env`, and its network reaches its tools and its model providers. Model-graded checks and the people in a world run on the workspace's model credit.\n- The `run_finished` event carries `url` (the result in the workspace) and `summary`, with `counts` of the attempts: requested, completed, invalid, skipped and cancelled. Interrupting the command stops the following, never the run: `ancha wait <run id>` follows it again, and `--detach` returns once the run is accepted.\n- `ancha explain <run id> --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n- When every attempt ended before the agent did anything (it exited within seconds without a call, or its command could not start), the run, `ancha wait` and `ancha explain` say that first: \"Your agent didn't run\", the end of its log once, and the likely fix read from it, such as the `agent.env` line that gives the agent its task under the name it reads. `agentNeverRan` in the JSON carries the same. Make that fix first: the failed checks follow from it, and `ancha explain <run id> --all` lists them.\n- `ancha status --json` shows the workspace's three steps (agent uploaded, tests added, tests run in the cloud) and the next command. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login. More: `ancha docs cloud`.\n\n## An app, not a command\n\nIf the AI feature lives inside an app (a web app or API server with its database, workers and scheduled jobs), don't wrap it in `agent.command`. Ancha starts the app once per attempt with `agent.start`, waits for `agent.ready_url`, delivers the tools' events to `agent.url`, and a scene's `world_rules.app_calls` call the app's own routes, such as its cron jobs, at a time. Read `ancha docs apps` before writing `ancha.yaml`. The start script gives the app a clean database, cache and seed every attempt: a new world has new URLs and tokens, and stale rows or sync cursors make an app silently do nothing.\n\n## More from production traces\n\n`ancha traces upload <file or folder> --json` sends the traces to the workspace, which rebuilds each one's world and checks, and writes each test to `scenes/from-traces/<name>/scene.yaml`: runs that went fine and runs that failed. `--from langfuse` or `--from langsmith` takes the newest traces there instead (`--limit`, `--since`), with the keys in this shell. For one trace of a failure, `--expect \"<what went wrong>\"` adds a check for it. A test lists the questions one trace cannot settle, each with the default it uses. Ask the user for the answers; don't guess them. Pass them with `ancha pull <test id> --answer <question>=<value>`. `ancha import --offline <trace file> --json` makes the tests on this computer instead, one per conversation, and uploads nothing; there, `--answer` and `--force` go on the import.\n\nA test from a run that failed should fail the same way production did. If it doesn't, run it on this computer: `ancha traces diff <trace file> latest` shows the calls production made and the attempt didn't, and the import also lists the app's own setup calls, which the start script or an `app_call` has to make.\n\nIf the user's workspace takes traces (their agents send them to it), each trace becomes a test there: `ancha pull --all --json` writes every test that is turned on (`--agent <name>` for one agent's), `ancha traces --failed --json` lists the ones where production failed a check, `ancha traces show <id> --json` previews the test, and `ancha pull <id> --json` writes one, with `--answer` for its questions. Checks you add to a pulled `scene.yaml` stay when you pull a newer version; any other edit stops the pull. More: `ancha docs traces`.\n\n## Other tests\n\nThe starter test `ancha init` writes when `scenes/` holds no tests only proves that the agent reaches each tool. For the agent's real job beyond its traces, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a test can make on it. More: `ancha docs scenes`.\n\n## The rule\n\nFix the agent, not the tests or their checks. `ancha.yaml` says how to start the agent and give it its task and keys: change it for that, never to make a check pass. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the tests, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach attempt gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task, and `ANCHA_TASK_FILE` names a file holding it. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: \"{{task}}\" }` (`{{task_file}}` for the file); `ancha init` writes that line when it finds the name.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\nThe agent's own keys are the names in `agent.pass_env` in `ancha.yaml`, such as `agent.pass_env: [OPENAI_API_KEY]`, and `agent.env` sets fixed values, such as the path of a key file. In the cloud each name comes from the workspace's secrets (`ancha secrets set NAME`). `ancha run --on local` starts the agent on this computer instead, with this computer's network and those names from this shell (or `--pass-env NAME`); `--on docker` seals it in a container (`agent.execution: { mode: container, image: node:24-slim }`, which needs Docker). An agent without its model key stops at its first model call.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain <run id> --json`.\n- Exit 2: usage, config, test file or authentication error, or a cancelled cloud run. `AUTH_INVALID` means `ancha login` again or a valid `ANCHA_API_KEY`; `CONFIG_INVALID` naming a workspace secret means `ancha secrets set NAME`. Read the `hint`.\n- Exit 3: infrastructure, or an attempt the harness couldn't run or grade. It counts as invalid, never as a failed check, so it's not the agent's fault; run again, and `ancha agent upload --json` if it repeats.\n- Exit 4, only with `--strict`: an endpoint coverage error or a verdict using simulated tool answers. The summary names the tests, trials and evaluated checks using those answers. `ancha explain` lists endpoint errors; `ancha twins coverage <tool>` shows the endpoint inventory.\n\nRead the error's stable `code` and `message`, then follow its `hint` when provided. More: `ancha docs`, `ancha docs <topic>` for setup, run, traces, explain, compare, scenes, integrations, cloud and playgrounds, and https://docs.ancha.io/coding-agents.\n\nTell the user what you ran, where it ran, the pass rate, the evidence and the result link. Never claim a fix until `ancha run --compare` exits 0.\n";
22188
22188
 
22189
22189
  // frontend/src/workspace-pages.ts
22190
22190
  var startSentence = "Set up Ancha for this agent: read https://app.ancha.io/llms.txt and follow its first steps.";
@@ -23118,6 +23118,10 @@ function shell(section, content) {
23118
23118
  const nav2 = (items) => items.map(([id, name]) => `<a href="/${id}" data-nav class="nav-item ${section === id ? "active" : ""}" ${section === id ? 'aria-current="page"' : ""}>${name}</a>`).join("");
23119
23119
  root.innerHTML = `<aside class="sidebar"><a href="/worlds" class="brand" data-nav>ancha</a><nav class="app-nav" aria-label="Main navigation">${nav2([["agents", "Agents"], ["playgrounds", "Runs"], ["worlds", "Worlds"], ["tools", "Tools"]])}</nav><div class="workspace"><span id="connection" class="connection warn" role="status"${failedProbes < 2 ? " hidden" : ""}>${failedProbes < 2 ? "" : "Can\u2019t reach the server. Retrying\u2026"}</span><a href="/help" data-nav>Help</a><a href="/settings" data-nav>Settings</a></div></aside><main id="main" tabindex="-1">${content}</main>`;
23120
23120
  }
23121
+ function folderWorlds(worlds2) {
23122
+ if (!worlds2.length) return "";
23123
+ return `<section class="k-card" aria-labelledby="folder-worlds-title"><div class="k-card-head"><h2 id="folder-worlds-title">World files in this folder</h2></div><div class="k-scroll" role="region" aria-label="World files in this folder" tabindex="0"><table class="k-table wide"><thead><tr><th scope="col">World</th><th scope="col">Tools</th><th scope="col" class="num">People</th></tr></thead><tbody>${worlds2.map((world) => `<tr><td><span class="k-name">${h(String(world.id))}</span><code class="worlds-path" title="${h(String(world.path))}">${h(String(world.path))}</code>${world.error ? `<p class="error">${h(String(world.error))}</p>` : ""}</td><td>${worldToolsCell(world)}</td><td class="num">${h(world.people ?? "\u2014")}</td></tr>`).join("")}</tbody></table></div></section>`;
23124
+ }
23121
23125
  function folderScenes(scenes) {
23122
23126
  if (!scenes.length) return "";
23123
23127
  return `<section class="k-card" aria-labelledby="folder-scenes-title"><div class="k-card-head"><h2 id="folder-scenes-title">Scenes in this folder</h2></div><div class="k-scroll" role="region" aria-label="Scenes in this folder" tabindex="0"><table class="k-table wide"><thead><tr><th scope="col">Scene</th><th scope="col">Tools</th><th scope="col">Path</th></tr></thead><tbody>${scenes.map((scene) => `<tr><td><a class="k-name" href="/worlds?scene=${enc2(String(scene.key))}" data-nav title="${h(String(scene.title || scene.id))}">${h(String(scene.title || scene.id))}</a></td><td>${worldToolIcons(scene)}</td><td><code class="worlds-path" title="${h(String(scene.path))}">${h(String(scene.path))}</code></td></tr>`).join("")}</tbody></table></div></section>`;
@@ -23234,7 +23238,7 @@ async function load() {
23234
23238
  const sampleRun = !p[1] && !ownAgents.length ? ((await api("/playgrounds")).runs ?? []).slice().sort((a, b) => String(a.createdAt).localeCompare(String(b.createdAt)))[0] : void 0;
23235
23239
  if (thisGeneration !== generation) return;
23236
23240
  if (!p[1]) {
23237
- document.querySelector("#worlds-page").innerHTML = (ownAgents.length ? "" : startCard(sampleRun?.id, Boolean(boot.hosted))) + worldsTable(worlds, worldTestCounts) + folderScenes(folder.scenes ?? []) + toolsCatalog(staticTools, Object.fromEntries(q), worlds);
23241
+ document.querySelector("#worlds-page").innerHTML = (ownAgents.length ? "" : startCard(sampleRun?.id, Boolean(boot.hosted))) + worldsTable(worlds, worldTestCounts) + folderWorlds(folder.worlds ?? []) + folderScenes(folder.scenes ?? []) + toolsCatalog(staticTools, Object.fromEntries(q), worlds);
23238
23242
  bindToolsCatalog();
23239
23243
  } else mountWorlds(document.querySelector("#worlds-page"), worlds, toolCatalog, p[1], api, go);
23240
23244
  }
package/lib/mcp-entry.mjs CHANGED
@@ -57450,6 +57450,9 @@ var NUMBER = new RegExp(
57450
57450
  "gu"
57451
57451
  );
57452
57452
  function readNumbers(text13) {
57453
+ return readNumberSpans(text13).map(({ start: _start, end: _end, ...number6 }) => number6);
57454
+ }
57455
+ function readNumberSpans(text13) {
57453
57456
  const numbers2 = [];
57454
57457
  for (const match of text13.normalize("NFKC").matchAll(NUMBER)) {
57455
57458
  const { open: open2, sign, before, minus, inner, digits, after, close } = match.groups;
@@ -57458,6 +57461,8 @@ function readNumbers(text13) {
57458
57461
  const negative = sign !== void 0 && sign !== "+" || minus !== void 0 || parenthesized && amount2;
57459
57462
  const value2 = Number(digits.replaceAll(",", ""));
57460
57463
  numbers2.push({
57464
+ start: match.index,
57465
+ end: match.index + match[0].length,
57461
57466
  value: negative && value2 !== 0 ? -value2 : value2,
57462
57467
  decimals: digits.split(".")[1]?.length ?? 0,
57463
57468
  text: match[0].trim(),
@@ -57468,7 +57473,8 @@ function readNumbers(text13) {
57468
57473
  }
57469
57474
  var AnswerNumberSchema = external_exports.strictObject({
57470
57475
  value: external_exports.union([external_exports.number(), external_exports.string().refine((text13) => readNumbers(text13).length === 1, 'a number, or one number written as text, e.g. "1,240.00" or "(300.00)"')]).describe('The number the answer must state: a number, or one number as text ("1,240.00") to keep its decimal places'),
57471
- tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)")
57476
+ tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)"),
57477
+ label: external_exports.string().trim().min(1).max(40).optional().describe("The name of this number, such as balance or credit limit; detects expected values stated under another label")
57472
57478
  });
57473
57479
  var texts = external_exports.union([external_exports.string().min(1), external_exports.array(external_exports.string().min(1)).min(1)]);
57474
57480
  var AnswerRowSchema = external_exports.record(external_exports.string().min(1), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()])).superRefine((row, ctx) => {
@@ -57498,6 +57504,7 @@ var AnswerCheckSchema = external_exports.strictObject({
57498
57504
  if (check3[key2] !== void 0) ctx.addIssue({ code: "custom", path: [key2], message: `rows is mutually exclusive with ${key2}` });
57499
57505
  }
57500
57506
  }).describe("Checks the agent's final answer (what it posts to ANCHA_DONE_URL, its HTTP reply, or what it prints on stdout): text and numbers, or exact structured rows");
57507
+ var CURRENCY_TOKEN = new RegExp(`^(?:${CURRENCY})$`, "iu");
57501
57508
 
57502
57509
  // packages/core/src/duration.ts
57503
57510
  var DURATION_RE = /^(-?)(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;